From ac70457dfda50cfbffb420906ec8a9a2735358de Mon Sep 17 00:00:00 2001 From: "Austin L." <86896075+rvnminers-A-and-N@users.noreply.github.com> Date: Fri, 3 Jul 2026 00:05:46 +0000 Subject: [PATCH] Add interactive 3D molecule structures to the workbench MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New /api/structure3d returns an RDKit-embedded 3D conformer (ETKDG + MMFF) as an SDF mol block; the workbench renders it interactively with 3Dmol.js (vendored, BSD-3-Clause, served locally so the demo stays self-contained — no CDN dependency, works air-gapped, consistent with the on-prem model). A 2D/3D toggle sits above the structure; 2D stays default, 3D shows a rotatable ball-and-stick model to spin/zoom. Toggle appears only when a 3D embed succeeds; degrades cleanly otherwise. Cited in docs/SOURCES.md + training/static/README.md. Signed-off-by: Austin L. <86896075+rvnminers-A-and-N@users.noreply.github.com> --- docs/SOURCES.md | 3 ++ training/app.py | 31 ++++++++++++++ training/static/3Dmol-min.js | 2 + training/static/3Dmol-min.js.LICENSE.txt | 5 +++ training/static/README.md | 10 +++++ training/workbench.html | 51 +++++++++++++++++++++++- 6 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 training/static/3Dmol-min.js create mode 100644 training/static/3Dmol-min.js.LICENSE.txt create mode 100644 training/static/README.md diff --git a/docs/SOURCES.md b/docs/SOURCES.md index 11db7b7..7b9f949 100644 --- a/docs/SOURCES.md +++ b/docs/SOURCES.md @@ -23,6 +23,9 @@ record of provenance, not legal advice. Get an IP/OSS-license review before ship - **PubChem / FDA SAF** — data sources for measured properties + GRAS; cited under *Data sources*. **Product / serving side** +- **3Dmol.js** (David Koes et al.) — interactive WebGL 3D viewer for the demo workbench; + renders the RDKit-embedded conformer from `/api/structure3d`. Vendored + served locally so + the demo stays self-contained. (BSD-3-Clause; see `training/static/README.md`.) - **ONNX** + **ONNX Runtime** — run taste models in-process in .NET. (MIT.) - **ASP.NET Core / .NET** — the app/API backbone. (MIT.) - **React** — frontend. (MIT.) diff --git a/training/app.py b/training/app.py index d71c541..1fd521c 100644 --- a/training/app.py +++ b/training/app.py @@ -145,6 +145,37 @@ def api_structure(q: Query): return {"svg": _svg(_resolve(q.smiles))} +@app.post("/api/structure3d") +def api_structure3d(q: Query): + """3D conformer as an SDF mol block — RDKit ETKDG embed + MMFF optimize. Rendered + interactively in the browser (3Dmol.js). {molblock: None} if a 3D embed isn't possible.""" + smi = _resolve(q.smiles) + mol = Chem.MolFromSmiles(smi) if smi else None + if mol is None: + return {"molblock": None} + try: + from rdkit.Chem import AllChem + mol = Chem.AddHs(mol) + params = AllChem.ETKDGv3() + params.randomSeed = 42 # deterministic conformer + if AllChem.EmbedMolecule(mol, params) != 0 and AllChem.EmbedMolecule(mol, AllChem.ETKDG()) != 0: + return {"molblock": None} # embedding failed (e.g. tricky cage/macrocycle) + try: + AllChem.MMFFOptimizeMolecule(mol) + except Exception: # noqa: BLE001 — no MMFF params for some atoms; unoptimized still fine + pass + return {"molblock": Chem.MolToMolBlock(mol)} + except Exception: # noqa: BLE001 — RDKit build without embedding etc.; degrade gracefully + return {"molblock": None} + + +@app.get("/static/3Dmol-min.js") +def _threedmol_js(): + """Serve the vendored 3Dmol.js (BSD-3-Clause) locally so the demo stays self-contained.""" + from fastapi.responses import FileResponse + return FileResponse("static/3Dmol-min.js", media_type="application/javascript") + + class MixtureQuery(BaseModel): ingredients: list[str] processes: list[str] = [] diff --git a/training/static/3Dmol-min.js b/training/static/3Dmol-min.js new file mode 100644 index 0000000..c63bd14 --- /dev/null +++ b/training/static/3Dmol-min.js @@ -0,0 +1,2 @@ +/*! For license information please see 3Dmol-min.js.LICENSE.txt */ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["3Dmol"]=e():t["3Dmol"]=e()}(this,(()=>(()=>{var __webpack_modules__={620:function(){"use strict";!function(t){if(t.TextEncoder&&t.TextDecoder)return!1;function e(t="utf-8"){if("utf-8"!==t)throw new RangeError(`Failed to construct 'TextEncoder': The encoding label provided ('${t}') is invalid.`)}function i(t="utf-8",e={fatal:!1}){if("utf-8"!==t)throw new RangeError(`Failed to construct 'TextDecoder': The encoding label provided ('${t}') is invalid.`);if(e.fatal)throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}Object.defineProperty(e.prototype,"encoding",{value:"utf-8"}),e.prototype.encode=function(t,e={stream:!1}){if(e.stream)throw new Error("Failed to encode: the 'stream' option is unsupported.");let i=0;const r=t.length;let s=0,n=Math.max(32,r+(r>>1)+7),a=new Uint8Array(n>>3<<3);for(;i=55296&&e<=56319){if(i=55296&&e<=56319)continue}if(s+4>a.length){n+=8,n*=1+i/t.length*2,n=n>>3<<3;const e=new Uint8Array(n);e.set(a),a=e}if(4294967168&e){if(4294965248&e)if(4294901760&e){if(4292870144&e)continue;a[s++]=e>>18&7|240,a[s++]=e>>12&63|128,a[s++]=e>>6&63|128}else a[s++]=e>>12&15|224,a[s++]=e>>6&63|128;else a[s++]=e>>6&31|192;a[s++]=63&e|128}else a[s++]=e}return a.slice(0,s)},Object.defineProperty(i.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(i.prototype,"fatal",{value:!1}),Object.defineProperty(i.prototype,"ignoreBOM",{value:!1}),i.prototype.decode=function(t,e={stream:!1}){if(e.stream)throw new Error("Failed to decode: the 'stream' option is unsupported.");const i=new Uint8Array(t);let r=0;const s=i.length,n=[];for(;r65535&&(e-=65536,n.push(e>>>10&1023|55296),e=56320|1023&e),n.push(e)}}else n.push(t)}return String.fromCharCode.apply(null,n)},t.TextEncoder=e,t.TextDecoder=i}("undefined"!=typeof window?window:"undefined"!=typeof self?self:this)},546:(t,e,i)=>{"use strict";i.r(e),i.d(e,{CustomLinear:()=>CustomLinear,Gradient:()=>Gradient,GradientType:()=>GradientType,ROYGB:()=>ROYGB,RWB:()=>RWB,Sinebow:()=>Sinebow,builtinGradients:()=>a,getGradient:()=>n,normalizeValue:()=>s});var r=i(222);class GradientType{}function s(t,e,i){return e>=t?(ie&&(i=e),{lo:t,hi:e,val:i}):(i>t&&(i=t),i=2?(this.max=t[1],this.min=t[0]):t&&e&&!Array.isArray(t)&&(this.min=t,this.max=e)}range(){return void 0!==this.min&&void 0!==this.max?[this.min,this.max]:null}valueToHex(t,e){var i,r;if(t=this.mult*t,e?(i=e[0],r=e[1]):(i=this.min,r=this.max),void 0===t)return 16777215;var n=s(i,r,t);i=n.lo;var a,o=((r=n.hi)+i)/2;return(t=n.val)<(o=e&&void 0!==e[2]?e[2]:void 0!==this.mid?this.mid:(i+r)/2)?16711680+256*(a=Math.floor(255*Math.sqrt((t-i)/(o-i))))+a:t>o?65536*(a=Math.floor(255*Math.sqrt(1-(t-o)/(r-o))))+256*a+255:16777215}}class ROYGB extends GradientType{constructor(t,e){super(),this.gradient="ROYGB",this.mult=1,this.min=t,this.max=e,void 0===e&&Array.isArray(t)&&t.length>=2?(this.max=t[1],this.min=t[0]):t&&e&&!Array.isArray(t)&&(this.min=t,this.max=e)}valueToHex(t,e){var i,r;if(t=this.mult*t,e?(i=e[0],r=e[1]):(i=this.min,r=this.max),void 0===t)return 16777215;var n=s(i,r,t),a=((i=n.lo)+(r=n.hi))/2,o=(i+a)/2,l=(a+r)/2;return(t=n.val)=2&&(this.max=t[1],this.min=t[0]),e=2?(this.max=t[1],this.min=t[0],s=e):(this.min=t,this.max=e,s=i),s)for(let t of s)this.colors.push(r.CC.color(t));else this.colors.push(r.CC.color(0))}range(){return void 0!==this.min&&void 0!==this.max?[this.min,this.max]:null}valueToHex(t,e){var i,n;if(e?(i=e[0],n=e[1]):(i=this.min,n=this.max),void 0===t)return 16777215;var a=s(i,n,t);i=a.lo,n=a.hi,t=a.val;let o=this.colors.length,l=(n-i)/o,h=Math.min(Math.floor((t-i)/l),o-1),c=Math.min(h+1,o-1),d=(t-i-h*l)/l,u=this.colors[h],f=this.colors[c];return new r.Color(u.r+d*(f.r-u.r),u.g+d*(f.g-u.g),u.b+d*(f.b-u.b)).getHex()}}const a={rwb:RWB,RWB,roygb:ROYGB,ROYGB,sinebow:Sinebow,linear:CustomLinear};class Gradient extends GradientType{valueToHex(t,e){return 0}range(){return null}}Gradient.RWB=RWB,Gradient.ROYGB=ROYGB,Gradient.Sinebow=Sinebow,Gradient.CustomLinear=CustomLinear,Gradient.builtinGradients=a,Gradient.normalizeValue=s,Gradient.getGradient=n},848:(t,e,i)=>{"use strict";i.r(e),i.d(e,{VolumeData:()=>VolumeData});var r=i(864),s=i(529),n=i(797),a=i(865),o=i(75);class VolumeData{constructor(t,e,i){if(this.unit={x:1,y:1,z:1},this.origin={x:0,y:0,z:0},this.size={x:0,y:0,z:0},this.data=new Float32Array([]),this.matrix=null,this.inversematrix=null,this.isbinary=new Set(["ccp4","CCP4"]),this.getCoordinates=function(t){var e=t/(this.size.y*this.size.z),i=t%(this.size.y*this.size.z),r=t%this.size.z;return e*=this.unit.x,i*=this.unit.y,r*=this.unit.z,{x:e+=this.origin.x,y:i+=this.origin.y,z:r+=this.origin.z}},this.vasp=function(t){var e=t.replace(/^\s+/,"").split(/[\n\r]/),i=(0,n.VASP)(t)[0].length;if(0==i)return console.warn("No good formating of CHG or CHGCAR file, not atomic information provided in the file."),void(this.data=[]);var r,a=1.889725992,o=parseFloat(e[1]);r=e[2].replace(/^\s+/,"").split(/\s+/);var l=new s.Vector3(parseFloat(r[0]),parseFloat(r[1]),parseFloat(r[2])).multiplyScalar(o*a);r=e[3].replace(/^\s+/,"").split(/\s+/);var h=new s.Vector3(parseFloat(r[0]),parseFloat(r[1]),parseFloat(r[2])).multiplyScalar(o*a);r=e[4].replace(/^\s+/,"").split(/\s+/);var c=new s.Vector3(parseFloat(r[0]),parseFloat(r[1]),parseFloat(r[2])).multiplyScalar(o*a),d=l.x*(h.y*c.z-c.y*h.z)-h.x*(l.y*c.z-c.y*l.z)+c.x*(l.y*h.z-h.y*l.z),u=1/(d=Math.abs(d)/Math.pow(a,3));e.splice(0,8+i+1);var f=e[0].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),p=Math.abs(parseFloat(f[0])),g=Math.abs(parseFloat(f[1])),m=Math.abs(parseFloat(f[2])),v=this.origin=new s.Vector3(0,0,0);this.size={x:p,y:g,z:m},this.unit=new s.Vector3(l.x,h.y,c.z),l=l.multiplyScalar(1/(a*p)),h=h.multiplyScalar(1/(a*g)),c=c.multiplyScalar(1/(a*m)),0==l.y&&0==l.z&&0==h.x&&0==h.z&&0==c.x&&0==c.y||(this.matrix=new s.Matrix4(l.x,h.x,c.x,0,l.y,h.y,c.y,0,l.z,h.z,c.z,0,0,0,0,1),this.matrix=this.matrix.multiplyMatrices(this.matrix,(new s.Matrix4).makeTranslation(v.x,v.y,v.z)),this.origin=new s.Vector3(0,0,0),this.unit=new s.Vector3(1,1,1)),e.splice(0,1);var _=e.join(" "),y=(_=_.replace(/^\s+/,"")).split(/[\s\r]+/);y.splice(p*g*m+1);for(var b=Float32Array.from(y,parseFloat),x=0;x=this.size.x||e<0||e>=this.size.y||i<0||i>=this.size.z?-1:t*this.size.y*this.size.z+e*this.size.z+i}getVal(t,e,i){let r=this.getIndex(t,e,i);return r<0?0:this.data[r]}cube(t){var e=t.split(/\r?\n/);if(!(e.length<6)){var i=(0,a.CUBE)(t,{}).modelData[0].cryst,r=e[2].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),s=parseFloat(r[0]),n=Math.abs(s);this.origin=i.origin,this.size=i.size,this.unit=i.unit,this.matrix=i.matrix4;var o=6;s<0&&o++;var l=e.splice(n+o).join(" "),h=(l=l.replace(/^\s+/,"")).split(/[\s\r]+/);this.data=Float32Array.from(h,parseFloat)}}ccp4(t){var e={};t=new Int8Array(t);var i=new Int32Array(t.buffer,0,56),r=new Float32Array(t.buffer,0,56),n=new DataView(t.buffer);if(e.MAP=String.fromCharCode(n.getUint8(208),n.getUint8(209),n.getUint8(210),n.getUint8(211)),e.MACHST=[n.getUint8(212),n.getUint8(213)],17===e.MACHST[0]&&17===e.MACHST[1])for(var a=t.byteLength,o=0;o{"use strict";var r;i.r(e),i.d(e,{BackSide:()=>n,Camera:()=>Camera,ClampToEdgeWrapping:()=>c,Coloring:()=>r,Cylinder:()=>M.Cylinder,DoubleSide:()=>a,EventDispatcher:()=>EventDispatcher,FloatType:()=>g,Fog:()=>Fog,FrontSide:()=>s,Geometry:()=>Geometry,GeometryGroup:()=>GeometryGroup,GeometryIDCount:()=>A,ImposterMaterial:()=>ImposterMaterial,InstancedMaterial:()=>InstancedMaterial,Light:()=>Light,Line:()=>Line,LineBasicMaterial:()=>LineBasicMaterial,LineStyle:()=>N,LinearFilter:()=>d,LinearMipMapLinearFilter:()=>f,Material:()=>Material,MaterialIdCount:()=>x,Matrix3:()=>l.Matrix3,Matrix4:()=>l.Matrix4,Mesh:()=>Mesh,MeshDoubleLambertMaterial:()=>MeshDoubleLambertMaterial,MeshLambertMaterial:()=>MeshLambertMaterial,MeshOutlineMaterial:()=>MeshOutlineMaterial,NearestFilter:()=>u,Object3D:()=>Object3D,Object3DIDCount:()=>C,Projector:()=>Projector,Quaternion:()=>l.Quaternion,R32Format:()=>_,RFormat:()=>v,RGBAFormat:()=>m,Ray:()=>l.Ray,Raycaster:()=>Raycaster,Renderer:()=>Renderer,Scene:()=>Scene,ShaderLib:()=>ct,ShaderUtils:()=>ut,Shading:()=>o,Sphere:()=>M.Sphere,SphereImposterMaterial:()=>SphereImposterMaterial,SphereImposterOutlineMaterial:()=>SphereImposterOutlineMaterial,Sprite:()=>Sprite,SpriteAlignment:()=>h,SpriteMaterial:()=>SpriteMaterial,SpritePlugin:()=>SpritePlugin,StickImposterMaterial:()=>StickImposterMaterial,StickImposterOutlineMaterial:()=>StickImposterOutlineMaterial,Texture:()=>Texture,TextureIdCount:()=>B,TextureOperations:()=>y,Triangle:()=>M.Triangle,UVMapping:()=>UVMapping,UnsignedByteType:()=>p,Vector2:()=>l.Vector2,Vector3:()=>l.Vector3,VolumetricMaterial:()=>VolumetricMaterial,basic:()=>V,clamp:()=>l.clamp,clone:()=>dt,conversionMatrix3:()=>l.conversionMatrix3,degToRad:()=>l.degToRad,instanced:()=>H,intersectObject:()=>U,lambert:()=>q,lambertdouble:()=>Z,outline:()=>K,screen:()=>Q,screenaa:()=>$,sphereimposter:()=>tt,sphereimposteroutline:()=>it,sprite:()=>rt,stickimposter:()=>at,stickimposteroutline:()=>ot,volumetric:()=>ht}),function(t){t[t.NoColors=0]="NoColors",t[t.FaceColors=1]="FaceColors",t[t.VertexColors=2]="VertexColors"}(r||(r={}));const s=0,n=1,a=2;var o;!function(t){t[t.NoShading=0]="NoShading",t[t.FlatShading=1]="FlatShading",t[t.SmoothShading=2]="SmoothShading"}(o||(o={}));var l=i(529);const h={topLeft:new l.Vector2(1,-1),topCenter:new l.Vector2(0,-1),topRight:new l.Vector2(-1,-1),centerLeft:new l.Vector2(1,0),center:new l.Vector2(0,0),centerRight:new l.Vector2(-1,0),bottomLeft:new l.Vector2(1,1),bottomCenter:new l.Vector2(0,1),bottomRight:new l.Vector2(-1,1)},c=1001,d=1006,u=1007,f=1008,p=1009,g=1010,m=1021,v=1022,_=1023;var y;!function(t){t[t.MultiplyOperation=0]="MultiplyOperation",t[t.MixOperation=1]="MixOperation",t[t.AddOperation=2]="AddOperation"}(y||(y={}));class EventDispatcher{constructor(){this.listeners={}}dispatchEvent(t){var e=this.listeners[t.type];if(void 0!==e){t.target=this;for(var i=0,r=e.length;i0?this.lineArray=(null==a?void 0:a.subarray(0,this.lineidx))||null:this.lineArray=new Uint16Array(0)):(this.normalArray=new Float32Array(0),this.faceArray=new Uint16Array(0),this.lineArray=new Uint16Array(0)),o&&(this.radiusArray=o.subarray(0,this.vertices)),e&&(this.normalArray&&(this.normalArray=new Float32Array(this.normalArray)),this.faceArray&&(this.faceArray=new Uint16Array(this.faceArray)),this.lineArray&&(this.lineArray=new Uint16Array(this.lineArray)),this.vertexArray&&(this.vertexArray=new Float32Array(this.vertexArray)),this.colorArray&&(this.colorArray=new Float32Array(this.colorArray)),this.radiusArray&&(this.radiusArray=new Float32Array(this.radiusArray))),this.__inittedArrays=!0}}class Geometry extends EventDispatcher{constructor(t=!1,e=!1,i=!1){super(),this.name="",this.hasTangents=!1,this.dynamic=!0,this.verticesNeedUpdate=!1,this.elementsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.buffersNeedUpdate=!1,this.imposter=!1,this.instanced=!1,this.geometryGroups=[],this.groups=0,this.id=A++,this.mesh=t,this.radii=e,this.offset=i}updateGeoGroup(t=0){var e,i=this.groups>0?this.geometryGroups[this.groups-1]:null;return(!i||i.vertices+t>((null===(e=null==i?void 0:i.vertexArray)||void 0===e?void 0:e.length)||0)/3)&&(i=this.addGeoGroup()),i}vrml(t,e){for(var i="",r=this.geometryGroups.length,s=0;st.distance-e.distance,T=new l.Matrix4;class Raycaster{constructor(t,e,i,r){this.precision=1e-4,this.linePrecision=.2,this.ray=new l.Ray(t,e),this.ray.direction.lengthSq()>0&&this.ray.direction.normalize(),this.near=r||0,this.far=i||1/0}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.ortho?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld)):(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,t.z),e.projectionMatrixInverse.getInverse(e.projectionMatrix),T.multiplyMatrices(e.matrixWorld,e.projectionMatrixInverse),this.ray.direction.applyProjection(T),this.ray.direction.sub(this.ray.origin).normalize())}intersectObjects(t,e){for(var i=[],r=0,s=e.length;rMath.min(Math.max(t,-1),1);var L=new M.Sphere,F=new M.Cylinder,I=new M.Triangle,O=new l.Vector3,D=new l.Vector3,k=new l.Vector3,R=new l.Vector3,P=new l.Vector3;function U(t,e,i,r){if(P.getPositionFromMatrix(t.matrixWorld),void 0===e.intersectionShape)return r;var s,n,a,o,l,h,c,d,u,f,p,g,m,v,_=e.intersectionShape,y=i.linePrecision,b=(y*=t.matrixWorld.getMaxScaleOnAxis())*y;if(void 0!==e.boundingSphere&&e.boundingSphere instanceof M.Sphere&&(L.copy(e.boundingSphere),L.applyMatrix4(t.matrixWorld),!i.ray.isIntersectionSphere(L)))return r;for(s=0,n=_.triangle.length;s=0)continue;if(O.subVectors(I.a,i.ray.origin),(c=a.dot(O)/o)<0)continue;D.copy(i.ray.direction).multiplyScalar(c).add(i.ray.origin),D.sub(I.a),k.copy(I.b).sub(I.a),R.copy(I.c).sub(I.a);var x=k.dot(R),w=k.lengthSq(),A=R.lengthSq();if((g=(w*D.dot(R)-x*D.dot(k))/(w*A-x*x))<0||g>1)continue;if((p=(D.dot(k)-g*x)/w)<0||p>1||p+g>1)continue;r.push({clickable:e,distance:c})}for(s=0,n=_.cylinder.length;sF.lengthSq()||g<0)continue;r.push({clickable:e,distance:c})}}for(s=0,n=_.line.length;s 0.0) {\n vec4 unadjusted = projectionMatrix*modelViewMatrix * vec4( position, 1.0 );\n float w = outpos.w;\n //normalize homogeneous coords\n unadjusted /= unadjusted.w;\n outpos /= outpos.w;\n vec2 diff = outpos.xy-unadjusted.xy;\n //put into pixels\n diff.x *= vWidth;\n diff.y *= vHeight;\n if ( length(diff) > outlineMaxPixels) {\n vec2 ndiff = normalize(diff)*outlineMaxPixels;\n ndiff.x /= vWidth;\n ndiff.y /= vHeight;\n outpos.xy = unadjusted.xy;\n outpos.xy += ndiff;\n }\n outpos *= w; //if I don't do this things blow up\n }\n gl_Position = outpos;\n mvPosition.z -= outlinePushback; //go backwards in model space\n vec4 pushpos = projectionMatrix*mvPosition; //project to get z in projection space, I'm probably missing some simple math to do the same thing..\n gl_Position.z = gl_Position.w*pushpos.z/pushpos.w;\n}\n\n".replace("#define GLSLIFY 1",""),uniforms:X},Q={fragmentShader:"uniform sampler2D colormap;\nvarying highp vec2 vTexCoords;\nuniform vec2 dimensions;\n//DEFINEFRAGCOLOR\nvoid main (void) {\n gl_FragColor = texture2D(colormap, vTexCoords);\n\n //gl_FragColor.g = gl_FragColor.b = gl_FragColor.r; //debug shading \n}\n ".replace("#define GLSLIFY 1",""),vertexShader:"attribute vec2 vertexPosition;\nvarying highp vec2 vTexCoords;\nconst vec2 scale = vec2(0.5, 0.5);\n\nvoid main() {\n vTexCoords = vertexPosition * scale + scale; // scale vertex attribute to [0,1] range\n gl_Position = vec4(vertexPosition, 0.0, 1.0);\n}\n ".replace("#define GLSLIFY 1",""),uniforms:{}},$={fragmentShader:"uniform highp sampler2D colormap;\nvarying highp vec2 vTexCoords;\n\n\n// Basic FXAA implementation based on the code on geeks3d.com \n#define FXAA_REDUCE_MIN (1.0/ 128.0)\n#define FXAA_REDUCE_MUL (1.0 / 8.0)\n#define FXAA_SPAN_MAX 8.0\n\n\nvec4 applyFXAA(vec2 fragCoord, highp sampler2D tex)\n{\n vec4 color;\n ivec2 dim = textureSize(tex,0);\n vec2 dimensions = vec2(float(dim.x),float(dim.y));\n vec2 inverseVP = vec2(1.0 / dimensions.x, 1.0 / dimensions.y);\n vec4 rgbNW = texture2D(tex, fragCoord + vec2(-1.0, -1.0) * inverseVP);\n vec4 rgbNE = texture2D(tex, fragCoord + vec2(1.0, -1.0) * inverseVP);\n vec4 rgbSW = texture2D(tex, fragCoord + vec2(-1.0, 1.0) * inverseVP);\n vec4 rgbSE = texture2D(tex, fragCoord + vec2(1.0, 1.0) * inverseVP);\n vec4 rgbM = texture2D(tex, fragCoord );\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW.xyz, luma);\n float lumaNE = dot(rgbNE.xyz, luma);\n float lumaSW = dot(rgbSW.xyz, luma);\n float lumaSE = dot(rgbSE.xyz, luma);\n float lumaM = dot(rgbM.xyz, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n\n vec4 rgbA = 0.5 * (\n texture2D(tex, fragCoord + dir * (1.0 / 3.0 - 0.5)) +\n texture2D(tex, fragCoord + dir * (2.0 / 3.0 - 0.5)));\n vec4 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord + dir * -0.5) +\n texture2D(tex, fragCoord + dir * 0.5));\n\n float lumaB = dot(rgbB.xyz, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = rgbA;\n else\n color = rgbB;\n\n return color;\n}\n\n\n//DEFINEFRAGCOLOR\nvoid main (void) {\n ivec2 dim = textureSize(colormap,0);\n\n gl_FragColor = applyFXAA(vTexCoords, colormap);\n}\n ".replace("#define GLSLIFY 1",""),vertexShader:"attribute vec2 vertexPosition;\nvarying highp vec2 vTexCoords;\nconst vec2 scale = vec2(0.5, 0.5);\n\nvoid main() {\n vTexCoords = vertexPosition * scale + scale; // scale vertex attribute to [0,1] range\n gl_Position = vec4(vertexPosition, 0.0, 1.0);\n}\n ".replace("#define GLSLIFY 1",""),uniforms:{}},J={opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}},tt={vertexShader:"uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 directionalLightColor[ 1 ];\nuniform vec3 directionalLightDirection[ 1 ];\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\n\nvarying vec2 mapping;\nvarying vec3 vColor;\nvarying float rval;\nvarying vec3 vLight;\nvarying vec3 center;\n\nvoid main() {\n\n vColor = color;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n center = mvPosition.xyz;\n vec4 projPosition = projectionMatrix * mvPosition;\n vec4 adjust = projectionMatrix* vec4(normal,0.0); adjust.z = 0.0; adjust.w = 0.0;\n vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );\n vLight = normalize( lDirection.xyz );\n mapping = normal.xy;\n rval = abs(normal.x);\n gl_Position = projPosition+adjust;\n\n}\n".replace("#define GLSLIFY 1",""),fragmentShader:"\nuniform mat4 viewMatrix;\nuniform float opacity;\nuniform mat4 projectionMatrix;\n\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\nuniform float uDepth;\nuniform vec3 directionalLightColor[ 1 ];\n\nvarying vec3 vColor;\nvarying vec2 mapping;\nvarying float rval;\nvarying vec3 vLight;\nvarying vec3 center;\n\n#ifdef SHADED\nuniform highp sampler2D shading;\n#endif\n\n//DEFINEFRAGCOLOR\n\nvoid main() {\n float lensqr = dot(mapping,mapping);\n float rsqr = rval*rval;\n if(lensqr > rsqr)\n discard;\n float z = sqrt(rsqr-lensqr);\n vec3 cameraPos = center+ vec3(mapping.x,mapping.y,z);\n vec4 clipPos = projectionMatrix * vec4(cameraPos, 1.0);\n float ndcDepth = clipPos.z / clipPos.w;\n gl_FragDepthEXT = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;\n vec3 norm = normalize(vec3(mapping.x,mapping.y,z));\n float dotProduct = dot( norm, vLight );\n vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n vec3 vLight = directionalLightColor[ 0 ] * directionalLightWeighting;\n vec3 color = vLight*vColor;\n#ifdef SHADED\n ivec2 dim = textureSize(shading,0);\n float shadowFactor = texture2D(shading,vec2(gl_FragCoord.x/float(dim.x),gl_FragCoord.y/float(dim.y))).r;\n color *= shadowFactor;\n#endif \n gl_FragColor = vec4(color, opacity*opacity );\n float fogFactor = smoothstep( fogNear, fogFar, gl_FragDepthEXT/gl_FragCoord.w );\n gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n\n".replace("#define GLSLIFY 1",""),uniforms:J},et={opacity:{type:"f",value:1},outlineColor:{type:"c",value:new b.Color(0,0,0)},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},outlineWidth:{type:"f",value:.1},outlinePushback:{type:"f",value:1},outlineMaxPixels:{type:"f",value:0}},it={fragmentShader:"\n\nuniform float opacity;\nuniform vec3 outlineColor;\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\nuniform mat4 projectionMatrix;\nvarying vec2 mapping;\nvarying float rval;\nvarying vec3 center;\n\nuniform float outlinePushback;\n\n//DEFINEFRAGCOLOR\n\nvoid main() {\n float lensqr = dot(mapping,mapping);\n float rsqr = rval*rval;\n if(lensqr > rsqr)\n discard;\n float z = sqrt(rsqr-lensqr);\n vec3 cameraPos = center+ vec3(mapping.x,mapping.y,z-outlinePushback);\n vec4 clipPos = projectionMatrix * vec4(cameraPos, 1.0);\n float ndcDepth = clipPos.z / clipPos.w;\n gl_FragDepthEXT = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;\n gl_FragColor = vec4(outlineColor, 1 );\n}\n\n\n".replace("#define GLSLIFY 1",""),vertexShader:"\n\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float outlineWidth;\nuniform float outlinePushback;\nuniform float outlineMaxPixels;\nuniform float vWidth;\nuniform float vHeight;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\n\nvarying vec2 mapping;\nvarying float rval;\nvarying vec3 center;\n\nvoid main() {\n\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n center = mvPosition.xyz;\n vec4 projPosition = projectionMatrix * mvPosition;\n vec2 norm = normal.xy + vec2(sign(normal.x)*outlineWidth,sign(normal.y)*outlineWidth);\n\n vec4 adjust = projectionMatrix* vec4(norm,normal.z,1.0); \n mapping = norm.xy;\n rval = abs(norm.x);\n gl_Position = projPosition+vec4(adjust.xy,0.0,0.0);\n\n if(outlineMaxPixels > 0.0) {\n vec4 unadjusted = projectionMatrix*vec4(center.x+normal.x, center.y,center.z,1.0); \n vec4 ccoord = projectionMatrix*vec4(center.xyz,1.0);\n adjust = projectionMatrix* vec4(center.x+norm.x,center.y,center.z,1.0); \n //subtract center \n unadjusted.xyz -= ccoord.xyz;\n adjust.xyz -= ccoord.xyz;\n unadjusted /= unadjusted.w;\n adjust /= adjust.w;\n float diff = abs(adjust.x-unadjusted.x);\n diff *= vWidth;\n if(diff > outlineMaxPixels) {\n \n float fixlen = abs(unadjusted.x) + outlineMaxPixels/vWidth;\n //adjsut reval by ratio of lengths\n rval *= fixlen/abs(adjust.x);\n }\n\n }\n}\n\n".replace("#define GLSLIFY 1",""),uniforms:et},rt={fragmentShader:"\n\nuniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\n\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\n\nvarying vec2 vUV;\n//DEFINEFRAGCOLOR\n\nvoid main() {\n\n vec4 texture = texture2D(map, vUV);\n\n if (texture.a <= alphaTest) discard;\n\n gl_FragColor = vec4(color * texture.xyz, texture.a * opacity);\n\n if (fogType > 0) {\n\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n float fogFactor = 0.0;\n\n if (fogType == 1) {\n fogFactor = smoothstep(fogNear, fogFar, depth);\n }\n\n else {\n const float LOG2 = 1.442695;\n float fogFactor = exp2(- fogDensity * fogDensity * depth * depth * LOG2);\n fogFactor = 1.0 - clamp(fogFactor, 0.0, 1.0);\n }\n\n gl_FragColor = mix(gl_FragColor, vec4(fogColor, gl_FragColor.w), fogFactor);\n\n }\n}\n\n".replace("#define GLSLIFY 1",""),vertexShader:"\n\nuniform int useScreenCoordinates;\nuniform vec3 screenPosition;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\n\nattribute vec2 position;\nattribute vec2 uv;\n\nvarying vec2 vUV;\n\nvoid main() {\n\n vUV = uvOffset + uv * uvScale;\n\n vec2 alignedPosition = position + alignment;\n\n vec2 rotatedPosition;\n rotatedPosition.x = ( cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y ) * scale.x;\n rotatedPosition.y = ( sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y ) * scale.y;\n\n vec4 finalPosition;\n\n if(useScreenCoordinates != 0) {\n finalPosition = vec4(screenPosition.xy + rotatedPosition, screenPosition.z, 1.0);\n }\n\n else {\n finalPosition = projectionMatrix * modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); finalPosition /= finalPosition.w;\n finalPosition.xy += rotatedPosition; \n }\n\n gl_Position = finalPosition;\n\n}\n\n".replace("#define GLSLIFY 1",""),uniforms:{}},st={opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}},nt="uniform float opacity;\nuniform mat4 projectionMatrix;\n\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n\nvarying vec3 vLight;\nvarying vec3 vColor;\nvarying vec3 cposition;\nvarying vec3 p1;\nvarying vec3 p2;\nvarying float r;\n\n#ifdef SHADED\nuniform highp sampler2D shading;\n#endif\n\n//DEFINEFRAGCOLOR\n\n//cylinder-ray intersection testing taken from http://mrl.nyu.edu/~dzorin/cg05/lecture12.pdf\n//also useful: http://stackoverflow.com/questions/9595300/cylinder-impostor-in-glsl\n//with a bit more care (caps) this could be a general cylinder imposter (see also outline)\nvoid main() {\n vec3 color = abs(vColor);\n vec3 pos = cposition;\n vec3 p = pos; //ray point\n vec3 v = vec3(0.0,0.0,-1.0); //ray normal - orthographic\n if(projectionMatrix[3][3] == 0.0) v = normalize(pos); //ray normal - perspective\n vec3 pa = p1; //cyl start\n vec3 va = normalize(p2-p1); //cyl norm\n vec3 tmp1 = v-(dot(v,va)*va);\n vec3 deltap = p-pa;\n float A = dot(tmp1,tmp1);\n if(A == 0.0) discard;\n vec3 tmp2 = deltap-(dot(deltap,va)*va);\n float B = 2.0*dot(tmp1, tmp2);\n float C = dot(tmp2,tmp2)-r*r;\n//quadratic equation!\n float det = (B*B) - (4.0*A*C);\n if(det < 0.0) discard;\n float sqrtDet = sqrt(det);\n float posT = (-B+sqrtDet)/(2.0*A);\n float negT = (-B-sqrtDet)/(2.0*A);\n float intersectionT = min(posT,negT);\n vec3 qi = p+v*intersectionT;\n float dotp1 = dot(va,qi-p1);\n float dotp2 = dot(va,qi-p2);\n vec3 norm;\n if( dotp1 < 0.0 || dotp2 > 0.0) { //(p-c)^2 + 2(p-c)vt +v^2+t^2 - r^2 = 0\n vec3 cp;\n if( dotp1 < 0.0) { \n// if(vColor.x < 0.0 ) discard; //color sign bit indicates if we should cap or not\n cp = p1;\n } else {\n// if(vColor.y < 0.0 ) discard;\n cp = p2;\n }\n vec3 diff = p-cp;\n A = dot(v,v);\n B = dot(diff,v)*2.0;\n C = dot(diff,diff)-r*r;\n det = (B*B) - (4.0*C);\n if(det < 0.0) discard;\n sqrtDet = sqrt(det);\n posT = (-B+sqrtDet)/(2.0);\n negT = (-B-sqrtDet)/(2.0);\n float t = min(posT,negT);\n qi = p+v*t; \n norm = normalize(qi-cp); \n } else {\n norm = normalize(qi-(dotp1*va + p1));\n }\n vec4 clipPos = projectionMatrix * vec4(qi, 1.0);\n float ndcDepth = clipPos.z / clipPos.w;\n float depth = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;\n gl_FragDepthEXT = depth;",at={fragmentShader:[nt," float dotProduct = dot( norm, vLight );\n vec3 light = vec3( max( dotProduct, 0.0 ) );\n color *= light;\n#ifdef SHADED\n ivec2 dim = textureSize(shading,0);\n float shadowFactor = texture2D(shading,vec2(gl_FragCoord.x/float(dim.x),gl_FragCoord.y/float(dim.y))).r;\n color *= shadowFactor;\n#endif \n gl_FragColor = vec4(color, opacity*opacity );\n float fogFactor = smoothstep( fogNear, fogFar, depth );\n gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}"].join("\n"),vertexShader:"\n\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 directionalLightColor[ 1 ];\nuniform vec3 directionalLightDirection[ 1 ];\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute float radius;\n\nvarying vec3 vColor;\nvarying vec3 vLight;\nvarying vec3 cposition;\nvarying vec3 p1;\nvarying vec3 p2;\nvarying float r;\n\nvoid main() {\n\n vColor = color; vColor.z = abs(vColor.z); //z indicates which vertex and so would vary\n r = abs(radius);\n vec4 to = modelViewMatrix*vec4(normal, 1.0); //normal is other point of cylinder\n vec4 pt = modelViewMatrix*vec4(position, 1.0);\n vec4 mvPosition = pt;\n p1 = pt.xyz; p2 = to.xyz;\n vec3 norm = to.xyz-pt.xyz;\n float mult = 1.1; //slop to account for perspective of sphere\n if(length(p1) > length(p2)) { //billboard at level of closest point\n mvPosition = to;\n }\n vec3 n = normalize(mvPosition.xyz);\n bool isperspective = (projectionMatrix[3][3] == 0.0);\n//intersect with the plane defined by the camera looking at the billboard point\n if(color.z >= 0.0) { //p1\n if(isperspective) { //perspective\n vec3 pnorm = normalize(p1);\n float t = dot(mvPosition.xyz-p1,n)/dot(pnorm,n);\n mvPosition.xyz = p1+t*pnorm; \n } else { //orthographic\n mvPosition.xyz = p1;\n }\n } else {\n if(isperspective) { //perspective\n vec3 pnorm = normalize(p2);\n float t = dot(mvPosition.xyz-p2,n)/dot(pnorm,n);\n mvPosition.xyz = p2+t*pnorm;\n } else { //orthographic\n mvPosition.xyz = p2;\n } \n mult *= -1.0;\n }\n\n if(isperspective) { //perspective\n vec3 cr = normalize(cross(mvPosition.xyz,norm))*radius;\n vec3 doublecr = normalize(cross(mvPosition.xyz,cr))*radius;\n mvPosition.xyz += mult*(cr + doublecr).xyz;\n } else {\n vec3 cr = normalize(cross(vec3(0.0,0.0,-1.0),norm))*radius;\n vec3 doublecr = normalize(cross(vec3(0.0,0.0,-1.0),cr))*radius;\n mvPosition.xyz += mult*(cr + doublecr).xyz; \n }\n\n cposition = mvPosition.xyz;\n gl_Position = projectionMatrix * mvPosition;\n vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );\n vLight = normalize( lDirection.xyz )*directionalLightColor[0]; //not really sure this is right, but color is always white so..\n}\n\n",uniforms:st},ot={fragmentShader:nt+"gl_FragColor = vec4(color,1.0);}",vertexShader:"\n\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 directionalLightColor[ 1 ];\nuniform vec3 directionalLightDirection[ 1 ];\nuniform vec3 outlineColor;\nuniform float outlineWidth;\nuniform float outlinePushback;\nuniform float outlineMaxPixels;\nuniform float vWidth;\nuniform mat4 projinv;\n\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute float radius;\n\nvarying vec3 vColor;\nvarying vec3 vLight;\nvarying vec3 cposition;\nvarying vec3 p1;\nvarying vec3 p2;\nvarying float r;\n\nvoid main() {\n\n vColor = outlineColor;\n float rad = radius+sign(radius)*outlineWidth;\n r = abs(rad);\n\n vec4 to = modelViewMatrix*vec4(normal, 1.0); //normal is other point of cylinder\n vec4 pt = modelViewMatrix*vec4(position, 1.0);\n//pushback\n float scale = 1.0;\n if(projectionMatrix[3][3] != 0.0) { //orthographic\n to.z -= outlinePushback;\n pt.z -= outlinePushback;\n } else { //perspective\n vec4 midbefore = pt;\n if(length(to.xyz) < length(pt)) {\n midbefore = to;\n }\n vec4 midafter = midbefore;\n midafter.xyz += normalize(midbefore.xyz)*outlinePushback;\n\n to.xyz += normalize(to.xyz)*outlinePushback;\n pt.xyz += normalize(pt.xyz)*outlinePushback;\n\n //figure out a scaling factor for radius to account for perspective setback\n vec4 midbeforer = vec4(midbefore.x+rad,midbefore.y, midbefore.z, midbefore.w);\n vec4 midafterr = vec4(midafter.x+rad,midafter.y, midafter.z, midafter.w);\n\n vec4 mb = projectionMatrix*midbefore;\n vec4 mbr = projectionMatrix*midbeforer;\n vec4 ma = projectionMatrix*midafter;\n vec4 mar = projectionMatrix*midafterr;\n mb /= mb.w;\n mbr /= mbr.w;\n ma /= ma.w;\n mar /= mar.w;\n scale = abs((mbr.x-mb.x)/(mar.x-ma.x));\n rad *= scale;\n r = abs(rad);\n }\n vec4 mvPosition = pt;\n p1 = pt.xyz; p2 = to.xyz;\n vec3 norm = to.xyz-pt.xyz;\n float mult = 1.1; //slop to account for perspective of sphere\n if(length(p1) > length(p2)) { //billboard at level of closest point\n mvPosition = to;\n }\n\n vec3 n = normalize(mvPosition.xyz);\n//intersect with the plane defined by the camera looking at the billboard point\n if(color.z >= 0.0) { //p1\n vec3 pnorm = normalize(p1);\n float t = dot(mvPosition.xyz-p1,n)/dot(pnorm,n);\n mvPosition.xyz = p1+t*pnorm;\n } else {\n vec3 pnorm = normalize(p2);\n float t = dot(mvPosition.xyz-p2,n)/dot(pnorm,n);\n mvPosition.xyz = p2+t*pnorm;\n mult *= -1.0;\n }\n\n if(outlineMaxPixels > 0.0) {\n vec4 cpos = mvPosition;\n vec4 unadjusted = projectionMatrix*vec4(cpos.x+abs(scale*radius), cpos.y,cpos.z,cpos.w); \n vec4 ccoord = projectionMatrix*cpos;\n vec4 adjust = projectionMatrix*vec4(cpos.x+r,cpos.y,cpos.z,cpos.w); \n unadjusted /= unadjusted.w;\n adjust /= adjust.w;\n unadjusted.xyz -= ccoord.xyz/ccoord.w;\n adjust.xyz -= ccoord.xyz/ccoord.w;\n float diff = abs(adjust.x-unadjusted.x);\n diff *= vWidth; //this should now be in pixels\n if(diff > outlineMaxPixels) {\n float fixlen = abs(unadjusted.x) + outlineMaxPixels/vWidth; \n vec4 pcoord = ccoord;\n pcoord.x += fixlen*pcoord.w;\n vec4 altc = projinv*pcoord;\n r= abs(altc.x-cpos.x);\n }\n }\n\n vec3 cr = normalize(cross(mvPosition.xyz,norm))*rad;\n vec3 doublecr = normalize(cross(mvPosition.xyz,cr))*rad;\n mvPosition.xy += mult*(cr + doublecr).xy;\n cposition = mvPosition.xyz;\n gl_Position = projectionMatrix * mvPosition;\n vLight = vec3(1.0,1.0,1.0);\n}\n\n",uniforms:{opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},outlineColor:{type:"c",value:new b.Color(0,0,0)},outlineWidth:{type:"f",value:.1},outlinePushback:{type:"f",value:1},outlineMaxPixels:{type:"f",value:0},projinv:{type:"mat4",value:[]}}},lt={opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},data:{type:"i",value:3},colormap:{type:"i",value:4},depthmap:{type:"i",value:5},step:{type:"f",value:1},maxdepth:{type:"f",value:100},subsamples:{type:"f",value:5},textmat:{type:"mat4",value:[]},projinv:{type:"mat4",value:[]},transfermin:{type:"f",value:-.2},transfermax:{type:"f",value:.2}},ht={fragmentShader:"\nuniform highp sampler3D data;\nuniform highp sampler2D colormap;\nuniform highp sampler2D depthmap;\n\n\nuniform mat4 textmat;\nuniform mat4 projinv;\nuniform mat4 projectionMatrix;\n\nuniform float step;\nuniform float subsamples;\nuniform float maxdepth;\nuniform float transfermin;\nuniform float transfermax;\nin vec4 mvPosition;\nout vec4 color;\nvoid main(void) {\n\n vec4 pos = mvPosition;\n bool seengood = false;\n float i = 0.0;\n color = vec4(1,1,1,0);\n float increment = 1.0/subsamples;\n float maxsteps = (maxdepth*subsamples/step);\n//there's probably a better way to do this..\n//calculate farthest possible point in model coordinates\n vec4 maxpos = vec4(pos.x,pos.y,pos.z-maxdepth,1.0);\n// convert to projection\n maxpos = projectionMatrix*maxpos;\n vec4 startp = projectionMatrix*pos;\n// homogonize\n maxpos /= maxpos.w;\n startp /= startp.w;\n//take x,y from start and z from max\n maxpos = vec4(startp.x,startp.y,maxpos.z,1.0);\n//convert back to model space\n maxpos = projinv*maxpos;\n maxpos /= maxpos.w;\n float incr = step/subsamples;\n//get depth from depthmap\n//startp is apparently [-1,1]\n vec2 tpos = startp.xy/2.0+0.5;\n float depth = texture(depthmap, tpos).r;\n//compute vector between start and end\n vec4 direction = maxpos-pos;\n for( i = 0.0; i <= maxsteps; i++) {\n vec4 pt = (pos+(i/maxsteps)*direction);\n vec4 ppt = projectionMatrix*pt;\n float ptdepth = ppt.z/ppt.w;\n ptdepth = ((gl_DepthRange.diff * ptdepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;\n if(ptdepth > depth) break;\n pt = textmat*pt;\n// pt /= pt.w;\n if(pt.x >= -0.01 && pt.y >= -0.01 && pt.z >= -0.01 && pt.x <= 1.01 && pt.y <= 1.01 && pt.z <= 1.01) {\n seengood = true;\n } else if(seengood) {\n break;\n }\n if( pt.x < -0.01 || pt.x > 1.01 || pt.y < -0.01 || pt.y > 1.01 || pt.z < -0.01 || pt.z > 1.01 ){\n color.a = 0.0;\n continue;\n }\n else {\n float val = texture(data, pt.zyx).r;\n if(isinf(val)) continue; //masked out\n float cval = (val-transfermin)/(transfermax-transfermin); //scale to texture 0-1 range\n vec4 val_color = texture(colormap, vec2(cval,0.5));\n color.rgb = color.rgb*color.a + (1.0-color.a)*val_color.a*val_color.rgb;\n color.a += (1.0 - color.a) * val_color.a; \n if(color.a > 0.0) color.rgb /= color.a;\n// color = vec4(pt.x, pt.y, pt.z, 1.0);\n }\n// color = vec4(pt.x, pt.y, pt.z, 0.0)\n }\n}\n\n ".replace("#define GLSLIFY 1",""),vertexShader:"uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\n\nin vec3 position;\nout vec4 mvPosition;\nvoid main() {\n\n mvPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix*mvPosition;\n}\n".replace("#define GLSLIFY 1",""),uniforms:lt},ct={basic:V,blur:{fragmentShader:"const float INV_TOTAL_SAMPLES_FACTOR = 1.0 / 9.0;\nuniform highp sampler2D inTex;\nvarying highp vec2 vTexCoords;\n \nvoid main() {\n \n vec2 texelSize = 1.0 / vec2(textureSize(inTex,0));\n float blurred_visibility_factor = 0.0f;\n for (int t = -1; t <= 1; ++t) {\n for (int s = -1; s <= 1; ++s) {\n vec2 offset = vec2(float(s), float(t)) * texelSize;\n blurred_visibility_factor += texture2D(inTex, vTexCoords + offset).r;\n }\n }\n \n gl_FragDepthEXT = blurred_visibility_factor * INV_TOTAL_SAMPLES_FACTOR;\n \n}",vertexShader:"attribute vec2 vertexPosition;\nvarying highp vec2 vTexCoords;\nconst vec2 scale = vec2(0.5, 0.5);\n\nvoid main() {\n vTexCoords = vertexPosition * scale + scale; // scale vertex attribute to [0,1] range\n gl_Position = vec4(vertexPosition, 0.0, 1.0);\n}\n ",uniforms:{}},instanced:H,lambert:q,lambertdouble:Z,outline:K,screen:Q,screenaa:$,ssao:{fragmentShader:"uniform sampler2D depthmap;\nvarying highp vec2 vTexCoords;\nuniform float vWidth;\nuniform float vHeight;\nuniform float total_strength;\nuniform float radius;\nuniform mat4 projinv;\nuniform mat4 projectionMatrix;\n\n//code for pseudorandom vector from chatgpt\nfloat hash(vec3 p) {\n p = fract(p * vec3(0.1031, 0.1030, 0.0973));\n p += dot(p, p.yzx + 33.33);\n return fract((p.x + p.y) * p.z);\n}\n\n// Generate a pseudorandom vec3 from a seed vec3\nvec3 pseudorandomVec3(vec3 seed) {\n vec3 randomVec;\n randomVec.x = hash(seed);\n randomVec.y = hash(seed + vec3(1.0, 0.0, 17.1));\n randomVec.z = hash(seed + vec3(0.0, 13.23, 0.0));\n return randomVec;\n}\n\nvoid main(void)\n{ \n const float base = 0.2;\n const float area = 0.75;\n const int cycles = 1;\n\n const int samples = 64;\n vec3 sample_sphere[64] = vec3[](\n vec3(0.091258,-0.510164,0.000000),\n vec3(-0.204347,-0.872967,0.187199),\n vec3(0.009690,-0.263696,-0.110414),\n vec3(0.175208,-0.563987,0.228527),\n vec3(-0.001824,-0.003113,-0.000323),\n vec3(0.411134,-0.719869,-0.261530),\n vec3(-0.074272,-0.377368,0.276290),\n vec3(-0.147773,-0.381587,-0.284529),\n vec3(0.173317,-0.199635,0.063295),\n vec3(-0.186452,-0.199460,0.076965),\n vec3(0.143985,-0.308160,-0.307687),\n vec3(0.053194,-0.148286,0.169589),\n vec3(-0.547656,-0.486476,-0.317378),\n vec3(0.020804,-0.015092,-0.004574),\n vec3(-0.038006,-0.043165,0.054059),\n vec3(-0.094795,-0.443908,-0.731525),\n vec3(0.547552,-0.396466,0.461477),\n vec3(-0.176886,-0.089989,0.007315),\n vec3(0.074401,-0.048840,-0.074039),\n vec3(-0.008240,-0.075697,0.178197),\n vec3(-0.307880,-0.185053,-0.368943),\n vec3(0.309520,-0.108483,0.041646),\n vec3(-0.773478,-0.292946,0.538166),\n vec3(0.184487,-0.231594,-0.820065),\n vec3(0.207318,-0.100531,0.361797),\n vec3(-0.173306,-0.037737,-0.055289),\n vec3(0.548102,-0.105342,-0.253237),\n vec3(-0.119342,-0.043907,0.285162),\n vec3(-0.270247,-0.087861,-0.751357),\n vec3(0.449312,-0.039777,0.236146),\n vec3(-0.743773,-0.036095,0.196056),\n vec3(0.148819,-0.004300,-0.231448),\n vec3(0.008773,0.000809,0.051047),\n vec3(-0.461467,0.027390,-0.357386),\n vec3(0.169626,0.013338,-0.014053),\n vec3(-0.043786,0.007095,0.047331),\n vec3(0.004821,0.140371,-0.988260),\n vec3(0.092402,0.023994,0.101860),\n vec3(-0.295335,0.061530,-0.027372),\n vec3(0.024903,0.007537,-0.018901),\n vec3(-0.081463,0.125402,0.447794),\n vec3(-0.397119,0.231805,-0.631062),\n vec3(0.163853,0.059014,0.044905),\n vec3(-0.495220,0.214357,0.254139),\n vec3(0.306123,0.373687,-0.825715),\n vec3(0.021665,0.026737,0.053220),\n vec3(-0.208231,0.117129,-0.098685),\n vec3(0.139749,0.080968,-0.043086),\n vec3(-0.153599,0.182814,0.262090),\n vec3(-0.159673,0.496777,-0.743568),\n vec3(0.134797,0.117152,0.095753),\n vec3(-0.155626,0.120533,0.019395),\n vec3(0.042311,0.054462,-0.049709),\n vec3(0.001257,0.031288,0.034468),\n vec3(-0.002271,0.003199,-0.002304),\n vec3(0.662104,0.717307,0.033854),\n vec3(-0.373100,0.576021,0.308274),\n vec3(0.024233,0.231316,-0.173688),\n vec3(0.161311,0.420217,0.234273),\n vec3(-0.045248,0.078031,-0.010411),\n vec3(0.167453,0.376942,-0.094872),\n vec3(-0.056194,0.433247,0.173218),\n vec3(-0.016224,0.123149,-0.035569),\n vec3(0.067127,0.407641,0.028479)\n );\n\n float depth = texture2D(depthmap, vTexCoords).r;\n if(depth == 1.0) {\n discard;\n }\n\n vec4 screen_position = vec4(vTexCoords, depth,1.0);\n vec4 pos = projinv*screen_position;\n pos /= pos.w;\n vec3 position = pos.xyz;\n\n //approximate the normal from the depth map; I find this simpler\n //than trying to recompute the exact normal within every possible object shader\n\n //pixel offset positions in screen space\n ivec2 dim = textureSize(depthmap,0);\n vec2 offset1 = vec2(0.0,1.0/float(dim.y));\n vec2 offset2 = vec2(1.0/float(dim.x),0.0);\n float depth1 = texture2D(depthmap, vTexCoords + offset1).r;\n float depth2 = texture2D(depthmap, vTexCoords + offset2).r;\n \n vec3 p1 = vec3(screen_position.xy+offset1, depth1 - depth);\n vec3 p2 = vec3(screen_position.xy+offset2, depth2 - depth);\n\n //convert to model space\n vec4 pos1 = projinv*vec4(p1,1);\n pos1 /= pos1.w;\n vec4 pos2 = projinv*vec4(p2,1);\n pos2 /= pos2.w;\n\n vec3 normal = normalize(cross(pos1.xyz-position, pos2.xyz-position)); //model normal, important we normalize in model space\n\n //pseudo random number\n\n float occlusion = 0.0;\n for(int c = 0; c < cycles; c++) {\n vec3 random = normalize(pseudorandomVec3(position+float(c)));\n for(int i=0; i < samples; i++) {\n\n vec3 ray = radius * reflect(sample_sphere[i],random);\n vec3 hemi_ray = position + sign(dot(ray,normal)) * ray; //model space\n vec4 hemi_screen = projectionMatrix*vec4(hemi_ray,1.0);\n hemi_screen /= hemi_screen.w;\n \n float occ_depth = texture2D(depthmap, clamp(hemi_screen.xy,0.0,1.0)).r;\n float difference = hemi_screen.z - occ_depth;\n \n occlusion += step(0.0, difference) * (1.0-smoothstep(0.0, area, difference));\n }\n }\n float ao = 1.0 - total_strength * occlusion * (1.0 / float(cycles*samples));\n gl_FragDepthEXT = clamp(ao+base,0.0,1.0);\n\n}",vertexShader:"attribute vec2 vertexPosition;\nvarying highp vec2 vTexCoords;\nconst vec2 scale = vec2(0.5, 0.5);\n\nvoid main() {\n vTexCoords = vertexPosition * scale + scale; // scale vertex attribute to [0,1] range\n gl_Position = vec4(vertexPosition, 0.0, 1.0);\n}\n ",uniforms:{total_strength:{type:"f",value:1},radius:{type:"f",value:5},projinv:{type:"mat4",value:[]}}},sphereimposter:tt,sphereimposteroutline:it,sprite:rt,stickimposter:at,stickimposteroutline:ot,volumetric:ht};function dt(t){let e={};for(const r in t){e[r]={},e[r].type=t[r].type;var i=t[r].value;i instanceof b.Color?e[r].value=i.clone():"number"==typeof i?e[r].value=i:i instanceof Array?e[r].value=[]:console.error("Error copying shader uniforms from ShaderLib: unknown type for uniform")}return e}const ut={clone:dt};class Camera extends Object3D{constructor(t=50,e=1,i=.1,r=2e3,s=!1){super(),this.projectionMatrix=new l.Matrix4,this.projectionMatrixInverse=new l.Matrix4,this.matrixWorldInverse=new l.Matrix4,this.fov=t,this.aspect=e,this.near=i,this.far=r;var n=this.position.z;this.right=n*Math.tan(Math.PI/180*t),this.left=-this.right,this.top=this.right/this.aspect,this.bottom=-this.top,this.ortho=!!s,this.updateProjectionMatrix()}lookAt(t){this.matrix.lookAt(this.position,t,this.up),this.rotationAutoUpdate&&(!1===this.useQuaternion&&this.rotation instanceof l.Vector3?this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder):console.error("Unimplemented math operation."))}updateProjectionMatrix(){this.ortho?this.projectionMatrix.makeOrthographic(this.left,this.right,this.top,this.bottom,this.near,this.far):this.projectionMatrix.makePerspective(this.fov,this.aspect,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)}}class Fog{constructor(t,e=1,i=1e3){this.name="",this.color=new b.Color(t),this.near=e,this.far=i}clone(){return new Fog(this.color.getHex(),this.near,this.far)}}class SpritePlugin{constructor(){this.sprite={vertices:null,faces:null,vertexBuffer:null,elementBuffer:null,program:null,attributes:{},uniforms:null}}init(t){this.gl=t.context,this.renderer=t,this.precision=t.getPrecision(),this.sprite.vertices=new Float32Array(16),this.sprite.faces=new Uint16Array(6);var e=0;this.sprite.vertices[e++]=-1,this.sprite.vertices[e++]=-1,this.sprite.vertices[e++]=0,this.sprite.vertices[e++]=0,this.sprite.vertices[e++]=1,this.sprite.vertices[e++]=-1,this.sprite.vertices[e++]=1,this.sprite.vertices[e++]=0,this.sprite.vertices[e++]=1,this.sprite.vertices[e++]=1,this.sprite.vertices[e++]=1,this.sprite.vertices[e++]=1,this.sprite.vertices[e++]=-1,this.sprite.vertices[e++]=1,this.sprite.vertices[e++]=0,this.sprite.vertices[e++]=1,e=0,this.sprite.faces[e++]=0,this.sprite.faces[e++]=1,this.sprite.faces[e++]=2,this.sprite.faces[e++]=0,this.sprite.faces[e++]=2,this.sprite.faces[e++]=3,this.sprite.vertexBuffer=this.gl.createBuffer(),this.sprite.elementBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.sprite.vertexBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.sprite.vertices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.sprite.elementBuffer),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.sprite.faces,this.gl.STATIC_DRAW),this.sprite.program=this.createProgram(ct.sprite,this.precision||1),this.sprite.attributes={};const i={};this.sprite.attributes.position=this.gl.getAttribLocation(this.sprite.program,"position"),this.sprite.attributes.uv=this.gl.getAttribLocation(this.sprite.program,"uv"),i.uvOffset=this.gl.getUniformLocation(this.sprite.program,"uvOffset"),i.uvScale=this.gl.getUniformLocation(this.sprite.program,"uvScale"),i.rotation=this.gl.getUniformLocation(this.sprite.program,"rotation"),i.scale=this.gl.getUniformLocation(this.sprite.program,"scale"),i.alignment=this.gl.getUniformLocation(this.sprite.program,"alignment"),i.color=this.gl.getUniformLocation(this.sprite.program,"color"),i.map=this.gl.getUniformLocation(this.sprite.program,"map"),i.opacity=this.gl.getUniformLocation(this.sprite.program,"opacity"),i.useScreenCoordinates=this.gl.getUniformLocation(this.sprite.program,"useScreenCoordinates"),i.screenPosition=this.gl.getUniformLocation(this.sprite.program,"screenPosition"),i.modelViewMatrix=this.gl.getUniformLocation(this.sprite.program,"modelViewMatrix"),i.projectionMatrix=this.gl.getUniformLocation(this.sprite.program,"projectionMatrix"),i.fogType=this.gl.getUniformLocation(this.sprite.program,"fogType"),i.fogDensity=this.gl.getUniformLocation(this.sprite.program,"fogDensity"),i.fogNear=this.gl.getUniformLocation(this.sprite.program,"fogNear"),i.fogFar=this.gl.getUniformLocation(this.sprite.program,"fogFar"),i.fogColor=this.gl.getUniformLocation(this.sprite.program,"fogColor"),i.alphaTest=this.gl.getUniformLocation(this.sprite.program,"alphaTest"),this.sprite.uniforms=i}render(t,e,i,r,s){var n,a,o,l,h,c,d,u,f,p;if(!this.gl)throw new Error("WebGLRenderer not initialized");let g=[];null===(n=null==t?void 0:t.__webglSprites)||void 0===n||n.forEach((t=>{(s&&0==t.material.depthTest||!s&&t.material.depthTest)&&g.push(t)}));let m=g.length;if(!m)return;const v=this.sprite.attributes,_=this.sprite.uniforms;if(!_)throw new Error("Uniforms not defined");var y=.5*i,b=.5*r;this.gl.useProgram(this.sprite.program),this.gl.enableVertexAttribArray(v.position),this.gl.enableVertexAttribArray(v.uv),this.gl.disable(this.gl.CULL_FACE),this.gl.enable(this.gl.BLEND),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.sprite.vertexBuffer),this.gl.vertexAttribPointer(v.position,2,this.gl.FLOAT,!1,16,0),this.gl.vertexAttribPointer(v.uv,2,this.gl.FLOAT,!1,16,8),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.sprite.elementBuffer),this.gl.uniformMatrix4fv(_.projectionMatrix,!1,e.projectionMatrix.elements),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.uniform1i(_.map,0);var x,w=0,A=0,C=t.fog;let S,M,z,T;C?(this.gl.uniform3f(_.fogColor,C.color.r,C.color.g,C.color.b),this.gl.uniform1f(_.fogNear,C.near),this.gl.uniform1f(_.fogFar,C.far),this.gl.uniform1i(_.fogType,1),w=1,A=1):(this.gl.uniform1i(_.fogType,0),w=0,A=0);let E=[];for(x=0;x0}disableAmbientOcclusion(){this._AOEnabled=!1}setViewport(){if(this._offscreen&&(this._offscreen.width=this._canvas.width,this._offscreen.height=this._canvas.height),null!=this.rows&&null!=this.cols&&null!=this.row&&null!=this.col){var t=this._canvas.width/this.cols,e=this._canvas.height/this.rows;this._viewportWidth=t,this._viewportHeight=e,this.isLost()||(this._gl.enable(this._gl.SCISSOR_TEST),this._gl.scissor(t*this.col,e*this.row,t,e),this._gl.viewport(t*this.col,e*this.row,t,e))}}setSize(t,e){if(this.devicePixelRatio=void 0!==window.devicePixelRatio?window.devicePixelRatio:1,this._antialias&&this.devicePixelRatio<2&&(this.devicePixelRatio*=2),null!=this.rows&&null!=this.cols&&null!=this.row&&null!=this.col){var i=t/this.cols,r=e/this.rows;this._canvas.width=t*this.devicePixelRatio,this._canvas.height=e*this.devicePixelRatio,this._viewportWidth=i*this.devicePixelRatio,this._viewportHeight=r*this.devicePixelRatio,this._canvas.style.width=t+"px",this._canvas.style.height=e+"px",this.setViewport()}else this._viewportWidth=this._canvas.width=t*this.devicePixelRatio,this._viewportHeight=this._canvas.height=e*this.devicePixelRatio,this._canvas.style.width=t+"px",this._canvas.style.height=e+"px",this.isLost()||this._gl.viewport(0,0,this._gl.drawingBufferWidth,this._gl.drawingBufferHeight);this.initFrameBuffer()}clear(t,e,i){var r=0;(void 0===t||t)&&(r|=this._gl.COLOR_BUFFER_BIT),(void 0===e||e)&&(r|=this._gl.DEPTH_BUFFER_BIT),(void 0===i||i)&&(r|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(r)}setMaterialFaces(t,e){var i=t.side===a,r=t.side===n;t.imposter||(r=e?!r:r),this._oldDoubleSided!==i&&(i?this._gl.disable(this._gl.CULL_FACE):this._gl.enable(this._gl.CULL_FACE),this._oldDoubleSided=i),this._oldFlipSided!==r&&(r?this._gl.frontFace(this._gl.CW):this._gl.frontFace(this._gl.CCW),this._oldFlipSided=r),this._gl.cullFace(this._gl.BACK)}setDepthTest(t){this._oldDepthTest!==t&&(t?this._gl.enable(this._gl.DEPTH_TEST):this._gl.disable(this._gl.DEPTH_TEST),this._oldDepthTest=t)}setDepthWrite(t){this._oldDepthWrite!==t&&(this._gl.depthMask(t),this._oldDepthWrite=t)}setBlending(t){t?(this._gl.enable(this._gl.BLEND),this._gl.blendEquationSeparate(this._gl.FUNC_ADD,this._gl.FUNC_ADD),this._gl.blendFuncSeparate(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA)):this._gl.disable(this._gl.BLEND)}initMaterial(t,e,i,r){var s,n;if(t.addEventListener("dispose",this.onMaterialDispose.bind(this)),n=t.shaderID){var a=ct[n];t.vertexShader=a.vertexShader,t.fragmentShader=a.fragmentShader,t.uniforms=ut.clone(a.uniforms),t.shaded&&t.makeShaded(this.SHADE_TEXTURE)}s={wireframe:t.wireframe,fragdepth:t.imposter,volumetric:t.volumetric,shaded:t.shaded},t.program=this.buildProgram(t.fragmentShader,t.vertexShader,t.uniforms,s)}renderBuffer(t,e,i,r,s,n){var a,o;if(r.visible&&(a=this.setProgram(t,e,i,r,n,this))){o=a.attributes;var l,h,c=!1,d=r.wireframe?1:0,u=16777215*s.id+2*a.id+d;if(u!==this._currentGeometryGroupHash&&(this._currentGeometryGroupHash=u,c=!0),c&&(this.disableAttributes(),o.position>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,s.__webglVertexBuffer),this.enableAttribute(o.position),this._gl.vertexAttribPointer(o.position,3,this._gl.FLOAT,!1,0,0)),o.color>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,s.__webglColorBuffer),this.enableAttribute(o.color),this._gl.vertexAttribPointer(o.color,3,this._gl.FLOAT,!1,0,0)),o.normal>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,s.__webglNormalBuffer),this.enableAttribute(o.normal),this._gl.vertexAttribPointer(o.normal,3,this._gl.FLOAT,!1,0,0)),o.offset>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,s.__webglOffsetBuffer),this.enableAttribute(o.offset),this._gl.vertexAttribPointer(o.offset,3,this._gl.FLOAT,!1,0,0)),o.radius>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,s.__webglRadiusBuffer),this.enableAttribute(o.radius),this._gl.vertexAttribPointer(o.radius,1,this._gl.FLOAT,!1,0,0))),n instanceof Mesh){if("instanced"===r.shaderID){var f=r.sphere.geometryGroups[0];c&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,s.__webglVertexBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,f.vertexArray,this._gl.STATIC_DRAW),this._gl.bindBuffer(this._gl.ARRAY_BUFFER,s.__webglNormalBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,f.normalArray,this._gl.STATIC_DRAW),this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,s.__webglFaceBuffer),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,f.faceArray,this._gl.STATIC_DRAW)),l=f.faceidx,this._extInstanced.vertexAttribDivisorANGLE(o.offset,1),this._extInstanced.vertexAttribDivisorANGLE(o.radius,1),this._extInstanced.vertexAttribDivisorANGLE(o.color,1),this._extInstanced.drawElementsInstancedANGLE(this._gl.TRIANGLES,l,this._gl.UNSIGNED_SHORT,0,s.radiusArray.length),this._extInstanced.vertexAttribDivisorANGLE(o.offset,0),this._extInstanced.vertexAttribDivisorANGLE(o.radius,0),this._extInstanced.vertexAttribDivisorANGLE(o.color,0)}else r.wireframe?(h=s.lineidx,this.setLineWidth(r.wireframeLinewidth),c&&this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,s.__webglLineBuffer),this._gl.drawElements(this._gl.LINES,h,this._gl.UNSIGNED_SHORT,0)):(l=s.faceidx,c&&this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,s.__webglFaceBuffer),this._gl.drawElements(this._gl.TRIANGLES,l,this._gl.UNSIGNED_SHORT,0));this.info.render.calls++,this.info.render.vertices+=l,this.info.render.faces+=l/3}else n instanceof Line&&(h=s.vertices,this.setLineWidth(r.linewidth),this._gl.drawArrays(this._gl.LINES,0,h),this.info.render.calls++)}}clearShading(){this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.DEPTH_ATTACHMENT,this._gl.TEXTURE_2D,this._shadingTexture,0),this.clear(!1,!0,!1),this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.DEPTH_ATTACHMENT,this._gl.TEXTURE_2D,this._depthTexture,0)}setShading(t,e,i){let r=t.__lights,s=t.fog,n=[];for(let e=0,r=t.__webglObjects.length;e=0;--i)t[i].object===e&&t.splice(i,1)}removeInstancesDirect(t,e){for(var i=t.length-1;i>=0;--i)t[i]===e&&t.splice(i,1)}unrollBufferMaterial(t){var e=t.object.material;if(e.volumetric)t.opaque=null,t.transparent=null,t.volumetric=e;else if(e.transparent){if(t.opaque=null,t.volumetric=null,t.transparent=e,!e.wireframe){let i=e.clone();i.opacity=0,t.transparentDepth=i}}else{if(t.opaque=e,t.transparent=null,t.volumetric=null,!e.wireframe){let i=e.clone();i.opacity=0,t.opaqueDepth=i}e.hasAO&&(t.hasAO=!0),(this._AOEnabled||t.hasAO)&&(t.opaqueShaded=e.clone(),t.opaqueShaded.shaded=!0)}}setBuffers(t,e){var i=t.vertexArray,r=t.colorArray;if(void 0!==t.__webglOffsetBuffer?(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t.__webglOffsetBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,i,e)):(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t.__webglVertexBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,i,e)),this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t.__webglColorBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,r,e),t.normalArray&&void 0!==t.__webglNormalBuffer){var s=t.normalArray;this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t.__webglNormalBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,s,e)}if(t.radiusArray&&void 0!==t.__webglRadiusBuffer&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t.__webglRadiusBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,t.radiusArray,e)),t.faceArray&&void 0!==t.__webglFaceBuffer){var n=t.faceArray;this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,t.__webglFaceBuffer),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,n,e)}if(t.lineArray&&void 0!==t.__webglLineBuffer){var a=t.lineArray;this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,t.__webglLineBuffer),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,a,e)}}createMeshBuffers(t){t.radiusArray&&(t.__webglRadiusBuffer=this._gl.createBuffer()),t.useOffset&&(t.__webglOffsetBuffer=this._gl.createBuffer()),t.__webglVertexBuffer=this._gl.createBuffer(),t.__webglNormalBuffer=this._gl.createBuffer(),t.__webglColorBuffer=this._gl.createBuffer(),t.__webglFaceBuffer=this._gl.createBuffer(),t.__webglLineBuffer=this._gl.createBuffer(),this.info.memory.geometries++}createLineBuffers(t){t.__webglVertexBuffer=this._gl.createBuffer(),t.__webglColorBuffer=this._gl.createBuffer(),this.info.memory.geometries++}addBuffer(t,e,i){t.push({buffer:e,object:i,opaque:null,transparent:null})}setupMatrices(t,e){t._modelViewMatrix.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld),t._normalMatrix.getInverse(t._modelViewMatrix),t._normalMatrix.transpose()}filterFallback(t){return this._gl.LINEAR}setTextureParameters(t,e){t==this._gl.TEXTURE_2D?(this._gl.texParameteri(t,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(t,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(t,this._gl.TEXTURE_MAG_FILTER,this.filterFallback(e.magFilter)),this._gl.texParameteri(t,this._gl.TEXTURE_MIN_FILTER,this.filterFallback(e.minFilter))):(this._gl.texParameteri(t,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(t,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(t,this._gl.TEXTURE_WRAP_R,this._gl.CLAMP_TO_EDGE),this._extColorBufferFloat&&this._extFloatLinear?(this._gl.texParameteri(t,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(t,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR)):(this._gl.texParameteri(t,this._gl.TEXTURE_MAG_FILTER,this._gl.NEAREST),this._gl.texParameteri(t,this._gl.TEXTURE_MIN_FILTER,this._gl.NEAREST)))}paramToGL(t){return t===p?this._gl.UNSIGNED_BYTE:t===m?this._gl.RGBA:t===u?this._gl.NEAREST:0}setupLights(t,e){var i,r,s,n,a,o=this._lights,l=o.directional.colors,h=o.directional.positions,c=0,d=0;for(i=0,r=e.length;i{"use strict";i.r(e),i.d(e,{Matrix3:()=>Matrix3,Matrix4:()=>Matrix4,Quaternion:()=>Quaternion,Ray:()=>Ray,Vector2:()=>Vector2,Vector3:()=>Vector3,clamp:()=>r,conversionMatrix3:()=>d,degToRad:()=>n});class Quaternion{constructor(t,e,i,r){this.x=t||0,this.y=e||0,this.z=i||0,this.w=void 0!==r?r:1}set(t,e,i,r){return this.x=t,this.y=e,this.z=i,this.w=r,this}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this}conjugate(){return this.x*=-1,this.y*=-1,this.z*=-1,this}inverse(){return this.conjugate().normalize()}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthxyz(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){let t=this.length();return 0===t?(this.x=0,this.y=0,this.z=0,this.w=1):(t=1/t,this.x*=t,this.y*=t,this.z*=t,this.w*=t),this}multiply(t){return this.multiplyQuaternions(this,t)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}multiplyQuaternions(t,e){const i=t.x,r=t.y,s=t.z,n=t.w,a=e.x,o=e.y,l=e.z,h=e.w;return this.x=i*h+n*a+r*l-s*o,this.y=r*h+n*o+s*a-i*l,this.z=s*h+n*l+i*o-r*a,this.w=n*h-i*a-r*o-s*l,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}clone(){return new Quaternion(this.x,this.y,this.z,this.w)}setFromEuler(t){const e=Math.cos(t.x/2),i=Math.cos(t.y/2),r=Math.cos(t.z/2),s=Math.sin(t.x/2),n=Math.sin(t.y/2),a=Math.sin(t.z/2);return this.x=s*i*r+e*n*a,this.y=e*n*r-s*i*a,this.z=e*i*a+s*n*r,this.w=e*i*r-s*n*a,this}}class Vector2{constructor(t,e){this.x=t||0,this.y=e||0}set(t,e){return this.x=t,this.y=e,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}copy(t){return this.x=t.x,this.y=t.y,this}clone(){return new Vector2(this.x,this.y)}}function r(t,e,i){return Math.min(Math.max(t,e),i)}const s=Math.PI/180;function n(t){return t*s}var a,o,l,h,c;class Matrix4{constructor(t=1,e=0,i=0,r=0,s=0,n=1,a=0,o=0,l=0,h=0,c=1,d=0,u=0,f=0,p=0,g=1){void 0!==t&&"number"!=typeof t?this.elements=new Float32Array(t):(this.elements=new Float32Array(16),this.elements[0]=t,this.elements[4]=e,this.elements[8]=i,this.elements[12]=r,this.elements[1]=s,this.elements[5]=n,this.elements[9]=a,this.elements[13]=o,this.elements[2]=l,this.elements[6]=h,this.elements[10]=c,this.elements[14]=d,this.elements[3]=u,this.elements[7]=f,this.elements[11]=p,this.elements[15]=g)}makeScale(t,e,i){throw new Error("Method not implemented.")}set(t,e,i,r,s,n,a,o,l,h,c,d,u,f,p,g){const m=this.elements;return m[0]=t,m[4]=e,m[8]=i,m[12]=r,m[1]=s,m[5]=n,m[9]=a,m[13]=o,m[2]=l,m[6]=h,m[10]=c,m[14]=d,m[3]=u,m[7]=f,m[11]=p,m[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}copy(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15]),this}matrix3FromTopLeft(){const t=this.elements;return new Matrix3(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10])}setRotationFromEuler(t,e){const i=this.elements,{x:r,y:s,z:n}=t,a=Math.cos(r),o=Math.sin(r),l=Math.cos(s),h=Math.sin(s),c=Math.cos(n),d=Math.sin(n);if(void 0===e||"XYZ"===e){const t=a*c,e=a*d,r=o*c,s=o*d;i[0]=l*c,i[4]=-l*d,i[8]=h,i[1]=e+r*h,i[5]=t-s*h,i[9]=-o*l,i[2]=s-t*h,i[6]=r+e*h,i[10]=a*l}else console.error(`Error with matrix4 setRotationFromEuler. Order: ${e}`);return this}setRotationFromQuaternion(t){const e=this.elements,{x:i,y:r,z:s,w:n}=t,a=i+i,o=r+r,l=s+s,h=i*a,c=i*o,d=i*l,u=r*o,f=r*l,p=s*l,g=n*a,m=n*o,v=n*l;return e[0]=1-(u+p),e[4]=c-v,e[8]=d+m,e[1]=c+v,e[5]=1-(h+p),e[9]=f-g,e[2]=d-m,e[6]=f+g,e[10]=1-(h+u),this}multiplyMatrices(t,e){const i=t.elements,r=e.elements,s=this.elements,n=i[0],a=i[4],o=i[8],l=i[12],h=i[1],c=i[5],d=i[9],u=i[13],f=i[2],p=i[6],g=i[10],m=i[14],v=i[3],_=i[7],y=i[11],b=i[15],x=r[0],w=r[4],A=r[8],C=r[12],S=r[1],M=r[5],z=r[9],T=r[13],E=r[2],L=r[6],F=r[10],I=r[14],O=r[3],D=r[7],k=r[11],R=r[15];return s[0]=n*x+a*S+o*E+l*O,s[4]=n*w+a*M+o*L+l*D,s[8]=n*A+a*z+o*F+l*k,s[12]=n*C+a*T+o*I+l*R,s[1]=h*x+c*S+d*E+u*O,s[5]=h*w+c*M+d*L+u*D,s[9]=h*A+c*z+d*F+u*k,s[13]=h*C+c*T+d*I+u*R,s[2]=f*x+p*S+g*E+m*O,s[6]=f*w+p*M+g*L+m*D,s[10]=f*A+p*z+g*F+m*k,s[14]=f*C+p*T+g*I+m*R,s[3]=v*x+_*S+y*E+b*O,s[7]=v*w+_*M+y*L+b*D,s[11]=v*A+_*z+y*F+b*k,s[15]=v*C+_*T+y*I+b*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}makeTranslation(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}snap(t){t||(t=4);const e=Math.pow(10,4),i=this.elements;for(let t=0;t<16;t++){const r=Math.round(i[t]);r===Math.round(i[t]*e)/e&&(i[t]=r)}return this}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t){const e=this.elements;return e[12]=t.x,e[13]=t.y,e[14]=t.z,this}translate(t){const e=this.elements;return e[12]+=t.x,e[13]+=t.y,e[14]+=t.z,this}getInverse(t,e){const i=this.elements,r=t.elements,s=r[0],n=r[4],a=r[8],o=r[12],l=r[1],h=r[5],c=r[9],d=r[13],u=r[2],f=r[6],p=r[10],g=r[14],m=r[3],v=r[7],_=r[11],y=r[15];i[0]=c*g*v-d*p*v+d*f*_-h*g*_-c*f*y+h*p*y,i[4]=o*p*v-a*g*v-o*f*_+n*g*_+a*f*y-n*p*y,i[8]=a*d*v-o*c*v+o*h*_-n*d*_-a*h*y+n*c*y,i[12]=o*c*f-a*d*f-o*h*p+n*d*p+a*h*g-n*c*g,i[1]=d*p*m-c*g*m-d*u*_+l*g*_+c*u*y-l*p*y,i[5]=a*g*m-o*p*m+o*u*_-s*g*_-a*u*y+s*p*y,i[9]=o*c*m-a*d*m-o*l*_+s*d*_+a*l*y-s*c*y,i[13]=a*d*u-o*c*u+o*l*p-s*d*p-a*l*g+s*c*g,i[2]=h*g*m-d*f*m+d*u*v-l*g*v-h*u*y+l*f*y,i[6]=o*f*m-n*g*m-o*u*v+s*g*v+n*u*y-s*f*y,i[10]=n*d*m-o*h*m+o*l*v-s*d*v-n*l*y+s*h*y,i[14]=o*h*u-n*d*u-o*l*f+s*d*f+n*l*g-s*h*g,i[3]=c*f*m-h*p*m-c*u*v+l*p*v+h*u*_-l*f*_,i[7]=n*p*m-a*f*m+a*u*v-s*p*v-n*u*_+s*f*_,i[11]=a*h*m-n*c*m-a*l*v+s*c*v+n*l*_-s*h*_,i[15]=n*c*u-a*h*u+a*l*f-s*c*f-n*l*p+s*h*p;const b=s*i[0]+l*i[4]+u*i[8]+m*i[12];if(0===b){const t="Matrix4.getInverse(): can't invert matrix, determinant is 0";if(e)throw new Error(t);return console.warn(t),this.identity(),this}return this.multiplyScalar(1/b),this}isReflected(){const t=this.elements,e=t[0],i=t[4],r=t[8],s=t[1],n=t[5],a=t[9],o=t[2],l=t[6],h=t[10];return e*n*h+s*l*r+o*i*a-o*n*r-s*i*h-e*l*a<0}scale(t){const e=this.elements,{x:i}=t,{y:r}=t,{z:s}=t;return e[0]*=i,e[4]*=r,e[8]*=s,e[1]*=i,e[5]*=r,e[9]*=s,e[2]*=i,e[6]*=r,e[10]*=s,e[3]*=i,e[7]*=r,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,Math.max(i,r)))}makeFrustum(t,e,i,r,s,n){const a=this.elements,o=2*s/(e-t),l=2*s/(r-i),h=(e+t)/(e-t),c=(r+i)/(r-i),d=-(n+s)/(n-s),u=-2*n*s/(n-s);return a[0]=o,a[4]=0,a[8]=h,a[12]=0,a[1]=0,a[5]=l,a[9]=c,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=u,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makePerspective(t,e,i,r){const s=i*Math.tan(n(.5*t)),a=-s,o=a*e,l=s*e;return this.makeFrustum(o,l,a,s,i,r)}makeOrthographic(t,e,i,r,s,n){const a=this.elements,o=1/(e-t),l=1/(i-r),h=1/(n-s),c=(e+t)*o,d=(i+r)*l,u=(n+s)*h;return a[0]=2*o,a[4]=0,a[8]=0,a[12]=-c,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-u,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}isEqual(t){const e=t.elements,i=this.elements;return i[0]===e[0]&&i[4]===e[4]&&i[8]===e[8]&&i[12]===e[12]&&i[1]===e[1]&&i[5]===e[5]&&i[9]===e[9]&&i[13]===e[13]&&i[2]===e[2]&&i[6]===e[6]&&i[10]===e[10]&&i[14]===e[14]&&i[3]===e[3]&&i[7]===e[7]&&i[11]===e[11]&&i[15]===e[15]}clone(){const t=this.elements;return new Matrix4(t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15])}isIdentity(){const t=this.elements;return 1===t[0]&&0===t[4]&&0===t[8]&&0===t[12]&&0===t[1]&&1===t[5]&&0===t[9]&&0===t[13]&&0===t[2]&&0===t[6]&&1===t[10]&&0===t[14]&&0===t[3]&&0===t[7]&&0===t[11]&&1===t[15]}isNearlyIdentity(t){return this.clone().snap(t).isIdentity()}getScale(t){const e=this.elements;return t=t||new Vector3,l.set(e[0],e[1],e[2]),h.set(e[4],e[5],e[6]),c.set(e[8],e[9],e[10]),t.x=l.length(),t.y=h.length(),t.z=c.length(),t}lookAt(t,e,i){const r=this.elements;return c.subVectors(t,e).normalize(),0===c.length()&&(c.z=1),l.crossVectors(i,c).normalize(),0===l.length()&&(c.x+=1e-4,l.crossVectors(i,c).normalize()),h.crossVectors(c,l),r[0]=l.x,r[4]=h.x,r[8]=c.x,r[1]=l.y,r[5]=h.y,r[9]=c.y,r[2]=l.z,r[6]=h.z,r[10]=c.z,this}compose(t,e,i){const r=this.elements;return a.identity(),a.setRotationFromQuaternion(e),o.makeScale(i.x,i.y,i.z),this.multiplyMatrices(a,o),r[12]=t.x,r[13]=t.y,r[14]=t.z,this}}a=new Matrix4,o=new Matrix4;class Vector3{constructor(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0,this.atomid=void 0}set(t,e,i){return this.x=t,this.y=e,this.z=i,this}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}divideScalar(t){return 0!==t?(this.x/=t,this.y/=t,this.z/=t):(this.x=0,this.y=0,this.z=0),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r}applyMatrix3(t){const{x:e}=this,{y:i}=this,{z:r}=this,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*r,this.y=s[1]*e+s[4]*i+s[7]*r,this.z=s[2]*e+s[5]*i+s[8]*r,this}applyMatrix4(t){const{x:e}=this,{y:i}=this,{z:r}=this,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*r+s[12],this.y=s[1]*e+s[5]*i+s[9]*r+s[13],this.z=s[2]*e+s[6]*i+s[10]*r+s[14],this}applyProjection(t){const{x:e}=this,{y:i}=this,{z:r}=this,s=t.elements,n=s[3]*e+s[7]*i+s[11]*r+s[15];return this.x=(s[0]*e+s[4]*i+s[8]*r+s[12])/n,this.y=(s[1]*e+s[5]*i+s[9]*r+s[13])/n,this.z=(s[2]*e+s[6]*i+s[10]*r+s[14])/n,this}applyQuaternion(t){const{x:e}=this,{y:i}=this,{z:r}=this,s=t.x,n=t.y,a=t.z,o=t.w,l={};l.x=2*(i*a-r*n),l.y=2*(r*s-e*a),l.z=2*(e*n-i*s);const h={};return h.x=l.y*a-l.z*n,h.y=l.z*s-l.x*a,h.z=l.x*n-l.y*s,this.x=e+o*l.x+h.x,this.y=i+o*l.y+h.y,this.z=r+o*l.z+h.z,this}negate(){return this.multiplyScalar(-1)}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}normalize(){return this.divideScalar(this.length())}cross(t){const{x:e}=this,{y:i}=this,{z:r}=this;return this.x=i*t.z-r*t.y,this.y=r*t.x-e*t.z,this.z=e*t.y-i*t.x,this}crossVectors(t,e){return this.x=t.y*e.z-t.z*e.y,this.y=t.z*e.x-t.x*e.z,this.z=t.x*e.y-t.y*e.x,this}equals(t){return this.x==t.x&&this.y==t.y&&this.z==t.z}getPositionFromMatrix(t){return this.x=t.elements[12],this.y=t.elements[13],this.z=t.elements[14],this}setEulerFromRotationMatrix(t,e){const i=t.elements,s=i[0],n=i[4],a=i[8],o=i[5],l=i[9],h=i[6],c=i[10];return void 0===e||"XYZ"===e?(this.y=Math.asin(r(a,-1,1)),Math.abs(a)<.99999?(this.x=Math.atan2(-l,c),this.z=Math.atan2(-n,s)):(this.x=Math.atan2(h,o),this.z=0)):console.error(`Error with vector's setEulerFromRotationMatrix: Unknown order: ${e}`),this}rotateAboutVector(t,e){t.normalize();const i=Math.cos(e),r=Math.sin(e),s=this.clone().multiplyScalar(i),n=t.clone().cross(this).multiplyScalar(r),a=t.clone().multiplyScalar(t.clone().dot(this)).multiplyScalar(1-i),o=s.add(n).add(a);return this.x=o.x,this.y=o.y,this.z=o.z,this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}transformDirection(t){const{x:e}=this,{y:i}=this,{z:r}=this,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*r,this.y=s[1]*e+s[5]*i+s[9]*r,this.z=s[2]*e+s[6]*i+s[10]*r,this.normalize()}clone(){return new Vector3(this.x,this.y,this.z)}unproject(t){const e=a;return e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyMatrix4(e)}}l=new Vector3,h=new Vector3,c=new Vector3;class Matrix3{constructor(t=1,e=0,i=0,r=0,s=1,n=0,a=0,o=0,l=1){this.elements=new Float32Array(9),this.set(t,e,i,r,s,n,a,o,l)}set(t,e,i,r,s,n,a,o,l){const h=this.elements;return h[0]=t,h[3]=e,h[6]=i,h[1]=r,h[4]=s,h[7]=n,h[2]=a,h[5]=o,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=t.elements;this.set(e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8])}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}getInverse3(t){const e=t.elements,i=this.elements;i[0]=e[4]*e[8]-e[5]*e[7],i[3]=e[6]*e[5]-e[3]*e[8],i[6]=e[3]*e[7]-e[6]*e[4],i[1]=e[7]*e[2]-e[1]*e[8],i[4]=e[0]*e[8]-e[6]*e[2],i[7]=e[1]*e[6]-e[0]*e[7],i[2]=e[1]*e[5]-e[2]*e[4],i[5]=e[2]*e[3]-e[0]*e[5],i[8]=e[0]*e[4]-e[1]*e[3];const r=e[0]*i[0]+e[3]*i[1]+e[6]*i[2];return this.multiplyScalar(1/r),this}getInverse(t,e){const i=t.elements,r=this.elements;r[0]=i[10]*i[5]-i[6]*i[9],r[1]=-i[10]*i[1]+i[2]*i[9],r[2]=i[6]*i[1]-i[2]*i[5],r[3]=-i[10]*i[4]+i[6]*i[8],r[4]=i[10]*i[0]-i[2]*i[8],r[5]=-i[6]*i[0]+i[2]*i[4],r[6]=i[9]*i[4]-i[5]*i[8],r[7]=-i[9]*i[0]+i[1]*i[8],r[8]=i[5]*i[0]-i[1]*i[4];const s=i[0]*r[0]+i[1]*r[3]+i[2]*r[6];if(0===s){const t="Matrix3.getInverse(): can't invert matrix, determinant is 0";if(e)throw new Error(t);return console.warn(t),this.identity(),this}return this.multiplyScalar(1/s),this}getDeterminant(){const t=this.elements;return t[0]*t[4]*t[8]+t[1]*t[5]*t[6]+t[2]*t[3]*t[7]-t[2]*t[4]*t[6]-t[1]*t[3]*t[8]-t[0]*t[5]*t[7]}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}clone(){const t=this.elements;return new Matrix3(t[0],t[3],t[6],t[1],t[4],t[7],t[2],t[5],t[8])}getMatrix4(){const t=this.elements;return new Matrix4(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0)}}class Ray{constructor(t,e){this.origin=void 0!==t?t:new Vector3,this.direction=void 0!==e?e:new Vector3}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return(e||new Vector3).copy(this.direction).multiplyScalar(t).add(this.origin)}recast(t){const e=l;return this.origin.copy(this.at(t,e)),this}closestPointToPoint(t,e){const i=e||new Vector3;i.subVectors(t,this.origin);const r=i.dot(this.direction);return i.copy(this.direction).multiplyScalar(r).add(this.origin)}distanceToPoint(t){const e=l,i=e.subVectors(t,this.origin).dot(this.direction);return e.copy(this.direction).multiplyScalar(i).add(this.origin),e.distanceTo(t)}isIntersectionCylinder(){}isIntersectionSphere(t){return this.distanceToPoint(t.center)<=t.radius}isIntersectionPlane(t){return 0!==t.normal.dot(this.direction)||0===t.distanceToPoint(this.origin)}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:void 0;return-(this.origin.dot(t.normal)+t.constant)/e}intersectPlane(t,e){const i=this.distanceToPlane(t);if(void 0!==i)return this.at(i,e)}applyMatrix4(t){return this.direction.add(this.origin).applyMatrix4(t),this.origin.applyMatrix4(t),this.direction.sub(this.origin),this}clone(){return(new Ray).copy(this)}}function d(t,e,i,r,s,n){r=r*Math.PI/180,s=s*Math.PI/180,n=n*Math.PI/180;const a=t=>t*t,o=Math.cos(r),l=Math.cos(s),h=Math.cos(n),c=Math.sin(n);return new Matrix3(t,e*h,i*l,0,e*c,i*(o-l*h)/c,0,0,i*Math.sqrt(1-a(o)-a(l)-a(h)+2*o*l*h)/c)}},99:(t,e,i)=>{"use strict";i.r(e),i.d(e,{Cylinder:()=>Cylinder,Sphere:()=>Sphere,Triangle:()=>Triangle});var r=i(529);class Sphere{constructor(t={x:0,y:0,z:0},e=0){this.center=new r.Vector3(t.x,t.y,t.z),this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new Sphere).copy(this)}}let s=new r.Vector3;class Cylinder{constructor(t=new r.Vector3,e=new r.Vector3,i=0){this.c1=t,this.c2=e,this.radius=i,this.direction=(new r.Vector3).subVectors(this.c2,this.c1).normalize()}copy(t){return this.c1.copy(t.c1),this.c2.copy(t.c2),this.direction.copy(t.direction),this.radius=t.radius,this}lengthSq(){return s.subVectors(this.c2,this.c1).lengthSq()}applyMatrix4(t){return this.direction.add(this.c1).applyMatrix4(t),this.c1.applyMatrix4(t),this.c2.applyMatrix4(t),this.direction.sub(this.c1).normalize(),this.radius=this.radius*t.getMaxScaleOnAxis(),this}}const n=new r.Vector3;class Triangle{constructor(t=new r.Vector3,e=new r.Vector3,i=new r.Vector3){this.a=t,this.b=e,this.c=i}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}applyMatrix4(t){return this.a.applyMatrix4(t),this.b.applyMatrix4(t),this.c.applyMatrix4(t),this}getNormal(){var t=this.a.clone();return t.sub(this.b),n.subVectors(this.c,this.b),t.cross(n),t.normalize(),t}}},222:(t,e,i)=>{"use strict";i.r(e),i.d(e,{CC:()=>CC,Color:()=>Color,builtinColorSchemes:()=>h,chains:()=>l,elementColors:()=>a,htmlColors:()=>r,residues:()=>o,ssColors:()=>s});class Color{constructor(t,e,i){return this.r=0,this.g=0,this.b=0,arguments.length>1&&"number"==typeof t?(this.r=t||0,this.g=e||0,this.b=i||0,this):this.set(t||0)}set(t){return t instanceof Color?t.clone():("number"==typeof t?this.setHex(t):"object"==typeof t&&(this.r=(null==t?void 0:t.r)||0,this.g=(null==t?void 0:t.g)||0,this.b=(null==t?void 0:t.b)||0),this)}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this}getHex(){return Math.round(255*this.r)<<16|Math.round(255*this.g)<<8|Math.round(255*this.b)}clone(){return new Color(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}scaled(){var t={};return t.r=Math.round(255*this.r),t.g=Math.round(255*this.g),t.b=Math.round(255*this.b),t.a=1,t}}class CC{static color(t){if(!t)return CC.cache[0];if(t instanceof Color)return t;if("number"==typeof t&&void 0!==CC.cache[t])return CC.cache[t];if(t&&Array.isArray(t))return t.map(CC.color);let e=CC.getHex(t),i=new Color(e);return CC.cache[e]=i,i}static getHex(t){var e;if(Array.isArray(t))return t.map(CC.getHex);if("string"==typeof t){let i=t;if(!isNaN(parseInt(i)))return parseInt(i);if(i=i.trim(),4==i.length&&"#"==i[0]&&(i="#"+i[1]+i[1]+i[2]+i[2]+i[3]+i[3]),7==i.length&&"#"==i[0])return parseInt(i.substring(1),16);let r=CC.rgbRegEx.exec(i);if(r){""!=r[1]&&console.log("WARNING: Opacity value in rgba ignored. Specify separately as opacity attribute.");let t=0;for(let e=2;e<5;e++){t*=256;let i=r[e].endsWith("%")?255*parseFloat(r[e])/100:parseFloat(r[e]);t+=Math.round(i)}return t}return(null===(e=null===window||void 0===window?void 0:window.$3Dmol)||void 0===e?void 0:e.htmlColors[t.toLowerCase()])||0}return t}}CC.rgbRegEx=/rgb(a?)\(\s*([^ ,\)\t]+)\s*,\s*([^ ,\)\t]+)\s*,\s*([^ ,\)\t]+)/i,CC.cache={0:new Color(0)};const r={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgrey:11119017,darkgreen:25600,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,grey:8421504,green:32768,greenyellow:11403055,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgrey:13882323,lightgreen:9498256,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},s={pyMol:{h:16711680,s:16776960,c:65280},Jmol:{h:16711808,s:16762880,c:16777215}},n={H:16777215,He:16761035,HE:16761035,Li:11674146,LI:11674146,B:65280,C:13158600,N:9408511,O:15728640,F:14329120,Na:255,NA:255,Mg:2263842,MG:2263842,Al:8421520,AL:8421520,Si:14329120,SI:14329120,P:16753920,S:16762930,Cl:65280,CL:65280,Ca:8421520,CA:8421520,Ti:8421520,TI:8421520,Cr:8421520,CR:8421520,Mn:8421520,MN:8421520,Fe:16753920,FE:16753920,Ni:10824234,NI:10824234,Cu:10824234,CU:10824234,Zn:10824234,ZN:10824234,Br:10824234,BR:10824234,Ag:8421520,AG:8421520,I:10494192,Ba:16753920,BA:16753920,Au:14329120,AU:14329120},a={defaultColor:16716947,Jmol:{H:16777215,He:14286847,HE:14286847,Li:13402367,LI:13402367,Be:12779264,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,Ne:11789301,NE:11789301,Na:11230450,NA:11230450,Mg:9109248,MG:9109248,Al:12560038,AL:12560038,Si:1578e4,SI:1578e4,P:16744448,S:16777008,Cl:2093087,CL:2093087,Ar:8442339,AR:8442339,K:9388244,Ca:4062976,CA:4062976,Sc:15132390,SC:15132390,Ti:12567239,TI:12567239,V:10921643,Cr:9083335,CR:9083335,Mn:10255047,MN:10255047,Fe:14706227,FE:14706227,Co:15765664,CO:15765664,Ni:5296208,NI:5296208,Cu:13140019,CU:13140019,Zn:8224944,ZN:8224944,Ga:12750735,GA:12750735,Ge:6721423,GE:6721423,As:12419299,AS:12419299,Se:16752896,SE:16752896,Br:10889513,BR:10889513,Kr:6076625,KR:6076625,Rb:7351984,RB:7351984,Sr:65280,SR:65280,Y:9764863,Zr:9756896,ZR:9756896,Nb:7586505,NB:7586505,Mo:5551541,MO:5551541,Tc:3907230,TC:3907230,Ru:2396047,RU:2396047,Rh:687500,RH:687500,Pd:27013,PD:27013,Ag:12632256,AG:12632256,Cd:16767375,CD:16767375,In:10909043,IN:10909043,Sn:6717568,SN:6717568,Sb:10380213,SB:10380213,Te:13924864,TE:13924864,I:9699476,Xe:4366e3,XE:4366e3,Cs:5707663,CS:5707663,Ba:51456,BA:51456,La:7394559,LA:7394559,Ce:16777159,CE:16777159,Pr:14286791,PR:14286791,Nd:13107143,ND:13107143,Pm:10747847,PM:10747847,Sm:9437127,SM:9437127,Eu:6422471,EU:6422471,Gd:4587463,GD:4587463,Tb:3211207,TB:3211207,Dy:2097095,DY:2097095,Ho:65436,HO:65436,Er:58997,ER:58997,Tm:54354,TM:54354,Yb:48952,YB:48952,Lu:43812,LU:43812,Hf:5096191,HF:5096191,Ta:5089023,TA:5089023,W:2200790,Re:2522539,RE:2522539,Os:2516630,OS:2516630,Ir:1528967,IR:1528967,Pt:13684960,PT:13684960,Au:16765219,AU:16765219,Hg:12105936,HG:12105936,Tl:10900557,TL:10900557,Pb:5724513,PB:5724513,Bi:10375093,BI:10375093,Po:11230208,PO:11230208,At:7688005,AT:7688005,Rn:4358806,RN:4358806,Fr:4325478,FR:4325478,Ra:32e3,RA:32e3,Ac:7384058,AC:7384058,Th:47871,TH:47871,Pa:41471,PA:41471,U:36863,Np:33023,NP:33023,Pu:27647,PU:27647,Am:5528818,AM:5528818,Cm:7888099,CM:7888099,Bk:9064419,BK:9064419,Cf:10565332,CF:10565332,Es:11739092,ES:11739092,Fm:11739066,FM:11739066,Md:11734438,MD:11734438,No:12389767,NO:12389767,Lr:13041766,LR:13041766,Rf:13369433,RF:13369433,Db:13697103,DB:13697103,Sg:14221381,SG:14221381,Bh:14680120,BH:14680120,Hs:15073326,HS:15073326,Mt:15400998,MT:15400998},rasmol:n,defaultColors:Object.assign({},n),greenCarbon:Object.assign(Object.assign({},n),{C:65280}),cyanCarbon:Object.assign(Object.assign({},n),{C:65535}),magentaCarbon:Object.assign(Object.assign({},n),{C:16711935}),yellowCarbon:Object.assign(Object.assign({},n),{C:16776960}),whiteCarbon:Object.assign(Object.assign({},n),{C:16777215}),orangeCarbon:Object.assign(Object.assign({},n),{C:16753920}),purpleCarbon:Object.assign(Object.assign({},n),{C:8388736}),blueCarbon:Object.assign(Object.assign({},n),{C:255})},o={amino:{ALA:13158600,ARG:1334015,ASN:56540,ASP:15075850,CYS:15132160,GLN:56540,GLU:15075850,GLY:15461355,HIS:8553170,ILE:1016335,LEU:1016335,LYS:1334015,MET:15132160,PHE:3289770,PRO:14456450,SER:16422400,THR:16422400,TRP:11819700,TYR:3289770,VAL:1016335,ASX:16738740,GLX:16738740},shapely:{ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935},nucleic:{A:10526975,G:16740464,I:8454143,C:16747595,T:10551200,U:16744576}},l={atom:{A:12636415,B:11599792,C:16761032,D:16777088,E:16761087,F:11596016,G:16765040,H:15761536,I:16113331,J:49151,K:13458524,L:6737322,M:10145074,N:15631086,O:52945,P:65407,Q:3978097,R:139,S:12433259,T:25600,U:8388608,V:8421376,W:8388736,X:32896,Y:12092939,Z:11674146},hetatm:{A:9478351,B:8441752,C:13602992,D:13619056,E:13603023,F:8437952,G:13607008,H:12603504,I:12955267,J:42959,K:11881548,L:5682578,M:9090346,N:12481214,O:46753,P:53103,Q:3447649,R:187,S:10854235,T:37888,U:11534336,V:11579392,W:11534512,X:45232,Y:15250963,Z:12726834}},h={ssPyMol:{prop:"ss",map:s.pyMol},ssJmol:{prop:"ss",map:s.Jmol},Jmol:{prop:"elem",map:a.Jmol},amino:{prop:"resn",map:o.amino},shapely:{prop:"resn",map:o.shapely},nucleic:{prop:"resn",map:o.nucleic},chain:{prop:"chain",map:l.atom},rasmol:{prop:"elem",map:a.rasmol},default:{prop:"elem",map:a.defaultColors},greenCarbon:{prop:"elem",map:a.greenCarbon},chainHetatm:{prop:"chain",map:l.hetatm},cyanCarbon:{prop:"elem",map:a.cyanCarbon},magentaCarbon:{prop:"elem",map:a.magentaCarbon},purpleCarbon:{prop:"elem",map:a.purpleCarbon},whiteCarbon:{prop:"elem",map:a.whiteCarbon},orangeCarbon:{prop:"elem",map:a.orangeCarbon},yellowCarbon:{prop:"elem",map:a.yellowCarbon},blueCarbon:{prop:"elem",map:a.blueCarbon}}},421:(t,e,i)=>{"use strict";i.r(e),i.d(e,{CAP:()=>it,CC:()=>s.CC,CONTEXTS_PER_VIEWPORT:()=>Wt,Color:()=>s.Color,CustomLinear:()=>r.CustomLinear,Cylinder:()=>J.Cylinder,GLDraw:()=>rt,GLModel:()=>GLModel,GLShape:()=>GLShape,GLViewer:()=>GLViewer,GLVolumetricRender:()=>GLVolumetricRender,Gradient:()=>r.Gradient,GradientType:()=>r.GradientType,Label:()=>Label,LabelCount:()=>a,MarchingCube:()=>MarchingCube,MarchingCubeInitializer:()=>MarchingCubeInitializer,Matrix3:()=>$.Matrix3,Matrix4:()=>$.Matrix4,Parsers:()=>K,PausableTimer:()=>L.PausableTimer,PointGrid:()=>PointGrid,ProteinSurface:()=>ProteinSurface,Quaternion:()=>$.Quaternion,ROYGB:()=>r.ROYGB,RWB:()=>r.RWB,Ray:()=>$.Ray,Sinebow:()=>r.Sinebow,Sphere:()=>J.Sphere,SurfaceType:()=>Q,Triangle:()=>J.Triangle,Vector2:()=>$.Vector2,Vector3:()=>$.Vector3,VolumeData:()=>st.VolumeData,adjustVolumeStyle:()=>L.adjustVolumeStyle,applyPartialCharges:()=>h,autoinit:()=>Xt,autoload:()=>$t,base64ToArray:()=>L.base64ToArray,bondLength:()=>C.bondLength,builtinColorSchemes:()=>s.builtinColorSchemes,builtinGradients:()=>r.builtinGradients,chains:()=>s.chains,clamp:()=>$.clamp,conversionMatrix3:()=>$.conversionMatrix3,createStereoViewer:()=>Zt,createViewer:()=>qt,createViewerGrid:()=>Yt,deepCopy:()=>L.deepCopy,degToRad:()=>$.degToRad,download:()=>L.download,drawCartoon:()=>xt,elementColors:()=>s.elementColors,extend:()=>L.extend,get:()=>L.get,getAtomProperty:()=>L.getAtomProperty,getColorFromStyle:()=>L.getColorFromStyle,getElement:()=>L.getElement,getExtent:()=>L.getExtent,getGradient:()=>r.getGradient,getPropertyRange:()=>L.getPropertyRange,getbin:()=>L.getbin,htmlColors:()=>s.htmlColors,inflateString:()=>L.inflateString,isEmptyObject:()=>L.isEmptyObject,isNumeric:()=>L.isNumeric,makeFunction:()=>L.makeFunction,mergeGeos:()=>L.mergeGeos,normalizeValue:()=>r.normalizeValue,partialCharges:()=>l,processing_autoinit:()=>Kt,residues:()=>s.residues,setBondLength:()=>C.setBondLength,setSyncSurface:()=>et,specStringToObject:()=>L.specStringToObject,splitMesh:()=>wt,ssColors:()=>s.ssColors,subdivide_spline:()=>nt,syncSurface:()=>tt,viewers:()=>Qt});var r=i(546),s=i(222),n=i(638);let a=0;function o(t,e,i){var r=i;return void 0!==t&&(t instanceof s.Color?r=t.scaled():void 0!==(r=s.CC.color(t)).scaled&&(r=r.scaled())),void 0!==e&&(r.a=parseFloat(e)),r}class Label{constructor(t,e){this.id=a++,this.stylespec=e||{},this.canvas=document.createElement("canvas"),this.canvas.width=134,this.canvas.height=35,this.context=this.canvas.getContext("2d"),this.sprite=new n.Sprite,this.text=t,this.frame=this.stylespec.frame}getStyle(){return this.stylespec}hide(){this.sprite&&(this.sprite.visible=!1)}show(){this.sprite&&(this.sprite.visible=!0)}setContext(){var t=this.stylespec,e=void 0!==t.useScreen&&t.useScreen,i=t.showBackground;"0"!==i&&"false"!==i||(i=!1),void 0===i&&(i=!0);var s=t.font?t.font:"sans-serif",a=parseInt(t.fontSize)?parseInt(t.fontSize):18,l=o(t.fontColor,t.fontOpacity,{r:255,g:255,b:255,a:1}),h=t.padding?t.padding:4,c=t.borderThickness?t.borderThickness:0,d=o(t.backgroundColor,t.backgroundOpacity,{r:0,g:0,b:0,a:1}),u=o(t.borderColor,t.borderOpacity,d),f=t.position?t.position:{x:-10,y:1,z:1},p=void 0===t.inFront||t.inFront;"false"!==p&&"0"!==p||(p=!1);var g=t.alignment||n.SpriteAlignment.topLeft;"string"==typeof g&&g in n.SpriteAlignment&&(g=n.SpriteAlignment[g]);var m="";t.bold&&(m="bold "),this.context.font=m+a+"px "+s;var v=this.context.measureText(this.text).width;i||(c=0);var _=v+2.5*c+2*h,y=1.25*a+2*c+2*h;if(t.backgroundImage){var b=t.backgroundImage,x=t.backgroundWidth?t.backgroundWidth:b.width,w=t.backgroundHeight?t.backgroundHeight:b.height;x>_&&(_=x),w>y&&(y=w)}if(this.canvas.width=_,this.canvas.height=y,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),m="",t.bold&&(m="bold "),this.context.font=m+a+"px "+s,this.context.fillStyle="rgba("+d.r+","+d.g+","+d.b+","+d.a+")",this.context.strokeStyle="rgba("+u.r+","+u.g+","+u.b+","+u.a+")",t.backgroundGradient){let e=this.context.createLinearGradient(0,y/2,_,y/2),i=r.Gradient.getGradient(t.backgroundGradient),s=i.range(),n=-1,a=1;s&&(n=s[0],a=s[1]);let l=a-n;for(let t=0;t<1.01;t+=.1){let r=o(i.valueToHex(n+l*t)),s="rgba("+r.r+","+r.g+","+r.b+","+r.a+")";e.addColorStop(t,s)}this.context.fillStyle=e}this.context.lineWidth=c,i&&function(t,e,i,r,s,n,a){t.beginPath(),t.moveTo(e+n,i),t.lineTo(e+r-n,i),t.quadraticCurveTo(e+r,i,e+r,i+n),t.lineTo(e+r,i+s-n),t.quadraticCurveTo(e+r,i+s,e+r-n,i+s),t.lineTo(e+n,i+s),t.quadraticCurveTo(e,i+s,e,i+s-n),t.lineTo(e,i+n),t.quadraticCurveTo(e,i,e+n,i),t.closePath(),t.fill(),a&&t.stroke()}(this.context,c,c,_-2*c,y-2*c,6,c>0),t.backgroundImage&&this.context.drawImage(b,0,0,_,y),this.context.fillStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",this.context.fillText(this.text,c+h,a+c+h,v);var A=new n.Texture(this.canvas);A.needsUpdate=!0,this.sprite.material=new n.SpriteMaterial({map:A,useScreenCoordinates:e,alignment:g,depthTest:!p,screenOffset:t.screenOffset||null}),this.sprite.scale.set(1,1,1),this.sprite.position.set(f.x,f.y,f.z)}dispose(){void 0!==this.sprite.material.map&&this.sprite.material.map.dispose(),void 0!==this.sprite.material&&this.sprite.material.dispose()}}const l={"ALA:N":-.15,"ALA:CA":.1,"ALA:CB":0,"ALA:C":.6,"ALA:O":-.55,"ARG:N":-.15,"ARG:CA":.1,"ARG:CB":0,"ARG:CG":0,"ARG:CD":.1,"ARG:NE":-.1,"ARG:CZ":.5,"ARG:NH1":.25,"ARG:NH2":.25,"ARG:C":.6,"ARG:O":-.55,"ASN:N":-.15,"ASN:CA":.1,"ASN:CB":0,"ASN:CG":.55,"ASN:OD1":-.55,"ASN:ND2":0,"ASN:C":.6,"ASN:O":-.55,"ASP:N":-.15,"ASP:CA":.1,"ASP:CB":0,"ASP:CG":.14,"ASP:OD1":-.57,"ASP:OD2":-.57,"ASP:C":.6,"ASP:O":-.55,"CYS:N":-.15,"CYS:CA":.1,"CYS:CB":.19,"CYS:SG":-.19,"CYS:C":.6,"CYS:O":-.55,"GLN:N":-.15,"GLN:CA":.1,"GLN:CB":0,"GLN:CG":0,"GLN:CD":.55,"GLN:OE1":-.55,"GLN:NE2":0,"GLN:C":.6,"GLN:O":-.55,"GLU:N":-.15,"GLU:CA":.1,"GLU:CB":0,"GLU:CG":0,"GLU:CD":.14,"GLU:OE1":-.57,"GLU:OE2":-.57,"GLU:C":.6,"GLU:O":-.55,"GLY:N":-.15,"GLY:CA":.1,"GLY:C":.6,"GLY:O":-.55,"HIS:N":-.15,"HIS:CA":.1,"HIS:CB":0,"HIS:CG":.1,"HIS:ND1":-.1,"HIS:CD2":.1,"HIS:NE2":-.4,"HIS:CE1":.3,"HIS:C":.6,"HIS:O":-.55,"ILE:N":-.15,"ILE:CA":.1,"ILE:CB":0,"ILE:CG2":0,"ILE:CG1":0,"ILE:CD":0,"ILE:C":.6,"ILE:O":-.55,"LEU:N":-.15,"LEU:CA":.1,"LEU:CB":0,"LEU:CG":0,"LEU:CD1":0,"LEU:CD2":0,"LEU:C":.6,"LEU:O":-.55,"LYS:N":-.15,"LYS:CA":.1,"LYS:CB":0,"LYS:CG":0,"LYS:CD":0,"LYS:CE":.25,"LYS:NZ":.75,"LYS:C":.6,"LYS:O":-.55,"MET:N":-.15,"MET:CA":.1,"MET:CB":0,"MET:CG":.06,"MET:SD":-.12,"MET:CE":.06,"MET:C":.6,"MET:O":-.55,"PHE:N":-.15,"PHE:CA":.1,"PHE:CB":0,"PHE:CG":0,"PHE:CD1":0,"PHE:CD2":0,"PHE:CE1":0,"PHE:CE2":0,"PHE:CZ":0,"PHE:C":.6,"PHE:O":-.55,"PRO:N":-.25,"PRO:CD":.1,"PRO:CA":.1,"PRO:CB":0,"PRO:CG":0,"PRO:C":.6,"PRO:O":-.55,"SER:N":-.15,"SER:CA":.1,"SER:CB":.25,"SER:OG":-.25,"SER:C":.6,"SER:O":-.55,"THR:N":-.15,"THR:CA":.1,"THR:CB":.25,"THR:OG1":-.25,"THR:CG2":0,"THR:C":.6,"THR:O":-.55,"TRP:N":-.15,"TRP:CA":.1,"TRP:CB":0,"TRP:CG":-.03,"TRP:CD2":.1,"TRP:CE2":-.04,"TRP:CE3":-.03,"TRP:CD1":.06,"TRP:NE1":-.06,"TRP:CZ2":0,"TRP:CZ3":0,"TRP:CH2":0,"TRP:C":.6,"TRP:O":-.55,"TYR:N":-.15,"TYR:CA":.1,"TYR:CB":0,"TYR:CG":0,"TYR:CD1":0,"TYR:CE1":0,"TYR:CD2":0,"TYR:CE2":0,"TYR:CZ":.25,"TYR:OH":-.25,"TYR:C":.6,"TYR:O":-.55,"VAL:N":-.15,"VAL:CA":.1,"VAL:CB":0,"VAL:CG1":0,"VAL:CG2":0,"VAL:C":.6,"VAL:O":-.55};function h(t,e){if((!e||void 0===t.partialCharge)&&t.resn&&t.atom){var i=t.resn+":"+t.atom;t.properties.partialCharge=l[i]}}var c=i(797),d=i(865),u=i(392);function f(t,e){for(var i=[[]],r=void 0===(e=e||{}).assignBonds||e.assignBonds,s=t.trimStart().split(/\r?\n|\r/);s.length>0&&!(s.length<3);){var a=parseInt(s[0]);if(isNaN(a)||a<=0)break;if(s.length1){var l=new Float32Array(o[1].split(/\s+/)),h=new n.Matrix3(l[0],l[3],l[6],l[1],l[4],l[7],l[2],l[5],l[8]);i.modelData=[{cryst:{matrix:h}}]}for(var c=2,d=i[i.length-1].length,f=d+a,p=d;p=7&&(m.dx=parseFloat(g[4]),m.dy=parseFloat(g[5]),m.dz=parseFloat(g[6]))}if(!e.multimodel)break;i.push([]),s.splice(0,c)}if(r)for(let t=0;t3&&r[3].length>38&&(i=r[3].substring(34,39)),"V2000"===i?function(t,e){var i=[[]],r=!1;for(void 0!==e.keepH&&(r=!e.keepH);t.length>0&&!(t.length<4);){var s=parseInt(t[3].substring(0,3));if(isNaN(s)||s<=0)break;var n=parseInt(t[3].substring(3,6)),a=4;if(t.length<4+s+n)break;var o,l,h=[],c=i[i.length-1].length,d=c+s;for(o=c;o0&&!(t.length<8)&&t[4].startsWith("M V30 BEGIN CTAB")&&t[5].startsWith("M V30 COUNTS")&&!(t[5].length<14);){var s=t[5].substring(13).match(/\S+/g);if(s.length<2)break;var n=parseInt(s[0]);if(isNaN(n)||n<=0)break;var a=parseInt(s[1]),o=7;if(t.length<8+n+a)break;var l,h=[],c=i[i.length-1].length,d=c+n;for(l=c;l4){var f={},p=u[1].replace(/ /g,"");f.atom=f.elem=p[0].toUpperCase()+p.substring(1).toLowerCase(),"H"===f.elem&&r||(f.serial=l,h[l]=i[i.length-1].length,f.x=parseFloat(u[2]),f.y=parseFloat(u[3]),f.z=parseFloat(u[4]),f.hetflag=!0,f.bonds=[],f.bondOrder=[],f.properties={},f.index=i[i.length-1].length,i[i.length-1].push(f))}}if("M V30 END ATOM"!==t[o])break;if(o++,0===a||"M V30 BEGIN BOND"!==t[o])break;for(o++,l=0;l3){var m=h[parseInt(g[2])-1+c],v=h[parseInt(g[3])-1+c],_=parseFloat(g[1]);void 0!==m&&void 0!==v&&(i[i.length-1][m].bonds.push(v),i[i.length-1][m].bondOrder.push(_),i[i.length-1][v].bonds.push(m),i[i.length-1][v].bondOrder.push(_))}}if(!e.multimodel)break;for(e.onemol||i.push([]);"$$$$"!==t[o]&&oi)break;if(t.atom==n.atom)continue;const o=Math.abs(t.y-n.y);if(o>i)continue;const l=Math.abs(t.x-n.x);if(l>i)continue;const h=l*l+o*o+e*e;h>r||t.chain==n.chain&&Math.abs(t.resi-n.resi)<4||(h1.001;)i[t]-=1,r[t]-=1}const s=new n.Vector3(r[0],r[1],r[2]);return s.applyMatrix3(h),s};if(i.normalizeAssembly&&r)for(let i=0;i.001&&(l=i),t[i].translate(s)}if(s){if(t.length>1)for(let i=0;i=0){const i=new n.Vector3;for(let r=0;r1)break;(0,_.areConnected)(r,t,e)&&(-1===r.bonds.indexOf(t.index)&&(r.bonds.push(t.index),r.bondOrder.push(1),t.bonds.push(r.index),t.bondOrder.push(1)),r.resi!==t.resi&&(s=!0))}}}function x(t,e={}){const i=[],r=!e.doAssembly,s=i.modelData=[],a=void 0===e.assignBonds||e.assignBonds;function o(t,e){const i=[];let r=0,s=0;for(;s-1){let e=d.split("");e[t]="_",d=(d=e.join("")).substring(0,t)+"_"+d.substring(t+1)}}h.push(d)}}let u=0;for(;uMOLECULE/),n=t.search(/@ATOM/);if(-1==s||-1==n)return i;for(var a=t.substring(s).split(/\r?\n|\r/);a.length>0;){var o=[],l=a[2].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),h=parseInt(l[0]),c=0;l.length>1&&(c=parseInt(l[1]));var d,u=4;for(d=3;dATOM"==a[d]){u=d+1;break}var f=i[i.length-1].length,p=f+h;for(d=f;dBOND"==a[u++]){b=!0;break}if(b&&c)for(d=0;d0&&"H"===i[0]&&"Hg"!==i&&"He"!==i&&"Hf"!==i&&"Hs"!==i&&"Ho"!==i&&(i="H"),i.length>1&&(i=i[0].toUpperCase()+i.substring(1).toLowerCase(),void 0===C.bondTable[i]?i=i[0]:e&&("Ca"===i||"Cd"===i)&&(i="C")),i}function M(t){for(const e in t)return!1;return!0}function z(t,e,i){const r=[],s=void 0===e.assignBonds||e.assignBonds,a=!e.keepH,o=!!e.noSecondaryStructure,l=!e.noComputeSecondaryStructure,h=!e.doAssembly,c=e.altLoc?e.altLoc:"A",d={symmetries:[],cryst:void 0};let u,f=[];const p=[];let g;const _={};for(let e=0;e=4?1:i}}else _[a]=1,0!=e.bonds.length&&e.bonds[e.bonds.length-1]===n||(e.bonds.push(n),e.bondOrder.push(1))}}else if("HELIX "===s){o=g.substring(19,20),l=parseInt(g.substring(21,25)),m=parseInt(g.substring(33,37)),o in i||(i[o]={}),i[o][l]="h1";for(let t=l+1;t1&&("1"==t[1]?e.ssbegin=!0:"2"==t[1]&&(e.ssend=!0))}}return[r,d,f]}function T(t,e){e=e||{};var i=[],r={};i.modelData=[];for(var s=t.split(/\r?\n|\r/);s.length>0;){var n=z(s,e,r),a=n[0],o=n[1];if(s=n[2],0!=a.length){if(e.multimodel&&e.onemol&&i.length>0)for(var l=i[0].length,h=0;h1&&e[1].toUpperCase()!=e[1]&&(g=e.substring(0,2)),l="H"==s[0],n[t]=i[i.length-1].length,i[i.length-1].push({resn:r,x:c,y:d,z:u,elem:g,hetflag:l,chain:a,resi:o,serial:t,atom:e,bonds:[],ss:"c",bondOrder:[],properties:{charge:f,partialCharge:f,radius:p},pdbline:s})}else if("CONECT"==o){var v=parseInt(s.substring(6,11)),_=i[i.length-1][n[v]];for(let t=0;t<4;t++){var y=parseInt(s.substring([11,16,21,26][t],[11,16,21,26][t]+5)),x=i[i.length-1][n[y]];void 0!==_&&void 0!==x&&(_.bonds.push(n[y]),_.bondOrder.push(1))}}}for(let t=0;t0){var R=g.bioAssemblyList[l].transformList;for(h=0,p=R.length;h{t.chainIndexList.forEach((e=>{N[e]="polymer"==t.type}))}));var G=0;for(f=0;f=A.length||O(A[et]!=tt))&&(J=!0)}var it=g.groupIdList[x],rt=X.groupName;let t=X.chemCompType;var st=w;let e=D.has(t)||!N[b];for(d=0;d=w){G=t;break}let s=H[e],n=H[i],a=j[s],o=j[n];a&&o&&(a.bonds.push(n),a.bondOrder.push(r),o.bonds.push(s),o.bondOrder.push(r))}e.multimodel&&(e.onemol||_.push([]))}if(!o)for(let t=0;t<_.length;t++)v(y[t].symmetries,_[t],e,y[t].cryst);return a&&!s&&m(_,e.hbondCutoff),_}function R(t){var e,i=[],r=0,s=t.split(/\r?\n|\r/);if(!(s.length>0&&s[0].includes("VERSION")))return[];var n=s.filter((function(t){return t.includes("POINTERS")||t.includes("ATOM_NAME")||t.includes("CHARGE")||t.includes("RADII")||t.includes("BONDS_INC_HYDROGEN")||t.includes("BONDS_WITHOUT_HYDROGEN")})),a=c("POINTERS");if(-1==a)return[];var o=d(a),l=parseInt(s[a+1].slice(0,o[1]));if(isNaN(l)||l<=0)return[];if(-1==(a=c("ATOM_NAME")))return[];var h=(o=d(a))[0];for(let t=0;t0){for(;!s[e].includes("FORMAT");)e++;return e}return-1}function d(t){var e=s[t].match(/\((\d*)\S*/),i=s[t].match(/[a-zA-Z](\d*)\)\s*/);return null==i&&(i=s[t].match(/[a-zA-Z](\d*)\.\d*\)\s*/)),[e[1],i[1]]}return[i]}function P(t,e){const i=[],r=t.split(/\r?\n|\r/);for(;r.length>0;){const t=parseInt(r[1]);if(r.length<3||isNaN(t)||t<=0||r.length44&&(n.dx=10*parseFloat(i.slice(44,52)),n.dy=10*parseFloat(i.slice(52,60)),n.dz=10*parseFloat(i.slice(60,68))),e[t]=n}if(r.length<=s+3){const t=r[s++].trim().split(/\s+/);if(3===t.length){for(let e=0;e<3;e++)t[e]=(10*parseFloat(t[e])).toString();i.box=t}}r.splice(0,++s)}for(let t=0;t=0;i--)e=j(e,t.encoding[i]);return e}function j(t,e){switch(e.kind){case"ByteArray":switch(e.type){case N.IntDataType.Uint8:return t;case N.IntDataType.Int8:return function(t){return new Int8Array(t.buffer,t.byteOffset)}(t);case N.IntDataType.Int16:return function(t){return q(t,2,Int16Array)}(t);case N.IntDataType.Uint16:return function(t){return q(t,2,Uint16Array)}(t);case N.IntDataType.Int32:return function(t){return q(t,4,Int32Array)}(t);case N.IntDataType.Uint32:return function(t){return q(t,4,Uint32Array)}(t);case N.FloatDataType.Float32:return function(t){return q(t,4,Float32Array)}(t);case N.FloatDataType.Float64:return function(t){return q(t,8,Float64Array)}(t);default:throw new Error("unreachable")}case"FixedPoint":return function(t,e){const i=t.length,r=W(e.srcType,i),s=1/e.factor;for(let e=0;et.name)),getField(t){const r=e[t];if(r)return i[t]||(i[t]=V(r.data)),i[t]}}}var Z=i(471);class Connectivity{constructor(t){if(this.C={},t){let e=t.getField("comp_id"),i=t.getField("atom_id_1"),r=t.getField("atom_id_2"),s=t.getField("value_order");for(let t=0;t0&&(n.bonds.push(a.index),a.bonds.push(n.index),n.bondOrder.push(o),a.bondOrder.push(o))}}for(let t of e.C){let e=t[0],i=t[1],r=t[2],s=this.geta(e),n=this.geta(i);null!=s&&null!=n&&(s.bonds.push(n.index),n.bonds.push(s.index),s.bondOrder.push(r),n.bondOrder.push(r))}}}function X(t,e){var i=!e.keepH,r=e.altLoc?e.altLoc:"A",s=!e.noComputeSecondaryStructure;const a=!e.doAssembly,o=void 0===e.assignBonds||e.assignBonds;if("string"==typeof t)try{t=(0,L.base64ToArray)(t)}catch(e){t=(new TextEncoder).encode(t)}else t=new Uint8Array(t);var l=Z.decodeMsgpack(t);31==l&&(t=(0,L.inflateString)(t,!1),l=Z.decodeMsgpack(t));var h=[],c=h.modelData=[],d=l.dataBlocks.length;if(0==d)return h;e.multimodel||(d=1);for(let t=0;t1&&("1"==t[1]?i.ssbegin=!0:"2"==t[1]&&(i.ssend=!0))}}}e.multimodel&&t=0||window.navigator.userAgent.indexOf("Trident/")>=0)&&(tt=!0);class MarchingCubeInitializer{constructor(){this.ISDONE=2,this.edgeTable=new Uint32Array([0,0,0,0,0,0,0,2816,0,0,0,1792,0,3328,3584,3840,0,0,0,138,0,21,0,134,0,0,0,652,0,2067,3865,3600,0,0,0,42,0,0,0,294,0,0,21,28,0,3875,1049,3360,0,168,162,170,0,645,2475,2210,0,687,293,172,4010,3747,3497,3232,0,0,0,0,0,69,0,900,0,0,0,1792,138,131,1608,1920,0,81,0,2074,84,85,84,86,0,81,0,3676,330,1105,1881,1616,0,0,0,42,0,69,0,502,0,0,21,3580,138,2035,1273,1520,2816,104,2337,106,840,581,367,102,2816,3695,3429,3180,1898,1635,1385,1120,0,0,0,0,0,0,0,3910,0,0,69,588,42,2083,41,2880,0,0,0,1722,0,2293,4095,3830,0,255,757,764,2538,2291,3065,2800,0,0,81,338,0,3925,1119,3414,84,855,85,340,2130,2899,89,2384,1792,712,194,1162,4036,3781,3535,3270,708,719,197,204,3018,2755,2505,2240,0,0,0,0,168,420,168,1958,162,162,676,2988,170,163,680,928,3328,3096,3328,3642,52,53,1855,1590,2340,2111,2869,2620,298,51,825,560,3584,3584,3090,3482,1668,1941,1183,1430,146,2975,2069,2460,154,915,153,400,3840,3592,3329,3082,1796,1541,1295,1030,2818,2575,2309,2060,778,515,265,0]),this.triTable=[[],[],[],[],[],[],[],[11,9,8],[],[],[],[8,10,9],[],[10,8,11],[9,11,10],[8,10,9,8,11,10],[],[],[],[1,7,3],[],[4,2,0],[],[2,1,7],[],[],[],[2,7,3,2,9,7],[],[1,4,11,1,0,4],[3,8,0,11,9,4,11,10,9],[4,11,9,11,10,9],[],[],[],[5,3,1],[],[],[],[2,5,8,2,1,5],[],[],[2,4,0],[3,2,4],[],[0,9,1,8,10,5,8,11,10],[3,4,0,3,10,4],[5,8,10,8,11,10],[],[3,5,7],[7,1,5],[1,7,3,1,5,7],[],[9,2,0,9,7,2],[0,3,8,1,7,11,1,5,7],[11,1,7,1,5,7],[],[9,1,0,5,3,2,5,7,3],[8,2,5,8,0,2],[2,5,3,5,7,3],[3,9,1,3,8,9,7,11,10,7,10,5],[9,1,0,10,7,11,10,5,7],[3,8,0,7,10,5,7,11,10],[11,5,7,11,10,5],[],[],[],[],[],[0,6,2],[],[7,2,9,7,9,8],[],[],[],[8,10,9],[7,1,3],[7,1,0],[6,9,3,6,10,9],[7,10,8,10,9,8],[],[6,0,4],[],[11,1,4,11,3,1],[2,4,6],[2,0,4,2,4,6],[2,4,6],[1,4,2,4,6,2],[],[6,0,4],[],[2,11,3,6,9,4,6,10,9],[8,6,1,8,1,3],[10,0,6,0,4,6],[8,0,3,9,6,10,9,4,6],[10,4,6,10,9,4],[],[],[],[5,3,1],[],[0,6,2],[],[7,4,8,5,2,1,5,6,2],[],[],[2,4,0],[7,4,8,2,11,3,10,5,6],[7,1,3],[5,6,10,0,9,1,8,7,4],[5,6,10,7,0,3,7,4,0],[10,5,6,4,8,7],[9,11,8],[3,5,6],[0,5,11,0,11,8],[6,3,5,3,1,5],[3,9,6,3,8,9],[9,6,0,6,2,0],[0,3,8,2,5,6,2,1,5],[1,6,2,1,5,6],[9,11,8],[1,0,9,6,10,5,11,3,2],[6,10,5,2,8,0,2,11,8],[3,2,11,10,5,6],[10,5,6,9,3,8,9,1,3],[0,9,1,5,6,10],[8,0,3,10,5,6],[10,5,6],[],[],[],[],[],[],[],[1,10,2,9,11,6,9,8,11],[],[],[6,0,2],[3,6,9,3,2,6],[3,5,1],[0,5,1,0,11,5],[0,3,5],[6,9,11,9,8,11],[],[],[],[4,5,9,7,1,10,7,3,1],[],[11,6,7,2,4,5,2,0,4],[11,6,7,8,0,3,1,10,2,9,4,5],[6,7,11,1,10,2,9,4,5],[],[4,1,0,4,5,1,6,7,3,6,3,2],[9,4,5,0,6,7,0,2,6],[4,5,9,6,3,2,6,7,3],[6,7,11,5,3,8,5,1,3],[6,7,11,4,1,0,4,5,1],[4,5,9,3,8,0,11,6,7],[9,4,5,7,11,6],[],[],[0,6,4],[8,6,4,8,1,6],[],[0,10,2,0,9,10,4,8,11,4,11,6],[10,2,1,6,0,3,6,4,0],[10,2,1,11,4,8,11,6,4],[4,2,6],[1,0,9,2,4,8,2,6,4],[2,4,0,2,6,4],[8,2,4,2,6,4],[11,4,1,11,6,4],[0,9,1,4,11,6,4,8,11],[3,6,0,6,4,0],[8,6,4,8,11,6],[10,8,9],[6,3,9,6,7,3],[6,7,1],[10,7,1,7,3,1],[7,11,6,8,10,2,8,9,10],[11,6,7,10,0,9,10,2,0],[2,1,10,7,11,6,8,0,3],[1,10,2,6,7,11],[7,2,6,7,9,2],[1,0,9,3,6,7,3,2,6],[7,0,6,0,2,6],[2,7,3,2,6,7],[7,11,6,3,9,1,3,8,9],[9,1,0,11,6,7],[0,3,8,11,6,7],[11,6,7],[],[],[],[],[5,3,7],[8,5,2,8,7,5],[5,3,7],[1,10,2,5,8,7,5,9,8],[1,7,5],[1,7,5],[9,2,7,9,7,5],[11,3,2,8,5,9,8,7,5],[1,3,7,1,7,5],[0,7,1,7,5,1],[9,3,5,3,7,5],[9,7,5,9,8,7],[8,10,11],[3,4,10,3,10,11],[8,10,11],[5,9,4,1,11,3,1,10,11],[2,4,5],[5,2,4,2,0,4],[0,3,8,5,9,4,10,2,1],[2,1,10,9,4,5],[2,8,5,2,11,8],[3,2,11,1,4,5,1,0,4],[9,4,5,8,2,11,8,0,2],[11,3,2,9,4,5],[8,5,3,5,1,3],[5,0,4,5,1,0],[3,8,0,4,5,9],[9,4,5],[11,9,10],[11,9,10],[1,11,4,1,10,11],[8,7,4,11,1,10,11,3,1],[2,7,9,2,9,10],[4,8,7,0,10,2,0,9,10],[2,1,10,0,7,4,0,3,7],[10,2,1,8,7,4],[1,7,4],[3,2,11,4,8,7,9,1,0],[11,4,2,4,0,2],[2,11,3,7,4,8],[4,1,7,1,3,7],[1,0,9,8,7,4],[3,4,0,3,7,4],[8,7,4],[8,9,10,8,10,11],[3,9,11,9,10,11],[0,10,8,10,11,8],[10,3,1,10,11,3],[2,8,10,8,9,10],[9,2,0,9,10,2],[8,0,3,1,10,2],[10,2,1],[1,11,9,11,8,9],[11,3,2,0,9,1],[11,0,2,11,8,0],[11,3,2],[8,1,3,8,9,1],[9,1,0],[8,0,3],[]],this.edgeTable2=[0,265,515,778,2060,2309,2575,2822,1030,1295,1541,1804,3082,3331,3593,3840,400,153,915,666,2460,2197,2975,2710,1430,1183,1941,1692,3482,3219,3993,3728,560,825,51,314,2620,2869,2111,2358,1590,1855,1077,1340,3642,3891,3129,3376,928,681,419,170,2988,2725,2479,2214,1958,1711,1445,1196,4010,3747,3497,3232,2240,2505,2755,3018,204,453,719,966,3270,3535,3781,4044,1226,1475,1737,1984,2384,2137,2899,2650,348,85,863,598,3414,3167,3925,3676,1370,1107,1881,1616,2800,3065,2291,2554,764,1013,255,502,3830,4095,3317,3580,1786,2035,1273,1520,2912,2665,2403,2154,876,613,367,102,3942,3695,3429,3180,1898,1635,1385,1120,1120,1385,1635,1898,3180,3429,3695,3942,102,367,613,876,2154,2403,2665,2912,1520,1273,2035,1786,3580,3317,4095,3830,502,255,1013,764,2554,2291,3065,2800,1616,1881,1107,1370,3676,3925,3167,3414,598,863,85,348,2650,2899,2137,2384,1984,1737,1475,1226,4044,3781,3535,3270,966,719,453,204,3018,2755,2505,2240,3232,3497,3747,4010,1196,1445,1711,1958,2214,2479,2725,2988,170,419,681,928,3376,3129,3891,3642,1340,1077,1855,1590,2358,2111,2869,2620,314,51,825,560,3728,3993,3219,3482,1692,1941,1183,1430,2710,2975,2197,2460,666,915,153,400,3840,3593,3331,3082,1804,1541,1295,1030,2822,2575,2309,2060,778,515,265,0],this.triTable2=[[],[8,3,0],[9,0,1],[8,3,1,8,1,9],[11,2,3],[11,2,0,11,0,8],[11,2,3,0,1,9],[2,1,11,1,9,11,11,9,8],[10,1,2],[8,3,0,1,2,10],[9,0,2,9,2,10],[3,2,8,2,10,8,8,10,9],[10,1,3,10,3,11],[1,0,10,0,8,10,10,8,11],[0,3,9,3,11,9,9,11,10],[8,10,9,8,11,10],[8,4,7],[3,0,4,3,4,7],[1,9,0,8,4,7],[9,4,1,4,7,1,1,7,3],[2,3,11,7,8,4],[7,11,4,11,2,4,4,2,0],[3,11,2,4,7,8,9,0,1],[2,7,11,2,1,7,1,4,7,1,9,4],[10,1,2,8,4,7],[2,10,1,0,4,7,0,7,3],[4,7,8,0,2,10,0,10,9],[2,7,3,2,9,7,7,9,4,2,10,9],[8,4,7,11,10,1,11,1,3],[11,4,7,1,4,11,1,11,10,1,0,4],[3,8,0,7,11,4,11,9,4,11,10,9],[7,11,4,4,11,9,11,10,9],[9,5,4],[3,0,8,4,9,5],[5,4,0,5,0,1],[4,8,5,8,3,5,5,3,1],[11,2,3,9,5,4],[9,5,4,8,11,2,8,2,0],[3,11,2,1,5,4,1,4,0],[8,5,4,2,5,8,2,8,11,2,1,5],[2,10,1,9,5,4],[0,8,3,5,4,9,10,1,2],[10,5,2,5,4,2,2,4,0],[3,4,8,3,2,4,2,5,4,2,10,5],[5,4,9,1,3,11,1,11,10],[0,9,1,4,8,5,8,10,5,8,11,10],[3,4,0,3,10,4,4,10,5,3,11,10],[4,8,5,5,8,10,8,11,10],[9,5,7,9,7,8],[0,9,3,9,5,3,3,5,7],[8,0,7,0,1,7,7,1,5],[1,7,3,1,5,7],[11,2,3,8,9,5,8,5,7],[9,2,0,9,7,2,2,7,11,9,5,7],[0,3,8,2,1,11,1,7,11,1,5,7],[2,1,11,11,1,7,1,5,7],[1,2,10,5,7,8,5,8,9],[9,1,0,10,5,2,5,3,2,5,7,3],[5,2,10,8,2,5,8,5,7,8,0,2],[10,5,2,2,5,3,5,7,3],[3,9,1,3,8,9,7,11,10,7,10,5],[9,1,0,10,7,11,10,5,7],[3,8,0,7,10,5,7,11,10],[11,5,7,11,10,5],[11,7,6],[0,8,3,11,7,6],[9,0,1,11,7,6],[7,6,11,3,1,9,3,9,8],[2,3,7,2,7,6],[8,7,0,7,6,0,0,6,2],[1,9,0,3,7,6,3,6,2],[7,6,2,7,2,9,2,1,9,7,9,8],[1,2,10,6,11,7],[2,10,1,7,6,11,8,3,0],[11,7,6,10,9,0,10,0,2],[7,6,11,3,2,8,8,2,10,8,10,9],[6,10,7,10,1,7,7,1,3],[6,10,1,6,1,7,7,1,0,7,0,8],[9,0,3,6,9,3,6,10,9,6,3,7],[6,10,7,7,10,8,10,9,8],[8,4,6,8,6,11],[11,3,6,3,0,6,6,0,4],[0,1,9,4,6,11,4,11,8],[1,9,4,11,1,4,11,3,1,11,4,6],[3,8,2,8,4,2,2,4,6],[2,0,4,2,4,6],[1,9,0,3,8,2,2,8,4,2,4,6],[9,4,1,1,4,2,4,6,2],[10,1,2,11,8,4,11,4,6],[10,1,2,11,3,6,6,3,0,6,0,4],[0,2,10,0,10,9,4,11,8,4,6,11],[2,11,3,6,9,4,6,10,9],[8,4,6,8,6,1,6,10,1,8,1,3],[1,0,10,10,0,6,0,4,6],[8,0,3,9,6,10,9,4,6],[10,4,6,10,9,4],[9,5,4,7,6,11],[4,9,5,3,0,8,11,7,6],[6,11,7,4,0,1,4,1,5],[6,11,7,4,8,5,5,8,3,5,3,1],[4,9,5,6,2,3,6,3,7],[9,5,4,8,7,0,0,7,6,0,6,2],[4,0,1,4,1,5,6,3,7,6,2,3],[7,4,8,5,2,1,5,6,2],[6,11,7,1,2,10,9,5,4],[11,7,6,8,3,0,1,2,10,9,5,4],[11,7,6,10,5,2,2,5,4,2,4,0],[7,4,8,2,11,3,10,5,6],[4,9,5,6,10,7,7,10,1,7,1,3],[5,6,10,0,9,1,8,7,4],[5,6,10,7,0,3,7,4,0],[10,5,6,4,8,7],[5,6,9,6,11,9,9,11,8],[0,9,5,0,5,3,3,5,6,3,6,11],[0,1,5,0,5,11,5,6,11,0,11,8],[11,3,6,6,3,5,3,1,5],[9,5,6,3,9,6,3,8,9,3,6,2],[5,6,9,9,6,0,6,2,0],[0,3,8,2,5,6,2,1,5],[1,6,2,1,5,6],[1,2,10,5,6,9,9,6,11,9,11,8],[1,0,9,6,10,5,11,3,2],[6,10,5,2,8,0,2,11,8],[3,2,11,10,5,6],[10,5,6,9,3,8,9,1,3],[0,9,1,5,6,10],[8,0,3,10,5,6],[10,5,6],[10,6,5],[8,3,0,10,6,5],[0,1,9,5,10,6],[10,6,5,9,8,3,9,3,1],[3,11,2,10,6,5],[6,5,10,2,0,8,2,8,11],[1,9,0,6,5,10,11,2,3],[1,10,2,5,9,6,9,11,6,9,8,11],[1,2,6,1,6,5],[0,8,3,2,6,5,2,5,1],[5,9,6,9,0,6,6,0,2],[9,6,5,3,6,9,3,9,8,3,2,6],[11,6,3,6,5,3,3,5,1],[0,5,1,0,11,5,5,11,6,0,8,11],[0,5,9,0,3,5,3,6,5,3,11,6],[5,9,6,6,9,11,9,8,11],[10,6,5,4,7,8],[5,10,6,7,3,0,7,0,4],[5,10,6,0,1,9,8,4,7],[4,5,9,6,7,10,7,1,10,7,3,1],[7,8,4,2,3,11,10,6,5],[11,6,7,10,2,5,2,4,5,2,0,4],[11,6,7,8,0,3,1,10,2,9,4,5],[6,7,11,1,10,2,9,4,5],[7,8,4,5,1,2,5,2,6],[4,1,0,4,5,1,6,7,3,6,3,2],[9,4,5,8,0,7,0,6,7,0,2,6],[4,5,9,6,3,2,6,7,3],[6,7,11,4,5,8,5,3,8,5,1,3],[6,7,11,4,1,0,4,5,1],[4,5,9,3,8,0,11,6,7],[9,4,5,7,11,6],[10,6,4,10,4,9],[8,3,0,9,10,6,9,6,4],[1,10,0,10,6,0,0,6,4],[8,6,4,8,1,6,6,1,10,8,3,1],[2,3,11,6,4,9,6,9,10],[0,10,2,0,9,10,4,8,11,4,11,6],[10,2,1,11,6,3,6,0,3,6,4,0],[10,2,1,11,4,8,11,6,4],[9,1,4,1,2,4,4,2,6],[1,0,9,3,2,8,2,4,8,2,6,4],[2,4,0,2,6,4],[3,2,8,8,2,4,2,6,4],[1,4,9,11,4,1,11,1,3,11,6,4],[0,9,1,4,11,6,4,8,11],[11,6,3,3,6,0,6,4,0],[8,6,4,8,11,6],[6,7,10,7,8,10,10,8,9],[9,3,0,6,3,9,6,9,10,6,7,3],[6,1,10,6,7,1,7,0,1,7,8,0],[6,7,10,10,7,1,7,3,1],[7,11,6,3,8,2,8,10,2,8,9,10],[11,6,7,10,0,9,10,2,0],[2,1,10,7,11,6,8,0,3],[1,10,2,6,7,11],[7,2,6,7,9,2,2,9,1,7,8,9],[1,0,9,3,6,7,3,2,6],[8,0,7,7,0,6,0,2,6],[2,7,3,2,6,7],[7,11,6,3,9,1,3,8,9],[9,1,0,11,6,7],[0,3,8,11,6,7],[11,6,7],[11,7,5,11,5,10],[3,0,8,7,5,10,7,10,11],[9,0,1,10,11,7,10,7,5],[3,1,9,3,9,8,7,10,11,7,5,10],[10,2,5,2,3,5,5,3,7],[5,10,2,8,5,2,8,7,5,8,2,0],[9,0,1,10,2,5,5,2,3,5,3,7],[1,10,2,5,8,7,5,9,8],[2,11,1,11,7,1,1,7,5],[0,8,3,2,11,1,1,11,7,1,7,5],[9,0,2,9,2,7,2,11,7,9,7,5],[11,3,2,8,5,9,8,7,5],[1,3,7,1,7,5],[8,7,0,0,7,1,7,5,1],[0,3,9,9,3,5,3,7,5],[9,7,5,9,8,7],[4,5,8,5,10,8,8,10,11],[3,0,4,3,4,10,4,5,10,3,10,11],[0,1,9,4,5,8,8,5,10,8,10,11],[5,9,4,1,11,3,1,10,11],[3,8,4,3,4,2,2,4,5,2,5,10],[10,2,5,5,2,4,2,0,4],[0,3,8,5,9,4,10,2,1],[2,1,10,9,4,5],[8,4,5,2,8,5,2,11,8,2,5,1],[3,2,11,1,4,5,1,0,4],[9,4,5,8,2,11,8,0,2],[11,3,2,9,4,5],[4,5,8,8,5,3,5,1,3],[5,0,4,5,1,0],[3,8,0,4,5,9],[9,4,5],[7,4,11,4,9,11,11,9,10],[3,0,8,7,4,11,11,4,9,11,9,10],[11,7,4,1,11,4,1,10,11,1,4,0],[8,7,4,11,1,10,11,3,1],[2,3,7,2,7,9,7,4,9,2,9,10],[4,8,7,0,10,2,0,9,10],[2,1,10,0,7,4,0,3,7],[10,2,1,8,7,4],[2,11,7,2,7,1,1,7,4,1,4,9],[3,2,11,4,8,7,9,1,0],[7,4,11,11,4,2,4,0,2],[2,11,3,7,4,8],[9,1,4,4,1,7,1,3,7],[1,0,9,8,7,4],[3,4,0,3,7,4],[8,7,4],[8,9,10,8,10,11],[0,9,3,3,9,11,9,10,11],[1,10,0,0,10,8,10,11,8],[10,3,1,10,11,3],[3,8,2,2,8,10,8,9,10],[9,2,0,9,10,2],[8,0,3,1,10,2],[10,2,1],[2,11,1,1,11,9,11,8,9],[11,3,2,0,9,1],[11,0,2,11,8,0],[11,3,2],[8,1,3,8,9,1],[9,1,0],[8,0,3],[]]}march(t,e,i,r){let s=!!r.fulltable,n=r.hasOwnProperty("origin")&&r.origin.hasOwnProperty("x")?r.origin:{x:0,y:0,z:0},a=!!r.voxel,o=r.matrix,l=r.nX||0,h=r.nY||0,c=r.nZ||0,d=r.scale||1,u=null;u=r.unitCube?r.unitCube:{x:d,y:d,z:d};let f,p,g=new Int32Array(l*h*c);for(f=0,p=g.length;f>2))+r+((2&e)>>1))*c+s+(1&e)]&this.ISDONE)<=3&&(e.push(e[r]),r=e.length-1,e.push(e[s]),s=e.length-1,e.push(e[n]),n=e.length-1),i.push(r),i.push(s),i.push(n)}}}laplacianSmooth(t,e,i){let r,s,n,a,o,l=new Array(e.length);for(r=0,s=e.length;r1e6&&(this.scaleFactor=this.defaultScaleFactor/2);let r=1/this.scaleFactor*5.5;this.pminx=t[0][0],this.pmaxx=t[1][0],this.pminy=t[0][1],this.pmaxy=t[1][1],this.pminz=t[0][2],this.pmaxz=t[1][2],e?(this.pminx-=this.probeRadius+r,this.pminy-=this.probeRadius+r,this.pminz-=this.probeRadius+r,this.pmaxx+=this.probeRadius+r,this.pmaxy+=this.probeRadius+r,this.pmaxz+=this.probeRadius+r):(this.pminx-=r,this.pminy-=r,this.pminz-=r,this.pmaxx+=r,this.pmaxy+=r,this.pmaxz+=r),this.pminx=Math.floor(this.pminx*this.scaleFactor)/this.scaleFactor,this.pminy=Math.floor(this.pminy*this.scaleFactor)/this.scaleFactor,this.pminz=Math.floor(this.pminz*this.scaleFactor)/this.scaleFactor,this.pmaxx=Math.ceil(this.pmaxx*this.scaleFactor)/this.scaleFactor,this.pmaxy=Math.ceil(this.pmaxy*this.scaleFactor)/this.scaleFactor,this.pmaxz=Math.ceil(this.pmaxz*this.scaleFactor)/this.scaleFactor,this.ptranx=-this.pminx,this.ptrany=-this.pminy,this.ptranz=-this.pminz,this.pLength=Math.ceil(this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.ceil(this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.ceil(this.scaleFactor*(this.pmaxz-this.pminz))+1,this.boundingatom(e),this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpDistance=new Float64Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Int32Array(this.pLength*this.pWidth*this.pHeight)}boundingatom(t){let e={};for(const i in this.vdwRadii){let r=this.vdwRadii[i];e[i]=t?(r+this.probeRadius)*this.scaleFactor+.5:r*this.scaleFactor+.5;let s=e[i]*e[i];this.widxz[i]=Math.floor(e[i])+1,this.depty[i]=new Int32Array(this.widxz[i]*this.widxz[i]);let n=0;for(let t=0;ts)this.depty[i][n]=-1;else{let t=Math.sqrt(s-r);this.depty[i][n]=Math.floor(t)}n++}}}fillvoxels(t,e){for(let t=0,e=this.vpBits.length;t=this.pLength||h>=this.pWidth||c>=this.pHeight)continue;let u=a*o+h*this.pHeight+c;if(this.vpBits[u]&this.INOUT){let a=e[this.vpAtomID[u]];if(a.serial!=t.serial){let e=i+f-Math.floor(.5+this.scaleFactor*(a.x+this.ptranx)),o=r+n-Math.floor(.5+this.scaleFactor*(a.y+this.ptrany)),l=s+p-Math.floor(.5+this.scaleFactor*(a.z+this.ptranz));f*f+n*n+p*p=this.pLength||h>=this.pWidth||c>=this.pHeight)continue;let u=a*o+h*this.pHeight+c;if(this.vpBits[u]&this.ISDONE){let a=e[this.vpAtomID[u]];if(a.serial!=t.serial){let e=r+f-Math.floor(.5+this.scaleFactor*(a.x+this.ptranx)),o=s+i-Math.floor(.5+this.scaleFactor*(a.y+this.ptrany)),l=n+p-Math.floor(.5+this.scaleFactor*(a.z+this.ptranz));f*f+i*i+p*p-1&&a-1&&l-1&&o=o)||(this.vpBits[t]|=this.ISBOUND))}fastoneshell(t,e){let i,r,s,n,a,o,l,h,c,d=[];if(0===t.length)return d;let u={ix:-1,iy:-1,iz:-1},f=this.pWidth*this.pHeight;for(let p=0,g=t.length;p-1&&u.iy-1&&u.iz-1&&(c=u.ix*f+this.pHeight*u.iy+u.iz,this.vpBits[c]&this.INOUT&&!(this.vpBits[c]&this.ISDONE)?(e.set(u.ix,u.iy,s+this.nb[t][2],h),n=u.ix-h.ix,a=u.iy-h.iy,o=u.iz-h.iz,l=n*n+a*a+o*o,this.vpDistance[c]=l,this.vpBits[c]|=this.ISDONE,this.vpBits[c]|=this.ISBOUND,d.push({ix:u.ix,iy:u.iy,iz:u.iz})):this.vpBits[c]&this.INOUT&&this.vpBits[c]&this.ISDONE&&(n=u.ix-h.ix,a=u.iy-h.iy,o=u.iz-h.iz,l=n*n+a*a+o*o,l-1&&u.iy-1&&u.iz-1&&(c=u.ix*f+this.pHeight*u.iy+u.iz,this.vpBits[c]&this.INOUT&&!(this.vpBits[c]&this.ISDONE)?(e.set(u.ix,u.iy,s+this.nb[t][2],h),n=u.ix-h.ix,a=u.iy-h.iy,o=u.iz-h.iz,l=n*n+a*a+o*o,this.vpDistance[c]=l,this.vpBits[c]|=this.ISDONE,this.vpBits[c]|=this.ISBOUND,d.push({ix:u.ix,iy:u.iy,iz:u.iz})):this.vpBits[c]&this.INOUT&&this.vpBits[c]&this.ISDONE&&(n=u.ix-h.ix,a=u.iy-h.iy,o=u.iz-h.iz,l=n*n+a*a+o*o,l-1&&u.iy-1&&u.iz-1&&(c=u.ix*f+this.pHeight*u.iy+u.iz,this.vpBits[c]&this.INOUT&&!(this.vpBits[c]&this.ISDONE)?(e.set(u.ix,u.iy,s+this.nb[t][2],h),n=u.ix-h.ix,a=u.iy-h.iy,o=u.iz-h.iz,l=n*n+a*a+o*o,this.vpDistance[c]=l,this.vpBits[c]|=this.ISDONE,this.vpBits[c]|=this.ISBOUND,d.push({ix:u.ix,iy:u.iy,iz:u.iz})):this.vpBits[c]&this.INOUT&&this.vpBits[c]&this.ISDONE&&(n=u.ix-h.ix,a=u.iy-h.iy,o=u.iz-h.iz,l=n*n+a*a+o*o,l0){var m=[n,n+1,n-1,n-2],v=d.faceidx;p[v]=m[0],p[v+1]=m[1],p[v+2]=m[3],p[v+3]=m[1],p[v+4]=m[2],p[v+5]=m[3],d.faceidx+=6}d.vertices+=2}}function ut(t,e,i,r,n,a,o){o&&"default"!==o||(o="rectangle"),"edged"===o?function(t,e,i,r,n){if(!(e.length<2)){var a,o;if(a=e[0],o=e[e.length-1],a=nt(a,r),o=nt(o,r),!n)return dt(t,a,o,i);var l,h,c,d,u,f,p,g,m,v,_,y,b,x,w,A,C,S,M,z,T,E,L=[],F=[[0,2,-6,-8],[-4,-2,6,4],[7,-1,-5,3],[-3,5,1,-7]];for(b=0,x=a.length;b0){var O=void 0!==y&&void 0!==_&&y.serial!==_.serial;for(w=0;w<4;w++){var D=[f+F[w][0],f+F[w][1],f+F[w][2],f+F[w][3]];if(E[g=M.faceidx]=D[0],E[g+1]=D[1],E[g+2]=D[3],E[g+3]=D[1],E[g+4]=D[2],E[g+5]=D[3],M.faceidx+=6,_.clickable||y.clickable||_.hoverable||y.hoverable){var k=L[D[3]].clone(),R=L[D[0]].clone(),P=L[D[2]].clone(),U=L[D[1]].clone();if(k.atom=L[D[3]].atom||null,P.atom=L[D[2]].atom||null,R.atom=L[D[0]].atom||null,U.atom=L[D[1]].atom||null,O){var B=k.clone().add(R).multiplyScalar(.5),N=P.clone().add(U).multiplyScalar(.5),G=k.clone().add(U).multiplyScalar(.5);w%2==0?((y.clickable||y.hoverable)&&(A=new J.Triangle(B,G,k),C=new J.Triangle(N,P,G),S=new J.Triangle(G,P,k),y.intersectionShape.triangle.push(A),y.intersectionShape.triangle.push(C),y.intersectionShape.triangle.push(S)),(_.clickable||_.hoverable)&&(A=new J.Triangle(R,U,G),C=new J.Triangle(U,N,G),S=new J.Triangle(R,G,B),_.intersectionShape.triangle.push(A),_.intersectionShape.triangle.push(C),_.intersectionShape.triangle.push(S))):((_.clickable||_.hoverable)&&(A=new J.Triangle(B,G,k),C=new J.Triangle(N,P,G),S=new J.Triangle(G,P,k),_.intersectionShape.triangle.push(A),_.intersectionShape.triangle.push(C),_.intersectionShape.triangle.push(S)),(y.clickable||y.hoverable)&&(A=new J.Triangle(R,U,G),C=new J.Triangle(U,N,G),S=new J.Triangle(R,G,B),y.intersectionShape.triangle.push(A),y.intersectionShape.triangle.push(C),y.intersectionShape.triangle.push(S)))}else(_.clickable||_.hoverable)&&(A=new J.Triangle(R,U,k),C=new J.Triangle(U,P,k),_.intersectionShape.triangle.push(A),_.intersectionShape.triangle.push(C))}}}M.vertices+=8,y=_}var V=L.length-8;for(z=(M=t.updateGeoGroup(8)).vertexArray,T=M.colorArray,E=M.faceArray,p=3*(f=M.vertices),g=M.faceidx,b=0;b<4;b++){L.push(L[2*b]),L.push(L[V+2*b]);var j=L[2*b],H=L[V+2*b];z[p+6*b]=j.x,z[p+1+6*b]=j.y,z[p+2+6*b]=j.z,z[p+3+6*b]=H.x,z[p+4+6*b]=H.y,z[p+5+6*b]=H.z,T[p+6*b]=m.r,T[p+1+6*b]=m.g,T[p+2+6*b]=m.b,T[p+3+6*b]=m.r,T[p+4+6*b]=m.g,T[p+5+6*b]=m.b}V+=8,A=[f,f+2,f+6,f+4],C=[f+1,f+5,f+7,f+3],E[g]=A[0],E[g+1]=A[1],E[g+2]=A[3],E[g+3]=A[1],E[g+4]=A[2],E[g+5]=A[3],E[g+6]=C[0],E[g+7]=C[1],E[g+8]=C[3],E[g+9]=C[1],E[g+10]=C[2],E[g+11]=C[3],M.faceidx+=12,M.vertices+=8}}(t,e,i,r,n):"rectangle"!==o&&"oval"!==o&&"parabola"!==o||function(t,e,i,r,n,a,o){var l,h,c,d,u,f,p,g,m,v;if((c=e.length)<2||e[0].length<2)return;for(l=0;l0&&(l-=1,a=!0),M=Math.round(l*(i.length-1)/d),S=s.CC.color(i[M]),m=p,v=g,p=[],g=[],u=[],void 0!==e[0][l].atom&&(C=e[0][l].atom,"oval"===o?f=_:"rectangle"===o?f=y:"parabola"===o&&(f=b)),f||(f=y),h=0;h0&&!a){for(h=0;h<2*c;h++)L=[x+F[h][0],x+F[h][1],x+F[h][2],x+F[h][3]],E[A=I.faceidx]=L[0],E[A+1]=L[1],E[A+2]=L[3],E[A+3]=L[1],E[A+4]=L[2],E[A+5]=L[3],I.faceidx+=6;if(C.clickable||C.hoverable){var k=[];for(h in k.push(new J.Triangle(m[0],p[0],p[c-1])),k.push(new J.Triangle(m[0],p[c-1],m[c-1])),k.push(new J.Triangle(m[c-1],p[c-1],g[c-1])),k.push(new J.Triangle(m[c-1],g[c-1],v[c-1])),k.push(new J.Triangle(g[0],v[0],v[c-1])),k.push(new J.Triangle(g[c-1],g[0],v[c-1])),k.push(new J.Triangle(p[0],m[0],v[0])),k.push(new J.Triangle(g[0],p[0],v[0])),k)C.intersectionShape.triangle.push(k[h])}}I.vertices+=2*c}for(z=I.vertexArray,T=I.colorArray,E=I.faceArray,w=3*(x=I.vertices),A=I.faceidx,l=0;l=0&&i<1&&(a.transparent=!0,a.opacity=i),a.outline=r;var o=new n.Mesh(e,a);t.add(o)}}function mt(t,e,i,r,s,n,a,o,l){var h,c,d,u,f,p;if(r&&s&&a){var g=s.sub(r);g.normalize();var m=o[l];for(c=l+1;c0&&ut(T,F,E,l,g,0,F.style);var i=[],r=null;if(e){for(m=0;m0&&ut(T,F,E,l,g,0,F.style),F=[],m=0;m0&&e.truncateArrayBuffers(!0,!0)}static updateColor(t,e){var i,r,n;e=e||s.CC.color(e),t.colorsNeedUpdate=!0,e.constructor!==Array&&(i=e.r,r=e.g,n=e.b);for(let s in t.geometryGroups){let a=t.geometryGroups[s],o=a.colorArray;for(let t=0,s=a.vertices;t0?l/t:(t+l)/t}c.multiplyScalar(o);var d=new $.Vector3(r.x,r.y,r.z).add(c),u=c.clone().negate();let f=new $.Vector3(r.x,r.y,r.z);t.intersectionShape.cylinder.push(new J.Cylinder(f,d.clone(),n)),t.intersectionShape.sphere.push(new J.Sphere(f,n));var p=[];p[0]=c.clone(),Math.abs(p[0].x)>1e-4?p[0].y+=1:p[0].x+=1,p[0].cross(c),p[0].normalize(),p[4]=p[0].clone(),p[4].crossVectors(p[0],c),p[4].normalize(),p[8]=p[0].clone().negate(),p[12]=p[4].clone().negate(),p[2]=p[0].clone().add(p[4]).normalize(),p[6]=p[4].clone().add(p[8]).normalize(),p[10]=p[8].clone().add(p[12]).normalize(),p[14]=p[12].clone().add(p[0]).normalize(),p[1]=p[0].clone().add(p[2]).normalize(),p[3]=p[2].clone().add(p[4]).normalize(),p[5]=p[4].clone().add(p[6]).normalize(),p[7]=p[6].clone().add(p[8]).normalize(),p[9]=p[8].clone().add(p[10]).normalize(),p[11]=p[10].clone().add(p[12]).normalize(),p[13]=p[12].clone().add(p[14]).normalize(),p[15]=p[14].clone().add(p[0]).normalize();var g,m,v,_,y,b,x,w,A,C,S,M,z,T,E,L,F,I,O,D,k,R,P=h.vertices,U=h.vertexArray,B=h.faceArray,N=h.normalArray,G=h.lineArray;for(m=0,v=p.length;m0){var W=U[g-3],q=U[g-2],Y=U[g-1],Z=new $.Vector3(W,q,Y),X=new $.Vector3(s.x,s.y,s.z),K=d.clone(),Q=new $.Vector3(H.x,H.y,H.z);t.intersectionShape.triangle.push(new J.Triangle(Q,X,Z)),t.intersectionShape.triangle.push(new J.Triangle(Z.clone(),K,Q.clone()))}}h.vertices+=48,U[g=3*h.vertices]=r.x,U[g+1]=r.y,U[g+2]=r.z,U[g+3]=d.x,U[g+4]=d.y,U[g+5]=d.z,U[g+6]=s.x,U[g+7]=s.y,U[g+8]=s.z,h.vertices+=3;var tt=h.vertices-3,et=h.vertices-2,it=h.vertices-1,rt=3*tt,st=3*et,nt=3*it;for(m=0,v=p.length-1;mo&&(o=c),d>l&&(l=d),u>h&&(h=u)}t.center.set((o+s)/2,(l+n)/2,(h+a)/2),t.radius=t.center.distanceTo({x:o,y:l,z:h}),t.box={min:{x:s,y:n,z:a},max:{x:o,y:l,z:h}}}static addCustomGeo(t,e,i,r,s){var n,a,o,l,h,c,d,u,f,p=e.addGeoGroup(),g=i.vertexArr,m=i.normalArr,v=i.faceArr;p.vertices=g.length,p.faceidx=v.length;var _=p.vertexArray,y=p.colorArray;for(r.constructor!==Array&&(u=r.r,f=r.g,l=r.b),c=0,d=p.vertices;ch?(c.fromCap=0,c.toCap=2):(c.fromCap=2,c.toCap=2),this.addCylinder(c)}}addLine(t){var e,i;e=t.start?new $.Vector3(t.start.x||0,t.start.y||0,t.start.z||0):new $.Vector3(0,0,0),t.end?void 0===(i=new $.Vector3(t.end.x,t.end.y||0,t.end.z||0)).x&&(i.x=3):i=new $.Vector3(3,0,0);var r=this.geo.updateGeoGroup(2),s=r.vertices,n=3*s,a=r.vertexArray;a[n]=e.x,a[n+1]=e.y,a[n+2]=e.z,a[n+3]=i.x,a[n+4]=i.y,a[n+5]=i.z,r.vertices+=2;var o=r.lineArray,l=r.lineidx;o[l]=s,o[l+1]=s+1,r.lineidx+=2;var h=new $.Vector3;this.components.push({centroid:h.addVectors(e,i).multiplyScalar(.5)}),r=this.geo.updateGeoGroup(0),GLShape.updateBoundingFromPoints(this.boundingSphere,this.components,r.vertexArray,r.vertices)}addArrow(t){if(t.start?t.start=new $.Vector3(t.start.x||0,t.start.y||0,t.start.z||0):t.start=new $.Vector3(0,0,0),t.dir instanceof $.Vector3&&"number"==typeof t.length){var e=t.dir.clone().multiplyScalar(t.length).add(t.start);t.end=e}else t.end?(t.end=new $.Vector3(t.end.x,t.end.y||0,t.end.z||0),void 0===t.end.x&&(t.end.x=3)):t.end=new $.Vector3(3,0,0);t.radius=t.radius||.1,t.radiusRatio=t.radiusRatio||1.618034,t.mid=0=0?f[s]-a:a-f[s])>0&&(p[s]|=GLShape.ISDONE)}var g=[],m=[];MarchingCube.march(p,g,m,{fulltable:!0,voxel:o,unitCube:t.unit,origin:t.origin,matrix:t.matrix,nX:h,nY:c,nZ:d}),!o&&l>0&&MarchingCube.laplacianSmooth(l,g,m);var v=[],_=[],y=[];if(e.selectedRegion&&void 0===e.coords&&(e.coords=e.selectedRegion),void 0===e.coords&&void 0!==e.selection&&(r?e.coords=r.selectedAtoms(e.selection):console.log("addIsosurface needs viewer is selection provided.")),void 0!==e.coords){var b=e.coords[0].x,x=e.coords[0].y,w=e.coords[0].z,A=e.coords[0].x,C=e.coords[0].y,S=e.coords[0].z;for(let t=0;tb?b=e.coords[t].x:e.coords[t].xx?x=e.coords[t].y:e.coords[t].yw?w=e.coords[t].z:e.coords[t].zA&&g[t].xC&&g[t].yS&&g[t].z0){var r=new n.LineBasicMaterial({linewidth:this.linewidth,color:this.color}),s=new n.Line(this.linegeo,r,n.LineStyle.LinePieces);this.shapeObj.add(s)}this.renderedShapeObj=this.shapeObj.clone(),t.add(this.renderedShapeObj)}}removegl(t){this.renderedShapeObj&&(void 0!==this.renderedShapeObj.geometry&&this.renderedShapeObj.geometry.dispose(),void 0!==this.renderedShapeObj.material&&this.renderedShapeObj.material.dispose(),t.remove(this.renderedShapeObj),this.renderedShapeObj=null),this.shapeObj=null}get position(){return this.boundingSphere.center}get x(){return this.boundingSphere.center.x}get y(){return this.boundingSphere.center.y}get z(){return this.boundingSphere.center.z}}function wt(t){if(t.vertexArr.length<64e3)return[t];var e=[{vertexArr:[],normalArr:[],faceArr:[]}];t.colorArr&&(e.colorArr=[]);var i=[],r=[],s=0,n=t.faceArr;for(let o=0,l=n.length;o=64e3&&(e.push({vertexArr:[],normalArr:[],faceArr:[]}),t.colorArr&&(e.colorArr=[]),s++)}return e}GLShape.ISDONE=2,GLShape.drawCustom=function(t,e,i){var r=i,n=r.vertexArr,a=r.faceArr;0!==n.length&&0!==a.length||console.warn("Error adding custom shape component: No vertices and/or face indices supplied!");var o=i.color;void 0===o&&(o=t.color),o=s.CC.color(o);for(var l=wt(r),h=0,c=l.length;h=0||t.getIndex(c,d,u)>=0)for(let e=o;e=0&&!i[o]){(e-a.x)*(e-a.x)+(r-a.y)*(r-a.y)+(n-a.z)*(n-a.z){const t=new Uint8Array(4);return!((new Uint32Array(t.buffer)[0]=1)&t[0])})(),Mt={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class IOBuffer{constructor(t=8192,e={}){let i=!1;"number"==typeof t?t=new ArrayBuffer(t):(i=!0,this.lastWrittenByte=t.byteLength);const r=e.offset?e.offset>>>0:0,s=t.byteLength-r;let n=r;(ArrayBuffer.isView(t)||t instanceof IOBuffer)&&(t.byteLength!==t.buffer.byteLength&&(n=t.byteOffset+r),t=t.buffer),this.lastWrittenByte=i?s:0,this.buffer=t,this.length=s,this.byteLength=s,this.byteOffset=n,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,n,s),this._mark=0,this._marks=[]}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t=1){return this.offset+=t,this}back(t=1){return this.offset-=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t=1){if(!this.available(t)){const e=2*(this.offset+t),i=new Uint8Array(e);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=this.byteLength=e,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t=1){return this.readArray(t,"uint8")}readArray(t,e){const i=Mt[e].BYTES_PER_ELEMENT*t,r=this.byteOffset+this.offset,s=this.buffer.slice(r,r+i);if(this.littleEndian===St&&"uint8"!==e&&"int8"!==e){const t=new Uint8Array(this.buffer.slice(r,r+i));t.reverse();const s=new Mt[e](t.buffer);return this.offset+=i,s.reverse(),s}const n=new Mt[e](s);return this.offset+=i,n}readInt16(){const t=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}readUint16(){const t=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,t}readInt32(){const t=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}readUint32(){const t=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat32(){const t=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat64(){const t=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}readBigInt64(){const t=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,t}readBigUint64(){const t=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,t}readChar(){return String.fromCharCode(this.readInt8())}readChars(t=1){let e="";for(let i=0;ithis.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}const zt=1,Tt=2,Et=3,Lt=4,Ft=5,It=6;function Ot(t){switch(Number(t)){case zt:return"byte";case Tt:return"char";case Et:return"short";case Lt:return"int";case Ft:return"float";case It:return"double";default:return"undefined"}}function Dt(t){switch(Number(t)){case zt:case Tt:return 1;case Et:return 2;case Lt:case Ft:return 4;case It:return 8;default:return-1}}function kt(t){switch(String(t)){case"byte":return zt;case"char":return Tt;case"short":return Et;case"int":return Lt;case"float":return Ft;case"double":return It;default:return-1}}function Rt(t,e){if(1!==t){const i=new Array(t);for(let r=0;r6,`non valid type ${c}`);const d=t.readUint32();let u=t.readUint32();2===i&&(Ut(u>0,"offsets larger than 4GB not supported"),u=t.readUint32());let f=!1;void 0!==e&&l[0]===e&&(n+=d,f=!0),s[r]={name:a,dimensions:l,attributes:h,type:Ot(c),size:d,offset:u,record:f}}}return{variables:s,recordStep:n}}(t,r?.id,e);return Array.isArray(n)||(i.variables=n.variables,r.recordStep=n.recordStep),i.recordDimension=r,i}function Vt(t){const e=t.readUint32();let i;if(0===e)return Ut(0!==t.readUint32(),"wrong empty tag for list of attributes"),[];{Ut(12!==e,"wrong tag for list of attributes");const r=t.readUint32();i=new Array(r);for(let e=0;e6,`non valid type ${s}`);const n=t.readUint32(),a=Pt(t,s,n);Bt(t),i[e]={name:r,type:Ot(s),value:a}}}return i}function jt(){const t=[];t.push("DIMENSIONS");for(const e of this.dimensions)t.push(` ${e.name.padEnd(30)} = size: ${e.size}`);t.push(""),t.push("GLOBAL ATTRIBUTES");for(const e of this.globalAttributes)t.push(` ${e.name.padEnd(30)} = ${e.value}`);const e=JSON.parse(JSON.stringify(this.variables));t.push(""),t.push("VARIABLES:");for(const i of e){i.value=this.getDataVariable(i);let e=JSON.stringify(i.value);e.length>50&&(e=e.substring(0,50)),isNaN(i.value.length)||(e+=` (length: ${i.value.length})`),t.push(` ${i.name.padEnd(30)} = ${e}`)}return t.join("\n")}class NetCDFReader{constructor(t){this.toString=jt;const e=new IOBuffer(t);e.setBigEndian(),Ut("CDF"!==e.readChars(3),"should start with CDF");const i=e.readByte();Ut(i>2,"unknown version"),this.header=Gt(e,i),this.buffer=e}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}getAttribute(t){const e=this.globalAttributes.find((e=>e.name===t));return e?e.value:null}getDataVariableAsString(t){const e=this.getDataVariable(t);return e?e.join(""):null}get variables(){return this.header.variables}getDataVariable(t){let e;if(e="string"==typeof t?this.header.variables.find((e=>e.name===t)):t,void 0===e)throw new Error("Not a valid NetCDF v3.x file: variable not found");return this.buffer.seek(e.offset),e.record?function(t,e,i){const r=kt(e.type),s=e.size?e.size/Dt(r):1,n=i.length,a=new Array(n),o=i.recordStep;if(!o)throw new Error("recordDimension.recordStep is undefined");for(let e=0;ee.name===t))}attributeExists(t){return void 0!==this.globalAttributes.find((e=>e.name===t))}}class GLModel{static sameObj(t,e){return t&&e?JSON.stringify(t)==JSON.stringify(e):t==e}constructor(t,e){this.atoms=[],this.frames=[],this.box=null,this.atomdfs=null,this.id=0,this.hidden=!1,this.molObj=null,this.renderedMolObj=null,this.lastColors=null,this.modelData={},this.modelDatas=null,this.idMatrix=new $.Matrix4,this.dontDuplicateAtoms=!0,this.defaultColor=s.elementColors.defaultColor,this.defaultStickRadius=.25,this.options=e||{},this.ElementColors=this.options.defaultcolors?this.options.defaultcolors:s.elementColors.defaultColors,this.defaultSphereRadius=this.options.defaultSphereRadius?this.options.defaultSphereRadius:1.5,this.defaultCartoonQuality=this.options.cartoonQuality?this.options.cartoonQuality:10,this.id=t}getRadiusFromStyle(t,e){var i=this.defaultSphereRadius;if(void 0!==e.radius)i=e.radius;else if(GLModel.vdwRadii[t.elem])i=GLModel.vdwRadii[t.elem];else if(t.elem.length>1){let e=t.elem;e=e[0].toUpperCase()+e[1].toLowerCase(),GLModel.vdwRadii[e]&&(i=GLModel.vdwRadii[e])}return void 0!==e.scale&&(i*=e.scale),i}drawAtomCross(t,e){if(t.style.cross){var i=t.style.cross;if(!i.hidden){var r=i.linewidth||GLModel.defaultlineWidth;e[r]||(e[r]=new n.Geometry);var s=e[r].updateGeoGroup(6),a=this.getRadiusFromStyle(t,i),o=[[a,0,0],[-a,0,0],[0,a,0],[0,-a,0],[0,0,a],[0,0,-a]],l=t.clickable||t.hoverable;l&&void 0===t.intersectionShape&&(t.intersectionShape={sphere:[],cylinder:[],line:[]});for(var h=(0,L.getColorFromStyle)(t,i),c=s.vertexArray,d=s.colorArray,u=0;u<6;u++){var f=3*s.vertices;if(s.vertices++,c[f]=t.x+o[u][0],c[f+1]=t.y+o[u][1],c[f+2]=t.z+o[u][2],d[f]=h.r,d[f+1]=h.g,d[f+2]=h.b,l){var p=new $.Vector3(o[u][0],o[u][1],o[u][2]);p.multiplyScalar(.1),p.set(p.x+t.x,p.y+t.y,p.z+t.z),t.intersectionShape.line.push(p)}}}}}getGoodCross(t,e,i,r){for(var s=null,n=-1,a=0,o=t.bonds.length;an&&(s=c,(n=l)>.1))return s}return s}getSideBondV(t,e,i){var r,s,n,a,o=new $.Vector3(t.x,t.y,t.z),l=new $.Vector3(e.x,e.y,e.z).clone(),h=null;if(l.sub(o),1===t.bonds.length)1===e.bonds.length?(h=l.clone(),Math.abs(h.x)>1e-4?h.y+=1:h.x+=1):(r=(i+1)%e.bonds.length,s=e.bonds[r],(n=this.atoms[s]).index==t.index&&(r=(r+1)%e.bonds.length,s=e.bonds[r],n=this.atoms[s]),(a=new $.Vector3(n.x,n.y,n.z).clone()).sub(o),(h=a.clone()).cross(l));else if((h=this.getGoodCross(t,e,o,l)).lengthSq()<.01){var c=this.getGoodCross(e,t,o,l);null!=c&&(h=c)}return h.lengthSq()<.01&&(h=l.clone(),Math.abs(h.x)>1e-4?h.y+=1:h.x+=1),h.cross(l),h.normalize(),h}addLine(t,e,i,r,s,n){t[i]=r.x,t[i+1]=r.y,t[i+2]=r.z,e[i]=n.r,e[i+1]=n.g,e[i+2]=n.b,t[i+3]=s.x,t[i+4]=s.y,t[i+5]=s.z,e[i+3]=n.r,e[i+4]=n.g,e[i+5]=n.b}drawBondLines(t,e,i){if(t.style.line){var r=t.style.line;if(!r.hidden){var a,o,l,h,c=r.linewidth||GLModel.defaultlineWidth;i[c]||(i[c]=new n.Geometry);for(var d=i[c].updateGeoGroup(6*t.bonds.length),u=d.vertexArray,f=d.colorArray,p=0;p=g.index)){var m=new $.Vector3(t.x,t.y,t.z),v=new $.Vector3(g.x,g.y,g.z),_=m.clone().add(v).multiplyScalar(.5),y=!1,b=t.clickable||t.hoverable,x=g.clickable||g.hoverable;(b||x)&&(b&&(void 0===t.intersectionShape&&(t.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}),t.intersectionShape.line.push(m),t.intersectionShape.line.push(_)),x&&(void 0===g.intersectionShape&&(g.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}),g.intersectionShape.line.push(_),g.intersectionShape.line.push(v)));var w=(0,L.getColorFromStyle)(t,t.style.line),A=(0,L.getColorFromStyle)(g,g.style.line);if(t.bondStyles&&t.bondStyles[p]){var C=t.bondStyles[p];if(!C.iswire)continue;C.singleBond&&(y=!0),void 0!==C.color1&&(w=s.CC.color(C.color1)),void 0!==C.color2&&(A=s.CC.color(C.color2))}var S,M,z=3*d.vertices;if(t.bondOrder[p]>1&&t.bondOrder[p]<4&&!y){var T=this.getSideBondV(t,g,p),E=v.clone();E.sub(m),2==t.bondOrder[p]?(T.multiplyScalar(.1),(a=m.clone()).add(T),(o=m.clone()).sub(T),(l=a.clone()).add(E),(h=o.clone()).add(E),w==A?(d.vertices+=4,this.addLine(u,f,z,a,l,w),this.addLine(u,f,z+6,o,h,w)):(d.vertices+=8,E.multiplyScalar(.5),(S=a.clone()).add(E),(M=o.clone()).add(E),this.addLine(u,f,z,a,S,w),this.addLine(u,f,z+6,S,l,A),this.addLine(u,f,z+12,o,M,w),this.addLine(u,f,z+18,M,h,A))):3==t.bondOrder[p]&&(T.multiplyScalar(.1),(a=m.clone()).add(T),(o=m.clone()).sub(T),(l=a.clone()).add(E),(h=o.clone()).add(E),w==A?(d.vertices+=6,this.addLine(u,f,z,m,v,w),this.addLine(u,f,z+6,a,l,w),this.addLine(u,f,z+12,o,h,w)):(d.vertices+=12,E.multiplyScalar(.5),(S=a.clone()).add(E),(M=o.clone()).add(E),this.addLine(u,f,z,m,_,w),this.addLine(u,f,z+6,_,v,A),this.addLine(u,f,z+12,a,S,w),this.addLine(u,f,z+18,S,l,A),this.addLine(u,f,z+24,o,M,w),this.addLine(u,f,z+30,M,h,A)))}else w==A?(d.vertices+=2,this.addLine(u,f,z,m,v,w)):(d.vertices+=4,this.addLine(u,f,z,m,_,w),this.addLine(u,f,z+6,_,v,A))}}}}}drawAtomSphere(t,e){if(t.style.sphere){var i=t.style.sphere;if(!i.hidden){var r=(0,L.getColorFromStyle)(t,i),s=this.getRadiusFromStyle(t,i);if((!0===t.clickable||t.hoverable)&&void 0!==t.intersectionShape){var n=new $.Vector3(t.x,t.y,t.z);t.intersectionShape.sphere.push(new J.Sphere(n,s))}rt.drawSphere(e,t,s,r)}}}drawAtomClickSphere(t){if(t.style.clicksphere){var e=t.style.clicksphere;if(!e.hidden){var i=this.getRadiusFromStyle(t,e);if((!0===t.clickable||t.hoverable)&&void 0!==t.intersectionShape){var r=new $.Vector3(t.x,t.y,t.z);t.intersectionShape.sphere.push(new J.Sphere(r,i))}}}}drawAtomInstanced(t,e){if(t.style.sphere){var i=t.style.sphere;if(!i.hidden){var r=this.getRadiusFromStyle(t,i),s=(0,L.getColorFromStyle)(t,i),n=e.updateGeoGroup(1),a=n.vertices,o=3*a,l=n.vertexArray,h=n.colorArray,c=n.radiusArray;if(l[o]=t.x,l[o+1]=t.y,l[o+2]=t.z,h[o]=s.r,h[o+1]=s.g,h[o+2]=s.b,c[a]=r,(!0===t.clickable||t.hoverable)&&void 0!==t.intersectionShape){var d=new $.Vector3(t.x,t.y,t.z);t.intersectionShape.sphere.push(new J.Sphere(d,r))}n.vertices+=1}}}drawSphereImposter(t,e,i,r){var s,n=t.updateGeoGroup(4),a=n.vertices,o=3*a,l=n.vertexArray,h=n.colorArray;for(s=0;s<4;s++)l[o+3*s]=e.x,l[o+3*s+1]=e.y,l[o+3*s+2]=e.z;var c=n.normalArray;for(s=0;s<4;s++)h[o+3*s]=r.r,h[o+3*s+1]=r.g,h[o+3*s+2]=r.b;c[o+0]=-i,c[o+1]=i,c[o+2]=0,c[o+3]=-i,c[o+4]=-i,c[o+5]=0,c[o+6]=i,c[o+7]=-i,c[o+8]=0,c[o+9]=i,c[o+10]=i,c[o+11]=0,n.vertices+=4;var d=n.faceArray,u=n.faceidx;d[u+0]=a,d[u+1]=a+1,d[u+2]=a+2,d[u+3]=a+2,d[u+4]=a+3,d[u+5]=a,n.faceidx+=6}drawAtomImposter(t,e){if(t.style.sphere){var i=t.style.sphere;if(!i.hidden){var r=this.getRadiusFromStyle(t,i),s=(0,L.getColorFromStyle)(t,i);if((!0===t.clickable||t.hoverable)&&void 0!==t.intersectionShape){var n=new $.Vector3(t.x,t.y,t.z);t.intersectionShape.sphere.push(new J.Sphere(n,r))}this.drawSphereImposter(e,t,r,s)}}}calculateDashes(t,e,i,r,s){var n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)+Math.pow(t.z-e.z,2));i=Math.max(i,0),s=Math.max(s,0)+2*i,(r=Math.max(r,.001))+s>n&&(r=n,s=0);var a,o=Math.floor((n-r)/(r+s))+1;s=(n-o*r)/o;for(var l=new $.Vector3(t.x,t.y,t.z),h=new $.Vector3((e.x-t.x)/(n/s),(e.y-t.y)/(n/s),(e.z-t.z)/(n/s)),c=new $.Vector3((e.x-t.x)/(n/r),(e.y-t.y)/(n/r),(e.z-t.z)/(n/r)),d=[],u=0;u{var e=i.imposter?GLModel.drawStickImposter:rt.drawCylinder;return!T&&t>=1?e:(t,i,r,s,n,a=0,o=0,l=.1,h=.25)=>{this.calculateDashes(i,r,s,l,h).forEach((i=>{e(t,i.from,i.to,s,n,a,o)}))}};for(h=0;h3){if(t.bondOrder[h]<1&&(M*=t.bondOrder[h]),!k.capDrawn&&k.bonds.length<4&&(F=2),I!=P?(_=(new $.Vector3).addVectors(U,B).multiplyScalar(.5),D(i,U,_,M,I,E,0,C,S),D(i,_,B,M,P,0,F,C,S)):D(i,U,B,M,I,E,F,C,S),o=t.clickable||t.hoverable,l=k.clickable||k.hoverable,o||l){if(_||(_=(new $.Vector3).addVectors(U,B).multiplyScalar(.5)),o){var N=new J.Cylinder(U,_,M),G=new J.Sphere(U,M);t.intersectionShape.cylinder.push(N),t.intersectionShape.sphere.push(G)}if(l){var V=new J.Cylinder(B,_,M),j=new J.Sphere(B,M);k.intersectionShape.cylinder.push(V),k.intersectionShape.sphere.push(j)}}}else if(t.bondOrder[h]>1){var H=0,W=0;M!=x&&(H=2,W=2);var q,Y,Z,X,K,Q=B.clone(),tt=null;Q.sub(U),tt=this.getSideBondV(t,k,h),2==t.bondOrder[h]?(q=M*w,tt.multiplyScalar(1.5*q),(Y=U.clone()).add(tt),(Z=U.clone()).sub(tt),(X=Y.clone()).add(Q),(K=Z.clone()).add(Q),I!=P?(_=(new $.Vector3).addVectors(Y,X).multiplyScalar(.5),y=(new $.Vector3).addVectors(Z,K).multiplyScalar(.5),D(i,Y,_,q,I,H,0),D(i,_,X,q,P,0,W),D(i,Z,y,q,I,H,0),D(i,y,K,q,P,0,W)):(D(i,Y,X,q,I,H,W),D(i,Z,K,q,I,H,W)),o=t.clickable||t.hoverable,l=k.clickable||k.hoverable,(o||l)&&(_||(_=(new $.Vector3).addVectors(Y,X).multiplyScalar(.5)),y||(y=(new $.Vector3).addVectors(Z,K).multiplyScalar(.5)),o&&(u=new J.Cylinder(Y,_,q),f=new J.Cylinder(Z,y,q),t.intersectionShape.cylinder.push(u),t.intersectionShape.cylinder.push(f)),l&&(g=new J.Cylinder(X,_,q),m=new J.Cylinder(K,y,q),k.intersectionShape.cylinder.push(g),k.intersectionShape.cylinder.push(m)))):3==t.bondOrder[h]&&(q=M*A,tt.cross(Q),tt.normalize(),tt.multiplyScalar(3*q),(Y=U.clone()).add(tt),(Z=U.clone()).sub(tt),(X=Y.clone()).add(Q),(K=Z.clone()).add(Q),I!=P?(_=(new $.Vector3).addVectors(Y,X).multiplyScalar(.5),y=(new $.Vector3).addVectors(Z,K).multiplyScalar(.5),b=(new $.Vector3).addVectors(U,B).multiplyScalar(.5),D(i,Y,_,q,I,H,0),D(i,_,X,q,P,0,W),D(i,U,b,q,I,E,0),D(i,b,B,q,P,0,F),D(i,Z,y,q,I,H,0),D(i,y,K,q,P,0,W)):(D(i,Y,X,q,I,H,W),D(i,U,B,q,I,E,F),D(i,Z,K,q,I,H,W)),o=t.clickable||t.hoverable,l=k.clickable||k.hoverable,(o||l)&&(_||(_=(new $.Vector3).addVectors(Y,X).multiplyScalar(.5)),y||(y=(new $.Vector3).addVectors(Z,K).multiplyScalar(.5)),b||(b=(new $.Vector3).addVectors(U,B).multiplyScalar(.5)),o&&(u=new J.Cylinder(Y.clone(),_.clone(),q),f=new J.Cylinder(Z.clone(),y.clone(),q),p=new J.Cylinder(U.clone(),b.clone(),q),t.intersectionShape.cylinder.push(u),t.intersectionShape.cylinder.push(f),t.intersectionShape.cylinder.push(p)),l&&(g=new J.Cylinder(X.clone(),_.clone(),q),m=new J.Cylinder(K.clone(),y.clone(),q),v=new J.Cylinder(B.clone(),b.clone(),q),k.intersectionShape.cylinder.push(g),k.intersectionShape.cylinder.push(m),k.intersectionShape.cylinder.push(v))))}}}var et=!1,it=0,st=!1;for(h=0;h0&&(et=!0):0==it&&(t.bonds.length>0||a.showNonBonded)&&(et=!0),et&&(M=x,i.imposter?this.drawSphereImposter(i.sphereGeometry,t,M,I):rt.drawSphere(i,t,M,I))}}}createMolObj(t,e){e=e||{};var i,r,a,o,l=new n.Object3D,h=[],c={},d={},u=this.drawAtomSphere,f=null,p=null;e.supportsImposters?(u=this.drawAtomImposter,(f=new n.Geometry(!0)).imposter=!0,(p=new n.Geometry(!0,!0)).imposter=!0,p.sphereGeometry=new n.Geometry(!0),p.sphereGeometry.imposter=!0,p.drawnCaps={}):e.supportsAIA?(u=this.drawAtomInstanced,(f=new n.Geometry(!1,!0,!0)).instanced=!0,p=new n.Geometry(!0)):(f=new n.Geometry(!0),p=new n.Geometry(!0));var g,m={},v=[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY];for(i=0,a=t.length;iv[1]&&(v[1]=_.resi)),h.push(_))}}if(h.length>0&&xt(l,h,v,this.defaultCartoonQuality),f&&f.vertices>0){f.initTypedArrays();var y=null,b=null;f.imposter?y=new n.SphereImposterMaterial({ambient:0,vertexColors:!0,reflectivity:0}):f.instanced?(b=new n.Geometry(!0),rt.drawSphere(b,{x:0,y:0,z:0},1,new s.Color(.5,.5,.5)),b.initTypedArrays(),y=new n.InstancedMaterial({sphereMaterial:new n.MeshLambertMaterial({ambient:0,vertexColors:!0,reflectivity:0}),sphere:b})):y=new n.MeshLambertMaterial({ambient:0,vertexColors:!0,reflectivity:0}),m.sphere<1&&m.sphere>=0&&(y.transparent=!0,y.opacity=m.sphere),b=new n.Mesh(f,y),l.add(b)}if(p.vertices>0){var x=null,w=null,A=p.sphereGeometry;A&&void 0!==A.vertices&&0!=A.vertices||(A=null),p.initTypedArrays(),A&&A.initTypedArrays();var C={ambient:0,vertexColors:!0,reflectivity:0};p.imposter?(x=new n.StickImposterMaterial(C),w=new n.SphereImposterMaterial(C)):(x=new n.MeshLambertMaterial(C),w=new n.MeshLambertMaterial(C),x.wireframe&&(p.setUpWireframe(),A&&A.setUpWireframe())),m.stick<1&&m.stick>=0&&(x.transparent=!0,x.opacity=m.stick,w.transparent=!0,w.opacity=m.stick);var S=new n.Mesh(p,x);if(l.add(S),A){var M=new n.Mesh(A,w);l.add(M)}}for(i in c)if(c.hasOwnProperty(i)){g=i;var z=new n.LineBasicMaterial({linewidth:g,vertexColors:!0});m.line<1&&m.line>=0&&(z.transparent=!0,z.opacity=m.line),c[i].initTypedArrays();var T=new n.Line(c[i],z,n.LineStyle.LinePieces);l.add(T)}for(i in d)if(d.hasOwnProperty(i)){g=i;var E=new n.LineBasicMaterial({linewidth:g,vertexColors:!0});m.cross<1&&m.cross>=0&&(E.transparent=!0,E.opacity=m.cross),d[i].initTypedArrays();var L=new n.Line(d[i],E,n.LineStyle.LinePieces);l.add(L)}if(this.dontDuplicateAtoms&&this.modelData.symmetries&&this.modelData.symmetries.length>0){var F,I=new n.Object3D;for(F=0;Fi?e-r:e}adjustCoordinatesToBox(){if(this.box&&this.atomdfs)for(var t=this.box[0],e=this.box[1],i=this.box[2],r=.9*t,s=.9*e,n=.9*i,a=0;a=i)&&(t=i-1),null!=r.frames.url){var a=r.frames.url;(0,L.getbin)(a+"/traj/frame/"+t+"/"+r.frames.path,void 0,"POST",void 0).then((function(t){for(var e=new Float32Array(t,44),i=0,n=0;n=r&&t<=s)return!0}}return!1}static deepCopyAndCache(t,e){if("object"!=typeof t||null==t)return t;if(t.__cache_created)return t;const i={};for(const r in t){const s=t[r];if(Array.isArray(s)){i[r]=[];for(let t=0;t=r[0][0]&&a<=r[1][0]&&o>=r[0][1]&&o<=r[1][1]&&l>=r[0][2]&&l<=r[1][2]&&(a>=i[0][0]&&a<=i[1][0]&&o>=i[0][1]&&o<=i[1][1]&&l>=i[0][2]&&l<=i[1][2]||n.push(this.atoms[t]))}return n}static getFloat(t){return"number"==typeof t?t:parseFloat(t)}selectedAtoms(t,e){var i=[];t=GLModel.deepCopyAndCache(t||{},this),e||(e=this.atoms);for(var r=e.length,s=0;s0&&i.push(r[t])}}if(t.hasOwnProperty("within")&&t.within.hasOwnProperty("sel")&&t.within.hasOwnProperty("distance")){var o=this.selectedAtoms(t.within.sel,this.atoms),l={};const e=GLModel.getFloat(t.within.distance),r=e*e;for(let t=0;t0&&(l[e]=1)}var h=[];if(t.within.invert)for(let t=0;t0;)if(e=u.pop(),f=e.chain,p=e.resi,void 0===d[e.index]){d[e.index]=!0;for(var g=0;g0&&(this.molObj=null)}else console.log("Callback is not a function")}setHoverable(t,e,i,r){if(e=!!e,i=(0,L.makeFunction)(i),r=(0,L.makeFunction)(r),null!==i)if(null!==r){var s=this.selectedAtoms(t,this.atoms),n=s.length;for(let t=0;t0&&(this.molObj=null)}else console.log("Unhover_callback is not a function");else console.log("Hover_callback is not a function")}enableContextMenu(t,e){var i;e=!!e;var r=this.selectedAtoms(t,this.atoms),s=r.length;for(i=0;i0&&(this.molObj=null)}setColorByElement(t,e){if(null===this.molObj||!GLModel.sameObj(e,this.lastColors)){this.lastColors=e;var i=this.selectedAtoms(t,i);i.length>0&&(this.molObj=null);for(var r=0;r0&&(this.molObj=null),"string"==typeof i&&void 0!==r.Gradient.builtinGradients[i]&&(i=new r.Gradient.builtinGradients[i]),s||(s=i.range()),s||(s=(0,L.getPropertyRange)(o,e)),n=0;n0&&(this.molObj=null);for(let t=0;t=s)continue;let a={b:i,e:s},o=n.bondOrder[t];1!=o&&(a.o=o),e.b.push(a)}}return e}globj(t,e){(null===this.molObj||e.regen)&&(this.molObj=this.createMolObj(this.atoms,e),this.renderedMolObj&&(t.remove(this.renderedMolObj),this.renderedMolObj=null),this.renderedMolObj=this.molObj.clone(),this.hidden&&(this.renderedMolObj.setVisible(!1),this.molObj.setVisible(!1)),t.add(this.renderedMolObj))}exportVRML(){return this.createMolObj(this.atoms,{supportsImposters:!1,supportsAIA:!1}).vrml()}removegl(t){this.renderedMolObj&&(void 0!==this.renderedMolObj.geometry&&this.renderedMolObj.geometry.dispose(),void 0!==this.renderedMolObj.material&&this.renderedMolObj.material.dispose(),t.remove(this.renderedMolObj),this.renderedMolObj=null),this.molObj=null}hide(){this.hidden=!0,this.renderedMolObj&&this.renderedMolObj.setVisible(!1),this.molObj&&this.molObj.setVisible(!1)}show(){this.hidden=!1,this.renderedMolObj&&this.renderedMolObj.setVisible(!0),this.molObj&&this.molObj.setVisible(!0)}addPropertyLabels(t,e,i,r){for(var s=this.selectedAtoms(e,s),n=(0,L.deepCopy)(r),a=0;aMOLECULE/gm)?"mol2":t.match(/^data_/gm)&&t.match(/^loop_/gm)?"cif":t.match(/^HETATM/gm)||t.match(/^ATOM/gm)?"pdb":t.match(/ITEM: TIMESTEP/gm)?"lammpstrj":t.match(/^.*\n.*\n.\s*(\d+)\s+(\d+)/gm)?"sdf":t.match(/^%VERSION\s+VERSION_STAMP/gm)?"prmtop":"xyz",console.log("Best guess: "+e))),(0,K[e])(t,i)}}GLModel.defaultAtomStyle={line:{}},GLModel.defaultlineWidth=1,GLModel.vdwRadii={H:1.2,He:1.4,Li:1.82,Be:1.53,B:1.92,C:1.7,N:1.55,O:1.52,F:1.47,Ne:1.54,Na:2.27,Mg:1.73,Al:1.84,Si:2.1,P:1.8,S:1.8,Cl:1.75,Ar:1.88,K:2.75,Ca:2.31,Ni:1.63,Cu:1.4,Zn:1.39,Ga:1.87,Ge:2.11,As:1.85,Se:1.9,Br:1.85,Kr:2.02,Rb:3.03,Sr:2.49,Pd:1.63,Ag:1.72,Cd:1.58,In:1.93,Sn:2.17,Sb:2.06,Te:2.06,I:1.98,Xe:2.16,Cs:3.43,Ba:2.68,Pt:1.75,Au:1.66,Hg:1.55,Tl:1.96,Pb:2.02,Bi:2.07,Po:1.97,At:2.02,Rn:2.2,Fr:3.48,Ra:2.83,U:1.86},GLModel.ignoredKeys=new Set(["props","invert","model","frame","byres","expand","within","and","or","not"]);var Ht=i(111);const Wt=16;class GLViewer{getWidth(){let t=this.container,e=t.offsetWidth;if(0==e&&"none"===t.style.display){let i=t.style.position,r=t.style.visibility;t.style.display="block",t.style.visibility="hidden",t.style.position="absolute",e=t.offsetWidth,t.style.display="none",t.style.visibility=r,t.style.position=i}return e}getHeight(){let t=this.container,e=t.offsetHeight;if(0==e&&"none"===t.style.display){let i=t.style.position,r=t.style.visibility;t.style.display="block",t.style.visibility="hidden",t.style.position="absolute",e=t.offsetHeight,t.style.display="none",t.style.visibility=r,t.style.position=i}return e}setupRenderer(){this.renderer=new n.Renderer({antialias:this.config.antialias,preserveDrawingBuffer:!0,premultipliedAlpha:!1,id:this.config.id,row:this.config.row,col:this.config.col,rows:this.config.rows,cols:this.config.cols,canvas:this.config.canvas,containerWidth:this.WIDTH,containerHeight:this.HEIGHT,ambientOcclusion:this.config.ambientOcclusion,outline:this.config.outline}),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.padding="0",this.renderer.domElement.style.position="absolute",this.renderer.domElement.style.top="0px",this.renderer.domElement.style.left="0px",this.renderer.domElement.style.zIndex="0"}initializeScene(){this.scene=new n.Scene,this.scene.fog=new n.Fog(this.bgColor,100,200),this.modelGroup=new n.Object3D,this.rotationGroup=new n.Object3D,this.rotationGroup.useQuaternion=!0,this.rotationGroup.quaternion=new $.Quaternion(0,0,0,1),this.rotationGroup.add(this.modelGroup),this.scene.add(this.rotationGroup);var t=new n.Light(16777215);t.position=new $.Vector3(.2,.2,1).normalize(),t.intensity=1,this.scene.add(t)}_handleLostContext(t){const e=function(t){const e=t.getBoundingClientRect();return!(e.right<0||e.bottom<0||e.top>(window.innerHeight||document.documentElement.clientHeight)||e.left>(window.innerWidth||document.documentElement.clientWidth))};if(e(this.container)){let t=0;for(let i of document.getElementsByTagName("canvas"))if(e(i)&&null!=i._3dmol_viewer&&(i._3dmol_viewer.resize(),t+=1,t>=Wt))break}}initContainer(t){this.container=t,this.WIDTH=this.getWidth(),this.HEIGHT=this.getHeight(),this.ASPECT=this.renderer.getAspect(this.WIDTH,this.HEIGHT),this.renderer.setSize(this.WIDTH,this.HEIGHT),this.container.append(this.renderer.domElement),this.glDOM=this.renderer.domElement,this.glDOM._3dmol_viewer=this,this.glDOM.addEventListener("webglcontextlost",this._handleLostContext.bind(this)),this.nomouse||(this.glDOM.addEventListener("mousedown",this._handleMouseDown.bind(this),{passive:!1}),this.glDOM.addEventListener("touchstart",this._handleMouseDown.bind(this),{passive:!1}),this.glDOM.addEventListener("wheel",this._handleMouseScroll.bind(this),{passive:!1}),this.glDOM.addEventListener("mousemove",this._handleMouseMove.bind(this),{passive:!1}),this.glDOM.addEventListener("touchmove",this._handleMouseMove.bind(this),{passive:!1}),this.glDOM.addEventListener("contextmenu",this._handleContextMenu.bind(this),{passive:!1}))}decAnim(){this.animated--,this.animated<0&&(this.animated=0)}incAnim(){this.animated++}nextSurfID(){var t=0;for(let i in this.surfaces)if(this.surfaces.hasOwnProperty(i)){var e=parseInt(i);isNaN(e)||e>t&&(t=e)}return t+1}setSlabAndFog(){let t=this.camera.position.z-this.rotationGroup.position.z;t<1&&(t=1),this.camera.near=t+this.slabNear,!this.camera.ortho&&this.camera.near<1&&(this.camera.near=1),this.camera.far=t+this.slabFar,this.camera.near+1>this.camera.far&&(this.camera.far=this.camera.near+1),this.camera.fov=this.fov,this.camera.right=t*Math.tan(Math.PI/180*this.fov),this.camera.left=-this.camera.right,this.camera.top=this.camera.right/this.ASPECT,this.camera.bottom=-this.camera.top,this.camera.updateProjectionMatrix(),this.scene.fog.near=this.camera.near+this.fogStart*(this.camera.far-this.camera.near),this.scene.fog.far=this.camera.far,this.config.disableFog&&(this.scene.fog.near=this.scene.fog.far)}show(t){if(this.renderer.setViewport(),this.scene&&(this.setSlabAndFog(),this.renderer.render(this.scene,this.camera),this.viewChangeCallback&&this.viewChangeCallback(this._viewer.getView()),!t&&this.linkedViewers.length>0))for(var e=this._viewer.getView(),i=0;i0){let e=this.CAMERA_Z-this.config.lowerZoomLimit;t>e&&(t=e)}if(this.config.upperZoomLimit&&this.config.upperZoomLimit>0){let e=this.CAMERA_Z-this.config.upperZoomLimit;tthis.CAMERA_Z-1&&(t=this.CAMERA_Z-1),t}static slerp(t,e,i){if(1==i)return e.clone();if(0==i)return t.clone();let r=t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w;if(r>.9995){let r=new $.Quaternion(t.x+i*(e.x-t.x),t.y+i*(e.y-t.y),t.z+i*(e.z-t.z),t.w+i*(e.w-t.w));return r.normalize(),r}r<0&&(e=e.clone().multiplyScalar(-1),r=-r),r>1?r=1:r<-1&&(r=-1);var s=Math.acos(r)*i,n=e.clone();n.sub(t.clone().multiplyScalar(r)),n.normalize();var a=Math.cos(s),o=Math.sin(s),l=new $.Quaternion(t.x*a+n.x*o,t.y*a+n.y*o,t.z*a+n.z*o,t.w*a+n.w*o);return l.normalize(),l}constructor(t,e={}){if(this.nomouse=!1,this.glDOM=null,this.models=[],this.surfaces={},this.shapes=[],this.labels=[],this.clickables=[],this.hoverables=[],this.contextMenuEnabledObjects=[],this.current_hover=null,this.hoverDuration=500,this.longTouchDuration=1e3,this.viewer_frame=0,this.viewChangeCallback=null,this.stateChangeCallback=null,this.NEAR=1,this.FAR=800,this.CAMERA_Z=150,this.fov=20,this.linkedViewers=[],this.renderer=null,this.control_all=!1,this.scene=null,this.rotationGroup=null,this.modelGroup=null,this.fogStart=.4,this.slabNear=-50,this.slabFar=50,this.cq=new $.Quaternion(0,0,0,1),this.dq=new $.Quaternion(0,0,0,1),this.animated=0,this.animationTimers=new Set,this.isDragging=!1,this.mouseStartX=0,this.mouseStartY=0,this.touchDistanceStart=0,this.touchHold=!1,this.currentModelPos=0,this.cz=0,this.cslabNear=0,this.cslabFar=0,this.userContextMenuHandler=null,this.config=e,this.callback=this.config.callback,this.defaultcolors=this.config.defaultcolors,this.defaultcolors||(this.defaultcolors=s.elementColors.defaultColors),this.nomouse=Boolean(this.config.nomouse),this.bgColor=0,this.config.backgroundColor=this.config.backgroundColor||"#ffffff",void 0!==this.config.backgroundColor&&(this.bgColor=s.CC.color(this.config.backgroundColor).getHex()),this.config.backgroundAlpha=null==this.config.backgroundAlpha?1:this.config.backgroundAlpha,this.camerax=0,void 0!==this.config.camerax&&(this.camerax="string"==typeof this.config.camerax?parseFloat(this.config.camerax):this.config.camerax),this._viewer=this,this.container=t,null!=this.config.hoverDuration&&(this.hoverDuration=this.config.hoverDuration),void 0===this.config.antialias&&(this.config.antialias=!0),void 0===this.config.cartoonQuality&&(this.config.cartoonQuality=10),this.WIDTH=this.getWidth(),this.HEIGHT=this.getHeight(),this.setupRenderer(),this.row=null==this.config.row?0:this.config.row,this.col=null==this.config.col?0:this.config.col,this.cols=this.config.cols,this.rows=this.config.rows,this.viewers=this.config.viewers,this.control_all=this.config.control_all,this.ASPECT=this.renderer.getAspect(this.WIDTH,this.HEIGHT),this.camera=new n.Camera(this.fov,this.ASPECT,this.NEAR,this.FAR,this.config.orthographic),this.camera.position=new $.Vector3(this.camerax,0,this.CAMERA_Z),this.lookingAt=new $.Vector3,this.camera.lookAt(this.lookingAt),this.raycaster=new n.Raycaster(new $.Vector3(0,0,0),new $.Vector3(0,0,0)),this.projector=new n.Projector,this.initializeScene(),this.renderer.setClearColorHex(this.bgColor,this.config.backgroundAlpha),this.scene.fog.color=s.CC.color(this.bgColor),document.body.addEventListener("mouseup",this._handleMouseUp.bind(this)),document.body.addEventListener("touchend",this._handleMouseUp.bind(this)),this.initContainer(this.container),this.config.style&&this.setViewStyle(this.config),window.addEventListener("resize",this.resize.bind(this)),void 0!==window.ResizeObserver&&(this.divwatcher=new window.ResizeObserver(this.resize.bind(this)),this.divwatcher.observe(this.container)),void 0!==window.IntersectionObserver){let t=(t,e)=>{t.forEach((t=>{t.isIntersecting&&this.resize()}))};this.intwatcher=new window.IntersectionObserver(t),this.intwatcher.observe(this.container)}try{"function"==typeof this.callback&&this.callback(this)}catch(t){console.log("error with glviewer callback: "+t)}}targetedObjects(t,e,i){var r={x:t,y:e,z:-1};return Array.isArray(i)||(i=this.selectedAtoms(i)),0==i.length?[]:(this.raycaster.setFromCamera(r,this.camera),this.raycaster.intersectObjects(this.modelGroup,i))}modelToScreen(t){let e=!1;Array.isArray(t)||(t=[t],e=!0);let i=this.renderer.getXRatio(),r=this.renderer.getYRatio(),s=this.col,n=this.row,a=s*(this.WIDTH/i),o=(r-n-1)*(this.HEIGHT/r),l=[],h=this.canvasOffset();return t.forEach((t=>{let e=new $.Vector3(t.x,t.y,t.z);e.applyMatrix4(this.modelGroup.matrixWorld),this.projector.projectVector(e,this.camera);let s=this.WIDTH/i*(e.x+1)/2+h.left+a,n=-this.HEIGHT/r*(e.y-1)/2+h.top+o;l.push({x:s,y:n})})),e&&(l=l[0]),l}screenOffsetToModel(t,e,i){var r=t/this.WIDTH,s=e/this.HEIGHT,n=void 0===i?this.rotationGroup.position.z:i,a=this.rotationGroup.quaternion,o=new $.Vector3(0,0,n);return this.projector.projectVector(o,this.camera),o.x+=2*r,o.y-=2*s,this.projector.unprojectVector(o,this.camera),o.z=0,o.applyQuaternion(a),o}screenToModelDistance(t,e){let i=this.canvasOffset(),r=new $.Vector3(e.x,e.y,e.z);r.applyMatrix4(this.modelGroup.matrixWorld);let s=r.clone();this.projector.projectVector(r,this.camera);let n=new $.Vector3(2*(t.x-i.left)/this.WIDTH-1,2*(t.y-i.top)/-this.HEIGHT+1,r.z);return this.projector.unprojectVector(n,this.camera),n.distanceTo(s)}setViewChangeCallback(t){"function"!=typeof t&&null!=t||(this.viewChangeCallback=t)}setStateChangeCallback(t){"function"!=typeof t&&null!=t||(this.stateChangeCallback=t)}getConfig(){return this.config}setConfig(t){this.config=t,t.ambientOcclusion&&this.renderer.enableAmbientOcclusion(t.ambientOcclusion)}getInternalState(){var t={models:[],surfaces:[],shapes:[],labels:[]};for(let e=0;e{e.getCanvas().toBlob((function(e){e.arrayBuffer().then(t)}),"image/png")}))),r+=1,r==t&&(e.viewChangeCallback=s,Promise.all(n).then((t=>{let r=[];for(let e=0;e0&&(this.hoverTimeout=setTimeout((function(){a.handleHoverSelection(n.x,n.y,t)}),this.hoverDuration)),this.isDragging)){t.targetTouches&&(t.targetTouches.length>1||1===t.targetTouches.length&&!this.closeEnoughForClick(t))&&clearTimeout(this.longTouchTimeout);var l=(e-this.mouseStartX)/this.WIDTH,h=(i-this.mouseStartY)/this.HEIGHT;if(0!=this.touchDistanceStart&&t.targetTouches&&2==t.targetTouches.length)o=2,h=2*(this.calcTouchDistance(t)-this.touchDistanceStart)/(this.WIDTH+this.HEIGHT);else t.targetTouches&&3==t.targetTouches.length&&(o=1);l*=r,h*=s;var c,d=Math.hypot(l,h);if(3==o||3==this.mouseButton&&t.ctrlKey)this.slabNear=this.cslabNear+100*l,this.slabFar=this.cslabFar-100*h;else if(2==o||3==this.mouseButton||t.shiftKey)(c=.85*(this.CAMERA_Z-this.rotationGroup.position.z))<80&&(c=80),this.rotationGroup.position.z=this.cz+h*c,this.rotationGroup.position.z=this.adjustZoomToLimits(this.rotationGroup.position.z);else if(1==o||2==this.mouseButton||t.ctrlKey){var u=this.screenOffsetToModel(r*(e-this.mouseStartX),s*(i-this.mouseStartY));this.modelGroup.position.addVectors(this.currentModelPos,u)}else if((0===o||1==this.mouseButton)&&0!==d){var f=Math.sin(d*Math.PI)/d;this.dq.x=Math.cos(d*Math.PI),this.dq.y=0,this.dq.z=f*l,this.dq.w=-f*h,this.rotationGroup.quaternion.set(1,0,0,0),this.rotationGroup.quaternion.multiply(this.dq),this.rotationGroup.quaternion.multiply(this.cq)}this.show()}}_handleContextMenu(t){if(t.preventDefault(),this.closeEnoughForClick(t)){var e=this.mouseStartX,i=this.mouseStartY,r=this.canvasOffset();let n=this.mouseXY(e,i),a=n.x,o=n.y,l=this.targetedObjects(a,o,this.contextMenuEnabledObjects);var s=null;l.length&&(s=l[0].clickable);r=this.canvasOffset(),e=this.mouseStartX-r.left,i=this.mouseStartY-r.top;this.userContextMenuHandler&&(this.userContextMenuHandler(s,e,i,l,t),this.isDragging=!1)}}setContainer(t){let e=(0,L.getElement)(t)||this.container;return this.initContainer(e),this}setBackgroundColor(t,e){(void 0===e||e<0||e>1)&&(e=1);var i=s.CC.color(t);return this.scene.fog.color=i,this.bgColor=i.getHex(),this.renderer.setClearColorHex(i.getHex(),e),this.show(),this}setProjection(t){this.camera.ortho="orthographic"===t,this.setSlabAndFog()}setViewStyle(t){if((t=t||{}).style=t.style||"",t.style.includes("outline")?this.renderer.enableOutline(t):this.renderer.disableOutline(),t.style.includes("ambientOcclusion")){var e={};t.strength&&(e.strength=t.strength),t.radius&&(e.radius=t.radius),this.renderer.enableAmbientOcclusion(e)}else this.renderer.disableAmbientOcclusion();return this}updateSize(){this.renderer.setSize(this.WIDTH,this.HEIGHT),this.ASPECT=this.renderer.getAspect(this.WIDTH,this.HEIGHT),this.renderer.setSize(this.WIDTH,this.HEIGHT),this.camera.aspect=this.ASPECT,this.camera.updateProjectionMatrix()}setWidth(t){return this.WIDTH=t||this.WIDTH,this.updateSize(),this}setHeight(t){return this.HEIGHT=t||this.HEIGHT,this.updateSize(),this}resize(){this.WIDTH=this.getWidth(),this.HEIGHT=this.getHeight();let t=!1;if(this.renderer.isLost()&&this.WIDTH>0&&this.HEIGHT>0){let e=!1,i=this.container.querySelector("canvas");i&&i!=this.renderer.getCanvas()?this.config.canvas=i:(i.remove(),this.config&&null!=this.config.canvas&&(delete this.config.canvas,e=!0)),this.setupRenderer(),this.initContainer(this.container),this.renderer.setClearColorHex(this.bgColor,this.config.backgroundAlpha),t=!0,e&&(this.config.canvas=this.renderer.getCanvas())}if(0==this.WIDTH||0==this.HEIGHT?this.animated&&this._viewer.pauseAnimate():this.animated&&this._viewer.resumeAnimate(),this.updateSize(),t){let t=this.renderer.supportedExtensions();if(t.regen=!0,this.viewers)for(let e=0,i=this.viewers.length;e=0&&(this.modelGroup.remove(this.labels[i].sprite),(this.viewer_frame<0||this.labels[i].frame==this.viewer_frame)&&this.modelGroup.add(this.labels[i].sprite));for(i in this.surfaces)if(this.surfaces.hasOwnProperty(i)){var a=this.surfaces[i];for(r=0;r1||1==a[r].symmetries.length&&!a[r].symmetries[r].isIdentity()){var h,c=new n.Object3D;for(h=0;h0?this.animateMotion(e,i,this.modelGroup.position,this.adjustZoomToLimits(s),this.rotationGroup.quaternion,this.lookingAt):(this.rotationGroup.position.z=this.adjustZoomToLimits(s),this.show()),this}translate(t,e,i=0,r=!1){var s=t/this.WIDTH,n=e/this.HEIGHT,a=new $.Vector3(0,0,-this.CAMERA_Z);this.projector.projectVector(a,this.camera),a.x-=s,a.y-=n,this.projector.unprojectVector(a,this.camera),a.z=0;var o=this.lookingAt.clone().add(a);return i>0?this.animateMotion(i,r,this.modelGroup.position,this.rotationGroup.position.z,this.rotationGroup.quaternion,o):(this.lookingAt=o,this.camera.lookAt(this.lookingAt),this.show()),this}translateScene(t,e,i=0,r=!1){var s=this.screenOffsetToModel(t,e),n=this.modelGroup.position.clone().add(s);return i>0?this.animateMotion(i,r,this.modelGroup.position,this.rotationGroup.position.z,this.rotationGroup.quaternion,this.lookingAt):(this.modelGroup.position=n,this.show()),this}fitSlab(t){t=t||{};var e=this.getAtomsFromSel(t),i=(0,L.getExtent)(e),r=i[1][0]-i[0][0],s=i[1][1]-i[0][1],n=i[1][2]-i[0][2],a=Math.hypot(r,s,n);return a<5&&(a=5),this.slabNear=-a/1.9,this.slabFar=a/2,this}center(t={},e=0,i=!1){var r,s,n=this.getAtomsFromSel(t),a=(0,L.getExtent)(n);(0,L.isEmptyObject)(t)?(this.shapes.forEach((t=>{if(t&&t.boundingSphere&&t.boundingSphere.center){var e=t.boundingSphere.center,i=t.boundingSphere.radius;i>0?(n.push(new $.Vector3(e.x+i,e.y,e.z)),n.push(new $.Vector3(e.x-i,e.y,e.z)),n.push(new $.Vector3(e.x,e.y+i,e.z)),n.push(new $.Vector3(e.x,e.y-i,e.z)),n.push(new $.Vector3(e.x,e.y,e.z+i)),n.push(new $.Vector3(e.x,e.y,e.z-i))):n.push(e)}})),a=(0,L.getExtent)(n),r=n,s=a):(r=this.getAtomsFromSel({}),s=(0,L.getExtent)(r));var o=new $.Vector3(a[2][0],a[2][1],a[2][2]),l=s[1][0]-s[0][0],h=s[1][1]-s[0][1],c=s[1][2]-s[0][2],d=Math.hypot(l,h,c);d<5&&(d=5),this.slabNear=-d/1.9,this.slabFar=d/2,l=a[1][0]-a[0][0],h=a[1][1]-a[0][1],c=a[1][2]-a[0][2],(d=Math.hypot(l,h,c))<5&&(d=5);for(var u=25,f=0;fu&&(u=p)}d=2*Math.sqrt(u);var g=o.clone().multiplyScalar(-1);return e>0?this.animateMotion(e,i,g,this.rotationGroup.position.z,this.rotationGroup.quaternion,this.lookingAt):(this.modelGroup.position=g,this.show()),this}zoomTo(t={},e=0,i=!1){let r=this.getAtomsFromSel(t),s=(0,L.getExtent)(r),n=s;if((0,L.isEmptyObject)(t)){let t=r&&r.length;if(this.shapes.forEach((t=>{if(t&&t.boundingSphere)if(t.boundingSphere.box){let e=t.boundingSphere.box;r.push(new $.Vector3(e.min.x,e.min.y,e.min.z)),r.push(new $.Vector3(e.max.x,e.max.y,e.max.z))}else if(t.boundingSphere.center){var e=t.boundingSphere.center,i=t.boundingSphere.radius;i>0?(r.push(new $.Vector3(e.x+i,e.y,e.z)),r.push(new $.Vector3(e.x-i,e.y,e.z)),r.push(new $.Vector3(e.x,e.y+i,e.z)),r.push(new $.Vector3(e.x,e.y-i,e.z)),r.push(new $.Vector3(e.x,e.y,e.z+i)),r.push(new $.Vector3(e.x,e.y,e.z-i))):r.push(e)}})),n=(0,L.getExtent)(r),!t)for(let t=0;t<3;t++)s[2][t]=(n[0][t]+n[1][t])/2}else{let t=this.getAtomsFromSel({});n=(0,L.getExtent)(t)}var a=new $.Vector3(s[2][0],s[2][1],s[2][2]),o=n[1][0]-n[0][0],l=n[1][1]-n[0][1],h=n[1][2]-n[0][2],c=Math.hypot(o,l,h);c<5&&(c=5),this.slabNear=-c/1.9,this.slabFar=c/2,0===Object.keys(t).length&&(this.slabNear=Math.min(2*-c,-50),this.slabFar=Math.max(2*c,50));var d=this.config.minimumZoomToDistance||5;o=s[1][0]-s[0][0],l=s[1][1]-s[0][1],h=s[1][2]-s[0][2],(c=Math.hypot(o,l,h))u&&(u=p)}c=2*Math.sqrt(u);var g=a.clone().multiplyScalar(-1),m=-(.5*c/Math.tan(Math.PI/180*this.camera.fov/2)-this.CAMERA_Z);return m=this.adjustZoomToLimits(m),e>0?this.animateMotion(e,i,g,m,this.rotationGroup.quaternion,this.lookingAt):(this.modelGroup.position=g,this.rotationGroup.position.z=m,this.show()),this}setSlab(t,e){this.slabNear=t,this.slabFar=e}getSlab(){return{near:this.slabNear,far:this.slabFar}}addLabel(t,e={},i,r=!1){if(i){var s=(0,L.getExtent)(this.getAtomsFromSel(i));e.position={x:s[2][0],y:s[2][1],z:s[2][2]}}var n=new Label(t,e);return n.setContext(),this.modelGroup.add(n.sprite),this.labels.push(n),r||this.show(),n}addResLabels(t,e,i=!1){let r=this.labels.length;return this.applyToModels("addResLabels",t,this,e,i),this.show(),this.labels.slice(r)}addPropertyLabels(t,e,i){return this.applyToModels("addPropertyLabels",t,e,this,i),this.show(),this}removeLabel(t){for(var e=0;e0&&void 0===this.shapes[this.shapes.length-1];)this.shapes.pop();return this}removeAllShapes(){for(var t=0;t-1e-4&&s.x<1.0001&&s.y>-1e-4&&s.y<1.0001&&s.z>-1e-4&&s.z<1.0001)}}for(let s=0;ss){t.start=i,t.end=r,e.addLine(t);break}c.addVectors(i,l),t.start=i,t.end=c,e.addLine(t),i=c.clone(),d+=n,c.addVectors(i,h),i=c.clone(),d+=a}return e.finalize(),e}addCustom(t){var e=new GLShape(t=t||{});return e.shapePosition=this.shapes.length,e.addCustom(t),this.shapes.push(e),e.finalize(),e}addVolumetricData(t,e,i={}){var r=new st.VolumeData(t,e);return i.hasOwnProperty("transferfn")?this.addVolumetricRender(r,i):this.addIsosurface(r,i)}addIsosurface(t,e={},i){var r=new GLShape(e);return r.shapePosition=this.shapes.length,r.addIsosurface(t,e,i,this),this.shapes.push(r),r}addVolumetricRender(t,e){var i=new GLVolumetricRender(t,e=e||{},this);return i.shapePosition=this.shapes.length,this.shapes.push(i),i}hasVolumetricRender(){return this.renderer.supportsVolumetric()}enableFog(t){t?this.scene.fog=new n.Fog(this.bgColor,100,200):(this.config.disableFog=!0,this.show())}setFrame(t){this.viewer_frame=t;let e=this;return new Promise((function(i){var r=e.models.map((function(i){return i.setFrame(t,e)}));Promise.all(r).then((function(){i()}))}))}getFrame(){return this.viewer_frame}getNumFrames(){var t=0;for(let e=0;et&&(t=this.models[e].getNumFrames());for(let e=0;e=t&&(t=this.shapes[e].frame+1);for(let e=0;e=t&&(t=this.labels[e].frame+1);return t}animate(t){this.incAnim();var e=100,i="forward",r=1/0;(t=t||{}).interval&&(e=t.interval),t.loop&&(i=t.loop),t.reps&&(r=t.reps);var s=this.getNumFrames(),n=this,a=0;t.startFrame&&(a=t.startFrame%s);var o=1;t.step&&(r/=o=t.step);var l,h,c=0,d=s*r,u=new Date,f=function(t){u=new Date,"forward"==t?n.setFrame(a).then((function(){a=(a+o)%s,l()})):"backward"==t?n.setFrame(s-1-a).then((function(){a=(a+o)%s,l()})):n.setFrame(a).then((function(){o*=(a+=o)%(s-1)==0?-1:1,l()}))};return l=function(){if(n.render(),n.getCanvas().isConnected)if(++c>=d||!n.isAnimated())h.cancel(),n.animationTimers.delete(h),n.decAnim();else{var t=e-((new Date).getTime()-u.getTime());t=t>0?t:0,n.animationTimers.delete(h),h=new L.PausableTimer(f,t,i),n.animationTimers.add(h)}else n.stopAnimate()},h=new L.PausableTimer(f,0,i),this.animationTimers.add(h),this}stopAnimate(){return this.animated=0,this.animationTimers.forEach((function(t){t.cancel()})),this.animationTimers=new Set,this}pauseAnimate(){return this.animationTimers.forEach((function(t){t.pause()})),this}resumeAnimate(){return this.animationTimers.forEach((function(t){t.resume()})),this}isAnimated(){return this.animated>0}getModelOpt(t){return t&&!t.defaultcolors?(t.defaultcolors=this.defaultcolors,t.cartoonQuality=t.cartoonQuality||this.config.cartoonQuality):void 0===t&&(t={defaultcolors:this.defaultcolors,cartoonQuality:this.config.cartoonQuality}),t}addModel(t,e="",i){i=this.getModelOpt(i);var r=new GLModel(this.models.length,i);return r.addMolData(t,e,i),this.models.push(r),r}addModels(t,e,i){(i=this.getModelOpt(i)).multimodel=!0,i.frames=!0;for(var r=GLModel.parseMolData(t,e,i),s=0;s0&&void 0===this.models[this.models.length-1];)this.models.pop();return this}}removeAllModels(){for(var t=0;te[1][0]||r.ye[1][1]||r.ze[1][2]||i.push(r))}return i}static volume(t){return(t[1][0]-t[0][0])*(t[1][1]-t[0][1])*(t[1][2]-t[0][2])}carveUpExtent(t,e,i){let r=[],s={};for(let t=0,i=e.length;tr&&i>s?0:r>i&&r>s?1:2;var n=a(t),l=a(t),h=(t[1][e]-t[0][e])/2+t[0][e];n[1][e]=h,l[0][e]=h;var c=o(n),d=o(l);return c.concat(d)},l=o(t);for(let t=0,s=l.length;t0)for(let e=0,i=c.length;e1||1==v.length&&!v[0].isIdentity()){m=!0;break}}var _=function(t,i,s){var n;f=a?GLViewer.shallowCopy(c.getAtomsFromSel(a)):s;var o=(0,L.getExtent)(s,!0);if(e.map&&e.map.prop){var u=e.map.prop;let t=(0,r.getGradient)(e.map.scheme||e.map.gradient||new r.Gradient.RWB),i=t.range();i||(i=(0,L.getPropertyRange)(s,u)),e.colorscheme={prop:u,gradient:t}}for(let t=0,r=i.length;t0){var m=(0,L.getExtent)(f,!0);g.sort((function(t,e){var i=function(t,e){var i=t.extent,r=i[1][0]-i[0][0],s=i[1][1]-i[0][1],n=i[1][2]-i[0][2],a=r-e[2][0];a*=a;var o=s-e[2][1];o*=o;var l=n-e[2][2];return a+o+(l*=l)};return i(t,m)-i(e,m)}))}var v=[];for(let t=0,e=i.length;t0&&(y.push({geo:new n.Geometry(!0),mat:h,done:!1,finished:!1,symmetries:this.models[g].getSymmetries()}),A.push(_(y[y.length-1],x[g],w[g])));b=Promise.all(A)}else y.push({geo:new n.Geometry(!0),mat:h,done:!1,finished:!1,symmetries:[new $.Matrix4]}),b=_(y[y.length-1],u,p);return this.surfaces[l]=y,b.surfid=l,o&&"function"==typeof o?(b.then((function(t){o(t)})),l):b}setSurfaceMaterialStyle(t,e){if((0,L.adjustVolumeStyle)(e),this.surfaces[t]){var i=this.surfaces[t];for(let t=0;t0?this.camera.position.x=i*Math.tan(Math.PI/180*e):this.camera.position.x=-i*Math.tan(Math.PI/180*e),this.camera.lookAt(new $.Vector3(0,0,this.rotationGroup.position.z)),this.camera.position.x}setDefaultCartoonQuality(t){this.config.cartoonQuality=t}}function qt(t,e){if(t=(0,L.getElement)(t)){e=e||{};try{return new GLViewer(t,e)}catch(t){throw"error creating viewer: "+t}}}function Yt(t,e={},i={}){if(t=(0,L.getElement)(t)){var r=[],s=document.createElement("canvas");i.rows=e.rows,i.cols=e.cols,i.control_all=null!=e.control_all&&e.control_all,t.appendChild(s);try{for(var n=0;n{var l=[],h=[],c="";"static"==o.style.position&&(o.style.position="relative");var d=null;if(n=null,o.dataset.pdb)l.push("https://files.rcsb.org/view/"+o.dataset.pdb+".pdb"),h.push("pdb");else if(o.dataset.cid)h.push("sdf"),l.push("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+o.dataset.cid+"/SDF?record_type=3d");else if(o.dataset.href||o.dataset.url){if(c=o.dataset.href?o.dataset.href:o.dataset.url,l.push(c),"gz"==(n=c.substring(c.lastIndexOf(".")+1))){let t=c.substring(0,c.lastIndexOf(".")).lastIndexOf(".");n=c.substring(t+1)}h.push(n);var u=c.substring(c.lastIndexOf("/")+1,c.lastIndexOf("."));"/"==u&&(u=c.substring(c.lastIndexOf("/")+1)),o.dataset[h[h.length-1]]=u}let f=o.dataset;for(i in f)"pdb"===i.substring(0,3)&&"pdb"!==i?(l.push("https://files.rcsb.org/view/"+f[i]+".pdb"),h.push("pdb")):"href"===i.substring(0,4)&&"href"!==i?(c=f[i],l.push(c),h.push(c.substring(c.lastIndexOf(".")+1))):"cid"===i.substring(0,3)&&"cid"!==i&&(l.push("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+f[i]+"/SDF?record_type=3d"),h.push("sdf"));var p={};o.dataset.options&&(p=(0,L.specStringToObject)(o.dataset.options));var g=s.CC.color(o.dataset.backgroundcolor),m=o.dataset.backgroundalpha;m=null==m?1:parseFloat(m);var v={line:{}};o.dataset.style&&(v=(0,L.specStringToObject)(o.dataset.style));var _={};o.dataset.select&&(_=(0,L.specStringToObject)(o.dataset.select));var y=[],b=[],x=[],w={},A=null,C=o.dataset,S=/style(.+)/,M=/surface(.*)/,z=/labelres(.*)/,T=[];for(r in C)Object.prototype.hasOwnProperty.call(C,r)&&T.push(r);for(T.sort(),i=0;i{d.loadSurface("VDW",e,r,t)})):t.addSurface(Q.VDW,r,e,e)}for(i=0;ifunction(n){c=l[t];var a=r.dataset.type||r.dataset.datatype||h[t];if(s.addModel(n,a,p),d){var o=r.dataset[h[t]];d.setModelTitle(o)}if(t+=1,t{"complete"===document.readyState&&$t()},window&&(window.$3Dmol=e)},865:(t,e,i)=>{"use strict";i.r(e),i.d(e,{CUBE:()=>a});var r=i(638),s=i(392);const n={1:"H",2:"He",3:"Li",4:"Be",5:"B",6:"C",7:"N",8:"O",9:"F",10:"Ne",11:"Na",12:"Mg",13:"Al",14:"Si",15:"P",16:"S",17:"Cl",18:"Ar",19:"K",20:"Ca",21:"Sc",22:"Ti",23:"V",24:"Cr",25:"Mn",26:"Fe",27:"Co",28:"Ni",29:"Cu",30:"Zn",31:"Ga",32:"Ge",33:"As",34:"Se",35:"Br",36:"Kr",37:"Rb",38:"Sr",39:"Y",40:"Zr",41:"Nb",42:"Mo",43:"Tc",44:"Ru",45:"Rh",46:"Pd",47:"Ag",48:"Cd",49:"In",50:"Sn",51:"Sb",52:"Te",53:"I",54:"Xe",55:"Cs",56:"Ba",71:"Lu",72:"Hf",73:"Ta",74:"W",75:"Re",76:"Os",77:"Ir",78:"Pt",79:"Au",80:"Hg",81:"Tl",82:"Pb",83:"Bi",84:"Po",85:"At",86:"Rn",87:"Fr",88:"Ra",104:"Rf",105:"Db",106:"Sg",107:"Bh",108:"Hs",109:"Mt",110:"Ds",111:"Rg",112:"Cn",113:"Nh",114:"Fl",115:"Mc",116:"Lv",117:"Ts",118:"Og",57:"La",58:"Ce",59:"Pr",60:"Nd",61:"Pm",62:"Sm",63:"Eu",64:"Gd",65:"Tb",66:"Dy",67:"Ho",68:"Er",69:"Tm",70:"Yb",89:"Ac",90:"Th",91:"Pa",92:"U",93:"Np",94:"Pu",95:"Am",96:"Cm",97:"Bk",98:"Cf",99:"Es",100:"Fm",101:"Md",102:"No"};function a(t,e){e=e||{};const i=[[]];let a=t.split(/\r?\n/);const o=void 0===e.assignBonds||e.assignBonds;if(a.length<6)return i;let l=a[2].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");const h=Math.abs(parseFloat(l[0]));let c={origin:void 0,size:void 0,unit:void 0,matrix4:void 0,matrix:void 0};const d=c.origin=new r.Vector3(parseFloat(l[1]),parseFloat(l[2]),parseFloat(l[3]));l=a[3].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),l=a[3].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");const u=l[0]>0?.529177:1;d.multiplyScalar(u);const f=Math.abs(l[0]),p=new r.Vector3(parseFloat(l[1]),parseFloat(l[2]),parseFloat(l[3])).multiplyScalar(u);l=a[4].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");const g=Math.abs(l[0]),m=new r.Vector3(parseFloat(l[1]),parseFloat(l[2]),parseFloat(l[3])).multiplyScalar(u);l=a[5].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");const v=Math.abs(l[0]),_=new r.Vector3(parseFloat(l[1]),parseFloat(l[2]),parseFloat(l[3])).multiplyScalar(u);if(c.size={x:f,y:g,z:v},c.unit=new r.Vector3(p.x,m.y,_.z),0!=p.y||0!=p.z||0!=m.x||0!=m.z||0!=_.x||0!=_.y){c.matrix4=new r.Matrix4(p.x,m.x,_.x,0,p.y,m.y,_.y,0,p.z,m.z,_.z,0,0,0,0,1);let t=(new r.Matrix4).makeTranslation(d.x,d.y,d.z);c.matrix4=c.matrix4.multiplyMatrices(t,c.matrix4),c.matrix=c.matrix4.matrix3FromTopLeft(),c.origin=new r.Vector3(0,0,0),c.unit=new r.Vector3(1,1,1)}i.modelData=[{cryst:c}],a=a.splice(6,h);for(var y=i[i.length-1].length,b=y+a.length,x=y;x{"use strict";i.r(e),i.d(e,{VASP:()=>n});var r=i(638),s=i(392);function n(t,e={}){var i=[[]],n={};const a=void 0===e.assignBonds||e.assignBonds;var o=t.replace(/^\s+/,"").split(/\r?\n/);if(o.length<3)return i;if(!o[1].match(/\d+/))return console.log("Warning: second line of the vasp structure file must be a number"),i;if(n.length=parseFloat(o[1]),n.length<0)return console.log("Warning: Vasp implementation for negative lattice lengths is not yet available"),i;n.xVec=new Float32Array(o[2].replace(/^\s+/,"").split(/\s+/)),n.yVec=new Float32Array(o[3].replace(/^\s+/,"").split(/\s+/)),n.zVec=new Float32Array(o[4].replace(/^\s+/,"").split(/\s+/));var l=new r.Matrix3(n.xVec[0],n.xVec[1],n.xVec[2],n.yVec[0],n.yVec[1],n.yVec[2],n.zVec[0],n.zVec[1],n.zVec[2]);l.multiplyScalar(n.length),i.modelData=[{symmetries:[],cryst:{matrix:l}}];var h=o[5].trim().split(/\s+/),c=new Int16Array(o[6].trim().split(/\s+/)),d=o[7].trim(),u=!1;if(d.match(/S/)&&(u=!0,d=o[8].trim()),"c"==d.toLowerCase()[0])d="cartesian";else{if("d"!=d.toLowerCase()[0])return console.log("Warning: Unknown vasp mode in POSCAR file: mode must be either C(artesian) or D(irect)"),i;d="direct"}if(h.length!=c.length)return console.log("Warning: declaration of atomary species wrong:"),console.log(h),console.log(c),i;u?o.splice(0,9):o.splice(0,8);for(var f=0,p=0,g=h.length;p{"use strict";i.r(e),i.d(e,{areConnected:()=>n});var r=i(40);const s=new Set(["Na","K","Ca","Mg","Mn","Sr"]);function n(t,e,i){if(i&&i.unboundCations&&(s.has(t.elem)||s.has(e.elem)))return!1;let n=(0,r.bondLength)(t.elem)+(0,r.bondLength)(e.elem);n+=.25,n*=n;let a=t.x-e.x;if(a*=a,a>n)return!1;let o=t.y-e.y;if(o*=o,o>n)return!1;let l=t.z-e.z;if(l*=l,l>n)return!1;const h=a+o+l;return!(isNaN(h)||h<.5||h>n||t.altLoc!==e.altLoc&&""!==t.altLoc.trim()&&""!==e.altLoc.trim())}},392:(t,e,i)=>{"use strict";i.r(e),i.d(e,{assignBonds:()=>a});var r=i(408);const s=[{x:0,y:0,z:1},{x:0,y:1,z:-1},{x:0,y:1,z:0},{x:0,y:1,z:1},{x:1,y:-1,z:-1},{x:1,y:-1,z:0},{x:1,y:-1,z:1},{x:1,y:0,z:-1},{x:1,y:0,z:0},{x:1,y:0,z:1},{x:1,y:1,z:-1},{x:1,y:1,z:0},{x:1,y:1,z:1}],n=4.95;function a(t,e){for(let e=0,i=t.length;e{"use strict";i.r(e),i.d(e,{bondLength:()=>s,bondTable:()=>r,setBondLength:()=>n});let r={H:.37,He:.32,Li:1.34,Be:.9,B:.82,C:.77,N:.75,O:.73,F:.71,Ne:.69,Na:1.54,Mg:1.3,Al:1.18,Si:1.11,P:1.06,S:1.02,Cl:.99,Ar:.97,K:1.96,Ca:1.74,Sc:1.44,Ti:1.56,V:1.25,Mn:1.39,Fe:1.25,Co:1.26,Ni:1.21,Cu:1.38,Zn:1.31,Ga:1.26,Ge:1.22,Se:1.16,Br:1.14,Kr:1.1,Rb:2.11,Sr:1.92,Y:1.62,Zr:1.48,Nb:1.37,Mo:1.45,Tc:1.56,Ru:1.26,Rh:1.35,Pd:1.31,Ag:1.53,Cd:1.48,In:1.44,Sn:1.41,Sb:1.38,Te:1.35,I:1.33,Xe:1.3,Cs:2.25,Ba:1.98,Lu:1.6,Hf:1.5,Ta:1.38,W:1.46,Re:1.59,Os:1.44,Ir:1.37,Pt:1.28,Au:1.44,Hg:1.49,Tl:1.48,Pb:1.47,Bi:1.46,Rn:1.45};function s(t){return r[t]||1.6}function n(t,e){e<0&&(e=0),r[t]=e}},864:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{PausableTimer:()=>PausableTimer,adjustVolumeStyle:()=>adjustVolumeStyle,base64ToArray:()=>base64ToArray,deepCopy:()=>deepCopy,download:()=>download,extend:()=>extend,get:()=>get,getAtomProperty:()=>getAtomProperty,getColorFromStyle:()=>getColorFromStyle,getElement:()=>getElement,getExtent:()=>getExtent,getPropertyRange:()=>getPropertyRange,getbin:()=>getbin,inflateString:()=>inflateString,isEmptyObject:()=>isEmptyObject,isNumeric:()=>isNumeric,makeFunction:()=>makeFunction,mergeGeos:()=>mergeGeos,specStringToObject:()=>specStringToObject});var _Gradient__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(546),_VolumeData__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(848),_colors__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(222),pako__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(75);function extend(t,e){for(var i in e)e.hasOwnProperty(i)&&void 0!==e[i]&&(t[i]=e[i]);return t}function deepCopy(t){let e,i,r;if(null==t)return{};if("object"!=typeof t||null===t)return t;for(r in e=Array.isArray(t)?[]:{},t)i=t[r],e[r]=deepCopy(i);return e}function isNumeric(t){var e=typeof t;return("number"===e||"string"===e)&&!isNaN(t-parseFloat(t))}function isEmptyObject(t){var e;for(e in t)return!1;return!0}function makeFunction(callback){return callback&&"string"==typeof callback&&(callback=eval("("+callback+")")),callback&&"function"!=typeof callback?(console.warn("Invalid callback provided."),()=>{}):callback}function adjustVolumeStyle(t){t&&(!t.volformat||t.voldata instanceof _VolumeData__WEBPACK_IMPORTED_MODULE_1__.VolumeData||(t.voldata=new _VolumeData__WEBPACK_IMPORTED_MODULE_1__.VolumeData(t.voldata,t.volformat)),t.volscheme&&(t.volscheme=_Gradient__WEBPACK_IMPORTED_MODULE_0__.Gradient.getGradient(t.volscheme)))}function getExtent(t,e){var i,r,s,n,a,o,l,h,c,d,u=!e;if(i=r=s=9999,n=a=o=-9999,l=h=c=d=0,0===t.length)return[[0,0,0],[0,0,0],[0,0,0]];for(var f=0;fp.x?n:p.x,a=a>p.y?a:p.y,o=o>p.z?o:p.z,p.symmetries&&u))for(var g=0;gp.symmetries[g].x?n:p.symmetries[g].x,a=a>p.symmetries[g].y?a:p.symmetries[g].y,o=o>p.symmetries[g].z?o:p.symmetries[g].z}return[[i,r,s],[n,a,o],[l/d,h/d,c/d]]}function getPropertyRange(t,e){for(var i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=0,n=t.length;sr&&(r=a))}return isFinite(i)||isFinite(r)?isFinite(i)?isFinite(r)||(r=i):i=r:i=r=0,[i,r]}class PausableTimer{constructor(t,e,i){this.total_time_run=0,this.fn=t,this.arg=i,this.countdown=e,this.start_time=(new Date).getTime(),this.ident=setTimeout(t,e,i)}cancel(){clearTimeout(this.ident)}pause(){clearTimeout(this.ident),this.total_time_run=(new Date).getTime()-this.start_time}resume(){this.ident=setTimeout(this.fn,Math.max(0,this.countdown-this.total_time_run),this.arg)}}function base64ToArray(t){for(var e=window.atob(t),i=e.length,r=new Uint8Array(i),s=0;s=0?parseFloat(t):parseInt(t):"true"===t||"false"!==t&&t},i={};if("all"===(t=t.replace(/%7E/g,"~")))return i;for(var r=t.split(";"),s=0;st.text()));return e?i.then(e):i}function getbin(t,e,i,r){var s;return s="POST"==i?fetch(t,{method:"POST",body:r}).then((t=>checkStatus(t))).then((t=>t.arrayBuffer())):fetch(t).then((t=>checkStatus(t))).then((t=>t.arrayBuffer())),e?s.then(e):s}function download(t,e,i,r){var s="",n="",a="",o=null,l=e.addModel();if(t.indexOf(":")<0&&(t=4==t.length?"pdb:"+t:isNaN(t)?"url:"+t:"cid:"+t),"mmtf:"==t.substring(0,5)&&(console.warn("WARNING: MMTF now deprecated. Reverting to bcif."),t="bcif:"+t.slice(5)),"bcif:"===t.substring(0,5))t=t.substring(5).toUpperCase(),a="https://models.rcsb.org/"+t+".bcif.gz",i&&void 0===i.noComputeSecondaryStructure&&(i.noComputeSecondaryStructure=!0),o=new Promise((function(t){getbin(a).then((function(r){l.addMolData(r,"bcif.gz",i),e.zoomTo(),e.render(),t(l)}),(function(){console.error("fetch of "+a+" failed.")}))}));else{if("pdb:"===t.substring(0,4)){if(s="bcif",i&&i.format&&(s=i.format),i&&void 0===i.noComputeSecondaryStructure&&(i.noComputeSecondaryStructure=!0),!(t=t.substring(4).toUpperCase()).match(/^[1-9][A-Za-z0-9]{3}$/))return void alert("Wrong PDB ID");"bcif"==s?a="https://models.rcsb.org/"+t.toUpperCase()+".bcif.gz":(n=i&&i.pdbUri?i.pdbUri:"https://files.rcsb.org/view/",a=n+t+"."+s)}else if("cid:"==t.substring(0,4)){if(s="sdf",!(t=t.substring(4)).match(/^[0-9]+$/))return void alert("Wrong Compound ID");a="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+t+"/SDF?record_type=3d"}else"url:"==t.substring(0,4)&&(a=t.substring(4),s=a);var h=function(t){l.addMolData(t,s,i),e.zoomTo(),e.render()};o=new Promise((function(e){"bcif"==s?getbin(a).then((function(t){h(t),e(l)})).catch((function(){n=i&&i.pdbUri?i.pdbUri:"https://files.rcsb.org/view/",a=n+t+".pdb",s="pdb",console.warn("falling back to pdb format"),get(a).then((function(t){h(t),e(l)})).catch((function(t){h(""),e(l),console.error("fetch of "+a+" failed: "+t.statusText)}))})):get(a).then((function(t){h(t),e(l)})).catch((function(t){h(""),e(l),console.error("fetch of "+a+" failed: "+t.statusText)}))}))}return r?(o.then((function(t){r(t)})),l):o}function getColorFromStyle(t,e){let i=e.colorscheme;if(void 0!==_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[i])i=_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[i];else if("string"==typeof i&&i.endsWith("Carbon")){let t=i.substring(0,i.lastIndexOf("Carbon")).toLowerCase();if(void 0!==_colors__WEBPACK_IMPORTED_MODULE_2__.htmlColors[t]){let e=Object.assign({},_colors__WEBPACK_IMPORTED_MODULE_2__.elementColors.defaultColors);e.C=_colors__WEBPACK_IMPORTED_MODULE_2__.htmlColors[t],_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[i]={prop:"elem",map:e},i=_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[i]}}let r=t.color;if(void 0!==e.color&&"spectrum"!=e.color&&(r=e.color),void 0!==i){let n,a;if(void 0!==_colors__WEBPACK_IMPORTED_MODULE_2__.elementColors[i])i=_colors__WEBPACK_IMPORTED_MODULE_2__.elementColors[i],void 0!==i[t[i.prop]]&&(r=i.map[t[i.prop]]);else if(void 0!==i[t[i.prop]])r=i.map[t[i.prop]];else if(void 0!==i.prop&&void 0!==i.gradient){n=i.prop;var s=i.gradient;s instanceof _Gradient__WEBPACK_IMPORTED_MODULE_0__.GradientType||(s=(0,_Gradient__WEBPACK_IMPORTED_MODULE_0__.getGradient)(i));let e=s.range()||[-1,1];a=getAtomProperty(t,n),null!=a&&(r=s.valueToHex(a,e))}else void 0!==i.prop&&void 0!==i.map?(n=i.prop,a=getAtomProperty(t,n),void 0!==i.map[a]&&(r=i.map[a])):void 0!==e.colorscheme[t.elem]?r=e.colorscheme[t.elem]:console.warn("Could not interpret colorscheme "+i)}else void 0!==e.colorfunc&&(r=e.colorfunc(t));return _colors__WEBPACK_IMPORTED_MODULE_2__.CC.color(r)}function getElement(t){let e=t;return"string"==typeof t?e=document.querySelector("#"+t):"object"==typeof t&&t.get&&(e=t.get(0)),e}function inflateString(t,e=!0){let i;if("string"==typeof t){i=(new TextEncoder).encode(t)}else i=new Uint8Array(t);return(0,pako__WEBPACK_IMPORTED_MODULE_3__.inflate)(i,{to:e?"string":null})}},111:(t,e,i)=>{var r;r={},t.exports=r,function(t,e){t.toRGBA8=function(e){var i=e.width,r=e.height;if(null==e.tabs.acTL)return[t.toRGBA8.decodeImage(e.data,i,r,e).buffer];var s=[];null==e.frames[0].data&&(e.frames[0].data=e.data);for(var n,a=new Uint8Array(i*r*4),o=0;o>3)]>>7-(7&p)&1);l[M]=b[z],l[M+1]=b[z+1],l[M+2]=b[z+2],l[M+3]=T>2)]>>6-((3&p)<<1)&3),l[M]=b[z],l[M+1]=b[z+1],l[M+2]=b[z+2],l[M+3]=T>1)]>>4-((1&p)<<2)&15),l[M]=b[z],l[M+1]=b[z+1],l[M+2]=b[z+2],l[M+3]=T>3]>>7-(7&p)&1))==255*m?0:255;h[p]=F<<24|E<<16|E<<8|E}if(2==d)for(p=0;p>2]>>6-((3&p)<<1)&3))==85*m?0:255,h[p]=F<<24|E<<16|E<<8|E;if(4==d)for(p=0;p>1]>>4-((1&p)<<2)&15))==17*m?0:255,h[p]=F<<24|E<<16|E<<8|E;if(8==d)for(p=0;p>3,o=Math.ceil(r*n/8),l=new Uint8Array(s*o),h=0,c=[0,0,4,0,2,0,1],d=[0,4,0,2,0,1,0],u=[8,8,8,4,4,2,2],f=[8,8,4,4,2,2,1],p=0;p<7;){for(var g=u[p],m=f[p],v=0,_=0,y=c[p];y>3])>>7-(7&S)&1,l[A*o+(C>>3)]|=M<<7-(3&C)),2==n&&(M=(M=e[S>>3])>>6-(7&S)&3,l[A*o+(C>>2)]|=M<<6-((3&C)<<1)),4==n&&(M=(M=e[S>>3])>>4-(7&S)&15,l[A*o+(C>>1)]|=M<<4-((1&C)<<2)),n>=8)for(var z=A*o+C*a,T=0;T>3)+T];S+=n,C+=m}w++,A+=g}v*_!=0&&(h+=_*(1+x)),p+=1}return l},t.decode._getBPP=function(t){return[1,null,3,1,2,null,4][t.ctype]*t.depth},t.decode._filterZero=function(e,i,r,s,n){var a=t.decode._getBPP(i),o=Math.ceil(s*a/8),l=t.decode._paeth;a=Math.ceil(a/8);for(var h=0;h>1)&255;if(4==u)for(f=a;f>1)&255;for(f=a;f>1)&255}if(4==u){for(f=0;f>8&255,t[e+1]=255&i},readUint:function(t,e){return 16777216*t[e]+(t[e+1]<<16|t[e+2]<<8|t[e+3])},writeUint:function(t,e,i){t[e]=i>>24&255,t[e+1]=i>>16&255,t[e+2]=i>>8&255,t[e+3]=255&i},readASCII:function(t,e,i){for(var r="",s=0;s=0&&o>=0?(d=f*e+p<<2,u=(o+f)*s+a+p<<2):(d=(-o+f)*e-a+p<<2,u=f*s+p<<2),0==l)r[u]=t[d],r[u+1]=t[d+1],r[u+2]=t[d+2],r[u+3]=t[d+3];else if(1==l){var g=t[d+3]*(1/255),m=t[d]*g,v=t[d+1]*g,_=t[d+2]*g,y=r[u+3]*(1/255),b=r[u]*y,x=r[u+1]*y,w=r[u+2]*y,A=1-g,C=g+y*A,S=0==C?0:1/C;r[u+3]=255*C,r[u+0]=(m+b*A)*S,r[u+1]=(v+x*A)*S,r[u+2]=(_+w*A)*S}else if(2==l)g=t[d+3],m=t[d],v=t[d+1],_=t[d+2],y=r[u+3],b=r[u],x=r[u+1],w=r[u+2],g==y&&m==b&&v==x&&_==w?(r[u]=0,r[u+1]=0,r[u+2]=0,r[u+3]=0):(r[u]=m,r[u+1]=v,r[u+2]=_,r[u+3]=g);else if(3==l){if(g=t[d+3],m=t[d],v=t[d+1],_=t[d+2],y=r[u+3],b=r[u],x=r[u+1],w=r[u+2],g==y&&m==b&&v==x&&_==w)continue;if(g<220&&y>20)return!1}return!0},t.encode=function(e,i,r,s,n,a){null==s&&(s=0),null==a&&(a=!1);for(var o=new Uint8Array(e[0].byteLength*e.length+100),l=[137,80,78,71,13,10,26,10],h=0;h<8;h++)o[h]=l[h];var c=8,d=t._bin,u=t.crc.crc,f=d.writeUint,p=d.writeUshort,g=d.writeASCII,m=t.encode.compressPNG(e,i,r,s,a);f(o,c,13),g(o,c+=4,"IHDR"),f(o,c+=4,i),f(o,c+=4,r),o[c+=4]=m.depth,o[++c]=m.ctype,o[++c]=0,o[++c]=0,o[++c]=0,f(o,++c,u(o,c-17,17)),f(o,c+=4,1),g(o,c+=4,"sRGB"),o[c+=4]=1,f(o,++c,u(o,c-5,5)),c+=4;var v=e.length>1;if(v&&(f(o,c,8),g(o,c+=4,"acTL"),f(o,c+=4,e.length),f(o,c+=4,0),f(o,c+=4,u(o,c-12,12)),c+=4),3==m.ctype){for(f(o,c,3*(M=m.plte.length)),g(o,c+=4,"PLTE"),c+=4,h=0;h>8&255,w=y>>16&255;o[c+_+0]=b,o[c+_+1]=x,o[c+_+2]=w}if(f(o,c+=3*M,u(o,c-3*M-4,3*M+4)),c+=4,m.gotAlpha){for(f(o,c,M),g(o,c+=4,"tRNS"),c+=4,h=0;h>24&255;f(o,c+=M,u(o,c-M-4,M+4)),c+=4}}for(var A=0,C=0;C=300))break}}var x=!!g&&n,w=v.length;w<=256&&0==a&&(l=w<=2?1:w<=4?2:w<=16?4:8,n&&(l=8),g=!0);var A=[];for(d=0;dB&&(B=V),GN&&(N=G));var j=-1==B?1:(B-P+1)*(N-U+1);j>1)]|=m[S[q+V]]<<4-4*(1&V);else if(2==l)for(V=0;V>2)]|=m[S[q+V]]<<6-2*(3&V);else if(1==l)for(V=0;V>3)]|=m[S[q+V]]<<7-1*(7&V)}C=H,o=3,h=1}else if(0==g&&1==e.length){H=new Uint8Array(T*E*3);var Y=T*E;for(p=0;p5e5)||2!=l&&3!=l&&4!=l){for(var h=0;h>1)+256&255;if(4==a)for(c=n;c>1)&255;for(c=n;c>1)&255}if(4==a){for(c=0;c>>1:i>>>=1;t[e]=i}return t}(),update:function(e,i,r,s){for(var n=0;n>>8;return e},crc:function(e,i,r){return 4294967295^t.crc.update(4294967295,e,i,r)}},t.quantize=function(e,i,r){for(var s=[],n=0,a=0;ag&&(g=p[a].est.L,m=a);if(g<.001)break;var v=p[m],_=t.quantize.splitPixels(o,l,v.i0,v.i1,v.est.e,v.est.eMq255),y={i0:v.i0,i1:_,bst:null,est:null,tdst:0,left:null,right:null};y.bst=t.quantize.stats(o,y.i0,y.i1),y.est=t.quantize.estats(y.bst);var b={i0:_,i1:v.i1,bst:null,est:null,tdst:0,left:null,right:null};for(b.bst={R:[],m:[],N:v.bst.N-y.bst.N},a=0;a<16;a++)b.bst.R[a]=v.bst.R[a]-y.bst.R[a];for(a=0;a<4;a++)b.bst.m[a]=v.bst.m[a]-y.bst.m[a];b.est=t.quantize.estats(b.bst),v.left=y,v.right=b,p[m]=y,p.push(b)}p.sort((function(t,e){return e.bst.N-t.bst.N}));for(var x=0;x>2]=L.est.rgba}s[x]=C.buffer}return{bufs:s,plte:p}},t.quantize.getNearest=function(e,i,r,s,n){if(null==e.left)return e.tdst=t.quantize.dist(e.est.q,i,r,s,n),e;var a=t.quantize.planeDst(e.est,i,r,s,n),o=e.left,l=e.right;a>0&&(o=e.right,l=e.left);var h=t.quantize.getNearest(o,i,r,s,n);if(h.tdst<=a*a)return h;var c=t.quantize.getNearest(l,i,r,s,n);return c.tdsta;)s-=4;if(r>=s)break;var l=i[r>>2];i[r>>2]=i[s>>2],i[s>>2]=l,r+=4,s-=4}for(;o(e,r,n)>a;)r-=4;return r+4},t.quantize.vecDot=function(t,e,i){return t[e]*i[0]+t[e+1]*i[1]+t[e+2]*i[2]+t[e+3]*i[3]},t.quantize.stats=function(t,e,i){for(var r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s=[0,0,0,0],n=i-e>>2,a=e;a>>0}},t.M4={multVec:function(t,e){return[t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3],t[4]*e[0]+t[5]*e[1]+t[6]*e[2]+t[7]*e[3],t[8]*e[0]+t[9]*e[1]+t[10]*e[2]+t[11]*e[3],t[12]*e[0]+t[13]*e[1]+t[14]*e[2]+t[15]*e[3]]},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},sml:function(t,e){return[t*e[0],t*e[1],t*e[2],t*e[3]]}},t.encode.alphaMul=function(t,e){for(var i=new Uint8Array(t.length),r=t.length>>2,s=0;s{"use strict";var r={};(0,i(981).assign)(r,i(71),i(3),i(681)),t.exports=r},71:(t,e,i)=>{"use strict";var r=i(107),s=i(981),n=i(972),a=i(834),o=i(746),l=Object.prototype.toString;function h(t){if(!(this instanceof h))return new h(t);this.options=s.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new o,this.strm.avail_out=0;var i=r.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(0!==i)throw new Error(a[i]);if(e.header&&r.deflateSetHeader(this.strm,e.header),e.dictionary){var c;if(c="string"==typeof e.dictionary?n.string2buf(e.dictionary):"[object ArrayBuffer]"===l.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,0!==(i=r.deflateSetDictionary(this.strm,c)))throw new Error(a[i]);this._dict_set=!0}}function c(t,e){var i=new h(e);if(i.push(t,!0),i.err)throw i.msg||a[i.err];return i.result}h.prototype.push=function(t,e){var i,a,o=this.strm,h=this.options.chunkSize;if(this.ended)return!1;a=e===~~e?e:!0===e?4:0,"string"==typeof t?o.input=n.string2buf(t):"[object ArrayBuffer]"===l.call(t)?o.input=new Uint8Array(t):o.input=t,o.next_in=0,o.avail_in=o.input.length;do{if(0===o.avail_out&&(o.output=new s.Buf8(h),o.next_out=0,o.avail_out=h),1!==(i=r.deflate(o,a))&&0!==i)return this.onEnd(i),this.ended=!0,!1;0!==o.avail_out&&(0!==o.avail_in||4!==a&&2!==a)||("string"===this.options.to?this.onData(n.buf2binstring(s.shrinkBuf(o.output,o.next_out))):this.onData(s.shrinkBuf(o.output,o.next_out)))}while((o.avail_in>0||0===o.avail_out)&&1!==i);return 4===a?(i=r.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,0===i):2!==a||(this.onEnd(0),o.avail_out=0,!0)},h.prototype.onData=function(t){this.chunks.push(t)},h.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Deflate=h,e.deflate=c,e.deflateRaw=function(t,e){return(e=e||{}).raw=!0,c(t,e)},e.gzip=function(t,e){return(e=e||{}).gzip=!0,c(t,e)}},3:(t,e,i)=>{"use strict";var r=i(663),s=i(981),n=i(972),a=i(681),o=i(834),l=i(746),h=i(670),c=Object.prototype.toString;function d(t){if(!(this instanceof d))return new d(t);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var i=r.inflateInit2(this.strm,e.windowBits);if(i!==a.Z_OK)throw new Error(o[i]);if(this.header=new h,r.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=n.string2buf(e.dictionary):"[object ArrayBuffer]"===c.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=r.inflateSetDictionary(this.strm,e.dictionary))!==a.Z_OK))throw new Error(o[i])}function u(t,e){var i=new d(e);if(i.push(t,!0),i.err)throw i.msg||o[i.err];return i.result}d.prototype.push=function(t,e){var i,o,l,h,d,u=this.strm,f=this.options.chunkSize,p=this.options.dictionary,g=!1;if(this.ended)return!1;o=e===~~e?e:!0===e?a.Z_FINISH:a.Z_NO_FLUSH,"string"==typeof t?u.input=n.binstring2buf(t):"[object ArrayBuffer]"===c.call(t)?u.input=new Uint8Array(t):u.input=t,u.next_in=0,u.avail_in=u.input.length;do{if(0===u.avail_out&&(u.output=new s.Buf8(f),u.next_out=0,u.avail_out=f),(i=r.inflate(u,a.Z_NO_FLUSH))===a.Z_NEED_DICT&&p&&(i=r.inflateSetDictionary(this.strm,p)),i===a.Z_BUF_ERROR&&!0===g&&(i=a.Z_OK,g=!1),i!==a.Z_STREAM_END&&i!==a.Z_OK)return this.onEnd(i),this.ended=!0,!1;u.next_out&&(0!==u.avail_out&&i!==a.Z_STREAM_END&&(0!==u.avail_in||o!==a.Z_FINISH&&o!==a.Z_SYNC_FLUSH)||("string"===this.options.to?(l=n.utf8border(u.output,u.next_out),h=u.next_out-l,d=n.buf2string(u.output,l),u.next_out=h,u.avail_out=f-h,h&&s.arraySet(u.output,u.output,l,h,0),this.onData(d)):this.onData(s.shrinkBuf(u.output,u.next_out)))),0===u.avail_in&&0===u.avail_out&&(g=!0)}while((u.avail_in>0||0===u.avail_out)&&i!==a.Z_STREAM_END);return i===a.Z_STREAM_END&&(o=a.Z_FINISH),o===a.Z_FINISH?(i=r.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===a.Z_OK):o!==a.Z_SYNC_FLUSH||(this.onEnd(a.Z_OK),u.avail_out=0,!0)},d.prototype.onData=function(t){this.chunks.push(t)},d.prototype.onEnd=function(t){t===a.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Inflate=d,e.inflate=u,e.inflateRaw=function(t,e){return(e=e||{}).raw=!0,u(t,e)},e.ungzip=u},981:(t,e)=>{"use strict";var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var s in i)r(i,s)&&(t[s]=i[s])}}return t},e.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var s={arraySet:function(t,e,i,r,s){if(e.subarray&&t.subarray)t.set(e.subarray(i,i+r),s);else for(var n=0;n{"use strict";var r=i(981),s=!0,n=!0;try{String.fromCharCode.apply(null,[0])}catch(t){s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){n=!1}for(var a=new r.Buf8(256),o=0;o<256;o++)a[o]=o>=252?6:o>=248?5:o>=240?4:o>=224?3:o>=192?2:1;function l(t,e){if(e<65534&&(t.subarray&&n||!t.subarray&&s))return String.fromCharCode.apply(null,r.shrinkBuf(t,e));for(var i="",a=0;a>>6,e[a++]=128|63&i):i<65536?(e[a++]=224|i>>>12,e[a++]=128|i>>>6&63,e[a++]=128|63&i):(e[a++]=240|i>>>18,e[a++]=128|i>>>12&63,e[a++]=128|i>>>6&63,e[a++]=128|63&i);return e},e.buf2binstring=function(t){return l(t,t.length)},e.binstring2buf=function(t){for(var e=new r.Buf8(t.length),i=0,s=e.length;i4)h[r++]=65533,i+=n-1;else{for(s&=2===n?31:3===n?15:7;n>1&&i1?h[r++]=65533:s<65536?h[r++]=s:(s-=65536,h[r++]=55296|s>>10&1023,h[r++]=56320|1023&s)}return l(h,r)},e.utf8border=function(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+a[t[i]]>e?i:e}},701:t=>{"use strict";t.exports=function(t,e,i,r){for(var s=65535&t,n=t>>>16&65535,a=0;0!==i;){i-=a=i>2e3?2e3:i;do{n=n+(s=s+e[r++]|0)|0}while(--a);s%=65521,n%=65521}return s|n<<16}},681:t=>{"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},407:t=>{"use strict";var e=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();t.exports=function(t,i,r,s){var n=e,a=s+r;t^=-1;for(var o=s;o>>8^n[255&(t^i[o])];return~t}},107:(t,e,i)=>{"use strict";var r,s=i(981),n=i(697),a=i(701),o=i(407),l=i(834),h=-2,c=258,d=262,u=103,f=113,p=666;function g(t,e){return t.msg=l[e],e}function m(t){return(t<<1)-(t>4?9:0)}function v(t){for(var e=t.length;--e>=0;)t[e]=0}function _(t){var e=t.state,i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(s.arraySet(t.output,e.pending_buf,e.pending_out,i,t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))}function y(t,e){n._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,_(t.strm)}function b(t,e){t.pending_buf[t.pending++]=e}function x(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function w(t,e){var i,r,s=t.max_chain_length,n=t.strstart,a=t.prev_length,o=t.nice_match,l=t.strstart>t.w_size-d?t.strstart-(t.w_size-d):0,h=t.window,u=t.w_mask,f=t.prev,p=t.strstart+c,g=h[n+a-1],m=h[n+a];t.prev_length>=t.good_match&&(s>>=2),o>t.lookahead&&(o=t.lookahead);do{if(h[(i=e)+a]===m&&h[i+a-1]===g&&h[i]===h[n]&&h[++i]===h[n+1]){n+=2,i++;do{}while(h[++n]===h[++i]&&h[++n]===h[++i]&&h[++n]===h[++i]&&h[++n]===h[++i]&&h[++n]===h[++i]&&h[++n]===h[++i]&&h[++n]===h[++i]&&h[++n]===h[++i]&&na){if(t.match_start=e,a=r,r>=o)break;g=h[n+a-1],m=h[n+a]}}}while((e=f[e&u])>l&&0!=--s);return a<=t.lookahead?a:t.lookahead}function A(t){var e,i,r,n,l,h,c,u,f,p,g=t.w_size;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=g+(g-d)){s.arraySet(t.window,t.window,g,g,0),t.match_start-=g,t.strstart-=g,t.block_start-=g,e=i=t.hash_size;do{r=t.head[--e],t.head[e]=r>=g?r-g:0}while(--i);e=i=g;do{r=t.prev[--e],t.prev[e]=r>=g?r-g:0}while(--i);n+=g}if(0===t.strm.avail_in)break;if(h=t.strm,c=t.window,u=t.strstart+t.lookahead,f=n,p=void 0,(p=h.avail_in)>f&&(p=f),i=0===p?0:(h.avail_in-=p,s.arraySet(c,h.input,h.next_in,p,u),1===h.state.wrap?h.adler=a(h.adler,c,p,u):2===h.state.wrap&&(h.adler=o(h.adler,c,p,u)),h.next_in+=p,h.total_in+=p,p),t.lookahead+=i,t.lookahead+t.insert>=3)for(l=t.strstart-t.insert,t.ins_h=t.window[l],t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<=3)if(r=n._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){s=t.strstart+t.lookahead-3,r=n._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=s&&(t.ins_h=(t.ins_h<15&&(o=2,r-=16),n<1||n>9||8!==i||r<8||r>15||e<0||e>9||a<0||a>4)return g(t,h);8===r&&(r=9);var l=new z;return t.state=l,l.strm=t,l.wrap=o,l.gzhead=null,l.w_bits=r,l.w_size=1<t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(A(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var r=t.block_start+i;if((0===t.strstart||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,y(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-d&&(y(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(y(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(y(t,!1),t.strm.avail_out),1)})),new M(4,4,8,4,C),new M(4,5,16,8,C),new M(4,6,32,32,C),new M(4,4,16,16,S),new M(8,16,32,32,S),new M(8,16,128,128,S),new M(8,32,128,256,S),new M(32,128,258,1024,S),new M(32,258,258,4096,S)],e.deflateInit=function(t,e){return L(t,e,8,15,8,0)},e.deflateInit2=L,e.deflateReset=E,e.deflateResetKeep=T,e.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?h:(t.state.gzhead=e,0):h},e.deflate=function(t,e){var i,s,a,l;if(!t||!t.state||e>5||e<0)return t?g(t,h):h;if(s=t.state,!t.output||!t.input&&0!==t.avail_in||s.status===p&&4!==e)return g(t,0===t.avail_out?-5:h);if(s.strm=t,i=s.last_flush,s.last_flush=e,42===s.status)if(2===s.wrap)t.adler=0,b(s,31),b(s,139),b(s,8),s.gzhead?(b(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),b(s,255&s.gzhead.time),b(s,s.gzhead.time>>8&255),b(s,s.gzhead.time>>16&255),b(s,s.gzhead.time>>24&255),b(s,9===s.level?2:s.strategy>=2||s.level<2?4:0),b(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(b(s,255&s.gzhead.extra.length),b(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(t.adler=o(t.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69):(b(s,0),b(s,0),b(s,0),b(s,0),b(s,0),b(s,9===s.level?2:s.strategy>=2||s.level<2?4:0),b(s,3),s.status=f);else{var d=8+(s.w_bits-8<<4)<<8;d|=(s.strategy>=2||s.level<2?0:s.level<6?1:6===s.level?2:3)<<6,0!==s.strstart&&(d|=32),d+=31-d%31,s.status=f,x(s,d),0!==s.strstart&&(x(s,t.adler>>>16),x(s,65535&t.adler)),t.adler=1}if(69===s.status)if(s.gzhead.extra){for(a=s.pending;s.gzindex<(65535&s.gzhead.extra.length)&&(s.pending!==s.pending_buf_size||(s.gzhead.hcrc&&s.pending>a&&(t.adler=o(t.adler,s.pending_buf,s.pending-a,a)),_(t),a=s.pending,s.pending!==s.pending_buf_size));)b(s,255&s.gzhead.extra[s.gzindex]),s.gzindex++;s.gzhead.hcrc&&s.pending>a&&(t.adler=o(t.adler,s.pending_buf,s.pending-a,a)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=73)}else s.status=73;if(73===s.status)if(s.gzhead.name){a=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>a&&(t.adler=o(t.adler,s.pending_buf,s.pending-a,a)),_(t),a=s.pending,s.pending===s.pending_buf_size)){l=1;break}l=s.gzindexa&&(t.adler=o(t.adler,s.pending_buf,s.pending-a,a)),0===l&&(s.gzindex=0,s.status=91)}else s.status=91;if(91===s.status)if(s.gzhead.comment){a=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>a&&(t.adler=o(t.adler,s.pending_buf,s.pending-a,a)),_(t),a=s.pending,s.pending===s.pending_buf_size)){l=1;break}l=s.gzindexa&&(t.adler=o(t.adler,s.pending_buf,s.pending-a,a)),0===l&&(s.status=u)}else s.status=u;if(s.status===u&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&_(t),s.pending+2<=s.pending_buf_size&&(b(s,255&t.adler),b(s,t.adler>>8&255),t.adler=0,s.status=f)):s.status=f),0!==s.pending){if(_(t),0===t.avail_out)return s.last_flush=-1,0}else if(0===t.avail_in&&m(e)<=m(i)&&4!==e)return g(t,-5);if(s.status===p&&0!==t.avail_in)return g(t,-5);if(0!==t.avail_in||0!==s.lookahead||0!==e&&s.status!==p){var w=2===s.strategy?function(t,e){for(var i;;){if(0===t.lookahead&&(A(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,i=n._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(y(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(y(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(y(t,!1),0===t.strm.avail_out)?1:2}(s,e):3===s.strategy?function(t,e){for(var i,r,s,a,o=t.window;;){if(t.lookahead<=c){if(A(t),t.lookahead<=c&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=o[s=t.strstart-1])===o[++s]&&r===o[++s]&&r===o[++s]){a=t.strstart+c;do{}while(r===o[++s]&&r===o[++s]&&r===o[++s]&&r===o[++s]&&r===o[++s]&&r===o[++s]&&r===o[++s]&&r===o[++s]&&st.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=n._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=n._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(y(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(y(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(y(t,!1),0===t.strm.avail_out)?1:2}(s,e):r[s.level].func(s,e);if(3!==w&&4!==w||(s.status=p),1===w||3===w)return 0===t.avail_out&&(s.last_flush=-1),0;if(2===w&&(1===e?n._tr_align(s):5!==e&&(n._tr_stored_block(s,0,0,!1),3===e&&(v(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),_(t),0===t.avail_out))return s.last_flush=-1,0}return 4!==e?0:s.wrap<=0?1:(2===s.wrap?(b(s,255&t.adler),b(s,t.adler>>8&255),b(s,t.adler>>16&255),b(s,t.adler>>24&255),b(s,255&t.total_in),b(s,t.total_in>>8&255),b(s,t.total_in>>16&255),b(s,t.total_in>>24&255)):(x(s,t.adler>>>16),x(s,65535&t.adler)),_(t),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?0:1)},e.deflateEnd=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&e!==u&&e!==f&&e!==p?g(t,h):(t.state=null,e===f?g(t,-3):0):h},e.deflateSetDictionary=function(t,e){var i,r,n,o,l,c,d,u,f=e.length;if(!t||!t.state)return h;if(2===(o=(i=t.state).wrap)||1===o&&42!==i.status||i.lookahead)return h;for(1===o&&(t.adler=a(t.adler,e,f,0)),i.wrap=0,f>=i.w_size&&(0===o&&(v(i.head),i.strstart=0,i.block_start=0,i.insert=0),u=new s.Buf8(i.w_size),s.arraySet(u,e,f-i.w_size,i.w_size,0),e=u,f=i.w_size),l=t.avail_in,c=t.next_in,d=t.input,t.avail_in=f,t.next_in=0,t.input=e,A(i);i.lookahead>=3;){r=i.strstart,n=i.lookahead-2;do{i.ins_h=(i.ins_h<{"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},165:t=>{"use strict";t.exports=function(t,e){var i,r,s,n,a,o,l,h,c,d,u,f,p,g,m,v,_,y,b,x,w,A,C,S,M;i=t.state,r=t.next_in,S=t.input,s=r+(t.avail_in-5),n=t.next_out,M=t.output,a=n-(e-t.avail_out),o=n+(t.avail_out-257),l=i.dmax,h=i.wsize,c=i.whave,d=i.wnext,u=i.window,f=i.hold,p=i.bits,g=i.lencode,m=i.distcode,v=(1<>>=b=y>>>24,p-=b,0===(b=y>>>16&255))M[n++]=65535&y;else{if(!(16&b)){if(64&b){if(32&b){i.mode=12;break t}t.msg="invalid literal/length code",i.mode=30;break t}y=g[(65535&y)+(f&(1<>>=b,p-=b),p<15&&(f+=S[r++]<>>=b=y>>>24,p-=b,16&(b=y>>>16&255)){if(w=65535&y,p<(b&=15)&&(f+=S[r++]<l){t.msg="invalid distance too far back",i.mode=30;break t}if(f>>>=b,p-=b,w>(b=n-a)){if((b=w-b)>c&&i.sane){t.msg="invalid distance too far back",i.mode=30;break t}if(A=0,C=u,0===d){if(A+=h-b,b2;)M[n++]=C[A++],M[n++]=C[A++],M[n++]=C[A++],x-=3;x&&(M[n++]=C[A++],x>1&&(M[n++]=C[A++]))}else{A=n-w;do{M[n++]=M[A++],M[n++]=M[A++],M[n++]=M[A++],x-=3}while(x>2);x&&(M[n++]=M[A++],x>1&&(M[n++]=M[A++]))}break}if(64&b){t.msg="invalid distance code",i.mode=30;break t}y=m[(65535&y)+(f&(1<>3,f&=(1<<(p-=x<<3))-1,t.next_in=r,t.next_out=n,t.avail_in=r{"use strict";var r=i(981),s=i(701),n=i(407),a=i(165),o=i(358),l=-2,h=12,c=30;function d(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new r.Buf32(852),e.distcode=e.distdyn=new r.Buf32(592),e.sane=1,e.back=-1,0):l}function p(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,f(t)):l}function g(t,e){var i,r;return t&&t.state?(r=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?l:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=i,r.wbits=e,p(t))):l}function m(t,e){var i,r;return t?(r=new u,t.state=r,r.window=null,0!==(i=g(t,e))&&(t.state=null),i):l}var v,_,y=!0;function b(t){if(y){var e;for(v=new r.Buf32(512),_=new r.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(o(1,t.lens,0,288,v,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;o(2,t.lens,0,32,_,0,t.work,{bits:5}),y=!1}t.lencode=v,t.lenbits=9,t.distcode=_,t.distbits=5}function x(t,e,i,s){var n,a=t.state;return null===a.window&&(a.wsize=1<=a.wsize?(r.arraySet(a.window,e,i-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((n=a.wsize-a.wnext)>s&&(n=s),r.arraySet(a.window,e,i-s,n,a.wnext),(s-=n)?(r.arraySet(a.window,e,i-s,s,0),a.wnext=s,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,i.check=n(i.check,U,2,0),_=0,y=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&_)<<8)+(_>>8))%31){t.msg="incorrect header check",i.mode=c;break}if(8!=(15&_)){t.msg="unknown compression method",i.mode=c;break}if(y-=4,O=8+(15&(_>>>=4)),0===i.wbits)i.wbits=O;else if(O>i.wbits){t.msg="invalid window size",i.mode=c;break}i.dmax=1<>8&1),512&i.flags&&(U[0]=255&_,U[1]=_>>>8&255,i.check=n(i.check,U,2,0)),_=0,y=0,i.mode=3;case 3:for(;y<32;){if(0===m)break t;m--,_+=u[p++]<>>8&255,U[2]=_>>>16&255,U[3]=_>>>24&255,i.check=n(i.check,U,4,0)),_=0,y=0,i.mode=4;case 4:for(;y<16;){if(0===m)break t;m--,_+=u[p++]<>8),512&i.flags&&(U[0]=255&_,U[1]=_>>>8&255,i.check=n(i.check,U,2,0)),_=0,y=0,i.mode=5;case 5:if(1024&i.flags){for(;y<16;){if(0===m)break t;m--,_+=u[p++]<>>8&255,i.check=n(i.check,U,2,0)),_=0,y=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((C=i.length)>m&&(C=m),C&&(i.head&&(O=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),r.arraySet(i.head.extra,u,p,C,O)),512&i.flags&&(i.check=n(i.check,u,C,p)),m-=C,p+=C,i.length-=C),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===m)break t;C=0;do{O=u[p+C++],i.head&&O&&i.length<65536&&(i.head.name+=String.fromCharCode(O))}while(O&&C>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=h;break;case 10:for(;y<32;){if(0===m)break t;m--,_+=u[p++]<>>=7&y,y-=7&y,i.mode=27;break}for(;y<3;){if(0===m)break t;m--,_+=u[p++]<>>=1)){case 0:i.mode=14;break;case 1:if(b(i),i.mode=20,6===e){_>>>=2,y-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=c}_>>>=2,y-=2;break;case 14:for(_>>>=7&y,y-=7&y;y<32;){if(0===m)break t;m--,_+=u[p++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=c;break}if(i.length=65535&_,_=0,y=0,i.mode=15,6===e)break t;case 15:i.mode=16;case 16:if(C=i.length){if(C>m&&(C=m),C>v&&(C=v),0===C)break t;r.arraySet(f,u,p,C,g),m-=C,p+=C,v-=C,g+=C,i.length-=C;break}i.mode=h;break;case 17:for(;y<14;){if(0===m)break t;m--,_+=u[p++]<>>=5,y-=5,i.ndist=1+(31&_),_>>>=5,y-=5,i.ncode=4+(15&_),_>>>=4,y-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=c;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,y-=3}for(;i.have<19;)i.lens[B[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,k={bits:i.lenbits},D=o(0,i.lens,0,19,i.lencode,0,i.work,k),i.lenbits=k.bits,D){t.msg="invalid code lengths set",i.mode=c;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,E=65535&P,!((z=P>>>24)<=y);){if(0===m)break t;m--,_+=u[p++]<>>=z,y-=z,i.lens[i.have++]=E;else{if(16===E){for(R=z+2;y>>=z,y-=z,0===i.have){t.msg="invalid bit length repeat",i.mode=c;break}O=i.lens[i.have-1],C=3+(3&_),_>>>=2,y-=2}else if(17===E){for(R=z+3;y>>=z)),_>>>=3,y-=3}else{for(R=z+7;y>>=z)),_>>>=7,y-=7}if(i.have+C>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=c;break}for(;C--;)i.lens[i.have++]=O}}if(i.mode===c)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=c;break}if(i.lenbits=9,k={bits:i.lenbits},D=o(1,i.lens,0,i.nlen,i.lencode,0,i.work,k),i.lenbits=k.bits,D){t.msg="invalid literal/lengths set",i.mode=c;break}if(i.distbits=6,i.distcode=i.distdyn,k={bits:i.distbits},D=o(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,k),i.distbits=k.bits,D){t.msg="invalid distances set",i.mode=c;break}if(i.mode=20,6===e)break t;case 20:i.mode=21;case 21:if(m>=6&&v>=258){t.next_out=g,t.avail_out=v,t.next_in=p,t.avail_in=m,i.hold=_,i.bits=y,a(t,A),g=t.next_out,f=t.output,v=t.avail_out,p=t.next_in,u=t.input,m=t.avail_in,_=i.hold,y=i.bits,i.mode===h&&(i.back=-1);break}for(i.back=0;T=(P=i.lencode[_&(1<>>16&255,E=65535&P,!((z=P>>>24)<=y);){if(0===m)break t;m--,_+=u[p++]<>L)])>>>16&255,E=65535&P,!(L+(z=P>>>24)<=y);){if(0===m)break t;m--,_+=u[p++]<>>=L,y-=L,i.back+=L}if(_>>>=z,y-=z,i.back+=z,i.length=E,0===T){i.mode=26;break}if(32&T){i.back=-1,i.mode=h;break}if(64&T){t.msg="invalid literal/length code",i.mode=c;break}i.extra=15&T,i.mode=22;case 22:if(i.extra){for(R=i.extra;y>>=i.extra,y-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;T=(P=i.distcode[_&(1<>>16&255,E=65535&P,!((z=P>>>24)<=y);){if(0===m)break t;m--,_+=u[p++]<>L)])>>>16&255,E=65535&P,!(L+(z=P>>>24)<=y);){if(0===m)break t;m--,_+=u[p++]<>>=L,y-=L,i.back+=L}if(_>>>=z,y-=z,i.back+=z,64&T){t.msg="invalid distance code",i.mode=c;break}i.offset=E,i.extra=15&T,i.mode=24;case 24:if(i.extra){for(R=i.extra;y>>=i.extra,y-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=c;break}i.mode=25;case 25:if(0===v)break t;if(C=A-v,i.offset>C){if((C=i.offset-C)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=c;break}C>i.wnext?(C-=i.wnext,S=i.wsize-C):S=i.wnext-C,C>i.length&&(C=i.length),M=i.window}else M=f,S=g-i.offset,C=i.length;C>v&&(C=v),v-=C,i.length-=C;do{f[g++]=M[S++]}while(--C);0===i.length&&(i.mode=21);break;case 26:if(0===v)break t;f[g++]=i.length,v--,i.mode=21;break;case 27:if(i.wrap){for(;y<32;){if(0===m)break t;m--,_|=u[p++]<{"use strict";var r=i(981),s=15,n=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],o=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],l=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(t,e,i,h,c,d,u,f){var p,g,m,v,_,y,b,x,w,A=f.bits,C=0,S=0,M=0,z=0,T=0,E=0,L=0,F=0,I=0,O=0,D=null,k=0,R=new r.Buf16(16),P=new r.Buf16(16),U=null,B=0;for(C=0;C<=s;C++)R[C]=0;for(S=0;S=1&&0===R[z];z--);if(T>z&&(T=z),0===z)return c[d++]=20971520,c[d++]=20971520,f.bits=1,0;for(M=1;M0&&(0===t||1!==z))return-1;for(P[1]=0,C=1;C852||2===t&&I>592)return 1;for(;;){b=C-L,u[S]y?(x=U[B+u[S]],w=D[k+u[S]]):(x=96,w=0),p=1<>L)+(g-=p)]=b<<24|x<<16|w}while(0!==g);for(p=1<>=1;if(0!==p?(O&=p-1,O+=p):O=0,S++,0==--R[C]){if(C===z)break;C=e[i+u[S]]}if(C>T&&(O&v)!==m){for(0===L&&(L=T),_+=M,F=1<<(E=C-L);E+L852||2===t&&I>592)return 1;c[m=O&v]=T<<24|E<<16|_-d}}return 0!==O&&(c[_+O]=C-L<<24|64<<16),f.bits=T,0}},834:t=>{"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},697:(t,e,i)=>{"use strict";var r=i(981);function s(t){for(var e=t.length;--e>=0;)t[e]=0}var n=256,a=286,o=30,l=15,h=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],c=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],u=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],f=new Array(576);s(f);var p=new Array(60);s(p);var g=new Array(512);s(g);var m=new Array(256);s(m);var v=new Array(29);s(v);var _,y,b,x=new Array(o);function w(t,e,i,r,s){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=r,this.max_length=s,this.has_stree=t&&t.length}function A(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function C(t){return t<256?g[t]:g[256+(t>>>7)]}function S(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function M(t,e,i){t.bi_valid>16-i?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<>>=1,i<<=1}while(--e>0);return i>>>1}function E(t,e,i){var r,s,n=new Array(16),a=0;for(r=1;r<=l;r++)n[r]=a=a+i[r-1]<<1;for(s=0;s<=e;s++){var o=t[2*s+1];0!==o&&(t[2*s]=T(n[o]++,o))}}function L(t){var e;for(e=0;e8?S(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function I(t,e,i,r){var s=2*e,n=2*i;return t[s]>1;i>=1;i--)O(t,n,i);s=h;do{i=t.heap[1],t.heap[1]=t.heap[t.heap_len--],O(t,n,1),r=t.heap[1],t.heap[--t.heap_max]=i,t.heap[--t.heap_max]=r,n[2*s]=n[2*i]+n[2*r],t.depth[s]=(t.depth[i]>=t.depth[r]?t.depth[i]:t.depth[r])+1,n[2*i+1]=n[2*r+1]=s,t.heap[1]=s++,O(t,n,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var i,r,s,n,a,o,h=e.dyn_tree,c=e.max_code,d=e.stat_desc.static_tree,u=e.stat_desc.has_stree,f=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,g=e.stat_desc.max_length,m=0;for(n=0;n<=l;n++)t.bl_count[n]=0;for(h[2*t.heap[t.heap_max]+1]=0,i=t.heap_max+1;i<573;i++)(n=h[2*h[2*(r=t.heap[i])+1]+1]+1)>g&&(n=g,m++),h[2*r+1]=n,r>c||(t.bl_count[n]++,a=0,r>=p&&(a=f[r-p]),o=h[2*r],t.opt_len+=o*(n+a),u&&(t.static_len+=o*(d[2*r+1]+a)));if(0!==m){do{for(n=g-1;0===t.bl_count[n];)n--;t.bl_count[n]--,t.bl_count[n+1]+=2,t.bl_count[g]--,m-=2}while(m>0);for(n=g;0!==n;n--)for(r=t.bl_count[n];0!==r;)(s=t.heap[--i])>c||(h[2*s+1]!==n&&(t.opt_len+=(n-h[2*s+1])*h[2*s],h[2*s+1]=n),r--)}}(t,e),E(n,c,t.bl_count)}function R(t,e,i){var r,s,n=-1,a=e[1],o=0,l=7,h=4;for(0===a&&(l=138,h=3),e[2*(i+1)+1]=65535,r=0;r<=i;r++)s=a,a=e[2*(r+1)+1],++o>=7;r0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e=3&&0===t.bl_tree[2*u[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),s=t.opt_len+3+7>>>3,(a=t.static_len+3+7>>>3)<=s&&(s=a)):s=a=i+5,i+4<=s&&-1!==e?B(t,e,i,r):4===t.strategy||a===s?(M(t,2+(r?1:0),3),D(t,f,p)):(M(t,4+(r?1:0),3),function(t,e,i,r){var s;for(M(t,e-257,5),M(t,i-1,5),M(t,r-4,4),s=0;s>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(m[i]+n+1)]++,t.dyn_dtree[2*C(e)]++),t.last_lit===t.lit_bufsize-1},e._tr_align=function(t){M(t,2,3),z(t,256,f),function(t){16===t.bi_valid?(S(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},746:t=>{"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},185:()=>{$3Dmol.workerString=function(){self.onmessage=function(t){var e=t.data,i=e.type;if(i<0)self.atomData=e.atoms,self.volume=e.volume,self.ps=new ProteinSurface;else{var r=self.ps;r.initparm(e.expandedExtent,1!=i,self.volume),r.fillvoxels(self.atomData,e.extendedAtoms),r.buildboundary(),4!==i&&2!==i||(r.fastdistancemap(),r.boundingatom(!1),r.fillvoxelswaals(self.atomData,e.extendedAtoms)),r.marchingcube(i);var s=r.getFacesAndVertices(e.atomsToShow);self.postMessage(s)}}}.toString().replace(/(^.*?\{|\}$)/g,""),$3Dmol.workerString+=";\nfunction _classCallCheck() {};",$3Dmol.workerString+=";\n"+$3Dmol.Vector3.toString(),$3Dmol.workerString+=";\n"+$3Dmol.MarchingCubeInitializer.toString()+";\n\n",$3Dmol.workerString+=";\n"+$3Dmol.PointGrid.toString()+";\n",$3Dmol.workerString+=";\nvar ProteinSurface = "+$3Dmol.ProteinSurface.toString()+";\n",$3Dmol.SurfaceWorker=window.URL?window.URL.createObjectURL(new Blob([$3Dmol.workerString],{type:"text/javascript"})):void 0},307:t=>{"object"==typeof t.exports&&(t.exports=window.$3Dmol)},471:function(t,e){!function(t){"use strict";function e(t,e,i){for(var r=(t.byteLength,0),s=i.length;s>r;r++){var n=i.charCodeAt(r);if(128>n)t.setUint8(e++,n>>>0&127);else if(2048>n)t.setUint8(e++,n>>>6&31|192),t.setUint8(e++,n>>>0&63|128);else if(65536>n)t.setUint8(e++,n>>>12&15|224),t.setUint8(e++,n>>>6&63|128),t.setUint8(e++,n>>>0&63|128);else{if(!(1114112>n))throw new Error("bad codepoint "+n);t.setUint8(e++,n>>>18&7|240),t.setUint8(e++,n>>>12&63|128),t.setUint8(e++,n>>>6&63|128),t.setUint8(e++,n>>>0&63|128)}}}function i(t){for(var e=0,i=0,r=t.length;r>i;i++){var s=t.charCodeAt(i);if(128>s)e+=1;else if(2048>s)e+=2;else if(65536>s)e+=3;else{if(!(1114112>s))throw new Error("bad codepoint "+s);e+=4}}return e}function r(t,s,n){var a=typeof t;if("string"===a){if(32>(o=i(t)))return s.setUint8(n,160|o),e(s,n+1,t),1+o;if(256>o)return s.setUint8(n,217),s.setUint8(n+1,o),e(s,n+2,t),2+o;if(65536>o)return s.setUint8(n,218),s.setUint16(n+1,o),e(s,n+3,t),3+o;if(4294967296>o)return s.setUint8(n,219),s.setUint32(n+1,o),e(s,n+5,t),5+o}if(t instanceof Uint8Array){var o=t.byteLength,l=new Uint8Array(s.buffer);if(256>o)return s.setUint8(n,196),s.setUint8(n+1,o),l.set(t,n+2),2+o;if(65536>o)return s.setUint8(n,197),s.setUint16(n+1,o),l.set(t,n+3),3+o;if(4294967296>o)return s.setUint8(n,198),s.setUint32(n+1,o),l.set(t,n+5),5+o}if("number"===a){if(!isFinite(t))throw new Error("Number not finite: "+t);if(Math.floor(t)!==t)return s.setUint8(n,203),s.setFloat64(n+1,t),9;if(t>=0){if(128>t)return s.setUint8(n,t),1;if(256>t)return s.setUint8(n,204),s.setUint8(n+1,t),2;if(65536>t)return s.setUint8(n,205),s.setUint16(n+1,t),3;if(4294967296>t)return s.setUint8(n,206),s.setUint32(n+1,t),5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return s.setInt8(n,t),1;if(t>=-128)return s.setUint8(n,208),s.setInt8(n+1,t),2;if(t>=-32768)return s.setUint8(n,209),s.setInt16(n+1,t),3;if(t>=-2147483648)return s.setUint8(n,210),s.setInt32(n+1,t),5;throw new Error("Number too small -0x"+(-t).toString(16).substr(1))}if(null===t)return s.setUint8(n,192),1;if("boolean"===a)return s.setUint8(n,t?195:194),1;if("object"===a){var h=0,c=Array.isArray(t);if(c)o=t.length;else{var d=Object.keys(t);o=d.length}if(16>o?(s.setUint8(n,o|(c?144:128)),h=1):65536>o?(s.setUint8(n,c?220:222),s.setUint16(n+1,o),h=3):4294967296>o&&(s.setUint8(n,c?221:223),s.setUint32(n+1,o),h=5),c)for(var u=0;o>u;u++)h+=r(t[u],s,n+h);else for(u=0;o>u;u++){var f=d[u];h+=r(f,s,n+h),h+=r(t[f],s,n+h)}return h}throw new Error("Unknown type "+a)}function s(t){var e=typeof t;if("string"===e){if(32>(r=i(t)))return 1+r;if(256>r)return 2+r;if(65536>r)return 3+r;if(4294967296>r)return 5+r}if(t instanceof Uint8Array){if(256>(r=t.byteLength))return 2+r;if(65536>r)return 3+r;if(4294967296>r)return 5+r}if("number"===e){if(Math.floor(t)!==t)return 9;if(t>=0){if(128>t)return 1;if(256>t)return 2;if(65536>t)return 3;if(4294967296>t)return 5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return 1;if(t>=-128)return 2;if(t>=-32768)return 3;if(t>=-2147483648)return 5;throw new Error("Number too small -0x"+t.toString(16).substr(1))}if("boolean"===e||null===t)return 1;if("object"===e){var r,n=0;if(Array.isArray(t)){r=t.length;for(var a=0;r>a;a++)n+=s(t[a])}else{var o=Object.keys(t);for(r=o.length,a=0;r>a;a++){var l=o[a];n+=s(l)+s(t[l])}}if(16>r)return 1+n;if(65536>r)return 3+n;if(4294967296>r)return 5+n;throw new Error("Array or object too long 0x"+r.toString(16))}throw new Error("Unknown type "+e)}function n(t){var e=new ArrayBuffer(s(t));return r(t,new DataView(e),0),new Uint8Array(e)}function a(t,e,i){return e?new t(e.buffer,e.byteOffset,e.byteLength/(i||1)):void 0}function o(t){return a(DataView,t)}function l(t){return a(Uint8Array,t)}function h(t){return a(Int8Array,t)}function c(t){return a(Int32Array,t,4)}function d(t){return a(Float32Array,t,4)}function u(t,e){var i=t.length/2;e||(e=new Int16Array(i));for(var r=0,s=0;i>r;++r,s+=2)e[r]=t[s]<<8^t[s+1];return e}function f(t,e){var i=t.length;e||(e=new Uint8Array(2*i));for(var r=o(e),s=0;i>s;++s)r.setInt16(2*s,t[s]);return l(e)}function p(t,e){var i=t.length/4;e||(e=new Int32Array(i));for(var r=0,s=0;i>r;++r,s+=4)e[r]=t[s]<<24^t[s+1]<<16^t[s+2]<<8^t[s+3];return e}function g(t,e){var i=t.length;e||(e=new Uint8Array(4*i));for(var r=o(e),s=0;i>s;++s)r.setInt32(4*s,t[s]);return l(e)}function m(t,e){var i=t.length;e||(e=new Float32Array(i/4));for(var r=o(e),s=o(t),n=0,a=0,l=i/4;l>n;++n,a+=4)r.setFloat32(a,s.getFloat32(a),!0);return e}function v(t,e,i){var r=t.length,s=1/e;i||(i=new Float32Array(r));for(var n=0;r>n;++n)i[n]=t[n]*s;return i}function _(t,e,i){var r=t.length;i||(i=new Int32Array(r));for(var s=0;r>s;++s)i[s]=Math.round(t[s]*e);return i}function y(t,e){var i,r;if(!e){var s=0;for(i=0,r=t.length;r>i;i+=2)s+=t[i+1];e=new t.constructor(s)}var n=0;for(i=0,r=t.length;r>i;i+=2)for(var a=t[i],o=t[i+1],l=0;o>l;++l)e[n]=a,++n;return e}function b(t){if(0===t.length)return new Int32Array;var e,i,r=2;for(e=1,i=t.length;i>e;++e)t[e-1]!==t[e]&&(r+=2);var s=new Int32Array(r),n=0,a=1;for(e=1,i=t.length;i>e;++e)t[e-1]!==t[e]?(s[n]=t[e-1],s[n+1]=a,a=1,n+=2):++a;return s[n]=t[t.length-1],s[n+1]=a,s}function x(t,e){var i=t.length;e||(e=new t.constructor(i)),i&&(e[0]=t[0]);for(var r=1;i>r;++r)e[r]=t[r]+e[r-1];return e}function w(t,e){var i=t.length;e||(e=new t.constructor(i)),e[0]=t[0];for(var r=1;i>r;++r)e[r]=t[r]-t[r-1];return e}function A(t,e){var i,r,s=t instanceof Int8Array?127:32767,n=-s-1,a=t.length;if(!e){var o=0;for(i=0;a>i;++i)t[i]n&&++o;e=new Int32Array(o)}for(i=0,r=0;a>i;){for(var l=0;t[i]===s||t[i]===n;)l+=t[i],++i;l+=t[i],++i,e[r]=l,++r}return e}function C(t,e){var i,r=e?127:32767,s=-r-1,n=t.length,a=0;for(i=0;n>i;++i)0===(h=t[i])?++a:h>0?(a+=Math.ceil(h/r),h%r==0&&(a+=1)):(a+=Math.ceil(h/s),h%s==0&&(a+=1));var o=e?new Int8Array(a):new Int16Array(a),l=0;for(i=0;n>i;++i){var h;if((h=t[i])>=0)for(;h>=r;)o[l]=r,++l,h-=r;else for(;s>=h;)o[l]=s,++l,h-=s;o[l]=h,++l}return o}function S(t,e){return x(y(t),e)}function M(t){return b(w(t))}function z(t,e,i){return v(y(t,c(i)),e,i)}function T(t,e){return b(_(t,e))}function E(t,e,i){return v(x(t,c(i)),e,i)}function L(t,e,i){return w(_(t,e),i)}function F(t,e,i){return v(A(t,c(i)),e,i)}function I(t,e,i){var r=A(t,c(i));return E(r,e,d(r))}function O(t,e,i){return C(L(t,e),i)}function D(t){var e=o(t),i=e.getInt32(0),r=e.getInt32(4),s=t.subarray(8,12);return[i,t=t.subarray(12),r,s]}function k(t,e,i,r){var s=new ArrayBuffer(12+r.byteLength),n=new Uint8Array(s),a=new DataView(s);return a.setInt32(0,t),a.setInt32(4,e),i&&n.set(i,8),n.set(r,12),n}function R(t){return k(2,t.length,void 0,l(t))}function P(t){return k(4,t.length,void 0,g(t))}function U(t,e){return k(5,t.length/e,g([e]),l(t))}function B(t){return k(6,t.length,void 0,g(b(t)))}function N(t){return k(8,t.length,void 0,g(M(t)))}function G(t,e){return k(9,t.length,g([e]),g(T(t,e)))}function V(t,e){return k(10,t.length,g([e]),f(O(t,e)))}function j(t){var e={};return tt.forEach((function(i){void 0!==t[i]&&(e[i]=t[i])})),t.bondAtomList&&(e.bondAtomList=P(t.bondAtomList)),t.bondOrderList&&(e.bondOrderList=R(t.bondOrderList)),e.xCoordList=V(t.xCoordList,1e3),e.yCoordList=V(t.yCoordList,1e3),e.zCoordList=V(t.zCoordList,1e3),t.bFactorList&&(e.bFactorList=V(t.bFactorList,100)),t.atomIdList&&(e.atomIdList=N(t.atomIdList)),t.altLocList&&(e.altLocList=B(t.altLocList)),t.occupancyList&&(e.occupancyList=G(t.occupancyList,100)),e.groupIdList=N(t.groupIdList),e.groupTypeList=P(t.groupTypeList),t.secStructList&&(e.secStructList=R(t.secStructList)),t.insCodeList&&(e.insCodeList=B(t.insCodeList)),t.sequenceIndexList&&(e.sequenceIndexList=N(t.sequenceIndexList)),e.chainIdList=U(t.chainIdList,4),t.chainNameList&&(e.chainNameList=U(t.chainNameList,4)),e}function H(t){function e(t){for(var e={},i=0;t>i;i++)e[n()]=n();return e}function i(e){var i=t.subarray(a,a+e);return a+=e,i}function r(e){var i=t.subarray(a,a+e);a+=e;var r=65535;if(e>r){for(var s=[],n=0;ni;i++)e[i]=n();return e}function n(){var n,l,h=t[a];if(!(128&h))return a++,h;if(128==(240&h))return a++,e(l=15&h);if(144==(240&h))return a++,s(l=15&h);if(160==(224&h))return a++,r(l=31&h);if(!(224&~h))return n=o.getInt8(a),a++,n;switch(h){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return l=o.getUint8(a+1),a+=2,i(l);case 197:return l=o.getUint16(a+1),a+=3,i(l);case 198:return l=o.getUint32(a+1),a+=5,i(l);case 202:return n=o.getFloat32(a+1),a+=5,n;case 203:return n=o.getFloat64(a+1),a+=9,n;case 204:return n=t[a+1],a+=2,n;case 205:return n=o.getUint16(a+1),a+=3,n;case 206:return n=o.getUint32(a+1),a+=5,n;case 208:return n=o.getInt8(a+1),a+=2,n;case 209:return n=o.getInt16(a+1),a+=3,n;case 210:return n=o.getInt32(a+1),a+=5,n;case 217:return l=o.getUint8(a+1),a+=2,r(l);case 218:return l=o.getUint16(a+1),a+=3,r(l);case 219:return l=o.getUint32(a+1),a+=5,r(l);case 220:return l=o.getUint16(a+1),a+=3,s(l);case 221:return l=o.getUint32(a+1),a+=5,s(l);case 222:return l=o.getUint16(a+1),a+=3,e(l);case 223:return l=o.getUint32(a+1),a+=5,e(l)}throw new Error("Unknown type 0x"+h.toString(16))}var a=0,o=new DataView(t.buffer);return n()}function W(t,e,i,r){switch(t){case 1:return m(e);case 2:return h(e);case 3:return u(e);case 4:return p(e);case 5:return l(e);case 6:return y(p(e),new Uint8Array(i));case 7:return y(p(e));case 8:return S(p(e));case 9:return z(p(e),p(r)[0]);case 10:return I(u(e),p(r)[0]);case 11:return v(u(e),p(r)[0]);case 12:return F(u(e),p(r)[0]);case 13:return F(h(e),p(r)[0]);case 14:return A(u(e));case 15:return A(h(e))}}function q(t,e){var i=(e=e||{}).ignoreFields,r={};return it.forEach((function(e){var s=!!i&&-1!==i.indexOf(e),n=t[e];s||void 0===n||(n instanceof Uint8Array?r[e]=W.apply(null,D(n)):r[e]=n)})),r}function Y(t){return String.fromCharCode.apply(null,t).replace(/\0/g,"")}function Z(t,e,i){var r,s,n,a,o,l,h=(i=i||{}).firstModelOnly,c=e.onModel,d=e.onChain,u=e.onGroup,f=e.onAtom,p=e.onBond,g=0,m=0,v=0,_=0,y=0,b=-1,x=t.chainNameList,w=t.secStructList,A=t.insCodeList,C=t.sequenceIndexList,S=t.atomIdList,M=t.bFactorList,z=t.altLocList,T=t.occupancyList,E=t.bondAtomList,L=t.bondOrderList;for(r=0,s=t.chainsPerModel.length;s>r&&!(h&&g>0);++r){var F=t.chainsPerModel[g];for(c&&c({chainCount:F,modelIndex:g}),n=0;F>n;++n){var I=t.groupsPerChain[m];if(d){var O=Y(t.chainIdList.subarray(4*m,4*m+4)),D=null;x&&(D=Y(x.subarray(4*m,4*m+4))),d({groupCount:I,chainIndex:m,modelIndex:g,chainId:O,chainName:D})}for(a=0;I>a;++a){var k=t.groupList[t.groupTypeList[v]],R=k.atomNameList.length;if(u){var P=null;w&&(P=w[v]);var U=null;t.insCodeList&&(U=String.fromCharCode(A[v]));var B=null;C&&(B=C[v]),u({atomCount:R,groupIndex:v,chainIndex:m,modelIndex:g,groupId:t.groupIdList[v],groupType:t.groupTypeList[v],groupName:k.groupName,singleLetterCode:k.singleLetterCode,chemCompType:k.chemCompType,secStruct:P,insCode:U,sequenceIndex:B})}for(o=0;R>o;++o){if(f){var N=null;S&&(N=S[_]);var G=null;M&&(G=M[_]);var V=null;z&&(V=String.fromCharCode(z[_]));var j=null;T&&(j=T[_]),f({atomIndex:_,groupIndex:v,chainIndex:m,modelIndex:g,atomId:N,element:k.elementList[o],atomName:k.atomNameList[o],formalCharge:k.formalChargeList[o],xCoord:t.xCoordList[_],yCoord:t.yCoordList[_],zCoord:t.zCoordList[_],bFactor:G,altLoc:V,occupancy:j})}_+=1}if(p){var H=k.bondAtomList;for(o=0,l=k.bondOrderList.length;l>o;++o)p({atomIndex1:_-R+H[2*o],atomIndex2:_-R+H[2*o+1],bondOrder:k.bondOrderList[o]})}v+=1}m+=1}if(y=b+1,b=_-1,p&&E)for(o=0,l=E.length;l>o;o+=2){var W=E[o],q=E[o+1];(W>=y&&b>=W||q>=y&&b>=q)&&p({atomIndex1:W,atomIndex2:q,bondOrder:L?L[o/2]:null})}g+=1}}function X(t){return n(j(t))}function K(t,e){return t instanceof ArrayBuffer&&(t=new Uint8Array(t)),q(t instanceof Uint8Array?H(t):t,e)}function Q(t,e,i,r){function s(){try{var t=K(n.response);i(t)}catch(t){r(t)}}var n=new XMLHttpRequest;n.addEventListener("load",s,!0),n.addEventListener("error",r,!0),n.responseType="arraybuffer",n.open("GET",e+t.toUpperCase()),n.send()}function $(t,e,i){Q(t,nt,e,i)}function J(t,e,i){Q(t,at,e,i)}var tt=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],et=["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"],it=tt.concat(et),rt="v1.0.1",st="//mmtf.rcsb.org/v1.0/",nt=st+"full/",at=st+"reduced/";t.encode=X,t.decode=K,t.traverse=Z,t.fetch=$,t.fetchReduced=J,t.version=rt,t.fetchUrl=nt,t.fetchReducedUrl=at,t.encodeMsgpack=n,t.encodeMmtf=j,t.decodeMsgpack=H,t.decodeMmtf=q}(e)},75:(t,e,i)=>{"use strict";i.r(e),i.d(e,{Deflate:()=>yi,Inflate:()=>Ai,constants:()=>zi,default:()=>Ti,deflate:()=>bi,deflateRaw:()=>xi,gzip:()=>wi,inflate:()=>Ci,inflateRaw:()=>Si,ungzip:()=>Mi});function r(t){let e=t.length;for(;--e>=0;)t[e]=0}const s=256,n=286,a=30,o=15,l=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),h=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),c=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),d=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=new Array(576);r(u);const f=new Array(60);r(f);const p=new Array(512);r(p);const g=new Array(256);r(g);const m=new Array(29);r(m);const v=new Array(a);function _(t,e,i,r,s){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=r,this.max_length=s,this.has_stree=t&&t.length}let y,b,x;function w(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}r(v);const A=t=>t<256?p[t]:p[256+(t>>>7)],C=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},S=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<{S(t,i[2*e],i[2*e+1])},z=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},T=(t,e,i)=>{const r=new Array(16);let s,n,a=0;for(s=1;s<=o;s++)a=a+i[s-1]<<1,r[s]=a;for(n=0;n<=e;n++){let e=t[2*n+1];0!==e&&(t[2*n]=z(r[e]++,e))}},E=t=>{let e;for(e=0;e{t.bi_valid>8?C(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},F=(t,e,i,r)=>{const s=2*e,n=2*i;return t[s]{const r=t.heap[i];let s=i<<1;for(;s<=t.heap_len&&(s{let r,n,a,o,c=0;if(0!==t.sym_next)do{r=255&t.pending_buf[t.sym_buf+c++],r+=(255&t.pending_buf[t.sym_buf+c++])<<8,n=t.pending_buf[t.sym_buf+c++],0===r?M(t,n,e):(a=g[n],M(t,a+s+1,e),o=l[a],0!==o&&(n-=m[a],S(t,n,o)),r--,a=A(r),M(t,a,i),o=h[a],0!==o&&(r-=v[a],S(t,r,o)))}while(c{const i=e.dyn_tree,r=e.stat_desc.static_tree,s=e.stat_desc.has_stree,n=e.stat_desc.elems;let a,l,h,c=-1;for(t.heap_len=0,t.heap_max=573,a=0;a>1;a>=1;a--)I(t,i,a);h=n;do{a=t.heap[1],t.heap[1]=t.heap[t.heap_len--],I(t,i,1),l=t.heap[1],t.heap[--t.heap_max]=a,t.heap[--t.heap_max]=l,i[2*h]=i[2*a]+i[2*l],t.depth[h]=(t.depth[a]>=t.depth[l]?t.depth[a]:t.depth[l])+1,i[2*a+1]=i[2*l+1]=h,t.heap[1]=h++,I(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,r=e.max_code,s=e.stat_desc.static_tree,n=e.stat_desc.has_stree,a=e.stat_desc.extra_bits,l=e.stat_desc.extra_base,h=e.stat_desc.max_length;let c,d,u,f,p,g,m=0;for(f=0;f<=o;f++)t.bl_count[f]=0;for(i[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)d=t.heap[c],f=i[2*i[2*d+1]+1]+1,f>h&&(f=h,m++),i[2*d+1]=f,d>r||(t.bl_count[f]++,p=0,d>=l&&(p=a[d-l]),g=i[2*d],t.opt_len+=g*(f+p),n&&(t.static_len+=g*(s[2*d+1]+p)));if(0!==m){do{for(f=h-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[h]--,m-=2}while(m>0);for(f=h;0!==f;f--)for(d=t.bl_count[f];0!==d;)u=t.heap[--c],u>r||(i[2*u+1]!==f&&(t.opt_len+=(f-i[2*u+1])*i[2*u],i[2*u+1]=f),d--)}})(t,e),T(i,c,t.bl_count)},k=(t,e,i)=>{let r,s,n=-1,a=e[1],o=0,l=7,h=4;for(0===a&&(l=138,h=3),e[2*(i+1)+1]=65535,r=0;r<=i;r++)s=a,a=e[2*(r+1)+1],++o{let r,s,n=-1,a=e[1],o=0,l=7,h=4;for(0===a&&(l=138,h=3),r=0;r<=i;r++)if(s=a,a=e[2*(r+1)+1],!(++o{S(t,0+(r?1:0),3),L(t),C(t,i),C(t,~i),i&&t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i};var B=(t,e,i,r)=>{let n,a,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e{let e;for(k(t,t.dyn_ltree,t.l_desc.max_code),k(t,t.dyn_dtree,t.d_desc.max_code),D(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*d[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),n=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,a<=n&&(n=a)):n=a=i+5,i+4<=n&&-1!==e?U(t,e,i,r):4===t.strategy||a===n?(S(t,2+(r?1:0),3),O(t,u,f)):(S(t,4+(r?1:0),3),((t,e,i,r)=>{let s;for(S(t,e-257,5),S(t,i-1,5),S(t,r-4,4),s=0;s{P||((()=>{let t,e,i,r,s;const d=new Array(16);for(i=0,r=0;r<28;r++)for(m[r]=i,t=0;t<1<>=7;r(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=i,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(g[i]+s+1)]++,t.dyn_dtree[2*A(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{S(t,2,3),M(t,256,u),(t=>{16===t.bi_valid?(C(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var G=(t,e,i,r)=>{let s=65535&t,n=t>>>16&65535,a=0;for(;0!==i;){a=i>2e3?2e3:i,i-=a;do{s=s+e[r++]|0,n=n+s|0}while(--a);s%=65521,n%=65521}return s|n<<16};const V=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var j=(t,e,i,r)=>{const s=V,n=r+i;t^=-1;for(let i=r;i>>8^s[255&(t^e[i])];return~t},H={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},W={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:q,_tr_stored_block:Y,_tr_flush_block:Z,_tr_tally:X,_tr_align:K}=N,{Z_NO_FLUSH:Q,Z_PARTIAL_FLUSH:$,Z_FULL_FLUSH:J,Z_FINISH:tt,Z_BLOCK:et,Z_OK:it,Z_STREAM_END:rt,Z_STREAM_ERROR:st,Z_DATA_ERROR:nt,Z_BUF_ERROR:at,Z_DEFAULT_COMPRESSION:ot,Z_FILTERED:lt,Z_HUFFMAN_ONLY:ht,Z_RLE:ct,Z_FIXED:dt,Z_DEFAULT_STRATEGY:ut,Z_UNKNOWN:ft,Z_DEFLATED:pt}=W,gt=258,mt=262,vt=42,_t=113,yt=666,bt=(t,e)=>(t.msg=H[e],e),xt=t=>2*t-(t>4?9:0),wt=t=>{let e=t.length;for(;--e>=0;)t[e]=0},At=t=>{let e,i,r,s=t.w_size;e=t.hash_size,r=e;do{i=t.head[--r],t.head[r]=i>=s?i-s:0}while(--e);e=s,r=e;do{i=t.prev[--r],t.prev[r]=i>=s?i-s:0}while(--e)};let Ct=(t,e,i)=>(e<{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},Mt=(t,e)=>{Z(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,St(t.strm)},zt=(t,e)=>{t.pending_buf[t.pending++]=e},Tt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Et=(t,e,i,r)=>{let s=t.avail_in;return s>r&&(s=r),0===s?0:(t.avail_in-=s,e.set(t.input.subarray(t.next_in,t.next_in+s),i),1===t.state.wrap?t.adler=G(t.adler,e,s,i):2===t.state.wrap&&(t.adler=j(t.adler,e,s,i)),t.next_in+=s,t.total_in+=s,s)},Lt=(t,e)=>{let i,r,s=t.max_chain_length,n=t.strstart,a=t.prev_length,o=t.nice_match;const l=t.strstart>t.w_size-mt?t.strstart-(t.w_size-mt):0,h=t.window,c=t.w_mask,d=t.prev,u=t.strstart+gt;let f=h[n+a-1],p=h[n+a];t.prev_length>=t.good_match&&(s>>=2),o>t.lookahead&&(o=t.lookahead);do{if(i=e,h[i+a]===p&&h[i+a-1]===f&&h[i]===h[n]&&h[++i]===h[n+1]){n+=2,i++;do{}while(h[++n]===h[++i]&&h[++n]===h[++i]&&h[++n]===h[++i]&&h[++n]===h[++i]&&h[++n]===h[++i]&&h[++n]===h[++i]&&h[++n]===h[++i]&&h[++n]===h[++i]&&na){if(t.match_start=e,a=r,r>=o)break;f=h[n+a-1],p=h[n+a]}}}while((e=d[e&c])>l&&0!=--s);return a<=t.lookahead?a:t.lookahead},Ft=t=>{const e=t.w_size;let i,r,s;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-mt)&&(t.window.set(t.window.subarray(e,e+e-r),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),At(t),r+=e),0===t.strm.avail_in)break;if(i=Et(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=i,t.lookahead+t.insert>=3)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=Ct(t,t.ins_h,t.window[s+1]);t.insert&&(t.ins_h=Ct(t,t.ins_h,t.window[s+3-1]),t.prev[s&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=s,s++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead{let i,r,s,n=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,a=0,o=t.strm.avail_in;do{if(i=65535,s=t.bi_valid+42>>3,t.strm.avail_outr+t.strm.avail_in&&(i=r+t.strm.avail_in),i>s&&(i=s),i>8,t.pending_buf[t.pending-2]=~i,t.pending_buf[t.pending-1]=~i>>8,St(t.strm),r&&(r>i&&(r=i),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+r),t.strm.next_out),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r,t.block_start+=r,i-=r),i&&(Et(t.strm,t.strm.output,t.strm.next_out,i),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i)}while(0===a);return o-=t.strm.avail_in,o&&(o>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=o&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-o,t.strm.next_in),t.strstart),t.strstart+=o,t.insert+=o>t.w_size-t.insert?t.w_size-t.insert:o),t.block_start=t.strstart),t.high_waters&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,s+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),s>t.strm.avail_in&&(s=t.strm.avail_in),s&&(Et(t.strm,t.window,t.strstart,s),t.strstart+=s,t.insert+=s>t.w_size-t.insert?t.w_size-t.insert:s),t.high_water>3,s=t.pending_buf_size-s>65535?65535:t.pending_buf_size-s,n=s>t.w_size?t.w_size:s,r=t.strstart-t.block_start,(r>=n||(r||e===tt)&&e!==Q&&0===t.strm.avail_in&&r<=s)&&(i=r>s?s:r,a=e===tt&&0===t.strm.avail_in&&i===r?1:0,Y(t,t.block_start,i,a),t.block_start+=i,St(t.strm)),a?3:1)},Ot=(t,e)=>{let i,r;for(;;){if(t.lookahead=3&&(t.ins_h=Ct(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-mt&&(t.match_length=Lt(t,i)),t.match_length>=3)if(r=X(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=Ct(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=Ct(t,t.ins_h,t.window[t.strstart+1]);else r=X(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(Mt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===tt?(Mt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Mt(t,!1),0===t.strm.avail_out)?1:2},Dt=(t,e)=>{let i,r,s;for(;;){if(t.lookahead=3&&(t.ins_h=Ct(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){s=t.strstart+t.lookahead-3,r=X(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=s&&(t.ins_h=Ct(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,r&&(Mt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(r=X(t,0,t.window[t.strstart-1]),r&&Mt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(r=X(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===tt?(Mt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Mt(t,!1),0===t.strm.avail_out)?1:2};function kt(t,e,i,r,s){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=r,this.func=s}const Rt=[new kt(0,0,0,0,It),new kt(4,4,8,4,Ot),new kt(4,5,16,8,Ot),new kt(4,6,32,32,Ot),new kt(4,4,16,16,Dt),new kt(8,16,32,32,Dt),new kt(8,16,128,128,Dt),new kt(8,32,128,256,Dt),new kt(32,128,258,1024,Dt),new kt(32,258,258,4096,Dt)];function Pt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=pt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),wt(this.dyn_ltree),wt(this.dyn_dtree),wt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),wt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),wt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ut=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==vt&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==_t&&e.status!==yt?1:0},Bt=t=>{if(Ut(t))return bt(t,st);t.total_in=t.total_out=0,t.data_type=ft;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?vt:_t,t.adler=2===e.wrap?0:1,e.last_flush=-2,q(e),it},Nt=t=>{const e=Bt(t);var i;return e===it&&((i=t.state).window_size=2*i.w_size,wt(i.head),i.max_lazy_match=Rt[i.level].max_lazy,i.good_match=Rt[i.level].good_length,i.nice_match=Rt[i.level].nice_length,i.max_chain_length=Rt[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e},Gt=(t,e,i,r,s,n)=>{if(!t)return st;let a=1;if(e===ot&&(e=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),s<1||s>9||i!==pt||r<8||r>15||e<0||e>9||n<0||n>dt||8===r&&1!==a)return bt(t,st);8===r&&(r=9);const o=new Pt;return t.state=o,o.strm=t,o.status=vt,o.wrap=a,o.gzhead=null,o.w_bits=r,o.w_size=1<Gt(t,e,pt,15,8,ut),deflateInit2:Gt,deflateReset:Nt,deflateResetKeep:Bt,deflateSetHeader:(t,e)=>Ut(t)||2!==t.state.wrap?st:(t.state.gzhead=e,it),deflate:(t,e)=>{if(Ut(t)||e>et||e<0)return t?bt(t,st):st;const i=t.state;if(!t.output||0!==t.avail_in&&!t.input||i.status===yt&&e!==tt)return bt(t,0===t.avail_out?at:st);const r=i.last_flush;if(i.last_flush=e,0!==i.pending){if(St(t),0===t.avail_out)return i.last_flush=-1,it}else if(0===t.avail_in&&xt(e)<=xt(r)&&e!==tt)return bt(t,at);if(i.status===yt&&0!==t.avail_in)return bt(t,at);if(i.status===vt&&0===i.wrap&&(i.status=_t),i.status===vt){let e=pt+(i.w_bits-8<<4)<<8,r=-1;if(r=i.strategy>=ht||i.level<2?0:i.level<6?1:6===i.level?2:3,e|=r<<6,0!==i.strstart&&(e|=32),e+=31-e%31,Tt(i,e),0!==i.strstart&&(Tt(i,t.adler>>>16),Tt(i,65535&t.adler)),t.adler=1,i.status=_t,St(t),0!==i.pending)return i.last_flush=-1,it}if(57===i.status)if(t.adler=0,zt(i,31),zt(i,139),zt(i,8),i.gzhead)zt(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),zt(i,255&i.gzhead.time),zt(i,i.gzhead.time>>8&255),zt(i,i.gzhead.time>>16&255),zt(i,i.gzhead.time>>24&255),zt(i,9===i.level?2:i.strategy>=ht||i.level<2?4:0),zt(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(zt(i,255&i.gzhead.extra.length),zt(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=j(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(zt(i,0),zt(i,0),zt(i,0),zt(i,0),zt(i,0),zt(i,9===i.level?2:i.strategy>=ht||i.level<2?4:0),zt(i,3),i.status=_t,St(t),0!==i.pending)return i.last_flush=-1,it;if(69===i.status){if(i.gzhead.extra){let e=i.pending,r=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+r>i.pending_buf_size;){let s=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+s),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>e&&(t.adler=j(t.adler,i.pending_buf,i.pending-e,e)),i.gzindex+=s,St(t),0!==i.pending)return i.last_flush=-1,it;e=0,r-=s}let s=new Uint8Array(i.gzhead.extra);i.pending_buf.set(s.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending+=r,i.gzhead.hcrc&&i.pending>e&&(t.adler=j(t.adler,i.pending_buf,i.pending-e,e)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let e,r=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(t.adler=j(t.adler,i.pending_buf,i.pending-r,r)),St(t),0!==i.pending)return i.last_flush=-1,it;r=0}e=i.gzindexr&&(t.adler=j(t.adler,i.pending_buf,i.pending-r,r)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let e,r=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(t.adler=j(t.adler,i.pending_buf,i.pending-r,r)),St(t),0!==i.pending)return i.last_flush=-1,it;r=0}e=i.gzindexr&&(t.adler=j(t.adler,i.pending_buf,i.pending-r,r))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(St(t),0!==i.pending))return i.last_flush=-1,it;zt(i,255&t.adler),zt(i,t.adler>>8&255),t.adler=0}if(i.status=_t,St(t),0!==i.pending)return i.last_flush=-1,it}if(0!==t.avail_in||0!==i.lookahead||e!==Q&&i.status!==yt){let r=0===i.level?It(i,e):i.strategy===ht?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(Ft(t),0===t.lookahead)){if(e===Q)return 1;break}if(t.match_length=0,i=X(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(Mt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===tt?(Mt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Mt(t,!1),0===t.strm.avail_out)?1:2})(i,e):i.strategy===ct?((t,e)=>{let i,r,s,n;const a=t.window;for(;;){if(t.lookahead<=gt){if(Ft(t),t.lookahead<=gt&&e===Q)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(s=t.strstart-1,r=a[s],r===a[++s]&&r===a[++s]&&r===a[++s])){n=t.strstart+gt;do{}while(r===a[++s]&&r===a[++s]&&r===a[++s]&&r===a[++s]&&r===a[++s]&&r===a[++s]&&r===a[++s]&&r===a[++s]&&st.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=X(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=X(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(Mt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===tt?(Mt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Mt(t,!1),0===t.strm.avail_out)?1:2})(i,e):Rt[i.level].func(i,e);if(3!==r&&4!==r||(i.status=yt),1===r||3===r)return 0===t.avail_out&&(i.last_flush=-1),it;if(2===r&&(e===$?K(i):e!==et&&(Y(i,0,0,!1),e===J&&(wt(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),St(t),0===t.avail_out))return i.last_flush=-1,it}return e!==tt?it:i.wrap<=0?rt:(2===i.wrap?(zt(i,255&t.adler),zt(i,t.adler>>8&255),zt(i,t.adler>>16&255),zt(i,t.adler>>24&255),zt(i,255&t.total_in),zt(i,t.total_in>>8&255),zt(i,t.total_in>>16&255),zt(i,t.total_in>>24&255)):(Tt(i,t.adler>>>16),Tt(i,65535&t.adler)),St(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?it:rt)},deflateEnd:t=>{if(Ut(t))return st;const e=t.state.status;return t.state=null,e===_t?bt(t,nt):it},deflateSetDictionary:(t,e)=>{let i=e.length;if(Ut(t))return st;const r=t.state,s=r.wrap;if(2===s||1===s&&r.status!==vt||r.lookahead)return st;if(1===s&&(t.adler=G(t.adler,e,i,0)),r.wrap=0,i>=r.w_size){0===s&&(wt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let t=new Uint8Array(r.w_size);t.set(e.subarray(i-r.w_size,i),0),e=t,i=r.w_size}const n=t.avail_in,a=t.next_in,o=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,Ft(r);r.lookahead>=3;){let t=r.strstart,e=r.lookahead-2;do{r.ins_h=Ct(r,r.ins_h,r.window[t+3-1]),r.prev[t&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=t,t++}while(--e);r.strstart=t,r.lookahead=2,Ft(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=a,t.input=o,t.avail_in=n,r.wrap=s,it},deflateInfo:"pako deflate (from Nodeca project)"};const jt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ht=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)jt(i,e)&&(t[e]=i[e])}}return t},Wt=t=>{let e=0;for(let i=0,r=t.length;i=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Yt[254]=Yt[254]=1;var Zt=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,i,r,s,n,a=t.length,o=0;for(s=0;s>>6,e[n++]=128|63&i):i<65536?(e[n++]=224|i>>>12,e[n++]=128|i>>>6&63,e[n++]=128|63&i):(e[n++]=240|i>>>18,e[n++]=128|i>>>12&63,e[n++]=128|i>>>6&63,e[n++]=128|63&i);return e},Xt=(t,e)=>{const i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let r,s;const n=new Array(2*i);for(s=0,r=0;r4)n[s++]=65533,r+=a-1;else{for(e&=2===a?31:3===a?15:7;a>1&&r1?n[s++]=65533:e<65536?n[s++]=e:(e-=65536,n[s++]=55296|e>>10&1023,n[s++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&qt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let r=0;r{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Yt[t[i]]>e?i:e};var Qt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const $t=Object.prototype.toString,{Z_NO_FLUSH:Jt,Z_SYNC_FLUSH:te,Z_FULL_FLUSH:ee,Z_FINISH:ie,Z_OK:re,Z_STREAM_END:se,Z_DEFAULT_COMPRESSION:ne,Z_DEFAULT_STRATEGY:ae,Z_DEFLATED:oe}=W;function le(t){this.options=Ht({level:ne,method:oe,chunkSize:16384,windowBits:15,memLevel:8,strategy:ae},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Qt,this.strm.avail_out=0;let i=Vt.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==re)throw new Error(H[i]);if(e.header&&Vt.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Zt(e.dictionary):"[object ArrayBuffer]"===$t.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=Vt.deflateSetDictionary(this.strm,t),i!==re)throw new Error(H[i]);this._dict_set=!0}}function he(t,e){const i=new le(e);if(i.push(t,!0),i.err)throw i.msg||H[i.err];return i.result}le.prototype.push=function(t,e){const i=this.strm,r=this.options.chunkSize;let s,n;if(this.ended)return!1;for(n=e===~~e?e:!0===e?ie:Jt,"string"==typeof t?i.input=Zt(t):"[object ArrayBuffer]"===$t.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(r),i.next_out=0,i.avail_out=r),(n===te||n===ee)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(s=Vt.deflate(i,n),s===se)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),s=Vt.deflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===re;if(0!==i.avail_out){if(n>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},le.prototype.onData=function(t){this.chunks.push(t)},le.prototype.onEnd=function(t){t===re&&(this.result=Wt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var ce={Deflate:le,deflate:he,deflateRaw:function(t,e){return(e=e||{}).raw=!0,he(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,he(t,e)},constants:W};const de=16209;var ue=function(t,e){let i,r,s,n,a,o,l,h,c,d,u,f,p,g,m,v,_,y,b,x,w,A,C,S;const M=t.state;i=t.next_in,C=t.input,r=i+(t.avail_in-5),s=t.next_out,S=t.output,n=s-(e-t.avail_out),a=s+(t.avail_out-257),o=M.dmax,l=M.wsize,h=M.whave,c=M.wnext,d=M.window,u=M.hold,f=M.bits,p=M.lencode,g=M.distcode,m=(1<>>24,u>>>=y,f-=y,y=_>>>16&255,0===y)S[s++]=65535&_;else{if(!(16&y)){if(64&y){if(32&y){M.mode=16191;break t}t.msg="invalid literal/length code",M.mode=de;break t}_=p[(65535&_)+(u&(1<>>=y,f-=y),f<15&&(u+=C[i++]<>>24,u>>>=y,f-=y,y=_>>>16&255,16&y){if(x=65535&_,y&=15,fo){t.msg="invalid distance too far back",M.mode=de;break t}if(u>>>=y,f-=y,y=s-n,x>y){if(y=x-y,y>h&&M.sane){t.msg="invalid distance too far back",M.mode=de;break t}if(w=0,A=d,0===c){if(w+=l-y,y2;)S[s++]=A[w++],S[s++]=A[w++],S[s++]=A[w++],b-=3;b&&(S[s++]=A[w++],b>1&&(S[s++]=A[w++]))}else{w=s-x;do{S[s++]=S[w++],S[s++]=S[w++],S[s++]=S[w++],b-=3}while(b>2);b&&(S[s++]=S[w++],b>1&&(S[s++]=S[w++]))}break}if(64&y){t.msg="invalid distance code",M.mode=de;break t}_=g[(65535&_)+(u&(1<>3,i-=b,f-=b<<3,u&=(1<{const l=o.bits;let h,c,d,u,f,p,g=0,m=0,v=0,_=0,y=0,b=0,x=0,w=0,A=0,C=0,S=null;const M=new Uint16Array(16),z=new Uint16Array(16);let T,E,L,F=null;for(g=0;g<=fe;g++)M[g]=0;for(m=0;m=1&&0===M[_];_--);if(y>_&&(y=_),0===_)return s[n++]=20971520,s[n++]=20971520,o.bits=1,0;for(v=1;v<_&&0===M[v];v++);for(y0&&(0===t||1!==_))return-1;for(z[1]=0,g=1;g852||2===t&&A>592)return 1;for(;;){T=g-x,a[m]+1=p?(E=F[a[m]-p],L=S[a[m]-p]):(E=96,L=0),h=1<>x)+c]=T<<24|E<<16|L}while(0!==c);for(h=1<>=1;if(0!==h?(C&=h-1,C+=h):C=0,m++,0==--M[g]){if(g===_)break;g=e[i+a[m]]}if(g>y&&(C&u)!==d){for(0===x&&(x=y),f+=v,b=g-x,w=1<852||2===t&&A>592)return 1;d=C&u,s[d]=y<<24|b<<16|f-n}}return 0!==C&&(s[f+C]=g-x<<24|64<<16),o.bits=y,0};const{Z_FINISH:ye,Z_BLOCK:be,Z_TREES:xe,Z_OK:we,Z_STREAM_END:Ae,Z_NEED_DICT:Ce,Z_STREAM_ERROR:Se,Z_DATA_ERROR:Me,Z_MEM_ERROR:ze,Z_BUF_ERROR:Te,Z_DEFLATED:Ee}=W,Le=16180,Fe=16190,Ie=16191,Oe=16192,De=16194,ke=16199,Re=16200,Pe=16206,Ue=16209,Be=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Ne(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ge=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode16211?1:0},Ve=t=>{if(Ge(t))return Se;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=Le,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,we},je=t=>{if(Ge(t))return Se;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Ve(t)},He=(t,e)=>{let i;if(Ge(t))return Se;const r=t.state;return e<0?(i=0,e=-e):(i=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?Se:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=i,r.wbits=e,je(t))},We=(t,e)=>{if(!t)return Se;const i=new Ne;t.state=i,i.strm=t,i.window=null,i.mode=Le;const r=He(t,e);return r!==we&&(t.state=null),r};let qe,Ye,Ze=!0;const Xe=t=>{if(Ze){qe=new Int32Array(512),Ye=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(_e(1,t.lens,0,288,qe,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;_e(2,t.lens,0,32,Ye,0,t.work,{bits:5}),Ze=!1}t.lencode=qe,t.lenbits=9,t.distcode=Ye,t.distbits=5},Ke=(t,e,i,r)=>{let s;const n=t.state;return null===n.window&&(n.wsize=1<=n.wsize?(n.window.set(e.subarray(i-n.wsize,i),0),n.wnext=0,n.whave=n.wsize):(s=n.wsize-n.wnext,s>r&&(s=r),n.window.set(e.subarray(i-r,i-r+s),n.wnext),(r-=s)?(n.window.set(e.subarray(i-r,i),0),n.wnext=r,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whaveWe(t,15),inflateInit2:We,inflate:(t,e)=>{let i,r,s,n,a,o,l,h,c,d,u,f,p,g,m,v,_,y,b,x,w,A,C=0;const S=new Uint8Array(4);let M,z;const T=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ge(t)||!t.output||!t.input&&0!==t.avail_in)return Se;i=t.state,i.mode===Ie&&(i.mode=Oe),a=t.next_out,s=t.output,l=t.avail_out,n=t.next_in,r=t.input,o=t.avail_in,h=i.hold,c=i.bits,d=o,u=l,A=we;t:for(;;)switch(i.mode){case Le:if(0===i.wrap){i.mode=Oe;break}for(;c<16;){if(0===o)break t;o--,h+=r[n++]<>>8&255,i.check=j(i.check,S,2,0),h=0,c=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",i.mode=Ue;break}if((15&h)!==Ee){t.msg="unknown compression method",i.mode=Ue;break}if(h>>>=4,c-=4,w=8+(15&h),0===i.wbits&&(i.wbits=w),w>15||w>i.wbits){t.msg="invalid window size",i.mode=Ue;break}i.dmax=1<>8&1),512&i.flags&&4&i.wrap&&(S[0]=255&h,S[1]=h>>>8&255,i.check=j(i.check,S,2,0)),h=0,c=0,i.mode=16182;case 16182:for(;c<32;){if(0===o)break t;o--,h+=r[n++]<>>8&255,S[2]=h>>>16&255,S[3]=h>>>24&255,i.check=j(i.check,S,4,0)),h=0,c=0,i.mode=16183;case 16183:for(;c<16;){if(0===o)break t;o--,h+=r[n++]<>8),512&i.flags&&4&i.wrap&&(S[0]=255&h,S[1]=h>>>8&255,i.check=j(i.check,S,2,0)),h=0,c=0,i.mode=16184;case 16184:if(1024&i.flags){for(;c<16;){if(0===o)break t;o--,h+=r[n++]<>>8&255,i.check=j(i.check,S,2,0)),h=0,c=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(f=i.length,f>o&&(f=o),f&&(i.head&&(w=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(r.subarray(n,n+f),w)),512&i.flags&&4&i.wrap&&(i.check=j(i.check,r,f,n)),o-=f,n+=f,i.length-=f),i.length))break t;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===o)break t;f=0;do{w=r[n+f++],i.head&&w&&i.length<65536&&(i.head.name+=String.fromCharCode(w))}while(w&&f>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=Ie;break;case 16189:for(;c<32;){if(0===o)break t;o--,h+=r[n++]<>>=7&c,c-=7&c,i.mode=Pe;break}for(;c<3;){if(0===o)break t;o--,h+=r[n++]<>>=1,c-=1,3&h){case 0:i.mode=16193;break;case 1:if(Xe(i),i.mode=ke,e===xe){h>>>=2,c-=2;break t}break;case 2:i.mode=16196;break;case 3:t.msg="invalid block type",i.mode=Ue}h>>>=2,c-=2;break;case 16193:for(h>>>=7&c,c-=7&c;c<32;){if(0===o)break t;o--,h+=r[n++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=Ue;break}if(i.length=65535&h,h=0,c=0,i.mode=De,e===xe)break t;case De:i.mode=16195;case 16195:if(f=i.length,f){if(f>o&&(f=o),f>l&&(f=l),0===f)break t;s.set(r.subarray(n,n+f),a),o-=f,n+=f,l-=f,a+=f,i.length-=f;break}i.mode=Ie;break;case 16196:for(;c<14;){if(0===o)break t;o--,h+=r[n++]<>>=5,c-=5,i.ndist=1+(31&h),h>>>=5,c-=5,i.ncode=4+(15&h),h>>>=4,c-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=Ue;break}i.have=0,i.mode=16197;case 16197:for(;i.have>>=3,c-=3}for(;i.have<19;)i.lens[T[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,M={bits:i.lenbits},A=_e(0,i.lens,0,19,i.lencode,0,i.work,M),i.lenbits=M.bits,A){t.msg="invalid code lengths set",i.mode=Ue;break}i.have=0,i.mode=16198;case 16198:for(;i.have>>24,v=C>>>16&255,_=65535&C,!(m<=c);){if(0===o)break t;o--,h+=r[n++]<>>=m,c-=m,i.lens[i.have++]=_;else{if(16===_){for(z=m+2;c>>=m,c-=m,0===i.have){t.msg="invalid bit length repeat",i.mode=Ue;break}w=i.lens[i.have-1],f=3+(3&h),h>>>=2,c-=2}else if(17===_){for(z=m+3;c>>=m,c-=m,w=0,f=3+(7&h),h>>>=3,c-=3}else{for(z=m+7;c>>=m,c-=m,w=0,f=11+(127&h),h>>>=7,c-=7}if(i.have+f>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=Ue;break}for(;f--;)i.lens[i.have++]=w}}if(i.mode===Ue)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=Ue;break}if(i.lenbits=9,M={bits:i.lenbits},A=_e(1,i.lens,0,i.nlen,i.lencode,0,i.work,M),i.lenbits=M.bits,A){t.msg="invalid literal/lengths set",i.mode=Ue;break}if(i.distbits=6,i.distcode=i.distdyn,M={bits:i.distbits},A=_e(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,M),i.distbits=M.bits,A){t.msg="invalid distances set",i.mode=Ue;break}if(i.mode=ke,e===xe)break t;case ke:i.mode=Re;case Re:if(o>=6&&l>=258){t.next_out=a,t.avail_out=l,t.next_in=n,t.avail_in=o,i.hold=h,i.bits=c,ue(t,u),a=t.next_out,s=t.output,l=t.avail_out,n=t.next_in,r=t.input,o=t.avail_in,h=i.hold,c=i.bits,i.mode===Ie&&(i.back=-1);break}for(i.back=0;C=i.lencode[h&(1<>>24,v=C>>>16&255,_=65535&C,!(m<=c);){if(0===o)break t;o--,h+=r[n++]<>y)],m=C>>>24,v=C>>>16&255,_=65535&C,!(y+m<=c);){if(0===o)break t;o--,h+=r[n++]<>>=y,c-=y,i.back+=y}if(h>>>=m,c-=m,i.back+=m,i.length=_,0===v){i.mode=16205;break}if(32&v){i.back=-1,i.mode=Ie;break}if(64&v){t.msg="invalid literal/length code",i.mode=Ue;break}i.extra=15&v,i.mode=16201;case 16201:if(i.extra){for(z=i.extra;c>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;C=i.distcode[h&(1<>>24,v=C>>>16&255,_=65535&C,!(m<=c);){if(0===o)break t;o--,h+=r[n++]<>y)],m=C>>>24,v=C>>>16&255,_=65535&C,!(y+m<=c);){if(0===o)break t;o--,h+=r[n++]<>>=y,c-=y,i.back+=y}if(h>>>=m,c-=m,i.back+=m,64&v){t.msg="invalid distance code",i.mode=Ue;break}i.offset=_,i.extra=15&v,i.mode=16203;case 16203:if(i.extra){for(z=i.extra;c>>=i.extra,c-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=Ue;break}i.mode=16204;case 16204:if(0===l)break t;if(f=u-l,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=Ue;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=s,p=a-i.offset,f=i.length;f>l&&(f=l),l-=f,i.length-=f;do{s[a++]=g[p++]}while(--f);0===i.length&&(i.mode=Re);break;case 16205:if(0===l)break t;s[a++]=i.length,l--,i.mode=Re;break;case Pe:if(i.wrap){for(;c<32;){if(0===o)break t;o--,h|=r[n++]<{if(Ge(t))return Se;let e=t.state;return e.window&&(e.window=null),t.state=null,we},inflateGetHeader:(t,e)=>{if(Ge(t))return Se;const i=t.state;return 2&i.wrap?(i.head=e,e.done=!1,we):Se},inflateSetDictionary:(t,e)=>{const i=e.length;let r,s,n;return Ge(t)?Se:(r=t.state,0!==r.wrap&&r.mode!==Fe?Se:r.mode===Fe&&(s=1,s=G(s,e,i,0),s!==r.check)?Me:(n=Ke(t,e,i,i),n?(r.mode=16210,ze):(r.havedict=1,we)))},inflateInfo:"pako inflate (from Nodeca project)"};var $e=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Je=Object.prototype.toString,{Z_NO_FLUSH:ti,Z_FINISH:ei,Z_OK:ii,Z_STREAM_END:ri,Z_NEED_DICT:si,Z_STREAM_ERROR:ni,Z_DATA_ERROR:ai,Z_MEM_ERROR:oi}=W;function li(t){this.options=Ht({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Qt,this.strm.avail_out=0;let i=Qe.inflateInit2(this.strm,e.windowBits);if(i!==ii)throw new Error(H[i]);if(this.header=new $e,Qe.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Zt(e.dictionary):"[object ArrayBuffer]"===Je.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=Qe.inflateSetDictionary(this.strm,e.dictionary),i!==ii)))throw new Error(H[i])}function hi(t,e){const i=new li(e);if(i.push(t),i.err)throw i.msg||H[i.err];return i.result}li.prototype.push=function(t,e){const i=this.strm,r=this.options.chunkSize,s=this.options.dictionary;let n,a,o;if(this.ended)return!1;for(a=e===~~e?e:!0===e?ei:ti,"[object ArrayBuffer]"===Je.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(r),i.next_out=0,i.avail_out=r),n=Qe.inflate(i,a),n===si&&s&&(n=Qe.inflateSetDictionary(i,s),n===ii?n=Qe.inflate(i,a):n===ai&&(n=si));i.avail_in>0&&n===ri&&i.state.wrap>0&&0!==t[i.next_in];)Qe.inflateReset(i),n=Qe.inflate(i,a);switch(n){case ni:case ai:case si:case oi:return this.onEnd(n),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||n===ri))if("string"===this.options.to){let t=Kt(i.output,i.next_out),e=i.next_out-t,s=Xt(i.output,t);i.next_out=e,i.avail_out=r-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(s)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(n!==ii||0!==o){if(n===ri)return n=Qe.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},li.prototype.onData=function(t){this.chunks.push(t)},li.prototype.onEnd=function(t){t===ii&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Wt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var ci={Inflate:li,inflate:hi,inflateRaw:function(t,e){return(e=e||{}).raw=!0,hi(t,e)},ungzip:hi,constants:W};const{Deflate:di,deflate:ui,deflateRaw:fi,gzip:pi}=ce,{Inflate:gi,inflate:mi,inflateRaw:vi,ungzip:_i}=ci;var yi=di,bi=ui,xi=fi,wi=pi,Ai=gi,Ci=mi,Si=vi,Mi=_i,zi=W,Ti={Deflate:di,deflate:ui,deflateRaw:fi,gzip:pi,Inflate:gi,inflate:mi,inflateRaw:vi,ungzip:_i,constants:W}}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var i=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t].call(i.exports,i,i.exports,__webpack_require__),i.exports}__webpack_require__.d=(t,e)=>{for(var i in e)__webpack_require__.o(e,i)&&!__webpack_require__.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),__webpack_require__.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},__webpack_require__(421),__webpack_require__(185);var __webpack_exports__=__webpack_require__(307);return __webpack_exports__})())); \ No newline at end of file diff --git a/training/static/3Dmol-min.js.LICENSE.txt b/training/static/3Dmol-min.js.LICENSE.txt new file mode 100644 index 0000000..892ff71 --- /dev/null +++ b/training/static/3Dmol-min.js.LICENSE.txt @@ -0,0 +1,5 @@ +/*! + * 3dmol v2.4.2 + * JavaScript/TypeScript molecular visualization library + * Author: David Koes and contributors + */ diff --git a/training/static/README.md b/training/static/README.md new file mode 100644 index 0000000..723bd0f --- /dev/null +++ b/training/static/README.md @@ -0,0 +1,10 @@ +# Vendored static assets + +Third-party browser assets served locally by `app.py` so the demo workbench stays +self-contained (no CDN dependency, works on an air-gapped/LAN box). + +- **`3Dmol-min.js`** — [3Dmol.js](https://3dmol.csb.pitt.edu/) v2.4.2, an interactive + WebGL molecular viewer by David Koes and contributors. **License: BSD-3-Clause** + (permissive, commercial-OK with attribution). Renders the 3D conformer that + `/api/structure3d` generates (RDKit ETKDG embed + MMFF optimize). `3Dmol-min.js.LICENSE.txt` + is the upstream license header extracted by the build. diff --git a/training/workbench.html b/training/workbench.html index e75777f..de5290a 100644 --- a/training/workbench.html +++ b/training/workbench.html @@ -95,6 +95,13 @@ .structure{text-align:center;margin:0 0 14px;background:#fff;border:1px solid var(--line);border-radius:8px;padding:6px} .structure svg{max-width:100%;height:auto} .structure:empty{display:none} + .struct-toggle{display:flex;gap:0;justify-content:center;margin:0 0 8px} + .st-tab{font:inherit;font-size:12px;font-weight:600;padding:4px 14px;border:1px solid var(--line);background:#fff;color:var(--muted);cursor:pointer} + .st-tab:first-child{border-radius:6px 0 0 6px;border-right:none} + .st-tab:last-child{border-radius:0 6px 6px 0} + .st-tab.on{background:var(--aroma);color:#fff;border-color:var(--aroma)} + .structure3d{position:relative;width:100%;height:280px;margin:0 0 14px;background:#fff;border:1px solid var(--line);border-radius:8px;overflow:hidden} + .s3-empty{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--muted);font-size:13px} .domain-banner{background:#FFF6E6;border:1px solid #E8D38A;color:#7A5A12;border-radius:8px;padding:10px 13px;font-size:13px;margin-bottom:14px;line-height:1.5} .hint code{font-family:var(--mono);background:var(--accent-soft);padding:1px 5px;border-radius:4px;color:var(--accent)} .toggle{font-family:var(--mono);font-size:12px;color:var(--muted);margin:12px 2px 0;display:flex;align-items:center;gap:7px;cursor:pointer} @@ -158,7 +165,12 @@

Flavor Workbench