diff --git a/angular.json b/angular.json index 2c7dd7a..6ef4946 100644 --- a/angular.json +++ b/angular.json @@ -81,8 +81,8 @@ "budgets": [ { "type": "initial", - "maximumWarning": "500kb", - "maximumError": "1mb" + "maximumWarning": "1mb", + "maximumError": "5mb" }, { "type": "anyComponentStyle", diff --git a/docs/3rdpartylicenses.txt b/docs/3rdpartylicenses.txt new file mode 100644 index 0000000..5f9d817 --- /dev/null +++ b/docs/3rdpartylicenses.txt @@ -0,0 +1,372 @@ + +-------------------------------------------------------------------------------- +Package: xhr2 +License: "MIT" + +Copyright (c) 2013 Victor Costan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +-------------------------------------------------------------------------------- +Package: @angular/core +License: "MIT" + + +-------------------------------------------------------------------------------- +Package: rxjs +License: "Apache-2.0" + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +-------------------------------------------------------------------------------- +Package: tslib +License: "0BSD" + +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +-------------------------------------------------------------------------------- +Package: @angular/common +License: "MIT" + + +-------------------------------------------------------------------------------- +Package: @angular/platform-browser +License: "MIT" + + +-------------------------------------------------------------------------------- +Package: @angular/router +License: "MIT" + + +-------------------------------------------------------------------------------- +Package: molstar +License: "MIT" + +The MIT License + + Copyright (c) 2017 - now, Mol* contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +-------------------------------------------------------------------------------- +Package: immutable +License: "MIT" + +MIT License + +Copyright (c) 2014-present, Lee Byron and other contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +-------------------------------------------------------------------------------- +Package: immer +License: "MIT" + +MIT License + +Copyright (c) 2017 Michel Weststrate + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +-------------------------------------------------------------------------------- +Package: zone.js +License: "MIT" + +The MIT License + +Copyright (c) 2010-2023 Google LLC. https://angular.io/license + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------------------------------------------------------------------- diff --git a/docs/browser/assets/ngx-structure-viewer.png b/docs/browser/assets/ngx-structure-viewer.png new file mode 100644 index 0000000..af623ac Binary files /dev/null and b/docs/browser/assets/ngx-structure-viewer.png differ diff --git a/docs/browser/assets/ngx-structure-viewer.svg b/docs/browser/assets/ngx-structure-viewer.svg new file mode 100644 index 0000000..10ab1b0 --- /dev/null +++ b/docs/browser/assets/ngx-structure-viewer.svg @@ -0,0 +1,155 @@ + + + + + + + +* diff --git a/docs/browser/favicon.ico b/docs/browser/favicon.ico new file mode 100644 index 0000000..57614f9 Binary files /dev/null and b/docs/browser/favicon.ico differ diff --git a/docs/browser/index.html b/docs/browser/index.html new file mode 100644 index 0000000..8897ab4 --- /dev/null +++ b/docs/browser/index.html @@ -0,0 +1,13 @@ + + + + + DemoShowcase + + + + + + + + diff --git a/docs/browser/main-I5LT33BF.js b/docs/browser/main-I5LT33BF.js new file mode 100644 index 0000000..b7c726b --- /dev/null +++ b/docs/browser/main-I5LT33BF.js @@ -0,0 +1,5554 @@ +var vk=Object.defineProperty,fce=Object.defineProperties;var dce=Object.getOwnPropertyDescriptors;var pk=Object.getOwnPropertySymbols;var mce=Object.prototype.hasOwnProperty,pce=Object.prototype.propertyIsEnumerable;var hk=(e,t,r)=>t in e?vk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ar=(e,t)=>{for(var r in t||={})mce.call(t,r)&&hk(e,r,t[r]);if(pk)for(var r of pk(t))pce.call(t,r)&&hk(e,r,t[r]);return e},uo=(e,t)=>fce(e,dce(t));var hce=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),fi=(e,t)=>{for(var r in t)vk(e,r,{get:t[r],enumerable:!0})};var FD=(e,t,r)=>new Promise((n,a)=>{var i=u=>{try{s(r.next(u))}catch(c){a(c)}},o=u=>{try{s(r.throw(u))}catch(c){a(c)}},s=u=>u.done?n(u.value):Promise.resolve(u.value).then(i,o);s((r=r.apply(e,t)).next())});var B8=hce((dZe,R8)=>{"use strict";R8.exports=XMLHttpRequest});var gk=null;var LD=1;function qu(e){let t=gk;return gk=e,t}var yk={version:0,lastCleanEpoch:0,dirty:!1,producerNode:void 0,producerLastReadVersion:void 0,producerIndexOfThis:void 0,nextProducerIndex:0,liveConsumerNode:void 0,liveConsumerIndexOfThis:void 0,consumerAllowSignalWrites:!1,consumerIsAlwaysLive:!1,producerMustRecompute:()=>!1,producerRecomputeValue:()=>{},consumerMarkedDirty:()=>{},consumerOnSignalRead:()=>{}};function vce(e){if(!(UD(e)&&!e.dirty)&&!(!e.dirty&&e.lastCleanEpoch===LD)){if(!e.producerMustRecompute(e)&&!kD(e)){e.dirty=!1,e.lastCleanEpoch=LD;return}e.producerRecomputeValue(e),e.dirty=!1,e.lastCleanEpoch=LD}}function bk(e){return e&&(e.nextProducerIndex=0),qu(e)}function xk(e,t){if(qu(t),!(!e||e.producerNode===void 0||e.producerIndexOfThis===void 0||e.producerLastReadVersion===void 0)){if(UD(e))for(let r=e.nextProducerIndex;re.nextProducerIndex;)e.producerNode.pop(),e.producerLastReadVersion.pop(),e.producerIndexOfThis.pop()}}function kD(e){US(e);for(let t=0;t0}function US(e){e.producerNode??=[],e.producerIndexOfThis??=[],e.producerLastReadVersion??=[]}function gce(e){e.liveConsumerNode??=[],e.liveConsumerIndexOfThis??=[]}function yce(){throw new Error}var bce=yce;function Ck(e){bce=e}function rn(e){return typeof e=="function"}function dg(e){let r=e(n=>{Error.call(n),n.stack=new Error().stack});return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var VS=dg(e=>function(r){e(this),this.message=r?`${r.length} errors occurred during unsubscription: +${r.map((n,a)=>`${a+1}) ${n.toString()}`).join(` + `)}`:"",this.name="UnsubscriptionError",this.errors=r});function vh(e,t){if(e){let r=e.indexOf(t);0<=r&&e.splice(r,1)}}var co=class e{constructor(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}unsubscribe(){let t;if(!this.closed){this.closed=!0;let{_parentage:r}=this;if(r)if(this._parentage=null,Array.isArray(r))for(let i of r)i.remove(this);else r.remove(this);let{initialTeardown:n}=this;if(rn(n))try{n()}catch(i){t=i instanceof VS?i.errors:[i]}let{_finalizers:a}=this;if(a){this._finalizers=null;for(let i of a)try{_k(i)}catch(o){t=t??[],o instanceof VS?t=[...t,...o.errors]:t.push(o)}}if(t)throw new VS(t)}}add(t){var r;if(t&&t!==this)if(this.closed)_k(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}}_hasParent(t){let{_parentage:r}=this;return r===t||Array.isArray(r)&&r.includes(t)}_addParent(t){let{_parentage:r}=this;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t}_removeParent(t){let{_parentage:r}=this;r===t?this._parentage=null:Array.isArray(r)&&vh(r,t)}remove(t){let{_finalizers:r}=this;r&&vh(r,t),t instanceof e&&t._removeParent(this)}};co.EMPTY=(()=>{let e=new co;return e.closed=!0,e})();var VD=co.EMPTY;function GS(e){return e instanceof co||e&&"closed"in e&&rn(e.remove)&&rn(e.add)&&rn(e.unsubscribe)}function _k(e){rn(e)?e():e.unsubscribe()}var xl={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var mg={setTimeout(e,t,...r){let{delegate:n}=mg;return n?.setTimeout?n.setTimeout(e,t,...r):setTimeout(e,t,...r)},clearTimeout(e){let{delegate:t}=mg;return(t?.clearTimeout||clearTimeout)(e)},delegate:void 0};function zS(e){mg.setTimeout(()=>{let{onUnhandledError:t}=xl;if(t)t(e);else throw e})}function bb(){}var wk=(()=>GD("C",void 0,void 0))();function Tk(e){return GD("E",void 0,e)}function Ak(e){return GD("N",e,void 0)}function GD(e,t,r){return{kind:e,value:t,error:r}}var gh=null;function pg(e){if(xl.useDeprecatedSynchronousErrorHandling){let t=!gh;if(t&&(gh={errorThrown:!1,error:null}),e(),t){let{errorThrown:r,error:n}=gh;if(gh=null,r)throw n}}else e()}function Dk(e){xl.useDeprecatedSynchronousErrorHandling&&gh&&(gh.errorThrown=!0,gh.error=e)}var yh=class extends co{constructor(t){super(),this.isStopped=!1,t?(this.destination=t,GS(t)&&t.add(this)):this.destination=Cce}static create(t,r,n){return new ad(t,r,n)}next(t){this.isStopped?HD(Ak(t),this):this._next(t)}error(t){this.isStopped?HD(Tk(t),this):(this.isStopped=!0,this._error(t))}complete(){this.isStopped?HD(wk,this):(this.isStopped=!0,this._complete())}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe(),this.destination=null)}_next(t){this.destination.next(t)}_error(t){try{this.destination.error(t)}finally{this.unsubscribe()}}_complete(){try{this.destination.complete()}finally{this.unsubscribe()}}},xce=Function.prototype.bind;function zD(e,t){return xce.call(e,t)}var jD=class{constructor(t){this.partialObserver=t}next(t){let{partialObserver:r}=this;if(r.next)try{r.next(t)}catch(n){HS(n)}}error(t){let{partialObserver:r}=this;if(r.error)try{r.error(t)}catch(n){HS(n)}else HS(t)}complete(){let{partialObserver:t}=this;if(t.complete)try{t.complete()}catch(r){HS(r)}}},ad=class extends yh{constructor(t,r,n){super();let a;if(rn(t)||!t)a={next:t??void 0,error:r??void 0,complete:n??void 0};else{let i;this&&xl.useDeprecatedNextContext?(i=Object.create(t),i.unsubscribe=()=>this.unsubscribe(),a={next:t.next&&zD(t.next,i),error:t.error&&zD(t.error,i),complete:t.complete&&zD(t.complete,i)}):a=t}this.destination=new jD(a)}};function HS(e){xl.useDeprecatedSynchronousErrorHandling?Dk(e):zS(e)}function Sce(e){throw e}function HD(e,t){let{onStoppedNotification:r}=xl;r&&mg.setTimeout(()=>r(e,t))}var Cce={closed:!0,next:bb,error:Sce,complete:bb};var hg=(()=>typeof Symbol=="function"&&Symbol.observable||"@@observable")();function zs(e){return e}function xb(...e){return qD(e)}function qD(e){return e.length===0?zs:e.length===1?e[0]:function(r){return e.reduce((n,a)=>a(n),r)}}var qn=(()=>{class e{constructor(r){r&&(this._subscribe=r)}lift(r){let n=new e;return n.source=this,n.operator=r,n}subscribe(r,n,a){let i=wce(r)?r:new ad(r,n,a);return pg(()=>{let{operator:o,source:s}=this;i.add(o?o.call(i,s):s?this._subscribe(i):this._trySubscribe(i))}),i}_trySubscribe(r){try{return this._subscribe(r)}catch(n){r.error(n)}}forEach(r,n){return n=Pk(n),new n((a,i)=>{let o=new ad({next:s=>{try{r(s)}catch(u){i(u),o.unsubscribe()}},error:i,complete:a});this.subscribe(o)})}_subscribe(r){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(r)}[hg](){return this}pipe(...r){return qD(r)(this)}toPromise(r){return r=Pk(r),new r((n,a)=>{let i;this.subscribe(o=>i=o,o=>a(o),()=>n(i))})}}return e.create=t=>new e(t),e})();function Pk(e){var t;return(t=e??xl.Promise)!==null&&t!==void 0?t:Promise}function _ce(e){return e&&rn(e.next)&&rn(e.error)&&rn(e.complete)}function wce(e){return e&&e instanceof yh||_ce(e)&&GS(e)}function WD(e){return rn(e?.lift)}function Zr(e){return t=>{if(WD(t))return t.lift(function(r){try{return e(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function sn(e,t,r,n,a){return new YD(e,t,r,n,a)}var YD=class extends yh{constructor(t,r,n,a,i,o){super(t),this.onFinalize=i,this.shouldUnsubscribe=o,this._next=r?function(s){try{r(s)}catch(u){t.error(u)}}:super._next,this._error=a?function(s){try{a(s)}catch(u){t.error(u)}finally{this.unsubscribe()}}:super._error,this._complete=n?function(){try{n()}catch(s){t.error(s)}finally{this.unsubscribe()}}:super._complete}unsubscribe(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){let{closed:r}=this;super.unsubscribe(),!r&&((t=this.onFinalize)===null||t===void 0||t.call(this))}}};function vg(){return Zr((e,t)=>{let r=null;e._refCount++;let n=sn(t,void 0,void 0,void 0,()=>{if(!e||e._refCount<=0||0<--e._refCount){r=null;return}let a=e._connection,i=r;r=null,a&&(!i||a===i)&&a.unsubscribe(),t.unsubscribe()});e.subscribe(n),n.closed||(r=e.connect())})}var gg=class extends qn{constructor(t,r){super(),this.source=t,this.subjectFactory=r,this._subject=null,this._refCount=0,this._connection=null,WD(t)&&(this.lift=t.lift)}_subscribe(t){return this.getSubject().subscribe(t)}getSubject(){let t=this._subject;return(!t||t.isStopped)&&(this._subject=this.subjectFactory()),this._subject}_teardown(){this._refCount=0;let{_connection:t}=this;this._subject=this._connection=null,t?.unsubscribe()}connect(){let t=this._connection;if(!t){t=this._connection=new co;let r=this.getSubject();t.add(this.source.subscribe(sn(r,void 0,()=>{this._teardown(),r.complete()},n=>{this._teardown(),r.error(n)},()=>this._teardown()))),t.closed&&(this._connection=null,t=co.EMPTY)}return t}refCount(){return vg()(this)}};var Ek=dg(e=>function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"});var kr=(()=>{class e extends qn{constructor(){super(),this.closed=!1,this.currentObservers=null,this.observers=[],this.isStopped=!1,this.hasError=!1,this.thrownError=null}lift(r){let n=new jS(this,this);return n.operator=r,n}_throwIfClosed(){if(this.closed)throw new Ek}next(r){pg(()=>{if(this._throwIfClosed(),!this.isStopped){this.currentObservers||(this.currentObservers=Array.from(this.observers));for(let n of this.currentObservers)n.next(r)}})}error(r){pg(()=>{if(this._throwIfClosed(),!this.isStopped){this.hasError=this.isStopped=!0,this.thrownError=r;let{observers:n}=this;for(;n.length;)n.shift().error(r)}})}complete(){pg(()=>{if(this._throwIfClosed(),!this.isStopped){this.isStopped=!0;let{observers:r}=this;for(;r.length;)r.shift().complete()}})}unsubscribe(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null}get observed(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0}_trySubscribe(r){return this._throwIfClosed(),super._trySubscribe(r)}_subscribe(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)}_innerSubscribe(r){let{hasError:n,isStopped:a,observers:i}=this;return n||a?VD:(this.currentObservers=null,i.push(r),new co(()=>{this.currentObservers=null,vh(i,r)}))}_checkFinalizedStatuses(r){let{hasError:n,thrownError:a,isStopped:i}=this;n?r.error(a):i&&r.complete()}asObservable(){let r=new qn;return r.source=this,r}}return e.create=(t,r)=>new jS(t,r),e})(),jS=class extends kr{constructor(t,r){super(),this.destination=t,this.source=r}next(t){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.next)===null||n===void 0||n.call(r,t)}error(t){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.error)===null||n===void 0||n.call(r,t)}complete(){var t,r;(r=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||r===void 0||r.call(t)}_subscribe(t){var r,n;return(n=(r=this.source)===null||r===void 0?void 0:r.subscribe(t))!==null&&n!==void 0?n:VD}};var ha=class extends kr{constructor(t){super(),this._value=t}get value(){return this.getValue()}_subscribe(t){let r=super._subscribe(t);return!r.closed&&t.next(this._value),r}getValue(){let{hasError:t,thrownError:r,_value:n}=this;if(t)throw r;return this._throwIfClosed(),n}next(t){super.next(this._value=t)}};var Sb={now(){return(Sb.delegate||Date).now()},delegate:void 0};var of=class extends kr{constructor(t=1/0,r=1/0,n=Sb){super(),this._bufferSize=t,this._windowTime=r,this._timestampProvider=n,this._buffer=[],this._infiniteTimeWindow=!0,this._infiniteTimeWindow=r===1/0,this._bufferSize=Math.max(1,t),this._windowTime=Math.max(1,r)}next(t){let{isStopped:r,_buffer:n,_infiniteTimeWindow:a,_timestampProvider:i,_windowTime:o}=this;r||(n.push(t),!a&&n.push(i.now()+o)),this._trimBuffer(),super.next(t)}_subscribe(t){this._throwIfClosed(),this._trimBuffer();let r=this._innerSubscribe(t),{_infiniteTimeWindow:n,_buffer:a}=this,i=a.slice();for(let o=0;oe.complete());function XS(e){return e&&rn(e.schedule)}function XD(e){return e[e.length-1]}function KS(e){return rn(XD(e))?e.pop():void 0}function sf(e){return XS(XD(e))?e.pop():void 0}function Mk(e,t){return typeof XD(e)=="number"?e.pop():t}var KD=function(e,t){return KD=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])},KD(e,t)};function St(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");KD(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var P=function(){return P=Object.assign||function(t){for(var r,n=1,a=arguments.length;n0&&i[i.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ut(e,t,r){if(r||arguments.length===2)for(var n=0,a=t.length,i;n1||s(d,m)})})}function s(d,m){try{u(n[d](m))}catch(h){f(i[0][3],h)}}function u(d){d.value instanceof bh?Promise.resolve(d.value.v).then(c,l):f(i[0][2],d)}function c(d){s("next",d)}function l(d){s("throw",d)}function f(d,m){d(m),i.shift(),i.length&&s(i[0][0],i[0][1])}}function Ok(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof Rk=="function"?Rk(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=e[i]&&function(o){return new Promise(function(s,u){o=e[i](o),a(s,u,o.done,o.value)})}}function a(i,o,s,u){Promise.resolve(u).then(function(c){i({value:c,done:s})},o)}}var ZS=e=>e&&typeof e.length=="number"&&typeof e!="function";function QS(e){return rn(e?.then)}function $S(e){return rn(e[hg])}function JS(e){return Symbol.asyncIterator&&rn(e?.[Symbol.asyncIterator])}function eC(e){return new TypeError(`You provided ${e!==null&&typeof e=="object"?"an invalid object":`'${e}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}function Tce(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var tC=Tce();function rC(e){return rn(e?.[tC])}function nC(e){return Bk(this,arguments,function*(){let r=e.getReader();try{for(;;){let{value:n,done:a}=yield bh(r.read());if(a)return yield bh(void 0);yield yield bh(n)}}finally{r.releaseLock()}})}function aC(e){return rn(e?.getReader)}function ti(e){if(e instanceof qn)return e;if(e!=null){if($S(e))return Ace(e);if(ZS(e))return Dce(e);if(QS(e))return Pce(e);if(JS(e))return Fk(e);if(rC(e))return Ece(e);if(aC(e))return Ice(e)}throw eC(e)}function Ace(e){return new qn(t=>{let r=e[hg]();if(rn(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Dce(e){return new qn(t=>{for(let r=0;r{e.then(r=>{t.closed||(t.next(r),t.complete())},r=>t.error(r)).then(null,zS)})}function Ece(e){return new qn(t=>{for(let r of e)if(t.next(r),t.closed)return;t.complete()})}function Fk(e){return new qn(t=>{Mce(e,t).catch(r=>t.error(r))})}function Ice(e){return Fk(nC(e))}function Mce(e,t){var r,n,a,i;return $(this,void 0,void 0,function*(){try{for(r=Ok(e);n=yield r.next(),!n.done;){let o=n.value;if(t.next(o),t.closed)return}}catch(o){a={error:o}}finally{try{n&&!n.done&&(i=r.return)&&(yield i.call(r))}finally{if(a)throw a.error}}t.complete()})}function du(e,t,r,n=0,a=!1){let i=t.schedule(function(){r(),a?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(i),!a)return i}function iC(e,t=0){return Zr((r,n)=>{r.subscribe(sn(n,a=>du(n,e,()=>n.next(a),t),()=>du(n,e,()=>n.complete(),t),a=>du(n,e,()=>n.error(a),t)))})}function oC(e,t=0){return Zr((r,n)=>{n.add(e.schedule(()=>r.subscribe(n),t))})}function Lk(e,t){return ti(e).pipe(oC(t),iC(t))}function kk(e,t){return ti(e).pipe(oC(t),iC(t))}function Nk(e,t){return new qn(r=>{let n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}function Uk(e,t){return new qn(r=>{let n;return du(r,t,()=>{n=e[tC](),du(r,t,()=>{let a,i;try{({value:a,done:i}=n.next())}catch(o){r.error(o);return}i?r.complete():r.next(a)},0,!0)}),()=>rn(n?.return)&&n.return()})}function sC(e,t){if(!e)throw new Error("Iterable cannot be null");return new qn(r=>{du(r,t,()=>{let n=e[Symbol.asyncIterator]();du(r,t,()=>{n.next().then(a=>{a.done?r.complete():r.next(a.value)})},0,!0)})})}function Vk(e,t){return sC(nC(e),t)}function Gk(e,t){if(e!=null){if($S(e))return Lk(e,t);if(ZS(e))return Nk(e,t);if(QS(e))return kk(e,t);if(JS(e))return sC(e,t);if(rC(e))return Uk(e,t);if(aC(e))return Vk(e,t)}throw eC(e)}function di(e,t){return t?Gk(e,t):ti(e)}function Yr(...e){let t=sf(e);return di(e,t)}function bg(e,t){let r=rn(e)?e:()=>e,n=a=>a.error(r());return new qn(t?a=>t.schedule(n,0,a):n)}function ZD(e){return!!e&&(e instanceof qn||rn(e.lift)&&rn(e.subscribe))}var id=dg(e=>function(){e(this),this.name="EmptyError",this.message="no elements in sequence"});function zk(e){return e instanceof Date&&!isNaN(e)}function Cn(e,t){return Zr((r,n)=>{let a=0;r.subscribe(sn(n,i=>{n.next(e.call(t,i,a++))}))})}var{isArray:Rce}=Array;function Bce(e,t){return Rce(t)?e(...t):e(t)}function uC(e){return Cn(t=>Bce(e,t))}var{isArray:Oce}=Array,{getPrototypeOf:Fce,prototype:Lce,keys:kce}=Object;function Hk(e){if(e.length===1){let t=e[0];if(Oce(t))return{args:t,keys:null};if(Nce(t)){let r=kce(t);return{args:r.map(n=>t[n]),keys:r}}}return{args:e,keys:null}}function Nce(e){return e&&typeof e=="object"&&Fce(e)===Lce}function jk(e,t){return e.reduce((r,n,a)=>(r[n]=t[a],r),{})}function cC(...e){let t=sf(e),r=KS(e),{args:n,keys:a}=Hk(e);if(n.length===0)return di([],t);let i=new qn(QD(n,t,a?o=>jk(a,o):zs));return r?i.pipe(uC(r)):i}function QD(e,t,r=zs){return n=>{qk(t,()=>{let{length:a}=e,i=new Array(a),o=a,s=a;for(let u=0;u{let c=di(e[u],t),l=!1;c.subscribe(sn(n,f=>{i[u]=f,l||(l=!0,s--),s||n.next(r(i.slice()))},()=>{--o||n.complete()}))},n)},n)}}function qk(e,t,r){e?du(r,e,t):t()}function Wk(e,t,r,n,a,i,o,s){let u=[],c=0,l=0,f=!1,d=()=>{f&&!u.length&&!c&&t.complete()},m=p=>c{i&&t.next(p),c++;let v=!1;ti(r(p,l++)).subscribe(sn(t,g=>{a?.(g),i?m(g):t.next(g)},()=>{v=!0},void 0,()=>{if(v)try{for(c--;u.length&&ch(g)):h(g)}d()}catch(g){t.error(g)}}))};return e.subscribe(sn(t,m,()=>{f=!0,d()})),()=>{s?.()}}function To(e,t,r=1/0){return rn(t)?To((n,a)=>Cn((i,o)=>t(n,i,a,o))(ti(e(n,a))),r):(typeof t=="number"&&(r=t),Zr((n,a)=>Wk(n,a,e,r)))}function wb(e=1/0){return To(zs,e)}function Yk(){return wb(1)}function xg(...e){return Yk()(di(e,sf(e)))}function lC(e){return new qn(t=>{ti(e()).subscribe(t)})}function Xk(e=0,t,r=Ik){let n=-1;return t!=null&&(XS(t)?r=t:n=t),new qn(a=>{let i=zk(e)?+e-r.now():e;i<0&&(i=0);let o=0;return r.schedule(function(){a.closed||(a.next(o++),0<=n?this.schedule(void 0,n):a.complete())},i)})}function mu(...e){let t=sf(e),r=Mk(e,1/0),n=e;return n.length?n.length===1?ti(n[0]):wb(r)(di(n,t)):fu}var{isArray:Uce}=Array;function Kk(e){return e.length===1&&Uce(e[0])?e[0]:e}function _s(e,t){return Zr((r,n)=>{let a=0;r.subscribe(sn(n,i=>e.call(t,i,a++)&&n.next(i)))})}function mm(e){return Zr((t,r)=>{let n=null,a=!1,i;n=t.subscribe(sn(r,void 0,void 0,o=>{i=ti(e(o,mm(e)(t))),n?(n.unsubscribe(),n=null,i.subscribe(r)):a=!0})),a&&(n.unsubscribe(),n=null,i.subscribe(r))})}function Zk(e,t,r,n,a){return(i,o)=>{let s=r,u=t,c=0;i.subscribe(sn(o,l=>{let f=c++;u=s?e(u,l,f):(s=!0,l),n&&o.next(u)},a&&(()=>{s&&o.next(u),o.complete()})))}}function $D(...e){let t=KS(e);return t?xb($D(...e),uC(t)):Zr((r,n)=>{QD([r,...Kk(e)])(n)})}function fC(...e){return $D(...e)}function Sg(e,t){return rn(t)?To(e,t,1):To(e,1)}function JD(e,t=_b){return Zr((r,n)=>{let a=null,i=null,o=null,s=()=>{if(a){a.unsubscribe(),a=null;let c=i;i=null,n.next(c)}};function u(){let c=o+e,l=t.now();if(l{i=c,o=t.now(),a||(a=t.schedule(u,e),n.add(a))},()=>{s(),n.complete()},void 0,()=>{i=a=null}))})}function pm(e){return Zr((t,r)=>{let n=!1;t.subscribe(sn(r,a=>{n=!0,r.next(a)},()=>{n||r.next(e),r.complete()}))})}function Sl(e){return e<=0?()=>fu:Zr((t,r)=>{let n=0;t.subscribe(sn(r,a=>{++n<=e&&(r.next(a),e<=n&&r.complete())}))})}function eP(e){return Cn(()=>e)}function Cg(e,t=zs){return e=e??Vce,Zr((r,n)=>{let a,i=!0;r.subscribe(sn(n,o=>{let s=t(o);(i||!e(a,s))&&(i=!1,a=s,n.next(o))}))})}function Vce(e,t){return e===t}function dC(e=Gce){return Zr((t,r)=>{let n=!1;t.subscribe(sn(r,a=>{n=!0,r.next(a)},()=>n?r.complete():r.error(e())))})}function Gce(){return new id}function Tb(e){return Zr((t,r)=>{try{t.subscribe(r)}finally{r.add(e)}})}function uf(e,t){let r=arguments.length>=2;return n=>n.pipe(e?_s((a,i)=>e(a,i,n)):zs,Sl(1),r?pm(t):dC(()=>new id))}function _g(e){return e<=0?()=>fu:Zr((t,r)=>{let n=[];t.subscribe(sn(r,a=>{n.push(a),e{for(let a of n)r.next(a);r.complete()},void 0,()=>{n=null}))})}function tP(e,t){let r=arguments.length>=2;return n=>n.pipe(e?_s((a,i)=>e(a,i,n)):zs,_g(1),r?pm(t):dC(()=>new id))}function rP(e,t){return Zr(Zk(e,t,arguments.length>=2,!0))}function wg(e={}){let{connector:t=()=>new kr,resetOnError:r=!0,resetOnComplete:n=!0,resetOnRefCountZero:a=!0}=e;return i=>{let o,s,u,c=0,l=!1,f=!1,d=()=>{s?.unsubscribe(),s=void 0},m=()=>{d(),o=u=void 0,l=f=!1},h=()=>{let p=o;m(),p?.unsubscribe()};return Zr((p,v)=>{c++,!f&&!l&&d();let g=u=u??t();v.add(()=>{c--,c===0&&!f&&!l&&(s=nP(h,a))}),g.subscribe(v),!o&&c>0&&(o=new ad({next:b=>g.next(b),error:b=>{f=!0,d(),s=nP(m,r,b),g.error(b)},complete:()=>{l=!0,d(),s=nP(m,n),g.complete()}}),ti(p).subscribe(o))})(i)}}function nP(e,t,...r){if(t===!0){e();return}if(t===!1)return;let n=new ad({next:()=>{n.unsubscribe(),e()}});return ti(t(...r)).subscribe(n)}function aP(e,t,r){let n,a=!1;return e&&typeof e=="object"?{bufferSize:n=1/0,windowTime:t=1/0,refCount:a=!1,scheduler:r}=e:n=e??1/0,wg({connector:()=>new of(n,t,r),resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}function iP(...e){let t=sf(e);return Zr((r,n)=>{(t?xg(e,r,t):xg(e,r)).subscribe(n)})}function ds(e,t){return Zr((r,n)=>{let a=null,i=0,o=!1,s=()=>o&&!a&&n.complete();r.subscribe(sn(n,u=>{a?.unsubscribe();let c=0,l=i++;ti(e(u,l)).subscribe(a=sn(n,f=>n.next(t?t(u,f,l,c++):f),()=>{a=null,s()}))},()=>{o=!0,s()}))})}function oP(e){return Zr((t,r)=>{ti(e).subscribe(sn(r,()=>r.complete(),bb)),!r.closed&&t.subscribe(r)})}function Bo(e,t,r){let n=rn(e)||t||r?{next:e,error:t,complete:r}:e;return n?Zr((a,i)=>{var o;(o=n.subscribe)===null||o===void 0||o.call(n);let s=!0;a.subscribe(sn(i,u=>{var c;(c=n.next)===null||c===void 0||c.call(n,u),i.next(u)},()=>{var u;s=!1,(u=n.complete)===null||u===void 0||u.call(n),i.complete()},u=>{var c;s=!1,(c=n.error)===null||c===void 0||c.call(n,u),i.error(u)},()=>{var u,c;s&&((u=n.unsubscribe)===null||u===void 0||u.call(n)),(c=n.finalize)===null||c===void 0||c.call(n)}))}):zs}function Qk(e,t){return Zr((r,n)=>{let{leading:a=!0,trailing:i=!1}=t??{},o=!1,s=null,u=null,c=!1,l=()=>{u?.unsubscribe(),u=null,i&&(m(),c&&n.complete())},f=()=>{u=null,c&&n.complete()},d=h=>u=ti(e(h)).subscribe(sn(n,l,f)),m=()=>{if(o){o=!1;let h=s;s=null,n.next(h),!c&&d(h)}};r.subscribe(sn(n,h=>{o=!0,s=h,!(u&&!u.closed)&&(a?m():d(h))},()=>{c=!0,!(i&&o&&u&&!u.closed)&&n.complete()}))})}function Tg(e,t=_b,r){let n=Xk(e,t);return Qk(()=>n,r)}function ka(e){for(let t in e)if(e[t]===ka)return t;throw Error("Could not find renamed property on target object.")}function pu(e){if(typeof e=="string")return e;if(Array.isArray(e))return"["+e.map(pu).join(", ")+"]";if(e==null)return""+e;if(e.overriddenName)return`${e.overriddenName}`;if(e.name)return`${e.name}`;let t=e.toString();if(t==null)return""+t;let r=t.indexOf(` +`);return r===-1?t:t.substring(0,r)}function $k(e,t){return e==null||e===""?t===null?"":t:t==null||t===""?e:e+" "+t}var zce=ka({__forward_ref__:ka});function IN(e){return e.__forward_ref__=IN,e.toString=function(){return pu(this())},e}function Cc(e){return MN(e)?e():e}function MN(e){return typeof e=="function"&&e.hasOwnProperty(zce)&&e.__forward_ref__===IN}function RN(e){return e&&!!e.\u0275providers}var Qr=class extends Error{constructor(t,r){super(QP(t,r)),this.code=t}};function QP(e,t){return`${`NG0${Math.abs(e)}`}${t?": "+t:""}`}var Hce=ka({\u0275cmp:ka}),jce=ka({\u0275dir:ka}),qce=ka({\u0275pipe:ka}),Wce=ka({\u0275mod:ka}),bC=ka({\u0275fac:ka}),Ab=ka({__NG_ELEMENT_ID__:ka}),Jk=ka({__NG_ENV_ID__:ka});function BN(e){return typeof e=="string"?e:e==null?"":String(e)}function Yce(e){return typeof e=="function"?e.name||e.toString():typeof e=="object"&&e!=null&&typeof e.type=="function"?e.type.name||e.type.toString():BN(e)}function Xce(e,t){let r=t?`. Dependency path: ${t.join(" > ")} > ${e}`:"";throw new Qr(-200,`Circular dependency in DI detected for ${e}${r}`)}function $P(e,t){let r=t?` in ${t}`:"";throw new Qr(-201,!1)}function Kce(e,t){e==null&&Zce(t,e,null,"!=")}function Zce(e,t,r,n){throw new Error(`ASSERTION ERROR: ${e}`+(n==null?"":` [Expected=> ${r} ${n} ${t} <=Actual]`))}function un(e){return{token:e.token,providedIn:e.providedIn||null,factory:e.factory,value:void 0}}function BC(e){return{providers:e.providers||[],imports:e.imports||[]}}function OC(e){return eN(e,FN)||eN(e,LN)}function ON(e){return OC(e)!==null}function eN(e,t){return e.hasOwnProperty(t)?e[t]:null}function Qce(e){let t=e&&(e[FN]||e[LN]);return t||null}function tN(e){return e&&(e.hasOwnProperty(rN)||e.hasOwnProperty($ce))?e[rN]:null}var FN=ka({\u0275prov:ka}),rN=ka({\u0275inj:ka}),LN=ka({ngInjectableDef:ka}),$ce=ka({ngInjectorDef:ka}),_n=function(e){return e[e.Default=0]="Default",e[e.Host=1]="Host",e[e.Self=2]="Self",e[e.SkipSelf=4]="SkipSelf",e[e.Optional=8]="Optional",e}(_n||{}),gP;function Jce(){return gP}function Sc(e){let t=gP;return gP=e,t}function kN(e,t,r){let n=OC(e);if(n&&n.providedIn=="root")return n.value===void 0?n.value=n.factory():n.value;if(r&_n.Optional)return null;if(t!==void 0)return t;$P(pu(e),"Injector")}var Db=globalThis;var Nn=class{constructor(t,r){this._desc=t,this.ngMetadataName="InjectionToken",this.\u0275prov=void 0,typeof r=="number"?this.__NG_ELEMENT_ID__=r:r!==void 0&&(this.\u0275prov=un({token:this,providedIn:r.providedIn||"root",factory:r.factory}))}get multi(){return this}toString(){return`InjectionToken ${this._desc}`}};var ele={},Ib=ele,tle="__NG_DI_FLAG__",xC="ngTempTokenPath",rle="ngTokenPath",nle=/\n/gm,ale="\u0275",nN="__source",Pb;function hm(e){let t=Pb;return Pb=e,t}function ile(e,t=_n.Default){if(Pb===void 0)throw new Qr(-203,!1);return Pb===null?kN(e,void 0,t):Pb.get(e,t&_n.Optional?null:void 0,t)}function On(e,t=_n.Default){return(Jce()||ile)(Cc(e),t)}function br(e,t=_n.Default){return On(e,FC(t))}function FC(e){return typeof e>"u"||typeof e=="number"?e:0|(e.optional&&8)|(e.host&&1)|(e.self&&2)|(e.skipSelf&&4)}function yP(e){let t=[];for(let r=0;r ");else if(typeof t=="object"){let i=[];for(let o in t)if(t.hasOwnProperty(o)){let s=t[o];i.push(o+":"+(typeof s=="string"?JSON.stringify(s):pu(s)))}a=`{${i.join(", ")}}`}return`${r}${n?"("+n+")":""}[${a}]: ${e.replace(nle,` + `)}`}function LC(e){return{toString:e}.toString()}var NN=function(e){return e[e.OnPush=0]="OnPush",e[e.Default=1]="Default",e}(NN||{}),df=function(e){return e[e.Emulated=0]="Emulated",e[e.None=2]="None",e[e.ShadowDom=3]="ShadowDom",e}(df||{}),Mb={},cf=[];function UN(e,t,r){let n=e.length;for(;;){let a=e.indexOf(t,r);if(a===-1)return a;if(a===0||e.charCodeAt(a-1)<=32){let i=t.length;if(a+i===n||e.charCodeAt(a+i)<=32)return a}r=a+1}}function bP(e,t,r){let n=0;for(;nt){o=i-1;break}}}for(;ii?d="":d=a[f+1].toLowerCase();let m=n&8?d:null;if(m&&UN(m,c,0)!==-1||n&2&&c!==d){if(Cl(n))return!1;o=!0}}}}return Cl(n)||o}function Cl(e){return(e&1)===0}function ple(e,t,r,n){if(t===null)return-1;let a=0;if(n||!r){let i=!1;for(;a-1)for(r++;r0?'="'+s+'"':"")+"]"}else n&8?a+="."+o:n&4&&(a+=" "+o);else a!==""&&!Cl(o)&&(t+=iN(i,a),a=""),n=o,i=i||!Cl(n);r++}return a!==""&&(t+=iN(i,a)),t}function ble(e){return e.map(yle).join(",")}function xle(e){let t=[],r=[],n=1,a=2;for(;n{let t=WN(e),r=uo(Ar({},t),{decls:e.decls,vars:e.vars,template:e.template,consts:e.consts||null,ngContentSelectors:e.ngContentSelectors,onPush:e.changeDetection===NN.OnPush,directiveDefs:null,pipeDefs:null,dependencies:t.standalone&&e.dependencies||null,getStandaloneInjector:null,signals:e.signals??!1,data:e.data||{},encapsulation:e.encapsulation||df.Emulated,styles:e.styles||cf,_:null,schemas:e.schemas||null,tView:null,id:""});YN(r);let n=e.dependencies;return r.directiveDefs=sN(n,!1),r.pipeDefs=sN(n,!0),r.id=_le(r),r})}function Sle(e){return Ch(e)||zN(e)}function Cle(e){return e!==null}function kC(e){return LC(()=>({type:e.type,bootstrap:e.bootstrap||cf,declarations:e.declarations||cf,imports:e.imports||cf,exports:e.exports||cf,transitiveCompileScopes:null,schemas:e.schemas||null,id:e.id||null}))}function oN(e,t){if(e==null)return Mb;let r={};for(let n in e)if(e.hasOwnProperty(n)){let a=e[n],i=a;Array.isArray(a)&&(i=a[1],a=a[0]),r[a]=n,t&&(t[a]=i)}return r}function eE(e){return LC(()=>{let t=WN(e);return YN(t),t})}function Ch(e){return e[Hce]||null}function zN(e){return e[jce]||null}function HN(e){return e[qce]||null}function jN(e){let t=Ch(e)||zN(e)||HN(e);return t!==null?t.standalone:!1}function qN(e,t){let r=e[Wce]||null;if(!r&&t===!0)throw new Error(`Type ${pu(e)} does not have '\u0275mod' property.`);return r}function WN(e){let t={};return{type:e.type,providersResolver:null,factory:null,hostBindings:e.hostBindings||null,hostVars:e.hostVars||0,hostAttrs:e.hostAttrs||null,contentQueries:e.contentQueries||null,declaredInputs:t,inputTransforms:null,inputConfig:e.inputs||Mb,exportAs:e.exportAs||null,standalone:e.standalone===!0,signals:e.signals===!0,selectors:e.selectors||cf,viewQuery:e.viewQuery||null,features:e.features||null,setInput:null,findHostDirectiveDefs:null,hostDirectives:null,inputs:oN(e.inputs,t),outputs:oN(e.outputs),debugInfo:null}}function YN(e){e.features?.forEach(t=>t(e))}function sN(e,t){if(!e)return null;let r=t?HN:Sle;return()=>(typeof e=="function"?e():e).map(n=>r(n)).filter(Cle)}function _le(e){let t=0,r=[e.selectors,e.ngContentSelectors,e.hostVars,e.hostAttrs,e.consts,e.vars,e.decls,e.encapsulation,e.standalone,e.signals,e.exportAs,JSON.stringify(e.inputs),JSON.stringify(e.outputs),Object.getOwnPropertyNames(e.type.prototype),!!e.contentQueries,!!e.viewQuery].join("|");for(let a of r)t=Math.imul(31,t)+a.charCodeAt(0)<<0;return t+=2147483647+1,"c"+t}var cd=0,wn=1,Xr=2,fo=3,_l=4,Tl=5,xP=6,SC=7,od=8,Ig=9,Rb=10,Yu=11,Bb=12,uN=13,Vb=14,mf=15,Gb=16,Ag=17,ff=18,NC=19,XN=20,Eb=21,sP=22,_h=23,wh=25,KN=1;var Th=7,CC=8,Mg=9,Wu=10,Rg=function(e){return e[e.None=0]="None",e[e.HasTransplantedViews=2]="HasTransplantedViews",e[e.HasChildViewsToRefresh=4]="HasChildViewsToRefresh",e}(Rg||{});function xh(e){return Array.isArray(e)&&typeof e[KN]=="object"}function wl(e){return Array.isArray(e)&&e[KN]===!0}function ZN(e){return(e.flags&4)!==0}function UC(e){return e.componentOffset>-1}function wle(e){return(e.flags&1)===1}function zb(e){return!!e.template}function Tle(e){return(e[Xr]&512)!==0}function Bg(e,t){let r=e.hasOwnProperty(bC);return r?e[bC]:null}var SP=class{constructor(t,r,n){this.previousValue=t,this.currentValue=r,this.firstChange=n}isFirstChange(){return this.firstChange}};function VC(){return QN}function QN(e){return e.type.prototype.ngOnChanges&&(e.setInput=Dle),Ale}VC.ngInherit=!0;function Ale(){let e=JN(this),t=e?.current;if(t){let r=e.previous;if(r===Mb)e.previous=t;else for(let n in t)r[n]=t[n];e.current=null,this.ngOnChanges(t)}}function Dle(e,t,r,n){let a=this.declaredInputs[r],i=JN(e)||Ple(e,{previous:Mb,current:null}),o=i.current||(i.current={}),s=i.previous,u=s[a];o[a]=new SP(u&&u.currentValue,t,s===Mb),e[n]=t}var $N="__ngSimpleChanges__";function JN(e){return e[$N]||null}function Ple(e,t){return e[$N]=t}var cN=null;var vm=function(e,t,r){cN?.(e,t,r)},Ele="svg",Ile="math";function sd(e){for(;Array.isArray(e);)e=e[cd];return e}function Mle(e,t){return sd(t[e])}function pf(e,t){return sd(t[e.index])}function e5(e,t){return e.data[t]}function Ng(e,t){let r=t[e];return xh(r)?r:r[cd]}function Rle(e){return(e[Xr]&4)===4}function tE(e){return(e[Xr]&128)===128}function Ble(e){return wl(e[fo])}function lN(e,t){return t==null?null:e[t]}function t5(e){e[Ag]=0}function Ole(e){e[Xr]&1024||(e[Xr]|=1024,tE(e)&&GC(e))}function r5(e){return e[Xr]&9216||e[_h]?.dirty}function n5(e){r5(e)&&GC(e)}function GC(e){let t=e[fo];for(;t!==null&&!(wl(t)&&t[Xr]&Rg.HasChildViewsToRefresh||xh(t)&&t[Xr]&8192);){if(wl(t))t[Xr]|=Rg.HasChildViewsToRefresh;else if(t[Xr]|=8192,!tE(t))break;t=t[fo]}}function Fle(e,t){if((e[Xr]&256)===256)throw new Qr(911,!1);e[Eb]===null&&(e[Eb]=[]),e[Eb].push(t)}var sa={lFrame:f5(null),bindingsEnabled:!0,skipHydrationRootTNode:null};function Lle(){return sa.lFrame.elementDepthCount}function kle(){sa.lFrame.elementDepthCount++}function Nle(){sa.lFrame.elementDepthCount--}function a5(){return sa.bindingsEnabled}function Ule(){return sa.skipHydrationRootTNode!==null}function Vle(e){return sa.skipHydrationRootTNode===e}function Gle(){sa.skipHydrationRootTNode=null}function ms(){return sa.lFrame.lView}function Ph(){return sa.lFrame.tView}function ld(){let e=i5();for(;e!==null&&e.type===64;)e=e.parent;return e}function i5(){return sa.lFrame.currentTNode}function zle(){let e=sa.lFrame,t=e.currentTNode;return e.isParent?t:t.parent}function zC(e,t){let r=sa.lFrame;r.currentTNode=e,r.isParent=t}function o5(){return sa.lFrame.isParent}function Hle(){sa.lFrame.isParent=!1}function jle(e){return sa.lFrame.bindingIndex=e}function s5(){return sa.lFrame.bindingIndex++}function qle(){return sa.lFrame.inI18n}function Wle(e,t){let r=sa.lFrame;r.bindingIndex=r.bindingRootIndex=e,CP(t)}function Yle(){return sa.lFrame.currentDirectiveIndex}function CP(e){sa.lFrame.currentDirectiveIndex=e}function u5(){return sa.lFrame.currentQueryIndex}function rE(e){sa.lFrame.currentQueryIndex=e}function Xle(e){let t=e[wn];return t.type===2?t.declTNode:t.type===1?e[Tl]:null}function c5(e,t,r){if(r&_n.SkipSelf){let a=t,i=e;for(;a=a.parent,a===null&&!(r&_n.Host);)if(a=Xle(i),a===null||(i=i[Vb],a.type&10))break;if(a===null)return!1;t=a,e=i}let n=sa.lFrame=l5();return n.currentTNode=t,n.lView=e,!0}function nE(e){let t=l5(),r=e[wn];sa.lFrame=t,t.currentTNode=r.firstChild,t.lView=e,t.tView=r,t.contextLView=e,t.bindingIndex=r.bindingStartIndex,t.inI18n=!1}function l5(){let e=sa.lFrame,t=e===null?null:e.child;return t===null?f5(e):t}function f5(e){let t={currentTNode:null,isParent:!0,lView:null,tView:null,selectedIndex:-1,contextLView:null,elementDepthCount:0,currentNamespace:null,currentDirectiveIndex:-1,bindingRootIndex:-1,bindingIndex:-1,currentQueryIndex:0,parent:e,child:null,inI18n:!1};return e!==null&&(e.child=t),t}function d5(){let e=sa.lFrame;return sa.lFrame=e.parent,e.currentTNode=null,e.lView=null,e}var m5=d5;function aE(){let e=d5();e.isParent=!0,e.tView=null,e.selectedIndex=-1,e.contextLView=null,e.elementDepthCount=0,e.currentDirectiveIndex=-1,e.currentNamespace=null,e.bindingRootIndex=-1,e.bindingIndex=-1,e.currentQueryIndex=0}function iE(){return sa.lFrame.selectedIndex}function Ah(e){sa.lFrame.selectedIndex=e}function Kle(){let e=sa.lFrame;return e5(e.tView,e.selectedIndex)}function Zle(){return sa.lFrame.currentNamespace}var p5=!0;function h5(){return p5}function v5(e){p5=e}function Qle(e,t,r){let{ngOnChanges:n,ngOnInit:a,ngDoCheck:i}=t.type.prototype;if(n){let o=QN(t);(r.preOrderHooks??=[]).push(e,o),(r.preOrderCheckHooks??=[]).push(e,o)}a&&(r.preOrderHooks??=[]).push(0-e,a),i&&((r.preOrderHooks??=[]).push(e,i),(r.preOrderCheckHooks??=[]).push(e,i))}function g5(e,t){for(let r=t.directiveStart,n=t.directiveEnd;r=n)break}else t[u]<0&&(e[Ag]+=65536),(s>14>16&&(e[Xr]&3)===t&&(e[Xr]+=16384,fN(s,i)):fN(s,i)}var Eg=-1,Ob=class{constructor(t,r,n){this.factory=t,this.resolving=!1,this.canSeeViewProviders=r,this.injectImpl=n}};function Jle(e){return e instanceof Ob}function efe(e){return(e.flags&8)!==0}function tfe(e){return(e.flags&16)!==0}function b5(e){return e!==Eg}function _C(e){let t=e&32767;return e&32767}function rfe(e){return e>>16}function wC(e,t){let r=rfe(e),n=t;for(;r>0;)n=n[Vb],r--;return n}var _P=!0;function dN(e){let t=_P;return _P=e,t}var nfe=256,x5=nfe-1,S5=5,afe=0,lf={};function ife(e,t,r){let n;typeof r=="string"?n=r.charCodeAt(0)||0:r.hasOwnProperty(Ab)&&(n=r[Ab]),n==null&&(n=r[Ab]=afe++);let a=n&x5,i=1<>S5)]|=i}function C5(e,t){let r=_5(e,t);if(r!==-1)return r;let n=t[wn];n.firstCreatePass&&(e.injectorIndex=t.length,cP(n.data,e),cP(t,null),cP(n.blueprint,null));let a=oE(e,t),i=e.injectorIndex;if(b5(a)){let o=_C(a),s=wC(a,t),u=s[wn].data;for(let c=0;c<8;c++)t[i+c]=s[o+c]|u[o+c]}return t[i+8]=a,i}function cP(e,t){e.push(0,0,0,0,0,0,0,0,t)}function _5(e,t){return e.injectorIndex===-1||e.parent&&e.parent.injectorIndex===e.injectorIndex||t[e.injectorIndex+8]===null?-1:e.injectorIndex}function oE(e,t){if(e.parent&&e.parent.injectorIndex!==-1)return e.parent.injectorIndex;let r=0,n=null,a=t;for(;a!==null;){if(n=P5(a),n===null)return Eg;if(r++,a=a[Vb],n.injectorIndex!==-1)return n.injectorIndex|r<<16}return Eg}function ofe(e,t,r){ife(e,t,r)}function w5(e,t,r){if(r&_n.Optional||e!==void 0)return e;$P(t,"NodeInjector")}function T5(e,t,r,n){if(r&_n.Optional&&n===void 0&&(n=null),!(r&(_n.Self|_n.Host))){let a=e[Ig],i=Sc(void 0);try{return a?a.get(t,n,r&_n.Optional):kN(t,n,r&_n.Optional)}finally{Sc(i)}}return w5(n,t,r)}function A5(e,t,r,n=_n.Default,a){if(e!==null){if(t[Xr]&2048&&!(n&_n.Self)){let o=lfe(e,t,r,n,lf);if(o!==lf)return o}let i=D5(e,t,r,n,lf);if(i!==lf)return i}return T5(t,r,n,a)}function D5(e,t,r,n,a){let i=ufe(r);if(typeof i=="function"){if(!c5(t,e,n))return n&_n.Host?w5(a,r,n):T5(t,r,n,a);try{let o;if(o=i(n),o==null&&!(n&_n.Optional))$P(r);else return o}finally{m5()}}else if(typeof i=="number"){let o=null,s=_5(e,t),u=Eg,c=n&_n.Host?t[mf][Tl]:null;for((s===-1||n&_n.SkipSelf)&&(u=s===-1?oE(e,t):t[s+8],u===Eg||!pN(n,!1)?s=-1:(o=t[wn],s=_C(u),t=wC(u,t)));s!==-1;){let l=t[wn];if(mN(i,s,l.data)){let f=sfe(s,t,r,o,n,c);if(f!==lf)return f}u=t[s+8],u!==Eg&&pN(n,t[wn].data[s+8]===c)&&mN(i,s,t)?(o=l,s=_C(u),t=wC(u,t)):s=-1}}return a}function sfe(e,t,r,n,a,i){let o=t[wn],s=o.data[e+8],u=n==null?UC(s)&&_P:n!=o&&(s.type&3)!==0,c=a&_n.Host&&i===s,l=hC(s,o,r,u,c);return l!==null?Og(t,o,l,s):lf}function hC(e,t,r,n,a){let i=e.providerIndexes,o=t.data,s=i&1048575,u=e.directiveStart,c=e.directiveEnd,l=i>>20,f=n?s:s+l,d=a?s+l:c;for(let m=f;m=u&&h.type===r)return m}if(a){let m=o[u];if(m&&zb(m)&&m.type===r)return u}return null}function Og(e,t,r,n){let a=e[r],i=t.data;if(Jle(a)){let o=a;o.resolving&&Xce(Yce(i[r]));let s=dN(o.canSeeViewProviders);o.resolving=!0;let u,c=o.injectImpl?Sc(o.injectImpl):null,l=c5(e,n,_n.Default);try{a=e[r]=o.factory(void 0,i,e,n),t.firstCreatePass&&r>=n.directiveStart&&Qle(r,i[r],t)}finally{c!==null&&Sc(c),dN(s),o.resolving=!1,m5()}}return a}function ufe(e){if(typeof e=="string")return e.charCodeAt(0)||0;let t=e.hasOwnProperty(Ab)?e[Ab]:void 0;return typeof t=="number"?t>=0?t&x5:cfe:t}function mN(e,t,r){let n=1<>S5)]&n)}function pN(e,t){return!(e&_n.Self)&&!(e&_n.Host&&t)}var Sh=class{constructor(t,r){this._tNode=t,this._lView=r}get(t,r,n){return A5(this._tNode,this._lView,t,FC(n),r)}};function cfe(){return new Sh(ld(),ms())}function sE(e){return LC(()=>{let t=e.prototype.constructor,r=t[bC]||wP(t),n=Object.prototype,a=Object.getPrototypeOf(e.prototype).constructor;for(;a&&a!==n;){let i=a[bC]||wP(a);if(i&&i!==r)return i;a=Object.getPrototypeOf(a)}return i=>new i})}function wP(e){return MN(e)?()=>{let t=wP(Cc(e));return t&&t()}:Bg(e)}function lfe(e,t,r,n,a){let i=e,o=t;for(;i!==null&&o!==null&&o[Xr]&2048&&!(o[Xr]&512);){let s=D5(i,o,r,n|_n.Self,lf);if(s!==lf)return s;let u=i.parent;if(!u){let c=o[XN];if(c){let l=c.get(r,lf,n);if(l!==lf)return l}u=P5(o),o=o[Vb]}i=u}return a}function P5(e){let t=e[wn],r=t.type;return r===2?t.declTNode:r===1?e[Tl]:null}function ffe(e){return typeof e=="function"}function dfe(e,t,r){if(e.length!==t.length)return!1;for(let n=0;nArray.isArray(r)?uE(r,t):t(r))}function E5(e,t,r){t>=e.length?e.push(r):e.splice(t,0,r)}function TC(e,t){return t>=e.length-1?e.pop():e.splice(t,1)[0]}function pfe(e,t){let r=[];for(let n=0;n{r.push(o)};return uE(t,o=>{let s=o;TP(s,i,[],n)&&(a||=[],a.push(s))}),a!==void 0&&B5(a,i),r}function B5(e,t){for(let r=0;r{t(i,n)})}}function TP(e,t,r,n){if(e=Cc(e),!e)return!1;let a=null,i=tN(e),o=!i&&Ch(e);if(!i&&!o){let u=e.ngModule;if(i=tN(u),i)a=u;else return!1}else{if(o&&!o.standalone)return!1;a=e}let s=n.has(a);if(o){if(s)return!1;if(n.add(a),o.dependencies){let u=typeof o.dependencies=="function"?o.dependencies():o.dependencies;for(let c of u)TP(c,t,r,n)}}else if(i){if(i.imports!=null&&!s){n.add(a);let c;try{uE(i.imports,l=>{TP(l,t,r,n)&&(c||=[],c.push(l))})}finally{}c!==void 0&&B5(c,t)}if(!s){let c=Bg(a)||(()=>new a);t({provide:a,useFactory:c,deps:cf},a),t({provide:M5,useValue:a,multi:!0},a),t({provide:Hb,useValue:()=>On(a),multi:!0},a)}let u=i.providers;if(u!=null&&!s){let c=e;cE(u,l=>{t(l,c)})}}else return!1;return a!==e&&e.providers!==void 0}function cE(e,t){for(let r of e)RN(r)&&(r=r.\u0275providers),Array.isArray(r)?cE(r,t):t(r)}var vfe=ka({provide:String,useValue:ka});function O5(e){return e!==null&&typeof e=="object"&&vfe in e}function gfe(e){return!!(e&&e.useExisting)}function yfe(e){return!!(e&&e.useFactory)}function AP(e){return typeof e=="function"}var jC=new Nn("Set Injector scope."),vC={},bfe={},lP;function lE(){return lP===void 0&&(lP=new AC),lP}var _c=class{},Fb=class extends _c{get destroyed(){return this._destroyed}constructor(t,r,n,a){super(),this.parent=r,this.source=n,this.scopes=a,this.records=new Map,this._ngOnDestroyHooks=new Set,this._onDestroyHooks=[],this._destroyed=!1,PP(t,o=>this.processProvider(o)),this.records.set(I5,Dg(void 0,this)),a.has("environment")&&this.records.set(_c,Dg(void 0,this));let i=this.records.get(jC);i!=null&&typeof i.value=="string"&&this.scopes.add(i.value),this.injectorDefTypes=new Set(this.get(M5,cf,_n.Self))}destroy(){this.assertNotDestroyed(),this._destroyed=!0;try{for(let r of this._ngOnDestroyHooks)r.ngOnDestroy();let t=this._onDestroyHooks;this._onDestroyHooks=[];for(let r of t)r()}finally{this.records.clear(),this._ngOnDestroyHooks.clear(),this.injectorDefTypes.clear()}}onDestroy(t){return this.assertNotDestroyed(),this._onDestroyHooks.push(t),()=>this.removeOnDestroy(t)}runInContext(t){this.assertNotDestroyed();let r=hm(this),n=Sc(void 0),a;try{return t()}finally{hm(r),Sc(n)}}get(t,r=Ib,n=_n.Default){if(this.assertNotDestroyed(),t.hasOwnProperty(Jk))return t[Jk](this);n=FC(n);let a,i=hm(this),o=Sc(void 0);try{if(!(n&_n.SkipSelf)){let u=this.records.get(t);if(u===void 0){let c=Tfe(t)&&OC(t);c&&this.injectableDefInScope(c)?u=Dg(DP(t),vC):u=null,this.records.set(t,u)}if(u!=null)return this.hydrate(t,u)}let s=n&_n.Self?lE():this.parent;return r=n&_n.Optional&&r===Ib?null:r,s.get(t,r)}catch(s){if(s.name==="NullInjectorError"){if((s[xC]=s[xC]||[]).unshift(pu(t)),i)throw s;return sle(s,t,"R3InjectorError",this.source)}else throw s}finally{Sc(o),hm(i)}}resolveInjectorInitializers(){let t=hm(this),r=Sc(void 0),n;try{let a=this.get(Hb,cf,_n.Self);for(let i of a)i()}finally{hm(t),Sc(r)}}toString(){let t=[],r=this.records;for(let n of r.keys())t.push(pu(n));return`R3Injector[${t.join(", ")}]`}assertNotDestroyed(){if(this._destroyed)throw new Qr(205,!1)}processProvider(t){t=Cc(t);let r=AP(t)?t:Cc(t&&t.provide),n=Sfe(t);if(!AP(t)&&t.multi===!0){let a=this.records.get(r);a||(a=Dg(void 0,vC,!0),a.factory=()=>yP(a.multi),this.records.set(r,a)),r=t,a.multi.push(t)}else{let a=this.records.get(r)}this.records.set(r,n)}hydrate(t,r){return r.value===vC&&(r.value=bfe,r.value=r.factory()),typeof r.value=="object"&&r.value&&wfe(r.value)&&this._ngOnDestroyHooks.add(r.value),r.value}injectableDefInScope(t){if(!t.providedIn)return!1;let r=Cc(t.providedIn);return typeof r=="string"?r==="any"||this.scopes.has(r):this.injectorDefTypes.has(r)}removeOnDestroy(t){let r=this._onDestroyHooks.indexOf(t);r!==-1&&this._onDestroyHooks.splice(r,1)}};function DP(e){let t=OC(e),r=t!==null?t.factory:Bg(e);if(r!==null)return r;if(e instanceof Nn)throw new Qr(204,!1);if(e instanceof Function)return xfe(e);throw new Qr(204,!1)}function xfe(e){let t=e.length;if(t>0){let n=pfe(t,"?");throw new Qr(204,!1)}let r=Qce(e);return r!==null?()=>r.factory(e):()=>new e}function Sfe(e){if(O5(e))return Dg(void 0,e.useValue);{let t=Cfe(e);return Dg(t,vC)}}function Cfe(e,t,r){let n;if(AP(e)){let a=Cc(e);return Bg(a)||DP(a)}else if(O5(e))n=()=>Cc(e.useValue);else if(yfe(e))n=()=>e.useFactory(...yP(e.deps||[]));else if(gfe(e))n=()=>On(Cc(e.useExisting));else{let a=Cc(e&&(e.useClass||e.provide));if(_fe(e))n=()=>new a(...yP(e.deps));else return Bg(a)||DP(a)}return n}function Dg(e,t,r=!1){return{factory:e,value:t,multi:r?[]:void 0}}function _fe(e){return!!e.deps}function wfe(e){return e!==null&&typeof e=="object"&&typeof e.ngOnDestroy=="function"}function Tfe(e){return typeof e=="function"||typeof e=="object"&&e instanceof Nn}function PP(e,t){for(let r of e)Array.isArray(r)?PP(r,t):r&&RN(r)?PP(r.\u0275providers,t):t(r)}function Eh(e,t){e instanceof Fb&&e.assertNotDestroyed();let r,n=hm(e),a=Sc(void 0);try{return t()}finally{hm(n),Sc(a)}}function hN(e,t=null,r=null,n){let a=F5(e,t,r,n);return a.resolveInjectorInitializers(),a}function F5(e,t=null,r=null,n,a=new Set){let i=[r||cf,hfe(e)];return n=n||(typeof e=="object"?void 0:pu(e)),new Fb(i,t||lE(),n||null,a)}var Ug=(()=>{let t=class t{static create(n,a){if(Array.isArray(n))return hN({name:""},a,n,"");{let i=n.name??"";return hN({name:i},n.parent,n.providers,i)}}};t.THROW_IF_NOT_FOUND=Ib,t.NULL=new AC,t.\u0275prov=un({token:t,providedIn:"any",factory:()=>On(I5)}),t.__NG_ELEMENT_ID__=-1;let e=t;return e})();var EP;function L5(e){EP=e}function Afe(){if(EP!==void 0)return EP;if(typeof document<"u")return document;throw new Qr(210,!1)}var fE=new Nn("AppId",{providedIn:"root",factory:()=>Dfe}),Dfe="ng",dE=new Nn("Platform Initializer"),Vg=new Nn("Platform ID",{providedIn:"platform",factory:()=>"unknown"});var mE=new Nn("CSP nonce",{providedIn:"root",factory:()=>Afe().body?.querySelector("[ngCspNonce]")?.getAttribute("ngCspNonce")||null});function k5(e){return e instanceof Function?e():e}function N5(e){return(e.flags&128)===128}var Ih=function(e){return e[e.Important=1]="Important",e[e.DashCase=2]="DashCase",e}(Ih||{});var U5=new Map,Pfe=0;function Efe(){return Pfe++}function Ife(e){U5.set(e[NC],e)}function Mfe(e){U5.delete(e[NC])}var vN="__ngContext__";function Fg(e,t){xh(t)?(e[vN]=t[NC],Ife(t)):e[vN]=t}var Rfe;function pE(e,t){return Rfe(e,t)}function hE(e){let t=e[fo];return wl(t)?t[fo]:t}function V5(e){return z5(e[Bb])}function G5(e){return z5(e[_l])}function z5(e){for(;e!==null&&!wl(e);)e=e[_l];return e}function Pg(e,t,r,n,a){if(n!=null){let i,o=!1;wl(n)?i=n:xh(n)&&(o=!0,n=n[cd]);let s=sd(n);e===0&&r!==null?a==null?W5(t,r,s):DC(t,r,s,a||null,!0):e===1&&r!==null?DC(t,r,s,a||null,!0):e===2?Zfe(t,s,o):e===3&&t.destroyNode(s),i!=null&&$fe(t,e,i,r,a)}}function Bfe(e,t){return e.createText(t)}function Ofe(e,t,r){e.setValue(t,r)}function H5(e,t,r){return e.createElement(t,r)}function Ffe(e,t){let r=t[Yu];jb(e,t,r,2,null,null),t[cd]=null,t[Tl]=null}function Lfe(e,t,r,n,a,i){n[cd]=a,n[Tl]=t,jb(e,n,r,1,a,i)}function kfe(e,t){jb(e,t,t[Yu],2,null,null)}function Nfe(e){let t=e[Bb];if(!t)return fP(e[wn],e);for(;t;){let r=null;if(xh(t))r=t[Bb];else{let n=t[Wu];n&&(r=n)}if(!r){for(;t&&!t[_l]&&t!==e;)xh(t)&&fP(t[wn],t),t=t[fo];t===null&&(t=e),xh(t)&&fP(t[wn],t),r=t&&t[_l]}t=r}}function Ufe(e,t,r,n){let a=Wu+n,i=r.length;n>0&&(r[a-1][_l]=t),n0&&(e[r-1][_l]=n[_l]);let i=TC(e,Wu+t);Ffe(n[wn],n);let o=i[ff];o!==null&&o.detachView(i[wn]),n[fo]=null,n[_l]=null,n[Xr]&=-129}return n}function q5(e,t){if(!(t[Xr]&256)){let r=t[Yu];t[_h]&&Sk(t[_h]),r.destroyNode&&jb(e,t,r,3,null,null),Nfe(t)}}function fP(e,t){if(!(t[Xr]&256)){t[Xr]&=-129,t[Xr]|=256,zfe(e,t),Gfe(e,t),t[wn].type===1&&t[Yu].destroy();let r=t[Gb];if(r!==null&&wl(t[fo])){r!==t[fo]&&j5(r,t);let n=t[ff];n!==null&&n.detachView(e)}Mfe(t)}}function Gfe(e,t){let r=e.cleanup,n=t[SC];if(r!==null)for(let i=0;i=0?n[o]():n[-o].unsubscribe(),i+=2}else{let o=n[r[i+1]];r[i].call(o)}n!==null&&(t[SC]=null);let a=t[Eb];if(a!==null){t[Eb]=null;for(let i=0;i-1){let{encapsulation:i}=e.data[n.directiveStart+a];if(i===df.None||i===df.Emulated)return null}return pf(n,r)}}function DC(e,t,r,n,a){e.insertBefore(t,r,n,a)}function W5(e,t,r){e.appendChild(t,r)}function gN(e,t,r,n,a){n!==null?DC(e,t,r,n,a):W5(e,t,r)}function qfe(e,t,r,n){e.removeChild(t,r,n)}function vE(e,t){return e.parentNode(t)}function Wfe(e,t){return e.nextSibling(t)}function Yfe(e,t,r){return Kfe(e,t,r)}function Xfe(e,t,r){return e.type&40?pf(e,r):null}var Kfe=Xfe,yN;function Y5(e,t,r,n){let a=Hfe(e,n,t),i=t[Yu],o=n.parent||t[Tl],s=Yfe(o,n,t);if(a!=null)if(Array.isArray(r))for(let u=0;unull;function yE(e,t,r=!1){return rde(e,t,r)}var RP=class{},PC=class{};function nde(e){let t=Error(`No component factory found for ${pu(e)}.`);return t[ade]=e,t}var ade="ngComponent";var BP=class{resolveComponentFactory(t){throw nde(t)}},qC=(()=>{let t=class t{};t.NULL=new BP;let e=t;return e})();function ide(){return Gg(ld(),ms())}function Gg(e,t){return new Mh(pf(e,t))}var Mh=(()=>{let t=class t{constructor(n){this.nativeElement=n}};t.__NG_ELEMENT_ID__=ide;let e=t;return e})();function ode(e){return e instanceof Mh?e.nativeElement:e}var Lb=class{};var sde=(()=>{let t=class t{};t.\u0275prov=un({token:t,providedIn:"root",factory:()=>null});let e=t;return e})(),Lg=class{constructor(t){this.full=t,this.major=t.split(".")[0],this.minor=t.split(".")[1],this.patch=t.split(".").slice(2).join(".")}},ude=new Lg("17.0.5"),dP={};function EC(e,t,r,n,a=!1){for(;r!==null;){let i=t[r.index];i!==null&&n.push(sd(i)),wl(i)&&cde(i,n);let o=r.type;if(o&8)EC(e,t,r.child,n);else if(o&32){let s=pE(r,t),u;for(;u=s();)n.push(u)}else if(o&16){let s=X5(t,r);if(Array.isArray(s))n.push(...s);else{let u=hE(t[mf]);EC(u[wn],u,s,n,!0)}}r=a?r.projectionNext:r.next}return n}function cde(e,t){for(let r=Wu;r{GC(e.lView)},consumerOnSignalRead(){this.lView[_h]=this}}),pde="ngOriginalError";function mP(e){return e[pde]}var ud=class{constructor(){this._console=console}handleError(t){let r=this._findOriginalError(t);this._console.error("ERROR",t),r&&this._console.error("ORIGINAL ERROR",r)}_findOriginalError(t){let r=t&&mP(t);for(;r&&mP(r);)r=mP(r);return r||null}};var $5=!1,hde=new Nn("",{providedIn:"root",factory:()=>$5});var WC={};function bE(e){J5(Ph(),ms(),iE()+e,!1)}function J5(e,t,r,n){if(!n)if((t[Xr]&3)===3){let i=e.preOrderCheckHooks;i!==null&&mC(t,i,r)}else{let i=e.preOrderHooks;i!==null&&pC(t,i,0,r)}Ah(r)}function xE(e,t=_n.Default){let r=ms();if(r===null)return On(e,t);let n=ld();return A5(n,r,Cc(e),t)}function vde(e,t){let r=e.hostBindingOpCodes;if(r!==null)try{for(let n=0;nwh&&J5(e,t,wh,!1),vm(o?2:0,a),r(n,a)}finally{Ah(i),vm(o?3:1,a)}}function rU(e,t,r){if(ZN(t)){let n=qu(null);try{let a=t.directiveStart,i=t.directiveEnd;for(let o=a;onull;function wde(e,t,r,n){let a=jde(t);a.push(r),e.firstCreatePass&&qde(e).push(n,a.length-1)}function Tde(e,t,r,n,a,i){let o=t?t.injectorIndex:-1,s=0;return Ule()&&(s|=128),{type:r,index:n,insertBeforeIndex:null,injectorIndex:o,directiveStart:-1,directiveEnd:-1,directiveStylingLast:-1,componentOffset:-1,propertyBindings:null,flags:s,providerIndexes:0,value:a,attrs:i,mergedAttrs:null,localNames:null,initialInputs:void 0,inputs:null,outputs:null,tView:null,next:null,prev:null,projectionNext:null,child:null,parent:t,projection:null,styles:null,stylesWithoutHost:null,residualStyles:void 0,classes:null,classesWithoutHost:null,residualClasses:void 0,classBindings:0,styleBindings:0}}function bN(e,t,r,n){for(let a in e)if(e.hasOwnProperty(a)){r=r===null?{}:r;let i=e[a];n===null?xN(r,t,a,i):n.hasOwnProperty(a)&&xN(r,t,n[a],i)}return r}function xN(e,t,r,n){e.hasOwnProperty(r)?e[r].push(t,n):e[r]=[t,n]}function Ade(e,t,r){let n=t.directiveStart,a=t.directiveEnd,i=e.data,o=t.attrs,s=[],u=null,c=null;for(let l=n;l0;){let r=e[--t];if(typeof r=="number"&&r<0)return r}return 0}function Bde(e,t,r,n){let a=r.directiveStart,i=r.directiveEnd;UC(r)&&Vde(t,r,e.data[a+r.componentOffset]),e.firstCreatePass||C5(r,t),Fg(n,t);let o=r.initialInputs;for(let s=a;s-1&&(IP(t,n),TC(r,n))}this._attachedToViewContainer=!1}q5(this._lView[wn],this._lView)}onDestroy(t){Fle(this._lView,t)}markForCheck(){pU(this._cdRefInjectingView||this._lView)}detach(){this._lView[Xr]&=-129}reattach(){n5(this._lView),this._lView[Xr]|=128}detectChanges(){Kde(this._lView,this.notifyErrorHandler)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new Qr(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,kfe(this._lView[wn],this._lView)}attachToAppRef(t){if(this._attachedToViewContainer)throw new Qr(902,!1);this._appRef=t}},XC=(()=>{let t=class t{};t.__NG_ELEMENT_ID__=eme;let e=t;return e})();function eme(e){return tme(ld(),ms(),(e&16)===16)}function tme(e,t,r){if(UC(e)&&!r){let n=Ng(e.index,t);return new Dh(n,n)}else if(e.type&47){let n=t[mf];return new Dh(n,t)}return null}var SN=new Set;function hU(e){SN.has(e)||(SN.add(e),performance?.mark?.("mark_use_counter",{detail:{feature:e}}))}var LP=class extends kr{constructor(t=!1){super(),this.__isAsync=t}emit(t){super.next(t)}subscribe(t,r,n){let a=t,i=r||(()=>null),o=n;if(t&&typeof t=="object"){let u=t;a=u.next?.bind(u),i=u.error?.bind(u),o=u.complete?.bind(u)}this.__isAsync&&(i=pP(i),a&&(a=pP(a)),o&&(o=pP(o)));let s=super.subscribe({next:a,error:i,complete:o});return t instanceof co&&t.add(s),s}};function pP(e){return t=>{setTimeout(e,void 0,t)}}var Hs=LP;function CN(...e){}function rme(){let e=typeof Db.requestAnimationFrame=="function",t=Db[e?"requestAnimationFrame":"setTimeout"],r=Db[e?"cancelAnimationFrame":"clearTimeout"];if(typeof Zone<"u"&&t&&r){let n=t[Zone.__symbol__("OriginalDelegate")];n&&(t=n);let a=r[Zone.__symbol__("OriginalDelegate")];a&&(r=a)}return{nativeRequestAnimationFrame:t,nativeCancelAnimationFrame:r}}var lo=class e{constructor({enableLongStackTrace:t=!1,shouldCoalesceEventChangeDetection:r=!1,shouldCoalesceRunChangeDetection:n=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new Hs(!1),this.onMicrotaskEmpty=new Hs(!1),this.onStable=new Hs(!1),this.onError=new Hs(!1),typeof Zone>"u")throw new Qr(908,!1);Zone.assertZonePatched();let a=this;a._nesting=0,a._outer=a._inner=Zone.current,Zone.TaskTrackingZoneSpec&&(a._inner=a._inner.fork(new Zone.TaskTrackingZoneSpec)),t&&Zone.longStackTraceZoneSpec&&(a._inner=a._inner.fork(Zone.longStackTraceZoneSpec)),a.shouldCoalesceEventChangeDetection=!n&&r,a.shouldCoalesceRunChangeDetection=n,a.lastRequestAnimationFrameId=-1,a.nativeRequestAnimationFrame=rme().nativeRequestAnimationFrame,ime(a)}static isInAngularZone(){return typeof Zone<"u"&&Zone.current.get("isAngularZone")===!0}static assertInAngularZone(){if(!e.isInAngularZone())throw new Qr(909,!1)}static assertNotInAngularZone(){if(e.isInAngularZone())throw new Qr(909,!1)}run(t,r,n){return this._inner.run(t,r,n)}runTask(t,r,n,a){let i=this._inner,o=i.scheduleEventTask("NgZoneEvent: "+a,t,nme,CN,CN);try{return i.runTask(o,r,n)}finally{i.cancelTask(o)}}runGuarded(t,r,n){return this._inner.runGuarded(t,r,n)}runOutsideAngular(t){return this._outer.run(t)}},nme={};function wE(e){if(e._nesting==0&&!e.hasPendingMicrotasks&&!e.isStable)try{e._nesting++,e.onMicrotaskEmpty.emit(null)}finally{if(e._nesting--,!e.hasPendingMicrotasks)try{e.runOutsideAngular(()=>e.onStable.emit(null))}finally{e.isStable=!0}}}function ame(e){e.isCheckStableRunning||e.lastRequestAnimationFrameId!==-1||(e.lastRequestAnimationFrameId=e.nativeRequestAnimationFrame.call(Db,()=>{e.fakeTopEventTask||(e.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{e.lastRequestAnimationFrameId=-1,kP(e),e.isCheckStableRunning=!0,wE(e),e.isCheckStableRunning=!1},void 0,()=>{},()=>{})),e.fakeTopEventTask.invoke()}),kP(e))}function ime(e){let t=()=>{ame(e)};e._inner=e._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(r,n,a,i,o,s)=>{if(ome(s))return r.invokeTask(a,i,o,s);try{return _N(e),r.invokeTask(a,i,o,s)}finally{(e.shouldCoalesceEventChangeDetection&&i.type==="eventTask"||e.shouldCoalesceRunChangeDetection)&&t(),wN(e)}},onInvoke:(r,n,a,i,o,s,u)=>{try{return _N(e),r.invoke(a,i,o,s,u)}finally{e.shouldCoalesceRunChangeDetection&&t(),wN(e)}},onHasTask:(r,n,a,i)=>{r.hasTask(a,i),n===a&&(i.change=="microTask"?(e._hasPendingMicrotasks=i.microTask,kP(e),wE(e)):i.change=="macroTask"&&(e.hasPendingMacrotasks=i.macroTask))},onHandleError:(r,n,a,i)=>(r.handleError(a,i),e.runOutsideAngular(()=>e.onError.emit(i)),!1)})}function kP(e){e._hasPendingMicrotasks||(e.shouldCoalesceEventChangeDetection||e.shouldCoalesceRunChangeDetection)&&e.lastRequestAnimationFrameId!==-1?e.hasPendingMicrotasks=!0:e.hasPendingMicrotasks=!1}function _N(e){e._nesting++,e.isStable&&(e.isStable=!1,e.onUnstable.emit(null))}function wN(e){e._nesting--,wE(e)}var vU=new Nn("",{providedIn:"root",factory:gU});function gU(){let e=br(lo),t=!0,r=new qn(a=>{t=e.isStable&&!e.hasPendingMacrotasks&&!e.hasPendingMicrotasks,e.runOutsideAngular(()=>{a.next(t),a.complete()})}),n=new qn(a=>{let i;e.runOutsideAngular(()=>{i=e.onStable.subscribe(()=>{lo.assertNotInAngularZone(),queueMicrotask(()=>{!t&&!e.hasPendingMacrotasks&&!e.hasPendingMicrotasks&&(t=!0,a.next(!0))})})});let o=e.onUnstable.subscribe(()=>{lo.assertInAngularZone(),t&&(t=!1,e.runOutsideAngular(()=>{a.next(!1)}))});return()=>{i.unsubscribe(),o.unsubscribe()}});return mu(r,n.pipe(wg()))}function ome(e){return!Array.isArray(e)||e.length!==1?!1:e[0].data?.__ignore_ng_zone__===!0}var sme=(()=>{let t=class t{constructor(){this.renderDepth=0,this.handler=null,this.internalCallbacks=[]}begin(){this.handler?.validateBegin(),this.renderDepth++}end(){if(this.renderDepth--,this.renderDepth===0){for(let n of this.internalCallbacks)n();this.internalCallbacks.length=0,this.handler?.execute()}}ngOnDestroy(){this.handler?.destroy(),this.handler=null,this.internalCallbacks.length=0}};t.\u0275prov=un({token:t,providedIn:"root",factory:()=>new t});let e=t;return e})();function ume(e,t){let r=Ng(t,e),n=r[wn];cme(n,r);let a=r[cd];a!==null&&r[xP]===null&&(r[xP]=yE(a,r[Ig])),TE(n,r,r[od])}function cme(e,t){for(let r=t.length;r0&&K5(e,r,i.join(" "))}}function gme(e,t,r){let n=e.projection=[];for(let a=0;anull;function DN(e,t){return xme(e,t)}function Sme(e,t,r,n){let a=t.tView,o=e[Xr]&4096?4096:16,s=YC(e,a,r,o,null,t,null,null,null,n?.injector??null,n?.dehydratedView??null),u=e[t.index];s[Gb]=u;let c=e[ff];return c!==null&&(s[ff]=c.createEmbeddedView(a)),TE(a,s,r),s}function PN(e,t){return!t||N5(e)}function Cme(e,t,r,n=!0){let a=t[wn];if(Ufe(a,t,e,r),n){let i=MP(r,e),o=t[Yu],s=vE(o,e[Th]);s!==null&&Lfe(a,e[Tl],o,t,s,i)}}var zg=(()=>{let t=class t{};t.__NG_ELEMENT_ID__=_me;let e=t;return e})();function _me(){let e=ld();return xU(e,ms())}var wme=zg,bU=class extends wme{constructor(t,r,n){super(),this._lContainer=t,this._hostTNode=r,this._hostLView=n}get element(){return Gg(this._hostTNode,this._hostLView)}get injector(){return new Sh(this._hostTNode,this._hostLView)}get parentInjector(){let t=oE(this._hostTNode,this._hostLView);if(b5(t)){let r=wC(t,this._hostLView),n=_C(t),a=r[wn].data[n+8];return new Sh(a,r)}else return new Sh(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(t){let r=EN(this._lContainer);return r!==null&&r[t]||null}get length(){return this._lContainer.length-Wu}createEmbeddedView(t,r,n){let a,i;typeof n=="number"?a=n:n!=null&&(a=n.index,i=n.injector);let o=DN(this._lContainer,t.ssrId),s=t.createEmbeddedViewImpl(r||{},i,o);return this.insertImpl(s,a,PN(this._hostTNode,o)),s}createComponent(t,r,n,a,i){let o=t&&!ffe(t),s;if(o)s=r;else{let h=r||{};s=h.index,n=h.injector,a=h.projectableNodes,i=h.environmentInjector||h.ngModuleRef}let u=o?t:new kb(Ch(t)),c=n||this.parentInjector;if(!i&&u.ngModule==null){let p=(o?c:this.parentInjector).get(_c,null);p&&(i=p)}let l=Ch(u.componentType??{}),f=DN(this._lContainer,l?.id??null),d=f?.firstChild??null,m=u.create(c,a,d,i);return this.insertImpl(m.hostView,s,PN(this._hostTNode,f)),m}insert(t,r){return this.insertImpl(t,r,!0)}insertImpl(t,r,n){let a=t._lView;if(Ble(a)){let s=this.indexOf(t);if(s!==-1)this.detach(s);else{let u=a[fo],c=new bU(u,u[Tl],u[fo]);c.detach(c.indexOf(t))}}let i=this._adjustIndex(r),o=this._lContainer;return Cme(o,a,i,n),t.attachToViewContainerRef(),E5(hP(o),i,t),t}move(t,r){return this.insert(t,r)}indexOf(t){let r=EN(this._lContainer);return r!==null?r.indexOf(t):-1}remove(t){let r=this._adjustIndex(t,-1),n=IP(this._lContainer,r);n&&(TC(hP(this._lContainer),r),q5(n[wn],n))}detach(t){let r=this._adjustIndex(t,-1),n=IP(this._lContainer,r);return n&&TC(hP(this._lContainer),r)!=null?new Dh(n):null}_adjustIndex(t,r=0){return t??this.length+r}};function EN(e){return e[CC]}function hP(e){return e[CC]||(e[CC]=[])}function xU(e,t){let r,n=t[e.index];return wl(n)?r=n:(r=Hde(n,t,null,e),t[e.index]=r,CE(t,r)),Ame(r,t,e,n),new bU(r,e,t)}function Tme(e,t){let r=e[Yu],n=r.createComment(""),a=pf(t,e),i=vE(r,a);return DC(r,i,n,Wfe(r,a),!1),n}var Ame=Dme;function Dme(e,t,r,n){if(e[Th])return;let a;r.type&8?a=sd(n):a=Tme(t,r),e[Th]=a}function Pme(e,t,r,n,a,i){let o=t.consts,s=lN(o,a),u=SE(t,e,2,n,s);return Ide(t,r,u,lN(o,i)),u.attrs!==null&&NP(u,u.attrs,!1),u.mergedAttrs!==null&&NP(u,u.mergedAttrs,!0),t.queries!==null&&t.queries.elementStart(t,u),u}function Rh(e,t,r,n){let a=ms(),i=Ph(),o=wh+e,s=a[Yu],u=i.firstCreatePass?Pme(o,i,a,t,r,n):i.data[o],c=Eme(i,a,u,s,t,e);a[o]=c;let l=wle(u);return zC(u,!0),Z5(s,c,u),(u.flags&32)!==32&&h5()&&Y5(i,a,c,u),Lle()===0&&Fg(c,a),kle(),l&&(yde(i,a,u),rU(i,u,a)),n!==null&&bde(a,u),Rh}function Bh(){let e=ld();o5()?Hle():(e=e.parent,zC(e,!1));let t=e;Vle(t)&&Gle(),Nle();let r=Ph();return r.firstCreatePass&&(g5(r,e),ZN(e)&&r.queries.elementEnd(e)),t.classesWithoutHost!=null&&efe(t)&&AN(r,t,ms(),t.classesWithoutHost,!0),t.stylesWithoutHost!=null&&tfe(t)&&AN(r,t,ms(),t.stylesWithoutHost,!1),Bh}function Oh(e,t,r,n){return Rh(e,t,r,n),Bh(),Oh}var Eme=(e,t,r,n,a,i)=>(v5(!0),H5(n,a,Zle()));var MC="en-US";var Ime=MC;function Mme(e){Kce(e,"Expected localeId to be defined"),typeof e=="string"&&(Ime=e.toLowerCase().replace(/_/g,"-"))}function qb(e){return!!e&&typeof e.then=="function"}function SU(e){return!!e&&typeof e.subscribe=="function"}function CU(e,t=""){let r=ms(),n=Ph(),a=e+wh,i=n.firstCreatePass?SE(n,a,1,t,null):n.data[a],o=Rme(n,r,i,t,e);r[a]=o,h5()&&Y5(n,r,o,i),zC(i,!1)}var Rme=(e,t,r,n,a)=>(v5(!0),Bfe(t[Yu],n));function DE(e){return _U("",e,""),DE}function _U(e,t,r){let n=ms(),a=bme(n,e,t,r);return a!==WC&&Yde(n,iE(),a),_U}var gm=class{},Nb=class{};var GP=class extends gm{constructor(t,r,n){super(),this._parent=r,this._bootstrapComponents=[],this.destroyCbs=[],this.componentFactoryResolver=new IC(this);let a=qN(t);this._bootstrapComponents=k5(a.bootstrap),this._r3Injector=F5(t,r,[{provide:gm,useValue:this},{provide:qC,useValue:this.componentFactoryResolver},...n],pu(t),new Set(["environment"])),this._r3Injector.resolveInjectorInitializers(),this.instance=this._r3Injector.get(t)}get injector(){return this._r3Injector}destroy(){let t=this._r3Injector;!t.destroyed&&t.destroy(),this.destroyCbs.forEach(r=>r()),this.destroyCbs=null}onDestroy(t){this.destroyCbs.push(t)}},zP=class extends Nb{constructor(t){super(),this.moduleType=t}create(t){return new GP(this.moduleType,t,[])}};var RC=class extends gm{constructor(t){super(),this.componentFactoryResolver=new IC(this),this.instance=null;let r=new Fb([...t.providers,{provide:gm,useValue:this},{provide:qC,useValue:this.componentFactoryResolver}],t.parent||lE(),t.debugName,new Set(["environment"]));this.injector=r,t.runEnvironmentInitializers&&r.resolveInjectorInitializers()}destroy(){this.injector.destroy()}onDestroy(t){this.injector.onDestroy(t)}};function PE(e,t,r=null){return new RC({providers:e,parent:t,debugName:r,runEnvironmentInitializers:!0}).injector}var Bme=(()=>{let t=class t{constructor(n){this._injector=n,this.cachedInjectors=new Map}getOrCreateStandaloneInjector(n){if(!n.standalone)return null;if(!this.cachedInjectors.has(n)){let a=R5(!1,n.type),i=a.length>0?PE([a],this._injector,`Standalone[${n.type.name}]`):null;this.cachedInjectors.set(n,i)}return this.cachedInjectors.get(n)}ngOnDestroy(){try{for(let n of this.cachedInjectors.values())n!==null&&n.destroy()}finally{this.cachedInjectors.clear()}}};t.\u0275prov=un({token:t,providedIn:"environment",factory:()=>new t(On(_c))});let e=t;return e})();function Hg(e){hU("NgStandalone"),e.getStandaloneInjector=t=>t.get(Bme).getOrCreateStandaloneInjector(e)}function Ome(){return this._results[Symbol.iterator]()}var HP=class e{get changes(){return this._changes||(this._changes=new Hs)}constructor(t=!1){this._emitDistinctChangesOnly=t,this.dirty=!0,this._results=[],this._changesDetected=!1,this._changes=null,this.length=0,this.first=void 0,this.last=void 0;let r=e.prototype;r[Symbol.iterator]||(r[Symbol.iterator]=Ome)}get(t){return this._results[t]}map(t){return this._results.map(t)}filter(t){return this._results.filter(t)}find(t){return this._results.find(t)}reduce(t,r){return this._results.reduce(t,r)}forEach(t){this._results.forEach(t)}some(t){return this._results.some(t)}toArray(){return this._results.slice()}toString(){return this._results.toString()}reset(t,r){this.dirty=!1;let n=mfe(t);(this._changesDetected=!dfe(this._results,n,r))&&(this._results=n,this.length=n.length,this.last=n[this.length-1],this.first=n[0])}notifyOnChanges(){this._changes&&(this._changesDetected||!this._emitDistinctChangesOnly)&&this._changes.emit(this)}setDirty(){this.dirty=!0}destroy(){this.changes.complete(),this.changes.unsubscribe()}},Ub=(()=>{let t=class t{};t.__NG_ELEMENT_ID__=kme;let e=t;return e})(),Fme=Ub,Lme=class extends Fme{constructor(t,r,n){super(),this._declarationLView=t,this._declarationTContainer=r,this.elementRef=n}get ssrId(){return this._declarationTContainer.tView?.ssrId||null}createEmbeddedView(t,r){return this.createEmbeddedViewImpl(t,r)}createEmbeddedViewImpl(t,r,n){let a=Sme(this._declarationLView,this._declarationTContainer,t,{injector:r,dehydratedView:n});return new Dh(a)}};function kme(){return EE(ld(),ms())}function EE(e,t){return e.type&4?new Lme(t,e,Gg(e,t)):null}var jP=class e{constructor(t){this.queryList=t,this.matches=null}clone(){return new e(this.queryList)}setDirty(){this.queryList.setDirty()}},qP=class e{constructor(t=[]){this.queries=t}createEmbeddedView(t){let r=t.queries;if(r!==null){let n=t.contentQueries!==null?t.contentQueries[0]:r.length,a=[];for(let i=0;i0)n.push(o[s/2]);else{let c=i[s+1],l=t[-u];for(let f=Wu;f{let t=class t{constructor(){this.initialized=!1,this.done=!1,this.donePromise=new Promise((n,a)=>{this.resolve=n,this.reject=a}),this.appInits=br(AU,{optional:!0})??[]}runInitializers(){if(this.initialized)return;let n=[];for(let i of this.appInits){let o=i();if(qb(o))n.push(o);else if(SU(o)){let s=new Promise((u,c)=>{o.subscribe({complete:u,error:c})});n.push(s)}}let a=()=>{this.done=!0,this.resolve()};Promise.all(n).then(()=>{a()}).catch(i=>{this.reject(i)}),n.length===0&&a(),this.initialized=!0}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),QC=(()=>{let t=class t{log(n){console.log(n)}warn(n){console.warn(n)}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"platform"});let e=t;return e})();function qme(){return typeof $localize<"u"&&$localize.locale||MC}var ME=new Nn("LocaleId",{providedIn:"root",factory:()=>br(ME,_n.Optional|_n.SkipSelf)||qme()});var RE=(()=>{let t=class t{constructor(){this.taskId=0,this.pendingTasks=new Set,this.hasPendingTasks=new ha(!1)}add(){this.hasPendingTasks.next(!0);let n=this.taskId++;return this.pendingTasks.add(n),n}remove(n){this.pendingTasks.delete(n),this.pendingTasks.size===0&&this.hasPendingTasks.next(!1)}ngOnDestroy(){this.pendingTasks.clear(),this.hasPendingTasks.next(!1)}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),ZP=class{constructor(t,r){this.ngModuleFactory=t,this.componentFactories=r}},BE=(()=>{let t=class t{compileModuleSync(n){return new zP(n)}compileModuleAsync(n){return Promise.resolve(this.compileModuleSync(n))}compileModuleAndAllComponentsSync(n){let a=this.compileModuleSync(n),i=qN(n),o=k5(i.declarations).reduce((s,u)=>{let c=Ch(u);return c&&s.push(new kb(c)),s},[]);return new ZP(a,o)}compileModuleAndAllComponentsAsync(n){return Promise.resolve(this.compileModuleAndAllComponentsSync(n))}clearCache(){}clearCacheFor(n){}getModuleId(n){}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})();var PU=new Nn("");var yC=null;var EU=new Nn("PlatformDestroyListeners"),OE=new Nn("appBootstrapListener");function Wme(){Ck(()=>{throw new Qr(600,!1)})}function Yme(e){return e.isBoundToModule}function Xme(e=[]){if(yC)return yC;let t=Zme(e);return yC=t,Wme(),Kme(t),t}function Kme(e){e.get(dE,null)?.forEach(r=>r())}function IU(e){try{let{rootComponent:t,appProviders:r,platformProviders:n}=e,a=Xme(n),i=[rpe(),...r||[]],s=new RC({providers:i,parent:a,debugName:"",runEnvironmentInitializers:!1}).injector,u=s.get(lo);return u.run(()=>{s.resolveInjectorInitializers();let c=s.get(ud,null),l;u.runOutsideAngular(()=>{l=u.onError.subscribe({next:m=>{c.handleError(m)}})});let f=()=>s.destroy(),d=a.get(EU);return d.add(f),s.onDestroy(()=>{l.unsubscribe(),d.delete(f)}),$me(c,u,()=>{let m=s.get(DU);return m.runInitializers(),m.donePromise.then(()=>{let h=s.get(ME,MC);Mme(h||MC);let p=s.get(Wb);return t!==void 0&&p.bootstrap(t),p})})})}catch(t){return Promise.reject(t)}}function Zme(e=[],t){return Ug.create({name:t,providers:[{provide:jC,useValue:"platform"},{provide:EU,useValue:new Set([()=>yC=null])},...e]})}function Qme(e){return{enableLongStackTrace:!1,shouldCoalesceEventChangeDetection:e?.eventCoalescing??!1,shouldCoalesceRunChangeDetection:e?.runCoalescing??!1}}function $me(e,t,r){try{let n=r();return qb(n)?n.catch(a=>{throw t.runOutsideAngular(()=>e.handleError(a)),a}):n}catch(n){throw t.runOutsideAngular(()=>e.handleError(n)),n}}var Wb=(()=>{let t=class t{constructor(){this._bootstrapListeners=[],this._runningTick=!1,this._destroyed=!1,this._destroyListeners=[],this._views=[],this.internalErrorHandler=br(MU),this.zoneIsStable=br(vU),this.componentTypes=[],this.components=[],this.isStable=br(RE).hasPendingTasks.pipe(ds(n=>n?Yr(!1):this.zoneIsStable),Cg(),wg()),this._injector=br(_c)}get destroyed(){return this._destroyed}get injector(){return this._injector}bootstrap(n,a){let i=n instanceof PC;if(!this._injector.get(DU).done){let h="Cannot bootstrap as there are still asynchronous initializers running."+(!i&&jN(n)?"":" Bootstrap components in the `ngDoBootstrap` method of the root module.");throw new Qr(405,!1)}let s;i?s=n:s=this._injector.get(qC).resolveComponentFactory(n),this.componentTypes.push(s.componentType);let u=Yme(s)?void 0:this._injector.get(gm),c=a||s.selector,l=s.create(Ug.NULL,[],c,u),f=l.location.nativeElement,d=l.injector.get(PU,null);return d?.registerApplication(f),l.onDestroy(()=>{this.detachView(l.hostView),vP(this.components,l),d?.unregisterApplication(f)}),this._loadComponent(l),l}tick(){if(this._runningTick)throw new Qr(101,!1);try{this._runningTick=!0;for(let n of this._views)n.detectChanges()}catch(n){this.internalErrorHandler(n)}finally{this._runningTick=!1}}attachView(n){let a=n;this._views.push(a),a.attachToAppRef(this)}detachView(n){let a=n;vP(this._views,a),a.detachFromAppRef()}_loadComponent(n){this.attachView(n.hostView),this.tick(),this.components.push(n);let a=this._injector.get(OE,[]);[...this._bootstrapListeners,...a].forEach(i=>i(n))}ngOnDestroy(){if(!this._destroyed)try{this._destroyListeners.forEach(n=>n()),this._views.slice().forEach(n=>n.destroy())}finally{this._destroyed=!0,this._views=[],this._bootstrapListeners=[],this._destroyListeners=[]}}onDestroy(n){return this._destroyListeners.push(n),()=>vP(this._destroyListeners,n)}destroy(){if(this._destroyed)throw new Qr(406,!1);let n=this._injector;n.destroy&&!n.destroyed&&n.destroy()}get viewCount(){return this._views.length}warnIfDestroyed(){}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})();function vP(e,t){let r=e.indexOf(t);r>-1&&e.splice(r,1)}var MU=new Nn("",{providedIn:"root",factory:()=>br(ud).handleError.bind(void 0)});function Jme(){let e=br(lo),t=br(ud);return r=>e.runOutsideAngular(()=>t.handleError(r))}var epe=(()=>{let t=class t{constructor(){this.zone=br(lo),this.applicationRef=br(Wb)}initialize(){this._onMicrotaskEmptySubscription||(this._onMicrotaskEmptySubscription=this.zone.onMicrotaskEmpty.subscribe({next:()=>{this.zone.run(()=>{this.applicationRef.tick()})}}))}ngOnDestroy(){this._onMicrotaskEmptySubscription?.unsubscribe()}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})();function tpe(e){return[{provide:lo,useFactory:e},{provide:Hb,multi:!0,useFactory:()=>{let t=br(epe,{optional:!0});return()=>t.initialize()}},{provide:MU,useFactory:Jme},{provide:vU,useFactory:gU}]}function rpe(e){let t=tpe(()=>new lo(Qme(e)));return HC([[],t])}var FE=null;function jg(){return FE}function FU(e){FE||(FE=e)}var $C=class{},Xu=new Nn("DocumentToken"),LU=(()=>{let t=class t{historyGo(n){throw new Error("Not implemented")}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:()=>(()=>br(spe))(),providedIn:"platform"});let e=t;return e})();var spe=(()=>{let t=class t extends LU{constructor(){super(),this._doc=br(Xu),this._location=window.location,this._history=window.history}getBaseHrefFromDOM(){return jg().getBaseHref(this._doc)}onPopState(n){let a=jg().getGlobalEventTarget(this._doc,"window");return a.addEventListener("popstate",n,!1),()=>a.removeEventListener("popstate",n)}onHashChange(n){let a=jg().getGlobalEventTarget(this._doc,"window");return a.addEventListener("hashchange",n,!1),()=>a.removeEventListener("hashchange",n)}get href(){return this._location.href}get protocol(){return this._location.protocol}get hostname(){return this._location.hostname}get port(){return this._location.port}get pathname(){return this._location.pathname}get search(){return this._location.search}get hash(){return this._location.hash}set pathname(n){this._location.pathname=n}pushState(n,a,i){this._history.pushState(n,a,i)}replaceState(n,a,i){this._history.replaceState(n,a,i)}forward(){this._history.forward()}back(){this._history.back()}historyGo(n=0){this._history.go(n)}getState(){return this._history.state}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:()=>(()=>new t)(),providedIn:"platform"});let e=t;return e})();function kU(e,t){if(e.length==0)return t;if(t.length==0)return e;let r=0;return e.endsWith("/")&&r++,t.startsWith("/")&&r++,r==2?e+t.substring(1):r==1?e+t:e+"/"+t}function RU(e){let t=e.match(/#|\?|$/),r=t&&t.index||e.length,n=r-(e[r-1]==="/"?1:0);return e.slice(0,n)+e.slice(r)}function Fh(e){return e&&e[0]!=="?"?"?"+e:e}var e2=(()=>{let t=class t{historyGo(n){throw new Error("Not implemented")}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:()=>(()=>br(NU))(),providedIn:"root"});let e=t;return e})(),upe=new Nn("appBaseHref"),NU=(()=>{let t=class t extends e2{constructor(n,a){super(),this._platformLocation=n,this._removeListenerFns=[],this._baseHref=a??this._platformLocation.getBaseHrefFromDOM()??br(Xu).location?.origin??""}ngOnDestroy(){for(;this._removeListenerFns.length;)this._removeListenerFns.pop()()}onPopState(n){this._removeListenerFns.push(this._platformLocation.onPopState(n),this._platformLocation.onHashChange(n))}getBaseHref(){return this._baseHref}prepareExternalUrl(n){return kU(this._baseHref,n)}path(n=!1){let a=this._platformLocation.pathname+Fh(this._platformLocation.search),i=this._platformLocation.hash;return i&&n?`${a}${i}`:a}pushState(n,a,i,o){let s=this.prepareExternalUrl(i+Fh(o));this._platformLocation.pushState(n,a,s)}replaceState(n,a,i,o){let s=this.prepareExternalUrl(i+Fh(o));this._platformLocation.replaceState(n,a,s)}forward(){this._platformLocation.forward()}back(){this._platformLocation.back()}getState(){return this._platformLocation.getState()}historyGo(n=0){this._platformLocation.historyGo?.(n)}};t.\u0275fac=function(a){return new(a||t)(On(LU),On(upe,8))},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})();var Xb=(()=>{let t=class t{constructor(n){this._subject=new Hs,this._urlChangeListeners=[],this._urlChangeSubscription=null,this._locationStrategy=n;let a=this._locationStrategy.getBaseHref();this._basePath=fpe(RU(BU(a))),this._locationStrategy.onPopState(i=>{this._subject.emit({url:this.path(!0),pop:!0,state:i.state,type:i.type})})}ngOnDestroy(){this._urlChangeSubscription?.unsubscribe(),this._urlChangeListeners=[]}path(n=!1){return this.normalize(this._locationStrategy.path(n))}getState(){return this._locationStrategy.getState()}isCurrentPathEqualTo(n,a=""){return this.path()==this.normalize(n+Fh(a))}normalize(n){return t.stripTrailingSlash(lpe(this._basePath,BU(n)))}prepareExternalUrl(n){return n&&n[0]!=="/"&&(n="/"+n),this._locationStrategy.prepareExternalUrl(n)}go(n,a="",i=null){this._locationStrategy.pushState(i,"",n,a),this._notifyUrlChangeListeners(this.prepareExternalUrl(n+Fh(a)),i)}replaceState(n,a="",i=null){this._locationStrategy.replaceState(i,"",n,a),this._notifyUrlChangeListeners(this.prepareExternalUrl(n+Fh(a)),i)}forward(){this._locationStrategy.forward()}back(){this._locationStrategy.back()}historyGo(n=0){this._locationStrategy.historyGo?.(n)}onUrlChange(n){return this._urlChangeListeners.push(n),this._urlChangeSubscription||(this._urlChangeSubscription=this.subscribe(a=>{this._notifyUrlChangeListeners(a.url,a.state)})),()=>{let a=this._urlChangeListeners.indexOf(n);this._urlChangeListeners.splice(a,1),this._urlChangeListeners.length===0&&(this._urlChangeSubscription?.unsubscribe(),this._urlChangeSubscription=null)}}_notifyUrlChangeListeners(n="",a){this._urlChangeListeners.forEach(i=>i(n,a))}subscribe(n,a,i){return this._subject.subscribe({next:n,error:a,complete:i})}};t.normalizeQueryParams=Fh,t.joinWithSlash=kU,t.stripTrailingSlash=RU,t.\u0275fac=function(a){return new(a||t)(On(e2))},t.\u0275prov=un({token:t,factory:()=>cpe(),providedIn:"root"});let e=t;return e})();function cpe(){return new Xb(On(e2))}function lpe(e,t){if(!e||!t.startsWith(e))return t;let r=t.substring(e.length);return r===""||["/",";","?","#"].includes(r[0])?r:t}function BU(e){return e.replace(/\/index.html$/,"")}function fpe(e){if(new RegExp("^(https?:)?//").test(e)){let[,r]=e.split(/\/\/[^\/]+/);return r}return e}function UU(e,t){t=encodeURIComponent(t);for(let r of e.split(";")){let n=r.indexOf("="),[a,i]=n==-1?[r,""]:[r.slice(0,n),r.slice(n+1)];if(a.trim()===t)return decodeURIComponent(i)}return null}var LE=(()=>{let t=class t{};t.\u0275fac=function(a){return new(a||t)},t.\u0275mod=kC({type:t}),t.\u0275inj=BC({});let e=t;return e})(),VU="browser",dpe="server";function kE(e){return e===dpe}var JC=class{};var VE=class extends $C{constructor(){super(...arguments),this.supportsDOMEvents=!0}},GE=class e extends VE{static makeCurrent(){FU(new e)}onAndCancel(t,r,n){return t.addEventListener(r,n),()=>{t.removeEventListener(r,n)}}dispatchEvent(t,r){t.dispatchEvent(r)}remove(t){t.parentNode&&t.parentNode.removeChild(t)}createElement(t,r){return r=r||this.getDefaultDocument(),r.createElement(t)}createHtmlDocument(){return document.implementation.createHTMLDocument("fakeTitle")}getDefaultDocument(){return document}isElementNode(t){return t.nodeType===Node.ELEMENT_NODE}isShadowRoot(t){return t instanceof DocumentFragment}getGlobalEventTarget(t,r){return r==="window"?window:r==="document"?t:r==="body"?t.body:null}getBaseHref(t){let r=ppe();return r==null?null:hpe(r)}resetBaseElement(){Kb=null}getUserAgent(){return window.navigator.userAgent}getCookie(t){return UU(document.cookie,t)}},Kb=null;function ppe(){return Kb=Kb||document.querySelector("base"),Kb?Kb.getAttribute("href"):null}function hpe(e){return new URL(e,"http://a").pathname}var vpe=(()=>{let t=class t{build(){return new XMLHttpRequest}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:t.\u0275fac});let e=t;return e})(),zE=new Nn("EventManagerPlugins"),jU=(()=>{let t=class t{constructor(n,a){this._zone=a,this._eventNameToPlugin=new Map,n.forEach(i=>{i.manager=this}),this._plugins=n.slice().reverse()}addEventListener(n,a,i){return this._findPluginFor(a).addEventListener(n,a,i)}getZone(){return this._zone}_findPluginFor(n){let a=this._eventNameToPlugin.get(n);if(a)return a;if(a=this._plugins.find(o=>o.supports(n)),!a)throw new Qr(5101,!1);return this._eventNameToPlugin.set(n,a),a}};t.\u0275fac=function(a){return new(a||t)(On(zE),On(lo))},t.\u0275prov=un({token:t,factory:t.\u0275fac});let e=t;return e})(),t2=class{constructor(t){this._doc=t}},NE="ng-app-id",qU=(()=>{let t=class t{constructor(n,a,i,o={}){this.doc=n,this.appId=a,this.nonce=i,this.platformId=o,this.styleRef=new Map,this.hostNodes=new Set,this.styleNodesInDOM=this.collectServerRenderedStyles(),this.platformIsServer=kE(o),this.resetHostNodes()}addStyles(n){for(let a of n)this.changeUsageCount(a,1)===1&&this.onStyleAdded(a)}removeStyles(n){for(let a of n)this.changeUsageCount(a,-1)<=0&&this.onStyleRemoved(a)}ngOnDestroy(){let n=this.styleNodesInDOM;n&&(n.forEach(a=>a.remove()),n.clear());for(let a of this.getAllStyles())this.onStyleRemoved(a);this.resetHostNodes()}addHost(n){this.hostNodes.add(n);for(let a of this.getAllStyles())this.addStyleToHost(n,a)}removeHost(n){this.hostNodes.delete(n)}getAllStyles(){return this.styleRef.keys()}onStyleAdded(n){for(let a of this.hostNodes)this.addStyleToHost(a,n)}onStyleRemoved(n){let a=this.styleRef;a.get(n)?.elements?.forEach(i=>i.remove()),a.delete(n)}collectServerRenderedStyles(){let n=this.doc.head?.querySelectorAll(`style[${NE}="${this.appId}"]`);if(n?.length){let a=new Map;return n.forEach(i=>{i.textContent!=null&&a.set(i.textContent,i)}),a}return null}changeUsageCount(n,a){let i=this.styleRef;if(i.has(n)){let o=i.get(n);return o.usage+=a,o.usage}return i.set(n,{usage:a,elements:[]}),a}getStyleElement(n,a){let i=this.styleNodesInDOM,o=i?.get(a);if(o?.parentNode===n)return i.delete(a),o.removeAttribute(NE),o;{let s=this.doc.createElement("style");return this.nonce&&s.setAttribute("nonce",this.nonce),s.textContent=a,this.platformIsServer&&s.setAttribute(NE,this.appId),n.appendChild(s),s}}addStyleToHost(n,a){let i=this.getStyleElement(n,a),o=this.styleRef,s=o.get(a)?.elements;s?s.push(i):o.set(a,{elements:[i],usage:1})}resetHostNodes(){let n=this.hostNodes;n.clear(),n.add(this.doc.head)}};t.\u0275fac=function(a){return new(a||t)(On(Xu),On(fE),On(mE,8),On(Vg))},t.\u0275prov=un({token:t,factory:t.\u0275fac});let e=t;return e})(),UE={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/",math:"http://www.w3.org/1998/MathML/"},jE=/%COMP%/g,WU="%COMP%",gpe=`_nghost-${WU}`,ype=`_ngcontent-${WU}`,bpe=!0,xpe=new Nn("RemoveStylesOnCompDestroy",{providedIn:"root",factory:()=>bpe});function Spe(e){return ype.replace(jE,e)}function Cpe(e){return gpe.replace(jE,e)}function YU(e,t){return t.map(r=>r.replace(jE,e))}var GU=(()=>{let t=class t{constructor(n,a,i,o,s,u,c,l=null){this.eventManager=n,this.sharedStylesHost=a,this.appId=i,this.removeStylesOnCompDestroy=o,this.doc=s,this.platformId=u,this.ngZone=c,this.nonce=l,this.rendererByCompId=new Map,this.platformIsServer=kE(u),this.defaultRenderer=new Zb(n,s,c,this.platformIsServer)}createRenderer(n,a){if(!n||!a)return this.defaultRenderer;this.platformIsServer&&a.encapsulation===df.ShadowDom&&(a=uo(Ar({},a),{encapsulation:df.Emulated}));let i=this.getOrCreateRenderer(n,a);return i instanceof r2?i.applyToHost(n):i instanceof Qb&&i.applyStyles(),i}getOrCreateRenderer(n,a){let i=this.rendererByCompId,o=i.get(a.id);if(!o){let s=this.doc,u=this.ngZone,c=this.eventManager,l=this.sharedStylesHost,f=this.removeStylesOnCompDestroy,d=this.platformIsServer;switch(a.encapsulation){case df.Emulated:o=new r2(c,l,a,this.appId,f,s,u,d);break;case df.ShadowDom:return new HE(c,l,n,a,s,u,this.nonce,d);default:o=new Qb(c,l,a,f,s,u,d);break}i.set(a.id,o)}return o}ngOnDestroy(){this.rendererByCompId.clear()}};t.\u0275fac=function(a){return new(a||t)(On(jU),On(qU),On(fE),On(xpe),On(Xu),On(Vg),On(lo),On(mE))},t.\u0275prov=un({token:t,factory:t.\u0275fac});let e=t;return e})(),Zb=class{constructor(t,r,n,a){this.eventManager=t,this.doc=r,this.ngZone=n,this.platformIsServer=a,this.data=Object.create(null),this.throwOnSyntheticProps=!0,this.destroyNode=null}destroy(){}createElement(t,r){return r?this.doc.createElementNS(UE[r]||r,t):this.doc.createElement(t)}createComment(t){return this.doc.createComment(t)}createText(t){return this.doc.createTextNode(t)}appendChild(t,r){(zU(t)?t.content:t).appendChild(r)}insertBefore(t,r,n){t&&(zU(t)?t.content:t).insertBefore(r,n)}removeChild(t,r){t&&t.removeChild(r)}selectRootElement(t,r){let n=typeof t=="string"?this.doc.querySelector(t):t;if(!n)throw new Qr(-5104,!1);return r||(n.textContent=""),n}parentNode(t){return t.parentNode}nextSibling(t){return t.nextSibling}setAttribute(t,r,n,a){if(a){r=a+":"+r;let i=UE[a];i?t.setAttributeNS(i,r,n):t.setAttribute(r,n)}else t.setAttribute(r,n)}removeAttribute(t,r,n){if(n){let a=UE[n];a?t.removeAttributeNS(a,r):t.removeAttribute(`${n}:${r}`)}else t.removeAttribute(r)}addClass(t,r){t.classList.add(r)}removeClass(t,r){t.classList.remove(r)}setStyle(t,r,n,a){a&(Ih.DashCase|Ih.Important)?t.style.setProperty(r,n,a&Ih.Important?"important":""):t.style[r]=n}removeStyle(t,r,n){n&Ih.DashCase?t.style.removeProperty(r):t.style[r]=""}setProperty(t,r,n){t!=null&&(t[r]=n)}setValue(t,r){t.nodeValue=r}listen(t,r,n){if(typeof t=="string"&&(t=jg().getGlobalEventTarget(this.doc,t),!t))throw new Error(`Unsupported event target ${t} for event ${r}`);return this.eventManager.addEventListener(t,r,this.decoratePreventDefault(n))}decoratePreventDefault(t){return r=>{if(r==="__ngUnwrap__")return t;(this.platformIsServer?this.ngZone.runGuarded(()=>t(r)):t(r))===!1&&r.preventDefault()}}};function zU(e){return e.tagName==="TEMPLATE"&&e.content!==void 0}var HE=class extends Zb{constructor(t,r,n,a,i,o,s,u){super(t,i,o,u),this.sharedStylesHost=r,this.hostEl=n,this.shadowRoot=n.attachShadow({mode:"open"}),this.sharedStylesHost.addHost(this.shadowRoot);let c=YU(a.id,a.styles);for(let l of c){let f=document.createElement("style");s&&f.setAttribute("nonce",s),f.textContent=l,this.shadowRoot.appendChild(f)}}nodeOrShadowRoot(t){return t===this.hostEl?this.shadowRoot:t}appendChild(t,r){return super.appendChild(this.nodeOrShadowRoot(t),r)}insertBefore(t,r,n){return super.insertBefore(this.nodeOrShadowRoot(t),r,n)}removeChild(t,r){return super.removeChild(this.nodeOrShadowRoot(t),r)}parentNode(t){return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(t)))}destroy(){this.sharedStylesHost.removeHost(this.shadowRoot)}},Qb=class extends Zb{constructor(t,r,n,a,i,o,s,u){super(t,i,o,s),this.sharedStylesHost=r,this.removeStylesOnCompDestroy=a,this.styles=u?YU(u,n.styles):n.styles}applyStyles(){this.sharedStylesHost.addStyles(this.styles)}destroy(){this.removeStylesOnCompDestroy&&this.sharedStylesHost.removeStyles(this.styles)}},r2=class extends Qb{constructor(t,r,n,a,i,o,s,u){let c=a+"-"+n.id;super(t,r,n,i,o,s,u,c),this.contentAttr=Spe(c),this.hostAttr=Cpe(c)}applyToHost(t){this.applyStyles(),this.setAttribute(t,this.hostAttr,"")}createElement(t,r){let n=super.createElement(t,r);return super.setAttribute(n,this.contentAttr,""),n}},_pe=(()=>{let t=class t extends t2{constructor(n){super(n)}supports(n){return!0}addEventListener(n,a,i){return n.addEventListener(a,i,!1),()=>this.removeEventListener(n,a,i)}removeEventListener(n,a,i){return n.removeEventListener(a,i)}};t.\u0275fac=function(a){return new(a||t)(On(Xu))},t.\u0275prov=un({token:t,factory:t.\u0275fac});let e=t;return e})(),HU=["alt","control","meta","shift"],wpe={"\b":"Backspace"," ":"Tab","\x7F":"Delete","\x1B":"Escape",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown",Menu:"ContextMenu",Scroll:"ScrollLock",Win:"OS"},Tpe={alt:e=>e.altKey,control:e=>e.ctrlKey,meta:e=>e.metaKey,shift:e=>e.shiftKey},Ape=(()=>{let t=class t extends t2{constructor(n){super(n)}supports(n){return t.parseEventName(n)!=null}addEventListener(n,a,i){let o=t.parseEventName(a),s=t.eventCallback(o.fullKey,i,this.manager.getZone());return this.manager.getZone().runOutsideAngular(()=>jg().onAndCancel(n,o.domEventName,s))}static parseEventName(n){let a=n.toLowerCase().split("."),i=a.shift();if(a.length===0||!(i==="keydown"||i==="keyup"))return null;let o=t._normalizeKey(a.pop()),s="",u=a.indexOf("code");if(u>-1&&(a.splice(u,1),s="code."),HU.forEach(l=>{let f=a.indexOf(l);f>-1&&(a.splice(f,1),s+=l+".")}),s+=o,a.length!=0||o.length===0)return null;let c={};return c.domEventName=i,c.fullKey=s,c}static matchEventFullKeyCode(n,a){let i=wpe[n.key]||n.key,o="";return a.indexOf("code.")>-1&&(i=n.code,o="code."),i==null||!i?!1:(i=i.toLowerCase(),i===" "?i="space":i==="."&&(i="dot"),HU.forEach(s=>{if(s!==i){let u=Tpe[s];u(n)&&(o+=s+".")}}),o+=i,o===a)}static eventCallback(n,a,i){return o=>{t.matchEventFullKeyCode(o,n)&&i.runGuarded(()=>a(o))}}static _normalizeKey(n){return n==="esc"?"escape":n}};t.\u0275fac=function(a){return new(a||t)(On(Xu))},t.\u0275prov=un({token:t,factory:t.\u0275fac});let e=t;return e})();function XU(e,t){return IU(Ar({rootComponent:e},Dpe(t)))}function Dpe(e){return{appProviders:[...Rpe,...e?.providers??[]],platformProviders:Mpe}}function Ppe(){GE.makeCurrent()}function Epe(){return new ud}function Ipe(){return L5(document),document}var Mpe=[{provide:Vg,useValue:VU},{provide:dE,useValue:Ppe,multi:!0},{provide:Xu,useFactory:Ipe,deps:[]}];var Rpe=[{provide:jC,useValue:"root"},{provide:ud,useFactory:Epe,deps:[]},{provide:zE,useClass:_pe,multi:!0,deps:[Xu,lo,Vg]},{provide:zE,useClass:Ape,multi:!0,deps:[Xu]},GU,qU,jU,{provide:Lb,useExisting:GU},{provide:JC,useClass:vpe,deps:[]},[]];function Bpe(){return new qE(On(Xu))}var qE=(()=>{let t=class t{constructor(n){this._doc=n}getTitle(){return this._doc.title}setTitle(n){this._doc.title=n||""}};t.\u0275fac=function(a){return new(a||t)(On(Xu))},t.\u0275prov=un({token:t,factory:function(a){let i=null;return a?i=new a:i=Bpe(),i},providedIn:"root"});let e=t;return e})();var cn="primary",d1=Symbol("RouteTitle"),ZE=class{constructor(t){this.params=t||{}}has(t){return Object.prototype.hasOwnProperty.call(this.params,t)}get(t){if(this.has(t)){let r=this.params[t];return Array.isArray(r)?r[0]:r}return null}getAll(t){if(this.has(t)){let r=this.params[t];return Array.isArray(r)?r:[r]}return[]}get keys(){return Object.keys(this.params)}};function Kg(e){return new ZE(e)}function Fpe(e,t,r){let n=r.path.split("/");if(n.length>e.length||r.pathMatch==="full"&&(t.hasChildren()||n.lengthn[i]===a)}else return e===t}function rV(e){return e.length>0?e[e.length-1]:null}function xm(e){return ZD(e)?e:qb(e)?di(Promise.resolve(e)):Yr(e)}var kpe={exact:aV,subset:iV},nV={exact:Npe,subset:Upe,ignored:()=>!0};function KU(e,t,r){return kpe[r.paths](e.root,t.root,r.matrixParams)&&nV[r.queryParams](e.queryParams,t.queryParams)&&!(r.fragment==="exact"&&e.fragment!==t.fragment)}function Npe(e,t){return hf(e,t)}function aV(e,t,r){if(!kh(e.segments,t.segments)||!i2(e.segments,t.segments,r)||e.numberOfChildren!==t.numberOfChildren)return!1;for(let n in t.children)if(!e.children[n]||!aV(e.children[n],t.children[n],r))return!1;return!0}function Upe(e,t){return Object.keys(t).length<=Object.keys(e).length&&Object.keys(t).every(r=>tV(e[r],t[r]))}function iV(e,t,r){return oV(e,t,t.segments,r)}function oV(e,t,r,n){if(e.segments.length>r.length){let a=e.segments.slice(0,r.length);return!(!kh(a,r)||t.hasChildren()||!i2(a,r,n))}else if(e.segments.length===r.length){if(!kh(e.segments,r)||!i2(e.segments,r,n))return!1;for(let a in t.children)if(!e.children[a]||!iV(e.children[a],t.children[a],n))return!1;return!0}else{let a=r.slice(0,e.segments.length),i=r.slice(e.segments.length);return!kh(e.segments,a)||!i2(e.segments,a,n)||!e.children[cn]?!1:oV(e.children[cn],t,i,n)}}function i2(e,t,r){return t.every((n,a)=>nV[r](e[a].parameters,n.parameters))}var ym=class{constructor(t=new va([],{}),r={},n=null){this.root=t,this.queryParams=r,this.fragment=n}get queryParamMap(){return this._queryParamMap||(this._queryParamMap=Kg(this.queryParams)),this._queryParamMap}toString(){return zpe.serialize(this)}},va=class{constructor(t,r){this.segments=t,this.children=r,this.parent=null,Object.values(r).forEach(n=>n.parent=this)}hasChildren(){return this.numberOfChildren>0}get numberOfChildren(){return Object.keys(this.children).length}toString(){return o2(this)}},Lh=class{constructor(t,r){this.path=t,this.parameters=r}get parameterMap(){return this._parameterMap||(this._parameterMap=Kg(this.parameters)),this._parameterMap}toString(){return uV(this)}};function Vpe(e,t){return kh(e,t)&&e.every((r,n)=>hf(r.parameters,t[n].parameters))}function kh(e,t){return e.length!==t.length?!1:e.every((r,n)=>r.path===t[n].path)}function Gpe(e,t){let r=[];return Object.entries(e.children).forEach(([n,a])=>{n===cn&&(r=r.concat(t(a,n)))}),Object.entries(e.children).forEach(([n,a])=>{n!==cn&&(r=r.concat(t(a,n)))}),r}var CI=(()=>{let t=class t{};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:()=>(()=>new u2)(),providedIn:"root"});let e=t;return e})(),u2=class{parse(t){let r=new JE(t);return new ym(r.parseRootSegment(),r.parseQueryParams(),r.parseFragment())}serialize(t){let r=`/${$b(t.root,!0)}`,n=qpe(t.queryParams),a=typeof t.fragment=="string"?`#${Hpe(t.fragment)}`:"";return`${r}${n}${a}`}},zpe=new u2;function o2(e){return e.segments.map(t=>uV(t)).join("/")}function $b(e,t){if(!e.hasChildren())return o2(e);if(t){let r=e.children[cn]?$b(e.children[cn],!1):"",n=[];return Object.entries(e.children).forEach(([a,i])=>{a!==cn&&n.push(`${a}:${$b(i,!1)}`)}),n.length>0?`${r}(${n.join("//")})`:r}else{let r=Gpe(e,(n,a)=>a===cn?[$b(e.children[cn],!1)]:[`${a}:${$b(n,!1)}`]);return Object.keys(e.children).length===1&&e.children[cn]!=null?`${o2(e)}/${r[0]}`:`${o2(e)}/(${r.join("//")})`}}function sV(e){return encodeURIComponent(e).replace(/%40/g,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",")}function n2(e){return sV(e).replace(/%3B/gi,";")}function Hpe(e){return encodeURI(e)}function $E(e){return sV(e).replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/%26/gi,"&")}function s2(e){return decodeURIComponent(e)}function ZU(e){return s2(e.replace(/\+/g,"%20"))}function uV(e){return`${$E(e.path)}${jpe(e.parameters)}`}function jpe(e){return Object.keys(e).map(t=>`;${$E(t)}=${$E(e[t])}`).join("")}function qpe(e){let t=Object.keys(e).map(r=>{let n=e[r];return Array.isArray(n)?n.map(a=>`${n2(r)}=${n2(a)}`).join("&"):`${n2(r)}=${n2(n)}`}).filter(r=>!!r);return t.length?`?${t.join("&")}`:""}var Wpe=/^[^\/()?;#]+/;function WE(e){let t=e.match(Wpe);return t?t[0]:""}var Ype=/^[^\/()?;=#]+/;function Xpe(e){let t=e.match(Ype);return t?t[0]:""}var Kpe=/^[^=?&#]+/;function Zpe(e){let t=e.match(Kpe);return t?t[0]:""}var Qpe=/^[^&#]+/;function $pe(e){let t=e.match(Qpe);return t?t[0]:""}var JE=class{constructor(t){this.url=t,this.remaining=t}parseRootSegment(){return this.consumeOptional("/"),this.remaining===""||this.peekStartsWith("?")||this.peekStartsWith("#")?new va([],{}):new va([],this.parseChildren())}parseQueryParams(){let t={};if(this.consumeOptional("?"))do this.parseQueryParam(t);while(this.consumeOptional("&"));return t}parseFragment(){return this.consumeOptional("#")?decodeURIComponent(this.remaining):null}parseChildren(){if(this.remaining==="")return{};this.consumeOptional("/");let t=[];for(this.peekStartsWith("(")||t.push(this.parseSegment());this.peekStartsWith("/")&&!this.peekStartsWith("//")&&!this.peekStartsWith("/(");)this.capture("/"),t.push(this.parseSegment());let r={};this.peekStartsWith("/(")&&(this.capture("/"),r=this.parseParens(!0));let n={};return this.peekStartsWith("(")&&(n=this.parseParens(!1)),(t.length>0||Object.keys(r).length>0)&&(n[cn]=new va(t,r)),n}parseSegment(){let t=WE(this.remaining);if(t===""&&this.peekStartsWith(";"))throw new Qr(4009,!1);return this.capture(t),new Lh(s2(t),this.parseMatrixParams())}parseMatrixParams(){let t={};for(;this.consumeOptional(";");)this.parseParam(t);return t}parseParam(t){let r=Xpe(this.remaining);if(!r)return;this.capture(r);let n="";if(this.consumeOptional("=")){let a=WE(this.remaining);a&&(n=a,this.capture(n))}t[s2(r)]=s2(n)}parseQueryParam(t){let r=Zpe(this.remaining);if(!r)return;this.capture(r);let n="";if(this.consumeOptional("=")){let o=$pe(this.remaining);o&&(n=o,this.capture(n))}let a=ZU(r),i=ZU(n);if(t.hasOwnProperty(a)){let o=t[a];Array.isArray(o)||(o=[o],t[a]=o),o.push(i)}else t[a]=i}parseParens(t){let r={};for(this.capture("(");!this.consumeOptional(")")&&this.remaining.length>0;){let n=WE(this.remaining),a=this.remaining[n.length];if(a!=="/"&&a!==")"&&a!==";")throw new Qr(4010,!1);let i;n.indexOf(":")>-1?(i=n.slice(0,n.indexOf(":")),this.capture(i),this.capture(":")):t&&(i=cn);let o=this.parseChildren();r[i]=Object.keys(o).length===1?o[cn]:new va([],o),this.consumeOptional("//")}return r}peekStartsWith(t){return this.remaining.startsWith(t)}consumeOptional(t){return this.peekStartsWith(t)?(this.remaining=this.remaining.substring(t.length),!0):!1}capture(t){if(!this.consumeOptional(t))throw new Qr(4011,!1)}};function cV(e){return e.segments.length>0?new va([],{[cn]:e}):e}function lV(e){let t={};for(let n of Object.keys(e.children)){let a=e.children[n],i=lV(a);if(n===cn&&i.segments.length===0&&i.hasChildren())for(let[o,s]of Object.entries(i.children))t[o]=s;else(i.segments.length>0||i.hasChildren())&&(t[n]=i)}let r=new va(e.segments,t);return Jpe(r)}function Jpe(e){if(e.numberOfChildren===1&&e.children[cn]){let t=e.children[cn];return new va(e.segments.concat(t.segments),t.children)}return e}function Zg(e){return e instanceof ym}function ehe(e,t,r=null,n=null){let a=fV(e);return dV(a,t,r,n)}function fV(e){let t;function r(i){let o={};for(let u of i.children){let c=r(u);o[u.outlet]=c}let s=new va(i.url,o);return i===e&&(t=s),s}let n=r(e.root),a=cV(n);return t??a}function dV(e,t,r,n){let a=e;for(;a.parent;)a=a.parent;if(t.length===0)return YE(a,a,a,r,n);let i=the(t);if(i.toRoot())return YE(a,a,new va([],{}),r,n);let o=rhe(i,a,e),s=o.processChildren?t1(o.segmentGroup,o.index,i.commands):pV(o.segmentGroup,o.index,i.commands);return YE(a,o.segmentGroup,s,r,n)}function c2(e){return typeof e=="object"&&e!=null&&!e.outlets&&!e.segmentPath}function a1(e){return typeof e=="object"&&e!=null&&e.outlets}function YE(e,t,r,n,a){let i={};n&&Object.entries(n).forEach(([u,c])=>{i[u]=Array.isArray(c)?c.map(l=>`${l}`):`${c}`});let o;e===t?o=r:o=mV(e,t,r);let s=cV(lV(o));return new ym(s,i,a)}function mV(e,t,r){let n={};return Object.entries(e.children).forEach(([a,i])=>{i===t?n[a]=r:n[a]=mV(i,t,r)}),new va(e.segments,n)}var l2=class{constructor(t,r,n){if(this.isAbsolute=t,this.numberOfDoubleDots=r,this.commands=n,t&&n.length>0&&c2(n[0]))throw new Qr(4003,!1);let a=n.find(a1);if(a&&a!==rV(n))throw new Qr(4004,!1)}toRoot(){return this.isAbsolute&&this.commands.length===1&&this.commands[0]=="/"}};function the(e){if(typeof e[0]=="string"&&e.length===1&&e[0]==="/")return new l2(!0,0,e);let t=0,r=!1,n=e.reduce((a,i,o)=>{if(typeof i=="object"&&i!=null){if(i.outlets){let s={};return Object.entries(i.outlets).forEach(([u,c])=>{s[u]=typeof c=="string"?c.split("/"):c}),[...a,{outlets:s}]}if(i.segmentPath)return[...a,i.segmentPath]}return typeof i!="string"?[...a,i]:o===0?(i.split("/").forEach((s,u)=>{u==0&&s==="."||(u==0&&s===""?r=!0:s===".."?t++:s!=""&&a.push(s))}),a):[...a,i]},[]);return new l2(r,t,n)}var Yg=class{constructor(t,r,n){this.segmentGroup=t,this.processChildren=r,this.index=n}};function rhe(e,t,r){if(e.isAbsolute)return new Yg(t,!0,0);if(!r)return new Yg(t,!1,NaN);if(r.parent===null)return new Yg(r,!0,0);let n=c2(e.commands[0])?0:1,a=r.segments.length-1+n;return nhe(r,a,e.numberOfDoubleDots)}function nhe(e,t,r){let n=e,a=t,i=r;for(;i>a;){if(i-=a,n=n.parent,!n)throw new Qr(4005,!1);a=n.segments.length}return new Yg(n,!1,a-i)}function ahe(e){return a1(e[0])?e[0].outlets:{[cn]:e}}function pV(e,t,r){if(e||(e=new va([],{})),e.segments.length===0&&e.hasChildren())return t1(e,t,r);let n=ihe(e,t,r),a=r.slice(n.commandIndex);if(n.match&&n.pathIndexi!==cn)&&e.children[cn]&&e.numberOfChildren===1&&e.children[cn].segments.length===0){let i=t1(e.children[cn],t,r);return new va(e.segments,i.children)}return Object.entries(n).forEach(([i,o])=>{typeof o=="string"&&(o=[o]),o!==null&&(a[i]=pV(e.children[i],t,o))}),Object.entries(e.children).forEach(([i,o])=>{n[i]===void 0&&(a[i]=o)}),new va(e.segments,a)}}function ihe(e,t,r){let n=0,a=t,i={match:!1,pathIndex:0,commandIndex:0};for(;a=r.length)return i;let o=e.segments[a],s=r[n];if(a1(s))break;let u=`${s}`,c=n0&&u===void 0)break;if(u&&c&&typeof c=="object"&&c.outlets===void 0){if(!$U(u,c,o))return i;n+=2}else{if(!$U(u,{},o))return i;n++}a++}return{match:!0,pathIndex:a,commandIndex:n}}function eI(e,t,r){let n=e.segments.slice(0,t),a=0;for(;a{typeof n=="string"&&(n=[n]),n!==null&&(t[r]=eI(new va([],{}),0,n))}),t}function QU(e){let t={};return Object.entries(e).forEach(([r,n])=>t[r]=`${n}`),t}function $U(e,t,r){return e==r.path&&hf(t,r.parameters)}var r1="imperative",wc=class{constructor(t,r){this.id=t,this.url=r}},i1=class extends wc{constructor(t,r,n="imperative",a=null){super(t,r),this.type=0,this.navigationTrigger=n,this.restoredState=a}toString(){return`NavigationStart(id: ${this.id}, url: '${this.url}')`}},Nh=class extends wc{constructor(t,r,n){super(t,r),this.urlAfterRedirects=n,this.type=1}toString(){return`NavigationEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}')`}},bm=class extends wc{constructor(t,r,n,a){super(t,r),this.reason=n,this.code=a,this.type=2}toString(){return`NavigationCancel(id: ${this.id}, url: '${this.url}')`}},Uh=class extends wc{constructor(t,r,n,a){super(t,r),this.reason=n,this.code=a,this.type=16}},o1=class extends wc{constructor(t,r,n,a){super(t,r),this.error=n,this.target=a,this.type=3}toString(){return`NavigationError(id: ${this.id}, url: '${this.url}', error: ${this.error})`}},f2=class extends wc{constructor(t,r,n,a){super(t,r),this.urlAfterRedirects=n,this.state=a,this.type=4}toString(){return`RoutesRecognized(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}},tI=class extends wc{constructor(t,r,n,a){super(t,r),this.urlAfterRedirects=n,this.state=a,this.type=7}toString(){return`GuardsCheckStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}},rI=class extends wc{constructor(t,r,n,a,i){super(t,r),this.urlAfterRedirects=n,this.state=a,this.shouldActivate=i,this.type=8}toString(){return`GuardsCheckEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state}, shouldActivate: ${this.shouldActivate})`}},nI=class extends wc{constructor(t,r,n,a){super(t,r),this.urlAfterRedirects=n,this.state=a,this.type=5}toString(){return`ResolveStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}},aI=class extends wc{constructor(t,r,n,a){super(t,r),this.urlAfterRedirects=n,this.state=a,this.type=6}toString(){return`ResolveEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}},iI=class{constructor(t){this.route=t,this.type=9}toString(){return`RouteConfigLoadStart(path: ${this.route.path})`}},oI=class{constructor(t){this.route=t,this.type=10}toString(){return`RouteConfigLoadEnd(path: ${this.route.path})`}},sI=class{constructor(t){this.snapshot=t,this.type=11}toString(){return`ChildActivationStart(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}},uI=class{constructor(t){this.snapshot=t,this.type=12}toString(){return`ChildActivationEnd(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}},cI=class{constructor(t){this.snapshot=t,this.type=13}toString(){return`ActivationStart(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}},lI=class{constructor(t){this.snapshot=t,this.type=14}toString(){return`ActivationEnd(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}};var s1=class{},u1=class{constructor(t){this.url=t}};var fI=class{constructor(){this.outlet=null,this.route=null,this.injector=null,this.children=new g2,this.attachRef=null}},g2=(()=>{let t=class t{constructor(){this.contexts=new Map}onChildOutletCreated(n,a){let i=this.getOrCreateContext(n);i.outlet=a,this.contexts.set(n,i)}onChildOutletDestroyed(n){let a=this.getContext(n);a&&(a.outlet=null,a.attachRef=null)}onOutletDeactivated(){let n=this.contexts;return this.contexts=new Map,n}onOutletReAttached(n){this.contexts=n}getOrCreateContext(n){let a=this.getContext(n);return a||(a=new fI,this.contexts.set(n,a)),a}getContext(n){return this.contexts.get(n)||null}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),d2=class{constructor(t){this._root=t}get root(){return this._root.value}parent(t){let r=this.pathFromRoot(t);return r.length>1?r[r.length-2]:null}children(t){let r=dI(t,this._root);return r?r.children.map(n=>n.value):[]}firstChild(t){let r=dI(t,this._root);return r&&r.children.length>0?r.children[0].value:null}siblings(t){let r=mI(t,this._root);return r.length<2?[]:r[r.length-2].children.map(a=>a.value).filter(a=>a!==t)}pathFromRoot(t){return mI(t,this._root).map(r=>r.value)}};function dI(e,t){if(e===t.value)return t;for(let r of t.children){let n=dI(e,r);if(n)return n}return null}function mI(e,t){if(e===t.value)return[t];for(let r of t.children){let n=mI(e,r);if(n.length)return n.unshift(t),n}return[]}var Ku=class{constructor(t,r){this.value=t,this.children=r}toString(){return`TreeNode(${this.value})`}};function Wg(e){let t={};return e&&e.children.forEach(r=>t[r.value.outlet]=r),t}var m2=class extends d2{constructor(t,r){super(t),this.snapshot=r,wI(this,t)}toString(){return this.snapshot.toString()}};function hV(e,t){let r=she(e,t),n=new ha([new Lh("",{})]),a=new ha({}),i=new ha({}),o=new ha({}),s=new ha(""),u=new Qg(n,a,o,s,i,cn,t,r.root);return u.snapshot=r.root,new m2(new Ku(u,[]),r)}function she(e,t){let r={},n={},a={},i="",o=new c1([],r,a,i,n,cn,t,null,{});return new p2("",new Ku(o,[]))}var Qg=class{constructor(t,r,n,a,i,o,s,u){this.urlSubject=t,this.paramsSubject=r,this.queryParamsSubject=n,this.fragmentSubject=a,this.dataSubject=i,this.outlet=o,this.component=s,this._futureSnapshot=u,this.title=this.dataSubject?.pipe(Cn(c=>c[d1]))??Yr(void 0),this.url=t,this.params=r,this.queryParams=n,this.fragment=a,this.data=i}get routeConfig(){return this._futureSnapshot.routeConfig}get root(){return this._routerState.root}get parent(){return this._routerState.parent(this)}get firstChild(){return this._routerState.firstChild(this)}get children(){return this._routerState.children(this)}get pathFromRoot(){return this._routerState.pathFromRoot(this)}get paramMap(){return this._paramMap||(this._paramMap=this.params.pipe(Cn(t=>Kg(t)))),this._paramMap}get queryParamMap(){return this._queryParamMap||(this._queryParamMap=this.queryParams.pipe(Cn(t=>Kg(t)))),this._queryParamMap}toString(){return this.snapshot?this.snapshot.toString():`Future(${this._futureSnapshot})`}};function _I(e,t,r="emptyOnly"){let n,{routeConfig:a}=e;return t!==null&&(r==="always"||a?.path===""||!t.component&&!t.routeConfig?.loadComponent)?n={params:Ar(Ar({},t.params),e.params),data:Ar(Ar({},t.data),e.data),resolve:Ar(Ar(Ar(Ar({},e.data),t.data),a?.data),e._resolvedData)}:n={params:e.params,data:e.data,resolve:Ar(Ar({},e.data),e._resolvedData??{})},a&&gV(a)&&(n.resolve[d1]=a.title),n}var c1=class{get title(){return this.data?.[d1]}constructor(t,r,n,a,i,o,s,u,c){this.url=t,this.params=r,this.queryParams=n,this.fragment=a,this.data=i,this.outlet=o,this.component=s,this.routeConfig=u,this._resolve=c}get root(){return this._routerState.root}get parent(){return this._routerState.parent(this)}get firstChild(){return this._routerState.firstChild(this)}get children(){return this._routerState.children(this)}get pathFromRoot(){return this._routerState.pathFromRoot(this)}get paramMap(){return this._paramMap||(this._paramMap=Kg(this.params)),this._paramMap}get queryParamMap(){return this._queryParamMap||(this._queryParamMap=Kg(this.queryParams)),this._queryParamMap}toString(){let t=this.url.map(n=>n.toString()).join("/"),r=this.routeConfig?this.routeConfig.path:"";return`Route(url:'${t}', path:'${r}')`}},p2=class extends d2{constructor(t,r){super(r),this.url=t,wI(this,r)}toString(){return vV(this._root)}};function wI(e,t){t.value._routerState=e,t.children.forEach(r=>wI(e,r))}function vV(e){let t=e.children.length>0?` { ${e.children.map(vV).join(", ")} } `:"";return`${e.value}${t}`}function XE(e){if(e.snapshot){let t=e.snapshot,r=e._futureSnapshot;e.snapshot=r,hf(t.queryParams,r.queryParams)||e.queryParamsSubject.next(r.queryParams),t.fragment!==r.fragment&&e.fragmentSubject.next(r.fragment),hf(t.params,r.params)||e.paramsSubject.next(r.params),Lpe(t.url,r.url)||e.urlSubject.next(r.url),hf(t.data,r.data)||e.dataSubject.next(r.data)}else e.snapshot=e._futureSnapshot,e.dataSubject.next(e._futureSnapshot.data)}function pI(e,t){let r=hf(e.params,t.params)&&Vpe(e.url,t.url),n=!e.parent!=!t.parent;return r&&!n&&(!e.parent||pI(e.parent,t.parent))}function gV(e){return typeof e.title=="string"||e.title===null}var uhe=(()=>{let t=class t{constructor(){this.activated=null,this._activatedRoute=null,this.name=cn,this.activateEvents=new Hs,this.deactivateEvents=new Hs,this.attachEvents=new Hs,this.detachEvents=new Hs,this.parentContexts=br(g2),this.location=br(zg),this.changeDetector=br(XC),this.environmentInjector=br(_c),this.inputBinder=br(TI,{optional:!0}),this.supportsBindingToComponentInputs=!0}get activatedComponentRef(){return this.activated}ngOnChanges(n){if(n.name){let{firstChange:a,previousValue:i}=n.name;if(a)return;this.isTrackedInParentContexts(i)&&(this.deactivate(),this.parentContexts.onChildOutletDestroyed(i)),this.initializeOutletWithName()}}ngOnDestroy(){this.isTrackedInParentContexts(this.name)&&this.parentContexts.onChildOutletDestroyed(this.name),this.inputBinder?.unsubscribeFromRouteData(this)}isTrackedInParentContexts(n){return this.parentContexts.getContext(n)?.outlet===this}ngOnInit(){this.initializeOutletWithName()}initializeOutletWithName(){if(this.parentContexts.onChildOutletCreated(this.name,this),this.activated)return;let n=this.parentContexts.getContext(this.name);n?.route&&(n.attachRef?this.attach(n.attachRef,n.route):this.activateWith(n.route,n.injector))}get isActivated(){return!!this.activated}get component(){if(!this.activated)throw new Qr(4012,!1);return this.activated.instance}get activatedRoute(){if(!this.activated)throw new Qr(4012,!1);return this._activatedRoute}get activatedRouteData(){return this._activatedRoute?this._activatedRoute.snapshot.data:{}}detach(){if(!this.activated)throw new Qr(4012,!1);this.location.detach();let n=this.activated;return this.activated=null,this._activatedRoute=null,this.detachEvents.emit(n.instance),n}attach(n,a){this.activated=n,this._activatedRoute=a,this.location.insert(n.hostView),this.inputBinder?.bindActivatedRouteToOutletComponent(this),this.attachEvents.emit(n.instance)}deactivate(){if(this.activated){let n=this.component;this.activated.destroy(),this.activated=null,this._activatedRoute=null,this.deactivateEvents.emit(n)}}activateWith(n,a){if(this.isActivated)throw new Qr(4013,!1);this._activatedRoute=n;let i=this.location,s=n.snapshot.component,u=this.parentContexts.getOrCreateContext(this.name).children,c=new hI(n,u,i.injector);this.activated=i.createComponent(s,{index:i.length,injector:c,environmentInjector:a??this.environmentInjector}),this.changeDetector.markForCheck(),this.inputBinder?.bindActivatedRouteToOutletComponent(this),this.activateEvents.emit(this.activated.instance)}};t.\u0275fac=function(a){return new(a||t)},t.\u0275dir=eE({type:t,selectors:[["router-outlet"]],inputs:{name:"name"},outputs:{activateEvents:"activate",deactivateEvents:"deactivate",attachEvents:"attach",detachEvents:"detach"},exportAs:["outlet"],standalone:!0,features:[VC]});let e=t;return e})(),hI=class{constructor(t,r,n){this.route=t,this.childContexts=r,this.parent=n}get(t,r){return t===Qg?this.route:t===g2?this.childContexts:this.parent.get(t,r)}},TI=new Nn("");function che(e,t,r){let n=l1(e,t._root,r?r._root:void 0);return new m2(n,t)}function l1(e,t,r){if(r&&e.shouldReuseRoute(t.value,r.value.snapshot)){let n=r.value;n._futureSnapshot=t.value;let a=lhe(e,t,r);return new Ku(n,a)}else{if(e.shouldAttach(t.value)){let i=e.retrieve(t.value);if(i!==null){let o=i.route;return o.value._futureSnapshot=t.value,o.children=t.children.map(s=>l1(e,s)),o}}let n=fhe(t.value),a=t.children.map(i=>l1(e,i));return new Ku(n,a)}}function lhe(e,t,r){return t.children.map(n=>{for(let a of r.children)if(e.shouldReuseRoute(n.value,a.value.snapshot))return l1(e,n,a);return l1(e,n)})}function fhe(e){return new Qg(new ha(e.url),new ha(e.params),new ha(e.queryParams),new ha(e.fragment),new ha(e.data),e.outlet,e.component,e)}var yV="ngNavigationCancelingError";function bV(e,t){let{redirectTo:r,navigationBehaviorOptions:n}=Zg(t)?{redirectTo:t,navigationBehaviorOptions:void 0}:t,a=xV(!1,0,t);return a.url=r,a.navigationBehaviorOptions=n,a}function xV(e,t,r){let n=new Error("NavigationCancelingError: "+(e||""));return n[yV]=!0,n.cancellationCode=t,r&&(n.url=r),n}function dhe(e){return SV(e)&&Zg(e.url)}function SV(e){return e&&e[yV]}var mhe=(()=>{let t=class t{};t.\u0275fac=function(a){return new(a||t)},t.\u0275cmp=kg({type:t,selectors:[["ng-component"]],standalone:!0,features:[Hg],decls:1,vars:0,template:function(a,i){a&1&&Oh(0,"router-outlet")},dependencies:[uhe],encapsulation:2});let e=t;return e})();function phe(e,t){return e.providers&&!e._injector&&(e._injector=PE(e.providers,t,`Route: ${e.path}`)),e._injector??t}function AI(e){let t=e.children&&e.children.map(AI),r=t?uo(Ar({},e),{children:t}):Ar({},e);return!r.component&&!r.loadComponent&&(t||r.loadChildren)&&r.outlet&&r.outlet!==cn&&(r.component=mhe),r}function vf(e){return e.outlet||cn}function hhe(e,t){let r=e.filter(n=>vf(n)===t);return r.push(...e.filter(n=>vf(n)!==t)),r}function m1(e){if(!e)return null;if(e.routeConfig?._injector)return e.routeConfig._injector;for(let t=e.parent;t;t=t.parent){let r=t.routeConfig;if(r?._loadedInjector)return r._loadedInjector;if(r?._injector)return r._injector}return null}var vhe=(e,t,r,n)=>Cn(a=>(new vI(t,a.targetRouterState,a.currentRouterState,r,n).activate(e),a)),vI=class{constructor(t,r,n,a,i){this.routeReuseStrategy=t,this.futureState=r,this.currState=n,this.forwardEvent=a,this.inputBindingEnabled=i}activate(t){let r=this.futureState._root,n=this.currState?this.currState._root:null;this.deactivateChildRoutes(r,n,t),XE(this.futureState.root),this.activateChildRoutes(r,n,t)}deactivateChildRoutes(t,r,n){let a=Wg(r);t.children.forEach(i=>{let o=i.value.outlet;this.deactivateRoutes(i,a[o],n),delete a[o]}),Object.values(a).forEach(i=>{this.deactivateRouteAndItsChildren(i,n)})}deactivateRoutes(t,r,n){let a=t.value,i=r?r.value:null;if(a===i)if(a.component){let o=n.getContext(a.outlet);o&&this.deactivateChildRoutes(t,r,o.children)}else this.deactivateChildRoutes(t,r,n);else i&&this.deactivateRouteAndItsChildren(r,n)}deactivateRouteAndItsChildren(t,r){t.value.component&&this.routeReuseStrategy.shouldDetach(t.value.snapshot)?this.detachAndStoreRouteSubtree(t,r):this.deactivateRouteAndOutlet(t,r)}detachAndStoreRouteSubtree(t,r){let n=r.getContext(t.value.outlet),a=n&&t.value.component?n.children:r,i=Wg(t);for(let o of Object.keys(i))this.deactivateRouteAndItsChildren(i[o],a);if(n&&n.outlet){let o=n.outlet.detach(),s=n.children.onOutletDeactivated();this.routeReuseStrategy.store(t.value.snapshot,{componentRef:o,route:t,contexts:s})}}deactivateRouteAndOutlet(t,r){let n=r.getContext(t.value.outlet),a=n&&t.value.component?n.children:r,i=Wg(t);for(let o of Object.keys(i))this.deactivateRouteAndItsChildren(i[o],a);n&&(n.outlet&&(n.outlet.deactivate(),n.children.onOutletDeactivated()),n.attachRef=null,n.route=null)}activateChildRoutes(t,r,n){let a=Wg(r);t.children.forEach(i=>{this.activateRoutes(i,a[i.value.outlet],n),this.forwardEvent(new lI(i.value.snapshot))}),t.children.length&&this.forwardEvent(new uI(t.value.snapshot))}activateRoutes(t,r,n){let a=t.value,i=r?r.value:null;if(XE(a),a===i)if(a.component){let o=n.getOrCreateContext(a.outlet);this.activateChildRoutes(t,r,o.children)}else this.activateChildRoutes(t,r,n);else if(a.component){let o=n.getOrCreateContext(a.outlet);if(this.routeReuseStrategy.shouldAttach(a.snapshot)){let s=this.routeReuseStrategy.retrieve(a.snapshot);this.routeReuseStrategy.store(a.snapshot,null),o.children.onOutletReAttached(s.contexts),o.attachRef=s.componentRef,o.route=s.route.value,o.outlet&&o.outlet.attach(s.componentRef,s.route.value),XE(s.route.value),this.activateChildRoutes(t,null,o.children)}else{let s=m1(a.snapshot);o.attachRef=null,o.route=a,o.injector=s,o.outlet&&o.outlet.activateWith(a,o.injector),this.activateChildRoutes(t,null,o.children)}}else this.activateChildRoutes(t,null,n)}},h2=class{constructor(t){this.path=t,this.route=this.path[this.path.length-1]}},Xg=class{constructor(t,r){this.component=t,this.route=r}};function ghe(e,t,r){let n=e._root,a=t?t._root:null;return Jb(n,a,r,[n.value])}function yhe(e){let t=e.routeConfig?e.routeConfig.canActivateChild:null;return!t||t.length===0?null:{node:e,guards:t}}function Jg(e,t){let r=Symbol(),n=t.get(e,r);return n===r?typeof e=="function"&&!ON(e)?e:t.get(e):n}function Jb(e,t,r,n,a={canDeactivateChecks:[],canActivateChecks:[]}){let i=Wg(t);return e.children.forEach(o=>{bhe(o,i[o.value.outlet],r,n.concat([o.value]),a),delete i[o.value.outlet]}),Object.entries(i).forEach(([o,s])=>n1(s,r.getContext(o),a)),a}function bhe(e,t,r,n,a={canDeactivateChecks:[],canActivateChecks:[]}){let i=e.value,o=t?t.value:null,s=r?r.getContext(e.value.outlet):null;if(o&&i.routeConfig===o.routeConfig){let u=xhe(o,i,i.routeConfig.runGuardsAndResolvers);u?a.canActivateChecks.push(new h2(n)):(i.data=o.data,i._resolvedData=o._resolvedData),i.component?Jb(e,t,s?s.children:null,n,a):Jb(e,t,r,n,a),u&&s&&s.outlet&&s.outlet.isActivated&&a.canDeactivateChecks.push(new Xg(s.outlet.component,o))}else o&&n1(t,s,a),a.canActivateChecks.push(new h2(n)),i.component?Jb(e,null,s?s.children:null,n,a):Jb(e,null,r,n,a);return a}function xhe(e,t,r){if(typeof r=="function")return r(e,t);switch(r){case"pathParamsChange":return!kh(e.url,t.url);case"pathParamsOrQueryParamsChange":return!kh(e.url,t.url)||!hf(e.queryParams,t.queryParams);case"always":return!0;case"paramsOrQueryParamsChange":return!pI(e,t)||!hf(e.queryParams,t.queryParams);case"paramsChange":default:return!pI(e,t)}}function n1(e,t,r){let n=Wg(e),a=e.value;Object.entries(n).forEach(([i,o])=>{a.component?t?n1(o,t.children.getContext(i),r):n1(o,null,r):n1(o,t,r)}),a.component?t&&t.outlet&&t.outlet.isActivated?r.canDeactivateChecks.push(new Xg(t.outlet.component,a)):r.canDeactivateChecks.push(new Xg(null,a)):r.canDeactivateChecks.push(new Xg(null,a))}function p1(e){return typeof e=="function"}function She(e){return typeof e=="boolean"}function Che(e){return e&&p1(e.canLoad)}function _he(e){return e&&p1(e.canActivate)}function whe(e){return e&&p1(e.canActivateChild)}function The(e){return e&&p1(e.canDeactivate)}function Ahe(e){return e&&p1(e.canMatch)}function CV(e){return e instanceof id||e?.name==="EmptyError"}var a2=Symbol("INITIAL_VALUE");function $g(){return ds(e=>cC(e.map(t=>t.pipe(Sl(1),iP(a2)))).pipe(Cn(t=>{for(let r of t)if(r!==!0){if(r===a2)return a2;if(r===!1||r instanceof ym)return r}return!0}),_s(t=>t!==a2),Sl(1)))}function Dhe(e,t){return To(r=>{let{targetSnapshot:n,currentSnapshot:a,guards:{canActivateChecks:i,canDeactivateChecks:o}}=r;return o.length===0&&i.length===0?Yr(uo(Ar({},r),{guardsResult:!0})):Phe(o,n,a,e).pipe(To(s=>s&&She(s)?Ehe(n,i,e,t):Yr(s)),Cn(s=>uo(Ar({},r),{guardsResult:s})))})}function Phe(e,t,r,n){return di(e).pipe(To(a=>Ohe(a.component,a.route,r,t,n)),uf(a=>a!==!0,!0))}function Ehe(e,t,r,n){return di(t).pipe(Sg(a=>xg(Mhe(a.route.parent,n),Ihe(a.route,n),Bhe(e,a.path,r),Rhe(e,a.route,r))),uf(a=>a!==!0,!0))}function Ihe(e,t){return e!==null&&t&&t(new cI(e)),Yr(!0)}function Mhe(e,t){return e!==null&&t&&t(new sI(e)),Yr(!0)}function Rhe(e,t,r){let n=t.routeConfig?t.routeConfig.canActivate:null;if(!n||n.length===0)return Yr(!0);let a=n.map(i=>lC(()=>{let o=m1(t)??r,s=Jg(i,o),u=_he(s)?s.canActivate(t,e):Eh(o,()=>s(t,e));return xm(u).pipe(uf())}));return Yr(a).pipe($g())}function Bhe(e,t,r){let n=t[t.length-1],i=t.slice(0,t.length-1).reverse().map(o=>yhe(o)).filter(o=>o!==null).map(o=>lC(()=>{let s=o.guards.map(u=>{let c=m1(o.node)??r,l=Jg(u,c),f=whe(l)?l.canActivateChild(n,e):Eh(c,()=>l(n,e));return xm(f).pipe(uf())});return Yr(s).pipe($g())}));return Yr(i).pipe($g())}function Ohe(e,t,r,n,a){let i=t&&t.routeConfig?t.routeConfig.canDeactivate:null;if(!i||i.length===0)return Yr(!0);let o=i.map(s=>{let u=m1(t)??a,c=Jg(s,u),l=The(c)?c.canDeactivate(e,t,r,n):Eh(u,()=>c(e,t,r,n));return xm(l).pipe(uf())});return Yr(o).pipe($g())}function Fhe(e,t,r,n){let a=t.canLoad;if(a===void 0||a.length===0)return Yr(!0);let i=a.map(o=>{let s=Jg(o,e),u=Che(s)?s.canLoad(t,r):Eh(e,()=>s(t,r));return xm(u)});return Yr(i).pipe($g(),_V(n))}function _V(e){return xb(Bo(t=>{if(Zg(t))throw bV(e,t)}),Cn(t=>t===!0))}function Lhe(e,t,r,n){let a=t.canMatch;if(!a||a.length===0)return Yr(!0);let i=a.map(o=>{let s=Jg(o,e),u=Ahe(s)?s.canMatch(t,r):Eh(e,()=>s(t,r));return xm(u)});return Yr(i).pipe($g(),_V(n))}var f1=class{constructor(t){this.segmentGroup=t||null}},v2=class extends Error{constructor(t){super(),this.urlTree=t}};function qg(e){return bg(new f1(e))}function khe(e){return bg(new Qr(4e3,!1))}function Nhe(e){return bg(xV(!1,3))}var gI=class{constructor(t,r){this.urlSerializer=t,this.urlTree=r}noMatchError(t){return new Qr(4002,!1)}lineralizeSegments(t,r){let n=[],a=r.root;for(;;){if(n=n.concat(a.segments),a.numberOfChildren===0)return Yr(n);if(a.numberOfChildren>1||!a.children[cn])return khe(t.redirectTo);a=a.children[cn]}}applyRedirectCommands(t,r,n){let a=this.applyRedirectCreateUrlTree(r,this.urlSerializer.parse(r),t,n);if(r.startsWith("/"))throw new v2(a);return a}applyRedirectCreateUrlTree(t,r,n,a){let i=this.createSegmentGroup(t,r.root,n,a);return new ym(i,this.createQueryParams(r.queryParams,this.urlTree.queryParams),r.fragment)}createQueryParams(t,r){let n={};return Object.entries(t).forEach(([a,i])=>{if(typeof i=="string"&&i.startsWith(":")){let s=i.substring(1);n[a]=r[s]}else n[a]=i}),n}createSegmentGroup(t,r,n,a){let i=this.createSegments(t,r.segments,n,a),o={};return Object.entries(r.children).forEach(([s,u])=>{o[s]=this.createSegmentGroup(t,u,n,a)}),new va(i,o)}createSegments(t,r,n,a){return r.map(i=>i.path.startsWith(":")?this.findPosParam(t,i,a):this.findOrReturn(i,n))}findPosParam(t,r,n){let a=n[r.path.substring(1)];if(!a)throw new Qr(4001,!1);return a}findOrReturn(t,r){let n=0;for(let a of r){if(a.path===t.path)return r.splice(n),a;n++}return t}},yI={matched:!1,consumedSegments:[],remainingSegments:[],parameters:{},positionalParamSegments:{}};function Uhe(e,t,r,n,a){let i=DI(e,t,r);return i.matched?(n=phe(t,n),Lhe(n,t,r,a).pipe(Cn(o=>o===!0?i:Ar({},yI)))):Yr(i)}function DI(e,t,r){if(t.path==="")return t.pathMatch==="full"&&(e.hasChildren()||r.length>0)?Ar({},yI):{matched:!0,consumedSegments:[],remainingSegments:r,parameters:{},positionalParamSegments:{}};let a=(t.matcher||Fpe)(r,e,t);if(!a)return Ar({},yI);let i={};Object.entries(a.posParams??{}).forEach(([s,u])=>{i[s]=u.path});let o=a.consumed.length>0?Ar(Ar({},i),a.consumed[a.consumed.length-1].parameters):i;return{matched:!0,consumedSegments:a.consumed,remainingSegments:r.slice(a.consumed.length),parameters:o,positionalParamSegments:a.posParams??{}}}function JU(e,t,r,n){return r.length>0&&zhe(e,r,n)?{segmentGroup:new va(t,Ghe(n,new va(r,e.children))),slicedSegments:[]}:r.length===0&&Hhe(e,r,n)?{segmentGroup:new va(e.segments,Vhe(e,t,r,n,e.children)),slicedSegments:r}:{segmentGroup:new va(e.segments,e.children),slicedSegments:r}}function Vhe(e,t,r,n,a){let i={};for(let o of n)if(y2(e,r,o)&&!a[vf(o)]){let s=new va([],{});i[vf(o)]=s}return Ar(Ar({},a),i)}function Ghe(e,t){let r={};r[cn]=t;for(let n of e)if(n.path===""&&vf(n)!==cn){let a=new va([],{});r[vf(n)]=a}return r}function zhe(e,t,r){return r.some(n=>y2(e,t,n)&&vf(n)!==cn)}function Hhe(e,t,r){return r.some(n=>y2(e,t,n))}function y2(e,t,r){return(e.hasChildren()||t.length>0)&&r.pathMatch==="full"?!1:r.path===""}function jhe(e,t,r,n){return vf(e)!==n&&(n===cn||!y2(t,r,e))?!1:e.path==="**"?!0:DI(t,e,r).matched}function qhe(e,t,r){return t.length===0&&!e.children[r]}var bI=class{};function Whe(e,t,r,n,a,i,o="emptyOnly"){return new xI(e,t,r,n,a,o,i).recognize()}var Yhe=31,xI=class{constructor(t,r,n,a,i,o,s){this.injector=t,this.configLoader=r,this.rootComponentType=n,this.config=a,this.urlTree=i,this.paramsInheritanceStrategy=o,this.urlSerializer=s,this.applyRedirects=new gI(this.urlSerializer,this.urlTree),this.absoluteRedirectCount=0,this.allowRedirects=!0}noMatchError(t){return new Qr(4002,!1)}recognize(){let t=JU(this.urlTree.root,[],[],this.config).segmentGroup;return this.match(t).pipe(Cn(r=>{let n=new c1([],Object.freeze({}),Object.freeze(Ar({},this.urlTree.queryParams)),this.urlTree.fragment,{},cn,this.rootComponentType,null,{}),a=new Ku(n,r),i=new p2("",a),o=ehe(n,[],this.urlTree.queryParams,this.urlTree.fragment);return o.queryParams=this.urlTree.queryParams,i.url=this.urlSerializer.serialize(o),this.inheritParamsAndData(i._root,null),{state:i,tree:o}}))}match(t){return this.processSegmentGroup(this.injector,this.config,t,cn).pipe(mm(n=>{if(n instanceof v2)return this.urlTree=n.urlTree,this.match(n.urlTree.root);throw n instanceof f1?this.noMatchError(n):n}))}inheritParamsAndData(t,r){let n=t.value,a=_I(n,r,this.paramsInheritanceStrategy);n.params=Object.freeze(a.params),n.data=Object.freeze(a.data),t.children.forEach(i=>this.inheritParamsAndData(i,n))}processSegmentGroup(t,r,n,a){return n.segments.length===0&&n.hasChildren()?this.processChildren(t,r,n):this.processSegment(t,r,n,n.segments,a,!0).pipe(Cn(i=>i instanceof Ku?[i]:[]))}processChildren(t,r,n){let a=[];for(let i of Object.keys(n.children))i==="primary"?a.unshift(i):a.push(i);return di(a).pipe(Sg(i=>{let o=n.children[i],s=hhe(r,i);return this.processSegmentGroup(t,s,o,i)}),rP((i,o)=>(i.push(...o),i)),pm(null),tP(),To(i=>{if(i===null)return qg(n);let o=wV(i);return Xhe(o),Yr(o)}))}processSegment(t,r,n,a,i,o){return di(r).pipe(Sg(s=>this.processSegmentAgainstRoute(s._injector??t,r,s,n,a,i,o).pipe(mm(u=>{if(u instanceof f1)return Yr(null);throw u}))),uf(s=>!!s),mm(s=>{if(CV(s))return qhe(n,a,i)?Yr(new bI):qg(n);throw s}))}processSegmentAgainstRoute(t,r,n,a,i,o,s){return jhe(n,a,i,o)?n.redirectTo===void 0?this.matchSegmentAgainstRoute(t,a,n,i,o):this.allowRedirects&&s?this.expandSegmentAgainstRouteUsingRedirect(t,a,r,n,i,o):qg(a):qg(a)}expandSegmentAgainstRouteUsingRedirect(t,r,n,a,i,o){let{matched:s,consumedSegments:u,positionalParamSegments:c,remainingSegments:l}=a.path==="**"?eV(i):DI(r,a,i);if(!s)return qg(r);a.redirectTo.startsWith("/")&&(this.absoluteRedirectCount++,this.absoluteRedirectCount>Yhe&&(this.allowRedirects=!1));let f=this.applyRedirects.applyRedirectCommands(u,a.redirectTo,c);return this.applyRedirects.lineralizeSegments(a,f).pipe(To(d=>this.processSegment(t,n,r,d.concat(l),o,!1)))}matchSegmentAgainstRoute(t,r,n,a,i){let o;return n.path==="**"?(o=Yr(eV(a)),r.children={}):o=Uhe(r,n,a,t,this.urlSerializer),o.pipe(ds(s=>s.matched?(t=n._injector??t,this.getChildConfig(t,n,a).pipe(ds(({routes:u})=>{let c=n._loadedInjector??t,{consumedSegments:l,remainingSegments:f,parameters:d}=s,m=new c1(l,d,Object.freeze(Ar({},this.urlTree.queryParams)),this.urlTree.fragment,Zhe(n),vf(n),n.component??n._loadedComponent??null,n,Qhe(n)),{segmentGroup:h,slicedSegments:p}=JU(r,l,f,u);if(p.length===0&&h.hasChildren())return this.processChildren(c,u,h).pipe(Cn(g=>g===null?null:new Ku(m,g)));if(u.length===0&&p.length===0)return Yr(new Ku(m,[]));let v=vf(n)===i;return this.processSegment(c,u,h,p,v?cn:i,!0).pipe(Cn(g=>new Ku(m,g instanceof Ku?[g]:[])))}))):qg(r)))}getChildConfig(t,r,n){return r.children?Yr({routes:r.children,injector:t}):r.loadChildren?r._loadedRoutes!==void 0?Yr({routes:r._loadedRoutes,injector:r._loadedInjector}):Fhe(t,r,n,this.urlSerializer).pipe(To(a=>a?this.configLoader.loadChildren(t,r).pipe(Bo(i=>{r._loadedRoutes=i.routes,r._loadedInjector=i.injector})):Nhe(r))):Yr({routes:[],injector:t})}};function Xhe(e){e.sort((t,r)=>t.value.outlet===cn?-1:r.value.outlet===cn?1:t.value.outlet.localeCompare(r.value.outlet))}function Khe(e){let t=e.value.routeConfig;return t&&t.path===""}function wV(e){let t=[],r=new Set;for(let n of e){if(!Khe(n)){t.push(n);continue}let a=t.find(i=>n.value.routeConfig===i.value.routeConfig);a!==void 0?(a.children.push(...n.children),r.add(a)):t.push(n)}for(let n of r){let a=wV(n.children);t.push(new Ku(n.value,a))}return t.filter(n=>!r.has(n))}function Zhe(e){return e.data||{}}function Qhe(e){return e.resolve||{}}function eV(e){return{matched:!0,parameters:e.length>0?rV(e).parameters:{},consumedSegments:e,remainingSegments:[],positionalParamSegments:{}}}function $he(e,t,r,n,a,i){return To(o=>Whe(e,t,r,n,o.extractedUrl,a,i).pipe(Cn(({state:s,tree:u})=>uo(Ar({},o),{targetSnapshot:s,urlAfterRedirects:u}))))}function Jhe(e,t){return To(r=>{let{targetSnapshot:n,guards:{canActivateChecks:a}}=r;if(!a.length)return Yr(r);let i=new Set(a.map(u=>u.route)),o=new Set;for(let u of i)if(!o.has(u))for(let c of TV(u))o.add(c);let s=0;return di(o).pipe(Sg(u=>i.has(u)?eve(u,n,e,t):(u.data=_I(u,u.parent,e).resolve,Yr(void 0))),Bo(()=>s++),_g(1),To(u=>s===o.size?Yr(r):fu))})}function TV(e){let t=e.children.map(r=>TV(r)).flat();return[e,...t]}function eve(e,t,r,n){let a=e.routeConfig,i=e._resolve;return a?.title!==void 0&&!gV(a)&&(i[d1]=a.title),tve(i,e,t,n).pipe(Cn(o=>(e._resolvedData=o,e.data=_I(e,e.parent,r).resolve,null)))}function tve(e,t,r,n){let a=QE(e);if(a.length===0)return Yr({});let i={};return di(a).pipe(To(o=>rve(e[o],t,r,n).pipe(uf(),Bo(s=>{i[o]=s}))),_g(1),eP(i),mm(o=>CV(o)?fu:bg(o)))}function rve(e,t,r,n){let a=m1(t)??n,i=Jg(e,a),o=i.resolve?i.resolve(t,r):Eh(a,()=>i(t,r));return xm(o)}function KE(e){return ds(t=>{let r=e(t);return r?di(r).pipe(Cn(()=>t)):Yr(t)})}var AV=(()=>{let t=class t{buildTitle(n){let a,i=n.root;for(;i!==void 0;)a=this.getResolvedTitleForRoute(i)??a,i=i.children.find(o=>o.outlet===cn);return a}getResolvedTitleForRoute(n){return n.data[d1]}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:()=>(()=>br(nve))(),providedIn:"root"});let e=t;return e})(),nve=(()=>{let t=class t extends AV{constructor(n){super(),this.title=n}updateTitle(n){let a=this.buildTitle(n);a!==void 0&&this.title.setTitle(a)}};t.\u0275fac=function(a){return new(a||t)(On(qE))},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),PI=new Nn("",{providedIn:"root",factory:()=>({})}),EI=new Nn("ROUTES"),ave=(()=>{let t=class t{constructor(){this.componentLoaders=new WeakMap,this.childrenLoaders=new WeakMap,this.compiler=br(BE)}loadComponent(n){if(this.componentLoaders.get(n))return this.componentLoaders.get(n);if(n._loadedComponent)return Yr(n._loadedComponent);this.onLoadStartListener&&this.onLoadStartListener(n);let a=xm(n.loadComponent()).pipe(Cn(DV),Bo(o=>{this.onLoadEndListener&&this.onLoadEndListener(n),n._loadedComponent=o}),Tb(()=>{this.componentLoaders.delete(n)})),i=new gg(a,()=>new kr).pipe(vg());return this.componentLoaders.set(n,i),i}loadChildren(n,a){if(this.childrenLoaders.get(a))return this.childrenLoaders.get(a);if(a._loadedRoutes)return Yr({routes:a._loadedRoutes,injector:a._loadedInjector});this.onLoadStartListener&&this.onLoadStartListener(a);let o=ive(a,this.compiler,n,this.onLoadEndListener).pipe(Tb(()=>{this.childrenLoaders.delete(a)})),s=new gg(o,()=>new kr).pipe(vg());return this.childrenLoaders.set(a,s),s}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})();function ive(e,t,r,n){return xm(e.loadChildren()).pipe(Cn(DV),To(a=>a instanceof Nb||Array.isArray(a)?Yr(a):di(t.compileModuleAsync(a))),Cn(a=>{n&&n(e);let i,o,s=!1;return Array.isArray(a)?(o=a,s=!0):(i=a.create(r).injector,o=i.get(EI,[],{optional:!0,self:!0}).flat()),{routes:o.map(AI),injector:i}}))}function ove(e){return e&&typeof e=="object"&&"default"in e}function DV(e){return ove(e)?e.default:e}var II=(()=>{let t=class t{};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:()=>(()=>br(sve))(),providedIn:"root"});let e=t;return e})(),sve=(()=>{let t=class t{shouldProcessUrl(n){return!0}extract(n){return n}merge(n,a){return n}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),uve=new Nn("");var cve=(()=>{let t=class t{get hasRequestedNavigation(){return this.navigationId!==0}constructor(){this.currentNavigation=null,this.currentTransition=null,this.lastSuccessfulNavigation=null,this.events=new kr,this.transitionAbortSubject=new kr,this.configLoader=br(ave),this.environmentInjector=br(_c),this.urlSerializer=br(CI),this.rootContexts=br(g2),this.location=br(Xb),this.inputBindingEnabled=br(TI,{optional:!0})!==null,this.titleStrategy=br(AV),this.options=br(PI,{optional:!0})||{},this.paramsInheritanceStrategy=this.options.paramsInheritanceStrategy||"emptyOnly",this.urlHandlingStrategy=br(II),this.createViewTransition=br(uve,{optional:!0}),this.navigationId=0,this.afterPreactivation=()=>Yr(void 0),this.rootComponentType=null;let n=i=>this.events.next(new iI(i)),a=i=>this.events.next(new oI(i));this.configLoader.onLoadEndListener=a,this.configLoader.onLoadStartListener=n}complete(){this.transitions?.complete()}handleNavigationRequest(n){let a=++this.navigationId;this.transitions?.next(uo(Ar(Ar({},this.transitions.value),n),{id:a}))}setupNavigations(n,a,i){return this.transitions=new ha({id:0,currentUrlTree:a,currentRawUrl:a,extractedUrl:this.urlHandlingStrategy.extract(a),urlAfterRedirects:this.urlHandlingStrategy.extract(a),rawUrl:a,extras:{},resolve:null,reject:null,promise:Promise.resolve(!0),source:r1,restoredState:null,currentSnapshot:i.snapshot,targetSnapshot:null,currentRouterState:i,targetRouterState:null,guards:{canActivateChecks:[],canDeactivateChecks:[]},guardsResult:null}),this.transitions.pipe(_s(o=>o.id!==0),Cn(o=>uo(Ar({},o),{extractedUrl:this.urlHandlingStrategy.extract(o.rawUrl)})),ds(o=>{this.currentTransition=o;let s=!1,u=!1;return Yr(o).pipe(Bo(c=>{this.currentNavigation={id:c.id,initialUrl:c.rawUrl,extractedUrl:c.extractedUrl,trigger:c.source,extras:c.extras,previousNavigation:this.lastSuccessfulNavigation?uo(Ar({},this.lastSuccessfulNavigation),{previousNavigation:null}):null}}),ds(c=>{let l=!n.navigated||this.isUpdatingInternalState()||this.isUpdatedBrowserUrl(),f=c.extras.onSameUrlNavigation??n.onSameUrlNavigation;if(!l&&f!=="reload"){let d="";return this.events.next(new Uh(c.id,this.urlSerializer.serialize(c.rawUrl),d,0)),c.resolve(null),fu}if(this.urlHandlingStrategy.shouldProcessUrl(c.rawUrl))return Yr(c).pipe(ds(d=>{let m=this.transitions?.getValue();return this.events.next(new i1(d.id,this.urlSerializer.serialize(d.extractedUrl),d.source,d.restoredState)),m!==this.transitions?.getValue()?fu:Promise.resolve(d)}),$he(this.environmentInjector,this.configLoader,this.rootComponentType,n.config,this.urlSerializer,this.paramsInheritanceStrategy),Bo(d=>{o.targetSnapshot=d.targetSnapshot,o.urlAfterRedirects=d.urlAfterRedirects,this.currentNavigation=uo(Ar({},this.currentNavigation),{finalUrl:d.urlAfterRedirects});let m=new f2(d.id,this.urlSerializer.serialize(d.extractedUrl),this.urlSerializer.serialize(d.urlAfterRedirects),d.targetSnapshot);this.events.next(m)}));if(l&&this.urlHandlingStrategy.shouldProcessUrl(c.currentRawUrl)){let{id:d,extractedUrl:m,source:h,restoredState:p,extras:v}=c,g=new i1(d,this.urlSerializer.serialize(m),h,p);this.events.next(g);let b=hV(m,this.rootComponentType).snapshot;return this.currentTransition=o=uo(Ar({},c),{targetSnapshot:b,urlAfterRedirects:m,extras:uo(Ar({},v),{skipLocationChange:!1,replaceUrl:!1})}),this.currentNavigation.finalUrl=m,Yr(o)}else{let d="";return this.events.next(new Uh(c.id,this.urlSerializer.serialize(c.extractedUrl),d,1)),c.resolve(null),fu}}),Bo(c=>{let l=new tI(c.id,this.urlSerializer.serialize(c.extractedUrl),this.urlSerializer.serialize(c.urlAfterRedirects),c.targetSnapshot);this.events.next(l)}),Cn(c=>(this.currentTransition=o=uo(Ar({},c),{guards:ghe(c.targetSnapshot,c.currentSnapshot,this.rootContexts)}),o)),Dhe(this.environmentInjector,c=>this.events.next(c)),Bo(c=>{if(o.guardsResult=c.guardsResult,Zg(c.guardsResult))throw bV(this.urlSerializer,c.guardsResult);let l=new rI(c.id,this.urlSerializer.serialize(c.extractedUrl),this.urlSerializer.serialize(c.urlAfterRedirects),c.targetSnapshot,!!c.guardsResult);this.events.next(l)}),_s(c=>c.guardsResult?!0:(this.cancelNavigationTransition(c,"",3),!1)),KE(c=>{if(c.guards.canActivateChecks.length)return Yr(c).pipe(Bo(l=>{let f=new nI(l.id,this.urlSerializer.serialize(l.extractedUrl),this.urlSerializer.serialize(l.urlAfterRedirects),l.targetSnapshot);this.events.next(f)}),ds(l=>{let f=!1;return Yr(l).pipe(Jhe(this.paramsInheritanceStrategy,this.environmentInjector),Bo({next:()=>f=!0,complete:()=>{f||this.cancelNavigationTransition(l,"",2)}}))}),Bo(l=>{let f=new aI(l.id,this.urlSerializer.serialize(l.extractedUrl),this.urlSerializer.serialize(l.urlAfterRedirects),l.targetSnapshot);this.events.next(f)}))}),KE(c=>{let l=f=>{let d=[];f.routeConfig?.loadComponent&&!f.routeConfig._loadedComponent&&d.push(this.configLoader.loadComponent(f.routeConfig).pipe(Bo(m=>{f.component=m}),Cn(()=>{})));for(let m of f.children)d.push(...l(m));return d};return cC(l(c.targetSnapshot.root)).pipe(pm(),Sl(1))}),KE(()=>this.afterPreactivation()),ds(()=>{let{currentSnapshot:c,targetSnapshot:l}=o,f=this.createViewTransition?.(this.environmentInjector,c.root,l.root);return f?di(f).pipe(Cn(()=>o)):Yr(o)}),Cn(c=>{let l=che(n.routeReuseStrategy,c.targetSnapshot,c.currentRouterState);return this.currentTransition=o=uo(Ar({},c),{targetRouterState:l}),this.currentNavigation.targetRouterState=l,o}),Bo(()=>{this.events.next(new s1)}),vhe(this.rootContexts,n.routeReuseStrategy,c=>this.events.next(c),this.inputBindingEnabled),Sl(1),Bo({next:c=>{s=!0,this.lastSuccessfulNavigation=this.currentNavigation,this.events.next(new Nh(c.id,this.urlSerializer.serialize(c.extractedUrl),this.urlSerializer.serialize(c.urlAfterRedirects))),this.titleStrategy?.updateTitle(c.targetRouterState.snapshot),c.resolve(!0)},complete:()=>{s=!0}}),oP(this.transitionAbortSubject.pipe(Bo(c=>{throw c}))),Tb(()=>{if(!s&&!u){let c="";this.cancelNavigationTransition(o,c,1)}this.currentNavigation?.id===o.id&&(this.currentNavigation=null)}),mm(c=>{if(u=!0,SV(c))this.events.next(new bm(o.id,this.urlSerializer.serialize(o.extractedUrl),c.message,c.cancellationCode)),dhe(c)?this.events.next(new u1(c.url)):o.resolve(!1);else{this.events.next(new o1(o.id,this.urlSerializer.serialize(o.extractedUrl),c,o.targetSnapshot??void 0));try{o.resolve(n.errorHandler(c))}catch(l){o.reject(l)}}return fu}))}))}cancelNavigationTransition(n,a,i){let o=new bm(n.id,this.urlSerializer.serialize(n.extractedUrl),a,i);this.events.next(o),n.resolve(!1)}isUpdatingInternalState(){return this.currentTransition?.extractedUrl.toString()!==this.currentTransition?.currentUrlTree.toString()}isUpdatedBrowserUrl(){return this.urlHandlingStrategy.extract(this.urlSerializer.parse(this.location.path(!0))).toString()!==this.currentTransition?.extractedUrl.toString()&&!this.currentTransition?.extras.skipLocationChange}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})();function lve(e){return e!==r1}var fve=(()=>{let t=class t{};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:()=>(()=>br(dve))(),providedIn:"root"});let e=t;return e})(),SI=class{shouldDetach(t){return!1}store(t,r){}shouldAttach(t){return!1}retrieve(t){return null}shouldReuseRoute(t,r){return t.routeConfig===r.routeConfig}},dve=(()=>{let t=class t extends SI{};t.\u0275fac=(()=>{let n;return function(i){return(n||(n=sE(t)))(i||t)}})(),t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),PV=(()=>{let t=class t{};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:()=>(()=>br(mve))(),providedIn:"root"});let e=t;return e})(),mve=(()=>{let t=class t extends PV{constructor(){super(...arguments),this.location=br(Xb),this.urlSerializer=br(CI),this.options=br(PI,{optional:!0})||{},this.canceledNavigationResolution=this.options.canceledNavigationResolution||"replace",this.urlHandlingStrategy=br(II),this.urlUpdateStrategy=this.options.urlUpdateStrategy||"deferred",this.currentUrlTree=new ym,this.rawUrlTree=this.currentUrlTree,this.currentPageId=0,this.lastSuccessfulId=-1,this.routerState=hV(this.currentUrlTree,null),this.stateMemento=this.createStateMemento()}getCurrentUrlTree(){return this.currentUrlTree}getRawUrlTree(){return this.rawUrlTree}restoredState(){return this.location.getState()}get browserPageId(){return this.canceledNavigationResolution!=="computed"?this.currentPageId:this.restoredState()?.\u0275routerPageId??this.currentPageId}getRouterState(){return this.routerState}createStateMemento(){return{rawUrlTree:this.rawUrlTree,currentUrlTree:this.currentUrlTree,routerState:this.routerState}}registerNonRouterCurrentEntryChangeListener(n){return this.location.subscribe(a=>{a.type==="popstate"&&n(a.url,a.state)})}handleRouterEvent(n,a){if(n instanceof i1)this.stateMemento=this.createStateMemento();else if(n instanceof Uh)this.rawUrlTree=a.initialUrl;else if(n instanceof f2){if(this.urlUpdateStrategy==="eager"&&!a.extras.skipLocationChange){let i=this.urlHandlingStrategy.merge(a.finalUrl,a.initialUrl);this.setBrowserUrl(i,a)}}else n instanceof s1?(this.currentUrlTree=a.finalUrl,this.rawUrlTree=this.urlHandlingStrategy.merge(a.finalUrl,a.initialUrl),this.routerState=a.targetRouterState,this.urlUpdateStrategy==="deferred"&&(a.extras.skipLocationChange||this.setBrowserUrl(this.rawUrlTree,a))):n instanceof bm&&(n.code===3||n.code===2)?this.restoreHistory(a):n instanceof o1?this.restoreHistory(a,!0):n instanceof Nh&&(this.lastSuccessfulId=n.id,this.currentPageId=this.browserPageId)}setBrowserUrl(n,a){let i=this.urlSerializer.serialize(n);if(this.location.isCurrentPathEqualTo(i)||a.extras.replaceUrl){let o=this.browserPageId,s=Ar(Ar({},a.extras.state),this.generateNgRouterState(a.id,o));this.location.replaceState(i,"",s)}else{let o=Ar(Ar({},a.extras.state),this.generateNgRouterState(a.id,this.browserPageId+1));this.location.go(i,"",o)}}restoreHistory(n,a=!1){if(this.canceledNavigationResolution==="computed"){let i=this.browserPageId,o=this.currentPageId-i;o!==0?this.location.historyGo(o):this.currentUrlTree===n.finalUrl&&o===0&&(this.resetState(n),this.resetUrlToCurrentUrlTree())}else this.canceledNavigationResolution==="replace"&&(a&&this.resetState(n),this.resetUrlToCurrentUrlTree())}resetState(n){this.routerState=this.stateMemento.routerState,this.currentUrlTree=this.stateMemento.currentUrlTree,this.rawUrlTree=this.urlHandlingStrategy.merge(this.currentUrlTree,n.finalUrl??this.rawUrlTree)}resetUrlToCurrentUrlTree(){this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree),"",this.generateNgRouterState(this.lastSuccessfulId,this.currentPageId))}generateNgRouterState(n,a){return this.canceledNavigationResolution==="computed"?{navigationId:n,\u0275routerPageId:a}:{navigationId:n}}};t.\u0275fac=(()=>{let n;return function(i){return(n||(n=sE(t)))(i||t)}})(),t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})(),e1=function(e){return e[e.COMPLETE=0]="COMPLETE",e[e.FAILED=1]="FAILED",e[e.REDIRECTING=2]="REDIRECTING",e}(e1||{});function pve(e,t){e.events.pipe(_s(r=>r instanceof Nh||r instanceof bm||r instanceof o1||r instanceof Uh),Cn(r=>r instanceof Nh||r instanceof Uh?e1.COMPLETE:(r instanceof bm?r.code===0||r.code===1:!1)?e1.REDIRECTING:e1.FAILED),_s(r=>r!==e1.REDIRECTING),Sl(1)).subscribe(()=>{t()})}function hve(e){throw e}var vve={paths:"exact",fragment:"ignored",matrixParams:"ignored",queryParams:"exact"},gve={paths:"subset",fragment:"ignored",matrixParams:"ignored",queryParams:"subset"},EV=(()=>{let t=class t{get currentUrlTree(){return this.stateManager.getCurrentUrlTree()}get rawUrlTree(){return this.stateManager.getRawUrlTree()}get events(){return this._events}get routerState(){return this.stateManager.getRouterState()}constructor(){this.disposed=!1,this.isNgZoneEnabled=!1,this.console=br(QC),this.stateManager=br(PV),this.options=br(PI,{optional:!0})||{},this.pendingTasks=br(RE),this.urlUpdateStrategy=this.options.urlUpdateStrategy||"deferred",this.navigationTransitions=br(cve),this.urlSerializer=br(CI),this.location=br(Xb),this.urlHandlingStrategy=br(II),this._events=new kr,this.errorHandler=this.options.errorHandler||hve,this.navigated=!1,this.routeReuseStrategy=br(fve),this.onSameUrlNavigation=this.options.onSameUrlNavigation||"ignore",this.config=br(EI,{optional:!0})?.flat()??[],this.componentInputBindingEnabled=!!br(TI,{optional:!0}),this.eventsSubscription=new co,this.isNgZoneEnabled=br(lo)instanceof lo&&lo.isInAngularZone(),this.resetConfig(this.config),this.navigationTransitions.setupNavigations(this,this.currentUrlTree,this.routerState).subscribe({error:n=>{this.console.warn(n)}}),this.subscribeToNavigationEvents()}subscribeToNavigationEvents(){let n=this.navigationTransitions.events.subscribe(a=>{try{let i=this.navigationTransitions.currentTransition,o=this.navigationTransitions.currentNavigation;if(i!==null&&o!==null){if(this.stateManager.handleRouterEvent(a,o),a instanceof bm&&a.code!==0&&a.code!==1)this.navigated=!0;else if(a instanceof Nh)this.navigated=!0;else if(a instanceof u1){let s=this.urlHandlingStrategy.merge(a.url,i.currentRawUrl),u={skipLocationChange:i.extras.skipLocationChange,replaceUrl:this.urlUpdateStrategy==="eager"||lve(i.source)};this.scheduleNavigation(s,r1,null,u,{resolve:i.resolve,reject:i.reject,promise:i.promise})}}bve(a)&&this._events.next(a)}catch(i){this.navigationTransitions.transitionAbortSubject.next(i)}});this.eventsSubscription.add(n)}resetRootComponentType(n){this.routerState.root.component=n,this.navigationTransitions.rootComponentType=n}initialNavigation(){this.setUpLocationChangeListener(),this.navigationTransitions.hasRequestedNavigation||this.navigateToSyncWithBrowser(this.location.path(!0),r1,this.stateManager.restoredState())}setUpLocationChangeListener(){this.nonRouterCurrentEntryChangeSubscription||(this.nonRouterCurrentEntryChangeSubscription=this.stateManager.registerNonRouterCurrentEntryChangeListener((n,a)=>{setTimeout(()=>{this.navigateToSyncWithBrowser(n,"popstate",a)},0)}))}navigateToSyncWithBrowser(n,a,i){let o={replaceUrl:!0},s=i?.navigationId?i:null;if(i){let c=Ar({},i);delete c.navigationId,delete c.\u0275routerPageId,Object.keys(c).length!==0&&(o.state=c)}let u=this.parseUrl(n);this.scheduleNavigation(u,a,s,o)}get url(){return this.serializeUrl(this.currentUrlTree)}getCurrentNavigation(){return this.navigationTransitions.currentNavigation}get lastSuccessfulNavigation(){return this.navigationTransitions.lastSuccessfulNavigation}resetConfig(n){this.config=n.map(AI),this.navigated=!1}ngOnDestroy(){this.dispose()}dispose(){this.navigationTransitions.complete(),this.nonRouterCurrentEntryChangeSubscription&&(this.nonRouterCurrentEntryChangeSubscription.unsubscribe(),this.nonRouterCurrentEntryChangeSubscription=void 0),this.disposed=!0,this.eventsSubscription.unsubscribe()}createUrlTree(n,a={}){let{relativeTo:i,queryParams:o,fragment:s,queryParamsHandling:u,preserveFragment:c}=a,l=c?this.currentUrlTree.fragment:s,f=null;switch(u){case"merge":f=Ar(Ar({},this.currentUrlTree.queryParams),o);break;case"preserve":f=this.currentUrlTree.queryParams;break;default:f=o||null}f!==null&&(f=this.removeEmptyProps(f));let d;try{let m=i?i.snapshot:this.routerState.snapshot.root;d=fV(m)}catch{(typeof n[0]!="string"||!n[0].startsWith("/"))&&(n=[]),d=this.currentUrlTree.root}return dV(d,n,f,l??null)}navigateByUrl(n,a={skipLocationChange:!1}){let i=Zg(n)?n:this.parseUrl(n),o=this.urlHandlingStrategy.merge(i,this.rawUrlTree);return this.scheduleNavigation(o,r1,null,a)}navigate(n,a={skipLocationChange:!1}){return yve(n),this.navigateByUrl(this.createUrlTree(n,a),a)}serializeUrl(n){return this.urlSerializer.serialize(n)}parseUrl(n){try{return this.urlSerializer.parse(n)}catch{return this.urlSerializer.parse("/")}}isActive(n,a){let i;if(a===!0?i=Ar({},vve):a===!1?i=Ar({},gve):i=a,Zg(n))return KU(this.currentUrlTree,n,i);let o=this.parseUrl(n);return KU(this.currentUrlTree,o,i)}removeEmptyProps(n){return Object.keys(n).reduce((a,i)=>{let o=n[i];return o!=null&&(a[i]=o),a},{})}scheduleNavigation(n,a,i,o,s){if(this.disposed)return Promise.resolve(!1);let u,c,l;s?(u=s.resolve,c=s.reject,l=s.promise):l=new Promise((d,m)=>{u=d,c=m});let f=this.pendingTasks.add();return pve(this,()=>{queueMicrotask(()=>this.pendingTasks.remove(f))}),this.navigationTransitions.handleNavigationRequest({source:a,restoredState:i,currentUrlTree:this.currentUrlTree,currentRawUrl:this.currentUrlTree,rawUrl:n,extras:o,resolve:u,reject:c,promise:l,currentSnapshot:this.routerState.snapshot,currentRouterState:this.routerState}),l.catch(d=>Promise.reject(d))}};t.\u0275fac=function(a){return new(a||t)},t.\u0275prov=un({token:t,factory:t.\u0275fac,providedIn:"root"});let e=t;return e})();function yve(e){for(let t=0;tr.\u0275providers)])}function Sve(e){return e.routerState.root}function Cve(){let e=br(Ug);return t=>{let r=e.get(Wb);if(t!==r.components[0])return;let n=e.get(EV),a=e.get(_ve);e.get(wve)===1&&n.initialNavigation(),e.get(Tve,null,_n.Optional)?.setUpPreloading(),e.get(xve,null,_n.Optional)?.init(),n.resetRootComponentType(r.componentTypes[0]),a.closed||(a.next(),a.complete(),a.unsubscribe())}}var _ve=new Nn("",{factory:()=>new kr}),wve=new Nn("",{providedIn:"root",factory:()=>1});var Tve=new Nn("");var MV=[];var RV={providers:[IV(MV)]};var ws;(function(e){function t(n){return n}e.create=t;function r(n,a){var i,o;if(a.customDurationMs)return a.customDurationMs;var s=(o=(i=a.definition).getDuration)===null||o===void 0?void 0:o.call(i,a.params,n);if(s?.kind==="fixed")return s.durationMs}e.getDuration=r})(ws||(ws={}));var Ya;(function(e){function t(a){return a}e.create=t;function r(a,i){return(a&i)!==0}e.has=r;function n(a,i){return!!i&&(a&i)===i}e.hasAll=n})(Ya||(Ya={}));var $r;(function(e){function t(S){return S===void 0&&(S=512),{current:[],offset:0,capacity:S,chunks:[]}}e.create=t;function r(S){return S.chunks.length?(S.offset>0&&(S.chunks[S.chunks.length]=S.current.length===S.offset?S.current.join(""):S.current.slice(0,S.offset).join("")),S.chunks.join("")):S.current.length===S.offset?S.current.join(""):S.current.splice(0,S.offset).join("")}e.getString=r;function n(S){for(var _=0,C=0,D=S.chunks;C0&&(S.current.length===S.offset?S.chunks[S.chunks.length]=S.current.join(""):S.chunks[S.chunks.length]=S.current.slice(0,S.offset).join(""),S.offset=0),S.chunks}e.getChunks=a;var i=[];(function(){for(var S="",_=0;_<512;_++)i[_]=S,S=S+" "})();function o(S){l(S,` +`)}e.newline=o;function s(S,_){_>0&&l(S,i[_])}e.whitespace=s;function u(S){l(S," ")}e.whitespace1=u;function c(S,_){_&&(S.offset===S.capacity&&(S.chunks[S.chunks.length]=S.current.join(""),S.offset=0),S.current[S.offset++]=_)}e.write=c;function l(S,_){S.offset===S.capacity&&(S.chunks[S.chunks.length]=S.current.join(""),S.offset=0),S.current[S.offset++]=_}e.writeSafe=l;function f(S,_,C){if(!_){s(S,C);return}var D=C-_.length;s(S,D),l(S,_)}e.writePadLeft=f;function d(S,_,C){if(!_){s(S,C);return}var D=C-_.length;l(S,_),s(S,D)}e.writePadRight=d;function m(S,_){l(S,""+_)}e.writeInteger=m;function h(S,_){l(S,""+_+" ")}e.writeIntegerAndSpace=h;function p(S,_,C){var D=""+_,T=C-D.length;s(S,T),l(S,D)}e.writeIntegerPadLeft=p;function v(S,_,C){var D=""+_,T=C-D.length;l(S,D),s(S,T)}e.writeIntegerPadRight=v;function g(S,_,C){l(S,""+Math.round(C*_)/C)}e.writeFloat=g;function b(S,_,C,D){var T=""+Math.round(C*_)/C,A=D-T.length;s(S,A),l(S,T)}e.writeFloatPadLeft=b;function x(S,_,C,D){var T=""+Math.round(C*_)/C,A=D-T.length;l(S,T),s(S,A)}e.writeFloatPadRight=x})($r||($r={}));var pn=function(){if(typeof window<"u"&&window.performance){var e=window.performance;return function(){return e.now()}}else return typeof process<"u"&&process.hrtime!=="undefined"&&typeof process.hrtime=="function"?function(){var t=process.hrtime();return t[0]*1e3+t[1]/1e6}:Date.now?function(){return Date.now()}:function(){return+new Date}}();function b2(e,t){if(t===void 0&&(t=!0),isNaN(e))return"n/a";for(var r=Math.floor(e/(60*60*1e3)),n=Math.floor(e/(60*1e3)%60),a=Math.floor(e/1e3%60),i=Math.floor(e%1e3).toString();i.length<3;)i="0"+i;for(;!t&&i.length>1&&i[i.length-1]==="0";)i=i.substr(0,i.length-1);return r>0?"".concat(r,"h").concat(n,"m").concat(a,".").concat(i,"s"):n>0?"".concat(n,"m").concat(a,".").concat(i,"s"):a>0?"".concat(a,".").concat(i,"s"):"".concat(e.toFixed(0),"ms")}var Er;(function(e){var t=typeof btoa<"u"?btoa:function(o){return Buffer.from(o).toString("base64")},r=[];function n(){for(var o=+new Date+pn(),s=0;s<16;s++)r[s]=String.fromCharCode((o+Math.random()*255)%255|0),o=Math.floor(o/255);return t(r.join("")).replace(/\+/g,"-").replace(/\//g,"_").substr(0,22)}e.create22=n;function a(){var o=+new Date+pn(),s="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(u){var c=(o+Math.random()*16)%16|0;return o=Math.floor(o/16),(u==="x"?c:c&3|8).toString(16)});return s}e.createv4=a;function i(o){return typeof o=="string"}e.is=i})(Er||(Er={}));function Ave(e,t){return e-t}function Dve(e){return Array.prototype.sort.call(e,Ave),e}var MI;(function(e){var t=function(){function m(){this.size=0}return m.prototype.has=function(h){return!1},m.prototype.forEach=function(h,p){return p},m}(),r=function(){function m(h){this.idx=h,this.size=1}return m.prototype.has=function(h){return h===this.idx},m.prototype.forEach=function(h,p){return h(this.idx,p),p},m}(),n=function(){function m(h,p){this.mask=h,this.size=p,this.length=h.length}return m.prototype.has=function(h){return hp&&(p=b)}if(h===p)return new a(h);var x=h/p;if(x<1/12){for(var S=new Set,_=0,C=m;_v&&(v=x))}),p/v<1/12){var g=new Set;return h.forEach(function(x){m.has(x)||g.add(x)}),s(g)}else{var b=new Uint8Array(v+1);return h.forEach(function(x){m.has(x)||(b[x]=1)}),l(b,p)}}e.complement=d})(MI||(MI={}));function ua(e,t){e===void 0&&(e=0),t===void 0&&(t=Number.MAX_SAFE_INTEGER);var r=e;return function(){var n=r;return r=(r+1)%t,n}}var h1;(function(e){function t(n){return{ref:n}}e.create=t;function r(n,a){return n.ref=a,n}e.set=r})(h1||(h1={}));var Pve=ua(0,2147483647),gf;(function(e){function t(n,a){return{id:Pve(),version:0,value:n,metadata:a}}e.create=t;function r(n,a){return{id:n.id,version:n.version+1,value:a,metadata:n.metadata}}e.withValue=r})(gf||(gf={}));var M;(function(e){function t(i,o){return h1.create(gf.create(i,o))}e.create=t;function r(i,o){return h1.set(i,gf.withValue(i.ref,o))}e.update=r;function n(i,o){return h1.set(i,o)}e.set=n;function a(i,o){return i.ref.value!==o?r(i,o):i}e.updateIfChanged=a})(M||(M={}));var fd=function(){};function Xi(e,t){var r=e.length;if(r!==t.length)return!1;for(var n=0;n>>0;if(""+r!==t||r===4294967295)return NaN;t=r}return t<0?t0(e)+t:t}function i6(){return!0}function P2(e,t,r){return(e===0&&!s6(e)||r!==void 0&&e<=-r)&&(t===void 0||r!==void 0&&t>=r)}function D1(e,t){return o6(e,t,0)}function E2(e,t){return o6(e,t,t)}function o6(e,t,r){return e===void 0?r:s6(e)?t===1/0?t:Math.max(0,t+e)|0:t===void 0||t===e?e:Math.min(t,e)|0}function s6(e){return e<0||e===0&&1/e===-1/0}var u6="@@__IMMUTABLE_ITERABLE__@@";function vu(e){return!!(e&&e[u6])}var c6="@@__IMMUTABLE_KEYED__@@";function mi(e){return!!(e&&e[c6])}var l6="@@__IMMUTABLE_INDEXED__@@";function hu(e){return!!(e&&e[l6])}function I2(e){return mi(e)||hu(e)}var Ki=function(t){return vu(t)?t:Ju(t)},Pc=function(e){function t(r){return mi(r)?r:Tm(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Ki),Hh=function(e){function t(r){return hu(r)?r:El(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Ki),u0=function(e){function t(r){return vu(r)&&!I2(r)?r:d0(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Ki);Ki.Keyed=Pc;Ki.Indexed=Hh;Ki.Set=u0;var f6="@@__IMMUTABLE_SEQ__@@";function XI(e){return!!(e&&e[f6])}var d6="@@__IMMUTABLE_RECORD__@@";function c0(e){return!!(e&&e[d6])}function bf(e){return vu(e)||c0(e)}var l0="@@__IMMUTABLE_ORDERED__@@";function Dl(e){return!!(e&&e[l0])}var P1=0,Pl=1,Dc=2,UI=typeof Symbol=="function"&&Symbol.iterator,m6="@@iterator",M2=UI||m6,ca=function(t){this.next=t};ca.prototype.toString=function(){return"[Iterator]"};ca.KEYS=P1;ca.VALUES=Pl;ca.ENTRIES=Dc;ca.prototype.inspect=ca.prototype.toSource=function(){return this.toString()};ca.prototype[M2]=function(){return this};function pi(e,t,r,n){var a=e===0?t:e===1?r:[t,r];return n?n.value=a:n={value:a,done:!1},n}function gu(){return{value:void 0,done:!0}}function p6(e){return Array.isArray(e)?!0:!!R2(e)}function OV(e){return e&&typeof e.next=="function"}function VI(e){var t=R2(e);return t&&t.call(e)}function R2(e){var t=e&&(UI&&e[UI]||e[m6]);if(typeof t=="function")return t}function Ive(e){var t=R2(e);return t&&t===e.entries}function Mve(e){var t=R2(e);return t&&t===e.keys}var f0=Object.prototype.hasOwnProperty;function h6(e){return Array.isArray(e)||typeof e=="string"?!0:e&&typeof e=="object"&&Number.isInteger(e.length)&&e.length>=0&&(e.length===0?Object.keys(e).length===1:e.hasOwnProperty(e.length-1))}var Ju=function(e){function t(r){return r==null?ZI():bf(r)?r.toSeq():Bve(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toSeq=function(){return this},t.prototype.toString=function(){return this.__toString("Seq {","}")},t.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},t.prototype.__iterate=function(n,a){var i=this._cache;if(i){for(var o=i.length,s=0;s!==o;){var u=i[a?o-++s:s++];if(n(u[1],u[0],this)===!1)break}return s}return this.__iterateUncached(n,a)},t.prototype.__iterator=function(n,a){var i=this._cache;if(i){var o=i.length,s=0;return new ca(function(){if(s===o)return gu();var u=i[a?o-++s:s++];return pi(n,u[0],u[1])})}return this.__iteratorUncached(n,a)},t}(Ki),Tm=function(e){function t(r){return r==null?ZI().toKeyedSeq():vu(r)?mi(r)?r.toSeq():r.fromEntrySeq():c0(r)?r.toSeq():QI(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toKeyedSeq=function(){return this},t}(Ju),El=function(e){function t(r){return r==null?ZI():vu(r)?mi(r)?r.entrySeq():r.toIndexedSeq():c0(r)?r.toSeq().entrySeq():v6(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return t(arguments)},t.prototype.toIndexedSeq=function(){return this},t.prototype.toString=function(){return this.__toString("Seq [","]")},t}(Ju),d0=function(e){function t(r){return(vu(r)&&!I2(r)?r:El(r)).toSetSeq()}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return t(arguments)},t.prototype.toSetSeq=function(){return this},t}(Ju);Ju.isSeq=XI;Ju.Keyed=Tm;Ju.Set=d0;Ju.Indexed=El;Ju.prototype[f6]=!0;var zh=function(e){function t(r){this._array=r,this.size=r.length}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.get=function(n,a){return this.has(n)?this._array[_m(this,n)]:a},t.prototype.__iterate=function(n,a){for(var i=this._array,o=i.length,s=0;s!==o;){var u=a?o-++s:s++;if(n(i[u],u,this)===!1)break}return s},t.prototype.__iterator=function(n,a){var i=this._array,o=i.length,s=0;return new ca(function(){if(s===o)return gu();var u=a?o-++s:s++;return pi(n,u,i[u])})},t}(El),KI=function(e){function t(r){var n=Object.keys(r).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(r):[]);this._object=r,this._keys=n,this.size=n.length}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.get=function(n,a){return a!==void 0&&!this.has(n)?a:this._object[n]},t.prototype.has=function(n){return f0.call(this._object,n)},t.prototype.__iterate=function(n,a){for(var i=this._object,o=this._keys,s=o.length,u=0;u!==s;){var c=o[a?s-++u:u++];if(n(i[c],c,this)===!1)break}return u},t.prototype.__iterator=function(n,a){var i=this._object,o=this._keys,s=o.length,u=0;return new ca(function(){if(u===s)return gu();var c=o[a?s-++u:u++];return pi(n,c,i[c])})},t}(Tm);KI.prototype[l0]=!0;var Rve=function(e){function t(r){this._collection=r,this.size=r.length||r.size}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.__iterateUncached=function(n,a){if(a)return this.cacheResult().__iterate(n,a);var i=this._collection,o=VI(i),s=0;if(OV(o))for(var u;!(u=o.next()).done&&n(u.value,s++,this)!==!1;);return s},t.prototype.__iteratorUncached=function(n,a){if(a)return this.cacheResult().__iterator(n,a);var i=this._collection,o=VI(i);if(!OV(o))return new ca(gu);var s=0;return new ca(function(){var u=o.next();return u.done?u:pi(n,s++,u.value)})},t}(El),FV;function ZI(){return FV||(FV=new zh([]))}function QI(e){var t=$I(e);if(t)return t.fromEntrySeq();if(typeof e=="object")return new KI(e);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+e)}function v6(e){var t=$I(e);if(t)return t;throw new TypeError("Expected Array or collection object of values: "+e)}function Bve(e){var t=$I(e);if(t)return Ive(e)?t.fromEntrySeq():Mve(e)?t.toSetSeq():t;if(typeof e=="object")return new KI(e);throw new TypeError("Expected Array or collection object of values, or keyed object: "+e)}function $I(e){return h6(e)?new zh(e):p6(e)?new Rve(e):void 0}var g6="@@__IMMUTABLE_MAP__@@";function JI(e){return!!(e&&e[g6])}function y6(e){return JI(e)&&Dl(e)}function LV(e){return!!(e&&typeof e.equals=="function"&&typeof e.hashCode=="function")}function $u(e,t){if(e===t||e!==e&&t!==t)return!0;if(!e||!t)return!1;if(typeof e.valueOf=="function"&&typeof t.valueOf=="function"){if(e=e.valueOf(),t=t.valueOf(),e===t||e!==e&&t!==t)return!0;if(!e||!t)return!1}return!!(LV(e)&&LV(t)&&e.equals(t))}var v1=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(t,r){t|=0,r|=0;var n=t&65535,a=r&65535;return n*a+((t>>>16)*a+n*(r>>>16)<<16>>>0)|0};function B2(e){return e>>>1&1073741824|e&3221225471}var Ove=Object.prototype.valueOf;function Zu(e){if(e==null)return kV(e);if(typeof e.hashCode=="function")return B2(e.hashCode(e));var t=Vve(e);if(t==null)return kV(t);switch(typeof t){case"boolean":return t?1108378657:1108378656;case"number":return Fve(t);case"string":return t.length>Gve?Lve(t):GI(t);case"object":case"function":return Nve(t);case"symbol":return kve(t);default:if(typeof t.toString=="function")return GI(t.toString());throw new Error("Value type "+typeof t+" cannot be hashed.")}}function kV(e){return e===null?1108378658:1108378659}function Fve(e){if(e!==e||e===1/0)return 0;var t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)e/=4294967295,t^=e;return B2(t)}function Lve(e){var t=OI[e];return t===void 0&&(t=GI(e),BI===zve&&(BI=0,OI={}),BI++,OI[e]=t),t}function GI(e){for(var t=0,r=0;r0)switch(e.nodeType){case 1:return e.uniqueID;case 9:return e.documentElement&&e.documentElement.uniqueID}}function Vve(e){return e.valueOf!==Ove&&typeof e.valueOf=="function"?e.valueOf(e):e}function b6(){var e=++RI;return RI&1073741824&&(RI=0),e}var zI=typeof WeakMap=="function",HI;zI&&(HI=new WeakMap);var VV=Object.create(null),RI=0,Gh="__immutablehash__";typeof Symbol=="function"&&(Gh=Symbol(Gh));var Gve=16,zve=255,BI=0,OI={},O2=function(e){function t(r,n){this._iter=r,this._useKeys=n,this.size=r.size}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.get=function(n,a){return this._iter.get(n,a)},t.prototype.has=function(n){return this._iter.has(n)},t.prototype.valueSeq=function(){return this._iter.valueSeq()},t.prototype.reverse=function(){var n=this,a=e3(this,!0);return this._useKeys||(a.valueSeq=function(){return n._iter.toSeq().reverse()}),a},t.prototype.map=function(n,a){var i=this,o=w6(this,n,a);return this._useKeys||(o.valueSeq=function(){return i._iter.toSeq().map(n,a)}),o},t.prototype.__iterate=function(n,a){var i=this;return this._iter.__iterate(function(o,s){return n(o,s,i)},a)},t.prototype.__iterator=function(n,a){return this._iter.__iterator(n,a)},t}(Tm);O2.prototype[l0]=!0;var x6=function(e){function t(r){this._iter=r,this.size=r.size}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.includes=function(n){return this._iter.includes(n)},t.prototype.__iterate=function(n,a){var i=this,o=0;return a&&t0(this),this._iter.__iterate(function(s){return n(s,a?i.size-++o:o++,i)},a)},t.prototype.__iterator=function(n,a){var i=this,o=this._iter.__iterator(Pl,a),s=0;return a&&t0(this),new ca(function(){var u=o.next();return u.done?u:pi(n,a?i.size-++s:s++,u.value,u)})},t}(El),S6=function(e){function t(r){this._iter=r,this.size=r.size}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.has=function(n){return this._iter.includes(n)},t.prototype.__iterate=function(n,a){var i=this;return this._iter.__iterate(function(o){return n(o,o,i)},a)},t.prototype.__iterator=function(n,a){var i=this._iter.__iterator(Pl,a);return new ca(function(){var o=i.next();return o.done?o:pi(n,o.value,o.value,o)})},t}(d0),C6=function(e){function t(r){this._iter=r,this.size=r.size}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.entrySeq=function(){return this._iter.toSeq()},t.prototype.__iterate=function(n,a){var i=this;return this._iter.__iterate(function(o){if(o){zV(o);var s=vu(o);return n(s?o.get(1):o[1],s?o.get(0):o[0],i)}},a)},t.prototype.__iterator=function(n,a){var i=this._iter.__iterator(Pl,a);return new ca(function(){for(;;){var o=i.next();if(o.done)return o;var s=o.value;if(s){zV(s);var u=vu(s);return pi(n,u?s.get(0):s[0],u?s.get(1):s[1],o)}}})},t}(Tm);x6.prototype.cacheResult=O2.prototype.cacheResult=S6.prototype.cacheResult=C6.prototype.cacheResult=n3;function _6(e){var t=xf(e);return t._iter=e,t.size=e.size,t.flip=function(){return e},t.reverse=function(){var r=e.reverse.apply(this);return r.flip=function(){return e.reverse()},r},t.has=function(r){return e.includes(r)},t.includes=function(r){return e.has(r)},t.cacheResult=n3,t.__iterateUncached=function(r,n){var a=this;return e.__iterate(function(i,o){return r(o,i,a)!==!1},n)},t.__iteratorUncached=function(r,n){if(r===Dc){var a=e.__iterator(r,n);return new ca(function(){var i=a.next();if(!i.done){var o=i.value[0];i.value[0]=i.value[1],i.value[1]=o}return i})}return e.__iterator(r===Pl?P1:Pl,n)},t}function w6(e,t,r){var n=xf(e);return n.size=e.size,n.has=function(a){return e.has(a)},n.get=function(a,i){var o=e.get(a,Un);return o===Un?i:t.call(r,o,a,e)},n.__iterateUncached=function(a,i){var o=this;return e.__iterate(function(s,u,c){return a(t.call(r,s,u,c),u,o)!==!1},i)},n.__iteratorUncached=function(a,i){var o=e.__iterator(Dc,i);return new ca(function(){var s=o.next();if(s.done)return s;var u=s.value,c=u[0];return pi(a,c,t.call(r,u[1],c,e),s)})},n}function e3(e,t){var r=this,n=xf(e);return n._iter=e,n.size=e.size,n.reverse=function(){return e},e.flip&&(n.flip=function(){var a=_6(e);return a.reverse=function(){return e.flip()},a}),n.get=function(a,i){return e.get(t?a:-1-a,i)},n.has=function(a){return e.has(t?a:-1-a)},n.includes=function(a){return e.includes(a)},n.cacheResult=n3,n.__iterate=function(a,i){var o=this,s=0;return i&&t0(e),e.__iterate(function(u,c){return a(u,t?c:i?o.size-++s:s++,o)},!i)},n.__iterator=function(a,i){var o=0;i&&t0(e);var s=e.__iterator(Dc,!i);return new ca(function(){var u=s.next();if(u.done)return u;var c=u.value;return pi(a,t?c[0]:i?r.size-++o:o++,c[1],u)})},n}function T6(e,t,r,n){var a=xf(e);return n&&(a.has=function(i){var o=e.get(i,Un);return o!==Un&&!!t.call(r,o,i,e)},a.get=function(i,o){var s=e.get(i,Un);return s!==Un&&t.call(r,s,i,e)?s:o}),a.__iterateUncached=function(i,o){var s=this,u=0;return e.__iterate(function(c,l,f){if(t.call(r,c,l,f))return u++,i(c,n?l:u-1,s)},o),u},a.__iteratorUncached=function(i,o){var s=e.__iterator(Dc,o),u=0;return new ca(function(){for(;;){var c=s.next();if(c.done)return c;var l=c.value,f=l[0],d=l[1];if(t.call(r,d,f,e))return pi(i,n?f:u++,d,c)}})},a}function Hve(e,t,r){var n=rc().asMutable();return e.__iterate(function(a,i){n.update(t.call(r,a,i,e),0,function(o){return o+1})}),n.asImmutable()}function jve(e,t,r){var n=mi(e),a=(Dl(e)?ec():rc()).asMutable();e.__iterate(function(o,s){a.update(t.call(r,o,s,e),function(u){return u=u||[],u.push(n?[s,o]:o),u})});var i=r3(e);return a.map(function(o){return Na(e,i(o))}).asImmutable()}function qve(e,t,r){var n=mi(e),a=[[],[]];e.__iterate(function(o,s){a[t.call(r,o,s,e)?1:0].push(n?[s,o]:o)});var i=r3(e);return a.map(function(o){return Na(e,i(o))})}function t3(e,t,r,n){var a=e.size;if(P2(t,r,a))return e;var i=D1(t,a),o=E2(r,a);if(i!==i||o!==o)return t3(e.toSeq().cacheResult(),t,r,n);var s=o-i,u;s===s&&(u=s<0?0:s);var c=xf(e);return c.size=u===0?u:e.size&&u||void 0,!n&&XI(e)&&u>=0&&(c.get=function(l,f){return l=_m(this,l),l>=0&&lu)return gu();var p=d.next();return n||l===Pl||p.done?p:l===P1?pi(l,h-1,void 0,p):pi(l,h-1,p.value[1],p)})},c}function Wve(e,t,r){var n=xf(e);return n.__iterateUncached=function(a,i){var o=this;if(i)return this.cacheResult().__iterate(a,i);var s=0;return e.__iterate(function(u,c,l){return t.call(r,u,c,l)&&++s&&a(u,c,o)}),s},n.__iteratorUncached=function(a,i){var o=this;if(i)return this.cacheResult().__iterator(a,i);var s=e.__iterator(Dc,i),u=!0;return new ca(function(){if(!u)return gu();var c=s.next();if(c.done)return c;var l=c.value,f=l[0],d=l[1];return t.call(r,d,f,o)?a===Dc?c:pi(a,f,d,c):(u=!1,gu())})},n}function A6(e,t,r,n){var a=xf(e);return a.__iterateUncached=function(i,o){var s=this;if(o)return this.cacheResult().__iterate(i,o);var u=!0,c=0;return e.__iterate(function(l,f,d){if(!(u&&(u=t.call(r,l,f,d))))return c++,i(l,n?f:c-1,s)}),c},a.__iteratorUncached=function(i,o){var s=this;if(o)return this.cacheResult().__iterator(i,o);var u=e.__iterator(Dc,o),c=!0,l=0;return new ca(function(){var f,d,m;do{if(f=u.next(),f.done)return n||i===Pl?f:i===P1?pi(i,l++,void 0,f):pi(i,l++,f.value[1],f);var h=f.value;d=h[0],m=h[1],c&&(c=t.call(r,m,d,s))}while(c);return i===Dc?f:pi(i,d,m,f)})},a}function Yve(e,t){var r=mi(e),n=[e].concat(t).map(function(o){return vu(o)?r&&(o=Pc(o)):o=r?QI(o):v6(Array.isArray(o)?o:[o]),o}).filter(function(o){return o.size!==0});if(n.length===0)return e;if(n.length===1){var a=n[0];if(a===e||r&&mi(a)||hu(e)&&hu(a))return a}var i=new zh(n);return r?i=i.toKeyedSeq():hu(e)||(i=i.toSetSeq()),i=i.flatten(!0),i.size=n.reduce(function(o,s){if(o!==void 0){var u=s.size;if(u!==void 0)return o+u}},0),i}function D6(e,t,r){var n=xf(e);return n.__iterateUncached=function(a,i){if(i)return this.cacheResult().__iterate(a,i);var o=0,s=!1;function u(c,l){c.__iterate(function(f,d){return(!t||l0}function C2(e,t,r,n){var a=xf(e),i=new zh(r).map(function(o){return o.size});return a.size=n?i.max():i.min(),a.__iterate=function(o,s){for(var u=this.__iterator(Pl,s),c,l=0;!(c=u.next()).done&&o(c.value,l++,this)!==!1;);return l},a.__iteratorUncached=function(o,s){var u=r.map(function(f){return f=Ki(f),VI(s?f.reverse():f)}),c=0,l=!1;return new ca(function(){var f;return l||(f=u.map(function(d){return d.next()}),l=n?f.every(function(d){return d.done}):f.some(function(d){return d.done})),l?gu():pi(o,c++,t.apply(null,f.map(function(d){return d.value})))})},a}function Na(e,t){return e===t?e:XI(e)?t:e.constructor(t)}function zV(e){if(e!==Object(e))throw new TypeError("Expected [K, V] tuple: "+e)}function r3(e){return mi(e)?Pc:hu(e)?Hh:u0}function xf(e){return Object.create((mi(e)?Tm:hu(e)?El:d0).prototype)}function n3(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Ju.prototype.cacheResult.call(this)}function P6(e,t){return e===void 0&&t===void 0?0:e===void 0?1:t===void 0?-1:e>t?1:e0;)t[r]=arguments[r+1];if(typeof e!="function")throw new TypeError("Invalid merger function: "+e);return F6(this,t,e)}function F6(e,t,r){for(var n=[],a=0;a0;)t[r]=arguments[r+1];return c3(this,t,e)}function f3(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return m0(this,e,Al(),function(n){return l3(n,t)})}function d3(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return m0(this,e,Al(),function(n){return c3(n,t)})}function E1(e){var t=this.asMutable();return e(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this}function I1(){return this.__ownerID?this:this.__ensureOwner(new YI)}function M1(){return this.__ensureOwner()}function m3(){return this.__altered}var rc=function(e){function t(r){return r==null?Al():JI(r)&&!Dl(r)?r:Al().withMutations(function(n){var a=e(r);Qu(a.size),a.forEach(function(i,o){return n.set(o,i)})})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){for(var n=[],a=arguments.length;a--;)n[a]=arguments[a];return Al().withMutations(function(i){for(var o=0;o=n.length)throw new Error("Missing value for key: "+n[o]);i.set(n[o],n[o+1])}})},t.prototype.toString=function(){return this.__toString("Map {","}")},t.prototype.get=function(n,a){return this._root?this._root.get(0,void 0,n,a):a},t.prototype.set=function(n,a){return qV(this,n,a)},t.prototype.remove=function(n){return qV(this,n,Un)},t.prototype.deleteAll=function(n){var a=Ki(n);return a.size===0?this:this.withMutations(function(i){a.forEach(function(o){return i.remove(o)})})},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Al()},t.prototype.sort=function(n){return ec(r0(this,n))},t.prototype.sortBy=function(n,a){return ec(r0(this,a,n))},t.prototype.map=function(n,a){var i=this;return this.withMutations(function(o){o.forEach(function(s,u){o.set(u,n.call(a,s,u,i))})})},t.prototype.__iterator=function(n,a){return new ige(this,n,a)},t.prototype.__iterate=function(n,a){var i=this,o=0;return this._root&&this._root.iterate(function(s){return o++,n(s[1],s[0],i)},a),o},t.prototype.__ensureOwner=function(n){return n===this.__ownerID?this:n?p3(this.size,this._root,n,this.__hash):this.size===0?Al():(this.__ownerID=n,this.__altered=!1,this)},t}(Pc);rc.isMap=JI;var ai=rc.prototype;ai[g6]=!0;ai[A1]=ai.remove;ai.removeAll=ai.deleteAll;ai.setIn=i3;ai.removeIn=ai.deleteIn=o3;ai.update=s3;ai.updateIn=u3;ai.merge=ai.concat=B6;ai.mergeWith=O6;ai.mergeDeep=L6;ai.mergeDeepWith=k6;ai.mergeIn=f3;ai.mergeDeepIn=d3;ai.withMutations=E1;ai.wasAltered=m3;ai.asImmutable=M1;ai["@@transducer/init"]=ai.asMutable=I1;ai["@@transducer/step"]=function(e,t){return e.set(t[0],t[1])};ai["@@transducer/result"]=function(e){return e.asImmutable()};var C1=function(t,r){this.ownerID=t,this.entries=r};C1.prototype.get=function(t,r,n,a){for(var i=this.entries,o=0,s=i.length;o=fge)return oge(t,c,a,i);var m=t&&t===this.ownerID,h=m?c:yf(c);return d?u?l===f-1?h.pop():h[l]=h.pop():h[l]=[a,i]:h.push([a,i]),m?(this.entries=h,this):new C1(t,h)}};var n0=function(t,r,n){this.ownerID=t,this.bitmap=r,this.nodes=n};n0.prototype.get=function(t,r,n,a){r===void 0&&(r=Zu(n));var i=1<<((t===0?r:r>>>t)&js),o=this.bitmap;return o&i?this.nodes[N6(o&i-1)].get(t+ni,r,n,a):a};n0.prototype.update=function(t,r,n,a,i,o,s){n===void 0&&(n=Zu(a));var u=(r===0?n:n>>>r)&js,c=1<=dge)return uge(t,m,l,u,p);if(f&&!p&&m.length===2&&WV(m[d^1]))return m[d^1];if(f&&p&&m.length===1&&WV(p))return p;var v=t&&t===this.ownerID,g=f?p?l:l^c:l|c,b=f?p?U6(m,d,p,v):lge(m,d,v):cge(m,d,p,v);return v?(this.bitmap=g,this.nodes=b,this):new n0(t,g,b)};var _1=function(t,r,n){this.ownerID=t,this.count=r,this.nodes=n};_1.prototype.get=function(t,r,n,a){r===void 0&&(r=Zu(n));var i=(t===0?r:r>>>t)&js,o=this.nodes[i];return o?o.get(t+ni,r,n,a):a};_1.prototype.update=function(t,r,n,a,i,o,s){n===void 0&&(n=Zu(a));var u=(r===0?n:n>>>r)&js,c=i===Un,l=this.nodes,f=l[u];if(c&&!f)return this;var d=h3(f,t,r+ni,n,a,i,o,s);if(d===f)return this;var m=this.count;if(!f)m++;else if(!d&&(m--,m>>r)&js,o=(r===0?n:n>>>r)&js,s,u=i===o?[v3(e,t,r+ni,n,a)]:(s=new md(t,n,a),i>>=1)o[s]=r&1?t[i++]:void 0;return o[n]=a,new _1(e,i+1,o)}function N6(e){return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),e=e+(e>>4)&252645135,e+=e>>8,e+=e>>16,e&127}function U6(e,t,r,n){var a=n?e:yf(e);return a[t]=r,a}function cge(e,t,r,n){var a=e.length+1;if(n&&t+1===a)return e[t]=r,e;for(var i=new Array(a),o=0,s=0;s0&&i=0&&n>>r&js;if(a>=this.array.length)return new Cm([],t);var i=a===0,o;if(r>0){var s=this.array[a];if(o=s&&s.removeBefore(t,r-ni,n),o===s&&i)return this}if(i&&!o)return this;var u=i0(this,t);if(!i)for(var c=0;c>>r&js;if(a>=this.array.length)return this;var i;if(r>0){var o=this.array[a];if(i=o&&o.removeAfter(t,r-ni,n),i===o&&a===this.array.length-1)return this}var s=i0(this,t);return s.array.splice(a+1),i&&(s.array[a]=i),s};var x1={};function YV(e,t){var r=e._origin,n=e._capacity,a=T1(n),i=e._tail;return o(e._root,e._level,0);function o(c,l,f){return l===0?s(c,f):u(c,l,f)}function s(c,l){var f=l===a?i&&i.array:c&&c.array,d=l>r?0:r-l,m=n-l;return m>Tc&&(m=Tc),function(){if(d===m)return x1;var h=t?--m:d++;return f&&f[h]}}function u(c,l,f){var d,m=c&&c.array,h=f>r?0:r-f>>l,p=(n-f>>l)+1;return p>Tc&&(p=Tc),function(){for(;;){if(d){var v=d();if(v!==x1)return v;d=null}if(h===p)return x1;var g=t?--p:h++;d=o(m&&m[g],l-ni,f+(g<=e.size||t<0)return e.withMutations(function(o){t<0?Sm(o,t).set(0,r):Sm(o,0,t+1).set(t,r)});t+=e._origin;var n=e._tail,a=e._root,i=NI();return t>=T1(e._capacity)?n=jI(n,e.__ownerID,0,t,r,i):a=jI(a,e.__ownerID,e._level,t,r,i),i.value?e.__ownerID?(e._root=a,e._tail=n,e.__hash=void 0,e.__altered=!0,e):w1(e._origin,e._capacity,e._level,a,n):e}function jI(e,t,r,n,a,i){var o=n>>>r&js,s=e&&o0){var c=e&&e.array[o],l=jI(c,t,r-ni,n,a,i);return l===c?e:(u=i0(e,t),u.array[o]=l,u)}return s&&e.array[o]===a?e:(i&&Ac(i),u=i0(e,t),a===void 0&&o===u.array.length-1?u.array.pop():u.array[o]=a,u)}function i0(e,t){return t&&e&&t===e.ownerID?e:new Cm(e?e.array.slice():[],t)}function z6(e,t){if(t>=T1(e._capacity))return e._tail;if(t<1<0;)r=r.array[t>>>n&js],n-=ni;return r}}function Sm(e,t,r){t!==void 0&&(t|=0),r!==void 0&&(r|=0);var n=e.__ownerID||new YI,a=e._origin,i=e._capacity,o=a+t,s=r===void 0?i:r<0?i+r:a+r;if(o===a&&s===i)return e;if(o>=s)return e.clear();for(var u=e._level,c=e._root,l=0;o+l<0;)c=new Cm(c&&c.array.length?[void 0,c]:[],n),u+=ni,l+=1<=1<f?new Cm([],n):m;if(m&&d>f&&oni;v-=ni){var g=f>>>v&js;p=p.array[g]=i0(p.array[g],n)}p.array[f>>>ni&js]=m}if(s=d)o-=d,s-=d,u=ni,c=null,h=h&&h.removeBefore(n,0,o);else if(o>a||d>>u&js;if(b!==d>>>u&js)break;b&&(l+=(1<a&&(c=c.removeBefore(n,u,o-l)),c&&d>>ni<=Tc&&a.size>=n.size*2?(u=a.filter(function(c,l){return c!==void 0&&i!==l}),s=u.toKeyedSeq().map(function(c){return c[0]}).flip().toMap(),e.__ownerID&&(s.__ownerID=u.__ownerID=e.__ownerID)):(s=n.remove(t),u=i===a.size-1?a.pop():a.set(i,void 0))}else if(o){if(r===a.get(i)[1])return e;s=n,u=a.set(i,[t,r])}else s=n.set(t,a.size),u=a.set(a.size,[t,r]);return e.__ownerID?(e.size=s.size,e._map=s,e._list=u,e.__hash=void 0,e.__altered=!0,e):g3(s,u)}var H6="@@__IMMUTABLE_STACK__@@";function qI(e){return!!(e&&e[H6])}var y3=function(e){function t(r){return r==null?_2():qI(r)?r:_2().pushAll(r)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("Stack [","]")},t.prototype.get=function(n,a){var i=this._head;for(n=_m(this,n);i&&n--;)i=i.next;return i?i.value:a},t.prototype.peek=function(){return this._head&&this._head.value},t.prototype.push=function(){var n=arguments;if(arguments.length===0)return this;for(var a=this.size+arguments.length,i=this._head,o=arguments.length-1;o>=0;o--)i={value:n[o],next:i};return this.__ownerID?(this.size=a,this._head=i,this.__hash=void 0,this.__altered=!0,this):y1(a,i)},t.prototype.pushAll=function(n){if(n=e(n),n.size===0)return this;if(this.size===0&&qI(n))return n;Qu(n.size);var a=this.size,i=this._head;return n.__iterate(function(o){a++,i={value:o,next:i}},!0),this.__ownerID?(this.size=a,this._head=i,this.__hash=void 0,this.__altered=!0,this):y1(a,i)},t.prototype.pop=function(){return this.slice(1)},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):_2()},t.prototype.slice=function(n,a){if(P2(n,a,this.size))return this;var i=D1(n,this.size),o=E2(a,this.size);if(o!==this.size)return e.prototype.slice.call(this,n,a);for(var s=this.size-i,u=this._head;i--;)u=u.next;return this.__ownerID?(this.size=s,this._head=u,this.__hash=void 0,this.__altered=!0,this):y1(s,u)},t.prototype.__ensureOwner=function(n){return n===this.__ownerID?this:n?y1(this.size,this._head,n,this.__hash):this.size===0?_2():(this.__ownerID=n,this.__altered=!1,this)},t.prototype.__iterate=function(n,a){var i=this;if(a)return new zh(this.toArray()).__iterate(function(u,c){return n(u,c,i)},a);for(var o=0,s=this._head;s&&n(s.value,o++,this)!==!1;)s=s.next;return o},t.prototype.__iterator=function(n,a){if(a)return new zh(this.toArray()).__iterator(n,a);var i=0,o=this._head;return new ca(function(){if(o){var s=o.value;return o=o.next,pi(n,i++,s)}return gu()})},t}(Hh);y3.isStack=qI;var qs=y3.prototype;qs[H6]=!0;qs.shift=qs.pop;qs.unshift=qs.push;qs.unshiftAll=qs.pushAll;qs.withMutations=E1;qs.wasAltered=m3;qs.asImmutable=M1;qs["@@transducer/init"]=qs.asMutable=I1;qs["@@transducer/step"]=function(e,t){return e.unshift(t)};qs["@@transducer/result"]=function(e){return e.asImmutable()};function y1(e,t,r,n){var a=Object.create(qs);return a.size=e,a._head=t,a.__ownerID=r,a.__hash=n,a.__altered=!1,a}var QV;function _2(){return QV||(QV=y1(0))}var j6="@@__IMMUTABLE_SET__@@";function b3(e){return!!(e&&e[j6])}function q6(e){return b3(e)&&Dl(e)}function W6(e,t){if(e===t)return!0;if(!vu(t)||e.size!==void 0&&t.size!==void 0&&e.size!==t.size||e.__hash!==void 0&&t.__hash!==void 0&&e.__hash!==t.__hash||mi(e)!==mi(t)||hu(e)!==hu(t)||Dl(e)!==Dl(t))return!1;if(e.size===0&&t.size===0)return!0;var r=!I2(e);if(Dl(e)){var n=e.entries();return t.every(function(u,c){var l=n.next().value;return l&&$u(l[1],u)&&(r||$u(l[0],c))})&&n.next().done}var a=!1;if(e.size===void 0)if(t.size===void 0)typeof e.cacheResult=="function"&&e.cacheResult();else{a=!0;var i=e;e=t,t=i}var o=!0,s=t.__iterate(function(u,c){if(r?!e.has(u):a?!$u(u,e.get(c,Un)):!$u(e.get(c,Un),u))return o=!1,!1});return o&&e.size===s}function jh(e,t){var r=function(n){e.prototype[n]=t[n]};return Object.keys(t).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(t).forEach(r),e}function D2(e){if(!e||typeof e!="object")return e;if(!vu(e)){if(!wm(e))return e;e=Ju(e)}if(mi(e)){var t={};return e.__iterate(function(n,a){t[a]=D2(n)}),t}var r=[];return e.__iterate(function(n){r.push(D2(n))}),r}var F2=function(e){function t(r){return r==null?b1():b3(r)&&!Dl(r)?r:b1().withMutations(function(n){var a=e(r);Qu(a.size),a.forEach(function(i){return n.add(i)})})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.fromKeys=function(n){return this(Pc(n).keySeq())},t.intersect=function(n){return n=Ki(n).toArray(),n.length?ps.intersect.apply(t(n.pop()),n):b1()},t.union=function(n){return n=Ki(n).toArray(),n.length?ps.union.apply(t(n.pop()),n):b1()},t.prototype.toString=function(){return this.__toString("Set {","}")},t.prototype.has=function(n){return this._map.has(n)},t.prototype.add=function(n){return w2(this,this._map.set(n,n))},t.prototype.remove=function(n){return w2(this,this._map.remove(n))},t.prototype.clear=function(){return w2(this,this._map.clear())},t.prototype.map=function(n,a){var i=this,o=!1,s=w2(this,this._map.mapEntries(function(u){var c=u[1],l=n.call(a,c,c,i);return l!==c&&(o=!0),[l,l]},a));return o?s:this},t.prototype.union=function(){for(var n=[],a=arguments.length;a--;)n[a]=arguments[a];return n=n.filter(function(i){return i.size!==0}),n.length===0?this:this.size===0&&!this.__ownerID&&n.length===1?this.constructor(n[0]):this.withMutations(function(i){for(var o=0;o=0&&a=0&&ithis.size?r:this.find(function(n,a){return a===t},void 0,r)},has:function(t){return t=_m(this,t),t>=0&&(this.size!==void 0?this.size===1/0||tt?-1:0}function xge(e){if(e.size===1/0)return 0;var t=Dl(e),r=mi(e),n=t?1:0,a=e.__iterate(r?t?function(i,o){n=31*n+n6(Zu(i),Zu(o))|0}:function(i,o){n=n+n6(Zu(i),Zu(o))|0}:t?function(i){n=31*n+Zu(i)|0}:function(i){n=n+Zu(i)|0});return Sge(a,n)}function Sge(e,t){return t=v1(t,3432918353),t=v1(t<<15|t>>>-15,461845907),t=v1(t<<13|t>>>-13,5),t=(t+3864292196|0)^e,t=v1(t^t>>>16,2246822507),t=v1(t^t>>>13,3266489909),t=B2(t^t>>>16),t}function n6(e,t){return e^t+2654435769+(e<<6)+(e>>2)|0}var tc=function(e){function t(r){return r==null?WI():q6(r)?r:WI().withMutations(function(n){var a=u0(r);Qu(a.size),a.forEach(function(i){return n.add(i)})})}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.fromKeys=function(n){return this(Pc(n).keySeq())},t.prototype.toString=function(){return this.__toString("OrderedSet {","}")},t}(F2);tc.isOrderedSet=q6;var qh=tc.prototype;qh[l0]=!0;qh.zip=p0.zip;qh.zipWith=p0.zipWith;qh.zipAll=p0.zipAll;qh.__empty=WI;qh.__make=Q6;function Q6(e,t){var r=Object.create(qh);return r.size=e?e.size:0,r._map=e,r.__ownerID=t,r}var a6;function WI(){return a6||(a6=Q6(g1()))}function Cge(e){if(c0(e))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(bf(e))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(e===null||typeof e!="object")throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var Fo=function(t,r){var n;Cge(t);var a=function(s){var u=this;if(s instanceof a)return s;if(!(this instanceof a))return new a(s);if(!n){n=!0;var c=Object.keys(t),l=i._indices={};i._name=r,i._keys=c,i._defaultValues=t;for(var f=0;f0&&(Tt=1/Math.sqrt(Tt),ue[0]=ye[0]*Tt,ue[1]=ye[1]*Tt,ue[2]=ye[2]*Tt),ue}e.normalize=X;function ae(ue,ye){return ue[0]*ye[0]+ue[1]*ye[1]+ue[2]*ye[2]}e.dot=ae;function q(ue,ye,we){var $e=ye[0],Et=ye[1],Tt=ye[2],nr=we[0],Br=we[1],sr=we[2];return ue[0]=Et*sr-Tt*Br,ue[1]=Tt*nr-$e*sr,ue[2]=$e*Br-Et*nr,ue}e.cross=q;function F(ue,ye,we,$e){var Et=ye[0],Tt=ye[1],nr=ye[2];return ue[0]=Et+$e*(we[0]-Et),ue[1]=Tt+$e*(we[1]-Tt),ue[2]=nr+$e*(we[2]-nr),ue}e.lerp=F;var j=t();function Z(ue,ye,we,$e){var Et=Ta(ae(ye,we),-1,1),Tt=Math.acos(Et)*$e;return x(j,we,ye,-Et),X(j,j),h(ue,b(ue,ye,Math.cos(Tt)),b(j,j,Math.sin(Tt)))}e.slerp=Z;function Y(ue,ye,we,$e,Et,Tt){var nr=Tt*Tt,Br=nr*(2*Tt-3)+1,sr=nr*(Tt-2)+Tt,Sn=nr*(Tt-1),oa=nr*(3-2*Tt);return ue[0]=ye[0]*Br+we[0]*sr+$e[0]*Sn+Et[0]*oa,ue[1]=ye[1]*Br+we[1]*sr+$e[1]*Sn+Et[1]*oa,ue[2]=ye[2]*Br+we[2]*sr+$e[2]*Sn+Et[2]*oa,ue}e.hermite=Y;function H(ue,ye,we,$e,Et,Tt){var nr=1-Tt,Br=nr*nr,sr=Tt*Tt,Sn=Br*nr,oa=3*Tt*Br,oo=3*sr*nr,ei=sr*Tt;return ue[0]=ye[0]*Sn+we[0]*oa+$e[0]*oo+Et[0]*ei,ue[1]=ye[1]*Sn+we[1]*oa+$e[1]*oo+Et[1]*ei,ue[2]=ye[2]*Sn+we[2]*oa+$e[2]*oo+Et[2]*ei,ue}e.bezier=H;function N(ue,ye,we,$e,Et){return ue[0]=L2(ye[0],we[0],$e[0],Et),ue[1]=L2(ye[1],we[1],$e[1],Et),ue[2]=L2(ye[2],we[2],$e[2],Et),ue}e.quadraticBezier=N;function ee(ue,ye,we,$e,Et,Tt,nr){return ue[0]=h0(ye[0],we[0],$e[0],Et[0],Tt,nr),ue[1]=h0(ye[1],we[1],$e[1],Et[1],Tt,nr),ue[2]=h0(ye[2],we[2],$e[2],Et[2],Tt,nr),ue}e.spline=ee;function oe(ue,ye){var we=Math.random()*2*Math.PI,$e=Math.random()*2-1,Et=Math.sqrt(1-$e*$e)*ye;return ue[0]=Math.cos(we)*Et,ue[1]=Math.sin(we)*Et,ue[2]=$e*ye,ue}e.random=oe;function me(ue,ye,we){var $e=ye[0],Et=ye[1],Tt=ye[2],nr=1/(we[3]*$e+we[7]*Et+we[11]*Tt+we[15]||1);return ue[0]=(we[0]*$e+we[4]*Et+we[8]*Tt+we[12])*nr,ue[1]=(we[1]*$e+we[5]*Et+we[9]*Tt+we[13])*nr,ue[2]=(we[2]*$e+we[6]*Et+we[10]*Tt+we[14])*nr,ue}e.transformMat4=me;function pe(ue,ye,we){var $e=ye[0],Et=ye[1],Tt=ye[2];return ue[0]=we[0]*$e+we[4]*Et+we[8]*Tt,ue[1]=we[1]*$e+we[5]*Et+we[9]*Tt,ue[2]=we[2]*$e+we[6]*Et+we[10]*Tt,X(ue,ue)}e.transformDirection=pe;function de(ue,ye,we,$e,Et,Tt){var nr=ye[0+Et],Br=ye[1+Et],sr=ye[2+Et],Sn=1/(we[3+Tt]*nr+we[7+Tt]*Br+we[11+Tt]*sr+we[15+Tt]||1);return ue[0+$e]=(we[0+Tt]*nr+we[4+Tt]*Br+we[8+Tt]*sr+we[12+Tt])*Sn,ue[1+$e]=(we[1+Tt]*nr+we[5+Tt]*Br+we[9+Tt]*sr+we[13+Tt])*Sn,ue[2+$e]=(we[2+Tt]*nr+we[6+Tt]*Br+we[10+Tt]*sr+we[14+Tt])*Sn,ue}e.transformMat4Offset=de;function re(ue,ye,we){var $e=ye[0],Et=ye[1],Tt=ye[2];return ue[0]=$e*we[0]+Et*we[3]+Tt*we[6],ue[1]=$e*we[1]+Et*we[4]+Tt*we[7],ue[2]=$e*we[2]+Et*we[5]+Tt*we[8],ue}e.transformMat3=re;function te(ue,ye,we){var $e=ye[0],Et=ye[1],Tt=ye[2],nr=we[0],Br=we[1],sr=we[2],Sn=we[3],oa=Sn*$e+Br*Tt-sr*Et,oo=Sn*Et+sr*$e-nr*Tt,ei=Sn*Tt+nr*Et-Br*$e,Yi=-nr*$e-Br*Et-sr*Tt;return ue[0]=oa*Sn+Yi*-nr+oo*-sr-ei*-Br,ue[1]=oo*Sn+Yi*-Br+ei*-nr-oa*-sr,ue[2]=ei*Sn+Yi*-sr+oa*-Br-oo*-nr,ue}e.transformQuat=te;function fe(ue,ye){var we=Math.sqrt(V(ue)*V(ye));if(we===0)return Math.PI/2;var $e=ae(ue,ye)/we;return Math.acos(Ta($e,-1,1))}e.angle=fe;var ve=t(),De=t(),Ge=t(),Ke=t(),L=t(),K=t(),ge=t();function Pe(ue,ye,we,$e){p(ve,ue,ye),p(De,we,ye),p(Ge,ye,we),p(Ke,$e,we),q(L,ve,De),q(K,Ge,Ke);var Et=fe(L,K);return q(ge,L,K),ae(De,ge)>0?Et:-Et}e.dihedralAngle=Pe;function Ie(ue,ye,we,$e){return e.set(ue,$e*Math.cos(we)*Math.sin(ye),$e*Math.sin(we)*Math.sin(ye),$e*Math.cos(ye))}e.directionFromSpherical=Ie;function ke(ue,ye){return ue[0]===ye[0]&&ue[1]===ye[1]&&ue[2]===ye[2]}e.exactEquals=ke;function Ne(ue,ye){var we=ue[0],$e=ue[1],Et=ue[2],Tt=ye[0],nr=ye[1],Br=ye[2];return Math.abs(we-Tt)<=Dr*Math.max(1,Math.abs(we),Math.abs(Tt))&&Math.abs($e-nr)<=Dr*Math.max(1,Math.abs($e),Math.abs(nr))&&Math.abs(Et-Br)<=Dr*Math.max(1,Math.abs(Et),Math.abs(Br))}e.equals=Ne;var Ve=t();function et(ue,ye,we){var $e=fe(ye,we);if(Math.abs($e)<1e-4)return se.setIdentity(ue);if(Math.abs($e-Math.PI)0?m(ue,ye):Q(ue,m(ue,ye)),ue}e.matchDirection=ut;var Ct=t(),bt=t();function Mt(ue,ye,we,$e){return p(Ct,we,ye),p(bt,$e,ye),X(ue,q(ue,Ct,bt))}e.triangleNormal=Mt;function Ot(ue,ye){return"[".concat(ue[0].toPrecision(ye)," ").concat(ue[1].toPrecision(ye)," ").concat(ue[2].toPrecision(ye),"]")}e.toString=Ot,e.origin=l(0,0,0),e.unit=l(1,1,1),e.negUnit=l(-1,-1,-1),e.unitX=l(1,0,0),e.unitY=l(0,1,0),e.unitZ=l(0,0,1),e.negUnitX=l(-1,0,0),e.negUnitY=l(0,-1,0),e.negUnitZ=l(0,0,-1)})(y||(y={}));var Wh=Math.PI/2,$6=Math.PI/180;function vr(e){return e*$6}function Zi(e){return e/$6}function Am(e){return e!==0&&(e&e-1)===0}function J6(){for(var e=[],t=0;tn&&(r=o,n=s)}return r}function N2(e,t){return e*t}function e8(e){for(var t,r=0,n=0,a=[0,-1],i=e*2+1,o=i/2,s=[],u=Math.pow(i,2);u>0;--u)-o0&&r===1-n)&&(t=[-a[1],a[0]],a[0]=t[0],a[1]=t[1]),r+=a[0],n+=a[1];return s}function se(){return se.zero()}(function(e){function t(){var L=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];return L[0]=0,L}e.zero=t;function r(){var L=t();return L[0]=1,L[1]=0,L[2]=0,L[3]=0,L[4]=0,L[5]=1,L[6]=0,L[7]=0,L[8]=0,L[9]=0,L[10]=1,L[11]=0,L[12]=0,L[13]=0,L[14]=0,L[15]=1,L}e.identity=r;function n(L){return L[0]=1,L[1]=0,L[2]=0,L[3]=0,L[4]=0,L[5]=1,L[6]=0,L[7]=0,L[8]=0,L[9]=0,L[10]=1,L[11]=0,L[12]=0,L[13]=0,L[14]=0,L[15]=1,L}e.setIdentity=n;function a(L){for(var K=0;K<16;K++)L[K]=0;return L}e.setZero=a;function i(L){for(var K=t(),ge=0;ge<4;ge++)for(var Pe=L[ge],Ie=0;Ie<4;Ie++)K[4*Ie+ge]=Pe[Ie];return K}e.ofRows=i;var o=r();function s(L,K){return c(L,o,typeof K>"u"?Dr:K)}e.isIdentity=s;function u(L){for(var K=0;K<16;K++)if(isNaN(L[K]))return!0;return!1}e.hasNaN=u;function c(L,K,ge){for(var Pe=0;Pe<16;Pe++)if(Math.abs(L[Pe]-K[Pe])>ge)return!1;return!0}e.areEqual=c;function l(L,K,ge,Pe){L[4*ge+K]=Pe}e.setValue=l;function f(L,K,ge){return L[4*ge+K]}e.getValue=f;function d(L,K,ge){return K[ge+0]=L[0],K[ge+1]=L[1],K[ge+2]=L[2],K[ge+3]=L[3],K[ge+4]=L[4],K[ge+5]=L[5],K[ge+6]=L[6],K[ge+7]=L[7],K[ge+8]=L[8],K[ge+9]=L[9],K[ge+10]=L[10],K[ge+11]=L[11],K[ge+12]=L[12],K[ge+13]=L[13],K[ge+14]=L[14],K[ge+15]=L[15],K}e.toArray=d;function m(L,K,ge){return L[0]=K[ge+0],L[1]=K[ge+1],L[2]=K[ge+2],L[3]=K[ge+3],L[4]=K[ge+4],L[5]=K[ge+5],L[6]=K[ge+6],L[7]=K[ge+7],L[8]=K[ge+8],L[9]=K[ge+9],L[10]=K[ge+10],L[11]=K[ge+11],L[12]=K[ge+12],L[13]=K[ge+13],L[14]=K[ge+14],L[15]=K[ge+15],L}e.fromArray=m;function h(L,K,ge,Pe){return a(L),l(L,0,0,K[0]),l(L,1,0,K[1]),l(L,2,0,K[2]),l(L,0,1,ge[0]),l(L,1,1,ge[1]),l(L,2,1,ge[2]),l(L,0,2,Pe[0]),l(L,1,2,Pe[1]),l(L,2,2,Pe[2]),l(L,3,3,1),L}e.fromBasis=h;function p(L,K){return L[0]=K[0],L[1]=K[1],L[2]=K[2],L[3]=K[3],L[4]=K[4],L[5]=K[5],L[6]=K[6],L[7]=K[7],L[8]=K[8],L[9]=K[9],L[10]=K[10],L[11]=K[11],L[12]=K[12],L[13]=K[13],L[14]=K[14],L[15]=K[15],L}e.copy=p;function v(L){return p(t(),L)}e.clone=v;function g(L,K){return L[0]=K[12],L[1]=K[13],L[2]=K[14],L}e.getTranslation=g;function b(L,K){var ge=K[0],Pe=K[1],Ie=K[2],ke=K[4],Ne=K[5],Ve=K[6],et=K[8],Re=K[9],je=K[10];return L[0]=Math.sqrt(ge*ge+Pe*Pe+Ie*Ie),L[1]=Math.sqrt(ke*ke+Ne*Ne+Ve*Ve),L[2]=Math.sqrt(et*et+Re*Re+je*je),L}e.getScaling=b;function x(L,K){var ge=K[0]+K[5]+K[10],Pe=0;return ge>0?(Pe=Math.sqrt(ge+1)*2,L[3]=.25*Pe,L[0]=(K[6]-K[9])/Pe,L[1]=(K[8]-K[2])/Pe,L[2]=(K[1]-K[4])/Pe):K[0]>K[5]&&K[0]>K[10]?(Pe=Math.sqrt(1+K[0]-K[5]-K[10])*2,L[3]=(K[6]-K[9])/Pe,L[0]=.25*Pe,L[1]=(K[1]+K[4])/Pe,L[2]=(K[8]+K[2])/Pe):K[5]>K[10]?(Pe=Math.sqrt(1+K[5]-K[0]-K[10])*2,L[3]=(K[8]-K[2])/Pe,L[0]=(K[1]+K[4])/Pe,L[1]=.25*Pe,L[2]=(K[6]+K[9])/Pe):(Pe=Math.sqrt(1+K[10]-K[0]-K[5])*2,L[3]=(K[1]-K[4])/Pe,L[0]=(K[8]+K[2])/Pe,L[1]=(K[6]+K[9])/Pe,L[2]=.25*Pe),L}e.getRotation=x;function S(L,K){var ge=1/Math.sqrt(K[0]*K[0]+K[1]*K[1]+K[2]*K[2]),Pe=1/Math.sqrt(K[4]*K[4]+K[5]*K[5]+K[6]*K[6]),Ie=1/Math.sqrt(K[8]*K[8]+K[9]*K[9]+K[10]*K[10]);return L[0]=K[0]*ge,L[1]=K[1]*ge,L[2]=K[2]*ge,L[3]=0,L[4]=K[4]*Pe,L[5]=K[5]*Pe,L[6]=K[6]*Pe,L[7]=0,L[8]=K[8]*Ie,L[9]=K[9]*Ie,L[10]=K[10]*Ie,L[11]=0,L[12]=0,L[13]=0,L[14]=0,L[15]=1,L}e.extractRotation=S;function _(L,K){if(L===K){var ge=K[1],Pe=K[2],Ie=K[3],ke=K[6],Ne=K[7],Ve=K[11];L[1]=K[4],L[2]=K[8],L[3]=K[12],L[4]=ge,L[6]=K[9],L[7]=K[13],L[8]=Pe,L[9]=ke,L[11]=K[14],L[12]=Ie,L[13]=Ne,L[14]=Ve}else L[0]=K[0],L[1]=K[4],L[2]=K[8],L[3]=K[12],L[4]=K[1],L[5]=K[5],L[6]=K[9],L[7]=K[13],L[8]=K[2],L[9]=K[6],L[10]=K[10],L[11]=K[14],L[12]=K[3],L[13]=K[7],L[14]=K[11],L[15]=K[15];return L}e.transpose=_;function C(L,K){var ge=K[0],Pe=K[1],Ie=K[2],ke=K[3],Ne=K[4],Ve=K[5],et=K[6],Re=K[7],je=K[8],tt=K[9],ht=K[10],ct=K[11],xt=K[12],_t=K[13],Ue=K[14],ut=K[15],Ct=ge*Ve-Pe*Ne,bt=ge*et-Ie*Ne,Mt=ge*Re-ke*Ne,Ot=Pe*et-Ie*Ve,ue=Pe*Re-ke*Ve,ye=Ie*Re-ke*et,we=je*_t-tt*xt,$e=je*Ue-ht*xt,Et=je*ut-ct*xt,Tt=tt*Ue-ht*_t,nr=tt*ut-ct*_t,Br=ht*ut-ct*Ue,sr=Ct*Br-bt*nr+Mt*Tt+Ot*Et-ue*$e+ye*we;return sr?(sr=1/sr,L[0]=(Ve*Br-et*nr+Re*Tt)*sr,L[1]=(Ie*nr-Pe*Br-ke*Tt)*sr,L[2]=(_t*ye-Ue*ue+ut*Ot)*sr,L[3]=(ht*ue-tt*ye-ct*Ot)*sr,L[4]=(et*Et-Ne*Br-Re*$e)*sr,L[5]=(ge*Br-Ie*Et+ke*$e)*sr,L[6]=(Ue*Mt-xt*ye-ut*bt)*sr,L[7]=(je*ye-ht*Mt+ct*bt)*sr,L[8]=(Ne*nr-Ve*Et+Re*we)*sr,L[9]=(Pe*Et-ge*nr-ke*we)*sr,L[10]=(xt*ue-_t*Mt+ut*Ct)*sr,L[11]=(tt*Mt-je*ue-ct*Ct)*sr,L[12]=(Ve*$e-Ne*Tt-et*we)*sr,L[13]=(ge*Tt-Pe*$e+Ie*we)*sr,L[14]=(_t*bt-xt*Ot-Ue*Ct)*sr,L[15]=(je*Ot-tt*bt+ht*Ct)*sr,!0):!1}e.tryInvert=C;function D(L,K){return C(L,K)||console.warn("non-invertible matrix.",K),L}e.invert=D;function T(L,K,ge){var Pe=K[0],Ie=K[1],ke=K[2],Ne=K[3],Ve=K[4],et=K[5],Re=K[6],je=K[7],tt=K[8],ht=K[9],ct=K[10],xt=K[11],_t=K[12],Ue=K[13],ut=K[14],Ct=K[15],bt=ge[0],Mt=ge[1],Ot=ge[2],ue=ge[3];return L[0]=bt*Pe+Mt*Ve+Ot*tt+ue*_t,L[1]=bt*Ie+Mt*et+Ot*ht+ue*Ue,L[2]=bt*ke+Mt*Re+Ot*ct+ue*ut,L[3]=bt*Ne+Mt*je+Ot*xt+ue*Ct,bt=ge[4],Mt=ge[5],Ot=ge[6],ue=ge[7],L[4]=bt*Pe+Mt*Ve+Ot*tt+ue*_t,L[5]=bt*Ie+Mt*et+Ot*ht+ue*Ue,L[6]=bt*ke+Mt*Re+Ot*ct+ue*ut,L[7]=bt*Ne+Mt*je+Ot*xt+ue*Ct,bt=ge[8],Mt=ge[9],Ot=ge[10],ue=ge[11],L[8]=bt*Pe+Mt*Ve+Ot*tt+ue*_t,L[9]=bt*Ie+Mt*et+Ot*ht+ue*Ue,L[10]=bt*ke+Mt*Re+Ot*ct+ue*ut,L[11]=bt*Ne+Mt*je+Ot*xt+ue*Ct,bt=ge[12],Mt=ge[13],Ot=ge[14],ue=ge[15],L[12]=bt*Pe+Mt*Ve+Ot*tt+ue*_t,L[13]=bt*Ie+Mt*et+Ot*ht+ue*Ue,L[14]=bt*ke+Mt*Re+Ot*ct+ue*ut,L[15]=bt*Ne+Mt*je+Ot*xt+ue*Ct,L}e.mul=T;function A(L,K,ge,Pe,Ie,ke){var Ne=K[0+Ie],Ve=K[1+Ie],et=K[2+Ie],Re=K[3+Ie],je=K[4+Ie],tt=K[5+Ie],ht=K[6+Ie],ct=K[7+Ie],xt=K[8+Ie],_t=K[9+Ie],Ue=K[10+Ie],ut=K[11+Ie],Ct=K[12+Ie],bt=K[13+Ie],Mt=K[14+Ie],Ot=K[15+Ie],ue=ge[0+ke],ye=ge[1+ke],we=ge[2+ke],$e=ge[3+ke];return L[0+Pe]=ue*Ne+ye*je+we*xt+$e*Ct,L[1+Pe]=ue*Ve+ye*tt+we*_t+$e*bt,L[2+Pe]=ue*et+ye*ht+we*Ue+$e*Mt,L[3+Pe]=ue*Re+ye*ct+we*ut+$e*Ot,ue=ge[4+ke],ye=ge[5+ke],we=ge[6+ke],$e=ge[7+ke],L[4+Pe]=ue*Ne+ye*je+we*xt+$e*Ct,L[5+Pe]=ue*Ve+ye*tt+we*_t+$e*bt,L[6+Pe]=ue*et+ye*ht+we*Ue+$e*Mt,L[7+Pe]=ue*Re+ye*ct+we*ut+$e*Ot,ue=ge[8+ke],ye=ge[9+ke],we=ge[10+ke],$e=ge[11+ke],L[8+Pe]=ue*Ne+ye*je+we*xt+$e*Ct,L[9+Pe]=ue*Ve+ye*tt+we*_t+$e*bt,L[10+Pe]=ue*et+ye*ht+we*Ue+$e*Mt,L[11+Pe]=ue*Re+ye*ct+we*ut+$e*Ot,ue=ge[12+ke],ye=ge[13+ke],we=ge[14+ke],$e=ge[15+ke],L[12+Pe]=ue*Ne+ye*je+we*xt+$e*Ct,L[13+Pe]=ue*Ve+ye*tt+we*_t+$e*bt,L[14+Pe]=ue*et+ye*ht+we*Ue+$e*Mt,L[15+Pe]=ue*Re+ye*ct+we*ut+$e*Ot,L}e.mulOffset=A;function E(L,K,ge,Pe){return T(L,T(L,K,ge),Pe)}e.mul3=E;function I(L,K,ge){var Pe=ge[0],Ie=ge[1],ke=ge[2],Ne,Ve,et,Re,je,tt,ht,ct,xt,_t,Ue,ut;return K===L?(L[12]=K[0]*Pe+K[4]*Ie+K[8]*ke+K[12],L[13]=K[1]*Pe+K[5]*Ie+K[9]*ke+K[13],L[14]=K[2]*Pe+K[6]*Ie+K[10]*ke+K[14],L[15]=K[3]*Pe+K[7]*Ie+K[11]*ke+K[15]):(Ne=K[0],Ve=K[1],et=K[2],Re=K[3],je=K[4],tt=K[5],ht=K[6],ct=K[7],xt=K[8],_t=K[9],Ue=K[10],ut=K[11],L[0]=Ne,L[1]=Ve,L[2]=et,L[3]=Re,L[4]=je,L[5]=tt,L[6]=ht,L[7]=ct,L[8]=xt,L[9]=_t,L[10]=Ue,L[11]=ut,L[12]=Ne*Pe+je*Ie+xt*ke+K[12],L[13]=Ve*Pe+tt*Ie+_t*ke+K[13],L[14]=et*Pe+ht*Ie+Ue*ke+K[14],L[15]=Re*Pe+ct*Ie+ut*ke+K[15]),L}e.translate=I;function R(L,K){return L[0]=1,L[1]=0,L[2]=0,L[3]=0,L[4]=0,L[5]=1,L[6]=0,L[7]=0,L[8]=0,L[9]=0,L[10]=1,L[11]=0,L[12]=K[0],L[13]=K[1],L[14]=K[2],L[15]=1,L}e.fromTranslation=R;function B(L,K){return L[12]=K[0],L[13]=K[1],L[14]=K[2],L}e.setTranslation=B;function O(L,K,ge,Pe){return L[0]=ge[0],L[4]=ge[1],L[8]=ge[2],L[1]=Pe[0],L[5]=Pe[1],L[9]=Pe[2],L[2]=K[0],L[6]=K[1],L[10]=K[2],L}e.setAxes=O;function z(L,K,ge,Pe){var Ie=Pe[0],ke=Pe[1],Ne=Pe[2],Ve=Math.sqrt(Ie*Ie+ke*ke+Ne*Ne);if(Math.abs(Ve)0&&(ct=1/Math.sqrt(ct),je*=ct,tt*=ct,ht*=ct);var xt=et*ht-Re*tt,_t=Re*je-Ve*ht,Ue=Ve*tt-et*je;return ct=xt*xt+_t*_t+Ue*Ue,ct>0&&(ct=1/Math.sqrt(ct),xt*=ct,_t*=ct,Ue*=ct),L[0]=xt,L[1]=_t,L[2]=Ue,L[3]=0,L[4]=tt*Ue-ht*_t,L[5]=ht*xt-je*Ue,L[6]=je*_t-tt*xt,L[7]=0,L[8]=je,L[9]=tt,L[10]=ht,L[11]=0,L[12]=Ie,L[13]=ke,L[14]=Ne,L[15]=1,L}e.targetTo=te;function fe(L,K){a(L);for(var ge=0;ge<4;ge++){var Pe=K[ge];l(L,ge,Pe,1)}return L}e.fromPermutation=fe;function ve(L){var K=L[0]*L[0]+L[1]*L[1]+L[2]*L[2],ge=L[4]*L[4]+L[5]*L[5]+L[6]*L[6],Pe=L[8]*L[8]+L[9]*L[9]+L[10]*L[10];return Math.sqrt(Math.max(K,ge,Pe))}e.getMaxScaleOnAxis=ve;var De=[1,0,0],Ge=[0,1,0],Ke=[0,0,1];e.rotX90=k(t(),vr(90),De),e.rotX180=k(t(),vr(180),De),e.rotY90=k(t(),vr(90),Ge),e.rotY180=k(t(),vr(180),Ge),e.rotY270=k(t(),vr(270),Ge),e.rotZ90=k(t(),vr(90),Ke),e.rotZ180=k(t(),vr(180),Ke),e.rotXY90=T(t(),e.rotX90,e.rotY90),e.rotZY90=T(t(),e.rotZ90,e.rotY90),e.rotZYZ90=T(t(),e.rotZY90,e.rotZ90),e.rotZ90X180=T(t(),e.rotZ90,e.rotX180),e.rotY90Z180=T(t(),e.rotY90,e.rotZ180),e.id=r()})(se||(se={}));function Ht(){return Ht.zero()}(function(e){function t(){var F=[.1,0,0,0,0,0,0,0,0];return F[0]=0,F}e.zero=t;function r(){var F=t();return F[0]=1,F[1]=0,F[2]=0,F[3]=0,F[4]=1,F[5]=0,F[6]=0,F[7]=0,F[8]=1,F}e.identity=r;function n(F){return F[0]=1,F[1]=0,F[2]=0,F[3]=0,F[4]=1,F[5]=0,F[6]=0,F[7]=0,F[8]=1,F}e.setIdentity=n;function a(F,j,Z){return j[Z+0]=F[0],j[Z+1]=F[1],j[Z+2]=F[2],j[Z+3]=F[3],j[Z+4]=F[4],j[Z+5]=F[5],j[Z+6]=F[6],j[Z+7]=F[7],j[Z+8]=F[8],j}e.toArray=a;function i(F,j,Z){return F[0]=j[Z+0],F[1]=j[Z+1],F[2]=j[Z+2],F[3]=j[Z+3],F[4]=j[Z+4],F[5]=j[Z+5],F[6]=j[Z+6],F[7]=j[Z+7],F[8]=j[Z+8],F}e.fromArray=i;function o(F,j,Z,Y){return F[0]=j[0],F[1]=j[1],F[2]=j[2],F[3]=Z[0],F[4]=Z[1],F[5]=Z[2],F[6]=Y[0],F[7]=Y[1],F[8]=Y[2],F}e.fromColumns=o;function s(F,j){return F[0]=j[0],F[1]=j[1],F[2]=j[2],F[3]=j[4],F[4]=j[5],F[5]=j[6],F[6]=j[8],F[7]=j[9],F[8]=j[10],F}e.fromMat4=s;function u(F,j,Z,Y,H,N,ee,oe,me){var pe=t();return pe[0]=F,pe[1]=j,pe[2]=Z,pe[3]=Y,pe[4]=H,pe[5]=N,pe[6]=ee,pe[7]=oe,pe[8]=me,pe}e.create=u;var c=r();function l(F,j){return m(F,c,typeof j>"u"?Dr:j)}e.isIdentity=l;function f(F){for(var j=0;j<9;j++)if(isNaN(F[j]))return!0;return!1}e.hasNaN=f;function d(F){return v(t(),F)}e.clone=d;function m(F,j,Z){for(var Y=0;Y<9;Y++)if(Math.abs(F[Y]-j[Y])>Z)return!1;return!0}e.areEqual=m;function h(F,j,Z,Y){F[3*Z+j]=Y}e.setValue=h;function p(F,j,Z){return F[3*Z+j]}e.getValue=p;function v(F,j){return F[0]=j[0],F[1]=j[1],F[2]=j[2],F[3]=j[3],F[4]=j[4],F[5]=j[5],F[6]=j[6],F[7]=j[7],F[8]=j[8],F}e.copy=v;function g(F,j){if(F===j){var Z=j[1],Y=j[2],H=j[5];F[1]=j[3],F[2]=j[6],F[3]=Z,F[5]=j[7],F[6]=Y,F[7]=H}else F[0]=j[0],F[1]=j[3],F[2]=j[6],F[3]=j[1],F[4]=j[4],F[5]=j[7],F[6]=j[2],F[7]=j[5],F[8]=j[8];return F}e.transpose=g;function b(F,j){var Z=j[0],Y=j[1],H=j[2],N=j[3],ee=j[4],oe=j[5],me=j[6],pe=j[7],de=j[8],re=de*ee-oe*pe,te=-de*N+oe*me,fe=pe*N-ee*me,ve=Z*re+Y*te+H*fe;return ve?(ve=1/ve,F[0]=re*ve,F[1]=(-de*Y+H*pe)*ve,F[2]=(oe*Y-H*ee)*ve,F[3]=te*ve,F[4]=(de*Z-H*me)*ve,F[5]=(-oe*Z+H*N)*ve,F[6]=fe*ve,F[7]=(-pe*Z+Y*me)*ve,F[8]=(ee*Z-Y*N)*ve,F):(console.warn("non-invertible matrix.",j),F)}e.invert=b;function x(F,j){return F===j?(F[3]=j[1],F[6]=j[2],F[7]=j[5]):(F[0]=j[0],F[1]=j[1],F[2]=j[2],F[3]=j[1],F[4]=j[4],F[5]=j[5],F[6]=j[2],F[7]=j[5],F[8]=j[8]),F}e.symmtricFromUpper=x;function S(F,j){return F===j?(F[1]=j[3],F[2]=j[6],F[5]=j[7]):(F[0]=j[0],F[1]=j[3],F[2]=j[6],F[3]=j[3],F[4]=j[4],F[5]=j[7],F[6]=j[6],F[7]=j[7],F[8]=j[8]),F}e.symmtricFromLower=S;function _(F){var j=F[0],Z=F[1],Y=F[2],H=F[3],N=F[4],ee=F[5],oe=F[6],me=F[7],pe=F[8],de=pe*N-ee*me,re=-pe*H+ee*oe,te=me*H-N*oe;return j*de+Z*re+Y*te}e.determinant=_;function C(F){return F[0]+F[4]+F[8]}e.trace=C;function D(F,j,Z){return F[0]=j[0]-Z[0],F[1]=j[1]-Z[1],F[2]=j[2]-Z[2],F[3]=j[3]-Z[3],F[4]=j[4]-Z[4],F[5]=j[5]-Z[5],F[6]=j[6]-Z[6],F[7]=j[7]-Z[7],F[8]=j[8]-Z[8],F}e.sub=D;function T(F,j,Z){return F[0]=j[0]+Z[0],F[1]=j[1]+Z[1],F[2]=j[2]+Z[2],F[3]=j[3]+Z[3],F[4]=j[4]+Z[4],F[5]=j[5]+Z[5],F[6]=j[6]+Z[6],F[7]=j[7]+Z[7],F[8]=j[8]+Z[8],F}e.add=T;function A(F,j,Z){var Y=j[0],H=j[1],N=j[2],ee=j[3],oe=j[4],me=j[5],pe=j[6],de=j[7],re=j[8],te=Z[0],fe=Z[1],ve=Z[2],De=Z[3],Ge=Z[4],Ke=Z[5],L=Z[6],K=Z[7],ge=Z[8];return F[0]=te*Y+fe*ee+ve*pe,F[1]=te*H+fe*oe+ve*de,F[2]=te*N+fe*me+ve*re,F[3]=De*Y+Ge*ee+Ke*pe,F[4]=De*H+Ge*oe+Ke*de,F[5]=De*N+Ge*me+Ke*re,F[6]=L*Y+K*ee+ge*pe,F[7]=L*H+K*oe+ge*de,F[8]=L*N+K*me+ge*re,F}e.mul=A;function E(F,j,Z){return F[0]=j[0]-Z,F[1]=j[1]-Z,F[2]=j[2]-Z,F[3]=j[3]-Z,F[4]=j[4]-Z,F[5]=j[5]-Z,F[6]=j[6]-Z,F[7]=j[7]-Z,F[8]=j[8]-Z,F}e.subScalar=E;function I(F,j,Z){return F[0]=j[0]+Z,F[1]=j[1]+Z,F[2]=j[2]+Z,F[3]=j[3]+Z,F[4]=j[4]+Z,F[5]=j[5]+Z,F[6]=j[6]+Z,F[7]=j[7]+Z,F[8]=j[8]+Z,F}e.addScalar=I;function R(F,j,Z){return F[0]=j[0]*Z,F[1]=j[1]*Z,F[2]=j[2]*Z,F[3]=j[3]*Z,F[4]=j[4]*Z,F[5]=j[5]*Z,F[6]=j[6]*Z,F[7]=j[7]*Z,F[8]=j[8]*Z,F}e.mulScalar=R;var B=Math.PI/3,O=t();function z(F,j){var Z=j[1]*j[1]+j[2]*j[2]+j[5]*j[5];if(Z===0)F[0]=j[0],F[1]=j[4],F[2]=j[8];else{var Y=C(j)/3,H=j[0]-Y,N=j[4]-Y,ee=j[8]-Y,oe=H*H+N*N+ee*ee+2*Z,me=Math.sqrt(oe/6);R(O,e.Identity,Y),D(O,j,O),R(O,O,1/me);var pe=_(O)/2,de=pe<=-1?B:pe>=1?0:Math.acos(pe)/3;F[0]=Y+2*me*Math.cos(de),F[2]=Y+2*me*Math.cos(de+2*B),F[1]=3*Y-F[0]-F[2]}return F}e.symmetricEigenvalues=z;var k=[.1,0,0],G=[.1,0,0],V=[.1,0,0],U=[.1,0,0],Q=[.1,0,0],W=[.1,0,0];function X(F,j,Z){y.set(k,j[0]-Z,j[1],j[2]),y.set(G,j[1],j[4]-Z,j[5]),y.set(V,j[2],j[5],j[8]-Z),y.cross(U,k,G),y.cross(Q,k,V),y.cross(W,G,V);var Y=y.dot(U,U),H=y.dot(Q,Q),N=y.dot(W,W),ee=Y,oe=0;return H>ee&&(ee=H,oe=1),N>ee&&(oe=2),oe===0?y.scale(F,U,1/Math.sqrt(Y)):oe===1?y.scale(F,Q,1/Math.sqrt(H)):y.scale(F,W,1/Math.sqrt(N)),F}e.eigenvector=X;function ae(F,j){return s(F,j),b(F,F),g(F,F),F}e.directionTransform=ae,e.Identity=r();function q(F,j){return F[0]*j[0]+F[1]*j[1]+F[2]*j[2]+F[3]*j[3]+F[4]*j[4]+F[5]*j[5]+F[6]*j[6]+F[7]*j[7]+F[8]*j[8]}e.innerProduct=q})(Ht||(Ht={}));function Me(){return Me.zero()}(function(e){function t(){var T=[.1,0];return T[0]=0,T}e.zero=t;function r(T){var A=t();return A[0]=T[0],A[1]=T[1],A}e.clone=r;function n(T,A){var E=t();return E[0]=T,E[1]=A,E}e.create=n;function a(T){return isNaN(T[0])||isNaN(T[1])}e.hasNaN=a;function i(T,A,E){return A[E+0]=T[0],A[E+1]=T[1],A}e.toArray=i;function o(T,A,E){return T[0]=A[E+0],T[1]=A[E+1],T}e.fromArray=o;function s(T,A){return T[0]=A[0],T[1]=A[1],T}e.copy=s;function u(T,A,E){return T[0]=A,T[1]=E,T}e.set=u;function c(T,A,E){return T[0]=A[0]+E[0],T[1]=A[1]+E[1],T}e.add=c;function l(T,A,E){return T[0]=A[0]-E[0],T[1]=A[1]-E[1],T}e.sub=l;function f(T,A,E){return T[0]=A[0]*E[0],T[1]=A[1]*E[1],T}e.mul=f;function d(T,A,E){return T[0]=A[0]/E[0],T[1]=A[1]/E[1],T}e.div=d;function m(T,A,E){return T[0]=A[0]*E,T[1]=A[1]*E,T}e.scale=m;function h(T,A){return T[0]=Math.round(A[0]),T[1]=Math.round(A[1]),T}e.round=h;function p(T,A){return T[0]=Math.ceil(A[0]),T[1]=Math.ceil(A[1]),T}e.ceil=p;function v(T,A){return T[0]=Math.floor(A[0]),T[1]=Math.floor(A[1]),T}e.floor=v;function g(T,A){var E=A[0]-T[0],I=A[1]-T[1];return Math.sqrt(E*E+I*I)}e.distance=g;function b(T,A){var E=A[0]-T[0],I=A[1]-T[1];return E*E+I*I}e.squaredDistance=b;function x(T){var A=T[0],E=T[1];return Math.sqrt(A*A+E*E)}e.magnitude=x;function S(T){var A=T[0],E=T[1];return A*A+E*E}e.squaredMagnitude=S;function _(T,A){return T[0]=1/A[0],T[1]=1/A[1],T}e.inverse=_;function C(T,A){return T[0]===A[0]&&T[1]===A[1]}e.areEqual=C;function D(T,A){return"[".concat(T[0].toPrecision(A)," ").concat(T[1].toPrecision(A),"}]")}e.toString=D})(Me||(Me={}));function Wt(){return Wt.zero()}(function(e){function t(){var R=[.1,0,0,0];return R[0]=0,R}e.zero=t;function r(R){var B=t();return B[0]=R[0],B[1]=R[1],B[2]=R[2],B[3]=R[3],B}e.clone=r;function n(R,B,O,z){var k=t();return k[0]=R,k[1]=B,k[2]=O,k[3]=z,k}e.create=n;function a(R,B){return R[0]=B.center[0],R[1]=B.center[1],R[2]=B.center[2],R[3]=B.radius,R}e.fromSphere=a;function i(R){return a(t(),R)}e.ofSphere=i;function o(R){return isNaN(R[0])||isNaN(R[1])||isNaN(R[2])||isNaN(R[3])}e.hasNaN=o;function s(R,B,O){return B[O+0]=R[0],B[O+1]=R[1],B[O+2]=R[2],B[O+3]=R[3],B}e.toArray=s;function u(R,B,O){return R[0]=B[O+0],R[1]=B[O+1],R[2]=B[O+2],R[3]=B[O+3],R}e.fromArray=u;function c(R,B,O){B[O+0]=R[0],B[O+1]=R[1],B[O+2]=R[2]}e.toVec3Array=c;function l(R,B,O){return R[0]=B[O+0],R[1]=B[O+1],R[2]=B[O+2],R[3]=0,R}e.fromVec3Array=l;function f(R,B){return R[0]=B[0],R[1]=B[1],R[2]=B[2],R[3]=B[3],R}e.copy=f;function d(R,B,O,z,k){return R[0]=B,R[1]=O,R[2]=z,R[3]=k,R}e.set=d;function m(R,B,O){return R[0]=B[0]+O[0],R[1]=B[1]+O[1],R[2]=B[2]+O[2],R[3]=B[3]+O[3],R}e.add=m;function h(R,B){var O=B[0]-R[0],z=B[1]-R[1],k=B[2]-R[2],G=B[3]-R[3];return Math.sqrt(O*O+z*z+k*k+G*G)}e.distance=h;function p(R,B,O){return R[0]=B[0]*O,R[1]=B[1]*O,R[2]=B[2]*O,R[4]=B[4]*O,R}e.scale=p;function v(R,B){return R[0]=Math.round(B[0]),R[1]=Math.round(B[1]),R[2]=Math.round(B[2]),R[3]=Math.round(B[3]),R}e.round=v;function g(R,B){return R[0]=Math.ceil(B[0]),R[1]=Math.ceil(B[1]),R[2]=Math.ceil(B[2]),R[3]=Math.ceil(B[3]),R}e.ceil=g;function b(R,B){return R[0]=Math.floor(B[0]),R[1]=Math.floor(B[1]),R[2]=Math.floor(B[2]),R[3]=Math.floor(B[3]),R}e.floor=b;function x(R,B){var O=B[0]-R[0],z=B[1]-R[1],k=B[2]-R[2],G=B[3]-R[3];return O*O+z*z+k*k+G*G}e.squaredDistance=x;function S(R){var B=R[0],O=R[1],z=R[2],k=R[3];return Math.sqrt(B*B+O*O+z*z+k*k)}e.norm=S;function _(R){var B=R[0],O=R[1],z=R[2],k=R[3];return B*B+O*O+z*z+k*k}e.squaredNorm=_;function C(R,B,O){var z=B[0],k=B[1],G=B[2],V=B[3];return R[0]=O[0]*z+O[4]*k+O[8]*G+O[12]*V,R[1]=O[1]*z+O[5]*k+O[9]*G+O[13]*V,R[2]=O[2]*z+O[6]*k+O[10]*G+O[14]*V,R[3]=O[3]*z+O[7]*k+O[11]*G+O[15]*V,R}e.transformMat4=C;function D(R,B){return R[0]*B[0]+R[1]*B[1]+R[2]*B[2]+R[3]*B[3]}e.dot=D;function T(R,B){return R[0]=1/B[0],R[1]=1/B[1],R[2]=1/B[2],R[3]=1/B[3],R}e.inverse=T;function A(R,B){return R[0]===B[0]&&R[1]===B[1]&&R[2]===B[2]&&R[3]===B[3]}e.exactEquals=A;function E(R,B){var O=R[0],z=R[1],k=R[2],G=R[3],V=B[0],U=B[1],Q=B[2],W=B[3];return Math.abs(O-V)<=Dr*Math.max(1,Math.abs(O),Math.abs(V))&&Math.abs(z-U)<=Dr*Math.max(1,Math.abs(z),Math.abs(U))&&Math.abs(k-Q)<=Dr*Math.max(1,Math.abs(k),Math.abs(Q))&&Math.abs(G-W)<=Dr*Math.max(1,Math.abs(G),Math.abs(W))}e.equals=E;function I(R,B){return"[".concat(R[0].toPrecision(B)," ").concat(R[1].toPrecision(B)," ").concat(R[2].toPrecision(B)," ").concat(R[3].toPrecision(B),"]")}e.toString=I})(Wt||(Wt={}));function Yh(e){return Object.keys(e)}function cr(e){throw new Error("unreachable")}function Dm(e){return typeof e?.then=="function"}function Jr(){return Jr.zero()}(function(e){function t(){var q=[.1,0,0,0];return q[0]=0,q}e.zero=t;function r(){var q=t();return q[3]=1,q}e.identity=r;function n(q){q[0]=0,q[1]=0,q[2]=0,q[3]=1}e.setIdentity=n;function a(q){return isNaN(q[0])||isNaN(q[1])||isNaN(q[2])||isNaN(q[3])}e.hasNaN=a;function i(q,F,j,Z){var Y=r();return Y[0]=q,Y[1]=F,Y[2]=j,Y[3]=Z,Y}e.create=i;function o(q,F,j){j=j*.5;var Z=Math.sin(j);return q[0]=Z*F[0],q[1]=Z*F[1],q[2]=Z*F[2],q[3]=Math.cos(j),q}e.setAxisAngle=o;function s(q,F){var j=Math.acos(F[3])*2,Z=Math.sin(j/2);return Z!==0?(q[0]=F[0]/Z,q[1]=F[1]/Z,q[2]=F[2]/Z):(q[0]=1,q[1]=0,q[2]=0),j}e.getAxisAngle=s;function u(q,F,j){var Z=F[0],Y=F[1],H=F[2],N=F[3],ee=j[0],oe=j[1],me=j[2],pe=j[3];return q[0]=Z*pe+N*ee+Y*me-H*oe,q[1]=Y*pe+N*oe+H*ee-Z*me,q[2]=H*pe+N*me+Z*oe-Y*ee,q[3]=N*pe-Z*ee-Y*oe-H*me,q}e.multiply=u;function c(q,F,j){j*=.5;var Z=F[0],Y=F[1],H=F[2],N=F[3],ee=Math.sin(j),oe=Math.cos(j);return q[0]=Z*oe+N*ee,q[1]=Y*oe+H*ee,q[2]=H*oe-Y*ee,q[3]=N*oe-Z*ee,q}e.rotateX=c;function l(q,F,j){j*=.5;var Z=F[0],Y=F[1],H=F[2],N=F[3],ee=Math.sin(j),oe=Math.cos(j);return q[0]=Z*oe-H*ee,q[1]=Y*oe+N*ee,q[2]=H*oe+Z*ee,q[3]=N*oe-Y*ee,q}e.rotateY=l;function f(q,F,j){j*=.5;var Z=F[0],Y=F[1],H=F[2],N=F[3],ee=Math.sin(j),oe=Math.cos(j);return q[0]=Z*oe+Y*ee,q[1]=Y*oe-Z*ee,q[2]=H*oe+N*ee,q[3]=N*oe-H*ee,q}e.rotateZ=f;function d(q,F){var j=F[0],Z=F[1],Y=F[2];return q[0]=j,q[1]=Z,q[2]=Y,q[3]=Math.sqrt(Math.abs(1-j*j-Z*Z-Y*Y)),q}e.calculateW=d;function m(q,F,j,Z){var Y=F[0],H=F[1],N=F[2],ee=F[3],oe=j[0],me=j[1],pe=j[2],de=j[3],re,te,fe,ve,De;return te=Y*oe+H*me+N*pe+ee*de,te<0&&(te=-te,oe=-oe,me=-me,pe=-pe,de=-de),1-te>1e-6?(re=Math.acos(te),fe=Math.sin(re),ve=Math.sin((1-Z)*re)/fe,De=Math.sin(Z*re)/fe):(ve=1-Z,De=Z),q[0]=ve*Y+De*oe,q[1]=ve*H+De*me,q[2]=ve*N+De*pe,q[3]=ve*ee+De*de,q}e.slerp=m;function h(q,F){var j=F[0],Z=F[1],Y=F[2],H=F[3],N=j*j+Z*Z+Y*Y+H*H,ee=N?1/N:0;return q[0]=-j*ee,q[1]=-Z*ee,q[2]=-Y*ee,q[3]=H*ee,q}e.invert=h;function p(q,F){return q[0]=-F[0],q[1]=-F[1],q[2]=-F[2],q[3]=F[3],q}e.conjugate=p;function v(q,F){return q[0]*F[0]+q[1]*F[1]+q[2]*F[2]+q[3]*F[3]}e.dot=v;function g(q,F){var j=F[0]+F[4]+F[8],Z;if(j>0)Z=Math.sqrt(j+1),q[3]=.5*Z,Z=.5/Z,q[0]=(F[5]-F[7])*Z,q[1]=(F[6]-F[2])*Z,q[2]=(F[1]-F[3])*Z;else{var Y=0;F[4]>F[0]&&(Y=1),F[8]>F[Y*3+Y]&&(Y=2);var H=(Y+1)%3,N=(Y+2)%3;Z=Math.sqrt(F[Y*3+Y]-F[H*3+H]-F[N*3+N]+1),q[Y]=.5*Z,Z=.5/Z,q[3]=(F[H*3+N]-F[N*3+H])*Z,q[H]=(F[H*3+Y]+F[Y*3+H])*Z,q[N]=(F[N*3+Y]+F[Y*3+N])*Z}return q}e.fromMat3=g;function b(q,F,j){var Z=F[0],Y=F[1],H=F[2],N=Math.cos(Z/2),ee=Math.cos(Y/2),oe=Math.cos(H/2),me=Math.sin(Z/2),pe=Math.sin(Y/2),de=Math.sin(H/2);switch(j){case"XYZ":q[0]=me*ee*oe+N*pe*de,q[1]=N*pe*oe-me*ee*de,q[2]=N*ee*de+me*pe*oe,q[3]=N*ee*oe-me*pe*de;break;case"YXZ":q[0]=me*ee*oe+N*pe*de,q[1]=N*pe*oe-me*ee*de,q[2]=N*ee*de-me*pe*oe,q[3]=N*ee*oe+me*pe*de;break;case"ZXY":q[0]=me*ee*oe-N*pe*de,q[1]=N*pe*oe+me*ee*de,q[2]=N*ee*de+me*pe*oe,q[3]=N*ee*oe-me*pe*de;break;case"ZYX":q[0]=me*ee*oe-N*pe*de,q[1]=N*pe*oe+me*ee*de,q[2]=N*ee*de-me*pe*oe,q[3]=N*ee*oe+me*pe*de;break;case"YZX":q[0]=me*ee*oe+N*pe*de,q[1]=N*pe*oe+me*ee*de,q[2]=N*ee*de-me*pe*oe,q[3]=N*ee*oe-me*pe*de;break;case"XZY":q[0]=me*ee*oe-N*pe*de,q[1]=N*pe*oe-me*ee*de,q[2]=N*ee*de+me*pe*oe,q[3]=N*ee*oe+me*pe*de;break;default:cr(j)}return q}e.fromEuler=b;var x=[0,0,0];function S(q,F,j){var Z=y.dot(F,j)+1;return ZMath.abs(F[2])?y.set(x,-F[1],F[0],0):y.set(x,0,-F[2],F[1])):y.cross(x,F,j),q[0]=x[0],q[1]=x[1],q[2]=x[2],q[3]=Z,B(q,q),q}e.fromUnitVec3=S;function _(q){var F=t();return F[0]=q[0],F[1]=q[1],F[2]=q[2],F[3]=q[3],F}e.clone=_;function C(q,F,j){return F[j+0]=q[0],F[j+1]=q[1],F[j+2]=q[2],F[j+3]=q[3],F}e.toArray=C;function D(q,F,j){return q[0]=F[j+0],q[1]=F[j+1],q[2]=F[j+2],q[3]=F[j+3],q}e.fromArray=D;function T(q,F){return q[0]=F[0],q[1]=F[1],q[2]=F[2],q[3]=F[3],q}e.copy=T;function A(q,F,j,Z,Y){return q[0]=F,q[1]=j,q[2]=Z,q[3]=Y,q}e.set=A;function E(q,F){return q[0]===F[0]&&q[1]===F[1]&&q[2]===F[2]&&q[3]===F[3]}e.exactEquals=E;function I(q,F){var j=q[0],Z=q[1],Y=q[2],H=q[3],N=F[0],ee=F[1],oe=F[2],me=F[3];return Math.abs(j-N)<=Dr*Math.max(1,Math.abs(j),Math.abs(N))&&Math.abs(Z-ee)<=Dr*Math.max(1,Math.abs(Z),Math.abs(ee))&&Math.abs(Y-oe)<=Dr*Math.max(1,Math.abs(Y),Math.abs(oe))&&Math.abs(H-me)<=Dr*Math.max(1,Math.abs(H),Math.abs(me))}e.equals=I;function R(q,F,j){return q[0]=F[0]+j[0],q[1]=F[1]+j[1],q[2]=F[2]+j[2],q[3]=F[3]+j[3],q}e.add=R;function B(q,F){var j=F[0],Z=F[1],Y=F[2],H=F[3],N=j*j+Z*Z+Y*Y+H*H;return N>0&&(N=1/Math.sqrt(N),q[0]=j*N,q[1]=Z*N,q[2]=Y*N,q[3]=H*N),q}e.normalize=B;var O=[0,0,0],z=[1,0,0],k=[0,1,0];function G(q,F,j){var Z=y.dot(F,j);return Z<-.999999?(y.cross(O,z,F),y.magnitude(O)<1e-6&&y.cross(O,k,F),y.normalize(O,O),o(q,O,Math.PI),q):Z>.999999?(q[0]=0,q[1]=0,q[2]=0,q[3]=1,q):(y.cross(O,F,j),q[0]=O[0],q[1]=O[1],q[2]=O[2],q[3]=1+Z,B(q,q))}e.rotationTo=G;var V=t(),U=t();function Q(q,F,j,Z,Y,H){return m(V,F,Y,H),m(U,j,Z,H),m(q,V,U,2*H*(1-H)),q}e.sqlerp=Q;var W=[0,0,0,0,0,0,0,0,0];function X(q,F,j,Z){return W[0]=j[0],W[3]=j[1],W[6]=j[2],W[1]=Z[0],W[4]=Z[1],W[7]=Z[2],W[2]=-F[0],W[5]=-F[1],W[8]=-F[2],B(q,g(q,W))}e.setAxes=X;function ae(q,F){return"[".concat(q[0].toPrecision(F)," ").concat(q[1].toPrecision(F)," ").concat(q[2].toPrecision(F)," ").concat(q[3].toPrecision(F),"]")}e.toString=ae,e.Identity=r()})(Jr||(Jr={}));var tr;(function(e){function t(_,C,D){for(var T=[],A=0;A=0;I--)E=(E+C[T[I]])*D[I];return E}function v(_,C,D){for(var T=_.dimensions,A=_.axisOrderFastToSlow,E=T.length,I=C,R=0;R"u"&&(e[a]=t[a])}return e}function Age(e,t){for(var r=!1,n=0,a=Object.keys(t);nr-t)return!1;for(var i=0;i]+>/g,"")}function pd(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hi(){return hi.zero()}(function(e){function t(){var R=[.1,0,0];return R[0]=0,R}e.zero=t;function r(R,B,O){var z=t();return z[0]=R,z[1]=B,z[2]=O,z}e.create=r;function n(R,B,O,z){return R[0]=B,R[1]=O,R[2]=z,R}e.set=n;function a(R,B){var O=B[0]-R[0],z=B[1]-R[1],k=B[2]-R[2];return Math.sqrt(O*O+z*z+k*k)}e.distance=a;function i(R,B){var O=Xe.toRgb(B),z=O[0],k=O[1],G=O[2],V=I(z,k,G),U=V[0],Q=V[1],W=V[2],X=116*Q-16;return R[0]=X<0?0:X,R[1]=500*(U-Q),R[2]=200*(Q-W),R}e.fromColor=i;function o(R,B){return yu.toLab(R,B)}e.fromHcl=o;function s(R){var B=(R[0]+16)/116,O=isNaN(R[1])?B:B+R[1]/500,z=isNaN(R[2])?B:B-R[2]/200;B=g*T(B),O=v*T(O),z=b*T(z);var k=D(3.2404542*O-1.5371385*B-.4985314*z),G=D(-.969266*O+1.8760108*B+.041556*z),V=D(.0556434*O-.2040259*B+1.0572252*z);return Xe.fromRgb(Math.round(Ta(k,0,255)),Math.round(Ta(G,0,255)),Math.round(Ta(V,0,255)))}e.toColor=s;function u(R,B){var O=B[0],z=B[1],k=B[2],G=Math.sqrt(z*z+k*k),V=(Zi(Math.atan2(k,z))+360)%360;return Math.round(G*1e4)===0&&(V=Number.NaN),R[0]=V,R[1]=G,R[2]=O,R}e.toHcl=u;function c(R,B){return R[0]=B[0],R[1]=B[1],R[2]=B[2],R}e.copy=c;function l(R,B,O){return R[0]=B[0]-p*O,R[1]=B[1],R[2]=B[2],R}e.darken=l;function f(R,B,O){return l(R,B,-O)}e.lighten=f;var d=[0,0,0];function m(R,B,O){return u(d,B),yu.toLab(R,yu.saturate(d,d,O))}e.saturate=m;function h(R,B,O){return m(R,B,-O)}e.desaturate=h;var p=18,v=.95047,g=1,b=1.08883,x=.137931034,S=.206896552,_=.12841855,C=.008856452;function D(R){return 255*(R<=.00304?12.92*R:1.055*Math.pow(R,1/2.4)-.055)}function T(R){return R>S?R*R*R:_*(R-x)}function A(R){return(R/=255)<=.04045?R/12.92:Math.pow((R+.055)/1.055,2.4)}function E(R){return R>C?Math.pow(R,1/3):R/_+x}function I(R,B,O){R=A(R),B=A(B),O=A(O);var z=E((.4124564*R+.3575761*B+.1804375*O)/v),k=E((.2126729*R+.7151522*B+.072175*O)/g),G=E((.0193339*R+.119192*B+.9503041*O)/b);return[z,k,G]}})(hi||(hi={}));function yu(){return yu.zero()}(function(e){function t(){var b=[.1,0,0];return b[0]=0,b}e.zero=t;function r(b,x,S){var _=t();return _[0]=b,_[1]=x,_[2]=S,_}e.create=r;function n(b,x,S,_){return b[0]=x,b[1]=S,b[2]=_,b}e.set=n;function a(b){return!isNaN(b[0])}e.hasHue=a;var i=[0,0,0];function o(b,x){return hi.toHcl(b,hi.fromColor(i,x))}e.fromColor=o;function s(b,x){return hi.toHcl(b,x)}e.fromLab=s;var u=[0,0,0];function c(b){return hi.toColor(l(u,b))}e.toColor=c;function l(b,x){var S=x[0],_=x[1],C=x[2];return isNaN(S)&&(S=0),S=vr(S),b[0]=C,b[1]=Math.cos(S)*_,b[2]=Math.sin(S)*_,b}e.toLab=l;function f(b,x){return b[0]=x[0],b[1]=x[1],b[2]=x[2],b}e.copy=f;function d(b,x,S){return b[0]=x[0],b[1]=Math.max(0,x[1]+g*S),b[2]=x[2],b}e.saturate=d;function m(b,x,S){return d(b,x,-S)}e.desaturate=m;var h=[0,0,0];function p(b,x,S){return l(h,x),hi.toHcl(b,hi.darken(h,h,S))}e.darken=p;function v(b,x,S){return p(b,x,-S)}e.lighten=v;var g=18})(yu||(yu={}));function Xe(e){return e}(function(e){function t(k){return"rgb(".concat(k>>16&255,", ").concat(k>>8&255,", ").concat(k&255,")")}e.toStyle=t;function r(k){return"#"+("000000"+k.toString(16)).slice(-6)}e.toHexStyle=r;function n(k){return"0x"+("000000"+k.toString(16)).slice(-6)}e.toHexString=n;function a(k){return"RGB: ".concat(e.toRgb(k).join(", "))}e.toRgbString=a;function i(k){return[k>>16&255,k>>8&255,k&255]}e.toRgb=i;function o(k){return[(k>>16&255)/255,(k>>8&255)/255,(k&255)/255]}e.toRgbNormalized=o;function s(k){return parseInt(k.replace("#","0x"))}e.fromHexStyle=s;function u(k){return parseInt(k)}e.fromHexString=u;function c(k,G,V){return k<<16|G<<8|V}e.fromRgb=c;function l(k,G,V){return k*255<<16|G*255<<8|V*255}e.fromNormalizedRgb=l;function f(k,G){return c(k[G],k[G+1],k[G+2])}e.fromArray=f;function d(k,G){return l(k[G],k[G+1],k[G+2])}e.fromNormalizedArray=d;function m(k,G,V){return G[V]=k>>16&255,G[V+1]=k>>8&255,G[V+2]=k&255,G}e.toArray=m;function h(k,G,V){return G[V]=(k>>16&255)/255,G[V+1]=(k>>8&255)/255,G[V+2]=(k&255)/255,G}e.toArrayNormalized=h;function p(k,G){return k[0]=G>>16&255,k[1]=G>>8&255,k[2]=G&255,k}e.toVec3=p;function v(k,G){return k[0]=(G>>16&255)/255,k[1]=(G>>8&255)/255,k[2]=(G&255)/255,k}e.toVec3Normalized=v;function g(k,G,V){var U=k>>16&255,Q=k>>8&255,W=k&255,X=G>>16&255,ae=G>>8&255,q=G&255,F=U+(X-U)*V,j=Q+(ae-Q)*V,Z=W+(q-W)*V;return F<<16|j<<8|Z}e.interpolate=g;function b(k){var G=k>>16&255,V=k>>8&255,U=k&255;return G!==V||G!==U}e.hasHue=b;var x=[0,0,0];function S(k,G){return b(k)?(yu.fromColor(x,k),yu.toColor(yu.saturate(x,x,G))):k}e.saturate=S;function _(k,G){return S(k,-G)}e.desaturate=_;var C=[0,0,0];function D(k,G){return hi.fromColor(C,k),hi.toColor(hi.darken(C,C,G))}e.darken=D;function T(k,G){return D(k,-G)}e.lighten=T;function A(k){return k<=.03928?k/12.92:Math.pow((k+.055)/1.055,2.4)}function E(k){var G=A((k>>16&255)/255),V=A((k>>8&255)/255),U=A((k&255)/255);return .2126*G+.7152*V+.0722*U}e.luminance=E;function I(k,G){var V=E(k),U=E(G);return V>U?(V+.05)/(U+.05):(U+.05)/(V+.05)}e.contrast=I;function R(k){return k<.04045?k*.0773993808:Math.pow(k*.9478672986+.0521327014,2.4)}function B(k){return l(R((k>>16&255)/255),R((k>>8&255)/255),R((k&255)/255))}e.sRGBToLinear=B;function O(k){return k<.0031308?k*12.92:1.055*Math.pow(k,.41666)-.055}function z(k){return l(O((k>>16&255)/255),O((k>>8&255)/255),O((k&255)/255))}e.linearToSRGB=z})(Xe||(Xe={}));function zr(e,t,r,n){return{label:e,description:r,list:n,type:t}}function Em(e,t,r){var n={};for(var a in e){var i=e[a];i=Xe.saturate(i,t),i=Xe.darken(i,-r),n[a]=i}return n}var Ao={"orange-red":zr("Orange-Red","sequential","Orange-Red, sequential color scheme from ColorBrewer 2.0",[16775148,16705736,16635038,16628612,16551257,15689032,14102559,11730944,8323072]),"purple-blue":zr("Purple-Blue","sequential","Purple-Blue, sequential color scheme from ColorBrewer 2.0",[16775163,15525874,13685222,10927579,7645647,3576e3,356528,285325,145496]),"blue-purple":zr("Blue-Purple","sequential","Blue-Purple, sequential color scheme from ColorBrewer 2.0",[16252157,14740724,12571622,10403034,9213638,9202609,8929693,8458108,5046347]),oranges:zr("Oranges","sequential","",[16774635,16705230,16634018,16625259,16616764,15821075,14239745,10892803,8333060]),"blue-green":zr("Blue-Green","sequential","",[16252157,15070713,13429990,10082505,6734500,4304502,2329413,27948,17435]),"yellow-orange-brown":zr("Yellow-Orange-Brown","sequential","",[16777189,16775100,16704401,16696399,16685353,15495188,13388802,10040324,6694150]),"yellow-green":zr("Yellow-Green","sequential","",[16777189,16252089,14282915,11394446,7915129,4303709,2327619,26679,17705]),reds:zr("Reds","sequential","",[16774640,16703698,16563105,16552562,16476746,15678252,13309981,10817301,6750221]),"red-purple":zr("Red-Purple","sequential","",[16775155,16638173,16565696,16424885,16214177,14496919,11403646,7995767,4784234]),greens:zr("Greens","sequential","",[16252149,15070688,13101504,10607003,7652470,4303709,2329413,27948,17435]),"yellow-green-blue":zr("Yellow-Green-Blue","sequential","",[16777177,15595697,13101492,8375739,4306628,1937856,2252456,2438292,531800]),purples:zr("Purples","sequential","",[16579581,15724021,14342891,12369372,10394312,8420794,6967715,5515151,4128893]),"green-blue":zr("Green-Blue","sequential","",[16252144,14742491,13429701,11066805,8113348,5157843,2854078,551084,540801]),greys:zr("Greys","sequential","",[16777215,15790320,14277081,12434877,9868950,7566195,5395026,2434341,0]),"yellow-orange-red":zr("Yellow-Orange-Red","sequential","",[16777164,16772512,16701814,16691788,16616764,16535082,14883356,12386342,8388646]),"purple-red":zr("Purple-Red","sequential","",[16250105,15196655,13941210,13210823,14640560,15149450,13505110,9961539,6750239]),blues:zr("Blues","sequential","",[16251903,14609399,13032431,10406625,7057110,4362950,2191797,545180,536683]),"purple-blue-green":zr("Purple-Blue-Green","sequential","",[16775163,15524592,13685222,10927579,6793679,3576e3,164234,93273,83510]),spectral:zr("Spectral","diverging","",[10355010,13975119,16018755,16625249,16703627,16777151,15136152,11263396,6734501,3311805,6180770]),"red-yellow-green":zr("Red-Yellow-Green","diverging","",[10813478,14102567,16018755,16625249,16703627,16777151,14282635,10934634,6733155,1742928,26679]),"red-blue":zr("Red-Blue","diverging","",[6750239,11671595,14049357,16033154,16636871,16250871,13755888,9618910,4428739,2188972,340065]),"pink-yellow-green":zr("Pink-Yellow-Green","diverging","",[9306450,12917629,14579630,15840986,16638191,16250871,15136208,12116358,8371265,5083681,2581529]),"purple-green":zr("Purple-Green","diverging","",[4194379,7744131,10055851,12756431,15193320,16250871,14282963,10935200,5942881,1800247,17435]),"red-yellow-blue":zr("Red-Yellow-Blue","diverging","Red-Yellow-Blue, diverging color scheme from ColorBrewer 2.0",[10813478,14102567,16018755,16625249,16703632,16777151,14742520,11262441,7646673,4552116,3225237]),"brown-white-green":zr("Brown-White-Green","diverging","",[5517317,9195786,12550445,14664317,16181443,16119285,13101797,8441281,3512207,91742,15408]),"red-grey":zr("Red-Grey","diverging","",[6750239,11671595,14049357,16033154,16636871,16777215,14737632,12237498,8882055,5066061,1710618]),"orange-purple":zr("Orange-Purple","diverging","",[8338184,11753478,14713364,16627811,16703670,16250871,14211819,11709394,8418220,5515144,2949195]),"set-2":zr("Set-2","qualitative","",[6734501,16551266,9281739,15174339,10934356,16767279,15058068,11776947]),accent:zr("Accent","qualitative","",[8374655,12496596,16629894,16777113,3697840,15729279,12540695,6710886]),"set-1":zr("Set-1","qualitative","",[14948892,3636920,5091146,9981603,16744192,16777011,10901032,16220607,10066329]),"set-3":zr("Set-3","qualitative","",[9294791,16777139,12499674,16482418,8434131,16626786,11787881,16567781,14277081,12353725,13429701,16772463]),"dark-2":zr("Dark-2","qualitative","",[1810039,14245634,7696563,15149450,6727198,15117058,10909213,6710886]),paired:zr("Paired","qualitative","",[10931939,2062516,11722634,3383340,16489113,14883356,16629615,16744192,13284054,6962586,16777113,11622696]),"pastel-2":zr("Pastel-2","qualitative","",[11789005,16633260,13358568,16042724,15136201,16773806,15852236,13421772]),"pastel-1":zr("Pastel-1","qualitative","",[16495790,11783651,13429701,14601188,16701862,16777164,15063229,16636652,15921906]),"many-distinct":zr("Many-Distinct","qualitative","",[1810039,14245634,7696563,15149450,6727198,15117058,10909213,6710886,14948892,3636920,5091146,9981603,16744192,16777011,10901032,16220607,10066329,6734501,16551266,9281739,15174339,10934356,16767279,15058068,11776947]),magma:zr("Magma","sequential","Perceptually uniform shades of black-red-white",[4329332,4853881,5378684,5903742,6363263,6888576,7413633,7938689,8463745,8988801,9513600,10038655,10563454,11088508,11613562,12138360,12728949,13254258,13714030,14239338,14699366,15094114,15489119,15753309,16017499,16216411,16350045,16483424,16551523,16619368,16621934,16689780,16692091,16694402,16696969,16633746,16636058,16638371,16575148,16577461,16514239]),inferno:zr("Inferno","sequential","Perceptually uniform shades of black-red-yellow",[4721514,5246316,5771373,6296430,6821486,7346542,7871597,8396651,8921450,9446504,9971557,10496610,10956127,11481435,12006486,12466258,12926285,13386056,13780802,14241085,14570295,14965297,15229227,15558693,15757342,15956248,16154897,16288267,16421638,16489734,16492043,16494612,16496926,16368426,16305463,16111429,15982678,15853928,15856253,16119953,16580260]),plasma:zr("Plasma","sequential","Perceptually uniform shades of blue-red-yellow",[1771148,2426257,3081365,3671193,4195228,4784799,5308834,5833124,6357158,6815911,7340200,7864744,8324007,8783782,9309348,9769377,10164126,10624154,11018902,11413393,11808141,12137352,12466307,12795519,13124730,13453685,13717361,14046573,14309992,14573668,14837344,15035483,15299159,15497299,15695438,15893834,16091974,16224833,16357693,16425017,16557877,16625457,16627245,16629289,16631334,16567845,16438820,16310052,16115494,15921190,15726625]),viridis:zr("Viridis","sequential","Perceptually uniform shades of blue-green-yellow",[4524123,4656994,4658793,4726127,4727668,4663929,4599933,4535937,4406404,4276870,4081800,3952010,3822475,3627148,3497356,3302029,3172237,3042446,2912654,2782862,2652814,2523022,2393229,2328973,2198924,2069132,2004874,2005897,2007175,2139525,2337154,2666111,3060348,3520376,4045684,4570991,5227369,5883748,6605661,7392854,8180303,8967495,9819967,10672695,11525166,12443174,13295646,14148121,15000344,15852828,16639780]),cividis:zr("Cividis","sequential","Perceptually uniform shades of blue-green-yellow, should look effectively identical to colorblind and non-colorblind users",[11367,12400,537456,1455727,2046574,2571629,3031404,3425388,3754092,4148075,4476779,4805227,5133932,5396844,5725549,5988462,6317166,6580079,6843249,7171698,7434867,7697781,7960951,8289656,8618104,8881272,9209976,9538679,9867127,10195830,10524533,10853235,11181938,11510640,11839343,12168045,12497002,12891240,13219941,13548642,13943134,14271834,14666326,14995025,15389516,15718470,16112703,16507190,16639799]),twilight:zr("Twilight","sequential","Perceptually uniform shades of white-blue-black-red-white, cyclic",[14670305,14211037,13554648,12766675,11847630,10993866,10139847,9351365,8628419,8036290,7509952,7048895,6718653,6519739,6386105,6252470,6184114,6181293,6112935,6044831,5976470,5777291,5447293,5052270,4592479,4067665,3674181,3281211,3150646,3543352,4067644,4657728,5379141,6166345,6953549,7741007,8463184,9120336,9777743,10304079,10830671,11291984,11687762,12083541,12348505,12613471,12878439,13077872,13211771,13411209,13545111,13809830,14074293,14338756,14537169,14735067,14801121]),turbo:zr("Turbo","sequential","Improved (smooth) rainbow colormap for visualization",[4866485,4872413,4354034,3770361,3120629,2667241,2475736,2611140,3073454,3928216,5109892,6487408,8126047,9829201,11531332,13167162,14605618,15780908,16693543,16753699,16748063,16741916,16146200,15026195,13644558,12198408,10818563,9833728]),rainbow:zr("Rainbow","sequential","",[3367393,3516485,16383744,15501073,12526114]),"red-white-blue":zr("Red-White-Blue","diverging","",[12526114,16777215,3367393])},Ige=Object.keys(Ao),s8=Ige.map(function(e){return[e,Ao[e].label,Pm(Ao[e].type)]}),QXe=s8.filter(function(e){return Ao[e[0]].type==="diverging"||Ao[e[0]].type==="sequential"}),$Xe=s8.filter(function(e){return Ao[e[0]].type==="qualitative"});function vs(e){return e in Ao?Ao[e]:(console.warn("unknown color list named '".concat(e,"'")),Ao["red-yellow-blue"])}var He;(function(e){function t(d){return d.creator&&d.chunkSize}e.is=t;function r(d){var m=d.growBy*d.elementSize;d.currentSize=m,d.currentIndex=0,d.currentChunk=new d.ctor(m),d.allocatedSize+=m,d.chunks[d.chunks.length]=d.currentChunk}function n(d,m,h,p,v){d.currentIndex>=d.currentSize&&r(d);var g=d.currentChunk,b=d.currentIndex;return g[b]=m,g[b+1]=h,g[b+2]=p,g[b+3]=v,d.currentIndex+=4,d.elementCount++}e.add4=n;function a(d,m,h,p){d.currentIndex>=d.currentSize&&r(d);var v=d.currentChunk,g=d.currentIndex;return v[g]=m,v[g+1]=h,v[g+2]=p,d.currentIndex+=3,d.elementCount++}e.add3=a;function i(d,m,h){d.currentIndex>=d.currentSize&&r(d);var p=d.currentChunk,v=d.currentIndex;return p[v]=m,p[v+1]=h,d.currentIndex+=2,d.elementCount++}e.add2=i;function o(d,m){return d.currentIndex>=d.currentSize&&r(d),d.currentChunk[d.currentIndex]=m,d.currentIndex+=1,d.elementCount++}e.add=o;function s(d,m,h){for(var p=0;p=d.currentSize&&r(d),d.currentChunk[d.currentIndex++]=h,d.elementCount++;return d.elementCount}e.addRepeat=s;function u(d,m){for(var h=d.elementSize,p=0,v=m.length;p=d.currentSize&&r(d);for(var g=d.currentChunk,b=0;b=d.currentSize)S.set(A,_);else for(var D=0,T=A.length;D"u")return v;if(typeof p=="number")return v.currentChunk=new d(p*m),v.allocatedSize=p*m,v.currentSize=v.currentChunk.length,v.chunks[0]=v.currentChunk,v;var g=p;if(g.length%m!==0)throw new Error("initialChunk length must be a multiple of the element size.");return v.currentChunk=g,v.allocatedSize=g.length,v.currentSize=g.length,v.chunks[0]=g,v}e.create=f})(He||(He={}));function G2(e,t,r){return e[t]-e[r]}function hd(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function u8(e,t,r,n){var a=r+n>>1;return t(e,r,n)>0?t(e,r,a)>0?t(e,a,n)>0?a:n:r:t(e,n,a)>0?t(e,a,r)>0?a:r:n}function Mge(e,t,r){var n=e.cmp,a=e.swap,i=e.data,o=e.parts,s=t+1,u=r;for(a(i,t,u8(i,n,t,r));n(i,u,t)>0;)--u;for(var c=t+1;c<=u;c++){var l=n(i,c,t);if(l>0){for(a(i,c,u),--u;n(i,u,t)>0;)--u;c--}else l===0&&(a(i,c,s),s++)}for(var c=t;c=t&&a(n,s,s+1)>0;)i(n,s,s+1),s=s-1}function z2(e,t,r){for(var n=e.parts;to;)--i;for(var s=r+1;s<=i;s++){var u=e[s];if(u>o){for(hd(e,s,i),--i;e[i]>o;)--i;s--}else u===o&&(hd(e,s,a),++a)}for(var s=r;s=t&&e[i]>a;)e[i+1]=e[i],i=i-1;e[i+1]=a}}function _3(e,t,r,n){for(;ro[c].key){m=!1;break}}if(u&&m){for(var c=0;c>4;return t=(t^3735928559)+(t<<5),t=t^t>>11,t}function bu(e,t){var r=23;return r=31*r+e|0,r=31*r+t|0,r=r^r>>4,r=(r^3735928559)+(r<<5),r=r^r>>11,r}function l8(e,t,r){var n=23;return n=31*n+e|0,n=31*n+t|0,n=31*n+r|0,n=n^n>>4,n=(n^3735928559)+(n<<5),n=n^n>>11,n}function f8(e,t,r,n){var a=23;return a=31*a+e|0,a=31*a+t|0,a=31*a+r|0,a=31*a+n|0,a=a^a>>4,a=(a^3735928559)+(a<<5),a=a^a>>11,a}function B1(e){for(var t=0,r=0,n=e.length;r>>0}var Aa={};fi(Aa,{createAndFillArray:()=>Uge,createArray:()=>Xh,fillArrayValues:()=>d8,getArrayBounds:()=>Mm,isTypedArray:()=>Y2,typedArrayWindow:()=>X2});function Mm(e,t){var r=t&&typeof t.start<"u"?Math.max(Math.min(t.start,e-1),0):0,n=t&&typeof t.end<"u"?Math.min(t.end,e):e;return{start:r,end:n}}function Xh(e,t){var r=t&&typeof t.array<"u"?t.array:Array,n=Mm(e,t),a=n.start,i=n.end;return{array:new r(i-a),start:a,end:i}}function d8(e,t,r){for(var n=0,a=t.length;n9||o<0)return i*a|0;a=10*a+o|0}return i*a}function m8(e,t,r,n){return t.charCodeAt(r)===43&&r++,e*Math.pow(10,Ec(t,r,n))}function p8(e,t,r){for(;t=0&&u<10)i=i*10+u,++n;else if(u===-2){for(++n;n=0&&u<10)o=10*o+u,s=10*s,++n;else return u===53||u===21?m8(a*(i+o/s),e,n+1,r):a*(i+o/s);return a*(i+o/s)}else{if(u===53||u===21)return m8(a*i,e,n+1,r);break}}return a*i}var ne;(function(e){var t;(function(E){E.str={"@type":"str",T:"",valueType:"str"},E.ustr={"@type":"str",T:"",valueType:"str",transform:"uppercase"},E.lstr={"@type":"str",T:"",valueType:"str",transform:"lowercase"},E.int={"@type":"int",T:0,valueType:"int"},E.coord={"@type":"coord",T:0,valueType:"float"},E.float={"@type":"float",T:0,valueType:"float"};function I(U){var Q;return{"@type":"str",T:(Q=U?.defaultValue)!==null&&Q!==void 0?Q:"",transform:U?.transform,valueType:"str"}}E.Str=I;function R(U){return U===void 0&&(U=0),{"@type":"int",T:U,valueType:"int"}}E.Int=R;function B(U){return U===void 0&&(U=0),{"@type":"float",T:U,valueType:"float"}}E.Float=B;function O(U,Q){return Q===void 0&&(Q=E.float),{"@type":"tensor",T:U.create(),space:U,valueType:"tensor",baseType:Q}}E.Tensor=O;function z(U,Q){return Q===void 0&&(Q=E.float),O(tr.Vector(U,Q["@type"]==="int"?Int32Array:Float64Array),Q)}E.Vector=z;function k(U,Q,W){return W===void 0&&(W=E.float),O(tr.ColumnMajorMatrix(U,Q,W["@type"]==="int"?Int32Array:Float64Array),W)}E.Matrix=k;function G(U){return U}E.Aliased=G;function V(U,Q,W){return W===void 0&&(W=[]),{"@type":"list",T:W,separator:U,itemParse:Q,valueType:"list"}}E.List=V})(t=e.Schema||(e.Schema={}));function r(E){return!!E&&!!E.schema&&!!E.value}e.is=r,e.ValueKind={Present:0,NotPresent:1,Unknown:2};function n(E,I){return h8(I.T,E,I,1)}e.Undefined=n;function a(E,I,R){return h8(E,I,R,0)}e.ofConst=a;function i(E){return K2(E)}e.ofLambda=i;function o(E,I){return i({value:function(R){return R+E},rowCount:Math.max(I-E+1,0),schema:t.int})}e.range=o;function s(E){return gd(E)}e.ofArray=s;function u(E){return gd({array:E,schema:t.int})}e.ofIntArray=u;function c(E){return gd({array:E,schema:t.float})}e.ofFloatArray=c;function l(E){return gd({array:E,schema:t.str})}e.ofStringArray=l;function f(E){return gd({array:E,schema:t.Aliased(t.str)})}e.ofStringAliasArray=f;function d(E,I){return I===void 0&&(I=","),gd({array:E,schema:t.List(I,function(R){return R})})}e.ofStringListArray=d;function m(E){var I=E.count,R=E.data,B=E.indices;return K2({value:function(O){return Ec(R,B[2*O],B[2*O+1])||0},rowCount:I,schema:t.int})}e.ofIntTokens=m;function h(E){var I=E.count,R=E.data,B=E.indices;return K2({value:function(O){return Ws(R,B[2*O],B[2*O+1])||0},rowCount:I,schema:t.float})}e.ofFloatTokens=h;function p(E){var I=E.count,R=E.data,B=E.indices;return K2({value:function(O){var z=R.substring(B[2*O],B[2*O+1]);return z==="."||z==="?"?"":z},rowCount:I,schema:t.str})}e.ofStringTokens=p;function v(E,I,R){return zge(E,I,R)}e.window=v;function g(E,I,R){return R===void 0&&(R=!0),Wge(E,I,R)}e.view=g;function b(E){return Vge(E)}e.createFirstIndexMap=b;function x(E){return Gge(E)}e.createIndexer=x;function S(E,I,R){return Kge(E,I,R||Array)}e.mapToArray=S;function _(E,I){return Zge(E,I)}e.areEqual=_;function C(E,I){return Jge(E,I)}e.indicesOf=C;function D(E,I){return E.__array?E:E.isDefined?gd({array:E.toArray({array:I}),schema:E.schema,valueKind:E.valueKind}):n(E.rowCount,E.schema)}e.asArrayColumn=D;function T(E,I,R){if(R===void 0&&(R=0),!!E.isDefined){var B=E.__array;if(B)for(var O=0,z=B.length;O"u"?1:0}})},E=0,I=T;E>>0&127|0;continue}if(i<2048){e[t++]=i>>>6&31|192,e[t++]=i>>>0&63|128;continue}if(i<65536){e[t++]=i>>>12&15|224,e[t++]=i>>>6&63|128,e[t++]=i>>>0&63|128;continue}if(i<1114112){e[t++]=i>>>18&7|240,e[t++]=i>>>12&63|128,e[t++]=i>>>6&63|128,e[t++]=i>>>0&63|128;continue}throw new Error("bad codepoint "+i)}}var n0e=function(){for(var e=[],t=0;t<1024;t++)e[t]=String.fromCharCode(t);return e}();function y8(e){throw new Error(e)}function a0e(e,t,r){for(var n=n0e,a=void 0,i=0,o=[],s=512,u=t,c=t+r;u0&&(a[a.length]=o.slice(0,i).join("")),a.join("")):o.slice(0,i).join("")}var g8=typeof TextDecoder<"u"?new TextDecoder:void 0;function y0(e,t,r){if(g8){var n=t||r!==e.length?e.subarray(t,t+r):e;return g8.decode(n)}else return a0e(e,t,r)}function b0(e){for(var t=0,r=0,n=e.length;r0?[4,new Promise(function(i){t.onChildrenFinished=i})]:[3,5]):[3,6];case 4:a.sent(),a.label=5;case 5:e.onAbort&&e.onAbort(),a.label=6;case 6:throw n;case 7:return[2]}})})}function P8(e){throw e.abortToken.treeAborted||(e.abortToken.treeAborted=!0,E8(e.root),I8(e,pn())),Ce.Aborted(e.abortToken.reason)}function E8(e){var t=e.progress;t.isIndeterminate=!0,t.canAbort=!1,t.message="Aborting...";for(var r=0,n=e.children;rthis.info.updateRateMs},enumerable:!1,configurable:!0}),e.prototype.updateProgress=function(t){if(this.checkAborted(),!!t){var r=this.node.progress;typeof t=="string"?(r.message=t,r.isIndeterminate=!0):(typeof t.canAbort<"u"&&(r.canAbort=t.canAbort),typeof t.message<"u"&&(r.message=t.message),typeof t.current<"u"&&(r.current=t.current),typeof t.max<"u"&&(r.max=t.max),r.isIndeterminate=typeof r.current>"u"||typeof r.max>"u",typeof t.isIndeterminate<"u"&&(r.isIndeterminate=t.isIndeterminate))}},e.prototype.update=function(t,r){if(this.lastUpdatedTime=pn(),this.updateProgress(t),!r)return I8(this.info,this.lastUpdatedTime),this.checkAborted(),yd.immediatePromise()},e.prototype.runChild=function(t,r){return $(this,void 0,void 0,function(){var n,a,i,o,s,u,c;return J(this,function(l){switch(l.label){case 0:this.updateProgress(r),n={progress:w8(t),children:[]},a=this.node.children,a.push(n),i=new e(this.info,n),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,A3(t,i)];case 2:return[2,l.sent()];case 3:if(o=l.sent(),Ce.isAbort(o)&&this.isAborted)return[2,void 0];throw o;case 4:if(s=a.indexOf(n),s>=0){for(u=s,c=a.length-1;u0?(o+=c,f=pn()-u,l+=f,s+=f,e.shouldUpdate?[4,a(e,r,o)]:[3,3]):[3,4];case 2:d.sent(),i=Math.round(l*o/s)+1,u=pn(),l=0,d.label=3;case 3:return[3,1];case 4:return e.shouldUpdate?[4,a(e,r,o)]:[3,6];case 5:d.sent(),d.label=6;case 6:return[2,r]}})})}var Kh=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,S0=f0e(),k1=d0e();function f0e(){return typeof XMLHttpRequest>"u"||Kh?B8():XMLHttpRequest}function d0e(){if(typeof File>"u"||Kh){var e=function(){function t(r,n,a){var i;this.blob=new Blob(r,a),this.size=this.blob.size,this.type=this.blob.type,this.name=n,this.lastModified=(i=a?.lastModified)!==null&&i!==void 0?i:0,this.webkitRelativePath=""}return t.prototype.arrayBuffer=function(){return this.blob.arrayBuffer()},t.prototype.slice=function(r,n,a){return this.blob.slice(r,n,a)},t.prototype.stream=function(){return this.blob.stream()},t.prototype.text=function(){return this.blob.text()},t}();return e}else return File}function O8(e){return e>>0}function bd(e,t){return e[t]|e[t+1]<<8}function Fm(e,t,r){e[t]=r&255,e[t+1]=r>>8&255}function Lm(e,t){return e[t+3]*(256*256*256)+(e[t+2]<<16|e[t+1]<<8|e[t])}function Cf(e,t,r){e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255}function m0e(e,t,r){for(var n="",a=0;a>6,e[t+a+1]=128|o>>0&63,a+=2;else if(!(o&4294967295-65536+1))e[t+a]=224|o>>12,e[t+a+1]=128|o>>6&63,e[t+a+2]=128|o>>0&63,a+=3;else if(!(o&4294967295-(1<<21)+1))e[t+a]=240|o>>18,e[t+a+1]=128|o>>12&63,e[t+a+2]=128|o>>6&63,e[t+a+3]=128|o>>0&63,a+=4;else throw new Error("e")}return a}function P3(e){for(var t=e.length,r=0,n=0;n>>1:r=r>>>1;e[t]=r}return e}();function v0e(e,t,r,n){for(var a=0;a>>8;return e}function E3(e,t,r){return v0e(4294967295,e,t,r)^4294967295}var vt=function(){var e=Uint16Array,t=Uint32Array;return{next_code:new e(16),bl_count:new e(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new e(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new t(32),flmap:new e(512),fltree:[],fdmap:new e(32),fdtree:[],lmap:new e(32768),ltree:[],ttree:[],dmap:new e(32768),dtree:[],imap:new e(512),itree:[],rev15:new e(32768),lhst:new t(286),dhst:new t(30),ihst:new t(19),lits:new t(15e3),strt:new e(65536),prev:new e(32768)}}();(function(){for(var e=32768,t=0;t>>1|(r&1431655765)<<1,r=(r&3435973836)>>>2|(r&858993459)<<2,r=(r&4042322160)>>>4|(r&252645135)<<4,r=(r&4278255360)>>>8|(r&16711935)<<8,vt.rev15[t]=(r>>>16|r<<16)>>>17}function n(a,i,o){for(;i--!==0;)a.push(0,o)}for(var t=0;t<32;t++)vt.ldef[t]=vt.of0[t]<<3|vt.exb[t],vt.ddef[t]=vt.df0[t]<<4|vt.dxb[t];n(vt.fltree,144,8),n(vt.fltree,255-143,9),n(vt.fltree,279-255,7),n(vt.fltree,287-279,8),_f(vt.fltree,9),C0(vt.fltree,9,vt.flmap),_0(vt.fltree,9),n(vt.fdtree,32,5),_f(vt.fdtree,5),C0(vt.fdtree,5,vt.fdmap),_0(vt.fdtree,5),n(vt.itree,19,0),n(vt.ltree,286,0),n(vt.dtree,30,0),n(vt.ttree,320,0)})();function C0(e,t,r){for(var n=e.length,a=vt.rev15,i=0;i>1,s=e[i+1],u=o<<4|s,c=t-s,l=e[i]<>>15-t;r[d]=u,l++}}function _f(e,t){for(var r=e.length,n=vt.bl_count,a=0;a<=t;a++)n[a]=0;for(var a=1;a>>n}}function g0e(e,t){var r=t===void 0;return t===void 0&&(t=new Uint8Array(e.length>>>2<<3)),{data:e,buf:t,noBuf:r,BFINAL:0,off:0,pos:0}}function y0e(e,t){for(var r=e.data,n=e.noBuf,a=e.buf,i=e.BFINAL,o=e.off,s=e.pos,u=0;i===0&&u>>3)+4,p=r[h-4]|r[h-3]<<8;n&&(a=I3(a,o+p)),a.set(new Uint8Array(r.buffer,r.byteOffset+h,p),o),s=h+p<<3,o+=p;continue}if(n&&(a=I3(a,o+(1<<17))),m===1)c=vt.flmap,l=vt.fdmap,f=512-1,d=32-1;else if(m===2){var v=km(r,s,5)+257,g=km(r,s+5,5)+1,b=km(r,s+10,4)+4;s+=14;for(var x=0;x<38;x+=2)vt.itree[x]=0,vt.itree[x+1]=0;for(var S=1,x=0;xS&&(S=_)}s+=3*b,_f(vt.itree,S),C0(vt.itree,S,vt.imap),c=vt.lmap,l=vt.dmap,s=b0e(vt.imap,(1<>>4;if(!(A>>>8))a[o++]=A;else{if(A===256)break;var E=o+A-254;if(A>264){var I=vt.ldef[A-257];E=o+(I>>>3)+km(r,s,I&7),s+=I&7}var R=l[R3(r,s)&d];s+=R&15;var B=R>>>4,O=vt.ddef[B],z=(O>>>4)+M3(r,s,O&15);for(s+=O&15,n&&(a=I3(a,o+(1<<17)));o>>4;if(u<=15)i[o]=u,o++;else{var c=0,l=0;u===16?(l=3+km(n,a,2),a+=2,c=i[o-1]):u===17?(l=3+km(n,a,3),a+=3):u===18&&(l=11+km(n,a,7),a+=7);for(var f=o+l;o>>1;ia&&(a=s),i++}for(;i>>3]|e[(t>>>3)+1]<<8)>>>(t&7)&(1<>>3]|e[(t>>>3)+1]<<8|e[(t>>>3)+2]<<16)>>>(t&7)&(1<>>3]|e[(t>>>3)+1]<<8|e[(t>>>3)+2]<<16)>>>(t&7)}function $2(e,t,r){for(var n=[],a=e.length,i=t.length,o=0;or&&(x0e(u,r,v),v=r);for(var o=0;ot;n++){var o=e[n].d;e[n].d=t,a+=i-(1<>>r-t;a>0;){var o=e[n].d;o=0;n--)e[n].d===t&&a<0&&(e[n].d--,a++);a!==0&&console.log("debt left")}function S0e(e,t,r,n){var a=vt.lits,i=vt.strt,o=vt.prev;return{data:e,out:t,opt:_0e[n],i:0,pos:r<<3,cvrd:0,dlen:e.length,li:0,lc:0,bs:0,ebits:0,c:0,nc:0,lits:a,strt:i,prev:o}}function C0e(e,t){for(var r=e.data,n=e.dlen,a=e.out,i=e.opt,o=e.i,s=e.pos,u=e.cvrd,c=e.li,l=e.lc,f=e.bs,d=e.ebits,m=e.c,h=e.nc,p=vt.lits,v=vt.strt,g=vt.prev,b=Math.min(o+t,n);o14e3||l>26697)&&n-o>100&&(u>>16,C=S&65535,D=G8(_,vt.of0);vt.lhst[257+D]++;var T=G8(C,vt.df0);vt.dhst[T]++,d+=vt.exb[D]+vt.dxb[T],p[c]=_<<23|o-u,p[c+1]=C<<16|D<<8|T,c+=2,u=o+_}else vt.lhst[r[o]]++;l++}}e.i=o,e.pos=s,e.cvrd=u,e.li=c,e.lc=l,e.bs=f,e.ebits=d,e.c=m,e.nc=h}var _0e=[[0,0,0,0,0],[4,4,8,4,0],[4,5,16,8,0],[4,6,16,16,0],[4,10,16,32,0],[8,16,32,32,0],[8,16,128,128,0],[8,32,128,256,0],[32,128,258,1024,1],[32,258,258,4096,1]];function z8(e,t,r,n,a){return $(this,void 0,void 0,function(){var i,o,s,u,c,l,f,d,m,h,p,v;return J(this,function(g){switch(g.label){case 0:if(i=S0e(t,r,n,a),o=i.dlen,a===0){for(s=i.i,u=i.pos;s>>3]}o>2&&(i.nc=O3(t,0),i.strt[i.nc]=0),g.label=1;case 1:return i.i>>3]}})})}function w0e(e,t,r,n,a,i){var o=t&32767,s=r[o],u=o-s+32768&32767;if(s===o||n!==O3(e,t-u))return 0;for(var c=0,l=0,f=Math.min(32767,t);u<=f&&--i!==0&&s!==o;){if(c===0||e[t+c]===e[t+c-u]){var d=T0e(e,t,u);if(d>c){if(c=d,l=u,c>=a)break;u+2m&&(m=g,s=p)}}}o=s,s=r[o],u+=o-s+32768&32767}return c<<16|l}function T0e(e,t,r){if(e[t]!==e[t-r]||e[t+1]!==e[t+1-r]||e[t+2]!==e[t+2-r])return 0;var n=t,a=Math.min(e.length,t+258);for(t+=3;t>>23,O=E+(R&(1<<23)-1);E>16,G=z>>8&255,V=z&255;u=U1(257+G,D,s,u),Zh(s,u,B-vt.of0[G]),u+=vt.exb[G],u=U1(V,T,s,u),J2(s,u,k-vt.df0[V]),u+=vt.dxb[V],E+=B}}u=U1(256,D,s,u)}return u}function j8(e,t,r,n,a){var i=a>>>3;return n[i]=r,n[i+1]=r>>>8,n[i+2]=255-n[i],n[i+3]=255-n[i+1],i+=4,n.set(new Uint8Array(e.buffer,t,r),i),a+(r+4<<3)}function A0e(){for(var e=$2(vt.lhst,vt.ltree,15),t=$2(vt.dhst,vt.dtree,15),r=[],n=V8(vt.ltree,r),a=[],i=V8(vt.dtree,a),o=0;o4&&vt.itree[(vt.ordr[u-1]<<1)+1]===0;)u--;return[e,t,s,n,i,u,r,a]}function N1(e,t){for(var r=0,n=0;n15&&(Zh(r,n,o),n+=s)}return n}function V8(e,t){for(var r=e.length;r!==2&&e[r-1]===0;)r-=2;for(var n=0;n>>1,138);c<11?t.push(17,c-3):t.push(18,c-11),n+=c*2-2}else if(a===s&&i===a&&o===a){for(var u=n+5;u+2>>1,6);t.push(16,c-3),n+=c*2-2}else t.push(a,0)}return r>>>1}function G8(e,t){var r=0;return t[r|16]<=e&&(r|=16),t[r|8]<=e&&(r|=8),t[r|4]<=e&&(r|=4),t[r|2]<=e&&(r|=2),t[r|1]<=e&&(r|=1),r}function U1(e,t,r,n){return J2(r,n,t[e<<1]),n+t[(e<<1)+1]}function Zh(e,t,r){r=r<<(t&7);var n=t>>>3;e[n]|=r,e[n+1]|=r>>>8}function J2(e,t,r){r=r<<(t&7);var n=t>>>3;e[n]|=r,e[n+1]|=r>>>8,e[n+2]|=r>>>16}function w0(e,t,r){return r===void 0&&(r=!1),$(this,void 0,void 0,function(){var n,a,i,o,s,u,c,l,f,d,m,h,p;return J(this,function(v){switch(v.label){case 0:for(n=Object.create(null),a=new Uint8Array(t),i=a.length-4;Lm(a,i)!==101010256;)i--;o=i,o+=4,o+=4,s=bd(a,o),o+=2,o+=2,o+=4,u=Lm(a,o),o+=4,o=u,c=0,v.label=1;case 1:return c=200&&e.status<400){var r=e.response;if(F3.deposit(e),(t==="binary"||t==="zip")&&r instanceof ArrayBuffer)return new Uint8Array(r);if(t==="string"&&typeof r=="string")return r;if(t==="xml"&&r instanceof XMLDocument)return r;if(t==="json"&&typeof r=="object")return r;throw new Error("could not get requested response data '".concat(t,"'"))}else throw F3.deposit(e),new Error("Download failed with status code ".concat(e.status))}function k0e(e){switch(e){case"json":return"json";case"xml":return"document";case"string":return"text";case"binary":return"arraybuffer";case"zip":return"arraybuffer"}}function Z8(e,t,r,n,a){var i=this;if(Kh&&t.startsWith("file://"))return U0e(e,t,r,n,a);var o=void 0;return Ce.create(e||"Download",function(s){return $(i,void 0,void 0,function(){var u,c,l,f,d,m,h;return J(this,function(p){switch(p.label){case 0:if(o=F3.get(),o.open(n?"post":"get",t,!0),a)for(u=0,c=a;u0?[4,Promise.race(o)]:[3,6];case 3:if(f=v.sent(),d=r[f.index],m=s.indexOf(f.index),l++,f.kind==="error"&&!d.canFail)throw new Error("".concat(d.url,": ").concat(f.error));return e.shouldUpdate?[4,e.update({message:"Downloading...",current:l,max:a})]:[3,5];case 4:v.sent(),v.label=5;case 5:return i[f.index]=f,o=o.filter($8,m),s=s.filter($8,m),u"u")return fe?re.defaultValue:void 0;if(!H(re.select,K.name))return re.defaultValue;var L=re.map(K.name);return{name:K.name,params:N(L,K.params,fe)}}else{if(re.type==="select")return H(re,te)?te:re.defaultValue;if(re.type==="multi-select"){if(!Array.isArray(te))return re.defaultValue;var ve=te.filter(function(Pe){return H(this,Pe)},re);return te.length>0&&ve.length===0?re.defaultValue:ve}else if(re.type==="object-list")return Array.isArray(te)?te.map(function(ge){return ee(re.element,ge,fe?"all":"skip")}):re.defaultValue}return te}function ee(re,te,fe){if(typeof te!="object"||te===null)return fe?k(re):te;for(var ve=Object.create(null),De=0,Ge=Object.keys(re);De0?te[0][0]:void 0}})(w||(w={}));var go;(function(e){function t(a){var i={create:function(o){return{action:i,params:o}},id:Er.create22(),definition:a,createDefaultParams:function(o,s){return a.params?w.getDefaultValues(a.params(o,s)):{}}};return i}e.create=t;function r(a){var i=a.definition;return t({from:i.from,display:i.display,params:i.params,isApplicable:a.definition.isApplicable?function(o,s,u){return a.definition.isApplicable(o,u)}:void 0,run:function(o){var s=o.cell,u=o.state,c=o.params,l=u.build().to(s.transform.ref).apply(a,c);return u.updateTree(l)}})}e.fromTransformer=r;var n;(function(a){function i(o){return function(s){return t(P({from:o.from instanceof Array?o.from:o.from?[o.from]:[],display:typeof o.display=="string"?{name:o.display}:o.display?o.display:{name:"Unnamed State Action"},params:typeof o.params=="object"?function(){return o.params}:o.params?o.params:void 0,isApplicable:o.isApplicable},typeof s=="function"?{run:s}:s))}}a.build=function(o){return i(o)}})(n=e.Builder||(e.Builder={})),e.build=n.build})(go||(go={}));var rt;(function(e){function t(p,v,g){return p.definition.params?p.definition.params(v,g):{}}e.getParamDefinition=t;function r(p){return!!p&&typeof p.toAction=="function"&&typeof p.apply=="function"}e.is=r;var n;(function(p){p[p.Unchanged=0]="Unchanged",p[p.Updated=1]="Updated",p[p.Recreate=2]="Recreate",p[p.Null=3]="Null"})(n=e.UpdateResult||(e.UpdateResult={}));var a=new Map,i=new Map;function o(p){for(var v=0,g=p.definition.from;v=0:!1}e.hasTag=f;function d(v,g){if(!v.tags)return typeof g!="string"&&g.length===0;if(typeof g=="string")return f(v,g);for(var b=0,x=g;bt&&(t=e[r]);return t}function Nm(e){for(var t=1/0,r=0,n=e.length;rr&&(r=e[n]);return[t,r]}function L3(e,t,r){t===void 0&&(t=1),r===void 0&&(r=0);for(var n=e.length,a=0,i=r;i=0?!1:(e.push(t),!0)}function Mc(e,t){var r=e.indexOf(t);if(r<0)return!1;for(var n=r,a=e.length-1;n=0})}e.withTag=v,s("subtree",g);function g(F){return l(F,function(j,Z){var Y=[];return ya.doPreOrder(Z.tree,Z.tree.transforms.get(j.transform.ref),Y,function(H,N,ee){ee.push(H.ref)}),Y.map(function(H){return Z.cells.get(H)})})}e.subtree=g,s("children",b);function b(F){return l(F,function(j,Z){var Y=[];return Z.tree.children.get(j.transform.ref).forEach(function(H){return Y.push(Z.cells.get(H))}),Y})}e.children=b,s("ofType",x);function x(F,j){return h(F,function(Z){return Z.obj?Z.obj.type===j.type:!1})}e.ofType=x,s("ancestor",S);function S(F,j){return d(f(F,function(Z,Y){return R(Y.tree,Y.cells,Z.transform.ref,j)}))}e.ancestor=S,s("ancestorOfType",_);function _(F,j){return d(f(F,function(Z,Y){return z(Y.tree,Y.cells,Z.transform.ref,j)}))}e.ancestorOfType=_,s("ancestorWithTransformer",C);function C(F,j){return d(f(F,function(Z,Y){return O(Y.tree,Y.cells,Z.transform.ref,j)}))}e.ancestorWithTransformer=C,s("withTransformer",D);function D(F,j){return h(F,function(Z){return Z.transform.transformer===j})}e.withTransformer=D,s("root",T);function T(F,j){return d(f(F,function(Z,Y){return B(Y.tree,Y.cells,Z.transform.ref,j)}))}e.root=T,s("rootOfType",A);function A(F,j){return d(f(F,function(Z,Y){return k(Y.tree,Y.cells,Z.transform.ref,j)}))}e.rootOfType=A,s("parent",E);function E(F){return d(f(F,function(j,Z){return Z.cells.get(Z.tree.transforms.get(j.transform.ref).parent)}))}e.parent=E;function I(F,j,Z,Y,H){for(var N=F.transforms.get(Z),ee=void 0;;){N=F.transforms.get(N.parent);var oe=j.get(N.ref);if(oe.obj&&Y(oe)&&(ee=oe,H)||N.ref===Ir.RootRef)return ee}}function R(F,j,Z,Y){return I(F,j,Z,Y,!0)}e.findAncestor=R;function B(F,j,Z,Y){return I(F,j,Z,Y,!1)}e.findRoot=B;function O(F,j,Z,Y){return R(F,j,Z,Array.isArray(Y)?function(H){return Y.indexOf(H.transform.transformer)>=0}:function(H){return H.transform.transformer===Y})}e.findAncestorWithTransformer=O;function z(F,j,Z,Y){return R(F,j,Z,G(Y))}e.findAncestorOfType=z;function k(F,j,Z,Y){return B(F,j,Z,G(Y))}e.findRootOfType=k;function G(F){return Array.isArray(F)?function(j){for(var Z=0,Y=F;Z=0?(Z.ref=F.ref,!1):!0}function X(F,j,Z){return ya.doPreOrder(F,F.transforms.get(j),{refs:[],tags:Z},ae).refs}e.findWithAllTags=X;function ae(F,j,Z){if(F.tags)for(var Y=Z.tags.size,H=0,N=0,ee=F.tags;N1?t-1:0),n=1;n3?t.i-4:t.i:Array.isArray(e)?1:Y3(e)?2:X3(e)?3:0}function z3(e,t){return D0(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function q0e(e,t){return D0(e)===2?e.get(t):e[t]}function pG(e,t,r){var n=D0(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function W0e(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function Y3(e){return Z0e&&e instanceof Map}function X3(e){return Q0e&&e instanceof Set}function Qh(e){return e.o||e.t}function K3(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=J0e(e);delete t[nc];for(var r=J3(t),n=0;n1&&(e.set=e.add=e.clear=e.delete=Y0e),Object.freeze(e),t&&H1(e,function(r,n){return Z3(n,!0)},!0)),e}function Y0e(){Ml(2)}function Q3(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function wf(e){var t=eye[e];return t||Ml(18,e),t}function oG(){return j1}function N3(e,t){t&&(wf("Patches"),e.u=[],e.s=[],e.v=t)}function r_(e){H3(e),e.p.forEach(X0e),e.p=null}function H3(e){e===j1&&(j1=e.l)}function sG(e){return j1={p:[],l:j1,h:e,m:!0,_:0}}function X0e(e){var t=e[nc];t.i===0||t.i===1?t.j():t.g=!0}function U3(e,t){t._=t.p.length;var r=t.p[0],n=e!==void 0&&e!==r;return t.h.O||wf("ES5").S(t,e,n),n?(r[nc].P&&(r_(t),Ml(4)),$h(e)&&(e=n_(t,e),t.l||a_(t,e)),t.u&&wf("Patches").M(r[nc].t,e,t.u,t.s)):e=n_(t,r,[]),r_(t),t.u&&t.v(t.u,t.s),e!==hG?e:void 0}function n_(e,t,r){if(Q3(t))return t;var n=t[nc];if(!n)return H1(t,function(s,u){return uG(e,n,t,s,u,r)},!0),t;if(n.A!==e)return t;if(!n.P)return a_(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var a=n.i===4||n.i===5?n.o=K3(n.k):n.o,i=a,o=!1;n.i===3&&(i=new Set(a),a.clear(),o=!0),H1(i,function(s,u){return uG(e,n,a,s,u,r,o)}),a_(e,a,!1),r&&e.u&&wf("Patches").N(n,r,e.u,e.s)}return n.o}function uG(e,t,r,n,a,i,o){if(A0(a)){var s=n_(e,a,i&&t&&t.i!==3&&!z3(t.R,n)?i.concat(n):void 0);if(pG(r,n,s),!A0(s))return;e.m=!1}else o&&r.add(a);if($h(a)&&!Q3(a)){if(!e.h.D&&e._<1)return;n_(e,a),t&&t.A.l||a_(e,a)}}function a_(e,t,r){r===void 0&&(r=!1),!e.l&&e.h.D&&e.m&&Z3(t,r)}function V3(e,t){var r=e[nc];return(r?Qh(r):e)[t]}function cG(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function j3(e){e.P||(e.P=!0,e.l&&j3(e.l))}function G3(e){e.o||(e.o=K3(e.t))}function q3(e,t,r){var n=Y3(t)?wf("MapSet").F(t,r):X3(t)?wf("MapSet").T(t,r):e.O?function(a,i){var o=Array.isArray(a),s={i:o?1:0,A:i?i.A:oG(),P:!1,I:!1,R:{},l:i,t:a,k:null,o:null,j:null,C:!1},u=s,c=W3;o&&(u=[s],c=z1);var l=Proxy.revocable(u,c),f=l.revoke,d=l.proxy;return s.k=d,s.j=f,d}(t,r):wf("ES5").J(t,r);return(r?r.A:oG()).p.push(n),n}function K0e(e){return A0(e)||Ml(22,e),function t(r){if(!$h(r))return r;var n,a=r[nc],i=D0(r);if(a){if(!a.P&&(a.i<4||!wf("ES5").K(a)))return a.t;a.I=!0,n=lG(r,i),a.I=!1}else n=lG(r,i);return H1(n,function(o,s){a&&q0e(a.t,o)===s||pG(n,o,t(s))}),i===3?new Set(n):n}(e)}function lG(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return K3(e)}var fG,j1,$3=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",Z0e=typeof Map<"u",Q0e=typeof Set<"u",dG=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",hG=$3?Symbol.for("immer-nothing"):((fG={})["immer-nothing"]=!0,fG),mG=$3?Symbol.for("immer-draftable"):"__$immer_draftable",nc=$3?Symbol.for("immer-state"):"__$immer_state";var $0e=""+Object.prototype.constructor,J3=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,J0e=Object.getOwnPropertyDescriptors||function(e){var t={};return J3(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},eye={},W3={get:function(e,t){if(t===nc)return e;var r=Qh(e);if(!z3(r,t))return function(a,i,o){var s,u=cG(i,o);return u?"value"in u?u.value:(s=u.get)===null||s===void 0?void 0:s.call(a.k):void 0}(e,r,t);var n=r[t];return e.I||!$h(n)?n:n===V3(e.t,t)?(G3(e),e.o[t]=q3(e.A.h,n,e)):n},has:function(e,t){return t in Qh(e)},ownKeys:function(e){return Reflect.ownKeys(Qh(e))},set:function(e,t,r){var n=cG(Qh(e),t);if(n?.set)return n.set.call(e.k,r),!0;if(!e.P){var a=V3(Qh(e),t),i=a?.[nc];if(i&&i.t===r)return e.o[t]=r,e.R[t]=!1,!0;if(W0e(r,a)&&(r!==void 0||z3(e.t,t)))return!0;G3(e),j3(e)}return e.o[t]===r&&(r!==void 0||t in e.o)||Number.isNaN(r)&&Number.isNaN(e.o[t])||(e.o[t]=r,e.R[t]=!0),!0},deleteProperty:function(e,t){return V3(e.t,t)!==void 0||t in e.t?(e.R[t]=!1,G3(e),j3(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=Qh(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.i!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty:function(){Ml(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){Ml(12)}},z1={};H1(W3,function(e,t){z1[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),z1.deleteProperty=function(e,t){return z1.set.call(this,e,t,void 0)},z1.set=function(e,t,r){return W3.set.call(this,e[0],t,r,e[0])};var tye=function(){function e(r){var n=this;this.O=dG,this.D=!0,this.produce=function(a,i,o){if(typeof a=="function"&&typeof i!="function"){var s=i;i=a;var u=n;return function(p){var v=this;p===void 0&&(p=s);for(var g=arguments.length,b=Array(g>1?g-1:0),x=1;x1?l-1:0),d=1;d=0;a--){var i=n[a];if(i.path.length===0&&i.op==="replace"){r=i.value;break}}a>-1&&(n=n.slice(a+1));var o=wf("Patches").$;return A0(r)?o(r,n):this.produce(r,function(s){return o(s,n)})},e}(),ac=new tye,zm=ac.produce,GQe=ac.produceWithPatches.bind(ac),vG=ac.setAutoFreeze.bind(ac),zQe=ac.setUseProxies.bind(ac),HQe=ac.applyPatches.bind(ac),jQe=ac.createDraft.bind(ac),qQe=ac.finishDraft.bind(ac),P0=zm;var Hm;(function(e){function t(o){if(!o.state||o.state.tree===o.editInfo.sourceTree)return o.tree.asImmutable();for(var s=o.state.tree.asTransient(),u=0,c=o.actions;u0&&this.signal.next({v:this.queue[0],stillPresent:!0})},e.prototype.remove=function(t){var r=xd(this.queue,t);return r&&this.signal.next({v:t,stillPresent:!1}),r},e.prototype.waitFor=function(t){var r=this;return new Promise(function(n){var a=r.signal.subscribe(function(i){var o=i.v,s=i.stillPresent;o===t&&(a.unsubscribe(),n(s))})})},e}();var rye=function(){function e(t,r){this.getHash=t,this.areEqual=r,this.size=0,this.byHash=new Map}return e.prototype.add=function(t){var r=this.getHash(t);if(this.byHash.has(r)){for(var n=this.byHash.get(r),a=0,i=n.length;athis.historyCapacity&&this.history.pop(),this.events.historyUpdated.next({state:this}))},e.prototype.clearHistory=function(){this.history.length!==0&&(this.history=[],this.events.historyUpdated.next({state:this}))},Object.defineProperty(e.prototype,"latestUndoLabel",{get:function(){return this.history.length>0?this.history[0][1]:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canUndo",{get:function(){return this.history.length>0},enumerable:!1,configurable:!0}),e.prototype.undo=function(){var t=this;return Ce.create("Undo",function(r){return $(t,void 0,void 0,function(){var n;return J(this,function(a){switch(a.label){case 0:if(n=this.history.shift(),!n)return[2];this.events.historyUpdated.next({state:this}),this.undoingHistory=!0,a.label=1;case 1:return a.trys.push([1,,3,4]),[4,this.updateTree(n[0],{canUndo:!1}).runInContext(r)];case 2:return a.sent(),[3,4];case 3:return this.undoingHistory=!1,[7];case 4:return[2]}})})})},e.prototype.getSnapshot=function(){return{tree:ya.toJSON(this._tree)}},e.prototype.setSnapshot=function(t){var r=ya.fromJSON(t.tree);return this.updateTree(r)},e.prototype.setCurrent=function(t){this.behaviors.currentObject.next({state:this,ref:t})},e.prototype.updateCellState=function(t,r){var n=this.cells.get(t);if(n){var a=typeof r=="function"?r(n.state):r;Ir.assignState(n.state,a)&&(n.transform=this._tree.assignState(n.transform.ref,a),this.events.cell.stateUpdated.next({state:this,ref:t,cell:n}))}},e.prototype.dispose=function(){this.ev.dispose(),this.actions.dispose()},e.prototype.select=function(t){return Yt.select(t,this)},e.prototype.selectQ=function(t){return typeof t=="string"?Yt.select(t,this):Yt.select(t(Yt.Generators),this)},e.prototype.applyAction=function(t,r,n){var a=this;return n===void 0&&(n=Ir.RootRef),Ce.create("Apply Action",function(i){var o=a.cells.get(n);if(!o)throw new Error("'".concat(n,"' does not exist."));if(o.status!=="ok")throw new Error("Action cannot be applied to a cell with status '".concat(o.status,"'"));return rM(t.definition.run({ref:n,cell:o,a:o.obj,params:r,state:a},a.globalContext),i)})},e.prototype.transaction=function(t,r){var n=this;return Ce.create("State Transaction",function(a){return $(n,void 0,void 0,function(){var i,o,s,u;return J(this,function(c){switch(c.label){case 0:i=this.inTransaction,o=this._tree.asImmutable(),s=!1,c.label=1;case 1:return c.trys.push([1,5,8,9]),i||this.behaviors.isUpdating.next(!0),this.inTransaction=!0,this.inTransactionError=!1,[4,t(a)];case 2:return c.sent(),this.inTransactionError?(s=!0,[4,this.updateTree(o).runInContext(a)]):[3,4];case 3:c.sent(),c.label=4;case 4:return[3,9];case 5:return u=c.sent(),s?[3,7]:(s=!0,[4,this.updateTree(o).runInContext(a)]);case 6:c.sent(),this.events.log.next(Rc.error("Error during state transaction, reverting")),c.label=7;case 7:if(i)throw this.inTransactionError=!0,u;if(r?.rethrowErrors)throw u;return console.error(u),[3,9];case 8:return i||(this.inTransaction=!1,this.events.changed.next({state:this,inTransaction:!1}),this.behaviors.isUpdating.next(!1),s||(r?.canUndo?this.addHistory(o,typeof r.canUndo=="string"?r.canUndo:void 0):this.clearHistory())),[7];case 9:return[2]}})})})},Object.defineProperty(e.prototype,"inUpdate",{get:function(){return this._inUpdate},enumerable:!1,configurable:!0}),e.prototype.updateTree=function(t,r){var n=this,a={tree:t,options:r};return Ce.create("Update Tree",function(i){return $(n,void 0,void 0,function(){var o,s,u,c,l;return J(this,function(f){switch(f.label){case 0:return[4,this.updateQueue.enqueue(a)];case 1:if(o=f.sent(),!o)return[2];this._inUpdate=!0,s=r?.canUndo?this._tree.asImmutable():void 0,u=!1,this.inTransaction||this.behaviors.isUpdating.next(!0),f.label=2;case 2:if(f.trys.push([2,,7,8]),Hm.is(t)){if(t.editInfo.applied)throw new Error("This builder has already been applied. Create a new builder for further state updates");t.editInfo.applied=!0}return this.reverted=!1,r&&(r.revertIfAborted||r.revertOnError)?[4,this._revertibleTreeUpdate(i,a,r)]:[3,4];case 3:return l=f.sent(),[3,6];case 4:return[4,this._updateTree(i,a)];case 5:l=f.sent(),f.label=6;case 6:return c=l,u=this.reverted,c.ctx.hadError&&(this.inTransactionError=!0),c.cell?[2,new x2(c.cell.transform.ref,this)]:[2];case 7:return this._inUpdate=!1,this.updateQueue.handled(a),this.inTransaction||(this.behaviors.isUpdating.next(!1),r?.canUndo?u||this.addHistory(s,typeof r.canUndo=="string"?r.canUndo:void 0):this.undoingHistory||this.clearHistory()),[7];case 8:return[2]}})})},function(){n.updateQueue.remove(a)})},e.prototype._revertibleTreeUpdate=function(t,r,n){return $(this,void 0,void 0,function(){var a,i,o;return J(this,function(s){switch(s.label){case 0:return a=this.tree,[4,this._updateTree(t,r)];case 1:return i=s.sent(),o=(i.ctx.hadError||i.ctx.wasAborted)&&n.revertOnError||i.ctx.wasAborted&&n.revertIfAborted,o?(this.reverted=!0,[4,this._updateTree(t,{tree:a,options:r.options})]):[3,3];case 2:return[2,s.sent()];case 3:return[2,i]}})})},e.prototype._updateTree=function(t,r){return $(this,void 0,void 0,function(){var n,a,i;return J(this,function(o){switch(o.label){case 0:n=!1,a=this.updateTreeAndCreateCtx(r.tree,t,r.options),o.label=1;case 1:return o.trys.push([1,,3,4]),[4,oye(a)];case 2:return n=o.sent(),Hm.isTo(r.tree)?(i=this.select(r.tree.ref)[0],[2,{ctx:a,cell:i}]):[2,{ctx:a}];case 3:return this.spine.current=void 0,n&&this.events.changed.next({state:this,inTransaction:this.inTransaction}),[7];case 4:return[2]}})})},e.prototype.updateTreeAndCreateCtx=function(t,r,n){var a=(Hm.is(t)?t.getTree():t).asTransient(),i=this._tree;this._tree=a;var o=this.cells,s={parent:this,editInfo:Hm.is(t)?t.editInfo:void 0,errorFree:this.errorFree,taskCtx:r,oldTree:i,tree:a,cells:this.cells,spine:this.spine,results:[],options:P(P({},iye),n),changed:!1,hadError:!1,wasAborted:!1,newCurrent:void 0,getCellData:function(u){var c;return(c=o.get(u).obj)===null||c===void 0?void 0:c.data}};return this.errorFree=!0,s},e}();(function(e){function t(n,a){return new e(n,a)}e.create=t;var r;(function(n){function a(i,o){return!!o&&i.ref===o.transform.ref&&i.state===o.parent}n.isCell=a})(r=e.ObjectEvent||(e.ObjectEvent={}))})(W1||(W1={}));var iye={doNotLogTiming:!1,doNotUpdateCurrent:!0,revertIfAborted:!1,revertOnError:!1,canUndo:!1};function oye(e){return $(this,void 0,void 0,function(){var t,r,n,a,B,i,o,s,v,u,p,S,c,l,v,S,f,d,m,h,S,p,v,g,b,x,S,_,C,D,T,A,E,I,R,B,O;return J(this,function(z){switch(z.label){case 0:if(t=!!(e.editInfo&&e.editInfo.count===1&&e.editInfo.lastUpdate&&e.editInfo.sourceTree===e.oldTree),n=[],t)r=[],a=[e.editInfo.lastUpdate];else{for(r=lye(e),B=e.parent.current,i=!1,o=0,s=r;o=0;p--)S=e.cells.get(r[p]),S&&i_(S.transform,S.obj,S?.transform.params,S.cache,e.parent.globalContext);for(c=0,l=r;c0||a.length>0||e.changed]}})})}function sye(e,t){var r={roots:[],cells:e};return ya.doPreOrder(t,t.root,r,uye),r.roots}function uye(e,t,r){var n=r.cells.get(e.ref);return!n||n.transform.version!==e.version?(r.roots.push(e.ref),!1):!(n.status==="error"||n&&n.obj===gn.Null)}function cye(e,t,r){!r.newTree.transforms.has(e.ref)&&r.cells.has(e.ref)&&r.deletes.push(e.ref)}function lye(e){var t={newTree:e.tree,cells:e.cells,deletes:[]};return ya.doPostOrder(e.oldTree,e.oldTree.root,t,cye),t.deletes}function fye(e,t,r){var n=r.cells.get(e.ref);!n||!Ir.syncState(n.state,e.state)||r.parent.events.cell.stateUpdated.next({state:r.parent,ref:e.ref,cell:n})}function dye(e){ya.doPreOrder(e.tree,e.tree.root,e,fye)}function o_(e,t,r,n){var a=e.cells.get(t),i=a.status!==r;a.status=r,a.errorText=n,i&&e.parent.events.cell.stateUpdated.next({state:e.parent,ref:t,cell:a})}function mye(e,t,r){r.cells.get(e.ref).transform=e,o_(r,e.ref,"pending")}function pye(e,t){for(var r=0,n=t;rTM,DownloadBlob:()=>AM,ImportJson:()=>H1e,ImportString:()=>z1e,LazyVolume:()=>q1e,ParseBlob:()=>R1e,ParseCcp4:()=>U1e,ParseCif:()=>B1e,ParseCube:()=>O1e,ParseDsn6:()=>V1e,ParseDx:()=>G1e,ParseJson:()=>j1e,ParsePly:()=>N1e,ParsePrmtop:()=>L1e,ParsePsf:()=>F1e,ParseTop:()=>k1e,RawData:()=>DM,ReadFile:()=>PM});var wr;(function(e){function t(i,o){return o===void 0&&(o=-1),new n(i,o)}e.error=t;function r(i,o){return o===void 0&&(o=[]),new a(i,o)}e.success=r;var n=function(){function i(o,s){this.message=o,this.line=s,this.isError=!0}return i.prototype.toString=function(){return this.line>=0?"[Line ".concat(this.line,"] ").concat(this.message):this.message},i}();e.Error=n;var a=function(){function i(o,s){this.result=o,this.warnings=s,this.isError=!1}return i}();e.Success=a})(wr||(wr={}));var Ys;(function(e){function t(s){var u=new DataView(s.buffer);return Object.assign(s.subarray(0),{readInt8:function(c){return u.getInt8(c)},readUInt8:function(c){return u.getUint8(c)},writeInt8:function(c,l){return u.setInt8(l,c)},writeUInt8:function(c,l){return u.setUint8(l,c)},readInt16LE:function(c){return u.getInt16(c,!0)},readInt32LE:function(c){return u.getInt32(c,!0)},readUInt16LE:function(c){return u.getUint16(c,!0)},readUInt32LE:function(c){return u.getUint32(c,!0)},readFloatLE:function(c){return u.getFloat32(c,!0)},readDoubleLE:function(c){return u.getFloat64(c,!0)},writeInt16LE:function(c,l){return u.setInt16(l,c,!0)},writeInt32LE:function(c,l){return u.setInt32(l,c,!0)},writeUInt16LE:function(c,l){return u.setUint16(l,c,!0)},writeUInt32LE:function(c,l){return u.setUint32(l,c,!0)},writeFloatLE:function(c,l){return u.setFloat32(l,c,!0)},writeDoubleLE:function(c,l){return u.setFloat64(l,c,!0)},readInt16BE:function(c){return u.getInt16(c,!1)},readInt32BE:function(c){return u.getInt32(c,!1)},readUInt16BE:function(c){return u.getUint16(c,!1)},readUInt32BE:function(c){return u.getUint32(c,!1)},readFloatBE:function(c){return u.getFloat32(c,!1)},readDoubleBE:function(c){return u.getFloat64(c,!1)},writeInt16BE:function(c,l){return u.setInt16(l,c,!1)},writeInt32BE:function(c,l){return u.setInt32(l,c,!1)},writeUInt16BE:function(c,l){return u.setUint16(l,c,!1)},writeUInt32BE:function(c,l){return u.setUint32(l,c,!1)},writeFloatBE:function(c,l){return u.setFloat32(l,c,!1)},writeDoubleBE:function(c,l){return u.setFloat64(l,c,!1)},copy:function(c,l,f,d){return l=ri(l,0),f=ri(f,0),d=ri(d,s.length),c.set(s.subarray(f,d),l),d-f}})}e.fromUint8Array=t;function r(s){return t(new Uint8Array(s))}e.fromArrayBuffer=r;function n(s){return s}e.fromBuffer=n,e.IsNativeEndianLittle=new Uint16Array(new Uint8Array([18,52]).buffer)[0]===13330;function a(s,u,c,l,f){for(var d=0,m=c;d>8&255}}e.flipByteOrderInPlace2=i;function o(s,u,c,l,f){e.IsNativeEndianLittle||!c||l<=1||a(s,u,c,l,f)}e.ensureLittleEndian=o})(Ys||(Ys={}));var M0;(function(e){function t(r,n){return{name:n,readBuffer:function(a,i,o,s){var u,c;if(typeof i=="number"){o=ri(o,i);var l=a,f=Math.min(r.length,l+o);u=f-l,c=Ys.fromUint8Array(new Uint8Array(r.buffer,l,f-l))}else{o=ri(o,i.length);var l=a,f=Math.min(r.length,l+o);i.set(r.subarray(l,f),s),u=f-l,c=i}return o!==u&&console.warn("byteCount ".concat(o," and bytesRead ").concat(u," differ")),Promise.resolve({bytesRead:u,buffer:c})},writeBuffer:function(a,i,o){return o=ri(o,i.length),console.error(".writeBuffer not implemented for FileHandle.fromBuffer"),Promise.resolve(0)},writeBufferSync:function(a,i,o){return o=ri(o,i.length),console.error(".writeSync not implemented for FileHandle.fromBuffer"),0},close:fd}}e.fromBuffer=t})(M0||(M0={}));var ko=function(e){return e.Float32="float32",e.Int8="int8",e.Int16="int16",e.Uint16="uint16",e}(ko||{});function nM(e){return e===ko.Float32?4:e===ko.Int16||e===ko.Uint16?2:1}function _ye(e,t,r,n){return r===void 0&&(r=0),e===ko.Float32?new Float32Array(t,r,n):e===ko.Int16?new Int16Array(t,r,n):e===ko.Uint16?new Uint16Array(t,r,n):new Int8Array(t,r,n)}function AG(e,t){var r=nM(t),n=new ArrayBuffer(r*e),a=Ys.fromArrayBuffer(n),i=Ys.IsNativeEndianLittle?n:new ArrayBuffer(r*e);return{type:t,elementByteSize:r,readBuffer:a,valuesBuffer:new Uint8Array(i),values:_ye(t,i)}}function DG(e,t,r,n,a,i){return $(this,void 0,void 0,function(){return J(this,function(o){switch(o.label){case 0:return[4,t.readBuffer(r,e.readBuffer,n,a)];case 1:return o.sent(),e.elementByteSize>1&&(i!==void 0&&i!==Ys.IsNativeEndianLittle||!Ys.IsNativeEndianLittle)&&Ys.flipByteOrder(e.readBuffer,e.valuesBuffer,n,e.elementByteSize,a),[2,e.values]}})})}function wye(e){return $(this,void 0,void 0,function(){var t,r,n,a,i,o,s,u,c;return J(this,function(l){switch(l.label){case 0:return t=1024,[4,e.readBuffer(0,t)];case 1:if(r=l.sent().buffer,n=String.fromCharCode(r.readUInt8(52*4),r.readUInt8(52*4+1),r.readUInt8(52*4+2),r.readUInt8(52*4+3)),n!=="MAP ")throw new Error('ccp4 format error, missing "MAP " string');return a=[r.readUInt8(53*4),r.readUInt8(53*4+1)],i=!1,a[0]===68&&a[1]===65?i=!0:a[0]===17&&a[1]===17?i=!1:(o=r.readInt32LE(3*4),o<=16&&(i=!0)),s=i?function(f){return r.readInt32LE(f*4)}:function(f){return r.readInt32BE(f*4)},u=i?function(f){return r.readFloatLE(f*4)}:function(f){return r.readFloatBE(f*4)},c={NC:s(0),NR:s(1),NS:s(2),MODE:s(3),NCSTART:s(4),NRSTART:s(5),NSSTART:s(6),NX:s(7),NY:s(8),NZ:s(9),xLength:u(10),yLength:u(11),zLength:u(12),alpha:u(13),beta:u(14),gamma:u(15),MAPC:s(16),MAPR:s(17),MAPS:s(18),AMIN:u(19),AMAX:u(20),AMEAN:u(21),ISPG:s(22),NSYMBT:s(23),LSKFLG:s(24),SKWMAT:[],SKWTRN:[],userFlag1:s(39),userFlag2:s(40),originX:u(49),originY:u(50),originZ:u(51),MAP:n,MACHST:a,ARMS:u(54)},[2,{header:c,littleEndian:i}]}})})}function Tye(e,t,r,n,a,i){return $(this,void 0,void 0,function(){var o,s,u,c,l,f;return J(this,function(d){switch(d.label){case 0:return EG(e)?(o=3*a,[4,r.readBuffer(n,t.readBuffer,a,o)]):[3,2];case 1:for(d.sent(),s=new Int8Array(t.valuesBuffer.buffer,o),u=(e.AMAX-e.AMIN)/255,c=.5*(e.AMIN+e.AMAX+u),l=0,f=a;l0?i[o[0]].rowCount:0,name:a,fieldNames:o,getField:function(s){return i[s]}}}e.ofFields=r;function n(a,i){for(var o={},s=0,u=i._columns;s1)return 0;if(p===0)return 1;var v=h.charCodeAt(0);return v===46?1:v===63?2:0};return{__array:void 0,binaryEncoding:void 0,isDefined:!0,rowCount:u,str:c,int:l,float:f,valueKind:d,areValuesEqual:function(m,h){return s[m]===s[h]},toStringArray:function(m){return m?Aa.createAndFillArray(u,c,m):s},toIntArray:function(m){return Aa.createAndFillArray(u,l,m)},toFloatArray:function(m){return Aa.createAndFillArray(u,f,m)}}}e.ofStrings=r;function n(s){var u=s.length,c=function(m){return""+s[m]},l=function(m){return s[m]},f=function(m){return 0},d=function(m){return!m||m.array&&s instanceof m.array?s:Aa.createAndFillArray(u,l,m)};return{__array:void 0,binaryEncoding:void 0,isDefined:!0,rowCount:u,str:c,int:l,float:l,valueKind:f,areValuesEqual:function(m,h){return s[m]===s[h]},toStringArray:function(m){return Aa.createAndFillArray(u,c,m)},toIntArray:d,toFloatArray:d}}e.ofNumbers=n;function a(s){var u=s.data,c=s.indices,l=s.count,f=function(p){var v=u.substring(c[2*p],c[2*p+1]);return v==="."||v==="?"?"":v},d=function(p){return Ec(u,c[2*p],c[2*p+1])||0},m=function(p){return Ws(u,c[2*p],c[2*p+1])||0},h=function(p){var v=c[2*p],g=c[2*p+1]-v;if(g>1)return 0;if(g===0)return 1;var b=u.charCodeAt(v);return b===46?1:b===63?2:0};return{__array:void 0,binaryEncoding:void 0,isDefined:!0,rowCount:l,str:f,int:d,float:m,valueKind:h,areValuesEqual:iM(s),toStringArray:function(p){return Aa.createAndFillArray(l,f,p)},toIntArray:function(p){return Aa.createAndFillArray(l,d,p)},toFloatArray:function(p){return Aa.createAndFillArray(l,m,p)}}}e.ofTokens=a;function i(s){var u=s.rowCount,c=s.valueKind,l=s.areValuesEqual,f=s.isDefined,d,m,h;switch(s.schema.valueType){case"float":case"int":d=function(v){return""+s.value(v)},m=s.value,h=s.value;break;case"str":d=s.value,m=function(v){var g=s.value(v);return Ec(g,0,g.length)||0},h=function(v){var g=s.value(v);return Ws(g,0,g.length)||0};break;case"list":var p=s.schema.separator;d=function(v){return s.value(v).join(p)},m=function(v){return NaN},h=function(v){return NaN};break;default:throw new Error("unsupported valueType '".concat(s.schema.valueType,"'"))}return{__array:void 0,binaryEncoding:void 0,isDefined:f,rowCount:u,str:d,int:m,float:h,valueKind:c,areValuesEqual:l,toStringArray:function(v){return Aa.createAndFillArray(u,d,v)},toIntArray:function(v){return Aa.createAndFillArray(u,m,v)},toFloatArray:function(v){return Aa.createAndFillArray(u,h,v)}}}e.ofColumn=i;function o(s,u){return i(ne.Undefined(s,u))}e.ofUndefined=o})(dt||(dt={}));function BG(e,t,r,n){var a=r?0:1;switch(t){case 1:return n==="brackets"?function(i){return"".concat(e,"[").concat(i+a,"]")}:function(i){return"".concat(e,"_").concat(i+a)};case 2:return n==="brackets"?function(i,o){return"".concat(e,"[").concat(i+a,"][").concat(o+a,"]")}:function(i,o){return"".concat(e,"_").concat(i+a).concat(o+a)};case 3:return n==="brackets"?function(i,o,s){return"".concat(e,"[").concat(i+a,"][").concat(o+a,"][").concat(s+a,"]")}:function(i,o,s){return"".concat(e,"_").concat(i+a).concat(o+a).concat(s+a)};default:throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.")}}function OG(e,t,r,n){var a=t.create();if(t.rank===1)for(var i=t.dimensions[0],o=0;o 3 or rank 0 are currently not supported.");return a}function at(e){return{data:e,position:0,length:e.length,lineNumber:1,tokenStart:0,tokenEnd:0}}(function(e){function t(b){return b.data.substring(b.tokenStart,b.tokenEnd)}e.getTokenString=t;function r(b){b.position=0,b.lineNumber=1,b.tokenStart=0,b.tokenEnd=0}e.reset=r;function n(b){for(var x=b.data;b.position=C;)T=_.charCodeAt(--D);return b.tokenStart=C,b.tokenEnd=D+1,b.position=S,b}e.trim=g})(at||(at={}));function FG(e,t,r){for(var n=t,a=r-1,i=e.charCodeAt(n);(i===9||i===32)&&n<=a;)i=e.charCodeAt(++n);for(i=e.charCodeAt(a);(i===9||i===32)&&a>=n;)i=e.charCodeAt(--a);return e.substring(n,a+1)}var We;(function(e){function t(o){var s=new Uint32Array(1.61*o.indices.length|0);s.set(o.indices),o.indices=s,o.indicesLenMinus2=s.length-2|0}function r(o,s,u){var c=o;c.offset>c.indicesLenMinus2&&t(c),c.indices[c.offset++]=s,c.indices[c.offset++]=u,o.count++}e.add=r;function n(o,s){r(o,s.tokenStart,s.tokenEnd)}e.addToken=n;function a(o,s,u){o.indices[o.offset++]=s,o.indices[o.offset++]=u,o.count++}e.addUnchecked=a;function i(o,s){return s=Math.max(10,s),{data:o,indicesLenMinus2:s-2|0,count:0,offset:0,indices:new Uint32Array(s)}}e.create=i})(We||(We={}));function LG(e){for(;e.position=e.length){e.tokenType=6;return}e.tokenStart=e.position,e.tokenEnd=e.position,e.isEscaped=!1;var r=e.data.charCodeAt(e.position);switch(r){case 35:Oye(e),e.tokenType=5;break;case 39:if(UG(e)){Mye(e),e.tokenType=3;break}case 34:Iye(e,r),e.tokenType=3;break;case 59:t===10||t===13?Rye(e):LG(e),e.tokenType=3;break;default:e.isImportGet?Bye(e):LG(e),e.isEscaped?e.tokenType=3:e.data.charCodeAt(e.tokenStart)===95?(e.inSaveFrame&&Uye(e)&&(e.isImportGet=!0),e.tokenType=4):e.tokenEnd-e.tokenStart>=5&&e.data.charCodeAt(e.tokenStart+4)===95?Lye(e)?e.tokenType=0:kye(e)?e.tokenType=1:Nye(e)?e.tokenType=2:e.tokenType=3:e.tokenType=3;break}}function jm(e){for(kG(e);e.tokenType===5;)kG(e)}function zye(e,t){return{data:e,length:e.length,position:0,tokenStart:0,tokenEnd:0,tokenType:6,lineNumber:1,isEscaped:!1,isImportGet:!1,inSaveFrame:!1,runtimeCtx:t}}function c_(){return{categoryNames:[],categoryData:Object.create(null)}}function cM(e,t){for(var r=Object.create(null),n=0,a=e;n0&&r.push(NG(i,a,o)),a=e.substring(n.tokenStart+5,n.tokenEnd),i=c_(),o=[],jm(n),[3,6]));case 2:if(l!==1)return[3,3];if(n.tokenEnd-n.tokenStart===5)s.categoryNames.length>0&&(o[o.length]=Hye(s,c)),n.inSaveFrame=!1;else{if(n.inSaveFrame)return[2,R0(n.lineNumber,"Save frames cannot be nested.")];n.inSaveFrame=!0,c=e.substring(n.tokenStart+5,n.tokenEnd),s=c_()}return jm(n),[3,6];case 3:return l!==2?[3,5]:[4,Yye(n,n.inSaveFrame?s:i)];case 4:return f=d.sent(),f.hasError?[2,R0(f.errorLine,f.errorMessage)]:[3,6];case 5:if(l===4){if(f=jye(n,n.inSaveFrame?s:i),f.hasError)return[2,R0(f.errorLine,f.errorMessage)]}else return console.log(n.tokenType,at.getTokenString(n)),[2,R0(n.lineNumber,"Unexpected token. Expected data_, loop_, or data name.")];d.label=6;case 6:return[3,1];case 7:return n.inSaveFrame?[2,R0(n.lineNumber,"Unfinished save frame (".concat(u.header,")."))]:((i.categoryNames.length>0||o.length>0)&&r.push(NG(i,a,o)),[2,Xye(u_(r))])}})})}function lM(e){var t=this;return Ce.create("Parse CIF",function(r){return $(t,void 0,void 0,function(){return J(this,function(n){switch(n.label){case 0:return[4,Kye(e,r)];case 1:return[2,n.sent()]}})})})}var zG="0.3.0",en;(function(e){var t;(function(i){i[i.Int8=1]="Int8",i[i.Int16=2]="Int16",i[i.Int32=3]="Int32",i[i.Uint8=4]="Uint8",i[i.Uint16=5]="Uint16",i[i.Uint32=6]="Uint32"})(t=e.IntDataType||(e.IntDataType={}));var r;(function(i){i[i.Float32=32]="Float32",i[i.Float64=33]="Float64"})(r=e.FloatDataType||(e.FloatDataType={}));function n(i){var o;return i instanceof Int8Array?o=e.IntDataType.Int8:i instanceof Int16Array?o=e.IntDataType.Int16:i instanceof Int32Array?o=e.IntDataType.Int32:i instanceof Uint8Array?o=e.IntDataType.Uint8:i instanceof Uint16Array?o=e.IntDataType.Uint16:i instanceof Uint32Array?o=e.IntDataType.Uint32:i instanceof Float32Array?o=e.FloatDataType.Float32:i instanceof Float64Array?o=e.FloatDataType.Float64:o=e.IntDataType.Int32,o}e.getDataType=n;function a(i){if(i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array)return!0;for(var o=0,s=i.length;ofM){for(var t=[],r=0;r=0;r--)t=Zye(t,e.encoding[r]);return t}function Zye(e,t){switch(t.kind){case"ByteArray":switch(t.type){case en.IntDataType.Uint8:return e;case en.IntDataType.Int8:return Qye(e);case en.IntDataType.Int16:return $ye(e);case en.IntDataType.Uint16:return Jye(e);case en.IntDataType.Int32:return ebe(e);case en.IntDataType.Uint32:return tbe(e);case en.FloatDataType.Float32:return rbe(e);case en.FloatDataType.Float64:return nbe(e);default:cr(t.type)}case"FixedPoint":return abe(e,t);case"IntervalQuantization":return ibe(e,t);case"RunLength":return obe(e,t);case"Delta":return sbe(e,t);case"IntegerPacking":return lbe(e,t);case"StringArray":return fbe(e,t)}}function WG(e,t){switch(e){case en.IntDataType.Int8:return new Int8Array(t);case en.IntDataType.Int16:return new Int16Array(t);case en.IntDataType.Int32:return new Int32Array(t);case en.IntDataType.Uint8:return new Uint8Array(t);case en.IntDataType.Uint16:return new Uint16Array(t);case en.IntDataType.Uint32:return new Uint32Array(t);default:cr(e)}}function YG(e,t){switch(e){case en.FloatDataType.Float32:return new Float32Array(t);case en.FloatDataType.Float64:return new Float64Array(t);default:cr(e)}}function Qye(e){return new Int8Array(e.buffer,e.byteOffset)}function O0(e,t,r){return HG?new r(e.buffer):new r(jG(e,t))}function $ye(e){return O0(e,2,Int16Array)}function Jye(e){return O0(e,2,Uint16Array)}function ebe(e){return O0(e,4,Int32Array)}function tbe(e){return O0(e,4,Uint32Array)}function rbe(e){return O0(e,4,Float32Array)}function nbe(e){return O0(e,8,Float64Array)}function abe(e,t){for(var r=e.length,n=YG(t.srcType,r),a=1/t.factor,i=0;i=0){var s=dbe(e[i],t,r);s<0?n=-1:s>n&&(n=s)}var u=Math.abs(e[i]);if(u>r){var c=Math.floor(Math.log10(Math.abs(u)))+1;c>a&&(a=c)}}return{mantissaDigits:n,integerDigits:a}}function ZG(e){e=e.trim();var t=parseInt(e,10);return isNaN(t)?!1:t.toString()===e}function dM(e,t){return parseFloat(e.toPrecision(t))}function K1(e){return X1.classify(e)}function QG(e){return mM.classify(e)}var X1;(function(e){function t(m,h){return m>=0?Math.ceil((m+1)/h):Math.ceil((m+1)/(-h-1))}function r(m){for(var h=!1,p=0,v=m.length;p10)return Or.by(Or.byteArray);if(s===0)return X1.classify(a);for(var c=n(s),l=new Int32Array(a.length),f=0,d=a.length;f=T?O[z]=A-1:O[z]=Math.round((G-D)/B)|0}return{encodings:[{kind:"IntervalQuantization",min:D,max:T,numSteps:A,srcType:I}],data:O}}function d(C,D,T,A){return A===void 0&&(A=Int32Array),function(E){return f(E,C,D,T,A)}}e.intervalQuantizaiton=d;function m(C){var D=en.getDataType(C);if(D===void 0&&(C=new Int32Array(C),D=en.IntDataType.Int32),!C.length)return{encodings:[{kind:"RunLength",srcType:D,srcSize:0}],data:new Int32Array(0)};for(var T=2,A=1,E=C.length;A=0?A+=R/D|0:A+=R/T|0}return A+=C.length,A}function b(C){var D=p(C),T=D?g(C,127):v(C,255),A=D?g(C,32767):v(C,65535);return C.length*4=0)for(;O>=T;)I[R]=T,++R,O-=T;else for(;O<=A;)I[R]=A,++R,O-=A;I[R]=O,++R}var z=u(I);return{encodings:[{kind:"IntegerPacking",byteCount:D.bytesPerElement,isUnsigned:!D.isSigned,srcSize:E},z.encodings[0]],data:z.data}}function S(C){var D=b(C);return D.bytesPerElement===4?u(C):x(C,D)}e.integerPacking=S;function _(C){var D=Object.create(null),T=[],A=new Int32Array(C.length),E=He.create(Int32Array,1,Math.min(1024,C.length<32?C.length+1:Math.round(C.length/8)+1));He.add(E,0);for(var I=0,R=0,B=0,O=C;Bt[r])return!1;return!0}function pbe(e){for(var t=Object.create(null),r=Object.create(null),n=0,a=e.columns;n=0){var _=r(2,4);_===0&&(_=1);for(var C=0;C<_;C++)S.push(C)}else for(var D=at.readLine(e).trim().split(/\s+/g),C=0,T=+D[0];C1e5&&t.shouldUpdate?(i=r.position,[4,t.update({current:r.position,max:r.length})]):[3,3]:[3,4];case 2:l.sent(),l.label=3;case 3:if(o=S_(n.tokenizer).trim(),o.startsWith("%VERSION"))a.version=o.substring(8).trim();else if(o.startsWith("%FLAG")){if(s=o.substring(5).trim(),u=S_(n.tokenizer).trim(),!u.startsWith("%FORMAT"))throw new Error("expected %FORMAT");if(s==="TITLE")a.title=v1e(n);else if(s==="POINTERS")a.pointers=g1e(n);else if(s==="ATOM_NAME")c=Ym(n,a.pointers.NATOM,20,4),a.atomName=Qt(c)(ne.Schema.str);else if(s==="CHARGE")c=Ym(n,a.pointers.NATOM,5,16),a.charge=Qt(c)(ne.Schema.float);else if(s==="MASS")c=Ym(n,a.pointers.NATOM,5,16),a.mass=Qt(c)(ne.Schema.float);else if(s==="RESIDUE_LABEL")c=Ym(n,a.pointers.NRES,20,4),a.residueLabel=Qt(c)(ne.Schema.str);else if(s==="RESIDUE_POINTER")c=Ym(n,a.pointers.NRES,10,8),a.residuePointer=Qt(c)(ne.Schema.int);else if(s==="BONDS_INC_HYDROGEN")c=Ym(n,a.pointers.NBONH*3,10,8),a.bondsIncHydrogen=Qt(c)(ne.Schema.int);else if(s==="BONDS_WITHOUT_HYDROGEN")c=Ym(n,a.pointers.NBONA*3,10,8),a.bondsWithoutHydrogen=Qt(c)(ne.Schema.int);else if(s==="RADII")c=Ym(n,a.pointers.NATOM,5,16),a.radii=Qt(c)(ne.Schema.float);else for(;r.tokenEnd=t.length));){var a=t.data[t.position];if(a==="[")break;if(a===";"||a==="*"){Xm(t);continue}for(var i=0;i<2;++i)switch(Km(t),C_(t),wM(t),i){case 0:We.add(r,t.tokenStart,t.tokenEnd);break;case 1:We.add(n,t.tokenStart,t.tokenEnd);break}C1e(t),C_(t)}return ar.ofColumns(S1e,{compound:Qt(r)(ne.Schema.str),molCount:Qt(n)(ne.Schema.int)})}function M1e(e,t){return $(this,void 0,void 0,function(){function r(){u&&s.atoms&&(i.compounds[u]=s,s={},u="")}var n,a,i,o,s,u,c,l,f;return J(this,function(d){switch(d.label){case 0:n=at(e),a=_1e(n,t),i=Object.create(null),o=0,i.compounds={},s={},u="",d.label=1;case 1:return n.tokenEnd1e5&&t.shouldUpdate?(o=n.position,[4,t.update({current:n.position,max:n.length})]):[3,3]:[3,4];case 2:d.sent(),d.label=3;case 3:if(c=_M(a.tokenizer).trim(),!c||c[0]==="*"||c[0]===";")return[3,1];if(c.startsWith("#include"))throw new Error("#include statements not allowed");if(c.startsWith("[")){if(l=c.match(w1e),l===null)throw new Error("expected field name");if(f=l[1],f==="moleculetype")r(),u=A1e(a);else if(f==="atoms")s.atoms=D1e(a);else if(f==="bonds")s.bonds=P1e(a);else if(f==="system")i.system=E1e(a);else if(f==="molecules")r(),i.molecules=I1e(a);else for(;n.tokenEndW1e});var W1e=It.BuiltIn({name:"create-group",display:{name:"Group"},from:[],to:he.Group,params:{label:w.Text("Group"),description:w.Optional(w.Text(""))}})({apply:function(e){var t=e.params;return new he.Group({},t)},update:function(e){var t=e.oldParams,r=e.newParams,n=e.b;return Vh(t,r)?rt.UpdateResult.Unchanged:(n.label=r.label,n.description=r.description,rt.UpdateResult.Updated)}});var wO={};fi(wO,{CoordinatesFromDcd:()=>aIe,CoordinatesFromNctraj:()=>sIe,CoordinatesFromTrr:()=>oIe,CoordinatesFromXtc:()=>iIe,CustomModelProperties:()=>CO,CustomStructureProperties:()=>_O,ModelFromTrajectory:()=>SO,MultiStructureSelectionFromExpression:()=>PIe,ShapeFromPly:()=>OIe,StructureComplexElement:()=>RIe,StructureComplexElementTypes:()=>eQ,StructureComponent:()=>BIe,StructureFromModel:()=>TIe,StructureFromTrajectory:()=>wIe,StructureSelectionFromBundle:()=>IIe,StructureSelectionFromExpression:()=>DIe,StructureSelectionFromScript:()=>EIe,TopologyFromPrmtop:()=>cIe,TopologyFromPsf:()=>uIe,TopologyFromTop:()=>lIe,TrajectoryFromBlob:()=>dIe,TrajectoryFromCifCore:()=>SIe,TrajectoryFromCube:()=>xIe,TrajectoryFromGRO:()=>hIe,TrajectoryFromMOL:()=>gIe,TrajectoryFromMOL2:()=>bIe,TrajectoryFromMmCif:()=>mIe,TrajectoryFromModelAndCoordinates:()=>Zw,TrajectoryFromPDB:()=>pIe,TrajectoryFromSDF:()=>yIe,TrajectoryFromXYZ:()=>vIe,TransformStructureConformation:()=>AIe});function Y1e(e){var t=new DataView(e.buffer),r=Object.create(null),n=[],a=0,i=new Int32Array(e.buffer,0,23),o=i[0]!==t.getInt32(0);if(i[0]!==84)for(var s=e.byteLength,u=0;u0)throw new Error("dcd format with fixed atoms unsupported, aborting");for(var p=r.NATOM,v=p*4,u=0,s=r.NSET;u=f)return"";var d=l+r;return d>f&&(d=f),FG(a,l,d)}:s==="int"?function(c){var l=i[2*c]+t;return l>i[2*c+1]?0:vd(a,l,l+r)}:function(c){var l=i[2*c]+t;return l>i[2*c+1]?0:p8(a,l,l+r)};return{schema:n,__array:void 0,isDefined:!0,rowCount:o,value:u,valueKind:function(c){return 0},toArray:function(c){return Aa.createAndFillArray(o,u,c)},areValuesEqual:function(c,l){return u(c)===u(l)}}}function K1e(){return{title:"",timeInPs:0,hasVelocities:!1,precision:{position:0,velocity:0},box:[0,0,0]}}function Z1e(e,t){return{tokenizer:e,header:K1e(),numberOfAtoms:0,runtimeCtx:t}}function Q1e(e){var t=e.tokenizer,r=e.header,n=at.readLine(t);n.trim().length===0&&(n=at.readLine(t));var a=n.lastIndexOf("t=");a>=0?(r.timeInPs=parseFloat(n.substring(a+2)),r.title=n.substring(0,a).trim(),r.title&&r.title[r.title.length-1]===","&&(r.title=r.title.substring(0,r.title.length-1))):r.title=n}function $1e(e){var t=e.tokenizer;at.markLine(t);var r=at.getTokenString(t);e.numberOfAtoms=parseInt(r)}function J1e(e){return $(this,void 0,void 0,function(){var t,r,n,a,i,o,s,u,c,l,f,d,m;return J(this,function(h){switch(h.label){case 0:return t=e.tokenizer,r=e.numberOfAtoms,[4,at.readLinesAsync(t,r,e.runtimeCtx,1e5)];case 1:return n=h.sent(),a=t.data.substring(n.indices[0],n.indices[1]).substring(20),i=a.match(/\.\d+/g),o=i.length===6,e.header.hasVelocities=o,e.header.precision.position=i[0].length-1,e.header.precision.velocity=o?i[3].length-1:0,s=20,u=e.header.precision.position+5,c=s+3*u,l=e.header.precision.velocity+4,f=Ez(n),d=ne.Undefined(e.numberOfAtoms,ne.Schema.float),m={count:e.numberOfAtoms,residueNumber:f(0,5,ne.Schema.int),residueName:f(5,5,ne.Schema.str),atomName:f(10,5,ne.Schema.str),atomNumber:f(15,5,ne.Schema.int),x:f(s,u,ne.Schema.float),y:f(s+u,u,ne.Schema.float),z:f(s+2*u,u,ne.Schema.float),vx:o?f(c,l,ne.Schema.float):d,vy:o?f(c+l,l,ne.Schema.float):d,vz:o?f(c+2*l,l,ne.Schema.float):d},[2,m]}})})}function exe(e){var t=e.tokenizer,r=at.readLine(t).trim().split(/\s+/g);e.header.box=[+r[0],+r[1],+r[2]]}function txe(e,t){return $(this,void 0,void 0,function(){var r,n,a,i,o;return J(this,function(s){switch(s.label){case 0:return r=at(e),[4,t.update({message:"Parsing...",current:0,max:e.length})];case 1:s.sent(),n=[],s.label=2;case 2:return r.position=r&&t0&&n>0&&ex(e)>=J1(t)&&J1(e)<=ex(t)}function Gz(e,t){return Zm(e)?Zm(t)?Pf(e)<=Pf(t)&&wd(e)>=wd(t):!0:Zm(t)===0}function __(e,t){var r=Pf(e);if(t<=r)return 0;var n=wd(e);return t>=n?n-r:t-r}function zz(e,t,r){var n=Pf(r),a=Pf(e);if(t<=n+a)return n;var i=wd(r);return t>=i+a?i:t-a}function OM(e,t,r){return w_(__(e,t),__(e,r+1))}function Hz(e,t){return BM(e,t)?w_(Math.max(Pf(e),Pf(t)),Math.min(wd(e),wd(t))):MM}function jz(e,t){return Zm(OM(e,J1(t),ex(t)))}var Se;(function(e){e.Empty=MM,e.ofSingleton=function(t){return RM(t,t)},e.ofRange=RM,e.ofBounds=w_,e.ofLength=Bz,e.is=Oz,e.has=kz,e.indexOf=Nz,e.getAt=Uz,e.start=Pf,e.end=wd,e.min=J1,e.max=ex,e.size=Zm,e.hashCode=Fz,e.toString=Lz,e.areEqual=Vz,e.areIntersecting=BM,e.isSubInterval=Gz,e.findPredecessorIndex=__,e.findPredecessorIndexInInterval=zz,e.findRange=OM,e.intersectionSize=jz,e.intersect=Hz})(Se||(Se={}));var k0=[];function qz(e){return[e]}function Wz(e){return e}function Yz(e){return ho(e),e}function FM(e,t){if(t2?f8(t,e[0],e[t-1],e[t>>1]):l8(t,e[0],e[t-1]):0}function $z(e){var t=e.length;return t>5?"[".concat(e[0],", ").concat(e[1],", ..., ").concat(e[t-1],"], length ").concat(t):"[".concat(e.join(", "),"]")}function NM(e,t){var r=e.length;return r===0?-1:e[0]<=t&&t<=e[r-1]?nH(e,t,0,r):-1}function Jz(e,t,r){return UM(e,t,Se.start(r),Se.end(r))}function UM(e,t,r,n){var a=e.length;return a===0||n<=r?-1:e[r]<=t&&t<=e[n-1]?nH(e,t,r,n):-1}function eH(e,t){return NM(e,t)>=0}function VM(e,t){if(e===t)return!0;var r=e.length;if(r!==t.length||e[0]!==t[0]||e[r-1]!==t[r-1])return!1;if(LM(e))return!0;r--;for(var n=1;ne[r-1]?r:aH(e,t,0,r)}function tH(e,t,r){var n=Se.start(r),a=Se.end(r),i=e[n];return t<=i?n:a>n&&t>e[a-1]?a:t-i<=11?nxe(e,t,n+1,a):aH(e,t,n,a)}function rH(e,t,r){return Se.ofBounds(Qm(e,t),Qm(e,r+1))}function nH(e,t,r,n){for(var a=r,i=n-1;a<=i;){if(a+11>i){for(var o=a;o<=i;o++)if(t===e[o])return o;return-1}var s=a+i>>1,u=e[s];if(tu)a=s+1;else return s}return-1}function aH(e,t,r,n){for(var a=r,i=n-1;ai){for(var o=a;o<=i;o++)if(t<=e[o])return o;return i+1}var s=a+i>>1,u=e[s];if(tu)a=s+1;else return s}return a>i?i+1:e[a]>=t?a:a+1}function nxe(e,t,r,n){for(var a=r;au)a++;else return!0}return!1}function oH(e,t){if(e===t)return!0;var r=t.length,n=rv(e,t),a=n.startI,i=n.startJ,o=n.endI,s=n.endJ;if(s-il?i++:(a++,i++,u++)}return u===r}function GM(e,t){if(e===t)return e;var r=e.length,n=t.length;if(r===0)return t;if(n===0)return e;if(e[0]>t[0])return GM(t,e);var a=rv(e,t),i=a.startI,o=a.startJ,s=a.endI,u=a.endJ,c=zM(e,t,i,o,s,u);if(c===r&&c===n||c===n)return e;if(c===r)return t;var l=new Int32Array(r+n-c),f=0,d=0,m=0;for(f=0;ft[d];)l[m++]=t[d++];for(;fp?(l[m++]=p,d++):(l[m++]=h,f++,d++)}for(;fl?s++:(o++,s++,u++)}return u}function uH(e,t){if(e===t)return e;var r=rv(e,t),n=r.startI,a=r.startJ,i=r.endI,o=r.endJ,s=zM(e,t,n,a,i,o),u=e.length,c=t.length;if(!s)return k0;if(s===u&&s===c||s===c)return t;if(s===u)return e;for(var l=new Int32Array(s),f=0,d=n,m=a;dp||(l[f++]=h,d++),m++)}return l}function cH(e,t){if(e===t)return k0;for(var r=e.length,n=rv(e,t),a=n.startI,i=n.startJ,o=n.endI,s=n.endJ,u=a,c=i,l=0;ud?c++:(u++,c++,l++)}if(!l)return e;if(l>=r)return k0;for(var m=new Int32Array(r-l),h=0,p=0;pd||u++,c++)}for(;uf?u++:(s++,u++,c++)}var d=e.length;if(!c)return k0;if(c===d)return F1(0,e.length-1);var m=new Int32Array(c),h=0;for(s=n,u=a;sf||(m[h++]=s,s++),u++)}return m}var Td={startI:0,startJ:0,endI:0,endJ:0};function rv(e,t){var r=e.length,n=t.length,a=r/n;return r>=128||n>=128||a<=.34||a>=2.99?(Td.startI=Qm(e,T_(t)),Td.startJ=Qm(t,T_(e)),Td.endI=Qm(e,A_(t)),Td.endJ=Qm(t,A_(e))):(Td.startI=0,Td.startJ=0,Td.endI=r,Td.endJ=n),Td}var Fe;(function(e){e.Empty=k0,e.ofUnsortedArray=Yz,e.ofSingleton=qz,e.ofSortedArray=Wz,e.ofRange=FM,e.ofBounds=function(t,r){return FM(t,r-1)},e.is=Xz,e.isRange=LM,e.has=eH,e.indexOf=NM,e.indexOfInInterval=Jz,e.indexOfInRange=UM,e.start=T_,e.end=A_,e.min=Kz,e.max=Zz,e.size=kM,e.hashCode=Qz,e.toString=$z,e.areEqual=VM,e.areIntersecting=iH,e.isSubset=oH,e.union=GM,e.intersect=uH,e.subtract=cH,e.findPredecessorIndex=Qm,e.findPredecessorIndexInInterval=tH,e.findRange=rH,e.intersectionSize=sH,e.deduplicate=lH,e.indicesOf=fH})(Fe||(Fe={}));var Rl=Se.Empty,gH=Se.ofSingleton,yH=Se.ofRange,bH=Se.ofBounds;function Fc(e){return e.length?Fe.isRange(e)?Se.ofRange(e[0],e[e.length-1]):e:Rl}function $m(e){return Se.is(e)?Se.size(e):Fe.size(e)}function xH(e,t){return Se.is(e)?Se.has(e,t):Fe.has(e,t)}function SH(e,t){return Se.is(e)?Se.indexOf(e,t):Fe.indexOf(e,t)}function D_(e,t){return Se.is(e)?Se.getAt(e,t):e[t]}function nv(e){return Se.is(e)?Se.min(e):Fe.min(e)}function av(e){return Se.is(e)?Se.max(e):Fe.max(e)}function CH(e){return Se.is(e)?Se.start(e):Fe.start(e)}function _H(e){return Se.is(e)?Se.end(e):Fe.end(e)}function wH(e){return Se.is(e)?Se.hashCode(e):Fe.hashCode(e)}function TH(e){return Se.is(e)?Se.toString(e):Fe.toString(e)}function AH(e,t){return Se.is(e)?Se.is(t)?Se.areEqual(e,t):dH(e,t):Se.is(t)?dH(t,e):Fe.areEqual(e,t)}function DH(e,t){return Se.is(e)?Se.is(t)?Se.areIntersecting(e,t):mH(t,e):Se.is(t)?mH(e,t):Fe.areIntersecting(e,t)}function PH(e,t){return Se.is(e)?Se.is(t)?Se.isSubInterval(e,t):oxe(e,t):Se.is(t)?ixe(e,t):Fe.isSubset(e,t)}function EH(e,t){return Se.is(e)?Se.findPredecessorIndex(e,t):Fe.findPredecessorIndex(e,t)}function IH(e,t,r){return Se.is(e)?Se.findPredecessorIndexInInterval(e,t,r):Fe.findPredecessorIndexInInterval(e,t,r)}function MH(e,t,r){return Se.is(e)?Se.findRange(e,t,r):Fe.findRange(e,t,r)}function RH(e,t){return Se.is(e)?Se.is(t)?Se.intersectionSize(e,t):hH(t,e):Se.is(t)?hH(e,t):Fe.intersectionSize(e,t)}function BH(e,t){return Se.is(e)?Se.is(t)?cxe(e,t):pH(t,e):Se.is(t)?pH(e,t):Fc(Fe.union(e,t))}function OH(e,t){return Se.is(e)?Se.is(t)?Se.intersect(e,t):vH(t,e):Se.is(t)?vH(e,t):Fc(Fe.intersect(e,t))}function FH(e,t){return Se.is(e)?Se.is(t)?lxe(e,t):dxe(e,t):Se.is(t)?fxe(e,t):Fc(Fe.subtract(e,t))}function dH(e,t){return Se.size(e)===Fe.size(t)&&Se.start(e)===Fe.start(t)&&Se.end(e)===Fe.end(t)}function mH(e,t){return e.length!==0&&Se.size(Fe.findRange(e,Se.min(t),Se.max(t)))!==0}function ixe(e,t){var r=Se.min(t),n=Se.max(t);if(n-r+1===0)return!0;var a=Fe.min(e),i=Fe.max(e);if(ri)return!1;var o=Fe.findRange(e,r,n);return Se.size(o)===Se.size(t)}function oxe(e,t){var r=Se.min(e),n=Se.max(e);if(n-r+1===0)return!1;var a=Fe.min(t),i=Fe.max(t);return a>=r&&i<=n}function sxe(e,t){var r=$m(e),n=$m(t);return r===0&&n===0?!0:r>0&&n>0&&av(e)>=nv(t)&&nv(e)<=av(t)}function uxe(e,t){return $m(e)?$m(t)?nv(e)<=nv(t)&&av(e)>=av(t):!0:$m(t)===0}function cxe(e,t){if(Se.areEqual(e,t))return e;var r=Se.size(e),n=Se.size(t);if(!n)return e;if(!r)return t;var a=Se.min(e),i=Se.min(t);if(sxe(e,t))return Se.ofRange(Math.min(a,i),Math.max(Se.max(e),Se.max(t)));var o,s,u,c;am||(u++,l++),f++)}if(u===0)return Rl;if(u===a&&u===i)return e;var h=new Int32Array(u);for(c=0,l=0,f=o;lm||(h[c++]=f,l++),f++)}return Fc(h)}var Ee;(function(e){e.Empty=Rl,e.ofSingleton=gH,e.ofRange=yH,e.ofBounds=bH,e.ofSortedArray=Fc,e.has=xH,e.indexOf=SH,e.getAt=D_,e.min=nv,e.max=av,e.start=CH,e.end=_H,e.size=$m,e.hashCode=wH,e.areEqual=AH,e.areIntersecting=DH,e.isSubset=PH,e.union=BH,e.intersect=OH,e.indexedIntersect=NH,e.subtract=FH,e.findPredecessorIndex=EH,e.findPredecessorIndexInInterval=IH,e.findRange=MH,e.intersectionSize=RH;function t(s,u,c){return LH(s,u,c)}e.forEach=t;function r(s,u,c,l){return kH(s,u,c,l)}e.forEachSegment=r;function n(s){return Se.is(s)}e.isInterval=n;function a(s){return!Se.is(s)}e.isSortedArray=a;function i(s){var u=[];return e.forEach(s,function(c){return u.push(c)}),u}e.toArray=i;function o(s){return TH(s)}e.toString=o})(Ee||(Ee={}));function HM(e){for(var t=Fe.ofSortedArray(e),r=Fe.max(t),n=new Int32Array(r),a=0,i=e.length-1;a=a?-1:Ee.findPredecessorIndex(n,r-1);return Ee.findRange(t,Ee.getAt(n,i),Ee.getAt(n,i+1)-1)}var pxe=function(){function e(t,r,n,a){this.segments=t,this.segmentMap=r,this.set=n,this.segmentMin=0,this.segmentMax=0,this.setRange=Se.Empty,this.value={index:0,start:0,end:0},this.hasNext=!1,this.setRange=a,this.updateSegmentRange()}return e.prototype.move=function(){for(;this.hasNext;)if(this.updateValue()){this.value.index=this.segmentMin++,this.hasNext=this.segmentMax>=this.segmentMin&&Se.size(this.setRange)>0;break}else this.updateSegmentRange();return this.value},e.prototype.updateValue=function(){var t=this.segments[this.segmentMin+1],r=Ee.findPredecessorIndexInInterval(this.set,t,this.setRange);return this.value.start=Se.start(this.setRange),this.value.end=r,this.setRange=Se.ofBounds(r,Se.end(this.setRange)),r>this.value.start},e.prototype.updateSegmentRange=function(){var t=Se.min(this.setRange),r=Se.max(this.setRange);if(r=this.segmentMin},e.prototype.setSegment=function(t){this.setRange=Se.ofBounds(t.start,t.end),this.updateSegmentRange()},e}();function HH(e,t,r){var n=typeof r<"u"?Se.ofBounds(r.start,r.end):Se.ofBounds(0,Ee.size(t));return new pxe(e.offsets,e.index,t,n)}var qt;(function(e){e.create=HM,e.ofOffsets=UH,e.count=VH,e.getSegment=GH,e.projectValue=zH,e.transientSegments=HH})(qt||(qt={}));function jM(e){return new vxe(e)}var vxe=function(){function e(t){this.head=t>0?0:-1,this.prev=new Int32Array(t),this.next=new Int32Array(t);for(var r=0;r=0&&(a[i]=o,n[t]=-1),o>=0&&(n[o]=i,a[t]=-1),t===this.head&&(i<0?this.head=o:this.head=i)},e.prototype.has=function(t){return this.prev[t]>=0||this.next[t]>=0||this.head===t},e}();var Do;(function(e){e.Empty=new Map;function t(o){return Rm(o.keys())}e.keyArray=t;function r(){return new Map}e.Mutable=r;function n(o){return o}e.asImmutable=n;function a(o){for(var s=r(),u=o.keys();;){var c=u.next(),l=c.done,f=c.value;if(l)break;s.set(f,o.get(f))}return s}e.copy=a;function i(o,s){for(var u=s.keys();;){var c=u.next(),l=c.done,f=c.value;if(l)break;o.set(f,s.get(f))}return o}e.addFrom=i})(Do||(Do={}));var gxe=function(){function e(t){this.xs=[],this.index=-1,this.length=0,this.hasNext=!1,this.length=t.length,this.hasNext=t.length>0,this.xs=t,this.index=-1,this.lastValue=t.length>0?t[0]:void 0}return e.prototype.move=function(){return++this.index,this.lastValue=this.xs[this.index],this.hasNext=this.index=t}return e.prototype.move=function(){return++this.value,this.hasNext=this.value_)return x[_];var A=S[T-1],E=S[T],I=Ta((D-A)/(E-A),0,1);return Xe.interpolate(x[T-1],x[T],I)}}else v=function(C){var D=Math.min(u.length-1,Math.max(0,(C-f)/l*c)),T=Math.floor(D),A=u[T],E=u[Math.ceil(D)];return Xe.interpolate(A,E,D-T)};return{color:v,colorToArray:function(C,D,T){Xe.toArray(v(C),D,T)},normalizedColorToArray:function(C,D,T){Xe.toArrayNormalized(v(C),D,T)},setDomain:m,get legend(){return Rz(h,p,u)}}}e.create=t})(Ti||(Ti={}));function ep(e,t,r){for(var n=new Float32Array(e),a=0;a146&&++t,e>148&&++t,e>155&&++t,e>160&&++t,e>161&&++t,e>166&&++t,e>167&&++t,e-1+t}function Mxe(e){if(e<146)return e+1;if(e===146)return 1146;if(e<149)return e+1-1;if(e===149)return 1148;if(e<157)return e+1-2;if(e===157)return 1155;if(e<163)return e+1-3;if(e===163)return 1160;if(e<165)return e+1-4;if(e===165)return 1161;if(e<171)return e+1-5;if(e===171)return 1166;if(e<173)return e+1-6;if(e===173)return 1167;if(e<237)return e+1-7;if(e===237)return 1003;if(e===238)return 1004;if(e===239)return 1005;if(e===240)return 2005;if(e===241)return 3005;if(e===242)return 4005;if(e===243)return 5005;if(e===244)return 1006;if(e===245)return 1007;if(e===246)return 1008;if(e===247)return 1009;if(e===248)return 1010;if(e===249)return 1011;if(e===250)return 1012;if(e===251)return 1013;if(e===252)return 1014;if(e===253)return 2014;if(e===254)return 3014;if(e===255)return 1015;if(e===256)return 1017;if(e===257)return 2017;if(e===258)return 1018;if(e===259)return 2018;if(e===260)return 3018;if(e===261)return 1020;if(e===262)return 1021;if(e===263)return 1022;if(e===264)return 1023;if(e===265)return 1059;if(e===266)return 1094;if(e===267)return 1197;throw new Error("unknown spacegroup index '".concat(e,"'"))}var WM=function(){for(var e=Object.create(null),t=0,r=Object.keys(tx);t"u"||typeof WM[t]>"u"?-1:t}var Va;(function(e){e.Zero=r("P 1",y.create(1,1,1),y.create(Math.PI/2,Math.PI/2,Math.PI/2));function t(n){return n?n.index===0&&n.size[0]===1&&n.size[1]===1&&n.size[1]===1:!0}e.isZero=t;function r(n,a,i){var o=XH(n);if(o<0)return console.warn("Unknown spacegroup '".concat(n,"', returning a 'P 1' with cellsize [1, 1, 1]")),e.Zero;var s=a[0]*a[1]*a[2],u=i[0],c=i[1],l=i[2],f=a[0],d=a[1],m=a[2],h=Math.cos(c),p=(Math.cos(u)-Math.cos(c)*Math.cos(l))/Math.sin(l),v=Math.sqrt(1-h*h-p*p),g=[f,0,0],b=[Math.cos(l)*d,Math.sin(l)*d,0],x=[h*m,p*m,v*m],S=se.ofRows([[g[0],b[0],x[0],0],[0,b[1],x[1],0],[0,0,x[2],0],[0,0,0,1]]),_=se.invert(se.zero(),S);return{index:o,size:a,volume:s,anglesInRadians:i,toFractional:_,fromFractional:S}}e.create=r})(Va||(Va={}));var $i;(function(e){e.ZeroP1=t(Va.Zero);function t(v){var g=WH[v.index].map(function(S){return f(qH[S])}),b=WM[v.index],x=YH[v.index];return{name:b,num:x,cell:v,operators:g}}e.create=t;var r=y(),n=se();function a(v,g,b,x,S,_){return y.set(r,b,x,S),se.fromTranslation(n,r),se.mul(_,se.mul(_,se.mul(_,v.cell.fromFractional,n),v.operators[g]),v.cell.toFractional)}e.setOperatorMatrix=a;function i(v,g,b,x,S){var _=a(v,g,b,x,S,se.zero());return yn.create("".concat(g+1,"_").concat(5+b).concat(5+x).concat(5+S),_,{hkl:y.create(b,x,S),spgrOp:g})}e.getSymmetryOperator=i;var o=y(),s=y(),u=y(),c=y();function l(v,g,b,x,S,_){var C=se.zero();y.set(r,b,x,S),y.floor(o,_),se.copy(C,v.operators[g]),y.floor(s,y.transformMat4(s,_,C)),se.getTranslation(c,C),y.sub(c,c,s),y.add(c,c,o),y.add(c,c,r),se.setTranslation(C,c),se.mul(C,v.cell.fromFractional,C),se.mul(C,C,v.cell.toFractional),y.sub(u,s,o);var D=b-u[0],T=x-u[1],A=S-u[2];return yn.create("".concat(g+1,"_").concat(5+D).concat(5+T).concat(5+A),C,{hkl:y.create(D,T,A),spgrOp:g})}e.getSymmetryOperatorRef=l;function f(v){var g=E_[v[0]],b=E_[v[1]],x=E_[v[2]];return se.ofRows([g,b,x,[0,0,0,1]])}function d(v){return[p(m(v[0],v[4],v[8]),h(v[12])),p(m(v[1],v[5],v[9]),h(v[13])),p(m(v[2],v[6],v[10]),h(v[14]))].join(",")}e.getOperatorXyz=d;function m(v,g,b){var x=[];if(v>0?x.push("+X"):v<0&&x.push("-X"),g>0?x.push("+Y"):g<0&&x.push("-Y"),b>0?x.push("+Z"):b<0&&x.push("-Z"),x.length===1)return x[0].charAt(0)==="+"?x[0].substr(1):x[0];if(x.length===2){var S=x[0].charAt(0),_=x[1].charAt(0);if(S==="+")return"".concat(x[0].substr(1)).concat(x[1]);if(_==="+")return"".concat(x[1].substr(1)).concat(x[0])}throw new Error("unknown rotation '".concat(x,"', ").concat(v," ").concat(g," ").concat(b))}function h(v){switch(v){case 1/2:return"1/2";case 1/4:return"1/4";case 3/4:return"3/4";case 1/3:return"1/3";case 2/3:return"2/3";case 1/6:return"1/6";case 5/6:return"5/6"}return""}function p(v,g){return g===""?v:v.length>2?"".concat(v,"+").concat(g):v.charAt(0)==="-"?"".concat(g).concat(v):"".concat(g,"+").concat(v)}})($i||($i={}));var xu;(function(e){function t(i,o,s){i.squaredDistances[i.count]=s,i.indices[i.count++]=o}e.add=t;function r(i){i.count=0}e.reset=r;function n(){return{count:0,indices:[],squaredDistances:[]}}e.create=n;function a(i,o){for(var s=0;st?(t/=e,e*Math.sqrt(1+t*t)):t>0?(e/=t,t*Math.sqrt(1+e*e)):0}var Bxe=1192092896e-16,Oxe=1e-37;function Fxe(e,t,r,n,a,i,o,s){for(var u=Bxe*2,c=Oxe,l=0,f=0,d=0,m=0,h=Math.max(i,30),p=0,v=0,g=0,b=0,x=0,S=0,_=0,C=0,D=0,T=0,A=0,E=0,I=0,R=0,B=0,O=0,z=0,k=4660,G=0,V=0,U=0,Q=new Float64Array(o<<3);l>16&32767&256?V:-V,e[l*t+d]=G;for(m=0;m<2;m++)for(f=0;f0?_>u&&(u=_):_>c&&(c=_),y.projectPointOnVector(h,y.fromArray(h,o,b),g.dirB,v);var C=y.dot(g.dirB,y.normalize(p,y.sub(p,h,v))),D=y.distance(h,v);C>0?D>l&&(l=D):D>f&&(f=D),y.projectPointOnVector(h,y.fromArray(h,o,b),g.dirC,v);var T=y.dot(g.dirC,y.normalize(p,y.sub(p,h,v))),A=y.distance(h,v);T>0?A>d&&(d=A):A>m&&(m=A)}var E=y.setMagnitude(y(),g.dirA,(u+c)/2),I=y.setMagnitude(y(),g.dirB,(l+f)/2),R=y.setMagnitude(y(),g.dirC,(d+m)/2),B=y.isFinite(E),O=y.isFinite(I),z=y.isFinite(R),k=y(),G=function(V,U,Q){y.copy(a,v),B&&y.scaleAndAdd(a,a,g.dirA,V),O&&y.scaleAndAdd(a,a,g.dirB,U),z&&y.scaleAndAdd(a,a,g.dirC,Q),y.add(k,k,a)};return G(u,l,d),G(u,l,-m),G(u,-f,-m),G(u,-f,d),G(-c,-f,-m),G(-c,-f,d),G(-c,l,d),G(-c,l,-m),y.scale(k,k,1/8),si.create(k,E,I,R)}e.calculateBoxAxes=i})(No||(No={}));function xe(){return xe.zero()}(function(e){function t(R){return R.extrema!==void 0}e.hasExtrema=t;function r(R,B){return{center:R,radius:B}}e.create=r;function n(){return{center:y(),radius:0}}e.zero=n;function a(R){var B=r(y.clone(R.center),R.radius);return t(R)&&(B.extrema=R.extrema.map(function(O){return y.clone(O)})),B}e.clone=a;function i(R,B,O){return y.copy(R.center,B),R.radius=O,R}e.set=i;function o(R,B){return y.copy(R.center,B.center),R.radius=B.radius,t(B)&&s(R,B.extrema.map(function(O){return y.clone(O)})),R}e.copy=o;function s(R,B){var O;return R.extrema!==void 0?(R.extrema.length=0,(O=R.extrema).push.apply(O,B)):R.extrema=B,R}e.setExtrema=s;function u(R){for(var B=R.x,O=R.y,z=R.z,k=R.indices,G=0,V=0,U=0,Q=0,W=Ee.size(k),X=0;X0&&(G/=W,V/=W,U/=W);for(var X=0;XQ&&(Q=Z)}return{center:y.create(G,V,U),radius:Math.sqrt(Q)}}e.computeBounding=u;function c(R,B,O){return y.transformMat4(R.center,B.center,O),R.radius=B.radius*se.getMaxScaleOnAxis(O),t(B)&&s(R,B.extrema.map(function(z){return y.transformMat4(y(),z,O)})),R}e.transform=c;function l(R,B,O){return y.add(R.center,B.center,O),t(B)&&s(R,B.extrema.map(function(z){return y.add(y(),z,O)})),R}e.translate=l;function f(R,B,O){return y.toArray(R.center,B,O),B[O+3]=R.radius,B}e.toArray=f;function d(R,B,O){return y.fromArray(R.center,B,O),R.radius=B[O+3],R}e.fromArray=d;function m(R,B){return y.scale(R.center,y.add(R.center,B.max,B.min),.5),R.radius=y.distance(R.center,B.max),e.setExtrema(R,[y.create(B.min[0],B.min[1],B.min[2]),y.create(B.max[0],B.max[1],B.max[2]),y.create(B.max[0],B.min[1],B.min[2]),y.create(B.min[0],B.max[1],B.max[2]),y.create(B.min[0],B.min[1],B.max[2]),y.create(B.max[0],B.min[1],B.max[2]),y.create(B.max[0],B.max[1],B.min[2]),y.create(B.min[0],B.max[1],B.min[2])]),R}e.fromBox3D=m;function h(R,B){return y.copy(R.center,B.origin),R.radius=Math.max(y.magnitude(B.dirA),y.magnitude(B.dirB),y.magnitude(B.dirC)),R}e.fromAxes3D=h;var p=y();function v(R,B,O){var z=B[0],k=B[1],G=B[2],V=y.create(0,0,0);y.transformMat4(V,V,O);var U=y.create(z,k,G);y.transformMat4(U,U,O);var Q=y.create(z,0,0);y.transformMat4(Q,Q,O);var W=y.create(0,k,G);y.transformMat4(W,W,O);var X=y.create(0,0,G);y.transformMat4(X,X,O);var ae=y.create(z,0,G);y.transformMat4(ae,ae,O);var q=y.create(z,k,0);y.transformMat4(q,q,O);var F=y.create(0,k,0);y.transformMat4(F,F,O),y.add(p,V,U),y.scale(p,p,.5);var j=Math.max(y.distance(V,U),y.distance(Q,W));return e.set(R,p,j/2),e.setExtrema(R,[V,U,Q,W,X,ae,q,F]),R}e.fromDimensionsAndTransform=v;var g=y();function b(R,B,O){var z=y.distance(B.center,O);return zR.radius&&(B.extrema.length>=14&&y.normalize(S,y.sub(S,W,B.center)),y.scaleAndAdd(W,R.center,S,R.radius)),W}))}return R}e.expand=_;function C(R,B){return R.radius===B.radius&&y.exactEquals(R.center,B.center)}e.exactEquals=C;function D(R,B){var O=R.radius,z=B.radius;return Math.abs(O-z)<=Dr*Math.max(1,Math.abs(O),Math.abs(z))&&y.equals(R.center,B.center)}e.equals=D;function T(R,B){if(t(B)){for(var O=0,z=B.extrema;OR.radius)return!1}return!0}else return y.distance(R.center,B.center)+B.radius<=R.radius}e.includes=T;function A(R,B){return y.distance(R.center,B.center)<=R.radius+B.radius}e.overlaps=A;function E(R,B){return y.distance(R.center,B.center)-R.radius+B.radius}e.distance=E;function I(R,B){var O=R.center,z=R.radius;return y.distance(B,O)-z}e.distanceToVec=I})(xe||(xe={}));function gt(){return gt.zero()}(function(e){function t(A,E){return{min:A,max:E}}e.create=t;function r(){return{min:y(),max:y()}}e.zero=r;function n(A,E){return y.copy(A.min,E.min),y.copy(A.max,E.max),A}e.copy=n;function a(A){return n(r(),A)}e.clone=a;var i=y();function o(A,E){return xe.hasExtrema(E)&&E.extrema.length>=14?u(A,E.extrema):(y.set(i,E.radius,E.radius,E.radius),y.sub(A.min,E.center,i),y.add(A.max,E.center,i),A)}e.fromSphere3D=o;function s(A,E){for(var I=0,R=E.length;I=14?s(A,E.extrema):(v(A,y.subScalar(i,E.center,E.radius)),v(A,y.addScalar(i,E.center,E.radius)),A)}e.addSphere3D=c;function l(A,E){return y.clamp(i,E.center,A.min,A.max),y.squaredDistance(i,E.center)<=E.radius*E.radius}e.intersectsSphere3D=l;function f(A){for(var E=y.create(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),I=y.create(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),R=A.x,B=A.y,O=A.z,z=A.indices,k=0,G=Ee.size(z);kA.max[0]||E[1]A.max[1]||E[2]A.max[2])}e.containsVec3=_;function C(A,E){return!(A.max[0]E.max[0]||A.max[1]E.max[1]||A.max[2]E.max[2])}e.overlaps=C;function D(A,E){var I=E.center,R=E.radius;return!(I[0]-RA.max[0]||I[1]-RA.max[1]||I[2]-RA.max[2])}e.containsSphere3D=D;function T(A,E,I,R){var B=E.min,O=B[0],z=B[1],k=B[2],G=E.max,V=G[0],U=G[1],Q=G[2],W=I[0],X=I[1],ae=I[2],q=1/R[0],F=1/R[1],j=1/R[2],Z,Y,H,N,ee,oe;return q>=0?(Z=(O-W)*q,Y=(V-W)*q):(Z=(V-W)*q,Y=(O-W)*q),F>=0?(H=(z-X)*F,N=(U-X)*F):(H=(U-X)*F,N=(z-X)*F),j>=0?(ee=(k-ae)*j,oe=(Q-ae)*j):(ee=(Q-ae)*j,oe=(k-ae)*j),H>Z&&(Z=H),NZ&&(Z=ee),oe0)throw new Error("New key is larger than old key");t.key=r;var n=t.parent;n&&this._compare(t,n)<0&&(this._cut(t,n,this._minNode),this._cascadingCut(n,this._minNode)),this._compare(t,this._minNode)<0&&(this._minNode=t)},e.prototype.delete=function(t){var r=t.parent;r&&(this._cut(t,r,this._minNode),this._cascadingCut(r,this._minNode)),this._minNode=t,this.extractMinimum()},e.prototype.extractMinimum=function(){var t=this._minNode;if(t){if(t.child){var r=t.child;do r.parent=null,r=r.next;while(r!==t.child)}var n=null;t.next!==t&&(n=t.next),this._removeNodeFromList(t),this._nodeCount--,this._minNode=this._mergeLists(n,t.child),this._minNode&&(this._minNode=this._consolidate(this._minNode))}return t},e.prototype.findMinimum=function(){return this._minNode},e.prototype.insert=function(t,r){var n=new Lxe(t,r);return this._minNode=this._mergeLists(this._minNode,n),this._nodeCount++,n},e.prototype.isEmpty=function(){return this._minNode===null},e.prototype.size=function(){return this._minNode===null?0:this._getNodeListSize(this._minNode)},e.prototype.union=function(t){this._minNode=this._mergeLists(this._minNode,t._minNode),this._nodeCount+=t._nodeCount},e.prototype._defaultCompare=function(t,r){return t.key>r.key?1:t.key0){var i=n;n=a,a=i}this._linkHeaps(a,n),r[n.degree]=null,n.degree++,a=r[n.degree]}r[n.degree]=n}for(var o=null,s=0;sx&&(x=l[T])}for(var B=new Int32Array(S),T=0,O=0;T0&&(_[T]=O+1,B[O]=z,O+=1)}for(var k=new Uint32Array(S),T=1;T0){var Q=U-1;V[k[Q]+G[Q]]=T,G[Q]+=1}}return{size:e.size,bucketArray:V,bucketCounts:B,bucketOffset:k,grid:_,delta:m,min:e.expandedBox.min,data:e.data,maxRadius:x,expandedBox:e.expandedBox,boundingBox:e.boundingBox,boundingSphere:e.boundingSphere}}function Vxe(e,t,r){var n=gt.expand(gt(),t.box,y.create(.5,.5,.5)),a=e.indices,i=gt.size(y(),n),o,s,u=Ee.size(a),c=typeof r=="number"?r:32,l=Array.isArray(r)&&r;if(l&&!y.isZero(l))s=[Math.ceil(i[0]/l[0]),Math.ceil(i[1]/l[1]),Math.ceil(i[2]/l[2])],o=l;else if(u>0){var f=Math.ceil(u/c),d=Math.pow(f/(i[0]*i[1]*i[2]),1/3);s=[Math.ceil(i[0]*d),Math.ceil(i[1]*d),Math.ceil(i[2]*d)],o=[i[0]/s[0],i[1]/s[1],i[2]/s[2]]}else o=i,s=[1,1,1];var m={x:e.x,y:e.y,z:e.z,indices:a,radius:e.radius},h={size:s,data:m,expandedBox:n,boundingBox:t.box,boundingSphere:t.sphere,elementCount:u,delta:o};return Uxe(h)}function Gxe(e){return{grid:e,x:.1,y:.1,z:.1,k:1,stopIf:void 0,radius:.1,isCheck:!1}}function ZH(e,t){var r=e.grid,n=r.min,a=r.size,i=a[0],o=a[1],s=a[2],u=r.bucketOffset,c=r.bucketCounts,l=r.bucketArray,f=r.grid,d=r.data,m=d.x,h=d.y,p=d.z,v=d.indices,g=d.radius,b=r.delta,x=r.maxRadius,S=e.radius,_=e.isCheck,C=e.x,D=e.y,T=e.z,A=S+x,E=A*A;xu.reset(t);var I=Math.max(0,Math.floor((C-A-n[0])/b[0])),R=Math.max(0,Math.floor((D-A-n[1])/b[1])),B=Math.max(0,Math.floor((T-A-n[2])/b[2])),O=Math.min(i-1,Math.floor((C+A-n[0])/b[0])),z=Math.min(o-1,Math.floor((D+A-n[1])/b[1])),k=Math.min(s-1,Math.floor((T+A-n[2])/b[2]));if(I>O||R>z||B>k)return!1;for(var G=I;G<=O;G++)for(var V=R;V<=z;V++)for(var U=B;U<=k;U++){var Q=f[(G*o+V)*s+U];if(Q!==0)for(var W=Q-1,X=u[W],ae=c[W],q=X+ae,F=X;F0&&Math.sqrt(N)-g[j]>S)continue;if(_)return!0;xu.add(t,l[F],N)}}}return t.count>0}var QH=y(),tp=y(),rx=new Set,KM=new Set,zxe=[.1],Hxe=[.1],jxe=[.1],N0=new I_;function qxe(e,t){var r=e.grid,n=r.min,a=r.expandedBox,i=r.boundingSphere.center,o=r.size,s=o[0],u=o[1],c=o[2],l=r.bucketOffset,f=r.bucketCounts,d=r.bucketArray,m=r.grid,h=r.data,p=h.x,v=h.y,g=h.z,b=h.indices,x=h.radius,S=r.delta,_=r.maxRadius,C=e.x,D=e.y,T=e.z,A=e.k,E=e.stopIf,I=Ee.size(b);if(xu.reset(t),I===0||A<=0)return!1;var R,B,O,z=!1,k=1,G=!0,V=0,U=zxe,Q=Hxe,W=0,X=!0,ae,q=!1,F=jxe,j=_*_;U.length=0,F.length=0,rx.clear(),N0.clear(),y.set(tp,C,D,T),gt.containsVec3(a,tp)?(R=Math.floor((C-n[0])/S[0]),B=Math.floor((D-n[1])/S[1]),O=Math.floor((T-n[2])/S[2])):(gt.nearestIntersectionWithRay(tp,a,tp,y.normalize(QH,y.sub(QH,i,tp))),R=Math.max(0,Math.min(s-1,Math.floor((tp[0]-n[0])/S[0]))),B=Math.max(0,Math.min(u-1,Math.floor((tp[1]-n[1])/S[1]))),O=Math.max(0,Math.min(c-1,Math.floor((tp[2]-n[2])/S[2]))));var Z=_!==0?Math.max(1,Math.min(s-1,Math.ceil(_/S[0]))):1,Y=_!==0?Math.max(1,Math.min(u-1,Math.ceil(_/S[1]))):1,H=_!==0?Math.max(1,Math.min(c-1,Math.ceil(_/S[2]))):1;for(U.push(R,B,O,(R*u+B)*c+O);t.count=m.length;var oe=m[ae];if(oe!==0){for(var me=W,pe=oe-1,de=l[pe],re=f[pe],te=de+re,fe=de;feW&&(W=K),N0.insert(K,ve)}me=s))for(var ke=-Y;ke<=Y;ke++){var Ne=B+ke;if(!(Ne<0||Ne>=u))for(var Ve=-H;Ve<=H;Ve++){var et=O+Ve;if(!(et<0||et>=c)&&(ae=(Ie*u+Ne)*c+et,!KM.has(ae)&&(KM.add(ae),!rx.has(ae)))){if(!G){var Re=n[0]+Ie*S[0]-C,je=n[1]+Ne*S[1]-D,tt=n[2]+et*S[2]-T,ht=Re*Re+je*je+tt*tt-j;if(ht>W){F.push(Ie,Ne,et,ae);continue}}Q.push(Ie,Ne,et,ae),V++}}}}}if(G=!1,V===0){if(A===1){var ct=N0.findMinimum();if(ct){var xt=ct,_t=xt.key,Ue=xt.value;return xu.add(t,Ue,_t),!0}}else for(;!N0.isEmpty()&&(q||N0.findMinimum().key<=W)&&t.count=A||z||t.count>=I)return t.count>0;if(G=!0,X=!0,F.length>0){for(var fe=0,ut=F.length;fe0}function Wxe(e,t){for(var r=0,n=t*3;rthis.radiusSq&&(this.radiusSq=r)},e.prototype.radiusSphereStep=function(t,r){var n=Kxe(t,this.center)+r,a=n*n;a>this.radiusSq&&(this.radiusSq=a)},e.prototype.getSphere=function(t){return t||(t=xe()),y.copy(t.center,this.center),t.radius=Math.sqrt(this.radiusSq),t},e.prototype.getCount=function(){return this.count},e}();(function(e){var t=new e,r=y(),n=y();function a(s,u){var c=s.x,l=s.y,f=s.z;t.reset();for(var d=c.length,m=0;mthis.maxDist[t]&&(this.maxDist[t]=n,a7(this.extrema[t*2+1],r))},e.prototype.computeSphereExtrema=function(t,r,n){var a=this.dir[t],i=n7(a,r);i-nthis.maxDist[t]&&(this.maxDist[t]=i+n,Qxe(this.extrema[t*2+1],r,a,n))},e.prototype.includeSphere=function(t){if(xe.hasExtrema(t)&&t.extrema.length>1)for(var r=0,n=t.extrema;r1)for(var r=0,n=t.extrema;r0?Math.ceil(e/n):0;return{width:n,height:a,length:n*a*t}}function Vn(e,t,r,n){var a=rSe(e,t),i=a.length,o=a.width,s=a.height;return n=n&&n.length>=i?n:new r(i),{array:n,width:o,height:s}}var Vc=y(),nSe=new Di("14"),aSe=new Di("98");function o7(e){return e>1e5?nSe:aSe}function Cu(e,t,r){var n=r*3,a=o7(t);a.reset();for(var i=0,o=t*3;i>2),n=t-4>>2,a=4*n,i=0;if(n<0)for(var o=0;o>16]}for(var o=a;o 0.0 && uBumpAmplitude > 0.0 && bumpiness > 0.0) { + material.rgb += fbm(vModelPosition * uBumpFrequency) * uBumpAmplitude * bumpiness; + material.rgb -= 0.5 * uBumpAmplitude * bumpiness; + } + #endif + + gl_FragColor = material; +#else + #ifdef bumpEnabled + if (uBumpFrequency > 0.0 && uBumpAmplitude > 0.0 && bumpiness > 0.0) { + normal = perturbNormal(-vViewPosition, normal, fbm(vModelPosition * uBumpFrequency), (uBumpAmplitude * bumpiness) / uBumpFrequency); + } + #endif + + vec4 color = material; + + ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)); + + PhysicalMaterial physicalMaterial; + physicalMaterial.diffuseColor = color.rgb * (1.0 - metalness); + #ifdef enabledFragDepth + physicalMaterial.roughness = min(max(roughness, 0.0525), 1.0); + #else + vec3 dxy = max(abs(dFdx(normal)), abs(dFdy(normal))); + float geometryRoughness = max(max(dxy.x, dxy.y), dxy.z); + physicalMaterial.roughness = min(max(roughness, 0.0525) + geometryRoughness, 1.0); + #endif + physicalMaterial.specularColor = mix(vec3(0.04), color.rgb, metalness); + physicalMaterial.specularF90 = 1.0; + + GeometricContext geometry; + geometry.position = -vViewPosition; + geometry.normal = normal; + geometry.viewDir = normalize(vViewPosition); + + IncidentLight directLight; + #pragma unroll_loop_start + for (int i = 0; i < dLightCount; ++i) { + directLight.direction = uLightDirection[i]; + directLight.color = uLightColor[i] * PI; // * PI for punctual light + RE_Direct_Physical(directLight, geometry, physicalMaterial, reflectedLight); + } + #pragma unroll_loop_end + + vec3 irradiance = uAmbientColor * PI; // * PI for punctual light + RE_IndirectDiffuse_Physical(irradiance, geometry, physicalMaterial, reflectedLight); + + // indirect specular only metals + vec3 radiance = uAmbientColor * metalness; + vec3 iblIrradiance = uAmbientColor * metalness; + vec3 clearcoatRadiance = vec3(0.0); + RE_IndirectSpecular_Physical(radiance, iblIrradiance, clearcoatRadiance, geometry, physicalMaterial, reflectedLight); + + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular; + outgoingLight = clamp(outgoingLight, 0.01, 0.99); // prevents black artifacts on specular highlight with transparent background + + gl_FragColor = vec4(outgoingLight, color.a); +#endif + +#if defined(dXrayShaded_on) + gl_FragColor.a *= 1.0 - pow(abs(dot(normal, vec3(0.0, 0.0, 1.0))), uXrayEdgeFalloff); +#elif defined(dXrayShaded_inverted) + gl_FragColor.a *= pow(abs(dot(normal, vec3(0.0, 0.0, 1.0))), uXrayEdgeFalloff); +#endif + +gl_FragColor.rgb *= uExposure; +`;var z7=` + +#if defined(dColorMarker) + if (marker > 0.0) { + if ((uMarkerPriority == 1 && marker != 2.0) || (uMarkerPriority != 1 && marker == 1.0)) { + gl_FragColor.rgb = mix(gl_FragColor.rgb, uHighlightColor, uHighlightStrength); + gl_FragColor.a = max(gl_FragColor.a, uHighlightStrength * 0.002); // for direct-volume rendering + } else { + gl_FragColor.rgb = mix(gl_FragColor.rgb, uSelectColor, uSelectStrength); + gl_FragColor.a = max(gl_FragColor.a, uSelectStrength * 0.002); // for direct-volume rendering + } + } else if (uMarkerAverage > 0.0) { + gl_FragColor.rgb = mix(gl_FragColor.rgb, uDimColor, uDimStrength); + gl_FragColor.a = max(gl_FragColor.a, uDimStrength * 0.002); // for direct-volume rendering + } +#endif +`;var H7=` +#if dClipObjectCount != 0 && defined(dClipping) + #if defined(dClippingType_instance) + vClipping = readFromTexture(tClipping, aInstance, uClippingTexDim).a; + #elif defined(dMarkerType_groupInstance) + vClipping = readFromTexture(tClipping, aInstance * float(uGroupCount) + group, uClippingTexDim).a; + #endif +#endif +`;var j7=` +#if defined(dRenderVariant_color) + #if defined(dColorType_attribute) + vColor.rgb = aColor; + #elif defined(dColorType_instance) + vColor.rgb = readFromTexture(tColor, aInstance, uColorTexDim).rgb; + #elif defined(dColorType_group) + vColor.rgb = readFromTexture(tColor, group, uColorTexDim).rgb; + #elif defined(dColorType_groupInstance) + vColor.rgb = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim).rgb; + #elif defined(dColorType_vertex) + vColor.rgb = readFromTexture(tColor, VertexID, uColorTexDim).rgb; + #elif defined(dColorType_vertexInstance) + vColor.rgb = readFromTexture(tColor, int(aInstance) * uVertexCount + VertexID, uColorTexDim).rgb; + #elif defined(dColorType_volume) + vec3 cgridPos = (uColorGridTransform.w * (position - uColorGridTransform.xyz)) / uColorGridDim; + vColor.rgb = texture3dFrom2dLinear(tColorGrid, cgridPos, uColorGridDim, uColorTexDim).rgb; + #elif defined(dColorType_volumeInstance) + vec3 cgridPos = (uColorGridTransform.w * (vModelPosition - uColorGridTransform.xyz)) / uColorGridDim; + vColor.rgb = texture3dFrom2dLinear(tColorGrid, cgridPos, uColorGridDim, uColorTexDim).rgb; + #endif + + #ifdef dUsePalette + vPaletteV = ((vColor.r * 256.0 * 256.0 * 255.0 + vColor.g * 256.0 * 255.0 + vColor.b * 255.0) - 1.0) / 16777215.0; + #endif + + #ifdef dOverpaint + #if defined(dOverpaintType_instance) + vOverpaint = readFromTexture(tOverpaint, aInstance, uOverpaintTexDim); + #elif defined(dOverpaintType_groupInstance) + vOverpaint = readFromTexture(tOverpaint, aInstance * float(uGroupCount) + group, uOverpaintTexDim); + #elif defined(dOverpaintType_vertexInstance) + vOverpaint = readFromTexture(tOverpaint, int(aInstance) * uVertexCount + VertexID, uOverpaintTexDim); + #elif defined(dOverpaintType_volumeInstance) + vec3 ogridPos = (uOverpaintGridTransform.w * (vModelPosition - uOverpaintGridTransform.xyz)) / uOverpaintGridDim; + vOverpaint = texture3dFrom2dLinear(tOverpaintGrid, ogridPos, uOverpaintGridDim, uOverpaintTexDim); + #endif + + // pre-mix to avoid darkening due to empty overpaint + #ifdef dColorType_uniform + vOverpaint.rgb = mix(uColor.rgb, vOverpaint.rgb, vOverpaint.a); + #else + vOverpaint.rgb = mix(vColor.rgb, vOverpaint.rgb, vOverpaint.a); + #endif + vOverpaint *= uOverpaintStrength; + #endif + + #ifdef dSubstance + #if defined(dSubstanceType_instance) + vSubstance = readFromTexture(tSubstance, aInstance, uSubstanceTexDim); + #elif defined(dSubstanceType_groupInstance) + vSubstance = readFromTexture(tSubstance, aInstance * float(uGroupCount) + group, uSubstanceTexDim); + #elif defined(dSubstanceType_vertexInstance) + vSubstance = readFromTexture(tSubstance, int(aInstance) * uVertexCount + VertexID, uSubstanceTexDim); + #elif defined(dSubstanceType_volumeInstance) + vec3 sgridPos = (uSubstanceGridTransform.w * (vModelPosition - uSubstanceGridTransform.xyz)) / uSubstanceGridDim; + vSubstance = texture3dFrom2dLinear(tSubstanceGrid, sgridPos, uSubstanceGridDim, uSubstanceTexDim); + #endif + + // pre-mix to avoid artifacts due to empty substance + vSubstance.rgb = mix(vec3(uMetalness, uRoughness, uBumpiness), vSubstance.rgb, vSubstance.a); + vSubstance *= uSubstanceStrength; + #endif +#elif defined(dRenderVariant_pick) + #ifdef requiredDrawBuffers + vObject = vec4(packIntToRGB(float(uObjectId)), 1.0); + vInstance = vec4(packIntToRGB(aInstance), 1.0); + vGroup = vec4(packIntToRGB(group), 1.0); + #else + if (uPickType == 1) { + vColor = vec4(packIntToRGB(float(uObjectId)), 1.0); + } else if (uPickType == 2) { + vColor = vec4(packIntToRGB(aInstance), 1.0); + } else { + vColor = vec4(packIntToRGB(group), 1.0); + } + #endif +#endif + +#ifdef dTransparency + #if defined(dTransparencyType_instance) + vTransparency = readFromTexture(tTransparency, aInstance, uTransparencyTexDim).a; + #elif defined(dTransparencyType_groupInstance) + vTransparency = readFromTexture(tTransparency, aInstance * float(uGroupCount) + group, uTransparencyTexDim).a; + #elif defined(dTransparencyType_vertexInstance) + vTransparency = readFromTexture(tTransparency, int(aInstance) * uVertexCount + VertexID, uTransparencyTexDim).a; + #elif defined(dTransparencyType_volumeInstance) + vec3 tgridPos = (uTransparencyGridTransform.w * (vModelPosition - uTransparencyGridTransform.xyz)) / uTransparencyGridDim; + vTransparency = texture3dFrom2dLinear(tTransparencyGrid, tgridPos, uTransparencyGridDim, uTransparencyTexDim).a; + #endif + vTransparency *= uTransparencyStrength; +#endif +`;var q7=` +#ifdef dGeometryType_textureMesh + float group = unpackRGBToInt(readFromTexture(tGroup, VertexID, uGeoTexDim).rgb); +#else + float group = aGroup; +#endif +`;var W7=` +#if defined(dNeedsMarker) + #if defined(dMarkerType_instance) + vMarker = readFromTexture(tMarker, aInstance, uMarkerTexDim).a; + #elif defined(dMarkerType_groupInstance) + vMarker = readFromTexture(tMarker, aInstance * float(uGroupCount) + group, uMarkerTexDim).a; + #endif +#endif +`;var Y7=` +#if defined(dNeedsMarker) + float marker = uMarker; + if (uMarker == -1.0) { + marker = floor(vMarker * 255.0 + 0.5); // rounding required to work on some cards on win + } +#endif + +#if defined(dRenderVariant_color) + #if defined(dUsePalette) + vec4 material = vec4(texture2D(tPalette, vec2(vPaletteV, 0.5)).rgb, uAlpha); + #elif defined(dColorType_uniform) + vec4 material = vec4(uColor, uAlpha); + #elif defined(dColorType_varying) + vec4 material = vec4(vColor.rgb, uAlpha); + #endif + + // mix material with overpaint + #if defined(dOverpaint) + material.rgb = mix(material.rgb, vOverpaint.rgb, vOverpaint.a); + #endif + + float metalness = uMetalness; + float roughness = uRoughness; + float bumpiness = uBumpiness; + #ifdef dSubstance + metalness = mix(metalness, vSubstance.r, vSubstance.a); + roughness = mix(roughness, vSubstance.g, vSubstance.a); + bumpiness = mix(bumpiness, vSubstance.b, vSubstance.a); + #endif +#elif defined(dRenderVariant_depth) + if (fragmentDepth > getDepth(gl_FragCoord.xy / uDrawingBufferSize)) { + discard; + } + + #ifndef dXrayShaded + #if defined(dTransparency) + float dta = 1.0 - vTransparency; + if (vTransparency < 0.2) dta = 1.0; // hard cutoff looks better + + if (uRenderMask == MaskTransparent && uAlpha * dta == 1.0) { + discard; + } else if (uRenderMask == MaskOpaque && uAlpha * dta < 1.0) { + discard; + } + #else + if (uRenderMask == MaskTransparent && uAlpha == 1.0) { + discard; + } else if (uRenderMask == MaskOpaque && uAlpha < 1.0) { + discard; + } + #endif + #else + if (uRenderMask == MaskOpaque) { + discard; + } + #endif + + vec4 material = packDepthToRGBA(fragmentDepth); +#elif defined(dRenderVariant_marking) + vec4 material; + if(uMarkingType == 1) { + if (marker > 0.0) + discard; + #ifdef enabledFragDepth + material = packDepthToRGBA(gl_FragDepthEXT); + #else + material = packDepthToRGBA(gl_FragCoord.z); + #endif + } else { + if (marker == 0.0) + discard; + float depthTest = 1.0; + if (uMarkingDepthTest) { + depthTest = (fragmentDepth >= getDepthPacked(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0; + } + bool isHighlight = intMod(marker, 2.0) > 0.1; + float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar); + float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ)); + if (fogFactor == 1.0) + discard; + material = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0 - fogFactor); + } +#endif + +// apply per-group transparency +#if defined(dTransparency) && (defined(dRenderVariant_pick) || defined(dRenderVariant_color)) + float ta = 1.0 - vTransparency; + if (vTransparency < 0.09) ta = 1.0; // hard cutoff looks better + + #if defined(dRenderVariant_pick) + if (ta < uPickingAlphaThreshold) + discard; // ignore so the element below can be picked + #elif defined(dRenderVariant_color) + material.a *= ta; + + #if defined(dRenderVariant_colorBlended) + #if defined(dTransparentBackfaces_off) + if ((uRenderMask == MaskOpaque && material.a < 1.0) || + (uRenderMask == MaskTransparent && material.a == 1.0) || + (interior && material.a < 1.0) + ) { + discard; + } + #elif defined(dTransparentBackfaces_on) + if ((uRenderMask == MaskOpaque && material.a < 1.0) || + (uRenderMask == MaskTransparent && material.a == 1.0) + ) { + discard; + } + #elif defined(dTransparentBackfaces_opaque) + if (interior) { + material.a = 1.0; + } else if ( + (uRenderMask == MaskOpaque && material.a < 1.0) || + (uRenderMask == MaskTransparent && material.a == 1.0) + ) { + discard; + } + #endif + #endif + #endif +#endif +`;var X7=` +mat4 model = uModel * aTransform; +mat4 modelView = uView * model; +#ifdef dGeometryType_textureMesh + vec3 position = readFromTexture(tPosition, VertexID, uGeoTexDim).xyz; +#else + vec3 position = aPosition; +#endif +vec4 position4 = vec4(position, 1.0); +// for accessing tColorGrid in vert shader and for clipping in frag shader +vModelPosition = (model * position4).xyz; +vec4 mvPosition = modelView * position4; +vViewPosition = mvPosition.xyz; +gl_Position = uProjection * mvPosition; +`;var K7=` +#if defined(dSizeType_uniform) + float size = uSize; +#elif defined(dSizeType_attribute) + float size = aSize; +#elif defined(dSizeType_instance) + float size = unpackRGBToInt(readFromTexture(tSize, aInstance, uSizeTexDim).rgb); +#elif defined(dSizeType_group) + float size = unpackRGBToInt(readFromTexture(tSize, group, uSizeTexDim).rgb); +#elif defined(dSizeType_groupInstance) + float size = unpackRGBToInt(readFromTexture(tSize, aInstance * float(uGroupCount) + group, uSizeTexDim).rgb); +#endif + +#if defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance) + size /= 100.0; // NOTE factor also set in TypeScript +#endif + +size *= uSizeFactor; +`;var Z7=` +float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar); +float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ)); +float alpha = (1.0 - fogFactor) * uAlpha; +// if not opaque enough ignore so the element below can be picked +if (uAlpha < uPickingAlphaThreshold || alpha < 0.1) { + #ifdef dTransparentBackfaces_opaque + if (!interior) discard; + #else + discard; + #endif +} +`;var Q7=` +#if defined(dClipVariant_instance) && dClipObjectCount != 0 + vec4 mCenter = uModel * aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0); + if (clipTest(vec4(mCenter.xyz, uInvariantBoundingSphere.w))) + // move out of [ -w, +w ] to 'discard' in vert shader + gl_Position.z = 2.0 * gl_Position.w; +#endif +`;var $7=` +#if defined(dClipVariant_pixel) && dClipObjectCount != 0 + if (clipTest(vec4(vModelPosition, 0.0))) + discard; +#endif +`;var J7=` +uniform float uMetalness; +uniform float uRoughness; +uniform float uBumpiness; +#ifdef bumpEnabled + uniform float uBumpFrequency; + uniform float uBumpAmplitude; +#endif + +#if defined(dRenderVariant_color) + #if defined(dColorType_uniform) + uniform vec3 uColor; + #elif defined(dColorType_varying) + varying vec4 vColor; + #endif + + #ifdef dUsePalette + uniform sampler2D tPalette; + varying float vPaletteV; + #endif + + #ifdef dOverpaint + varying vec4 vOverpaint; + #endif + + #ifdef dSubstance + varying vec4 vSubstance; + #endif +#elif defined(dRenderVariant_pick) + #if __VERSION__ == 100 || !defined(dVaryingGroup) + #ifdef requiredDrawBuffers + varying vec4 vObject; + varying vec4 vInstance; + varying vec4 vGroup; + #else + varying vec4 vColor; + #endif + #else + #ifdef requiredDrawBuffers + flat in vec4 vObject; + flat in vec4 vInstance; + flat in vec4 vGroup; + #else + flat in vec4 vColor; + #endif + #endif +#endif + +#ifdef dTransparency + varying float vTransparency; +#endif +`;var e9=` +uniform float uMetalness; +uniform float uRoughness; +uniform float uBumpiness; + +#if defined(dRenderVariant_color) + #if defined(dColorType_uniform) + uniform vec3 uColor; + #elif defined(dColorType_attribute) + varying vec4 vColor; + attribute vec3 aColor; + #elif defined(dColorType_texture) + varying vec4 vColor; + uniform vec2 uColorTexDim; + uniform sampler2D tColor; + #elif defined(dColorType_grid) + varying vec4 vColor; + uniform vec2 uColorTexDim; + uniform vec3 uColorGridDim; + uniform vec4 uColorGridTransform; + uniform sampler2D tColorGrid; + #elif defined(dColorType_direct) + varying vec4 vColor; + #endif + + #ifdef dUsePalette + varying float vPaletteV; + #endif + + #ifdef dOverpaint + #if defined(dOverpaintType_instance) || defined(dOverpaintType_groupInstance) || defined(dOverpaintType_vertexInstance) + varying vec4 vOverpaint; + uniform vec2 uOverpaintTexDim; + uniform sampler2D tOverpaint; + #elif defined(dOverpaintType_volumeInstance) + varying vec4 vOverpaint; + uniform vec2 uOverpaintTexDim; + uniform vec3 uOverpaintGridDim; + uniform vec4 uOverpaintGridTransform; + uniform sampler2D tOverpaintGrid; + #endif + uniform float uOverpaintStrength; + #endif + + #ifdef dSubstance + #if defined(dSubstanceType_instance) || defined(dSubstanceType_groupInstance) || defined(dSubstanceType_vertexInstance) + varying vec4 vSubstance; + uniform vec2 uSubstanceTexDim; + uniform sampler2D tSubstance; + #elif defined(dSubstanceType_volumeInstance) + varying vec4 vSubstance; + uniform vec2 uSubstanceTexDim; + uniform vec3 uSubstanceGridDim; + uniform vec4 uSubstanceGridTransform; + uniform sampler2D tSubstanceGrid; + #endif + uniform float uSubstanceStrength; + #endif +#elif defined(dRenderVariant_pick) + #if __VERSION__ == 100 || !defined(dVaryingGroup) + #ifdef requiredDrawBuffers + varying vec4 vObject; + varying vec4 vInstance; + varying vec4 vGroup; + #else + varying vec4 vColor; + #endif + #else + #ifdef requiredDrawBuffers + flat out vec4 vObject; + flat out vec4 vInstance; + flat out vec4 vGroup; + #else + flat out vec4 vColor; + #endif + #endif +#endif + +#ifdef dTransparency + #if defined(dTransparencyType_instance) || defined(dTransparencyType_groupInstance) || defined(dTransparencyType_vertexInstance) + varying float vTransparency; + uniform vec2 uTransparencyTexDim; + uniform sampler2D tTransparency; + #elif defined(dTransparencyType_volumeInstance) + varying float vTransparency; + uniform vec2 uTransparencyTexDim; + uniform vec3 uTransparencyGridDim; + uniform vec4 uTransparencyGridTransform; + uniform sampler2D tTransparencyGrid; + #endif + uniform float uTransparencyStrength; +#endif +`;var t9=` +#if dClipObjectCount != 0 + vec3 quaternionTransform(const in vec4 q, const in vec3 v) { + vec3 t = 2.0 * cross(q.xyz, v); + return v + q.w * t + cross(q.xyz, t); + } + + vec4 computePlane(const in vec3 normal, const in vec3 inPoint) { + return vec4(normalize(normal), -dot(normal, inPoint)); + } + + float planeSD(const in vec4 plane, const in vec3 center) { + return -dot(plane.xyz, center - plane.xyz * -plane.w); + } + + float sphereSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in vec3 center) { + return ( + length(quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position) / size) - 1.0 + ) * min(min(size.x, size.y), size.z); + } + + float cubeSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in vec3 center) { + vec3 d = abs(quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position)) - size; + return min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0)); + } + + float cylinderSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in vec3 center) { + vec3 t = quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position); + + vec2 d = abs(vec2(length(t.xz), t.y)) - size.xy; + return min(max(d.x, d.y), 0.0) + length(max(d, 0.0)); + } + + float infiniteConeSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in vec3 center) { + vec3 t = quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position); + + float q = length(t.xy); + return dot(size.xy, vec2(q, t.z)); + } + + float getSignedDistance(const in vec3 center, const in int type, const in vec3 position, const in vec4 rotation, const in vec3 scale) { + if (type == 1) { + vec3 normal = quaternionTransform(rotation, vec3(0.0, 1.0, 0.0)); + vec4 plane = computePlane(normal, position); + return planeSD(plane, center); + } else if (type == 2) { + return sphereSD(position, rotation, scale * 0.5, center); + } else if (type == 3) { + return cubeSD(position, rotation, scale * 0.5, center); + } else if (type == 4) { + return cylinderSD(position, rotation, scale * 0.5, center); + } else if (type == 5) { + return infiniteConeSD(position, rotation, scale * 0.5, center); + } else { + return 0.1; + } + } + + #if __VERSION__ == 100 + // 8-bit + int bitwiseAnd(in int a, in int b) { + int d = 128; + int result = 0; + for (int i = 0; i < 8; ++i) { + if (d <= 0) break; + if (a >= d && b >= d) result += d; + if (a >= d) a -= d; + if (b >= d) b -= d; + d /= 2; + } + return result; + } + + bool hasBit(const in int mask, const in int bit) { + return bitwiseAnd(mask, bit) == 0; + } + #else + bool hasBit(const in int mask, const in int bit) { + return (mask & bit) == 0; + } + #endif + + bool clipTest(const in vec4 sphere) { + // flag is a bit-flag for clip-objects to ignore (note, object ids start at 1 not 0) + #if defined(dClipping) + int flag = int(floor(vClipping * 255.0 + 0.5)); + #else + int flag = 0; + #endif + + #pragma unroll_loop_start + for (int i = 0; i < dClipObjectCount; ++i) { + if (flag == 0 || hasBit(flag, UNROLLED_LOOP_INDEX + 1)) { + // TODO take sphere radius into account? + bool test = getSignedDistance(sphere.xyz, uClipObjectType[i], uClipObjectPosition[i], uClipObjectRotation[i], uClipObjectScale[i]) <= 0.0; + if ((!uClipObjectInvert[i] && test) || (uClipObjectInvert[i] && !test)) { + return true; + } + } + } + #pragma unroll_loop_end + return false; + } +#endif +`;var r9=` +uniform int uObjectId; +uniform int uInstanceCount; +uniform int uGroupCount; + +uniform int uPickType; +uniform int uMarkingType; + +#if dClipObjectCount != 0 + uniform int uClipObjectType[dClipObjectCount]; + uniform bool uClipObjectInvert[dClipObjectCount]; + uniform vec3 uClipObjectPosition[dClipObjectCount]; + uniform vec4 uClipObjectRotation[dClipObjectCount]; + uniform vec3 uClipObjectScale[dClipObjectCount]; + + #if defined(dClipping) + #if __VERSION__ == 100 || defined(dClippingType_instance) || !defined(dVaryingGroup) + varying float vClipping; + #else + flat in float vClipping; + #endif + #endif +#endif + +#if defined(dColorMarker) + uniform vec3 uHighlightColor; + uniform vec3 uSelectColor; + uniform vec3 uDimColor; + uniform float uHighlightStrength; + uniform float uSelectStrength; + uniform float uDimStrength; + uniform int uMarkerPriority; + uniform float uMarkerAverage; +#endif + +#if defined(dNeedsMarker) + uniform float uMarker; + #if __VERSION__ == 100 || defined(dMarkerType_instance) || !defined(dVaryingGroup) + varying float vMarker; + #else + flat in float vMarker; + #endif +#endif + +#if defined(dRenderVariant_colorDpoit) + #define MAX_DPOIT_DEPTH 99999.0 // NOTE constant also set in TypeScript + uniform sampler2D tDpoitDepth; + uniform sampler2D tDpoitFrontColor; +#endif + +varying vec3 vModelPosition; +varying vec3 vViewPosition; + +uniform vec2 uViewOffset; + +uniform float uNear; +uniform float uFar; +uniform float uIsOrtho; + +uniform bool uFog; +uniform float uFogNear; +uniform float uFogFar; +uniform vec3 uFogColor; + +uniform float uAlpha; +uniform float uPickingAlphaThreshold; +uniform bool uTransparentBackground; + +uniform bool uDoubleSided; +uniform float uInteriorDarkening; +uniform bool uInteriorColorFlag; +uniform vec3 uInteriorColor; +bool interior; + +uniform float uXrayEdgeFalloff; +uniform float uExposure; + +uniform mat4 uProjection; + +uniform int uRenderMask; +uniform bool uMarkingDepthTest; + +uniform sampler2D tDepth; +uniform vec2 uDrawingBufferSize; + +float getDepthPacked(const in vec2 coords) { + return unpackRGBAToDepth(texture2D(tDepth, coords)); +} + +float getDepth(const in vec2 coords) { + #ifdef depthTextureSupport + return texture2D(tDepth, coords).r; + #else + return unpackRGBAToDepth(texture2D(tDepth, coords)); + #endif +} + +float calcDepth(const in vec3 pos) { + vec2 clipZW = pos.z * uProjection[2].zw + uProjection[3].zw; + return 0.5 + 0.5 * clipZW.x / clipZW.y; +} + +// "Bump Mapping Unparametrized Surfaces on the GPU" Morten S. Mikkelsen +// https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf +vec3 perturbNormal(in vec3 position, in vec3 normal, in float height, in float scale) { + vec3 sigmaS = dFdx(position); + vec3 sigmaT = dFdy(position); + + vec3 r1 = cross(sigmaT, normal); + vec3 r2 = cross(normal, sigmaS); + float det = dot(sigmaS, r1); + + float bs = dFdx(height); + float bt = dFdy(height); + + vec3 surfGrad = sign(det) * (bs * r1 + bt * r2); + return normalize(abs(det) * normal - scale * surfGrad); +} + +float hash(in float h) { + return fract(sin(h) * 43758.5453123); +} + +float noise(in vec3 x) { + vec3 p = floor(x); + vec3 f = fract(x); + f = f * f * (3.0 - 2.0 * f); + + float n = p.x + p.y * 157.0 + 113.0 * p.z; + return mix( + mix(mix(hash(n + 0.0), hash(n + 1.0), f.x), + mix(hash(n + 157.0), hash(n + 158.0), f.x), f.y), + mix(mix(hash(n + 113.0), hash(n + 114.0), f.x), + mix(hash(n + 270.0), hash(n + 271.0), f.x), f.y), f.z); +} + +float fbm(in vec3 p) { + float f = 0.0; + f += 0.5 * noise(p); + p *= 2.01; + f += 0.25 * noise(p); + p *= 2.02; + f += 0.125 * noise(p); + + return f; +} +`;var n9=` +uniform mat4 uProjection, uModel, uView; +uniform vec3 uCameraPosition; + +uniform int uObjectId; +uniform int uVertexCount; +uniform int uInstanceCount; +uniform int uGroupCount; +uniform vec4 uInvariantBoundingSphere; + +uniform bool uDoubleSided; +uniform int uPickType; + +#if dClipObjectCount != 0 + uniform int uClipObjectType[dClipObjectCount]; + uniform bool uClipObjectInvert[dClipObjectCount]; + uniform vec3 uClipObjectPosition[dClipObjectCount]; + uniform vec4 uClipObjectRotation[dClipObjectCount]; + uniform vec3 uClipObjectScale[dClipObjectCount]; + + #if defined(dClipping) + uniform vec2 uClippingTexDim; + uniform sampler2D tClipping; + #if __VERSION__ == 100 || defined(dClippingType_instance) || !defined(dVaryingGroup) + varying float vClipping; + #else + flat out float vClipping; + #endif + #endif +#endif + +#if defined(dNeedsMarker) + uniform float uMarker; + uniform vec2 uMarkerTexDim; + uniform sampler2D tMarker; + #if __VERSION__ == 100 || defined(dMarkerType_instance) || !defined(dVaryingGroup) + varying float vMarker; + #else + flat out float vMarker; + #endif +#endif + +varying vec3 vModelPosition; +varying vec3 vViewPosition; + +#if defined(noNonInstancedActiveAttribs) + // int() is needed for some Safari versions + // see https://bugs.webkit.org/show_bug.cgi?id=244152 + #define VertexID int(gl_VertexID) +#else + attribute float aVertex; + #define VertexID int(aVertex) +#endif +`;var a9=` +// TODO find a better place for these convenience defines + +#if defined(dRenderVariant_colorBlended) || defined(dRenderVariant_colorWboit) || defined(dRenderVariant_colorDpoit) + #define dRenderVariant_color +#endif + +#if defined(dColorType_instance) || defined(dColorType_group) || defined(dColorType_groupInstance) || defined(dColorType_vertex) || defined(dColorType_vertexInstance) + #define dColorType_texture +#endif + +#if defined(dColorType_volume) || defined(dColorType_volumeInstance) + #define dColorType_grid +#endif + +#if defined(dColorType_attribute) || defined(dColorType_texture) || defined(dColorType_grid) + #define dColorType_varying +#endif + +#if (defined(dRenderVariant_color) && defined(dColorMarker)) || defined(dRenderVariant_marking) + #define dNeedsMarker +#endif + +#if defined(dXrayShaded_on) || defined(dXrayShaded_inverted) + #define dXrayShaded +#endif + +#define MaskAll 0 +#define MaskOpaque 1 +#define MaskTransparent 2 + +// + +#define PI 3.14159265 +#define RECIPROCAL_PI 0.31830988618 +#define EPSILON 1e-6 + +#define saturate(a) clamp(a, 0.0, 1.0) + +#if __VERSION__ == 100 + #define round(x) floor((x) + 0.5) +#endif + +float intDiv(const in float a, const in float b) { return float(int(a) / int(b)); } +vec2 ivec2Div(const in vec2 a, const in vec2 b) { return vec2(ivec2(a) / ivec2(b)); } +float intMod(const in float a, const in float b) { return a - b * float(int(a) / int(b)); } +int imod(const in int a, const in int b) { return a - b * (a / b); } + +float pow2(const in float x) { return x * x; } + +vec3 packIntToRGB(in float value) { + value = clamp(round(value), 0.0, 16777216.0 - 1.0) + 1.0; + vec3 c = vec3(0.0); + c.b = mod(value, 256.0); + value = floor(value / 256.0); + c.g = mod(value, 256.0); + value = floor(value / 256.0); + c.r = mod(value, 256.0); + return c / 255.0; +} +float unpackRGBToInt(const in vec3 rgb) { + return (floor(rgb.r * 255.0 + 0.5) * 256.0 * 256.0 + floor(rgb.g * 255.0 + 0.5) * 256.0 + floor(rgb.b * 255.0 + 0.5)) - 1.0; +} + +vec2 packUnitIntervalToRG(const in float v) { + vec2 enc; + enc.xy = vec2(fract(v * 256.0), v); + enc.y -= enc.x * (1.0 / 256.0); + enc.xy *= 256.0 / 255.0; + + return enc; +} + +float unpackRGToUnitInterval(const in vec2 enc) { + return dot(enc, vec2(255.0 / (256.0 * 256.0), 255.0 / 256.0)); +} + +vec3 screenSpaceToViewSpace(const in vec3 ssPos, const in mat4 invProjection) { + vec4 p = vec4(ssPos * 2.0 - 1.0, 1.0); + p = invProjection * p; + return p.xyz / p.w; +} + +const float PackUpscale = 256.0 / 255.0; // fraction -> 0..1 (including 1) +const float UnpackDownscale = 255.0 / 256.0; // 0..1 -> fraction (excluding 1) +const vec3 PackFactors = vec3(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0); +const vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.0); +const float ShiftRight8 = 1.0 / 256.0; + +vec4 packDepthToRGBA(const in float v) { + vec4 r = vec4(fract(v * PackFactors), v); + r.yzw -= r.xyz * ShiftRight8; // tidy overflow + return r * PackUpscale; +} +float unpackRGBAToDepth(const in vec4 v) { + return dot(v, UnpackFactors); +} + +vec4 sRGBToLinear(const in vec4 c) { + return vec4(mix(pow(c.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), c.rgb * 0.0773993808, vec3(lessThanEqual(c.rgb, vec3(0.04045)))), c.a); +} +vec4 linearTosRGB(const in vec4 c) { + return vec4(mix(pow(c.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), c.rgb * 12.92, vec3(lessThanEqual(c.rgb, vec3(0.0031308)))), c.a); +} + +float linearizeDepth(const in float depth, const in float near, const in float far) { + return (2.0 * near) / (far + near - depth * (far - near)); +} + +float perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) { + return (near * far) / ((far - near) * invClipZ - far); +} + +float orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) { + return linearClipZ * (near - far) - near; +} + +float depthToViewZ(const in float isOrtho, const in float linearClipZ, const in float near, const in float far) { + return isOrtho == 1.0 ? orthographicDepthToViewZ(linearClipZ, near, far) : perspectiveDepthToViewZ(linearClipZ, near, far); +} + +#if __VERSION__ == 100 + // transpose + + float transpose(const in float m) { + return m; + } + + mat2 transpose2(const in mat2 m) { + return mat2( + m[0][0], m[1][0], + m[0][1], m[1][1] + ); + } + + mat3 transpose3(const in mat3 m) { + return mat3( + m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2] + ); + } + + mat4 transpose4(const in mat4 m) { + return mat4( + m[0][0], m[1][0], m[2][0], m[3][0], + m[0][1], m[1][1], m[2][1], m[3][1], + m[0][2], m[1][2], m[2][2], m[3][2], + m[0][3], m[1][3], m[2][3], m[3][3] + ); + } + + // inverse + + float inverse(const in float m) { + return 1.0 / m; + } + + mat2 inverse2(const in mat2 m) { + return mat2(m[1][1],-m[0][1], + -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]); + } + + mat3 inverse3(const in mat3 m) { + float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2]; + float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2]; + float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2]; + + float b01 = a22 * a11 - a12 * a21; + float b11 = -a22 * a10 + a12 * a20; + float b21 = a21 * a10 - a11 * a20; + + float det = a00 * b01 + a01 * b11 + a02 * b21; + + return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11), + b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10), + b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det; + } + + mat4 inverse4(const in mat4 m) { + float + a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3], + a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3], + a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3], + a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3], + + b00 = a00 * a11 - a01 * a10, + b01 = a00 * a12 - a02 * a10, + b02 = a00 * a13 - a03 * a10, + b03 = a01 * a12 - a02 * a11, + b04 = a01 * a13 - a03 * a11, + b05 = a02 * a13 - a03 * a12, + b06 = a20 * a31 - a21 * a30, + b07 = a20 * a32 - a22 * a30, + b08 = a20 * a33 - a23 * a30, + b09 = a21 * a32 - a22 * a31, + b10 = a21 * a33 - a23 * a31, + b11 = a22 * a33 - a23 * a32, + + det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + return mat4( + a11 * b11 - a12 * b10 + a13 * b09, + a02 * b10 - a01 * b11 - a03 * b09, + a31 * b05 - a32 * b04 + a33 * b03, + a22 * b04 - a21 * b05 - a23 * b03, + a12 * b08 - a10 * b11 - a13 * b07, + a00 * b11 - a02 * b08 + a03 * b07, + a32 * b02 - a30 * b05 - a33 * b01, + a20 * b05 - a22 * b02 + a23 * b01, + a10 * b10 - a11 * b08 + a13 * b06, + a01 * b08 - a00 * b10 - a03 * b06, + a30 * b04 - a31 * b02 + a33 * b00, + a21 * b02 - a20 * b04 - a23 * b00, + a11 * b07 - a10 * b09 - a12 * b06, + a00 * b09 - a01 * b07 + a02 * b06, + a31 * b01 - a30 * b03 - a32 * b00, + a20 * b03 - a21 * b01 + a22 * b00) / det; + } + + #define isNaN(x) ((x) != (x)) + #define isInf(x) ((x) == (x) + 1.0) +#else + #define transpose2(m) transpose(m) + #define transpose3(m) transpose(m) + #define transpose4(m) transpose(m) + + #define inverse2(m) inverse(m) + #define inverse3(m) inverse(m) + #define inverse4(m) inverse(m) + + #define isNaN isnan + #define isInf isinf +#endif +`;var i9=` + // floatToRgba adapted from https://github.com/equinor/glsl-float-to-rgba + // MIT License, Copyright (c) 2020 Equinor + + float shiftRight (float v, float amt) { + v = floor(v) + 0.5; + return floor(v / exp2(amt)); + } + float shiftLeft (float v, float amt) { + return floor(v * exp2(amt) + 0.5); + } + float maskLast (float v, float bits) { + return mod(v, shiftLeft(1.0, bits)); + } + float extractBits (float num, float from, float to) { + from = floor(from + 0.5); to = floor(to + 0.5); + return maskLast(shiftRight(num, from), to - from); + } + + vec4 floatToRgba(float texelFloat, bool littleEndian) { + if (texelFloat == 0.0) return vec4(0.0, 0.0, 0.0, 0.0); + float sign = texelFloat > 0.0 ? 0.0 : 1.0; + texelFloat = abs(texelFloat); + float exponent = floor(log2(texelFloat)); + float biased_exponent = exponent + 127.0; + float fraction = ((texelFloat / exp2(exponent)) - 1.0) * 8388608.0; + float t = biased_exponent / 2.0; + float last_bit_of_biased_exponent = fract(t) * 2.0; + float remaining_bits_of_biased_exponent = floor(t); + float byte4 = extractBits(fraction, 0.0, 8.0) / 255.0; + float byte3 = extractBits(fraction, 8.0, 16.0) / 255.0; + float byte2 = (last_bit_of_biased_exponent * 128.0 + extractBits(fraction, 16.0, 23.0)) / 255.0; + float byte1 = (sign * 128.0 + remaining_bits_of_biased_exponent) / 255.0; + return ( + littleEndian + ? vec4(byte4, byte3, byte2, byte1) + : vec4(byte1, byte2, byte3, byte4) + ); + } +`;var o9=` +#if dLightCount != 0 + uniform vec3 uLightDirection[dLightCount]; + uniform vec3 uLightColor[dLightCount]; +#endif +uniform vec3 uAmbientColor; + +struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; +}; + +struct IncidentLight { + vec3 color; + vec3 direction; +}; + +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; + +struct GeometricContext { + vec3 position; + vec3 normal; + vec3 viewDir; +}; + +vec3 BRDF_Lambert(const in vec3 diffuseColor) { + return RECIPROCAL_PI * diffuseColor; +} + +vec3 F_Schlick(const in vec3 f0, const in float f90, const in float dotVH) { + // Original approximation by Christophe Schlick '94 + // float fresnel = pow( 1.0 - dotVH, 5.0 ); + // Optimized variant (presented by Epic at SIGGRAPH '13) + // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf + float fresnel = exp2((-5.55473 * dotVH - 6.98316) * dotVH); + return f0 * (1.0 - fresnel) + (f90 * fresnel); +} + +// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2 +// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf +float V_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) { + float a2 = pow2(alpha); + float gv = dotNL * sqrt(a2 + (1.0 - a2) * pow2(dotNV)); + float gl = dotNV * sqrt(a2 + (1.0 - a2) * pow2(dotNL)); + return 0.5 / max(gv + gl, EPSILON); +} + +// Microfacet Models for Refraction through Rough Surfaces - equation (33) +// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html +// alpha is "roughness squared" in Disney\u2019s reparameterization +float D_GGX(const in float alpha, const in float dotNH) { + float a2 = pow2(alpha); + float denom = pow2(dotNH) * (a2 - 1.0) + 1.0; // avoid alpha = 0 with dotNH = 1 + return RECIPROCAL_PI * a2 / pow2(denom); +} + +// GGX Distribution, Schlick Fresnel, GGX_SmithCorrelated Visibility +vec3 BRDF_GGX(const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness) { + float alpha = pow2(roughness); // UE4's roughness + vec3 halfDir = normalize( lightDir + viewDir); + float dotNL = saturate(dot(normal, lightDir)); + float dotNV = saturate(dot(normal, viewDir)); + float dotNH = saturate(dot(normal, halfDir)); + float dotVH = saturate(dot(viewDir, halfDir)); + vec3 F = F_Schlick(f0, f90, dotVH); + float V = V_GGX_SmithCorrelated(alpha, dotNL, dotNV); + float D = D_GGX(alpha, dotNH); + return F * (V * D); +} + +// Analytical approximation of the DFG LUT, one half of the +// split-sum approximation used in indirect specular lighting. +// via 'environmentBRDF' from "Physically Based Shading on Mobile" +// https://www.unrealengine.com/blog/physically-based-shading-on-mobile +vec2 DFGApprox(const in vec3 normal, const in vec3 viewDir, const in float roughness) { + float dotNV = saturate(dot(normal, viewDir)); + const vec4 c0 = vec4(-1, -0.0275, -0.572, 0.022); + const vec4 c1 = vec4(1, 0.0425, 1.04, -0.04); + vec4 r = roughness * c0 + c1; + float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y; + vec2 fab = vec2(-1.04, 1.04) * a004 + r.zw; + return fab; +} + +// Fdez-Ag\xFCera's "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting" +// Approximates multiscattering in order to preserve energy. +// http://www.jcgt.org/published/0008/01/03/ +void computeMultiscattering(const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter) { + vec2 fab = DFGApprox(normal, viewDir, roughness); + vec3 FssEss = specularColor * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = specularColor + (1.0 - specularColor) * 0.047619; // 1/21 + vec3 Fms = FssEss * Favg / (1.0 - Ems * Favg); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} + +void RE_Direct_Physical(const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + float dotNL = saturate(dot(geometry.normal, directLight.direction)); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directSpecular += irradiance * BRDF_GGX(directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert(material.diffuseColor); +} + +void RE_IndirectDiffuse_Physical(const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert(material.diffuseColor); +} + +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + // Both indirect specular and indirect diffuse light accumulate here + vec3 singleScattering = vec3(0.0); + vec3 multiScattering = vec3(0.0); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + computeMultiscattering(geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering); + vec3 diffuse = material.diffuseColor * (1.0 - ( singleScattering + multiScattering)); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +`;var s9=` +float matrixScale(in mat4 m){ + vec4 r = m[0]; + return sqrt(r[0] * r[0] + r[1] * r[1] + r[2] * r[2]); +} +`;var u9=` +varying vec3 vNormal; +`;var c9=` +vec4 readFromTexture(const in sampler2D tex, const in float i, const in vec2 dim) { + float x = intMod(i, dim.x); + float y = floor(intDiv(i, dim.x)); + vec2 uv = (vec2(x, y) + 0.5) / dim; + return texture2D(tex, uv); +} + +vec4 readFromTexture(const in sampler2D tex, const in int i, const in vec2 dim) { + int x = imod(i, int(dim.x)); + int y = i / int(dim.x); + vec2 uv = (vec2(x, y) + 0.5) / dim; + return texture2D(tex, uv); +} +`;var l9=` + // rgbaToFloat adapted from https://github.com/ihmeuw/glsl-rgba-to-float + // BSD 3-Clause License + // + // Copyright (c) 2019, Institute for Health Metrics and Evaluation All rights reserved. + // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + // - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + // - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + // - Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + // + // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + // OF THE POSSIBILITY OF SUCH DAMAGE. + + ivec4 floatsToBytes(vec4 inputFloats, bool littleEndian) { + ivec4 bytes = ivec4(inputFloats * 255.0); + return ( + littleEndian + ? bytes.abgr + : bytes + ); + } + + // Break the four bytes down into an array of 32 bits. + void bytesToBits(const in ivec4 bytes, out bool bits[32]) { + for (int channelIndex = 0; channelIndex < 4; ++channelIndex) { + float acc = float(bytes[channelIndex]); + for (int indexInByte = 7; indexInByte >= 0; --indexInByte) { + float powerOfTwo = exp2(float(indexInByte)); + bool bit = acc >= powerOfTwo; + bits[channelIndex * 8 + (7 - indexInByte)] = bit; + acc = mod(acc, powerOfTwo); + } + } + } + + // Compute the exponent of the 32-bit float. + float getExponent(bool bits[32]) { + const int startIndex = 1; + const int bitStringLength = 8; + const int endBeforeIndex = startIndex + bitStringLength; + float acc = 0.0; + int pow2 = bitStringLength - 1; + for (int bitIndex = startIndex; bitIndex < endBeforeIndex; ++bitIndex) { + acc += float(bits[bitIndex]) * exp2(float(pow2--)); + } + return acc; + } + + // Compute the mantissa of the 32-bit float. + float getMantissa(bool bits[32], bool subnormal) { + const int startIndex = 9; + const int bitStringLength = 23; + const int endBeforeIndex = startIndex + bitStringLength; + // Leading/implicit/hidden bit convention: + // If the number is not subnormal (with exponent 0), we add a leading 1 digit. + float acc = float(!subnormal) * exp2(float(bitStringLength)); + int pow2 = bitStringLength - 1; + for (int bitIndex = startIndex; bitIndex < endBeforeIndex; ++bitIndex) { + acc += float(bits[bitIndex]) * exp2(float(pow2--)); + } + return acc; + } + + // Parse the float from its 32 bits. + float bitsToFloat(bool bits[32]) { + float signBit = float(bits[0]) * -2.0 + 1.0; + float exponent = getExponent(bits); + bool subnormal = abs(exponent - 0.0) < 0.01; + float mantissa = getMantissa(bits, subnormal); + float exponentBias = 127.0; + return signBit * mantissa * exp2(exponent - exponentBias - 23.0); + } + + float rgbaToFloat(vec4 texelRGBA, bool littleEndian) { + ivec4 rgbaBytes = floatsToBytes(texelRGBA, littleEndian); + bool bits[32]; + bytesToBits(rgbaBytes, bits); + return bitsToFloat(bits); + } +`;var f9=` +#if defined(dSizeType_uniform) + uniform float uSize; +#elif defined(dSizeType_attribute) + attribute float aSize; +#elif defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance) + uniform vec2 uSizeTexDim; + uniform sampler2D tSize; +#endif + +uniform float uSizeFactor; +`;var d9=` +vec4 texture3dFrom1dTrilinear(const in sampler2D tex, const in vec3 pos, const in vec3 gridDim, const in vec2 texDim, const in float offset) { + float gdYZ = gridDim.z * gridDim.y; + float gdZ = gridDim.z; + vec3 p0 = floor(pos * gridDim); + vec3 p1 = ceil(pos * gridDim); + vec3 pd = (pos * gridDim - p0) / (p1 - p0); + vec4 s000 = readFromTexture(tex, offset + p0.z + p0.y * gdZ + p0.x * gdYZ, texDim); + vec4 s100 = readFromTexture(tex, offset + p0.z + p0.y * gdZ + p1.x * gdYZ, texDim); + vec4 s001 = readFromTexture(tex, offset + p1.z + p0.y * gdZ + p0.x * gdYZ, texDim); + vec4 s101 = readFromTexture(tex, offset + p1.z + p0.y * gdZ + p1.x * gdYZ, texDim); + vec4 s010 = readFromTexture(tex, offset + p0.z + p1.y * gdZ + p0.x * gdYZ, texDim); + vec4 s110 = readFromTexture(tex, offset + p0.z + p1.y * gdZ + p1.x * gdYZ, texDim); + vec4 s011 = readFromTexture(tex, offset + p1.z + p1.y * gdZ + p0.x * gdYZ, texDim); + vec4 s111 = readFromTexture(tex, offset + p1.z + p1.y * gdZ + p1.x * gdYZ, texDim); + vec4 s00 = mix(s000, s100, pd.x); + vec4 s01 = mix(s001, s101, pd.x); + vec4 s10 = mix(s010, s110, pd.x); + vec4 s11 = mix(s011, s111, pd.x); + vec4 s0 = mix(s00, s10, pd.y); + vec4 s1 = mix(s01, s11, pd.y); + return mix(s0, s1, pd.z); +} +`;var m9=` +vec4 texture3dFrom2dLinear(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) { + float zSlice0 = floor(pos.z * gridDim.z); + float column0 = intMod(zSlice0 * gridDim.x, texDim.x) / gridDim.x; + float row0 = floor(intDiv(zSlice0 * gridDim.x, texDim.x)); + vec2 coord0 = (vec2(column0 * gridDim.x, row0 * gridDim.y) + (pos.xy * gridDim.xy)) / texDim; + vec4 color0 = texture2D(tex, coord0); + + float zSlice1 = zSlice0 + 1.0; + float column1 = intMod(zSlice1 * gridDim.x, texDim.x) / gridDim.x; + float row1 = floor(intDiv(zSlice1 * gridDim.x, texDim.x)); + vec2 coord1 = (vec2(column1 * gridDim.x, row1 * gridDim.y) + (pos.xy * gridDim.xy)) / texDim; + vec4 color1 = texture2D(tex, coord1); + + float delta0 = abs((pos.z * gridDim.z) - zSlice0); + return mix(color0, color1, delta0); +} +`;var p9=` +vec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) { + float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice + float column = intMod(zSlice * gridDim.x, texDim.x) / gridDim.x; + float row = floor(intDiv(zSlice * gridDim.x, texDim.x)); + vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / texDim; + return texture2D(tex, coord); +} +`;var h9=` +#if defined(dRenderVariant_colorWboit) + if (uRenderMask == MaskOpaque) { + if (preFogAlpha < 1.0) { + discard; + } + } else if (uRenderMask == MaskTransparent) { + if (preFogAlpha != 1.0 && fragmentDepth < getDepth(gl_FragCoord.xy / uDrawingBufferSize)) { + #ifdef dTransparentBackfaces_off + if (interior) discard; + #endif + float alpha = gl_FragColor.a; + float wboitWeight = alpha * clamp(pow(1.0 - fragmentDepth, 2.0), 0.01, 1.0); + gl_FragColor = vec4(gl_FragColor.rgb * alpha * wboitWeight, alpha); + // extra alpha is to handle pre-multiplied alpha + #ifndef dGeometryType_directVolume + gl_FragData[1] = vec4((uTransparentBackground ? alpha : 1.0) * alpha * wboitWeight); + #else + gl_FragData[1] = vec4(alpha * alpha * wboitWeight); + #endif + } else { + discard; + } + } +#endif +`;var v9=` +#if defined(dRenderVariant_colorDpoit) + if (uRenderMask == MaskOpaque) { + if (preFogAlpha < 1.0) { + discard; + } + } else if (uRenderMask == MaskTransparent) { + vec2 coords = gl_FragCoord.xy / uDrawingBufferSize; + if (preFogAlpha != 1.0 && fragmentDepth < getDepth(coords)) { + #ifdef dTransparentBackfaces_off + if (interior) discard; + #endif + + // adapted from https://github.com/tsherif/webgl2examples + // The MIT License, Copyright 2017 Tarek Sherif, Shuai Shao + + vec2 lastDepth = texture2D(tDpoitDepth, coords).rg; + vec4 lastFrontColor = texture2D(tDpoitFrontColor, coords); + + vec4 fragColor = gl_FragColor; + + // depth value always increases + // so we can use MAX blend equation + gl_FragData[2].rg = vec2(-MAX_DPOIT_DEPTH); + + // front color always increases + // so we can use MAX blend equation + gl_FragColor = lastFrontColor; + + // back color is separately blend afterwards each pass + gl_FragData[1] = vec4(0.0); + + float nearestDepth = -lastDepth.x; + float furthestDepth = lastDepth.y; + float alphaMultiplier = 1.0 - lastFrontColor.a; + + if (fragmentDepth < nearestDepth || fragmentDepth > furthestDepth) { + // Skip this depth since it's been peeled. + return; + } + + if (fragmentDepth > nearestDepth && fragmentDepth < furthestDepth) { + // This needs to be peeled. + // The ones remaining after MAX blended for + // all need-to-peel will be peeled next pass. + gl_FragData[2].rg = vec2(-fragmentDepth, fragmentDepth); + return; + } + + // write to back and front color buffer + if (fragmentDepth == nearestDepth) { + gl_FragColor.rgb += fragColor.rgb * fragColor.a * alphaMultiplier; + gl_FragColor.a = 1.0 - alphaMultiplier * (1.0 - fragColor.a); + } else { + gl_FragData[1] += fragColor; + } + + } else { + discard; + } + } +#endif +`;var g9=` +precision highp float; +precision highp int; + +#include common +#include read_from_texture +#include common_vert_params +#include color_vert_params +#include size_vert_params +#include common_clip + +uniform float uPixelRatio; +uniform vec4 uViewport; + +attribute vec3 aPosition; +attribute mat4 aTransform; +attribute float aInstance; +attribute float aGroup; + +void main(){ + #include assign_group + #include assign_color_varying + #include assign_marker_varying + #include assign_clipping_varying + #include assign_position + #include assign_size + + #ifdef dPointSizeAttenuation + gl_PointSize = size * uPixelRatio * ((uViewport.w / 2.0) / -mvPosition.z) * 5.0; + #else + gl_PointSize = size * uPixelRatio; + #endif + gl_PointSize = max(1.0, gl_PointSize); + + gl_Position = uProjection * mvPosition; + + #include clip_instance +} +`;var y9=` +precision highp float; +precision highp int; + +#include common +#include common_frag_params +#include color_frag_params +#include common_clip + +const vec2 center = vec2(0.5); +const float radius = 0.5; + +void main(){ + #include clip_pixel + + float fragmentDepth = gl_FragCoord.z; + #include assign_material_color + + #if defined(dPointStyle_circle) + float dist = distance(gl_PointCoord, center); + if (dist > radius) discard; + #elif defined(dPointStyle_fuzzy) + float dist = distance(gl_PointCoord, center); + float fuzzyAlpha = 1.0 - smoothstep(0.0, radius, dist); + if (fuzzyAlpha < 0.0001) discard; + #endif + + #if defined(dRenderVariant_pick) + #include check_picking_alpha + #ifdef requiredDrawBuffers + gl_FragColor = vObject; + gl_FragData[1] = vInstance; + gl_FragData[2] = vGroup; + gl_FragData[3] = packDepthToRGBA(fragmentDepth); + #else + gl_FragColor = vColor; + #endif + #elif defined(dRenderVariant_depth) + gl_FragColor = material; + #elif defined(dRenderVariant_marking) + gl_FragColor = material; + #elif defined(dRenderVariant_color) + gl_FragColor = material; + + #if defined(dPointStyle_fuzzy) + gl_FragColor.a *= fuzzyAlpha; + #endif + + #include apply_marker_color + #include apply_fog + #include wboit_write + #include dpoit_write + #endif +} +`;var b9=` +precision highp float; +precision highp int; + +#include common +#include read_from_texture +#include common_vert_params +#include color_vert_params +#include size_vert_params +#include common_clip + +uniform mat4 uModelView; +uniform mat4 uInvProjection; +uniform float uIsOrtho; + +uniform vec2 uTexDim; +uniform sampler2D tPositionGroup; + +attribute mat4 aTransform; +attribute float aInstance; + +varying float vRadius; +varying vec3 vPoint; +varying vec3 vPointViewPosition; + +#include matrix_scale + +/** + * Bounding rectangle of a clipped, perspective-projected 3D Sphere. + * Michael Mara, Morgan McGuire. 2013 + * + * Specialization by Arseny Kapoulkine, MIT License Copyright (c) 2018 + * https://github.com/zeux/niagara + */ +void sphereProjection(const in vec3 p, const in float r, const in vec2 mapping) { + vec3 pr = p * r; + float pzr2 = p.z * p.z - r * r; + + float vx = sqrt(p.x * p.x + pzr2); + float minx = ((vx * p.x - pr.z) / (vx * p.z + pr.x)) * uProjection[0][0]; + float maxx = ((vx * p.x + pr.z) / (vx * p.z - pr.x)) * uProjection[0][0]; + + float vy = sqrt(p.y * p.y + pzr2); + float miny = ((vy * p.y - pr.z) / (vy * p.z + pr.y)) * uProjection[1][1]; + float maxy = ((vy * p.y + pr.z) / (vy * p.z - pr.y)) * uProjection[1][1]; + + gl_Position.xy = vec2(maxx + minx, maxy + miny) * -0.5; + gl_Position.xy -= mapping * vec2(maxx - minx, maxy - miny) * 0.5; + gl_Position.xy *= gl_Position.w; +} + +void main(void){ + vec2 mapping = vec2(1.0, 1.0); // vertices 2 and 5 + #if __VERSION__ == 100 + int m = imod(VertexID, 6); + #else + int m = VertexID % 6; + #endif + if (m == 0) { + mapping = vec2(-1.0, 1.0); + } else if (m == 1 || m == 3) { + mapping = vec2(-1.0, -1.0); + } else if (m == 4) { + mapping = vec2(1.0, -1.0); + } + + vec4 positionGroup = readFromTexture(tPositionGroup, VertexID / 6, uTexDim); + vec3 position = positionGroup.rgb; + float group = positionGroup.a; + + #include assign_color_varying + #include assign_marker_varying + #include assign_clipping_varying + #include assign_size + + vRadius = size * matrixScale(uModelView); + + vec4 position4 = vec4(position, 1.0); + vec4 mvPosition = uModelView * aTransform * position4; + + #ifdef dApproximate + vec4 mvCorner = vec4(mvPosition.xyz, 1.0); + mvCorner.xy += mapping * vRadius; + gl_Position = uProjection * mvCorner; + #else + if (uIsOrtho == 1.0) { + vec4 mvCorner = vec4(mvPosition.xyz, 1.0); + mvCorner.xy += mapping * vRadius; + gl_Position = uProjection * mvCorner; + } else { + gl_Position = uProjection * vec4(mvPosition.xyz, 1.0); + sphereProjection(mvPosition.xyz, vRadius, mapping); + } + #endif + + vec4 vPoint4 = uInvProjection * gl_Position; + vPoint = vPoint4.xyz / vPoint4.w; + vPointViewPosition = -mvPosition.xyz / mvPosition.w; + + vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader + + if (gl_Position.z < -gl_Position.w) { + mvPosition.z -= 2.0 * vRadius; // avoid clipping + gl_Position.z = (uProjection * vec4(mvPosition.xyz, 1.0)).z; + } + + #if defined(dClipPrimitive) && !defined(dClipVariant_instance) && dClipObjectCount != 0 + if (clipTest(vec4(vModelPosition.xyz, 0.0))) { + // move out of [ -w, +w ] to 'discard' in vert shader + gl_Position.z = 2.0 * gl_Position.w; + } + #else + #include clip_instance + #endif +} +`;var x9=` +precision highp float; +precision highp int; + +#define bumpEnabled + +#include common +#include common_frag_params +#include color_frag_params +#include light_frag_params +#include common_clip + +uniform mat4 uInvView; +uniform float uAlphaThickness; + +varying float vRadius; +varying vec3 vPoint; +varying vec3 vPointViewPosition; + +#ifdef dSolidInterior + const bool solidInterior = true; +#else + const bool solidInterior = false; +#endif + +bool SphereImpostor(out vec3 modelPos, out vec3 cameraPos, out vec3 cameraNormal, out bool interior, out float fragmentDepth){ + vec3 cameraSpherePos = -vPointViewPosition; + + vec3 rayOrigin = mix(vec3(0.0, 0.0, 0.0), vPoint, uIsOrtho); + vec3 rayDirection = mix(normalize(vPoint), vec3(0.0, 0.0, 1.0), uIsOrtho); + vec3 cameraSphereDir = mix(cameraSpherePos, rayOrigin - cameraSpherePos, uIsOrtho); + + float B = dot(rayDirection, cameraSphereDir); + float det = B * B + vRadius * vRadius - dot(cameraSphereDir, cameraSphereDir); + + if (det < 0.0) return false; + + float sqrtDet = sqrt(det); + float posT = mix(B + sqrtDet, B - sqrtDet, uIsOrtho); + float negT = mix(B - sqrtDet, B + sqrtDet, uIsOrtho); + + cameraPos = rayDirection * negT + rayOrigin; + modelPos = (uInvView * vec4(cameraPos, 1.0)).xyz; + fragmentDepth = calcDepth(cameraPos); + + bool objectClipped = false; + + #if !defined(dClipPrimitive) && defined(dClipVariant_pixel) && dClipObjectCount != 0 + if (clipTest(vec4(modelPos, 0.0))) { + objectClipped = true; + fragmentDepth = -1.0; + } + #endif + + if (fragmentDepth > 0.0) { + cameraNormal = normalize(cameraPos - cameraSpherePos); + interior = false; + return true; + } else if (uDoubleSided || solidInterior) { + cameraPos = rayDirection * posT + rayOrigin; + modelPos = (uInvView * vec4(cameraPos, 1.0)).xyz; + fragmentDepth = calcDepth(cameraPos); + cameraNormal = -normalize(cameraPos - cameraSpherePos); + interior = true; + if (fragmentDepth > 0.0) { + #ifdef dSolidInterior + if (!objectClipped) { + fragmentDepth = 0.0 + (0.0000001 / vRadius); + cameraNormal = -mix(normalize(vPoint), vec3(0.0, 0.0, 1.0), uIsOrtho); + } + #endif + return true; + } + } + + return false; +} + +void main(void){ + vec3 cameraNormal; + float fragmentDepth; + + #ifdef dApproximate + vec3 pointDir = -vPointViewPosition - vPoint; + if (dot(pointDir, pointDir) > vRadius * vRadius) discard; + vec3 vViewPosition = -vPointViewPosition; + fragmentDepth = gl_FragCoord.z; + #if !defined(dIgnoreLight) || defined(dXrayShaded) + pointDir.z -= cos(length(pointDir) / vRadius); + cameraNormal = -normalize(pointDir / vRadius); + #endif + interior = false; + #else + vec3 modelPos; + vec3 cameraPos; + bool hit = SphereImpostor(modelPos, cameraPos, cameraNormal, interior, fragmentDepth); + if (!hit) discard; + + if (fragmentDepth < 0.0) discard; + if (fragmentDepth > 1.0) discard; + + gl_FragDepthEXT = fragmentDepth; + + vec3 vModelPosition = modelPos; + vec3 vViewPosition = cameraPos; + #endif + + #if !defined(dClipPrimitive) && defined(dClipVariant_pixel) && dClipObjectCount != 0 + #include clip_pixel + #endif + #include assign_material_color + + #if defined(dRenderVariant_pick) + #include check_picking_alpha + #ifdef requiredDrawBuffers + gl_FragColor = vObject; + gl_FragData[1] = vInstance; + gl_FragData[2] = vGroup; + gl_FragData[3] = packDepthToRGBA(fragmentDepth); + #else + gl_FragColor = vColor; + #endif + #elif defined(dRenderVariant_depth) + gl_FragColor = material; + #elif defined(dRenderVariant_marking) + gl_FragColor = material; + #elif defined(dRenderVariant_color) + vec3 normal = -cameraNormal; + #include apply_light_color + + if (uRenderMask == MaskTransparent && uAlphaThickness > 0.0) { + gl_FragColor.a *= min(1.0, vRadius / uAlphaThickness); + } + + #include apply_interior_color + #include apply_marker_color + #include apply_fog + #include wboit_write + #include dpoit_write + #endif +} +`;var S9=` +precision highp float; +precision highp int; + +#include common +#include read_from_texture +#include common_vert_params +#include color_vert_params +#include size_vert_params +#include common_clip + +uniform mat4 uModelView; + +attribute mat4 aTransform; +attribute float aInstance; +attribute float aGroup; + +attribute vec3 aMapping; +attribute vec3 aStart; +attribute vec3 aEnd; +attribute float aScale; +attribute float aCap; + +varying mat4 vTransform; +varying vec3 vStart; +varying vec3 vEnd; +varying float vSize; +varying float vCap; + +uniform float uIsOrtho; +uniform vec3 uCameraDir; + +void main() { + #include assign_group + #include assign_color_varying + #include assign_marker_varying + #include assign_clipping_varying + #include assign_size + + mat4 modelTransform = uModel * aTransform; + + vTransform = aTransform; + vStart = (modelTransform * vec4(aStart, 1.0)).xyz; + vEnd = (modelTransform * vec4(aEnd, 1.0)).xyz; + vSize = size * aScale; + vCap = aCap; + + vModelPosition = (vStart + vEnd) * 0.5; + vec3 camDir = -mix(normalize(vModelPosition - uCameraPosition), uCameraDir, uIsOrtho); + vec3 dir = vEnd - vStart; + // ensure cylinder 'dir' is pointing towards the camera + if(dot(camDir, dir) < 0.0) { + dir = -dir; + } + + vec3 left = cross(camDir, dir); + vec3 up = cross(left, dir); + left = vSize * normalize(left); + up = vSize * normalize(up); + + // move vertex in object-space from center to corner + vModelPosition += aMapping.x * dir + aMapping.y * left + aMapping.z * up; + + vec4 mvPosition = uView * vec4(vModelPosition, 1.0); + vViewPosition = mvPosition.xyz; + gl_Position = uProjection * mvPosition; + + if (gl_Position.z < -gl_Position.w) { + mvPosition.z -= 2.0 * (length(vEnd - vStart) + vSize); // avoid clipping + gl_Position.z = (uProjection * mvPosition).z; + } + + #include clip_instance +} +`;var C9=` +precision highp float; +precision highp int; + +#define bumpEnabled + +uniform mat4 uView; + +varying mat4 vTransform; +varying vec3 vStart; +varying vec3 vEnd; +varying float vSize; +varying float vCap; + +uniform vec3 uCameraDir; +uniform vec3 uCameraPosition; +uniform mat4 uInvView; + +#include common +#include common_frag_params +#include color_frag_params +#include light_frag_params +#include common_clip + +#ifdef dSolidInterior + const bool solidInterior = true; +#else + const bool solidInterior = false; +#endif + +// adapted from https://www.shadertoy.com/view/4lcSRn +// The MIT License, Copyright 2016 Inigo Quilez +bool CylinderImpostor( + in vec3 rayOrigin, in vec3 rayDir, + in vec3 start, in vec3 end, in float radius, + out vec3 cameraNormal, out bool interior, + out vec3 modelPosition, out vec3 viewPosition, out float fragmentDepth +){ + vec3 ba = end - start; + vec3 oc = rayOrigin - start; + + float baba = dot(ba, ba); + float bard = dot(ba, rayDir); + float baoc = dot(ba, oc); + + float k2 = baba - bard * bard; + float k1 = baba * dot(oc, rayDir) - baoc * bard; + float k0 = baba * dot(oc, oc) - baoc * baoc - radius * radius * baba; + + float h = k1 * k1 - k2 * k0; + if (h < 0.0) return false; + + bool topCap = (vCap > 0.9 && vCap < 1.1) || vCap >= 2.9; + bool bottomCap = (vCap > 1.9 && vCap < 2.1) || vCap >= 2.9; + + #ifdef dSolidInterior + bool topInterior = !topCap; + bool bottomInterior = !bottomCap; + topCap = true; + bottomCap = true; + #else + bool topInterior = false; + bool bottomInterior = false; + #endif + + bool clipped = false; + bool objectClipped = false; + + // body outside + h = sqrt(h); + float t = (-k1 - h) / k2; + float y = baoc + t * bard; + if (y > 0.0 && y < baba) { + interior = false; + cameraNormal = (oc + t * rayDir - ba * y / baba) / radius; + modelPosition = rayOrigin + t * rayDir; + viewPosition = (uView * vec4(modelPosition, 1.0)).xyz; + fragmentDepth = calcDepth(viewPosition); + #if defined(dClipVariant_pixel) && dClipObjectCount != 0 + if (clipTest(vec4(modelPosition, 0.0))) { + objectClipped = true; + fragmentDepth = -1.0; + #ifdef dSolidInterior + topCap = !topInterior; + bottomCap = !bottomInterior; + #endif + } + #endif + if (fragmentDepth > 0.0) return true; + clipped = true; + } + + if (!clipped) { + if (topCap && y < 0.0) { + // top cap + t = -baoc / bard; + if (abs(k1 + k2 * t) < h) { + interior = topInterior; + cameraNormal = -ba / baba; + modelPosition = rayOrigin + t * rayDir; + viewPosition = (uView * vec4(modelPosition, 1.0)).xyz; + fragmentDepth = calcDepth(viewPosition); + #if defined(dClipVariant_pixel) && dClipObjectCount != 0 + if (clipTest(vec4(modelPosition, 0.0))) { + objectClipped = true; + fragmentDepth = -1.0; + #ifdef dSolidInterior + topCap = !topInterior; + bottomCap = !bottomInterior; + #endif + } + #endif + if (fragmentDepth > 0.0) { + #ifdef dSolidInterior + if (interior) cameraNormal = -rayDir; + #endif + return true; + } + } + } else if (bottomCap && y >= 0.0) { + // bottom cap + t = (baba - baoc) / bard; + if (abs(k1 + k2 * t) < h) { + interior = bottomInterior; + cameraNormal = ba / baba; + modelPosition = rayOrigin + t * rayDir; + viewPosition = (uView * vec4(modelPosition, 1.0)).xyz; + fragmentDepth = calcDepth(viewPosition); + #if defined(dClipVariant_pixel) && dClipObjectCount != 0 + if (clipTest(vec4(modelPosition, 0.0))) { + objectClipped = true; + fragmentDepth = -1.0; + #ifdef dSolidInterior + topCap = !topInterior; + bottomCap = !bottomInterior; + #endif + } + #endif + if (fragmentDepth > 0.0) { + #ifdef dSolidInterior + if (interior) cameraNormal = -rayDir; + #endif + return true; + } + } + } + } + + if (uDoubleSided || solidInterior) { + // body inside + h = -h; + t = (-k1 - h) / k2; + y = baoc + t * bard; + if (y > 0.0 && y < baba) { + interior = true; + cameraNormal = -(oc + t * rayDir - ba * y / baba) / radius; + modelPosition = rayOrigin + t * rayDir; + viewPosition = (uView * vec4(modelPosition, 1.0)).xyz; + fragmentDepth = calcDepth(viewPosition); + if (fragmentDepth > 0.0) { + #ifdef dSolidInterior + if (!objectClipped) { + fragmentDepth = 0.0 + (0.0000002 / vSize); + cameraNormal = -rayDir; + } + #endif + return true; + } + } + + if (topCap && y < 0.0) { + // top cap + t = -baoc / bard; + if (abs(k1 + k2 * t) < -h) { + interior = true; + cameraNormal = ba / baba; + modelPosition = rayOrigin + t * rayDir; + viewPosition = (uView * vec4(modelPosition, 1.0)).xyz; + fragmentDepth = calcDepth(viewPosition); + if (fragmentDepth > 0.0) { + #ifdef dSolidInterior + if (!objectClipped) { + fragmentDepth = 0.0 + (0.0000002 / vSize); + cameraNormal = -rayDir; + } + #endif + return true; + } + } + } else if (bottomCap && y >= 0.0) { + // bottom cap + t = (baba - baoc) / bard; + if (abs(k1 + k2 * t) < -h) { + interior = true; + cameraNormal = -ba / baba; + modelPosition = rayOrigin + t * rayDir; + viewPosition = (uView * vec4(modelPosition, 1.0)).xyz; + fragmentDepth = calcDepth(viewPosition); + if (fragmentDepth > 0.0) { + #ifdef dSolidInterior + if (!objectClipped) { + fragmentDepth = 0.0 + (0.0000002 / vSize); + cameraNormal = -rayDir; + } + #endif + return true; + } + } + } + } + + return false; +} + +void main() { + vec3 rayOrigin = vModelPosition; + vec3 rayDir = mix(normalize(vModelPosition - uCameraPosition), uCameraDir, uIsOrtho); + + vec3 cameraNormal; + vec3 modelPosition; + vec3 viewPosition; + float fragmentDepth; + bool hit = CylinderImpostor(rayOrigin, rayDir, vStart, vEnd, vSize, cameraNormal, interior, modelPosition, viewPosition, fragmentDepth); + if (!hit) discard; + + if (fragmentDepth < 0.0) discard; + if (fragmentDepth > 1.0) discard; + + gl_FragDepthEXT = fragmentDepth; + + vec3 vViewPosition = viewPosition; + vec3 vModelPosition = modelPosition; + + #include clip_pixel + #include assign_material_color + + #if defined(dRenderVariant_pick) + #include check_picking_alpha + #ifdef requiredDrawBuffers + gl_FragColor = vObject; + gl_FragData[1] = vInstance; + gl_FragData[2] = vGroup; + gl_FragData[3] = packDepthToRGBA(fragmentDepth); + #else + gl_FragColor = vColor; + #endif + #elif defined(dRenderVariant_depth) + gl_FragColor = material; + #elif defined(dRenderVariant_marking) + gl_FragColor = material; + #elif defined(dRenderVariant_color) + mat3 normalMatrix = transpose3(inverse3(mat3(uView))); + vec3 normal = normalize(normalMatrix * -normalize(cameraNormal)); + #include apply_light_color + + #include apply_interior_color + #include apply_marker_color + #include apply_fog + #include wboit_write + #include dpoit_write + #endif +} +`;var _9=` +precision highp float; +precision highp int; + +#include common +#include read_from_texture +#include common_vert_params +#include color_vert_params +#include size_vert_params +#include common_clip + +uniform mat4 uModelView; + +attribute vec3 aPosition; +attribute vec2 aMapping; +attribute float aDepth; +attribute vec2 aTexCoord; +attribute mat4 aTransform; +attribute float aInstance; +attribute float aGroup; + +uniform float uOffsetX; +uniform float uOffsetY; +uniform float uOffsetZ; + +uniform float uIsOrtho; +uniform float uPixelRatio; +uniform vec4 uViewport; + +varying vec2 vTexCoord; + +#include matrix_scale + +void main(void){ + #include assign_group + #include assign_color_varying + #include assign_marker_varying + #include assign_clipping_varying + #include assign_size + + vTexCoord = aTexCoord; + + float scale = matrixScale(uModelView); + + float offsetX = uOffsetX * scale; + float offsetY = uOffsetY * scale; + float offsetZ = (uOffsetZ + aDepth * 0.95) * scale; + + vec4 position4 = vec4(aPosition, 1.0); + vec4 mvPosition = uModelView * aTransform * position4; + + vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader + + // TODO + // #ifdef FIXED_SIZE + // if (ortho) { + // scale /= pixelRatio * ((uViewport.w / 2.0) / -uCameraPosition.z) * 0.1; + // } else { + // scale /= pixelRatio * ((uViewport.w / 2.0) / -mvPosition.z) * 0.1; + // } + // #endif + + vec4 mvCorner = vec4(mvPosition.xyz, 1.0); + + if (vTexCoord.x == 10.0) { // indicates background plane + // move a bit to the back, taking distance to camera into account to avoid z-fighting + offsetZ -= 0.001 * distance(uCameraPosition, (uProjection * mvCorner).xyz); + } + + mvCorner.xy += aMapping * size * scale; + mvCorner.x += offsetX; + mvCorner.y += offsetY; + + if (uIsOrtho == 1.0) { + mvCorner.z += offsetZ; + } else { + mvCorner.xyz += normalize(-mvCorner.xyz) * offsetZ; + } + + gl_Position = uProjection * mvCorner; + + vViewPosition = -mvCorner.xyz; + + #include clip_instance +} +`;var w9=` +precision highp float; +precision highp int; + +#include common +#include common_frag_params +#include color_frag_params +#include common_clip + +uniform sampler2D tFont; + +uniform vec3 uBorderColor; +uniform float uBorderWidth; +uniform vec3 uBackgroundColor; +uniform float uBackgroundOpacity; + +varying vec2 vTexCoord; + +const float smoothness = 32.0; +const float gamma = 2.2; + +void main2(){ + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} + +void main(){ + #include clip_pixel + + float fragmentDepth = gl_FragCoord.z; + #include assign_material_color + + if (vTexCoord.x > 1.0) { + #if defined(dRenderVariant_color) + material = vec4(uBackgroundColor, uBackgroundOpacity * material.a); + #endif + } else { + // retrieve signed distance + float sdf = texture2D(tFont, vTexCoord).a + uBorderWidth; + + // perform adaptive anti-aliasing of the edges + float w = clamp(smoothness * (abs(dFdx(vTexCoord.x)) + abs(dFdy(vTexCoord.y))), 0.0, 0.5); + float a = smoothstep(0.5 - w, 0.5 + w, sdf); + + // gamma correction for linear attenuation + a = pow(a, 1.0 / gamma); + + if (a < 0.5) discard; + + #if defined(dRenderVariant_color) + material.a *= a; + + // add border + float t = 0.5 + uBorderWidth; + if (uBorderWidth > 0.0 && sdf < t) { + material.xyz = mix(uBorderColor, material.xyz, smoothstep(t - w, t, sdf)); + } + #endif + } + + #if defined(dRenderVariant_pick) + #include check_picking_alpha + #ifdef requiredDrawBuffers + gl_FragColor = vObject; + gl_FragData[1] = vInstance; + gl_FragData[2] = vGroup; + gl_FragData[3] = packDepthToRGBA(fragmentDepth); + #else + gl_FragColor = vColor; + #endif + #elif defined(dRenderVariant_depth) + gl_FragColor = material; + #elif defined(dRenderVariant_marking) + gl_FragColor = material; + #elif defined(dRenderVariant_color) + gl_FragColor = material; + + #include apply_marker_color + #include apply_fog + #include wboit_write + #include dpoit_write + #endif +} +`;var T9=` +precision highp float; +precision highp int; + +#include common +#include read_from_texture +#include common_vert_params +#include color_vert_params +#include size_vert_params +#include common_clip + +uniform float uPixelRatio; +uniform vec4 uViewport; + +attribute mat4 aTransform; +attribute float aInstance; +attribute float aGroup; + +attribute vec2 aMapping; +attribute vec3 aStart; +attribute vec3 aEnd; + +void trimSegment(const in vec4 start, inout vec4 end) { + // trim end segment so it terminates between the camera plane and the near plane + // conservative estimate of the near plane + float a = uProjection[2][2]; // 3rd entry in 3rd column + float b = uProjection[3][2]; // 3rd entry in 4th column + float nearEstimate = -0.5 * b / a; + float alpha = (nearEstimate - start.z) / (end.z - start.z); + end.xyz = mix(start.xyz, end.xyz, alpha); +} + +void main(){ + float aspect = uViewport.z / uViewport.w; + + #include assign_group + #include assign_color_varying + #include assign_marker_varying + #include assign_clipping_varying + #include assign_size + + mat4 modelView = uView * uModel * aTransform; + + // camera space + vec4 start = modelView * vec4(aStart, 1.0); + vec4 end = modelView * vec4(aEnd, 1.0); + + // assign position + vec4 position4 = vec4((aMapping.y < 0.5) ? aStart : aEnd, 1.0); + vec4 mvPosition = modelView * position4; + vViewPosition = mvPosition.xyz; + + vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader + + // special case for perspective projection, and segments that terminate either in, or behind, the camera plane + // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space + // but we need to perform ndc-space calculations in the shader, so we must address this issue directly + // perhaps there is a more elegant solution -- WestLangley + bool perspective = (uProjection[2][3] == -1.0); // 4th entry in the 3rd column + if (perspective) { + if (start.z < 0.0 && end.z >= 0.0) { + trimSegment(start, end); + } else if (end.z < 0.0 && start.z >= 0.0) { + trimSegment(end, start); + } + } + + // clip space + vec4 clipStart = uProjection * start; + vec4 clipEnd = uProjection * end; + + // ndc space + vec2 ndcStart = clipStart.xy / clipStart.w; + vec2 ndcEnd = clipEnd.xy / clipEnd.w; + + // direction + vec2 dir = ndcEnd - ndcStart; + + // account for clip-space aspect ratio + dir.x *= aspect; + dir = normalize(dir); + + // perpendicular to dir + vec2 offset = vec2(dir.y, - dir.x); + + // undo aspect ratio adjustment + dir.x /= aspect; + offset.x /= aspect; + + // sign flip + if (aMapping.x < 0.0) offset *= -1.0; + + // calculate linewidth + float linewidth; + #ifdef dLineSizeAttenuation + linewidth = size * uPixelRatio * ((uViewport.w / 2.0) / -start.z) * 5.0; + #else + linewidth = size * uPixelRatio; + #endif + linewidth = max(1.0, linewidth); + + // adjust for linewidth + offset *= linewidth; + + // adjust for clip-space to screen-space conversion + offset /= uViewport.w; + + // select end + vec4 clip = (aMapping.y < 0.5) ? clipStart : clipEnd; + + // back to clip space + offset *= clip.w; + clip.xy += offset; + gl_Position = clip; + + #include clip_instance +} +`;var A9=` +precision highp float; +precision highp int; + +#include common +#include common_frag_params +#include color_frag_params +#include common_clip + +void main(){ + #include clip_pixel + + float fragmentDepth = gl_FragCoord.z; + #include assign_material_color + + #if defined(dRenderVariant_pick) + #include check_picking_alpha + #ifdef requiredDrawBuffers + gl_FragColor = vObject; + gl_FragData[1] = vInstance; + gl_FragData[2] = vGroup; + gl_FragData[3] = packDepthToRGBA(fragmentDepth); + #else + gl_FragColor = vColor; + #endif + #elif defined(dRenderVariant_depth) + gl_FragColor = material; + #elif defined(dRenderVariant_marking) + gl_FragColor = material; + #elif defined(dRenderVariant_color) + gl_FragColor = material; + + #include apply_marker_color + #include apply_fog + #include wboit_write + #include dpoit_write + #endif +} +`;var D9=` +precision highp float; +precision highp int; +precision highp sampler2D; + +#include common +#include read_from_texture +#include common_vert_params +#include color_vert_params +#include common_clip +#include texture3d_from_2d_linear + +#ifdef dGeometryType_textureMesh + uniform vec2 uGeoTexDim; + uniform sampler2D tPosition; + uniform sampler2D tGroup; + uniform sampler2D tNormal; +#else + attribute vec3 aPosition; + attribute float aGroup; + attribute vec3 aNormal; +#endif +attribute mat4 aTransform; +attribute float aInstance; + +varying vec3 vNormal; + +void main(){ + #include assign_group + #include assign_marker_varying + #include assign_clipping_varying + #include assign_position + #include assign_color_varying + #include clip_instance + + #ifdef dGeometryType_textureMesh + vec3 normal = readFromTexture(tNormal, VertexID, uGeoTexDim).xyz; + #else + vec3 normal = aNormal; + #endif + mat3 normalMatrix = transpose3(inverse3(mat3(modelView))); + vec3 transformedNormal = normalize(normalMatrix * normalize(normal)); + #if defined(dFlipSided) + if (!uDoubleSided) { // TODO checking uDoubleSided should not be required, ASR + transformedNormal = -transformedNormal; + } + #endif + vNormal = transformedNormal; +} +`;var P9=` +precision highp float; +precision highp int; + +#define bumpEnabled + +#include common +#include common_frag_params +#include color_frag_params +#include light_frag_params +#include normal_frag_params +#include common_clip + +void main() { + #include clip_pixel + + // Workaround for buggy gl_FrontFacing (e.g. on some integrated Intel GPUs) + vec3 fdx = dFdx(vViewPosition); + vec3 fdy = dFdy(vViewPosition); + vec3 faceNormal = normalize(cross(fdx,fdy)); + bool frontFacing = dot(vNormal, faceNormal) > 0.0; + + #if defined(dFlipSided) + interior = frontFacing; + #else + interior = !frontFacing; + #endif + + float fragmentDepth = gl_FragCoord.z; + #include assign_material_color + + #if defined(dRenderVariant_pick) + #include check_picking_alpha + #ifdef requiredDrawBuffers + gl_FragColor = vObject; + gl_FragData[1] = vInstance; + gl_FragData[2] = vGroup; + gl_FragData[3] = packDepthToRGBA(fragmentDepth); + #else + gl_FragColor = vColor; + #endif + #elif defined(dRenderVariant_depth) + gl_FragColor = material; + #elif defined(dRenderVariant_marking) + gl_FragColor = material; + #elif defined(dRenderVariant_color) + #if defined(dFlatShaded) + vec3 normal = -faceNormal; + #else + vec3 normal = -normalize(vNormal); + if (uDoubleSided) normal *= float(frontFacing) * 2.0 - 1.0; + #endif + #include apply_light_color + + #include apply_interior_color + #include apply_marker_color + #include apply_fog + #include wboit_write + #include dpoit_write + #endif +} +`;var E9=` +precision highp float; + +attribute vec3 aPosition; +attribute mat4 aTransform; +attribute float aInstance; + +uniform mat4 uModelView; +uniform mat4 uProjection; +uniform vec4 uInvariantBoundingSphere; + +varying vec3 vOrigPos; +varying float vInstance; +varying vec4 vBoundingSphere; +varying mat4 vTransform; + +uniform vec3 uBboxSize; +uniform vec3 uBboxMin; +uniform vec3 uBboxMax; +uniform vec3 uGridDim; +uniform mat4 uTransform; + +uniform mat4 uUnitToCartn; + +void main() { + vec4 unitCoord = vec4(aPosition + vec3(0.5), 1.0); + vec4 mvPosition = uModelView * aTransform * uUnitToCartn * unitCoord; + + vOrigPos = (aTransform * uUnitToCartn * unitCoord).xyz; + vInstance = aInstance; + vBoundingSphere = vec4( + (aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0)).xyz, + uInvariantBoundingSphere.w + ); + vTransform = aTransform; + + gl_Position = uProjection * mvPosition; + + // move z position to near clip plane (but not too close to get precision issues) + gl_Position.z = gl_Position.w - 0.01; +} +`;var I9=` +precision highp float; +precision highp int; + +#include common +#include light_frag_params + +#if dClipObjectCount != 0 + uniform int uClipObjectType[dClipObjectCount]; + uniform bool uClipObjectInvert[dClipObjectCount]; + uniform vec3 uClipObjectPosition[dClipObjectCount]; + uniform vec4 uClipObjectRotation[dClipObjectCount]; + uniform vec3 uClipObjectScale[dClipObjectCount]; +#endif +#include common_clip + +#include read_from_texture +#include texture3d_from_1d_trilinear +#include texture3d_from_2d_nearest +#include texture3d_from_2d_linear + +uniform mat4 uProjection, uTransform, uModelView, uModel, uView; +uniform vec3 uCameraDir; + +uniform sampler2D tDepth; +uniform vec2 uDrawingBufferSize; + +varying vec3 vOrigPos; +varying float vInstance; +varying vec4 vBoundingSphere; +varying mat4 vTransform; + +uniform mat4 uInvView; +uniform vec3 uGridDim; +uniform vec3 uBboxSize; +uniform sampler2D tTransferTex; +uniform float uTransferScale; +uniform float uStepScale; +uniform float uJumpLength; + +uniform int uObjectId; +uniform int uVertexCount; +uniform int uInstanceCount; +uniform int uGroupCount; + +#if defined(dColorMarker) + uniform vec3 uHighlightColor; + uniform vec3 uSelectColor; + uniform vec3 uDimColor; + uniform float uHighlightStrength; + uniform float uSelectStrength; + uniform float uDimStrength; + uniform int uMarkerPriority; + uniform float uMarkerAverage; + + uniform float uMarker; + uniform vec2 uMarkerTexDim; + uniform sampler2D tMarker; +#endif + +uniform float uMetalness; +uniform float uRoughness; + +uniform bool uFog; +uniform float uFogNear; +uniform float uFogFar; +uniform vec3 uFogColor; + +uniform float uAlpha; +uniform bool uTransparentBackground; +uniform float uXrayEdgeFalloff; +uniform float uExposure; + +uniform int uRenderMask; + +uniform float uNear; +uniform float uFar; +uniform float uIsOrtho; + +uniform vec3 uCellDim; +uniform vec3 uCameraPosition; +uniform mat4 uCartnToUnit; + +#if __VERSION__ != 100 + // for webgl1 this is given as a 'define' + uniform int uMaxSteps; +#endif + +#if defined(dGridTexType_2d) + precision highp sampler2D; + uniform sampler2D tGridTex; + uniform vec3 uGridTexDim; +#elif defined(dGridTexType_3d) + precision highp sampler3D; + uniform sampler3D tGridTex; +#endif + +#if defined(dColorType_uniform) + uniform vec3 uColor; +#elif defined(dColorType_texture) + uniform vec2 uColorTexDim; + uniform sampler2D tColor; +#endif + +#ifdef dOverpaint + #if defined(dOverpaintType_groupInstance) || defined(dOverpaintType_vertexInstance) + uniform vec2 uOverpaintTexDim; + uniform sampler2D tOverpaint; + #endif +#endif + +#ifdef dUsePalette + uniform sampler2D tPalette; +#endif + +#if defined(dGridTexType_2d) + vec4 textureVal(vec3 pos) { + return texture3dFrom2dLinear(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy); + } + vec4 textureGroup(vec3 pos) { + return texture3dFrom2dNearest(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy); + } +#elif defined(dGridTexType_3d) + vec4 textureVal(vec3 pos) { + return texture(tGridTex, pos + (vec3(0.5) / uGridDim)); + } + vec4 textureGroup(vec3 pos) { + return texelFetch(tGridTex, ivec3(pos * uGridDim), 0); + } +#endif + +float calcDepth(const in vec3 pos) { + vec2 clipZW = pos.z * uProjection[2].zw + uProjection[3].zw; + return 0.5 + 0.5 * clipZW.x / clipZW.y; +} + +float transferFunction(float value) { + return texture2D(tTransferTex, vec2(value, 0.0)).a; +} + +float getDepth(const in vec2 coords) { + #ifdef depthTextureSupport + return texture2D(tDepth, coords).r; + #else + return unpackRGBAToDepth(texture2D(tDepth, coords)); + #endif +} + +const float gradOffset = 0.5; + +vec3 v3m4(vec3 p, mat4 m) { + return (m * vec4(p, 1.0)).xyz; +} + +float preFogAlphaBlended = 0.0; + +vec4 raymarch(vec3 startLoc, vec3 step, vec3 rayDir) { + mat3 normalMatrix = transpose3(inverse3(mat3(uModelView * vTransform))); + mat4 cartnToUnit = uCartnToUnit * inverse4(vTransform); + #if defined(dClipVariant_pixel) && dClipObjectCount != 0 + mat4 modelTransform = uModel * vTransform * uTransform; + #endif + mat4 modelViewTransform = uModelView * vTransform * uTransform; + + vec3 scaleVol = vec3(1.0) / uGridDim; + vec3 pos = startLoc; + vec4 cell; + float prevValue = -1.0; + float value = 0.0; + vec4 src = vec4(0.0); + vec4 dst = vec4(0.0); + float fragmentDepth; + + vec3 posMin = vec3(0.0); + vec3 posMax = vec3(1.0) - vec3(1.0) / uGridDim; + + vec3 unitPos; + + vec3 nextPos; + float nextValue; + + vec4 material; + vec4 overpaint; + float metalness = uMetalness; + float roughness = uRoughness; + + vec3 gradient = vec3(1.0); + vec3 dx = vec3(gradOffset * scaleVol.x, 0.0, 0.0); + vec3 dy = vec3(0.0, gradOffset * scaleVol.y, 0.0); + vec3 dz = vec3(0.0, 0.0, gradOffset * scaleVol.z); + + float maxDist = min(vBoundingSphere.w * 2.0, uFar - uNear); + float maxDistSq = maxDist * maxDist; + + for (int i = 0; i < uMaxSteps; ++i) { + // break when beyond bounding-sphere or far-plane + vec3 distVec = startLoc - pos; + if (dot(distVec, distVec) > maxDistSq) break; + + unitPos = v3m4(pos, cartnToUnit); + + // continue when outside of grid + if (unitPos.x > posMax.x || unitPos.y > posMax.y || unitPos.z > posMax.z || + unitPos.x < posMin.x || unitPos.y < posMin.y || unitPos.z < posMin.z + ) { + prevValue = value; + pos += step; + continue; + } + + cell = textureVal(unitPos); + value = cell.a; // current voxel value + + if (uJumpLength > 0.0 && value < 0.01) { + nextPos = pos + rayDir * uJumpLength; + nextValue = textureVal(v3m4(nextPos, cartnToUnit)).a; + if (nextValue < 0.01) { + prevValue = nextValue; + pos = nextPos; + continue; + } + } + + vec4 mvPosition = modelViewTransform * vec4(unitPos * uGridDim, 1.0); + if (calcDepth(mvPosition.xyz) > getDepth(gl_FragCoord.xy / uDrawingBufferSize)) + break; + + #if defined(dClipVariant_pixel) && dClipObjectCount != 0 + vec3 vModelPosition = v3m4(unitPos * uGridDim, modelTransform); + if (clipTest(vec4(vModelPosition, 0.0))) { + prevValue = value; + pos += step; + continue; + } + #endif + + vec3 vViewPosition = mvPosition.xyz; + material.a = transferFunction(value); + + #ifdef dPackedGroup + float group = unpackRGBToInt(textureGroup(floor(unitPos * uGridDim + 0.5) / uGridDim).rgb); + #else + vec3 g = floor(unitPos * uGridDim + 0.5); + // note that we swap x and z because the texture is flipped around y + #if defined(dAxisOrder_012) + float group = g.z + g.y * uGridDim.z + g.x * uGridDim.z * uGridDim.y; // 210 + #elif defined(dAxisOrder_021) + float group = g.y + g.z * uGridDim.y + g.x * uGridDim.y * uGridDim.z; // 120 + #elif defined(dAxisOrder_102) + float group = g.z + g.x * uGridDim.z + g.y * uGridDim.z * uGridDim.x; // 201 + #elif defined(dAxisOrder_120) + float group = g.x + g.z * uGridDim.x + g.y * uGridDim.x * uGridDim.z; // 021 + #elif defined(dAxisOrder_201) + float group = g.y + g.x * uGridDim.y + g.z * uGridDim.y * uGridDim.x; // 102 + #elif defined(dAxisOrder_210) + float group = g.x + g.y * uGridDim.x + g.z * uGridDim.x * uGridDim.y; // 012 + #endif + #endif + + #if defined(dColorType_direct) && defined(dUsePalette) + material.rgb = texture2D(tPalette, vec2(value, 0.0)).rgb; + #elif defined(dColorType_uniform) + material.rgb = uColor; + #elif defined(dColorType_instance) + material.rgb = readFromTexture(tColor, vInstance, uColorTexDim).rgb; + #elif defined(dColorType_group) + material.rgb = readFromTexture(tColor, group, uColorTexDim).rgb; + #elif defined(dColorType_groupInstance) + material.rgb = readFromTexture(tColor, vInstance * float(uGroupCount) + group, uColorTexDim).rgb; + #elif defined(dColorType_vertex) + material.rgb = texture3dFrom1dTrilinear(tColor, unitPos, uGridDim, uColorTexDim, 0.0).rgb; + #elif defined(dColorType_vertexInstance) + material.rgb = texture3dFrom1dTrilinear(tColor, unitPos, uGridDim, uColorTexDim, vInstance * float(uVertexCount)).rgb; + #endif + + #ifdef dOverpaint + #if defined(dOverpaintType_groupInstance) + overpaint = readFromTexture(tOverpaint, vInstance * float(uGroupCount) + group, uOverpaintTexDim); + #elif defined(dOverpaintType_vertexInstance) + overpaint = texture3dFrom1dTrilinear(tOverpaint, unitPos, uGridDim, uOverpaintTexDim, vInstance * float(uVertexCount)); + #endif + + material.rgb = mix(material.rgb, overpaint.rgb, overpaint.a); + #endif + + #ifdef dIgnoreLight + gl_FragColor.rgb = material.rgb; + #else + if (material.a >= 0.01) { + #ifdef dPackedGroup + // compute gradient by central differences + gradient.x = textureVal(unitPos - dx).a - textureVal(unitPos + dx).a; + gradient.y = textureVal(unitPos - dy).a - textureVal(unitPos + dy).a; + gradient.z = textureVal(unitPos - dz).a - textureVal(unitPos + dz).a; + #else + gradient = cell.xyz * 2.0 - 1.0; + #endif + vec3 normal = -normalize(normalMatrix * normalize(gradient)); + #include apply_light_color + } else { + gl_FragColor.rgb = material.rgb; + } + #endif + + gl_FragColor.a = material.a * uAlpha * uTransferScale; + + #if defined(dColorMarker) + float marker = uMarker; + if (uMarker == -1.0) { + marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a; + marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win + } + #endif + #include apply_marker_color + + preFogAlphaBlended = (1.0 - preFogAlphaBlended) * gl_FragColor.a + preFogAlphaBlended; + fragmentDepth = calcDepth(mvPosition.xyz); + #include apply_fog + + src = gl_FragColor; + + if (!uTransparentBackground) { + // done in 'apply_fog' otherwise + src.rgb *= src.a; + } + dst = (1.0 - dst.a) * src + dst; // standard blending + + // break if the color is opaque enough + if (dst.a > 0.95) + break; + + pos += step; + } + + return dst; +} + +// TODO: support float texture for higher precision values??? +// TODO: support clipping exclusion texture support + +void main() { + if (gl_FrontFacing) + discard; + + vec3 rayDir = mix(normalize(vOrigPos - uCameraPosition), uCameraDir, uIsOrtho); + vec3 step = rayDir * uStepScale; + + float boundingSphereNear = distance(vBoundingSphere.xyz, uCameraPosition) - vBoundingSphere.w; + float d = max(uNear, boundingSphereNear) - mix(0.0, distance(vOrigPos, uCameraPosition), uIsOrtho); + vec3 start = mix(uCameraPosition, vOrigPos, uIsOrtho) + (d * rayDir); + gl_FragColor = raymarch(start, step, rayDir); + + float fragmentDepth = calcDepth((uModelView * vec4(start, 1.0)).xyz); + float preFogAlpha = clamp(preFogAlphaBlended, 0.0, 1.0); + #include wboit_write +} +`;var M9=` +precision highp float; +precision highp int; + +#include common +#include common_vert_params + +attribute vec3 aPosition; +attribute vec2 aUv; +attribute mat4 aTransform; +attribute float aInstance; + +varying vec2 vUv; +varying float vInstance; + +void main() { + #include assign_position + + vUv = aUv; + vInstance = aInstance; +} +`;var R9=` +precision highp float; +precision highp int; + +#include common +#include read_from_texture +#include common_frag_params +#include common_clip + +uniform vec2 uImageTexDim; +uniform sampler2D tImageTex; +uniform sampler2D tGroupTex; + +uniform vec2 uMarkerTexDim; +uniform sampler2D tMarker; + +varying vec2 vUv; +varying float vInstance; + +#if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell) || defined(dInterpolation_bspline) + #define dInterpolation_cubic +#endif + +#if defined(dInterpolation_cubic) + #if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell) + #if defined(dInterpolation_catmulrom) + const float B = 0.0; + const float C = 0.5; + #elif defined(dInterpolation_mitchell) + const float B = 0.333; + const float C = 0.333; + #endif + + float cubicFilter(float x){ + float f = x; + if (f < 0.0) { + f = -f; + } + if (f < 1.0) { + return ((12.0 - 9.0 * B - 6.0 * C) * (f * f * f) + + (-18.0 + 12.0 * B + 6.0 * C) * (f * f) + + (6.0 - 2.0 * B)) / 6.0; + }else if (f >= 1.0 && f < 2.0){ + return ((-B - 6.0 * C) * ( f * f * f) + + (6.0 * B + 30.0 * C) * (f * f) + + (-(12.0 * B) - 48.0 * C) * f + + 8.0 * B + 24.0 * C) / 6.0; + }else{ + return 0.0; + } + } + #elif defined(dInterpolation_bspline) + float cubicFilter(float x) { + float f = x; + if (f < 0.0) { + f = -f; + } + if (f >= 0.0 && f <= 1.0){ + return (2.0 / 3.0) + (0.5) * (f * f * f) - (f * f); + } else if (f > 1.0 && f <= 2.0) { + return 1.0 / 6.0 * pow((2.0 - f), 3.0); + } + return 1.0; + } + #endif + + vec4 biCubic(sampler2D tex, vec2 texCoord) { + vec2 texelSize = 1.0 / uImageTexDim; + texCoord -= texelSize / 2.0; + vec4 nSum = vec4(0.0); + float nDenom = 0.0; + vec2 cell = fract(texCoord * uImageTexDim); + for (float m = -1.0; m <= 2.0; ++m) { + for (float n = -1.0; n <= 2.0; ++n) { + vec4 vecData = texture2D(tex, texCoord + texelSize * vec2(m, n)); + float c = cubicFilter(m - cell.x) * cubicFilter(-n + cell.y); + nSum += vecData * c; + nDenom += c; + } + } + return nSum / nDenom; + } +#endif + +void main() { + #include clip_pixel + + #if defined(dInterpolation_cubic) + vec4 imageData = biCubic(tImageTex, vUv); + #else + vec4 imageData = texture2D(tImageTex, vUv); + #endif + imageData.a = clamp(imageData.a, 0.0, 1.0); + if (imageData.a > 0.9) imageData.a = 1.0; + + float fragmentDepth = gl_FragCoord.z; + + #if defined(dRenderVariant_pick) + if (imageData.a < 0.3) + discard; + #ifdef requiredDrawBuffers + gl_FragColor = vec4(packIntToRGB(float(uObjectId)), 1.0); + gl_FragData[1] = vec4(packIntToRGB(vInstance), 1.0); + gl_FragData[2] = vec4(texture2D(tGroupTex, vUv).rgb, 1.0); + gl_FragData[3] = packDepthToRGBA(gl_FragCoord.z); + #else + gl_FragColor = vColor; + if (uPickType == 1) { + gl_FragColor = vec4(packIntToRGB(float(uObjectId)), 1.0); + } else if (uPickType == 2) { + gl_FragColor = vec4(packIntToRGB(vInstance), 1.0); + } else { + gl_FragColor = vec4(texture2D(tGroupTex, vUv).rgb, 1.0); + } + #endif + #elif defined(dRenderVariant_depth) + if (imageData.a < 0.05) + discard; + gl_FragColor = packDepthToRGBA(gl_FragCoord.z); + #elif defined(dRenderVariant_marking) + float marker = uMarker; + if (uMarker == -1.0) { + float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb); + marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a; + marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win + } + if (uMarkingType == 1) { + if (marker > 0.0 || imageData.a < 0.05) + discard; + gl_FragColor = packDepthToRGBA(gl_FragCoord.z); + } else { + if (marker == 0.0 || imageData.a < 0.05) + discard; + float depthTest = 1.0; + if (uMarkingDepthTest) { + depthTest = (fragmentDepth >= getDepthPacked(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0; + } + bool isHighlight = intMod(marker, 2.0) > 0.1; + gl_FragColor = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0); + } + #elif defined(dRenderVariant_color) + if (imageData.a < 0.05) + discard; + gl_FragColor = imageData; + gl_FragColor.a *= uAlpha; + + float marker = uMarker; + if (uMarker == -1.0) { + float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb); + marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a; + marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win + } + + #include apply_marker_color + #include apply_fog + #include wboit_write + #include dpoit_write + #endif +} +`;var L9=ua(),oSe={apply_fog:U7,apply_interior_color:V7,apply_light_color:G7,apply_marker_color:z7,assign_clipping_varying:H7,assign_color_varying:j7,assign_group:q7,assign_marker_varying:W7,assign_material_color:Y7,assign_position:X7,assign_size:K7,check_picking_alpha:Z7,clip_instance:Q7,clip_pixel:$7,color_frag_params:J7,color_vert_params:e9,common_clip:t9,common_frag_params:r9,common_vert_params:n9,common:a9,float_to_rgba:i9,light_frag_params:o9,matrix_scale:s9,normal_frag_params:u9,read_from_texture:c9,rgba_to_float:l9,size_vert_params:f9,texture3d_from_1d_trilinear:d9,texture3d_from_2d_linear:m9,texture3d_from_2d_nearest:p9,wboit_write:h9,dpoit_write:v9},sSe=/^(?!\/\/)\s*#include\s+(\S+)/gm,uSe=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*\+\+i\s*\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g,cSe=/[ \t]*\/\/.*\n/g,lSe=/[ \t]*\/\*[\s\S]*?\*\//g,fSe=/\n{2,}/g;function B9(e){return e.replace(sSe,function(t,r){var n=oSe[r];if(!n)throw new Error("empty chunk, '".concat(r,"'"));return n}).trim().replace(cSe,` +`).replace(lSe,` +`).replace(fSe,` +`)}function dSe(e){return e.replace(uSe,mSe)}function mSe(e,t,r,n){for(var a="",i=parseInt(t);i0?v():m=null}},stats:function(){return{gpu:l.stats(),cpu:f.stats()}},formatedStats:function(){for(var g={},b=l.stats(),x=f.stats(),S=0,_=Object.keys(b);S<_.length;S++){var C=_[S],D="".concat((b[C]/1e3/1e3).toFixed(2)),T="".concat(x[C].toFixed(2));g[C]="".concat(D," ms | CPU: ").concat(T," ms")}return g},clear:p,destroy:function(){p()}}}function tCe(e){var t="".concat((e.gpuElapsed/1e3/1e3).toFixed(2)),r="".concat((e.gpuAvg/1e3/1e3).toFixed(2)),n="".concat(e.cpuElapsed.toFixed(2)),a="".concat(e.cpuAvg.toFixed(2));return"".concat(e.label," ").concat(t," ms (avg. ").concat(r," ms) | CPU: ").concat(n," ms (avg. ").concat(a," ms)")}function nR(e){e.map(function(t){var r=tCe(t);t.children.length||t.calls?(console.groupCollapsed(r),t.calls&&console.log(t.calls),nR(t.children),console.groupEnd()):console.log(r)})}function bj(e,t){function r(a){try{return e.getContext(a,t)}catch{return null}}var n=(t?.preferWebGl1?null:r("webgl2"))||r("webgl")||r("experimental-webgl");return or&&console.log("isWebgl2: ".concat(Gt(n))),n}function iR(e,t){switch(t){case e.NO_ERROR:return"no error";case e.INVALID_ENUM:return"invalid enum";case e.INVALID_VALUE:return"invalid value";case e.INVALID_OPERATION:return"invalid operation";case e.INVALID_FRAMEBUFFER_OPERATION:return"invalid framebuffer operation";case e.OUT_OF_MEMORY:return"out of memory";case e.CONTEXT_LOST_WEBGL:return"context lost"}return"unknown error"}function oR(e){var t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL error: '".concat(iR(e,t),"'"))}function rCe(e){for(var t=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),r=0;r= 8');var c=n.provokingVertex;c?.provokingVertex(c.FIRST_VERTEX_CONVENTION);var l=!1,f=new ha(0),d;if(Gt(e)){var m=e.createBuffer(),h=void 0,p=void 0,v=!1,g=function(){e.bindBuffer(e.PIXEL_PACK_BUFFER,m),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,h),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),v=!1,p(),p=void 0,h=void 0};d=function(x,S,_,C,D){return new Promise(function(T,A){if(v){A("Can not call multiple readPixelsAsync at the same time");return}v=!0,e.bindBuffer(e.PIXEL_PACK_BUFFER,m),e.bufferData(e.PIXEL_PACK_BUFFER,_*C*4,e.STREAM_READ),e.readPixels(x,S,_,C,e.RGBA,e.UNSIGNED_BYTE,0),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),p=T,h=D,Cj(e,g)})}}else d=function(x,S,_,C,D){return $(r,void 0,void 0,function(){return J(this,function(T){return aR(e,x,S,_,C,D),[2]})})};var b=new Set;return{gl:e,isWebGL2:Gt(e),get pixelRatio(){var x=typeof window<"u"&&window.devicePixelRatio||1;return x*(t.pixelScale||1)},extensions:n,state:a,stats:i,resources:o,timer:s,get maxTextureSize(){return u.maxTextureSize},get max3dTextureSize(){return u.max3dTextureSize},get maxRenderbufferSize(){return u.maxRenderbufferSize},get maxDrawBuffers(){return u.maxDrawBuffers},get maxTextureImageUnits(){return u.maxTextureImageUnits},namedComputeRenderables:Object.create(null),namedFramebuffers:Object.create(null),namedTextures:Object.create(null),get isContextLost(){return l||e.isContextLost()},contextRestored:f,setContextLost:function(){l=!0},handleContextRestored:function(x){Object.assign(n,tR(e)),a.reset(),a.currentMaterialId=-1,a.currentProgramId=-1,a.currentRenderItemId=-1,o.reset(),b.forEach(function(S){return S.reset()}),x?.(),l=!1,f.next(pn())},createRenderTarget:function(x,S,_,C,D,T){var A=pj(e,o,x,S,_,C,D,T);return b.add(A),P(P({},A),{destroy:function(){A.destroy(),b.delete(A)}})},unbindFramebuffer:function(){return N_(e)},readPixels:function(x,S,_,C,D){aR(e,x,S,_,C,D)},readPixelsAsync:d,waitForGpuCommandsComplete:function(){return nCe(e)},waitForGpuCommandsCompleteSync:function(){return _j(e)},getDrawingBufferPixelData:function(){return aCe(e,a)},clear:function(x,S,_,C){N_(e),a.enable(e.SCISSOR_TEST),a.depthMask(!0),a.colorMask(!0,!0,!0,!0),a.clearColor(x,S,_,C),a.viewport(0,0,e.drawingBufferWidth,e.drawingBufferHeight),a.scissor(0,0,e.drawingBufferWidth,e.drawingBufferHeight),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)},destroy:function(x){var S,_;o.destroy(),rCe(e),x?.doNotForceWebGLContextLoss||((S=e.getExtension("WEBGL_lose_context"))===null||S===void 0||S.loseContext(),(_=e.getExtension("STACKGL_destroy_context"))===null||_===void 0||_.destroy())}}}function Gt(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext}function d7(e){if(Gt(e))return{drawArraysInstanced:e.drawArraysInstanced.bind(e),drawElementsInstanced:e.drawElementsInstanced.bind(e),vertexAttribDivisor:e.vertexAttribDivisor.bind(e),VERTEX_ATTRIB_ARRAY_DIVISOR:e.VERTEX_ATTRIB_ARRAY_DIVISOR};var t=e.getExtension("ANGLE_instanced_arrays");return t===null?null:{drawArraysInstanced:t.drawArraysInstancedANGLE.bind(t),drawElementsInstanced:t.drawElementsInstancedANGLE.bind(t),vertexAttribDivisor:t.vertexAttribDivisorANGLE.bind(t),VERTEX_ATTRIB_ARRAY_DIVISOR:t.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE}}function m7(e){if(Gt(e))return{FRAGMENT_SHADER_DERIVATIVE_HINT:e.FRAGMENT_SHADER_DERIVATIVE_HINT};var t=e.getExtension("OES_standard_derivatives");return t===null?null:{FRAGMENT_SHADER_DERIVATIVE_HINT:t.FRAGMENT_SHADER_DERIVATIVE_HINT_OES}}function p7(e){return Gt(e)?{}:e.getExtension("OES_element_index_uint")}function h7(e){if(Gt(e))return{VERTEX_ARRAY_BINDING:e.VERTEX_ARRAY_BINDING,bindVertexArray:e.bindVertexArray.bind(e),createVertexArray:e.createVertexArray.bind(e),deleteVertexArray:e.deleteVertexArray.bind(e),isVertexArray:e.isVertexArray.bind(e)};var t=e.getExtension("OES_vertex_array_object");return t===null?null:{VERTEX_ARRAY_BINDING:t.VERTEX_ARRAY_BINDING_OES,bindVertexArray:t.bindVertexArrayOES.bind(t),createVertexArray:t.createVertexArrayOES.bind(t),deleteVertexArray:t.deleteVertexArrayOES.bind(t),isVertexArray:t.isVertexArrayOES.bind(t)}}function v7(e){return Gt(e)?{}:e.getExtension("OES_texture_float")}function g7(e){return e.getExtension("OES_texture_float_linear")}function y7(e){if(Gt(e))return{HALF_FLOAT:e.HALF_FLOAT};var t=e.getExtension("OES_texture_half_float");return t===null?null:{HALF_FLOAT:t.HALF_FLOAT_OES}}function b7(e){return e.getExtension("OES_texture_half_float_linear")}function x7(e){if(Gt(e))return{MIN:e.MIN,MAX:e.MAX};var t=e.getExtension("EXT_blend_minmax");return t===null?null:{MIN:t.MIN_EXT,MAX:t.MAX_EXT}}function S7(e){return Gt(e)?{}:e.getExtension("EXT_frag_depth")}function C7(e){if(Gt(e))return e.getExtension("EXT_color_buffer_float")===null?null:(e.getExtension("EXT_float_blend"),{RGBA32F:e.RGBA32F});var t=e.getExtension("WEBGL_color_buffer_float");return t===null?(e.getExtension("OES_texture_float"),Tj(e,e.FLOAT)?{RGBA32F:34836}:null):(e.getExtension("EXT_float_blend"),{RGBA32F:t.RGBA32F_EXT})}function _7(e){if(Gt(e))return e.getExtension("EXT_color_buffer_half_float")===null?null:(e.getExtension("EXT_float_blend"),{RGBA16F:e.RGBA16F});var t=e.getExtension("EXT_color_buffer_half_float");return t===null?(e.getExtension("OES_texture_half_float"),Tj(e,36193)?{RGBA16F:34842}:null):(e.getExtension("EXT_float_blend"),{RGBA16F:t.RGBA16F_EXT})}function w7(e){if(Gt(e))return{drawBuffers:e.drawBuffers.bind(e),COLOR_ATTACHMENT0:e.COLOR_ATTACHMENT0,COLOR_ATTACHMENT1:e.COLOR_ATTACHMENT1,COLOR_ATTACHMENT2:e.COLOR_ATTACHMENT2,COLOR_ATTACHMENT3:e.COLOR_ATTACHMENT3,COLOR_ATTACHMENT4:e.COLOR_ATTACHMENT4,COLOR_ATTACHMENT5:e.COLOR_ATTACHMENT5,COLOR_ATTACHMENT6:e.COLOR_ATTACHMENT6,COLOR_ATTACHMENT7:e.COLOR_ATTACHMENT7,DRAW_BUFFER0:e.DRAW_BUFFER0,DRAW_BUFFER1:e.DRAW_BUFFER1,DRAW_BUFFER2:e.DRAW_BUFFER2,DRAW_BUFFER3:e.DRAW_BUFFER3,DRAW_BUFFER4:e.DRAW_BUFFER4,DRAW_BUFFER5:e.DRAW_BUFFER5,DRAW_BUFFER6:e.DRAW_BUFFER6,DRAW_BUFFER7:e.DRAW_BUFFER7,MAX_COLOR_ATTACHMENTS:e.MAX_COLOR_ATTACHMENTS,MAX_DRAW_BUFFERS:e.MAX_DRAW_BUFFERS};var t=e.getExtension("WEBGL_draw_buffers");return t===null?null:{drawBuffers:t.drawBuffersWEBGL.bind(t),COLOR_ATTACHMENT0:t.COLOR_ATTACHMENT0_WEBGL,COLOR_ATTACHMENT1:t.COLOR_ATTACHMENT1_WEBGL,COLOR_ATTACHMENT2:t.COLOR_ATTACHMENT2_WEBGL,COLOR_ATTACHMENT3:t.COLOR_ATTACHMENT3_WEBGL,COLOR_ATTACHMENT4:t.COLOR_ATTACHMENT4_WEBGL,COLOR_ATTACHMENT5:t.COLOR_ATTACHMENT5_WEBGL,COLOR_ATTACHMENT6:t.COLOR_ATTACHMENT6_WEBGL,COLOR_ATTACHMENT7:t.COLOR_ATTACHMENT7_WEBGL,DRAW_BUFFER0:t.DRAW_BUFFER0_WEBGL,DRAW_BUFFER1:t.DRAW_BUFFER1_WEBGL,DRAW_BUFFER2:t.DRAW_BUFFER2_WEBGL,DRAW_BUFFER3:t.DRAW_BUFFER3_WEBGL,DRAW_BUFFER4:t.DRAW_BUFFER4_WEBGL,DRAW_BUFFER5:t.DRAW_BUFFER5_WEBGL,DRAW_BUFFER6:t.DRAW_BUFFER6_WEBGL,DRAW_BUFFER7:t.DRAW_BUFFER7_WEBGL,MAX_COLOR_ATTACHMENTS:t.MAX_COLOR_ATTACHMENTS_WEBGL,MAX_DRAW_BUFFERS:t.MAX_DRAW_BUFFERS_WEBGL}}function T7(e){var t=e.getExtension("OES_draw_buffers_indexed");return t===null?null:{enablei:t.enableiOES.bind(t),disablei:t.disableiOES.bind(t),blendEquationi:t.blendEquationiOES.bind(t),blendEquationSeparatei:t.blendEquationSeparateiOES.bind(t),blendFunci:t.blendFunciOES.bind(t),blendFuncSeparatei:t.blendFuncSeparateiOES.bind(t),colorMaski:t.colorMaskiOES.bind(t)}}function A7(e){return Gt(e)?{}:e.getExtension("EXT_shader_texture_lod")}function D7(e){if(Gt(e))return{UNSIGNED_INT_24_8:e.UNSIGNED_INT_24_8};var t=e.getExtension("WEBGL_depth_texture");return t===null?null:{UNSIGNED_INT_24_8:t.UNSIGNED_INT_24_8_WEBGL}}function P7(e){if(Gt(e))return{FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING,SRGB8_ALPHA8:e.SRGB8_ALPHA8,SRGB8:e.SRGB8,SRGB:e.SRGB};var t=e.getExtension("EXT_sRGB");return t===null?null:{FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT,SRGB8_ALPHA8:t.SRGB8_ALPHA8_EXT,SRGB8:t.SRGB_ALPHA_EXT,SRGB:t.SRGB_EXT}}function E7(e){if(Gt(e)){var t=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query");return t===null?null:{QUERY_COUNTER_BITS:t.QUERY_COUNTER_BITS_EXT,CURRENT_QUERY:e.CURRENT_QUERY,QUERY_RESULT:e.QUERY_RESULT,QUERY_RESULT_AVAILABLE:e.QUERY_RESULT_AVAILABLE,TIME_ELAPSED:t.TIME_ELAPSED_EXT,TIMESTAMP:t.TIMESTAMP_EXT,GPU_DISJOINT:t.GPU_DISJOINT_EXT,createQuery:e.createQuery.bind(e),deleteQuery:e.deleteQuery.bind(e),isQuery:e.isQuery.bind(e),beginQuery:e.beginQuery.bind(e),endQuery:e.endQuery.bind(e),queryCounter:t.queryCounterEXT.bind(t),getQuery:e.getQuery.bind(e),getQueryParameter:e.getQueryParameter.bind(e)}}else{var t=e.getExtension("EXT_disjoint_timer_query");return t===null?null:{QUERY_COUNTER_BITS:t.QUERY_COUNTER_BITS_EXT,CURRENT_QUERY:t.CURRENT_QUERY_EXT,QUERY_RESULT:t.QUERY_RESULT_EXT,QUERY_RESULT_AVAILABLE:t.QUERY_RESULT_AVAILABLE_EXT,TIME_ELAPSED:t.TIME_ELAPSED_EXT,TIMESTAMP:t.TIMESTAMP_EXT,GPU_DISJOINT:t.GPU_DISJOINT_EXT,createQuery:t.createQueryEXT.bind(t),deleteQuery:t.deleteQueryEXT.bind(t),isQuery:t.isQueryEXT.bind(t),beginQuery:t.beginQueryEXT.bind(t),endQuery:t.endQueryEXT.bind(t),queryCounter:t.queryCounterEXT.bind(t),getQuery:t.getQueryEXT.bind(t),getQueryParameter:t.getQueryObjectEXT.bind(t)}}}function I7(e){var t=e.getExtension("KHR_parallel_shader_compile");return t===null?null:{COMPLETION_STATUS:t.COMPLETION_STATUS_KHR}}function M7(e){return Gt(e)?{}:e.getExtension("OES_fbo_render_mipmap")}function R7(e){if(Gt(e)){var t=e.getExtension("WEBGL_provoking_vertex");if(t)return{FIRST_VERTEX_CONVENTION:t.FIRST_VERTEX_CONVENTION_WEBGL,LAST_VERTEX_CONVENTION:t.LAST_VERTEX_CONVENTION_WEBGL,PROVOKING_VERTEX:t.PROVOKING_VERTEX_WEBGL,provokingVertex:t.provokingVertexWEBGL.bind(t)}}return null}function B7(e){if(Gt(e)){var t=e.getExtension("WEBGL_clip_cull_distance");if(t)return{MAX_CLIP_DISTANCES:t.MAX_CLIP_DISTANCES_WEBGL,MAX_CULL_DISTANCES:t.MAX_CULL_DISTANCES_WEBGL,MAX_COMBINED_CLIP_AND_CULL_DISTANCES:t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL,CLIP_DISTANCE0:t.CLIP_DISTANCE0_WEBGL,CLIP_DISTANCE1:t.CLIP_DISTANCE1_WEBGL,CLIP_DISTANCE2:t.CLIP_DISTANCE2_WEBGL,CLIP_DISTANCE3:t.CLIP_DISTANCE3_WEBGL,CLIP_DISTANCE4:t.CLIP_DISTANCE4_WEBGL,CLIP_DISTANCE5:t.CLIP_DISTANCE5_WEBGL,CLIP_DISTANCE6:t.CLIP_DISTANCE6_WEBGL,CLIP_DISTANCE7:t.CLIP_DISTANCE7_WEBGL}}return null}function O7(e){if(Gt(e)){var t=e.getExtension("EXT_conservative_depth");if(t)return{}}return null}function F7(e){if(Gt(e)){var t=e.getExtension("WEBGL_stencil_texturing");if(t)return{DEPTH_STENCIL_TEXTURE_MODE:t.DEPTH_STENCIL_TEXTURE_MODE_WEBGL,STENCIL_INDEX:t.STENCIL_INDEX_WEBGL}}return null}function L7(e){var t=e.getExtension("EXT_clip_control");return t?{LOWER_LEFT:t.LOWER_LEFT_EXT,UPPER_LEFT:t.UPPER_LEFT_EXT,NEGATIVE_ONE_TO_ONE:t.NEGATIVE_ONE_TO_ONE_EXT,ZERO_TO_ONE:t.ZERO_TO_ONE_EXT,CLIP_ORIGIN:t.CLIP_ORIGIN_EXT,CLIP_DEPTH_MODE:t.CLIP_DEPTH_MODE_EXT,clipControl:t.clipControlEXT.bind(t)}:null}function k7(e){if(!Gt(e))return!1;if(typeof navigator<"u"){var t=window.navigator.userAgent.match(/Firefox\/([0-9]+)\./);if(!t)return!0;var r=parseInt(t[1]);return r>=85}return!1}var oCe=` +attribute vec4 aPosition; + +void main() { + gl_Position = aPosition; +}`,sCe=` +precision mediump float; +uniform vec4 uColor; +uniform sampler2D uTexture; + +void main() { + gl_FragColor = texture2D(uTexture, vec2(0.5, 0.5)) * uColor; +}`,uCe=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function Tj(e,t){var r=ax(e,{type:"vert",source:oCe}),n=ax(e,{type:"frag",source:sCe});if(!r||!n)return!1;var a=k_(e);e.attachShader(a,r),e.attachShader(a,n),e.linkProgram(a),e.useProgram(a);var i=e.getAttribLocation(a,"aPosition"),o=e.getUniformLocation(a,"uColor");if(!o)return or&&console.log("error getting 'uColor' uniform location"),!1;var s=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,uCe,e.STATIC_DRAW),e.enableVertexAttribArray(i),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0);var u=e.createTexture(),c=new Uint8Array([255,255,255,255]);e.bindTexture(e.TEXTURE_2D,u),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,c);var l=e.createTexture();e.bindTexture(e.TEXTURE_2D,l),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,t,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);var f=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,f),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l,0);var d=e.checkFramebufferStatus(e.FRAMEBUFFER);if(d!==e.FRAMEBUFFER_COMPLETE)return or&&console.log("error creating framebuffer for '".concat(t,"'")),!1;e.bindTexture(e.TEXTURE_2D,u),e.uniform4fv(o,[0,10,20,1]),e.drawArrays(e.TRIANGLES,0,6),e.bindTexture(e.TEXTURE_2D,l),e.bindFramebuffer(e.FRAMEBUFFER,null),e.clearColor(1,0,0,1),e.clear(e.COLOR_BUFFER_BIT),e.uniform4fv(o,[0,1/10,1/20,1]),e.drawArrays(e.TRIANGLES,0,6);var m=new Uint8Array(4);if(e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,m),m[0]!==0||m[1]<248||m[2]<248||m[3]<254)return or&&console.log("not able to actually render to '".concat(t,"' texture")),!1;if(t===e.FLOAT){e.bindFramebuffer(e.FRAMEBUFFER,f);var h=new Float32Array(4);e.readPixels(0,0,1,1,e.RGBA,e.FLOAT,h);var p=e.getError();if(p)return or&&console.log("error reading float pixels: '".concat(iR(e,p),"'")),!1}return!0}var sR=ua();function cCe(e,t){switch(t){case"image-uint8":return e.TEXTURE_2D;case"image-float32":return e.TEXTURE_2D;case"image-float16":return e.TEXTURE_2D;case"image-depth":return e.TEXTURE_2D}if(Gt(e))switch(t){case"image-int32":return e.TEXTURE_2D;case"volume-uint8":return e.TEXTURE_3D;case"volume-float32":return e.TEXTURE_3D;case"volume-float16":return e.TEXTURE_3D}throw new Error("unknown texture kind '".concat(t,"'"))}function Ij(e,t,r){switch(t){case"alpha":return Gt(e)&&r==="float"?e.RED:Gt(e)&&r==="int"?e.RED_INTEGER:e.ALPHA;case"rgb":return Gt(e)&&r==="int"?e.RGB_INTEGER:e.RGB;case"rg":if(Gt(e)&&r==="float")return e.RG;if(Gt(e)&&r==="int")return e.RG_INTEGER;throw new Error('texture format "rg" requires webgl2 and type "float" or int"');case"rgba":return Gt(e)&&r==="int"?e.RGBA_INTEGER:e.RGBA;case"depth":return e.DEPTH_COMPONENT}}function lCe(e,t,r){if(Gt(e))switch(t){case"alpha":switch(r){case"ubyte":return e.ALPHA;case"float":return e.R32F;case"fp16":return e.R16F;case"int":return e.R32I}case"rg":switch(r){case"ubyte":return e.RG;case"float":return e.RG32F;case"fp16":return e.RG16F;case"int":return e.RG32I}case"rgb":switch(r){case"ubyte":return e.RGB;case"float":return e.RGB32F;case"fp16":return e.RGB16F;case"int":return e.RGB32I}case"rgba":switch(r){case"ubyte":return e.RGBA;case"float":return e.RGBA32F;case"fp16":return e.RGBA16F;case"int":return e.RGBA32I}case"depth":switch(r){case"ushort":return e.DEPTH_COMPONENT16;case"float":return e.DEPTH_COMPONENT32F}}return Ij(e,t,r)}function Mj(e,t,r,n,a){var i=fCe(e)*dCe(t);return i*r*n*(a||1)}function fCe(e){switch(e){case"alpha":return 1;case"rg":return 2;case"rgb":return 3;case"rgba":return 4;case"depth":return 4}}function dCe(e){switch(e){case"ubyte":return 1;case"ushort":return 2;case"float":return 4;case"fp16":return 2;case"int":return 4}}function mCe(e,t,r){switch(r){case"ubyte":return e.UNSIGNED_BYTE;case"ushort":return e.UNSIGNED_SHORT;case"float":return e.FLOAT;case"fp16":if(t.textureHalfFloat)return t.textureHalfFloat.HALF_FLOAT;throw new Error('extension "texture_half_float" unavailable');case"int":if(Gt(e))return e.INT;throw new Error('texture type "int" requires webgl2')}}function Aj(e,t){switch(t){case"nearest":return e.NEAREST;case"linear":return e.LINEAR}}function U_(e,t,r){switch(r){case"depth":return e.DEPTH_ATTACHMENT;case"stencil":return e.STENCIL_ATTACHMENT;case"color0":case 0:return e.COLOR_ATTACHMENT0}if(t.drawBuffers)switch(r){case"color1":case 1:return t.drawBuffers.COLOR_ATTACHMENT1;case"color2":case 2:return t.drawBuffers.COLOR_ATTACHMENT2;case"color3":case 3:return t.drawBuffers.COLOR_ATTACHMENT3;case"color4":case 4:return t.drawBuffers.COLOR_ATTACHMENT4;case"color5":case 5:return t.drawBuffers.COLOR_ATTACHMENT5;case"color6":case 6:return t.drawBuffers.COLOR_ATTACHMENT6;case"color7":case 7:return t.drawBuffers.COLOR_ATTACHMENT7}throw new Error("unknown texture attachment")}function Dj(e){return typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement}function pCe(e,t,r){return t===r.TEXTURE_2D}function Pj(e,t,r){return t===r.TEXTURE_3D}function Ej(e){var t=e.createTexture();if(t===null)throw new Error("Could not create WebGL texture");return t}function fj(e,t,r,n,a,i){var o=sR(),s=Ej(e);if(r.endsWith("float32")&&a!=="float"||r.endsWith("float16")&&a!=="fp16"||r.endsWith("uint8")&&a!=="ubyte"||r.endsWith("int32")&&a!=="int"||r.endsWith("depth")&&a!=="ushort"&&a!=="float")throw new Error("texture kind '".concat(r,"' and type '").concat(a,"' are incompatible"));if(!t.depthTexture&&n==="depth")throw new Error("extension 'WEBGL_depth_texture' needed for 'depth' texture format");var u=cCe(e,r),c=Aj(e,i),l=Ij(e,n,a),f=lCe(e,n,a),d=mCe(e,t,a);function m(){e.bindTexture(u,s),e.texParameteri(u,e.TEXTURE_MAG_FILTER,c),e.texParameteri(u,e.TEXTURE_MIN_FILTER,c),e.texParameteri(u,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(u,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(u,null)}m();var h=0,p=0,v=0,g,b=!1,x=!1;function S(T,A,E){if(T===0||A===0||Gt(e)&&u===e.TEXTURE_3D&&E===0)throw new Error("empty textures are not allowed");if(!(h===T&&p===A&&v===(E||0)))if(h=T,p=A,v=E||0,e.bindTexture(u,s),u===e.TEXTURE_2D)e.texImage2D(u,0,f,h,p,0,l,d,null);else if(Gt(e)&&u===e.TEXTURE_3D&&v!==void 0)e.texImage3D(u,0,f,h,p,v,0,l,d,null);else throw new Error("unknown texture target")}S(1,1,Gt(e)&&u===e.TEXTURE_3D?1:0);function _(T,A){if(A===void 0&&(A=!1),T.width===0||T.height===0||!Dj(T)&&Gt(e)&&Pj(T,u,e)&&T.depth===0)throw new Error("empty textures are not allowed");if(e.bindTexture(u,s),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),Dj(T))h=T.width,p=T.height,e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.bindTexture(e.TEXTURE_2D,s),e.texImage2D(e.TEXTURE_2D,0,f,l,d,T);else if(pCe(T,u,e)){var E=T.filter?Aj(e,T.filter):c;e.texParameteri(u,e.TEXTURE_MAG_FILTER,E),e.texParameteri(u,e.TEXTURE_MIN_FILTER,E),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!!T.flipY),A?e.texSubImage2D(u,0,0,0,T.width,T.height,l,d,T.array):(h=T.width,p=T.height,e.texImage2D(u,0,f,h,p,0,l,d,T.array))}else if(Gt(e)&&Pj(T,u,e))e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),A?e.texSubImage3D(u,0,0,0,0,T.width,T.height,T.depth,l,d,T.array):(h=T.width,p=T.height,v=T.depth,e.texImage3D(u,0,f,h,p,v,0,l,d,T.array));else throw new Error("unknown texture target");e.bindTexture(u,null),g=T}function C(){if(u!==e.TEXTURE_2D)throw new Error("mipmap only supported for 2d textures");if(Gt(e)||Am(h)&&Am(p))e.bindTexture(u,s),e.texParameteri(u,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.generateMipmap(u),e.bindTexture(u,null),b=!0;else throw new Error("mipmap unsupported for non-power-of-two textures and webgl1")}function D(T,A,E){if(T.bind(),u===e.TEXTURE_2D)e.framebufferTexture2D(e.FRAMEBUFFER,U_(e,t,A),e.TEXTURE_2D,s,0);else if(Gt(e)&&u===e.TEXTURE_3D){if(E===void 0)throw new Error("need `layer` to attach 3D texture");e.framebufferTextureLayer(e.FRAMEBUFFER,U_(e,t,A),s,0,E)}else throw new Error("unknown/unsupported texture target")}return{id:o,target:u,format:l,internalFormat:f,type:d,filter:c,getWidth:function(){return h},getHeight:function(){return p},getDepth:function(){return v},getByteCount:function(){return Mj(n,a,h,p,v)},define:S,load:_,mipmap:C,bind:function(T){e.activeTexture(e.TEXTURE0+T),e.bindTexture(u,s)},unbind:function(T){e.activeTexture(e.TEXTURE0+T),e.bindTexture(u,null)},attachFramebuffer:D,detachFramebuffer:function(T,A){if(T.bind(),u===e.TEXTURE_2D)e.framebufferTexture2D(e.FRAMEBUFFER,U_(e,t,A),e.TEXTURE_2D,null,0);else if(Gt(e)&&u===e.TEXTURE_3D)e.framebufferTextureLayer(e.FRAMEBUFFER,U_(e,t,A),null,0,0);else throw new Error("unknown texture target")},reset:function(){s=Ej(e),m();var T=[h,p,v],A=T[0],E=T[1],I=T[2];h=0,p=0,v=0,S(A,E,I),g&&_(g),b&&C()},destroy:function(){x||(e.deleteTexture(s),x=!0)}}}function uR(e,t,r){var n=e.resources,a=[];return Object.keys(t).forEach(function(i){var o=t[i];if(o.type==="texture"){var s=r[i];if(s)if(o.kind==="texture")a[a.length]=[i,s.ref.value];else{var u=n.texture(o.kind,o.format,o.dataType,o.filter);u.load(s.ref.value),a[a.length]=[i,u]}}}),a}function cR(e,t,r){var n=new Image;n.onload=function(){r.load(n),M.update(t,r)},n.src=e}function hCe(e,t){switch(t){case"nx":return e.TEXTURE_CUBE_MAP_NEGATIVE_X;case"ny":return e.TEXTURE_CUBE_MAP_NEGATIVE_Y;case"nz":return e.TEXTURE_CUBE_MAP_NEGATIVE_Z;case"px":return e.TEXTURE_CUBE_MAP_POSITIVE_X;case"py":return e.TEXTURE_CUBE_MAP_POSITIVE_Y;case"pz":return e.TEXTURE_CUBE_MAP_POSITIVE_Z}}function dj(e,t,r,n){var a=e.TEXTURE_CUBE_MAP,i=e.LINEAR,o=e.RGBA,s=e.RGBA,u=e.UNSIGNED_BYTE,c=0,l=e.createTexture();e.bindTexture(a,l);var f=0;Ua(t,function(m,h){if(m){var p=0,v=hCe(e,h),g=new Image;m instanceof File?g.src=URL.createObjectURL(m):Dm(m)?m.then(function(b){g.src=URL.createObjectURL(b)}):g.src=m,g.addEventListener("load",function(){c===0&&(c=g.width),e.texImage2D(v,p,o,c,c,0,s,u,null),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.bindTexture(a,l),e.texImage2D(v,p,o,s,u,g),f+=1,f===6&&(d||(r?(e.texParameteri(a,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.generateMipmap(a)):e.texParameteri(a,e.TEXTURE_MIN_FILTER,i),e.texParameteri(a,e.TEXTURE_MAG_FILTER,i)),n?.(d))}),g.addEventListener("error",function(){n?.(!0)})}});var d=!1;return{id:sR(),target:a,format:s,internalFormat:o,type:u,filter:i,getWidth:function(){return c},getHeight:function(){return c},getDepth:function(){return 0},getByteCount:function(){return Mj("rgba","ubyte",c,c,0)*6*(r?2:1)},define:function(){},load:function(){},mipmap:function(){},bind:function(m){e.activeTexture(e.TEXTURE0+m),e.bindTexture(a,l)},unbind:function(m){e.activeTexture(e.TEXTURE0+m),e.bindTexture(a,null)},attachFramebuffer:function(){},detachFramebuffer:function(){},reset:function(){},destroy:function(){d||(e.deleteTexture(l),d=!0)}}}var Rj=-1;function Bj(e){return e.format===Rj}function Ga(e){var t,r=(t=e?.TEXTURE_2D)!==null&&t!==void 0?t:3553;return{id:sR(),target:r,format:Rj,internalFormat:0,type:0,filter:0,getWidth:function(){return 0},getHeight:function(){return 0},getDepth:function(){return 0},getByteCount:function(){return 0},define:function(){},load:function(){},mipmap:function(){},bind:function(n){e&&(e.activeTexture(e.TEXTURE0+n),e.bindTexture(r,null))},unbind:function(n){e&&(e.activeTexture(e.TEXTURE0+n),e.bindTexture(r,null))},attachFramebuffer:function(){throw new Error("cannot attach null-texture to a framebuffer")},detachFramebuffer:function(){throw new Error("cannot detach null-texture from a framebuffer")},reset:function(){},destroy:function(){}}}function Qa(e,t,r,n){var a=vCe(e,t,r,n);return r.palette?(M.updateIfChanged(a.dUsePalette,!0),gCe(r.palette,a.tPalette)):M.updateIfChanged(a.dUsePalette,!1),a}function vCe(e,t,r,n){switch(r.granularity){case"uniform":return bCe(e,r.color,n);case"instance":return e.nonInstanceable?Oj(e,r.color,n):xCe(e,r.color,n);case"group":return Oj(e,r.color,n);case"groupInstance":return SCe(e,r.color,n);case"vertex":return CCe(t,r.color,n);case"vertexInstance":return _Ce(t,r.color,n);case"volume":return Fj(r.grid,"volume",n);case"volumeInstance":return Fj(r.grid,"volumeInstance",n);case"direct":return wCe(n)}}function gCe(e,t){var r=!0,n=t.ref.value;if(e.colors.length!==n.width||n.filter!==e.filter)r=!1;else for(var a=n.array,i=0,o=0,s=e.colors;o=t*16?r.transform.ref.value:new Float32Array(t*16);a.set(e),M.update(r.transform,a),M.updateIfChanged(r.uInstanceCount,t),M.updateIfChanged(r.instanceCount,t);var i=r.aTransform.ref.value.length>=t*16?r.aTransform.ref.value:new Float32Array(t*16);M.update(r.aTransform,i);var o=r.extraTransform.ref.value.length>=t*16?r.extraTransform.ref.value:new Float32Array(t*16);M.update(r.extraTransform,U0(o,t));var s=r.aInstance.ref.value.length>=t?r.aInstance.ref.value:new Float32Array(t);M.update(r.aInstance,Qi(s,t)),M.update(r.hasReflection,n)}else r={aTransform:M.create(new Float32Array(t*16)),matrix:M.create(se.identity()),transform:M.create(new Float32Array(e)),extraTransform:M.create(U0(new Float32Array(t*16),t)),uInstanceCount:M.create(t),instanceCount:M.create(t),aInstance:M.create(Qi(new Float32Array(t))),hasReflection:M.create(n)};return fR(r),r}var lR=new Float32Array(16);se.toArray(se.identity(),lR,0);function V0(e){return ox(new Float32Array(lR),1,e)}function U0(e,t){for(var r=0;r1.2&&(n=2)),{resolution:r,stride:n}}}var Ze;(function(e){e.MaterialCategory={category:"Material"},e.ShadingCategory={category:"Shading"},e.CustomQualityParamInfo={category:"Custom Quality",hideIf:function(o){return typeof o.quality<"u"&&o.quality!=="custom"}},e.Params={alpha:w.Numeric(1,{min:0,max:1,step:.01},{label:"Opacity",isEssential:!0,description:"How opaque/transparent the representation is rendered."}),quality:w.Select("auto",sx,{isEssential:!0,description:"Visual/rendering quality of the representation."}),material:Pi.getParam(),clip:w.Group(Ol.Params),instanceGranularity:w.Boolean(!1,{description:"Use instance granularity for marker, transparency, clipping, overpaint, substance data to save memory."})};function t(o,s,u){o===void 0&&(o=Xt.grey),s===void 0&&(s=1),u||(u=V0());var c=hr(1,u.instanceCount.ref.value,1,function(){return Gi},!1,function(){return!1}),l={color:Bl({},{value:o,lightness:0,saturation:0}),size:V_({},{value:s})};return{transform:u,locationIterator:c,theme:l}}e.createSimple=t;function r(o,s){var u=Ol.getClip(o.clip);return{alpha:M.create(o.alpha),uAlpha:M.create(o.alpha),uVertexCount:M.create(s.vertexCount),uGroupCount:M.create(s.groupCount),drawCount:M.create(s.drawCount),uMetalness:M.create(o.material.metalness),uRoughness:M.create(o.material.roughness),uBumpiness:M.create(o.material.bumpiness),dLightCount:M.create(1),dColorMarker:M.create(!0),dClipObjectCount:M.create(u.objects.count),dClipVariant:M.create(u.variant),uClipObjectType:M.create(u.objects.type),uClipObjectInvert:M.create(u.objects.invert),uClipObjectPosition:M.create(u.objects.position),uClipObjectRotation:M.create(u.objects.rotation),uClipObjectScale:M.create(u.objects.scale),instanceGranularity:M.create(o.instanceGranularity)}}e.createValues=r;function n(o,s){M.updateIfChanged(o.alpha,s.alpha),M.updateIfChanged(o.uMetalness,s.material.metalness),M.updateIfChanged(o.uRoughness,s.material.roughness),M.updateIfChanged(o.uBumpiness,s.material.bumpiness);var u=Ol.getClip(s.clip);M.updateIfChanged(o.dClipObjectCount,u.objects.count),M.updateIfChanged(o.dClipVariant,u.variant),M.update(o.uClipObjectType,u.objects.type),M.update(o.uClipObjectInvert,u.objects.invert),M.update(o.uClipObjectPosition,u.objects.position),M.update(o.uClipObjectRotation,u.objects.rotation),M.update(o.uClipObjectScale,u.objects.scale),M.updateIfChanged(o.instanceGranularity,s.instanceGranularity)}e.updateValues=n;function a(o){o===void 0&&(o={});var s=o.alpha===void 0?!0:o.alpha===1;return{disposed:!1,visible:!0,alphaFactor:1,pickable:!0,colorOnly:!1,opaque:s,writeDepth:s}}e.createRenderableState=a;function i(o,s){o.opaque=s.alpha*o.alphaFactor>=1,o.writeDepth=o.opaque}e.updateRenderableState=i})(Ze||(Ze={}));function zj(e,t,r,n){for(var a=t;a0),M.updateIfChanged(r.dOverpaintType,t),r):{tOverpaint:M.create(n),uOverpaintTexDim:M.create(Me.create(n.width,n.height)),dOverpaint:M.create(e>0),tOverpaintGrid:M.create(Ga()),uOverpaintGridDim:M.create(y.create(1,1,1)),uOverpaintGridTransform:M.create(Wt.create(0,0,0,1)),dOverpaintType:M.create(t),uOverpaintStrength:M.create(1)}}var Gj={array:new Uint8Array(4),width:1,height:1};function Uo(e){return e?(M.update(e.tOverpaint,Gj),M.update(e.uOverpaintTexDim,Me.create(1,1)),e):{tOverpaint:M.create(Gj),uOverpaintTexDim:M.create(Me.create(1,1)),dOverpaint:M.create(!1),tOverpaintGrid:M.create(Ga()),uOverpaintGridDim:M.create(y.create(1,1,1)),uOverpaintGridTransform:M.create(Wt.create(0,0,0,1)),dOverpaintType:M.create("groupInstance"),uOverpaintStrength:M.create(1)}}function qj(e,t,r,n){for(var a=t;a0),M.updateIfChanged(r.transparencyAverage,mR(n.array,e)),M.updateIfChanged(r.dTransparencyType,t),r):{tTransparency:M.create(n),uTransparencyTexDim:M.create(Me.create(n.width,n.height)),dTransparency:M.create(e>0),transparencyAverage:M.create(0),tTransparencyGrid:M.create(Ga()),uTransparencyGridDim:M.create(y.create(1,1,1)),uTransparencyGridTransform:M.create(Wt.create(0,0,0,1)),dTransparencyType:M.create(t),uTransparencyStrength:M.create(1)}}var jj={array:new Uint8Array(1),width:1,height:1};function Vo(e){return e?(M.update(e.tTransparency,jj),M.update(e.uTransparencyTexDim,Me.create(1,1)),e):{tTransparency:M.create(jj),uTransparencyTexDim:M.create(Me.create(1,1)),dTransparency:M.create(!1),transparencyAverage:M.create(0),tTransparencyGrid:M.create(Ga()),uTransparencyGridDim:M.create(y.create(1,1,1)),uTransparencyGridTransform:M.create(Wt.create(0,0,0,1)),dTransparencyType:M.create("groupInstance"),uTransparencyStrength:M.create(1)}}function Kj(e,t,r,n){return e.fill(n,t,r),!0}function Zj(e,t,r){e.fill(0,t,r)}function Qj(e,t,r){var n=Vn(Math.max(1,e),1,Uint8Array,r&&r.tClipping.ref.value.array);return r?(M.update(r.tClipping,n),M.update(r.uClippingTexDim,Me.create(n.width,n.height)),M.updateIfChanged(r.dClipping,e>0),M.updateIfChanged(r.dClippingType,t),r):{tClipping:M.create(n),uClippingTexDim:M.create(Me.create(n.width,n.height)),dClipping:M.create(e>0),dClippingType:M.create(t)}}var Xj={array:new Uint8Array(1),width:1,height:1};function Go(e){return e?(M.update(e.tClipping,Xj),M.update(e.uClippingTexDim,Me.create(1,1)),M.updateIfChanged(e.dClipping,!1),e):{tClipping:M.create(Xj),uClippingTexDim:M.create(Me.create(1,1)),dClipping:M.create(!1),dClippingType:M.create("groupInstance")}}function Jj(e,t,r,n){for(var a=t;a0),M.updateIfChanged(r.dSubstanceType,t),r):{tSubstance:M.create(n),uSubstanceTexDim:M.create(Me.create(n.width,n.height)),dSubstance:M.create(e>0),tSubstanceGrid:M.create(Ga()),uSubstanceGridDim:M.create(y.create(1,1,1)),uSubstanceGridTransform:M.create(Wt.create(0,0,0,1)),dSubstanceType:M.create(t),uSubstanceStrength:M.create(1)}}var $j={array:new Uint8Array(4),width:1,height:1};function zo(e){return e?(M.update(e.tSubstance,$j),M.update(e.uSubstanceTexDim,Me.create(1,1)),e):{tSubstance:M.create($j),uSubstanceTexDim:M.create(Me.create(1,1)),dSubstance:M.create(!1),tSubstanceGrid:M.create(Ga()),uSubstanceGridDim:M.create(y.create(1,1,1)),uSubstanceGridTransform:M.create(Wt.create(0,0,0,1)),dSubstanceType:M.create("groupInstance"),uSubstanceStrength:M.create(1)}}var pt;(function(e){function t(I,R,B,O,z,k,G){return G?i(I,R,B,O,z,k,G):a(I,R,B,O,z,k)}e.create=t;function r(I){var R=I?I.vertexBuffer.ref.value:new Float32Array(0),B=I?I.indexBuffer.ref.value:new Uint32Array(0),O=I?I.normalBuffer.ref.value:new Float32Array(0),z=I?I.groupBuffer.ref.value:new Float32Array(0);return t(R,B,O,z,0,0,I)}e.createEmpty=r;function n(I){return ga([I.vertexCount,I.triangleCount,I.vertexBuffer.ref.version,I.indexBuffer.ref.version,I.normalBuffer.ref.version,I.groupBuffer.ref.version])}function a(I,R,B,O,z,k){var G=xe(),V,U=-1,Q=-1,W={kind:"mesh",vertexCount:z,triangleCount:k,vertexBuffer:M.create(I),indexBuffer:M.create(R),normalBuffer:M.create(B),groupBuffer:M.create(O),varyingGroup:M.create(!1),get boundingSphere(){var X=n(W);if(X!==U){var ae=Cu(W.vertexBuffer.ref.value,W.vertexCount,1);xe.copy(G,ae),U=X}return G},get groupMapping(){return W.groupBuffer.ref.version!==Q&&(V=Nc(W.groupBuffer.ref.value,W.vertexCount),Q=W.groupBuffer.ref.version),V},setBoundingSphere:function(X){xe.copy(G,X),U=n(W)},meta:{}};return W}function i(I,R,B,O,z,k,G){return G.vertexCount=z,G.triangleCount=k,M.update(G.vertexBuffer,I),M.update(G.indexBuffer,R),M.update(G.normalBuffer,B),M.update(G.groupBuffer,O),G}function o(I){var R=I.vertexCount,B=I.triangleCount,O=I.vertexBuffer.ref.value,z=I.indexBuffer.ref.value,k=I.normalBuffer.ref.value.length>=R*3?I.normalBuffer.ref.value:new Float32Array(R*3);k===I.normalBuffer.ref.value&&k.fill(0,0,R*3),M_(O,z,k,R,B),M.update(I.normalBuffer,k)}e.computeNormals=o;function s(I,R){R===void 0&&(R=3);for(var B=I.vertexBuffer.ref.value,O=new Map,z=function(X,ae){return"".concat(X[0].toFixed(ae),"|").concat(X[1].toFixed(ae),"|").concat(X[2].toFixed(ae))},k=0,G=y(),V=0,U=I.vertexCount;Vre)){var K=B.get(Ke);if(!(R[K[0]].includes(K[1])&&!(!((z=B.get(K[0]))===null||z===void 0)&&z.includes(K[1])))&&(y.fromArray(j,Q,Ke*3),y.fromArray(Z,Q,K[0]*3),y.fromArray(Y,Q,K[1]*3),y.sub(N,Z,j),y.sub(ee,Y,j),y.add(me,N,ee),!(y.squaredDistance(j,Z)>=O))){for(var ge=!1,Pe=0,Ie=R[Ke];Pe0?He.add3(ae,Ke,K[0],K[1]):He.add3(ae,K[1],K[0],Ke),te.add(Ke),te.add(K[0]),te.add(K[1]),q+=1)}}}var Ne=He.compact(ae);return I.triangleCount=q,M.update(G,Ne),I}function b(I,R,B){for(var O=B.iterations,z=B.lambda,k=y(),G=y(),V=y(),U=y(),Q=-z,W=new Float32Array(I.vertexBuffer.ref.value.length),X=function(q){var F=I.vertexBuffer.ref.value;W.set(F),R.forEach(function(Z,Y){if(Z.length===2){y.fromArray(k,F,Y*3),y.fromArray(G,F,Z[0]*3),y.fromArray(V,F,Z[1]*3);var H=1/y.distance(k,G),N=1/y.distance(k,V);y.scale(G,G,H),y.scale(V,V,N),y.add(U,G,V),y.scale(U,U,1/(H+N)),y.sub(U,U,k),y.scale(U,U,q),y.add(U,k,U),y.toArray(U,W,Y*3)}});var j=I.vertexBuffer.ref.value;M.update(I.vertexBuffer,W),W=j},ae=0;ae0&&b(!0),u&&n>0&&b(!1),{vertices:new Float32Array(d),normals:new Float32Array(m),indices:new Uint32Array(f)};function g(){for(var x=y.zero(),S=(n-r)/a,_=0;_<=o;++_){for(var C=[],D=_/o,T=D*(n-r)+r,A=0;A<=i;++A){var E=A/i,I=E*l+c,R=Math.sin(I),B=Math.cos(I);d.push(T*R,-D*a+v,T*B),y.normalize(x,y.set(x,R,S,B)),m.push.apply(m,x),C.push(h++)}p.push(C)}for(var A=0;Aa&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>i)return console.warn("canvas to small"),this.placeholder;this.mapped[t]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH,nw:this.scratchW/this.lineHeight,nh:this.scratchH/this.lineHeight};for(var s=0;sa&&(a=c);var l=Math.abs(e[u+1]);l>a&&(a=l);var f=Math.abs(t[o]);f>i&&(i=f)}return Math.max(i,n+n*a)}var $s=y(),Ul=y(),ux=y(),Bq=He.add,Z_=He.add3,Ji;(function(e){function t(r,n,a){r===void 0&&(r=2048),n===void 0&&(n=1024);var i=He.create(Float32Array,1,n,a?a.groupBuffer.ref.value:r),o=He.create(Float32Array,3,n,a?a.startBuffer.ref.value:r),s=He.create(Float32Array,3,n,a?a.endBuffer.ref.value:r),u=function(f,d,m,h,p,v,g){for(var b=0;b<4;++b)Z_(o,f,d,m),Z_(s,h,p,v),Bq(i,g)},c=function(f,d,m){for(var h=0;h<4;++h)Z_(o,f[0],f[1],f[2]),Z_(s,d[0],d[1],d[2]),Bq(i,m)},l=function(f,d,m,h){var p=y.distance(f,d),v=m%2!==0,g=Math.floor((m+1)/2),b=p/(m+.5);y.setMagnitude(ux,y.sub(ux,d,f),b),y.copy($s,f);for(var x=0;xa.lineCount)&&e2e(f,p,v),Kr.create(p,v,d,m,h,f,a)}}}e.create=t})(Ji||(Ji={}));function e2e(e,t,r){for(var n=0;nx.lineCount&&(M.update(x.mappingBuffer,m),M.update(x.indexBuffer,h)),x.lineCount=b,M.update(x.groupBuffer,p),M.update(x.startBuffer,v),M.update(x.endBuffer,g),x}function s(m,h){var p=m.startBuffer.ref.value;kc(h,p,0,m.lineCount*4),M.update(m.startBuffer,p);var v=m.endBuffer.ref.value;kc(h,v,0,m.lineCount*4),M.update(m.endBuffer,v)}e.transform=s,e.Params=P(P({},Ze.Params),{sizeFactor:w.Numeric(2,{min:0,max:10,step:.1}),lineSizeAttenuation:w.Boolean(!1)}),e.Utils={Params:e.Params,createEmpty:r,createValues:c,createValuesSimple:l,updateValues:f,updateBoundingSphere:d,createRenderableState:Ze.createRenderableState,updateRenderableState:Ze.updateRenderableState,createPositionIterator:u};function u(m,h){var p=m.lineCount*4,v=h.instanceCount.ref.value,g=Ms(),b=g.position,x=m.startBuffer.ref.value,S=m.endBuffer.ref.value,_=h.aTransform.ref.value,C=function(D,T){var A=D%4===0?x:S;return T<0?y.fromArray(b,A,D*3):y.transformMat4Offset(b,A,_,0,D*3,T*16),g};return hr(p,v,2,C)}function c(m,h,p,v,g){var b=p.instanceCount,x=p.groupCount,S=u(m,h),_=Qa(p,S,v.color),C=Ho(p,v.size),D=g.instanceGranularity?bn(b,"instance"):bn(b*x,"groupInstance"),T=Uo(),A=Vo(),E=zo(),I=Go(),R={drawCount:m.lineCount*2*3,vertexCount:m.lineCount*4,groupCount:x,instanceCount:b},B=xe.clone(m.boundingSphere),O=Da(B,h.aTransform.ref.value,b,0);return P(P(P(P(P(P(P(P(P(P({dGeometryType:M.create("lines"),aMapping:m.mappingBuffer,aGroup:m.groupBuffer,aStart:m.startBuffer,aEnd:m.endBuffer,elements:m.indexBuffer,boundingSphere:M.create(O),invariantBoundingSphere:M.create(B),uInvariantBoundingSphere:M.create(Wt.ofSphere(B))},_),C),D),T),A),E),I),h),Ze.createValues(g,R)),{uSizeFactor:M.create(g.sizeFactor),dLineSizeAttenuation:M.create(g.lineSizeAttenuation),uDoubleSided:M.create(!0),dFlipSided:M.create(!1)})}function l(m,h,p,v,g){var b=Ze.createSimple(p,v,g),x=P(P({},w.getDefaultValues(e.Params)),h);return c(m,b.transform,b.locationIterator,b.theme,x)}function f(m,h){Ze.updateValues(m,h),M.updateIfChanged(m.uSizeFactor,h.sizeFactor),M.updateIfChanged(m.dLineSizeAttenuation,h.lineSizeAttenuation)}function d(m,h){var p=xe.clone(h.boundingSphere),v=Da(p,m.aTransform.ref.value,m.instanceCount.ref.value,0);xe.equals(v,m.boundingSphere.ref.value)||M.update(m.boundingSphere,v),xe.equals(p,m.invariantBoundingSphere.ref.value)||(M.update(m.invariantBoundingSphere,p),M.update(m.uInvariantBoundingSphere,Wt.fromSphere(m.uInvariantBoundingSphere.ref.value,p)))}})(Kr||(Kr={}));var Id=y(),Md=y(),Rd=y(),j0=y(),bi=Qs(4,!0);function Oq(e){for(var t=12,r=e?12*3:6*4,n=Ll(t,r),a=0;a<4;++a){var i=(a+1)%4;y.set(Id,bi[a*3],bi[a*3+1],-.5),y.set(Md,bi[i*3],bi[i*3+1],-.5),y.set(Rd,bi[i*3],bi[i*3+1],.5),y.set(j0,bi[a*3],bi[a*3+1],.5),e?n.add(Id,Md,Rd):n.addQuad(Id,Md,Rd,j0)}return y.set(Id,bi[0],bi[1],-.5),y.set(Md,bi[3],bi[4],-.5),y.set(Rd,bi[6],bi[7],-.5),y.set(j0,bi[9],bi[10],-.5),e?n.add(Rd,Md,Id):n.addQuad(j0,Rd,Md,Id),y.set(Id,bi[0],bi[1],.5),y.set(Md,bi[3],bi[4],.5),y.set(Rd,bi[6],bi[7],.5),y.set(j0,bi[9],bi[10],.5),e?n.add(Id,Md,Rd):n.addQuad(Id,Md,Rd,j0),n.getPrimitive()}var RR;function q0(){return RR||(RR=Oq(!1)),RR}var BR;function Fq(){return BR||(BR=Oq(!0)),BR}var OR;function Q_(){return OR||(OR=Ef([.5,.5,-.5,-.5,.5,-.5,-.5,-.5,-.5,.5,-.5,-.5,.5,.5,.5,-.5,.5,.5,-.5,-.5,.5,.5,-.5,.5],[0,4,1,5,2,6,3,7,0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4])),OR}function FR(e){return e.map(function(t){return{x:t[0],alpha:t[1]}})}function LR(e,t){for(var r=Ut(Ut([{x:0,alpha:0},{x:0,alpha:0}],e,!0),[{x:1,alpha:0},{x:1,alpha:0}],!1),n=256,a=t?t.ref.value.array:new Uint8Array(n),i=0,o,s,u,c,l,f,d=e.length+1,m=0;m=t?u=t-1:u<0&&(u=0),i[u]++}return{min:r,max:n,binWidth:a,counts:i}}var Ba;(function(e){e.One={transform:{kind:"matrix",matrix:se.identity()},cells:tr.create(tr.Space([1,1,1],[0,1,2]),tr.Data1([0])),stats:{min:0,max:0,mean:0,sigma:0}};var t=se.zero(),r=se.zero();function n(u){if(u.transform.kind==="matrix")return se.copy(se(),u.transform.matrix);if(u.transform.kind==="spacegroup"){var c=u.cells.space,l=se.fromScaling(t,y.div(y.zero(),gt.size(y.zero(),u.transform.fractionalBox),y.ofArray(c.dimensions))),f=se.fromTranslation(r,u.transform.fractionalBox.min);return se.mul3(se.zero(),u.transform.cell.fromFractional,f,l)}return se.identity()}e.getGridToCartesianTransform=n;function a(u,c){return u===c}e.areEquivalent=a;function i(u){return u.cells.data.length===0}e.isEmpty=i;function o(u,c){c||(c=xe());var l=u.cells.space.dimensions,f=e.getGridToCartesianTransform(u);return xe.fromDimensionsAndTransform(c,l,f)}e.getBoundingSphere=o;function s(u,c){var l=u._historams;return l||(l=u._historams={}),l[c]||(l[c]=kq(u.cells.data,c,{min:u.stats.min,max:u.stats.max})),l[c]}e.getHistogram=s})(Ba||(Ba={}));function ui(e){return e}(function(e){function t(r){return r.__key||(r.__key=Er.create22()),r.__key}e.getUUID=t})(ui||(ui={}));var eo=function(){function e(){this._list=[],this._set=new Set,this._refs=new Map,this._assets=new Map}return Object.defineProperty(e.prototype,"all",{get:function(){return this._list},enumerable:!1,configurable:!0}),e.prototype.add=function(t){this._set.has(t)||(this._list.push(t),this._set.add(t))},e.prototype.reference=function(t,r){var n=this._refs.get(t)||0;n+=r?1:-1,this._refs.set(t,Math.max(n,0))},e.prototype.hasReference=function(t){return(this._refs.get(t)||0)>0},e.prototype.has=function(t){return this._set.has(t)},e.prototype.assets=function(t,r){var n=this._assets.get(t);if(n)for(var a=0,i=n;a_&&(E=e.IsoValue.absolute(_)):g.relativeValueA&&(E=e.IsoValue.relative(A)),w.Conditioned(E,{absolute:w.Converted(function(I){return e.IsoValue.toAbsolute(I,Ba.One.stats).absoluteValue},function(I){return e.IsoValue.absolute(I)},w.Numeric(C,{min:S,max:_,step:dM(D/100,2)},{immediateUpdate:!0})),relative:w.Converted(function(I){return e.IsoValue.toRelative(I,Ba.One.stats).relativeValue},function(I){return e.IsoValue.relative(I)},w.Numeric(Math.min(1,A),{min:T,max:A,step:dM(Math.round((_-S)/D)/100,2)},{immediateUpdate:!0}))},function(I){return I.kind==="absolute"?"absolute":"relative"},function(I,R){return R==="absolute"?e.IsoValue.toAbsolute(I,x):e.IsoValue.toRelative(I,x)},{isEssential:!0})}e.createIsoValueParam=i,e.IsoValueParam=i(e.IsoValue.relative(2)),e.One={label:"",grid:Ba.One,sourceData:{kind:"",name:"",data:{}},customProperties:new eo,_propertyData:Object.create(null)};function o(g,b){return Ba.areEquivalent(g.grid,b.grid)}e.areEquivalent=o;function s(g){return Ba.isEmpty(g.grid)}e.isEmpty=s;function u(g){return cx.is(g.sourceData)?g.sourceData.data.header.orbitals:!1}e.isOrbitals=u;function c(g){return{kind:"volume-loci",volume:g}}e.Loci=c;function l(g){return!!g&&g.kind==="volume-loci"}e.isLoci=l;function f(g,b){return g.volume===b.volume}e.areLociEqual=f;function d(g){return Ba.isEmpty(g.volume.grid)}e.isLociEmpty=d;function m(g,b){return Ba.getBoundingSphere(g.grid,b)}e.getBoundingSphere=m;var h;(function(g){function b(T,A){return{kind:"isosurface-loci",volume:T,isoValue:A}}g.Loci=b;function x(T){return!!T&&T.kind==="isosurface-loci"}g.isLoci=x;function S(T,A){return T.volume===A.volume&&e.IsoValue.areSame(T.isoValue,A.isoValue,T.volume.grid.stats)}g.areLociEqual=S;function _(T){return T.volume.grid.cells.data.length===0}g.isLociEmpty=_;var C=gt();function D(T,A,E){for(var I=e.IsoValue.toAbsolute(A,T.grid.stats).absoluteValue,R=I<0,B=[0,0,0],O=T.grid.cells.space.getCoords,z=T.grid.cells.data,k=T.grid.cells.space.dimensions,G=k[0],V=k[1],U=k[2],Q=G-1,W=V-1,X=U-1,ae=0,q=0,F=0,j=0,Z=z.length;j=I)&&(O(j,B),B[0]ae&&(ae=B[0]),B[1]>q&&(q=B[1]),B[2]>F&&(F=B[2]));y.set(C.min,Q-1,W-1,X-1),y.set(C.max,ae+1,q+1,F+1);var Y=Ba.getGridToCartesianTransform(T.grid);return gt.transform(C,C,Y),xe.fromBox3D(E||xe(),C)}g.getBoundingSphere=D})(h=e.Isosurface||(e.Isosurface={}));var p;(function(g){function b(A,E){return{kind:"cell-loci",volume:A,indices:E}}g.Loci=b;function x(A){return!!A&&A.kind==="cell-loci"}g.isLoci=x;function S(A,E){return A.volume===E.volume&&Ee.areEqual(A.indices,E.indices)}g.areLociEqual=S;function _(A){return Ee.size(A.indices)===0}g.isLociEmpty=_;var C=new Di("98"),D=y();function T(A,E,I){C.reset();for(var R=Ba.getGridToCartesianTransform(A.grid),B=A.grid.cells.space.getCoords,O=0,z=Ee.size(E);O=0&&y.transformMat4Offset(E,E,I,0,0,O*16),A};return hr(D,T,1,R)}function s(v,g){return Math.ceil(y.magnitude(v)*g)}function u(v,g){return Math.min.apply(Math,v)*(1/g)}function c(v){return 1/v}function l(v,g,b,x,S){var _=v.gridTexture,C=v.gridTextureDim,D=v.gridStats,T=v.bboxSize,A=v.bboxMin,E=v.bboxMax,I=v.gridDimension,R=v.transform,B=b.instanceCount,O=b.groupCount,z=e.Utils.createPositionIterator(v,g),k=Qa(b,z,x.color),G=S.instanceGranularity?bn(B,"instance"):bn(B*O,"groupInstance"),V=Uo(),U=Vo(),Q=zo(),W=Go(),X=I.ref.value,ae=X[0],q=X[1],F=X[2],j={drawCount:kR.indices.length,vertexCount:ae*q*F,groupCount:O,instanceCount:B},Z=xe.clone(v.boundingSphere),Y=Da(Z,g.aTransform.ref.value,B,0),H=FR(S.controlPoints),N=LR(H);return P(P(P(P(P(P(P(P(P({dGeometryType:M.create("directVolume")},k),G),V),U),Q),W),g),Ze.createValues(S,j)),{aPosition:M.create(kR.vertices),elements:M.create(kR.indices),boundingSphere:M.create(Y),invariantBoundingSphere:M.create(Z),uInvariantBoundingSphere:M.create(Wt.ofSphere(Z)),uBboxMin:A,uBboxMax:E,uBboxSize:T,uMaxSteps:M.create(s(I.ref.value,S.stepsPerCell)),uStepScale:M.create(u(v.cellDim.ref.value,S.stepsPerCell)),uJumpLength:M.create(S.jumpLength),uTransform:R,uGridDim:I,tTransferTex:N,uTransferScale:M.create(c(S.stepsPerCell)),dGridTexType:M.create(_.ref.value.getDepth()>0?"3d":"2d"),uGridTexDim:C,tGridTex:_,uGridStats:D,uCellDim:v.cellDim,uCartnToUnit:v.cartnToUnit,uUnitToCartn:v.unitToCartn,dPackedGroup:v.packedGroup,dAxisOrder:M.create(v.axisOrder.ref.value.join("")),dIgnoreLight:M.create(S.ignoreLight),dXrayShaded:M.create(S.xrayShaded==="inverted"?"inverted":S.xrayShaded===!0?"on":"off")})}function f(v,g,b,x,S){var _=Ze.createSimple(b,x,S),C=P(P({},w.getDefaultValues(e.Params)),g);return l(v,_.transform,_.locationIterator,_.theme,C)}function d(v,g){Ze.updateValues(v,g),M.updateIfChanged(v.dIgnoreLight,g.ignoreLight),M.updateIfChanged(v.dXrayShaded,g.xrayShaded==="inverted"?"inverted":g.xrayShaded===!0?"on":"off");var b=FR(g.controlPoints);LR(b,v.tTransferTex),M.updateIfChanged(v.uMaxSteps,s(v.uGridDim.ref.value,g.stepsPerCell)),M.updateIfChanged(v.uStepScale,u(v.uCellDim.ref.value,g.stepsPerCell)),M.updateIfChanged(v.uTransferScale,c(g.stepsPerCell)),M.updateIfChanged(v.uJumpLength,g.jumpLength)}function m(v,g){var b=xe.clone(g.boundingSphere),x=Da(b,v.aTransform.ref.value,v.instanceCount.ref.value,0);xe.equals(x,v.boundingSphere.ref.value)||M.update(v.boundingSphere,x),xe.equals(b,v.invariantBoundingSphere.ref.value)||(M.update(v.invariantBoundingSphere,b),M.update(v.uInvariantBoundingSphere,Wt.fromSphere(v.uInvariantBoundingSphere.ref.value,b)))}function h(v){var g=Ze.createRenderableState(v);return g.opaque=!1,g.writeDepth=!1,g}function p(v,g){Ze.updateRenderableState(v,g),v.opaque=!1,v.writeDepth=!1}})(Po||(Po={}));function t2e(e,t){return xe.fromDimensionsAndTransform(xe(),e,t)}var ys;(function(e){function t(h,p,v,g){return g?i(h,p,v,g):a(h,p,v)}e.create=t;function r(h){var p=h?h.centerBuffer.ref.value:new Float32Array(0),v=h?h.groupBuffer.ref.value:new Float32Array(0);return t(p,v,0,h)}e.createEmpty=r;function n(h){return ga([h.sphereCount,h.centerBuffer.ref.version,h.groupBuffer.ref.version])}function a(h,p,v){var g=xe(),b,x=-1,S=-1,_=M.create(Vn(1,4,Float32Array)),C=M.create(Me.create(0,0)),D={kind:"spheres",sphereCount:v,centerBuffer:M.create(h),groupBuffer:M.create(p),get boundingSphere(){var T=n(D);if(T!==x){var A=Cu(D.centerBuffer.ref.value,D.sphereCount*4,4);xe.copy(g,A),x=T}return g},get groupMapping(){return D.groupBuffer.ref.version!==S&&(b=Nc(D.groupBuffer.ref.value,D.sphereCount,4),S=D.groupBuffer.ref.version),b},setBoundingSphere:function(T){xe.copy(g,T),x=n(D)},shaderData:{positionGroup:_,texDim:C,update:function(){var T=Vn(D.sphereCount,4,Float32Array,_.ref.value.array);o(T,D.centerBuffer.ref.value,D.groupBuffer.ref.value,D.sphereCount),M.update(_,T),M.update(C,Me.set(C.ref.value,T.width,T.height))}}};return D}function i(h,p,v,g){return g.sphereCount=v,M.update(g.centerBuffer,h),M.update(g.groupBuffer,p),g.shaderData.update(),g}function o(h,p,v,g){for(var b=h.array,x=0;x=re.ref.value.length)De.updateSubData(re.ref.value,0,De.length);else{De.destroy();var Ge=n[de],Ke=Ge.itemSize,L=Ge.divisor;Q[oe][1]=l.attribute(re.ref.value,Ke,L),Y.attributes=!0}R[de]=re.ref.version}}if(W&&a.elements.ref.version!==R.elements&&(W.length>=a.elements.ref.value.length?W.updateSubData(a.elements.ref.value,0,W.length):(W.destroy(),W=l.elements(a.elements.ref.value),Y.elements=!0),R.elements=a.elements.ref.version),Y.attributes||Y.defines||Y.elements)for(var K=0,ge=o;Ko&&(o=c)}var l=xe.create(t,o);return xe.setExtrema(l,r),l}var zi;(function(e){function t(h,p,v,g,b,x,S,_,C){return C?i(h,p,v,g,b,x,S,_,C):a(h,p,v,g,b,x,S,_)}e.create=t;function r(h){var p=h?h.mappingBuffer.ref.value:new Float32Array(0),v=h?h.indexBuffer.ref.value:new Uint32Array(0),g=h?h.groupBuffer.ref.value:new Float32Array(0),b=h?h.startBuffer.ref.value:new Float32Array(0),x=h?h.endBuffer.ref.value:new Float32Array(0),S=h?h.scaleBuffer.ref.value:new Float32Array(0),_=h?h.capBuffer.ref.value:new Float32Array(0);return t(p,v,g,b,x,S,_,0,h)}e.createEmpty=r;function n(h){return ga([h.cylinderCount,h.mappingBuffer.ref.version,h.indexBuffer.ref.version,h.groupBuffer.ref.version,h.startBuffer.ref.version,h.endBuffer.ref.version,h.scaleBuffer.ref.version,h.capBuffer.ref.version])}function a(h,p,v,g,b,x,S,_){var C=xe(),D,T=-1,A=-1,E={kind:"cylinders",cylinderCount:_,mappingBuffer:M.create(h),indexBuffer:M.create(p),groupBuffer:M.create(v),startBuffer:M.create(g),endBuffer:M.create(b),scaleBuffer:M.create(x),capBuffer:M.create(S),get boundingSphere(){var I=n(E);if(I!==T){var R=Cu(E.startBuffer.ref.value,E.cylinderCount*6,6),B=Cu(E.endBuffer.ref.value,E.cylinderCount*6,6);xe.expandBySphere(C,R,B),T=I}return C},get groupMapping(){return E.groupBuffer.ref.version!==A&&(D=Nc(E.groupBuffer.ref.value,E.cylinderCount,6),A=E.groupBuffer.ref.version),D},setBoundingSphere:function(I){xe.copy(C,I),T=n(E)}};return E}function i(h,p,v,g,b,x,S,_,C){return _>C.cylinderCount&&(M.update(C.mappingBuffer,h),M.update(C.indexBuffer,p)),C.cylinderCount=_,M.update(C.groupBuffer,v),M.update(C.startBuffer,g),M.update(C.endBuffer,b),M.update(C.scaleBuffer,x),M.update(C.capBuffer,S),C}function o(h,p){var v=h.startBuffer.ref.value;kc(p,v,0,h.cylinderCount*6),M.update(h.startBuffer,v);var g=h.endBuffer.ref.value;kc(p,g,0,h.cylinderCount*6),M.update(h.endBuffer,g)}e.transform=o,e.Params=P(P({},Ze.Params),{sizeFactor:w.Numeric(1,{min:0,max:10,step:.1}),sizeAspectRatio:w.Numeric(1,{min:0,max:3,step:.01}),doubleSided:w.Boolean(!1,Ze.CustomQualityParamInfo),ignoreLight:w.Boolean(!1,Ze.ShadingCategory),xrayShaded:w.Select(!1,[[!1,"Off"],[!0,"On"],["inverted","Inverted"]],Ze.ShadingCategory),transparentBackfaces:w.Select("off",w.arrayToOptions(["off","on","opaque"]),Ze.ShadingCategory),solidInterior:w.Boolean(!0,Ze.ShadingCategory),bumpFrequency:w.Numeric(0,{min:0,max:10,step:.1},Ze.ShadingCategory),bumpAmplitude:w.Numeric(1,{min:0,max:5,step:.1},Ze.ShadingCategory)}),e.Utils={Params:e.Params,createEmpty:r,createValues:u,createValuesSimple:c,updateValues:l,updateBoundingSphere:f,createRenderableState:d,updateRenderableState:m,createPositionIterator:s};function s(h,p){var v=h.cylinderCount*6,g=p.instanceCount.ref.value,b=Ms(),x=b.position,S=h.startBuffer.ref.value,_=h.endBuffer.ref.value,C=p.aTransform.ref.value,D=function(T,A){var E=T%6===0?S:_;return A<0?y.fromArray(x,E,T*3):y.transformMat4Offset(x,E,C,0,T*3,A*16),b};return hr(v,g,2,D)}function u(h,p,v,g,b){var x=v.instanceCount,S=v.groupCount,_=s(h,p),C=Qa(v,_,g.color),D=Ho(v,g.size),T=b.instanceGranularity?bn(x,"instance"):bn(x*S,"groupInstance"),A=Uo(),E=Vo(),I=zo(),R=Go(),B={drawCount:h.cylinderCount*4*3,vertexCount:h.cylinderCount*6,groupCount:S,instanceCount:x},O=ap(D)*b.sizeFactor,z=xe.clone(h.boundingSphere),k=Da(z,p.aTransform.ref.value,x,0);return P(P(P(P(P(P(P(P(P(P(P({dGeometryType:M.create("cylinders"),aMapping:h.mappingBuffer,aGroup:h.groupBuffer,aStart:h.startBuffer,aEnd:h.endBuffer,aScale:h.scaleBuffer,aCap:h.capBuffer,elements:h.indexBuffer,boundingSphere:M.create(k),invariantBoundingSphere:M.create(z),uInvariantBoundingSphere:M.create(Wt.ofSphere(z))},C),D),T),A),E),I),R),p),{padding:M.create(O)}),Ze.createValues(b,B)),{uSizeFactor:M.create(b.sizeFactor*b.sizeAspectRatio),uDoubleSided:M.create(b.doubleSided),dIgnoreLight:M.create(b.ignoreLight),dXrayShaded:M.create(b.xrayShaded==="inverted"?"inverted":b.xrayShaded===!0?"on":"off"),dTransparentBackfaces:M.create(b.transparentBackfaces),dSolidInterior:M.create(b.solidInterior),uBumpFrequency:M.create(b.bumpFrequency),uBumpAmplitude:M.create(b.bumpAmplitude)})}function c(h,p,v,g,b){var x=Ze.createSimple(v,g,b),S=P(P({},w.getDefaultValues(e.Params)),p);return u(h,x.transform,x.locationIterator,x.theme,S)}function l(h,p){Ze.updateValues(h,p),M.updateIfChanged(h.uSizeFactor,p.sizeFactor*p.sizeAspectRatio),M.updateIfChanged(h.uDoubleSided,p.doubleSided),M.updateIfChanged(h.dIgnoreLight,p.ignoreLight),M.updateIfChanged(h.dXrayShaded,p.xrayShaded==="inverted"?"inverted":p.xrayShaded===!0?"on":"off"),M.updateIfChanged(h.dTransparentBackfaces,p.transparentBackfaces),M.updateIfChanged(h.dSolidInterior,p.solidInterior),M.updateIfChanged(h.uBumpFrequency,p.bumpFrequency),M.updateIfChanged(h.uBumpAmplitude,p.bumpAmplitude)}function f(h,p){var v=xe.clone(p.boundingSphere),g=Da(v,h.aTransform.ref.value,h.instanceCount.ref.value,0);xe.equals(g,h.boundingSphere.ref.value)||M.update(h.boundingSphere,g),xe.equals(v,h.invariantBoundingSphere.ref.value)||(M.update(h.invariantBoundingSphere,v),M.update(h.uInvariantBoundingSphere,Wt.fromSphere(h.uInvariantBoundingSphere.ref.value,v)))}function d(h){var p=Ze.createRenderableState(h);return m(p,h),p}function m(h,p){Ze.updateRenderableState(h,p),h.opaque=h.opaque&&!p.xrayShaded,h.writeDepth=h.opaque}})(zi||(zi={}));var Ra;(function(e){function t(o){switch(o.kind){case"mesh":return o.triangleCount*3;case"points":return o.pointCount;case"spheres":return o.sphereCount*2*3;case"cylinders":return o.cylinderCount*4*3;case"text":return o.charCount*2*3;case"lines":return o.lineCount*2*3;case"direct-volume":return 12*3;case"image":return 2*3;case"texture-mesh":return o.vertexCount}}e.getDrawCount=t;function r(o){switch(o.kind){case"mesh":return o.vertexCount;case"points":return o.pointCount;case"spheres":return o.sphereCount*6;case"cylinders":return o.cylinderCount*6;case"text":return o.charCount*4;case"lines":return o.lineCount*4;case"direct-volume":var s=o.gridDimension.ref.value,u=s[0],c=s[1],l=s[2];return u*c*l;case"image":return 4;case"texture-mesh":return o.vertexCount}}e.getVertexCount=r;function n(o){switch(o.kind){case"mesh":case"points":case"spheres":case"cylinders":case"text":case"lines":return t(o)===0?0:Lo(o.groupBuffer.ref.value)+1;case"direct-volume":return 1;case"image":return Lo(o.groupTexture.ref.value.array)+1;case"texture-mesh":return o.groupCount}}e.getGroupCount=n;function a(o){switch(o.kind){case"mesh":return pt.Utils;case"points":return Tu.Utils;case"spheres":return ys.Utils;case"cylinders":return zi.Utils;case"text":return yi.Utils;case"lines":return Kr.Utils;case"direct-volume":return Po.Utils;case"image":return Vl.Utils;case"texture-mesh":return Ei.Utils}}e.getUtils=a;function i(o,s){return s==="instance"&&o.nonInstanceable?"group":s}e.getGranularity=i})(Ra||(Ra={}));var b2e=1,x2e="Assigns sizes as defined by the shape object.",Zq={};function S2e(e){return Zq}function J_(e,t){return{factory:J_,granularity:"groupInstance",size:function(r){return to.isLocation(r)?r.shape.getSize(r.group,r.instance):b2e},props:t,description:x2e}}var Qq={name:"shape-group",label:"Shape Group",category:"",factory:J_,getParams:S2e,defaultValues:w.getDefaultValues(Zq),isApplicable:function(e){return!!e.shape}};var C2e=Xe(13421772),_2e="Assigns colors as defined by the shape object.",$q={};function w2e(e){return $q}function ew(e,t){return{factory:ew,granularity:"groupInstance",color:function(r){return to.isLocation(r)?r.shape.getColor(r.group,r.instance):C2e},props:t,description:_2e}}var Jq={name:"shape-group",label:"Shape Group",category:lr.Misc,factory:ew,getParams:w2e,defaultValues:w.getDefaultValues($q),isApplicable:function(e){return!!e.shape}};var T2e=P(P({},Yo),{aPosition:Gr("float32",3,0),elements:zc("uint32"),uBboxMin:_e("v3"),uBboxMax:_e("v3"),uBboxSize:_e("v3"),uMaxSteps:_e("i"),uStepScale:_e("f"),uJumpLength:_e("f"),uTransform:_e("m4"),uGridDim:_e("v3"),tTransferTex:Ft("image-uint8","alpha","ubyte","linear"),uTransferScale:_e("f","material"),dGridTexType:Dt("string",["2d","3d"]),uGridTexDim:_e("v3"),tGridTex:Ft("texture","rgba","ubyte","linear"),uGridStats:_e("v4"),uCellDim:_e("v3"),uCartnToUnit:_e("m4"),uUnitToCartn:_e("m4"),dPackedGroup:Dt("boolean"),dAxisOrder:Dt("string",["012","021","102","120","201","210"]),dIgnoreLight:Dt("boolean"),dXrayShaded:Dt("string",["off","on","inverted"])});function eW(e,t,r,n,a,i){var o=P(P(P(P({},jo),qo),Wo),T2e);e.isWebGL2||(o.uMaxSteps=Dt("number"));var s={uObjectId:M.create(t)},u=z9,c=Xo(e,"triangles",u,o,P(P({},r),s),a,i);return Ko(c,r,n)}var A2e=P(P({},Yo),{aGroup:Gr("float32",1,0),aPosition:Gr("float32",3,0),aNormal:Gr("float32",3,0),elements:zc("uint32"),dVaryingGroup:Dt("boolean"),dFlatShaded:Dt("boolean"),uDoubleSided:_e("b","material"),dFlipSided:Dt("boolean"),dIgnoreLight:Dt("boolean"),dXrayShaded:Dt("string",["off","on","inverted"]),dTransparentBackfaces:Dt("string",["off","on","opaque"]),uBumpFrequency:_e("f","material"),uBumpAmplitude:_e("f","material"),meta:An("unknown")});function tW(e,t,r,n,a,i){var o=P(P(P(P({},jo),qo),Wo),A2e),s={uObjectId:M.create(t)},u=L_,c=Xo(e,"triangles",u,o,P(P({},r),s),a,i);return Ko(c,r,n)}var D2e=P(P(P({},Yo),Ff),{aGroup:Gr("float32",1,0),aPosition:Gr("float32",3,0),dPointSizeAttenuation:Dt("boolean"),dPointStyle:Dt("string",["square","circle","fuzzy"])});function rW(e,t,r,n,a,i){var o=P(P(P(P({},jo),qo),Wo),D2e),s={uObjectId:M.create(t)},u=k9,c=Xo(e,"points",u,o,P(P({},r),s),a,i);return Ko(c,r,n)}var P2e=P(P(P({},Yo),Ff),{aGroup:Gr("float32",1,0),aMapping:Gr("float32",2,0),aStart:Gr("float32",3,0),aEnd:Gr("float32",3,0),elements:zc("uint32"),dLineSizeAttenuation:Dt("boolean"),uDoubleSided:_e("b","material"),dFlipSided:Dt("boolean")});function nW(e,t,r,n,a,i){var o=P(P(P(P({},jo),qo),Wo),P2e),s={uObjectId:M.create(t)},u=G9,c=Xo(e,"triangles",u,o,P(P({},r),s),a,i);return Ko(c,r,n)}var E2e=P(P(P({},Yo),Ff),{uTexDim:_e("v2"),tPositionGroup:Ft("image-float32","rgba","float","nearest"),padding:An("number"),uDoubleSided:_e("b","material"),dIgnoreLight:Dt("boolean"),dXrayShaded:Dt("string",["off","on","inverted"]),dTransparentBackfaces:Dt("string",["off","on","opaque"]),dSolidInterior:Dt("boolean"),dClipPrimitive:Dt("boolean"),dApproximate:Dt("boolean"),uAlphaThickness:_e("f"),uBumpFrequency:_e("f","material"),uBumpAmplitude:_e("f","material"),centerBuffer:An("float32"),groupBuffer:An("float32")});function aW(e,t,r,n,a,i){var o=P(P(P(P({},jo),qo),Wo),E2e),s={uObjectId:M.create(t)},u=N9,c=Xo(e,"triangles",u,o,P(P({},r),s),a,i);return Ko(c,r,n)}var I2e=P(P(P({},Yo),Ff),{aGroup:Gr("float32",1,0),aPosition:Gr("float32",3,0),aMapping:Gr("float32",2,0),aDepth:Gr("float32",1,0),elements:zc("uint32"),aTexCoord:Gr("float32",2,0),tFont:Ft("image-uint8","alpha","ubyte","linear"),padding:An("number"),uBorderWidth:_e("f","material"),uBorderColor:_e("v3","material"),uOffsetX:_e("f","material"),uOffsetY:_e("f","material"),uOffsetZ:_e("f","material"),uBackgroundColor:_e("v3","material"),uBackgroundOpacity:_e("f","material")});function iW(e,t,r,n,a,i){var o=P(P(P(P({},jo),qo),Wo),I2e),s={uObjectId:M.create(t)},u=V9,c=Xo(e,"triangles",u,o,P(P({},r),s),a,i);return Ko(c,r,n)}var M2e=P(P({},Yo),{uGeoTexDim:_e("v2","buffered"),tPosition:Ft("texture","rgb","float","nearest"),tGroup:Ft("texture","alpha","float","nearest"),tNormal:Ft("texture","rgb","float","nearest"),dVaryingGroup:Dt("boolean"),dFlatShaded:Dt("boolean"),uDoubleSided:_e("b","material"),dFlipSided:Dt("boolean"),dIgnoreLight:Dt("boolean"),dXrayShaded:Dt("string",["off","on","inverted"]),dTransparentBackfaces:Dt("string",["off","on","opaque"]),uBumpFrequency:_e("f","material"),uBumpAmplitude:_e("f","material"),meta:An("unknown")});function oW(e,t,r,n,a,i){var o=P(P(P(P({},jo),qo),Wo),M2e),s={uObjectId:M.create(t)},u=L_,c=Xo(e,"triangles",u,o,P(P({},r),s),a,i);return Ko(c,r,n)}var R2e=P(P({},Yo),{aGroup:Gr("float32",1,0),aPosition:Gr("float32",3,0),aUv:Gr("float32",2,0),elements:zc("uint32"),uImageTexDim:_e("v2"),tImageTex:Ft("image-uint8","rgba","ubyte","nearest"),tGroupTex:Ft("image-uint8","rgba","ubyte","nearest"),dInterpolation:Dt("string",Kq)});function sW(e,t,r,n,a,i){var o=P(P(P(P({},jo),qo),Wo),R2e),s={uObjectId:M.create(t)},u=H9,c=Xo(e,"triangles",u,o,P(P({},r),s),a,i);return Ko(c,r,n)}var B2e=P(P(P({},Yo),Ff),{aGroup:Gr("float32",1,0),aStart:Gr("float32",3,0),aEnd:Gr("float32",3,0),aMapping:Gr("float32",3,0),aScale:Gr("float32",1,0),aCap:Gr("float32",1,0),elements:zc("uint32"),padding:An("number"),uDoubleSided:_e("b","material"),dIgnoreLight:Dt("boolean"),dXrayShaded:Dt("string",["off","on","inverted"]),dTransparentBackfaces:Dt("string",["off","on","opaque"]),dSolidInterior:Dt("boolean"),uBumpFrequency:_e("f","material"),uBumpAmplitude:_e("f","material")});function uW(e,t,r,n,a,i){var o=P(P(P(P({},jo),qo),Wo),B2e),s={uObjectId:M.create(t)},u=U9,c=Xo(e,"triangles",u,o,P(P({},r),s),a,i);return Ko(c,r,n)}var O2e=ua(0,2147483647),Js=ua(0,2147483647);function Hc(e,t,r,n){return{id:O2e(),type:e,values:t,state:r,materialId:n}}function cW(e,t,r){switch(t.type){case"mesh":return tW(e,t.id,t.values,t.state,t.materialId,r);case"points":return rW(e,t.id,t.values,t.state,t.materialId,r);case"spheres":return aW(e,t.id,t.values,t.state,t.materialId,r);case"cylinders":return uW(e,t.id,t.values,t.state,t.materialId,r);case"text":return iW(e,t.id,t.values,t.state,t.materialId,r);case"lines":return nW(e,t.id,t.values,t.state,t.materialId,r);case"direct-volume":return eW(e,t.id,t.values,t.state,t.materialId,r);case"image":return sW(e,t.id,t.values,t.state,t.materialId,r);case"texture-mesh":return oW(e,t.id,t.values,t.state,t.materialId,r)}throw new Error("unsupported type")}var gr;(function(e){function t(l,f,d,m,h,p,v){return{id:Er.create22(),name:l,sourceData:f,geometry:d,transforms:v||[se.identity()],get groupCount(){return Ra.getGroupCount(d)},getColor:m,getSize:h,getLabel:p}}e.create=t;function r(l){return{color:ew({shape:l},{}),size:J_({shape:l},{})}}e.getTheme=r;function n(l){var f=l.transforms.length,d=to.Location(l),m=function(h,p){return d.group=h,d.instance=p,d};return hr(l.groupCount,f,1,m)}e.groupIterator=n;function a(l,f){for(var d=f&&f.aTransform.ref.value.length>=l.length*16?f.aTransform.ref.value:new Float32Array(l.length*16),m=0,h=l.length;m=Math.PI||f>=Math.PI||d>=Math.PI?r():t(y.create(s,u,c),y.create(l,f,d))}e.fromBasis=n})(sc||(sc={}));var V2e=20.45482949774598;function hW(e){var t=this;return Ce.create("Parse DCD",function(r){return $(t,void 0,void 0,function(){var n,a,i,o,s,u,c,l,f;return J(this,function(d){switch(d.label){case 0:return[4,r.update("Converting to coordinates")];case 1:for(d.sent(),n=e.header,a=n.DELTA?Zo(n.DELTA*V2e,"ps"):Zo(1,"step"),i=n.ISTART>=1?Zo((n.ISTART-1)*a.value,a.unit):Zo(0,a.unit),o=[],s=0,u=e.frames.length;s=-1&&f[1]<=1&&f[3]>=-1&&f[3]<=1&&f[4]>=-1&&f[4]<=1?l.cell=sc.create(y.create(f[0],f[2],f[5]),y.create(vr(90-Math.asin(f[1])*90/Wh),vr(90-Math.asin(f[3])*90/Wh),vr(90-Math.asin(f[4])*90/Wh))):f[0]<0||f[1]<0||f[2]<0||f[3]<0||f[4]<0||f[5]<0||f[3]>180||f[4]>180||f[5]>180?l.cell=sc.fromBasis(y.create(f[0],f[1],f[3]),y.create(f[1],f[2],f[4]),y.create(f[3],f[4],f[5])):l.cell=sc.create(y.create(f[0],f[2],f[5]),y.create(vr(Tn(f[1],0,Dr)?90:f[1]),vr(Tn(f[3],0,Dr)?90:f[3]),vr(Tn(f[4],0,Dr)?90:f[4])))),o.push(l);return[2,jc.create(o,a,i)]}})})})}function W0(e,t,r,n){for(var a=r,i=n-1,o=t.charCodeAt(a);(o===32||o>=48&&o<=57)&&a<=i;)o=t.charCodeAt(++a);for(o=t.charCodeAt(i);(o===32||o>=48&&o<=57)&&i>=a;)o=t.charCodeAt(--i);if(++i,a===i)return We.add(e,a,i);if(a+1===i)return We.add(e,a,i);if(o=t.charCodeAt(a),a+2===i){var s=t.charCodeAt(a+1);if((o===78||o===110)&&(s===65||s===97)||(o===67||o===99)&&(s===76||s===108)||(o===70||o===102)&&(s===69||s===101)||(o===83||o===115)&&(s===73||s===105)||(o===66||o===98)&&(s===82||s===114)||(o===65||o===97)&&(s===83||s===115))return We.add(e,a,a+2)}if(o===67||o===99||o===72||o===104||o===78||o===110||o===79||o===111||o===80||o===112||o===83||o===115)return We.add(e,a,a+1);We.add(e,a,a)}var G2e=new Set(["NA","CL","FE","SI","BR","AS","LI"]),z2e=new Set(["C","H","N","O","P","S","F","B"]),H2e=/^[\s\d]+|[\s\d]+$/g;function qc(e,t){e=e.replace(H2e,"").toUpperCase();var r=e.length;if(r===0||r===1||G2e.has(e))return e;if(r===3&&t===e){if(e==="SOD")return"NA";if(e==="POT")return"K";if(e==="CES")return"CS";if(e==="CAL")return"CA";if(e==="CLA")return"CL"}return z2e.has(e[0])?e[0]:""}var NR=new Set(["145","147","149","289","291","293","445","475","491","510","604","045","05L","07E","07Y","08U","09X","0AT","0BD","0H0","0HX","0LP","0MK","0NZ","0TS","0UB","0V4","0WK","0XY","0YT","10M","12E","14T","15L","16F","16G","16O","17T","18D","18O","18T","1AR","1BW","1CF","1FT","1GL","1GN","1JB","1LL","1NA","1S3","1S4","1SD","1X4","20S","20X","22O","22S","23V","24S","25E","26M","26O","26Q","26R","26V","26W","26Y","27C","2DG","2DR","2F8","2FG","2FL","2FP","2GL","2GS","2H5","2HA","2M4","2M5","2M8","2OS","2SI","2WP","2WS","32O","34V","38J","3BU","3CM","3DO","3DY","3FM","3GR","3HD","3J3","3J4","3LJ","3LR","3MF","3MG","3MK","3R3","3S6","3SA","3YW","40J","42D","44S","46D","46M","46Z","48Z","49A","49S","49T","49V","4AM","4CQ","4GC","4GL","4GP","4JA","4N2","4NN","4QY","4R1","4RS","4SG","4U0","4U1","4U2","4UZ","4V5","50A","51N","56N","57S","5DI","5GF","5GO","5II","5KQ","5KS","5KT","5KV","5L2","5L3","5LS","5LT","5MM","5N6","5QP","5RP","5SA","5SP","5TH","5TJ","5TK","5TM","61J","62I","64K","66O","6BG","6C2","6DM","6GB","6GP","6GR","6K3","6KH","6KL","6KS","6KU","6KW","6LA","6LS","6LW","6MJ","6MN","6PG","6PY","6PZ","6S2","6SA","6UD","6Y6","6YR","6ZC","73E","79J","7CV","7D1","7GP","7JZ","7K2","7K3","7NU","7SA","83Y","89Y","8B7","8B9","8EX","8GA","8GG","8GP","8I4","8LM","8LR","8OQ","8PK","8S0","8YV","95Z","96O","98U","9AM","9C1","9CD","9GP","9KJ","9MR","9OK","9PG","9QG","9QZ","9S7","9SG","9SJ","9SM","9SP","9T1","9T7","9VP","9WJ","9WN","9WZ","9YW","A0K","A1Q","A2G","A5C","A6P","AAL","AAO","ABC","ABD","ABE","ABF","ABL","AC1","ACG","ACR","ACX","ADA","ADG","ADR","AF1","AFD","AFL","AFO","AFP","AFR","AGC","AGH","AGL","AGR","AH2","AH8","AHG","AHM","AHR","AIG","ALL","ALX","AMG","AMN","AMU","AMV","ANA","AOG","AOS","AQA","ARA","ARB","ARE","ARI","ARW","ASC","ASG","ASO","AXP","AXR","AY9","AZC","B0D","B16","B1H","B1N","B2G","B4G","B6D","B7G","B8D","B9D","BBK","BBV","BCD","BCW","BDF","BDG","BDP","BDR","BDZ","BEM","BFN","BFP","BG6","BG8","BGC","BGL","BGN","BGP","BGS","BHG","BM3","BM7","BMA","BMX","BND","BNG","BNX","BO1","BOG","BQY","BRI","BS7","BTG","BTU","BW3","BWG","BXF","BXP","BXX","BXY","BZD","C3B","C3G","C3X","C4B","C4W","C4X","C5X","CAP","CBF","CBI","CBK","CDR","CE5","CE6","CE8","CEG","CEX","CEY","CEZ","CGF","CJB","CKB","CKP","CNP","CR1","CR6","CRA","CT3","CTO","CTR","CTT","D0N","D1M","D5E","D6G","DAF","DAG","DAN","DDA","DDB","DDL","DEG","DEL","DFR","DFX","DG0","DGC","DGD","DGM","DGO","DGS","DGU","DIG","DJB","DJE","DK4","DKX","DKZ","DL6","DLD","DLF","DLG","DMU","DNO","DO8","DOM","DP5","DPC","DQQ","DQR","DR2","DR3","DR4","DR5","DRI","DSR","DT6","DVC","DYM","E3M","E4P","E5G","EAG","EBG","EBQ","EEN","EEQ","EGA","EJT","EMP","EMZ","EPG","EQP","EQV","ERE","ERI","ETT","EUS","F1P","F1X","F55","F58","F6P","F8X","FBP","FCA","FCB","FCT","FDP","FDQ","FFC","FFX","FIF","FIX","FK9","FKD","FMF","FMO","FNG","FNY","FRU","FSA","FSI","FSM","FSR","FSW","FU4","FUB","FUC","FUD","FUF","FUL","FUY","FVQ","FX1","FYJ","G0S","G16","G1P","G20","G28","G2F","G3F","G3I","G4D","G4S","G6D","G6P","G6S","G7P","G8Z","GAA","GAC","GAD","GAF","GAL","GAT","GBH","GC1","GC4","GC9","GCB","GCD","GCN","GCO","GCS","GCT","GCU","GCV","GCW","GDA","GDL","GE1","GE3","GFP","GIV","GL0","GL1","GL2","GL4","GL5","GL6","GL7","GL9","GLA","GLB","GLC","GLD","GLF","GLG","GLO","GLP","GLS","GLT","GLW","GM0","GMB","GMH","GMT","GMZ","GN1","GN4","GNS","GNX","GP0","GP1","GP4","GPH","GPK","GPM","GPO","GPQ","GPU","GPV","GPW","GQ1","GRF","GRX","GS1","GS4","GS9","GSA","GSD","GTE","GTH","GTK","GTM","GTR","GU0","GU1","GU2","GU3","GU4","GU5","GU6","GU8","GU9","GUF","GUL","GUP","GUZ","GXL","GXV","GYE","GYG","GYP","GYU","GYV","GZL","H1M","H1S","H2P","H3S","H53","H6Q","H6Z","HBZ","HD4","HDL","HMS","HNV","HNW","HSG","HSH","HSJ","HSQ","HSR","HSU","HSX","HSY","HSZ","HTG","HTM","HVC","I57","IAB","IDC","IDF","IDG","IDR","IDS","IDT","IDU","IDX","IDY","IEM","IN1","IPT","ISD","ISL","ISX","IVG","IXD","J5B","JFZ","JHM","JLT","JRV","JS2","JSV","JV4","JVA","JVS","JZR","K5B","K99","KBA","KBG","KD5","KDA","KDB","KDD","KDE","KDF","KDM","KDN","KDO","KDR","KFN","KG1","KGM","KHP","KME","KO1","KO2","KOT","KQC","KTU","L1L","L6N","L6S","L6T","LAG","LAH","LAI","LAK","LAO","LAT","LB2","LBS","LBT","LCN","LDY","LEC","LER","LFC","LFR","LGC","LGU","LKA","LKS","LM2","LMO","LMT","LMU","LNV","LOG","LOX","LPK","LRH","LSM","LTG","LTM","LVO","LVZ","LXB","LXC","LXZ","LZ0","M1F","M1P","M2F","M3M","M3N","M55","M6D","M6P","M7B","M7P","M8C","MA1","MA2","MA3","MA8","MAB","MAF","MAG","MAL","MAN","MAT","MAV","MAW","MBE","MBF","MBG","MCU","MDA","MDP","MFA","MFB","MFU","MG5","MGA","MGC","MGL","MGS","MJJ","MLB","MLR","MMA","MMN","MN0","MNA","MQG","MQT","MRH","MRP","MSX","MTT","MUB","MUG","MUR","MVP","MXY","MXZ","MYG","N1L","N3U","N9S","NA1","NAA","NAG","NBG","NBX","NBY","NDG","NED","NFG","NG1","NG6","NGA","NGB","NGC","NGE","NGF","NGK","NGL","NGR","NGS","NGY","NGZ","NHF","NLC","NM6","NM9","NNG","NPF","NSQ","NT1","NTF","NTO","NTP","NXD","NYT","O1G","OAK","OEL","OI7","OPM","ORP","OSU","OTG","OTN","OTU","OX2","P53","P6P","P8E","PA1","PA5","PAV","PDX","PH5","PKM","PNA","PNG","PNJ","PNW","PPC","PRP","PSG","PSJ","PSV","PTQ","PUF","PZU","QDK","QIF","QKH","QPS","QV4","R1P","R1X","R2B","R2G","R5P","RAA","RAE","RAF","RAM","RAO","RAT","RB5","RBL","RCD","RDP","REL","RER","RF5","RG1","RGG","RHA","RHC","RI2","RIB","RIP","RM4","RNS","RNT","ROB","ROR","RP3","RP5","RP6","RPA","RR7","RRJ","RRY","RST","RTG","RTV","RUB","RUG","RUU","RV7","RVG","RVM","RWI","RY7","RZM","S6P","S7P","S81","SA0","SCG","SCR","SDD","SDY","SEJ","SF6","SF9","SFJ","SFU","SG4","SG5","SG6","SG7","SGA","SGC","SGD","SGN","SGS","SHB","SHD","SHG","SI3","SIA","SID","SIO","SIZ","SLB","SLM","SLT","SMD","SN5","SNG","SOE","SOG","SOL","SOR","SR1","SSG","SSH","STW","STZ","SUC","SUP","SUS","SWE","SZZ","T68","T6D","T6P","T6T","TA6","TAG","TCB","TCG","TDG","TEU","TF0","TFU","TGA","TGK","TGR","TGY","TH1","TM5","TM6","TM9","TMR","TMX","TNX","TOA","TOC","TQY","TRE","TRV","TS8","TT7","TTV","TTZ","TU4","TUG","TUJ","TUP","TUR","TVD","TVG","TVM","TVS","TVV","TVY","TW7","TWA","TWD","TWG","TWJ","TWY","TXB","TY6","TYV","U1Y","U2A","U2D","U63","U8V","U97","U9A","U9D","U9G","U9J","U9M","UAP","UBH","UBO","UCD","UDC","UEA","V3M","V3P","V71","VG1","VJ1","VJ4","VKN","VTB","W9T","WIA","WOO","WUN","WZ1","WZ2","WZ4","X0X","X1P","X1X","X2F","X2Y","X34","X4S","X5S","X6X","X6Y","XBP","XDP","XDX","XGP","XIL","XKJ","XLF","XLS","XMM","XS2","XUL","XXM","XXR","XXX","XY6","XY9","XYB","XYF","XYL","XYP","XYS","XYT","XYZ","YDR","YIO","YJM","YKR","YO5","YX0","YX1","YYB","YYD","YYH","YYJ","YYK","YYM","YYQ","YYR","YZ0","YZT","Z0F","Z15","Z16","Z2D","Z2T","Z3K","Z3L","Z3Q","Z3U","Z4K","Z4R","Z4S","Z4U","Z4V","Z4W","Z4Y","Z57","Z5J","Z5L","Z61","Z6G","Z6H","Z6J","Z6W","Z8H","Z8T","Z9D","Z9E","Z9H","Z9K","Z9L","Z9M","Z9N","Z9W","ZB0","ZB1","ZB2","ZB3","ZCD","ZCZ","ZD0","ZDC","ZDM","ZDO","ZEE","ZEL","ZGE","ZMR","UMQ","SQD"]);var Au,Du,Hn=function(e){return e[e.FilledSphere=0]="FilledSphere",e[e.FilledCube=1]="FilledCube",e[e.CrossedCube=2]="CrossedCube",e[e.DividedDiamond=3]="DividedDiamond",e[e.FilledCone=4]="FilledCone",e[e.DevidedCone=5]="DevidedCone",e[e.FlatBox=6]="FlatBox",e[e.FilledStar=7]="FilledStar",e[e.FilledDiamond=8]="FilledDiamond",e[e.FlatDiamond=9]="FlatDiamond",e[e.FlatHexagon=10]="FlatHexagon",e[e.Pentagon=11]="Pentagon",e[e.DiamondPrism=12]="DiamondPrism",e[e.PentagonalPrism=13]="PentagonalPrism",e[e.HexagonalPrism=14]="HexagonalPrism",e[e.HeptagonalPrism=15]="HeptagonalPrism",e}(Hn||{}),Nt={Blue:37052,Green:42577,Yellow:16765952,Orange:16021792,Pink:16162465,Purple:10830745,LightBlue:9424105,Brown:10582605,Red:15539236,Secondary:15854817},wt=function(e){return e[e.Hexose=0]="Hexose",e[e.HexNAc=1]="HexNAc",e[e.Hexosamine=2]="Hexosamine",e[e.Hexuronate=3]="Hexuronate",e[e.Deoxyhexose=4]="Deoxyhexose",e[e.DeoxyhexNAc=5]="DeoxyhexNAc",e[e.DiDeoxyhexose=6]="DiDeoxyhexose",e[e.Pentose=7]="Pentose",e[e.Deoxynonulosonate=8]="Deoxynonulosonate",e[e.DiDeoxynonulosonate=9]="DiDeoxynonulosonate",e[e.Unknown=10]="Unknown",e[e.Assigned=11]="Assigned",e}(wt||{}),Cgt=(Au={},Au[wt.Hexose]="Hexose",Au[wt.HexNAc]="HexNAc",Au[wt.Hexosamine]="Hexosamine",Au[wt.Hexuronate]="Hexuronate",Au[wt.Deoxyhexose]="Deoxyhexose",Au[wt.DeoxyhexNAc]="DeoxyhexNAc",Au[wt.DiDeoxyhexose]="Di-deoxyhexose",Au[wt.Pentose]="Pentose",Au[wt.Deoxynonulosonate]="Deoxynonulosonate",Au[wt.DiDeoxynonulosonate]="Di-deoxynonulosonate",Au[wt.Unknown]="Unknown",Au[wt.Assigned]="Assigned",Au);var j2e=(Du={},Du[wt.Hexose]=Hn.FilledSphere,Du[wt.HexNAc]=Hn.FilledCube,Du[wt.Hexosamine]=Hn.CrossedCube,Du[wt.Hexuronate]=Hn.DividedDiamond,Du[wt.Deoxyhexose]=Hn.FilledCone,Du[wt.DeoxyhexNAc]=Hn.DevidedCone,Du[wt.DiDeoxyhexose]=Hn.FlatBox,Du[wt.Pentose]=Hn.FilledStar,Du[wt.Deoxynonulosonate]=Hn.FilledDiamond,Du[wt.DiDeoxynonulosonate]=Hn.FlatDiamond,Du[wt.Unknown]=Hn.FlatHexagon,Du[wt.Assigned]=Hn.Pentagon,Du);function vW(e,t){return e===wt.Unknown?t===4?Hn.DiamondPrism:t===5?Hn.PentagonalPrism:t===6?Hn.HexagonalPrism:t===7?Hn.HeptagonalPrism:Hn.FlatHexagon:j2e[e]}var tw={abbr:"Unk",name:"Unknown",color:Nt.Secondary,type:wt.Unknown},Y0=[{abbr:"Glc",name:"Glucose",color:Nt.Blue,type:wt.Hexose},{abbr:"Man",name:"Mannose",color:Nt.Green,type:wt.Hexose},{abbr:"Gal",name:"Galactose",color:Nt.Yellow,type:wt.Hexose},{abbr:"Gul",name:"Gulose",color:Nt.Orange,type:wt.Hexose},{abbr:"Alt",name:"Altrose",color:Nt.Pink,type:wt.Hexose},{abbr:"All",name:"Allose",color:Nt.Purple,type:wt.Hexose},{abbr:"Tal",name:"Talose",color:Nt.LightBlue,type:wt.Hexose},{abbr:"Ido",name:"Idose",color:Nt.Brown,type:wt.Hexose},{abbr:"GlcNAc",name:"N-Acetyl Glucosamine",color:Nt.Blue,type:wt.HexNAc},{abbr:"ManNAc",name:"N-Acetyl Mannosamine",color:Nt.Green,type:wt.HexNAc},{abbr:"GalNAc",name:"N-Acetyl Galactosamine",color:Nt.Yellow,type:wt.HexNAc},{abbr:"GulNAc",name:"N-Acetyl Gulosamine",color:Nt.Orange,type:wt.HexNAc},{abbr:"AltNAc",name:"N-Acetyl Altrosamine",color:Nt.Pink,type:wt.HexNAc},{abbr:"AllNAc",name:"N-Acetyl Allosamine",color:Nt.Purple,type:wt.HexNAc},{abbr:"TalNAc",name:"N-Acetyl Talosamine",color:Nt.LightBlue,type:wt.HexNAc},{abbr:"IdoNAc",name:"N-Acetyl Idosamine",color:Nt.Brown,type:wt.HexNAc},{abbr:"GlcN",name:"Glucosamine",color:Nt.Blue,type:wt.Hexosamine},{abbr:"ManN",name:"Mannosamine",color:Nt.Green,type:wt.Hexosamine},{abbr:"GalN",name:"Galactosamine",color:Nt.Yellow,type:wt.Hexosamine},{abbr:"GulN",name:"Gulosamine",color:Nt.Orange,type:wt.Hexosamine},{abbr:"AltN",name:"Altrosamine",color:Nt.Pink,type:wt.Hexosamine},{abbr:"AllN",name:"Allosamine",color:Nt.Purple,type:wt.Hexosamine},{abbr:"TalN",name:"Talosamine",color:Nt.LightBlue,type:wt.Hexosamine},{abbr:"IdoN",name:"Idosamine",color:Nt.Brown,type:wt.Hexosamine},{abbr:"GlcA",name:"Glucuronic Acid",color:Nt.Blue,type:wt.Hexuronate},{abbr:"ManA",name:"Mannuronic Acid",color:Nt.Green,type:wt.Hexuronate},{abbr:"GalA",name:"Galacturonic Acid",color:Nt.Yellow,type:wt.Hexuronate},{abbr:"GulA",name:"Guluronic Acid",color:Nt.Orange,type:wt.Hexuronate},{abbr:"AltA",name:"Altruronic Acid",color:Nt.Pink,type:wt.Hexuronate},{abbr:"AllA",name:"Alluronic Acid",color:Nt.Purple,type:wt.Hexuronate},{abbr:"TalA",name:"Taluronic Acid",color:Nt.LightBlue,type:wt.Hexuronate},{abbr:"IdoA",name:"Iduronic Acid",color:Nt.Brown,type:wt.Hexuronate},{abbr:"Qui",name:"Quinovose",color:Nt.Blue,type:wt.Deoxyhexose},{abbr:"Rha",name:"Rhamnose",color:Nt.Green,type:wt.Deoxyhexose},{abbr:"6dGul",name:"6-Deoxy Gulose",color:Nt.Orange,type:wt.Deoxyhexose},{abbr:"6dAlt",name:"6-Deoxy Altrose",color:Nt.Pink,type:wt.Deoxyhexose},{abbr:"6dTal",name:"6-Deoxy Talose",color:Nt.LightBlue,type:wt.Deoxyhexose},{abbr:"Fuc",name:"Fucose",color:Nt.Red,type:wt.Deoxyhexose},{abbr:"QuiNAc",name:"N-Acetyl Quinovosamine",color:Nt.Blue,type:wt.DeoxyhexNAc},{abbr:"RhaNAc",name:"N-Acetyl Rhamnosamine",color:Nt.Green,type:wt.DeoxyhexNAc},{abbr:"6dAltNAc",name:"N-Acetyl 6-Deoxy Altrosamine",color:Nt.Pink,type:wt.DeoxyhexNAc},{abbr:"6dTalNAc",name:"N-Acetyl 6-Deoxy Talosamine",color:Nt.LightBlue,type:wt.DeoxyhexNAc},{abbr:"FucNAc",name:"N-Acetyl Fucosamine",color:Nt.Red,type:wt.DeoxyhexNAc},{abbr:"Oli",name:"Olivose",color:Nt.Blue,type:wt.DiDeoxyhexose},{abbr:"Tyv",name:"Tyvelose",color:Nt.Green,type:wt.DiDeoxyhexose},{abbr:"Abe",name:"Abequose",color:Nt.Orange,type:wt.DiDeoxyhexose},{abbr:"Par",name:"Paratose",color:Nt.Pink,type:wt.DiDeoxyhexose},{abbr:"Dig",name:"Digitoxose",color:Nt.Purple,type:wt.DiDeoxyhexose},{abbr:"Col",name:"Colitose",color:Nt.LightBlue,type:wt.DiDeoxyhexose},{abbr:"Ara",name:"Arabinose",color:Nt.Green,type:wt.Pentose},{abbr:"Lyx",name:"Lyxose",color:Nt.Yellow,type:wt.Pentose},{abbr:"Xyl",name:"Xylose",color:Nt.Orange,type:wt.Pentose},{abbr:"Rib",name:"Ribose",color:Nt.Pink,type:wt.Pentose},{abbr:"Kdn",name:"Keto-Deoxy Nonulonic Acid",color:Nt.Green,type:wt.Deoxynonulosonate},{abbr:"Neu5Ac",name:"N-Acetyl Neuraminic Acid",color:Nt.Purple,type:wt.Deoxynonulosonate},{abbr:"Neu5Gc",name:"N-Glycolyl Neuraminic Acid",color:Nt.LightBlue,type:wt.Deoxynonulosonate},{abbr:"Neu",name:"Neuraminic Acid",color:Nt.Brown,type:wt.Deoxynonulosonate},{abbr:"Sia",name:"Sialic acid",color:Nt.Red,type:wt.Deoxynonulosonate},{abbr:"Pse",name:"Pseudaminic Acid",color:Nt.Green,type:wt.DiDeoxynonulosonate},{abbr:"Leg",name:"Legionaminic Acid",color:Nt.Yellow,type:wt.DiDeoxynonulosonate},{abbr:"Aci",name:"Acinetaminic Acid",color:Nt.Pink,type:wt.DiDeoxynonulosonate},{abbr:"4eLeg",name:"4-Epilegionaminic Acid",color:Nt.LightBlue,type:wt.DiDeoxynonulosonate},{abbr:"Bac",name:"Bacillosamine",color:Nt.Blue,type:wt.Unknown},{abbr:"LDmanHep",name:"L-Glycero-D-Manno Heptose",color:Nt.Green,type:wt.Unknown},{abbr:"Kdo",name:"Keto-Deoxy Octulonic Acid",color:Nt.Yellow,type:wt.Unknown},{abbr:"Dha",name:"3-Deoxy Lyxo-Heptulosaric Acid",color:Nt.Orange,type:wt.Unknown},{abbr:"DDmanHep",name:"D-Glycero-D-Manno-Heptose",color:Nt.Pink,type:wt.Unknown},{abbr:"MurNAc",name:"N-Acetyl Muramic Acid",color:Nt.Purple,type:wt.Unknown},{abbr:"MurNGc",name:"N-Glycolyl Muramic Acid",color:Nt.LightBlue,type:wt.Unknown},{abbr:"Mur",name:"Muramic Acid",color:Nt.Brown,type:wt.Unknown},{abbr:"Api",name:"Apicose",color:Nt.Green,type:wt.Assigned},{abbr:"Fru",name:"Fructose",color:Nt.Green,type:wt.Assigned},{abbr:"Tag",name:"Tagatose",color:Nt.Yellow,type:wt.Assigned},{abbr:"Sor",name:"Sorbose",color:Nt.Orange,type:wt.Assigned},{abbr:"Psi",name:"Psicose",color:Nt.Pink,type:wt.Assigned}],gW=function(){for(var e=new Map,t=0,r=Y0.length;t=t;)r=Math.floor(r/t),a+=jR[r%t],n+=1;return n>=5&&console.warn("getChainId overflow"),a}var Ld=sw(u_e);var ji=function(){function e(){this.count=0,this.ids=[],this.types=[],this.descriptions=[],this.compoundsMap=new Map,this.namesMap=new Map,this.heteroMap=new Map,this.chainMap=new Map}return e.prototype.set=function(t,r){this.count+=1,this.ids.push("".concat(this.count)),this.types.push(t),this.descriptions.push([r])},e.prototype.getEntityId=function(t,r,n,a){return r===2?(this.waterId===void 0&&(this.set("water",a?.customName||"Water"),this.waterId="".concat(this.count)),this.waterId):op(r)?this.compoundsMap.has(n)?this.compoundsMap.get(n):(this.chainMap.has(n)||(this.set("polymer",a?.customName||"Polymer ".concat(this.chainMap.size+1)),this.chainMap.set(n,"".concat(this.count))),this.chainMap.get(n)):(this.heteroMap.has(t)||(this.set("non-polymer",a?.customName||this.namesMap.get(t)||t),this.heteroMap.set(t,"".concat(this.count))),this.heteroMap.get(t))},e.prototype.getEntityTable=function(){return ar.ofPartialColumns(ta.entity,{id:ne.ofStringArray(this.ids),type:ne.ofStringAliasArray(this.types),pdbx_description:ne.ofStringListArray(this.descriptions)},this.count)},e.prototype.setCompounds=function(t){for(var r=0,n=t.length;rm&&(h=m,p=d);var v=vo(h,p);return this.included.has(v)?!1:(this.included.add(v),this.xs[this.xs.length]=h,this.ys[this.ys.length]=p,!0)},f.prototype.getGraph=function(){return s(this.vertexCount,this.xs,this.ys)},f.prototype.getEdgeBuiler=function(){return new a(this.vertexCount,this.xs,this.ys)},f}();e.UniqueEdgeBuilder=o;function s(f,d,m){var h=new e.EdgeBuilder(f,d,m);return h.addAllEdges(),h.createGraph({})}e.fromVertexPairs=s;function u(f,d,m){for(var h=f.b,p=f.offset,v=f.vertexCount,g=f.edgeProps,b=new Int32Array(v),x=0,S=d.length;xx&&b[h[C]]!==0&&_++;for(var T=new Int32Array(d.length+1),A=new Int32Array(2*_),E=new Int32Array(2*_),I=new Int32Array(2*_),R=0,B=0,x=0;x0;){for(var C=S.pop(),D=v[C],T=b[C],A=b[C+1];T=0&&(S.push(_.head),v[_.head]=++g,_.remove(_.head))}return{componentCount:d,componentIndex:v}}e.connectedComponents=c;function l(f,d,m,h){if(Fe.areIntersecting(d,m))return!0;if(h<1)return!1;for(var p=new Set,v=0,g=d.length;v1?WW(e,s,r,n-1,a):!1}var c_e=function(){function e(){this.map=new Map,this.applicable=new Map}return e.prototype.add=function(t,r,n){this.map.set(t,r),n&&this.applicable.set(t,n)},e.prototype.remove=function(t){this.map.delete(t),this.applicable.delete(t)},e.prototype.get=function(t){return this.map.get(t)},e.prototype.isApplicable=function(t){if(!this.map.has(t.sourceData.kind))return!1;var r=this.applicable.get(t.sourceData.kind);return r?r(t):!0},e}();var yo;(function(e){function t(r,n){var a=r.name,i=new c_e;return{descriptor:r,formatRegistry:i,isApplicable:function(o){return i.isApplicable(o)},get:function(o){var s=n?.asDynamic?o._dynamicPropertyData:o._staticPropertyData;if(s[a])return s[a];if(!o.customProperties.has(r)){var u=i.get(o.sourceData.kind);if(u)return s[a]=u(o),o.customProperties.add(r),s[a]}},set:function(o,s){n?.asDynamic?o._dynamicPropertyData[a]=s:o._staticPropertyData[a]=s},delete:function(o){n?.asDynamic?delete o._dynamicPropertyData[a]:delete o._staticPropertyData[a]}}}e.create=t})(yo||(yo={}));function l_e(e,t,r,n){for(var a=new Mi.EdgeBuilder(n,e,t),i=new Int32Array(a.slotCount),o=new Array(a.slotCount),s=new Array(a.slotCount),u=new Int8Array(a.slotCount),c=new Array(a.slotCount),l=new Array(a.slotCount),f=0,d=a.edgeCount;f".concat(o," #").concat(s)),v.push("".concat(l,"\xD7").concat(f,"\xD7").concat(d," \u212B")),v.push("\u03B1=".concat(m,"\xB0 \u03B2=").concat(h,"\xB0 \u03B3=").concat(p,"\xB0")),v.join(" | ")}e.getUnitcellLabel=r})(kd||(kd={}));var sp;(function(e){function t(r,n,a,i){return{id:Er.create22(),label:r,basic:n,sourceData:i,bonds:a}}e.create=t})(sp||(sp={}));var f_e={HIS:"H",ARG:"R",LYS:"K",ILE:"I",PHE:"F",LEU:"L",TRP:"W",ALA:"A",MET:"M",PRO:"P",CYS:"C",ASN:"N",VAL:"V",GLY:"G",SER:"S",GLN:"Q",TYR:"Y",ASP:"D",GLU:"E",THR:"T",SEC:"U",PYL:"O",HSD:"H",HSE:"H",HSP:"H",LSN:"K",ASPP:"D",GLUP:"E",HID:"H",HIE:"H",HIP:"H",LYN:"K",ASH:"D",GLH:"E"},d_e={DA:"A",DC:"C",DG:"G",DT:"T",DU:"U"},m_e={A:"A",C:"C",G:"G",T:"T",U:"U"};function qR(e){var t=f_e[e];return t||"X"}function WR(e){var t=m_e[e];return t||"X"}function YR(e){var t=d_e[e];return t||"X"}var pv;(function(e){var t;(function(c){c.Protein="protein",c.RNA="RNA",c.DNA="DNA",c.Generic="generic"})(t=e.Kind||(e.Kind={}));function r(c){var l=c.code.toArray();return(l instanceof Array?l:Array.from(l)).join("")}e.getSequenceString=r;function n(c){for(var l=0,f=Math.min(c.rowCount,10);l0?function(d){var m=f(d);return m!=="X"||!l.has(d)?m:f(l.get(d))}:f}function i(c,l){if(l.rowCount===0)throw new Error("cannot be empty");var f=n(c);return new o(f,c,l)}e.ofResidueNames=i;var o=function(){function c(l,f,d){this.kind=l,this.microHet=new Map;for(var m=a(l),h=[],p=[],v=[],g=new Map,b=0,x=new Map,S=0,_=d.rowCount;S<_;++S){var C=d.value(S);if(x.has(C))g.has(C)?g.get(C).push(f.value(S)):g.set(C,[p[x.get(C)],f.value(S)]);else{x.set(C,b);var D=f.value(S);p[b]=D,v[b]=C,h[b]=m(D),b+=1}}for(var T=[],S=0,_=b;S<_;++S){var A=g.get(v[S]);if(A){var E=A.map(function(B){var O=m(B);return O==="X"?B:O});T[S]="(".concat(E.join("|"),")")}else T[S]=h[S]==="X"?p[S]:h[S]}this.length=b,this.code=ne.ofStringArray(h),this.compId=ne.ofStringArray(p),this.seqId=ne.ofIntArray(v),this.label=ne.ofStringArray(T),this.microHet=g,this.indexMap=x}return c.prototype.index=function(l){return this.indexMap.get(l)},c}();function s(c,l){var f=t.Generic;return new u(f,c,l)}e.ofSequenceRanges=s;var u=function(){function c(l,f,d){this.kind=l,this.seqIdStart=f,this.seqIdEnd=d,this.microHet=new Map;for(var m=0,h=Number.MAX_SAFE_INTEGER,p=0,v=this.seqIdStart.rowCount;pgx,Location:()=>Mn,Loci:()=>lp,Stats:()=>pB,atomicProperty:()=>GAe,chainIndex:()=>jAe,coarseProperty:()=>zAe,entityIndex:()=>qAe,property:()=>VAe,residueIndex:()=>HAe});var Mn;(function(e){function t(m,h,p){return{kind:"element-location",structure:m,unit:h,element:p||0}}e.create=t;function r(m){return t(m.structure,m.unit,m.element)}e.clone=r;function n(m,h,p,v){return h&&(m.structure=h),p&&(m.unit=p),v!==void 0&&(m.element=v),m}e.set=n;function a(m,h){return m.unit=h.unit,m.element=h.element,m}e.copy=a;function i(m){return!!m&&m.kind==="element-location"}e.is=i;function o(m,h){return m.unit===h.unit&&m.element===h.element}e.areEqual=o;var s=y(),u=y();function c(m,h){return m.unit.conformation.position(m.element,s),h.unit.conformation.position(h.element,u),y.distance(s,u)}e.distance=c;function l(m,h){return h.unit.conformation.position(h.element,m)}e.position=l;function f(m){return m.unit.model.atomicHierarchy.residueAtomSegments.index[m.element]}e.residueIndex=f;function d(m){return m.unit.model.atomicHierarchy.chainAtomSegments.index[m.element]}e.chainIndex=d})(Mn||(Mn={}));var Ae;(function(e){function t(s,u,c){return{kind:"variable",name:s,type:u,isConstraint:c}}e.Variable=t;function r(s,u,c){return{kind:"value",namespace:s,name:u,parent:c}}e.Value=r;function n(s,u,c,l){return{kind:"container",namespace:s,name:u,child:c,alias:l}}e.Container=n;function a(s){return{kind:"union",types:s}}e.Union=a;function i(s,u,c,l){for(var f=Object.create(null),d=0,m=l;d= 2nd and <= 3rd.")},y_e={"@header":"Math",add:up(Ae.Num),sub:up(Ae.Num),mult:up(Ae.Num),div:Yc(Ae.Num,Ae.Num),pow:Yc(Ae.Num,Ae.Num),mod:Yc(Ae.Num,Ae.Num),min:up(Ae.Num),max:up(Ae.Num),cantorPairing:Yc(Ae.Num,Ae.Num),sortedCantorPairing:Yc(Ae.Num,Ae.Num),invertCantorPairing:$t(zt.Dictionary({0:lt(Ae.Num)}),jr.List(Ae.Num)),floor:ro(Ae.Num),ceil:ro(Ae.Num),roundInt:ro(Ae.Num),trunc:ro(Ae.Num),abs:ro(Ae.Num),sign:ro(Ae.Num),sqrt:ro(Ae.Num),cbrt:ro(Ae.Num),sin:ro(Ae.Num),cos:ro(Ae.Num),tan:ro(Ae.Num),asin:ro(Ae.Num),acos:ro(Ae.Num),atan:ro(Ae.Num),sinh:ro(Ae.Num),cosh:ro(Ae.Num),tanh:ro(Ae.Num),exp:ro(Ae.Num),log:ro(Ae.Num),log10:ro(Ae.Num),atan2:Yc(Ae.Num,Ae.Num)},b_e={"@header":"Strings",concat:up(Ae.Str),match:$t(zt.Dictionary({0:lt(jr.Regex),1:lt(Ae.Str)}),Ae.Bool)},x_e={"@header":"Lists",getAt:$t(zt.Dictionary({0:lt(jr.List()),1:lt(Ae.Num)}),jr.AnyVar),equal:$t(zt.Dictionary({0:lt(jr.List()),1:lt(jr.List())}),Ae.Bool)},S_e={"@header":"Sets",has:$t(zt.Dictionary({0:lt(jr.Set(jr.ConstrainedVar)),1:lt(jr.ConstrainedVar)}),Ae.Bool,"Check if the the 1st argument includes the value of the 2nd."),isSubset:$t(zt.Dictionary({0:lt(jr.Set(jr.ConstrainedVar)),1:lt(jr.Set(jr.ConstrainedVar))}),Ae.Bool,"Check if the the 1st argument is a subset of the 2nd.")},C_e={"@header":"Flags",hasAny:$t(zt.Dictionary({0:lt(jr.Flags(jr.ConstrainedVar)),1:lt(jr.Flags(jr.ConstrainedVar))}),Ae.Bool,"Check if the the 1st argument has at least one of the 2nd one's flags."),hasAll:$t(zt.Dictionary({0:lt(jr.Flags(jr.ConstrainedVar)),1:lt(jr.Flags(jr.ConstrainedVar))}),Ae.Bool,"Check if the the 1st argument has all 2nd one's flags.")},fw={"@header":"Language Primitives",type:p_e,logic:h_e,ctrl:v_e,rel:g_e,math:y_e,str:b_e,list:x_e,set:S_e,flags:C_e};cw(fw);var __e=lw(fw),K0t=function(){for(var e=Object.create(null),t=0,r=__e;t0?a:t<0?r:(r+n)/1.95}var z_e=KR.H;function Xc(e){return e===z_e}var H_e=new Map([["HIS|CD2|CG",2],["HIS|CE1|ND1",2],["ARG|CZ|NH2",2],["PHE|CE1|CZ",2],["PHE|CD2|CE2",2],["PHE|CD1|CG",2],["TRP|CD1|CG",2],["TRP|CD2|CE2",2],["TRP|CE3|CZ3",2],["TRP|CH2|CZ2",2],["ASN|CG|OD1",2],["GLN|CD|OE1",2],["TYR|CD1|CG",2],["TYR|CD2|CE2",2],["TYR|CE1|CZ",2],["ASP|CG|OD1",2],["GLU|CD|OE1",2],["G|C8|N7",2],["G|C4|C5",2],["G|C2|N3",2],["G|C6|O6",2],["C|C4|N3",2],["C|C5|C6",2],["C|C2|O2",2],["A|C2|N3",2],["A|C6|N1",2],["A|C4|C5",2],["A|C8|N7",2],["U|C5|C6",2],["U|C2|O2",2],["U|C4|O4",2],["DG|C8|N7",2],["DG|C4|C5",2],["DG|C2|N3",2],["DG|C6|O6",2],["DC|C4|N3",2],["DC|C5|C6",2],["DC|C2|O2",2],["DA|C2|N3",2],["DA|C6|N1",2],["DA|C4|C5",2],["DA|C8|N7",2],["DT|C5|C6",2],["DT|C2|O2",2],["DT|C4|O4",2]]);function eY(e,t,r){var n;return n=tr&&(a=[r,e],e=a[0],r=a[1],i=[n,t],t=i[0],n=i[1]),j_e.get("".concat(e,"|").concat(t,"|").concat(r,"|").concat(n))||1}var hw;(function(e){function t(s,u,c){return{name:s,type:0,value:u,valueKind:c&&c.valueKind,defaultFormat:c&&c.encoder?{encoder:c.encoder}:void 0,shouldInclude:c&&c.shouldInclude}}e.str=t;function r(s,u,c){return{name:s,type:1,value:u,valueKind:c&&c.valueKind,defaultFormat:c?{encoder:c.encoder,typedArray:c.typedArray}:void 0,shouldInclude:c&&c.shouldInclude}}e.int=r;function n(s,u,c){return{name:s,type:2,value:u,valueKind:c&&c.valueKind,defaultFormat:c?{encoder:c.encoder,typedArray:c.typedArray,digitCount:typeof c.digitCount<"u"?c.digitCount:void 0}:void 0,shouldInclude:c&&c.shouldInclude}}e.float=n;function a(s){return r(s,function(u,c,l){return l+1},{typedArray:Int32Array,encoder:Or.by(Or.delta).and(Or.runLength).and(Or.integerPacking)})}e.index=a;var i=function(){function s(){this.fields=[]}return s.prototype.index=function(u){return this.fields.push(e.index(u)),this},s.prototype.str=function(u,c,l){return this.fields.push(e.str(u,c,l)),this},s.prototype.int=function(u,c,l){return this.fields.push(e.int(u,c,l)),this},s.prototype.vec=function(u,c,l){for(var f=0;f 3 or rank 0 are currently not supported.");return r}function tY(e){for(var t=[],r=0,n=Object.keys(e);r0});if(!n.length)return{instance:r,rowCount:0,source:[]};var a=n.reduce(function(o,s){return o+s.rowCount},0),i=n.map(function(o){return{data:o.data,keys:function(){return o.keys?o.keys():Jm.Range(0,o.rowCount-1)},rowCount:o.rowCount}});return{instance:r,rowCount:a,source:i}}var aY=function(){function e(){this.builder=$r.create(),this.encoded=!1,this.dataBlockCreated=!1,this.filter=Bs.DefaultFilter,this.formatter=Bs.DefaultFormatter,this.isBinary=!1,this.binaryEncodingProvider=void 0}return e.prototype.setFilter=function(t){this.filter=t||Bs.DefaultFilter},e.prototype.isCategoryIncluded=function(t){return this.filter.includeCategory(t)},e.prototype.setFormatter=function(t){this.formatter=t||Bs.DefaultFormatter},e.prototype.startDataBlock=function(t){this.dataBlockCreated=!0,$r.write(this.builder,"data_".concat((t||"").replace(/[ \n\t]/g,"").toUpperCase(),` +# +`))},e.prototype.writeCategory=function(t,r,n){if(this.encoded)throw new Error("The writer contents have already been encoded, no more writing.");if(!this.dataBlockCreated)throw new Error("No data block created.");if(!(!n?.ignoreFilter&&!this.filter.includeCategory(t.name))){var a=gw(t,r),i=a.instance,o=a.rowCount,s=a.source;o&&(o===1?X_e(t,i,s,this.builder,this.filter,this.formatter):K_e(t,i,s,this.builder,this.filter,this.formatter))}},e.prototype.encode=function(){this.encoded=!0},e.prototype.writeTo=function(t){for(var r=$r.getChunks(this.builder),n=0,a=r.length;n=0}function nY(e,t){$r.write(e,t),$r.newline(e)}function Q_e(e,t){$r.writeInteger(e,t),$r.whitespace1(e)}function $_e(e,t,r){$r.writeFloat(e,t,r),$r.whitespace1(e)}function J_e(e){$r.writeSafe(e,". ")}function ewe(e){$r.writeSafe(e,"? ")}function twe(e,t){if(!t)return $r.writeSafe(e,". "),!1;for(var r=t.charCodeAt(0),n=!1,a=0,i=!1,o=!1,s=0,u=t.length-1;s<=u;s++){var c=t.charCodeAt(s);switch(c){case 9:n=!0;break;case 10:return yw(e,t),!0;case 32:n=!0;break;case 34:if(s&&s===u)break;if(i)return yw(e,t),!0;o=!0,n=!0,a=0;break;case 39:if(s&&s===u)break;if(o)return yw(e,t),!0;i=!0,n=!0,a=1;break}}return!n&&(r===35||r===36||r===59||r===91||r===93||r===95)&&(n=!0),n?($r.writeSafe(e,a?'"':"'"),$r.writeSafe(e,t),$r.writeSafe(e,a?'" ':"' ")):($r.writeSafe(e,t),$r.writeSafe(e," ")),!1}function yw(e,t){$r.writeSafe(e,` +;`+t),$r.writeSafe(e,` +; +`)}function sY(e){var t=new ArrayBuffer(bw(e)),r=new DataView(t),n=new Uint8Array(t);return xw(e,r,n,0),n}function bw(e){var t=typeof e;if(t==="string"){var r=b0(e);if(r<32)return 1+r;if(r<256)return 2+r;if(r<65536)return 3+r;if(r<4294967296)return 5+r}if(e instanceof Uint8Array){var n=e.byteLength;if(n<256)return 2+n;if(n<65536)return 3+n;if(n<4294967296)return 5+n}if(t==="number"){if(Math.floor(e)!==e)return 9;if(e>=0){if(e<128)return 1;if(e<256)return 2;if(e<65536)return 3;if(e<4294967296)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(t==="boolean"||e===null||e===void 0)return 1;if(t==="object"){var a,i=0;if(Array.isArray(e)){a=e.length;for(var o=0;o=0){if(e<128)return t.setUint8(n,e),1;if(e<256)return t.setUint8(n,204),t.setUint8(n+1,e),2;if(e<65536)return t.setUint8(n,205),t.setUint16(n+1,e),3;if(e<4294967296)return t.setUint8(n,206),t.setUint32(n+1,e),5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return t.setInt8(n,e),1;if(e>=-128)return t.setUint8(n,208),t.setInt8(n+1,e),2;if(e>=-32768)return t.setUint8(n,209),t.setInt16(n+1,e),3;if(e>=-2147483648)return t.setUint8(n,210),t.setInt32(n+1,e),5;throw new Error("Number too small -0x"+(-e).toString(16).substr(1))}if(e==null)return t.setUint8(n,192),1;if(a==="boolean")return t.setUint8(n,e?195:194),1;if(a==="object"){var u,c=0,l=Array.isArray(e),f=void 0;if(l?u=e.length:(f=Object.keys(e),u=f.length),u<16?(t.setUint8(n,u|(l?144:128)),c=1):u<65536?(t.setUint8(n,l?220:222),t.setUint16(n+1,u),c=3):u<4294967296&&(t.setUint8(n,l?221:223),t.setUint32(n+1,u),c=5),l)for(var d=0;d.95}e.isExhaustive=t;function r(i,o){for(var s=i.units,u=0,c=s.length;u=0)return!0;return!1}function n(i){for(var o=new Map,s=0,u=i;s=z)){var k=Fe.indexOf(e.elements,z);if(!(k<0)){var G=h[B],V=p[B];if(!(G>=0&&G!==D||V>=0&&V!==D)){var U=Pu(n.value(z)),Q=f[B],W=cwe(e,A,z),X=!1;if(Q>=0)X=Tn(W,Q,.3);else if(i>=0)X=W1&&(k=!1)}}}}}}}}}var xt=O||z&&k;return fY(D,T,E,A,I,s,xt)}function dY(e,t){var r=P(P({},mw),t);return r.noCompute||Vt.isCoarseGrained(e.model)&&!$a.Provider.get(e.model)&&!bs.isExhaustive(e.model)?dw.Empty:!r.forceCompute&&$a.Provider.get(e.model)?fwe(e):dwe(e,r)}var mwe=y.distance,pwe=y.set,hwe=y.squaredDistance,vwe=y.transformMat4,mY=y(),pY=y();function hY(e,t,r,n){return e.conformation.position(t,mY),r.conformation.position(n,pY),mwe(mY,pY)}var gwe=se(),gv=y();function ywe(e,t,r,n){var a=r.maxRadius,i=e.elements,o=e.residueIndex,s=e.model.atomicConformation,u=s.x,c=s.y,l=s.z,f=t.elements,d=t.residueIndex,m=e.elements.length,h=e.model.atomicHierarchy.atoms,p=h.type_symbol,v=h.label_alt_id,g=h.label_atom_id,b=h.label_comp_id,x=t.model.atomicHierarchy.atoms,S=x.type_symbol,_=x.label_alt_id,C=x.label_atom_id,D=x.label_comp_id,T=e.model.atomicHierarchy.residues.auth_seq_id,A=t.model.atomicHierarchy.residues.auth_seq_id,E=e.model.atomicConformation.occupancy,I=t.model.atomicConformation.occupancy,R=E.isDefined&&I.isDefined,B=e.model===t.model&&bs.Provider.get(e.model),O=!r.forceCompute&&e.model===t.model&&$a.Provider.get(e.model),z=e.model.atomicHierarchy.atomSourceIndex,k=(O?Vt.getInvertedAtomSourceIndex(t.model):{invertedIndex:void 0}).invertedIndex,G=e.model===t.model&&bs.isExhaustive(e.model),V=se.mul(gwe,t.conformation.operator.inverse,e.conformation.operator.matrix),U=!se.isIdentity(V),Q=t.boundary.sphere,W=Q.center,X=Q.radius,ae=(X+a)*(X+a);n.startUnitPair(e.id,t.id);for(var q=e.conformation.operator.key,F=t.conformation.operator.key,j=0;jae)){if(!r.forceCompute&&O){for(var Y=O.maxDistance,H=O.bonds,N=H.offset,ee=H.b,oe=H.edgeProps,me=oe.order,pe=oe.distance,de=oe.flag,re=oe.key,te=oe.operatorA,fe=oe.operatorB,ve=z.value(Z),De=Pu(p.value(Z)),Ge=N[ve],Ke=N[ve+1];Ge=0&&ge!==q&&ge!==F||Pe>=0&&Pe!==F&&Pe!==q)){var Ie=Pu(p.value(L)),ke=pe[Ge],Ne=hY(e,Z,t,L),Ve=!1;if(ke>=0)Ve=Tn(Ne,ke,.3);else if(Y>=0)Ve=Nea||(n.add(j,K,{order:ct.order,flag:ct.flags,key:ct.rowIndex}),je=!0)}if(je)continue}if(!G){var ut=E.value(Z),Ct=t.lookup3d,bt=Ct.find(gv[0],gv[1],gv[2],a),Mt=bt.indices,Ot=bt.count,ue=bt.squaredDistances;if(Ot!==0)for(var ye=Pu(p.value(Z)),we=Xc(ye),$e=Lf(ye),Et=v.value(Z),Tt=cp.has(ye),nr=g.value(Z),Br=b.value(o[Z]),sr=0;sr=t.elements.length?e:t,i=n.elements,o=a.elements,s=Fe.indexOf,u=0,c=i.length;u=0)return!0}}return!1}var mt;(function(e){function t(v,g,b,x,S,_){return{kind:"bond-location",aStructure:v,aUnit:g,aIndex:b,bStructure:x,bUnit:S,bIndex:_}}e.Location=t;function r(v){return!!v&&v.kind==="bond-location"}e.isLocation=r;function n(v,g){return v.aStructure.label===g.aStructure.label&&v.bStructure.label===g.bStructure.label&&v.aIndex===g.aIndex&&v.bIndex===g.bIndex&&v.aUnit.id===g.aUnit.id&&v.bUnit.id===g.bUnit.id}e.areLocationsEqual=n;function a(v,g){return{kind:"bond-loci",structure:v,bonds:g}}e.Loci=a;function i(v){return!!v&&v.kind==="bond-loci"}e.isLoci=i;function o(v,g){if(v.structure!==g.structure||v.bonds.length!==g.bonds.length)return!1;for(var b=0,x=v.bonds.length;b=0;l--)v[g++]=e.startVertex+s[l],n[s[l]]=1;ho(v);for(var b=0,x=e.currentRings.length;bS.length&&Fe.isSubset(v,S))return!1}return e.currentRings.push(Fe.ofSortedArray(v)),!0}function xY(e,t,r){var n=e.bonds,a=e.startVertex,i=e.endVertex,o=e.isRingAtom,s=e.marked,u=e.queue,c=e.pred,l=e.depth,f=e.unit.elements,d=n.b,m=n.edgeProps.flags,h=n.offset;s[t]=r,l[t]=0,u[0]=t;for(var p=0,v=1;p=i||!mr.isCovalent(m[C]))){if(e.hasAltLoc){var T=e.altLoc.value(f[D]);if(T&&e.currentAltLoc!==T)continue}var A=D-a;if(s[A]===r){if(c[A]!==g&&c[g]!==A&&Twe(e,g,A,o))return r+1;continue}var E=Math.min(l[A],b+1);E>5||(l[A]=E,s[A]=r,u[v++]=A,c[A]=g)}}return r+1}function wY(e){for(var t=e.length,r=new Array(t),n=0;n=v||d.addEdge(a,v)}}for(var g=Mi.connectedComponents(d.getGraph()),b=g.componentIndex,x=[],s=0;s0)return!1;var T=No.calculateMomentsAxes(Sw(s,u));return y.magnitude(T.dirC)=0&&(r.has(s)?r.get(s).push(o):r.set(s,[o]))}}function Mwe(e,t){for(var r=[],n=0,a=t.length;nEe.max(_)||i(S)1e4?Bwe:Owe}function _w(e){var t=gt.computeBounding(e);return{box:t,sphere:xe.fromBox3D(xe(),t)}}var Cw=y();function Iu(e){var t=e.x,r=e.y,n=e.z,a=e.radius,i=e.indices,o=Ee.size(i);if(o>25e4)return _w(e);var s=Fwe(o);s.reset();for(var u=0;u=2){f(d,h[0],h[1]);for(var b=1,x=h.length;b=a},i.closeUnitsResult);if(l.count===0)return o;for(var f=0,d=-Number.MAX_VALUE,m=0,h=l.count;m=a&&do||u.addElement(b[g.indices[x]])}u.commitUnit()}}},e.prototype.check=function(t,r,n,a){var i=this.structure.units,o=this.unitLookup.find(t,r,n,a);if(o.count===0)return!1;for(var s=0,u=o.count;s0&&(a[a.length]=s.getChild(c))}return Le.create(a,{parent:e.parent||t.parent})}var st;(function(e){function t(g,b){return{kind:"singletons",source:g,structure:b}}e.Singletons=t;function r(g,b){return{kind:"sequence",source:g,structures:b}}e.Sequence=r;function n(g){return t(g,Le.Empty)}e.Empty=n;function a(g){return g.kind==="singletons"}e.isSingleton=a;function i(g){return a(g)?g.structure.units.length===0:g.structures.length===0}e.isEmpty=i;function o(g){return a(g)?g.structure.elementCount:g.structures.length}e.structureCount=o;function s(g){return i(g)?Le.Empty:a(g)?g.structure:Ud(g.source,g.structures)}e.unionStructure=s;function u(g){for(var b=[],x=g.source.unitMap,S=0,_=s(g).units;S<_.length;S++){var C=_[S];C===x.get(C.id)?b[b.length]={unit:C,indices:Ee.ofBounds(0,C.elements.length)}:b[b.length]={unit:C,indices:Ee.ofSortedArray(Fe.indicesOf(x.get(C.id).elements,C.elements))}}return ie.Loci(g.source,b)}e.toLociWithCurrentUnits=u;function c(g){for(var b=[],x=g.source.unitMap,S=0,_=s(g).units;S<_.length;S++){var C=_[S],D=x.get(C.id);D===C?b[b.length]={unit:D,indices:Ee.ofBounds(0,D.elements.length)}:b[b.length]={unit:D,indices:Ee.ofSortedArray(Fe.indicesOf(D.elements,C.elements))}}return ie.Loci(g.source,b)}e.toLociWithSourceUnits=c;function l(g,b,x){var S=b.length;return S===0?n(g):x?t(g,Ud(g,b)):r(g,b)}var f=function(){function g(b){this.source=b,this.structures=[],this.allSingletons=!0}return g.prototype.add=function(b){var x=b.elementCount;x!==0&&(this.structures[this.structures.length]=b,x!==1&&(this.allSingletons=!1))},g.prototype.getSelection=function(){return l(this.source,this.structures,this.allSingletons)},g}(),d=function(){function g(b){this.structure=b,this.structures=[],this.allSingletons=!0,this.uniqueSets=I0(Le.hashCode,Le.areUnitIdsAndIndicesEqual)}return g.prototype.add=function(b){var x=b.elementCount;x===0||!this.uniqueSets.add(b)||(this.structures[this.structures.length]=b,x!==1&&(this.allSingletons=!1))},g.prototype.getSelection=function(){return l(this.structure,this.structures,this.allSingletons)},g}();function m(g){return new f(g)}e.LinearBuilder=m;function h(g){return new d(g)}e.UniqueBuilder=h;function p(g,b){var x=0;if(e.isSingleton(g))for(var S=0,_=g.structure.units;S<_.length;S++)for(var C=_[S],D=C.elements,T=0,A=D.length;TVwe,atomicSequence:()=>Nwe,bundleElementImpl:()=>eB,bundleGenerator:()=>tB,defaultBondTest:()=>Tw,spheres:()=>Gwe,water:()=>Uwe});var gx;(function(e){e.Empty={hash:-1,elements:[]};function t(l,f){return n(st.toLociWithSourceUnits(st.Singletons(l,f)))}e.fromSubStructure=t;function r(l){return n(st.toLociWithSourceUnits(l))}e.fromSelection=r;function n(l){for(var f=[],d=0,m=l.elements;d2)g.push(v[_],v[C-1]);else for(var D=_;DWr.max(p.ranges)){Wr.forEach(p.ranges,function(k,G){return A[G]=C[k]});for(var I=0,R=T;IFe.max(p.set)){for(var I=0,R=T;I=8)continue}a.push(s)}}}return st.Singletons(r,Le.create(a,{parent:r}))}}function Gwe(){return function(t){for(var r=t.inputStructure,n=[],a=0,i=r.units;a0?this.atomicBond=this.currentAtomicBondStack.pop():this.atomicBond=void 0},e.prototype.pushCurrentStructure=function(){this.currentStructure&&this.currentStructureStack.push(this.currentStructure)},e.prototype.popCurrentStructure=function(){this.currentStructureStack.length?this.currentStructure=this.currentStructureStack.pop():this.currentStructure=void 0},e.prototype.pushInputStructure=function(t){this.inputStructureStack.push(this.inputStructure),this.inputStructure=t},e.prototype.popInputStructure=function(){if(this.inputStructureStack.length===0)throw new Error("Must push before pop.");this.inputStructure=this.inputStructureStack.pop()},e.prototype.throwIfTimedOut=function(){if(this.timeoutMs!==0&&pn()-this.timeCreated>this.timeoutMs)throw new Error("The query took too long to execute (> ".concat(this.timeoutMs/1e3,"s)."))},e.prototype.tryGetCurrentSelection=function(){if(!this.currentSelection)throw new Error("The current selection is not assigned.");return this.currentSelection},e}();var UY=function(){function e(){this.a=ie.Location.create(void 0),this.aIndex=0,this.b=ie.Location.create(void 0),this.bIndex=0,this.type=0,this.order=0,this.key=-1,this.testFn=Tw}return e.prototype.setStructure=function(t){this.a.structure=t,this.b.structure=t},e.prototype.setTestFn=function(t){this.testFn=t||Tw},e.prototype.test=function(t,r){return this.testFn(t)?!0:r?(this.swap(),this.testFn(t)):!1},e.prototype.swap=function(){var t=this.aIndex;this.aIndex=this.bIndex,this.bIndex=t;var r=this.a.unit;this.a.unit=this.b.unit,this.b.unit=r;var n=this.a.element;this.a.element=this.b.element,this.b.element=n},Object.defineProperty(e.prototype,"length",{get:function(){return ie.Location.distance(this.a,this.b)},enumerable:!1,configurable:!0}),e}();var nB;(function(e){function t(r,n,a){return r(new no(n,a))}e.run=t})(nB||(nB={}));var oB={};fi(oB,{all:()=>GY,atoms:()=>iB,bondedAtomicPairs:()=>Zwe,chains:()=>Hwe,none:()=>Dw,querySelection:()=>Kwe,residues:()=>zwe,rings:()=>Xwe});var Aw=function(){function e(t){this.source=t,this.set=I0(Le.hashCode,Le.areUnitIdsAndIndicesEqual),this.structures=[],this.allSingletons=!0}return e.prototype.add=function(t){t.elementCount&&(t.elementCount!==1&&(this.allSingletons=!1),this.set.add(t)&&(this.structures[this.structures.length]=t))},e.prototype.getSelection=function(){return this.allSingletons?st.Singletons(this.source,Ud(this.source,this.structures)):st.Sequence(this.source,this.structures)},e}();var VY=function(){function e(t){this.source=t,this.builders=[],this.builderMap=new Map}return e.prototype.add=function(t,r,n){var a=this.builderMap.get(t);a||(a=this.source.subsetBuilder(!0),this.builders[this.builders.length]=a,this.builderMap.set(t,a)),a.addToUnit(r,n)},e.prototype.allSingletons=function(){for(var t=0,r=this.builders.length;t1)return!1;return!0},e.prototype.singletonSelection=function(){for(var t=this.source.subsetBuilder(!0),r=ie.Location.create(this.source),n=0,a=this.builders.length;nLTe,expandProperty:()=>NTe,includeConnected:()=>UTe,includeSurroundings:()=>BTe,intersectBy:()=>FTe,querySelection:()=>OTe,surroundingLigands:()=>GTe,union:()=>kTe,wholeResidues:()=>ITe});var yx=function(){function e(t){this.parent=t,this.ids=[],this.unitMap=Do.Mutable(),this.parentId=-1,this.currentUnit=nn.create(),this.elementCount=0}return e.prototype.addToUnit=function(t,r){var n=this.unitMap.get(t);if(n)nn.add(n,r,r)&&this.elementCount++;else{var a=nn.create();nn.add(a,r,r),this.unitMap.set(t,a),this.ids[this.ids.length]=t,this.elementCount++}},e.prototype.has=function(t,r){var n=this.unitMap.get(t);return n?nn.has(n,r):!1},e.prototype.beginUnit=function(t){this.parentId=t,this.unitMap.has(t)?this.currentUnit=this.unitMap.get(t):this.currentUnit=this.currentUnit.array.length>0?nn.create():this.currentUnit},e.prototype.addElement=function(t){nn.add(this.currentUnit,t,t)&&this.elementCount++},e.prototype.commitUnit=function(){this.currentUnit.array.length===0||this.unitMap.has(this.parentId)||(this.ids[this.ids.length]=this.parentId,this.unitMap.set(this.parentId,this.currentUnit),this.parentId=-1)},e.prototype.getStructure=function(){if(this.isEmpty)return Le.Empty;var t=[];ho(this.ids);for(var r=eu.UnitEquivalenceBuilder(),n=0,a=this.ids.length;n1&&ho(s);var c=o.getChild(Fe.ofSortedArray(s)),l=r.add(c.id,c);c!==l&&(c=l.applyOperator(c.id,c.conformation.operator,!0)),t[t.length]=c}return Le.create(t,{parent:this.parent})},Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.elementCount===0},enumerable:!1,configurable:!0}),e}();var zY={type_symbol:ne.Schema.Aliased(Pr.atom_site.type_symbol),label_atom_id:Pr.atom_site.label_atom_id,auth_atom_id:Pr.atom_site.auth_atom_id,label_alt_id:Pr.atom_site.label_alt_id,label_comp_id:Pr.atom_site.label_comp_id,auth_comp_id:Pr.atom_site.auth_comp_id,pdbx_formal_charge:Pr.atom_site.pdbx_formal_charge},HY={group_PDB:Pr.atom_site.group_PDB,label_seq_id:Pr.atom_site.label_seq_id,auth_seq_id:Pr.atom_site.auth_seq_id,pdbx_PDB_ins_code:Pr.atom_site.pdbx_PDB_ins_code},jY={label_asym_id:Pr.atom_site.label_asym_id,auth_asym_id:Pr.atom_site.auth_asym_id,label_entity_id:Pr.atom_site.label_entity_id},Pw;(function(e){function t(){return{label_entity_id:"",label_asym_id:"",auth_seq_id:0,pdbx_PDB_ins_code:void 0}}e.EmptyResidueKey=t})(Pw||(Pw={}));var Nf;(function(e){function t(a,i){return a.residueAtomSegments.index[a.chainAtomSegments.offsets[i]]}e.chainStartResidueIndex=t;function r(a,i){return a.residueAtomSegments.index[a.chainAtomSegments.offsets[i+1]-1]+1}e.chainEndResidueIndexExcl=r;function n(a,i){return r(a,i)-t(a,i)}e.chainResidueCount=n})(Nf||(Nf={}));var bx={H:1,D:1,T:1,HE:2,LI:3,BE:4,B:5,C:6,N:7,O:8,F:9,NE:10,NA:11,MG:12,AL:13,SI:14,P:15,S:16,CL:17,AR:18,K:19,CA:20,SC:21,TI:22,V:23,CR:24,MN:25,FE:26,CO:27,NI:28,CU:29,ZN:30,GA:31,GE:32,AS:33,SE:34,BR:35,KR:36,RB:37,SR:38,Y:39,ZR:40,NB:41,MO:42,TC:43,RU:44,RH:45,PD:46,AG:47,CD:48,IN:49,SN:50,SB:51,TE:52,I:53,XE:54,CS:55,BA:56,LA:57,CE:58,PR:59,ND:60,PM:61,SM:62,EU:63,GD:64,TB:65,DY:66,HO:67,ER:68,TM:69,YB:70,LU:71,HF:72,TA:73,W:74,RE:75,OS:76,IR:77,PT:78,AU:79,HG:80,TL:81,PB:82,BI:83,PO:84,AT:85,RN:86,FR:87,RA:88,AC:89,TH:90,PA:91,U:92,NP:93,PU:94,AM:95,CM:96,BK:97,CF:98,ES:99,FM:100,MD:101,NO:102,LR:103,RF:104,DB:105,SG:106,BH:107,HS:108,MT:109},Qwe={1:1.1,2:1.4,3:1.81,4:1.53,5:1.92,6:1.7,7:1.55,8:1.52,9:1.47,10:1.54,11:2.27,12:1.73,13:1.84,14:2.1,15:1.8,16:1.8,17:1.75,18:1.88,19:2.75,20:2.31,21:2.3,22:2.15,23:2.05,24:2.05,25:2.05,26:2.05,27:2,28:2,29:2,30:2.1,31:1.87,32:2.11,33:1.85,34:1.9,35:1.83,36:2.02,37:3.03,38:2.49,39:2.4,40:2.3,41:2.15,42:2.1,43:2.05,44:2.05,45:2,46:2.05,47:2.1,48:2.2,49:2.2,50:1.93,51:2.17,52:2.06,53:1.98,54:2.16,55:3.43,56:2.68,57:2.5,58:2.48,59:2.47,60:2.45,61:2.43,62:2.42,63:2.4,64:2.38,65:2.37,66:2.35,67:2.33,68:2.32,69:2.3,70:2.28,71:2.27,72:2.25,73:2.2,74:2.1,75:2.05,76:2,77:2,78:2.05,79:2.1,80:2.05,81:1.96,82:2.02,83:2.07,84:1.97,85:2.02,86:2.2,87:3.48,88:2.83,89:2,90:2.4,91:2,92:2.3,93:2,94:2,95:2,96:2,97:2,98:2,99:2,100:2,101:2,102:2,103:2,104:2,105:2,106:2,107:2,108:2,109:2},$we={1:1.008,2:4.0026,3:6.94,4:9.0122,5:10.81,6:10.81,7:14.007,8:15.999,9:18.998,10:20.18,11:22.99,12:24.305,13:26.982,14:28.085,15:30.974,16:32.06,17:35.45,18:39.948,19:39.098,20:40.078,21:44.956,22:47.867,23:50.942,24:51.996,25:54.938,26:55.845,27:58.933,28:58.693,29:63.546,30:65.38,31:69.723,32:72.63,33:74.922,34:78.971,35:79.904,36:83.798,37:85.468,38:87.62,39:88.906,40:91.224,41:92.906,42:95.95,43:96.906,44:101.07,45:102.91,46:106.42,47:107.87,48:112.41,49:114.82,50:118.71,51:121.76,52:127.6,53:127.6,54:131.29,55:132.91,56:137.33,57:138.91,58:140.12,59:140.91,60:144.24,61:144.912,62:150.36,63:151.96,64:157.25,65:158.93,66:162.5,67:164.93,68:167.26,69:168.93,70:173.05,71:174.97,72:178.49,73:180.95,74:183.84,75:186.21,76:190.23,77:192.22,78:195.08,79:196.97,80:200.59,81:204.38,82:207.2,83:208.98,84:1.97,85:2.02,86:2.2,87:3.48,88:2.83,89:2,90:232.04,91:231.04,92:238.03,93:237.048,94:244.064,95:243.061,96:247.07,97:247.07,98:251.079,99:252.083,100:257.095,101:258.098,102:259.101,103:262.11,104:267.122,105:270.131,106:271.134,107:270.133,108:270.134,109:278.156},Jwe=1.7,eTe=10.81,tTe=0;function Uf(e){var t=bx[e];return t===void 0?Jwe:Qwe[t]}function qY(e){var t=bx[e];return t===void 0?eTe:$we[t]}function dp(e){var t=bx[e];return t===void 0?tTe:t}function Ew(e,t,r,n){return{type:e,key:t,elements:r,getIndex:n}}function WY(e){var t=e.unit,r=e.flags,n=e.proteinInfo,a=t.conformation.position,i=t.model.atomicHierarchy.derived.residue.traceElementIndex,o=n.residueIndices,s=n.nIndices,u=o.length,c=function(I,R){return I===-1?y.setNaN(R):a(I,R)},l=y(),f=y(),d=y(),m=y(),h=y(),p=y(),v=y();e:for(var g=2;g6.25)continue e}var S=o[g-2],_=o[g],C=o[g+2],D=i[S],T=i[_],A=i[C];c(D,l),c(T,f),c(A,d),y.sub(p,l,f),y.sub(v,f,d);var E=Zi(y.angle(p,v));E&&E>70&&(r[g]|=32)}}var rTe=9,Iw=-27.888,nTe=-.5,YY=-9.9;function aTe(e,t,r,n){var a=y.distance(e,n),i=y.distance(t,n),o=y.distance(t,r),s=y.distance(e,r),u=Iw/a-Iw/i,c=Iw/o-Iw/s,l=u+c;return lnTe||(d[d.length]=T,m[m.length]=G,h[h.length]=q)}}}}}return iTe(f,d,m,h)}function iTe(e,t,r,n){for(var a=new Mi.DirectedEdgeBuilder(e,t,r),i=new Float32Array(a.slotCount),o=0,s=a.edgeCount;o0&&(t.secondStart-e.secondEnd<6&&t.firstStart-e.firstEnd<3||t.secondStart-e.secondEnd<3)}function $Y(e){for(var t=e.bridges,r=e.ladders,n=0;nm||(s=c+1,u=m,s!==u&&r.getDirectedEdgeIndex(u,s+1)!==-1&&(n[s]|=2,n[u]|=2,a[a.length]=new xx(s,u,0)),s=c,u=m-1,s!==u&&r.getDirectedEdgeIndex(u-1,s)!==-1&&(n[s]|=2,n[u]|=2,a[a.length]=new xx(u,s,0)),s=c,u=m,s!==u&&r.getDirectedEdgeIndex(u,s)!==-1&&(n[s]|=2,n[u]|=2,a[a.length]=new xx(u,s,1)),s=c+1,u=m-1,s!==u&&r.getDirectedEdgeIndex(u-1,s+1)!==-1&&(n[s]|=2,n[u]|=2,a[a.length]=new xx(u,s,1)))}a.sort(function(h,p){return h.partner1>p.partner1?1:h.partner10&&bTe(a,s,i,l),Ew(l.type,l.key,l.elements,c)}e.fromStruct=t})(Hl||(Hl={}));function hTe(e,t){if(e._rowCount>0){if(e.beg_label_seq_id.valueKind(0)!==0||e.end_label_seq_id.valueKind(0)!==0)return"auth"}else if(t&&(t.beg_label_seq_id.valueKind(0)!==0||t.end_label_seq_id.valueKind(0)!==0))return"auth";return"label"}function vTe(e,t,r,n){if(e._rowCount)for(var a=e.beg_label_asym_id,i=e.beg_label_seq_id,o=e.beg_auth_seq_id,s=e.pdbx_beg_PDB_ins_code,u=e.end_label_seq_id,c=e.end_auth_seq_id,l=e.pdbx_end_PDB_ins_code,f=e.pdbx_PDB_helix_class,d=e.conf_type_id,m=e.details,h=t==="label"?i:o,p=t==="label"?u:c,v=0,g=e._rowCount;vl||v===l&&c.value(p)===f)break;p++}}function bTe(e,t,r,n){for(var a=e.chainAtomSegments.count,i=e.chains.label_asym_id,o=e.residues,s=o.auth_seq_id,u=o.label_seq_id,c=o.pdbx_PDB_ins_code,l=t==="label"?u:s,f=0;fr&&(r=l)}}return e.throwIfTimedOut(),r}function BTe(e,t){return function(n){var a=e(n);if(t.elementRadius){var i=P(P({},t),{elementRadius:t.elementRadius,elementRadiusClosure:MTe(n,t.elementRadius),sourceMaxRadius:RTe(n,t.elementRadius)});if(st.isSingleton(a)){var o=vX(n,n.inputStructure,a.structure,i),s=st.Singletons(n.inputStructure,o);return s}else{for(var u=new Aw(n.inputStructure),c=0,l=a.structures;c=0){T.addElementRange(v,x.start,x.end);continue}if(d.hasLabelAsymId(S))for(b.setSegment(x);b.hasNext;){var D=b.move();l.element=v[D.start],d.has(l)&&T.addElementRange(v,D.start,D.end)}}T.commitUnit(),i.throwIfTimedOut()}}var I=Ud(i.inputStructure,[T.getStructure(),o]);if(n){for(var R=new yx(i.inputStructure),B=i.inputStructure.lookup3d,O=0,z=I.units;O0;){var s=o.pop();a.add(s);for(var u=this.vertices.get(s),c=0,l=this.edges.get(s);cQTe,first:()=>XTe,getCurrentStructureProperties:()=>Cx,isConnectedTo:()=>nAe,pick:()=>YTe,withSameAtomProperties:()=>ZTe,within:()=>$Te});function yX(e,t,r,n,a,i){return t.elementCount===0||r.elementCount===0?!0:t.elementCount<=r.elementCount?Rw.check(e,t,r,n,a,i):Rw.check(e,r,t,n,a,i)}function bX(e,t,r,n,a){return t.elementCount===0||r.elementCount===0?!0:t.elementCount<=r.elementCount?Bw.check(e,t,r,n,a):Bw.check(e,r,t,n,a)}var Rw;(function(e){var t=y.zero();function r(o,s,u,c,l,f,d){var m=s.elements,h=s.conformation.position,p=t;o.element.unit=s;for(var v=!1,g=0,b=m.length;g0){var a=r.structure.units[0],i=Le.create([a.getChild(Fe.ofSingleton(a.elements[0]))],{parent:t.inputStructure});n.add(i)}}else r.structures.length>0&&n.add(r.structures[0]);return n.getSelection()}}function Cx(e,t,r){var n=e.currentStructure.units,a=e.pushCurrentElement();a.structure=e.currentStructure;for(var i=0,o=n;i"u"?JTe(r):r.minRadius===0?eAe(r):tAe(r)}}function JTe(e){var t=e.queryCtx,r=e.selection,n=e.target,a=e.maxRadius,i=e.invert,o=st.unionStructure(n).lookup3d,s=st.LinearBuilder(t.inputStructure),u=y.zero();return st.forEach(r,function(c,l){for(var f=c.units,d=!1,m=0,h=f.length;miAe,merge:()=>aAe});function aAe(e){return e.length===0?Dw:e.length===1?e[0]:function(t){for(var r=st.UniqueBuilder(t.inputStructure),n=function(i){st.forEach(e[i](t),function(o,s){r.add(o),i%100&&t.throwIfTimedOut()})},a=0;aoAe,countQuery:()=>sAe,propertySet:()=>uAe});function oAe(e){return e.currentStructure.elementCount}function sAe(e){return function(t){var r=e(t);return st.structureCount(r)}}function uAe(e){return function(t){var r=new Set;return Cx(t,e,r)}}var Ow;(function(e){function t(d){return!!d&&!!d.has}function r(d,m){return function(h){return d(h)===m}}e.eq=r;function n(d,m){return function(h){return d(h)m}}e.gt=i;function o(d,m){return function(h){return d(h)>=m}}e.gte=o;function s(d){return!0}function u(d){return!1}function c(d,m){if(t(m))return function(v){return m.has(d(v))};if(m.length===0)return u;for(var h=new Set,p=0;p=0&&t[1]<=0&&r[1]>=0&&t[2]<=0&&r[2]>=0&&(s[0]=$i.getSymmetryOperator(a,0,0,0,0));for(var u=0;u0?[]:this.currentUnit},e.prototype.addElement=function(t){this.currentUnit[this.currentUnit.length]=t,this.elementCount++},e.prototype.addElementRange=function(t,r,n){for(var a=r;a1&&ho(u);var f=s.getChild(Fe.ofSortedArray(u)),d=n.add(f.id,f);f!==d&&(f=d.applyOperator(f.id,f.conformation.operator,!0)),r[r.length]=f}return Le.create(r,{parent:this.parent})},e.prototype.getStructure=function(){return this._getStructure(!1)},e.prototype.getStructureDeduplicate=function(){return this._getStructure(!0)},e.prototype.setSingletonLocation=function(t){var r=this.ids[0];t.unit=this.parent.unitMap.get(r),t.element=this.unitMap.get(r)[0]},Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.elementCount===0},enumerable:!1,configurable:!0}),e}();function wX(e,t){for(var r=1;t--;)r*=e--;return r}function pAe(e,t){return t>e?0:wX(e,t)/wX(t,t)}function hAe(e){var t=e&-e,r=e+t,n=r&-r,a=(n/t>>1)-1;return r|a}var vAe=function(){function e(t,r){this.array=t,this.hasNext=!1,this.index=(1<0&&r<=t.length}return e.prototype.move=function(){if(this.hasNext){for(var t=0,r=0,n=this.index;n;n>>>=1,t++)n&1&&(this.value[r++]=this.array[t]);this.index=hAe(this.index),this.hasNext=this.index0&&ge.length>0)for(var Pe=K.length,Ie=ge.length,ke=0,Ne=Math.max(Pe,Ie);ke500?wAe:TAe}function PX(e){var t=e.units,r=AAe(t.length);r.reset();for(var n=0,a=t.length;n0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"customPropertyDescriptors",{get:function(){return this.state.customProps||(this.state.customProps=new eo),this.state.customProps},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentPropertyData",{get:function(){return this.state.propertyData||(this.state.propertyData=Object.create(null)),this.state.propertyData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"inheritedPropertyData",{get:function(){return this.parent?this.parent.currentPropertyData:this.currentPropertyData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"polymerResidueCount",{get:function(){return this.state.polymerResidueCount===-1&&(this.state.polymerResidueCount=OAe(this)),this.state.polymerResidueCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"polymerGapCount",{get:function(){return this.state.polymerGapCount===-1&&(this.state.polymerGapCount=FAe(this)),this.state.polymerGapCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"polymerUnitCount",{get:function(){return this.state.polymerUnitCount===-1&&(this.state.polymerUnitCount=LAe(this)),this.state.polymerUnitCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uniqueElementCount",{get:function(){return this.state.uniqueElementCount===-1&&(this.state.uniqueElementCount=BAe(this)),this.state.uniqueElementCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"atomicResidueCount",{get:function(){return this.state.atomicResidueCount===-1&&(this.state.atomicResidueCount=kAe(this)),this.state.atomicResidueCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCoarseGrained",{get:function(){return this.models.some(function(t){return Vt.isCoarseGrained(t)})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.units.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hashCode",{get:function(){return this.state.hashCode!==-1?this.state.hashCode:this.computeHash()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transformHash",{get:function(){return this.state.transformHash!==-1?this.state.transformHash:(this.state.transformHash=ga(this.units.map(function(t){return t.id})),this.state.transformHash)},enumerable:!1,configurable:!0}),e.prototype.computeHash=function(){for(var t=23,r=0,n=this.units.length;r1)throw new Error("The structure is based on multiple models and has neither a master- nor a representative-model.");return this.state.model=t[0],this.state.model},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"masterModel",{get:function(){return this.state.masterModel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"representativeModel",{get:function(){return this.state.representativeModel},enumerable:!1,configurable:!0}),e.prototype.hasElement=function(t){return this.unitMap.has(t.unit.id)?Fe.has(this.unitMap.get(t.unit.id).elements,t.element):!1},e.prototype.getModelIndex=function(t){return this.models.indexOf(t)},e.prototype.remapModel=function(t){for(var r=this.state,n=r.dynamicBonds,a=r.interUnitBonds,i=r.parent,o=[],s=0,u=this.unitSymmetryGroups;s0&&(r+=1);return r}function kAe(e){for(var t=e.units,r=0,n=0,a=t.length;n0?H[0].id:0,re=0,te=H.length;re2e5||d(H,re)?p(H,Ie,de,De,te):de.addUnit(0,H,te,Ie,De?Te.Trait.MultiChain:Te.Trait.None):de.addUnit(0,H,te,Ie,De?Te.Trait.MultiChain:Te.Trait.None)}var ke=H.coarseHierarchy;return ke.isDefined&&(ke.spheres.count>0&&v(de,H,H.coarseHierarchy.spheres,1),ke.gaussians.count>0&&v(de,H,H.coarseHierarchy.gaussians,2)),de.getStructure()}e.ofModel=f;function d(H,N){var ee=H.atomicHierarchy.index.getEntityFromChain(N);return H.entities.data.type.value(ee)==="water"}function m(H,N){var ee=H.atomicHierarchy.index.getEntityFromChain(N);return H.entities.data.type.value(ee)==="polymer"}function h(H,N,ee,oe,me){var pe=H.atomicConformation,de=pe.x,re=pe.y,te=pe.z,fe={x:de,y:re,z:te,indices:N},ve=Ks(fe,Iu(fe),8192),De=ve.buckets,Ge=De.offset,Ke=De.count,L=De.array,K=(oe?Te.Trait.MultiChain:Te.Trait.None)|(Ge.length>1?Te.Trait.Partitioned:Te.Trait.None);ee.beginChainGroup();for(var ge=0,Pe=Ge.length;ge1?Te.Trait.Partitioned:Te.Trait.None);ee.beginChainGroup();for(var Re=0,je=ke.length;Re0,this.hasNext&&(this.elements=N.units[0].elements,this.maxIdx=this.elements.length-1,this.current.unit=N.units[0])}return H.prototype.move=function(){return this.advance(),this.current.element=this.elements[this.idx],this.current},H.prototype.advance=function(){if(this.idx=this.structure.units.length){this.hasNext=!1;return}this.current.unit=this.structure.units[this.unitIndex],this.elements=this.current.unit.elements,this.maxIdx=this.elements.length-1,this.maxIdx===0&&(this.hasNext=this.unitIndex+1=L.id||!me(L)||!pe(ve,L)||(L.elements.length>=ve.elements.length?N(ve,L):N(L,ve))}}}}e.eachUnitPair=Q;function W(H,N){for(var ee=N.chain,oe=N.residue,me=N.atom,pe=ie.Location.create(H),de=0,re=H.units;de0})}function ae(H,N){var ee=X(H);return ee.length===1&&ee[0].units.length>2&&ee[0].units[0].polymerElements.length=1&&ee[0].units.length>N.highSymmetryUnitCount}var F;(function(H){H[H.Small=0]="Small",H[H.Medium=1]="Medium",H[H.Large=2]="Large",H[H.Huge=3]="Huge",H[H.Gigantic=4]="Gigantic"})(F=e.Size||(e.Size={}));function j(H,N,ee){N===void 0&&(N={}),ee===void 0&&(ee=1);var oe=P(P({},e.DefaultSizeThresholds),N);return H.polymerResidueCount>=oe.largeResidueCount*ee?q(H,oe)?F.Huge:F.Gigantic:ae(H,oe)||H.polymerResidueCount0)return!1}return!0}e.isEmpty=n;function a(Y){return i(Y)===Y.structure.elementCount}e.isWholeStructure=a;function i(Y){for(var H=0,N=0,ee=Y.elements;N0&&N.push({unit:oe,indices:me})}}),e(H,N)}e.remap=h;function p(Y,H){if(Y.elements.length>H.elements.length)return p(H,Y);if(e.isEmpty(Y))return H;for(var N=new Map,ee=0,oe=Y.elements;eeH.elements.length)return b(H,Y);if(e.isEmpty(Y))return e.isEmpty(H);for(var N=new Map,ee=0,oe=Y.elements;ee3&&Fe.isRange(Y)?Se.ofRange(Y[0],Y[Y.length-1]):Fe.ofSortedArray(Y)}function _(Y,H){for(var N=[],ee=new Set,oe=0,me=Y.elements;oe=0){var Re=te.value(Ne);(!H||ke||!Re||ee.has(Re))&&(Ge[Ge.length]=et)}}}N[N.length]={unit:pe.unit,indices:S(Ge)}}else N[N.length]=pe}return e(Y.structure,N)}e.extendToWholeResidues=_;function C(Y){switch(Y.kind){case 0:return Y.model.atomicHierarchy.chainAtomSegments;case 1:return Y.model.coarseHierarchy.spheres.chainElementSegments;case 2:return Y.model.coarseHierarchy.gaussians.chainElementSegments}}function D(Y){return Y.unit.elements.length===Ee.size(Y.indices)}function T(Y,H,N){for(var ee=C(Y).index,oe=Y.elements,me=0,pe=0,de=oe.length;pe0&&(N[N.length]={unit:Y,indices:S(fe)})}function A(Y,H,N,ee,oe){for(var me=C(Y.elements[0].unit).index,pe=new Set,de=H;de1,pe.modelLabel,pe.modelIndex))}for(var ge=new Map,ve=0,Pe=Ke.length;ve0&&(xt[xt.length]=le.core.set.has([le.core.type.set(je),ct]));for(var _t=0,Ue=Re.length/2;_t1?le.core.logic.or(xt):xt[0],"chain-test":tt.length>1?le.core.set.has([le.core.type.set(tt),ht]):le.core.rel.eq([ht,tt[0]]),"entity-test":le.core.logic.and([le.core.rel.eq([le.struct.atomProperty.core.modelLabel(),Ct]),le.core.rel.eq([le.struct.atomProperty.core.modelIndex(),bt])])}))}else Ne.push(le.struct.generator.atomGroups({"atom-test":xt.length>1?le.core.logic.or(xt):xt[0],"chain-test":tt.length>1?le.core.set.has([le.core.type.set(tt),ht]):le.core.rel.eq([ht,tt[0]])}))}),le.struct.modifier.union([Ne.length===1?Ne[0]:le.struct.combinator.merge(Ne.map(function(Ve){return le.struct.modifier.union([Ve])}))])}e.toExpression=j;function Z(Y,H,N,ee,oe){ho(H);for(var me=[],pe=[],de=0,re=H.length;de12)me[me.length]=H[te],me[me.length]=H[fe-1];else for(var ve=te;ve0&&Mn.set(u.firstElementLoc,c,d,m[Ee.start(f)]),h===m.length)u.unitCount+=1,u.unitCount===1&&Mn.set(u.firstUnitLoc,c,d,m[Ee.start(f)]);else if(h===1){if(Te.Traits.is(d.traits,Te.Trait.MultiChain))return;u.elementCount+=1,u.elementCount===1&&Mn.set(u.firstElementLoc,c,d,m[Ee.start(f)])}else if(Te.isAtomic(d))for(var g=d.model.atomicHierarchy.residueAtomSegments,b=g.index,x=g.offsets,S=d.model.atomicHierarchy.atoms.label_alt_id,_=0,C=function(){p.clear();var D=0,T=m[Ee.getAt(f,_)],A=b[T];for(r(p,S.value(T),1),++_,++D;_"u"?1:0},gB=function(e,t){return t[e].operator.spgrOp===-1?1:0},mwt=Rn.fields().str("label_asym_id",function(e,t){return t[e].label_asym_id}).str("auth_asym_id",function(e,t){return t[e].auth_asym_id}).str("operator_name",function(e,t){return t[e].operator.name}).str("suffix",function(e,t){return t[e].operator.suffix}).str("assembly_id",function(e,t){var r;return((r=t[e].operator.assembly)===null||r===void 0?void 0:r.id)||""},{valueKind:jX}).int("assembly_operator_id",function(e,t){var r;return((r=t[e].operator.assembly)===null||r===void 0?void 0:r.operId)||0},{valueKind:jX}).int("symmetry_operator_index",function(e,t){return t[e].operator.spgrOp},{valueKind:gB}).vec("symmetry_hkl",[function(e,t){return t[e].operator.hkl[0]},function(e,t){return t[e].operator.hkl[1]},function(e,t){return t[e].operator.hkl[2]}],{valueKind:gB}).int("ncs_id",function(e,t){return t[e].operator.ncsId},{valueKind:gB}).getFields();var tDe=Rn.Category,WX;(function(e){function t(r){var n=Array.isArray(r)?r:[r];return{structures:n,firstModel:n[0].model,cache:Object.create(null)}}e.create=t})(WX||(WX={}));var rDe={name:"entity",instance:function(e){var t=e.structures,r=hB(t);return tDe.ofTable(t[0].model.entities.data,r)}};function bB(e){return e.units.every(function(t){return t.conformation.operator.isIdentity})}function yB(e){return bB(e)&&e.units.every(function(t){return!t.conformation.operator.assembly&&!t.conformation.operator.suffix})}var Awt=[lc("entry"),lc("exptl"),rDe,lc("cell",bB),lc("symmetry",bB),lc("pdbx_struct_assembly",yB),lc("pdbx_struct_assembly_gen",yB),lc("pdbx_struct_oper_list",yB),RX,BX,GX,zX,HX,lc("pdbx_entity_branch"),lc("pdbx_entity_branch_link"),lc("pdbx_branch_scheme"),lc("struct_conn"),LX,kX,NX,lc("atom_sites"),UX,MX],YX;(function(e){e.AtomSitePositionsFieldNames=new Set(["id","Cartn_x","Cartn_y","Cartn_z"])})(YX||(YX={}));var XX;(function(e){function t(f,d,m){if(!d)return{rowCount:0};if(m&&m[d.id])return m[d.id];var h=d.getElements(f),p={data:h,rowCount:h.elements.length};return m&&(m[d.id]=p),p}e.getCifDataSource=t;function r(f){return new KX(f)}e.fromAtomMap=r;function n(f){return new KX(xB(f))}e.fromAtomArray=n;var a=function(f){return f.atomicHierarchy.residueAtomSegments};function i(f){return new kw("residue",f,a,0)}e.fromResidueMap=i;function o(f){return new kw("residue",xB(f),a,0)}e.fromResidueArray=o;var s=function(f){return f.atomicHierarchy.chainAtomSegments};function u(f){return new kw("chain",f,s,0)}e.fromChainMap=u;function c(f){return new kw("chain",xB(f),s,0)}e.fromChainArray=c;function l(f){return new nDe(f)}e.fromEntityMap=l})(XX||(XX={}));function xB(e){for(var t=new Map,r=0,n=e.length;r0)for(var c=parseInt(s.substring(0,u)),l=parseInt(s.substr(u+1)),f=c;f<=l;f++)o[o.length]=f.toString();else o[o.length]=s.trim()}),n[n.length]=o}),n}var jn;(function(e){e.Descriptor={name:"model_symmetry"},e.Provider=yo.create(e.Descriptor);function t(n){var a=ZX(n.pdbx_struct_assembly,n.pdbx_struct_assembly_gen,n.pdbx_struct_oper_list),i=dDe(n.symmetry,n.cell),o=lDe(n.atom_sites,i);return{assemblies:a,spacegroup:i,isNonStandardCrystalFrame:o,ncsOperators:mDe(n.struct_ncs_oper)}}e.fromData=t;function r(n,a){var i=Va.create("P 1",n,a),o=$i.create(i);return{assemblies:[],spacegroup:o,isNonStandardCrystalFrame:!1}}e.fromCell=r})(jn||(jn={}));function lDe(e,t){return e._rowCount===0,!1}function fDe(e){var t=e.Int_Tables_number.value(0),r=e["space_group_name_H-M"].value(0);return e.Int_Tables_number.isDefined?e["space_group_name_H-M"].isDefined?r:t:r}function dDe(e,t){if(e._rowCount===0||t._rowCount===0)return $i.ZeroP1;var r=t.length_a.value(0),n=t.length_b.value(0),a=t.length_c.value(0);if(r===0||n===0||a===0)return $i.ZeroP1;var i=t.angle_alpha.value(0),o=t.angle_beta.value(0),s=t.angle_gamma.value(0);if(i===0||o===0||s===0)return $i.ZeroP1;var u=fDe(e),c=Va.create(u,y.create(r,n,a),y.scale(y(),y.create(i,o,s),Math.PI/180));return $i.create(c)}function mDe(e){if(e._rowCount!==0){for(var t=e.id,r=e.matrix,n=e.vector,a=Pr.struct_ncs_oper.matrix.space,i=Pr.struct_ncs_oper.vector.space,o=[],s=0;s0}e.hasData=o;function s(u,c){u.writeCategory({name:r,instance:function(){var l=ar.ofRows(e.Schema.molstar_global_model_transform_info,[{matrix:c}]);return Rn.Category.ofTable(l)}})}e.writeMmCif=s})(Gf||(Gf={}));function hDe(e){if(Vr.is(e.sourceData))return jn.fromData(e.sourceData.data.db)}jn.Provider.formatRegistry.add("mmCIF",hDe);function vDe(e){if(Vr.is(e.sourceData)){var t=e.sourceData.data.db,r=t.struct_conf,n=t.struct_sheet_range;return Hl.fromStruct(r,n,e.atomicHierarchy)}}Hl.Provider.formatRegistry.add("mmCIF",vDe);function gDe(e){if(Vr.is(e.sourceData)){var t=e.sourceData.data.db.atom_site_anisotrop,r=ar.ofColumns(Mu.Schema,t),n=Mu.getElementToAnsiotrop(e.atomicConformation.atomId,t.id);return{data:r,elementToAnsiotrop:n}}}function yDe(e){return Vr.is(e.sourceData)?e.sourceData.data.db.atom_site_anisotrop.U.isDefined:!1}Mu.Provider.formatRegistry.add("mmCIF",gDe,yDe);function bDe(e){if(Vr.is(e.sourceData)){var t=e.sourceData.data.db.chem_comp_bond;if(t._rowCount!==0)return{data:t,entries:Nd.getEntriesFromChemCompBond(t)}}}Nd.Provider.formatRegistry.add("mmCIF",bDe);function xDe(e){if(Vr.is(e.sourceData)){var t=e.sourceData.data.db.struct_conn;if(t._rowCount!==0){var r=bs.getEntriesFromStructConn(t,e);return{data:t,byAtomIndex:bs.getAtomIndexFromEntries(r),entries:r}}}}bs.Provider.formatRegistry.add("mmCIF",xDe);Gf.Provider.formatRegistry.add("mmCIF",Gf.fromMmCif,Gf.hasData);var Vr;(function(e){function t(n){return n?.kind==="mmCIF"}e.is=t;function r(n,a,i,o){return a||(a=Es.schema.mmCIF(n)),{kind:"mmCIF",name:a._name,data:{db:a,file:o,frame:n,source:i}}}e.fromFrame=r})(Vr||(Vr={}));function Nw(e,t){var r=Vr.fromFrame(e,void 0,void 0,t),n=Ii(r.data.db,!0);return Ce.create("Create mmCIF Model",function(a){return Io(n,r,a)})}var Tx;(function(e){var t="__CcdCoordinateType__";e.CoordinateType={get:function(a){return a._staticPropertyData[t]},set:function(a,i){return a._staticPropertyData[t]=i}};function r(a){return a?.kind==="CCD"}e.is=r;function n(a,i){return i||(i=Es.schema.CCD(a)),{kind:"CCD",name:i._name,data:{db:i,frame:a}}}e.fromFrame=n})(Tx||(Tx={}));function JX(e){var t=Tx.fromFrame(e);return Ce.create("Create CCD Models",function(r){return SDe(t.data.db,Tx.fromFrame(e),r)})}function SDe(e,t,r){return $(this,void 0,void 0,function(){var n,a,i,o,s;return J(this,function(u){switch(u.label){case 0:return[4,$X(e,t,{coordinateType:"ideal",cartn_x:"pdbx_model_Cartn_x_ideal",cartn_y:"pdbx_model_Cartn_y_ideal",cartn_z:"pdbx_model_Cartn_z_ideal"},r)];case 1:return n=u.sent(),[4,$X(e,t,{coordinateType:"model",cartn_x:"model_Cartn_x",cartn_y:"model_Cartn_y",cartn_z:"model_Cartn_z"},r)];case 2:for(a=u.sent(),i=[],n&&i.push(n),a&&i.push(a),o=0,s=i.length;o0||(x[x.length]=S);return _=x.length,C=ne.ofConst("A",_,ne.Schema.str),D=ne.ofConst(1,_,ne.Schema.int),T=ne.ofConst("1",_,ne.Schema.str),A=ne.ofConst(1,_,ne.Schema.float),E=ne.ofConst(1,_,ne.Schema.int),I=ne.view(m,x),R=ne.view(p,x),B=ne.view(i[u],x),O=ne.view(i[c],x),z=ne.view(i[l],x),k=ne.view(v,x),G=ne.view(g,x),V=ne.view(h,x),U=ar.ofPartialColumns(ta.atom_site,{auth_asym_id:C,auth_atom_id:I,auth_comp_id:R,auth_seq_id:D,Cartn_x:B,Cartn_y:O,Cartn_z:z,id:k,label_asym_id:C,label_atom_id:I,label_comp_id:R,label_seq_id:D,label_entity_id:T,occupancy:A,type_symbol:G,pdbx_PDB_model_num:E,pdbx_formal_charge:V},_),Q=new ji,Q.setNames([[d,"".concat(f," (").concat(s,")")]]),Q.getEntityId(d,0,"A"),W=new Hi(D,g),W.setNames([[d,"".concat(f," (").concat(s,")")]]),W.add(d,0),X=Ii({entity:Q.getEntityTable(),chem_comp:W.getChemCompTable(),atom_site:U}),[4,Io(X,t,n)];case 1:return ae=j.sent(),ae.representative?(q=ae.representative,F=Nd.getEntriesFromChemCompBond(o),Nd.Provider.set(q,{data:o,entries:F}),Tx.CoordinateType.set(q,s),[2,ae.representative]):[2]}})})}var Vt;(function(e){function t(k,G){for(var V=[],U=G.frames,Q=k.atomicHierarchy.atomSourceIndex,W=ne.isIdentity(Q),X=W?void 0:Q.toArray({array:Int32Array}),ae=p(k),q=k.atomicHierarchy.atoms._rowCount,F=0,j=U.length;F0}e.hasCarbohydrate=v;function g(k){for(var G=k.entities.subtype,V=0,U=G.rowCount;V=0)return!0}return!1}e.isFromXray=A;function E(k){if(!Vr.is(k.sourceData))return!1;for(var G=k.sourceData.data.db,V=0;V=0)return!0}return!1}e.isFromEm=E;function I(k){if(!Vr.is(k.sourceData))return!1;for(var G=k.sourceData.data.db,V=0;V=0)return!0}return!1}e.isFromNmr=I;function R(k){if(!Vr.is(k.sourceData)||!A(k))return!1;var G=k.sourceData.data.db,V=G.pdbx_database_status.status_code_sf;return V.isDefined&&V.value(0)==="REL"}e.hasXrayMap=R;function B(k){if(!Vr.is(k.sourceData))return!1;for(var G=k.sourceData.data.db,V=G.pdbx_database_related,U=V.db_name,Q=V.content_type,W=0,X=G.pdbx_database_related._rowCount;W=s?s:i},e.prototype.findAtom=function(t){var r=this.findResidue(t);return r<0?-1:typeof t.label_alt_id>"u"?SB(this.residueOffsets[r],this.residueOffsets[r+1],this.map.label_atom_id,t.label_atom_id):CB(this.residueOffsets[r],this.residueOffsets[r+1],this.map.label_atom_id,this.map.label_alt_id,t.label_atom_id,t.label_alt_id)},e.prototype.findAtomAuth=function(t){var r=this.findResidueAuth(t);return r<0?-1:typeof t.label_alt_id>"u"?SB(this.residueOffsets[r],this.residueOffsets[r+1],this.map.auth_atom_id,t.auth_atom_id):CB(this.residueOffsets[r],this.residueOffsets[r+1],this.map.auth_atom_id,this.map.label_alt_id,t.auth_atom_id,t.label_alt_id)},e.prototype.findAtomOnResidue=function(t,r,n){return typeof n>"u"?SB(this.residueOffsets[t],this.residueOffsets[t+1],this.map.label_atom_id,r):CB(this.residueOffsets[t],this.residueOffsets[t+1],this.map.label_atom_id,this.map.label_alt_id,r,n)},e.prototype.findAtomsOnResidue=function(t,r){return ADe(this.residueOffsets[t],this.residueOffsets[t+1],this.map.label_atom_id,r)},e.prototype.findElementOnResidue=function(t,r){return DDe(this.residueOffsets[t],this.residueOffsets[t+1],this.map.type_symbol,r)},e}();function SB(e,t,r,n){for(var a=e;a=u[c+1]&&(c+=1,l=0),o[f]=++l;a.label_seq_id=ne.ofIntArray(o)}return ar.columnToArray(a,"label_seq_id",Int32Array),ar.columnToArray(a,"auth_seq_id",Int32Array),{atoms:n,residues:a,chains:i,atomSourceIndex:t}}function IDe(e){return{id:Er.create22(),atomId:e.id,occupancy:e.occupancy.isDefined?e.occupancy:ne.ofConst(1,e._rowCount,ne.Schema.float),B_iso_or_equiv:e.B_iso_or_equiv,xyzDefined:e.Cartn_x.isDefined&&e.Cartn_y.isDefined&&e.Cartn_z.isDefined,x:e.Cartn_x.toArray({array:Float32Array}),y:e.Cartn_y.toArray({array:Float32Array}),z:e.Cartn_z.toArray({array:Float32Array})}}function MDe(e,t){return ar.areEqual(e.chains,t.chains)&&ar.areEqual(e.residues,t.residues)&&ar.areEqual(e.atoms,t.atoms)}function RDe(e,t){var r=new Map;if(!Vr.is(t))return r;var n=Bc(qX,t.data.frame).molstar_atom_site_operator_mapping;if(n._rowCount===0)return r;for(var a=new Map,i=new Map,o=0;o1&&(r.push(l,d-1),n.push(d-1,d),l=d),d===c-1&&r.push(l,d),f=m}return{polymerRanges:Wr.ofSortedRanges(r),gapRanges:Wr.ofSortedRanges(n)}}var DB={hierarchy:wB.Empty,conformation:void 0};function aK(e,t){var r=e.ihm_sphere_obj_site,n=e.ihm_gaussian_obj_site;if(r._rowCount===0&&n._rowCount===0)return DB;var a=nK(r),i=NDe(r),o=TB(a,e.entities),s=AB(a,t),u=nK(n),c=UDe(n),l=TB(u,e.entities),f=AB(u,t);return{hierarchy:{isDefined:!0,spheres:P(P(P({},a),o),s),gaussians:P(P(P({},u),l),f)},conformation:{id:Er.create22(),spheres:i,gaussians:c}}}function NDe(e){return{x:e.Cartn_x.toArray({array:Float32Array}),y:e.Cartn_y.toArray({array:Float32Array}),z:e.Cartn_z.toArray({array:Float32Array}),radius:e.object_radius.toArray({array:Float32Array}),rmsf:e.rmsf.toArray({array:Float32Array})}}function UDe(e){for(var t=ta.ihm_gaussian_obj_site.covariance_matrix.space,r=[],n=e.covariance_matrix,a=0,i=n.rowCount;a0)for(var r=e.chem_comp.id,n=0,a=r.rowCount;n0){for(var r=e.pdbx_chem_comp_identifier,n=r.comp_id,a=r.type,i=r.identifier,o=0,s=n.rowCount;o0)for(var l=e.chem_comp,f=l.id,a=l.type,o=0,s=f.rowCount;o0?[4,qDe(r,e,n,t)]:[3,2];case 1:return i=s.sent(),[3,4];case 2:return[4,jDe(r,e,n,t)];case 3:i=s.sent(),s.label=4;case 4:for(a=i,o=0;o0?a[a.length-1]:void 0),a.push(d),s=u,[3,1];case 3:return[2,a]}})})}function OB(e,t){for(var r=new Map,n=e._rowCount,a=0;a=66?We.addToken(e.B_iso_or_equiv,at.trim(r,n+60,n+66)):We.add(e.B_iso_or_equiv,0,0),i&&We.addToken(e.partial_charge,at.trim(r,n+70,n+76)),s>=78&&!i?(at.trim(r,n+76,n+78),r.tokenStart=78?(at.trim(r,n+76,n+78),r.tokenStartI||T[I]===void 0&&(u.push("covale".concat(_)),c.push("covale"),l.push(n.label_asym_id.str(D)),f.push(n.auth_seq_id.int(D)),d.push(n.label_atom_id.str(D)),m.push(n.label_alt_id.str(D)),h.push(n.pdbx_PDB_ins_code.str(D)),p.push(n.label_asym_id.str(I)),v.push(n.auth_seq_id.int(I)),g.push(n.label_atom_id.str(I)),b.push(n.label_alt_id.str(I)),x.push(n.pdbx_PDB_ins_code.str(I)),_+=1))}}}var R={id:dt.ofStrings(u),conn_type_id:dt.ofStrings(c),ptnr1_label_asym_id:dt.ofStrings(l),ptnr1_auth_seq_id:dt.ofNumbers(f),ptnr1_label_atom_id:dt.ofStrings(d),pdbx_ptnr1_label_alt_id:dt.ofStrings(m),pdbx_ptnr1_PDB_ins_code:dt.ofStrings(h),ptnr2_label_asym_id:dt.ofStrings(p),ptnr2_auth_seq_id:dt.ofNumbers(v),ptnr2_label_atom_id:dt.ofStrings(g),pdbx_ptnr2_label_alt_id:dt.ofStrings(b),pdbx_ptnr2_PDB_ins_code:dt.ofStrings(x)};return Za.ofFields("struct_conn",R)}function DK(e,t,r,n){var a=e.substring(t,r);n.id_code=a.substring(62,66).trim()||void 0,n.dep_date=a.substring(50,59).trim()||void 0,n.classification=a.substring(10,50).trim()||void 0}function PK(e){return $(this,void 0,void 0,function(){var t,r,n,a,i,o,s,z,x,S,_,u,c,l,f,d,m,h,p,v,g,b,z,x,S,_,C,C,C,C,C,C,C,D,T,A,E,I,R,B,O,z,k,G,V,U,Q,W,X,ae;return J(this,function(q){for(t=e.lines,r=t.data,n=t.indices,a=at(r),i=!!e.isPdbqt,o=0,s=0,z=0,x=t.count;z"),it(be.core.rel.gre,"gre",">="),it(be.core.rel.inRange,"in-range"),it(be.core.str.concat,"concat"),it(be.core.str.match,"regex.match"),it(be.core.list.getAt,"list.get"),it(be.core.set.has,"set.has"),it(be.core.set.isSubset,"set.subset")],["Structure",["Types",it(be.structureQuery.type.entityType,"ent-type"),it(be.structureQuery.type.authResidueId,"auth-resid"),it(be.structureQuery.type.labelResidueId,"label-resid"),it(be.structureQuery.type.ringFingerprint,"ringfp"),it(be.structureQuery.type.bondFlags,"bond-flags")],["Slots",it(be.structureQuery.slot.elementSetReduce,"atom.set.reduce.value")],["Generators",it(be.structureQuery.generator.atomGroups,"sel.atom.atom-groups"),it(be.structureQuery.generator.queryInSelection,"sel.atom.query-in-selection"),it(be.structureQuery.generator.rings,"sel.atom.rings"),it(be.structureQuery.generator.empty,"sel.atom.empty"),it(be.structureQuery.generator.all,"sel.atom.all"),it(be.structureQuery.generator.bondedAtomicPairs,"sel.atom.bonded-pairs"),Vw(hv("sel.atom.atoms",zt.Dictionary({0:lt(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test applied to each atom."})}),Pt.ElementSelection,"A selection of singleton atom sets."),function(e){return le.struct.generator.atomGroups({"atom-test":Uw(e,0,!0)})}),Vw(hv("sel.atom.res",zt.Dictionary({0:lt(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test applied to the 1st atom of each residue."})}),Pt.ElementSelection,"A selection of atom sets grouped by residue."),function(e){return le.struct.generator.atomGroups({"residue-test":Uw(e,0,!0),"group-by":le.ammp("residueKey")})}),Vw(hv("sel.atom.chains",zt.Dictionary({0:lt(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test applied to the 1st atom of each chain."})}),Pt.ElementSelection,"A selection of atom sets grouped by chain."),function(e){return le.struct.generator.atomGroups({"chain-test":Uw(e,0,!0),"group-by":le.ammp("chainKey")})})],["Modifiers",it(be.structureQuery.modifier.queryEach,"sel.atom.query-each"),it(be.structureQuery.modifier.intersectBy,"sel.atom.intersect-by"),it(be.structureQuery.modifier.exceptBy,"sel.atom.except-by"),it(be.structureQuery.modifier.unionBy,"sel.atom.union-by"),it(be.structureQuery.modifier.union,"sel.atom.union"),it(be.structureQuery.modifier.cluster,"sel.atom.cluster"),it(be.structureQuery.modifier.includeSurroundings,"sel.atom.include-surroundings"),it(be.structureQuery.modifier.surroundingLigands,"sel.atom.surrounding-ligands"),it(be.structureQuery.modifier.includeConnected,"sel.atom.include-connected"),it(be.structureQuery.modifier.expandProperty,"sel.atom.expand-property")],["Filters",it(be.structureQuery.filter.pick,"sel.atom.pick"),it(be.structureQuery.filter.first,"sel.atom.first"),it(be.structureQuery.filter.withSameAtomProperties,"sel.atom.with-same-atom-properties"),it(be.structureQuery.filter.intersectedBy,"sel.atom.intersected-by"),it(be.structureQuery.filter.within,"sel.atom.within"),it(be.structureQuery.filter.isConnectedTo,"sel.atom.is-connected-to")],["Combinators",it(be.structureQuery.combinator.intersect,"sel.atom.intersect"),it(be.structureQuery.combinator.merge,"sel.atom.merge"),it(be.structureQuery.combinator.distanceCluster,"sel.atom.dist-cluster")],["Atom Set Properties",it(be.structureQuery.atomSet.atomCount,"atom.set.atom-count"),it(be.structureQuery.atomSet.countQuery,"atom.set.count-query"),it(be.structureQuery.atomSet.reduce,"atom.set.reduce"),it(be.structureQuery.atomSet.propertySet,"atom.set.property")],["Atom Properties",it(be.structureQuery.atomProperty.core.elementSymbol,"atom.el"),it(be.structureQuery.atomProperty.core.vdw,"atom.vdw"),it(be.structureQuery.atomProperty.core.mass,"atom.mass"),it(be.structureQuery.atomProperty.core.atomicNumber,"atom.atomic-number"),it(be.structureQuery.atomProperty.core.x,"atom.x"),it(be.structureQuery.atomProperty.core.y,"atom.y"),it(be.structureQuery.atomProperty.core.z,"atom.z"),it(be.structureQuery.atomProperty.core.sourceIndex,"atom.src-index"),it(be.structureQuery.atomProperty.core.operatorName,"atom.op-name"),it(be.structureQuery.atomProperty.core.operatorKey,"atom.op-key"),it(be.structureQuery.atomProperty.core.modelIndex,"atom.model-index"),it(be.structureQuery.atomProperty.core.modelLabel,"atom.model-label"),it(be.structureQuery.atomProperty.core.atomKey,"atom.key"),it(be.structureQuery.atomProperty.core.bondCount,"atom.bond-count"),it(be.structureQuery.atomProperty.topology.connectedComponentKey,"atom.key.molecule"),it(be.structureQuery.atomProperty.macromolecular.authResidueId,"atom.auth-resid"),it(be.structureQuery.atomProperty.macromolecular.labelResidueId,"atom.label-resid"),it(be.structureQuery.atomProperty.macromolecular.residueKey,"atom.key.res"),it(be.structureQuery.atomProperty.macromolecular.chainKey,"atom.key.chain"),it(be.structureQuery.atomProperty.macromolecular.entityKey,"atom.key.entity"),it(be.structureQuery.atomProperty.macromolecular.isHet,"atom.is-het"),it(be.structureQuery.atomProperty.macromolecular.id,"atom.id"),it(be.structureQuery.atomProperty.macromolecular.label_atom_id,"atom.label_atom_id"),it(be.structureQuery.atomProperty.macromolecular.label_alt_id,"atom.label_alt_id","atom.altloc"),it(be.structureQuery.atomProperty.macromolecular.label_comp_id,"atom.label_comp_id"),it(be.structureQuery.atomProperty.macromolecular.label_asym_id,"atom.label_asym_id"),it(be.structureQuery.atomProperty.macromolecular.label_entity_id,"atom.label_entity_id"),it(be.structureQuery.atomProperty.macromolecular.label_seq_id,"atom.label_seq_id"),it(be.structureQuery.atomProperty.macromolecular.auth_atom_id,"atom.auth_atom_id","atom.name"),it(be.structureQuery.atomProperty.macromolecular.auth_comp_id,"atom.auth_comp_id","atom.resname"),it(be.structureQuery.atomProperty.macromolecular.auth_asym_id,"atom.auth_asym_id","atom.chain"),it(be.structureQuery.atomProperty.macromolecular.auth_seq_id,"atom.auth_seq_id","atom.resno"),it(be.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code,"atom.pdbx_PDB_ins_code","atom.inscode"),it(be.structureQuery.atomProperty.macromolecular.pdbx_formal_charge,"atom.pdbx_formal_charge"),it(be.structureQuery.atomProperty.macromolecular.occupancy,"atom.occupancy"),it(be.structureQuery.atomProperty.macromolecular.B_iso_or_equiv,"atom.B_iso_or_equiv","atom.bfactor"),it(be.structureQuery.atomProperty.macromolecular.entityType,"atom.entity-type"),it(be.structureQuery.atomProperty.macromolecular.entitySubtype,"atom.entity-subtype"),it(be.structureQuery.atomProperty.macromolecular.entityPrdId,"atom.entity-prd-id"),it(be.structureQuery.atomProperty.macromolecular.entityDescription,"atom.entity-description"),it(be.structureQuery.atomProperty.macromolecular.objectPrimitive,"atom.object-primitive"),it(be.structureQuery.atomProperty.macromolecular.chemCompType,"atom.chem-comp-type"),it(be.structureQuery.atomProperty.macromolecular.secondaryStructureKey,"atom.key.sec-struct"),it(be.structureQuery.atomProperty.macromolecular.isModified,"atom.is-modified"),it(be.structureQuery.atomProperty.macromolecular.modifiedParentName,"atom.modified-parent")],["Bond Properties",it(be.structureQuery.bondProperty.order,"bond.order"),it(be.structureQuery.bondProperty.length,"bond.length"),it(be.structureQuery.bondProperty.key,"bond.key"),it(be.structureQuery.bondProperty.atomA,"bond.atom-a"),it(be.structureQuery.bondProperty.atomB,"bond.atom-b"),Vw(hv("bond.is",zt.List(Pt.BondFlag),Ae.Bool,"Test if the current bond has at least one (or all if partial = false) of the specified flags: ".concat(Ae.oneOfValues(Pt.BondFlag).join(", "))),function(e){return le.core.flags.hasAny([le.struct.bondProperty.flags(),le.struct.type.bondFlags(MK(e))])})]]],RK=[];function BK(e){for(var t=0,r=e;t"u"?t:r;return new e(function(i,o){var s=[],u=void 0,c=void 0,l;for(l=0;l=0})}e.oneOf=v;function g(T){return p(function(A){return T.indexOf(A)<0})}e.noneOf=g;function b(T,A){return p(function(E){return T<=E&&E<=A}).desc(T+"-"+A)}e.range=b;function x(T){return new e(function(A,E){for(var I=E;I=T.length?Hd(A,"any character"):Os(A+1,T.charAt(A))}),e.all=new e(function(T,A){return Os(T.length,T.slice(A))}),e.eof=new e(function(T,A){return At.furthest)return e;var r=e.furthest===t.furthest?rPe(e.expected,t.expected):t.expected;return{status:e.status,furthest:t.furthest,expected:r}}function FK(e,t){var r=e.slice(0,t).split(` +`),n=r.length,a=r[r.length-1].length+1;return{offset:t,line:n,column:a}}function JDe(e){return e.length===1?e[0]:"one of "+e.join(", ")}function ePe(e,t){var r=t.index,n=r.offset;if(n===e.length)return", got the end of the input";var a=n>0?"'...":"'",i=e.length-n>12?"...'":"'";return" at line ".concat(r.line," column ").concat(r.column,", got ").concat(a).concat(e.slice(n,n+12)).concat(i)}function tPe(e,t){return"expected ".concat(JDe(t.expected)).concat(ePe(e,t))}function rPe(e,t){var r=e.length,n=t.length;if(r===0)return t;if(n===0)return e;for(var a=new Set,i=[],o=0;o1){var C=_.charAt(0);switch(C){case".":return le.atomName(_.substr(1));case"_":return le.struct.type.elementSymbol([_.substr(1)])}}return _==="true"?!0:_==="false"?!1:b(_)?+_:xi.Symbol(_)}case"list":switch(S.bracket){case"[":return le.core.type.list(g(S.nodes).map(h));case"{":return le.core.type.set(g(S.nodes).map(h));case"(":{if(S.nodes[0].kind==="comment")throw new Error("Invalid expression");var D=h(S.nodes[0]);return xi.Apply(D,p(S.nodes))}default:cr(S.bracket)}default:cr(S)}}function p(S){if(!(S.length<=1)){if(!v(S)){for(var _=[],C=1,D=S.length;C1&&T.value.charAt(0)===":"){var R=T.value.substr(1);for(++C;C=D)throw new Error("There must be a value foolowed a named arg ':".concat(R,"'."));if(S[C].kind==="comment")throw new Error("Invalid expression");A[R]=h(S[C]),isNaN(+R)&&(E=!1)}else A[I++]=h(T)}if(E){for(var B=Object.keys(A).map(function(k){return+k}).sort(function(k,G){return k-G}),O=!0,C=0,D=B.length;C1&&D.value.charAt(0)===":")return!0}return!1}function g(S){for(var _=!1,C=0,D=S.length;C1?ra.core.logic.and(e):void 0}function NK(e){return e.length===1?e[0]:e.length>1?ra.core.logic.or(e):void 0}function GB(e,t){if(t&&t.op!==void 0&&t.val!==void 0){var r=[e,t.val];switch(t.op){case"=":return ra.core.rel.eq(r);case"!=":return ra.core.rel.neq(r);case">":return ra.core.rel.gr(r);case"<":return ra.core.rel.lt(r);case">=":return ra.core.rel.gre(r);case"<=":return ra.core.rel.lte(r);default:throw new Error("operator '".concat(t.op,"' not supported"))}}else return t&&t.flags!==void 0?ra.core.flags.hasAny([e,t.flags]):t&&t.min!==void 0&&t.max!==void 0?ra.core.rel.inRange([e,t.min,t.max]):Array.isArray(t)?t.length>1?ra.core.set.has([ra.core.type.set(t),e]):ra.core.rel.eq([e,t[0]]):ra.core.rel.eq([e,t])}function $o(e){return ra.struct.generator.queryInSelection({0:e,query:ra.struct.generator.all(),"in-complement":!0})}function Ru(e,t){return e.length=|<=|=|!=|>|1)return ra.core.set.has([ra.core.type.set(t),e])}}function tn(e){return ra.struct.generator.atomGroups({"residue-test":ra.core.set.has([ra.core.type.set(e),ra.ammp("label_comp_id")])})}var Ri=le,$c=/[-+]?[0-9]*\.?[0-9]+/,Rx=/[0-9]+/;function ir(e){return e}var cPe={none:"none",turn:"turn",sheet:"beta",helix:"helix",dna:"dna",rna:"rna",carbohydrate:"carbohydrate",helix310:"3-10",helixalpha:"alpha",helixpi:"pi",0:"none",1:"turn",2:"beta",3:"helix",4:"dna",5:"rna",6:"carbohydrate",7:"3-10",8:"alpha",9:"pi"};function HB(e){if(e.head){if(e.head.name&&e.head.name==="core.type.regex"&&(e=e.args[0].replace(/^\^|\$$/g,"")),e=cPe[e.toString().toLowerCase()]||"none",["dna","rna","carbohydrate"].indexOf(e)!==-1)throw new Error("values 'dna', 'rna', 'carbohydrate' not yet supported for 'structure' property");return Ri.struct.type.secondaryStructureFlags([e])}}var jB={adpmax:{"@desc":"the maximum anisotropic displacement parameter for the selected atom","@examples":[""],isUnsupported:!0,regex:$c,map:function(e){return parseFloat(e)},level:"atom-test"},adpmin:{"@desc":"the minimum anisotropic displacement parameter for the selected atom","@examples":[""],isUnsupported:!0,regex:$c,map:function(e){return parseFloat(e)},level:"atom-test"},altloc:{"@desc":"PDB alternate location identifier","@examples":["altloc = A"],regex:/[a-zA-Z0-9]/,map:ir,level:"atom-test",property:Ri.ammp("label_alt_id")},altname:{"@desc":"an alternative name given to atoms by some file readers (for example, P2N)","@examples":[""],isUnsupported:!0,regex:/[a-zA-Z0-9]/,map:ir,level:"atom-test"},atomID:{"@desc":"special atom IDs for PDB atoms assigned by Jmol","@examples":[""],isUnsupported:!0,regex:Rx,map:function(e){return parseInt(e)},level:"atom-test"},atomIndex:{"@desc":"atom 0-based index; a unique number for each atom regardless of the number of models loaded","@examples":[""],isUnsupported:!0,regex:Rx,map:function(e){return parseInt(e)},level:"atom-test"},atomName:{"@desc":"atom name","@examples":["atomName = CA"],regex:/[a-zA-Z0-9]+/,map:function(e){return Ri.atomName(e)},level:"atom-test",property:Ri.ammp("label_atom_id")},atomno:{"@desc":'sequential number; you can use "@" instead of "atomno=" -- for example, select @33 or Var x = @33 or @35',"@examples":[""],isUnsupported:!0,regex:Rx,map:function(e){return parseInt(e)},level:"atom-test"},atomType:{"@desc":"atom type (mol2, AMBER files) or atom name (other file types)","@examples":["atomType = OH"],regex:/[a-zA-Z0-9]+/,map:function(e){return Ri.atomName(e)},level:"atom-test",property:Ri.ammp("label_atom_id")},atomX:{"@desc":"Cartesian X coordinate (or just X)","@examples":["x = 4.2"],abbr:["X"],isNumeric:!0,regex:$c,map:function(e){return parseFloat(e)},level:"atom-test",property:Ri.acp("x")},atomY:{"@desc":"Cartesian Y coordinate (or just Y)","@examples":["y < 42"],abbr:["Y"],isNumeric:!0,regex:$c,map:function(e){return parseFloat(e)},level:"atom-test",property:Ri.acp("y")},atomZ:{"@desc":"Cartesian Z coordinate (or just Z)","@examples":["Z > 10"],abbr:["Z"],isNumeric:!0,regex:$c,map:function(e){return parseFloat(e)},level:"atom-test",property:Ri.acp("z")},bondcount:{"@desc":"covalent bond count","@examples":["bondcount = 0"],isNumeric:!0,regex:Rx,map:function(e){return parseInt(e)},level:"atom-test",property:Ri.acp("bondCount")},bondingRadius:{"@desc":"radius used for auto bonding; synonymous with ionic and ionicRadius","@examples":[""],abbr:["ionic","ionicRadius"],isUnsupported:!0,regex:$c,map:function(e){return parseFloat(e)},level:"atom-test"},cell:{"@desc":'crystallographic unit cell, expressed either in lattice integer notation (111-999) or as a coordinate in ijk space, where {1 1 1} is the same as 555. ANDing two cells, for example select cell=555 and cell=556, selects the atoms on the common face. (Note: in the specifc case of CELL, only "=" is allowed as a comparator.)',"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},configuration:{"@desc":'Only in the context {configuration=n}, this option selects the set of atoms with either no ALTLOC specified or those atoms having this index into the array of altlocs within its model. So, for example, if the model has altloc "A" and "B", select configuration=1 is equivalent to select altloc="" or altloc="A", and print {configuration=2} is equivalent to print {altloc="" or altloc="B"}. Configuration 0 is "all atoms in a model having configurations", and an invalid configuration number gives no atoms. (Note: in the specifc case of CONFIGURATION, only "=" is allowed as a comparator.)',"@examples":[""],isUnsupported:!0,regex:Rx,map:function(e){return parseInt(e)},level:"atom-test"},chain:{"@desc":'protein chain. For newer CIF files allowing multicharacter chain specifications, use quotations marks: select chain="AA". For these multicharacter desigations, case is not checked unless the CIF file has lower-case chain designations.',"@examples":["chain = A",'chain = "AA"'],regex:/[a-zA-Z0-9]+/,map:ir,level:"chain-test",property:Ri.ammp("auth_asym_id")},chainNo:{"@desc":'chain number; sequentially counted from 1 for each model; chainNo == 0 means"no chain" or PDB chain identifier indicated as a blank (Jmol 14.0).',"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},color:{"@desc":"the atom color","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},covalentRadius:{"@desc":"covalent bonding radius, synonymous with covalent. Not used by Jmol, but could be used, for example, in {*}.spacefill={*}.covalentRadius.all.","@examples":[""],abbr:["covalent"],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},cs:{"@desc":"chemical shift calculated using computational results that include magnetic shielding tensors.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},element:{"@desc":'element symbol. The value of this parameter depends upon the context. Used with select structure=x, x can be either the quoted element symbol, "H", "He", "Li", etc. or atomic number. In all other contexts, the value is the element symbol. When the atom is a specific isotope, the string will contain the isotope number -- "13C", for example.',"@examples":["element=Fe"],regex:/[a-zA-Z]+/,map:function(e){return Ri.es(e)},level:"atom-test",property:Ri.acp("elementSymbol")},elemno:{"@desc":"atomic element number","@examples":["elemno=8"],regex:/[0-9\s{}-]+/,map:function(e){return parseInt(e)},level:"atom-test",property:Ri.acp("atomicNumber")},eta:{"@desc":`Based on Carlos M. Duarte, Leven M. Wadley, and Anna Marie Pyle, RNA structure comparison, motif search and discovery using a reduced representation of RNA conformational space, Nucleic Acids Research, 2003, Vol. 31, No. 16 4755-4761. The parameter eta is the C4'[i-1]-P[i]-C4'[i]-P[i+1] dihedral angle; theta is the P[i]-C4'[i]-P[i+1]-C4'[i+1] dihedral angle. Both are measured on a 0-360 degree scale because they are commonly near 180 degrees. Using the commands plot PROPERTIES eta theta resno; select visible;wireframe only one can create these authors' "RNA worm" graph.`,"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},theta:{"@desc":`Based on Carlos M. Duarte, Leven M. Wadley, and Anna Marie Pyle, RNA structure comparison, motif search and discovery using a reduced representation of RNA conformational space, Nucleic Acids Research, 2003, Vol. 31, No. 16 4755-4761. The parameter eta is the C4'[i-1]-P[i]-C4'[i]-P[i+1] dihedral angle; theta is the P[i]-C4'[i]-P[i+1]-C4'[i+1] dihedral angle. Both are measured on a 0-360 degree scale because they are commonly near 180 degrees. Using the commands plot PROPERTIES eta theta resno; select visible;wireframe only one can create these authors' "RNA worm" graph.`,"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},file:{"@desc":"file number containing this atom","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},formalCharge:{"@desc":"formal charge","@examples":["formalCharge=1"],regex:$c,map:function(e){return parseFloat(e)},level:"atom-test",property:Ri.ammp("pdbx_formal_charge")},format:{"@desc":"format (label) of the atom.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},fXyz:{"@desc":"fractional XYZ coordinates","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},fX:{"@desc":"fractional X coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},fY:{"@desc":"fractional Y coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},fZ:{"@desc":"fractional Z coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},fuxyz:{"@desc":"fractional XYZ coordinates in the unitcell coordinate system","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},fux:{"@desc":"fractional X coordinate in the unitcell coordinate system","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},fuy:{"@desc":"fractional Y coordinate in the unitcell coordinate system","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},fuz:{"@desc":"fractional Z coordinate in the unit cell coordinate system","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},group:{"@desc":"3-letter residue code","@examples":["group = ALA"],regex:/[a-zA-Z0-9]{1,3}/,map:ir,level:"residue-test",property:Ri.ammp("label_comp_id")},group1:{"@desc":"single-letter residue code (amino acids only)","@examples":["group1 = G"],regex:/[a-zA-Z]/,map:ir,level:"residue-test",property:Ri.ammp("label_comp_id")},groupID:{"@desc":"group ID number: A unique ID for each amino acid or nucleic acid residue in a PDB file. 0 noGroup 1-5 ALA, ARG, ASN, ASP, CYS 6-10 GLN, GLU, GLY, HIS, ILE 11-15 LEU, LYS, MET, PHE, PRO 16-20 SER, THR, TRP, TYR, VAL 21-23 ASX, GLX, UNK 24-29 A, +A, G, +G, I, +I 30-35 C, +C, T, +T, U, +U Additional unique numbers are assigned arbitrarily by Jmol and cannot be used reproducibly.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},groupindex:{"@desc":"overall group index","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},hydrophobicity:{"@desc":"Aminoacid residue scale of hydrophobicity based on Rose, G. D., Geselowitz, A. R., Lesser, G. J., Lee, R. H., and Zehfus, M. H. (1985). Hydrophobicity of amino acid residues in globular proteins, Science, 229(4716):834-838.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},identify:{"@desc":"for a PDB/mmCIF file, a label such as [ILE]7^1:A.CD1%A/3 #47, which includes the group ([ILE]), residue number with optional insertion code (7^1), chain (:A), atom name (CD1), alternate location if present (%A), PDB model number (/3, for NMR models when one file is loaded; /file.model such as /2.3 if more than one file is loaded), and atom number (#47). For non-PDB data, the information is shorter -- for example, H15/2.1 #6, indicating atom name (H15), full file.model number (/2.1), and atom number (#6). If only a single model is loaded, %[identify] does not include the model number.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},insertion:{"@desc":"protein residue insertion code","@examples":["insertion=A"],regex:/[a-zA-Z0-9]/,map:ir,level:"atom-test",property:Ri.ammp("pdbx_PDB_ins_code")},label:{"@desc":"current atom label (same as format)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},mass:{"@desc":"atomic mass -- especially useful with appended .max or .sum","@examples":["mass > 13"],regex:$c,map:function(e){return parseFloat(e)},level:"atom-test",property:Ri.acp("mass")},model:{"@desc":"model number","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},modelindex:{"@desc":"a unique number for each model, starting with 0 and spanning all models in all files","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},modO:{"@desc":"currently calculated occupancy from modulation (0 to 100; NaN if atom has no occupancy modulation)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},modXYZ:{"@desc":"currently calculated displacement modulation (for incommensurately modulated structures). Also modX, modY, modZ for individual components. For atoms without modultion, {xx}.modXYZ is -1 and {xx}.modX is NaN, and in a label %[modXYZ] and %[modX] are blank.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},molecule:{"@desc":"molecule number","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},monomer:{"@desc":"monomer number (group number) in a polymer (usually a chain), starting with 1, or 0 if not part of a biopolymer -- that is, not a connected carbohydrate, amino acid, or nucleic acid (Jmol 14.3.15)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},ms:{"@desc":"magnetic shielding calculated from file-loaded tensors.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},occupancy:{"@desc":'CIF file site occupancy. In SELECT command comparisons ("select occupancy < 90"), an integer n implies measurement on a 0-100 scale; also, in the context %[occupancy] or %q for a label, the reported number is a percentage. In all other cases, such as when %Q is used in a label or when a decimal number is used in a comparison, the scale is 0.0 - 1.0.',"@examples":["occupancy < 1"],regex:$c,map:function(e){return parseFloat(e)},level:"atom-test",property:Ri.ammp("occupancy")},partialCharge:{"@desc":"partial charge","@examples":[""],isUnsupported:!0,regex:$c,map:function(e){return parseFloat(e)},level:"atom-test"},phi:{"@desc":"protein group PHI angle for atom's residue","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},polymer:{"@desc":"sequential polymer number in a model, starting with 1.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},polymerLength:{"@desc":"polymer length","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},property_xx:{"@desc":"a property created using the DATA command","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},psi:{"@desc":"protein group PSI angle for the atom's residue","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},radius:{"@desc":'currently displayed radius -- In SELECT command comparisons ("select radius=n"), integer n implies Rasmol units 1/250 Angstroms; in all other cases or when a decimal number is used, the units are Angstroms.',"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},resno:{"@desc":"PDB residue number, not including insertion code (see also seqcode, below)","@examples":["resno = 100"],regex:/-?[0-9]+/,map:function(e){return parseInt(e)},level:"residue-test",property:Ri.ammp("auth_seq_id")},selected:{"@desc":"1.0 if atom is selected; 0.0 if not","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},sequence:{"@desc":'PDB one-character sequence code, as a string of characters, with "?" indicated where single-character codes are not available',"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},seqcode:{"@desc":'PDB residue number, including insertion code (for example, 234^2; "seqcode" option added in Jmol 14.3.16)',"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},seqid:{"@desc":"(mmCIF only) the value from _atom_site.label_seq_id; a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category specifying the sequence of monomers in a polymer. Allowance is made for the possibility of microheterogeneity in a sample by allowing a given sequence number to be correlated with more than one monomer id. (Jmol 14.2.3)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},shape:{"@desc":'hybridization geometry such as "tetrahedral"',"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},site:{"@desc":"crystallographic site number","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},spacefill:{"@desc":"currently displayed radius","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},straightness:{"@desc":'quaternion-derived straightness (second derivative of the quaternion describing the orientation of the residue. This quantity will have different values depending upon the setting of quaternionFrame as "A" (alpha-carbon/phosphorus atom only), "C" (alpha-carbon/pyrimidine or purine base based), "P" (carbonyl-carbon peptide plane/phosphorus tetrahedron based), or "N" (amide-nitrogen based). The default is alpha-carbon based, which corresponds closely to the following combination of Ramachandran angles involving three consecutive residues i-1, i, and i+1: -psii-1 - phii + psii + phii+1.',"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},strucno:{"@desc":"a unique number for each helix, sheet, or turn in a model, starting with 1.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},structure:{"@desc":'The value of this parameter depends upon the context. Used with select structure=x, x can be either the quoted keyword "none", "turn", "sheet", "helix", "dna", "rna", or "carbohydrate" or a respective number 0-6. In the context {*}.structure, the return value is a number; in the context label %[structure], the return is one of the six keywords.',"@examples":['structure="helix"',"structure=3"],regex:/none|turn|sheet|helix|dna|rna|carbohydrate|[0-6]/i,map:ir,level:"residue-test",property:"structure"},substructure:{"@desc":'like structure, the value of this parameter depends upon the context. Used with select substructure=x, x can be either the quoted keyword "none", "turn", "sheet", "helix", "dna", "rna", "carbohydrate", "helix310", "helixalpha", or "helixpi", or the respective number 0-9. In the context {*}.substructure, the return value is a number; in the context label %[substructure], the return is one of the nine keywords.',"@examples":['substructure = "alphahelix"',"substructure =9"],regex:/none|turn|sheet|helix|dna|rna|carbohydrate|helix310|helixalpha|helixpi|[0-9]/i,map:ir,level:"residue-test",property:"structure"},surfacedistance:{"@desc":"A value related to the distance of an atom to a nominal molecular surface. 0 indicates at the surface. Positive numbers are minimum distances in Angstroms from the given atom to the surface.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},symop:{"@desc":'the first symmetry operation code that generated this atom by Jmol; an integer starting with 1. See also symmetry, below. This operator is only present if the file contains space group information and the file was loaded using the {i, j, k} option so as to generate symmetry-based atoms. To select only the original atoms prior to application of symmetry, you can either use "SYMOP=n", where n is the symmetry operator corresponding to "x,y,z", or you can specify instead simply "NOT symmetry" the way you might specify "NOT hydrogen". Note that atoms in special positions will have multiple operator matches. These atoms can be selected using the keyword SPECIALPOSITION. The special form select SYMOP=nijk selects a specific translation of atoms from the given crystallographic symmetry operation. Comparators <, <=, >, >=, and != can be used and only apply to the ijk part of the designation. The ijk are relative, not absolute. Thus, symop=2555 selects for atoms that have been transformed by symop=2 but not subjected to any further translation. select symop=1555 is identical to select not symmetry. All other ijk are relative to these selections for 555. If the model was loaded using load "filename.cif" {444 666 1}, where the 1 indicates that all symmetry-generated atoms are to be packed within cell 555 and then translated to fill the other 26 specified cells, then select symop=3555 is nearly the same as select symop=3 and cell=555. (The difference being that cell=555 selects for all atoms that are on any edge of the cell, while symop=3555 does not.) However, the situation is different if instead the model was loaded using load "filename.cif" {444 666 0}, where the 0 indicates that symmetry-generated atoms are to be placed exactly where their symmetry operator would put them (x,-y,z being different then from x, 1-y, z). In that case, select symop=3555 is for all atoms that have been generated using symmetry operation 3 but have not had any additional translations applied to the x,y,z expression found in the CIF file. If, for example, symmetry operation 3 is -x,-y,-z, then load "filename.cif" {444 666 0} will place an atom originally at {1/2, 1/2, 1/2} at positions {-1/2, -1/2, -1/2} (symop=3555) and {-3/2, -3/2, -3/2} (symop=3444) and 24 other sites.',"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},symmetry:{"@desc":'as "symmetry" or in a label as lower-case "o" gives list of crystallographic symmetry operators generating this atom with lattice designations,such as 3555; upper-case "%O" in a label gives a list without the lattice designations. See also symop, above.',"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},temperature:{"@desc":"yes yes temperature factor (B-factor)","@examples":["temperature >= 20"],regex:$c,map:function(e){return parseFloat(e)},level:"atom-test",property:Ri.ammp("B_iso_or_equiv")},unitXyz:{"@desc":"unit cell XYZ coordinates","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},uX:{"@desc":"unit cell X coordinate normalized to [0,1)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},uY:{"@desc":"unit cell Y coordinate normalized to [0,1)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},uZ:{"@desc":"unit cell Z coordinate normalized to [0,1)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},valence:{"@desc":"the valence of an atom (sum of bonds, where double bond counts as 2 and triple bond counts as 3","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},vanderwaals:{"@desc":"van der Waals radius","@examples":["vanderwaals >2"],regex:$c,map:function(e){return parseFloat(e)},level:"atom-test",property:Ri.acp("vdw")},vectorScale:{"@desc":"vibration vector scale","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},volume:{"@desc":"approximate van der Waals volume for this atom. Note, {*}.volume gives an average; use {*}.volume.sum to get total volume.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},vXyz:{"@desc":"vibration vector, or individual components as %vx %vy %vz. For atoms without vibration vectors, {xx}.vXyz is -1; in a label, %[vxyz] is blank.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},vX:{"@desc":"vibration vector X coordinate; for atoms without vibration vector, {xx}.vX is NaN (same for vY and vZ)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},vY:{"@desc":"vibration vector Y coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},vZ:{"@desc":"vibration vector Z coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"},xyz:{"@desc":"Cartesian XYZ coordinates; select xyz > 1.0 selects atoms more than one Angstrom from the origin.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:ir,level:"atom-test"}};var HK=le,qB=[{"@desc":"Selects atoms that are not included in s1.","@examples":["not ARG"],name:"not",type:Mo,rule:qe.alt(qe.regex(/NOT/i).skip(qe.whitespace),qe.string("!").skip(qe.optWhitespace)),map:function(e,t){return $o(t)}},{"@desc":"Selects atoms included in both s1 and s2.","@examples":["ASP and .CA"],name:"and",type:xo,rule:Qc(/AND|&/i),map:function(e,t,r){return HK.struct.modifier.intersectBy({0:t,by:r})}},{"@desc":"Selects atoms included in either s1 or s2.","@examples":["ASP or GLU"],name:"or",type:xo,rule:Qc(/OR|\||,/i),map:function(e,t,r){return HK.struct.combinator.merge([t,r])}}];var Oe=le,Oa={acidic:["ASP","GLU"],aliphatic:["ALA","GLY","ILE","LEU","VAL"],amino:["ALA","ARG","ASN","ASP","CYS","GLN","GLU","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","ASX","GLX","UNK"],aromatic:["HIS","PHE","TRP","TYR"],basic:["ARG","HIS","LYS"],buried:["ALA","CYS","ILE","LEU","MET","PHE","TRP","VAL"],cg:["CYT","C","GUA","G"],cyclic:["HIS","PHE","PRO","TRP","TYR"],hydrophobic:["ALA","GLY","ILE","LEU","MET","PHE","PRO","TRP","TYR","VAL"],large:["ARG","GLU","GLN","HIS","ILE","LEU","LYS","MET","PHE","TRP","TYR"],medium:["ASN","ASP","CYS","PRO","THR","VAL"],small:["ALA","GLY","SER"],nucleic:["G","C","A","T","U","I","DG","DC","DA","DT","DU","DI","+G","+C","+A","+T","+U","+I"]},jK={nucleic:["P","O3'","O5'","C5'","C4'","C3'","OP1","OP2","O3*","O5*","C5*","C4*","C3*","C2'","C1'","O4'","O2'"],protein:["C","N","CA"]};function Bx(){return Oe.struct.combinator.merge([Oe.struct.generator.atomGroups({"residue-test":Oe.core.set.has([Oe.set.apply(Oe,Oa.nucleic),Oe.ammp("label_comp_id")])}),Oe.struct.filter.pick({0:Oe.struct.generator.atomGroups({"group-by":Oe.ammp("residueKey")}),test:Oe.core.logic.and([Oe.core.rel.eq([Oe.struct.atomSet.atomCount(),1]),Oe.core.rel.eq([Oe.ammp("label_atom_id"),Oe.atomName("P")])])}),Oe.struct.filter.pick({0:Oe.struct.generator.atomGroups({"group-by":Oe.ammp("residueKey")}),test:Oe.core.logic.or([Oe.core.set.isSubset([fc(["C1'","C2'","O3'","C3'","C4'","C5'","O5'"]),Oe.ammpSet("label_atom_id")]),Oe.core.set.isSubset([fc(["C1*","C2*","O3*","C3*","C4*","C5*","O5*"]),Oe.ammpSet("label_atom_id")])])})])}function lPe(){return Oe.struct.generator.atomGroups({"residue-test":Oe.core.set.has([Oe.set.apply(Oe,Oa.amino),Oe.ammp("label_comp_id")])})}function fPe(){return Oe.struct.combinator.merge([Oe.struct.modifier.intersectBy({0:Oe.struct.generator.atomGroups({"residue-test":Oe.core.set.has([Oe.core.type.set(Oa.amino),Oe.ammp("label_comp_id")])}),by:Oe.struct.generator.atomGroups({"atom-test":Oe.core.set.has([Oe.core.type.set(jK.protein),Oe.ammp("label_atom_id")])})}),Oe.struct.modifier.intersectBy({0:Oe.struct.generator.atomGroups({"residue-test":Oe.core.set.has([Oe.core.type.set(Oa.nucleic),Oe.ammp("label_comp_id")])}),by:Oe.struct.generator.atomGroups({"atom-test":Oe.core.set.has([Oe.core.type.set(jK.nucleic),Oe.ammp("label_atom_id")])})})])}var WB={all:{"@desc":"all atoms; same as *",abbr:["*"],map:function(){return Oe.struct.generator.all()}},bonded:{"@desc":"covalently bonded",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.rel.gr([Oe.struct.atomProperty.core.bondCount({flags:Oe.struct.type.bondFlags(["covalent","metallic","sulfide"])}),0])})}},clickable:{"@desc":"actually visible -- having some visible aspect such as wireframe, spacefill, or a label showing, or the alpha-carbon or phosphorus atom in a biomolecule that is rendered with only cartoon, rocket, or other biomolecule-specific shape."},connected:{"@desc":"bonded in any way, including hydrogen bonds",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.rel.gr([Oe.struct.atomProperty.core.bondCount({flags:Oe.struct.type.bondFlags()}),0])})}},displayed:{"@desc":"displayed using the display or hide command; not necessarily visible"},hidden:{"@desc":"hidden using the display or hide command"},none:{"@desc":"no atoms",map:function(){return Oe.struct.generator.empty()}},selected:{"@desc":"atoms that have been selected; defaults to all when a file is first loaded"},thisModel:{"@desc":'atoms in the current frame set, as defined by frame, model, or animation commands. If more than one model is in this set, "thisModel" refers to all of them, regardless of atom displayed/hidden status.'},visible:{"@desc":"visible in any way, including PDB residue atoms for which a cartoon or other such rendering makes their group visible, even if they themselves are not visible."},subset:{"@desc":"the currently defined subset. Note that if a subset is currently defined, then select/display all is the same as select/display subset, restrict none is the same as restrict not subset. In addition, select not subset selects nothing."},specialPosition:{"@desc":"atoms in crystal structures that are at special positions - that is, for which there is more than one operator that leads to them."},unitcell:{"@desc":"atoms within the current unitcell, which may be offset. This includes atoms on the faces and at the vertices of the unitcell."},polyhedra:{"@desc":"all central atoms for which polyhedra have been created. See also polyhera(n), below. (Jmol 14.4)"},nonmetal:{"@desc":"_H,_He,_B,_C,_N,_O,_F,_Ne,_Si,_P,_S,_Cl,_Ar,_As,_Se,_Br,_Kr,_Te,_I,_Xe,_At,_Rn",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.set.has([Oe.set.apply(Oe,["H","He","B","C","N","O","F","Ne","Si","P","S","Cl","Ar","As","Se","Br","Kr","Te","I","Xe","At","Rn"].map(Oe.es)),Oe.acp("elementSymbol")])})}},metal:{"@desc":"!nonmetal",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.logic.not([Oe.core.set.has([Oe.set.apply(Oe,["H","He","B","C","N","O","F","Ne","Si","P","S","Cl","Ar","As","Se","Br","Kr","Te","I","Xe","At","Rn"].map(Oe.es)),Oe.acp("elementSymbol")])])})}},alkaliMetal:{"@desc":"_Li,_Na,_K,_Rb,_Cs,_Fr",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.set.has([Oe.set.apply(Oe,["Li","Na","K","Rb","Cs","Fr"].map(Oe.es)),Oe.acp("elementSymbol")])})}},alkalineEarth:{"@desc":"_Be,_Mg,_Ca,_Sr,_Ba,_Ra",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.set.has([Oe.set.apply(Oe,["Be","Mg","Ca","Sr","Ba","Ra"].map(Oe.es)),Oe.acp("elementSymbol")])})}},nobleGas:{"@desc":"_He,_Ne,_Ar,_Kr,_Xe,_Rn",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.set.has([Oe.set.apply(Oe,["He","Ne","Ar","Kr","Xe","Rn"].map(Oe.es)),Oe.acp("elementSymbol")])})}},metalloid:{"@desc":"_B,_Si,_Ge,_As,_Sb,_Te",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.set.has([Oe.set.apply(Oe,["B","Si","Ge","As","Sb","Te"].map(Oe.es)),Oe.acp("elementSymbol")])})}},transitionMetal:{"@desc":"(includes La and Ac) elemno>=21 and elemno<=30, elemno=57, elemno=89, elemno>=39 and elemno<=48, elemno>=72 and elemno<=80, elemno>=104 and elemno<=112",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.logic.or([Oe.core.rel.inRange([Oe.acp("atomicNumber"),21,30]),Oe.core.rel.inRange([Oe.acp("atomicNumber"),39,48]),Oe.core.rel.inRange([Oe.acp("atomicNumber"),72,80]),Oe.core.rel.inRange([Oe.acp("atomicNumber"),104,112]),Oe.core.set.has([Oe.set(57,89),Oe.acp("atomicNumber")])])})}},lanthanide:{"@desc":"(does not include La) elemno>57 and elemno<=71",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.rel.inRange([Oe.acp("atomicNumber"),57,71])})}},actinide:{"@desc":"(does not include Ac) elemno>89 and elemno<=103",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.rel.inRange([Oe.acp("atomicNumber"),89,103])})}},isaromatic:{"@desc":"atoms connected with the AROMATIC, AROMATICSINGLE, or AROMATICDOUBLE bond types",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.rel.gr([Oe.struct.atomProperty.core.bondCount({flags:Oe.struct.type.bondFlags(["aromatic"])}),0])})}},carbohydrate:{"@desc":""},ions:{"@desc":'(specifically the PDB designations "PO4" and "SO4")'},ligand:{"@desc":'(originally "hetero and not solvent"; changed to "!(protein,nucleic,water,UREA)" for Jmol 12.2)'},nucleic:{"@desc":`any group that (a) has one of the following group names: G, C, A, T, U, I, DG, DC, DA, DT, DU, DI, +G, +C, +A, +T, +U, +I; or (b) can be identified as a group that is only one atom, with name "P"; or (c) has all of the following atoms (prime, ', can replace * here): C1*, C2*, C3*, O3*, C4*, C5*, and O5*.`,map:function(){return Bx()}},purine:{"@desc":"any nucleic group that (a) has one of the following group names: A, G, I, DA, DG, DI, +A, +G, or +I; or (b) also has atoms N7, C8, and N9.",map:function(){return Oe.struct.modifier.intersectBy({0:Bx(),by:Oe.struct.combinator.merge([Oe.struct.generator.atomGroups({"residue-test":Oe.core.set.has([Oe.set.apply(Oe,["A","G","I","DA","DG","DI","+A","+G","+I"]),Oe.ammp("label_comp_id")])}),Oe.struct.filter.pick({0:Oe.struct.generator.atomGroups({"group-by":Oe.ammp("residueKey")}),test:Oe.core.set.isSubset([fc(["N7","C8","N9"]),Oe.ammpSet("label_atom_id")])})])})}},pyrimidine:{"@desc":"any nucleic group that (a) has one of the following group names: C, T, U, DC, DT, DU, +C, +T, +U; or (b) also has atom O2.",map:function(){return Oe.struct.modifier.intersectBy({0:Bx(),by:Oe.struct.combinator.merge([Oe.struct.generator.atomGroups({"residue-test":Oe.core.set.has([Oe.set.apply(Oe,["C","T","U","DC","DT","DU","+C","+T","+U"]),Oe.ammp("label_comp_id")])}),Oe.struct.filter.pick({0:Oe.struct.generator.atomGroups({"group-by":Oe.ammp("residueKey")}),test:Oe.core.logic.or([Oe.core.set.has([Oe.ammpSet("label_atom_id"),Oe.atomName("O2*")]),Oe.core.set.has([Oe.ammpSet("label_atom_id"),Oe.atomName("O2'")])])})])})}},dna:{"@desc":"any nucleic group that (a) has one of the following group names: DG, DC, DA, DT, DU, DI, T, +G, +C, +A, +T; or (b) has neither atom O2* or O2'.",map:function(){return Oe.struct.modifier.intersectBy({0:Bx(),by:Oe.struct.combinator.merge([Oe.struct.generator.atomGroups({"residue-test":Oe.core.set.has([Oe.set.apply(Oe,["DG","DC","DA","DT","DU","DI","T","+G","+C","+A","+T"]),Oe.ammp("label_comp_id")])}),Oe.struct.filter.pick({0:Oe.struct.generator.atomGroups({"group-by":Oe.ammp("residueKey")}),test:Oe.core.logic.not([Oe.core.logic.or([Oe.core.set.has([Oe.ammpSet("label_atom_id"),Oe.atomName("O2*")]),Oe.core.set.has([Oe.ammpSet("label_atom_id"),Oe.atomName("O2'")])])])})])})}},rna:{"@desc":"any nucleic group that (a) has one of the following group names: G, C, A, U, I, +U, +I; or (b) has atom O2* or O2'.",map:function(){return Oe.struct.modifier.intersectBy({0:Bx(),by:Oe.struct.combinator.merge([Oe.struct.generator.atomGroups({"residue-test":Oe.core.set.has([Oe.set.apply(Oe,["G","C","A","U","I","+U","+I"]),Oe.ammp("label_comp_id")])}),Oe.struct.filter.pick({0:Oe.struct.generator.atomGroups({"group-by":Oe.ammp("residueKey")}),test:Oe.core.logic.or([Oe.core.set.has([Oe.ammpSet("label_atom_id"),Oe.atomName("O2*")]),Oe.core.set.has([Oe.ammpSet("label_atom_id"),Oe.atomName("O2'")])])})])})}},protein:{"@desc":'defined as a group that (a) has one of the following group names: ALA, ARG, ASN, ASP, CYS, GLN, GLU, GLY, HIS, ILE, LEU, LYS, MET, PHE, PRO, SER, THR, TRP, TYR, VAL, ASX, GLX, or UNK; or (b) contains PDB atom designations [C, O, CA, and N] bonded correctly; or (c) does not contain "O" but contains [C, CA, and N] bonded correctly; or (d) has only one atom, which has name CA and does not have the group name CA (indicating a calcium atom).',map:function(){return lPe()}},acidic:{"@desc":"ASP GLU",map:function(){return tn(Oa.acidic)}},acyclic:{"@desc":"amino and not cyclic",map:function(){return Oe.struct.modifier.intersectBy({0:tn(Oa.amino),by:$o(tn(Oa.cyclic))})}},aliphatic:{"@desc":"ALA GLY ILE LEU VAL",map:function(){return tn(Oa.aliphatic)}},amino:{"@desc":"all twenty standard amino acids, plus ASX, GLX, UNK",map:function(){return tn(Oa.amino)}},aromatic:{"@desc":'HIS PHE TRP TYR (see also "isaromatic" for aromatic bonds)',map:function(){return tn(Oa.aromatic)}},basic:{"@desc":"ARG HIS LYS",map:function(){return tn(Oa.basic)}},buried:{"@desc":"ALA CYS ILE LEU MET PHE TRP VAL",map:function(){return tn(Oa.buried)}},charged:{"@desc":"same as acidic or basic -- ASP GLU, ARG HIS LYS",map:function(){return tn(Oa.acidic.concat(Oa.basic))}},cyclic:{"@desc":"HIS PHE PRO TRP TYR",map:function(){return tn(Oa.cyclic)}},helix:{"@desc":"secondary structure-related.",map:function(){return Oe.struct.generator.atomGroups({"residue-test":Oe.core.flags.hasAny([Oe.struct.type.secondaryStructureFlags(["helix"]),Oe.ammp("secondaryStructureFlags")])})}},helixalpha:{"@desc":"secondary structure-related.",map:function(){return Oe.struct.generator.atomGroups({"residue-test":Oe.core.flags.hasAny([Oe.struct.type.secondaryStructureFlags(["alpha"]),Oe.ammp("secondaryStructureFlags")])})}},helix310:{"@desc":"secondary structure-related.",map:function(){return Oe.struct.generator.atomGroups({"residue-test":Oe.core.flags.hasAny([Oe.struct.type.secondaryStructureFlags(["3-10"]),Oe.ammp("secondaryStructureFlags")])})}},helixpi:{"@desc":"secondary structure-related.",map:function(){return Oe.struct.generator.atomGroups({"residue-test":Oe.core.flags.hasAny([Oe.struct.type.secondaryStructureFlags(["pi"]),Oe.ammp("secondaryStructureFlags")])})}},hetero:{"@desc":"PDB atoms designated as HETATM",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.ammp("isHet")})}},hydrophobic:{"@desc":"ALA GLY ILE LEU MET PHE PRO TRP TYR VAL",map:function(){return tn(Oa.hydrophobic)}},large:{"@desc":"ARG GLU GLN HIS ILE LEU LYS MET PHE TRP TYR",map:function(){return tn(Oa.large)}},medium:{"@desc":"ASN ASP CYS PRO THR VAL",map:function(){return tn(Oa.medium)}},negative:{"@desc":"same as acidic -- ASP GLU",map:function(){return tn(Oa.acidic)}},neutral:{"@desc":"amino and not (acidic or basic)",map:function(){return Oe.struct.modifier.intersectBy({0:tn(Oa.amino),by:$o(tn(Oa.acidic.concat(Oa.basic)))})}},polar:{"@desc":"amino and not hydrophobic",map:function(){return Oe.struct.modifier.intersectBy({0:tn(Oa.amino),by:$o(tn(Oa.hydrophobic))})}},positive:{"@desc":"same as basic -- ARG HIS LYS",map:function(){return tn(Oa.basic)}},sheet:{"@desc":"secondary structure-related",map:function(){return Oe.struct.generator.atomGroups({"residue-test":Oe.core.flags.hasAny([Oe.struct.type.secondaryStructureFlags(["sheet"]),Oe.ammp("secondaryStructureFlags")])})}},small:{"@desc":"ALA GLY SER",map:function(){return tn(Oa.small)}},surface:{"@desc":"amino and not buried",map:function(){return Oe.struct.modifier.intersectBy({0:tn(Oa.amino),by:$o(tn(Oa.buried))})}},turn:{"@desc":"secondary structure-related",map:function(){return Oe.struct.generator.atomGroups({"residue-test":Oe.core.flags.hasAny([Oe.struct.type.secondaryStructureFlags(["turn"]),Oe.ammp("secondaryStructureFlags")])})}},alpha:{"@desc":"(*.CA)",map:function(){return Oe.struct.generator.atomGroups({"atom-test":Oe.core.rel.eq([Oe.atomName("CA"),Oe.ammp("label_atom_id")])})}},base:{"@desc":"(nucleic bases)"},backbone:{"@desc":"(*.C, *.CA, *.N, and all nucleic other than the bases themselves)",abbr:["mainchain"],map:function(){return fPe()}},sidechain:{"@desc":"((protein or nucleic) and not backbone)"},spine:{"@desc":"(*.CA, *.N, *.C for proteins; *.P, *.O3', *.O5', *.C3', *.C4', *.C5 for nucleic acids)"},leadatom:{"@desc":"(*.CA, *.P, and terminal *.O5')"},solvent:{"@desc":'PDB "HOH", water, also the connected set of H-O-H in any model'}};var Mr=le,dPe=[{"@desc":"value comparisons","@examples":[],name:"=",abbr:["=="],type:xo,rule:qe.regexp(/\s*(LIKE|>=|<=|=|!=|>|<)\s*/i,1),map:function(e,t,r){var n;if(t==="structure"?n=Mr.core.flags.hasAny([Mr.ammp("secondaryStructureFlags"),HB(r)]):r==="structure"?n=Mr.core.flags.hasAny([Mr.ammp("secondaryStructureFlags"),HB(t)]):t.head!==void 0?t.head.name==="core.type.regex"&&(n=Mr.core.str.match([t,Mr.core.type.str([r])])):r.head!==void 0?r.head.name==="core.type.regex"&&(n=Mr.core.str.match([r,Mr.core.type.str([t])])):e.toUpperCase()==="LIKE"&&(t.head?n=Mr.core.str.match([Mr.core.type.regex(["^".concat(r,"$"),"i"]),Mr.core.type.str([t])]):n=Mr.core.str.match([Mr.core.type.regex(["^".concat(t,"$"),"i"]),Mr.core.type.str([r])])),!n)switch(t.head&&(r=Cv(t,r)),r.head&&(t=Cv(r,t)),e){case"=":n=Mr.core.rel.eq([t,r]);break;case"!=":n=Mr.core.rel.neq([t,r]);break;case">":n=Mr.core.rel.gr([t,r]);break;case"<":n=Mr.core.rel.lt([t,r]);break;case">=":n=Mr.core.rel.gre([t,r]);break;case"<=":n=Mr.core.rel.lte([t,r]);break;default:throw new Error("value operator '".concat(e,"' not supported"))}return Mr.struct.generator.atomGroups({"atom-test":n})}}];function mPe(e){var t=e[1],r=t[0],n=t[1],a=t[2],i=t[3],o=t[4],s=t[5],u=t[6],c={};o&&(c["chain-test"]=Mr.core.rel.eq([Mr.ammp("auth_asym_id"),o]));var l=[];r&&l.push(Mr.core.rel.eq([Mr.ammp("label_comp_id"),r])),n&&l.push(Mr.core.logic.and([Mr.core.rel.gre([Mr.ammp("auth_seq_id"),n[0]]),Mr.core.rel.lte([Mr.ammp("auth_seq_id"),n[1]])])),a&&l.push(Mr.core.rel.eq([Mr.ammp("auth_seq_id"),a])),i&&l.push(Mr.core.rel.eq([Mr.ammp("pdbx_PDB_ins_code"),i])),l.length&&(c["residue-test"]=Ix(l));var f=[];return s&&f.push(Mr.core.rel.eq([Mr.ammp("auth_atom_id"),s])),u&&f.push(Mr.core.rel.eq([Mr.ammp("label_alt_id"),u])),f.length&&(c["atom-test"]=Ix(f)),Mr.struct.generator.atomGroups(c)}var pPe=qe.createLanguage({Integer:function(){return qe.regexp(/-?[0-9]+/).map(Number).desc("integer")},Parens:function(e){return qe.alt(e.Parens,e.Operator,e.Expression).wrap(qe.regexp(/\(\s*/),qe.regexp(/\s*\)/))},Expression:function(e){return qe.alt(e.Keywords,e.AtomExpression.map(mPe),e.Within.map(function(t){return Mr.struct.modifier.includeSurroundings({0:t[1],radius:t[0]})}),e.ValueQuery,e.Element.map(function(t){return Mr.struct.generator.atomGroups({"atom-test":Mr.core.rel.eq([Mr.acp("elementSymbol"),Mr.struct.type.elementSymbol(t)])})}),e.Resname.map(function(t){return Mr.struct.generator.atomGroups({"residue-test":Mr.core.rel.eq([Mr.ammp("label_comp_id"),t])})}))},Operator:function(e){return hp(qB,qe.alt(e.Parens,e.Expression))},AtomExpression:function(e){return qe.seq(qe.lookahead(e.AtomPrefix),qe.seq(e.BracketedResname.or(qe.of(null)),e.ResnoRange.or(qe.of(null)),e.Resno.or(qe.of(null)),e.Inscode.or(qe.of(null)),e.Chainname.or(qe.of(null)),e.Atomname.or(qe.of(null)),e.Altloc.or(qe.of(null)),e.Model.or(qe.of(null)))).desc("expression")},AtomPrefix:function(){return qe.regexp(/[\[0-9:^%/.-]/).desc("atom-prefix")},Chainname:function(){return qe.regexp(/:([A-Za-z]{1,3})/,1).desc("chainname")},Model:function(){return qe.regexp(/\/([0-9]+)/,1).map(Number).desc("model")},Element:function(){return qe.regexp(/_([A-Za-z]{1,3})/,1).desc("element")},Atomname:function(){return qe.regexp(/\.([a-zA-Z0-9]{1,4})/,1).map(Mr.atomName).desc("atomname")},Resname:function(){return qe.regexp(/[a-zA-Z0-9]{1,4}/).desc("resname")},Resno:function(e){return e.Integer.desc("resno")},Altloc:function(){return qe.regexp(/%([a-zA-Z0-9])/,1).desc("altloc")},Inscode:function(){return qe.regexp(/\^([a-zA-Z0-9])/,1).desc("inscode")},BracketedResname:function(){return qe.regexp(/\[([a-zA-Z0-9]{1,4})\]/,1).desc("bracketed-resname")},ResnoRange:function(e){return qe.seq(e.Integer.skip(qe.seq(qe.optWhitespace,qe.string("-"),qe.optWhitespace)),e.Integer).desc("resno-range")},Within:function(e){return qe.regexp(/within/i).skip(qe.regexp(/\s*\(\s*/)).then(qe.seq(e.Integer.skip(qe.regexp(/\s*,\s*/)),e.Query)).skip(qe.regexp(/\)/))},Keywords:function(){var e;return(e=qe).alt.apply(e,cy(WB)).desc("keyword")},Query:function(e){return qe.alt(e.Operator,e.Parens,e.Expression).trim(qe.optWhitespace)},Number:function(){return qe.regexp(/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/).map(Number).desc("number")},String:function(){var e=ly(jB,WB,qB).sort(Ru).map(pd).join("|");return qe.alt(qe.regexp(new RegExp("(?!(".concat(e,"))[A-Z0-9_]+"),"i")),qe.regexp(/'((?:[^"\\]|\\.)*)'/,1),qe.regexp(/"((?:[^"\\]|\\.)*)"/,1).map(function(t){return Mr.core.type.regex(["^".concat(t,"$"),"i"])})).desc("string")},Value:function(e){return qe.alt(e.Number,e.String)},ValueParens:function(e){return qe.alt(e.ValueParens,e.ValueOperator,e.ValueExpressions).wrap(qe.string("("),qe.string(")"))},ValuePropertyNames:function(){var e;return(e=qe).alt.apply(e,Mx(jB,/LIKE|>=|<=|=|!=|>|<|\)|\s/i))},ValueOperator:function(e){return hp(dPe,qe.alt(e.ValueParens,e.ValueExpressions))},ValueExpressions:function(e){return qe.alt(e.Value,e.ValuePropertyNames)},ValueQuery:function(e){return qe.alt(e.ValueOperator.map(function(t){if(t.head){if(t.head.name.startsWith("structure-query.generator"))return t}else if(typeof t=="string"&&t.length<=4)return Mr.struct.generator.atomGroups({"residue-test":Mr.core.rel.eq([Mr.ammp("label_comp_id"),t])});throw new Error("values must be part of an comparison, value '".concat(t,"'"))}))}}),qK=function(e){return pPe.Query.tryParse(e)};var Jo=le,jw=/[-+]?[0-9]*\.?[0-9]+/;function hPe(e){return e.split("+").map(Jo.atomName)}function fy(e){return e.split("+").map(function(t){return t.replace(/^["']|["']$/g,"")})}function YB(e){if(e.includes("-")&&e.includes("+")){var t=e.split("+").map(function(u){return u.replace(/^["']|["']$/g,"")}),r=[];return t.forEach(function(u){if(u.includes("-")&&!u.startsWith("-"))for(var c=u.split("-").map(function(m){return parseInt(m)}),l=c[0],f=c[1],d=l;d<=f;d++)r.push(d);else if(u.includes("-")&&u.startsWith("-")&&u.match(/[0-9]+-[-0-9]+/)){var l=-parseInt(u.split("-")[1]),f=void 0;u.includes("--")?f=-parseInt(u.split("-")[3]):f=parseInt(u.split("-")[2]);for(var d=l;d<=f;d++)r.push(d)}else u.includes("-")&&u.startsWith("-")&&u.match(/[0-9]+-[-0-9]+/),r.push(parseInt(u))}),r}else if(e.includes("-")&&!e.includes("+")){var n=[];if(e.startsWith("-"))if(e.startsWith("-")&&e.match(/[0-9]+-[-0-9]+/)){var i=-parseInt(e.split("-")[1]),o=void 0;e.includes("--")?o=-parseInt(e.split("-")[3]):o=parseInt(e.split("-")[2]);for(var s=i;s<=o;s++)n.push(s)}else e.startsWith("-")&&e.match(/[0-9]+-[-0-9]+/),n.push(parseInt(e));else for(var a=e.split("-").map(function(u){return parseInt(u)}),i=a[0],o=a[1],s=i;s<=o;s++)n.push(s);return n}else return!e.includes("-")&&e.includes("+")?fy(e).map(function(u){return parseInt(u)}):[parseInt(e)]}function vPe(e){return e.split("+").map(Jo.struct.type.elementSymbol)}var gPe={H:"helix",S:"beta",L:"none"};function yPe(e){return{flags:Jo.struct.type.secondaryStructureFlags(e.toUpperCase().split("+").map(function(t){return gPe[t]||"none"}))}}var Ox={symbol:{"@desc":"chemical-symbol-list: list of 1- or 2-letter chemical symbols from the periodic table","@examples":["symbol O+N"],abbr:["e."],regex:/[a-zA-Z'"+]+/,map:vPe,level:"atom-test",property:Jo.acp("elementSymbol")},name:{"@desc":"atom-name-list: list of up to 4-letter codes for atoms in proteins or nucleic acids","@examples":["name CA+CB+CG+CD"],abbr:["n."],regex:/[a-zA-Z0-9'"+]+/,map:hPe,level:"atom-test",property:Jo.ammp("label_atom_id")},resn:{"@desc":"residue-name-list: list of 3-letter codes for amino acids or list of up to 2-letter codes for nucleic acids","@examples":["resn ASP+GLU+ASN+GLN","resn A+G"],abbr:["resname","r."],regex:/[a-zA-Z0-9'"+]+/,map:fy,level:"residue-test",property:Jo.ammp("label_comp_id")},resi:{"@desc":"residue-identifier-list list of up to 4-digit residue numbers or residue-identifier-range","@examples":["resi 1+10+100+1000","resi 1-10"],abbr:["resident","residue","resid","i."],regex:/[0-9+-]+/,map:YB,level:"residue-test",property:Jo.ammp("auth_seq_id")},alt:{"@desc":"alternate-conformation-identifier-list list of single letters","@examples":["alt A+B",'alt ""','alt ""+A'],abbr:[],regex:/[a-zA-Z0-9'"+]+/,map:fy,level:"atom-test",property:Jo.ammp("label_alt_id")},chain:{"@desc":"chain-identifier-list list of single letters or sometimes numbers","@examples":["chain A"],abbr:["c."],regex:/[a-zA-Z0-9'"+]+/,map:fy,level:"chain-test",property:Jo.ammp("auth_asym_id")},segi:{"@desc":"segment-identifier-list list of up to 4 letter identifiers","@examples":["segi lig"],abbr:["segid","s."],regex:/[a-zA-Z0-9'"+]+/,map:fy,level:"chain-test",property:Jo.ammp("label_asym_id")},flag:{"@desc":"flag-number a single integer from 0 to 31","@examples":["flag 0"],isUnsupported:!0,abbr:["f."],regex:/[0-9]+/,map:function(e){return parseInt(e)},level:"atom-test"},numeric_type:{"@desc":"type-number a single integer","@examples":["nt. 5"],isUnsupported:!0,abbr:["nt."],regex:/[0-9]+/,map:function(e){return parseInt(e)},level:"atom-test"},text_type:{"@desc":"type-string a list of up to 4 letter codes","@examples":["text_type HA+HC"],isUnsupported:!0,abbr:["tt."],regex:/[a-zA-Z0-9'"+]+/,map:fy,level:"atom-test"},id:{"@desc":"external-index-number a single integer","@examples":["id 23"],regex:/[0-9+-]+/,map:YB,level:"atom-test",property:Jo.ammp("id")},index:{"@desc":"internal-index-number a single integer","@examples":["index 11"],regex:/[0-9+-]+/,map:YB,level:"atom-test",property:Jo.ammp("id")},ss:{"@desc":"secondary-structure-type list of single letters. Helical regions should be assigned H and sheet regions S. Loop regions can either be assigned L or be blank.","@examples":["ss H+S+L",'ss S+""'],abbr:[],regex:/[a-zA-Z'"+]+/,map:yPe,level:"residue-test",property:Jo.ammp("secondaryStructureFlags")},b:{"@desc":"comparison-operator b-factor-value a real number","@examples":["b > 10"],isNumeric:!0,abbr:[],regex:jw,map:function(e){return parseFloat(e)},level:"atom-test",property:Jo.ammp("B_iso_or_equiv")},q:{"@desc":"comparison-operator occupancy-value a real number","@examples":["q <0.50"],isNumeric:!0,abbr:[],regex:jw,map:function(e){return parseFloat(e)},level:"atom-test",property:Jo.ammp("occupancy")},formal_charge:{"@desc":"comparison-operator formal charge-value an integer","@examples":["fc. = -1"],isNumeric:!0,abbr:["fc."],regex:jw,map:function(e){return parseFloat(e)},level:"atom-test",property:Jo.ammp("pdbx_formal_charge")},partial_charge:{"@desc":"comparison-operator partial charge-value a real number","@examples":["pc. > 1"],isUnsupported:!0,isNumeric:!0,abbr:["pc."],regex:jw,map:function(e){return parseFloat(e)},level:"atom-test"},elem:{"@desc":'str atomic element symbol string ("X" if undefined)',"@examples":["elem N"],regex:/[a-zA-Z0-9]{1,3}/,map:function(e){return Jo.es(e)},level:"atom-test",property:Jo.acp("elementSymbol")}};var Sr=le,XB=[{"@desc":"Selects atoms that are not included in s1.","@examples":["NOT resn ALA","not (resi 42 or chain A)","!resi 42 or chain A"],name:"not",type:Mo,rule:qe.alt(qe.regexp(/NOT/i).skip(qe.whitespace),qe.string("!").skip(qe.optWhitespace)),map:function(e,t){return $o(t)}},{"@desc":"Selects atoms included in both s1 and s2.","@examples":["chain A AND name CA"],name:"and",type:xo,rule:Qc(/AND|&/i),map:function(e,t,r){return Sr.struct.modifier.intersectBy({0:t,by:r})}},{"@desc":"Selects atoms included in either s1 or s2.","@examples":["chain A OR chain B"],name:"or",type:xo,rule:Qc(/OR|\|/i),map:function(e,t,r){return Sr.struct.combinator.merge([t,r])}},{"@desc":"Selects atoms in s1 whose identifiers name, resi, resn, chain and segi all match atoms in s2.","@examples":["chain A IN chain B"],name:"in",type:xo,rule:Qc(/IN/i),map:function(e,t,r){return Sr.struct.filter.withSameAtomProperties({0:t,source:r,property:Sr.core.type.compositeKey([Sr.ammp("label_atom_id"),Sr.ammp("label_seq_id"),Sr.ammp("label_comp_id"),Sr.ammp("auth_asym_id"),Sr.ammp("label_asym_id")])})}},{"@desc":"Selects atoms in s1 whose identifiers name and resi match atoms in s2.","@examples":["chain A LIKE chain B"],name:"like",type:xo,rule:Qc(/LIKE|l\./i),map:function(e,t,r){return Sr.struct.filter.withSameAtomProperties({0:t,source:r,property:Sr.core.type.compositeKey([Sr.ammp("label_atom_id"),Sr.ammp("label_seq_id")])})}},{"@desc":"Selects all atoms whose van der Waals radii are separated from the van der Waals radii of s1 by a minimum of X Angstroms.","@examples":["solvent GAP 2"],name:"gap",type:Px,rule:Ex(/GAP\s+([-+]?[0-9]*\.?[0-9]+)/i,1).map(function(e){return parseFloat(e)}),map:function(e,t){return Sr.struct.filter.within({0:Sr.struct.generator.all(),target:t,"atom-radius":Sr.acp("vdw"),"max-radius":e,invert:!0})}},{"@desc":"Selects atoms with centers within X Angstroms of the center of any atom in s1.","@examples":["resname LIG AROUND 1"],name:"around",abbr:["a."],type:Px,rule:Ex(/(AROUND|a\.)\s+([-+]?[0-9]*\.?[0-9]+)/i,2).map(function(e){return parseFloat(e)}),map:function(e,t){return Sr.struct.modifier.exceptBy({0:Sr.struct.filter.within({0:Sr.struct.generator.all(),target:t,"max-radius":e}),by:t})}},{"@desc":"Expands s1 by all atoms within X Angstroms of the center of any atom in s1.","@examples":["chain A EXPAND 3"],name:"expand",abbr:["x."],type:Px,rule:Ex(/(EXPAND|x\.)\s+([-+]?[0-9]*\.?[0-9]+)/i,2).map(function(e){return parseFloat(e)}),map:function(e,t){return Sr.struct.modifier.includeSurroundings({0:t,radius:e})}},{"@desc":"Selects atoms in s1 that are within X Angstroms of any atom in s2.","@examples":["chain A WITHIN 3 OF chain B"],name:"within",abbr:["w."],type:xo,rule:zw("WITHIN","w."),map:function(e,t,r){return Sr.struct.filter.within({0:t,target:r,"max-radius":e})}},{"@desc":"Same as within, but excludes s2 from the selection (and thus is identical to s1 and s2 around X).","@examples":["chain A NEAR_TO 3 OF chain B"],name:"near_to",abbr:["nto."],type:xo,rule:zw("NEAR_TO","nto."),map:function(e,t,r){return Sr.struct.modifier.exceptBy({0:Sr.struct.filter.within({0:t,target:r,"max-radius":e}),by:r})}},{"@desc":"Selects atoms in s1 that are at least X Anstroms away from s2.","@examples":["solvent BEYOND 2 OF chain A"],name:"beyond",abbr:["be."],type:xo,rule:zw("BEYOND","be."),map:function(e,t,r){return Sr.struct.modifier.exceptBy({0:Sr.struct.filter.within({0:t,target:r,"max-radius":e,invert:!0}),by:r})}},{"@desc":"Expands selection to complete residues.","@examples":["BYRESIDUE name N"],name:"byresidue",abbr:["byresi","byres","br."],type:Mo,rule:au(/BYRESIDUE|byresi|byres|br\./i),map:function(e,t){return dc(Sr.struct.modifier.expandProperty({0:Sr.struct.modifier.union({0:t}),property:Sr.ammp("residueKey")}))}},{"@desc":"Completely selects all alpha carbons in all residues covered by a selection.","@examples":["BYCALPHA chain A"],name:"bycalpha",abbr:["bca."],type:Mo,rule:au(/BYCALPHA|bca\./i),map:function(e,t){return Sr.struct.generator.queryInSelection({0:Sr.struct.modifier.expandProperty({0:Sr.struct.modifier.union({0:t}),property:Sr.ammp("residueKey")}),query:Sr.struct.generator.atomGroups({"atom-test":Sr.core.rel.eq([Sr.atomName("CA"),Sr.ammp("label_atom_id")])})})}},{"@desc":"Expands selection to complete molecules.","@examples":["BYMOLECULE resi 20-30"],name:"bymolecule",isUnsupported:!0,abbr:["bymol","bm."],type:Mo,rule:au(/BYMOLECULE|bymol|bm\./i),map:function(e,t){return dc(Sr.struct.modifier.expandProperty({0:Sr.struct.modifier.union({0:t}),property:Sr.atp("connectedComponentKey")}))}},{"@desc":"Expands selection to complete fragments.","@examples":["BYFRAGMENT resi 10"],name:"byfragment",abbr:["byfrag","bf."],isUnsupported:!0,type:Mo,rule:au(/BYFRAGMENT|byfrag|bf\./i),map:function(e,t){return[e,t]}},{"@desc":"Expands selection to complete segments.","@examples":["BYSEGMENT resn CYS"],name:"bysegment",abbr:["bysegi","byseg","bs."],type:Mo,rule:au(/BYSEGMENT|bysegi|byseg|bs\./i),map:function(e,t){return dc(Sr.struct.modifier.expandProperty({0:Sr.struct.modifier.union({0:t}),property:Sr.ammp("chainKey")}))}},{"@desc":"Expands selection to complete objects.","@examples":["BYOBJECT chain A"],name:"byobject",abbr:["byobj","bo."],isUnsupported:!0,type:Mo,rule:au(/BYOBJECT|byobj|bo\./i),map:function(e,t){return[e,t]}},{"@desc":"Expands selection to unit cell.","@examples":["BYCELL chain A"],name:"bycell",isUnsupported:!0,type:Mo,rule:au(/BYCELL/i),map:function(e,t){return[e,t]}},{"@desc":"All rings of size \u2264 7 which have at least one atom in s1.","@examples":["BYRING resn HEM"],name:"byring",type:Mo,rule:au(/BYRING/i),map:function(e,t){return dc(Sr.struct.modifier.intersectBy({0:Sr.struct.filter.pick({0:Sr.struct.generator.rings(),test:Sr.core.logic.and([Sr.core.rel.lte([Sr.struct.atomSet.atomCount(),7]),Sr.core.rel.gr([Sr.struct.atomSet.countQuery([t]),1])])}),by:t}))}},{"@desc":"Selects atoms directly bonded to s1, excludes s1.","@examples":["NEIGHBOR resn CYS"],name:"neighbor",type:Mo,abbr:["nbr."],rule:au(/NEIGHBOR|nbr\./i),map:function(e,t){return Sr.struct.modifier.exceptBy({0:dc(Sr.struct.modifier.includeConnected({0:Sr.struct.modifier.union({0:t}),"bond-test":!0})),by:t})}},{"@desc":"Selects atoms directly bonded to s1, may include s1.","@examples":["BOUND_TO name CA"],name:"bound_to",abbr:["bto."],type:Mo,rule:au(/BOUND_TO|bto\./i),map:function(e,t){return dc(Sr.struct.modifier.includeConnected({0:Sr.struct.modifier.union({0:t})}))}},{"@desc":"Extends s1 by X bonds connected to atoms in s1.","@examples":["resname LIG EXTEND 3"],name:"extend",abbr:["xt."],type:Px,rule:Ex(/(EXTEND|xt\.)\s+([0-9]+)/i,2).map(function(e){return parseInt(e)}),map:function(e,t){return dc(Sr.struct.modifier.includeConnected({0:Sr.struct.modifier.union({0:t}),"bond-test":!0,"layer-count":e}))}}];var Bt=le,Fs={nucleic:["A","C","T","G","U","DA","DC","DT","DG","DU"],protein:["ALA","ARG","ASN","ASP","CYS","CYX","GLN","GLU","GLY","HIS","HID","HIE","HIP","ILE","LEU","LYS","MET","MSE","PHE","PRO","SER","THR","TRP","TYR","VAL"],solvent:["HOH","WAT","H20","TIP","SOL"]},WK={nucleic:["P","O3'","O5'","C5'","C4'","C3'","OP1","OP2","O3*","O5*","C5*","C4*","C3*","C2'","C1'","O4'","O2'"],protein:["C","N","CA","O"]};function YK(){return Bt.struct.combinator.merge([Bt.struct.modifier.intersectBy({0:Bt.struct.generator.atomGroups({"residue-test":Bt.core.set.has([Bt.core.type.set(Fs.protein),Bt.ammp("label_comp_id")])}),by:Bt.struct.generator.atomGroups({"atom-test":Bt.core.set.has([Bt.core.type.set(WK.protein),Bt.ammp("label_atom_id")])})}),Bt.struct.modifier.intersectBy({0:Bt.struct.generator.atomGroups({"residue-test":Bt.core.set.has([Bt.core.type.set(Fs.nucleic),Bt.ammp("label_comp_id")])}),by:Bt.struct.generator.atomGroups({"atom-test":Bt.core.set.has([Bt.core.type.set(WK.nucleic),Bt.ammp("label_atom_id")])})})])}var KB={all:{"@desc":"All atoms currently loaded into PyMOL",abbr:["*"],map:function(){return Bt.struct.generator.all()}},none:{"@desc":"No atoms (empty selection)",map:function(){return Bt.struct.generator.empty()}},hydrogens:{"@desc":"All hydrogen atoms currently loaded into PyMOL",abbr:["hydro","h."],map:function(){return Bt.struct.generator.atomGroups({"atom-test":Bt.core.rel.eq([Bt.acp("elementSymbol"),Bt.es("H")])})}},hetatm:{"@desc":"All atoms loaded from Protein Data Bank HETATM records",abbr:["het"],map:function(){return Bt.struct.generator.atomGroups({"atom-test":Bt.core.rel.eq([Bt.ammp("isHet"),!0])})}},visible:{"@desc":"All atoms in enabled objects with at least one visible representation",abbr:["v."]},polymer:{"@desc":"All atoms on the polymer (not het). Finds atoms with residue identifiers matching a known polymer, such a peptide and DNA.",abbr:["pol."],map:function(){return Bt.struct.generator.atomGroups({"residue-test":Bt.core.set.has([Bt.core.type.set(Fs.nucleic.concat(Fs.protein)),Bt.ammp("label_comp_id")])})}},sidechain:{"@desc":"Polymer non-backbone atoms (new in PyMOL 1.6.1)",abbr:["sc."],map:function(){return Bt.struct.modifier.exceptBy({0:Bt.struct.generator.atomGroups({"residue-test":Bt.core.set.has([Bt.core.type.set(Fs.nucleic.concat(Fs.protein)),Bt.ammp("label_comp_id")])}),by:YK()})}},present:{"@desc":"All atoms with defined coordinates in the current state (used in creating movies)",abbr:["pr."]},center:{"@desc":"Pseudo-atom at the center of the scene"},origin:{"@desc":"Pseudo-atom at the origin of rotation"},enabled:{"@desc":"All enabled objects or selections from the object list."},masked:{"@desc":"All masked atoms.",abbr:["msk."]},protected:{"@desc":"All protected atoms.",abbr:["pr."]},bonded:{"@desc":"All bonded atoms",map:function(){return Bt.struct.generator.atomGroups({"atom-test":Bt.core.rel.gr([Bt.struct.atomProperty.core.bondCount({flags:Bt.struct.type.bondFlags(["covalent","metallic","sulfide"])}),0])})}},donors:{"@desc":"All hydrogen bond donor atoms.",abbr:["don."]},acceptors:{"@desc":"All hydrogen bond acceptor atoms.",abbr:["acc."]},fixed:{"@desc":"All fixed atoms.",abbr:["fxd."]},restrained:{"@desc":"All restrained atoms.",abbr:["rst."]},organic:{"@desc":"All atoms in non-polymer organic compounds (e.g. ligands, buffers). Finds carbon-containing molecules that do not match known polymers.",abbr:["org."],map:function(){return dc(Bt.struct.modifier.expandProperty({0:Bt.struct.modifier.union([Bt.struct.generator.queryInSelection({0:Bt.struct.generator.atomGroups({"residue-test":Bt.core.logic.not([Bt.core.set.has([Bt.core.type.set(Fs.nucleic.concat(Fs.protein)),Bt.ammp("label_comp_id")])])}),query:Bt.struct.generator.atomGroups({"atom-test":Bt.core.rel.eq([Bt.es("C"),Bt.acp("elementSymbol")])})})]),property:Bt.ammp("residueKey")}))}},inorganic:{"@desc":"All non-polymer inorganic atoms/ions. Finds atoms in molecules that do not contain carbon and do not match any known solvent residues.",abbr:["ino."],map:function(){return dc(Bt.struct.modifier.expandProperty({0:Bt.struct.modifier.union([Bt.struct.filter.pick({0:Bt.struct.generator.atomGroups({"residue-test":Bt.core.logic.not([Bt.core.set.has([Bt.core.type.set(Fs.nucleic.concat(Fs.protein).concat(Fs.solvent)),Bt.ammp("label_comp_id")])]),"group-by":Bt.ammp("residueKey")}),test:Bt.core.logic.not([Bt.core.set.has([Bt.struct.atomSet.propertySet([Bt.acp("elementSymbol")]),Bt.es("C")])])})]),property:Bt.ammp("residueKey")}))}},solvent:{"@desc":"All water molecules. The hardcoded solvent residue identifiers are currently: HOH, WAT, H20, TIP, SOL.",abbr:["sol."],map:function(){return Bt.struct.generator.atomGroups({"residue-test":Bt.core.set.has([Bt.core.type.set(Fs.solvent),Bt.ammp("label_comp_id")])})}},guide:{"@desc":"All protein CA and nucleic acid C4*/C4",map:function(){return Bt.struct.combinator.merge([Bt.struct.generator.atomGroups({"atom-test":Bt.core.rel.eq([Bt.atomName("CA"),Bt.ammp("label_atom_id")]),"residue-test":Bt.core.set.has([Bt.core.type.set(Fs.protein),Bt.ammp("label_comp_id")])}),Bt.struct.generator.atomGroups({"atom-test":Bt.core.set.has([fc(["C4*","C4'"]),Bt.ammp("label_atom_id")]),"residue-test":Bt.core.set.has([Bt.core.type.set(Fs.nucleic),Bt.ammp("label_comp_id")])})])}},metals:{"@desc":"All metal atoms (new in PyMOL 1.6.1)"},backbone:{"@desc":"Polymer backbone atoms (new in PyMOL 1.6.1)",abbr:["bb."],map:function(){return YK()}},"polymer.protein":{"@desc":"Protein (New in PyMOL 2.1)",abbr:["polymer.protein"],map:function(){return Bt.struct.generator.atomGroups({"residue-test":Bt.core.set.has([Bt.core.type.set(Fs.protein),Bt.ammp("label_comp_id")])})}},"polymer.nucleic":{"@desc":"Nucleic Acid (New in PyMOL 2.1)",abbr:["polymer.nucleic"],map:function(){return Bt.struct.generator.atomGroups({"residue-test":Bt.core.set.has([Bt.core.type.set(Fs.nucleic),Bt.ammp("label_comp_id")])})}}};var bPe=le,Bi=UK(Ox),qi=qe.string("/");function Pa(e){return e.or(qe.of(null))}function xPe(e){var t={},r={};for(var n in e){var a=Ox[n];if(!a)throw new Error("property '".concat(n,"' not supported, value '").concat(e[n],"'"));e[n]!==null&&(r[a.level]||(r[a.level]=[]),r[a.level].push(e[n]))}for(var i in r)t[i]=Ix(r[i]);return bPe.struct.generator.atomGroups(t)}var SPe=qe.createLanguage({Parens:function(e){return qe.alt(e.Parens,e.Operator,e.Expression).wrap(qe.string("("),qe.string(")"))},Expression:function(e){return qe.alt(e.Keywords,e.AtomSelectionMacro.map(xPe),e.NamedAtomProperties,e.Pepseq,e.Rep,e.Object)},AtomSelectionMacro:function(e){return qe.alt(qi.then(qe.alt(qe.seq(Pa(e.ObjectProperty).skip(qi),Pa(Bi.segi).skip(qi),Pa(Bi.chain).skip(qi),Pa(Bi.resi).skip(qi),Pa(Bi.name)).map(function(t){return{object:t[0],segi:t[1],chain:t[2],resi:t[3],name:t[4]}}),qe.seq(Pa(e.ObjectProperty).skip(qi),Pa(Bi.segi).skip(qi),Pa(Bi.chain).skip(qi),Pa(Bi.resi)).map(function(t){return{object:t[0],segi:t[1],chain:t[2],resi:t[3]}}),qe.seq(Pa(e.ObjectProperty).skip(qi),Pa(Bi.segi).skip(qi),Pa(Bi.chain)).map(function(t){return{object:t[0],segi:t[1],chain:t[2]}}),qe.seq(Pa(e.ObjectProperty).skip(qi),Pa(Bi.segi)).map(function(t){return{object:t[0],segi:t[1]}}),qe.seq(Pa(e.ObjectProperty)).map(function(t){return{object:t[0]}}))),qe.alt(qe.seq(Pa(e.ObjectProperty).skip(qi),Pa(Bi.segi).skip(qi),Pa(Bi.chain).skip(qi),Pa(Bi.resi).skip(qi),Pa(Bi.name)).map(function(t){return{object:t[0],segi:t[1],chain:t[2],resi:t[3],name:t[4]}}),qe.seq(Pa(Bi.segi).skip(qi),Pa(Bi.chain).skip(qi),Pa(Bi.resi).skip(qi),Pa(Bi.name)).map(function(t){return{segi:t[0],chain:t[1],resi:t[2],name:t[3]}}),qe.seq(Pa(Bi.chain).skip(qi),Pa(Bi.resi).skip(qi),Pa(Bi.name)).map(function(t){return{chain:t[0],resi:t[1],name:t[2]}}),qe.seq(Pa(Bi.resi).skip(qi),Pa(Bi.name)).map(function(t){return{resi:t[0],name:t[1]}})))},NamedAtomProperties:function(){var e;return(e=qe).alt.apply(e,Hw(Ox))},Keywords:function(){var e;return(e=qe).alt.apply(e,cy(KB))},ObjectProperty:function(){var e=ly(Ox,KB,XB).sort(Ru).map(pd).join("|");return qe.regexp(new RegExp("(?!(".concat(e,"))[A-Z0-9_]+"),"i"))},Object:function(e){return e.ObjectProperty.notFollowedBy(qi).map(function(t){throw new Error("property 'object' not supported, value '".concat(t,"'"))})},Pepseq:function(){return qe.regexp(/(PEPSEQ|ps\.)\s+([a-z]+)/i,2).map(jd("operator 'pepseq' not supported"))},Rep:function(){return qe.regexp(/REP\s+(lines|spheres|mesh|ribbon|cartoon|sticks|dots|surface|labels|extent|nonbonded|nb_spheres|slice|extent|slice|dashes|angles|dihedrals|cgo|cell|callback|everything)/i,1).map(jd("operator 'rep' not supported"))},Operator:function(e){return hp(XB,qe.alt(e.Parens,e.Expression,e.Operator))},Query:function(e){return qe.alt(e.Operator,e.Parens,e.Expression).trim(qe.optWhitespace)}}),XK=function(e){return SPe.Query.tryParse(e)};var Si=le,Bu=/[-+]?[0-9]*\.?[0-9]+/,qw=/[+]?[0-9]+/,Fx=/[-+]?[0-9]+/;function _v(e){return e}var ZB={T:"turn",E:"sheet",B:"strand",H:"alpha",G:"3-10",I:"pi",C:"none"};function Ww(e){return Si.struct.type.secondaryStructureFlags([ZB[e.toUpperCase()]||"none"])}var Wd={name:{"@desc":"str atom name","@examples":["name CA"],regex:/[a-zA-Z0-9]+/,map:Si.atomName,level:"atom-test",property:Si.ammp("label_atom_id")},type:{"@desc":"str atom type","@examples":["type C3"],isUnsupported:!0,regex:/[a-zA-Z0-9]+/,map:_v,level:"atom-test"},index:{"@desc":"num the atom number, starting at 0","@examples":["index 10"],isNumeric:!0,regex:qw,map:function(e){return parseInt(e)-1},level:"atom-test",property:Si.ammp("id")},serial:{"@desc":"num the atom number, starting at 1","@examples":["serial 11"],isNumeric:!0,regex:qw,map:function(e){return parseInt(e)},level:"atom-test",property:Si.ammp("id")},atomicnumber:{"@desc":"num atomic number (0 if undefined)","@examples":["atomicnumber 13"],isNumeric:!0,regex:qw,map:function(e){return parseInt(e)},level:"atom-test",property:Si.acp("atomicNumber")},element:{"@desc":'str atomic element symbol string ("X" if undefined)',"@examples":["element N"],regex:/[a-zA-Z0-9]{1,3}/,map:function(e){return Si.es(e)},level:"atom-test",property:Si.acp("elementSymbol")},altloc:{"@desc":"str alternate location/conformation identifier","@examples":["altloc C"],regex:/[a-zA-Z0-9]+/,map:_v,level:"atom-test",property:Si.ammp("label_alt_id")},chain:{"@desc":"str the one-character chain identifier","@examples":["chain A"],regex:/[a-zA-Z0-9]+/,map:_v,level:"residue-test",property:Si.ammp("auth_asym_id")},residue:{"@desc":"num a set of connected atoms with the same residue number","@examples":["residue < 11","residue 11"],isNumeric:!0,regex:Fx,map:function(e){return parseInt(e)},level:"residue-test",property:Si.ammp("auth_seq_id")},fragment:{"@desc":"num a set of connected residues","@examples":["fragment 42"],isUnsupported:!0,isNumeric:!0,regex:Fx,map:function(e){return parseInt(e)},level:"residue-test"},pfrag:{"@desc":"num a set of connected protein residues","@examples":["pfrag 42"],isUnsupported:!0,isNumeric:!0,regex:Fx,map:function(e){return parseInt(e)},level:"residue-test"},nfrag:{"@desc":"num a set of connected nucleic residues","@examples":["nfrag 42"],isUnsupported:!0,isNumeric:!0,regex:Fx,map:function(e){return parseInt(e)},level:"residue-test"},sequence:{"@desc":"str a sequence given by one letter names","@examples":["sequence PGATTACA"],isUnsupported:!0,regex:/[a-zA-Z0-9]+/,map:_v,level:"residue-test"},numbonds:{"@desc":"num number of bonds","@examples":["numbonds = 2","numbonds >= 3"],isNumeric:!0,regex:qw,map:function(e){return parseInt(e)},level:"atom-test",property:Si.acp("bondCount")},resname:{"@desc":"str residue name","@examples":["resname ALA"],regex:/[a-zA-Z0-9]+/,map:_v,level:"residue-test",property:Si.ammp("auth_comp_id")},resid:{"@desc":"num residue id","@examples":["resid 42"],isNumeric:!0,regex:Fx,map:function(e){return parseInt(e)},level:"residue-test",property:Si.ammp("auth_seq_id")},segname:{"@desc":"str segment name","@examples":["segname B"],regex:/[a-zA-Z0-9]+/,map:_v,level:"residue-test",property:Si.ammp("label_asym_id")},x:{"@desc":"float x coordinate","@examples":["x 42"],isNumeric:!0,regex:Bu,map:function(e){return parseFloat(e)},level:"atom-test",property:Si.acp("x")},y:{"@desc":"float y coordinate","@examples":["y > 1.7"],isNumeric:!0,regex:Bu,map:function(e){return parseFloat(e)},level:"atom-test",property:Si.acp("y")},z:{"@desc":"float z coordinate","@examples":["z < 11","z > -21"],isNumeric:!0,regex:Bu,map:function(e){return parseFloat(e)},level:"atom-test",property:Si.acp("z")},radius:{"@desc":"float atomic radius","@examples":["radius > 1.3"],isNumeric:!0,regex:Bu,map:function(e){return parseFloat(e)},level:"atom-test",property:Si.acp("vdw")},mass:{"@desc":"float atomic mass","@examples":["mass > 2"],isNumeric:!0,regex:Bu,map:function(e){return parseFloat(e)},level:"atom-test",property:Si.acp("mass")},charge:{"@desc":"float atomic charge","@examples":["charge > 0","charge 1"],isNumeric:!0,regex:Bu,map:function(e){return parseFloat(e)},level:"atom-test",property:Si.ammp("pdbx_formal_charge")},beta:{"@desc":"float temperature factor","@examples":["beta < 20","beta > 35"],isNumeric:!0,regex:Bu,map:function(e){return parseFloat(e)},level:"atom-test",property:Si.ammp("B_iso_or_equiv")},occupancy:{"@desc":"float occupancy","@examples":["occupancy 1","occupancy < 1"],isNumeric:!0,regex:Bu,map:function(e){return parseFloat(e)},level:"atom-test",property:Si.ammp("occupancy")},user:{"@desc":"float time-varying user-specified value","@examples":["user < 0.1"],isUnsupported:!0,isNumeric:!0,regex:Bu,map:function(e){return parseFloat(e)},level:"atom-test"},rasmol:{"@desc":"str translates Rasmol selection string to VMD","@examples":["rasmol 'all'"],isUnsupported:!0,regex:/[^']*/,map:_v,level:"atom-test"},structure:{"@desc":"str single letter name for the secondary structure","@examples":["structure H","structure H E"],regex:/T|E|B|H|G|I|C/i,map:Ww,level:"atom-test",property:Si.ammp("secondaryStructureFlags")},phi:{"@desc":"float phi backbone conformational angles","@examples":["phi < 160"],isUnsupported:!0,isNumeric:!0,regex:Bu,map:function(e){return parseFloat(e)},level:"residue-test"},psi:{"@desc":"float psi backbone conformational angles","@examples":["psi < 160"],isUnsupported:!0,isNumeric:!0,regex:Bu,map:function(e){return parseFloat(e)},level:"residue-test"},ufx:{"@desc":"num force to apply in the x coordinate","@examples":["ufx 1"],isUnsupported:!0,isNumeric:!0,regex:Bu,map:function(e){return parseInt(e)},level:"atom-test"},ufy:{"@desc":"num force to apply in the y coordinate","@examples":["ufy 1"],isUnsupported:!0,isNumeric:!0,regex:Bu,map:function(e){return parseInt(e)},level:"atom-test"},ufz:{"@desc":"num force to apply in the z coordinate","@examples":["ufz 1"],isUnsupported:!0,isNumeric:!0,regex:Bu,map:function(e){return parseInt(e)},level:"atom-test"}};var wv=le,CPe=Object.keys(Wd).sort(Ru).filter(function(e){return!Wd[e].isUnsupported}).join("|"),QB=[{"@desc":"Selects atoms that are not included in s1.","@examples":["not protein"],name:"not",type:Mo,rule:qe.regexp(/NOT/i).skip(qe.whitespace),map:function(e,t){return $o(t)}},{"@desc":"Selects atoms within a specified distance of a selection","@examples":["within 5 of name FE"],name:"within",type:Mo,rule:au(/WITHIN\s+([-+]?[0-9]*\.?[0-9]+)\s+OF/i,1).map(function(e){return parseFloat(e)}),map:function(e,t){return wv.struct.modifier.includeSurroundings({0:t,radius:e})}},{"@desc":"Exclusive within, equivalent to (within 3 of X) and not X","@examples":["exwithin 10 of resname HEM"],name:"exwithin",type:Mo,rule:au(/EXWITHIN\s+([-+]?[0-9]*\.?[0-9]+)\s+OF/i,1).map(function(e){return parseFloat(e)}),map:function(e,t){return wv.struct.modifier.exceptBy({0:wv.struct.modifier.includeSurroundings({0:t,radius:e}),by:t})}},{"@desc":"Selects atoms which have the same keyword as the atoms in a given selection","@examples":["same resid as name FE"],name:"same",type:Mo,rule:au(new RegExp("SAME\\s+(".concat(CPe,")\\s+AS"),"i"),1).map(function(e){return Wd[e].property}),map:function(e,t){return wv.struct.filter.withSameAtomProperties({0:wv.struct.generator.all(),source:t,property:e})}},{"@desc":"Selects atoms included in both s1 and s2.","@examples":["backbone and protein"],name:"and",type:xo,rule:qe.alt(Qc(/AND/i),qe.whitespace),map:function(e,t,r){return wv.struct.modifier.intersectBy({0:t,by:r})}},{"@desc":"Selects atoms included in either s1 or s2.","@examples":["water or protein"],name:"or",type:xo,rule:Qc(/OR/i),map:function(e,t,r){return wv.struct.combinator.merge([t,r])}}];var Fr=le;function Yd(){return Fr.struct.filter.pick({0:Fr.struct.generator.atomGroups({"group-by":Fr.ammp("residueKey")}),test:Fr.core.set.isSubset([fc(["C","N","CA","O"]),Fr.ammpSet("label_atom_id")])})}function $B(){return Fr.struct.filter.pick({0:Fr.struct.generator.atomGroups({"group-by":Fr.ammp("residueKey")}),test:Fr.core.logic.and([Fr.core.set.isSubset([fc(["P"]),Fr.ammpSet("label_atom_id")]),Fr.core.logic.or([Fr.core.set.isSubset([fc(["O3'","C3'","C4'","C5'","O5'"]),Fr.ammpSet("label_atom_id")]),Fr.core.set.isSubset([fc(["O3*","C3*","C4*","C5*","O5*"]),Fr.ammpSet("label_atom_id")])])])})}function KK(){return Fr.struct.combinator.merge([Fr.struct.generator.queryInSelection({0:Yd(),query:Fr.struct.generator.atomGroups({"atom-test":Fr.core.set.has([fc(ZK.protein),Fr.ammp("label_atom_id")])})}),Fr.struct.generator.queryInSelection({0:$B(),query:Fr.struct.generator.atomGroups({"atom-test":Fr.core.set.has([fc(ZK.nucleic),Fr.ammp("label_atom_id")])})})])}function zf(e){return Fr.struct.generator.atomGroups({"residue-test":Fr.core.flags.hasAll([Fr.ammp("secondaryStructureFlags"),Fr.struct.type.secondaryStructureFlags(e)])})}var ZK={nucleic:["P","O3'","O5'","C5'","C4'","C3'","OP1","OP2","O3*","O5*","C5*","C4*","C3*"],protein:["C","N","CA","O"]},Wi={acidic:["ASP","GLU"],aliphatic:["ALA","GLY","ILE","LEU","VAL"],aromatic:["HIS","PHE","TRP","TYR"],at:["ADA","A","THY","T"],basic:["ARG","HIS","LYS"],buried:["ALA","LEU","VAL","ILE","PHE","CYS","MET","TRP"],cg:["CYT","C","GUA","G"],cyclic:["HIS","PHE","PRO","TRP","TYR"],hydrophobic:["ALA","LEU","VAL","ILE","PRO","PHE","MET","TRP"],medium:["VAL","THR","ASP","ASN","PRO","CYS","ASX","PCA","HYP"],neutral:["VAL","PHE","GLN","TYR","HIS","CYS","MET","TRP","ASX","GLX","PCA","HYP"],purine:["ADE","A","GUA","G"],pyrimidine:["CYT","C","THY","T","URI","U"],small:["ALA","GLY","SER"],water:["H2O","HH0","OHH","HOH","OH2","SOL","WAT","TIP","TIP2","TIP3","TIP4"]},JB={all:{"@desc":"everything",map:function(){return Fr.struct.generator.all()}},none:{"@desc":"nothing",map:function(){return Fr.struct.generator.empty()}},protein:{"@desc":"a residue with atoms named C, N, CA, and O",map:function(){return Yd()}},nucleic:{"@desc":"a residue with atoms named P, O1P, O2P and either O3', C3', C4', C5', O5' or O3*, C3*, C4*, C5*, O5*. This definition assumes that the base is phosphorylated, an assumption which will be corrected in the future.",map:function(){return $B()}},backbone:{"@desc":"the C, N, CA, and O atoms of a protein and the equivalent atoms in a nucleic acid.",map:function(){return KK()}},sidechain:{"@desc":"non-backbone atoms and bonds",map:function(){return $o(KK())}},water:{"@desc":"all atoms with the resname H2O, HH0, OHH, HOH, OH2, SOL, WAT, TIP, TIP2, TIP3 or TIP4",abbr:["waters"],map:function(){return tn(Wi.water)}},at:{"@desc":"residues named ADA A THY T",map:function(){return tn(Wi.at)}},acidic:{"@desc":"residues named ASP GLU",map:function(){return tn(Wi.acidic)}},acyclic:{"@desc":'"protein and not cyclic"',map:function(){return Fr.struct.modifier.intersectBy({0:Yd(),by:$o(tn(Wi.cyclic))})}},aliphatic:{"@desc":"residues named ALA GLY ILE LEU VAL",map:function(){return tn(Wi.aliphatic)}},alpha:{"@desc":"atom's residue is an alpha helix",map:function(){return zf(["alpha"])}},amino:{"@desc":"a residue with atoms named C, N, CA, and O",map:function(){return Yd()}},aromatic:{"@desc":"residues named HIS PHE TRP TYR",map:function(){return tn(Wi.aromatic)}},basic:{"@desc":"residues named ARG HIS LYS",map:function(){return tn(Wi.basic)}},bonded:{"@desc":"atoms for which numbonds > 0",map:function(){return dc(Fr.struct.filter.pick({0:Fr.struct.modifier.includeConnected({0:Fr.struct.generator.all(),"bond-test":Fr.core.flags.hasAny([Fr.struct.bondProperty.flags(),Fr.struct.type.bondFlags(["covalent","metallic","sulfide"])])}),test:Fr.core.rel.gr([Fr.struct.atomSet.atomCount(),1])}))}},buried:{"@desc":"residues named ALA LEU VAL ILE PHE CYS MET TRP",map:function(){return tn(Wi.buried)}},cg:{"@desc":"residues named CYT C GUA G",map:function(){return tn(Wi.cg)}},charged:{"@desc":'"basic or acidic"',map:function(){return tn(Wi.basic.concat(Wi.acidic))}},cyclic:{"@desc":"residues named HIS PHE PRO TRP TYR",map:function(){return tn(Wi.cyclic)}},hetero:{"@desc":'"not (protein or nucleic)"',map:function(){return $o(Fr.struct.combinator.merge([Yd(),$B()]))}},hydrogen:{"@desc":'name "[0-9]?H.*"',map:function(){return Fr.struct.generator.atomGroups({"atom-test":Fr.core.str.match([Fr.core.type.regex(["^[0-9]?[H].*$","i"]),Fr.core.type.str([Fr.ammp("label_atom_id")])])})}},large:{"@desc":'"protein and not (small or medium)"',map:function(){return Fr.struct.modifier.intersectBy({0:Yd(),by:$o(tn(Wi.small.concat(Wi.medium)))})}},medium:{"@desc":"residues named VAL THR ASP ASN PRO CYS ASX PCA HYP",map:function(){return tn(Wi.medium)}},neutral:{"@desc":"residues named VAL PHE GLN TYR HIS CYS MET TRP ASX GLX PCA HYP",map:function(){return tn(Wi.neutral)}},hydrophobic:{"@desc":"hydrophobic resname ALA LEU VAL ILE PRO PHE MET TRP",map:function(){return tn(Wi.hydrophobic)}},polar:{"@desc":'"protein and not hydrophobic"',map:function(){return Fr.struct.modifier.intersectBy({0:Yd(),by:$o(tn(Wi.hydrophobic))})}},purine:{"@desc":"residues named ADE A GUA G",map:function(){return tn(Wi.purine)}},pyrimidine:{"@desc":"residues named CYT C THY T URI U",map:function(){return tn(Wi.pyrimidine)}},small:{"@desc":"residues named ALA GLY SER",map:function(){return tn(Wi.small)}},surface:{"@desc":'"protein and not buried"',map:function(){return Fr.struct.modifier.intersectBy({0:Yd(),by:$o(tn(Wi.buried))})}},alpha_helix:{"@desc":"atom's residue is in an alpha helix",map:function(){return zf(["alpha"])}},pi_helix:{"@desc":"atom's residue is in a pi helix",map:function(){return zf(["pi"])}},helix_3_10:{"@desc":"atom's residue is in a 3-10 helix",map:function(){return zf(["3-10"])}},helix:{"@desc":"atom's residue is in an alpha or pi or 3-10 helix",map:function(){return zf(["helix"])}},extended_beta:{"@desc":"atom's residue is a beta sheet",map:function(){return zf(["sheet"])}},bridge_beta:{"@desc":"atom's residue is a beta sheet",map:function(){return zf(["strand"])}},sheet:{"@desc":"atom's residue is a beta sheet",map:function(){return zf(["beta"])}},turn:{"@desc":"atom's residue is in a turn conformation",map:function(){return zf(["turn"])}},coil:{"@desc":"atom's residue is in a coil conformation",map:function(){return Fr.struct.modifier.intersectBy({0:Yd(),by:zf(["none"])})}}};var xs=le,QK={sqr:{"@desc":"square of x","@examples":["sqr(2)"],map:function(e){return xs.core.math.pow([e,2])}},sqrt:{"@desc":"square root of x","@examples":["sqrt(2)"],map:function(e){return xs.core.math.sqrt([e])}},abs:{"@desc":"absolute value of x","@examples":["abs(2)"],map:function(e){return xs.core.math.abs([e])}},floor:{"@desc":"largest integer not greater than x","@examples":["floor(2)"],map:function(e){return xs.core.math.floor([e])}},ceil:{"@desc":"smallest integer not less than x","@examples":["ceil(2)"],map:function(e){return xs.core.math.ceil([e])}},sin:{"@desc":"sine of x","@examples":["sin(2)"],map:function(e){return xs.core.math.sin([e])}},cos:{"@desc":"cosine of x","@examples":["cos(2)"],map:function(e){return xs.core.math.cos([e])}},tan:{"@desc":"tangent of x","@examples":["tan(2)"],map:function(e){return xs.core.math.tan([e])}},atan:{"@desc":"arctangent of x","@examples":["atan(2)"],map:function(e){return xs.core.math.atan([e])}},asin:{"@desc":"arcsin of x","@examples":["asin(2)"],map:function(e){return xs.core.math.asin([e])}},acos:{"@desc":"arccos of x","@examples":["acos(2)"],map:function(e){return xs.core.math.acos([e])}},sinh:{"@desc":"hyperbolic sine of x","@examples":["sinh(2)"],map:function(e){return xs.core.math.sinh([e])}},cosh:{"@desc":"hyperbolic cosine of x","@examples":["cosh(2)"],map:function(e){return xs.core.math.cosh([e])}},tanh:{"@desc":"hyperbolic tangent of x","@examples":["tanh(2)"],map:function(e){return xs.core.math.tanh([e])}},exp:{"@desc":"e to the power x","@examples":["exp(2)"],map:function(e){return xs.core.math.exp([e])}},log:{"@desc":"natural log of x","@examples":["log(2)"],map:function(e){return xs.core.math.log([e])}},log10:{"@desc":"log base 10 of x","@examples":["log10(2)"],map:function(e){return xs.core.math.log10([e])}}};var Ha=le,_Pe=[{"@desc":"multiplication, division","@examples":[],name:"mul-div",type:xo,rule:qe.regexp(/\s*(\*|\/)\s*/,1),map:function(e,t,r){switch(e){case"*":return Ha.core.math.mult([t,r]);case"/":return Ha.core.math.div([t,r]);default:throw new Error("value operator '".concat(e,"' not supported"))}}},{"@desc":"addition, substraction","@examples":[],name:"add-sub",type:xo,rule:qe.regexp(/\s*(-|\+)\s*/,1),map:function(e,t,r){switch(e){case"-":return Ha.core.math.sub([t,r]);case"+":return Ha.core.math.add([t,r]);default:throw new Error("value operator '".concat(e,"' not supported"))}}},{"@desc":"value comparisons","@examples":[],name:"comparison",type:xo,rule:qe.alt(qe.regexp(/\s*(=~|==|>=|<=|=|!=|>|<)\s*/,1),qe.whitespace.result("=")),map:function(e,t,r){var n;if(t.head!==void 0?(t.head.name==="structure-query.atom-property.macromolecular.secondary-structure-flags"&&(n=Ha.core.flags.hasAny([t,Ww(r)])),t.head.name==="core.type.regex"&&(n=Ha.core.str.match([t,Ha.core.type.str([r])]))):r.head!==void 0?(r.head.name==="structure-query.atom-property.macromolecular.secondary-structure-flags"&&(n=Ha.core.flags.hasAny([r,Ww(t)])),r.head.name==="core.type.regex"&&(n=Ha.core.str.match([r,Ha.core.type.str([t])]))):e==="=~"&&(t.head?n=Ha.core.str.match([Ha.core.type.regex(["^".concat(r,"$"),"i"]),Ha.core.type.str([t])]):n=Ha.core.str.match([Ha.core.type.regex(["^".concat(t,"$"),"i"]),Ha.core.type.str([r])])),!n)switch(t.head&&(r=Cv(t,r)),r.head&&(t=Cv(r,t)),e){case"=":case"==":n=Ha.core.rel.eq([t,r]);break;case"!=":n=Ha.core.rel.neq([t,r]);break;case">":n=Ha.core.rel.gr([t,r]);break;case"<":n=Ha.core.rel.lt([t,r]);break;case">=":n=Ha.core.rel.gre([t,r]);break;case"<=":n=Ha.core.rel.lte([t,r]);break;default:throw new Error("value operator '".concat(e,"' not supported"))}return Ha.struct.generator.atomGroups({"atom-test":n})}}],wPe=qe.createLanguage({Parens:function(e){return qe.alt(e.Parens,e.Operator,e.Expression).wrap(qe.string("("),qe.string(")"))},Expression:function(e){return qe.alt(e.RangeListProperty,e.ValueQuery,e.Keywords)},NamedAtomProperties:function(){var e;return(e=qe).alt.apply(e,Hw(Wd))},Keywords:function(){var e;return(e=qe).alt.apply(e,cy(JB))},ValueRange:function(e){return qe.seq(e.Value.skip(qe.regexp(/\s+TO\s+/i)),e.Value).map(function(t){return{range:t}})},RangeListProperty:function(e){var t;return qe.seq((t=qe).alt.apply(t,Mx(Wd,/\s/)).skip(qe.whitespace),qe.alt(e.ValueRange,e.Value).sepBy1(qe.whitespace)).map(function(r){var n,a=r[0],i=r[1],o=[],s=[];i.forEach(function(f){f.range?s.push(Ha.core.rel.inRange([a,f.range[0],f.range[1]])):o.push(Cv(a,f,ZB))});var u=NK(s),c=zK(a,o),l;return u&&c?l=Ha.core.logic.or([u,c]):l=u||c,Ha.struct.generator.atomGroups((n={},n[GK(a)]=l,n))})},Operator:function(e){return hp(QB,qe.alt(e.Parens,e.Expression,e.ValueQuery))},Query:function(e){return qe.alt(e.Operator,e.Parens,e.Expression).trim(qe.optWhitespace)},Number:function(){return qe.regexp(/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/).map(Number).desc("number")},String:function(){var e=ly(Wd,JB,QB).sort(Ru).map(pd).join("|");return qe.alt(qe.regexp(new RegExp("(?!(".concat(e,"))[A-Z0-9_]+"),"i")),qe.regexp(/'((?:[^"\\]|\\.)*)'/,1),qe.regexp(/"((?:[^"\\]|\\.)*)"/,1).map(function(t){return Ha.core.type.regex(["^".concat(t,"$"),"i"])})).desc("string")},Value:function(e){return qe.alt(e.Number,e.String)},ValueParens:function(e){return qe.alt(e.ValueParens,e.ValueOperator,e.ValueExpressions).wrap(qe.string("("),qe.string(")"))},ValuePropertyNames:function(){var e;return(e=qe).alt.apply(e,Mx(Wd,/=~|==|>=|<=|=|!=|>|<|\)|\s|\+|-|\*|\//i))},ValueOperator:function(e){return hp(_Pe,qe.alt(e.ValueParens,e.ValueExpressions))},ValueExpressions:function(e){return qe.alt(e.ValueFunctions,e.Value,e.ValuePropertyNames)},ValueFunctions:function(e){var t;return(t=qe).alt.apply(t,VK(QK,e.ValueOperator))},ValueQuery:function(e){return qe.alt(e.ValueOperator.map(function(t){if(!t.head.name||!t.head.name.startsWith("structure-query.generator"))throw new Error("values must be part of an comparison, value '".concat(t,"'"));return t}))}}),$K=function(e){return wPe.Query.tryParse(e)};var JK={pymol:XK,vmd:$K,jmol:qK};var TPe=JK;function eZ(e,t){try{var r=TPe[e](t);return r}catch(n){throw console.error(n.message),n}}var APe=function(){function e(){this.map=new Map}return e.prototype.removeSymbol=function(t){this.map.delete(t.symbol.id)},e.prototype.addSymbol=function(t){this.map.has(t.symbol.id)&&console.warn("Symbol '".concat(t.symbol.id,"' already added. Call removeSymbol/removeCustomProps re-adding the symbol.")),this.map.set(t.symbol.id,t)},e.prototype.addCustomProp=function(t){if(t.symbols)for(var r=0,n=Object.keys(t.symbols);rt[1](e)}),ur(be.core.rel.gre,function(e,t){return t[0](e)>=t[1](e)}),ur(be.core.rel.inRange,function(e,t){var r=t[0](e);return r>=t[1](e)&&r<=t[2](e)}),ur(be.core.math.add,function(e,t){var r=0;if(typeof t.length=="number")for(var n=0,a=t.length;n0&&x.push(["assembly","Assembly"]),d&&(x.push(["symmetry-mates","Symmetry Mates"]),x.push(["symmetry","Symmetry (indices)"]),x.push(["symmetry-assembly","Symmetry (assembly)"])),{type:w.MappedStatic(c||"model",b,{options:x})}}e.getParams=t;function r(u,c){return!(c.name==="symmetry-assembly"||c.name==="symmetry"&&u.name==="symmetry")}e.canAutoUpdate=r;function n(u,c,l,f,d){return $(this,void 0,void 0,function(){var m,h,p,v,g,b;return J(this,function(x){switch(x.label){case 0:return m=void 0,h=jn.Provider.get(l),!f&&h&&h.assemblies.length!==0&&(f=h.assemblies[0].id),!h||h.assemblies.length===0?u.log.warn("Model '".concat(l.entryId,"' has no assembly, returning model structure.")):(m=kd.findAssembly(l,f||""),m||u.log.warn("Model '".concat(l.entryId,"' has no assembly called '").concat(f,"', returning model structure."))),p=Le.ofModel(l,d),m?(f=m.id,[4,eu.buildAssembly(p,f).runInContext(c)]):(v={label:"Model",description:Le.elementDescription(p)},[2,new he.Molecule.Structure(p,v)]);case 1:return g=x.sent(),b={label:"Assembly ".concat(f),description:Le.elementDescription(g)},[2,new he.Molecule.Structure(g,b)]}})})}function a(u,c,l,f,d){return $(this,void 0,void 0,function(){var m,h,p;return J(this,function(v){switch(v.label){case 0:return m=Le.ofModel(c,d),[4,eu.buildSymmetryRange(m,l,f).runInContext(u)];case 1:return h=v.sent(),p={label:"Symmetry [".concat(l,"] to [").concat(f,"]"),description:Le.elementDescription(h)},[2,new he.Molecule.Structure(h,p)]}})})}function i(u,c,l,f){return $(this,void 0,void 0,function(){var d,m,h;return J(this,function(p){switch(p.label){case 0:return d=Le.ofModel(c,f),[4,eu.builderSymmetryMates(d,l).runInContext(u)];case 1:return m=p.sent(),h={label:"Symmetry Mates",description:Le.elementDescription(m)},[2,new he.Molecule.Structure(m,h)]}})})}function o(u,c,l,f,d){return $(this,void 0,void 0,function(){var m,h,p;return J(this,function(v){switch(v.label){case 0:return m=Le.ofModel(c,d),[4,eu.buildSymmetryAssembly(m,l,f).runInContext(u)];case 1:return h=v.sent(),p={label:"Symmetry Assembly",description:Le.elementDescription(h)},[2,new he.Molecule.Structure(h,p)]}})})}function s(u,c,l,f){return $(this,void 0,void 0,function(){var d,m,h,h;return J(this,function(p){return d=f?.params,m=jn.Provider.get(l),!m||!f||f.name==="model"?(h=Le.ofModel(l,d),[2,new he.Molecule.Structure(h,{label:"Model",description:Le.elementDescription(h)})]):f.name==="auto"?m.assemblies.length===0?(h=Le.ofModel(l,d),[2,new he.Molecule.Structure(h,{label:"Model",description:Le.elementDescription(h)})]):[2,n(u,c,l,void 0,d)]:f.name==="assembly"?[2,n(u,c,l,f.params.id,d)]:f.name==="symmetry"?[2,a(c,l,f.params.ijkMin,f.params.ijkMax,d)]:f.name==="symmetry-mates"?[2,i(c,l,f.params.radius,d)]:f.name==="symmetry-assembly"?[2,o(c,l,f.params.generators,m,d)]:(cr(f),[2])})})}e.create=s})(Hf||(Hf={}));var es;(function(e){function t(s,u,c){return s.currentStructure!==c?!1:Ea.is(u)?!!s.script&&Ea.areEqual(s.script,u):s.expression===u}e.isUnchanged=t;function r(s,u){var c=Ea.is(u)?u:void 0,l=Ea.is(u)?Ea.toExpression(u):u,f=gp(l);return{script:c,expression:l,compiled:f,originalStructure:s,currentStructure:s}}e.create=r;function n(s,u){return s.compiled(new no(u))}e.run=n;function a(s,u){var c=r(s,u);return{entry:c,selection:n(c,s)}}e.createAndRun=a;function i(s,u){return s.currentStructure=u,s.compiled(new no(u))}e.updateStructure=i;function o(s,u,c){var l=st.unionStructure(u);s.label="".concat(c||"Selection"),s.description=Le.elementDescription(l),s.data=l}e.updateStructureObject=o})(es||(es={}));var IPe=new Set(["LI","NA","K","RB","CS","FR"]);function MPe(e){return IPe.has(e)}var RPe=new Set(["BE","MG","CA","SR","BA","RA"]);function BPe(e){return RPe.has(e)}var OPe=new Set(["ZN","GA","CD","IN","SN","HG","TI","PB","BI","PO","CN"]);function FPe(e){return OPe.has(e)}var LPe=new Set(["F","CL","BR","I","AT"]);function tO(e){return LPe.has(e)}function rO(e){var t=dp(e);return t>=21&&t<=29||t>=39&&t<=47||t>=72&&t<=79||t>=104&&t<=108}function kPe(e){var t=dp(e);return t>=57&&t<=71}function NPe(e){var t=dp(e);return t>=89&&t<=103}function oZ(e){return MPe(e)||BPe(e)||kPe(e)||NPe(e)||rO(e)||FPe(e)}var hn=function(e){return e.Type="Type",e.Structure="Structure Property",e.Atom="Atom Property",e.Bond="Bond Property",e.Residue="Residue Property",e.AminoAcid="Amino Acid",e.NucleicBase="Nucleic Base",e.Manipulate="Manipulate Selection",e.Validation="Validation",e.Misc="Miscellaneous",e.Internal="Internal",e}(hn||{});function xn(e,t,r){var n;r===void 0&&(r={});var a;return{label:e,expression:t,description:r.description||"",category:(n=r.category)!==null&&n!==void 0?n:hn.Misc,isHidden:!!r.isHidden,priority:r.priority||0,referencesCurrent:!!r.referencesCurrent,get query(){return a||(a=gp(t)),a},ensureCustomProperties:r.ensureCustomProperties,getSelection:function(i,o,s){return $(this,void 0,void 0,function(){var u,c;return J(this,function(l){switch(l.label){case 0:return u=i.managers.structure.selection.getStructure(s),c=u?st.Sequence(s,[u]):st.Empty(s),r.ensureCustomProperties?[4,r.ensureCustomProperties({runtime:o,assetManager:i.managers.asset},s)]:[3,2];case 1:l.sent(),l.label=2;case 2:return a||(a=gp(t)),[2,a(new no(s,{currentSelection:c}))]}})})}}}var UPe=xn("All",le.struct.generator.all(),{category:"",priority:1e3}),VPe=xn("Current Selection",le.internal.generator.current(),{category:"",referencesCurrent:!0}),GPe=xn("Polymer",le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":le.core.logic.and([le.core.rel.eq([le.ammp("entityType"),"polymer"]),le.core.str.match([le.re("(polypeptide|cyclic-pseudo-peptide|peptide-like|nucleotide|peptide nucleic acid)","i"),le.ammp("entitySubtype")])])})]),{category:hn.Type}),zPe=xn("Trace",le.struct.modifier.union([le.struct.combinator.merge([le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":le.core.rel.eq([le.ammp("entityType"),"polymer"]),"chain-test":le.core.set.has([le.set("sphere","gaussian"),le.ammp("objectPrimitive")])})]),le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":le.core.rel.eq([le.ammp("entityType"),"polymer"]),"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"atom-test":le.core.set.has([le.set("CA","P"),le.ammp("label_atom_id")])})])])]),{category:hn.Structure}),hy=le.core.logic.and([le.core.rel.eq([le.ammp("entityType"),"polymer"]),le.core.str.match([le.re("(polypeptide|cyclic-pseudo-peptide|peptide-like)","i"),le.ammp("entitySubtype")])]),Yw=le.core.logic.and([le.core.rel.eq([le.ammp("entityType"),"polymer"]),le.core.str.match([le.re("(nucleotide|peptide nucleic acid)","i"),le.ammp("entitySubtype")])]),Av=le.core.str.match([le.re("non-polymer|(amino|carboxy) terminus|peptide-like","i"),le.ammp("chemCompType")]),HPe=xn("Backbone",le.struct.modifier.union([le.struct.combinator.merge([le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":hy,"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":le.core.logic.not([Av]),"atom-test":le.core.set.has([le.set.apply(le,dn.toArray(uc)),le.ammp("label_atom_id")])})]),le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":Yw,"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":le.core.logic.not([Av]),"atom-test":le.core.set.has([le.set.apply(le,dn.toArray(X0)),le.ammp("label_atom_id")])})])])]),{category:hn.Structure}),jPe=xn("Sidechain",le.struct.modifier.union([le.struct.combinator.merge([le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":hy,"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":le.core.logic.not([Av]),"atom-test":le.core.logic.or([le.core.logic.not([le.core.set.has([le.set.apply(le,dn.toArray(uc)),le.ammp("label_atom_id")])])])})]),le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":Yw,"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":le.core.logic.not([Av]),"atom-test":le.core.logic.or([le.core.logic.not([le.core.set.has([le.set.apply(le,dn.toArray(X0)),le.ammp("label_atom_id")])])])})])])]),{category:hn.Structure}),qPe=xn("Sidechain with Trace",le.struct.modifier.union([le.struct.combinator.merge([le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":hy,"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":le.core.logic.not([Av]),"atom-test":le.core.logic.or([le.core.logic.not([le.core.set.has([le.set.apply(le,dn.toArray(uc)),le.ammp("label_atom_id")])]),le.core.rel.eq([le.ammp("label_atom_id"),"CA"]),le.core.logic.and([le.core.rel.eq([le.ammp("auth_comp_id"),"PRO"]),le.core.rel.eq([le.ammp("label_atom_id"),"N"])])])})]),le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":Yw,"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":le.core.logic.not([Av]),"atom-test":le.core.logic.or([le.core.logic.not([le.core.set.has([le.set.apply(le,dn.toArray(X0)),le.ammp("label_atom_id")])]),le.core.rel.eq([le.ammp("label_atom_id"),"P"])])})])])]),{category:hn.Structure}),WPe=xn("Protein",le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":hy})]),{category:hn.Type}),YPe=xn("Nucleic",le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":Yw})]),{category:hn.Type}),XPe=xn("Helix",le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":hy,"residue-test":le.core.flags.hasAny([le.ammp("secondaryStructureFlags"),le.core.type.bitflags([2])])})]),{category:hn.Structure,ensureCustomProperties:function(e,t){return Eo.attach(e,t)}}),KPe=xn("Beta Strand/Sheet",le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":hy,"residue-test":le.core.flags.hasAny([le.ammp("secondaryStructureFlags"),le.core.type.bitflags([4])])})]),{category:hn.Structure,ensureCustomProperties:function(e,t){return Eo.attach(e,t)}}),ZPe=xn("Water",le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":le.core.rel.eq([le.ammp("entityType"),"water"])})]),{category:hn.Type}),QPe=xn("Ion",le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":le.core.rel.eq([le.ammp("entitySubtype"),"ion"])})]),{category:hn.Type}),$Pe=xn("Lipid",le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":le.core.rel.eq([le.ammp("entitySubtype"),"lipid"])})]),{category:hn.Type}),Xw=xn("Carbohydrate",le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":le.core.logic.or([le.core.rel.eq([le.ammp("entityType"),"branched"]),le.core.logic.and([le.core.rel.eq([le.ammp("entityType"),"non-polymer"]),le.core.str.match([le.re("oligosaccharide","i"),le.ammp("entitySubtype")])])])})]),{category:hn.Type}),uZ=xn("Carbohydrate with Connected",le.struct.modifier.union([le.struct.modifier.includeConnected({0:Xw.expression,"layer-count":1,"as-whole-residues":!0})]),{category:hn.Internal,isHidden:!0}),cZ=xn("Connected to Carbohydrate",le.struct.modifier.union([le.struct.modifier.exceptBy({0:uZ.expression,by:Xw.expression})]),{category:hn.Internal,isHidden:!0}),nO=xn("Ligand",le.struct.modifier.union([le.struct.modifier.exceptBy({0:le.struct.modifier.union([le.struct.combinator.merge([le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":le.core.logic.and([le.core.logic.or([le.core.rel.eq([le.ammp("entityType"),"non-polymer"]),le.core.rel.neq([le.ammp("entityPrdId"),""])]),le.core.logic.not([le.core.str.match([le.re("(oligosaccharide|lipid|ion)","i"),le.ammp("entitySubtype")])])]),"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":le.core.logic.not([le.core.str.match([le.re("saccharide","i"),le.ammp("chemCompType")])])})]),le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":le.core.rel.eq([le.ammp("entityType"),"polymer"]),"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":Av})])])]),by:le.struct.combinator.merge([le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":le.core.rel.eq([le.ammp("entityType"),"polymer"]),"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":le.core.set.has([le.set.apply(le,dn.toArray(Fd)),le.ammp("label_comp_id")])})]),le.struct.generator.atomGroups({"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":le.core.set.has([le.set.apply(le,dn.toArray(BW)),le.ammp("label_comp_id")])})])})]),{category:hn.Type}),lZ=xn("Ligand with Connected",le.struct.modifier.union([le.struct.modifier.exceptBy({0:le.struct.modifier.union([le.struct.modifier.includeConnected({0:nO.expression,"layer-count":1,"as-whole-residues":!0,"bond-test":le.core.flags.hasAny([le.struct.bondProperty.flags(),le.core.type.bitflags([3])])})]),by:Xw.expression})]),{category:hn.Internal,isHidden:!0}),fZ=xn("Connected to Ligand",le.struct.modifier.union([le.struct.modifier.exceptBy({0:lZ.expression,by:nO.expression})]),{category:hn.Internal,isHidden:!0}),JPe=xn("Connected to Ligand or Carbohydrate",le.struct.modifier.union([le.struct.combinator.merge([cZ.expression,fZ.expression])]),{category:hn.Internal,isHidden:!0}),eEe=xn("Disulfide Bridges",le.struct.modifier.union([le.struct.combinator.merge([le.struct.modifier.union([le.struct.modifier.wholeResidues([le.struct.filter.isConnectedTo({0:le.struct.generator.atomGroups({"residue-test":le.core.set.has([le.set("CYS"),le.ammp("auth_comp_id")]),"atom-test":le.core.set.has([le.set("SG"),le.ammp("label_atom_id")])}),target:le.struct.generator.atomGroups({"residue-test":le.core.set.has([le.set("CYS"),le.ammp("auth_comp_id")]),"atom-test":le.core.set.has([le.set("SG"),le.ammp("label_atom_id")])}),"bond-test":!0})])]),le.struct.modifier.union([le.struct.modifier.wholeResidues([le.struct.modifier.union([le.struct.generator.bondedAtomicPairs({0:le.core.flags.hasAny([le.struct.bondProperty.flags(),le.core.type.bitflags([8])])})])])])])]),{category:hn.Bond}),tEe=xn("NOS Bridges",le.struct.modifier.union([le.struct.modifier.wholeResidues([le.struct.filter.isConnectedTo({0:le.struct.generator.atomGroups({"residue-test":le.core.set.has([le.set("CSO","LYS"),le.ammp("auth_comp_id")]),"atom-test":le.core.set.has([le.set("OD","NZ"),le.ammp("label_atom_id")])}),target:le.struct.generator.atomGroups({"residue-test":le.core.set.has([le.set("CSO","LYS"),le.ammp("auth_comp_id")]),"atom-test":le.core.set.has([le.set("OD","NZ"),le.ammp("label_atom_id")])}),"bond-test":!0})])]),{category:hn.Bond}),rEe=xn("Non-standard Residues in Polymers",le.struct.modifier.union([le.struct.generator.atomGroups({"entity-test":le.core.rel.eq([le.ammp("entityType"),"polymer"]),"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":le.ammp("isNonStandard")})]),{category:hn.Residue}),nEe=xn("Coarse Elements",le.struct.modifier.union([le.struct.generator.atomGroups({"chain-test":le.core.set.has([le.set("sphere","gaussian"),le.ammp("objectPrimitive")])})]),{category:hn.Type}),aEe=xn("Rings in Residues",le.struct.modifier.union([le.struct.generator.rings()]),{category:hn.Residue}),iEe=xn("Aromatic Rings in Residues",le.struct.modifier.union([le.struct.generator.rings({"only-aromatic":!0})]),{category:hn.Residue}),oEe=xn("Surrounding Residues (5 \u212B) of Selection",le.struct.modifier.union([le.struct.modifier.exceptBy({0:le.struct.modifier.includeSurroundings({0:le.internal.generator.current(),radius:5,"as-whole-residues":!0}),by:le.internal.generator.current()})]),{description:"Select residues within 5 \u212B of the current selection.",category:hn.Manipulate,referencesCurrent:!0}),sEe=xn("Surrounding Ligands (5 \u212B) of Selection",le.struct.modifier.union([le.struct.modifier.surroundingLigands({0:le.internal.generator.current(),radius:5,"include-water":!0})]),{description:"Select ligand components within 5 \u212B of the current selection.",category:hn.Manipulate,referencesCurrent:!0}),uEe=xn("Surrounding Atoms (5 \u212B) of Selection",le.struct.modifier.union([le.struct.modifier.exceptBy({0:le.struct.modifier.includeSurroundings({0:le.internal.generator.current(),radius:5,"as-whole-residues":!1}),by:le.internal.generator.current()})]),{description:"Select atoms within 5 \u212B of the current selection.",category:hn.Manipulate,referencesCurrent:!0}),cEe=xn("Inverse / Complement of Selection",le.struct.modifier.union([le.struct.modifier.exceptBy({0:le.struct.generator.all(),by:le.internal.generator.current()})]),{description:"Select everything not in the current selection.",category:hn.Manipulate,referencesCurrent:!0}),lEe=xn("Residues Covalently Bonded to Selection",le.struct.modifier.union([le.struct.modifier.includeConnected({0:le.internal.generator.current(),"layer-count":1,"as-whole-residues":!0})]),{description:"Select residues covalently bonded to current selection.",category:hn.Manipulate,referencesCurrent:!0}),fEe=xn("Covalently Bonded Component",le.struct.modifier.union([le.struct.modifier.includeConnected({0:le.internal.generator.current(),"fixed-point":!0})]),{description:"Select covalently bonded component based on current selection.",category:hn.Manipulate,referencesCurrent:!0}),dEe=xn("Residues with Cov. or Metallic Bond to Selection",le.struct.modifier.union([le.struct.modifier.includeConnected({0:le.internal.generator.current(),"layer-count":1,"as-whole-residues":!0,"bond-test":le.core.flags.hasAny([le.struct.bondProperty.flags(),le.core.type.bitflags([3])])})]),{description:"Select residues with covalent or metallic bond to current selection.",category:hn.Manipulate,referencesCurrent:!0}),mEe=xn("Whole Residues of Selection",le.struct.modifier.union([le.struct.modifier.wholeResidues({0:le.internal.generator.current()})]),{description:"Expand current selection to whole residues.",category:hn.Manipulate,referencesCurrent:!0}),pEe=[[["HIS"],"Histidine"],[["ARG"],"Arginine"],[["LYS"],"Lysine"],[["ILE"],"Isoleucine"],[["PHE"],"Phenylalanine"],[["LEU"],"Leucine"],[["TRP"],"Tryptophan"],[["ALA"],"Alanine"],[["MET"],"Methionine"],[["PRO"],"Proline"],[["CYS"],"Cysteine"],[["ASN"],"Asparagine"],[["VAL"],"Valine"],[["GLY"],"Glycine"],[["SER"],"Serine"],[["GLN"],"Glutamine"],[["TYR"],"Tyrosine"],[["ASP"],"Aspartic Acid"],[["GLU"],"Glutamic Acid"],[["THR"],"Threonine"],[["SEC"],"Selenocysteine"],[["PYL"],"Pyrrolysine"],[["UNK"],"Unknown"]].sort(function(e,t){return e[1]t[1]?1:0}),hEe=[[["A","DA"],"Adenosine"],[["C","DC"],"Cytidine"],[["T","DT"],"Thymidine"],[["G","DG"],"Guanosine"],[["I","DI"],"Inosine"],[["U","DU"],"Uridine"],[["N","DN"],"Unknown"]].sort(function(e,t){return e[1]t[1]?1:0});function sZ(e,t,r){var n=e[0],a=e[1];r===void 0&&(r=0);var i=n.length===1&&!vEe.has(n[0])?"[".concat(n[0],"] ").concat(a):"".concat(a," (").concat(n.join(", "),")");return xn(i,le.struct.modifier.union([le.struct.generator.atomGroups({"residue-test":le.core.set.has([le.set.apply(le,n),le.ammp("auth_comp_id")])})]),{category:t,priority:r,description:i})}var vEe=dn.unionMany(rw,Z0,Q0,K0);var Ci={all:UPe,current:VPe,polymer:GPe,trace:zPe,backbone:HPe,sidechain:jPe,sidechainWithTrace:qPe,protein:WPe,nucleic:YPe,helix:XPe,beta:KPe,water:ZPe,ion:QPe,lipid:$Pe,branched:Xw,branchedPlusConnected:uZ,branchedConnectedOnly:cZ,ligand:nO,ligandPlusConnected:lZ,ligandConnectedOnly:fZ,connectedOnly:JPe,disulfideBridges:eEe,nosBridges:tEe,nonStandardPolymer:rEe,coarse:nEe,ring:aEe,aromaticRing:iEe,surroundings:oEe,surroundingLigands:sEe,surroundingAtoms:uEe,complement:cEe,covalentlyBonded:lEe,covalentlyOrMetallicBonded:dEe,covalentlyBondedComponent:fEe,wholeResidues:mEe},dZ=function(){function e(){var t,r;this.list=[],this.options=[],this.version=1,(t=this.list).push.apply(t,Ut(Ut(Ut([],Object.values(Ci),!1),pEe.map(function(n){return sZ(n,hn.AminoAcid)}),!1),hEe.map(function(n){return sZ(n,hn.NucleicBase)}),!1)),(r=this.options).push.apply(r,this.list.map(function(n){return[n,n.label,n.category]}))}return e.prototype.add=function(t){this.list.push(t),this.options.push([t,t.label,t.category]),this.version+=1},e.prototype.remove=function(t){var r=this.list.indexOf(t);r!==-1&&(this.list.splice(r,1),this.options.splice(r,1),this.version+=1)},e}();var mZ=function(){return{type:w.MappedStatic("static",{static:w.Text("polymer"),expression:w.Value(le.struct.generator.all),bundle:w.Value(ie.Bundle.Empty),script:w.Script({language:"mol-script",expression:"(sel.atom.all)"})},{isHidden:!0}),nullIfEmpty:w.Optional(w.Boolean(!0,{isHidden:!0})),label:w.Text("",{isHidden:!0})}};function pZ(e,t,r){r.source=e;var n=Le.Empty,a=void 0;switch(t.type.name){case"static":{var i=void 0;switch(t.type.params){case"all":i=Ci.all.query,a="All";break;case"polymer":i=Ci.polymer.query,a="Polymer";break;case"protein":i=Ci.protein.query,a="Protein";break;case"nucleic":i=Ci.nucleic.query,a="Nucleic";break;case"water":i=an.internal.water(),a="Water";break;case"ion":i=Ci.ion.query,a="Ion";break;case"lipid":i=Ci.lipid.query,a="Lipid";break;case"branched":i=Ci.branchedPlusConnected.query,a="Branched";break;case"ligand":i=Ci.ligandPlusConnected.query,a="Ligand";break;case"non-standard":i=Ci.nonStandardPolymer.query,a="Non-standard";break;case"coarse":i=Ci.coarse.query,a="Coarse";break;default:cr(t.type)}var o=i(new no(e));n=st.unionStructure(o);break}case"script":case"expression":{var s=es.createAndRun(e,t.type.params),u=s.selection,c=s.entry;r.entry=c,n=st.unionStructure(u);break}case"bundle":{if(t.type.params.hash!==e.hashCode)break;n=ie.Bundle.toStructure(t.type.params,e);break}}if(t.nullIfEmpty&&n.elementCount===0)return gn.Null;var l={label:"".concat(t.label||a||"Component"),description:Le.elementDescription(n)};return new he.Molecule.Structure(n,l)}function hZ(e,t,r,n,a){if(r.type.name!==n.type.name)return rt.UpdateResult.Recreate;var i=!1;switch(n.type.name){case"static":return r.type.params!==n.type.params?rt.UpdateResult.Recreate:Le.areEquivalent(e,a.source)?t.data.model===e.model?rt.UpdateResult.Unchanged:Vt.areHierarchiesEqual(e.model,t.data.model)?(t.data=t.data.remapModel(e.model),rt.UpdateResult.Updated):rt.UpdateResult.Recreate:rt.UpdateResult.Recreate;case"script":if(!Ea.areEqual(r.type.params,n.type.params))return rt.UpdateResult.Recreate;case"expression":{if(r.type.params!==n.type.params)return rt.UpdateResult.Recreate;if(e===a.source)break;var o=a.entry,s=es.updateStructure(o,e);a.source=e,t.data=st.unionStructure(s),es.updateStructureObject(t,s,n.label),i=!0;break}case"bundle":{if(e===a.source&&ie.Bundle.areEqual(r.type.params,n.type.params))break;a.source=e,n.type.params.hash!==e.hashCode?(i=t.data.elementCount!==0,t.data=t.data.elementCount===0?t.data:Le.Empty):(i=!0,t.data=ie.Bundle.toStructure(n.type.params,e));break}}if(i){if(n.nullIfEmpty&&t.data.elementCount===0)return rt.UpdateResult.Null;t.description=Le.elementDescription(t.data)}return r.label!==n.label&&(i=!0,t.label="".concat(n.label||t.label)),i?rt.UpdateResult.Updated:rt.UpdateResult.Unchanged}function vZ(e){switch(e){case 7:return-3;case 6:return-2;case 5:return-1;case 0:return 0;case 3:return 1;case 2:return 2;case 1:return 3;case 4:return 0;default:return console.error("Value ".concat(e," is outside the 0-7 range, defaulting to 0.")),0}}function aO(e,t){for(var r=We.create(e.data,t*2),n=We.create(e.data,t*2),a=We.create(e.data,t*2),i=We.create(e.data,t*2),o=We.create(e.data,t*2),s=0;s0)for(f=0;f0&&(g=ne.ofIntArray(ne.mapToArray(a.atomIdxA,function(C){return C-1},Int32Array)),b=ne.ofIntArray(ne.mapToArray(a.atomIdxB,function(C){return C-1},Int32Array)),x=ne.asArrayColumn(a.order,Int32Array),S=$a.fromData({pairs:{indexA:g,indexB:b,order:x},count:n.count},{maxDistance:1/0}),$a.Provider.set(v.representative,S)),[2,v]}})})}var sO;(function(e){function t(n){return n?.kind==="mol"}e.is=t;function r(n){return{kind:"mol",name:n.title,data:n}}e.create=r})(sO||(sO={}));function yZ(e){return Ce.create("Parse MOL",function(t){return uO(e,void 0,t)})}function bEe(e){var t=e.it_number.value(0),r=e["name_h-m_full"].value(0).replace("-"," ");return e.it_number.isDefined?(e["name_h-m_full"].isDefined,t):r}function xEe(e){var t=e.cell,r=e.space_group,n=bEe(r),a=Va.create(n,y.create(t.length_a.value(0),t.length_b.value(0),t.length_c.value(0)),y.scale(y(),y.create(t.angle_alpha.value(0),t.angle_beta.value(0),t.angle_gamma.value(0)),Math.PI/180));return{spacegroup:$i.create(a),assemblies:[],isNonStandardCrystalFrame:!1,ncsOperators:[]}}function SEe(e,t,r){var n;return $(this,void 0,void 0,function(){var a,i,o,s,u,c,l,f,d,m,h,p,v,g,de,b,x,S,_,C,E,D,de,T,A,E,de,I,R,B,O,z,k,G,V,U,Q,de,W,X,ae,q,F,j,Z,Y,H,N,ee,oe,me,pe,de,re,te,fe,ve;return J(this,function(De){switch(De.label){case 0:for(a=e.atom_site._rowCount,i=ne.ofConst("MOL",a,ne.Schema.str),o=ne.ofConst("A",a,ne.Schema.str),s=ne.ofConst(1,a,ne.Schema.int),u=xEe(e),c=u.spacegroup.cell.fromFractional,l=e.atom_site,f=l.fract_x,d=l.fract_y,m=l.fract_z,h=new Float32Array(a),p=new Float32Array(a),v=new Float32Array(a),g=y(),de=0;de0&&(G=k.representative,jn.Provider.set(G,u),V=e.geom_bond._rowCount,V>0)){for(U={},Q=e.atom_site.label,de=0,W=Q.rowCount;deMOLECULE"&&t.position")){r.mol_type=a,Jc(t);var i=el(t);if(!i.startsWith("@")){r.charge_type=i,Jc(t);var o=el(t);if(!o.startsWith("@")){r.status_bits=o,Jc(t);var s=el(t);s.startsWith("@")||(r.mol_comment=s)}}}}function PEe(e){return $(this,void 0,void 0,function(){var t,r,n,a,i,o,s,u,c,l,f,d,m,h,p,v,g,b,x,S,_,C,D;return J(this,function(T){switch(T.label){case 0:for(t=e.tokenizer,r=e.molecule;el(t)!=="@ATOM"&&t.position5?Qt(m)(ne.Schema.str):S,subst_id:s>6?Qt(h)(ne.Schema.int):x,subst_name:s>7?Qt(p)(ne.Schema.str):S,charge:s>8?Qt(v)(ne.Schema.float):b,status_bit:s>9?Qt(g)(ne.Schema.str):S},[2,D]}})})}function EEe(e){return $(this,void 0,void 0,function(){var t,r,n,a,i,o,s,u,c,l,f,d,m,h,p;return J(this,function(v){switch(v.label){case 0:for(t=e.tokenizer,r=e.molecule;el(t)!=="@BOND"&&t.position4?Qt(d)(ne.Schema.str):ne.Undefined(r.num_bonds,ne.Schema.str)},[2,p]}})})}function IEe(e){for(var t=e.tokenizer;t.positionMOLECULE")return;if(r==="@CRYSIN")break;Jc(t)}if(!(t.position>=t.data.length)){Jc(t);var n=el(t).trim().split(_Z);return{a:parseFloat(n[0]),b:parseFloat(n[1]),c:parseFloat(n[2]),alpha:parseFloat(n[3]),beta:parseFloat(n[4]),gamma:parseFloat(n[5]),spaceGroup:parseInt(n[6],10),setting:parseInt(n[7],10)}}}function MEe(e,t,r){return $(this,void 0,void 0,function(){var n,a,i,o,s,u,c;return J(this,function(l){switch(l.label){case 0:n=at(t),e.update({message:"Parsing...",current:0,max:t.length}),a=[],l.label=1;case 1:return n.positionMOLECULE"&&n.position0&&(C=ne.ofIntArray(ne.mapToArray(u.origin_atom_id,function(z){return z-1},Int32Array)),D=ne.ofIntArray(ne.mapToArray(u.target_atom_id,function(z){return z-1},Int32Array)),T=u.bond_id,A=ne.ofIntArray(ne.mapToArray(u.bond_type,function(z){switch(z){case"ar":case"am":case"un":return 1;case"du":case"nc":return 0;default:return parseInt(z)}},Int8Array)),E=ne.ofIntArray(ne.mapToArray(u.bond_type,function(z){switch(z){case"ar":case"am":return 17;case"du":case"nc":return 0;case"un":default:return 1}},Int8Array)),I=$a.fromData({pairs:{key:T,indexA:C,indexB:D,order:A,flag:E},count:s.count},{maxDistance:c?-1:1/0}),R=_.representative,$a.Provider.set(R,I),zd.Provider.set(R,{data:s.charge,type:o.charge_type}),c&&(B=BEe(c),B&&jn.Provider.set(R,B)),r.push(R)),O.label=3;case 3:return++n,[3,1];case 4:return[2,new nu(r)]}})})}function BEe(e){if(e.setting===1){var t=Va.create(e.spaceGroup,y.create(e.a,e.b,e.c),y.scale(y(),y.create(e.alpha,e.beta,e.gamma),Math.PI/180));return{spacegroup:$i.create(t),assemblies:[],isNonStandardCrystalFrame:!1,ncsOperators:[]}}}var fO;(function(e){function t(n){return n?.kind==="mol2"}e.is=t;function r(n){return{kind:"mol2",name:n.name,data:n}}e.create=r})(fO||(fO={}));function TZ(e){return Ce.create("Parse MOL2",function(t){return REe(e,t)})}var vy=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]),dO=9,Ou;(function(e){function t(l){for(var f=1,d=0;l>=f&&d<32;)d++,f<<=1;return d}e.sizeOfInt=t;var r=new Uint8Array(32);function n(l,f){var d=1,m=0;r[0]=1;for(var h=0;h>=8;for(;v!==0;)r[p++]=v&255,v>>=8;d=p}var g=1;for(d--;r[d]>=g;)m++,g*=2;return m+d*8}e.sizeOfInts=n;var a=new ArrayBuffer(8*3);e.buf=new Int32Array(a);var i=new Uint32Array(a);function o(l,f,d){for(var m=d,h=(1<=8;)v=v<<8|l[f+g++],b|=v>>p<0&&(p>p&(1<>i[1]&255}var u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];function c(l,f,d,m,h){var p=d,v=0;for(u[0]=0,u[1]=0,u[2]=0,u[3]=0;p>8;)u[v++]=s(l,f),p-=8;p>0&&(u[v++]=o(l,f,p));for(var g=2;g>0;g--){for(var b=0,x=m[g],S=v-1;S>=0;S--){b=b<<8|u[S];var _=b/x|0;u[S]=_,b=b-_*x}h[g]=b}h[0]=u[0]|u[1]<<8|u[2]<<16|u[3]<<24}e.decodeInts=c})(Ou||(Ou={}));function OEe(){throw new Error("(xdrfile error) Undefined error.")}function FEe(e,t){return $(this,void 0,void 0,function(){var r,n,a,i,o,s,u,c,l,f,d,m,h,p,v,g,B,B,b,x,S,_,C,D,T,A,E,I,R,B,O,z,k,G,V;return J(this,function(U){switch(U.label){case 0:r=new DataView(t.buffer,t.byteOffset),n={frames:[],boxes:[],times:[],timeOffset:0,deltaTime:0},a=n.frames,i=n.boxes,o=n.times,s=[0,0,0,0,0,0],u=[0,0,0],c=[0,0,0],l=[0,0,0],f=[.1,.1,.1],d=[.1,.1,.1],m=0,h=Ou.buf,U.label=1;case 1:for(p=void 0,v=r.getInt32(m+4),m+=12,o.push(r.getFloat32(m)),m+=4,g=new Float32Array(9),B=0;B<9;++B)g[B]=r.getFloat32(m)*10,m+=4;if(i.push(g),v<=9)for(p={count:v/3,x:new Float32Array(v/3),y:new Float32Array(v/3),z:new Float32Array(v/3)},B=0;B16777215?(c[0]=Ou.sizeOfInt(u[0]),c[1]=Ou.sizeOfInt(u[1]),c[2]=Ou.sizeOfInt(u[2]),_=0):_=Ou.sizeOfInts(3,u),C=r.getInt32(m),m+=4,D=C-1,D=dO>D?dO:D,T=vy[D]/2|0,A=vy[C]/2|0,l[0]=l[1]=l[2]=vy[C],E=Math.ceil(r.getInt32(m)/4)*4,m+=4,I=1/S,R=0,B=0,f[0]=f[1]=f[2]=0;B0)for(f[0]=f[1]=f[2]=0,k=0;kdO?T=vy[C-1]/2|0:T=0):z>0&&(T=A,A=vy[C]/2|0),l[0]=l[1]=l[2]=vy[C],(l[0]===0||l[1]===0||l[2]===0)&&OEe()}m+=E}for(V=0;V=t.length?[3,4]:[3,1];case 4:return o.length>=1&&(n.timeOffset=o[0]),o.length>=2&&(n.deltaTime=o[1]-o[0]),[2,n]}})})}function AZ(e){var t=this;return Ce.create("Parse XTC",function(r){return $(t,void 0,void 0,function(){var n,a;return J(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r.update({canAbort:!0,message:"Parsing trajectory..."}),[4,FEe(r,e)];case 1:return n=i.sent(),[2,wr.success(n)];case 2:return a=i.sent(),[2,wr.error(""+a)];case 3:return[2]}})})})}function DZ(e){var t=this;return Ce.create("Parse XTC",function(r){return $(t,void 0,void 0,function(){var n,a,i,o,s,u,c,l,f;return J(this,function(d){switch(d.label){case 0:return[4,r.update("Converting to coordinates")];case 1:for(d.sent(),n=Zo(e.deltaTime,"step"),a=Zo(e.timeOffset,n.unit),i=[],o=0,s=e.frames.length;o=e.data.length-1?0:+at.readLine(e);isNaN(t)&&(t=0);for(var r=at.readLine(e),n=new Float64Array(t),a=new Float64Array(t),i=new Float64Array(t),o=new Array(t),s=0;s ")){We.add(t,e.tokenStart+2,e.tokenEnd),at.markLine(e);for(var a=e.tokenStart,i=e.tokenEnd,o=!1;e.position ")){We.add(r,a,i),o=!0;break}i=e.tokenEnd}o||We.add(r,a,i)}}return{dataHeader:Qt(t)(ne.Schema.str),data:Qt(r)(ne.Schema.str)}}function VEe(e){return{atomCount:+e.substr(0,3),bondCount:+e.substr(3,3)}}function GEe(e){var t=at.readLine(e).trim(),r=at.readLine(e).trim(),n=at.readLine(e).trim(),a=at.readLine(e),i=IZ(a),o=i?MZ(e):VEe(a),s=o.atomCount,u=o.bondCount;if(Number.isNaN(s)||Number.isNaN(u)){for(;e.position>8&65280|C>>24&255;for(D=new Float32Array(e.buffer,o,v),T=0;T=e.byteLength)break}return i.length>=1&&(r.timeOffset=i[0]),i.length>=2&&(r.deltaTime=i[1]-i[0]),[2,r]})})}function LZ(e){var t=this;return Ce.create("Parse TRR",function(r){return $(t,void 0,void 0,function(){var n,a;return J(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r.update({canAbort:!0,message:"Parsing trajectory..."}),[4,HEe(e)];case 1:return n=i.sent(),[2,wr.success(n)];case 2:return a=i.sent(),[2,wr.error(""+a)];case 3:return[2]}})})})}function kZ(e){var t=this;return Ce.create("Parse TRR",function(r){return $(t,void 0,void 0,function(){var n,a,i,o,s,u,c,l,f;return J(this,function(d){switch(d.label){case 0:return[4,r.update("Converting to coordinates")];case 1:for(d.sent(),n=Zo(e.deltaTime,"step"),a=Zo(e.timeOffset,n.unit),i=[],o=0,s=e.frames.length;o>>0:0,i=t.byteLength-a,o=a;t instanceof ArrayBuffer||(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+a),t=t.buffer),n?this._lastWrittenByte=i:this._lastWrittenByte=0,this.buffer=t,this.length=i,this.byteLength=i,this.byteOffset=o,this._data=new DataView(this.buffer,o,i)}return e.prototype.available=function(t){return t===void 0&&(t=1),this.offset+t<=this.length},e.prototype.isLittleEndian=function(){return this.littleEndian},e.prototype.setLittleEndian=function(){return this.littleEndian=!0,this},e.prototype.isBigEndian=function(){return!this.littleEndian},e.prototype.setBigEndian=function(){return this.littleEndian=!1,this},e.prototype.skip=function(t){return t===void 0&&(t=1),this.offset+=t,this},e.prototype.seek=function(t){return this.offset=t,this},e.prototype.mark=function(){return this._mark=this.offset,this},e.prototype.reset=function(){return this.offset=this._mark,this},e.prototype.pushMark=function(){return this._marks.push(this.offset),this},e.prototype.popMark=function(){var t=this._marks.pop();if(t===void 0)throw new Error("Mark stack empty");return this.seek(t),this},e.prototype.rewind=function(){return this.offset=0,this},e.prototype.ensureAvailable=function(t){if(t===void 0&&(t=1),!this.available(t)){var r=this.offset+t,n=r*2,a=new Uint8Array(n);a.set(new Uint8Array(this.buffer)),this.buffer=a.buffer,this.length=this.byteLength=n,this._data=new DataView(this.buffer)}return this},e.prototype.readBoolean=function(){return this.readUint8()!==0},e.prototype.readInt8=function(){return this._data.getInt8(this.offset++)},e.prototype.readUint8=function(){return this._data.getUint8(this.offset++)},e.prototype.readByte=function(){return this.readUint8()},e.prototype.readBytes=function(t){t===void 0&&(t=1);for(var r=new Uint8Array(t),n=0;nthis._lastWrittenByte&&(this._lastWrittenByte=this.offset)},e}();function tl(e,t){if(e)throw new TypeError("Not a valid NetCDF v3.x file: "+t)}function UZ(e){e.offset%4!==0&&e.skip(4-e.offset%4)}function gO(e){var t=e.readUint32(),r=e.readChars(t);return UZ(e),r}var _i={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function VZ(e){switch(Number(e)){case _i.BYTE:return"byte";case _i.CHAR:return"char";case _i.SHORT:return"short";case _i.INT:return"int";case _i.FLOAT:return"float";case _i.DOUBLE:return"double";default:return"undefined"}}function GZ(e){switch(Number(e)){case _i.BYTE:return 1;case _i.CHAR:return 1;case _i.SHORT:return 2;case _i.INT:return 4;case _i.FLOAT:return 4;case _i.DOUBLE:return 8;default:return-1}}function zZ(e){switch(String(e)){case"byte":return _i.BYTE;case"char":return _i.CHAR;case"short":return _i.SHORT;case"int":return _i.INT;case"float":return _i.FLOAT;case"double":return _i.DOUBLE;default:return-1}}function Kw(e,t){if(e!==1){for(var r=new Array(e),n=0;n6,"non valid type "+o);var s=e.readUint32(),u=yO(e,o,s);UZ(e),t[a]={name:i,type:VZ(o),value:u}}return t}function JEe(e,t,r){var n=e.readUint32(),a=0,i;if(n===gy)return tl(e.readUint32()!==gy,"wrong empty tag for list of variables"),[];tl(n!==KEe,"wrong tag for list of variables");var o=e.readUint32();i=new Array(o);for(var s=0;s6,"non valid type "+m);var h=e.readUint32(),p=e.readUint32();r===2&&(tl(p>0,"offsets larger than 4GB not supported"),p=e.readUint32()),l[0]===t&&(a+=h),i[s]={name:u,dimensions:l,attributes:d,type:VZ(m),size:h,offset:p,record:l[0]===t}}return{variables:i,recordStep:a}}var jZ=function(){function e(t){var r=new NZ(t);r.setBigEndian(),tl(r.readChars(3)!=="CDF","should start with CDF");var n=r.readByte();tl(n>2,"unknown version"),this.header=QEe(r,n),this.buffer=r}return Object.defineProperty(e.prototype,"version",{get:function(){return this.header.version===1?"classic format":"64-bit offset format"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"recordDimension",{get:function(){return this.header.recordDimension},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dimensions",{get:function(){return this.header.dimensions},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalAttributes",{get:function(){return this.header.globalAttributes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"variables",{get:function(){return this.header.variables},enumerable:!1,configurable:!0}),e.prototype.hasDataVariable=function(t){return this.header.variables&&this.header.variables.findIndex(function(r){return r.name===t})!==-1},e.prototype.getDataVariable=function(t){var r,n;if(typeof t=="string"?n=(r=this.header.variables)===null||r===void 0?void 0:r.find(function(a){return a.name===t}):n=t,n===void 0)throw new Error("variable not found");return this.buffer.seek(n.offset),n.record?YEe(this.buffer,n,this.header.recordDimension):WEe(this.buffer,n)},e}();function eIe(e){return $(this,void 0,void 0,function(){var t,r,n,a,i,o,s,u,c,l,f,d,m,h,p,v,g,b,x,S,_,C,D,T,A;return J(this,function(E){for(t=new jZ(e),r={coordinates:[],time:[],timeOffset:0,deltaTime:1},n=0,a=t.getDataVariable("coordinates");n=1&&(r.timeOffset=r.time[0]),r.time.length>=2&&(r.deltaTime=r.time[1]-r.time[0])),[2,r]})})}function qZ(e){var t=this;return Ce.create("Parse NCTRAJ",function(r){return $(t,void 0,void 0,function(){var n,a;return J(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r.update({canAbort:!0,message:"Parsing trajectory..."}),[4,eIe(e)];case 1:return n=i.sent(),[2,wr.success(n)];case 2:return a=i.sent(),[2,wr.error(""+a)];case 3:return[2]}})})})}function WZ(e){var t=this;return Ce.create("Parse NCTRAJ",function(r){return $(t,void 0,void 0,function(){var n,a,i,o,s,u,c,l,f,d,m,h,p,v,g,b,x;return J(this,function(S){switch(S.label){case 0:return[4,r.update("Converting to coordinates")];case 1:for(S.sent(),n=Zo(e.deltaTime,"step"),a=Zo(e.timeOffset,n.unit),i=[],o=0,s=e.coordinates.length;o0},apply:function(e){var t=this,r=e.a,n=e.params;return Ce.create("Parse mmCIF",function(a){return $(t,void 0,void 0,function(){var i,o,s,u,h,c,l,f,d,m,h,p,v,g,b;return J(this,function(x){switch(x.label){case 0:if(!n.loadAllBlocks)return[3,10];o=[],s=0,u=r.data.blocks,x.label=1;case 1:return s0},apply:function(e){var t=this,r=e.a,n=e.params;return Ce.create("Model from Trajectory",function(a){return $(t,void 0,void 0,function(){var i,o,s,u;return J(this,function(c){switch(c.label){case 0:return i=n.modelIndex%r.data.frameCount,i<0&&(i+=r.data.frameCount),[4,Ce.resolveInContext(r.data.getFrameAtIndex(i),a)];case 1:return o=c.sent(),s="Model ".concat(i+1),u=r.data.frameCount===1?void 0:"of ".concat(r.data.frameCount),[2,new he.Molecule.Model(o,{label:s,description:u})]}})})})},interpolate:function(e,t,r){var n=r>=1?t.modelIndex:e.modelIndex+Math.floor((t.modelIndex-e.modelIndex+1)*r);return{modelIndex:n}},dispose:function(e){var t=e.b;t?.data.customProperties.dispose()}}),wIe=It.BuiltIn({name:"structure-from-trajectory",display:{name:"Structure from Trajectory",description:"Create a molecular structure from a trajectory."},from:he.Molecule.Trajectory,to:he.Molecule.Structure})({apply:function(e){var t=this,r=e.a;return Ce.create("Build Structure",function(n){return $(t,void 0,void 0,function(){var a,i;return J(this,function(o){switch(o.label){case 0:return[4,Le.ofTrajectory(r.data,n)];case 1:return a=o.sent(),i={label:"Ensemble",description:Le.elementDescription(a)},[2,new he.Molecule.Structure(a,i)]}})})})},dispose:function(e){var t=e.b;t?.data.customPropertyDescriptors.dispose()}}),TIe=It.BuiltIn({name:"structure-from-model",display:{name:"Structure",description:"Create a molecular structure (model, assembly, or symmetry) from the specified model."},from:he.Molecule.Model,to:he.Molecule.Structure,params:function(e){return Hf.getParams(e&&e.data)}})({canAutoUpdate:function(e){var t=e.oldParams,r=e.newParams;return Hf.canAutoUpdate(t.type,r.type)},apply:function(e,t){var r=this,n=e.a,a=e.params;return Ce.create("Build Structure",function(i){return $(r,void 0,void 0,function(){return J(this,function(o){return[2,Hf.create(t,i,n.data,a&&a.type)]})})})},update:function(e){var t=e.a,r=e.b,n=e.oldParams,a=e.newParams;return Oo(n,a)?r.data.model===t.data?rt.UpdateResult.Unchanged:Vt.areHierarchiesEqual(t.data,r.data.model)?(r.data=r.data.remapModel(t.data),rt.UpdateResult.Updated):rt.UpdateResult.Recreate:rt.UpdateResult.Recreate},dispose:function(e){var t=e.b;t?.data.customPropertyDescriptors.dispose()}}),KZ=y(),ZZ=se(),QZ=se(),AIe=It.BuiltIn({name:"transform-structure-conformation",display:{name:"Transform Conformation"},isDecorator:!0,from:he.Molecule.Structure,to:he.Molecule.Structure,params:{transform:w.MappedStatic("components",{components:w.Group({axis:w.Vec3(y.create(1,0,0)),angle:w.Numeric(0,{min:-180,max:180,step:.1}),translation:w.Vec3(y.create(0,0,0))},{isFlat:!0}),matrix:w.Group({data:w.Mat4(se.identity()),transpose:w.Boolean(!1)},{isFlat:!0})},{label:"Kind"})}})({canAutoUpdate:function(e){var t=e.newParams;return t.transform.name!=="matrix"},apply:function(e){var t=e.a,r=e.params,n=se();if(r.transform.name==="components"){var a=r.transform.params,i=a.axis,o=a.angle,s=a.translation,u=t.data.boundary.sphere.center;se.fromTranslation(ZZ,y.negate(KZ,u)),se.fromTranslation(QZ,y.add(KZ,u,s));var c=se.fromRotation(se(),Math.PI/180*o,y.normalize(y(),i));se.mul3(n,QZ,c,ZZ)}else r.transform.name==="matrix"&&(se.copy(n,r.transform.params.data),r.transform.params.transpose&&se.transpose(n,n));var l=Le.transform(t.data,n);return new he.Molecule.Structure(l,{label:t.label,description:"".concat(t.description," [Transformed]")})},dispose:function(e){var t=e.b;t?.data.customPropertyDescriptors.dispose()}}),DIe=It.BuiltIn({name:"structure-selection-from-expression",display:{name:"Selection",description:"Create a molecular structure from the specified expression."},from:he.Molecule.Structure,to:he.Molecule.Structure,params:function(){return{expression:w.Value(le.struct.generator.all,{isHidden:!0}),label:w.Optional(w.Text("",{isHidden:!0}))}}})({apply:function(e){var t=e.a,r=e.params,n=e.cache,a=es.createAndRun(t.data,r.expression),i=a.selection,o=a.entry;if(n.entry=o,st.isEmpty(i))return gn.Null;var s=st.unionStructure(i),u={label:"".concat(r.label||"Selection"),description:Le.elementDescription(s)};return new he.Molecule.Structure(s,u)},update:function(e){var t=e.a,r=e.b,n=e.oldParams,a=e.newParams,i=e.cache;if(n.expression!==a.expression)return rt.UpdateResult.Recreate;var o=i.entry;if(o.currentStructure===t.data)return rt.UpdateResult.Unchanged;var s=es.updateStructure(o,t.data);return st.isEmpty(s)?rt.UpdateResult.Null:(es.updateStructureObject(r,s,a.label),rt.UpdateResult.Updated)},dispose:function(e){var t=e.b;t?.data.customPropertyDescriptors.dispose()}}),PIe=It.BuiltIn({name:"structure-multi-selection-from-expression",display:{name:"Multi-structure Measurement Selection",description:"Create selection object from multiple structures."},from:he.Root,to:he.Molecule.Structure.Selections,params:function(){return{selections:w.ObjectList({key:w.Text(void 0,{description:"A unique key."}),ref:w.Text(),groupId:w.Optional(w.Text()),expression:w.Value(le.struct.generator.empty)},function(e){return e.ref},{isHidden:!0}),isTransitive:w.Optional(w.Boolean(!1,{isHidden:!0,description:"Remap the selections from the original structure if structurally equivalent."})),label:w.Optional(w.Text("",{isHidden:!0}))}}})({apply:function(e){for(var t=e.params,r=e.cache,n=e.dependencies,a=new Map,i=[],o=0,s=0,u=t.selections;sHIe,VolumeFromCcp4:()=>kIe,VolumeFromCube:()=>UIe,VolumeFromDensityServerCif:()=>GIe,VolumeFromDsn6:()=>NIe,VolumeFromDx:()=>VIe,VolumeFromSegmentationCif:()=>zIe});function FIe(e){return e.originX===0&&e.originY===0&&e.originZ===0?y.create(e.NCSTART,e.NRSTART,e.NSSTART):y.create(e.originX/(e.xLength/e.NX),e.originY/(e.yLength/e.NY),e.originZ/(e.zLength/e.NZ))}function LIe(e){var t=aM(e);switch(t){case ko.Float32:return Float32Array;case ko.Int8:return Int8Array;case ko.Int16:return Int16Array;case ko.Uint16:return Uint16Array}throw Error("".concat(t," is not a supported value format."))}function tQ(e,t){var r=this;return Ce.create("Create Volume",function(n){return $(r,void 0,void 0,function(){var a,i,o,s,u,c,l,f,d,m,h,p,v,g,b,x,S;return J(this,function(_){return a=e.header,i=e.values,o=y.create(a.xLength,a.yLength,a.zLength),t&&t.voxelSize&&y.mul(o,o,t.voxelSize),s=y.create(vr(a.alpha),vr(a.beta),vr(a.gamma)),u=a.ISPG>65536?0:a.ISPG,c=Va.create(u||"P 1",o,s),l=y.create(a.MAPC-1,a.MAPR-1,a.MAPS-1),f=tr.convertToCanonicalAxisIndicesFastToSlow(l),d=[a.NX,a.NY,a.NZ],m=f([a.NC,a.NR,a.NS]),h=FIe(a),t?.offset&&y.add(h,h,t.offset),p=f(h),v=y.create(p[0]/d[0],p[1]/d[1],p[2]/d[2]),g=y.create(m[0]/d[0],m[1]/d[1],m[2]/d[2]),b=tr.Space(m,tr.invertAxisOrder(l),LIe(a)),x=tr.create(b,tr.Data1(i)),S=a.AMIN===0&&a.AMAX===0&&a.AMEAN===0&&a.ARMS===0,[2,{label:t?.label,entryId:t?.entryId,grid:{transform:{kind:"spacegroup",cell:c,fractionalBox:gt.create(v,y.add(y.zero(),v,g))},cells:x,stats:{min:isNaN(a.AMIN)||S?Nm(i):a.AMIN,max:isNaN(a.AMAX)||S?Lo(i):a.AMAX,mean:isNaN(a.AMEAN)||S?Um(i):a.AMEAN,sigma:isNaN(a.ARMS)||a.ARMS===0?Vm(i):a.ARMS}},sourceData:TO.create(e),customProperties:new eo,_propertyData:Object.create(null)}]})})})}var TO;(function(e){function t(n){return n?.kind==="ccp4"}e.is=t;function r(n){return{kind:"ccp4",name:n.name,data:n}}e.create=r})(TO||(TO={}));function rQ(e,t){var r=this;return Ce.create("Create Volume",function(n){return $(r,void 0,void 0,function(){var a,i,o,s,u,c,l,f,d,m,h,p;return J(this,function(v){return a=e.header,i=e.values,o=y.create(a.xlen,a.ylen,a.zlen),t&&t.voxelSize&&y.mul(o,o,t.voxelSize),s=y.create(vr(a.alpha),vr(a.beta),vr(a.gamma)),u=Va.create("P 1",o,s),c=[a.xRate,a.yRate,a.zRate],l=[a.xExtent,a.yExtent,a.zExtent],f=[a.xStart,a.yStart,a.zStart],d=y.create(f[0]/c[0],f[1]/c[1],f[2]/c[2]),m=y.create(l[0]/c[0],l[1]/c[1],l[2]/c[2]),h=tr.Space(l,[0,1,2],Float32Array),p=tr.create(h,tr.Data1(i)),[2,{label:t?.label,entryId:t?.entryId,grid:{transform:{kind:"spacegroup",cell:u,fractionalBox:gt.create(d,y.add(y.zero(),d,m))},cells:p,stats:{min:Nm(i),max:Lo(i),mean:Um(i),sigma:a.sigma!==void 0?a.sigma:Vm(i)}},sourceData:AO.create(e),customProperties:new eo,_propertyData:Object.create(null)}]})})})}var AO;(function(e){function t(n){return n?.kind==="dsn6"}e.is=t;function r(n){return{kind:"dsn6",name:n.name,data:n}}e.create=r})(AO||(AO={}));function nQ(e,t){var r=this;return Ce.create("Create Volume",function(){return $(r,void 0,void 0,function(){var n,a,i,o,s,u;return J(this,function(c){return n=e.header,a=e.values,i=tr.Space(n.dim,[0,1,2],Float64Array),o=tr.create(i,tr.Data1(a)),s=se.fromTranslation(se(),n.min),u=se.fromScaling(se(),n.h),se.mul(s,s,u),[2,{label:t?.label,entryId:t?.entryId,grid:{transform:{kind:"matrix",matrix:s},cells:o,stats:{min:Nm(a),max:Lo(a),mean:Um(a),sigma:Vm(a)}},sourceData:DO.create(e),customProperties:new eo,_propertyData:Object.create(null)}]})})})}var DO;(function(e){function t(n){return n?.kind==="dx"}e.is=t;function r(n){return{kind:"dx",name:n.name,data:n}}e.create=r})(DO||(DO={}));function aQ(e,t){var r=this;return Ce.create("Create Segmentation Volume",function(n){return $(r,void 0,void 0,function(){var a,i,o,s,u,c,l,f,d,m,h,p,v,g,b,x,G,V,S,_,C,D,T,A,E,I,R,B,O,z,k,G,V,U,Q,W,X;return J(this,function(ae){for(a=e.volume_data_3d_info,i=e.segmentation_data_3d,o=Va.create(a.spacegroup_number.value(0),y.ofArray(a.spacegroup_cell_size.value(0)),y.scale(y(),y.ofArray(a.spacegroup_cell_angles.value(0)),Math.PI/180)),s=a.axis_order.value(0),u=tr.convertToCanonicalAxisIndicesFastToSlow(s),c=u(a.sample_count.value(0)),l=tr.Space(c,tr.invertAxisOrder(s),Float32Array),f=tr.create(l,tr.Data1(i.values.toArray({array:Float32Array}))),d=y.ofArray(u(a.origin.value(0))),m=y.ofArray(u(a.dimensions.value(0))),h={label:t?.label,entryId:void 0,grid:{transform:{kind:"spacegroup",cell:o,fractionalBox:gt.create(d,y.add(y(),d,m))},cells:f,stats:{min:0,max:1,mean:0,sigma:1}},sourceData:PO.create(e),customProperties:new eo,_propertyData:{ownerId:t?.ownerId}},Je.PickingGranularity.set(h,"object"),p=new Map,v=new Map,g=e.segmentation_data_table,b=g.segment_id,x=g.set_id,G=0,V=b.rowCount;GQ[3]&&(Q[3]=C[0]),C[1]>Q[4]&&(Q[4]=C[1]),C[2]>Q[5]&&(Q[5]=C[2]));return W={},p.forEach(function(q,F){W[F]=gt.create(y.create(B,O,z),y.create(-1,-1,-1))}),Ua(k,function(q,F){v.get(parseInt(F)).forEach(function(j){var Z=W[j];q[0]Z.max[0]&&(Z.max[0]=q[3]),q[4]>Z.max[1]&&(Z.max[1]=q[4]),q[5]>Z.max[2]&&(Z.max[2]=q[5])})}),Je.Segmentation.set(h,{segments:p,sets:v,bounds:W,labels:(X=t?.segmentLabels)!==null&&X!==void 0?X:{}}),[2,h]})})})}var PO;(function(e){function t(n){return n?.kind==="segcif"}e.is=t;function r(n){return{kind:"segcif",name:n._name,data:n}}e.create=r})(PO||(PO={}));var kIe=It.BuiltIn({name:"volume-from-ccp4",display:{name:"Volume from CCP4/MRC/MAP",description:"Create Volume from CCP4/MRC/MAP data"},from:he.Format.Ccp4,to:he.Volume.Data,params:function(e){return{voxelSize:w.Vec3(y.create(1,1,1)),offset:w.Vec3(y.create(0,0,0)),entryId:w.Text("")}}})({apply:function(e){var t=this,r=e.a,n=e.params;return Ce.create("Create volume from CCP4/MRC/MAP",function(a){return $(t,void 0,void 0,function(){var i,o;return J(this,function(s){switch(s.label){case 0:return[4,tQ(r.data,P(P({},n),{label:r.data.name||r.label})).runInContext(a)];case 1:return i=s.sent(),o={label:i.label||"Volume",description:"Volume ".concat(r.data.header.NX,"\xD7").concat(r.data.header.NX,"\xD7").concat(r.data.header.NX)},[2,new he.Volume.Data(i,o)]}})})})},dispose:function(e){var t=e.b;t?.data.customProperties.dispose()}}),NIe=It.BuiltIn({name:"volume-from-dsn6",display:{name:"Volume from DSN6/BRIX",description:"Create Volume from DSN6/BRIX data"},from:he.Format.Dsn6,to:he.Volume.Data,params:function(e){return{voxelSize:w.Vec3(y.create(1,1,1)),entryId:w.Text("")}}})({apply:function(e){var t=this,r=e.a,n=e.params;return Ce.create("Create volume from DSN6/BRIX",function(a){return $(t,void 0,void 0,function(){var i,o;return J(this,function(s){switch(s.label){case 0:return[4,rQ(r.data,P(P({},n),{label:r.data.name||r.label})).runInContext(a)];case 1:return i=s.sent(),o={label:i.label||"Volume",description:"Volume ".concat(r.data.header.xExtent,"\xD7").concat(r.data.header.yExtent,"\xD7").concat(r.data.header.zExtent)},[2,new he.Volume.Data(i,o)]}})})})},dispose:function(e){var t=e.b;t?.data.customProperties.dispose()}}),UIe=It.BuiltIn({name:"volume-from-cube",display:{name:"Volume from Cube",description:"Create Volume from Cube data"},from:he.Format.Cube,to:he.Volume.Data,params:function(e){var t=e?w.Select(0,e.data.header.dataSetIds.map(function(r,n){return[n,"".concat(r)]})):w.Numeric(0);return{dataIndex:t,entryId:w.Text("")}}})({apply:function(e){var t=this,r=e.a,n=e.params;return Ce.create("Create volume from Cube",function(a){return $(t,void 0,void 0,function(){var i,o;return J(this,function(s){switch(s.label){case 0:return[4,Nq(r.data,P(P({},n),{label:r.data.name||r.label})).runInContext(a)];case 1:return i=s.sent(),o={label:i.label||"Volume",description:"Volume ".concat(r.data.header.dim[0],"\xD7").concat(r.data.header.dim[1],"\xD7").concat(r.data.header.dim[2])},[2,new he.Volume.Data(i,o)]}})})})},dispose:function(e){var t=e.b;t?.data.customProperties.dispose()}}),VIe=It.BuiltIn({name:"volume-from-dx",display:{name:"Parse DX",description:"Create volume from DX data."},from:he.Format.Dx,to:he.Volume.Data})({apply:function(e){var t=this,r=e.a;return Ce.create("Parse DX",function(n){return $(t,void 0,void 0,function(){var a,i;return J(this,function(o){switch(o.label){case 0:return[4,nQ(r.data,{label:r.data.name||r.label}).runInContext(n)];case 1:return a=o.sent(),i={label:a.label||"Volume",description:"Volume ".concat(r.data.header.dim[0],"\xD7").concat(r.data.header.dim[1],"\xD7").concat(r.data.header.dim[2])},[2,new he.Volume.Data(a,i)]}})})})},dispose:function(e){var t=e.b;t?.data.customProperties.dispose()}}),GIe=It.BuiltIn({name:"volume-from-density-server-cif",display:{name:"Volume from density-server CIF",description:"Identify and create all separate models in the specified CIF data block"},from:he.Format.Cif,to:he.Volume.Data,params:function(e){if(!e)return{blockHeader:w.Optional(w.Text(void 0,{description:"Header of the block to parse. If none is specifed, the 1st data block in the file is used."})),entryId:w.Text("")};var t=e.data.blocks.slice(1);return{blockHeader:w.Optional(w.Select(t[0]&&t[0].header,t.map(function(r){return[r.header,r.header]}),{description:"Header of the block to parse"})),entryId:w.Text("")}}})({isApplicable:function(e){return e.data.blocks.length>0},apply:function(e){var t=this,r=e.a,n=e.params;return Ce.create("Parse density-server CIF",function(a){return $(t,void 0,void 0,function(){var i,o,s,u,c,l,f,d,m,h;return J(this,function(p){switch(p.label){case 0:if(i=n.blockHeader||r.data.blocks[1].header,o=r.data.blocks.find(function(v){return v.header===i}),!o)throw new Error("Data block '".concat([i],"' not found."));return s=Es.schema.densityServer(o),[4,$_(s,{entryId:n.entryId}).runInContext(a)];case 1:return u=p.sent(),c=u.grid.cells.space.dimensions,l=c[0],f=c[1],d=c[2],m={label:(h=n.entryId)!==null&&h!==void 0?h:s.volume_data_3d_info.name.value(0),description:"Volume ".concat(l,"\xD7").concat(f,"\xD7").concat(d)},[2,new he.Volume.Data(u,m)]}})})})},dispose:function(e){var t=e.b;t?.data.customProperties.dispose()}}),zIe=It.BuiltIn({name:"volume-from-segmentation-cif",display:{name:"Volume from Segmentation CIF"},from:he.Format.Cif,to:he.Volume.Data,params:function(e){var t=e?.data.blocks.slice(1),r=t?w.Optional(w.Select(t[0]&&t[0].header,t.map(function(n){return[n.header,n.header]}),{description:"Header of the block to parse"})):w.Optional(w.Text(void 0,{description:"Header of the block to parse. If none is specifed, the 1st data block in the file is used."}));return{blockHeader:r,segmentLabels:w.ObjectList({id:w.Numeric(-1),label:w.Text("")},function(n){return"".concat(n.id," = ").concat(n.label)},{description:"Mapping of segment IDs to segment labels"}),ownerId:w.Text("",{isHidden:!0,description:"Reference to the object which manages this volume"})}}})({isApplicable:function(e){return e.data.blocks.length>0},apply:function(e){var t=this,r=e.a,n=e.params;return Ce.create("Parse segmentation CIF",function(a){return $(t,void 0,void 0,function(){var i,o,s,u,c,l,f,d,m,h,p,v,g;return J(this,function(b){switch(b.label){case 0:if(i=n.blockHeader||r.data.blocks[1].header,o=r.data.blocks.find(function(x){return x.header===i}),!o)throw new Error("Data block '".concat([i],"' not found."));for(s=Es.schema.segmentation(o),u={},c=0,l=n.segmentLabels;cMBe,ClippingStructureRepresentation3DFromScript:()=>IBe,ExplodeStructureRepresentation3D:()=>CBe,ModelUnitcell3D:()=>FBe,OverpaintStructureRepresentation3DFromBundle:()=>TBe,OverpaintStructureRepresentation3DFromScript:()=>wBe,ShapeRepresentation3D:()=>OBe,SpinStructureRepresentation3D:()=>_Be,StructureBoundingBox3D:()=>LBe,StructureRepresentation3D:()=>Ey,StructureSelectionsAngle3D:()=>NBe,StructureSelectionsDihedral3D:()=>UBe,StructureSelectionsDistance3D:()=>kBe,StructureSelectionsLabel3D:()=>VBe,StructureSelectionsOrientation3D:()=>GBe,StructureSelectionsPlane3D:()=>zBe,SubstanceStructureRepresentation3DFromBundle:()=>EBe,SubstanceStructureRepresentation3DFromScript:()=>PBe,ThemeStrengthRepresentation3D:()=>RBe,TransparencyStructureRepresentation3DFromBundle:()=>DBe,TransparencyStructureRepresentation3DFromScript:()=>ABe,UnwindStructureAssemblyRepresentation3D:()=>SBe,VolumeRepresentation3D:()=>BBe,VolumeRepresentation3DHelpers:()=>al});var Qw=Xe(13421772),jIe="Assigns colors according to the Symbol Nomenclature for Glycans (SNFG).",iQ={};function qIe(e){return iQ}function oQ(e,t){var r;if(e.structure){var n=e.structure.carbohydrates,a=n.elements,i=n.getElementIndices,o=function(s,u){if(!Te.isAtomic(s))return Qw;var c=i(s,u);return c.length>0?a[c[0]].component.color:Qw};r=function(s,u){return u?Nt.Secondary:ie.Location.is(s)?o(s.unit,s.element):mt.isLocation(s)?o(s.aUnit,s.aUnit.elements[s.aIndex]):Qw}}else r=function(){return Qw};return{factory:oQ,granularity:"group",color:r,props:t,description:jIe,legend:Is(yW)}}var sQ={name:"carbohydrate-symbol",label:"Carbohydrate Symbol",category:lr.Residue,factory:oQ,getParams:qIe,defaultValues:w.getDefaultValues(iQ),isApplicable:function(e){return!!e.structure&&e.structure.models.some(function(t){return Vt.hasCarbohydrate(t)})}};var IO={hue:w.Interval([1,360],{min:0,max:360,step:1}),chroma:w.Interval([40,70],{min:0,max:100,step:1}),luminance:w.Interval([15,85],{min:0,max:100,step:1}),sort:w.Select("contrast",w.arrayToOptions(["none","contrast"]),{description:"no sorting leaves colors approximately ordered by hue"}),clusteringStepCount:w.Numeric(50,{min:10,max:200,step:1},{isHidden:!0}),minSampleCount:w.Numeric(800,{min:100,max:5e3,step:100},{isHidden:!0}),sampleCountFactor:w.Numeric(5,{min:1,max:100,step:1},{isHidden:!0})},yy=2,Dv=[0,0,0],Pv=[0,0,0];function WIe(e,t){return hi.toHcl(Dv,e),hi.fromColor(Pv,hi.toColor(e)),Dv[0]>=t.hue[0]&&Dv[0]<=t.hue[1]&&Dv[1]>=t.chroma[0]&&Dv[1]<=t.chroma[1]&&Dv[2]>=t.luminance[0]&&Dv[2]<=t.luminance[1]&&Pv[0]>=e[0]-yy&&Pv[0]<=e[0]+yy&&Pv[1]>=e[1]-yy&&Pv[1]<=e[1]+yy&&Pv[2]>=e[2]-yy&&Pv[2]<=e[2]+yy}function YIe(e){for(var t=e.slice(0),r=[t.shift()];t.length>0;){for(var n=r[r.length-1],a=0,i=Number.NEGATIVE_INFINITY,o=0;oi&&(i=s,a=o)}r.push(t.splice(a,1)[0])}return r}function XIe(e,t){for(var r=new Map,n=Math.ceil(Math.cbrt(e)),a=yu(),i=Math.max((t.hue[1]-t.hue[0])/n,1),o=Math.max((t.chroma[1]-t.chroma[0])/n,1),s=Math.max((t.luminance[1]-t.luminance[0])/n,1),u=t.hue[0]+i/2;u<=t.hue[1];u+=i)for(var c=t.chroma[0]+o/2;c<=t.chroma[1];c+=o)for(var l=t.luminance[0]+s/2;l<=t.luminance[1];l+=s){var f=hi.fromHcl(hi(),yu.set(a,u,c,l));WIe(f,t)&&r.set(hi.toColor(f),f)}return Array.from(r.values())}function uQ(e,t){for(var r=1/0,n=0,a=0;a=e));s+=o);for(var u=1;u<=r.clusteringStepCount;++u){for(var c=hs(i),l=hs(n),s=0;s1?pQ(e.unit.model,r):r}function pQ(e,t){return"".concat(t,"|").concat((Vt.Index.get(e).value||0)+1)}function JIe(e,t){for(var r=new Map,n=function(s){var u=Vt.AsymIdOffset.get(s).value,c=(t==="auth"?u?.auth:u?.label)||0,l=0;s.properties.structAsymMap.forEach(function(f,d){var m=f.auth_id,h=t==="auth"?m:d,p=e.models.length>1?pQ(s,h):h;r.has(p)||(r.set(p,l+c),++l)})},a=0,i=e.models;aAo[RO].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params=P(P({},t.palette.defaultValue.params),{list:{kind:"interpolate",colors:vs(RO).list}})),t}function _Q(e,t){return"".concat(e,"|").concat(t)}function d3e(e,t,r,n,a,i){return"".concat(e,"|").concat(t,"|").concat(r,"|").concat(i||a||n)}function MO(e,t,r,n,a,i,o,s){for(var u=a.entity_id,c=a.pdbx_src_id,l=a.pdbx_beg_seq_num,f=a.pdbx_end_seq_num,d=0,m=a._rowCount;d0}};var PQ=Xe(13421772),v3e="Gives every structure a unique color based on its index.",Dp=P({},fa({type:"colors",colorList:"many-distinct"}));function g3e(e){return w.clone(Dp)}function Pp(e,t){var r,n,a;if(e.structure){var i=((r=Le.MaxIndex.get(e.structure).value)!==null&&r!==void 0?r:-1)+1,o=ba(i,t);a=o.legend,n=function(s){return ie.Location.is(s)?o.color(Le.Index.get(s.structure).value||0):mt.isLocation(s)?o.color(Le.Index.get(s.aStructure).value||0):PQ}}else n=function(){return PQ};return{factory:Pp,granularity:"instance",color:n,props:t,description:v3e,legend:a}}var EQ={name:"structure-index",label:"Structure Index",category:lr.Chain,factory:Pp,getParams:g3e,defaultValues:w.getDefaultValues(Dp),isApplicable:function(e){return!!e.structure&&e.structure.elementCount>0}};var BO="dark-2",IQ=Xe(13421772),y3e="Gives every chain instance (single chain or collection of single elements) a unique color based on the position (index) of the chain in the list of chains in the structure.",rT=P({},fa({type:"colors",colorList:BO}));function b3e(e){var t=w.clone(rT);return e.structure&&e.structure.root.units.length>Ao[BO].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params=P(P({},t.palette.defaultValue.params),{list:{kind:"interpolate",colors:vs(BO).list}})),t}function nT(e,t){var r,n;if(e.structure){var a=e.structure.root.units,i=ba(a.length,t);n=i.legend;for(var o=new Map,s=0,u=a.length;sAo[FO].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params=P(P({},t.palette.defaultValue.params),{list:{kind:"interpolate",colors:vs(FO).list}})),t}function UQ(e){switch(e.kind){case 0:return nt.chain.label_asym_id;case 1:case 2:return nt.coarse.asym_id}}function GQ(e){for(var t=new Map,r=0,n=e.unitSymmetryGroups.length;rAo[LO].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params=P(P({},t.palette.defaultValue.params),{list:{kind:"interpolate",colors:vs(LO).list}})),t}function WQ(e){for(var t=0,r=e.units,n=0,a=r.length;n0&&++t;return t}function YQ(e,t){var r,n;if(e.structure){var a=ba(WQ(e.structure.root),t);n=a.legend;for(var i=e.structure.root.units,o=new Map,s=0,u=0,c=i.length;s0&&(o.set(i[s].id,a.color(u)),++u);r=function(l){var f;return ie.Location.is(l)?f=o.get(l.unit.id):mt.isLocation(l)&&(f=o.get(l.aUnit.id)),f!==void 0?f:jQ}}else r=function(){return jQ};return{factory:YQ,granularity:"instance",color:r,props:t,description:P3e,legend:n}}var XQ={name:"polymer-index",label:"Polymer Chain Instance",category:lr.Chain,factory:YQ,getParams:E3e,defaultValues:w.getDefaultValues(qQ),isApplicable:function(e){return!!e.structure}};var QQ={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:15658734,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,A:14423100,G:3329330,I:10145074,C:16766720,T:4286945,U:4251856,DA:14423100,DG:3329330,DI:10145074,DC:16766720,DT:4286945,DU:4251856,APN:14423100,GPN:3329330,CPN:16766720,TPN:4286945},kO=Xe(16711935),I3e="Assigns a color to every residue according to its name.",sT={saturation:w.Numeric(0,{min:-6,max:6,step:.1}),lightness:w.Numeric(1,{min:-6,max:6,step:.1}),colors:w.MappedStatic("default",{default:w.EmptyGroup(),custom:w.Group(xp(QQ))})};function M3e(e){return sT}function KQ(e,t){return e.model.atomicHierarchy.atoms.label_comp_id.value(t)}function ZQ(e,t){var r=e.coarseElements.seq_id_begin.value(t),n=e.coarseElements.seq_id_end.value(t);if(r===n){var a=e.coarseElements.entityKey[t],i=e.model.sequence.byEntityKey[a].sequence;return i.compId.value(r-1)}}function oT(e,t){var r=e[t];return r===void 0?kO:r}function uT(e,t){var r=Em(t.colors.name==="default"?QQ:t.colors.params,t.saturation,t.lightness);function n(a){if(ie.Location.is(a))if(Te.isAtomic(a.unit)){var i=KQ(a.unit,a.element);return oT(r,i)}else{var i=ZQ(a.unit,a.element);if(i)return oT(r,i)}else if(mt.isLocation(a))if(Te.isAtomic(a.aUnit)){var i=KQ(a.aUnit,a.aUnit.elements[a.aIndex]);return oT(r,i)}else{var i=ZQ(a.aUnit,a.aUnit.elements[a.aIndex]);if(i)return oT(r,i)}return kO}return{factory:uT,granularity:"group",preferSmoothing:!0,color:n,props:t,description:I3e,legend:Is(Object.keys(r).map(function(a){return[a,r[a]]}).concat([["Unknown",kO]]))}}var $Q={name:"residue-name",label:"Residue Name",category:lr.Residue,factory:uT,getParams:M3e,defaultValues:w.getDefaultValues(sT),isApplicable:function(e){return!!e.structure}};var e$={alphaHelix:16711808,threeTenHelix:10485888,piHelix:6291584,betaTurn:6324479,betaStrand:16762880,coil:16777215,bend:6740169,turn:45670,dna:11403518,rna:16580962,carbohydrate:10921722},NO=Xe(8421504),R3e="Assigns a color based on the type of secondary structure and basic molecule type.",cT={saturation:w.Numeric(-1,{min:-6,max:6,step:.1}),lightness:w.Numeric(0,{min:-6,max:6,step:.1}),colors:w.MappedStatic("default",{default:w.EmptyGroup(),custom:w.Group(xp(e$))})};function B3e(e){return cT}function JQ(e,t,r,n){var a=Hr.create(0);if(n&&Te.isAtomic(t)){var i=n.get(t.invariantId);i&&(a=i.type[i.getIndex(t.residueIndex[r])])}if(Hr.is(a,2))return Hr.is(a,2048)?e.threeTenHelix:Hr.is(a,32768)?e.piHelix:e.alphaHelix;if(Hr.is(a,4))return e.betaStrand;if(Hr.is(a,8))return e.bend;if(Hr.is(a,16))return e.turn;var o=ey(t,r);return o===7?e.dna:o===6?e.rna:o===9?e.carbohydrate:o===5?e.coil:NO}function lT(e,t){var r=e.structure&&Eo.get(e.structure),n=r?bu(r.id,r.version):-1,a=Em(t.colors.name==="default"?e$:t.colors.params,t.saturation,t.lightness);function i(o){return ie.Location.is(o)?JQ(a,o.unit,o.element,r?.value):mt.isLocation(o)?JQ(a,o.aUnit,o.aUnit.elements[o.aIndex],r?.value):NO}return{factory:lT,granularity:"group",preferSmoothing:!0,color:i,props:t,contextHash:n,description:R3e,legend:Is(Object.keys(a).map(function(o){return[o,a[o]]}).concat([["Other",NO]]))}}var t$={name:"secondary-structure",label:"Secondary Structure",category:lr.Residue,factory:lT,getParams:B3e,defaultValues:w.getDefaultValues(cT),isApplicable:function(e){return!!e.structure},ensureCustomProperties:{attach:function(e,t){return t.structure?Eo.attach(e,t.structure,void 0,!0):Promise.resolve()},detach:function(e){return e.structure&&Eo.ref(e.structure,!1)}}};var O3e=Xe(13421772),F3e="Gives every polymer residue a color based on its `seq_id` value.",a$={list:w.ColorList("turbo",{presetKind:"scale"})};function L3e(e){return a$}function r$(e,t){var r=e.model;switch(e.kind){case 0:var n=r.atomicHierarchy.residueAtomSegments.index[t];return r.atomicHierarchy.residues.label_seq_id.value(n);case 1:return Math.round((r.coarseHierarchy.spheres.seq_id_begin.value(t)+r.coarseHierarchy.spheres.seq_id_end.value(t))/2);case 2:return Math.round((r.coarseHierarchy.gaussians.seq_id_begin.value(t)+r.coarseHierarchy.gaussians.seq_id_end.value(t))/2)}}function n$(e,t){var r=e.model,n="";switch(e.kind){case 0:var a=r.atomicHierarchy.chainAtomSegments.index[t];n=r.atomicHierarchy.chains.label_entity_id.value(a);break;case 1:n=r.coarseHierarchy.spheres.entity_id.value(t);break;case 2:n=r.coarseHierarchy.gaussians.entity_id.value(t);break}if(n==="")return 0;var i=r.entities.getEntityIndex(n);if(i===-1)return 0;var o=r.sequence.byEntityKey[i];return o===void 0?0:o.sequence.length}function i$(e,t){var r=Ti.create({listOrName:t.list.colors,minLabel:"Start",maxLabel:"End"}),n=function(a){if(ie.Location.is(a)){var i=a.unit,o=a.element,s=r$(i,o);if(s>0){var u=n$(i,o);if(u)return r.setDomain(0,u-1),r.color(s)}}else if(mt.isLocation(a)){var c=a.aUnit,l=a.aIndex,s=r$(c,c.elements[l]);if(s>0){var u=n$(c,c.elements[l]);if(u)return r.setDomain(0,u-1),r.color(s)}}return O3e};return{factory:i$,granularity:"group",preferSmoothing:!0,color:n,props:t,description:F3e,legend:r?r.legend:void 0}}var o$={name:"sequence-id",label:"Sequence Id",category:lr.Residue,factory:i$,getParams:L3e,defaultValues:w.getDefaultValues(a$),isApplicable:function(e){return!!e.structure}};var k3e=Xe(16777113),N3e="Assigns a color based on the uncertainty or disorder of an element's position, e.g. B-factor or RMSF, depending on the data availability and experimental technique.",u$={domain:w.Interval([0,100]),list:w.ColorList("red-white-blue",{presetKind:"scale"})};function U3e(e){return u$}function s$(e,t){return Te.isAtomic(e)?e.model.atomicConformation.B_iso_or_equiv.value(t):Te.isSpheres(e)?e.model.coarseConformation.spheres.rmsf[t]:0}function c$(e,t){var r=Ti.create({reverse:!0,domain:t.domain,listOrName:t.list.colors});function n(a){return ie.Location.is(a)?r.color(s$(a.unit,a.element)):mt.isLocation(a)?r.color(s$(a.aUnit,a.aUnit.elements[a.aIndex])):k3e}return{factory:c$,granularity:"group",preferSmoothing:!0,color:n,props:t,description:N3e,legend:r?r.legend:void 0}}var l$={name:"uncertainty",label:"Uncertainty/Disorder",category:lr.Atom,factory:c$,getParams:U3e,defaultValues:w.getDefaultValues(u$),isApplicable:function(e){return!!e.structure&&e.structure.models.some(function(t){return t.atomicConformation.B_iso_or_equiv.isDefined||t.coarseHierarchy.isDefined})}};var V3e=Xe(15658734),G3e="Assigns an illustrative color that gives every chain a color based on the chosen style but with lighter carbons (inspired by David Goodsell's Molecule of the Month style).",f$={style:w.MappedStatic("entity-id",{uniform:w.Group(Dd),"chain-id":w.Group(yp),"entity-id":w.Group(Sp),"entity-source":w.Group(_p),"molecule-type":w.Group(xy),"model-index":w.Group(Tp),"structure-index":w.Group(Dp)}),carbonLightness:w.Numeric(.8,{min:-6,max:6,step:.1})};function z3e(e){var t=w.clone(f$);return t}function H3e(e,t){switch(t.name){case"uniform":return Bl(e,t.params);case"chain-id":return bp(e,t.params);case"entity-id":return Cp(e,t.params);case"entity-source":return wp(e,t.params);case"molecule-type":return Sy(e,t.params);case"model-index":return Ap(e,t.params);case"structure-index":return Pp(e,t.params);default:cr(t)}}function d$(e,t){var r=H3e(e,t.style),n=r.color,a=r.legend;function i(s,u){var c=n(s,!1);return u==="C"?Xe.lighten(c,t.carbonLightness):c}function o(s){if(ie.Location.is(s)&&Te.isAtomic(s.unit)){var u=s.unit.model.atomicHierarchy.atoms.type_symbol.value(s.element);return i(s,u)}else if(mt.isLocation(s)&&Te.isAtomic(s.aUnit)){var c=s.aUnit.elements[s.aIndex],u=s.aUnit.model.atomicHierarchy.atoms.type_symbol.value(c);return i(s,u)}return V3e}return{factory:d$,granularity:"group",preferSmoothing:!0,color:o,props:t,description:G3e,legend:a}}var m$={name:"illustrative",label:"Illustrative",category:lr.Misc,factory:d$,getParams:z3e,defaultValues:w.getDefaultValues(f$),isApplicable:function(e){return!!e.structure}};var j3e='Assigns a color to every amino acid according to the "Experimentally determined hydrophobicity scale for proteins at membrane interfaces" by Wimely and White (doi:10.1038/nsb1096-842).',v$={list:w.ColorList("red-yellow-green",{presetKind:"scale"}),scale:w.Select("DGwif",[["DGwif","DG water-membrane"],["DGwoct","DG water-octanol"],["Oct-IF","DG difference"]])};function q3e(e){return v$}var W3e={DGwif:0,DGwoct:1,"Oct-IF":2};function Y3e(e,t){var r=iw[e];return r===void 0?0:r[t]}function p$(e,t){return e.model.atomicHierarchy.atoms.label_comp_id.value(t)}function h$(e,t){var r=e.coarseElements.seq_id_begin.value(t),n=e.coarseElements.seq_id_end.value(t);if(r===n){var a=e.coarseElements.entityKey[t],i=e.model.sequence.byEntityKey[a].sequence;return i.compId.value(r-1)}}function g$(e,t){var r=W3e[t.scale],n=1/0,a=-1/0;for(var i in iw){var o=iw[i][r];n=Math.min(n,o),a=Math.max(a,o)}var s=Ti.create({listOrName:t.list.colors,domain:[a,n],minLabel:"Hydrophilic",maxLabel:"Hydrophobic"});function u(c){var l;return ie.Location.is(c)?Te.isAtomic(c.unit)?l=p$(c.unit,c.element):l=h$(c.unit,c.element):mt.isLocation(c)&&(Te.isAtomic(c.aUnit)?l=p$(c.aUnit,c.aUnit.elements[c.aIndex]):l=h$(c.aUnit,c.aUnit.elements[c.aIndex])),s.color(l?Y3e(l,r):0)}return{factory:g$,granularity:"group",preferSmoothing:!0,color:u,props:t,description:j3e,legend:s?s.legend:void 0}}var y$={name:"hydrophobicity",label:"Hydrophobicity",category:lr.Residue,factory:g$,getParams:q3e,defaultValues:w.getDefaultValues(v$),isApplicable:function(e){return!!e.structure}};var b$=Xe(13421772),X3e="Gives every model (frame) a unique color based on the index in its trajectory.",x$=P({},fa({type:"colors",colorList:"purples"}));function K3e(e){return w.clone(x$)}function S$(e,t){var r,n,a,i;if(e.structure){for(var o=e.structure.root.models,s=0,u=0,c=o;u0&&Vt.TrajectoryInfo.get(e.structure.models[0]).size>1}};var Z3e=Xe(13421772),Q3e="Assigns a color based on the occupancy of an atom.",w$={domain:w.Interval([0,1]),list:w.ColorList("purples",{presetKind:"scale"})};function $3e(e){return w$}function _$(e,t){return Te.isAtomic(e)?e.model.atomicConformation.occupancy.value(t):0}function T$(e,t){var r=Ti.create({reverse:!1,domain:t.domain,listOrName:t.list.colors});function n(a){return ie.Location.is(a)?r.color(_$(a.unit,a.element)):mt.isLocation(a)?r.color(_$(a.aUnit,a.aUnit.elements[a.aIndex])):Z3e}return{factory:T$,granularity:"group",preferSmoothing:!0,color:n,props:t,description:Q3e,legend:r?r.legend:void 0}}var A$={name:"occupancy",label:"Occupancy",category:lr.Atom,factory:T$,getParams:$3e,defaultValues:w.getDefaultValues(w$),isApplicable:function(e){return!!e.structure&&e.structure.models.some(function(t){return t.atomicConformation.occupancy.isDefined})}};var VO="dark-2",D$=Xe(13421772),J3e="Assigns a color based on the operator HKL value of a transformed chain.",P$=P({},fa({type:"colors",colorList:VO}));function eMe(e){var t=w.clone(P$);return e.structure&&E$(e.structure.root).map.size>Ao[VO].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params=P(P({},t.palette.defaultValue.params),{list:{kind:"interpolate",colors:vs(VO).list}})),t}var Nx=1e4;function GO(e){return e.map(function(t){return"".concat(t+Nx).padStart(5,"0")}).join("")}function zO(e){var t=XG(Nx,0),r=parseInt(e.substr(0,t)),n=parseInt(e.substr(t,t)),a=parseInt(e.substr(t+t,t));return y.create(r-Nx,n-Nx,a-Nx)}function UO(e){return e.map(function(t){return t+5}).join("")}function E$(e){for(var t=new Map,r=new Set,n=0,a=e.units.length;n"]})},function(e,t){return t(e)}),coloring:w.MappedStatic("absolute-value",{"absolute-value":w.Group({domain:w.MappedStatic("auto",{custom:w.Interval([-1,1]),auto:w.Group({symmetric:w.Boolean(!1,{description:"If true the automatic range is determined as [-|max|, |max|]."})})}),list:w.ColorList("red-white-blue",{presetKind:"scale"})}),"relative-value":w.Group({domain:w.MappedStatic("auto",{custom:w.Interval([-1,1]),auto:w.Group({symmetric:w.Boolean(!1,{description:"If true the automatic range is determined as [-|max|, |max|]."})})}),list:w.ColorList("red-white-blue",{presetKind:"scale"})})}),defaultColor:w.Color(Xe(13421772))};function X$(e,t){var r;try{r=t.volume.getValue()}catch{}var n;if(r){var a=t.coloring.params,i=r.grid.stats,o=a.domain.name==="custom"?a.domain.params:[i.min,i.max],s=t.coloring.name==="relative-value";if(a.domain.name==="auto"&&s&&(o[0]=(o[0]-i.mean)/i.sigma,o[1]=(o[1]-i.mean)/i.sigma),t.coloring.params.domain.name==="auto"&&t.coloring.params.domain.params.symmetric){var u=Math.max(Math.abs(o[0]),Math.abs(o[1]));o[0]=-u,o[1]=u}var c=Ti.create({domain:o,listOrName:a.list.colors}),l=Ba.getGridToCartesianTransform(r.grid);se.invert(l,l);var f=y(),d=r.grid.cells.space,m=d.dimensions,h=d.get,p=r.grid.cells.data,v=m[0],g=m[1],b=m[2];n=function(x){if(!s7(x))return t.defaultColor;y.copy(f,x.position),y.transformMat4(f,f,l);var S=Math.floor(f[0]),_=Math.floor(f[1]),C=Math.floor(f[2]);if(S<0||S>=v||_<0||_>=g||C<0||C>=b)return t.defaultColor;var D=f[0]-S,T=f[1]-_,A=f[2]-C,E=Math.min(S+1,v-1),I=Math.min(_+1,g-1),R=Math.min(C+1,b-1),B=h(p,S,_,C),O=h(p,E,_,C),z=h(p,S,I,C),k=h(p,E,I,C),G=Fn(Fn(B,O,D),Fn(z,k,D),T);B=h(p,S,_,R),O=h(p,E,_,R),z=h(p,S,I,R),k=h(p,E,I,R);var V=Fn(Fn(B,O,D),Fn(z,k,D),T),U=Fn(G,V,A);return s&&(U=(U-i.mean)/i.sigma),c.color(U)}}else n=function(){return t.defaultColor};return{factory:X$,granularity:"vertex",preferSmoothing:!0,color:n,props:t,description:fMe}}var K$={name:"external-volume",label:"External Volume",category:lr.Misc,factory:X$,getParams:function(){return Y$},defaultValues:w.getDefaultValues(Y$),isApplicable:function(e){return!0}};var dMe="Uses separate themes for coloring mainchain and sidechain visuals.",Z$={mainchain:w.MappedStatic("molecule-type",{uniform:w.Group(Dd),"chain-id":w.Group(yp),"entity-id":w.Group(Sp),"entity-source":w.Group(_p),"molecule-type":w.Group(xy),"model-index":w.Group(Tp),"structure-index":w.Group(Dp),"secondary-structure":w.Group(cT)}),sidechain:w.MappedStatic("residue-name",{uniform:w.Group(Dd),"residue-name":w.Group(sT),"element-symbol":w.Group(aT)})};function mMe(e){var t=w.clone(Z$);return t}function pMe(e,t){switch(t.name){case"uniform":return Bl(e,t.params);case"chain-id":return bp(e,t.params);case"entity-id":return Cp(e,t.params);case"entity-source":return wp(e,t.params);case"molecule-type":return Sy(e,t.params);case"model-index":return Ap(e,t.params);case"structure-index":return Pp(e,t.params);case"secondary-structure":return lT(e,t.params);default:cr(t)}}function hMe(e,t){switch(t.name){case"uniform":return Bl(e,t.params);case"residue-name":return uT(e,t.params);case"element-symbol":return iT(e,t.params);default:cr(t)}}function Q$(e,t){var r,n,a=pMe(e,t.mainchain),i=hMe(e,t.sidechain);function o(u,c){return c?a.color(u,!1):i.color(u,!1)}var s=a.legend;return((r=a.legend)===null||r===void 0?void 0:r.kind)==="table-legend"&&((n=i.legend)===null||n===void 0?void 0:n.kind)==="table-legend"&&(s={kind:"table-legend",table:Ut(Ut([],a.legend.table,!0),i.legend.table,!0)}),{factory:Q$,granularity:"group",preferSmoothing:!1,color:o,props:t,description:dMe,legend:s}}var $$={name:"cartoon",label:"Cartoon",category:lr.Misc,factory:Q$,getParams:mMe,defaultValues:w.getDefaultValues(Z$),isApplicable:function(e){return!!e.structure}};var ci;(function(e){e.Category=lr,e.PaletteScale=(1<<24)-1,e.EmptyFactory=function(){return e.Empty};var t=Xe(13421772);e.Empty={factory:e.EmptyFactory,granularity:"uniform",color:function(){return t},props:{}};function r(a,i){return a.contextHash===i.contextHash&&a.factory===i.factory&&Oo(a.props,i.props)}e.areEqual=r,e.EmptyProvider={name:"",label:"",category:"",factory:e.EmptyFactory,getParams:function(){return{}},defaultValues:{},isApplicable:function(){return!0}};function n(){return new fT(e.BuiltIn,e.EmptyProvider)}e.createRegistry=n,e.BuiltIn={"atom-id":U$,"carbohydrate-symbol":sQ,cartoon:$$,"chain-id":$w,"element-index":yQ,"element-symbol":OQ,"entity-id":CQ,"entity-source":TQ,hydrophobicity:y$,illustrative:m$,"model-index":DQ,"molecule-type":kQ,occupancy:A$,"operator-hkl":M$,"operator-name":by,"partial-charge":F$,"polymer-id":HQ,"polymer-index":XQ,"residue-name":$Q,"secondary-structure":t$,"sequence-id":o$,"shape-group":Jq,"structure-index":EQ,"trajectory-index":C$,uncertainty:l$,"unit-index":MQ,uniform:Nj,"volume-segment":W$,"volume-value":z$,"external-volume":K$}})(ci||(ci={}));var vMe=1,gMe="Assigns a physical size, i.e. vdW radius for atoms or given radius for coarse spheres.",J$={scale:w.Numeric(1,{min:.1,max:5,step:.1})};function yMe(e){return J$}function jO(e,t){return Te.isAtomic(e)?Uf(e.model.atomicHierarchy.atoms.type_symbol.value(t)):Te.isSpheres(e)?e.model.coarseConformation.spheres.radius[t]:0}function eJ(e,t){var r=t.scale===void 0?1:t.scale;function n(a){var i;return ie.Location.is(a)?i=r*jO(a.unit,a.element):mt.isLocation(a)?i=r*Math.min(jO(a.aUnit,a.aUnit.elements[a.aIndex]),jO(a.bUnit,a.bUnit.elements[a.bIndex])):i=r*vMe,i}return{factory:eJ,granularity:"group",size:n,props:t,description:gMe}}var tJ={name:"physical",label:"Physical",category:"",factory:eJ,getParams:yMe,defaultValues:w.getDefaultValues(J$),isApplicable:function(e){return!!e.structure}};var bMe="Assigns a size reflecting the uncertainty or disorder of an element's position, e.g. B-factor or RMSF, depending on the data availability and experimental technique.",nJ={bfactorFactor:w.Numeric(.1,{min:0,max:1,step:.01}),rmsfFactor:w.Numeric(.05,{min:0,max:1,step:.01}),baseSize:w.Numeric(.2,{min:0,max:2,step:.1})};function xMe(e){return nJ}function rJ(e,t,r){return Te.isAtomic(e)?e.model.atomicConformation.B_iso_or_equiv.value(t)*r.bfactorFactor:Te.isSpheres(e)?e.model.coarseConformation.spheres.rmsf[t]*r.rmsfFactor:0}function aJ(e,t){function r(n){var a=t.baseSize;return ie.Location.is(n)?a+=rJ(n.unit,n.element,t):mt.isLocation(n)&&(a+=rJ(n.aUnit,n.aUnit.elements[n.aIndex],t)),a}return{factory:aJ,granularity:"group",size:r,props:t,description:bMe}}var iJ={name:"uncertainty",label:"Uncertainty/Disorder",category:"",factory:aJ,getParams:xMe,defaultValues:w.getDefaultValues(nJ),isApplicable:function(e){return!!e.structure&&e.structure.models.some(function(t){return t.atomicConformation.B_iso_or_equiv.isDefined||t.coarseHierarchy.isDefined})}};var ja;(function(e){e.EmptyFactory=function(){return e.Empty},e.Empty={factory:e.EmptyFactory,granularity:"uniform",size:function(){return 1},props:{}};function t(n,a){return n.contextHash===a.contextHash&&n.factory===a.factory&&Oo(n.props,a.props)}e.areEqual=t,e.EmptyProvider={name:"",label:"",category:"",factory:e.EmptyFactory,getParams:function(){return{}},defaultValues:{},isApplicable:function(){return!0}};function r(){return new fT(e.BuiltIn,e.EmptyProvider)}e.createRegistry=r,e.BuiltIn={physical:tJ,"shape-group":Qq,uncertainty:iJ,uniform:Vj}})(ja||(ja={}));var da;(function(e){function t(i,o,s,u){u=u||r();var c=s.colorTheme,l=s.sizeTheme;return u.color=i.colorThemeRegistry.create(c.name,o,c.params),u.size=i.sizeThemeRegistry.create(l.name,o,l.params),u}e.create=t;function r(){return{color:ci.Empty,size:ja.Empty}}e.createEmpty=r;function n(i,o,s,u){var c,l;return $(this,void 0,void 0,function(){return J(this,function(f){switch(f.label){case 0:return[4,(c=o.colorThemeRegistry.get(u.colorTheme.name).ensureCustomProperties)===null||c===void 0?void 0:c.attach(i,s)];case 1:return f.sent(),[4,(l=o.sizeThemeRegistry.get(u.sizeTheme.name).ensureCustomProperties)===null||l===void 0?void 0:l.attach(i,s)];case 2:return f.sent(),[2]}})})}e.ensureDependencies=n;function a(i,o,s){var u,c;(u=i.colorThemeRegistry.get(s.colorTheme.name).ensureCustomProperties)===null||u===void 0||u.detach(o),(c=i.sizeThemeRegistry.get(s.sizeTheme.name).ensureCustomProperties)===null||c===void 0||c.detach(o)}e.releaseDependencies=a})(da||(da={}));function oJ(e){return e.map(function(t){return[t.name,t.provider.label,t.provider.category]})}var fT=function(){function e(t,r){var n=this;this.emptyProvider=r,this._list=[],this._map=new Map,this._name=new Map,Ua(t,function(a,i){if(a.name!==i)throw new Error("Fix build in themes to have matching names. ".concat(a.name," ").concat(i));n.add(a)})}return Object.defineProperty(e.prototype,"default",{get:function(){return this._list[0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"list",{get:function(){return this._list},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"types",{get:function(){return oJ(this._list)},enumerable:!1,configurable:!0}),e.prototype.sort=function(){this._list.sort(function(t,r){return t.provider.category===r.provider.category?t.provider.labelr.provider.label?1:0:t.provider.category>2,o=i+(a-4*i>>2);if(o<=i){for(var s=n;s>2),c=n,l=Math.min(4*i,a),f=Math.max(n,4*o),d=a;switch(r){case kt.Highlight:for(var s=i;sr.lowestElementCount?"lowest":n>r.lowerElementCount?"lower":n>r.lowElementCount?"low":n>r.mediumElementCount?"medium":n>r.highElementCount?"high":"higher"}function wMe(e){if(e.root.models.length===1){var t=jn.Provider.get(e.root.model);if(t&&t.spacegroup.name==="P 1"&&!Va.isZero(t.spacegroup.cell))return t.spacegroup.cell.volume}return gt.volume(e.root.boundary.box)}function Vx(e,t){var r=ri(e.quality,"auto"),n=ri(e.detail,1),a=ri(e.radialSegments,12),i=ri(e.linearSegments,8),o=ri(e.resolution,2),s=ri(e.probePositions,12),u=ri(e.doubleSided,!0),c=0;if(r==="auto"){if(t instanceof Le)r=WO(t.root),c=wMe(t);else if(Je.is(t)){var l=t.grid.cells.space.dimensions,f=l[0],d=l[1],m=l[2];c=f*d*m,r=c<1e7?"medium":"low"}}switch(r){case"highest":n=3,a=36,i=18,o=.1,s=72,u=!0;break;case"higher":n=3,a=28,i=14,o=.3,s=48,u=!0;break;case"high":n=2,a=20,i=10,o=.5,s=36,u=!0;break;case"medium":n=1,a=12,i=8,o=.8,s=24,u=!0;break;case"low":n=0,a=8,i=3,o=1.3,s=24,u=!1;break;case"lower":n=0,a=4,i=2,o=3,s=12,u=!1;break;case"lowest":n=0,a=2,i=1,o=8,s=12,u=!1;break;case"custom":break}return o=Math.max(o,c/5e8),o=Math.min(o,20),e.transparentBackfaces==="off"&&(e.alpha!==void 0&&e.alpha<1||e.xrayShaded)&&(u=!1),{detail:n,radialSegments:a,linearSegments:i,resolution:o,probePositions:s,doubleSided:u}}var dT=y.set,lJ=y.normalize,fJ=y.sub,dJ=y.addScalar,mT=y.scale,mJ=y.toArray;function Mp(e,t,r,n){var a=!1;if(Je.isLoci(e)){if(!Je.areEquivalent(e.volume,t))return!1;n(Se.ofLength(t.grid.cells.data.length))&&(a=!0)}else if(Je.Isosurface.isLoci(e)){if(!Je.areEquivalent(e.volume,t))return!1;if(r?.isoValue){if(!Je.IsoValue.areSame(e.isoValue,r.isoValue,t.grid.stats))return!1;n(Se.ofLength(t.grid.cells.data.length))&&(a=!0)}else for(var i=t.grid,o=i.stats,s=i.cells.data,u=o.sigma,c=Je.IsoValue.toAbsolute(e.isoValue,o).absoluteValue,l=0,f=s.length;lk)){for(var L=k-Ke,K=z(re,fe,De),ge=0;gec)throw new Error("outputStride + itemOffset must NOT be larger than colorStride");var d=e.colorType.endsWith("Instance"),m=d?e.instanceCount:1,h=Vn(Math.max(1,m*t),f,Uint8Array),p=h.array,v=i[0],g=i[1],b=o[0],x=y.fromArray(y(),s,0),S=s[3];function _(ge,Pe,Ie){var ke=Math.floor(Ie*v%b/v),Ne=Math.floor(Ie*v/b),Ve=ke*v+ge;return c*(Ne*g*b+Pe*b+Ve)}for(var C=y(),D=y(),T=y(),A=y(),E=0;E p) discard; + + float f = p - dist; + gl_FragColor = vColor * f; + gl_FragData[1] = vec4(f); +} +`;var SJ=` +precision highp float; + +#include common +#include read_from_texture + +uniform int uGroupCount; + +attribute float aSample; +#define SampleID int(aSample) + +attribute mat4 aTransform; +attribute float aInstance; + +uniform vec2 uGeoTexDim; +uniform sampler2D tPosition; +uniform sampler2D tGroup; + +uniform vec2 uColorTexDim; +uniform sampler2D tColor; + +varying vec3 vPosition; +varying vec4 vColor; + +uniform vec3 uBboxSize; +uniform vec3 uBboxMin; +uniform float uResolution; + +void main() { + vec3 position = readFromTexture(tPosition, SampleID, uGeoTexDim).xyz; + float group = unpackRGBToInt(readFromTexture(tGroup, SampleID, uGeoTexDim).rgb); + + position = (aTransform * vec4(position, 1.0)).xyz; + gl_PointSize = 7.0; + vPosition = (position - uBboxMin) / uResolution; + gl_Position = vec4(((position - uBboxMin) / uBboxSize) * 2.0 - 1.0, 1.0); + + #if defined(dColorType_group) + vColor = readFromTexture(tColor, group, uColorTexDim); + #elif defined(dColorType_groupInstance) + vColor = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim); + #endif +} +`;var IMe={drawCount:An("number"),instanceCount:An("number"),stride:An("number"),uGroupCount:_e("i","material"),aTransform:Gr("float32",16,1),aInstance:Gr("float32",1,1),aSample:Gr("float32",1,0),uGeoTexDim:_e("v2","material"),tPosition:Ft("texture","rgba","float","nearest","material"),tGroup:Ft("texture","rgba","float","nearest","material"),uColorTexDim:_e("v2","material"),tColor:Ft("texture","rgba","ubyte","nearest","material"),dColorType:Dt("string",["group","groupInstance","vertex","vertexInstance"]),uCurrentSlice:_e("f"),uCurrentX:_e("f"),uCurrentY:_e("f"),uBboxMin:_e("v3","material"),uBboxSize:_e("v3","material"),uResolution:_e("f","material")},mc="color-accumulate",Gx="color-count";function CJ(e,t){for(var r=new Float32Array(e),n=0;no.drawCount.ref.value||a!==o.stride.ref.value)&&M.update(o.aSample,CJ(s,a)),M.updateIfChanged(o.drawCount,s),M.updateIfChanged(o.instanceCount,t.instanceCount),M.updateIfChanged(o.stride,a),M.updateIfChanged(o.uGroupCount,t.groupCount),M.update(o.aTransform,t.transformBuffer),M.update(o.aInstance,t.instanceBuffer),M.update(o.uGeoTexDim,Me.set(o.uGeoTexDim.ref.value,t.positionTexture.getWidth(),t.positionTexture.getHeight())),M.update(o.tPosition,t.positionTexture),M.update(o.tGroup,t.groupTexture),M.update(o.uColorTexDim,Me.set(o.uColorTexDim.ref.value,t.colorData.getWidth(),t.colorData.getHeight())),M.update(o.tColor,t.colorData),M.updateIfChanged(o.dColorType,t.colorType),M.updateIfChanged(o.uCurrentSlice,0),M.updateIfChanged(o.uCurrentX,0),M.updateIfChanged(o.uCurrentY,0),M.update(o.uBboxMin,r.min),M.update(o.uBboxSize,i),M.updateIfChanged(o.uResolution,n),e.namedComputeRenderables[mc].update()}else e.namedComputeRenderables[mc]=RMe(e,t,r,n,a);return e.namedComputeRenderables[mc]}function RMe(e,t,r,n,a){var i=y.sub(y(),r.max,r.min),o=Math.round(t.vertexCount/a),s={drawCount:M.create(o),instanceCount:M.create(t.instanceCount),stride:M.create(a),uGroupCount:M.create(t.groupCount),aTransform:M.create(t.transformBuffer),aInstance:M.create(t.instanceBuffer),aSample:M.create(CJ(o,a)),uGeoTexDim:M.create(Me.create(t.positionTexture.getWidth(),t.positionTexture.getHeight())),tPosition:M.create(t.positionTexture),tGroup:M.create(t.groupTexture),uColorTexDim:M.create(Me.create(t.colorData.getWidth(),t.colorData.getHeight())),tColor:M.create(t.colorData),dColorType:M.create(t.colorType),uCurrentSlice:M.create(0),uCurrentX:M.create(0),uCurrentY:M.create(0),uBboxMin:M.create(r.min),uBboxSize:M.create(i),uResolution:M.create(n)},u=P({},IMe),c=Nr("accumulate",SJ,xJ,{drawBuffers:"required"}),l=ln(e,"points",c,u,s);return fn(l,s)}function BMe(e){var t=e.gl,r=e.state;r.disable(t.CULL_FACE),r.enable(t.BLEND),r.disable(t.DEPTH_TEST),r.enable(t.SCISSOR_TEST),r.depthMask(!1),r.clearColor(0,0,0,0),r.blendFunc(t.ONE,t.ONE),r.blendEquation(t.FUNC_ADD)}var OMe=P(P({},Gn),{tColor:Ft("texture","rgba","float","nearest"),tCount:Ft("texture","alpha","float","nearest"),uTexSize:_e("v2")}),zx="color-normalize";function FMe(e,t,r){if(e.namedComputeRenderables[zx]){var n=e.namedComputeRenderables[zx].values;M.update(n.tColor,t),M.update(n.tCount,r),M.update(n.uTexSize,Me.set(n.uTexSize.ref.value,t.getWidth(),t.getHeight())),e.namedComputeRenderables[zx].update()}else e.namedComputeRenderables[zx]=LMe(e,t,r);return e.namedComputeRenderables[zx]}function LMe(e,t,r){var n=P(P({},zn),{tColor:M.create(t),tCount:M.create(r),uTexSize:M.create(Me.create(t.getWidth(),t.getHeight()))}),a=P({},OMe),i=Nr("normalize",ea,bJ),o=ln(e,"triangles",i,a,n);return fn(o,n)}function kMe(e){var t=e.gl,r=e.state;r.disable(t.CULL_FACE),r.enable(t.BLEND),r.disable(t.DEPTH_TEST),r.enable(t.SCISSOR_TEST),r.depthMask(!1),r.clearColor(0,0,0,0),r.blendFunc(t.ONE,t.ONE),r.blendEquation(t.FUNC_ADD)}function NMe(e){var t=e[0]*e[1]*e[2],r=Math.sqrt(t),n=Math.pow(2,Math.ceil(Math.log(r)/Math.log(2))),a=0,i=e[1],o=1,s=e[2];return n=E&&(U-=E,Q+=_,W=0,M.update(V,Q)),M.update(G,W),M.update(k,X),u.viewport(W,Q,S,_),u.scissor(W,Q,S,_),O.render(),++U,W+=S;R.detachFramebuffer(I,0),B.detachFramebuffer(I,1),i.drawBuffers([o.COLOR_ATTACHMENT0,o.NONE]),ft&&n.timer.markEnd("ColorAccumulate.render"),ft&&n.timer.mark("ColorNormalize.render"),(!a||Bj(a))&&(a=s.texture("image-uint8","rgba","ubyte","linear")),a.define(T,A);var ae=FMe(n,R,B);u.currentRenderItemId=-1,kMe(n),a.attachFramebuffer(I,0),u.viewport(0,0,T,A),u.scissor(0,0,T,A),o.clear(o.COLOR_BUFFER_BIT),ae.render(),ft&&n.timer.markEnd("ColorNormalize.render");var q=Wt.create(x[0],x[1],x[2],v),F=d?"volumeInstance":"volume";return ft&&n.timer.markEnd("calcTextureMeshColorSmoothing"),{texture:a,gridDim:b,gridTexDim:Me.create(T,A),gridTransform:q,type:F}}var YO="color-smoothing-rgb",_y="color-smoothing-rgba",XO="color-smoothing-alpha";function UMe(e){return e==="group"||e==="groupInstance"}function KO(e,t,r,n,a){if(UMe(e.dColorType.ref.value)){r*=3,n.namedTextures[YO]||(n.namedTextures[YO]=n.resources.texture("image-uint8","rgb","ubyte","nearest"));var i=n.namedTextures[YO];i.load(e.tColor.ref.value);var o=vT({vertexCount:e.uVertexCount.ref.value,instanceCount:e.uInstanceCount.ref.value,groupCount:e.uGroupCount.ref.value,transformBuffer:e.aTransform.ref.value,instanceBuffer:e.aInstance.ref.value,positionTexture:e.tPosition.ref.value,groupTexture:e.tGroup.ref.value,colorData:i,colorType:e.dColorType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value},t,r,n,a);M.updateIfChanged(e.dColorType,o.type),M.update(e.tColorGrid,o.texture),M.update(e.uColorTexDim,o.gridTexDim),M.update(e.uColorGridDim,o.gridDim),M.update(e.uColorGridTransform,o.gridTransform)}}function VMe(e){return e==="groupInstance"}function _J(e,t,r,n,a){if(VMe(e.dOverpaintType.ref.value)){r*=3,n.namedTextures[_y]||(n.namedTextures[_y]=n.resources.texture("image-uint8","rgba","ubyte","nearest"));var i=n.namedTextures[_y];i.load(e.tOverpaint.ref.value);var o=vT({vertexCount:e.uVertexCount.ref.value,instanceCount:e.uInstanceCount.ref.value,groupCount:e.uGroupCount.ref.value,transformBuffer:e.aTransform.ref.value,instanceBuffer:e.aInstance.ref.value,positionTexture:e.tPosition.ref.value,groupTexture:e.tGroup.ref.value,colorData:i,colorType:e.dOverpaintType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value},t,r,n,a);M.updateIfChanged(e.dOverpaintType,o.type),M.update(e.tOverpaintGrid,o.texture),M.update(e.uOverpaintTexDim,o.gridTexDim),M.update(e.uOverpaintGridDim,o.gridDim),M.update(e.uOverpaintGridTransform,o.gridTransform)}}function GMe(e){return e==="groupInstance"}function wJ(e,t,r,n,a){if(GMe(e.dTransparencyType.ref.value)){r*=3,n.namedTextures[XO]||(n.namedTextures[XO]=n.resources.texture("image-uint8","alpha","ubyte","nearest"));var i=n.namedTextures[XO];i.load(e.tTransparency.ref.value);var o=vT({vertexCount:e.uVertexCount.ref.value,instanceCount:e.uInstanceCount.ref.value,groupCount:e.uGroupCount.ref.value,transformBuffer:e.aTransform.ref.value,instanceBuffer:e.aInstance.ref.value,positionTexture:e.tPosition.ref.value,groupTexture:e.tGroup.ref.value,colorData:i,colorType:e.dTransparencyType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value},t,r,n,a);M.updateIfChanged(e.dTransparencyType,o.type),M.update(e.tTransparencyGrid,o.texture),M.update(e.uTransparencyTexDim,o.gridTexDim),M.update(e.uTransparencyGridDim,o.gridDim),M.update(e.uTransparencyGridTransform,o.gridTransform)}}function zMe(e){return e==="groupInstance"}function TJ(e,t,r,n,a){if(zMe(e.dSubstanceType.ref.value)){r*=3,n.namedTextures[_y]||(n.namedTextures[_y]=n.resources.texture("image-uint8","rgba","ubyte","nearest"));var i=n.namedTextures[_y];i.load(e.tSubstance.ref.value);var o=vT({vertexCount:e.uVertexCount.ref.value,instanceCount:e.uInstanceCount.ref.value,groupCount:e.uGroupCount.ref.value,transformBuffer:e.aTransform.ref.value,instanceBuffer:e.aInstance.ref.value,positionTexture:e.tPosition.ref.value,groupTexture:e.tGroup.ref.value,colorData:i,colorType:e.dSubstanceType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value},t,r,n,a);M.updateIfChanged(e.dSubstanceType,o.type),M.update(e.tSubstanceGrid,o.texture),M.update(e.uSubstanceTexDim,o.gridTexDim),M.update(e.uSubstanceGridDim,o.gridDim),M.update(e.uSubstanceGridTransform,o.gridTransform)}}var pr;(function(e){function t(d,m){d&&(d.state.visible=m)}e.setVisibility=t;function r(d,m){d&&(d.state.alphaFactor=m)}e.setAlphaFactor=r;function n(d,m){d&&(d.state.pickable=m)}e.setPickable=n;function a(d,m){d&&(d.state.colorOnly=m)}e.setColorOnly=a;function i(d,m,h,p,v){if(!d||qa(m))return!1;var g=d.values,b=g.tMarker,x=g.uMarker,S=g.markerAverage,_=g.markerStatus,C=g.uGroupCount,D=g.instanceCount,T=g.instanceGranularity,A=T.ref.value?D.ref.value:C.ref.value*D.ref.value,E=b.ref.value.array,I=_.ref.value;if(!Oi(m)){var R=0;if(p(m,function(G){return R+=Se.size(G),!0},!0),R===0)return!1;R===A&&(m=Ep)}var B=!1,O=-1,z=-1;if(Oi(m)){var k=uJ(h,I);k.status!==-1?(B=I!==k.status,B&&sJ(E,k.status,A)):B=Ux(E,Se.ofLength(A),h),O=k.average,z=k.status}else B=p(m,function(G){return Ux(E,G,h)},!0),B&&(O=cJ(h,I),v&&v.status!==-1&&O===-1&&Fa.isReverse(v.action,h)&&jt.areEqual(m,v.loci)&&(z=v.status,O=z===0?0:.5));return B&&(O===-1&&(O=eR(E,A),O===0&&(z=0)),v&&(v.action=h,v.loci=m,v.status=I),M.updateIfChanged(x,z),z===-1&&M.update(b,b.ref.value),M.updateIfChanged(S,O),M.updateIfChanged(_,z)),B}e.mark=i;function o(d,m,h,p,v){if(d){var g=d.values,b=g.tOverpaint,x=g.dOverpaintType,S=g.dOverpaint,_=g.uGroupCount,C=g.instanceCount,D=g.instanceGranularity,T=D.ref.value?C.ref.value:_.ref.value*C.ref.value,A=D.ref.value?"instance":"groupInstance";Hj(m.layers.length?T:0,A,d.values);var E=b.ref.value.array;p&&dR(E,0,T);for(var I=function(X,ae){var q=m.layers[X],F=q.loci,j=q.color,Z=q.clear,Y=function(H){var N=Se.start(H),ee=Se.end(H);return Z?dR(E,N,ee):zj(E,N,ee,j)};h(F,Y,!1)},R=0,B=m.layers.length;R0),m.layers.length!==0&&A!=="instance"&&v&&Fl(v.props)){var O=v.geometry,z=v.props,k=v.webgl;if(O.kind==="mesh"){var G=O.meta,V=G.resolution,U=G.overpaintTexture,Q=Zs(z.smoothColors,!0,V);Q&&(vJ(d.values,Q.resolution,Q.stride,k,U),O.meta.overpaintTexture=d.values.tOverpaintGrid.ref.value)}else if(k&&O.kind==="texture-mesh"){var W=O.meta,V=W.resolution,U=W.overpaintTexture,Q=Zs(z.smoothColors,!0,V);Q&&(_J(d.values,Q.resolution,Q.stride,k,U),O.meta.overpaintTexture=d.values.tOverpaintGrid.ref.value)}}}}e.setOverpaint=o;function s(d,m,h,p,v){if(d){var g=d.values,b=g.tTransparency,x=g.dTransparencyType,S=g.transparencyAverage,_=g.dTransparency,C=g.uGroupCount,D=g.instanceCount,T=g.instanceGranularity,A=T.ref.value?D.ref.value:C.ref.value*D.ref.value,E=T.ref.value?"instance":"groupInstance";Yj(m.layers.length?A:0,E,d.values);var I=b.ref.value.array;p&&Wj(I,0,A);for(var R=function(ae,q){var F=m.layers[ae],j=F.loci,Z=F.value,Y=function(H){var N=Se.start(H),ee=Se.end(H);return qj(I,N,ee,Z)};h(j,Y,!1)},B=0,O=m.layers.length;B0),m.layers.length!==0&&E!=="instance"&&v&&Fl(v.props)){var z=v.geometry,k=v.props,G=v.webgl;if(z.kind==="mesh"){var V=z.meta,U=V.resolution,Q=V.transparencyTexture,W=Zs(k.smoothColors,!0,U);W&&(gJ(d.values,W.resolution,W.stride,G,Q),z.meta.transparencyTexture=d.values.tTransparencyGrid.ref.value)}else if(G&&z.kind==="texture-mesh"){var X=z.meta,U=X.resolution,Q=X.transparencyTexture,W=Zs(k.smoothColors,!0,U);W&&(wJ(d.values,W.resolution,W.stride,G,Q),z.meta.transparencyTexture=d.values.tTransparencyGrid.ref.value)}}}}e.setTransparency=s;function u(d,m,h,p,v){if(d){var g=d.values,b=g.tSubstance,x=g.dSubstanceType,S=g.dSubstance,_=g.uGroupCount,C=g.instanceCount,D=g.instanceGranularity,T=D.ref.value?C.ref.value:_.ref.value*C.ref.value,A=D.ref.value?"instance":"groupInstance";eq(m.layers.length?T:0,A,d.values);var E=b.ref.value.array;p&&pR(E,0,T);for(var I=function(X,ae){var q=m.layers[X],F=q.loci,j=q.material,Z=q.clear,Y=function(H){var N=Se.start(H),ee=Se.end(H);return Z?pR(E,N,ee):Jj(E,N,ee,j)};h(F,Y,!1)},R=0,B=m.layers.length;R0),m.layers.length!==0&&A!=="instance"&&v&&Fl(v.props)){var O=v.geometry,z=v.props,k=v.webgl;if(O.kind==="mesh"){var G=O.meta,V=G.resolution,U=G.substanceTexture,Q=Zs(z.smoothColors,!0,V);Q&&(yJ(d.values,Q.resolution,Q.stride,k,U),O.meta.substanceTexture=d.values.tSubstanceGrid.ref.value)}else if(k&&O.kind==="texture-mesh"){var W=O.meta,V=W.resolution,U=W.substanceTexture,Q=Zs(z.smoothColors,!0,V);Q&&(TJ(d.values,Q.resolution,Q.stride,k,U),O.meta.substanceTexture=d.values.tSubstanceGrid.ref.value)}}}}e.setSubstance=u;function c(d,m,h,p){if(d){var v=d.values,g=v.tClipping,b=v.dClippingType,x=v.dClipping,S=v.uGroupCount,_=v.instanceCount,C=v.instanceGranularity,D=C.ref.value?_.ref.value:S.ref.value*_.ref.value,T=m.layers,A=C.ref.value?"instance":"groupInstance";Qj(T.length?D:0,A,d.values);var E=g.ref.value.array;p&&Zj(E,0,D);for(var I=function(O,z){var k=m.layers[O],G=k.loci,V=k.groups,U=function(Q){var W=Se.start(Q),X=Se.end(Q);return Kj(E,W,X,V)};h(G,U,!1)},R=0,B=m.layers.length;R0)}}e.setClipping=c;function l(d,m){d&&(M.updateIfChanged(d.values.uOverpaintStrength,m.overpaint),M.updateIfChanged(d.values.uTransparencyStrength,m.transparency),M.updateIfChanged(d.values.uSubstanceStrength,m.substance))}e.setThemeStrength=l;function f(d,m,h){if(!(!d||!m&&!h)){var p=d.values;m&&(se.copy(p.matrix.ref.value,m),M.update(p.matrix,p.matrix.ref.value)),h?(p.extraTransform.ref.value.set(h),M.update(p.extraTransform,p.extraTransform.ref.value)):h===null&&(U0(p.extraTransform.ref.value,p.instanceCount.ref.value),M.update(p.extraTransform,p.extraTransform.ref.value)),fR(p);var v=Da(p.invariantBoundingSphere.ref.value,p.aTransform.ref.value,p.instanceCount.ref.value,0);M.update(p.boundingSphere,v)}}e.setTransform=f})(pr||(pr={}));function Dn(e,t){return{kind:e,layers:t}}(function(e){e.Empty={kind:"empty-loci",layers:[]};var t;(function(l){l.is=Ya.has;var f;(function(g){g[g.None=0]="None",g[g.One=1]="One",g[g.Two=2]="Two",g[g.Three=4]="Three",g[g.Four=8]="Four",g[g.Five=16]="Five",g[g.Six=32]="Six"})(f=l.Flag||(l.Flag={}));function d(g){return Ya.create(g)}l.create=d,l.Names={one:f.One,two:f.Two,three:f.Three,four:f.Four,five:f.Five,six:f.Six};function m(g){return g in l.Names}l.isName=m;function h(g){switch(g){case"one":return f.One;case"two":return f.Two;case"three":return f.Three;case"four":return f.Four;case"five":return f.Five;case"six":return f.Six}}l.fromName=h;function p(g){for(var b=f.None,x=0,S=g.length;x[+ ").concat(Ty(e-1,"other ".concat(Pm(r))),"]")}function JMe(e){var t=e.elements,r=e.model,n=r.atomicHierarchy,a=n.chainAtomSegments,i=n.residueAtomSegments,o=a.offsets[a.index[t[0]]],s=a.offsets[a.index[t[t.length-1]]+1]-1;return i.index[s]-i.index[o]+1}function jx(e,t){t===void 0&&(t={});var r=P(P({},Ay),t),n=eRe(e,r.countsOnly,r.hidePrefix,r.condensed,r.reverse);return r.htmlStyling?n:V2(n)}function Dy(e,t){t===void 0&&(t={});for(var r=ie.Stats.create(),n=0,a=e;n0&&d.push(Ty(i,"Structure")),o>0&&d.push(Ty(o,"Chain")),s>0&&d.push(Ty(s,"Residue")),u>0&&d.push(Ty(u,"Conformation")),c>0&&d.push(Ty(c,"Element")),d.join(" + ")}else{var d=[];return i>0&&d.push(i===1?Qd(e.firstStructureLoc,{hidePrefix:r,condensed:n,granularity:"structure",reverse:a}):Hx(i,e.firstStructureLoc,"structure",r,a,n)),o>0&&(d.push(o===1?Qd(e.firstChainLoc,{condensed:n,granularity:"chain",hidePrefix:r,reverse:a}):Hx(o,e.firstChainLoc,"chain",r,a,n)),r=!0),s>0&&(d.push(s===1?Qd(e.firstResidueLoc,{condensed:n,granularity:"residue",hidePrefix:r,reverse:a}):Hx(s,e.firstResidueLoc,"residue",r,a,n)),r=!0),u>0&&(d.push(u===1?Qd(e.firstConformationLoc,{condensed:n,granularity:"conformation",hidePrefix:r,reverse:a}):Hx(u,e.firstConformationLoc,"conformation",r,a,n)),r=!0),c>0&&d.push(c===1?Qd(e.firstElementLoc,{condensed:n,granularity:"element",hidePrefix:r,reverse:a}):Hx(c,e.firstElementLoc,"element",r,a,n)),d.join(" + ")}}function qx(e,t){return t===void 0&&(t={}),xT({loci:[ie.Loci(e.aStructure,[{unit:e.aUnit,indices:Ee.ofSingleton(e.aIndex)}]),ie.Loci(e.bStructure,[{unit:e.bUnit,indices:Ee.ofSingleton(e.bIndex)}])]},t)}function xT(e,t){t===void 0&&(t={});var r=P(P({},Ay),t),n=tRe(e,r);return r.htmlStyling?n:V2(n)}function tRe(e,t){for(var r=t.granularity,n=t.hidePrefix,a=t.reverse,i=t.condensed,o=!0,s=0,u=e.loci;s0){for(var b=[f[0].join(" | ")],v=1,g=f.length;v")}else{var f=e.loci.map(function(S){return Rv(S,t)});return f.filter(function(S){return!!S}).join(i?" \u2014 ":"
")}}function Qd(e,t){var r,n;t===void 0&&(t={});var a=P(P({},Ay),t),i=kJ(e,a.granularity,a.hidePrefix,a.reverse||a.condensed),o=a.condensed?(n=(r=i[0])===null||r===void 0?void 0:r.replace(/\[.*\]/g,"").trim())!==null&&n!==void 0?n:"":i.filter(function(s){return!!s}).join(" | ");return a.htmlStyling?o:V2(o)}function kJ(e,t,r,n){t===void 0&&(t="element"),r===void 0&&(r=!1),n===void 0&&(n=!1);var a=[];if(!r){var i=e.unit.model.entry;i.length>30&&(i=i.substr(0,27)+"\u2026"),a.push("".concat(i,"")),t!=="structure"&&(a.push("Model ".concat(e.unit.model.modelNum,"")),a.push("Instance ".concat(e.unit.conformation.operator.name,"")))}return Te.isAtomic(e.unit)?a.push.apply(a,rRe(e,t,n)):Te.isCoarse(e.unit)?a.push.apply(a,nRe(e,t)):a.push("Unknown"),n?a.reverse():a}function rRe(e,t,r){r===void 0&&(r=!1);var n=ie.Location.residueIndex(e),a=nt.chain.label_asym_id(e),i=nt.chain.auth_asym_id(e),o=e.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(n)===0,s=nt.residue.label_seq_id(e),u=nt.residue.auth_seq_id(e),c=nt.residue.pdbx_PDB_ins_code(e),l=nt.atom.label_comp_id(e),f=nt.atom.label_atom_id(e),d=nt.atom.label_alt_id(e),m=nt.atom.occupancy(e),h=nt.residue.microheterogeneityCompIds(e),p=t==="residue"&&h.length>1?"(".concat(h.join("|"),")"):l,v=[];switch(t){case"element":v.push("".concat(f,"").concat(d?"%".concat(d):""));case"conformation":t==="conformation"&&d&&v.push("Conformation ".concat(d,""));case"residue":var g=s===u||!o?u:s;v.push("".concat(p," ").concat(g,"").concat(g!==u?" [auth ".concat(u,"]"):"","").concat(c||"",""));case"chain":a===i?v.push("".concat(a,"")):t==="chain"&&Te.Traits.is(e.unit.traits,Te.Trait.MultiChain)?v.push("[auth ".concat(i,"]")):v.push("".concat(a," [auth ").concat(i,"]"))}return v.length>0&&m!==1&&!r&&(v[0]="".concat(v[0]," [occupancy ").concat(Math.round(100*m)/100,"]")),v.reverse()}function nRe(e,t){var r=nt.coarse.asym_id(e),n=nt.coarse.seq_id_begin(e),a=nt.coarse.seq_id_end(e),i=[];switch(t){case"element":case"conformation":case"residue":if(n===a){var o=nt.coarse.entityKey(e),s=e.unit.model.sequence.byEntityKey[o],u=s.sequence.compId.value(n-1);i.push("".concat(u," ").concat(n,""))}else i.push("".concat(n,"-").concat(a,""));case"chain":i.push("".concat(r,""))}return i.reverse()}function ST(e,t){t===void 0&&(t={});var r=P(P(P({},Ay),{measureOnly:!1,unitLabel:"\u212B"}),t),n=e.loci.map(function(u){return jt.getCenter(u)}),a=n[0],i=n[1],o="".concat(y.distance(a,i).toFixed(2)," ").concat(r.unitLabel);if(r.measureOnly)return o;var s=xT(e,r);return r.condensed?"".concat(o," | ").concat(s):"Distance ".concat(o,"
").concat(s)}function CT(e,t){t===void 0&&(t={});var r=P(P(P({},Ay),{measureOnly:!1}),t),n=e.loci.map(function(f){return jt.getCenter(f)}),a=n[0],i=n[1],o=n[2],s=y.sub(y(),a,i),u=y.sub(y(),o,i),c="".concat(Zi(y.angle(s,u)).toFixed(2),"\xB0");if(r.measureOnly)return c;var l=xT(e,r);return r.condensed?"".concat(c," | ").concat(l):"Angle ".concat(c,"
").concat(l)}function _T(e,t){t===void 0&&(t={});var r=P(P(P({},Ay),{measureOnly:!1}),t),n=e.loci.map(function(l){return jt.getCenter(l)}),a=n[0],i=n[1],o=n[2],s=n[3],u="".concat(Zi(y.dihedralAngle(a,i,o,s)).toFixed(2),"\xB0");if(r.measureOnly)return u;var c=xT(e,r);return r.condensed?"".concat(u," | ").concat(c):"Dihedral ".concat(u,"
").concat(c)}var rF={customText:w.Text("",{label:"Text",description:"Override the label with custom value.",isEssential:!0}),textColor:w.Color(Xt.black,{isEssential:!0}),textSize:w.Numeric(.5,{min:.1,max:10,step:.1},{isEssential:!0})},Rp=P(P(P({},yi.Params),rF),{borderWidth:w.Numeric(.2,{min:0,max:.5,step:.01})});var NJ={unitLabel:w.Text("\u212B",{isEssential:!0})},aRe=P(P(P({},Kr.Params),NJ),{lineSizeAttenuation:w.Boolean(!0),linesColor:w.Color(Xt.lightgreen,{isEssential:!0}),linesSize:w.Numeric(.075,{min:.01,max:5,step:.01}),dashLength:w.Numeric(.2,{min:.01,max:.2,step:.01})}),iRe=P(P({},Rp),NJ),UJ={lines:function(e,t){return Ia(uRe,Kr.Utils,{modifyState:function(r){return P(P({},r),{markerActions:Fa.Highlighting})}})},text:function(e,t){return Ia(lRe,yi.Utils,{modifyState:function(r){return P(P({},r),{markerActions:kt.None})}})}},nF=P(P(P({},aRe),iRe),{visuals:w.MultiSelect(["lines","text"],w.objectToOptions(UJ))});function oRe(){return{sphereA:xe(),sphereB:xe(),center:y(),distance:0}}function VJ(e,t){var r=t.sphereA,n=t.sphereB,a=t.center,i=e.loci,o=i[0],s=i[1];return jt.getBoundingSphere(o,r),jt.getBoundingSphere(s,n),y.add(a,r.center,n.center),y.scale(a,a,.5),t.distance=y.distance(r.center,n.center),t}var Bp=oRe();function GJ(e,t){return e.pairs.length===1?"Distance ".concat(ST(e.pairs[0],{unitLabel:t,measureOnly:!0})):"".concat(e.pairs.length," Distances")}function sRe(e,t,r){for(var n=Ji.create(128,64,r),a=0,i=e.pairs.length;avBe,getBoxMesh:()=>PT});var vBe=It.BuiltIn({name:"box-shape-3d",display:"Box Shape",from:he.Root,to:he.Shape.Provider,params:{bottomLeft:w.Vec3(y()),topRight:w.Vec3(y.create(1,1,1)),radius:w.Numeric(.15,{min:.01,max:4,step:.01}),color:w.Color(Xt.red)}})({canAutoUpdate:function(){return!0},apply:function(e){var t=this,r=e.params;return Ce.create("Shape Representation",function(n){return $(t,void 0,void 0,function(){return J(this,function(a){return[2,new he.Shape.Provider({label:"Box",data:r,params:pt.Params,getShape:function(i,o){var s=PT(gt.create(r.bottomLeft,r.topRight),r.radius);return gr.create("Box",o,s,function(){return o.color},function(){return 1},function(){return"Box"})},geometryUtils:pt.Utils},{label:"Box"})]})})})}});function PT(e,t,r){var n=y.sub(y(),e.max,e.min),a=se.fromTranslation(se(),y.create(.5,.5,.5)),i=se.fromScaling(se(),n),o=se.fromTranslation(se(),e.min),s=se.mul3(se(),o,i,a),u=ot.createState(256,128,r);u.currentGroup=1,ot.addCage(u,s,Q_(),t,2,20);var c=ot.getMesh(u),l=y.scaleAndAdd(y(),e.min,n,.5),f=y.distance(e.min,l);return c.setBoundingSphere(xe.create(l,f)),c}var oee={vertices:new Float32Array([-.5,.5,0,.5,.5,0,-.5,-.5,0,.5,-.5,0]),normals:new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1]),indices:new Uint32Array([0,2,1,1,2,3])},JGt={vertices:oee.vertices,edges:new Uint32Array([0,1,2,3,3,1,2,0])};function see(){return oee}var gBe=P(P({},pt.Params),{color:w.Color(Xt.orange),scaleFactor:w.Numeric(1,{min:.1,max:10,step:.1})}),uee={plane:function(e,t){return Ia(xBe,pt.Utils)}},yF=P(P({},gBe),{visuals:w.MultiSelect(["plane"],w.objectToOptions(uee))});function yBe(e){var t=Dy(e,{countsOnly:!0});return"Best Fit Plane of ".concat(t)}var Lp=se(),gF=y();function bBe(e,t,r){var n=ot.createState(256,128,r),a=ie.Loci.getPrincipalAxesMany(e.locis),i=a.boxAxes,o=see();return y.add(gF,i.origin,i.dirC),se.targetTo(Lp,gF,i.origin,i.dirB),se.scale(Lp,Lp,si.size(gF,i)),se.scaleUniformly(Lp,Lp,t.scaleFactor),se.setTranslation(Lp,i.origin),n.currentGroup=0,ot.addPrimitive(n,Lp,o),ot.addPrimitiveFlipped(n,Lp,o),ot.getMesh(n)}function xBe(e,t,r,n){var a=bBe(t,r,n&&n.geometry),i=yBe(t.locis);return gr.create(i,t,a,function(){return r.color},function(){return 1},function(){return i})}function cee(e,t){var r=Lt.createMulti("Plane",e,t,Lt.StateBuilder,uee);return r.setState({markerActions:Fa.Highlighting}),r}var Ey=It.BuiltIn({name:"structure-representation-3d",display:"3D Representation",from:he.Molecule.Structure,to:he.Molecule.Structure.Representation3D,params:function(e,t){var r=t.representation.structure,n=r.registry,a=r.themes,i=n.get(n.default.name);if(!e){var o={help:function(c){var l=c.name,f=c.params,d=a.colorThemeRegistry.get(l),m=d.factory({},f);return{description:m.description,legend:m.legend}}};return{type:w.Mapped(n.default.name,n.types,function(c){return w.Group(n.get(c).getParams(a,Le.Empty))}),colorTheme:w.Mapped(i.defaultColorTheme.name,a.colorThemeRegistry.types,function(c){return w.Group(a.colorThemeRegistry.get(c).getParams({structure:Le.Empty}))},o),sizeTheme:w.Mapped(i.defaultSizeTheme.name,a.sizeThemeRegistry.types,function(c){return w.Group(a.sizeThemeRegistry.get(c).getParams({structure:Le.Empty}))})}}var s={structure:e.data},u={help:function(c){var l=c.name,f=c.params,d=a.colorThemeRegistry.get(l),m=d.factory(s,f);return{description:m.description,legend:m.legend}}};return{type:w.Mapped(n.default.name,n.getApplicableTypes(e.data),function(c){return w.Group(n.get(c).getParams(a,e.data))}),colorTheme:w.Mapped(i.defaultColorTheme.name,a.colorThemeRegistry.getApplicableTypes(s),function(c){return w.Group(a.colorThemeRegistry.get(c).getParams(s))},u),sizeTheme:w.Mapped(i.defaultSizeTheme.name,a.sizeThemeRegistry.getApplicableTypes(s),function(c){return w.Group(a.sizeThemeRegistry.get(c).getParams(s))})}}})({canAutoUpdate:function(e){var t=e.a,r=e.oldParams,n=e.newParams;return t.data.elementCount<1e4||r.type.name===n.type.name&&n.type.params.quality!=="custom"},apply:function(e,t){var r=this,n=e.a,a=e.params,i=e.cache;return Ce.create("Structure Representation",function(o){return $(r,void 0,void 0,function(){var s,u,c,l,f,d,m;return J(this,function(h){switch(h.label){case 0:return s={runtime:o,assetManager:t.managers.asset},u=t.representation.structure.registry.get(a.type.name),c=((d=u.getData)===null||d===void 0?void 0:d.call(u,n.data,a.type.params))||n.data,u.ensureCustomProperties?[4,u.ensureCustomProperties.attach(s,c)]:[3,2];case 1:h.sent(),h.label=2;case 2:return l=u.factory(P({webgl:(m=t.canvas3d)===null||m===void 0?void 0:m.webgl},t.representation.structure.themes),u.getParams),[4,da.ensureDependencies(s,t.representation.structure.themes,{structure:c},a)];case 3:return h.sent(),l.setTheme(da.create(t.representation.structure.themes,{structure:c},a)),f=a.type.params||{},[4,l.createOrUpdate(f,c).runInContext(o)];case 4:return h.sent(),[2,new he.Molecule.Structure.Representation3D({repr:l,sourceData:n.data},{label:u.label})]}})})})},update:function(e,t){var r=this,n=e.a,a=e.b,i=e.oldParams,o=e.newParams,s=e.cache;return Ce.create("Structure Representation",function(u){return $(r,void 0,void 0,function(){var c,l,f,d,m,h;return J(this,function(p){switch(p.label){case 0:return o.type.name!==i.type.name?[2,rt.UpdateResult.Recreate]:(c=t.representation.structure.registry.get(o.type.name),!((m=c.mustRecreate)===null||m===void 0)&&m.call(c,i.type.params,o.type.params)?[2,rt.UpdateResult.Recreate]:(l=((h=c.getData)===null||h===void 0?void 0:h.call(c,n.data,o.type.params))||n.data,f={runtime:u,assetManager:t.managers.asset},c.ensureCustomProperties?[4,c.ensureCustomProperties.attach(f,l)]:[3,2]));case 1:p.sent(),p.label=2;case 2:return da.releaseDependencies(t.representation.structure.themes,{structure:a.data.sourceData},i),[4,da.ensureDependencies(f,t.representation.structure.themes,{structure:l},o)];case 3:return p.sent(),a.data.repr.setTheme(da.create(t.representation.structure.themes,{structure:l},o)),d=P(P({},a.data.repr.props),o.type.params),[4,a.data.repr.createOrUpdate(d,l).runInContext(u)];case 4:return p.sent(),a.data.sourceData=n.data,[2,rt.UpdateResult.Updated]}})})})},dispose:function(e,t){var r=e.b,n=e.params;if(!(!r||!n)){var a=r.data.sourceData,i=t.representation.structure.registry.get(n.type.name);i.ensureCustomProperties&&i.ensureCustomProperties.detach(a),da.releaseDependencies(t.representation.structure.themes,{structure:a},n)}},interpolate:function(e,t,r){if(e.colorTheme.name!=="uniform"||t.colorTheme.name!=="uniform")return r<=.5?e:t;var n=e.colorTheme.params.value,a=t.colorTheme.params.value,i=Xe.interpolate(n,a,r);return{type:r<=.5?e.type:t.type,colorTheme:{name:"uniform",params:{value:i}},sizeTheme:r<=.5?e.sizeTheme:t.sizeTheme}}}),SBe=It.BuiltIn({name:"unwind-structure-assembly-representation-3d",display:"Unwind Assembly 3D Representation",from:he.Molecule.Structure.Representation3D,to:he.Molecule.Structure.Representation3DState,params:{t:w.Numeric(0,{min:0,max:1,step:.01})}})({canAutoUpdate:function(){return!0},apply:function(e){var t=e.a,r=e.params,n=t.data.sourceData,a=new Iv(n);return ZO(n,a,r.t),new he.Molecule.Structure.Representation3DState({state:{unitTransforms:a},initialState:{unitTransforms:new Iv(n)},info:n,repr:t.data.repr},{label:"Unwind T = ".concat(r.t.toFixed(2))})},update:function(e){var t=e.a,r=e.b,n=e.newParams,a=e.oldParams,i=r.data.info;if(t.data.sourceData!==i)return rt.UpdateResult.Recreate;if(t.data.repr!==r.data.repr)return rt.UpdateResult.Recreate;if(a.t===n.t)return rt.UpdateResult.Unchanged;var o=r.data.state.unitTransforms;return ZO(i,o,n.t),r.label="Unwind T = ".concat(n.t.toFixed(2)),r.data.repr=t.data.repr,rt.UpdateResult.Updated}}),CBe=It.BuiltIn({name:"explode-structure-representation-3d",display:"Explode 3D Representation",from:he.Molecule.Structure.Representation3D,to:he.Molecule.Structure.Representation3DState,params:{t:w.Numeric(0,{min:0,max:1,step:.01})}})({canAutoUpdate:function(){return!0},apply:function(e){var t=e.a,r=e.params,n=t.data.sourceData,a=new Iv(n);return QO(n,a,r.t,n.root.boundary.sphere),new he.Molecule.Structure.Representation3DState({state:{unitTransforms:a},initialState:{unitTransforms:new Iv(n)},info:n,repr:t.data.repr},{label:"Explode T = ".concat(r.t.toFixed(2))})},update:function(e){var t=e.a,r=e.b,n=e.newParams,a=e.oldParams,i=t.data.sourceData;if(r.data.info!==i)return rt.UpdateResult.Recreate;if(t.data.repr!==r.data.repr)return rt.UpdateResult.Recreate;if(a.t===n.t)return rt.UpdateResult.Unchanged;var o=r.data.state.unitTransforms;return QO(i,o,n.t,i.root.boundary.sphere),r.label="Explode T = ".concat(n.t.toFixed(2)),r.data.repr=t.data.repr,rt.UpdateResult.Updated}}),_Be=It.BuiltIn({name:"spin-structure-representation-3d",display:"Spin 3D Representation",from:he.Molecule.Structure.Representation3D,to:he.Molecule.Structure.Representation3DState,params:P({t:w.Numeric(0,{min:0,max:1,step:.01})},BJ)})({canAutoUpdate:function(){return!0},apply:function(e){var t=e.a,r=e.params,n=t.data.sourceData,a=new Iv(n),i=$O(n.root,r),o=i.axis,s=i.origin;return JO(n,a,r.t,o,s),new he.Molecule.Structure.Representation3DState({state:{unitTransforms:a},initialState:{unitTransforms:new Iv(n)},info:n,repr:t.data.repr},{label:"Spin T = ".concat(r.t.toFixed(2))})},update:function(e){var t=e.a,r=e.b,n=e.newParams,a=e.oldParams,i=t.data.sourceData;if(r.data.info!==i)return rt.UpdateResult.Recreate;if(t.data.repr!==r.data.repr)return rt.UpdateResult.Recreate;if(a.t===n.t&&a.axis===n.axis&&a.origin===n.origin)return rt.UpdateResult.Unchanged;var o=r.data.state.unitTransforms,s=$O(i.root,n),u=s.axis,c=s.origin;return JO(i,o,n.t,u,c),r.label="Spin T = ".concat(n.t.toFixed(2)),r.data.repr=t.data.repr,rt.UpdateResult.Updated}}),wBe=It.BuiltIn({name:"overpaint-structure-representation-3d-from-script",display:"Overpaint 3D Representation",from:he.Molecule.Structure.Representation3D,to:he.Molecule.Structure.Representation3DState,params:function(){return{layers:w.ObjectList({script:w.Script(Ea("(sel.atom.all)","mol-script")),color:w.Color(Xt.blueviolet),clear:w.Boolean(!1)},function(e){return"".concat(e.clear?"Clear":Xe.toRgbString(e.color))},{defaultValue:[{script:Ea("(sel.atom.all)","mol-script"),color:Xt.blueviolet,clear:!1}]})}}})({canAutoUpdate:function(){return!0},apply:function(e){var t=e.a,r=e.params,n=t.data.sourceData,a=t.data.repr.geometryVersion,i=Fi.ofScript(r.layers,n);return new he.Molecule.Structure.Representation3DState({state:{overpaint:i},initialState:{overpaint:Fi.Empty},info:{structure:n,geometryVersion:a},repr:t.data.repr},{label:"Overpaint (".concat(i.layers.length," Layers)")})},update:function(e){var t=e.a,r=e.b,n=e.newParams,a=e.oldParams,i=r.data.info,o=t.data.sourceData;if(o!==i.structure)return rt.UpdateResult.Recreate;if(t.data.repr!==r.data.repr)return rt.UpdateResult.Recreate;var s=t.data.repr.geometryVersion;if(s!==i.geometryVersion&&Fl(t.data.repr.props))return rt.UpdateResult.Recreate;var u=r.data.state.overpaint,c=Fi.ofScript(n.layers,o);return Fi.areEqual(u,c)?rt.UpdateResult.Unchanged:(i.geometryVersion=s,r.data.state.overpaint=c,r.data.repr=t.data.repr,r.label="Overpaint (".concat(c.layers.length," Layers)"),rt.UpdateResult.Updated)}}),TBe=It.BuiltIn({name:"overpaint-structure-representation-3d-from-bundle",display:"Overpaint 3D Representation",from:he.Molecule.Structure.Representation3D,to:he.Molecule.Structure.Representation3DState,params:function(){return{layers:w.ObjectList({bundle:w.Value(ie.Bundle.Empty),color:w.Color(Xt.blueviolet),clear:w.Boolean(!1)},function(e){return"".concat(e.clear?"Clear":Xe.toRgbString(e.color))},{defaultValue:[{bundle:ie.Bundle.Empty,color:Xt.blueviolet,clear:!1}],isHidden:!0})}}})({canAutoUpdate:function(){return!0},apply:function(e){var t=e.a,r=e.params,n=t.data.sourceData,a=t.data.repr.geometryVersion,i=Fi.ofBundle(r.layers,n);return new he.Molecule.Structure.Representation3DState({state:{overpaint:i},initialState:{overpaint:Fi.Empty},info:{structure:n,geometryVersion:a},repr:t.data.repr},{label:"Overpaint (".concat(i.layers.length," Layers)")})},update:function(e){var t=e.a,r=e.b,n=e.newParams,a=e.oldParams,i=r.data.info,o=t.data.sourceData;if(o!==i.structure)return rt.UpdateResult.Recreate;if(t.data.repr!==r.data.repr)return rt.UpdateResult.Recreate;var s=t.data.repr.geometryVersion;if(s!==i.geometryVersion&&Fl(t.data.repr.props))return rt.UpdateResult.Recreate;var u=r.data.state.overpaint,c=Fi.ofBundle(n.layers,o);return Fi.areEqual(u,c)?rt.UpdateResult.Unchanged:(i.geometryVersion=s,r.data.state.overpaint=c,r.data.repr=t.data.repr,r.label="Overpaint (".concat(c.layers.length," Layers)"),rt.UpdateResult.Updated)}}),ABe=It.BuiltIn({name:"transparency-structure-representation-3d-from-script",display:"Transparency 3D Representation",from:he.Molecule.Structure.Representation3D,to:he.Molecule.Structure.Representation3DState,params:function(){return{layers:w.ObjectList({script:w.Script(Ea("(sel.atom.all)","mol-script")),value:w.Numeric(.5,{min:0,max:1,step:.01},{label:"Transparency"})},function(e){return"Transparency (".concat(e.value,")")},{defaultValue:[{script:Ea("(sel.atom.all)","mol-script"),value:.5}]})}}})({canAutoUpdate:function(){return!0},apply:function(e){var t=e.a,r=e.params,n=t.data.sourceData,a=t.data.repr.geometryVersion,i=Li.ofScript(r.layers,n);return new he.Molecule.Structure.Representation3DState({state:{transparency:i},initialState:{transparency:Li.Empty},info:{structure:n,geometryVersion:a},repr:t.data.repr},{label:"Transparency (".concat(i.layers.length," Layers)")})},update:function(e){var t=e.a,r=e.b,n=e.newParams,a=e.oldParams,i=r.data.info,o=t.data.sourceData;if(o!==i.structure)return rt.UpdateResult.Recreate;if(t.data.repr!==r.data.repr)return rt.UpdateResult.Recreate;var s=t.data.repr.geometryVersion;if(s!==i.geometryVersion&&Fl(t.data.repr.props))return rt.UpdateResult.Recreate;var u=r.data.state.transparency,c=Li.ofScript(n.layers,o);return Li.areEqual(u,c)?rt.UpdateResult.Unchanged:(i.geometryVersion=s,r.data.state.transparency=c,r.data.repr=t.data.repr,r.label="Transparency (".concat(c.layers.length," Layers)"),rt.UpdateResult.Updated)}}),DBe=It.BuiltIn({name:"transparency-structure-representation-3d-from-bundle",display:"Transparency 3D Representation",from:he.Molecule.Structure.Representation3D,to:he.Molecule.Structure.Representation3DState,params:function(){return{layers:w.ObjectList({bundle:w.Value(ie.Bundle.Empty),value:w.Numeric(.5,{min:0,max:1,step:.01},{label:"Transparency"})},function(e){return"Transparency (".concat(e.value,")")},{defaultValue:[{bundle:ie.Bundle.Empty,value:.5}],isHidden:!0})}}})({canAutoUpdate:function(){return!0},apply:function(e){var t=e.a,r=e.params,n=t.data.sourceData,a=t.data.repr.geometryVersion,i=Li.ofBundle(r.layers,n);return new he.Molecule.Structure.Representation3DState({state:{transparency:i},initialState:{transparency:Li.Empty},info:{structure:n,geometryVersion:a},repr:t.data.repr},{label:"Transparency (".concat(i.layers.length," Layers)")})},update:function(e){var t=e.a,r=e.b,n=e.newParams,a=e.oldParams,i=r.data.info,o=t.data.sourceData;if(o!==i.structure)return rt.UpdateResult.Recreate;if(t.data.repr!==r.data.repr)return rt.UpdateResult.Recreate;var s=t.data.repr.geometryVersion;if(s!==i.geometryVersion&&Fl(t.data.repr.props))return rt.UpdateResult.Recreate;var u=r.data.state.transparency,c=Li.ofBundle(n.layers,o);return Li.areEqual(u,c)?rt.UpdateResult.Unchanged:(i.geometryVersion=s,r.data.state.transparency=c,r.data.repr=t.data.repr,r.label="Transparency (".concat(c.layers.length," Layers)"),rt.UpdateResult.Updated)}}),PBe=It.BuiltIn({name:"substance-structure-representation-3d-from-script",display:"Substance 3D Representation",from:he.Molecule.Structure.Representation3D,to:he.Molecule.Structure.Representation3DState,params:function(){return{layers:w.ObjectList({script:w.Script(Ea("(sel.atom.all)","mol-script")),material:Pi.getParam(),clear:w.Boolean(!1)},function(e){return"".concat(e.clear?"Clear":Pi.toString(e.material))},{defaultValue:[{script:Ea("(sel.atom.all)","mol-script"),material:Pi({roughness:1}),clear:!1}]})}}})({canAutoUpdate:function(){return!0},apply:function(e){var t=e.a,r=e.params,n=t.data.sourceData,a=t.data.repr.geometryVersion,i=ki.ofScript(r.layers,n);return new he.Molecule.Structure.Representation3DState({state:{substance:i},initialState:{substance:ki.Empty},info:{structure:n,geometryVersion:a},repr:t.data.repr},{label:"Substance (".concat(i.layers.length," Layers)")})},update:function(e){var t=e.a,r=e.b,n=e.newParams,a=e.oldParams,i=r.data.info,o=t.data.sourceData;if(o!==i.structure)return rt.UpdateResult.Recreate;if(t.data.repr!==r.data.repr)return rt.UpdateResult.Recreate;var s=t.data.repr.geometryVersion;if(s!==i.geometryVersion&&Fl(t.data.repr.props))return rt.UpdateResult.Recreate;var u=r.data.state.substance,c=ki.ofScript(n.layers,o);return ki.areEqual(u,c)?rt.UpdateResult.Unchanged:(i.geometryVersion=s,r.data.state.substance=c,r.data.repr=t.data.repr,r.label="Substance (".concat(c.layers.length," Layers)"),rt.UpdateResult.Updated)}}),EBe=It.BuiltIn({name:"substance-structure-representation-3d-from-bundle",display:"Substance 3D Representation",from:he.Molecule.Structure.Representation3D,to:he.Molecule.Structure.Representation3DState,params:function(){return{layers:w.ObjectList({bundle:w.Value(ie.Bundle.Empty),material:Pi.getParam(),clear:w.Boolean(!1)},function(e){return"".concat(e.clear?"Clear":Pi.toString(e.material))},{defaultValue:[{bundle:ie.Bundle.Empty,material:Pi({roughness:1}),clear:!1}],isHidden:!0})}}})({canAutoUpdate:function(){return!0},apply:function(e){var t=e.a,r=e.params,n=t.data.sourceData,a=t.data.repr.geometryVersion,i=ki.ofBundle(r.layers,n);return new he.Molecule.Structure.Representation3DState({state:{substance:i},initialState:{substance:ki.Empty},info:{structure:n,geometryVersion:a},repr:t.data.repr},{label:"Substance (".concat(i.layers.length," Layers)")})},update:function(e){var t=e.a,r=e.b,n=e.newParams,a=e.oldParams,i=r.data.info,o=t.data.sourceData;if(o!==i.structure)return rt.UpdateResult.Recreate;if(t.data.repr!==r.data.repr)return rt.UpdateResult.Recreate;var s=t.data.repr.geometryVersion;if(s!==i.geometryVersion&&Fl(t.data.repr.props))return rt.UpdateResult.Recreate;var u=r.data.state.substance,c=ki.ofBundle(n.layers,o);return ki.areEqual(u,c)?rt.UpdateResult.Unchanged:(i.geometryVersion=s,r.data.state.substance=c,r.data.repr=t.data.repr,r.label="Substance (".concat(c.layers.length," Layers)"),rt.UpdateResult.Updated)}}),IBe=It.BuiltIn({name:"clipping-structure-representation-3d-from-script",display:"Clipping 3D Representation",from:he.Molecule.Structure.Representation3D,to:he.Molecule.Structure.Representation3DState,params:function(){return{layers:w.ObjectList({script:w.Script(Ea("(sel.atom.all)","mol-script")),groups:w.Converted(function(e){return Dn.Groups.toNames(e)},function(e){return Dn.Groups.fromNames(e)},w.MultiSelect(Yh(Dn.Groups.Names),w.objectToOptions(Dn.Groups.Names)))},function(e){return"".concat(Dn.Groups.toNames(e.groups).length," group(s)")},{defaultValue:[{script:Ea("(sel.atom.all)","mol-script"),groups:Dn.Groups.Flag.None}]})}}})({canAutoUpdate:function(){return!0},apply:function(e){var t=e.a,r=e.params,n=t.data.sourceData,a=Dn.ofScript(r.layers,n);return new he.Molecule.Structure.Representation3DState({state:{clipping:a},initialState:{clipping:Dn.Empty},info:n,repr:t.data.repr},{label:"Clipping (".concat(a.layers.length," Layers)")})},update:function(e){var t=e.a,r=e.b,n=e.newParams,a=e.oldParams,i=r.data.info;if(t.data.sourceData!==i)return rt.UpdateResult.Recreate;if(t.data.repr!==r.data.repr)return rt.UpdateResult.Recreate;var o=r.data.state.clipping,s=Dn.ofScript(n.layers,i);return Dn.areEqual(o,s)?rt.UpdateResult.Unchanged:(r.data.state.clipping=s,r.data.repr=t.data.repr,r.label="Clipping (".concat(s.layers.length," Layers)"),rt.UpdateResult.Updated)}}),MBe=It.BuiltIn({name:"clipping-structure-representation-3d-from-bundle",display:"Clipping 3D Representation",from:he.Molecule.Structure.Representation3D,to:he.Molecule.Structure.Representation3DState,params:function(){return{layers:w.ObjectList({bundle:w.Value(ie.Bundle.Empty),groups:w.Converted(function(e){return Dn.Groups.toNames(e)},function(e){return Dn.Groups.fromNames(e)},w.MultiSelect(Yh(Dn.Groups.Names),w.objectToOptions(Dn.Groups.Names)))},function(e){return"".concat(Dn.Groups.toNames(e.groups).length," group(s)")},{defaultValue:[{bundle:ie.Bundle.Empty,groups:Dn.Groups.Flag.None}],isHidden:!0})}}})({canAutoUpdate:function(){return!0},apply:function(e){var t=e.a,r=e.params,n=t.data.sourceData,a=Dn.ofBundle(r.layers,n);return new he.Molecule.Structure.Representation3DState({state:{clipping:a},initialState:{clipping:Dn.Empty},info:n,repr:t.data.repr},{label:"Clipping (".concat(a.layers.length," Layers)")})},update:function(e){var t=e.a,r=e.b,n=e.newParams,a=e.oldParams,i=r.data.info;if(t.data.sourceData!==i)return rt.UpdateResult.Recreate;if(t.data.repr!==r.data.repr)return rt.UpdateResult.Recreate;var o=r.data.state.clipping,s=Dn.ofBundle(n.layers,i);return Dn.areEqual(o,s)?rt.UpdateResult.Unchanged:(r.data.state.clipping=s,r.data.repr=t.data.repr,r.label="Clipping (".concat(s.layers.length," Layers)"),rt.UpdateResult.Updated)}}),RBe=It.BuiltIn({name:"theme-strength-representation-3d",display:"Theme Strength 3D Representation",from:he.Molecule.Structure.Representation3D,to:he.Molecule.Structure.Representation3DState,params:function(){return{overpaintStrength:w.Numeric(1,{min:0,max:1,step:.01}),transparencyStrength:w.Numeric(1,{min:0,max:1,step:.01}),substanceStrength:w.Numeric(1,{min:0,max:1,step:.01})}}})({canAutoUpdate:function(){return!0},apply:function(e){var t=e.a,r=e.params;return new he.Molecule.Structure.Representation3DState({state:{themeStrength:{overpaint:r.overpaintStrength,transparency:r.transparencyStrength,substance:r.substanceStrength}},initialState:{themeStrength:{overpaint:1,transparency:1,substance:1}},info:{},repr:t.data.repr},{label:"Theme Strength",description:"".concat(r.overpaintStrength.toFixed(2),", ").concat(r.transparencyStrength.toFixed(2),", ").concat(r.substanceStrength.toFixed(2))})},update:function(e){var t,r,n,a=e.a,i=e.b,o=e.newParams,s=e.oldParams;return o.overpaintStrength===((t=i.data.state.themeStrength)===null||t===void 0?void 0:t.overpaint)&&o.transparencyStrength===((r=i.data.state.themeStrength)===null||r===void 0?void 0:r.transparency)&&o.substanceStrength===((n=i.data.state.themeStrength)===null||n===void 0?void 0:n.substance)?rt.UpdateResult.Unchanged:(i.data.state.themeStrength={overpaint:o.overpaintStrength,transparency:o.transparencyStrength,substance:o.substanceStrength},i.data.repr=a.data.repr,i.label="Theme Strength",i.description="".concat(o.overpaintStrength.toFixed(2),", ").concat(o.transparencyStrength.toFixed(2),", ").concat(o.substanceStrength.toFixed(2)),rt.UpdateResult.Updated)},interpolate:function(e,t,r){return{overpaintStrength:Fn(e.overpaintStrength,t.overpaintStrength,r),transparencyStrength:Fn(e.transparencyStrength,t.transparencyStrength,r),substanceStrength:Fn(e.substanceStrength,t.substanceStrength,r)}}}),al;(function(e){function t(a,i,o,s,u,c,l,f){var d=a.representation.volume.registry.get(i),m=a.representation.volume.themes.colorThemeRegistry.get(u||d.defaultColorTheme.name),h=a.representation.volume.themes.sizeThemeRegistry.get(l||d.defaultSizeTheme.name),p=w.getDefaultValues(d.getParams(a.representation.volume.themes,o));return{type:{name:i,params:s?P(P({},p),s):p},colorTheme:{name:m.name,params:c?P(P({},m.defaultValues),c):m.defaultValues},sizeTheme:{name:h.name,params:f?P(P({},h.defaultValues),f):h.defaultValues}}}e.getDefaultParams=t;function r(a,i,o,s,u,c,l){var f=a.representation.volume.registry.get(i),d=a.representation.volume.themes.colorThemeRegistry.get(s||f.defaultColorTheme.name),m=a.representation.volume.themes.sizeThemeRegistry.get(c||f.defaultSizeTheme.name);return{type:{name:i,params:o?P(P({},f.defaultValues),o):f.defaultValues},colorTheme:{name:f.defaultColorTheme.name,params:u?P(P({},d.defaultValues),u):d.defaultValues},sizeTheme:{name:f.defaultSizeTheme.name,params:l?P(P({},m.defaultValues),l):m.defaultValues}}}e.getDefaultParamsStatic=r;function n(a){var i,o,s,u;if(a.isoValue)return Je.IsoValue.toString(a.isoValue);if(!((o=(i=a.renderMode)===null||i===void 0?void 0:i.params)===null||o===void 0)&&o.isoValue)return Je.IsoValue.toString((u=(s=a.renderMode)===null||s===void 0?void 0:s.params)===null||u===void 0?void 0:u.isoValue)}e.getDescription=n})(al||(al={}));var BBe=It.BuiltIn({name:"volume-representation-3d",display:"3D Representation",from:he.Volume.Data,to:he.Volume.Representation3D,params:function(e,t){var r=t.representation.volume,n=r.registry,a=r.themes,i=n.get(n.default.name);if(!e)return{type:w.Mapped(n.default.name,n.types,function(s){return w.Group(n.get(s).getParams(a,Je.One))}),colorTheme:w.Mapped(i.defaultColorTheme.name,a.colorThemeRegistry.types,function(s){return w.Group(a.colorThemeRegistry.get(s).getParams({volume:Je.One}))}),sizeTheme:w.Mapped(i.defaultSizeTheme.name,a.sizeThemeRegistry.types,function(s){return w.Group(a.sizeThemeRegistry.get(s).getParams({volume:Je.One}))})};var o={volume:e.data};return{type:w.Mapped(n.default.name,n.types,function(s){return w.Group(n.get(s).getParams(a,e.data))}),colorTheme:w.Mapped(i.defaultColorTheme.name,a.colorThemeRegistry.getApplicableTypes(o),function(s){return w.Group(a.colorThemeRegistry.get(s).getParams(o))}),sizeTheme:w.Mapped(i.defaultSizeTheme.name,a.sizeThemeRegistry.getApplicableTypes(o),function(s){return w.Group(a.sizeThemeRegistry.get(s).getParams(o))})}}})({canAutoUpdate:function(e){var t=e.oldParams,r=e.newParams;return t.type.name===r.type.name},apply:function(e,t){var r=this,n=e.a,a=e.params;return Ce.create("Volume Representation",function(i){return $(r,void 0,void 0,function(){var o,s,u,c,l;return J(this,function(f){switch(f.label){case 0:return o={runtime:i,assetManager:t.managers.asset},s=t.representation.volume.registry.get(a.type.name),s.ensureCustomProperties?[4,s.ensureCustomProperties.attach(o,n.data)]:[3,2];case 1:f.sent(),f.label=2;case 2:return u=s.factory(P({webgl:(l=t.canvas3d)===null||l===void 0?void 0:l.webgl},t.representation.volume.themes),s.getParams),u.setTheme(da.create(t.representation.volume.themes,{volume:n.data},a)),c=a.type.params||{},[4,u.createOrUpdate(c,n.data).runInContext(i)];case 3:return f.sent(),[2,new he.Volume.Representation3D({repr:u,sourceData:n.data},{label:s.label,description:al.getDescription(c)})]}})})})},update:function(e,t){var r=this,n=e.a,a=e.b,i=e.oldParams,o=e.newParams;return Ce.create("Volume Representation",function(s){return $(r,void 0,void 0,function(){var u,c,l;return J(this,function(f){switch(f.label){case 0:return o.type.name!==i.type.name?(u=t.representation.volume.registry.get(i.type.name),(l=u.ensureCustomProperties)===null||l===void 0||l.detach(n.data),[2,rt.UpdateResult.Recreate]):(c=P(P({},a.data.repr.props),o.type.params),a.data.repr.setTheme(da.create(t.representation.volume.themes,{volume:n.data},o)),[4,a.data.repr.createOrUpdate(c,n.data).runInContext(s)]);case 1:return f.sent(),a.data.sourceData=n.data,a.description=al.getDescription(c),[2,rt.UpdateResult.Updated]}})})})}});var OBe=It.BuiltIn({name:"shape-representation-3d",display:"3D Representation",from:he.Shape.Provider,to:he.Shape.Representation3D,params:function(e,t){return e?e.data.params:Ze.Params}})({canAutoUpdate:function(){return!0},apply:function(e,t){var r=this,n=e.a,a=e.params;return Ce.create("Shape Representation",function(i){return $(r,void 0,void 0,function(){var o,s;return J(this,function(u){switch(u.label){case 0:return o=P(P({},w.getDefaultValues(n.data.params)),a),s=Ia(n.data.getShape,n.data.geometryUtils),[4,s.createOrUpdate(o,n.data.data).runInContext(i)];case 1:return u.sent(),[2,new he.Shape.Representation3D({repr:s,sourceData:n.data},{label:n.data.label})]}})})})},update:function(e,t){var r=this,n=e.a,a=e.b,i=e.oldParams,o=e.newParams;return Ce.create("Shape Representation",function(s){return $(r,void 0,void 0,function(){var u;return J(this,function(c){switch(c.label){case 0:return u=P(P({},a.data.repr.props),o),[4,a.data.repr.createOrUpdate(u,n.data.data).runInContext(s)];case 1:return c.sent(),a.data.sourceData=n.data,[2,rt.UpdateResult.Updated]}})})})}});var FBe=It.BuiltIn({name:"model-unitcell-3d",display:"Model Unit Cell",from:he.Molecule.Model,to:he.Shape.Representation3D,params:function(){return P({},eF)}})({isApplicable:function(e){return!!jn.Provider.get(e.data)},canAutoUpdate:function(e){var t=e.oldParams,r=e.newParams;return!0},apply:function(e,t){var r=this,n=e.a,a=e.params;return Ce.create("Model Unit Cell",function(i){return $(r,void 0,void 0,function(){var o,s,u,c;return J(this,function(l){switch(l.label){case 0:return o=jn.Provider.get(n.data),o?(s=tF(n.data,o,a),u=FJ(P({webgl:(c=t.canvas3d)===null||c===void 0?void 0:c.webgl},t.representation.structure.themes),function(){return eF}),[4,u.createOrUpdate(a,s).runInContext(i)]):[2,gn.Null];case 1:return l.sent(),[2,new he.Shape.Representation3D({repr:u,sourceData:s},{label:"Unit Cell",description:o.spacegroup.name})]}})})})},update:function(e){var t=this,r=e.a,n=e.b,a=e.newParams;return Ce.create("Model Unit Cell",function(i){return $(t,void 0,void 0,function(){var o,s,u;return J(this,function(c){switch(c.label){case 0:return o=jn.Provider.get(r.data),o?(s=P(P({},n.data.repr.props),a),u=tF(r.data,o,s),[4,n.data.repr.createOrUpdate(s,u).runInContext(i)]):[2,rt.UpdateResult.Null];case 1:return c.sent(),n.data.sourceData=u,[2,rt.UpdateResult.Updated]}})})})}});var LBe=It.BuiltIn({name:"structure-bounding-box-3d",display:"Bounding Box",from:he.Molecule.Structure,to:he.Shape.Representation3D,params:P({radius:w.Numeric(.05,{min:.01,max:4,step:.01},{isEssential:!0}),color:w.Color(Xt.red,{isEssential:!0})},pt.Params)})({canAutoUpdate:function(){return!0},apply:function(e,t){var r=this,n=e.a,a=e.params;return Ce.create("Bounding Box",function(i){return $(r,void 0,void 0,function(){var o;return J(this,function(s){switch(s.label){case 0:return o=Ia(function(u,c,l,f){var d=PT(c.box,c.radius,f?.geometry);return gr.create("Bouding Box",c,d,function(){return c.color},function(){return 1},function(){return"Bounding Box"})},pt.Utils),[4,o.createOrUpdate(a,{box:n.data.boundary.box,radius:a.radius,color:a.color}).runInContext(i)];case 1:return s.sent(),[2,new he.Shape.Representation3D({repr:o,sourceData:n.data},{label:"Bounding Box"})]}})})})},update:function(e,t){var r=this,n=e.a,a=e.b,i=e.oldParams,o=e.newParams;return Ce.create("Bounding Box",function(s){return $(r,void 0,void 0,function(){return J(this,function(u){switch(u.label){case 0:return[4,a.data.repr.createOrUpdate(o,{box:n.data.boundary.box,radius:o.radius,color:o.color}).runInContext(s)];case 1:return u.sent(),a.data.sourceData=n.data,[2,rt.UpdateResult.Updated]}})})})}});var kBe=It.BuiltIn({name:"structure-selections-distance-3d",display:"3D Distance",from:he.Molecule.Structure.Selections,to:he.Shape.Representation3D,params:function(){return P({},nF)}})({canAutoUpdate:function(e){var t=e.oldParams,r=e.newParams;return!0},apply:function(e,t){var r=this,n=e.a,a=e.params;return Ce.create("Structure Distance",function(i){return $(r,void 0,void 0,function(){var o,s,u;return J(this,function(c){switch(c.label){case 0:return o=aF(n.data),s=zJ(P({webgl:(u=t.canvas3d)===null||u===void 0?void 0:u.webgl},t.representation.structure.themes),function(){return nF}),[4,s.createOrUpdate(a,o).runInContext(i)];case 1:return c.sent(),[2,new he.Shape.Representation3D({repr:s,sourceData:o},{label:"Distance"})]}})})})},update:function(e,t){var r=this,n=e.a,a=e.b,i=e.oldParams,o=e.newParams;return Ce.create("Structure Distance",function(s){return $(r,void 0,void 0,function(){var u,c;return J(this,function(l){switch(l.label){case 0:return u=P(P({},a.data.repr.props),o),c=aF(n.data),[4,a.data.repr.createOrUpdate(u,c).runInContext(s)];case 1:return l.sent(),a.data.sourceData=c,[2,rt.UpdateResult.Updated]}})})})}});var NBe=It.BuiltIn({name:"structure-selections-angle-3d",display:"3D Angle",from:he.Molecule.Structure.Selections,to:he.Shape.Representation3D,params:function(){return P({},pF)}})({canAutoUpdate:function(e){var t=e.oldParams,r=e.newParams;return!0},apply:function(e,t){var r=this,n=e.a,a=e.params;return Ce.create("Structure Angle",function(i){return $(r,void 0,void 0,function(){var o,s,u;return J(this,function(c){switch(c.label){case 0:return o=iF(n.data),s=tee(P({webgl:(u=t.canvas3d)===null||u===void 0?void 0:u.webgl},t.representation.structure.themes),function(){return pF}),[4,s.createOrUpdate(a,o).runInContext(i)];case 1:return c.sent(),[2,new he.Shape.Representation3D({repr:s,sourceData:o},{label:"Angle"})]}})})})},update:function(e,t){var r=this,n=e.a,a=e.b,i=e.oldParams,o=e.newParams;return Ce.create("Structure Angle",function(s){return $(r,void 0,void 0,function(){var u,c;return J(this,function(l){switch(l.label){case 0:return u=P(P({},a.data.repr.props),o),c=iF(n.data),[4,a.data.repr.createOrUpdate(u,c).runInContext(s)];case 1:return l.sent(),a.data.sourceData=c,[2,rt.UpdateResult.Updated]}})})})}});var UBe=It.BuiltIn({name:"structure-selections-dihedral-3d",display:"3D Dihedral",from:he.Molecule.Structure.Selections,to:he.Shape.Representation3D,params:function(){return P({},hF)}})({canAutoUpdate:function(e){var t=e.oldParams,r=e.newParams;return!0},apply:function(e,t){var r=this,n=e.a,a=e.params;return Ce.create("Structure Dihedral",function(i){return $(r,void 0,void 0,function(){var o,s,u;return J(this,function(c){switch(c.label){case 0:return o=oF(n.data),s=iee(P({webgl:(u=t.canvas3d)===null||u===void 0?void 0:u.webgl},t.representation.structure.themes),function(){return hF}),[4,s.createOrUpdate(a,o).runInContext(i)];case 1:return c.sent(),[2,new he.Shape.Representation3D({repr:s,sourceData:o},{label:"Dihedral"})]}})})})},update:function(e,t){var r=this,n=e.a,a=e.b,i=e.oldParams,o=e.newParams;return Ce.create("Structure Dihedral",function(s){return $(r,void 0,void 0,function(){var u,c;return J(this,function(l){switch(l.label){case 0:return u=P(P({},a.data.repr.props),o),c=oF(n.data),[4,a.data.repr.createOrUpdate(u,c).runInContext(s)];case 1:return l.sent(),a.data.sourceData=c,[2,rt.UpdateResult.Updated]}})})})}});var VBe=It.BuiltIn({name:"structure-selections-label-3d",display:"3D Label",from:he.Molecule.Structure.Selections,to:he.Shape.Representation3D,params:function(){return P({},lF)}})({canAutoUpdate:function(e){var t=e.oldParams,r=e.newParams;return!0},apply:function(e,t){var r=this,n=e.a,a=e.params;return Ce.create("Structure Label",function(i){return $(r,void 0,void 0,function(){var o,s,u;return J(this,function(c){switch(c.label){case 0:return o=sF(n.data),s=jJ(P({webgl:(u=t.canvas3d)===null||u===void 0?void 0:u.webgl},t.representation.structure.themes),function(){return lF}),[4,s.createOrUpdate(a,o).runInContext(i)];case 1:return c.sent(),[2,new he.Shape.Representation3D({repr:s,sourceData:o},{label:"Label"})]}})})})},update:function(e,t){var r=this,n=e.a,a=e.b,i=e.oldParams,o=e.newParams;return Ce.create("Structure Label",function(s){return $(r,void 0,void 0,function(){var u,c;return J(this,function(l){switch(l.label){case 0:return u=P(P({},a.data.repr.props),o),c=sF(n.data),[4,a.data.repr.createOrUpdate(u,c).runInContext(s)];case 1:return l.sent(),a.data.sourceData=c,[2,rt.UpdateResult.Updated]}})})})}});var GBe=It.BuiltIn({name:"structure-selections-orientation-3d",display:"3D Orientation",from:he.Molecule.Structure.Selections,to:he.Shape.Representation3D,params:function(){return P({},mF)}})({canAutoUpdate:function(e){var t=e.oldParams,r=e.newParams;return!0},apply:function(e,t){var r=this,n=e.a,a=e.params;return Ce.create("Structure Orientation",function(i){return $(r,void 0,void 0,function(){var o,s,u;return J(this,function(c){switch(c.label){case 0:return o=uF(n.data),s=ZJ(P({webgl:(u=t.canvas3d)===null||u===void 0?void 0:u.webgl},t.representation.structure.themes),function(){return mF}),[4,s.createOrUpdate(a,o).runInContext(i)];case 1:return c.sent(),[2,new he.Shape.Representation3D({repr:s,sourceData:o},{label:"Orientation"})]}})})})},update:function(e,t){var r=this,n=e.a,a=e.b,i=e.oldParams,o=e.newParams;return Ce.create("Structure Orientation",function(s){return $(r,void 0,void 0,function(){var u,c;return J(this,function(l){switch(l.label){case 0:return u=P(P({},a.data.repr.props),o),c=uF(n.data),[4,a.data.repr.createOrUpdate(u,c).runInContext(s)];case 1:return l.sent(),a.data.sourceData=c,[2,rt.UpdateResult.Updated]}})})})}});var zBe=It.BuiltIn({name:"structure-selections-plane-3d",display:"3D Plane",from:he.Molecule.Structure.Selections,to:he.Shape.Representation3D,params:function(){return P({},yF)}})({canAutoUpdate:function(e){var t=e.oldParams,r=e.newParams;return!0},apply:function(e,t){var r=this,n=e.a,a=e.params;return Ce.create("Structure Plane",function(i){return $(r,void 0,void 0,function(){var o,s,u;return J(this,function(c){switch(c.label){case 0:return o=cF(n.data),s=cee(P({webgl:(u=t.canvas3d)===null||u===void 0?void 0:u.webgl},t.representation.structure.themes),function(){return yF}),[4,s.createOrUpdate(a,o).runInContext(i)];case 1:return c.sent(),[2,new he.Shape.Representation3D({repr:s,sourceData:o},{label:"Plane"})]}})})})},update:function(e,t){var r=this,n=e.a,a=e.b,i=e.oldParams,o=e.newParams;return Ce.create("Structure Plane",function(s){return $(r,void 0,void 0,function(){var u,c;return J(this,function(l){switch(l.label){case 0:return u=P(P({},a.data.repr.props),o),c=cF(n.data),[4,a.data.repr.createOrUpdate(u,c).runInContext(s)];case 1:return l.sent(),a.data.sourceData=c,[2,rt.UpdateResult.Updated]}})})})}});var Ye={Data:EM,Misc:IM,Model:wO,Volume:EO,Representation:bF,Shape:vF};function aa(){var e=function(t,r){return t.commands.dispatch(e,r||{})};return e.subscribe=function(t,r){return t.commands.subscribe(e,r)},e.id=Er.create22(),e}var lee=function(){function e(){this.subs=new Map,this.disposing=!1}return e.prototype.subscribe=function(t,r){var n=this,a=this.subs.get(t.id);return a||(a=[],this.subs.set(t.id,a)),a.push(r),{unsubscribe:function(){var i=n.subs.get(t.id);if(i){var o=i.indexOf(r);if(!(o<0)){for(var s=o+1;s0}},getDuration:function(e){return{kind:"fixed",durationMs:e.durationInMs}},initialState:function(){return{t:0}},setup:function(e,t,r){for(var n=r.state.data,a=!e.target||e.target==="all"?Ir.RootRef:e.target,i=n.select(Yt.Generators.ofType(he.Molecule.Structure.Representation3D,a)),o=n.build(),s=!1,u=0,c=i;u0||(s=!0,o.to(l).apply(Ye.Representation.UnwindStructureAssemblyRepresentation3D,{t:0},{tags:"animate-assembly-unwind"}))}if(s)return o.commit({doNotUpdateCurrent:!0})},teardown:function(e,t,r){var n=r.state.data,a=n.select(Yt.Generators.ofType(he.Molecule.Structure.Representation3DState).withTag("animate-assembly-unwind"));if(a.length!==0){for(var i=n.build(),o=0,s=a;o=1?(c=!0,u=1):u=u%1,l=0,f=i;l=.99999?[2,{kind:"finished"}]:[2,{kind:"next",state:e}]))})})}});var hee=ws.create({name:"built-in.animate-model-index",display:{name:"Animate Trajectory"},isExportable:!0,params:function(){return{mode:w.MappedStatic("loop",{palindrome:w.Group({}),loop:w.Group({direction:w.Select("forward",[["forward","Forward"],["backward","Backward"]])}),once:w.Group({direction:w.Select("forward",[["forward","Forward"],["backward","Backward"]])},{isFlat:!0})},{options:[["palindrome","Palindrome"],["loop","Loop"],["once","Once"]]}),duration:w.MappedStatic("fixed",{fixed:w.Group({durationInS:w.Numeric(5,{min:1,max:120,step:.1},{description:"Duration in seconds"})},{isFlat:!0}),computed:w.Group({targetFps:w.Numeric(30,{min:5,max:250,step:1},{label:"Target FPS"})},{isFlat:!0}),sequential:w.Group({maxFps:w.Numeric(30,{min:5,max:60,step:1})},{isFlat:!0})})}},canApply:function(e){for(var t=e.state.data,r=t.select(Yt.Generators.ofTransformer(Ye.Model.ModelFromTrajectory)),n=0,a=r;n1)return{canApply:!0}}return{canApply:!1,reason:"No trajectory to animate"}},getDuration:function(e,t){var r;if(((r=e.duration)===null||r===void 0?void 0:r.name)==="fixed")return{kind:"fixed",durationMs:e.duration.params.durationInS*1e3};if(e.duration.name==="computed"){for(var n=t.state.data,a=n.select(Yt.Generators.ofTransformer(Ye.Model.ModelFromTrajectory)),i=0,o=0,s=a;o0&&t.current-t.lastApplied<1e3/r.params.duration.params.maxFps)return[2,{kind:"skip"}];if(n=r.plugin.state.data,a=n.select(Yt.Generators.ofTransformer(Ye.Model.ModelFromTrajectory)),a.length===0)return[2,{kind:"finished"}];for(i=n.build(),o=r.params,s=e.palindromeDirections||{},u=!1,c=!0,l=function(p){var v=Yt.findAncestorOfType(n.tree,n.cells,p.transform.ref,he.Molecule.Trajectory);if(!v||!v.obj)return"continue";var g=v.obj;if(g.data.frameCount<=1)return"continue";i.to(p).update(function(b){var x=g.data.frameCount;if(x!==1)c=!1;else return b;if(o.duration.name==="sequential"){var S=1;if(o.mode.name==="once"){if(S=o.mode.params.direction==="backward"?-1:1,S===-1&&b.modelIndex===0||S===1&&b.modelIndex===x-1)return u=!0,b}else o.mode.name==="palindrome"&&(b.modelIndex===0?S=1:b.modelIndex===x-1?S=-1:S=s[p.transform.ref]||1);s[p.transform.ref]=S;var _=(b.modelIndex+S)%x;return _<0&&(_+=x),u=u||S===-1&&_===0||S===1&&_===x-1,{modelIndex:_}}else{var C=o.duration.name==="fixed"?o.duration.params.durationInS*1e3:Math.ceil(1e3*g.data.frameCount/o.duration.params.targetFps);if(o.mode.name==="once"&&t.current>=C)return u=!0,{modelIndex:g.data.frameCount-1};var D=t.current%C/C;o.mode.name==="loop"&&o.mode.params.direction==="backward"&&(D=1-D),o.mode.name==="palindrome"&&(D=2*D,D>1&&(D=2-D));var _=Math.min(Math.floor(g.data.frameCount*D),g.data.frameCount-1);return{modelIndex:_}}})},f=0,d=a;f1}},setup:function(e,t,r){var n=r.managers.snapshot.state.entries.get(0);vee(r,n,!0)},getDuration:function(e,t){return{kind:"fixed",durationMs:t.managers.snapshot.state.entries.toArray().reduce(function(r,n){var a;return r+((a=n.snapshot.durationInMs)!==null&&a!==void 0?a:0)},0)}},initialState:function(e,t){var r=t.managers.snapshot.state.entries.toArray();return{totalDuration:r.reduce(function(n,a){var i;return n+((i=a.snapshot.durationInMs)!==null&&i!==void 0?i:0)},0),snapshots:r,currentIndex:0}},apply:function(e,t,r){var n;return $(this,void 0,void 0,function(){var a,i,o,s,u;return J(this,function(c){if(t.current>=e.totalDuration)return[2,{kind:"finished"}];for(a=0,i=0,o=0,s=e.snapshots;o=e.snapshots.length?[2,{kind:"finished"}]:i===e.currentIndex?[2,{kind:"skip"}]:(vee(r.plugin,e.snapshots[i]),[2,{kind:"next",state:P(P({},e),{currentIndex:i})}])})})}});var _r;(function(e){var t=function(l){St(f,l);function f(){return l!==null&&l.apply(this,arguments)||this}return f}(he.Create({name:"Root",typeClass:"Root"}));e.Root=t;var r=function(l){St(f,l);function f(){return l!==null&&l.apply(this,arguments)||this}return f}(he.Create({name:"Category",typeClass:"Object"}));e.Category=r;var n=function(l){St(f,l);function f(){return l!==null&&l.apply(this,arguments)||this}return f}(he.CreateBehavior({name:"Behavior"}));e.Behavior=n,e.Categories={common:"Common",representation:"Representation",interaction:"Interaction","custom-props":"Custom Properties",misc:"Miscellaneous"},e.CreateCategory=It.BuiltIn({name:"create-behavior-category",display:{name:"Behavior Category"},from:t,to:r,params:{label:w.Text("",{isHidden:!0})}})({apply:function(l){var f=l.params;return new r({},{label:f.label})}});var a=new Map;function i(l){return a.get(l.id)}e.getCategoryId=i;function o(l){var f=It.CreateBuiltIn({name:l.name,display:l.display,from:[t],to:[n],params:l.params,apply:function(d,m){var h=d.params,p=l.label?l.label(h):{label:l.display.name,description:l.display.description};return new n(new l.ctor(m,h),p)},update:function(d){var m=this,h=d.b,p=d.newParams;return Ce.create("Update Behavior",function(){return $(m,void 0,void 0,function(){var v;return J(this,function(g){switch(g.label){case 0:return h.data.update?[4,h.data.update(p)]:[2,rt.UpdateResult.Unchanged];case 1:return v=g.sent(),[2,v?rt.UpdateResult.Updated:rt.UpdateResult.Unchanged]}})})})},canAutoUpdate:l.canAutoUpdate});return a.set(f.id,l.category),f}e.create=o;function s(l,f){return function(){function d(m){this.ctx=m,this.sub=void 0}return d.prototype.register=function(){var m=this;this.sub=l.subscribe(this.ctx,function(h){return f(h,m.ctx)})},d.prototype.dispose=function(){this.sub&&this.sub.unsubscribe(),this.sub=void 0},d}()}e.simpleCommandHandler=s;var u=function(){function l(f,d){this.ctx=f,this.params=d,this.subs=[]}return l.prototype.subscribeCommand=function(f,d){this.subs.push(f.subscribe(this.ctx,d))},l.prototype.subscribeObservable=function(f,d){this.subs.push(f.subscribe(d))},l.prototype.track=function(f){this.subs.push(f)},l.prototype.dispose=function(){for(var f=0,d=this.subs;f=0&&(m.subs.splice(p,1),h.unsubscribe())}}},l.prototype.dispose=function(){for(var f=0,d=this.subs;fDee,ClearHighlights:()=>Ree,Highlight:()=>Mee,RemoveObject:()=>Pee,SetCurrentObject:()=>Tee,Snapshots:()=>Bee,SyncBehaviors:()=>wee,ToggleExpanded:()=>Eee,ToggleVisibility:()=>Iee,Update:()=>Aee,registerDefault:()=>YBe,setSubtreeVisibility:()=>Jd});var $d=function(){function e(){this.subs=void 0}return e.prototype.subscribe=function(t,r){var n=this;typeof this.subs>"u"&&(this.subs=[]);var a=t.subscribe(r);return this.subs.push(a),{unsubscribe:function(){a&&n.subs&&Mc(n.subs,a)&&(a.unsubscribe(),a=void 0)}}},Object.defineProperty(e.prototype,"ev",{get:function(){return this._ev||(this._ev=Ps.create())},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){if(this._ev&&this._ev.dispose(),this.subs){for(var t=0,r=this.subs;t>2,s=new Uint8Array(i),u=new Uint32Array(s.buffer,0,o),c=0,l=0;l0?r.entries[0].snapshot.id:void 0,this.updateState({current:s,entries:n.asImmutable(),isPlaying:!1,nextSnapshotDelayInMs:r.playback?r.playback.nextSnapshotDelayInMs:t.DefaultNextSnapshotDelayInMs}),this.events.changed.next(void 0),s?(u=this.getEntry(s),c=u&&u.snapshot,c?[4,this.plugin.state.setSnapshot(c)]:[2]):[2];case 1:return l.sent(),r.playback&&r.playback.isPlaying&&this.play(!0),[2,c]}})})},t.prototype.syncCurrent=function(r){var n,a;return $(this,void 0,void 0,function(){var i,o,s,u,c,l;return J(this,function(f){switch(f.label){case 0:return i=this.state.entries.size===0,o=this.state.entries.size===1&&this.state.current&&this.state.current===this.defaultSnapshotId,!i&&!o?[2]:(s=this.plugin.state.getSnapshot(r?.params),((a=(n=r?.params)===null||n===void 0?void 0:n.image)!==null&&a!==void 0?a:this.plugin.state.snapshotParams.value.image)?[4,t.getCanvasImageAsset(this.plugin,"".concat(s.id,"-image.png"))]:[3,2]);case 1:return c=f.sent(),[3,3];case 2:c=void 0,f.label=3;case 3:return u=c,i?this.add(t.Entry(s,{name:r?.name,description:r?.description,image:u})):o&&(l=this.getEntry(this.state.current),l?.image&&this.plugin.managers.asset.delete(l.image),this.replace(this.state.current,s,{image:u})),this.defaultSnapshotId=s.id,[2]}})})},t.prototype.getStateSnapshot=function(r){return $(this,void 0,void 0,function(){return J(this,function(n){switch(n.label){case 0:return[4,this.syncCurrent(r)];case 1:return n.sent(),[2,{timestamp:+new Date,version:Xx,name:r&&r.name,description:r&&r.description,current:this.state.current,playback:{isPlaying:!!(r&&r.playOnLoad),nextSnapshotDelayInMs:this.state.nextSnapshotDelayInMs},entries:this.state.entries.valueSeq().toArray()}]}})})},t.prototype.serialize=function(r){return $(this,void 0,void 0,function(){var n,a,i,o,s,u,c,l,f,d,m,h,p,v,g,b,x;return J(this,function(S){switch(S.label){case 0:return i=(a=JSON).stringify,[4,this.getStateSnapshot({params:r?.params})];case 1:return n=i.apply(a,[S.sent(),null,2]),!r?.type||r.type==="json"||r.type==="molj"?[2,new Blob([n],{type:"application/json;charset=utf-8"})]:[3,2];case 2:o=new Uint8Array(b0(n)),Bm(o,0,n),s={"state.json":o},u=[],c=0,l=this.plugin.managers.asset.assets,S.label=3;case 3:return c0&&(g=JSON.stringify(u,null,2),b=new Uint8Array(b0(g)),Bm(b,0,g),s["assets.json"]=b),[4,this.plugin.runTask(X8(s))];case 7:return x=S.sent(),[2,new Blob([x],{type:"application/zip"})]}})})},t.prototype.open=function(r){return $(this,void 0,void 0,function(){var n,a,g,a,i,o,s,u,c,l,f,d,m,h,p,v,g,b;return J(this,function(x){switch(x.label){case 0:return x.trys.push([0,15,,16]),n=r.name.toLowerCase(),n.endsWith("json")||n.endsWith("molj")?[4,this.plugin.runTask(Il(r,"string"))]:[3,8];case 1:return a=x.sent(),g=JSON.parse(a),t.isStateSnapshot(g)?[4,this.setStateSnapshot(g)]:[3,3];case 2:return x.sent(),[3,7];case 3:return t.isStateSnapshot(g.data)?[4,this.setStateSnapshot(g.data)]:[3,5];case 4:return x.sent(),[3,7];case 5:return[4,this.plugin.state.setSnapshot(g)];case 6:x.sent(),x.label=7;case 7:return[3,14];case 8:return[4,this.plugin.runTask(Il(r,"zip"))];case 9:return a=x.sent(),i=Object.create(null),Ua(a,function(S,_){if(!(_==="state.json"||_==="assets.json")){var C=_.substring(_.indexOf("/")+1);i[C]=S}}),o=new File([a["state.json"]],"state.json"),[4,this.plugin.runTask(Il(o,"string"))];case 10:return s=x.sent(),a["assets.json"]?(u=new File([a["assets.json"]],"assets.json"),f=(l=JSON).parse,[4,this.plugin.runTask(Il(u,"string"))]):[3,12];case 11:for(c=f.apply(l,[x.sent()]),d=0,m=c;d"u"||typeof window>"u")return!1;var e=["Version/15.1 Safari","Version/15.2 Safari","Version/15.3 Safari"];if(e.some(function(a){return navigator.userAgent.indexOf(a)>0}))return!0;var t=/iPad|iPhone|iPod/.test(navigator.userAgent),r=navigator.userAgent.includes("Macintosh"),n=navigator.maxTouchPoints>=4;return!window.MSStream&&(t||r&&n)}};var WBe=function(){function e(t,r){this.key=t,this.defaultValue=r}return e.prototype.toString=function(){return this.key},e.prototype.valueOf=function(){return this.key},e}();function ia(e,t){return new WBe(e,t)}var Bn={item:ia,General:{IsBusyTimeoutMs:ia("plugin-config.is-busy-timeout",750),DisableAntialiasing:ia("plugin-config.disable-antialiasing",!1),DisablePreserveDrawingBuffer:ia("plugin-config.disable-preserve-drawing-buffer",!1),PixelScale:ia("plugin-config.pixel-scale",1),PickScale:ia("plugin-config.pick-scale",.25),PickPadding:ia("plugin-config.pick-padding",3),EnableWboit:ia("plugin-config.enable-wboit",!0),EnableDpoit:ia("plugin-config.enable-dpoit",!1),PreferWebGl1:ia("plugin-config.prefer-webgl1",Cee.preferWebGl1),AllowMajorPerformanceCaveat:ia("plugin-config.allow-major-performance-caveat",!1),PowerPreference:ia("plugin-config.power-preference","high-performance")},State:{DefaultServer:ia("plugin-state.server","https://webchem.ncbr.muni.cz/molstar-state"),CurrentServer:ia("plugin-state.server","https://webchem.ncbr.muni.cz/molstar-state"),HistoryCapacity:ia("history-capacity.server",5)},VolumeStreaming:{Enabled:ia("volume-streaming.enabled",!0),DefaultServer:ia("volume-streaming.server","https://ds.litemol.org"),CanStream:ia("volume-streaming.can-stream",function(e,t){return e.models.length===1&&Vt.probablyHasDensityMap(e.models[0])}),EmdbHeaderServer:ia("volume-streaming.emdb-header-server","https://files.wwpdb.org/pub/emdb/structures")},Viewport:{ShowExpand:ia("viewer.show-expand-button",!0),ShowControls:ia("viewer.show-controls-button",!0),ShowSettings:ia("viewer.show-settings-button",!0),ShowSelectionMode:ia("viewer.show-selection-model-button",!0),ShowAnimation:ia("viewer.show-animation-button",!0),ShowTrajectoryControls:ia("viewer.show-trajectory-controls",!0)},Download:{DefaultPdbProvider:ia("download.default-pdb-provider","pdbe"),DefaultEmdbProvider:ia("download.default-emdb-provider","pdbe")},Structure:{SizeThresholds:ia("structure.size-thresholds",Le.DefaultSizeThresholds),DefaultRepresentationPreset:ia("structure.default-representation-preset","auto"),DefaultRepresentationPresetParams:ia("structure.default-representation-preset-params",{}),SaccharideCompIdMapType:ia("structure.saccharide-comp-id-map-type","default")},Background:{Styles:ia("background.styles",[])}},_ee=function(){function e(t){var r=this;this._config=new Map,t&&t.forEach(function(n){var a=n[0],i=n[1];return r._config.set(a,i)})}return e.prototype.get=function(t){return this._config.has(t)?this._config.get(t):t.defaultValue},e.prototype.set=function(t,r){this._config.set(t,r)},e.prototype.delete=function(t){this._config.delete(t)},e}();function YBe(e){wee(e),Tee(e),Aee(e),Dee(e),Pee(e),Eee(e),Iee(e),Mee(e),Ree(e),Bee(e)}function wee(e){e.state.events.object.created.subscribe(function(t){he.isBehavior(t.obj)&&t.obj.data.register(t.ref)}),e.state.events.object.removed.subscribe(function(t){var r,n,a,i;he.isBehavior(t.obj)&&((n=(r=t.obj.data).unregister)===null||n===void 0||n.call(r),(i=(a=t.obj.data).dispose)===null||i===void 0||i.call(a))}),e.state.events.object.updated.subscribe(function(t){var r,n,a,i;t.action==="recreate"&&(t.oldObj&&he.isBehavior(t.oldObj)&&((n=(r=t.oldObj.data).unregister)===null||n===void 0||n.call(r),(i=(a=t.oldObj.data).dispose)===null||i===void 0||i.call(a)),t.obj&&he.isBehavior(t.obj)&&t.obj.data.register(t.ref))})}function Tee(e){rr.State.SetCurrentObject.subscribe(e,function(t){var r=t.state,n=t.ref;return r.setCurrent(n)})}function Aee(e){rr.State.Update.subscribe(e,function(t){var r=t.state,n=t.tree,a=t.options;return e.runTask(r.updateTree(n,a))})}function Dee(e){rr.State.ApplyAction.subscribe(e,function(t){var r=t.state,n=t.action,a=t.ref;return e.runTask(r.applyAction(n.action,n.params,a))})}function Pee(e){function t(r,n){var a=r.build().delete(n);return e.runTask(r.updateTree(a))}rr.State.RemoveObject.subscribe(e,function(r){var n=r.state,a=r.ref,i=r.removeParentGhosts;if(i){var o=n.tree,s=o.transforms.get(a);if(s.parent===a)return t(n,a);for(;;){var u=o.children.get(s.parent);if(s.parent===s.ref||u.size>1)return t(n,s.ref);var c=o.transforms.get(s.parent);if(!c.state.isGhost)return t(n,s.ref);s=c}}else return t(n,a)})}function Eee(e){rr.State.ToggleExpanded.subscribe(e,function(t){var r=t.state,n=t.ref;return r.updateCellState(n,function(a){var i=a.isCollapsed;return{isCollapsed:!i}})})}function Iee(e){rr.State.ToggleVisibility.subscribe(e,function(t){var r=t.state,n=t.ref;return Jd(r,n,!r.cells.get(n).state.isHidden)})}function Jd(e,t,r){ya.doPreOrder(e.tree,e.transforms.get(t),{state:e,value:r},XBe)}function XBe(e,t,r){r.state.updateCellState(e.ref,{isHidden:r.value})}function Mee(e){rr.Interactivity.Object.Highlight.subscribe(e,function(t){var r=t.state,n=t.ref;if(!(!e.canvas3d||e.isBusy)){e.managers.interactivity.lociHighlights.clearHighlights();for(var a=typeof n=="string"?[n]:n,i=0,o=a;iOee,SyncStructureRepresentation3DState:()=>Fee,UpdateRepresentationVisibility:()=>Lee,registerDefault:()=>KBe});function KBe(e){Oee(e),Fee(e),Lee(e)}function Oee(e){var t=e.state.data.events;t.object.created.subscribe(function(r){var n;he.isRepresentation3D(r.obj)&&(SF(r.state.cells.get(r.ref),r.obj.data.repr),r.obj.data.repr.setState({syncManually:!0}),(n=e.canvas3d)===null||n===void 0||n.add(r.obj.data.repr))}),t.object.updated.subscribe(function(r){var n,a;r.oldObj&&he.isRepresentation3D(r.oldObj)&&((n=e.canvas3d)===null||n===void 0||n.remove(r.oldObj.data.repr),r.oldObj.data.repr.destroy()),he.isRepresentation3D(r.obj)&&(SF(r.state.cells.get(r.ref),r.obj.data.repr),r.action==="recreate"&&r.obj.data.repr.setState({syncManually:!0}),(a=e.canvas3d)===null||a===void 0||a.add(r.obj.data.repr))}),t.object.removed.subscribe(function(r){var n;he.isRepresentation3D(r.obj)&&((n=e.canvas3d)===null||n===void 0||n.remove(r.obj.data.repr),r.obj.data.repr.destroy())})}function Fee(e){var t=e.state.data.events;t.object.created.subscribe(function(r){var n;if(he.Molecule.Structure.Representation3DState.is(r.obj)){var a=r.obj.data;a.repr.setState(a.state),(n=e.canvas3d)===null||n===void 0||n.update(a.repr)}}),t.object.updated.subscribe(function(r){var n;if(he.Molecule.Structure.Representation3DState.is(r.obj)){var a=r.obj.data;a.repr.setState(a.state),(n=e.canvas3d)===null||n===void 0||n.update(a.repr)}}),t.object.removed.subscribe(function(r){var n;if(he.Molecule.Structure.Representation3DState.is(r.obj)){var a=r.obj.data;a.repr.setState(a.initialState),(n=e.canvas3d)===null||n===void 0||n.update(a.repr)}})}function Lee(e){e.state.data.events.cell.stateUpdated.subscribe(function(t){var r,n=t.state.cells.get(t.ref);he.isRepresentation3D(n.obj)&&SF(n,n.obj.data.repr)&&((r=e.canvas3d)===null||r===void 0||r.syncVisibility())})}function SF(e,t){return t.state.visible===!!e.state.isHidden?(t.setState({visible:!e.state.isHidden}),!0):!1}var _F={};fi(_F,{Focus:()=>Uee,OrientAxes:()=>Vee,Reset:()=>kee,ResetAxes:()=>Gee,SetSnapshot:()=>Nee,registerDefault:()=>ZBe});function ZBe(e){kee(e),Uee(e),Nee(e),Vee(e),Gee(e)}function kee(e){rr.Camera.Reset.subscribe(e,function(t){e.managers.camera.reset(t?.snapshot,t?.durationMs)})}function Nee(e){rr.Camera.SetSnapshot.subscribe(e,function(t){var r=t.snapshot,n=t.durationMs;e.managers.camera.setSnapshot(r,n)})}function Uee(e){rr.Camera.Focus.subscribe(e,function(t){var r=t.center,n=t.radius,a=t.durationMs;e.managers.camera.focusSphere({center:r,radius:n},{durationMs:a}),e.events.canvas3d.settingsUpdated.next(void 0)})}function Vee(e){rr.Camera.OrientAxes.subscribe(e,function(t){var r=t.structures,n=t.durationMs;e.managers.camera.orientAxes(r,n)})}function Gee(e){rr.Camera.ResetAxes.subscribe(e,function(t){var r=t.durationMs;e.managers.camera.resetAxes(r)})}var kF={};fi(kF,{Canvas3DSetSettings:()=>$te,registerDefault:()=>kFe});function Ma(){return Ma.zero()}(function(e){function t(){return{x:0,y:0,width:0,height:0}}e.zero=t;function r(u,c,l,f){return{x:u,y:c,width:l,height:f}}e.create=r;function n(u){return P({},u)}e.clone=n;function a(u,c){return Object.assign(u,c)}e.copy=a;function i(u,c,l,f,d){return u.x=c,u.y=l,u.width=f,u.height=d,u}e.set=i;function o(u,c){return u[0]=c.x,u[1]=c.y,u[2]=c.width,u[3]=c.height,u}e.toVec4=o;function s(u,c){return u.x===c.x&&u.y===c.y&&u.width===c.width&&u.height===c.height}e.equals=s})(Ma||(Ma={}));var jf=Wt();function zee(e,t,r,n){var a=r.x,i=r.y,o=r.width,s=r.height;Wt.set(jf,t[0],t[1],t[2],1),Wt.transformMat4(jf,jf,n);var u=jf[3];return u!==0&&(jf[0]/=u,jf[1]/=u,jf[2]/=u),e[0]=(jf[0]+1)*o*.5+a,e[1]=(jf[1]+1)*s*.5+i,e[2]=(jf[2]+1)*.5,e[3]=u===0?0:1/u,e}function My(e,t,r,n){var a=r.x,i=r.y,o=r.width,s=r.height,u=t[0]-a,c=t[1]-i,l=t[2];return e[0]=2*u/o-1,e[1]=2*c/s-1,e[2]=2*l-1,y.transformMat4(e,e,n)}function wF(e){if(typeof e=="object"){if("buttons"in e)return e.buttons;if("which"in e){var t=e.which;if(t===2)return 4;if(t===3)return 2;if(t>0)return 1<=0)return 1<=4&&(U=!0);var fm=D[0],dm=D[1];X.next({x:wa,y:La,dx:fm,dy:dm,pageX:Zt,pageY:Rr,buttons:k,button:G,modifiers:R(),isStart:nd}),Me.copy(_,C),O=kv.Moving}}}function Ot(ze){if(f(ze.clientX,ze.clientY)){oa(C,ze);var Qe=oo(ze),yt=Qe.pageX,Zt=Qe.pageY,Rr=C[0],wa=C[1];o&&ze.preventDefault();var La=$Be(ze);k=G=xa.Flag.Auxilary,(La.dx||La.dy||La.dz)&&q.next(P(P({x:Rr,y:wa,pageX:yt,pageY:Zt},La),{buttons:k,button:G,modifiers:R()}))}}function ue(ze){var Qe,yt;m&&(ze.preventDefault(),(Qe=ze.stopImmediatePropagation)===null||Qe===void 0||Qe.call(ze),(yt=ze.stopPropagation)===null||yt===void 0||yt.call(ze))}var ye=0,we=0;function $e(ze){ue(ze),ye=ze.scale,we=ze.rotation,j.next({scale:ze.scale,rotation:ze.rotation,deltaRotation:0,deltaScale:0,isStart:!0})}function Et(ze,Qe){j.next({scale:ze.scale,rotation:ze.rotation,deltaRotation:we-ze.rotation,deltaScale:ye-ze.scale,isEnd:Qe}),we=ze.rotation,ye=ze.scale}function Tt(ze){ue(ze),Et(ze)}function nr(ze){ue(ze),Et(ze,!0)}function Br(){ee.next({})}function sr(ze){if(n instanceof Window||n instanceof Document||n===document.body)return!0;var Qe=n.getBoundingClientRect();return ze[0]>=0&&ze[1]>=0&&ze[0]0||ve)&&R(fe,"depth",0)}ft&&r.timer.markEnd("Renderer.renderDepthTransparent")},U=function(N,ee,oe){ft&&r.timer.mark("Renderer.renderMarkingDepth"),i.disable(a.BLEND),i.enable(a.DEPTH_TEST),i.depthMask(!0),O(N,ee,oe,0,!1),M.updateIfChanged(A.uMarkingType,RT.Depth);for(var me=N.renderables,pe=0,de=me.length;pe0&&R(me[pe],"marking",0)}ft&&r.timer.markEnd("Renderer.renderMarkingMask")},W=function(N,ee){N.hasOpaque&&X(N,ee,null),N.opacityAverage<1&&ae(N,ee,null)},X=function(N,ee,oe){var me,pe;ft&&r.timer.mark("Renderer.renderBlendedOpaque"),i.disable(a.BLEND),i.enable(a.DEPTH_TEST),i.depthMask(!0),O(N,ee,oe,1,!1);for(var de=N.renderables,re=0,te=de.length;re0)&&(!((me=fe.values.uDoubleSided)===null||me===void 0)&&me.ref.value?(((pe=fe.values.dTransparentBackfaces)===null||pe===void 0?void 0:pe.ref.value)!=="opaque"&&R(fe,"colorBlended",2),R(fe,"colorBlended",1)):R(fe,"colorBlended",0))}ft&&r.timer.markEnd("Renderer.renderBlendedTransparent")},q=function(N,ee,oe){ft&&r.timer.mark("Renderer.renderBlendedVolume"),i.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA),i.enable(a.BLEND),O(N,ee,oe,2,!1);for(var me=N.renderables,pe=0,de=me.length;pe0||ve.values.dGeometryType.ref.value==="directVolume"||((de=ve.values.dPointStyle)===null||de===void 0?void 0:de.ref.value)==="fuzzy"||ve.values.dGeometryType.ref.value==="text"||Ge)&&R(ve,"colorWboit",0)}ft&&r.timer.markEnd("Renderer.renderWboitTransparent")},Z=function(N,ee,oe){var me,pe,de,re;ft&&r.timer.mark("Renderer.renderDpoitOpaque"),i.disable(a.BLEND),i.enable(a.DEPTH_TEST),i.depthMask(!0),O(N,ee,oe,1,!1);for(var te=N.renderables,fe=0,ve=te.length;fe0||((re=De.values.dPointStyle)===null||re===void 0?void 0:re.ref.value)==="fuzzy"||De.values.dGeometryType.ref.value==="text"||Ke)&&R(De,"colorDpoit",0)}ft&&r.timer.markEnd("Renderer.renderDpoitTransparent")},H=function(N,ee,oe){ft&&r.timer.mark("Renderer.renderDpoitVolume"),i.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA),i.enable(a.BLEND),O(N,ee,oe,2,!1);for(var me=N.renderables,pe=0,de=me.length;pe"+o(l)+""})}e.format=s;function u(l,f){return u.create(l,f)}e.Trigger=u;function c(l,f){return u.create(void 0,f,l)}e.TriggerKey=c,function(l){function f(p,v,g){return{buttons:p,modifiers:v,code:g}}l.create=f,l.Empty={};function d(p,v,g){var b=p.buttons,x=p.modifiers;return b!==void 0&&(b===v||xa.has(b,v))&&(!x||Ro.areEqual(x,g))}l.match=d;function m(p,v,g,b){var x=p.modifiers,S=p.code;return S!==void 0&&(S===v||S.length===1&&v.length===4&&v.startsWith("Key")&&!!b&&b.length===1&&b.toUpperCase()===S.toUpperCase())&&(!x||Ro.areEqual(x,g))}l.matchKey=m;function h(p){var v=[],g=JBe(p.buttons,p.code);g&&v.push(g);var b=tOe(p.code);b&&v.push(b);var x=eOe(p.modifiers);return x&&v.push(x),v.join(" + ")}l.format=h}(u=e.Trigger||(e.Trigger={}))})(At||(At={}));var Up=xa;function JBe(e,t){var r=[];return e===void 0&&!t?r.push("any mouse button"):e===0?r.push("mouse hover"):e!==void 0&&(Up.has(e,Up.Flag.Primary)&&r.push("left mouse button"),Up.has(e,Up.Flag.Secondary)&&r.push("right mouse button"),Up.has(e,Up.Flag.Auxilary)&&r.push("wheel/middle mouse button"),Up.has(e,Up.Flag.Forth)&&r.push("three fingers")),r.join(" + ")}function eOe(e,t){var r=[];return e?(e.alt&&r.push("alt key"),e.control&&r.push("control key"),e.meta&&r.push("meta/command key"),e.shift&&r.push("shift key"),t&&r.length===0&&r.push("no key")):t&&r.push("any key"),r.join(" + ")}function tOe(e){return e?.startsWith("Key")&&(e=e.substring(3)),e&&a8(e).toLowerCase()}var Vp=xa,pc=Ro,Gp=At.Trigger,Lu=At.TriggerKey,Xee={dragRotate:At([Gp(Vp.Flag.Primary,pc.create())],"Rotate","Drag using ${triggers}"),dragRotateZ:At([Gp(Vp.Flag.Primary,pc.create({shift:!0,control:!0}))],"Rotate around z-axis (roll)","Drag using ${triggers}"),dragPan:At([Gp(Vp.Flag.Secondary,pc.create()),Gp(Vp.Flag.Primary,pc.create({control:!0}))],"Pan","Drag using ${triggers}"),dragZoom:At.Empty,dragFocus:At([Gp(Vp.Flag.Forth,pc.create())],"Focus","Drag using ${triggers}"),dragFocusZoom:At([Gp(Vp.Flag.Auxilary,pc.create())],"Focus and zoom","Drag using ${triggers}"),scrollZoom:At([Gp(Vp.Flag.Auxilary,pc.create())],"Zoom","Scroll using ${triggers}"),scrollFocus:At([Gp(Vp.Flag.Auxilary,pc.create({shift:!0}))],"Clip","Scroll using ${triggers}"),scrollFocusZoom:At.Empty,keyMoveForward:At([Lu("KeyW")],"Move forward","Press ${triggers}"),keyMoveBack:At([Lu("KeyS")],"Move back","Press ${triggers}"),keyMoveLeft:At([Lu("KeyA")],"Move left","Press ${triggers}"),keyMoveRight:At([Lu("KeyD")],"Move right","Press ${triggers}"),keyMoveUp:At([Lu("KeyR")],"Move up","Press ${triggers}"),keyMoveDown:At([Lu("KeyF")],"Move down","Press ${triggers}"),keyRollLeft:At([Lu("KeyQ")],"Roll left","Press ${triggers}"),keyRollRight:At([Lu("KeyE")],"Roll right","Press ${triggers}"),keyPitchUp:At([Lu("ArrowUp",pc.create({shift:!0}))],"Pitch up","Press ${triggers}"),keyPitchDown:At([Lu("ArrowDown",pc.create({shift:!0}))],"Pitch down","Press ${triggers}"),keyYawLeft:At([Lu("ArrowLeft",pc.create({shift:!0}))],"Yaw left","Press ${triggers}"),keyYawRight:At([Lu("ArrowRight",pc.create({shift:!0}))],"Yaw right","Press ${triggers}"),boostMove:At([Lu("ShiftLeft")],"Boost move","Press ${triggers}"),enablePointerLock:At([Lu("Space",pc.create({control:!0}))],"Enable pointer lock","Press ${triggers}")},DF={noScroll:w.Boolean(!0,{isHidden:!0}),rotateSpeed:w.Numeric(5,{min:1,max:10,step:1}),zoomSpeed:w.Numeric(7,{min:1,max:15,step:1}),panSpeed:w.Numeric(1,{min:.1,max:5,step:.1}),moveSpeed:w.Numeric(.75,{min:.1,max:3,step:.1}),boostMoveFactor:w.Numeric(5,{min:.1,max:10,step:.1}),flyMode:w.Boolean(!1),animate:w.MappedStatic("off",{off:w.EmptyGroup(),spin:w.Group({speed:w.Numeric(1,{min:-20,max:20,step:1})},{description:"Spin the 3D scene around the x-axis in view space"}),rock:w.Group({speed:w.Numeric(.3,{min:-5,max:5,step:.1}),angle:w.Numeric(10,{min:0,max:90,step:1},{description:"How many degrees to rotate in each direction."})},{description:"Rock the 3D scene around the x-axis in view space"})}),staticMoving:w.Boolean(!0,{isHidden:!0}),dynamicDampingFactor:w.Numeric(.2,{},{isHidden:!0}),minDistance:w.Numeric(.01,{},{isHidden:!0}),maxDistance:w.Numeric(1e150,{},{isHidden:!0}),gestureScaleFactor:w.Numeric(1,{},{isHidden:!0}),maxWheelDelta:w.Numeric(.02,{},{isHidden:!0}),bindings:w.Value(Xee,{isHidden:!0}),autoAdjustMinMaxDistance:w.MappedStatic("on",{off:w.EmptyGroup(),on:w.Group({minDistanceFactor:w.Numeric(0),minDistancePadding:w.Numeric(5),maxDistanceFactor:w.Numeric(10),maxDistanceMin:w.Numeric(20)})},{isHidden:!0})};var FT;(function(e){function t(r,n,a,i){i===void 0&&(i={});var o=P(P(P({},w.getDefaultValues(DF)),i),{bindings:P(P({},Xee),i.bindings)}),s=o.bindings,u=Ma.clone(n.viewport),c=!1,l=r.drag.subscribe(Ct),f=r.interactionEnd.subscribe(bt),d=r.wheel.subscribe(Mt),m=r.pinch.subscribe(Ot),h=r.gesture.subscribe(ue),p=r.keyDown.subscribe(we),v=r.keyUp.subscribe($e),g=r.move.subscribe(ye),b=r.lock.subscribe(nr),x=r.leave.subscribe(sr),S=!1,_=y(),C=y(),D=Me(),T=Me(),A=y(),E=0,I=Me(),R=Me(),B=0,O=0,z=0,k=Me(),G=Me(),V=Me(),U=Me(),Q=Me(),W=Me(),X=y.clone(n.target),ae=y.clone(n.position),q=y.clone(n.up),F=Me();function j(Qe,yt){return Me.set(F,(Qe-u.x)/u.width,(yt-u.y)/u.height)}var Z=Me();function Y(Qe,yt){return Me.set(Z,(Qe-u.width*.5-u.x)/(u.width*.5),(u.height+2*(u.y-yt))/u.width)}function H(){var Qe=r.width/r.height;return o.rotateSpeed*r.pixelRatio*Qe}var N=y(),ee=Jr(),oe=y(),me=y(),pe=y(),de=y();function re(){var Qe=T[0]-D[0],yt=T[1]-D[1];y.set(de,Qe,yt,0);var Zt=y.magnitude(de)*H();Zt?(y.sub(C,n.position,n.target),y.normalize(oe,C),y.normalize(me,n.up),y.normalize(pe,y.cross(pe,me,oe)),y.setMagnitude(me,me,yt),y.setMagnitude(pe,pe,Qe),y.add(de,me,pe),y.normalize(N,y.cross(N,de,C)),Jr.setAxisAngle(ee,N,Zt),y.transformQuat(C,C,ee),y.transformQuat(n.up,n.up,ee),y.copy(A,N),E=Zt):!o.staticMoving&&E&&(E*=Math.sqrt(1-o.dynamicDampingFactor),y.sub(C,n.position,n.target),Jr.setAxisAngle(ee,A,E),y.transformQuat(C,C,ee),y.transformQuat(n.up,n.up,ee)),Me.copy(D,T)}var te=Jr(),fe=y();function ve(){var Qe=(Re.rollRight-Re.rollLeft)/45,yt=(R[0]-I[0])*-Math.sign(R[1]),Zt=(R[1]-I[1])*-Math.sign(R[0]),Rr=-o.rotateSpeed*(-yt+Zt)+Qe;Rr?(y.normalize(fe,C),Jr.setAxisAngle(te,fe,Rr),y.transformQuat(n.up,n.up,te),B=Rr):!o.staticMoving&&B&&(B*=Math.sqrt(1-o.dynamicDampingFactor),y.normalize(fe,C),Jr.setAxisAngle(te,fe,B),y.transformQuat(n.up,n.up,te)),Me.copy(I,R)}var De=Jr(),Ge=y();function Ke(){var Qe=(Re.pitchUp-Re.pitchDown)/(o.flyMode?360:90),yt=-o.rotateSpeed*Qe;yt?(y.cross(Ge,C,n.up),y.normalize(Ge,Ge),Jr.setAxisAngle(De,Ge,yt),y.transformQuat(C,C,De),y.transformQuat(n.up,n.up,De),O=yt):!o.staticMoving&&O&&(O*=Math.sqrt(1-o.dynamicDampingFactor),y.cross(Ge,C,n.up),y.normalize(Ge,Ge),Jr.setAxisAngle(De,Ge,O),y.transformQuat(C,C,De),y.transformQuat(n.up,n.up,De))}var L=Jr(),K=y();function ge(){var Qe=(Re.yawRight-Re.yawLeft)/(o.flyMode?360:90),yt=-o.rotateSpeed*Qe;yt?(y.normalize(K,n.up),Jr.setAxisAngle(L,K,yt),y.transformQuat(C,C,L),y.transformQuat(n.up,n.up,L),z=yt):!o.staticMoving&&z&&(z*=Math.sqrt(1-o.dynamicDampingFactor),y.normalize(K,n.up),Jr.setAxisAngle(L,K,z),y.transformQuat(C,C,L),y.transformQuat(n.up,n.up,L))}function Pe(){var Qe=1+(G[1]-k[1])*o.zoomSpeed;Qe!==1&&Qe>0&&y.scale(C,C,Qe),o.staticMoving?Me.copy(k,G):k[1]+=(G[1]-k[1])*o.dynamicDampingFactor}function Ie(){var Qe=(U[1]-V[1])*o.zoomSpeed;if(Qe!==0){var yt=Math.max(1,n.state.radius+n.state.radius*Qe);n.setState({radius:yt})}o.staticMoving?Me.copy(V,U):V[1]+=(U[1]-V[1])*o.dynamicDampingFactor}var ke=Me(),Ne=y(),Ve=y();function et(){if(Me.sub(ke,Me.copy(ke,W),Q),Me.squaredMagnitude(ke)){var Qe=r.pixelRatio*o.panSpeed;ke[0]*=1/n.zoom*n.viewport.width*Qe,ke[1]*=1/n.zoom*n.viewport.height*Qe,y.cross(Ve,y.copy(Ve,C),n.up),y.setMagnitude(Ve,Ve,ke[0]),y.setMagnitude(Ne,n.up,ke[1]),y.add(Ve,Ve,Ne),y.add(n.position,n.position,Ve),y.add(n.target,n.target,Ve),o.staticMoving?Me.copy(Q,W):(Me.sub(ke,W,Q),Me.scale(ke,ke,o.dynamicDampingFactor),Me.add(Q,Q,ke))}}var Re={moveUp:0,moveDown:0,moveLeft:0,moveRight:0,moveForward:0,moveBack:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0,boostMove:0},je=y(),tt=y();function ht(Qe){y.sub(tt,n.position,n.target);var yt=Math.max(n.state.minNear,o.minDistance);y.setMagnitude(tt,tt,yt);var Zt=Qe*(60/1e3)*o.moveSpeed*(Re.boostMove===1?o.boostMoveFactor:1);if(Re.moveForward===1&&(y.normalize(je,tt),y.scaleAndSub(n.position,n.position,je,Zt),(o.flyMode||r.pointerLock)&&y.sub(n.target,n.position,tt)),Re.moveBack===1&&(y.normalize(je,tt),y.scaleAndAdd(n.position,n.position,je,Zt),(o.flyMode||r.pointerLock)&&y.sub(n.target,n.position,tt)),Re.moveLeft===1&&(y.cross(je,tt,n.up),y.normalize(je,je),o.flyMode||r.pointerLock?(y.scaleAndAdd(n.position,n.position,je,Zt),y.sub(n.target,n.position,tt)):(y.scaleAndSub(n.position,n.position,je,Zt),y.sub(n.target,n.position,C))),Re.moveRight===1&&(y.cross(je,tt,n.up),y.normalize(je,je),o.flyMode||r.pointerLock?(y.scaleAndSub(n.position,n.position,je,Zt),y.sub(n.target,n.position,tt)):(y.scaleAndAdd(n.position,n.position,je,Zt),y.sub(n.target,n.position,C))),Re.moveUp===1&&(y.normalize(je,n.up),o.flyMode||r.pointerLock?(y.scaleAndAdd(n.position,n.position,je,Zt),y.sub(n.target,n.position,tt)):(y.scaleAndSub(n.position,n.position,je,Zt),y.sub(n.target,n.position,C))),Re.moveDown===1&&(y.normalize(je,n.up),o.flyMode||r.pointerLock?(y.scaleAndSub(n.position,n.position,je,Zt),y.sub(n.target,n.position,tt)):(y.scaleAndAdd(n.position,n.position,je,Zt),y.sub(n.target,n.position,C))),o.flyMode||r.pointerLock){var Rr=y.distance(n.position,a.boundingSphereVisible.center);n.setState({minFar:Rr+a.boundingSphereVisible.radius})}}function ct(){var Qe=Math.min(Math.max(n.state.radiusMax*1e3,.01),o.maxDistance);y.squaredMagnitude(C)>Qe*Qe&&(y.setMagnitude(C,C,Qe),y.add(n.position,n.target,C),Me.copy(k,G),Me.copy(V,U)),y.squaredMagnitude(C)u.x+u.width||r.height-yt>u.y+u.height||Qe0&&(o.animate.name==="spin"?oo(yt):o.animate.name==="rock"&&nf(yt)),y.sub(C,n.position,n.target),re(),ve(),Ke(),ge(),Pe(),Ie(),et(),y.add(n.position,n.target,C),ct(),_t>0&&ht(Math.min(yt,15*1e3/60)),y.sub(C,n.position,n.target),ct(),y.squaredDistance(_,n.position)>Dr&&y.copy(_,n.position),_t=Qe}}function ut(){y.copy(n.target,X),y.copy(n.position,ae),y.copy(n.up,q),y.sub(C,n.position,n.target),y.copy(_,n.position)}function Ct(Qe){var yt=Qe.x,Zt=Qe.y,Rr=Qe.pageX,wa=Qe.pageY,La=Qe.buttons,ls=Qe.modifiers,bc=Qe.isStart,fs=xt(yt,Zt);if(!(bc&&fs)&&!(!bc&&!S)){S=!0,lm();var nd=At.match(s.dragRotate,La,ls),fm=At.match(s.dragRotateZ,La,ls),dm=At.match(s.dragPan,La,ls),fg=At.match(s.dragZoom,La,ls),so=At.match(s.dragFocus,La,ls),af=At.match(s.dragFocusZoom,La,ls);Y(Rr,wa),j(Rr,wa);var Cs=r.pixelRatio,kS=(yt*Cs-u.width/2-u.x)/u.width,NS=-(r.height-Zt*Cs-u.height/2-u.y)/u.height;if(bc&&(nd&&(Me.copy(T,Z),Me.copy(D,T)),fm&&(Me.set(R,kS,NS),Me.copy(I,R)),(fg||af)&&(Me.copy(k,F),Me.copy(G,k)),so&&(Me.copy(V,F),Me.copy(U,V)),dm&&(Me.copy(Q,F),Me.copy(W,Q))),nd&&Me.copy(T,Z),fm&&Me.set(R,kS,NS),(fg||af)&&Me.copy(G,F),so&&Me.copy(U,F),af){var hh=y.distance(n.state.position,n.state.target);n.setState({radius:hh/5})}dm&&Me.copy(W,F)}}function bt(){S=!1}function Mt(Qe){var yt=Qe.x,Zt=Qe.y,Rr=Qe.spinX,wa=Qe.spinY,La=Qe.dz,ls=Qe.buttons,bc=Qe.modifiers;if(!xt(yt,Zt)){var fs=J6(Rr*.075,wa*.075,La*1e-4);fs<-o.maxWheelDelta?fs=-o.maxWheelDelta:fs>o.maxWheelDelta&&(fs=o.maxWheelDelta),At.match(s.scrollZoom,ls,bc)&&(G[1]+=fs),At.match(s.scrollFocus,ls,bc)&&(U[1]+=fs)}}function Ot(Qe){var yt=Qe.fractionDelta,Zt=Qe.buttons,Rr=Qe.modifiers;At.match(s.scrollZoom,Zt,Rr)&&(S=!0,G[1]+=o.gestureScaleFactor*yt)}function ue(Qe){var yt=Qe.deltaScale;S=!0,G[1]+=o.gestureScaleFactor*yt}function ye(Qe){var yt=Qe.movementX,Zt=Qe.movementY;if(!(!r.pointerLock||yt===void 0||Zt===void 0)){var Rr=u.width*.5-u.x,wa=u.height*.5-u.y;Me.copy(D,Y(Rr,wa)),Me.copy(T,Y(yt+Rr,Zt+wa))}}function we(Qe){var yt=Qe.modifiers,Zt=Qe.code,Rr=Qe.key,wa=Qe.x,La=Qe.y;xt(wa,La)||(At.matchKey(s.keyMoveForward,Zt,yt,Rr)?Re.moveForward=1:At.matchKey(s.keyMoveBack,Zt,yt,Rr)?Re.moveBack=1:At.matchKey(s.keyMoveLeft,Zt,yt,Rr)?Re.moveLeft=1:At.matchKey(s.keyMoveRight,Zt,yt,Rr)?Re.moveRight=1:At.matchKey(s.keyMoveUp,Zt,yt,Rr)?Re.moveUp=1:At.matchKey(s.keyMoveDown,Zt,yt,Rr)?Re.moveDown=1:At.matchKey(s.keyRollLeft,Zt,yt,Rr)?Re.rollLeft=1:At.matchKey(s.keyRollRight,Zt,yt,Rr)?Re.rollRight=1:At.matchKey(s.keyPitchUp,Zt,yt,Rr)?Re.pitchUp=1:At.matchKey(s.keyPitchDown,Zt,yt,Rr)?Re.pitchDown=1:At.matchKey(s.keyYawLeft,Zt,yt,Rr)?Re.yawLeft=1:At.matchKey(s.keyYawRight,Zt,yt,Rr)&&(Re.yawRight=1),At.matchKey(s.boostMove,Zt,yt,Rr)&&(Re.boostMove=1),At.matchKey(s.enablePointerLock,Zt,yt,Rr)&&r.requestPointerLock(u))}function $e(Qe){var yt,Zt,Rr,wa,La,ls,bc,fs,nd,fm,dm,fg,so=Qe.modifiers,af=Qe.code,Cs=Qe.key,kS=Qe.x,NS=Qe.y;if(!xt(kS,NS)){var hh=!1;af.startsWith("Alt")?(hh=!0,so.alt=!0):af.startsWith("Shift")?(hh=!0,so.shift=!0):af.startsWith("Control")?(hh=!0,so.control=!0):af.startsWith("Meta")&&(hh=!0,so.meta=!0);var lu=[];hh?(Re.moveForward&&lu.push(((yt=s.keyMoveForward.triggers[0])===null||yt===void 0?void 0:yt.code)||""),Re.moveBack&&lu.push(((Zt=s.keyMoveBack.triggers[0])===null||Zt===void 0?void 0:Zt.code)||""),Re.moveLeft&&lu.push(((Rr=s.keyMoveLeft.triggers[0])===null||Rr===void 0?void 0:Rr.code)||""),Re.moveRight&&lu.push(((wa=s.keyMoveRight.triggers[0])===null||wa===void 0?void 0:wa.code)||""),Re.moveUp&&lu.push(((La=s.keyMoveUp.triggers[0])===null||La===void 0?void 0:La.code)||""),Re.moveDown&&lu.push(((ls=s.keyMoveDown.triggers[0])===null||ls===void 0?void 0:ls.code)||""),Re.rollLeft&&lu.push(((bc=s.keyRollLeft.triggers[0])===null||bc===void 0?void 0:bc.code)||""),Re.rollRight&&lu.push(((fs=s.keyRollRight.triggers[0])===null||fs===void 0?void 0:fs.code)||""),Re.pitchUp&&lu.push(((nd=s.keyPitchUp.triggers[0])===null||nd===void 0?void 0:nd.code)||""),Re.pitchDown&&lu.push(((fm=s.keyPitchDown.triggers[0])===null||fm===void 0?void 0:fm.code)||""),Re.yawLeft&&lu.push(((dm=s.keyYawLeft.triggers[0])===null||dm===void 0?void 0:dm.code)||""),Re.yawRight&&lu.push(((fg=s.keyYawRight.triggers[0])===null||fg===void 0?void 0:fg.code)||"")):lu.push(af);for(var OD=0,mk=lu;ODZt){var wa=n.getFocus(yt,Zt);n.setState(P(P({},wa),{minFar:0}))}else n.setState({minFar:0,radius:a.boundingSphereVisible.radius})}function nr(Qe){Qe?Et():Tt()}function Br(){Re.moveForward=0,Re.moveBack=0,Re.moveLeft=0,Re.moveRight=0,Re.moveUp=0,Re.moveDown=0,Re.rollLeft=0,Re.rollRight=0,Re.pitchUp=0,Re.pitchDown=0,Re.yawLeft=0,Re.yawRight=0,Re.boostMove=0}function sr(){Br()}function Sn(){c||(c=!0,l.unsubscribe(),d.unsubscribe(),m.unsubscribe(),h.unsubscribe(),f.unsubscribe(),p.unsubscribe(),v.unsubscribe(),g.unsubscribe(),b.unsubscribe(),x.unsubscribe())}var oa=Me.create(.005,0);function oo(Qe){if(!(o.animate.name!=="spin"||o.animate.params.speed===0||S)){var yt=o.animate.params.speed/1e3;oa[0]=60*Math.min(Math.abs(Qe),1e3/8)/1e3*yt,Me.add(T,D,oa)}}var ei=0,Yi=Me.create(.005,0);function nf(Qe){if(!(o.animate.name!=="rock"||o.animate.params.speed===0||S)){var yt=Qe/1e3*o.animate.params.speed,Zt=vr(o.animate.params.angle)/H(),Rr=Math.sin(ei*Math.PI*2)*Zt,wa=Math.sin((ei+yt)*Math.PI*2)*Zt;Yi[0]=wa-Rr,Me.add(T,D,Yi),ei+=yt,ei>=1&&(ei=0)}}function lm(){ei=0}function ze(Qe){_t=-1,Ue(Qe)}return{viewport:u,get isAnimating(){return o.animate.name!=="off"},get isMoving(){return Re.moveForward===1||Re.moveBack===1||Re.moveLeft===1||Re.moveRight===1||Re.moveUp===1||Re.moveDown===1||Re.rollLeft===1||Re.rollRight===1||Re.pitchUp===1||Re.pitchDown===1||Re.yawLeft===1||Re.yawRight===1},get props(){return o},setProps:function(Qe){var yt;((yt=Qe.animate)===null||yt===void 0?void 0:yt.name)==="rock"&&o.animate.name!=="rock"&&lm(),Qe.flyMode!==void 0&&Qe.flyMode!==o.flyMode&&(Qe.flyMode?Et():Tt()),Object.assign(o,Qe),Object.assign(s,Qe.bindings)},start:ze,update:Ue,reset:ut,dispose:Sn}}e.create=t})(FT||(FT={}));var Zx;(function(e){function t(){return{view:se.identity(),position:y.create(0,0,0),direction:y.create(0,0,-1),up:y.create(0,1,0)}}e.create=t;var r=y.zero();function n(a){y.add(r,a.position,a.direction),se.lookAt(a.view,a.position,r,a.up)}e.update=n})(Zx||(Zx={}));var Kee=function(){function e(){this.removeList=q1(),this.removeMap=new Map,this.addList=q1(),this.addMap=new Map}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.removeList.count===0&&this.addList.count===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.removeMap.size+this.addMap.size},enumerable:!1,configurable:!0}),e.prototype.add=function(t){if(this.removeMap.has(t)){var r=this.removeMap.get(t);this.removeMap.delete(t),this.removeList.remove(r)}if(!this.addMap.has(t)){var n=this.addList.addLast(t);this.addMap.set(t,n)}},e.prototype.remove=function(t){if(this.addMap.has(t)){var r=this.addMap.get(t);this.addMap.delete(t),this.addList.remove(r)}if(!this.removeMap.has(t)){var n=this.removeList.addLast(t);this.removeMap.set(t,n)}},e.prototype.tryGetRemove=function(){var t=this.removeList.removeFirst();return t&&this.removeMap.delete(t),t},e.prototype.tryGetAdd=function(){var t=this.addList.removeFirst();return t&&this.addMap.delete(t),t},e}();var Qx=new Di("98");function Zee(e,t,r){Qx.reset();for(var n=0,a=e.length;nV)return!1}for(;;){var W=I.tryGetAdd();if(!W)break;if(D(W),++Q%A===0&&pn()-U>V)return!1}return i.sort(rOe),d=!0,m=!0,h=!0,!0}var I=new Kee,R=-1;function B(){for(var V=23,U=0,Q=i.length;U0?U/V:0}function k(){var V,U;if(u.length===0)return 0;for(var Q=0,W=0,X=0,ae=u.length;X0?W/Q:0}function G(){var V;if(u.length===0)return!1;for(var U=0,Q=u.length;U0)&&Qn.copySnapshot(this._source,this.camera.state),this.inTransition||Qn.copySnapshot(this._target,this.camera.state),Qn.copySnapshot(this._target,t),this._target.radius>this._target.radiusMax&&(this._target.radius=this._target.radiusMax),this._target.radius<.01&&(this._target.radius=.01),this._target.radiusMax<.01&&(this._target.radiusMax=.01),!this.inTransition&&r<=0||typeof t.mode<"u"&&t.mode!==this.camera.state.mode){this.finish(this._target);return}this.inTransition=!0,this.func=n||e.defaultTransition,(!this.inTransition||r>0)&&(this.start=this.t,this.durationMs=r)},e.prototype.tick=function(t){this.t=t,this.update()},e.prototype.finish=function(t){Qn.copySnapshot(this.camera.state,t),this.inTransition=!1},e.prototype.update=function(){if(this.inTransition){var t=Math.min((this.t-this.start)/this.durationMs,1);if(t===1){this.finish(this._target);return}this.func(this._current,t,this._source,this._target),Qn.copySnapshot(this.camera.state,this._current)}},e}();(function(e){var t=Jr.identity();function r(n,a,i,o){Qn.copySnapshot(n,o),Jr.slerp(t,Jr.Identity,Jr.rotationTo(t,i.up,o.up),a),y.transformQuat(n.up,i.up,t),y.lerp(n.target,i.target,o.target,a),y.lerp(n.position,i.position,o.position,a),n.radius=Fn(i.radius,o.radius,a),n.radiusMax=Fn(i.radiusMax,o.radiusMax,a),n.fov=Fn(i.fov,o.fov,a),n.fog=Fn(i.fog,o.fog,a)}e.defaultTransition=r})(LT||(LT={}));var Qee=y(),$ee=y(),kT=Wt(),Qn=function(){function e(t,r,n){r===void 0&&(r=Ma.create(0,0,128,128)),n===void 0&&(n={}),this.view=se.identity(),this.projection=se.identity(),this.projectionView=se.identity(),this.inverseProjectionView=se.identity(),this.state=e.createDefaultSnapshot(),this.viewOffset=e.ViewOffset(),this.near=1,this.far=1e4,this.fogNear=5e3,this.fogFar=1e4,this.zoom=1,this.transition=new LT(this),this.stateChanged=new ha(this.state),this.prevProjection=se.identity(),this.prevView=se.identity(),this.deltaDirection=y(),this.newPosition=y(),this.viewport=r,this.pixelScale=n.pixelScale||1,e.copySnapshot(this.state,t)}return Object.defineProperty(e.prototype,"pixelRatio",{get:function(){var t=typeof window<"u"?window.devicePixelRatio:1;return t*this.pixelScale},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this.state.position},set:function(t){y.copy(this.state.position,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"up",{get:function(){return this.state.up},set:function(t){y.copy(this.state.up,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this.state.target},set:function(t){y.copy(this.state.target,t)},enumerable:!1,configurable:!0}),e.prototype.update=function(){var t=this.state;if(t.radiusMax===0)return!1;var r=2*Math.tan(t.fov/2)*y.distance(t.position,t.target);switch(this.zoom=this.viewport.height/r,iOe(this),this.state.mode){case"orthographic":nOe(this);break;case"perspective":aOe(this);break;default:cr(this.state.mode)}var n=!se.areEqual(this.projection,this.prevProjection,Dr)||!se.areEqual(this.view,this.prevView,Dr);if(n){if(se.mul(this.projectionView,this.projection,this.view),!se.tryInvert(this.inverseProjectionView,this.projectionView))return se.copy(this.view,this.prevView),se.copy(this.projection,this.prevProjection),se.mul(this.projectionView,this.projection,this.view),!1;se.copy(this.prevView,this.view),se.copy(this.prevProjection,this.projection)}return n},e.prototype.setState=function(t,r){this.transition.apply(t,r),this.stateChanged.next(t)},e.prototype.getSnapshot=function(){return e.copySnapshot(e.createDefaultSnapshot(),this.state)},e.prototype.getTargetDistance=function(t){return e.targetDistance(t,this.state.mode,this.state.fov,this.viewport.width,this.viewport.height)},e.prototype.getFocus=function(t,r,n,a,i){var o,s,u=Math.max(r,.01),c=this.getTargetDistance(u);y.sub(this.deltaDirection,(o=i?.target)!==null&&o!==void 0?o:this.target,(s=i?.position)!==null&&s!==void 0?s:this.position),a&&y.matchDirection(this.deltaDirection,a,this.deltaDirection),y.setMagnitude(this.deltaDirection,this.deltaDirection,c),y.sub(this.newPosition,t,this.deltaDirection);var l=e.copySnapshot(e.createDefaultSnapshot(),this.state);return l.target=y.clone(t),l.radius=u,l.position=y.clone(this.newPosition),n&&y.matchDirection(l.up,n,l.up),l},e.prototype.getCenter=function(t,r){y.sub(this.deltaDirection,this.target,this.position),y.sub(this.newPosition,t,this.deltaDirection);var n=e.copySnapshot(e.createDefaultSnapshot(),this.state);return n.target=y.clone(t),n.position=y.clone(this.newPosition),r&&(n.radius=Math.max(r,.01)),n},e.prototype.getInvariantFocus=function(t,r,n,a){var i=Math.max(r,.01),o=this.getTargetDistance(i);y.copy(this.deltaDirection,a),y.setMagnitude(this.deltaDirection,this.deltaDirection,o),y.sub(this.newPosition,t,this.deltaDirection);var s=e.copySnapshot(e.createDefaultSnapshot(),this.state);return s.target=y.clone(t),s.radius=i,s.position=y.clone(this.newPosition),y.copy(s.up,n),s},e.prototype.focus=function(t,r,n,a,i){r>0&&this.setState(this.getFocus(t,r,a,i),n)},e.prototype.center=function(t,r){this.setState(this.getCenter(t),r)},e.prototype.project=function(t,r){return zee(t,r,this.viewport,this.projectionView)},e.prototype.unproject=function(t,r){return My(t,r,this.viewport,this.inverseProjectionView)},e.prototype.getPixelSize=function(t){return this.project(kT,t),this.unproject(Qee,kT),kT[0]+=1,this.unproject($ee,kT),y.distance(Qee,$ee)},e}();(function(e){function t(){return{enabled:!1,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}}e.ViewOffset=t;function r(u,c,l,f,d,m,h){u.fullWidth=c,u.fullHeight=l,u.offsetX=f,u.offsetY=d,u.width=m,u.height=h}e.setViewOffset=r;function n(u,c){u.enabled=c.enabled,u.fullWidth=c.fullWidth,u.fullHeight=c.fullHeight,u.offsetX=c.offsetX,u.offsetY=c.offsetY,u.width=c.width,u.height=c.height}e.copyViewOffset=n;function a(u,c,l,f,d){var m=Math.max(u,.01),h=f/d,p=d1e3/this.props.maxFps&&(this.prevT=t,this.currentIdentifyT=t,this.identify(this.isInteracting?Nv.Drag:Nv.Move,t))},e.prototype.leave=function(){this.inside=!1,Lt.Loci.isEmpty(this.prevLoci)||(this.prevLoci=Lt.Loci.Empty,this.events.hover.next({current:this.prevLoci,buttons:this.buttons,button:this.button,modifiers:this.modifiers}))},e.prototype.move=function(t,r,n,a,i){this.inside=!0,this.buttons=n,this.button=a,this.modifiers=i,this.endX=t,this.endY=r},e.prototype.click=function(t,r,n,a,i){this.endX=t,this.endY=r,this.buttons=n,this.button=a,this.modifiers=i,this.identify(Nv.Click,0)},e.prototype.drag=function(t,r,n,a,i){this.endX=t,this.endY=r,this.buttons=n,this.button=a,this.modifiers=i,this.identify(Nv.Drag,0)},e.prototype.modify=function(t){Ro.areEqual(t,this.modifiers)||(this.modifiers=t,this.events.hover.next({current:this.prevLoci,buttons:this.buttons,button:this.button,modifiers:this.modifiers,page:Me.create(this.endX,this.endY),position:this.position}))},e.prototype.outsideViewport=function(t,r){var n=this,a=n.input,i=n.camera.viewport;return t*=a.pixelRatio,r*=a.pixelRatio,t>i.x+i.width||a.height-r>i.y+i.height||t pixelSizeOpaque && selfDepthOpaque > sampleDepthOpaque && sampleDepthOpaque <= bestDepth) { + outline = 0.0; + bestDepth = sampleDepthOpaque; + } + + if (sampleDepthTransparent < sampleDepthOpaque) { + float sampleViewZTransparent = isBackground(sampleDepthTransparent) ? backgroundViewZ : getViewZ(sampleDepthTransparent); + if (abs(selfViewZTransparent - sampleViewZTransparent) > pixelSizeTransparent && selfDepthTransparent > sampleDepthTransparent && sampleDepthTransparent <= bestDepth) { + outline = 0.0; + bestDepth = sampleDepthTransparent; + transparentFlag = 1.0; + } + } + } + } + + gl_FragColor = vec4(outline, packUnitIntervalToRG(bestDepth), transparentFlag); +} +`;var nte=` +precision highp float; +precision highp int; +precision highp sampler2D; + +#include common + +uniform sampler2D tDepth; +uniform sampler2D tDepthHalf; +uniform sampler2D tDepthQuarter; +uniform vec2 uTexSize; +uniform vec4 uBounds; + +uniform vec3 uSamples[dNSamples]; + +uniform mat4 uProjection; +uniform mat4 uInvProjection; + +#ifdef dMultiScale + uniform float uLevelRadius[dLevels]; + uniform float uLevelBias[dLevels]; + uniform float uNearThreshold; + uniform float uFarThreshold; +#else + uniform float uRadius; +#endif +uniform float uBias; + +float smootherstep(float edge0, float edge1, float x) { + x = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0); + return x * x * x * (x * (x * 6.0 - 15.0) + 10.0); +} + +float noise(const in vec2 coords) { + float a = 12.9898; + float b = 78.233; + float c = 43758.5453; + float dt = dot(coords, vec2(a,b)); + float sn = mod(dt, PI); + return abs(fract(sin(sn) * c)); // is abs necessary? +} + +vec2 getNoiseVec2(const in vec2 coords) { + return vec2(noise(coords), noise(coords + vec2(PI, 2.71828))); +} + +bool isBackground(const in float depth) { + return depth == 1.0; +} + +float getDepth(const in vec2 coords) { + vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w)); + #ifdef depthTextureSupport + return texture2D(tDepth, c).r; + #else + return unpackRGBAToDepth(texture2D(tDepth, c)); + #endif +} + +#define dQuarterThreshold 0.1 +#define dHalfThreshold 0.05 + +float getMappedDepth(const in vec2 coords, const in vec2 selfCoords) { + vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w)); + float d = distance(coords, selfCoords); + #ifdef depthTextureSupport + if (d > dQuarterThreshold) { + return texture2D(tDepthQuarter, c).r; + } else if (d > dHalfThreshold) { + return texture2D(tDepthHalf, c).r; + } else { + return texture2D(tDepth, c).r; + } + #else + if (d > dQuarterThreshold) { + return unpackRGBAToDepth(texture2D(tDepthQuarter, c)); + } else if (d > dHalfThreshold) { + return unpackRGBAToDepth(texture2D(tDepthHalf, c)); + } else { + return unpackRGBAToDepth(texture2D(tDepth, c)); + } + #endif +} + +vec3 normalFromDepth(const in float depth, const in float depth1, const in float depth2, vec2 offset1, vec2 offset2) { + vec3 p1 = vec3(offset1, depth1 - depth); + vec3 p2 = vec3(offset2, depth2 - depth); + + vec3 normal = cross(p1, p2); + normal.z = -normal.z; + + return normalize(normal); +} + +float getPixelSize(const in vec2 coords, const in float depth) { + vec3 viewPos0 = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection); + vec3 viewPos1 = screenSpaceToViewSpace(vec3(coords + vec2(1.0, 0.0) / uTexSize, depth), uInvProjection); + return distance(viewPos0, viewPos1); +} + +// StarCraft II Ambient Occlusion by [Filion and McNaughton 2008] +void main(void) { + vec2 invTexSize = 1.0 / uTexSize; + vec2 selfCoords = gl_FragCoord.xy * invTexSize; + + float selfDepth = getDepth(selfCoords); + vec2 selfPackedDepth = packUnitIntervalToRG(selfDepth); + + if (isBackground(selfDepth)) { + gl_FragColor = vec4(packUnitIntervalToRG(1.0), selfPackedDepth); + return; + } + + vec2 offset1 = vec2(0.0, invTexSize.y); + vec2 offset2 = vec2(invTexSize.x, 0.0); + + float selfDepth1 = getDepth(selfCoords + offset1); + float selfDepth2 = getDepth(selfCoords + offset2); + + vec3 selfViewNormal = normalFromDepth(selfDepth, selfDepth1, selfDepth2, offset1, offset2); + vec3 selfViewPos = screenSpaceToViewSpace(vec3(selfCoords, selfDepth), uInvProjection); + + vec3 randomVec = normalize(vec3(getNoiseVec2(selfCoords) * 2.0 - 1.0, 0.0)); + vec3 tangent = normalize(randomVec - selfViewNormal * dot(randomVec, selfViewNormal)); + vec3 bitangent = cross(selfViewNormal, tangent); + mat3 TBN = mat3(tangent, bitangent, selfViewNormal); + + float occlusion = 0.0; + #ifdef dMultiScale + float pixelSize = getPixelSize(selfCoords, selfDepth); + + for(int l = 0; l < dLevels; l++) { + // TODO: smooth transition + if (pixelSize * uNearThreshold > uLevelRadius[l]) continue; + if (pixelSize * uFarThreshold < uLevelRadius[l]) continue; + + float levelOcclusion = 0.0; + for(int i = 0; i < dNSamples; i++) { + vec3 sampleViewPos = TBN * uSamples[i]; + sampleViewPos = selfViewPos + sampleViewPos * uLevelRadius[l]; + + vec4 offset = vec4(sampleViewPos, 1.0); + offset = uProjection * offset; + offset.xyz = (offset.xyz / offset.w) * 0.5 + 0.5; + + float sampleDepth = getMappedDepth(offset.xy, selfCoords); + float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, sampleDepth), uInvProjection).z; + + levelOcclusion += step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uLevelRadius[l] / abs(selfViewPos.z - sampleViewZ)) * uLevelBias[l]; + } + occlusion = max(occlusion, levelOcclusion); + } + #else + for(int i = 0; i < dNSamples; i++) { + vec3 sampleViewPos = TBN * uSamples[i]; + sampleViewPos = selfViewPos + sampleViewPos * uRadius; + + vec4 offset = vec4(sampleViewPos, 1.0); + offset = uProjection * offset; + offset.xyz = (offset.xyz / offset.w) * 0.5 + 0.5; + + float sampleDepth = getMappedDepth(offset.xy, selfCoords); + float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, sampleDepth), uInvProjection).z; + + occlusion += step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uRadius / abs(selfViewPos.z - sampleViewZ)); + } + #endif + occlusion = 1.0 - (uBias * occlusion / float(dNSamples)); + + vec2 packedOcclusion = packUnitIntervalToRG(clamp(occlusion, 0.01, 1.0)); + + gl_FragColor = vec4(packedOcclusion, selfPackedDepth); +} +`;var ate=` +precision highp float; +precision highp int; +precision highp sampler2D; + +uniform sampler2D tSsaoDepth; +uniform vec2 uTexSize; +uniform vec4 uBounds; + +uniform float uKernel[dOcclusionKernelSize]; + +uniform float uBlurDirectionX; +uniform float uBlurDirectionY; + +uniform mat4 uInvProjection; +uniform float uNear; +uniform float uFar; + +#include common + +float getViewZ(const in float depth) { + #if dOrthographic == 1 + return orthographicDepthToViewZ(depth, uNear, uFar); + #else + return perspectiveDepthToViewZ(depth, uNear, uFar); + #endif +} + +bool isBackground(const in float depth) { + return depth == 1.0; +} + +bool outsideBounds(const in vec2 p) { + return p.x < uBounds.x || p.y < uBounds.y || p.x > uBounds.z || p.y > uBounds.w; +} + +float getPixelSize(const in vec2 coords, const in float depth) { + vec3 viewPos0 = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection); + vec3 viewPos1 = screenSpaceToViewSpace(vec3(coords + vec2(1.0, 0.0) / uTexSize, depth), uInvProjection); + return distance(viewPos0, viewPos1); +} + +void main(void) { + vec2 coords = gl_FragCoord.xy / uTexSize; + + vec2 packedDepth = texture2D(tSsaoDepth, coords).zw; + + if (outsideBounds(coords)) { + gl_FragColor = vec4(packUnitIntervalToRG(1.0), packedDepth); + return; + } + + float selfDepth = unpackRGToUnitInterval(packedDepth); + // if background and if second pass + if (isBackground(selfDepth) && uBlurDirectionY != 0.0) { + gl_FragColor = vec4(packUnitIntervalToRG(1.0), packedDepth); + return; + } + + float selfViewZ = getViewZ(selfDepth); + float pixelSize = getPixelSize(coords, selfDepth); + float maxDiffViewZ = pixelSize * 10.0; + + vec2 offset = vec2(uBlurDirectionX, uBlurDirectionY) / uTexSize; + + float sum = 0.0; + float kernelSum = 0.0; + // only if kernelSize is odd + for (int i = -dOcclusionKernelSize / 2; i <= dOcclusionKernelSize / 2; i++) { + if (abs(float(i)) > 1.0 && abs(float(i)) * pixelSize > 0.8) continue; + + vec2 sampleCoords = coords + float(i) * offset; + if (outsideBounds(sampleCoords)) { + continue; + } + + vec4 sampleSsaoDepth = texture2D(tSsaoDepth, sampleCoords); + + float sampleDepth = unpackRGToUnitInterval(sampleSsaoDepth.zw); + if (isBackground(sampleDepth)) { + continue; + } + + if (abs(float(i)) > 1.0) { + float sampleViewZ = getViewZ(sampleDepth); + if (abs(selfViewZ - sampleViewZ) > maxDiffViewZ) { + continue; + } + } + + float kernel = uKernel[int(abs(float(i)))]; // abs is not defined for int in webgl1 + float sampleValue = unpackRGToUnitInterval(sampleSsaoDepth.xy); + + sum += kernel * sampleValue; + kernelSum += kernel; + } + + gl_FragColor = vec4(packUnitIntervalToRG(sum / kernelSum), packedDepth); +} +`;var ite=` +precision highp float; +precision highp int; +precision highp sampler2D; + +uniform sampler2D tSsaoDepth; +uniform sampler2D tColor; +uniform sampler2D tDepthOpaque; +uniform sampler2D tDepthTransparent; +uniform sampler2D tShadows; +uniform sampler2D tOutlines; +uniform vec2 uTexSize; + +uniform float uNear; +uniform float uFar; +uniform float uFogNear; +uniform float uFogFar; +uniform vec3 uFogColor; +uniform vec3 uOutlineColor; +uniform vec3 uOcclusionColor; +uniform bool uTransparentBackground; +uniform vec2 uOcclusionOffset; + +#include common + +float getViewZ(const in float depth) { + #if dOrthographic == 1 + return orthographicDepthToViewZ(depth, uNear, uFar); + #else + return perspectiveDepthToViewZ(depth, uNear, uFar); + #endif +} + +float getDepthOpaque(const in vec2 coords) { + #ifdef depthTextureSupport + return texture2D(tDepthOpaque, coords).r; + #else + return unpackRGBAToDepth(texture2D(tDepthOpaque, coords)); + #endif +} + +float getDepthTransparent(const in vec2 coords) { + #ifdef dTransparentOutline + return unpackRGBAToDepth(texture2D(tDepthTransparent, coords)); + #else + return 1.0; + #endif +} + +bool isBackground(const in float depth) { + return depth == 1.0; +} + +float getOutline(const in vec2 coords, const in float opaqueDepth, out float closestTexel) { + float backgroundViewZ = 2.0 * uFar; + vec2 invTexSize = 1.0 / uTexSize; + + float transparentDepth = getDepthTransparent(coords); + float opaqueSelfViewZ = isBackground(opaqueDepth) ? backgroundViewZ : getViewZ(opaqueDepth); + float transparentSelfViewZ = isBackground(transparentDepth) ? backgroundViewZ : getViewZ(transparentDepth); + float selfDepth = min(opaqueDepth, transparentDepth); + + float outline = 1.0; + closestTexel = 1.0; + for (int y = -dOutlineScale; y <= dOutlineScale; y++) { + for (int x = -dOutlineScale; x <= dOutlineScale; x++) { + if (x * x + y * y > dOutlineScale * dOutlineScale) { + continue; + } + + vec2 sampleCoords = coords + vec2(float(x), float(y)) * invTexSize; + + vec4 sampleOutlineCombined = texture2D(tOutlines, sampleCoords); + float sampleOutline = sampleOutlineCombined.r; + float sampleOutlineDepth = unpackRGToUnitInterval(sampleOutlineCombined.gb); + float sampleOutlineViewZ = isBackground(sampleOutlineDepth) ? backgroundViewZ : getViewZ(sampleOutlineDepth); + + float selfViewZ = sampleOutlineCombined.a == 0.0 ? opaqueSelfViewZ : transparentSelfViewZ; + if (sampleOutline == 0.0 && sampleOutlineDepth < closestTexel) { + outline = 0.0; + closestTexel = sampleOutlineDepth; + } + } + } + return closestTexel < opaqueDepth ? outline : 1.0; +} + +float getSsao(vec2 coords) { + float rawSsao = unpackRGToUnitInterval(texture2D(tSsaoDepth, coords).xy); + if (rawSsao > 0.999) { + return 1.0; + } else if (rawSsao > 0.001) { + return rawSsao; + } + // treat values close to 0.0 as errors and return no occlusion + return 1.0; +} + +void main(void) { + vec2 coords = gl_FragCoord.xy / uTexSize; + vec4 color = texture2D(tColor, coords); + + float viewDist; + float fogFactor; + float opaqueDepth = getDepthOpaque(coords); + + #ifdef dOcclusionEnable + if (!isBackground(opaqueDepth)) { + viewDist = abs(getViewZ(opaqueDepth)); + fogFactor = smoothstep(uFogNear, uFogFar, viewDist); + float occlusionFactor = getSsao(coords + uOcclusionOffset); + if (!uTransparentBackground) { + color.rgb = mix(mix(uOcclusionColor, uFogColor, fogFactor), color.rgb, occlusionFactor); + } else { + color.rgb = mix(uOcclusionColor * (1.0 - fogFactor), color.rgb, occlusionFactor); + } + } + #endif + + #ifdef dShadowEnable + if (!isBackground(opaqueDepth)) { + viewDist = abs(getViewZ(opaqueDepth)); + fogFactor = smoothstep(uFogNear, uFogFar, viewDist); + vec4 shadow = texture2D(tShadows, coords); + if (!uTransparentBackground) { + color.rgb = mix(mix(vec3(0), uFogColor, fogFactor), color.rgb, shadow.a); + } else { + color.rgb = mix(vec3(0) * (1.0 - fogFactor), color.rgb, shadow.a); + } + } + #endif + + // outline needs to be handled after occlusion and shadow to keep them clean + #ifdef dOutlineEnable + float closestTexel; + float outline = getOutline(coords, opaqueDepth, closestTexel); + if (outline == 0.0) { + viewDist = abs(getViewZ(closestTexel)); + fogFactor = smoothstep(uFogNear, uFogFar, viewDist); + if (!uTransparentBackground) { + color.rgb = mix(uOutlineColor, uFogColor, fogFactor); + } else { + color.a = 1.0 - fogFactor; + color.rgb = mix(uOutlineColor, color.rgb, fogFactor); + } + } + #endif + + gl_FragColor = color; +} +`;var ote=` +precision highp float; +precision highp int; +precision highp sampler2D; + +uniform sampler2D tColor; +uniform vec2 uTexSizeInv; + +// adapted from https://github.com/kosua20/Rendu +// MIT License Copyright (c) 2017 Simon Rodriguez + +#define QUALITY(q) ((q) < 5 ? 1.0 : ((q) > 5 ? ((q) < 10 ? 2.0 : ((q) < 11 ? 4.0 : 8.0)) : 1.5)) + +float rgb2luma(vec3 rgb){ + return sqrt(dot(rgb, vec3(0.299, 0.587, 0.114))); +} + +float sampleLuma(vec2 uv) { + return rgb2luma(texture2D(tColor, uv).rgb); +} + +float sampleLuma(vec2 uv, float uOffset, float vOffset) { + uv += uTexSizeInv * vec2(uOffset, vOffset); + return sampleLuma(uv); +} + +void main(void) { + vec2 coords = gl_FragCoord.xy * uTexSizeInv; + vec2 inverseScreenSize = uTexSizeInv; + + vec4 colorCenter = texture2D(tColor, coords); + + // Luma at the current fragment + float lumaCenter = rgb2luma(colorCenter.rgb); + + // Luma at the four direct neighbours of the current fragment. + float lumaDown = sampleLuma(coords, 0.0, -1.0); + float lumaUp = sampleLuma(coords, 0.0, 1.0); + float lumaLeft = sampleLuma(coords, -1.0, 0.0); + float lumaRight = sampleLuma(coords, 1.0, 0.0); + + // Find the maximum and minimum luma around the current fragment. + float lumaMin = min(lumaCenter, min(min(lumaDown, lumaUp), min(lumaLeft, lumaRight))); + float lumaMax = max(lumaCenter, max(max(lumaDown, lumaUp), max(lumaLeft, lumaRight))); + + // Compute the delta. + float lumaRange = lumaMax - lumaMin; + + // If the luma variation is lower that a threshold (or if we are in a really dark area), + // we are not on an edge, don't perform any AA. + if (lumaRange < max(dEdgeThresholdMin, lumaMax * dEdgeThresholdMax)) { + gl_FragColor = colorCenter; + return; + } + + // Query the 4 remaining corners lumas. + float lumaDownLeft = sampleLuma(coords, -1.0, -1.0); + float lumaUpRight = sampleLuma(coords, 1.0, 1.0); + float lumaUpLeft = sampleLuma(coords, -1.0, 1.0); + float lumaDownRight = sampleLuma(coords, 1.0, -1.0); + + // Combine the four edges lumas (using intermediary variables for future computations + // with the same values). + float lumaDownUp = lumaDown + lumaUp; + float lumaLeftRight = lumaLeft + lumaRight; + + // Same for corners + float lumaLeftCorners = lumaDownLeft + lumaUpLeft; + float lumaDownCorners = lumaDownLeft + lumaDownRight; + float lumaRightCorners = lumaDownRight + lumaUpRight; + float lumaUpCorners = lumaUpRight + lumaUpLeft; + + // Compute an estimation of the gradient along the horizontal and vertical axis. + float edgeHorizontal = abs(-2.0 * lumaLeft + lumaLeftCorners) + abs(-2.0 * lumaCenter + lumaDownUp) * 2.0 + abs(-2.0 * lumaRight + lumaRightCorners); + float edgeVertical = abs(-2.0 * lumaUp + lumaUpCorners) + abs(-2.0 * lumaCenter + lumaLeftRight) * 2.0 + abs(-2.0 * lumaDown + lumaDownCorners); + + // Is the local edge horizontal or vertical ? + bool isHorizontal = (edgeHorizontal >= edgeVertical); + + // Choose the step size (one pixel) accordingly. + float stepLength = isHorizontal ? inverseScreenSize.y : inverseScreenSize.x; + + // Select the two neighboring texels lumas in the opposite direction to the local edge. + float luma1 = isHorizontal ? lumaDown : lumaLeft; + float luma2 = isHorizontal ? lumaUp : lumaRight; + // Compute gradients in this direction. + float gradient1 = luma1 - lumaCenter; + float gradient2 = luma2 - lumaCenter; + + // Which direction is the steepest ? + bool is1Steepest = abs(gradient1) >= abs(gradient2); + + // Gradient in the corresponding direction, normalized. + float gradientScaled = 0.25 * max(abs(gradient1), abs(gradient2)); + + // Average luma in the correct direction. + float lumaLocalAverage = 0.0; + if(is1Steepest){ + // Switch the direction + stepLength = -stepLength; + lumaLocalAverage = 0.5 * (luma1 + lumaCenter); + } else { + lumaLocalAverage = 0.5 * (luma2 + lumaCenter); + } + + // Shift UV in the correct direction by half a pixel. + vec2 currentUv = coords; + if(isHorizontal){ + currentUv.y += stepLength * 0.5; + } else { + currentUv.x += stepLength * 0.5; + } + + // Compute offset (for each iteration step) in the right direction. + vec2 offset = isHorizontal ? vec2(inverseScreenSize.x, 0.0) : vec2(0.0, inverseScreenSize.y); + // Compute UVs to explore on each side of the edge, orthogonally. + // The QUALITY allows us to step faster. + vec2 uv1 = currentUv - offset * QUALITY(0); + vec2 uv2 = currentUv + offset * QUALITY(0); + + // Read the lumas at both current extremities of the exploration segment, + // and compute the delta wrt to the local average luma. + float lumaEnd1 = sampleLuma(uv1); + float lumaEnd2 = sampleLuma(uv2); + lumaEnd1 -= lumaLocalAverage; + lumaEnd2 -= lumaLocalAverage; + + // If the luma deltas at the current extremities is larger than the local gradient, + // we have reached the side of the edge. + bool reached1 = abs(lumaEnd1) >= gradientScaled; + bool reached2 = abs(lumaEnd2) >= gradientScaled; + bool reachedBoth = reached1 && reached2; + + // If the side is not reached, we continue to explore in this direction. + if(!reached1){ + uv1 -= offset * QUALITY(1); + } + if(!reached2){ + uv2 += offset * QUALITY(1); + } + + // If both sides have not been reached, continue to explore. + if(!reachedBoth){ + for(int i = 2; i < dIterations; i++){ + // If needed, read luma in 1st direction, compute delta. + if(!reached1){ + lumaEnd1 = sampleLuma(uv1); + lumaEnd1 = lumaEnd1 - lumaLocalAverage; + } + // If needed, read luma in opposite direction, compute delta. + if(!reached2){ + lumaEnd2 = sampleLuma(uv2); + lumaEnd2 = lumaEnd2 - lumaLocalAverage; + } + // If the luma deltas at the current extremities is larger than the local gradient, + // we have reached the side of the edge. + reached1 = abs(lumaEnd1) >= gradientScaled; + reached2 = abs(lumaEnd2) >= gradientScaled; + reachedBoth = reached1 && reached2; + + // If the side is not reached, we continue to explore in this direction, + // with a variable quality. + if(!reached1){ + uv1 -= offset * QUALITY(i); + } + if(!reached2){ + uv2 += offset * QUALITY(i); + } + + // If both sides have been reached, stop the exploration. + if(reachedBoth){ + break; + } + } + } + + // Compute the distances to each side edge of the edge (!). + float distance1 = isHorizontal ? (coords.x - uv1.x) : (coords.y - uv1.y); + float distance2 = isHorizontal ? (uv2.x - coords.x) : (uv2.y - coords.y); + + // In which direction is the side of the edge closer ? + bool isDirection1 = distance1 < distance2; + float distanceFinal = min(distance1, distance2); + + // Thickness of the edge. + float edgeThickness = (distance1 + distance2); + + // Is the luma at center smaller than the local average ? + bool isLumaCenterSmaller = lumaCenter < lumaLocalAverage; + + // If the luma at center is smaller than at its neighbour, + // the delta luma at each end should be positive (same variation). + bool correctVariation1 = (lumaEnd1 < 0.0) != isLumaCenterSmaller; + bool correctVariation2 = (lumaEnd2 < 0.0) != isLumaCenterSmaller; + + // Only keep the result in the direction of the closer side of the edge. + bool correctVariation = isDirection1 ? correctVariation1 : correctVariation2; + + // UV offset: read in the direction of the closest side of the edge. + float pixelOffset = - distanceFinal / edgeThickness + 0.5; + + // If the luma variation is incorrect, do not offset. + float finalOffset = correctVariation ? pixelOffset : 0.0; + + // Sub-pixel shifting + // Full weighted average of the luma over the 3x3 neighborhood. + float lumaAverage = (1.0 / 12.0) * (2.0 * (lumaDownUp + lumaLeftRight) + lumaLeftCorners + lumaRightCorners); + // Ratio of the delta between the global average and the center luma, + // over the luma range in the 3x3 neighborhood. + float subPixelOffset1 = clamp(abs(lumaAverage - lumaCenter) / lumaRange, 0.0, 1.0); + float subPixelOffset2 = (-2.0 * subPixelOffset1 + 3.0) * subPixelOffset1 * subPixelOffset1; + // Compute a sub-pixel offset based on this delta. + float subPixelOffsetFinal = subPixelOffset2 * subPixelOffset2 * float(dSubpixelQuality); + + // Pick the biggest of the two offsets. + finalOffset = max(finalOffset, subPixelOffsetFinal); + + // Compute the final UV coordinates. + vec2 finalUv = coords; + if(isHorizontal){ + finalUv.y += finalOffset * stepLength; + } else { + finalUv.x += finalOffset * stepLength; + } + + // Read the color at the new UV coordinates, and use it. + gl_FragColor = texture2D(tColor, finalUv); +} +`;var ste={edgeThresholdMin:w.Numeric(.0312,{min:.0312,max:.0833,step:1e-4},{description:"Trims the algorithm from processing darks."}),edgeThresholdMax:w.Numeric(.063,{min:.063,max:.333,step:.001},{description:"The minimum amount of local contrast required to apply algorithm."}),iterations:w.Numeric(12,{min:0,max:16,step:1},{description:"Number of edge exploration steps."}),subpixelQuality:w.Numeric(.3,{min:0,max:1,step:.01},{description:"Choose the amount of sub-pixel aliasing removal."})},ute=function(){function e(t,r){this.webgl=t,this.renderable=pOe(t,r)}return e.prototype.updateState=function(t){var r=this.webgl,n=r.gl,a=r.state;a.enable(n.SCISSOR_TEST),a.disable(n.BLEND),a.disable(n.DEPTH_TEST),a.depthMask(!1);var i=t.x,o=t.y,s=t.width,u=t.height;a.viewport(i,o,s,u),a.scissor(i,o,s,u),a.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT)},e.prototype.setSize=function(t,r){M.update(this.renderable.values.uTexSizeInv,Me.set(this.renderable.values.uTexSizeInv.ref.value,1/t,1/r))},e.prototype.update=function(t,r){var n=this.renderable.values,a=r.edgeThresholdMin,i=r.edgeThresholdMax,o=r.iterations,s=r.subpixelQuality,u=!1;n.tColor.ref.value!==t&&(M.update(this.renderable.values.tColor,t),u=!0),n.dEdgeThresholdMin.ref.value!==a&&(u=!0),M.updateIfChanged(n.dEdgeThresholdMin,a),n.dEdgeThresholdMax.ref.value!==i&&(u=!0),M.updateIfChanged(n.dEdgeThresholdMax,i),n.dIterations.ref.value!==o&&(u=!0),M.updateIfChanged(n.dIterations,o),n.dSubpixelQuality.ref.value!==s&&(u=!0),M.updateIfChanged(n.dSubpixelQuality,s),u&&this.renderable.update()},e.prototype.render=function(t,r){ft&&this.webgl.timer.mark("FxaaPass.render"),r?r.bind():this.webgl.unbindFramebuffer(),this.updateState(t),this.renderable.render(),ft&&this.webgl.timer.markEnd("FxaaPass.render")},e}();var dOe=P(P({},Gn),{tColor:Ft("texture","rgba","ubyte","linear"),uTexSizeInv:_e("v2"),dEdgeThresholdMin:Dt("number"),dEdgeThresholdMax:Dt("number"),dIterations:Dt("number"),dSubpixelQuality:Dt("number")}),mOe=Nr("fxaa",ea,ote);function pOe(e,t){var r=t.getWidth(),n=t.getHeight(),a=P(P({},zn),{tColor:M.create(t),uTexSizeInv:M.create(Me.create(1/r,1/n)),dEdgeThresholdMin:M.create(.0312),dEdgeThresholdMax:M.create(.125),dIterations:M.create(12),dSubpixelQuality:M.create(.3)}),i=P({},dOe),o=ln(e,"triangles",mOe,i,a);return fn(o,a)}var cte=` +precision highp float; + +attribute vec2 aPosition; +uniform vec2 uQuadScale; + +uniform vec2 uTexSizeInv; +uniform vec4 uViewport; + +varying vec2 vUv; +varying vec4 vOffset[2]; + +void SMAANeighborhoodBlendingVS(vec2 texCoord) { + vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-1.0, 0.0, 0.0, 1.0); // WebGL port note: Changed sign in W component + vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(1.0, 0.0, 0.0, -1.0); // WebGL port note: Changed sign in W component +} + +void main() { + vec2 scale = uViewport.zw * uTexSizeInv; + vec2 shift = uViewport.xy * uTexSizeInv; + vUv = (aPosition + 1.0) * 0.5 * scale + shift; + SMAANeighborhoodBlendingVS(vUv); + vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale; + gl_Position = vec4(position, 0.0, 1.0); +} +`;var lte=` +precision highp float; +precision highp int; +precision highp sampler2D; + +uniform sampler2D tWeights; +uniform sampler2D tColor; +uniform vec2 uTexSizeInv; + +varying vec2 vUv; +varying vec4 vOffset[2]; + +vec4 SMAANeighborhoodBlendingPS(vec2 texCoord, vec4 offset[2], sampler2D colorTex, sampler2D blendTex) { + // Fetch the blending weights for current pixel: + vec4 a; + a.xz = texture2D(blendTex, texCoord).xz; + a.y = texture2D(blendTex, offset[1].zw).g; + a.w = texture2D(blendTex, offset[1].xy).a; + + // Is there any blending weight with a value greater than 0.0? + if (dot(a, vec4(1.0, 1.0, 1.0, 1.0)) < 1e-5) { + return texture2D(colorTex, texCoord, 0.0); + } else { + // Up to 4 lines can be crossing a pixel (one through each edge). We + // favor blending by choosing the line with the maximum weight for each + // direction: + vec2 offset; + offset.x = a.a > a.b ? a.a : -a.b; // left vs. right + offset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs + + // Then we go in the direction that has the maximum weight: + if (abs(offset.x) > abs(offset.y)) { // horizontal vs. vertical + offset.y = 0.0; + } else { + offset.x = 0.0; + } + + // Fetch the opposite color and lerp by hand: + vec4 C = texture2D(colorTex, texCoord, 0.0); + texCoord += sign(offset) * uTexSizeInv; + vec4 Cop = texture2D(colorTex, texCoord, 0.0); + float s = abs(offset.x) > abs(offset.y) ? abs(offset.x) : abs(offset.y); + + // WebGL port note: Added gamma correction + C.xyz = pow(C.xyz, vec3(2.2)); + Cop.xyz = pow(Cop.xyz, vec3(2.2)); + vec4 mixed = mix(C, Cop, s); + mixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2)); + + return mixed; + } +} + +void main() { + gl_FragColor = SMAANeighborhoodBlendingPS(vUv, vOffset, tColor, tWeights); +} +`;var fte=` +precision highp float; + +attribute vec2 aPosition; +uniform vec2 uQuadScale; + +uniform vec2 uTexSizeInv; +uniform vec4 uViewport; + +varying vec2 vUv; +varying vec4 vOffset[3]; +varying vec2 vPixCoord; + +void SMAABlendingWeightCalculationVS(vec2 texCoord) { + vPixCoord = texCoord / uTexSizeInv; + + // We will use these offsets for the searches later on (see @PSEUDO_GATHER4): + vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-0.25, 0.125, 1.25, 0.125); // WebGL port note: Changed sign in Y and W components + vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-0.125, 0.25, -0.125, -1.25); // WebGL port note: Changed sign in Y and W components + + // And these for the searches, they indicate the ends of the loops: + vOffset[2] = vec4(vOffset[0].xz, vOffset[1].yw) + vec4(-2.0, 2.0, -2.0, 2.0) * uTexSizeInv.xxyy * float(dMaxSearchSteps); +} + +void main() { + vec2 scale = uViewport.zw * uTexSizeInv; + vec2 shift = uViewport.xy * uTexSizeInv; + vUv = (aPosition + 1.0) * 0.5 * scale + shift; + SMAABlendingWeightCalculationVS(vUv); + vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale; + gl_Position = vec4(position, 0.0, 1.0); +} +`;var dte=` +precision highp float; +precision highp int; +precision highp sampler2D; + +#define SMAASampleLevelZeroOffset(tex, coord, offset) texture2D(tex, coord + float(offset) * uTexSizeInv, 0.0) + +#define SMAA_AREATEX_MAX_DISTANCE 16 +#define SMAA_AREATEX_PIXEL_SIZE (1.0 / vec2(160.0, 560.0)) +#define SMAA_AREATEX_SUBTEX_SIZE (1.0 / 7.0) + +uniform sampler2D tEdges; +uniform sampler2D tArea; +uniform sampler2D tSearch; +uniform vec2 uTexSizeInv; + +varying vec2 vUv; +varying vec4 vOffset[3]; +varying vec2 vPixCoord; + +#if __VERSION__ == 100 + vec2 round(vec2 x) { + return sign(x) * floor(abs(x) + 0.5); + } +#endif + +float SMAASearchLength(sampler2D searchTex, vec2 e, float bias, float scale) { + // Not required if searchTex accesses are set to point: + // float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0); + // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE + + // e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE; + e.r = bias + e.r * scale; + return 255.0 * texture2D(searchTex, e, 0.0).r; +} + +float SMAASearchXLeft(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) { + /** + * @PSEUDO_GATHER4 + * This texCoord has been offset by (-0.25, -0.125) in the vertex shader to + * sample between edge, thus fetching four edges in a row. + * Sampling with different offsets in each direction allows to disambiguate + * which edges are active from the four fetched ones. + */ + vec2 e = vec2(0.0, 1.0); + + for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for + e = texture2D( edgesTex, texCoord, 0.0).rg; + texCoord -= vec2(2.0, 0.0) * uTexSizeInv; + if (!(texCoord.x > end && e.g > 0.8281 && e.r == 0.0)) break; + } + + // We correct the previous (-0.25, -0.125) offset we applied: + texCoord.x += 0.25 * uTexSizeInv.x; + + // The searches are bias by 1, so adjust the coords accordingly: + texCoord.x += uTexSizeInv.x; + + // Disambiguate the length added by the last step: + texCoord.x += 2.0 * uTexSizeInv.x; // Undo last step + texCoord.x -= uTexSizeInv.x * SMAASearchLength(searchTex, e, 0.0, 0.5); + + return texCoord.x; +} + +float SMAASearchXRight(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) { + vec2 e = vec2( 0.0, 1.0 ); + + for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for + e = texture2D(edgesTex, texCoord, 0.0).rg; + texCoord += vec2(2.0, 0.0) * uTexSizeInv; + if (!(texCoord.x < end && e.g > 0.8281 && e.r == 0.0)) break; + } + + texCoord.x -= 0.25 * uTexSizeInv.x; + texCoord.x -= uTexSizeInv.x; + texCoord.x -= 2.0 * uTexSizeInv.x; + texCoord.x += uTexSizeInv.x * SMAASearchLength( searchTex, e, 0.5, 0.5 ); + + return texCoord.x; +} + +float SMAASearchYUp(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) { + vec2 e = vec2( 1.0, 0.0 ); + + for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for + e = texture2D(edgesTex, texCoord, 0.0).rg; + texCoord += vec2(0.0, 2.0) * uTexSizeInv; // WebGL port note: Changed sign + if (!(texCoord.y > end && e.r > 0.8281 && e.g == 0.0)) break; + } + + texCoord.y -= 0.25 * uTexSizeInv.y; // WebGL port note: Changed sign + texCoord.y -= uTexSizeInv.y; // WebGL port note: Changed sign + texCoord.y -= 2.0 * uTexSizeInv.y; // WebGL port note: Changed sign + texCoord.y += uTexSizeInv.y * SMAASearchLength(searchTex, e.gr, 0.0, 0.5); // WebGL port note: Changed sign + + return texCoord.y; +} + +float SMAASearchYDown(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) { + vec2 e = vec2( 1.0, 0.0 ); + + for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for + e = texture2D(edgesTex, texCoord, 0.0).rg; + texCoord -= vec2( 0.0, 2.0 ) * uTexSizeInv; // WebGL port note: Changed sign + if (!(texCoord.y < end && e.r > 0.8281 && e.g == 0.0)) break; + } + + texCoord.y += 0.25 * uTexSizeInv.y; // WebGL port note: Changed sign + texCoord.y += uTexSizeInv.y; // WebGL port note: Changed sign + texCoord.y += 2.0 * uTexSizeInv.y; // WebGL port note: Changed sign + texCoord.y -= uTexSizeInv.y * SMAASearchLength(searchTex, e.gr, 0.5, 0.5); // WebGL port note: Changed sign + + return texCoord.y; +} + +vec2 SMAAArea(sampler2D areaTex, vec2 dist, float e1, float e2, float offset) { + // Rounding prevents precision errors of bilinear filtering: + vec2 texCoord = float(SMAA_AREATEX_MAX_DISTANCE) * round(4.0 * vec2(e1, e2)) + dist; + + // We do a scale and bias for mapping to texel space: + texCoord = SMAA_AREATEX_PIXEL_SIZE * texCoord + (0.5 * SMAA_AREATEX_PIXEL_SIZE); + + // Move to proper place, according to the subpixel offset: + texCoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset; + + return texture2D(areaTex, texCoord, 0.0).rg; +} + +vec4 SMAABlendingWeightCalculationPS(vec2 texCoord, vec2 pixCoord, vec4 offset[3], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices) { + vec4 weights = vec4(0.0, 0.0, 0.0, 0.0); + + vec2 e = texture2D(edgesTex, texCoord).rg; + + if (e.g > 0.0) { // Edge at north + vec2 d; + + // Find the distance to the left: + vec2 coords; + coords.x = SMAASearchXLeft(edgesTex, searchTex, offset[0].xy, offset[2].x ); + coords.y = offset[1].y; // offset[1].y = texCoord.y - 0.25 * uTexSizeInv.y (@CROSSING_OFFSET) + d.x = coords.x; + + // Now fetch the left crossing edges, two at a time using bilinear + // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to + // discern what value each edge has: + float e1 = texture2D(edgesTex, coords, 0.0).r; + + // Find the distance to the right: + coords.x = SMAASearchXRight(edgesTex, searchTex, offset[0].zw, offset[2].y); + d.y = coords.x; + + // We want the distances to be in pixel units (doing this here allow to + // better interleave arithmetic and memory accesses): + d = d / uTexSizeInv.x - pixCoord.x; + + // SMAAArea below needs a sqrt, as the areas texture is compressed + // quadratically: + vec2 sqrt_d = sqrt(abs(d)); + + // Fetch the right crossing edges: + coords.y -= 1.0 * uTexSizeInv.y; // WebGL port note: Added + float e2 = SMAASampleLevelZeroOffset(edgesTex, coords, ivec2(1, 0)).r; + + // Ok, we know how this pattern looks like, now it is time for getting + // the actual area: + weights.rg = SMAAArea(areaTex, sqrt_d, e1, e2, float(subsampleIndices.y)); + } + + if (e.r > 0.0) { // Edge at west + vec2 d; + + // Find the distance to the top: + vec2 coords; + + coords.y = SMAASearchYUp(edgesTex, searchTex, offset[1].xy, offset[2].z ); + coords.x = offset[0].x; // offset[1].x = texCoord.x - 0.25 * uTexSizeInv.x; + d.x = coords.y; + + // Fetch the top crossing edges: + float e1 = texture2D(edgesTex, coords, 0.0).g; + + // Find the distance to the bottom: + coords.y = SMAASearchYDown(edgesTex, searchTex, offset[1].zw, offset[2].w); + d.y = coords.y; + + // We want the distances to be in pixel units: + d = d / uTexSizeInv.y - pixCoord.y; + + // SMAAArea below needs a sqrt, as the areas texture is compressed + // quadratically: + vec2 sqrt_d = sqrt(abs(d)); + + // Fetch the bottom crossing edges: + coords.y -= 1.0 * uTexSizeInv.y; // WebGL port note: Added + float e2 = SMAASampleLevelZeroOffset(edgesTex, coords, ivec2(0, 1)).g; + + // Get the area for this direction: + weights.ba = SMAAArea(areaTex, sqrt_d, e1, e2, float(subsampleIndices.x)); + } + + return weights; +} + +void main() { + gl_FragColor = SMAABlendingWeightCalculationPS(vUv, vPixCoord, vOffset, tEdges, tArea, tSearch, ivec4(0.0)); +} +`;var mte=` +precision highp float; + +attribute vec2 aPosition; +uniform vec2 uQuadScale; + +uniform vec2 uTexSizeInv; +uniform vec4 uViewport; + +varying vec2 vUv; +varying vec4 vOffset[3]; + +void SMAAEdgeDetectionVS(vec2 texCoord) { + vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-1.0, 0.0, 0.0, 1.0); // WebGL port note: Changed sign in W component + vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(1.0, 0.0, 0.0, -1.0); // WebGL port note: Changed sign in W component + vOffset[2] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-2.0, 0.0, 0.0, 2.0); // WebGL port note: Changed sign in W component +} + +void main() { + vec2 scale = uViewport.zw * uTexSizeInv; + vec2 shift = uViewport.xy * uTexSizeInv; + vUv = (aPosition + 1.0) * 0.5 * scale + shift; + SMAAEdgeDetectionVS(vUv); + vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale; + gl_Position = vec4(position, 0.0, 1.0); +} +`;var pte=` +precision highp float; +precision highp int; +precision highp sampler2D; + +uniform sampler2D tColor; +uniform vec2 uTexSizeInv; + +varying vec2 vUv; +varying vec4 vOffset[3]; + +vec4 SMAAColorEdgeDetectionPS(vec2 texcoord, vec4 offset[3], sampler2D colorTex) { + vec2 threshold = vec2(dEdgeThreshold, dEdgeThreshold); + + // Calculate color deltas: + vec4 delta; + vec3 C = texture2D(colorTex, texcoord).rgb; + + vec3 Cleft = texture2D(colorTex, offset[0].xy).rgb; + vec3 t = abs(C - Cleft); + delta.x = max(max(t.r, t.g), t.b); + + vec3 Ctop = texture2D(colorTex, offset[0].zw).rgb; + t = abs(C - Ctop); + delta.y = max(max(t.r, t.g), t.b); + + // We do the usual threshold: + vec2 edges = step(threshold, delta.xy); + + // Then discard if there is no edge: + if (dot(edges, vec2(1.0, 1.0 )) == 0.0) + discard; + + // Calculate right and bottom deltas: + vec3 Cright = texture2D(colorTex, offset[1].xy).rgb; + t = abs( C - Cright ); + delta.z = max(max(t.r, t.g), t.b); + + vec3 Cbottom = texture2D(colorTex, offset[1].zw).rgb; + t = abs(C - Cbottom); + delta.w = max(max(t.r, t.g), t.b); + + // Calculate the maximum delta in the direct neighborhood: + float maxDelta = max(max(max(delta.x, delta.y), delta.z), delta.w ); + + // Calculate left-left and top-top deltas: + vec3 Cleftleft = texture2D(colorTex, offset[2].xy).rgb; + t = abs( C - Cleftleft ); + delta.z = max(max(t.r, t.g), t.b); + + vec3 Ctoptop = texture2D(colorTex, offset[2].zw).rgb; + t = abs(C - Ctoptop); + delta.w = max(max(t.r, t.g), t.b); + + // Calculate the final maximum delta: + maxDelta = max(max(maxDelta, delta.z), delta.w); + + // Local contrast adaptation in action: + edges.xy *= step(0.5 * maxDelta, delta.xy); + + return vec4(edges, 0.0, 0.0); +} + +void main() { + gl_FragColor = SMAAColorEdgeDetectionPS(vUv, vOffset, tColor); +} +`;var hte={edgeThreshold:w.Numeric(.1,{min:.05,max:.15,step:.01}),maxSearchSteps:w.Numeric(16,{min:0,max:32,step:1})},vte=function(){function e(t,r){if(this.webgl=t,this._supported=!1,typeof HTMLImageElement>"u"){or&&console.log('Missing "HTMLImageElement" required for "SMAA"');return}var n=r.getWidth(),a=r.getHeight();this.edgesTarget=t.createRenderTarget(n,a,!1,"uint8","linear"),this.weightsTarget=t.createRenderTarget(n,a,!1,"uint8","linear"),this.edgesRenderable=gOe(t,r),this.weightsRenderable=xOe(t,this.edgesTarget.texture),this.blendRenderable=_Oe(t,r,this.weightsTarget.texture),this._supported=!0}return Object.defineProperty(e.prototype,"supported",{get:function(){return this._supported},enumerable:!1,configurable:!0}),e.prototype.updateState=function(t){var r=this.webgl,n=r.gl,a=r.state;a.enable(n.SCISSOR_TEST),a.disable(n.BLEND),a.disable(n.DEPTH_TEST),a.depthMask(!1);var i=t.x,o=t.y,s=t.width,u=t.height;a.viewport(i,o,s,u),a.scissor(i,o,s,u),a.colorMask(!0,!0,!0,!0),a.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT),M.update(this.edgesRenderable.values.uViewport,Ma.toVec4(this.edgesRenderable.values.uViewport.ref.value,t)),M.update(this.weightsRenderable.values.uViewport,Ma.toVec4(this.weightsRenderable.values.uViewport.ref.value,t)),M.update(this.blendRenderable.values.uViewport,Ma.toVec4(this.blendRenderable.values.uViewport.ref.value,t))},e.prototype.setSize=function(t,r){var n=this.edgesTarget.getWidth(),a=this.edgesTarget.getHeight();(t!==n||r!==a)&&(this.edgesTarget.setSize(t,r),this.weightsTarget.setSize(t,r),M.update(this.edgesRenderable.values.uTexSizeInv,Me.set(this.edgesRenderable.values.uTexSizeInv.ref.value,1/t,1/r)),M.update(this.weightsRenderable.values.uTexSizeInv,Me.set(this.weightsRenderable.values.uTexSizeInv.ref.value,1/t,1/r)),M.update(this.blendRenderable.values.uTexSizeInv,Me.set(this.blendRenderable.values.uTexSizeInv.ref.value,1/t,1/r)))},e.prototype.update=function(t,r){var n=!1;this.edgesRenderable.values.tColor.ref.value!==t&&(M.update(this.edgesRenderable.values.tColor,t),n=!0),this.edgesRenderable.values.dEdgeThreshold.ref.value!==r.edgeThreshold&&(M.update(this.edgesRenderable.values.dEdgeThreshold,r.edgeThreshold),n=!0),n&&this.edgesRenderable.update(),this.weightsRenderable.values.dMaxSearchSteps.ref.value!==r.maxSearchSteps&&(M.update(this.weightsRenderable.values.dMaxSearchSteps,r.maxSearchSteps),this.weightsRenderable.update()),this.blendRenderable.values.tColor.ref.value!==t&&(M.update(this.blendRenderable.values.tColor,t),this.blendRenderable.update())},e.prototype.render=function(t,r){ft&&this.webgl.timer.mark("SmaaPass.render"),this.edgesTarget.bind(),this.updateState(t),this.edgesRenderable.render(),this.weightsTarget.bind(),this.updateState(t),this.weightsRenderable.render(),r?r.bind():this.webgl.unbindFramebuffer(),this.updateState(t),this.blendRenderable.render(),ft&&this.webgl.timer.markEnd("SmaaPass.render")},e}();var hOe=P(P({},Gn),{tColor:Ft("texture","rgba","ubyte","linear"),uTexSizeInv:_e("v2"),uViewport:_e("v4"),dEdgeThreshold:Dt("number")}),vOe=Nr("smaa-edges",mte,pte);function gOe(e,t){var r=t.getWidth(),n=t.getHeight(),a=P(P({},zn),{tColor:M.create(t),uTexSizeInv:M.create(Me.create(1/r,1/n)),uViewport:M.create(Wt()),dEdgeThreshold:M.create(.1)}),i=P({},hOe),o=ln(e,"triangles",vOe,i,a);return fn(o,a)}var yOe=P(P({},Gn),{tEdges:Ft("texture","rgba","ubyte","linear"),tArea:Ft("texture","rgb","ubyte","linear"),tSearch:Ft("texture","rgba","ubyte","nearest"),uTexSizeInv:_e("v2"),uViewport:_e("v4"),dMaxSearchSteps:Dt("number")}),bOe=Nr("smaa-weights",fte,dte);function xOe(e,t){var r=t.getWidth(),n=t.getHeight(),a=e.resources.texture("image-uint8","rgb","ubyte","linear"),i=e.resources.texture("image-uint8","rgba","ubyte","nearest"),o=P(P({},zn),{tEdges:M.create(t),tArea:M.create(a),tSearch:M.create(i),uTexSizeInv:M.create(Me.create(1/r,1/n)),uViewport:M.create(Wt()),dMaxSearchSteps:M.create(16)});cR(wOe(),o.tArea,a),cR(TOe(),o.tSearch,i);var s=P({},yOe),u=ln(e,"triangles",bOe,s,o);return fn(u,o)}var SOe=P(P({},Gn),{tColor:Ft("texture","rgba","ubyte","linear"),tWeights:Ft("texture","rgba","ubyte","linear"),uTexSizeInv:_e("v2"),uViewport:_e("v4")}),COe=Nr("smaa-blend",cte,lte);function _Oe(e,t,r){var n=t.getWidth(),a=t.getHeight(),i=P(P({},zn),{tColor:M.create(t),tWeights:M.create(r),uTexSizeInv:M.create(Me.create(1/n,1/a)),uViewport:M.create(Wt())}),o=P({},SOe),s=ln(e,"triangles",COe,o,i);return fn(s,i)}function wOe(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAIAAACOVPcQAACBeklEQVR42u39W4xlWXrnh/3WWvuciIzMrKxrV8/0rWbY0+SQFKcb4owIkSIFCjY9AC1BT/LYBozRi+EX+cV+8IMsYAaCwRcBwjzMiw2jAWtgwC8WR5Q8mDFHZLNHTarZGrLJJllt1W2qKrsumZWZcTvn7L3W54e1vrXX3vuciLPPORFR1XE2EomorB0nVuz//r71re/y/1eMvb4Cb3N11xV/PP/2v4UBAwJG/7H8urx6/25/Gf8O5hypMQ0EEEQwAqLfoN/Z+97f/SW+/NvcgQk4sGBJK6H7N4PFVL+K+e0N11yNfkKvwUdwdlUAXPHHL38oa15f/i/46Ih6SuMSPmLAYAwyRKn7dfMGH97jaMFBYCJUgotIC2YAdu+LyW9vvubxAP8kAL8H/koAuOKP3+q6+xGnd5kdYCeECnGIJViwGJMAkQKfDvB3WZxjLKGh8VSCCzhwEWBpMc5/kBbjawT4HnwJfhr+pPBIu7uu+OOTo9vsmtQcniMBGkKFd4jDWMSCRUpLjJYNJkM+IRzQ+PQvIeAMTrBS2LEiaiR9b/5PuT6Ap/AcfAFO4Y3dA3DFH7/VS+M8k4baEAQfMI4QfbVDDGIRg7GKaIY52qAjTAgTvGBAPGIIghOCYAUrGFNgzA7Q3QhgCwfwAnwe5vDejgG44o/fbm1C5ZlYQvQDARPAIQGxCWBM+wWl37ZQESb4gImexGMDouhGLx1Cst0Saa4b4AqO4Hk4gxo+3DHAV/nx27p3JziPM2pVgoiia5MdEzCGULprIN7gEEeQ5IQxEBBBQnxhsDb5auGmAAYcHMA9eAAz8PBol8/xij9+C4Djlim4gJjWcwZBhCBgMIIYxGAVIkH3ZtcBuLdtRFMWsPGoY9rN+HoBji9VBYdwD2ZQg4cnO7OSq/z4rU5KKdwVbFAjNojCQzTlCLPFSxtamwh2jMUcEgg2Wm/6XgErIBhBckQtGN3CzbVacERgCnfgLswhnvqf7QyAq/z4rRZm1YglYE3affGITaZsdIe2FmMIpnOCap25I6jt2kCwCW0D1uAD9sZctNGXcQIHCkINDQgc78aCr+zjtw3BU/ijdpw3zhCwcaONwBvdeS2YZKkJNJsMPf2JKEvC28RXxxI0ASJyzQCjCEQrO4Q7sFArEzjZhaFc4cdv+/JFdKULM4px0DfUBI2hIsy06BqLhGTQEVdbfAIZXYMPesq6VoCHICzUyjwInO4Y411//LYLs6TDa9wvg2CC2rElgAnpTBziThxaL22MYhzfkghz6GAs2VHbbdM91VZu1MEEpupMMwKyVTb5ij9+u4VJG/5EgEMMmFF01cFai3isRbKbzb+YaU/MQbAm2XSMoUPAmvZzbuKYRIFApbtlrfFuUGd6vq2hXNnH78ZLh/iFhsQG3T4D1ib7k5CC6vY0DCbtrohgLEIClXiGtl10zc0CnEGIhhatLBva7NP58Tvw0qE8yWhARLQ8h4+AhQSP+I4F5xoU+VilGRJs6wnS7ruti/4KvAY/CfdgqjsMy4pf8fodQO8/gnuX3f/3xi3om1/h7THr+co3x93PP9+FBUfbNUjcjEmhcrkT+8K7ml7V10Jo05mpIEFy1NmCJWx9SIKKt+EjAL4Ez8EBVOB6havuT/rByPvHXK+9zUcfcbb254+9fydJknYnRr1oGfdaiAgpxu1Rx/Rek8KISftx3L+DfsLWAANn8Hvw0/AFeAGO9DFV3c6D+CcWbL8Dj9e7f+T1k8AZv/d7+PXWM/Z+VvdCrIvuAKO09RpEEQJM0Ci6+B4xhTWr4cZNOvhktabw0ta0rSJmqz3Yw5/AKXwenod7cAhTmBSPKf6JBdvH8IP17h95pXqw50/+BFnj88fev4NchyaK47OPhhtI8RFSvAfDSNh0Ck0p2gLxGkib5NJj/JWCr90EWQJvwBzO4AHcgztwAFN1evHPUVGwfXON+0debT1YeGON9Yy9/63X+OguiwmhIhQhD7l4sMqlG3D86Suc3qWZ4rWjI1X7u0Ytw6x3rIMeIOPDprfe2XzNgyj6PahhBjO4C3e6puDgXrdg+/5l948vF3bqwZetZ+z9Rx9zdIY5pInPK4Nk0t+l52xdK2B45Qd87nM8fsD5EfUhIcJcERw4RdqqH7Yde5V7m1vhNmtedkz6EDzUMF/2jJYWbC+4fzzA/Y+/8PPH3j9dcBAPIRP8JLXd5BpAu03aziOL3VVHZzz3CXWDPWd+SH2AnxIqQoTZpo9Ckc6HIrFbAbzNmlcg8Ag8NFDDAhbJvTBZXbC94P7t68EXfv6o+21gUtPETU7bbkLxvNKRFG2+KXzvtObonPP4rBvsgmaKj404DlshFole1Glfh02fE7bYR7dZ82oTewIBGn1Md6CG6YUF26X376oevOLzx95vhUmgblI6LBZwTCDY7vMq0op5WVXgsObOXJ+1x3qaBl9j1FeLxbhU9w1F+Wiba6s1X/TBz1LnUfuYDi4r2C69f1f14BWfP+p+W2GFKuC9phcELMYRRLur9DEZTUdEH+iEqWdaM7X4WOoPGI+ZYD2+wcQ+y+ioHUZ9dTDbArzxmi/bJI9BND0Ynd6lBdve/butBw8+f/T9D3ABa3AG8W3VPX4hBin+bj8dMMmSpp5pg7fJ6xrBFE2WQQEWnV8Qg3FbAWzYfM1rREEnmvkN2o1+acG2d/9u68GDzx91v3mAjb1zkpqT21OipPKO0b9TO5W0nTdOmAQm0TObts3aBKgwARtoPDiCT0gHgwnbArzxmtcLc08HgF1asN0C4Ms/fvD5I+7PhfqyXE/b7RbbrGyRQRT9ARZcwAUmgdoz0ehJ9Fn7QAhUjhDAQSw0bV3T3WbNa59jzmiP6GsWbGXDX2ytjy8+f9T97fiBPq9YeLdBmyuizZHaqXITnXiMUEEVcJ7K4j3BFPurtB4bixW8wTpweL8DC95szWMOqucFYGsWbGU7p3TxxxefP+r+oTVktxY0v5hbq3KiOKYnY8ddJVSBxuMMVffNbxwIOERShst73HZ78DZrHpmJmH3K6sGz0fe3UUj0eyRrSCGTTc+rjVNoGzNSv05srAxUBh8IhqChiQgVNIIBH3AVPnrsnXQZbLTm8ammv8eVXn/vWpaTem5IXRlt+U/LA21zhSb9cye6jcOfCnOwhIAYXAMVTUNV0QhVha9xjgA27ODJbLbmitt3tRN80lqG6N/khgot4ZVlOyO4WNg3OIMzhIZQpUEHieg2im6F91hB3I2tubql6BYNN9Hj5S7G0G2tahslBWKDnOiIvuAEDzakDQKDNFQT6gbn8E2y4BBubM230YIpBnDbMa+y3dx0n1S0BtuG62lCCXwcY0F72T1VRR3t2ONcsmDjbmzNt9RFs2LO2hQNyb022JisaI8rAWuw4HI3FuAIhZdOGIcdjLJvvObqlpqvWTJnnQbyi/1M9O8UxWhBs//H42I0q1Yb/XPGONzcmm+ri172mHKvZBpHkJaNJz6v9jxqiklDj3U4CA2ugpAaYMWqNXsdXbmJNd9egCnJEsphXNM+MnK3m0FCJ5S1kmJpa3DgPVbnQnPGWIDspW9ozbcO4K/9LkfaQO2KHuqlfFXSbdNzcEcwoqNEFE9zcIXu9/6n/ym/BC/C3aJLzEKPuYVlbFnfhZ8kcWxV3dbv4bKl28566wD+8C53aw49lTABp9PWbsB+knfc/Li3eVizf5vv/xmvnPKg5ihwKEwlrcHqucuVcVOxEv8aH37E3ZqpZypUulrHEtIWKUr+txHg+ojZDGlwnqmkGlzcVi1dLiNSJiHjfbRNOPwKpx9TVdTn3K05DBx4psIk4Ei8aCkJahRgffk4YnEXe07T4H2RR1u27E6wfQsBDofUgjFUFnwC2AiVtA+05J2zpiDK2Oa0c5fmAecN1iJzmpqFZxqYBCYhFTCsUNEmUnIcZ6aEA5rQVhEywG6w7HSW02XfOoBlQmjwulOFQAg66SvJblrTEX1YtJ3uG15T/BH1OfOQeuR8g/c0gdpT5fx2SKbs9EfHTKdM8A1GaJRHLVIwhcGyydZsbifAFVKl5EMKNU2Hryo+06BeTgqnxzYjThVySDikbtJPieco75lYfKAJOMEZBTjoITuWHXXZVhcUDIS2hpiXHV9Ku4u44bN5OYLDOkJo8w+xJSMbhBRHEdEs9JZUCkQrPMAvaHyLkxgkEHxiNkx/x2YB0mGsQ8EUWj/stW5YLhtS5SMu+/YBbNPDCkGTUybN8krRLBGPlZkVOA0j+a1+rkyQKWGaPHPLZOkJhioQYnVZ2hS3zVxMtgC46KuRwbJNd9nV2PHgb36F194ecf/Yeu2vAFe5nm/bRBFrnY4BauE8ERmZRFUn0k8hbftiVYSKMEme2dJCJSCGYAlNqh87bXOPdUkGy24P6d1ll21MBqqx48Fvv8ZHH8HZFY7j/uAq1xMJUFqCSUlJPmNbIiNsmwuMs/q9CMtsZsFO6SprzCS1Z7QL8xCQClEelpjTduDMsmWD8S1PT152BtvmIGvUeDA/yRn83u/x0/4qxoPHjx+PXY9pqX9bgMvh/Nz9kpP4pOe1/fYf3axUiMdHLlPpZCNjgtNFAhcHEDxTumNONhHrBduW+vOyY++70WWnPXj98eA4kOt/mj/5E05l9+O4o8ePx67HFqyC+qSSnyselqjZGaVK2TadbFLPWAQ4NBhHqDCCV7OTpo34AlSSylPtIdd2AJZlyzYQrDJ5lcWGNceD80CunPLGGzsfD+7wRb95NevJI5docQ3tgCyr5bGnyaPRlmwNsFELViOOx9loebGNq2moDOKpHLVP5al2cymWHbkfzGXL7kfRl44H9wZy33tvt+PB/Xnf93e+nh5ZlU18wCiRUa9m7kib9LYuOk+hudQNbxwm0AQqbfloimaB2lM5fChex+ylMwuTbfmXQtmWlenZljbdXTLuOxjI/fDDHY4Hjx8/Hrse0zXfPFxbUN1kKqSCCSk50m0Ajtx3ub9XHBKHXESb8iO6E+qGytF4nO0OG3SXzbJlhxBnKtKyl0NwybjvYCD30aMdjgePHz8eu56SVTBbgxJMliQ3Oauwg0QHxXE2Ez/EIReLdQj42Gzb4CLS0YJD9xUx7bsi0vJi5mUbW1QzL0h0PFk17rtiIPfJk52MB48fPx67npJJwyrBa2RCCQRTbGZSPCxTPOiND4G2pYyOQ4h4jINIJh5wFU1NFZt+IsZ59LSnDqBjZ2awbOku+yInunLcd8VA7rNnOxkPHj9+PGY9B0MWJJNozOJmlglvDMXDEozdhQWbgs/U6oBanGzLrdSNNnZFjOkmbi5bNt1lX7JLLhn3vXAg9/h4y/Hg8ePHI9dzQMEkWCgdRfYykYKnkP7D4rIujsujaKPBsB54vE2TS00ccvFY/Tth7JXeq1hz+qgVy04sAJawTsvOknHfCwdyT062HA8eP348Zj0vdoXF4pilKa2BROed+9fyw9rWRXeTFXESMOanvDZfJuJaSXouQdMdDJZtekZcLLvEeK04d8m474UDuaenW44Hjx8/Xns9YYqZpszGWB3AN/4VHw+k7WSFtJ3Qicuqb/NlVmgXWsxh570xg2UwxUw3WfO6B5nOuO8aA7lnZxuPB48fPx6znm1i4bsfcbaptF3zNT78eFPtwi1OaCNOqp1x3zUGcs/PN++AGD1+fMXrSVm2baTtPhPahbPhA71wIHd2bXzRa69nG+3CraTtPivahV/55tXWg8fyRY/9AdsY8VbSdp8V7cKrrgdfM//z6ILQFtJ2nxHtwmuoB4/kf74+gLeRtvvMaBdeSz34+vifx0YG20jbfTa0C6+tHrwe//NmOG0L8EbSdp8R7cLrrQe/996O+ai3ujQOskpTNULa7jOjXXj99eCd8lHvoFiwsbTdZ0a78PrrwTvlo966pLuRtB2fFe3Cm6oHP9kNH/W2FryxtN1nTLvwRurBO+Kj3pWXHidtx2dFu/Bm68Fb81HvykuPlrb7LGkX3mw9eGs+6h1Y8MbSdjegXcguQLjmevDpTQLMxtJ2N6NdyBZu9AbrwVvwUW+LbteULUpCdqm0HTelXbhNPe8G68Gb8lFvVfYfSNuxvrTdTWoXbozAzdaDZzfkorOj1oxVxlIMlpSIlpLrt8D4hrQL17z+c3h6hU/wv4Q/utps4+bm+6P/hIcf0JwQ5oQGPBL0eKPTYEXTW+eL/2DKn73J9BTXYANG57hz1cEMviVf/4tf5b/6C5pTQkMIWoAq7hTpOJjtAM4pxKu5vg5vXeUrtI09/Mo/5H+4z+Mp5xULh7cEm2QbRP2tFIKR7WM3fPf/jZ3SWCqLM2l4NxID5zB72HQXv3jj/8mLR5xXNA5v8EbFQEz7PpRfl1+MB/hlAN65qgDn3wTgH13hK7T59bmP+NIx1SHHU84nLOITt3iVz8mNO+lPrjGAnBFqmioNn1mTyk1ta47R6d4MrX7tjrnjYUpdUbv2rVr6YpVfsGG58AG8Ah9eyUN8CX4WfgV+G8LVWPDGb+Zd4cU584CtqSbMKxauxTg+dyn/LkVgA+IR8KHtejeFKRtTmLLpxN6mYVLjYxwXf5x2VofiZcp/lwKk4wGOpYDnoIZPdg/AAbwMfx0+ge9dgZvYjuqKe4HnGnykYo5TvJbG0Vj12JagRhwKa44H95ShkZa5RyLGGdfYvG7aw1TsF6iapPAS29mNS3NmsTQZCmgTzFwgL3upCTgtBTRwvGMAKrgLn4evwin8+afJRcff+8izUGUM63GOOuAs3tJkw7J4kyoNreqrpO6cYLQeFUd7TTpr5YOTLc9RUUogUOVJQ1GYJaFLAW0oTmKyYS46ZooP4S4EON3xQ5zC8/CX4CnM4c1PE8ApexpoYuzqlP3d4S3OJP8ZDK7cKWNaTlqmgDiiHwl1YsE41w1zT4iRTm3DBqxvOUsbMKKDa/EHxagtnta072ejc3DOIh5ojvh8l3tk1JF/AV6FU6jh3U8HwEazLgdCLYSQ+MYiAI2ltomkzttUb0gGHdSUUgsIYjTzLG3mObX4FBRaYtpDVNZrih9TgTeYOBxsEnN1gOCTM8Bsw/ieMc75w9kuAT6A+/AiHGvN/+Gn4KRkiuzpNNDYhDGFndWRpE6SVfm8U5bxnSgVV2jrg6JCKmneqey8VMFgq2+AM/i4L4RUbfSi27lNXZ7R7W9RTcq/q9fk4Xw3AMQd4I5ifAZz8FcVtm9SAom/dyN4lczJQW/kC42ZrHgcCoIf1oVMKkVItmMBi9cOeNHGLqOZk+QqQmrbc5YmYgxELUUN35z2iohstgfLIFmcMV7s4CFmI74L9+EFmGsi+tGnAOD4Yk9gIpo01Y4cA43BWGygMdr4YZekG3OBIUXXNukvJS8tqa06e+lSDCtnqqMFu6hWHXCF+WaYt64m9QBmNxi7Ioy7D+fa1yHw+FMAcPt7SysFLtoG4PXAk7JOA3aAxBRqUiAdU9Yp5lK3HLSRFtOim0sa8euEt08xvKjYjzeJ2GU7YawexrnKI9tmobInjFXCewpwriY9+RR4aaezFhMhGCppKwom0ChrgFlKzyPKkGlTW1YQrE9HJqu8hKGgMc6hVi5QRq0PZxNfrYNgE64utmRv6KKHRpxf6VDUaOvNP5jCEx5q185My/7RKz69UQu2im5k4/eownpxZxNLwiZ1AZTO2ZjWjkU9uaB2HFn6Q3u0JcsSx/qV9hTEApRzeBLDJQXxYmTnq7bdLa3+uqFrxLJ5w1TehnNHx5ECvCh2g2c3hHH5YsfdaSKddztfjQ6imKFGSyFwlLzxEGPp6r5IevVjk1AMx3wMqi1NxDVjLBiPs9tbsCkIY5we5/ML22zrCScFxnNtzsr9Wcc3CnD+pYO+4VXXiDE0oc/vQQ/fDK3oPESJMYXNmJa/DuloJZkcTpcYE8lIH8Dz8DJMiynNC86Mb2lNaaqP/+L7f2fcE/yP7/Lde8xfgSOdMxvOixZf/9p3+M4hT1+F+zApxg9XfUvYjc8qX2lfOOpK2gNRtB4flpFu9FTKCp2XJRgXnX6olp1zyYjTKJSkGmLE2NjUr1bxFM4AeAAHBUFIeSLqXR+NvH/M9fOnfHzOD2vCSyQJKzfgsCh+yi/Mmc35F2fUrw7miW33W9hBD1vpuUojFphIyvg7aTeoymDkIkeW3XLHmguMzbIAJejN6B5MDrhipE2y6SoFRO/AK/AcHHZHNIfiWrEe/C6cr3f/yOvrQKB+zMM55/GQdLDsR+ifr5Fiuu+/y+M78LzOE5dsNuXC3PYvYWd8NXvphLSkJIasrlD2/HOqQ+RjcRdjKTGWYhhVUm4yxlyiGPuMsZR7sMCHUBeTuNWA7if+ifXgc/hovftHXs/DV+Fvwe+f8shzMiMcweFgBly3//vwJfg5AN4450fn1Hd1Rm1aBLu22Dy3y3H2+OqMemkbGZ4jozcDjJf6596xOLpC0eMTHbKnxLxH27uZ/bMTGs2jOaMOY4m87CfQwF0dw53oa1k80JRuz/XgS+8fX3N9Af4qPIMfzKgCp4H5TDGe9GGeFPzSsZz80SlPTxXjgwJmC45njzgt2vbQ4b4OAdUK4/vWhO8d8v6EE8fMUsfakXbPpFJeLs2ubM/qdm/la3WP91uWhxXHjoWhyRUq2iJ/+5mA73zwIIo+LoZ/SgvIRjAd1IMvvn98PfgOvAJfhhm8scAKVWDuaRaK8aQ9f7vuPDH6Bj47ZXau7rqYJ66mTDwEDU6lLbCjCK0qTXyl5mnDoeNRxanj3FJbaksTk0faXxHxLrssgPkWB9LnA/MFleXcJozzjwsUvUG0X/QCve51qkMDXp9mtcyOy3rwBfdvVJK7D6/ACSzg3RoruIq5UDeESfEmVclDxnniU82vxMLtceD0hGZWzBNPMM/jSPne2OVatiTKUpY5vY7gc0LdUAWeWM5tH+O2I66AOWw9xT2BuyRVLGdoDHUsVRXOo/c+ZdRXvFfnxWyIV4upFLCl9eAL7h8Zv0QH8Ry8pA2cHzQpGesctVA37ZtklBTgHjyvdSeKY/RZw/kJMk0Y25cSNRWSigQtlULPTw+kzuJPeYEkXjQRpoGZobYsLF79pyd1dMRHInbgFTZqNLhDqiIsTNpoex2WLcy0/X6rHcdMMQvFSd5dWA++4P7xv89deACnmr36uGlL69bRCL6BSZsS6c0TU2TKK5gtWCzgAOOwQcurqk9j8whvziZSMLcq5hbuwBEsYjopUBkqw1yYBGpLA97SRElEmx5MCInBY5vgLk94iKqSWmhIGmkJ4Bi9m4L645J68LyY4wsFYBfUg5feP/6gWWm58IEmKQM89hq7KsZNaKtP5TxxrUZZVkNmMJtjbKrGxLNEbHPJxhqy7lAmbC32ZqeF6lTaknRWcYaFpfLUBh/rwaQycCCJmW15Kstv6jRHyJFry2C1ahkkIW0LO75s61+owxK1y3XqweX9m5YLM2DPFeOjn/iiqCKJ+yKXF8t5Yl/kNsqaSCryxPq5xWTFIaP8KSW0RYxqupaUf0RcTNSSdJZGcKYdYA6kdtrtmyBckfKXwqk0pHpUHlwWaffjNRBYFPUDWa8e3Lt/o0R0CdisKDM89cX0pvRHEfM8ca4t0s2Xx4kgo91MPQJ/0c9MQYq0co8MBh7bz1fio0UUHLR4aAIOvOmoYO6kwlEVODSSTliWtOtH6sPkrtctF9ZtJ9GIerBskvhdVS5cFNv9s1BU0AbdUgdK4FG+dRnjFmDTzniRMdZO1QhzMK355vigbdkpz9P6qjUGE5J2qAcXmwJ20cZUiAD0z+pGMx6xkzJkmEf40Hr4qZfVg2XzF9YOyoV5BjzVkUJngKf8lgNYwKECEHrCNDrWZzMlflS3yBhr/InyoUgBc/lKT4pxVrrC6g1YwcceK3BmNxZcAtz3j5EIpqguh9H6wc011YN75cKDLpFDxuwkrPQmUwW4KTbj9mZTwBwLq4aQMUZbHm1rylJ46dzR0dua2n3RYCWZsiHROeywyJGR7mXKlpryyCiouY56sFkBWEnkEB/raeh/Sw4162KeuAxMQpEkzy5alMY5wamMsWKKrtW2WpEWNnReZWONKWjrdsKZarpFjqCslq773PLmEhM448Pc3+FKr1+94vv/rfw4tEcu+lKTBe4kZSdijBrykwv9vbCMPcLQTygBjzVckSLPRVGslqdunwJ4oegtFOYb4SwxNgWLCmD7T9kVjTv5YDgpo0XBmN34Z/rEHp0sgyz7lngsrm4lvMm2Mr1zNOJYJ5cuxuQxwMGJq/TP5emlb8fsQBZviK4t8hFL+zbhtlpwaRSxQRWfeETjuauPsdGxsBVdO7nmP4xvzSoT29pRl7kGqz+k26B3Oy0YNV+SXbbQas1ctC/GarskRdFpKczVAF1ZXnLcpaMuzVe6lZ2g/1ndcvOVgRG3sdUAY1bKD6achijMPdMxV4muKVorSpiDHituH7rSTs7n/4y5DhRXo4FVBN4vO/zbAcxhENzGbHCzU/98Mcx5e7a31kWjw9FCe/zNeYyQjZsWb1uc7U33pN4Mji6hCLhivqfa9Ss6xLg031AgfesA/l99m9fgvnaF9JoE6bYKmkGNK3aPbHB96w3+DnxFm4hs0drLsk7U8kf/N/CvwQNtllna0rjq61sH8L80HAuvwH1tvBy2ChqWSCaYTaGN19sTvlfzFD6n+iKTbvtayfrfe9ueWh6GJFoxLdr7V72a5ZpvHcCPDzma0wTO4EgbLyedxstO81n57LYBOBzyfsOhUKsW1J1BB5vr/tz8RyqOFylQP9Tvst2JALsC5lsH8PyQ40DV4ANzYa4dedNiKNR1s+x2wwbR7q4/4cTxqEk4LWDebfisuo36JXLiWFjOtLrlNWh3K1rRS4xvHcDNlFnNmWBBAl5SWaL3oPOfnvbr5pdjVnEaeBJSYjuLEkyLLsWhKccadmOphZkOPgVdalj2QpSmfOsADhMWE2ZBu4+EEJI4wKTAuCoC4xwQbWXBltpxbjkXJtKxxabo9e7tyhlgb6gNlSbUpMh+l/FaqzVwewGu8BW1Zx7pTpQDJUjb8tsUTW6+GDXbMn3mLbXlXJiGdggxFAoUrtPS3wE4Nk02UZG2OOzlk7fRs7i95QCLo3E0jtrjnM7SR3uS1p4qtS2nJ5OwtQVHgOvArLBFijZUV9QtSl8dAY5d0E0hM0w3HS2DpIeB6m/A1+HfhJcGUq4sOxH+x3f5+VO+Ds9rYNI7zPXOYWPrtf8bYMx6fuOAX5jzNR0PdsuON+X1f7EERxMJJoU6GkTEWBvVolVlb5lh3tKCg6Wx1IbaMDdJ+9sUCc5KC46hKGCk3IVOS4TCqdBNfUs7Kd4iXf2RjnT/LLysJy3XDcHLh/vde3x8DoGvwgsa67vBk91G5Pe/HbOe7xwym0NXbtiuuDkGO2IJDh9oQvJ4cY4vdoqLDuoH9Zl2F/ofsekn8lkuhIlhQcffUtSjytFyp++p6NiE7Rqx/lodgKVoceEp/CP4FfjrquZaTtj2AvH5K/ywpn7M34K/SsoYDAdIN448I1/0/wveW289T1/lX5xBzc8N5IaHr0XMOQdHsIkDuJFifj20pBm5jzwUv9e2FhwRsvhAbalCIuIw3bhJihY3p6nTFFIZgiSYjfTf3aXuOjmeGn4bPoGvwl+CFzTRczBIuHBEeImHc37/lGfwZR0cXzVDOvaKfNHvwe+suZ771K/y/XcBlsoN996JpBhoE2toYxOznNEOS5TJc6Id5GEXLjrWo+LEWGNpPDU4WAwsIRROu+1vM+0oW37z/MBN9kqHnSArwPfgFJ7Cq/Ai3Ie7g7ncmI09v8sjzw9mzOAEXoIHxURueaAce5V80f/DOuuZwHM8vsMb5wBzOFWM7wymTXPAEvm4vcFpZ2ut0VZRjkiP2MlmLd6DIpbGSiHOjdnUHN90hRYmhTnmvhzp1iKDNj+b7t5hi79lWGwQ+HN9RsfFMy0FXbEwhfuczKgCbyxYwBmcFhhvo/7a44v+i3XWcwDP86PzpGQYdWh7csP5dBvZ1jNzdxC8pBGuxqSW5vw40nBpj5JhMwvOzN0RWqERHMr4Lv1kWX84xLR830G3j6yqZ1a8UstTlW+qJPOZ+sZ7xZPKTJLhiNOAFd6tk+jrTH31ncLOxid8+nzRb128HhUcru/y0Wn6iT254YPC6FtVSIMoW2sk727AhvTtrWKZTvgsmckfXYZWeNRXx/3YQ2OUxLDrbHtN11IwrgXT6c8dATDwLniYwxzO4RzuQqTKSC5gAofMZ1QBK3zQ4JWobFbcvJm87FK+6JXrKahLn54m3p+McXzzYtP8VF/QpJuh1OwieElEoI1pRxPS09FBrkq2tWCU59+HdhNtTIqKm8EBrw2RTOEDpG3IKo2Y7mFdLm3ZeVjYwVw11o/oznceMve4CgMfNym/utA/d/ILMR7gpXzRy9eDsgLcgbs8O2Va1L0zzIdwGGemTBuwROHeoMShkUc7P+ISY3KH5ZZeWqO8mFTxQYeXTNuzvvK5FGPdQfuu00DwYFY9dyhctEt+OJDdnucfpmyhzUJzfsJjr29l8S0bXBfwRS9ZT26tmMIdZucch5ZboMz3Nio3nIOsYHCGoDT4kUA9MiXEp9Xsui1S8th/kbWIrMBxDGLodWUQIWcvnXy+9M23xPiSMOiRPqM+YMXkUN3gXFrZJwXGzUaMpJfyRS9ZT0lPe8TpScuRlbMHeUmlaKDoNuy62iWNTWNFYjoxFzuJs8oR+RhRx7O4SVNSXpa0ZJQ0K1LAHDQ+D9IepkMXpcsq5EVCvClBUIzDhDoyKwDw1Lc59GbTeORivugw1IcuaEOaGWdNm+Ps5fQ7/tm0DjMegq3yM3vb5j12qUId5UZD2oxDSEWOZMSqFl/W+5oynWDa/aI04tJRQ2eTXusg86SQVu/nwSYwpW6wLjlqIzwLuxGIvoAvul0PS+ZNz0/akp/pniO/8JDnGyaCkzbhl6YcqmK/69prxPqtpx2+Km9al9sjL+rwMgHw4jE/C8/HQ3m1vBuL1fldbzd8mOueVJ92syqdEY4KJjSCde3mcRw2TA6szxedn+zwhZMps0XrqEsiUjnC1hw0TELC2Ek7uAAdzcheXv1BYLagspxpzSAoZZUsIzIq35MnFQ9DOrlNB30jq3L4pkhccKUAA8/ocvN1Rzx9QyOtERs4CVsJRK/DF71kPYrxYsGsm6RMh4cps5g1DOmM54Ly1ii0Hd3Y/BMk8VWFgBVmhqrkJCPBHAolwZaWzLR9Vb7bcWdX9NyUYE+uB2BKfuaeBUcjDljbYVY4DdtsVWvzRZdWnyUzDpjNl1Du3aloAjVJTNDpcIOVVhrHFF66lLfJL1zJr9PQ2nFJSBaKoDe+sAvLufZVHVzYh7W0h/c6AAZ+7Tvj6q9j68G/cTCS/3n1vLKHZwNi+P+pS0WkZNMBMUl+LDLuiE4omZy71r3UFMwNJV+VJ/GC5ixVUkBStsT4gGKh0Gm4Oy3qvq7Lbmq24nPdDuDR9deR11XzP4vFu3TYzfnIyiSVmgizUYGqkIXNdKTY9pgb9D2Ix5t0+NHkVzCdU03suWkkVZAoCONCn0T35gAeW38de43mf97sMOpSvj4aa1KYUm58USI7Wxxes03bAZdRzk6UtbzMaCQ6IxO0dy7X+XsjoD16hpsBeGz9dfzHj+R/Hp8nCxZRqkEDTaCKCSywjiaoMJ1TITE9eg7Jqnq8HL6gDwiZb0u0V0Rr/rmvqjxKuaLCX7ZWXTvAY+uvm3z8CP7nzVpngqrJpZKwWnCUjIviYVlirlGOzPLI3SMVyp/elvBUjjDkNhrtufFFErQ8pmdSlbK16toBHlt/HV8uHMX/vEGALkV3RJREiSlopxwdMXOZPLZ+ix+kAHpMKIk8UtE1ygtquttwxNhphrIZ1IBzjGF3IIGxGcBj6q8bHJBG8T9vdsoWrTFEuebEZuVxhhClH6P5Zo89OG9fwHNjtNQTpD0TG9PJLEYqvEY6Rlxy+ZZGfL0Aj62/bnQCXp//eeM4KzfQVJbgMQbUjlMFIm6TpcfWlZje7NBSV6IsEVmumWIbjiloUzQX9OzYdo8L1wjw2PrrpimONfmfNyzKklrgnEkSzT5QWYQW40YShyzqsRmMXbvVxKtGuYyMKaU1ugenLDm5Ily4iT14fP11Mx+xJv+zZ3MvnfdFqxU3a1W/FTB4m3Qfsyc1XUcdVhDeUDZXSFHHLQj/Y5jtC7ZqM0CXGwB4bP11i3LhOvzPGygYtiUBiwQV/4wFO0majijGsafHyRLu0yG6q35cL1rOpVxr2s5cM2jJYMCdc10Aj6q/blRpWJ//+dmm5psMl0KA2+AFRx9jMe2WbC4jQxnikd4DU8TwUjRVacgdlhmr3bpddzuJ9zXqr2xnxJfzP29RexdtjDVZqzkqa6PyvcojGrfkXiJ8SEtml/nYskicv0ivlxbqjemwUjMw5evdg8fUX9nOiC/lf94Q2i7MURk9nW1MSj5j8eAyV6y5CN2S6qbnw3vdA1Iwq+XOSCl663udN3IzLnrt+us25cI1+Z83SXQUldqQq0b5XOT17bGpLd6ssN1VMPf8c+jG8L3NeCnMdF+Ra3fRa9dft39/LuZ/3vwHoHrqGmQFafmiQw6eyzMxS05K4bL9uA+SKUQzCnSDkqOGokXyJvbgJ/BHI+qvY69//4rl20NsmK2ou2dTsyIALv/91/8n3P2Aao71WFGi8KKv1fRC5+J67Q/507/E/SOshqN5TsmYIjVt+kcjAx98iz/4SaojbIV1rexE7/C29HcYD/DX4a0rBOF5VTu7omsb11L/AWcVlcVZHSsqGuXLLp9ha8I//w3Mv+T4Ew7nTBsmgapoCrNFObIcN4pf/Ob/mrvHTGqqgAupL8qWjWPS9m/31jAe4DjA+4+uCoQoT/zOzlrNd3qd4SdphFxsUvYwGWbTWtISc3wNOWH+kHBMfc6kpmpwPgHWwqaSUG2ZWWheYOGQGaHB+eQ/kn6b3pOgLV+ODSn94wDvr8Bvb70/LLuiPPEr8OGVWfDmr45PZyccEmsVXZGe1pRNX9SU5+AVQkNTIVPCHF/jGmyDC9j4R9LfWcQvfiETmgMMUCMN1uNCakkweZsowdYobiMSlnKA93u7NzTXlSfe+SVbfnPQXmg9LpYAQxpwEtONyEyaueWM4FPjjyjG3uOaFmBTWDNgBXGEiQpsaWhnAqIijB07Dlsy3fUGeP989xbWkyf+FF2SNEtT1E0f4DYYVlxFlbaSMPIRMk/3iMU5pME2SIWJvjckciebkQuIRRyhUvkHg/iUljG5kzVog5hV7vIlCuBrmlhvgPfNHQM8lCf+FEGsYbMIBC0qC9a0uuy2wLXVbLBaP5kjHokCRxapkQyzI4QEcwgYHRZBp+XEFTqXFuNVzMtjXLJgX4gAid24Hjwc4N3dtVSe+NNiwTrzH4WVUOlDobUqr1FuAgYllc8pmzoVrELRHSIW8ViPxNy4xwjBpyR55I6J220qQTZYR4guvUICJiSpr9gFFle4RcF/OMB7BRiX8sSfhpNSO3lvEZCQfLUVTKT78Ek1LRLhWN+yLyTnp8qWUZ46b6vxdRGXfHVqx3eI75YaLa4iNNiK4NOW7wPW6lhbSOF9/M9qw8e/aoB3d156qTzxp8pXx5BKAsYSTOIIiPkp68GmTq7sZtvyzBQaRLNxIZ+paozHWoLFeExIhRBrWitHCAHrCF7/thhD8JhYz84wg93QRV88wLuLY8zF8sQ36qF1J455bOlgnELfshKVxYOXKVuKx0jaj22sczTQqPqtV/XDgpswmGTWWMSDw3ssyUunLLrVPGjYRsH5ggHeHSWiV8kT33ycFSfMgkoOK8apCye0J6VW6GOYvffgU9RWsukEi2kUV2nl4dOYUzRik9p7bcA4ggdJ53LxKcEe17B1R8eqAd7dOepV8sTXf5lhejoL85hUdhDdknPtKHFhljOT+bdq0hxbm35p2nc8+Ja1Iw+tJykgp0EWuAAZYwMVwac5KzYMslhvgHdHRrxKnvhTYcfKsxTxtTETkjHO7rr3zjoV25lAQHrqpV7bTiy2aXMmUhTBnKS91jhtR3GEoF0oLnWhWNnYgtcc4N0FxlcgT7yz3TgNIKkscx9jtV1ZKpWW+Ub1tc1eOv5ucdgpx+FJy9pgbLE7xDyXb/f+hLHVGeitHOi6A7ybo3sF8sS7w7cgdk0nJaOn3hLj3uyD0Zp5pazFIUXUpuTTU18d1EPkDoX8SkmWTnVIozEdbTcZjoqxhNHf1JrSS/AcvHjZ/SMHhL/7i5z+POsTUh/8BvNfYMTA8n+yU/MlTZxSJDRStqvEuLQKWwDctMTQogUDyQRoTQG5Kc6oQRE1yV1jCA7ri7jdZyK0sYTRjCR0Hnnd+y7nHxNgTULqw+8wj0mQKxpYvhjm9uSUxg+TTy7s2GtLUGcywhXSKZN275GsqlclX90J6bRI1aouxmgL7Q0Nen5ziM80SqMIo8cSOo+8XplT/5DHNWsSUr/6lLN/QQ3rDyzLruEW5enpf7KqZoShEduuSFOV7DLX7Ye+GmXb6/hnNNqKsVXuMDFpb9Y9eH3C6NGEzuOuI3gpMH/I6e+zDiH1fXi15t3vA1czsLws0TGEtmPEJdiiFPwlwKbgLHAFk4P6ZyPdymYYHGE0dutsChQBl2JcBFlrEkY/N5bQeXQ18gjunuMfMfsBlxJSx3niO485fwO4fGD5T/+3fPQqkneWVdwnw/3bMPkW9Wbqg+iC765Zk+xcT98ibKZc2EdgHcLoF8cSOo/Oc8fS+OyEULF4g4sJqXVcmfMfsc7A8v1/yfGXmL9I6Fn5pRwZhsPv0TxFNlAfZCvG+Oohi82UC5f/2IsJo0cTOm9YrDoKhFPEUr/LBYTUNht9zelHXDqwfPCIw4owp3mOcIQcLttWXFe3VZ/j5H3cIc0G6oPbCR+6Y2xF2EC5cGUm6wKC5tGEzhsWqw5hNidUiKX5gFWE1GXh4/Qplw4sVzOmx9QxU78g3EF6wnZlEN4FzJ1QPSLEZz1KfXC7vd8ssGdIbNUYpVx4UapyFUHzJoTOo1McSkeNn1M5MDQfs4qQuhhX5vQZFw8suwWTcyYTgioISk2YdmkhehG4PkE7w51inyAGGaU+uCXADabGzJR1fn3lwkty0asIo8cROm9Vy1g0yDxxtPvHDAmpu+PKnM8Ix1wwsGw91YJqhteaWgjYBmmQiebmSpwKKzE19hx7jkzSWOm66oPbzZ8Yj6kxVSpYjVAuvLzYMCRo3oTQecOOjjgi3NQ4l9K5/hOGhNTdcWVOTrlgYNkEXINbpCkBRyqhp+LdRB3g0OU6rMfW2HPCFFMV9nSp+uB2woepdbLBuJQyaw/ZFysXrlXwHxI0b0LovEkiOpXGA1Ijagf+KUNC6rKNa9bQnLFqYNkEnMc1uJrg2u64ELPBHpkgWbmwKpJoDhMwNbbGzAp7Yg31wS2T5rGtzit59PrKhesWG550CZpHEzpv2NGRaxlNjbMqpmEIzygJqQfjypycs2pg2cS2RY9r8HUqkqdEgKTWtWTKoRvOBPDYBltja2SO0RGjy9UHtxwRjA11ujbKF+ti5cIR9eCnxUg6owidtyoU5tK4NLji5Q3HCtiyF2IqLGYsHViOXTXOYxucDqG0HyttqYAKqYo3KTY1ekyDXRAm2AWh9JmsVh/ccg9WJ2E8YjG201sPq5ULxxX8n3XLXuMInbft2mk80rRGjCGctJ8/GFdmEQ9Ug4FlE1ll1Y7jtiraqm5Fe04VV8lvSVBL8hiPrfFVd8+7QH3Qbu2ipTVi8cvSGivc9cj8yvH11YMHdNSERtuOslM97feYFOPKzGcsI4zW0YGAbTAOaxCnxdfiYUmVWslxiIblCeAYr9VYR1gM7GmoPrilunSxxeT3DN/2eBQ9H11+nk1adn6VK71+5+Jfct4/el10/7KBZfNryUunWSCPxPECk1rdOv1WVSrQmpC+Tl46YD3ikQYcpunSQgzVB2VHFhxHVGKDgMEY5GLlQnP7FMDzw7IacAWnO6sBr12u+XanW2AO0wQ8pknnFhsL7KYIqhkEPmEXFkwaN5KQphbkUmG72wgw7WSm9RiL9QT925hkjiVIIhphFS9HKI6/8QAjlpXqg9W2C0apyaVDwKQwrwLY3j6ADR13ZyUNByQXHQu6RY09Hu6zMqXRaNZGS/KEJs0cJEe9VH1QdvBSJv9h09eiRmy0V2uJcqHcShcdvbSNg5fxkenkVprXM9rDVnX24/y9MVtncvbKY706anNl3ASll9a43UiacVquXGhvq4s2FP62NGKfQLIQYu9q1WmdMfmUrDGt8eDS0cXozH/fjmUH6Jruvm50hBDSaEU/2Ru2LEN/dl006TSc/g7tfJERxGMsgDUEr104pfWH9lQaN+M4KWQjwZbVc2rZVNHsyHal23wZtIs2JJqtIc/WLXXRFCpJkfE9jvWlfFbsNQ9pP5ZBS0zKh4R0aMFj1IjTcTnvi0Zz2rt7NdvQb2mgbju1plsH8MmbnEk7KbK0b+wC2iy3aX3szW8xeZvDwET6hWZYwqTXSSG+wMETKum0Dq/q+x62gt2ua2ppAo309TRk9TPazfV3qL9H8z7uhGqGqxNVg/FKx0HBl9OVUORn8Q8Jx9gFttGQUDr3tzcXX9xGgN0EpzN9mdZ3GATtPhL+CjxFDmkeEU6x56kqZRusLzALXVqkCN7zMEcqwjmywDQ6OhyUe0Xao1Qpyncrg6wKp9XfWDsaZplElvQ/b3sdweeghorwBDlHzgk1JmMc/wiERICVy2VJFdMjFuLQSp3S0W3+sngt2njwNgLssFGVQdJ0tu0KH4ky1LW4yrbkuaA6Iy9oz/qEMMXMMDWyIHhsAyFZc2peV9hc7kiKvfULxCl9iddfRK1f8kk9qvbdOoBtOg7ZkOZ5MsGrSHsokgLXUp9y88smniwWyuFSIRVmjplga3yD8Uij5QS1ZiM4U3Qw5QlSm2bXjFe6jzzBFtpg+/YBbLAWG7OPynNjlCw65fukGNdkJRf7yM1fOxVzbxOJVocFoYIaGwH22mIQkrvu1E2nGuebxIgW9U9TSiukPGU+Lt++c3DJPKhyhEEbXCQLUpae2exiKy6tMPe9mDRBFCEMTWrtwxN8qvuGnt6MoihKWS5NSyBhbH8StXoAz8PLOrRgLtOT/+4vcu+7vDLnqNvztOq7fmd8sMmY9Xzn1zj8Dq8+XVdu2Nv0IIySgEdQo3xVHps3Q5i3fLFsV4aiqzAiBhbgMDEd1uh8qZZ+lwhjkgokkOIv4xNJmyncdfUUzgB4oFMBtiu71Xumpz/P+cfUP+SlwFExwWW62r7b+LSPxqxn/gvMZ5z9C16t15UbNlq+jbGJtco7p8wbYlL4alSyfWdeuu0j7JA3JFNuVAwtst7F7FhWBbPFNKIUORndWtLraFLmMu7KFVDDOzqkeaiN33YAW/r76wR4XDN/yN1z7hejPau06EddkS/6XThfcz1fI/4K736fO48vlxt2PXJYFaeUkFS8U15XE3428xdtn2kc8GQlf1vkIaNRRnOMvLTWrZbElEHeLWi1o0dlKPAh1MVgbbVquPJ5+Cr8LU5/H/+I2QlHIU2ClXM9G8v7Rr7oc/hozfUUgsPnb3D+I+7WF8kNO92GY0SNvuxiE+2Bt8prVJTkzE64sfOstxuwfxUUoyk8VjcTlsqe2qITSFoSj6Epd4KsT6BZOWmtgE3hBfir8IzZDwgV4ZTZvD8VvPHERo8v+vL1DASHTz/i9OlKueHDjK5Rnx/JB1Vb1ioXdBra16dmt7dgik10yA/FwJSVY6XjA3oy4SqM2frqDPPSRMex9qs3XQtoWxMj7/Er8GWYsXgjaVz4OYumP2+9kbxvny/6kvWsEBw+fcb5bInc8APdhpOSs01tEqIkoiZjbAqKMruLbJYddHuHFRIyJcbdEdbl2sVLaySygunutBg96Y2/JjKRCdyHV+AEFtTvIpbKIXOamknYSiB6KV/0JetZITgcjjk5ZdaskBtWO86UF0ap6ozGXJk2WNiRUlCPFir66lzdm/SLSuK7EUdPz8f1z29Skq6F1fXg8+5UVR6bszncP4Tn4KUkkdJ8UFCY1zR1i8RmL/qQL3rlei4THG7OODlnKko4oI01kd3CaM08Ia18kC3GNoVaO9iDh+hWxSyTXFABXoau7Q6q9OxYg/OVEMw6jdbtSrJ9cBcewGmaZmg+bvkUnUUaGr+ZfnMH45Ivevl61hMcXsxYLFTu1hTm2zViCp7u0o5l+2PSUh9bDj6FgYypufBDhqK2+oXkiuHFHR3zfj+9PtA8oR0xnqX8qn+sx3bFODSbbF0X8EUvWQ8jBIcjo5bRmLOljDNtcqNtOe756h3l0VhKa9hDd2l1eqmsnh0MNMT/Cqnx6BInumhLT8luljzQ53RiJeA/0dxe5NK0o2fA1+GLXr6eNQWHNUOJssQaTRlGpLHKL9fD+IrQzTOMZS9fNQD4AnRNVxvTdjC+fJdcDDWQcyB00B0t9BDwTxXgaAfzDZ/DBXzRnfWMFRwuNqocOmX6OKNkY63h5n/fFcB28McVHqnXZVI27K0i4rDLNE9lDKV/rT+udVbD8dFFu2GGZ8mOt0kAXcoX3ZkIWVtw+MNf5NjR2FbivROHmhV1/pj2egv/fMGIOWTIWrV3Av8N9imV9IWml36H6cUjqEWNv9aNc+veb2sH46PRaHSuMBxvtW+twxctq0z+QsHhux8Q7rCY4Ct8lqsx7c6Sy0dl5T89rIeEuZKoVctIk1hNpfavER6yyH1Vvm3MbsUHy4ab4hWr/OZPcsRBphnaV65/ZcdYPNNwsjN/djlf9NqCw9U5ExCPcdhKxUgLSmfROpLp4WSUr8ojdwbncbvCf+a/YzRaEc6QOvXcGO256TXc5Lab9POvB+AWY7PigWYjzhifbovuunzRawsO24ZqQQAqguBtmpmPB7ysXJfyDDaV/aPGillgz1MdQg4u5MYaEtBNNHFjkRlSpd65lp4hd2AVPTfbV7FGpyIOfmNc/XVsPfg7vzaS/3nkvLL593ANLvMuRMGpQIhiF7kUEW9QDpAUbTWYBcbp4WpacHHY1aacqQyjGZS9HI3yCBT9kUZJhVOD+zUDvEH9ddR11fzPcTDQ5TlgB0KwqdXSavk9BC0pKp0WmcuowSw07VXmXC5guzSa4p0UvRw2lbDiYUx0ExJJRzWzi6Gm8cnEkfXXsdcG/M/jAJa0+bmCgdmQ9CYlNlSYZOKixmRsgiFxkrmW4l3KdFKv1DM8tk6WxPYJZhUUzcd8Kdtgrw/gkfXXDT7+avmfVak32qhtkg6NVdUS5wgkru1YzIkSduTW1FDwVWV3JQVJVuieTc0y4iDpFwc7/BvSalvKdQM8sv662cevz/+8sQVnjVAT0W2wLllw1JiMhJRxgDjCjLQsOzSFSgZqx7lAW1JW0e03yAD3asC+GD3NbQhbe+mN5GXH1F83KDOM4n/e5JIuH4NpdQARrFPBVptUNcjj4cVMcFSRTE2NpR1LEYbYMmfWpXgP9KejaPsLUhuvLCsVXznAG9dfx9SR1ud/3hZdCLHb1GMdPqRJgqDmm76mHbvOXDtiO2QPUcKo/TWkQ0i2JFXpBoo7vij1i1Lp3ADAo+qvG3V0rM//vFnnTE4hxd5Ka/Cor5YEdsLVJyKtDgVoHgtW11pWSjolPNMnrlrVj9Fv2Qn60twMwKPqr+N/wvr8z5tZcDsDrv06tkqyzESM85Ycv6XBWA2birlNCXrI6VbD2lx2L0vQO0QVTVVLH4SE67fgsfVXv8n7sz7/85Z7cMtbE6f088wSaR4kCkCm10s6pKbJhfqiUNGLq+0gLWC6eUAZFPnLjwqtKd8EwGvWX59t7iPW4X/eAN1svgRVSY990YZg06BD1ohLMtyFTI4pKTJsS9xREq9EOaPWiO2gpms7397x6nQJkbh+Fz2q/rqRROX6/M8bJrqlVW4l6JEptKeUFuMYUbtCQ7CIttpGc6MY93x1r1vgAnRXvY5cvwWPqb9uWQm+lP95QxdNMeWhOq1x0Db55C7GcUv2ZUuN6n8iKzsvOxibC//Yfs9Na8r2Rlz02vXXDT57FP/zJi66/EJSmsJKa8QxnoqW3VLQ+jZVUtJwJ8PNX1NQCwfNgdhhHD9on7PdRdrdGPF28rJr1F+3LBdeyv+8yYfLoMYet1vX4upNAjVvwOUWnlNXJXlkzk5Il6kqeoiL0C07qno+/CYBXq/+utlnsz7/Mzvy0tmI4zm4ag23PRN3t/CWryoUVJGm+5+K8RJ0V8Hc88/XHUX/HfiAq7t+BH+x6v8t438enWmdJwFA6ZINriLGKv/95f8lT9/FnyA1NMVEvQyaXuu+gz36f/DD73E4pwqpLcvm/o0Vle78n//+L/NPvoefp1pTJye6e4A/D082FERa5/opeH9zpvh13cNm19/4v/LDe5xMWTi8I0Ta0qKlK27AS/v3/r+/x/2GO9K2c7kVMonDpq7//jc5PKCxeNPpFVzaRr01wF8C4Pu76hXuX18H4LduTr79guuFD3n5BHfI+ZRFhY8w29TYhbbLi/bvBdqKE4fUgg1pBKnV3FEaCWOWyA+m3WpORZr/j+9TKJtW8yBTF2/ZEODI9/QavHkVdGFp/Pjn4Q+u5hXapsP5sOH+OXXA1LiKuqJxiMNbhTkbdJTCy4llEt6NnqRT4dhg1V3nbdrm6dYMecA1yTOL4PWTE9L5VzPFlLBCvlG58AhehnN4uHsAYinyJ+AZ/NkVvELbfOBUuOO5syBIEtiqHU1k9XeISX5bsimrkUUhnGDxourN8SgUsCZVtKyGbyGzHXdjOhsAvOAswSRyIBddRdEZWP6GZhNK/yjwew9ehBo+3jEADu7Ay2n8mDc+TS7awUHg0OMzR0LABhqLD4hJEh/BEGyBdGlSJoXYXtr+3HS4ijzVpgi0paWXtdruGTknXBz+11qT1Q2inxaTzQCO46P3lfLpyS4fou2PH/PupwZgCxNhGlj4IvUuWEsTkqMWm6i4xCSMc9N1RDQoCVcuGItJ/MRWefais+3synowi/dESgJjkilnWnBTGvRWmaw8oR15257t7CHmCf8HOn7cwI8+NQBXMBEmAa8PMRemrNCEhLGEhDQKcGZWS319BX9PFBEwGTbRBhLbDcaV3drFcDqk5kCTd2JF1Wp0HraqBx8U0wwBTnbpCadwBA/gTH/CDrcCs93LV8E0YlmmcyQRQnjBa8JESmGUfIjK/7fkaDJpmD2QptFNVJU1bbtIAjjWQizepOKptRjbzR9Kag6xZmMLLjHOtcLT3Tx9o/0EcTT1XN3E45u24AiwEypDJXihKjQxjLprEwcmRKclaDNZCVqr/V8mYWyFADbusiY5hvgFoU2vio49RgJLn5OsReRFN6tabeetiiy0V7KFHT3HyZLx491u95sn4K1QQSPKM9hNT0wMVvAWbzDSVdrKw4zRjZMyJIHkfq1VAVCDl/bUhNKlGq0zGr05+YAceXVPCttVk0oqjVwMPt+BBefx4yPtGVkUsqY3CHDPiCM5ngupUwCdbkpd8kbPrCWHhkmtIKLEetF2499eS1jZlIPGYnlcPXeM2KD9vLS0bW3ktYNqUllpKLn5ZrsxlIzxvDu5eHxzGLctkZLEY4PgSOg2IUVVcUONzUDBEpRaMoXNmUc0tFZrTZquiLyKxrSm3DvIW9Fil+AkhXu5PhEPx9mUNwqypDvZWdKlhIJQY7vn2OsnmBeOWnYZ0m1iwbbw1U60by5om47iHRV6fOgzjMf/DAZrlP40Z7syxpLK0lJ0gqaAK1c2KQKu7tabTXkLFz0sCftuwX++MyNeNn68k5Buq23YQhUh0SNTJa1ioQ0p4nUG2y0XilF1JqODqdImloPS4Bp111DEWT0jJjVv95uX9BBV7eB3bUWcu0acSVM23YZdd8R8UbQUxJ9wdu3oMuhdt929ME+mh6JXJ8di2RxbTi6TbrDquqV4aUKR2iwT6aZbyOwEXN3DUsWr8Hn4EhwNyHuXHh7/pdaUjtR7vnDh/d8c9xD/s5f501eQ1+CuDiCvGhk1AN/4Tf74RfxPwD3toLarR0zNtsnPzmS64KIRk861dMWCU8ArasG9T9H0ZBpsDGnjtAOM2+/LuIb2iIUGXNgl5ZmKD/Tw8TlaAuihaFP5yrw18v4x1898zIdP+DDAX1bM3GAMvPgRP/cJn3zCW013nrhHkrITyvYuwOUkcHuKlRSW5C6rzIdY4ppnF7J8aAJbQepgbJYBjCY9usGXDKQxq7RZfh9eg5d1UHMVATRaD/4BHK93/1iAgYZ/+jqPn8Dn4UExmWrpa3+ZOK6MvM3bjwfzxNWA2dhs8+51XHSPJiaAhGSpWevEs5xHLXcEGFXYiCONySH3fPWq93JIsBiSWvWyc3CAN+EcXoT7rCSANloPPoa31rt/5PUA/gp8Q/jDD3hyrjzlR8VkanfOvB1XPubt17vzxAfdSVbD1pzAnfgyF3ycadOTOTXhpEUoLC1HZyNGW3dtmjeXgr2r56JNmRwdNNWaQVBddd6rh4MhviEB9EFRD/7RGvePvCbwAL4Mx/D6M541hHO4D3e7g6PafdcZVw689z7NGTwo5om7A8sPhccT6qKcl9NJl9aM/9kX+e59Hh1yPqGuCCZxuITcsmNaJ5F7d0q6J3H48TO1/+M57085q2icdu2U+W36Ldllz9Agiv4YGljoEN908EzvDOrBF98/vtJwCC/BF2AG75xxEmjmMIcjxbjoaxqOK3/4hPOZzhMPBpYPG44CM0dTVm1LjLtUWWVz1Bcf8tEx0zs8O2A2YVHRxKYOiy/aOVoAaMu0i7ubu43njjmd4ibMHU1sIDHaQNKrZND/FZYdk54oCXetjq7E7IVl9eAL7t+oHnwXXtLx44czzoRFHBztYVwtH1d+NOMkupZ5MTM+gUmq90X+Bh9zjRlmaQ+m7YMqUL/veemcecAtOJ0yq1JnVlN27di2E0+Klp1tAJ4KRw1eMI7aJjsO3R8kPSI3fUFXnIOfdQe86sIIVtWDL7h//Ok6vj8vwDk08NEcI8zz7OhBy+WwalzZeZ4+0XniRfst9pAJqQHDGLzVQ2pheZnnv1OWhwO43/AgcvAEXEVVpa4db9sGvNK8wjaENHkfFQ4Ci5i7dqnQlPoLQrHXZDvO3BIXZbJOBrOaEbML6sFL798I4FhKihjHMsPjBUZYCMFr6nvaArxqXPn4lCa+cHfSa2cP27g3Z3ziYTRrcbQNGLQmGF3F3cBdzzzX7AILx0IB9rbwn9kx2G1FW3Inic+ZLIsVvKR8Zwfj0l1fkqo8LWY1M3IX14OX3r9RKTIO+d9XzAI8qRPGPn/4NC2n6o4rN8XJ82TOIvuVA8zLKUHRFgBCetlDZlqR1gLKjS39xoE7Bt8UvA6BxuEDjU3tFsEijgA+615tmZkXKqiEENrh41iLDDZNq4pKTWR3LZfnos81LOuNa15cD956vLMsJd1rqYp51gDUQqMYm2XsxnUhD2jg1DM7SeuJxxgrmpfISSXVIJIS5qJJSvJPEQ49DQTVIbYWJ9QWa/E2+c/oPK1drmC7WSfJRNKBO5Yjvcp7Gc3dmmI/Xh1kDTEuiSnWqQf37h+fTMhGnDf6dsS8SQfQWlqqwXXGlc/PEZ/SC5mtzIV0nAshlQdM/LvUtYutrEZ/Y+EAFtq1k28zQhOwLr1AIeANzhF8t9qzTdZf2qRKO6MWE9ohBYwibbOmrFtNmg3mcS+tB28xv2uKd/agYCvOP+GkSc+0lr7RXzyufL7QbkUpjLjEWFLqOIkAGu2B0tNlO9Eau2W1qcOUvVRgKzypKIQZ5KI3q0MLzqTNRYqiZOqmtqloIRlmkBHVpHmRYV6/HixbO6UC47KOFJnoMrVyr7wYz+SlW6GUaghYbY1I6kkxA2W1fSJokUdSh2LQ1GAimRGm0MT+uu57H5l7QgOWxERpO9moLRPgTtquWCfFlGlIjQaRly9odmzMOWY+IBO5tB4sW/0+VWGUh32qYk79EidWKrjWuiLpiVNGFWFRJVktyeXWmbgBBzVl8anPuXyNJlBJOlKLTgAbi/EYHVHxWiDaVR06GnHQNpJcWcK2jJtiCfG2sEHLzuI66sGrMK47nPIInPnu799935aOK2cvmvubrE38ZzZjrELCmXM2hM7UcpXD2oC3+ECVp7xtIuxptJ0jUr3sBmBS47TVxlvJ1Sqb/E0uLdvLj0lLr29ypdd/eMX3f6lrxGlKwKQxEGvw0qHbkbwrF3uHKwVENbIV2wZ13kNEF6zD+x24aLNMfDTCbDPnEikZFyTNttxWBXDaBuM8KtI2rmaMdUY7cXcUPstqTGvBGSrFWIpNMfbdea990bvAOC1YX0qbc6smDS1mPxSJoW4fwEXvjMmhlijDRq6qale6aJEuFGoppYDoBELQzLBuh/mZNx7jkinv0EtnUp50lO9hbNK57lZaMAWuWR5Yo9/kYwcYI0t4gWM47Umnl3YmpeBPqSyNp3K7s2DSAS/39KRuEN2bS4xvowV3dFRMx/VFcp2Yp8w2nTO9hCXtHG1kF1L4KlrJr2wKfyq77R7MKpFKzWlY9UkhYxyHWW6nBWPaudvEAl3CGcNpSXPZ6R9BbBtIl6cHL3gIBi+42CYXqCx1gfGWe7Ap0h3luyXdt1MKy4YUT9xSF01G16YEdWsouW9mgDHd3veyA97H+Ya47ZmEbqMY72oPztCGvK0onL44AvgC49saZKkWRz4veWljE1FHjbRJaWv6ZKKtl875h4CziFCZhG5rx7tefsl0aRT1bMHZjm8dwL/6u7wCRysaQblQoG5yAQN5zpatMNY/+yf8z+GLcH/Qn0iX2W2oEfXP4GvwQHuIL9AYGnaO3zqAX6946nkgqZNnUhx43DIdQtMFeOPrgy/y3Yd85HlJWwjLFkU3kFwq28xPnuPhMWeS+tDLV9Otllq7pQCf3uXJDN9wFDiUTgefHaiYbdfi3b3u8+iY6TnzhgehI1LTe8lcd7s1wJSzKbahCRxKKztTLXstGAiu3a6rPuQs5pk9TWAan5f0BZmGf7Ylxzzk/A7PAs4QPPPAHeFQ2hbFHszlgZuKZsJcUmbDC40sEU403cEjczstOEypa+YxevL4QBC8oRYqWdK6b7sK25tfE+oDZgtOQ2Jg8T41HGcBE6fTWHn4JtHcu9S7uYgU5KSCkl/mcnq+5/YBXOEr6lCUCwOTOM1taOI8mSxx1NsCXBEmLKbMAg5MkwbLmpBaFOPrNSlO2HnLiEqW3tHEwd8AeiQLmn+2gxjC3k6AxREqvKcJbTEzlpLiw4rNZK6oJdidbMMGX9FULKr0AkW+2qDEPBNNm5QAt2Ik2nftNWHetubosHLo2nG4vQA7GkcVCgVCgaDixHqo9UUn1A6OshapaNR/LPRYFV8siT1cCtJE0k/3WtaNSuUZYKPnsVIW0xXWnMUxq5+En4Kvw/MqQmVXnAXj9Z+9zM98zM/Agy7F/qqj2Nh67b8HjFnPP3iBn/tkpdzwEJX/whIcQUXOaikeliCRGUk7tiwF0rItwMEhjkZ309hikFoRAmLTpEXWuHS6y+am/KB/fM50aLEhGnSMwkpxzOov4H0AvgovwJ1iGzDLtJn/9BU+fAINfwUe6FHSLhu83viV/+/HrOePX+STT2B9uWGbrMHHLldRBlhS/CJQmcRxJFqZica01XixAZsYiH1uolZxLrR/SgxVIJjkpQP4PE9sE59LKLr7kltSBogS5tyszzH8Fvw8/AS8rNOg0xUS9fIaHwb+6et8Q/gyvKRjf5OusOzGx8evA/BP4IP11uN/grca5O0lcsPLJ5YjwI4QkJBOHa0WdMZYGxPbh2W2nR9v3WxEWqgp/G3+6VZbRLSAAZ3BhdhAaUL33VUSw9yjEsvbaQ9u4A/gGXwZXoEHOuU1GSj2chf+Mo+f8IcfcAxfIKVmyunRbYQVnoevwgfw3TXXcw++xNuP4fhyueEUNttEduRVaDttddoP0eSxLe2LENk6itYxlrxBNBYrNNKSQmeaLcm9c8UsaB5WyO6675yyQIAWSDpBVoA/gxmcwEvwoDv0m58UE7gHn+fJOa8/Ywan8EKRfjsopF83eCglX/Sfr7OeaRoQfvt1CGvIDccH5BCvw1sWIzRGC/66t0VTcLZQZtm6PlAasbOJ9iwWtUo7biktTSIPxnR24jxP1ZKaqq+2RcXM9OrBAm/AAs7hDJ5bNmGb+KIfwCs8a3jnjBrOFeMjHSCdbKr+2uOLfnOd9eiA8Hvvwwq54VbP2OqwkB48Ytc4YEOiH2vTXqodabfWEOzso4qxdbqD5L6tbtNPECqbhnA708DZH4QOJUXqScmUlks7Ot6FBuZw3n2mEbaUX7kDzxHOOQk8nKWMzAzu6ZZ8sOFw4RK+6PcuXo9tB4SbMz58ApfKDXf3szjNIIbGpD5TKTRxGkEMLjLl+K3wlWXBsCUxIDU+jbOiysESqAy1MGUJpXgwbTWzNOVEziIXZrJ+VIztl1PUBxTSo0dwn2bOmfDRPD3TRTGlfbCJvO9KvuhL1hMHhB9wPuPRLGHcdOWG2xc0U+5bQtAJT0nRTewXL1pgk2+rZAdeWmz3jxAqfNQQdzTlbF8uJ5ecEIWvTkevAHpwz7w78QujlD/Lr491bD8/1vhM2yrUQRrWXNQY4fGilfctMWYjL72UL/qS9eiA8EmN88nbNdour+PBbbAjOjIa4iBhfFg6rxeKdEGcL6p3EWR1Qq2Qkhs2DrnkRnmN9tG2EAqmgPw6hoL7Oza7B+3SCrR9tRftko+Lsf2F/mkTndN2LmzuMcKTuj/mX2+4Va3ki16+nnJY+S7MefpkidxwnV+4wkXH8TKnX0tsYzYp29DOOoSW1nf7nTh2akYiWmcJOuTidSaqESrTYpwjJJNVGQr+rLI7WsqerHW6Kp/oM2pKuV7T1QY9gjqlZp41/WfKpl56FV/0kvXQFRyeQ83xaTu5E8p5dNP3dUF34ihyI3GSpeCsywSh22ZJdWto9winhqifb7VRvgktxp13vyjrS0EjvrRfZ62uyqddSWaWYlwTPAtJZ2oZ3j/Sgi/mi+6vpzesfAcWNA0n8xVyw90GVFGuZjTXEQy+6GfLGLMLL523f5E0OmxVjDoOuRiH91RKU+vtoCtH7TgmvBLvtFXWLW15H9GTdVw8ow4IlRLeHECN9ym1e9K0I+Cbnhgv4Yu+aD2HaQJ80XDqOzSGAV4+4yCqBxrsJAX6ZTIoX36QnvzhhzzMfFW2dZVLOJfo0zbce5OvwXMFaZ81mOnlTVXpDZsQNuoYWveketKb5+6JOOsgX+NTm7H49fUTlx+WLuWL7qxnOFh4BxpmJx0p2gDzA/BUARuS6phR+pUsY7MMboAHx5xNsSVfVZcYSwqCKrqon7zM+8ecCkeS4nm3rINuaWvVNnMRI1IRpxTqx8PZUZ0Br/UEduo3B3hNvmgZfs9gQPj8vIOxd2kndir3awvJ6BLvoUuOfFWNYB0LR1OQJoUySKb9IlOBx74q1+ADC2G6rOdmFdJcD8BkfualA+BdjOOzP9uUhGUEX/TwhZsUduwRr8wNuXKurCixLBgpQI0mDbJr9dIqUuV+92ngkJZ7xduCk2yZKbfWrH1VBiTg9VdzsgRjW3CVXCvAwDd+c1z9dWw9+B+8MJL/eY15ZQ/HqvTwVdsZn5WQsgRRnMaWaecu3jFvMBEmgg+FJFZsnSl0zjB9OqPYaBD7qmoVyImFvzi41usesV0julaAR9dfR15Xzv9sEruRDyk1nb+QaLU67T885GTls6YgcY+UiMa25M/pwGrbCfzkvR3e0jjtuaFtnwuagHTSb5y7boBH119HXhvwP487jJLsLJ4XnUkHX5sLbS61dpiAXRoZSCrFJ+EjpeU3puVfitngYNo6PJrAigKktmwjyQdZpfq30mmtulaAx9Zfx15Xzv+cyeuiBFUs9zq8Kq+XB9a4PVvph3GV4E3y8HENJrN55H1X2p8VyqSKwVusJDKzXOZzplWdzBUFK9e+B4+uv468xvI/b5xtSAkBHQaPvtqWzllVvEOxPbuiE6+j2pvjcKsbvI7txnRErgfH7LdXqjq0IokKzga14GzQ23SSbCQvO6r+Or7SMIr/efOkkqSdMnj9mBx2DRsiY29Uj6+qK9ZrssCKaptR6HKURdwUYeUWA2kPzVKQO8ku2nU3Anhs/XWkBx3F/7wJtCTTTIKftthue1ty9xvNYLY/zo5KSbIuKbXpbEdSyeRyYdAIwKY2neyoc3+k1XUaufYga3T9daMUx/r8z1s10ITknIO0kuoMt+TB8jK0lpayqqjsJ2qtXAYwBU932zinimgmd6mTRDnQfr88q36NAI+tv24E8Pr8zxtasBqx0+xHH9HhlrwsxxNUfKOHQaZBITNf0uccj8GXiVmXAuPEAKSdN/4GLHhs/XWj92dN/uetNuBMnVR+XWDc25JLjo5Mg5IZIq226tmCsip2zZliL213YrTlL2hcFjpCduyim3M7/eB16q/blQsv5X/esDRbtJeabLIosWy3ycavwLhtxdWzbMmHiBTiVjJo6lCLjXZsi7p9PEPnsq6X6wd4bP11i0rD5fzPm/0A6brrIsllenZs0lCJlU4abakR59enZKrKe3BZihbTxlyZ2zl1+g0wvgmA166/bhwDrcn/7Ddz0eWZuJvfSESug6NzZsox3Z04FIxz0mUjMwVOOVTq1CQ0AhdbBGVdjG/CgsfUX7esJl3K/7ytWHRv683praW/8iDOCqWLLhpljDY1ZpzK75QiaZoOTpLKl60auHS/97oBXrv+umU9+FL+5+NtLFgjqVLCdbmj7pY5zPCPLOHNCwXGOcLquOhi8CmCWvbcuO73XmMUPab+ug3A6/A/78Bwe0bcS2+tgHn4J5pyS2WbOck0F51Vq3LcjhLvZ67p1ABbaL2H67bg78BfjKi/jr3+T/ABV3ilLmNXTI2SpvxWBtt6/Z//D0z/FXaGbSBgylzlsEGp+5//xrd4/ae4d8DUUjlslfIYS3t06HZpvfQtvv0N7AHWqtjP2pW08QD/FLy//da38vo8PNlKHf5y37Dxdfe/oj4kVIgFq3koLReSR76W/bx//n9k8jonZxzWTANVwEniDsg87sOSd/z7//PvMp3jQiptGVWFX2caezzAXwfgtzYUvbr0iozs32c3Uge7varH+CNE6cvEYmzbPZ9hMaYDdjK4V2iecf6EcEbdUDVUARda2KzO/JtCuDbNQB/iTeL0EG1JSO1jbXS+nLxtPMDPw1fh5+EPrgSEKE/8Gry5A73ui87AmxwdatyMEBCPNOCSKUeRZ2P6Myb5MRvgCHmA9ywsMifU+AYXcB6Xa5GibUC5TSyerxyh0j6QgLVpdyhfArRTTLqQjwe4HOD9s92D4Ap54odXAPBWLAwB02igG5Kkc+piN4lvODIFGAZgT+EO4Si1s7fjSR7vcQETUkRm9O+MXyo9OYhfe4xt9STQ2pcZRLayCV90b4D3jR0DYAfyxJ+eywg2IL7NTMXna7S/RpQ63JhWEM8U41ZyQGjwsVS0QBrEKLu8xwZsbi4wLcCT+OGidPIOCe1PiSc9Qt+go+vYqB7cG+B9d8cAD+WJPz0Am2gxXgU9IneOqDpAAXOsOltVuMzpdakJXrdPCzXiNVUpCeOos5cxnpQT39G+XVLhs1osQVvJKPZyNq8HDwd4d7pNDuWJPxVX7MSzqUDU6gfadKiNlUFTzLeFHHDlzO4kpa7aiKhBPGKwOqxsBAmYkOIpipyXcQSPlRTf+Tii0U3EJGaZsDER2qoB3h2hu0qe+NNwUooYU8y5mILbJe6OuX+2FTKy7bieTDAemaQyQ0CPthljSWO+xmFDIYiESjM5xKd6Ik5lvLq5GrQ3aCMLvmCA9wowLuWJb9xF59hVVP6O0CrBi3ZjZSNOvRy+I6klNVRJYRBaEzdN+imiUXQ8iVF8fsp+W4JXw7WISW7fDh7lptWkCwZ4d7QTXyBPfJMYK7SijjFppGnlIVJBJBYj7eUwtiP1IBXGI1XCsjNpbjENVpSAJ2hq2LTywEly3hUYazt31J8w2+aiLx3g3fohXixPfOMYm6zCGs9LVo9MoW3MCJE7R5u/WsOIjrqBoHUO0bJE9vxBpbhsd3+Nb4/vtPCZ4oZYCitNeYuC/8UDvDvy0qvkiW/cgqNqRyzqSZa/s0mqNGjtKOoTm14zZpUauiQgVfqtQiZjq7Q27JNaSK5ExRcrGCXO1FJYh6jR6CFqK7bZdQZ4t8g0rSlPfP1RdBtqaa9diqtzJkQ9duSryi2brQXbxDwbRUpFMBHjRj8+Nt7GDKgvph9okW7LX47gu0SpGnnFQ1S1lYldOsC7hYteR574ZuKs7Ei1lBsfdz7IZoxzzCVmmVqaSySzQbBVAWDek+N4jh9E/4VqZrJjPwiv9BC1XcvOWgO8275CVyBPvAtTVlDJfZkaZGU7NpqBogAj/xEHkeAuJihWYCxGN6e8+9JtSegFXF1TrhhLGP1fak3pebgPz192/8gB4d/6WT7+GdYnpH7hH/DJzzFiYPn/vjW0SgNpTNuPIZoAEZv8tlGw4+RLxy+ZjnKa5NdFoC7UaW0aduoYse6+bXg1DLg6UfRYwmhGEjqPvF75U558SANrElK/+MdpXvmqBpaXOa/MTZaa1DOcSiLaw9j0NNNst3c+63c7EKTpkvKHzu6bPbP0RkuHAVcbRY8ijP46MIbQeeT1mhA+5PV/inyDdQipf8LTvMXbwvoDy7IruDNVZKTfV4CTSRUYdybUCnGU7KUTDxLgCknqUm5aAW6/1p6eMsOYsphLzsHrE0Y/P5bQedx1F/4yPHnMB3/IOoTU9+BL8PhtjuFKBpZXnYNJxTuv+2XqolKR2UQgHhS5novuxVySJhBNRF3SoKK1XZbbXjVwWNyOjlqWJjrWJIy+P5bQedyldNScP+HZ61xKSK3jyrz+NiHG1hcOLL/+P+PDF2gOkekKGiNWKgJ+8Z/x8Iv4DdQHzcpZyF4v19I27w9/yPGDFQvmEpKtqv/TLiWMfn4sofMm9eAH8Ao0zzh7h4sJqYtxZd5/D7hkYPneDzl5idlzNHcIB0jVlQ+8ULzw/nc5/ojzl2juE0apD7LRnJxe04dMz2iOCFNtGFpTuXA5AhcTRo8mdN4kz30nVjEC4YTZQy4gpC7GlTlrePKhGsKKgeXpCYeO0MAd/GH7yKQUlXPLOasOH3FnSphjHuDvEu4gB8g66oNbtr6eMbFIA4fIBJkgayoXriw2XEDQPJrQeROAlY6aeYOcMf+IVYTU3XFlZufMHinGywaW3YLpObVBAsbjF4QJMsVUSayjk4voPsHJOQfPWDhCgDnmDl6XIRerD24HsGtw86RMHOLvVSHrKBdeVE26gKB5NKHzaIwLOmrqBWJYZDLhASG16c0Tn+CdRhWDgWXnqRZUTnPIHuMJTfLVpkoYy5CzylHVTGZMTwkGAo2HBlkQplrJX6U+uF1wZz2uwS1SQ12IqWaPuO4baZaEFBdukksJmkcTOm+YJSvoqPFzxFA/YUhIvWxcmSdPWTWwbAKVp6rxTtPFUZfKIwpzm4IoMfaYQLWgmlG5FME2gdBgm+J7J+rtS/XBbaVLsR7bpPQnpMFlo2doWaVceHk9+MkyguZNCJ1He+kuHTWyQAzNM5YSUg/GlTk9ZunAsg1qELVOhUSAK0LABIJHLKbqaEbHZLL1VA3VgqoiOKXYiS+HRyaEKgsfIqX64HYWbLRXy/qWoylIV9gudL1OWBNgBgTNmxA6b4txDT4gi3Ri7xFSLxtXpmmYnzAcWDZgY8d503LFogz5sbonDgkKcxGsWsE1OI+rcQtlgBBCSOKD1mtqYpIU8cTvBmAT0yZe+zUzeY92fYjTtGipXLhuR0ePoHk0ofNWBX+lo8Z7pAZDk8mEw5L7dVyZZoE/pTewbI6SNbiAL5xeygW4xPRuLCGbhcO4RIeTMFYHEJkYyEO9HmJfXMDEj/LaH781wHHZEtqSQ/69UnGpzH7LKIAZEDSPJnTesJTUa+rwTepI9dLJEawYV+ZkRn9g+QirD8vF8Mq0jFQ29js6kCS3E1+jZIhgPNanHdHFqFvPJLHqFwQqbIA4jhDxcNsOCCQLDomaL/dr5lyJaJU6FxPFjO3JOh3kVMcROo8u+C+jo05GjMF3P3/FuDLn5x2M04xXULPwaS6hBYki+MrMdZJSgPHlcB7nCR5bJ9Kr5ACUn9jk5kivdd8tk95SOGrtqu9lr2IhK65ZtEl7ZKrp7DrqwZfRUSN1el7+7NJxZbywOC8neNKTch5vsTEMNsoCCqHBCqIPRjIPkm0BjvFODGtto99rCl+d3wmHkW0FPdpZtC7MMcVtGFQjJLX5bdQ2+x9ypdc313uj8xlsrfuLgWXz1cRhZvJYX0iNVBRcVcmCXZs6aEf3RQF2WI/TcCbKmGU3IOoDJGDdDub0+hYckt6PlGu2BcxmhbTdj/klhccLGJMcqRjMJP1jW2ETqLSWJ/29MAoORluJ+6LPffBZbi5gqi5h6catQpmOT7/OFf5UorRpLzCqcMltBLhwd1are3kztrSzXO0LUbXRQcdLh/RdSZ+swRm819REDrtqzC4es6Gw4JCKlSnjYVpo0xeq33PrADbFLL3RuCmObVmPN+24kfa+AojDuM4umKe2QwCf6EN906HwjujaitDs5o0s1y+k3lgbT2W2i7FJdnwbLXhJUBq/9liTctSmFC/0OqUinb0QddTWamtjbHRFuWJJ6NpqZ8vO3fZJ37Db+2GkaPYLGHs7XTTdiFQJ68SkVJFVmY6McR5UycflNCsccHFaV9FNbR4NttLxw4pQ7wJd066Z0ohVbzihaxHVExd/ay04oxUKWt+AsdiQ9OUyZ2krzN19IZIwafSTFgIBnMV73ADj7V/K8u1MaY2sJp2HWm0f41tqwajEvdHWOJs510MaAqN4aoSiPCXtN2KSi46dUxHdaMquar82O1x5jqhDGvqmoE9LfxcY3zqA7/x3HA67r9ZG4O6Cuxu12/+TP+eLP+I+HErqDDCDVmBDO4larujNe7x8om2rMug0MX0rL1+IWwdwfR+p1TNTyNmVJ85ljWzbWuGv8/C7HD/izjkHNZNYlhZcUOKVzKFUxsxxN/kax+8zPWPSFKw80rJr9Tizyj3o1gEsdwgWGoxPezDdZ1TSENE1dLdNvuKL+I84nxKesZgxXVA1VA1OcL49dFlpFV5yJMhzyCmNQ+a4BqusPJ2bB+xo8V9u3x48VVIEPS/mc3DvAbXyoYr6VgDfh5do5hhHOCXMqBZUPhWYbWZECwVJljLgMUWOCB4MUuMaxGNUQDVI50TQ+S3kFgIcu2qKkNSHVoM0SHsgoZxP2d5HH8B9woOk4x5bPkKtAHucZsdykjxuIpbUrSILgrT8G7G5oCW+K0990o7E3T6AdW4TilH5kDjds+H64kS0mz24grtwlzDHBJqI8YJQExotPvoC4JBq0lEjjQkyBZ8oH2LnRsQ4Hu1QsgDTJbO8fQDnllitkxuVskoiKbRF9VwzMDvxHAdwB7mD9yCplhHFEyUWHx3WtwCbSMMTCUCcEmSGlg4gTXkHpZXWQ7kpznK3EmCHiXInqndkQjunG5kxTKEeGye7jWz9cyMR2mGiFQ15ENRBTbCp+Gh86vAyASdgmJq2MC6hoADQ3GosP0QHbnMHjyBQvQqfhy/BUbeHd5WY/G/9LK/8Ka8Jd7UFeNWEZvzPb458Dn8DGLOe3/wGL/4xP+HXlRt+M1PE2iLhR8t+lfgxsuh7AfO2AOf+owWhSZRYQbd622hbpKWKuU+XuvNzP0OseRDa+mObgDHJUSc/pKx31QdKffQ5OIJpt8GWjlgTwMc/w5MPCR/yl1XC2a2Yut54SvOtMev55Of45BOat9aWG27p2ZVORRvnEk1hqWMVUmqa7S2YtvlIpspuF1pt0syuZS2NV14mUidCSfzQzg+KqvIYCMljIx2YK2AO34fX4GWdu5xcIAb8MzTw+j/lyWM+Dw/gjs4GD6ehNgA48kX/AI7XXM/XAN4WHr+9ntywqoCakCqmKP0rmQrJJEErG2Upg1JObr01lKQy4jskWalKYfJ/EDLMpjNSHFEUAde2fltaDgmrNaWQ9+AAb8I5vKjz3L1n1LriB/BXkG/wwR9y/oRX4LlioHA4LzP2inzRx/DWmutRweFjeP3tNeSGlaE1Fde0OS11yOpmbIp2u/jF1n2RRZviJM0yBT3IZl2HWImKjQOxIyeU325b/qWyU9Moj1o07tS0G7qJDoGHg5m8yeCxMoEH8GU45tnrNM84D2l297DQ9t1YP7jki/7RmutRweEA77/HWXOh3HCxkRgldDQkAjNTMl2Iloc1qN5JfJeeTlyTRzxURTdn1Ixv2uKjs12AbdEWlBtmVdk2k7FFwj07PCZ9XAwW3dG+8xKzNFr4EnwBZpy9Qzhh3jDXebBpYcpuo4fQ44u+fD1dweEnHzI7v0xuuOALRUV8rXpFyfSTQYkhd7IHm07jpyhlkCmI0ALYqPTpUxXS+z4jgDj1Pflvmz5ecuItpIBxyTHpSTGWd9g1ApfD/bvwUhL4nT1EzqgX7cxfCcNmb3mPL/qi9SwTHJ49oj5ZLjccbTG3pRmlYi6JCG0mQrAt1+i2UXTZ2dv9IlQpN5naMYtviaXlTrFpoMsl3bOAFEa8sqPj2WCMrx3Yjx99qFwO59Aw/wgx+HlqNz8oZvA3exRDvuhL1jMQHPaOJ0+XyA3fp1OfM3qObEVdhxjvynxNMXQV4+GJyvOEFqeQBaIbbO7i63rpxCltdZShPFxkjM2FPVkn3TG+Rp9pO3l2RzFegGfxGDHIAh8SteR0C4HopXzRF61nheDw6TFN05Ebvq8M3VKKpGjjO6r7nhudTEGMtYM92HTDaR1FDMXJ1eThsbKfywyoWwrzRSXkc51flG3vIid62h29bIcFbTGhfV+faaB+ohj7dPN0C2e2lC96+XouFByen9AsunLDJZ9z7NExiUc0OuoYW6UZkIyx2YUR2z6/TiRjyKMx5GbbjLHvHuf7YmtKghf34LJfx63Yg8vrvN2zC7lY0x0tvKezo4HmGYDU+Gab6dFL+KI761lDcNifcjLrrr9LWZJctG1FfU1uwhoQE22ObjdfkSzY63CbU5hzs21WeTddH2BaL11Gi7lVdlxP1nkxqhnKhVY6knS3EPgVGg1JpN5cP/hivujOelhXcPj8HC/LyI6MkteVjlolBdMmF3a3DbsuAYhL44dxzthWSN065xxUd55Lmf0wRbOYOqH09/o9WbO2VtFdaMb4qBgtFJoT1SqoN8wPXMoXLb3p1PUEhxfnnLzGzBI0Ku7FxrKsNJj/8bn/H8fPIVOd3rfrklUB/DOeO+nkghgSPzrlPxluCMtOnDL4Yml6dK1r3vsgMxgtPOrMFUZbEUbTdIzii5beq72G4PD0DKnwjmBULUVFmy8t+k7fZ3pKc0Q4UC6jpVRqS9Umv8bxw35flZVOU1X7qkjnhZlsMbk24qQ6Hz7QcuL6sDC0iHHki96Uh2UdvmgZnjIvExy2TeJdMDZNSbdZyAHe/Yd1xsQhHiKzjh7GxQ4yqMPaywPkjMamvqrYpmO7Knad+ZQC5msCuAPWUoxrxVhrGv7a+KLXFhyONdTMrZ7ke23qiO40ZJUyzgYyX5XyL0mV7NiUzEs9mjtbMN0dERqwyAJpigad0B3/zRV7s4PIfXSu6YV/MK7+OrYe/JvfGMn/PHJe2fyUdtnFrKRNpXV0Y2559aWPt/G4BlvjTMtXlVIWCnNyA3YQBDmYIodFz41PvXPSa6rq9lWZawZ4dP115HXV/M/tnFkkrBOdzg6aP4pID+MZnTJ1SuuB6iZlyiox4HT2y3YBtkUKWooacBQUDTpjwaDt5poBHl1/HXltwP887lKKXxNUEyPqpGTyA699UqY/lt9yGdlUKra0fFWS+36iylVWrAyd7Uw0CZM0z7xKTOduznLIjG2Hx8cDPLb+OvK6Bv7n1DYci4CxUuRxrjBc0bb4vD3rN5Zz36ntLb83eVJIB8LiIzCmn6SMPjlX+yNlTjvIGjs+QzHPf60Aj62/jrzG8j9vYMFtm1VoRWCJdmw7z9N0t+c8cxZpPeK4aTRicS25QhrVtUp7U578chk4q04Wx4YoQSjFryUlpcQ1AbxZ/XVMknIU//OGl7Q6z9Zpxi0+3yFhSkjUDpnCIUhLWVX23KQ+L9vKvFKI0ZWFQgkDLvBoylrHNVmaw10zwCPrr5tlodfnf94EWnQ0lFRWy8pW9LbkLsyUVDc2NSTHGDtnD1uMtchjbCeb1mpxFP0YbcClhzdLu6lfO8Bj6q+bdT2sz/+8SZCV7VIxtt0DUn9L7r4cLYWDSXnseEpOGFuty0qbOVlS7NNzs5FOGJUqQpl2Q64/yBpZf90sxbE+//PGdZ02HSipCbmD6NItmQ4Lk5XUrGpDMkhbMm2ZVheNYV+VbUWTcv99+2NyX1VoafSuC+AN6q9bFIMv5X/eagNWXZxEa9JjlMwNWb00akGUkSoepp1/yRuuqHGbUn3UdBSTxBU6SEVklzWRUkPndVvw2PrrpjvxOvzPmwHc0hpmq82npi7GRro8dXp0KXnUQmhZbRL7NEVp1uuZmO45vuzKsHrktS3GLWXODVjw+vXXLYx4Hf7njRPd0i3aoAGX6W29GnaV5YdyDj9TFkakje7GHYzDoObfddHtOSpoi2SmzJHrB3hM/XUDDEbxP2/oosszcRlehWXUvzHv4TpBVktHqwenFo8uLVmy4DKLa5d3RtLrmrM3aMFr1183E4sewf+85VWeg1c5ag276NZrM9IJVNcmLEvDNaV62aq+14IAOGFsBt973Ra8Xv11YzXwNfmft7Jg2oS+XOyoC8/cwzi66Dhmgk38kUmP1CUiYWOX1bpD2zWXt2FCp7uq8703APAa9dfNdscR/M/bZLIyouVxqJfeWvG9Je+JVckHQ9+CI9NWxz+blX/KYYvO5n2tAP/vrlZ7+8/h9y+9qeB/Hnt967e5mevX10rALDWK//FaAT5MXdBXdP0C/BAes792c40H+AiAp1e1oH8HgH94g/Lttx1gp63op1eyoM/Bvw5/G/7xFbqJPcCXnmBiwDPb/YKO4FX4OjyCb289db2/Noqicw4i7N6TVtoz8tNwDH+8x/i6Ae7lmaQVENzJFb3Di/BFeAwz+Is9SjeQySpPqbLFlNmyz47z5a/AF+AYFvDmHqibSXTEzoT4Gc3OALaqAP4KPFUJ6n+1x+rGAM6Zd78bgJ0a8QN4GU614vxwD9e1Amy6CcskNrczLx1JIp6HE5UZD/DBHrFr2oNlgG4Odv226BodoryjGJ9q2T/AR3vQrsOCS0ctXZi3ruLlhpFDJYl4HmYtjQCP9rhdn4suySLKDt6wLcC52h8xPlcjju1fn+yhuw4LZsAGUuo2b4Fx2UwQu77uqRHXGtg92aN3tQCbFexc0uk93vhTXbct6y7MulLycoUljx8ngDMBg1tvJjAazpEmOtxlzclvj1vQf1Tx7QlPDpGpqgtdSKz/d9/hdy1vTfFHSmC9dGDZbLiezz7Ac801HirGZsWjydfZyPvHXL/Y8Mjzg8BxTZiuwKz4Eb8sBE9zznszmjvFwHKPIWUnwhqfVRcd4Ck0K6ate48m1oOfrX3/yOtvAsJ8zsPAM89sjnddmuLuDPjX9Bu/L7x7xpMzFk6nWtyQfPg278Gn4Aekz2ZgOmU9eJ37R14vwE/BL8G3aibCiWMWWDQ0ZtkPMnlcGeAu/Ag+8ZyecU5BPuy2ILD+sQqyZhAKmn7XZd+jIMTN9eBL7x95xVLSX4On8EcNlXDqmBlqS13jG4LpmGbkF/0CnOi3H8ETOIXzmnmtb0a16Tzxj1sUvQCBiXZGDtmB3KAefPH94xcUa/6vwRn80GOFyjEXFpba4A1e8KQfFF+259tx5XS4egYn8fQsLGrqGrHbztr+uByTahWuL1NUGbDpsnrwBfePPwHHIf9X4RnM4Z2ABWdxUBlqQ2PwhuDxoS0vvqB1JzS0P4h2nA/QgTrsJFn+Y3AOjs9JFC07CGWX1oNX3T/yHOzgDjwPn1PM3g9Jk9lZrMEpxnlPmBbjyo2+KFXRU52TJM/2ALcY57RUzjObbjqxVw++4P6RAOf58pcVsw9Daje3htriYrpDOonre3CudSe6bfkTEgHBHuDiyu5MCsc7BHhYDx7ePxLjqigXZsw+ijMHFhuwBmtoTPtOxOrTvYJDnC75dnUbhfwu/ZW9AgYd+peL68HD+0emKquiXHhWjJg/UrkJYzuiaL3E9aI/ytrCvAd4GcYZMCkSQxfUg3v3j8c4e90j5ZTPdvmJJGHnOCI2nHS8081X013pHuBlV1gB2MX1YNmWLHqqGN/TWmG0y6clJWthxNUl48q38Bi8vtMKyzzpFdSDhxZ5WBA5ZLt8Jv3895DduBlgbPYAj8C4B8hO68FDkoh5lydC4FiWvBOVqjYdqjiLv92t8yPDjrDaiHdUD15qkSURSGmXJwOMSxWAXYwr3zaAufJ66l+94vv3AO+vPcD7aw/w/toDvL/2AO+vPcD7aw/wHuD9tQd4f+0B3l97gPfXHuD9tQd4f+0B3l97gG8LwP8G/AL8O/A5OCq0Ys2KIdv/qOIXG/4mvFAMF16gZD+2Xvu/B8as5+8bfllWyg0zaNO5bfXj6vfhhwD86/Aq3NfRS9t9WPnhfnvCIw/CT8GLcFTMnpntdF/z9V+PWc/vWoIH+FL3Znv57PitcdGP4R/C34avw5fgRVUInCwbsn1yyA8C8zm/BH8NXoXnVE6wVPjdeCI38kX/3+Ct9dbz1pTmHFRu+Hm4O9Ch3clr99negxfwj+ER/DR8EV6B5+DuQOnTgUw5rnkY+FbNU3gNXh0o/JYTuWOvyBf9FvzX663HH/HejO8LwAl8Hl5YLTd8q7sqA3wbjuExfAFegQdwfyDoSkWY8swzEf6o4Qyewefg+cHNbqMQruSL/u/WWc+E5g7vnnEXgDmcDeSGb/F4cBcCgT+GGRzDU3hZYburAt9TEtHgbM6JoxJ+6NMzzTcf6c2bycv2+KK/f+l6LBzw5IwfqZJhA3M472pWT/ajKxnjv4AFnMEpnBTPND6s2J7qHbPAqcMK74T2mZ4VGB9uJA465It+/eL1WKhYOD7xHOkr1ajK7d0C4+ke4Hy9qXZwpgLr+Znm/uNFw8xQOSy8H9IzjUrd9+BIfenYaylf9FsXr8fBAadnPIEDna8IBcwlxnuA0/Wv6GAWPd7dDIKjMdSWueAsBj4M7TOd06qBbwDwKr7oleuxMOEcTuEZTHWvDYUO7aHqAe0Bbq+HEFRzOz7WVoTDQkVds7A4sIIxfCQdCefFRoIOF/NFL1mPab/nvOakSL/Q1aFtNpUb/nFOVX6gzyg/1nISyDfUhsokIzaBR9Kxm80s5mK+6P56il1jXic7nhQxsxSm3OwBHl4fFdLqi64nDQZvqE2at7cWAp/IVvrN6/BFL1mPhYrGMBfOi4PyjuSGf6wBBh7p/FZTghCNWGgMzlBbrNJoPJX2mW5mwZfyRffXo7OFi5pZcS4qZUrlViptrXtw+GQoyhDPS+ANjcGBNRiLCQDPZPMHuiZfdFpPSTcQwwKYdRNqpkjm7AFeeT0pJzALgo7g8YYGrMHS0iocy+YTm2vyRUvvpXCIpQ5pe666TJrcygnScUf/p0NDs/iAI/nqDHC8TmQT8x3NF91l76oDdQGwu61Z6E0ABv7uO1dbf/37Zlv+Zw/Pbh8f1s4Avur6657/+YYBvur6657/+YYBvur6657/+YYBvur6657/+aYBvuL6657/+VMA8FXWX/f8zzcN8BXXX/f8zzcNMFdbf93zP38KLPiK6697/uebtuArrr/u+Z9vGmCusP6653/+1FjwVdZf9/zPN7oHX339dc//fNMu+irrr3v+50+Bi+Zq6697/uebA/jz8Pudf9ht/fWv517J/XUzAP8C/BAeX9WCDrUpZ3/dEMBxgPcfbtTVvsYV5Yn32u03B3Ac4P3b8I+vxNBKeeL9dRMAlwO83959qGO78sT769oB7g3w/vGVYFzKE++v6wV4OMD7F7tckFkmT7y/rhHgpQO8b+4Y46XyxPvrugBeNcB7BRiX8sT767oAvmCA9woAHsoT76+rBJjLBnh3txOvkifeX1dswZcO8G6N7sXyxPvr6i340gHe3TnqVfLE++uKAb50gHcXLnrX8sR7gNdPRqwzwLu7Y/FO5Yn3AK9jXCMGeHdgxDuVJ75VAI8ljP7PAb3/RfjcZfePHBB+79dpfpH1CanN30d+mT1h9GqAxxJGM5LQeeQ1+Tb+EQJrElLb38VHQ94TRq900aMIo8cSOo+8Dp8QfsB8zpqE1NO3OI9Zrj1h9EV78PqE0WMJnUdeU6E+Jjyk/hbrEFIfeWbvId8H9oTRFwdZaxJGvziW0Hn0gqYB/wyZ0PwRlxJST+BOw9m77Amj14ii1yGM/txYQudN0qDzGe4EqfA/5GJCagsHcPaEPWH0esekSwmjRxM6b5JEcZ4ww50ilvAOFxBSx4yLW+A/YU8YvfY5+ALC6NGEzhtmyZoFZoarwBLeZxUhtY4rc3bKnjB6TKJjFUHzJoTOozF2YBpsjcyxDgzhQ1YRUse8+J4wenwmaylB82hC5w0zoRXUNXaRBmSMQUqiWSWkLsaVqc/ZE0aPTFUuJWgeTei8SfLZQeMxNaZSIzbII4aE1Nmr13P2hNHjc9E9guYNCZ032YlNwESMLcZiLQHkE4aE1BFg0yAR4z1h9AiAGRA0jyZ03tyIxWMajMPWBIsxYJCnlITU5ShiHYdZ94TR4wCmSxg9jtB5KyPGYzymAYexWEMwAPIsAdYdV6aObmNPGD0aYLoEzaMJnTc0Ygs+YDw0GAtqxBjkuP38bMRWCHn73xNGjz75P73WenCEJnhwyVe3AEe8TtKdJcYhBl97wuhNAObK66lvD/9J9NS75v17wuitAN5fe4D31x7g/bUHeH/tAd5fe4D3AO+vPcD7aw/w/toDvL/2AO+vPcD7aw/w/toDvAd4f/24ABzZ8o+KLsSLS+Pv/TqTb3P4hKlQrTGh+fbIBT0Axqznnb+L/V2mb3HkN5Mb/nEHeK7d4IcDld6lmDW/iH9E+AH1MdOw/Jlu2T1xNmY98sv4wHnD7D3uNHu54WUuOsBTbQuvBsPT/UfzNxGYzwkP8c+Yz3C+r/i6DcyRL/rZ+utRwWH5PmfvcvYEt9jLDS/bg0/B64DWKrQM8AL8FPwS9beQCe6EMKNZYJol37jBMy35otdaz0Bw2H/C2Smc7+WGB0HWDELBmOByA3r5QONo4V+DpzR/hFS4U8wMW1PXNB4TOqYz9urxRV++ntWCw/U59Ty9ebdWbrgfRS9AYKKN63ZokZVygr8GZ/gfIhZXIXPsAlNjPOLBby5c1eOLvmQ9lwkOy5x6QV1j5TYqpS05JtUgUHUp5toHGsVfn4NX4RnMCe+AxTpwmApTYxqMxwfCeJGjpXzRF61nbcHhUBPqWze9svwcHJ+S6NPscKrEjug78Dx8Lj3T8D4YxGIdxmJcwhi34fzZUr7olevZCw5vkOhoClq5zBPZAnygD/Tl9EzDh6kl3VhsHYcDEb+hCtJSvuiV69kLDm+WycrOTArHmB5/VYyP6jOVjwgGawk2zQOaTcc1L+aLXrKeveDwZqlKrw8U9Y1p66uK8dEzdYwBeUQAY7DbyYNezBfdWQ97weEtAKYQg2xJIkuveAT3dYeLGH+ShrWNwZgN0b2YL7qznr3g8JYAo5bQBziPjx7BPZ0d9RCQp4UZbnFdzBddor4XHN4KYMrB2qHFRIzzcLAHQZ5the5ovui94PCWAPefaYnxIdzRwdHCbuR4B+tbiy96Lzi8E4D7z7S0mEPd+eqO3cT53Z0Y8SV80XvB4Z0ADJi/f7X113f+7p7/+UYBvur6657/+YYBvur6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+VMA8FXWX/f8z58OgK+y/rrnf75RgLna+uue//lTA/CV1V/3/M837aKvvv6653++UQvmauuve/7nTwfAV1N/3fM/fzr24Cuuv+75nz8FFnxl9dc9//MOr/8/glixwRuUfM4AAAAASUVORK5CYII="}function TOe(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII="}var gte=` +precision mediump float; +precision mediump samplerCube; +precision mediump sampler2D; + +#if defined(dVariant_skybox) + uniform samplerCube tSkybox; + uniform mat4 uViewDirectionProjectionInverse; + uniform float uBlur; + uniform float uOpacity; + uniform float uSaturation; + uniform float uLightness; +#elif defined(dVariant_image) + uniform sampler2D tImage; + uniform vec2 uImageScale; + uniform vec2 uImageOffset; + uniform float uBlur; + uniform float uOpacity; + uniform float uSaturation; + uniform float uLightness; +#elif defined(dVariant_horizontalGradient) || defined(dVariant_radialGradient) + uniform vec3 uGradientColorA; + uniform vec3 uGradientColorB; + uniform float uGradientRatio; +#endif + +uniform vec2 uTexSize; +uniform vec4 uViewport; +uniform bool uViewportAdjusted; +varying vec4 vPosition; + +// TODO: add as general pp option to remove banding? +// Iestyn's RGB dither from http://alex.vlachos.com/graphics/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf +vec3 ScreenSpaceDither(vec2 vScreenPos) { + vec3 vDither = vec3(dot(vec2(171.0, 231.0), vScreenPos.xy)); + vDither.rgb = fract(vDither.rgb / vec3(103.0, 71.0, 97.0)); + return vDither.rgb / 255.0; +} + +vec3 saturateColor(vec3 c, float amount) { + // https://www.w3.org/TR/WCAG21/#dfn-relative-luminance + const vec3 W = vec3(0.2125, 0.7154, 0.0721); + vec3 intensity = vec3(dot(c, W)); + return mix(intensity, c, 1.0 + amount); +} + +vec3 lightenColor(vec3 c, float amount) { + return c + amount; +} + +void main() { + #if defined(dVariant_skybox) + vec4 t = uViewDirectionProjectionInverse * vPosition; + #ifdef enabledShaderTextureLod + gl_FragColor = textureCubeLodEXT(tSkybox, normalize(t.xyz / t.w), uBlur * 8.0); + #else + gl_FragColor = textureCube(tSkybox, normalize(t.xyz / t.w)); + #endif + gl_FragColor.a = uOpacity; + gl_FragColor.rgb = lightenColor(saturateColor(gl_FragColor.rgb, uSaturation), uLightness); + #elif defined(dVariant_image) + vec2 coords; + if (uViewportAdjusted) { + coords = ((gl_FragCoord.xy - uViewport.xy) * (uTexSize / uViewport.zw) / uImageScale) + uImageOffset; + } else { + coords = (gl_FragCoord.xy / uImageScale) + uImageOffset; + } + #ifdef enabledShaderTextureLod + gl_FragColor = texture2DLodEXT(tImage, vec2(coords.x, 1.0 - coords.y), uBlur * 8.0); + #else + gl_FragColor = texture2D(tImage, vec2(coords.x, 1.0 - coords.y)); + #endif + gl_FragColor.a = uOpacity; + gl_FragColor.rgb = lightenColor(saturateColor(gl_FragColor.rgb, uSaturation), uLightness); + #elif defined(dVariant_horizontalGradient) + float d; + if (uViewportAdjusted) { + d = ((gl_FragCoord.y - uViewport.y) * (uTexSize.y / uViewport.w) / uTexSize.y) + 1.0 - (uGradientRatio * 2.0); + } else { + d = (gl_FragCoord.y / uTexSize.y) + 1.0 - (uGradientRatio * 2.0); + } + gl_FragColor = vec4(mix(uGradientColorB, uGradientColorA, clamp(d, 0.0, 1.0)), 1.0); + gl_FragColor.rgb += ScreenSpaceDither(gl_FragCoord.xy); + #elif defined(dVariant_radialGradient) + float d; + if (uViewportAdjusted) { + d = distance(vec2(0.5), (gl_FragCoord.xy - uViewport.xy) * (uTexSize / uViewport.zw) / uTexSize) + uGradientRatio - 0.5; + } else { + d = distance(vec2(0.5), gl_FragCoord.xy / uTexSize) + uGradientRatio - 0.5; + } + gl_FragColor = vec4(mix(uGradientColorB, uGradientColorA, 1.0 - clamp(d, 0.0, 1.0)), 1.0); + gl_FragColor.rgb += ScreenSpaceDither(gl_FragCoord.xy); + #endif +} +`;var yte=` +precision mediump float; + +attribute vec2 aPosition; + +varying vec4 vPosition; + +void main() { + vPosition = vec4(aPosition, 1.0, 1.0); + gl_Position = vec4(aPosition, 1.0, 1.0); +} +`;var _te={opacity:w.Numeric(1,{min:0,max:1,step:.01}),saturation:w.Numeric(0,{min:-1,max:1,step:.01}),lightness:w.Numeric(0,{min:-1,max:1,step:.01})},AOe=P({faces:w.MappedStatic("urls",{urls:w.Group({nx:w.Text("",{label:"Negative X / Left"}),ny:w.Text("",{label:"Negative Y / Bottom"}),nz:w.Text("",{label:"Negative Z / Back"}),px:w.Text("",{label:"Positive X / Right"}),py:w.Text("",{label:"Positive Y / Top"}),pz:w.Text("",{label:"Positive Z / Front"})},{isExpanded:!0,label:"URLs"}),files:w.Group({nx:w.File({label:"Negative X / Left",accept:"image/*"}),ny:w.File({label:"Negative Y / Bottom",accept:"image/*"}),nz:w.File({label:"Negative Z / Back",accept:"image/*"}),px:w.File({label:"Positive X / Right",accept:"image/*"}),py:w.File({label:"Positive Y / Top",accept:"image/*"}),pz:w.File({label:"Positive Z / Front",accept:"image/*"})},{isExpanded:!0,label:"Files"})}),blur:w.Numeric(0,{min:0,max:1,step:.01},{description:'Note, this only works in WebGL2 or when "EXT_shader_texture_lod" is available.'})},_te),DOe=P(P({source:w.MappedStatic("url",{url:w.Text(""),file:w.File({accept:"image/*"})}),blur:w.Numeric(0,{min:0,max:1,step:.01},{description:'Note, this only works in WebGL2 or with power-of-two images and when "EXT_shader_texture_lod" is available.'})},_te),{coverage:w.Select("viewport",w.arrayToOptions(["viewport","canvas"]))}),POe={topColor:w.Color(Xe(14540253)),bottomColor:w.Color(Xe(15658734)),ratio:w.Numeric(.5,{min:0,max:1,step:.01}),coverage:w.Select("viewport",w.arrayToOptions(["viewport","canvas"]))},EOe={centerColor:w.Color(Xe(14540253)),edgeColor:w.Color(Xe(15658734)),ratio:w.Numeric(.5,{min:0,max:1,step:.01}),coverage:w.Select("viewport",w.arrayToOptions(["viewport","canvas"]))},wte={variant:w.MappedStatic("off",{off:w.EmptyGroup(),skybox:w.Group(AOe,{isExpanded:!0}),image:w.Group(DOe,{isExpanded:!0}),horizontalGradient:w.Group(POe,{isExpanded:!0}),radialGradient:w.Group(EOe,{isExpanded:!0})},{label:"Environment"})},Tte=function(){function e(t,r,n,a){this.webgl=t,this.assetManager=r,this.camera=new Qn,this.target=y(),this.position=y(),this.dir=y(),this.renderable=NOe(t,n,a)}return e.prototype.setSize=function(t,r){var n=this.renderable.values.uTexSize.ref.value,a=n[0],i=n[1];(t!==a||r!==i)&&M.update(this.renderable.values.uTexSize,Me.set(this.renderable.values.uTexSize.ref.value,t,r))},e.prototype.clearSkybox=function(){var t=this;this.skybox!==void 0&&(this.skybox.texture.destroy(),this.skybox.assets.forEach(function(r){return t.assetManager.release(r)}),this.skybox=void 0)},e.prototype.updateSkybox=function(t,r,n){var a=this,i,o=(i=this.skybox)===null||i===void 0?void 0:i.props.faces,s=r.faces.params;if(!s.nx||!s.ny||!s.nz||!s.px||!s.py||!s.pz){this.clearSkybox(),n?.(!1);return}if(!this.skybox||!o||!ROe(r.faces,this.skybox.props.faces)){this.clearSkybox();var u=BOe(this.webgl,this.assetManager,r.faces,function(m){a.skybox&&(a.skybox.loaded=!m),n?.(!0)}),c=u.texture,l=u.assets;this.skybox={texture:c,props:P({},r),assets:l,loaded:!1},M.update(this.renderable.values.tSkybox,c),this.renderable.update()}else n?.(!1);if(this.skybox){var f=t;t.state.mode==="orthographic"&&(this.camera.setState(P(P({},t.state),{mode:"perspective"})),this.camera.update(),f=this.camera);var d=this.renderable.values.uViewDirectionProjectionInverse.ref.value;y.sub(this.dir,f.state.position,f.state.target),y.setMagnitude(this.dir,this.dir,.1),y.copy(this.position,this.dir),se.lookAt(d,this.position,this.target,f.state.up),se.mul(d,f.projection,d),se.invert(d,d),M.update(this.renderable.values.uViewDirectionProjectionInverse,d),M.updateIfChanged(this.renderable.values.uBlur,r.blur),M.updateIfChanged(this.renderable.values.uOpacity,r.opacity),M.updateIfChanged(this.renderable.values.uSaturation,r.saturation),M.updateIfChanged(this.renderable.values.uLightness,r.lightness),M.updateIfChanged(this.renderable.values.dVariant,"skybox"),this.renderable.update()}},e.prototype.clearImage=function(){this.image!==void 0&&(this.image.texture.destroy(),this.assetManager.release(this.image.asset),this.image=void 0)},e.prototype.updateImage=function(t,r){var n=this;if(!t.source.params){this.clearImage(),r?.(!1);return}if(!this.image||!this.image.props.source.params||!OOe(t.source,this.image.props.source)){this.clearImage();var a=FOe(this.webgl,this.assetManager,t.source,function(s){n.image&&(n.image.loaded=!s),r?.(!0)}),i=a.texture,o=a.asset;this.image={texture:i,props:P({},t),asset:o,loaded:!1},M.update(this.renderable.values.tImage,i),this.renderable.update()}else r?.(!1);this.image&&(M.updateIfChanged(this.renderable.values.uBlur,t.blur),M.updateIfChanged(this.renderable.values.uOpacity,t.opacity),M.updateIfChanged(this.renderable.values.uSaturation,t.saturation),M.updateIfChanged(this.renderable.values.uLightness,t.lightness),M.updateIfChanged(this.renderable.values.uViewportAdjusted,t.coverage==="viewport"),M.updateIfChanged(this.renderable.values.dVariant,"image"),this.renderable.update())},e.prototype.updateImageScaling=function(){var t,r,n=this.renderable.values,a=n.uTexSize.ref.value,i=a[0],o=a[1],s=((t=this.image)===null||t===void 0?void 0:t.texture.getWidth())||0,u=((r=this.image)===null||r===void 0?void 0:r.texture.getHeight())||0,c=i/o,l=s/u;cc?M.update(n.uImageOffset,Me.set(n.uImageOffset.ref.value,(1-c/h)/2,0)):M.update(n.uImageOffset,Me.set(n.uImageOffset.ref.value,0,(1-h/c)/2))},e.prototype.updateGradient=function(t,r,n,a,i){M.update(this.renderable.values.uGradientColorA,Xe.toVec3Normalized(this.renderable.values.uGradientColorA.ref.value,t)),M.update(this.renderable.values.uGradientColorB,Xe.toVec3Normalized(this.renderable.values.uGradientColorB.ref.value,r)),M.updateIfChanged(this.renderable.values.uGradientRatio,n),M.updateIfChanged(this.renderable.values.uViewportAdjusted,i),M.updateIfChanged(this.renderable.values.dVariant,a),this.renderable.update()},e.prototype.update=function(t,r,n){if(r.variant.name==="off"){this.clearSkybox(),this.clearImage(),n?.(!1);return}else r.variant.name==="skybox"?(this.clearImage(),this.updateSkybox(t,r.variant.params,n)):r.variant.name==="image"?(this.clearSkybox(),this.updateImage(r.variant.params,n)):r.variant.name==="horizontalGradient"?(this.clearSkybox(),this.clearImage(),this.updateGradient(r.variant.params.topColor,r.variant.params.bottomColor,r.variant.params.ratio,r.variant.name,r.variant.params.coverage==="viewport"),n?.(!1)):r.variant.name==="radialGradient"&&(this.clearSkybox(),this.clearImage(),this.updateGradient(r.variant.params.centerColor,r.variant.params.edgeColor,r.variant.params.ratio,r.variant.name,r.variant.params.coverage==="viewport"),n?.(!1));var a=t.viewport,i=a.x,o=a.y,s=a.width,u=a.height;M.update(this.renderable.values.uViewport,Wt.set(this.renderable.values.uViewport.ref.value,i,o,s,u))},e.prototype.isEnabled=function(t){return!!(this.skybox&&this.skybox.loaded||this.image&&this.image.loaded||t.variant.name==="horizontalGradient"||t.variant.name==="radialGradient")},e.prototype.isReady=function(){return!!(this.skybox&&this.skybox.loaded||this.image&&this.image.loaded||this.renderable.values.dVariant.ref.value==="horizontalGradient"||this.renderable.values.dVariant.ref.value==="radialGradient")},e.prototype.render=function(){this.isReady()&&(this.renderable.values.dVariant.ref.value==="image"&&this.updateImageScaling(),ft&&this.webgl.timer.mark("BackgroundPass.render"),this.renderable.render(),ft&&this.webgl.timer.markEnd("BackgroundPass.render"))},e.prototype.dispose=function(){this.clearSkybox(),this.clearImage()},e}();var bte="background-skybox";function IOe(e,t){return t.name==="urls"?{nx:Ur.getUrlAsset(e,t.params.nx),ny:Ur.getUrlAsset(e,t.params.ny),nz:Ur.getUrlAsset(e,t.params.nz),px:Ur.getUrlAsset(e,t.params.px),py:Ur.getUrlAsset(e,t.params.py),pz:Ur.getUrlAsset(e,t.params.pz)}:{nx:t.params.nx,ny:t.params.ny,nz:t.params.nz,px:t.params.px,py:t.params.py,pz:t.params.pz}}function MOe(e,t){var r=function(n){return e.resolve(n,"binary").run().then(function(a){return new Blob([a.data])})};return{nx:r(t.nx),ny:r(t.ny),nz:r(t.nz),px:r(t.px),py:r(t.py),pz:r(t.pz)}}function xte(e){var t,r,n,a,i,o;return e.name==="urls"?"".concat(bte,"_").concat(e.params.nx,"|").concat(e.params.ny,"|").concat(e.params.nz,"|").concat(e.params.px,"|").concat(e.params.py,"|").concat(e.params.pz):"".concat(bte,"_").concat((t=e.params.nx)===null||t===void 0?void 0:t.id,"|").concat((r=e.params.ny)===null||r===void 0?void 0:r.id,"|").concat((n=e.params.nz)===null||n===void 0?void 0:n.id,"|").concat((a=e.params.px)===null||a===void 0?void 0:a.id,"|").concat((i=e.params.py)===null||i===void 0?void 0:i.id,"|").concat((o=e.params.pz)===null||o===void 0?void 0:o.id)}function ROe(e,t){return xte(e)===xte(t)}function BOe(e,t,r,n){var a=IOe(t,r),i=MOe(t,a),o=[a.nx,a.ny,a.nz,a.px,a.py,a.pz];if(typeof HTMLImageElement>"u")return console.error('Missing "HTMLImageElement" required for background skybox'),n?.(!0),{texture:Ga(),assets:o};var s=e.resources.cubeTexture(i,!0,n);return{texture:s,assets:o}}var Ste="background-image";function Cte(e){var t;return e.name==="url"?"".concat(Ste,"_").concat(e.params):"".concat(Ste,"_").concat((t=e.params)===null||t===void 0?void 0:t.id)}function OOe(e,t){return Cte(e)===Cte(t)}function FOe(e,t,r,n){var a=r.name==="url"?Ur.getUrlAsset(t,r.params):r.params;if(typeof HTMLImageElement>"u")return console.error('Missing "HTMLImageElement" required for background image'),n?.(!0),{texture:Ga(),asset:a};var i=e.resources.texture("image-uint8","rgba","ubyte","linear"),o=new Image;return o.onload=function(){i.load(o),(e.isWebGL2||Am(o.width)&&Am(o.height))&&i.mipmap(),n?.()},o.onerror=function(){n?.(!0)},t.resolve(a,"binary").run().then(function(s){var u=new Blob([s.data]);o.src=URL.createObjectURL(u)}),{texture:i,asset:a}}var LOe={drawCount:An("number"),instanceCount:An("number"),aPosition:Gr("float32",2,0),tSkybox:Ft("texture","rgba","ubyte","linear"),tImage:Ft("texture","rgba","ubyte","linear"),uImageScale:_e("v2"),uImageOffset:_e("v2"),uTexSize:_e("v2"),uViewport:_e("v4"),uViewportAdjusted:_e("b"),uViewDirectionProjectionInverse:_e("m4"),uGradientColorA:_e("v3"),uGradientColorB:_e("v3"),uGradientRatio:_e("f"),uBlur:_e("f"),uOpacity:_e("f"),uSaturation:_e("f"),uLightness:_e("f"),dVariant:Dt("string",["skybox","image","verticalGradient","horizontalGradient","radialGradient"])},kOe=Nr("background",yte,gte,{shaderTextureLod:"optional"});function NOe(e,t,r){var n={drawCount:M.create(6),instanceCount:M.create(1),aPosition:M.create(dx),tSkybox:M.create(Ga()),tImage:M.create(Ga()),uImageScale:M.create(Me()),uImageOffset:M.create(Me()),uTexSize:M.create(Me.create(t,r)),uViewport:M.create(Wt()),uViewportAdjusted:M.create(!0),uViewDirectionProjectionInverse:M.create(se()),uGradientColorA:M.create(y()),uGradientColorB:M.create(y()),uGradientRatio:M.create(.5),uBlur:M.create(0),uOpacity:M.create(1),uSaturation:M.create(0),uLightness:M.create(0),dVariant:M.create("skybox")},a=P({},LOe),i=ln(e,"triangles",kOe,a,n);return fn(i,n)}var Ate=` +precision highp float; +precision highp int; +precision highp sampler2D; + +#include common + +uniform sampler2D tDepth; +uniform vec2 uTexSize; +uniform vec4 uBounds; + +uniform float uNear; +uniform float uFar; + +#if dLightCount != 0 + uniform vec3 uLightDirection[dLightCount]; + uniform vec3 uLightColor[dLightCount]; +#endif + +uniform mat4 uProjection; +uniform mat4 uInvProjection; + +uniform float uMaxDistance; +uniform float uTolerance; +uniform float uBias; + +bool isBackground(const in float depth) { + return depth == 1.0; +} + +bool outsideBounds(const in vec2 p) { + return p.x < uBounds.x || p.y < uBounds.y || p.x > uBounds.z || p.y > uBounds.w; +} + +float getViewZ(const in float depth) { + #if dOrthographic == 1 + return orthographicDepthToViewZ(depth, uNear, uFar); + #else + return perspectiveDepthToViewZ(depth, uNear, uFar); + #endif +} + +float getDepth(const in vec2 coords) { + #ifdef depthTextureSupport + return texture2D(tDepth, coords).r; + #else + return unpackRGBAToDepth(texture2D(tDepth, coords)); + #endif +} + +float screenFade(const in vec2 coords) { + vec2 c = (coords - uBounds.xy) / (uBounds.zw - uBounds.xy); + vec2 fade = max(12.0 * abs(c - 0.5) - 5.0, vec2(0.0)); + return saturate(1.0 - dot(fade, fade)); +} + +// based on https://panoskarabelas.com/posts/screen_space_shadows/ +float screenSpaceShadow(const in vec3 position, const in vec3 lightDirection, const in float stepLength) { + // Ray position and direction (in view-space) + vec3 rayPos = position; + vec3 rayDir = -lightDirection; + + // Compute ray step + vec3 rayStep = rayDir * stepLength; + + // Ray march towards the light + float occlusion = 0.0; + vec4 rayCoords = vec4(0.0); + for (int i = 0; i < dSteps; ++i) { + // Step the ray + rayPos += rayStep; + + rayCoords = uProjection * vec4(rayPos, 1.0); + rayCoords.xyz = (rayCoords.xyz / rayCoords.w) * 0.5 + 0.5; + + if (outsideBounds(rayCoords.xy)) + return 1.0; + + // Compute the difference between the ray's and the camera's depth + float depth = getDepth(rayCoords.xy); + float viewZ = getViewZ(depth); + float zDelta = rayPos.z - viewZ; + + if (zDelta < uTolerance) { + occlusion = 1.0; + + // Fade out as we approach the edges of the screen + occlusion *= screenFade(rayCoords.xy); + + break; + } + } + + return 1.0 - (uBias * occlusion); +} + +void main(void) { + vec2 invTexSize = 1.0 / uTexSize; + vec2 selfCoords = gl_FragCoord.xy * invTexSize; + + float selfDepth = getDepth(selfCoords); + + if (isBackground(selfDepth)) { + gl_FragColor = vec4(0.0); + return; + } + + vec3 selfViewPos = screenSpaceToViewSpace(vec3(selfCoords, selfDepth), uInvProjection); + float stepLength = uMaxDistance / float(dSteps); + + float o = 1.0; + #if dLightCount != 0 + float sh[dLightCount]; + #pragma unroll_loop_start + for (int i = 0; i < dLightCount; ++i) { + sh[i] = screenSpaceShadow(selfViewPos, uLightDirection[i], stepLength); + o = min(o, sh[i]); + } + #pragma unroll_loop_end + #endif + + gl_FragColor = vec4(o); +} +`;var Dte=` +precision mediump float; +precision mediump sampler2D; + +uniform sampler2D tColor; +uniform vec2 uTexSizeInv; + +uniform float uSharpness; + +// adapted from https://www.shadertoy.com/view/stXSWB + +/* +* FidelityFX Super Resolution scales up a low resolution +* image, while adding fine detail. +* +* MIT Open License +* +* https://gpuopen.com/fsr +* +* Left: FSR processed +* Right: Original texture, bilinear interpolation +* +* Mouse at top: Sharpness 0 stops (maximum) +* Mouse at bottom: Sharpness 2 stops (minimum) +* +* It works in two passes- +* EASU upsamples the image with a clamped Lanczos kernel. +* RCAS sharpens the image at the target resolution. +* +* I needed to make a few changes to improve readability and +* WebGL compatibility in an algorithm I don't fully understand. +* Expect bugs. +* +* Shader not currently running for WebGL1 targets (eg. mobile Safari) +* +* There is kind of no point to using FSR in Shadertoy, as it renders buffers +* at full target resolution. But this might be useful for WebGL based demos +* running smaller-than-target render buffers. +* +* For sharpening with a full resolution render buffer, +* FidelityFX CAS is a better option. +* https://www.shadertoy.com/view/ftsXzM +* +* For readability and compatibility, these optimisations have been removed: +* * Fast approximate inverse and inversesqrt +* * textureGather fetches (not WebGL compatible) +* * Multiplying by reciprocal instead of division +* +* Apologies to AMD for the numerous slowdowns and errors I have introduced. +* +*/ + +/***** RCAS *****/ +#define FSR_RCAS_LIMIT (0.25-(1.0/16.0)) + +// Input callback prototypes that need to be implemented by calling shader +vec4 FsrRcasLoadF(vec2 p); +//------------------------------------------------------------------------------------------------------------------------------ +void FsrRcasCon( + out float con, + // The scale is {0.0 := maximum, to N>0, where N is the number of stops (halving) of the reduction of sharpness}. + float sharpness +) { + // Transform from stops to linear value. + con = exp2(-sharpness); +} + +vec3 FsrRcasF( + vec2 ip, // Integer pixel position in output. + float con +) { + // Constant generated by RcasSetup(). + // Algorithm uses minimal 3x3 pixel neighborhood. + // b + // d e f + // h + vec2 sp = vec2(ip); + vec3 b = FsrRcasLoadF(sp + vec2( 0,-1)).rgb; + vec3 d = FsrRcasLoadF(sp + vec2(-1, 0)).rgb; + vec3 e = FsrRcasLoadF(sp).rgb; + vec3 f = FsrRcasLoadF(sp + vec2( 1, 0)).rgb; + vec3 h = FsrRcasLoadF(sp + vec2( 0, 1)).rgb; + + // Luma times 2. + float bL = b.g + .5 * (b.b + b.r); + float dL = d.g + .5 * (d.b + d.r); + float eL = e.g + .5 * (e.b + e.r); + float fL = f.g + .5 * (f.b + f.r); + float hL = h.g + .5 * (h.b + h.r); + + // Noise detection. + #ifdef dDenoise + float nz = .25 * (bL + dL + fL + hL) - eL; + nz=clamp( + abs(nz) + /( + max(max(bL,dL),max(eL,max(fL,hL))) + -min(min(bL,dL),min(eL,min(fL,hL))) + ), + 0., 1. + ); + nz=1.-.5*nz; + #endif + + // Min and max of ring. + vec3 mn4 = min(b, min(f, h)); + vec3 mx4 = max(b, max(f, h)); + + // Immediate constants for peak range. + vec2 peakC = vec2(1., -4.); + + // Limiters, these need to be high precision RCPs. + vec3 hitMin = mn4 / (4. * mx4); + vec3 hitMax = (peakC.x - mx4) / (4.* mn4 + peakC.y); + vec3 lobeRGB = max(-hitMin, hitMax); + float lobe = max( + -FSR_RCAS_LIMIT, + min(max(lobeRGB.r, max(lobeRGB.g, lobeRGB.b)), 0.) + )*con; + + // Apply noise removal. + #ifdef dDenoise + lobe *= nz; + #endif + + // Resolve, which needs the medium precision rcp approximation to avoid visible tonality changes. + return (lobe * (b + d + h + f) + e) / (4. * lobe + 1.); +} + + +vec4 FsrRcasLoadF(vec2 p) { + return texture2D(tColor, p * uTexSizeInv); +} + +void main() { + // Set up constants + float con; + FsrRcasCon(con, uSharpness); + + // Perform RCAS pass + vec3 col = FsrRcasF(gl_FragCoord.xy, con); + + gl_FragColor = vec4(col, FsrRcasLoadF(gl_FragCoord.xy).a); +} +`;var Pte={sharpness:w.Numeric(.5,{min:0,max:1,step:.05}),denoise:w.Boolean(!0)},Ete=function(){function e(t,r){this.webgl=t,this.renderable=GOe(t,r)}return e.prototype.updateState=function(t){var r=this.webgl,n=r.gl,a=r.state;a.enable(n.SCISSOR_TEST),a.disable(n.BLEND),a.disable(n.DEPTH_TEST),a.depthMask(!1);var i=t.x,o=t.y,s=t.width,u=t.height;a.viewport(i,o,s,u),a.scissor(i,o,s,u),a.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT)},e.prototype.setSize=function(t,r){M.update(this.renderable.values.uTexSizeInv,Me.set(this.renderable.values.uTexSizeInv.ref.value,1/t,1/r))},e.prototype.update=function(t,r){var n=this.renderable.values,a=r.sharpness,i=r.denoise,o=!1;n.tColor.ref.value!==t&&(M.update(this.renderable.values.tColor,t),o=!0),M.updateIfChanged(n.uSharpness,2-2*Math.pow(a,.25)),n.dDenoise.ref.value!==i&&(o=!0),M.updateIfChanged(n.dDenoise,i),o&&this.renderable.update()},e.prototype.render=function(t,r){ft&&this.webgl.timer.mark("CasPass.render"),r?r.bind():this.webgl.unbindFramebuffer(),this.updateState(t),this.renderable.render(),ft&&this.webgl.timer.markEnd("CasPass.render")},e}();var UOe=P(P({},Gn),{tColor:Ft("texture","rgba","ubyte","linear"),uTexSizeInv:_e("v2"),uSharpness:_e("f"),dDenoise:Dt("boolean")}),VOe=Nr("cas",ea,Dte);function GOe(e,t){var r=t.getWidth(),n=t.getHeight(),a=P(P({},zn),{tColor:M.create(t),uTexSizeInv:M.create(Me.create(1/r,1/n)),uSharpness:M.create(.5),dDenoise:M.create(!0)}),i=P({},UOe),o=ln(e,"triangles",VOe,i,a);return fn(o,a)}var zOe=P(P({},Gn),{tDepthOpaque:Ft("texture","rgba","ubyte","nearest"),tDepthTransparent:Ft("texture","rgba","ubyte","nearest"),uTexSize:_e("v2"),dOrthographic:Dt("number"),uNear:_e("f"),uFar:_e("f"),uInvProjection:_e("m4"),uOutlineThreshold:_e("f"),dTransparentOutline:Dt("boolean")});function HOe(e,t,r,n){var a=t.getWidth(),i=t.getHeight(),o=P(P({},zn),{tDepthOpaque:M.create(t),tDepthTransparent:M.create(r),uTexSize:M.create(Me.create(a,i)),dOrthographic:M.create(0),uNear:M.create(1),uFar:M.create(1e4),uInvProjection:M.create(se.identity()),uOutlineThreshold:M.create(.33),dTransparentOutline:M.create(n)}),s=P({},zOe),u=Nr("outlines",ea,rte),c=ln(e,"triangles",u,s,o);return fn(c,o)}var jOe=P(P({},Gn),{tDepth:Ft("texture","rgba","ubyte","nearest"),uTexSize:_e("v2"),uProjection:_e("m4"),uInvProjection:_e("m4"),uBounds:_e("v4"),dOrthographic:Dt("number"),uNear:_e("f"),uFar:_e("f"),dSteps:Dt("number"),uMaxDistance:_e("f"),uTolerance:_e("f"),uBias:_e("f"),uLightDirection:_e("v3[]"),uLightColor:_e("v3[]"),dLightCount:Dt("number")});function qOe(e,t){var r=t.getWidth(),n=t.getHeight(),a=P(P({},zn),{tDepth:M.create(t),uTexSize:M.create(Me.create(r,n)),uProjection:M.create(se.identity()),uInvProjection:M.create(se.identity()),uBounds:M.create(Wt()),dOrthographic:M.create(0),uNear:M.create(1),uFar:M.create(1e4),dSteps:M.create(1),uMaxDistance:M.create(3),uTolerance:M.create(1),uBias:M.create(.6),uLightDirection:M.create([]),uLightColor:M.create([]),dLightCount:M.create(0)}),i=P({},jOe),o=Nr("shadows",ea,Ate),s=ln(e,"triangles",o,i,a);return fn(s,a)}var WOe=P(P({},Gn),{tDepth:Ft("texture","rgba","ubyte","nearest"),tDepthHalf:Ft("texture","rgba","ubyte","nearest"),tDepthQuarter:Ft("texture","rgba","ubyte","nearest"),uSamples:_e("v3[]"),dNSamples:Dt("number"),uProjection:_e("m4"),uInvProjection:_e("m4"),uBounds:_e("v4"),uTexSize:_e("v2"),uRadius:_e("f"),uBias:_e("f"),dMultiScale:Dt("boolean"),dLevels:Dt("number"),uLevelRadius:_e("f[]"),uLevelBias:_e("f[]"),uNearThreshold:_e("f"),uFarThreshold:_e("f")});function YOe(e,t,r,n){var a=P(P({},zn),{tDepth:M.create(t),tDepthHalf:M.create(r),tDepthQuarter:M.create(n),uSamples:M.create(Rte(32)),dNSamples:M.create(32),uProjection:M.create(se.identity()),uInvProjection:M.create(se.identity()),uBounds:M.create(Wt()),uTexSize:M.create(Me.create(e.gl.drawingBufferWidth,e.gl.drawingBufferHeight)),uRadius:M.create(Math.pow(2,5)),uBias:M.create(.8),dMultiScale:M.create(!1),dLevels:M.create(3),uLevelRadius:M.create([Math.pow(2,2),Math.pow(2,5),Math.pow(2,8)]),uLevelBias:M.create([.8,.8,.8]),uNearThreshold:M.create(10),uFarThreshold:M.create(1500)}),i=P({},WOe),o=Nr("ssao",ea,nte),s=ln(e,"triangles",o,i,a);return fn(s,a)}var XOe=P(P({},Gn),{tSsaoDepth:Ft("texture","rgba","ubyte","nearest"),uTexSize:_e("v2"),uKernel:_e("f[]"),dOcclusionKernelSize:Dt("number"),uBlurDirectionX:_e("f"),uBlurDirectionY:_e("f"),uInvProjection:_e("m4"),uNear:_e("f"),uFar:_e("f"),uBounds:_e("v4"),dOrthographic:Dt("number")});function Ite(e,t,r){var n=P(P({},zn),{tSsaoDepth:M.create(t),uTexSize:M.create(Me.create(t.getWidth(),t.getHeight())),uKernel:M.create(Mte(15)),dOcclusionKernelSize:M.create(15),uBlurDirectionX:M.create(r==="horizontal"?1:0),uBlurDirectionY:M.create(r==="vertical"?1:0),uInvProjection:M.create(se.identity()),uNear:M.create(0),uFar:M.create(1e4),uBounds:M.create(Wt()),dOrthographic:M.create(0)}),a=P({},XOe),i=Nr("ssao_blur",ea,ate),o=ln(e,"triangles",i,a,n);return fn(o,n)}function Mte(e){for(var t=e/3,r=Math.floor((e+1)/2),n=[],a=0;a=h.length)return-2;var p=i.viewport,v=p.x,g=p.y,b=p.width,x=p.height,S=1/h.length;if(t===-1)l.render(r,n,!1),M.update(s.values.uWeight,1),M.update(s.values.tColor,l.getColorTarget(n.postprocessing).texture),s.update(),c.bind(),m.disable(d.BLEND),m.disable(d.DEPTH_TEST),m.depthMask(!1),m.viewport(v,g,b,x),m.scissor(v,g,b,x),s.render(),t+=1;else{i.viewOffset.enabled=!0,M.update(s.values.tColor,l.getColorTarget(n.postprocessing).texture),M.update(s.values.uWeight,S),s.update();for(var _=Math.pow(2,Math.max(0,n.multiSample.sampleLevel-2)),C=0;C<_;++C){var D=h[t];if(Qn.setViewOffset(i.viewOffset,b,x,D[0],D[1],b,x),i.update(),t===0?l.postprocessing.setOcclusionOffset(0,0):l.postprocessing.setOcclusionOffset(D[0]/b,D[1]/x),l.render(r,n,!1),u.bind(),m.enable(d.BLEND),m.blendEquationSeparate(d.FUNC_ADD,d.FUNC_ADD),m.blendFuncSeparate(d.ONE,d.ONE,d.ONE,d.ONE),m.disable(d.DEPTH_TEST),m.depthMask(!1),m.viewport(v,g,b,x),m.scissor(v,g,b,x),t===0&&(m.clearColor(0,0,0,0),d.clear(d.COLOR_BUFFER_BIT)),s.render(),t+=1,t>=h.length)break}}l.postprocessing.setOcclusionOffset(0,0),this.bindOutputTarget(a),m.viewport(v,g,b,x),m.scissor(v,g,b,x);var T=t*S;return T>0&&(M.update(s.values.uWeight,1),M.update(s.values.tColor,u.texture),s.update(),m.disable(d.BLEND),s.render()),T<1&&(M.update(s.values.uWeight,1-T),M.update(s.values.tColor,c.texture),s.update(),T===0?m.disable(d.BLEND):m.enable(d.BLEND),s.render()),i.viewOffset.enabled=!1,i.update(),ft&&f.timer.markEnd("MultiSamplePass.renderTemporalMultiSample"),t>=h.length?-2:t},e}();var RF=[[[0,0]],[[0,0],[-4,-4]],[[0,0],[6,-2],[-6,2],[2,6]],[[0,0],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[0,0],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[0,0],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]];RF.forEach(function(e){e.forEach(function(t){t[0]*=.0625,t[1]*=.0625})});var HT=function(){function e(t){this.multiSamplePass=t,this.sampleIndex=-2}return e.prototype.update=function(t,r){return t&&(this.sampleIndex=-1),r.mode==="temporal"?this.sampleIndex!==-2:!1},e.prototype.render=function(t,r,n,a){return this.sampleIndex=this.multiSamplePass.render(this.sampleIndex,t,r,n,!!a),this.sampleIndex<0},e}();var BF={eyeSeparation:w.Numeric(.062,{min:.02,max:.1,step:.001},{description:"Distance between left and right camera."}),focus:w.Numeric(10,{min:1,max:20,step:.1},{description:"Apparent object distance."})},tFe=w.getDefaultValues(BF);var tm=function(){function e(t,r){r===void 0&&(r={}),this.parent=t,this.left=new Ote,this.right=new Ote,this.props=P(P({},tFe),r)}return Object.defineProperty(e.prototype,"viewport",{get:function(){return this.parent.viewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewOffset",{get:function(){return this.parent.viewOffset},enumerable:!1,configurable:!0}),e.prototype.setProps=function(t){Object.assign(this.props,t)},e.prototype.update=function(){this.parent.update(),rFe(this.parent,this.props,this.left,this.right)},e}();(function(e){function t(r){return"left"in r&&"right"in r}e.is=t})(tm||(tm={}));var Ote=function(){function e(){this.viewport=Ma.create(0,0,0,0),this.view=se(),this.projection=se(),this.projectionView=se(),this.inverseProjectionView=se(),this.state=Qn.createDefaultSnapshot(),this.viewOffset=Qn.ViewOffset(),this.far=0,this.near=0,this.fogFar=0,this.fogNear=0}return e}(),Fte=se.identity(),Lte=se.identity();function rFe(e,t,r,n){Ma.copy(r.viewport,e.viewport),se.copy(r.view,e.view),se.copy(r.projection,e.projection),Qn.copySnapshot(r.state,e.state),Qn.copyViewOffset(r.viewOffset,e.viewOffset),r.far=e.far,r.near=e.near,r.fogFar=e.fogFar,r.fogNear=e.fogNear,Ma.copy(n.viewport,e.viewport),se.copy(n.view,e.view),se.copy(n.projection,e.projection),Qn.copySnapshot(n.state,e.state),Qn.copyViewOffset(n.viewOffset,e.viewOffset),n.far=e.far,n.near=e.near,n.fogFar=e.fogFar,n.fogNear=e.fogNear;var a=Math.floor(e.viewport.width/2),i=a/e.viewport.height;r.viewport.width=a,n.viewport.x+=a,n.viewport.width-=a;var o=t.eyeSeparation/2,s=o*e.near/t.focus,u=e.near*Math.tan(e.state.fov*.5),c,l;Fte[12]=-o,Lte[12]=o,c=-u*i+s,l=u*i+s,r.projection[0]=2*e.near/(l-c),r.projection[8]=(l+c)/(l-c),se.mul(r.view,r.view,Fte),se.mul(r.projectionView,r.projection,r.view),se.invert(r.inverseProjectionView,r.projectionView),c=-u*i-s,l=u*i-s,n.projection[0]=2*e.near/(l-c),n.projection[8]=(l+c)/(l-c),se.mul(n.view,n.view,Lte),se.mul(n.projectionView,n.projection,n.view),se.invert(n.inverseProjectionView,n.projectionView)}var OF=Math.pow(2,24)-2,kte=function(){function e(t,r,n){this.webgl=t,this.drawPass=r,this.pickBaseScale=n;var a=n/t.pixelRatio;this.pickWidth=Math.ceil(r.colorTarget.getWidth()*a),this.pickHeight=Math.ceil(r.colorTarget.getHeight()*a);var i=t.resources,o=t.extensions.drawBuffers,s=t.gl;o?(this.objectPickTexture=i.texture("image-uint8","rgba","ubyte","nearest"),this.objectPickTexture.define(this.pickWidth,this.pickHeight),this.instancePickTexture=i.texture("image-uint8","rgba","ubyte","nearest"),this.instancePickTexture.define(this.pickWidth,this.pickHeight),this.groupPickTexture=i.texture("image-uint8","rgba","ubyte","nearest"),this.groupPickTexture.define(this.pickWidth,this.pickHeight),this.depthPickTexture=i.texture("image-uint8","rgba","ubyte","nearest"),this.depthPickTexture.define(this.pickWidth,this.pickHeight),this.framebuffer=i.framebuffer(),this.objectPickFramebuffer=i.framebuffer(),this.instancePickFramebuffer=i.framebuffer(),this.groupPickFramebuffer=i.framebuffer(),this.depthPickFramebuffer=i.framebuffer(),this.framebuffer.bind(),o.drawBuffers([o.COLOR_ATTACHMENT0,o.COLOR_ATTACHMENT1,o.COLOR_ATTACHMENT2,o.COLOR_ATTACHMENT3]),this.objectPickTexture.attachFramebuffer(this.framebuffer,"color0"),this.instancePickTexture.attachFramebuffer(this.framebuffer,"color1"),this.groupPickTexture.attachFramebuffer(this.framebuffer,"color2"),this.depthPickTexture.attachFramebuffer(this.framebuffer,"color3"),this.depthRenderbuffer=Gt(s)?i.renderbuffer("depth32f","depth",this.pickWidth,this.pickHeight):i.renderbuffer("depth16","depth",this.pickWidth,this.pickHeight),this.depthRenderbuffer.attachFramebuffer(this.framebuffer),this.objectPickTexture.attachFramebuffer(this.objectPickFramebuffer,"color0"),this.instancePickTexture.attachFramebuffer(this.instancePickFramebuffer,"color0"),this.groupPickTexture.attachFramebuffer(this.groupPickFramebuffer,"color0"),this.depthPickTexture.attachFramebuffer(this.depthPickFramebuffer,"color0")):(this.objectPickTarget=t.createRenderTarget(this.pickWidth,this.pickHeight),this.instancePickTarget=t.createRenderTarget(this.pickWidth,this.pickHeight),this.groupPickTarget=t.createRenderTarget(this.pickWidth,this.pickHeight),this.depthPickTarget=t.createRenderTarget(this.pickWidth,this.pickHeight))}return e.prototype.bindObject=function(){this.webgl.extensions.drawBuffers?this.objectPickFramebuffer.bind():this.objectPickTarget.bind()},e.prototype.bindInstance=function(){this.webgl.extensions.drawBuffers?this.instancePickFramebuffer.bind():this.instancePickTarget.bind()},e.prototype.bindGroup=function(){this.webgl.extensions.drawBuffers?this.groupPickFramebuffer.bind():this.groupPickTarget.bind()},e.prototype.bindDepth=function(){this.webgl.extensions.drawBuffers?this.depthPickFramebuffer.bind():this.depthPickTarget.bind()},Object.defineProperty(e.prototype,"drawingBufferHeight",{get:function(){return this.drawPass.colorTarget.getHeight()},enumerable:!1,configurable:!0}),e.prototype.syncSize=function(){var t=this.pickBaseScale/this.webgl.pixelRatio,r=Math.ceil(this.drawPass.colorTarget.getWidth()*t),n=Math.ceil(this.drawPass.colorTarget.getHeight()*t);(r!==this.pickWidth||n!==this.pickHeight)&&(this.pickWidth=r,this.pickHeight=n,this.webgl.extensions.drawBuffers?(this.objectPickTexture.define(this.pickWidth,this.pickHeight),this.instancePickTexture.define(this.pickWidth,this.pickHeight),this.groupPickTexture.define(this.pickWidth,this.pickHeight),this.depthPickTexture.define(this.pickWidth,this.pickHeight),this.depthRenderbuffer.setSize(this.pickWidth,this.pickHeight)):(this.objectPickTarget.setSize(this.pickWidth,this.pickHeight),this.instancePickTarget.setSize(this.pickWidth,this.pickHeight),this.groupPickTarget.setSize(this.pickWidth,this.pickHeight),this.depthPickTarget.setSize(this.pickWidth,this.pickHeight)))},e.prototype.renderVariant=function(t,r,n,a,i,o){t.clear(!1),t.update(r,n),t.renderPick(n.primitives,r,i,null,o),a.handle.isEnabled&&t.renderPick(a.handle.scene,r,i,null,o),a.camera.isEnabled&&(a.camera.update(r),t.update(a.camera.camera,a.camera.scene),t.renderPick(a.camera.scene,a.camera.camera,i,null,o))},e.prototype.render=function(t,r,n,a){this.webgl.extensions.drawBuffers?(this.framebuffer.bind(),this.renderVariant(t,r,n,a,"pick",Np.None)):(this.objectPickTarget.bind(),this.renderVariant(t,r,n,a,"pick",Np.Object),this.instancePickTarget.bind(),this.renderVariant(t,r,n,a,"pick",Np.Instance),this.groupPickTarget.bind(),this.renderVariant(t,r,n,a,"pick",Np.Group),this.depthPickTarget.bind(),this.renderVariant(t,r,n,a,"depth",Np.None))},e}();var Nte=function(){function e(t,r,n,a,i,o,s){s===void 0&&(s=1),this.webgl=t,this.renderer=r,this.scene=n,this.helper=a,this.pickPass=i,this.pickPadding=s,this.dirty=!0,this.viewport=Ma(),this.setViewport(o.x,o.y,o.width,o.height)}return e.prototype.setupBuffers=function(){var t=this.pickWidth*this.pickHeight*4;(!this.objectBuffer||this.objectBuffer.length!==t)&&(this.objectBuffer=new Uint8Array(t),this.instanceBuffer=new Uint8Array(t),this.groupBuffer=new Uint8Array(t),this.depthBuffer=new Uint8Array(t))},e.prototype.setViewport=function(t,r,n,a){Ma.set(this.viewport,t,r,n,a),this.pickScale=this.pickPass.pickBaseScale/this.webgl.pixelRatio,this.pickX=Math.ceil(t*this.pickScale),this.pickY=Math.ceil(r*this.pickScale);var i=Math.floor(n*this.pickScale),o=Math.floor(a*this.pickScale);(i!==this.pickWidth||o!==this.pickHeight)&&(this.pickWidth=i,this.pickHeight=o,this.halfPickWidth=Math.floor(this.pickWidth/2),this.setupBuffers()),this.spiral=e8(Math.round(this.pickScale*this.pickPadding))},e.prototype.syncBuffers=function(){ft&&this.webgl.timer.mark("PickHelper.syncBuffers");var t=this,r=t.pickX,n=t.pickY,a=t.pickWidth,i=t.pickHeight;this.pickPass.bindObject(),this.webgl.readPixels(r,n,a,i,this.objectBuffer),this.pickPass.bindInstance(),this.webgl.readPixels(r,n,a,i,this.instanceBuffer),this.pickPass.bindGroup(),this.webgl.readPixels(r,n,a,i,this.groupBuffer),this.pickPass.bindDepth(),this.webgl.readPixels(r,n,a,i,this.depthBuffer),ft&&this.webgl.timer.markEnd("PickHelper.syncBuffers")},e.prototype.getBufferIdx=function(t,r){return(r*this.pickWidth+t)*4},e.prototype.getDepth=function(t,r){var n=this.getBufferIdx(t,r),a=this.depthBuffer;return Eq(a[n],a[n+1],a[n+2],a[n+3])},e.prototype.getId=function(t,r,n){var a=this.getBufferIdx(t,r);return lv(n[a],n[a+1],n[a+2])},e.prototype.render=function(t){ft&&this.webgl.timer.mark("PickHelper.render",!0);var r=this,n=r.pickX,a=r.pickY,i=r.pickWidth,o=r.pickHeight,s=r.halfPickWidth,u=this,c=u.renderer,l=u.scene,f=u.helper;c.setTransparentBackground(!1),c.setDrawingBufferSize(i,o),c.setPixelRatio(this.pickScale),tm.is(t)?(c.setViewport(n,a,s,o),this.pickPass.render(c,t.left,l,f),c.setViewport(n+s,a,i-s,o),this.pickPass.render(c,t.right,l,f)):(c.setViewport(n,a,i,o),this.pickPass.render(c,t,l,f)),this.dirty=!1,ft&&this.webgl.timer.markEnd("PickHelper.render")},e.prototype.identifyInternal=function(t,r,n){var a=this,i=a.webgl,o=a.pickScale;if(!i.isContextLost){t*=i.pixelRatio,r*=i.pixelRatio,r=this.pickPass.drawingBufferHeight-r;var s=this.viewport;if(!(ts.x+s.width||r>s.y+s.height)){this.dirty&&(ft&&this.webgl.timer.mark("PickHelper.identify"),this.render(n),this.syncBuffers(),ft&&this.webgl.timer.markEnd("PickHelper.identify"));var u=t-s.x,c=r-s.y,l=Math.floor(u*o),f=Math.floor(c*o),d=this.getId(l,f,this.objectBuffer);if(!(d===-1||d===OF)){var m=this.getId(l,f,this.instanceBuffer);if(!(m===-1||m===OF)){var h=this.getId(l,f,this.groupBuffer);if(!(h===-1||h===OF)){var p=this.getDepth(l,f),v=y.create(t,r,p);if(tm.is(n)){var g=Math.floor(s.width/2);t>s.x+g?(v[0]=s.x+(u-g)*2,My(v,v,s,n.right.inverseProjectionView)):(v[0]=s.x+u*2,My(v,v,s,n.left.inverseProjectionView))}else My(v,v,s,n.inverseProjectionView);return{id:{objectId:d,instanceId:m,groupId:h},position:v}}}}}}},e.prototype.identify=function(t,r,n){for(var a=0,i=this.spiral;a 0.0) { + vec3 edgeColor = edgeValue.b == 1.0 ? uHighlightEdgeColor : uSelectEdgeColor; + gl_FragColor.rgb = edgeValue.g > 0.0 ? edgeColor : edgeColor * uInnerEdgeFactor; + gl_FragColor.a = (edgeValue.r == 1.0 ? uGhostEdgeStrength : 1.0) * edgeValue.a; + float edgeStrength = edgeValue.b == 1.0 ? uHighlightEdgeStrength : uSelectEdgeStrength; + gl_FragColor.a *= edgeStrength; + } else { + gl_FragColor = vec4(0.0); + } +} +`;var qte=` +precision highp float; +precision highp sampler2D; + +uniform sampler2D tMaskTexture; +uniform vec2 uTexSizeInv; + +void main() { + vec2 coords = gl_FragCoord.xy * uTexSizeInv; + vec4 offset = vec4(float(dEdgeScale), 0.0, 0.0, float(dEdgeScale)) * vec4(uTexSizeInv, uTexSizeInv); + vec4 c0 = texture2D(tMaskTexture, coords); + vec4 c1 = texture2D(tMaskTexture, coords + offset.xy); + vec4 c2 = texture2D(tMaskTexture, coords - offset.xy); + vec4 c3 = texture2D(tMaskTexture, coords + offset.yw); + vec4 c4 = texture2D(tMaskTexture, coords - offset.yw); + float diff1 = (c1.r - c2.r) * 0.5; + float diff2 = (c3.r - c4.r) * 0.5; + float d = length(vec2(diff1, diff2)); + if (d <= 0.0) + discard; + float a1 = min(c1.g, c2.g); + float a2 = min(c3.g, c4.g); + float visibility = min(a1, a2) > 0.001 ? 1.0 : 0.0; + float mask = c0.r; + float marker = min(c1.b, min(c2.b, min(c3.b, c4.b))); + float fogAlpha = min(c1.a, min(c2.a, min(c3.a, c4.a))); + gl_FragColor = vec4(visibility, mask, marker, fogAlpha); +} +`;var jT={enabled:w.Boolean(!0),highlightEdgeColor:w.Color(Xe.darken(Xe.fromNormalizedRgb(1,.4,.6),1)),selectEdgeColor:w.Color(Xe.darken(Xe.fromNormalizedRgb(.2,1,.1),1)),edgeScale:w.Numeric(1,{min:1,max:3,step:1},{description:"Thickness of the edge."}),highlightEdgeStrength:w.Numeric(1,{min:0,max:1,step:.1}),selectEdgeStrength:w.Numeric(1,{min:0,max:1,step:.1}),ghostEdgeStrength:w.Numeric(.3,{min:0,max:1,step:.1},{description:"Opacity of the hidden edges that are covered by other geometry. When set to 1, one less geometry render pass is done."}),innerEdgeFactor:w.Numeric(1.5,{min:0,max:3,step:.1},{description:"Factor to multiply the inner edge color with - for added contrast."})},FF=function(){function e(t,r,n){this.webgl=t,this.depthTarget=t.createRenderTarget(r,n),this.maskTarget=t.createRenderTarget(r,n),this.edgesTarget=t.createRenderTarget(r,n),this.edge=pFe(t,this.maskTarget.texture),this.overlay=gFe(t,this.edgesTarget.texture)}return e.isEnabled=function(t){return t.enabled},e.prototype.setEdgeState=function(t){var r=this.webgl,n=r.gl,a=r.state;a.enable(n.SCISSOR_TEST),a.enable(n.BLEND),a.blendFunc(n.ONE,n.ONE),a.blendEquation(n.FUNC_ADD),a.disable(n.DEPTH_TEST),a.depthMask(!1);var i=t.x,o=t.y,s=t.width,u=t.height;a.viewport(i,o,s,u),a.scissor(i,o,s,u),a.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT)},e.prototype.setOverlayState=function(t){var r=this.webgl,n=r.gl,a=r.state;a.enable(n.SCISSOR_TEST),a.enable(n.BLEND),a.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),a.blendEquation(n.FUNC_ADD),a.disable(n.DEPTH_TEST),a.depthMask(!1);var i=t.x,o=t.y,s=t.width,u=t.height;a.viewport(i,o,s,u),a.scissor(i,o,s,u)},e.prototype.setSize=function(t,r){var n=this.depthTarget.getWidth(),a=this.depthTarget.getHeight();(t!==n||r!==a)&&(this.depthTarget.setSize(t,r),this.maskTarget.setSize(t,r),this.edgesTarget.setSize(t,r),M.update(this.edge.values.uTexSizeInv,Me.set(this.edge.values.uTexSizeInv.ref.value,1/t,1/r)),M.update(this.overlay.values.uTexSizeInv,Me.set(this.overlay.values.uTexSizeInv.ref.value,1/t,1/r)))},e.prototype.update=function(t){var r=t.highlightEdgeColor,n=t.selectEdgeColor,a=t.edgeScale,i=t.innerEdgeFactor,o=t.ghostEdgeStrength,s=t.highlightEdgeStrength,u=t.selectEdgeStrength,c=this.edge.values,l=Math.max(1,Math.round(a*this.webgl.pixelRatio));c.dEdgeScale.ref.value!==l&&(M.update(c.dEdgeScale,l),this.edge.update());var f=this.overlay.values;M.update(f.uHighlightEdgeColor,Xe.toVec3Normalized(f.uHighlightEdgeColor.ref.value,r)),M.update(f.uSelectEdgeColor,Xe.toVec3Normalized(f.uSelectEdgeColor.ref.value,n)),M.updateIfChanged(f.uInnerEdgeFactor,i),M.updateIfChanged(f.uGhostEdgeStrength,o),M.updateIfChanged(f.uHighlightEdgeStrength,s),M.updateIfChanged(f.uSelectEdgeStrength,u)},e.prototype.render=function(t,r){ft&&this.webgl.timer.mark("MarkingPass.render"),this.edgesTarget.bind(),this.setEdgeState(t),this.edge.render(),r?r.bind():this.webgl.unbindFramebuffer(),this.setOverlayState(t),this.overlay.render(),ft&&this.webgl.timer.markEnd("MarkingPass.render")},e}();var dFe=P(P({},Gn),{tMaskTexture:Ft("texture","rgba","ubyte","linear"),uTexSizeInv:_e("v2"),dEdgeScale:Dt("number")}),mFe=Nr("edge",ea,qte);function pFe(e,t){var r=t.getWidth(),n=t.getHeight(),a=P(P({},zn),{tMaskTexture:M.create(t),uTexSizeInv:M.create(Me.create(1/r,1/n)),dEdgeScale:M.create(1)}),i=P({},dFe),o=ln(e,"triangles",mFe,i,a);return fn(o,a)}var hFe=P(P({},Gn),{tEdgeTexture:Ft("texture","rgba","ubyte","linear"),uTexSizeInv:_e("v2"),uHighlightEdgeColor:_e("v3"),uSelectEdgeColor:_e("v3"),uHighlightEdgeStrength:_e("f"),uSelectEdgeStrength:_e("f"),uGhostEdgeStrength:_e("f"),uInnerEdgeFactor:_e("f")}),vFe=Nr("overlay",ea,jte);function gFe(e,t){var r=t.getWidth(),n=t.getHeight(),a=P(P({},zn),{tEdgeTexture:M.create(t),uTexSizeInv:M.create(Me.create(1/r,1/n)),uHighlightEdgeColor:M.create(y()),uSelectEdgeColor:M.create(y()),uHighlightEdgeStrength:M.create(1),uSelectEdgeStrength:M.create(1),uGhostEdgeStrength:M.create(0),uInnerEdgeFactor:M.create(0)}),i=P({},hFe),o=ln(e,"triangles",vFe,i,a);return fn(o,a)}var qT=function(){function e(t,r,n,a,i,o){this.webgl=t;var s=t.extensions,u=t.resources,c=t.isWebGL2;this.drawTarget=hj(t.gl),this.colorTarget=t.createRenderTarget(n,a,!0,"uint8","linear"),this.packedDepth=!s.depthTexture,this.depthTargetTransparent=t.createRenderTarget(n,a),this.depthTextureTransparent=this.depthTargetTransparent.texture,this.depthTargetOpaque=this.packedDepth?t.createRenderTarget(n,a):null,this.depthTextureOpaque=this.depthTargetOpaque?this.depthTargetOpaque.texture:u.texture("image-depth","depth",c?"float":"ushort","nearest"),this.packedDepth||this.depthTextureOpaque.define(n,a),this.wboit=i?new Vte(t,n,a):void 0,this.dpoit=o?new Hte(t,n,a):void 0,this.marking=new FF(t,n,a),this.postprocessing=new Ns(t,r,this),this.antialiasing=new GT(t,this),this.copyFboTarget=fv(t,this.colorTarget.texture),this.copyFboPostprocessing=fv(t,this.postprocessing.target.texture)}return Object.defineProperty(e.prototype,"wboitEnabled",{get:function(){var t;return!!(!((t=this.wboit)===null||t===void 0)&&t.supported)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dpoitEnabled",{get:function(){var t;return!!(!((t=this.dpoit)===null||t===void 0)&&t.supported)},enumerable:!1,configurable:!0}),e.prototype.reset=function(){var t,r;(t=this.wboit)===null||t===void 0||t.reset(),(r=this.dpoit)===null||r===void 0||r.reset()},e.prototype.setSize=function(t,r){var n,a,i=this.colorTarget.getWidth(),o=this.colorTarget.getHeight();(t!==i||r!==o)&&(this.colorTarget.setSize(t,r),this.depthTargetTransparent.setSize(t,r),this.depthTargetOpaque?this.depthTargetOpaque.setSize(t,r):this.depthTextureOpaque.define(t,r),M.update(this.copyFboTarget.values.uTexSize,Me.set(this.copyFboTarget.values.uTexSize.ref.value,t,r)),M.update(this.copyFboPostprocessing.values.uTexSize,Me.set(this.copyFboPostprocessing.values.uTexSize.ref.value,t,r))),!((n=this.wboit)===null||n===void 0)&&n.supported&&this.wboit.setSize(t,r),!((a=this.dpoit)===null||a===void 0)&&a.supported&&this.dpoit.setSize(t,r),this.marking.setSize(t,r),this.postprocessing.setSize(t,r),this.antialiasing.setSize(t,r)},e.prototype._renderDpoit=function(t,r,n,a,i,o){var s;if(!(!((s=this.dpoit)===null||s===void 0)&&s.supported))throw new Error("expected dpoit to be supported");if(this.depthTextureOpaque.attachFramebuffer(this.colorTarget.framebuffer,"depth"),t.clear(!0),n.hasOpaque&&t.renderDpoitOpaque(n.primitives,r,null),Ns.isEnabled(o)&&(Ns.isTransparentOutlineEnabled(o)&&(this.depthTargetTransparent.bind(),t.clearDepth(!0),n.opacityAverage<1&&t.renderDepthTransparent(n.primitives,r,this.depthTextureOpaque)),this.postprocessing.render(r,!1,i,t.props.backgroundColor,o,t.light)),this.depthTextureOpaque.detachFramebuffer(this.colorTarget.framebuffer,"depth"),n.opacityAverage<1){var u=Ns.isEnabled(o)?this.postprocessing.target:this.colorTarget,c=this.dpoit.bind();t.renderDpoitTransparent(n.primitives,r,this.depthTextureOpaque,c);for(var l=0;l0&&t.renderDpoitVolume(n.volumes,r,this.depthTextureOpaque)},e.prototype._renderWboit=function(t,r,n,a,i){var o;if(!(!((o=this.wboit)===null||o===void 0)&&o.supported))throw new Error("expected wboit to be supported");this.depthTextureOpaque.attachFramebuffer(this.colorTarget.framebuffer,"depth"),t.clear(!0),n.hasOpaque&&t.renderWboitOpaque(n.primitives,r,null),Ns.isEnabled(i)&&(Ns.isTransparentOutlineEnabled(i)&&(this.depthTargetTransparent.bind(),t.clearDepth(!0),n.opacityAverage<1&&t.renderDepthTransparent(n.primitives,r,this.depthTextureOpaque)),this.postprocessing.render(r,!1,a,t.props.backgroundColor,i,t.light)),(n.opacityAverage<1||n.volumes.renderables.length>0)&&(this.wboit.bind(),n.opacityAverage<1&&t.renderWboitTransparent(n.primitives,r,this.depthTextureOpaque),n.volumes.renderables.length>0&&t.renderWboitTransparent(n.volumes,r,this.depthTextureOpaque),Ns.isEnabled(i)?this.postprocessing.target.bind():this.colorTarget.bind(),this.wboit.render())},e.prototype._renderBlended=function(t,r,n,a,i,o){var s,u,c,l;if(a?this.drawTarget.bind():this.packedDepth?this.colorTarget.bind():this.depthTextureOpaque.attachFramebuffer(this.colorTarget.framebuffer,"depth"),t.clear(!0),n.hasOpaque&&t.renderBlendedOpaque(n.primitives,r,null),!a&&(this.depthTargetOpaque&&(this.depthTargetOpaque.bind(),t.clearDepth(!0),t.renderDepthOpaque(n.primitives,r,null),this.colorTarget.bind()),Ns.isEnabled(o)&&(this.packedDepth?(s=this.colorTarget.depthRenderbuffer)===null||s===void 0||s.detachFramebuffer(this.postprocessing.target.framebuffer):this.depthTextureOpaque.detachFramebuffer(this.postprocessing.target.framebuffer,"depth"),Ns.isTransparentOutlineEnabled(o)&&(this.depthTargetTransparent.bind(),t.clearDepth(!0),n.opacityAverage<1&&t.renderDepthTransparent(n.primitives,r,this.depthTextureOpaque)),this.postprocessing.render(r,!1,i,t.props.backgroundColor,o,t.light),this.packedDepth?(u=this.colorTarget.depthRenderbuffer)===null||u===void 0||u.attachFramebuffer(this.postprocessing.target.framebuffer):this.depthTextureOpaque.attachFramebuffer(this.postprocessing.target.framebuffer,"depth")),n.volumes.renderables.length>0)){var f=Ns.isEnabled(o)?this.postprocessing.target:this.colorTarget;this.packedDepth?(c=this.colorTarget.depthRenderbuffer)===null||c===void 0||c.detachFramebuffer(f.framebuffer):this.depthTextureOpaque.detachFramebuffer(f.framebuffer,"depth"),f.bind(),t.renderBlendedVolume(n.volumes,r,this.depthTextureOpaque),this.packedDepth?(l=this.colorTarget.depthRenderbuffer)===null||l===void 0||l.attachFramebuffer(f.framebuffer):this.depthTextureOpaque.attachFramebuffer(f.framebuffer,"depth"),f.bind()}n.opacityAverage<1&&t.renderBlendedTransparent(n.primitives,r,null)},e.prototype._render=function(t,r,n,a,i,o,s){var u=n.volumes.renderables.length>0,c=Ns.isEnabled(s.postprocessing),l=GT.isEnabled(s.postprocessing),f=FF.isEnabled(s.marking),d=r.viewport,m=d.x,h=d.y,p=d.width,v=d.height;t.setViewport(m,h,p,v),t.update(r,n),o&&!l&&i&&(this.drawTarget.bind(),t.clear(!1)),this.wboitEnabled?this._renderWboit(t,r,n,o,s.postprocessing):this.dpoitEnabled?this._renderDpoit(t,r,n,s.dpoitIterations,o,s.postprocessing):this._renderBlended(t,r,n,!u&&!c&&!l&&i,o,s.postprocessing);var g=c?this.postprocessing.target:!i||u||this.wboitEnabled||this.dpoitEnabled?this.colorTarget:this.drawTarget;if(f&&n.markerAverage>0){var b=s.marking.ghostEdgeStrength<1;b&&n.markerAverage!==1&&(this.marking.depthTarget.bind(),t.clear(!1,!0),t.renderMarkingDepth(n.primitives,r,null)),this.marking.maskTarget.bind(),t.clear(!1,!0),t.renderMarkingMask(n.primitives,r,b?this.marking.depthTarget.texture:null),this.marking.update(s.marking),this.marking.render(r.viewport,g)}else g.bind();a.debug.isEnabled&&(a.debug.syncVisibility(),t.renderBlended(a.debug.scene,r)),a.handle.isEnabled&&t.renderBlended(a.handle.scene,r),a.camera.isEnabled&&(a.camera.update(r),t.update(a.camera.camera,a.camera.scene),t.renderBlended(a.camera.scene,a.camera.camera)),l?this.antialiasing.render(r,i,s.postprocessing):i&&(this.drawTarget.bind(),this.webgl.state.disable(this.webgl.gl.DEPTH_TEST),c?this.copyFboPostprocessing.render():(u||this.wboitEnabled||this.dpoitEnabled)&&this.copyFboTarget.render()),this.webgl.gl.flush()},e.prototype.render=function(t,r,n){ft&&this.webgl.timer.mark("DrawPass.render");var a=t.renderer,i=t.camera,o=t.scene,s=t.helper;this.postprocessing.setTransparentBackground(r.transparentBackground);var u=r.transparentBackground||this.postprocessing.background.isEnabled(r.postprocessing.background);a.setTransparentBackground(u),a.setDrawingBufferSize(this.colorTarget.getWidth(),this.colorTarget.getHeight()),a.setPixelRatio(this.webgl.pixelRatio),tm.is(i)?(ft&&this.webgl.timer.mark("StereoCamera.left"),this._render(a,i.left,o,s,n,u,r),ft&&this.webgl.timer.markEnd("StereoCamera.left"),ft&&this.webgl.timer.mark("StereoCamera.right"),this._render(a,i.right,o,s,n,u,r),ft&&this.webgl.timer.markEnd("StereoCamera.right")):this._render(a,i,o,s,n,u,r),ft&&this.webgl.timer.markEnd("DrawPass.render")},e.prototype.getColorTarget=function(t){return GT.isEnabled(t)?this.antialiasing.target:Ns.isEnabled(t)?this.postprocessing.target:this.colorTarget},e}();var yFe={alpha:w.Numeric(.51,{min:0,max:1,step:.01},{isEssential:!0,label:"Opacity"}),colorX:w.Color(Xt.red,{isEssential:!0}),colorY:w.Color(Xt.green,{isEssential:!0}),colorZ:w.Color(Xt.blue,{isEssential:!0}),scale:w.Numeric(.33,{min:.1,max:2,step:.1},{isEssential:!0}),location:w.Select("bottom-left",w.arrayToOptions(["bottom-left","bottom-right","top-left","top-right"])),locationOffsetX:w.Numeric(0),locationOffsetY:w.Numeric(0),originColor:w.Color(Xt.grey),radiusScale:w.Numeric(.075,{min:.01,max:.3,step:.001}),showPlanes:w.Boolean(!0),planeColorXY:w.Color(Xt.grey,{label:"Plane Color XY"}),planeColorXZ:w.Color(Xt.grey,{label:"Plane Color XZ"}),planeColorYZ:w.Color(Xt.grey,{label:"Plane Color YZ"}),showLabels:w.Boolean(!1),labelX:w.Text("X"),labelY:w.Text("Y"),labelZ:w.Text("Z"),labelColorX:w.Color(Xt.grey),labelColorY:w.Color(Xt.grey),labelColorZ:w.Color(Xt.grey),labelOpacity:w.Numeric(1,{min:0,max:1,step:.01}),labelScale:w.Numeric(.25,{min:.1,max:1,step:.01})},zp={axes:w.MappedStatic("on",{on:w.Group(yFe),off:w.Group({})},{cycle:!0,description:"Show camera orientation axes"})},YT=function(){function e(t,r){r===void 0&&(r={});var n=this;this.webgl=t,this.props={axes:{name:"off",params:{}}},this.pixelRatio=1,this.eachGroup=function(a,i){if(!WT(a))return!1;var o=!1;if(n.meshRenderObject)for(var s=n.meshRenderObject.values.uGroupCount.ref.value,u=0,c=a.elements;ug.drawingBufferWidth||x+_<0||S>g.drawingBufferHeight||S+C<0)return!1;var Ct=Z()&&(O.props.colorMarker||c.marking.enabled),bt=!1;B.update(T);var Mt=I.update(),Ot=Ue||Mt||ut||D;D=!1;var ue=V.update(Ct||Ot,c.multiSample);if(Ot||ue||Ct){var ye=I;c.camera.stereo.name==="on"&&(R.update(),ye=R),ft&&a.timer.mark("Canvas3D.render",!0);var we={renderer:O,camera:ye,scene:A,helper:z};if(Uv.isEnabled(c.multiSample)){var $e=c.multiSample.reduceFlicker&&!Mt&&Ct&&!B.isAnimating;V.render(we,c,!0,$e)}else o.draw.render(we,c,!0);ft&&a.timer.markEnd("Canvas3D.render"),k.dirty=k.dirty||Ot,bt=!0}return bt}var N=!1,ee=!1;function oe(Ue){ee||H(!!Ue?.force)&&ae&&h.next(pn()-m)}function me(){D=!0}var pe=0;function de(Ue,ut){T=Ue,Ge(ut?.isSynchronous),I.transition.tick(T),!ut?.manualDraw&&(oe(),!I.transition.inTransition&&!a.isContextLost&&G.tick(T))}function re(){de(pn()),pe=LFe(re)}function te(Ue){m=Ue,B.start(Ue)}function fe(){ee=!1,B.start(pn()),pe===0&&re()}function ve(Ue){Ue===void 0&&(Ue=!1),ee=Ue,Qte(pe),pe=0}function De(Ue,ut){var Ct=c.camera.stereo.name==="on"?R:I;return a.isContextLost?void 0:k.identify(Ue,ut,Ct)}function Ge(Ue){Ue===void 0&&(Ue=!1);var ut=Ie(Ue);ut&&(Ke(),N&&(z.debug.isEnabled&&z.debug.update(),oe({force:!0}),N=!1),p.next(pn()))}function Ke(){if(U){var Ue=A.boundingSphereVisible,ut=Ue.center,Ct=Ue.radius,bt=B.props.autoAdjustMinMaxDistance;if(bt.name==="on"){var Mt=bt.params.minDistanceFactor*Ct+bt.params.minDistancePadding,Ot=Math.max(bt.params.maxDistanceFactor*Ct,bt.params.maxDistanceMin);B.setProps({minDistance:Mt,maxDistance:Ot})}if(Ct>0){var ue=Q===void 0?c.cameraResetDurationMs:Q,ye=I.getFocus(ut,Ct),we=typeof W=="function"?W(A,I):W,$e=we?P(P({},ye),we):ye;I.setState(P(P({},$e),{radiusMax:E()}),ue)}Q=void 0,W=void 0,U=!1}}var L=xe(),K=xe();function ge(){if(I.state.radiusMax===0)return!0;if(I.transition.inTransition||W)return!1;var Ue=!0,ut=!0;xe.set(K,I.state.target,I.state.radius);for(var Ct=0,bt=A.renderables;CtK.radius||ue>Ot.radius||Ot.radius>I.state.radiusMax)&&!xe.includes(L,Ot))return!0;xe.overlaps(K,Ot)&&(Ue=!1)}}}return Ue||!ut&&K.radius<=.1}var Pe=250;function Ie(Ue){return A.needsCommit?(xe.copy(L,A.boundingSphereVisible),A.commit(Ue?void 0:Pe)?(v.next(0),z.debug.isEnabled&&z.debug.update(),!c.camera.manualReset&&(d.value===0||ge())&&(U=!0),L.radius===0&&(Q=0),c.camera.manualReset||I.setState({radiusMax:E()},0),d.next(l.size),or&&ke(),!0):(v.next(A.commitQueueSize),!1)):!0}function ke(){var Ue=A.renderables.map(function(Ot){return{drawCount:Ot.values.drawCount.ref.value,instanceCount:Ot.values.instanceCount.ref.value,materialId:Ot.materialId,renderItemId:Ot.id}});console.groupCollapsed("".concat(Ue.length," RenderItems")),Ue.length<50?console.table(Ue):console.log(Ue),console.log(JSON.stringify(a.stats,void 0,4));var ut=a.resources.getByteCounts(),Ct=ut.texture,bt=ut.attribute,Mt=ut.elements;console.log(JSON.stringify({texture:"".concat((Ct/1024/1024).toFixed(3)," MiB"),attribute:"".concat((bt/1024/1024).toFixed(3)," MiB"),elements:"".concat((Mt/1024/1024).toFixed(3)," MiB")},void 0,4)),console.log(JSON.stringify(a.timer.formatedStats(),void 0,4)),console.groupEnd()}function Ne(Ue){et(Ue);var ut=l.get(Ue),Ct=new Set;Ue.renderObjects.forEach(function(bt){return Ct.add(bt)}),ut?dn.areEqual(Ct,ut)||(Ct.forEach(function(bt){ut.has(bt)||A.add(bt)}),ut.forEach(function(bt){Ct.has(bt)||A.remove(bt)})):Ue.renderObjects.forEach(function(bt){return A.add(bt)}),l.set(Ue,Ct),A.update(Ue.renderObjects,!1),N=!0,or&&ke()}function Ve(Ue){Re(Ue);var ut=l.get(Ue);ut&&(ut.forEach(function(Ct){return A.remove(Ct)}),l.delete(Ue),N=!0,or&&ke())}function et(Ue){f.has(Ue)||f.set(Ue,Ue.updated.subscribe(function(ut){Ue.state.syncManually||Ne(Ue)}))}function Re(Ue){var ut=f.get(Ue);ut&&(ut.unsubscribe(),f.delete(Ue))}function je(){var Ue=A.boundingSphere.radius>0?100-Math.round(I.transition.target.radius/E()*100):0;return{camera:{mode:I.state.mode,helper:P({},z.camera.props),stereo:P({},c.camera.stereo),fov:Math.round(Zi(I.state.fov)),manualReset:!!c.camera.manualReset},cameraFog:I.state.fog>0?{name:"on",params:{intensity:I.state.fog}}:{name:"off",params:{}},cameraClipping:{far:I.state.clipFar,radius:Ue,minNear:I.state.minNear},cameraResetDurationMs:c.cameraResetDurationMs,sceneRadiusFactor:c.sceneRadiusFactor,transparentBackground:c.transparentBackground,dpoitIterations:c.dpoitIterations,viewport:c.viewport,postprocessing:P({},c.postprocessing),marking:P({},c.marking),multiSample:P({},c.multiSample),renderer:P({},O.props),trackball:P({},B.props),interaction:P({},G.props),debug:P({},z.debug.props),handle:P({},z.handle.props)}}var tt=b.subscribe(function(){k.dirty=!0,oe({force:!0}),oe({force:!0})}),ht=new ha(0);function ct(Ue){Ue===void 0&&(Ue=!0),o.updateSize(),xt(),_t(),Ue&&me(),ht.next(+new Date)}return b8(ke),{webgl:a,add:Ne,remove:Ve,commit:Ge,update:function(Ue,ut){if(Ue){if(!l.has(Ue))return;A.update(Ue.renderObjects,!!ut)}else A.update(void 0,!!ut);N=!0},clear:function(){f.forEach(function(Ue){return Ue.unsubscribe()}),f.clear(),l.clear(),A.clear(),z.debug.clear(),me(),d.next(l.size)},syncVisibility:function(){I.state.radiusMax===0&&(U=!0,Q=0),A.syncVisibility()&&z.debug.isEnabled&&z.debug.update(),me()},requestDraw:me,tick:de,animate:fe,resetTime:te,pause:ve,resume:function(){ee=!1},identify:De,mark:j,getLoci:q,handleResize:ct,requestResize:function(){X=!0},requestCameraReset:function(Ue){Q=Ue?.durationMs,W=Ue?.snapshot,U=!0},camera:I,boundingSphere:A.boundingSphere,boundingSphereVisible:A.boundingSphereVisible,get notifyDidDraw(){return ae},set notifyDidDraw(Ue){ae=Ue},didDraw:h,commited:p,commitQueueSize:v,reprCount:d,resized:ht,setProps:function(Ue,ut){var Ct,bt,Mt,Ot;ut===void 0&&(ut=!1);var ue=typeof Ue=="function"?zm(je(),Ue):Ue;ue.sceneRadiusFactor!==void 0&&(c.sceneRadiusFactor=ue.sceneRadiusFactor,I.setState({radiusMax:E()},0));var ye=Object.create(null);ue.camera&&ue.camera.mode!==void 0&&ue.camera.mode!==I.state.mode&&(ye.mode=ue.camera.mode);var we=Math.round(Zi(I.state.fov));if(ue.camera&&ue.camera.fov!==void 0&&ue.camera.fov!==we&&(ye.fov=vr(ue.camera.fov)),ue.cameraFog!==void 0&&ue.cameraFog.params){var $e=ue.cameraFog.name==="on"?ue.cameraFog.params.intensity:0;$e!==I.state.fog&&(ye.fog=$e)}if(ue.cameraClipping!==void 0&&(ue.cameraClipping.far!==void 0&&ue.cameraClipping.far!==I.state.clipFar&&(ye.clipFar=ue.cameraClipping.far),ue.cameraClipping.minNear!==void 0&&ue.cameraClipping.minNear!==I.state.minNear&&(ye.minNear=ue.cameraClipping.minNear),ue.cameraClipping.radius!==void 0)){var Et=E()/100*(100-ue.cameraClipping.radius);Et>0&&Et!==ye.radius&&(ye.radius=Math.max(Et,.01))}if(Object.keys(ye).length>0&&I.setState(ye),!((Ct=ue.camera)===null||Ct===void 0)&&Ct.helper&&z.camera.setProps(ue.camera.helper),((bt=ue.camera)===null||bt===void 0?void 0:bt.manualReset)!==void 0&&(c.camera.manualReset=ue.camera.manualReset),((Mt=ue.camera)===null||Mt===void 0?void 0:Mt.stereo)!==void 0&&(Object.assign(c.camera.stereo,ue.camera.stereo),R.setProps(c.camera.stereo.params)),ue.cameraResetDurationMs!==void 0&&(c.cameraResetDurationMs=ue.cameraResetDurationMs),ue.transparentBackground!==void 0&&(c.transparentBackground=ue.transparentBackground),ue.dpoitIterations!==void 0&&(c.dpoitIterations=ue.dpoitIterations),ue.viewport!==void 0){var Tt=c.viewport===ue.viewport||c.viewport.name===ue.viewport.name&&dd(c.viewport.params,ue.viewport.params);Tt||(c.viewport=ue.viewport,xt(),_t())}!((Ot=ue.postprocessing)===null||Ot===void 0)&&Ot.background&&(Object.assign(c.postprocessing.background,ue.postprocessing.background),o.draw.postprocessing.background.update(I,c.postprocessing.background,function(nr){nr&&!ut&&me()})),ue.postprocessing&&Object.assign(c.postprocessing,ue.postprocessing),ue.marking&&Object.assign(c.marking,ue.marking),ue.multiSample&&Object.assign(c.multiSample,ue.multiSample),ue.renderer&&O.setProps(ue.renderer),ue.trackball&&B.setProps(ue.trackball),ue.interaction&&G.setProps(ue.interaction),ue.debug&&z.debug.setProps(ue.debug),ue.handle&&z.handle.setProps(ue.handle),ye.mode==="orthographic"&&(c.camera.stereo.name="off"),ut||me()},getImagePass:function(Ue){return Ue===void 0&&(Ue={}),new Wte(a,u,O,A,I,z,o.draw.wboitEnabled,o.draw.dpoitEnabled,Ue)},getRenderObjects:function(){var Ue=[];return A.forEach(function(ut,Ct){return Ue.push(Ct)}),Ue},get props(){return je()},get input(){return i},get stats(){return O.stats},get interaction(){return G.events},dispose:function(){tt.unsubscribe(),Qte(pe),F=[],A.clear(),z.debug.clear(),B.dispose(),O.dispose(),G.dispose(),x8(ke)}};function xt(){var Ue=x,ut=S,Ct=_,bt=C;c.viewport.name==="canvas"?(x=0,S=0,_=g.drawingBufferWidth,C=g.drawingBufferHeight):c.viewport.name==="static-frame"?(x=c.viewport.params.x*a.pixelRatio,C=c.viewport.params.height*a.pixelRatio,S=g.drawingBufferHeight-C-c.viewport.params.y*a.pixelRatio,_=c.viewport.params.width*a.pixelRatio):c.viewport.name==="relative-frame"&&(x=Math.round(c.viewport.params.x*g.drawingBufferWidth),C=Math.round(c.viewport.params.height*g.drawingBufferHeight),S=Math.round(g.drawingBufferHeight-C-c.viewport.params.y*g.drawingBufferHeight),_=Math.round(c.viewport.params.width*g.drawingBufferWidth)),(Ue!==x||ut!==S||Ct!==_||bt!==C)&&(D=!0)}function _t(){k.setViewport(x,S,_,C),O.setViewport(x,S,_,C),Ma.set(I.viewport,x,S,_,C),Ma.set(B.viewport,x,S,_,C)}}e.create=t})(ZT||(ZT={}));function kFe(e){$te(e)}function $te(e){rr.Canvas3D.ResetSettings.subscribe(e,function(){var t;(t=e.canvas3d)===null||t===void 0||t.setProps(Jx),e.events.canvas3d.settingsUpdated.next(void 0)}),rr.Canvas3D.SetSettings.subscribe(e,function(t){var r;e.canvas3d&&((r=e.canvas3d)===null||r===void 0||r.setProps(t.settings),e.events.canvas3d.settingsUpdated.next(void 0))})}var NF={};fi(NF,{DefaultFocusLociBindings:()=>ere,DefaultLociLabelProvider:()=>HFe,DefaultSelectLociBindings:()=>Jte,FocusLoci:()=>qFe,HighlightLoci:()=>VFe,SelectLoci:()=>zFe});var Gv=xa,Hp=Ro,zv=At.Trigger,NFe={hoverHighlightOnly:At([zv(Gv.Flag.None)],"Highlight","Hover element using ${triggers}"),hoverHighlightOnlyExtend:At([zv(Gv.Flag.None,Hp.create({shift:!0}))],"Extend highlight","From selected to hovered element along polymer using ${triggers}")},UFe={bindings:w.Value(NFe,{isHidden:!0}),ignore:w.Value([],{isHidden:!0}),preferAtoms:w.Boolean(!1,{description:"Always prefer atoms over bonds"}),mark:w.Boolean(!0)},VFe=_r.create({name:"representation-highlight-loci",category:"interaction",ctor:function(e){St(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.lociMarkProvider=function(n,a){!r.ctx.canvas3d||!r.params.mark||r.ctx.canvas3d.mark(n,a)},r}return t.prototype.getLoci=function(r){return this.params.preferAtoms&&mt.isLoci(r)&&r.bonds.length===2?mt.toFirstStructureElementLoci(r):r},t.prototype.register=function(){var r=this;this.subscribeObservable(this.ctx.behaviors.interaction.hover,function(n){var a=n.current,i=n.buttons,o=n.modifiers;if(!(!r.ctx.canvas3d||r.ctx.isBusy)){var s=r.getLoci(a.loci);if(r.params.ignore.includes(s.kind)){r.ctx.managers.interactivity.lociHighlights.highlightOnly({repr:a.repr,loci:Jt});return}var u=!1;At.match(r.params.bindings.hoverHighlightOnly,i,o)&&(r.ctx.managers.interactivity.lociHighlights.highlightOnly({loci:s}),u=!0),At.match(r.params.bindings.hoverHighlightOnlyExtend,i,o)&&(r.ctx.managers.interactivity.lociHighlights.highlightOnlyExtend({loci:s}),u=!0),u||r.ctx.managers.interactivity.lociHighlights.highlightOnly({repr:a.repr,loci:Jt})}}),this.ctx.managers.interactivity.lociHighlights.addProvider(this.lociMarkProvider)},t.prototype.unregister=function(){this.ctx.managers.interactivity.lociHighlights.removeProvider(this.lociMarkProvider)},t}(_r.Handler),params:function(){return UFe},display:{name:"Highlight Loci on Canvas"}}),Jte={clickSelect:At.Empty,clickToggleExtend:At([zv(Gv.Flag.Primary,Hp.create({shift:!0}))],"Toggle extended selection","Click on element using ${triggers} to extend selection along polymer"),clickSelectOnly:At.Empty,clickToggle:At([zv(Gv.Flag.Primary,Hp.create())],"Toggle selection","Click on element using ${triggers}"),clickDeselect:At.Empty,clickDeselectAllOnEmpty:At([zv(Gv.Flag.Primary,Hp.create())],"Deselect all","Click on nothing using ${triggers}")},GFe={bindings:w.Value(Jte,{isHidden:!0}),ignore:w.Value([],{isHidden:!0}),preferAtoms:w.Boolean(!1,{description:"Always prefer atoms over bonds"}),mark:w.Boolean(!0)},zFe=_r.create({name:"representation-select-loci",category:"interaction",ctor:function(e){St(t,e);function t(r,n){var a=e.call(this,r,n)||this;return a.lociMarkProvider=function(i,o){!a.ctx.canvas3d||!a.params.mark||a.ctx.canvas3d.mark({loci:i.loci},o)},a.spine=new E0.Impl(r.state.data.cells),a}return t.prototype.getLoci=function(r){return this.params.preferAtoms&&mt.isLoci(r)&&r.bonds.length===2?mt.toFirstStructureElementLoci(r):r},t.prototype.applySelectMark=function(r,n){var a=this.ctx.state.data.cells.get(r);if(a&&he.isRepresentation3D(a.obj)){this.spine.current=a;var i=this.spine.getRootOfType(he.Molecule.Structure);if(i){n&&this.lociMarkProvider({loci:Le.Loci(i.data)},kt.Deselect);var o=this.ctx.managers.structure.selection.getLoci(i.data);this.lociMarkProvider({loci:o},kt.Select)}}},t.prototype.register=function(){var r=this,n=function(o){return jt.isEmpty(o)},a=function(o){return!jt.isEmpty(o)},i=[["clickSelect",function(o){return r.ctx.managers.interactivity.lociSelects.select(o)},a],["clickToggle",function(o){return r.ctx.managers.interactivity.lociSelects.toggle(o)},a],["clickToggleExtend",function(o){return r.ctx.managers.interactivity.lociSelects.toggleExtend(o)},a],["clickSelectOnly",function(o){return r.ctx.managers.interactivity.lociSelects.selectOnly(o)},a],["clickDeselect",function(o){return r.ctx.managers.interactivity.lociSelects.deselect(o)},a],["clickDeselectAllOnEmpty",function(){return r.ctx.managers.interactivity.lociSelects.deselectAll()},n]];i.sort(function(o,s){var u=r.params.bindings[o[0]],c=r.params.bindings[s[0]],l=u.triggers.length===0?0:Lo(u.triggers.map(function(d){return Hp.size(d.modifiers)})),f=c.triggers.length===0?0:Lo(c.triggers.map(function(d){return Hp.size(d.modifiers)}));return f-l}),this.subscribeObservable(this.ctx.behaviors.interaction.click,function(o){var s=o.current,u=o.button,c=o.modifiers;if(!(!r.ctx.canvas3d||r.ctx.isBusy||!r.ctx.selectionMode)){var l=r.getLoci(s.loci);if(!r.params.ignore.includes(l.kind))for(var f=0,d=i;f")},group:function(r){return r.toString().replace(/Model [0-9]+/g,"Models")},priority:100}}return e.prototype.register=function(){this.ctx.managers.lociLabels.addProvider(this.f)},e.prototype.unregister=function(){this.ctx.managers.lociLabels.removeProvider(this.f)},e}(),display:{name:"Provide Default Loci Label"}}),ere={clickFocus:At([zv(Gv.Flag.Primary,Hp.create())],"Representation Focus","Click element using ${triggers}"),clickFocusAdd:At([zv(Gv.Flag.Primary,Hp.create({shift:!0}))],"Representation Focus Add","Click element using ${triggers}"),clickFocusSelectMode:At([],"Representation Focus","Click element using ${triggers}"),clickFocusAddSelectMode:At([],"Representation Focus Add","Click element using ${triggers}")},jFe={bindings:w.Value(ere,{isHidden:!0})},qFe=_r.create({name:"representation-focus-loci",category:"interaction",ctor:function(e){St(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.register=function(){var r=this;this.subscribeObservable(this.ctx.behaviors.interaction.click,function(n){var a,i=n.current,o=n.button,s=n.modifiers,u=r.params.bindings,c=u.clickFocus,l=u.clickFocusAdd,f=u.clickFocusSelectMode,d=u.clickFocusAddSelectMode,m=r.ctx.managers.interactivity.props.granularity;if(!(m!=="residue"&&m!=="element")){var h=r.ctx.selectionMode?f:c,p=At.match(h,o,s),v=r.ctx.selectionMode?d:l,g=At.match(v,o,s);if(!(!p&&!g)){var b=jt.normalize(i.loci,"residue"),x=r.ctx.managers.structure.focus.current;if(x&&jt.areEqual(x.loci,b))r.ctx.managers.structure.focus.clear();else if(p)r.ctx.managers.structure.focus.setFromLoci(b);else{r.ctx.managers.structure.focus.addFromLoci(b);var S=(a=r.ctx.managers.structure.focus.current)===null||a===void 0?void 0:a.loci;S&&r.ctx.managers.camera.focusLoci(S)}}}})},t}(_r.Handler),params:function(){return jFe},display:{name:"Representation Focus Loci on Canvas"}});var GF={};fi(GF,{CameraAxisHelper:()=>XFe,CameraControls:()=>ZFe,DefaultClickResetCameraOnEmpty:()=>UF,DefaultClickResetCameraOnEmptySelectMode:()=>VF,DefaultFocusLociBindings:()=>tre,FocusLoci:()=>YFe});var Wf=xa,Wl=Ro,Yf=At.Trigger,QT=At.TriggerKey,UF=At([Yf(Wf.Flag.Primary,Wl.create()),Yf(Wf.Flag.Secondary,Wl.create()),Yf(Wf.Flag.Primary,Wl.create({control:!0}))],"Reset camera focus","Click on nothing using ${triggers}"),VF=At([Yf(Wf.Flag.Secondary,Wl.create()),Yf(Wf.Flag.Primary,Wl.create({control:!0}))],"Reset camera focus","Click on nothing using ${triggers}"),tre={clickCenterFocus:At([Yf(Wf.Flag.Primary,Wl.create()),Yf(Wf.Flag.Secondary,Wl.create()),Yf(Wf.Flag.Primary,Wl.create({control:!0}))],"Camera center and focus","Click element using ${triggers}"),clickCenterFocusSelectMode:At([Yf(Wf.Flag.Secondary,Wl.create()),Yf(Wf.Flag.Primary,Wl.create({control:!0}))],"Camera center and focus","Click element using ${triggers}"),clickResetCameraOnEmpty:UF,clickResetCameraOnEmptySelectMode:VF},WFe={minRadius:w.Numeric(8,{min:1,max:50,step:1}),extraRadius:w.Numeric(4,{min:1,max:50,step:1},{description:"Value added to the bounding-sphere radius of the Loci"}),durationMs:w.Numeric(250,{min:0,max:1e3,step:1},{description:"Camera transition duration"}),bindings:w.Value(tre,{isHidden:!0})},YFe=_r.create({name:"camera-focus-loci",category:"interaction",ctor:function(e){St(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.register=function(){var r=this;this.subscribeObservable(this.ctx.behaviors.interaction.click,function(n){var a,i,o=n.current,s=n.button,u=n.modifiers;if(r.ctx.canvas3d){var c=r.ctx.selectionMode?r.params.bindings.clickCenterFocusSelectMode:r.params.bindings.clickCenterFocus,l=r.ctx.selectionMode?(a=r.params.bindings.clickResetCameraOnEmptySelectMode)!==null&&a!==void 0?a:VF:(i=r.params.bindings.clickResetCameraOnEmpty)!==null&&i!==void 0?i:UF;if(jt.isEmpty(o.loci)&&At.match(l,s,u)){rr.Camera.Reset(r.ctx,{});return}if(At.match(c,s,u)){var f=jt.normalize(o.loci,r.ctx.managers.interactivity.props.granularity);r.ctx.managers.camera.focusLoci(f,r.params)}}})},t}(_r.Handler),params:function(){return WFe},display:{name:"Camera Focus Loci on Canvas"}}),XFe=_r.create({name:"camera-axis-helper",category:"interaction",ctor:function(e){St(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.register=function(){var r=this,n=Pn.None,a=0;this.subscribeObservable(this.ctx.behaviors.interaction.click,function(i){var o=i.current;if(!(!r.ctx.canvas3d||!WT(o.loci))){var s=o.loci.elements[0].groupId;if(s===Pn.None){n=Pn.None,a=0;return}var u=r.ctx.canvas3d.camera,c,l;if(s>=Pn.X&&s<=Pn.Z){n=Pn.None,a=0;var f=y.sub(y(),u.target,u.position),d=y.cross(y(),f,u.up);l=y(),l[s-1]=1,c=y.cross(y(),l,d),y.magnitude(c)===0&&(c=f)}else n===s?a=(a+1)%2:(n=s,a=0),s===Pn.XY?(l=a?y.unitX:y.unitY,c=y.negUnitZ):s===Pn.XZ?(l=a?y.unitX:y.unitZ,c=y.negUnitY):(l=a?y.unitY:y.unitZ,c=y.negUnitX);r.ctx.canvas3d.requestCameraReset({snapshot:function(m,h){return h.getInvariantFocus(m.boundingSphereVisible.center,m.boundingSphereVisible.radius,l,c)}})}})},t}(_r.Handler),params:function(){return{}},display:{name:"Camera Axis Helper"}}),rre={keySpinAnimation:At([QT("I")],"Spin Animation","Press ${triggers}"),keyRockAnimation:At([QT("O")],"Rock Animation","Press ${triggers}"),keyToggleFlyMode:At([QT("Space",Wl.create({shift:!0}))],"Toggle Fly Mode","Press ${triggers}"),keyResetView:At([QT("T")],"Reset View","Press ${triggers}")},KFe={bindings:w.Value(rre,{isHidden:!0})},ZFe=_r.create({name:"camera-controls",category:"interaction",ctor:function(e){St(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.register=function(){var r=this;this.subscribeObservable(this.ctx.behaviors.interaction.key,function(n){var a,i=n.code,o=n.key,s=n.modifiers;if(r.ctx.canvas3d){var u=P(P({},rre),r.params.bindings),c=r.ctx.canvas3d.props.trackball;if(At.matchKey(u.keySpinAnimation,i,s,o)){var l=c.animate.name!=="spin"?"spin":"off";l==="off"?r.ctx.canvas3d.setProps({trackball:{animate:{name:l,params:{}}}}):r.ctx.canvas3d.setProps({trackball:{animate:{name:l,params:{speed:1}}}})}if(At.matchKey(u.keyRockAnimation,i,s,o)){var f=c.animate.name!=="rock"?"rock":"off";f==="off"?r.ctx.canvas3d.setProps({trackball:{animate:{name:f,params:{}}}}):r.ctx.canvas3d.setProps({trackball:{animate:{name:f,params:{speed:.3,angle:10}}}})}if(At.matchKey(u.keyToggleFlyMode,i,s,o)){var d=!c.flyMode;r.ctx.canvas3d.setProps({trackball:{flyMode:d}}),!((a=r.ctx.canvas3dContext)===null||a===void 0)&&a.canvas&&(r.ctx.canvas3dContext.canvas.style.cursor=d?"crosshair":"unset")}At.matchKey(u.keyResetView,i,s,o)&&rr.Camera.Reset(r.ctx,{})}})},t}(_r.Handler),params:function(){return KFe},display:{name:"Camera Controls on Canvas"}});var DL={};fi(DL,{AccessibleSurfaceArea:()=>dre,BestDatabaseSequenceMapping:()=>Qne,CrossLinkRestraint:()=>iae,Interactions:()=>Wne,SecondaryStructure:()=>Yne,StructureInfo:()=>nre,ValenceModel:()=>Xne});var nre=_r.create({name:"structure-info-prop",category:"custom-props",display:{name:"Structure Info"},ctor:function(e){St(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return Object.defineProperty(t.prototype,"maxModelIndex",{get:function(){for(var r,n,a=-1,i=this.ctx.state.data.select(Yt.Generators.rootsOfType(he.Molecule.Model)),o=0,s=i;oa&&(a=c)}return a},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxStructureIndex",{get:function(){for(var r,n,a=-1,i=this.ctx.state.data.select(Yt.Generators.rootsOfType(he.Molecule.Structure)),o=0,s=i;oa&&(a=c)}return a},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"asymIdOffset",{get:function(){for(var r,n=0,a=0,i=this.ctx.state.data.select(Yt.Generators.rootsOfType(he.Molecule.Model)),o=0,s=i;ooe)continue e}++q}o[i[b]]+=u*q*O*O}}}var HF={numberOfSpherePoints:w.Numeric(92,{min:12,max:360,step:1},{description:"Number of sphere points to sample per atom: 92 (original paper), 960 (BioJava), 3000 (EPPIC) - see Shrake A, Rupley JA: Environment and exposure to solvent of protein atoms. Lysozyme and insulin. J Mol Biol 1973."}),probeSize:w.Numeric(1.4,{min:.1,max:4,step:.01},{description:"Corresponds to the size of a water molecule: 1.4 (original paper), 1.5 (occassionally used)"}),nonPolymer:w.Boolean(!1,{description:"Include non-polymer atoms as occluders."}),traceOnly:w.Boolean(!1,{description:"Compute only using alpha-carbons, if true increase probeSize accordingly (e.g., 4 A). Considers only canonical amino acids."})};var jp;(function(e){function t(c,l){var f=this;l===void 0&&(l={});var d=P(P({},w.getDefaultValues(HF)),l);return Ce.create("Compute Accessible Surface Area",function(m){return $(f,void 0,void 0,function(){return J(this,function(h){switch(h.label){case 0:return[4,r(m,c,d)];case 1:return[2,h.sent()]}})})})}e.compute=t;function r(c,l,f){return $(this,void 0,void 0,function(){var d,m,h;return J(this,function(p){switch(p.label){case 0:return d=n(l,f),ire(d),[4,sre(c,d)];case 1:return p.sent(),m=d.area,h=d.serialResidueIndex,[2,{area:m,serialResidueIndex:h}]}})})}function n(c,l){var f=c.elementCount,d=c.atomicResidueCount,m=l.probeSize,h=l.nonPolymer,p=l.traceOnly,v=l.numberOfSpherePoints;return{structure:c,probeSize:m,nonPolymer:h,traceOnly:p,spherePoints:a(v),scalingConstant:4*Math.PI/v,maxLookupRadius:2*l.probeSize+2*Yl[2],atomRadiusType:new Int8Array(f),serialResidueIndex:new Int32Array(f),area:new Float32Array(d)}}function a(c){for(var l=[],f=Math.PI*(3-Math.sqrt(5)),d=2/c,m=0;m1?"Residues sum":"Residue",")");return"Accessible Surface Area ".concat(m,": ").concat(o.toFixed(2)," \u212B2")}else if(e.kind==="structure-loci"){var t=ku.get(e.structure).value;return!t||e.structure.customPropertyDescriptors.hasReference(ku.descriptor)?void 0:"Accessible Surface Area (Whole Structure): ".concat(L3(t.area).toFixed(2)," \u212B2")}}var lre=xn("Buried Protein Residues",le.struct.modifier.union([le.struct.modifier.wholeResidues([le.struct.modifier.union([le.struct.generator.atomGroups({"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":JT.isBuried.symbol()})])])]),{description:"Select buried protein residues.",category:hn.Residue,ensureCustomProperties:function(e,t){return ku.attach(e,t)}}),fre=xn("Accessible Protein Residues",le.struct.modifier.union([le.struct.modifier.wholeResidues([le.struct.modifier.union([le.struct.generator.atomGroups({"chain-test":le.core.rel.eq([le.ammp("objectPrimitive"),"atomistic"]),"residue-test":JT.isAccessible.symbol()})])])]),{description:"Select accessible protein residues.",category:hn.Residue,ensureCustomProperties:function(e,t){return ku.attach(e,t)}});function Lr(e,t){return e.model.atomicHierarchy.atoms.type_symbol.value(e.elements[t])}function eA(e,t){return e.model.atomicHierarchy.atoms.pdbx_formal_charge.value(e.elements[t])}function qp(e,t){return e.model.atomicHierarchy.atoms.label_atom_id.value(e.elements[t])}function eS(e,t){return e.model.atomicHierarchy.atoms.label_alt_id.value(e.elements[t])}function tS(e,t){return e.model.atomicHierarchy.atoms.label_comp_id.value(e.elements[t])}function nLe(e,t,r){for(var n=0,a=e.interUnitBonds.getEdgeIndices(r,t.id),i=0,o=a.length;i1||Lr(c,l)!=="H"&&(s=c,u=l,c.conformation.position(c.elements[l],Ry),y.sub(i[o++],Ry,Hv))}),o===1&&s&&u&&ao(e,s,u,function(c,l){o>1||c===t&&l===r||Lr(c,l)!=="H"&&(c.conformation.position(c.elements[l],Ry),y.sub(i[o++],Ry,Hv))}),o===2)return y.cross(nA,i[0],i[1]),Math.abs(Math.PI/2-y.angle(nA,rA))}var KF=new mt.ElementBondIterator,ZF=new mt.ElementBondIterator;function uLe(e,t,r){var n=Lr(t,r),a=n==="O"||n==="N";if(a&&Nu(e,t,r)===4)return!1;for(KF.setElement(e,t,r);KF.hasNext;){var i=KF.move();if(i.order>1)return!0;if(a){var o=Lr(i.otherUnit,i.otherIndex);for(ZF.setElement(e,i.otherUnit,i.otherIndex);ZF.hasNext;){var s=ZF.move();if(s.order>1){if((o==="P"||o==="S")&&Lr(s.otherUnit,s.otherIndex)==="O")continue;return!0}}}}return!1}function cLe(e,t,r){for(var n=0,a=t.bonds,i=a.offset,o=a.edgeProps,s=o.flags,u=o.order,c=i[r],l=i[r+1];c0,m=0,h=Sa.Unknown;switch(i){case"H":s&&(c===0?(o=1,h=Sa.Spherical):c===1&&(o=0,h=Sa.Terminal));break;case"C":s&&(o=0),u&&(m=Math.max(0,4-l-Math.abs(o))),h=jv(c+m+Math.max(0,-o));break;case"N":if(s)if(!u)o=l-3;else if(f&&l<4)c-a===1&&l-a===2?o=1:o=0;else for(Oy.setElement(e,t,r);Oy.hasNext;){var p=Oy.move(),v=Lr(p.otherUnit,p.otherIndex);if(v==="S"||oZ(v)){o=0;break}else o=1}u&&(m=Math.max(0,3-l+o)),f&&!d?h=jv(c+m-o):h=jv(c+m+1-o);break;case"O":if(s&&(u||(o=l-2),l===1)){Oy.setElement(e,t,r);e:for(;Oy.hasNext;){var g=Oy.move();for(QF.setElement(e,g.otherUnit,g.otherIndex);QF.hasNext;){var b=QF.move();if(!(b.otherUnit===t&&b.otherIndex===r)&&Lr(b.otherUnit,b.otherIndex)==="O"&&b.order===2){o=-1;break e}}}}u&&(m=Math.max(0,2-l+o)),f&&!d?h=jv(c+m-o+1):h=jv(c+m-o+2);break;case"S":s&&(u||(l<=3&&as(e,t,r,"O")===0?o=l-2:o=0)),u&&l<2&&(m=Math.max(0,2-l+o)),l<=3&&(h=jv(c+m-o+2));break;case"F":case"CL":case"BR":case"I":case"AT":s&&(o=l-1);break;case"LI":case"NA":case"K":case"RB":case"CS":case"FR":s&&(o=1-l);break;case"BE":case"MG":case"CA":case"SR":case"BA":case"RA":s&&(o=2-l);break;default:or&&console.warn("Requested charge, protonation for an unhandled element",i)}return[o,m,m+a,h]}function fLe(e,t,r){var n=t.elements.length,a=new Int8Array(n),i=new Int8Array(n),o=new Int8Array(n),s=new Int8Array(n),u=!!e.parent,c;if(u){var l=e.root.unitMap.get(t.id);if(c=Fe.indicesOf(l.elements,t.elements),c.length!==t.elements.length)throw new Error("expected to find an index for every element");t=l,e=e.root}for(var f=0;fm)){for(var h=c[d],p=c[d+1];hm)){for(var h=c[d],p=c[d+1];h1&&t.unit.residueIndex[t.unit.elements[n]]===r.unit.residueIndex[r.unit.elements[a]]||mre(e,t.unit,n,r.unit,a))}function bre(e,t,r,n){var a=eS(e,t),i=eS(r,n);return a&&i&&a!==i}function xre(e,t){for(var r=t.feature,n=t.offsets,a=t.members,i=n[r],o=n[r+1];iS)){var A=d.find(p[0],p[1],p[2],v),E=A.indices,I=A.count,R=A.squaredDistances;if(I!==0){C.feature=T;for(var B=0;Bn.angleMax)){var d=By(e,u.unit,l,s.unit,c);if(d.length!==0&&!d.some(function(m){return wLe-m>n.angleMax}))return Cr.HalogenBond}}}var Are=Ln.Provider([6],yLe),Dre=Ln.Provider([7],SLe),Pre={name:"halogen-bonds",params:vLe,createTester:function(e){var t=TLe(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([6,7]),getType:function(r,n,a){return ALe(r,n,a,t)}}}};var Rre={distanceMax:w.Numeric(3.5,{min:1,max:5,step:.1}),backbone:w.Boolean(!0,{description:"Include backbone-to-backbone hydrogen bonds"}),accAngleDevMax:w.Numeric(45,{min:0,max:180,step:1},{description:"Max deviation from ideal acceptor angle"}),donAngleDevMax:w.Numeric(45,{min:0,max:180,step:1},{description:"Max deviation from ideal donor angle"}),accOutOfPlaneAngleMax:w.Numeric(90,{min:0,max:180,step:1}),donOutOfPlaneAngleMax:w.Numeric(45,{min:0,max:180,step:1})},DLe=P(P({},Rre),{water:w.Boolean(!1,{description:"Include water-to-water hydrogen bonds"}),sulfurDistanceMax:w.Numeric(4.1,{min:1,max:5,step:.1})}),PLe=P({},Rre);function nL(e,t){var r=Xf.get(e).value;if(!r)throw Error("expected valence model to be available");var n=r.get(t.id);if(!n)throw Error("expected valence model for unit to be available");return n}function ELe(e,t,r){for(var n=nL(e,t).totalH,a=t.elements,i=t.model.atomicConformation,o=i.x,s=i.y,u=i.z,c=0,l=a.length;c0&&(f==="N"||f==="O"||f==="S"))&&r.add(4,mn.None,o[a[c]],s[a[c]],u[a[c]],c)}}function ILe(e,t,r){for(var n=nL(e,t).totalH,a=t.elements,i=t.model.atomicConformation,o=i.x,s=i.y,u=i.z,c=0,l=a.length;c0&&(as(e,t,c,"N")>0||as(e,t,c,"O")>0||MLe(t,c))&&r.add(9,mn.None,o[a[c]],s[a[c]],u[a[c]],c)}function MLe(e,t){var r=e.rings,n=r.elementAromaticRingIndices,a=r.all,i=n.get(t);if(i===void 0)return!1;for(var o=0,s=i.length;on.maxDonAngleDev})){if(t.idealGeometry[a]===Sa.Trigonal){var u=XF(e,t.unit,a,r.unit,i);if(u!==void 0&&u>n.maxDonOutOfPlaneAngle)return}var c=By(e,r.unit,i,t.unit,a),l=YF.get(r.idealGeometry[i])||Mre;if(!c.some(function(f){return l-f>n.maxAccAngleDev})){if(r.idealGeometry[i]===Sa.Trigonal){var u=XF(e,r.unit,i,t.unit,a);if(u!==void 0&&u>n.maxAccOutOfPlaneAngle)return}return!0}}}}function ULe(e,t,r,n,a){var i=t.types[t.feature],o=r.types[r.feature];if(LLe(i,o)){var s=o===5?[t,r]:[r,t],u=s[0],c=s[1],l=u.members[u.offsets[u.feature]],f=c.members[c.offsets[c.feature]],d=Lr(u.unit,l)==="S"||Lr(c.unit,f)==="S"?a.maxSulfurDistSq:a.maxDistSq;if(!(n>d)&&!(!a.includeWater&&FLe(u.unit,l,c.unit,f))&&Fre(e,u,c,a))return Cr.HydrogenBond}}function VLe(e,t,r,n,a){var i=t.types[t.feature],o=r.types[r.feature];if(kLe(i,o)){var s=o===5?[t,r]:[r,t],u=s[0],c=s[1];if(Fre(e,u,c,a))return Cr.WeakHydrogenBond}}var Lre=Ln.Provider([4],ELe),kre=Ln.Provider([9],ILe),Nre=Ln.Provider([5],RLe),Ure={name:"hydrogen-bonds",params:DLe,createTester:function(e){var t=Math.max(e.distanceMax,e.sulfurDistanceMax),r=NLe(e);return{maxDistance:t,requiredFeatures:new Set([4,5]),getType:function(n,a,i,o){return ULe(n,a,i,o,r)}}}},Vre={name:"weak-hydrogen-bonds",params:PLe,createTester:function(e){var t=Ore(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([9,5]),getType:function(r,n,a,i){return VLe(r,n,a,i,t)}}}};function Gre(e,t,r){return Lr(t,r)==="S"&&as(e,t,r,"O")===3}function zre(e,t,r){return Lr(t,r)==="S"&&as(e,t,r,"O")===4}function aL(e,t,r){return Lr(t,r)==="P"&&as(e,t,r,"O")===Nu(e,t,r)}function Hre(e,t,r){var n=0;return Lr(t,r)==="C"&&as(e,t,r,"O")===2&&as(e,t,r,"C")===1&&ao(e,t,r,function(a,i){Lr(a,i)==="O"&&Nu(e,a,i)-as(e,a,i,"H")===1&&(n+=1)}),n===2}function jre(e,t,r){var n=0;return Lr(t,r)==="C"&&Nu(e,t,r)===3&&as(e,t,r,"N")===3&&ao(e,t,r,function(a,i){Nu(e,a,i)-as(e,a,i,"H")===1&&(n+=1)}),n===2}function qre(e,t,r){var n=0;return Lr(t,r)==="C"&&Nu(e,t,r)===3&&as(e,t,r,"N")===2&&as(e,t,r,"C")===1&&ao(e,t,r,function(a,i){Nu(e,a,i)-as(e,a,i,"H")===1&&(n+=1)}),n===2}var GLe=new Set(["N","O","S","F","CL","BR","I"]);function zLe(e){return GLe.has(e)}function Wre(e,t,r){var n=!1;return ao(e,t,r,function(a,i){zLe(Lr(a,i))&&(n=!0)}),n}var HLe={distanceMax:w.Numeric(5,{min:0,max:8,step:.1})},jLe={distanceMax:w.Numeric(5.5,{min:1,max:8,step:.1}),offsetMax:w.Numeric(2,{min:0,max:4,step:.1}),angleDevMax:w.Numeric(30,{min:0,max:180,step:1})},qLe={distanceMax:w.Numeric(6,{min:1,max:8,step:.1}),offsetMax:w.Numeric(2,{min:0,max:4,step:.1})},WLe=["ARG","HIS","LYS"],YLe=["GLU","ASP"];function Zre(e,t){var r=Xf.get(e).value;if(!r)throw Error("expected valence model to be available");var n=r.get(t.id);if(!n)throw Error("expected valence model for unit to be available");return n}function XLe(e,t,r){for(var n=Zre(e,t).charge,a=t.elements,i=t.model.atomicConformation,o=i.x,s=i.y,u=i.z,c=new Set,l=t.model.atomicHierarchy.atoms.label_comp_id,f=qt.transientSegments(t.model.atomicHierarchy.residueAtomSegments,a);f.hasNext;){var d=f.move(),m=d.index,h=d.start,p=d.end,v=l.value(t.model.atomicHierarchy.residueAtomSegments.offsets[m]);if(WLe.includes(v)){r.startState();for(var g=h;g0&&!c.has(g)&&r.add(1,mn.None,o[a[g]],s[a[g]],u[a[g]],g)}}}function KLe(e,t,r){for(var n=Zre(e,t).charge,a=t.elements,i=t.model.atomicConformation,o=i.x,s=i.y,u=i.z,c=new Set,l=t.model.atomicHierarchy.atoms.label_comp_id,f=qt.transientSegments(t.model.atomicHierarchy.residueAtomSegments,a);f.hasNext;){var d=f.move(),m=d.index,h=d.start,p=d.end,v=l.value(t.model.atomicHierarchy.residueAtomSegments.offsets[m]);if(YLe.includes(v)){r.startState();for(var g=h;g=a4e-a.angleDevMax)return Cr.PiStacking;if(s<=a.angleDevMax+Kre&&s>=Kre-a.angleDevMax)return Cr.PiStacking}}}function s4e(e,t,r,n,a){var i=t.types[t.feature],o=r.types[r.feature];if(JLe(i,o)){var s=i===3?[t,r]:[r,t],u=s[0],c=s[1];oL(rS,u);var l=sL(c,u,rS);if(l<=a.offsetMax)return Cr.CationPi}}var Qre=Ln.Provider([2],KLe),$re=Ln.Provider([1],XLe),Jre=Ln.Provider([3],ZLe),ene={name:"ionic",params:HLe,createTester:function(e){var t=t4e(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([2,1]),getType:function(r,n,a,i){return i4e(r,n,a,i,t)}}}},tne={name:"pi-stacking",params:jLe,createTester:function(e){var t=r4e(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([3]),getType:function(r,n,a,i){return o4e(r,n,a,i,t)}}}},rne={name:"cation-pi",params:qLe,createTester:function(e){var t=n4e(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([3,1]),getType:function(r,n,a,i){return s4e(r,n,a,i,t)}}}};var u4e={distanceMax:w.Numeric(4,{min:1,max:5,step:.1})};function c4e(e,t,r){for(var n=t.elements,a=t.model.atomicConformation,i=a.x,o=a.y,s=a.z,u=function(f,d){var m=Lr(t,f),h=!1;m==="C"?(h=!0,ao(e,t,f,function(p,v){var g=Lr(p,v);g!=="C"&&g!=="H"&&(h=!1)})):m==="F"&&(h=!0),h&&r.add(8,mn.None,i[n[f]],o[n[f]],s[n[f]],f)},c=0,l=n.length;c1||T[g+1]-T[g]>1)&&(A.granularity="residue"),[a(f,m),qx(mt.Location(l,h,S[_[p]],l,v,D[T[g]]),A)].join("
")}e.getLabel=c})(il||(il={}));var w4e=[Lre,kre,Nre,Qre,$re,Jre,Are,Dre,nne,sne,une],dA={ionic:ene,"pi-stacking":tne,"cation-pi":rne,"halogen-bonds":Pre,"hydrogen-bonds":Ure,"weak-hydrogen-bonds":Vre,hydrophobic:ane,"metal-coordination":cne};function T4e(e){e===void 0&&(e=[]);var t=Object.create(null);return Object.keys(dA).forEach(function(r){t[r]=w.MappedStatic(e.includes(r)?"on":"off",{on:w.Group(dA[r].params),off:w.Group({})},{cycle:!0})}),t}var A4e=T4e(["cation-pi","pi-stacking","hydrogen-bonds","halogen-bonds","metal-coordination"]),lL={providers:w.Group(A4e,{isFlat:!0}),contacts:w.Group(Sre,{label:"Advanced Options"})};function fne(e,t,r){return $(this,void 0,void 0,function(){var n,a,i,o,s,u,c,l,f,d,m,h,p,v,g,b;return J(this,function(x){switch(x.label){case 0:return n=P(P({},w.getDefaultValues(lL)),r),[4,Xf.attach(e,t)];case 1:x.sent(),a=[],Yh(dA).forEach(function(S){var _=n.providers[S],C=_.name,D=_.params;C==="on"&&a.push(dA[S].createTester(D))}),i=new Set,a.forEach(function(S){return dn.add(i,S.requiredFeatures)}),o=w4e.filter(function(S){return dn.areIntersecting(i,S.types)}),s=Do.Mutable(),u=Do.Mutable(),c=0,l=t.unitSymmetryGroups.length,x.label=2;case 2:return c=o?r.aTransform.ref.value:new Float32Array(o),u=0;uo?Math.sqrt(a/o):t.resolution;return P(P({},t),{resolution:s})}function O4e(e){switch(e.kind){case 0:return e.model.atomicConformation;case 1:return e.model.coarseConformation.spheres;case 2:return e.model.coarseConformation.gaussians}}var qv={ignoreHydrogens:w.Boolean(!1,{description:"Whether or not to include hydrogen atoms in the surface calculation."}),ignoreHydrogensVariant:w.Select("all",w.arrayToOptions(["all","non-polar"])),traceOnly:w.Boolean(!1,{description:"Whether or not to only use trace atoms in the surface calculation."}),includeParent:w.Boolean(!1,{description:"Include elements of the parent structure in surface calculation to get a surface patch of the current structure."})},RJt=w.getDefaultValues(qv),F4e=y();function bne(e,t,r,n){return y.squaredDistance(y.set(F4e,e,t,r),n)}function L4e(e,t,r){for(var n=0,a=t.length,i=0,o=r.length;ix||(C.push(E),D.push(T))}S=Fe.ofSortedArray(C),_=D}else S=h,_=Qi(new Int32Array(S.length));s&&u!==t&&L4e(_,t.elements,S);var I={indices:S,x:f,y:d,z:m,id:_},R=c?Iu(I):t.boundary,B=ie.Location.create(e,u),O=function(z){return B.element=z,r.size(B)};return{position:I,boundary:R,radius:O}}function ky(e,t,r){var n=r.ignoreHydrogens,a=r.ignoreHydrogensVariant,i=r.traceOnly,o=r.includeParent,s=o&&!!e.parent,u=ie.Location.create(e.root),c=e.boundary.sphere,l=c.center,f=c.radius,d=(4+1.5)*2,m=(f+d)*(f+d),h,p,v,g,b,x;if(n||i||s){for(var S=e.serialMapping.getSerialIndex,_=s?e.root.units:e.units,C=[],D=[],T=[],A=[],E=[],I=0,R=_.length;Im))if(C.push(ae),D.push(q),T.push(F),u.element=X,A.push(t.size(u)),s){var j=U?Fe.indexOf(U.elements,X):-1;j===-1?E.push(-2):E.push(S(U,X))}else E.push(S(B,X))}}}h=C,p=D,v=T,g=A,b=E,x=Ee.ofRange(0,b.length)}else{for(var Z=e.elementCount,C=new Float32Array(Z),D=new Float32Array(Z),T=new Float32Array(Z),A=new Float32Array(Z),I=0,Y=0,R=e.units.length;Ia.cylinderCount)&&U4e(d,b,x),zi.create(b,x,m,h,p,v,g,d,a)}}}e.create=t})(Ny||(Ny={}));function U4e(e,t,r){for(var n=0;n0,G=u(O),V=s?s(O):0,U=_&&(l?l(O):!1),Q=k?[U,h]:[h,U],W=Q[0],X=Q[1];if(D.currentGroup=O,V===0)B.radiusTop=B.radiusBottom=G,B.topCap=W,B.bottomCap=X,za(D,T,A,.5,B);else if(V===1)B.radiusTop=B.radiusBottom=G*x,B.topCap=B.bottomCap=S,uv(D,T,A,.5,b,U,B);else if(V===2||V===3||V===4||V===5||V===7||V===8){var ae=V===2||V===3?2:V===4||V===5?3:1.5,q=G*(f/(.5*ae)),F=(G-q)*d;if(gL(E,T,A,i?i(O):null),B.topCap=W,B.bottomCap=X,V===7||V===8){B.radiusTop=B.radiusBottom=G,za(D,T,A,.5,B);var j=G+p*G+p*G*v;os(Yn,Ni(Yn,A,T),G*.5),Wa(T,T,Yn),Ni(A,A,Yn),B.radiusTop=B.radiusBottom=G*p,B.topCap=B.bottomCap=S,os(E,E,j),Ni(T,T,E),Ni(A,A,E),uv(D,T,A,.5,g,U,B),V===8&&(os(E,E,j*2),Wa(T,T,E),Wa(A,A,E),uv(D,T,A,.5,g,U,B))}else if(V===3||V===5){var Z=G+q+f*G*d;os(E,E,Z),B.radiusTop=B.radiusBottom=G,za(D,T,A,.5,B),Xl(Yn,Yn,d*f*.2),Wa(T,T,Yn),Ni(A,A,Yn),B.radiusTop=B.radiusBottom=q,B.topCap=k?U:S,B.bottomCap=k?S:U,os(E,E,Z),Ni(T,T,E),Ni(A,A,E),za(D,T,A,.5,B),ae===3&&(os(E,E,Z*2),Wa(T,T,E),Wa(A,A,E),za(D,T,A,.5,B))}else os(E,E,F),B.radiusTop=B.radiusBottom=q,ae===3&&za(D,T,A,.5,B),_q(D,T,A,.5,E,B)}else V===6&&(Xl(Yn,Yn,.475),Wa(T,T,Yn),Ni(A,A,Yn),B.radiusTop=B.radiusBottom=G,B.topCap=W,B.bottomCap=X,za(D,T,A,.5,B))}var Y=n?xe.clone(n.boundingSphere):void 0,H=ot.getMesh(D);return R===0?{mesh:H}:(y.scale(I,I,1/R),Y&&y.distance(I,Y.center)/Y.radius<.1?{mesh:H,boundingSphere:Y}:{mesh:H})}function AA(e,t,r,n){var a=t.linkCount,i=t.referencePosition,o=t.position,s=t.style,u=t.radius,c=t.ignore,l=t.stub;if(!a)return{cylinders:zi.createEmpty(n)};for(var f=r.linkScale,d=r.linkSpacing,m=r.linkCap,h=r.aromaticScale,p=r.aromaticSpacing,v=r.aromaticDashCount,g=r.dashCount,b=r.dashScale,x=r.dashCap,S=r.stubCap,_=a*2,C=Ny.create(_,_/4,n),D=y(),T=y(),A=y(),E=y(),I=y(),R=0,B=0,O=a;B0&&(Q=xe.expand(xe(),(s??t).boundary.sphere,1*D),V.setBoundingSphere(Q)),[2,V]):[2,pt.createEmpty(i)])):[2,pt.createEmpty(i)]})})}var bL=P(P(P({},Wn),hc),PA);function zne(e){return Ca({defaultProps:w.getDefaultValues(bL),createGeometry:z4e,createLocationIterator:q4e,getLoci:H4e,eachLocation:j4e,setUpdateState:function(t,r,n,a,i,o,s){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.dashCount!==n.dashCount||r.dashScale!==n.dashScale||r.dashCap!==n.dashCap||r.radialSegments!==n.radialSegments||r.ignoreHydrogens!==n.ignoreHydrogens||r.ignoreHydrogensVariant!==n.ignoreHydrogensVariant||r.parentDisplay!==n.parentDisplay;var u=ma.get(o.structure).version;t.info.interactionsHash!==u&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.info.interactionsHash=u)}},e)}function H4e(e,t,r){var n=e.objectId,a=e.instanceId,i=e.groupId;if(r===n){var o=t.structure,s=t.group,u=o.unitMap.get(s.units[a].id),c=ma.get(o).value,l=c.unitsContacts.get(u.id),f=l.a,d=l.b;return il.Loci(o,c,[{unitA:u,indexA:f[i],unitB:u,indexB:d[i]},{unitA:u,indexA:d[i],unitB:u,indexB:f[i]}])}return Jt}var yL=new Set;function j4e(e,t,r,n){var a=!1;if(il.isLoci(e)){var i=t.structure,o=t.group;if(!Le.areEquivalent(e.data.structure,i))return!1;var s=ma.get(i).value;if(e.data.interactions!==s)return!1;for(var u=o.units[0],c=s.unitsContacts.get(u.id),l=c.edgeCount*2,f=0,d=e.elements;f0){var D=t.child,T=xe.expand(xe(),(D??t).boundary.sphere,1*f);_.setBoundingSphere(T)}return _}var SL=P(P(P({},ol),hc),PA);function Hne(e){return is({defaultProps:w.getDefaultValues(SL),createGeometry:W4e,createLocationIterator:K4e,getLoci:Y4e,eachLocation:X4e,setUpdateState:function(t,r,n,a,i,o,s){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.dashCount!==n.dashCount||r.dashScale!==n.dashScale||r.dashCap!==n.dashCap||r.radialSegments!==n.radialSegments||r.ignoreHydrogens!==n.ignoreHydrogens||r.ignoreHydrogensVariant!==n.ignoreHydrogensVariant||r.parentDisplay!==n.parentDisplay;var u=ma.get(o).version;t.info.interactionsHash!==u&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.info.interactionsHash=u)}},e)}function Y4e(e,t,r){var n=e.objectId,a=e.groupId;if(r===n){var i=ma.get(t).value,o=i.contacts.edges[a],s=t.unitMap.get(o.unitA),u=t.unitMap.get(o.unitB);return il.Loci(t,i,[{unitA:s,indexA:o.indexA,unitB:u,indexB:o.indexB},{unitA:u,indexA:o.indexB,unitB:s,indexB:o.indexA}])}return Jt}var EA=new Map,xL=new Set;function X4e(e,t,r,n){var a=!1;if(il.isLoci(e)){if(!Le.areEquivalent(e.data.structure,t))return!1;var i=ma.get(t).value;if(e.data.interactions!==i)return!1;for(var o=i.contacts,s=0,u=e.elements;s0&&ma.isApplicable(e)},ensureCustomProperties:{attach:function(e,t){return ma.attach(e,t,void 0,!0)},detach:function(e){return ma.ref(e,!1)}},getData:function(e,t){return t.includeParent?e.asParent():e},mustRecreate:function(e,t){return e.includeParent!==t.includeParent}};var Wne=_r.create({name:"computed-interactions-prop",category:"custom-props",display:{name:"Interactions"},ctor:function(e){St(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.provider=ma,r.labelProvider={label:function(n){if(r.params.showTooltip)switch(n.kind){case"element-loci":if(n.elements.length===0)return;for(var a=[],i=r.getStructures(n.structure),o=0,s=i;oTypes ".concat(m.join(", "))),h.length&&p.push("Groups ".concat(h.join(", "))),p.length&&a.push("Interaction Feature: ".concat(p.join(" | ")))}}}}}return a.length?a.join("
"):void 0;default:return}}},r}return t.prototype.getStructures=function(r){var n=[],a=this.ctx.helpers.substructureParent.get(r);if(a)for(var i=this.ctx.state.data,o=i.select(Yt.Generators.ofType(he.Molecule.Structure,a.transform.ref)),s=0,u=o;sCharge ".concat(h," | Ideal Geometry ").concat(pre(p)," | Implicit H ").concat(v," | Total H ").concat(g))}}}}}return a.length?a.join("
"):void 0;default:return}}},r}return t.prototype.getStructures=function(r){var n=[],a=this.ctx.helpers.substructureParent.get(r);if(a)for(var i=this.ctx.state.data,o=i.select(Yt.Generators.ofType(he.Molecule.Structure,a.transform.ref)),s=0,u=o;s=0&&o(c,x,h)}else if(n.coarseHierarchy.isDefined){var S=n.coarseHierarchy.spheres.findSequenceKey(v,g,b);if(S>=0)o(l,S,h);else{var _=n.coarseHierarchy.gaussians.findSequenceKey(v,g,b);_>=0&&o(f,_,h)}}}function u(h){switch(h){case 0:return c;case 1:return l;case 2:return f}}for(var c=new Map,l=new Map,f=new Map,d=[],m=0;m")}e.getLabel=h})(vc||(vc={}));function Jne(e,t,r){for(var n=t.elements,a=n.length,i=t.kind,o=function(u){var c=n[u];r.getIndicesByElement(c,i).forEach(function(l){return e.set(l,u)})},s=0;s0){var d=xe.expand(xe(),t.boundary.sphere,1*o);l.setBoundingSphere(d)}return l}var eae=P(P(P({},ol),hc),{sizeFactor:w.Numeric(.5,{min:0,max:10,step:.1})});function oke(e){return is({defaultProps:w.getDefaultValues(eae),createGeometry:ike,createLocationIterator:ske,getLoci:uke,eachLocation:cke,setUpdateState:function(t,r,n){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.radialSegments!==n.radialSegments||r.linkCap!==n.linkCap}},e)}function ske(e){var t=Zl.get(e).value,r=t.pairs,n=r.length,a=1,i=vc.Location(t,e),o=function(s){return i.element=s,i};return hr(n,a,1,o,!0)}function uke(e,t,r){var n=e.objectId,a=e.groupId;if(r===n){var i=Zl.get(t).value,o=i.pairs[a];if(o)return vc.Loci(t,i,[a])}return Jt}function cke(e,t,r){var n=!1;if(vc.isLoci(e)){if(!Le.areEquivalent(e.data.structure,t))return!1;var a=Zl.get(t).value;if(e.data.crossLinkRestraints!==a)return!1;for(var i=0,o=e.elements;i=0&&!s[pa.TargetRepr]&&(s[pa.TargetRepr]=o.to(s[pa.TargetSel]).apply(Ye.Representation.StructureRepresentation3D,this.getReprParams(this.params.targetParams),{tags:pa.TargetRepr}).ref),u.indexOf("surroundings")>=0&&!s[pa.SurrRepr]&&(s[pa.SurrRepr]=o.to(s[pa.SurrSel]).apply(Ye.Representation.StructureRepresentation3D,this.getReprParams(this.params.surroundingsParams),{tags:pa.SurrRepr}).ref),u.indexOf("interactions")>=0&&!s[pa.SurrNciRepr]&&r.obj&&Uy.isApplicable((n=r.obj)===null||n===void 0?void 0:n.data)&&(s[pa.SurrNciRepr]=o.to(s[pa.SurrSel]).apply(Ye.Representation.StructureRepresentation3D,this.getReprParams(this.params.nciParams),{tags:pa.SurrNciRepr}).ref),{state:a,builder:o,refs:s}},t.prototype.clear=function(r){var n=this.plugin.state.data;this.currentSource=void 0;var a=n.select(Yt.Generators.byRef(r).subtree().withTag(pa.TargetSel)),i=n.select(Yt.Generators.byRef(r).subtree().withTag(pa.SurrSel));if(!(a.length===0&&i.length===0)){for(var o=n.build(),s=ie.Bundle.Empty,u=0,c=a;u=0,c=0,l=a.select(o.withTag(pa.TargetRepr));c=0,f=0,d=a.select(o.withTag(pa.SurrRepr));f=0,m=0,h=a.select(o.withTag(pa.SurrNciRepr));mKke,DownloadStructure:()=>zke,EnableModelCustomProps:()=>Yke,EnableStructureCustomProps:()=>Xke,LoadTrajectory:()=>Zke,PdbDownloadProvider:()=>hae,UpdateTrajectory:()=>Wke});function ss(e){return e}(function(e){e.CommonParams={ignoreHydrogens:w.Optional(w.Boolean(!1)),ignoreHydrogensVariant:w.Optional(w.Select("all",w.arrayToOptions(["all","non-polar"]))),ignoreLight:w.Optional(w.Boolean(!1)),quality:w.Optional(w.Select("auto",sx)),theme:w.Optional(w.Group({globalName:w.Optional(w.Text("")),globalColorParams:w.Optional(w.Value({},{isHidden:!0})),carbonColor:w.Optional(w.Select("chain-id",w.arrayToOptions(["chain-id","operator-name","element-symbol"]))),symmetryColor:w.Optional(w.Text("")),symmetryColorParams:w.Optional(w.Value({},{isHidden:!0})),focus:w.Optional(w.Group({name:w.Optional(w.Text("")),params:w.Optional(w.Value({}))}))}))};function t(i){return i==="chain-id"?{name:i,params:$w.defaultValues}:i==="operator-name"?{name:i,params:by.defaultValues}:{name:i,params:{}}}function r(i){return i.units.some(function(o){return!o.conformation.operator.assembly&&o.conformation.operator.spgrOp>=0})}function n(i,o,s){var u,c,l,f,d,m,h,p,v,g,b,x,S,_,C=i.state.data.build(),D=i.builders.structure.representation,T=i.managers.structure.component.state.options.hydrogens,A={quality:i.managers.structure.component.state.options.visualQuality,ignoreHydrogens:T!=="all",ignoreHydrogensVariant:T==="only-polar"?"non-polar":"all",ignoreLight:i.managers.structure.component.state.options.ignoreLight};o.quality&&o.quality!=="auto"&&(A.quality=o.quality),o.ignoreHydrogens!==void 0&&(A.ignoreHydrogens=!!o.ignoreHydrogens),o.ignoreHydrogensVariant!==void 0&&(A.ignoreHydrogensVariant=o.ignoreHydrogensVariant),o.ignoreLight!==void 0&&(A.ignoreLight=!!o.ignoreLight);var E=!((u=o.theme)===null||u===void 0)&&u.globalName?(c=o.theme)===null||c===void 0?void 0:c.globalName:void 0,I=((l=o.theme)===null||l===void 0?void 0:l.carbonColor)!==void 0?P({carbonColor:t((f=o.theme)===null||f===void 0?void 0:f.carbonColor)},(d=o.theme)===null||d===void 0?void 0:d.globalColorParams):P({},(m=o.theme)===null||m===void 0?void 0:m.globalColorParams),R=s&&(!((h=o.theme)===null||h===void 0)&&h.symmetryColor)&&r(s)?(p=o.theme)===null||p===void 0?void 0:p.symmetryColor:E,B=!((v=o.theme)===null||v===void 0)&&v.symmetryColorParams?P(P({},(g=o.theme)===null||g===void 0?void 0:g.globalColorParams),(b=o.theme)===null||b===void 0?void 0:b.symmetryColorParams):P({},(x=o.theme)===null||x===void 0?void 0:x.globalColorParams),O=!((S=o.theme)===null||S===void 0)&&S.globalColorParams?P({},(_=o.theme)===null||_===void 0?void 0:_.globalColorParams):void 0;return{update:C,builder:D,color:E,symmetryColor:R,symmetryColorParams:B,globalColorParams:O,typeParams:A,ballAndStickColor:I}}e.reprBuilder=n;function a(i,o,s,u){if(i.state.hasBehavior(Wv))return i.state.updateBehavior(Wv,function(c){var l=uS(i,o,"ball-and-stick",s||"element-symbol",u);c.surroundingsParams.colorTheme=l,c.targetParams.colorTheme=l})}e.updateFocusRepr=a})(ss||(ss={}));var Yv=ss.CommonParams,Gy=ss.reprBuilder,zy=ss.updateFocusRepr,xke=ss({id:"preset-structure-representation-auto",display:{name:"Automatic",description:"Show representations based on the size of the structure. Smaller structures are shown with more detail than larger ones, ranging from atomistic display to coarse surfaces."},params:function(){return Yv},apply:function(e,t,r){var n,a,i=(a=(n=Xa.resolveAndCheck(r.state.data,e))===null||n===void 0?void 0:n.obj)===null||a===void 0?void 0:a.data;if(!i)return{};var o=r.config.get(Bn.Structure.SizeThresholds)||Le.DefaultSizeThresholds,s=Le.getSize(i,o),u=i.polymerResidueCount/i.polymerGapCount;switch(s){case Le.Size.Gigantic:case Le.Size.Huge:return lae.apply(e,t,r);case Le.Size.Large:return fae.apply(e,t,r);case Le.Size.Medium:if(u>3)return cae.apply(e,t,r);case Le.Size.Small:return dae.apply(e,P(P({},t),{showCarbohydrateSymbol:!0}),r);default:cr(s)}}}),Ske=ss({id:"preset-structure-representation-empty",display:{name:"Empty",description:"Removes all existing representations."},apply:function(e,t,r){return $(this,void 0,void 0,function(){return J(this,function(n){return[2,{}]})})}}),cS="Basic",cae=ss({id:"preset-structure-representation-polymer-and-ligand",display:{name:"Polymer & Ligand",group:cS,description:"Shows polymers as Cartoon, ligands as Ball & Stick, carbohydrates as 3D-SNFG and water molecules semi-transparent."},params:function(){return Yv},apply:function(e,t,r){var n,a,i,o,s,u,c,l,f,d;return $(this,void 0,void 0,function(){var m,h,p,v,g,b,x,S,_,C,D,T,A,E,I,R,B;return J(this,function(O){switch(O.label){case 0:return m=Xa.resolveAndCheck(r.state.data,e),m?(B={},[4,Gu(r,m,"polymer")]):[2,{}];case 1:return B.polymer=O.sent(),[4,Gu(r,m,"ligand")];case 2:return B.ligand=O.sent(),[4,Gu(r,m,"non-standard")];case 3:return B.nonStandard=O.sent(),[4,Gu(r,m,"branched",{label:"Carbohydrate"})];case 4:return B.branched=O.sent(),[4,Gu(r,m,"water")];case 5:return B.water=O.sent(),[4,Gu(r,m,"ion")];case 6:return B.ion=O.sent(),[4,Gu(r,m,"lipid")];case 7:return B.lipid=O.sent(),[4,Gu(r,m,"coarse")];case 8:return h=(B.coarse=O.sent(),B),p=m.obj.data,v={sizeFactor:p.isCoarseGrained?.8:.2},g=(((i=(a=(n=h.water)===null||n===void 0?void 0:n.obj)===null||a===void 0?void 0:a.data)===null||i===void 0?void 0:i.elementCount)||0)>5e4?"line":"ball-and-stick",b=(((u=(s=(o=h.lipid)===null||o===void 0?void 0:o.obj)===null||s===void 0?void 0:s.data)===null||u===void 0?void 0:u.elementCount)||0)>2e4?"line":"ball-and-stick",x=Gy(r,t,p),S=x.update,_=x.builder,C=x.typeParams,D=x.color,T=x.symmetryColor,A=x.symmetryColorParams,E=x.globalColorParams,I=x.ballAndStickColor,R={polymer:_.buildRepresentation(S,h.polymer,{type:"cartoon",typeParams:P(P({},C),v),color:T,colorParams:A},{tag:"polymer"}),ligand:_.buildRepresentation(S,h.ligand,{type:"ball-and-stick",typeParams:C,color:D,colorParams:I},{tag:"ligand"}),nonStandard:_.buildRepresentation(S,h.nonStandard,{type:"ball-and-stick",typeParams:C,color:D,colorParams:I},{tag:"non-standard"}),branchedBallAndStick:_.buildRepresentation(S,h.branched,{type:"ball-and-stick",typeParams:P(P({},C),{alpha:.3}),color:D,colorParams:I},{tag:"branched-ball-and-stick"}),branchedSnfg3d:_.buildRepresentation(S,h.branched,{type:"carbohydrate",typeParams:C,color:D,colorParams:E},{tag:"branched-snfg-3d"}),water:_.buildRepresentation(S,h.water,{type:g,typeParams:P(P({},C),{alpha:.6,visuals:g==="line"?["intra-bond","element-point"]:void 0}),color:D,colorParams:P({carbonColor:{name:"element-symbol",params:{}}},E)},{tag:"water"}),ion:_.buildRepresentation(S,h.ion,{type:"ball-and-stick",typeParams:C,color:D,colorParams:P({carbonColor:{name:"element-symbol",params:{}}},E)},{tag:"ion"}),lipid:_.buildRepresentation(S,h.lipid,{type:b,typeParams:P(P({},C),{alpha:.6,visuals:b==="line"?["intra-bond"]:void 0}),color:D,colorParams:P({carbonColor:{name:"element-symbol",params:{}}},E)},{tag:"lipid"}),coarse:_.buildRepresentation(S,h.coarse,{type:"spacefill",typeParams:C,color:D||"chain-id",colorParams:E},{tag:"coarse"})},[4,S.commit({revertOnError:!1})];case 9:return O.sent(),[4,zy(r,p,(l=(c=t.theme)===null||c===void 0?void 0:c.focus)===null||l===void 0?void 0:l.name,(d=(f=t.theme)===null||f===void 0?void 0:f.focus)===null||d===void 0?void 0:d.params)];case 10:return O.sent(),[2,{components:h,representations:R}]}})})}}),Cke=ss({id:"preset-structure-representation-protein-and-nucleic",display:{name:"Protein & Nucleic",group:cS,description:"Shows proteins as Cartoon and RNA/DNA as Gaussian Surface."},params:function(){return Yv},apply:function(e,t,r){var n,a,i,o;return $(this,void 0,void 0,function(){var s,u,c,l,f,d,m,h,p,v,g,b,x;return J(this,function(S){switch(S.label){case 0:return s=Xa.resolveAndCheck(r.state.data,e),s?(x={},[4,uae(r,s,"protein")]):[2,{}];case 1:return x.protein=S.sent(),[4,uae(r,s,"nucleic")];case 2:return u=(x.nucleic=S.sent(),x),c=s.obj.data,l={sizeFactor:c.isCoarseGrained?.8:.2},f={radiusOffset:c.isCoarseGrained?2:0,smoothness:c.isCoarseGrained?1:1.5},d=Gy(r,t,c),m=d.update,h=d.builder,p=d.typeParams,v=d.symmetryColor,g=d.symmetryColorParams,b={protein:h.buildRepresentation(m,u.protein,{type:"cartoon",typeParams:P(P({},p),l),color:v,colorParams:g},{tag:"protein"}),nucleic:h.buildRepresentation(m,u.nucleic,{type:"gaussian-surface",typeParams:P(P({},p),f),color:v,colorParams:g},{tag:"nucleic"})},[4,m.commit({revertOnError:!0})];case 3:return S.sent(),[4,zy(r,c,(a=(n=t.theme)===null||n===void 0?void 0:n.focus)===null||a===void 0?void 0:a.name,(o=(i=t.theme)===null||i===void 0?void 0:i.focus)===null||o===void 0?void 0:o.params)];case 4:return S.sent(),[2,{components:u,representations:b}]}})})}}),lae=ss({id:"preset-structure-representation-coarse-surface",display:{name:"Coarse Surface",group:cS,description:"Shows polymers and lipids as coarse Gaussian Surface."},params:function(){return Yv},apply:function(e,t,r){var n,a,i,o;return $(this,void 0,void 0,function(){var s,u,c,l,f,d,m,h,p,v,g,b,x;return J(this,function(S){switch(S.label){case 0:return s=Xa.resolveAndCheck(r.state.data,e),s?(x={},[4,Gu(r,s,"polymer")]):[2,{}];case 1:return x.polymer=S.sent(),[4,Gu(r,s,"lipid")];case 2:return u=(x.lipid=S.sent(),x),c=s.obj.data,l=Le.getSize(c),f=Object.create(null),l===Le.Size.Gigantic?Object.assign(f,{traceOnly:!c.isCoarseGrained,radiusOffset:2,smoothness:1,visuals:["structure-gaussian-surface-mesh"]}):l===Le.Size.Huge?Object.assign(f,{radiusOffset:c.isCoarseGrained?2:0,smoothness:1}):c.isCoarseGrained&&Object.assign(f,{radiusOffset:2,smoothness:1}),d=Gy(r,t,c),m=d.update,h=d.builder,p=d.typeParams,v=d.symmetryColor,g=d.symmetryColorParams,b={polymer:h.buildRepresentation(m,u.polymer,{type:"gaussian-surface",typeParams:P(P({},p),f),color:v,colorParams:g},{tag:"polymer"}),lipid:h.buildRepresentation(m,u.lipid,{type:"gaussian-surface",typeParams:P(P({},p),f),color:v,colorParams:g},{tag:"lipid"})},[4,m.commit({revertOnError:!0})];case 3:return S.sent(),[4,zy(r,c,(a=(n=t.theme)===null||n===void 0?void 0:n.focus)===null||a===void 0?void 0:a.name,(o=(i=t.theme)===null||i===void 0?void 0:i.focus)===null||o===void 0?void 0:o.params)];case 4:return S.sent(),[2,{components:u,representations:b}]}})})}}),fae=ss({id:"preset-structure-representation-polymer-cartoon",display:{name:"Polymer Cartoon",group:cS,description:"Shows polymers as Cartoon."},params:function(){return Yv},apply:function(e,t,r){var n,a,i,o;return $(this,void 0,void 0,function(){var s,u,c,l,f,d,m,h,p,v,g,b;return J(this,function(x){switch(x.label){case 0:return s=Xa.resolveAndCheck(r.state.data,e),s?(b={},[4,Gu(r,s,"polymer")]):[2,{}];case 1:return u=(b.polymer=x.sent(),b),c=s.obj.data,l={sizeFactor:c.isCoarseGrained?.8:.2},f=Gy(r,t,c),d=f.update,m=f.builder,h=f.typeParams,p=f.symmetryColor,v=f.symmetryColorParams,g={polymer:m.buildRepresentation(d,u.polymer,{type:"cartoon",typeParams:P(P({},h),l),color:p,colorParams:v},{tag:"polymer"})},[4,d.commit({revertOnError:!0})];case 2:return x.sent(),[4,zy(r,c,(a=(n=t.theme)===null||n===void 0?void 0:n.focus)===null||a===void 0?void 0:a.name,(o=(i=t.theme)===null||i===void 0?void 0:i.focus)===null||o===void 0?void 0:o.params)];case 3:return x.sent(),[2,{components:u,representations:g}]}})})}}),dae=ss({id:"preset-structure-representation-atomic-detail",display:{name:"Atomic Detail",group:cS,description:"Shows everything in atomic detail with Ball & Stick."},params:function(){return P(P({},Yv),{showCarbohydrateSymbol:w.Boolean(!1)})},apply:function(e,t,r){var n,a,i,o,s,u;return $(this,void 0,void 0,function(){var c,l,f,d,m,h,p,v,g,b,x,S,_,C,D,T,A,E,I,R,B,O,z;return J(this,function(k){switch(k.label){case 0:return c=Xa.resolveAndCheck(r.state.data,e),c?(O={},[4,Gu(r,c,"all")]):[2,{}];case 1:return l=(O.all=k.sent(),O.branched=void 0,O),f=c.obj.data,d=f.elementCount>1e5,m=f.atomicResidueCount&&f.elementCount>1e3&&f.atomicResidueCount/f.elementCount<3,h=f.models[0],p=!!$a.Provider.get(h)||bs.isExhaustive(h),v="ball-and-stick",f.isCoarseGrained?v=f.elementCount>1e6?"point":"spacefill":m&&!p?v="spacefill":d&&(v="line"),g=t.showCarbohydrateSymbol&&!d&&!m,g?(x=(b=Object).assign,S=[l],z={},[4,Gu(r,c,"branched",{label:"Carbohydrate"})]):[3,3];case 2:x.apply(b,S.concat([(z.branched=k.sent(),z)])),k.label=3;case 3:return _=Gy(r,t,f),C=_.update,D=_.builder,T=_.typeParams,A=_.color,E=_.ballAndStickColor,I=_.globalColorParams,R=m&&!p?P({carbonColor:{name:"element-symbol",params:{}}},I):E,B={all:D.buildRepresentation(C,l.all,{type:v,typeParams:T,color:A,colorParams:R},{tag:"all"})},g&&Object.assign(B,{snfg3d:D.buildRepresentation(C,l.branched,{type:"carbohydrate",typeParams:P(P({},T),{alpha:.4,visuals:["carbohydrate-symbol"]}),color:A,colorParams:I},{tag:"snfg-3d"})}),[4,C.commit({revertOnError:!0})];case 4:return k.sent(),[4,zy(r,f,(i=(a=(n=t.theme)===null||n===void 0?void 0:n.focus)===null||a===void 0?void 0:a.name)!==null&&i!==void 0?i:A,(u=(s=(o=t.theme)===null||o===void 0?void 0:o.focus)===null||s===void 0?void 0:s.params)!==null&&u!==void 0?u:R)];case 5:return k.sent(),[2,{components:l,representations:B}]}})})}}),_ke=ss({id:"preset-structure-representation-illustrative",display:{name:"Illustrative",group:"Miscellaneous",description:"..."},params:function(){return P(P({},Yv),{showCarbohydrateSymbol:w.Boolean(!1)})},apply:function(e,t,r){var n,a,i,o,s;return $(this,void 0,void 0,function(){var u,c,l,f,d,m,h,p,v,g;return J(this,function(b){switch(b.label){case 0:return u=Xa.resolveAndCheck(r.state.data,e),u?(g={},[4,Gu(r,u,"all")]):[2,{}];case 1:return c=(g.all=b.sent(),g.branched=void 0,g),l=u.obj.data,f=Gy(r,t,l),d=f.update,m=f.builder,h=f.typeParams,p=f.color,v={all:m.buildRepresentation(d,c.all,{type:"spacefill",typeParams:P(P({},h),{ignoreLight:!0}),color:"illustrative"},{tag:"all"})},[4,d.commit({revertOnError:!0})];case 2:return b.sent(),[4,zy(r,l,(i=(a=(n=t.theme)===null||n===void 0?void 0:n.focus)===null||a===void 0?void 0:a.name)!==null&&i!==void 0?i:p,(s=(o=t.theme)===null||o===void 0?void 0:o.focus)===null||s===void 0?void 0:s.params)];case 3:return b.sent(),[2,{components:c,representations:v}]}})})}});function Gu(e,t,r,n){return e.builders.structure.tryCreateComponentStatic(t,r,n)}function uae(e,t,r,n){return e.builders.structure.tryCreateComponentFromSelection(t,Ci[r],"selection-".concat(r),n)}var gc={empty:Ske,auto:xke,"atomic-detail":dae,"polymer-cartoon":fae,"polymer-and-ligand":cae,"protein-and-nucleic":Cke,"coarse-surface":lae,illustrative:_ke};function Hy(e,t){if(e.ext==="bcif")try{var r=d_(t).encoder;if(r.startsWith("VolumeServer"))return"dscif";if(r.startsWith("volseg-volume-server"))return"segcif"}catch(a){console.error(a)}else if(e.ext==="cif"){var n=t;if(n.startsWith(`data_SERVER +# +_density_server_result`))return"dscif";if(n.startsWith(`data_SERVER +# +data_SEGMENTATION_DATA`))return"segcif";if(n.includes("atom_site_fract_x")||n.includes("atom_site.fract_x"))return"coreCif"}return-1}var ul="Trajectory";function am(e,t){return e.builders.structure.hierarchy.applyPreset(t.trajectory,"default")}var wke={label:"mmCIF",description:"mmCIF",category:ul,stringExtensions:["cif","mmcif","mcif"],binaryExtensions:["bcif"],isApplicable:function(e,t){return e.ext==="mmcif"||e.ext==="mcif"?!0:e.ext==="cif"||e.ext==="bcif"?Hy(e,t)===-1:!1},parse:function(e,t,r){return $(void 0,void 0,void 0,function(){var n,a,i,o,s;return J(this,function(u){switch(u.label){case 0:return n=e.state.data,a=n.build().to(t).apply(Ye.Data.ParseCif,void 0,{state:{isGhost:!0}}),[4,a.apply(Ye.Model.TrajectoryFromMmCif,void 0,{tags:r?.trajectoryTags}).commit({revertOnError:!0})];case 1:return i=u.sent(),(((s=(o=a.selector.cell)===null||o===void 0?void 0:o.obj)===null||s===void 0?void 0:s.data.blocks.length)||0)>1&&e.state.data.updateCellState(a.ref,{isGhost:!1}),[2,{trajectory:i}]}})})},visuals:am},Tke={label:"cifCore",description:"CIF Core",category:ul,stringExtensions:["cif"],isApplicable:function(e,t){return e.ext==="cif"?Hy(e,t)==="coreCif":!1},parse:function(e,t,r){return $(void 0,void 0,void 0,function(){var n,a,i,o,s;return J(this,function(u){switch(u.label){case 0:return n=e.state.data,a=n.build().to(t).apply(Ye.Data.ParseCif,void 0,{state:{isGhost:!0}}),[4,a.apply(Ye.Model.TrajectoryFromCifCore,void 0,{tags:r?.trajectoryTags}).commit({revertOnError:!0})];case 1:return i=u.sent(),(((s=(o=a.selector.cell)===null||o===void 0?void 0:o.obj)===null||s===void 0?void 0:s.data.blocks.length)||0)>1&&e.state.data.updateCellState(a.ref,{isGhost:!1}),[2,{trajectory:i}]}})})},visuals:am};function Xv(e,t){var r=this;return function(n,a,i){return $(r,void 0,void 0,function(){var o,s;return J(this,function(u){switch(u.label){case 0:return o=n.state.data,[4,o.build().to(a).apply(e,t,{tags:i?.trajectoryTags}).commit({revertOnError:!0})];case 1:return s=u.sent(),[2,{trajectory:s}]}})})}}var Ake={label:"PDB",description:"PDB",category:ul,stringExtensions:["pdb","ent"],parse:Xv(Ye.Model.TrajectoryFromPDB),visuals:am},Dke={label:"PDBQT",description:"PDBQT",category:ul,stringExtensions:["pdbqt"],parse:Xv(Ye.Model.TrajectoryFromPDB,{isPdbqt:!0}),visuals:am},Pke={label:"XYZ",description:"XYZ",category:ul,stringExtensions:["xyz"],parse:Xv(Ye.Model.TrajectoryFromXYZ),visuals:am},Eke={label:"GRO",description:"GRO",category:ul,stringExtensions:["gro"],binaryExtensions:[],parse:Xv(Ye.Model.TrajectoryFromGRO),visuals:am},Ike={label:"MOL",description:"MOL",category:ul,stringExtensions:["mol"],parse:Xv(Ye.Model.TrajectoryFromMOL),visuals:am},Mke={label:"SDF",description:"SDF",category:ul,stringExtensions:["sdf","sd"],parse:Xv(Ye.Model.TrajectoryFromSDF),visuals:am},Rke={label:"MOL2",description:"MOL2",category:ul,stringExtensions:["mol2"],parse:Xv(Ye.Model.TrajectoryFromMOL2),visuals:am},MA=[["mmcif",wke],["cifCore",Tke],["pdb",Ake],["pdbqt",Dke],["gro",Eke],["xyz",Pke],["mol",Ike],["sdf",Mke],["mol2",Rke]];var Bke=["gz","zip"];function Zf(e){var t=e,r="",n=t.lastIndexOf("?"),a=n!==-1?t.substring(n):"";t=t.substring(0,n===-1?t.length:n);var i=t.replace(/^.*[\\/]/,""),o=i.substring(0,i.lastIndexOf(".")),s=i.split("."),u=s.length>1?(s.pop()||"").toLowerCase():"",c=t.match(/^(.+):\/\/(.+)$/);c&&(r=c[1].toLowerCase(),t=c[2]||"");var l=t.substring(0,t.lastIndexOf("/")+1);if(Bke.includes(u)){var f=t.length-u.length-1;u=(t.substr(0,f).split(".").pop()||"").toLowerCase();var d=o.length-u.length-1;o=o.substr(0,d)}return{path:t,name:i,ext:u,base:o,dir:l,protocol:r,query:a}}var jy="Topology";var Oke={label:"PSF",description:"PSF",category:jy,stringExtensions:["psf"],parse:function(e,t){return $(void 0,void 0,void 0,function(){var r,n;return J(this,function(a){switch(a.label){case 0:return r=e.state.data.build().to(t).apply(Ye.Data.ParsePsf,{},{state:{isGhost:!0}}),n=r.apply(Ye.Model.TopologyFromPsf),[4,r.commit()];case 1:return a.sent(),[2,{format:r.selector,topology:n.selector}]}})})}};var Fke={label:"PRMTOP",description:"PRMTOP",category:jy,stringExtensions:["prmtop","parm7"],parse:function(e,t){return $(void 0,void 0,void 0,function(){var r,n;return J(this,function(a){switch(a.label){case 0:return r=e.state.data.build().to(t).apply(Ye.Data.ParsePrmtop,{},{state:{isGhost:!0}}),n=r.apply(Ye.Model.TopologyFromPrmtop),[4,r.commit()];case 1:return a.sent(),[2,{format:r.selector,topology:n.selector}]}})})}};var Lke={label:"TOP",description:"TOP",category:jy,stringExtensions:["top"],parse:function(e,t){return $(void 0,void 0,void 0,function(){var r,n;return J(this,function(a){switch(a.label){case 0:return r=e.state.data.build().to(t).apply(Ye.Data.ParseTop,{},{state:{isGhost:!0}}),n=r.apply(Ye.Model.TopologyFromTop),[4,r.commit()];case 1:return a.sent(),[2,{format:r.selector,topology:n.selector}]}})})}},mae=[["psf",Oke],["prmtop",Fke],["top",Lke]];var Kv="Coordinates";var kke={label:"DCD",description:"DCD",category:Kv,binaryExtensions:["dcd"],parse:function(e,t){var r=e.state.data.build().to(t).apply(Ye.Model.CoordinatesFromDcd);return r.commit()}};var Nke={label:"XTC",description:"XTC",category:Kv,binaryExtensions:["xtc"],parse:function(e,t){var r=e.state.data.build().to(t).apply(Ye.Model.CoordinatesFromXtc);return r.commit()}};var Uke={label:"TRR",description:"TRR",category:Kv,binaryExtensions:["trr"],parse:function(e,t){var r=e.state.data.build().to(t).apply(Ye.Model.CoordinatesFromTrr);return r.commit()}};var Vke={label:"NCTRAJ",description:"NCTRAJ",category:Kv,binaryExtensions:["nc","nctraj"],parse:function(e,t){var r=e.state.data.build().to(t).apply(Ye.Model.CoordinatesFromNctraj);return r.commit()}},pae=[["dcd",kke],["xtc",Nke],["trr",Uke],["nctraj",Vke]];var Gke=function(e){var t=e.config.get(Bn.Structure.DefaultRepresentationPreset)||gc.auto.id;return w.Group({type:Hf.getParams(void 0,"auto").type,representation:w.Select(t,e.builders.structure.representation.getPresets().map(function(r){return[r.id,r.display.name,r.display.group]}),{description:"Which representation preset to use."}),representationParams:w.Group(ss.CommonParams,{isHidden:!0}),asTrajectory:w.Optional(w.Boolean(!1,{description:"Load all entries into a single trajectory."}))},{isExpanded:!1})},hae={rcsb:w.Group({encoding:w.Select("bcif",w.arrayToOptions(["cif","bcif"]))},{label:"RCSB PDB",isFlat:!0}),pdbe:w.Group({variant:w.Select("updated-bcif",[["updated-bcif","Updated (bcif)"],["updated","Updated"],["archival","Archival"]])},{label:"PDBe",isFlat:!0}),pdbj:w.EmptyGroup({label:"PDBj"})};var zke=go.build({from:he.Root,display:{name:"Download Structure",description:"Load a structure from the provided source and create its representation."},params:function(e,t){var r=Gke(t),n=t.config.get(Bn.Download.DefaultPdbProvider)||"pdbe";return{source:w.MappedStatic("pdb",{pdb:w.Group({provider:w.Group({id:w.Text("1tqn",{label:"PDB Id(s)",description:"One or more comma/space separated PDB ids."}),server:w.MappedStatic(n,hae)},{pivot:"id"}),options:r},{isFlat:!0,label:"PDB"}),"pdb-dev":w.Group({provider:w.Group({id:w.Text("PDBDEV_00000001",{label:"PDB-Dev Id(s)",description:"One or more comma/space separated ids."}),encoding:w.Select("bcif",w.arrayToOptions(["cif","bcif"]))},{pivot:"id"}),options:r},{isFlat:!0,label:"PDB-Dev"}),swissmodel:w.Group({id:w.Text("Q9Y2I8",{label:"UniProtKB AC(s)",description:"One or more comma/space separated ACs."}),options:r},{isFlat:!0,label:"SWISS-MODEL",description:"Loads the best homology model or experimental structure"}),alphafolddb:w.Group({id:w.Text("Q8W3K0",{label:"UniProtKB AC(s)",description:"One or more comma/space separated ACs."}),options:r},{isFlat:!0,label:"AlphaFold DB",description:"Loads the predicted model if available"}),modelarchive:w.Group({id:w.Text("ma-bak-cepc-0003",{label:"Accession Code(s)",description:"One or more comma/space separated ACs."}),options:r},{isFlat:!0,label:"Model Archive"}),pubchem:w.Group({id:w.Text("2244,2245",{label:"PubChem ID",description:"One or more comma/space separated IDs."}),options:r},{isFlat:!0,label:"PubChem",description:"Loads 3D conformer from PubChem."}),url:w.Group({url:w.Url(""),format:w.Select("mmcif",w.arrayToOptions(MA.map(function(a){return a[0]}),function(a){return a})),isBinary:w.Boolean(!1),label:w.Optional(w.Text("")),options:r},{isFlat:!0,label:"URL"})})}}})(function(e,t){var r=e.params,n=e.state;return Ce.create("Download Structure",function(a){return $(void 0,void 0,void 0,function(){var i,o,s,u,c,l,f,d;return J(this,function(m){switch(m.label){case 0:switch(t.behaviors.layout.leftPanelTabName.next("data"),i=r.source,s=!1,u="mmcif",c=i.name,c){case"url":return[3,1];case"pdb":return[3,2];case"pdb-dev":return[3,4];case"swissmodel":return[3,6];case"alphafolddb":return[3,8];case"modelarchive":return[3,10];case"pubchem":return[3,12]}return[3,14];case 1:return o=[{url:i.params.url,isBinary:i.params.isBinary,label:i.params.label||void 0}],u=i.params.format,[3,15];case 2:return[4,i.params.provider.server.name==="pdbe"?Hke(i):i.params.provider.server.name==="pdbj"?jke(i):i.params.provider.server.name==="rcsb"?qke(i):cr(i)];case 3:return o=m.sent(),s=!!i.params.options.asTrajectory,[3,15];case 4:return[4,Ql(i.params.provider.id,function(h){var p=h.toUpperCase().startsWith("PDBDEV_")?h:"PDBDEV_".concat(h.padStart(8,"0"));return i.params.provider.encoding==="bcif"?"https://pdb-dev.wwpdb.org/bcif/".concat(p.toUpperCase(),".bcif"):"https://pdb-dev.wwpdb.org/cif/".concat(p.toUpperCase(),".cif")},function(h){return h.toUpperCase().startsWith("PDBDEV_")?h:"PDBDEV_".concat(h.padStart(8,"0"))},i.params.provider.encoding==="bcif")];case 5:return o=m.sent(),s=!!i.params.options.asTrajectory,[3,15];case 6:return[4,Ql(i.params.id,function(h){return"https://swissmodel.expasy.org/repository/uniprot/".concat(h.toUpperCase(),".pdb")},function(h){return"SWISS-MODEL: ".concat(h)},!1)];case 7:return o=m.sent(),s=!!i.params.options.asTrajectory,u="pdb",[3,15];case 8:return[4,Ql(i.params.id,function(h){return $(void 0,void 0,void 0,function(){var p,v;return J(this,function(g){switch(g.label){case 0:return p="https://www.alphafold.ebi.ac.uk/api/prediction/".concat(h.toUpperCase()),[4,t.runTask(t.fetch({url:p,type:"json"}))];case 1:if(v=g.sent(),Array.isArray(v)&&v.length>0)return[2,v[0].cifUrl];throw new Error("No AlphaFold DB entry for '".concat(h,"'"))}})})},function(h){return"AlphaFold DB: ".concat(h)},!1)];case 9:return o=m.sent(),s=!!i.params.options.asTrajectory,u="mmcif",[3,15];case 10:return[4,Ql(i.params.id,function(h){return"https://www.modelarchive.org/doi/10.5452/".concat(h.toLowerCase(),".cif")},function(h){return"Model Archive: ".concat(h)},!1)];case 11:return o=m.sent(),s=!!i.params.options.asTrajectory,u="mmcif",[3,15];case 12:return[4,Ql(i.params.id,function(h){return"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/CID/".concat(h.trim(),"/record/SDF/?record_type=3d")},function(h){return"PubChem: ".concat(h)},!1)];case 13:return o=m.sent(),s=!!i.params.options.asTrajectory,u="mol",[3,15];case 14:cr(i),m.label=15;case 15:return l=r.source.params.options.representation||t.config.get(Bn.Structure.DefaultRepresentationPreset)||gc.auto.id,f=l!==gc.empty.id,d=i.params.options.type.name==="auto"?void 0:i.params.options.type,[4,n.transaction(function(){return $(void 0,void 0,void 0,function(){var h,S,p,v,g,b,x,S,_;return J(this,function(C){switch(C.label){case 0:return o.length>0&&s?[4,t.builders.data.downloadBlob({sources:o.map(function(D,T){return{id:""+T,url:D.url,isBinary:D.isBinary}}),maxConcurrency:6},{state:{isGhost:!0}})]:[3,4];case 1:return h=C.sent(),[4,t.builders.structure.parseTrajectory(h,{formats:o.map(function(D,T){return{id:""+T,format:"cif"}})})];case 2:return S=C.sent(),[4,t.builders.structure.hierarchy.applyPreset(S,"default",{structure:d,showUnitcell:f,representationPreset:l,representationPresetParams:r.source.params.options.representationParams})];case 3:return C.sent(),[3,10];case 4:p=0,v=o,C.label=5;case 5:return p=4||/^[1-9][0-9]*$/.test(p))}),i=[],o=0,s=a,h.label=1;case 1:return oML,DownloadDensity:()=>Qke});var Qke=go.build({from:he.Root,display:{name:"Download Density",description:"Load a density from the provided source and create its default visual."},params:function(e,t){var r=t.dataFormats.options;return{source:w.MappedStatic("pdb-xray",{"pdb-xray":w.Group({provider:w.Group({id:w.Text("1tqn",{label:"Id"}),server:w.Select("rcsb",[["pdbe","PDBe"],["rcsb","RCSB PDB"]])},{pivot:"id"}),type:w.Select("2fofc",[["2fofc","2Fo-Fc"],["fofc","Fo-Fc"]])},{isFlat:!0}),"pdb-xray-ds":w.Group({provider:w.Group({id:w.Text("1tqn",{label:"Id"}),server:w.Select("pdbe",[["pdbe","PDBe"],["rcsb","RCSB PDB"]])},{pivot:"id"}),detail:w.Numeric(3,{min:0,max:6,step:1},{label:"Detail"})},{isFlat:!0}),"pdb-emd-ds":w.Group({provider:w.Group({id:w.Text("emd-8004",{label:"Id"}),server:w.Select("pdbe",[["pdbe","PDBe"],["rcsb","RCSB PDB"]])},{pivot:"id"}),detail:w.Numeric(3,{min:0,max:6,step:1},{label:"Detail"})},{isFlat:!0}),url:w.Group({url:w.Url(""),isBinary:w.Boolean(!1),format:w.Select("auto",r)},{isFlat:!0})},{options:[["pdb-xray","PDB X-ray maps"],["pdb-emd-ds","PDB EMD Density Server"],["pdb-xray-ds","PDB X-ray Density Server"],["url","URL"]]})}}})(function(e,t){var r=e.params;return Ce.create("Download Density",function(n){return $(void 0,void 0,void 0,function(){var a,i,o,s,u,c,l,f;return J(this,function(d){switch(d.label){case 0:switch(a=r.source,a.name){case"url":i=a.params;break;case"pdb-xray":i=a.params.provider.server==="pdbe"?{url:Ur.Url(a.params.type==="2fofc"?"https://www.ebi.ac.uk/pdbe/coordinates/files/".concat(a.params.provider.id.toLowerCase(),".ccp4"):"https://www.ebi.ac.uk/pdbe/coordinates/files/".concat(a.params.provider.id.toLowerCase(),"_diff.ccp4")),isBinary:!0,label:"PDBe X-ray map: ".concat(a.params.provider.id)}:{url:Ur.Url(a.params.type==="2fofc"?"https://edmaps.rcsb.org/maps/".concat(a.params.provider.id.toLowerCase(),"_2fofc.dsn6"):"https://edmaps.rcsb.org/maps/".concat(a.params.provider.id.toLowerCase(),"_fofc.dsn6")),isBinary:!0,label:"RCSB X-ray map: ".concat(a.params.provider.id)};break;case"pdb-emd-ds":i=a.params.provider.server==="pdbe"?{url:Ur.Url("https://www.ebi.ac.uk/pdbe/densities/emd/".concat(a.params.provider.id.toLowerCase(),"/cell?detail=").concat(a.params.detail)),isBinary:!0,label:"PDBe EMD Density Server: ".concat(a.params.provider.id)}:{url:Ur.Url("https://maps.rcsb.org/em/".concat(a.params.provider.id.toLowerCase(),"/cell?detail=").concat(a.params.detail)),isBinary:!0,label:"RCSB PDB EMD Density Server: ".concat(a.params.provider.id)};break;case"pdb-xray-ds":i=a.params.provider.server==="pdbe"?{url:Ur.Url("https://www.ebi.ac.uk/pdbe/densities/x-ray/".concat(a.params.provider.id.toLowerCase(),"/cell?detail=").concat(a.params.detail)),isBinary:!0,label:"PDBe X-ray Density Server: ".concat(a.params.provider.id)}:{url:Ur.Url("https://maps.rcsb.org/x-ray/".concat(a.params.provider.id.toLowerCase(),"/cell?detail=").concat(a.params.detail)),isBinary:!0,label:"RCSB PDB X-ray Density Server: ".concat(a.params.provider.id)};break;default:cr(a)}return[4,t.builders.data.download(i)];case 1:switch(s=d.sent(),u=void 0,a.name){case"url":i=a.params,o=a.params.format==="auto"?t.dataFormats.auto(Zf(Ur.getUrl(i.url)),(l=s.cell)===null||l===void 0?void 0:l.obj):t.dataFormats.get(a.params.format);break;case"pdb-xray":u=a.params.provider.id,o=a.params.provider.server==="pdbe"?t.dataFormats.get("ccp4"):t.dataFormats.get("dsn6");break;case"pdb-emd-ds":case"pdb-xray-ds":u=a.params.provider.id,o=t.dataFormats.get("dscif");break;default:cr(a)}return o?[4,o.parse(t,s,{entryId:u})]:(t.log.warn("DownloadDensity: Format provider not found."),[2]);case 2:return c=d.sent(),[4,(f=o.visuals)===null||f===void 0?void 0:f.call(o,t,c)];case 3:return d.sent(),[2]}})})})}),ML=go.build({display:{name:"Assign Volume Colors",description:"Assigns another volume to be available for coloring."},from:he.Volume.Data,isApplicable:function(e){return!e.data.colorVolume},params:function(e,t){var r=t.state.data.select(Yt.Generators.root.subtree().ofType(he.Volume.Data).filter(function(n){var a;return!!n.obj&&!(!((a=n.obj)===null||a===void 0)&&a.data.colorVolume)&&n.obj!==e}));return r.length===0?{ref:w.Text("",{isHidden:!0,label:"Volume"})}:{ref:w.Select(r[0].transform.ref,r.map(function(n){return[n.transform.ref,n.obj.label]}),{label:"Volume"})}}})(function(e,t){var r=e.ref,n=e.params,a=e.state;return t.build().to(r).apply(Ye.Volume.AssignColorVolume,{ref:n.ref},{dependsOn:[n.ref]}).commit()});var OL={};fi(OL,{DownloadFile:()=>$ke,OpenFiles:()=>BL});function RA(e,t,r,n){var a,i,o,s;return $(this,void 0,void 0,function(){var u,c,l,f,d;return J(this,function(m){switch(m.label){case 0:return u=Zf((i=(a=e.file)===null||a===void 0?void 0:a.name)!==null&&i!==void 0?i:""),c=t.dataFormats.binaryExtensions.has(u.ext),[4,t.builders.data.readFile({file:e,isBinary:c})];case 1:return l=m.sent().data,f=r==="auto"?t.dataFormats.auto(u,(o=l.cell)===null||o===void 0?void 0:o.obj):t.dataFormats.get(r),f?[3,3]:(t.log.warn("OpenFiles: could not find data provider for '".concat(u.ext,"'")),[4,t.state.data.build().delete(l).commit()]);case 2:return m.sent(),[2];case 3:return[4,f.parse(t,l)];case 4:return d=m.sent(),n?[4,(s=f.visuals)===null||s===void 0?void 0:s.call(f,t,d)]:[3,6];case 5:m.sent(),m.label=6;case 6:return[2]}})})}var BL=go.build({display:{name:"Open Files",description:"Load one or more files and optionally create default visuals"},from:he.Root,params:function(e,t){var r=t.dataFormats,n=r.extensions,a=r.options;return{files:w.FileList({accept:Array.from(n.values()).map(function(i){return".".concat(i)}).join(",")+",.gz,.zip",multiple:!0}),format:w.MappedStatic("auto",{auto:w.EmptyGroup(),specific:w.Select(a[0][0],a)}),visuals:w.Boolean(!0,{description:"Add default visuals"})}}})(function(e,t){var r=e.params,n=e.state;return Ce.create("Open Files",function(a){return $(void 0,void 0,void 0,function(){return J(this,function(i){switch(i.label){case 0:return t.behaviors.layout.leftPanelTabName.next("data"),[4,n.transaction(function(){return $(void 0,void 0,void 0,function(){var o,s,u,c,l,f,d,m,h,p,v,g,b,x;return J(this,function(S){switch(S.label){case 0:if(r.files===null)return t.log.error("No file(s) selected"),[2];o=0,s=r.files,S.label=1;case 1:if(!(o=o.capacity){var l=o.entries.first;c=l.value.data,o.entries.remove(l)}return o.entries.addLast(t(s,u)),c}e.set=a;function i(o,s){for(var u=o.entries.first;u;u=u.next)if(u.value.key===s){o.entries.remove(u);break}}e.remove=i})(qy||(qy={}));var xae=function(){function e(t){t===void 0&&(t=!1),this.isRunning=!1,this.queue=[],this.counter=0,this.log=t}return e.prototype.enqueue=function(t){this.log&&console.log("SingleAsyncQueue enqueue",this.counter),this.queue[0]={id:this.counter,func:t},this.counter++,this.run()},e.prototype.run=function(){return $(this,void 0,void 0,function(){var t;return J(this,function(r){switch(r.label){case 0:if(this.isRunning)return[2];if(t=this.queue.pop(),!t)return[2];this.isRunning=!0,r.label=1;case 1:return r.trys.push([1,,3,4]),this.log&&console.log("SingleAsyncQueue run",t.id),[4,t.func()];case 2:return r.sent(),this.log&&console.log("SingleAsyncQueue complete",t.id),[3,4];case 3:return this.isRunning=!1,this.run(),[7];case 4:return[2]}})})},e}();var uu=function(e){St(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(he.CreateBehavior({name:"Volume Streaming"}));(function(e){e.RootTag="volume-streaming-info";function t(u,c,l,f,d){var m,h,p,v;return d===void 0&&(d={}),w.Group({isoValue:Je.createIsoValueParam((m=d.isoValue)!==null&&m!==void 0?m:l,f),color:w.Color((h=d.color)!==null&&h!==void 0?h:c),wireframe:w.Boolean((p=d.wireframe)!==null&&p!==void 0?p:!1),opacity:w.Numeric((v=d.opacity)!==null&&v!==void 0?v:.3,{min:0,max:1,step:.01})},{label:u,isExpanded:!0})}var r={byteOffset:0,rate:1,sampleCount:[1,1,1],valuesInfo:[{mean:0,min:-1,max:1,sigma:.1},{mean:0,min:-1,max:1,sigma:.1}]};function n(u){u===void 0&&(u={});var c=u.data,l=u.defaultView,f=u.channelParams,d=new Map;c&&c.entries.forEach(function(p){return d.set(p.dataId,p)});var m=c?c.entries.map(function(p){return[p.dataId,p.dataId]}):[],h=c?c.entries[0].dataId:"";return{entry:w.Mapped(h,m,function(p){return w.Group(a({entryData:d.get(p),defaultView:l,structure:c&&c.structure,channelParams:f}))})}}e.createParams=n;function a(u){var c=u.entryData,l=u.defaultView,f=u.structure,d=u.channelParams,m=d===void 0?{}:d,h=c||{kind:"em",header:{sampling:[r],availablePrecisions:[{precision:0,maxVoxels:0}]},emDefaultContourLevel:Je.IsoValue.relative(0)},p=f&&f.boundary.box||gt();return{view:w.MappedStatic(l||(h.kind==="em"?"auto":"selection-box"),{off:w.Group({}),box:w.Group({bottomLeft:w.Vec3(p.min),topRight:w.Vec3(p.max)},{description:"Static box defined by cartesian coords.",isFlat:!0}),"selection-box":w.Group({radius:w.Numeric(5,{min:0,max:50,step:.5},{description:"Radius in \u212B within which the volume is shown."}),bottomLeft:w.Vec3(y.create(0,0,0),{},{isHidden:!0}),topRight:w.Vec3(y.create(0,0,0),{},{isHidden:!0})},{description:"Box around focused element.",isFlat:!0}),"camera-target":w.Group({radius:w.Numeric(.5,{min:0,max:1,step:.05},{description:"Radius within which the volume is shown (relative to the field of view)."}),dynamicDetailLevel:i(h.header.availablePrecisions,0,{label:"Dynamic Detail"}),bottomLeft:w.Vec3(y.create(0,0,0),{},{isHidden:!0}),topRight:w.Vec3(y.create(0,0,0),{},{isHidden:!0})},{description:"Box around camera target.",isFlat:!0}),cell:w.Group({}),auto:w.Group({radius:w.Numeric(5,{min:0,max:50,step:.5},{description:"Radius in \u212B within which the volume is shown."}),selectionDetailLevel:i(h.header.availablePrecisions,6,{label:"Selection Detail"}),isSelection:w.Boolean(!1,{isHidden:!0}),bottomLeft:w.Vec3(p.min,{},{isHidden:!0}),topRight:w.Vec3(p.max,{},{isHidden:!0})},{description:"Box around focused element.",isFlat:!0})},{options:e.ViewTypeOptions,description:'Controls what of the volume is displayed. "Off" hides the volume alltogether. "Bounded box" shows the volume inside the given box. "Around Interaction" shows the volume around the focused element/atom. "Whole Structure" shows the volume for the whole structure.'}),detailLevel:i(h.header.availablePrecisions,3),channels:h.kind==="em"?w.Group({em:t("EM",Xe(6524815),h.emDefaultContourLevel||Je.IsoValue.relative(1),h.header.sampling[0].valuesInfo[0],m.em)},{isFlat:!0}):w.Group({"2fo-fc":t("2Fo-Fc",Xe(3367602),Je.IsoValue.relative(1.5),h.header.sampling[0].valuesInfo[0],m["2fo-fc"]),"fo-fc(+ve)":t("Fo-Fc(+ve)",Xe(3390259),Je.IsoValue.relative(3),h.header.sampling[0].valuesInfo[1],m["fo-fc(+ve)"]),"fo-fc(-ve)":t("Fo-Fc(-ve)",Xe(12268339),Je.IsoValue.relative(-3),h.header.sampling[0].valuesInfo[1],m["fo-fc(-ve)"])},{isFlat:!0})}}e.createEntryParams=a;function i(u,c,l){return w.Select(Math.min(c,u.length-1),u.map(function(f,d){return[d,"".concat(d+1," [ ").concat(Math.pow(f.maxVoxels,1/3)|0,"^3 cells ]")]}),P({description:"Determines the maximum number of voxels. Depending on the size of the volume options are in the range from 1 (0.52M voxels) to 7 (25.17M voxels)."},l))}function o(u){return{entry:{name:u.entry.name,params:{detailLevel:u.entry.params.detailLevel,channels:u.entry.params.channels,view:{name:u.entry.params.view.name,params:P({},u.entry.params.view.params)}}}}}e.copyParams=o,e.ViewTypeOptions=[["off","Off"],["box","Bounded Box"],["selection-box","Around Focus"],["camera-target","Around Camera"],["cell","Whole Structure"],["auto","Auto"]],e.ChannelTypeOptions=[["em","em"],["2fo-fc","2fo-fc"],["fo-fc(+ve)","fo-fc(+ve)"],["fo-fc(-ve)","fo-fc(-ve)"]];var s=function(u){St(c,u);function c(l,f){var d=u.call(this,l,{})||this;return d.plugin=l,d.data=f,d.cache=qy.create(25),d.params={},d.lastLoci=Jt,d.ref="",d.cameraTargetObservable=d.plugin.canvas3d.didDraw.pipe(Tg(500,void 0,{leading:!0,trailing:!0}),Cn(function(){var m;return(m=d.plugin.canvas3d)===null||m===void 0?void 0:m.camera.getSnapshot()}),Cg(function(m,h){return d.isCameraTargetSame(m,h)}),_s(function(m){return m!==void 0})),d.cameraTargetSubscription=void 0,d.channels={},d._invTransform=se(),d.infoMap=new Map,d.data.entries.forEach(function(m){return d.infoMap.set(m.dataId,m)}),d.updateQueue=new xae,d}return Object.defineProperty(c.prototype,"info",{get:function(){return this.infoMap.get(this.params.entry.name)},enumerable:!1,configurable:!0}),c.prototype.queryData=function(l){return $(this,void 0,void 0,function(){var f,d,m,h,p,v,g,b,x;return J(this,function(S){switch(S.label){case 0:return f=Iy(this.data.serverUrl,"".concat(this.info.kind,"/").concat(this.info.dataId.toLowerCase())),l?(d=l.min,m=l.max,f+="/box"+"/".concat(d.map(function(_){return Math.round(1e3*_)/1e3}).join(","))+"/".concat(m.map(function(_){return Math.round(1e3*_)/1e3}).join(","))):f+="/cell",h=this.params.entry.params.detailLevel,this.params.entry.params.view.name==="auto"&&this.params.entry.params.view.params.isSelection&&(h=this.params.entry.params.view.params.selectionDetailLevel),this.params.entry.params.view.name==="camera-target"&&l&&(h=this.decideDetail(l,this.params.entry.params.view.params.dynamicDetailLevel)),f+="?detail=".concat(h),p=qy.get(this.cache,f),p?[2,p.data]:(v=Ur.getUrlAsset(this.plugin.managers.asset,f),[4,this.plugin.runTask(this.plugin.managers.asset.resolve(v,"binary"))]);case 1:return g=S.sent(),[4,this.parseCif(g.data)];case 2:return b=S.sent(),b?(x=qy.set(this.cache,f,{data:b,asset:g}),x&&x.asset.dispose(),[2,b]):[2]}})})},c.prototype.parseCif=function(l){return $(this,void 0,void 0,function(){var f,d,m,h,p,v;return J(this,function(g){switch(g.label){case 0:return[4,this.plugin.runTask(Es.parseBinary(l))];case 1:if(f=g.sent(),f.isError)return this.plugin.log.error("VolumeStreaming, parsing CIF: "+f.toString()),[2];if(f.result.blocks.length<2)return this.plugin.log.error("VolumeStreaming: Invalid data."),[2];d={},m=1,g.label=2;case 2:return mg.height&&(v*=g.width/g.height);var b=this.params.entry.params.view.name==="camera-target"?this.params.entry.params.view.params.radius:.5;v*=b;var x,S,_;if(f){var C=y.zero();gt.size(C,this.data.structure.boundary.box),x=Math.min(v,.5*C[0]),S=Math.min(v,.5*C[1]),_=Math.min(v,.5*C[2])}else x=S=_=v;return gt.create(y.create(m[0]-x,m[1]-S,m[2]-_),y.create(m[0]+x,m[1]+S,m[2]+_))},c.prototype.decideDetail=function(l,f){for(var d=this.info.kind==="x-ray"?gt.volume(this.data.structure.boundary.box):this.info.header.spacegroup.size.reduce(function(g,b){return g*b},1),m=gt.volume(l),h=m/d,p=this.info.header.availablePrecisions.length-1,v=f;h<=.5&&v=0&&h>=0&&p>=0&&(++u,He.add3(o,m,h,p))},get:function(){var c=He.compact(n,!0),l=He.compact(a,!0),f=He.compact(o,!0),d=He.compact(i,!0);return pt.create(c,f,l,d,s,u,t)}}}function Tae(e,t){var r=He.create(Float32Array,3,e),n=He.create(Float32Array,1,e),a=He.create(Float32Array,2,e),i=0;return{addVertex:function(o,s,u){return He.add3(r,o,s,u)},addNormal:function(){return fd},addGroup:function(o){He.add(n,o)},addTriangle:function(o,s,u,c,l){var f=o[s],d=o[u],m=o[c];f>=0&&d>=0&&m>=0&&(OA[s][u]&l&&(++i,He.add2(a,o[s],o[u])),OA[u][c]&l&&(++i,He.add2(a,o[u],o[c])),OA[s][c]&l&&(++i,He.add2(a,o[s],o[c])))},get:function(){for(var o=He.compact(r,!0),s=He.compact(a,!0),u=He.compact(n,!0),c=Ji.create(i,i/10,t),l=0;l0)return a-1;var i=this.scalarField,o=this.scalarFieldGet,s=Sae[t],u=s.a,c=s.b,l=u.i+this.i,f=u.j+this.j,d=u.k+this.k,m=c.i+this.i,h=c.j+this.j,p=c.k+this.k,v=o(i,l,f,d),g=o(i,m,h,p),b=(this.isoLevel-v)/(v-g);if(this.idField){var x=this.idFieldGet(this.idField,l,f,d),S=this.idFieldGet(this.idField,m,h,p),_=b<.5?x:S;if(_===-1&&(_=b<.5?S:x),_===-2)return-1;this.builder.addGroup(_)}else this.builder.addGroup(0);var C=this.builder.addVertex(l+b*(l-m),f+b*(f-h),d+b*(d-p));this.verticesOnEdges[n]=C+1;var D=o(i,Math.max(0,l-1),f,d)-o(i,Math.min(this.nX-1,l+1),f,d),T=o(i,l,Math.max(0,f-1),d)-o(i,l,Math.min(this.nY-1,f+1),d),A=o(i,l,f,Math.max(0,d-1))-o(i,l,f,Math.min(this.nZ,d+1)),E=o(i,Math.max(0,m-1),h,p)-o(i,Math.min(this.nX-1,m+1),h,p),I=o(i,m,Math.max(0,h-1),p)-o(i,m,Math.min(this.nY-1,h+1),p),R=o(i,m,h,Math.max(0,p-1))-o(i,m,h,Math.min(this.nZ-1,p+1)),B=D+b*(D-E),O=T+b*(T-I),z=A+b*(A-R);return this.isoLevel>=0?this.builder.addNormal(B,O,z):this.builder.addNormal(-B,-O,-z),C},e.prototype.get=function(t,r,n){return this.scalarFieldGet(this.scalarField,t,r,n)},e.prototype.processCell=function(t,r,n,a){var i=0;if(this.get(t,r,n)0&&(this.vertList[0]=this.interpolate(0)),(o&2)>0&&(this.vertList[1]=this.interpolate(1)),(o&4)>0&&(this.vertList[2]=this.interpolate(2)),(o&8)>0&&(this.vertList[3]=this.interpolate(3)),(o&16)>0&&(this.vertList[4]=this.interpolate(4)),(o&32)>0&&(this.vertList[5]=this.interpolate(5)),(o&64)>0&&(this.vertList[6]=this.interpolate(6)),(o&128)>0&&(this.vertList[7]=this.interpolate(7)),(o&256)>0&&(this.vertList[8]=this.interpolate(8)),(o&512)>0&&(this.vertList[9]=this.interpolate(9)),(o&1024)>0&&(this.vertList[10]=this.interpolate(10)),(o&2048)>0&&(this.vertList[11]=this.interpolate(11));for(var s=th[i],u=0;u=0?this.builder.addTriangle(this.vertList,c,l,f,a):this.builder.addTriangle(this.vertList,f,l,c,a)}}},e}();function aNe(e,t,r,n,a,i){var o=Ra.getUtils(t),s=o.createValues,u=o.createRenderableState,c=V0(),l=s(t,c,r,n,a),f=u(a);return Hc(t.kind,l,f,i)}function $l(e,t){var r=e.defaultProps,n=e.createGeometry,a=e.createLocationIterator,i=e.getLoci,o=e.eachLocation,s=e.setUpdateState,u=e.mustRecreate,c=e.dispose,l=e.geometryUtils,f=l.updateValues,d=l.updateBoundingSphere,m=l.updateRenderableState,h=l.createPositionIterator,p=Fu.create(),v,g,b,x,S,_=Object.assign({},r),C=da.createEmpty(),D,T,A,E=-1,I,R;function B(G,V,U,Q){if(!U&&!D)throw new Error("missing volume");if(g=Object.assign({},_,V),b=G,x=U,S=Q,Fu.reset(p),v?(!Je.areEquivalent(x,D)||S!==T)&&(p.createNew=!0):p.createNew=!0,p.createNew){p.createGeometry=!0;return}s(p,U,g,_,b,C),ci.areEqual(G.color,C.color)||(p.updateColor=!0),p.createGeometry&&(p.updateColor=!0),g.instanceGranularity!==_.instanceGranularity&&(p.updateTransform=!0)}function O(G){if(p.createNew)if(I=a(x,S),G)v=aNe(x,G,I,b,g,t),R=h(G,v.values);else throw new Error("expected geometry to be given");else{if(!v)throw new Error("expected renderObject to be available");if(p.updateTransform){I=a(x,S);var V=I.instanceCount,U=I.groupCount;g.instanceGranularity?bn(V,"instance",v.values):bn(V*U,"groupInstance",v.values)}else I.reset();if(p.createGeometry)if(G)M.updateIfChanged(v.values.drawCount,Ra.getDrawCount(G)),M.updateIfChanged(v.values.uVertexCount,Ra.getVertexCount(G)),M.updateIfChanged(v.values.uGroupCount,Ra.getGroupCount(G));else throw new Error("expected geometry to be given");(p.updateTransform||p.createGeometry)&&(d(v.values,G||A),R=h(G||A,v.values)),p.updateSize&&"uSize"in v.values&&Ho(I,b.size,v.values),p.updateColor&&Qa(I,R,b.color,v.values),f(v.values,g),m(v.state,g)}_=g,C=b,D=x,T=S,G&&(A=G,E+=1)}function z(G,V,U,Q){var W=!1;if(Je.Cell.isLoci(G)){if(Je.Cell.isLociEmpty(G)||!Je.areEquivalent(G.volume,V))return!1;Q(Se.ofSingleton(0))&&(W=!0)}else if(Je.Segment.isLoci(G)){if(Je.Segment.isLociEmpty(G)||!Je.areEquivalent(G.volume,V)||!Fe.has(G.segments,U))return!1;Q(Se.ofSingleton(0))&&(W=!0)}return W}function k(G,V){return Oi(G)?_.instanceGranularity?V(Se.ofBounds(0,I.instanceCount)):V(Se.ofBounds(0,I.groupCount*I.instanceCount)):_.instanceGranularity?z(G,D,T,V):o(G,D,T,_,V)}return{get groupCount(){return I?I.count:0},get renderObject(){return v},get geometryVersion(){return E},createOrUpdate:function(G,V,U,Q){return U===void 0&&(U={}),$(this,void 0,void 0,function(){var W;return J(this,function(X){return B(V,U,Q?.volume||D,Q?.key||T),p.createGeometry?(W=n(G,x,S,b,g,A),[2,Dm(W)?W.then(O):O(W)]):(O(),[2])})})},getLoci:function(G){return v?i(G,D,T,_,v.id):Jt},eachLocation:function(G){for(I.reset();I.hasNext;){var V=I.move(),U=V.location,Q=V.isSecondary;G(U,Q)}},mark:function(G,V){return pr.mark(v,G,V,k)},setVisibility:function(G){pr.setVisibility(v,G)},setAlphaFactor:function(G){pr.setAlphaFactor(v,G)},setPickable:function(G){pr.setPickable(v,G)},setColorOnly:function(G){pr.setColorOnly(v,G)},setTransform:function(G,V){pr.setTransform(v,G,V)},setOverpaint:function(G){return pr.setOverpaint(v,G,k,!0)},setTransparency:function(G){return pr.setTransparency(v,G,k,!0)},setSubstance:function(G){return pr.setSubstance(v,G,k,!0)},setClipping:function(G){return pr.setClipping(v,G,k,!0)},setThemeStrength:function(G){pr.setThemeStrength(v,G)},destroy:function(){c?.(A),v&&(v.state.disposed=!0,v=void 0)},mustRecreate:u}}var lsr=P({},Ze.Params);function im(e,t,r,n,a,i){i===void 0&&(i=function(){return[-1]});var o=0,s=t.webgl,u=new kr,c=new Lt.GeometryState,l=Js(),f=[],d=Lt.createState(),m=new Map,h,p,v,g,b=da.createEmpty();function x(E,I){var R;return $(this,void 0,void 0,function(){var B;return J(this,function(O){return B=m.get(I),B?!((R=B.mustRecreate)===null||R===void 0)&&R.call(B,{volume:h,key:I},g,s)&&(B.destroy(),B=n(l,h,I,g,s),m.set(I,B)):(B=n(l,h,I,g,s),m.set(I,B)),[2,B.createOrUpdate({webgl:s,runtime:E},b,g,{volume:h,key:I})]})})}function S(E,I){var R=this;E===void 0&&(E={}),I&&I!==h&&(v=r(t,I),h=I,g||(g=w.getDefaultValues(v)));var B=Vx(Object.assign({},g,E),h);return Object.assign(g,E,B),p=i(g),Ce.create("Creating or updating VolumeRepresentation",function(O){return $(R,void 0,void 0,function(){var z,k,G,V,U;return J(this,function(Q){switch(Q.label){case 0:z=new Set(m.keys()),k=0,G=p.length,Q.label=1;case 1:return k0&&(M.update(v.values.tPreviousLevel,h[u-p].texture),v.update()),i.currentRenderItemId=-1,i.viewport(0,0,S,S),i.scissor(0,0,S,S),Gt(a)?a.clearBufferiv(a.COLOR,0,[0,0,0,0]):a.clear(a.COLOR_BUFFER_BIT),i.scissor(0,0,n[0],n[1]),v.render(),d.bind(0),a.copyTexSubImage2D(a.TEXTURE_2D,0,g,0,0,0,S,S),d.unbind(0),g+=S}a.finish(),ft&&e.timer.markEnd("createHistogramPyramid");var _=Math.max(1,Mae(e,h[0].texture)),C=Math.ceil(_/Math.pow(2,u));return{pyramidTex:d,count:_,height:C,levels:u,scale:r}}var lS;function Fae(){if(lS!==void 0)return lS;lS=Vn(16*16,1,Uint8Array);for(var e=lS.array,t=0,r=th.length;t 16777215.5 ? vec3(1.0) : packIntToRGB(group), 1.0); +} + +void main(void) { + // get 1D index + int vI = int(gl_FragCoord.x) + int(gl_FragCoord.y) * int(uSize); + + // ignore 1D indices outside of the grid + if(vI >= int(uCount)) discard; + + ivec2 offset = ivec2(int(uSize) - 2, 0); + + int start = 0; + ivec4 starts = ivec4(0); + ivec4 ends = ivec4(0); + int diff = 2; + ivec4 m = ivec4(0); + ivec2 position = ivec2(0); + ivec4 vI4 = ivec4(vI); + + ivec2 relativePosition = ivec2(0); + int end = 0; + ivec2 pos1 = ivec2(0); + ivec2 pos2 = ivec2(0); + ivec2 pos3 = ivec2(0); + ivec2 pos4 = ivec2(0); + ivec3 vI3 = ivec3(vI); + ivec3 mask = ivec3(0); + + // traverse the different levels of the pyramid + for(int i = 1; i < 14; i++) { + if(float(i) >= uLevels) break; + + offset.x -= diff; + diff *= 2; + relativePosition = position + offset; + + end = start + pyramidVoxel(vec2(relativePosition)); + pos1 = ivec2(relativePosition); + starts.x = start; + ends.x = end; + pos2 = ivec2(relativePosition + ivec2(1, 0)); + starts.y = ends.x; + ends.y = ends.x + pyramidVoxel(vec2(pos2)); + pos3 = relativePosition + ivec2(0, 1); + starts.z = ends.y; + ends.z = ends.y + pyramidVoxel(vec2(pos3)); + pos4 = relativePosition + ivec2(1, 1); + starts.w = ends.z; + mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb)); + m = ivec4(mask, 1 - int(any(bvec3(mask)))); + + relativePosition = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4; + start = idot4(m, starts); + position = 2 * (relativePosition - offset); + } + + end = start + int(baseVoxel(vec2(position)).r * 255.0); + pos1 = position; + starts.x = start; + ends.x = end; + pos2 = position + ivec2(1, 0); + starts.y = ends.x; + ends.y = ends.x + int(baseVoxel(vec2(pos2)).r * 255.0); + pos3 = position + ivec2(0, 1); + starts.z = ends.y; + ends.z = ends.y + int(baseVoxel(vec2(pos3)).r * 255.0); + pos4 = position + ivec2(1, 1); + starts.w = ends.z; + mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb)); + m = ivec4(mask, 1 - int(any(bvec3(mask)))); + position = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4; + + vec2 coord2d = (vec2(position) / uSize) / uScale; + vec3 coord3d = floor(index3dFrom2d(coord2d) + 0.5); + + float edgeIndex = floor(baseVoxel(vec2(position)).a * 255.0 + 0.5); + + // current vertex for the up to 15 MC cases + int currentVertex = vI - idot4(m, starts); + + // ensure winding-order is the same for negative and positive iso-levels + if (uInvert) { + int v = imod(currentVertex + 1, 3); + if (v == 1) currentVertex += 2; + else if (v == 0) currentVertex -= 2; + } + + // get index into triIndices table + int mcIndex = 16 * int(edgeIndex) + currentVertex; + vec4 mcData = texture2D(tTriIndices, vec2(imod(mcIndex, 64), mcIndex / 64) / 64.); + + // bit mask to avoid conditionals (see comment below) for getting MC case corner + vec4 m0 = vec4(floor(mcData.a * 255.0 + 0.5)); + + // get edge value masks + vec4 m1 = vec4(equal(m0, vec4(0., 1., 2., 3.))); + vec4 m2 = vec4(equal(m0, vec4(4., 5., 6., 7.))); + vec4 m3 = vec4(equal(m0, vec4(8., 9., 10., 11.))); + + // apply bit masks + vec3 b0 = coord3d + + m1.y * c1 + + m1.z * c2 + + m1.w * c3 + + m2.x * c4 + + m2.y * c5 + + m2.z * c6 + + m2.w * c7 + + m3.y * c1 + + m3.z * c2 + + m3.w * c3; + vec3 b1 = coord3d + + m1.x * c1 + + m1.y * c2 + + m1.z * c3 + + m2.x * c5 + + m2.y * c6 + + m2.z * c7 + + m2.w * c4 + + m3.x * c4 + + m3.y * c5 + + m3.z * c6 + + m3.w * c7; + + // the conditionals that are avoided by above bitmasks + // vec3 b0 = coord3d; + // vec3 b1 = coord3d; + // if (mcIndex == 0.0) { + // b1 += c1; + // } else if (mcIndex == 1.0) { + // b0 += c1; b1 += c2; + // } else if (mcIndex == 2.0) { + // b0 += c2; b1 += c3; + // } else if (mcIndex == 3.0) { + // b0 += c3; + // } else if (mcIndex == 4.0) { + // b0 += c4; b1 += c5; + // } else if (mcIndex == 5.0) { + // b0 += c5; b1 += c6; + // } else if (mcIndex == 6.0) { + // b0 += c6; b1 += c7; + // } else if (mcIndex == 7.0) { + // b0 += c7; b1 += c4; + // } else if (mcIndex == 8.0) { + // b1 += c4; + // } else if (mcIndex == 9.0) { + // b0 += c1; b1 += c5; + // } else if (mcIndex == 10.0) { + // b0 += c2; b1 += c6; + // } else if (mcIndex == 11.0) { + // b0 += c3; b1 += c7; + // } + // b0 = floor(b0 + 0.5); + // b1 = floor(b1 + 0.5); + + vec4 d0 = voxel(b0); + vec4 d1 = voxel(b1); + + float v0 = d0.a; + float v1 = d1.a; + + float t = (uIsoValue - v0) / (v0 - v1); + gl_FragData[0].xyz = (uGridTransform * vec4(b0 + t * (b0 - b1), 1.0)).xyz; + + // group id + #if __VERSION__ == 100 || defined(dConstantGroup) + // webgl1 does not support 'flat' interpolation (i.e. no interpolation) + // ensure a constant group id per triangle as needed + #ifdef dPackedGroup + gl_FragData[1] = vec4(voxel(coord3d).rgb, 1.0); + #else + gl_FragData[1] = getGroup(coord3d); + #endif + #else + #ifdef dPackedGroup + gl_FragData[1] = vec4(t < 0.5 ? d0.rgb : d1.rgb, 1.0); + #else + gl_FragData[1] = getGroup(t < 0.5 ? b0 : b1); + #endif + #endif + + // normals from gradients + vec3 n0 = -normalize(vec3( + voxelPadded(b0 - c1).a - voxelPadded(b0 + c1).a, + voxelPadded(b0 - c3).a - voxelPadded(b0 + c3).a, + voxelPadded(b0 - c4).a - voxelPadded(b0 + c4).a + )); + vec3 n1 = -normalize(vec3( + voxelPadded(b1 - c1).a - voxelPadded(b1 + c1).a, + voxelPadded(b1 - c3).a - voxelPadded(b1 + c3).a, + voxelPadded(b1 - c4).a - voxelPadded(b1 + c4).a + )); + gl_FragData[2].xyz = -vec3( + n0.x + t * (n0.x - n1.x), + n0.y + t * (n0.y - n1.y), + n0.z + t * (n0.z - n1.z) + ); + + // ensure normal-direction is the same for negative and positive iso-levels + if (uInvert) { + gl_FragData[2].xyz *= -1.0; + } + + // apply normal matrix + gl_FragData[2].xyz *= transpose3(inverse3(mat3(uGridTransform))); +} +`;var Nae=` +precision highp float; +precision highp int; +precision highp sampler2D; + +uniform sampler2D tTriCount; +uniform sampler2D tVolumeData; + +uniform float uIsoValue; +uniform vec3 uGridDim; +uniform vec3 uGridTexDim; +uniform vec2 uScale; + +#include common + +// cube corners (excluding origin) +const vec3 c1 = vec3(1., 0., 0.); +const vec3 c2 = vec3(1., 1., 0.); +const vec3 c3 = vec3(0., 1., 0.); +const vec3 c4 = vec3(0., 0., 1.); +const vec3 c5 = vec3(1., 0., 1.); +const vec3 c6 = vec3(1., 1., 1.); +const vec3 c7 = vec3(0., 1., 1.); + +vec3 index3dFrom2d(vec2 coord) { + vec2 gridTexPos = coord * uGridTexDim.xy; + vec2 columnRow = ivec2Div(gridTexPos, uGridDim.xy); + vec2 posXY = gridTexPos - columnRow * uGridDim.xy; + float posZ = columnRow.y * intDiv(uGridTexDim.x, uGridDim.x) + columnRow.x; + return vec3(posXY, posZ); +} + +vec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) { + float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice + float column = intDiv(intMod(zSlice * gridDim.x, texDim.x), gridDim.x); + float row = intDiv(zSlice * gridDim.x, texDim.x); + vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / (texDim / uScale); + return texture2D(tex, coord); +} + +vec4 voxel(vec3 pos) { + pos = min(max(vec3(0.0), pos), uGridDim - vec3(1.0)); + return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy); +} + +void main(void) { + vec2 uv = gl_FragCoord.xy / uGridTexDim.xy; + vec3 posXYZ = index3dFrom2d(uv); + + // get MC case as the sum of corners that are below the given iso level + float c = step(voxel(posXYZ).a, uIsoValue) + + 2. * step(voxel(posXYZ + c1).a, uIsoValue) + + 4. * step(voxel(posXYZ + c2).a, uIsoValue) + + 8. * step(voxel(posXYZ + c3).a, uIsoValue) + + 16. * step(voxel(posXYZ + c4).a, uIsoValue) + + 32. * step(voxel(posXYZ + c5).a, uIsoValue) + + 64. * step(voxel(posXYZ + c6).a, uIsoValue) + + 128. * step(voxel(posXYZ + c7).a, uIsoValue); + c *= step(c, 254.); + + // handle out of bounds positions + posXYZ += 1.0; + posXYZ.xy += 1.0; // pixel padding (usually ok even if the texture has no padding) + if (posXYZ.x >= uGridDim.x || posXYZ.y >= uGridDim.y || posXYZ.z >= uGridDim.z) + c = 0.0; + + // get total triangles to generate for calculated MC case from triCount texture + float totalTrianglesToGenerate = texture2D(tTriCount, vec2(intMod(c, 16.), floor(c / 16.)) / 16.).a; + gl_FragColor = vec4(vec3(totalTrianglesToGenerate * 3.0), c / 255.0); +} +`;var hNe=P(P({},Gn),{tTriCount:Ft("image-uint8","alpha","ubyte","nearest"),tVolumeData:Ft("texture","rgba","ubyte","nearest"),uIsoValue:_e("f"),uGridDim:_e("v3"),uGridTexDim:_e("v3"),uScale:_e("v2")}),Jl="active-voxels";function vNe(e,t,r,n,a,i){if(e.namedComputeRenderables[Jl]){var o=e.namedComputeRenderables[Jl].values;M.update(o.uQuadScale,i),M.update(o.tVolumeData,t),M.updateIfChanged(o.uIsoValue,a),M.update(o.uGridDim,r),M.update(o.uGridTexDim,n),M.update(o.uScale,i),e.namedComputeRenderables[Jl].update()}else e.namedComputeRenderables[Jl]=gNe(e,t,r,n,a,i);return e.namedComputeRenderables[Jl]}function gNe(e,t,r,n,a,i){var o=P(P({},zn),{tTriCount:M.create(Fae()),uQuadScale:M.create(i),tVolumeData:M.create(t),uIsoValue:M.create(a),uGridDim:M.create(r),uGridTexDim:M.create(n),uScale:M.create(i)}),s=P({},hNe),u=Nr("active-voxels",ea,Nae),c=ln(e,"triangles",u,s,o);return fn(c,o)}function yNe(e){var t=e.gl,r=e.state;r.disable(t.CULL_FACE),r.disable(t.BLEND),r.disable(t.DEPTH_TEST),r.enable(t.SCISSOR_TEST),r.depthMask(!1),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0)}function Uae(e,t,r,n,a,i){ft&&e.timer.mark("calcActiveVoxels");var o=e.gl,s=e.state,u=e.resources,c=t.getWidth(),l=t.getHeight();e.namedFramebuffers[Jl]||(e.namedFramebuffers[Jl]=u.framebuffer());var f=e.namedFramebuffers[Jl];f.bind(),e.namedTextures[Jl]||(e.namedTextures[Jl]=u.texture("image-uint8","rgba","ubyte","nearest"));var d=e.namedTextures[Jl];d.define(c,l);var m=vNe(e,t,r,n,a,i);return e.state.currentRenderItemId=-1,d.attachFramebuffer(f,0),yNe(e),s.viewport(0,0,c,l),s.scissor(0,0,c,l),o.clear(o.COLOR_BUFFER_BIT),s.scissor(0,0,n[0],n[1]),m.render(),o.finish(),ft&&e.timer.markEnd("calcActiveVoxels"),d}var bNe=P(P({},Gn),{tTriIndices:Ft("image-uint8","alpha","ubyte","nearest"),tActiveVoxelsPyramid:Ft("texture","rgba","float","nearest"),tActiveVoxelsBase:Ft("texture","rgba","float","nearest"),tVolumeData:Ft("texture","rgba","ubyte","nearest"),uIsoValue:_e("f"),uSize:_e("f"),uLevels:_e("f"),uCount:_e("f"),uInvert:_e("b"),uGridDim:_e("v3"),uGridTexDim:_e("v3"),uGridTransform:_e("m4"),uScale:_e("v2"),dPackedGroup:Dt("boolean"),dAxisOrder:Dt("string",["012","021","102","120","201","210"]),dConstantGroup:Dt("boolean")}),nh="isosurface";function xNe(e,t,r,n,a,i,o,s,u,c,l,f,d,m,h){if(e.namedComputeRenderables[nh]){var p=e.namedComputeRenderables[nh].values;M.update(p.tActiveVoxelsPyramid,t),M.update(p.tActiveVoxelsBase,r),M.update(p.tVolumeData,n),M.updateIfChanged(p.uIsoValue,s),M.updateIfChanged(p.uSize,Math.pow(2,u)),M.updateIfChanged(p.uLevels,u),M.updateIfChanged(p.uCount,l),M.updateIfChanged(p.uInvert,f),M.update(p.uGridDim,a),M.update(p.uGridTexDim,i),M.update(p.uGridTransform,o),M.update(p.uScale,c),M.updateIfChanged(p.dPackedGroup,d),M.updateIfChanged(p.dAxisOrder,m.join("")),M.updateIfChanged(p.dConstantGroup,h),e.namedComputeRenderables[nh].update()}else e.namedComputeRenderables[nh]=SNe(e,t,r,n,a,i,o,s,u,c,l,f,d,m,h);return e.namedComputeRenderables[nh]}function SNe(e,t,r,n,a,i,o,s,u,c,l,f,d,m,h){var p=P(P({},zn),{tTriIndices:M.create(Lae()),tActiveVoxelsPyramid:M.create(t),tActiveVoxelsBase:M.create(r),tVolumeData:M.create(n),uIsoValue:M.create(s),uSize:M.create(Math.pow(2,u)),uLevels:M.create(u),uCount:M.create(l),uInvert:M.create(f),uGridDim:M.create(a),uGridTexDim:M.create(i),uGridTransform:M.create(o),uScale:M.create(c),dPackedGroup:M.create(d),dAxisOrder:M.create(m.join("")),dConstantGroup:M.create(h)}),v=P({},bNe),g=Nr("isosurface",ea,kae,{drawBuffers:"required"}),b=ln(e,"triangles",g,v,p);return fn(b,p)}function CNe(e){var t=e.gl,r=e.state;r.disable(t.CULL_FACE),r.disable(t.BLEND),r.disable(t.DEPTH_TEST),r.disable(t.SCISSOR_TEST),r.depthMask(!1),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0)}function _Ne(e,t,r,n,a,i,o,s,u,c,l,f,d,m,h){var p=e.extensions.drawBuffers;if(!p)throw new Error("need WebGL draw buffers");ft&&e.timer.mark("createIsosurfaceBuffers");var v=e.gl,g=e.state,b=e.resources,x=e.extensions,S=n.pyramidTex,_=n.height,C=n.levels,D=n.scale,T=n.count,A=S.getWidth();e.namedFramebuffers[nh]||(e.namedFramebuffers[nh]=b.framebuffer());var E=e.namedFramebuffers[nh];Gt(v)?(d||(d=b.texture("image-float32","rgba","float","nearest")),m||(m=b.texture("image-uint8","rgba","ubyte","nearest")),h||(h=x.colorBufferHalfFloat&&x.textureHalfFloat?b.texture("image-float16","rgba","fp16","nearest"):b.texture("image-float32","rgba","float","nearest"))):(d||(d=b.texture("image-float32","rgba","float","nearest")),m||(m=b.texture("image-float32","rgba","float","nearest")),h||(h=b.texture("image-float32","rgba","float","nearest"))),d.define(A,_),m.define(A,_),h.define(A,_),d.attachFramebuffer(E,0),m.attachFramebuffer(E,1),h.attachFramebuffer(E,2);var I=xNe(e,S,t,r,a,i,o,s,C,D,T,u,c,l,f);return e.state.currentRenderItemId=-1,E.bind(),p.drawBuffers([p.COLOR_ATTACHMENT0,p.COLOR_ATTACHMENT1,p.COLOR_ATTACHMENT2]),CNe(e),g.viewport(0,0,A,_),v.clear(v.COLOR_BUFFER_BIT),I.render(),v.finish(),ft&&e.timer.markEnd("createIsosurfaceBuffers"),{vertexTexture:d,groupTexture:m,normalTexture:h,vertexCount:T}}function Zv(e,t,r,n,a,i,o,s,u,c,l,f,d,m){ft&&e.timer.mark("extractIsosurface");var h=Uae(e,t,r,n,o,a),p=Oae(e,h,a,n),v=_Ne(e,h,t,p,r,n,i,o,s,u,c,l,f,d,m);return ft&&e.timer.markEnd("extractIsosurface"),v}var Gae={isoValue:Je.IsoValueParam};function wNe(e){return e.extensions.colorBufferFloat&&e.extensions.textureFloat&&e.extensions.drawBuffers}var dS=1;function UL(e,t){if(e.grid.cells.data.lengtha.maxTextureSize/2)throw new Error("volume too large for gpu isosurface extraction");if(!n._propertyData[t]){n._propertyData[t]=i.texture("image-uint8","alpha","ubyte","linear");var h=n._propertyData[t];h.define(f,f),h.load(pT(n,"data",dS),!0),n.customProperties.add(e.descriptor),n.customProperties.assets(e.descriptor,[{dispose:function(){return h.destroy()}}])}return s[0]+=dS,s[1]+=dS,{texture:n._propertyData[t],transform:o,gridDimension:s,gridTexDim:d,gridTexScale:m}}e.get=r})(kL||(kL={}));function PNe(e,t,r,n,a,i){return $(this,void 0,void 0,function(){var o,s,u,c,l,f,d,m,h,p,v,g,b,x,S,_,C,D;return J(this,function(T){if(!e.webgl)throw new Error("webgl context required to create volume isosurface texture-mesh");return t.grid.cells.data.length<=1?[2,Ei.createEmpty(i)]:(o=t.grid.stats,s=o.max,u=o.min,c=s-u,l=Je.IsoValue.toAbsolute(a.isoValue,t.grid.stats).absoluteValue,f=(l-u)/c,d=kL.get(t,e.webgl),m=d.texture,h=d.gridDimension,p=d.gridTexDim,v=d.gridTexScale,g=d.transform,b=t.grid.cells.space.axisOrderSlowToFast,x=i?.doubleBuffer.get(),S=Zv(e.webgl,m,h,p,v,g,f,l<0,!1,b,!0,x?.vertex,x?.group,x?.normal),_=t.grid.cells.data.length,C=Je.getBoundingSphere(t),D=Ei.create(S.vertexCount,_,S.vertexTexture,S.groupTexture,S.normalTexture,C,i),D.meta.webgl=e.webgl,[2,D])})})}function ENe(e){return $l({defaultProps:w.getDefaultValues(zL),createGeometry:PNe,createLocationIterator:function(t){return hr(t.grid.cells.data.length,1,1,function(){return Gi})},getLoci:VL,eachLocation:GL,setUpdateState:function(t,r,n,a){Je.IsoValue.areSame(n.isoValue,a.isoValue,r.grid.stats)||(t.createGeometry=!0)},geometryUtils:Ei.Utils,mustRecreate:function(t,r,n){return!r.tryUseGpu||!n||!UL(t.volume,n)},dispose:function(t){t.vertexTexture.ref.value.destroy(),t.groupTexture.ref.value.destroy(),t.normalTexture.ref.value.destroy(),t.doubleBuffer.destroy()}},e)}function INe(e,t,r,n,a,i){return $(this,void 0,void 0,function(){var o,s,u;return J(this,function(c){switch(c.label){case 0:return e.runtime.update({message:"Marching cubes..."}),o=Qi(new Int32Array(t.grid.cells.data.length)),[4,Wy({isoLevel:Je.IsoValue.toAbsolute(a.isoValue,t.grid.stats).absoluteValue,scalarField:t.grid.cells,idField:tr.create(t.grid.cells.space,tr.Data1(o))},i).runAsChild(e.runtime)];case 1:return s=c.sent(),u=Ba.getGridToCartesianTransform(t.grid),Kr.transform(s,u),s.setBoundingSphere(Je.Isosurface.getBoundingSphere(t,a.isoValue)),[2,s]}})})}var zae=P(P(P({},Kr.Params),Gae),{quality:P(P({},Kr.Params.quality),{isEssential:!1}),sizeFactor:w.Numeric(3,{min:0,max:10,step:.1})});function MNe(e){return $l({defaultProps:w.getDefaultValues(zae),createGeometry:INe,createLocationIterator:function(t){return hr(t.grid.cells.data.length,1,1,function(){return Gi})},getLoci:VL,eachLocation:GL,setUpdateState:function(t,r,n,a){Je.IsoValue.areSame(n.isoValue,a.isoValue,r.grid.stats)||(t.createGeometry=!0)},geometryUtils:Kr.Utils},e)}var Hae={solid:function(e,t){return im("Isosurface mesh",e,t,TNe,Vae)},wireframe:function(e,t){return im("Isosurface wireframe",e,t,MNe,Vae)}},jae=P(P(P({},zL),zae),{visuals:w.MultiSelect(["solid"],w.objectToOptions(Hae)),bumpFrequency:w.Numeric(1,{min:0,max:10,step:.1},Ze.ShadingCategory)});function RNe(e,t){var r=w.clone(jae);return r.isoValue=Je.createIsoValueParam(Je.IsoValue.relative(2),t.grid.stats),r}function BNe(e,t){return Lt.createMulti("Isosurface",e,t,Lt.StateBuilder,Hae)}var qae={name:"isosurface",label:"Isosurface",description:"Displays a triangulated isosurface of volumetric data.",factory:BNe,getParams:RNe,defaultValues:w.getDefaultValues(jae),defaultColorTheme:{name:"uniform"},defaultSizeTheme:{name:"uniform"},isApplicable:function(e){return!Je.isEmpty(e)&&!Je.Segmentation.get(e)}};function ONe(e,t,r,n,a,i){return $(this,void 0,void 0,function(){var o,s,u,c,l,f,d,m,h,p,v,g,b,x,S,_,C,D,T,A,E,I,R,B,O,z,k,G,V,U,Q,W,X,ae,q,F,j,Z;return J(this,function(Y){for(o=a.dimension.name,s=a.isoValue,u=t.grid.cells,c=u.space,l=u.data,f=t.grid.stats,d=f.min,m=f.max,h=Je.IsoValue.toAbsolute(s,t.grid.stats).absoluteValue,p=("color"in n.color)?n.color.color(Gi,!1):Xe(16777215),v=Xe.toRgbNormalized(p),g=v[0],b=v[1],x=v[2],S=HL(t.grid,a),_=S.width,C=S.height,D=S.x,T=S.y,A=S.z,E=S.x0,I=S.y0,R=S.z0,B=S.nx,O=S.ny,z=S.nz,k=new Float32Array(o==="x"?[D,0,0,D,T,0,D,0,A,D,T,A]:o==="y"?[0,T,0,D,T,0,0,T,A,D,T,A]:[0,0,A,0,T,A,D,0,A,D,T,A]),G=new Uint8Array(_*C*4),V=FNe(t.grid,a),U=0,Q=I;Q=h?255:0,U+=4;return F={width:_,height:C,array:G,flipY:!0},j={width:_,height:C,array:V,flipY:!0},Z=Ba.getGridToCartesianTransform(t.grid),kc(Z,k,0,4),[2,Vl.create(F,k,j,i)]})})}function HL(e,t){var r=t.dimension,n=r.name,a=r.params,i=e.cells.space,o,s,u,c,l,f=0,d=0,m=0,h=i.dimensions,p=h[0],v=h[1],g=h[2];return n==="x"?(u=a,c=v-1,l=g-1,o=g,s=v,f=u,p=f+1):n==="y"?(u=p-1,c=a,l=g-1,o=g,s=p,d=c,v=d+1):(u=p-1,c=v-1,l=a,o=p,s=v,m=l,g=m+1),{width:o,height:s,x:u,y:c,z:l,x0:f,y0:d,z0:m,nx:p,ny:v,nz:g}}function FNe(e,t){for(var r=e.cells.space,n=HL(e,t),a=n.width,i=n.height,o=n.x0,s=n.y0,u=n.z0,c=n.nx,l=n.ny,f=n.nz,d=new Uint8Array(a*i*4),m=0,h=s;ht.maxTextureSize/2)throw new Error("volume too large for direct-volume rendering");var u=pT(r,"normals"),c=Ba.getGridToCartesianTransform(r.grid),l=Kae(a,c),f=n?n.gridTexture.ref.value:t.resources.texture("image-uint8","rgba","ubyte","linear");f.load(u);var d=Zae(r.grid),m=d.unitToCartn,h=d.cellDim,p=r.grid.cells.space.axisOrderSlowToFast;return Po.create(l,a,c,m,h,f,r.grid.stats,!1,p,n)}function Zae(e){if(e.transform.kind==="matrix")return{unitToCartn:se.mul(se(),e.transform.matrix,se.fromScaling(se(),e.cells.space.dimensions)),cellDim:se.getScaling(y(),e.transform.matrix)};var t=e.transform.fractionalBox,r=gt.size(y(),t);return{unitToCartn:se.mul3(se(),e.transform.cell.fromFractional,se.fromTranslation(se(),t.min),se.fromScaling(se(),r)),cellDim:y.div(y(),e.transform.cell.size,e.cells.space.dimensions)}}function HNe(e,t,r,n){var a=r.grid.cells.space.dimensions;if(Math.max.apply(Math,a)>t.max3dTextureSize/2)throw new Error("volume too large for direct-volume rendering");var i=pJ(r),o=Ba.getGridToCartesianTransform(r.grid),s=Kae(a,o),u=n?n.gridTexture.ref.value:t.resources.texture("volume-uint8","rgba","ubyte","linear");u.load(i);var c=Zae(r.grid),l=c.unitToCartn,f=c.cellDim,d=r.grid.cells.space.axisOrderSlowToFast;return Po.create(s,a,o,l,f,u,r.grid.stats,!1,d,n)}function jNe(e,t,r,n,a,i){return $(this,void 0,void 0,function(){var o,s;return J(this,function(u){if(o=e.runtime,s=e.webgl,s===void 0)throw new Error("DirectVolumeVisual requires `webgl` in props");return[2,s.isWebGL2?HNe(o,s,t,i):zNe(o,s,t,i)]})})}function qNe(e,t){return Je.Loci(e)}function WNe(e,t,r,n,a){var i=e.objectId,o=e.groupId;return a===i?Je.Cell.Loci(t,Se.ofSingleton(o)):Jt}function YNe(e,t,r,n,a){return Mp(e,t,void 0,a)}var qL=P(P({},Po.Params),{quality:P(P({},Po.Params.quality),{isEssential:!1})});function XNe(e,t){var r=w.clone(qL);return r.controlPoints.getVolume=function(){return t},r}function KNe(e){return $l({defaultProps:w.getDefaultValues(qL),createGeometry:jNe,createLocationIterator:function(t){return hr(t.grid.cells.data.length,1,1,function(){return Gi})},getLoci:WNe,eachLocation:YNe,setUpdateState:function(t,r,n,a){},geometryUtils:Po.Utils,dispose:function(t){t.gridTexture.ref.value.destroy()}},e)}function ZNe(e,t){return im("Direct Volume",e,t,KNe,qNe)}var Qae={name:"direct-volume",label:"Direct Volume",description:"Direct rendering of volumetric data.",factory:ZNe,getParams:XNe,defaultValues:w.getDefaultValues(qL),defaultColorTheme:{name:"volume-value"},defaultSizeTheme:{name:"uniform"},isApplicable:function(e){return!Je.isEmpty(e)&&!Je.Segmentation.get(e)}};var QNe={segments:w.Converted(function(e){return e.map(function(t){return"".concat(t)})},function(e){return e.map(function(t){return parseInt(t)})},w.MultiSelect(["0"],w.arrayToOptions(["0"]),{isEssential:!0}))};function $Ne(e){return e.extensions.colorBufferFloat&&e.extensions.textureFloat&&e.extensions.drawBuffers}var mS=1;function YL(e,t){if(e.grid.cells.data.lengthr.maxTextureSize/2)throw new Error("volume too large for gpu segment extraction");r.namedTextures[WL]||(r.namedTextures[WL]=a.texture("image-uint8","alpha","ubyte","linear"));var h=r.namedTextures[WL];h.define(f,f);var p=Array.from(n.segments.get(t).values());return h.load(hJ(e,p,i,mS),!0),s[0]+=mS,s[1]+=mS,{texture:h,transform:o,gridDimension:s,gridTexDim:d,gridTexScale:m}}function o5e(e,t,r,n,a,i){return $(this,void 0,void 0,function(){var o,s,u,c,l,f,d,m,h,p,v;return J(this,function(g){if(!e.webgl)throw new Error("webgl context required to create volume segment texture-mesh");return t.grid.cells.data.length<=1?[2,Ei.createEmpty(i)]:(o=i5e(t,r,e.webgl),s=o.texture,u=o.gridDimension,c=o.gridTexDim,l=o.gridTexScale,f=o.transform,d=t.grid.cells.space.axisOrderSlowToFast,m=i?.doubleBuffer.get(),h=Zv(e.webgl,s,u,c,l,f,.5,!1,!1,d,!0,m?.vertex,m?.group,m?.normal),p=t.grid.cells.data.length,v=Ei.create(h.vertexCount,p,h.vertexTexture,h.groupTexture,h.normalTexture,Je.Segment.getBoundingSphere(t,[r]),i),[2,v])})})}function s5e(e){return $l({defaultProps:w.getDefaultValues(XL),createGeometry:o5e,createLocationIterator:function(t,r){var n=Je.Segment.Location(t,r);return hr(t.grid.cells.data.length,1,1,function(){return n})},getLoci:Jae,eachLocation:eie,setUpdateState:function(t,r,n,a){},geometryUtils:Ei.Utils,mustRecreate:function(t,r,n){return!r.tryUseGpu||!n||!YL(t.volume,n)},dispose:function(t){t.vertexTexture.ref.value.destroy(),t.groupTexture.ref.value.destroy(),t.normalTexture.ref.value.destroy(),t.doubleBuffer.destroy()}},e)}function u5e(e){return Fe.ofUnsortedArray(e.segments)}var tie={segment:function(e,t){return im("Segment mesh",e,t,e5e,t5e,u5e)}},rie=P(P({},XL),{visuals:w.MultiSelect(["segment"],w.objectToOptions(tie)),bumpFrequency:w.Numeric(1,{min:0,max:10,step:.1},Ze.ShadingCategory)});function c5e(e,t){var r=w.clone(rie),n=Je.Segmentation.get(t);if(n){var a=Array.from(n.segments.keys());r.segments=w.Converted(function(i){return i.map(function(o){return"".concat(o)})},function(i){return i.map(function(o){return parseInt(o)})},w.MultiSelect(a.map(function(i){return"".concat(i)}),w.arrayToOptions(a.map(function(i){return"".concat(i)})),{isEssential:!0}))}return r}function l5e(e,t){return Lt.createMulti("Segment",e,t,Lt.StateBuilder,tie)}var nie={name:"segment",label:"Segment",description:"Displays a triangulated segment of volumetric data.",factory:l5e,getParams:c5e,defaultValues:w.getDefaultValues(rie),defaultColorTheme:{name:"volume-segment"},defaultSizeTheme:{name:"uniform"},isApplicable:function(e){return!Je.isEmpty(e)&&!!Je.Segmentation.get(e)}};var Yy=function(e){St(t,e);function t(){var r=e.call(this)||this;return Ua(t.BuiltIn,function(n,a){if(n.name!==a)throw new Error("Fix BuiltInVolumeRepresentations to have matching names. ".concat(n.name," ").concat(a));r.add(n)}),r}return t}(gT);(function(e){e.BuiltIn={isosurface:qae,slice:Xae,"direct-volume":Qae,segment:nie}})(Yy||(Yy={}));function aie(e,t,r,n){e.push({source:t==="em"?{name:"em",params:{isoValue:Je.IsoValue.absolute(n||0)}}:{name:"x-ray",params:{}},dataId:r})}var oie=go.build({display:{name:"Volume Streaming"},from:he.Molecule.Structure,params:function(e,t){var r=gae(e&&e.data),n=yae(r,e&&e.data);return{method:w.Select(r,[["em","EM"],["x-ray","X-Ray"]]),entries:w.ObjectList({id:w.Text(n[0]||"")},function(a){var i=a.id;return i},{defaultValue:n.map(function(a){return{id:a}})}),defaultView:w.Select(r==="em"?"auto":"selection-box",uu.ViewTypeOptions),options:w.Group({serverUrl:w.Text(t.config.get(Bn.VolumeStreaming.DefaultServer)||"https://ds.litemol.org"),behaviorRef:w.Text("",{isHidden:!0}),emContourProvider:w.Select("emdb",[["emdb","EMDB"],["pdbe","PDBe"]],{isHidden:!0}),channelParams:w.Value({},{isHidden:!0})})}},isApplicable:function(e,t,r){var n=r.config.get(Bn.VolumeStreaming.CanStream);return n?n(e.data,r):e.data.models.length===1&&Vt.probablyHasDensityMap(e.data.models[0])}})(function(e,t){var r=e.ref,n=e.state,a=e.params;return Ce.create("Volume Streaming",function(i){return $(void 0,void 0,void 0,function(){var o,s,u,c,l,f,d,m,h,p,v,g,b,x,S,_,C;return J(this,function(D){switch(D.label){case 0:o=[],s=0,u=a.entries.length,D.label=1;case 1:return s0?[4,t.managers.structure.hierarchy.remove(S?.toArray())]:[3,19]):[2];case 18:D.sent(),D.label=19;case 19:return _=x.cell.obj,C=n.build().to(b.ref).apply(KL,w.getDefaultValues(uu.createParams({data:_.data,defaultView:a.defaultView,channelParams:a.options.channelParams})),{ref:a.options.behaviorRef?a.options.behaviorRef:void 0}),a.method==="em"?C.apply(kA,{channel:"em"},{state:{isGhost:!0},tags:"em"}):(C.apply(kA,{channel:"2fo-fc"},{state:{isGhost:!0},tags:"2fo-fc"}),C.apply(kA,{channel:"fo-fc(+ve)"},{state:{isGhost:!0},tags:"fo-fc(+ve)"}),C.apply(kA,{channel:"fo-fc(-ve)"},{state:{isGhost:!0},tags:"fo-fc(-ve)"})),[4,n.updateTree(C).runInContext(i)];case 20:return D.sent(),[2]}})})})}),sie=go.build({display:{name:"Boxify Volume Streaming",description:"Make the current box permanent."},from:uu,isApplicable:function(e){return e.data.params.entry.params.view.name==="selection-box"}})(function(e,t){var r=e.a,n=e.ref,a=e.state,i=r.data.params;if(i.entry.params.view.name==="selection-box"){var o=gt.create(y.clone(i.entry.params.view.params.bottomLeft),y.clone(i.entry.params.view.params.topRight)),s=i.entry.params.view.params.radius;gt.expand(o,o,y.create(s,s,s));var u=P(P({},i),{entry:{name:i.entry.name,params:P(P({},i.entry.params),{view:{name:"box",params:{bottomLeft:o.min,topRight:o.max}}})}});return a.updateTree(a.build().to(n).update(u))}}),f5e={dataId:w.Text(""),source:w.MappedStatic("x-ray",{em:w.Group({isoValue:Je.createIsoValueParam(Je.IsoValue.relative(1))}),"x-ray":w.Group({})})};var d5e=It.BuiltIn({name:"create-volume-streaming-info",display:{name:"Volume Streaming Info"},from:he.Molecule.Structure,to:BA,params:function(e){return{serverUrl:w.Text("https://ds.litemol.org"),entries:w.ObjectList(f5e,function(t){var r=t.dataId;return r},{defaultValue:[{dataId:"",source:{name:"x-ray",params:{}}}]})}}})({apply:function(e,t){var r=e.a,n=e.params;return Ce.create("",function(a){return $(void 0,void 0,void 0,function(){var i,o,s,u,c,l,f,d;return J(this,function(m){switch(m.label){case 0:i=[],o=0,s=n.entries.length,m.label=1;case 1:return o1}},initialState:function(){return{}},apply:function(e,t,r){return $(this,void 0,void 0,function(){var n,a,i,o,s,u,c,l,f,d,m,h,p,v,g,b,x,S,_,C;return J(this,function(D){switch(D.label){case 0:if(n=r.plugin.managers.snapshot.state.entries,n.size<2)return[2,{kind:"finished"}];if(a=t.current%r.params.transtionDurationInMs/r.params.transtionDurationInMs,i=Math.floor(t.current/r.params.transtionDurationInMs)%n.size,o=Math.ceil(t.current/r.params.transtionDurationInMs),o===i&&o++,o=o%n.size,s=n.get(i).snapshot,u=n.get(o).snapshot,!s.data||!u.data)return[2,{kind:"skip"}];for(c=s.data.tree.transforms,l=u.data.tree.transforms,f=r.plugin.state.data,d=f.build(),m=0,h=c;m0)&&(o=!0,i.to(c.transform.ref).apply(Ye.Representation.SpinStructureRepresentation3D,{t:0},{tags:"animate-structure-spin"}));return o?[2,i.commit({doNotUpdateCurrent:!0})]:[2]})})},teardown:function(e,t,r){var n=r.state.data,a=n.select(Yt.Generators.ofType(he.Molecule.Structure.Representation3DState).withTag("animate-structure-spin"));if(a.length!==0){for(var i=n.build(),o=0,s=a;o=.99999?[2,{kind:"finished"}]:[2,{kind:"next",state:e}]))})})}});var dr;(function(e){function t(n,a){return{action:n,customControl:a&&a.customControl,autoUpdate:a&&a.autoUpdate}}e.Action=t;function r(n,a){return a===void 0&&(a={}),{transformer:n,defaultParams:a}}e.Behavior=r})(dr||(dr={}));var mie=function(){return{actions:[dr.Action(Jp.Structure.DownloadStructure),dr.Action(Jp.Volume.DownloadDensity),dr.Action(Jp.DataFormat.DownloadFile),dr.Action(Jp.DataFormat.OpenFiles),dr.Action(Jp.Structure.LoadTrajectory),dr.Action(Jp.Structure.EnableModelCustomProps),dr.Action(Jp.Structure.EnableStructureCustomProps),dr.Action(oie),dr.Action(sie),dr.Action(KL),dr.Action(Ye.Data.Download),dr.Action(Ye.Data.ParseCif),dr.Action(Ye.Data.ParseCcp4),dr.Action(Ye.Data.ParseDsn6),dr.Action(Ye.Model.TrajectoryFromMmCif),dr.Action(Ye.Model.TrajectoryFromCifCore),dr.Action(Ye.Model.TrajectoryFromPDB),dr.Action(Ye.Model.TransformStructureConformation),dr.Action(Ye.Model.StructureFromModel),dr.Action(Ye.Model.StructureFromTrajectory),dr.Action(Ye.Model.ModelFromTrajectory),dr.Action(Ye.Model.StructureSelectionFromScript),dr.Action(Ye.Representation.StructureRepresentation3D),dr.Action(Ye.Representation.StructureSelectionsDistance3D),dr.Action(Ye.Representation.StructureSelectionsAngle3D),dr.Action(Ye.Representation.StructureSelectionsDihedral3D),dr.Action(Ye.Representation.StructureSelectionsLabel3D),dr.Action(Ye.Representation.StructureSelectionsOrientation3D),dr.Action(Ye.Representation.ModelUnitcell3D),dr.Action(Ye.Representation.StructureBoundingBox3D),dr.Action(Ye.Representation.ExplodeStructureRepresentation3D),dr.Action(Ye.Representation.SpinStructureRepresentation3D),dr.Action(Ye.Representation.UnwindStructureAssemblyRepresentation3D),dr.Action(Ye.Representation.OverpaintStructureRepresentation3DFromScript),dr.Action(Ye.Representation.TransparencyStructureRepresentation3DFromScript),dr.Action(Ye.Representation.ClippingStructureRepresentation3DFromScript),dr.Action(Ye.Representation.SubstanceStructureRepresentation3DFromScript),dr.Action(Ye.Representation.ThemeStrengthRepresentation3D),dr.Action(ML),dr.Action(Ye.Volume.VolumeFromCcp4),dr.Action(Ye.Volume.VolumeFromDsn6),dr.Action(Ye.Volume.VolumeFromCube),dr.Action(Ye.Volume.VolumeFromDx),dr.Action(Ye.Representation.VolumeRepresentation3D)],behaviors:[dr.Behavior(su.Representation.HighlightLoci),dr.Behavior(su.Representation.SelectLoci),dr.Behavior(su.Representation.DefaultLociLabelProvider),dr.Behavior(su.Representation.FocusLoci),dr.Behavior(su.Camera.FocusLoci),dr.Behavior(su.Camera.CameraAxisHelper),dr.Behavior(su.Camera.CameraControls),dr.Behavior(Wv),dr.Behavior(su.CustomProps.StructureInfo),dr.Behavior(su.CustomProps.AccessibleSurfaceArea),dr.Behavior(su.CustomProps.BestDatabaseSequenceMapping),dr.Behavior(su.CustomProps.Interactions),dr.Behavior(su.CustomProps.SecondaryStructure),dr.Behavior(su.CustomProps.ValenceModel),dr.Behavior(su.CustomProps.CrossLinkRestraint)],animations:[hee,pee,die,gee,fee,cie,uie]}};var pS;(function(e){var t=function(){function r(){this.providers=ec().asMutable(),this.defaultAutoAttachValues=new Map}return r.prototype.getParams=function(n){var a={},i=[],o=[];if(n)for(var s=this.providers.values();;){var u=s.next();if(u.done)break;var c=u.value;c.isApplicable(n)&&(c.isHidden||(i.push([c.descriptor.name,c.label]),this.defaultAutoAttachValues.get(c.descriptor.name)&&o.push(c.descriptor.name)),a[c.descriptor.name]=w.Group(P({},c.getParams(n)),{label:c.label,isHidden:c.isHidden}))}return{autoAttach:w.MultiSelect(o,i),properties:w.Group(a,{isFlat:!0})}},r.prototype.setDefaultAutoAttach=function(n,a){this.defaultAutoAttachValues.set(n,a)},r.prototype.get=function(n){var a=this.providers.get(n);if(!a)throw new Error("Custom property '".concat(n,"' is not registered."));return this.providers.get(n)},r.prototype.register=function(n,a){this.providers.set(n.descriptor.name,n),this.defaultAutoAttachValues.set(n.descriptor.name,a)},r.prototype.unregister=function(n){this.providers.delete(n),this.defaultAutoAttachValues.delete(n)},r}();e.Registry=t})(pS||(pS={}));var pie=function(){function e(t){this.plugin=t}return Object.defineProperty(e.prototype,"dataState",{get:function(){return this.plugin.state.data},enumerable:!1,configurable:!0}),e.prototype.rawData=function(t,r){var n=this.dataState.build().toRoot().apply(DM,t,r);return n.commit({revertOnError:!0})},e.prototype.download=function(t,r){var n=this.dataState.build().toRoot().apply(TM,t,r);return n.commit({revertOnError:!0})},e.prototype.downloadBlob=function(t,r){var n=this.dataState.build().toRoot().apply(AM,t,r);return n.commit({revertOnError:!0})},e.prototype.readFile=function(t,r){var n,a,i;return $(this,void 0,void 0,function(){var o,s;return J(this,function(u){switch(u.label){case 0:return[4,this.dataState.build().toRoot().apply(PM,t,r).commit({revertOnError:!0})];case 1:return o=u.sent(),s=Zf((i=(a=(n=t.file)===null||n===void 0?void 0:n.file)===null||a===void 0?void 0:a.name)!==null&&i!==void 0?i:""),[2,{data:o,fileInfo:s}]}})})},e}();var hie=function(){function e(t){var r=this;this.plugin=t,this._providers=[],this.providerMap=new Map,this.defaultProvider=gc.auto,Ua(gc,function(n){return r.registerPreset(n)})}return Object.defineProperty(e.prototype,"dataState",{get:function(){return this.plugin.state.data},enumerable:!1,configurable:!0}),e.prototype.resolveProvider=function(t){var r;return typeof t=="string"?(r=gc[t])!==null&&r!==void 0?r:g0(this._providers,function(n){return n.id===t}):t},e.prototype.hasPreset=function(t){for(var r=0,n=this._providers;r1},params:p5e,apply:function(e,t,r){var n,a;return $(this,void 0,void 0,function(){var i,o,s,u,c,l,f,d,m,h,p;return J(this,function(v){switch(v.label){case 0:if(i=(a=(n=Xa.resolveAndCheck(r.state.data,e))===null||n===void 0?void 0:n.obj)===null||a===void 0?void 0:a.data,!i)return[2,{}];if(i.frameCount===1&&t.useDefaultIfSingleModel)return[2,vie.apply(e,t,r)];o=r.builders.structure,s=[],u=[],c=0,v.label=1;case 1:return c0&&(o.push(a.apply(Ye.Volume.VolumeFromDensityServerCif,{blockHeader:l.header,entryId:f}).selector),s++));return[4,a.commit()];case 2:v.sent(),d=0,m=o,v.label=3;case 3:return d0&&(i=r[0].data&&Cie(r[0].data)||Je.IsoValue.relative(1.5),a[0]=n.to(r[0]).apply(Ye.Representation.VolumeRepresentation3D,al.getDefaultParamsStatic(e,"isosurface",{isoValue:i,alpha:1},"uniform",{value:Xt.teal})).selector),r.length>1&&(o=al.getDefaultParamsStatic(e,"isosurface",{isoValue:Je.IsoValue.relative(3),alpha:.3},"uniform",{value:Xt.green}),s=al.getDefaultParamsStatic(e,"isosurface",{isoValue:Je.IsoValue.relative(-3),alpha:.3},"uniform",{value:Xt.red}),a[a.length]=n.to(r[1]).apply(Ye.Representation.VolumeRepresentation3D,o).selector,a[a.length]=n.to(r[1]).apply(Ye.Representation.VolumeRepresentation3D,s).selector),[4,n.commit()];case 1:return u.sent(),[2,a]}})})}},A5e={label:"Segmentation CIF",description:"Segmentation CIF",category:Xy,stringExtensions:["cif"],binaryExtensions:["bcif"],isApplicable:function(e,t){return Hy(e,t)==="segcif"},parse:function(e,t){return $(void 0,void 0,void 0,function(){var r,n,a,i,o,s,u,c;return J(this,function(l){switch(l.label){case 0:return[4,e.build().to(t).apply(Ye.Data.ParseCif).commit()];case 1:if(r=l.sent(),n=e.build().to(r),a=r.obj.data.blocks,a.length===0)throw new Error("no data blocks");for(i=[],o=0,s=a;o0&&i.push(n.apply(Ye.Volume.VolumeFromSegmentationCif,{blockHeader:u.header}).selector);return[4,n.commit()];case 2:return l.sent(),[2,{volumes:i}]}})})},visuals:function(e,t){return $(void 0,void 0,void 0,function(){var r,n,a,i;return J(this,function(o){switch(o.label){case 0:return r=t.volumes,n=e.build(),a=[],r.length>0&&(i=Je.Segmentation.get(r[0].data),i&&(a[a.length]=n.to(r[0]).apply(Ye.Representation.VolumeRepresentation3D,al.getDefaultParams(e,"segment",r[0].data,{alpha:1,instanceGranularity:!0},"volume-segment",{})).selector)),[4,n.commit()];case 1:return o.sent(),[2,a]}})})}},_ie=[["ccp4",S5e],["dsn6",C5e],["cube",w5e],["dx",_5e],["dscif",T5e],["segcif",A5e]];var D5e="Shape",P5e={label:"PLY",description:"PLY",category:D5e,stringExtensions:["ply"],parse:function(e,t){return $(void 0,void 0,void 0,function(){var r,n;return J(this,function(a){switch(a.label){case 0:return r=e.state.data.build().to(t).apply(Ye.Data.ParsePly,{},{state:{isGhost:!0}}),n=r.apply(Ye.Model.ShapeFromPly),[4,r.commit()];case 1:return a.sent(),[2,{format:r.selector,shape:n.selector}]}})})},visuals:function(e,t){var r=e.state.data.build().to(t.shape).apply(Ye.Representation.ShapeRepresentation3D);return r.commit()}},wie=[["ply",P5e]];var Tie=function(){function e(){this._list=[],this._map=new Map,this._extensions=void 0,this._binaryExtensions=void 0,this._options=void 0;for(var t=0,r=_ie;t=3*t||(r=$L(e,{skipHydrogens:!0,skipWater:!0}),r.length>=3*t)||(r=$L(e,{})),r}function $L(e,t){for(var r=t.onlyTrace,n=t.skipHydrogens,a=t.skipWater,i=nt.atom,o=i.x,s=i.y,u=i.z,c=i.type_symbol,l=i.label_comp_id,f=[],d=0,m=e;dn&&(r=s,n=u)}return r}function O5e(e,t,r){for(var n=y.create(Ht.getValue(t,0,0),Ht.getValue(t,0,1),Ht.getValue(t,0,2)),a=y.create(Ht.getValue(t,1,0),Ht.getValue(t,1,1),Ht.getValue(t,1,2)),i=y.create(Ht.getValue(t,2,0),Ht.getValue(t,2,1),Ht.getValue(t,2,2)),o=Math.floor(e.length/3),s=y(),u=0,c=0,l=0,f=0;f1){for(var a=[],i=0,o=t;i1&&f[0]!==f[1]?d:f[0];t.labels.push(m===1?h:"".concat(h," || \xD7 ").concat(m,""))}),this.isDirty=!1}return this.labels},e}();var Bie="overpaint-controls";function e4(e,t,r,n,a){return $(this,void 0,void 0,function(){var i=this;return J(this,function(o){switch(o.label){case 0:return[4,U5e(e,t,function(s,u,c){return $(i,void 0,void 0,function(){var l,f,d,m,h,h;return J(this,function(p){switch(p.label){case 0:return a&&a.length>0&&!a.includes(u.params.values.type.name)?[2]:(l=u.obj.data.sourceData,[4,n(l.root)]);case 1:return f=p.sent(),jt.isEmpty(f)||qa(f)?[2]:(d={bundle:ie.Bundle.fromLoci(f),color:r===-1?Xe(0):r,clear:r===-1},c?(m=Ut(Ut([],c.params.values.layers,!0),[d],!1),h=Rie(m,l),s.to(c).update(Fi.toBundle(h))):(h=Rie([d],l),s.to(u.transform.ref).apply(Ye.Representation.OverpaintStructureRepresentation3DFromBundle,Fi.toBundle(h),{tags:Bie})),[2])}})})})];case 1:return o.sent(),[2]}})})}function U5e(e,t,r){return $(this,void 0,void 0,function(){var n,a,i,o,s,u,c,l,f;return J(this,function(d){switch(d.label){case 0:n=e.state.data,a=n.build(),i=0,o=t,d.label=1;case 1:if(!(i0&&!a.includes(u.params.values.type.name)?[2]:(l=u.obj.data.sourceData,[4,n(l.root)]);case 1:return f=p.sent(),jt.isEmpty(f)||qa(f)?[2]:(d={bundle:ie.Bundle.fromLoci(f),groups:r},c?(m=Ut(Ut([],c.params.values.layers,!0),[d],!1),h=Oie(m,l),s.to(c).update(Dn.toBundle(h))):(h=Oie([d],l),s.to(u.transform.ref).apply(Ye.Representation.ClippingStructureRepresentation3DFromBundle,Dn.toBundle(h),{tags:Fie})),[2])}})})})];case 1:return o.sent(),[2]}})})}function V5e(e,t,r){return $(this,void 0,void 0,function(){var n,a,i,o,s,u,c,l,f;return J(this,function(d){switch(d.label){case 0:n=e.state.data,a=n.build(),i=0,o=t,d.label=1;case 1:if(!(i0&&!a.includes(u.params.values.type.name)?[2]:(l=u.obj.data.sourceData,[4,n(l.root)]);case 1:return f=p.sent(),jt.isEmpty(f)||qa(f)?[2]:(d={bundle:ie.Bundle.fromLoci(f),value:r},c?(m=Ut(Ut([],c.params.values.layers,!0),[d],!1),h=kie(m,l),s.to(c).update(Li.toBundle(h))):(h=kie([d],l),s.to(u.transform.ref).apply(Ye.Representation.TransparencyStructureRepresentation3DFromBundle,Li.toBundle(h),{tags:Nie})),[2])}})})})];case 1:return o.sent(),[2]}})})}function G5e(e,t,r){return $(this,void 0,void 0,function(){var n,a,i,o,s,u,c,l,f;return J(this,function(d){switch(d.label){case 0:n=e.state.data,a=n.build(),i=0,o=t,d.label=1;case 1:if(!(i0&&!a.includes(u.params.values.type.name)?[2]:(l=u.obj.data.sourceData,[4,n(l.root)]);case 1:return f=p.sent(),jt.isEmpty(f)||qa(f)?[2]:(d={bundle:ie.Bundle.fromLoci(f),material:r??Pi(),clear:!r},c?(m=Ut(Ut([],c.params.values.layers,!0),[d],!1),h=Vie(m,l),s.to(c).update(ki.toBundle(h))):(h=Vie([d],l),s.to(u.transform.ref).apply(Ye.Representation.SubstanceStructureRepresentation3DFromBundle,ki.toBundle(h),{tags:Gie})),[2])}})})})];case 1:return o.sent(),[2]}})})}function z5e(e,t,r){return $(this,void 0,void 0,function(){var n,a,i,o,s,u,c,l,f;return J(this,function(d){switch(d.label){case 0:n=e.state.data,a=n.build(),i=0,o=t,d.label=1;case 1:if(!(i"]]:[]),options:w.Group({label:w.Text(""),checkExisting:w.Boolean(!!o?.checkExisting,{help:function(){return{description:"Checks if a selection with the specifield elements already exists to avoid creating duplicate components."}}})})}}e.getAddParams=t;function r(i,o){var s=i.query.structure.registry.options;return{selection:w.Select(s[1][0],s,{isHidden:!1}),action:w.MappedStatic("color",{color:w.Group({color:w.Color(Xt.blue,{isExpanded:!0})},{isFlat:!0}),resetColor:w.EmptyGroup({label:"Reset Color"}),transparency:w.Group({value:w.Numeric(.5,{min:0,max:1,step:.01})},{isFlat:!0}),material:w.Group({material:Pi.getParam({isFlat:!0})},{isFlat:!0}),resetMaterial:w.EmptyGroup({label:"Reset Material"}),clipping:w.Group({excludeGroups:w.MultiSelect([],w.objectToOptions(Dn.Groups.Names))},{isFlat:!0})}),representations:w.MultiSelect([],n(i,o),{emptyValue:"All"})}}e.getThemeParams=r;function n(i,o){var s,u;return!((s=o?.cell.obj)===null||s===void 0)&&s.data?i.representation.structure.registry.getApplicableTypes((u=o.cell.obj)===null||u===void 0?void 0:u.data):i.representation.structure.registry.types}e.getRepresentationTypes=n;function a(i,o,s,u){var c=Ut(Ut([],s,!0),n(i,o),!0);return w.Select(c[0][0],c,{label:u})}})(zA||(zA={}));var H5e=8,zie=function(e){St(t,e);function t(r){var n=e.call(this,{history:[]})||this;n.plugin=r,n.events={historyUpdated:n.ev()},n.behaviors={current:n.ev.behavior(void 0)},r.state.data.events.object.removed.subscribe(function(i){var o,s,u=i.obj;if(he.Molecule.Structure.is(u)){((s=n.current)===null||s===void 0?void 0:s.loci.structure)===u.data&&n.clear();for(var c=[],l=0,f=n.history;la.radius||h>m.viewport.height/m.zoom)&&n.plugin.managers.camera.focusSphere(a,{durationMs:0})}}}),n}return Object.defineProperty(t.prototype,"current",{get:function(){return this.state.current},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"history",{get:function(){return this.state.history},enumerable:!1,configurable:!0}),t.prototype.tryAddHistory=function(r){if(!ie.Loci.isEmpty(r.loci)){for(var n=0,a=void 0,i=0,o=this.state.history;iH5e&&this.state.history.pop(),this.events.historyUpdated.next(void 0)}},t.prototype.set=function(r){this.tryAddHistory(r),(!this.state.current||!ie.Loci.areEqual(this.state.current.loci,r.loci))&&(this.state.current=r,this.behaviors.current.next(r))},t.prototype.setFromLoci=function(r){var n=jt.normalize(r);if(!ie.Loci.is(n)||ie.Loci.isEmpty(n)){this.clear();return}this.set({loci:n,label:Rv(n,{reverse:!0,hidePrefix:!0,htmlStyling:!1})})},t.prototype.addFromLoci=function(r){var n=this.state.current&&ie.Loci.is(r)&&r.structure===this.state.current.loci.structure?ie.Loci.union(r,this.state.current.loci):r;this.setFromLoci(n)},t.prototype.clear=function(){this.state.current&&(this.state.current=void 0,this.behaviors.current.next(void 0))},t.prototype.getSnapshot=function(){if(!this.current)return{};var r=this.plugin.helpers.substructureParent.get(this.current.loci.structure),n=r?.transform.ref;return n?{current:{label:this.current.label,ref:n,bundle:ie.Bundle.fromLoci(this.current.loci),category:this.current.category}}:{}},t.prototype.setSnapshot=function(r){var n,a;if(!r.current){this.clear();return}var i=r.current,o=i.label,s=i.ref,u=i.bundle,c=i.category,l=(a=(n=this.plugin.state.data.select(Yt.Generators.byRef(s))[0])===null||n===void 0?void 0:n.obj)===null||a===void 0?void 0:a.data;if(l){var f=ie.Bundle.toLoci(u,l);this.set({label:o,loci:f,category:c})}},t}(ns);function Yie(e,t){var r=eUe(e,t||jA());return aUe(e.tree,r),t&&t.refs.forEach(rUe,r),{hierarchy:r.hierarchy,added:r.added,changed:r.changed}}function jA(){return{trajectories:[],models:[],structures:[],refs:new Map}}function j5e(e){return{kind:"trajectory",cell:e,version:e.transform.version,models:[]}}function Hie(e,t){return{kind:"model",cell:e,version:e.transform.version,trajectory:t,structures:[]}}function q5e(e,t){return{kind:"model-properties",cell:e,version:e.transform.version,model:t}}function W5e(e,t){return{kind:"model-unitcell",cell:e,version:e.transform.version,model:t}}function jie(e,t){return{kind:"structure",cell:e,version:e.transform.version,model:t,components:[]}}function Y5e(e,t){return{kind:"structure-properties",cell:e,version:e.transform.version,structure:t}}function X5e(e,t){return{kind:"structure-transform",cell:e,version:e.transform.version,structure:t}}function K5e(e,t){return{kind:"structure-volume-streaming",cell:e,version:e.transform.version,structure:t}}function Z5e(e){return e.transform.tags?Ut([],e.transform.tags,!0).sort().join():e.transform.ref}function Q5e(e,t){return{kind:"structure-component",cell:e,version:e.transform.version,structure:t,key:Z5e(e),representations:[]}}function $5e(e,t){return{kind:"structure-representation",cell:e,version:e.transform.version,component:t}}function J5e(e,t){return{kind:"generic-representation",cell:e,version:e.transform.version,parent:t}}function eUe(e,t){return{state:e,oldHierarchy:t,hierarchy:jA(),changed:!1,added:new Set}}function Ky(e,t,r,n){for(var a=[],i=4;i0?[r[0]]:[]:i},t.prototype.sync=function(r){if(!(!r&&this.dataState.inUpdate)){if(this.state.syncedTree===this.dataState.tree){r&&!this.state.notified&&(this.state.notified=!0,this.behaviors.selection.next(P({hierarchy:this.state.hierarchy},this.state.selection)));return}this.state.syncedTree=this.dataState.tree;var n=Yie(this.plugin.state.data,this.current);if(n.changed){var a=n.hierarchy,i=this.syncCurrent(a.trajectories,n.added),o=this.syncCurrent(a.models,n.added),s=this.syncCurrent(a.structures,n.added);this._currentComponentGroups=void 0,this._currentSelectionSet=void 0,this.state.hierarchy=a,this.state.selection.trajectories=i,this.state.selection.models=o,this.state.selection.structures=s,r?(this.state.notified=!0,this.behaviors.selection.next({hierarchy:a,trajectories:i,models:o,structures:s})):this.state.notified=!1}}},t.prototype.updateCurrent=function(r,n){for(var a=this.current,i=n==="add"?dn.union(this.seletionSet,new Set(r.map(function(b){return b.cell.transform.ref}))):dn.difference(this.seletionSet,new Set(r.map(function(b){return b.cell.transform.ref}))),o=[],s=[],u=[],c=0,l=a.trajectories;c0?[4,this.clearTrajectory(u)]:[3,3]):[3,6];case 2:c.sent(),c.label=3;case 3:return[4,this.plugin.builders.structure.hierarchy.applyPreset(u.cell,n,a)];case 4:c.sent(),c.label=5;case 5:return o++,[3,1];case 6:return[2]}})})})},t.prototype.updateStructure=function(r,n){return $(this,void 0,void 0,function(){var a=this;return J(this,function(i){switch(i.label){case 0:return[4,this.plugin.dataTransaction(function(){return $(a,void 0,void 0,function(){var o,s;return J(this,function(u){switch(u.label){case 0:return o=ya.getDecoratorRoot(this.dataState.tree,r.cell.transform.ref),s=this.dataState.tree.children.get(o).toArray(),[4,this.remove(s,!1)];case 1:return u.sent(),[4,this.plugin.state.updateTransform(this.plugin.state.data,r.cell.transform.ref,n,"Structure Type")];case 2:return u.sent(),[4,this.plugin.builders.structure.representation.applyPreset(r.cell.transform.ref,"auto")];case 3:return u.sent(),[2]}})})},{canUndo:"Structure Type"})];case 1:return i.sent(),rr.Camera.Reset(this.plugin),[2]}})})},t.prototype.clearTrajectory=function(r){for(var n=this.dataState.build(),a=0,i=r.models;asUe&&this.additionsHistory.pop(),this.events.additionsHistoryUpdated.next(void 0)}},t.prototype.clearHistory=function(){this.state.additionsHistory.length!==0&&(this.state.additionsHistory=[],this.events.additionsHistoryUpdated.next(void 0))},t.prototype.clearHistoryForStructure=function(r){for(var n=[],a=0,i=this.state.additionsHistory;aY&&(F=[Y,Z],Z=F[0],Y=F[1]),l[Z+1]-l[Z]===1&&(j=[Y,Z],Z=j[0],Y=j[1]);for(var N=X.get(Z)||W.get(Z),ee=0,oe=l[Z],me=l[Z+1];oeee&&(ee=re,I(a[pe],A))}else return I(a[pe],A)}return ee>0?A:null},position:function(q,F,j){if(I(a[s[j]],q),I(a[u[j]],F),p){var Z=V(j),Y=U(j),H=Math.min(Z,Y)*h,N=Math.sqrt(Math.max(0,Z*Z-H*H))-.05,ee=Math.sqrt(Math.max(0,Y*Y-H*H))-.05;if(N<=.01&&ee<=.01)return;y.normalize(E,y.sub(E,F,q)),y.scaleAndAdd(q,q,E,N),y.scaleAndAdd(F,F,E,-ee)}},style:function(q){var F=f[q],j=d[q];if(u4(j,2)||u4(j,4))return 1;if(F===3)return S?0:_?4:5;if(v){var Z=s[q],Y=u[q],H=X.get(Z),N=X.get(Y),ee=H&&N?T0(H,N):0;if(u4(j,16)||ee&&!T)return ee===2?8:7}return F!==2||S?0:_?2:3},radius:function(q){return G(q)*h},ignore:KA(t,e,n),stub:R}}function CUe(e,t,r,n,a,i){if(!Te.isAtomic(t))return zi.createEmpty(i);if(!t.bonds.edgeCount)return zi.createEmpty(i);var o=r.child,s=o?.unitMap.get(t.id);if(o&&!s)return zi.createEmpty(i);var u=noe(t,r,n,a),c=AA(e,u,a,i),l=c.cylinders,f=c.boundingSphere;if(f)l.setBoundingSphere(f);else if(l.cylinderCount>0){var d=xe.expand(xe(),(s??t).boundary.sphere,1*a.sizeFactor);l.setBoundingSphere(d)}return l}function _Ue(e,t,r,n,a,i){if(!Te.isAtomic(t))return pt.createEmpty(i);if(!t.bonds.edgeCount)return pt.createEmpty(i);var o=r.child,s=o?.unitMap.get(t.id);if(o&&!s)return pt.createEmpty(i);var u=noe(t,r,n,a),c=Vu(e,u,a,i),l=c.mesh,f=c.boundingSphere;if(f)l.setBoundingSphere(f);else if(l.triangleCount>0){var d=xe.expand(xe(),(s??t).boundary.sphere,1*a.sizeFactor);l.setBoundingSphere(d)}return l}var Qy=P(P(P(P({},Wn),wA),yS),{sizeFactor:w.Numeric(.3,{min:0,max:10,step:.01}),sizeAspectRatio:w.Numeric(2/3,{min:0,max:3,step:.01}),tryUseImpostor:w.Boolean(!0),includeParent:w.Boolean(!1)});function QA(e,t,r,n){return r.tryUseImpostor&&n&&n.extensions.fragDepth?wUe(e):TUe(e)}function wUe(e){return TA({defaultProps:w.getDefaultValues(Qy),createGeometry:CUe,createLocationIterator:fl.fromGroup,getLoci:xS,eachLocation:SS,setUpdateState:function(t,r,n,a,i,o,s){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.sizeAspectRatio!==n.sizeAspectRatio||r.linkScale!==n.linkScale||r.linkSpacing!==n.linkSpacing||r.ignoreHydrogens!==n.ignoreHydrogens||r.ignoreHydrogensVariant!==n.ignoreHydrogensVariant||r.linkCap!==n.linkCap||r.aromaticScale!==n.aromaticScale||r.aromaticSpacing!==n.aromaticSpacing||r.aromaticDashCount!==n.aromaticDashCount||r.dashCount!==n.dashCount||r.dashScale!==n.dashScale||r.dashCap!==n.dashCap||r.stubCap!==n.stubCap||!Xi(r.includeTypes,n.includeTypes)||!Xi(r.excludeTypes,n.excludeTypes)||r.adjustCylinderLength!==n.adjustCylinderLength||r.aromaticBonds!==n.aromaticBonds||r.multipleBonds!==n.multipleBonds;var u=o.group.units[0],c=s.group.units[0];Te.isAtomic(u)&&Te.isAtomic(c)&&(Mi.areEqual(u.bonds,c.bonds)||(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0))},mustRecreate:function(t,r,n){return!r.tryUseImpostor||!n}},e)}function TUe(e){return Ca({defaultProps:w.getDefaultValues(Qy),createGeometry:_Ue,createLocationIterator:fl.fromGroup,getLoci:xS,eachLocation:SS,setUpdateState:function(t,r,n,a,i,o,s){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.sizeAspectRatio!==n.sizeAspectRatio||r.radialSegments!==n.radialSegments||r.linkScale!==n.linkScale||r.linkSpacing!==n.linkSpacing||r.ignoreHydrogens!==n.ignoreHydrogens||r.ignoreHydrogensVariant!==n.ignoreHydrogensVariant||r.linkCap!==n.linkCap||r.aromaticScale!==n.aromaticScale||r.aromaticSpacing!==n.aromaticSpacing||r.aromaticDashCount!==n.aromaticDashCount||r.dashCount!==n.dashCount||r.dashScale!==n.dashScale||r.dashCap!==n.dashCap||r.stubCap!==n.stubCap||!Xi(r.includeTypes,n.includeTypes)||!Xi(r.excludeTypes,n.excludeTypes)||r.adjustCylinderLength!==n.adjustCylinderLength||r.aromaticBonds!==n.aromaticBonds||r.multipleBonds!==n.multipleBonds;var u=o.group.units[0],c=s.group.units[0];Te.isAtomic(u)&&Te.isAtomic(c)&&(Mi.areEqual(u.bonds,c.bonds)||(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0))},mustRecreate:function(t,r,n){return r.tryUseImpostor&&!!n}},e)}var c4=new mt.ElementBondIterator;function aoe(e,t,r,n){for(c4.setElement(t,r,n);c4.hasNext;){var a=c4.move();return a.otherUnit.conformation.position(a.otherUnit.elements[a.otherIndex],e),e}return null}var ioe=y();function ooe(e,t,r){var n=ie.Location.create(e),a=mt.Location(e,void 0,void 0,e,void 0,void 0),i=e.interUnitBonds,o=i.edgeCount,s=i.edges,u=r.sizeFactor,c=r.sizeAspectRatio,l=r.adjustCylinderLength,f=r.aromaticBonds,d=r.multipleBonds,m=d==="off",h=d==="symmetric",p=y(),v,g=e.child;r.includeParent&&g&&(v=function(_){var C=s[_],D=g.unitMap.get(C.unitA),T=g.unitMap.get(C.unitB),A=e.unitMap.get(C.unitA),E=A.elements[C.indexA],I=e.unitMap.get(C.unitB),R=I.elements[C.indexB];return D&&Fe.has(D.elements,E)&&(!T||!Fe.has(T.elements,R))});var b=function(_){var C=s[_];return a.aUnit=e.unitMap.get(C.unitA),a.aIndex=C.indexA,a.bUnit=e.unitMap.get(C.unitB),a.bIndex=C.indexB,t.size.size(a)*u},x=function(_){var C=s[_];return n.unit=e.unitMap.get(C.unitA),n.element=n.unit.elements[C.indexA],t.size.size(n)*u},S=function(_){var C=s[_];return n.unit=e.unitMap.get(C.unitB),n.element=n.unit.elements[C.indexB],t.size.size(n)*u};return{linkCount:o,referencePosition:function(_){var C=s[_],D,T,A,E;if(C.unitAC.unitB)D=e.unitMap.get(C.unitB),T=e.unitMap.get(C.unitA),A=C.indexB,E=C.indexA;else throw new Error("same units in createInterUnitBondCylinderMesh");return aoe(ioe,e,D,A)||aoe(ioe,e,T,E)},position:function(_,C,D){var T=s[D],A=e.unitMap.get(T.unitA),E=e.unitMap.get(T.unitB);if(A.conformation.position(A.elements[T.indexA],_),E.conformation.position(E.elements[T.indexB],C),l){var I=x(D),R=S(D),B=Math.min(I,R)*c,O=Math.sqrt(Math.max(0,I*I-B*B))-.05,z=Math.sqrt(Math.max(0,R*R-B*B))-.05;if(O<=.01&&z<=.01)return;y.normalize(p,y.sub(p,C,_)),y.scaleAndAdd(_,_,p,O),y.scaleAndAdd(C,C,p,-z)}},style:function(_){var C=s[_].props.order,D=Ya.create(s[_].props.flag);return mr.is(D,2)||mr.is(D,4)?1:C===3?m?0:h?4:5:f&&mr.is(D,16)?7:C!==2||m?0:h?2:3},radius:function(_){return b(_)*c},ignore:ZA(e,r),stub:v}}function AUe(e,t,r,n,a){if(!t.interUnitBonds.edgeCount)return zi.createEmpty(a);var i=ooe(t,r,n),o=AA(e,i,n,a),s=o.cylinders,u=o.boundingSphere;if(u)s.setBoundingSphere(u);else if(s.cylinderCount>0){var c=t.child,l=xe.expand(xe(),(c??t).boundary.sphere,1*n.sizeFactor);s.setBoundingSphere(l)}return s}function DUe(e,t,r,n,a){if(!t.interUnitBonds.edgeCount)return pt.createEmpty(a);var i=ooe(t,r,n),o=Vu(e,i,n,a),s=o.mesh,u=o.boundingSphere;if(u)s.setBoundingSphere(u);else if(s.triangleCount>0){var c=t.child,l=xe.expand(xe(),(c??t).boundary.sphere,1*n.sizeFactor);s.setBoundingSphere(l)}return s}var $y=P(P(P(P({},ol),Tne),yS),{sizeFactor:w.Numeric(.3,{min:0,max:10,step:.01}),sizeAspectRatio:w.Numeric(2/3,{min:0,max:3,step:.01}),tryUseImpostor:w.Boolean(!0),includeParent:w.Boolean(!1)});function $A(e,t,r,n){return r.tryUseImpostor&&n&&n.extensions.fragDepth?PUe(e):EUe(e)}function PUe(e){return Ane({defaultProps:w.getDefaultValues($y),createGeometry:AUe,createLocationIterator:fl.fromStructure,getLoci:CS,eachLocation:_S,setUpdateState:function(t,r,n,a,i,o,s){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.sizeAspectRatio!==n.sizeAspectRatio||r.linkScale!==n.linkScale||r.linkSpacing!==n.linkSpacing||r.ignoreHydrogens!==n.ignoreHydrogens||r.ignoreHydrogensVariant!==n.ignoreHydrogensVariant||r.linkCap!==n.linkCap||r.aromaticScale!==n.aromaticScale||r.aromaticSpacing!==n.aromaticSpacing||r.aromaticDashCount!==n.aromaticDashCount||r.dashCount!==n.dashCount||r.dashScale!==n.dashScale||r.dashCap!==n.dashCap||r.stubCap!==n.stubCap||!Xi(r.includeTypes,n.includeTypes)||!Xi(r.excludeTypes,n.excludeTypes)||r.adjustCylinderLength!==n.adjustCylinderLength||r.multipleBonds!==n.multipleBonds,o.interUnitBonds!==s.interUnitBonds&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0)},mustRecreate:function(t,r,n){return!r.tryUseImpostor||!n}},e)}function EUe(e){return is({defaultProps:w.getDefaultValues($y),createGeometry:DUe,createLocationIterator:fl.fromStructure,getLoci:CS,eachLocation:_S,setUpdateState:function(t,r,n,a,i,o,s){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.sizeAspectRatio!==n.sizeAspectRatio||r.radialSegments!==n.radialSegments||r.linkScale!==n.linkScale||r.linkSpacing!==n.linkSpacing||r.ignoreHydrogens!==n.ignoreHydrogens||r.ignoreHydrogensVariant!==n.ignoreHydrogensVariant||r.linkCap!==n.linkCap||r.aromaticScale!==n.aromaticScale||r.aromaticSpacing!==n.aromaticSpacing||r.aromaticDashCount!==n.aromaticDashCount||r.dashCount!==n.dashCount||r.dashScale!==n.dashScale||r.dashCap!==n.dashCap||r.stubCap!==n.stubCap||!Xi(r.includeTypes,n.includeTypes)||!Xi(r.excludeTypes,n.excludeTypes)||r.adjustCylinderLength!==n.adjustCylinderLength||r.multipleBonds!==n.multipleBonds,o.interUnitBonds!==s.interUnitBonds&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0)},mustRecreate:function(t,r,n){return r.tryUseImpostor&&!!n}},e)}var IUe=He.add3,MUe=He.add,eg;(function(e){function t(r,n,a){r===void 0&&(r=2048),n===void 0&&(n=1024);var i=He.create(Float32Array,3,n,a?a.centerBuffer.ref.value:r),o=He.create(Float32Array,1,n,a?a.groupBuffer.ref.value:r);return{add:function(s,u,c,l){IUe(i,s,u,c),MUe(o,l)},getSpheres:function(){var s=He.compact(i,!0),u=He.compact(o,!0);return ys.create(s,u,i.elementCount,a)}}}e.create=t})(eg||(eg={}));var Jy=y.add;function Jf(e,t,r){var n=r.ignoreHydrogens,a=r.ignoreHydrogensVariant,i=r.traceOnly,o=Te.isCoarse(t),s=e.child,u=s?.unitMap.get(t.id);if(s&&!u)throw new Error("expected childUnit to exist if child exists");if(!(!s&&!n&&!i))return function(c){return!!u&&!Fe.has(u.elements,c)||!o&&n&&iu(e,t,c,a)||i&&!pA(t,c)}}function soe(e,t,r,n,a,i){var o=r.child,s=o?.unitMap.get(t.id);if(o&&!s)return pt.createEmpty(i);for(var u=a.detail,c=a.sizeFactor,l=a.stride,f=t.elements,d=f.length,m=d*Pd(u),h=ot.createState(m,m/2,i),p=y(),v=t.conformation.invariantPosition,g=Jf(r,t,a),b=ie.Location.create(r,t),x=n.size.size,S=y(),_=0,C=0,D=0;D_&&(_=T),h.currentGroup=D,Kn(h,p,T*c,u)}var A=i?xe.clone(i.boundingSphere):void 0,E=ot.getMesh(h);if(C===0)return E;var I;return y.scale(S,S,1/C),A&&y.distance(S,A.center)/A.radius<.1?I=A:I=xe.expand(xe(),(s??t).boundary.sphere,_*c+.05),E.setBoundingSphere(I),E}function uoe(e,t,r,n,a,i){var o=r.child,s=o?.unitMap.get(t.id);if(o&&!s)return ys.createEmpty(i);var u=a.sizeFactor,c=a.stride,l=t.elements,f=l.length,d=eg.create(f,f/2,i),m=y(),h=t.conformation.invariantPosition,p=Jf(r,t,a),v=ie.Location.create(r,t),g=n.size.size,b=y(),x=0,S=0;if(c&&c>1||p||n.size.granularity!=="uniform"){for(var _=0;_x&&(x=C)}}else{for(var _=0;_p&&(p=B),d.currentGroup=c(x,R),Kn(d,D,B*s,o)}}}var O=a?xe.clone(a.boundingSphere):void 0,z=ot.getMesh(d);if(v===0)return z;var k;return y.scale(h,h,1/v),O&&y.distance(h,O.center)/O.radius<1?k=O:k=xe.expand(xe(),(i??t).boundary.sphere,p*s+.05),z.setBoundingSphere(k),z}function loe(e,t,r,n,a){for(var i=t.child,o=n.sizeFactor,s=n.stride,u=t.serialMapping.getSerialIndex,c=t.elementCount,l=eg.create(c,c/2,a),f=r.size.size,d=y(),m=0,h=0,p=0,v=t.units;p1||D||r.size.granularity!=="uniform")for(var A=0;Am&&(m=I)}}else{for(var A=0;A0},getData:function(e,t){return t.includeParent?e.asParent():e},mustRecreate:function(e,t){return e.includeParent!==t.includeParent}};function NUe(e,t,r,n,a){var i=t.carbohydrates,o=i.links,s=i.elements,u=n.linkSizeFactor,c=ie.Location.create(t),l={linkCount:o.length,position:function(p,v,g){var b=o[g];y.copy(p,s[b.carbohydrateIndexA].geometry.center),y.copy(v,s[b.carbohydrateIndexB].geometry.center)},radius:function(p){var v=o[p],g=s[v.carbohydrateIndexA],b=g.unit.rings.all[g.ringIndex];return c.unit=g.unit,c.element=g.unit.elements[b[0]],r.size.size(c)*u}},f=Vu(e,l,n,a),d=f.mesh,m=f.boundingSphere;if(m)d.setBoundingSphere(m);else if(d.triangleCount>0){var h=xe.expand(xe(),t.boundary.sphere,1*u);d.setBoundingSphere(h)}return d}var f4=P(P(P({},Wn),hc),{linkSizeFactor:w.Numeric(.3,{min:0,max:3,step:.01})});function goe(e){return is({defaultProps:w.getDefaultValues(f4),createGeometry:NUe,createLocationIterator:UUe,getLoci:VUe,eachLocation:GUe,setUpdateState:function(t,r,n){t.createGeometry=r.linkSizeFactor!==n.linkSizeFactor||r.radialSegments!==n.radialSegments||r.linkCap!==n.linkCap}},e)}function UUe(e){var t=e.carbohydrates,r=t.elements,n=t.links,a=n.length,i=1,o=ie.Location.create(e),s=function(u){var c=n[u],l=r[c.carbohydrateIndexA],f=l.unit.rings.all[l.ringIndex];return o.unit=l.unit,o.element=l.unit.elements[f[0]],o};return hr(a,i,1,s,!0)}function VUe(e,t,r){var n=e.objectId,a=e.groupId;if(r===n){var i=t.carbohydrates,o=i.links,s=i.elements,u=o[a],c=s[u.carbohydrateIndexA],l=s[u.carbohydrateIndexB];return ie.Loci.union(Yp(t,c.unit,c.residueIndex,c.altId),Yp(t,l.unit,l.residueIndex,l.altId))}return Jt}var l4=new Set;function GUe(e,t,r){var n=!1;if(!ie.Loci.is(e)||!Le.areEquivalent(e.structure,t))return!1;for(var a=t.carbohydrates.getLinkIndices,i=function(f,d){if(!Te.isAtomic(f))return"continue";l4.clear(),Ee.forEach(d,function(m){for(var h=a(f,f.elements[m]),p=0,v=h.length;p0){var h=xe.expand(xe(),t.boundary.sphere,1*u);d.setBoundingSphere(h)}return d}var w4=P(P(P({},Wn),hc),{terminalLinkSizeFactor:w.Numeric(.2,{min:0,max:3,step:.01})});function Moe(e){return is({defaultProps:w.getDefaultValues(w4),createGeometry:sVe,createLocationIterator:uVe,getLoci:cVe,eachLocation:lVe,setUpdateState:function(t,r,n){t.createGeometry=r.terminalLinkSizeFactor!==n.terminalLinkSizeFactor||r.radialSegments!==n.radialSegments||r.linkCap!==n.linkCap}},e)}function uVe(e){var t=e.carbohydrates,r=t.elements,n=t.terminalLinks,a=n.length,i=1,o=ie.Location.create(e),s=function(u){var c=n[u];if(c.fromCarbohydrate){var l=r[c.carbohydrateIndex],f=l.unit.rings.all[l.ringIndex];o.unit=l.unit,o.element=l.unit.elements[f[0]]}else o.unit=c.elementUnit,o.element=c.elementUnit.elements[c.elementIndex];return o};return hr(a,i,1,s,!0)}function cVe(e,t,r){var n=e.objectId,a=e.groupId;if(r===n){var i=t.carbohydrates,o=i.terminalLinks,s=i.elements,u=o[a],c=s[u.carbohydrateIndex];return ie.Loci.union(Yp(t,c.unit,c.residueIndex,c.altId),hne(t,u.elementUnit,u.elementUnit.elements[u.elementIndex]))}return Jt}var _4=new Set;function lVe(e,t,r){var n=!1;if(!ie.Loci.is(e)||!Le.areEquivalent(e.structure,t))return!1;for(var a=t.carbohydrates.getTerminalLinkIndices,i=function(f,d){if(!Te.isAtomic(f))return"continue";_4.clear(),Ee.forEach(d,function(m){for(var h=a(f,f.elements[m]),p=0,v=h.length;pl)continue;a=!1}t(n[c-1],n[c],i-1,i,0),++i}}}function A4(e,t){switch(e.kind){case 0:return hVe(e,t);case 1:case 2:return vVe(e,t)}}function hVe(e,t){for(var r=Wr.transientSegments(tg(e),e.elements),n=qt.transientSegments(e.model.atomicHierarchy.residueAtomSegments,e.elements),a=e.model.atomicHierarchy.derived.residue.traceElementIndex,i=0;r.hasNext;)for(n.setSegment(r.move());n.hasNext;){var o=n.move().index;t(a[o],i),++i}}function vVe(e,t){for(var r=Wr.transientSegments(tg(e),e.elements),n=e.elements,a=0;r.hasNext;)for(var i=r.move(),o=i.start,s=i.end,u=o,c=s;uthis.residueSegmentMax){var r=this.cyclicPolymerMap.get(this.residueSegmentMax);r!==void 0?t=r+(t-this.residueSegmentMax-1):t=this.residueSegmentMax}return t},e.prototype.getSecStruc=function(t){if(this.secondaryStructure){var r=this.secondaryStructure,n=r.type,a=r.getIndex,i=n[a(t)];return ef(i)?2:i}else return nD},e.prototype.setControlPoint=function(t,r,n,a,i){bVe(i)||this.helixOrientationCenters&&ef(i)?y.scale(t,y.add(t,r,y.add(t,a,y.add(t,n,n))),1/4):y.copy(t,n)},e.prototype.setFromToVector=function(t,r,n){this.value.isCoarseBackbone||this.helixOrientationCenters&&ef(n)?y.set(t,1,0,0):(this.atomicPos(tD,this.directionFromElementIndex[r]),this.atomicPos(rD,this.directionToElementIndex[r]),y.sub(t,rD,tD))},e.prototype.setDirection=function(t,r,n,a){y.matchDirection(tD,r,n),y.matchDirection(rD,a,n),y.scale(t,y.add(t,tD,y.add(t,rD,y.add(t,n,n))),1/4)},e.prototype.move=function(){var t=this,r=t.residueIt,n=t.polymerIt,a=t.value;if(this.state===0){for(;n.hasNext;)if(this.polymerSegment=n.move(),r.setSegment(this.polymerSegment),this.updateResidueSegmentRange(this.polymerSegment),r.hasNext){this.state=1;var i=this.residueAtomSegments.index[this.unit.elements[this.polymerSegment.start]],o=this.getResidueIndex(i-1);this.currSecStrucType=i===o?nD:this.getSecStruc(o),this.nextSecStrucType=this.getSecStruc(i),this.currCoarseBackbone=this.directionFromElementIndex[o]===-1||this.directionToElementIndex[o]===-1,this.nextCoarseBackbone=this.directionFromElementIndex[i]===-1||this.directionToElementIndex[i]===-1;break}}if(this.state===1){var s=r.move().index,u=this.getResidueIndex(s-3),c=this.getResidueIndex(s-2),l=this.getResidueIndex(s-1),f=this.getResidueIndex(s+1),d=this.getResidueIndex(s+2),m=this.getResidueIndex(s+3);this.prevSecStrucType=this.getSecStruc(l),this.currSecStrucType=this.getSecStruc(s),this.nextSecStrucType=s===f?nD:this.getSecStruc(f),this.prevCoarseBackbone=this.currCoarseBackbone,this.currCoarseBackbone=this.nextCoarseBackbone,this.nextCoarseBackbone=this.directionFromElementIndex[f]===-1||this.directionToElementIndex[f]===-1,a.secStrucType=this.currSecStrucType,a.secStrucFirst=this.prevSecStrucType!==this.currSecStrucType,a.secStrucLast=this.currSecStrucType!==this.nextSecStrucType,a.isCoarseBackbone=this.currCoarseBackbone,a.coarseBackboneFirst=this.prevCoarseBackbone!==this.currCoarseBackbone,a.coarseBackboneLast=this.currCoarseBackbone!==this.nextCoarseBackbone,a.first=s===this.residueSegmentMin,a.last=s===this.residueSegmentMax,a.moleculeType=this.moleculeType[s],a.initial=s===l,a.final=s===f,a.centerPrev.element=this.traceElementIndex[l],a.center.element=this.traceElementIndex[s],a.centerNext.element=this.traceElementIndex[f];var h=this.getSecStruc(u),p=this.getSecStruc(c),v=this.getSecStruc(l),g=this.getSecStruc(s),b=this.getSecStruc(f),x=this.getSecStruc(d),S=this.getSecStruc(m);this.pos(this.p0,u,h),this.pos(this.p1,c,p),this.pos(this.p2,l,v),this.pos(this.p3,s,g),this.pos(this.p4,f,b),this.pos(this.p5,d,x),this.pos(this.p6,m,S);var _=ef(h),C=ef(p),D=ef(v),T=ef(g),A=ef(b),E=ef(x),I=ef(S);this.helixOrientationCenters&&(T!==D?T?(y.copy(this.p0,this.p3),y.copy(this.p1,this.p3),y.copy(this.p2,this.p3)):D&&(y.scale(fr,y.sub(fr,this.p2,this.p3),2),y.add(this.p2,this.p3,fr),y.add(this.p1,this.p2,fr),y.add(this.p0,this.p1,fr)):T!==C?T?(y.copy(this.p0,this.p2),y.copy(this.p1,this.p2)):C&&(y.scale(fr,y.sub(fr,this.p1,this.p2),2),y.add(this.p1,this.p2,fr),y.add(this.p0,this.p1,fr)):T!==_&&(T?y.copy(this.p0,this.p1):_&&(y.scale(fr,y.sub(fr,this.p0,this.p1),2),y.add(this.p0,this.p1,fr))),T!==A?T?(y.copy(this.p4,this.p3),y.copy(this.p5,this.p3),y.copy(this.p6,this.p3)):A&&(y.scale(fr,y.sub(fr,this.p4,this.p3),2),y.add(this.p4,this.p3,fr),y.add(this.p5,this.p4,fr),y.add(this.p6,this.p5,fr)):T!==E?T?(y.copy(this.p5,this.p4),y.copy(this.p6,this.p4)):E&&(y.scale(fr,y.sub(fr,this.p5,this.p4),2),y.add(this.p5,this.p4,fr),y.add(this.p6,this.p5,fr)):T!==I&&(T?y.copy(this.p6,this.p5):I&&(y.scale(fr,y.sub(fr,this.p6,this.p5),2),y.add(this.p6,this.p5,fr)))),this.setFromToVector(this.d01,l,v),this.setFromToVector(this.d12,s,g),this.setFromToVector(this.d23,f,b),this.setFromToVector(this.d34,d,x);var R=T&&this.helixOrientationCenters,B=1.5;s===l||g!==v&&R?(y.setMagnitude(fr,y.sub(fr,this.p3,this.p4),B),y.add(this.p2,this.p3,fr),y.add(this.p1,this.p2,fr),y.add(this.p0,this.p1,fr)):l===c||g!==p&&R?(y.setMagnitude(fr,y.sub(fr,this.p2,this.p3),B),y.add(this.p1,this.p2,fr),y.add(this.p0,this.p1,fr)):(c===u||g!==h&&R)&&(y.setMagnitude(fr,y.sub(fr,this.p1,this.p2),B),y.add(this.p0,this.p1,fr)),s===f||g!==b&&R?(y.setMagnitude(fr,y.sub(fr,this.p3,this.p2),B),y.add(this.p4,this.p3,fr),y.add(this.p5,this.p4,fr),y.add(this.p6,this.p5,fr)):f===d||g!==x&&R?(y.setMagnitude(fr,y.sub(fr,this.p4,this.p3),B),y.add(this.p5,this.p4,fr),y.add(this.p6,this.p5,fr)):(d===m||g!==S&&R)&&(y.setMagnitude(fr,y.sub(fr,this.p5,this.p4),B),y.add(this.p6,this.p5,fr)),this.setControlPoint(a.p0,this.p0,this.p1,this.p2,p),this.setControlPoint(a.p1,this.p1,this.p2,this.p3,v),this.setControlPoint(a.p2,this.p2,this.p3,this.p4,g),this.setControlPoint(a.p3,this.p3,this.p4,this.p5,b),this.setControlPoint(a.p4,this.p4,this.p5,this.p6,x),this.setDirection(a.d12,this.d01,this.d12,this.d23),this.setDirection(a.d23,this.d12,this.d23,this.d34),r.hasNext||(this.state=0)}return this.hasNext=r.hasNext||n.hasNext,this.value},e}();var SVe=function(){function e(t,r){switch(this.unit=t,this.state=0,this.hasNext=!1,this.polymerIt=Wr.transientSegments(tg(t),t.elements),this.value=Noe(r,t),y.set(this.value.d12,1,0,0),y.set(this.value.d23,1,0,0),t.kind){case 1:this.conformation=t.model.coarseConformation.spheres;break;case 2:this.conformation=t.model.coarseConformation.gaussians;break}this.hasNext=this.polymerIt.hasNext}return e.prototype.getElementIndex=function(t){return Math.min(Math.max(this.polymerSegment.start,t),this.polymerSegment.end-1)},e.prototype.pos=function(t,r){var n=this.unit.elements[r];t[0]=this.conformation.x[n],t[1]=this.conformation.y[n],t[2]=this.conformation.z[n]},e.prototype.move=function(){if(this.state===0){for(;this.polymerIt.hasNext;)if(this.polymerSegment=this.polymerIt.move(),this.elementIndex=this.polymerSegment.start,this.elementIndex=this.polymerSegment.end&&(this.state=0)}return this.hasNext=this.elementIndex+1=0)){s=u;break}}if(o<0)return!1;for(var l=o,u=i;u>s;u--){var c=r[u];if(!(c<0)){var f=Ee.indexOf(t,c);if(f>=0){l=f;break}}}return n(Se.ofRange(e+o,e+l))}function O4(e,t,r,n,a){var i=!1,o=a.unit.elements,s=a.unit.model.atomicHierarchy.derived.residue.traceElementIndex,u=a.unit.model.atomicHierarchy.residueAtomSegments.index,c=r(a.unit);if(Se.is(a.indices))if(Se.start(a.indices)===0&&Se.end(a.indices)===a.unit.elements.length)i=n(Se.ofBounds(e,e+t))||i;else{var l=u[o[Se.min(a.indices)]],f=u[o[Se.max(a.indices)]];i=qoe(e,c,s,n,l,f)||i}else for(var d=a.indices,m=0,h=d.length;m1)break;f=v,p++}m=p-1,i=qoe(e,c,s,n,l,f)||i}return i}function EVe(e){return e.polymerElements}function hl(e,t,r){var n=!1;if(!ie.Loci.is(e))return!1;var a=t.structure,i=t.group;if(!Le.areEquivalent(e.structure,a))return!1;for(var o=i.units[0].polymerElements.length,s=0,u=e.elements;s0?(vl(on,t,0),vl(kn,t,a*3),v=s/KVe(sm(XVe,kn,on))):ZVe(MS,0,0,0);for(var g=0;g<=a;++g){var b=i[g],x=o[g],S=s===0?x:s*(1-g/a),_=g*3;vl(ed,r,_),db(ed,ed,S),vl(yc,n,_),db(yc,yc,b),s>0&&(vl(on,r,_),vl(kn,n,_),db(MS,gse(MS,on,kn),v)),vl(rf,t,_),vl(td,r,_),vl(H4,n,_),gl(on,gl(on,rf,yc),ed),gl(kn,td,MS),Xn(f,on[0],on[1],on[2]),Xn(d,kn[0],kn[1],kn[2]),gl(on,sm(on,rf,yc),ed),Xn(f,on[0],on[1],on[2]),Xn(d,kn[0],kn[1],kn[2]),vse(kn,H4),Xn(f,on[0],on[1],on[2]),Xn(d,kn[0],kn[1],kn[2]),sm(on,sm(on,rf,yc),ed),Xn(f,on[0],on[1],on[2]),Xn(d,kn[0],kn[1],kn[2]),gl(kn,vse(kn,td),MS),Xn(f,on[0],on[1],on[2]),Xn(d,kn[0],kn[1],kn[2]),sm(on,gl(on,rf,yc),ed),Xn(f,on[0],on[1],on[2]),Xn(d,kn[0],kn[1],kn[2]),j4(kn,H4),Xn(f,on[0],on[1],on[2]),Xn(d,kn[0],kn[1],kn[2]),gl(on,gl(on,rf,yc),ed),Xn(f,on[0],on[1],on[2]),Xn(d,kn[0],kn[1],kn[2])}for(var g=0;g0){var b=i[0],x=o[0];bD(0,e,t,r,n,b,s,-x,!1),bD(0,e,t,r,n,b,-s,x,!1)}if(c&&s===0){var b=i[a],x=o[a];bD(a*3,e,t,r,n,b,x,x,!0)}for(var T=(a+1)*8+(u?4:s>0?8:0)+(c&&s===0?4:0),g=0,A=T;gT,I=0;I=_?A-T:-A+T:I>=S&&I<_?-A+T:A-T;q4(io,io,us,R),I===S||I===S-1?xD(Ui,us,Vs,0,1):I===_||I===_-1?xD(Ui,us,Vs,0,-1):xD(Ui,us,Vs,b[I],x[I])}else pb(io,us,Vs,cu,A*b[I],T*x[I]),xD(Ui,us,Vs,T*b[I],A*x[I]);$Ve(Ui,Ui),Gs(d,io[0],io[1],io[2]),Gs(m,Ui[0],Ui[1],Ui[2])}}for(var B=Math.round(i/2),C=0;CT;E&&(A-=T),v=d.elementCount;for(var C=0;C=_?A:-A)):pb(io,us,Vs,cu,A*b[C],T*x[C]),Gs(d,io[0],io[1],io[2]),Gs(m,Ui[0],Ui[1],Ui[2]),Gs(h,v+(C+1)%i,v+C,z)}if(c){var O=a*3,z=d.elementCount;um(us,r,O),um(Vs,n,O),um(cu,t,O),yse(Ui,us,Vs),Gs(d,cu[0],cu[1],cu[2]),Gs(m,Ui[0],Ui[1],Ui[2]);var T=o[a],A=s[a],E=l==="rounded"&&A>T;E&&(A-=T),v=d.elementCount;for(var C=0;C=_?A:-A)):pb(io,us,Vs,cu,A*b[C],T*x[C]),Gs(d,io[0],io[1],io[2]),Gs(m,Ui[0],Ui[1],Ui[2]),Gs(h,v+C,v+(C+1)%i,z)}var k=(a+1)*i+(u?i+1:0)+(c?i+1:0);He.addRepeat(p,k,f)}var cm=y.fromArray,r6e=y.magnitude,Y4=y.sub,bse=y.add,X4=y.scale,n6e=y.negate,a6e=y.copy,i6e=y.cross,yl=He.add3,o6e=He.add,wo=y(),cs=y(),s6e=y(),K4=y(),lg=y(),xse=y(),BS=y(),u6e=y(),Z4=y();function hb(e,t,r,n,a,i,o,s){var u=e.currentGroup,c=e.vertices,l=e.normals,f=e.indices,d=e.groups,m=c.elementCount,h=0;s>0&&(cm(wo,t,0),cm(cs,t,a*3),h=s/r6e(Y4(s6e,cs,wo)));for(var p=0;p<=a;++p){var v=i[p],g=o[p],b=s===0?g:s*(1-p/a),x=p*3;cm(lg,r,x),X4(lg,lg,b),cm(K4,n,x),X4(K4,K4,v),s>0&&(cm(wo,r,x),cm(cs,n,x),X4(xse,i6e(xse,wo,cs),h)),cm(BS,t,x),cm(u6e,r,x),cm(Z4,n,x),bse(wo,BS,lg),n6e(cs,Z4),yl(c,wo[0],wo[1],wo[2]),yl(l,cs[0],cs[1],cs[2]),Y4(wo,BS,lg),yl(c,wo[0],wo[1],wo[2]),yl(l,cs[0],cs[1],cs[2]),bse(wo,BS,lg),a6e(cs,Z4),yl(c,wo[0],wo[1],wo[2]),yl(l,cs[0],cs[1],cs[2]),Y4(wo,BS,lg),yl(c,wo[0],wo[1],wo[2]),yl(l,cs[0],cs[1],cs[2])}for(var p=0;p0},ensureCustomProperties:{attach:function(e,t){return $(void 0,void 0,void 0,function(){var r,n,a;return J(this,function(i){switch(i.label){case 0:return[4,Eo.attach(e,t,void 0,!0)];case 1:i.sent(),r=0,n=t.models,i.label=2;case 2:return r0&&e.models.some(function(t){return Mu.Provider.isApplicable(t)})},getData:function(e,t){return t.includeParent?e.asParent():e},mustRecreate:function(e,t){return e.includeParent!==t.includeParent}};var Ise=` +precision highp float; + +attribute vec3 aPosition; +attribute float aRadius; + +varying vec3 vPosition; +varying float vRadiusSqInv; + +#if defined(dCalcType_groupId) + attribute float aGroup; + varying float vGroup; +#endif + +uniform vec3 uBboxSize; +uniform vec3 uBboxMin; +uniform float uResolution; + +void main() { + vRadiusSqInv = 1.0 / (aRadius * aRadius); + #if defined(dCalcType_groupId) + vGroup = aGroup; + #endif + gl_PointSize = ceil(((aRadius * 3.0) / uResolution) + uResolution); + vPosition = (aPosition - uBboxMin) / uResolution; + gl_Position = vec4(((aPosition - uBboxMin) / uBboxSize) * 2.0 - 1.0, 1.0); +} +`;var Mse=` +precision highp float; + +varying vec3 vPosition; +varying float vRadiusSqInv; +#if defined(dCalcType_groupId) + #if defined(dGridTexType_2d) + precision highp sampler2D; + uniform sampler2D tMinDistanceTex; + uniform vec3 uGridTexDim; + #elif defined(dGridTexType_3d) + precision highp sampler3D; + uniform sampler3D tMinDistanceTex; + #endif + varying float vGroup; +#endif + +#include common + +uniform vec3 uGridDim; +uniform vec2 uGridTexScale; +uniform float uCurrentSlice; +uniform float uCurrentX; +uniform float uCurrentY; +uniform float uAlpha; +uniform float uResolution; +uniform float uRadiusFactorInv; + +void main() { + vec2 v = gl_FragCoord.xy - vec2(uCurrentX, uCurrentY) - 0.5; + vec3 fragPos = vec3(v.x, v.y, uCurrentSlice); + float dist = distance(fragPos, vPosition) * uResolution; + + #if defined(dCalcType_density) + float density = exp(-uAlpha * ((dist * dist) * vRadiusSqInv)); + gl_FragColor.a = density * uRadiusFactorInv; + #elif defined(dCalcType_minDistance) + gl_FragColor.a = 1.0 - dist * uRadiusFactorInv; + #elif defined(dCalcType_groupId) + #if defined(dGridTexType_2d) + float minDistance = 1.0 - texture2D(tMinDistanceTex, (gl_FragCoord.xy) / (uGridTexDim.xy / uGridTexScale)).a; + #elif defined(dGridTexType_3d) + float minDistance = 1.0 - texelFetch(tMinDistanceTex, ivec3(gl_FragCoord.xy, uCurrentSlice), 0).a; + #endif + if (dist * uRadiusFactorInv > minDistance + uResolution * 0.05) + discard; + gl_FragColor.rgb = packIntToRGB(vGroup); + #endif +} +`;var h6e={drawCount:An("number"),instanceCount:An("number"),aRadius:Gr("float32",1,0),aPosition:Gr("float32",3,0),aGroup:Gr("float32",1,0),uCurrentSlice:_e("f"),uCurrentX:_e("f"),uCurrentY:_e("f"),uBboxMin:_e("v3","material"),uBboxSize:_e("v3","material"),uGridDim:_e("v3","material"),uGridTexDim:_e("v3","material"),uGridTexScale:_e("v2","material"),uAlpha:_e("f","material"),uResolution:_e("f","material"),uRadiusFactorInv:_e("f","material"),tMinDistanceTex:Ft("texture","rgba","float","nearest","material"),dGridTexType:Dt("string",["2d","3d"]),dCalcType:Dt("string",["density","minDistance","groupId"])},rd="gaussian-density";function Rse(e){return e.namedFramebuffers[rd]||(e.namedFramebuffers[rd]=e.resources.framebuffer()),e.namedFramebuffers[rd]}function Bse(e,t,r,n,a,i){var o="".concat(rd,"-").concat(e);return t.namedTextures[o]||(t.namedTextures[o]=t.resources.texture(r,n,a,i)),t.namedTextures[o]}function J4(e,t,r,n,a,i){return e.isWebGL2?v6e(e,t,r,n,a,i):SD(e,t,r,n,!1,a,i)}function SD(e,t,r,n,a,i,o){ft&&e.timer.mark("GaussianDensityTexture2d");var s=y6e(e,t,r,n,a,i,o);return ft&&e.timer.markEnd("GaussianDensityTexture2d"),Ose(s)}function v6e(e,t,r,n,a,i){ft&&e.timer.mark("GaussianDensityTexture3d");var o=b6e(e,t,r,n,a,i);return ft&&e.timer.markEnd("GaussianDensityTexture3d"),Ose(o)}function Ose(e){var t=e.texture,r=e.scale,n=e.bbox,a=e.gridDim,i=e.gridTexDim,o=e.gridTexScale,s=e.radiusFactor,u=e.resolution,c=e.maxRadius;return{transform:g6e(r,n),texture:t,bbox:n,gridDim:a,gridTexDim:i,gridTexScale:o,radiusFactor:s,resolution:u,maxRadius:c}}function g6e(e,t){var r=se.identity();return se.fromScaling(r,e),se.setTranslation(r,t.min),r}function y6e(e,t,r,n,a,i,o){var s=e.gl,u=e.resources,c=e.state,l=e.extensions,f=l.colorBufferFloat,d=l.textureFloat,m=l.colorBufferHalfFloat,h=l.textureHalfFloat,p=l.blendMinMax,v=i.smoothness,g=i.resolution,b=Fse(t,r,n,i),x=b.drawCount,S=b.positions,_=b.radii,C=b.groups,D=b.scale,T=b.expandedBox,A=b.dim,E=b.maxRadius,I=A[0],R=A[1],B=A[2],O=S6e(A),z=O.texDimX,k=O.texDimY,G=O.texCols,V=O.powerOfTwoSize,U=y.create(z,k,0),Q=Me.create(z/V,k/V),W=E*2,X=a?V:z,ae=a?V:k,q=Bse("min-dist-2d",e,"image-uint8","rgba","ubyte","nearest");q.define(X,ae);var F=Lse(e,x,S,_,C,q,T,A,U,Q,v,g,W),j=F.values,Z=j.uCurrentSlice,Y=j.uCurrentX,H=j.uCurrentY,N=Rse(e);N.bind(),kse(e),o||(o=m&&h?u.texture("image-float16","rgba","fp16","linear"):f&&d?u.texture("image-float32","rgba","float","linear"):u.texture("image-uint8","rgba","ubyte","linear")),o.define(X,ae);function ee(oe,me){c.currentRenderItemId=-1,oe.attachFramebuffer(N,0),me&&(c.viewport(0,0,X,ae),c.scissor(0,0,X,ae),s.clear(s.COLOR_BUFFER_BIT)),M.update(H,0);for(var pe=0,de=0,re=0,te=0;te=G&&(pe-=G,de+=R,re=0,M.update(H,de)),M.update(Y,re),M.update(Z,te),c.viewport(re,de,I,R),c.scissor(re,de,I,R),F.render(),++pe,re+=I;s.flush()}return Use(e,F),ee(o,!0),p&&(Nse(e,F),ee(q,!0),Vse(e,F),ee(o,!1)),{texture:o,scale:D,bbox:T,gridDim:A,gridTexDim:U,gridTexScale:Q,radiusFactor:W,resolution:g,maxRadius:E}}function b6e(e,t,r,n,a,i){var o=e.gl,s=e.resources,u=e.state,c=e.extensions,l=c.colorBufferFloat,f=c.textureFloat,d=c.colorBufferHalfFloat,m=c.textureHalfFloat,h=a.smoothness,p=a.resolution,v=Fse(t,r,n,a),g=v.drawCount,b=v.positions,x=v.radii,S=v.groups,_=v.scale,C=v.expandedBox,D=v.dim,T=v.maxRadius,A=D[0],E=D[1],I=D[2],R=Bse("min-dist-3d",e,"volume-uint8","rgba","ubyte","nearest");R.define(A,E,I);var B=Me.create(1,1),O=T*2,z=Lse(e,g,b,x,S,R,C,D,D,B,h,p,O),k=z.values.uCurrentSlice,G=Rse(e);G.bind(),kse(e),u.viewport(0,0,A,E),u.scissor(0,0,A,E),i||(i=d&&m?s.texture("volume-float16","rgba","fp16","linear"):l&&f?s.texture("volume-float32","rgba","float","linear"):s.texture("volume-uint8","rgba","ubyte","linear")),i.define(A,E,I);function V(U,Q){u.currentRenderItemId=-1;for(var W=0;W0?"3d":"2d"),M.updateIfChanged(h.dCalcType,"density"),e.namedComputeRenderables[rd].update()}else e.namedComputeRenderables[rd]=x6e(e,t,r,n,a,i,o,s,u,c,l,f,d);return e.namedComputeRenderables[rd]}function x6e(e,t,r,n,a,i,o,s,u,c,l,f,d){var m=y.sub(y(),o.max,o.min),h={drawCount:M.create(t),instanceCount:M.create(1),aRadius:M.create(n),aPosition:M.create(r),aGroup:M.create(a),uCurrentSlice:M.create(0),uCurrentX:M.create(0),uCurrentY:M.create(0),uBboxMin:M.create(o.min),uBboxSize:M.create(m),uGridDim:M.create(s),uGridTexDim:M.create(u),uGridTexScale:M.create(c),uAlpha:M.create(l),uResolution:M.create(f),uRadiusFactorInv:M.create(1/d),tMinDistanceTex:M.create(i),dGridTexType:M.create(i.getDepth()>0?"3d":"2d"),dCalcType:M.create("density")},p=P({},h6e),v=Nr(rd,Ise,Mse),g=ln(e,"points",v,p,h);return fn(g,h)}function kse(e){var t=e.gl,r=e.state;r.disable(t.CULL_FACE),r.enable(t.BLEND),r.disable(t.DEPTH_TEST),r.enable(t.SCISSOR_TEST),r.depthMask(!1),r.clearColor(0,0,0,0)}function Nse(e,t){var r=e.gl,n=e.state;if(M.update(t.values.dCalcType,"minDistance"),t.update(),n.colorMask(!1,!1,!1,!0),n.blendFunc(r.ONE,r.ONE),!e.extensions.blendMinMax)throw new Error("GPU gaussian surface calculation requires EXT_blend_minmax");n.blendEquation(e.extensions.blendMinMax.MAX)}function Use(e,t){var r=e.gl,n=e.state;M.update(t.values.dCalcType,"density"),t.update(),n.colorMask(!1,!1,!1,!0),n.blendFunc(r.ONE,r.ONE),n.blendEquation(r.FUNC_ADD)}function Vse(e,t){var r=e.gl,n=e.state;M.update(t.values.dCalcType,"groupId"),t.update(),n.colorMask(!0,!0,!0,!1),n.blendFunc(r.ONE,r.ZERO),n.blendEquation(r.FUNC_ADD)}function S6e(e){var t=e[0]*e[1]*e[2],r=Math.sqrt(t),n=Math.pow(2,Math.ceil(Math.log(r)/Math.log(2))),a=0,i=e[1],o=1,s=e[2];return nq[Ct]&&(q[Ct]=ut,B[Ct]=p?p[N]:N)}}}function o(){return $(this,void 0,void 0,function(){var Y;return J(this,function(H){switch(H.label){case 0:Y=0,H.label=1;case 1:return Y1)return!1;var n=r.maxTextureSize/3,a=pL(e.boundary.box,t.resolution,n*n),i=a.areaCells,o=a.maxAreaCells;return i0}};var rk=P(P({},Ene),{background:w.Boolean(!1),backgroundMargin:w.Numeric(0,{min:0,max:1,step:.01}),backgroundColor:w.Color(Xt.black),backgroundOpacity:w.Numeric(.5,{min:0,max:1,step:.01}),borderWidth:w.Numeric(.25,{min:0,max:.5,step:.01}),level:w.Select("residue",[["chain","Chain"],["residue","Residue"],["element","Element"]],{isEssential:!0}),ignoreHydrogens:w.Boolean(!1),ignoreHydrogensVariant:w.Select("all",w.arrayToOptions(["all","non-polar"])),chainScale:w.Numeric(10,{min:0,max:20,step:.1}),residueScale:w.Numeric(1,{min:0,max:20,step:.1}),elementScale:w.Numeric(.5,{min:0,max:20,step:.1})});function lue(e){return Ine({defaultProps:w.getDefaultValues(rk),createGeometry:L6e,createLocationIterator:_a.fromStructure,getLoci:ml,eachLocation:dl,setUpdateState:function(t,r,n){t.createGeometry=r.level!==n.level||r.level==="chain"&&r.chainScale!==n.chainScale||r.level==="residue"&&r.residueScale!==n.residueScale||r.level==="element"&&r.elementScale!==n.elementScale||r.ignoreHydrogens!==n.ignoreHydrogens||r.ignoreHydrogensVariant!==n.ignoreHydrogensVariant}},e)}function L6e(e,t,r,n,a){switch(n.level){case"chain":return k6e(e,t,r,n,a);case"residue":return N6e(e,t,r,n,a);case"element":return U6e(e,t,r,n,a)}}var bl=y(),OS=new Di("98");function k6e(e,t,r,n,a){for(var i=ie.Location.create(t),o=t.units,s=t.serialMapping,u=nt.chain,c=u.auth_asym_id,l=u.label_asym_id,f=s.cumulativeUnitElementCount,d=o.length,m=n.chainScale,h=Ls.create(n,d,d/2,a),p=0,v=o.length;p0}};function z6e(e,t){return e[0]=e[1]=e[2]=1,t[0]!==0?e[0]=(t[1]+t[2])/-t[0]:t[1]!==0?e[1]=(t[0]+t[2])/-t[1]:t[2]!==0&&(e[2]=(t[0]+t[1])/-t[2]),e}function H6e(e){for(var t=0,r=2*Math.PI/e,n=new Float32Array(e),a=new Float32Array(e),i=0;i0&&lm0}};var ak=P(P({},Wn),{sizeFactor:w.Numeric(1,{min:0,max:2,step:.1}),detail:w.Numeric(0,{min:0,max:3,step:1},Ze.CustomQualityParamInfo)});function _ue(e){return Ca({defaultProps:w.getDefaultValues(ak),createGeometry:$6e,createLocationIterator:J6e,getLoci:e8e,eachLocation:t8e,setUpdateState:function(t,r,n){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.detail!==n.detail}},e)}function Q6e(e){if(Te.Traits.is(e.traits,Te.Trait.MultiChain)||Te.Traits.is(e.traits,Te.Trait.Partitioned))return!1;if(Te.isCoarse(e))return!0;if(e.elements.length===0)return!1;e.model.atomicHierarchy.derived.residue.moleculeType;var t=e.residueIndex[e.elements[0]],r=e.model.atomicHierarchy.derived.residue.moleculeType[t];return!(r===3||r===2)}function $6e(e,t,r,n,a,i){if(!Q6e(t))return pt.createEmpty(i);var o=a.detail,s=a.sizeFactor,u=256,c=ot.createState(u,u/2,i),l=t.principalAxes.boxAxes,f=l.origin,d=l.dirA,m=l.dirB,h=si.size(y(),l);y.scale(h,h,s/2);var p=y.create(h[2],h[1],h[0]);c.currentGroup=0,Py(c,f,d,m,p,o+1);var v=ot.getMesh(c),g=xe.expand(xe(),t.boundary.sphere,1*a.sizeFactor);return v.setBoundingSphere(g),v}function J6e(e){var t=e.group,r=e.structure,n=1,a=t.units.length,i=ie.Location.create(r),o=function(s,u){var c=t.units[u];return i.unit=c,i.element=c.elements[s],i};return hr(n,a,1,o)}function e8e(e,t,r){var n=e.objectId,a=e.instanceId;if(r===n){var i=t.structure,o=t.group,s=o.units[a],u=Ee.ofBounds(0,s.elements.length);return ie.Loci(i,[{unit:s,indices:u}])}return Jt}function t8e(e,t,r){var n=!1;if(!ie.Loci.is(e))return!1;var a=t.structure,i=t.group;if(!Le.areEquivalent(e.structure,a))return!1;for(var o=i.elements.length,s=0,u=e.elements;s0}};var a8e=He.add3,i8e=He.add,AD;(function(e){function t(r,n,a){r===void 0&&(r=2048),n===void 0&&(n=1024);var i=He.create(Float32Array,3,n,a?a.centerBuffer.ref.value:r),o=He.create(Float32Array,1,n,a?a.groupBuffer.ref.value:r);return{add:function(s,u,c,l){a8e(i,s,u,c),i8e(o,l)},getPoints:function(){var s=He.compact(i,!0),u=He.compact(o,!0);return Tu.create(s,u,i.elementCount,a)}}}e.create=t})(AD||(AD={}));var Due=y.add,LS=P(P({},Fne),{pointSizeAttenuation:w.Boolean(!1),ignoreHydrogens:w.Boolean(!1),ignoreHydrogensVariant:w.Select("all",w.arrayToOptions(["all","non-polar"])),traceOnly:w.Boolean(!1),stride:w.Numeric(1,{min:1,max:100,step:1})});function o8e(e,t,r,n,a,i){var o=r.child;if(o&&!o.unitMap.get(t.id))return Tu.createEmpty(i);var s=t.elements,u=s.length,c=AD.create(u,u/10,i),l=y(),f=t.conformation.invariantPosition,d=Jf(r,t,a),m=y(),h=0;if(d)for(var p=0;p0}};var Iue={sizeFactor:w.Numeric(.2,{min:0,max:10,step:.01}),detail:w.Numeric(0,{min:0,max:3,step:1},Ze.CustomQualityParamInfo),linearSegments:w.Numeric(8,{min:1,max:48,step:1},Ze.CustomQualityParamInfo),radialSegments:w.Numeric(16,{min:2,max:56,step:2},Ze.CustomQualityParamInfo)},l2r=w.getDefaultValues(Iue),ju=y();function l8e(e,t,r,n,a,i){var o=t.polymerElements.length;if(!o)return pt.createEmpty(i);for(var s=a.sizeFactor,u=a.detail,c=a.linearSegments,l=a.radialSegments,f=c*l*o+(l+1)*o*2,d=ot.createState(f,f/10,i),m=ib(c),h=m.curvePoints,p=m.normalVectors,v=m.binormalVectors,g=m.widthValues,b=m.heightValues,x=0,S=tb(t,r,{ignoreSecondaryStructure:!0});S.hasNext;){var _=S.move();d.currentGroup=x;var C=Qo(_.moleculeType),D=C?ag:ng;ob(m,_,oD,D);var T=_.coarseBackboneFirst||_.first,A=_.coarseBackboneLast||_.last,E=n.size.size(_.centerPrev)*s,I=n.size.size(_.center)*s,R=n.size.size(_.centerNext)*s;DS(m,E,I,R,E,I,R,D);var B=c;if(_.initial){B=Math.max(Math.round(c*D),1);var O=c-B;h.copyWithin(0,O*3),v.copyWithin(0,O*3),p.copyWithin(0,O*3),g.copyWithin(0,O*3),b.copyWithin(0,O*3),y.fromArray(ju,h,3),y.normalize(ju,y.sub(ju,_.p2,ju)),y.scaleAndAdd(ju,_.p2,ju,I*sb),y.toArray(ju,h,0)}else _.final&&(B=Math.max(Math.round(c*(1-D)),1),y.fromArray(ju,h,B*3-3),y.normalize(ju,y.sub(ju,_.p2,ju)),y.scaleAndAdd(ju,_.p2,ju,I*sb),y.toArray(ju,h,B*3));_.initial===!0&&_.final===!0?Kn(d,_.p2,I*2,u):l===2?hb(d,h,p,v,B,g,b,0):l===4?mb(d,h,p,v,B,g,b,0,T,A):RS(d,h,p,v,B,l,g,b,T,A,"elliptical"),++x}var z=ot.getMesh(d),k=xe.expand(xe(),t.boundary.sphere,1*a.sizeFactor);return z.setBoundingSphere(k),z}var ik=P(P({},Wn),Iue);function Mue(e){return Ca({defaultProps:w.getDefaultValues(ik),createGeometry:l8e,createLocationIterator:function(t){return zu.fromGroup(t,!0)},getLoci:pl,eachLocation:hl,setUpdateState:function(t,r,n){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.detail!==n.detail||r.linearSegments!==n.linearSegments||r.radialSegments!==n.radialSegments}},e)}var Rue={"polymer-tube":function(e,t){return vn("Polymer tube mesh",e,t,Mue)},"polymer-gap":function(e,t){return vn("Polymer gap cylinder",e,t,fb)}},Bue=P(P(P({},ik),cg),{sizeFactor:w.Numeric(.2,{min:0,max:10,step:.01}),visuals:w.MultiSelect(["polymer-tube","polymer-gap"],w.objectToOptions(Rue)),bumpFrequency:w.Numeric(2,{min:0,max:10,step:.1},Ze.ShadingCategory)});function f8e(e,t){var r=w.clone(Bue),n=!1,a=!1;return t.units.forEach(function(i){!n&&Te.isAtomic(i)&&i.nucleotideElements.length&&(n=!0),!a&&i.gapElements.length&&(a=!0)}),r.visuals.defaultValue=["polymer-tube"],a&&r.visuals.defaultValue.push("polymer-gap"),r}function d8e(e,t){return Lt.createMulti("Putty",e,t,En,Rue)}var Oue={name:"putty",label:"Putty",description:"Displays a tube smoothly following the trace atoms of polymers.",factory:d8e,getParams:f8e,defaultValues:w.getDefaultValues(Bue),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"uncertainty"},isApplicable:function(e){return e.polymerResidueCount>0}};var Fue={"element-sphere":function(e,t){return vn("Sphere mesh/impostor",e,t,JA)},"structure-element-sphere":function(e,t){return li("Structure sphere mesh/impostor",e,t,moe)}},ok=P(P({},eb),{bumpFrequency:w.Numeric(1,{min:0,max:10,step:.1},Ze.ShadingCategory),visuals:w.MultiSelect(["element-sphere"],w.objectToOptions(Fue))}),PD;function m8e(e,t){return t.isCoarseGrained?(PD||(PD=w.clone(ok),PD.sizeFactor.defaultValue=2),PD):ok}function p8e(e,t){return Lt.createMulti("Spacefill",e,t,En,Fue)}var Lue={name:"spacefill",label:"Spacefill",description:"Displays atomic/coarse elements as spheres.",factory:p8e,getParams:m8e,defaultValues:w.getDefaultValues(ok),defaultColorTheme:{name:"element-symbol"},defaultSizeTheme:{name:"physical"},isApplicable:function(e){return e.elementCount>0}};var sk=mr.is;function h8e(e,t,r,n,a,i){if(!Te.isAtomic(t))return Kr.createEmpty(i);var o=r.child,s=o?.unitMap.get(t.id);if(o&&!s)return Kr.createEmpty(i);var u=ie.Location.create(r,t),c=t.elements,l=t.bonds,f=l.edgeCount,d=l.a,m=l.b,h=l.edgeProps,p=l.offset;if(!f)return Kr.createEmpty(i);var v=h.order,g=h.flags,b=a.sizeFactor,x=a.aromaticBonds,S=a.includeTypes,_=a.excludeTypes,C=a.multipleBonds,D=C==="off",T=C==="symmetric",A=mr.fromNames(S),E=mr.fromNames(_),I=Zy(A,E,32),R=y(),B=t.conformation.invariantPosition,O=t.rings,z=O.elementRingIndices,k=O.elementAromaticRingIndices,G=x?t.resonance.delocalizedTriplets:void 0,V={linkCount:f*2,referencePosition:function(ae){var q,F,j=d[ae],Z=m[ae],Y=G?.getThirdElement(j,Z);if(Y!==void 0)return B(c[Y],R);j>Z&&(q=[Z,j],j=q[0],Z=q[1]),p[j+1]-p[j]===1&&(F=[Z,j],j=F[0],Z=F[1]);for(var H=k.get(j)||z.get(j),N=0,ee=p[j],oe=p[j+1];eeN&&(N=de,B(c[me],R))}else return B(c[me],R)}return N>0?R:null},position:function(ae,q,F){B(c[d[F]],ae),B(c[m[F]],q)},style:function(ae){var q=v[ae],F=g[ae];if(sk(F,2)||sk(F,4))return 1;if(q===3)return D?0:T?4:5;if(x){var j=d[ae],Z=m[ae],Y=k.get(j),H=k.get(Z),N=Y&&H?T0(Y,H):0;if(sk(F,16)||N&&!I)return N===2?8:7}return q!==2||D?0:T?2:3},radius:function(ae){u.element=c[d[ae]];var q=n.size.size(u);u.element=c[m[ae]];var F=n.size.size(u);return Math.min(q,F)*b},ignore:KA(r,t,a)},U=DA(e,V,a,i),Q=U.lines,W=U.boundingSphere;if(W)Q.setBoundingSphere(W);else if(Q.lineCount>0){var X=xe.expand(xe(),(s??t).boundary.sphere,1*b);Q.setBoundingSphere(X)}return Q}var uk=P(P(P({},Zp),bS),{includeParent:w.Boolean(!1)});function kue(e){return Qp({defaultProps:w.getDefaultValues(uk),createGeometry:h8e,createLocationIterator:fl.fromGroup,getLoci:xS,eachLocation:SS,setUpdateState:function(t,r,n,a,i,o,s){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.linkScale!==n.linkScale||r.linkSpacing!==n.linkSpacing||r.aromaticDashCount!==n.aromaticDashCount||r.dashCount!==n.dashCount||r.ignoreHydrogens!==n.ignoreHydrogens||r.ignoreHydrogensVariant!==n.ignoreHydrogensVariant||!Xi(r.includeTypes,n.includeTypes)||!Xi(r.excludeTypes,n.excludeTypes)||r.aromaticBonds!==n.aromaticBonds||r.multipleBonds!==n.multipleBonds;var u=o.group.units[0],c=s.group.units[0];Te.isAtomic(u)&&Te.isAtomic(c)&&(Mi.areEqual(u.bonds,c.bonds)||(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0))}},e)}var ck=new mt.ElementBondIterator;function Nue(e,t,r,n){for(ck.setElement(t,r,n);ck.hasNext;){var a=ck.move();return a.otherUnit.conformation.position(a.otherUnit.elements[a.otherIndex],e),e}return null}function v8e(e,t,r,n,a){var i=t.interUnitBonds,o=i.edgeCount,s=i.edges;if(!o)return Kr.createEmpty(a);var u=n.sizeFactor,c=n.aromaticBonds,l=n.multipleBonds,f=l==="off",d=l==="symmetric",m=y(),h=ie.Location.create(),p={linkCount:o,referencePosition:function(_){var C=s[_],D,T,A,E;if(C.unitAC.unitB)D=t.unitMap.get(C.unitB),T=t.unitMap.get(C.unitA),A=C.indexB,E=C.indexA;else throw new Error("same units in createInterUnitBondLines");return Nue(m,t,D,A)||Nue(m,t,T,E)},position:function(_,C,D){var T=s[D],A=t.unitMap.get(T.unitA),E=t.unitMap.get(T.unitB);A.conformation.position(A.elements[T.indexA],_),E.conformation.position(E.elements[T.indexB],C)},style:function(_){var C=s[_].props.order,D=Ya.create(s[_].props.flag);return mr.is(D,2)||mr.is(D,4)?1:C===3?f?0:d?4:5:c&&mr.is(D,16)?7:C!==2||f?0:d?2:3},radius:function(_){var C=s[_];h.structure=t,h.unit=t.unitMap.get(C.unitA),h.element=h.unit.elements[C.indexA];var D=r.size.size(h);h.unit=t.unitMap.get(C.unitB),h.element=h.unit.elements[C.indexB];var T=r.size.size(h);return Math.min(D,T)*u},ignore:ZA(t,n)},v=DA(e,p,n,a),g=v.lines,b=v.boundingSphere;if(b)g.setBoundingSphere(b);else if(g.lineCount>0){var x=t.child,S=xe.expand(xe(),(x??t).boundary.sphere,1*u);g.setBoundingSphere(S)}return g}var lk=P(P(P({},Dne),bS),{includeParent:w.Boolean(!1)});function Uue(e){return Pne({defaultProps:w.getDefaultValues(lk),createGeometry:v8e,createLocationIterator:fl.fromStructure,getLoci:CS,eachLocation:_S,setUpdateState:function(t,r,n,a,i,o,s){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.linkScale!==n.linkScale||r.linkSpacing!==n.linkSpacing||r.aromaticDashCount!==n.aromaticDashCount||r.dashCount!==n.dashCount||r.ignoreHydrogens!==n.ignoreHydrogens||r.ignoreHydrogensVariant!==n.ignoreHydrogensVariant||!Xi(r.includeTypes,n.includeTypes)||!Xi(r.excludeTypes,n.excludeTypes)||r.multipleBonds!==n.multipleBonds,o.interUnitBonds!==s.interUnitBonds&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0)}},e)}var yb=y.scaleAndAdd,Vue=y.unitX,Gue=y.unitY,zue=y.unitZ,fk=P(P({},Zp),{lineSizeAttenuation:w.Boolean(!1),ignoreHydrogens:w.Boolean(!1),ignoreHydrogensVariant:w.Select("all",w.arrayToOptions(["all","non-polar"])),traceOnly:w.Boolean(!1),crosses:w.Select("lone",w.arrayToOptions(["lone","all"])),crossSize:w.Numeric(.35,{min:0,max:2,step:.01})});function g8e(e,t,r,n,a,i){var o=r.child;if(o&&!o.unitMap.get(t.id))return Kr.createEmpty(i);for(var s=t.elements,u=s.length,c=Ji.create(u,u/10,i),l=y(),f=y(),d=y(),m=t.conformation.invariantPosition,h=Jf(r,t,a),p=a.crossSize/2,v=a.crosses==="lone",g=0;g0},getData:function(e,t){return t.includeParent?e.asParent():e},mustRecreate:function(e,t){return e.includeParent!==t.includeParent}};function x8e(e,t,r,n,a){return $(this,void 0,void 0,function(){var i,o,s,u,c,l,f,d,m,h,p,v,g,b;return J(this,function(x){switch(x.label){case 0:if(i=e.runtime,o=e.webgl,!o||!o.extensions.blendMinMax)throw new Error("GaussianDensityVolume requires `webgl` and `blendMinMax` extension");return s=a?a.gridTexture.ref.value:void 0,[4,Jse(t,r.size,n,o,s).runInContext(i)];case 1:return u=x.sent(),c=u.transform,l=u.texture,f=u.bbox,d=u.gridDim,m={min:0,max:1,mean:.04,sigma:.01},h=se.mul(se(),c,se.fromScaling(se(),d)),p=se.getScaling(y(),c),v=y.create(0,1,2),g=Po.create(f,d,c,h,p,l,m,!0,v,a),b=xe.expand(xe(),t.boundary.sphere,u.maxRadius),g.setBoundingSphere(b),[2,g]}})})}var dk=P(P(P({},Mne),ph),{ignoreHydrogens:w.Boolean(!1),ignoreHydrogensVariant:w.Select("all",w.arrayToOptions(["all","non-polar"])),includeParent:w.Boolean(!1,{isHidden:!0})});function Yue(e){return Rne({defaultProps:w.getDefaultValues(dk),createGeometry:x8e,createLocationIterator:_a.fromStructure,getLoci:ml,eachLocation:dl,setUpdateState:function(t,r,n){r.resolution!==n.resolution&&(t.createGeometry=!0),r.radiusOffset!==n.radiusOffset&&(t.createGeometry=!0),r.smoothness!==n.smoothness&&(t.createGeometry=!0),r.ignoreHydrogens!==n.ignoreHydrogens&&(t.createGeometry=!0),r.ignoreHydrogensVariant!==n.ignoreHydrogensVariant&&(t.createGeometry=!0),r.traceOnly!==n.traceOnly&&(t.createGeometry=!0),r.includeParent!==n.includeParent&&(t.createGeometry=!0)},dispose:function(t){t.gridTexture.ref.value.destroy()}},e)}function S8e(e,t,r,n,a,i){return $(this,void 0,void 0,function(){var o,s,u,c,l,f,d,m,h,p,v,g,b,x;return J(this,function(S){switch(S.label){case 0:if(o=e.runtime,s=e.webgl,!s)throw new Error("GaussianDensityVolume requires `webgl`");return u=i?i.gridTexture.ref.value:void 0,[4,Zse(r,t,n.size,a,s,u).runInContext(o)];case 1:return c=S.sent(),l=c.transform,f=c.texture,d=c.bbox,m=c.gridDim,h={min:0,max:1,mean:.04,sigma:.01},p=se.mul(se(),l,se.fromScaling(se(),m)),v=se.getScaling(y(),l),g=y.create(0,1,2),b=Po.create(d,m,l,p,v,f,h,!0,g,i),x=xe.expand(xe(),t.boundary.sphere,c.maxRadius),b.setBoundingSphere(x),[2,b]}})})}var C8e=P(P(P({},kne),ph),{ignoreHydrogens:w.Boolean(!1),ignoreHydrogensVariant:w.Select("all",w.arrayToOptions(["all","non-polar"])),includeParent:w.Boolean(!1,{isHidden:!0})});function Xue(e){return Nne({defaultProps:w.getDefaultValues(C8e),createGeometry:S8e,createLocationIterator:_a.fromGroup,getLoci:Co,eachLocation:So,setUpdateState:function(t,r,n){r.resolution!==n.resolution&&(t.createGeometry=!0),r.radiusOffset!==n.radiusOffset&&(t.createGeometry=!0),r.smoothness!==n.smoothness&&(t.createGeometry=!0),r.ignoreHydrogens!==n.ignoreHydrogens&&(t.createGeometry=!0),r.ignoreHydrogensVariant!==n.ignoreHydrogensVariant&&(t.createGeometry=!0),r.traceOnly!==n.traceOnly&&(t.createGeometry=!0),r.includeParent!==n.includeParent&&(t.createGeometry=!0)},dispose:function(t){t.gridTexture.ref.value.destroy()}},e)}var Kue={"gaussian-volume":function(e,t){return li("Gaussian volume",e,t,Yue)},"units-gaussian-volume":function(e,t){return vn("Units-Gaussian volume",e,t,Xue)}},Zue=P(P({},dk),{jumpLength:w.Numeric(4,{min:0,max:20,step:.1}),visuals:w.MultiSelect(["gaussian-volume"],w.objectToOptions(Kue))});function _8e(e,t){return Zue}function w8e(e,t){return Lt.createMulti("Gaussian Volume",e,t,En,Kue)}var Que={name:"gaussian-volume",label:"Gaussian Volume",description:"Displays a gaussian molecular density using direct volume rendering.",factory:w8e,getParams:_8e,defaultValues:w.getDefaultValues(Zue),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"physical"},isApplicable:function(e){return e.elementCount>0}};var T8e=y.scale,A8e=y.add,D8e=y.sub,ED=P(P(P({},Wn),wA),{sizeFactor:w.Numeric(.3,{min:0,max:10,step:.01}),radialSegments:w.Numeric(16,{min:2,max:56,step:2},Ze.CustomQualityParamInfo),tryUseImpostor:w.Boolean(!0)});function $ue(e,t,r,n){return r.tryUseImpostor&&n&&n.extensions.fragDepth?E8e(e):M8e(e)}function P8e(e,t,r,n,a,i){var o=t.polymerElements.length;if(!o)return zi.createEmpty(i);var s=o*2,u=Ny.create(s,s/4,i),c=t.conformation.invariantPosition,l=y(),f=y(),d=y(),m=function(v,g,b,x,S){c(v,l),c(g,f);var _=Qo(S),C=_?ag:ng;A8e(d,l,T8e(d,D8e(d,f,l),C)),u.add(l[0],l[1],l[2],d[0],d[1],d[2],1,!1,!1,b),u.add(d[0],d[1],d[2],f[0],f[1],f[2],1,!1,!1,x)};T4(t,m);var h=u.getCylinders(),p=xe.expand(xe(),t.boundary.sphere,1*a.sizeFactor);return h.setBoundingSphere(p),h}function E8e(e){return TA({defaultProps:w.getDefaultValues(ED),createGeometry:P8e,createLocationIterator:zu.fromGroup,getLoci:pl,eachLocation:hl,setUpdateState:function(t,r,n){},mustRecreate:function(t,r,n){return!r.tryUseImpostor||!n}},e)}function I8e(e,t,r,n,a,i){var o=t.polymerElements.length;if(!o)return pt.createEmpty(i);var s=a.radialSegments,u=a.sizeFactor,c=s*2*o*2,l=ot.createState(c,c/10,i),f=t.conformation.invariantPosition,d=y(),m=y(),h={radiusTop:1,radiusBottom:1,radialSegments:s},p=ie.Location.create(r,t),v=ie.Location.create(r,t),g=function(S,_,C,D,T){p.element=S,v.element=_,f(p.element,d),f(v.element,m);var A=Qo(T),E=A?ag:ng;h.radiusTop=h.radiusBottom=n.size.size(p)*u,l.currentGroup=C,za(l,d,m,E,h),h.radiusTop=h.radiusBottom=n.size.size(v)*u,l.currentGroup=D,za(l,m,d,1-E,h)};T4(t,g);var b=ot.getMesh(l),x=xe.expand(xe(),t.boundary.sphere,1*a.sizeFactor);return b.setBoundingSphere(x),b}function M8e(e){return Ca({defaultProps:w.getDefaultValues(ED),createGeometry:I8e,createLocationIterator:zu.fromGroup,getLoci:pl,eachLocation:hl,setUpdateState:function(t,r,n){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.radialSegments!==n.radialSegments},mustRecreate:function(t,r,n){return r.tryUseImpostor&&!!n}},e)}var ID=P(P(P({},Wn),CA),{sizeFactor:w.Numeric(.3,{min:0,max:10,step:.01}),detail:w.Numeric(0,{min:0,max:3,step:1},Ze.CustomQualityParamInfo),tryUseImpostor:w.Boolean(!0)});function Jue(e,t,r,n){return r.tryUseImpostor&&n&&n.extensions.fragDepth&&n.extensions.textureFloat?B8e(e):F8e(e)}function R8e(e,t,r,n,a,i){var o=t.polymerElements.length;if(!o)return ys.createEmpty(i);var s=eg.create(o,o/2,i),u=t.conformation.invariantPosition,c=y(),l=function(m,h){u(m,c),s.add(c[0],c[1],c[2],h)};A4(t,l);var f=s.getSpheres(),d=xe.expand(xe(),t.boundary.sphere,1*a.sizeFactor);return f.setBoundingSphere(d),f}function B8e(e){return _A({defaultProps:w.getDefaultValues(ID),createGeometry:R8e,createLocationIterator:zu.fromGroup,getLoci:pl,eachLocation:hl,setUpdateState:function(t,r,n){},mustRecreate:function(t,r,n){return!r.tryUseImpostor||!n}},e)}function O8e(e,t,r,n,a,i){var o=t.polymerElements.length;if(!o)return pt.createEmpty(i);var s=a.detail,u=a.sizeFactor,c=o*Pd(s),l=ot.createState(c,c/2,i),f=t.conformation.invariantPosition,d=y(),m=ie.Location.create(r,t),h=function(g,b){m.element=g,f(m.element,d),l.currentGroup=b,Kn(l,d,n.size.size(m)*u,s)};A4(t,h);var p=ot.getMesh(l),v=xe.expand(xe(),t.boundary.sphere,1*a.sizeFactor);return p.setBoundingSphere(v),p}function F8e(e){return Ca({defaultProps:w.getDefaultValues(ID),createGeometry:O8e,createLocationIterator:zu.fromGroup,getLoci:pl,eachLocation:hl,setUpdateState:function(t,r,n){t.createGeometry=r.sizeFactor!==n.sizeFactor||r.detail!==n.detail},mustRecreate:function(t,r,n){return r.tryUseImpostor&&!!n}},e)}var ece={"polymer-backbone-cylinder":function(e,t){return vn("Polymer backbone cylinder",e,t,$ue)},"polymer-backbone-sphere":function(e,t){return vn("Polymer backbone sphere",e,t,Jue)},"polymer-gap":function(e,t){return vn("Polymer gap cylinder",e,t,fb)}},tce=P(P(P(P({},ID),ED),cg),{sizeAspectRatio:w.Numeric(1,{min:.1,max:3,step:.1}),visuals:w.MultiSelect(["polymer-backbone-cylinder","polymer-backbone-sphere","polymer-gap"],w.objectToOptions(ece)),bumpFrequency:w.Numeric(0,{min:0,max:10,step:.1},Ze.ShadingCategory)});function L8e(e,t){var r=w.clone(tce),n=!1;return t.units.forEach(function(a){!n&&a.gapElements.length&&(n=!0)}),r.visuals.defaultValue=["polymer-backbone-cylinder","polymer-backbone-sphere"],n&&r.visuals.defaultValue.push("polymer-gap"),r}function k8e(e,t){return Lt.createMulti("Backbone",e,t,En,ece)}var rce={name:"backbone",label:"Backbone",description:"Displays polymer backbone with cylinders and spheres.",factory:k8e,getParams:L8e,defaultValues:w.getDefaultValues(tce),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"uniform"},isApplicable:function(e){return e.polymerResidueCount>0}};var MD=function(e){St(t,e);function t(){var r=e.call(this)||this;return Ua(t.BuiltIn,function(n,a){if(n.name!==a)throw new Error("Fix BuiltInStructureRepresentations to have matching names. ".concat(n.name," ").concat(a));r.add(n)}),r}return t}(gT);(function(e){e.BuiltIn={cartoon:Tse,backbone:rce,"ball-and-stick":voe,carbohydrate:Ooe,ellipsoid:Ese,"gaussian-surface":cue,"gaussian-volume":Que,label:mue,line:Wue,"molecular-surface":Cue,orientation:Aue,point:Eue,putty:Oue,spacefill:Lue}})(MD||(MD={}));var nce=function(){function e(t){var r=this;this.plugin=t,this.currentFrame=void 0,this._isAnimating=!1,this.frame=function(){r.tick(pn()),r._isAnimating&&(r.currentFrame=requestAnimationFrame(r.frame))}}return Object.defineProperty(e.prototype,"isAnimating",{get:function(){return this._isAnimating},enumerable:!1,configurable:!0}),e.prototype.tick=function(t,r){var n,a;return $(this,void 0,void 0,function(){var i,o,s,u;return J(this,function(c){switch(c.label){case 0:return[4,this.plugin.managers.animation.tick(t,r?.isSynchronous,r?.animation)];case 1:if(c.sent(),(n=this.plugin.canvas3d)===null||n===void 0||n.tick(t,r),ft&&(i=(a=this.plugin.canvas3d)===null||a===void 0?void 0:a.webgl.timer.resolve(),i))for(o=0,s=i;o1?n.count--:this.root.delete(r),!0},e.prototype.updateMapping=function(t,r,n,a){return he.Molecule.Structure.is(a)?(this.removeMapping(r),this.addMapping(t,r,a),!0):!1},e.prototype.dispose=function(){this.ev.dispose()},e}();var BD=function(){function e(){this.ev=Ps.create(),this.id=0,this.runningTasks=new Set,this.abortRequests=new Map,this.options=new Map,this.currentContext=[],this.events={progress:this.ev(),finished:this.ev()}}return e.prototype.tryGetAbortTaskId=function(t){if(this.abortRequests.has(t.progress.taskId))return t.progress.taskId;for(var r=0,n=t.children;rl&&(l=p),md&&(d=m)}if(c>l){var b=c;c=l,l=b}if(f>d){var b=f;f=d,d=b}var x=l-c+1,S=d-f+1;c-=r*x,l+=r*x,f-=r*S,d+=r*S;var _={x:Math.max(0,c/i),y:Math.max(0,f/o),width:Math.min(1,(l-c+1)/i),height:Math.min(1,(d-f+1)/o)};this.behaviors.relativeCrop.next(_)},t.prototype.getPreview=function(r){r===void 0&&(r=320);var n=this.getSize(),a=n.width,i=n.height;if(!(a<=0||i<=0)){var o=a/i,s=0,u=0;o>1?(s=r,u=Math.round(r/o)):(u=r,s=Math.round(r*o));var c=this.plugin.canvas3d.props;this.previewPass.setProps({cameraHelper:{axes:this.values.axes},transparentBackground:this.values.transparent,postprocessing:c.postprocessing,marking:c.marking});var l=this.previewPass.getImageData(s,u),f=this.previewCanvas;f.width=l.width,f.height=l.height,this.previewData.image=l,this.previewData.background=c.renderer.backgroundColor,this.previewData.transparent=this.values.transparent;var d=f.getContext("2d");if(!d)throw new Error("Could not create canvas 2d context");return d.putImageData(l,0,0),this.cropParams.auto&&this.autocrop(),this.events.previewed.next(void 0),{canvas:f,width:s,height:u}}},t.prototype.getSizeAndViewport=function(){var r=this.getSize(),n=r.width,a=r.height,i=this.relativeCrop,o={x:Math.floor(i.x*n),y:Math.floor(i.y*a),width:Math.ceil(i.width*n),height:Math.ceil(i.height*a)};return o.width+o.x>n&&(o.width=n-o.x),o.height+o.y>a&&(o.height=a-o.y),{width:n,height:a,viewport:o}},t.prototype.draw=function(r){return $(this,void 0,void 0,function(){var n,a,i,o,s,u,c,l;return J(this,function(f){switch(f.label){case 0:return n=this.getSizeAndViewport(),a=n.width,i=n.height,o=n.viewport,a<=0||i<=0?[2]:[4,r.update("Rendering image...")];case 1:return f.sent(),s=this.imagePass,[4,s.updateBackground()];case 2:return f.sent(),u=s.getImageData(a,i,o),[4,r.update("Encoding image...")];case 3:if(f.sent(),c=this.canvas,c.width=u.width,c.height=u.height,l=c.getContext("2d"),!l)throw new Error("Could not create canvas 2d context");return l.putImageData(u,0,0),[2]}})})},t.prototype.copyToClipboardTask=function(){var r=this,n=navigator.clipboard;if(!n?.write){this.plugin.log.error("clipboard.write not supported!");return}return Ce.create("Copy Image",function(a){return $(r,void 0,void 0,function(){var i,o;return J(this,function(s){switch(s.label){case 0:return[4,this.draw(a)];case 1:return s.sent(),[4,a.update("Converting image...")];case 2:return s.sent(),[4,Kx(this.canvas,"png")];case 3:return i=s.sent(),o=new ClipboardItem({"image/png":i}),[4,n.write([o])];case 4:return s.sent(),this.plugin.log.message("Image copied to clipboard."),[2]}})})})},t.prototype.getImageDataUri=function(){var r=this;return this.plugin.runTask(Ce.create("Generate Image",function(n){return $(r,void 0,void 0,function(){return J(this,function(a){switch(a.label){case 0:return[4,this.draw(n)];case 1:return a.sent(),[4,n.update("Converting image...")];case 2:return a.sent(),[2,this.canvas.toDataURL("png")]}})})}))},t.prototype.copyToClipboard=function(){var r=this.copyToClipboardTask();if(r)return this.plugin.runTask(r)},t.prototype.downloadTask=function(r){var n=this;return Ce.create("Download Image",function(a){return $(n,void 0,void 0,function(){var i;return J(this,function(o){switch(o.label){case 0:return[4,this.draw(a)];case 1:return o.sent(),[4,a.update("Downloading image...")];case 2:return o.sent(),[4,Kx(this.canvas,"png")];case 3:return i=o.sent(),IT(i,r??this.getFilename()),[2]}})})})},t.prototype.download=function(r){this.plugin.runTask(this.downloadTask(r))},t}($d);var sce=function(){function e(t){this.plugin=t,this.handlers=[]}return e.prototype.addHandler=function(t,r){var n=this.handlers.findIndex(function(a){return a[0]===t});n<0?this.handlers.push([t,r]):this.handlers[n][1]=r},e.prototype.removeHandler=function(t){var r=this.handlers.findIndex(function(n){return n[0]===t});r>=0&&this.handlers.splice(r,1)},e.prototype.handle=function(t){return $(this,void 0,void 0,function(){var r,n,a;return J(this,function(i){switch(i.label){case 0:r=this.handlers.length-1,i.label=1;case 1:return r>=0?(n=this.handlers[r][1],[4,n(t,this.plugin)]):[3,4];case 2:if(a=i.sent(),a)return[2];i.label=3;case 3:return r--,[3,1];case 4:return N8e(this.plugin,t),[2]}})})},e.prototype.dispose=function(){this.handlers.length=0},e}();function N8e(e,t){var r=t.filter(function(n){var a=n.name.toLowerCase();return a.endsWith(".molx")||a.endsWith(".molj")});r.length>0?rr.State.Snapshots.OpenFile(e,{file:r[0]}):e.runTask(e.state.data.applyAction(BL,{files:t.map(function(n){return Ur.File(n)}),format:{name:"auto",params:{}},visuals:!0}))}var uce=function(){function e(t){var r=this,n;this.spec=t,this.runTask=function(a,i){return r.managers.task.run(a,i)},this.resolveTask=function(a){if(a)return Ce.is(a)?r.runTask(a):a},this.subs=[],this.initCanvas3dPromiseCallbacks=[function(){},function(){}],this._isInitialized=!1,this.initializedPromiseCallbacks=[function(){},function(){}],this.disposed=!1,this.canvasContainer=void 0,this.ev=Ps.create(),this.config=new _ee(this.spec.config),this.state=new RD(this),this.commands=new lee,this.canvas3dInit=this.ev.behavior(!1),this.behaviors={state:{isAnimating:this.ev.behavior(!1),isUpdating:this.ev.behavior(!1),isBusy:this.ev.behavior(!1)},interaction:{hover:this.ev.behavior({current:Lt.Loci.Empty,modifiers:Ro.None,buttons:0,button:0}),click:this.ev.behavior({current:Lt.Loci.Empty,modifiers:Ro.None,buttons:0,button:0}),drag:this.ev.behavior({current:Lt.Loci.Empty,modifiers:Ro.None,buttons:0,button:0,pageStart:Me(),pageEnd:Me()}),key:this.ev.behavior(TF),keyReleased:this.ev.behavior(TF),selectionMode:this.ev.behavior(!1)},labels:{highlight:this.ev.behavior({labels:[]})},layout:{leftPanelTabName:this.ev.behavior("root")},canvas3d:{initialized:this.canvas3dInit.pipe(_s(function(a){return!!a}),Sl(1))}},this.canvas3dInitialized=new Promise(function(a,i){r.initCanvas3dPromiseCallbacks=[a,i]}),this.initialized=new Promise(function(a,i){r.initializedPromiseCallbacks=[a,i]}),this.layout=new roe(this),this.animationLoop=new nce(this),this.representation={structure:{registry:new MD,themes:{colorThemeRegistry:ci.createRegistry(),sizeThemeRegistry:ja.createRegistry()}},volume:{registry:new Yy,themes:{colorThemeRegistry:ci.createRegistry(),sizeThemeRegistry:ja.createRegistry()}}},this.query={structure:{registry:new dZ}},this.dataFormats=new Tie,this.builders={data:new pie(this),structure:void 0},this.helpers={substructureParent:new ace(this),viewportScreenshot:void 0},this.managers={structure:{hierarchy:new qA(this),component:new zA(this),measurement:new Zie(this),selection:new Qie(this),focus:new zie(this)},volume:{hierarchy:new XA(this)},interactivity:void 0,camera:new Iie(this),animation:new Aie(this),snapshot:new kp(this),lociLabels:void 0,toast:new ice(this),asset:new aG,task:new BD,dragAndDrop:new sce(this)},this.events={log:this.ev(),task:this.managers.task.events,canvas3d:{settingsUpdated:this.ev()}},this.customModelProperties=new pS.Registry,this.customStructureProperties=new pS.Registry,this.customStructureControls=new Map,this.customImportControls=new Map,this.genericRepresentationControls=new Map,this.customState=Object.create(null),this.log={entries:Sf(),entry:function(a){return r.events.log.next(a)},error:function(a){return r.events.log.next(Rc.error(a))},message:function(a){return r.events.log.next(Rc.message(a))},info:function(a){return r.events.log.next(Rc.info(a))},warn:function(a){return r.events.log.next(Rc.warning(a))}},this.fetch=V1,vG(!1),CW((n=this.config.get(Bn.Structure.SaccharideCompIdMapType))!==null&&n!==void 0?n:"default")}return Object.defineProperty(e.prototype,"isInitialized",{get:function(){return this._isInitialized},enumerable:!1,configurable:!0}),e.prototype.build=function(){return this.state.data.build()},e.prototype.initContainer=function(t){var r;if(this.canvasContainer)return!0;var n=document.createElement("div");Object.assign(n.style,{position:"absolute",left:0,top:0,right:0,bottom:0,"-webkit-user-select":"none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","-webkit-touch-callout":"none","touch-action":"manipulation"});var a=(r=t?.canvas3dContext)===null||r===void 0?void 0:r.canvas;return a||(a=document.createElement("canvas"),t?.checkeredCanvasBackground&&Object.assign(a.style,{"background-image":"linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%, lightgrey), linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%, lightgrey)","background-size":"60px 60px","background-position":"0 0, 30px 30px"}),n.appendChild(a)),this.initViewer(a,n,t?.canvas3dContext)?(this.canvasContainer=n,!0):!1},e.prototype.mount=function(t,r){var n;if(this.disposed)throw new Error("Cannot mount a disposed context");return this.initContainer(r)?(this.canvasContainer.parentElement!==t&&((n=this.canvasContainer.parentElement)===null||n===void 0||n.removeChild(this.canvasContainer)),t.appendChild(this.canvasContainer),this.handleResize(),!0):!1},e.prototype.unmount=function(){var t,r;(r=(t=this.canvasContainer)===null||t===void 0?void 0:t.parentElement)===null||r===void 0||r.removeChild(this.canvasContainer)},e.prototype.initViewer=function(t,r,n){var a=this,i,o,s,u,c,l,f;try{if(this.layout.setRoot(r),this.spec.layout&&this.spec.layout.initial&&this.layout.setProps(this.spec.layout.initial),n)this.canvas3dContext=n;else{var d=!((i=this.config.get(Bn.General.DisableAntialiasing))!==null&&i!==void 0&&i),m=!((o=this.config.get(Bn.General.DisablePreserveDrawingBuffer))!==null&&o!==void 0&&o),h=this.config.get(Bn.General.PixelScale)||1,p=this.config.get(Bn.General.PickScale)||.25,v=(s=this.config.get(Bn.General.PickPadding))!==null&&s!==void 0?s:1,g=this.config.get(Bn.General.EnableWboit)||!1,b=this.config.get(Bn.General.EnableDpoit)||!1,x=this.config.get(Bn.General.PreferWebGl1)||!1,S=!((u=this.config.get(Bn.General.AllowMajorPerformanceCaveat))!==null&&u!==void 0&&u),_=this.config.get(Bn.General.PowerPreference)||"high-performance";this.canvas3dContext=KT.fromCanvas(t,this.managers.asset,{antialias:d,preserveDrawingBuffer:m,pixelScale:h,pickScale:p,pickPadding:v,enableWboit:g,enableDpoit:b,preferWebGl1:x,failIfMajorPerformanceCaveat:S,powerPreference:_})}this.canvas3d=ZT.create(this.canvas3dContext),this.canvas3dInit.next(!0);var C=this.spec.canvas3d,D=Xe(16579577);return C?(((l=C.renderer)===null||l===void 0?void 0:l.backgroundColor)===void 0&&(C=P0(C,function(T){T.renderer?T.renderer.backgroundColor=D:T.renderer={backgroundColor:D}})),(f=this.canvas3d)===null||f===void 0||f.setProps(C)):(c=this.canvas3d)===null||c===void 0||c.setProps({renderer:{backgroundColor:D}}),this.animationLoop.start(),this.helpers.viewportScreenshot=new oce(this),this.subs.push(this.canvas3d.interaction.click.subscribe(function(T){return a.behaviors.interaction.click.next(T)})),this.subs.push(this.canvas3d.interaction.drag.subscribe(function(T){return a.behaviors.interaction.drag.next(T)})),this.subs.push(this.canvas3d.interaction.hover.subscribe(function(T){return a.behaviors.interaction.hover.next(T)})),this.subs.push(this.canvas3d.input.resize.pipe(JD(50),Tg(100,void 0,{leading:!1,trailing:!0})).subscribe(function(){return a.handleResize()})),this.subs.push(this.canvas3d.input.keyDown.subscribe(function(T){return a.behaviors.interaction.key.next(T)})),this.subs.push(this.canvas3d.input.keyUp.subscribe(function(T){return a.behaviors.interaction.keyReleased.next(T)})),this.subs.push(this.layout.events.updated.subscribe(function(){return requestAnimationFrame(function(){return a.handleResize()})})),this.handleResize(),yd.setImmediate(function(){return a.initCanvas3dPromiseCallbacks[0]()}),!0}catch(T){return this.log.error(""+T),console.error(T),yd.setImmediate(function(){return a.initCanvas3dPromiseCallbacks[1](T)}),!1}},e.prototype.handleResize=function(){var t,r,n=(t=this.canvas3dContext)===null||t===void 0?void 0:t.canvas,a=this.layout.root;if(a&&n){var i=this.config.get(Bn.General.PixelScale)||1;bee(n,a,i),(r=this.canvas3d)===null||r===void 0||r.requestResize()}},Object.defineProperty(e.prototype,"isBusy",{get:function(){return this.behaviors.state.isAnimating.value||this.behaviors.state.isUpdating.value},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectionMode",{get:function(){return this.behaviors.interaction.selectionMode.value},set:function(t){this.behaviors.interaction.selectionMode.next(t)},enumerable:!1,configurable:!0}),e.prototype.dataTransaction=function(t,r){return this.runTask(this.state.data.transaction(t,r))},e.prototype.clear=function(t){var r;return t===void 0&&(t=!1),t&&((r=this.canvas3d)===null||r===void 0||r.setProps(Jx)),rr.State.RemoveObject(this,{state:this.state.data,ref:Ir.RootRef})},e.prototype.dispose=function(t){var r,n;if(!this.disposed){for(var a=0,i=this.subs;a{let t=class t{set source(n){this.source$.next(n)}set loci(n){this.loci$.next(n)}set contacts(n){this.contacts$.next(n)}constructor(){this.parent$=new of(1),this.source$=new of(1),this.loci$=new of(1),this.contacts$=new of(1),this.selected=new Hs,this.highlighted=new Hs,this.plugin$=this.initPlugin(),this.structure$=this.initStructure(),this.update$=this.updateRepresentation(),this._update=this.update$.subscribe()}initPlugin(){let n=Ar({},mie());return this.parent$.pipe(Cn(()=>({parent:this._parent.nativeElement,canvas:this._canvas.nativeElement})),ds(({parent:a,canvas:i})=>di((()=>FD(this,null,function*(){let o=new uce(n);if(yield o.init(),!o.initViewer(i,a))throw new Error("Could not render the Mol* plugin");return o}))())),aP(1))}initStructure(){return this.plugin$.pipe(fC(this.source$),ds(([n,a])=>di((()=>FD(this,null,function*(){let i,o=a.label||"structure",s=a.format||"mmcif",u=a.compressed===!0;if(typeof a.data=="string"){let l=Ur.Url(a.data);i=yield n.builders.data.download({url:l,label:o,isBinary:u})}else{let l=Ur.File(a.data instanceof Blob?new File([a.data],`${o}.${s}`):a.data);i=yield n.builders.data.readFile({file:l,label:o,isBinary:u})}let c=yield n.builders.structure.parseTrajectory(i,s);return yield n.builders.structure.hierarchy.applyPreset(c,"default"),n.managers.structure.hierarchy.current.structures[0]?.cell.obj?.data}))())))}updateRepresentation(){return this.structure$.pipe(fC(this.loci$,this.contacts$),Cn(()=>{}))}ngAfterViewInit(){let n=this._parent.nativeElement;this.parent$.next(n)}ngOnDestroy(){this._update.unsubscribe()}};t.\u0275fac=function(a){return new(a||t)},t.\u0275cmp=kg({type:t,selectors:[["ngx-structure-viewer"]],viewQuery:function(a,i){if(a&1&&(IE(U8e,5),IE(V8e,5)),a&2){let o;KC(o=ZC())&&(i._parent=o.first),KC(o=ZC())&&(i._canvas=o.first)}},inputs:{source:"source",loci:"loci",contacts:"contacts"},outputs:{selected:"selected",highlighted:"highlighted"},standalone:!0,features:[Hg],decls:4,vars:0,consts:[[2,"position","relative","width","100%","height","100%"],["parent",""],[2,"position","absolute","left","0","top","0","width","100%","height","100%"],["canvas",""]],template:function(a,i){a&1&&(Rh(0,"div",0,1),Oh(2,"canvas",2,3),Bh())}});let e=t;return e})();var lce=(()=>{let t=class t{constructor(){this.title="demo-showcase",this.source={data:"https://files.rcsb.org/view/1CU4.cif",label:"1CU4",compressed:!1},this.loci=[{start:"1",end:"10",chain:"A",color:"#ff0000"},{start:"11",end:"20",chain:"A",color:"#00ff00"},{start:"21",end:"30",chain:"A",color:"#0000ff"}],this.contacts=[]}};t.\u0275fac=function(a){return new(a||t)},t.\u0275cmp=kg({type:t,selectors:[["app-root"]],standalone:!0,features:[Hg],decls:4,vars:3,consts:[[2,"width","600px","height","600px","outline","2px solid orangered"],[3,"source","loci"]],template:function(a,i){a&1&&(Rh(0,"h1"),CU(1),Bh(),Rh(2,"div",0),Oh(3,"ngx-structure-viewer",1),Bh()),a&2&&(bE(1),DE(i.title),bE(2),AE("source",i.source)("loci",i.loci))},dependencies:[LE,cce]});let e=t;return e})();XU(lce,RV).catch(e=>console.error(e)); diff --git a/docs/browser/polyfills-LZBJRJJE.js b/docs/browser/polyfills-LZBJRJJE.js new file mode 100644 index 0000000..57d4c33 --- /dev/null +++ b/docs/browser/polyfills-LZBJRJJE.js @@ -0,0 +1,2 @@ +(function(e){let n=e.performance;function c(L){n&&n.mark&&n.mark(L)}function r(L,t){n&&n.measure&&n.measure(L,t)}c("Zone");let a=e.__Zone_symbol_prefix||"__zone_symbol__";function l(L){return a+L}let y=e[l("forceDuplicateZoneCheck")]===!0;if(e.Zone){if(y||typeof e.Zone.__symbol__!="function")throw new Error("Zone already loaded.");return e.Zone}let oe=class oe{static assertZonePatched(){if(e.Promise!==re.ZoneAwarePromise)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")}static get root(){let t=oe.current;for(;t.parent;)t=t.parent;return t}static get current(){return U.zone}static get currentTask(){return te}static __load_patch(t,s,o=!1){if(re.hasOwnProperty(t)){if(!o&&y)throw Error("Already loaded patch: "+t)}else if(!e["__Zone_disable_"+t]){let v="Zone:"+t;c(v),re[t]=s(e,oe,z),r(v,v)}}get parent(){return this._parent}get name(){return this._name}constructor(t,s){this._parent=t,this._name=s?s.name||"unnamed":"",this._properties=s&&s.properties||{},this._zoneDelegate=new k(this,this._parent&&this._parent._zoneDelegate,s)}get(t){let s=this.getZoneWith(t);if(s)return s._properties[t]}getZoneWith(t){let s=this;for(;s;){if(s._properties.hasOwnProperty(t))return s;s=s._parent}return null}fork(t){if(!t)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,t)}wrap(t,s){if(typeof t!="function")throw new Error("Expecting function got: "+t);let o=this._zoneDelegate.intercept(this,t,s),v=this;return function(){return v.runGuarded(o,this,arguments,s)}}run(t,s,o,v){U={parent:U,zone:this};try{return this._zoneDelegate.invoke(this,t,s,o,v)}finally{U=U.parent}}runGuarded(t,s=null,o,v){U={parent:U,zone:this};try{try{return this._zoneDelegate.invoke(this,t,s,o,v)}catch(F){if(this._zoneDelegate.handleError(this,F))throw F}}finally{U=U.parent}}runTask(t,s,o){if(t.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(t.zone||$).name+"; Execution: "+this.name+")");if(t.state===H&&(t.type===K||t.type===P))return;let v=t.state!=T;v&&t._transitionTo(T,M),t.runCount++;let F=te;te=t,U={parent:U,zone:this};try{t.type==P&&t.data&&!t.data.isPeriodic&&(t.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,t,s,o)}catch(u){if(this._zoneDelegate.handleError(this,u))throw u}}finally{t.state!==H&&t.state!==d&&(t.type==K||t.data&&t.data.isPeriodic?v&&t._transitionTo(M,T):(t.runCount=0,this._updateTaskCount(t,-1),v&&t._transitionTo(H,T,H))),U=U.parent,te=F}}scheduleTask(t){if(t.zone&&t.zone!==this){let o=this;for(;o;){if(o===t.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${t.zone.name}`);o=o.parent}}t._transitionTo(X,H);let s=[];t._zoneDelegates=s,t._zone=this;try{t=this._zoneDelegate.scheduleTask(this,t)}catch(o){throw t._transitionTo(d,X,H),this._zoneDelegate.handleError(this,o),o}return t._zoneDelegates===s&&this._updateTaskCount(t,1),t.state==X&&t._transitionTo(M,X),t}scheduleMicroTask(t,s,o,v){return this.scheduleTask(new m(N,t,s,o,v,void 0))}scheduleMacroTask(t,s,o,v,F){return this.scheduleTask(new m(P,t,s,o,v,F))}scheduleEventTask(t,s,o,v,F){return this.scheduleTask(new m(K,t,s,o,v,F))}cancelTask(t){if(t.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(t.zone||$).name+"; Execution: "+this.name+")");if(!(t.state!==M&&t.state!==T)){t._transitionTo(x,M,T);try{this._zoneDelegate.cancelTask(this,t)}catch(s){throw t._transitionTo(d,x),this._zoneDelegate.handleError(this,s),s}return this._updateTaskCount(t,-1),t._transitionTo(H,x),t.runCount=0,t}}_updateTaskCount(t,s){let o=t._zoneDelegates;s==-1&&(t._zoneDelegates=null);for(let v=0;vL.hasTask(s,o),onScheduleTask:(L,t,s,o)=>L.scheduleTask(s,o),onInvokeTask:(L,t,s,o,v,F)=>L.invokeTask(s,o,v,F),onCancelTask:(L,t,s,o)=>L.cancelTask(s,o)};class k{constructor(t,s,o){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=t,this._parentDelegate=s,this._forkZS=o&&(o&&o.onFork?o:s._forkZS),this._forkDlgt=o&&(o.onFork?s:s._forkDlgt),this._forkCurrZone=o&&(o.onFork?this.zone:s._forkCurrZone),this._interceptZS=o&&(o.onIntercept?o:s._interceptZS),this._interceptDlgt=o&&(o.onIntercept?s:s._interceptDlgt),this._interceptCurrZone=o&&(o.onIntercept?this.zone:s._interceptCurrZone),this._invokeZS=o&&(o.onInvoke?o:s._invokeZS),this._invokeDlgt=o&&(o.onInvoke?s:s._invokeDlgt),this._invokeCurrZone=o&&(o.onInvoke?this.zone:s._invokeCurrZone),this._handleErrorZS=o&&(o.onHandleError?o:s._handleErrorZS),this._handleErrorDlgt=o&&(o.onHandleError?s:s._handleErrorDlgt),this._handleErrorCurrZone=o&&(o.onHandleError?this.zone:s._handleErrorCurrZone),this._scheduleTaskZS=o&&(o.onScheduleTask?o:s._scheduleTaskZS),this._scheduleTaskDlgt=o&&(o.onScheduleTask?s:s._scheduleTaskDlgt),this._scheduleTaskCurrZone=o&&(o.onScheduleTask?this.zone:s._scheduleTaskCurrZone),this._invokeTaskZS=o&&(o.onInvokeTask?o:s._invokeTaskZS),this._invokeTaskDlgt=o&&(o.onInvokeTask?s:s._invokeTaskDlgt),this._invokeTaskCurrZone=o&&(o.onInvokeTask?this.zone:s._invokeTaskCurrZone),this._cancelTaskZS=o&&(o.onCancelTask?o:s._cancelTaskZS),this._cancelTaskDlgt=o&&(o.onCancelTask?s:s._cancelTaskDlgt),this._cancelTaskCurrZone=o&&(o.onCancelTask?this.zone:s._cancelTaskCurrZone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;let v=o&&o.onHasTask,F=s&&s._hasTaskZS;(v||F)&&(this._hasTaskZS=v?o:b,this._hasTaskDlgt=s,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=t,o.onScheduleTask||(this._scheduleTaskZS=b,this._scheduleTaskDlgt=s,this._scheduleTaskCurrZone=this.zone),o.onInvokeTask||(this._invokeTaskZS=b,this._invokeTaskDlgt=s,this._invokeTaskCurrZone=this.zone),o.onCancelTask||(this._cancelTaskZS=b,this._cancelTaskDlgt=s,this._cancelTaskCurrZone=this.zone))}fork(t,s){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,t,s):new _(t,s)}intercept(t,s,o){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,t,s,o):s}invoke(t,s,o,v,F){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,t,s,o,v,F):s.apply(o,v)}handleError(t,s){return this._handleErrorZS?this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,t,s):!0}scheduleTask(t,s){let o=s;if(this._scheduleTaskZS)this._hasTaskZS&&o._zoneDelegates.push(this._hasTaskDlgtOwner),o=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,t,s),o||(o=s);else if(s.scheduleFn)s.scheduleFn(s);else if(s.type==N)R(s);else throw new Error("Task is missing scheduleFn.");return o}invokeTask(t,s,o,v){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,t,s,o,v):s.callback.apply(o,v)}cancelTask(t,s){let o;if(this._cancelTaskZS)o=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,t,s);else{if(!s.cancelFn)throw Error("Task is not cancelable");o=s.cancelFn(s)}return o}hasTask(t,s){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,t,s)}catch(o){this.handleError(t,o)}}_updateTaskCount(t,s){let o=this._taskCounts,v=o[t],F=o[t]=v+s;if(F<0)throw new Error("More tasks executed then were scheduled.");if(v==0||F==0){let u={microTask:o.microTask>0,macroTask:o.macroTask>0,eventTask:o.eventTask>0,change:t};this.hasTask(this.zone,u)}}}class m{constructor(t,s,o,v,F,u){if(this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=t,this.source=s,this.data=v,this.scheduleFn=F,this.cancelFn=u,!o)throw new Error("callback is not defined");this.callback=o;let f=this;t===K&&v&&v.useG?this.invoke=m.invokeTask:this.invoke=function(){return m.invokeTask.call(e,f,this,arguments)}}static invokeTask(t,s,o){t||(t=this),Q++;try{return t.runCount++,t.zone.runTask(t,s,o)}finally{Q==1&&E(),Q--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(H,X)}_transitionTo(t,s,o){if(this._state===s||this._state===o)this._state=t,t==H&&(this._zoneDelegates=null);else throw new Error(`${this.type} '${this.source}': can not transition to '${t}', expecting state '${s}'${o?" or '"+o+"'":""}, was '${this._state}'.`)}toString(){return this.data&&typeof this.data.handleId<"u"?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}let I=l("setTimeout"),Z=l("Promise"),O=l("then"),B=[],A=!1,J;function q(L){if(J||e[Z]&&(J=e[Z].resolve(0)),J){let t=J[O];t||(t=J.then),t.call(J,L)}else e[I](L,0)}function R(L){Q===0&&B.length===0&&q(E),L&&B.push(L)}function E(){if(!A){for(A=!0;B.length;){let L=B;B=[];for(let t=0;tU,onUnhandledError:W,microtaskDrainDone:W,scheduleMicroTask:R,showUncaughtError:()=>!_[l("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:W,patchMethod:()=>W,bindArguments:()=>[],patchThen:()=>W,patchMacroTask:()=>W,patchEventPrototype:()=>W,isIEOrEdge:()=>!1,getGlobalObjects:()=>{},ObjectDefineProperty:()=>W,ObjectGetOwnPropertyDescriptor:()=>{},ObjectCreate:()=>{},ArraySlice:()=>[],patchClass:()=>W,wrapWithCurrentZone:()=>W,filterProperties:()=>[],attachOriginToPatched:()=>W,_redefineProperty:()=>W,patchCallbacks:()=>W,nativeScheduleMicroTask:q},U={parent:null,zone:new _(null,null)},te=null,Q=0;function W(){}return r("Zone","Zone"),e.Zone=_})(globalThis);var me=Object.getOwnPropertyDescriptor,Ne=Object.defineProperty,Ie=Object.getPrototypeOf,it=Object.create,ct=Array.prototype.slice,Me="addEventListener",Le="removeEventListener",Se=Zone.__symbol__(Me),De=Zone.__symbol__(Le),ie="true",ce="false",pe=Zone.__symbol__("");function Ae(e,n){return Zone.current.wrap(e,n)}function je(e,n,c,r,a){return Zone.current.scheduleMacroTask(e,n,c,r,a)}var j=Zone.__symbol__,Pe=typeof window<"u",Te=Pe?window:void 0,Y=Pe&&Te||globalThis,at="removeAttribute";function He(e,n){for(let c=e.length-1;c>=0;c--)typeof e[c]=="function"&&(e[c]=Ae(e[c],n+"_"+c));return e}function lt(e,n){let c=e.constructor.name;for(let r=0;r{let b=function(){return _.apply(this,He(arguments,c+"."+a))};return ae(b,_),b})(l)}}}function Ye(e){return e?e.writable===!1?!1:!(typeof e.get=="function"&&typeof e.set>"u"):!0}var $e=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,we=!("nw"in Y)&&typeof Y.process<"u"&&{}.toString.call(Y.process)==="[object process]",xe=!we&&!$e&&!!(Pe&&Te.HTMLElement),Je=typeof Y.process<"u"&&{}.toString.call(Y.process)==="[object process]"&&!$e&&!!(Pe&&Te.HTMLElement),be={},We=function(e){if(e=e||Y.event,!e)return;let n=be[e.type];n||(n=be[e.type]=j("ON_PROPERTY"+e.type));let c=this||e.target||Y,r=c[n],a;if(xe&&c===Te&&e.type==="error"){let l=e;a=r&&r.call(this,l.message,l.filename,l.lineno,l.colno,l.error),a===!0&&e.preventDefault()}else a=r&&r.apply(this,arguments),a!=null&&!a&&e.preventDefault();return a};function qe(e,n,c){let r=me(e,n);if(!r&&c&&me(c,n)&&(r={enumerable:!0,configurable:!0}),!r||!r.configurable)return;let a=j("on"+n+"patched");if(e.hasOwnProperty(a)&&e[a])return;delete r.writable,delete r.value;let l=r.get,y=r.set,_=n.slice(2),b=be[_];b||(b=be[_]=j("ON_PROPERTY"+_)),r.set=function(k){let m=this;if(!m&&e===Y&&(m=Y),!m)return;typeof m[b]=="function"&&m.removeEventListener(_,We),y&&y.call(m,null),m[b]=k,typeof k=="function"&&m.addEventListener(_,We,!1)},r.get=function(){let k=this;if(!k&&e===Y&&(k=Y),!k)return null;let m=k[b];if(m)return m;if(l){let I=l.call(this);if(I)return r.set.call(this,I),typeof k[at]=="function"&&k.removeAttribute(n),I}return null},Ne(e,n,r),e[a]=!0}function Ke(e,n,c){if(n)for(let r=0;rfunction(y,_){let b=c(y,_);return b.cbIdx>=0&&typeof _[b.cbIdx]=="function"?je(b.name,_[b.cbIdx],b,a):l.apply(y,_)})}function ae(e,n){e[j("OriginalDelegate")]=n}var Xe=!1,Ze=!1;function ft(){try{let e=Te.navigator.userAgent;if(e.indexOf("MSIE ")!==-1||e.indexOf("Trident/")!==-1)return!0}catch{}return!1}function ht(){if(Xe)return Ze;Xe=!0;try{let e=Te.navigator.userAgent;(e.indexOf("MSIE ")!==-1||e.indexOf("Trident/")!==-1||e.indexOf("Edge/")!==-1)&&(Ze=!0)}catch{}return Ze}Zone.__load_patch("ZoneAwarePromise",(e,n,c)=>{let r=Object.getOwnPropertyDescriptor,a=Object.defineProperty;function l(u){if(u&&u.toString===Object.prototype.toString){let f=u.constructor&&u.constructor.name;return(f||"")+": "+JSON.stringify(u)}return u?u.toString():Object.prototype.toString.call(u)}let y=c.symbol,_=[],b=e[y("DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION")]!==!1,k=y("Promise"),m=y("then"),I="__creationTrace__";c.onUnhandledError=u=>{if(c.showUncaughtError()){let f=u&&u.rejection;f?console.error("Unhandled Promise rejection:",f instanceof Error?f.message:f,"; Zone:",u.zone.name,"; Task:",u.task&&u.task.source,"; Value:",f,f instanceof Error?f.stack:void 0):console.error(u)}},c.microtaskDrainDone=()=>{for(;_.length;){let u=_.shift();try{u.zone.runGuarded(()=>{throw u.throwOriginal?u.rejection:u})}catch(f){O(f)}}};let Z=y("unhandledPromiseRejectionHandler");function O(u){c.onUnhandledError(u);try{let f=n[Z];typeof f=="function"&&f.call(this,u)}catch{}}function B(u){return u&&u.then}function A(u){return u}function J(u){return t.reject(u)}let q=y("state"),R=y("value"),E=y("finally"),$=y("parentPromiseValue"),H=y("parentPromiseState"),X="Promise.then",M=null,T=!0,x=!1,d=0;function N(u,f){return i=>{try{z(u,f,i)}catch(h){z(u,!1,h)}}}let P=function(){let u=!1;return function(i){return function(){u||(u=!0,i.apply(null,arguments))}}},K="Promise resolved with itself",re=y("currentTaskTrace");function z(u,f,i){let h=P();if(u===i)throw new TypeError(K);if(u[q]===M){let g=null;try{(typeof i=="object"||typeof i=="function")&&(g=i&&i.then)}catch(w){return h(()=>{z(u,!1,w)})(),u}if(f!==x&&i instanceof t&&i.hasOwnProperty(q)&&i.hasOwnProperty(R)&&i[q]!==M)te(i),z(u,i[q],i[R]);else if(f!==x&&typeof g=="function")try{g.call(i,h(N(u,f)),h(N(u,!1)))}catch(w){h(()=>{z(u,!1,w)})()}else{u[q]=f;let w=u[R];if(u[R]=i,u[E]===E&&f===T&&(u[q]=u[H],u[R]=u[$]),f===x&&i instanceof Error){let p=n.currentTask&&n.currentTask.data&&n.currentTask.data[I];p&&a(i,re,{configurable:!0,enumerable:!1,writable:!0,value:p})}for(let p=0;p{try{let C=u[R],S=!!i&&E===i[E];S&&(i[$]=C,i[H]=w);let D=f.run(p,void 0,S&&p!==J&&p!==A?[]:[C]);z(i,!0,D)}catch(C){z(i,!1,C)}},i)}let W="function ZoneAwarePromise() { [native code] }",oe=function(){},L=e.AggregateError;class t{static toString(){return W}static resolve(f){return z(new this(null),T,f)}static reject(f){return z(new this(null),x,f)}static any(f){if(!f||typeof f[Symbol.iterator]!="function")return Promise.reject(new L([],"All promises were rejected"));let i=[],h=0;try{for(let p of f)h++,i.push(t.resolve(p))}catch{return Promise.reject(new L([],"All promises were rejected"))}if(h===0)return Promise.reject(new L([],"All promises were rejected"));let g=!1,w=[];return new t((p,C)=>{for(let S=0;S{g||(g=!0,p(D))},D=>{w.push(D),h--,h===0&&(g=!0,C(new L(w,"All promises were rejected")))})})}static race(f){let i,h,g=new this((C,S)=>{i=C,h=S});function w(C){i(C)}function p(C){h(C)}for(let C of f)B(C)||(C=this.resolve(C)),C.then(w,p);return g}static all(f){return t.allWithCallback(f)}static allSettled(f){return(this&&this.prototype instanceof t?this:t).allWithCallback(f,{thenCallback:h=>({status:"fulfilled",value:h}),errorCallback:h=>({status:"rejected",reason:h})})}static allWithCallback(f,i){let h,g,w=new this((D,G)=>{h=D,g=G}),p=2,C=0,S=[];for(let D of f){B(D)||(D=this.resolve(D));let G=C;try{D.then(V=>{S[G]=i?i.thenCallback(V):V,p--,p===0&&h(S)},V=>{i?(S[G]=i.errorCallback(V),p--,p===0&&h(S)):g(V)})}catch(V){g(V)}p++,C++}return p-=2,p===0&&h(S),w}constructor(f){let i=this;if(!(i instanceof t))throw new Error("Must be an instanceof Promise.");i[q]=M,i[R]=[];try{let h=P();f&&f(h(N(i,T)),h(N(i,x)))}catch(h){z(i,!1,h)}}get[Symbol.toStringTag](){return"Promise"}get[Symbol.species](){return t}then(f,i){let h=this.constructor?.[Symbol.species];(!h||typeof h!="function")&&(h=this.constructor||t);let g=new h(oe),w=n.current;return this[q]==M?this[R].push(w,g,f,i):Q(this,w,g,f,i),g}catch(f){return this.then(null,f)}finally(f){let i=this.constructor?.[Symbol.species];(!i||typeof i!="function")&&(i=t);let h=new i(oe);h[E]=E;let g=n.current;return this[q]==M?this[R].push(g,h,f,f):Q(this,g,h,f,f),h}}t.resolve=t.resolve,t.reject=t.reject,t.race=t.race,t.all=t.all;let s=e[k]=e.Promise;e.Promise=t;let o=y("thenPatched");function v(u){let f=u.prototype,i=r(f,"then");if(i&&(i.writable===!1||!i.configurable))return;let h=f.then;f[m]=h,u.prototype.then=function(g,w){return new t((C,S)=>{h.call(this,C,S)}).then(g,w)},u[o]=!0}c.patchThen=v;function F(u){return function(f,i){let h=u.apply(f,i);if(h instanceof t)return h;let g=h.constructor;return g[o]||v(g),h}}return s&&(v(s),le(e,"fetch",u=>F(u))),Promise[n.__symbol__("uncaughtPromiseErrors")]=_,t});Zone.__load_patch("toString",e=>{let n=Function.prototype.toString,c=j("OriginalDelegate"),r=j("Promise"),a=j("Error"),l=function(){if(typeof this=="function"){let k=this[c];if(k)return typeof k=="function"?n.call(k):Object.prototype.toString.call(k);if(this===Promise){let m=e[r];if(m)return n.call(m)}if(this===Error){let m=e[a];if(m)return n.call(m)}}return n.call(this)};l[c]=n,Function.prototype.toString=l;let y=Object.prototype.toString,_="[object Promise]";Object.prototype.toString=function(){return typeof Promise=="function"&&this instanceof Promise?_:y.call(this)}});var _e=!1;if(typeof window<"u")try{let e=Object.defineProperty({},"passive",{get:function(){_e=!0}});window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch{_e=!1}var dt={useG:!0},ee={},Qe={},et=new RegExp("^"+pe+"(\\w+)(true|false)$"),tt=j("propagationStopped");function nt(e,n){let c=(n?n(e):e)+ce,r=(n?n(e):e)+ie,a=pe+c,l=pe+r;ee[e]={},ee[e][ce]=a,ee[e][ie]=l}function _t(e,n,c,r){let a=r&&r.add||Me,l=r&&r.rm||Le,y=r&&r.listeners||"eventListeners",_=r&&r.rmAll||"removeAllListeners",b=j(a),k="."+a+":",m="prependListener",I="."+m+":",Z=function(R,E,$){if(R.isRemoved)return;let H=R.callback;typeof H=="object"&&H.handleEvent&&(R.callback=T=>H.handleEvent(T),R.originalDelegate=H);let X;try{R.invoke(R,E,[$])}catch(T){X=T}let M=R.options;if(M&&typeof M=="object"&&M.once){let T=R.originalDelegate?R.originalDelegate:R.callback;E[l].call(E,$.type,T,M)}return X};function O(R,E,$){if(E=E||e.event,!E)return;let H=R||E.target||e,X=H[ee[E.type][$?ie:ce]];if(X){let M=[];if(X.length===1){let T=Z(X[0],H,E);T&&M.push(T)}else{let T=X.slice();for(let x=0;x{throw x})}}}let B=function(R){return O(this,R,!1)},A=function(R){return O(this,R,!0)};function J(R,E){if(!R)return!1;let $=!0;E&&E.useG!==void 0&&($=E.useG);let H=E&&E.vh,X=!0;E&&E.chkDup!==void 0&&(X=E.chkDup);let M=!1;E&&E.rt!==void 0&&(M=E.rt);let T=R;for(;T&&!T.hasOwnProperty(a);)T=Ie(T);if(!T&&R[a]&&(T=R),!T||T[b])return!1;let x=E&&E.eventNameToString,d={},N=T[b]=T[a],P=T[j(l)]=T[l],K=T[j(y)]=T[y],re=T[j(_)]=T[_],z;E&&E.prepend&&(z=T[j(E.prepend)]=T[E.prepend]);function U(i,h){return!_e&&typeof i=="object"&&i?!!i.capture:!_e||!h?i:typeof i=="boolean"?{capture:i,passive:!0}:i?typeof i=="object"&&i.passive!==!1?{...i,passive:!0}:i:{passive:!0}}let te=function(i){if(!d.isExisting)return N.call(d.target,d.eventName,d.capture?A:B,d.options)},Q=function(i){if(!i.isRemoved){let h=ee[i.eventName],g;h&&(g=h[i.capture?ie:ce]);let w=g&&i.target[g];if(w){for(let p=0;pfunction(a,l){a[tt]=!0,r&&r.apply(a,l)})}function Tt(e,n,c,r,a){let l=Zone.__symbol__(r);if(n[l])return;let y=n[l]=n[r];n[r]=function(_,b,k){return b&&b.prototype&&a.forEach(function(m){let I=`${c}.${r}::`+m,Z=b.prototype;try{if(Z.hasOwnProperty(m)){let O=e.ObjectGetOwnPropertyDescriptor(Z,m);O&&O.value?(O.value=e.wrapWithCurrentZone(O.value,I),e._redefineProperty(b.prototype,m,O)):Z[m]&&(Z[m]=e.wrapWithCurrentZone(Z[m],I))}else Z[m]&&(Z[m]=e.wrapWithCurrentZone(Z[m],I))}catch{}}),y.call(n,_,b,k)},e.attachOriginToPatched(n[r],y)}function ot(e,n,c){if(!c||c.length===0)return n;let r=c.filter(l=>l.target===e);if(!r||r.length===0)return n;let a=r[0].ignoreProperties;return n.filter(l=>a.indexOf(l)===-1)}function ze(e,n,c,r){if(!e)return;let a=ot(e,n,c);Ke(e,a,r)}function Oe(e){return Object.getOwnPropertyNames(e).filter(n=>n.startsWith("on")&&n.length>2).map(n=>n.substring(2))}function yt(e,n){if(we&&!Je||Zone[e.symbol("patchEvents")])return;let c=n.__Zone_ignore_on_properties,r=[];if(xe){let a=window;r=r.concat(["Document","SVGElement","Element","HTMLElement","HTMLBodyElement","HTMLMediaElement","HTMLFrameSetElement","HTMLFrameElement","HTMLIFrameElement","HTMLMarqueeElement","Worker"]);let l=ft()?[{target:a,ignoreProperties:["error"]}]:[];ze(a,Oe(a),c&&c.concat(l),Ie(a))}r=r.concat(["XMLHttpRequest","XMLHttpRequestEventTarget","IDBIndex","IDBRequest","IDBOpenDBRequest","IDBDatabase","IDBTransaction","IDBCursor","WebSocket"]);for(let a=0;a{let r=Oe(e);c.patchOnProperties=Ke,c.patchMethod=le,c.bindArguments=He,c.patchMacroTask=ut;let a=n.__symbol__("BLACK_LISTED_EVENTS"),l=n.__symbol__("UNPATCHED_EVENTS");e[l]&&(e[a]=e[l]),e[a]&&(n[a]=n[l]=e[a]),c.patchEventPrototype=Et,c.patchEventTarget=_t,c.isIEOrEdge=ht,c.ObjectDefineProperty=Ne,c.ObjectGetOwnPropertyDescriptor=me,c.ObjectCreate=it,c.ArraySlice=ct,c.patchClass=ge,c.wrapWithCurrentZone=Ae,c.filterProperties=ot,c.attachOriginToPatched=ae,c._redefineProperty=Object.defineProperty,c.patchCallbacks=Tt,c.getGlobalObjects=()=>({globalSources:Qe,zoneSymbolEventNames:ee,eventNames:r,isBrowser:xe,isMix:Je,isNode:we,TRUE_STR:ie,FALSE_STR:ce,ZONE_SYMBOL_PREFIX:pe,ADD_EVENT_LISTENER_STR:Me,REMOVE_EVENT_LISTENER_STR:Le})});function mt(e,n){n.patchMethod(e,"queueMicrotask",c=>function(r,a){Zone.current.scheduleMicroTask("queueMicrotask",a[0])})}var ve=j("zoneTask");function Ee(e,n,c,r){let a=null,l=null;n+=r,c+=r;let y={};function _(k){let m=k.data;return m.args[0]=function(){return k.invoke.apply(this,arguments)},m.handleId=a.apply(e,m.args),k}function b(k){return l.call(e,k.data.handleId)}a=le(e,n,k=>function(m,I){if(typeof I[0]=="function"){let Z={isPeriodic:r==="Interval",delay:r==="Timeout"||r==="Interval"?I[1]||0:void 0,args:I},O=I[0];I[0]=function(){try{return O.apply(this,arguments)}finally{Z.isPeriodic||(typeof Z.handleId=="number"?delete y[Z.handleId]:Z.handleId&&(Z.handleId[ve]=null))}};let B=je(n,I[0],Z,_,b);if(!B)return B;let A=B.data.handleId;return typeof A=="number"?y[A]=B:A&&(A[ve]=B),A&&A.ref&&A.unref&&typeof A.ref=="function"&&typeof A.unref=="function"&&(B.ref=A.ref.bind(A),B.unref=A.unref.bind(A)),typeof A=="number"||A?A:B}else return k.apply(e,I)}),l=le(e,c,k=>function(m,I){let Z=I[0],O;typeof Z=="number"?O=y[Z]:(O=Z&&Z[ve],O||(O=Z)),O&&typeof O.type=="string"?O.state!=="notScheduled"&&(O.cancelFn&&O.data.isPeriodic||O.runCount===0)&&(typeof Z=="number"?delete y[Z]:Z&&(Z[ve]=null),O.zone.cancelTask(O)):k.apply(e,I)})}function pt(e,n){let{isBrowser:c,isMix:r}=n.getGlobalObjects();if(!c&&!r||!e.customElements||!("customElements"in e))return;let a=["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"];n.patchCallbacks(n,e.customElements,"customElements","define",a)}function gt(e,n){if(Zone[n.symbol("patchEventTarget")])return;let{eventNames:c,zoneSymbolEventNames:r,TRUE_STR:a,FALSE_STR:l,ZONE_SYMBOL_PREFIX:y}=n.getGlobalObjects();for(let b=0;b{let n=e[Zone.__symbol__("legacyPatch")];n&&n()});Zone.__load_patch("timers",e=>{let n="set",c="clear";Ee(e,n,c,"Timeout"),Ee(e,n,c,"Interval"),Ee(e,n,c,"Immediate")});Zone.__load_patch("requestAnimationFrame",e=>{Ee(e,"request","cancel","AnimationFrame"),Ee(e,"mozRequest","mozCancel","AnimationFrame"),Ee(e,"webkitRequest","webkitCancel","AnimationFrame")});Zone.__load_patch("blocking",(e,n)=>{let c=["alert","prompt","confirm"];for(let r=0;rfunction(b,k){return n.current.run(l,e,k,_)})}});Zone.__load_patch("EventTarget",(e,n,c)=>{kt(e,c),gt(e,c);let r=e.XMLHttpRequestEventTarget;r&&r.prototype&&c.patchEventTarget(e,c,[r.prototype])});Zone.__load_patch("MutationObserver",(e,n,c)=>{ge("MutationObserver"),ge("WebKitMutationObserver")});Zone.__load_patch("IntersectionObserver",(e,n,c)=>{ge("IntersectionObserver")});Zone.__load_patch("FileReader",(e,n,c)=>{ge("FileReader")});Zone.__load_patch("on_property",(e,n,c)=>{yt(c,e)});Zone.__load_patch("customElements",(e,n,c)=>{pt(e,c)});Zone.__load_patch("XHR",(e,n)=>{b(e);let c=j("xhrTask"),r=j("xhrSync"),a=j("xhrListener"),l=j("xhrScheduled"),y=j("xhrURL"),_=j("xhrErrorBeforeScheduled");function b(k){let m=k.XMLHttpRequest;if(!m)return;let I=m.prototype;function Z(d){return d[c]}let O=I[Se],B=I[De];if(!O){let d=k.XMLHttpRequestEventTarget;if(d){let N=d.prototype;O=N[Se],B=N[De]}}let A="readystatechange",J="scheduled";function q(d){let N=d.data,P=N.target;P[l]=!1,P[_]=!1;let K=P[a];O||(O=P[Se],B=P[De]),K&&B.call(P,A,K);let re=P[a]=()=>{if(P.readyState===P.DONE)if(!N.aborted&&P[l]&&d.state===J){let U=P[n.__symbol__("loadfalse")];if(P.status!==0&&U&&U.length>0){let te=d.invoke;d.invoke=function(){let Q=P[n.__symbol__("loadfalse")];for(let W=0;Wfunction(d,N){return d[r]=N[2]==!1,d[y]=N[1],$.apply(d,N)}),H="XMLHttpRequest.send",X=j("fetchTaskAborting"),M=j("fetchTaskScheduling"),T=le(I,"send",()=>function(d,N){if(n.current[M]===!0||d[r])return T.apply(d,N);{let P={target:d,url:d[y],isPeriodic:!1,args:N,aborted:!1},K=je(H,R,P,q,E);d&&d[_]===!0&&!P.aborted&&K.state===J&&K.invoke()}}),x=le(I,"abort",()=>function(d,N){let P=Z(d);if(P&&typeof P.type=="string"){if(P.cancelFn==null||P.data&&P.data.aborted)return;P.zone.cancelTask(P)}else if(n.current[X]===!0)return x.apply(d,N)})}});Zone.__load_patch("geolocation",e=>{e.navigator&&e.navigator.geolocation&<(e.navigator.geolocation,["getCurrentPosition","watchPosition"])});Zone.__load_patch("PromiseRejectionEvent",(e,n)=>{function c(r){return function(a){rt(e,r).forEach(y=>{let _=e.PromiseRejectionEvent;if(_){let b=new _(r,{promise:a.promise,reason:a.rejection});y.invoke(b)}})}}e.PromiseRejectionEvent&&(n[j("unhandledPromiseRejectionHandler")]=c("unhandledrejection"),n[j("rejectionHandledHandler")]=c("rejectionhandled"))});Zone.__load_patch("queueMicrotask",(e,n,c)=>{mt(e,c)}); diff --git a/docs/browser/styles-5INURTSO.css b/docs/browser/styles-5INURTSO.css new file mode 100644 index 0000000..e69de29