aldehyde 0.2.32 → 0.2.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.022b9d9e54b55ad6267e.js +1 -0
- package/dist/bundle.022b9d9e54b55ad6267e.js.gz +0 -0
- package/dist/bundle.03c8826fed3306e7bca7.js +1 -0
- package/dist/bundle.17695fcdfc4d8b13d695.js +2 -0
- package/dist/bundle.17695fcdfc4d8b13d695.js.LICENSE.txt +8 -0
- package/dist/bundle.17695fcdfc4d8b13d695.js.gz +0 -0
- package/dist/bundle.1bc3fad9b6dda01db2dc.js +1 -0
- package/dist/bundle.1bc3fad9b6dda01db2dc.js.gz +0 -0
- package/dist/bundle.26e8ea213610dd77dfc5.js +2 -0
- package/dist/bundle.26e8ea213610dd77dfc5.js.LICENSE.txt +22 -0
- package/dist/bundle.26e8ea213610dd77dfc5.js.gz +0 -0
- package/dist/bundle.2e0aa3d0288f29cd9bdb.js +1 -0
- package/dist/bundle.2e0aa3d0288f29cd9bdb.js.gz +0 -0
- package/dist/bundle.3afd92d0051920d083b8.js +1 -0
- package/dist/bundle.3afd92d0051920d083b8.js.gz +0 -0
- package/dist/bundle.3b47a72a98819ce207b4.js +2 -0
- package/dist/bundle.3b47a72a98819ce207b4.js.LICENSE.txt +14 -0
- package/dist/bundle.3b47a72a98819ce207b4.js.gz +0 -0
- package/dist/bundle.4d91709f680596b4b0ac.js +2 -0
- package/dist/bundle.4d91709f680596b4b0ac.js.LICENSE.txt +9 -0
- package/dist/bundle.4d91709f680596b4b0ac.js.gz +0 -0
- package/dist/bundle.4e6573855d62c2c61293.js +1 -0
- package/dist/bundle.4e6573855d62c2c61293.js.gz +0 -0
- package/dist/bundle.51344a730efffedb67a3.js +2 -0
- package/dist/bundle.51344a730efffedb67a3.js.LICENSE.txt +8 -0
- package/dist/bundle.51344a730efffedb67a3.js.gz +0 -0
- package/dist/bundle.59446aa1a6e81028b0f3.js +1 -0
- package/dist/bundle.59446aa1a6e81028b0f3.js.gz +0 -0
- package/dist/bundle.5c631f42a0bc32bcee42.js +1 -0
- package/dist/bundle.5cc46bd3e80bed3462d0.js +2 -0
- package/dist/bundle.5cc46bd3e80bed3462d0.js.LICENSE.txt +1 -0
- package/dist/bundle.5cc46bd3e80bed3462d0.js.gz +0 -0
- package/dist/bundle.5fc1d01501a8fadd2680.js +2 -0
- package/dist/bundle.5fc1d01501a8fadd2680.js.LICENSE.txt +7 -0
- package/dist/bundle.5fc1d01501a8fadd2680.js.gz +0 -0
- package/dist/bundle.6bf28a6aa5ba025b9cbe.js +2 -0
- package/dist/bundle.6bf28a6aa5ba025b9cbe.js.LICENSE.txt +18 -0
- package/dist/bundle.6bf28a6aa5ba025b9cbe.js.gz +0 -0
- package/dist/bundle.6c63d1f8fd32a2e9ca6c.js +75 -0
- package/dist/bundle.6c63d1f8fd32a2e9ca6c.js.LICENSE.txt +17 -0
- package/dist/bundle.6c63d1f8fd32a2e9ca6c.js.gz +0 -0
- package/dist/bundle.75ca758485013fe73c8a.js +1 -0
- package/dist/bundle.75ca758485013fe73c8a.js.gz +0 -0
- package/dist/bundle.79c75972bdb84e2526a0.js +1 -0
- package/dist/bundle.79c75972bdb84e2526a0.js.gz +0 -0
- package/dist/bundle.7c07c768d6aa85f8cb7f.js +1 -0
- package/dist/bundle.7c07c768d6aa85f8cb7f.js.gz +0 -0
- package/dist/bundle.7e85c36e04f1428d40ae.js +2 -0
- package/dist/bundle.7e85c36e04f1428d40ae.js.LICENSE.txt +17 -0
- package/dist/bundle.7e85c36e04f1428d40ae.js.gz +0 -0
- package/dist/bundle.7fe4c9d6d1fad1b785b4.js +1 -0
- package/dist/bundle.7fe4c9d6d1fad1b785b4.js.gz +0 -0
- package/dist/bundle.8a46aaa80505db8f0a31.js +1 -0
- package/dist/bundle.8a46aaa80505db8f0a31.js.gz +0 -0
- package/dist/bundle.8a6c3026f7b0ad7bdc84.js +2 -0
- package/dist/bundle.8a6c3026f7b0ad7bdc84.js.LICENSE.txt +25 -0
- package/dist/bundle.8a6c3026f7b0ad7bdc84.js.gz +0 -0
- package/dist/bundle.9a888a685a8dc8795cb1.js +1 -0
- package/dist/bundle.9d12b63336a9c8d44a9d.js +1 -0
- package/dist/bundle.9d12b63336a9c8d44a9d.js.gz +0 -0
- package/dist/bundle.a7dfe1231cfa8ef5b0d3.js +2 -0
- package/dist/bundle.a7dfe1231cfa8ef5b0d3.js.LICENSE.txt +5 -0
- package/dist/bundle.a7dfe1231cfa8ef5b0d3.js.gz +0 -0
- package/dist/bundle.be6aaf07219b3f9a361f.js +1 -0
- package/dist/bundle.be6aaf07219b3f9a361f.js.gz +0 -0
- package/dist/bundle.c015ad492469b8a18b36.js +1 -0
- package/dist/bundle.c015ad492469b8a18b36.js.gz +0 -0
- package/dist/bundle.c31ad04e1e30564fea70.js +1 -0
- package/dist/bundle.c560447b006cce1238b6.js +2 -0
- package/dist/bundle.c560447b006cce1238b6.js.LICENSE.txt +1 -0
- package/dist/bundle.c560447b006cce1238b6.js.gz +0 -0
- package/dist/bundle.cad48ecfb6c9304f8477.js +2 -0
- package/dist/bundle.cad48ecfb6c9304f8477.js.LICENSE.txt +5 -0
- package/dist/bundle.cad48ecfb6c9304f8477.js.gz +0 -0
- package/dist/bundle.d7eaee8d9bcfcf8b0bd0.js +1 -0
- package/dist/bundle.d7eaee8d9bcfcf8b0bd0.js.gz +0 -0
- package/dist/bundle.d8256eaa6fe575fb9d01.js +8 -0
- package/dist/bundle.d8256eaa6fe575fb9d01.js.LICENSE.txt +8 -0
- package/dist/bundle.d8256eaa6fe575fb9d01.js.gz +0 -0
- package/dist/bundle.dbb253f3029c97475380.js +1 -0
- package/dist/bundle.dbb253f3029c97475380.js.gz +0 -0
- package/dist/bundle.df7845990c0fed52fca8.js +2 -0
- package/dist/bundle.df7845990c0fed52fca8.js.LICENSE.txt +29 -0
- package/dist/bundle.df7845990c0fed52fca8.js.gz +0 -0
- package/dist/bundle.e1ac7a74c5a25a07424c.js +1 -0
- package/dist/bundle.e1ac7a74c5a25a07424c.js.gz +0 -0
- package/dist/bundle.e9b7939a81971b04ce61.js +1 -0
- package/dist/bundle.e9b7939a81971b04ce61.js.gz +0 -0
- package/dist/bundle.eb8b12c34556f700f59a.js +2 -0
- package/dist/bundle.eb8b12c34556f700f59a.js.LICENSE.txt +30 -0
- package/dist/bundle.eb8b12c34556f700f59a.js.gz +0 -0
- package/dist/bundle.f4f8e071565f4dff4698.js +2 -0
- package/dist/bundle.f4f8e071565f4dff4698.js.LICENSE.txt +5 -0
- package/dist/bundle.f4f8e071565f4dff4698.js.gz +0 -0
- package/dist/css/chemstruc-graph-15d5053934e613f20d2b.css +11 -0
- package/dist/css/chemstruc-graph-15d5053934e613f20d2b.css.gz +0 -0
- package/dist/css/common-131a1a93b3a3dde25f8f.css +90 -0
- package/dist/css/html-editor-draft-5e8e152675ab7d201c00.css +886 -0
- package/dist/css/html-editor-draft-5e8e152675ab7d201c00.css.gz +0 -0
- package/dist/css/main-4bd110a5b2a4a3fbef88.css +803 -0
- package/dist/css/main-4bd110a5b2a4a3fbef88.css.gz +0 -0
- package/dist/images/development-30de07a0.png +0 -0
- package/dist/images/pain-point-8f02421e.png +0 -0
- package/dist/images/target-13a5b4b9.png +0 -0
- package/dist/images/time-cost-cb40d2c2.png +0 -0
- package/dist/images/time-prograss-44b86b36.png +0 -0
- package/dist/index.html +4 -0
- package/lib/controls/code-editor/sql-code-editor.d.ts.map +1 -1
- package/lib/controls/code-editor/sql-code-editor.js.map +1 -1
- package/lib/controls/date-picker/index.d.ts +2 -2
- package/lib/controls/entry-control.d.ts.map +1 -1
- package/lib/controls/entry-control.js +2 -2
- package/lib/controls/entry-control.js.map +1 -1
- package/lib/controls/view-control.d.ts.map +1 -1
- package/lib/controls/view-control.js +3 -3
- package/lib/controls/view-control.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/layout/MainPage.js +1 -1
- package/lib/layout/MainPage.js.map +1 -1
- package/lib/layout/header/index.d.ts.map +1 -1
- package/lib/layout/header/index.js.map +1 -1
- package/lib/tmpl/superagent.d.ts.map +1 -1
- package/lib/tmpl/superagent.js +2 -1
- package/lib/tmpl/superagent.js.map +1 -1
- package/lib/welcome/workbench.js.map +1 -1
- package/package.json +2 -3
- package/src/aldehyde/controls/code-editor/sql-code-editor.tsx +1 -2
- package/src/aldehyde/controls/date-picker/index.tsx +2 -2
- package/src/aldehyde/controls/entry-control.tsx +4 -2
- package/src/aldehyde/controls/view-control.tsx +7 -6
- package/src/aldehyde/index.tsx +5 -2
- package/src/aldehyde/layout/MainPage.tsx +1 -1
- package/src/aldehyde/layout/header/index.tsx +0 -1
- package/src/aldehyde/tmpl/superagent.js +3 -1
- package/src/aldehyde/welcome/workbench.tsx +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkaldehyde=self.webpackChunkaldehyde||[]).push([[623],{76623:function(e,t,r){r.d(t,{r:function(){return Ru}});var n=r(96486),i=r(68636);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(e,"prototype",{value:Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),writable:!1}),t&&u(e,t)}function f(e,t){if(t&&("object"===o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return c(e)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function m(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,t):void 0}}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}}(e,t)||m(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},y.apply(this,arguments)},_={lines:12,length:7,width:5,radius:10,scale:1,corners:1,color:"#000",fadeColor:"transparent",animation:"spinner-line-fade-default",rotate:0,direction:1,speed:1,zIndex:2e9,className:"spinner",top:"50%",left:"50%",shadow:"0 0 1px transparent",position:"absolute"},g=function(){function e(e){void 0===e&&(e={}),this.opts=y(y({},_),e)}return e.prototype.spin=function(e){return this.stop(),this.el=document.createElement("div"),this.el.className=this.opts.className,this.el.setAttribute("role","progressbar"),x(this.el,{position:this.opts.position,width:0,zIndex:this.opts.zIndex,left:this.opts.left,top:this.opts.top,transform:"scale("+this.opts.scale+")"}),e&&e.insertBefore(this.el,e.firstChild||null),function(e,t){var r=Math.round(t.corners*t.width*500)/1e3+"px",n="none";!0===t.shadow?n="0 2px 4px #000":"string"==typeof t.shadow&&(n=t.shadow);for(var i=function(e){for(var t=/^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/,r=[],n=0,i=e.split(",");n<i.length;n++){var o=i[n].match(t);if(null!==o){var a=+o[2],s=+o[5],l=o[4],c=o[7];0!==a||l||(l=c),0!==s||c||(c=l),l===c&&r.push({prefix:o[1]||"",x:a,y:s,xUnits:l,yUnits:c,end:o[8]})}}return r}(n),o=0;o<t.lines;o++){var a=~~(360/t.lines*o+t.rotate),s=x(document.createElement("div"),{position:"absolute",top:-t.width/2+"px",width:t.length+t.width+"px",height:t.width+"px",background:b(t.fadeColor,o),borderRadius:r,transformOrigin:"left",transform:"rotate("+a+"deg) translateX("+t.radius+"px)"}),l=o*t.direction/t.lines/t.speed;l-=1/t.speed;var c=x(document.createElement("div"),{width:"100%",height:"100%",background:b(t.color,o),borderRadius:r,boxShadow:w(i,a),animation:1/t.speed+"s linear "+l+"s infinite "+t.animation});s.appendChild(c),e.appendChild(s)}}(this.el,this.opts),this},e.prototype.stop=function(){return this.el&&("undefined"!=typeof requestAnimationFrame?cancelAnimationFrame(this.animateId):clearTimeout(this.animateId),this.el.parentNode&&this.el.parentNode.removeChild(this.el),this.el=void 0),this},e}();function x(e,t){for(var r in t)e.style[r]=t[r];return e}function b(e,t){return"string"==typeof e?e:e[t%e.length]}function w(e,t){for(var r=[],n=0,i=e;n<i.length;n++){var o=i[n],a=S(o.x,o.y,t);r.push(o.prefix+a[0]+o.xUnits+" "+a[1]+o.yUnits+o.end)}return r.join(", ")}function S(e,t,r){var n=r*Math.PI/180,i=Math.sin(n),o=Math.cos(n);return[Math.round(1e3*(e*o+t*i))/1e3,Math.round(1e3*(-e*i+t*o))/1e3]}var R,C=function(){function e(){a(this,e),this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}return l(e,[{key:"start",value:function(){this.startTime=e.now(),this.oldTime=this.startTime,this.running=!0}},{key:"stop",value:function(){this.getElapsedTime(),this.running=!1}},{key:"getElapsedTime",value:function(){return this.update(),this.elapsedTime}},{key:"update",value:function(){var t=0;if(this.running){var r=e.now();t=.001*(r-this.oldTime),this.oldTime=r,this.elapsedTime+=t}return t}}]),e}();C.now=(R="undefined"!=typeof window&&window.performance)&&R.now?R.now.bind(R):Date.now;var A=C.now;function E(e,t,r){var n=document.createElement(e);return n.id=t,n.style.cssText=r,n}var k=function(){function e(){a(this,e),this.domElement=E("div","stats","padding:8px"),this._text=E("p","fps","margin:0;color:silver;font-size:large"),this.domElement.appendChild(this._text),this._startTime=A(),this._prevTime=this._startTime,this._deltas=new Array(20),this._index=0,this._total=0,this._count=0}return l(e,[{key:"end",value:function(){var e=A(),t=e-this._startTime;return this._count<this._deltas.length?this._count++:this._total-=this._deltas[this._index],this._total+=t,this._deltas[this._index]=t,this._index=(this._index+1)%this._deltas.length,this.ms=this._total/this._count,this.fps=1e3/this.ms,e>this._prevTime+1e3&&(this._text.textContent=this.fps.toPrecision(2),this._prevTime=e),e}},{key:"update",value:function(){this._startTime=this.end()}},{key:"show",value:function(e){void 0===e&&(e=!0),this.domElement.style.display=e?"block":"none"}}]),e}();function P(e,t,r){return P=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&u(i,r.prototype),i},P.apply(null,arguments)}function T(e){var t="function"==typeof Map?new Map:void 0;return T=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return P(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)},T(e)}function M(e,t){return!e||e===t}function N(){this._handlers={}}N.prototype.addEventListener=function(e,t,r){var i=this._handlers[e];i||(this._handlers[e]=[],i=this._handlers[e]);var o=[t,r];void 0===(0,n.find)(i,(function(e){return e[0]===o[0]&&e[1]===o[1]}))&&i.push(o)},N.prototype.removeEventListener=function(e,t,r){var i=this;(0,n.forEach)(i._handlers,(function(o,a){(0,n.remove)(o,(function(n){return M(e,a)&&M(t,n[0])&&M(r,n[1]||i)}))})),this._handlers=(0,n.omitBy)(i._handlers,(function(e){return 0===e.length}))},N.prototype.dispatchEvent=function(e){var t=this;(0,n.forEach)(this._handlers[e.type],(function(r){var n=r[1]||t;r[0].apply(n,[e])}))};var I={debug:0,info:1,report:2,warn:3,error:4};function O(){N.call(this),this.console=!1,this._priority=I.warn}function L(e){if(!(0,n.isNumber)(e))throw new Error("Wrong log level specified!");return e}O.prototype=Object.create(N.prototype),O.prototype.constructor=O,O.prototype.instantiate=function(){return new O},Object.defineProperty(O.prototype,"level",{get:function(){var e=this;return(0,n.findKey)(I,(function(t){return t===e._priority}))},set:function(e){this._priority=L(I[e])}}),O.prototype.levels=function(){return Object.keys(I)},O.prototype.message=function(e,t){var r=L(I[e]);this._message(r,t)},O.prototype.debug=function(e){this._message(I.debug,e)},O.prototype.info=function(e){this._message(I.info,e)},O.prototype.report=function(e){this._message(I.report,e)},O.prototype.warn=function(e){this._message(I.warn,e)},O.prototype.error=function(e){this._message(I.error,e)},O.prototype._message=function(e,t){if(!(e<this._priority)){var r=(0,n.findKey)(I,(function(t){return t===e}));if(t=String(t),this.console){var i="miew:".concat(r,": ").concat(t);"error"===r?console.error(i):"warn"===r?console.warn(i):console.log(i)}this.dispatchEvent({type:"message",level:r,message:t})}};var B=new O;var D={DEFAULT:0,SAFARI:1};function z(e){return decodeURIComponent(e.replace(/\+/g," "))}function F(e){for(var t,r=(e=e||window.location.search).substring(e.indexOf("?")+1),n=/([^&=]+)=?([^&]*)/g,i=[];null!==(t=n.exec(r));)i.push([z(t[1]),z(t[2])]);return i}function V(e){var t=!1;this.enable=function(e){t=e};var r=0,n=Object.keys(e);function i(e,n){return function(){var i=V.spaces.substr(0,2*r);t&&B.debug("".concat(i+n," {")),r++;for(var o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];var l=e.apply(this,a);return r--,t&&B.debug("".concat(i,"} // ").concat(n)),l}}for(var o=0,a=n.length;o<a;++o){var s=n[o],l=e[s];l instanceof Function&&"constructor"!==s&&(e[s]=i(l,s))}}V.spaces=" ";var U=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;return a(this,i),(t=n.call(this)).name="OutOfMemoryError",t.message=e,t}return l(i)}(T(Error));function G(e){for(var t=new Uint8Array(e),r="",n=0;n<t.byteLength;n++)r+=String.fromCharCode(t[n]);return window.btoa(r)}function j(e){for(var t=window.atob(e),r=new Uint8Array(t.length),n=0;n<r.length;++n)r[n]=t[n].charCodeAt(0);return r.buffer}function H(e){if((0,n.isPlainObject)(e))return!0;var t=e&&Object.getPrototypeOf(e);return!!t&&!t.hasOwnProperty("constructor")&&H(t)}function W(e){return e.slice(Math.max(0,e.lastIndexOf("."))||1/0)}function Y(e){var t=e.split(/[:;,]/),r=t.length;return r>=3&&"base64"===t[r-2]?new Blob([j(t[r-1])]):null}var X=/^[a-zA-Z0-9_]*$/,q=['"',"",'"'],$={browserType:D,encodeQueryComponent:function(e,t){return encodeURIComponent(e).replace(t,(function(e){return String.fromCharCode(parseInt(e.substr(1),16))})).replace(/%20/g,"+")},decodeQueryComponent:z,getUrlParameters:F,getUrlParametersAsDict:function(e){for(var t={},r=F(e),n=0;n<r.length;++n){var i=v(r[n],2),o=i[0],a=i[1];t[o]=a}return t},resolveURL:function(e){if("undefined"!=typeof URL)try{return"undefined"!=typeof window?new URL(e,window.location).href:new URL(e).href}catch(e){}if("undefined"!=typeof document){var t=document.createElement("a");return t.href=e,t.href}return e},generateRegExp:function(e){for(var t=[],r=0,n=e.length;r<n;++r)t[t.length]=e[r].charCodeAt(0).toString(16);var i=t.join("|");return new RegExp("%(?:".concat(i,")"),"gi")},createElement:function(e,t,r){var n,i,o=document.createElement(e);if(t){var a=Object.keys(t);for(n=0,i=a.length;n<i;++n){var s=a[n];o.setAttribute(s,t[s])}}if(r)for(r instanceof Array||(r=[r]),n=0,i=r.length;n<i;++n){var l=r[n];"string"==typeof l?o.appendChild(document.createTextNode(l)):l instanceof HTMLElement&&o.appendChild(l)}return o},deriveClass:function(e,t,r,i){return e.prototype=(0,n.assign)(Object.create(t.prototype),{constructor:e},r),i&&(0,n.assign)(e,i),e},deriveDeep:function e(t,r){var n,i,o=t;if(t instanceof Array)for(o=new Array(t.length),n=0,i=t.length;n<i;++n)o[n]=e(t[n]);else if(t instanceof Object){o=Object.create(t);var a=Object.keys(t);for(n=0,i=a.length;n<i;++n){var s=a[n],l=t[s],c=e(l);c!==l&&(o[s]=c)}r&&Object.keys(o).length>0&&(o=Object.create(o))}return o},hexColor:function(e){var t="0000000".concat(e.toString(16)).substr(-6);return"#".concat(t)},DebugTracer:V,OutOfMemoryError:U,allocateTyped:function(e,t){var r=null;try{r=new e(t)}catch(e){throw e instanceof RangeError?new U(e.message):e}return r},bytesFromBase64:j,bytesToBase64:G,arrayFromBase64:function(e,t){return Array.prototype.slice.call(new t(j(e)))},arrayToBase64:function(e,t){return G(new t(e).buffer)},compareOptionsWithDefaults:function(e,t){var r=[];if(t&&e){for(var n=Object.keys(e),i=0;i<n.length;++i){var o=n[i],a=e[o];a instanceof Object||void 0===t[o]||t[o]===a||r.push("".concat(o,":").concat(a))}if(r.length>0)return"!".concat(r.join())}return""},objectsDiff:function e(t,r){var i={};return(0,n.forIn)(t,(function(t,o){var a=r[o];if(H(t)&&H(a)){var s=e(t,a);(0,n.isEmpty)(s)||(i[o]=s)}else(0,n.isEqual)(t,a)||(i[o]=t)})),i},forInRecursive:function(e,t){!function e(r,i){(0,n.forIn)(r,(function(r,n){var o=i+(i.length>0?".":"");r instanceof Object?e(r,o+n):void 0!==r&&t(r,o+n)}))}(e,"")},enquoteString:function(e){return(0,n.isString)(e)?'"'.concat(e.replace(/"/g,'\\"'),'"'):e},unquoteString:function(e){if(!(0,n.isString)(e))return e;if('"'===e[0]&&'"'===e[e.length-1])return(e=e.slice(1,e.length-1)).replace(/\\"/g,'"');if("'"===e[0]&&"'"===e[e.length-1])return(e=e.slice(1,e.length-1)).replace(/\\'/g,"'");throw new SyntaxError("Incorrect string format, can't unqute it")},getBrowser:function(){return navigator.vendor&&navigator.vendor.indexOf("Apple")>-1&&navigator.userAgent&&-1===navigator.userAgent.indexOf("CriOS")&&-1===navigator.userAgent.indexOf("FxiOS")?D.SAFARI:D.DEFAULT},shotOpen:function(e){"undefined"!=typeof window&&window.open().document.write('<body style="margin:0"><img src="'.concat(e,'" /></body>'))},shotDownload:function(e,t){if(e&&"data:"===e.substr(0,5))if(t||(t=["screenshot-",+new Date,".png"].join("")),"undefined"!=typeof window&&window.navigator&&window.navigator.msSaveBlob)window.navigator.msSaveBlob(Y(e),t);else if("undefined"!=typeof document){var r=document.createElement("a");r.download=t,r.innerHTML="download",r.href=window.URL.createObjectURL(Y(e)),document.body.appendChild(r),r.click(),document.body.removeChild(r)}},copySubArrays:function(e,t,r,n){for(var i=0,o=r.length;i<o;++i)for(var a=0;a<n;++a)t[i*n+a]=e[r[i]*n+a]},shallowCloneNode:function(e){var t=e.cloneNode(!0);return t.worldPos=e.worldPos,t},correctSelectorIdentifier:function(e){return X.test(e)?e:(q[1]=e,q.join(""))},getFileExtension:W,splitFileName:function(e){var t=W(e);return[e.slice(0,e.length-t.length),t]},download:function(e,t,r){var n=new Blob([e]);if(t||(t=["data",+new Date].join("")),t+=r?".".concat(r):n.type||".bin","undefined"!=typeof window&&window.navigator&&window.navigator.msSaveBlob)window.navigator.msSaveBlob(n,t);else if("undefined"!=typeof document){var i=document.createElement("a");i.download=t,i.innerHTML="download",i.href=window.URL.createObjectURL(n),document.body.appendChild(i),i.click(),document.body.removeChild(i)}},concatTypedArraysUnsafe:function(e,t){var r=new e.constructor(e.length+t.length);return r.set(e),r.set(t,e.length),r},mergeTypedArraysUnsafe:function(e){if(e.length<=0)return null;for(var t=e.reduce((function(e,t){return e+t.length}),0),r=new e[0].constructor(t),n=0,i=0;n<e.length;n++){var o=e[n].length;r.set(e[n],i),i+=o}return r}};var Z=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;return a(this,i),(e=n.call(this))._shouldCancel=!1,e}return l(i,[{key:"cancel",value:function(){this._shouldCancel=!0,this.dispatchEvent({type:"cancel"})}},{key:"shouldCancel",value:function(){return this._shouldCancel}},{key:"notify",value:function(e){this.dispatchEvent({type:"notification",slaveEvent:e})}}]),i}(N),K={modes:{BS:{atom:.23,bond:.15,space:.5,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:3,low:4,medium:6,high:12,ultra:32}},VW:{polyComplexity:{poor:4,low:6,medium:8,high:16,ultra:32}},LN:{multibond:!0,showarom:!0,offsarom:.2,chunkarom:10,atom:.23,lineWidth:2},LC:{bond:.2,space:0,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:3,low:4,medium:6,high:12,ultra:32}},SA:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},SE:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},QS:{isoValue:.5,gaussLim:{poor:1.5,low:2,medium:2.5,high:3,ultra:4},scale:1,wireframe:!1,gridSpacing:{poor:2,low:1.5,medium:1,high:.5,ultra:.25},subset:"",zClip:!1},CS:{probeRadius:1.4,isoValue:1.5,wireframe:!1,probePositions:30,polyComplexity:{poor:.5,low:1,medium:1.5,high:1.75,ultra:2},subset:"",zClip:!1},TR:{radius:.3,polyComplexity:{poor:12,low:16,medium:32,high:64,ultra:64}},TU:{radius:.3,heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:4,low:6,medium:10,high:18,ultra:34}},CA:{radius:.3,depth:.25,ss:{helix:{width:1,arrow:2},strand:{width:1,arrow:2}},heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:4,low:6,medium:10,high:18,ultra:34}},TX:{template:"{{Chain}}.{{Residue}}{{Sequence}}.{{Name}}",horizontalAlign:"center",verticalAlign:"middle",dx:0,dy:0,dz:1,fg:"none",bg:"0x202020",showBg:!0},VD:{kSigma:1,kSigmaMed:2,kSigmaMax:4,frame:!0,isoMode:!1,polyComplexity:{poor:2,low:3,medium:4,high:8,ultra:10}}},colorers:{EL:{carbon:-1},UN:{color:16777215},CO:{subset:"charged",color:16711680,baseColor:16777215},CB:{color:9474192,factor:.6},SQ:{gradient:"rainbow"},TM:{gradient:"temp",min:5,max:40},OC:{gradient:"reds"},HY:{gradient:"blue-red"},MO:{gradient:"rainbow"}},antialias:!0,camFov:45,camNear:.5,camFar:100,camDistance:2.5,radiusToFit:1,fogNearFactor:.5,fogFarFactor:1,fogAlpha:1,fogColor:0,fogColorEnable:!1,palette:"JM",resolution:"medium",autoResolution:!1,autoPreset:!0,preset:"default",presets:{default:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],empty:[],wire:[{mode:"LN",colorer:"EL",selector:"all",material:"SF"}],small:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],macro:[{mode:"CA",colorer:"SS",selector:"not hetatm",material:"SF"},{mode:"BS",colorer:"EL",selector:"hetatm and not water",material:"SF"}]},objects:{line:{color:4294967295,dashSize:.3,gapSize:.05}},bg:{color:2105376,transparent:!1},draft:{clipPlane:!1,clipPlaneFactor:.5,clipPlaneSpeed:3e-5},plugins:{},axes:!0,fog:!0,fps:!0,zSprites:!0,isoSurfaceFakeOpacity:!0,suspendRender:!0,nowater:!1,autobuild:!0,fxaa:!0,outline:{on:!1,color:0,threshold:.1,thickness:1},ao:!1,shadow:{on:!1,type:"random",radius:1},autoRotation:0,maxfps:30,fbxprec:4,autoRotationAxisFixed:!0,zooming:!0,picking:!0,pick:"atom",editing:!1,aromatic:!1,singleUnit:!0,stereo:"NONE",interpolateViews:!0,transparency:"prepass",translationSpeed:2,debug:{example:3.5,text:"hello!",good:!0,ssaoKernelRadius:.7,ssaoFactor:.7,stereoBarrel:.25},use:{multiFile:!1}};function Q(){N.call(this),this.old=null,this.now={},this._changed={},this.reset()}$.deriveClass(Q,N,{defaults:K,set:function(e,t){if((0,n.isString)(e))(0,n.get)(this.now,e)!==t&&((0,n.set)(this.now,e,t),this._notifyChange(e,t));else{var r=$.objectsDiff(e,this.now);(0,n.isEmpty)(r)||((0,n.merge)(this.now,r),this._notifyChanges(r))}},get:function(e,t){return(0,n.get)(this.now,e,t)},reset:function(){var e=$.objectsDiff(K,this.now);this.now=(0,n.cloneDeep)(K),this.old=null,this._notifyChanges(e),this._changed={}},checkpoint:function(){this.old=(0,n.cloneDeep)(this.now),this._changed={}},_notifyChange:function(e,t){this._changed[e]=!0,this.dispatchEvent({type:"change:".concat(e),value:t})},_notifyChanges:function(e){var t=this;$.forInRecursive(e,(function(e,r){t._notifyChange(r,e)}))},changed:function(){if(!this.old)return[];var e=this.old,t=this.now;return(0,n.filter)(Object.keys(this._changed),(function(r){return(0,n.get)(e,r)!==(0,n.get)(t,r)}))},applyDiffs:function(e){if(e.hasOwnProperty("VERSION")&&0!==e.VERSION)throw new Error("Settings version does not match!");delete e.VERSION,this.reset(),this.set(e)},getDiffs:function(e){var t=$.objectsDiff(this.now,K);return e&&(t.VERSION=0),t},setPluginOpts:function(e,t){K.plugins[e]=(0,n.cloneDeep)(t),this.now.plugins[e]=(0,n.cloneDeep)(t)}});var J=new Q,ee=0;function te(e){return!(!e||"0"===e||(0,n.isString)(e)&&"false"===e.toLowerCase())}var re={string:String,number:Number,boolean:te},ne="!",ie=":",oe=",",ae="$;@/?",se=$.generateRegExp(ae+":,");function le(e){return $.encodeQueryComponent(e,se)}var ce=$.generateRegExp(ae+" ");function ue(e){return $.encodeQueryComponent(e,ce)}function he(e){var t=e.reps;if(!t){var r=J.now.presets,n=e.preset||J.now.preset;(t=r[n])||(B.warn('Unknown preset "'.concat(n,'"')),t=r[n=v(Object.keys(r),1)[0]]),e.preset=n,e.reps=$.deriveDeep(t,!0)}}function fe(e,t,r){he(e);var n=e.reps[ee];n.hasOwnProperty(t)&&(ee=e.reps.length,e.reps[ee]=$.deriveDeep(n,!0)),void 0!==r&&(e.reps[ee][t]=r)}function de(e,t,r){if(e){var i=e.indexOf(ne),a=function(e,t){var r=e.indexOf(",");return r>=0?(t.push(e.substr(r+1).split(",")),e.substr(0,r)):e}(e.substr(0,i>=0?i:void 0),r);if(i>=0){var s=e.substr(i+1).split(oe);if(e=a,t){var l=t[e],c=$.deriveDeep(l,!0);s.forEach((function(t){var r=t.split(ie,2),i=decodeURIComponent(r[0]),a=decodeURIComponent(r[1]),s=re[o((0,n.get)(l,i))];s?(0,n.set)(c,i,s(a)):B.warn('Unknown argument "'.concat(i,'" for option "').concat(e,'"'))})),Object.keys(c).length>0&&(e=[e,c])}}else e=a}return e}var pe={l:"load",load:String,t:"type",type:String,v:"view",view:String,u:"unit",unit:Number,menu:te,o:"object",object:function(e,t){var r=[],n=de(e,J.defaults.objects,r);Array.isArray(n)||(n=[n]),function(e,t,r){void 0===e._objects&&(e._objects=[]);var n=v(r,2),i=n[0],o=n[1],a={type:i,params:t};void 0!==o&&(a.opts=o),e._objects[e._objects.length]=a}(t,r[0],n)},p:"preset",preset:function(e,t){t.preset=e,t.reps=null,he(t)},r:"rep",rep:function(e,t){he(t),(ee=(ee=Number(e))<=t.reps.length?ee<0?0:ee:t.reps.length)===t.reps.length&&(t.reps[ee]=ee>0?$.deriveDeep(t.reps[ee-1],!0):$.deriveDeep(J.defaults.presets.default[0],!0))},s:"select",select:function(e,t){fe(t,"selector",e)},m:"mode",mode:function(e,t){fe(t,"mode",de(e,J.defaults.modes))},c:"color",color:function(e,t){fe(t,"colorer",de(e,J.defaults.colorers))},mt:"material",material:function(e,t){fe(t,"material",de(e,J.defaults.materials))},dup:function(e,t){he(t);var r=t.reps,n=r[ee];r[ee=r.length]=$.deriveDeep(n,!0)},ar:"autoResolution"};function me(e){ee=0;for(var t={},r=0,i=e.length;r<i;++r){var a=e[r],s=a[0],l=a[1];if(pe.hasOwnProperty(s)){for(var c=pe[s];(0,n.isString)(c);)c=pe[s=c];if("function"==typeof c){var u=c(l,t);void 0!==u&&(t[s]=u)}}else{var h=re[o((0,n.get)(J.defaults,s))];h?(0,n.set)(t,"settings.".concat(s),h(l)):B.warn('Unknown option "'.concat(s,'"'))}}return t}function ve(e){var t=[],r=0;return $.forInRecursive(e,(function(e,n){t[r++]=ue(n)+ie+ue(e)})),t.join(oe)}function ye(e){return(0,n.isArray)(e)?e.length<2?e[0]:"".concat(e[0]).concat(ne).concat(ve(e[1])):e}function _e(e){if(e&&e.type){var t=e.type;return(0,n.isArray)(e.params)&&e.params.length>0&&(t+=",".concat(e.params.join(","))),e.opts&&(t+=ne+ve(e.opts)),t}}function ge(e){var t=[],r=0;return $.forInRecursive(e,(function(e,n){t[r++]="".concat(n,"=").concat($.enquoteString(e))})),t.join(" ")}function xe(e){return(0,n.isArray)(e)?e.length<2?e[0]:"".concat(e[0]," ").concat(ge(e[1])):e}function be(e){if(e&&e.type){var t=e.type;return(0,n.isArray)(e.params)&&e.params.length>0&&(t+=" ".concat(e.params.map($.enquoteString).join(" "))),e.opts&&(t+=" ".concat(ge(e.opts))),t}}function we(e,t){var r=[],i=0;function o(e,t){null!=t&&(r[i++]=e+t)}return(0,n.isEmpty)(e)?null:(o("",t),o("s=",$.enquoteString(e.selector)),o("m=",xe(e.mode)),o("c=",xe(e.colorer)),o("mt=",xe(e.material)),r.join(" "))}var Se={fromURL:function(e){return me($.getUrlParameters(e))},fromAttr:function(e){return me($.getUrlParameters("?".concat(e||"")))},adapters:re,toURL:function(e){var t=[],r=0;function i(e,n){null!=n&&(t[r++]=le(e)+"="+le(n))}i("l",e.load),i("u",e.unit),i("p",e.preset),function(e){if(e)for(var t=0,r=e.length;t<r;++t)(0,n.isEmpty)(e[t])||(i("r",t),i("s",e[t].selector),i("m",ye(e[t].mode)),i("c",ye(e[t].colorer)),i("mt",ye(e[t].material)))}(e.reps),function(e){if(e)for(var t=0,r=e.length;t<r;++t)i("o",_e(e[t]))}(e._objects),i("v",e.view),$.forInRecursive(e.settings,(function(e,t){"preset"!==t&&i(t,e)}));var o="";if("undefined"!=typeof window){var a=window.location;o="".concat(a.protocol,"//").concat(a.host).concat(a.pathname)}return t.length>0&&(o+="?".concat(t.join("&"))),o},toScript:function(e){var t=[],r=0;function n(e,n,i){if(null!=n){var o="string"==typeof n&&i?'"':"";t[r++]="".concat(e," ").concat(o).concat(n).concat(o).trim()}}return n("set","autobuild false"),n("load",e.load,!0),n("unit",e.unit),n("preset",e.preset),function(e){if(e)for(var t=0,r=e.length;t<r;++t)n("rep",we(e[t],t))}(e.reps),function(e){if(e)for(var t=0,r=e.length;t<r;++t)n("",be(e[t]))}(e._objects),$.forInRecursive(e.settings,(function(e,t){"preset"!==t&&n("set ".concat(t),e,!0)})),n("view",e.view),n("set","autobuild true"),t.join("\n")}};function Re(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Ce=function(){function e(t,r,n,i,o,s,l,c,u,h,f){a(this,e),this.index=-1,this.residue=t,this.name=r,this.element=n,this.position=i,this.role=o,this.mask=1,this.het=s,this.serial=l,this.location=(c||" ").charCodeAt(0),this.occupancy=u||1,this.temperature=h,this.charge=f,this.hydrogenCount=-1,this.radicalCount=0,this.valence=-1,this.bonds=[],this.flags=0,"H"===n.name?this.flags|=e.Flags.HYDROGEN:"C"===n.name&&(this.flags|=e.Flags.CARBON)}return l(e,[{key:"isHet",value:function(){return this.het}},{key:"isHydrogen",value:function(){return 1===this.element.number}},{key:"getVisualName",value:function(){var e=this.name;return e.length>0?e:this.element.name.trim()}},{key:"forEachBond",value:function(e){for(var t=this.bonds,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"getFullName",value:function(){var e="";return null!==this.residue&&(null!==this.residue._chain&&(e+="".concat(this.residue._chain.getName(),".")),e+="".concat(this.residue._sequence,".")),e+this.name}}]),e}();Re(Ce,"Flags",{CARBON:1,HYDROGEN:8,NONPOLARH:4104});var Ae=l((function e(t,r,n,i,o,s,l){a(this,e),this.number=t,this.name=r,this.fullName=n,this.weight=i,this.radius=o,this.radiusBonding=s,this.hydrogenValency=l}));Re(Ae,"Constants",{U1:1,Lead:2,U2:3,Wing:4,U18:18}),Re(Ae,"Role",{N:Ae.Constants.U1,CA:Ae.Constants.Lead,C:Ae.Constants.U2,O:Ae.Constants.Wing,SG:Ae.Constants.U18}),Re(Ae,"ByAtomicNumber",[null,new Ae(1,"H","Hydrogen",1.008,1.2,.23,[1]),new Ae(2,"HE","Helium",4.003,1.4,.93,[0]),new Ae(3,"LI","Lithium",6.941,1.82,.68,[1]),new Ae(4,"BE","Beryllium",9.012,1.7,.35,[2]),new Ae(5,"B","Boron",10.81,2.08,.83,[3]),new Ae(6,"C","Carbon",12.011,1.95,.68,[4]),new Ae(7,"N","Nitrogen",14.007,1.85,.68,[3,5]),new Ae(8,"O","Oxygen",15.999,1.7,.68,[2,4]),new Ae(9,"F","Fluorine",18.998,1.73,.64,[1]),new Ae(10,"NE","Neon",20.18,1.54,1.12,[0]),new Ae(11,"NA","Sodium",22.99,2.27,.97,[1]),new Ae(12,"MG","Magnesium",24.305,1.73,1.1,[2]),new Ae(13,"AL","Aluminum",26.981,2.05,1.35,[3]),new Ae(14,"SI","Silicon",28.086,2.1,1.2,[4]),new Ae(15,"P","Phosphorus",30.974,2.08,.75,[3,5]),new Ae(16,"S","Sulfur",32.07,2,1.02,[2,4,6]),new Ae(17,"CL","Chlorine",35.453,1.97,.99,[1,3,5,7]),new Ae(18,"AR","Argon",39.948,1.88,1.57,[0]),new Ae(19,"K","Potassium",39.1,2.75,1.33,[1]),new Ae(20,"CA","Calcium",40.08,1.973,.99,[2]),new Ae(21,"SC","Scandium",44.956,1.7,1.44,[0]),new Ae(22,"TI","Titanium",47.88,1.7,1.47,[0]),new Ae(23,"V","Vanadium",50.941,1.7,1.33,[0]),new Ae(24,"CR","Chromium",52,1.7,1.35,[0]),new Ae(25,"MN","Manganese",54.938,1.7,1.35,[0]),new Ae(26,"FE","Iron",55.847,1.7,1.34,[0]),new Ae(27,"CO","Cobalt",58.93,1.7,1.33,[0]),new Ae(28,"NI","Nickel",58.69,1.63,1.5,[0]),new Ae(29,"CU","Copper",63.55,1.4,1.52,[0]),new Ae(30,"ZN","Zinc",65.39,1.39,1.45,[0]),new Ae(31,"GA","Gallium",69.72,1.87,1.22,[3]),new Ae(32,"GE","Germanium",72.61,1.7,1.17,[4]),new Ae(33,"AS","Arsenic",74.92,1.85,1.21,[3,5]),new Ae(34,"SE","Selenium",78.96,1.9,1.22,[2,4,6]),new Ae(35,"BR","Bromine",79.9,2.1,1.21,[1,3,5,7]),new Ae(36,"KR","Krypton",83.8,2.02,1.91,[0]),new Ae(37,"RB","Rubidium",85.47,1.7,1.47,[1]),new Ae(38,"SR","Strontium",87.62,1.7,1.12,[2]),new Ae(39,"Y","Yttrium",88.91,1.7,1.78,[0]),new Ae(40,"ZR","Zirconium",91.22,1.7,1.56,[0]),new Ae(41,"NB","Niobium",92.91,1.7,1.48,[0]),new Ae(42,"MO","Molybdenum",95.94,1.7,1.47,[0]),new Ae(43,"TC","Technetium",98.91,1.7,1.35,[0]),new Ae(44,"RU","Ruthenium",101.07,1.7,1.4,[0]),new Ae(45,"RH","Rhodium",102.91,1.7,1.45,[0]),new Ae(46,"PD","Palladium",106.42,1.63,1.5,[0]),new Ae(47,"AG","Silver",107.87,1.72,1.59,[0]),new Ae(48,"CD","Cadmium",112.41,1.58,1.69,[0]),new Ae(49,"IN","Indium",114.82,1.93,1.63,[3]),new Ae(50,"SN","Tin",118.71,2.17,1.46,[2,4]),new Ae(51,"SB","Antimony",121.75,2.2,1.46,[3,5]),new Ae(52,"TE","Tellurium",127.6,2.06,1.47,[2,4,6]),new Ae(53,"I","Iodine",126.91,2.15,1.4,[1,3,5,7]),new Ae(54,"XE","Xenon",131.29,2.16,1.98,[0]),new Ae(55,"CS","Cesium",132.91,1.7,1.67,[1]),new Ae(56,"BA","Barium",137.33,1.7,1.34,[2]),new Ae(57,"LA","Lanthanum",138.91,1.7,1.87,[0]),new Ae(58,"CE","Cerium",140.12,1.7,1.83,[0]),new Ae(59,"PR","Praseodymium",140.91,1.7,1.82,[0]),new Ae(60,"ND","Neodymium",144.24,1.7,1.81,[0]),new Ae(61,"PM","Promethium",144.9,1.7,1.8,[0]),new Ae(62,"SM","Samarium",150.36,1.7,1.8,[0]),new Ae(63,"EU","Europium",151.96,1.7,1.99,[0]),new Ae(64,"GD","Gadolinium",157.25,1.7,1.79,[0]),new Ae(65,"TB","Terbium",158.93,1.7,1.76,[0]),new Ae(66,"DY","Dysprosium",162.5,1.7,1.75,[0]),new Ae(67,"HO","Holmium",164.93,1.7,1.74,[0]),new Ae(68,"ER","Erbium",167.26,1.7,1.73,[0]),new Ae(69,"TM","Thulium",168.93,1.7,1.72,[0]),new Ae(70,"YB","Ytterbium",173.04,1.7,1.94,[0]),new Ae(71,"LU","Lutetium",174.97,1.7,1.72,[0]),new Ae(72,"HF","Hafnium",178.49,1.7,1.57,[0]),new Ae(73,"TA","Tantalum",180.95,1.7,1.43,[0]),new Ae(74,"W","Tungsten",183.85,1.7,1.37,[0]),new Ae(75,"RE","Rhenium",186.21,1.7,1.35,[0]),new Ae(76,"OS","Osmium",190.2,1.7,1.37,[0]),new Ae(77,"IR","Iridium",192.22,1.7,1.32,[0]),new Ae(78,"PT","Platinum",195.08,1.72,1.5,[0]),new Ae(79,"AU","Gold",196.97,1.66,1.5,[0]),new Ae(80,"HG","Mercury",200.59,1.55,1.7,[0]),new Ae(81,"TL","Thallium",204.38,1.96,1.55,[1,3]),new Ae(82,"PB","Lead",207.2,2.02,1.54,[2,4]),new Ae(83,"BI","Bismuth",208.98,1.7,1.54,[3,5]),new Ae(84,"PO","Polonium",210,1.7,1.68,[2,4,6]),new Ae(85,"AT","Astatine",210,1.7,1.7,[1,3,5,7]),new Ae(86,"RN","Radon",222,1.7,2.4,[0]),new Ae(87,"FR","Francium",223,1.7,2,[1]),new Ae(88,"RA","Radium",226.03,1.7,1.9,[2]),new Ae(89,"AC","Actinium",227.03,1.7,1.88,[0]),new Ae(90,"TH","Thorium",232.04,1.7,1.79,[0]),new Ae(91,"PA","Protactinium",231.04,1.7,1.61,[0]),new Ae(92,"U","Uranium",238.03,1.86,1.58,[0]),new Ae(93,"NP","Neptunium",237.05,1.7,1.55,[0]),new Ae(94,"PU","Plutonium",239.1,1.7,1.53,[0]),new Ae(95,"AM","Americium",243.1,1.7,1.51,[0]),new Ae(96,"CM","Curium",247.1,1.7,1.5,[0]),new Ae(97,"BK","Berkelium",247.1,1.7,1.5,[0]),new Ae(98,"CF","Californium",252.1,1.7,1.5,[0]),new Ae(99,"ES","Einsteinium",252.1,1.7,1.5,[0]),new Ae(100,"FM","Fermium",257.1,1.7,1.5,[0]),new Ae(101,"MD","Mendelevium",256.1,1.7,1.5,[0]),new Ae(102,"NO","Nobelium",259.1,1.7,1.5,[0]),new Ae(103,"LR","Lawrencium",260.1,1.7,1.5,[0]),new Ae(104,"RF","Rutherfordium",261,1.7,1.6,[0]),new Ae(105,"DB","Dubnium",262,1.7,1.6,[0]),new Ae(106,"SG","Seaborgium",263,1.7,1.6,[0]),new Ae(107,"BH","Bohrium",262,1.7,1.6,[0]),new Ae(108,"HS","Hassium",265,1.7,1.6,[0]),new Ae(109,"MT","Meitnerium",268,1.7,1.6,[0])]),Re(Ae,"ByName",{D:new Ae(1,"D","Deuterium",2.014,1.2,.23,[1]),T:new Ae(1,"T","Tritium",3.016,1.2,.23,[1])}),function(){for(var e=Ae.ByAtomicNumber,t=Ae.ByName,r=0,n=e.length;r<n;++r){var i=e[r];i&&(t[i.name]=i)}}(),Ae.getByName=function(e){var t=Ae.ByName[e];return t||(t=Ae.ByName[e]=new Ae(0,e,"Unknown",0,1,.01,[0])),t};var Ee={UNKNOWN:0,COVALENT:1,AROMATIC:2};function ke(e){return e.position}var Pe=function(){function e(t,r,n,i,o){if(a(this,e),this._left=t,this._right=r,this._fixed=o,this._index=-1,t>r)throw new Error("In a bond atom indices must be in increasing order");this._order=n,this._type=i}return l(e,[{key:"getLeft",value:function(){return this._left}},{key:"getRight",value:function(){return this._right}},{key:"getOrder",value:function(){return this._order}},{key:"calcLength",value:function(){return this._left.position.distanceTo(this._right.position)}},{key:"_forEachNeighbour",value:function(e,t){for(var r=e.bonds,n=0,i=r.length;n<i;++n)t(r[n]._left!==e?r[n]._left:r[n]._right)}},{key:"forEachLevelOne",value:function(e){var t=this._left,r=this._right;this._forEachNeighbour(t,(function(t){t!==r&&e(t)})),this._forEachNeighbour(r,(function(r){r!==t&&e(r)}))}},{key:"forEachLevelTwo",value:function(e){var t=this._left,r=this._right,n=this;n._forEachNeighbour(t,(function(i){i!==r&&n._forEachNeighbour(i,(function(r){r!==t&&e(r)}))})),n._forEachNeighbour(r,(function(i){i!==t&&n._forEachNeighbour(i,(function(t){t!==r&&e(t)}))}))}},{key:"_fixDir",value:function(e,t,r){var n=0,i=0,o=e.clone();function a(a){o.copy(r(a)),o.sub(e),t.dot(o)>0?++n:++i}function s(e){"C"===e.element.name&&a(e)}for(var l=[[this.forEachLevelOne,s],[this.forEachLevelOne,a],[this.forEachLevelTwo,s],[this.forEachLevelTwo,a]],c=0;c<l.length;++c){if(l[c][0].call(this,l[c][1]),i>n)return t.multiplyScalar(-1);if(i<n)return t}return t}},{key:"calcNormalDir",value:function(e){var t=this._left,r=this._right,n=t,i=r;e=void 0===e?ke:e,t.bonds.length>r.bonds.length&&(n=r,i=t);for(var o=n,a=0,s=i.bonds,l=0,c=s.length;l<c;++l){var u=s[l]._left;s[l]._left===i&&(u=s[l]._right),u.bonds.length>a&&u!==n&&(o=u,a=u.bonds.length)}var h=e(i),f=e(n).clone().sub(h),d=e(o).clone().sub(h);return d.crossVectors(f,d),d.lengthSq()<1e-4&&d.set(0,1,0),f.normalize(),d.normalize(),f.crossVectors(d,f),f.lengthSq()<1e-4&&f.set(0,1,0),f.normalize(),this._fixDir(h,f,e)}}]),e}();Re(Pe,"BondType",Ee),Pe.prototype.BondType=Ee;var Te=["C3'","C3*","P","H5T","H3T"],Me=["OP1","O1P"],Ne=["OP2","O2P"],Ie=["C3'","C3*","C1","C1'","C1*","P"],Oe=[{types:["A","DA","G","DG"],atoms:["N1"]},{types:["C","DC"],atoms:["N3"]},{types:["T","DT","U","DU"],atoms:["O4"]}],Le=function(){function e(t,r,n,i){a(this,e),this._chain=t,this._component=null,this._type=r,this._sequence=n,this._icode=i,this._mask=1,this._index=-1,this._atoms=[],this._secondary=null,this._firstAtom=null,this._leadAtom=null,this._wingAtom=null,this._lastAtom=null,this._controlPoint=null,this._midPoint=null,this._wingVector=null,this._cylinders=null,this._isValid=!0,this._het=!1,this._molecule=null,this.temperature=null,this.occupancy=null}return l(e,[{key:"getChain",value:function(){return this._chain}},{key:"getMolecule",value:function(){return this._molecule}},{key:"getType",value:function(){return this._type}},{key:"getSequence",value:function(){return this._sequence}},{key:"getSecondary",value:function(){return this._secondary}},{key:"getICode",value:function(){return this._icode}},{key:"addAtom",value:function(e,t,r,n,i,o,a,s,l,c){var u=new Ce(this,e,t,r,n,i,o,a,s,l,c);return this._chain.getComplex().addAtom(u),this._atoms.push(u),this._het=this._het||i,u}},{key:"getAtomCount",value:function(){return this._atoms.length}},{key:"forEachAtom",value:function(e){for(var t=this._atoms,r=0,n=t.length;r<n&&!e(t[r]);++r);}},{key:"_findAtomByName",value:function(e){var t=null;return this.forEachAtom((function(r){return r.name===e&&(t=r,!0)})),t}},{key:"_findFirstAtomInList",value:function(e){for(var t=null,r=0;r<e.length;++r)if(null!==(t=this._findAtomByName(e[r])))return t;return t}},{key:"collectMask",value:function(){for(var e=4294967295,t=this._atoms,r=0,n=t.length;r<n;++r)e&=t[r].mask;this._mask=e}},{key:"getCylinderTargetList",value:function(){for(var e=this._type._name,t=0,r=Oe.length;t<r;++t)for(var n=0,i=Oe[t].types.length;n<i;++n)if(e===Oe[t].types[n])return Oe[t].atoms;return null}},{key:"_detectLeadWing",value:function(e,t,r){var n=this._findFirstAtomInList(Te),i=this._findFirstAtomInList(Me),o=this._findFirstAtomInList(Ne);if(null===i&&null!==t&&(i=t._findFirstAtomInList(Me)),null===o&&null!==t&&(o=t._findFirstAtomInList(Ne)),null!==n&&null!==i&&null!==o){e._leadAtom=n,e._controlPoint=r(n),e._wingVector=r(o).clone().sub(r(i)),e._isValid=!0;var a=this._findFirstAtomInList(Ie),s=this.getCylinderTargetList(),l=null!==s?this._findFirstAtomInList(s):null;null!==a&&null!==l&&(e._cylinders=[r(a),r(l)])}}},{key:"calcWing",value:function(e,t,r,n){var i=t.clone().sub(e),o=e.clone().sub(r);return o.crossVectors(i,o),o.crossVectors(i,o).normalize(),null!==n&&n.length()>1e-4&&o.length()>1e-4&&Math.abs(n.angleTo(o))>Math.PI/2&&o.negate(),o}},{key:"_innerFinalize",value:function(e,t,r,n,o,a){var s=null===t,l=a(this._leadAtom),c=new i.Pa4(l.x,l.y,l.z);if(o)this._detectLeadWing(n,r,a);else{if(s)n._midPoint=a(this._firstAtom).clone();else{var u=t._controlPoint;n._midPoint=u.clone().lerp(c,.5),n._wingVector=this.calcWing(u,c,a(e._wingAtom),t._wingVector)}n._controlPoint=c}}},{key:"_finalize2",value:function(e,t,r){this._innerFinalize(e,e,t,this,r,(function(e){return e.position}))}},{key:"isConnected",value:function(e){if(this._chain!==e._chain)return!1;if(this===e)return!0;var t=!1;return this.forEachAtom((function(r){for(var n=r.bonds,i=0,o=n.length;i<o;++i){var a=n[i];if(a._left.residue===e||a._right.residue===e)return t=!0,!0}return!1})),t}},{key:"_finalize",value:function(){var e=this,t=v(this._atoms,1);this._firstAtom=t[0],this._lastAtom=this._atoms[this._atoms.length-1],this._leadAtom=null,this._wingAtom=null;var r=0,n=0,i=0,o=0;this.forEachAtom((function(t){return null===e._leadAtom&&t.role===Ae.Constants.Lead&&(e._leadAtom=t),null===e._wingAtom&&t.role===Ae.Constants.Wing&&(e._wingAtom=t),t.temperature&&(n+=t.temperature,r++),t.occupancy&&(o+=t.occupancy,i++),null!==e._leadAtom&&null!==e._wingAtom})),r>0&&(this.temperature=n/r),i>0&&(this.occupancy=o/i),null!==this._leadAtom&&null!==this._wingAtom||(this._isValid=!1),null===this._leadAtom&&(this._leadAtom=this._firstAtom),null===this._wingAtom&&(this._wingAtom=this._lastAtom)}}]),e}(),Be=function(){function e(t,r,n){a(this,e),this._name=t,this._fullName=r,this.letterCode=n,this.flags=0}return l(e,[{key:"getName",value:function(){return this._name}}]),e}();function De(e,t){for(var r=0,n=t.length;r<n;++r){var i=Be.StandardTypes[t[r]];i&&(i.flags|=e)}}Re(Be,"StandardTypes",{ALA:new Be("ALA","Alanine","A"),ARG:new Be("ARG","Arginine","R"),ASN:new Be("ASN","Asparagine","N"),ASP:new Be("ASP","Aspartic Acid","D"),CYS:new Be("CYS","Cysteine","C"),GLN:new Be("GLN","Glutamine","Q"),GLU:new Be("GLU","Glutamic Acid","E"),GLY:new Be("GLY","Glycine","G"),HIS:new Be("HIS","Histidine","H"),ILE:new Be("ILE","Isoleucine","I"),LEU:new Be("LEU","Leucine","L"),LYS:new Be("LYS","Lysine","K"),MET:new Be("MET","Methionine","M"),PHE:new Be("PHE","Phenylalanine","F"),PRO:new Be("PRO","Proline","P"),PYL:new Be("PYL","Pyrrolysine","O"),SEC:new Be("SEC","Selenocysteine","U"),SER:new Be("SER","Serine","S"),THR:new Be("THR","Threonine","T"),TRP:new Be("TRP","Tryptophan","W"),TYR:new Be("TYR","Tyrosine","Y"),VAL:new Be("VAL","Valine","V"),A:new Be("A","Adenine","A"),C:new Be("C","Cytosine","C"),G:new Be("G","Guanine","G"),I:new Be("I","Inosine","I"),T:new Be("T","Thymine","T"),U:new Be("U","Uracil","U"),DA:new Be("DA","Adenine","A"),DC:new Be("DC","Cytosine","C"),DG:new Be("DG","Guanine","G"),DI:new Be("DI","Inosine","I"),DT:new Be("DT","Thymine","T"),DU:new Be("DU","Uracil","U"),"+A":new Be("+A","Adenine","A"),"+C":new Be("+C","Cytosine","C"),"+G":new Be("+G","Guanine","G"),"+I":new Be("+I","Inosine","I"),"+T":new Be("+T","Thymine","T"),"+U":new Be("+U","Uracil","U"),WAT:new Be("WAT","Water",""),H2O:new Be("H2O","Water",""),HOH:new Be("HOH","Water",""),DOD:new Be("DOD","Water",""),UNK:new Be("UNK","Unknown",""),UNL:new Be("UNL","Unknown Ligand","")}),Re(Be,"Flags",{PROTEIN:1,BASIC:2,ACIDIC:4,POLAR:8,NONPOLAR:16,AROMATIC:32,NUCLEIC:256,PURINE:512,PYRIMIDINE:1024,DNA:2048,RNA:4096,WATER:65536});var ze=Be.Flags;De(ze.WATER,["WAT","H2O","HOH","DOD"]),De(ze.PROTEIN,["ALA","ARG","ASN","ASP","CYS","GLY","GLU","GLN","HIS","ILE","LEU","LYS","MET","PHE","PRO","PYL","SEC","SER","THR","TRP","TYR","VAL"]),De(ze.BASIC,["ARG","HIS","LYS"]),De(ze.ACIDIC,["ASP","GLU"]),De(ze.POLAR,["ASN","CYS","GLN","SER","THR","TYR"]),De(ze.NONPOLAR,["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL","GLY"]),De(ze.AROMATIC,["PHE","TRP","TYR"]),De(ze.NUCLEIC,["A","G","I","DA","DG","DI","+A","+G","+I","C","T","U","DC","DT","DU","+C","+T","+U"]),De(ze.PURINE,["A","G","I","DA","DG","DI","+A","+G","+I"]),De(ze.PYRIMIDINE,["C","T","U","DC","DT","DU","+C","+T","+U"]),De(ze.DNA,["DA","DG","DI","DC","DT","DU"]),De(ze.RNA,["A","G","I","C","T","U"]),function(e,t){for(var r=Object.keys(t),n=0,i=r.length;n<i;++n){var o=r[n],a=t[o];Be.StandardTypes[o].hydrophobicity=a}}(0,{ILE:4.5,VAL:4.2,LEU:3.8,PHE:2.8,CYS:2.5,MET:1.9,ALA:1.8,GLY:-.4,THR:-.7,SER:-.8,TRP:-.9,TYR:-1.3,PRO:-1.6,HIS:-3.2,GLU:-3.5,GLN:-3.5,ASP:-3.5,ASN:-3.5,LYS:-3.9,ARG:-4.5});var Fe,Ve=function(){function e(t,r){a(this,e),this._complex=t,this._name=r,this._mask=1,this._index=-1,this._residues=[],this.minSequence=Number.POSITIVE_INFINITY,this.maxSequence=Number.NEGATIVE_INFINITY}return l(e,[{key:"getComplex",value:function(){return this._complex}},{key:"getName",value:function(){return this._name}},{key:"getResidues",value:function(){return this._residues}},{key:"_determineType",value:function(){var e=this._residues,t=Be.Flags,r=t.PROTEIN,n=t.NUCLEIC;this.type=0;for(var i=0,o=e.length;i<o;++i){var a=e[i]._type.flags;if(0!=(a&n)){this.type=2;break}if(0!=(a&r)){this.type=1;break}}}},{key:"findResidue",value:function(e,t){for(var r=this._residues,n=0,i=r.length;n<i;++n){var o=r[n];if(o._sequence===e&&o._icode===t)return[o,n]}return null}},{key:"_finalize",value:function(){this._determineType();for(var e=this._residues,t=null,r=0,n=e.length;r<n;++r){var o=r+1<n?e[r+1]:null,a=e[r];a._finalize2(t,o,2===this.type),t=a}if(e.length>1&&e[1]._wingVector){var s=e[1]._wingVector;e[0]._wingVector=new i.Pa4(s.x,s.y,s.z)}else e.length>0&&(e[0]._wingVector=new i.Pa4(1,0,0))}},{key:"updateToFrame",value:function(e){var t=this._residues,r=null,n=null,o=e._residues,a=t.length;function s(t){return e.getAtomPos(t.index)}for(var l=0;l<a;++l){var c=t[l],u=o[c._index],h=l+1<a?t[l+1]:null;c._innerFinalize(r,n,h,u,2===this.type,s),r=c,n=u}o[t[0]._index]._wingVector=a>1?o[t[1]._index]._wingVector:new i.Pa4(1,0,0)}},{key:"addResidue",value:function(e,t,r){var n=this._complex.getResidueType(e);null===n&&(n=this._complex.addResidueType(e));var i=new Le(this,n,t,r);return this._complex.addResidue(i),this._residues.push(i),n.flags&(Be.Flags.NUCLEIC|Be.Flags.PROTEIN)&&(this.maxSequence<t&&(this.maxSequence=t),this.minSequence>t&&(this.minSequence=t)),i}},{key:"getResidueCount",value:function(){return this._residues.length}},{key:"forEachResidue",value:function(e){for(var t=this._residues,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"collectMask",value:function(){for(var e=4294967295,t=this._residues,r=0,n=t.length;r<n;++r)e&=t[r]._mask;this._mask=e}}]),e}(),Ue=function(){function e(t,r,n){a(this,e),this.type=t,this.generic=e.genericByType[this.type]||"loop",this.init=r,this.term=n}return l(e,[{key:"_finalize",value:function(e,t,r){if(!(this.init instanceof Le&&this.term instanceof Le)){for(var n=r.splitUnifiedSerial(this.init),i=r.splitUnifiedSerial(this.term),o=n.chain;o<=i.chain;o++)for(var a=n.serial;a<=i.serial;a++)for(var s=n.iCode;s<=i.iCode;s++){var l=r.getUnifiedSerial(o,a,s);t[l]&&(t[l]._secondary=this)}this.init=t[this.init],this.term=t[this.term]}}}]),e}();Ue.Type={STRAND:"E",BRIDGE:"B",HELIX_310:"G",HELIX_ALPHA:"H",HELIX_PI:"I",HELIX:"X",TURN_310:"3",TURN_ALPHA:"4",TURN_PI:"5",TURN:"T",BEND:"S",COIL:"C"},Ue.Generic={STRAND:"strand",HELIX:"helix",LOOP:"loop"};var Ge=Ue.Type,je=Ue.Generic;Ue.genericByType=(Re(Fe={},Ge.STRAND,je.STRAND),Re(Fe,Ge.HELIX_310,je.HELIX),Re(Fe,Ge.HELIX_ALPHA,je.HELIX),Re(Fe,Ge.HELIX_PI,je.HELIX),Re(Fe,Ge.HELIX,je.HELIX),Fe);var He=Ue.Type,We={1:He.HELIX_ALPHA,3:He.HELIX_PI,5:He.HELIX_310},Ye=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,s,l,c){var u;return a(this,i),(u=n.call(this,We[e]||Ue.Type.HELIX,t,r)).serial=o,u.name=s,u.comment=l,u.length=c,u}return l(i)}(Ue);function Xe(){return Xe="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},Xe.apply(this,arguments)}var qe=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,s,l){var c;return a(this,i),(c=n.call(this,Ue.Type.STRAND,t,r)).sheet=e,c.sense=o,c.atomCur=s,c.atomPrev=l,c}return l(i,[{key:"_finalize",value:function(e,t,r){Xe(d(i.prototype),"_finalize",this).call(this,e,t,r);var n=this.atomCur;null===n||Number.isNaN(n)||(this.atomCur=e[n]),null===(n=this.atomPrev)||Number.isNaN(n)||(this.atomPrev=e[n])}}]),i}(Ue),$e=function(){function e(t,r){a(this,e),this._name=t,this._width=r,this._strands=[]}return l(e,[{key:"getName",value:function(){return this._name}},{key:"getWidth",value:function(){return this._width}},{key:"addStrand",value:function(e){this._strands.push(e),this._width=this._strands.length}},{key:"addEmptyStrand",value:function(){this._strands.push(new qe(null,null,null,null,null,null))}},{key:"_finalize",value:function(e,t,r){for(var n=this._strands,i=0,o=n.length;i<o;++i)n[i]._finalize(e,t,r);if(this._width||(this._width=n.length),n.length!==this._width)throw new Error("Sheet ".concat(this._name," is inconsistent."))}}]),e}(),Ze=function(){function e(t,r,n,o,s){a(this,e),this._id=t,this._name=r,this._position=n||new i.Pa4,this._atoms=o||[],this._charge=0,this._repeat=1,this._center=null,this.xmlNodeRef=s||null}return l(e,[{key:"getName",value:function(){return this._name}},{key:"getPosition",value:function(){return this._position}},{key:"getCentralPoint",value:function(){return this._center}},{key:"_rebuildSGroupOnAtomChange",value:function(){var e=1e8;if(null!==this._center){for(var t=new i.Pa4(e,e,e),r=new i.Pa4(-e,-e,-e),n=0,o=this._atoms.length;n<o;n++){var a=this._atoms[n].position;t.set(Math.min(t.x,a.x),Math.min(t.y,a.y),Math.min(t.z,a.z)),r.set(Math.max(r.x,a.x),Math.max(r.y,a.y),Math.max(r.z,a.z))}this._center.addVectors(t,r),this._center.multiplyScalar(.5)}}}]),e}(),Ke="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self?self:{},Qe=function(){var e=function(e,t,r,n){for(r=r||{},n=e.length;n--;r[e[n]]=t);return r},t=[1,4],r=[1,5],n=[1,6],i=[1,7],o=[1,8],a=[1,9],s=[1,11],l=[1,12],c=[5,7,8,11],u=[1,17],h=[1,22],f=[1,20],d=[1,21],p=[5,7,8,11,19],m={trace:function(){},yy:{},symbols_:{error:2,Program:3,Expression:4,EOF:5,Selector:6,OR:7,AND:8,NOT:9,"(":10,")":11,SELECTOR:12,NAMED_SELECTOR:13,SELECTOR_RANGED:14,RangeList:15,SELECTOR_NAMED:16,NameList:17,Range:18,",":19,NUMBER:20,":":21,Name:22,IDENTIFIER:23,STRING:24,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",7:"OR",8:"AND",9:"NOT",10:"(",11:")",12:"SELECTOR",13:"NAMED_SELECTOR",14:"SELECTOR_RANGED",16:"SELECTOR_NAMED",19:",",20:"NUMBER",21:":",23:"IDENTIFIER",24:"STRING"},productions_:[0,[3,2],[4,1],[4,3],[4,3],[4,2],[4,3],[6,1],[6,1],[6,2],[6,2],[15,1],[15,3],[18,1],[18,3],[17,1],[17,3],[22,1],[22,1],[22,1]],performAction:function(e,t,r,n,i,o,a){var s=o.length-1;switch(i){case 1:return o[s-1];case 3:this.$=n.keyword("or")(o[s-2],o[s]);break;case 4:this.$=n.keyword("and")(o[s-2],o[s]);break;case 5:this.$=n.keyword("not")(o[s]);break;case 6:this.$=o[s-1];break;case 7:this.$=n.keyword(o[s])();break;case 8:this.$=n.GetSelector(o[s].toLowerCase().slice(1,o[s].length));break;case 9:case 10:this.$=n.keyword(o[s-1])(o[s]);break;case 11:this.$=new n.RangeList(o[s]);break;case 12:case 16:this.$=o[s-2].append(o[s]);break;case 13:this.$=new n.Range(Number(o[s]));break;case 14:this.$=new n.Range(Number(o[s-2]),Number(o[s]));break;case 15:this.$=new n.ValueList(o[s])}},table:[{3:1,4:2,6:3,9:t,10:r,12:n,13:i,14:o,16:a},{1:[3]},{5:[1,10],7:s,8:l},e(c,[2,2]),{4:13,6:3,9:t,10:r,12:n,13:i,14:o,16:a},{4:14,6:3,9:t,10:r,12:n,13:i,14:o,16:a},e(c,[2,7]),e(c,[2,8]),{15:15,18:16,20:u},{17:18,20:h,22:19,23:f,24:d},{1:[2,1]},{4:23,6:3,9:t,10:r,12:n,13:i,14:o,16:a},{4:24,6:3,9:t,10:r,12:n,13:i,14:o,16:a},e(c,[2,5]),{7:s,8:l,11:[1,25]},e(c,[2,9],{19:[1,26]}),e(p,[2,11]),e(p,[2,13],{21:[1,27]}),e(c,[2,10],{19:[1,28]}),e(p,[2,15]),e(p,[2,17]),e(p,[2,18]),e(p,[2,19]),e([5,7,11],[2,3],{8:l}),e(c,[2,4]),e(c,[2,6]),{18:29,20:u},{20:[1,30]},{20:h,22:31,23:f,24:d},e(p,[2,12]),e(p,[2,14]),e(p,[2,16])],defaultActions:{10:[2,1]},parseError:function(e,t){if(!t.recoverable){var r=new Error(e);throw r.hash=t,r}this.trace(e)},parse:function(e){var t=[0],r=[],n=[null],i=[],o=this.table,a="",s=0,l=0,c=i.slice.call(arguments,1),u=Object.create(this.lexer),h={yy:{}};for(var f in this.yy)Object.prototype.hasOwnProperty.call(this.yy,f)&&(h.yy[f]=this.yy[f]);u.setInput(e,h.yy),h.yy.lexer=u,h.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var d=u.yylloc;i.push(d);var p=u.options&&u.options.ranges;"function"==typeof h.yy.parseError?this.parseError=h.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var m,v,y,_,g,x,b,w,S,R={};;){if(v=t[t.length-1],this.defaultActions[v]?y=this.defaultActions[v]:(null==m&&(S=void 0,"number"!=typeof(S=r.pop()||u.lex()||1)&&(S instanceof Array&&(S=(r=S).pop()),S=this.symbols_[S]||S),m=S),y=o[v]&&o[v][m]),void 0===y||!y.length||!y[0]){var C;for(g in w=[],o[v])this.terminals_[g]&&g>2&&w.push("'"+this.terminals_[g]+"'");C=u.showPosition?"Parse error on line "+(s+1)+":\n"+u.showPosition()+"\nExpecting "+w.join(", ")+", got '"+(this.terminals_[m]||m)+"'":"Parse error on line "+(s+1)+": Unexpected "+(1==m?"end of input":"'"+(this.terminals_[m]||m)+"'"),this.parseError(C,{text:u.match,token:this.terminals_[m]||m,line:u.yylineno,loc:d,expected:w})}if(y[0]instanceof Array&&y.length>1)throw new Error("Parse Error: multiple actions possible at state: "+v+", token: "+m);switch(y[0]){case 1:t.push(m),n.push(u.yytext),i.push(u.yylloc),t.push(y[1]),m=null,l=u.yyleng,a=u.yytext,s=u.yylineno,d=u.yylloc;break;case 2:if(x=this.productions_[y[1]][1],R.$=n[n.length-x],R._$={first_line:i[i.length-(x||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(x||1)].first_column,last_column:i[i.length-1].last_column},p&&(R._$.range=[i[i.length-(x||1)].range[0],i[i.length-1].range[1]]),void 0!==(_=this.performAction.apply(R,[a,l,s,h.yy,y[1],n,i].concat(c))))return _;x&&(t=t.slice(0,-1*x*2),n=n.slice(0,-1*x),i=i.slice(0,-1*x)),t.push(this.productions_[y[1]][0]),n.push(R.$),i.push(R._$),b=o[t[t.length-2]][t[t.length-1]],t.push(b);break;case 3:return!0}}return!0}},v=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;o<i.length;o++)if((r=this._input.match(this.rules[i[o]]))&&(!t||r[0].length>t[0].length)){if(t=r,n=o,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,i[o])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,i[n]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(e,t,r,n){switch(r){case 0:break;case 1:return 20;case 2:return 7;case 3:return 8;case 4:return 9;case 5:return 12;case 6:return 16;case 7:return 14;case 8:return 10;case 9:return 11;case 10:return 19;case 11:return 21;case 12:return"<=";case 13:return">=";case 14:return"<";case 15:return">";case 16:return t.yytext=t.yytext.substr(1,t.yyleng-2),24;case 17:return 13;case 18:return 23;case 19:return 5;case 20:return"INVALID"}},rules:[/^(?:\s+)/i,/^(?:(-?(?:[1-9][0-9]+|[0-9]))\b)/i,/^(?:OR\b)/i,/^(?:AND\b)/i,/^(?:NOT\b)/i,/^(?:((ALL|NONE|HETATM|PROTEIN|BASIC|ACIDIC|CHARGED|POLAR|NONPOLAR|AROMATIC|NUCLEIC|PURINE|PYRIMIDINE|WATER|POLARH|NONPOLARH))\b)/i,/^(?:((NAME|ELEM|TYPE|RESIDUE|ICODE|CHAIN|ALTLOC))\b)/i,/^(?:((SERIAL|SEQUENCE|RESIDX))\b)/i,/^(?:\()/i,/^(?:\))/i,/^(?:,)/i,/^(?::)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:((?:"(?:\\.|[^\\"])*"|'(?:\\.|[^\\'])*')))/i,/^(?:(@[_A-Z0-9]+))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],inclusive:!0}}};return e}();function y(){this.yy={}}return m.lexer=v,y.prototype=m,m.Parser=y,new y}(),Je={parser:Qe};function et(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var tt=function(){function e(t,r){a(this,e),this.min=t,this.max=void 0===r?t:r}return l(e,[{key:"includes",value:function(e){return this.min<=e&&e<=this.max}},{key:"toString",value:function(){var e=this.min,t=this.max;return e===t?String(e):[e,t].join(":")}},{key:"toJSON",value:function(){return[this.min,this.max]}}]),e}(),rt=function(){function e(t){if(a(this,e),t instanceof this.constructor)return t;this._values=t instanceof Array?t.slice(0):t?[t]:[]}return l(e,[{key:"append",value:function(e){var t=this._values;return t[t.length]=e,this}},{key:"remove",value:function(e){var t=this._values,r=t.indexOf(e);return r>=0&&t.splice(r,1),this}},{key:"toString",value:function(){return this._values.join(",")}},{key:"toJSON",value:function(){for(var e=this._values,t=[],r=0,n=e.length;r<n;++r){var i=e[r];t[r]=i.toJSON?i.toJSON():i}return t}}]),e}(),nt=function(e){h(r,e);var t=et(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includes",value:function(e){for(var t=this._values,r=0,n=t.length;r<n;++r)if(t[r].includes(e))return!0;return!1}}]),r}(rt),it=[],ot=function(e){h(r,e);var t=et(r);function r(e,n){var i;a(this,r);var o=i=t.call(this,e);if(n){i.upperOnly=!0;for(var s=o._values,l=0,c=s.length;l<c;++l){var u=s[l];"string"==typeof u&&(s[l]=u.toUpperCase())}}else i.upperOnly=!1;return f(i,o)}return l(r,[{key:"includes",value:function(e){return-1!==this._values.indexOf(e)}},{key:"toString",value:function(){var e=this._values;it.length=0;for(var t=0,r=e.length;t<r;++t)it[t]=$.correctSelectorIdentifier(String(e[t]));return it.join(",")}},{key:"_validate",value:function(e){return this.upperOnly&&"string"==typeof e?e.toUpperCase():e}},{key:"append",value:function(e){return Xe(d(r.prototype),"append",this).call(this,this._validate(e)),this}},{key:"remove",value:function(e){return Xe(d(r.prototype),"remove",this).call(this,this._validate(e)),this}}]),r}(rt);function at(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var st=function(){function e(){a(this,e)}return l(e,[{key:"toString",value:function(){return this.keyword}},{key:"toJSON",value:function(){return[this.name]}}]),e}();st.prototype.name="Error",st.prototype.keyword="error";var lt=function(e){h(r,e);var t=at(r);function r(e){var n;return a(this,r),(n=t.call(this)).list=e,n}return l(r,[{key:"toString",value:function(){return"".concat(this.keyword," ").concat(this.list)}},{key:"toJSON",value:function(){return[this.name,this.list.toJSON()]}}]),r}(st),ct=function(e){h(r,e);var t=at(r);function r(e){return a(this,r),t.call(this,new nt(e))}return l(r)}(lt),ut=function(e){h(r,e);var t=at(r);function r(e,n){return a(this,r),t.call(this,new ot(e,!n))}return l(r)}(lt),ht=function(e){h(r,e);var t=at(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return!1}}]),r}(st);ht.prototype.name="None",ht.prototype.keyword="none";var ft=function(e){h(r,e);var t=at(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return!0}}]),r}(st);function dt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}ft.prototype.name="All",ft.prototype.keyword="all";var pt=new ht,mt=function(e){h(r,e);var t=dt(r);function r(e){var n;return a(this,r),(n=t.call(this)).rhs=e||pt,n}return l(r,[{key:"toString",value:function(){var e=this.rhs.priority&&this.rhs.priority>this.priority?"(".concat(this.rhs,")"):this.rhs;return"".concat(this.keyword," ").concat(e)}},{key:"toJSON",value:function(){return[this.name,this.rhs.toJSON()]}}]),r}(st);mt.prototype.priority=1;var vt=function(e){h(r,e);var t=dt(r);function r(e,n){var i;return a(this,r),(i=t.call(this)).lhs=e||pt,i.rhs=n||pt,i}return l(r,[{key:"toString",value:function(){var e=this.lhs.priority&&this.lhs.priority>this.priority?"(".concat(this.lhs,")"):this.lhs,t=this.rhs.priority&&this.rhs.priority>this.priority?"(".concat(this.rhs,")"):this.rhs;return"".concat(e," ").concat(this.keyword," ").concat(t)}},{key:"toJSON",value:function(){return[this.name,this.lhs.toJSON(),this.rhs.toJSON()]}}]),r}(st);function yt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}vt.prototype.priority=1e3;var _t={};function gt(e,t){var r=e.toLowerCase();t.prototype.keyword=r,t.prototype.name=e;var n=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return P(t,r)};return n.SelectorClass=t,_t[r]=n,t}gt("Serial",function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.serial)}}]),r}(ct)),gt("Name",function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.name)}}]),r}(ut)),gt("AltLoc",function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(String.fromCharCode(e.location))}}]),r}(ut)),gt("Elem",function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.element.name)}}]),r}(ut)),gt("Residue",function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.residue._type._name)}}]),r}(ut)),gt("Sequence",function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.residue._sequence)}}]),r}(ct)),gt("ICode",function(e){h(r,e);var t=yt(r);function r(e){return a(this,r),t.call(this,e,!0)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.residue._icode)}}]),r}(ut)),gt("ResIdx",function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.residue._index)}}]),r}(ct)),gt("Chain",function(e){h(r,e);var t=yt(r);function r(e){return a(this,r),t.call(this,e,!0)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.residue._chain._name)}}]),r}(ut)),gt("Hetatm",function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return e.het}}]),r}(st)),gt("PolarH",function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return(e.flags&Ce.Flags.NONPOLARH)===Ce.Flags.HYDROGEN}}]),r}(st)),gt("NonPolarH",function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return(e.flags&Ce.Flags.NONPOLARH)===Ce.Flags.NONPOLARH}}]),r}(st)),gt("All",ft),gt("None",ht);var xt=_t.none();function bt(e,t,r){return r.prototype.priority=t,gt(e,r)}function wt(e,t){return gt(t,function(t){h(n,t);var r=yt(n);function n(){return a(this,n),r.apply(this,arguments)}return l(n,[{key:"includesAtom",value:function(t){return 0!=(t.residue._type.flags&e)}}]),n}(st))}bt("Not",1,function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return!this.rhs.includesAtom(e)}}]),r}(mt)),bt("And",2,function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.lhs.includesAtom(e)&&this.rhs.includesAtom(e)}}]),r}(vt)),bt("Or",3,function(e){h(r,e);var t=yt(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.lhs.includesAtom(e)||this.rhs.includesAtom(e)}}]),r}(vt)),wt(Be.Flags.PROTEIN,"Protein"),wt(Be.Flags.BASIC,"Basic"),wt(Be.Flags.ACIDIC,"Acidic"),wt(Be.Flags.BASIC|Be.Flags.ACIDIC,"Charged"),wt(Be.Flags.POLAR,"Polar"),wt(Be.Flags.NONPOLAR,"NonPolar"),wt(Be.Flags.AROMATIC,"Aromatic"),wt(Be.Flags.NUCLEIC,"Nucleic"),wt(Be.Flags.PURINE,"Purine"),wt(Be.Flags.PYRIMIDINE,"Pyrimidine"),wt(Be.Flags.WATER,"Water");var St=Object.create(_t);St.Selector=st,St.RangeListSelector=ct,St.ValueListSelector=ut,St.Range=tt,St.RangeList=nt,St.ValueList=ot,St.PrefixOperator=mt,St.InfixOperator=vt,St.Context=Object.create({}),St.GetSelector=function(e){if(!St.Context.hasOwnProperty(e))throw{message:"selector ".concat(e," is not registered")};return St.Context[e]||xt},St.ClearContext=function(){Object.keys(St.Context).forEach((function(e){delete St.Context[e]}))},St.keyword=function(e){return _t[e.toLowerCase()]||_t.none},St.parse=function(e){var t={};try{t.selector=Je.parser.parse(e)}catch(e){t.selector=xt,t.error=e.message}return t},Je.parser.yy=St,Je.parser.yy.parseError=Je.parser.parseError;var Rt=function(){function e(t){a(this,e),this._complex=t,this._selector=St.keyword("All")(),this._boundaries={boundingBox:new i.ZzF,boundingSphere:new i.aLr}}return l(e,[{key:"computeBoundaries",value:function(){var e=this._complex._atoms,t=e.length,r=this._selector,n=this._boundaries.boundingBox;if(n.makeEmpty(),1===t){n.expandByPoint(e[0].position);var o=new i.Pa4;n.getCenter(o);var a=2*e[0].element.radius;n.setFromCenterAndSize(o,new i.Pa4(a,a,a))}else for(var s=0;s<t;++s)r.includesAtom(e[s])&&n.expandByPoint(e[s].position);var l=0,c=new i.Pa4;if(n.getCenter(c),1===t)this._boundaries.boundingSphere.set(c,e[0].element.radius);else{for(var u=0;u<t;++u)if(r.includesAtom(e[u])){var h=e[u].position,f=c.distanceToSquared(h);l<f&&(l=f)}this._boundaries.boundingSphere.set(c,Math.sqrt(l))}}},{key:"getTransforms",value:function(){return[]}},{key:"getSelector",value:function(){return this._selector}},{key:"getBoundaries",value:function(){return this._boundaries}},{key:"finalize",value:function(){}}]),e}();var Ct=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;return a(this,o),(t=n.call(this,e)).chains=[],t.matrices=[],t}return l(o,[{key:"computeBoundaries",value:function(){Xe(d(o.prototype),"computeBoundaries",this).call(this);var e=this.matrices,t=this._boundaries.boundingSphere.center,r=this._boundaries.boundingSphere.radius,n=this._boundaries.boundingBox=new i.ZzF;n.makeEmpty();for(var a=0,s=e.length;a<s;++a)n.expandByPoint(t.clone().applyMatrix4(e[a]));var l=n.max.distanceTo(n.min)/2+r,c=new i.Pa4;n.getCenter(c),this._boundaries.boundingSphere=(new i.aLr).set(c,l),n.max.addScalar(r),n.min.subScalar(r)}},{key:"addChain",value:function(e){this.chains[this.chains.length]=e}},{key:"addMatrix",value:function(e){this.matrices[this.matrices.length]=e}},{key:"getTransforms",value:function(){return this.matrices}},{key:"finalize",value:function(){this.chains.length>0?this._selector=St.keyword("Chain")(this.chains):this._selector=St.keyword("None")()}}]),o}(Rt),At=function(){function e(t){a(this,e),this._complex=t,this._index=-1,this._residueIndices=[],this._cycles=[],this._subDivs=[],this._residueCount=0}return l(e,[{key:"getResidues",value:function(){return this._complex._residues}},{key:"getResidueCount",value:function(){return this._residueCount}},{key:"forEachResidue",value:function(e){for(var t=this._complex._residues,r=this._residueIndices,n=0,i=r.length;n<i;++n)for(var o=r[n].start,a=r[n].end;o<=a;++o)e(t[o])}},{key:"setSubDivs",value:function(e){this._subDivs=e;for(var t=0,r=[],n=0,i=0,o=e.length;i<o;++i)if(i===o-1||e[i].end+1!==e[i+1].start){var a=e[t].start,s=e[i].end;r[r.length]={start:a,end:s},n+=s-a+1,t=i+1}this._residueIndices=r,this._residueCount=n}},{key:"getComplex",value:function(){return this._complex}},{key:"forEachBond",value:function(e){for(var t=this._complex._bonds,r=0,n=t.length;r<n;++r){var i=t[r];i._left.residue._component===this&&e(i)}}},{key:"update",value:function(){this.forEachCycle((function(e){e.update()}))}},{key:"forEachAtom",value:function(e){this.forEachResidue((function(t){t.forEachAtom(e)}))}},{key:"addCycle",value:function(e){this._cycles.push(e)}},{key:"forEachCycle",value:function(e){for(var t=this._cycles,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"markResidues",value:function(){var e=this;e.forEachResidue((function(t){t._component=e}))}},{key:"_forEachSubChain",value:function(e,t){for(var r=this._complex._residues,n=this._subDivs,i=0,o=n.length;i<o;++i)for(var a=n[i].start,s=n[i].end;a<=s;++a){var l=r[a];if(e&l._mask&&l._isValid){for(var c=a+1;c<=s;++c){var u=r[c];if(!(e&u._mask&&u._isValid))break}t(i,a,c-1),a=c}}}},{key:"getMaskedSequences",value:function(e){var t=[],r=0;return this._forEachSubChain(e,(function(e,n,i){t[r++]={start:n,end:i}})),t}},{key:"getMaskedSubdivSequences",value:function(e){var t=[],r=-1,n=-1,i=this._subDivs;return this._forEachSubChain(e,(function(e,o,a){n!==e&&(++r,t[r]={arr:[],boundaries:i[e]},n=e),t[r].arr[t[r].arr.length]={start:o,end:a}})),t}}]),e}(),Et=function(){function e(t){a(this,e),this.numPairs=0,this.numMaxPairs=t,this.intBuffer=$.allocateTyped(Int32Array,4*t);for(var r=0;r<4*t;r++)this.intBuffer[r]=-1;this.hashBuffer=$.allocateTyped(Int32Array,33554432);for(var n=0;n<33554432;n++)this.hashBuffer[n]=-1}return l(e,[{key:"destroy",value:function(){this.intBuffer=null,this.hashBuffer=null}},{key:"addPair",value:function(e,t){for(var r=e<t?e:t,n=e>t?e:t,i=r+(n<<14),o=32*(r+89237*n&1048575),a=0;a<32;a++){var s=this.hashBuffer[o+a];if(-1===s)break;if(s===i)return!1}if(a>=32)throw new Error("addPair: increase cMaxPairsForHashCode");if(this.hashBuffer[o+a]=i,this.numPairs>=this.numMaxPairs)throw new Error("addPair: increase num pairs");return o=4*this.numPairs,this.intBuffer[o]=r,this.intBuffer[o+1]=n,this.intBuffer[o+2]=i,this.numPairs++,!0}}]),e}();function kt(e){var t=e.element;if(t)return t.radiusBonding;throw new Error("_getBondingRadius: Logic error.")}var Pt,Tt,Mt,Nt=function(){function e(t){a(this,e),this._complex=t,this._maxRad=1.8;var r=this._complex.getDefaultBoundaries().boundingBox;this._vBoxMin=r.min.clone(),this._vBoxMax=r.max.clone(),this._pairCollection=null}return l(e,[{key:"_addExistingPairs",value:function(){for(var e=this._complex.getAtoms(),t=e.length,r=0,n=this._pairCollection;r<t;r++)for(var i=e[r].bonds,o=i.length,a=0;a<o;a++){var s=i[a];s._left.index===r&&n.addPair(r,s._right.index)}return 0}},{key:"_findPairs",value:function(){var e=this._complex.getVoxelWorld();if(null!==e)for(var t,r,n,i,o,a,s=this._complex._atoms,l=s.length,c=this,u=function(e){if(!r||!e.isHydrogen()){var a=e.location;if(32===i||32===a||i===a){var s=n.distanceToSquared(e.position),l=e.element.radiusBonding,u=t+l+.45;s>u*u||s<.001||c._pairCollection.addPair(o.index,e.index)}}},h=0;h<l;++h)(!(a=o=s[h]).isHet()||a.bonds&&0===a.bonds.length)&&(t=o.element.radiusBonding,r=o.isHydrogen(),n=o.position,i=o.location,e.forEachAtomWithinRadius(n,2*this._maxRad+.45,u))}},{key:"_addPairs",value:function(){for(var e=this._complex._atoms,t=0,r=0;t<this._pairCollection.numPairs;t++,r+=4){var n=this._pairCollection.intBuffer[r],i=this._pairCollection.intBuffer[r+1];this._addPair(e[n],e[i])}}},{key:"_addPair",value:function(e,t){for(var r=e.bonds,n=e.index,i=t.index,o=0,a=r.length;o<a;++o){var s=r[o];if(s._left.index===i||s._right.index===i)return}var l=n<i?e:t,c=n<i?t:e,u=this._complex.addBond(l,c,0,Pe.BondType.UNKNOWN,!1);r.push(u),t.bonds.push(u)}},{key:"build",value:function(){this._buildInner()}},{key:"_buildInner",value:function(){var e=this._complex._atoms;if(!(e.length<2)){if(e[0].index<0)throw new Error("AutoBond: Atoms in complex were not indexed.");this._calcBoundingBox(),this._pairCollection=new Et(4*e.length),this._addExistingPairs(),this._findPairs(),this._addPairs()}}},{key:"_calcBoundingBox",value:function(){for(var e=this._complex._atoms,t=e.length,r=kt(e[0]),n=1;n<t;++n)r=Math.max(r,kt(e[n]));this._vBoxMax.addScalar(r),this._vBoxMin.addScalar(-r),this._maxRad=1.2*r}},{key:"destroy",value:function(){this._pairCollection&&this._pairCollection.destroy()}}]),e}(),It=Pe.BondType.AROMATIC,Ot=[Ae.ByName.C.number,Ae.ByName.N.number],Lt=(Pt=new i.Pa4,Tt=new i.Pa4,Mt=new i.Pa4,function(e,t){return Pt.copy(e).normalize(),Tt.copy(t).normalize(),Mt.crossVectors(Pt,Tt),!(Mt.length()>.1)&&Pt.dot(Tt)>=0});function Bt(e,t){for(var r=0;r<e.length&&e[r]<t;)++r;e.splice(r,0,t)}function Dt(e,t){return e._left===t?e._right:e._left}function zt(e){e._type=It}var Ft=function(){function e(t){a(this,e),this.atoms=t,this.update()}return l(e,[{key:"update",value:function(){for(var e=this.atoms,t=new i.Pa4,r=e.length,n=0;n<r;++n)t.add(e[n].position);t.multiplyScalar(1/r),this.center=t,this.radius=t.distanceTo(e[0].position.clone().lerp(e[1].position,.5))}},{key:"forEachBond",value:function(e){var t,r=this.atoms,n=r.length,i=r[0];function o(r){r._left!==t&&r._right!==t||e(r)}for(var a=0;a<n;++a)t=r[(a+1)%n],i.forEachBond(o),i=t}}]),e}();function Vt(e){return e._type===It}function Ut(e){if(e.type===It)return!0;var t=Ot.indexOf(e._right.element.number),r=Ot.indexOf(e._left.element.number);return-1!==t&&-1!==r}function Gt(e){return e.length>3}function jt(e){return console.assert(e.length>2),!0}var Ht=function(){function e(t){a(this,e),this._complex=t;for(var r=new Array(t._bonds.length),n=new Array(t._bonds.length),i=0,o=r.length;i<o;++i)r[i]=[],n[i]=!1;this._bondsData=r,this._bondMarks=n,this._resetCycles()}return l(e,[{key:"_resetCycles",value:function(){this._cycles=[],this._currIdx=-1}},{key:"_haveSameCycle",value:function(e,t,r){for(var n=e[t._index],i=e[r._index],o=n.length,a=i.length,s=0,l=0;s<o&&l<a;){if(n[s]===i[l])return!0;n[s]>i[l]?++l:++s}return!1}},{key:"_tryBond",value:function(e,t,r){var n=[],o=this._bondsData,a=Dt(e,t),s=t.position.clone().sub(a.position),l=this._currStart,c=this,u=this._bondMarks,h=this._checkBond;u[e._index]=!0,h=void 0===h?Vt:h,t.forEachBond((function(a){if(h(a)&&a!==e&&!u[a._index]&&!c._haveSameCycle(o,e,a)){var f,d,p,m=Dt(a,t),v=m.position.clone().sub(t.position),y=m===l?-2:1-(d=v,p=(f=s).dot(d)/Math.sqrt(f.lengthSq()*d.lengthSq()),i.M8C.clamp(p,-1,1)),_=v.cross(s);if(Lt(_,r)){for(var g=0;g<n.length&&n[g].val<y;)++g;n.splice(g,0,{bond:a,val:y,dir:_})}}}));for(var f=0,d=n.length;f<d;++f){var p=n[f].bond,m=p._left===t?p._right:p._left;if(m===l)return++this._currIdx,this._cycles.push([t]),u[e._index]=!1,!0;if(this._tryBond(p,m,n[f].dir))return Bt(o[p._index],this._currIdx),this._cycles[this._currIdx].push(t),u[e._index]=!1,!0}return u[e._index]=!1,!1}},{key:"_startCycle",value:function(e){this._currStart=e._left,this._tryBond(e,e._right,new i.Pa4)&&(Bt(this._bondsData[e._index],this._currIdx),this._cycles[this._currIdx].push(e._left))}},{key:"_findLoops",value:function(e,t){this._checkBond=e;var r=this._complex,n=this;r.forEachComponent((function(r){n._resetCycles(),r.forEachBond((function(t){e(t)&&n._startCycle(t)}));for(var i=n._cycles,o=0,a=i.length;o<a;++o){var s=i[o];if(t(s)){var l=new Ft(s);l.forEachBond(zt),r.addCycle(l)}}}))}},{key:"markCycles",value:function(){this._findLoops(Vt,Gt)}},{key:"detectCycles",value:function(){this._findLoops(Ut,jt)}}]),e}();function Wt(e,t,r,n){var i=r-e.z,o=n-e.z,a=Math.sqrt(Math.max(t*t-i*i,0)),s=Math.sqrt(Math.max(t*t-o*o,0));return[Math.min(a,s),r<=e.z&&n>=e.z?t:Math.max(a,s)]}function Yt(e,t,r,n){var i=r-e.y,o=n-e.y,a=Math.sqrt(Math.max(t*t-i*i,0)),s=Math.sqrt(Math.max(t*t-o*o,0));return[Math.min(a,s),r<=e.y&&n>=e.y?t:Math.max(a,s)]}var Xt=function(){function e(t,r){a(this,e),this._box=t.clone();var n=new i.Pa4;t.getSize(n),this._count=n.clone().divide(r).floor().max(new i.Pa4(1,1,1)),this._last=this._count.clone().subScalar(1),this._cellSize=n.clone().divide(this._count),this._cellInnerR=.5*Math.min(Math.min(this._cellSize.x,this._cellSize.y),this._cellSize.z),this._cellOuterR=.5*Math.sqrt(this._cellSize.dot(this._cellSize));var o=this._count.x*this._count.y*this._count.z;this._voxels=$.allocateTyped(Int32Array,o);for(var s=0;s<o;++s)this._voxels[s]=-1;this._atoms=[]}return l(e,[{key:"addAtoms",value:function(e){var t=this,r=this._atoms.length;this._atoms.length+=2*e.getAtomCount(),e.forEachAtom((function(e){var n=t._findVoxel(e.position);t._atoms[r]=e,t._atoms[r+1]=t._voxels[n],t._voxels[n]=r,r+=2}))}},{key:"_findVoxel",value:function(t){var r=e._zero,n=e._voxel;return n.copy(t).sub(this._box.min).divide(this._cellSize).floor().clamp(r,this._last),n.x+this._count.x*(n.y+this._count.y*n.z)}},{key:"_forEachAtomInVoxel",value:function(e,t){for(var r=this._voxels[e];r>=0;r=this._atoms[r+1])t(this._atoms[r])}},{key:"_forEachVoxelWithinRadius",value:function(t,r,n){var i=e._xRange,o=e._yRange,a=e._zRange;if(r/this._cellInnerR<10)this._forEachVoxelWithinRadiusSimple(t,r,n);else{var s,l,c,u,h,f,d,p;a.set(t.z-r,t.z+r),a.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0,this._count.z-1);for(var m=a.x;m<=a.y;++m){h=[this._box.min.z+m*this._cellSize.z,this._box.min.z+(m+1)*this._cellSize.z],p=t.z-r<=h[0]&&h[1]<=t.z+r,s=Wt(t,r,h[0],h[1]),o.set(t.y-s[1],t.y+s[1]),o.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0,this._count.y-1);for(var v=o.x;v<=o.y;++v){u=[this._box.min.y+v*this._cellSize.y,this._box.min.y+(v+1)*this._cellSize.y],d=t.y-s[0]<=u[0]&&u[1]<=t.y+s[0],l=Yt(t,s[1],u[0],u[1]),i.set(t.x-l[1],t.x+l[1]),i.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0,this._count.x-1);for(var y=i.x;y<=i.y;++y)c=[this._box.min.x+y*this._cellSize.x,this._box.min.x+(y+1)*this._cellSize.x],f=t.x-l[0]<=c[0]&&c[1]<=t.x+l[0],n(y+this._count.x*(v+this._count.y*m),f&&d&&p)}}}}},{key:"_forEachVoxelWithinRadiusSimple",value:function(t,r,n){var i=e._xRange,o=e._yRange,a=e._zRange,s=e._vCenter,l=(r+this._cellOuterR)*(r+this._cellOuterR),c=-1;r>this._cellOuterR&&(c=(r-this._cellOuterR)*(r-this._cellOuterR)),i.set(t.x-r,t.x+r),i.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor(),i.x=Math.min(Math.max(i.x,0),this._count.x-1),i.y=Math.min(Math.max(i.y,0),this._count.x-1),o.set(t.y-r,t.y+r),o.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor(),o.x=Math.min(Math.max(o.x,0),this._count.y-1),o.y=Math.min(Math.max(o.y,0),this._count.y-1),a.set(t.z-r,t.z+r),a.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor(),a.x=Math.min(Math.max(a.x,0),this._count.z-1),a.y=Math.min(Math.max(a.y,0),this._count.z-1);for(var u=a.x;u<=a.y;++u){var h=[this._box.min.z+u*this._cellSize.z,this._box.min.z+(u+1)*this._cellSize.z];s.z=.5*(h[0]+h[1]);for(var f=o.x;f<=o.y;++f){var d=[this._box.min.y+f*this._cellSize.y,this._box.min.y+(f+1)*this._cellSize.y];s.y=.5*(d[0]+d[1]);for(var p=i.x;p<=i.y;++p){var m=[this._box.min.x+p*this._cellSize.x,this._box.min.x+(p+1)*this._cellSize.x];s.x=.5*(m[0]+m[1]);var v=t.distanceToSquared(s);v<=l&&n(p+this._count.x*(f+this._count.y*u),v<=c)}}}}},{key:"forEachAtomWithinRadius",value:function(e,t,r){var n=this,i=t*t;n._forEachVoxelWithinRadius(e,t,(function(t,o){o?n._forEachAtomInVoxel(t,r):n._forEachAtomInVoxel(t,(function(t){e.distanceToSquared(t.position)<=i&&r(t)}))}))}},{key:"forEachAtomWithinDistFromMasked",value:function(e,t,r,n){this._forEachAtomWithinDistFromGroup((function(r){e.forEachAtom((function(e){0!=(e.mask&t)&&r(e)}))}),r,n)}},{key:"forEachAtomWithinDistFromSelected",value:function(e,t,r,n){this._forEachAtomWithinDistFromGroup((function(r){e.forEachAtom((function(e){t.includesAtom(e)&&r(e)}))}),r,n)}},{key:"_forEachAtomWithinDistFromGroup",value:function(e,t,r){var n,i=this,o=t*t,a=[],s=[],l=0;e((function(e){i._forEachVoxelWithinRadius(e.position,t,(function(t,r){r?a[t]=-1:void 0===a[t]?(s.push(e),s.push(-1),a[t]=l,l+=2):-1!==a[t]&&(s.push(e),s.push(a[t]),a[t]=l,l+=2)}))}));var c=function(e){if(void 0!==a[n])if(-1!==(l=a[n])){for(;l>=0;l=s[l+1])if(e.position.distanceToSquared(s[l].position)<o){r(e);break}}else r(e)};for(n in a)a.hasOwnProperty(n)&&i._forEachAtomInVoxel(n,c)}}]),e}();Re(Xt,"_zero",new i.Pa4(0,0,0)),Re(Xt,"_voxel",new i.Pa4),Re(Xt,"_xRange",new i.FM8),Re(Xt,"_yRange",new i.FM8),Re(Xt,"_zRange",new i.FM8),Re(Xt,"_vCenter",new i.Pa4);var qt=.5,$t=-9.9,Zt=-27.888,Kt=function(){function e(t){a(this,e),this._complex=t,this._hbonds=[],this._complex._residues.length>1e3?this._buildVW():this._build()}return l(e,[{key:"isBond",value:function(e,t){if(this._hbonds[e]){var r=v(this._hbonds[e].acceptor,2),n=r[0],i=r[1];if(n&&n.residue===t&&n.energy<-.5)return!0;if(i&&i.residue===t&&i.energy<-.5)return!0}return!1}},{key:"_build",value:function(){for(var e=0;e<this._complex._residues.length-1;++e){var t=this._complex._residues[e];if(0!=(t.getType().flags&Be.Flags.PROTEIN)){var r=null;e>0&&this._complex._residues[e-1].getType().flags&Be.Flags.PROTEIN&&t._sequence===this._complex._residues[e-1]._sequence+1&&(r=this._complex._residues[e-1]);for(var n=e+1;n<this._complex._residues.length;++n){var i=this._complex._residues[n];if(0!=(i.getType().flags&Be.Flags.PROTEIN)){var o=null;this._complex._residues[n-1].getType().flags&Be.Flags.PROTEIN&&i._sequence===this._complex._residues[n-1]._sequence+1&&(o=this._complex._residues[n-1]),this._calcHBondEnergy(r,t,i),n!==e+1&&this._calcHBondEnergy(o,i,t)}}}}}},{key:"_buildVW",value:function(){var e,t,r=this,n=this._complex._residues,i=this._complex.getVoxelWorld();if(null!==i)for(var o=new Et(this._complex._residues.length*this._complex._residues.length/2),a=0;a<n.length-1;++a)0!=((e=n[a]).getType().flags&Be.Flags.PROTEIN)&&(!(t=a>0?n[a-1]:null)||0!=(t.getType().flags&Be.Flags.PROTEIN)&&e._sequence===t._sequence+1||(t=null),i.forEachAtomWithinRadius(this._residueGetCAlpha(e),5,s));function s(i){var a=i.residue;if(a._index!==e._index&&0!=(a.getType().flags&Be.Flags.PROTEIN)&&o.addPair(e._index,a._index)){var s=a._index>0?n[a._index-1]:null;!s||0!=(s.getType().flags&Be.Flags.PROTEIN)&&a._sequence===s._sequence+1||(s=null),r._calcHBondEnergy(t,e,a),a._index!==e._index+1&&r._calcHBondEnergy(s,a,e)}}}},{key:"_residueGetCAlpha",value:function(e){for(var t=0;t<e._atoms.length;++t){var r=e._atoms[t].name;if("CA"===r||"C1"===r)return e._atoms[t].position}return null}},{key:"_residueGetCO",value:function(e){var t=null,r=null;return e.forEachAtom((function(e){"C"===e.name?t=e.position:"O"===e.name&&(r=e.position)})),[t,r]}},{key:"_residueGetNH",value:function(e,t){var r,n=v(this._residueGetCO(e),2),i=n[0],o=n[1];if(t.forEachAtom((function(e){"N"===e.name&&(r=e.position)})),i&&o&&r){var a=i.clone();return a.sub(o),a.multiplyScalar(1/a.length()),a.add(r),[r,a]}return[null,null]}},{key:"_calcHBondEnergy",value:function(e,t,r){var n=0;if(null===e)return n;if("PRO"!==t.getType().getName()){var i=v(this._residueGetNH(e,t),2),o=i[0],a=i[1],s=v(this._residueGetCO(r),2),l=s[0],c=s[1];if(null===o||null===a||null===l||null===c)return n;var u=a.distanceTo(c),h=a.distanceTo(l),f=o.distanceTo(l),d=o.distanceTo(c);n=u<qt||h<qt||f<qt||d<qt?$t:Zt/u-Zt/h+Zt/f-Zt/d,(n=Math.round(1e3*n)/1e3)<$t&&(n=$t)}void 0===this._hbonds[t._index]&&(this._hbonds[t._index]={donor:[],acceptor:[]});var p=this._hbonds[t._index];p.acceptor.length<2&&p.acceptor.push({residue:r._index,energy:n}),p.acceptor.length>1&&(n<p.acceptor[0].energy?(p.acceptor[1].residue=p.acceptor[0].residue,p.acceptor[1].energy=p.acceptor[0].energy,p.acceptor[0].residue=r._index,p.acceptor[0].energy=n):n<p.acceptor[1].energy&&(p.acceptor[1].residue=r._index,p.acceptor[1].energy=n)),void 0===this._hbonds[r._index]&&(this._hbonds[r._index]={donor:[],acceptor:[]});var m=this._hbonds[r._index];return m.donor.length<2&&m.donor.push({residue:t._index,energy:n}),m.donor.length>1&&(n<m.donor[0].energy?(m.donor[1].residue=m.donor[0].residue,m.donor[1].energy=m.donor[0].energy,m.donor[0].residue=t._index,m.donor[0].energy=n):n<m.donor[1].energy&&(m.donor[1].residue=t._index,m.donor[1].energy=n)),n}}]),e}();function Qt(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Jt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Jt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Jt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var er,tr,rr=Object.freeze({NO_BRIDGE:0,PARALLEL:1,ANTI_PARALLEL:2}),nr=Object.freeze({START:1,MIDDLE:2,END:3,START_AND_END:4}),ir=Object.freeze({STRAND:"E",BRIDGE:"B",HELIX_310:"G",HELIX_ALPHA:"H",HELIX_PI:"I",TURN:"T",BEND:"S",LOOP:" "}),or=function(){function e(t){a(this,e),this._complex=t,this._build()}return l(e,[{key:"_build",value:function(){this._hbonds=new Kt(this._complex),this._ss=[],this._sheet=[],this._betaPartners=[],this._bend=[];for(var e=0;e<this._complex.getResidues().length;++e)this._betaPartners[e]=[];this._helixFlags=[],this._helixFlags[3]=[],this._helixFlags[4]=[],this._helixFlags[5]=[],this._chainLengths=[];for(var t=0;t<this._complex._chains.length;++t){for(var r=this._complex._chains[t].getResidues(),n=0;n<r.length&&0!=(r[n].getType().flags&Be.Flags.PROTEIN);++n);this._chainLengths[t]=n}this._buildBetaSheets();for(var i=0;i<this._complex._chains.length;++i)this._buildAlphaHelices(this._complex._chains[i].getResidues(),this._chainLengths[i],!1)}},{key:"_buildAlphaHelices",value:function(e,t,r){for(var n=3;n<=5&&!(e.length<n);++n)for(var i=0;i+n<t;++i)if(this._hbonds.isBond(e[i+n]._index,e[i]._index)){this._helixFlags[n][e[i+n]._index]=nr.END;for(var o=i+1;o<i+n;++o)void 0===this._helixFlags[n][e[o]._index]&&(this._helixFlags[n][e[o]._index]=nr.MIDDLE);this._helixFlags[n][e[i]._index]===nr.END?this._helixFlags[n][e[i]._index]=nr.START_AND_END:this._helixFlags[n][e[i]._index]=nr.START}for(var a=2;a<t-2;++a){var s=this._kappa(e[a-2],e[a],e[a+2]);this._bend[e[a]._index]=360!==s&&s>70}for(var l=1;l+4<t;++l)if(this._isHelixStart(e[l]._index,4)&&this._isHelixStart(e[l-1]._index,4))for(var c=l;c<=l+3;++c)this._ss[e[c]._index]=ir.HELIX_ALPHA;for(var u=1;u+3<t;++u)if(this._isHelixStart(e[u]._index,3)&&this._isHelixStart(e[u-1]._index,3)){for(var h=!0,f=u;h&&f<=u+2;++f)h=void 0===this._ss[e[f]._index]||this._ss[e[f]._index]===ir.HELIX_310;if(h)for(var d=u;d<=u+2;++d)this._ss[e[d]._index]=ir.HELIX_310}for(var p=1;p+5<t;++p)if(this._isHelixStart(e[p]._index,5)&&this._isHelixStart(e[p-1]._index,5)){for(var m=!0,v=p;m&&v<=p+4;++v)m=void 0===this._ss[e[v]._index]||this._ss[e[v]._index]===ir.HELIX_PI||r&&this._ss[e[v]._index]===ir.HELIX_ALPHA;if(m)for(var y=p;y<=p+4;++y)this._ss[e[y]._index]=ir.HELIX_PI}for(var _=1;_+1<t;++_)if(void 0===this._ss[e[_]._index]){for(var g=!1,x=3;x<=5&&!g;++x)for(var b=1;b<x&&!g;++b)g=_>=b&&this._isHelixStart(e[_-b]._index,x);g?this._ss[e[_]._index]=ir.TURN:this._bend[e[_]._index]&&(this._ss[e[_]._index]=ir.BEND)}}},{key:"_residueGetCAlpha",value:function(e){for(var t=0;t<e._atoms.length;++t){var r=e._atoms[t].name;if("CA"===r||"C1"===r)return e._atoms[t].position}return null}},{key:"_cosinusAngle",value:function(e,t,r,n){var i=e.clone().sub(t),o=r.clone().sub(n),a=0,s=i.dot(i)*o.dot(o);return s>0&&(a=i.dot(o)/Math.sqrt(s)),a}},{key:"_kappa",value:function(e,t,r){var n=this._residueGetCAlpha(t),i=this._residueGetCAlpha(e),o=this._residueGetCAlpha(r);if(null===n||null===i||null===o)return 180;var a=this._cosinusAngle(n,i,o,n),s=Math.sqrt(1-a*a);return 180*Math.atan2(s,a)/Math.PI}},{key:"_isHelixStart",value:function(e,t){return this._helixFlags[t][e]===nr.START||this._helixFlags[t][e]===nr.START_AND_END}},{key:"_buildBetaSheets",value:function(){for(var e=[],t=0;t<this._complex._chains.length;++t){var r=this._chainLengths[t];if(!(r<=4))for(var n=this._complex._chains[t].getResidues(),i=t;i<this._complex._chains.length;++i){var o=this._chainLengths[i];if(!(o<=4))for(var a=this._complex._chains[i].getResidues(),s=1;s+1<r;++s){var l=n[s],c=1;for(i===t&&(c=s+3);c+1<o;++c){var u=a[c],h=this._testBridge(n,s,a,c);if(h!==rr.NO_BRIDGE){var f,d=!1,p=Qt(e);try{for(p.s();!(f=p.n()).done;){var m=f.value;if(h===m.type&&l._index===m.i[m.i.length-1]+1){if(h===rr.PARALLEL&&m.j[m.j.length-1]+1===u._index){m.i.push(l._index),m.j.push(u._index),d=!0;break}if(h===rr.ANTI_PARALLEL&&m.j[0]-1===u._index){m.i.push(l._index),m.j.unshift(u._index),d=!0;break}}}}catch(e){p.e(e)}finally{p.f()}d||e.push({type:h,i:[l._index],chainI:l.getChain()._index,j:[u._index],chainJ:u.getChain()._index})}}}}}e.sort((function(e,t){return e.chainI<t.chainI||e.chainI===t.chainI&&e.i[0]<t.i[0]?-1:1}));for(var v=0;v<e.length;++v)for(var y=v+1;y<e.length;++y){var _=e[v].i[0],g=e[v].i[e[v].i.length-1],x=e[v].j[0],b=e[v].j[e[v].j.length-1],w=e[y].i[0],S=e[y].i[e[y].i.length-1],R=e[y].j[0],C=e[y].j[e[y].j.length-1];e[v].type!==e[y].type||this._hasChainBreak(Math.min(_,w),Math.max(g,S))||this._hasChainBreak(Math.min(x,R),Math.max(b,C))||w-g>=6||g>=w&&_<=S||(e[v].type===rr.PARALLEL?R-b<6&&w-g<3||R-b<3:x-C<6&&w-g<3||x-C<3)&&(e[v].i=e[v].i.concat(e[y].i),e[v].type===rr.PARALLEL?e[v].j=e[v].j.concat(e[y].j):e[v].j=e[y].j.concat(e[v].j),e.splice(y--,1))}for(var A=new Set,E=0;E<e.length;++E)A.add(e[E]);for(var k=1,P=0;A.size>0;){var T=A.values().next().value;A.delete(T);var M=new Set;M.add(T);var N=void 0;do{N=new Set;var I,O=Qt(M.values());try{for(O.s();!(I=O.n()).done;){var L,B=I.value,D=Qt(A.values());try{for(D.s();!(L=D.n()).done;){var z=L.value;this._areBridgesLinked(B,z)&&N.add(z)}}catch(e){D.e(e)}finally{D.f()}}}catch(e){O.e(e)}finally{O.f()}var F,V=Qt(N.values());try{for(V.s();!(F=V.n()).done;)T=F.value,M.add(T),A.delete(T)}catch(e){V.e(e)}finally{V.f()}}while(N.size>0);var U,G=Qt(M.values());try{for(G.s();!(U=G.n()).done;)(T=U.value).ladder=P,T.sheet=k,T.link=M,++P}catch(e){G.e(e)}finally{G.f()}++k}for(var j=0;j<e.length;++j){for(var H=e[j],W=0,Y=0,X=0;X<H.i.length;++X)if(this._betaPartners[H.i[X]][0]){W=1;break}for(var q=0;q<H.j.length;++q)if(this._betaPartners[H.j[q]][0]){Y=1;break}var $=ir.BRIDGE;if(H.i.length>1&&($=ir.STRAND),H.type===rr.PARALLEL){for(var Z=0,K=0;K<H.i.length;++K)this._betaPartners[H.i[K]][W]={residue:H.j[Z++],ladder:H.ladder,parallel:!0};Z=0;for(var Q=0;Q<H.j.length;++Q)this._betaPartners[H.j[Q]][Y]={residue:H.i[Z++],ladder:H.ladder,parallel:!0}}else{for(var J=H.j.length-1,ee=0;ee<H.i.length;++ee)this._betaPartners[H.i[ee]][W]={residue:H.j[J--],ladder:H.ladder,parallel:!1};J=H.i.length-1;for(var te=0;te<H.j.length;++te)this._betaPartners[H.j[te]][Y]={residue:H.i[J--],ladder:H.ladder,parallel:!1}}for(var re=H.i[0];re<=H.i[H.i.length-1];++re)this._ss[re]!==ir.STRAND&&(this._ss[re]=$,this._sheet[re]=H.sheet);for(var ne=H.j[0];ne<=H.j[H.j.length-1];++ne)this._ss[ne]!==ir.STRAND&&(this._ss[ne]=$,this._sheet[ne]=H.sheet)}}},{key:"_testBridge",value:function(e,t,r,n){var i=rr.NO_BRIDGE,o=e[t-1]._index,a=e[t]._index,s=e[t+1]._index,l=r[n-1]._index,c=r[n]._index,u=r[n+1]._index,h=this._hbonds.isBond.bind(this._hbonds);return h(s,c)&&h(c,o)||h(u,a)&&h(a,l)?i=rr.PARALLEL:(h(s,l)&&h(u,o)||h(c,a)&&h(a,c))&&(i=rr.ANTI_PARALLEL),i}},{key:"_areBridgesLinked",value:function(e,t){var r,n=new Set(e.i),i=new Set(e.j),o=Qt(t.i);try{for(o.s();!(r=o.n()).done;){var a=r.value;if(n.has(a)||i.has(a))return!0}}catch(e){o.e(e)}finally{o.f()}var s,l=Qt(t.j);try{for(l.s();!(s=l.n()).done;){var c=s.value;if(n.has(c)||i.has(c))return!0}}catch(e){l.e(e)}finally{l.f()}return!1}},{key:"_hasChainBreak",value:function(e,t){for(var r=e+1;r<=t;++r)if(this._complex._residues[r]._sequence!==this._complex._residues[r-1]._sequence+1)return!0;return!1}}]),e}();or.StructureType=ir;var ar=or.StructureType,sr=Ue.Type,lr=(Re(er={},ar.HELIX_ALPHA,1),Re(er,ar.HELIX_PI,3),Re(er,ar.HELIX_310,5),er),cr=(Re(tr={},ar.BRIDGE,sr.BRIDGE),Re(tr,ar.TURN,sr.TURN),Re(tr,ar.BEND,sr.BEND),Re(tr,ar.LOOP,sr.COIL),tr),ur=function(){function e(){a(this,e),this._chains=[],this._components=[],this._helices=[],this._sheets=[],this.structures=[],this._residueTypes=Object.create(Be.StandardTypes),this._atoms=[],this._residues=[],this._bonds=[],this._sgroups=[],this._molecules=[],this._maskNeedsUpdate=!1,this.metadata={},this.symmetry=[],this.units=[new Rt(this)],this._currentUnit=0}return l(e,[{key:"addAtom",value:function(e){var t=this._atoms.length;return this._atoms.push(e),t}},{key:"addSheet",value:function(e){var t=this._sheets.length;return this._sheets.push(e),t}},{key:"addHelix",value:function(e){var t=this._helices.length;return this._helices.push(e),t}},{key:"getAtoms",value:function(){return this._atoms}},{key:"getBonds",value:function(){return this._bonds}},{key:"getAtomCount",value:function(){return this._atoms.length}},{key:"addResidue",value:function(e){var t=this._residues.length;return this._residues.push(e),t}},{key:"updateToFrame",value:function(e){this.forEachChain((function(t){t.updateToFrame(e)}))}},{key:"addResidueType",value:function(e){return this._residueTypes[e]=new Be(e,"Unknown","")}},{key:"getResidueCount",value:function(){return this._residues.length}},{key:"getResidues",value:function(){return this._residues}},{key:"getSGroupCount",value:function(){return this._sgroups.length}},{key:"getSGroups",value:function(){return this._sgroups}},{key:"getAtomByFullname",value:function(e){var t=e.split(".");if(3!==t.length)return null;var r=t[0],n=parseInt(t[1],10);if(Number.isNaN(n))return null;var i=t[2].toUpperCase(),o=null;return this.forEachChain((function(e){o||0===e._name.localeCompare(r)&&e.forEachResidue((function(e){o||e._sequence===n&&e.forEachAtom((function(e){o||0===i.localeCompare(e.name)&&(o=e)}))}))})),o}},{key:"addChain",value:function(e){var t=new Ve(this,e);return this._chains.push(t),t}},{key:"getChain",value:function(e){for(var t=0,r=this._chains.length;t<r;++t){var n=this._chains[t];if(n.getName()===e)return n}return null}},{key:"getChainCount",value:function(){return this._chains.length}},{key:"getMolecules",value:function(){return this._molecules}},{key:"getMoleculeCount",value:function(){return this._molecules.length}},{key:"forEachAtom",value:function(e){for(var t=this._atoms,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"forEachBond",value:function(e){for(var t=this._bonds,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"forEachResidue",value:function(e){for(var t=this._residues,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"forEachChain",value:function(e){for(var t=this._chains,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"forEachMolecule",value:function(e){for(var t=this._molecules,r=t.length,n=0;n<r;++n)e(t[n])}},{key:"forEachSGroup",value:function(e){for(var t=this._sgroups,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"forEachComponent",value:function(e){for(var t=this._components,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"forEachVisibleComponent",value:function(e){for(var t=this._components,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"addBond",value:function(e,t,r,n,i){var o=new Pe(e,t,r,n,i);return this._bonds.push(o),o}},{key:"getBondCount",value:function(){return this._bonds.length}},{key:"getResidueType",value:function(e){return this._residueTypes[e]||null}},{key:"getUnifiedSerial",value:function(e,t,r){return t+65536*r+16777216*e}},{key:"splitUnifiedSerial",value:function(e){var t=16777216,r=Math.floor(e/t),n=e-r*t,i=Math.floor(n/65536);return{chain:r,serial:n-65536*i,iCode:i}}},{key:"_fillCmpEdit",value:function(){var e=this,t=this._components;function r(){var r=new At(e);return r._index=t.length,t[r._index]=r,r}this.forEachChain((function(e){var t=e._residues,n=t.length;if(!(n<1))for(var i=r(),o=t[0]._index,a=0;a<n;++a){var s=t[a];s._component=i;var l=a===n-1?null:t[a+1];l&&s.isConnected(l)&&s._index===l._index-1||(i.setSubDivs([{start:o,end:s._index}]),l&&(o=l._index,i=r()))}}))}},{key:"_fillCmpNoedit",value:function(){var e=new At(this);e._index=0;var t=this._residues,r=t.length;if(0!==r){for(var n=[],i=0,o=0;o<r;++o){var a=t[o];a._component=e;var s=o===r-1?null:t[o+1];s&&a.isConnected(s)||(n[n.length]={start:i,end:o},s&&(i=o+1))}e.setSubDivs(n),this._components[e._index]=e}}},{key:"_fillComponents",value:function(e){e?this._fillCmpEdit():this._fillCmpNoedit()}},{key:"getCurrentUnit",value:function(){return this._currentUnit}},{key:"getDefaultBoundaries",value:function(){return this.units[0].getBoundaries()}},{key:"getBoundaries",value:function(){return this.units[this._currentUnit].getBoundaries()}},{key:"getTransforms",value:function(){return this.units[this._currentUnit].getTransforms()}},{key:"getSelector",value:function(){return this.units[this._currentUnit].getSelector()}},{key:"resetCurrentUnit",value:function(){this._currentUnit=0,this.setCurrentUnit(1)}},{key:"setCurrentUnit",value:function(e){return null!=e&&e!==this._currentUnit&&e>=0&&e<this.units.length&&(this._currentUnit=e,!0)}},{key:"_computeBounds",value:function(){for(var e=this.units,t=0,r=e.length;t<r;++t)e[t].computeBoundaries()}},{key:"onAtomPositionChanged",value:function(){this.forEachChain((function(e){e._finalize()})),this.forEachComponent((function(e){e.update()})),this._computeBounds(),this._finalizeBonds(),this.forEachSGroup((function(e){e._rebuildSGroupOnAtomChange()}))}},{key:"update",value:function(){this._maskNeedsUpdate&&(this.updateStructuresMask(),this._maskNeedsUpdate=!1)}},{key:"_finalizeBonds",value:function(){for(var e=this.getBonds(),t=e.length,r=0;r<t;++r)e[r]._index=r}},{key:"finalize",value:function(e){e=e||{};var t,r,n=this._bonds;for(t=n.length-1;t>=0;t--){var i=n[t];null===i._left||null===i._right?n.splice(t,1):(i._left.bonds.push(i),i._right.bonds.push(i))}var o=this._residues;for(t=0,r=o.length;t<r;++t)o[t]._finalize();this.forEachChain((function(e){e._finalize()}));var a=this.units;for(t=0,r=a.length;t<r;++t)a[t].finalize();this.setCurrentUnit(1);var s={};for(t=0,r=o.length;t<r;++t){var l=o[t];s[this.getUnifiedSerial(l.getChain().getName().charCodeAt(0),l.getSequence(),l.getICode().charCodeAt(0))]=l}var c=this.structures;for(t=0,r=c.length;t<r;++t)c[t]._finalize(e.serialAtomMap,s,this);var u=this._helices;for(t=0,r=u.length;t<r;++t)u[t]._finalize(e.serialAtomMap,s,this);var h=this._sheets;for(t=0,r=h.length;t<r;++t)h[t]._finalize(e.serialAtomMap,s,this);this._computeBounds();var f=this._atoms;for(t=0,r=f.length;t<r;++t)f[t].index=t;if(e.needAutoBonding){var d=new Nt(this);d.build(),d.destroy()}var p=this._chains;for(t=0,r=p.length;t<r;++t)p[t]._index=t;for(t=0,r=o.length;t<r;++t)o[t]._index=t;for(t=0,r=f.length;t<r;++t){var m=f[t];if(m.flags&Ce.Flags.HYDROGEN&&1===m.bonds.length){var v=m.bonds[0];(v._left!==m&&v._left||v._right).flags&Ce.Flags.CARBON&&(m.flags|=Ce.Flags.NONPOLARH)}}this._finalizeBonds(),this._fillComponents(e.enableEditing);var y=new Ht(this);y.markCycles(),e.detectAromaticLoops&&y.detectCycles(),this._finalizeMolecules()}},{key:"_finalizeMolecules",value:function(){for(var e=0;e<this._molecules.length;e++)for(var t=this._molecules[e],r=t.residues.length,n=0;n<r;n++)t.residues[n]._molecule=t}},{key:"updateStructuresMask",value:function(){var e=function(e){return e.collectMask()};this.forEachResidue(e),this.forEachChain(e),this.forEachMolecule(e)}},{key:"countAtomsByMask",value:function(e){var t=0;return this.forEachAtom((function(r){0!=(r.mask&e)&&t++})),t}},{key:"getNumAtomsBySelector",value:function(e){var t=0;return this.forEachAtom((function(r){e.includesAtom(r)&&t++})),t}},{key:"resetAtomMask",value:function(e){this.forEachAtom((function(t){t.mask=e}))}},{key:"markAtoms",value:function(e,t){var r=t,n=~r,i=0,o=St.keyword("And")(e,this.getSelector());return this.forEachAtom((function(e){o.includesAtom(e)?(e.mask|=r,i++):e.mask&=n})),this._maskNeedsUpdate=!0,i}},{key:"markAtomsAdditionally",value:function(e,t){var r=t,n=0;return this.forEachAtom((function(i){e.includesAtom(i)&&(i.mask&t)!==t&&(i.mask|=r,n++)})),n}},{key:"clearAtomBits",value:function(e){var t=~e;this.forEachAtom((function(e){e.mask&=t}));var r=function(e){e._mask&=t};this.forEachAtom(r),this.forEachResidue(r),this.forEachChain(r),this.forEachMolecule(r)}},{key:"getAtomNames",value:function(){if(this.hasOwnProperty("_atomNames"))return this._atomNames;var e={};return this.forEachAtom((function(t){e[t.name]=1})),this._atomNames=Object.keys(e),this._atomNames}},{key:"getElements",value:function(){if(this.hasOwnProperty("_elements"))return this._elements;var e={};return this.forEachAtom((function(t){e[t.element.name]=1})),this._elements=Object.keys(e),this._elements}},{key:"getResidueNames",value:function(){if(this.hasOwnProperty("_residueNames"))return this._residueNames;var e={};return this.forEachResidue((function(t){e[t._type._name]=1})),this._residueNames=Object.keys(e),this._residueNames}},{key:"getChainNames",value:function(){if(this.hasOwnProperty("_chainNames"))return this._chainNames;var e={};return this.forEachChain((function(t){e[t._name]=1})),this._chainNames=Object.keys(e),this._chainNames}},{key:"getAltLocNames",value:function(){if(this.hasOwnProperty("_altlocNames"))return this._altlocNames;var e={};return this.forEachAtom((function(t){e[String.fromCharCode(t.location)]=1})),this._altlocNames=Object.keys(e),this._altlocNames}},{key:"getVoxelWorld",value:function(){if(!this.hasOwnProperty("_voxelWorld"))try{this._voxelWorld=new Xt(this.getDefaultBoundaries().boundingBox,new i.Pa4(5,5,5)),this._voxelWorld.addAtoms(this)}catch(e){B.warn("Unable to create voxel world"),this._voxelWorld=null}return this._voxelWorld}},{key:"addElement",value:function(e,t,r,n){for(var i=e.length,o=0;o<i;++o){var a=e[o];n(a,r),t.push(a)}}},{key:"joinComplexes",value:function(e){this._chains=[],this._components=[],this._helices=[],this._sheets=[],this.structures=[],this._atoms=[],this._residues=[],this._bonds=[],this._sgroups=[];var t=this,r=0,n=0,i=0,o=0,a=0;function s(e,t){e.serial+=t,e.index+=t}function l(e,t){e._index+=t}function c(e,t){e._index+=t}function u(e,r){e._complex=t,e._index+=r}function h(e,r){e._complex=t,e._index+=r}function f(){}for(var d=0;d<e.length;++d){var p=e[d];for(var m in this.addElement(p._atoms,this._atoms,r,s),this.addElement(p._bonds,this._bonds,n,l),this.addElement(p._residues,this._residues,i,c),this.addElement(p._chains,this._chains,o,u),this.addElement(p._sheets,this._sheets,0,f),this.addElement(p._helices,this._helices,0,f),this.addElement(p._sgroups,this._sgroups,0,f),this.addElement(p._components,this._components,a,h),this.addElement(p.structures,this.structures,0,f),p._residueTypes)p._residueTypes.hasOwnProperty(m)&&(this._residueTypes[m]=p._residueTypes[m]);r+=p._atoms.length,n+=p._bonds.length,i+=p._residues.length,o+=p._chains.length,a+=p._components.length}this._computeBounds()}},{key:"dssp",value:function(){for(var e,t,r,n,i=new or(this),o=this.structures=[],a=this._helices=[],s=this._sheets=[],l=0,c=null,u=0,h=this._residues.length;u<h;++u){var f=i._ss[u],d=this._residues[u],p=i._sheet[u];if(f!==e||p!==t){var m=lr[f],v=cr[f];if(f===ar.STRAND){var y=(n=void 0,(n=s[r=p])||(n=s[r]=new $e(String(r),0)),n);c=new qe(y,d,d,0,null,null),y.addStrand(c)}else void 0!==m?(l++,c=new Ye(m,d,d,l,String(l),"",1),a.push(c)):c=void 0!==v?new Ue(v,d,d):null;c&&o.push(c),d._secondary=c,e=f,t=p}else d._secondary=c,c&&(c.term=d),c instanceof Ye&&c.length++}this._sheets=s.filter((function(e){return!0}))}}]),e}();function hr(e){var t=2;for(e=e-1>>1;e;)t<<=1,e>>=1;return t}ur.prototype.id="Complex",ur.prototype.name="";var fr=function(){function e(t,r,n,i,o,s){if(a(this,e),this._box=n.clone(),this._dimVec=Math.max(Math.floor(i||1),1),this._volumeInfo=s,r instanceof Array){var l=v(r,3);this._dimX=l[0],this._dimY=l[1],this._dimZ=l[2]}else this._dimX=r.x,this._dimY=r.y,this._dimZ=r.z;switch(this._dimX=Math.max(Math.floor(this._dimX),1),this._dimY=Math.max(Math.floor(this._dimY),1),this._dimZ=Math.max(Math.floor(this._dimZ),1),this._rowElements=this._dimVec*this._dimX,this._planeElements=this._rowElements*this._dimY,this._totalElements=this._planeElements*this._dimZ,this._data=o||$.allocateTyped(t,this._totalElements),this._dimVec){case 1:break;case 2:this.getValue=function(e,t,r){var n=e*this._dimVec+t*this._rowElements+r*this._planeElements;return[this._data[n],this._data[n+1]]},this.setValue=function(e,t,r,n,i){var o=e*this._dimVec+t*this._rowElements+r*this._planeElements;this._data[o]=n,this._data[o+1]=i},this.addValue=function(e,t,r,n,i){var o=e*this._dimVec+t*this._rowElements+r*this._planeElements;this._data[o]+=n,this._data[o+1]+=i};break;case 3:this.getValue=function(e,t,r){var n=e*this._dimVec+t*this._rowElements+r*this._planeElements;return[this._data[n],this._data[n+1],this._data[n+2]]},this.setValue=function(e,t,r,n,i,o){var a=e*this._dimVec+t*this._rowElements+r*this._planeElements;this._data[a]=n,this._data[a+1]=i,this._data[a+2]=o},this.addValue=function(e,t,r,n,i,o){var a=e*this._dimVec+t*this._rowElements+r*this._planeElements;this._data[a]+=n,this._data[a+1]+=i,this._data[a+2]+=o};break;default:throw new Error("Volume: invalid vector dimension")}}return l(e,[{key:"getValue",value:function(e,t,r){return this._data[e+t*this._rowElements+r*this._planeElements]}},{key:"setValue",value:function(e,t,r,n){this._data[e+t*this._rowElements+r*this._planeElements]=n}},{key:"addValue",value:function(e,t,r,n){this._data[e+t*this._rowElements+r*this._planeElements]+=n}},{key:"getDimensions",value:function(){return[this._dimX,this._dimY,this._dimZ]}},{key:"getBox",value:function(){return this._box}},{key:"getVolumeInfo",value:function(){return this._volumeInfo}},{key:"getCellSize",value:function(){var e=new i.Pa4;this._box.getSize(e);var t=new i.Pa4;return t.x=this._dimX>1?e.x/(this._dimX-1):0,t.y=this._dimY>1?e.y/(this._dimY-1):0,t.z=this._dimZ>1?e.z/(this._dimZ-1):0,t}},{key:"computeGradient",value:function(){if(1!==this._dimVec)return null;var t=new e(Float32Array,[this._dimX,this._dimY,this._dimZ],this._box,3),r=this.getCellSize(),n=new i.Pa4(-.5/r.x,-.5/r.y,-.5/r.z);function o(e,t,r){return Math.min(r,Math.max(t,e))}var a=this._dimX,s=this._dimY,l=this._dimZ,c=this._data;function u(e,t,r){return c[r*a*s+t*a+e]}for(var h=0;h<l;++h)for(var f=o(h-1,0,l-1),d=o(h+1,0,l-1),p=0;p<s;++p)for(var m=o(p-1,0,s-1),v=o(p+1,0,s-1),y=0;y<a;++y){var _=o(y-1,0,a-1),g=o(y+1,0,a-1);t.setValue(y,p,h,(u(g,p,h)-u(_,p,h))*n.x,(u(y,v,h)-u(y,m,h))*n.y,(u(y,p,d)-u(y,p,f))*n.z)}return t}},{key:"normalize",value:function(){for(var e=this._data,t=e[0],r=e[0],n=1;n<e.length;++n)t=Math.min(t,e[n]),r=Math.max(r,e[n]);var i=1/(r-t);if(0!==i)for(var o=0;o<e.length;++o)e[o]=i*(e[o]-t)}},{key:"getTiledTextureStride",value:function(){return[this._dimX+2,this._dimY+2]}},{key:"buildTiledTexture",value:function(){var e=Math.ceil(Math.sqrt(this._dimZ*this._dimY/this._dimX)),t=e*(this._dimX+2)-1;t=hr(t),e=Math.floor(t/(this._dimX+2));var r=Math.ceil(this._dimZ/e),n=r*(this._dimY+2)-1;n=hr(n);for(var o,a,s=new Uint8Array(t*n),l=0;l<r;++l)for(var c=0;c<this._dimY;++c){o=l*e*this._planeElements+c*this._rowElements,a=t*(l*(this._dimY+2)+c);for(var u=0;u<e;++u){for(var h=0;h<this._dimX;++h)s[a++]=255*this._data[o++];s[a++]=255*this._data[o-1],u<e-1&&(o+=this._planeElements-this._rowElements,s[a++]=255*this._data[o])}}for(var f=0;f<r;++f){a=(o=t*(f*(this._dimY+2)+this._dimY-1))+t;for(var d=0;d<t;++d)s[a++]=s[o++];if(f<r-1){a=(o=t*(f+1)*(this._dimY+2))-t;for(var p=0;p<t;++p)s[a++]=s[o++]}}var m=new i.IEO(s,t,n,i.Y8D,i.ywz,i.xfE,i.uWy,i.uWy,i.wem,i.wem);return m.needsUpdate=!0,m}},{key:"getData",value:function(){return this._data}},{key:"getDirectIdx",value:function(e,t,r){return e*this._dimVec+t*this._rowElements+r*this._planeElements}},{key:"getStrideX",value:function(){return this._dimVec}},{key:"getStrideY",value:function(){return this._rowElements}},{key:"getStrideZ",value:function(){return this._planeElements}}]),e}();fr.prototype.id="Volume";var dr=function(){function e(t,r,n){a(this,e),this.complex=t,this.name=r||"",this.residues=[],this.mask=1,this.index=n||-1}return l(e,[{key:"forEachResidue",value:function(e){for(var t=this.residues,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"collectMask",value:function(){for(var e=4294967295,t=this.residues,r=0,n=t.length;r<n;++r)e&=t[r]._mask;this.mask=e}}]),e}(),pr={Atom:Ce,Element:Ae,Bond:Pe,Residue:Le,ResidueType:Be,Chain:Ve,Helix:Ye,Strand:qe,Sheet:$e,SGroup:Ze,Assembly:Ct,Complex:ur,Volume:fr,VoxelWorld:Xt,selectors:St,Molecule:dr};var mr=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;a(this,i);var r=c(t=n.call(this));return t._element=e,t._element.style.position="absolute",t.addEventListener("removed",(function(){null!==r._element.parentNode&&r._element.parentNode.removeChild(r._element)})),t}return l(i,[{key:"getElement",value:function(){return this._element}},{key:"setTransparency",value:function(e){var t=this.getElement();if(null!==t)if(1!==e){t.style.display="inline";var r=1-e,n=r.toString(),i=100*r;t.style.opacity=n,t.style.filter="alpha(opacity=".concat(i,")")}else t.style.display="none"}},{key:"clone",value:function(){var e=new i(this._element);return e.copy(this),e}}]),i}(i.Tme);var vr=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"raycast",value:function(e,t){if(this.visible)for(var r=this.children,n=0,i=r.length;n<i;++n)r[n].raycast(e,t)}},{key:"enableSubset",value:function(e,t){for(var r=this.children,n=0,i=r.length;n<i;++n)r[n].enableSubset&&r[n].enableSubset(e,t)}},{key:"disableSubset",value:function(e,t){for(var r=this.children,n=0,i=r.length;n<i;++n)r[n].disableSubset&&r[n].disableSubset(e,t)}},{key:"isEmpty",value:function(){return 0===this.children.length}},{key:"updateToFrame",value:function(e){for(var t=this.children,r=0,n=t.length;r<n;++r)t[r].updateToFrame&&t[r].updateToFrame(e)}},{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=n.length;i<o;++i)n[i].getSubset&&Array.prototype.push.apply(r,n[i].getSubset(e,t));return r}}]),i}(i.ZAu),yr="uniform mat4 projectionMatrix;\r\nuniform mat4 modelViewMatrix;\r\n\r\nattribute vec2 uv;\r\nattribute vec3 position;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n vUv = uv;\r\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n}\r\n";var _r,gr,xr={DEFAULT:0,VOLUME:1,TRANSPARENT:2,PREPASS_TRANSPARENT:3,VOLUME_BFPLANE:4,COLOR_FROM_POSITION:5,SHADOWMAP:6},br=[xr.DEFAULT,xr.TRANSPARENT];i.Tme.prototype.resetTransform=function(){this.position.set(0,0,0),this.quaternion.set(0,0,0,1),this.scale.set(1,1,1)},i.Tme.prototype.updateMatrixWorldRecursive=function(){null!=this.parent&&this.parent.updateMatrixWorldRecursive(),this.updateMatrixWorld()},i.Tme.prototype.addSavingWorldTransform=(_r=new i.yGw,function(e){e instanceof i.Tme&&(_r.copy(this.matrixWorld).invert(),_r.multiply(e.matrixWorld),e.matrix.copy(_r),e.matrix.decompose(e.position,e.quaternion,e.scale),this.add(e))}),i.CP7.prototype.renderDummyQuad=function(){var e=new i.vBJ({transparent:!0,opacity:0,depthWrite:!1}),t=new i.xsS,r=new i.Kj0(new i.BKK(.01,.01),e);t.add(r);var n=new i.iKG(-.5,.5,.5,-.5,-1e4,1e4);return n.position.z=100,function(){this.render(t,n)}}(),i.CP7.prototype.renderScreenQuad=function(){var e=new i.xsS,t=new i.Kj0(new i.BKK(1,1));e.add(t);var r=new i.iKG(-.5,.5,.5,-.5,-1e4,1e4);return r.position.z=100,function(n){t.material=n,this.render(e,r)}}(),i.yGw.prototype.isIdentity=(gr=new i.yGw,function(){return gr.equals(this)}),i.yGw.prototype.applyToPointsArray=function(e,t,r){if(!e||!t||t<3)return e;r=r||0;for(var n=this.elements,i=0;i<e.length;i+=t){var o=e[i],a=e[i+1],s=e[i+2],l=1/(n[3]*o+n[7]*a+n[11]*s+n[15]);e[i]=(n[0]*o+n[4]*a+n[8]*s+n[12]*r)*l,e[i+1]=(n[1]*o+n[5]*a+n[9]*s+n[13]*r)*l,e[i+2]=(n[2]*o+n[6]*a+n[10]*s+n[14]*r)*l}return e};var wr,Sr,Rr=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){return a(this,i),void 0===e.uniforms&&(e.uniforms={}),e.uniforms.srcTex={type:"t",value:null},e.vertexShader=yr,e.transparent=!1,e.depthTest=!1,e.depthWrite=!1,n.call(this,e)}return l(i)}(i.FIo);function Cr(e){e.traverse((function(e){(e instanceof i.Kj0||e instanceof i.ejS||e instanceof i.x12)&&e.geometry.dispose()})),function(e){for(var t=e.children,r=0,n=t.length;r<n;++r){var i=t[r];i.parent=null,i.dispatchEvent({type:"removed"})}e.children=[]}(e)}i.CP7.prototype.renderScreenQuadFromTex=(wr=new Rr({uniforms:{opacity:{type:"f",value:1}},fragmentShader:"precision highp float;\r\n\r\nvarying vec2 vUv;\r\nuniform sampler2D srcTex;\r\nuniform float opacity;\r\n\r\nvoid main() {\r\n vec4 color = texture2D(srcTex, vUv);\r\n gl_FragColor = vec4(color.xyz, color.a * opacity);\r\n}\r\n",transparent:!0}),function(e,t){wr.uniforms.srcTex.value=e,wr.transparent=t<1,wr.uniforms.opacity.value=t,this.renderScreenQuad(wr)}),i.CP7.prototype.renderScreenQuadFromTexWithDistortion=function(){var e=new Rr({uniforms:{coef:{type:"f",value:1}},fragmentShader:"precision highp float;\r\n\r\nvarying vec2 vUv;\r\nuniform sampler2D srcTex;\r\nuniform float coef;\r\n\r\nvoid main() {\r\n vec2 uv = vUv * 2.0 - 1.0;\r\n float r2 = dot(uv, uv);\r\n vec2 tc = uv * (1.0 + coef * r2);\r\n if (!all(lessThan(abs(tc), vec2(1.0))))\r\n discard;\r\n tc = 0.5 * (tc + 1.0);\r\n gl_FragColor = texture2D(srcTex, tc);\r\n}\r\n"});return function(t,r){e.uniforms.srcTex.value=t,e.uniforms.coef.value=r,this.renderScreenQuad(e)}}(),i.cPb.prototype.setMinimalFov=function(e){this.aspect>=1?this.fov=e:this.fov=i.M8C.radToDeg(2*Math.atan(Math.tan(.5*i.M8C.degToRad(e))/this.aspect))},i.u37.prototype.updateHalfSized=function(e,t){var r=e.aspect,n=e.fov;e.aspect=r/2,e.setMinimalFov(t),e.updateProjectionMatrix(),this.update(e),e.aspect=r,e.fov=n,e.updateProjectionMatrix()},i.cPb.prototype.setDistanceToFit=function(e,t){this.position.z=e/Math.sin(.5*i.M8C.degToRad(t))},i.iMs.prototype.intersectVisibleObject=function(e,t,r,n){var o=this.intersectObject(e,!1);if(0===o.length)return null;var a,s=Math.min(t.near,r),l=o[0],c=new i.Pa4;for(a=0;a<o.length&&(l=o[a],c.copy(l.point),c.applyMatrix4(t.matrixWorldInverse),!(c.z<=-s));++a);if(a===o.length)return null;var u=Math.min(t.far,n);return c.copy(l.point),c.applyMatrix4(t.matrixWorldInverse),c.z<=-u?null:l},i.yGw.prototype.extractScale=(Sr=new i.Pa4,function(e){void 0===e&&(B.debug("extractScale(): new is too expensive operation to do it on-the-fly"),e=Sr.clone());var t=this.elements;return e.x=Sr.set(t[0],t[1],t[2]).length(),e.y=Sr.set(t[4],t[5],t[6]).length(),e.z=Sr.set(t[8],t[9],t[10]).length(),this.determinant()<0&&(e.x=-e.x),e}),i.TlE.prototype.copyAtList=function(e,t){console.assert(this.itemSize===e.itemSize,"false: BufferAttribute.copyAtList buffers have different item size.");for(var r=this.itemSize,n=0,i=t.length;n<i;++n)for(var o=0;o<r;++o)this.array[n*r+o]=e.array[t[n]*r+o];return this};var Ar=i.L5s.prototype.copy;i.L5s.prototype.copy=function(e){Ar.call(this,e),void 0===this.instanceCount&&(this.instanceCount=1/0)};var Er={calcCylinderMatrix:function(e,t,r){var n=e.clone().lerp(t,.5),o=new i.yGw;o.makeScale(r,e.distanceTo(t),r);var a=new i.yGw;a.makeRotationX(Math.PI/2);var s=new i.yGw,l=new i.Pa4(0,1,0);return s.lookAt(n,t,l),s.multiply(a),s.multiply(o),s.setPosition(n),s},calcChunkMatrix:function(e,t,r,n){var o=new i.yGw;o.makeScale(n.x,n.y,0);var a=new i.yGw;return a.lookAt(e,t,r),a.multiply(o),a.setPosition(e),a},groupHasGeometryToRender:function(e){var t=!1;return e.traverse((function(e){(e.hasOwnProperty("geometry")||e instanceof mr)&&(t=!0)})),t},buildDistorionMesh:function(e,t,r){function n(e){for(var t=0,n=e,i=1;Math.abs(n-t)>1e-5;)t=n,n=e/((i=1+r*n)*i);return 1/i}for(var o=new i.BKK(2,2,e,t),a=o.getAttribute("position"),s=0;s<a.count;++s){var l=a.array[3*s],c=a.array[3*s+1],u=n(l*l+c*c);a.setXY(s,u*l,u*c)}return o},RCGroup:vr,fillArray:function(e,t,r,n){r=void 0!==r?r:0,n=void 0!==n?n:e.length;for(var i=r;i<n;++i)e[i]=t},clearTree:Cr,destroyObject:function(e){Cr(e),e.parent?e.parent.remove(e):e.dispatchEvent({type:"removed"})},belongToSelectLayers:function(e){for(var t=0;t<br.length;t++)if(1==(e.layers.mask>>br[t]&1))return!0;return!1},processObjRenderOrder:function(e,t){var r=+("BA"!==t);e.traverse((function(e){e.isGroup&&(e.renderOrder=r)}))},applySelectionMaterial:function(e){e.traverse((function(e){"material"in e&&(e.material=e.material.clone(!0),e.material.setValues({depthFunc:i.vCF,overrideColor:!0,fog:!1,lights:!1,shadowmap:!1}),e.material.setUberOptions({fixedColor:new i.Ilk(16776960),zOffset:-1e-6}))}))},getMiddlePoint:function(e,t,r){var n=r||new i.Pa4;return n.set(0,0,0),n.addScaledVector(e,.5),n.addScaledVector(t,.5),n},LAYERS:xr};var kr={boundingBox:new i.ZzF(new i.Pa4(-1,-1,-1),new i.Pa4(1,1,1)),boundingSphere:new i.aLr(new i.Pa4(0,0,0),1)},Pr=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return a(this,i),(r=n.call(this,e,t)).name=e,r._dataSource=t,r}return l(i,[{key:"release",value:function(){this.parent&&this.parent.remove(this)}},{key:"getDataSource",value:function(){return this._dataSource}},{key:"getBoundaries",value:function(){return kr}}]),i}(Er.RCGroup);function Tr(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||m(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Mr(e){return null==e||Array.isArray(e)?e:[e]}var Nr=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["id"];a(this,e),this._list=[],this._dict={},this._indices=Tr(n),this._indices.forEach((function(e){t._dict[e]={}})),r.forEach((function(e){return t.register(e)}))}return l(e,[{key:"register",value:function(t){var r=this;e.registerInList(this._list,t),this._indices.forEach((function(n){e.registerInDict(r._dict[n],Mr(t[n]),t)}))}},{key:"unregister",value:function(t){var r=this;e.unregisterFromList(this._list,t),this._indices.forEach((function(n){e.unregisterFromDict(r._dict[n],Mr(t[n]),t)}))}},{key:"all",get:function(){return Tr(this._list)}},{key:"first",get:function(){return this._list[0]}},{key:"keys",value:function(e){return Object.keys(this._dict[e||this._indices[0]])}},{key:"get",value:function(e,t){var r=this._dict[t||this._indices[0]];if(r){var n=r[e&&e.toLowerCase()];return n&&n.length>0?n[0]:void 0}}}],[{key:"registerInList",value:function(e,t){e.includes(t)||e.push(t)}},{key:"unregisterFromList",value:function(e,t){var r=e.indexOf(t);-1!==r&&e.splice(r,1)}},{key:"registerInDict",value:function(e,t,r){t.forEach((function(t){t=t.toLowerCase();var n=e[t]=e[t]||[];n.includes(r)||n.push(r)}))}},{key:"unregisterFromDict",value:function(e,t,r){t.forEach((function(t){t=t.toLowerCase();var n=e[t];if(n){var i=n.indexOf(r);-1!==i&&n.splice(i,1),0===n.length&&delete e[t]}}))}}]),e}();function Ir(e){Object.defineProperties(e,{logger:{get:function(){return this.context&&this.context.logger?this.context.logger:B}},settings:{get:function(){return this.context&&this.context.settings?this.context.settings:J}}})}var Or=function(){function e(t,r){a(this,e),this._position=t,this._radius=r}return l(e,[{key:"raycast",value:function(t){var r=e._sphere;r.set(this._position,this._radius);var n=new i.Pa4;return t.ray.intersectSphere(r,n)?{distance:t.ray.origin.distanceTo(n),point:n}:null}}]),e}();Re(Or,"_sphere",new i.aLr);var Lr=function(e){return function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;a(this,o);for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];return(t=n.call.apply(n,[this].concat(i)))._objects=new Array(e),t.boundingSphere=null,t.boundingBox=null,t}return l(o,[{key:"setSphere",value:function(e,t,r){this._objects[e]=new Or(t,r)}},{key:"raycast",value:function(e,t){for(var r=0,n=this._objects.length;r<n;++r){var i=this._objects[r].raycast(e);i&&(i.chunkIdx=r,t.push(i))}}},{key:"computeBoundingBox",value:function(){var e=this._objects,t=this.boundingBox;null===t&&(this.boundingBox=t=new i.ZzF),t.makeEmpty();for(var r=0,n=e.length;r<n;++r)t.expandByPoint(e[r]._position)}},{key:"computeBoundingSphere",value:function(){this.computeBoundingBox();var e=this._objects,t=this.boundingBox,r=0,n=new i.Pa4;t.getCenter(n);for(var o=0,a=e.length;o<a;++o){var s=e[o]._position,l=n.distanceToSquared(s);r<l&&(r=l)}null===this.boundingSphere&&(this.boundingSphere=new i.aLr),this.boundingSphere.set(n,Math.sqrt(r))}}]),o}(e)};var Br=new i.Ilk,Dr=$.copySubArrays,zr=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e,t,r){var n;return a(this,s),(n=o.call(this,e))._sphGeometry=r?new i.BKK(2,2,1,1):new i.Aip(1,2*t,t,0,2*Math.PI,0,Math.PI),n._init(e,n._sphGeometry),n}return l(s,[{key:"setItem",value:function(e,t,r){var n,i,o,a,s,l;n=this._offsets,i=4*e,o=t.x,a=t.y,s=t.z,l=r,n[i]=o,n[i+1]=a,n[i+2]=s,n[i+3]=l,this.setSphere(e,t,r)}},{key:"setColor",value:function(e,t){var r,n,i,o,a;Br.set(t),r=this._colors,n=3*e,i=Br.r,o=Br.g,a=Br.b,r[n]=i,r[n+1]=o,r[n+2]=a}},{key:"startUpdate",value:function(){return!0}},{key:"finishUpdate",value:function(){this.getAttribute("offset").needsUpdate=!0,this.getAttribute("color").needsUpdate=!0}},{key:"finalize",value:function(){this.finishUpdate(),this.computeBoundingSphere()}},{key:"setOpacity",value:function(e,t){for(var r=this._alpha,n=0,i=e.length;n<i;++n)r[e[n]]=t;this.getAttribute("alphaColor").needsUpdate=!0}},{key:"getSubset",value:function(e){var t=e.length,r=new i.L5s;return this._init.call(r,t,this._sphGeometry),Dr(this._offsets,r._offsets,e,4),Dr(this._colors,r._colors,e,3),r.boundingSphere=this.boundingSphere,r.boundingBox=this.boundingBox,[r]}},{key:"_init",value:function(e,t){this.copy(t),this._offsets=$.allocateTyped(Float32Array,4*e),this._colors=$.allocateTyped(Float32Array,3*e);var r=this._alpha=$.allocateTyped(Float32Array,e);(0,n.fill)(r,1),this.setAttribute("offset",new i.lb7(this._offsets,4,!1,1)),this.setAttribute("color",new i.lb7(this._colors,3,!1,1)),this.setAttribute("alphaColor",new i.lb7(r,1,!1,1))}}]),s}(Lr(i.L5s));var Fr=new i.Ilk,Vr=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e,t){var r;if(a(this,s),(r=o.call(this)).constructor===s)throw new Error("Can not instantiate abstract class!");return r._chunkGeo=e,r._init(e,t),r}return l(s,[{key:"startUpdate",value:function(){return!0}},{key:"finishUpdate",value:function(){this.getAttribute("position").needsUpdate=!0,this.getAttribute("normal").needsUpdate=!0,this.getAttribute("color").needsUpdate=!0}},{key:"setColor",value:function(e,t){Fr.set(t);for(var r=this._colors,n=this._chunkSize,i=e*n,o=i+n;i<o;++i){var a=3*i;r[a]=Fr.r,r[a+1]=Fr.g,r[a+2]=Fr.b}}},{key:"finalize",value:function(){this.finishUpdate(),this.computeBoundingSphere()}},{key:"setOpacity",value:function(e,t){for(var r=this._alpha,i=this._chunkSize,o=0,a=e.length;o<a;++o){var s=e[o]*i;(0,n.fill)(r,t,s,s+i)}this.getAttribute("alphaColor").needsUpdate=!0}},{key:"raycast",value:function(e,t){var r=[],n=new i.Kj0;n.geometry=this,n.raycast(e,r);for(var o=this._chunkGeo.index.count/3,a=0,s=r.length;a<s;++a)r[a].hasOwnProperty("faceIndex")&&(r[a].chunkIdx=Math.floor(r[a].faceIndex/o),t.push(r[a]))}},{key:"getSubset",value:function(e){var t=e.length,r=new i.u9r;this._init.call(r,this._chunkGeo,t);for(var n=this._positions,o=this._normals,a=this._colors,s=r._positions,l=r._normals,c=r._colors,u=3*this._chunkSize,h=0,f=e.length;h<f;++h){var d=h*u,p=e[h]*u,m=p+u;s.set(n.subarray(p,m),d),l.set(o.subarray(p,m),d),c.set(a.subarray(p,m),d)}return r.boundingSphere=this.boundingSphere,r.boundingBox=this.boundingBox,[r]}},{key:"_init",value:function(e,t){var r=this._chunkSize=e.attributes.position.count,o=e.index.array,a=o.length,s=this._chunkSize*t,l=s>65535,c=a*t,u=this._index=$.allocateTyped(l?Uint32Array:Uint16Array,c);this._positions=$.allocateTyped(Float32Array,3*s),this._normals=$.allocateTyped(Float32Array,3*s),this._colors=$.allocateTyped(Float32Array,3*s);var h=this._alpha=$.allocateTyped(Float32Array,s);(0,n.fill)(h,1);for(var f=0;f<t;++f){var d=f*a,p=f*r;u.set(o,d);for(var m=0;m<a;++m)u[d+m]+=p}this.setIndex(new i.TlE(this._index,1)),this.setAttribute("position",new i.TlE(this._positions,3)),this.setAttribute("normal",new i.TlE(this._normals,3)),this.setAttribute("color",new i.TlE(this._colors,3)),this.setAttribute("alphaColor",new i.TlE(h,1))}}]),s}(i.u9r);var Ur=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;a(this,o);var s=new i.Aip(1,2*t,t,0,2*Math.PI,0,Math.PI),l=(r=n.call(this,e,s,e))._normals,c=s.attributes.normal.array,u=r._chunkSize;r._chunkPos=r._chunkGeo.attributes.position.array,r._tmpPositions=$.allocateTyped(Float32Array,3*u);for(var h=0;h<e;++h)l.set(c,3*u*h);return r}return l(o,[{key:"setItem",value:function(e,t,r){for(var n=this._tmpPositions,i=this._chunkSize,o=this._chunkPos,a=0;a<i;++a){var s=3*a;n[s]=t.x+o[s]*r,n[s+1]=t.y+o[s+1]*r,n[s+2]=t.z+o[s+2]*r}this._positions.set(n,i*e*3),this.setSphere(e,t,r)}}]),o}(Lr(Vr));var Gr=new i.Pa4,jr=new i.Pa4,Hr=new i.Vkp,Wr=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;a(this,o);var s=new i.m_w(1,1,1,Math.max(3,t),2,!0),l=(r=n.call(this,s,2*e))._chunkSize;return r._chunkPos=r._chunkGeo.attributes.position.array,r._chunkNorms=r._chunkGeo.attributes.normal.array,r._tmpVector=$.allocateTyped(Float32Array,3*l),r}return l(o,[{key:"setItem",value:function(e,t,r,n){var i=this._chunkSize,o=2*i*e*3,a=o+3*i,s=this._tmpVector,l=this._chunkPos,c=this._chunkNorms;Gr.lerpVectors(t,r,.5);var u,h=Er.calcCylinderMatrix(t,Gr,n);Hr.getNormalMatrix(h);for(var f=0;f<i;++f)u=3*f,jr.fromArray(l,u),jr.applyMatrix4(h),jr.toArray(s,u);this._positions.set(s,o),Gr.sub(t);for(var d=0;d<i;++d)s[u=3*d]+=Gr.x,s[u+1]+=Gr.y,s[u+2]+=Gr.z;this._positions.set(s,a);for(var p=0;p<i;++p)u=3*p,jr.fromArray(c,u),jr.applyMatrix3(Hr),jr.toArray(s,u);this._normals.set(s,o),this._normals.set(s,a)}},{key:"setColor",value:function(e,t,r){var n=2*e;Xe(d(o.prototype),"setColor",this).call(this,n,t);var i=n+1;Xe(d(o.prototype),"setColor",this).call(this,i,r)}}]),o}(Vr);var Yr=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t,r,s,l,c){var u;a(this,o),u=n.call(this);var h=2*Math.PI;u.type="CylinderBufferGeometry",u.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:s,heightSegments:l,openEnded:c};var f=!1===c&&e>0,d=!1===c&&t>0,p=(l+1)*s+f*(s+1)+d*(s+1),m=(2*l+f+d)*s,v=r/2,y=new i.TlE($.allocateTyped(Float32Array,3*p),3),_=new i.TlE($.allocateTyped(Float32Array,3*p),3),g=new i.qlB($.allocateTyped(Uint16Array,3*m),1),x=new i.TlE($.allocateTyped(Float32Array,2*p),2);console.assert(p<65536,"false: Cylinder Geometry has too many vertices (65536 max).");for(var b=0,w=0,S=-(t-e)/r,R=0;R<=l;R++){if(R!==l)for(var C=0;C<s;C++){var A=b+C,E=b+s+C,k=b+s+(C+1)%s,P=b+(C+1)%s;g.setXYZ(3*w,A,P,E),w++,g.setXYZ(3*w,E,P,k),w++}for(var T=R/l,M=T*(t-e)+e,N=0;N<s;N++){var I=N/s,O=M*Math.sin(I*h+0),L=T*r-v,B=M*Math.cos(I*h+0),D=new i.Pa4(O,Math.sqrt(O*O+B*B)*S,B).normalize();y.setXYZ(b,O,L,B),_.setXYZ(b,D.x,D.y,D.z),x.setXY(b,I,T),++b}}if(f){for(var z=b,F=b+s,V=0;V<s;++V){var U=b-s;y.setXYZ(b,y.getX(U),y.getY(U),y.getZ(U)),_.setXYZ(b,0,1,0),x.setXY(b,1,1);var G=z+(V+1)%s;g.setXYZ(3*w,b,G,F),w++,b++}y.setXYZ(b,0,v,0),_.setXYZ(b,0,1,0),x.setXY(b,1,1),++b}if(d){for(var j=b,H=b+s,W=0;W<s;++W){var Y=W;y.setXYZ(b,y.getX(Y),y.getY(Y),y.getZ(Y)),_.setXYZ(b,0,-1,0),x.setXY(b,0,0);var X=j+(W+1)%s;g.setXYZ(3*w,X,b,H),w++,b++}y.setXYZ(b,0,-v,0),_.setXYZ(b,0,-1,0),x.setXY(b,0,0)}return u.setIndex(g),u.setAttribute("position",y),u.setAttribute("normal",_),u.setAttribute("uv",x),u}return l(o,[{key:"clone",value:function(){var e=this.parameters;return new o(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded)}}]),o}(i.u9r);var Xr=new i.Ilk,qr=new i.yGw,$r=$.copySubArrays;function Zr(e,t,r,n,i){e[t]=r,e[t+1]=n,e[t+2]=i}function Kr(e,t,r,n,i,o){e[t]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o}function Qr(e,t){return e-t}var Jr=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e,t,r,n){var l;return a(this,s),(l=o.call(this))._useZSprites=r,l._cylGeometry=r?new i.BKK(2,2,1,1):new Yr(1,1,1,Math.max(3,t),2,n),l._init(e,l._cylGeometry,l._useZSprites),l._collisionGeo=new Wr(e,3),l}return l(s,[{key:"setItem",value:function(e,t,r,n){var i=Er.calcCylinderMatrix(t,r,n),o=i.elements,a=4*e;this._collisionGeo.setItem(e,t,r,n),Kr(this._matVector1,a,o[0],o[4],o[8],o[12]),Kr(this._matVector2,a,o[1],o[5],o[9],o[13]),Kr(this._matVector3,a,o[2],o[6],o[10],o[14]),this._useZSprites&&(qr.copy(i).invert(),o=qr.elements,Kr(this._invmatVector1,a,o[0],o[4],o[8],o[12]),Kr(this._invmatVector2,a,o[1],o[5],o[9],o[13]),Kr(this._invmatVector3,a,o[2],o[6],o[10],o[14]))}},{key:"setColor",value:function(e,t,r){var n=3*e;Xr.set(t),Zr(this._color1,n,Xr.r,Xr.g,Xr.b),Xr.set(r),Zr(this._color2,n,Xr.r,Xr.g,Xr.b)}},{key:"computeBoundingSphere",value:function(){this._collisionGeo.computeBoundingSphere(),this.boundingSphere=this._collisionGeo.boundingSphere}},{key:"computeBoundingBox",value:function(){this._collisionGeo.computeBoundingBox(),this.boundingBox=this._collisionGeo.boundingBox}},{key:"raycast",value:function(e,t){this._collisionGeo.raycast(e,t)}},{key:"startUpdate",value:function(){return!0}},{key:"finishUpdate",value:function(){this.getAttribute("matVector1").needsUpdate=!0,this.getAttribute("matVector2").needsUpdate=!0,this.getAttribute("matVector3").needsUpdate=!0,this.getAttribute("color").needsUpdate=!0,this.getAttribute("color2").needsUpdate=!0,this.getAttribute("alphaColor").needsUpdate=!0,this._useZSprites&&(this.getAttribute("invmatVector1").needsUpdate=!0,this.getAttribute("invmatVector2").needsUpdate=!0,this.getAttribute("invmatVector3").needsUpdate=!0),this._collisionGeo.finishUpdate()}},{key:"finalize",value:function(){this.finishUpdate(),this.computeBoundingSphere()}},{key:"setOpacity",value:function(e,t){for(var r=this._alpha,n=0,i=e.length;n<i;++n)r[Math.floor(e[n]/2)]=t;this.getAttribute("alphaColor").needsUpdate=!0}},{key:"getSubset",value:function(e){var t=function(e){e.sort(Qr);for(var t=[],r=[],n=0,i=e.length;n<i;++n){var o=e[n],a={first:!1,second:!1};(0|o)%2==0?(a.first=!0,a.second=n+1<i&&e[n+1]===e[n]+1,a.second&&++n):a.second=!0,t.push(Math.floor(o/2)),r.push(a)}return{indices:t,cylinderInfo:r}}(e),r=t.indices,n=r.length,o=new i.L5s;return this._init.call(o,n,this._cylGeometry,this._useZSprites),$r(this._matVector1,o._matVector1,r,4),$r(this._matVector2,o._matVector2,r,4),$r(this._matVector3,o._matVector3,r,4),this._useZSprites&&($r(this._invmatVector1,o._invmatVector1,r,4),$r(this._invmatVector2,o._invmatVector2,r,4),$r(this._invmatVector3,o._invmatVector3,r,4)),$r(this._color1,o._color1,r,3),$r(this._color2,o._color2,r,3),function(e,t,r){for(var n=0,i=e.length;n<i;++n){var o=e[n];o.first||(t[3*n]=-.5),o.second||(r[3*n]=-.5)}}(t.cylinderInfo,o._color1,o._color2),o.boundingSphere=this.boundingSphere,o.boundingBox=this.boundingBox,[o]}},{key:"getGeoParams",value:function(){return this._cylGeometry.parameters}},{key:"_init",value:function(e,t,r){this.copy(t),this._matVector1=$.allocateTyped(Float32Array,4*e),this._matVector2=$.allocateTyped(Float32Array,4*e),this._matVector3=$.allocateTyped(Float32Array,4*e),this._color1=$.allocateTyped(Float32Array,3*e),this._color2=$.allocateTyped(Float32Array,3*e);var o=this._alpha=$.allocateTyped(Float32Array,e);(0,n.fill)(o,1),this.setAttribute("matVector1",new i.lb7(this._matVector1,4,!1,1)),this.setAttribute("matVector2",new i.lb7(this._matVector2,4,!1,1)),this.setAttribute("matVector3",new i.lb7(this._matVector3,4,!1,1)),this.setAttribute("color",new i.lb7(this._color1,3,!1,1)),this.setAttribute("color2",new i.lb7(this._color2,3,!1,1)),this.setAttribute("alphaColor",new i.lb7(this._alpha,1,!1,1)),r&&(this._invmatVector1=$.allocateTyped(Float32Array,4*e),this._invmatVector2=$.allocateTyped(Float32Array,4*e),this._invmatVector3=$.allocateTyped(Float32Array,4*e),this.setAttribute("invmatVector1",new i.lb7(this._invmatVector1,4,!1,1)),this.setAttribute("invmatVector2",new i.lb7(this._invmatVector2,4,!1,1)),this.setAttribute("invmatVector3",new i.lb7(this._invmatVector3,4,!1,1)))}}]),s}(i.L5s);var en=new i.Pa4,tn=new i.Pa4,rn=new i.Pa4,nn=new i.Pa4(1,0,0),on=new i.Pa4,an=new i.Pa4,sn=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t,r){var s;a(this,o);var l=function(e,t){for(var r=new i.u9r,n=e.length,o=n*t,a=o<=65536?Uint16Array:Uint32Array,s=(t-1)*n*2,l=new i.TlE($.allocateTyped(a,3*s),1),c=0,u=0,h=0;h<t;h++){if(h!==t-1)for(var f=0;f<n;f++){var d=c+f,p=c+n+f,m=c+n+(f+1)%n,v=c+(f+1)%n;l.setXYZ(3*u,d,v,p),u++,l.setXYZ(3*u,p,v,m),u++}c+=n}r.setIndex(l);var y=$.allocateTyped(Float32Array,3*o);return r.setAttribute("position",new i.TlE(y,3)),r._positions=e,r}(e,t);(s=n.call(this,l,r))._ringsCount=t;for(var c=s._tmpShape=[],u=0;u<e.length;++u)c[u]=new i.Pa4;return s}return l(o,[{key:"setItem",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=this._chunkGeo._positions.length,o=this._ringsCount,a=i*this._ringsCount*e*3;this._setPoints(t,i,o,a),r?this._setSlopeNormals(i,o,a):this._setBaseNormals(i,o,a),n&&this._addCut(i,o,a)}},{key:"_setPoints",value:function(e,t,r,n){for(var i=this._tmpShape,o=this._positions,a=this._chunkGeo._positions,s=0,l=n;s<r;++s)for(var c=e[s],u=0;u<t;++u,l+=3)i[u].copy(a[u]).applyMatrix4(c).toArray(o,l)}},{key:"_setBaseNormals",value:function(e,t,r){for(var n=3*e,i=0,o=r;i<t;++i,o+=n)this._countNormalsInRing(e,o,!1)}},{key:"_setSlopeNormals",value:function(e,t,r){for(var n=this._normals,i=3*e,o=r,a=0;a<e;++a,o+=3)nn.toArray(n,o);if(o-2*i>0)for(var s=0;s<e;++s,o+=3)rn.fromArray(n,o-2*i).toArray(n,o);else this._countNormalsInRing(e,o,!0,+i),o+=i;for(var l=2;l<t;++l,o+=i)this._countNormalsInRing(e,o,!0,-i)}},{key:"_countNormalsInRing",value:function(e,t,r,n){var i=this._tmpShape,o=this._normals;i[0].fromArray(this._positions,t),i[e-1].fromArray(this._positions,t+3*(e-1));for(var a=0;a<e;++a,t+=3)a<e-1&&i[a+1].fromArray(this._positions,t+3),r?(an.fromArray(this._positions,t+n),en.subVectors(i[(a+e-1)%e],i[(a+1)%e]).normalize(),tn.subVectors(i[a],an).normalize(),rn.crossVectors(tn,en).normalize().toArray(o,t)):(en.subVectors(i[a],i[(a+e-1)%e]).normalize(),tn.subVectors(i[a],i[(a+1)%e]).normalize(),rn.addVectors(en,tn).normalize().toArray(o,t))}},{key:"_addCut",value:function(e,t,r){if(!(e<3||t<2)){var n=this._positions,i=this._normals,o=this._tmpShape,a=3*e;o[0].fromArray(n,r),o[1].fromArray(n,r+3),o[2].fromArray(n,r+6),en.subVectors(o[1],o[0]).normalize(),tn.subVectors(o[1],o[2]).normalize(),on.crossVectors(en,tn).normalize();for(var s=r,l=0;l<2*e;++l,s+=3)on.toArray(i,s);if(t>2)for(var c=0;c<e;++c,s+=3)rn.fromArray(n,s-a).toArray(n,s)}}}]),o}(Vr);var ln=4,cn=new i.Ilk,un=new i.Pa4;function hn(e,t,r,n,i){e[t]=r,e[t+1]=n,e[t+2]=i}function fn(e,t,r,n,i,o){e[t]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o}function dn(e,t,r,n){var i=t*ln,o=i+r*ln;return e.subarray(i*n,o*n)}var pn=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e){var t;return a(this,s),(t=o.call(this))._initVertices(e),t}return l(s,[{key:"startUpdate",value:function(){return!0}},{key:"finishUpdate",value:function(){this.getAttribute("position").needsUpdate=!0,this.getAttribute("color").needsUpdate=!0,this.getAttribute("alphaColor").needsUpdate=!0,this.getAttribute("direction").needsUpdate=!0}},{key:"setColor",value:function(e,t){cn.set(t);var r=e*ln*3;hn(this._colors,r,cn.r,cn.g,cn.b),r+=3,hn(this._colors,r,cn.r,cn.g,cn.b),r+=3,hn(this._colors,r,cn.r,cn.g,cn.b),r+=3,hn(this._colors,r,cn.r,cn.g,cn.b)}},{key:"setSegment",value:function(e,t,r){un.subVectors(t,r),un.normalize();var n=this._positions,i=this._directions,o=e*ln*4,a=e*ln*3;fn(n,o,t.x,t.y,t.z,.5),hn(i,a,un.x,un.y,un.z),a+=3,fn(n,o+=4,t.x,t.y,t.z,-.5),hn(i,a,un.x,un.y,un.z),a+=3,fn(n,o+=4,r.x,r.y,r.z,.5),hn(i,a,un.x,un.y,un.z),a+=3,fn(n,o+=4,r.x,r.y,r.z,-.5),hn(i,a,un.x,un.y,un.z)}},{key:"setOpacity",value:function(e,t,r){var i=e*ln,o=t*ln;(0,n.fill)(this.alpha,r,o,i),this.getAttribute("alphaColor").needsUpdate=!0}},{key:"getSubsetSegments",value:function(e,t){return[dn(this._positions,e,t,4),dn(this._directions,e,t,3)]}},{key:"getSubsetColors",value:function(e,t){return dn(this._colors,e,t,3)}},{key:"getSubsetOpacities",value:function(e,t){return dn(this._alpha,e,t,1)}},{key:"getNumVertexPerSegment",value:function(){return ln}},{key:"getPositionSize",value:function(){return 4}},{key:"setSegments",value:function(e,t){var r=e*ln*4;if(t instanceof Array&&2===t.length){this._positions.set(t[0],r);var n=e*ln*3;this._directions.set(t[1],n)}else this._positions.set(t,r)}},{key:"setColors",value:function(e,t){var r=e*ln*3;this._colors.set(t,r)}},{key:"_initVertices",value:function(e){this._buffersSize=e*ln;var t=this._buffersSize,r=t>65535;this._index=$.allocateTyped(r?Uint32Array:Uint16Array,6*e),this._positions=$.allocateTyped(Float32Array,4*t),this._colors=$.allocateTyped(Float32Array,3*t),this._directions=$.allocateTyped(Float32Array,3*t);var o=this._alpha=$.allocateTyped(Float32Array,t);(0,n.fill)(o,1);for(var a=this._index,s=0,l=0,c=0;c<e;c++,s+=6,l+=ln)a[s]=l,a[s+1]=l+1,a[s+2]=l+3,a[s+3]=l,a[s+4]=l+2,a[s+5]=l+3;this.setIndex(new i.TlE(this._index,1)),this.setAttribute("position",new i.TlE(this._positions,4)),this.setAttribute("color",new i.TlE(this._colors,3)),this.setAttribute("alphaColor",new i.TlE(o,1)),this.setAttribute("direction",new i.TlE(this._directions,3))}}]),s}(i.u9r);var mn=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return a(this,o),n.apply(this,arguments)}return l(o,[{key:"startUpdate",value:function(){return!0}},{key:"computeBoundingSphere",value:function(){var e=this.boundingBox,t=0,r=new i.Pa4;e&&e.getCenter(r);for(var n=this._positions,o=this.boundingSphere||new i.aLr,a=this._positions.length,s=new i.Pa4,l=this.getPositionSize(),c=0;c<a;c+=l){s.set(n[c],n[c+1],n[c+2]);var u=r.distanceToSquared(s);t<u&&(t=u)}o.set(r,Math.sqrt(t)),this.boundingSphere=o}},{key:"computeBoundingBox",value:function(){for(var e=this._positions,t=new i.ZzF,r=this._positions.length,n=new i.Pa4,o=this.getPositionSize(),a=0;a<r;a+=o)n.set(e[a],e[a+1],e[a+2]),t.expandByPoint(n);this.boundingBox=t}},{key:"finalize",value:function(){this.finishUpdate(),this.computeBoundingSphere()}}]),o}(pn);var vn=new i.Pa4,yn=new i.Vkp,_n=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;a(this,o);var s=new i.m_w(1,1,1,Math.max(3,t),2,!0),l=(r=n.call(this,s,e))._chunkSize;return r._chunkPos=r._chunkGeo.attributes.position.array,r._chunkNorms=r._chunkGeo.attributes.normal.array,r._tmpVector=$.allocateTyped(Float32Array,3*l),r}return l(o,[{key:"setItem",value:function(e,t,r,n){var i,o=this._chunkSize,a=o*e*3,s=this._tmpVector,l=this._chunkPos,c=this._chunkNorms,u=Er.calcCylinderMatrix(t,r,n);yn.getNormalMatrix(u);for(var h=0;h<o;++h)i=3*h,vn.fromArray(l,i),vn.applyMatrix4(u),vn.toArray(s,i);this._positions.set(s,a);for(var f=0;f<o;++f)i=3*f,vn.fromArray(c,i),vn.applyMatrix3(yn),vn.toArray(s,i);this._normals.set(s,a)}}]),o}(Vr);var gn=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r){var o;return a(this,i),(o=n.call(this,e*t))._init(t),o._collisionGeo=r?new _n(e*t,3):null,o}return l(i,[{key:"startUpdate",value:function(){return!0}},{key:"computeBoundingSphere",value:function(){var e=this._collisionGeo;if(e)return e.computeBoundingSphere(),void(this.boundingSphere=e.boundingSphere);Xe(d(i.prototype),"computeBoundingSphere",this).call(this)}},{key:"computeBoundingBox",value:function(){var e=this._collisionGeo;if(e)return e.computeBoundingBox(),void(this.boundingBox=e.boundingBox);Xe(d(i.prototype),"computeBoundingBox",this).call(this)}},{key:"raycast",value:function(e,t){if(this._collisionGeo){var r=this._chunkSize;this._collisionGeo.raycast(e,t);for(var n=0,i=t.length;n<i;++n){var o=t[n].chunkIdx;void 0!==o&&(o=o/r|0,t[n].chunkIdx=o)}}}},{key:"setColor",value:function(e,t){for(var r=this._chunkSize,n=e*r,o=n+r;n<o;++n)Xe(d(i.prototype),"setColor",this).call(this,n,t)}},{key:"setSegment",value:function(e,t,r,n){var o=this._chunkSize,a=e*o+t;Xe(d(i.prototype),"setSegment",this).call(this,a,r,n),this._collisionGeo&&this._collisionGeo.setItem(e*o+t,r,n,.1)}},{key:"finalize",value:function(){this.finishUpdate(),this.computeBoundingSphere()}},{key:"setOpacity",value:function(e,t){for(var r=this._chunkSize,n=0,o=e.length;n<o;++n){var a=e[n]*r;Xe(d(i.prototype),"setOpacity",this).call(this,a,a+r-1,t)}}},{key:"getSubset",value:function(e){for(var t=e.length,r=this._chunkSize,n=new i(t,r,!1),o=0,a=e.length;o<a;++o){var s=o*r,l=e[o]*r;n.setSegments(s,this.getSubsetSegments(l,r)),n.setColors(s,this.getSubsetColors(l,r))}return n.boundingSphere=this.boundingSphere,n.boundingBox=this.boundingBox,[n]}},{key:"_init",value:function(e){this._chunkSize=e}}]),i}(mn);var xn=new i.Pa4,bn=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;return a(this,i),(t=n.call(this,2*e))._init(e),t._collisionGeo=new Wr(e,3),t}return l(i,[{key:"setItem",value:function(e,t,r){this._collisionGeo.setItem(e,t,r,.3);var n=2*e;xn.lerpVectors(t,r,.5),Xe(d(i.prototype),"setSegment",this).call(this,n,t,xn),Xe(d(i.prototype),"setSegment",this).call(this,n+1,xn,r)}},{key:"setColor",value:function(e,t,r){var n=2*e;Xe(d(i.prototype),"setColor",this).call(this,n,t),Xe(d(i.prototype),"setColor",this).call(this,n+1,r)}},{key:"raycast",value:function(e,t){this._collisionGeo&&this._collisionGeo.raycast(e,t)}},{key:"getSubset",value:function(e){for(var t=e.length,r=new i(t,!1),n=0,o=t;n<o;++n){var a=e[n];r.setSegments(n,this.getSubsetSegments(a,1)),r.setColors(n,this.getSubsetColors(a,1))}return r.boundingSphere=this.boundingSphere,r.boundingBox=this.boundingBox,[r]}},{key:"_init",value:function(e){this._segCounts=2*e}}]),i}(mn);var wn=[new i.Pa4(1,0,0),new i.Pa4(-1,0,0),new i.Pa4(0,1,0),new i.Pa4(0,-1,0),new i.Pa4(0,0,1),new i.Pa4(0,0,-1)],Sn=wn.length,Rn=new i.Pa4,Cn=new i.Pa4,An=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){return a(this,i),n.call(this,e,e,Sn/2|0,!1)}return l(i,[{key:"setItem",value:function(e,t,r){this.setSphere(e,t,r);for(var n=0;n<Sn/2;++n){var i=2*n;Rn.x=t.x+wn[i].x*r,Rn.y=t.y+wn[i].y*r,Rn.z=t.z+wn[i].z*r;var o=i+1;Cn.x=t.x+wn[o].x*r,Cn.y=t.y+wn[o].y*r,Cn.z=t.z+wn[o].z*r,this.setSegment(e,n,Rn,Cn)}}}]),i}(Lr(gn));var En=new i.Ilk,kn=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return a(this,i),(r=n.call(this))._opts=t,r.zClip=r._opts.zClip,r._posRad=$.allocateTyped(Float32Array,4*e),r._colors=$.allocateTyped(Float32Array,3*e),r}return l(i,[{key:"setItem",value:function(e,t,r){var n=this._posRad,i=4*e;n[i++]=t.x,n[i++]=t.y,n[i++]=t.z,n[i]=r}},{key:"setColor",value:function(e,t){En.set(t);var r=this._colors,n=3*e;r[n++]=En.r,r[n++]=En.g,r[n]=En.b}},{key:"finalize",value:function(){this.finishUpdate(),this.computeBoundingSphere()}},{key:"finishUpdate",value:function(){this._build()}},{key:"setOpacity",value:function(){}},{key:"raycast",value:function(){}},{key:"getSubset",value:function(){return[]}}]),i}(i.u9r),Pn=function(){function e(){a(this,e),this.pointsValuesLinear=null,this.hasIntersection=null,this.bitsInside=null}return l(e,[{key:"create",value:function(e){var t=e*e*e;if(t>117440512)throw new Error("Too large cube dimension: lead to memory huge uasge");return this.pointsValuesLinear=$.allocateTyped(Float32Array,32*t),this.hasIntersection=$.allocateTyped(Int32Array,t),this.bitsInside=$.allocateTyped(Int32Array,t),0}},{key:"destroy",value:function(){this.bitsInside=null,this.hasIntersection=null,this.pointsValuesLinear=null}}]),e}();Pn.prototype.striIndicesMarchCube=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];var Tn=[0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0],Mn=l((function e(){a(this,e),this._arrSize=8,this.p=new Array(this._arrSize),this.g=new Array(this._arrSize),this.val=new Array(this._arrSize);for(var t=0;t<this._arrSize;++t)this.p[t]=new i.Pa4,this.g[t]=new i.Pa4;this.cubeIndex=0})),Nn=l((function e(){a(this,e),this.a={p:new i.Pa4,n:new i.Pa4},this.b={p:new i.Pa4,n:new i.Pa4},this.c={p:new i.Pa4,n:new i.Pa4}}));function In(e){for(var t=new Array(e),r=0;r<e;++r)t[r]=new i.Pa4;return t}var On=function(){function e(){a(this,e),this._numTriangles=0,this._numVertices=0,this._position=[],this._normals=[],this._colors=null,this._indices=[],this._volumetricData=null,this._xAxis=new i.Pa4,this._yAxis=new i.Pa4,this._zAxis=new i.Pa4,this._xDir=new i.Pa4,this._yDir=new i.Pa4,this._zDir=new i.Pa4}return l(e,[{key:"_prepareAxesAndDirs",value:function(){var e=this._volumetricData.getCellSize(),t=this._xAxis,r=this._yAxis,n=this._zAxis,o=this._xDir,a=this._yDir,s=this._zDir;t.set(e.x,0,0),r.set(0,e.y,0),n.set(0,0,e.z),o.set(1,0,0),a.set(0,1,0),s.set(0,0,1);var l=new i.Pa4;if(l.crossVectors(o,a),l.dot(s)<0&&(o.negate(),a.negate(),s.negate()),o.x<0||o.y<0||o.z<0||a.x<0||a.y<0||a.z<0||s.x<0||s.y<0||s.z<0)return!1;var c=function(e){return Math.abs(e)>Number.EPSILON};return!(c(t.y)||c(t.z)||c(r.x)||c(r.z)||c(n.x)||c(n.y))}},{key:"_vertexInterp",value:function(e,t,r,n,i,o){var a=t.p[r],s=t.p[n],l=t.g[r],c=t.g[n],u=t.val[r],h=e-u,f=t.val[n]-u,d=0;Math.abs(f)>0&&(d=h/f),d=d>1?1:d,i.lerpVectors(a,s,d),o.lerpVectors(l,c,d)}},{key:"_polygonize",value:function(t,r,n){for(var i=t.cubeIndex,o=0,a=e._arrSize,s=e._firstIndices,l=e._secondIndices,c=e._vertexList,u=e._normalList;o<a;++o)Tn[i]&1<<o&&this._vertexInterp(r,t,s[o],l[o],c[o],u[o]);var h=0,f=16*i,d=e._triTable;for(o=0;-1!==d[f+o];o+=3)n[h].a.p.copy(c[d[f+o]]),n[h].a.n.copy(u[d[f+o]]),n[h].b.p.copy(c[d[f+o+1]]),n[h].b.n.copy(u[d[f+o+1]]),n[h].c.p.copy(c[d[f+o+2]]),n[h].c.n.copy(u[d[f+o+2]]),++h;return h}},{key:"_doGridPosNorms",value:function(e,t,r){for(var n,o=this._volumetricData,a=this._volumetricData.getData(),s=o.getDimensions(),l=s[0],c=s[1],u=s[2],h=t*o.getStrideX(),f=t*o.getStrideY(),d=t*o.getStrideZ(),p=new Mn,m=p.val,v=p.val.length,y=[new i.Pa4(0,0,0),new i.Pa4(t,0,0),new i.Pa4(t,t,0),new i.Pa4(0,t,0),new i.Pa4(0,0,t),new i.Pa4(t,0,t),new i.Pa4(t,t,t),new i.Pa4(0,t,t)],_=new Array(5),g=0;g<5;++g)_[g]=new Nn;var x,b=this,w=this._position,S=this._normals;r?(x=new i.Pa4(b._xAxis.x,b._yAxis.y,b._zAxis.z),n=function(e){var t=e.p.clone();t.multiply(x),w.push(t.add(b._origin)),S.push(e.n.clone())}):n=function(){var e=new i.Vkp;e.set(b._xAxis.x,b._yAxis.x,b._zAxis.x,b._xAxis.y,b._yAxis.y,b._zAxis.y,b._xAxis.z,b._yAxis.z,b._zAxis.z);var t=new i.Vkp;return t.set(b._xDir.x,b._yDir.x,b._zDir.x,b._xDir.y,b._yDir.y,b._zDir.y,b._xDir.z,b._yDir.z,b._zDir.z),function(r){w.push(r.p.clone().applyMatrix3(e).add(b._origin)),S.push(r.n.clone().applyMatrix3(t))}}();for(var R,C,A,E,k=this._indices,P=0,T=0;T<u-t;T+=t)for(var M=0;M<c-t;M+=t)for(var N=o.getDirectIdx(0,M,T),I=0;I<l-t;I+=t,N+=h){m[0]=a[N],m[1]=a[N+h],m[3]=a[N+f],m[2]=a[N+h+f],m[4]=a[N+d],m[5]=a[N+h+d],m[7]=a[N+f+d],m[6]=a[N+h+f+d];for(var O=0,L=0;L<v;++L)m[L]<e&&(O|=1<<L);if(0!==Tn[O]){for(p.cubeIndex=O,L=0;L<v;++L)p.p[L].set(I+y[L].x,M+y[L].y,T+y[L].z),R=this._gradient,C=p.p[L],A=p.g[L],void 0,E=R.getValue(C.x,C.y,C.z),A.set(E[0],E[1],E[2]);var B=this._polygonize(p,e,_);for(P+=B,L=0;L<B;++L)k.push(3*this._numTriangles),k.push(3*this._numTriangles+1),k.push(3*this._numTriangles+2),++this._numTriangles,n(_[L].a),n(_[L].b),n(_[L].c)}}return P}},{key:"compute",value:function(e,t,r,n){this._volumetricData=e,this._origin=t,this._gradient=e.computeGradient(),this._doGridPosNorms(r,n,this._prepareAxesAndDirs())}},{key:"_remapIndices",value:function(e,t){for(var r=this._indices,n=$.allocateTyped(Uint32Array,t),i=0;i<t;++i)r[i]=e[r[i]],n[i]=r[i];this._indices=n}},{key:"_remapVertices",value:function(e,t,r){for(var n=$.allocateTyped(Float32Array,3*r),i=$.allocateTyped(Float32Array,3*r),o=0;o<r;++o){var a=e[o];n[3*o]=a.x,n[3*o+1]=a.y,n[3*o+2]=a.z;var s=t[o].normalize();i[3*o]=s.x,i[3*o+1]=s.y,i[3*o+2]=s.z}this._position=n,this._normals=i}},{key:"vertexFusion",value:function(e,t){var r=this._indices.length,n=this._position,i=this._normals,o=0|n.length;if(0!==r&&0!==o){var a=$.allocateTyped(Uint32Array,o);a[0]=0;for(var s=1,l=1;l<o;++l){for(var c=s-e<0?0:s-e,u=c+t>s?s:c+t,h=-1,f=c;f<u;++f)if(Math.abs(n[l]-n[f])<Number.EPSILON){h=f;break}-1!==h?a[l]=h:(n[s].copy(n[l]),i[s].copy(i[l]),a[l]=s,++s)}this._remapIndices(a,r),this._remapVertices(n,i,s)}}},{key:"setColorVolTex",value:function(e,t,r,n){var i,o,a,s,l,c,u=this._position.length/3,h=this._position,f=this._origin,d=this._volumetricData.getDimensions(),p=d[0]-1,m=d[1]-1,v=d[2]-1,y=e.getData(),_=e.getStrideX(),g=e.getStrideY(),x=e.getStrideZ();null!==n&&(a=r.getData(),s=r.getStrideX(),l=r.getStrideY(),c=r.getStrideZ());var b=1/this._xAxis.x,w=1/this._yAxis.y,S=1/this._zAxis.z,R=[],C=[],A=$.allocateTyped(Float32Array,3*u);function E(e,t,r,n){n[0]=(1-e)*y[t]+e*y[r],n[1]=(1-e)*y[t+1]+e*y[r+1],n[2]=(1-e)*y[t+2]+e*y[r+2]}function k(e,r,n,i){var o=t[e];if(null!=o){R[o.index]=o;var s=r*n*i*a[e];void 0===C[o.index]?C[o.index]=s:C[o.index]+=s}}var P=$.allocateTyped(Int32Array,u),T=0;for(i=0;i<u;i++){var M=3*i,N=(h[M]-f.x)*b,I=(h[M+1]-f.y)*w,O=(h[M+2]-f.z)*S,L=0|Math.min(Math.max(N,0),p),B=0|Math.min(Math.max(I,0),m),D=0|Math.min(Math.max(O,0),v),z=N-L,F=I-B,V=O-D;if(null!=n){R=[],C=[],k(o=r.getDirectIdx(L,B,D),1-z,1-F,1-V),k(o+s,z,1-F,1-V),k(o+l,1-z,F,1-V),k(o+s+l,z,F,1-V),k(o+c,1-z,1-F,V),k(o+s+c,z,1-F,V),k(o+l+c,1-z,F,V),k(o+s+l+c,z,F,V);var U=0,G=-1;for(var j in C)C[j]>U&&(G=j,U=C[j]);if(G<0||!n.includesAtom(R[G])){P[i]=-1;continue}}P[i]=T++;var H=L<p?_:0,W=B<m?g:0,Y=D<v?x:0,X=[0,0,0],q=[0,0,0],Z=[0,0,0],K=[0,0,0];E(z,o=e.getDirectIdx(L,B,D),o+H,X),E(z,o+W,o+H+W,q),E(z,o+Y,o+H+Y,Z),E(z,o+W+Y,o+H+W+Y,K);var Q=[0,0,0];Q[0]=(1-F)*X[0]+F*q[0],Q[1]=(1-F)*X[1]+F*q[1],Q[2]=(1-F)*X[2]+F*q[2];var J=[0,0,0];J[0]=(1-F)*Z[0]+F*K[0],J[1]=(1-F)*Z[1]+F*K[1],J[2]=(1-F)*Z[2]+F*K[2],A[M]=(1-V)*Q[0]+V*J[0],A[M+1]=(1-V)*Q[1]+V*J[1],A[M+2]=(1-V)*Q[2]+V*J[2]}if(this._colors=A,null!=n){for(i=0;i<u;++i){var ee=P[i];ee<0||(this._position[3*ee]=this._position[3*i],this._position[3*ee+1]=this._position[3*i+1],this._position[3*ee+2]=this._position[3*i+2],this._normals[3*ee]=this._normals[3*i],this._normals[3*ee+1]=this._normals[3*i+1],this._normals[3*ee+2]=this._normals[3*i+2],this._colors[3*ee]=this._colors[3*i],this._colors[3*ee+1]=this._colors[3*i+1],this._colors[3*ee+2]=this._colors[3*i+2])}var te=this._indices.length/3,re=0;for(i=0;i<te;++i){var ne=P[this._indices[3*i]],ie=P[this._indices[3*i+1]],oe=P[this._indices[3*i+2]];ne>=0&&ie>=0&&oe>=0&&(this._indices[3*re]=ne,this._indices[3*re+1]=ie,this._indices[3*re+2]=oe,++re)}this._position=new Float32Array(this._position.buffer.slice(0,3*T*4)),this._normals=new Float32Array(this._normals.buffer.slice(0,3*T*4)),this._colors=new Float32Array(this._colors.buffer.slice(0,3*T*4)),this._indices=new Uint32Array(this._indices.buffer.slice(0,3*re*4))}}},{key:"toMesh",value:function(){var e=new i.u9r;return e.setIndex(new i.TlE(this._indices,1)),e.setAttribute("position",new i.TlE(this._position,3)),e.setAttribute("normal",new i.TlE(this._normals,3)),e.setAttribute("color",new i.TlE(this._colors,3)),e.computeBoundingSphere(),e}}]),e}();Re(On,"_triTable",Pn.prototype.striIndicesMarchCube),Re(On,"_arrSize",12),Re(On,"_firstIndices",[0,1,2,3,4,5,6,7,0,1,2,3]),Re(On,"_secondIndices",[1,2,3,0,5,6,7,4,4,5,6,7]),Re(On,"_vertexList",In(On._arrSize)),Re(On,"_normalList",In(On._arrSize));var Ln=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return a(this,o),n.apply(this,arguments)}return l(o,[{key:"_build",value:function(){var e=this._opts;this.numVoxels=[128,128,128],this.xAxis=new i.Pa4(1,0,0),this.yAxis=new i.Pa4(0,1,0),this.zAxis=new i.Pa4(0,0,1),this.origin=new i.Pa4(0,0,0),this._visibilitySelector=e.visibilitySelector,this._calcSurface(e)}},{key:"_findMinMax",value:function(e){for(var t=e.length/4,r=[e[0],e[1],e[2],e[3]],n=[e[0],e[1],e[2],e[3]],i=1;i<t;++i)for(var o=4*i,a=0;a<4;++a){var s=e[o+a];r[a]=Math.max(s,r[a]),n[a]=Math.min(s,n[a])}return{maxPosRad:r,minPosRad:n}}},{key:"_findNumVoxels",value:function(e,t){var r=this.numVoxels,n=this._findMinMax(e),i=n.minPosRad,o=n.maxPosRad;i[3]>4&&(t.gridSpacing*=i[3]);var a=t.radScale*o[3]*1.7,s=a;s=.65*Math.sqrt(4/3*Math.PI*s*s*s),a=Math.max(a,s);for(var l=0;l<3;++l)i[l]-=a,o[l]+=a;for(l=0;l<3;++l)r[l]=Math.ceil((o[l]-i[l])/t.gridSpacing);this.xAxis.x=(r[0]-1)*t.gridSpacing,this.yAxis.y=(r[1]-1)*t.gridSpacing,this.zAxis.z=(r[2]-1)*t.gridSpacing;var c=v(i,3);return this.origin.x=c[0],this.origin.y=c[1],this.origin.z=c[2],{bbox:n,dim:r}}},{key:"_makeSurface",value:function(e,t){var r=new On;r.compute(e.volMap,this.origin,t.isoValue,1),r.vertexFusion(9,9),r._numTriangles>0?(r.setColorVolTex(e.volTexMap,e.atomMap,e.atomWeightMap,this._visibilitySelector),this.setIndex(new i.TlE(r._indices,1)),this.setAttribute("position",new i.TlE(r._position,3)),this.setAttribute("normal",new i.TlE(r._normals,3)),this.setAttribute("color",new i.TlE(r._colors,3))):this.setAttribute("position",new i.TlE($.allocateTyped(Float32Array,0),3))}},{key:"_calcSurface",value:function(e){var t={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};if(0!==t.posRad.length){var r=this._findNumVoxels(t.posRad,e),n=new i.ZzF(this.origin,new i.Pa4(this.xAxis.x,this.yAxis.y,this.zAxis.z).add(this.origin)),o=this._computeSurface(t,n,r,e);this._makeSurface(o,e)}}}]),o}(kn);var Bn=pr.Volume,Dn=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_computeSurface",value:function(e,t,r,n){this._shiftByOrigin(e.posRad);var i={volMap:new Bn(Float32Array,this.numVoxels,t),volTexMap:new Bn(Float32Array,this.numVoxels,t,3)};return null!=this._visibilitySelector&&(i.atomMap=[],i.atomWeightMap=new Bn(Float32Array,this.numVoxels,t)),this.gaussdensity(i,e,null,n),i}},{key:"gaussdensity",value:function(e,t,r,n){var i,o=t.posRad.length/4,a=t.posRad,s=t.colors,l=this.numVoxels,c=n.radScale,u=n.gaussLim,h=n.gridSpacing,f=1/n.isoValue,d=1/h,p=l[0]-1,m=l[1]-1,v=l[2]-1,y=e.volMap,_=e.volTexMap,g=y.getData(),x=y.getStrideX(),b=_.getData(),w=_.getStrideX();null!=this._visibilitySelector&&(i=e.atomWeightMap.getData());for(var S=e.atomMap,R=0;R<o;++R){var C=4*R,A=a[C+3]*c,E=null===r?1:r[R],k=1/(2*A*A),P=u*A,T=P*P;P*=d;var M=a[C]*d,N=Math.max(M-P|0,0),I=Math.min(M+P|0,p);M=a[C+1]*d;var O=Math.max(M-P|0,0),L=Math.min(M+P|0,m);M=a[C+2]*d;for(var B=Math.max(M-P|0,0),D=Math.min(M+P|0,v),z=B*h-a[C+2],F=B;F<=D;++F,z+=h)for(var V=O*h-a[C+1],U=O;U<=L;++U,V+=h){var G=V*V+z*z;if(!(G>=T))for(var j=y.getDirectIdx(N,U,F),H=_.getDirectIdx(N,U,F),W=N*h-a[C],Y=N;Y<=I;++Y,W+=h,j+=x,H+=w){var X=-(W*W+G)*k,q=Math.exp(X)*E;null!=this._visibilitySelector&&q>i[j]&&(i[j]=q,S[j]=t.atoms[R]),g[j]+=q,q*=f;var $=3*R;b[H]+=q*s[$],b[H+1]+=q*s[$+1],b[H+2]+=q*s[$+2]}}}}},{key:"_shiftByOrigin",value:function(e){for(var t=this.origin.x,r=this.origin.y,n=this.origin.z,i=e.length/4,o=0;o<i;++o){var a=4*o;e[a]-=t,e[a+1]-=r,e[a+2]-=n}}}]),i}(Ln);function zn(e,t,r,n){var i=e.length/4,o=t[0],a=t[1],s=t[2],l=r[0],c=r[1],u=r[2];function h(e,t){return Math.floor((e-t)/n)}var f,d,p,m,v,y=h(l,o)+1,_=h(c,a)+1,g=h(u,s)+1,x=y*_*g,b=_*g,w=[];for(f=0;f<i;f++){var S=4*f;p=e[S],m=e[S+1],v=e[S+2],void 0===w[d=(h(p,o)*_+h(m,a))*g+h(v,s)]?w[d]=[f]:w[d].push(f)}var R,C=$.allocateTyped(Uint32Array,x),A=$.allocateTyped(Uint16Array,x),E=$.allocateTyped(Uint32Array,i),k=0,P=0;for(f=0;f<x;f++){var T=C[f]=k,M=w[f];if(void 0!==M)for(R=0;R<M.length;R++)E[k]=M[R],k++;var N=k-T;A[f]=N,N>P&&(P=N)}this.neighbourListLength=27*P+1,this.withinRadii=function(t,r,n,i,l){var c=0,u=h(t,o),p=h(r,a),m=h(n,s),v=Math.max(0,u-1),x=Math.max(0,p-1),w=Math.max(0,m-1),S=Math.min(y-1,u+1),k=Math.min(_-1,p+1),P=Math.min(g-1,m+1);for(f=v;f<=S;++f){var T=f*b;for(R=x;R<=k;++R)for(var M=R*g,N=w;N<=P;++N)for(var I=C[d=T+M+N],O=I+A[d],L=I;L<O;L++){var B=4*E[L],D=e[B]-t,z=e[B+1]-r,F=e[B+2]-n,V=e[B+3]+i;D*D+z*z+F*F<=V*V&&(l[c++]=E[L])}}l[c]=-1}}function Fn(e,t,r,n){var o,a,s,l,c,u,h,f,d,p,m,v,y,_,g,x,b,w=4,S=e.posRad,R=e.colors,C=e.atoms,A=S.length/w,E=t.bbox,k=E.minPosRad,P=E.maxPosRad,T=-1,M=null,N=null,I=null,O=new i.Pa4(0,0,0),L=new i.Pa4(0,0,0),B=new i.Pa4(0,0,0);function D(e,t,r){for(var n=0;n<e.length;n++)e[n]=t+r*n}function z(){s=r.probeRadius,l=r.scaleFactor,c=r.probePositions,I=r.visibilitySelector,o=$.allocateTyped(Float32Array,A),a=0;for(var e=0;e<A;++e){var n=S[e*w+3]+=s;n>a&&(a=n),o[e]=n*n}(function(){l=r.scaleFactor,u=t.dim,b=Math.min(5,2+Math.floor(s*l));var e=u[0]*u[1]*u[2];h=function(e,t,r){for(var n=$.allocateTyped(e,t),i=0;i<t;++i)n[i]=-1001;return n}(Float32Array,e),f=$.allocateTyped(Float32Array,3*e),d=$.allocateTyped(Float32Array,e),I&&(M=$.allocateTyped(Float32Array,e),N=[]),p=$.allocateTyped(Float32Array,u[0]),m=$.allocateTyped(Float32Array,u[1]),v=$.allocateTyped(Float32Array,u[2]),D(p,k[0],1/l),D(m,k[1],1/l),D(v,k[2],1/l)})(),function(){var e=0,t=2*Math.PI/c;_=$.allocateTyped(Float32Array,c),y=$.allocateTyped(Float32Array,c);for(var r=0;r<c;r++)_[r]=Math.cos(e),y[r]=Math.sin(e),e+=t}(),g=new zn(S,k,P,2.01*a),x=new Int32Array(g.neighbourListLength),T=-1}function F(e,t,r,n){var i=w*e,a=o[e],s=S[i]-t,l=S[i+1]-r,c=S[i+2]-n;return s*s+l*l+c*c<a}function V(e,t,r,n,i){var o;if(-1!==T){if((o=T)!==n&&o!==i&&F(o,e,t,r))return o;T=-1}var a=0;for(o=x[a];o>=0;){if(o!==n&&o!==i&&F(o,e,t,r))return T=o,o;o=x[++a]}return T=-1,-1}function U(e,t){var r=w*e,n=w*t,i=S[r],o=S[r+1],a=S[r+2],s=S[r+3],f=O.x=S[n]-i,d=O.y=S[n+1]-o,g=O.z=S[n+2]-a,x=S[n+3],R=f*f+d*d+g*g,C=Math.sqrt(R),A=s*((s*s+C*C-x*x)/(2*s*C));O.normalize(),function(e,t){e.x=e.y=e.z=1,0!==t.x?e.x=(t.y+t.z)/-t.x:0!==t.y?e.y=(t.x+t.z)/-t.y:0!==t.z&&(e.z=(t.x+t.y)/-t.z)}(L,O),L.normalize(),B.crossVectors(O,L),B.normalize();var E=Math.sqrt(s*s-A*A);L.multiplyScalar(E),B.multiplyScalar(E),O.multiplyScalar(A),O.x+=i,O.y+=o,O.z+=a,T=-1;for(var P=b,M=0;M<c;M++){var N=_[M],I=y[M],D=O.x+N*L.x+I*B.x,z=O.y+N*L.y+I*B.y,F=O.z+N*L.z+I*B.z;if(-1===V(D,z,F,e,t))for(var U=Math.floor(l*(D-k[0])),G=Math.floor(l*(z-k[1])),j=Math.floor(l*(F-k[2])),H=Math.max(0,U-P),W=Math.max(0,G-P),Y=Math.max(0,j-P),X=Math.min(u[0],U+P+2),q=Math.min(u[1],G+P+2),$=Math.min(u[2],j+P+2),Z=Y;Z<$;Z++){g=F-v[Z];for(var K=u[1]*u[0]*Z,Q=W;Q<q;Q++)for(var J=g*g+(d=z-m[Q])*d,ee=K+u[0]*Q,te=H;te<X;te++){R=J+(f=D-p[te])*f;var re=te+ee,ne=h[re];ne>0&&R<ne*ne&&(h[re]=Math.sqrt(R))}}}}this.build=function(){console.time("ContactSurface.getVolume"),console.time("ContactSurface.init"),z(),console.timeEnd("ContactSurface.init"),console.time("ContactSurface.projectPoints"),function(){for(var e=0;e<A;e++){var t=w*e,r=S[t],n=S[t+1],i=S[t+2],a=S[t+3],s=o[e];g.withinRadii(r,n,i,a,x);for(var c=Math.ceil(a*l),y=Math.floor(l*(r-k[0])),_=Math.floor(l*(n-k[1])),b=Math.floor(l*(i-k[2])),E=Math.max(0,y-c),P=Math.max(0,_-c),T=Math.max(0,b-c),O=Math.min(u[0],y+c+2),L=Math.min(u[1],_+c+2),B=Math.min(u[2],b+c+2),D=3*e,z=R[D],F=R[D+1],U=R[D+2],G=T;G<B;G++)for(var j=v[G]-i,H=u[1]*u[0]*G,W=P;W<L;W++)for(var Y=m[W]-n,X=j*j+Y*Y,q=H+u[0]*W,$=E;$<O;$++){var Z=$+q,K=p[$]-r,Q=X+K*K;if(Q<s){var J=Math.exp(.28125*-Q),ee=3*Z;f[ee]+=z*J,f[ee+1]+=F*J,f[ee+2]+=U*J,d[Z]+=J,null!==I&&J>M[Z]&&(M[Z]=J,N[Z]=C[e]),h[Z]<0&&(h[Z]=-h[Z]);var te=Math.sqrt(Q),re=a/te,ne=K*re,ie=Y*re,oe=j*re;if(-1===V(ne+=r,ie+=n,oe+=i,e,-1)){var ae=a-te;ae<h[Z]&&(h[Z]=ae)}}}}}(),console.timeEnd("ContactSurface.projectPoints"),console.time("ContactSurface.projectTorii"),function(){for(var e=0;e<A;e++){var t=w*e;g.withinRadii(S[t],S[t+1],S[t+2],S[t+3],x);for(var r=0,n=x[r];n>=0;)e<n&&U(e,n),n=x[++r]}}(),console.timeEnd("ContactSurface.projectTorii"),function(){for(var e=0,t=h.length;e<t;e++){h[e]<0&&(h[e]=0);var r=d[e];if(r>0){r=1/r;var n=3*e;f[n]*=r,f[n+1]*=r,f[n+2]*=r}}}(),console.timeEnd("ContactSurface.getVolume"),this.volTexMap=f,this.weightsMap=M,this.atomMap=N,this.volMap=h}}var Vn=pr.Volume,Un=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_computeSurface",value:function(e,t,r,n){var i=new Fn(e,r,n);return i.build(),{volMap:new Vn(Float32Array,this.numVoxels,t,1,i.volMap),volTexMap:new Vn(Float32Array,this.numVoxels,t,3,i.volTexMap),atomMap:i.atomMap,atomWeightMap:new Vn(Float32Array,this.numVoxels,t,1,i.weightsMap)}}}]),i}(Ln),Gn=l((function e(t,r){a(this,e),this.coord=new i.Pa4,this.coord.copy(t),this.radius=r,this.colorX=.99999,this.colorY=0,this.colorZ=0,this.atomType=0,this.srcAtom=null})),jn=function(){function e(t,r,n,o,s){a(this,e),this._numAtoms=t,this._atoms=r,this._vBoxMin=new i.Pa4,this._vBoxMax=new i.Pa4,this._vBoxMin.copy(n),this._vBoxMax.copy(o),this._probeRadius=s,this._atomsList=null,this._voxelList=null}return l(e,[{key:"createVoxels",value:function(){var e,t,r=0|this._numAtoms,n=this._atoms,i=this._vBoxMax.x-this._vBoxMin.x,o=this._vBoxMax.y-this._vBoxMin.y,a=this._vBoxMax.z-this._vBoxMin.z,s=i<o?i:o;s=a<s?a:s;var l,c=0,u=0;for(l=0;l<r;l++)c=(t=2*(n[l].radius+this._probeRadius))>c?t:c,u+=t;var h=Math.floor(s/c);h<2&&(h=2),u/=r,this._numCells=h,this._aveRad=u,this._maxRad=c;var f=h,d=h*h,p=h*h*h,m=this._xScale=1/(this._vBoxMax.x-this._vBoxMin.x),v=this._yScale=1/(this._vBoxMax.y-this._vBoxMin.y),y=this._zScale=1/(this._vBoxMax.z-this._vBoxMin.z),_=0,g=m*h,x=v*h,b=y*h;for(l=0;l<r;l++){var w=4.5*(n[l].radius+this._probeRadius)*2,S=Math.floor(g*w+.8),R=Math.floor(x*w+.8),C=Math.floor(b*w+.8);_+=++S*++R*++C}this._voxelList=$.allocateTyped(Int32Array,p);var A=[];if(A.length=_,null===this._voxelList||null===A)return-1;for(l=0;l<p;l++)this._voxelList[l]=-1;for(e=0,l=0;l<r;l++){t=4.5*(n[l].radius+this._probeRadius);var E=Math.floor((n[l].coord.x-this._vBoxMin.x-t)*h*m),k=Math.floor((n[l].coord.y-this._vBoxMin.y-t)*h*v),P=Math.floor((n[l].coord.z-this._vBoxMin.z-t)*h*y),T=Math.floor((n[l].coord.x-this._vBoxMin.x+t)*h*m),M=Math.floor((n[l].coord.y-this._vBoxMin.y+t)*h*v),N=Math.floor((n[l].coord.z-this._vBoxMin.z+t)*h*y);E=E>=0?E:0,k=k>=0?k:0,T=T<h?T:h-1,M=M<h?M:h-1,N=N<h?N:h-1;for(var I=P=P>=0?P:0;I<=N;I++)for(var O=k;O<=M;O++)for(var L=E;L<=T;L++){var B=L+O*f+I*d;if(this._voxelList[B]<0)A[2*e+0]=l,A[2*e+1]=-1,this._voxelList[B]=e,e++;else{var D=this._voxelList[B];this._voxelList[B]=e,A[2*e+0]=l,A[2*e+1]=D,e++}}}return this._atomsList=Int32Array.from(A),0}},{key:"destroyVoxels",value:function(){this._atomsList=null,this._voxelList=null,this._atoms=null,this._vertices=null,this._vBoxMin=null,this._vBoxMax=null}},{key:"forEachRelatedAtom",value:function(e,t){for(var r=Math.floor((e.x-this._vBoxMin.x)*this._numCells*this._xScale),n=Math.floor((e.y-this._vBoxMin.y)*this._numCells*this._yScale),i=Math.floor((e.z-this._vBoxMin.z)*this._numCells*this._zScale),o=r+n*this._numCells+i*this._numCells*this._numCells,a=this._atoms,s=this._voxelList[o];s>=0;s=this._atomsList[2*s+1])t(a[this._atomsList[2*s]])}},{key:"getClosestAtom",value:function(e){var t=null,r=Number.MAX_VALUE;return this.forEachRelatedAtom(e,(function(n){var i=e.distanceToSquared(n.coord);i<r&&(r=i,t=n)})),t}},{key:"buildNormals",value:function(e,t,r){for(var n,i=this,o=0,a=0,s=0,l=0,c=0,u=0,h=0,f=0,d=0,p=2.5*this._aveRad,m=p*p,v=.1*-this._aveRad,y=function(e){var t=a-e.coord.x,r=s-e.coord.y,p=l-e.coord.z;if(!((n=t*t+r*r+p*p)>m)){var y=e.radius+i._probeRadius;(f=n-y*y)<0&&(f=-f),d=Math.exp(v*f),c+=t*d,u+=r*d,h+=p*d,o++}},_=0;_<e;_++)a=t[_].x,s=t[_].y,l=t[_].z,o=0,c=u=h=0,this.forEachRelatedAtom(t[_],y),n=c*c+u*u+h*h,o>0&&(f=1/Math.sqrt(n),c*=f,u*=f,h*=f),r[_].x=c,r[_].y=u,r[_].z=h;return 0}},{key:"buildColors",value:function(e,t,r,n){for(var i=this,o=0,a=0,s=0,l=0,c=0,u=n*n,h=[],f=[],d=0,p=function(e){var t=o-e.coord.x,r=a-e.coord.y,n=s-e.coord.z,p=t*t+r*r+n*n;if(!(p>u)){var m=e.radius+i._probeRadius;(l=p-m*m)<0&&(l=-l),c=1/(.8+l),h.push([e.colorX,e.colorY,e.colorZ]),f.push(c),d+=c}},m=0;m<e;m++){o=t[m].x,a=t[m].y,s=t[m].z,h=[],f=[],d=0,this.forEachRelatedAtom(t[m],p);for(var v=0;v<h.length;++v){var y=f[v]/d;r[m].x+=h[v][0]*y,r[m].y+=h[v][1]*y,r[m].z+=h[v][2]*y}}return 0}}]),e}(),Hn=function(){function e(t,r,n){var o;for(a(this,e),this._maxNumVertices=t,this._maxNumTriangles=r,this._vertices=new Array(t),this._normals=new Array(t),this._colors=null,n&&(this._colors=new Array(t)),this._indices=new Array(3*r),this._numVertices=0,this._numTriangles=0,o=0;o<t;o++)this._vertices[o]=new i.Pa4,this._normals[o]=new i.Pa4;for(o=0;o<3*r;o++)this._indices[o]=-1;if(n)for(o=0;o<t;o++)this._colors[o]=new i.Pa4}return l(e,[{key:"destroy",value:function(){this._vertices=null,this._normals=null,this._indices=null}}]),e}();var Wn=pr.Element,Yn=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return a(this,o),n.apply(this,arguments)}return l(o,[{key:"_build",value:function(){this._innerBuild();var e=this.getGeo();this.destroy(),this._fromGeo(e)}},{key:"_fromGeo",value:function(e){var t=null,r=$.allocateTyped(Float32Array,3*e._numVertices),n=$.allocateTyped(Float32Array,3*e._numVertices);null!==e._colors&&(t=$.allocateTyped(Float32Array,3*e._numVertices));for(var o=$.allocateTyped(Uint32Array,3*e._numTriangles),a=0,s=0;a<e._numVertices;a++)r[s+0]=e._vertices[a].x,r[s+1]=e._vertices[a].y,r[s+2]=e._vertices[a].z,n[s+0]=e._normals[a].x,n[s+1]=e._normals[a].y,n[s+2]=e._normals[a].z,s+=3;if(null!==t)for(var l=0,c=0;l<e._numVertices;l++,c+=3)t[c+0]=e._colors[l].x,t[c+1]=e._colors[l].y,t[c+2]=e._colors[l].z;for(var u=3*e._numTriangles,h=0;h<u;h++)o[h]=e._indices[h];this.setIndex(new i.TlE(o,1)),this.setAttribute("position",new i.TlE(r,3)),this.setAttribute("normal",new i.TlE(n,3)),this.setAttribute("color",new i.TlE(t,3)),this.computeBoundingBox(),this.computeBoundingSphere(),e.destroy()}},{key:"convertToAtomsColored",value:function(e,t){for(var r=e.atoms,n=e.colors,i=0,o=r.length;i<o;i++){var a=r[i].position,s=r[i].element.radius;t[i]=new Gn(a,s);var l=r[i].element.number;t[i].atomType=this.getType(l);var c=3*i;t[i].colorX=n[c++],t[i].colorY=n[c++],t[i].colorZ=n[c],t[i].srcAtom=r[i]}}},{key:"getGeo",value:function(){return this.geoOut}},{key:"destroy",value:function(){this.atoms=null,this.hashLines=null,this.hashEntries=null}},{key:"getBoundingBox",value:function(e,t,r){var n=1e7;t.x=t.y=t.z=n,r.x=r.y=r.z=0-n;for(var i=this.probeRadius*this.atomRadiusScale,o=0,a=0,s=e.length;a<s;a++){var l=e[a].coord,c=e[a].radius+i;o=c>o?c:o,l.x-c<t.x&&(t.x=l.x-c),l.y-c<t.y&&(t.y=l.y-c),l.z-c<t.z&&(t.z=l.z-c),l.x+c>r.x&&(r.x=l.x+c),l.y+c>r.y&&(r.y=l.y+c),l.z+c>r.z&&(r.z=l.z+c)}t.x-=o,t.y-=o,t.z-=o,r.x+=o,r.y+=o,r.z+=o}},{key:"getCornerCoord",value:function(e,t,r,n,i,o,a){var s=1/(o-1),l=r*s,c=n*s,u=i*s;a.x=e.x*(1-l)+t.x*l,a.y=e.y*(1-c)+t.y*c,a.z=e.z*(1-u)+t.z*u}},{key:"buildEdgePoint",value:function(e,t,r,n,i,o){if(r[e]^r[t]){var a=(0-n.pointsValuesLinear[i+24+e])/(n.pointsValuesLinear[i+24+t]-n.pointsValuesLinear[i+24+e]),s=n.pointsValuesLinear[i+3*e+0],l=n.pointsValuesLinear[i+3*e+1],c=n.pointsValuesLinear[i+3*e+2],u=n.pointsValuesLinear[i+3*t+0],h=n.pointsValuesLinear[i+3*t+1],f=n.pointsValuesLinear[i+3*t+2];o.x=s*(1-a)+u*a,o.y=l*(1-a)+h*a,o.z=c*(1-a)+f*a}}},{key:"isTriangleVisible",value:function(e,t,r){var n=this.voxelWorld.getClosestAtom(e),i=this.voxelWorld.getClosestAtom(t),o=this.voxelWorld.getClosestAtom(r);return null!==n&&null!==i&&null!==o&&null!==n.srcAtom&&null!==i.srcAtom&&null!==o.srcAtom&&this.visibilitySelector.includesAtom(n.srcAtom)&&this.visibilitySelector.includesAtom(i.srcAtom)&&this.visibilitySelector.includesAtom(o.srcAtom)}},{key:"addTriangle",value:function(e,t,r){if(this.visibilitySelector&&!this.isTriangleVisible(e,t,r))return!0;var n=this.geoOut;if(n._numTriangles>=this.maxNumTriangles)return!1;var i=this.addVertexToGeo(n,e),o=this.addVertexToGeo(n,t),a=this.addVertexToGeo(n,r);if((i|o|a)<0)return!1;var s=3*n._numTriangles;return n._indices[s+0]=i,n._indices[s+1]=o,n._indices[s+2]=a,n._numTriangles++,!0}},{key:"buildGeoFromCorners",value:function(e,t,r,n,o,a){for(var s=e-1,l=e,c=e*e,u=new Array(12),h=0;h<12;h++)u[h]=new i.Pa4;for(var f=[],d=0;d<8;d++)f[d]=1;for(var p=new i.Pa4,m=0,v=0,y=0;y<s;y++,v+=c)for(var _=0,g=0;g<s;g++,_+=l)for(var x=0;x<s;x++)if(a.hasIntersection[m]){var b=a.bitsInside[m];this.getCornerCoord(t,r,x,y,g,e,p);for(var w=32*m,S=0,R=0;S<8;S++)a.pointsValuesLinear[w+R++]=p.x,a.pointsValuesLinear[w+R++]=p.y,a.pointsValuesLinear[w+R++]=p.z;a.pointsValuesLinear[w+3]+=o.x,a.pointsValuesLinear[w+6]+=o.x,a.pointsValuesLinear[w+15]+=o.x,a.pointsValuesLinear[w+18]+=o.x,a.pointsValuesLinear[w+6+2]+=o.z,a.pointsValuesLinear[w+9+2]+=o.z,a.pointsValuesLinear[w+18+2]+=o.z,a.pointsValuesLinear[w+21+2]+=o.z,a.pointsValuesLinear[w+12+1]+=o.y,a.pointsValuesLinear[w+15+1]+=o.y,a.pointsValuesLinear[w+18+1]+=o.y,a.pointsValuesLinear[w+21+1]+=o.y;for(var C=w+24,A=0;A<8;++A)f[A]=a.pointsValuesLinear[C+A]<0?1:0;this.buildEdgePoint(0,1,f,a,w,u[0]),this.buildEdgePoint(1,2,f,a,w,u[1]),this.buildEdgePoint(2,3,f,a,w,u[2]),this.buildEdgePoint(3,0,f,a,w,u[3]),this.buildEdgePoint(4,5,f,a,w,u[4]),this.buildEdgePoint(5,6,f,a,w,u[5]),this.buildEdgePoint(6,7,f,a,w,u[6]),this.buildEdgePoint(7,4,f,a,w,u[7]),this.buildEdgePoint(0,4,f,a,w,u[8]),this.buildEdgePoint(1,5,f,a,w,u[9]),this.buildEdgePoint(2,6,f,a,w,u[10]),this.buildEdgePoint(3,7,f,a,w,u[11]);for(var E=16*b,k=0,P=0;k<6;k++,P+=3){var T=a.striIndicesMarchCube[E+P];if(T<0)break;var M=a.striIndicesMarchCube[E+P+1],N=a.striIndicesMarchCube[E+P+2];if(!this.addTriangle(u[T],u[M],u[N]))return-2}m++}else m++;return 0}},{key:"getNumIntersectedCells",value:function(e,t,r,n){for(var i=e*e,o=0,a=0,s=0,l=0;l<t;l++,s+=i)for(var c=0,u=0;u<t;u++,c+=e)for(var h=0;h<t;h++){var f=32*a+24,d=h+c+s;n.pointsValuesLinear[f]=r[d],n.pointsValuesLinear[f+1]=r[d+1],n.pointsValuesLinear[f+2]=r[d+e+1],n.pointsValuesLinear[f+3]=r[d+e],n.pointsValuesLinear[f+4]=r[i+d],n.pointsValuesLinear[f+5]=r[i+d+1],n.pointsValuesLinear[f+6]=r[i+d+e+1],n.pointsValuesLinear[f+7]=r[i+d+e];for(var p=0,m=0;m<8;++m)n.pointsValuesLinear[f+m]<0&&(p|=1<<m);0===p||255===p?n.hasIntersection[a]=!1:(n.hasIntersection[a]=!0,o++),n.bitsInside[a]=p,a++}return o}},{key:"getType",value:function(e){var t=[0,0,1,1,2,6,3,6,4,6,5,6,6,0,7,3,8,2,9,6,10,6,11,6,12,6,13,6,14,6,15,4,16,5,17,6,18,6,19,6,20,6,21,6,22,6,23,6,24,6,25,6,26,6,27,6,28,6,29,6,30,6,31,6,32,6,33,6,34,6,35,6,36,6,37,6,38,6,39,6,40,6,41,6,42,6,43,6,44,6,45,6,46,6,47,6,48,6,49,6,50,6,51,6,52,6,53,6,54,6,55,6,56,6,57,6,58,6,59,6,60,6,61,6,62,6,63,6,64,6,65,6,66,6,67,6,68,6,69,6,70,6,71,6,72,6,73,6,74,6,75,6,76,6,77,6,78,6,79,6,80,6,81,6,82,6,83,6,84,6,85,6,86,6,87,6,88,6,89,6,90,6,91,6,92,6,93,6,94,6,95,6,96,6,97,6,98,6,99,6,100,6,101,6,102,6,103,6,104,6,105,6,106,6,107,6,108,6,109,6];if(e<1||e>t.length/2||2*Object.keys(Wn.ByAtomicNumber).length!==t.length)throw new Error("atomT.length should be equal Element.ByAtomicNumber.length * 2");return t[2*e]}},{key:"calculateGridCorners",value:function(e,t,r,n,o,a){for(var s=t*t,l=s*t,c=new i.Pa4,u=new i.Pa4,h=0;h<l;h++)e[h]=1e12;for(var f=(t-1)/(n.x-r.x),d=(t-1)/(n.y-r.y),p=(t-1)/(n.z-r.z),m=0,v=o.length;m<v;m++){var y=o[m],_=y.radius+a,g=(y.coord.x-_-r.x)*f,x=(y.coord.y-_-r.y)*d,b=(y.coord.z-_-r.z)*p,w=Math.floor(g),S=Math.floor(x),R=Math.floor(b),C=Math.floor((y.coord.x+_-r.x)*f),A=Math.floor((y.coord.y+_-r.y)*d),E=Math.floor((y.coord.z+_-r.z)*p);C=++C<=t-1?C:t-1,A=++A<=t-1?A:t-1,E=++E<=t-1?E:t-1;for(var k=S;k<=A;k++)for(var P=k*s,T=R;T<=E;T++)for(var M=T*t,N=w;N<=C;N++){var I=P+M+N;this.getCornerCoord(r,n,N,k,T,t,c),u.x=c.x-y.coord.x,u.y=c.y-y.coord.y,u.z=c.z-y.coord.z;var O=Math.sqrt(u.x*u.x+u.y*u.y+u.z*u.z)-_;O<e[I]&&(e[I]=O)}}}},{key:"createVertexHash",value:function(e,t){if(this.hashLines=$.allocateTyped(Int32Array,65536),null===this.hashLines)return-1;for(var r=0,n=0;r<32768;r++)this.hashLines[n++]=0,this.hashLines[n++]=-1;if(this.maxNumVertices=e,this.maxNumTriangles=t,this.numHashEtriesAllocated=e,this.hashEntries=$.allocateTyped(Int32Array,2*this.numHashEtriesAllocated),null===this.hashEntries)return-1;for(var i=0,o=0;i<this.numHashEtriesAllocated;i++)this.hashEntries[o++]=-1,this.hashEntries[o++]=-1;return this.numHashEntryIndex=0,0}},{key:"getNewHashEntry",value:function(){if(this.numHashEntryIndex<this.numHashEtriesAllocated){var e=this.numHashEntryIndex;return this.numHashEntryIndex++,e}return-1}},{key:"addVertexToGeo",value:function(e,t){var r,n=.01,o=this.marCubeResoultion<<2,a=new i.Pa4,s=Math.floor(o*(t.x-this.vBoxMin.x)/(this.vBoxMax.x+n-this.vBoxMin.x)),l=Math.floor(o*(t.y-this.vBoxMin.y)/(this.vBoxMax.y+n-this.vBoxMin.y)),c=815851*s+37633*Math.floor(o*(t.z-this.vBoxMin.z)/(this.vBoxMax.z+n-this.vBoxMin.z))+2453543*l,u=(c&=32767)+c;if(null!==this.vBoxMin&&null!==this.vBoxMax)for(r=this.hashLines[u+1];r>=0;r=this.hashEntries[2*r+1]){var h=this.hashEntries[2*r+0];if(a.copy(e._vertices[h]),a.x-=t.x,a.y-=t.y,a.z-=t.z,a.x*a.x+a.y*a.y+a.z*a.z<1e-6)return h}if(e._numVertices>=this.maxNumVertices)return-1;var f=e._numVertices;if(e._vertices[f].copy(t),null!==this.vBoxMin&&null!==this.vBoxMax){if((r=this.getNewHashEntry())<0)return-1;var d=this.hashLines[u+1];this.hashLines[u+1]=r,this.hashEntries[2*r+0]=f,this.hashEntries[2*r+1]=d,this.hashLines[u+0]++}return e._numVertices++,f}},{key:"modifyExcludedFromGeo",value:function(e,t,r,n,i,o){for(var a,s,l=e*e,c=(e-1)/(n.x-r.x),u=(e-1)/(n.y-r.y),h=(e-1)/(n.z-r.z),f=2*t*(2*t),d=1/(e-1),p=0;p<i._numVertices;p++){var m=i._vertices[p],v=1.1*t,y=Math.floor((m.x-v-r.x)*c),_=Math.floor((m.y-v-r.y)*u),g=Math.floor((m.z-v-r.z)*h),x=Math.floor((m.x+v-r.x)*c),b=Math.floor((m.y+v-r.y)*u),w=Math.floor((m.z+v-r.z)*h);y=y>=0?y:0,g=g>=0?g:0,x=x<=e-1?x:e-1,b=b<=e-1?b:e-1,w=w<=e-1?w:e-1;for(var S=_=_>=0?_:0;S<=b;S++)for(var R=S*l,C=g;C<=w;C++)for(var A=C*e,E=y;E<=x;E++){a=R+A+E;var k=E*d,P=r.x*(1-k)+n.x*k;k=S*d;var T=r.y*(1-k)+n.y*k;k=C*d;var M=r.z*(1-k)+n.z*k,N=P-m.x,I=T-m.y,O=M-m.z,L=N*N+I*I+O*O;L<f&&((s=-(Math.sqrt(L)-t))>0?(o[a]<0&&(o[a]=s),s>o[a]&&(o[a]=s)):s>o[a]&&(o[a]=s))}}return 0}},{key:"_innerBuild",value:function(){var e,t=1.2,r={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};this.complex=this._opts.parent,this.atoms=r.atoms,this.meshResolution=this._opts.gridSpacing,this.atomRadiusScale=this._opts.radScale,this.colorMode=this._opts.colorMode,this.probeRadius=this._opts.probeRadius,this.useVertexColors=!0,this.excludeProbe=this._opts.excludeProbe,this.visibilitySelector=this._opts.visibilitySelector,this.geoOut=null,this.hashLines=null,this.hashEntries=null,this.numHashEtriesAllocated=0,this.numHashEntryIndex=0,this.maxNumVertices=0,this.maxNumTriangles=0;var n=new Array(this.atoms.length);this.convertToAtomsColored(r,n);var o=this.vBoxMin=new i.Pa4,a=this.vBoxMax=new i.Pa4;this.getBoundingBox(n,o,a);var s=this.marCubeResoultion=4*this.meshResolution,l=s,c=l*l*l,u=$.allocateTyped(Float32Array,c),h=this.probeRadius*this.atomRadiusScale;this.calculateGridCorners(u,l,o,a,n,h);var f=s-1,d=new Pn;if((e=d.create(f))<0)return e;var p=new i.Pa4;p.x=(a.x-o.x)/f,p.y=(a.y-o.y)/f,p.z=(a.z-o.z)/f;var m=this.getNumIntersectedCells(l,f,u,d),v=Math.floor(m*t),y=Math.floor(m*t*2);if(this.geoOut=new Hn(v,y,this.useVertexColors),(e=this.createVertexHash(v,y))<0)return e;var _=h;if(this.excludeProbe&&(_=.01),this.voxelWorld=new jn(n.length,n,o,a,_),this.voxelWorld.createVoxels(),e=this.buildGeoFromCorners(s,o,a,u,p,d),this.excludeProbe){if(this.modifyExcludedFromGeo(l,h,o,a,this.geoOut,u),this.geoOut._vertices=null,this.geoOut._colors=null,this.geoOut._indices=null,this.geoOut._normals=null,this.geoOut._numVertices=0,this.geoOut._numTriangles=0,this.geoOut=null,m=this.getNumIntersectedCells(l,f,u,d),v=Math.floor(m*t),y=Math.floor(m*t*2),this.geoOut=new Hn(v,y,this.useVertexColors),(e=this.createVertexHash(v,y))<0)return e;e=this.buildGeoFromCorners(l,o,a,u,p,d)}this.voxelWorld.buildNormals(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._normals);var g=6.5;return this.excludeProbe&&(g-=1.5),this.useVertexColors&&this.voxelWorld.buildColors(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._colors,g),this.voxelWorld.destroyVoxels(),this.voxelWorld=null,d.destroy(),e}}]),o}(kn);var Xn=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;a(this,o),(r=n.call(this))._opts=t,r.items=[],r.needsUpdate=!1;var s=-50,l=-50;switch(t.horizontalAlign){case"left":s=0;break;case"right":s=-100}switch(t.verticalAlign){case"top":l=-100;break;case"bottom":l=0}var c=new i.Pa4(t.dx||0,t.dy||0,t.dz||0);return r.userData={translation:"translate(".concat(s,"%, ").concat(l,"%)"),offset:c},r}return l(o,[{key:"setItem",value:function(e,t,r){var n=this._opts,o=this.items[e]||function(e,t){var r=document.createElement("div");if(r.className="label","string"==typeof e){var n=document.createElement("span");n.style.fontSize="150%";for(var o=e.split("\n"),a=0,s=o.length;a<s;++a){var l=document.createElement("span"),c=document.createTextNode(o[a]);l.appendChild(c),n.appendChild(l),a<s-1&&n.appendChild(document.createElement("br"))}r.appendChild(n)}else r.appendChild(e);return r.worldPos=new i.Pa4,r}(r);o.worldPos.copy(t),o.style.textAlign=n.horizontalAlign,o.style.verticalAlign=n.verticalAlign,this.items[e]=o}},{key:"setColor",value:function(e,t,r){this.items[e].opts={color:t,background:r}}},{key:"startUpdate",value:function(){return!0}},{key:"finishUpdate",value:function(){this.needsUpdate=!0,this.dispatchEvent({type:"update"})}},{key:"finalize",value:function(){this.finishUpdate()}},{key:"raycast",value:function(){}},{key:"setOpacity",value:function(){}},{key:"getSubset",value:function(){return[]}}]),o}(N),qn={InstancedSpheresGeometry:zr,SimpleSpheresGeometry:Ur,Simple2CCylindersGeometry:Wr,Instanced2CCylindersGeometry:Jr,ExtrudedObjectsGeometry:sn,ChunkedLinesGeometry:gn,TwoColorLinesGeometry:bn,CrossGeometry:An,QuickSurfGeometry:Dn,ContactSurfaceGeometry:Un,SSIsosurfaceGeometry:Yn,LabelsGeometry:Xn},$n={precision:"mediump",init:function(e){this.precision=e.capabilities.getMaxPrecision("highp")}},Zn=new Uint8Array([24,52,0,254,145,0,122,0,0,7,170,0,34,214,0,173,8,0,86,249,0,160,4,0,226,46,0,224,211,0,3,157,0,174,247,0,12,182,0,220,216,0,1,109,0,253,154,0]),Kn=i.rpg,Qn=i.rpg,Jn=i.TyD,ei=i.TyD,ti=i.xfE,ri=new i.IEO(Zn,4,4,i.UCm,i.ywz,ti,Kn,Qn,ei,Jn,1);ri.needsUpdate=!0;var ni={noiseWidth:4,noiseHeight:4,noiseTexture:ri};function ii(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function oi(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ii(Object(r),!0).forEach((function(t){Re(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ii(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ai=[new i.FM8(-.541978,.840393),new i.FM8(.125533,-.992089),new i.FM8(.374329,.927296),new i.FM8(-.105475,.994422)],si=i.rDY.merge([i.rBU.fog,i.rBU.lights,{diffuse:{value:new i.Ilk(15658734)},opacity:{value:1},specular:{type:"c",value:new i.Ilk(1118481)},shininess:{type:"f",value:30},fixedColor:{type:"c",value:new i.Ilk(16777215)},zOffset:{type:"f",value:0},zClipValue:{type:"f",value:0},clipPlaneValue:{type:"f",value:0},nearPlaneValue:{type:"f",value:-.5},invModelViewMatrix:{type:"4fv",value:new i.yGw},world2colorMatrix:{type:"4fv",value:new i.yGw},dashedLineSize:{type:"f",value:.1},dashedLinePeriod:{type:"f",value:.2},projMatrixInv:{type:"4fv",value:new i.yGw},viewport:{type:"v2",value:new i.FM8},lineWidth:{type:"f",value:2},fogAlpha:{type:"f",value:1},samplesKernel:{type:"v2v",value:null},noiseTex:{type:"t",value:null},noiseTexelSize:{type:"v2",value:null},srcTexelSize:{type:"v2",value:null}}]),li=["shininess","opacity","zOffset","diffuse","specular","fixedColor","zClipCoef","zClipValue","clipPlaneValue","world2colorMatrix","dashedLineSize","dashedLinePeriod","projMatrixInv","viewport","lineWidth","fogAlpha","samplesKernel","noiseTex","noiseTexelSize","srcTexelSize"],ci={diffuse:new i.Ilk(16777215),specular:new i.Ilk(1118481),shininess:30,opacity:1,fixedColor:new i.Ilk(16777215),zOffset:0,zClipCoef:2,zClipValue:0,clipPlaneValue:0,world2colorMatrix:new i.yGw,dashedLineSize:.1,dashedLinePeriod:.3,projMatrixInv:new i.yGw,viewport:new i.FM8(800,600),lineWidth:2,fogAlpha:1,samplesKernel:ai,noiseTex:ni.noiseTexture,noiseTexelSize:new i.FM8(1/ni.noiseWidth,1/ni.noiseHeight),srcTexelSize:new i.FM8(1/800,1/600),copy:function(e){this.diffuse.copy(e.diffuse),this.specular.copy(e.specular),this.shininess=e.shininess,this.opacity=e.opacity,this.fixedColor.copy(e.fixedColor),this.zOffset=e.zOffset,this.zClipCoef=e.zClipCoef,this.zClipValue=e.zClipValue,this.clipPlaneValue=e.clipPlaneValue,this.world2colorMatrix.copy(e.world2colorMatrix),this.dashedLineSize=e.dashedLineSize,this.dashedLinePeriod=e.dashedLinePeriod,this.projMatrixInv=e.projMatrixInv,this.viewport=e.viewport,this.lineWidth=e.lineWidth,this.toonShading=e.toonShading,this.fogAlpha=e.fogAlpha,this.samplesKernel=e.samplesKernel,this.noiseTex=e.noiseTex,this.noiseTexelSize=e.noiseTexelSize,this.srcTexelSize=e.srcTexelSize}},ui=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;return a(this,o),(t=n.call(this,e)).fog=!0,t.instancedPos=!1,t.instancedMatrix=!1,t.attrColor=!1,t.attrColor2=!1,t.attrAlphaColor=!1,t.overrideColor=!1,t.sphereSprite=!1,t.cylinderSprite=!1,t.zClip=!1,t.clipPlane=!1,t.fakeOpacity=!1,t.prepassTransparancy=!1,t.colorFromPos=!1,t.shadowmap=!1,t.shadowmapType="random",t.colorFromDepth=!1,t.orthoCam=!1,t.dashedLine=!1,t.transparent=!0,t.thickLine=!1,t.fogTransparent=!1,t.normalsToGBuffer=!1,t.toonShading=!1,t.uberOptions=ci,t.setValues(oi({uniforms:i.rDY.clone(si),vertexShader:t.precisionString()+"float INSTANCED_SPRITE_OVERSCALE = 1.3;\r\n\r\nattribute vec3 normal;\r\n\r\n#ifdef NORMALS_TO_G_BUFFER\r\n varying vec3 viewNormal;\r\n#endif\r\n#if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n varying vec3 vNormal;\r\n#endif\r\n\r\n#ifdef THICK_LINE\r\n attribute vec4 position; // W contains vert pos or neg offset\r\n#else\r\n attribute vec3 position;\r\n#endif\r\n\r\nvarying vec3 vWorldPosition;\r\nvarying vec3 vViewPosition;\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n attribute float alphaColor;\r\n varying float alphaCol;\r\n#endif\r\n\r\n#if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n\t#if NUM_DIR_LIGHTS > 0\r\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\r\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\r\n\t\tvarying vec3 vDirectionalShadowNormal[ NUM_DIR_LIGHTS ];\r\n\t#endif\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n attribute vec3 color;\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n attribute vec3 color2;\r\n varying vec3 vColor2;\r\n attribute vec2 uv;\r\n #ifndef CYLINDER_SPRITE\r\n varying vec2 vUv;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_POS\r\n attribute vec4 offset;\r\n #ifdef SPHERE_SPRITE\r\n varying vec4 instOffset;\r\n varying vec4 spritePosEye;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n attribute vec4 matVector1;\r\n attribute vec4 matVector2;\r\n attribute vec4 matVector3;\r\n attribute vec4 invmatVector1;\r\n attribute vec4 invmatVector2;\r\n attribute vec4 invmatVector3;\r\n\r\n #ifdef CYLINDER_SPRITE\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n varying vec4 spritePosEye;\r\n #endif\r\n#endif\r\n\r\nuniform mat4 modelViewMatrix; // optional\r\nuniform mat4 projectionMatrix; // optional\r\nuniform mat3 normalMatrix; // optional\r\nuniform mat4 modelMatrix; // optional\r\n\r\n#ifdef DASHED_LINE\r\n attribute float lineDistance;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n#ifdef THICK_LINE\r\n attribute vec3 direction;\r\n uniform mat4 projMatrixInv;\r\n uniform vec2 viewport;\r\n uniform float lineWidth;\r\n\r\n vec4 transform(vec4 coord){\r\n return projectionMatrix * modelViewMatrix * coord;\r\n }\r\n\r\n vec2 project(vec4 device){\r\n vec3 device_normal = device.xyz/device.w;\r\n vec2 clip_pos = (device_normal*0.5+0.5).xy;\r\n return clip_pos * viewport;\r\n }\r\n\r\n vec4 unproject(vec2 screen, float z, float w){\r\n vec2 clip_pos = screen/viewport;\r\n vec2 device_normal = clip_pos*2.0-1.0;\r\n return vec4(device_normal*w, z, w);\r\n }\r\n#endif\r\n\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n alphaCol = alphaColor;\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n vec3 objectNormal = vec3(\r\n dot(normal, matVector1.xyz),\r\n dot(normal, matVector2.xyz),\r\n dot(normal, matVector3.xyz));\r\n#else\r\n vec3 objectNormal = vec3( normal );\r\n#endif\r\n\r\nvec3 transformedNormal = normalMatrix * objectNormal;\r\n\r\n#if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n vNormal = normalize(transformedNormal);\r\n#endif\r\n\r\n#ifdef NORMALS_TO_G_BUFFER\r\n viewNormal = normalize(mat3(modelViewMatrix)*objectNormal);\r\n#endif\r\n\r\n vec4 localPos = vec4(position.xyz, 1.0);\r\n vec4 worldPos = modelMatrix * localPos;\r\n vec4 mvPosition = modelViewMatrix * localPos;\r\n\r\n// make thick line offset\r\n#ifdef THICK_LINE\r\n // get screen pos\r\n vec4 dPos = transform(vec4(position.xyz, 1.0));\r\n vec2 sPos = project(dPos);\r\n // move pos forward\r\n vec3 position2 = position.xyz + direction.xyz * 0.5;\r\n // get screen offset pos\r\n vec4 dPos2 = transform(vec4(position2.xyz, 1.0));\r\n vec2 sPos2 = project(dPos2);\r\n // screen line direction\r\n vec2 sDir = normalize(sPos2 - sPos);\r\n // vertex offset (orthogonal to line direction)\r\n vec2 offset1 = vec2(-sDir.y, sDir.x);\r\n // move screen vertex\r\n vec2 newPos = sPos + offset1 * position.w * lineWidth;\r\n // get moved pos in view space\r\n vec4 dNewPos = unproject(newPos, dPos.z, dPos.w);\r\n mvPosition.xyz = (projMatrixInv * dNewPos).xyz;\r\n#endif // THICK_LINE\r\n\r\n#ifdef INSTANCED_POS\r\n #ifdef SPHERE_SPRITE\r\n instOffset = offset;\r\n\r\n vec4 posEye = modelViewMatrix * vec4( offset.xyz, 1.0 );\r\n float scale = length(modelViewMatrix[0]);\r\n mvPosition = posEye + vec4( position.xyz * offset.w * scale * INSTANCED_SPRITE_OVERSCALE, 0.0 );\r\n posEye.w = offset.w * scale;\r\n\r\n spritePosEye = posEye;\r\n #else\r\n localPos = vec4( offset.xyz + position.xyz * offset.w, 1.0 );\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n #ifdef CYLINDER_SPRITE\r\n matVec1 = matVector1;\r\n matVec2 = matVector2;\r\n matVec3 = matVector3;\r\n invmatVec1 = invmatVector1;\r\n invmatVec2 = invmatVector2;\r\n invmatVec3 = invmatVector3;\r\n\r\n // calculate eye coords of cylinder endpoints\r\n vec4 v = vec4(0, -0.5, 0, 1);\r\n vec4 p1 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n v.y = 0.5;\r\n vec4 p2 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n\r\n // sprite is placed at the center of cylinder\r\n vec4 posEye;\r\n posEye.xyz = mix(p1.xyz, p2.xyz, 0.5);\r\n posEye.w = 1.0;\r\n spritePosEye = posEye;\r\n\r\n // cylinder radius in eye space\r\n float rad = length(modelViewMatrix[0]) * length(vec3(matVector1.x, matVector2.x, matVector3.x));\r\n vec2 spriteSize;\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // In ortho projection we skip z coordinate\r\n // basic sprite size at screen plane (covers only cylinder axis)\r\n vec2 spriteSizeScreen = abs(p2.xy - p1.xy);\r\n\r\n spriteSize = vec2(1.0, 1.0) * INSTANCED_SPRITE_OVERSCALE * (spriteSizeScreen + 2.0 * rad);\r\n #else\r\n // basic sprite size at screen plane (covers only cylinder axis)\r\n vec2 spriteSizeScreen = abs(p2.xy / p2.z - p1.xy / p1.z);\r\n\r\n // full sprite size in eye coords\r\n float minZ = min(abs(p1.z), abs(p2.z));\r\n spriteSize = vec2(1.0, 1.0) * INSTANCED_SPRITE_OVERSCALE * abs(posEye.z) * (spriteSizeScreen + 2.0 * rad / minZ);\r\n #endif\r\n\r\n mvPosition = posEye + vec4( position.xy * 0.5 * spriteSize, 0, 0 );\r\n #else\r\n localPos = vec4(dot(localPos, matVector1), dot(localPos, matVector2), dot(localPos, matVector3), 1.0);\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n gl_Position = projectionMatrix * mvPosition;\r\n\r\n vWorldPosition = worldPos.xyz;\r\n vViewPosition = - mvPosition.xyz;\r\n\r\n#if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n\t#if NUM_DIR_LIGHTS > 0\r\n\t vec4 worldPosition;\r\n\t // see THREE.WebGLProgram.unrollLoops\r\n\t #pragma unroll_loop_start\r\n\t for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * vec4(vWorldPosition, 1.0);\r\n vDirectionalShadowNormal[ i ] = (directionalShadowMatrix[ i ] * (modelMatrix * vec4(objectNormal, 0.0))).xyz;\r\n\t }\r\n\t #pragma unroll_loop_end\r\n\t#endif\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n vColor = color.xyz;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n vColor2 = color2;\r\n #ifndef CYLINDER_SPRITE\r\n vUv = uv;\r\n #endif\r\n#endif\r\n\r\n#ifdef DASHED_LINE\r\n vLineDistance = lineDistance;\r\n#endif\r\n}\r\n",fragmentShader:t.precisionString()+"#if defined (NORMALS_TO_G_BUFFER)\r\n #define fragColor gl_FragData[0]\r\n#else\r\n #define fragColor gl_FragColor\r\n#endif\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n varying float alphaCol;\r\n#endif\r\n\r\n#ifdef COLOR_FROM_POS\r\n uniform mat4 world2colorMatrix;\r\n#endif\r\n\r\n#if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n\t#if NUM_DIR_LIGHTS > 0\r\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\r\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ]; //only for sprites\r\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\r\n\t\tvarying vec3 vDirectionalShadowNormal[ NUM_DIR_LIGHTS ];\r\n vec4 vDirLightWorldCoord[ NUM_DIR_LIGHTS ];\r\n vec3 vDirLightWorldNormal[ NUM_DIR_LIGHTS ];\r\n\r\n #ifdef SHADOWMAP_PCF_RAND\r\n // We use 4 instead uniform variable or define because this value is used in for(... i < value; ...) with\r\n // unroll_loop and unroll_loop has pattern:\r\n // /#pragma unroll_loop[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}/g\r\n uniform vec2 samplesKernel[4]; // 4 is length of _samplesKernel which is defined in UberMaterial.js\r\n uniform sampler2D noiseTex;\r\n uniform vec2 noiseTexelSize;\r\n uniform vec2 srcTexelSize;\r\n uniform mat4 projectionMatrix;\r\n #endif\r\n\t#endif\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n varying vec3 vColor2;\r\n #ifndef CYLINDER_SPRITE\r\n varying vec2 vUv;\r\n #endif\r\n#endif\r\n\r\nuniform vec3 diffuse;\r\nuniform vec3 emissive;\r\nuniform vec3 specular;\r\nuniform float shininess;\r\nuniform vec3 fixedColor;\r\nuniform float opacity;\r\nuniform float zClipValue;\r\nuniform float clipPlaneValue;\r\n\r\n#ifdef NORMALS_TO_G_BUFFER\r\n varying vec3 viewNormal;\r\n#endif\r\n\r\n#define PI 3.14159265359\r\n#define RECIPROCAL_PI 0.31830988618\r\n#define saturate(a) clamp( a, 0.0, 1.0 )\r\n\r\n#ifdef USE_FOG\r\n uniform vec3 fogColor;\r\n uniform float fogAlpha;\r\n uniform float fogNear;\r\n uniform float fogFar;\r\n#endif\r\n\r\nvarying vec3 vWorldPosition; // world position of the pixel (invalid when INSTANCED_SPRITE is defined)\r\nvarying vec3 vViewPosition;\r\n\r\n#if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n varying vec3 vNormal;\r\n#endif\r\n\r\n/////////////////////////////////////////// ZSprites ////////////////////////////////////////////////\r\n#if defined (SPHERE_SPRITE) || defined (CYLINDER_SPRITE)\r\n uniform float nearPlaneValue;\r\n#endif\r\n\r\n#ifdef SPHERE_SPRITE\r\n varying vec4 spritePosEye;\r\n#endif\r\n\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n uniform float zOffset;\r\n\r\n #if !defined(USE_LIGHTS) || !defined(SHADOWMAP) || !defined(SHADOWMAP_PCF_RAND) || !(NUM_DIR_LIGHTS > 0)\r\n uniform mat4 projectionMatrix;\r\n #endif\r\n\r\n float calcDepthForSprites(vec4 pixelPosEye, float zOffset, mat4 projMatrix) {\r\n vec4 pixelPosScreen = projMatrix * pixelPosEye;\r\n return 0.5 * (pixelPosScreen.z / pixelPosScreen.w + 1.0) + zOffset;\r\n }\r\n#endif\r\n\r\n#ifdef SPHERE_SPRITE\r\n varying vec4 instOffset;\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n\r\n\r\n bool intersect_ray_sphere(in vec3 origin, in vec3 ray, out vec3 point, out float frontFaced) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray, ray);\r\n float b = dot(ray, origin);\r\n float c = dot(origin, origin) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return false;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n // choose nearest point inside frustum\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // orthografic camera is used for dirLight sources. So in it for all spheres the point with smaller 't' is visible\r\n // t1 is always smaller than t2 (from calculations)\r\n point = p1;\r\n frontFaced = 1.0;\r\n return true;\r\n #else\r\n // for perspective camera first intersection can be in front of near plane. If not intersection is p1 else - p2\r\n // t* = 0.0 corresponds to point of intersection near plane by the ray from camera to curPixel\r\n if (t1 >= 0.0) {\r\n point = p1;\r\n frontFaced = 1.0;\r\n return true;\r\n }\r\n if (t2 >= 0.0) {\r\n point = p2;\r\n frontFaced = -1.0;\r\n return true;\r\n }\r\n #endif\r\n\r\n return false;\r\n }\r\n\r\n bool get_sphere_point(in vec3 pixelPosEye, out vec3 point, out float frontFaced) {\r\n vec3 origin, ray;\r\n\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // transform vector from sprite center to curPixel into sphere local coords\r\n origin = pixelPosEye.xyz - spritePosEye.xyz;\r\n origin = (invModelViewMatrix * vec4(origin, 0.0)).xyz / instOffset.w;\r\n\r\n // transform camera orientation vector into sphere local coords\r\n ray = (invModelViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\r\n #else\r\n // find point of intersection near plane by the ray from camera to curPixel\r\n vec4 v = vec4(-(nearPlaneValue / pixelPosEye.z) * pixelPosEye, 1.0);\r\n\r\n // transform intersection point into sphere local coords\r\n v = invModelViewMatrix * v;\r\n origin = (v.xyz - instOffset.xyz) / instOffset.w;\r\n\r\n // transform vector from camera pos to curPixel into sphere local coords\r\n ray = (invModelViewMatrix * vec4(pixelPosEye, 0.0)).xyz;\r\n #endif\r\n ray = normalize(ray);\r\n\r\n return intersect_ray_sphere(origin, ray, point, frontFaced);\r\n }\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n\r\n varying vec4 spritePosEye;\r\n\r\n bool intersect_ray_cylinder(in vec3 origin, in vec3 ray, out vec3 point, out float frontFaced) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray.xz, ray.xz);\r\n float b = dot(ray.xz, origin.xz);\r\n float c = dot(origin.xz, origin.xz) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return false;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n float halfHeight = 0.5;\r\n\r\n // choose nearest point\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // orthografic camera is used for dirLight sources. So in it for all cylinders the point with smaller 't' is visible\r\n // if it is not outside of cylinnder (t1 is always smaller than t2).\r\n if (p1.y >= -halfHeight && p1.y <= halfHeight) {\r\n point = p1;\r\n frontFaced = 1.0;\r\n return true;\r\n }\r\n if (p2.y >= -halfHeight && p2.y <= halfHeight) {\r\n point = p2;\r\n frontFaced = -1.0;\r\n return true;\r\n }\r\n #else\r\n // for perspective camera first intersection can be in front of near plane. If not intersection is p1 else - p2\r\n // t* = 0.0 corresponds to point of intersection near plane by the ray from camera to curPixel\r\n if (t1 >= 0.0 && p1.y >= -halfHeight && p1.y <= halfHeight) {\r\n point = p1;\r\n frontFaced = 1.0;\r\n return true;\r\n }\r\n if (t2 >= 0.0 && p2.y >= -halfHeight && p2.y <= halfHeight) {\r\n point = p2;\r\n frontFaced = -1.0;\r\n return true;\r\n }\r\n #endif\r\n\r\n return false;\r\n }\r\n\r\n bool get_cylinder_point(in vec3 pixelPosEye, out vec3 point, out float frontFaced) {\r\n vec3 origin, ray;\r\n vec4 v;\r\n\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // transform vector from sprite center to curPixel into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye.xyz - spritePosEye.xyz, 0.0);\r\n origin = vec3(dot(v, invmatVec1), dot(v, invmatVec2), dot(v, invmatVec3));\r\n\r\n // transform camera orientation vector into cylinder local coords\r\n v = invModelViewMatrix * vec4(0.0, 0.0, -1.0, 0.0);\r\n ray = vec3(dot(v, invmatVec1), dot(v, invmatVec2), dot(v, invmatVec3));\r\n #else\r\n // find point of intersection near plane by the ray from camera to curPixel\r\n v = vec4(-(nearPlaneValue / pixelPosEye.z) * pixelPosEye, 1.0);\r\n\r\n // transform intersection point into cylinder local coords\r\n v = invModelViewMatrix * v;\r\n origin = vec3(dot(v, invmatVec1), dot(v, invmatVec2), dot(v, invmatVec3));\r\n\r\n // transform vector from camera pos to curPixel into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye, 0.0);\r\n ray = vec3(dot(v, invmatVec1), dot(v, invmatVec2), dot(v, invmatVec3));\r\n #endif\r\n ray = normalize(ray);\r\n\r\n return intersect_ray_cylinder(origin, ray, point, frontFaced);\r\n }\r\n#endif\r\n\r\n///////////////////////////////////// Pack and unpack ///////////////////////////////////////////////\r\nconst float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\r\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\r\n\r\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\r\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\r\n\r\n\r\nconst float ShiftRight8 = 1. / 256.;\r\n\r\nvec4 packDepthToRGBA( const in float v ) {\r\n vec4 r = vec4( fract( v * PackFactors ), v );\r\n r.yzw -= r.xyz * ShiftRight8; // tidy overflow\r\n return r * PackUpscale;\r\n}\r\n\r\nfloat unpackRGBAToDepth( const in vec4 v ) {\r\n return dot( v, UnpackFactors );\r\n}\r\n\r\n////////////////////////////////////////// All Lighting /////////////////////////////////////////////////\r\n#ifdef TOON_SHADING\r\n #define LOW_TOON_BORDER 0.0\r\n #define MEDIUM_TOON_BORDER 0.7\r\n #define HIGH_TOON_BORDER 1.0\r\n\r\n #define MEDIUM_TOON_RANGE 0.5\r\n #define HIGH_TOON_RANGE 0.95\r\n#endif\r\n#if defined(USE_LIGHTS) && NUM_DIR_LIGHTS > 0\r\n struct ReflectedLight {\r\n vec3 directDiffuse;\r\n vec3 directSpecular;\r\n vec3 indirectDiffuse;\r\n };\r\n\r\n struct BlinnPhongMaterial {\r\n vec3 diffuseColor;\r\n vec3 specularColor;\r\n float specularShininess;\r\n };\r\n\r\n struct GeometricContext {\r\n vec3 normal;\r\n vec3 viewDir;\r\n };\r\n\r\n struct DirectionalLight {\r\n vec3 direction;\r\n vec3 color;\r\n };\r\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\r\n\r\n struct DirectionalLightShadow {\r\n vec2 shadowMapSize;\r\n float shadowBias;\r\n float shadowRadius;\r\n };\r\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHTS ];\r\n\r\n uniform vec3 ambientLightColor;\r\n\r\n /////////////////////////////////////////// Shadowmap ////////////////////////////////////////////////\r\n\r\n #if defined(SHADOWMAP)\r\n \tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\r\n \t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\r\n \t}\r\n\r\n float getShadow( sampler2D shadowMap, DirectionalLightShadow dirLight, vec4 shadowCoord, vec3 vViewPosition, vec3 vNormal ) {\r\n \t float shadow = 0.0;\r\n\r\n // When shadows for sprites will appear use here for them normals as it done for G-buffer\r\n shadowCoord.xyz += dirLight.shadowBias * vNormal;\r\n shadowCoord.xyz /= shadowCoord.w;\r\n\r\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\r\n bool inFrustum = all( inFrustumVec );\r\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\r\n bool frustumTest = all( frustumTestVec );\r\n\r\n if ( frustumTest ) {\r\n #ifdef SHADOWMAP_BASIC\r\n \t shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\r\n \t#endif\r\n\r\n \t#ifdef SHADOWMAP_PCF_SHARP\r\n \t vec2 texelSize = vec2( 1.0 ) / dirLight.shadowMapSize;\r\n\r\n float dx0 = - texelSize.x * dirLight.shadowRadius;\r\n float dy0 = - texelSize.y * dirLight.shadowRadius;\r\n float dx1 = + texelSize.x * dirLight.shadowRadius;\r\n float dy1 = + texelSize.y * dirLight.shadowRadius;\r\n\r\n shadow = (\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\r\n ) * ( 1.0 / 9.0 );\r\n #endif\r\n\r\n #ifdef SHADOWMAP_PCF_RAND\r\n vec2 texelSize = vec2( 1.0 ) / dirLight.shadowMapSize;\r\n\r\n vec4 vUv = ((projectionMatrix * vec4(vViewPosition, 1.0)) + 1.0) / 2.0;\r\n vec2 vUvNoise = vUv.xy / srcTexelSize * noiseTexelSize;\r\n\r\n vec2 noiseVec = normalize(texture2D(noiseTex, vUvNoise).rg);\r\n mat2 mNoise = mat2(noiseVec.x, noiseVec.y, -noiseVec.y, noiseVec.x);\r\n\r\n vec2 offset;\r\n #pragma unroll_loop_start\r\n for ( int i = 0; i < 4; i ++ ) { // 4 is length of _samplesKernel which is defined in UberMaterial.js\r\n offset = mNoise * ( normalize( samplesKernel[ i ]) * texelSize * dirLight.shadowRadius );\r\n shadow += texture2DCompare( shadowMap, shadowCoord.xy + offset, shadowCoord.z );\r\n }\r\n #pragma unroll_loop_end\r\n shadow /= float( 4 ); // 4 is length of _samplesKernel which is defined in UberMaterial.js\r\n #endif\r\n }\r\n return shadow;//(shadow != 1.0) ? 0.5 : 1.0;//vec4(shadow, shadow, shadow, 1.0);\r\n }\r\n #endif\r\n\r\n /////////////////////////////////////////// Lighting /////////////////////////////////////////////////\r\n\r\n vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\r\n return RECIPROCAL_PI * diffuseColor;\r\n } // validated\r\n\r\n vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\r\n // Original approximation by Christophe Schlick '94\r\n //;float fresnel = pow( 1.0 - dotLH, 5.0 );\r\n // Optimized variant (presented by Epic at SIGGRAPH '13)\r\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\r\n return ( 1.0 - specularColor ) * fresnel + specularColor;\r\n } // validated\r\n\r\n float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\r\n // geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\r\n return 0.25;\r\n }\r\n\r\n float D_BlinnPhong( const in float shininess, const in float dotNH ) {\r\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\r\n }\r\n\r\n vec3 BRDF_Specular_BlinnPhong( const in DirectionalLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\r\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\r\n float dotNH = saturate(dot( geometry.normal, halfDir ));\r\n float dotLH = saturate(dot( incidentLight.direction, halfDir ));\r\n\r\n vec3 F = F_Schlick( specularColor, dotLH );\r\n float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\r\n float D = D_BlinnPhong( shininess, dotNH );\r\n\r\n return F * ( G * D );\r\n } // validated\r\n\r\n void RE_Direct_BlinnPhong( const in DirectionalLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight, float penumbra ) {\r\n\r\n float dotNL = saturate( dot( geometry.normal, directLight.direction ));\r\n #ifdef TOON_SHADING\r\n if(dotNL < MEDIUM_TOON_RANGE){\r\n dotNL = LOW_TOON_BORDER;\r\n }\r\n else if(dotNL < HIGH_TOON_RANGE){\r\n dotNL = MEDIUM_TOON_BORDER;\r\n }\r\n else{\r\n dotNL = HIGH_TOON_BORDER;\r\n }\r\n #endif\r\n\r\n vec3 irradiance = dotNL * directLight.color * PI;\r\n reflectedLight.directDiffuse += penumbra * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n reflectedLight.directSpecular += penumbra * irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess );\r\n }\r\n\r\n void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n }\r\n\r\n vec3 calcLighting(const in GeometricContext geometry, const in BlinnPhongMaterial material, vec3 vViewPosition) {\r\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ));\r\n vec3 irradiance = ambientLightColor * PI;\r\n\r\n float shadowMask = 1.0;\r\n // see THREE.WebGLProgram.unrollLoops\r\n \t#pragma unroll_loop_start\r\n \t for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n \t #ifdef SHADOWMAP\r\n \t shadowMask = getShadow( directionalShadowMap[ i ], directionalLightShadows[ i ], vDirLightWorldCoord[ i ], vViewPosition, vDirLightWorldNormal[ i ] );\r\n #endif\r\n\r\n \t\t if ( shadowMask > 0.0 ) RE_Direct_BlinnPhong( directionalLights[ i ], geometry, material, reflectedLight, shadowMask );\r\n \t\t}\r\n \t\t#pragma unroll_loop_end\r\n\r\n RE_IndirectDiffuse_BlinnPhong(irradiance, material, reflectedLight);\r\n\r\n return saturate(reflectedLight.indirectDiffuse + reflectedLight.directDiffuse + reflectedLight.directSpecular);\r\n }\r\n#endif\r\n\r\n/////////////////////////////////////////// Dashed Line ///////////////////////////////////////////////\r\n#ifdef DASHED_LINE\r\n uniform float dashedLineSize;\r\n uniform float dashedLinePeriod;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef CLIP_PLANE\r\n if (vViewPosition.z < clipPlaneValue) discard;\r\n#endif\r\n\r\n#ifdef ZCLIP\r\n if (vViewPosition.z < zClipValue) discard;\r\n#endif\r\n\r\n#if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n #if NUM_DIR_LIGHTS > 0\r\n // see THREE.WebGLProgram.unrollLoops\r\n #pragma unroll_loop_start\r\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n vDirLightWorldCoord[ i ] = vDirectionalShadowCoord[ i ];\r\n vDirLightWorldNormal[ i ] = vDirectionalShadowNormal[ i ];\r\n }\r\n #pragma unroll_loop_end\r\n #endif\r\n#endif\r\n\r\n vec4 pixelPosWorld = vec4(vWorldPosition, 1.0);\r\n vec4 pixelPosEye;\r\n\r\n#ifdef SPHERE_SPRITE\r\n\r\n vec3 viewNormalSprites;\r\n float frontFaced = 1.0;\r\n vec3 normal;\r\n\r\n/* quick-and-dirty method\r\n normal.xy = ' + INSTANCED_SPRITE_OVERSCALE + ' * (2.0 * vUv - 1.0);\r\n float r2 = dot(normal.xy, normal.xy);\r\n if (r2 > 1.0) discard;\r\n float normalZ = sqrt(1.0 - r2);\r\n normal.z = normalZ;\r\n normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\r\n pixelPosEye = vec4(spritePosEye.xyz, 1.0);\r\n pixelPosEye.z += spritePosEye.w * normalZ;\r\n*/\r\n\r\n // ray-trace sphere surface\r\n {\r\n vec3 p;\r\n if (!get_sphere_point(-vViewPosition, p, frontFaced)) discard;\r\n vec4 v = vec4(instOffset.xyz + p * instOffset.w, 1.0);\r\n pixelPosWorld = modelMatrix * v;\r\n pixelPosEye = modelViewMatrix * v;\r\n normal = normalize(normalMatrix * p);\r\n #ifdef NORMALS_TO_G_BUFFER\r\n viewNormalSprites = normalize(mat3(modelViewMatrix)*p);\r\n #endif\r\n\r\n #if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n #if NUM_DIR_LIGHTS > 0\r\n // see THREE.WebGLProgram.unrollLoops\r\n #pragma unroll_loop_start\r\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n vDirLightWorldCoord[ i ] = directionalShadowMatrix[ i ] * pixelPosWorld;\r\n vDirLightWorldNormal[ i ] = (directionalShadowMatrix[ i ] * (modelMatrix * vec4(p, 0.0))).xyz;\r\n }\r\n #pragma unroll_loop_end\r\n #endif\r\n #endif\r\n }\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n vec3 normal;\r\n vec3 viewNormalSprites;\r\n float frontFaced = 1.0;\r\n float cylinderY = 0.0;\r\n\r\n // ray-trace cylinder surface\r\n {\r\n vec3 p;\r\n if (!get_cylinder_point(-vViewPosition, p, frontFaced)) discard;\r\n\r\n cylinderY = 0.5 * (p.y + 1.0);\r\n\r\n vec4 v = vec4(p, 1.0);\r\n v = vec4(dot(v, matVec1), dot(v, matVec2), dot(v, matVec3), 1.0);\r\n pixelPosWorld = modelMatrix * v;\r\n pixelPosEye = modelViewMatrix * v;\r\n\r\n vec3 localNormal = normalize(vec3(p.x, 0.0, p.z));\r\n normal = vec3(\r\n dot(localNormal, matVec1.xyz),\r\n dot(localNormal, matVec2.xyz),\r\n dot(localNormal, matVec3.xyz));\r\n #ifdef NORMALS_TO_G_BUFFER\r\n viewNormalSprites = normalize(mat3(modelViewMatrix)*normal);\r\n #endif\r\n\r\n #if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n #if NUM_DIR_LIGHTS > 0\r\n // see THREE.WebGLProgram.unrollLoops\r\n #pragma unroll_loop_start\r\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n vDirLightWorldCoord[ i ] = directionalShadowMatrix[ i ] * pixelPosWorld;\r\n vDirLightWorldNormal[ i ] = (directionalShadowMatrix[ i ] * (modelMatrix * vec4(normal, 0.0))).xyz;\r\n }\r\n #pragma unroll_loop_end\r\n #endif\r\n #endif\r\n\r\n normal = normalize(normalMatrix * normal);\r\n }\r\n#endif\r\n\r\n #ifdef ATTR_COLOR\r\n vec3 vertexColor = vColor;\r\n #else\r\n vec3 vertexColor = vec3(1.0, 1.0, 1.0);\r\n #endif\r\n\r\n #ifdef ATTR_COLOR2\r\n #ifdef CYLINDER_SPRITE\r\n float colorCoef = cylinderY; // cylinder parameter is calculated from ray-tracing\r\n #else\r\n float colorCoef = vUv.y; // cylinder parameter is interpolated as tex coord\r\n #endif\r\n // choose either color or color2\r\n vertexColor = mix(vColor2, vColor, step(0.5, colorCoef));\r\n #endif\r\n\r\n // negative red component is a special condition\r\n if (vertexColor.x < 0.0) discard;\r\n\r\n #ifdef DASHED_LINE\r\n if ( mod( vLineDistance, dashedLinePeriod ) > dashedLineSize ) discard;\r\n #endif\r\n\r\n // transparency prepass writes only z, so we don't need to calc the color\r\n #ifdef PREPASS_TRANSP\r\n fragColor = vec4(1.0, 1.0, 1.0, 1.0);\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n #endif\r\n return;\r\n #endif\r\n\r\n float totalOpacity = opacity;\r\n\r\n #ifdef ATTR_ALPHA_COLOR\r\n totalOpacity *= alphaCol;\r\n #endif\r\n\r\n // discard fully transparent pixels\r\n if (totalOpacity == 0.0) discard;\r\n\r\n #ifdef FAKE_OPACITY\r\n // discard pixels in checker pattern\r\n vec2 dm_coord = floor(gl_FragCoord.xy);\r\n dm_coord = fract(dm_coord * 0.5);\r\n if (totalOpacity < 1.0 && (dm_coord.x < 0.5 ^^ dm_coord.y < 0.5)) discard;\r\n vec4 diffuseColor = vec4(diffuse, 1.0);\r\n #else\r\n vec4 diffuseColor = vec4(diffuse, totalOpacity);\r\n #endif\r\n\r\n float flipNormal;\r\n #if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n flipNormal = 1.0;\r\n #ifdef DOUBLE_SIDED\r\n flipNormal = float( gl_FrontFacing );\r\n #endif\r\n vec3 normal = normalize( vNormal ) * flipNormal;\r\n #endif\r\n\r\n diffuseColor.rgb *= vertexColor;\r\n\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n #endif\r\n\r\n #ifdef NORMALS_TO_G_BUFFER\r\n #if defined (SPHERE_SPRITE) || defined (CYLINDER_SPRITE)\r\n vec3 viewNormaInColor = viewNormalSprites;\r\n #else\r\n vec3 viewNormaInColor = viewNormal;\r\n float frontFaced = float( gl_FrontFacing );\r\n #endif\r\n // [-1, 1] -> [0, 1]\r\n viewNormaInColor = 0.5 * viewNormaInColor + 0.5;\r\n gl_FragData[1] = vec4(viewNormaInColor, frontFaced);\r\n #endif\r\n\r\n #if defined(USE_LIGHTS) && NUM_DIR_LIGHTS > 0\r\n vec3 viewDir;\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n viewDir = -pixelPosEye.xyz;\r\n #else\r\n viewDir = vViewPosition;\r\n #endif\r\n GeometricContext geometry = GeometricContext(normal, normalize( viewDir ));\r\n BlinnPhongMaterial material = BlinnPhongMaterial(diffuseColor.rgb, specular, shininess);\r\n vec3 outgoingLight = calcLighting(geometry, material, viewDir);\r\n #else\r\n vec3 outgoingLight = diffuseColor.rgb;\r\n #endif\r\n\r\n #ifdef COLOR_FROM_DEPTH\r\n float depth = 0.0;\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n depth = gl_FragDepthEXT;\r\n #else\r\n depth = gl_FragCoord.z;\r\n #endif\r\n fragColor = packDepthToRGBA(depth);\r\n return;\r\n #endif\r\n\r\n #ifdef COLOR_FROM_POS\r\n fragColor = world2colorMatrix * pixelPosWorld;\r\n #else\r\n #ifdef OVERRIDE_COLOR\r\n fragColor = vec4(fixedColor, diffuseColor.a);\r\n #else\r\n fragColor = vec4(outgoingLight, diffuseColor.a);//vec4(vNormal, 1.0);\r\n #endif\r\n\r\n #ifdef USE_FOG\r\n float viewDistance;\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n viewDistance = abs(pixelPosEye.z);\r\n #else\r\n viewDistance = vViewPosition.z;\r\n #endif\r\n float fogFactor = smoothstep( fogNear, fogFar, viewDistance) * fogAlpha;\r\n #ifdef FOG_TRANSPARENT\r\n fragColor.a = fragColor.a * (1.0 - fogFactor);\r\n #else\r\n fragColor.rgb = mix( fragColor.rgb, fogColor, fogFactor );\r\n #endif\r\n #endif\r\n\r\n #endif\r\n}\r\n",lights:!0,fog:!0,side:i.ehD},e)),t}return l(o,[{key:"precisionString",value:function(){var e=$n.precision;return"precision ".concat(e," float;\n")+"precision ".concat(e," int;\n\n")}},{key:"copy",value:function(e){return Xe(d(o.prototype),"copy",this).call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=i.rDY.clone(e.uniforms),this.defines=oi({},e.defines),this.extensions=e.extensions,this.fog=e.fog,this.instancedPos=e.instancedPos,this.instancedMatrix=e.instancedMatrix,this.attrColor=e.attrColor,this.attrColor2=e.attrColor2,this.attrAlphaColor=e.attrAlphaColor,this.overrideColor=e.overrideColor,this.sphereSprite=e.sphereSprite,this.cylinderSprite=e.cylinderSprite,this.zClip=e.zClip,this.clipPlane=e.clipPlane,this.fakeOpacity=e.fakeOpacity,this.colorFromPos=e.colorFromPos,this.shadowmap=e.shadowmap,this.shadowmapType=e.shadowmapType,this.colorFromDepth=e.colorFromDepth,this.orthoCam=e.orthoCam,this.prepassTransparancy=e.prepassTransparancy,this.dashedLine=e.dashedLine,this.thickLine=e.thickLine,this.fogTransparent=e.fogTransparent,this.normalsToGBuffer=e.normalsToGBuffer,this.toonShading=e.toonShading,this.uberOptions.copy(e.uberOptions),this}},{key:"createInstance",value:function(){var e=new o;return e.copy(this),e.uberOptions=Object.create(this.uberOptions),e}},{key:"setValues",value:function(e){if(void 0!==e){Xe(d(o.prototype),"setValues",this).call(this,e);var t={},r={};this.fog&&(t.USE_FOG=1),this.instancedPos&&(t.INSTANCED_POS=1),this.instancedMatrix&&(t.INSTANCED_MATRIX=1),this.attrColor&&(t.ATTR_COLOR=1),this.attrColor2&&(t.ATTR_COLOR2=1),this.attrAlphaColor&&(t.ATTR_ALPHA_COLOR=1),this.overrideColor&&(t.OVERRIDE_COLOR=1),this.sphereSprite&&(t.SPHERE_SPRITE=1,r.fragDepth=1),this.cylinderSprite&&(t.CYLINDER_SPRITE=1,r.fragDepth=1),this.zClip&&(t.ZCLIP=1),this.clipPlane&&(t.CLIP_PLANE=1),this.fakeOpacity&&(t.FAKE_OPACITY=1),this.lights&&(t.USE_LIGHTS=1),this.colorFromPos&&(t.COLOR_FROM_POS=1),this.shadowmap&&(t.SHADOWMAP=1,"pcf"===this.shadowmapType?t.SHADOWMAP_PCF_SHARP=1:"random"===this.shadowmapType?t.SHADOWMAP_PCF_RAND=1:t.SHADOWMAP_BASIC=1),this.colorFromDepth&&(t.COLOR_FROM_DEPTH=1),this.orthoCam&&(t.ORTHOGRAPHIC_CAMERA=1),this.prepassTransparancy&&(t.PREPASS_TRANSP=1),this.dashedLine&&(t.DASHED_LINE=1),this.thickLine&&(t.THICK_LINE=1),this.fogTransparent&&(t.FOG_TRANSPARENT=1),this.normalsToGBuffer&&(r.drawBuffers=1,t.NORMALS_TO_G_BUFFER=1),this.toonShading&&(t.TOON_SHADING=1),this.defines=t,this.extensions=r}}},{key:"setUberOptions",value:function(e){if(void 0!==e)for(var t in e)e.hasOwnProperty(t)&&(this.uberOptions[t]instanceof i.Ilk?this.uberOptions[t]=e[t].clone():this.uberOptions[t]=e[t])}},{key:"clone",value:function(e){return e?this.createInstance():i.F5T.prototype.clone.call(this)}},{key:"updateUniforms",value:function(){var e=this;li.forEach((function(t){e.uniforms.hasOwnProperty(t)&&(e.uberOptions[t]instanceof i.Ilk||e.uberOptions[t]instanceof i.yGw?e.uniforms[t].value=e.uberOptions[t].clone():e.uniforms[t].value=e.uberOptions[t])}))}}]),o}(i.FIo);function hi(e){var t=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;a(this,i);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return(e=n.call.apply(n,[this].concat(r))).onBeforeRender=i.prototype.onBeforeRender,e}return l(i,[{key:"onBeforeRender",value:function(e,t,r,n,i,o){this._onBeforeRender(e,t,r,n,i,o),this._update()}},{key:"_onBeforeRender",value:function(){}},{key:"_update",value:function(){var e=this.material;e&&e instanceof ui&&e.updateUniforms()}}]),i}(e);return t}var fi=hi(i.Kj0),di=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;a(this,i);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return(e=n.call.apply(n,[this].concat(r))).castShadow=!0,e.receiveShadow=!0,e}return l(i,[{key:"_onBeforeRender",value:function(e,t,r,n,i,o){fi.prototype._onBeforeRender.call(this,e,t,r);var a=this.material;a&&a.uniforms.invModelViewMatrix&&(this.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,this.matrixWorld),a.uniforms.invModelViewMatrix.value.copy(this.modelViewMatrix).invert(),a.uniforms.nearPlaneValue.value=r.near,a.uniformsNeedUpdate=!0)}}]),i}(fi);var pi=hi(i.Kj0),mi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return a(this,i),(r=n.call(this,e,t)).castShadow=!0,r.receiveShadow=!0,r}return l(i,[{key:"_onBeforeRender",value:function(e,t,r){pi.prototype._onBeforeRender.call(this,e,t,r);var n=this.geometry,o=this.material;if(n.zClip&&o.uberOptions){var a=i._modelView,s=i._mvLength,l=i._center;a.multiplyMatrices(this.matrixWorld,r.matrixWorldInverse);var c=s.setFromMatrixColumn(a,0).length();l.copy(n.boundingSphere.center),this.localToWorld(l),o.uberOptions.zClipValue=r.position.z-l.z-c*(.5*n.boundingSphere.radius)}}}]),i}(pi);Re(mi,"_mvLength",new i.Pa4),Re(mi,"_center",new i.Pa4),Re(mi,"_modelView",new i.yGw);var vi=function(e){h(o,e);var t,r,i=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;a(this,o),(r=i.call(this)).geometry=e;var n=c(r);return n.initialized=!1,r.geometry.addEventListener("update",(function(){n.update()})),r}return l(o,[{key:"init",value:function(){for(var e=this.children,t=e.length-1;t>=0;--t)this.remove(e[t]);for(var r=this.geometry,i=r.items,o=r.userData,a=0,s=i.length;a<s;++a){var l=i[a];if(l){var c=$.shallowCloneNode(l),u=new mr(c);u.userData=(0,n.clone)(o),u.getElement().style.visibility="visible",u.source=l,this.add(u)}}this.initialized=!0}},{key:"update",value:function(){if(this.geometry.needsUpdate){var e=this.children;this.initialized||this.init();for(var t=0,r=e.length;t<r;++t){var n=e[t],i=n.source;n.position.copy(i.worldPos),n.userData.color=i.opts.color,n.userData.background=i.opts.background}}}}]),o}(i.ZAu);var yi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return a(this,i),(r=n.call(this,e,t)).castShadow=!0,r.receiveShadow=!0,r}return l(i)}(hi(i.Kj0));var _i=hi(i.Kj0),gi=new i.FM8,xi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_onBeforeRender",value:function(e,t,r,n,i,o){var a=this.material;a.uberOptions&&(a.uberOptions.projMatrixInv.copy(r.projectionMatrix).invert(),e.getSize(gi),a.uberOptions.viewport.set(gi.width,gi.height))}}]),i}(_i);var bi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;a(this,i);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return(e=n.call.apply(n,[this].concat(r))).castShadow=!0,e.receiveShadow=!0,e}return l(i)}(hi(i.Kj0)),wi={ZClipped:mi,ZSprite:di,Text:vi,Line:hi(i.x12),LineSegments:hi(i.ejS),Mesh:yi,ThickLineMesh:xi,Instanced:bi};function Si(e,t){return function(r){r.setValues(e),r.setUberOptions(t)}}function Ri(e,t){return{Geometry:function(r,n){return new qn.Instanced2CCylindersGeometry(r,n,e,t)},Object:e?wi.ZSprite:wi.Instanced,initMaterial:Si({instancedMatrix:!0,attrColor:!0,attrColor2:!0,attrAlphaColor:!0,cylinderSprite:e})}}function Ci(e,t){var r=e.prototype instanceof pn,n=t.lineWidth||0;return{Geometry:e,Object:r?wi.ThickLineMesh:wi.LineSegments,initMaterial:Si({lights:!1,attrColor:!0,attrAlphaColor:!0,thickLine:r},{lineWidth:n})}}function Ai(e,t,r,n){var i={wireframe:!!n.wireframe,fakeOpacity:r.now.isoSurfaceFakeOpacity,zClip:n.zClip};return{Geometry:e,Object:wi.ZClipped,initMaterial:Si({attrColor:!0,attrAlphaColor:!1,wireframe:i.wireframe,fakeOpacity:i.fakeOpacity,zClip:i.zClip})}}var Ei=function(){function e(){a(this,e)}return l(e,null,[{key:"createSpheres",value:function(e,t){var r=t.now.zSprites;return{Geometry:function(e,t){return new qn.InstancedSpheresGeometry(e,t,r)},Object:r?wi.ZSprite:wi.Instanced,initMaterial:Si({instancedPos:!0,attrColor:!0,attrAlphaColor:!0,sphereSprite:r})}}},{key:"create2CClosedCylinders",value:function(e,t){return Ri(!1,!1)}},{key:"create2CCylinders",value:function(e,t){return Ri(t.now.zSprites,!0)}},{key:"create2CLines",value:function(e,t,r){return Ci(qn.TwoColorLinesGeometry,r)}},{key:"createCrosses",value:function(e,t,r){return Ci(qn.CrossGeometry,r)}},{key:"createExtrudedChains",value:function(e,t){return{Geometry:qn.ExtrudedObjectsGeometry,Object:wi.Mesh,initMaterial:Si({attrColor:!0,attrAlphaColor:!0})}}},{key:"createChunkedLines",value:function(e,t,r){return Ci(qn.ChunkedLinesGeometry,r)}},{key:"createQuickSurface",value:function(e,t,r){return Ai(qn.QuickSurfGeometry,0,t,r)}},{key:"createContactSurface",value:function(e,t,r){return Ai(qn.ContactSurfaceGeometry,0,t,r)}},{key:"createSASSES",value:function(e,t,r){return Ai(qn.SSIsosurfaceGeometry,0,t,r)}},{key:"createLabels",value:function(e,t){return{Geometry:qn.LabelsGeometry,Object:wi.Text,initMaterial:function(){}}}}]),e}();var ki=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t,r,s){var l;a(this,o),(l=n.call(this))._geometry=e,l._geoParams=t;var c=r.createInstance();t.initMaterial(c),l._material=c,l._transforms=s.length>0?s:[new i.yGw];for(var u=l._createMeshes(e),h=0,f=u.length;h<f;++h)l.add(u[h]);return l}return l(o,[{key:"raycast",value:function(e,t){var r=o._ray,n=o._inverseMatrix,i=this.children;r.copy(e.ray);for(var a=0,s=i.length;a<s;++a){var l=i[a];if(Er.belongToSelectLayers(l)){l.updateMatrixWorld();var c=l.matrixWorld;n.copy(c).invert(),e.ray.copy(r).applyMatrix4(n);var u=[];this._geometry.raycast(e,u);for(var h=0,f=u.length;h<f;++h){var d=u[h];d.point&&(d.point.applyMatrix4(c),d.distance=r.origin.distanceTo(d.point)),d.object=l,t[t.length]=d}}}e.ray.copy(r)}},{key:"getSubset",value:function(e){for(var t=this._geometry.getSubset(e),r=[],n=0,i=0,o=t.length;i<o;++i)for(var a=this._createMeshes(t[i]),s=0,l=a.length;s<l;++s)r[n++]=a[s];return r}},{key:"_createMeshes",value:function(e){for(var t=this._transforms,r=this._geoParams.Object,n=this._material,i=[],o=0,a=t.length;o<a;++o){var s=new r(e,n);s.applyMatrix4(t[o]),i[o]=s}return i}}]),o}(i.Tme);Re(ki,"_inverseMatrix",new i.yGw),Re(ki,"_ray",new i.zHn);var Pi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,s,l,c){var u,h,f,d;if(a(this,i),(u=n.call(this)).constructor===i)throw new Error("Can not instantiate abstract class!");return u._selection=t,u._mode=o,u._colorer=r,u._chunksIdc=t.chunks,u._polyComplexity=l,u._geo=new(h=e.Geometry,f=u._makeGeoArgs(),d=[h].concat(f),h.bind.apply(h,Tr(d))),u._mesh=new ki(u._geo,e,c,s),u.add(u._mesh),u._build(),u}return l(i,[{key:"_makeGeoArgs",value:function(){throw new Error("ChemGroup subclass must override _makeGeoArgs() method")}},{key:"getSubset",value:function(e,t){t=void 0!==t&&t;var r=this._calcChunksList(e,t);return 0===r.length?[]:this._mesh.getSubset(r)}},{key:"_changeSubsetOpacity",value:function(e,t,r){var n=this._calcChunksList(e,r);0!==n.length&&this._geo.setOpacity(n,t)}},{key:"enableSubset",value:function(e,t){t=void 0===t||t,this._changeSubsetOpacity(e,1,t)}},{key:"disableSubset",value:function(e,t){t=void 0===t||t,this._changeSubsetOpacity(e,0,t)}}]),i}(vr);var Ti=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"raycast",value:function(e,t){var r=this._selection.atoms,n=[];this._mesh.raycast(e,n);for(var i=this._chunksIdc,o=0,a=n.length;o<a;++o)if(n[o].hasOwnProperty("chunkIdx")){var s=i[n[o].chunkIdx];s<r.length&&(n[o].atom=r[s],t.push(n[o]))}}},{key:"_calcChunksList",value:function(e){for(var t=[],r=this._selection.atoms,n=this._chunksIdc,i=0,o=n.length;i<o;++i)0!=(r[n[i]].mask&e)&&t.push(i);return t}}]),i}(Pi);var Mi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){return[this._selection.chunks.length,this._polyComplexity]}},{key:"_build",value:function(){for(var e=this._selection.chunks,t=this._selection,r=t.atoms,n=t.parent,i=this._mode,o=this._colorer,a=this._geo,s=0,l=e.length;s<l;++s){var c=r[e[s]];a.setItem(s,c.position,i.calcAtomRadius(c)),a.setColor(s,o.getAtomColor(c,n))}a.finalize()}},{key:"updateToFrame",value:function(e){for(var t=this._selection.chunks,r=this._selection.atoms,n=this._mode,i=this._colorer,o=e.needsColorUpdate(i),a=this._geo,s=0,l=t.length;s<l;++s){var c=r[t[s]];a.setItem(s,e.getAtomPos(t[s]),n.calcAtomRadius(c)),o&&a.setColor(s,e.getAtomColor(i,c))}a.finalize()}}]),i}(Ti);var Ni=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){for(var e=[],t=this._selection,r=t.atoms,n=t.chunks,i=n.length,o=0;o<i;++o)e[o]=r[n[o]];var a=this._mode.getSurfaceOpts();return a.atoms=e,[i,a]}}]),i}(Mi);var Ii=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){for(var e=[],t=this._selection,r=t.atoms,n=t.chunks,i=n.length,o=0;o<i;++o)e[o]=r[n[o]];var a=this._mode.getSurfaceOpts();return a.atoms=e,a.selection=this._selection,a.colorMode=this._colorer,[i,a]}}]),i}(Mi);function Oi(e){return null!==e.name.getNode()?e.name.getNode():e.getVisualName()}var Li={none:function(e){return e},adjust:function(e){var t=e>>16&255,r=e>>8&255,n=255&e;return.2126*t+.7152*r+.0722*n>127?(t=3*t/10,r=3*r/10,n=3*n/10):(t=255-3*(255-t)/10,r=255-3*(255-r)/10,n=255-3*(255-n)/10),t<<16|r<<8|n},inverse:function(e){return 255-(e>>16&255)<<16|255-(e>>8&255)<<8|255-(255&e)}};function Bi(e,t){var r;if(Li.hasOwnProperty(t))r=$.hexColor(Li[t](e));else{var n=parseInt(t,16);r=!Number.isNaN(n)&&t.toLowerCase().startsWith("0x")?$.hexColor(n):"#000000"}return r}var Di={serial:function(e){return e.serial},name:function(e){return e.getVisualName()},elem:function(e){return e.element.name},residue:function(e){return e.residue.getType().getName()},sequence:function(e){return e.residue.getSequence()},chain:function(e){return e.residue.getChain().getName()},hetatm:function(e){return e.isHet()},water:function(e){return"HOH"===e.residue.getType().getName()||"WAT"===e.residue.getType().getName()}},zi=function(e,t){return t.replace(/\{\{(\s*\w+\s*)\}\}/g,(function(t){var r=t.replace(/\s+/g,"");return r=r.substring(2,r.length-2).toLowerCase(),Di.hasOwnProperty(r)?Di[r](e):"null"}))},Fi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){var e=this._mode.getLabelOpts();return[this._selection.chunks.length,e]}},{key:"_build",value:function(){for(var e=this._mode.getLabelOpts(),t=this._selection.chunks,r=this._selection,n=r.atoms,i=r.parent,o=this._colorer,a=this._geo,s=0,l=t.length;s<l;++s){var c=n[t[s]],u=e.template?zi(c,e.template):Oi(c);if(u){var h=o.getAtomColor(c,i),f=parseInt(Bi(h,e.fg).substring(1),16),d=e.showBg?parseInt(Bi(h,e.bg).substring(1),16):"transparent";a.setItem(s,c.position,u),a.setColor(s,f,d)}}a.finalize()}},{key:"updateToFrame",value:function(e){for(var t=this._mode.getLabelOpts(),r=this._selection.chunks,n=this._selection.atoms,i=this._colorer,o=this._geo,a=e.needsColorUpdate(i),s=0,l=r.length;s<l;++s){var c=n[r[s]],u=t.template?zi(c,t.template):Oi(c);if(u){var h=e.getAtomColor(i,c),f=parseInt(Bi(h,t.fg).substring(1),16),d=t.showBg?parseInt(Bi(h,t.bg).substring(1),16):"transparent";o.setItem(s,e.getAtomPos(r[s]),u),a&&o.setColor(s,f,d)}}o.finalize()}}]),i}(Ti);function Vi(e,t,r,n){var i=Math.sin(e);return t.clone().multiplyScalar(Math.sin((1-n)*e)/i).addScaledVector(r,Math.sin(n*e)/i)}var Ui=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return a(this,o),n.apply(this,arguments)}return l(o,[{key:"_buildInner",value:function(e,t){for(var r=this._selection.chunks,n=new i.Pa4,o=new i.Pa4,a=this._segmentsHeight,s=1/a,l=this._colorer,c=this._selection,u=c.cycles,h=c.parent,f=0,d=r[f],p=0,m=u.length;p<m;++p){var v=u[p],y=v.atoms,_=[],g=[],x=v.center,b=v.radius-e,w=y.length,S=0,R=y[w-1].position,C=y[S].position;n.subVectors(R,x),o.subVectors(C,x);for(var A=o.clone().cross(n).normalize();S<w;++S){var E=n.angleTo(o);g[S]=Vi(E,n,o,.5).normalize(),C=y[(S+1)%w].position,n.copy(o),o.subVectors(C,x)}for(S=0;S<w;++S)if(y[S].index===d){for(var k=g[S],P=g[(S+1)%w],T=l.getAtomColor(y[S],h),M=k.angleTo(P),N=0;N<=a;++N)_[N]=Vi(M,k,P,N*s).multiplyScalar(b).add(x);t(f++,T,_,x,A),d=r[f]}}}}]),o}(Ti);function Gi(e,t){for(var r=[],n=0;n<t;++n){var o=-2*n/t*Math.PI;r.push(new i.Pa4(Math.cos(o)*e,Math.sin(o)*e,0))}return r}var ji=Er.calcChunkMatrix,Hi=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return a(this,o),n.apply(this,arguments)}return l(o,[{key:"_build",value:function(){var e=this._segmentsHeight,t=this._mode.getAromRadius(),r=new i.FM8(t,t),n=this._mode.calcStickRadius()+2*t,o=new i.Pa4,a=[],s=this._geo;this._buildInner(n,(function(t,n,i,l,c){for(var u=0;u<=e;++u){var h=i[u],f=h.clone().sub(l).cross(c);o.addVectors(h,f),a[u]=ji(h,o,c,r)}s.setItem(t,a),s.setColor(t,n)})),s.finalize()}},{key:"_makeGeoArgs",value:function(){return this._segmentsHeight=this._polyComplexity,[Gi(1,this._polyComplexity),this._segmentsHeight+1,this._selection.chunks.length]}}]),o}(Ui);var Wi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_build",value:function(){var e=this,t=this._geo,r=this._mode.getAromaticOffset();this._buildInner(r,(function(r,n,i){for(var o=i[0],a=1;a<=e._segmentsHeight;++a){var s=i[a];t.setSegment(r,a-1,o,s),o=s}t.setColor(r,n)})),t.finalize()}},{key:"_makeGeoArgs",value:function(){return this._segmentsHeight=this._mode.getAromaticArcChunks(),[this._selection.chunks.length,this._segmentsHeight,!0]}}]),i}(Ui);var Yi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"raycast",value:function(e,t){var r=this._selection.residues,n=[];this._mesh.raycast(e,n);for(var i=this._chunksIdc,o=0,a=n.length;o<a;++o)if(n[o].hasOwnProperty("chunkIdx")){var s=i[n[o].chunkIdx];s<r.length&&(n[o].residue=r[s],t.push(n[o]))}}},{key:"_calcChunksList",value:function(e){for(var t=[],r=this._selection.residues,n=this._chunksIdc,i=0,o=n.length;i<o;++i)0!=(r[n[i]]._mask&e)&&t.push(i);return t}}]),i}(Pi);var Xi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"raycast",value:function(e,t){var r=this._selection.residues,n=[];this._mesh.raycast(e,n);for(var i=this._chunksIdc,o=0,a=n.length;o<a;++o)if(n[o].hasOwnProperty("chunkIdx")){var s=i[Math.floor(n[o].chunkIdx/2)];s<r.length&&(n[o].residue=r[s],t.push(n[o]))}}},{key:"_build",value:function(){for(var e=this._selection,t=e.residues,r=e.parent,n=this._colorer,i=this._geo,o=this._mode.calcStickRadius(),a=0,s=this._selection.chunks,l=0,c=s.length;l<c;++l){var u=t[s[l]],h=n.getResidueColor(u,r);this._processItem(a++,u._cylinders[0],u._cylinders[1],o,h)}i.finalize()}},{key:"_calcChunksList",value:function(e){for(var t=[],r=0,n=this._selection.residues,i=this._chunksIdc,o=0,a=i.length;o<a;++o)0!=(n[i[o]]._mask&e)&&(t[r++]=2*o,t[r++]=2*o+1);return t}},{key:"updateToFrame",value:function(e){for(var t=e.getResidues(),r=this._selection.parent,n=this._colorer,i=this._geo,o=this._mode.calcStickRadius(),a=0,s=this._selection.chunks,l=0,c=s.length;l<c;++l){var u=t[s[l]],h=n.getResidueColor(u,r);this._processItem(a++,u._cylinders[0],u._cylinders[1],o,h)}i.finishUpdate()}}]),i}(Yi);var qi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){return[this._selection.chunks.length,this._polyComplexity]}},{key:"_processItem",value:function(e,t,r,n,i){var o=this._geo;o.setItem(e,t,r,n),o.setColor(e,i,i)}}]),i}(Xi);var $i,Zi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){return[2*this._selection.chunks.length,this._polyComplexity]}},{key:"_processItem",value:function(e,t,r,n,i){var o=this._geo,a=2*e;o.setItem(a,t,n),o.setColor(a,i),a++,o.setItem(a,r,n),o.setColor(a,i)}}]),i}(Xi),Ki={};$i=Ki,function(){var e,t,r,n,i,o,a,s,l,c,u,h,f,d,p,m,v,y,_,g,x,b,w,S,R,C,A=Object.prototype.hasOwnProperty,E=function(e,t){for(var r in t)A.call(t,r)&&(e[r]=t[r]);function n(){this.constructor=e}return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e};for(m in h={method:(r={METHOD_NEAREST:"nearest",METHOD_LINEAR:"linear",METHOD_CUBIC:"cubic",METHOD_LANCZOS:"lanczos",METHOD_SINC:"sinc",CLIP_CLAMP:"clamp",CLIP_ZERO:"zero",CLIP_PERIODIC:"periodic",CLIP_MIRROR:"mirror",CUBIC_TENSION_DEFAULT:0,CUBIC_TENSION_CATMULL_ROM:0}).METHOD_CUBIC,cubicTension:r.CUBIC_TENSION_DEFAULT,clip:r.CLIP_CLAMP,scaleTo:0,sincFilterSize:2,sincWindow:void 0},l=function(e,t){return Math.max(0,Math.min(e,t-1))},u=function(e,t){return(e%=t)<0&&(e+=t),e},c=function(e,t){var r;return(e=u(e,r=2*(t-1)))>t-1&&(e=r-e),e},e=function(){function e(e,t){if(this.array=e.slice(0),this.length=this.array.length,!(this.clipHelper={clamp:this.clipHelperClamp,zero:this.clipHelperZero,periodic:this.clipHelperPeriodic,mirror:this.clipHelperMirror}[t.clip]))throw"Invalid clip: "+t.clip}return e.prototype.getClippedInput=function(e){return 0<=e&&e<this.length?this.array[e]:this.clipHelper(e)},e.prototype.clipHelperClamp=function(e){return this.array[l(e,this.length)]},e.prototype.clipHelperZero=function(e){return 0},e.prototype.clipHelperPeriodic=function(e){return this.array[u(e,this.length)]},e.prototype.clipHelperMirror=function(e){return this.array[c(e,this.length)]},e.prototype.interpolate=function(e){throw"Subclasses of AbstractInterpolator must override the interpolate() method."},e}(),i=function(e){function t(){t.__super__.constructor.apply(this,arguments)}return E(t,e),t.prototype.interpolate=function(e){return this.getClippedInput(Math.round(e))},t}(e),n=function(e){function t(){t.__super__.constructor.apply(this,arguments)}return E(t,e),t.prototype.interpolate=function(e){var t;return(1-(e-=t=Math.floor(e)))*this.getClippedInput(t)+e*this.getClippedInput(t+1)},t}(e),t=function(e){function t(e,r){this.tangentFactor=1-Math.max(-1,Math.min(1,r.cubicTension)),t.__super__.constructor.apply(this,arguments)}return E(t,e),t.prototype.getTangent=function(e){return this.tangentFactor*(this.getClippedInput(e+1)-this.getClippedInput(e-1))/2},t.prototype.interpolate=function(e){var t,r,n,i,o;return t=Math.floor(e),r=[this.getTangent(t),this.getTangent(t+1)],(2*(o=(e-=t)*(i=e*e))-3*i+1)*(n=[this.getClippedInput(t),this.getClippedInput(t+1)])[0]+(o-2*i+e)*r[0]+(-2*o+3*i)*n[1]+(o-i)*r[1]},t}(e),b=Math.sin,o=Math.PI,w=function(e){return 0===e?1:b(o*e)/(o*e)},v=function(e){return function(t){return w(t/e)}},_=function(e){return function(t){return w(t)*e(t)}},a=function(e){function t(e,r){if(t.__super__.constructor.apply(this,arguments),this.a=r.sincFilterSize,!r.sincWindow)throw"No sincWindow provided";this.kernel=_(r.sincWindow)}return E(t,e),t.prototype.interpolate=function(e){var t,r,n,i,o;for(n=0,r=i=(t=Math.floor(e))-this.a+1,o=t+this.a;i<=o?r<=o:r>=o;i<=o?r++:r--)n+=this.kernel(e-r)*this.getClippedInput(r);return n},t}(e),f=function(e,t){var r,n,i,o;for(o=[],n=0,i=e.length;n<i;n++)r=e[n],o.push(r[t]);return o},y=function(e,t,r){var n,i;return"0,1"===r.join?e:(n=t/(r[1]-r[0]),i=r[0],function(t){return e(n*(t-i))})},d=function(e){return Object.prototype.toString.call(e).slice("[object ".length,-1)},R=function(e){if(isNaN(e))throw"NaN in Smooth() input";if("Number"!==d(e))throw"Non-number in Smooth() input";if(!isFinite(e))throw"Infinity in Smooth() input"},C=function(e,t){var r,n,i;if("Array"!==d(e))throw"Non-vector in Smooth() input";if(e.length!==t)throw"Inconsistent dimension in Smooth() input";for(n=0,i=e.length;n<i;n++)r=e[n],R(r)},p=function(e){return"Number"===d(e)&&isFinite(e)&&!isNaN(e)},g=function(e){var t;switch(t="scaleTo param must be number or array of two numbers",d(e)){case"Number":if(!p(e))throw t;e=[0,e];break;case"Array":if(2!==e.length)throw t;if(!p(e[0])||!p(e[1]))throw t;break;default:throw t}return e},x=function(e){var t,r,n;for(r in t={},e)A.call(e,r)&&(n=e[r],t[r]=n);return t},s=function(e,r){var o,l,c,u,p,m,_,b,w,S,E;for(_ in null==r&&(r={}),w={},r=x(r),w.config=x(r),null==r.scaleTo&&(r.scaleTo=r.period),null==r.sincFilterSize&&(r.sincFilterSize=r.lanczosFilterSize),h)A.call(h,_)&&(E=h[_],null==r[_]&&(r[_]=E));if(!(p={nearest:i,linear:n,cubic:t,lanczos:a,sinc:a}[r.method]))throw"Invalid method: "+r.method;if("lanczos"===r.method&&(r.sincWindow=v(r.sincFilterSize)),e.length<2)throw"Array must have at least two elements";for(_ in w.count=e.length,S=function(){var t,n,i,o;switch(d(e[0])){case"Number":if(w.dimension="scalar",s.deepValidation)for(t=0,i=e.length;t<i;t++)b=e[t],R(b);return u=new p(e,r),function(e){return u.interpolate(e)};case"Array":if(w.dimension=l=e[0].length,!l)throw"Vectors must be non-empty";if(s.deepValidation)for(n=0,o=e.length;n<o;n++)E=e[n],C(E,l);return m=function(){var t;for(t=[],c=0;0<=l?c<l:c>l;0<=l?c++:c--)t.push(new p(f(e,c),r));return t}(),function(e){var t,r,n,i;for(i=[],r=0,n=m.length;r<n;r++)t=m[r],i.push(t.interpolate(e));return i};default:throw"Invalid element type: "+d(e[0])}}(),o="periodic"===r.clip?e.length:e.length-1,r.scaleTo||(r.scaleTo=o),w.domain=g(r.scaleTo),S=y(S,o,w.domain),w.domain.sort(),w)A.call(w,_)&&(E=w[_],S[_]=E);return S},r)A.call(r,m)&&(S=r[m],s[m]=S);s.deepValidation=!0,(null!==$i?$i:window).Smooth=s}.call(Ke);var Qi=pr.ResidueType,Ji=Er.calcChunkMatrix;function eo(e,t){var r=Ki.Smooth(e,{method:Ki.Smooth.METHOD_CUBIC,clip:Ki.Smooth.CLIP_CLAMP,cubicTension:t,scaleTo:1});return function(t,n){var o=n;null===o&&(o=function(t){return(t*(e.length-1-2)+1)/(e.length-1)});var a=o(t),s=r(a);return new i.Pa4(s[0],s[1],s[2])}}function to(e,t,r,n){if(!n._isValid)return e[r]=e[r-1],void(t[r]=t[r-1]);var i=n._controlPoint;e[r]=[i.x,i.y,i.z];var o=i.clone().add(n._wingVector);t[r]=[o.x,o.y,o.z]}var ro=function(){function e(t,r,n,i,o,s){a(this,e);var l=function(e,t,r,n){var i=n.start,o=n.end;function a(t){return t>i&&e[t-1]._isValid?t-1:t}function s(t){return t<o&&e[t+1]._isValid?t+1:t}var l=[],c=[],u=0;function h(t,r){var n=e[t]._controlPoint.clone().lerp(e[r]._controlPoint,-.25),i=n.clone().add(e[t]._wingVector);c[u]=[n.x,n.y,n.z],l[u++]=[i.x,i.y,i.z],c[u]=[n.x,n.y,n.z],l[u++]=[i.x,i.y,i.z]}var f=a(t),d=s(r);if(f===d)return function(e,t,r,n){var i,o,a=0!=(n._type.flags&Qi.Flags.NUCLEIC),s=a?"C5'":"N",l=a?"C3'":"C";if(n.forEachAtom((function(e){var t=e.getVisualName();i||t!==s?o||t!==l||(o=e.position):i=e.position})),i&&o||(i=n._firstAtom.position,o=n._lastAtom.position),i&&o){var c=o.clone().sub(i),u=n._wingVector,h=n._controlPoint,f=h.clone().add(u),d=h.clone().sub(c),p=d.clone().add(u);e[r]=[d.x,d.y,d.z],t[r]=[p.x,p.y,p.z],e[++r]=[d.x,d.y,d.z],t[r]=[p.x,p.y,p.z],e[++r]=[h.x,h.y,h.z],t[r]=[f.x,f.y,f.z],++r;var m=h.clone().add(c),v=m.clone().add(u);e[r]=[m.x,m.y,m.z],t[r]=[v.x,v.y,v.z],e[++r]=[m.x,m.y,m.z],t[r]=[v.x,v.y,v.z]}}(c,l,u,e[t]),{centerPoints:c,topPoints:l};t===f?h(t,s(t)):(to(c,l,u++,e[a(f)]),to(c,l,u++,e[f]));for(var p=t;p<=r;++p)to(c,l,u++,e[p]);return d===s(d)?h(r,a(r)):(to(c,l,u++,e[d]),to(c,l,u,e[s(d)])),{centerPoints:c,topPoints:l}}(t,r,n,s);this._topInterp=eo(l.topPoints,o),this._centerInterp=eo(l.centerPoints,o),this._shift=.5/(n-r+2),this._valueStep=(1-2*this._shift)/(2*(n-r+1)*(i-1)),this._segmentsCount=i}return l(e,[{key:"prepareMatrices",value:function(e,t,r){for(var n=this._segmentsCount,o=new Array(n),a=new i.FM8(0,0),s=this._topInterp,l=this._centerInterp,c=this._shift+this._valueStep*(n-1)*e,u=0;u<n;++u){var h=Math.min(1,u/(n-1));a.lerpVectors(t,r,h);var f=s(c,null),d=l(c,null),p=l(c+=this._valueStep,null);o[u]=Ji(d.clone(),p.clone(),f.clone().sub(d),a)}return o}}]),e}();function no(e,t){for(var r=[],n=0;n<t;++n){var o=Math.PI/2-2*Math.PI*n/t;r.push(new i.Pa4(Math.cos(o)*e,Math.sin(o)*e,0))}return r}function io(e,t,r,n,i,o){for(var a=0,s=e.length;a<s;++a)for(var l=e[a].arr,c=e[a].boundaries,u=0,h=l.length;u<h;++u)for(var f=[l[u].start,l[u].end],d=new ro(t,f[0],f[1],r,n,c),p=null,m=2*l[u].start,v=2*l[u].end+1,y=i.getResidueRadius(t[0],0),_=m;_<=v;++_){var g=t[_/2|0],x=i.getResidueRadius(g,_%2),b=i.getResidueRadius(g,1+_%2),w=d.prepareMatrices(_-2*f[0],x,b);w.unshift(null===p?w[0]:p),o(g,w,x.x!==b.x||x.y!==b.y,x.x!==y.x||x.y!==y.y),p=w[r],y=b}}var oo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){var e=this._mode.getHeightSegmentsRatio();return this._segmentsHeight=this._polyComplexity*e|0,[no(1,this._polyComplexity),this._segmentsHeight+1,2*this._selection.chunks.length]}},{key:"_build",value:function(){var e=this._selection,t=e.residues,r=e.parent,n=this._mode,i=this._colorer,o=n.getTension(),a=this._geo,s=0,l=[];io(this._selection.subdivs,t,this._segmentsHeight,o,n,(function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],c=i.getResidueColor(e,r);l[s]=e._index,a.setItem(s,t,n,o),a.setColor(s++,c)})),this._chunksIdc=l,a.finalize()}},{key:"updateToFrame",value:function(e){var t=this._selection.parent,r=this._mode,n=this._colorer,i=r.getTension(),o=this._geo,a=e.getResidues(),s=0,l=e.needsColorUpdate(n);io(this._selection.subdivs,a,this._segmentsHeight,i,r,(function(e,r){o.setItem(s,r),l&&o.setColor(s,n.getResidueColor(e,t)),s++})),o.finalize()}}]),i}(Yi);var ao=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){for(var e=this._selection.subdivs,t=0,r=0,n=e.length;r<n;++r)for(var i=e[r].arr,o=0,a=i.length;o<a;++o)t+=i[o].end-i[o].start;return[t,this._polyComplexity]}},{key:"_build",value:function(){for(var e=this._selection,t=e.residues,r=e.parent,n=this._mode,i=this._colorer,o=this._geo,a=0,s=[],l=this._selection.subdivs,c=n.calcStickRadius(),u=0,h=l.length;u<h;++u)for(var f=l[u].arr,d=0,p=f.length;d<p;++d)for(var m=f[d].start,v=f[d].end,y=t[m],_=m+1;_<=v;++_){var g=t[_];s[a]={first:y._index,second:g._index},o.setItem(a,y._controlPoint,g._controlPoint,c),o.setColor(a,i.getResidueColor(y,r),i.getResidueColor(g,r)),a++,y=g}this._chunksIdc=s,o.finalize()}},{key:"updateToFrame",value:function(e){for(var t=e.getResidues(),r=this._selection.parent,n=this._mode,i=this._colorer,o=this._geo,a=0,s=this._selection.subdivs,l=n.calcStickRadius(),c=e.needsColorUpdate(i),u=0,h=s.length;u<h;++u)for(var f=s[u].arr,d=0,p=f.length;d<p;++d)for(var m=f[d].start,v=f[d].end,y=t[m],_=m+1;_<=v;++_){var g=t[_];o.setItem(a,y._controlPoint,g._controlPoint,l),c&&o.setColor(a,i.getResidueColor(y,r),i.getResidueColor(g,r)),a++,y=g}o.finalize()}},{key:"raycast",value:function(e,t){var r=[],n=this._selection.residues;this._mesh.raycast(e,r);for(var i=this._chunksIdc,o=0,a=r.length;o<a;++o)if(r[o].hasOwnProperty("chunkIdx")){var s=r[o].chunkIdx,l=i[Math.floor(s/2)],c=s%2==0?l.first:l.second;c<n.length&&(r[o].residue=n[c],t.push(r[o]))}}},{key:"_calcChunksList",value:function(e){for(var t=[],r=this._chunksIdc,n=this._selection.residues,i=0,o=r.length;i<o;++i){var a=r[i];n[a.first]._mask&e&&t.push(2*i),n[a.second]._mask&e&&t.push(2*i+1)}return t}}]),i}(Pi);var so=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){for(var e=this._mode.drawMultiorderBonds(),t=this._mode.showAromaticLoops(),r=this._selection.chunks,n=this._selection.bonds,i=0,o=0,a=r.length;o<a;++o)i+=this.getBondOrder(n[r[o]],e,t);return[i,this._polyComplexity]}},{key:"getBondOrder",value:function(e,t,r){var n=1;return!t||r&&e._type===Pe.BondType.AROMATIC||(n=function(e){return e<2?1:e}(e._order)),n}},{key:"raycast",value:function(e,t){var r=this._selection.bonds,n=[];this._mesh.raycast(e,n);for(var i=this._chunksIdc,o=0,a=n.length;o<a;++o)if(n[o].hasOwnProperty("chunkIdx")){var s=n[o].chunkIdx,l=i[Math.floor(s/2)];if(l<r.length){var c=r[l];n[o].atom=s%2==0?c._left:c._right,t.push(n[o])}}}},{key:"_calcChunksList",value:function(e,t){for(var r=[],n=this._selection.bonds,i=this._chunksIdc,o=0,a=i.length;o<a;++o){var s=n[i[o]];s._left.mask&e&&(!t||s._right.mask&e)&&r.push(2*o),s._right.mask&e&&(!t||s._left.mask&e)&&r.push(2*o+1)}return r}}]),i}(Pi);var lo=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return a(this,o),n.apply(this,arguments)}return l(o,[{key:"_build",value:function(){for(var e,t=this._selection.chunks,r=this._selection,n=r.bonds,o=r.parent,a=this._mode,s=this._colorer,l=this._geo,c=a.drawMultiorderBonds(),u=a.showAromaticLoops(),h=a.calcStickRadius(),f=a.calcSpaceFraction(),d=new i.Pa4,p=new i.Pa4,m=0,v=[],y=0,_=t.length;y<_;++y){var g=n[t[y]],x=g._left,b=g._right,w=x.position,S=b.position;e=g.calcNormalDir();for(var R=this.getBondOrder(g,c,u),C=2*Math.min(a.calcAtomRadius(x),a.calcAtomRadius(b))/R,A=c?Math.min(h,.5*C*(1-f)):h,E=0;E<R;++E){var k=C*(R%2==0?(.5+(E/2|0))*(1-E%2*2):((E+1)/2|0)*(E%2*2-1));v[m]=g._index,d.copy(w),d.addScaledVector(e,k),p.copy(S),p.addScaledVector(e,k),l.setItem(m,d,p,A),l.setColor(m++,s.getAtomColor(x,o),s.getAtomColor(b,o))}}l.finalize(),this._chunksIdc=v}},{key:"updateToFrame",value:function(e){for(var t,r=this._selection.chunks,n=this._selection.bonds,o=this._mode,a=this._colorer,s=this._geo,l=o.drawMultiorderBonds(),c=o.showAromaticLoops(),u=o.calcStickRadius(),h=o.calcSpaceFraction(),f=new i.Pa4,d=new i.Pa4,p=0,m=e.needsColorUpdate(a),v=0,y=r.length;v<y;++v){var _=n[r[v]],g=_._left,x=_._right,b=e.getAtomPos(g.index).clone(),w=e.getAtomPos(x.index);t=_.calcNormalDir();for(var S=this.getBondOrder(_,l,c),R=2*Math.min(o.calcAtomRadius(g),o.calcAtomRadius(x))/S,C=l?Math.min(u,.5*R*(1-h)):u,A=0;A<S;++A){var E=R*(S%2==0?(.5+(A/2|0))*(1-A%2*2):((A+1)/2|0)*(A%2*2-1));f.copy(b),f.addScaledVector(t,E),d.copy(w),d.addScaledVector(t,E),s.setItem(p,f,d,C),m&&s.setColor(p,e.getAtomColor(a,g),e.getAtomColor(a,x)),p++}}s.finalize()}}]),o}(so);var co=.15,uo=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return a(this,o),n.apply(this,arguments)}return l(o,[{key:"_build",value:function(){for(var e=this._selection.chunks,t=this._selection,r=t.bonds,n=t.parent,o=this._mode,a=this._colorer,s=this._geo,l=o.drawMultiorderBonds(),c=o.showAromaticLoops(),u=new i.Pa4,h=new i.Pa4,f=new i.Pa4,d=0,p=[],m=0,v=e.length;m<v;++m){var y=r[e[m]],_=y._left,g=y._right,x=_.position,b=g.position,w=1===_.bonds.length,S=1===g.bonds.length;u.subVectors(b,x);for(var R=u.length(),C=y.calcNormalDir(),A=this.getBondOrder(y,l,c),E=0;E<A;++E){h.copy(x),f.copy(b);var k=A%2==0?(.5+(E/2|0))*(1-E%2*2):((E+1)/2|0)*(E%2*2-1);p[d]=y._index,2!==A||w||S||(k-=.5,k*=-1),!w&&!S&&A>1&&0!==k&&(h.lerpVectors(x,b,co/R),f.lerpVectors(x,b,1-co/R)),k*=co,h.addScaledVector(C,k),f.addScaledVector(C,k),s.setItem(d,h,f),s.setColor(d++,a.getAtomColor(_,n),a.getAtomColor(g,n))}}s.finalize(),this._chunksIdc=p}},{key:"updateToFrame",value:function(e){for(var t=this._selection.chunks,r=this._selection.bonds,n=this._mode,o=this._colorer,a=this._geo,s=n.drawMultiorderBonds(),l=n.showAromaticLoops(),c=new i.Pa4,u=new i.Pa4,h=new i.Pa4,f=0,d=e.needsColorUpdate(o),p=0,m=t.length;p<m;++p){var v=r[t[p]],y=v._left,_=v._right,g=e.getAtomPos(y.index).clone(),x=e.getAtomPos(_.index),b=1===y.bonds.length,w=1===_.bonds.length;c.subVectors(x,g);for(var S=c.length(),R=v.calcNormalDir(),C=this.getBondOrder(v,s,l),A=0;A<C;++A){u.copy(g),h.copy(x);var E=C%2==0?(.5+(A/2|0))*(1-A%2*2):((A+1)/2|0)*(A%2*2-1);2!==C||b||w||(E-=.5,E*=-1),!b&&!w&&C>1&&0!==E&&(u.lerpVectors(g,x,co/S),h.lerpVectors(g,x,1-co/S)),E*=co,u.addScaledVector(R,E),h.addScaledVector(R,E),a.setItem(f,u,h),d&&a.setColor(f,e.getAtomColor(o,y),e.getAtomColor(o,_)),f++}}a.finalize()}}]),o}(so),ho={AtomsSphereGroup:Mi,AtomsSurfaceGroup:Ni,AtomsSASSESGroupStub:Ii,AtomsTextGroup:Fi,AromaticTorusGroup:Hi,AromaticLinesGroup:Wi,NucleicCylindersGroup:qi,NucleicSpheresGroup:Zi,ResiduesSubseqGroup:oo,ResiduesTraceGroup:ao,BondsCylinderGroup:lo,BondsLinesGroup:uo};var fo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,s,l,u,h){var f;a(this,i);var d=c(f=n.call(this));f._complex=r,f._mode=s;var p=r.getAtoms(),m=r.getTransforms();return r.forEachComponent((function(n){var i=[],a=0;if(n.forEachAtom((function(e){d._checkAtom(e,u)&&(i[a++]=e.index)})),0!==a){var c=new e(t,{atoms:p,chunks:i,parent:r},o,s,m,l,h);c._component=n,d.add(c)}})),f}return l(i,[{key:"_checkAtom",value:function(e,t){return e.mask&t}},{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=0,a=n.length;o<a;++o)if(n[o].getSubset)for(var s=n[o].getSubset(e,t),l=0,c=s.length;l<c;++l){var u=s[l];u._component=n[o]._component,r[i++]=u}return r}}]),i}(vr);var po=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_checkAtom",value:function(e,t){if(!(e.mask&t))return!1;for(var r=e.bonds,n=0,i=r.length;n<i;++n)if(r[n]._left.mask&t&&r[n]._right.mask&t)return!1;return!0}}]),i}(fo);var mo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,s,l,u,h){var f;a(this,i);var d=c(f=n.call(this));f._complex=r;var p=r.getResidues(),m=r.getTransforms();return r.forEachComponent((function(n){var i=0,a=[];if(n.forEachResidue((function(e){d._checkResidue(e,u)&&(a[i++]=e._index)})),0!==i){var c=new e(t,{residues:p,chunks:a,parent:r},o,s,m,l,h);c._component=n,d.add(c)}})),f}return l(i,[{key:"checkResidue",value:function(e,t){return e._mask&t}},{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=0,a=n.length;o<a;++o)if(n[o].getSubset)for(var s=n[o].getSubset(e,t),l=0,c=s.length;l<c;++l){var u=s[l];u._component=n[o]._component,r[i++]=u}return r}}]),i}(vr);var vo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_checkResidue",value:function(e,t){return t&e._mask&&null!==e._cylinders}}]),i}(mo);var yo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,s,l,u,h){var f;a(this,i);var d=c(f=n.call(this));f._complex=r;var p=r.getResidues(),m=r.getTransforms();return r.forEachComponent((function(n){for(var i=n.getMaskedSubdivSequences(u),a=0,c=[],f=0,v=i.length;f<v;++f)for(var y=i[f].arr,_=0,g=y.length;_<g;++_)for(var x=y[_].start,b=y[_].end;x<=b;++x)c[a++]=p[x]._index;if(0!==a){var w=new e(t,{residues:p,chunks:c,subdivs:i,parent:r},o,s,m,l,h);w._component=n,d.add(w)}})),f}return l(i,[{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=0,a=n.length;o<a;++o)if(n[o].getSubset)for(var s=n[o].getSubset(e,t),l=0,c=s.length;l<c;++l){var u=s[l];u._component=n[o]._component,r[i++]=u}return r}}]),i}(vr);var _o=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,s,l,u,h){var f;a(this,i);var d=c(f=n.call(this));f._complex=r;var p=r.getBonds(),m=r.getTransforms();return r.forEachComponent((function(n){var i=[],a=0;if(n.forEachBond((function(e){var t=e._left,r=e._right;t.mask&u&&r.mask&u&&(i[a++]=e._index)})),0!==a){var c=new e(t,{bonds:p,chunks:i,parent:r},o,s,m,l,h);c._component=n,d.add(c)}})),f}return l(i,[{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=0,a=n.length;o<a;++o)if(n[o].getSubset)for(var s=n[o].getSubset(e,t),l=0,c=s.length;l<c;++l){var u=s[l];u._component=n[o]._component,r[i++]=u}return r}}]),i}(vr);var go=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,s,l,u,h){var d;a(this,i);var p=c(d=n.call(this));d._complex=r;var m=r.getAtoms(),v=r.getTransforms();return s.showAromaticLoops()?(r.forEachComponent((function(n){var i=[],a=0,c=[],f=0;n.forEachCycle((function(e){for(var t=e.atoms,r=0,n=0,o=t.length;n<o;++n)0!=(t[n].mask&u)&&(++r,i[a++]=t[n].index);r>0&&(c[f++]=e)}));var d=new e(t,{cycles:c,atoms:m,chunks:i,parent:r},o,s,v,l,h);d._component=n,p.add(d)})),d):f(d)}return l(i,[{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=0,a=n.length;o<a;++o)if(n[o].getSubset)for(var s=n[o].getSubset(e,t),l=0,c=s.length;l<c;++l){var u=s[l];u._component=n[o]._component,r[i++]=u}return r}}]),i}(vr),xo={Atoms:fo,OrphanAtoms:po,Residues:mo,Nucleic:vo,Subseqs:yo,Bonds:_o,Aromatic:go};function bo(e,t,r){return function(n,i,o,a,s,l){return new t(r,e,n,i,o,a,s,l)}}var wo=function(){function e(){a(this,e)}return l(e,null,[{key:"AtomsSpheres",value:function(e,t){return bo(Ei.createSpheres(e,t),xo.Atoms,ho.AtomsSphereGroup)}},{key:"OrphanedAtomsCrosses",value:function(e,t,r){return bo(Ei.createCrosses(e,t,r),xo.OrphanAtoms,ho.AtomsSphereGroup)}},{key:"BondsCylinders",value:function(e,t){return bo(Ei.create2CCylinders(e,t),xo.Bonds,ho.BondsCylinderGroup)}},{key:"BondsLines",value:function(e,t,r){return bo(Ei.create2CLines(e,t,r),xo.Bonds,ho.BondsLinesGroup)}},{key:"CartoonChains",value:function(e,t){return bo(Ei.createExtrudedChains(e,t),xo.Subseqs,ho.ResiduesSubseqGroup)}},{key:"TraceChains",value:function(e,t){return bo(Ei.create2CClosedCylinders(e,t),xo.Subseqs,ho.ResiduesTraceGroup)}},{key:"NucleicSpheres",value:function(e,t){return bo(Ei.createSpheres(e,t),xo.Nucleic,ho.NucleicSpheresGroup)}},{key:"NucleicCylinders",value:function(e,t){return bo(Ei.create2CCylinders(e,t),xo.Nucleic,ho.NucleicCylindersGroup)}},{key:"ALoopsTorus",value:function(e,t){return bo(Ei.createExtrudedChains(e,t),xo.Aromatic,ho.AromaticTorusGroup)}},{key:"ALoopsLines",value:function(e,t,r){return bo(Ei.createChunkedLines(e,t,r),xo.Aromatic,ho.AromaticLinesGroup)}},{key:"QuickSurfGeo",value:function(e,t,r){return bo(Ei.createQuickSurface(e,t,r),xo.Atoms,ho.AtomsSurfaceGroup)}},{key:"ContactSurfaceGeo",value:function(e,t,r){return bo(Ei.createContactSurface(e,t,r),xo.Atoms,ho.AtomsSurfaceGroup)}},{key:"SASSESSurfaceGeo",value:function(e,t,r){return bo(Ei.createSASSES(e,t,r),xo.Atoms,ho.AtomsSASSESGroupStub)}},{key:"TextLabelsGeo",value:function(e,t){return bo(Ei.createLabels(e,t),xo.Atoms,ho.AtomsTextGroup)}}]),e}(),So=function(){function e(t){if(a(this,e),this.constructor===e)throw new Error("Can not instantiate abstract class!");this.opts=(0,n.merge)($.deriveDeep(this.settings.now.modes[this.id],!0),t)}return l(e,[{key:"identify",value:function(){var e=$.objectsDiff(this.opts,this.settings.now.modes[this.id]);return(0,n.isEmpty)(e)?this.id:[this.id,e]}},{key:"buildGeometry",value:function(e,t,r,i){for(var o=this.opts.polyComplexity?this.opts.polyComplexity[this.settings.now.resolution]:0,a=this.depGroups,s=a.length,l=new Er.RCGroup,c=0;c<s;++c){var u=a[c],h={};(0,n.isArray)(u)&&(h=u[1].call(this),u=v(u,1)[0]);var f=new(wo[u](null,this.settings,h))(e,t,this,o,r,i);f.children.length>0&&l.add(f)}return l}}]),e}();function Ro(){return{lineWidth:this.opts.lineWidth}}Ir(So.prototype),So.prototype.id="__",So.prototype.depGroups=[];var Co=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;a(this,i),(t=n.call(this,e)).depGroups=t.depGroups.slice(0);for(var r=t.depGroups,o=0,s=r.length;o<s;++o)r[o]=[r[o],Ro];return t}return l(i,[{key:"drawMultiorderBonds",value:function(){return this.opts.multibond}},{key:"calcAtomRadius",value:function(){return this.opts.atom}},{key:"getAromaticOffset",value:function(){return this.opts.offsarom}},{key:"getAromaticArcChunks",value:function(){return this.opts.chunkarom}},{key:"showAromaticLoops",value:function(){return this.opts.showarom}}]),i}(So);Re(Co,"id","LN"),Co.prototype.id="LN",Co.prototype.name="Lines",Co.prototype.shortName="Lines",Co.prototype.depGroups=["ALoopsLines","BondsLines","OrphanedAtomsCrosses"];var Ao=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"calcAtomRadius",value:function(e){return this.opts.bond}},{key:"calcStickRadius",value:function(){return this.opts.bond}},{key:"calcSpaceFraction",value:function(){return this.opts.space}},{key:"getAromRadius",value:function(){return this.opts.aromrad}},{key:"showAromaticLoops",value:function(){return this.opts.showarom}},{key:"drawMultiorderBonds",value:function(){return this.opts.multibond}}]),i}(So);Re(Ao,"id","LC"),Ao.prototype.id="LC",Ao.prototype.name="Licorice",Ao.prototype.shortName="Licorice",Ao.prototype.depGroups=["AtomsSpheres","BondsCylinders","ALoopsTorus"];var Eo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"calcAtomRadius",value:function(e){return e.element.radius*this.opts.atom}},{key:"calcStickRadius",value:function(){return this.opts.bond}},{key:"getAromRadius",value:function(){return this.opts.aromrad}},{key:"showAromaticLoops",value:function(){return this.opts.showarom}},{key:"calcSpaceFraction",value:function(){return this.opts.space}},{key:"drawMultiorderBonds",value:function(){return this.opts.multibond}}]),i}(So);Re(Eo,"id","BS"),Eo.prototype.id="BS",Eo.prototype.name="Balls and Sticks",Eo.prototype.shortName="Balls",Eo.prototype.depGroups=["AtomsSpheres","BondsCylinders","ALoopsTorus"];var ko=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"calcAtomRadius",value:function(e){return e.element.radius}}]),i}(So);Re(ko,"id","VW"),ko.prototype.id="VW",ko.prototype.name="Van der Waals",ko.prototype.shortName="VDW",ko.prototype.depGroups=["AtomsSpheres"];var Po=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"calcStickRadius",value:function(){return this.opts.radius}}]),i}(So);Re(Po,"id","TR"),Po.prototype.id="TR",Po.prototype.name="Trace",Po.prototype.shortName="Trace",Po.prototype.depGroups=["TraceChains"];var To=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return a(this,o),n.apply(this,arguments)}return l(o,[{key:"getResidueRadius",value:function(e){return this.TUBE_RADIUS}},{key:"getHeightSegmentsRatio",value:function(){return this.opts.heightSegmentsRatio}},{key:"getTension",value:function(){return this.opts.tension}},{key:"buildGeometry",value:function(e,t,r,n){var o=this.opts.radius;return this.TUBE_RADIUS=new i.FM8(o,o),So.prototype.buildGeometry.call(this,e,t,r,n)}}]),o}(So);Re(To,"id","TU"),To.prototype.id="TU",To.prototype.name="Tube",To.prototype.shortName="Tube",To.prototype.depGroups=["CartoonChains"];var Mo=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;return a(this,o),(t=n.call(this,e)).secCache={},t}return l(o,[{key:"getResidueStartRadius",value:function(e){var t=e.getSecondary();if(!t||!t.generic)return this.TUBE_RADIUS;var r=this.secCache[t.generic];return r?t.term===e?r.start:r.center:this.TUBE_RADIUS}},{key:"getResidueEndRadius",value:function(e){var t=e.getSecondary();if(null===t||!t.generic)return this.TUBE_RADIUS;var r=this.secCache[t.generic];return r?t.term===e?this.ARROW_END:r.center:this.TUBE_RADIUS}},{key:"getResidueRadius",value:function(e,t){var r=this.getResidueStartRadius(e);if(0===t)return r;var n=this.getResidueEndRadius(e);return 2===t?n:r.clone().lerp(n,t/2)}},{key:"calcStickRadius",value:function(e){return this.opts.radius}},{key:"getHeightSegmentsRatio",value:function(){return this.opts.heightSegmentsRatio}},{key:"getTension",value:function(){return this.opts.tension}},{key:"buildGeometry",value:function(e,t,r,n){var o=this.opts.radius,a=this.opts.depth;this.TUBE_RADIUS=new i.FM8(o,o),this.ARROW_END=new i.FM8(a,o);var s={},l=this.opts.ss;for(var c in l)s[c]={center:new i.FM8(a,l[c].width),start:new i.FM8(a,l[c].arrow)};return this.secCache=s,So.prototype.buildGeometry.call(this,e,t,r,n)}}]),o}(So);Re(Mo,"id","CA"),Mo.prototype.id="CA",Mo.prototype.name="Cartoon",Mo.prototype.shortName="Cartoon",Mo.prototype.depGroups=["CartoonChains","NucleicSpheres","NucleicCylinders"];var No=pr.selectors;function Io(){return{wireframe:this.opts.wireframe,zClip:this.opts.zClip}}var Oo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;a(this,i),(t=n.call(this,e)).depGroups=t.depGroups.slice(0);for(var r=t.surfaceNames,o=t.depGroups,s=0,l=r.length;s<l;++s)o[o.length]=[r[s],Io];return t}return l(i,[{key:"calcAtomRadius",value:function(e){return e.element.radius}},{key:"getVisibilitySelector",value:function(){var e=null;if(""!==this.opts.subset){var t=No.parse(this.opts.subset);t.error||(e=t.selector)}return e}}]),i}(So);Oo.prototype.isSurface=!0,Oo.prototype.surfaceNames=[];var Lo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getSurfaceOpts",value:function(){return{useBeads:!1,isoValue:this.opts.isoValue,gaussLim:this.opts.gaussLim[this.settings.now.resolution],radScale:this.opts.scale,gridSpacing:this.opts.gridSpacing[this.settings.now.resolution],zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}}}]),i}(Oo);Re(Lo,"id","QS"),Lo.prototype.id="QS",Lo.prototype.name="Quick Surface",Lo.prototype.shortName="Quick Surf",Lo.prototype.surfaceNames=["QuickSurfGeo"];var Bo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return a(this,i),(r=n.call(this,t))._excludeProbe=e,r}return l(i,[{key:"calcAtomRadius",value:function(e){return e.element.radius}},{key:"getSurfaceOpts",value:function(){return{gridSpacing:this.opts.polyComplexity[this.settings.now.resolution],radScale:this._radScale,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector(),probeRadius:this.opts.probeRadius,excludeProbe:this._excludeProbe}}}]),i}(Oo);Bo.prototype.id="SU",Bo.prototype.name="Surface",Bo.prototype.shortName="Surface",Bo.prototype.surfaceNames=["SASSESSurfaceGeo"],Bo.prototype._radScale=1,Bo.prototype._excludeProbe=!1;var Do=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){return a(this,i),n.call(this,!1,e)}return l(i)}(Bo);Re(Do,"id","SA"),Do.prototype.id="SA",Do.prototype.name="Solvent Accessible Surface",Do.prototype.shortName="SAS";var zo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){return a(this,i),n.call(this,!0,e)}return l(i)}(Bo);Re(zo,"id","SE"),zo.prototype.id="SE",zo.prototype.name="Solvent Excluded Surface",zo.prototype.shortName="SES";var Fo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getSurfaceOpts",value:function(){return{probeRadius:this.opts.probeRadius,radScale:this.opts.polyComplexity[this.settings.now.resolution],scaleFactor:this.opts.polyComplexity[this.settings.now.resolution],gridSpacing:1/this.opts.polyComplexity[this.settings.now.resolution],isoValue:this.opts.isoValue,probePositions:this.opts.probePositions,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}}}]),i}(Oo);Re(Fo,"id","CS"),Fo.prototype.id="CS",Fo.prototype.name="Contact Surface",Fo.prototype.shortName="Contact Surf",Fo.prototype.isSurface=!0,Fo.prototype.surfaceNames=["ContactSurfaceGeo"];var Vo=function(e){h(o,e);var t,r,i=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return a(this,o),i.apply(this,arguments)}return l(o,[{key:"getTemplateOptions",value:function(){return this.opts.template}},{key:"getLabelOpts",value:function(){return(0,n.merge)(this.opts,{colors:!0,adjustColor:!0,transparent:!0})}}]),o}(So);Re(Vo,"id","TX"),Vo.prototype.id="TX",Vo.prototype.name="Text mode",Vo.prototype.shortName="Text",Vo.prototype.depGroups=["TextLabelsGeo"];var Uo=new Nr([Co,Ao,Eo,ko,Po,To,Mo,Lo,Do,zo,Fo,Vo]);function Go(e,t,r){return e<=r?e<0?0:e:r}var jo=function(){function e(t,r){a(this,e),this.name=t||"Custom",this.id=r||"CP"}return l(e,[{key:"getElementColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.elementColors[e];return void 0!==r||t?r:this.defaultElementColor}},{key:"getResidueColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.residueColors[e];return void 0!==r||t?r:this.defaultResidueColor}},{key:"getChainColor",value:function(e){var t=e.charCodeAt(0);return t=(31&(t<0?0:t>=256?t-256:t))%this.chainColors.length,this.chainColors[t]}},{key:"getSecondaryColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.secondaryColors[e];return void 0!==r||t?r:this.defaultSecondaryColor}},{key:"getSequentialColor",value:function(e){var t=this.colors,r=t.length;return e<0?t[e%r+r]:t[e%r]}},{key:"getGradientColor",value:function(e,t){var r=this.gradients[t];if(!r)return this.defaultNamedColor;var n,i,o,a,s=r.length,l=e*(s-1),c=Math.floor(l),u=Go(c+1,0,s-1);return(a=1-(o=l-(c=Go(c,0,s-1))))*((n=r[c])>>16&255)+o*((i=r[u])>>16&255)<<16|a*(n>>8&255)+o*(i>>8&255)<<8|a*(255&n)+o*(255&i)}},{key:"getNamedColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.namedColors[e];return void 0!==r||t?r:this.defaultNamedColor}}]),e}();(0,n.assign)(jo.prototype,{colors:[16777215,16711680,65280,255,8421504],minRangeColor:0,midRangeColor:8355711,maxRangeColor:16777215,defaultElementColor:16777215,elementColors:{},defaultResidueColor:16777215,residueColors:{},chainColors:[16777215],defaultSecondaryColor:16777215,secondaryColors:{},defaultGradientColor:0,defaultNamedColor:16777215,namedColorsArray:[["indianred",13458524],["lightcoral",15761536],["salmon",16416882],["darksalmon",15308410],["lightsalmon",16752762],["crimson",14423100],["red",16711680],["firebrick",11674146],["darkred",9109504],["pink",16761035],["lightpink",16758465],["hotpink",16738740],["deeppink",16716947],["mediumvioletred",13047173],["palevioletred",14381203],["coral",16744272],["tomato",16737095],["orangered",16729344],["darkorange",16747520],["orange",16753920],["gold",16766720],["yellow",16776960],["lightyellow",16777184],["lemonchiffon",16775885],["lightgoldenrodyellow",16448210],["papayawhip",16773077],["moccasin",16770229],["peachpuff",16767673],["palegoldenrod",15657130],["khaki",15787660],["darkkhaki",12433259],["lavender",15132410],["thistle",14204888],["plum",14524637],["violet",15631086],["orchid",14315734],["fuchsia",16711935],["magenta",16711935],["mediumorchid",12211667],["mediumpurple",9662683],["rebeccapurple",6697881],["blueviolet",9055202],["darkviolet",9699539],["darkorchid",10040012],["darkmagenta",9109643],["purple",8388736],["indigo",4915330],["slateblue",6970061],["mediumslateblue",8087790],["darkslateblue",4734347],["greenyellow",11403055],["chartreuse",8388352],["lawngreen",8190976],["lime",65280],["limegreen",3329330],["palegreen",10025880],["lightgreen",9498256],["mediumspringgreen",64154],["springgreen",65407],["mediumseagreen",3978097],["seagreen",3050327],["forestgreen",2263842],["green",32768],["darkgreen",25600],["yellowgreen",10145074],["olivedrab",7048739],["olive",8421376],["darkolivegreen",5597999],["mediumaquamarine",6737322],["darkseagreen",9419919],["lightseagreen",2142890],["darkcyan",35723],["teal",32896],["aqua",65535],["cyan",65535],["lightcyan",14745599],["paleturquoise",11529966],["aquamarine",8388564],["turquoise",4251856],["mediumturquoise",4772300],["darkturquoise",52945],["cadetblue",6266528],["steelblue",4620980],["lightsteelblue",11584734],["powderblue",11591910],["lightblue",11393254],["skyblue",8900331],["lightskyblue",8900346],["deepskyblue",49151],["dodgerblue",2003199],["cornflowerblue",6591981],["royalblue",4286945],["blue",255],["mediumblue",205],["darkblue",139],["navy",128],["midnightblue",1644912],["cornsilk",16775388],["blanchedalmond",16772045],["bisque",16770244],["navajowhite",16768685],["wheat",16113331],["burlywood",14596231],["tan",13808780],["rosybrown",12357519],["sandybrown",16032864],["goldenrod",14329120],["darkgoldenrod",12092939],["peru",13468991],["chocolate",13789470],["saddlebrown",9127187],["sienna",10506797],["brown",10824234],["maroon",8388608],["white",16777215],["snow",16775930],["honeydew",15794160],["mintcream",16121850],["azure",15794175],["aliceblue",15792383],["ghostwhite",16316671],["whitesmoke",16119285],["seashell",16774638],["beige",16119260],["oldlace",16643558],["floralwhite",16775920],["ivory",16777200],["antiquewhite",16444375],["linen",16445670],["lavenderblush",16773365],["mistyrose",16770273],["gainsboro",14474460],["lightgray",13882323],["silver",12632256],["darkgray",11119017],["gray",8421504],["dimgray",6908265],["lightslategray",7833753],["slategray",7372944],["darkslategray",3100495],["black",0]],namedColors:{},gradients:{rainbow:[255,65535,65280,16776960,16711680],temp:[255,32767,16777215,16744192,16711680],hot:[16777215,16744192,16711680],cold:[16777215,32767,255],"blue-red":[255,16777215,16711680],reds:[16777215,16711680],blues:[16777215,255]}});for(var Ho=jo.prototype,Wo=Ho.namedColorsArray,Yo=Ho.namedColors,Xo=0,qo=Wo.length;Xo<qo;++Xo){var $o=v(Wo[Xo],2),Zo=$o[0],Ko=$o[1];Yo[Zo]=Ko}var Qo,Jo=new jo("CPK","CP");Jo.elementColors={H:16777215,C:2105376,N:2121983,O:15605776,F:65280,P:8397055,S:16776960,CL:47872,FE:13684944,CO:13684944,NI:13684944,CU:13684944,BR:34816,I:21760};var ea=new jo("Jmol","JM");ea.colors=[255,22015,44031,65535,65451,65365,65280,5635840,11271936,16776960,16755456,16733440,16711680,16711765,16711851,16711935,11206911,5570815],ea.elementColors={H:16777215,D:16777152,T:16777120,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:4366e3,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998},ea.defaultResidueColor=12492910,ea.residueColors={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,A:10526975,C:16747595,G:16740464,I:8454143,T:10551200,U:16744576,DA:10526975,DC:16747595,DG:16740464,DI:8454143,DT:10551200,DU:16744576,"+A":10526975,"+C":16747595,"+G":16740464,"+I":8454143,"+T":10551200,"+U":16744576},ea.chainColors=[4294967295,4290826495,4289789872,4294951112,4294967168,4294951167,4289786096,4294955120,4293951616,4294303411,4278239231,4291648604,4284927402,4288335154,4293821166,4278243025,4278255487,4282168177,4278190219,4290623339,4278215680,4286578688,4286611456,4286578816,4278222976,4290283019,4289864226];var ta,ra=Ue.Type;ea.secondaryColors=(Re(Qo={},ra.HELIX_ALPHA,16711808),Re(Qo,ra.HELIX_PI,6291584),Re(Qo,ra.HELIX_310,10485888),Re(Qo,ra.STRAND,16762880),Re(Qo,ra.TURN,6324479),Re(Qo,"dna",11403518),Re(Qo,"rna",16580962),Qo);var na=new jo("VMD","VM");na.colors=[255,16711680,6316128,16744448,16776960,8421427,10066329,65280,16777215,16751001,4243648,10879142,8447590,15099571,8408320,8421568],na.defaultElementColor=8408320,na.elementColors={H:16777215,C:4243391,N:255,O:16711680,P:8421427,S:16776960},na.defaultResidueColor=4243648,na.residueColors={ALA:255,ARG:16777215,ASN:8421427,ASP:16711680,CYS:16776960,GLN:16744448,GLU:16751001,GLY:16777215,HIS:4243648,ILE:65280,LEU:16751001,LYS:4243648,MET:16776960,PHE:10879142,PRO:8408064,SER:16776960,THR:15099571,TRP:10066329,TYR:65280,VAL:8421427,A:255,C:16744448,G:16776960,T:10879142,U:65280,DA:255,DC:16744448,DG:16776960,DT:10879142,DU:65280,"+A":255,"+C":16744448,"+G":16776960,"+T":10879142,"+U":65280,WAT:4243648,H2O:4243648,HOH:4243648},na.chainColors=[16777215].concat(na.colors);var ia=Ue.Type;na.secondaryColors=(Re(ta={},ia.HELIX_ALPHA,10879142),Re(ta,ia.HELIX_310,255),Re(ta,ia.HELIX_PI,16711680),Re(ta,ia.STRAND,16776960),Re(ta,ia.BRIDGE,8421427),Re(ta,ia.TURN,4243648),ta);var oa=new Nr([Jo,ea,na]),aa=function(){function e(t){if(a(this,e),this.constructor===e)throw new Error("Can not instantiate abstract class!");this.opts=(0,n.merge)($.deriveDeep(J.now.colorers[this.id],!0),t),this.palette=oa.first}return l(e,[{key:"identify",value:function(){var e=$.objectsDiff(this.opts,J.now.colorers[this.id]);return(0,n.isEmpty)(e)?this.id:[this.id,e]}}]),e}();aa.prototype.id="__";var sa=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){var r=e.element.name;return"C"===r&&this.opts.carbon>=0?this.opts.carbon:this.palette.getElementColor(r)}},{key:"getResidueColor",value:function(e,t){return this.palette.defaultResidueColor}}]),i}(aa);Re(sa,"id","EL"),sa.prototype.id="EL",sa.prototype.name="Element",sa.prototype.shortName="Element";var la=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){return this.palette.getResidueColor(e._type._name)}}]),i}(aa);Re(la,"id","RT"),la.prototype.id="RT",la.prototype.name="Residue Type",la.prototype.shortName="Residue";var ca=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){var r=e._chain;if(r.minSequence===Number.POSITIVE_INFINITY&&r.maxSequence===Number.NEGATIVE_INFINITY)return this.palette.defaultNamedColor;var n=r.minSequence,i=r.maxSequence>n?r.maxSequence:n+1;return this.palette.getGradientColor((e._sequence-n)/(i-n),this.opts.gradient)}}]),i}(aa);Re(ca,"id","SQ"),ca.prototype.id="SQ",ca.prototype.name="Sequence",ca.prototype.shortName="Sequence";var ua=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){return this.palette.getChainColor(e.getChain()._name)}}]),i}(aa);Re(ua,"id","CH"),ua.prototype.id="CH",ua.prototype.name="Chain",ua.prototype.shortName="Chain";var ha=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){if(e._type.flags&Be.Flags.DNA)return this.palette.getSecondaryColor("dna");if(e._type.flags&Be.Flags.RNA)return this.palette.getSecondaryColor("rna");var r=e.getSecondary();if(r){var n=this.palette.getSecondaryColor(r.type,!0);return void 0===n&&(n=this.palette.getSecondaryColor(r.generic)),n}return this.palette.defaultSecondaryColor}}]),i}(aa);Re(ha,"id","SS"),ha.prototype.id="SS",ha.prototype.name="Secondary Structure",ha.prototype.shortName="Structure";var fa=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.opts.color}},{key:"getResidueColor",value:function(e,t){return this.opts.color}}]),i}(aa);Re(fa,"id","UN"),fa.prototype.id="UN",fa.prototype.name="Uniform",fa.prototype.shortName="Uniform";var da=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;a(this,i),t=n.call(this,e);var r=St.parse(t.opts.subset);return t._subsetCached=r.error?St.none():r.selector,t}return l(i,[{key:"getAtomColor",value:function(e,t){return this._subsetCached.includesAtom(e)?this.opts.color:this.opts.baseColor}},{key:"getResidueColor",value:function(e,t){for(var r=this._subsetCached,n=e._atoms,i=0,o=n.length;i<o;++i)if(!r.includesAtom(n[i]))return this.opts.baseColor;return this.opts.color}}]),i}(aa);Re(da,"id","CO"),da.prototype.id="CO",da.prototype.name="Conditional",da.prototype.shortName="Conditional";var pa=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.palette.getChainColor(String.fromCharCode(e.location))}},{key:"getResidueColor",value:function(e,t){return this.palette.defaultResidueColor}}]),i}(aa);Re(pa,"id","CF"),pa.prototype.id="CF",pa.prototype.name="Conformation",pa.prototype.shortName="Conformation";var ma=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){var r=this.opts,n=1;return e.temperature&&r?(n=r.min===r.max?e.temperature>r.max?1:0:(e.temperature-r.min)/(r.max-r.min),this.palette.getGradientColor(n,r.gradient)):this.palette.defaultGradientColor}},{key:"getResidueColor",value:function(e,t){var r=this.opts;if(!r)return this.palette.defaultGradientColor;if(e.temperature){var n;return n=r.min===r.max?e.temperature>r.max?1:0:(e.temperature-r.min)/(r.max-r.min),this.palette.getGradientColor(n,r.gradient)}return this.palette.defaultGradientColor}}]),i}(aa);Re(ma,"id","TM"),ma.prototype.id="TM",ma.prototype.name="Temperature",ma.prototype.shortName="Temperature";var va=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"_getColorByOccupancy",value:function(e,t){if(void 0!==e){var r=1-e;return this.palette.getGradientColor(r,t.gradient)}return this.palette.defaultGradientColor}},{key:"getAtomColor",value:function(e,t){var r=this.opts;return this._getColorByOccupancy(e.occupancy,r)}},{key:"getResidueColor",value:function(e,t){var r=this.opts;return this._getColorByOccupancy(e.occupancy,r)}}]),i}(aa);Re(va,"id","OC"),va.prototype.id="OC",va.prototype.name="Occupancy",va.prototype.shortName="Occupancy";var ya=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){var r=this.palette.defaultResidueColor;return void 0!==e._type.hydrophobicity&&(r=this.palette.getGradientColor((e._type.hydrophobicity- -4.5)/9,this.opts.gradient)),r}}]),i}(aa);Re(ya,"id","HY"),ya.prototype.id="HY",ya.prototype.name="Hydrophobicity",ya.prototype.shortName="Hydrophobicity";var _a=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){var r=e._molecule,n=t.getMoleculeCount();return n>1?this.palette.getGradientColor((r.index-1)/(n-1),this.opts.gradient):this.palette.getGradientColor(0,this.opts.gradient)}}]),i}(aa);Re(_a,"id","MO"),_a.prototype.id="MO",_a.prototype.name="Molecule",_a.prototype.shortName="Molecule";var ga=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){var r,n,i=this.opts.color,o=(r=i,(n=this.opts.factor)*(r>>16&255)<<16|n*(r>>8&255)<<8|n*(255&r));return e.flags&Ce.Flags.CARBON?i:o}},{key:"getResidueColor",value:function(e,t){return this.opts.color}}]),i}(aa);Re(ga,"id","CB"),ga.prototype.id="CB",ga.prototype.name="Carbon",ga.prototype.shortName="Carbon";var xa=new Nr([sa,la,ca,ua,ha,fa,da,pa,ma,va,ya,_a,ga]);function ba(e){return new i.Ilk(e,e,e)}var wa=new Nr([{id:"DF",name:"Diffuse",shortName:"Diffuse",uberOptions:{diffuse:ba(1),specular:ba(0),shininess:1,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!1}},{id:"SF",name:"Soft Plastic",shortName:"Soft",uberOptions:{diffuse:ba(1),specular:ba(.1),shininess:30,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!1}},{id:"PL",name:"Glossy Plastic",shortName:"Glossy",uberOptions:{diffuse:ba(.56),specular:ba(.28),shininess:100,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!1}},{id:"ME",name:"Metal",shortName:"Metal",uberOptions:{diffuse:ba(.56),specular:ba(.55),shininess:30,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!1}},{id:"TR",name:"Transparent",shortName:"Transparent",uberOptions:{diffuse:ba(1),specular:ba(0),shininess:1,opacity:.5},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!0,toonShading:!1}},{id:"GL",name:"Glass",shortName:"Glass",uberOptions:{diffuse:ba(.5),specular:ba(.65),shininess:100,opacity:.5},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!0,toonShading:!1}},{id:"BA",name:"Backdrop",shortName:"Backdrop",uberOptions:{diffuse:ba(1),specular:ba(0),shininess:1,opacity:1},values:{lights:!1,fog:!1,depthWrite:!1,transparent:!1,toonShading:!1}},{id:"TN",name:"Toon",shortName:"Toon",uberOptions:{diffuse:ba(1),specular:ba(0),shininess:1,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!0}},{id:"FL",name:"Flat",shortName:"Flat",uberOptions:{diffuse:ba(1),specular:ba(0),shininess:0,opacity:1},values:{lights:!1,fog:!0,depthWrite:!0,transparent:!1}}]);function Sa(e,t,r){var n=e.material.createInstance();n.setValues(t);var i=new e.constructor(e.geometry,n);return i.material.needsUpdate=!0,i.applyMatrix4(e.matrix),i.layers.set(r),i}function Ra(e,t,r){for(var n=function(e,t){var r=[];return e.traverse((function(e){for(var n=0;n<t.length;n++)if(e instanceof t[n]){r[r.length]=e;break}})),r}(e,t),i=0,o=n.length;i<o;++i){var a=n[i];a.parent&&r(a)}}var Ca,Aa=(Ca={prepassTransparancy:!0,fakeOpacity:!1,transparent:!1,colorFromDepth:!1,lights:!1,shadowmap:!1,fog:!1},function(e,t){t instanceof ui&&Ra(e,[i.Kj0,i.ejS],(function(e){e.material.setValues({prepassTransparancy:!1,fakeOpacity:!1}),e.material.needsUpdate=!0,e.layers.set(Er.LAYERS.TRANSPARENT);var t=Sa(e,Ca,Er.LAYERS.PREPASS_TRANSPARENT);e.parent.add(t)}))}),Ea=function(){var e={colorFromPos:!0,transparent:!1,colorFromDepth:!1,lights:!1,shadowmap:!1,fog:!1,overrideColor:!1,fogTransparent:!1,attrColor:!1,attrColor2:!1,attrAlphaColor:!1,fakeOpacity:!1};return function(t,r){r instanceof ui&&Ra(t,[i.Kj0,i.ejS],(function(t){var r=Sa(t,e,Er.LAYERS.COLOR_FROM_POSITION);t.parent.add(r)}))}}(),ka=function(){var e={colorFromDepth:!0,orthoCam:!0,lights:!1,shadowmap:!1,fog:!1};return function(t,r){r instanceof ui&&Ra(t,[i.Kj0,i.ejS],(function(t){if(!t.receiveShadow&&t.material.shadowmap&&t.material.setValues({shadowmap:!1}),t.material.lights&&t.castShadow&&Er.belongToSelectLayers(t)){var r=Sa(t,e,Er.LAYERS.SHADOWMAP);r.isShadowmapMesh=!0,t.parent.add(r)}}))}}();function Pa(e,t){!function e(r){r instanceof i.Kj0&&t(r);for(var n=0,o=r.children.length;n<o;n++)e(r.children[n])}(e)}var Ta={applyTransformsToMeshes:function(e,t){var r=t.length;r<1||Ra(e,[i.Kj0,i.ejS,i.x12],(function(e){e.applyMatrix4(t[0]);for(var n=1;n<r;++n){var i=new e.constructor(e.geometry,e.material);e.parent.add(i),i.applyMatrix4(t[n])}}))},processTransparentMaterial:Aa,processColFromPosMaterial:Ea,createShadowmapMaterial:ka,removeShadowmapMaterial:function(e,t){t instanceof ui&&Ra(e,[i.Kj0,i.ejS],(function(e){e.isShadowmapMesh&&e.parent.remove(e)}))},forEachMeshInGroup:Pa,countTriangles:function(e){var t=0;return Pa(e,(function(e){t+=function(e){var t=e.geometry;if(t instanceof i.L5s){var r=t.attributes;for(var n in r)if(r.hasOwnProperty(n)&&r[n]instanceof i.lb7){var o=r[n];return(t.index?t.index.array.length/3:0)*o.array.length/o.itemSize}return 0}return t instanceof i.u9r?t.index?t.index.array.length/3:0:t.faces?t.faces.length:0}(e)})),t}},Ma=pr.selectors,Na=function(){function e(t,r,n,i){a(this,e);var o={clipPlane:J.now.draft.clipPlane,fogTransparent:J.now.bg.transparent,shadowmap:J.now.shadow.on,shadowmapType:J.now.shadow.type};this.index=t,this.mode=r,this.colorer=n,this.selector=i,this.selectorString="",this.count=0,this.material=new ui,this.material.setValues(o),this.material.setUberOptions({fogAlpha:J.now.fogAlpha}),this.materialPreset=wa.first,this.needsRebuild=!0,this.visible=!0,this.setMode(r)}return l(e,[{key:"markAtoms",value:function(e){return this.count=e.markAtoms(this.selector,1<<this.index),this.needsRebuild=!0,this.count}},{key:"unmarkAtoms",value:function(e){e.clearAtomBits(1<<this.index),this.count=0}},{key:"setMode",value:function(e){this.mode=e}},{key:"setMaterialPreset",value:function(e){this.materialPreset=e,this.material.setUberOptions(e.uberOptions),this.material.setValues(e.values)}},{key:"reset",value:function(){this.geo=null,this.selectionGeo=null}},{key:"buildGeometry",value:function(e){return this.reset(),this.needsRebuild=!1,J.now.ao&&this.material.setValues({normalsToGBuffer:J.now.ao}),this.geo=this.mode.buildGeometry(e,this.colorer,1<<this.index,this.material),this.material.uberOptions.opacity<.99&&"prepass"===J.now.transparency&&Ta.processTransparentMaterial(this.geo,this.material),this.geo.visible=this.visible,Er.processObjRenderOrder(this.geo,this.materialPreset.id),Ta.processColFromPosMaterial(this.geo,this.material),J.now.shadow.on&&Ta.createShadowmapMaterial(this.geo,this.material),this.geo}},{key:"buildSelectionGeometry",value:function(e){var t=null;if(this.geo&&"getSubset"in this.geo){var r=this.geo.getSubset(e);if(r&&r.length>0){(t=new i.ZAu).matrixAutoUpdate=!1,t.matrix=this.geo.matrix;for(var n=0;n<r.length;n++){var o=r[n];t.add(o)}}}return t&&(t.visible=this.visible),this.selectionGeo=t,this.selectionGeo}},{key:"compare",value:function(e){var t={},r=String(this.selector);e&&r.valueOf()===String(e.selector).valueOf()||(t.selector=r);var n=this.mode.identify();e&&!Array.isArray(n)&&n===e.mode||(t.mode=n);var i=this.colorer.identify();return e&&!Array.isArray(i)&&i===e.colorer||(t.colorer=i),e&&this.materialPreset.id===e.material||(t.material=this.materialPreset.id),t}},{key:"change",value:function(e,t,r,i){var o={};if(e.selector){var a=Ma.parse(e.selector).selector,s=String(a);this.selectorString!==s&&(o.selector=s,this.selectorString=s,this.selector=a,this.markAtoms(t))}if(e.mode){var l=e.mode;(0,n.isEqual)(this.mode.identify(),l)||(o.mode=l,this.setMode(r))}if(e.colorer){var c=e.colorer;(0,n.isEqual)(this.colorer.identify(),c)||(o.colorer=c,this.colorer=i)}if(e.material){var u=e.material;(0,n.isEqual)(this.materialPreset.id,u)||(o.material=u,this.setMaterialPreset(wa.get(e.material)))}return o}},{key:"show",value:function(e){this.visible=e,this.geo&&(this.geo.visible=e),this.selectionGeo&&(this.selectionGeo.visible=e)}}]),e}();function Ia(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}function Oa(e,t,r){var n=e.children;if(n)for(var i=0,o=n.length;i<o;++i){var a=n[i];a._component===t&&r(a),a instanceof Er.RCGroup&&Oa(a,t,r)}}function La(){}var Ba=function(e){h(r,e);var t=Ia(r);function r(e){var n;return a(this,r),(n=t.call(this))._complexVisual=e,n._inProgress=!1,n}return l(r,[{key:"begin",value:function(){var e=this._complexVisual.getComplex();this._componentTransforms=[];for(var t=0;t<e._components.length;++t){var r=e._components[t];this._componentTransforms[r._index]=new i.Tme}return this._inProgress=!0,!0}},{key:"apply",value:function(){if(this._inProgress){for(var e=this._complexVisual.getComplex(),t=0;t<e._components.length;++t)this._bakeComponentTransform(e._components[t]);e.onAtomPositionChanged(),this._resetComponentTransform(),this._complexVisual.finalizeEdit()}}},{key:"discard",value:function(){this._inProgress&&(this._resetComponentTransform(),this._complexVisual.finalizeEdit())}},{key:"getAltObj",value:function(){var e={objects:[],pivot:new i.Pa4(0,0,0)},t=this._complexVisual,r=t.getSelectedComponent();if(null===r)return e;var n,o,a,s,l=this._complexVisual.getSelectionGeo(),c=1<<t.getSelectionBit();for(Oa(t,r,(function(t){e.objects.push(t)})),n=0;n<l.children.length;++n)for(a=l.children[n],o=0;o<a.children.length;++o)(s=a.children[o]).hasOwnProperty("_component")&&s._component===r&&e.objects.push(s);e.objects.push(this._componentTransforms[r._index]);var u=new i.Pa4(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),h=new i.Pa4(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return r.forEachResidue((function(e){var t=e._atoms;for(o=0;o<t.length;++o)t[o].mask&c&&(u.min(t[o].position),h.max(t[o].position))})),e.pivot.lerpVectors(u,h,.5),e}},{key:"_bakeComponentTransform",value:function(e){var t=this._componentTransforms[e._index];!t||0===t.position.x&&0===t.position.y&&0===t.position.z&&0===t.quaternion.x&&0===t.quaternion.y&&0===t.quaternion.z&&1===t.quaternion.w||(t.updateMatrix(),e.forEachResidue((function(e){for(var r=e._atoms,n=0;n<r.length;++n)r[n].position.applyMatrix4(t.matrix)})))}},{key:"_resetComponentTransform",value:function(){var e,t,r,n,i=this._complexVisual,o=this._complexVisual.getSelectionGeo();for(e=0;e<this._componentTransforms.length;++e)(n=this._componentTransforms[e]).position.set(0,0,0),n.quaternion.set(0,0,0,1);for(e=0;e<i.children.length;++e)for(r=i.children[e],t=0;t<r.children.length;++t)(n=r.children[t]).hasOwnProperty("_component")&&(n.position.set(0,0,0),n.quaternion.set(0,0,0,1));for(e=0;e<o.children.length;++e)for(r=o.children[e],t=0;t<r.children.length;++t)(n=r.children[t]).hasOwnProperty("_component")&&(n.position.set(0,0,0),n.quaternion.set(0,0,0,1))}}]),r}(La),Da=function(e){h(r,e);var t=Ia(r);function r(e){var n;return a(this,r),(n=t.call(this))._complexVisual=e,n._inProgress=!1,n}return l(r,[{key:"begin",value:function(){var e=this._complexVisual,t=this._complexVisual.getSelectionGeo(),r=this._getSelectionBorderAtoms();if(r.length<1||r.length>2)return B.error("Can only edit fragments with one or two bound atoms."),!1;this._fragmentBoundAtoms=r;var n=1<<e.getSelectionBit();e.disableSubset(n,!0);for(var o=0;o<t.children.length;++o)t.children[o].visible=!1;var a=r[0].position.clone();2===r.length&&a.lerp(r[1].position,.5),this._fragmentGeo=new i.ZAu,e.add(this._fragmentGeo),this._fragmentGeo.position.copy(a),this._fragmentSelectionGeo=new i.ZAu,t.add(this._fragmentSelectionGeo),this._fragmentSelectionGeo.position.copy(a);var s=a.clone();s.negate();for(var l=0;l<e.children.length;++l){var c=e.children[l];if("getSubset"in c){var u=new i.ZAu;this._fragmentGeo.add(u);var h=new i.ZAu;this._fragmentSelectionGeo.add(h);for(var f=c.getSubset(n,!0),d=0;d<f.length;d++){var p=f[d];u.add(p),p.position.copy(s)}for(var m=c.getSubset(n,!0),v=0;v<m.length;v++){var y=m[v];h.add(y),y.position.copy(s)}}}return Er.applySelectionMaterial(this._fragmentSelectionGeo),this._inProgress=!0,!0}},{key:"apply",value:function(){if(this._inProgress){var e=this._complexVisual,t=e.getSelectionBit(),r=this._fragmentGeo.position,n=this._fragmentGeo.matrix.clone();n.multiply((new i.yGw).makeTranslation(-r.x,-r.y,-r.z)),this._bakeAtomTransform(n,1<<t),e.enableSubset(1<<t,!0),e.getComplex().onAtomPositionChanged(),e.finalizeEdit()}}},{key:"discard",value:function(){if(this._inProgress){var e=this._complexVisual,t=this._complexVisual.getSelectionGeo();this._fragmentGeo.parent.remove(this._fragmentGeo),e.enableSubset(1<<e.getSelectionBit(),!0);for(var r=0;r<t.children.length;++r){var n=t.children[r];n.visible?t.remove(n):n.visible=!0}e.finalizeEdit()}}},{key:"isFreeRotationAllowed",value:function(){return this._fragmentBoundAtoms.length<2}},{key:"getAltObj",value:function(){var e={objects:[],pivot:new i.Pa4(0,0,0)};e.objects.push(this._fragmentGeo,this._fragmentSelectionGeo);var t=this._fragmentBoundAtoms;if(1===t.length){if(1===t[0].bonds.length){var r=t[0].bonds[0];e.axis=(new i.Pa4).subVectors(r._right.position,r._left.position),e.axis.normalize(),e.axis.transformDirection(this._complexVisual.matrixWorld)}}else 2===t.length&&(e.axis=(new i.Pa4).subVectors(t[1].position,t[0].position),e.axis.normalize(),e.axis.transformDirection(this._complexVisual.matrixWorld));return e}},{key:"_getSelectionBorderAtoms",value:function(){var e=this._complexVisual.getComplex(),t=1<<this._complexVisual.getSelectionBit(),r={};e.forEachBond((function(e){e._left.mask&t?0==(e._right.mask&t)&&(r[e._left.index]=1):e._right.mask&t&&(r[e._right.index]=1)}));for(var n=[],i=Object.keys(r),o=0,a=i.length;o<a;++o){var s=i[o];n.push(e._atoms[s])}return n}},{key:"_bakeAtomTransform",value:function(e,t){this._complexVisual.getComplex().forEachAtom((function(r){r.mask&t&&r.position.applyMatrix4(e)}))}}]),r}(La),za={ComponentEditor:Ba,FragmentEditor:Da};var Fa=pr.selectors;function Va(e,t){Array.isArray(t)||(t=[t]);var r=v(t,2),n=r[0],i=r[1];return new(e.get(n)||e.first)(i)}var Ua=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e,t){var r;return a(this,s),(r=o.call(this,e,t))._complex=t,r._reprList=[],r._repr=null,r._reprListChanged=!0,r._selectionBit=0,r._reprUsedBits=0,r._selectionCount=0,r._selectionGeometry=new i.ZAu,r}return l(s,[{key:"getBoundaries",value:function(){return this._complex.getBoundaries()}},{key:"release",value:function(){this._selectionGeometry.parent&&this._selectionGeometry.remove(this._selectionGeometry),Pr.prototype.release.call(this)}},{key:"getComplex",value:function(){return this._complex}},{key:"getSelectionCount",value:function(){return this._selectionCount}},{key:"getSelectionGeo",value:function(){return this._selectionGeometry}},{key:"getSelectionBit",value:function(){return this._selectionBit}},{key:"getEditor",value:function(){return this._editor}},{key:"resetReps",value:function(e){this._complex&&this._complex.clearAtomBits(-1),this._reprListChanged=!0,this._reprUsedBits=0,this._reprList.length=e.length;for(var t=0,r=e.length;t<r;++t){var n=e[t],i=void 0,o=void 0;"string"==typeof n.selector?(o=n.selector,i=Fa.parse(o).selector):void 0===n.selector?(o=J.now.presets.default[0].selector,i=Fa.parse(o).selector):o=(i=n.selector).toString();var a=Va(Uo,n.mode),s=Va(xa,n.colorer),l=wa.get(n.material)||wa.first;this._reprList[t]=new Na(t,a,s,i),this._reprList[t].setMaterialPreset(l),this._reprList[t].selectorString=o,this._complex&&this._complex.markAtoms(i,1<<t),this._reprUsedBits|=1<<t}this._repr=e.length>0?this._reprList[0]:null,this._selectionBit=e.length,this._reprUsedBits|=1<<this._selectionBit,this._selectionCount=0,this._complex&&this._complex.update()}},{key:"repCount",value:function(){return this._reprList.length}},{key:"repCurrent",value:function(e){return e>=0&&e<this._reprList.length?this._repr=this._reprList[e]:e=this._reprList.indexOf(this._repr),e}},{key:"rep",value:function(e,t){if(!t&&(void 0===e||e instanceof Object)&&(t=e,e=this.repCurrent()),e<0||e>this._reprList.length)return B.error("Rep ".concat(e," does not exist!")),null;if(e===this._reprList.length){var r=this.repAdd(t);return B.warn("Rep ".concat(e," does not exist! New representation was created.")),{desc:r.desc,index:e,status:"created"}}var i=this._reprList[e],o={selector:i.selectorString,mode:i.mode.identify(),colorer:i.colorer.identify(),material:i.materialPreset.id};if(t){var a=i.change(t,this._complex,Va(Uo,t.mode),Va(xa,t.colorer));if(!(0,n.isEmpty)(a)){for(var s in i.needsRebuild=!0,a)a.hasOwnProperty(s)&&(o[s]=a[s],B.debug("rep[".concat(e,"].").concat(s," changed to ").concat(a[s])));return a.mode&&i.mode.isSurface&&("ultra"===J.now.resolution||"high"===J.now.resolution)&&(B.report('Surface resolution was changed to "medium" to avoid hang-ups.'),J.set("resolution","medium")),{desc:o,index:e,status:"changed"}}}return{desc:o,index:e,status:""}}},{key:"repGet",value:function(e){return(void 0===e||e instanceof Object)&&(e=this.repCurrent()),e<0||e>=this._reprList.length?null:this._reprList[e]}},{key:"_getFreeReprIdx",value:function(){for(var e=this._reprUsedBits,t=0;t<=s.NUM_REPRESENTATION_BITS;++t,e>>=1)if(0==(1&e))return t;return-1}},{key:"repAdd",value:function(e){if(this._reprList.length>=s.NUM_REPRESENTATION_BITS)return null;var t=this._getFreeReprIdx();if(t<0)return null;var r=this.buildSelectorFromMask(1<<this._selectionBit),i=J.now.presets.default[0],o=(0,n.merge)({selector:i.selector,mode:i.mode,colorer:i.colorer,material:i.material},e),a="string"==typeof o.selector?Fa.parse(o.selector).selector:o.selector,l=new Na(this._selectionBit,Va(Uo,o.mode),Va(xa,o.colorer),a);return l.selectorString=a.toString(),l.setMaterialPreset(wa.get(o.material)),l.markAtoms(this._complex),this._reprList.push(l),this._selectionBit=t,this._reprUsedBits|=1<<this._selectionBit,this._complex.markAtoms(r,1<<this._selectionBit),{desc:o,index:this._reprList.length-1}}},{key:"repRemove",value:function(e){void 0===e&&(e=this.repCurrent());var t=this._reprList.length;if(!(e<0||e>=t||t<=1)){var r=this._reprList[e];r.unmarkAtoms(this._complex),this._reprUsedBits&=~(1<<r.index),this._reprList.splice(e,1),r===this._repr&&(e=e<--t?e:t-1,this._repr=this._reprList[e]),this._reprListChanged=!0}}},{key:"repHide",value:function(e,t){void 0===t&&(t=!0),e<0||e>=this._reprList.length||this._reprList[e].show(!t)}},{key:"select",value:function(e,t){t?this._selectionCount+=this._complex.markAtomsAdditionally(e,1<<this._selectionBit):this._selectionCount=this._complex.markAtoms(e,1<<this._selectionBit),this._complex.updateStructuresMask(),this.rebuildSelectionGeometry()}},{key:"resetSelectionMask",value:function(){0!==this._selectionCount&&(this._selectionCount=0,this._complex&&this._complex.clearAtomBits(1<<this._selectionBit))}},{key:"updateSelectionMask",value:function(e){var t=this,r=e.atom,n=e.residue,i=e.chain,o=e.molecule,a=1<<this._selectionBit,s=~a;if(r)n=r.residue,i=n._chain,o=n._molecule,r.mask&a?(r.mask&=s,n._mask&=s,i._mask&=s,o&&(o.mask&=s),this._selectionCount--):(r.mask|=a,this._selectionCount++,n.collectMask(),i.collectMask(),o&&o.collectMask());else if(n)i=n._chain,o=n._molecule,n._mask&a?(n._mask&=s,i._mask&=s,n.forEachAtom((function(e){e.mask&a&&(e.mask&=s,t._selectionCount--)}))):(n._mask|=a,n.forEachAtom((function(e){e.mask&a||(e.mask|=a,t._selectionCount++)})),i.collectMask(),o&&o.collectMask());else if(i||o){var l=i||o;l._mask&a?(l._mask&=s,l.forEachResidue((function(e){e._mask&a&&(e._mask&=s,e.forEachAtom((function(e){e.mask&a&&(e.mask&=s,t._selectionCount--)})),e._mask&=s)}))):(l._mask|=a,l.forEachResidue((function(e){if(!(e._mask&a)){e._mask|=a,e.forEachAtom((function(e){e.mask&a||(e.mask|=a,t._selectionCount++)}));var r=i?e.getMolecule():e.getChain();r&&r.collectMask()}})))}else this.resetSelectionMask()}},{key:"expandSelection",value:function(){var e=this,t=1<<this._selectionBit,r=1<<31;this._complex.forEachBond((function(e){e._left.mask&t?0==(e._right.mask&t)&&(e._right.mask|=r):e._right.mask&t&&(e._left.mask|=r)})),this._complex.forEachAtom((function(n){n.mask&r&&(n.mask=2147483647&n.mask|t,++e._selectionCount)})),this._complex.updateStructuresMask()}},{key:"shrinkSelection",value:function(){var e=this,t=1<<this._selectionBit,r=1<<31;this._complex.forEachBond((function(e){e._left.mask&t?0==(e._right.mask&t)&&(e._left.mask|=r):e._right.mask&t&&(e._right.mask|=r)})),this._complex.forEachAtom((function(e){e.mask&t&&1===e.bonds.length&&(e.mask|=r)}));var n=~(t|r);this._complex.forEachAtom((function(t){t.mask&r&&(t.mask&=n,--e._selectionCount)})),this._complex.updateStructuresMask()}},{key:"getSelectedComponent",value:function(){var e=1<<this._selectionBit,t=null,r=!1;return this._complex.forEachAtom((function(n){n.mask&e&&(null===t?t=n.residue._component:t!==n.residue._component&&(r=!0))})),r?null:t}},{key:"getSelectionCenter",value:function(e,t,r){e.set(0,0,0);var n=0;return this._complex.forEachAtom((function(i){t(i,r)&&(e.add(i.position),n++)})),0!==n&&(e.divideScalar(n),e.applyMatrix4(this.matrix),!0)}},{key:"needsRebuild",value:function(){if(this._reprListChanged)return!0;for(var e=this._reprList,t=0,r=e.length;t<r;++t)if(e[t].needsRebuild)return!0;return!1}},{key:"rebuild",value:function(){var e=this;return Er.clearTree(this),new Promise((function(t){var r=e._complex;if(r){var n=!1;setTimeout((function(){console.time("build");for(var i=e._reprList,o=oa.get(J.now.palette)||oa.first,a=!1,s=0,l=i.length;s<l;++s){var c=i[s];if(c.colorer.palette=o,c.needsRebuild){c.reset();try{c.buildGeometry(r)}catch(e){if(!(e instanceof $.OutOfMemoryError))throw e;c.needsRebuild=!1,c.reset(),B.error("Not enough memory to build geometry for representation ".concat(c.index+1)),n=!0}}a=n||a||Er.groupHasGeometryToRender(c.geo),c.geo&&e.add(c.geo)}e._reprListChanged=!1,console.timeEnd("build"),t()}),10)}else t()}))}},{key:"setNeedsRebuild",value:function(){for(var e=this._reprList,t=0,r=e.length;t<r;++t)e[t].needsRebuild=!0}},{key:"rebuildSelectionGeometry",value:function(){var e=1<<this._selectionBit;Er.clearTree(this._selectionGeometry);for(var t=0,r=this._reprList.length;t<r;++t){var n=this._reprList[t].buildSelectionGeometry(e);if(n){this._selectionGeometry.add(n);for(var i=0;i<n.children.length;i++){var o=n.children[i];if(this._editor&&this._editor._componentTransforms){var a=this._editor._componentTransforms[o._component._index];a&&(o.position.copy(a.position),o.quaternion.copy(a.quaternion))}}Er.applySelectionMaterial(n)}}}},{key:"_buildSelectorFromSortedLists",value:function(e,t,r){var n=this._complex;function i(e){for(var t=[],r=0,n=NaN,i=NaN,o=0,a=e.length;o<a;++o){var s=e[o];s===i+1?i=s:(Number.isNaN(n)||(t[r++]=new Fa.Range(n,i)),n=i=s)}return Number.isNaN(n)||(t[r]=new Fa.Range(n,i)),t}var o=null;if(r.length===n._chains.length)o=Fa.all();else{var a;if(r.length>0&&(a=Fa.chain(r),o=o?Fa.or(o,a):a),Object.keys(t).length>0)for(var s in t)t.hasOwnProperty(s)&&(a=Fa.and(Fa.chain(s),Fa.residx(i(t[s]))),o=o?Fa.or(o,a):a);e.length>0&&(a=Fa.serial(i(e)),o=o?Fa.or(o,a):a),o||(o=Fa.none())}return o}},{key:"buildSelectorFromMask",value:function(e){var t=this._complex,r=[],n={},i=[];return t.forEachChain((function(t){t._mask&e&&r.push(t._name)})),t.forEachResidue((function(t){if(t._mask&e&&!(t._chain._mask&e)){var r=t._chain._name;r in n?n[r].push(t._index):n[r]=[t._index]}})),t.forEachAtom((function(t){t.mask&e&&!(t.residue._mask&e)&&i.push(t.serial)})),this._buildSelectorFromSortedLists(i,n,r)}},{key:"forSelectedResidues",value:function(e){var t=1<<this._selectionBit;this._complex.forEachResidue((function(r){r._mask&t&&e(r)}))}},{key:"beginComponentEdit",value:function(){if(this._editor)return null;var e=new za.ComponentEditor(this);return e.begin()?(this._editor=e,e):null}},{key:"beginFragmentEdit",value:function(){if(this._editor)return null;var e=new za.FragmentEditor(this);return e.begin()?(this._editor=e,e):null}},{key:"finalizeEdit",value:function(){this._editor=null}},{key:"setMaterialValues",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=0,o=this._reprList.length;n<o;++n){var a=this._reprList[n];a.material.setValues(e),t&&a.geo.traverse((function(t){t instanceof i.Kj0&&(t.material.setValues(e),void 0!==r&&r(t),t.material.needsUpdate=!0)}))}}},{key:"setUberOptions",value:function(e){for(var t=0,r=this._reprList.length;t<r;++t)this._reprList[t].material.setUberOptions(e)}},{key:"within",value:function(e,t){var r=this._complex.getVoxelWorld();if(null===r)return!1;var n=1<<this._selectionBit;return this._complex.markAtoms(e,n),r&&r.forEachAtomWithinDistFromMasked(this._complex,n,Number(t),(function(e){e.mask|=n})),this._selectionCount=this._complex.countAtomsByMask(n),this._complex.updateStructuresMask(),this.buildSelectorFromMask(n)}}]),s}(Pr);function Ga(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}Ua.NUM_REPRESENTATION_BITS=30;var ja=i.rDY.merge([{volumeDim:{type:"v3",value:new i.Pa4(512,512,512)},tileTex:{type:"t",value:null},tileTexSize:{type:"v2",value:new i.FM8(512,512)},tileStride:{type:"v2",value:new i.FM8(512,512)},boxAngles:{type:"v3",value:new i.Pa4(1,1,1)},delta:{type:"v3",value:new i.Pa4(0,0,0)},_isoLevel0:{type:"v2",value:new i.Pa4(.5,.75,1)},_flipV:{type:"f",value:0},_BFLeft:{type:"t",value:null},_BFRight:{type:"t",value:null},_FFLeft:{type:"t",value:null},_FFRight:{type:"t",value:null},_WFFLeft:{type:"t",value:null},_WFFRight:{type:"t",value:null}}]);function Ha(e,t){var r=i.rDY.clone(t);for(var n in e)r.hasOwnProperty(n)&&(r[n].value=e[n]);return r}function Wa(e,t){return{uniforms:Ha(e,{}),vertexShader:"varying vec3 pos;\r\n\r\nvoid main() {\r\n // we're assuming local position is in [-0.5, 0.5]\r\n // we need to offset it to be represented in RGB\r\n pos = position.xyz + 0.5;\r\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\r\n}",fragmentShader:"varying vec3 pos;\r\n\r\nvoid main() {\r\n gl_FragColor = vec4(pos, 0.5);\r\n}",transparent:!1,depthTest:!1,depthWrite:!1,side:t}}var Ya=function(e){h(r,e);var t=Ga(r);function r(e){a(this,r);var n=Wa(e,i._Li);return t.call(this,n)}return l(r)}(i.jyz),Xa=l((function e(t,r,n,o){a(this,e),this.uniforms=Ha(t,r),this.vertexShader=n,this.fragmentShader=o,this.transparent=!1,this.depthTest=!1,this.depthWrite=!1,this.side=i.Wl3})),qa={BackFacePosMaterial:Ya,BackFacePosMaterialFarPlane:function(e){h(r,e);var t=Ga(r);function r(e){a(this,r);var n=i.rDY.merge([{aspectRatio:{type:"f",value:0},farZ:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},matWorld2Volume:{type:"4fv",value:new i.yGw}}]),o=new Xa(e,n,"varying vec4 volPos;\r\nuniform float aspectRatio;\r\nuniform float farZ;\r\nuniform float tanHalfFOV;\r\nuniform mat4 matWorld2Volume;\r\n\r\nvoid main() {\r\n // rescale plane to fill in the whole far plane area seen from camera\r\n vec3 pos = position.xyz;\r\n pos.x = pos.x * tanHalfFOV * farZ * aspectRatio;\r\n pos.y = pos.y * tanHalfFOV * farZ;\r\n // common transformation\r\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\r\n // calc pos in volume CS\r\n volPos = matWorld2Volume * modelMatrix * vec4(pos, 1.0);\r\n // we're assuming local position is in [-0.5, 0.5]\r\n // we need to offset it to be represented in RGB\r\n volPos = volPos + 0.5;\r\n volPos.w = 0.5;\r\n}\r\n","varying vec4 volPos;\r\n\r\nvoid main() {\r\n gl_FragColor = volPos;\r\n}");return t.call(this,o)}return l(r)}(i.jyz),FrontFacePosMaterial:function(e){h(r,e);var t=Ga(r);function r(e){a(this,r);var n=Wa(e,i.Wl3);return t.call(this,n)}return l(r)}(i.jyz),VolumeMaterial:function(e){h(r,e);var t=Ga(r);function r(e){var n;a(this,r);var i=new Xa(e,ja,"varying vec4 screenSpacePos;\r\n\r\nvoid main() {\r\n screenSpacePos = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\r\n gl_Position = screenSpacePos;\r\n}","uniform mat4 projectionMatrix;\r\n\r\n// 3D volume texture\r\nuniform vec3 volumeDim; // volume dimensions, pixels\r\nuniform sampler2D tileTex; // tiled texture containing all Z-slices of a 3D data\r\nuniform vec2 tileTexSize; // size of tiled texture, pixels\r\nuniform vec2 tileStride; // UV stride between slices in tile tex, pixels\r\n\r\nuniform vec3 boxAngles;//value of angles({x: alpha, y:beta, z:gamma}) types 1 - if angle is obtuse, 0 - if acute\r\nuniform vec3 delta; //Projection box delta's from non-orthogonal origin axes; {x: XY, y : XZ, z: YZ}\r\n\r\nuniform vec3 _isoLevel0;\r\nuniform float _flipV;\r\nuniform sampler2D _BFLeft;\r\nuniform sampler2D _BFRight;\r\nuniform sampler2D _FFLeft;\r\nuniform sampler2D _FFRight;\r\nuniform sampler2D _WFFLeft;\r\nuniform sampler2D _WFFRight;\r\n\r\nvarying vec4 screenSpacePos;\r\n\r\n#define NO_COLOR vec4(0., 0., 0., 0.)\r\n\r\nvec4 sample3DTexture(vec3 texCoord) {\r\n // a pair of Z slices is determined by nearest slice border\r\n float zSliceBorder = floor(texCoord.z * volumeDim.z + 0.5);\r\n float zSliceNumber1 = max(zSliceBorder - 1.0, 0.0);\r\n float zSliceNumber2 = min(zSliceBorder, volumeDim.z - 1.0);\r\n\r\n float rowTiles = floor(tileTexSize.x / tileStride.x);\r\n\r\n // calculate coords in tile texture for both slices\r\n vec2 tileOffset = vec2(mod(zSliceNumber1, rowTiles), floor(zSliceNumber1 / rowTiles));\r\n vec2 texCoordSlice1 = (texCoord.xy * volumeDim.xy + tileOffset * tileStride) / tileTexSize.xy;\r\n tileOffset = vec2(mod(zSliceNumber2, rowTiles), floor(zSliceNumber2 / rowTiles));\r\n vec2 texCoordSlice2 = (texCoord.xy * volumeDim.xy + tileOffset * tileStride) / tileTexSize.xy;\r\n\r\n // bilinear filtering\r\n vec4 colorSlice1 = texture2D(tileTex, texCoordSlice1);\r\n vec4 colorSlice2 = texture2D(tileTex, texCoordSlice2);\r\n float weightSlice2 = texCoord.z * volumeDim.z - (zSliceNumber1 + 0.5);\r\n return mix(colorSlice1, colorSlice2, weightSlice2);\r\n}\r\n\r\nvec4 sample3DTextureInclined(vec3 boxCoord) { // delta:{ x: XY, y : XZ, z: YZ }\r\n vec3 textCoord = boxCoord;\r\n vec2 currDelta = mix(boxCoord.zz, vec2(1., 1.) - boxCoord.zz, boxAngles.yx) * delta.yz;\r\n\r\n textCoord.y = (boxCoord.y - currDelta.y) / (1. - delta.z);\r\n if (textCoord.y < 0.0 || textCoord.y > 1.0)\r\n return NO_COLOR;\r\n\r\n currDelta.x += mix(textCoord.y, 1.0 - textCoord.y, boxAngles.z) * delta.x;\r\n\r\n textCoord.x = (boxCoord.x - currDelta.x) / (1. - delta.x - delta.y);\r\n if (textCoord.x < 0.0 || textCoord.x > 1.0)\r\n return NO_COLOR;\r\n\r\n return sample3DTexture(textCoord);\r\n}\r\n\r\nfloat CalcColor(vec3 iter, vec3 dir) {\r\n float d = 1. / 128.;\r\n vec3 dx = vec3(d, 0.0, 0.0);\r\n vec3 dy = vec3(0.0, d, 0.0);\r\n vec3 dz = vec3(0.0, 0.0, d);\r\n\r\n // #Opt: coordInc.x:(iter + dx).x > 1. ? 0.: sample3DTextureInclined(iter + dx).x,\r\n vec3 coordInc = mix(\r\n vec3(\r\n sample3DTextureInclined(iter + dx).x,\r\n sample3DTextureInclined(iter + dy).x,\r\n sample3DTextureInclined(iter + dz).x\r\n ),\r\n vec3(0. ,0. , 0.),\r\n vec3(floor((iter + dx).x), floor((iter + dy).y), floor((iter + dz).z))\r\n );\r\n\r\n // #Opt: coordDec.x:(iter - dx).x < 0. ? 0.: sample3DTextureInclined(iter - dx).x,\r\n vec3 coordDec = mix(\r\n vec3(0. ,0. , 0.),\r\n vec3(\r\n sample3DTextureInclined(iter - dx).x,\r\n sample3DTextureInclined(iter - dy).x,\r\n sample3DTextureInclined(iter - dz).x\r\n ),\r\n vec3(ceil((iter - dx).x), ceil((iter - dy).y), ceil((iter - dz).z))\r\n );\r\n\r\n vec3 N = normalize(coordInc - coordDec);\r\n float dif = max(0.0, dot(N, dir));\r\n return dif;\r\n}\r\n\r\nvec3 AccuracyIso(vec3 left, vec3 right, float volLeft, float threshold) {\r\n for (int i = 0; i < 5; i++) {\r\n vec3 iterator = 0.5 * (left + right);\r\n float vol = sample3DTextureInclined(iterator).r;\r\n if ((volLeft - threshold) * (vol - threshold) < 0.)\r\n right = iterator;\r\n else\r\n left = iterator;\r\n }\r\n return 0.5 * (left + right);\r\n}\r\n\r\nvec3 CorrectIso(vec3 left, vec3 right, float tr) {\r\n for (int j = 0; j < 5; j++) {\r\n vec3 iterator = 0.5 * (left + right);\r\n float vol = sample3DTextureInclined(iterator).r;\r\n if (vol < tr)\r\n right = iterator;\r\n else\r\n left = iterator;\r\n }\r\n return 0.5 * (left + right);\r\n}\r\n\r\nvec4 GetIso1(vec3 start, vec3 back, float molDist, vec3 dir, float tr, int count) {\r\n float vol, stepSize = (float(count) + 2.) / float(STEPS_COUNT);\r\n vec3 step = stepSize * dir, iterator = start, left, right;\r\n vec4 acc = NO_COLOR;\r\n\r\n for (int i = 0; i < STEPS_COUNT; i++) {\r\n iterator = iterator + step;\r\n vol = sample3DTextureInclined(iterator).r;\r\n if (length(iterator - back) <= stepSize || (vol > tr))\r\n break;\r\n }\r\n\r\n if (vol > tr)\r\n acc = vec4(CorrectIso(iterator, iterator - step, tr).xyz, 1.);\r\n\r\n return acc;\r\n}\r\n\r\nfloat easeOut(float x0, float x1, float x) {\r\n float t = clamp((x - x0) / (x1 - x0), 0.0, 1.0);\r\n return 1.0 - (1.0 - t) * (1.0 - t);\r\n}\r\n\r\nfloat easeIn(float x0, float x1, float x) {\r\n float t = clamp((x - x0) / (x1 - x0), 0.0, 1.0);\r\n return t * t;\r\n}\r\n\r\nvec3 GetColSimple(float vol) {\r\n float t = easeOut(_isoLevel0.x, _isoLevel0.y, vol);\r\n float s = easeIn(_isoLevel0.y, _isoLevel0.z, vol);\r\n return vec3(0.5, 0.6, 0.7) * (1.0 - t) + 2.0 * vec3(s, 0, 0);\r\n}\r\n\r\nvec4 VolRender(vec3 start, vec3 back, float molDist, vec3 dir) {\r\n vec4 acc = NO_COLOR, iso;\r\n vec3 iterator = start, sumColor = vec3(0., 0., 0.);\r\n float stepSize, alpha, sumAlpha = 0.0, vol, curStepSize, molD;\r\n vec3 step, col, colOld, right;\r\n float tr0 = _isoLevel0.x;\r\n float dif, r, kd, finish;\r\n int count = 0, stopMol = 0;\r\n\r\n for (int k = 0; k < 3; k++) {\r\n stepSize = (float(k) + 2.) / float(STEPS_COUNT);\r\n kd = 140. * tr0 * stepSize;\r\n r = 1. - kd;\r\n step = stepSize * dir;\r\n iso = GetIso1(iterator, back, molDist, dir, tr0, k);\r\n if (iso.a < 0.1 || length(iso.xyz - start) > molDist)\r\n break;\r\n iterator = iso.xyz;\r\n dif = 1.;// CalcColor(iterator, dir);\r\n colOld = GetColSimple(tr0);\r\n curStepSize = stepSize;\r\n for (int i = 0; i < STEPS_COUNT; i++) {\r\n iterator = iterator + step;\r\n molD = length(iterator - start);\r\n vol = sample3DTextureInclined(iterator).r;\r\n finish = distance(iterator, back) - stepSize;\r\n if (finish < 0.0 || vol < tr0 || (sumAlpha > 0.97) || molD > molDist)\r\n break;\r\n alpha = (1. - r);\r\n col = GetColSimple(vol);\r\n vol = sample3DTextureInclined(iterator - 0.5 * step).r;\r\n vec3 colMid = GetColSimple(vol);\r\n sumColor += (1. - sumAlpha) * (colOld + 4.* colMid + col) * alpha / 6.;\r\n sumAlpha += (1. - sumAlpha) * alpha;// *(1. - 1.0*dif*dif);\r\n colOld = col;\r\n } // for i\r\n\r\n if (finish < 0.0 || sumAlpha > 0.97)\r\n break;\r\n\r\n if (molD > molDist) {\r\n curStepSize = stepSize - (molD - molDist);\r\n right = iterator - (molD - molDist) * dir;\r\n vol = sample3DTextureInclined(right).r;\r\n } else {\r\n vec3 left = iterator - step;\r\n right = CorrectIso(left, iterator, tr0);\r\n curStepSize = distance(left, right);\r\n vol = tr0;\r\n }\r\n\r\n alpha = (1. - r) * curStepSize / stepSize;\r\n dif = 1.;// CalcColor(right, dir);\r\n col = GetColSimple(vol);\r\n vol = sample3DTextureInclined(iterator - 0.5 * curStepSize / stepSize * step).r;\r\n vec3 colMid = GetColSimple(vol);\r\n sumColor += (1. - sumAlpha) * (colOld + 4. * colMid + col) * alpha / 6.;\r\n sumAlpha += (1. - sumAlpha) * alpha;// *(1. - 1.0*dif*dif);\r\n\r\n if (molD > molDist)\r\n break;\r\n } // for k\r\n acc.rgb = 1. * sumColor / sumAlpha;\r\n acc.a = sumAlpha;\r\n return acc;\r\n}\r\n\r\nvec4 VolRender1(vec3 start, vec3 back, float molDist, vec3 dir) {\r\n float stepSize = 1.0 / float(STEPS_COUNT);\r\n float len = length(back - start);\r\n vec3 step = stepSize * dir;\r\n vec3 iterator = start;\r\n float acc = 0.0;\r\n\r\n for (int i = 0; i < STEPS_COUNT; i++) {\r\n if (float(i) * stepSize > len)\r\n break;\r\n iterator = iterator + step;\r\n if (sample3DTextureInclined(iterator).r > _isoLevel0.x)\r\n acc += 10. * sample3DTextureInclined(iterator).r / float(STEPS_COUNT);\r\n }\r\n\r\n return vec4(1.,1.,1., acc);\r\n}\r\n\r\nvec4 IsoRender(vec3 start, vec3 back, float molDist, vec3 dir) {\r\n vec4 tst = GetIso1(start, back, 2., dir, _isoLevel0.x, 0);\r\n vec4 col = NO_COLOR;\r\n\r\n if (length(tst.xyz - start) < molDist && tst.a > 0.1) {\r\n float dif = CalcColor(tst.xyz, dir);\r\n dif = 0.9 * dif * dif;\r\n col = vec4(dif, dif, dif, 1);\r\n }\r\n return col;\r\n}\r\n\r\nvec4 VolRender2(vec3 start, vec3 back, float molDist, vec3 dir) {\r\n return sample3DTexture(start);\r\n}\r\n\r\nvoid main() {\r\n vec3 tc = screenSpacePos.xyz / screenSpacePos.w * 0.5 + 0.5;\r\n\r\n if (_flipV > 0.0) {\r\n tc.y = 1.0 - tc.y;\r\n }\r\n\r\n vec3 start;\r\n vec3 back;\r\n vec3 molBack;\r\n if (projectionMatrix[0][2] < 0.0) {\r\n start = texture2D(_FFLeft, tc.xy).xyz;\r\n back = texture2D(_BFLeft, tc.xy).xyz;\r\n molBack = texture2D(_WFFLeft, tc.xy).xyz;\r\n } else {\r\n start = texture2D(_FFRight, tc.xy).xyz;\r\n back = texture2D(_BFRight, tc.xy).xyz;\r\n molBack = texture2D(_WFFRight, tc.xy).xyz;\r\n }\r\n\r\n vec3 dir = normalize(back - start);\r\n\r\n float molDist = 2.0;\r\n if (length(molBack) > 0.001) {\r\n molDist = distance(start, molBack);\r\n }\r\n\r\n #ifdef ISO_MODE\r\n gl_FragColor = IsoRender(start, back, molDist, dir);\r\n #else\r\n gl_FragColor = VolRender(start, back, molDist, dir);\r\n #endif\r\n}\r\n");return i.transparent=!0,i.depthTest=!0,(n=t.call(this,i)).updateDefines(),n}return l(r,[{key:"updateDefines",value:function(){this.defines={ISO_MODE:J.now.modes.VD.isoMode,STEPS_COUNT:100*J.now.modes.VD.polyComplexity[J.now.resolution]},this.needsUpdate=!0}}]),r}(i.jyz)};var $a=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){var e;a(this,o);var t=new i.u9r;Re(c(e=n.call(this,t)),"volumeInfo",{}),e.clipPlane=new i.JOQ;var r=new i.Pa4(.5,.5,.5);return e.size=r,e.cullFlag=[!0,!0,!0,!0,!0,!0,!0,!0,!1,!1,!1,!1,!1,!1],e.faces=[{indices:[],norm:new i.Pa4(0,0,-1)},{indices:[],norm:new i.Pa4(0,0,1)},{indices:[],norm:new i.Pa4(0,-1,0)},{indices:[],norm:new i.Pa4(0,1,0)},{indices:[],norm:new i.Pa4(-1,0,0)},{indices:[],norm:new i.Pa4(1,0,0)},{indices:[],norm:new i.Pa4(0,0,0)}],e.vertices=[new i.Pa4(-r.x,-r.y,-r.z),new i.Pa4(-r.x,r.y,-r.z),new i.Pa4(r.x,-r.y,-r.z),new i.Pa4(r.x,r.y,-r.z),new i.Pa4(-r.x,-r.y,r.z),new i.Pa4(-r.x,r.y,r.z),new i.Pa4(r.x,-r.y,r.z),new i.Pa4(r.x,r.y,r.z),new i.Pa4(0,0,0),new i.Pa4(0,0,0),new i.Pa4(0,0,0),new i.Pa4(0,0,0),new i.Pa4(0,0,0),new i.Pa4(0,0,0)],t.setAttribute("position",new i.TlE(new Float32Array(3*e.vertices.length),3)),e.name="VolumeMesh",e}return l(o,[{key:"_updateVertices",value:function(){var e,t=o._corners,r=o._edges,n=o._edgeIntersections,a=this.clipPlane.normal,s=this.clipPlane.constant,l=this.vertices,c=this.size,u=[0,0,0,0,0,0,0,0],h=[1,1,1,1,1,1,1,1,1,1,1,1],f=new i.Pa4,d=null;function p(){if(0===a.x)return 0;var e=-(a.dot(f)+s)/a.x;return-c.x<=e&&e<=c.x?(d.set(e,f.y,f.z),e===c.x?2:e===-c.x?-2:1):0}function m(){if(0===a.y)return 0;var e=-(a.dot(f)+s)/a.y;return-c.y<=e&&e<=c.y?(d.set(f.x,e,f.z),e===c.y?2:e===-c.y?-2:1):0}function v(){if(0===a.z)return 0;var e=-(a.dot(f)+s)/a.z;return-c.z<=e&&e<=c.z?(d.set(f.x,f.y,e),e===c.z?2:e===-c.z?-2:1):0}for(var y=0;y<12;++y){var _=r[y];d=n[y],f.set(_[2],_[3],_[4]),f.multiply(c);var g=0;0===_[2]&&(g=p()),0===_[3]&&(g=m()),0===_[4]&&(g=v()),-2===g?u[_[0]]=1:2===g?u[_[1]]=1:0===g&&(h[y]=0)}var x={indices:[],norm:a.clone().negate()},b=8;for(e=0;e<8;++e)1===u[e]&&(l[b].set(t[e][0],t[e][1],t[e][2]).multiply(c),x.indices.push(b++),h[t[e][3]]=0,h[t[e][4]]=0,h[t[e][5]]=0);for(e=0;e<12;++e)1===h[e]&&(l[b].copy(n[e]),x.indices.push(b++));this.faces[6]=x;var w=new i.Pa4,S=new i.Pa4;for(this.clipPlane.coplanarPoint(S),e=0;e<l.length;++e)this.cullFlag[e]=!1,e<8?(w.subVectors(l[e],S),this.cullFlag[e]=a.dot(w)>=0):e<8+x.indices.length&&(this.cullFlag[e]=!0);var R=this.geometry.getAttribute("position"),C=0;for(e=0;e<l.length;++e)R.array[C++]=l[e].x,R.array[C++]=l[e].y,R.array[C++]=l[e].z;R.needsUpdate=!0}},{key:"_collectVertices",value:function(e,t){var r,n=this.vertices;for(e.indices=[],r=0;r<n.length;++r)this.cullFlag[r]&&t(n[r])&&e.indices.push(r)}},{key:"_sortIndices",value:function(e,t){var r,n,o=this.vertices,a=[],s=new i.Pa4;for(r=1;r<e.indices.length;++r)s.subVectors(o[e.indices[r]],o[e.indices[0]]),s.normalize(),s.cross(t),s.negate(),a[r]=e.norm.dot(s);for(r=1;r<e.indices.length-1;++r)for(n=r+1;n<e.indices.length;++n)if(a[n]<a[r]){var l=a[r];a[r]=a[n],a[n]=l,l=e.indices[r],e.indices[r]=e.indices[n],e.indices[n]=l}}},{key:"_updateIndices",value:function(){var e,t,r,n=this.vertices,o=this.size;this._collectVertices(this.faces[0],(function(e){return e.z===-o.z})),this._collectVertices(this.faces[1],(function(e){return e.z===o.z})),this._collectVertices(this.faces[2],(function(e){return e.y===-o.y})),this._collectVertices(this.faces[3],(function(e){return e.y===o.y})),this._collectVertices(this.faces[4],(function(e){return e.x===-o.x})),this._collectVertices(this.faces[5],(function(e){return e.x===o.x}));var a=new i.Pa4,s=new i.Pa4,l=new i.Pa4;for(t=0;t<this.faces.length;++t)if(0!==(r=this.faces[t]).indices.length){for(a.set(0,0,0),e=0;e<r.indices.length;++e)a.add(n[r.indices[e]]);a.multiplyScalar(1/r.indices.length),s.subVectors(n[r.indices[0]],a),s.normalize();var c=[];for(e=0;e<r.indices.length;++e)l.subVectors(n[r.indices[e]],a),c[e]=l.dot(s);for(e=1;e<r.indices.length;++e)if(c[e]<c[0]){var u=c[0];c[0]=c[e],c[e]=u,u=v(r.indices,1)[0],r.indices[0]=r.indices[e],r.indices[e]=u}this._sortIndices(r,s)}var h=0;for(t=0;t<this.faces.length;++t)(r=this.faces[t]).indices.length>=3&&(h+=3*(r.indices.length-2));var f=0,d=new Uint16Array(h);for(t=0;t<this.faces.length;++t)for(r=this.faces[t],e=0;e<r.indices.length-2;++e)d[f]=r.indices[0],d[f+1]=r.indices[e+1],d[f+2]=r.indices[e+2],f+=3;this.geometry.setIndex(new i.TlE(d,1))}},{key:"setDataSource",value:function(e){var t=new qa.VolumeMaterial,r=e.getDimensions(),n=e.getTiledTextureStride(),i=e.buildTiledTexture(),o=e.getBox();t.uniforms.volumeDim.value.set(r[0],r[1],r[2]),t.uniforms.tileTex.value=i,t.uniforms.tileTexSize.value.set(i.image.width,i.image.height),t.uniforms.tileStride.value.set(n[0],n[1]),Object.assign(this.volumeInfo,e.getVolumeInfo());var a=this.volumeInfo;t.uniforms.delta.value.copy(a.delta),t.uniforms.boxAngles.value.set(a.obtuseAngle[0],a.obtuseAngle[1],a.obtuseAngle[2]),this.material=t,o.getSize(this.scale),o.getCenter(this.position)}},{key:"_updateIsoLevel",value:function(){var e=J.now.modes.VD,t=e.kSigma,r=e.kSigmaMed,n=e.kSigmaMax,i=this.volumeInfo,o=i.dmean-i.dmin,a=i.dmax-i.dmin,s=function(e){return(o+e*i.sd)/a};this.material.uniforms._isoLevel0.value.set(s(t),s(r),s(n))}},{key:"rebuild",value:function(e){var t=o._nearClipPlaneOffset,r=o._pos,n=o._norm,i=o._norm4D,a=o._matrixWorldToLocal,s=o._clipPlane;this._updateIsoLevel(),e.getWorldDirection(n),e.getWorldPosition(r),r.addScaledVector(n,e.near+t),a.copy(this.matrixWorld).invert(),r.applyMatrix4(a),i.set(n.x,n.y,n.z,0),i.applyMatrix4(a),n.copy(i),n.normalize(),s.setFromNormalAndCoplanarPoint(n,r),this.clipPlane.equals(s)||(this.clipPlane=s.clone(),this._updateVertices(),this._updateIndices())}}]),o}(i.Kj0);Re($a,"_corners",[[-1,-1,-1,0,4,8],[1,-1,-1,0,5,9],[1,1,-1,1,5,10],[-1,1,-1,1,4,11],[-1,-1,1,2,6,8],[1,-1,1,2,7,9],[1,1,1,3,7,10],[-1,1,1,3,6,11]]),Re($a,"_edges",[[0,1,0,-1,-1],[2,3,0,1,-1],[4,5,0,-1,1],[6,7,0,1,1],[0,3,-1,0,-1],[1,2,1,0,-1],[4,7,-1,0,1],[5,6,1,0,1],[0,4,-1,-1,0],[1,5,1,-1,0],[2,6,-1,1,0],[3,7,1,1,0]]),Re($a,"_edgeIntersections",function(){for(var e=[],t=0;t<12;++t)e.push(new i.Pa4);return e}()),Re($a,"_nearClipPlaneOffset",.2),Re($a,"_pos",new i.Pa4),Re($a,"_norm",new i.Pa4),Re($a,"_norm4D",new i.Ltg),Re($a,"_matrixWorldToLocal",new i.yGw),Re($a,"_clipPlane",new i.JOQ);var Za=function(){function e(t,r){a(this,e);var n=r.delta,o=r.obtuseAngle,s=new i.Pa4;t.getSize(s),s.multiplyScalar(.5);for(var l=this._getBaseVertices(n,o),c=new i.u9r,u=[],h=0;h<4;h++)u.push(l[h].clone().multiply(s)),u.push(l[(h+1)%4].clone().multiply(s));for(var f=new i.Pa4(2*s.x*(1-n.x-n.y),0,0),d=0;d<8;d++)u.push(u[d].clone().add(f));for(var p=0;p<4;p++)u.push(u[2*p].clone()),u.push(u[2*p+8].clone());var m=new i.Pa4;t.getCenter(m),u.forEach((function(e){return e.add(m)}));var v=function(e){for(var t=e.length,r=new Float32Array(3*t),n=0;n<t;++n){var i=3*n,o=e[n];r[i]=o.x,r[i+1]=o.y,r[i+2]=o.z}return r}(u);c.setAttribute("position",new i.TlE(v,3)),this._lines=new i.ejS(c,new i.nls({color:16777215})),this._lines.layers.set(Er.LAYERS.VOLUME)}return l(e,[{key:"_getBaseVertices",value:function(t,r){var n=e._projectionTable,o=function(e,i){var o=t[n[e][0]];return(-.5*(i-1)+i*r[n[e][1]])*o};return[new i.Pa4(2*(o("XZ",1)+o("XY",1))-1,2*o("YZ",1)-1,-1),new i.Pa4(2*(o("XZ",-1)+o("XY",1))-1,2*o("YZ",-1)-1,1),new i.Pa4(2*(o("XZ",-1)+o("XY",-1))-1,1-2*o("YZ",1),1),new i.Pa4(2*(o("XZ",1)+o("XY",-1))-1,1-2*o("YZ",-1),-1)]}},{key:"getMesh",value:function(){return this._lines}}]),e}();Re(Za,"_projectionTable",{XY:["x",2],XZ:["y",1],YZ:["z",0]});var Ka=function(){function e(t,r,n){a(this,e);var o=this._initPlaneGeo(r,n),s=new qa.BackFacePosMaterialFarPlane;this._plane=new wi.Mesh(o,s),this._plane.frustumCulled=!1,this._plane.doubleSided=!0;var l=new i.yGw;this._plane._onBeforeRender=function(e,r,n,o,a,s){var c=this.material;if(t&&c){var u=new i.Ltg(0,0,-(n.far-.1),1);u.applyMatrix4(n.matrixWorld),this.matrix.identity(),this.matrix.makeTranslation(u.x,u.y,u.z),this.matrixWorld.copy(this.matrix),this.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,this.matrixWorld),this.normalMatrix.getNormalMatrix(this.modelViewMatrix);var h=t.matrixWorld;l.copy(h).invert(),c.uniforms.aspectRatio.value=n.aspect,c.uniforms.farZ.value=n.far,c.uniforms.tanHalfFOV.value=Math.tan(.5*i.M8C.DEG2RAD*n.fov),c.uniforms.matWorld2Volume.value=l}},this._plane.layers.set(Er.LAYERS.VOLUME_BFPLANE)}return l(e,[{key:"_initPlaneGeo",value:function(e,t){var r=new i.u9r;e=e||1,t=t||1;var n=new Float32Array([-.5*e,.5*t,0,.5*e,.5*t,0,-.5*e,-.5*t,0,.5*e,-.5*t,0]);return r.setAttribute("position",new i.TlE(n,3)),r.setIndex([0,2,1,2,3,1]),r}},{key:"getMesh",value:function(){return this._plane}}]),e}();var Qa=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;return a(this,o),(r=n.call(this,e,t))._mesh=new $a,r._mesh.setDataSource(t),r.add(r._mesh),r._frame=new Za(r.getBoundaries().boundingBox,r._mesh.volumeInfo),r.add(r._frame.getMesh()),r.showFrame(J.now.modes.VD.frame),r._farPlane=new Ka(r._mesh,2,2),r.add(r._farPlane.getMesh()),r}return l(o,[{key:"getBoundaries",value:function(){var e=this._dataSource.getBox(),t=new i.aLr;return e.getBoundingSphere(t),{boundingBox:e,boundingSphere:t}}},{key:"getMesh",value:function(){return this._mesh}},{key:"showFrame",value:function(e){this._frame.getMesh().material.visible=e}}]),o}(Pr);var Ja=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return a(this,i),n.call(this,e,["types"])}return l(i,[{key:"find",value:function(e){var t=[];if(e.type)t=this._dict.types[e.type.toLowerCase()]||[];else if(e.source)return this._list.filter((function(t){return t.canProbablyLoad&&t.canProbablyLoad(e.source)}));return Tr(t)}}]),i}(Nr);var es=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return a(this,i),(r=n.call(this))._source=e,r._options=t||{},r._abort=!1,r._agent=null,r}return l(i,[{key:"load",value:function(){return Promise.reject(new Error("Loading from this source is not implemented"))}},{key:"abort",value:function(){this._abort=!0,this._agent&&this._agent.abort()}}],[{key:"extractName",value:function(e){}}]),i}(N);Ir(es.prototype);var ts=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return a(this,i),t=(r=n.call(this,e,t))._options,r._binary=!0===t.binary,r}return l(i,[{key:"load",value:function(){var e=this;return new Promise((function(t,r){if(e._abort)throw new Error("Loading aborted");var n=e._source,i=e._agent=new FileReader;i.addEventListener("load",(function(){t(i.result)})),i.addEventListener("error",(function(){r(i.error)})),i.addEventListener("abort",(function(){r(new Error("Loading aborted"))})),i.addEventListener("progress",(function(t){e.dispatchEvent(t)})),e._binary?i.readAsArrayBuffer(n):i.readAsText(n)}))}}],[{key:"canProbablyLoad",value:function(e){return File&&e instanceof File||Blob&&e instanceof Blob}},{key:"extractName",value:function(e){return e&&e.name}}]),i}(es);ts.types=["file","blob"];var rs=/^(https?|ftp):\/\//i,ns=function(e){h(o,e);var t,r,i=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;return a(this,o),t=(r=i.call(this,e,t))._options,r._binary=!0===t.binary,r}return l(o,[{key:"load",value:function(){var e=this;return new Promise((function(t,r){if(e._abort)throw new Error("Loading aborted");var n=e._source,i=e._agent=new XMLHttpRequest;i.addEventListener("load",(function(){200===i.status?t(i.response):r(new Error("HTTP ".concat(i.status," while fetching ").concat(n)))})),i.addEventListener("error",(function(){r(new Error("HTTP request failed"))})),i.addEventListener("abort",(function(){r(new Error("Loading aborted"))})),i.addEventListener("progress",(function(t){e.dispatchEvent(t)})),i.open("GET",n),e._binary?i.responseType="arraybuffer":i.responseType="text",i.send()}))}}],[{key:"canProbablyLoad",value:function(e){return(0,n.isString)(e)&&rs.test(e)}},{key:"extractName",value:function(e){if(e){var t=(e.indexOf("?")+1||e.lastIndexOf("#")+1||e.length+1)-1;return e.slice(e.lastIndexOf("/",t)+1,t)}}}]),o}(es);ns.types=["url"];var is=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"load",value:function(){var e=this;return new Promise((function(t){if(e._abort)throw new Error("Loading aborted");t(e._source)}))}}],[{key:"canProbablyLoad",value:function(e){return!1}}]),i}(es);is.types=["immediate"];var os=new Ja([ts,ns,is]);var as=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return a(this,i),n.call(this,e,["formats","extensions"])}return l(i,[{key:"find",value:function(e){var t=[];return e.format?t=this._dict.formats[e.format.toLowerCase()]||[]:e.ext&&(t=this._dict.extensions[e.ext.toLowerCase()]||[]),0===t.length&&!e.format&&e.data?this._list.filter((function(t){return t.canProbablyParse&&t.canProbablyParse(e.data)})):Tr(t)}}]),i}(Nr),ss=function(){function e(t,r){a(this,e),this._data=t,this._options=r||{},this._abort=!1}return l(e,[{key:"parseSync",value:function(){throw new Error("Parsing this type of data is not implemented")}},{key:"parse",value:function(){var e=this;return new Promise((function(t,r){setTimeout((function(){try{return e._abort?r(new Error("Parsing aborted")):t(e.parseSync())}catch(e){return r(e)}}))}))}},{key:"getModel",value:function(){return this.model._parseHeader(this._data),this.model}},{key:"abort",value:function(){this._abort=!0}}]),e}();Ir(ss.prototype);var ls=function(){function e(){a(this,e),this.matrices=[],this._matrix=null,this._matrixIndex=-1}return l(e,[{key:"parse",value:function(e){var t=this._matrix;if(" SMTRY"===e.readString(12,18)){var r=e.readCharCode(19)-49,n=e.readString(20,80).trim().split(/\s+/),o=parseInt(n[0],10);null!==this._matrix&&o===this._matrixIndex||(this._matrixIndex=o,this._matrix=t=new i.yGw,this.matrices[this.matrices.length]=t);var a=t.elements;a[r]=parseFloat(n[1]),a[r+4]=parseFloat(n[2]),a[r+8]=parseFloat(n[3]),a[r+12]=parseFloat(n[4])}}}]),e}();ls.prototype.id=290;var cs=pr.Assembly,us=function(){function e(t){a(this,e),this._complex=t,this.assemblies=[],this._assembly=null,this._matrix=null,this._matrixIndex=-1}return l(e,[{key:"parse",value:function(e){var t=this._assembly,r=this._matrix;if(t&&" BIOMT"===e.readString(12,18)){var n=e.readCharCode(19)-49,o=e.readString(20,80).trim().split(/\s+/),a=parseInt(o[0],10);null!==this._matrix&&a===this._matrixIndex||(this._matrixIndex=a,this._matrix=r=new i.yGw,t.addMatrix(r));var s=r.elements;s[n]=parseFloat(o[1]),s[n+4]=parseFloat(o[2]),s[n+8]=parseFloat(o[3]),s[n+12]=parseFloat(o[4])}else if(t&&"CHAINS:"===e.readString(35,41))for(var l=e.readString(42,80).split(","),c=0,u=l.length;c<u;++c){var h=l[c].trim();h.length>0&&t.addChain(h)}else"BIOMOLECULE:"===e.readString(12,23)&&(this._matrix=null,this._matrixIndex=-1,this._assembly=t=new cs(this._complex),this.assemblies.push(t))}}]),e}();us.prototype.id=350;var hs=function(){function e(t){a(this,e),this._data=t,this._start=0,this._nextCR=-1,this._nextLF=-1,this._next=-1,this._end=t.length,this.next()}return l(e,[{key:"readLine",value:function(){return this._data.slice(this._start,this._next)}},{key:"readChar",value:function(e){return(e=this._start+e-1)<this._next?this._data[e]:" "}},{key:"readCharCode",value:function(e){return(e=this._start+e-1)<this._next?this._data.charCodeAt(e):32}},{key:"readString",value:function(e,t){var r=this._start+e-1,n=this._start+t;return this._data.slice(r,n<this._next?n:this._next)}},{key:"readInt",value:function(e,t){return parseInt(this.readString(e,t),10)}},{key:"readFloat",value:function(e,t){return parseFloat(this.readString(e,t))}},{key:"end",value:function(){return this._start>=this._end}},{key:"next",value:function(){var e=this._next+1;this._start=e<this._end?e:this._end,this._start>this._nextCR&&(this._nextCR=(this._data.indexOf("\r",this._start)+1||this._end+1)-1),this._start>this._nextLF&&(this._nextLF=(this._data.indexOf("\n",this._start)+1||this._end+1)-1),this._next=this._nextCR+1<this._nextLF?this._nextCR:this._nextLF}}]),e}();var fs=pr.Complex,ds=pr.Element,ps=pr.Helix,ms=pr.Sheet,vs=pr.Strand,ys=pr.Bond,_s=pr.Molecule,gs=/^(HEADER\s|COMPND\s|REMARK\s|ATOM {2}|HETATM|MODEL )/i,xs={290:ls,350:us},bs=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e,t){var r;return a(this,s),(r=o.call(this,e,t))._complex=null,r._chain=null,r._residue=null,r._sheet=null,r._serialAtomMap=null,r._modelId=1,r._compaundFound=!1,r._biomoleculeFound=!1,r._allowedChainsIDs=null,r._lastMolId=-1,r._remarks={},r._remark=null,r._molecules=[],r._molecule=null,r._compndCurrToken="",r._options.fileType="pdb",r}return l(s,[{key:"_finalize",value:function(){this._fixBondsArray(),this._fixChains();var e=this._remarks[290];this._complex.symmetry=(0,n.isUndefined)(e)?[]:e.matrices;var t=this._remarks[350];this._complex.units=this._complex.units.concat((0,n.isUndefined)(t)?[]:t.assemblies),this._finalizeMolecules(),this._complex.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap})}},{key:"_finalizeMolecules",value:function(){var e,t={},r=this._complex._chains;for(e=0;e<r.length;++e){var n=r[e];t[n._name]=n}for(e=0;e<this._molecules.length;e++){for(var i=this._molecules[e],o=[],a=0;a<i._chains.length;a++){var s=t[i._chains[a]];o=o.concat(s._residues.slice())}var l=new _s(this._complex,i._name,e+1);l.residues=o,this._complex._molecules[e]=l}}},{key:"_fixChains",value:function(){for(var e={},t=this._complex,r=0;r<t._chains.length;r++){var n=t._chains[r];e[n._name.charCodeAt(0)]=n}}},{key:"_fixBondsArray",value:function(){for(var e=this._serialAtomMap={},t=this._complex,r=t._atoms,n=0,i=r.length;n<i;++n){var o=r[n];e[o.serial]=o}for(var a=t._bonds,s=this.logger,l=0,c=a.length;l<c;++l){var u=a[l];u._right<u._left&&s.debug("_fixBondsArray: Logic error."),u._left=e[u._left]||null,u._right=e[u._right]||null}}},{key:"_parseATOM",value:function(e){if(1===this._modelId){var t=72===e.readCharCode(1),r=t?e.readInt(7,11):e.readInt(6,11),n=e.readString(13,16),o=e.readChar(17),a=e.readString(18,20).trim(),s=e.readChar(22),l=e.readInt(23,26),c=e.readChar(27),u=e.readFloat(31,38),h=e.readFloat(39,46),f=e.readFloat(47,54),d=e.readFloat(55,60),p=e.readFloat(61,66),m=e.readString(77,78).trim()||function(e){var t=4===e.trim().length;return e.slice(0,t?1:2).trim()}(n),v=e.readInt(79,80)||0;if(!this.settings.now.nowater||"HOH"!==a&&"WAT"!==a){n=n.trim();var y=ds.getByName(m),_=ds.Role[n],g=this._chain;g&&g.getName()===s||(this._chain=g=this._complex.getChain(s)||this._complex.addChain(s),this._residue=null);var x=this._residue;x&&x.getSequence()===l&&x.getICode()===c||(this._residue=x=g.addResidue(a,l,c));var b=new i.Pa4(u,h,f);x.addAtom(n,y,b,_,t,r,o,d,p,v)}}}},{key:"_parseENDMDL",value:function(){this._modelId+=1}},{key:"_parseCONECT",value:function(e){var t=e.readInt(7,11),r=e.readInt(12,16),n=e.readInt(17,21),i=e.readInt(22,26),o=e.readInt(27,31),a=this._complex;r&&r>t&&a.addBond(t,r,0,ys.BondType.UNKNOWN,!0),n&&n>t&&a.addBond(t,n,0,ys.BondType.UNKNOWN,!0),i&&i>t&&a.addBond(t,i,0,ys.BondType.UNKNOWN,!0),o&&o>t&&a.addBond(t,o,0,ys.BondType.UNKNOWN,!0)}},{key:"_parseCOMPND",value:function(e){var t=e.readString(11,80),r=t.indexOf(":");if(this._compndCurrToken=r>0?t.substring(0,r).trim():this._compndCurrToken,"MOL_ID"===this._compndCurrToken)this._molecule={_index:"",_chains:[]},this._molecule._index=parseInt(t.substring(r+1,t.indexOf(";")),10),this._molecules.push(this._molecule);else if("MOLECULE"===this._compndCurrToken&&null!=this._molecule)this._molecule._name=t.substring(r+1,t.indexOf(";")).trim();else if("CHAIN"===this._compndCurrToken&&null!=this._molecule){var n=t.substring(r+1,80).trim(),i=n[n.length-1];";"!==i&&","!==i||(n=n.slice(0,-1));var o=(n=n.replace(/\s+/g,"")).split(",");this._molecule._chains=this._molecule._chains.concat(o)}}},{key:"_parseREMARK",value:function(e){var t=e.readInt(8,10),r=this._remarks[t];if((0,n.isUndefined)(r)){var i=xs[t];"function"==typeof i&&(this._remarks[t]=r=new i(this._complex))}(0,n.isUndefined)(r)||r.parse(e)}},{key:"_parseHELIX",value:function(e){var t=this;this._parseSTRUCTURE(e,[20,22,32,34],(function(e){t._complex.addHelix(e),t._complex.structures.push(e)}))}},{key:"_parseSHEET",value:function(e){var t=this;this._parseSTRUCTURE(e,[22,23,33,34],(function(e){t._complex.addSheet(e)}))}},{key:"_parseSTRUCTURE",value:function(e,t,r){var n=e.readInt(8,10),i=e.readString(12,14).trim(),o=e.readString(41,70).trim(),a=e.readInt(72,76),s=e.readInt(39,40),l=e.readInt(15,16),c=e.readInt(42,45),u=e.readInt(57,60),h=e.readString(t[0],t[2]+1).charCodeAt(0),f=e.readString(t[2],t[2]+1).charCodeAt(0),d=e.readInt(t[1],t[1]+3),p=e.readString(t[1]+4,t[1]+4),m=0;p.length>0&&(m=p.charCodeAt(0));var v,y=e.readInt(t[3],t[3]+3),_=0;(p=e.readString(t[3]+4,t[3]+4)).length>0&&(_=p.charCodeAt(0));var g=this._sheet;if(83===e.readCharCode(1)){null!==g&&g.getName()!==i&&(g=null,this._sheet=null),null===g?(this._sheet=v=new ms(i,l),r(v)):v=g;var x=new vs(v,this._complex.getUnifiedSerial(h,d,m),this._complex.getUnifiedSerial(f,y,_),s,c,u);v.addStrand(x),this._complex.structures.push(x)}else r(v=new ps(s,this._complex.getUnifiedSerial(h,d,m),this._complex.getUnifiedSerial(f,y,_),n,i,o,a))}},{key:"_parseHEADER",value:function(e){var t=this._complex.metadata;t.classification=e.readString(11,50).trim(),t.date=e.readString(51,59).trim();var r=e.readString(63,66).trim();t.id=r,r&&(this._complex.name=r),t.format="pdb"}},{key:"_parseTITLE",value:function(e){var t=this._complex.metadata;t.title=t.title||[];var r=e.readInt(9,10)||1;t.title[r-1]=e.readString(11,80).trim()}},{key:"parseSync",value:function(){for(var e=new hs(this._data),t=this._complex=new fs;!e.end();){var r=e.readString(1,6),n=s.tagParsers[r];"function"==typeof n&&n.call(this,e),e.next()}if(this._finalize(),this._serialAtomMap=null,this._sheet=null,this._residue=null,this._chain=null,this._complex=null,0===t.getAtomCount())throw new Error("The data does not contain valid atoms");return t}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&gs.test(e)}}]),s}(ss);Re(bs,"tagParsers",{HEADER:bs.prototype._parseHEADER,"TITLE ":bs.prototype._parseTITLE,"ATOM ":bs.prototype._parseATOM,HETATM:bs.prototype._parseATOM,ENDMDL:bs.prototype._parseENDMDL,CONECT:bs.prototype._parseCONECT,COMPND:bs.prototype._parseCOMPND,REMARK:bs.prototype._parseREMARK,"HELIX ":bs.prototype._parseHELIX,"SHEET ":bs.prototype._parseSHEET,"ATOM 1":bs.prototype._parseATOM,"ATOM 2":bs.prototype._parseATOM,"ATOM 3":bs.prototype._parseATOM,"ATOM 4":bs.prototype._parseATOM,"ATOM 5":bs.prototype._parseATOM,"ATOM 6":bs.prototype._parseATOM,"ATOM 7":bs.prototype._parseATOM,"ATOM 8":bs.prototype._parseATOM,"ATOM 9":bs.prototype._parseATOM}),bs.formats=["pdb"],bs.extensions=[".pdb",".ent"];var ws=pr.Complex,Ss=pr.Element,Rs=pr.SGroup,Cs=pr.Bond,As={A:0,S:1,D:2,T:3},Es=/\s*<\?xml\b[^?>]*\?>\s*<(?:cml|molecule)\b/i,ks=function(e){h(c,e);var t,r,s=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function c(e,t){var r;return a(this,c),(r=s.call(this,e,t))._complex=null,r._residue=null,r._serialAtomMap=null,r._modelId=1,r._lastMolId=-1,r._readOnlyOneMolecule=!1,r._options.fileType="cml",r}return l(c,[{key:"_rebuidBondIndexes",value:function(e,t){for(var r=e.length,n=0;n<r;n++)for(var i=e[n].id,o=t.length,a=0;a<o;a++){var s=t[a].atomRefs2.split(" ");s[0]===i&&(t[a].start=n),s[1]===i&&(t[a].end=n)}}},{key:"_createSGroup",value:function(e,t){var r=new Rs(e.id,e.fieldData,new i.Pa4(parseFloat(e.x),parseFloat(e.y),0),e.atomRefs,e);"Relative"===e.placement&&(r._center=new i.Pa4(0,0,0)),"MDLBG_FRAGMENT_CHARGE"===e.fieldName&&(r._charge=parseInt(e.fieldData,10)||0),"MDLBG_FRAGMENT_COEFFICIENT"===e.fieldName&&(r._repeat=parseInt(e.fieldData,10)||1),t.push(r)}},{key:"_extractSGroup",value:function(e,t){if(Array.isArray(t)||(t=[]),e)if(Array.isArray(e))for(var r=e.length,n=0;n<r;n++)e[n].molecule&&(t=t.concat(this._extractSGroup(e[n].molecule))),this._createSGroup(e[n],t);else e.molecule&&e.molecule&&(t=t.concat(this._extractSGroup(e.molecule))),this._createSGroup(e,t);return t}},{key:"_extractSGroups",value:function(e,t){var r,n,o=this._extractSGroup(e),a=t.length;for(r=0;r<a;r++){var s=t[r].id;for(n=0;n<o.length;n++)o[n]._atoms.split(" ")[0]===s&&(t[r].sgroupRef||(t[r].sgroupRef=[]),t[r].sgroupRef.push(o[n]))}var l,c={},u=null,h=1e8,f=new i.Pa4(h,h,h),d=new i.Pa4(-h,-h,-h);function p(e){(u=c[e])&&o[n]._atoms.push(u.a)}function m(e){(u=c[e])&&(f.set(Math.min(f.x,u.x),Math.min(f.y,u.y),Math.min(f.z,u.z)),d.set(Math.max(d.x,u.x),Math.max(d.y,u.y),Math.max(d.z,u.z)),p(e))}for(r=0;r<t.length;r++)c[t[r].id]={},c[t[r].id].x=t[r].x2,t[r].x3&&(c[t[r].id].x=t[r].x3),c[t[r].id].x=parseFloat(c[t[r].id].x),c[t[r].id].y=t[r].y2,t[r].y3&&(c[t[r].id].y=t[r].y3),c[t[r].id].y=parseFloat(c[t[r].id].y),c[t[r].id].z="0.0",t[r].z3&&(c[t[r].id].z=t[r].z3),c[t[r].id].z=parseFloat(c[t[r].id].z),c[t[r].id].a=t[r];for(n=0;n<o.length;n++)null!==o[n]._center?(f.set(h,h,h),d.set(-h,-h,-h),l=o[n]._atoms.split(" "),o[n]._atoms=[],l.forEach(m),o[n]._center.addVectors(f,d),o[n]._center.multiplyScalar(.5)):(l=o[n]._atoms.split(" "),o[n]._atoms=[],l.forEach(p));c=null}},{key:"_traverseData",value:function(e){var t={};return e.childNodes.length&&function e(t,r){if("#text"!==t.nodeName||""!==t.nodeValue.trim()){var n={};n.xmlNode=t;var i,o,a,s=r[t.nodeName];if(s?(i=s,"[object Array]"!==Object.prototype.toString.apply(i)?r[t.nodeName]=[s,n]:r[t.nodeName].push(n)):r[t.nodeName]=n,t.attributes)for(o=t.attributes.length,a=0;a<o;a++){var l=t.attributes[a];n[l.nodeName]=l.nodeValue}for(o=t.childNodes.length,a=0;a<o;a++)e(t.childNodes[a],n)}}(e.childNodes[0],t),t}},{key:"_findSuitableMolecule",value:function(e,t){for(var r in e)if("xmlNode"!==r)if("molecule"===r){if(e.molecule&&(e.molecule.atomArray&&e.molecule.atomArray.atom&&t.push(e),Array.isArray(e.molecule)))for(var n=0;n<e.molecule.length;n++)e.molecule[n].atomArray&&e.molecule[n].atomArray.atom&&t.push({molecule:e.molecule[n]})}else e[r]&&null!==e[r]&&"object"===o(e[r])&&this._findSuitableMolecule(e[r],t)}},{key:"_selectComponents",value:function(e){var t,r=(new DOMParser).parseFromString(e,"application/xml"),n=this._traverseData(r),i=this;t=n.cml?n.cml:n;var o=[],a=[];return this._findSuitableMolecule(t,a),this._readOnlyOneMolecule&&a.length>1&&a.splice(1,a.length-1),a.forEach((function(e){var t=function(e){var t,n=[];if(e.molecule&&e.molecule.atomArray&&e.molecule.atomArray.atom)Array.isArray(e.molecule.atomArray.atom)?n=e.molecule.atomArray.atom:n.push(e.molecule.atomArray.atom);else if(!e.molecule)return{atomLabels:null,labelsCount:1};e.molecule.molecule&&i._extractSGroups(e.molecule.molecule,n);for(var o=n.length,a=0;a<o;a++)(t=n[a]).edges=[];var s,l=[];e.molecule.bondArray&&e.molecule.bondArray.bond&&(Array.isArray(e.molecule.bondArray.bond)?l=e.molecule.bondArray.bond:l.push(e.molecule.bondArray.bond)),o=l.length,i._rebuidBondIndexes(n,l);for(var c=0;c<o;c++)if((t=n[(s=l[c]).start])&&(t.edges.push(s.end),(t=n[s.end])&&(t.edges.push(s.start),1))){var u=s.xmlNode.getAttribute("order"),h=parseInt(u,10);if(l[c].order=0,l[c].type=Cs.BondType.UNKNOWN,h>1)l[c].order=h;else{var f=As[u];void 0!==f&&(l[c].order=f,"A"===u&&(l[c].type=Cs.BondType.AROMATIC))}}o=n.length;for(var d=0;d<o;d++)(t=n[d]).edges.sort();var p=i._breadWidthSearch(n,0),m={};return m.atoms=n,m.bonds=l,m.labels=p.atomLabels,m.count=Math.min(1,p.labelsCount),m.curr=-1,m.originalCML=r,m}(e);t.atoms.length>0&&o.push(t)})),o}},{key:"_packLabel",value:function(e,t){return(t<<16)+e}},{key:"_unpackLabel",value:function(e){return{molId:e>>>16,compId:65535&e}}},{key:"_breadWidthSearch",value:function(e,t){var r,n=new Array(e.length);for(r=0;r<n.length;r++)n[r]=this._packLabel(0,t);for(var i=[],o=0,a=e.length;a>0;){o++;var s=-1;for(r=0;r<n.length;r++)if(0===this._unpackLabel(n[r]).compId){s=r;break}if(s<0)break;for(i.push(e[s]),n[s]=this._packLabel(o,t),a--;i.length>0;){var l=i.shift();if(l)for(var c=0;c<l.edges.length;c++)n[l.edges[c]]!==o&&(i.push(e[l.edges[c]]),n[l.edges[c]]=o,a--)}}var u={};return u.atomLabels=n,u.labelsCount=o,u}},{key:"_parseBond",value:function(e,t,r,n){if(e>=0){var i=[Math.min(e,t),Math.max(e,t)];this._complex.addBond(i[0],i[1],r,n,!0)}}},{key:"_fixBondsArray",value:function(){for(var e=this._serialAtomMap={},t=this._complex,r=t._atoms,n=0,i=r.length;n<i;++n){var o=r[n];e[o.serial]=o}for(var a=t._bonds,s=this.logger,l=0,c=a.length;l<c;++l){var u=a[l];u._right<u._left&&s.debug("_fixBondsArray: Logic error."),u._left=e[u._left]||null,u._right=e[u._right]||null}}},{key:"_parseSet",value:function(e){var t,r,n,o=this._complex=new ws,a=e,s=a.curr,l=a.atoms,c=a.labels,u=null,h=l.length,f={},d=[];for(t=0;t<h;t++)d.push(t);for(d.sort((function(e,t){return c[e]-c[t]})),t=0;t<h;t++){var p=c[d[t]];if(this._unpackLabel(p).molId===this._unpackLabel(s).molId){var m=(u=l[d[t]]).elementType;if(u.sgroupRef)for(var v=u.sgroupRef.length,y=0;y<v;++y)o._sgroups.push(u.sgroupRef[y]);if(u.x3||u.x2){var _=this._unpackLabel(p).compId,g=" ",x=_,b=_.toString();1===b.length&&(b="0".concat(b));var w="N".concat(b),S=f[g];S&&S.getName()===g||(f[g]=S=this._complex.getChain(g)||this._complex.addChain(g),this._residue=null);var R=this._residue;R&&R.getSequence()===x&&" "===R.getICode()||(this._residue=R=S.addResidue(w,x," "));var C=null;u.x3?C=new i.Pa4(parseFloat(u.x3),parseFloat(u.y3),parseFloat(u.z3)):u.x2&&(C=new i.Pa4(parseFloat(u.x2),parseFloat(u.y2),0));var A=Ss.ByName[u.elementType.toUpperCase()];A||((A=JSON.parse(JSON.stringify(Ss.ByName[Object.keys(Ss.ByName)[Object.keys(Ss.ByName).length-1]]))).number+=1,A.name=u.elementType.toUpperCase(),A.fullName="Unknown",Ss.ByName[u.elementType.toUpperCase()]=A);var E=parseInt(u.id.replace(/[^0-9]/,""),10),k=R.addAtom(m,A,C,Ss.Role.SG,!0,E," ",1,0,0);u.hydrogenCount&&(k.hydrogenCount=parseInt(u.hydrogenCount,10)),u.mrvValence&&(k.valence=parseInt(u.mrvValence,10)),(n=k).xmlNodeRef=u,u.x2&&(u.x3=u.x2,delete u.x2),u.y2&&(u.y3=u.y2,delete u.y2),u.z3||(u.z3="0.0"),u.complexAtom=n}}}for(f=null,t=0;t<a.bonds.length;t++){var P=a.bonds[t];if(this._unpackLabel(c[P.start]).molId===this._unpackLabel(s).molId&&this._unpackLabel(c[P.end]).molId===this._unpackLabel(s).molId){if(!(u=l[P.start])||!l[P.end])continue;this._parseBond(parseInt(u.id.replace(/[^0-9]/,""),10),parseInt(l[P.end].id.replace(/[^0-9]/,""),10),P.order,P.type)}}for(t=0;t<this._complex.getSGroupCount();t++){var T=this._complex.getSGroups()[t];for(r=0;r<T._atoms.length;r++)T._atoms[r]=T._atoms[r].complexAtom}for(t=0;t<h;t++)this._unpackLabel(c[t]).molId===this._unpackLabel(s).molId&&((u=l[t]).complexAtom=null,delete u.complexAtom);return this._complex.originalCML=a.originalCML,this._fixBondsArray(),o.finalize({needAutoBonding:!1,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap}),this._serialAtomMap=null,this._complex=null,o}},{key:"parseSync",value:function(){var e=[],t=this;this._selectComponents(this._data).forEach((function(r){r.curr=2,0===r.count&&(r.count=1);for(var n=0;n<r.count;n++)r.curr=n+1,e.push(t._parseSet(r,!1))}));var r=0;if(e.forEach((function(e){r+=e.getAtomCount()})),r<=0)throw new Error("The data does not contain valid atoms");if(e.length>1){var n=new ws;return n.joinComplexes(e),n.originalCML=e[0].originalCML,n}return 1===e.length?e[0]:new ws}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&Es.test(e)}}]),c}(ss);ks.formats=["cml"],ks.extensions=[".cml"];var Ps={};!function(e,t){!function(e){function t(e,t,r){for(var n=(e.byteLength,0),i=r.length;i>n;n++){var o=r.charCodeAt(n);if(128>o)e.setUint8(t++,o>>>0&127|0);else if(2048>o)e.setUint8(t++,o>>>6&31|192),e.setUint8(t++,o>>>0&63|128);else if(65536>o)e.setUint8(t++,o>>>12&15|224),e.setUint8(t++,o>>>6&63|128),e.setUint8(t++,o>>>0&63|128);else{if(!(1114112>o))throw new Error("bad codepoint "+o);e.setUint8(t++,o>>>18&7|240),e.setUint8(t++,o>>>12&63|128),e.setUint8(t++,o>>>6&63|128),e.setUint8(t++,o>>>0&63|128)}}}function r(e){for(var t=0,r=0,n=e.length;n>r;r++){var i=e.charCodeAt(r);if(128>i)t+=1;else if(2048>i)t+=2;else if(65536>i)t+=3;else{if(!(1114112>i))throw new Error("bad codepoint "+i);t+=4}}return t}function n(e,i,a){var s=o(e);if("string"===s){if(32>(l=r(e)))return i.setUint8(a,160|l),t(i,a+1,e),1+l;if(256>l)return i.setUint8(a,217),i.setUint8(a+1,l),t(i,a+2,e),2+l;if(65536>l)return i.setUint8(a,218),i.setUint16(a+1,l),t(i,a+3,e),3+l;if(4294967296>l)return i.setUint8(a,219),i.setUint32(a+1,l),t(i,a+5,e),5+l}if(e instanceof Uint8Array){var l=e.byteLength,c=new Uint8Array(i.buffer);if(256>l)return i.setUint8(a,196),i.setUint8(a+1,l),c.set(e,a+2),2+l;if(65536>l)return i.setUint8(a,197),i.setUint16(a+1,l),c.set(e,a+3),3+l;if(4294967296>l)return i.setUint8(a,198),i.setUint32(a+1,l),c.set(e,a+5),5+l}if("number"===s){if(!isFinite(e))throw new Error("Number not finite: "+e);if(Math.floor(e)!==e)return i.setUint8(a,203),i.setFloat64(a+1,e),9;if(e>=0){if(128>e)return i.setUint8(a,e),1;if(256>e)return i.setUint8(a,204),i.setUint8(a+1,e),2;if(65536>e)return i.setUint8(a,205),i.setUint16(a+1,e),3;if(4294967296>e)return i.setUint8(a,206),i.setUint32(a+1,e),5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return i.setInt8(a,e),1;if(e>=-128)return i.setUint8(a,208),i.setInt8(a+1,e),2;if(e>=-32768)return i.setUint8(a,209),i.setInt16(a+1,e),3;if(e>=-2147483648)return i.setUint8(a,210),i.setInt32(a+1,e),5;throw new Error("Number too small -0x"+(-e).toString(16).substr(1))}if(null===e)return i.setUint8(a,192),1;if("boolean"===s)return i.setUint8(a,e?195:194),1;if("object"===s){var u=0,h=Array.isArray(e);if(h)l=e.length;else{var f=Object.keys(e);l=f.length}if(16>l?(i.setUint8(a,l|(h?144:128)),u=1):65536>l?(i.setUint8(a,h?220:222),i.setUint16(a+1,l),u=3):4294967296>l&&(i.setUint8(a,h?221:223),i.setUint32(a+1,l),u=5),h)for(var d=0;l>d;d++)u+=n(e[d],i,a+u);else for(d=0;l>d;d++){var p=f[d];u+=n(p,i,a+u),u+=n(e[p],i,a+u)}return u}throw new Error("Unknown type "+s)}function i(e){var t=o(e);if("string"===t){if(32>(n=r(e)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(e instanceof Uint8Array){if(256>(n=e.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===t){if(Math.floor(e)!==e)return 9;if(e>=0){if(128>e)return 1;if(256>e)return 2;if(65536>e)return 3;if(4294967296>e)return 5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return 1;if(e>=-128)return 2;if(e>=-32768)return 3;if(e>=-2147483648)return 5;throw new Error("Number too small -0x"+e.toString(16).substr(1))}if("boolean"===t||null===e)return 1;if("object"===t){var n,a=0;if(Array.isArray(e)){n=e.length;for(var s=0;n>s;s++)a+=i(e[s])}else{var l=Object.keys(e);for(n=l.length,s=0;n>s;s++){var c=l[s];a+=i(c)+i(e[c])}}if(16>n)return 1+a;if(65536>n)return 3+a;if(4294967296>n)return 5+a;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+t)}function a(e){var t=new ArrayBuffer(i(e));return n(e,new DataView(t),0),new Uint8Array(t)}function s(e,t,r){return t?new e(t.buffer,t.byteOffset,t.byteLength/(r||1)):void 0}function l(e){return s(DataView,e)}function c(e){return s(Uint8Array,e)}function u(e){return s(Int8Array,e)}function h(e){return s(Int32Array,e,4)}function f(e,t){var r=e.length/2;t||(t=new Int16Array(r));for(var n=0,i=0;r>n;++n,i+=2)t[n]=e[i]<<8^e[i+1]<<0;return t}function d(e,t){var r=e.length/4;t||(t=new Int32Array(r));for(var n=0,i=0;r>n;++n,i+=4)t[n]=e[i]<<24^e[i+1]<<16^e[i+2]<<8^e[i+3]<<0;return t}function p(e,t){var r=e.length;t||(t=new Uint8Array(4*r));for(var n=l(t),i=0;r>i;++i)n.setInt32(4*i,e[i]);return c(t)}function m(e,t,r){var n=e.length,i=1/t;r||(r=new Float32Array(n));for(var o=0;n>o;++o)r[o]=e[o]*i;return r}function v(e,t,r){var n=e.length;r||(r=new Int32Array(n));for(var i=0;n>i;++i)r[i]=Math.round(e[i]*t);return r}function y(e,t){var r,n;if(!t){var i=0;for(r=0,n=e.length;n>r;r+=2)i+=e[r+1];t=new e.constructor(i)}var o=0;for(r=0,n=e.length;n>r;r+=2)for(var a=e[r],s=e[r+1],l=0;s>l;++l)t[o]=a,++o;return t}function _(e){if(0===e.length)return new Int32Array;var t,r,n=2;for(t=1,r=e.length;r>t;++t)e[t-1]!==e[t]&&(n+=2);var i=new Int32Array(n),o=0,a=1;for(t=1,r=e.length;r>t;++t)e[t-1]!==e[t]?(i[o]=e[t-1],i[o+1]=a,a=1,o+=2):++a;return i[o]=e[e.length-1],i[o+1]=a,i}function g(e,t){var r=e.length;t||(t=new e.constructor(r)),r&&(t[0]=e[0]);for(var n=1;r>n;++n)t[n]=e[n]+t[n-1];return t}function x(e,t){var r=e.length;t||(t=new e.constructor(r)),t[0]=e[0];for(var n=1;r>n;++n)t[n]=e[n]-e[n-1];return t}function b(e,t){var r,n,i=e instanceof Int8Array?127:32767,o=-i-1,a=e.length;if(!t){var s=0;for(r=0;a>r;++r)e[r]<i&&e[r]>o&&++s;t=new Int32Array(s)}for(r=0,n=0;a>r;){for(var l=0;e[r]===i||e[r]===o;)l+=e[r],++r;l+=e[r],++r,t[n]=l,++n}return t}function w(e,t,r){return m(b(e,h(r)),t,r)}function S(e,t,r){var n=b(e,h(r));return function(e,t,r){return m(g(e,h(r)),t,r)}(n,t,function(e){return s(Float32Array,e,4)}(n))}function R(e,t,r){return function(e,t){var r,n=t?127:32767,i=-n-1,o=e.length,a=0;for(r=0;o>r;++r)0===(c=e[r])?++a:a+=c===n||c===i?2:c>0?Math.ceil(c/n):Math.ceil(c/i);var s=t?new Int8Array(a):new Int16Array(a),l=0;for(r=0;o>r;++r){var c;if((c=e[r])>=0)for(;c>=n;)s[l]=n,++l,c-=n;else for(;i>=c;)s[l]=i,++l,c-=i;s[l]=c,++l}return s}(function(e,t,r){return x(v(e,t),r)}(e,t),r)}function C(e,t,r,n){var i=new ArrayBuffer(12+n.byteLength),o=new Uint8Array(i),a=new DataView(i);return a.setInt32(0,e),a.setInt32(4,t),r&&o.set(r,8),o.set(n,12),o}function A(e){return C(2,e.length,void 0,c(e))}function E(e){return C(4,e.length,void 0,p(e))}function k(e,t){return C(5,e.length/t,p([t]),c(e))}function P(e){return C(6,e.length,void 0,p(_(e)))}function T(e){return C(8,e.length,void 0,p(function(e){return _(x(e))}(e)))}function M(e,t){return C(9,e.length,p([t]),p(function(e,t){return _(v(e,t))}(e,t)))}function N(e,t){return C(10,e.length,p([t]),function(e,t){var r=e.length;t||(t=new Uint8Array(2*r));for(var n=l(t),i=0;r>i;++i)n.setInt16(2*i,e[i]);return c(t)}(R(e,t)))}function I(e){var t={};return V.forEach((function(r){void 0!==e[r]&&(t[r]=e[r])})),e.bondAtomList&&(t.bondAtomList=E(e.bondAtomList)),e.bondOrderList&&(t.bondOrderList=A(e.bondOrderList)),t.xCoordList=N(e.xCoordList,1e3),t.yCoordList=N(e.yCoordList,1e3),t.zCoordList=N(e.zCoordList,1e3),e.bFactorList&&(t.bFactorList=N(e.bFactorList,100)),e.atomIdList&&(t.atomIdList=T(e.atomIdList)),e.altLocList&&(t.altLocList=P(e.altLocList)),e.occupancyList&&(t.occupancyList=M(e.occupancyList,100)),t.groupIdList=T(e.groupIdList),t.groupTypeList=E(e.groupTypeList),e.secStructList&&(t.secStructList=A(e.secStructList)),e.insCodeList&&(t.insCodeList=P(e.insCodeList)),e.sequenceIndexList&&(t.sequenceIndexList=T(e.sequenceIndexList)),t.chainIdList=k(e.chainIdList,4),e.chainNameList&&(t.chainNameList=k(e.chainNameList,4)),t}function O(e){function t(e){for(var t={},r=0;e>r;r++)t[o()]=o();return t}function r(t){var r=e.subarray(a,a+t);return a+=t,r}function n(t){var r=e.subarray(a,a+t);a+=t;var n=65535;if(t>n){for(var i=[],o=0;o<r.length;o+=n)i.push(String.fromCharCode.apply(null,r.subarray(o,o+n)));return i.join("")}return String.fromCharCode.apply(null,r)}function i(e){for(var t=new Array(e),r=0;e>r;r++)t[r]=o();return t}function o(){var o,l,c=e[a];if(0==(128&c))return a++,c;if(128==(240&c))return a++,t(l=15&c);if(144==(240&c))return a++,i(l=15&c);if(160==(224&c))return a++,n(l=31&c);if(224==(224&c))return o=s.getInt8(a),a++,o;switch(c){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return l=s.getUint8(a+1),a+=2,r(l);case 197:return l=s.getUint16(a+1),a+=3,r(l);case 198:return l=s.getUint32(a+1),a+=5,r(l);case 202:return o=s.getFloat32(a+1),a+=5,o;case 203:return o=s.getFloat64(a+1),a+=9,o;case 204:return o=e[a+1],a+=2,o;case 205:return o=s.getUint16(a+1),a+=3,o;case 206:return o=s.getUint32(a+1),a+=5,o;case 208:return o=s.getInt8(a+1),a+=2,o;case 209:return o=s.getInt16(a+1),a+=3,o;case 210:return o=s.getInt32(a+1),a+=5,o;case 217:return l=s.getUint8(a+1),a+=2,n(l);case 218:return l=s.getUint16(a+1),a+=3,n(l);case 219:return l=s.getUint32(a+1),a+=5,n(l);case 220:return l=s.getUint16(a+1),a+=3,i(l);case 221:return l=s.getUint32(a+1),a+=5,i(l);case 222:return l=s.getUint16(a+1),a+=3,t(l);case 223:return l=s.getUint32(a+1),a+=5,t(l)}throw new Error("Unknown type 0x"+c.toString(16))}var a=0,s=new DataView(e.buffer);return o()}function L(e,t,r,n){switch(e){case 1:return function(e,t){var r=e.length;t||(t=new Float32Array(r/4));for(var n=l(t),i=l(e),o=0,a=0,s=r/4;s>o;++o,a+=4)n.setFloat32(a,i.getFloat32(a),!0);return t}(t);case 2:return u(t);case 3:return f(t);case 4:return d(t);case 5:return c(t);case 6:return y(d(t),new Uint8Array(r));case 7:return y(d(t));case 8:return function(e,t){return g(y(e),t)}(d(t));case 9:return function(e,t,r){return m(y(e,h(r)),t,r)}(d(t),d(n)[0]);case 10:return S(f(t),d(n)[0]);case 11:return m(f(t),d(n)[0]);case 12:return w(f(t),d(n)[0]);case 13:return w(u(t),d(n)[0]);case 14:return b(f(t));case 15:return b(u(t))}}function B(e,t){var r=(t=t||{}).ignoreFields,n={};return U.forEach((function(t){var i=!!r&&-1!==r.indexOf(t),o=e[t];i||void 0===o||(o instanceof Uint8Array?n[t]=L.apply(null,function(e){var t=l(e),r=t.getInt32(0),n=t.getInt32(4),i=e.subarray(8,12);return[r,e=e.subarray(12),n,i]}(o)):n[t]=o)})),n}function D(e){return String.fromCharCode.apply(null,e).replace(/\0/g,"")}function z(e,t){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),B(e instanceof Uint8Array?O(e):e,t)}function F(e,t,r,n){var i=new XMLHttpRequest;i.addEventListener("load",(function(){try{var e=z(i.response);r(e)}catch(e){n(e)}}),!0),i.addEventListener("error",n,!0),i.responseType="arraybuffer",i.open("GET",t+e.toUpperCase()),i.send()}var V=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],U=V.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),G="//mmtf.rcsb.org/v1.0/",j=G+"full/",H=G+"reduced/";e.encode=function(e){return a(I(e))},e.decode=z,e.traverse=function(e,t,r){var n,i,o,a,s,l,c=(r=r||{}).firstModelOnly,u=t.onModel,h=t.onChain,f=t.onGroup,d=t.onAtom,p=t.onBond,m=0,v=0,y=0,_=0,g=0,x=-1,b=e.chainNameList,w=e.secStructList,S=e.insCodeList,R=e.sequenceIndexList,C=e.atomIdList,A=e.bFactorList,E=e.altLocList,k=e.occupancyList,P=e.bondAtomList,T=e.bondOrderList;for(n=0,i=e.chainsPerModel.length;i>n&&!(c&&m>0);++n){var M=e.chainsPerModel[m];for(u&&u({chainCount:M,modelIndex:m}),o=0;M>o;++o){var N=e.groupsPerChain[v];if(h){var I=D(e.chainIdList.subarray(4*v,4*v+4)),O=null;b&&(O=D(b.subarray(4*v,4*v+4))),h({groupCount:N,chainIndex:v,modelIndex:m,chainId:I,chainName:O})}for(a=0;N>a;++a){var L=e.groupList[e.groupTypeList[y]],B=L.atomNameList.length;if(f){var z=null;w&&(z=w[y]);var F=null;e.insCodeList&&(F=String.fromCharCode(S[y]));var V=null;R&&(V=R[y]),f({atomCount:B,groupIndex:y,chainIndex:v,modelIndex:m,groupId:e.groupIdList[y],groupType:e.groupTypeList[y],groupName:L.groupName,singleLetterCode:L.singleLetterCode,chemCompType:L.chemCompType,secStruct:z,insCode:F,sequenceIndex:V})}for(s=0;B>s;++s){if(d){var U=null;C&&(U=C[_]);var G=null;A&&(G=A[_]);var j=null;E&&(j=String.fromCharCode(E[_]));var H=null;k&&(H=k[_]),d({atomIndex:_,groupIndex:y,chainIndex:v,modelIndex:m,atomId:U,element:L.elementList[s],atomName:L.atomNameList[s],formalCharge:L.formalChargeList[s],xCoord:e.xCoordList[_],yCoord:e.yCoordList[_],zCoord:e.zCoordList[_],bFactor:G,altLoc:j,occupancy:H})}_+=1}if(p){var W=L.bondAtomList;for(s=0,l=L.bondOrderList.length;l>s;++s)p({atomIndex1:_-B+W[2*s],atomIndex2:_-B+W[2*s+1],bondOrder:L.bondOrderList[s]})}y+=1}v+=1}if(g=x+1,x=_-1,p&&P)for(s=0,l=P.length;l>s;s+=2){var Y=P[s],X=P[s+1];(Y>=g&&x>=Y||X>=g&&x>=X)&&p({atomIndex1:Y,atomIndex2:X,bondOrder:T?T[s/2]:null})}m+=1}},e.fetch=function(e,t,r){F(e,j,t,r)},e.fetchReduced=function(e,t,r){F(e,H,t,r)},e.version="v1.1.0dev",e.fetchUrl=j,e.fetchReducedUrl=H,e.encodeMsgpack=a,e.encodeMmtf=I,e.decodeMsgpack=O,e.decodeMmtf=B}(t)}(0,Ps);var Ts=Ps;var Ms=pr.Complex,Ns=pr.Chain,Is=pr.Atom,Os=pr.Element,Ls=pr.Helix,Bs=pr.Sheet,Ds=pr.Strand,zs=pr.Bond,Fs=pr.Assembly,Vs=pr.Molecule,Us=function(){function e(t){a(this,e),this._original=Array.from(t),this._original.sort(),this._sum=0;for(var r=0;r<this._original.length;++r)this._sum+=this._original[r]}return l(e,[{key:"compare",value:function(e){var t=e.length;if(t!==this._original.length)return!1;var r,n=0;for(r=0;r<t;++r)n+=e[r];if(n!==this._sum)return!1;var i=Array.from(e);for(i.sort(),r=0;r<t;++r)if(i[r]!==this._original[r])return!1;return!0}}]),e}();Us.prototype.constructor=Us;var Gs=Ue.Type,js=[Gs.HELIX_PI,Gs.BEND,Gs.HELIX_ALPHA,Gs.STRAND,Gs.HELIX_310,Gs.BRIDGE,Gs.TURN,Gs.COIL],Hs=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e,t){var r;return a(this,s),(r=o.call(this,e,t))._options.fileType="mmtf",r}return l(s,[{key:"_onModel",value:function(e){}},{key:"_onChain",value:function(e){if(0===e.modelIndex){var t=new Ns(this._complex,e.chainName);this._complex._chains[e.chainIndex]=t,t._index=e.chainIndex}}},{key:"_onGroup",value:function(e){if(0===e.modelIndex&&(!this.settings.now.nowater||"HOH"!==e.groupName&&"WAT"!==e.groupName)){var t=this._complex._chains[e.chainIndex],r=e.insCode.charCodeAt(0)?e.insCode:"",n=t.addResidue(e.groupName,e.groupId,r);n._index=e.groupIndex,this._updateSecStructure(this._complex,n,e)}}},{key:"_onAtom",value:function(e){if(0===e.modelIndex){var t=e.altLoc.charCodeAt(0)?e.altLoc:"",r=new Is(e.groupIndex,e.atomName,Os.getByName(e.element.toUpperCase()),new i.Pa4(e.xCoord,e.yCoord,e.zCoord),Os.Role[e.atomName],!1,e.atomId,t,e.occupancy,e.bFactor,e.formalCharge);this._complex._atoms[e.atomIndex]=r,r.index=e.atomIndex,this._serialAtomMap[e.atomId]=r}}},{key:"_onBond",value:function(e){var t=Math.max(e.atomIndex1,e.atomIndex2);if(!(t>=this._complex._atoms.length)){var r=Math.min(e.atomIndex1,e.atomIndex2);this._complex.addBond(this._complex._atoms[r],this._complex._atoms[t],e.bondOrder,zs.BondType.UNKNOWN,!0)}}},{key:"_updateSecStructure",value:function(e,t,r){if(!(0,n.isUndefined)(r)&&r.secStruct===this._ssType)return t._secondary=this._ssStruct,void(this._ssStruct&&(this._ssStruct.term=t));if(!(0,n.isUndefined)(r)){var i=js[r.secStruct];this._ssType=r.secStruct,this._ssStart=t;var o=null;switch(this._ssType){case-1:case 7:break;case 0:case 2:case 4:o=new Ls([3,-1,1,-1,5][this._ssType],t,t,0,"","",0),e._helices.push(o);break;case 3:var a=new Bs("",0);e._sheets.push(a),o=new Ds(a,t,t,0,null,null);break;default:void 0!==i&&(o=new Ue(i,t,t))}this._ssStruct=o,t._secondary=o,o&&e.structures.push(o)}}},{key:"_updateMolecules",value:function(e){var t=e.entityList;if(t)for(var r=e.chainsPerModel[0],n=0;n<t.length;n++){for(var i=t[n],o=i.chainIndexList,a=[],s=0;s<o.length;s++){var l=o[s];if(!(l>=r)){var c=this._complex._chains[l];a=a.concat(c._residues.slice())}}var u=new Vs(this._complex,i.description,n+1);u.residues=a,this._complex._molecules[n]=u}}},{key:"_traverse",value:function(e){var t=this,r=this._complex.metadata;r.id=e.structureId,r.title=[],r.title[0]=e.title,r.date=e.releaseDate,r.format="mmtf";var n={onModel:function(e){t._onModel(e)},onChain:function(e){t._onChain(e)},onGroup:function(e){t._onGroup(e)},onAtom:function(e){t._onAtom(e)},onBond:function(e){t._onBond(e)}};this._ssType=-1,this._ssStruct=null,this._ssStart=null,Ts.traverse(e,n),this._updateSecStructure(this._complex),this._updateMolecules(e)}},{key:"_linkAtomsToResidues",value:function(){for(var e=0;e<this._complex._atoms.length;++e){var t=this._complex._atoms[e],r=this._complex._residues[t.residue];t.residue=r,r._atoms.push(t)}}},{key:"_findSynonymousChains",value:function(){for(var e={},t=0;t<this._complex._chains.length;++t){var r=this._complex._chains[t],n=r.getName();e.hasOwnProperty(n)||(e[n]=[]),e[n].push(r._index)}return e}},{key:"_parseAssemblyInfo",value:function(e){var t,r,n,o=[],a=this.logger;for(t=0;t<e.bioAssemblyList.length;++t){var s=e.bioAssemblyList[t];if(0!==s.transformList.length){var l=s.transformList[0].chainIndexList,c=new Us(l),u={};for(r=0;r<l.length;++r)u[this._complex._chains[l[r]].getName()]=1;var h=[],f=void 0;for(f in u)u.hasOwnProperty(f)&&Array.prototype.push.apply(h,this._chainsByName[f]);c.compare(h)||a.debug("MMTF: Assembly is missing some of the synonymous chains. Skipping...");var d=new Fs(this._complex);for(f in u)u.hasOwnProperty(f)&&d.addChain(f);for(d.addMatrix((new i.yGw).fromArray(s.transformList[0].matrix).transpose()),r=1;r<s.transformList.length;++r){var p=s.transformList[r];if(c.compare(p.chainIndexList)){var m=(new i.yGw).fromArray(p.matrix).transpose();for(n=0;n<d.matrices.length&&!d.matrices[n].equals(m);++n);n===d.matrices.length&&d.addMatrix(m)}else a.debug("MMTF: Chain lists differ for different transforms in one assembly. Skipping...")}d.finalize(),o.push(d)}}return o}},{key:"_markHeteroAtoms",value:function(e){for(var t=e.chainsPerModel[0],r=0;r<e.entityList.length;++r){var n=e.entityList[r];if("polymer"!==n.type)for(var i=0;i<n.chainIndexList.length;++i){var o=n.chainIndexList[i];if(!(o>=t))for(var a=this._complex._chains[o],s=0;s<a._residues.length;++s)for(var l=a._residues[s],c=0;c<l._atoms.length;++c)l._atoms[c].het=!0}}}},{key:"_joinSynonymousChains",value:function(){var e,t,r=[],n={};for(e=0;e<this._complex._chains.length;++e){var i=this._complex._chains[e],o=i.getName();if(n.hasOwnProperty(o)){var a=n[o];for(t=0;t<i._residues.length;++t){var s=i._residues[t];a._residues.push(s),s._chain=a}}else n[o]=i,i._index=r.length,r.push(i)}this._complex._chains=r}},{key:"parseSync",value:function(){var e=Ts.decode(this._data);return this._complex=new Ms,this._serialAtomMap={},this._traverse(e),this._linkAtomsToResidues(),this._markHeteroAtoms(e),this._chainsByName=this._findSynonymousChains(),Array.prototype.push.apply(this._complex.units,this._parseAssemblyInfo(e)),this._joinSynonymousChains(),this._complex.finalize({needAutoBonding:!1,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap}),this._complex}}],[{key:"canProbablyParse",value:function(e){return(0,n.isArrayBuffer)(e)&&223==(1|new Uint8Array(e,0,1)[0])}}]),s}(ss);Hs.formats=["mmtf"],Hs.extensions=[".mmtf"],Hs.binary=!0;var Ws=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r){var o;return a(this,i),o=n.call(this,"data:".concat(t,":").concat(r,": ").concat(e)),Error.captureStackTrace&&Error.captureStackTrace(c(o),i),o.name="ParsingError",o.parseLine=t,o.parseColumn=r,o}return l(i)}(T(Error));function Ys(e){return 32===e||10===e||13===e||9===e}function Xs(e,t,r){for(var n=t.length,i=-1;r<n&&(i=t.charCodeAt(r))!==e&&10!==i;)++r;return i===e?r:-1}function qs(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var $s=pr.Complex,Zs=pr.Element,Ks=pr.Helix,Qs=pr.Sheet,Js=pr.Strand,el=pr.Assembly,tl=pr.Molecule,rl=["auth_seq_id","Cartn_x","Cartn_y","Cartn_z","label_atom_id"],nl={helx:"helix",turn:"turn",strn:"strand"};function il(e){return null==e||(0,n.isArray)(e)?e:[e]}function ol(e){var t=4===e.trim().length;return e.slice(0,t?1:2).trim()}var al=function(e){h(r,e);var t=qs(r);function r(e){var n;return a(this,r),(n=t.call(this)).name="AtomDataError",n.message=e,n}return l(r)}(T(Error));function sl(e,t){for(var r=(e=(0,n.isString)(e)?e:"".concat(e)).replace(/\)\s*\(/g,"!").replace(/[()']/g,"").split("!"),o=[],a=0,s=r.length;a<s;++a){for(var l=r[a].split(","),c=[],u=0,h=0,f=l.length;h<f;++h){var d=l[h];if(d.includes("-"))for(var p=d.split("-"),m=parseInt(p[0],10),v=parseInt(p[1],10);m<=v;++m)c[u++]=t[m];else c[u++]=t[d]}o.push(c)}var y=[],_=0;return function e(t,r){for(var n=0,a=o[t].length;n<a;++n){var s=r?r.clone():new i.yGw;s.multiplyMatrices(o[t][n],s),0===t?y[_++]=s:e(t-1,s)}}(o.length-1),y}var ll=function(e){h(r,e);var t=qs(r);function r(e,n){var i;return a(this,r),(i=t.call(this,e,n)).asymDict={},i.molecules=[],i._options.fileType="cif",i}return l(r,[{key:"parseSync",value:function(){this.logger.info("Parsing CIF file..");var e=function(e){var t,r,i,o,a=0,s=0,l=e.length,c=NaN,u=!0,h=1,f=1,d=0,p={},m={},v=[],y=0,_="",g=[],x=0;function b(){var t;if((46===c||63===c)&&(a+1>=l||Ys(e.charCodeAt(a+1))))return++f,void++a;if(u&&59===c){s=a;var r=0;do{if(-1===(s=Xs(10,e,s+1)))throw new Ws("Unterminated text block found",h,f);++r}while(s+1<l&&e.charCodeAt(s+1)!==c||s+1>=l);return t=e.substring(a+1,s).replace(/\r/g,""),a=s+2,h+=r,f=1,u=!1,t}if(39===c||34===c){s=a;do{if(-1===(s=Xs(c,e,s+1)))throw new Ws("Unterminated quoted string found",h,f)}while(s+1<l&&!Ys(e.charCodeAt(s+1)));return t=e.substring(a+1,s),f+=s-a+1,a=s+1,t}for(s=a;s<l&&!Ys(e.charCodeAt(s));)++s;t=e.substring(a,s),f+=s-a,a=s;var n=Number(t);return Number.isNaN(n)?t:n}for(;a<=l;){if(13===(c=e.charCodeAt(a)));else if(10===c)u=!0,++h,f=1;else{if(32!==c&&9!==c){if(35===c){if(-1===(a=Xs(10,e,a+1)))break;continue}if(0===d){if(68!==c&&100!==c||"ata_"!==e.substr(a+1,4).toLowerCase()){if(Number.isNaN(c))break;throw new Ws("Unexpected character in state ".concat(d),h,f)}for(t=s=a+5;s<l&&!Ys(e.charCodeAt(s));)++s;if(f+=s-a,t<(a=s)){p[e.substring(t,a)]=m={},d=1;continue}throw new Ws("Data block name missing",h,f)}if(1===d){if(68!==c&&100!==c||"ata_"!==e.substr(a+1,4).toLowerCase()){if(95===c){for(t=s=a+1;s<l&&!Ys(e.charCodeAt(s));)++s;if(f+=s-a,t<(a=s)){_=e.substring(t,a),d=2;continue}throw new Ws("Tag name missing",h,f)}if(76!==c&&108!==c||"oop_"!==e.substr(a+1,4).toLowerCase()){if(Number.isNaN(c))break;throw new Ws("Unexpected character in state ".concat(d),h,f)}if(f+=5,(a+=5)<l&&!Ys(e.charCodeAt(a)))throw new Ws("Unexpected character in state ".concat(d),h,f);v=[],y=0,g=[],x=0,d=3;continue}d=0;continue}if(2===d){if(Number.isNaN(c))break;r=b(),(0,n.set)(m,_,r),d=1;continue}if(3===d){if(95===c){for(t=s=a+1;s<l&&!Ys(e.charCodeAt(s));)++s;if(f+=s-a,t<(a=s)){o=e.substring(t,a),v[y++]=o;continue}throw new Ws("Tag name missing",h,f)}if(y>0){for(var w=0;w<y;++w)r=[],g[w]=r,(0,n.set)(m,v[w],r);d=4;continue}throw new Ws("Data tags are missing inside a loop",h,f)}if(4===d){68!==c&&100!==c||"ata_"!==e.substr(a+1,4).toLowerCase()?95===c?d=1:76!==c&&108!==c||"oop_"!==e.substr(a+1,4).toLowerCase()?Number.isNaN(c)?d=0:(i=b(),g[x%y].push(i),++x):d=1:d=0;continue}throw new Ws("Unexpected internal state ".concat(d),h,f)}u=!1,++f}++a}if(2===d)throw new Ws("Unexpected end of file in state ".concat(d),h,f);return p}(this._data);return this._toComplex(e)}},{key:"_toComplex",value:function(e){var t=new $s,r=e[Object.keys(e)[0]];return this._extractAtoms(t,r),this._extractSecondary(t,r),this._extractAssemblies(t,r),this._extractMolecules(t,r),this._extractMetadata(t,r),t.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing}),t}},{key:"_extractMetadata",value:function(e,t){var r=e.metadata;r.id=t.entry.id,r.classification=t.struct_keywords.pdbx_keywords;var n=t.database_PDB_rev;r.date=n&&n.date_original?n.date_original:"",r.format="cif",r.title=[],r.title[0]=t.struct.title}},{key:"_extractMolecules",value:function(e,t){var r,n=il(t.entity.pdbx_description),i=n.length;for(r=0;r<i;r++)this.molecules[r]?this.molecules[r].name=n[r]:this.molecules[r]={name:n[r],residues:[]};var o=e.getMolecules();for(r=0;r<i;r++){var a=this.molecules[r];o[r]=new tl(e,a.name,r+1),o[r].residues=a.residues}}},{key:"_extractAtoms",value:function(e,t){var r=t.atom_site;if(!r)throw new al("CIF parsing error: atom_site is not specified!");for(var n=0,o=rl.length;n<o;++n)if(!r[rl[n]])throw new al("CIF parsing error: requires field ".concat(rl[n]," not found!"));for(var a=this.asymDict,s=il(r.auth_seq_id),l=il(r.Cartn_x),c=il(r.Cartn_y),u=il(r.Cartn_z),h=il(r.label_atom_id),f=h.length,d=il(r.group_PDB)||[],p=il(r.auth_asym_id)||[],m=il(r.label_asym_id)||[],v=il(r.id)||[],y=il(r.pdbx_PDB_ins_code)||[],_=il(r.label_comp_id)||[],g=il(r.type_symbol)||[],x=il(r.B_iso_or_equiv)||[],b=il(r.occupancy)||[],w=il(r.pdbx_formal_charge)||[],S=il(r.label_alt_id)||[],R=il(r.pdbx_PDB_model_num)||[],C=il(r.label_entity_id)||[],A=null,E=null,k=0;k<f;++k)if(1===(R[k]||1)){var P=String(p[k]||" ");A&&A.getName()===P||(A=e.getChain(P)||e.addChain(P)),a[String(m[k]||" ")]=P;var T=s[k],M=String(y[k]||" "),N=String(_[k]||"");if(!E||E.getSequence()!==T||E.getICode()!==M){E=A.addResidue(N,T,M);var I=C[k]-1,O=this.molecules[I];O||(this.molecules[I]={name:"",residues:[]},O=this.molecules[I]),O.residues.push(E)}var L=h[k],B=g[k]||ol(L),D=Zs.getByName(B),z=Zs.Role[L.trim()],F=new i.Pa4(l[k],c[k],u[k]),V="HETATM"===d[k]||!1,U=v[k]||k,G=x[k]||0,j=b[k]||0,H=String(S[k]||""),W=w[k]||0;E.addAtom(L,D,F,z,V,U,H,j,G,W)}}},{key:"_extractSecondary",value:function(e,t){t.struct_conf&&this._extractConfs(e,t.struct_conf),t.struct_sheet_range&&this._extractSheets(e,t.struct_sheet_range)}},{key:"_extractSheets",value:function(e,t){var r=this.asymDict;if(t.sheet_id&&t.id&&t.beg_label_seq_id&&t.end_label_seq_id&&t.beg_label_asym_id)for(var n=e._sheets,i=il(t.sheet_id),o=il(t.id),a=il(t.beg_auth_seq_id),s=il(t.end_auth_seq_id),l=il(t.beg_label_asym_id),c=il(t.pdbx_beg_PDB_ins_code)||[],u=il(t.pdbx_end_PDB_ins_code)||[],h=0,f=o.length;h<f;++h){var d=e.getChain(r[l[h]]),p=R(i[h]),m=a[h],v=s[h],y=c[h]||" ",_=u[h]||" ",g=d.findResidue(m,y),x=d.findResidue(v,_);if(g&&x){for(var b=new Js(p,g[0],x[0],0,null,null),w=d.getResidues(),S=g[1];S<=x[1];++S)w[S]._secondary=b;p.addStrand(b),e.structures.push(b)}}function R(e){for(var t=n.length,r=0;r<t;++r)if(n[r]._name===e)return n[r];return n[t]=new Qs(e,0),n[t]}}},{key:"_extractConfs",value:function(e,t){var r=this.asymDict;if(t.conf_type_id&&t.beg_label_seq_id&&t.end_label_seq_id&&t.beg_label_asym_id)for(var n,i,o=il(t.conf_type_id),a=il(t.beg_auth_seq_id),s=il(t.pdbx_beg_PDB_ins_code)||[],l=il(t.end_auth_seq_id),c=il(t.pdbx_end_PDB_ins_code)||[],u=il(t.details)||[],h=il(t.pdbx_PDB_helix_length)||[],f=il(t.pdbx_PDB_helix_class)||[],d=il(t.id)||[],p=il(t.beg_label_asym_id),m=0,v=o.length;m<v;++m){var y=(n=o[m],i=void 0,(i=/[A-Za-z]+/.exec(n))?nl[i[0].toLowerCase()]:null);if(y){var _=d[m]||o[m],g=e.getChain(r[p[m]]),x=a[m],b=l[m],w=s[m]||" ",S=c[m]||" ",R=g.findResidue(x,w),C=g.findResidue(b,S);if(R&&C){var A=u[m]||"",E=h[m]||0,k=f[m]||" ",P=void 0;if("helix"===y){var T=e._helices.length;P=new Ks(k,R[0],C[0],T,_,A,E),e.addHelix(P),e.structures.push(P)}else"turn"===y?(P=new Ue(Ue.Type.TURN,R[0],C[0]),e.structures.push(P)):P=null;if(P)for(var M=g.getResidues(),N=R[1];N<=C[1];++N)M[N]._secondary=P}}}}},{key:"_extractAssemblies",value:function(e,t){var r=this.asymDict,n=t.pdbx_struct_assembly_gen;if(n){var o=il(n.assembly_id),a=il(n.oper_expression),s=il(n.asym_id_list);if(o&&a&&s){var l=function(e){if(!e)return null;var t=il(e.id),r=e.matrix,n=e.vector;if(!t||!r||!n)return null;for(var o=[],a=0,s=t.length;a<s;++a){for(var l=new i.yGw,c=l.elements,u=0;u<3;++u){var h=r[u+1];c[u]=il(h[1])[a],c[u+4]=il(h[2])[a],c[u+8]=il(h[3])[a],c[u+12]=il(n[u+1])[a]}o[t[a]]=l}return o}(t.pdbx_struct_oper_list);if(l)for(var c=0,u=o.length;c<u;++c){for(var h=new el(e),f=sl(a[c],l),d=s[c].split(","),p=0,m=d.length;p<m;++p){var v=d[p].trim();v.length>0&&h.addChain(r[v])}h.matrices=f,e.units.push(h)}}}}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&/^\s*data_/i.test(e)}}]),r}(ss);ll.formats=["cif","mmcif"],ll.extensions=[".cif",".mmcif"];var cl=function(){function e(){a(this,e),Re(this,"_xyz2crs",[]),Re(this,"_origin",new i.Pa4(0,0,0)),this._header={},this._boxSize=new i.Pa4,this._boxStart=new i.Pa4,this._header.delta={},this._header.extent=[],this._header.nstart=[],this._header.grid=[],this._header.crs2xyz=[],this._header.cellDims=new i.Pa4,this._header.angles=[],this._header.origin=new i.Pa4(0,0,0),this._header.dmin=0,this._header.dmean=0,this._header.dmax=0}return l(e,[{key:"_typedCheck",value:function(){if((0,n.isTypedArray)(this._buff))this._buff=this._buff.buffer;else if(!(0,n.isArrayBuffer)(this._buff))throw new TypeError("Expected ArrayBuffer or TypedArray")}},{key:"_fillHeader",value:function(e,t){for(var r in e)if(e.hasOwnProperty(r))switch(e[r][0]){case 0:this._header[r]=t[e[r][1]][e[r][2]];break;case 2:this._parseArray(this._header[r],t[e[r][1]],e[r][2]);break;case 1:this._parseVector(this._header[r],t[e[r][1]],e[r][2]);break;case 3:this._header[r]=new Uint8Array(t[e[r][1]],4*[e[r][2]],4*[e[r][3]])}}},{key:"_parseVector",value:function(e,t,r){var n=[t[r],t[r+1],t[r+2]];e.x=n[0],e.y=n[1],e.z=n[2]}},{key:"_parseArray",value:function(e,t,r){e[0]=t[r],e[1]=t[r+1],e[2]=t[r+2]}},{key:"_parseHeader",value:function(e){}},{key:"_setAxisIndices",value:function(){}},{key:"_setOrigins",value:function(){}},{key:"_getAxis",value:function(){var e=this._header,t=e.cellDims.x/e.grid[0],r=e.cellDims.y/e.grid[1],n=e.cellDims.z/e.grid[2],o=v(e.angles,3),a=o[0],s=o[1],l=o[2],c=Math.cos(s),u=(Math.cos(a)-Math.cos(s)*Math.cos(l))/Math.sin(l),h=Math.sqrt(1-c*c-u*u);return[new i.Pa4(t,0,0),new i.Pa4(Math.cos(l)*r,Math.sin(l)*r,0),new i.Pa4(c*n,u*n,h*n)]}},{key:"_getXYZdim",value:function(){return[this._header.extent[this._xyz2crs[0]],this._header.extent[this._xyz2crs[1]],this._header.extent[this._xyz2crs[2]]]}},{key:"_getVolumeInfo",value:function(){var e=(0,n.pick)(this._header,["dmean","dmin","dmax","sd","delta"]);return e.obtuseAngle=this._header.angles.map((function(e){return Number(e>=Math.PI/2)})),e}},{key:"_setBoxParams",value:function(e,t,r){var n=this,o=0,a=0,s=v(this._header.angles,3),l=s[0],c=s[1];s[2]>=Math.PI/2&&(o+=Math.abs(t.x)),c>=Math.PI/2&&(o+=Math.abs(r.x)),l>=Math.PI/2&&(a+=Math.abs(r.y)),this._boxStart=new i.Pa4(this._origin.x-o,this._origin.y-a,this._origin.z),this._boxSize=new i.Pa4(Math.abs(e.x)+Math.abs(t.x)+Math.abs(r.x),Math.abs(t.y)+Math.abs(r.y),Math.abs(r.z));var u=function(e,t){return Math.abs(e[t])/n._boxSize[t]};this._header.delta.x=u(t,"x"),this._header.delta.y=u(r,"x"),this._header.delta.z=u(r,"y")}},{key:"_getXYZbox",value:function(){return new i.ZzF(this._boxStart.clone(),this._boxStart.clone().add(this._boxSize))}},{key:"_toXYZData",value:function(){}},{key:"parse",value:function(e){return this._parseHeader(e),this._setOrigins(),new fr(Float32Array,this._getXYZdim(),this._getXYZbox(),1,this._toXYZData(),this._getVolumeInfo())}}]),e}();function ul(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var hl={extent:[2,"u32",0],type:[0,"u32",3],nstart:[2,"i32",4],grid:[2,"u32",7],cellDims:[1,"f32",10],angles:[2,"f32",13],crs2xyz:[2,"i32",16],dmin:[0,"f32",19],dmax:[0,"f32",20],dmean:[0,"f32",21],ispg:[0,"u32",22],nsymbt:[0,"u32",23],lksflg:[0,"u32",24],customData:[3,"buffer",25,9],origin:[1,"f32",34],map:[3,"buffer",52,1],machine:[0,"u32",53],sd:[0,"f32",54],nlabel:[0,"f32",55],label:[3,"buffer",56,200]},fl=function(e){h(r,e);var t=ul(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"_parseHeader",value:function(e){this._buff=e,this._typedCheck();var t={};t.u32=new Uint32Array(this._buff,0,56),t.i32=new Int32Array(this._buff,0,56),t.f32=new Float32Array(this._buff,0,56),t.buffer=this._buff;var r=this._header;this._fillHeader(hl,t),r.angles.forEach((function(e,t,r){r[t]*=Math.PI/180}))}},{key:"_setAxisIndices",value:function(){var e=this._header;0===e.cellDims.x&&0===e.cellDims.y&&0===e.cellDims.z&&e.cellDims.set(1,1,1);var t=this._header.crs2xyz;0===t[0]&&0===t[1]&&0===t[2]&&(t[0]=1,t[1]=2,t[2]=3);var r=this._xyz2crs;r[t[0]-1]=0,r[t[1]-1]=1,r[t[2]-1]=2}},{key:"_setOrigins",value:function(){var e=v(this._getAxis(),3),t=e[0],r=e[1],n=e[2];this._setAxisIndices();var i=this._header,o=this._xyz2crs;if(0===i.origin.x&&0===i.origin.y&&0===i.origin.z?(this._origin.addScaledVector(t,i.nstart[o[0]]),this._origin.addScaledVector(r,i.nstart[o[1]]),this._origin.addScaledVector(n,i.nstart[o[2]])):this._origin=i.origin,t.multiplyScalar(i.extent[o[0]]-1),r.multiplyScalar(i.extent[o[1]]-1),n.multiplyScalar(i.extent[o[2]]-1),2!==i.type)throw new Error("CCP4: Unsupported format ".concat(i.type));this._data=new Float32Array(this._buff,1024+i.nsymbt,i.extent[0]*i.extent[1]*i.extent[2]),this._setBoxParams(t,r,n)}},{key:"_toXYZData",value:function(){var e=this._header,t=this._data,r=this._xyz2crs,n=new Float32Array(t.length),i=this._getXYZdim(),o=i[0],a=i[1],s=0,l=[];for(l[2]=0;l[2]<e.extent[2];l[2]++)for(l[1]=0;l[1]<e.extent[1];l[1]++)for(l[0]=0;l[0]<e.extent[0];l[0]++,s++)n[l[r[0]]+o*(l[r[1]]+a*l[r[2]])]=t[s];return n}}]),r}(cl),dl=function(e){h(r,e);var t=ul(r);function r(e,n){var i;return a(this,r),(i=t.call(this,e,n))._options.fileType="ccp4",i.model=new fl,i}return l(r,[{key:"parseSync",value:function(){return this.model.parse(this._data)}}],[{key:"canProbablyParse",value:function(e){return!1}}]),r}(ss);dl.formats=["ccp4"],dl.extensions=[".ccp4",".map",".mrc"],dl.binary=!0;var pl=pr.Complex,ml=pr.Element,vl=pr.Molecule,yl=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e,t){var r;return a(this,s),(r=o.call(this,e,t))._complex=null,r._atomsInf=null,r._options.fileType="xyz",r._fileName=t.name,r}return l(s,[{key:"_parseToAtomsInf",value:function(e){var t=e.indexOf("\n"),r=parseInt(e.substring(0,t),10),n=e.indexOf("\n",t+1),i=e.slice(t+1,n).trim();0===i.length&&(i=this._fileName);var o=n+e.substring(n).search(/\S/);this._atomsInf=e.substring(o).split(/[\s,]*\n[\s,]*/),Number.isNaN(r)||this._atomsInf.length-1===r?(this._complex.metadata.format="xyz",this._complex.name=i):this._complex.error={message:"wrong number of atoms"}}},{key:"_parseAtomsInf",value:function(){for(var e=this._complex.addChain("A").addResidue("UNK",1," "),t=0;t<this._atomsInf.length-1;t++){var r=this._atomsInf[t].split(/[\s,]+/);if(4!==r.length){this._complex.error={message:"missed parameters"};break}var n=t+1,o=r[0],a=new i.Pa4(parseFloat(r[1]),parseFloat(r[2]),parseFloat(r[3])),s=ml.getByName(o);e.addAtom(o,s,a,void 0,!0,n," ",1,1,0)}var l=new vl(this._complex,this._complex.name,1);l.residues=e,this._complex._molecules[0]=l}},{key:"parseSync",value:function(){var e=this._complex=new pl;if(this._parseToAtomsInf(this._data),this._parseAtomsInf(),this._complex.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap}),this._complex=null,this._atomsInf=null,e.error)throw new Error(e.error.message);return e}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&/^\s*\d+ *\n[^\n]*\n\s*\w{1,3}\s+-?\d/.test(e)}}]),s}(ss);Re(yl,"formats",["xyz"]),Re(yl,"extensions",[".xyz"]);var _l=pr.Complex,gl=pr.Element,xl=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e,t){var r;return a(this,s),(r=o.call(this,e,t))._options.fileType="pubchem+json",r}return l(s,[{key:"parseSync",value:function(){return this.logger.info("Parsing PubChem JSON file..."),this._toComplex(JSON.parse(this._data))}},{key:"_toComplex",value:function(e){var t=new _l,r=e.PC_Compounds&&e.PC_Compounds[0];return r&&(this._extractAtoms(t,r),t.finalize({needAutoBonding:!1,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing})),t}},{key:"_extractAtoms",value:function(e,t){var r=t.atoms&&t.atoms.aid,o=r&&t.atoms.element;if(!o||r.length!==o.length)throw new Error("Unable to parse atom elements");o=(0,n.fromPairs)((0,n.zip)(r,o));var a={},s=t.coords&&t.coords[0],l=s&&s.conformers&&s.conformers[0],c=l&&l.x,u=l&&l.y,h=l&&l.z||[];if(!(r=s&&s.aid)||!c||!u)throw new Error("Coordinates are not found in the file");for(var f=e.addChain(" ").addResidue("UNK",1," "),d=0,p=r.length;d<p;++d){var m=r[d],v=gl.ByAtomicNumber[o[m]],y=new i.Pa4(c[d],u[d],h[d]||0);a[m]=f.addAtom(v.name,v,y,void 0,!0,m," ",1,0,0)}var _=t.bonds&&t.bonds.aid1,g=t.bonds&&t.bonds.aid2,x=t.bonds&&t.bonds.order||[];if(_&&g&&_.length===g.length)for(var b=0,w=_.length;b<w;++b)e.addBond(a[_[b]],a[g[b]],x[b]||1,0,!0)}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&"{"===e[0]}}]),s}(ss);xl.formats=["pubchem","pubchem+json","pc"],xl.extensions=[".json"];var bl=function(){function e(t){a(this,e),this._strings=t.split(/\r?\n|\r/),this._currentStart=0,this._currentStringIndx=0}return l(e,[{key:"setStart",value:function(e){e>=this._strings.length?(this._currentStart=this._strings.length-1,this._currentStringIndx=this._strings.length-1):(this._currentStart=e,this._currentStringIndx=e)}},{key:"getNextString",value:function(){return this._strings[++this._currentStringIndx]}},{key:"getCurrentString",value:function(){return this._strings[this._currentStringIndx]}},{key:"getStringFromStart",value:function(e){return this._currentStringIndx=this._currentStart+e,this._strings[this._currentStart+e]}},{key:"findNextDataItem",value:function(){for(var e=this.getNextString(),t=!1;!(0,n.isUndefined)(e)&&"$$$$"!==e.trim();){if(e.match(/>\s+<(.*)>/)){t=!0;break}e=this.getNextString()}return t}},{key:"findNextCompoundStart",value:function(){for(var e=this.getCurrentString();!(0,n.isUndefined)(e)&&"$$$$"!==e.trim();)e=this.getNextString();return this.setStart(++this._currentStringIndx),this.probablyHaveDataToParse()}},{key:"probablyHaveDataToParse",value:function(){return this._currentStringIndx<this._strings.length-2}}]),e}();var wl=pr.Complex,Sl=pr.Element,Rl=pr.Bond,Cl=pr.Molecule,Al=[0,3,2,1,0,-1,-2,-3],El=[0,1,2,3,1,1,1,2],kl=[Rl.BondType.UNKNOWN,Rl.BondType.COVALENT,Rl.BondType.COVALENT,Rl.BondType.COVALENT,Rl.BondType.AROMATIC,Rl.BondType.UNKNOWN,Rl.BondType.AROMATIC,Rl.BondType.AROMATIC],Pl=/.*(M\s\sEND).*|.*(^$$$$).*|.*>\s+<(.+)>.*/,Tl=/.*($$$$).*|.*>\s+<(.+)>.*/,Ml=["name","id","title"],Nl={name:["PUBCHEM_IUPAC_TRADITIONAL_NAME",/PUBCHEM_(.+)_NAME/,/(.+)name/,/(.+)NAME/],id:["PUBCHEM_COMPOUND_CID","id","ID",/.*CID/,/.*ID/,/.*id/],title:["msg","MSG","message","title","description","desc"]},Il=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e,t){var r;return a(this,s),(r=o.call(this,e,t))._format="sdf",r._complex=null,r._chain=null,r._residue=null,r._molecules=null,r._metadata={},r._metadata.molecules=[],r._currentMolProps={},r._compoundIndx=-1,r._assemblies=[],r._atomsParsed=0,r._atomsIndexes=[],r}return l(s,[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&Pl.test(e)}},{key:"_parseHeader",value:function(e){var t={};t.name=e.getStringFromStart(0);var r=parseInt(e.getStringFromStart(1).substr(10,6).trim(),10);t.date=r.toString()||"",t.title=e.getStringFromStart(2),this._metadata.molecules.push(t)}},{key:"_parseAtoms",value:function(e,t){var r,n=this._atomsParsed,o=function(e){if(!e)return"A";for(var t=[];e;)t.push(65+e%26),e=Math.trunc(e/26);return t.length>1&&(t.reverse(),t[0]-=1),String.fromCharCode.apply(String,t)}(this._compoundIndx);this._chain=this._complex.getChain(o)||this._complex.addChain(o),this._residue=this._chain.addResidue("UNK",1," ");for(var a=0;a<t;a++){r=e.getNextString(),n++;var s=parseFloat(r.substr(0,10)),l=parseFloat(r.substr(10,10)),c=parseFloat(r.substr(20,10)),u=Al[parseInt(r.substr(36,3),10)],h=new i.Pa4(s,l,c),f=r.substr(31,3).trim().toUpperCase(),d=Sl.getByName(f);this._atomsIndexes[f]||(this._atomsIndexes[f]=0),this._atomsIndexes[f]+=1,f+=this._atomsIndexes[f],this._residue.addAtom(f,d,h,void 0,!0,n," ",1,0,u)}}},{key:"_parseBonds",value:function(e,t){for(var r,n=0;n<t;n++){r=e.getNextString();var i=parseInt(r.substr(0,3),10)+this._atomsParsed,o=parseInt(r.substr(3,3),10)+this._atomsParsed,a=parseInt(r.substr(6,3),10);if(i>o){var s=[o,i];i=s[0],o=s[1]}this._complex.addBond(i,o,El[a]||1,kl[a]||Rl.BondType.UNKNOWN,!0)}}},{key:"_parseMOL",value:function(e){this._compoundIndx++,this._parseHeader(e);var t=e.getStringFromStart(3),r=parseInt(t.substr(0,3),10),n=parseInt(t.substr(3,3),10);this._parseAtoms(e,r),this._parseBonds(e,n),this._atomsParsed+=r,this._metadata.molecules[this._compoundIndx]._residues=[],this._metadata.molecules[this._compoundIndx]._residues.push(this._residue)}},{key:"_parseDataItem",value:function(e){for(var t=e.getCurrentString(),r=[],n=e.getNextString();""!==n.trim();)r.push(n),n=e.getNextString();1===r.length&&(r=v(r,1)[0]),this._currentMolProps[t.replace(/[<>]/g,"").trim()]=r}},{key:"_parseCompound",value:function(e){if(this._parseMOL(e),"sdf"===this._format){for(this._currentMolProps={};e.findNextDataItem();)this._parseDataItem(e);if(0!==Object.keys(this._currentMolProps).length){var t=this._metadata.molecules[this._compoundIndx];t.props=this._currentMolProps,this._tryToUpdateMoleculeData(t)}}}},{key:"_fixBondsArray",value:function(){for(var e=this._serialAtomMap,t=this._complex._bonds,r=0;r<t.length;r++){var n=t[r];n._right<n._left&&console.log("_fixBondsArray: Logic error."),n._left=e[n._left]||null,n._right=e[n._right]||null}}},{key:"_buildAssemblies",value:function(){var e=this._complex._chains;if(1===e.length)return this._assemblies;for(var t=0;t<e.length;t++){var r=new Ct(this._complex),n=new i.yGw;r.addMatrix(n),r.addChain(e[t]._name),this._assemblies.push(r)}return this._assemblies}},{key:"_buildMolecules",value:function(){this._complex._molecules=[];for(var e=this._metadata.molecules,t=0;t<e.length;t++){var r=new Cl(this._complex,e[t].name,t+1);r.residues=e[t]._residues,this._complex._molecules[t]=r}return this._complex._molecules}},{key:"_searchTag",value:function(e,t){for(var r=0;r<t.length;r++)if(e instanceof RegExp&&e.test(t[r].tag)||e===t[r].tag)return t[r].data}},{key:"_tryToFind",value:function(e,t){for(var r=0;r<e.length;r++){var n=this._searchTag(e[r],t);if(n)return n}}},{key:"_tryToUpdateMoleculeData",value:function(e){for(var t=!1,r=0;r<Ml.length;r++){var n=Nl[Ml[r]],i=this._tryToFind(n,e.props);i&&(e[Ml[r]]=i,t=!0)}return e.name=e.name||e.id,e.name.match(/^\d+$/)&&(e.name="CID: ".concat(e.name)),t}},{key:"_finalizeMetadata",value:function(){var e=this._metadata.molecules,t=this._complex.metadata,r=this._complex;if(1===e.length)r.name=e[0].name,t.title=e[0].title,t.date=e[0].date,t.properties=e[0].props;else if(e.length>1){t.molecules=[];for(var n=0;n<e.length;n++)t.molecules.push({name:e[n].name,date:e[n].date,title:e[n].title,properties:e[n].props})}}},{key:"_finalize",value:function(){for(var e=this._serialAtomMap={},t=this._complex._atoms,r=0;r<t.length;r++){var n=t[r];e[n.serial]=n}this._complex._finalizeBonds(),this._fixBondsArray(),this._finalizeMetadata(),this._buildAssemblies(),this._complex.units=this._complex.units.concat(this._assemblies),this._buildMolecules(),this._complex.finalize({needAutoBonding:!1,detectAromaticLoops:!1,enableEditing:!1,serialAtomMap:this._serialAtomMap})}},{key:"defineFormat",value:function(e){return Tl.test(e)?"sdf":"mol"}},{key:"parseSync",value:function(){var e=this._complex=new wl,t=new bl(this._data);this._format=this.defineFormat(this._data),e.metadata.format=this._format;do{this._parseCompound(t)}while(t.findNextCompoundStart());return this._finalize(),e}}]),s}(ss);function Ol(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}Il.formats=["mol","sdf"],Il.extensions=[".mol",".sdf"];var Ll={nstart:[2,"i16",0],extent:[2,"i16",3],grid:[2,"i16",6],cellDims:[1,"i16",9],angles:[2,"i16",12],div:[0,"i16",15],adder:[0,"i16",16],scaleFactor:[0,"i16",17]},Bl=function(e){h(r,e);var t=Ol(r);function r(){return a(this,r),t.apply(this,arguments)}return l(r,[{key:"_parseHeader",value:function(e){this._buff=e,this._typedCheck();var t={};if(t.i16=new Int16Array(this._buff),100!==t.i16[18])for(var r=0,n=t.i16.length;r<n;++r){var i=t.i16[r];t.i16[r]=(255&i)<<8|i>>8&255}if(100!==t.i16[18])throw new Error("DSN6: Incorrect format ");var o=this._header;this._fillHeader(Ll,t),o.cellDims.multiplyScalar(1/o.scaleFactor),o.angles.forEach((function(e,t,r){r[t]*=Math.PI/180/o.scaleFactor})),o.div/=100}},{key:"_setAxisIndices",value:function(){this._xyz2crs[0]=0,this._xyz2crs[1]=1,this._xyz2crs[2]=2}},{key:"_setOrigins",value:function(){var e=this._header,t=v(this._getAxis(),3),r=t[0],n=t[1],i=t[2];this._setAxisIndices(),this._origin.addScaledVector(r,e.nstart[0]),this._origin.addScaledVector(n,e.nstart[1]),this._origin.addScaledVector(i,e.nstart[2]),r.multiplyScalar(e.extent[0]),n.multiplyScalar(e.extent[1]),i.multiplyScalar(e.extent[2]),this._setBoxParams(r,n,i)}},{key:"_pointCalculate",value:function(e,t,r,n,i,o,a){var s=this._header;return i<s.extent[0]&&n<s.extent[1]&&r<s.extent[2]?(e[i+s.extent[0]*(n+s.extent[1]*r)]=(t[o.counter]-s.adder)/s.div,++o.counter,!0):(o.counter+=8-a,!1)}},{key:"_blockCalculate",value:function(e,t,r,n,i,o){for(var a=0;a<8;++a)for(var s=8*r+a,l=0;l<8;++l)for(var c=8*n+l,u=!0,h=0;u&&h<8;){var f=8*i+h;u=this._pointCalculate(e,t,s,c,f,o,h),h++}}},{key:"_toXYZData",value:function(){for(var e=this._header,t=new Uint8Array(this._buff),r=new Float32Array(e.extent[0]*e.extent[1]*e.extent[2]),n=new i.Pa4(e.extent[0]/8,e.extent[1]/8,e.extent[2]/8),o={counter:512},a=0;a<n.z;++a)for(var s=0;s<n.y;++s)for(var l=0;l<n.x;++l)this._blockCalculate(r,t,a,s,l,o);return this._calculateInfoParams(r),r}},{key:"_calculateInfoParams",value:function(e){this._header.dmean/=e.length;for(var t=0,r=e[0],n=e[0],i=0;i<e.length;i++)t+=Math.pow(this._header.dmean-e[i],2),e[i]<r&&(r=e[i]),e[i]>n&&(n=e[i]);this._header.sd=Math.sqrt(t/e.length),this._header.dmax=n,this._header.dmin=r}}]),r}(cl),Dl=function(e){h(r,e);var t=Ol(r);function r(e,n){var i;return a(this,r),(i=t.call(this,e,n))._options.fileType="dsn6",i.model=new Bl,i}return l(r,[{key:"parseSync",value:function(){return this.model.parse(this._data)}}],[{key:"canParse",value:function(e,t){return!!e&&e instanceof ArrayBuffer&&ss.checkDataTypeOptions(t,"dsn6")}},{key:"canProbablyParse",value:function(e){return!1}}]),r}(ss);Dl.formats=["dsn6"],Dl.extensions=[".dsn6",".omap"],Dl.binary=!0;var zl=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;return a(this,i),(t=n.call(this,e))._next=-1,t.next(),t}return l(i,[{key:"getNext",value:function(){return this._next}}]),i}(hs);var Fl=pr.Complex,Vl=pr.Element,Ul=pr.Molecule,Gl=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e,t){var r;return a(this,s),(r=o.call(this,e,t))._time=null,r._numAtoms=null,r._residueNumber=null,r._residueName="",r._atomName="",r._atomNumber=null,r._atomPosition=[],r._atomVelocity=[],r._complex=null,r._molecules=[],r._molecule=null,r._options.filetype="gro",r}return l(s,[{key:"canProbablyParse",value:function(e){return(0,n.isString)(this._data)&&/^\s*[^\n]*\n\s*\d+ *\n\s*\d+[^\n\d]{3}\s*\w+\s*\d+\s*-?\d/.test(e)}},{key:"_parseTitle",value:function(e){var t=this._complex.metadata;t.id=e.readLine().trim(),t.name=t.id.slice(t.id.lastIndexOf("\\")+1,t.id.lastIndexOf(".")),t.format="gro"}},{key:"_parseNumberOfAtoms",value:function(e){if(this._numAtoms=e.readInt(0,e.getNext()),Number.isNaN(this._numAtoms))throw new Error("Line 2 is not representing atom number. Consider checking input file")}},{key:"_parseAtom",value:function(e){this._residueNumber=e.readInt(1,5),this._residueName=e.readString(6,10).trim(),this._atomName=e.readString(11,15).trim(),this._atomNumber=e.readInt(16,20);var t=10*e.readFloat(21,28),r=10*e.readFloat(29,36),n=10*e.readFloat(37,45);if(Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(n))this._complex.error={message:'Atom position is invalid in "'.concat(e.readLine(),'"')};else{var o=Vl.getByName(this._atomName[0]);if("Unknown"!==o.fullName){var a=Vl.Role[this._atomName],s=this._chain;s||(this._chain=s=this._complex.addChain("A"));var l=this._residue;l&&l.getSequence()===this._residueNumber||(this._residue=l=s.addResidue(this._residueName,this._residueNumber," ")),this._atomPosition=new i.Pa4(t,r,n),l.addAtom(this._atomName,o,this._atomPosition,a,!0,this._atomNumber," ",1,1,0)}else this._complex.error={message:"".concat(this._atomName[0]," hasn't been recognised as an atom name.")}}}},{key:"_finalize",value:function(){var e=new Ul(this._complex,this._complex.metadata.name,1);e.residues=this._chain._residues,e._chains=this._chain,this._complex._molecules[0]=e,this._molecules.push(e),this._complex.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap})}},{key:"parseSync",value:function(){var e=this._complex=new Fl,t=new zl(this._data),r=0;for(this._parseTitle(t),t.next(),this._parseNumberOfAtoms(t),t.next(),r=0;r<this._numAtoms&&!t.end();++r)this._parseAtom(t),t.next();if(r<this._numAtoms&&(this._complex.error={message:"File ended unexpectedly."}),e.error)throw new Error(e.error.message);return this._finalize(),this._atomPosition=null,this._complex=null,this._molecules=null,this._molecule=null,e}}]),s}(ss);Gl.formats=["gro"],Gl.extensions=[".gro"];var jl=pr.Complex,Hl=pr.Element,Wl=pr.Bond,Yl=pr.Molecule,Xl={un:0,1:1,2:2,3:3,ar:1,am:1,nc:0,du:1},ql={un:Wl.BondType.UNKNOWN,1:Wl.BondType.COVALENT,2:Wl.BondType.COVALENT,3:Wl.BondType.COVALENT,ar:Wl.BondType.AROMATIC,am:Wl.BondType.COVALENT,nc:Wl.BondType.UNKNOWN,du:Wl.BondType.COVALENT},$l=/\d+$/,Zl=/\s+/;function Kl(e){return e.trim().split(Zl)}var Ql=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;return a(this,o),(r=n.call(this,e,t))._complex=null,r._chain=null,r._residue=null,r._compoundIndx=-1,r._molecules=[],r._molecule=null,r._currPosIdx=0,r._currStartIdx=0,r._serialAtomMap={},r._options.fileType="mol2",r}return l(o,[{key:"_parseRawStrings",value:function(e){return e.split(/\r?\n|\r/)}},{key:"_toStringFromStart",value:function(e,t){var r=this._currStartIdx+e;this._currPosIdx=r<t.length?r:this._currStartIdx}},{key:"_toHeaderString",value:function(e,t){for(this._toStringFromStart(0,t);this._currPosIdx<t.length;){if(t[this._currPosIdx].match("@<TRIPOS>".concat(e)))return;this._currPosIdx++}this._toStringFromStart(0,t)}},{key:"_toStringFromHeader",value:function(e,t,r){this._toHeaderString(e,r);var n=this._currPosIdx+t;r[this._currPosIdx].match("@<TRIPOS>".concat(e))&&n<r.length&&(this._currPosIdx=n)}},{key:"_setStart",value:function(e,t){e>=t.length?this._currStartIdx=this._currPosIdx=t.length-1:this._currStartIdx=this._currPosIdx=e}},{key:"_probablyHaveDataToParse",value:function(e){return this._currPosIdx<e.length-2}},{key:"_findNextCompoundStart",value:function(e){for(;this._currPosIdx<e.length&&"@<TRIPOS>MOLECULE>"!==e[this._currPosIdx].trim();)this._currPosIdx++;return this._setStart(++this._currPosIdx,e),this._probablyHaveDataToParse(e)}},{key:"_parseMolecule",value:function(e){this._toHeaderString("MOLECULE",e);var t=this._complex.metadata;t.name=e[++this._currPosIdx],t.format="mol2",this._molecule={_index:"",_chains:[]},this._molecule._index=this._compoundIndx+1,this._molecules.push(this._molecule)}},{key:"_parseAtoms",value:function(e,t){this._toHeaderString("ATOM",t);for(var r=0;r<e;r++){var n=Kl(t[++this._currPosIdx]);if(n.length<6)throw new Error("MOL2 parsing error: Not enough information to create atom!");var o=parseInt(n[0],10),a=n[1],s=parseFloat(n[2]),l=parseFloat(n[3]),c=parseFloat(n[4]),u=n[5].split(".")[0].toUpperCase(),h=0;n.length>=9&&(h=parseFloat(n[8])||0);var f=this._chain;if(f||(this._chain=f=this._complex.getChain("A")||this._complex.addChain("A"),this._residue=null),this._setResidue(n)){var d=Hl.getByName(u),p=Hl.Role[a],m=new i.Pa4(s,l,c);this._residue.addAtom(a,d,m,p,!1,o," ",1,0,h)}}}},{key:"_setResidue",value:function(e){var t=1,r="UNK";if(e.length>=7&&(t=parseInt(e[6],10)),e.length>=8&&"<0>"!==e[7]&&(r=e[7].replace($l,"")),this.settings.now.nowater&&("HOH"===r||"WAT"===r))return!1;var n=this._residue,i=this._chain;return n&&n.getSequence()===t||(this._residue=i.addResidue(r,t,"A")),!0}},{key:"_parseBonds",value:function(e,t){this._toHeaderString("BOND",t);for(var r=0;r<e;r++){var n=Kl(t[++this._currPosIdx]);if(n.length<3)throw new Error("MOL2 parsing error: Missing information about bonds!");var i=parseInt(n[1],10),o=parseInt(n[2],10),a=n[3];if(i>o){var s=[o,i];i=s[0],o=s[1]}this._complex.addBond(i,o,Xl[a]||0,ql[a]||Wl.BondType.UNKNOWN,!0)}}},{key:"_fixSerialAtoms",value:function(){for(var e=this._complex._atoms,t=0;t<e.length;t++){var r=e[t];this._serialAtomMap[r.serial]=r}}},{key:"_fixBondsArray",value:function(){var e=this._serialAtomMap,t=this._complex;if(0===Object.keys(e).length)throw new Error("MOL2 parsing error: Missing atom information!");for(var r=t._bonds,n=0;n<r.length;n++){var i=r[n];i._left=e[i._left]||null,i._right=e[i._right]||null}}},{key:"_finalizeMolecules",value:function(){var e=this._complex._chains[0];this._complex._molecules=[];for(var t=0;t<this._molecules.length;t++){var r=this._molecules[t],n=e._residues,i=new Yl(this._complex,r._name,t+1);i.residues=n,this._complex._molecules[t]=i}}},{key:"_finalize",value:function(){this._complex._finalizeBonds(),this._fixSerialAtoms(),this._fixBondsArray(),this._finalizeMolecules(),this._complex.finalize({needAutoBonding:!1,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap})}},{key:"_parseCompound",value:function(e){this._compoundIndx++,this._parseMolecule(e),this._toStringFromHeader("MOLECULE",2,e);var t=e[this._currPosIdx].trim().split(Zl),r=t[0],n=t[1];this._parseAtoms(r,e),this._parseBonds(n,e)}},{key:"parseSync",value:function(){var e=this._complex=new jl,t=this._parseRawStrings(this._data);do{this._parseCompound(t)}while(this._findNextCompoundStart(t));return this._finalize(),e}}]),o}(ss);Ql.formats=["mol2"],Ql.extensions=[".mol2",".ml2",".sy2"];var Jl=new as([bs,ll,Hs,yl,ks,xl,Il,dl,Dl,Gl,Ql]);var ec=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return a(this,i),n.call(this,e,["formats"])}return l(i,[{key:"find",value:function(e){var t=[];return e.format&&(t=this._dict.formats[e.format.toLowerCase()]||[]),Tr(t)}}]),i}(Nr),tc=function(){function e(t,r){a(this,e),this._source=t,this._options=r||{},this._abort=!1}return l(e,[{key:"exportSync",value:function(){throw new Error("Exporting to this source is not implemented")}},{key:"export",value:function(){var e=this;return new Promise((function(t,r){setTimeout((function(){try{return e._abort?r(new Error("Export aborted")):t(e.exportSync())}catch(e){return r(e)}}))}))}},{key:"abort",value:function(){this._abort=!0}}]),e}();Ir(tc.prototype);var rc=function(){function e(){a(this,e),this._resultArray=[],this._currentStr=-1,this._tag=null,this._fixedNumeration=!1,this._numeration=!1,this._tagStrNum=0}return l(e,[{key:"getResult",value:function(){return this.writeString("\n",81,81),this._resultArray.join("")}},{key:"_currentStrLength",value:function(){var e=this._resultArray[this._currentStr];return e?e.length:0}},{key:"newTag",value:function(e,t){this._tag=e||null,(0,n.isUndefined)(t)?(this._numeration=!1,this._fixedNumeration=!1,this._tagStrNum=0):(0,n.isNumber)(t)?(this._tagStrNum=t,this._numeration=!0,this._fixedNumeration=!0):(0,n.isBoolean)(t)&&(this._tagStrNum=0,this._numeration=t,this._fixedNumeration=!1)}},{key:"newString",value:function(e){this.writeString("\n",81,81),this._currentStr++,this._resultArray.push(""),e?this.writeString(e,1,6):this._tag&&this.writeString(this._tag,1,6),this._numeration&&(this._fixedNumeration||this._tagStrNum++,1!==this._tagStrNum&&this.writeString(this._tagStrNum.toString(),10,8))}},{key:"writeEntireString",value:function(e,t,r){t||(t=81);for(var n=0;n<e.length;n++)this._currentStrLength()===t&&n!==e.length-1&&(this.newString(),r&&this.writeString(r.tag,r.begin,r.end)),"\n"===e[n]?this.newString():this.writeString(e[n])}},{key:"writeString",value:function(e,t,r){var i,o=this._resultArray[this._currentStr],a=o?o.length:0;if(!(0,n.isUndefined)(e)){(0,n.isNumber)(t)||(t=a+1),(0,n.isNumber)(r)||(r=a+e.length);var s=t<r?r:t,l=t<r?t:r;if((i=(0,n.isString)(e)?e:e.toString()).length>Math.abs(t-r)+1&&(i=i.substr(0,Math.abs(t-r+1))),l>a+1)this._resultArray[this._currentStr]+=" ".repeat(l-a-1);else if(l<=a){var c=this._resultArray[this._currentStr];this._resultArray[this._currentStr]=c.slice(0,l-1)}r<t&&(i=" ".repeat(t-r+1-i.length)+i),11===l&&this._numeration&&1!==this._tagStrNum&&(i=" ".concat(i)),this._resultArray[this._currentStr]+=i,s>(o=this._resultArray[this._currentStr]).length&&(this._resultArray[this._currentStr]+=" ".repeat(s-o.length))}}},{key:"writeBondsArray",value:function(e,t){for(var r=this._getSubArrays(e,4),n=0;n<r.length;n++){this.newString(),this.writeString(t.serial,11,7);for(var i=0;i<r[n].length;i++){var o=r[n][i]._left.serial===t.serial?r[n][i]._right.serial:r[n][i]._left.serial;this.writeString(o,16+5*i,12+5*i)}}}},{key:"_getSubArrays",value:function(e,t){for(var r=[],n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}},{key:"writeMatrix",value:function(e,t,r){for(var n=0;n<3;n++){this.newString(),this.writeString(r,14,18),this.writeString((n+1).toString(),19,19),this.writeString(t.toString(),23,20);for(var i=0;i<3;i++){var o=parseFloat(e.elements[4*n+i]).toFixed(6);this.writeString(o.toString(),33+10*i,24+10*i)}var a=parseFloat(e.elements[4*n+3]).toFixed(5);this.writeString(a.toString(),68,55)}}},{key:"writeMatrices",value:function(e,t){if(e)for(var r=new i.yGw,n=0;n<e.length;n++)r.copy(e[n]).transpose(),this.writeMatrix(r,n+1,t)}}]),e}();var nc=function(e){h(o,e);var t,r,i=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;return a(this,o),(r=i.call(this,e,t))._tags=["HEADER","TITLE","COMPND","REMARK","HELIX","SHEET","ATOM and HETATM","CONECT"],r._result=null,r._tagExtractors={HEADER:r._extractHEADER,TITLE:r._extractTITLE,"ATOM and HETATM":r._extractATOM,CONECT:r._extractCONECT,COMPND:r._extractCOMPND,REMARK:r._extractREMARK,HELIX:r._extractHELIX,SHEET:r._extractSHEET},r._stringForRemark350="COORDINATES FOR A COMPLETE MULTIMER REPRESENTING THE KNOWN\nBIOLOGICALLY SIGNIFICANT OLIGOMERIZATION STATE OF THE\nMOLECULE CAN BE GENERATED BY APPLYING BIOMT TRANSFORMATIONS\nGIVEN BELOW. BOTH NON-CRYSTALLOGRAPHIC AND\nCRYSTALLOGRAPHIC OPERATIONS ARE GIVEN.",r._stringForRemark290="CRYSTALLOGRAPHIC SYMMETRY TRANSFORMATIONS\nTHE FOLLOWING TRANSFORMATIONS OPERATE ON THE ATOM/HETATM\nRECORDS IN THIS ENTRY TO PRODUCE CRYSTALLOGRAPHICALLY\nRELATED MOLECULES.",r}return l(o,[{key:"exportSync",value:function(){var e=new rc;if(!this._source)return this._result;for(var t=0;t<this._tags.length;t++){var r=this._tags[t],n=this._tagExtractors[r];"function"==typeof n&&n.call(this,e)}return this._result=e.getResult(),this._result}},{key:"_extractHEADER",value:function(e){if(this._source.metadata){var t=this._source.metadata;e.newTag("HEADER"),e.newString(),t.classification&&e.writeString(t.classification,11,50),t.date&&e.writeString(t.date,51,59),t.id&&e.writeString(t.id,63,66)}}},{key:"_extractTITLE",value:function(e){if(this._source.metadata){var t=this._source.metadata;if(t.title){e.newTag("TITLE",!0);for(var r=0;r<t.title.length;r++)e.newString(),e.writeString(t.title[r],11,80)}}}},{key:"_extractCONECT",value:function(e){if(this._source._atoms){var t=this._source._atoms;e.newTag("CONECT");for(var r=0;r<t.length;r++){var n=t[r].bonds.filter((function(e){return e._fixed}));0!==n.length&&e.writeBondsArray(n.reverse(),t[r])}}}},{key:"_extractSHEET",value:function(e){if(this._source._sheets){e.newTag("SHEET");for(var t=this._source._sheets,r=0;r<t.length;r++)if(t[r]._strands)for(var n=t[r]._strands,i=0;i<n.length;i++)e.newString(),e.writeString(i+1,10,8),e.writeString(t[r]._name,14,12),e.writeString(n.length,16,15),e.writeString(n[i].init._type._name,18,20),e.writeString(n[i].init._chain._name,22,22),e.writeString(n[i].init._sequence,26,23),e.writeString(n[i].init._icode,27,27),e.writeString(n[i].term._type._name,29,31),e.writeString(n[i].init._chain._name,33,33),e.writeString(n[i].term._sequence,37,34),e.writeString(n[i].term._icode,38,38),e.writeString(n[i].sense,40,39)}}},{key:"_extractHELIX",value:function(e){if(this._source._helices){e.newTag("HELIX");for(var t=this._source._helices,r=0;r<t.length;r++){var i=t[r],o=(0,n.invert)(We);e.newString(),e.writeString(i.serial,10,8),e.writeString(i.name,14,12),e.writeString(i.init._type._name,16,18),e.writeString(i.init._chain._name,20,20),e.writeString(i.init._sequence,25,22),e.writeString(i.init._icode,26,26),e.writeString(i.term._type._name,28,30),e.writeString(i.term._chain._name,32,32),e.writeString(i.term._sequence,37,34),e.writeString(i.term._icode,38,38),e.writeString(o[i.type],40,39),e.writeString(i.comment,41,70),e.writeString(i.length,76,72)}}}},{key:"_extractATOM",value:function(e){if(this._source._atoms)for(var t=this._source._atoms,r=0;r<t.length;r++){var n=t[r].het?"HETATM":"ATOM";e.newString(n);var i=t[r].element.name.length>1||t[r].name.length>3?13:14;e.writeString(t[r].serial,11,7),e.writeString(t[r].name,i,16),e.writeString(String.fromCharCode(t[r].location),17,17),e.writeString(t[r].residue._type._name,20,18),e.writeString(t[r].residue._chain._name,22,22),e.writeString(t[r].residue._sequence,26,23),e.writeString(t[r].residue._icode,27,27),e.writeString(t[r].position.x.toFixed(3),38,31),e.writeString(t[r].position.y.toFixed(3),46,39),e.writeString(t[r].position.z.toFixed(3),54,47),e.writeString(t[r].occupancy.toFixed(2),60,55),e.writeString(t[r].temperature.toFixed(2),66,61),e.writeString(t[r].element.name,78,77),t[r].charge&&e.writeString(t[r].charge,79,80)}}},{key:"_extractCOMPND",value:function(e){if(this._source._molecules){var t=this._source._molecules;e.newTag("COMPND",!0);for(var r=0;r<t.length;r++){var n=this._getMoleculeChains(t[r]);e.newString(),e.writeString("MOL_ID: ".concat(t[r].index,";"),11,80),e.newString(),e.writeString("MOLECULE: ".concat(t[r].name,";"),11,80),e.newString(),e.writeString("CHAIN: ",11,18);var i="".concat(n.join(", "),";");e.writeEntireString(i,81)}}}},{key:"_extractREMARK",value:function(e){this._Remark290(e),this._Remark350(e)}},{key:"_Remark290",value:function(e){if(this._source.symmetry&&0!==this._source.symmetry.length){var t=this._source.symmetry;e.newTag("REMARK",290),e.newString(),e.newString(),e.writeEntireString(this._stringForRemark290),e.writeMatrices(t,"SMTRY"),e.newString(),e.newString(),e.writeString("REMARK: NULL",11,80)}}},{key:"_Remark350",value:function(e){if(this._source.units){var t=this._source.units,r=0;e.newTag("REMARK",350),e.newString(),e.newString(),e.writeEntireString(this._stringForRemark350);for(var n=t.filter((function(e){return e instanceof Ct})),i=0;i<n.length;i++){e.newString(),e.newString(),r++,e.writeString("BIOMOLECULE: ".concat(r),11,80);var o=n[i].chains.join(", ");e.newString(),e.writeString("APPLY THE FOLLOWING TO CHAINS: "),e.writeEntireString(o,69,{tag:"AND CHAINS: ",begin:31,end:42});var a=n[i].matrices;e.writeMatrices(a,"BIOMT")}}}},{key:"_getMoleculeChains",value:function(e){var t=e.residues.map((function(e){return e._chain._name}));return t.filter((function(e,r){return t.indexOf(e)===r}))}}]),o}(tc);function ic(e,t,r,n){r[n]=e[t],r[n+1]=e[t+1],r[n+2]=e[t+2]}function oc(e,t,r,n,i){r[n]=e[t],r[n+1]=e[t+1],r[n+2]=e[t+2],r[n+3]=i}nc.formats=["pdb"],nc.SourceClass=ur;var ac=new i.Ltg;function sc(e,t,r,n,i){ac.set(e[t],e[t+1],e[t+2],i.w),ac.applyMatrix4(i.matrix),r[n]=ac.x,r[n+1]=ac.y,r[n+2]=ac.z}function lc(e,t,r,n,i){if(!((t.array.length-t.start)/t.stride<r||(e.array.length-e.start)/e.stride<r))if(e.stride===t.stride)t.array.set(e.array,t.start);else for(var o=t.start,a=e.start,s=0;s<r;++s,o+=t.stride,a+=e.stride)n(e.array,a,t.array,o,i)}var cc=function(){function e(){a(this,e),this.positions=null,this.normals=null,this.colors=null,this.indices=null,this.lastPos=0,this.lastNorm=0,this.lastCol=0,this.lastIdx=0}return l(e,[{key:"init",value:function(e,t){this.positions=new Float32Array(3*e),this.normals=new Float32Array(3*e),this.colors=new Float32Array(4*e),this.indices=new Int32Array(t)}},{key:"setPositions",value:function(e,t,r,n){lc({array:e,start:t,stride:n},{array:this.positions,start:this.lastPos,stride:3},r,ic),this.lastPos+=3*r}},{key:"setTransformedPositions",value:function(e,t,r,n,i){for(var o=this.lastPos,a=t,s={matrix:i,w:1},l=0;l<r;++l,a+=n,o+=3)sc(e,a,this.positions,o,s);this.lastPos+=3*r}},{key:"setNormals",value:function(e,t,r,n){lc({array:e,start:t,stride:n},{array:this.normals,start:this.lastNorm,stride:3},r,ic),this.lastNorm+=3*r}},{key:"setTransformedNormals",value:function(e,t,r,n,i){for(var o=this.lastNorm,a=t,s={matrix:i,w:0},l=0;l<r;++l,a+=n,o+=3)sc(e,a,this.normals,o,s);this.lastNorm+=3*r}},{key:"setColors",value:function(e,t,r,n){lc({array:e,start:t,stride:n},{array:this.colors,start:this.lastCol,stride:4},r,oc,1),this.lastCol+=4*r}},{key:"setIndices",value:function(e,t,r){this.indices.set(e,this.lastIdx),this.lastIdx+=r}},{key:"setShiftedIndices",value:function(e,t,r){var n=e.map((function(e){return e+r}));this.setIndices(n,0,t)}},{key:"getVerticesNumber",value:function(){return this.lastPos/3}},{key:"addInstance",value:function(e,t){var r=this.getVerticesNumber();this.setShiftedIndices(t.indices,t.indices.length,r);var n=t.itemSize;this.setTransformedPositions(t.positions,0,t.vertsCount,n.position,e),this.setTransformedNormals(t.normals,0,t.vertsCount,n.normal,e),this.setColors(t.colors,0,t.vertsCount,n.color)}}]),e}(),uc=function(){function e(){a(this,e),this.positions=null,this.normals=null,this.colors=null,this.indices=null,this.vertsCount=0,this.itemSize=null}return l(e,[{key:"init",value:function(e,t){var r=e.attributes;this.itemSize={position:r.position.itemSize,normal:r.normal.itemSize,color:r.color.itemSize}}}]),e}();var hc=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return a(this,i),n.apply(this,arguments)}return l(i,[{key:"init",value:function(e,t){Xe(d(i.prototype),"init",this).call(this,e,t);var r=e.attributes,n=r.position,o=r.normal,a=e.index;this.vertsCount=n.count,this.positions=n.array,this.normals=o.array,this.colors=new Float32Array(this.vertsCount*this.itemSize.color),this.indices=a.array}},{key:"setColors",value:function(e){for(var t=0,r=0,n=this.colors.length,i=this.itemSize.color;r<n;r+=i)this.colors[t++]=e.r,this.colors[t++]=e.g,this.colors[t++]=e.b}}]),i}(uc);var fc=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;return a(this,i),(e=n.call(this))._cutRawStart=0,e._cutRawEnd=0,e._facesPerSlice=0,e}return l(i,[{key:"init",value:function(e,t){Xe(d(i.prototype),"init",this).call(this,e,t);var r=e.attributes.position,n=e.index;this.vertsCount=r.count+t.addPerCylinder,this._facesPerSlice=t.addPerCylinder,this.positions=new Float32Array(this.vertsCount*r.itemSize),this.normals=new Float32Array(this.vertsCount*this.itemSize.normal),this.colors=new Float32Array(this.vertsCount*this.itemSize.color),this._extendVertices(e,t),this.indices=new Uint32Array(n.count),this._extendIndices(e,t)}},{key:"_extendVertices",value:function(e,t){var r=e.attributes.position,n=e.attributes.normal,i=e.getGeoParams();this._cutRawStart=1*i.radialSegments,this._cutRawEnd=this._cutRawStart+t.addPerCylinder;var o=r.array.slice(0,this._cutRawEnd*r.itemSize);this.positions.set(o,0),o=n.array.slice(0,this._cutRawEnd*n.itemSize),this.normals.set(o,0);var a=r.array.slice(this._cutRawStart*r.itemSize,r.array.length);this.positions.set(a,this._cutRawEnd*r.itemSize),a=n.array.slice(this._cutRawStart*n.itemSize,n.array.length),this.normals.set(a,this._cutRawEnd*n.itemSize)}},{key:"_extendIndices",value:function(e,t){var r=e.index,n=6*t.addPerCylinder,i=t.addPerCylinder,o=r.array.slice(n,r.count);o=o.map((function(e){return e+i})),this.indices.set(r.array,0),this.indices.set(o,n)}},{key:"_setColorRange",value:function(e,t,r,n){for(var i=n.length,o=e;o<t;o+=i)r.set(n,o)}},{key:"setColors",value:function(e,t){var r=this.itemSize.color,n=this._cutRawEnd*r,i=2*n;if(this._setColorRange(0,n,this.colors,e.toArray()),this._setColorRange(n,i,this.colors,t.toArray()),i<this.colors.length){var o=(this._facesPerSlice+1)*r,a=i+o;this._setColorRange(i,a,this.colors,t.toArray());var s=a+o;this._setColorRange(a,s,this.colors,e.toArray())}}}]),i}(uc),dc=function(){function e(){a(this,e),this._materials=[],this._models=[]}return l(e,[{key:"process",value:function(e){this._extractModelsAndMaterials(e);var t=this._flattenModels();return{name:e.name,models:t,materials:this._materials}}},{key:"_extractModelsAndMaterials",value:function(e){var t=this,r=new i.S9g;r.set(Er.LAYERS.DEFAULT),r.enable(Er.LAYERS.TRANSPARENT),e.traverse((function(e){e instanceof i.Kj0&&e.layers.test(r)&&t.checkExportAbility(e)&&("InstancedBufferGeometry"===e.geometry.type?t._collectInstancedGeoInfo(e):t._collectGeoInfo(e))}))}},{key:"_reworkIndices",value:function(e){for(var t=2;t<e.length;t+=3)e[t]*=-1,e[t]--}},{key:"_flattenModels",value:function(){var e=0;function t(t){return t+e}for(var r=[],n=0,i=this._models.length;n<i;n++){var o=this._models[n],a=[],s=[],l=[],c=[];e=0;for(var u=0;u<o.length;u++){var h=o[u];a.push(h.indices.map(t)),e+=h.getVerticesNumber(),s.push(h.positions),l.push(h.normals),c.push(h.colors)}a=$.mergeTypedArraysUnsafe(a),this._reworkIndices(a),s=$.mergeTypedArraysUnsafe(s),l=$.mergeTypedArraysUnsafe(l),c=$.mergeTypedArraysUnsafe(c),r.push({indices:a,positions:s,normals:l,colors:c,verticesCount:e})}return r}},{key:"checkExportAbility",value:function(e){return!(0===e.geometry.attributes.position.count||(e instanceof di?(B.warn("Currently we cannot export 'sprites' modes, like BS, WV, LC. Please turn of settings 'zSprites' and try again"),1):e instanceof xi&&(B.warn("Currently we cannot export Lines mode"),1)))}},{key:"_collectGeoInfo",value:function(e){var t=e.geometry,r=t.attributes,n=r.position,i=r.color,o=r.normal,a=t.index,s=e.matrix,l=new cc,c=n.count;l.init(c,a.count),s.isIdentity()?(l.setPositions(n.array,0,c,n.itemSize),l.setNormals(o.array,0,c,o.itemSize)):(l.setTransformedPositions(n.array,0,c,n.itemSize,s),l.setTransformedNormals(o.array,0,c,o.itemSize,s)),l.setColors(i.array,0,c,i.itemSize),l.setIndices(a.array,0,a.count);var u=this._collectMaterialInfo(e);this._addToPool(l,u)}},{key:"_collectSpheresInfo",value:function(e){var t=e.geometry,r=t.attributes,n=r.position,o=r.color,a=t.index,s=e.matrix,l=new cc,c=e.geometry.instanceCount,u=n.count,h=a.count;l.init(c*u,c*h);var f=new hc;f.init(e.geometry);for(var d=new i.yGw,p=new i.yGw,m=new i.Ilk,v=0;v<c;++v){var y=v*o.itemSize;m.fromArray(o.array,y),f.setColors(m),this._getSphereInstanceMatrix(e.geometry,v,d),p.multiplyMatrices(s,d),l.addInstance(p,f)}var _=this._collectMaterialInfo(e);this._addToPool(l,_)}},{key:"_collectCylindersInfo",value:function(e){var t=e.geometry,r=t.attributes,n=r.position,o=r.color,a=r.color2,s=t.index,l=e.matrix,c=new cc,u=e.geometry.instanceCount,h=new hc;h.init(e.geometry);var f=this._gatherCylindersColoringInfo(e.geometry),d=null;f.needToSplit>0&&(d=new fc).init(e.geometry,f);var p=f.addPerCylinder*f.needToSplit,m=n.count,v=s.count;c.init(u*m+p,u*v);for(var y=new i.yGw,_=new i.yGw,g=new i.Ilk,x=new i.Ilk,b={},w=0;w<u;++w){var S=w*o.itemSize;f.is2Colored[w]?(g.fromArray(a.array,S),x.fromArray(o.array,S),d&&(d.setColors(g,x),b=d)):(g.fromArray(o.array,S),h.setColors(g),b=h),this._getCylinderInstanceMatrix(e.geometry,w,y),_.multiplyMatrices(l,y),c.addInstance(_,b)}var R=this._collectMaterialInfo(e);this._addToPool(c,R)}},{key:"_addToPool",value:function(e,t){var r=this._checkExistingMaterial(t);r<0?(this._models.push([e]),this._materials.push(t)):this._models[r].push(e)}},{key:"_checkExistingMaterial",value:function(e){return(0,n.findIndex)(this._materials,(function(t){return(0,n.isEqual)(t,e)}))}},{key:"_gatherCylindersColoringInfo",value:function(e){for(var t=e.instanceCount,r=e.attributes.color.array,n=e.attributes.color2.array,i=e.attributes.color.itemSize,o=new Array(t),a=0,s=0,l=0;l<t;l++,s+=i){var c=Math.abs(r[s]-n[s])>1e-7||Math.abs(r[s+1]-n[s+1])>1e-7||Math.abs(r[s+2]-n[s+2])>1e-7;o[l]=c,a+=c}return{is2Colored:o,needToSplit:a,addPerCylinder:e.getGeoParams().radialSegments}}},{key:"_collectInstancedGeoInfo",value:function(e){e.geometry instanceof zr?this._collectSpheresInfo(e):e.geometry instanceof Jr&&this._collectCylindersInfo(e)}},{key:"_collectMaterialInfo",value:function(e){var t=e.material.uberOptions;return{diffuse:t.diffuse.toArray(),opacity:t.opacity,shininess:t.shininess,specular:t.specular.toArray()}}},{key:"_getCylinderInstanceMatrix",value:function(e,t,r){var n=e.attributes.matVector1.array,i=e.attributes.matVector2.array,o=e.attributes.matVector3.array,a=4*t;r.set(n[a],n[a+1],n[a+2],n[a+3],i[a],i[a+1],i[a+2],i[a+3],o[a],o[a+1],o[a+2],o[a+3],0,0,0,1)}},{key:"_getSphereInstanceMatrix",value:function(e,t,r){var n=e.attributes.offset,i=t*n.itemSize,o=n.array[i],a=n.array[i+1],s=n.array[i+2],l=n.array[i+3];r.set(l,0,0,o,0,l,0,a,0,0,l,s,0,0,0,1)}}]),e}(),pc=function(){function e(){a(this,e),this._resultArray=[],this._info=null}return l(e,[{key:"getResult",value:function(e){return this._info=e,this._resultArray.push(this._writeHeader()),this._resultArray.push(this._writeDefinitions()),this._resultArray.push(this._writeObjects(e.models,e.materials)),this._resultArray.push(this._writeRelations()),this._resultArray.push(this._writeConnections()),this._info=null,this._resultArray.join("")}},{key:"_writeHeader",value:function(){var e=new Date,t="Miew FBX Exporter v".concat(this._info.version);return"; FBX 6.1.0 project file\n; Created by ".concat(t," Copyright (c) 2015-2020 EPAM Systems, Inc.\n; For support please contact miew@epam.com\n; ----------------------------------------------------\n\nFBXHeaderExtension: {\n FBXHeaderVersion: ").concat(1003,"\n FBXVersion: ").concat(6100,"\n CreationTimeStamp: {\n Version: ").concat(1e3,"\n Year: ").concat(e.getFullYear(),"\n Month: ").concat(e.getMonth()+1," \n Day: ").concat(e.getDate(),"\n Hour: ").concat(e.getHours(),"\n Minute: ").concat(e.getMinutes(),"\n Second: ").concat(e.getSeconds(),"\n Millisecond: ").concat(e.getMilliseconds(),'\n }\n Creator: "').concat(t,'"\n OtherFlags: {\n FlagPLE: 0\n }\n}\nCreationTime: "').concat(e,'"\nCreator: "').concat(t,'" \n')}},{key:"_writeDefinitions",value:function(){return"\n; Object definitions\n;------------------------------------------------------------------\n\n".concat('\nDefinitions: {\n Version: 100\n Count: 3\n ObjectType: "Model" {\n Count: 1\n }\n ObjectType: "Geometry" {\n Count: 1\n }\n ObjectType: "Material" {\n Count: 1\n }\n ObjectType: "Pose" {\n Count: 1\n }\n ObjectType: "GlobalSettings" {\n Count: 1\n }\n} ',"\n")}},{key:"_models",value:function(){for(var e="",t=this._info.models,r=0;r<t.length;++r){var n=t[r],i=n.verticesCount;e+='\n Model: "Model::'.concat(this._info.name,"_").concat(r,'", "Mesh" {\n Version: ').concat(232," \n ").concat('Properties60: {\n Property: "QuaternionInterpolate", "bool", "",0\n Property: "Visibility", "Visibility", "A",1\n Property: "Lcl Translation", "Lcl Translation", "A",0.000000000000000,0.000000000000000,-1789.238037109375000\n Property: "Lcl Rotation", "Lcl Rotation", "A",0.000009334667643,-0.000000000000000,0.000000000000000\n Property: "Lcl Scaling", "Lcl Scaling", "A",1.000000000000000,1.000000000000000,1.000000000000000\n Property: "RotationOffset", "Vector3D", "",0,0,0\n Property: "RotationPivot", "Vector3D", "",0,0,0\n Property: "ScalingOffset", "Vector3D", "",0,0,0\n Property: "ScalingPivot", "Vector3D", "",0,0,0\n Property: "TranslationActive", "bool", "",0\n Property: "TranslationMin", "Vector3D", "",0,0,0\n Property: "TranslationMax", "Vector3D", "",0,0,0\n Property: "TranslationMinX", "bool", "",0\n Property: "TranslationMinY", "bool", "",0\n Property: "TranslationMinZ", "bool", "",0\n Property: "TranslationMaxX", "bool", "",0\n Property: "TranslationMaxY", "bool", "",0\n Property: "TranslationMaxZ", "bool", "",0\n Property: "RotationOrder", "enum", "",0\n Property: "RotationSpaceForLimitOnly", "bool", "",0\n Property: "AxisLen", "double", "",10\n Property: "PreRotation", "Vector3D", "",0,0,0\n Property: "PostRotation", "Vector3D", "",0,0,0\n Property: "RotationActive", "bool", "",0\n Property: "RotationMin", "Vector3D", "",0,0,0\n Property: "RotationMax", "Vector3D", "",0,0,0\n Property: "RotationMinX", "bool", "",0\n Property: "RotationMinY", "bool", "",0\n Property: "RotationMinZ", "bool", "",0\n Property: "RotationMaxX", "bool", "",0\n Property: "RotationMaxY", "bool", "",0\n Property: "RotationMaxZ", "bool", "",0\n Property: "RotationStiffnessX", "double", "",0\n Property: "RotationStiffnessY", "double", "",0\n Property: "RotationStiffnessZ", "double", "",0\n Property: "MinDampRangeX", "double", "",0\n Property: "MinDampRangeY", "double", "",0\n Property: "MinDampRangeZ", "double", "",0\n Property: "MaxDampRangeX", "double", "",0\n Property: "MaxDampRangeY", "double", "",0\n Property: "MaxDampRangeZ", "double", "",0\n Property: "MinDampStrengthX", "double", "",0\n Property: "MinDampStrengthY", "double", "",0\n Property: "MinDampStrengthZ", "double", "",0\n Property: "MaxDampStrengthX", "double", "",0\n Property: "MaxDampStrengthY", "double", "",0\n Property: "MaxDampStrengthZ", "double", "",0\n Property: "PreferedAngleX", "double", "",0\n Property: "PreferedAngleY", "double", "",0\n Property: "PreferedAngleZ", "double", "",0\n Property: "InheritType", "enum", "",0\n Property: "ScalingActive", "bool", "",0\n Property: "ScalingMin", "Vector3D", "",1,1,1\n Property: "ScalingMax", "Vector3D", "",1,1,1\n Property: "ScalingMinX", "bool", "",0\n Property: "ScalingMinY", "bool", "",0\n Property: "ScalingMinZ", "bool", "",0\n Property: "ScalingMaxX", "bool", "",0\n Property: "ScalingMaxY", "bool", "",0\n Property: "ScalingMaxZ", "bool", "",0\n Property: "GeometricTranslation", "Vector3D", "",0,0,0\n Property: "GeometricRotation", "Vector3D", "",0,0,0\n Property: "GeometricScaling", "Vector3D", "",1,1,1\n Property: "LookAtProperty", "object", ""\n Property: "UpVectorProperty", "object", ""\n Property: "Show", "bool", "",1\n Property: "NegativePercentShapeSupport", "bool", "",1\n Property: "DefaultAttributeIndex", "int", "",0\n Property: "Color", "Color", "A+",0,0,0\n Property: "Size", "double", "",100\n Property: "Look", "enum", "",1\n }',"\n ").concat(this._verticesIndices(n.positions,n.indices),"\n ").concat(this._normalLayer(n.normals)," \n ").concat(this._colorLayer(n.colors,i)," \n ").concat('\n LayerElementMaterial: 0 {\n Version: 101\n Name: ""\n MappingInformationType: "AllSame"\n ReferenceInformationType: "Direct"\n Materials: 0\n }'," \n ").concat('\n Layer: 0 {\n Version: 100\n LayerElement: {\n Type: "LayerElementNormal"\n TypedIndex: 0\n }\n LayerElement: {\n Type: "LayerElementColor"\n TypedIndex: 0\n }\n LayerElement: {\n Type: "LayerElementMaterial"\n TypedIndex: 0\n }\n }',"\n }")}return e}},{key:"_materials",value:function(){for(var e="",t=this._info.materials,r=0;r<t.length;++r){var n=t[r];e+='\n Material: "Material::'.concat(this._info.name,"_").concat(r,'_default", "" {\n Version: ').concat(102,'\n ShadingModel: "lambert"\n MultiLayer: 0\n ').concat(this._materialProperties(n),"\n }")}return e}},{key:"_writeObjects",value:function(){return"\n; Object properties\n;------------------------------------------------------------------\n\nObjects: {\n ".concat(this._models(),"\n ").concat(this._materials(),"\n ").concat('GlobalSettings: {\n Version: 1000\n Properties60: {\n Property: "UpAxis", "int", "",1\n Property: "UpAxisSign", "int", "",1\n Property: "FrontAxis", "int", "",2\n Property: "FrontAxisSign", "int", "",1\n Property: "CoordAxis", "int", "",0\n Property: "CoordAxisSign", "int", "",1\n Property: "UnitScaleFactor", "double", "",1\n }\n }',"\n}\n")}},{key:"_writeRelations",value:function(){for(var e="",t=0;t<this._info.models.length;++t)e+='\n Model: "Model::'.concat(this._info.name,"_").concat(t,'", "Mesh" {\n }');for(var r="",n=0;n<this._info.materials.length;++n)r+='\n Material: "Material::'.concat(this._info.name,"_").concat(n,'_default", "" {\n }');return"\n; Object relations\n;------------------------------------------------------------------\n\nRelations: {\n ".concat(e,'\n Model: "Model::Producer Perspective", "Camera" {\n }\n Model: "Model::Producer Top", "Camera" {\n }\n Model: "Model::Producer Bottom", "Camera" {\n }\n Model: "Model::Producer Front", "Camera" {\n }\n Model: "Model::Producer Back", "Camera" {\n }\n Model: "Model::Producer Right", "Camera" {\n }\n Model: "Model::Producer Left", "Camera" {\n }\n Model: "Model::Camera Switcher", "CameraSwitcher" {\n }\n ').concat(r,"\n}")}},{key:"_writeConnections",value:function(){for(var e="",t=this._info.name,r=0;r<this._info.models.length;++r)e+='\n Connect: "OO", "Model::'.concat(t,"_").concat(r,'", "Model::Scene"');for(var n="",i=0;i<this._info.materials.length;++i)n+='\n Connect: "OO", "Material::'.concat(t,"_").concat(i,'_default", "Model::').concat(t,"_").concat(i,'"');return"\n; Object connections\n;------------------------------------------------------------------\n\nConnections: {\n ".concat(e,"\n ").concat(n,"\n}")}},{key:"_floatArrayToString",value:function(e){for(var t=[],r=0;r<e.length;++r)t[r]=e[r].toFixed(6);return t.join(",")}},{key:"_colorLayer",value:function(e,t){var r=this._floatArrayToString(e),n=Tr(Array(t).keys());return"\n LayerElementColor: ".concat(0," {\n Version: ").concat(101,'\n Name: "').concat("",'"\n MappingInformationType: "ByVertice"\n ReferenceInformationType: "Direct"\n Colors: ').concat(r,"\n ColorIndex: ").concat(n,"\n }")}},{key:"_normalLayer",value:function(e){var t=this._floatArrayToString(e);return"\n LayerElementNormal: ".concat(0," {\n Version: ").concat(101,'\n Name: "').concat("",'"\n MappingInformationType: "ByVertice"\n ReferenceInformationType: "Direct" \n Normals: ').concat(t,"\n }")}},{key:"_verticesIndices",value:function(e,t){var r=this._floatArrayToString(e);return"MultiLayer: ".concat(0,"\n MultiTake: ").concat(1,"\n Shading: ").concat("Y",'\n Culling: "').concat("CullingOff",'"\n Vertices: ').concat(r,"\n PolygonVertexIndex: ").concat(t,"\n GeometryVersion: ").concat(124)}},{key:"_materialProperties",value:function(e){return'Properties60: {\n Property: "ShadingModel", "KString", "", "Lambert"\n Property: "MultiLayer", "bool", "",0\n Property: "EmissiveColor", "ColorRGB", "",0,0,0\n Property: "EmissiveFactor", "double", "",0.0000\n Property: "AmbientColor", "ColorRGB", "",1,1,1\n Property: "AmbientFactor", "double", "",0.0000\n Property: "DiffuseColor", "ColorRGB", "",'.concat(e.diffuse,'\n Property: "DiffuseFactor", "double", "",1.0000\n Property: "Bump", "Vector3D", "",0,0,0\n Property: "TransparentColor", "ColorRGB", "",1,1,1\n Property: "TransparencyFactor", "double", "",0.0000\n Property: "SpecularColor", "ColorRGB", "",').concat(e.specular,'\n Property: "SpecularFactor", "double", "",1.0000\n Property: "ShininessExponent", "double", "",').concat(e.shininess,'\n Property: "ReflectionColor", "ColorRGB", "",0,0,0\n Property: "ReflectionFactor", "double", "",1\n Property: "Ambient", "ColorRGB", "",1,1,1\n Property: "Diffuse", "ColorRGB", "",').concat(e.diffuse,'\n Property: "Specular", "ColorRGB", "",').concat(e.specular,'\n Property: "Shininess", "double", "",').concat(e.shininess,'\n Property: "Opacity", "double", "",').concat(e.opacity,'\n Property: "Reflectivity", "double", "",0\n }')}}]),e}();var mc=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return a(this,i),(r=n.call(this,e,t))._data=e,r._version=t.miewVersion||"0.0-UNSPECIFIED",r._extractor=new dc,r}return l(i,[{key:"exportSync",value:function(){var e=new pc;if(!this._source)return this._result;var t=this._extractor.process(this._data);return t.version=this._version,this._result=e.getResult(t),this._result}}]),i}(tc);mc.formats=["fbx"],mc.SourceClass=Ua;var vc,yc,_c,gc,xc,bc,wc,Sc,Rc,Cc,Ac,Ec,kc,Pc,Tc={loaders:os,parsers:Jl,exporters:new ec([nc,mc])},Mc=new i.Ilk,Nc=function(){function e(){a(this,e),this._width=0,this._height=0,this._widthHalf=0,this._heightHalf=0,this._vector=new i.Pa4,this._viewMatrix=new i.yGw,this._projectionMatrix=new i.yGw,this._domElement=document.createElement("div"),this._domElement.style.overflow="hidden",this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.zIndex="0",this._domElement.style.pointerEvents="none"}return l(e,[{key:"getElement",value:function(){return this._domElement}},{key:"reset",value:function(){for(var e=this.getElement();e.firstChild;)e.removeChild(e.firstChild)}},{key:"setSize",value:function(e,t){this._width=e,this._height=t,this._widthHalf=this._width/2,this._heightHalf=this._height/2,this._domElement.style.width="".concat(e,"px"),this._domElement.style.height="".concat(t,"px")}},{key:"_renderObject",value:function(e,t,r){function n(e,t,r){return Mc.setHex(e),Mc.lerp(t,r),"#".concat(Mc.getHexString())}function o(e){return Mc.setHex(e),"#".concat(Mc.getHexString())}if(e instanceof mr){if(this._vector.setFromMatrixPosition(e.matrixWorld),void 0!==e.userData&&void 0!==e.userData.offset){var a=new i.Pa4(e.userData.offset.x,e.userData.offset.y,0);this._vector.add(a.multiplyScalar(e.matrixWorld.getMaxScaleOnAxis()))}this._vector.applyMatrix4(this._viewMatrix);var s=this._vector.z>-t.near?"hidden":"visible",l=1e4*(t.far- -this._vector.z)/(t.far-t.near),c=e.getElement();if(void 0===r.fog)c.style.color=o(e.userData.color),"transparent"!==e.userData.background&&(c.style.background=o(e.userData.background));else{var u=i.M8C.smoothstep(-this._vector.z,r.fog.near,r.fog.far);c.style.color=n(e.userData.color,r.fog.color,u),"transparent"!==e.userData.background&&(c.style.background=n(e.userData.background,r.fog.color,u))}this._vector.applyMatrix4(this._projectionMatrix);var h="".concat(e.userData!=={}?e.userData.translation:"translate(-50%, -50%) ","translate(").concat(this._vector.x*this._widthHalf+this._widthHalf,"px,").concat(-this._vector.y*this._heightHalf+this._heightHalf,"px)");c.style.visibility=s,c.style.WebkitTransform=h,c.style.MozTransform=h,c.style.oTransform=h,c.style.transform=h,c.style.zIndex=Number(l).toFixed(0),c.parentNode!==this._domElement&&this._domElement.appendChild(c)}for(var f=0,d=e.children.length;f<d;f++)this._renderObject(e.children[f],t,r)}},{key:"render",value:function(e,t){e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),t.matrixWorldInverse.copy(t.matrixWorld).invert(),this._viewMatrix.copy(t.matrixWorldInverse),this._projectionMatrix.copy(t.projectionMatrix),this._renderObject(e,t,e)}}]),e}(),Ic={NONE:-1,ROTATE:0,TRANSLATE:1,SCALE:2,TRANSLATE_PIVOT:3},Oc=new i._fP,Lc=new i.yGw;function Bc(e,t,r,n){this.objects=e;var o=v(e,1);this.object=o[0],this.camera=t,this.pivot=r,this.axis=new i.Pa4(0,0,1),this.options=n,this.lastRotation={axis:new i.Pa4,angle:0}}function Dc(e,t,r,n,o){N.call(this);var a=this;this.object=e,this.objectPivot=t,this.camera=r,this.domElement=void 0!==n?n:document,this.getAltObj=o,this.enabled=!0,this.hotkeysEnabled=!0,this.screen={left:0,top:0,width:0,height:0},this.options={rotateFactor:Math.PI,axisRotateFactor:4*Math.PI,intertia:!0,dynamicDampingFactor:.1,intertiaThreshold:.001},this._state=Ic.NONE,this._mousePrevPos=new i.FM8,this._mouseCurPos=new i.FM8,this._mainObj=new Bc([this.object],this.camera,new i.Pa4(0,0,0),this.options),this._altObj=new Bc([this.object],this.camera,new i.Pa4(0,0,0),this.options),this._affectedObj=this._mainObj,this._isAltObjFreeRotationAllowed=!0,this._isTranslationAllowed=!0,this._isKeysTranslatingObj=!1,this._pressedKeys=[],this._clock=new C,this._clock.start(),this._lastUpdateTime=this._clock.getElapsedTime(),this._listeners=[{obj:a.domElement,type:"mousedown",handler:function(e){a.mousedown(e)}},{obj:a.domElement,type:"mouseup",handler:function(e){a.mouseup(e)}},{obj:a.domElement,type:"mousemove",handler:function(e){a.mousemove(e)}},{obj:a.domElement,type:"mousewheel",handler:function(e){a.mousewheel(e)}},{obj:a.domElement,type:"DOMMouseScroll",handler:function(e){a.mousewheel(e)}},{obj:a.domElement,type:"mouseout",handler:function(e){a.mouseup(e)}},{obj:a.domElement,type:"touchstart",handler:function(e){a.touchstartend(e)}},{obj:a.domElement,type:"touchend",handler:function(e){a.touchstartend(e)}},{obj:a.domElement,type:"touchmove",handler:function(e){a.touchmove(e)}},{obj:a.getKeyBindObject(),type:"keydown",handler:function(e){a.keydownup(e)}},{obj:a.getKeyBindObject(),type:"keyup",handler:function(e){a.keydownup(e)}},{obj:window,type:"resize",handler:function(){a.handleResize()}},{obj:window,type:"blur",handler:function(){a.resetKeys()}},{obj:a.domElement,type:"contextmenu",handler:function(e){a.contextmenu(e)}}];for(var s=0;s<this._listeners.length;s++){var l=this._listeners[s];l.obj.addEventListener(l.type,l.handler)}this.handleResize(),this.resetKeys(),this.update()}function zc(e,t,r){N.call(this);var n=this;this.gfxObj=e,this.camera=t,this.domElement=void 0!==r?r:document,this.screen={left:0,top:0,width:0,height:0},this._lastMousePos=new i.FM8(0,0),this._mouseTotalDist=0,this._lastClickBeginTime=-1e3,this._lastClickPos=new i.FM8(0,0),this._clickBeginTime=0,this._clock=new C,this._clock.start(),this._listeners=[{obj:n.domElement,type:"mousedown",handler:function(e){n.mousedown(e)}},{obj:n.domElement,type:"mouseup",handler:function(e){n.mouseup(e)}},{obj:n.domElement,type:"mousemove",handler:function(e){n.mousemove(e)}},{obj:n.domElement,type:"touchstart",handler:function(e){n.touchstart(e)}},{obj:n.domElement,type:"touchend",handler:function(e){n.touchend(e)}},{obj:window,type:"resize",handler:function(){n.handleResize()}}];for(var o=0;o<this._listeners.length;o++){var a=this._listeners[o];a.obj.addEventListener(a.type,a.handler)}this.handleResize()}Bc.prototype._rotate=function(){var e=new i.Pa4,t=new i._fP,r=new i.Pa4,n=new i.yGw;return function(i){var o=0===this.pivot.x&&0===this.pivot.y&&0===this.pivot.z;if(n.copy(this.object.matrix),o?n.multiply(Lc.makeRotationFromQuaternion(i)):(n.multiply(Lc.makeTranslation(this.pivot.x,this.pivot.y,this.pivot.z)),n.multiply(Lc.makeRotationFromQuaternion(i)),n.multiply(Lc.makeTranslation(-this.pivot.x,-this.pivot.y,-this.pivot.z))),n.decompose(e,t,r),!o)for(var a=0;a<this.objects.length;++a)this.objects[a].position.copy(e);for(var s=0;s<this.objects.length;++s)this.objects[s].quaternion.copy(t),this.objects[s].updateMatrix()}}(),Bc.prototype.setObjects=function(e){this.objects=e;var t=v(e,1);this.object=t[0]},Bc.prototype.rotate=(vc={axis:new i.Pa4,angle:0},function(e,t,r,n){this.mouse2rotation(vc,t,r,n),e.setFromAxisAngle(vc.axis,vc.angle),vc.angle&&this._rotate(e),this.lastRotation=vc}),Bc.prototype.translate=(yc=new i.Pa4,_c=new i.Pa4,function(e){yc.set(e.x/this.camera.projectionMatrix.elements[0],e.y/this.camera.projectionMatrix.elements[5],0);var t=yc.length();yc.normalize(),yc.transformDirection(Lc.copy(this.object.matrixWorld).invert()),_c.copy(this.pivot),this.object.localToWorld(_c),t*=Math.abs(_c.z-this.camera.position.z),t/=this.object.matrixWorld.getMaxScaleOnAxis();for(var r=0;r<this.objects.length;++r)this.objects[r].translateOnAxis(yc,t)}),Bc.prototype.update=(gc=new i.Pa4,function(e,t){if(0!==J.now.autoRotation)return J.now.autoRotationAxisFixed||0===this.lastRotation.axis.length()?gc.set(0,1,0).transformDirection(Lc.copy(this.object.matrixWorld).invert()):gc.copy(this.lastRotation.axis),this._rotate(Oc.setFromAxisAngle(gc,J.now.autoRotation*e)),!0;if(this.options.intertia&&this.lastRotation.angle){var r=this.lastRotation.angle*Math.pow(1-this.options.dynamicDampingFactor,40*t);if(!(Math.abs(r)<=this.options.intertiaThreshold))return this._rotate(Oc.setFromAxisAngle(this.lastRotation.axis,r)),!0;this.lastRotation.angle=0}return!1}),Bc.prototype.stop=function(){this.lastRotation.angle=0},Bc.prototype.mouse2rotation=(xc=new i.Pa4,bc=new i.Pa4,wc=new i.Pa4,Sc=new i.Pa4,Rc=new i.Pa4,Cc=new i.Pa4,Ac=new i.FM8,function(e,t,r,n){if(n)e.axis.copy(this.axis),e.angle=this.options.axisRotateFactor*(r.y-t.y);else{Ac.subVectors(r,t);var i=Ac.length();if(0===i)return;xc.copy(this.pivot),this.object.localToWorld(xc),bc.subVectors(this.camera.position,xc),wc.copy(bc).normalize(),Sc.copy(this.camera.up).normalize(),Rc.crossVectors(Sc,wc).normalize(),Sc.setLength(Ac.y),Rc.setLength(Ac.x),Cc.copy(Sc.add(Rc)),e.axis.crossVectors(Cc,bc),e.angle=-i*this.options.rotateFactor}e.axis.transformDirection(Lc.copy(this.object.matrixWorld).invert()),e.angle<0&&(e.axis.negate(),e.angle=-e.angle)}),Dc.prototype=Object.create(N.prototype),Dc.prototype.constructor=Dc,Dc.prototype.resetKeys=function(){this._pressedKeys[37]=!1,this._pressedKeys[38]=!1,this._pressedKeys[39]=!1,this._pressedKeys[40]=!1},Dc.prototype.contextmenu=function(e){e.stopPropagation(),e.preventDefault()},Dc.prototype.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}},Dc.prototype.enable=function(e){this.enabled=e},Dc.prototype.enableHotkeys=function(e){this.hotkeysEnabled=e},Dc.prototype.allowTranslation=function(e){this._isTranslationAllowed=e},Dc.prototype.allowAltObjFreeRotation=function(e){this._isAltObjFreeRotationAllowed=e},Dc.prototype.keysTranslateObj=function(e){this._isKeysTranslatingObj=e},Dc.prototype.isEditingAltObj=function(){return(this._state===Ic.ROTATE||this._state===Ic.TRANSLATE)&&this._affectedObj===this._altObj},Dc.prototype.convertMouseToOnCircle=function(e,t,r){var n=Math.min(this.screen.width,this.screen.height);0!==n?e.set((t-.5*this.screen.width-this.screen.left)/n,(.5*this.screen.height+this.screen.top-r)/n):e.set(0,0)},Dc.prototype.convertMouseToViewport=function(e,t,r){0!==this.screen.width&&0!==this.screen.height?e.set(2*(t-.5*this.screen.width-this.screen.left)/this.screen.width,2*(.5*this.screen.height+this.screen.top-r)/this.screen.height):e.set(0,0)},Dc.prototype.stop=function(){this._mainObj.stop(),this._altObj.stop()},Dc.prototype.rotateByMouse=(Ec=new i._fP,function(e){this._affectedObj.rotate(Ec,this._mousePrevPos,this._mouseCurPos,e),this.dispatchEvent({type:"change",action:"rotate",quaternion:Ec})}),Dc.prototype.rotate=function(e){this.object.quaternion.multiply(e),this.dispatchEvent({type:"change",action:"rotate",quaternion:e})},Dc.prototype.getOrientation=function(){return this.object.quaternion},Dc.prototype.setOrientation=function(e){this.object.quaternion.copy(e)},Dc.prototype.translate=(kc=new i.FM8,function(){kc.subVectors(this._mouseCurPos,this._mousePrevPos),this._affectedObj.translate(kc),this.dispatchEvent({type:"change",action:"translate"})}),Dc.prototype.getScale=function(){return this.object.scale.x},Dc.prototype.setScale=function(e){this.object.scale.set(e,e,e)},Dc.prototype.scale=function(e){e<=0||(this.setScale(this.object.scale.x*e),this.dispatchEvent({type:"change",action:"zoom",factor:e}))},Dc.prototype.update=(Pc=new i.FM8,function(){var e=this._clock.getElapsedTime(),t=e-this._lastUpdateTime;if(this._state===Ic.NONE){var r=e-this._lastMouseMoveTime;(this._mainObj.update(t,r)||this._altObj.update(t,r))&&this.dispatchEvent({type:"change",action:"auto"})}if(this._isKeysTranslatingObj){var n=Number(this._pressedKeys[39])-Number(this._pressedKeys[37]),i=Number(this._pressedKeys[38])-Number(this._pressedKeys[40]);if(0!==n||0!==i){var o=t,a=this.getAltObj();a.objects.length>0&&(this._altObj.setObjects(a.objects),this._altObj.pivot=a.pivot,"axis"in a?this._altObj.axis=a.axis.clone():this._altObj.axis.set(0,0,1),Pc.set(o*n,o*i),this._altObj.translate(Pc),this.dispatchEvent({type:"change",action:"translate"}))}}this._lastUpdateTime=e}),Dc.prototype.reset=function(){this._state=Ic.NONE,this.object.quaternion.copy(Oc.set(0,0,0,1))},Dc.prototype.mousedown=function(e){if(!1!==this.enabled&&this._state===Ic.NONE){if(e.preventDefault(),e.stopPropagation(),this._state===Ic.NONE)if(0===e.button){this._affectedObj.stop();var t=!1;if(e.altKey){var r=this.getAltObj();(t=r.objects.length>0)&&(this._altObj.setObjects(r.objects),this._altObj.pivot=r.pivot,"axis"in r?this._altObj.axis=r.axis.clone():this._altObj.axis.set(0,0,1))}this._affectedObj=t?this._altObj:this._mainObj,this._state=t&&e.ctrlKey&&this._isTranslationAllowed?Ic.TRANSLATE:Ic.ROTATE}else 2===e.button&&(this._state=Ic.TRANSLATE_PIVOT);this._state===Ic.ROTATE&&(this.convertMouseToOnCircle(this._mouseCurPos,e.pageX,e.pageY),this._mousePrevPos.copy(this._mouseCurPos)),this._state!==Ic.TRANSLATE&&this._state!==Ic.TRANSLATE_PIVOT||(this.convertMouseToViewport(this._mouseCurPos,e.pageX,e.pageY),this._mousePrevPos.copy(this._mouseCurPos))}},Dc.prototype.mousemove=function(e){if(!1!==this.enabled&&this._state!==Ic.NONE)switch(e.preventDefault(),e.stopPropagation(),this._state){case Ic.ROTATE:this._mousePrevPos.copy(this._mouseCurPos),this.convertMouseToOnCircle(this._mouseCurPos,e.pageX,e.pageY),this.rotateByMouse(e.altKey&&!this._isAltObjFreeRotationAllowed||e.shiftKey),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case Ic.TRANSLATE:this._mousePrevPos.copy(this._mouseCurPos),this.convertMouseToViewport(this._mouseCurPos,e.pageX,e.pageY),this.translate();break;case Ic.TRANSLATE_PIVOT:this._mousePrevPos.copy(this._mouseCurPos),this.convertMouseToViewport(this._mouseCurPos,e.pageX,e.pageY),this.translatePivotByMouse()}},Dc.prototype.mousewheel=function(e){if(!1!==this.enabled&&J.now.zooming&&this._state===Ic.NONE&&!e.shiftKey){e.preventDefault();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3);var r=1+.05*t;r=Math.max(r,.01),this.scale(r)}},Dc.prototype.mouseup=function(e){!1!==this.enabled&&this._state!==Ic.NONE&&(e.preventDefault(),e.stopPropagation(),this._state=Ic.NONE,this._clock.getElapsedTime()-this._lastMouseMoveTime>.1&&this._affectedObj.stop())},Dc.prototype.touchstartend=function(e){if(!1!==this.enabled)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:this._state=Ic.ROTATE,this.convertMouseToOnCircle(this._mouseCurPos,e.touches[0].pageX,e.touches[0].pageY),this._mousePrevPos.copy(this._mouseCurPos);break;case 2:this._mainObj.stop(),this._altObj.stop(),this._state=Ic.SCALE;var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;this._touchDistanceCur=this._touchDistanceStart=Math.sqrt(t*t+r*r),this._scaleStart=this.object.scale.x;break;default:this._state=Ic.NONE}},Dc.prototype.touchmove=function(e){if(!1!==this.enabled&&this._state!==Ic.NONE)switch(e.preventDefault(),e.stopPropagation(),this._state){case Ic.ROTATE:this._mousePrevPos.copy(this._mouseCurPos),this.convertMouseToOnCircle(this._mouseCurPos,e.touches[0].pageX,e.touches[0].pageY),this.rotateByMouse(!1),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case Ic.SCALE:if(J.now.zooming){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;this._touchDistanceCur=Math.sqrt(t*t+r*r);var n=this._scaleStart*this._touchDistanceCur/this._touchDistanceStart/this.object.scale.x;this.scale(n)}}},Dc.prototype.keydownup=function(e){if(!1!==this.enabled&&!1!==this.hotkeysEnabled)switch(e.keyCode){case 37:case 38:case 39:case 40:this._pressedKeys[e.keyCode]="keydown"===e.type,e.preventDefault(),e.stopPropagation()}},Dc.prototype.getKeyBindObject=function(){return window.top},Dc.prototype.dispose=function(){for(var e=0;e<this._listeners.length;e++){var t=this._listeners[e];t.obj.removeEventListener(t.type,t.handler)}},Dc.prototype.translatePivotByMouse=function(){var e=new i.FM8;return function(){e.subVectors(this._mouseCurPos,this._mousePrevPos),this.translatePivotInWorld(J.now.translationSpeed*e.x,J.now.translationSpeed*e.y,0)}}(),Dc.prototype.translatePivotInWorld=function(e,t,r){var n=this.objectPivot.position;n.applyMatrix4(this.object.matrixWorld),n.setX(n.x+e),n.setY(n.y+t),n.setZ(n.z+r),n.applyMatrix4(Lc.copy(this.object.matrixWorld).invert()),this.dispatchEvent({type:"change",action:"translatePivot"})},Dc.prototype.translatePivot=function(e,t,r){var n=this.objectPivot.position;n.setX(n.x+e),n.setY(n.y+t),n.setZ(n.z+r),this.dispatchEvent({type:"change",action:"translatePivot"})},Dc.prototype.setPivot=function(e){this.objectPivot.position.copy(e),this.dispatchEvent({type:"change",action:"translatePivot"})},zc.prototype=Object.create(N.prototype),zc.prototype.constructor=zc,zc.prototype.reset=function(){this.picked={},this.dispatchEvent({type:"newpick",obj:{}})},zc.prototype.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}},zc.prototype.pickObject=function(e){if(!this.gfxObj)return this.picked={},void this.dispatchEvent({type:"newpick",obj:{}});var t=this.gfxObj,r=new i.iMs;r.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),r.ray.direction.set(e.x,e.y,.5).unproject(this.camera).sub(r.ray.origin).normalize();var n=J.now.draft.clipPlane&&this.clipPlaneValue?this.clipPlaneValue:1/0,o=J.now.fog&&this.fogFarValue?this.fogFarValue:1/0,a=r.intersectVisibleObject(t,this.camera,n,o);if(!a)return this.picked={},void this.dispatchEvent({type:"newpick",obj:{}});var s={};if(a.residue||a.atom){var l=a.residue||a.atom.residue;"chain"===J.now.pick?s={chain:l.getChain()}:"molecule"===J.now.pick?s={molecule:l.getMolecule()}:a.residue||"residue"===J.now.pick?s={residue:l}:a.atom&&(s={atom:a.atom})}this.picked=s,this.dispatchEvent({type:"newpick",obj:s})},zc.prototype.getMouseInViewport=function(e,t){return new i.FM8((e-this.screen.left)/this.screen.width*2-1,-(t-this.screen.top)/this.screen.height*2+1)},zc.prototype.mousedown=function(e){e.preventDefault(),e.stopPropagation(),0===e.button&&(this._lastMousePos=this.getMouseInViewport(e.pageX,e.pageY),this._mouseTotalDist=0,this._clickBeginTime=this._clock.getElapsedTime())},zc.prototype.mousemove=function(e){e.preventDefault(),e.stopPropagation();var t=this.getMouseInViewport(e.pageX,e.pageY);this._mouseTotalDist+=t.sub(this._lastMousePos).length()},zc.prototype.mouseup=function(e){var t=this;if(e.preventDefault(),e.stopPropagation(),0===e.button&&this._mouseTotalDist<.01){var r=this._clock.getElapsedTime(),n=this.getMouseInViewport(e.pageX,e.pageY);if(r-this._lastClickBeginTime<.7&&(new i.FM8).subVectors(n,this._lastClickPos).length()<.01)return this.dispatchEvent({type:"dblclick",obj:this.picked}),this._lastClickPos=n,void(this._lastClickBeginTime=-1e3);setTimeout((function(){t.pickObject(n)}),0),this._lastClickPos=n,this._lastClickBeginTime=this._clickBeginTime}},zc.prototype.touchstart=function(e){e.preventDefault(),e.stopPropagation(),1===e.touches.length&&(this._lastTouchdownPos=this.getMouseInViewport(e.touches[0].pageX,e.touches[0].pageY))},zc.prototype.touchend=function(e){var t=this;e.preventDefault(),e.stopPropagation(),0===e.touches.length&&1===e.changedTouches.length&&this.getMouseInViewport(e.changedTouches[0].pageX,e.changedTouches[0].pageY).sub(this._lastTouchdownPos).length()<.01&&setTimeout((function(){t.pickObject(t._lastTouchdownPos)}),0)},zc.prototype.dispose=function(){for(var e=0;e<this._listeners.length;e++){var t=this._listeners[e];t.obj.removeEventListener(t.type,t.handler)}};var Fc=function(){function e(t,r){a(this,e),this._target=t,this._targetCamera=r,this._camera=new i.cPb(r.fov,r.aspect,1,100),this._object=new i.y8_(1),this._scene=new i.xsS,this._scene.add(this._object),this._full=new i.FM8,this._update()}return l(e,[{key:"_update",value:function(){var e=this._targetCamera.fov,t=this._camera;t.aspect=this._targetCamera.aspect,t.setMinimalFov(e),t.setDistanceToFit(1,e),t.updateProjectionMatrix(),this._object.quaternion.copy(this._target.quaternion)}},{key:"render",value:function(e){this._update(),e.getSize(this._full);var t=.25*this._full.width,r=.25*this._full.height,n=e.autoClear;e.autoClear=!1,e.setViewport(0,0,t,r),e.clear(!1,!0,!1),e.render(this._scene,this._camera),e.setViewport(0,0,this._full.width,this._full.height),e.autoClear=n}}]),e}(),Vc=["helix","strand"],Uc=["fs","ps","ns","us"];function Gc(e,t){for(var r=t._residues,n=r.length,i=new Uint8Array(n),o=t._atoms,a=0,s=e.length;a<s;++a)i[o[a].residue._index]=e[a];for(var l=[],c=0;c<n;){if(0!==i[c]){for(var u=c,h=i[c];c<n-1&&i[c+1]===h&&r[c].isConnected(r[c+1]);)++c;l.push({start:u,end:c,type:Vc[h-1]})}++c}return l}function jc(e){return e>=524288?e-1048576:e}var Hc=function(){function e(t,r,n){a(this,e),this._complex=t,this._secondary=null,this.isLoading=!1,this._framesRange={start:0,end:-1},this.frameIsReady=!1,this._buffer=null,this._frameRequest=null,this._callbacks=n,"function"==typeof r?(this._framesRequestLength=1,this._downloadDataFn=r):this.parseBinaryData(r,!0),this.reset(),this.setFrame(0)}return l(e,[{key:"_prepareBuffer",value:function(e,t){if(null==e&&(e=0),null==t&&(t=e+this._framesRequestLength),void 0!==this._framesCount&&(t=Math.min(this._framesCount-1,t)),this._downloadDataFn){var r=this;this._buffer||(this._buffer={}),this._buffer.state="downloading",this.isLoading=!0,r._callbacks&&"function"==typeof r._callbacks.onLoadStatusChanged&&r._callbacks.onLoadStatusChanged(),this._downloadDataFn({start:e,end:t+1},(function(n){if(r.isLoading=!1,r._callbacks&&"function"==typeof r._callbacks.onLoadStatusChanged&&r._callbacks.onLoadStatusChanged(),r._buffer={data:n,state:"ready",start:e,end:t},null!==r._frameRequest){var i=r._frameRequest;r._frameRequest=null,r.setFrame(i)}}),(function(){r.isLoading=!1,r._callbacks&&"function"==typeof r._callbacks.onError&&r._callbacks.onError("Streaming failed")}))}}},{key:"_parseBuffer",value:function(){if(this._buffer&&"ready"===this._buffer.state){this._framesRange={start:this._buffer.start,end:this._buffer.end},this.parseBinaryData(this._buffer.data,!1);var e=(this._buffer.end+1)%this._framesCount;if(e>=this._framesCount&&(e=0),this._buffer={state:"none"},this._prepareBuffer(e,e+this._framesRequestLength),null!==this._frameRequest){var t=this._frameRequest;this._frameRequest=null,this.setFrame(t)}}}},{key:"parseBinaryData",value:function(e){var t=new DataView(e),r=0,n=t.getUint32(r,!0);r+=4;var i=t.getUint32(r,!0);this._framesCount=i,this._framesRange.end=this._framesRange.end>0?Math.min(this._framesRange.end,i-1):i-1,r+=4,this._atomsCount=n,this._framesRequestLength=Math.ceil(1048576/(8*n));var o=this._framesRange.end-this._framesRange.start+1;if(n!==this._complex._atoms.length||e.byteLength!==12+o*n*8)throw new Error;for(var a=this._complex,s=t.getUint32(r,!0),l=0;s>1e3&&l<Uc.length-1;)s/=1e3,++l;this._timeStep="".concat(s.toString()," ").concat(Uc[l]),r+=4;for(var c=[],u=new Float32Array(o*n*3),h=0,f=new Int8Array(n),d=0;d<o;++d){for(var p=0;p<n;++p){var m=t.getUint32(r,!0);r+=4;var v=t.getUint32(r,!0);r+=4;var y=(4026531840&v)>>>28,_=jc((268435200&v)>>>8>>0),g=jc(((255&v)<<12|(4293918720&m)>>>20)>>0),x=jc((1048575&m)>>0);f[p]=0,y>0&&y<4?f[p]=1:4===y&&(f[p]=2),u[h++]=_/100,u[h++]=g/100,u[h++]=x/100}c.push(Gc(f,a))}this._secondaryData=c,this._data=u}},{key:"nextFrame",value:function(){this.setFrame((this._currFrame+1)%this._framesCount)}},{key:"needsColorUpdate",value:function(e){return e instanceof ha}},{key:"getAtomColor",value:function(e,t){return e.getResidueColor(this._residues[t.residue._index],this._complex)}},{key:"getResidueColor",value:function(e,t){return e.getResidueColor(this._residues[t._index],this._complex)}},{key:"_updateSecondary",value:function(){var e,t=this._residues,r=t.length;for(e=0;e<r;++e)t[e]._secondary=null;var n=this._secondaryData[this._currFrame-this._framesRange.start];for(e=0,r=n.length;e<r;++e)for(var i=n[e],o=i.start,a=i.end,s={_start:t[o],_end:t[a],type:i.type,generic:i.generic},l=o;l<=a;++l)t[l]._secondary=s}},{key:"reset",value:function(){var e=this._complex._residues,t=e.length;this._residues=new Array(t);for(var r=this._residues,n=function(){return this._secondary},i=0;i<t;++i)r[i]={_type:e[i]._type,_isValid:e[i]._isValid,_controlPoint:null,_wingVector:null,_secondary:null,getSecondary:n}}},{key:"setFrame",value:function(e){if(this.frameIsReady=!1,e>=this._framesRange.start&&e<=this._framesRange.end)this._currFrame=e,this._cachedResidues=!1,this._updateSecondary(),this.frameIsReady=!0;else if(this._frameRequest=e,this._buffer)switch(this._buffer.state){case"none":this._prepareBuffer(e);break;case"ready":this._parseBuffer()}else this._prepareBuffer(e)}},{key:"disableEvents",value:function(){this._callbacks=null}},{key:"getAtomPos",value:function(t){var r=e._vec,n=this,i=n._data,o=3*(n._atomsCount*(n._currFrame-n._framesRange.start)+t);return r.set(i[o],i[o+1],i[o+2]),r}},{key:"getResidues",value:function(){return this._cachedResidues||this._complex.updateToFrame(this),this._residues}}]),e}();Re(Hc,"_vec",new i.Pa4);var Wc=function(){function e(t,r){if(a(this,e),this.constructor===e)throw new Error("Can not instantiate abstract class!");this.params=t,this.opts=(0,n.merge)($.deriveDeep(J.now.objects[this.type],!0),r),this.needsRebuild=!1,this._mesh=null,this.id=null}return l(e,[{key:"identify",value:function(){var e={type:this.type,params:this.params},t=$.objectsDiff(this.opts,J.now.modes[this.id]);return(0,n.isEmpty)(t)||(e.opts=t),e}},{key:"toString",value:function(){return"o=".concat(this.type,",").concat(this.params.join(","))+$.compareOptionsWithDefaults(this.opts,J.defaults.objects[this.type])}},{key:"getGeometry",value:function(){return this._mesh}},{key:"destroy",value:function(){this._mesh&&Er.destroyObject(this._mesh)}}]),e}();Wc.prototype.type="__";var Yc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;if(a(this,o),r=n.call(this,e,t),e.length<2)throw new Error("Wrong number of argumets on line object creation!");var i=v(e,2);return r._id1=i[0],r._id2=i[1],r}return l(o,[{key:"_getAtomFromName",value:function(e,t){var r=e.getAtomByFullname(t);if(!r)throw new Error(t+" - Wrong atom format it must be '#CHAIN_NAME.#RESIDUE_NUMBER.#ATOM_NAME' (e.g. 'A.38.CO1')");return r}},{key:"build",value:function(e){var t=new i.u9r;this._atom1=this._getAtomFromName(e,this._id1),this._atom2=this._getAtomFromName(e,this._id2);var r=this._atom1.position,n=this._atom2.position,o=new Float32Array([r.x,r.y,r.z,n.x,n.y,n.z]);t.setAttribute("position",new i.TlE(o,3)),t.computeBoundingBox();var a=new ui;a.setValues({lights:!1,overrideColor:!0,dashedLine:!0,fogTransparent:J.now.bg.transparent}),this._line=new wi.Line(t,a),this._line.computeLineDistances(),this._line.material.setUberOptions({fixedColor:new i.Ilk(this.opts.color),dashedLineSize:this.opts.dashSize,dashedLinePeriod:this.opts.dashSize+this.opts.gapSize}),this._line.material.updateUniforms(),this._line.raycast=function(e,t){},this._mesh=this._line;var s=e.getTransforms();s.length>0&&(this._mesh=new i.ZAu,this._mesh.add(this._line),Ta.applyTransformsToMeshes(this._mesh,s))}},{key:"updateToFrame",value:function(e){if(this._atom1&&this._atom2&&this._line){var t=this._line.geometry;t.vertices[0].copy(e.getAtomPos(this._atom1.index)),t.vertices[1].copy(e.getAtomPos(this._atom2.index)),this._line.computeLineDistances(),t.computeBoundingSphere(),t.verticesNeedUpdate=!0}}}]),o}(Wc);Yc.prototype.constructor=Yc,Yc.prototype.type="line";var Xc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;a(this,o),t=n.call(this,e);var r={uniforms:{srcTex:{type:"t",value:null},srcDepthTex:{type:"t",value:null},srcTexSize:{type:"v2",value:new i.FM8(512,512)},color:{type:"v3",value:null},threshold:{type:"f",value:null},opacity:{type:"f",value:1},thickness:{type:"v2",value:new i.FM8(1,1)}},vertexShader:yr,fragmentShader:"precision highp float;\r\n\r\nuniform sampler2D srcTex;\r\nuniform vec2 srcTexSize;\r\nuniform vec2 thickness;\r\nvarying vec2 vUv;\r\n\r\n#ifdef DEPTH_OUTLINE\r\n uniform sampler2D srcDepthTex; //depthTexture\r\n uniform vec3 color;\r\n uniform float threshold;\r\n#endif\r\n\r\nvoid main() {\r\n\r\n vec2 pixelSize = thickness / srcTexSize;\r\n\r\n #ifdef DEPTH_OUTLINE\r\n float c00 = texture2D(srcDepthTex, vUv + vec2(-pixelSize.x,-pixelSize.y)).x;\r\n float c01 = texture2D(srcDepthTex, vUv + vec2(0,-pixelSize.y)).x;\r\n float c02 = texture2D(srcDepthTex, vUv + vec2(pixelSize.x,-pixelSize.y)).x;\r\n float c10 = texture2D(srcDepthTex, vUv + vec2(-pixelSize.x,0)).x;\r\n float c12 = texture2D(srcDepthTex, vUv + vec2(pixelSize.x,0)).x;\r\n float c20 = texture2D(srcDepthTex, vUv + vec2(-pixelSize.x,pixelSize.y)).x;\r\n float c21 = texture2D(srcDepthTex, vUv + vec2(0,pixelSize.y)).x;\r\n float c22 = texture2D(srcDepthTex, vUv + vec2(pixelSize.x,pixelSize.y)).x;\r\n\r\n float horizEdge = - c00 - 2.0 * c01 - c02 + c20 + 2.0 * c21 + c22;\r\n float vertEdge = - c00 - 2.0 * c10 - c20 + c02 + 2.0 * c12 + c22;\r\n\r\n float grad = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);\r\n\r\n gl_FragColor = ( grad > threshold ) ? vec4(color.rgb, 1.0) : gl_FragColor = texture2D(srcTex, vUv);\r\n\r\n #else\r\n vec4 c00 = texture2D(srcTex, vUv + vec2(-pixelSize.x,-pixelSize.y));\r\n vec4 c01 = texture2D(srcTex, vUv + vec2(0,-pixelSize.y));\r\n vec4 c02 = texture2D(srcTex, vUv + vec2(pixelSize.x,-pixelSize.y));\r\n vec4 c10 = texture2D(srcTex, vUv + vec2(-pixelSize.x,0));\r\n vec4 c12 = texture2D(srcTex, vUv + vec2(pixelSize.x,0));\r\n vec4 c20 = texture2D(srcTex, vUv + vec2(-pixelSize.x,pixelSize.y));\r\n vec4 c21 = texture2D(srcTex, vUv + vec2(0,pixelSize.y));\r\n vec4 c22 = texture2D(srcTex, vUv + vec2(pixelSize.x,pixelSize.y));\r\n\r\n vec4 horizEdge = - c00 - 2.0 * c01 - c02 + c20 + 2.0 * c21 + c22;\r\n vec4 vertEdge = - c00 - 2.0 * c10 - c20 + c02 + 2.0 * c12 + c22;\r\n\r\n vec4 grad = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);\r\n gl_FragColor = grad;\r\n #endif\r\n}\r\n",transparent:!0,depthTest:!1,depthWrite:!1};return t.setValues(r),t}return l(o,[{key:"copy",value:function(e){Xe(d(o.prototype),"copy",this).call(this,e),this.depth=e.depth}},{key:"setValues",value:function(e){if(void 0!==e){Xe(d(o.prototype),"setValues",this).call(this,e);var t={};this.depth&&(t.DEPTH_OUTLINE=1),this.defines=t}}}]),o}(i.FIo);Xc.prototype.depth=!1;var qc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;return a(this,o),(t=n.call(this,e)).setValues({uniforms:{srcTex:{type:"t",value:null},srcTexelSize:{type:"v2",value:new i.FM8(1/512,1/512)},bgColor:{type:"c",value:new i.Ilk(16777215)}},vertexShader:yr,fragmentShader:"precision highp float;\r\n\r\n// edge end finding algorithm parameters\r\n#define FXAA_QUALITY_PS 8\r\n#define FXAA_QUALITY_P0 1.0\r\n#define FXAA_QUALITY_P1 1.5\r\n#define FXAA_QUALITY_P2 2.0\r\n#define FXAA_QUALITY_P3 2.0\r\n#define FXAA_QUALITY_P4 2.0\r\n#define FXAA_QUALITY_P5 2.0\r\n#define FXAA_QUALITY_P6 4.0\r\n#define FXAA_QUALITY_P7 12.0\r\n// constants\r\nfloat fxaaQualityEdgeThreshold = 0.125;\r\nfloat fxaaQualityEdgeThresholdMin = 0.0625;\r\nfloat fxaaQualitySubpix = 0.7; //0.65;\r\n// global params\r\nuniform sampler2D srcTex;\r\nuniform vec2 srcTexelSize;\r\nuniform vec3 bgColor;\r\n// from vs\r\nvarying vec2 vUv;\r\n//=====================================================================//\r\n// calc luminance from rgb\r\n//'float FxaaLuma(vec3 rgb) {return rgb.y * (0.587/0.299) + rgb.x; } // Lotte's idea about game luminance\r\nfloat FxaaLuma(vec3 rgb) {return dot(rgb, vec3(0.299, 0.587, 0.114)); } // real luminance calculation\r\n // for non-real scene rendering\r\n// texture sampling by pixel position(coords) and offset(in pixels)\r\n vec3 FxaaTex(sampler2D tex, vec2 pos, vec2 off, vec2 res ) {\r\n #ifdef BG_TRANSPARENT\r\n vec4 color = texture2D( tex, pos + off * res );\r\n return mix(color.rgb, bgColor, 1.0 - color.a);\r\n #else\r\n return texture2D( tex, pos + off * res ).xyz;\r\n #endif\r\n}\r\nvec3 FxaaTexTop(sampler2D tex, vec2 pos) {\r\n #ifdef BG_TRANSPARENT\r\n vec4 color = texture2D( tex, pos );\r\n return mix(color.rgb, bgColor, 1.0 - color.a);\r\n #else\r\n return texture2D( tex, pos).xyz;\r\n #endif\r\n}\r\nvec4 FxaaTexTopAlpha(sampler2D tex, vec2 pos) {\r\n return texture2D( tex, pos);\r\n}\r\n\r\n//=====================================================================//\r\nvoid main() {\r\n // renaming\r\n vec2 posM = vUv;\r\n // get luminance for neighbours\r\n float lumaS = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, 1.0 ), srcTexelSize));\r\n float lumaE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 0.0 ), srcTexelSize));\r\n float lumaN = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, -1.0 ), srcTexelSize));\r\n float lumaW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 0.0 ), srcTexelSize));\r\n float lumaM = FxaaLuma(FxaaTexTop(srcTex, posM));\r\n // find max and min luminance\r\n float rangeMax = max(max(lumaN, lumaW), max(lumaE, max(lumaS, lumaM)));\r\n float rangeMin = min(min(lumaN, lumaW), min(lumaE, min(lumaS, lumaM)));\r\n // calc maximum non-edge range\r\n float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\r\n float range = rangeMax - rangeMin;\r\n float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\r\n // exit when luma contrast is small (is not edge)\r\n if(range < rangeMaxClamped){\r\n gl_FragColor = FxaaTexTopAlpha(srcTex, posM);\r\n return;\r\n }\r\n float subpixRcpRange = 1.0/range;\r\n // note: the sampling coordinates can be calculated in vertex shader but the approach doesn't affect performance\r\n // visibly, thus we decided to leave calculation here for better readability.\r\n // calc other neighbours luminance\r\n float lumaNE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, -1.0 ), srcTexelSize));\r\n float lumaSW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 1.0 ), srcTexelSize));\r\n float lumaSE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 1.0 ), srcTexelSize));\r\n float lumaNW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, -1.0 ), srcTexelSize));\r\n/*--------------span calculation and subpix amount calulation-----------------*/\r\n float lumaNS = lumaN + lumaS;\r\n float lumaWE = lumaW + lumaE;\r\n float subpixNSWE = lumaNS + lumaWE;\r\n float edgeHorz1 = (-2.0 * lumaM) + lumaNS;\r\n float edgeVert1 = (-2.0 * lumaM) + lumaWE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNESE = lumaNE + lumaSE;\r\n float lumaNWNE = lumaNW + lumaNE;\r\n float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\r\n float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNWSW = lumaNW + lumaSW;\r\n float lumaSWSE = lumaSW + lumaSE;\r\n float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\r\n float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\r\n float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\r\n float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\r\n float edgeHorz = abs(edgeHorz3) + edgeHorz4;\r\n float edgeVert = abs(edgeVert3) + edgeVert4;\r\n/*--------------------subpix amount calulation------------------------------*/\r\n float subpixNWSWNESE = lumaNWSW + lumaNESE;\r\n float lengthSign = srcTexelSize.x;\r\n bool horzSpan = edgeHorz >= edgeVert;\r\n // debug code edge span visualization\r\n/*' if (horzSpan)\r\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\r\n else\r\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\r\n return;*/\r\n float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\r\n/*--------------------------------------------------------------------------*/\r\n if(!horzSpan) lumaN = lumaW;\r\n if(!horzSpan) lumaS = lumaE;\r\n if(horzSpan) lengthSign = srcTexelSize.y;\r\n float subpixB = (subpixA * (1.0/12.0)) - lumaM;\r\n/*--------------------------------------------------------------------------*/\r\n float gradientN = lumaN - lumaM;\r\n float gradientS = lumaS - lumaM;\r\n float lumaNN = lumaN + lumaM;\r\n float lumaSS = lumaS + lumaM;\r\n bool pairN = abs(gradientN) >= abs(gradientS);\r\n float gradient = max(abs(gradientN), abs(gradientS));\r\n if(pairN) lengthSign = -lengthSign;\r\n float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posB;\r\n posB = posM;\r\n vec2 offNP;\r\n offNP.x = (!horzSpan) ? 0.0 : srcTexelSize.x;\r\n offNP.y = ( horzSpan) ? 0.0 : srcTexelSize.y;\r\n if(!horzSpan) posB.x += lengthSign * 0.5;\r\n if( horzSpan) posB.y += lengthSign * 0.5;\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posN;\r\n posN = posB - offNP * FXAA_QUALITY_P0;\r\n vec2 posP;\r\n posP = posB + offNP * FXAA_QUALITY_P0;\r\n float subpixD = ((-2.0)*subpixC) + 3.0;\r\n float lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN));\r\n float subpixE = subpixC * subpixC;\r\n float lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP));\r\n/*--------------------------------------------------------------------------*/\r\n if(!pairN) lumaNN = lumaSS;\r\n float gradientScaled = gradient * 1.0/4.0;\r\n float lumaMM = lumaM - lumaNN * 0.5;\r\n float subpixF = subpixD * subpixE;\r\n bool lumaMLTZero = lumaMM < 0.0;\r\n/*---------------------looped edge-end search-------------------------------*/\r\n lumaEndN -= lumaNN * 0.5;\r\n lumaEndP -= lumaNN * 0.5;\r\n bool doneN = abs(lumaEndN) >= gradientScaled;\r\n bool doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P1;\r\n bool doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P1;\r\n/*--------------------------------------------------------------------------*/\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P2;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P2;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 3)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P3;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P3;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 4)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P4;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P4;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 5)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P5;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P5;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 6)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P6;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P6;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 7)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P7;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P7;\r\n/*--------------------------------------------------------------------------*/\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n/*----------------calculate subpix offset due to edge ends-------------------*/\r\n float dstN = posM.x - posN.x;\r\n float dstP = posP.x - posM.x;\r\n if(!horzSpan) dstN = posM.y - posN.y;\r\n if(!horzSpan) dstP = posP.y - posM.y;\r\n/*--------------------------------------------------------------------------*/\r\n bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\r\n float spanLength = (dstP + dstN);\r\n bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\r\n float spanLengthRcp = 1.0 / spanLength;\r\n/*--------------------------------------------------------------------------*/\r\n bool directionN = dstN < dstP;\r\n float dst = min(dstN, dstP);\r\n bool goodSpan = directionN ? goodSpanN : goodSpanP;\r\n float subpixG = subpixF * subpixF;\r\n float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\r\n float subpixH = subpixG * fxaaQualitySubpix;\r\n/*-----------------calc texture offest using subpix-------------------------*/\r\n float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\r\n float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\r\n\r\n float offset = pixelOffsetSubpix * lengthSign;\r\n #ifdef BG_TRANSPARENT\r\n // get original texel\r\n vec4 rgbaA = FxaaTexTopAlpha(srcTex, posM);\r\n // calc step to blended texel\r\n vec2 step = sign((!horzSpan) ? vec2 (offset, 0.0) : vec2 (0.0, offset));\r\n // get neighboring texel\r\n vec4 rgbaB = FxaaTexTopAlpha(srcTex, posM + step * srcTexelSize);\r\n // calc blend factor from offset\r\n float f = (!horzSpan) ? offset / srcTexelSize.x : offset / srcTexelSize.y;\r\n f = abs(f);\r\n // calc alpha (special formula to emulate blending with bg)\r\n gl_FragColor.a = 1.0 - mix(1.0 - rgbaA.a, 1.0 - rgbaB.a, f);\r\n // calc color (special formula to emulate blending with bg)\r\n gl_FragColor.rgb = mix(rgbaA.rgb * rgbaA.a, rgbaB.rgb * rgbaB.a, f) / gl_FragColor.a;\r\n #else\r\n if(!horzSpan) {\r\n posM.x += offset;\r\n } else {\r\n posM.y += offset;\r\n }\r\n gl_FragColor = FxaaTexTopAlpha(srcTex, posM);\r\n #endif\r\n return;\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1}),t.setValues(e),t}return l(o,[{key:"copy",value:function(e){Xe(d(o.prototype),"copy",this).call(this,e),this.depth=e.depth}},{key:"setValues",value:function(e){if(void 0!==e){Xe(d(o.prototype),"setValues",this).call(this,e);var t={};this.bgTransparent&&(t.BG_TRANSPARENT=1),this.defines=t}}}]),o}(i.FIo);qc.prototype.bgTransparent=!1;var $c=[new i.Pa4(.295184,.077723,.068429),new i.Pa4(-.271976,-.365221,.838363),new i.Pa4(.547713,.467576,.488515),new i.Pa4(.662808,-.031733,.584758),new i.Pa4(-.025717,.218955,.657094),new i.Pa4(-.310153,-.365223,.370701),new i.Pa4(-.101407,-.006313,.747665),new i.Pa4(-.769138,.360399,.086847),new i.Pa4(-.271988,-.27514,.905353),new i.Pa4(.09674,-.566901,.700151),new i.Pa4(.562872,-.735136,.094647),new i.Pa4(.379877,.359278,.190061),new i.Pa4(.519064,-.023055,.405068),new i.Pa4(-.301036,.114696,.088885),new i.Pa4(-.282922,.598305,.487214),new i.Pa4(-.181859,.25167,.679702),new i.Pa4(-.191463,-.635818,.512919),new i.Pa4(-.293655,.427423,.078921),new i.Pa4(-.267983,.680534,.13288),new i.Pa4(.139611,.319637,.477439),new i.Pa4(-.352086,.31104,.653913),new i.Pa4(.321032,.805279,.487345),new i.Pa4(.073516,.820734,.414183),new i.Pa4(-.155324,.589983,.41146),new i.Pa4(.335976,.170782,.527627),new i.Pa4(.46346,-.355658,.167689),new i.Pa4(.222654,.59655,.769406),new i.Pa4(.922138,-.04207,.147555),new i.Pa4(-.72705,-.329192,.369826),new i.Pa4(-.090731,.53382,.463767),new i.Pa4(-.323457,-.876559,.238524),new i.Pa4(-.663277,-.372384,.342856)],Zc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){var e;return a(this,o),(e=n.call(this)).setValues({uniforms:{noiseTexture:{type:"t",value:ni.noiseTexture},noiseTexelSize:{type:"v2",value:new i.FM8(1/ni.noiseWidth,1/ni.noiseHeight)},diffuseTexture:{type:"t",value:null},normalTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new i.FM8(1/512,1/512)},camNearFar:{type:"v2",value:new i.FM8(1,10)},projMatrix:{type:"mat4",value:new i.yGw},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},samplesKernel:{type:"v3v",value:$c},kernelRadius:{type:"f",value:1},depthThreshold:{type:"f",value:1},factor:{type:"f",value:1}},vertexShader:yr,fragmentShader:"precision highp float;\r\n#define EPSILON 0.0000001\r\n\r\n#define MAX_SAMPLES_COUNT 32\r\nuniform vec3 samplesKernel[MAX_SAMPLES_COUNT];\r\nuniform sampler2D noiseTexture;\r\nuniform vec2 noiseTexelSize;\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D depthTexture;\r\nuniform sampler2D normalTexture;\r\nuniform vec2 srcTexelSize;\r\nuniform vec2 camNearFar;\r\nuniform mat4 projMatrix;\r\n\r\nuniform float aspectRatio;\r\nuniform float tanHalfFOV;\r\n\r\nuniform float kernelRadius;\r\nuniform float depthThreshold;\r\nuniform float factor;\r\n\r\nvarying vec2 vUv;\r\n\r\nfloat CalcViewZ(vec2 screenPos)\r\n{\r\n float depth = texture2D(depthTexture, screenPos).x;\r\n // [0, 1]->[-1, 1]\r\n float clipedZ = 2.0 * depth - 1.0;\r\n // see THREE.js camera.makeFrustum for projection details\r\n return (-projMatrix[3][2] / (clipedZ + projMatrix[2][2]));\r\n}\r\n\r\nvec3 ViewPosFromDepth(vec2 screenPos)\r\n{\r\n vec3 viewPos;\r\n viewPos.z = CalcViewZ(screenPos);\r\n //[0, 1]->[-1, 1]\r\n vec2 projPos = 2.0 * screenPos - 1.0;\r\n // reconstruct viewposition in right-handed sc with z to viewer\r\n viewPos.xy = vec2(\r\n projPos.x * aspectRatio * tanHalfFOV * abs(viewPos.z),\r\n projPos.y * tanHalfFOV * abs(viewPos.z)\r\n );\r\n return viewPos;\r\n}\r\n\r\nvoid main() {\r\n vec3 viewPos = ViewPosFromDepth(vUv);\r\n // remap coordinates to prevent noise exture rescale\r\n vec2 vUvNoise = vUv / srcTexelSize * noiseTexelSize;\r\n vec4 normalData = texture2D(normalTexture, vUv);\r\n // return for background fragments (their normals are zero vectors)\r\n if (length(normalData.rgb) < EPSILON) {\r\n // 0.0 in alpha component means that it is background fragment\r\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\r\n return;\r\n }\r\n //[0, 1] -> [-1, 1]\r\n vec3 normal = (normalData.rgb * 2.0 - 1.0);\r\n // normalData.a store 1.0 if normal was build for frontfaced surface\r\n // and 0.0 in other case\r\n if (normalData.a < EPSILON) {\r\n normal *= -1.0;\r\n }\r\n // get random vector for sampling sphere rotation\r\n vec3 randN = texture2D(noiseTexture, vUvNoise).rgb * 2.0 - 1.0;\r\n randN = normalize(randN);\r\n // build TBN (randomly rotated around normal)\r\n vec3 tangent = normalize(randN - normal * dot(randN, normal));\r\n vec3 bitangent = cross(tangent, normal);\r\n mat3 TBN = mat3(tangent, bitangent, normal);\r\n // calc AO value\r\n float AO = 0.0;\r\n for (int i = 0 ; i < MAX_SAMPLES_COUNT ; i++) {\r\n // rotate sampling kernel around normal\r\n vec3 reflectedSample = TBN * samplesKernel[i];\r\n // get sample\r\n vec3 samplePos = viewPos + reflectedSample * kernelRadius;\r\n\r\n // project sample to screen to get sample's screen pos\r\n vec4 SampleScrPos = vec4(samplePos, 1.0);\r\n // eye -> clip\r\n SampleScrPos = projMatrix * SampleScrPos;\r\n // normalize\r\n SampleScrPos.xy /= SampleScrPos.w;\r\n //[-1, 1] -> [0, 1]\r\n SampleScrPos.xy = (SampleScrPos.xy + vec2(1.0)) * 0.5;\r\n\r\n // get view z for sample projected to the objct surface\r\n float sampleDepth = CalcViewZ(SampleScrPos.xy);\r\n // calc occlusion made by object surface at the sample\r\n AO += step(samplePos.z, sampleDepth);\r\n }\r\n // calc result AO-map color\r\n AO = 1.0 - max(0.0, AO / float(MAX_SAMPLES_COUNT) * factor);\r\n // write value to AO-map\r\n gl_FragColor = vec4(AO, AO, AO, 1.0);\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1}),e}return l(o)}(i.FIo);var Kc=[-2,-1,0,1,2],Qc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){var e;return a(this,o),(e=n.call(this)).setValues({uniforms:{depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new i.FM8(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:Kc}},vertexShader:yr,fragmentShader:"precision highp float;\r\n#define EPSILON 0.0000001\r\n\r\n#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n res.a = texture2D(aoMap, vec2(x, y )).a;\r\n // return for background fragments (0.0 in alpha component means that it is background fragment)\r\n if (res.a < EPSILON) {\r\n gl_FragColor = res;\r\n return;\r\n }\r\n\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n if (texture2D(aoMap, vec2(x + samplesOffsets[i] * srcTexelSize.x, y )).a < EPSILON) {\r\n continue;\r\n }\r\n vec2 samplePos = vec2(x + samplesOffsets[i] * srcTexelSize.x, y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res.rgb += texture2D(aoMap, vec2(x + samplesOffsets[i] * srcTexelSize.x, y )).rgb * weight;\r\n weightSum += weight;\r\n }\r\n res.rgb = res.rgb / weightSum;\r\n gl_FragColor = res;\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1}),e}return l(o)}(i.FIo);var Jc=[-2,-1,0,1,2],eu=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;return a(this,o),(t=n.call(this,e)).setValues({uniforms:{diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new i.FM8(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:Jc},projMatrix:{type:"mat4",value:new i.yGw},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},fogNearFar:{type:"v2",value:new i.FM8(100,100)},fogColor:{type:"v4",value:new i.Ltg(0,.5,0,1)}},vertexShader:yr,fragmentShader:"precision highp float;\r\n#define EPSILON 0.0000001\r\n\r\n#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nuniform mat4 projMatrix;\r\nuniform float aspectRatio;\r\nuniform float tanHalfFOV;\r\n\r\n#ifdef USE_FOG\r\n uniform vec2 fogNearFar;\r\n uniform vec4 fogColor;\r\n#endif\r\nvarying vec2 vUv;\r\n\r\nfloat CalcViewZ(vec2 screenPos)\r\n{\r\n float depth = texture2D(depthTexture, screenPos).x;\r\n // [0, 1]->[-1, 1]\r\n float clipedZ = 2.0 * depth - 1.0;\r\n // see THREE.js camera.makeFrustum for projection details\r\n return (-projMatrix[3][2] / (clipedZ + projMatrix[2][2]));\r\n}\r\n\r\nvec3 ViewPosFromDepth(vec2 screenPos)\r\n{\r\n vec3 viewPos;\r\n viewPos.z = CalcViewZ(screenPos);\r\n //[0, 1]->[-1, 1]\r\n vec2 projPos = 2.0 * screenPos - 1.0;\r\n // reconstruct viewposition in right-handed sc with z to viewer\r\n viewPos.xy = vec2(\r\n projPos.x * aspectRatio * tanHalfFOV * abs(viewPos.z),\r\n projPos.y * tanHalfFOV * abs(viewPos.z)\r\n );\r\n return viewPos;\r\n}\r\n\r\nvoid main() {\r\n vec3 viewPos = ViewPosFromDepth(vUv);\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 color = texture2D(diffuseTexture, vec2(x, y));\r\n vec4 res = vec4(0.0);\r\n res.a = texture2D(aoMap, vec2(x, y )).a;\r\n // return for background fragments (0.0 in alpha component means that it is background fragment)\r\n if (res.a < EPSILON) {\r\n gl_FragColor = color;\r\n return;\r\n }\r\n\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n if (texture2D(aoMap, vec2(x, y + samplesOffsets[i] * srcTexelSize.y)).a < EPSILON) {\r\n continue;\r\n }\r\n vec2 samplePos = vec2(x, y + samplesOffsets[i] * srcTexelSize.y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res.rgb += texture2D(aoMap, vec2(x, y + samplesOffsets[i] * srcTexelSize.y)).rgb * weight;\r\n weightSum += weight;\r\n }\r\n res.rgb /= weightSum;\r\n\r\n #if defined(USE_FOG) && !defined(FOG_TRANSPARENT)\r\n // Add fog to the result value\r\n // Proper way to get an image with fog and ao requires formula:\r\n // gl_FragColor = fragColor*AO*(1-fogFactor) + fogColor*fogFactor\r\n // But we have already fogged molecule to add AO too. Let's split the straight formula into our real steps!\r\n // We have: AO, fogFactor, fogColor,\r\n // color = fragColor*(1-fogFactor) + fogColor*fogFactor (it comes from diffuseTexture,\r\n // where molecule has been already drawn with fog)\r\n // Transform:\r\n // fragColor*AO*(1-fogFactor) + fogColor*fogFactor =\r\n // = [fragColor*(1-fogFactor) = color - fogColor*fogFactor] =\r\n // = (color - fogColor*fogFactor)*AO + fogColor*fogFactor =\r\n // = color*AO + fogColor*fogFactor*(1 - AO)\r\n // Result: gl_FragColor = color*AO + fogColor*fogFactor*(1 - AO)\r\n float fogFactor = smoothstep(fogNearFar.x, fogNearFar.y, - viewPos.z) * fogColor.a;\r\n gl_FragColor.rgb = color.rgb * res.rgb + fogColor.rgb * fogFactor *(vec3(1.0, 1.0, 1.0) - res.rgb);\r\n #else\r\n gl_FragColor.rgb = color.rgb * res.rgb;\r\n #endif\r\n gl_FragColor.a = color.a;\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1}),t.setValues(e),t}return l(o,[{key:"setValues",value:function(e){if(void 0!==e){Xe(d(o.prototype),"setValues",this).call(this,e);var t={};this.useFog&&(t.USE_FOG=1),this.fogTransparent&&(t.FOG_TRANSPARENT=1),this.defines=t}}}]),o}(i.FIo);eu.prototype.useFog=!0,eu.prototype.fogTransparent=!1;var tu=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;a(this,i),e=n.call(this);var t={uniforms:{srcL:{type:"t",value:null},srcR:{type:"t",value:null}},vertexShader:yr,fragmentShader:"precision highp float;\r\n\r\nuniform sampler2D srcL;\r\nuniform sampler2D srcR;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n vec4 l = texture2D(srcL, vUv);\r\n vec4 r = texture2D(srcR, vUv);\r\n gl_FragColor = vec4(l.r, r.g, r.b, 1.0);\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1};return e.setValues(t),e}return l(i)}(i.FIo),ru=function(){function e(){a(this,e),this.position=new i.Pa4(0,0,0),this.scale=1,this.orientation=new i._fP(0,0,0,1)}return l(e,[{key:"set",value:function(e,t,r){this.position=e,this.scale=t,this.orientation=r}}]),e}(),nu=function(){function e(){a(this,e)}return l(e,[{key:"setup",value:function(e,t){this._startTime=void 0,this._endTime=void 0,this._isPaused=!1,this._srcView=e,this._dstView=t,this._isMoving=!1}},{key:"isMoving",value:function(){return this._isMoving}},{key:"wasStarted",value:function(){return void 0!==this._startTime&&void 0!==this._endTime}},{key:"start",value:function(){this._startTime=Date.now();var e=J.now.interpolateViews?1500:0;this._endTime=this._startTime+e,this._isMoving=!0}},{key:"getCurrentView",value:function(){if(void 0===this._srcView||void 0===this._dstView||!this._isMoving||!this.wasStarted())return{success:!1};var e=this.createView(),t=Date.now();if(t>this._endTime)return e=this._dstView,this.reset(),{success:!0,view:e};var r=(t-this._startTime)/(this._endTime-this._startTime);return e.position.copy(this._srcView.position),e.position.lerp(this._dstView.position,r),e.scale=(1-r)*this._srcView.scale+r*this._dstView.scale,e.orientation.copy(this._srcView.orientation),e.orientation.slerp(this._dstView.orientation,r),{success:!0,view:e}}},{key:"reset",value:function(){this._startTime=this._endTime=0,this._isMoving=!1}},{key:"pause",value:function(){this._isPaused||(this.setup(this.getCurrentView().view,this._dstView),this._isPaused=!0)}},{key:"resume",value:function(){this._isPaused=!1}},{key:"createView",value:function(){return new ru}}]),e}();function iu(e,t){this.context=e,this._opts=(0,n.merge)({path:"/"},t)}Ir(iu.prototype),iu.prototype.removeCookie=function(e){var t=this._toCount(e),r=this._getSimpleCookie(t);if(r){this._removeSimpleCookie(t),r=parseInt(r,10);for(var n=0;n<r;++n)this._removeSimpleCookie(e+n)}else this._removeSimpleCookie(e)},iu.prototype.setCookie=function(e,t){this.removeCookie(e);var r=function(e,t){for(var r=e.length,n=[],i=0,o=0;o<r;i++,o+=t)n[i]=e.slice(o,o+t);return n}(t=encodeURIComponent(t),4e3-e.length-1),n=r.length;if(1!==n){var i=this._toCount(e);this._setSimpleCookie(i,n.toString());for(var o=0;o<n;++o)this._setSimpleCookie(e+o,r[o])}else this._setSimpleCookie(e,t)},iu.prototype.getCookie=function(e){var t=this._toCount(e),r=this._getSimpleCookie(t);if(!r)return this._getSimpleCookie(e);r=parseInt(r,10);for(var n=[],i=0;i<r;++i)n[i]=this._getSimpleCookie(e+i);return n.join("")},iu.prototype._toCount=function(e){return e+"Cnt"},iu.prototype._removeSimpleCookie=function(e){document.cookie="".concat(e,"=; expires=Thu, 01 Jan 1970 00:00:01 GMT;")},iu.prototype._getExpirationDate=function(){var e=new Date;return e.setFullYear(e.getFullYear()+10),e},iu.prototype._setSimpleCookie=function(e,t){document.cookie="".concat(e,"=").concat(t,";expires=").concat(this._getExpirationDate().toUTCString(),";path=").concat(this._opts.path)},iu.prototype._getSimpleCookie=function(e){var t=document.cookie.match(new RegExp("(?:^|; )".concat(e,"=([^;]*)")));return t?decodeURIComponent(t[1]):""},iu.prototype._exists=function(e){return document.cookie.match(new RegExp("(?:^|; )".concat(e,"=([^;]*)")))};var ou=function(){function e(t){a(this,e),this._mainCamera=new i.cPb,this._button=null,this._onToggle=t,this._molContainer=new Er.RCGroup,this._user=new Er.RCGroup,this._scalingPivot=new i.Tme,this._user.add(this._scalingPivot),this._controller1=null,this._controller2=null,this._pressedGripsCounter=0,this._distance=0,this._gfx=null}return l(e,[{key:"startScalingByControllers",value:function(){this._distance=this._controller1.position.distanceTo(this._controller2.position),Er.getMiddlePoint(this._controller1.position,this._controller2.position,this._scalingPivot.position),this._scalingPivot.scale.set(1,1,1),this._scalingPivot.updateMatrix(),this._scalingPivot.updateMatrixWorld(),this._scalingPivot.addSavingWorldTransform(this._molContainer)}},{key:"stopScalingByControllers",value:function(){this._gfx.scene.addSavingWorldTransform(this._molContainer)}},{key:"handleGripsDown",value:function(e){this._pressedGripsCounter++,2===this._pressedGripsCounter?this.startScalingByControllers():1===this._pressedGripsCounter&&e.target.addSavingWorldTransform(this._molContainer)}},{key:"handleGripsUp",value:function(e){this._pressedGripsCounter--,1===this._pressedGripsCounter?(this.stopScalingByControllers(),(e.target===this._controller1?this._controller2:this._controller1).addSavingWorldTransform(this._molContainer)):0===this._pressedGripsCounter&&this._gfx.scene.addSavingWorldTransform(this._molContainer)}},{key:"enable",value:function(e){if(e){this._gfx=e;var t=e.renderer,r=e.camera;if(!t)throw new Error("No renderer is available to toggle WebVR");if(!r)throw new Error("No camera is available to toggle WebVR");t.xr.enabled=!0,this._button?this._button.style.display="block":(this._button=function(e){function t(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="transparent",e.style.color="#fff",e.style.font="normal 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.5",e.style.outline="none",e.style.zIndex="999"}if("xr"in navigator){var r=document.createElement("button");return r.style.display="none",t(r),navigator.xr.isSessionSupported("immersive-vr").then((function(t){return t?function(t){t.style.display="",t.style.cursor="pointer",t.style.left="calc(50% - 50px)",t.style.width="100px",t.textContent="ENTER VR";var r=null;function n(){r.removeEventListener("end",n),t.textContent="ENTER VR",r=null}function i(i){i.addEventListener("end",n),e._gfx.renderer.xr.setReferenceSpaceType("local"),e._gfx.renderer.xr.setSession(i),t.textContent="EXIT VR",r=i}t.onmouseenter=function(){t.style.opacity="1.0"},t.onmouseleave=function(){t.style.opacity="0.5"},t.onclick=function(){null===r?(navigator.xr.requestSession("immersive-vr",{optionalFeatures:["local-floor","bounded-floor"]}).then(i),e.moveSceneBehindHeadset()):r.end()}}(r):function(e){e.style.display="",e.style.cursor="auto",e.style.left="calc(50% - 75px)",e.style.width="150px",e.textContent="VR NOT FOUND",e.onmouseenter=null,e.onmouseleave=null,e.onclick=null}(r)})),r}var n=document.createElement("a");return n.href="https://webvr.info",n.innerHTML="WEBXR NOT SUPPORTED",n.style.left="calc(50% - 90px)",n.style.width="180px",n.style.textDecoration="none",t(n),n}(this),document.body.appendChild(this._button)),this._mainFog=J.now.fog,J.set("fog",!1),this._plugVRNodesIntoScene(e,t),this._setControllersListeners(),this._onToggle&&this._onToggle(!0)}else B.warn("WebVR couldn't be enabled, because gfx is not defined")}},{key:"_plugVRNodesIntoScene",value:function(e,t){this._mainCamera.copy(e.camera),e.scene.add(this._user),e.scene.add(this._molContainer),this._molContainer.add(e.root),this._controller1=t.xr.getController(0),this._controller2=t.xr.getController(1);var r=this._createControllerMesh();this._controller1.add(r),this._controller2.add(r.clone()),this._user.add(this._controller1),this._user.add(this._controller2)}},{key:"_setControllersListeners",value:function(){var e=this;this._controller1.addEventListener("selectstart",(function(t){e.handleGripsDown(t)})),this._controller1.addEventListener("selectend",(function(t){e.handleGripsUp(t)})),this._controller2.addEventListener("selectstart",(function(t){e.handleGripsDown(t)})),this._controller2.addEventListener("selectend",(function(t){e.handleGripsUp(t)})),this._controller1.addEventListener("squeezestart",(function(t){e.handleGripsDown(t)})),this._controller1.addEventListener("squeezeend",(function(t){e.handleGripsUp(t)})),this._controller2.addEventListener("squeezestart",(function(t){e.handleGripsDown(t)})),this._controller2.addEventListener("squeezeend",(function(t){e.handleGripsUp(t)}))}},{key:"disable",value:function(){if(this._gfx){var e=this._gfx,t=e.renderer,r=e.camera;if(!t)throw new Error("No renderer is available to toggle WebVR");t.setAnimationLoop(null);var n=t.xr.getSession();n&&n.end(),t.xr.enabled=!1,this._button&&(this._button.style.display="none"),J.set("fog",this._mainFog),this._unplugVRNodesFromScene(r),this._onToggle&&this._onToggle(!1)}}},{key:"_unplugVRNodesFromScene",value:function(e){this._mainCamera&&e&&e.copy(this._mainCamera);var t=this._molContainer.children[0];t&&this._gfx.scene.add(t),this._molContainer.parent.remove(this._molContainer),this._user&&this._gfx.scene.remove(this._user),this._molContainer=null,this._user=null,this._scalingPivot=null,this._user=null,this._controller1=null,this._controller2=null}},{key:"_createControllerMesh",value:function(){var e=new i.fHI(.04,.04,.3),t=new ui;t.setValues({lights:!1,overrideColor:!0}),t.setUberOptions({fixedColor:new i.Ilk(4474111)}),t.updateUniforms();var r=new i.Kj0(e,t);return r.rotateX(-Math.PI/2),r}},{key:"updateMoleculeScale",value:function(){if(this._controller1&&this._controller2){var e=this;if(2===e._pressedGripsCounter){Er.getMiddlePoint(e._controller1.position,e._controller2.position,e._scalingPivot.position);var t=e._controller1.position.distanceTo(e._controller2.position),r=t/e._distance;e._scalingPivot.scale.multiplyScalar(r),e._distance=t}}}},{key:"moveSceneBehindHeadset",value:function(){var e=this._gfx,t=e.camera,r=this._molContainer;r.matrix.identity(),r.position.set(0,0,-4),r.updateMatrix(),r.matrixWorld.multiplyMatrices(t.matrixWorld,r.matrix),e.scene.addSavingWorldTransform(r),this._onToggle&&this._onToggle(!0)}},{key:"getCanvas",value:function(){var e=this._gfx;return e&&e.renderer?e.renderer.domElement:null}}]),e}();var au=pr.selectors,su=pr.Atom,lu=pr.Residue,cu=pr.Chain,uu=pr.Molecule,hu="Could not find suitable loader for this source",fu=$.createElement;function du(e){var t=e.lastIndexOf(".");return t>=0&&(e=e.substr(0,t)),e}function pu(e,t,r){void 0!==r?e.debug("".concat(t,"... ").concat(Math.floor(100*r),"%")):e.debug("".concat(t,"..."))}function mu(){return J.now.fogColorEnable?J.now.fogColor:J.now.bg.color}function vu(e,t){for(var r=e;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(t)}function yu(e){return e.getExtension("EXT_frag_depth")}function _u(e){return e.getExtension("WEBGL_depth_texture")&&e.getExtension("WEBGL_draw_buffers")}var gu=/^(?:(pdb|cif|mmtf|ccp4|dsn6):\s*)?(\d[a-z\d]{3})$/i,xu=/^(?:pc|pubchem):\s*([a-z]+)$/i,bu=/^([a-z][a-z\d\-+.]*):/i;function wu(e,t){return e.mask&1<<t}function Su(e,t){return t.selector.includesAtom(e)}var Ru=function(e){h(s,e);var t,r,o=(t=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function s(e){var t;a(this,s),(t=o.call(this))._opts=(0,n.merge)({settingsCookie:"settings",cookiePath:"/"},e),t._gfx=null,t._interpolator=new nu,t._container=e&&e.container||document.getElementById("miew-container")||(0,n.head)(document.getElementsByClassName("miew-container"))||document.body,t._containerRoot=t._container,t._running=!1,t._halting=!1,t._building=!1,t._needRender=!0,t._hotKeysEnabled=!0,t.settings=J;var r=B;r.console=!1,r.level="info",t.logger=r,t._cookies=new iu(c(t)),t.restoreSettings(),e&&e.settings&&t.settings.set(e.settings),t._spinner=null,t._loading=[],t._animInterval=null,t._visuals={},t._curVisualName=null,t._objects=[],t._sourceWindow=null,t.reset(),t._repr&&r.debug("Selected ".concat(t._repr.mode.name," mode with ").concat(t._repr.colorer.name," colorer."));var l=c(t);return s.registeredPlugins.forEach((function(e){e.call(l)})),t._initOnSettingsChanged(),t.shadowMatrix=new i.yGw,t.direction=new i.Pa4,t.OBB={center:new i.Pa4,halfSize:new i.Pa4},t._bSphereForOneVisual=new i.aLr,t._bBoxForOneVisual=new i.ZzF,t._bBox=new i.ZzF,t._invMatrix=new i.yGw,t._points=[new i.Pa4,new i.Pa4,new i.Pa4,new i.Pa4],t._anaglyphMat=new tu,t._size=new i.FM8,t._scene=new i.xsS,t._camera=new i.iKG(-1,1,1,-1,-500,1e3),t._material=new i.FIo({uniforms:{srcTex:{type:"t",value:null},aberration:{type:"fv3",value:new i.Pa4(1)}},vertexShader:yr,fragmentShader:"precision highp float;\r\n\r\nvarying vec2 vUv;\r\nuniform sampler2D srcTex;\r\nuniform vec3 aberration;\r\n\r\nvoid main() {\r\n vec2 uv = vUv * 2.0 - 1.0;\r\n \r\n gl_FragColor.r = texture2D(srcTex, 0.5 * (uv * aberration[0] + 1.0)).r;\r\n gl_FragColor.g = texture2D(srcTex, 0.5 * (uv * aberration[1] + 1.0)).g;\r\n gl_FragColor.b = texture2D(srcTex, 0.5 * (uv * aberration[2] + 1.0)).b;\r\n gl_FragColor.a = 1.0;\r\n}",transparent:!1,depthTest:!1,depthWrite:!1}),t._geo=Er.buildDistorionMesh(10,10,J.now.debug.stereoBarrel),t._outlineMaterial=new Xc({depth:!0}),t.pars={minFilter:i.TyD,magFilter:i.TyD,format:i.wk1},t.VERSION="0.10.0+20220125.134627.b36f6a2-mod",t}return l(s,[{key:"getMaxRepresentationCount",value:function(){return Ua.NUM_REPRESENTATION_BITS}},{key:"_updateShadowCamera",value:function(){this._gfx.scene.updateMatrixWorld();for(var e=0;e<this._gfx.scene.children.length;e++)if("DirectionalLight"===this._gfx.scene.children[e].type){var t=this._gfx.scene.children[e];this.shadowMatrix.copy(t.shadow.camera.matrixWorldInverse),this.getOBB(this.shadowMatrix,this.OBB),this.direction.subVectors(t.target.position,t.position),t.position.subVectors(this.OBB.center,this.direction),t.target.position.copy(this.OBB.center),t.shadow.bias=.09,t.shadow.camera.bottom=-this.OBB.halfSize.y,t.shadow.camera.top=this.OBB.halfSize.y,t.shadow.camera.right=this.OBB.halfSize.x,t.shadow.camera.left=-this.OBB.halfSize.x,t.shadow.camera.near=this.direction.length()-this.OBB.halfSize.z,t.shadow.camera.far=this.direction.length()+this.OBB.halfSize.z,t.shadow.camera.updateProjectionMatrix()}}},{key:"init",value:function(){var e=this._container,t=$.createElement("div",{class:"miew-canvas"});vu(e,t),this._container=t;var r=document.createDocumentFragment();if(r.appendChild(this._msgMode=fu("div",{class:"mode-message overlay"},fu("p",{},"COMPONENT EDIT MODE"))),r.appendChild(this._msgAtomInfo=fu("div",{class:"atom-info overlay"},fu("p",{},""))),e.appendChild(r),null!==this._gfx)return!0;var n=this;this._showMessage("Viewer is being initialized...");try{this._initGfx(),this._initListeners(),this._spinner=new g({lines:13,length:28,width:14,radius:42,color:"#fff",zIndex:700}),window.top.addEventListener("keydown",(function(e){n._onKeyDown(e)})),window.top.addEventListener("keyup",(function(e){n._onKeyUp(e)})),this._objectControls=new Dc(this._gfx.root,this._gfx.pivot,this._gfx.camera,this._gfx.renderer.domElement,(function(){return n._getAltObj()})),this._objectControls.addEventListener("change",(function(e){switch(J.now.shadow.on&&n._updateShadowCamera(),e.action){case"rotate":n.dispatchEvent({type:"rotate",quaternion:e.quaternion});break;case"zoom":n.dispatchEvent({type:"zoom",factor:e.factor});break;default:n.dispatchEvent({type:e.action})}n.dispatchEvent({type:"transform"}),n._needRender=!0}));var i=this._gfx;this._picker=new zc(i.root,i.camera,i.renderer.domElement),this._picker.addEventListener("newpick",(function(e){n._onPick(e)})),this._picker.addEventListener("dblclick",(function(e){n.center(e)}))}catch(e){if("TypeError"===e.name&&"Cannot read property 'getExtension' of null"===e.message)this._showMessage("Could not create WebGL context.");else{if(!(e.message.search(/webgl/i)>1))throw this._showMessage("Viewer initialization failed."),e;this._showMessage(e.message)}return!1}var o=this._opts&&this._opts.load;if(o){var a=this._opts&&this._opts.type;this.load(o,{fileType:a,keepRepsInfo:!0})}return!0}},{key:"term",value:function(){this._showMessage("Viewer has been terminated."),this._loading.forEach((function(e){e.cancel()})),this._loading.length=0,this.halt(),this._gfx=null}},{key:"_showMessage",value:function(e){var t=document.createElement("div");t.setAttribute("class","miew-message"),t.appendChild(document.createElement("p")).appendChild(document.createTextNode(e)),vu(this._container,t)}},{key:"_showCanvas",value:function(){vu(this._container,this._gfx.renderer.domElement)}},{key:"_requestAnimationFrame",value:function(e){var t=this._gfx.renderer.xr;t&&t.enabled?this._gfx.renderer.setAnimationLoop(e):requestAnimationFrame(e)}},{key:"_initGfx",value:function(){var e={width:this._container.clientWidth,height:this._container.clientHeight},t={preserveDrawingBuffer:!0,alpha:!0,premultipliedAlpha:!1};J.now.antialias&&(t.antialias=!0),e.renderer2d=new Nc,e.renderer=new i.b5g(t),e.renderer.shadowMap.enabled=J.now.shadow.on,e.renderer.shadowMap.autoUpdate=!1,e.renderer.shadowMap.type=i._iA,$n.init(e.renderer),yu(e.renderer.getContext())||J.set("zSprites",!1),_u(e.renderer.getContext())||J.set("ao",!1),e.renderer.autoClear=!1,e.renderer.setPixelRatio(window.devicePixelRatio),e.renderer.setSize(e.width,e.height),e.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent)),e.renderer.clearColor(),e.renderer2d.setSize(e.width,e.height),e.camera=new i.cPb(J.now.camFov,e.width/e.height,J.now.camNear,J.now.camFar),e.camera.setMinimalFov(J.now.camFov),e.camera.position.z=J.now.camDistance,e.camera.updateProjectionMatrix(),e.camera.layers.set(Er.LAYERS.DEFAULT),e.camera.layers.enable(Er.LAYERS.VOLUME),e.camera.layers.enable(Er.LAYERS.VOLUME_BFPLANE),e.stereoCam=new i.u37,e.scene=new i.xsS;var r=mu();e.scene.fog=new i.ybr(r,J.now.camNear,J.now.camFar),e.root=new Er.RCGroup,e.scene.add(e.root),e.pivot=new Er.RCGroup,e.root.add(e.pivot),e.selectionScene=new i.xsS,e.selectionRoot=new i.ZAu,e.selectionRoot.matrixAutoUpdate=!1,e.selectionScene.add(e.selectionRoot),e.selectionPivot=new i.ZAu,e.selectionPivot.matrixAutoUpdate=!1,e.selectionRoot.add(e.selectionPivot);var n=new i.Ox3(16777215,.45);n.position.set(0,.414,1),n.layers.enable(Er.LAYERS.TRANSPARENT),n.castShadow=!0,n.shadow.bias=.09,n.shadow.radius=J.now.shadow.radius,n.shadow.camera.layers.set(Er.LAYERS.SHADOWMAP);var o=e.renderer.getPixelRatio(),a=Math.max(e.width,e.height)*o;n.shadow.mapSize.width=a,n.shadow.mapSize.height=a,n.target.position.set(0,0,0),e.scene.add(n),e.scene.add(n.target);var s=new i.Mig(6710886);s.layers.enable(Er.LAYERS.TRANSPARENT),e.scene.add(s),e.axes=new Fc(e.root,e.camera);var l=e.width*o,c=e.height*o;e.offscreenBuf=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.TyD,format:i.wk1,depthBuffer:!0}),e.renderer.getContext().getExtension("WEBGL_depth_texture")&&(e.offscreenBuf.depthTexture=new i.$YQ,e.offscreenBuf.depthTexture.type=i.LsT),e.offscreenBuf2=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,depthBuffer:!1}),e.offscreenBuf3=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,depthBuffer:!1}),e.offscreenBuf4=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,depthBuffer:!1}),e.volBFTex=e.offscreenBuf3,e.volFFTex=e.offscreenBuf4,e.volWFFTex=e.offscreenBuf,e.renderer.getContext().getExtension("OES_texture_float")?(e.offscreenBuf5=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,type:i.VzW,depthBuffer:!1}),e.offscreenBuf6=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,type:i.VzW,depthBuffer:!1}),e.offscreenBuf7=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,type:i.VzW,depthBuffer:!0}),e.volBFTex=e.offscreenBuf5,e.volFFTex=e.offscreenBuf6,e.volWFFTex=e.offscreenBuf7):this.logger.warn("Device doesn't support OES_texture_float extension"),e.stereoBufL=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,depthBuffer:!1}),e.stereoBufR=new i.dd2(l,c,{minFilter:i.wem,magFilter:i.wem,format:i.wk1,depthBuffer:!1}),this._gfx=e,this._showCanvas(),this._embedWebXR("WEBVR"===J.now.stereo),this._container.appendChild(e.renderer2d.getElement());var u=new k;u.domElement.style.position="absolute",u.domElement.style.right="0",u.domElement.style.bottom="0",this._container.appendChild(u.domElement),this._fps=u,this._fps.show(J.now.fps)}},{key:"_initListeners",value:function(){var e=this;window.addEventListener("resize",(function(){e._onResize()}))}},{key:"_makeUniqueVisualName",value:function(e){if(!e)return Math.random().toString();for(var t=e,r=1;this._visuals.hasOwnProperty(t);)t="".concat(e," (").concat(r.toString(),")"),r++;return t}},{key:"_addVisual",value:function(e){if(!e)return null;var t=this._makeUniqueVisualName(e.name);return e.name=t,this._visuals[t]=e,this._gfx.pivot.add(e),e.getSelectionGeo&&this._gfx.selectionPivot.add(e.getSelectionGeo()),t}},{key:"_removeVisual",value:function(e){var t="",r=null;e instanceof Pr?(t=e.name,r=e):"string"==typeof e&&(t=e,r=this._visuals[t]),r&&this._visuals.hasOwnProperty(t)&&this._visuals[t]===r&&(t===this._curVisualName&&(this._curVisualName=void 0),delete this._visuals[t],r.release(),this._needRender=!0)}},{key:"_forEachVisual",value:function(e){for(var t in this._visuals)this._visuals.hasOwnProperty(t)&&e(this._visuals[t])}},{key:"_releaseAllVisuals",value:function(){if(this._gfx&&this._gfx.pivot){for(var e in this._visuals)this._visuals.hasOwnProperty(e)&&this._visuals[e].release();this._visuals={}}}},{key:"_forEachComplexVisual",value:function(e){if(this._gfx&&this._gfx.pivot)for(var t in this._visuals)this._visuals.hasOwnProperty(t)&&this._visuals[t]instanceof Ua&&e(this._visuals[t])}},{key:"_getComplexVisual",value:function(e){e=e||this._curVisualName;var t=null,r=null;return this._forEachComplexVisual((function(n){t=n,n.name===e&&(r=n)})),r||t}},{key:"_getVolumeVisual",value:function(){var e=null;return this._forEachVisual((function(t){t instanceof Qa&&(e=t)})),e}},{key:"_getVisualForComplex",value:function(e){if(!e)return null;var t=null;return this._forEachComplexVisual((function(r){r.getComplex()===e&&(t=r)})),t}},{key:"getVisuals",value:function(){return Object.keys(this._visuals)}},{key:"getComplexVisualsCount",value:function(){var e=0;return this._forEachComplexVisual((function(){return e++})),e}},{key:"getCurrentVisual",value:function(){return this._curVisualName}},{key:"setCurrentVisual",value:function(e){this._visuals[e]&&(this._curVisualName=e)}},{key:"run",value:function(){var e=this;if(!this._running){if(this._running=!0,this._halting)return void(this._halting=!1);this._objectControls.enable(!0),this._interpolator.resume(),this._requestAnimationFrame((function(){return e._onTick()}))}}},{key:"halt",value:function(){this._running&&(this._discardComponentEdit(),this._discardFragmentEdit(),this._objectControls.enable(!1),this._interpolator.pause(),this._halting=!0)}},{key:"enableHotKeys",value:function(e){this._hotKeysEnabled=e,this._objectControls.enableHotkeys(e)}},{key:"_onResize",value:function(){this._needRender=!0;var e=this._gfx;e.width=this._container.clientWidth,e.height=this._container.clientHeight,e.camera.aspect=e.width/e.height,e.camera.setMinimalFov(J.now.camFov),e.camera.updateProjectionMatrix(),e.renderer.setSize(e.width,e.height),e.renderer2d.setSize(e.width,e.height),this.dispatchEvent({type:"resize"})}},{key:"_resizeOffscreenBuffers",value:function(e,t,r){var n=this._gfx,i="NONE"===(r=r||"NONE")||"ANAGLYPH"===r,o=i?1:.5;n.offscreenBuf.setSize(o*e,t),n.offscreenBuf2.setSize(o*e,t),n.offscreenBuf3.setSize(o*e,t),n.offscreenBuf4.setSize(o*e,t),n.offscreenBuf5&&n.offscreenBuf5.setSize(o*e,t),n.offscreenBuf6&&n.offscreenBuf6.setSize(o*e,t),n.offscreenBuf7&&n.offscreenBuf7.setSize(o*e,t),i&&(n.stereoBufL.setSize(e,t),n.stereoBufR.setSize(e,t))}},{key:"_onTick",value:function(){var e=this;if(this._halting)return this._running=!1,void(this._halting=!1);this._fps.update(),this._requestAnimationFrame((function(){return e._onTick()})),this._onUpdate(),this._needRender&&(this._onRender(),this._needRender=!J.now.suspendRender||"WEBVR"===J.now.stereo)}},{key:"_getBSphereRadius",value:function(){var e=0;return this._forEachVisual((function(t){e=Math.max(e,t.getBoundaries().boundingSphere.radius)})),e*this._objectControls.getScale()}},{key:"getOBB",value:function(e,t){var r=this;this._bBox.makeEmpty(),this._forEachVisual((function(t){r._bSphereForOneVisual.copy(t.getBoundaries().boundingSphere),r._bSphereForOneVisual.applyMatrix4(t.matrixWorld).applyMatrix4(e),r._bSphereForOneVisual.getBoundingBox(r._bBoxForOneVisual),r._bBox.union(r._bBoxForOneVisual)})),this._bBox.getCenter(t.center),this._invMatrix.copy(e).invert(),t.center.applyMatrix4(this._invMatrix);var n=this._bBox.min,i=this._bBox.max;this._points[0].set(n.x,n.y,n.z),this._points[1].set(i.x,n.y,n.z),this._points[2].set(n.x,i.y,n.z),this._points[3].set(n.x,n.y,i.z);for(var o=0,a=this._points.length;o<a;o++)this._points[o].applyMatrix4(this._invMatrix);t.halfSize.set(Math.abs(this._points[0].x-this._points[1].x),Math.abs(this._points[0].y-this._points[2].y),Math.abs(this._points[0].z-this._points[3].z)).multiplyScalar(.5)}},{key:"_updateFog",value:function(){var e=this._gfx;if(J.now.fog){if(void 0===e.scene.fog||null===e.scene.fog){var t=mu();e.scene.fog=new i.ybr(t),this._setUberMaterialValues({fog:J.now.fog})}!function(e,t,r){e.near=t-r*J.now.fogNearFactor,e.far=t+r*J.now.fogFarFactor}(e.scene.fog,e.camera.position.z,this._getBSphereRadius())}else e.scene.fog&&(e.scene.fog=void 0,this._setUberMaterialValues({fog:J.now.fog}))}},{key:"_onUpdate",value:function(){void 0!==this.isScriptingCommandAvailable&&this.isScriptingCommandAvailable()&&!this._building&&this.callNextCmd(),this._objectControls.update(),this._forEachComplexVisual((function(e){e.getComplex().update()})),J.now.autobuild&&!this._loading.length&&!this._building&&this._needRebuild()&&this.rebuild(),this._loading.length||this._building||this._needRebuild()||this._updateView(),this._updateFog(),this._gfx.renderer.xr.enabled&&this.webVR.updateMoleculeScale()}},{key:"_onRender",value:function(){var e=this._gfx;e.scene.updateMatrixWorld(),e.camera.updateMatrixWorld(),this._clipPlaneUpdateValue(this._getBSphereRadius()),this._fogFarUpdateValue(),e.renderer.setRenderTarget(null),e.renderer.clear(),this._renderFrame(J.now.stereo)}},{key:"_renderFrame",value:function(e){var t=this._gfx,r=t.renderer;r.getSize(this._size),"NONE"!==e&&(t.camera.focus=t.camera.position.z,t.stereoCam.aspect=1,"ANAGLYPH"===e?t.stereoCam.update(t.camera):t.stereoCam.updateHalfSized(t.camera,J.now.camFov));var n=t.renderer.getPixelRatio();switch(this._resizeOffscreenBuffers(this._size.width*n,this._size.height*n,e),this._renderShadowMap(),e){case"WEBVR":case"NONE":this._renderScene(t.camera,!1);break;case"SIMPLE":case"DISTORTED":r.setScissorTest(!0),r.setScissor(0,0,this._size.width/2,this._size.height),r.setViewport(0,0,this._size.width/2,this._size.height),this._renderScene(this._gfx.stereoCam.cameraL,"DISTORTED"===e),r.setScissor(this._size.width/2,0,this._size.width/2,this._size.height),r.setViewport(this._size.width/2,0,this._size.width/2,this._size.height),this._renderScene(this._gfx.stereoCam.cameraR,"DISTORTED"===e),r.setScissorTest(!1);break;case"ANAGLYPH":this._renderScene(this._gfx.stereoCam.cameraL,!1,t.stereoBufL),this._renderScene(this._gfx.stereoCam.cameraR,!1,t.stereoBufR),r.setRenderTarget(null),this._anaglyphMat.uniforms.srcL.value=t.stereoBufL.texture,this._anaglyphMat.uniforms.srcR.value=t.stereoBufR.texture,t.renderer.renderScreenQuad(this._anaglyphMat)}t.renderer2d.render(t.scene,t.camera),J.now.axes&&t.axes&&!t.renderer.xr.enabled&&t.axes.render(r)}},{key:"_onBgColorChanged",value:function(){var e=this._gfx,t=mu();e&&(e.scene.fog&&e.scene.fog.color.set(t),e.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent))),this._needRender=!0}},{key:"_onFogColorChanged",value:function(){var e=this._gfx,t=mu();e&&e.scene.fog&&e.scene.fog.color.set(t),this._needRender=!0}},{key:"_setUberMaterialValues",value:function(e){this._gfx.root.traverse((function(t){(t instanceof i.Kj0||t instanceof i.ejS||t instanceof i.x12)&&t.material instanceof ui&&(t.material.setValues(e),t.material.needsUpdate=!0)}))}},{key:"_enableMRT",value:function(e,t,r){var n=this._gfx,i=n.renderer.getContext(),o=i.getExtension("WEBGL_draw_buffers"),a=n.renderer.properties;if(e){n.renderer.setRenderTarget(r);var s=a.get(r.texture).__webglTexture;i.bindTexture(i.TEXTURE_2D,s),n.renderer.setRenderTarget(t);var l=a.get(t).__webglFramebuffer,c=a.get(t.texture).__webglTexture;i.bindFramebuffer(i.FRAMEBUFFER,l),l.width=t.width,l.height=t.height,i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,c,0),i.framebufferTexture2D(i.FRAMEBUFFER,o.COLOR_ATTACHMENT1_WEBGL,i.TEXTURE_2D,s,0),o.drawBuffersWEBGL([i.COLOR_ATTACHMENT0,o.COLOR_ATTACHMENT1_WEBGL])}else o.drawBuffersWEBGL([i.COLOR_ATTACHMENT0,null])}},{key:"_renderScene",value:function(e,t,r){t=t||!1,r=r||null;var n=this._gfx;if(n.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent)),n.renderer.setRenderTarget(r),n.renderer.clear(),n.renderer.xr.enabled)n.renderer.render(n.scene,e);else{n.renderer.setClearColor(0,0),n.renderer.setRenderTarget(n.offscreenBuf4),n.renderer.clearColor(),n.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent)),n.renderer.setRenderTarget(n.offscreenBuf),n.renderer.clear();var i=null!==this._getComplexVisual(),o=this._getVolumeVisual(),a=i&&J.now.ao;a&&this._enableMRT(!0,n.offscreenBuf,n.offscreenBuf4),"prepass"===J.now.transparency?this._renderWithPrepassTransparency(e,n.offscreenBuf):"standard"===J.now.transparency&&(n.renderer.setRenderTarget(n.offscreenBuf),n.renderer.render(n.scene,e)),a&&this._enableMRT(!1,null,null);var s=i&&J.now.outline.on,l=i&&J.now.fxaa,c=null!==o&&null!=o.getMesh().material,u=a||s||c||l||t?n.offscreenBuf2:r,h=n.offscreenBuf;a?(this._performAO(h,n.offscreenBuf4,n.offscreenBuf.depthTexture,u,n.offscreenBuf3,n.offscreenBuf2),l||t||c||s||(h=u,u=r,n.renderer.setRenderTarget(u),n.renderer.renderScreenQuadFromTex(h.texture,1))):(n.renderer.setRenderTarget(u),n.renderer.renderScreenQuadFromTex(h.texture,1)),s&&(h=u,u=c||l||t?n.offscreenBuf3:r,null!=h&&this._renderOutline(e,n.offscreenBuf,h,u)),this._renderSelection(e,n.offscreenBuf,u),c&&(n.renderer.setRenderTarget(n.offscreenBuf),n.renderer.renderScreenQuadFromTex(u.texture,1),u=n.offscreenBuf,this._renderVolume(o,e,u,n.volBFTex,n.volFFTex,n.volWFFTex),l||t||(n.renderer.setRenderTarget(r),n.renderer.renderScreenQuadFromTex(u.texture,1))),h=u,l&&(u=t?n.offscreenBuf4:r,this._performFXAA(h,u),h=u),t&&(u=r,this._performDistortion(h,u,!0))}}},{key:"_performDistortion",value:function(e,t,r){this._scene.add(new wi.Mesh(this._geo,this._material)),this._gfx.renderer.setRenderTarget(t),this._gfx.renderer.clear(),r?(this._material.uniforms.srcTex.value=e.texture,this._material.uniforms.aberration.value.set(.995,1,1.01),this._gfx.renderer.render(this._scene,this._camera)):this._gfx.renderer.renderScreenQuadFromTexWithDistortion(e,J.now.debug.stereoBarrel)}},{key:"_renderOutline",value:function(e,t,r,n){var o=this._gfx;this._outlineMaterial.uniforms.srcTex.value=r.texture,this._outlineMaterial.uniforms.srcDepthTex.value=t.depthTexture,this._outlineMaterial.uniforms.srcTexSize.value.set(t.width,t.height),this._outlineMaterial.uniforms.color.value=new i.Ilk(J.now.outline.color),this._outlineMaterial.uniforms.threshold.value=J.now.outline.threshold,this._outlineMaterial.uniforms.thickness.value=new i.FM8(J.now.outline.thickness,J.now.outline.thickness),o.renderer.setRenderTarget(n),o.renderer.renderScreenQuad(this._outlineMaterial)}},{key:"_renderShadowMap",value:function(){if(J.now.shadow.on){var e=this._gfx,t=e.renderer.getRenderTarget(),r=e.renderer.getActiveCubeFace(),n=e.renderer.getActiveMipmapLevel(),o=e.renderer.state;o.setBlending(i.jFi),o.buffers.color.setClear(1,1,1,1),o.buffers.depth.setTest(!0),o.setScissorTest(!1);for(var a=0;a<e.scene.children.length;a++)if("DirectionalLight"===e.scene.children[a].type){var s=e.scene.children[a];null==s.shadow.map&&(s.shadow.map=new i.dd2(s.shadow.mapSize.width,s.shadow.mapSize.height,this.pars),s.shadow.camera.updateProjectionMatrix()),s.shadow.updateMatrices(s),e.renderer.setRenderTarget(s.shadow.map),e.renderer.clear(),e.renderer.render(e.scene,s.shadow.camera)}e.renderer.setRenderTarget(t,r,n)}}},{key:"_hasSelectionToRender",value:function(){for(var e=this._gfx.selectionPivot,t=0;t<e.children.length;t++)if(e.children[t].children.length>0)return!0;return!1}},{key:"_renderSelection",value:function(e,t,r){var n=new Xc,i=this._gfx;i.renderer.setClearColor("black",0),i.renderer.setRenderTarget(t),i.renderer.clear(!0,!1,!1),this._hasSelectionToRender()?(i.selectionRoot.matrix=i.root.matrix,i.selectionPivot.matrix=i.pivot.matrix,i.renderer.render(i.selectionScene,e)):i.renderer.renderDummyQuad(),i.renderer.setRenderTarget(r),i.renderer.renderScreenQuadFromTex(t.texture,.6),n.uniforms.srcTex.value=t.texture,n.uniforms.srcTexSize.value.set(t.width,t.height),i.renderer.renderScreenQuad(n)}},{key:"_checkVolumeRenderingSupport",value:function(e){if(!e)return!1;var t=this._gfx,r=t.renderer.getRenderTarget();t.renderer.setRenderTarget(e);var n=t.renderer.getContext(),i=n.checkFramebufferStatus(n.FRAMEBUFFER);return t.renderer.setRenderTarget(r),i===n.FRAMEBUFFER_COMPLETE||(this.logger.warn("Device doesn't support electron density rendering"),!1)}},{key:"_renderVolume",value:function(e,t,r,n,o,a){var s,l=new qa.BackFacePosMaterial,c=new qa.FrontFacePosMaterial,u=(new i.yGw).makeTranslation(.5,.5,.5),h=new i.yGw,f=this._gfx;if(void 0===s&&(s=this._checkVolumeRenderingSupport(n)),s){var d=e.getMesh();d.rebuild(f.camera),f.renderer.setClearColor("black",0),f.renderer.setRenderTarget(n),f.renderer.clear(),f.renderer.setRenderTarget(o),f.renderer.clear(),f.renderer.setRenderTarget(a),f.renderer.clear(),f.renderer.setRenderTarget(n),t.layers.set(Er.LAYERS.VOLUME_BFPLANE),f.renderer.render(f.scene,t),t.layers.set(Er.LAYERS.VOLUME),f.scene.overrideMaterial=l,f.renderer.render(f.scene,t),f.renderer.setRenderTarget(o),t.layers.set(Er.LAYERS.VOLUME),f.scene.overrideMaterial=c,f.renderer.render(f.scene,t),f.scene.overrideMaterial=null,t.layers.set(Er.LAYERS.DEFAULT),h.copy(d.matrixWorld).invert(),ui.prototype.uberOptions.world2colorMatrix.multiplyMatrices(u,h),t.layers.set(Er.LAYERS.COLOR_FROM_POSITION),f.renderer.setRenderTarget(a),f.renderer.render(f.scene,t);var p=d.material;p.uniforms._BFRight.value=n.texture,p.uniforms._FFRight.value=o.texture,p.uniforms._WFFRight.value=a.texture,t.layers.set(Er.LAYERS.VOLUME),f.renderer.setRenderTarget(r),f.renderer.render(f.scene,t),t.layers.set(Er.LAYERS.DEFAULT)}}},{key:"_renderWithPrepassTransparency",value:function(e,t){var r=this._gfx;r.renderer.setRenderTarget(t),e.layers.set(Er.LAYERS.DEFAULT),r.renderer.render(r.scene,e),e.layers.set(Er.LAYERS.PREPASS_TRANSPARENT),r.renderer.getContext().colorMask(!1,!1,!1,!1),r.renderer.render(r.scene,e),r.renderer.getContext().colorMask(!0,!0,!0,!0),e.layers.set(Er.LAYERS.TRANSPARENT),r.renderer.render(r.scene,e),e.layers.set(Er.LAYERS.DEFAULT)}},{key:"_performFXAA",value:function(e,t){var r=new qc;if(void 0!==e&&void 0!==t){var n=this._gfx;n.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent)),n.renderer.setRenderTarget(t),n.renderer.clear(),r.uniforms.srcTex.value=e.texture,r.uniforms.srcTexelSize.value.set(1/e.width,1/e.height),r.uniforms.bgColor.value.set(J.now.bg.color),r.bgTransparent!==J.now.bg.transparent&&(r.setValues({bgTransparent:J.now.bg.transparent}),r.needsUpdate=!0),n.renderer.renderScreenQuad(r)}}},{key:"_performAO",value:function(e,t,r,n,o,a){var s=new Zc,l=new Qc,c=new eu,u=new i.Pa4;if(e&&t&&r&&n&&o&&a){var h=this._gfx,f=Math.tan(.5*i.M8C.DEG2RAD*h.camera.fov);s.uniforms.diffuseTexture.value=e.texture,s.uniforms.depthTexture.value=r,s.uniforms.normalTexture.value=t.texture,s.uniforms.srcTexelSize.value.set(1/e.width,1/e.height),s.uniforms.camNearFar.value.set(h.camera.near,h.camera.far),s.uniforms.projMatrix.value=h.camera.projectionMatrix,s.uniforms.aspectRatio.value=h.camera.aspect,s.uniforms.tanHalfFOV.value=f,h.root.matrix.extractScale(u),s.uniforms.kernelRadius.value=J.now.debug.ssaoKernelRadius*u.x,s.uniforms.depthThreshold.value=2*this._getBSphereRadius(),s.uniforms.factor.value=J.now.debug.ssaoFactor,h.renderer.setRenderTarget(a),h.renderer.renderScreenQuad(s),l.uniforms.aoMap.value=a.texture,l.uniforms.srcTexelSize.value.set(1/a.width,1/a.height),l.uniforms.depthTexture.value=r,h.renderer.setRenderTarget(o),h.renderer.renderScreenQuad(l),c.uniforms.aoMap.value=o.texture,c.uniforms.diffuseTexture.value=e.texture,c.uniforms.srcTexelSize.value.set(1/o.width,1/o.height),c.uniforms.depthTexture.value=r,c.uniforms.projMatrix.value=h.camera.projectionMatrix,c.uniforms.aspectRatio.value=h.camera.aspect,c.uniforms.tanHalfFOV.value=f;var d=h.scene.fog;d&&(c.uniforms.fogNearFar.value.set(d.near,d.far),c.uniforms.fogColor.value.set(d.color.r,d.color.g,d.color.b,J.now.fogAlpha)),c.useFog===J.now.fog&&c.fogTransparent===J.now.bg.transparent||(c.setValues({useFog:J.now.fog,fogTransparent:J.now.bg.transparent}),c.needsUpdate=!0),h.renderer.setRenderTarget(n),h.renderer.renderScreenQuad(c)}}},{key:"reset",value:function(){this._picker&&this._picker.reset(),this._lastPick=null,this._releaseAllVisuals(),this._setEditMode(0),this._resetObjects(),this._gfx&&(Er.clearTree(this._gfx.pivot),this._gfx.renderer2d.reset()),this.setNeedRender()}},{key:"_resetScene",value:function(){this._objectControls.reset(),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.resetReps(),this.resetPivot(),this.rebuildAll()}},{key:"resetView",value:function(){this._picker&&this._picker.reset(),this._setEditMode(0),this._resetScene(),this._forEachComplexVisual((function(e){e.updateSelectionMask({}),e.rebuildSelectionGeometry()}))}},{key:"_export",value:function(e){var t=(0,n.head)(Tc.exporters.find({format:e}));if(!t)return this.logger.error("Could not find suitable exporter for this source"),Promise.reject(new Error("Could not find suitable exporter for this source"));if(this.dispatchEvent({type:"exporting"}),this._visuals[this._curVisualName]instanceof Ua){var r=null;return t.SourceClass===Ua?r=this._visuals[this._curVisualName]:t.SourceClass===ur&&(r=this._visuals[this._curVisualName]._complex),new t(r,{miewVersion:s.VERSION}).export().then((function(e){return e}))}return this._visuals[this._curVisualName]instanceof Qa?Promise.reject(new Error("Sorry, exporter for volume data not implemented yet")):Promise.reject(new Error("Unexpected format of data"))}},{key:"load",value:function(e,t){var r=this;t=(0,n.merge)({},t,{context:this}),this.settings.now.use.multiFile||(this._loading.length&&(this._loading.forEach((function(e){e.cancel()})),this._loading.length=0),t.animation||this.reset(!0)),this._interpolator.reset(),this.dispatchEvent({type:"loading",options:t,source:e});var i=new Z;this._loading.push(i),i.addEventListener("notification",(function(e){r.dispatchEvent(e.slaveEvent)})),this._spinner.spin(this._container);var o=function(e){var t=r._loading.indexOf(i);return-1!==t&&r._loading.splice(t,1),r._spinner.stop(),r._refreshTitle(),i.notify({type:"loadingDone",anything:e}),e};return function(e,t,r){return new Promise((function(i){if(r.shouldCancel())throw new Error("Operation cancelled");r.notify({type:"fetching"}),e=function(e,t){if(!(0,n.isString)(e))return e;var r=gu.exec(e);if(r){var i=v(r,3),o=i[1],a=void 0===o?"pdb":o,s=i[2];switch(a=a.toLowerCase(),s=s.toUpperCase(),a){case"pdb":e="https://files.rcsb.org/download/".concat(s,".pdb");break;case"cif":e="https://files.rcsb.org/download/".concat(s,".cif");break;case"mmtf":e="https://mmtf.rcsb.org/v1.0/full/".concat(s);break;case"ccp4":e="https://www.ebi.ac.uk/pdbe/coordinates/files/".concat(s.toLowerCase(),".ccp4");break;case"dsn6":e="https://edmaps.rcsb.org/maps/".concat(s.toLowerCase(),"_2fofc.dsn6");break;default:throw new Error("Unexpected data format shortcut")}return t.fileType=a,t.fileName="".concat(s,".").concat(a),t.sourceType="url",e}var l=xu.exec(e);if(l){var c=l[1].toLowerCase();return e="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/".concat(c,"/JSON?record_type=3d"),t.fileType="pubchem",t.fileName="".concat(c,".json"),t.sourceType="url",e}return"url"!==t.sourceType&&void 0!==t.sourceType||(t.sourceType="url",bu.test(e)||(e=$.resolveURL(e))),e}(e,t);var o=(0,n.head)(Tc.loaders.find({type:t.sourceType,source:e}));if(!o)throw new Error(hu);var a=t.fileName||o.extractName(e);if(a){var s=v($.splitFileName(a),2),l=s[0],c=s[1];(0,n.defaults)(t,{name:l,fileExt:c,fileName:a})}!function(e){var t=e.binary;if(void 0!==e.fileType){var r=(0,n.head)(Tc.parsers.find({format:e.fileType}));if(!r)throw new Error("Could not find suitable parser for this format");t=r.binary||!1}if(void 0===t&&void 0!==e.fileExt){var i=(0,n.head)(Tc.parsers.find({ext:e.fileExt}));i&&(t=i.binary||!1)}void 0!==e.fileExt&&".man"===e.fileExt.toLowerCase()&&(e.binary=!0,e.animation=!0),void 0!==t&&void 0!==e.binary&&e.binary!==t&&e.context.logger.warn("Overriding incorrect binary mode"),e.binary=t||!1}(t);var u=(0,n.get)(t,"preset.expression");if(!(0,n.isUndefined)(u)&&(u=JSON.parse(u))&&u.settings)for(var h=["singleUnit"],f=0,d=h.length;f<d;++f){var p=h[f],m=(0,n.get)(u.settings,p);(0,n.isUndefined)(m)||J.set(p,m)}var y=new o(e,t);y.context=t.context,r.addEventListener("cancel",(function(){return y.abort()})),y.addEventListener("progress",(function(e){e.lengthComputable&&e.total>0?pu(y.logger,"Fetching",e.loaded/e.total):pu(y.logger,"Fetching")})),console.time("fetch"),i(y.load().then((function(e){return console.timeEnd("fetch"),t.context.logger.info("Fetching finished"),r.notify({type:"fetchingDone",data:e}),e})).catch((function(e){throw console.timeEnd("fetch"),t.context.logger.debug(e.message),e.stack&&t.context.logger.debug(e.stack),t.context.logger.error("Fetching failed"),r.notify({type:"fetchingDone",error:e}),e})))}))}(e,t,i).then((function(e){return function(e,t,r){if(r.shouldCancel())return Promise.reject(new Error("Operation cancelled"));r.notify({type:"parsing"});var i=(0,n.head)(Tc.parsers.find({format:t.fileType,ext:t.fileExt,data:e}));if(!i)return Promise.reject(new Error("Could not find suitable parser"));var o=new i(e,t);return o.context=t.context,r.addEventListener("cancel",(function(){return o.abort()})),console.time("parse"),o.parse().then((function(e){return console.timeEnd("parse"),r.notify({type:"parsingDone",data:e}),e})).catch((function(e){throw console.timeEnd("parse"),t.error=e,t.context.logger.debug(e.message),e.stack&&t.context.logger.debug(e.stack),t.context.logger.error("Parsing failed"),r.notify({type:"parsingDone",error:e}),e}))}(e,t,i)})).then((function(e){var n=r._onLoad(e,t);return o(n)})).catch((function(e){throw r.logger.error("Could not load data"),r.logger.debug(e),o(e)}))}},{key:"unload",value:function(e){this._removeVisual(e||this.getCurrentVisual()),this.resetPivot(),J.now.shadow.on&&this._updateShadowCamera()}},{key:"_startAnimation",value:function(e){this._stopAnimation();var t=this,r=this._getComplexVisual();if(null!==r){try{this._frameInfo=new Hc(r.getComplex(),e,{onLoadStatusChanged:function(){t.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:t._isAnimating,isLoading:!t._frameInfo||t._frameInfo.isLoading}})},onError:function(e){t._stopAnimation(),t.logger.error(e)}})}catch(e){return void this.logger.error("Animation file does not fit to current complex!")}this._continueAnimation()}else this.logger.error("Unable to start animation - no molecule is loaded.")}},{key:"_pauseAnimation",value:function(){null!==this._animInterval&&(this._isAnimating=!1,clearInterval(this._animInterval),this._animInterval=null,this._frameInfo&&this.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:this._isAnimating,isLoading:this._frameInfo.isLoading}}))}},{key:"_continueAnimation",value:function(){this._isAnimating=!0;var e=1e3/J.now.maxfps;e=Number.isNaN(e)?0:e;var t=this,r=t._gfx.pivot,n=this._getComplexVisual();n&&(n.resetSelectionMask(),n.rebuildSelectionGeometry(),this._msgAtomInfo.style.opacity=0),this._animInterval=setInterval((function(){if(t.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:t._isAnimating,isLoading:t._frameInfo.isLoading}}),t._frameInfo.frameIsReady){r.updateToFrame(t._frameInfo),t._updateObjsToFrame(t._frameInfo),t._refreshTitle(" Frame ".concat(t._frameInfo._currFrame," of ").concat(t._frameInfo._framesCount," time interval - ").concat(t._frameInfo._timeStep));try{t._frameInfo.nextFrame()}catch(e){return t.logger.error("Error during animation"),void t._stopAnimation()}t._needRender=!0}}),e)}},{key:"_stopAnimation",value:function(){null!==this._animInterval&&(clearInterval(this._animInterval),this._frameInfo.disableEvents(),this._frameInfo=null,this._animInterval=null,this.dispatchEvent({type:"mdPlayerStateChanged",state:null}))}},{key:"_onLoad",value:function(e,t){var r=this._gfx,i=null;if(t.animation)return this._refreshTitle(),this._startAnimation(e),null;if(this._stopAnimation(),t&&t.keepRepsInfo||(this._opts.reps=null,this._opts._objects=null),"Complex"===e.id){var o=e;t.fileName?o.name=o.name||du(t.fileName).toUpperCase():t.amberFileName?o.name=o.name||du(t.amberFileName).toUpperCase():o.name="Dynamic ".concat(t.fileType," molecule"),i=this._addVisual(new Ua(o.name,o)),this._curVisualName=i;var a=this.info();if(this.logger.info("Parsed ".concat(t.fileName," (").concat(a.atoms," atoms, ").concat(a.bonds," bonds, ").concat(a.residues," residues, ").concat(a.chains," chains).")),(0,n.isNumber)(this._opts.unit)&&o.setCurrentUnit(this._opts.unit),t.preset);else if(J.now.autoPreset)switch(t.fileType){case"cml":this.resetReps("small");break;case"pdb":case"mmtf":case"cif":!function(e){var t=!1;return e.forEachComponent((function(e){e.forEachResidue((function(e){e._isValid&&(t=!0)}))})),t}(o)?this.resetReps("small"):this.resetReps("macro");break;default:this.resetReps("default")}else this.resetReps("default")}else"Volume"===e.id&&(this.resetEd(),i=this._onLoadEd(e));return r.camera.updateProjectionMatrix(),this._updateFog(),r.root.resetTransform(),this.resetPivot(),this._objectControls.setScale(J.now.radiusToFit/this._getBSphereRadius()),this._resetObjects(),J.now.autoResolution&&this._tweakResolution(),J.now.shadow.on&&this._updateShadowCamera(),this._opts.view&&(this.view(this._opts.view),delete this._opts.view),this._refreshTitle(),i}},{key:"resetEd",value:function(){this._edLoader&&(this._edLoader.abort(),this._edLoader=null),this._removeVisual(this._getVolumeVisual()),this._needRender=!0}},{key:"loadEd",value:function(e){var t=this;this.resetEd();var r=(0,n.head)(Tc.loaders.find({source:e}));if(!r)return this.logger.error(hu),Promise.reject(new Error(hu));var i=this._edLoader=new r(e,{binary:!0});return i.context=this,i.load().then((function(e){var r=(0,n.head)(Tc.parsers.find({format:"ccp4"}));if(!r)throw new Error("Could not find suitable parser for this source");var i=new r(e);return i.context=t,i.parse().then((function(e){t._onLoadEd(e)}))})).catch((function(e){t.logger.error("Could not load ED data"),t.logger.debug(e)}))}},{key:"_onLoadEd",value:function(e){e.normalize();var t=new Qa("volume",e);t.getMesh().layers.set(Er.LAYERS.VOLUME);var r=this._addVisual(t);return this._needRender=!0,r}},{key:"_needRebuild",value:function(){var e=!1;return this._forEachComplexVisual((function(t){e=e||t.needsRebuild()})),e}},{key:"_rebuildObjects",value:function(){var e,t,r=this,n=this._gfx,i=[];for(e=0;e<n.pivot.children.length;++e){var o=n.pivot.children[e];o instanceof Pr||i.push(o)}for(e=0;e<i.length;++e)i[e].parent.remove(i[e]);setTimeout((function(){var i=r._objects;for(e=0,t=i.length;e<t;++e){var o=i[e];o.needsRebuild&&o.build(),o.getGeometry()&&n.pivot.add(o.getGeometry())}}),10)}},{key:"changeUnit",value:function(e,t){var r,i,o=this._getComplexVisual(t);if(!o)throw new Error("There is no complex to change!");return void 0===e||((0,n.isString)(e)&&(e=Math.max(parseInt(e,10),0)),o.getComplex().setCurrentUnit(e)&&(this._resetScene(),this._updateInfoPanel())),r=o?o.getComplex().getCurrentUnit():0,i=r>0?"Bio molecule ".concat(r):"Asymmetric unit","Current unit: ".concat(r," (").concat(i,")")}},{key:"rebuild",value:function(){var e=this;if(this._building)this.logger.warn("Miew.rebuild(): already building!");else{this._building=!0,this.dispatchEvent({type:"rebuilding"}),this._rebuildObjects(),this._gfx.renderer2d.reset();var t=[];this._forEachComplexVisual((function(e){e.needsRebuild()&&t.push(e.rebuild().then((function(){return new Promise((function(t){e.rebuildSelectionGeometry(),t()}))})))}));var r=this;this._spinner.spin(this._container),Promise.all(t).then((function(){r._spinner.stop(),r._needRender=!0,r._refreshTitle(),e.dispatchEvent({type:"buildingDone"}),r._building=!1}))}}},{key:"rebuildAll",value:function(){this._forEachComplexVisual((function(e){e.setNeedsRebuild()}))}},{key:"_refreshTitle",value:function(e){var t;e=void 0===e?"":e;var r=this._getComplexVisual();if(r){t=r.getComplex().name;var n=r.repGet(r.repCurrent());t+=n?" – ".concat(n.mode.name," Mode"):""}else t=Object.keys(this._visuals).length>0?"Unknown":"No Data";t+=e,this.dispatchEvent({type:"titleChanged",data:t})}},{key:"setNeedRender",value:function(){this._needRender=!0}},{key:"_extractRepresentation",value:function(){var e=this,t=[];this._forEachComplexVisual((function(r){if(0!==r.getSelectionCount()){var n=r.buildSelectorFromMask(1<<r.getSelectionBit()),i=J.now.presets.default,o=r.repAdd({selector:n,mode:i[0].mode.id,colorer:i[0].colorer.id,material:i[0].material.id});o?(e.dispatchEvent({type:"repAdded",index:o.index,name:r.name}),r.repCurrent(o.index),t.push(r.name)):r.repCount()===Ua.NUM_REPRESENTATION_BITS&&e.logger.warn("Number of representations is limited to ".concat(Ua.NUM_REPRESENTATION_BITS))}})),t.length>0&&this.logger.report("New representation from selection for complexes: ".concat(t.join(", ")))}},{key:"_setReps",value:function(e){e=e||this._opts&&this._opts.reps||[],this._forEachComplexVisual((function(t){return t.resetReps(e)}))}},{key:"applyPreset",value:function(e){for(var t=J.now.presets,r=[e||J.defaults.preset,J.defaults.preset,Object.keys(t)[0]],n=null,i=0;!n&&i<r.length;++i)J.set("preset",r[i]),(n=t[J.now.preset])||this.logger.warn('Unknown preset "'.concat(J.now.preset,'"'));this._setReps(n)}},{key:"resetReps",value:function(e){var t=this._opts&&this._opts.reps;t?this._setReps(t):this.applyPreset(e)}},{key:"repCount",value:function(e){var t=this._getComplexVisual(e);return t?t.repCount():0}},{key:"repCurrent",value:function(e,t){var r=this._getComplexVisual(t),n=r?r.repCurrent(e):-1;return e&&n!==e&&this.logger.warn("Representation ".concat(e," was not found. Current rep remains unchanged.")),n}},{key:"rep",value:function(e,t){var r=this._getComplexVisual("");if(!r)return null;var n=r.rep(e,t);return"created"===n.status?this.dispatchEvent({type:"repAdded",index:n.index,name:r.name}):"changed"===n.status&&this.dispatchEvent({type:"repChanged",index:n.index,name:r.name}),n.desc}},{key:"repGet",value:function(e,t){var r=this._getComplexVisual(t);return r?r.repGet(e):null}},{key:"repAdd",value:function(e,t){var r=this._getComplexVisual(t);if(!r)return-1;var n=r.repAdd(e);return n?(this.dispatchEvent({type:"repAdded",index:n.index,name:t}),n.index):-1}},{key:"repRemove",value:function(e,t){var r=this._getComplexVisual(t);r&&(r.repRemove(e),this.dispatchEvent({type:"repRemoved",index:e,name:t}))}},{key:"repHide",value:function(e,t,r){this._needRender=!0;var n=this._getComplexVisual(r);return n?n.repHide(e,t):null}},{key:"_setEditMode",value:function(e){this._editMode=e;var t=this._msgMode;t&&(t.style.opacity=0===e?0:1,0!==e&&(t.getElementsByTagName("p")[0].innerHTML=1===e?"COMPONENT EDIT MODE":"FRAGMENT EDIT MODE")),this.dispatchEvent({type:"editModeChanged",data:0===e})}},{key:"_enterComponentEditMode",value:function(){if(0===this._editMode){var e=[];this._forEachComplexVisual((function(t){var r=t.beginComponentEdit();r&&e.push(r)})),e!==[]&&(this._editors=e,this.logger.info("COMPONENT EDIT MODE -- ON"),this._setEditMode(1),this._objectControls.keysTranslateObj(!0))}}},{key:"_applyComponentEdit",value:function(){if(1===this._editMode){this._objectControls.stop(),this._objectControls.keysTranslateObj(!1);for(var e=0;e<this._editors.length;++e)this._editors[e].apply();this._editors=[],this.logger.info("COMPONENT EDIT MODE -- OFF (applied)"),this._setEditMode(0),this.rebuildAll()}}},{key:"_discardComponentEdit",value:function(){if(1===this._editMode){this._objectControls.stop(),this._objectControls.keysTranslateObj(!1);for(var e=0;e<this._editors.length;++e)this._editors[e].discard();this._editors=[],this.logger.info("COMPONENT EDIT MODE -- OFF (discarded)"),this._setEditMode(0),this._needRender=!0,this.rebuildAll()}}},{key:"_enterFragmentEditMode",value:function(){if(0===this._editMode){var e=[];if(this._forEachComplexVisual((function(t){t instanceof Ua&&t.getSelectionCount()>0&&e.push(t)})),1===e.length){var t=e[0].beginFragmentEdit();t&&(this._editors=[t],this.logger.info("FRAGMENT EDIT MODE -- ON (single bond)"),this._setEditMode(2),this._objectControls.allowTranslation(!1),this._objectControls.allowAltObjFreeRotation(t.isFreeRotationAllowed()),this._needRender=!0)}}}},{key:"_applyFragmentEdit",value:function(){if(2===this._editMode){this._objectControls.stop();for(var e=0;e<this._editors.length;++e)this._editors[e].apply();this._editors=[],this.logger.info("FRAGMENT EDIT MODE -- OFF (applied)"),this._setEditMode(0),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.rebuildAll()}}},{key:"_discardFragmentEdit",value:function(){if(2===this._editMode){this._objectControls.stop();for(var e=0;e<this._editors.length;++e)this._editors[e].discard();this._editors=[],this.logger.info("FRAGMENT EDIT MODE -- OFF (discarded)"),this._setEditMode(0),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this._needRender=!0}}},{key:"_onPick",value:function(e){if(J.now.picking&&null===this._animInterval&&2!==this._editMode&&!this._objectControls.isEditingAltObj()){var t=null;if(e.obj.atom?(t=e.obj.atom.residue.getChain().getComplex(),this._lastPick=e.obj.atom):e.obj.residue?(t=e.obj.residue.getChain().getComplex(),this._lastPick=e.obj.residue):e.obj.chain?(t=e.obj.chain.getComplex(),this._lastPick=e.obj.chain):e.obj.molecule?(t=e.obj.molecule.complex,this._lastPick=e.obj.molecule):this._lastPick=null,t){var r=this._getVisualForComplex(t);r&&(n(r),this._needRender=!0)}else this._forEachComplexVisual(n),this._needRender=!0;this._updateInfoPanel(),this.dispatchEvent(e)}function n(t){t.updateSelectionMask(e.obj),t.rebuildSelectionGeometry()}}},{key:"_onKeyDown",value:function(e){if(this._running&&this._hotKeysEnabled)switch(e.keyCode){case"C".charCodeAt(0):J.now.editing&&this._enterComponentEditMode();break;case"F".charCodeAt(0):J.now.editing&&this._enterFragmentEditMode();break;case"A".charCodeAt(0):switch(this._editMode){case 1:this._applyComponentEdit();break;case 2:this._applyFragmentEdit()}break;case"D".charCodeAt(0):switch(this._editMode){case 1:this._discardComponentEdit();break;case 2:this._discardFragmentEdit()}break;case"S".charCodeAt(0):e.preventDefault(),e.stopPropagation(),J.set("ao",!J.now.ao),this._needRender=!0;break;case 107:e.preventDefault(),e.stopPropagation(),this._forEachComplexVisual((function(e){e.expandSelection(),e.rebuildSelectionGeometry()})),this._updateInfoPanel(),this._needRender=!0;break;case 109:e.preventDefault(),e.stopPropagation(),this._forEachComplexVisual((function(e){e.shrinkSelection(),e.rebuildSelectionGeometry()})),this._updateInfoPanel(),this._needRender=!0}}},{key:"_onKeyUp",value:function(e){this._running&&this._hotKeysEnabled&&e.keyCode==="X".charCodeAt(0)&&this._extractRepresentation()}},{key:"_updateInfoPanel",value:function(){var e,t,r=this._msgAtomInfo.getElementsByTagName("p")[0],n=0;for(this._forEachComplexVisual((function(e){n+=e.getSelectionCount()}));r.firstChild;)r.removeChild(r.firstChild);if(0!==n){var i="".concat(String(n)," atom").concat(1!==n?"s":""," selected");null!==this._lastPick&&(i+=", the last pick:");var o="",a="",s="";if(this._lastPick instanceof su){t=(e=this._lastPick).residue,a=e.name;var l=32!==e.location?String.fromCharCode(e.location):"";o="".concat(e.element.fullName," #").concat(e.serial).concat(l,": ").concat(t._chain._name,".").concat(t._type._name).concat(t._sequence).concat(t._icode.trim(),"."),o+=a,s="Coord: (".concat(e.position.x.toFixed(2).toString(),", ").concat(e.position.y.toFixed(2).toString(),", ").concat(e.position.z.toFixed(2).toString(),")")}else this._lastPick instanceof lu?(t=this._lastPick,o="".concat(t._type._fullName,": ").concat(t._chain._name,".").concat(t._type._name).concat(t._sequence).concat(t._icode.trim())):this._lastPick instanceof cu?o="chain ".concat(this._lastPick._name):this._lastPick instanceof uu&&(o="molecule ".concat(this._lastPick._name));r.appendChild(document.createTextNode(i)),""!==o&&(r.appendChild(document.createElement("br")),r.appendChild(document.createTextNode(o))),""!==s&&(r.appendChild(document.createElement("br")),r.appendChild(document.createTextNode(s))),this._msgAtomInfo.style.opacity=1}else this._msgAtomInfo.style.opacity=0}},{key:"_getAltObj",value:function(){if(this._editors){for(var e=null,t=0;t<this._editors.length;++t){var r=this._editors[t].getAltObj();if(r.objects.length>0){if(e){e=null;break}e=r}}if(e)return e}return{objects:[],pivot:new i.Pa4(0,0,0)}}},{key:"resetPivot",value:function(){var e=new i.ZzF,t=new i.Pa4;e.makeEmpty(),this._forEachVisual((function(t){e.union(t.getBoundaries().boundingBox)})),e.getCenter(t),this._objectControls.setPivot(t.negate()),this.dispatchEvent({type:"transform"})}},{key:"setPivotResidue",value:function(e){var t=new i.Pa4,r=this._getVisualForComplex(e.getChain().getComplex());if(r){if(e._controlPoint)t.copy(e._controlPoint);else{for(var n=0,o=0,a=0,s=e._atoms.length,l=0;l<s;++l){var c=e._atoms[l].position;n+=c.x/s,o+=c.y/s,a+=c.z/s}t.set(n,o,a)}t.applyMatrix4(r.matrix).negate(),this._objectControls.setPivot(t),this.dispatchEvent({type:"transform"})}}},{key:"setPivotAtom",value:function(e){var t=new i.Pa4,r=this._getVisualForComplex(e.residue.getChain().getComplex());r&&(t.copy(e.position),t.applyMatrix4(r.matrix).negate(),this._objectControls.setPivot(t),this.dispatchEvent({type:"transform"}))}},{key:"getSelectionCenter",value:function(e,t,r){var n=new i.Pa4(0,0,0);e.set(0,0,0);var o=0;return this._forEachComplexVisual((function(i){i.getSelectionCenter(n,t,r||i.getSelectionBit())&&(e.add(n),o++)})),0!==o&&(e.divideScalar(o),e.negate(),!0)}},{key:"setPivotSubset",value:function(e){var t=new i.Pa4(0,0,0),r=e?Su:wu;this.getSelectionCenter(t,r,e)?(this._objectControls.setPivot(t),this.dispatchEvent({type:"transform"})):this.logger.warn("selection is empty. Center operation not performed")}},{key:"screenshot",value:function(e,t){var r,n,o,a=this._gfx,s=a.renderer.domElement.width,l=a.renderer.domElement.height;function c(){var r;if($.getBrowser()===$.browserType.SAFARI){var n=document.createElement("canvas"),i=n.getContext("2d");n.width=void 0===e?s:e,n.height=void 0===t?l:t,i.drawImage(a.renderer.domElement,0,0,n.width,n.height),r=n.toDataURL("image/png")}else r=a.renderer.domElement.toDataURL("image/png");return r}if(t=t||e,void 0===e&&void 0===t||e===s&&t===l)r=c();else{var u=a.camera.aspect,h=a.camera.fov,f=(o=a.camera.fov,Math.tan(i.M8C.degToRad(.5*o))*Math.min(a.width,a.height)/a.height),d=e/t;a.renderer.setPixelRatio(1),a.camera.aspect=d,a.camera.fov=(n=f/Math.min(d,1),2*i.M8C.radToDeg(Math.atan(n))),a.camera.updateProjectionMatrix(),a.renderer.setDrawingBufferSize(e,t,1),this._renderFrame(J.now.stereo),r=c(),a.renderer.setPixelRatio(window.devicePixelRatio),a.camera.aspect=u,a.camera.fov=h,a.camera.updateProjectionMatrix(),a.renderer.setDrawingBufferSize(a.width,a.height,window.devicePixelRatio),this._needRender=!0}return r}},{key:"screenshotSave",value:function(e,t,r){var n=this.screenshot(t,r);$.shotDownload(n,e)}},{key:"save",value:function(e){var t=this;this._export(e.fileType).then((function(r){var n=t._visuals[t._curVisualName]._complex.name;$.download(r,n,e.fileType),t._refreshTitle(),t.dispatchEvent({type:"exportingDone"})})).catch((function(e){t.logger.error("Could not export data"),t.logger.debug(e),t._refreshTitle(),t.dispatchEvent({type:"exportingDone",error:e})}))}},{key:"_tweakResolution",value:function(){var e=[["poor",100],["low",500],["medium",1e3],["high",5e3],["ultra",Number.MAX_VALUE]],t=0;if(this._forEachComplexVisual((function(e){t+=e.getComplex().getAtomCount()})),t>0)for(var r=1e6*this._gfxScore/t,n=0;n<e.length;++n)if(r<e[n][1]){this._autoChangeResolution(e[n][0]);break}}},{key:"_autoChangeResolution",value:function(e){e!==J.now.resolution&&this.logger.report('Your rendering resolution was changed to "'.concat(e,'" for best performance.')),J.now.resolution=e}},{key:"saveSettings",value:function(){this._cookies.setCookie(this._opts.settingsCookie,JSON.stringify(this.settings.getDiffs(!0)))}},{key:"restoreSettings",value:function(){try{var e=this._cookies.getCookie(this._opts.settingsCookie),t=e?JSON.parse(e):{};this.settings.applyDiffs(t,!0)}catch(e){this.logger.error("Cookies parse error: ".concat(e.message))}}},{key:"resetSettings",value:function(){this.settings.reset()}},{key:"setOptions",value:function(e){"string"==typeof e&&(e=s.options.fromAttr(e)),e.reps&&(this._opts.reps=null),(0,n.merge)(this._opts,e),e.settings&&this.set(e.settings),this._opts._objects=e._objects,this._resetObjects(),e.load&&this.load(e.load,{fileType:e.type}),e.preset&&(J.now.preset=e.preset),e.reps&&this.resetReps(e.preset),this._opts.view&&(this.view(this._opts.view),delete this._opts.view);var t=this._getComplexVisual();t&&(t.getComplex().resetCurrentUnit(),(0,n.isNumber)(e.unit)&&t.getComplex().setCurrentUnit(e.unit),this.resetView(),this.rebuildAll())}},{key:"info",value:function(e){var t=this._getComplexVisual(e);if(!t)return{};var r=t.getComplex(),n=r.metadata;return{id:n.id||r.name||"UNKNOWN",title:n.title&&n.title.join(" ")||"UNKNOWN DATA",atoms:r.getAtomCount(),bonds:r.getBondCount(),residues:r.getResidueCount(),chains:r.getChainCount()}}},{key:"addObject",value:function(e,t){var r=null;if(e.type===Yc.prototype.type&&(r=Yc),null===r)throw new Error("Unknown scene object type - ".concat(e.type));try{var n=new r(e.params,e.opts);this._addSceneObject(n)}catch(e){if(t)throw e;this.logger.debug("Error during scene object creation: ".concat(e.message))}this._needRender=!0}},{key:"_addSceneObject",value:function(e){var t=this._getComplexVisual();e.build&&t&&(e.build(t.getComplex()),this._gfx.pivot.add(e.getGeometry()));var r=this._objects;r[r.length]=e}},{key:"_updateObjsToFrame",value:function(e){for(var t=this._objects,r=0,n=t.length;r<n;++r)t[r].updateToFrame&&t[r].updateToFrame(e)}},{key:"_resetObjects",value:function(){var e=this._opts._objects;if(this._objects=[],e)for(var t=0,r=e.length;t<r;++t)this.addObject(e[t],!1)}},{key:"removeObject",value:function(e){var t=this._objects[e];if(!t)throw new Error("Scene object with index ".concat(e," does not exist"));t.destroy(),this._objects.splice(e,1),this._needRender=!0}},{key:"getURL",value:function(e){return Se.toURL(this.getState((0,n.defaults)(e,{compact:!0,settings:!1,view:!1})))}},{key:"getScript",value:function(e){return Se.toScript(this.getState((0,n.defaults)(e,{compact:!0,settings:!0,view:!0})))}},{key:"_compareReps",value:function(e,t){var r={},i=0;e&&(i=e.repCount());var o=J.defaults.presets[J.now.preset],a=t;void 0===o||o.length>i?(a=!1,r.preset="empty"):J.now.preset!==J.defaults.preset&&(r.preset=J.now.preset);for(var s=[],l=!0,c=0,u=i;c<u;++c)s[c]=e.repGet(c).compare(a?o[c]:null),(0,n.isEmpty)(s[c])||(l=!1);return l||(r.reps=s),r}},{key:"getState",value:function(e){var t={};e=(0,n.defaults)(e,{compact:!0,settings:!1,view:!1});var r=this._getComplexVisual();if(null!==r){var i=r.getComplex(),o=i.metadata;if(o.id){var a=o.format?"".concat(o.format,":"):"";t.load=a+o.id}var s=i.getCurrentUnit();1!==s&&(t.unit=s)}var l=this._compareReps(r,e.compact);l.preset&&(t.preset=l.preset),l.reps&&(t.reps=l.reps);for(var c=this._objects,u=[],h=0,f=c.length;h<f;++h)u[h]=c[h].identify();if(c.length>0&&(t._objects=u),e.view&&(t.view=this.view()),e.settings){var d=this.settings.getDiffs(!1);(0,n.isEmpty)(d)||(t.settings=d)}return t}},{key:"get",value:function(e,t){return J.get(e,t)}},{key:"_clipPlaneUpdateValue",value:function(e){var t=Math.max(this._gfx.camera.position.z-e*J.now.draft.clipPlaneFactor,J.now.camNear),r={clipPlaneValue:t};this._forEachComplexVisual((function(e){e.setUberOptions(r)}));for(var n=0,i=this._objects.length;n<i;++n){var o=this._objects[n];o._line&&o._line.material.setUberOptions(r)}null!==this._picker&&(this._picker.clipPlaneValue=t)}},{key:"_fogFarUpdateValue",value:function(){null!==this._picker&&(this._gfx.scene.fog?this._picker.fogFarValue=this._gfx.scene.fog.far:this._picker.fogFarValue=void 0)}},{key:"_updateShadowmapMeshes",value:function(e){this._forEachComplexVisual((function(t){for(var r=t._reprList,n=0,i=r.length;n<i;++n){var o=r[n];e(o.geo,o.material)}}))}},{key:"_updateMaterials",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;this._forEachComplexVisual((function(n){return n.setMaterialValues(e,t,r)}));for(var n=0,i=this._objects.length;n<i;++n){var o=this._objects[n];o._line&&(o._line.material.setValues(e),o._line.material.needsUpdate=!0)}}},{key:"_fogAlphaChanged",value:function(){this._forEachComplexVisual((function(e){e.setUberOptions({fogAlpha:J.now.fogAlpha})}))}},{key:"_embedWebXR",value:function(){var e=this;if("WEBVR"!==J.now.stereo)return this.webVR&&this.webVR.disable(),void(this.webVR=null);this.webVR||(this.webVR=new ou((function(){e._requestAnimationFrame((function(){return e._onTick()})),e._needRender=!0,e._onResize()}))),this.webVR.enable(this._gfx)}},{key:"_initOnSettingsChanged",value:function(){var e=this,t=function(t,r){(t=(0,n.isArray)(t)?t:[t]).forEach((function(t){e.settings.addEventListener("change:".concat(t),r)}))};t("modes.VD.frame",(function(){var t=e._getVolumeVisual();null!==t&&(t.showFrame(J.now.modes.VD.frame),e._needRender=!0)})),t("modes.VD.isoMode",(function(){var t=e._getVolumeVisual();null!==t&&(t.getMesh().material.updateDefines(),e._needRender=!0)})),t("bg.color",(function(){e._onBgColorChanged()})),t("ao",(function(){if(J.now.ao&&!_u(e._gfx.renderer.getContext()))e.logger.warn("Your device or browser does not support ao"),J.set("ao",!1);else{var t={normalsToGBuffer:J.now.ao};e._setUberMaterialValues(t)}})),t("zSprites",(function(){J.now.zSprites&&!yu(e._gfx.renderer.getContext())&&(e.logger.warn("Your device or browser does not support zSprites"),J.set("zSprites",!1)),e.rebuildAll()})),t("fogColor",(function(){e._onFogColorChanged()})),t("fogColorEnable",(function(){e._onFogColorChanged()})),t("bg.transparent",(function(t){var r=e._gfx;r&&r.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent)),e._updateMaterials({fogTransparent:t.value}),e.rebuildAll()})),t("draft.clipPlane",(function(t){e._updateMaterials({clipPlane:t.value}),e.rebuildAll()})),t("shadow.on",(function(t){var r={shadowmap:t.value,shadowmapType:J.now.shadow.type},n=e._gfx;n&&(n.renderer.shadowMap.enabled=Boolean(r.shadowmap)),e._updateMaterials(r,!0),r.shadowmap?(e._updateShadowCamera(),e._updateShadowmapMeshes(Ta.createShadowmapMaterial)):e._updateShadowmapMeshes(Ta.removeShadowmapMaterial),e._needRender=!0})),t("shadow.type",(function(t){J.now.shadow.on&&(e._updateMaterials({shadowmapType:t.value},!0),e._needRender=!0)})),t("shadow.radius",(function(t){for(var r=0;r<e._gfx.scene.children.length;r++)void 0!==e._gfx.scene.children[r].shadow&&(e._gfx.scene.children[r].shadow.radius=t.value,e._needRender=!0)})),t("fps",(function(){e._fps.show(J.now.fps)})),t(["fog","fogNearFactor","fogFarFactor"],(function(){e._updateFog(),e._needRender=!0})),t("fogAlpha",(function(){var t=J.now.fogAlpha;(t<0||t>1)&&e.logger.warn("fogAlpha must belong range [0,1]"),e._fogAlphaChanged(),e._needRender=!0})),t("autoResolution",(function(t){t.value&&!e._gfxScore&&e.logger.warn("Benchmarks are missed, autoresolution will not work! Autoresolution should be set during miew startup.")})),t("stereo",(function(){e._embedWebXR("WEBVR"===J.now.stereo),e._needRender=!0})),t(["transparency","palette"],(function(){e.rebuildAll()})),t("resolution",(function(){e.rebuildAll();var t=e._getVolumeVisual();t&&(t.getMesh().material.updateDefines(),e._needRender=!0)})),t(["axes","fxaa","ao","outline.on","outline.color","outline.threshold","outline.thickness"],(function(){e._needRender=!0}))}},{key:"set",value:function(e,t){J.set(e,t)}},{key:"select",value:function(e,t){var r=this._getComplexVisual();if(r){var i=e;(0,n.isString)(e)&&(i=au.parse(e).selector),r.select(i,t),this._lastPick=null,this._updateInfoPanel(),this._needRender=!0}}},{key:"view",value:function(e){var t,r,n,o=this,a=this._gfx.pivot,s=[];return void 0===e?(t=a.position,r=o._objectControls.getScale()/J.now.radiusToFit,(n=new i.USm).setFromQuaternion(o._objectControls.getOrientation(),"ZXY"),s=[t.x,t.y,t.z,r,n.x,n.y,n.z],"1"+$.arrayToBase64(s,Float32Array)):(function(){40===e.length&&(e="0".concat(e));var t=e[0];if(s=$.arrayFromBase64(e.substr(1),Float32Array),"1"!==t){if("0"!==t)return void o.logger.warn("Encoded view version mismatch, stored as ".concat(t," vs ").concat("1"," expected"));s[3]/=8}var r=o._interpolator,n=r.createView();n.position.copy(a.position),n.scale=o._objectControls.getScale(),n.orientation.copy(o._objectControls.getOrientation());var l=r.createView();l.position.set(s[0],s[1],s[2]),o._getComplexVisual()&&l.position.sub(o._getComplexVisual().position),l.scale=s[3],l.orientation.setFromEuler(new i.USm(s[4],s[5],s[6],"ZXY")),r.setup(n,l)}(),e)}},{key:"_updateView",value:function(){var e=this,t=this._gfx.pivot,r=this._interpolator;if(r.wasStarted()||r.start(),r.isMoving()){var n=r.getCurrentView();if(n.success){var i=n.view;t.position.copy(i.position),e._objectControls.setScale(i.scale*J.now.radiusToFit),e._objectControls.setOrientation(i.orientation),this.dispatchEvent({type:"transform"}),e._needRender=!0}}}},{key:"translate",value:function(e,t,r){this._objectControls.translatePivot(e,t,r),this.dispatchEvent({type:"transform"}),this._needRender=!0}},{key:"rotate",value:function(e,t,r){this._objectControls.rotate((new i._fP).setFromEuler(new i.USm(e,t,r,"XYZ"))),this.dispatchEvent({type:"transform"}),this._needRender=!0}},{key:"scale",value:function(e){if(e<=0)throw new RangeError("Scale should be greater than zero");this._objectControls.scale(e),this.dispatchEvent({type:"transform"}),this._needRender=!0}},{key:"center",value:function(e){if(void 0===e)return this.setPivotSubset(),void(this._needRender=!0);if(void 0!==e.obj&&("atom"in e.obj||"residue"in e.obj))return"atom"in e.obj?this.setPivotAtom(e.obj.atom):this.setPivotResidue(e.obj.residue),void(this._needRender=!0);if(void 0===e.obj&&""!==e){var t=au.parse(e);if(void 0===t.error)return this.setPivotSubset(t),void(this._needRender=!0)}this.resetPivot(),this._needRender=!0}},{key:"within",value:function(e,t){var r=this._getComplexVisual();if(!r)return au.None();e instanceof String&&(e=au.parse(e));var n=r.within(e,t);return n&&(r.rebuildSelectionGeometry(),this._needRender=!0),n}},{key:"projected",value:function(e,t){var r=this._getComplexVisual(t);if(!r)return!1;var n=r.getComplex().getAtomByFullname(e);if(null===n)return!1;var i=n.position.clone();return this._gfx.pivot.updateMatrixWorldRecursive(),this._gfx.camera.updateMatrixWorldRecursive(),this._gfx.pivot.localToWorld(i),i.project(this._gfx.camera),{x:.5*(i.x+1)*this._gfx.width,y:.5*(1-i.y)*this._gfx.height}}},{key:"dssp",value:function(e){var t=this._getComplexVisual(e);t&&(t.getComplex().dssp(),t._reprList.forEach((function(e){"CA"!==e.mode.id&&"SS"!==e.colorer.id||(e.needsRebuild=!0)})))}},{key:"exportCML",value:function(){var e=this,t=e._getComplexVisual(),r=t?t.getComplex():null;return r&&r.originalCML?(function(t){var r=function(e){var t=new i.Pa4,r=new i.Pa4,n=new i.Pa4;e.extractBasis(t,r,n),t.normalize(),r.normalize(),n.normalize();var o=new i.yGw;return o.identity(),o.makeBasis(t,r,n),o}(e._gfx.root.matrixWorld),n=new i.Ltg(0,0,0,0),o=new i.Ltg(0,0,0,0),a=null,s=null;t.forEachAtom((function(e){e.xmlNodeRef&&e.xmlNodeRef.xmlNode&&(a=e.xmlNodeRef.xmlNode,s=e.position,n.set(s.x,s.y,s.z,1),n.applyMatrix4(r),a.setAttribute("x3",n.x.toString()),a.setAttribute("y3",n.y.toString()),a.setAttribute("z3",n.z.toString()),a.removeAttribute("x2"),a.removeAttribute("y2"))})),t.forEachSGroup((function(e){if(e.xmlNodeRef&&e.xmlNodeRef.xmlNode){a=e.xmlNodeRef.xmlNode,s=e.getPosition(),n.set(s.x,s.y,s.z,1);var t=e.getCentralPoint();null===t?n.applyMatrix4(r):(o.set(t.x,t.y,t.z,0),n.add(o),n.applyMatrix4(r),o.set(t.x,t.y,t.z,1),o.applyMatrix4(r),n.sub(o)),a.setAttribute("x",n.x.toString()),a.setAttribute("y",n.y.toString()),a.setAttribute("z",n.z.toString())}}))}(r),(new XMLSerializer).serializeToString(r.originalCML)):null}},{key:"motm",value:function(){J.set({fogColorEnable:!0,fogColor:0,outline:{on:!0,threshold:.01},bg:{color:16777215}}),this._forEachComplexVisual((function(e){for(var t=[],r=e.getComplex(),n=oa.get(J.now.palette),i=0;i<r.getChainCount();i++){var o=r._chains[i]._name,a=n.getChainColor(o);t[i]={selector:"chain ".concat(o),mode:"VW",colorer:["CB",{color:a,factor:.9}],material:"FL"}}e.resetReps(t)}))}}]),s}(N);(0,n.assign)(Ru,{VERSION:Ru.VERSION,registeredPlugins:[],chem:pr,io:Tc,modes:Uo,colorers:xa,materials:wa,palettes:oa,options:Se,settings:J,utils:$,gfx:{Representation:Na}});var Cu=function(){var e=function(e,t,r,n){for(r=r||{},n=e.length;n--;r[e[n]]=t);return r},t=[1,60],r=[1,62],n=[1,63],i=[1,65],o=[1,66],a=[1,67],s=[1,68],l=[1,69],c=[1,80],u=[1,72],h=[1,73],f=[1,74],d=[1,75],p=[1,99],m=[1,76],v=[1,100],y=[1,79],_=[1,51],g=[1,81],x=[1,82],b=[1,84],w=[1,83],S=[1,85],R=[1,96],C=[1,97],A=[1,98],E=[1,86],k=[1,87],P=[1,64],T=[1,70],M=[1,71],N=[1,77],I=[1,78],O=[1,53],L=[1,54],B=[1,55],D=[1,61],z=[1,88],F=[1,89],V=[1,90],U=[1,91],G=[1,92],j=[1,93],H=[1,94],W=[1,95],Y=[1,101],X=[1,102],q=[1,103],$=[1,104],Z=[1,105],K=[1,56],Q=[1,57],J=[1,58],ee=[1,59],te=[1,115],re=[1,111],ne=[1,114],ie=[1,112],oe=[1,113],ae=[1,118],se=[1,117],le=[1,134],ce=[1,149],ue=[1,150],he=[1,157],fe=[5,6,7,9,13,14,15,17,18,19,20,23,25,26,27,30,33,34,35,37,38,41,43,45,46,49,52,54,55,56,58,59,62,64,65,66,70,72,74,77,78,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,101],de=[5,6,7,9,13,14,15,17,18,19,20,23,25,26,27,30,33,34,35,37,38,41,43,45,46,49,52,54,55,56,58,59,62,64,65,66,70,71,72,74,77,78,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,101],pe=[5,6,7,9,13,15,17,18,19,20,23,25,26,27,30,33,34,37,38,41,43,45,46,49,52,54,55,56,58,59,62,64,65,66,70,72,82,83,84,85,86,87,88,89,90,91,92,93,94,95],me=[5,70,72],ve=[5,74],ye=[71,101],_e={trace:function(){},yy:{},symbols_:{error:2,Program:3,Command:4,EOF:5,RESET:6,BUILD:7,ALL:8,HELP:9,Path:10,MOTM:11,OneArgCommand:12,GET:13,STRING:14,SET:15,Value:16,SET_SAVE:17,SET_RESTORE:18,SET_RESET:19,PRESET:20,AddRepresentation:21,EditRepresentation:22,REMOVE:23,RepresentationReference:24,HIDE:25,SHOW:26,LIST:27,EXPAND_KEY:28,SELECTOR_KEY:29,SELECT:30,AS:31,WordAll:32,SELECTOR:33,WITHIN:34,NUMBER:35,OF:36,MATERIAL:37,IDENTIFIER:38,ModeCMD:39,ColorCMD:40,VIEW:41,BASE_64:42,UNIT:43,DSSP:44,SCALE:45,ROTATE:46,AxesList:47,TRANSLATE:48,CENTER:49,GetURLBranch:50,Screenshot:51,LINE:52,ArgList:53,LISTOBJ:54,REMOVEOBJ:55,URL:56,VIEW_KEY:57,SCREENSHOT:58,LOAD:59,Url:60,FILE_KEY:61,ADD:62,Description:63,REP:64,MODE:65,COLOR:66,Descriptor:67,RepresentationOwnProperty:68,RepresentationOwnPropertyOpts:69,DESC_KEY:70,"=":71,DESC_KEY_OPTS:72,AxesArg:73,DESC_KEY_AXES:74,Arg:75,PathWoDescKey:76,HEX:77,BOOL:78,Word:79,CommandSetWoDESC_KEY:80,DescKeys:81,CLEAR:82,FILE_LIST:83,FILE_REGISTER:84,FILE_DELETE:85,PRESET_ADD:86,PRESET_DELETE:87,PRESET_UPDATE:88,PRESET_RENAME:89,PRESET_OPEN:90,CREATE_SCENARIO:91,RESET_SCENARIO:92,DELETE_SCENARIO:93,ADD_SCENARIO_ITEM:94,LIST_SCENARIO:95,PDB_KEY:96,DELAY_KEY:97,PRST_KEY:98,DESCRIPTION_KEY:99,CommandSet:100,".":101,PresetPath:102,"/":103,HexOrNumber:104,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",6:"RESET",7:"BUILD",8:"ALL",9:"HELP",11:"MOTM",13:"GET",14:"STRING",15:"SET",17:"SET_SAVE",18:"SET_RESTORE",19:"SET_RESET",20:"PRESET",23:"REMOVE",25:"HIDE",26:"SHOW",27:"LIST",28:"EXPAND_KEY",29:"SELECTOR_KEY",30:"SELECT",31:"AS",33:"SELECTOR",34:"WITHIN",35:"NUMBER",36:"OF",37:"MATERIAL",38:"IDENTIFIER",41:"VIEW",42:"BASE_64",43:"UNIT",44:"DSSP",45:"SCALE",46:"ROTATE",48:"TRANSLATE",49:"CENTER",52:"LINE",54:"LISTOBJ",55:"REMOVEOBJ",56:"URL",57:"VIEW_KEY",58:"SCREENSHOT",59:"LOAD",61:"FILE_KEY",62:"ADD",64:"REP",65:"MODE",66:"COLOR",70:"DESC_KEY",71:"=",72:"DESC_KEY_OPTS",74:"DESC_KEY_AXES",77:"HEX",78:"BOOL",82:"CLEAR",83:"FILE_LIST",84:"FILE_REGISTER",85:"FILE_DELETE",86:"PRESET_ADD",87:"PRESET_DELETE",88:"PRESET_UPDATE",89:"PRESET_RENAME",90:"PRESET_OPEN",91:"CREATE_SCENARIO",92:"RESET_SCENARIO",93:"DELETE_SCENARIO",94:"ADD_SCENARIO_ITEM",95:"LIST_SCENARIO",96:"PDB_KEY",97:"DELAY_KEY",98:"PRST_KEY",99:"DESCRIPTION_KEY",101:".",103:"/"},productions_:[0,[3,2],[3,1],[4,1],[4,1],[4,2],[4,1],[4,2],[4,1],[4,1],[4,2],[4,2],[4,3],[4,3],[4,1],[4,1],[4,1],[4,1],[4,2],[4,1],[4,1],[4,2],[4,2],[4,2],[4,2],[4,1],[4,2],[4,2],[4,2],[4,4],[4,2],[4,6],[4,2],[4,1],[4,1],[4,1],[4,2],[4,2],[4,1],[4,2],[4,1],[4,2],[4,2],[4,2],[4,1],[4,2],[4,1],[4,1],[4,3],[4,3],[4,4],[4,4],[4,1],[4,2],[50,1],[50,2],[50,2],[50,3],[50,3],[51,1],[51,2],[51,3],[12,2],[12,2],[12,2],[21,1],[21,2],[21,2],[21,3],[22,2],[22,3],[39,2],[39,3],[40,2],[40,3],[24,1],[24,1],[63,1],[63,2],[63,3],[63,4],[67,1],[67,1],[67,2],[68,3],[69,3],[47,1],[47,2],[73,2],[53,1],[53,2],[75,3],[16,1],[16,1],[16,1],[16,1],[16,1],[79,1],[79,1],[32,1],[32,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[81,1],[81,1],[81,1],[81,1],[81,1],[81,1],[81,1],[100,1],[100,1],[76,1],[76,3],[76,3],[10,1],[10,1],[10,3],[10,3],[10,3],[60,1],[102,1],[102,3],[104,1],[104,1]],performAction:function(e,t,r,n,i,o,a){var s=o.length-1;switch(i){case 1:return o[s-1];case 3:this.$=n.miew.reset(!1),n.ClearContext(),n.miew.resetReps("empty");break;case 4:this.$=n.miew.rebuild();break;case 5:this.$=n.miew.rebuildAll(),n.miew.rebuild();break;case 6:this.$=n.echo(n.utils.help().toString());break;case 7:this.$=n.echo(n.utils.help(o[s]).toString());break;case 8:this.$=n.miew.motm();break;case 10:case 11:this.$=n.utils.propagateProp(o[s]),n.echo(n.miew.get(o[s]).toString());break;case 12:case 13:this.$=n.miew.set(o[s-1],n.utils.propagateProp(o[s-1],o[s]));break;case 14:this.$=n.miew.saveSettings();break;case 15:this.$=n.miew.restoreSettings();break;case 16:this.$=n.miew.resetSettings();break;case 17:this.$=n.miew.resetReps();break;case 18:this.$=n.miew.applyPreset(o[s]);break;case 21:this.$=n.miew.repRemove(o[s]),n.representations.remove(o[s]);break;case 22:this.$=n.miew.repHide(o[s]);break;case 23:this.$=n.miew.repHide(o[s],!1);break;case 24:this.$=n.echo(n.utils.listRep(n.miew,n.representations,o[s],"-e"));break;case 25:this.$=n.echo(n.utils.list(n.miew,n.representations));break;case 26:this.$=n.echo(n.utils.list(n.miew,n.representations,o[s]));break;case 27:this.$=n.echo(n.utils.listSelector(n.miew,n.Context));break;case 28:this.$=n.miew.select(n.utils.checkArg(o[s-1].toLowerCase(),o[s],!0));break;case 29:this.$=n.Context[o[s].toLowerCase()]=n.utils.checkArg(o[s-3].toLowerCase(),o[s-2],!0),n.miew.select(n.Context[o[s].toLowerCase()]);break;case 30:this.$=n.miew.rep(n.miew.repCurrent(),{selector:n.utils.checkArg(o[s-1].toLowerCase(),o[s])});break;case 31:this.$=n.Context[o[s].toLowerCase()]=n.miew.within(n.utils.checkArg("select",o[s-2],!0),Number(o[s-4]));break;case 32:this.$=n.miew.rep(n.miew.repCurrent(),{material:n.utils.checkArg(o[s-1].toLowerCase(),o[s].toUpperCase())});break;case 35:this.$=n.echo(n.miew.view());break;case 36:case 37:this.$=n.miew.view(o[s]);break;case 38:this.$=n.echo(n.miew.changeUnit());break;case 39:this.$=n.echo(n.miew.changeUnit(o[s]));break;case 40:this.$=n.miew.dssp();break;case 41:this.$=n.miew.scale(o[s]);break;case 42:for(var l=0,c=o[s].length;l<c;l++)n.miew.rotate(o[s][l].x*Math.PI/180,o[s][l].y*Math.PI/180,o[s][l].z*Math.PI/180);break;case 43:for(l=0,c=o[s].length;l<c;l++)n.miew.translate(o[s][l].x||0,o[s][l].y||0,o[s][l].z||0);break;case 44:this.$=n.miew.center();break;case 45:this.$=n.miew.center(o[s]);break;case 48:case 49:this.$=n.miew.addObject({type:"line",params:[o[s-1],o[s]]},!0);break;case 50:case 51:this.$=n.miew.addObject({type:"line",params:[o[s-2],o[s-1]],opts:o[s].toJSO(n.utils,"objects","line")},!0);break;case 52:this.$=n.echo(n.utils.listObjs(n.miew));break;case 53:this.$=n.miew.removeObject(o[s]);break;case 54:this.$=n.echo(n.miew.getURL({view:!1,settings:!1}));break;case 55:this.$=n.echo(n.miew.getURL({view:!1,settings:!0}));break;case 56:this.$=n.echo(n.miew.getURL({view:!0,settings:!1}));break;case 57:case 58:this.$=n.echo(n.miew.getURL({view:!0,settings:!0}));break;case 59:this.$=n.miew.screenshotSave();break;case 60:this.$=n.miew.screenshotSave("",Number(o[s]));break;case 61:this.$=n.miew.screenshotSave("",Number(o[s-1]),Number(o[s]));break;case 62:case 63:case 64:this.$=n.utils.load(n.miew,o[s]),n.representations.clear();break;case 65:this.$=n.echo(n.representations.add(n.miew.repAdd()));break;case 66:this.$=n.echo(n.representations.add(o[s],n.miew.repAdd()));break;case 67:this.$=n.echo(n.representations.add(n.miew.repAdd(o[s])));break;case 68:this.$=n.echo(n.representations.add(o[s-1],n.miew.repAdd(o[s])));break;case 69:this.$=n.miew.rep(o[s]),n.miew.repCurrent(o[s]);break;case 70:this.$=n.miew.rep(o[s-1],o[s]),n.miew.repCurrent(o[s-1]);break;case 71:this.$=n.miew.rep(n.miew.repCurrent(),{mode:n.utils.checkArg(o[s-1].toLowerCase(),o[s].toUpperCase())});break;case 72:this.$=n.miew.rep(n.miew.repCurrent(),{mode:new Array(n.utils.checkArg(o[s-2].toLowerCase(),o[s-1].toUpperCase()),o[s].toJSO(n.utils,o[s-2],o[s-1].toUpperCase()))});break;case 73:this.$=n.miew.rep(n.miew.repCurrent(),{colorer:n.utils.checkArg(o[s-1].toLowerCase(),o[s].toUpperCase())});break;case 74:this.$=n.miew.rep(n.miew.repCurrent(),{colorer:new Array(n.utils.checkArg(o[s-2].toLowerCase(),o[s-1].toUpperCase()),o[s].toJSO(n.utils,o[s-2],o[s-1].toUpperCase()))});break;case 75:this.$=Number(n.representations.get(o[s]));break;case 76:case 92:this.$=Number(o[s]);break;case 77:this.$=o[s];break;case 78:this.$=n.assign(o[s-1],o[s]);break;case 79:this.$=n.assign(o[s-2],o[s-1],o[s]);break;case 80:this.$=n.assign(o[s-3],o[s-2],o[s-1],o[s]);break;case 81:case 82:this.$=n.CreateObjectPair(o[s].key,o[s].val);break;case 83:this.$=n.CreateObjectPair(o[s-1].key,new Array(o[s-1].val,o[s].toJSO(n.utils,o[s-1].key,o[s-1].val)));break;case 84:case 85:this.$=Object.create({key:n.keyRemap(o[s-2]),val:n.utils.checkArg(o[s-2],o[s])});break;case 86:this.$=[o[s]];break;case 87:this.$=o[s-1].concat(o[s]);break;case 88:this.$=n.CreateObjectPair(o[s-1].toLowerCase(),Number(o[s]));break;case 89:this.$=new n.ArgList(o[s]);break;case 90:this.$=o[s-1].append(o[s]);break;case 91:this.$=new n.Arg(o[s-2],o[s]);break;case 93:this.$=parseInt(o[s]);break;case 94:this.$=JSON.parse(o[s]);break;case 95:case 96:this.$=String(o[s]);break;case 157:case 158:case 161:case 162:case 163:this.$=o[s-2]+o[s-1]+o[s];break;case 166:this.$=o[s-2]=o[s-2]+o[s-1]+o[s]}},table:[{3:1,4:2,5:[1,3],6:[1,4],7:[1,5],9:[1,6],11:[1,7],12:8,13:[1,9],15:[1,10],17:[1,11],18:[1,12],19:[1,13],20:[1,14],21:15,22:16,23:[1,17],25:[1,18],26:[1,19],27:[1,20],30:[1,21],33:[1,22],34:[1,23],37:[1,24],39:25,40:26,41:[1,27],43:[1,28],44:[1,29],45:[1,30],46:[1,31],48:[1,32],49:[1,33],50:34,51:35,52:[1,36],54:[1,37],55:[1,38],56:[1,44],58:[1,45],59:[1,39],62:[1,40],64:[1,41],65:[1,42],66:[1,43]},{1:[3]},{5:[1,46]},{1:[2,2]},{5:[2,3]},{5:[2,4],8:[1,47]},{5:[2,6],6:t,7:r,9:n,10:48,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,70:O,72:L,74:B,79:49,80:52,81:50,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z,96:K,97:Q,98:J,99:ee},{5:[2,8]},{5:[2,9]},{6:t,7:r,9:n,10:106,13:i,14:[1,107],15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,70:O,72:L,74:B,79:49,80:52,81:50,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z,96:K,97:Q,98:J,99:ee},{6:t,7:r,9:n,10:108,13:i,14:[1,109],15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,70:O,72:L,74:B,79:49,80:52,81:50,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z,96:K,97:Q,98:J,99:ee},{5:[2,14]},{5:[2,15]},{5:[2,16]},{5:[2,17],14:te,16:110,35:re,38:ne,77:ie,78:oe},{5:[2,19]},{5:[2,20]},{24:116,35:ae,38:se},{24:119,35:ae,38:se},{24:120,35:ae,38:se},{5:[2,25],24:121,28:[1,122],29:[1,123],35:ae,38:se},{14:[1,124]},{14:[1,125]},{35:[1,126]},{38:[1,127]},{5:[2,33]},{5:[2,34]},{5:[2,35],14:[1,128],42:[1,129]},{5:[2,38],35:[1,130]},{5:[2,40]},{35:[1,131]},{47:132,73:133,74:le},{47:135,73:133,74:le},{5:[2,44],14:[1,136]},{5:[2,46]},{5:[2,47]},{6:t,7:r,9:n,10:138,13:i,14:[1,137],15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,70:O,72:L,74:B,79:49,80:52,81:50,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z,96:K,97:Q,98:J,99:ee},{5:[2,52]},{35:[1,139]},{14:[1,143],38:[1,141],60:140,61:[1,142]},{5:[2,65],38:[1,144],63:145,67:146,68:147,69:148,70:ce,72:ue},{24:151,35:ae,38:se},{38:[1,152]},{38:[1,153]},{5:[2,54],29:[1,154],57:[1,155]},{5:[2,59],35:[1,156]},{1:[2,1]},{5:[2,5]},{5:[2,7],101:he},e(fe,[2,159]),e(fe,[2,160]),e(de,[2,97]),e(de,[2,98]),e(fe,[2,147]),e(fe,[2,148]),e(fe,[2,149]),e(fe,[2,150]),e(fe,[2,151]),e(fe,[2,152]),e(fe,[2,153]),e(de,[2,101]),e(de,[2,102]),e(de,[2,103]),e(de,[2,104]),e(de,[2,105]),e(de,[2,106]),e(de,[2,107]),e(de,[2,108]),e(de,[2,109]),e(de,[2,110]),e(de,[2,111]),e(de,[2,112]),e(de,[2,113]),e(de,[2,114]),e(de,[2,115]),e(de,[2,116]),e(de,[2,117]),e(de,[2,118]),e(de,[2,119]),e(de,[2,120]),e(de,[2,121]),e(de,[2,122]),e(de,[2,123]),e(de,[2,124]),e(de,[2,125]),e(de,[2,126]),e(de,[2,127]),e(de,[2,128]),e(de,[2,129]),e(de,[2,130]),e(de,[2,131]),e(de,[2,132]),e(de,[2,133]),e(de,[2,134]),e(de,[2,135]),e(de,[2,136]),e(de,[2,137]),e(de,[2,138]),e(de,[2,139]),e(de,[2,140]),e(de,[2,141]),e(de,[2,142]),e(de,[2,143]),e(de,[2,144]),e(de,[2,145]),e(de,[2,146]),{5:[2,10],101:he},{5:[2,11]},{14:te,16:158,35:re,38:ne,77:ie,78:oe,101:he},{14:te,16:159,35:re,38:ne,77:ie,78:oe},{5:[2,18]},e(pe,[2,92]),e(pe,[2,93]),e(pe,[2,94]),e(pe,[2,95]),e(pe,[2,96]),{5:[2,21]},e(me,[2,75]),e(me,[2,76]),{5:[2,22]},{5:[2,23]},{5:[2,24]},{5:[2,26]},{5:[2,27]},{5:[2,28],31:[1,160]},{5:[2,30]},{36:[1,161]},{5:[2,32]},{5:[2,36]},{5:[2,37]},{5:[2,39]},{5:[2,41]},{5:[2,42],73:162,74:le},e(ve,[2,86]),{35:[1,163]},{5:[2,43],73:162,74:le},{5:[2,45]},{14:[1,164]},{6:t,7:r,9:n,10:165,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,70:O,72:L,74:B,79:49,80:52,81:50,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z,96:K,97:Q,98:J,99:ee,101:he},{5:[2,53]},{5:[2,62]},{5:[2,63]},{5:[2,64]},{5:[2,164]},{5:[2,66],63:166,67:146,68:147,69:148,70:ce,72:ue},{5:[2,67]},{5:[2,77],67:167,68:147,69:148,70:ce,72:ue},e(me,[2,81]),e(me,[2,82],{80:52,53:168,75:169,76:170,79:171,6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z}),{71:[1,172]},{71:[1,173]},{5:[2,69],63:174,67:146,68:147,69:148,70:ce,72:ue},{5:[2,71],6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,53:175,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,75:169,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z},{5:[2,73],6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,53:176,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,75:169,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z},{5:[2,55],57:[1,177]},{5:[2,56],29:[1,178]},{5:[2,60],35:[1,179]},{6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,35:[1,181],37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,70:O,72:L,74:B,79:180,80:52,81:182,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z,96:K,97:Q,98:J,99:ee},{5:[2,12]},{5:[2,13]},{6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,32:183,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,70:O,72:L,74:B,79:184,80:52,81:185,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z,96:K,97:Q,98:J,99:ee},{14:[1,186]},e(ve,[2,87]),e(ve,[2,88]),{5:[2,48],6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,53:187,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,75:169,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z},{5:[2,49],6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,53:188,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,75:169,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z,101:he},{5:[2,68]},{5:[2,78],67:189,68:147,69:148,70:ce,72:ue},e(me,[2,83],{80:52,76:170,79:171,75:190,6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z}),e(pe,[2,89]),{71:[1,191],101:[1,192]},e(ye,[2,156]),{14:te,16:193,35:re,38:ne,77:ie,78:oe},{14:te,16:194,35:re,38:ne,77:ie,78:oe},{5:[2,70]},{5:[2,72],6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,75:190,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z},{5:[2,74],6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,75:190,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z},{5:[2,57]},{5:[2,58]},{5:[2,61]},e(fe,[2,161]),e(fe,[2,162]),e(fe,[2,163]),{5:[2,29]},{5:[2,99]},{5:[2,100]},{31:[1,195]},{5:[2,50],6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,75:190,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z},{5:[2,51],6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,75:190,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z},{5:[2,79],67:196,68:147,69:148,70:ce,72:ue},e(pe,[2,90]),{14:te,16:197,35:re,38:ne,77:ie,78:oe},{6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,35:[1,199],37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,79:198,80:52,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z},e(me,[2,84]),e(pe,[2,85]),{6:t,7:r,9:n,13:i,15:o,17:a,18:s,19:l,20:c,23:u,25:h,26:f,27:d,30:p,32:200,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:A,56:E,58:k,59:P,62:T,64:M,65:N,66:I,70:O,72:L,74:B,79:184,80:52,81:185,82:D,83:z,84:F,85:V,86:U,87:G,88:j,89:H,90:W,91:Y,92:X,93:q,94:$,95:Z,96:K,97:Q,98:J,99:ee},{5:[2,80]},e(pe,[2,91]),e(ye,[2,157]),e(ye,[2,158]),{5:[2,31]}],defaultActions:{3:[2,2],4:[2,3],7:[2,8],8:[2,9],11:[2,14],12:[2,15],13:[2,16],15:[2,19],16:[2,20],25:[2,33],26:[2,34],29:[2,40],34:[2,46],35:[2,47],37:[2,52],46:[2,1],47:[2,5],107:[2,11],110:[2,18],116:[2,21],119:[2,22],120:[2,23],121:[2,24],122:[2,26],123:[2,27],125:[2,30],127:[2,32],128:[2,36],129:[2,37],130:[2,39],131:[2,41],136:[2,45],139:[2,53],140:[2,62],141:[2,63],142:[2,64],143:[2,164],145:[2,67],158:[2,12],159:[2,13],166:[2,68],174:[2,70],177:[2,57],178:[2,58],179:[2,61],183:[2,29],184:[2,99],185:[2,100],196:[2,80],200:[2,31]},parseError:function(e,t){if(!t.recoverable){var r=new Error(e);throw r.hash=t,r}this.trace(e)},parse:function(e){var t=[0],r=[],n=[null],i=[],o=this.table,a="",s=0,l=0,c=i.slice.call(arguments,1),u=Object.create(this.lexer),h={yy:{}};for(var f in this.yy)Object.prototype.hasOwnProperty.call(this.yy,f)&&(h.yy[f]=this.yy[f]);u.setInput(e,h.yy),h.yy.lexer=u,h.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var d=u.yylloc;i.push(d);var p=u.options&&u.options.ranges;"function"==typeof h.yy.parseError?this.parseError=h.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var m,v,y,_,g,x,b,w,S,R={};;){if(v=t[t.length-1],this.defaultActions[v]?y=this.defaultActions[v]:(null==m&&(S=void 0,"number"!=typeof(S=r.pop()||u.lex()||1)&&(S instanceof Array&&(S=(r=S).pop()),S=this.symbols_[S]||S),m=S),y=o[v]&&o[v][m]),void 0===y||!y.length||!y[0]){var C;for(g in w=[],o[v])this.terminals_[g]&&g>2&&w.push("'"+this.terminals_[g]+"'");C=u.showPosition?"Parse error on line "+(s+1)+":\n"+u.showPosition()+"\nExpecting "+w.join(", ")+", got '"+(this.terminals_[m]||m)+"'":"Parse error on line "+(s+1)+": Unexpected "+(1==m?"end of input":"'"+(this.terminals_[m]||m)+"'"),this.parseError(C,{text:u.match,token:this.terminals_[m]||m,line:u.yylineno,loc:d,expected:w})}if(y[0]instanceof Array&&y.length>1)throw new Error("Parse Error: multiple actions possible at state: "+v+", token: "+m);switch(y[0]){case 1:t.push(m),n.push(u.yytext),i.push(u.yylloc),t.push(y[1]),m=null,l=u.yyleng,a=u.yytext,s=u.yylineno,d=u.yylloc;break;case 2:if(x=this.productions_[y[1]][1],R.$=n[n.length-x],R._$={first_line:i[i.length-(x||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(x||1)].first_column,last_column:i[i.length-1].last_column},p&&(R._$.range=[i[i.length-(x||1)].range[0],i[i.length-1].range[1]]),void 0!==(_=this.performAction.apply(R,[a,l,s,h.yy,y[1],n,i].concat(c))))return _;x&&(t=t.slice(0,-1*x*2),n=n.slice(0,-1*x),i=i.slice(0,-1*x)),t.push(this.productions_[y[1]][0]),n.push(R.$),i.push(R._$),b=o[t[t.length-2]][t[t.length-1]],t.push(b);break;case 3:return!0}}return!0}},ge=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;o<i.length;o++)if((r=this._input.match(this.rules[i[o]]))&&(!t||r[0].length>t[0].length)){if(t=r,n=o,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,i[o])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,i[n]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(e,t,r,n){switch(r){case 0:break;case 1:case 2:return"";case 3:return 42;case 4:return 35;case 5:return 77;case 6:case 7:return 78;case 8:return 8;case 9:return 6;case 10:return 82;case 11:return 7;case 12:return 9;case 13:return 59;case 14:return 13;case 15:return 15;case 16:return 17;case 17:return 18;case 18:return 19;case 19:return 20;case 20:return 11;case 21:return 62;case 22:return 64;case 23:return 23;case 24:return 25;case 25:return 26;case 26:return 27;case 27:return 30;case 28:return 34;case 29:return 33;case 30:return 65;case 31:return 66;case 32:return 37;case 33:return 41;case 34:return 43;case 35:return 52;case 36:return 54;case 37:return 55;case 38:return 46;case 39:return 48;case 40:return 45;case 41:return 49;case 42:return 56;case 43:return 58;case 44:return 44;case 45:return 83;case 46:return 84;case 47:return 85;case 48:return 86;case 49:return 87;case 50:return 88;case 51:return 89;case 52:return 90;case 53:return 91;case 54:return 92;case 55:return 93;case 56:return 94;case 57:return 95;case 58:case 59:return 70;case 60:case 61:return 72;case 62:case 63:case 64:return 74;case 65:return 31;case 66:return 36;case 67:return 96;case 68:return 97;case 69:return 98;case 70:return 99;case 71:return t.yytext=e.utils.unquoteString(t.yytext),14;case 72:return 38;case 73:return 5;case 74:return 101;case 75:return 103;case 76:return"\\";case 77:return 28;case 78:return 61;case 79:return 29;case 80:return 57;case 81:return 71}},rules:[/^(?:\s+)/i,/^(?:[#].*)/i,/^(?:\/\/.*)/i,/^(?:([_A-Z0-9\/\+]+==))/i,/^(?:-?[0-9]+(\.[0-9]+)?\b)/i,/^(?:0[xX][0-9A-F]+\b)/i,/^(?:false\b)/i,/^(?:true\b)/i,/^(?:all\b)/i,/^(?:reset\b)/i,/^(?:clear\b)/i,/^(?:build\b)/i,/^(?:help\b)/i,/^(?:load\b)/i,/^(?:get\b)/i,/^(?:set\b)/i,/^(?:set_save\b)/i,/^(?:set_restore\b)/i,/^(?:set_reset\b)/i,/^(?:preset\b)/i,/^(?:motm\b)/i,/^(?:add\b)/i,/^(?:rep\b)/i,/^(?:remove\b)/i,/^(?:hide\b)/i,/^(?:show\b)/i,/^(?:list\b)/i,/^(?:select\b)/i,/^(?:within\b)/i,/^(?:selector\b)/i,/^(?:mode\b)/i,/^(?:color\b)/i,/^(?:material\b)/i,/^(?:view\b)/i,/^(?:unit\b)/i,/^(?:line\b)/i,/^(?:listobj\b)/i,/^(?:removeobj\b)/i,/^(?:rotate\b)/i,/^(?:translate\b)/i,/^(?:scale\b)/i,/^(?:center\b)/i,/^(?:url\b)/i,/^(?:screenshot\b)/i,/^(?:dssp\b)/i,/^(?:file_list\b)/i,/^(?:file_register\b)/i,/^(?:file_delete\b)/i,/^(?:preset_add\b)/i,/^(?:preset_delete\b)/i,/^(?:preset_update\b)/i,/^(?:preset_rename\b)/i,/^(?:preset_open\b)/i,/^(?:create_scenario\b)/i,/^(?:reset_scenario\b)/i,/^(?:delete_scenario\b)/i,/^(?:add_scenario_item\b)/i,/^(?:list_scenario\b)/i,/^(?:s\b)/i,/^(?:mt\b)/i,/^(?:m\b)/i,/^(?:c\b)/i,/^(?:x\b)/i,/^(?:y\b)/i,/^(?:z\b)/i,/^(?:as\b)/i,/^(?:of\b)/i,/^(?:pdb\b)/i,/^(?:delay\b)/i,/^(?:prst\b)/i,/^(?:desc\b)/i,/^(?:((?:"(?:\\.|[^\\"])*"|'(?:\\.|[^\\'])*')))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:\.)/i,/^(?:\/)/i,/^(?:\\)/i,/^(?:-e\b)/i,/^(?:-f\b)/i,/^(?:-s\b)/i,/^(?:-v\b)/i,/^(?:=)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81],inclusive:!0}}};return e}();function xe(){this.yy={}}return _e.lexer=ge,xe.prototype=_e,_e.Parser=xe,new xe}(),Au={parser:Cu},Eu={$help:["Rendering mode shortcut"," BS - balls and sticks mode"," LN - lines mode"," LC - licorice mode"," VW - van der waals mode"," TR - trace mode"," TU - tube mode"," CA - cartoon mode"," SA - isosurface mode"," QS - quick surface mode"," SE - solvent excluded mode"," TX - text mode"],BS:{$help:[" Balls and sticks"," aromrad = <number> #aromatic radius"," atom = <number> #atom radius"," bond = <number> #bond radius"," multibond = <bool> #use multibond"," showarom = <bool> #show aromatic"," space = <number> #space value\n"]},CA:{$help:[" Cartoon"," arrow = <number> #arrow size"," depth = <number> #depth of surface"," heightSegmentsRatio = <number>"," radius = <number> #tube radius"," tension = <number> #"," width = <number> #secondary width\n"]},LN:{$help:[" Lines"," atom = <number> #atom radius"," chunkarom = <number>"," multibond = <bool> #use multibond"," showarom = <bool> #show aromatic"," offsarom = <number>\n"]},LC:{$help:[" Licorice"," aromrad = <number> #aromatic radius"," bond = <number> #bond radius"," multibond = <bool> #use multibond"," showarom = <bool> #show aromatic"," space = <number> #space value\n"]},VW:{$help:[" Van der Waals"," nothing\n"]},TR:{$help:[" Trace"," radius = <number> #tube radius\n"]},TU:{$help:[" Tube"," heightSegmentsRatio = <number>"," radius = <number> #tube radius"," tension = <number> \n"]},SA:{$help:[" Surface"," zClip = <bool> #clip z plane\n"]},QS:{$help:[" Quick surface"," isoValue = <number>"," scale = <number>"," wireframe = <bool>"," zClip = <bool> #clip z plane\n"]},SE:{$help:[" Solvent excluded surface"," zClip = <bool> #clip z plane\n"]},TX:{$help:[" Text mode",' template = <format string> string that can include "{{ id }}"'," it will be replaced by value, id can be one of next:"," serial, name, type, sequence, residue, chain, hetatm, water\n",' horizontalAlign = <string> {"left", "right", "center"}',' verticalAlign = <string> {"top", "bottom", "middle"}'," dx = <number> #offset along x"," dy = <number> #offset along y"," dz = <number> #offset along z"," fg = <string> #text color modificator"," could be keyword, named color or hex"," fg = <string> #back color modificator"," could be keyword, named color or hex"," showBg = <bool> #if set show background"," plate under text"]}},ku={$help:["Coloring mode shortcut"," EL - color by element"," CH - color by chain"," SQ - color by sequence"," RT - color by residue type"," SS - color by secondary structure"," UN - uniform"],UN:{$help:["Parameters of coloring modes customization"," Uniform"," color = <number|color> #RGB->HEX->dec\n"],color:{$help:Object.keys(oa.get(J.now.palette).namedColors).sort().join("\n")}}},Pu={$help:["Material shortcut"," DF - diffuse"," TR - transparent"," SF - soft plastic"," PL - glossy plastic"," ME - metal"," GL - glass"]},Tu={$help:["Short (packed) representation description as a set of variables"," s=<EXPRESSION>"," selector property"," m=<MODE_ID>[!<PARAMETER>:<VALUE>[,...]]"," render mode property"," c=<COLORER_ID>[!<PARAMETER>:<VALUE>[,...]]"," color mode property"," mt=<MATERIAL_ID>"," material property"],s:{$help:"Selection expression string as it is in menu->representations->selection"},m:Eu,c:ku,mt:Pu},Mu={$help:["Parameters of rendering modes customization: modes","Parameters of colorer customization: colorers","Autobuild: autobuild = (<number>|<bool>)"],modes:Eu,colorers:ku},Nu={$help:["help (<cmd name>| <path to property>)","You can get detailed information about command options",' using "help cmd.opt.opt.[...]"\n'," you can use one line comments"," everything started from (#|//) will be skipped"," Example: >build //some comment\n","List of available commands:"],reset:{$help:["Reload current object, delete all representations"," Nothing will work until load new object"]},load:{$help:["load (<PDBID>|<URL>|-f [<*.NC FILE URL STRING>])"," Load new pdb object from selected source"],PDBID:{$help:"pdb id in remote molecule database"},URL:{$help:"url to source file"},f:{$help:["open file system dialog to fetch local file","optionally you can determine trajectory file","via URL for *.top model"]}},clear:{$help:"No args. Clear terminal"},add:{$help:["add [<REP_NAME>] [<DESCRIPTION>]"," Add new item to representation set with"," default or <DESCRIPTION> params"],REP_NAME:{$help:"Identifier string [_,a-z,A-Z,0-9] can not start from digit"},DESCRIPTION:Tu},rep:{$help:["rep [<REP_NAME>|<REP_INDEX>] [<DESCRIPTION>]"," set current representation by name or index"," edit current representation by <DESCRIPTION>"],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"},DESCRIPTION:Tu},remove:{$help:["remove (<REP_NAME>|<REP_INDEX>)","Remove representation by name or index"],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"}},selector:{$help:["selector <EXPRESSION>"," set selector from EXPRESSION to current representation"],EXPRESSION:{$help:"Selection expression string as it is in menu->representations->selection"}},mode:{$help:["mode <MODE_ID> [<PARAMETER>=<VALUE>...]"," set rendering mode and apply parameters to current representation"],MODE_ID:Eu},color:{$help:["color <COLORER_ID> [<PARAMETER>=<VALUE>...]"," set colorer and apply parameters to current representation"],COLORER_ID:ku},material:{$help:["material <MATERIAL_ID>"," set material to current representation"],MATERIAL_ID:Pu},build:{$help:"build help str",add:{$help:"build.add",new:{$help:["add.new","add.new new line 1","add.new new line 2","add.new new line 3"]}},del:{$help:"build.del"}},list:{$help:["list [-e|-s|<REP_NAME>|<REP_INDEX>]","Print representations if no args print list of representations"," -e expand list and show all representations"," -s show all user-registered selectors"," <REP_NAME>|<REP_INDEX> show only current representation"]},hide:{$help:["hide (<REP_NAME>|<REP_INDEX>)","Hide representation referenced in args"]},show:{$help:["show (<REP_NAME>|<REP_INDEX>)","Show representation referenced in args"]},get:{$help:["get <PARAMETER>","Print <PARAMETER> value"," <PARAMETER> - path to option use get.PARAMETER to get more info"],PARAMETER:Mu},set:{$help:["set <PARAMETER> <VALUE>","Set <PARAMETER> with <VALUE>"," <PARAMETER> - path to option use set.PARAMETER to get more info"],PARAMETER:Mu},set_save:{$help:["set_save","Save current settings to cookie"]},set_restore:{$help:["set_restore","Load and apply settings from cookie"]},set_reset:{$help:["set_reset","Reset current settings to the defaults"]},preset:{$help:["preset [<PRESET>]","Reset current representation or set preset to <PRESET>"],PRESET:{$help:["default","wire","small","macro"]}},unit:{$help:["unit [<unit_id>]","Change current biological structure view. Zero <unit_id> value means asymmetric unit,","positive values set an assembly with corresponding number.","Being called with no parameters command prints current unit information."]},view:{$help:["view [<ENCODED_VIEW>]","Get current encoded view or set if ENCODED_VIEW placed as argument"],ENCODED_VIEW:{$help:["encoded view matrix string (binary code)"]}},rotate:{$help:["rotate (x|y|z) [<DEGREES>] [(x|y|z) [<DEGREES>]]...","Rotate scene"]},scale:{$help:["scale <SCALE>","Scale scene"]},select:{$help:["select <SELECTOR_STRING> [as <SELECTOR_NAME>]","Select atoms using selector defined in SELECTOR_STRING"," and if SELECTOR_NAME is defined register it in viewer"," you can use it later as a complex selector"]},within:{$help:["within <DISTANCE> of <SELECTOR_STRING> as <SELECTOR_NAME>","Build within named selector"," DISTANCE <number>"," SELECTOR_STRING <string(selection language)>"," SELECTOR_NAME <identifier>"]},url:{$help:["url [-s] [-v]","Report URL encoded scene"," if -s set that include settings in the URL"," if -v set that include view in the URL"]},screenshot:{$help:["screenshot [<WIDTH> [<HEIGHT>]]","Make a screenshot of the scene"," WIDTH <number> in pixels"," HEIGHT <number> in pixels, equal to WIDTH by default"]},line:{$help:["line <first_atom_path> <second_atom_path> [<PARAMETER>=<VALUE>]","Draw dashed line between two specified atoms"]},removeobj:{$help:["removeobj <id>","Remove scene object by its index. Indices could be obtained by <listobj> command"]},listobj:{$help:["listobj","Display the list of all existing scene objects"]}},Iu=Ru.chem.selectors,Ou=Ru.modes,Lu=Ru.colorers,Bu=Ru.materials,Du=Ru.palettes,zu=Ru.options,Fu=Ru.settings;var Vu,Uu=(Vu=new function(){},function(){return Vu}),Gu=function(){function e(){a(this,e),this.representationMap={},this.representationID={}}return l(e,[{key:"get",value:function(e){return this.representationMap[e]||this.representationID[e]||"<no name>"}},{key:"add",value:function(e,t){if(-1===e)return"Can not create representation: there is no data";if(void 0!==t){if(this.representationMap.hasOwnProperty(e))return"This name has already existed, registered without name";this.representationMap[e.toString()]=t,this.representationID[t]=e.toString()}return"Representation ".concat(e," successfully added")}},{key:"remove",value:function(e){e&&this.representationID.hasOwnProperty(e)&&(delete this.representationMap[this.representationID[e]],delete this.representationID[e]);var t=Object.keys(this.representationID).sort();for(var r in t)if(t.hasOwnProperty(r)){var n=t[r];n>e&&(this.representationID[n-1]=this.representationID[n],this.representationMap[this.representationID[n]]-=1,delete this.representationID[n])}}},{key:"clear",value:function(){this.representationMap={},this.representationID={}}}]),e}(),ju=new Gu;function Hu(e){var t={s:"selector",m:"mode",c:"colorer",mt:"material",mode:"modes",color:"colorers",colorer:"colorers",select:"selector",material:"materials",selector:"selector"}[e];return void 0===t?e:t}var Wu=function(){function e(){a(this,e)}return l(e,[{key:"list",value:function(e,t,r){var n="";if(e&&void 0!==t&&(void 0===r||"-e"===r))for(var i=e.repCount(),o=0;o<i;o++)n+=this.listRep(e,t,o,r);return n}},{key:"listRep",value:function(e,t,r,n){var i="",o=e.repGet(r);if(!o)return B.warn("Rep ".concat(r," does not exist!")),i;var a=r,s=t.get(a),l=o.mode,c=o.colorer,u=o.selectorString,h=o.materialPreset;return i+="#".concat(a," : ").concat(l.name).concat("<no name>"===s?"":", ".concat(s),"\n"),void 0!==n&&(i+=' selection : "'.concat(u,'"\n'),i+=" mode : (".concat(l.id,"), ").concat(l.name,"\n"),i+=" colorer : (".concat(c.id,"), ").concat(c.name,"\n"),i+=" material : (".concat(h.id,"), ").concat(h.name,"\n")),i}},{key:"listSelector",value:function(e,t){var r="";for(var n in t)t.hasOwnProperty(n)&&(r+="".concat(n,' : "').concat(t[n],'"\n'));return r}},{key:"listObjs",value:function(e){var t=e._objects;if(!t||!Array.isArray(t)||0===t.length)return"There are no objects on the scene";for(var r=[],n=0,i=t.length;n<i;++n)r[n]="".concat(n,": ").concat(t[n].toString());return r.join("\n")}},{key:"joinHelpStr",value:function(e){return e instanceof Array?e.join("\n"):e}},{key:"help",value:function(e){if((0,n.isUndefined)(e))return"".concat(this.joinHelpStr(Nu.$help),"\n").concat((0,n.slice)((0,n.sortBy)((0,n.keys)(Nu)),1).join(", "),"\n");var t=(0,n.get)(Nu,e);return(0,n.isUndefined)(t)?this.help():"".concat(this.joinHelpStr(t.$help),"\n")}},{key:"load",value:function(e,t){if(void 0!==e&&void 0!==t&&"-f"!==t){e.awaitWhileCMDisInProcess();var r=function(){return e.finishAwaitingCMDInProcess()};e.load(t).then(r,r)}}},{key:"checkArg",value:function(e,t,r){if(void 0!==e&&void 0!==t){if("selector"===Hu(e)){var n=Iu.parse(t);if(void 0!==n.error)throw{message:n.error};return void 0!==r&&r?n.selector:t}for(var i,o={colorers:Lu,modes:Ou,materials:Bu},a=e;a!==i;)a=Hu(i=a);if(void 0===o[a].get(t))throw{message:"".concat(t," is not existed in ").concat(a)};return t}return Uu}},{key:"propagateProp",value:function(e,t){if(void 0!==e){var r=zu.adapters[o((0,n.get)(Fu.defaults,e))];if(void 0===r)throw{message:"".concat(e," is not existed")};if((e.endsWith(".color")||e.endsWith(".baseColor")||e.endsWith(".EL.carbon"))&&"number"!=typeof t&&(t=Du.get(Fu.now.palette).getNamedColor(t)),e.endsWith(".fg")||e.endsWith(".bg"))if("number"!=typeof t){var i=Du.get(Fu.now.palette).getNamedColor(t,!0);void 0!==i&&(t="0x".concat(i.toString(16)))}else t="0x".concat(t.toString(16));if(e.endsWith(".template")&&(t=t.replace(/\\n/g,"\n")),void 0!==t&&r(t)!==t&&r(t)!==t>0)throw{message:"".concat(e,' must be a "').concat(o((0,n.get)(Fu.defaults,e)),'"')}}return t}},{key:"unquoteString",value:function(e){return $.unquoteString(e)}}]),e}(),Yu=new Wu;function Xu(e){if(e instanceof this.constructor)return e;this._values=e instanceof Array?e.slice(0):e?[e]:[]}Xu.prototype.append=function(e){var t=this._values;return t[t.length]=e,this},Xu.prototype.remove=function(e){var t=this._values,r=t.indexOf(e);return r>=0&&t.splice(r,1),this},Xu.prototype.toJSO=function(e,t,r){for(var i={},o=this._values,a=0,s=o.length;a<s;++a)(0,n.set)(i,o[a].id,e.propagateProp("".concat(Hu(t),".").concat(r,".").concat(o[a].id),o[a].val));return i};var qu=Object.create({});qu.Arg=function(e,t){this.id=e,this.val=t},qu.ArgList=Xu,qu.miew=null,qu.echo=null,qu.representations=ju,qu.utils=Yu,qu.assign=n.assign,qu.CreateObjectPair=function(e,t){var r={};return r[e]=t,r},qu.keyRemap=Hu,qu.Context=Iu.Context,qu.ClearContext=Iu.ClearContext,qu.NULL=Uu,qu.notimplemented=function(){return this.NULL},Ru.prototype.script=function(e,t,r){Au.parser.yy.miew=this,Au.parser.yy.echo=t,Au.parser.yy.error=r,void 0===this.cmdQueue&&(this.cmdQueue=[]),void 0===this.commandInAction&&(this.commandInAction=!1),this.cmdQueue=this.cmdQueue.concat(e.split("\n"))},Ru.prototype.awaitWhileCMDisInProcess=function(){this.commandInAction=!0},Ru.prototype.finishAwaitingCMDInProcess=function(){this.commandInAction=!1},Ru.prototype.isScriptingCommandAvailable=function(){return void 0!==this.commandInAction&&!this.commandInAction&&void 0!==this.cmdQueue&&this.cmdQueue.length>0},Ru.prototype.callNextCmd=function(){if(this.isScriptingCommandAvailable()){var e=this.cmdQueue.shift(),t={success:!1};try{Au.parser.parse(e),t.success=!0}catch(e){t.error=e.message,Au.parser.yy.error(t.error),this.finishAwaitingCMDInProcess()}return t}return""},Au.parser.yy=qu,Au.parser.yy.parseError=Au.parser.parseError}}]);
|