diff --git a/docs/404.html b/docs/404.html index a26a967..7546f0a 100644 --- a/docs/404.html +++ b/docs/404.html @@ -16,5 +16,5 @@ - + diff --git a/docs/index.html b/docs/index.html index a26a967..7546f0a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -16,5 +16,5 @@ - + diff --git a/docs/main.6bf9860e8ab55dfd.js b/docs/main.01eb911639777ecf.js similarity index 84% rename from docs/main.6bf9860e8ab55dfd.js rename to docs/main.01eb911639777ecf.js index 0f534c6..c7820f8 100644 --- a/docs/main.6bf9860e8ab55dfd.js +++ b/docs/main.01eb911639777ecf.js @@ -1 +1 @@ -(self.webpackChunkdemo_showcase=self.webpackChunkdemo_showcase||[]).push([[792],{540:(n_,rG,Fn)=>{"use strict";var r_={};Fn.r(r_),Fn.d(r_,{atomicHet:()=>SOe,atomicSequence:()=>_Oe,bundleElementImpl:()=>FJ,bundleGenerator:()=>BJ,defaultBondTest:()=>KB,spheres:()=>COe,water:()=>xOe});var UP={};Fn.r(UP),Fn.d(UP,{all:()=>UJ,atoms:()=>JB,bondedAtomicPairs:()=>kOe,chains:()=>IOe,none:()=>QB,querySelection:()=>ROe,residues:()=>AOe,rings:()=>MOe});var VP={};Fn.r(VP),Fn.d(VP,{exceptBy:()=>m5e,expandProperty:()=>y5e,includeConnected:()=>b5e,includeSurroundings:()=>f5e,intersectBy:()=>h5e,querySelection:()=>p5e,surroundingLigands:()=>_5e,union:()=>g5e,wholeResidues:()=>u5e});var zP={};Fn.r(zP),Fn.d(zP,{areIntersectedBy:()=>R5e,first:()=>E5e,getCurrentStructureProperties:()=>PT,isConnectedTo:()=>L5e,pick:()=>D5e,withSameAtomProperties:()=>M5e,within:()=>k5e});var GP={};Fn.r(GP),Fn.d(GP,{intersect:()=>V5e,merge:()=>U5e});var jP={};Fn.r(jP),Fn.d(jP,{atomCount:()=>z5e,countQuery:()=>G5e,propertySet:()=>j5e});var HP={};Fn.r(HP),Fn.d(HP,{Download:()=>sre,DownloadBlob:()=>are,ImportJson:()=>Fze,ImportString:()=>Nze,LazyVolume:()=>Oze,ParseBlob:()=>wze,ParseCcp4:()=>Mze,ParseCif:()=>Aze,ParseCube:()=>Ize,ParseDsn6:()=>Rze,ParseDx:()=>kze,ParseJson:()=>Bze,ParsePly:()=>Pze,ParsePrmtop:()=>Dze,ParsePsf:()=>Tze,ParseTop:()=>Eze,RawData:()=>cre,ReadFile:()=>ure});var qP={};Fn.r(qP),Fn.d(qP,{CreateGroup:()=>Lze});var WP={};Fn.r(WP),Fn.d(WP,{CoordinatesFromDcd:()=>vXe,CoordinatesFromNctraj:()=>SXe,CoordinatesFromTrr:()=>xXe,CoordinatesFromXtc:()=>_Xe,CustomModelProperties:()=>Koe,CustomStructureProperties:()=>Qoe,ModelFromTrajectory:()=>qoe,MultiStructureSelectionFromExpression:()=>jXe,ShapeFromPly:()=>XXe,StructureComplexElement:()=>$Xe,StructureComplexElementTypes:()=>Xoe,StructureComponent:()=>YXe,StructureFromModel:()=>VXe,StructureFromTrajectory:()=>UXe,StructureSelectionFromBundle:()=>qXe,StructureSelectionFromExpression:()=>GXe,StructureSelectionFromScript:()=>HXe,TopologyFromPrmtop:()=>wXe,TopologyFromPsf:()=>CXe,TopologyFromTop:()=>AXe,TrajectoryFromBlob:()=>TXe,TrajectoryFromCifCore:()=>BXe,TrajectoryFromCube:()=>FXe,TrajectoryFromGRO:()=>PXe,TrajectoryFromMOL:()=>RXe,TrajectoryFromMOL2:()=>NXe,TrajectoryFromMmCif:()=>DXe,TrajectoryFromModelAndCoordinates:()=>I6,TrajectoryFromPDB:()=>EXe,TrajectoryFromSDF:()=>kXe,TrajectoryFromXYZ:()=>MXe,TransformStructureConformation:()=>zXe});var $P={};Fn.r($P),Fn.d($P,{AssignColorVolume:()=>cKe,VolumeFromCcp4:()=>nKe,VolumeFromCube:()=>iKe,VolumeFromDensityServerCif:()=>sKe,VolumeFromDsn6:()=>rKe,VolumeFromDx:()=>oKe,VolumeFromSegmentationCif:()=>aKe});var YP={};Fn.r(YP),Fn.d(YP,{BoxShape3D:()=>Fet,getBoxMesh:()=>g8});var XP={};Fn.r(XP),Fn.d(XP,{ClippingStructureRepresentation3DFromBundle:()=>Jet,ClippingStructureRepresentation3DFromScript:()=>Qet,ExplodeStructureRepresentation3D:()=>Het,ModelUnitcell3D:()=>rtt,OverpaintStructureRepresentation3DFromBundle:()=>$et,OverpaintStructureRepresentation3DFromScript:()=>Wet,ShapeRepresentation3D:()=>ntt,SpinStructureRepresentation3D:()=>qet,StructureBoundingBox3D:()=>itt,StructureRepresentation3D:()=>vE,StructureSelectionsAngle3D:()=>stt,StructureSelectionsDihedral3D:()=>att,StructureSelectionsDistance3D:()=>ott,StructureSelectionsLabel3D:()=>ctt,StructureSelectionsOrientation3D:()=>utt,StructureSelectionsPlane3D:()=>ltt,SubstanceStructureRepresentation3DFromBundle:()=>Zet,SubstanceStructureRepresentation3DFromScript:()=>Ket,ThemeStrengthRepresentation3D:()=>ett,TransparencyStructureRepresentation3DFromBundle:()=>Xet,TransparencyStructureRepresentation3DFromScript:()=>Yet,UnwindStructureAssemblyRepresentation3D:()=>jet,VolumeRepresentation3D:()=>ttt,VolumeRepresentation3DHelpers:()=>Af});var KP={};Fn.r(KP),Fn.d(KP,{ApplyAction:()=>Vce,ClearHighlights:()=>qce,Highlight:()=>Hce,RemoveObject:()=>zce,SetCurrentObject:()=>Lce,Snapshots:()=>Wce,SyncBehaviors:()=>Oce,ToggleExpanded:()=>Gce,ToggleVisibility:()=>jce,Update:()=>Uce,registerDefault:()=>Ttt,setSubtreeVisibility:()=>qv});var ZP={};Fn.r(ZP),Fn.d(ZP,{SyncRepresentationToCanvas:()=>$ce,SyncStructureRepresentation3DState:()=>Yce,UpdateRepresentationVisibility:()=>Xce,registerDefault:()=>Ett});var QP={};Fn.r(QP),Fn.d(QP,{Focus:()=>Qce,OrientAxes:()=>Jce,Reset:()=>Kce,ResetAxes:()=>eue,SetSnapshot:()=>Zce,registerDefault:()=>Ptt});var JP={};Fn.r(JP),Fn.d(JP,{Canvas3DSetSettings:()=>Zue,registerDefault:()=>Nit});var eM={};Fn.r(eM),Fn.d(eM,{DefaultFocusLociBindings:()=>Jue,DefaultLociLabelProvider:()=>Vit,DefaultSelectLociBindings:()=>Que,FocusLoci:()=>Git,HighlightLoci:()=>Oit,SelectLoci:()=>Uit});var tM={};Fn.r(tM),Fn.d(tM,{CameraAxisHelper:()=>qit,CameraControls:()=>$it,DefaultClickResetCameraOnEmpty:()=>W8,DefaultClickResetCameraOnEmptySelectMode:()=>$8,DefaultFocusLociBindings:()=>ele,FocusLoci:()=>Hit});var nM={};Fn.r(nM),Fn.d(nM,{AccessibleSurfaceArea:()=>rot,BestDatabaseSequenceMapping:()=>gct,CrossLinkRestraint:()=>Rct,Interactions:()=>dct,SecondaryStructure:()=>fct,StructureInfo:()=>Yit,ValenceModel:()=>pct});var rM={};Fn.r(rM),Fn.d(rM,{AddTrajectory:()=>gut,DownloadStructure:()=>uut,EnableModelCustomProps:()=>hut,EnableStructureCustomProps:()=>mut,LoadTrajectory:()=>yut,PdbDownloadProvider:()=>Dde,UpdateTrajectory:()=>put});var iM={};Fn.r(iM),Fn.d(iM,{AssignColorVolume:()=>Ede,DownloadDensity:()=>but});var oM={};function iG(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(u){return void n(u)}a.done?t(c):Promise.resolve(c).then(r,i)}function ie(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function s(c){iG(o,r,i,s,a,"next",c)}function a(c){iG(o,r,i,s,a,"throw",c)}s(void 0)})}}Fn.r(oM),Fn.d(oM,{DownloadFile:()=>vut,OpenFiles:()=>Pde});let xs=null,KC=1;const tg=Symbol("SIGNAL");function sr(e){const t=xs;return xs=e,t}function oG(e){if((!o_(e)||e.dirty)&&(e.dirty||e.lastCleanEpoch!==KC)){if(!e.producerMustRecompute(e)&&!aM(e))return e.dirty=!1,void(e.lastCleanEpoch=KC);e.producerRecomputeValue(e),e.dirty=!1,e.lastCleanEpoch=KC}}function aM(e){gy(e);for(let t=0;t0}function gy(e){e.producerNode??=[],e.producerIndexOfThis??=[],e.producerLastReadVersion??=[]}let hG=null;function Wi(e){return"function"==typeof e}function uM(e){const n=e(r=>{Error.call(r),r.stack=(new Error).stack});return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}const lM=uM(e=>function(n){e(this),this.message=n?`${n.length} errors occurred during unsubscription:\n${n.map((r,i)=>`${i+1}) ${r.toString()}`).join("\n ")}`:"",this.name="UnsubscriptionError",this.errors=n});function QC(e,t){if(e){const n=e.indexOf(t);0<=n&&e.splice(n,1)}}class Fa{constructor(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}unsubscribe(){let t;if(!this.closed){this.closed=!0;const{_parentage:n}=this;if(n)if(this._parentage=null,Array.isArray(n))for(const o of n)o.remove(this);else n.remove(this);const{initialTeardown:r}=this;if(Wi(r))try{r()}catch(o){t=o instanceof lM?o.errors:[o]}const{_finalizers:i}=this;if(i){this._finalizers=null;for(const o of i)try{vG(o)}catch(s){t=t??[],s instanceof lM?t=[...t,...s.errors]:t.push(s)}}if(t)throw new lM(t)}}add(t){var n;if(t&&t!==this)if(this.closed)vG(t);else{if(t instanceof Fa){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}}_hasParent(t){const{_parentage:n}=this;return n===t||Array.isArray(n)&&n.includes(t)}_addParent(t){const{_parentage:n}=this;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t}_removeParent(t){const{_parentage:n}=this;n===t?this._parentage=null:Array.isArray(n)&&QC(n,t)}remove(t){const{_finalizers:n}=this;n&&QC(n,t),t instanceof Fa&&t._removeParent(this)}}Fa.EMPTY=(()=>{const e=new Fa;return e.closed=!0,e})();const yG=Fa.EMPTY;function bG(e){return e instanceof Fa||e&&"closed"in e&&Wi(e.remove)&&Wi(e.add)&&Wi(e.unsubscribe)}function vG(e){Wi(e)?e():e.unsubscribe()}const ng={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},JC={setTimeout(e,t,...n){const{delegate:r}=JC;return r?.setTimeout?r.setTimeout(e,t,...n):setTimeout(e,t,...n)},clearTimeout(e){const{delegate:t}=JC;return(t?.clearTimeout||clearTimeout)(e)},delegate:void 0};function _G(e){JC.setTimeout(()=>{const{onUnhandledError:t}=ng;if(!t)throw e;t(e)})}function dM(){}const y0e=fM("C",void 0,void 0);function fM(e,t,n){return{kind:e,value:t,error:n}}let rg=null;function ew(e){if(ng.useDeprecatedSynchronousErrorHandling){const t=!rg;if(t&&(rg={errorThrown:!1,error:null}),e(),t){const{errorThrown:n,error:r}=rg;if(rg=null,n)throw r}}else e()}class pM extends Fa{constructor(t){super(),this.isStopped=!1,t?(this.destination=t,bG(t)&&t.add(this)):this.destination=w0e}static create(t,n,r){return new s_(t,n,r)}next(t){this.isStopped?mM(function v0e(e){return fM("N",e,void 0)}(t),this):this._next(t)}error(t){this.isStopped?mM(function b0e(e){return fM("E",void 0,e)}(t),this):(this.isStopped=!0,this._error(t))}complete(){this.isStopped?mM(y0e,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()}}}const x0e=Function.prototype.bind;function hM(e,t){return x0e.call(e,t)}class S0e{constructor(t){this.partialObserver=t}next(t){const{partialObserver:n}=this;if(n.next)try{n.next(t)}catch(r){tw(r)}}error(t){const{partialObserver:n}=this;if(n.error)try{n.error(t)}catch(r){tw(r)}else tw(t)}complete(){const{partialObserver:t}=this;if(t.complete)try{t.complete()}catch(n){tw(n)}}}class s_ extends pM{constructor(t,n,r){let i;if(super(),Wi(t)||!t)i={next:t??void 0,error:n??void 0,complete:r??void 0};else{let o;this&&ng.useDeprecatedNextContext?(o=Object.create(t),o.unsubscribe=()=>this.unsubscribe(),i={next:t.next&&hM(t.next,o),error:t.error&&hM(t.error,o),complete:t.complete&&hM(t.complete,o)}):i=t}this.destination=new S0e(i)}}function tw(e){ng.useDeprecatedSynchronousErrorHandling?function _0e(e){ng.useDeprecatedSynchronousErrorHandling&&rg&&(rg.errorThrown=!0,rg.error=e)}(e):_G(e)}function mM(e,t){const{onStoppedNotification:n}=ng;n&&JC.setTimeout(()=>n(e,t))}const w0e={closed:!0,next:dM,error:function C0e(e){throw e},complete:dM},gM="function"==typeof Symbol&&Symbol.observable||"@@observable";function vh(e){return e}function xG(...e){return SG(e)}function SG(e){return 0===e.length?vh:1===e.length?e[0]:function(n){return e.reduce((r,i)=>i(r),n)}}let ns=(()=>{class e{constructor(n){n&&(this._subscribe=n)}lift(n){const r=new e;return r.source=this,r.operator=n,r}subscribe(n,r,i){const o=function I0e(e){return e&&e instanceof pM||function A0e(e){return e&&Wi(e.next)&&Wi(e.error)&&Wi(e.complete)}(e)&&bG(e)}(n)?n:new s_(n,r,i);return ew(()=>{const{operator:s,source:a}=this;o.add(s?s.call(o,a):a?this._subscribe(o):this._trySubscribe(o))}),o}_trySubscribe(n){try{return this._subscribe(n)}catch(r){n.error(r)}}forEach(n,r){return new(r=CG(r))((i,o)=>{const s=new s_({next:a=>{try{n(a)}catch(c){o(c),s.unsubscribe()}},error:o,complete:i});this.subscribe(s)})}_subscribe(n){var r;return null===(r=this.source)||void 0===r?void 0:r.subscribe(n)}[gM](){return this}pipe(...n){return SG(n)(this)}toPromise(n){return new(n=CG(n))((r,i)=>{let o;this.subscribe(s=>o=s,s=>i(s),()=>r(o))})}}return e.create=t=>new e(t),e})();function CG(e){var t;return null!==(t=e??ng.Promise)&&void 0!==t?t:Promise}const T0e=uM(e=>function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"});let mr=(()=>{class e extends ns{constructor(){super(),this.closed=!1,this.currentObservers=null,this.observers=[],this.isStopped=!1,this.hasError=!1,this.thrownError=null}lift(n){const r=new wG(this,this);return r.operator=n,r}_throwIfClosed(){if(this.closed)throw new T0e}next(n){ew(()=>{if(this._throwIfClosed(),!this.isStopped){this.currentObservers||(this.currentObservers=Array.from(this.observers));for(const r of this.currentObservers)r.next(n)}})}error(n){ew(()=>{if(this._throwIfClosed(),!this.isStopped){this.hasError=this.isStopped=!0,this.thrownError=n;const{observers:r}=this;for(;r.length;)r.shift().error(n)}})}complete(){ew(()=>{if(this._throwIfClosed(),!this.isStopped){this.isStopped=!0;const{observers:n}=this;for(;n.length;)n.shift().complete()}})}unsubscribe(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null}get observed(){var n;return(null===(n=this.observers)||void 0===n?void 0:n.length)>0}_trySubscribe(n){return this._throwIfClosed(),super._trySubscribe(n)}_subscribe(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)}_innerSubscribe(n){const{hasError:r,isStopped:i,observers:o}=this;return r||i?yG:(this.currentObservers=null,o.push(n),new Fa(()=>{this.currentObservers=null,QC(o,n)}))}_checkFinalizedStatuses(n){const{hasError:r,thrownError:i,isStopped:o}=this;r?n.error(i):o&&n.complete()}asObservable(){const n=new ns;return n.source=this,n}}return e.create=(t,n)=>new wG(t,n),e})();class wG extends mr{constructor(t,n){super(),this.destination=t,this.source=n}next(t){var n,r;null===(r=null===(n=this.destination)||void 0===n?void 0:n.next)||void 0===r||r.call(n,t)}error(t){var n,r;null===(r=null===(n=this.destination)||void 0===n?void 0:n.error)||void 0===r||r.call(n,t)}complete(){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===n||n.call(t)}_subscribe(t){var n,r;return null!==(r=null===(n=this.source)||void 0===n?void 0:n.subscribe(t))&&void 0!==r?r:yG}}class Ao extends mr{constructor(t){super(),this._value=t}get value(){return this.getValue()}_subscribe(t){const n=super._subscribe(t);return!n.closed&&t.next(this._value),n}getValue(){const{hasError:t,thrownError:n,_value:r}=this;if(t)throw n;return this._throwIfClosed(),r}next(t){super.next(this._value=t)}}function AG(e){return Wi(e?.lift)}function mo(e){return t=>{if(AG(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function Io(e,t,n,r,i){return new D0e(e,t,n,r,i)}class D0e extends pM{constructor(t,n,r,i,o,s){super(t),this.onFinalize=o,this.shouldUnsubscribe=s,this._next=n?function(a){try{n(a)}catch(c){t.error(c)}}:super._next,this._error=i?function(a){try{i(a)}catch(c){t.error(c)}finally{this.unsubscribe()}}:super._error,this._complete=r?function(){try{r()}catch(a){t.error(a)}finally{this.unsubscribe()}}:super._complete}unsubscribe(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){const{closed:n}=this;super.unsubscribe(),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}}}function qt(e,t){return mo((n,r)=>{let i=0;n.subscribe(Io(r,o=>{r.next(e.call(t,o,i++))}))})}const IG="https://g.co/ng/security#xss";class It extends Error{constructor(t,n){super(function yy(e,t){return`NG0${Math.abs(e)}${t?": "+t:""}`}(t,n)),this.code=t}}function jf(e){return{toString:e}.toString()}const vy="__parameters__";function xy(e,t,n){return jf(()=>{const r=function yM(e){return function(...n){if(e){const r=e(...n);for(const i in r)this[i]=r[i]}}}(t);function i(...o){if(this instanceof i)return r.apply(this,o),this;const s=new i(...o);return a.annotation=s,a;function a(c,u,l){const d=c.hasOwnProperty(vy)?c[vy]:Object.defineProperty(c,vy,{value:[]})[vy];for(;d.length<=l;)d.push(null);return(d[l]=d[l]||[]).push(s),c}}return n&&(i.prototype=Object.create(n.prototype)),i.prototype.ngMetadataName=e,i.annotationCls=i,i})}const si=globalThis;function pi(e){for(let t in e)if(e[t]===pi)return t;throw Error("Could not find renamed property on target object.")}function Ss(e){if("string"==typeof e)return e;if(Array.isArray(e))return"["+e.map(Ss).join(", ")+"]";if(null==e)return""+e;if(e.overriddenName)return`${e.overriddenName}`;if(e.name)return`${e.name}`;const t=e.toString();if(null==t)return""+t;const n=t.indexOf("\n");return-1===n?t:t.substring(0,n)}function bM(e,t){return null==e||""===e?null===t?"":t:null==t||""===t?e:e+" "+t}const P0e=pi({__forward_ref__:pi});function vM(e){return e.__forward_ref__=vM,e.toString=function(){return Ss(this())},e}function En(e){return rw(e)?e():e}function rw(e){return"function"==typeof e&&e.hasOwnProperty(P0e)&&e.__forward_ref__===vM}function Gt(e){return{token:e.token,providedIn:e.providedIn||null,factory:e.factory,value:void 0}}function Sy(e){return{providers:e.providers||[],imports:e.imports||[]}}function iw(e){return PG(e,sw)||PG(e,MG)}function PG(e,t){return e.hasOwnProperty(t)?e[t]:null}function ow(e){return e&&(e.hasOwnProperty(_M)||e.hasOwnProperty(B0e))?e[_M]:null}const sw=pi({\u0275prov:pi}),_M=pi({\u0275inj:pi}),MG=pi({ngInjectableDef:pi}),B0e=pi({ngInjectorDef:pi});class Yt{constructor(t,n){this._desc=t,this.ngMetadataName="InjectionToken",this.\u0275prov=void 0,"number"==typeof n?this.__NG_ELEMENT_ID__=n:void 0!==n&&(this.\u0275prov=Gt({token:this,providedIn:n.providedIn||"root",factory:n.factory}))}get multi(){return this}toString(){return`InjectionToken ${this._desc}`}}function AM(e){return e&&!!e.\u0275providers}const a_=pi({\u0275cmp:pi}),IM=pi({\u0275dir:pi}),TM=pi({\u0275pipe:pi}),kG=pi({\u0275mod:pi}),Hf=pi({\u0275fac:pi}),c_=pi({__NG_ELEMENT_ID__:pi}),NG=pi({__NG_ENV_ID__:pi});function Un(e){return"string"==typeof e?e:null==e?"":String(e)}function DM(e,t){throw new It(-201,!1)}var yr=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}(yr||{});let EM;function FG(){return EM}function bc(e){const t=EM;return EM=e,t}function BG(e,t,n){const r=iw(e);return r&&"root"==r.providedIn?void 0===r.value?r.value=r.factory():r.value:n&yr.Optional?null:void 0!==t?t:void DM()}const u_={},PM="__NG_DI_FLAG__",aw="ngTempTokenPath",G0e=/\n/gm,OG="__source";let Cy;function xh(e){const t=Cy;return Cy=e,t}function q0e(e,t=yr.Default){if(void 0===Cy)throw new It(-203,!1);return null===Cy?BG(e,void 0,t):Cy.get(e,t&yr.Optional?null:void 0,t)}function Zt(e,t=yr.Default){return(FG()||q0e)(En(e),t)}function bt(e,t=yr.Default){return Zt(e,cw(t))}function cw(e){return typeof e>"u"||"number"==typeof e?e:(e.optional&&8)|(e.host&&1)|(e.self&&2)|(e.skipSelf&&4)}function MM(e){const t=[];for(let n=0;nArray.isArray(n)?wy(n,t):t(n))}function UG(e,t,n){t>=e.length?e.push(n):e.splice(t,0,n)}function dw(e,t){return t>=e.length-1?e.pop():e.splice(t,1)[0]}function Xc(e,t,n){let r=Ay(e,t);return r>=0?e[1|r]=n:(r=~r,function VG(e,t,n,r){let i=e.length;if(i==t)e.push(n,r);else if(1===i)e.push(r,e[0]),e[0]=n;else{for(i--,e.push(e[i-1],e[i]);i>t;)e[i]=e[i-2],i--;e[t]=n,e[t+1]=r}}(e,r,t,n)),r}function kM(e,t){const n=Ay(e,t);if(n>=0)return e[1|n]}function Ay(e,t){return function zG(e,t,n){let r=0,i=e.length>>n;for(;i!==r;){const o=r+(i-r>>1),s=e[o<t?i=o:r=o+1}return~(i<t){s=o-1;break}}}for(;o-1){let o;for(;++io?"":i[l+1].toLowerCase(),2&r&&u!==d){if(Ol(r))return!1;s=!0}}}}else{if(!s&&!Ol(r)&&!Ol(c))return!1;if(s&&Ol(c))continue;s=!1,r=c|1&r}}return Ol(r)||s}function Ol(e){return!(1&e)}function rye(e,t,n,r){if(null===t)return-1;let i=0;if(r||!n){let o=!1;for(;i-1)for(n++;n0?'="'+a+'"':"")+"]"}else 8&r?i+="."+s:4&r&&(i+=" "+s);else""!==i&&!Ol(s)&&(t+=YG(o,i),i=""),r=s,o=o||!Ol(r);n++}return""!==i&&(t+=YG(o,i)),t}function Mu(e){return jf(()=>{const t=KG(e),n={...t,decls:e.decls,vars:e.vars,template:e.template,consts:e.consts||null,ngContentSelectors:e.ngContentSelectors,onPush:e.changeDetection===hw.OnPush,directiveDefs:null,pipeDefs:null,dependencies:t.standalone&&e.dependencies||null,getStandaloneInjector:null,signals:e.signals??!1,data:e.data||{},encapsulation:e.encapsulation||Fl.Emulated,styles:e.styles||Vr,_:null,schemas:e.schemas||null,tView:null,id:""};ZG(n);const r=e.dependencies;return n.directiveDefs=mw(r,!1),n.pipeDefs=mw(r,!0),n.id=function hye(e){let t=0;const n=[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(const i of n)t=Math.imul(31,t)+i.charCodeAt(0)|0;return t+=2147483648,"c"+t}(n),n})}function dye(e){return dr(e)||Cs(e)}function fye(e){return null!==e}function f_(e){return jf(()=>({type:e.type,bootstrap:e.bootstrap||Vr,declarations:e.declarations||Vr,imports:e.imports||Vr,exports:e.exports||Vr,transitiveCompileScopes:null,schemas:e.schemas||null,id:e.id||null}))}function XG(e,t){if(null==e)return Pd;const n={};for(const r in e)if(e.hasOwnProperty(r)){const i=e[r];let o,s,a=Bl.None;Array.isArray(i)?(a=i[0],o=i[1],s=i[2]??o):(o=i,s=i),t?(n[o]=a!==Bl.None?[r,a]:r,t[o]=s):n[o]=r}return n}function Ba(e){return jf(()=>{const t=KG(e);return ZG(t),t})}function _c(e){return{type:e.type,name:e.name,factory:null,pure:!1!==e.pure,standalone:!0===e.standalone,onDestroy:e.type.prototype.ngOnDestroy||null}}function dr(e){return e[a_]||null}function Cs(e){return e[IM]||null}function Qs(e){return e[TM]||null}function sa(e,t){const n=e[kG]||null;if(!n&&!0===t)throw new Error(`Type ${Ss(e)} does not have '\u0275mod' property.`);return n}function KG(e){const 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||Pd,exportAs:e.exportAs||null,standalone:!0===e.standalone,signals:!0===e.signals,selectors:e.selectors||Vr,viewQuery:e.viewQuery||null,features:e.features||null,setInput:null,findHostDirectiveDefs:null,hostDirectives:null,inputs:XG(e.inputs,t),outputs:XG(e.outputs),debugInfo:null}}function ZG(e){e.features?.forEach(t=>t(e))}function mw(e,t){if(!e)return null;const n=t?Qs:dye;return()=>("function"==typeof e?e():e).map(r=>n(r)).filter(fye)}function Iy(e){return{\u0275providers:e}}function mye(...e){return{\u0275providers:OM(0,e),\u0275fromNgModule:!0}}function OM(e,...t){const n=[],r=new Set;let i;const o=s=>{n.push(s)};return wy(t,s=>{const a=s;gw(a,o,[],r)&&(i||=[],i.push(a))}),void 0!==i&&QG(i,o),n}function QG(e,t){for(let n=0;n{t(o,r)})}}function gw(e,t,n,r){if(!(e=En(e)))return!1;let i=null,o=ow(e);const s=!o&&dr(e);if(o||s){if(s&&!s.standalone)return!1;i=e}else{const c=e.ngModule;if(o=ow(c),!o)return!1;i=c}const a=r.has(i);if(s){if(a)return!1;if(r.add(i),s.dependencies){const c="function"==typeof s.dependencies?s.dependencies():s.dependencies;for(const u of c)gw(u,t,n,r)}}else{if(!o)return!1;{if(null!=o.imports&&!a){let u;r.add(i);try{wy(o.imports,l=>{gw(l,t,n,r)&&(u||=[],u.push(l))})}finally{}void 0!==u&&QG(u,t)}if(!a){const u=ig(i)||(()=>new i);t({provide:i,useFactory:u,deps:Vr},i),t({provide:NM,useValue:i,multi:!0},i),t({provide:og,useValue:()=>Zt(i),multi:!0},i)}const c=o.providers;if(null!=c&&!a){const u=e;LM(c,l=>{t(l,u)})}}}return i!==e&&void 0!==e.providers}function LM(e,t){for(let n of e)AM(n)&&(n=n.\u0275providers),Array.isArray(n)?LM(n,t):t(n)}const gye=pi({provide:String,useValue:pi});function UM(e){return null!==e&&"object"==typeof e&&gye in e}function sg(e){return"function"==typeof e}const VM=new Yt(""),yw={},bye={};let zM;function bw(){return void 0===zM&&(zM=new pw),zM}class xc{}class Ty extends xc{get destroyed(){return this._destroyed}constructor(t,n,r,i){super(),this.parent=n,this.source=r,this.scopes=i,this.records=new Map,this._ngOnDestroyHooks=new Set,this._onDestroyHooks=[],this._destroyed=!1,jM(t,s=>this.processProvider(s)),this.records.set(GG,Dy(void 0,this)),i.has("environment")&&this.records.set(xc,Dy(void 0,this));const o=this.records.get(VM);null!=o&&"string"==typeof o.value&&this.scopes.add(o.value),this.injectorDefTypes=new Set(this.get(NM,Vr,yr.Self))}destroy(){this.assertNotDestroyed(),this._destroyed=!0;const t=sr(null);try{for(const r of this._ngOnDestroyHooks)r.ngOnDestroy();const n=this._onDestroyHooks;this._onDestroyHooks=[];for(const r of n)r()}finally{this.records.clear(),this._ngOnDestroyHooks.clear(),this.injectorDefTypes.clear(),sr(t)}}onDestroy(t){return this.assertNotDestroyed(),this._onDestroyHooks.push(t),()=>this.removeOnDestroy(t)}runInContext(t){this.assertNotDestroyed();const n=xh(this),r=bc(void 0);try{return t()}finally{xh(n),bc(r)}}get(t,n=u_,r=yr.Default){if(this.assertNotDestroyed(),t.hasOwnProperty(NG))return t[NG](this);r=cw(r);const o=xh(this),s=bc(void 0);try{if(!(r&yr.SkipSelf)){let c=this.records.get(t);if(void 0===c){const u=function Cye(e){return"function"==typeof e||"object"==typeof e&&e instanceof Yt}(t)&&iw(t);c=u&&this.injectableDefInScope(u)?Dy(GM(t),yw):null,this.records.set(t,c)}if(null!=c)return this.hydrate(t,c)}return(r&yr.Self?bw():this.parent).get(t,n=r&yr.Optional&&n===u_?null:n)}catch(a){if("NullInjectorError"===a.name){if((a[aw]=a[aw]||[]).unshift(Ss(t)),o)throw a;return function $0e(e,t,n,r){const i=e[aw];throw t[OG]&&i.unshift(t[OG]),e.message=function Y0e(e,t,n,r=null){e=e&&"\n"===e.charAt(0)&&"\u0275"==e.charAt(1)?e.slice(2):e;let i=Ss(t);if(Array.isArray(t))i=t.map(Ss).join(" -> ");else if("object"==typeof t){let o=[];for(let s in t)if(t.hasOwnProperty(s)){let a=t[s];o.push(s+":"+("string"==typeof a?JSON.stringify(a):Ss(a)))}i=`{${o.join(", ")}}`}return`${n}${r?"("+r+")":""}[${i}]: ${e.replace(G0e,"\n ")}`}("\n"+e.message,i,n,r),e.ngTokenPath=i,e[aw]=null,e}(a,t,"R3InjectorError",this.source)}throw a}finally{bc(s),xh(o)}}resolveInjectorInitializers(){const t=sr(null),n=xh(this),r=bc(void 0);try{const o=this.get(og,Vr,yr.Self);for(const s of o)s()}finally{xh(n),bc(r),sr(t)}}toString(){const t=[],n=this.records;for(const r of n.keys())t.push(Ss(r));return`R3Injector[${t.join(", ")}]`}assertNotDestroyed(){if(this._destroyed)throw new It(205,!1)}processProvider(t){let n=sg(t=En(t))?t:En(t&&t.provide);const r=function _ye(e){return UM(e)?Dy(void 0,e.useValue):Dy(t9(e),yw)}(t);if(!sg(t)&&!0===t.multi){let i=this.records.get(n);i||(i=Dy(void 0,yw,!0),i.factory=()=>MM(i.multi),this.records.set(n,i)),n=t,i.multi.push(t)}this.records.set(n,r)}hydrate(t,n){const r=sr(null);try{return n.value===yw&&(n.value=bye,n.value=n.factory()),"object"==typeof n.value&&n.value&&function Sye(e){return null!==e&&"object"==typeof e&&"function"==typeof e.ngOnDestroy}(n.value)&&this._ngOnDestroyHooks.add(n.value),n.value}finally{sr(r)}}injectableDefInScope(t){if(!t.providedIn)return!1;const n=En(t.providedIn);return"string"==typeof n?"any"===n||this.scopes.has(n):this.injectorDefTypes.has(n)}removeOnDestroy(t){const n=this._onDestroyHooks.indexOf(t);-1!==n&&this._onDestroyHooks.splice(n,1)}}function GM(e){const t=iw(e),n=null!==t?t.factory:ig(e);if(null!==n)return n;if(e instanceof Yt)throw new It(204,!1);if(e instanceof Function)return function vye(e){if(e.length>0)throw new It(204,!1);const n=function F0e(e){return e&&(e[sw]||e[MG])||null}(e);return null!==n?()=>n.factory(e):()=>new e}(e);throw new It(204,!1)}function t9(e,t,n){let r;if(sg(e)){const i=En(e);return ig(i)||GM(i)}if(UM(e))r=()=>En(e.useValue);else if(function e9(e){return!(!e||!e.useFactory)}(e))r=()=>e.useFactory(...MM(e.deps||[]));else if(function JG(e){return!(!e||!e.useExisting)}(e))r=()=>Zt(En(e.useExisting));else{const i=En(e&&(e.useClass||e.provide));if(!function xye(e){return!!e.deps}(e))return ig(i)||GM(i);r=()=>new i(...MM(e.deps))}return r}function Dy(e,t,n=!1){return{factory:e,value:t,multi:n?[]:void 0}}function jM(e,t){for(const n of e)Array.isArray(n)?jM(n,t):n&&AM(n)?jM(n.\u0275providers,t):t(n)}function Md(e,t){e instanceof Ty&&e.assertNotDestroyed();const r=xh(e),i=bc(void 0);try{return t()}finally{xh(r),bc(i)}}function n9(){return void 0!==FG()||null!=function H0e(){return Cy}()}const Ji=0,Mt=1,bn=2,zo=3,Ll=4,aa=5,Kc=6,Py=7,Mi=8,Js=9,Ul=10,Mn=11,h_=12,i9=13,My=14,go=15,m_=16,Ry=17,qf=18,g_=19,o9=20,Ch=21,xw=22,ag=23,Vn=25,qM=1,Rd=7,ky=9,Go=10;var WM=function(e){return e[e.None=0]="None",e[e.HasTransplantedViews=2]="HasTransplantedViews",e}(WM||{});function ca(e){return Array.isArray(e)&&"object"==typeof e[qM]}function ua(e){return Array.isArray(e)&&!0===e[qM]}function $M(e){return!!(4&e.flags)}function cg(e){return e.componentOffset>-1}function Cw(e){return!(1&~e.flags)}function Vl(e){return!!e.template}function YM(e){return!!(512&e[bn])}class Bye{constructor(t,n,r){this.previousValue=t,this.currentValue=n,this.firstChange=r}isFirstChange(){return this.firstChange}}function u9(e,t,n,r){null!==t?t.applyValueToInputSignal(t,r):e[n]=r}function wh(){return l9}function l9(e){return e.type.prototype.ngOnChanges&&(e.setInput=Lye),Oye}function Oye(){const e=f9(this),t=e?.current;if(t){const n=e.previous;if(n===Pd)e.previous=t;else for(let r in t)n[r]=t[r];e.current=null,this.ngOnChanges(t)}}function Lye(e,t,n,r,i){const o=this.declaredInputs[r],s=f9(e)||function Uye(e,t){return e[d9]=t}(e,{previous:Pd,current:null}),a=s.current||(s.current={}),c=s.previous,u=c[o];a[o]=new Bye(u&&u.currentValue,n,c===Pd),u9(e,t,i,n)}wh.ngInherit=!0;const d9="__ngSimpleChanges__";function f9(e){return e[d9]||null}const kd=function(e,t,n){};let m9=!1;function _i(e){for(;Array.isArray(e);)e=e[Ji];return e}function b_(e,t){return _i(t[e])}function Oa(e,t){return _i(t[e.index])}function v_(e,t){return e.data[t]}function Zc(e,t){const n=t[e];return ca(n)?n:n[Ji]}function JM(e){return!(128&~e[bn])}function Nd(e,t){return null==t?null:e[t]}function g9(e){e[Ry]=0}function qye(e){1024&e[bn]||(e[bn]|=1024,JM(e)&&__(e))}function eR(e){return!!(9216&e[bn]||e[ag]?.dirty)}function tR(e){e[Ul].changeDetectionScheduler?.notify(1),eR(e)?__(e):64&e[bn]&&(function zye(){return m9}()?(e[bn]|=1024,__(e)):e[Ul].changeDetectionScheduler?.notify())}function __(e){e[Ul].changeDetectionScheduler?.notify();let t=ug(e);for(;null!==t&&!(8192&t[bn])&&(t[bn]|=8192,JM(t));)t=ug(t)}function ww(e,t){if(!(256&~e[bn]))throw new It(911,!1);null===e[Ch]&&(e[Ch]=[]),e[Ch].push(t)}function ug(e){const t=e[zo];return ua(t)?t[zo]:t}const Rn={lFrame:I9(null),bindingsEnabled:!0,skipHydrationRootTNode:null};function v9(){return Rn.bindingsEnabled}function it(){return Rn.lFrame.lView}function br(){return Rn.lFrame.tView}function hi(){let e=_9();for(;null!==e&&64===e.type;)e=e.parent;return e}function _9(){return Rn.lFrame.currentTNode}function Fd(e,t){const n=Rn.lFrame;n.currentTNode=e,n.isParent=t}function rR(){return Rn.lFrame.isParent}function La(){const e=Rn.lFrame;let t=e.bindingRootIndex;return-1===t&&(t=e.bindingRootIndex=e.tView.bindingStartIndex),t}function zl(){return Rn.lFrame.bindingIndex++}function ibe(e,t){const n=Rn.lFrame;n.bindingIndex=n.bindingRootIndex=e,oR(t)}function oR(e){Rn.lFrame.currentDirectiveIndex=e}function aR(){return Rn.lFrame.currentQueryIndex}function Aw(e){Rn.lFrame.currentQueryIndex=e}function sbe(e){const t=e[Mt];return 2===t.type?t.declTNode:1===t.type?e[aa]:null}function w9(e,t,n){if(n&yr.SkipSelf){let i=t,o=e;for(;!(i=i.parent,null!==i||n&yr.Host||(i=sbe(o),null===i||(o=o[My],10&i.type))););if(null===i)return!1;t=i,e=o}const r=Rn.lFrame=A9();return r.currentTNode=t,r.lView=e,!0}function cR(e){const t=A9(),n=e[Mt];Rn.lFrame=t,t.currentTNode=n.firstChild,t.lView=e,t.tView=n,t.contextLView=e,t.bindingIndex=n.bindingStartIndex,t.inI18n=!1}function A9(){const e=Rn.lFrame,t=null===e?null:e.child;return null===t?I9(e):t}function I9(e){const 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 null!==e&&(e.child=t),t}function T9(){const e=Rn.lFrame;return Rn.lFrame=e.parent,e.currentTNode=null,e.lView=null,e}const D9=T9;function uR(){const e=T9();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 la(){return Rn.lFrame.selectedIndex}function lg(e){Rn.lFrame.selectedIndex=e}function Ri(){const e=Rn.lFrame;return v_(e.tView,e.selectedIndex)}let P9=!0;function S_(){return P9}function Bd(e){P9=e}function Iw(e,t){for(let n=t.directiveStart,r=t.directiveEnd;n=r)break}else t[c]<0&&(e[Ry]+=65536),(a>14>16&&(3&e[bn])===t&&(e[bn]+=16384,R9(a,o)):R9(a,o)}const By=-1;class C_{constructor(t,n,r){this.factory=t,this.resolving=!1,this.canSeeViewProviders=n,this.injectImpl=r}}function fR(e){return e!==By}function w_(e){return 32767&e}function A_(e,t){let n=function bbe(e){return e>>16}(e),r=t;for(;n>0;)r=r[My],n--;return r}let pR=!0;function Ew(e){const t=pR;return pR=e,t}const k9=255,N9=5;let vbe=0;const Od={};function Pw(e,t){const n=F9(e,t);if(-1!==n)return n;const r=t[Mt];r.firstCreatePass&&(e.injectorIndex=t.length,hR(r.data,e),hR(t,null),hR(r.blueprint,null));const i=Mw(e,t),o=e.injectorIndex;if(fR(i)){const s=w_(i),a=A_(i,t),c=a[Mt].data;for(let u=0;u<8;u++)t[o+u]=a[s+u]|c[s+u]}return t[o+8]=i,o}function hR(e,t){e.push(0,0,0,0,0,0,0,0,t)}function F9(e,t){return-1===e.injectorIndex||e.parent&&e.parent.injectorIndex===e.injectorIndex||null===t[e.injectorIndex+8]?-1:e.injectorIndex}function Mw(e,t){if(e.parent&&-1!==e.parent.injectorIndex)return e.parent.injectorIndex;let n=0,r=null,i=t;for(;null!==i;){if(r=G9(i),null===r)return By;if(n++,i=i[My],-1!==r.injectorIndex)return r.injectorIndex|n<<16}return By}function mR(e,t,n){!function _be(e,t,n){let r;"string"==typeof n?r=n.charCodeAt(0)||0:n.hasOwnProperty(c_)&&(r=n[c_]),null==r&&(r=n[c_]=vbe++);const i=r&k9;t.data[e+(i>>N9)]|=1<=0?t&k9:wbe:t}(n);if("function"==typeof o){if(!w9(t,e,r))return r&yr.Host?B9(i,0,r):O9(t,n,r,i);try{let s;if(s=o(r),null!=s||r&yr.Optional)return s;DM()}finally{D9()}}else if("number"==typeof o){let s=null,a=F9(e,t),c=By,u=r&yr.Host?t[go][aa]:null;for((-1===a||r&yr.SkipSelf)&&(c=-1===a?Mw(e,t):t[a+8],c!==By&&z9(r,!1)?(s=t[Mt],a=w_(c),t=A_(c,t)):a=-1);-1!==a;){const l=t[Mt];if(V9(o,a,l.data)){const d=Sbe(a,t,n,s,r,u);if(d!==Od)return d}c=t[a+8],c!==By&&z9(r,t[Mt].data[a+8]===u)&&V9(o,a,t)?(s=l,a=w_(c),t=A_(c,t)):a=-1}}return i}function Sbe(e,t,n,r,i,o){const s=t[Mt],a=s.data[e+8],l=Rw(a,s,n,null==r?cg(a)&&pR:r!=s&&!!(3&a.type),i&yr.Host&&o===a);return null!==l?dg(t,s,l,a):Od}function Rw(e,t,n,r,i){const o=e.providerIndexes,s=t.data,a=1048575&o,c=e.directiveStart,l=o>>20,f=i?a+l:e.directiveEnd;for(let p=r?a:a+l;p=c&&m.type===n)return p}if(i){const p=s[c];if(p&&Vl(p)&&p.type===n)return c}return null}function dg(e,t,n,r){let i=e[n];const o=t.data;if(function hbe(e){return e instanceof C_}(i)){const s=i;s.resolving&&function U0e(e,t){throw t&&t.join(" > "),new It(-200,e)}(function Zr(e){return"function"==typeof e?e.name||e.toString():"object"==typeof e&&null!=e&&"function"==typeof e.type?e.type.name||e.type.toString():Un(e)}(o[n]));const a=Ew(s.canSeeViewProviders);s.resolving=!0;const u=s.injectImpl?bc(s.injectImpl):null;w9(e,r,yr.Default);try{i=e[n]=s.factory(void 0,o,e,r),t.firstCreatePass&&n>=r.directiveStart&&function fbe(e,t,n){const{ngOnChanges:r,ngOnInit:i,ngDoCheck:o}=t.type.prototype;if(r){const s=l9(t);(n.preOrderHooks??=[]).push(e,s),(n.preOrderCheckHooks??=[]).push(e,s)}i&&(n.preOrderHooks??=[]).push(0-e,i),o&&((n.preOrderHooks??=[]).push(e,o),(n.preOrderCheckHooks??=[]).push(e,o))}(n,o[n],t)}finally{null!==u&&bc(u),Ew(a),s.resolving=!1,D9()}}return i}function V9(e,t,n){return!!(n[t+(e>>N9)]&1<{const t=e.prototype.constructor,n=t[Hf]||yR(t),r=Object.prototype;let i=Object.getPrototypeOf(e.prototype).constructor;for(;i&&i!==r;){const o=i[Hf]||yR(i);if(o&&o!==n)return o;i=Object.getPrototypeOf(i)}return o=>new o})}function yR(e){return rw(e)?()=>{const t=yR(En(e));return t&&t()}:ig(e)}function G9(e){const t=e[Mt],n=t.type;return 2===n?t.declTNode:1===n?e[aa]:null}function $9(e,t=null,n=null,r){const i=Y9(e,t,n,r);return i.resolveInjectorInitializers(),i}function Y9(e,t=null,n=null,r,i=new Set){const o=[n||Vr,mye(e)];return r=r||("object"==typeof e?void 0:Ss(e)),new Ty(o,t||bw(),r||null,i)}let Sc=(()=>{class e{static#e=this.THROW_IF_NOT_FOUND=u_;static#t=this.NULL=new pw;static create(n,r){if(Array.isArray(n))return $9({name:""},r,n,"");{const i=n.name??"";return $9({name:i},n.parent,n.providers,i)}}static#n=this.\u0275prov=Gt({token:e,providedIn:"any",factory:()=>Zt(GG)});static#r=this.__NG_ELEMENT_ID__=-1}return e})();function vR(e){return e.ngOriginalError}class Ld{constructor(){this._console=console}handleError(t){const n=this._findOriginalError(t);this._console.error("ERROR",t),n&&this._console.error("ORIGINAL ERROR",n)}_findOriginalError(t){let n=t&&vR(t);for(;n&&vR(n);)n=vR(n);return n||null}}const K9=new Yt("",{providedIn:"root",factory:()=>bt(Ld).handleError.bind(void 0)});let Uy=(()=>{class e{static#e=this.__NG_ELEMENT_ID__=Nbe;static#t=this.__NG_ENV_ID__=n=>n}return e})();class kbe extends Uy{constructor(t){super(),this._lView=t}onDestroy(t){return ww(this._lView,t),()=>function nR(e,t){if(null===e[Ch])return;const n=e[Ch].indexOf(t);-1!==n&&e[Ch].splice(n,1)}(this._lView,t)}}function Nbe(){return new kbe(it())}function Fbe(){return Vy(hi(),it())}function Vy(e,t){return new Ah(Oa(e,t))}let Ah=(()=>{class e{constructor(n){this.nativeElement=n}static#e=this.__NG_ELEMENT_ID__=Fbe}return e})();function Q9(e){return e instanceof Ah?e.nativeElement:e}function _R(e){return t=>{setTimeout(e,void 0,t)}}const Ua=class Bbe extends mr{constructor(t=!1){super(),this.destroyRef=void 0,this.__isAsync=t,n9()&&(this.destroyRef=bt(Uy,{optional:!0})??void 0)}emit(t){const n=sr(null);try{super.next(t)}finally{sr(n)}}subscribe(t,n,r){let i=t,o=n||(()=>null),s=r;if(t&&"object"==typeof t){const c=t;i=c.next?.bind(c),o=c.error?.bind(c),s=c.complete?.bind(c)}this.__isAsync&&(o=_R(o),i&&(i=_R(i)),s&&(s=_R(s)));const a=super.subscribe({next:i,error:o,complete:s});return t instanceof Fa&&t.add(a),a}};function Obe(){return this._results[Symbol.iterator]()}class xR{static#e=Symbol.iterator;get changes(){return this._changes??=new Ua}constructor(t=!1){this._emitDistinctChangesOnly=t,this.dirty=!0,this._onDirty=void 0,this._results=[],this._changesDetected=!1,this._changes=void 0,this.length=0,this.first=void 0,this.last=void 0;const n=xR.prototype;n[Symbol.iterator]||(n[Symbol.iterator]=Obe)}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,n){return this._results.reduce(t,n)}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,n){this.dirty=!1;const r=function vc(e){return e.flat(Number.POSITIVE_INFINITY)}(t);(this._changesDetected=!function Q0e(e,t,n){if(e.length!==t.length)return!1;for(let r=0;rove}),ove="ng",bj=new Yt(""),Th=new Yt("",{providedIn:"platform",factory:()=>"unknown"}),vj=new Yt("",{providedIn:"root",factory:()=>function Ih(){if(void 0!==AR)return AR;if(typeof document<"u")return document;throw new It(210,!1)}().body?.querySelector("[ngCspNonce]")?.getAttribute("ngCspNonce")||null});let _j=()=>null;function NR(e,t,n=!1){return _j(e,t,n)}const Aj=new Yt("",{providedIn:"root",factory:()=>!1});let Hw;function Ej(e){return function UR(){if(void 0===Hw&&(Hw=null,si.trustedTypes))try{Hw=si.trustedTypes.createPolicy("angular#unsafe-bypass",{createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e})}catch{}return Hw}()?.createScriptURL(e)||e}class Pj{constructor(t){this.changingThisBreaksApplicationSecurity=t}toString(){return`SafeValue must use [property]=binding: ${this.changingThisBreaksApplicationSecurity} (see ${IG})`}}function Dh(e){return e instanceof Pj?e.changingThisBreaksApplicationSecurity:e}function k_(e,t){const n=function wve(e){return e instanceof Pj&&e.getTypeName()||null}(e);if(null!=n&&n!==t){if("ResourceURL"===n&&"URL"===t)return!0;throw new Error(`Required a safe ${t}, got a ${n} (see ${IG})`)}return n===t}const Dve=/^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:\/?#]*(?:[\/?#]|$))/i;var Hy=function(e){return e[e.NONE=0]="NONE",e[e.HTML=1]="HTML",e[e.STYLE=2]="STYLE",e[e.SCRIPT=3]="SCRIPT",e[e.URL=4]="URL",e[e.RESOURCE_URL=5]="RESOURCE_URL",e}(Hy||{});function Uj(e){const t=F_();return t?t.sanitize(Hy.URL,e)||"":k_(e,"URL")?Dh(e):function VR(e){return(e=String(e)).match(Dve)?e:"unsafe:"+e}(Un(e))}function Vj(e){const t=F_();if(t)return Ej(t.sanitize(Hy.RESOURCE_URL,e)||"");if(k_(e,"ResourceURL"))return Ej(Dh(e));throw new It(904,!1)}function F_(){const e=it();return e&&e[Ul].sanitizer}function qj(e){return e.ownerDocument.defaultView}function Qc(e){return e instanceof Function?e():e}var Ph=function(e){return e[e.Important=1]="Important",e[e.DashCase=2]="DashCase",e}(Ph||{});let $R;function YR(e,t){return $R(e,t)}function Wy(e,t,n,r,i){if(null!=r){let o,s=!1;ua(r)?o=r:ca(r)&&(s=!0,r=r[Ji]);const a=_i(r);0===e&&null!==n?null==i?eH(t,n,a):fg(t,n,a,i||null,!0):1===e&&null!==n?fg(t,n,a,i||null,!0):2===e?function L_(e,t,n){const r=Kw(e,t);r&&function l1e(e,t,n,r){e.removeChild(t,n,r)}(e,r,t,n)}(t,a,s):3===e&&t.destroyNode(a),null!=o&&function p1e(e,t,n,r,i){const o=n[Rd];o!==_i(n)&&Wy(t,e,r,o,i);for(let a=Go;a0&&(e[n-1][Ll]=r[Ll]);const o=dw(e,Go+t);!function r1e(e,t){Zj(e,t),t[Ji]=null,t[aa]=null}(r[Mt],r);const s=o[qf];null!==s&&s.detachView(o[Mt]),r[zo]=null,r[Ll]=null,r[bn]&=-129}return r}function Xw(e,t){if(!(256&t[bn])){const n=t[Mn];n.destroyNode&&Qw(e,t,n,3,null,null),function o1e(e){let t=e[h_];if(!t)return ZR(e[Mt],e);for(;t;){let n=null;if(ca(t))n=t[h_];else{const r=t[Go];r&&(n=r)}if(!n){for(;t&&!t[Ll]&&t!==e;)ca(t)&&ZR(t[Mt],t),t=t[zo];null===t&&(t=e),ca(t)&&ZR(t[Mt],t),n=t&&t[Ll]}t=n}}(t)}}function ZR(e,t){if(256&t[bn])return;const n=sr(null);try{t[bn]&=-129,t[bn]|=256,t[ag]&&function dG(e){if(gy(e),o_(e))for(let t=0;t=0?r[s]():r[-s].unsubscribe(),o+=2}else n[o].call(r[n[o+1]]);null!==r&&(t[Py]=null);const i=t[Ch];if(null!==i){t[Ch]=null;for(let o=0;o-1){const{encapsulation:o}=e.data[r.directiveStart+i];if(o===Fl.None||o===Fl.Emulated)return null}return Oa(r,n)}}(e,t.parent,n)}function fg(e,t,n,r,i){e.insertBefore(t,n,r,i)}function eH(e,t,n){e.appendChild(t,n)}function tH(e,t,n,r,i){null!==r?fg(e,t,n,r,i):eH(e,t,n)}function Kw(e,t){return e.parentNode(t)}let JR,iH=function rH(e,t,n){return 40&e.type?Oa(e,n):null};function Zw(e,t,n,r){const i=QR(e,r,t),o=t[Mn],a=function nH(e,t,n){return iH(e,t,n)}(r.parent||t[aa],r,t);if(null!=i)if(Array.isArray(n))for(let c=0;cVn&&dH(e,t,Vn,!1),kd(s?2:0,i),n(r,i)}finally{lg(o),kd(s?3:1,i)}}function rk(e,t,n){if($M(t)){const r=sr(null);try{const o=t.directiveEnd;for(let s=t.directiveStart;snull;function yH(e,t,n,r,i){for(let o in t){if(!t.hasOwnProperty(o))continue;const s=t[o];if(void 0===s)continue;r??={};let a,c=Bl.None;Array.isArray(s)?(a=s[0],c=s[1]):a=s;let u=o;if(null!==i){if(!i.hasOwnProperty(o))continue;u=i[o]}0===e?bH(r,n,u,a,c):bH(r,n,u,a)}return r}function bH(e,t,n,r,i){let o;e.hasOwnProperty(n)?(o=e[n]).push(t,r):o=e[n]=[t,r],void 0!==i&&o.push(i)}function ak(e,t,n,r){if(v9()){const i=null===r?null:{"":-1},o=function R1e(e,t){const n=e.directiveRegistry;let r=null,i=null;if(n)for(let o=0;o0;){const n=e[--t];if("number"==typeof n&&n<0)return n}return 0})(s)!=a&&s.push(a),s.push(n,r,o)}}(e,t,r,U_(e,n,i.hostVars,Wn),i)}function Ud(e,t,n,r,i,o){const s=Oa(e,t);!function uk(e,t,n,r,i,o,s){if(null==o)e.removeAttribute(t,i,n);else{const a=null==s?Un(o):s(o,r||"",i);e.setAttribute(t,i,a,n)}}(t[Mn],s,o,e.value,n,r,i)}function L1e(e,t,n,r,i,o){const s=o[t];if(null!==s)for(let a=0;a0&&(n[i-1][Ll]=t),r!1,producerRecomputeValue:()=>{},consumerMarkedDirty:()=>{},consumerOnSignalRead:()=>{},consumerIsAlwaysLive:!0,consumerMarkedDirty:e=>{__(e.lView)},consumerOnSignalRead(){this.lView[ag]=this}},EH=100;function nA(e,t=!0,n=0){const r=e[Ul],i=r.rendererFactory;i.begin?.();try{!function $1e(e,t){hk(e,t);let n=0;for(;eR(e);){if(n===EH)throw new It(103,!1);n++,hk(e,1)}}(e,n)}catch(s){throw t&&tA(e,s),s}finally{i.end?.(),r.inlineEffectRunner?.flush()}}function Y1e(e,t,n,r){const i=t[bn];if(!(256&~i))return;t[Ul].inlineEffectRunner?.flush(),cR(t);let s=null,a=null;(function X1e(e){return 2!==e.type})(e)&&(a=function j1e(e){return e[ag]??function H1e(e){const t=DH.pop()??Object.create(W1e);return t.lView=e,t}(e)}(t),s=function uG(e){return e&&(e.nextProducerIndex=0),sr(e)}(a));try{g9(t),function S9(e){return Rn.lFrame.bindingIndex=e}(e.bindingStartIndex),null!==n&&hH(e,t,n,2,r);const c=!(3&~i);if(c){const d=e.preOrderCheckHooks;null!==d&&Tw(t,d,null)}else{const d=e.preOrderHooks;null!==d&&Dw(t,d,0,null),lR(t,0)}if(function K1e(e){for(let t=cj(e);null!==t;t=uj(t)){if(!(t[bn]&WM.HasTransplantedViews))continue;const n=t[ky];for(let r=0;re.nextProducerIndex;)e.producerNode.pop(),e.producerLastReadVersion.pop(),e.producerIndexOfThis.pop()}}(a,s),function q1e(e){e.lView[ag]!==e&&(e.lView=null,DH.push(e))}(a)),uR()}}function PH(e,t){for(let n=cj(e);null!==n;n=uj(n))for(let r=Go;r-1&&(B_(t,r),dw(n,r))}this._attachedToViewContainer=!1}Xw(this._lView[Mt],this._lView)}onDestroy(t){ww(this._lView,t)}markForCheck(){j_(this._cdRefInjectingView||this._lView)}detach(){this._lView[bn]&=-129}reattach(){tR(this._lView),this._lView[bn]|=128}detectChanges(){this._lView[bn]|=1024,nA(this._lView,this.notifyErrorHandler)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new It(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,Zj(this._lView[Mt],this._lView)}attachToAppRef(t){if(this._attachedToViewContainer)throw new It(902,!1);this._appRef=t,tR(this._lView)}}let Kf=(()=>{class e{static#e=this.__NG_ELEMENT_ID__=e_e}return e})();const Q1e=Kf,J1e=class extends Q1e{constructor(t,n,r){super(),this._declarationLView=t,this._declarationTContainer=n,this.elementRef=r}get ssrId(){return this._declarationTContainer.tView?.ssrId||null}createEmbeddedView(t,n){return this.createEmbeddedViewImpl(t,n)}createEmbeddedViewImpl(t,n,r){const i=V_(this._declarationLView,this._declarationTContainer,t,{embeddedViewInjector:n,dehydratedView:r});return new H_(i)}};function e_e(){return rA(hi(),it())}function rA(e,t){return 4&e.type?new J1e(t,e,Vy(e,t)):null}let LH=()=>null;function Xy(e,t){return LH(e,t)}class _k{}class w_e{}class UH{}class I_e{resolveComponentFactory(t){throw function A_e(e){const t=Error(`No component factory found for ${Ss(e)}.`);return t.ngComponent=e,t}(t)}}let cA=(()=>{class e{static#e=this.NULL=new I_e}return e})();class zH{}let uA=(()=>{class e{constructor(){this.destroyNode=null}static#e=this.__NG_ELEMENT_ID__=()=>function T_e(){const e=it(),n=Zc(hi().index,e);return(ca(n)?n:e)[Mn]}()}return e})(),D_e=(()=>{class e{static#e=this.\u0275prov=Gt({token:e,providedIn:"root",factory:()=>null})}return e})();const xk={},GH=new Set;function Vd(e){GH.has(e)||(GH.add(e),performance?.mark?.("mark_feature_usage",{detail:{feature:e}}))}function jH(...e){}class Qr{constructor({enableLongStackTrace:t=!1,shouldCoalesceEventChangeDetection:n=!1,shouldCoalesceRunChangeDetection:r=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new Ua(!1),this.onMicrotaskEmpty=new Ua(!1),this.onStable=new Ua(!1),this.onError=new Ua(!1),typeof Zone>"u")throw new It(908,!1);Zone.assertZonePatched();const i=this;i._nesting=0,i._outer=i._inner=Zone.current,Zone.TaskTrackingZoneSpec&&(i._inner=i._inner.fork(new Zone.TaskTrackingZoneSpec)),t&&Zone.longStackTraceZoneSpec&&(i._inner=i._inner.fork(Zone.longStackTraceZoneSpec)),i.shouldCoalesceEventChangeDetection=!r&&n,i.shouldCoalesceRunChangeDetection=r,i.lastRequestAnimationFrameId=-1,i.nativeRequestAnimationFrame=function E_e(){const e="function"==typeof si.requestAnimationFrame;let t=si[e?"requestAnimationFrame":"setTimeout"],n=si[e?"cancelAnimationFrame":"clearTimeout"];if(typeof Zone<"u"&&t&&n){const r=t[Zone.__symbol__("OriginalDelegate")];r&&(t=r);const i=n[Zone.__symbol__("OriginalDelegate")];i&&(n=i)}return{nativeRequestAnimationFrame:t,nativeCancelAnimationFrame:n}}().nativeRequestAnimationFrame,function R_e(e){const t=()=>{!function M_e(e){e.isCheckStableRunning||-1!==e.lastRequestAnimationFrameId||(e.lastRequestAnimationFrameId=e.nativeRequestAnimationFrame.call(si,()=>{e.fakeTopEventTask||(e.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{e.lastRequestAnimationFrameId=-1,Ck(e),e.isCheckStableRunning=!0,Sk(e),e.isCheckStableRunning=!1},void 0,()=>{},()=>{})),e.fakeTopEventTask.invoke()}),Ck(e))}(e)};e._inner=e._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(n,r,i,o,s,a)=>{if(function k_e(e){return!(!Array.isArray(e)||1!==e.length)&&!0===e[0].data?.__ignore_ng_zone__}(a))return n.invokeTask(i,o,s,a);try{return HH(e),n.invokeTask(i,o,s,a)}finally{(e.shouldCoalesceEventChangeDetection&&"eventTask"===o.type||e.shouldCoalesceRunChangeDetection)&&t(),qH(e)}},onInvoke:(n,r,i,o,s,a,c)=>{try{return HH(e),n.invoke(i,o,s,a,c)}finally{e.shouldCoalesceRunChangeDetection&&t(),qH(e)}},onHasTask:(n,r,i,o)=>{n.hasTask(i,o),r===i&&("microTask"==o.change?(e._hasPendingMicrotasks=o.microTask,Ck(e),Sk(e)):"macroTask"==o.change&&(e.hasPendingMacrotasks=o.macroTask))},onHandleError:(n,r,i,o)=>(n.handleError(i,o),e.runOutsideAngular(()=>e.onError.emit(o)),!1)})}(i)}static isInAngularZone(){return typeof Zone<"u"&&!0===Zone.current.get("isAngularZone")}static assertInAngularZone(){if(!Qr.isInAngularZone())throw new It(909,!1)}static assertNotInAngularZone(){if(Qr.isInAngularZone())throw new It(909,!1)}run(t,n,r){return this._inner.run(t,n,r)}runTask(t,n,r,i){const o=this._inner,s=o.scheduleEventTask("NgZoneEvent: "+i,t,P_e,jH,jH);try{return o.runTask(s,n,r)}finally{o.cancelTask(s)}}runGuarded(t,n,r){return this._inner.runGuarded(t,n,r)}runOutsideAngular(t){return this._outer.run(t)}}const P_e={};function Sk(e){if(0==e._nesting&&!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 Ck(e){e.hasPendingMicrotasks=!!(e._hasPendingMicrotasks||(e.shouldCoalesceEventChangeDetection||e.shouldCoalesceRunChangeDetection)&&-1!==e.lastRequestAnimationFrameId)}function HH(e){e._nesting++,e.isStable&&(e.isStable=!1,e.onUnstable.emit(null))}function qH(e){e._nesting--,Sk(e)}var pg=function(e){return e[e.EarlyRead=0]="EarlyRead",e[e.Write=1]="Write",e[e.MixedReadWrite=2]="MixedReadWrite",e[e.Read=3]="Read",e}(pg||{});const $H={destroy(){}};function YH(e,t){!t&&function vw(e){if(!n9())throw new It(-203,!1)}();const n=t?.injector??bt(Sc);if(!function Eh(e){return"browser"===(e??bt(Sc)).get(Th)}(n))return $H;Vd("NgAfterNextRender");const r=n.get(X_),i=r.handler??=new KH,o=t?.phase??pg.MixedReadWrite,s=()=>{i.unregister(c),a()},a=n.get(Uy).onDestroy(s),c=Md(n,()=>new XH(o,()=>{s(),e()}));return i.register(c),{destroy:s}}class XH{constructor(t,n){this.phase=t,this.callbackFn=n,this.zone=bt(Qr),this.errorHandler=bt(Ld,{optional:!0}),bt(_k,{optional:!0})?.notify(1)}invoke(){try{this.zone.runOutsideAngular(this.callbackFn)}catch(t){this.errorHandler?.handleError(t)}}}class KH{constructor(){this.executingCallbacks=!1,this.buckets={[pg.EarlyRead]:new Set,[pg.Write]:new Set,[pg.MixedReadWrite]:new Set,[pg.Read]:new Set},this.deferredCallbacks=new Set}register(t){(this.executingCallbacks?this.deferredCallbacks:this.buckets[t.phase]).add(t)}unregister(t){this.buckets[t.phase].delete(t),this.deferredCallbacks.delete(t)}execute(){this.executingCallbacks=!0;for(const t of Object.values(this.buckets))for(const n of t)n.invoke();this.executingCallbacks=!1;for(const t of this.deferredCallbacks)this.buckets[t.phase].add(t);this.deferredCallbacks.clear()}destroy(){for(const t of Object.values(this.buckets))t.clear();this.deferredCallbacks.clear()}}let X_=(()=>{class e{constructor(){this.handler=null,this.internalCallbacks=[]}execute(){this.executeInternalCallbacks(),this.handler?.execute()}executeInternalCallbacks(){const n=[...this.internalCallbacks];this.internalCallbacks.length=0;for(const r of n)r()}ngOnDestroy(){this.handler?.destroy(),this.handler=null,this.internalCallbacks.length=0}static#e=this.\u0275prov=Gt({token:e,providedIn:"root",factory:()=>new e})}return e})();function dA(e,t,n){let r=n?e.styles:null,i=n?e.classes:null,o=0;if(null!==t)for(let s=0;s0&&uH(e,n,o.join(" "))}}(p,A,h,r),void 0!==n&&function W_e(e,t,n){const r=e.projection=[];for(let i=0;i{class e{static#e=this.__NG_ELEMENT_ID__=Y_e}return e})();function Y_e(){return rq(hi(),it())}const X_e=Gl,tq=class extends X_e{constructor(t,n,r){super(),this._lContainer=t,this._hostTNode=n,this._hostLView=r}get element(){return Vy(this._hostTNode,this._hostLView)}get injector(){return new As(this._hostTNode,this._hostLView)}get parentInjector(){const t=Mw(this._hostTNode,this._hostLView);if(fR(t)){const n=A_(t,this._hostLView),r=w_(t);return new As(n[Mt].data[r+8],n)}return new As(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(t){const n=nq(this._lContainer);return null!==n&&n[t]||null}get length(){return this._lContainer.length-Go}createEmbeddedView(t,n,r){let i,o;"number"==typeof r?i=r:null!=r&&(i=r.index,o=r.injector);const s=Xy(this._lContainer,t.ssrId),a=t.createEmbeddedViewImpl(n||{},o,s);return this.insertImpl(a,i,Yy(this._hostTNode,s)),a}createComponent(t,n,r,i,o){const s=t&&!function p_(e){return"function"==typeof e}(t);let a;if(s)a=n;else{const m=n||{};a=m.index,r=m.injector,i=m.projectableNodes,o=m.environmentInjector||m.ngModuleRef}const c=s?t:new Q_(dr(t)),u=r||this.parentInjector;if(!o&&null==c.ngModule){const h=(s?u:this.parentInjector).get(xc,null);h&&(o=h)}const l=dr(c.componentType??{}),d=Xy(this._lContainer,l?.id??null),p=c.create(u,i,d?.firstChild??null,o);return this.insertImpl(p.hostView,a,Yy(this._hostTNode,d)),p}insert(t,n){return this.insertImpl(t,n,!0)}insertImpl(t,n,r){const i=t._lView;if(function Hye(e){return ua(e[zo])}(i)){const a=this.indexOf(t);if(-1!==a)this.detach(a);else{const c=i[zo],u=new tq(c,c[aa],c[zo]);u.detach(u.indexOf(t))}}const o=this._adjustIndex(n),s=this._lContainer;return z_(s,i,o,r),t.attachToViewContainerRef(),UG(Tk(s),o,t),t}move(t,n){return this.insert(t,n)}indexOf(t){const n=nq(this._lContainer);return null!==n?n.indexOf(t):-1}remove(t){const n=this._adjustIndex(t,-1),r=B_(this._lContainer,n);r&&(dw(Tk(this._lContainer),n),Xw(r[Mt],r))}detach(t){const n=this._adjustIndex(t,-1),r=B_(this._lContainer,n);return r&&null!=dw(Tk(this._lContainer),n)?new H_(r):null}_adjustIndex(t,n=0){return t??this.length+n}};function nq(e){return e[8]}function Tk(e){return e[8]||(e[8]=[])}function rq(e,t){let n;const r=t[e.index];return ua(r)?n=r:(n=xH(r,t,null,e),t[e.index]=n,eA(t,n)),iq(n,t,e,r),new tq(n,e,t)}let iq=function sq(e,t,n,r){if(e[Rd])return;let i;i=8&n.type?_i(r):function K_e(e,t){const n=e[Mn],r=n.createComment(""),i=Oa(t,e);return fg(n,Kw(n,i),r,function d1e(e,t){return e.nextSibling(t)}(n,i),!1),r}(t,n),e[Rd]=i},Dk=()=>!1;class Ek{constructor(t){this.queryList=t,this.matches=null}clone(){return new Ek(this.queryList)}setDirty(){this.queryList.setDirty()}}class Pk{constructor(t=[]){this.queries=t}createEmbeddedView(t){const n=t.queries;if(null!==n){const r=null!==t.contentQueries?t.contentQueries[0]:n.length,i=[];for(let o=0;ot.trim())}(t):t}}class Mk{constructor(t=[]){this.queries=t}elementStart(t,n){for(let r=0;r0)r.push(s[a/2]);else{const u=o[a+1],l=t[-c];for(let d=Go;dn()),this.destroyCbs=null}onDestroy(t){this.destroyCbs.push(t)}}class Lk extends kq{constructor(t){super(),this.moduleType=t}create(t){return new Ok(this.moduleType,t,[])}}class Nq extends hg{constructor(t){super(),this.componentFactoryResolver=new JH(this),this.instance=null;const n=new Ty([...t.providers,{provide:hg,useValue:this},{provide:cA,useValue:this.componentFactoryResolver}],t.parent||bw(),t.debugName,new Set(["environment"]));this.injector=n,t.runEnvironmentInitializers&&n.resolveInjectorInitializers()}destroy(){this.injector.destroy()}onDestroy(t){this.injector.onDestroy(t)}}function hA(e,t,n=null){return new Nq({providers:e,parent:t,debugName:n,runEnvironmentInitializers:!0}).injector}let kh=(()=>{class e{constructor(){this.taskId=0,this.pendingTasks=new Set,this.hasPendingTasks=new Ao(!1)}get _hasPendingTasks(){return this.hasPendingTasks.value}add(){this._hasPendingTasks||this.hasPendingTasks.next(!0);const n=this.taskId++;return this.pendingTasks.add(n),n}remove(n){this.pendingTasks.delete(n),0===this.pendingTasks.size&&this._hasPendingTasks&&this.hasPendingTasks.next(!1)}ngOnDestroy(){this.pendingTasks.clear(),this._hasPendingTasks&&this.hasPendingTasks.next(!1)}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function zd(e,t,n){return e[t]=n}function jo(e,t,n){return!Object.is(e[t],n)&&(e[t]=n,!0)}function yA(e,t,n,r,i){const o=function mg(e,t,n,r){const i=jo(e,t,n);return jo(e,t+1,r)||i}(e,t,n,r);return jo(e,t+2,i)||o}function Jc(e,t,n,r,i,o,s,a){const c=it(),u=br(),l=e+Vn,d=u.firstCreatePass?function kxe(e,t,n,r,i,o,s,a,c){const u=t.consts,l=$y(t,e,4,s||null,Nd(u,a));ak(t,n,l,Nd(u,c)),Iw(t,l);const d=l.tView=sk(2,l,r,i,o,t.directiveRegistry,t.pipeRegistry,null,t.schemas,u,null);return null!==t.queries&&(t.queries.template(t,l),d.queries=t.queries.embeddedTView(l)),l}(l,u,c,t,n,r,i,o,s):u.data[l];Fd(d,!1);const f=Fq(u,c,d,e);S_()&&Zw(u,c,f,d),da(f,c);const p=xH(f,c,f,d);return c[l]=p,eA(c,p),function oq(e,t,n){return Dk(e,t,n)}(p,d,c),Cw(d)&&ik(u,c,d),null!=s&&ok(c,d,a),Jc}let Fq=function Bq(e,t,n,r){return Bd(!0),t[Mn].createComment("")};function Xk(e,t,n,r){const i=it();return jo(i,zl(),t)&&(br(),Ud(Ri(),i,e,t,n,r)),Xk}function CA(e,t){return e<<17|t<<2}function Fh(e){return e>>17&32767}function Kk(e){return 2|e}function yg(e){return(131068&e)>>2}function Zk(e,t){return-131069&e|t<<2}function Qk(e){return 1|e}function pW(e,t,n,r){const i=e[n+1],o=null===t;let s=r?Fh(i):yg(i),a=!1;for(;0!==s&&(!1===a||o);){const u=e[s+1];y2e(e[s],t)&&(a=!0,e[s+1]=r?Qk(u):Kk(u)),s=r?Fh(u):yg(u)}a&&(e[n+1]=r?Kk(i):Qk(i))}function y2e(e,t){return null===e||null==t||(Array.isArray(e)?e[1]:e)===t||!(!Array.isArray(e)||"string"!=typeof t)&&Ay(e,t)>=0}function Bh(e,t,n){const r=it();return jo(r,zl(),t)&&function wc(e,t,n,r,i,o,s,a){const c=Oa(t,n);let l,u=t.inputs;!a&&null!=u&&(l=u[r])?(dk(e,n,l,r,i),cg(t)&&function I1e(e,t){const n=Zc(t,e);16&n[bn]||(n[bn]|=64)}(n,t.index)):3&t.type&&(r=function A1e(e){return"class"===e?"className":"for"===e?"htmlFor":"formaction"===e?"formAction":"innerHtml"===e?"innerHTML":"readonly"===e?"readOnly":"tabindex"===e?"tabIndex":e}(r),i=null!=s?s(i,t.value||"",r):i,o.setProperty(c,r,i))}(br(),Ri(),r,e,t,r[Mn],n,!1),Bh}function Jk(e,t,n,r,i){const s=i?"class":"style";dk(e,n,t.inputs[s],s,r)}function pb(e,t,n){return function jl(e,t,n,r){const i=it(),o=br(),s=function $f(e){const t=Rn.lFrame,n=t.bindingIndex;return t.bindingIndex=t.bindingIndex+e,n}(2);o.firstUpdatePass&&function SW(e,t,n,r){const i=e.data;if(null===i[n+1]){const o=i[la()],s=function xW(e,t){return t>=e.expandoStartIndex}(e,n);(function IW(e,t){return!!(e.flags&(t?8:16))})(o,r)&&null===t&&!s&&(t=!1),t=function I2e(e,t,n,r){const i=function sR(e){const t=Rn.lFrame.currentDirectiveIndex;return-1===t?null:e[t]}(e);let o=r?t.residualClasses:t.residualStyles;if(null===i)0===(r?t.classBindings:t.styleBindings)&&(n=ox(n=eN(null,e,t,n,r),t.attrs,r),o=null);else{const s=t.directiveStylingLast;if(-1===s||e[s]!==i)if(n=eN(i,e,t,n,r),null===o){let c=function T2e(e,t,n){const r=n?t.classBindings:t.styleBindings;if(0!==yg(r))return e[Fh(r)]}(e,t,r);void 0!==c&&Array.isArray(c)&&(c=eN(null,e,t,c[1],r),c=ox(c,t.attrs,r),function D2e(e,t,n,r){e[Fh(n?t.classBindings:t.styleBindings)]=r}(e,t,r,c))}else o=function E2e(e,t,n){let r;const i=t.directiveEnd;for(let o=1+t.directiveStylingLast;o0)&&(u=!0)):l=n,i)if(0!==c){const f=Fh(e[a+1]);e[r+1]=CA(f,a),0!==f&&(e[f+1]=Zk(e[f+1],r)),e[a+1]=function p2e(e,t){return 131071&e|t<<17}(e[a+1],r)}else e[r+1]=CA(a,0),0!==a&&(e[a+1]=Zk(e[a+1],r)),a=r;else e[r+1]=CA(c,0),0===a?a=r:e[c+1]=Zk(e[c+1],r),c=r;u&&(e[r+1]=Kk(e[r+1])),pW(e,l,r,!0),pW(e,l,r,!1),function g2e(e,t,n,r,i){const o=i?e.residualClasses:e.residualStyles;null!=o&&"string"==typeof t&&Ay(o,t)>=0&&(n[r+1]=Qk(n[r+1]))}(t,l,e,r,o),s=CA(a,c),o?t.classBindings=s:t.styleBindings=s}(i,o,t,n,s,r)}}(o,e,s,r),t!==Wn&&jo(i,s,t)&&function wW(e,t,n,r,i,o,s,a){if(!(3&t.type))return;const c=e.data,u=c[a+1],l=function h2e(e){return!(1&~e)}(u)?AW(c,t,n,i,yg(u),s):void 0;wA(l)||(wA(o)||function f2e(e){return!(2&~e)}(u)&&(o=AW(c,null,n,i,a,s)),function h1e(e,t,n,r,i){if(t)i?e.addClass(n,r):e.removeClass(n,r);else{let o=-1===r.indexOf("-")?void 0:Ph.DashCase;null==i?e.removeStyle(n,r,o):("string"==typeof i&&i.endsWith("!important")&&(i=i.slice(0,-10),o|=Ph.Important),e.setStyle(n,r,i,o))}}(r,s,b_(la(),n),i,o))}(o,o.data[la()],i,i[Mn],e,i[s+1]=function k2e(e,t){return null==e||""===e||("string"==typeof t?e+=t:"object"==typeof e&&(e=Ss(Dh(e)))),e}(t,n),r,s)}(e,t,n,!1),pb}function eN(e,t,n,r,i){let o=null;const s=n.directiveEnd;let a=n.directiveStylingLast;for(-1===a?a=n.directiveStart:a++;a0;){const c=e[i],u=Array.isArray(c),l=u?c[1]:c,d=null===l;let f=n[i+1];f===Wn&&(f=d?Vr:void 0);let p=d?kM(f,r):l===r?f:void 0;if(u&&!wA(p)&&(p=kM(c,r)),wA(p)&&(a=p,s))return a;const m=e[i+1];i=s?Fh(m):yg(m)}if(null!==t){let c=o?t.residualClasses:t.residualStyles;null!=c&&(a=kM(c,r))}return a}function wA(e){return void 0!==e}class H2e{destroy(t){}updateValue(t,n){}swap(t,n){const r=Math.min(t,n),i=Math.max(t,n),o=this.detach(i);if(i-r>1){const s=this.detach(r);this.attach(r,o),this.attach(i,s)}else this.attach(r,o)}move(t,n){this.attach(n,this.detach(t))}}function tN(e,t,n,r,i){return e===n&&Object.is(t,r)?1:Object.is(i(e,t),i(n,r))?-1:0}function nN(e,t,n,r){return!(void 0===t||!t.has(r)||(e.attach(n,t.get(r)),t.delete(r),0))}function TW(e,t,n,r,i){if(nN(e,t,r,n(r,i)))e.updateValue(r,i);else{const o=e.create(r,i);e.attach(r,o)}}function DW(e,t,n,r){const i=new Set;for(let o=t;o<=n;o++)i.add(r(o,e.at(o)));return i}class EW{constructor(){this.kvMap=new Map,this._vMap=void 0}has(t){return this.kvMap.has(t)}delete(t){if(!this.has(t))return!1;const n=this.kvMap.get(t);return void 0!==this._vMap&&this._vMap.has(n)?(this.kvMap.set(t,this._vMap.get(n)),this._vMap.delete(n)):this.kvMap.delete(t),!0}get(t){return this.kvMap.get(t)}set(t,n){if(this.kvMap.has(t)){let r=this.kvMap.get(t);void 0===this._vMap&&(this._vMap=new Map);const i=this._vMap;for(;i.has(r);)r=i.get(r);i.set(r,n)}else this.kvMap.set(t,n)}forEach(t){for(let[n,r]of this.kvMap)if(t(r,n),void 0!==this._vMap){const i=this._vMap;for(;i.has(r);)r=i.get(r),t(r,n)}}}function Va(e,t,n){Vd("NgControlFlow");const r=it(),i=zl(),o=rN(r,Vn+e);if(jo(r,i,t)){const a=sr(null);try{if(pk(o,0),-1!==t){const c=iN(r[Mt],Vn+t),u=Xy(o,c.tView.ssrId);z_(o,V_(r,c,n,{dehydratedView:u}),0,Yy(c,u))}}finally{sr(a)}}else{const a=IH(o,0);void 0!==a&&(a[Mi]=n)}}class W2e{constructor(t,n,r){this.lContainer=t,this.$implicit=n,this.$index=r}get $count(){return this.lContainer.length-Go}}function PW(e){return e}class Y2e{constructor(t,n,r){this.hasEmptyBlock=t,this.trackByFn=n,this.liveCollection=r}}class X2e extends H2e{constructor(t,n,r){super(),this.lContainer=t,this.hostLView=n,this.templateTNode=r,this.needsIndexUpdate=!1}get length(){return this.lContainer.length-Go}at(t){return this.getLView(t)[Mi].$implicit}attach(t,n){const r=n[Kc];this.needsIndexUpdate||=t!==this.length,z_(this.lContainer,n,t,Yy(this.templateTNode,r))}detach(t){return this.needsIndexUpdate||=t!==this.length-1,function K2e(e,t){return B_(e,t)}(this.lContainer,t)}create(t,n){const r=Xy(this.lContainer,this.templateTNode.tView.ssrId);return V_(this.hostLView,this.templateTNode,new W2e(this.lContainer,n,t),{dehydratedView:r})}destroy(t){Xw(t[Mt],t)}updateValue(t,n){this.getLView(t)[Mi].$implicit=n}reset(){this.needsIndexUpdate=!1}updateIndexes(){if(this.needsIndexUpdate)for(let t=0;t(Bd(!0),Yw(r,i,function E9(){return Rn.lFrame.currentNamespace}()));const mb="en-US";let VW=mb;function fx(e,t,n,r){const i=it(),o=br(),s=hi();return function uN(e,t,n,r,i,o,s){const a=Cw(r),u=e.firstCreatePass&&wH(e),l=t[Mi],d=CH(t);let f=!0;if(3&r.type||s){const h=Oa(r,t),g=s?s(h):h,y=d.length,b=s?_=>s(_i(_[r.index])):r.index;let x=null;if(!s&&a&&(x=function rCe(e,t,n,r){const i=e.cleanup;if(null!=i)for(let o=0;oc?a[c]:null}"string"==typeof s&&(o+=2)}return null}(e,t,i,r.index)),null!==x)(x.__ngLastListenerFn__||x).__ngNextListenerFn__=o,x.__ngLastListenerFn__=o,f=!1;else{o=h$(r,t,l,o,!1);const _=n.listen(g,i,o);d.push(o,_),u&&u.push(i,b,y,y+1)}}else o=h$(r,t,l,o,!1);const p=r.outputs;let m;if(f&&null!==p&&(m=p[i])){const h=m.length;if(h)for(let g=0;g-1?Zc(e.index,t):t);let c=p$(t,n,r,s),u=o.__ngNextListenerFn__;for(;u;)c=p$(t,n,u,s)&&c,u=u.__ngNextListenerFn__;return i&&!1===c&&s.preventDefault(),c}}function px(e=1){return function abe(e){return(Rn.lFrame.contextLView=function y9(e,t){for(;e>0;)t=t[My],e--;return t}(e,Rn.lFrame.contextLView))[Mi]}(e)}function dN(e,t,n){lq(e,t,n)}function EA(e){const t=it(),n=br(),r=aR();Aw(r+1);const i=Fk(n,r);if(e.dirty&&function jye(e){return!(4&~e[bn])}(t)===!(2&~i.metadata.flags)){if(null===i.matches)e.reset([]);else{const o=pq(t,r);e.reset(o,Q9),e.notifyOnChanges()}return!0}return!1}function PA(){return function Nk(e,t){return e[qf].queries[t].queryList}(it(),aR())}function ar(e,t=""){const n=it(),r=br(),i=e+Vn,o=r.firstCreatePass?$y(r,i,1,t,null):r.data[i],s=N$(r,n,o,t,e);n[i]=s,S_()&&Zw(r,n,s,o),Fd(o,!1)}let N$=(e,t,n,r,i)=>(Bd(!0),function XR(e,t){return e.createText(t)}(t[Mn],r));function ku(e){return fN("",e,""),ku}function fN(e,t,n){const r=it(),i=function ib(e,t,n,r){return jo(e,zl(),n)?t+Un(n)+r:Wn}(r,e,t,n);return i!==Wn&&function Xf(e,t,n){const r=b_(t,e);!function Kj(e,t,n){e.setValue(t,n)}(e[Mn],r,n)}(r,la(),i),fN}function pN(e,t,n,r,i){if(e=En(e),Array.isArray(e))for(let o=0;o>20;if(sg(e)||!e.multi){const p=new C_(u,i,cn),m=mN(c,t,i?l:l+f,d);-1===m?(mR(Pw(a,s),o,c),hN(o,e,t.length),t.push(c),a.directiveStart++,a.directiveEnd++,i&&(a.providerIndexes+=1048576),n.push(p),s.push(p)):(n[m]=p,s[m]=p)}else{const p=mN(c,t,l+f,d),m=mN(c,t,l,l+f),g=m>=0&&n[m];if(i&&!g||!i&&!(p>=0&&n[p])){mR(Pw(a,s),o,c);const y=function TCe(e,t,n,r,i){const o=new C_(e,n,cn);return o.multi=[],o.index=t,o.componentProviders=0,q$(o,i,r&&!n),o}(i?ICe:ACe,n.length,i,r,u);!i&&g&&(n[m].providerFactory=y),hN(o,e,t.length,0),t.push(c),a.directiveStart++,a.directiveEnd++,i&&(a.providerIndexes+=1048576),n.push(y),s.push(y)}else hN(o,e,p>-1?p:m,q$(n[i?m:p],u,!i&&r));!i&&r&&g&&n[m].componentProviders++}}}function hN(e,t,n,r){const i=sg(t),o=function yye(e){return!!e.useClass}(t);if(i||o){const c=(o?En(t.useClass):t).prototype.ngOnDestroy;if(c){const u=e.destroyHooks||(e.destroyHooks=[]);if(!i&&t.multi){const l=u.indexOf(n);-1===l?u.push(n,[r,c]):u[l+1].push(r,c)}else u.push(n,c)}}}function q$(e,t,n){return n&&e.componentProviders++,e.multi.push(t)-1}function mN(e,t,n,r){for(let i=n;i{n.providersResolver=(r,i)=>function wCe(e,t,n){const r=br();if(r.firstCreatePass){const i=Vl(e);pN(n,r.data,r.blueprint,i,!0),pN(t,r.data,r.blueprint,i,!1)}}(r,i?i(e):e,t)}}let DCe=(()=>{class e{constructor(n){this._injector=n,this.cachedInjectors=new Map}getOrCreateStandaloneInjector(n){if(!n.standalone)return null;if(!this.cachedInjectors.has(n)){const r=OM(0,n.type),i=r.length>0?hA([r],this._injector,`Standalone[${n.type.name}]`):null;this.cachedInjectors.set(n,i)}return this.cachedInjectors.get(n)}ngOnDestroy(){try{for(const n of this.cachedInjectors.values())null!==n&&n.destroy()}finally{this.cachedInjectors.clear()}}static#e=this.\u0275prov=Gt({token:e,providedIn:"environment",factory:()=>new e(Zt(xc))})}return e})();function Nu(e){Vd("NgStandalone"),e.getStandaloneInjector=t=>t.get(DCe).getOrCreateStandaloneInjector(e)}function hx(e,t,n,r){return $$(it(),La(),e,t,n,r)}function yN(e,t,n,r,i,o){return function X$(e,t,n,r,i,o,s,a){const c=t+n;return yA(e,c,i,o,s)?zd(e,c+3,a?r.call(a,i,o,s):r(i,o,s)):mx(e,c+3)}(it(),La(),e,t,n,r,i,o)}function mx(e,t){const n=e[t];return n===Wn?void 0:n}function $$(e,t,n,r,i,o){const s=t+n;return jo(e,s,i)?zd(e,s+1,o?r.call(o,i):r(i)):mx(e,s+1)}function Ga(e,t){const n=br();let r;const i=e+Vn;n.firstCreatePass?(r=function UCe(e,t){if(t)for(let n=t.length-1;n>=0;n--){const r=t[n];if(e===r.name)return r}}(t,n.pipeRegistry),n.data[i]=r,r.onDestroy&&(n.destroyHooks??=[]).push(i,r.onDestroy)):r=n.data[i];const o=r.factory||(r.factory=ig(r.type)),a=bc(cn);try{const c=Ew(!1),u=o();return Ew(c),function lCe(e,t,n,r){n>=e.data.length&&(e.data[n]=null,e.blueprint[n]=null),t[n]=r}(n,it(),i,u),u}finally{bc(a)}}function ja(e,t,n){const r=e+Vn,i=it(),o=function Ny(e,t){return e[t]}(i,r);return function gx(e,t){return e[Mt].data[t].pure}(i,r)?$$(i,La(),t,o.transform,n,o):o.transform(n)}let pY=(()=>{class e{log(n){console.log(n)}warn(n){console.warn(n)}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();const bY=new Yt("");function OA(e){return!!e&&"function"==typeof e.then}function vY(e){return!!e&&"function"==typeof e.subscribe}const IN=new Yt("");let TN=(()=>{class e{constructor(){this.initialized=!1,this.done=!1,this.donePromise=new Promise((n,r)=>{this.resolve=n,this.reject=r}),this.appInits=bt(IN,{optional:!0})??[]}runInitializers(){if(this.initialized)return;const n=[];for(const i of this.appInits){const o=i();if(OA(o))n.push(o);else if(vY(o)){const s=new Promise((a,c)=>{o.subscribe({complete:a,error:c})});n.push(s)}}const r=()=>{this.done=!0,this.resolve()};Promise.all(n).then(()=>{r()}).catch(i=>{this.reject(i)}),0===n.length&&r(),this.initialized=!0}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();const LA=new Yt("");let Oh=(()=>{class e{constructor(){this._bootstrapListeners=[],this._runningTick=!1,this._destroyed=!1,this._destroyListeners=[],this._views=[],this.internalErrorHandler=bt(K9),this.afterRenderEffectManager=bt(X_),this.externalTestViews=new Set,this.beforeRender=new mr,this.afterTick=new mr,this.componentTypes=[],this.components=[],this.isStable=bt(kh).hasPendingTasks.pipe(qt(n=>!n)),this._injector=bt(xc)}get destroyed(){return this._destroyed}get injector(){return this._injector}bootstrap(n,r){const i=n instanceof UH;if(!this._injector.get(TN).done)throw!i&&function Sh(e){const t=dr(e)||Cs(e)||Qs(e);return null!==t&&t.standalone}(n),new It(405,!1);let s;s=i?n:this._injector.get(cA).resolveComponentFactory(n),this.componentTypes.push(s.componentType);const a=function Lwe(e){return e.isBoundToModule}(s)?void 0:this._injector.get(hg),u=s.create(Sc.NULL,[],r||s.selector,a),l=u.location.nativeElement,d=u.injector.get(bY,null);return d?.registerApplication(l),u.onDestroy(()=>{this.detachView(u.hostView),UA(this.components,u),d?.unregisterApplication(l)}),this._loadComponent(u),u}tick(){this._tick(!0)}_tick(n){if(this._runningTick)throw new It(101,!1);const r=sr(null);try{this._runningTick=!0,this.detectChangesInAttachedViews(n)}catch(i){this.internalErrorHandler(i)}finally{this.afterTick.next(),this._runningTick=!1,sr(r)}}detectChangesInAttachedViews(n){let r=0;const i=this.afterRenderEffectManager;for(;;){if(r===EH)throw new It(103,!1);if(n){const o=0===r;this.beforeRender.next(o);for(let{_lView:s,notifyErrorHandler:a}of this._views)Vwe(s,o,a)}if(r++,i.executeInternalCallbacks(),![...this.externalTestViews.keys(),...this._views].some(({_lView:o})=>DN(o))&&(i.execute(),![...this.externalTestViews.keys(),...this._views].some(({_lView:o})=>DN(o))))break}}attachView(n){const r=n;this._views.push(r),r.attachToAppRef(this)}detachView(n){const r=n;UA(this._views,r),r.detachFromAppRef()}_loadComponent(n){this.attachView(n.hostView),this.tick(),this.components.push(n);const r=this._injector.get(LA,[]);[...this._bootstrapListeners,...r].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),()=>UA(this._destroyListeners,n)}destroy(){if(this._destroyed)throw new It(406,!1);const n=this._injector;n.destroy&&!n.destroyed&&n.destroy()}get viewCount(){return this._views.length}warnIfDestroyed(){}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function UA(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}function Vwe(e,t,n){!t&&!DN(e)||function zwe(e,t,n){let r;n?(r=0,e[bn]|=1024):r=64&e[bn]?0:1,nA(e,t,r)}(e,n,t)}function DN(e){return eR(e)}class Gwe{constructor(t,n){this.ngModuleFactory=t,this.componentFactories=n}}let CY=(()=>{class e{compileModuleSync(n){return new Lk(n)}compileModuleAsync(n){return Promise.resolve(this.compileModuleSync(n))}compileModuleAndAllComponentsSync(n){const r=this.compileModuleSync(n),o=Qc(sa(n).declarations).reduce((s,a)=>{const c=dr(a);return c&&s.push(new Q_(c)),s},[]);return new Gwe(r,o)}compileModuleAndAllComponentsAsync(n){return Promise.resolve(this.compileModuleAndAllComponentsSync(n))}clearCache(){}clearCacheFor(n){}getModuleId(n){}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})(),qwe=(()=>{class e{constructor(){this.zone=bt(Qr),this.applicationRef=bt(Oh)}initialize(){this._onMicrotaskEmptySubscription||(this._onMicrotaskEmptySubscription=this.zone.onMicrotaskEmpty.subscribe({next:()=>{this.zone.run(()=>{this.applicationRef.tick()})}}))}ngOnDestroy(){this._onMicrotaskEmptySubscription?.unsubscribe()}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function AY(e){return[{provide:Qr,useFactory:e},{provide:og,multi:!0,useFactory:()=>{const t=bt(qwe,{optional:!0});return()=>t.initialize()}},{provide:og,multi:!0,useFactory:()=>{const t=bt(Ywe);return()=>{t.initialize()}}},{provide:K9,useFactory:Wwe}]}function Wwe(){const e=bt(Qr),t=bt(Ld);return n=>e.runOutsideAngular(()=>t.handleError(n))}function $we(e){return Iy([[],AY(()=>new Qr(function IY(e){return{enableLongStackTrace:!1,shouldCoalesceEventChangeDetection:e?.eventCoalescing??!1,shouldCoalesceRunChangeDetection:e?.runCoalescing??!1}}(e)))])}let Ywe=(()=>{class e{constructor(){this.subscription=new Fa,this.initialized=!1,this.zone=bt(Qr),this.pendingTasks=bt(kh)}initialize(){if(this.initialized)return;this.initialized=!0;let n=null;!this.zone.isStable&&!this.zone.hasPendingMacrotasks&&!this.zone.hasPendingMicrotasks&&(n=this.pendingTasks.add()),this.zone.runOutsideAngular(()=>{this.subscription.add(this.zone.onStable.subscribe(()=>{Qr.assertNotInAngularZone(),queueMicrotask(()=>{null!==n&&!this.zone.hasPendingMacrotasks&&!this.zone.hasPendingMicrotasks&&(this.pendingTasks.remove(n),n=null)})}))}),this.subscription.add(this.zone.onUnstable.subscribe(()=>{Qr.assertInAngularZone(),n??=this.pendingTasks.add()}))}ngOnDestroy(){this.subscription.unsubscribe()}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();const Zf=new Yt("",{providedIn:"root",factory:()=>bt(Zf,yr.Optional|yr.SkipSelf)||function Xwe(){return typeof $localize<"u"&&$localize.locale||mb}()}),EN=new Yt("");let Lh=null;let zA=(()=>{class e{static#e=this.__NG_ELEMENT_ID__=tAe}return e})();function tAe(e){return function nAe(e,t,n){if(cg(e)&&!n){const r=Zc(e.index,t);return new H_(r,r)}return 47&e.type?new H_(t[go],t):null}(hi(),it(),!(16&~e))}function DAe(e){try{const{rootComponent:t,appProviders:n,platformProviders:r}=e,i=function eAe(e=[]){if(Lh)return Lh;const t=function EY(e=[],t){return Sc.create({name:t,providers:[{provide:VM,useValue:"platform"},{provide:EN,useValue:new Set([()=>Lh=null])},...e]})}(e);return Lh=t,function _Y(){!function f0e(e){hG=e}(()=>{throw new It(600,!1)})}(),function PY(e){e.get(bj,null)?.forEach(n=>n())}(t),t}(r),o=[$we(),...n||[]],a=new Nq({providers:o,parent:i,debugName:"",runEnvironmentInitializers:!1}).injector,c=a.get(Qr);return c.run(()=>{a.resolveInjectorInitializers();const u=a.get(Ld,null);let l;c.runOutsideAngular(()=>{l=c.onError.subscribe({next:p=>{u.handleError(p)}})});const d=()=>a.destroy(),f=i.get(EN);return f.add(d),a.onDestroy(()=>{l.unsubscribe(),f.delete(d)}),function xY(e,t,n){try{const r=n();return OA(r)?r.catch(i=>{throw t.runOutsideAngular(()=>e.handleError(i)),i}):r}catch(r){throw t.runOutsideAngular(()=>e.handleError(r)),r}}(u,c,()=>{const p=a.get(TN);return p.runInitializers(),p.donePromise.then(()=>{!function zW(e){"string"==typeof e&&(VW=e.toLowerCase().replace(/_/g,"-"))}(a.get(Zf,mb)||mb);const h=a.get(Oh);return void 0!==t&&h.bootstrap(t),h})})})}catch(t){return Promise.reject(t)}}function LN(e){return"boolean"==typeof e?e:null!=e&&"false"!==e}function cX(e){const t=sr(null);try{return e()}finally{sr(t)}}let uX=null;function vb(){return uX}class ZAe{}const tu=new Yt("");let UN=(()=>{class e{historyGo(n){throw new Error("")}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>bt(JAe),providedIn:"platform"})}return e})();const QAe=new Yt("");let JAe=(()=>{class e extends UN{constructor(){super(),this._doc=bt(tu),this._location=window.location,this._history=window.history}getBaseHrefFromDOM(){return vb().getBaseHref(this._doc)}onPopState(n){const r=vb().getGlobalEventTarget(this._doc,"window");return r.addEventListener("popstate",n,!1),()=>r.removeEventListener("popstate",n)}onHashChange(n){const r=vb().getGlobalEventTarget(this._doc,"window");return r.addEventListener("hashchange",n,!1),()=>r.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,r,i){this._history.pushState(n,r,i)}replaceState(n,r,i){this._history.replaceState(n,r,i)}forward(){this._history.forward()}back(){this._history.back()}historyGo(n=0){this._history.go(n)}getState(){return this._history.state}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>new e,providedIn:"platform"})}return e})();function VN(e,t){if(0==e.length)return t;if(0==t.length)return e;let n=0;return e.endsWith("/")&&n++,t.startsWith("/")&&n++,2==n?e+t.substring(1):1==n?e+t:e+"/"+t}function lX(e){const t=e.match(/#|\?|$/),n=t&&t.index||e.length;return e.slice(0,n-("/"===e[n-1]?1:0))+e.slice(n)}function Qf(e){return e&&"?"!==e[0]?"?"+e:e}let _g=(()=>{class e{historyGo(n){throw new Error("")}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>bt(dX),providedIn:"root"})}return e})();const KA=new Yt("");let dX=(()=>{class e extends _g{constructor(n,r){super(),this._platformLocation=n,this._removeListenerFns=[],this._baseHref=r??this._platformLocation.getBaseHrefFromDOM()??bt(tu).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 VN(this._baseHref,n)}path(n=!1){const r=this._platformLocation.pathname+Qf(this._platformLocation.search),i=this._platformLocation.hash;return i&&n?`${r}${i}`:r}pushState(n,r,i,o){const s=this.prepareExternalUrl(i+Qf(o));this._platformLocation.pushState(n,r,s)}replaceState(n,r,i,o){const s=this.prepareExternalUrl(i+Qf(o));this._platformLocation.replaceState(n,r,s)}forward(){this._platformLocation.forward()}back(){this._platformLocation.back()}getState(){return this._platformLocation.getState()}historyGo(n=0){this._platformLocation.historyGo?.(n)}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(UN),Zt(KA,8))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})(),eIe=(()=>{class e extends _g{constructor(n,r){super(),this._platformLocation=n,this._baseHref="",this._removeListenerFns=[],null!=r&&(this._baseHref=r)}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}path(n=!1){const r=this._platformLocation.hash??"#";return r.length>0?r.substring(1):r}prepareExternalUrl(n){const r=VN(this._baseHref,n);return r.length>0?"#"+r:r}pushState(n,r,i,o){let s=this.prepareExternalUrl(i+Qf(o));0==s.length&&(s=this._platformLocation.pathname),this._platformLocation.pushState(n,r,s)}replaceState(n,r,i,o){let s=this.prepareExternalUrl(i+Qf(o));0==s.length&&(s=this._platformLocation.pathname),this._platformLocation.replaceState(n,r,s)}forward(){this._platformLocation.forward()}back(){this._platformLocation.back()}getState(){return this._platformLocation.getState()}historyGo(n=0){this._platformLocation.historyGo?.(n)}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(UN),Zt(KA,8))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})(),xx=(()=>{class e{constructor(n){this._subject=new Ua,this._urlChangeListeners=[],this._urlChangeSubscription=null,this._locationStrategy=n;const r=this._locationStrategy.getBaseHref();this._basePath=function rIe(e){if(new RegExp("^(https?:)?//").test(e)){const[,n]=e.split(/\/\/[^\/]+/);return n}return e}(lX(fX(r))),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,r=""){return this.path()==this.normalize(n+Qf(r))}normalize(n){return e.stripTrailingSlash(function nIe(e,t){if(!e||!t.startsWith(e))return t;const n=t.substring(e.length);return""===n||["/",";","?","#"].includes(n[0])?n:t}(this._basePath,fX(n)))}prepareExternalUrl(n){return n&&"/"!==n[0]&&(n="/"+n),this._locationStrategy.prepareExternalUrl(n)}go(n,r="",i=null){this._locationStrategy.pushState(i,"",n,r),this._notifyUrlChangeListeners(this.prepareExternalUrl(n+Qf(r)),i)}replaceState(n,r="",i=null){this._locationStrategy.replaceState(i,"",n,r),this._notifyUrlChangeListeners(this.prepareExternalUrl(n+Qf(r)),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.subscribe(r=>{this._notifyUrlChangeListeners(r.url,r.state)}),()=>{const r=this._urlChangeListeners.indexOf(n);this._urlChangeListeners.splice(r,1),0===this._urlChangeListeners.length&&(this._urlChangeSubscription?.unsubscribe(),this._urlChangeSubscription=null)}}_notifyUrlChangeListeners(n="",r){this._urlChangeListeners.forEach(i=>i(n,r))}subscribe(n,r,i){return this._subject.subscribe({next:n,error:r,complete:i})}static#e=this.normalizeQueryParams=Qf;static#t=this.joinWithSlash=VN;static#n=this.stripTrailingSlash=lX;static#r=this.\u0275fac=function(r){return new(r||e)(Zt(_g))};static#i=this.\u0275prov=Gt({token:e,factory:()=>function tIe(){return new xx(Zt(_g))}(),providedIn:"root"})}return e})();function fX(e){return e.replace(/\/index.html$/,"")}function xX(e,t){t=encodeURIComponent(t);for(const n of e.split(";")){const r=n.indexOf("="),[i,o]=-1==r?[n,""]:[n.slice(0,r),n.slice(r+1)];if(i.trim()===t)return decodeURIComponent(o)}return null}class KIe{createSubscription(t,n){return cX(()=>t.subscribe({next:n,error:r=>{throw r}}))}dispose(t){cX(()=>t.unsubscribe())}}class ZIe{createSubscription(t,n){return t.then(n,r=>{throw r})}dispose(t){}}const QIe=new ZIe,JIe=new KIe;let Cx=(()=>{class e{constructor(n){this._latestValue=null,this.markForCheckOnValueUpdate=!0,this._subscription=null,this._obj=null,this._strategy=null,this._ref=n}ngOnDestroy(){this._subscription&&this._dispose(),this._ref=null}transform(n){if(!this._obj){if(n)try{this.markForCheckOnValueUpdate=!1,this._subscribe(n)}finally{this.markForCheckOnValueUpdate=!0}return this._latestValue}return n!==this._obj?(this._dispose(),this.transform(n)):this._latestValue}_subscribe(n){this._obj=n,this._strategy=this._selectStrategy(n),this._subscription=this._strategy.createSubscription(n,r=>this._updateLatestValue(n,r))}_selectStrategy(n){if(OA(n))return QIe;if(vY(n))return JIe;throw function Wl(e,t){return new It(2100,!1)}()}_dispose(){this._strategy.dispose(this._subscription),this._latestValue=null,this._subscription=null,this._obj=null}_updateLatestValue(n,r){n===this._obj&&(this._latestValue=r,this.markForCheckOnValueUpdate&&this._ref?.markForCheck())}static#e=this.\u0275fac=function(r){return new(r||e)(cn(zA,16))};static#t=this.\u0275pipe=_c({name:"async",type:e,pure:!1,standalone:!0})}return e})(),cI=(()=>{class e{transform(n){return JSON.stringify(n,null,2)}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275pipe=_c({name:"json",type:e,pure:!1,standalone:!0})}return e})(),Uh=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275mod=f_({type:e});static#n=this.\u0275inj=Sy({})}return e})();const DX="browser";function EX(e){return"server"===e}let _Te=(()=>{class e{static#e=this.\u0275prov=Gt({token:e,providedIn:"root",factory:()=>function vTe(e){return e===DX}(bt(Th))?new xTe(bt(tu),window):new CTe})}return e})();class xTe{constructor(t,n){this.document=t,this.window=n,this.offset=()=>[0,0]}setOffset(t){this.offset=Array.isArray(t)?()=>t:t}getScrollPosition(){return[this.window.scrollX,this.window.scrollY]}scrollToPosition(t){this.window.scrollTo(t[0],t[1])}scrollToAnchor(t){const n=function STe(e,t){const n=e.getElementById(t)||e.getElementsByName(t)[0];if(n)return n;if("function"==typeof e.createTreeWalker&&e.body&&"function"==typeof e.body.attachShadow){const r=e.createTreeWalker(e.body,NodeFilter.SHOW_ELEMENT);let i=r.currentNode;for(;i;){const o=i.shadowRoot;if(o){const s=o.getElementById(t)||o.querySelector(`[name="${t}"]`);if(s)return s}i=r.nextNode()}}return null}(this.document,t);n&&(this.scrollToElement(n),n.focus())}setHistoryScrollRestoration(t){this.window.history.scrollRestoration=t}scrollToElement(t){const n=t.getBoundingClientRect(),r=n.left+this.window.pageXOffset,i=n.top+this.window.pageYOffset,o=this.offset();this.window.scrollTo(r-o[0],i-o[1])}}class CTe{setOffset(t){}getScrollPosition(){return[0,0]}scrollToPosition(t){}scrollToAnchor(t){}setHistoryScrollRestoration(t){}}class PX{}class ZTe extends ZAe{constructor(){super(...arguments),this.supportsDOMEvents=!0}}class nF extends ZTe{static makeCurrent(){!function KAe(e){uX??=e}(new nF)}onAndCancel(t,n,r){return t.addEventListener(n,r),()=>{t.removeEventListener(n,r)}}dispatchEvent(t,n){t.dispatchEvent(n)}remove(t){t.parentNode&&t.parentNode.removeChild(t)}createElement(t,n){return(n=n||this.getDefaultDocument()).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,n){return"window"===n?window:"document"===n?t:"body"===n?t.body:null}getBaseHref(t){const n=function QTe(){return Ix=Ix||document.querySelector("base"),Ix?Ix.getAttribute("href"):null}();return null==n?null:function JTe(e){return new URL(e,document.baseURI).pathname}(n)}resetBaseElement(){Ix=null}getUserAgent(){return window.navigator.userAgent}getCookie(t){return xX(document.cookie,t)}}let Ix=null,tDe=(()=>{class e{build(){return new XMLHttpRequest}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();const rF=new Yt("");let UX=(()=>{class e{constructor(n,r){this._zone=r,this._eventNameToPlugin=new Map,n.forEach(i=>{i.manager=this}),this._plugins=n.slice().reverse()}addEventListener(n,r,i){return this._findPluginFor(r).addEventListener(n,r,i)}getZone(){return this._zone}_findPluginFor(n){let r=this._eventNameToPlugin.get(n);if(r)return r;if(r=this._plugins.find(o=>o.supports(n)),!r)throw new It(5101,!1);return this._eventNameToPlugin.set(n,r),r}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(rF),Zt(Qr))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();class VX{constructor(t){this._doc=t}}const iF="ng-app-id";let zX=(()=>{class e{constructor(n,r,i,o={}){this.doc=n,this.appId=r,this.nonce=i,this.platformId=o,this.styleRef=new Map,this.hostNodes=new Set,this.styleNodesInDOM=this.collectServerRenderedStyles(),this.platformIsServer=EX(o),this.resetHostNodes()}addStyles(n){for(const r of n)1===this.changeUsageCount(r,1)&&this.onStyleAdded(r)}removeStyles(n){for(const r of n)this.changeUsageCount(r,-1)<=0&&this.onStyleRemoved(r)}ngOnDestroy(){const n=this.styleNodesInDOM;n&&(n.forEach(r=>r.remove()),n.clear());for(const r of this.getAllStyles())this.onStyleRemoved(r);this.resetHostNodes()}addHost(n){this.hostNodes.add(n);for(const r of this.getAllStyles())this.addStyleToHost(n,r)}removeHost(n){this.hostNodes.delete(n)}getAllStyles(){return this.styleRef.keys()}onStyleAdded(n){for(const r of this.hostNodes)this.addStyleToHost(r,n)}onStyleRemoved(n){const r=this.styleRef;r.get(n)?.elements?.forEach(i=>i.remove()),r.delete(n)}collectServerRenderedStyles(){const n=this.doc.head?.querySelectorAll(`style[${iF}="${this.appId}"]`);if(n?.length){const r=new Map;return n.forEach(i=>{null!=i.textContent&&r.set(i.textContent,i)}),r}return null}changeUsageCount(n,r){const i=this.styleRef;if(i.has(n)){const o=i.get(n);return o.usage+=r,o.usage}return i.set(n,{usage:r,elements:[]}),r}getStyleElement(n,r){const i=this.styleNodesInDOM,o=i?.get(r);if(o?.parentNode===n)return i.delete(r),o.removeAttribute(iF),o;{const s=this.doc.createElement("style");return this.nonce&&s.setAttribute("nonce",this.nonce),s.textContent=r,this.platformIsServer&&s.setAttribute(iF,this.appId),n.appendChild(s),s}}addStyleToHost(n,r){const i=this.getStyleElement(n,r),o=this.styleRef,s=o.get(r)?.elements;s?s.push(i):o.set(r,{elements:[i],usage:1})}resetHostNodes(){const n=this.hostNodes;n.clear(),n.add(this.doc.head)}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tu),Zt(IR),Zt(vj,8),Zt(Th))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();const oF={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/"},sF=/%COMP%/g,oDe=new Yt("",{providedIn:"root",factory:()=>!0});function jX(e,t){return t.map(n=>n.replace(sF,e))}let HX=(()=>{class e{constructor(n,r,i,o,s,a,c,u=null){this.eventManager=n,this.sharedStylesHost=r,this.appId=i,this.removeStylesOnCompDestroy=o,this.doc=s,this.platformId=a,this.ngZone=c,this.nonce=u,this.rendererByCompId=new Map,this.platformIsServer=EX(a),this.defaultRenderer=new aF(n,s,c,this.platformIsServer)}createRenderer(n,r){if(!n||!r)return this.defaultRenderer;this.platformIsServer&&r.encapsulation===Fl.ShadowDom&&(r={...r,encapsulation:Fl.Emulated});const i=this.getOrCreateRenderer(n,r);return i instanceof WX?i.applyToHost(n):i instanceof cF&&i.applyStyles(),i}getOrCreateRenderer(n,r){const i=this.rendererByCompId;let o=i.get(r.id);if(!o){const s=this.doc,a=this.ngZone,c=this.eventManager,u=this.sharedStylesHost,l=this.removeStylesOnCompDestroy,d=this.platformIsServer;switch(r.encapsulation){case Fl.Emulated:o=new WX(c,u,r,this.appId,l,s,a,d);break;case Fl.ShadowDom:return new uDe(c,u,n,r,s,a,this.nonce,d);default:o=new cF(c,u,r,l,s,a,d)}i.set(r.id,o)}return o}ngOnDestroy(){this.rendererByCompId.clear()}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(UX),Zt(zX),Zt(IR),Zt(oDe),Zt(tu),Zt(Th),Zt(Qr),Zt(vj))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();class aF{constructor(t,n,r,i){this.eventManager=t,this.doc=n,this.ngZone=r,this.platformIsServer=i,this.data=Object.create(null),this.throwOnSyntheticProps=!0,this.destroyNode=null}destroy(){}createElement(t,n){return n?this.doc.createElementNS(oF[n]||n,t):this.doc.createElement(t)}createComment(t){return this.doc.createComment(t)}createText(t){return this.doc.createTextNode(t)}appendChild(t,n){(qX(t)?t.content:t).appendChild(n)}insertBefore(t,n,r){t&&(qX(t)?t.content:t).insertBefore(n,r)}removeChild(t,n){t&&t.removeChild(n)}selectRootElement(t,n){let r="string"==typeof t?this.doc.querySelector(t):t;if(!r)throw new It(-5104,!1);return n||(r.textContent=""),r}parentNode(t){return t.parentNode}nextSibling(t){return t.nextSibling}setAttribute(t,n,r,i){if(i){n=i+":"+n;const o=oF[i];o?t.setAttributeNS(o,n,r):t.setAttribute(n,r)}else t.setAttribute(n,r)}removeAttribute(t,n,r){if(r){const i=oF[r];i?t.removeAttributeNS(i,n):t.removeAttribute(`${r}:${n}`)}else t.removeAttribute(n)}addClass(t,n){t.classList.add(n)}removeClass(t,n){t.classList.remove(n)}setStyle(t,n,r,i){i&(Ph.DashCase|Ph.Important)?t.style.setProperty(n,r,i&Ph.Important?"important":""):t.style[n]=r}removeStyle(t,n,r){r&Ph.DashCase?t.style.removeProperty(n):t.style[n]=""}setProperty(t,n,r){null!=t&&(t[n]=r)}setValue(t,n){t.nodeValue=n}listen(t,n,r){if("string"==typeof t&&!(t=vb().getGlobalEventTarget(this.doc,t)))throw new Error(`Unsupported event target ${t} for event ${n}`);return this.eventManager.addEventListener(t,n,this.decoratePreventDefault(r))}decoratePreventDefault(t){return n=>{if("__ngUnwrap__"===n)return t;!1===(this.platformIsServer?this.ngZone.runGuarded(()=>t(n)):t(n))&&n.preventDefault()}}}function qX(e){return"TEMPLATE"===e.tagName&&void 0!==e.content}class uDe extends aF{constructor(t,n,r,i,o,s,a,c){super(t,o,s,c),this.sharedStylesHost=n,this.hostEl=r,this.shadowRoot=r.attachShadow({mode:"open"}),this.sharedStylesHost.addHost(this.shadowRoot);const u=jX(i.id,i.styles);for(const l of u){const d=document.createElement("style");a&&d.setAttribute("nonce",a),d.textContent=l,this.shadowRoot.appendChild(d)}}nodeOrShadowRoot(t){return t===this.hostEl?this.shadowRoot:t}appendChild(t,n){return super.appendChild(this.nodeOrShadowRoot(t),n)}insertBefore(t,n,r){return super.insertBefore(this.nodeOrShadowRoot(t),n,r)}removeChild(t,n){return super.removeChild(this.nodeOrShadowRoot(t),n)}parentNode(t){return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(t)))}destroy(){this.sharedStylesHost.removeHost(this.shadowRoot)}}class cF extends aF{constructor(t,n,r,i,o,s,a,c){super(t,o,s,a),this.sharedStylesHost=n,this.removeStylesOnCompDestroy=i,this.styles=c?jX(c,r.styles):r.styles}applyStyles(){this.sharedStylesHost.addStyles(this.styles)}destroy(){this.removeStylesOnCompDestroy&&this.sharedStylesHost.removeStyles(this.styles)}}class WX extends cF{constructor(t,n,r,i,o,s,a,c){const u=i+"-"+r.id;super(t,n,r,o,s,a,c,u),this.contentAttr=function sDe(e){return"_ngcontent-%COMP%".replace(sF,e)}(u),this.hostAttr=function aDe(e){return"_nghost-%COMP%".replace(sF,e)}(u)}applyToHost(t){this.applyStyles(),this.setAttribute(t,this.hostAttr,"")}createElement(t,n){const r=super.createElement(t,n);return super.setAttribute(r,this.contentAttr,""),r}}let lDe=(()=>{class e extends VX{constructor(n){super(n)}supports(n){return!0}addEventListener(n,r,i){return n.addEventListener(r,i,!1),()=>this.removeEventListener(n,r,i)}removeEventListener(n,r,i){return n.removeEventListener(r,i)}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tu))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();const $X=["alt","control","meta","shift"],dDe={"\b":"Backspace","\t":"Tab","\x7f":"Delete","\x1b":"Escape",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown",Menu:"ContextMenu",Scroll:"ScrollLock",Win:"OS"},fDe={alt:e=>e.altKey,control:e=>e.ctrlKey,meta:e=>e.metaKey,shift:e=>e.shiftKey};let pDe=(()=>{class e extends VX{constructor(n){super(n)}supports(n){return null!=e.parseEventName(n)}addEventListener(n,r,i){const o=e.parseEventName(r),s=e.eventCallback(o.fullKey,i,this.manager.getZone());return this.manager.getZone().runOutsideAngular(()=>vb().onAndCancel(n,o.domEventName,s))}static parseEventName(n){const r=n.toLowerCase().split("."),i=r.shift();if(0===r.length||"keydown"!==i&&"keyup"!==i)return null;const o=e._normalizeKey(r.pop());let s="",a=r.indexOf("code");if(a>-1&&(r.splice(a,1),s="code."),$X.forEach(u=>{const l=r.indexOf(u);l>-1&&(r.splice(l,1),s+=u+".")}),s+=o,0!=r.length||0===o.length)return null;const c={};return c.domEventName=i,c.fullKey=s,c}static matchEventFullKeyCode(n,r){let i=dDe[n.key]||n.key,o="";return r.indexOf("code.")>-1&&(i=n.code,o="code."),!(null==i||!i)&&(i=i.toLowerCase()," "===i?i="space":"."===i&&(i="dot"),$X.forEach(s=>{s!==i&&(0,fDe[s])(n)&&(o+=s+".")}),o+=i,o===r)}static eventCallback(n,r,i){return o=>{e.matchEventFullKeyCode(o,n)&&i.runGuarded(()=>r(o))}}static _normalizeKey(n){return"esc"===n?"escape":n}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tu))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();function YX(e){return{appProviders:[..._De,...e?.providers??[]],platformProviders:bDe}}const bDe=[{provide:Th,useValue:DX},{provide:bj,useValue:function mDe(){nF.makeCurrent()},multi:!0},{provide:tu,useFactory:function yDe(){return function ive(e){AR=e}(document),document},deps:[]}],_De=[{provide:VM,useValue:"root"},{provide:Ld,useFactory:function gDe(){return new Ld},deps:[]},{provide:rF,useClass:lDe,multi:!0,deps:[tu,Qr,Th]},{provide:rF,useClass:pDe,multi:!0,deps:[tu]},HX,zX,UX,{provide:zH,useExisting:HX},{provide:PX,useClass:tDe,deps:[]},[]];let xDe=(()=>{class e{constructor(n){this._doc=n}getTitle(){return this._doc.title}setTitle(n){this._doc.title=n||""}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tu))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function Vh(e){return this instanceof Vh?(this.v=e,this):new Vh(e)}function tK(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,t=e[Symbol.asyncIterator];return t?t.call(e):(e=function fF(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(s){return new Promise(function(a,c){!function i(o,s,a,c){Promise.resolve(c).then(function(u){o({value:u,done:a})},s)}(a,c,(s=e[o](s)).done,s.value)})}}}"function"==typeof SuppressedError&&SuppressedError;const nK=e=>e&&"number"==typeof e.length&&"function"!=typeof e;function rK(e){return Wi(e?.then)}function iK(e){return Wi(e[gM])}function oK(e){return Symbol.asyncIterator&&Wi(e?.[Symbol.asyncIterator])}function sK(e){return new TypeError(`You provided ${null!==e&&"object"==typeof e?"an invalid object":`'${e}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}const aK=function $De(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}();function cK(e){return Wi(e?.[aK])}function uK(e){return function eK(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(e,t||[]),o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(f){r[f]&&(i[f]=function(p){return new Promise(function(m,h){o.push([f,p,m,h])>1||a(f,p)})})}function a(f,p){try{!function c(f){f.value instanceof Vh?Promise.resolve(f.value.v).then(u,l):d(o[0][2],f)}(r[f](p))}catch(m){d(o[0][3],m)}}function u(f){a("next",f)}function l(f){a("throw",f)}function d(f,p){f(p),o.shift(),o.length&&a(o[0][0],o[0][1])}}(this,arguments,function*(){const n=e.getReader();try{for(;;){const{value:r,done:i}=yield Vh(n.read());if(i)return yield Vh(void 0);yield yield Vh(r)}}finally{n.releaseLock()}})}function lK(e){return Wi(e?.getReader)}function ru(e){if(e instanceof ns)return e;if(null!=e){if(iK(e))return function YDe(e){return new ns(t=>{const n=e[gM]();if(Wi(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}(e);if(nK(e))return function XDe(e){return new ns(t=>{for(let n=0;n{e.then(n=>{t.closed||(t.next(n),t.complete())},n=>t.error(n)).then(null,_G)})}(e);if(oK(e))return dK(e);if(cK(e))return function ZDe(e){return new ns(t=>{for(const n of e)if(t.next(n),t.closed)return;t.complete()})}(e);if(lK(e))return function QDe(e){return dK(uK(e))}(e)}throw sK(e)}function dK(e){return new ns(t=>{(function JDe(e,t){var n,r,i,o;return function QX(e,t,n,r){return new(n||(n=Promise))(function(o,s){function a(l){try{u(r.next(l))}catch(d){s(d)}}function c(l){try{u(r.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):function i(o){return o instanceof n?o:new n(function(s){s(o)})}(l.value).then(a,c)}u((r=r.apply(e,t||[])).next())})}(this,void 0,void 0,function*(){try{for(n=tK(e);!(r=yield n.next()).done;)if(t.next(r.value),t.closed)return}catch(s){i={error:s}}finally{try{r&&!r.done&&(o=n.return)&&(yield o.call(n))}finally{if(i)throw i.error}}t.complete()})})(e,t).catch(n=>t.error(n))})}function tp(e,t,n,r=0,i=!1){const o=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(o),!i)return o}function fK(e,t=0){return mo((n,r)=>{n.subscribe(Io(r,i=>tp(r,e,()=>r.next(i),t),()=>tp(r,e,()=>r.complete(),t),i=>tp(r,e,()=>r.error(i),t)))})}function pK(e,t=0){return mo((n,r)=>{r.add(e.schedule(()=>n.subscribe(r),t))})}function hK(e,t){if(!e)throw new Error("Iterable cannot be null");return new ns(n=>{tp(n,t,()=>{const r=e[Symbol.asyncIterator]();tp(n,t,()=>{r.next().then(i=>{i.done?n.complete():n.next(i.value)})},0,!0)})})}function $i(e,t){return t?function oEe(e,t){if(null!=e){if(iK(e))return function eEe(e,t){return ru(e).pipe(pK(t),fK(t))}(e,t);if(nK(e))return function nEe(e,t){return new ns(n=>{let r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}(e,t);if(rK(e))return function tEe(e,t){return ru(e).pipe(pK(t),fK(t))}(e,t);if(oK(e))return hK(e,t);if(cK(e))return function rEe(e,t){return new ns(n=>{let r;return tp(n,t,()=>{r=e[aK](),tp(n,t,()=>{let i,o;try{({value:i,done:o}=r.next())}catch(s){return void n.error(s)}o?n.complete():n.next(i)},0,!0)}),()=>Wi(r?.return)&&r.return()})}(e,t);if(lK(e))return function iEe(e,t){return hK(uK(e),t)}(e,t)}throw sK(e)}(e,t):ru(e)}function mK(e){return e&&Wi(e.schedule)}function pF(e){return e[e.length-1]}function gK(e){return Wi(pF(e))?e.pop():void 0}function xb(e){return mK(pF(e))?e.pop():void 0}function yK(e,t){return"number"==typeof pF(e)?e.pop():t}function Pn(...e){return $i(e,xb(e))}const{isArray:sEe}=Array,{getPrototypeOf:aEe,prototype:cEe,keys:uEe}=Object;const{isArray:fEe}=Array;function bK(e){return qt(t=>function pEe(e,t){return fEe(t)?e(...t):e(t)}(e,t))}function dI(...e){const t=xb(e),n=gK(e),{args:r,keys:i}=function lEe(e){if(1===e.length){const t=e[0];if(sEe(t))return{args:t,keys:null};if(function dEe(e){return e&&"object"==typeof e&&aEe(e)===cEe}(t)){const n=uEe(t);return{args:n.map(r=>t[r]),keys:n}}}return{args:e,keys:null}}(e);if(0===r.length)return $i([],t);const o=new ns(vK(r,t,i?s=>function hEe(e,t){return e.reduce((n,r,i)=>(n[r]=t[i],n),{})}(i,s):vh));return n?o.pipe(bK(n)):o}function vK(e,t,n=vh){return r=>{_K(t,()=>{const{length:i}=e,o=new Array(i);let s=i,a=i;for(let c=0;c{const u=$i(e[c],t);let l=!1;u.subscribe(Io(r,d=>{o[c]=d,l||(l=!0,a--),a||r.next(n(o.slice()))},()=>{--s||r.complete()}))},r)},r)}}function _K(e,t,n){e?tp(n,e,t):t()}const fI=uM(e=>function(){e(this),this.name="EmptyError",this.message="no elements in sequence"});function fa(e,t,n=1/0){return Wi(t)?fa((r,i)=>qt((o,s)=>t(r,o,i,s))(ru(e(r,i))),n):("number"==typeof t&&(n=t),mo((r,i)=>function mEe(e,t,n,r,i,o,s,a){const c=[];let u=0,l=0,d=!1;const f=()=>{d&&!c.length&&!u&&t.complete()},p=h=>u{o&&t.next(h),u++;let g=!1;ru(n(h,l++)).subscribe(Io(t,y=>{i?.(y),o?p(y):t.next(y)},()=>{g=!0},void 0,()=>{if(g)try{for(u--;c.length&&um(y)):m(y)}f()}catch(y){t.error(y)}}))};return e.subscribe(Io(t,p,()=>{d=!0,f()})),()=>{a?.()}}(r,i,e,n)))}function xg(e=1/0){return fa(vh,e)}function hF(...e){return function gEe(){return xg(1)}()($i(e,xb(e)))}function xK(e){return new ns(t=>{ru(e()).subscribe(t)})}function pI(e,t){const n=Wi(e)?e:()=>e,r=i=>i.error(n());return new ns(t?i=>t.schedule(r,0,i):r)}const $l=new ns(e=>e.complete());function mF(){return mo((e,t)=>{let n=null;e._refCount++;const r=Io(t,void 0,void 0,void 0,()=>{if(!e||e._refCount<=0||0<--e._refCount)return void(n=null);const i=e._connection,o=n;n=null,i&&(!o||i===o)&&i.unsubscribe(),t.unsubscribe()});e.subscribe(r),r.closed||(n=e.connect())})}class SK extends ns{constructor(t,n){super(),this.source=t,this.subjectFactory=n,this._subject=null,this._refCount=0,this._connection=null,AG(t)&&(this.lift=t.lift)}_subscribe(t){return this.getSubject().subscribe(t)}getSubject(){const t=this._subject;return(!t||t.isStopped)&&(this._subject=this.subjectFactory()),this._subject}_teardown(){this._refCount=0;const{_connection:t}=this;this._subject=this._connection=null,t?.unsubscribe()}connect(){let t=this._connection;if(!t){t=this._connection=new Fa;const n=this.getSubject();t.add(this.source.subscribe(Io(n,void 0,()=>{this._teardown(),n.complete()},r=>{this._teardown(),n.error(r)},()=>this._teardown()))),t.closed&&(this._connection=null,t=Fa.EMPTY)}return t}refCount(){return mF()(this)}}function To(e,t){return mo((n,r)=>{let i=null,o=0,s=!1;const a=()=>s&&!i&&r.complete();n.subscribe(Io(r,c=>{i?.unsubscribe();let u=0;const l=o++;ru(e(c,l)).subscribe(i=Io(r,d=>r.next(t?t(c,d,l,u++):d),()=>{i=null,a()}))},()=>{s=!0,a()}))})}function Sg(e){return e<=0?()=>$l:mo((t,n)=>{let r=0;t.subscribe(Io(n,i=>{++r<=e&&(n.next(i),e<=r&&n.complete())}))})}function Dx(...e){const t=xb(e);return mo((n,r)=>{(t?hF(e,n,t):hF(e,n)).subscribe(r)})}function Yl(e,t){return mo((n,r)=>{let i=0;n.subscribe(Io(r,o=>e.call(t,o,i++)&&r.next(o)))})}function hI(e){return mo((t,n)=>{let r=!1;t.subscribe(Io(n,i=>{r=!0,n.next(i)},()=>{r||n.next(e),n.complete()}))})}function CK(e=bEe){return mo((t,n)=>{let r=!1;t.subscribe(Io(n,i=>{r=!0,n.next(i)},()=>r?n.complete():n.error(e())))})}function bEe(){return new fI}function Cg(e,t){const n=arguments.length>=2;return r=>r.pipe(e?Yl((i,o)=>e(i,o,r)):vh,Sg(1),n?hI(t):CK(()=>new fI))}function Sb(e,t){return Wi(t)?fa(e,t,1):fa(e,1)}function jr(e,t,n){const r=Wi(e)||t||n?{next:e,error:t,complete:n}:e;return r?mo((i,o)=>{var s;null===(s=r.subscribe)||void 0===s||s.call(r);let a=!0;i.subscribe(Io(o,c=>{var u;null===(u=r.next)||void 0===u||u.call(r,c),o.next(c)},()=>{var c;a=!1,null===(c=r.complete)||void 0===c||c.call(r),o.complete()},c=>{var u;a=!1,null===(u=r.error)||void 0===u||u.call(r,c),o.error(c)},()=>{var c,u;a&&(null===(c=r.unsubscribe)||void 0===c||c.call(r)),null===(u=r.finalize)||void 0===u||u.call(r)}))}):vh}function Cb(e){return mo((t,n)=>{let o,r=null,i=!1;r=t.subscribe(Io(n,void 0,void 0,s=>{o=ru(e(s,Cb(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,o.subscribe(n))})}function gF(e){return e<=0?()=>$l:mo((t,n)=>{let r=[];t.subscribe(Io(n,i=>{r.push(i),e{for(const i of r)n.next(i);n.complete()},void 0,()=>{r=null}))})}function Ex(e){return mo((t,n)=>{try{t.subscribe(n)}finally{n.add(e)}})}const rr="primary",Px=Symbol("RouteTitle");class wEe{constructor(t){this.params=t||{}}has(t){return Object.prototype.hasOwnProperty.call(this.params,t)}get(t){if(this.has(t)){const n=this.params[t];return Array.isArray(n)?n[0]:n}return null}getAll(t){if(this.has(t)){const n=this.params[t];return Array.isArray(n)?n:[n]}return[]}get keys(){return Object.keys(this.params)}}function wb(e){return new wEe(e)}function AEe(e,t,n){const r=n.path.split("/");if(r.length>e.length||"full"===n.pathMatch&&(t.hasChildren()||r.lengthr[o]===i)}return e===t}function AK(e){return e.length>0?e[e.length-1]:null}function zh(e){return function ADe(e){return!!e&&(e instanceof ns||Wi(e.lift)&&Wi(e.subscribe))}(e)?e:OA(e)?$i(Promise.resolve(e)):Pn(e)}const TEe={exact:function DK(e,t,n){if(!wg(e.segments,t.segments)||!mI(e.segments,t.segments,n)||e.numberOfChildren!==t.numberOfChildren)return!1;for(const r in t.children)if(!e.children[r]||!DK(e.children[r],t.children[r],n))return!1;return!0},subset:EK},IK={exact:function DEe(e,t){return Hd(e,t)},subset:function EEe(e,t){return Object.keys(t).length<=Object.keys(e).length&&Object.keys(t).every(n=>wK(e[n],t[n]))},ignored:()=>!0};function TK(e,t,n){return TEe[n.paths](e.root,t.root,n.matrixParams)&&IK[n.queryParams](e.queryParams,t.queryParams)&&!("exact"===n.fragment&&e.fragment!==t.fragment)}function EK(e,t,n){return PK(e,t,t.segments,n)}function PK(e,t,n,r){if(e.segments.length>n.length){const i=e.segments.slice(0,n.length);return!(!wg(i,n)||t.hasChildren()||!mI(i,n,r))}if(e.segments.length===n.length){if(!wg(e.segments,n)||!mI(e.segments,n,r))return!1;for(const i in t.children)if(!e.children[i]||!EK(e.children[i],t.children[i],r))return!1;return!0}{const i=n.slice(0,e.segments.length),o=n.slice(e.segments.length);return!!(wg(e.segments,i)&&mI(e.segments,i,r)&&e.children[rr])&&PK(e.children[rr],t,o,r)}}function mI(e,t,n){return t.every((r,i)=>IK[n](e[i].parameters,r.parameters))}class Ab{constructor(t=new xi([],{}),n={},r=null){this.root=t,this.queryParams=n,this.fragment=r}get queryParamMap(){return this._queryParamMap??=wb(this.queryParams),this._queryParamMap}toString(){return REe.serialize(this)}}class xi{constructor(t,n){this.segments=t,this.children=n,this.parent=null,Object.values(n).forEach(r=>r.parent=this)}hasChildren(){return this.numberOfChildren>0}get numberOfChildren(){return Object.keys(this.children).length}toString(){return gI(this)}}class Mx{constructor(t,n){this.path=t,this.parameters=n}get parameterMap(){return this._parameterMap??=wb(this.parameters),this._parameterMap}toString(){return kK(this)}}function wg(e,t){return e.length===t.length&&e.every((n,r)=>n.path===t[r].path)}let Ib=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>new bF,providedIn:"root"})}return e})();class bF{parse(t){const n=new jEe(t);return new Ab(n.parseRootSegment(),n.parseQueryParams(),n.parseFragment())}serialize(t){const n=`/${Rx(t.root,!0)}`,r=function FEe(e){const t=Object.entries(e).map(([n,r])=>Array.isArray(r)?r.map(i=>`${yI(n)}=${yI(i)}`).join("&"):`${yI(n)}=${yI(r)}`).filter(n=>n);return t.length?`?${t.join("&")}`:""}(t.queryParams);return`${n}${r}${"string"==typeof t.fragment?`#${function kEe(e){return encodeURI(e)}(t.fragment)}`:""}`}}const REe=new bF;function gI(e){return e.segments.map(t=>kK(t)).join("/")}function Rx(e,t){if(!e.hasChildren())return gI(e);if(t){const n=e.children[rr]?Rx(e.children[rr],!1):"",r=[];return Object.entries(e.children).forEach(([i,o])=>{i!==rr&&r.push(`${i}:${Rx(o,!1)}`)}),r.length>0?`${n}(${r.join("//")})`:n}{const n=function MEe(e,t){let n=[];return Object.entries(e.children).forEach(([r,i])=>{r===rr&&(n=n.concat(t(i,r)))}),Object.entries(e.children).forEach(([r,i])=>{r!==rr&&(n=n.concat(t(i,r)))}),n}(e,(r,i)=>i===rr?[Rx(e.children[rr],!1)]:[`${i}:${Rx(r,!1)}`]);return 1===Object.keys(e.children).length&&null!=e.children[rr]?`${gI(e)}/${n[0]}`:`${gI(e)}/(${n.join("//")})`}}function MK(e){return encodeURIComponent(e).replace(/%40/g,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",")}function yI(e){return MK(e).replace(/%3B/gi,";")}function vF(e){return MK(e).replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/%26/gi,"&")}function bI(e){return decodeURIComponent(e)}function RK(e){return bI(e.replace(/\+/g,"%20"))}function kK(e){return`${vF(e.path)}${function NEe(e){return Object.entries(e).map(([t,n])=>`;${vF(t)}=${vF(n)}`).join("")}(e.parameters)}`}const BEe=/^[^\/()?;#]+/;function _F(e){const t=e.match(BEe);return t?t[0]:""}const OEe=/^[^\/()?;=#]+/,UEe=/^[^=?&#]+/,zEe=/^[^&#]+/;class jEe{constructor(t){this.url=t,this.remaining=t}parseRootSegment(){return this.consumeOptional("/"),""===this.remaining||this.peekStartsWith("?")||this.peekStartsWith("#")?new xi([],{}):new xi([],this.parseChildren())}parseQueryParams(){const 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("/");const t=[];for(this.peekStartsWith("(")||t.push(this.parseSegment());this.peekStartsWith("/")&&!this.peekStartsWith("//")&&!this.peekStartsWith("/(");)this.capture("/"),t.push(this.parseSegment());let n={};this.peekStartsWith("/(")&&(this.capture("/"),n=this.parseParens(!0));let r={};return this.peekStartsWith("(")&&(r=this.parseParens(!1)),(t.length>0||Object.keys(n).length>0)&&(r[rr]=new xi(t,n)),r}parseSegment(){const t=_F(this.remaining);if(""===t&&this.peekStartsWith(";"))throw new It(4009,!1);return this.capture(t),new Mx(bI(t),this.parseMatrixParams())}parseMatrixParams(){const t={};for(;this.consumeOptional(";");)this.parseParam(t);return t}parseParam(t){const n=function LEe(e){const t=e.match(OEe);return t?t[0]:""}(this.remaining);if(!n)return;this.capture(n);let r="";if(this.consumeOptional("=")){const i=_F(this.remaining);i&&(r=i,this.capture(r))}t[bI(n)]=bI(r)}parseQueryParam(t){const n=function VEe(e){const t=e.match(UEe);return t?t[0]:""}(this.remaining);if(!n)return;this.capture(n);let r="";if(this.consumeOptional("=")){const s=function GEe(e){const t=e.match(zEe);return t?t[0]:""}(this.remaining);s&&(r=s,this.capture(r))}const i=RK(n),o=RK(r);if(t.hasOwnProperty(i)){let s=t[i];Array.isArray(s)||(s=[s],t[i]=s),s.push(o)}else t[i]=o}parseParens(t){const n={};for(this.capture("(");!this.consumeOptional(")")&&this.remaining.length>0;){const r=_F(this.remaining),i=this.remaining[r.length];if("/"!==i&&")"!==i&&";"!==i)throw new It(4010,!1);let o;r.indexOf(":")>-1?(o=r.slice(0,r.indexOf(":")),this.capture(o),this.capture(":")):t&&(o=rr);const s=this.parseChildren();n[o]=1===Object.keys(s).length?s[rr]:new xi([],s),this.consumeOptional("//")}return n}peekStartsWith(t){return this.remaining.startsWith(t)}consumeOptional(t){return!!this.peekStartsWith(t)&&(this.remaining=this.remaining.substring(t.length),!0)}capture(t){if(!this.consumeOptional(t))throw new It(4011,!1)}}function NK(e){return e.segments.length>0?new xi([],{[rr]:e}):e}function FK(e){const t={};for(const[r,i]of Object.entries(e.children)){const o=FK(i);if(r===rr&&0===o.segments.length&&o.hasChildren())for(const[s,a]of Object.entries(o.children))t[s]=a;else(o.segments.length>0||o.hasChildren())&&(t[r]=o)}return function HEe(e){if(1===e.numberOfChildren&&e.children[rr]){const t=e.children[rr];return new xi(e.segments.concat(t.segments),t.children)}return e}(new xi(e.segments,t))}function Tb(e){return e instanceof Ab}function BK(e){let t;const r=function n(o){const s={};for(const c of o.children){const u=n(c);s[c.outlet]=u}const a=new xi(o.url,s);return o===e&&(t=a),a}(e.root),i=NK(r);return t??i}function OK(e,t,n,r){let i=e;for(;i.parent;)i=i.parent;if(0===t.length)return xF(i,i,i,n,r);const o=function WEe(e){if("string"==typeof e[0]&&1===e.length&&"/"===e[0])return new UK(!0,0,e);let t=0,n=!1;const r=e.reduce((i,o,s)=>{if("object"==typeof o&&null!=o){if(o.outlets){const a={};return Object.entries(o.outlets).forEach(([c,u])=>{a[c]="string"==typeof u?u.split("/"):u}),[...i,{outlets:a}]}if(o.segmentPath)return[...i,o.segmentPath]}return"string"!=typeof o?[...i,o]:0===s?(o.split("/").forEach((a,c)=>{0==c&&"."===a||(0==c&&""===a?n=!0:".."===a?t++:""!=a&&i.push(a))}),i):[...i,o]},[]);return new UK(n,t,r)}(t);if(o.toRoot())return xF(i,i,new xi([],{}),n,r);const s=function $Ee(e,t,n){if(e.isAbsolute)return new _I(t,!0,0);if(!n)return new _I(t,!1,NaN);if(null===n.parent)return new _I(n,!0,0);const r=vI(e.commands[0])?0:1;return function YEe(e,t,n){let r=e,i=t,o=n;for(;o>i;){if(o-=i,r=r.parent,!r)throw new It(4005,!1);i=r.segments.length}return new _I(r,!1,i-o)}(n,n.segments.length-1+r,e.numberOfDoubleDots)}(o,i,e),a=s.processChildren?Nx(s.segmentGroup,s.index,o.commands):VK(s.segmentGroup,s.index,o.commands);return xF(i,s.segmentGroup,a,n,r)}function vI(e){return"object"==typeof e&&null!=e&&!e.outlets&&!e.segmentPath}function kx(e){return"object"==typeof e&&null!=e&&e.outlets}function xF(e,t,n,r,i){let s,o={};r&&Object.entries(r).forEach(([c,u])=>{o[c]=Array.isArray(u)?u.map(l=>`${l}`):`${u}`}),s=e===t?n:LK(e,t,n);const a=NK(FK(s));return new Ab(a,o,i)}function LK(e,t,n){const r={};return Object.entries(e.children).forEach(([i,o])=>{r[i]=o===t?n:LK(o,t,n)}),new xi(e.segments,r)}class UK{constructor(t,n,r){if(this.isAbsolute=t,this.numberOfDoubleDots=n,this.commands=r,t&&r.length>0&&vI(r[0]))throw new It(4003,!1);const i=r.find(kx);if(i&&i!==AK(r))throw new It(4004,!1)}toRoot(){return this.isAbsolute&&1===this.commands.length&&"/"==this.commands[0]}}class _I{constructor(t,n,r){this.segmentGroup=t,this.processChildren=n,this.index=r}}function VK(e,t,n){if(e??=new xi([],{}),0===e.segments.length&&e.hasChildren())return Nx(e,t,n);const r=function KEe(e,t,n){let r=0,i=t;const o={match:!1,pathIndex:0,commandIndex:0};for(;i=n.length)return o;const s=e.segments[i],a=n[r];if(kx(a))break;const c=`${a}`,u=r0&&void 0===c)break;if(c&&u&&"object"==typeof u&&void 0===u.outlets){if(!GK(c,u,s))return o;r+=2}else{if(!GK(c,{},s))return o;r++}i++}return{match:!0,pathIndex:i,commandIndex:r}}(e,t,n),i=n.slice(r.commandIndex);if(r.match&&r.pathIndexo!==rr)&&e.children[rr]&&1===e.numberOfChildren&&0===e.children[rr].segments.length){const o=Nx(e.children[rr],t,n);return new xi(e.segments,o.children)}return Object.entries(r).forEach(([o,s])=>{"string"==typeof s&&(s=[s]),null!==s&&(i[o]=VK(e.children[o],t,s))}),Object.entries(e.children).forEach(([o,s])=>{void 0===r[o]&&(i[o]=s)}),new xi(e.segments,i)}}function SF(e,t,n){const r=e.segments.slice(0,t);let i=0;for(;i{"string"==typeof r&&(r=[r]),null!==r&&(t[n]=SF(new xi([],{}),0,r))}),t}function zK(e){const t={};return Object.entries(e).forEach(([n,r])=>t[n]=`${r}`),t}function GK(e,t,n){return e==n.path&&Hd(t,n.parameters)}const Fx="imperative";var Dr=function(e){return e[e.NavigationStart=0]="NavigationStart",e[e.NavigationEnd=1]="NavigationEnd",e[e.NavigationCancel=2]="NavigationCancel",e[e.NavigationError=3]="NavigationError",e[e.RoutesRecognized=4]="RoutesRecognized",e[e.ResolveStart=5]="ResolveStart",e[e.ResolveEnd=6]="ResolveEnd",e[e.GuardsCheckStart=7]="GuardsCheckStart",e[e.GuardsCheckEnd=8]="GuardsCheckEnd",e[e.RouteConfigLoadStart=9]="RouteConfigLoadStart",e[e.RouteConfigLoadEnd=10]="RouteConfigLoadEnd",e[e.ChildActivationStart=11]="ChildActivationStart",e[e.ChildActivationEnd=12]="ChildActivationEnd",e[e.ActivationStart=13]="ActivationStart",e[e.ActivationEnd=14]="ActivationEnd",e[e.Scroll=15]="Scroll",e[e.NavigationSkipped=16]="NavigationSkipped",e}(Dr||{});class qd{constructor(t,n){this.id=t,this.url=n}}class xI extends qd{constructor(t,n,r="imperative",i=null){super(t,n),this.type=Dr.NavigationStart,this.navigationTrigger=r,this.restoredState=i}toString(){return`NavigationStart(id: ${this.id}, url: '${this.url}')`}}class np extends qd{constructor(t,n,r){super(t,n),this.urlAfterRedirects=r,this.type=Dr.NavigationEnd}toString(){return`NavigationEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}')`}}var iu=function(e){return e[e.Redirect=0]="Redirect",e[e.SupersededByNewNavigation=1]="SupersededByNewNavigation",e[e.NoDataFromResolver=2]="NoDataFromResolver",e[e.GuardRejected=3]="GuardRejected",e}(iu||{}),SI=function(e){return e[e.IgnoredSameUrlNavigation=0]="IgnoredSameUrlNavigation",e[e.IgnoredByUrlHandlingStrategy=1]="IgnoredByUrlHandlingStrategy",e}(SI||{});class Db extends qd{constructor(t,n,r,i){super(t,n),this.reason=r,this.code=i,this.type=Dr.NavigationCancel}toString(){return`NavigationCancel(id: ${this.id}, url: '${this.url}')`}}class Eb extends qd{constructor(t,n,r,i){super(t,n),this.reason=r,this.code=i,this.type=Dr.NavigationSkipped}}class CI extends qd{constructor(t,n,r,i){super(t,n),this.error=r,this.target=i,this.type=Dr.NavigationError}toString(){return`NavigationError(id: ${this.id}, url: '${this.url}', error: ${this.error})`}}class jK extends qd{constructor(t,n,r,i){super(t,n),this.urlAfterRedirects=r,this.state=i,this.type=Dr.RoutesRecognized}toString(){return`RoutesRecognized(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}}class QEe extends qd{constructor(t,n,r,i){super(t,n),this.urlAfterRedirects=r,this.state=i,this.type=Dr.GuardsCheckStart}toString(){return`GuardsCheckStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}}class JEe extends qd{constructor(t,n,r,i,o){super(t,n),this.urlAfterRedirects=r,this.state=i,this.shouldActivate=o,this.type=Dr.GuardsCheckEnd}toString(){return`GuardsCheckEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state}, shouldActivate: ${this.shouldActivate})`}}class e3e extends qd{constructor(t,n,r,i){super(t,n),this.urlAfterRedirects=r,this.state=i,this.type=Dr.ResolveStart}toString(){return`ResolveStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}}class t3e extends qd{constructor(t,n,r,i){super(t,n),this.urlAfterRedirects=r,this.state=i,this.type=Dr.ResolveEnd}toString(){return`ResolveEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}}class n3e{constructor(t){this.route=t,this.type=Dr.RouteConfigLoadStart}toString(){return`RouteConfigLoadStart(path: ${this.route.path})`}}class r3e{constructor(t){this.route=t,this.type=Dr.RouteConfigLoadEnd}toString(){return`RouteConfigLoadEnd(path: ${this.route.path})`}}class i3e{constructor(t){this.snapshot=t,this.type=Dr.ChildActivationStart}toString(){return`ChildActivationStart(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}}class o3e{constructor(t){this.snapshot=t,this.type=Dr.ChildActivationEnd}toString(){return`ChildActivationEnd(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}}class s3e{constructor(t){this.snapshot=t,this.type=Dr.ActivationStart}toString(){return`ActivationStart(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}}class a3e{constructor(t){this.snapshot=t,this.type=Dr.ActivationEnd}toString(){return`ActivationEnd(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}}class HK{constructor(t,n,r){this.routerEvent=t,this.position=n,this.anchor=r,this.type=Dr.Scroll}toString(){return`Scroll(anchor: '${this.anchor}', position: '${this.position?`${this.position[0]}, ${this.position[1]}`:null}')`}}class CF{}class wF{constructor(t){this.url=t}}class c3e{constructor(){this.outlet=null,this.route=null,this.injector=null,this.children=new Bx,this.attachRef=null}}let Bx=(()=>{class e{constructor(){this.contexts=new Map}onChildOutletCreated(n,r){const i=this.getOrCreateContext(n);i.outlet=r,this.contexts.set(n,i)}onChildOutletDestroyed(n){const r=this.getContext(n);r&&(r.outlet=null,r.attachRef=null)}onOutletDeactivated(){const n=this.contexts;return this.contexts=new Map,n}onOutletReAttached(n){this.contexts=n}getOrCreateContext(n){let r=this.getContext(n);return r||(r=new c3e,this.contexts.set(n,r)),r}getContext(n){return this.contexts.get(n)||null}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();class qK{constructor(t){this._root=t}get root(){return this._root.value}parent(t){const n=this.pathFromRoot(t);return n.length>1?n[n.length-2]:null}children(t){const n=AF(t,this._root);return n?n.children.map(r=>r.value):[]}firstChild(t){const n=AF(t,this._root);return n&&n.children.length>0?n.children[0].value:null}siblings(t){const n=IF(t,this._root);return n.length<2?[]:n[n.length-2].children.map(i=>i.value).filter(i=>i!==t)}pathFromRoot(t){return IF(t,this._root).map(n=>n.value)}}function AF(e,t){if(e===t.value)return t;for(const n of t.children){const r=AF(e,n);if(r)return r}return null}function IF(e,t){if(e===t.value)return[t];for(const n of t.children){const r=IF(e,n);if(r.length)return r.unshift(t),r}return[]}class Xl{constructor(t,n){this.value=t,this.children=n}toString(){return`TreeNode(${this.value})`}}function Pb(e){const t={};return e&&e.children.forEach(n=>t[n.value.outlet]=n),t}class WK extends qK{constructor(t,n){super(t),this.snapshot=n,EF(this,t)}toString(){return this.snapshot.toString()}}function $K(e){const t=function u3e(e){const o=new DF([],{},{},"",{},rr,e,null,{});return new YK("",new Xl(o,[]))}(e),n=new Ao([new Mx("",{})]),r=new Ao({}),i=new Ao({}),o=new Ao({}),s=new Ao(""),a=new Mb(n,r,o,s,i,rr,e,t.root);return a.snapshot=t.root,new WK(new Xl(a,[]),t)}class Mb{constructor(t,n,r,i,o,s,a,c){this.urlSubject=t,this.paramsSubject=n,this.queryParamsSubject=r,this.fragmentSubject=i,this.dataSubject=o,this.outlet=s,this.component=a,this._futureSnapshot=c,this.title=this.dataSubject?.pipe(qt(u=>u[Px]))??Pn(void 0),this.url=t,this.params=n,this.queryParams=r,this.fragment=i,this.data=o}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.params.pipe(qt(t=>wb(t))),this._paramMap}get queryParamMap(){return this._queryParamMap??=this.queryParams.pipe(qt(t=>wb(t))),this._queryParamMap}toString(){return this.snapshot?this.snapshot.toString():`Future(${this._futureSnapshot})`}}function TF(e,t,n="emptyOnly"){let r;const{routeConfig:i}=e;return r=null===t||"always"!==n&&""!==i?.path&&(t.component||t.routeConfig?.loadComponent)?{params:{...e.params},data:{...e.data},resolve:{...e.data,...e._resolvedData??{}}}:{params:{...t.params,...e.params},data:{...t.data,...e.data},resolve:{...e.data,...t.data,...i?.data,...e._resolvedData}},i&&KK(i)&&(r.resolve[Px]=i.title),r}class DF{get title(){return this.data?.[Px]}constructor(t,n,r,i,o,s,a,c,u){this.url=t,this.params=n,this.queryParams=r,this.fragment=i,this.data=o,this.outlet=s,this.component=a,this.routeConfig=c,this._resolve=u}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??=wb(this.params),this._paramMap}get queryParamMap(){return this._queryParamMap??=wb(this.queryParams),this._queryParamMap}toString(){return`Route(url:'${this.url.map(r=>r.toString()).join("/")}', path:'${this.routeConfig?this.routeConfig.path:""}')`}}class YK extends qK{constructor(t,n){super(n),this.url=t,EF(this,n)}toString(){return XK(this._root)}}function EF(e,t){t.value._routerState=e,t.children.forEach(n=>EF(e,n))}function XK(e){const t=e.children.length>0?` { ${e.children.map(XK).join(", ")} } `:"";return`${e.value}${t}`}function PF(e){if(e.snapshot){const t=e.snapshot,n=e._futureSnapshot;e.snapshot=n,Hd(t.queryParams,n.queryParams)||e.queryParamsSubject.next(n.queryParams),t.fragment!==n.fragment&&e.fragmentSubject.next(n.fragment),Hd(t.params,n.params)||e.paramsSubject.next(n.params),function IEe(e,t){if(e.length!==t.length)return!1;for(let n=0;nHd(n.parameters,t[r].parameters))}(e.url,t.url);return n&&!(!e.parent!=!t.parent)&&(!e.parent||MF(e.parent,t.parent))}function KK(e){return"string"==typeof e.title||null===e.title}let RF=(()=>{class e{constructor(){this.activated=null,this._activatedRoute=null,this.name=rr,this.activateEvents=new Ua,this.deactivateEvents=new Ua,this.attachEvents=new Ua,this.detachEvents=new Ua,this.parentContexts=bt(Bx),this.location=bt(Gl),this.changeDetector=bt(zA),this.environmentInjector=bt(xc),this.inputBinder=bt(wI,{optional:!0}),this.supportsBindingToComponentInputs=!0}get activatedComponentRef(){return this.activated}ngOnChanges(n){if(n.name){const{firstChange:r,previousValue:i}=n.name;if(r)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;const 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 It(4012,!1);return this.activated.instance}get activatedRoute(){if(!this.activated)throw new It(4012,!1);return this._activatedRoute}get activatedRouteData(){return this._activatedRoute?this._activatedRoute.snapshot.data:{}}detach(){if(!this.activated)throw new It(4012,!1);this.location.detach();const n=this.activated;return this.activated=null,this._activatedRoute=null,this.detachEvents.emit(n.instance),n}attach(n,r){this.activated=n,this._activatedRoute=r,this.location.insert(n.hostView),this.inputBinder?.bindActivatedRouteToOutletComponent(this),this.attachEvents.emit(n.instance)}deactivate(){if(this.activated){const n=this.component;this.activated.destroy(),this.activated=null,this._activatedRoute=null,this.deactivateEvents.emit(n)}}activateWith(n,r){if(this.isActivated)throw new It(4013,!1);this._activatedRoute=n;const i=this.location,s=n.snapshot.component,a=this.parentContexts.getOrCreateContext(this.name).children,c=new l3e(n,a,i.injector);this.activated=i.createComponent(s,{index:i.length,injector:c,environmentInjector:r??this.environmentInjector}),this.changeDetector.markForCheck(),this.inputBinder?.bindActivatedRouteToOutletComponent(this),this.activateEvents.emit(this.activated.instance)}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275dir=Ba({type:e,selectors:[["router-outlet"]],inputs:{name:"name"},outputs:{activateEvents:"activate",deactivateEvents:"deactivate",attachEvents:"attach",detachEvents:"detach"},exportAs:["outlet"],standalone:!0,features:[wh]})}return e})();class l3e{constructor(t,n,r){this.route=t,this.childContexts=n,this.parent=r}get(t,n){return t===Mb?this.route:t===Bx?this.childContexts:this.parent.get(t,n)}}const wI=new Yt("");let ZK=(()=>{class e{constructor(){this.outletDataSubscriptions=new Map}bindActivatedRouteToOutletComponent(n){this.unsubscribeFromRouteData(n),this.subscribeToRouteData(n)}unsubscribeFromRouteData(n){this.outletDataSubscriptions.get(n)?.unsubscribe(),this.outletDataSubscriptions.delete(n)}subscribeToRouteData(n){const{activatedRoute:r}=n,i=dI([r.queryParams,r.params,r.data]).pipe(To(([o,s,a],c)=>(a={...o,...s,...a},0===c?Pn(a):Promise.resolve(a)))).subscribe(o=>{if(!n.isActivated||!n.activatedComponentRef||n.activatedRoute!==r||null===r.component)return void this.unsubscribeFromRouteData(n);const s=function XAe(e){const t=dr(e);if(!t)return null;const n=new Q_(t);return{get selector(){return n.selector},get type(){return n.componentType},get inputs(){return n.inputs},get outputs(){return n.outputs},get ngContentSelectors(){return n.ngContentSelectors},get isStandalone(){return t.standalone},get isSignal(){return t.signals}}}(r.component);if(s)for(const{templateName:a}of s.inputs)n.activatedComponentRef.setInput(a,o[a]);else this.unsubscribeFromRouteData(n)});this.outletDataSubscriptions.set(n,i)}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();function Ox(e,t,n){if(n&&e.shouldReuseRoute(t.value,n.value.snapshot)){const r=n.value;r._futureSnapshot=t.value;const i=function f3e(e,t,n){return t.children.map(r=>{for(const i of n.children)if(e.shouldReuseRoute(r.value,i.value.snapshot))return Ox(e,r,i);return Ox(e,r)})}(e,t,n);return new Xl(r,i)}{if(e.shouldAttach(t.value)){const o=e.retrieve(t.value);if(null!==o){const s=o.route;return s.value._futureSnapshot=t.value,s.children=t.children.map(a=>Ox(e,a)),s}}const r=function p3e(e){return new Mb(new Ao(e.url),new Ao(e.params),new Ao(e.queryParams),new Ao(e.fragment),new Ao(e.data),e.outlet,e.component,e)}(t.value),i=t.children.map(o=>Ox(e,o));return new Xl(r,i)}}const QK="ngNavigationCancelingError";function JK(e,t){const{redirectTo:n,navigationBehaviorOptions:r}=Tb(t)?{redirectTo:t,navigationBehaviorOptions:void 0}:t,i=eZ(!1,iu.Redirect);return i.url=n,i.navigationBehaviorOptions=r,i}function eZ(e,t){const n=new Error(`NavigationCancelingError: ${e||""}`);return n[QK]=!0,n.cancellationCode=t,n}function tZ(e){return!!e&&e[QK]}let nZ=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["ng-component"]],standalone:!0,features:[Nu],decls:1,vars:0,template:function(r,i){1&r&&gi(0,"router-outlet")},dependencies:[RF],encapsulation:2})}return e})();function kF(e){const t=e.children&&e.children.map(kF),n=t?{...e,children:t}:{...e};return!n.component&&!n.loadComponent&&(t||n.loadChildren)&&n.outlet&&n.outlet!==rr&&(n.component=nZ),n}function Wd(e){return e.outlet||rr}function Lx(e){if(!e)return null;if(e.routeConfig?._injector)return e.routeConfig._injector;for(let t=e.parent;t;t=t.parent){const n=t.routeConfig;if(n?._loadedInjector)return n._loadedInjector;if(n?._injector)return n._injector}return null}class x3e{constructor(t,n,r,i,o){this.routeReuseStrategy=t,this.futureState=n,this.currState=r,this.forwardEvent=i,this.inputBindingEnabled=o}activate(t){const n=this.futureState._root,r=this.currState?this.currState._root:null;this.deactivateChildRoutes(n,r,t),PF(this.futureState.root),this.activateChildRoutes(n,r,t)}deactivateChildRoutes(t,n,r){const i=Pb(n);t.children.forEach(o=>{const s=o.value.outlet;this.deactivateRoutes(o,i[s],r),delete i[s]}),Object.values(i).forEach(o=>{this.deactivateRouteAndItsChildren(o,r)})}deactivateRoutes(t,n,r){const i=t.value,o=n?n.value:null;if(i===o)if(i.component){const s=r.getContext(i.outlet);s&&this.deactivateChildRoutes(t,n,s.children)}else this.deactivateChildRoutes(t,n,r);else o&&this.deactivateRouteAndItsChildren(n,r)}deactivateRouteAndItsChildren(t,n){t.value.component&&this.routeReuseStrategy.shouldDetach(t.value.snapshot)?this.detachAndStoreRouteSubtree(t,n):this.deactivateRouteAndOutlet(t,n)}detachAndStoreRouteSubtree(t,n){const r=n.getContext(t.value.outlet),i=r&&t.value.component?r.children:n,o=Pb(t);for(const s of Object.values(o))this.deactivateRouteAndItsChildren(s,i);if(r&&r.outlet){const s=r.outlet.detach(),a=r.children.onOutletDeactivated();this.routeReuseStrategy.store(t.value.snapshot,{componentRef:s,route:t,contexts:a})}}deactivateRouteAndOutlet(t,n){const r=n.getContext(t.value.outlet),i=r&&t.value.component?r.children:n,o=Pb(t);for(const s of Object.values(o))this.deactivateRouteAndItsChildren(s,i);r&&(r.outlet&&(r.outlet.deactivate(),r.children.onOutletDeactivated()),r.attachRef=null,r.route=null)}activateChildRoutes(t,n,r){const i=Pb(n);t.children.forEach(o=>{this.activateRoutes(o,i[o.value.outlet],r),this.forwardEvent(new a3e(o.value.snapshot))}),t.children.length&&this.forwardEvent(new o3e(t.value.snapshot))}activateRoutes(t,n,r){const i=t.value,o=n?n.value:null;if(PF(i),i===o)if(i.component){const s=r.getOrCreateContext(i.outlet);this.activateChildRoutes(t,n,s.children)}else this.activateChildRoutes(t,n,r);else if(i.component){const s=r.getOrCreateContext(i.outlet);if(this.routeReuseStrategy.shouldAttach(i.snapshot)){const a=this.routeReuseStrategy.retrieve(i.snapshot);this.routeReuseStrategy.store(i.snapshot,null),s.children.onOutletReAttached(a.contexts),s.attachRef=a.componentRef,s.route=a.route.value,s.outlet&&s.outlet.attach(a.componentRef,a.route.value),PF(a.route.value),this.activateChildRoutes(t,null,s.children)}else{const a=Lx(i.snapshot);s.attachRef=null,s.route=i,s.injector=a,s.outlet&&s.outlet.activateWith(i,s.injector),this.activateChildRoutes(t,null,s.children)}}else this.activateChildRoutes(t,null,r)}}class rZ{constructor(t){this.path=t,this.route=this.path[this.path.length-1]}}class AI{constructor(t,n){this.component=t,this.route=n}}function S3e(e,t,n){const r=e._root;return Ux(r,t?t._root:null,n,[r.value])}function Rb(e,t){const n=Symbol(),r=t.get(e,n);return r===n?"function"!=typeof e||function N0e(e){return null!==iw(e)}(e)?t.get(e):e:r}function Ux(e,t,n,r,i={canDeactivateChecks:[],canActivateChecks:[]}){const o=Pb(t);return e.children.forEach(s=>{(function w3e(e,t,n,r,i={canDeactivateChecks:[],canActivateChecks:[]}){const o=e.value,s=t?t.value:null,a=n?n.getContext(e.value.outlet):null;if(s&&o.routeConfig===s.routeConfig){const c=function A3e(e,t,n){if("function"==typeof n)return n(e,t);switch(n){case"pathParamsChange":return!wg(e.url,t.url);case"pathParamsOrQueryParamsChange":return!wg(e.url,t.url)||!Hd(e.queryParams,t.queryParams);case"always":return!0;case"paramsOrQueryParamsChange":return!MF(e,t)||!Hd(e.queryParams,t.queryParams);default:return!MF(e,t)}}(s,o,o.routeConfig.runGuardsAndResolvers);c?i.canActivateChecks.push(new rZ(r)):(o.data=s.data,o._resolvedData=s._resolvedData),Ux(e,t,o.component?a?a.children:null:n,r,i),c&&a&&a.outlet&&a.outlet.isActivated&&i.canDeactivateChecks.push(new AI(a.outlet.component,s))}else s&&Vx(t,a,i),i.canActivateChecks.push(new rZ(r)),Ux(e,null,o.component?a?a.children:null:n,r,i)})(s,o[s.value.outlet],n,r.concat([s.value]),i),delete o[s.value.outlet]}),Object.entries(o).forEach(([s,a])=>Vx(a,n.getContext(s),i)),i}function Vx(e,t,n){const r=Pb(e),i=e.value;Object.entries(r).forEach(([o,s])=>{Vx(s,i.component?t?t.children.getContext(o):null:t,n)}),n.canDeactivateChecks.push(new AI(i.component&&t&&t.outlet&&t.outlet.isActivated?t.outlet.component:null,i))}function zx(e){return"function"==typeof e}function iZ(e){return e instanceof fI||"EmptyError"===e?.name}const II=Symbol("INITIAL_VALUE");function kb(){return To(e=>dI(e.map(t=>t.pipe(Sg(1),Dx(II)))).pipe(qt(t=>{for(const n of t)if(!0!==n){if(n===II)return II;if(!1===n||n instanceof Ab)return n}return!0}),Yl(t=>t!==II),Sg(1)))}function oZ(e){return xG(jr(t=>{if(Tb(t))throw JK(0,t)}),qt(t=>!0===t))}class NF{constructor(t){this.segmentGroup=t||null}}class FF extends Error{constructor(t){super(),this.urlTree=t}}function Nb(e){return pI(new NF(e))}class H3e{constructor(t,n){this.urlSerializer=t,this.urlTree=n}lineralizeSegments(t,n){let r=[],i=n.root;for(;;){if(r=r.concat(i.segments),0===i.numberOfChildren)return Pn(r);if(i.numberOfChildren>1||!i.children[rr])return pI(new It(4e3,!1));i=i.children[rr]}}applyRedirectCommands(t,n,r){const i=this.applyRedirectCreateUrlTree(n,this.urlSerializer.parse(n),t,r);if(n.startsWith("/"))throw new FF(i);return i}applyRedirectCreateUrlTree(t,n,r,i){const o=this.createSegmentGroup(t,n.root,r,i);return new Ab(o,this.createQueryParams(n.queryParams,this.urlTree.queryParams),n.fragment)}createQueryParams(t,n){const r={};return Object.entries(t).forEach(([i,o])=>{if("string"==typeof o&&o.startsWith(":")){const a=o.substring(1);r[i]=n[a]}else r[i]=o}),r}createSegmentGroup(t,n,r,i){const o=this.createSegments(t,n.segments,r,i);let s={};return Object.entries(n.children).forEach(([a,c])=>{s[a]=this.createSegmentGroup(t,c,r,i)}),new xi(o,s)}createSegments(t,n,r,i){return n.map(o=>o.path.startsWith(":")?this.findPosParam(t,o,i):this.findOrReturn(o,r))}findPosParam(t,n,r){const i=r[n.path.substring(1)];if(!i)throw new It(4001,!1);return i}findOrReturn(t,n){let r=0;for(const i of n){if(i.path===t.path)return n.splice(r),i;r++}return t}}const BF={matched:!1,consumedSegments:[],remainingSegments:[],parameters:{},positionalParamSegments:{}};function q3e(e,t,n,r,i){const o=OF(e,t,n);return o.matched?(r=function m3e(e,t){return e.providers&&!e._injector&&(e._injector=hA(e.providers,t,`Route: ${e.path}`)),e._injector??t}(t,r),function z3e(e,t,n,r){const i=t.canMatch;return i&&0!==i.length?Pn(i.map(s=>{const a=Rb(s,e);return zh(function M3e(e){return e&&zx(e.canMatch)}(a)?a.canMatch(t,n):Md(e,()=>a(t,n)))})).pipe(kb(),oZ()):Pn(!0)}(r,t,n).pipe(qt(s=>!0===s?o:{...BF}))):Pn(o)}function OF(e,t,n){if("**"===t.path)return function W3e(e){return{matched:!0,parameters:e.length>0?AK(e).parameters:{},consumedSegments:e,remainingSegments:[],positionalParamSegments:{}}}(n);if(""===t.path)return"full"===t.pathMatch&&(e.hasChildren()||n.length>0)?{...BF}:{matched:!0,consumedSegments:[],remainingSegments:n,parameters:{},positionalParamSegments:{}};const i=(t.matcher||AEe)(n,e,t);if(!i)return{...BF};const o={};Object.entries(i.posParams??{}).forEach(([a,c])=>{o[a]=c.path});const s=i.consumed.length>0?{...o,...i.consumed[i.consumed.length-1].parameters}:o;return{matched:!0,consumedSegments:i.consumed,remainingSegments:n.slice(i.consumed.length),parameters:s,positionalParamSegments:i.posParams??{}}}function sZ(e,t,n,r){return n.length>0&&function X3e(e,t,n){return n.some(r=>TI(e,t,r)&&Wd(r)!==rr)}(e,n,r)?{segmentGroup:new xi(t,Y3e(r,new xi(n,e.children))),slicedSegments:[]}:0===n.length&&function K3e(e,t,n){return n.some(r=>TI(e,t,r))}(e,n,r)?{segmentGroup:new xi(e.segments,$3e(e,n,r,e.children)),slicedSegments:n}:{segmentGroup:new xi(e.segments,e.children),slicedSegments:n}}function $3e(e,t,n,r){const i={};for(const o of n)if(TI(e,t,o)&&!r[Wd(o)]){const s=new xi([],{});i[Wd(o)]=s}return{...r,...i}}function Y3e(e,t){const n={};n[rr]=t;for(const r of e)if(""===r.path&&Wd(r)!==rr){const i=new xi([],{});n[Wd(r)]=i}return n}function TI(e,t,n){return(!(e.hasChildren()||t.length>0)||"full"!==n.pathMatch)&&""===n.path}class J3e{}class nPe{constructor(t,n,r,i,o,s,a){this.injector=t,this.configLoader=n,this.rootComponentType=r,this.config=i,this.urlTree=o,this.paramsInheritanceStrategy=s,this.urlSerializer=a,this.applyRedirects=new H3e(this.urlSerializer,this.urlTree),this.absoluteRedirectCount=0,this.allowRedirects=!0}noMatchError(t){return new It(4002,`'${t.segmentGroup}'`)}recognize(){const t=sZ(this.urlTree.root,[],[],this.config).segmentGroup;return this.match(t).pipe(qt(n=>{const r=new DF([],Object.freeze({}),Object.freeze({...this.urlTree.queryParams}),this.urlTree.fragment,{},rr,this.rootComponentType,null,{}),i=new Xl(r,n),o=new YK("",i),s=function qEe(e,t,n=null,r=null){return OK(BK(e),t,n,r)}(r,[],this.urlTree.queryParams,this.urlTree.fragment);return s.queryParams=this.urlTree.queryParams,o.url=this.urlSerializer.serialize(s),this.inheritParamsAndData(o._root,null),{state:o,tree:s}}))}match(t){return this.processSegmentGroup(this.injector,this.config,t,rr).pipe(Cb(r=>{if(r instanceof FF)return this.urlTree=r.urlTree,this.match(r.urlTree.root);throw r instanceof NF?this.noMatchError(r):r}))}inheritParamsAndData(t,n){const r=t.value,i=TF(r,n,this.paramsInheritanceStrategy);r.params=Object.freeze(i.params),r.data=Object.freeze(i.data),t.children.forEach(o=>this.inheritParamsAndData(o,r))}processSegmentGroup(t,n,r,i){return 0===r.segments.length&&r.hasChildren()?this.processChildren(t,n,r):this.processSegment(t,n,r,r.segments,i,!0).pipe(qt(o=>o instanceof Xl?[o]:[]))}processChildren(t,n,r){const i=[];for(const o of Object.keys(r.children))"primary"===o?i.unshift(o):i.push(o);return $i(i).pipe(Sb(o=>{const s=r.children[o],a=function v3e(e,t){const n=e.filter(r=>Wd(r)===t);return n.push(...e.filter(r=>Wd(r)!==t)),n}(n,o);return this.processSegmentGroup(t,a,s,o)}),function _Ee(e,t){return mo(function vEe(e,t,n,r,i){return(o,s)=>{let a=n,c=t,u=0;o.subscribe(Io(s,l=>{const d=u++;c=a?e(c,l,d):(a=!0,l),r&&s.next(c)},i&&(()=>{a&&s.next(c),s.complete()})))}}(e,t,arguments.length>=2,!0))}((o,s)=>(o.push(...s),o)),hI(null),function xEe(e,t){const n=arguments.length>=2;return r=>r.pipe(e?Yl((i,o)=>e(i,o,r)):vh,gF(1),n?hI(t):CK(()=>new fI))}(),fa(o=>{if(null===o)return Nb(r);const s=aZ(o);return function rPe(e){e.sort((t,n)=>t.value.outlet===rr?-1:n.value.outlet===rr?1:t.value.outlet.localeCompare(n.value.outlet))}(s),Pn(s)}))}processSegment(t,n,r,i,o,s){return $i(n).pipe(Sb(a=>this.processSegmentAgainstRoute(a._injector??t,n,a,r,i,o,s).pipe(Cb(c=>{if(c instanceof NF)return Pn(null);throw c}))),Cg(a=>!!a),Cb(a=>{if(iZ(a))return function Q3e(e,t,n){return 0===t.length&&!e.children[n]}(r,i,o)?Pn(new J3e):Nb(r);throw a}))}processSegmentAgainstRoute(t,n,r,i,o,s,a){return function Z3e(e,t,n,r){return!!(Wd(e)===r||r!==rr&&TI(t,n,e))&&OF(t,e,n).matched}(r,i,o,s)?void 0===r.redirectTo?this.matchSegmentAgainstRoute(t,i,r,o,s):this.allowRedirects&&a?this.expandSegmentAgainstRouteUsingRedirect(t,i,n,r,o,s):Nb(i):Nb(i)}expandSegmentAgainstRouteUsingRedirect(t,n,r,i,o,s){const{matched:a,consumedSegments:c,positionalParamSegments:u,remainingSegments:l}=OF(n,i,o);if(!a)return Nb(n);i.redirectTo.startsWith("/")&&(this.absoluteRedirectCount++,this.absoluteRedirectCount>31&&(this.allowRedirects=!1));const d=this.applyRedirects.applyRedirectCommands(c,i.redirectTo,u);return this.applyRedirects.lineralizeSegments(i,d).pipe(fa(f=>this.processSegment(t,r,n,f.concat(l),s,!1)))}matchSegmentAgainstRoute(t,n,r,i,o){const s=q3e(n,r,i,t);return"**"===r.path&&(n.children={}),s.pipe(To(a=>a.matched?this.getChildConfig(t=r._injector??t,r,i).pipe(To(({routes:c})=>{const u=r._loadedInjector??t,{consumedSegments:l,remainingSegments:d,parameters:f}=a,p=new DF(l,f,Object.freeze({...this.urlTree.queryParams}),this.urlTree.fragment,function oPe(e){return e.data||{}}(r),Wd(r),r.component??r._loadedComponent??null,r,function sPe(e){return e.resolve||{}}(r)),{segmentGroup:m,slicedSegments:h}=sZ(n,l,d,c);if(0===h.length&&m.hasChildren())return this.processChildren(u,c,m).pipe(qt(y=>null===y?null:new Xl(p,y)));if(0===c.length&&0===h.length)return Pn(new Xl(p,[]));const g=Wd(r)===o;return this.processSegment(u,c,m,h,g?rr:o,!0).pipe(qt(y=>new Xl(p,y instanceof Xl?[y]:[])))})):Nb(n)))}getChildConfig(t,n,r){return n.children?Pn({routes:n.children,injector:t}):n.loadChildren?void 0!==n._loadedRoutes?Pn({routes:n._loadedRoutes,injector:n._loadedInjector}):function V3e(e,t,n,r){const i=t.canLoad;return void 0===i||0===i.length?Pn(!0):Pn(i.map(s=>{const a=Rb(s,e);return zh(function T3e(e){return e&&zx(e.canLoad)}(a)?a.canLoad(t,n):Md(e,()=>a(t,n)))})).pipe(kb(),oZ())}(t,n,r).pipe(fa(i=>i?this.configLoader.loadChildren(t,n).pipe(jr(o=>{n._loadedRoutes=o.routes,n._loadedInjector=o.injector})):function j3e(e){return pI(eZ(!1,iu.GuardRejected))}())):Pn({routes:[],injector:t})}}function iPe(e){const t=e.value.routeConfig;return t&&""===t.path}function aZ(e){const t=[],n=new Set;for(const r of e){if(!iPe(r)){t.push(r);continue}const i=t.find(o=>r.value.routeConfig===o.value.routeConfig);void 0!==i?(i.children.push(...r.children),n.add(i)):t.push(r)}for(const r of n){const i=aZ(r.children);t.push(new Xl(r.value,i))}return t.filter(r=>!n.has(r))}function cZ(e){const t=e.children.map(n=>cZ(n)).flat();return[e,...t]}function LF(e){return To(t=>{const n=e(t);return n?$i(n).pipe(qt(()=>t)):Pn(t)})}let uZ=(()=>{class e{buildTitle(n){let r,i=n.root;for(;void 0!==i;)r=this.getResolvedTitleForRoute(i)??r,i=i.children.find(o=>o.outlet===rr);return r}getResolvedTitleForRoute(n){return n.data[Px]}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>bt(fPe),providedIn:"root"})}return e})(),fPe=(()=>{class e extends uZ{constructor(n){super(),this.title=n}updateTitle(n){const r=this.buildTitle(n);void 0!==r&&this.title.setTitle(r)}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(xDe))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();const Fb=new Yt("",{providedIn:"root",factory:()=>({})}),Bb=new Yt("");let UF=(()=>{class e{constructor(){this.componentLoaders=new WeakMap,this.childrenLoaders=new WeakMap,this.compiler=bt(CY)}loadComponent(n){if(this.componentLoaders.get(n))return this.componentLoaders.get(n);if(n._loadedComponent)return Pn(n._loadedComponent);this.onLoadStartListener&&this.onLoadStartListener(n);const r=zh(n.loadComponent()).pipe(qt(lZ),jr(o=>{this.onLoadEndListener&&this.onLoadEndListener(n),n._loadedComponent=o}),Ex(()=>{this.componentLoaders.delete(n)})),i=new SK(r,()=>new mr).pipe(mF());return this.componentLoaders.set(n,i),i}loadChildren(n,r){if(this.childrenLoaders.get(r))return this.childrenLoaders.get(r);if(r._loadedRoutes)return Pn({routes:r._loadedRoutes,injector:r._loadedInjector});this.onLoadStartListener&&this.onLoadStartListener(r);const o=function pPe(e,t,n,r){return zh(e.loadChildren()).pipe(qt(lZ),fa(i=>i instanceof kq||Array.isArray(i)?Pn(i):$i(t.compileModuleAsync(i))),qt(i=>{r&&r(e);let o,s,a=!1;return Array.isArray(i)?(s=i,!0):(o=i.create(n).injector,s=o.get(Bb,[],{optional:!0,self:!0}).flat()),{routes:s.map(kF),injector:o}}))}(r,this.compiler,n,this.onLoadEndListener).pipe(Ex(()=>{this.childrenLoaders.delete(r)})),s=new SK(o,()=>new mr).pipe(mF());return this.childrenLoaders.set(r,s),s}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function lZ(e){return function hPe(e){return e&&"object"==typeof e&&"default"in e}(e)?e.default:e}let VF=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>bt(mPe),providedIn:"root"})}return e})(),mPe=(()=>{class e{shouldProcessUrl(n){return!0}extract(n){return n}merge(n,r){return n}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();const dZ=new Yt(""),fZ=new Yt("");function gPe(e,t,n){const r=e.get(fZ),i=e.get(tu);return e.get(Qr).runOutsideAngular(()=>{if(!i.startViewTransition||r.skipNextTransition)return r.skipNextTransition=!1,Promise.resolve();let o;const s=new Promise(u=>{o=u}),a=i.startViewTransition(()=>(o(),function yPe(e){return new Promise(t=>{YH(t,{injector:e})})}(e))),{onViewTransitionCreated:c}=r;return c&&Md(e,()=>c({transition:a,from:t,to:n})),s})}let DI=(()=>{class e{get hasRequestedNavigation(){return 0!==this.navigationId}constructor(){this.currentNavigation=null,this.currentTransition=null,this.lastSuccessfulNavigation=null,this.events=new mr,this.transitionAbortSubject=new mr,this.configLoader=bt(UF),this.environmentInjector=bt(xc),this.urlSerializer=bt(Ib),this.rootContexts=bt(Bx),this.location=bt(xx),this.inputBindingEnabled=null!==bt(wI,{optional:!0}),this.titleStrategy=bt(uZ),this.options=bt(Fb,{optional:!0})||{},this.paramsInheritanceStrategy=this.options.paramsInheritanceStrategy||"emptyOnly",this.urlHandlingStrategy=bt(VF),this.createViewTransition=bt(dZ,{optional:!0}),this.navigationId=0,this.afterPreactivation=()=>Pn(void 0),this.rootComponentType=null,this.configLoader.onLoadEndListener=i=>this.events.next(new r3e(i)),this.configLoader.onLoadStartListener=i=>this.events.next(new n3e(i))}complete(){this.transitions?.complete()}handleNavigationRequest(n){const r=++this.navigationId;this.transitions?.next({...this.transitions.value,...n,id:r})}setupNavigations(n,r,i){return this.transitions=new Ao({id:0,currentUrlTree:r,currentRawUrl:r,extractedUrl:this.urlHandlingStrategy.extract(r),urlAfterRedirects:this.urlHandlingStrategy.extract(r),rawUrl:r,extras:{},resolve:null,reject:null,promise:Promise.resolve(!0),source:Fx,restoredState:null,currentSnapshot:i.snapshot,targetSnapshot:null,currentRouterState:i,targetRouterState:null,guards:{canActivateChecks:[],canDeactivateChecks:[]},guardsResult:null}),this.transitions.pipe(Yl(o=>0!==o.id),qt(o=>({...o,extractedUrl:this.urlHandlingStrategy.extract(o.rawUrl)})),To(o=>{let s=!1,a=!1;return Pn(o).pipe(To(c=>{if(this.navigationId>o.id)return this.cancelNavigationTransition(o,"",iu.SupersededByNewNavigation),$l;this.currentTransition=o,this.currentNavigation={id:c.id,initialUrl:c.rawUrl,extractedUrl:c.extractedUrl,trigger:c.source,extras:c.extras,previousNavigation:this.lastSuccessfulNavigation?{...this.lastSuccessfulNavigation,previousNavigation:null}:null};const u=!n.navigated||this.isUpdatingInternalState()||this.isUpdatedBrowserUrl();if(!u&&"reload"!==(c.extras.onSameUrlNavigation??n.onSameUrlNavigation)){const d="";return this.events.next(new Eb(c.id,this.urlSerializer.serialize(c.rawUrl),d,SI.IgnoredSameUrlNavigation)),c.resolve(null),$l}if(this.urlHandlingStrategy.shouldProcessUrl(c.rawUrl))return Pn(c).pipe(To(d=>{const f=this.transitions?.getValue();return this.events.next(new xI(d.id,this.urlSerializer.serialize(d.extractedUrl),d.source,d.restoredState)),f!==this.transitions?.getValue()?$l:Promise.resolve(d)}),function aPe(e,t,n,r,i,o){return fa(s=>function ePe(e,t,n,r,i,o,s="emptyOnly"){return new nPe(e,t,n,r,i,s,o).recognize()}(e,t,n,r,s.extractedUrl,i,o).pipe(qt(({state:a,tree:c})=>({...s,targetSnapshot:a,urlAfterRedirects:c}))))}(this.environmentInjector,this.configLoader,this.rootComponentType,n.config,this.urlSerializer,this.paramsInheritanceStrategy),jr(d=>{o.targetSnapshot=d.targetSnapshot,o.urlAfterRedirects=d.urlAfterRedirects,this.currentNavigation={...this.currentNavigation,finalUrl:d.urlAfterRedirects};const f=new jK(d.id,this.urlSerializer.serialize(d.extractedUrl),this.urlSerializer.serialize(d.urlAfterRedirects),d.targetSnapshot);this.events.next(f)}));if(u&&this.urlHandlingStrategy.shouldProcessUrl(c.currentRawUrl)){const{id:d,extractedUrl:f,source:p,restoredState:m,extras:h}=c,g=new xI(d,this.urlSerializer.serialize(f),p,m);this.events.next(g);const y=$K(this.rootComponentType).snapshot;return this.currentTransition=o={...c,targetSnapshot:y,urlAfterRedirects:f,extras:{...h,skipLocationChange:!1,replaceUrl:!1}},this.currentNavigation.finalUrl=f,Pn(o)}{const d="";return this.events.next(new Eb(c.id,this.urlSerializer.serialize(c.extractedUrl),d,SI.IgnoredByUrlHandlingStrategy)),c.resolve(null),$l}}),jr(c=>{const u=new QEe(c.id,this.urlSerializer.serialize(c.extractedUrl),this.urlSerializer.serialize(c.urlAfterRedirects),c.targetSnapshot);this.events.next(u)}),qt(c=>(this.currentTransition=o={...c,guards:S3e(c.targetSnapshot,c.currentSnapshot,this.rootContexts)},o)),function R3e(e,t){return fa(n=>{const{targetSnapshot:r,currentSnapshot:i,guards:{canActivateChecks:o,canDeactivateChecks:s}}=n;return 0===s.length&&0===o.length?Pn({...n,guardsResult:!0}):function k3e(e,t,n,r){return $i(e).pipe(fa(i=>function U3e(e,t,n,r,i){const o=t&&t.routeConfig?t.routeConfig.canDeactivate:null;return o&&0!==o.length?Pn(o.map(a=>{const c=Lx(t)??i,u=Rb(a,c);return zh(function P3e(e){return e&&zx(e.canDeactivate)}(u)?u.canDeactivate(e,t,n,r):Md(c,()=>u(e,t,n,r))).pipe(Cg())})).pipe(kb()):Pn(!0)}(i.component,i.route,n,t,r)),Cg(i=>!0!==i,!0))}(s,r,i,e).pipe(fa(a=>a&&function I3e(e){return"boolean"==typeof e}(a)?function N3e(e,t,n,r){return $i(t).pipe(Sb(i=>hF(function B3e(e,t){return null!==e&&t&&t(new i3e(e)),Pn(!0)}(i.route.parent,r),function F3e(e,t){return null!==e&&t&&t(new s3e(e)),Pn(!0)}(i.route,r),function L3e(e,t,n){const r=t[t.length-1],o=t.slice(0,t.length-1).reverse().map(s=>function C3e(e){const t=e.routeConfig?e.routeConfig.canActivateChild:null;return t&&0!==t.length?{node:e,guards:t}:null}(s)).filter(s=>null!==s).map(s=>xK(()=>Pn(s.guards.map(c=>{const u=Lx(s.node)??n,l=Rb(c,u);return zh(function E3e(e){return e&&zx(e.canActivateChild)}(l)?l.canActivateChild(r,e):Md(u,()=>l(r,e))).pipe(Cg())})).pipe(kb())));return Pn(o).pipe(kb())}(e,i.path,n),function O3e(e,t,n){const r=t.routeConfig?t.routeConfig.canActivate:null;if(!r||0===r.length)return Pn(!0);const i=r.map(o=>xK(()=>{const s=Lx(t)??n,a=Rb(o,s);return zh(function D3e(e){return e&&zx(e.canActivate)}(a)?a.canActivate(t,e):Md(s,()=>a(t,e))).pipe(Cg())}));return Pn(i).pipe(kb())}(e,i.route,n))),Cg(i=>!0!==i,!0))}(r,o,e,t):Pn(a)),qt(a=>({...n,guardsResult:a})))})}(this.environmentInjector,c=>this.events.next(c)),jr(c=>{if(o.guardsResult=c.guardsResult,Tb(c.guardsResult))throw JK(0,c.guardsResult);const u=new JEe(c.id,this.urlSerializer.serialize(c.extractedUrl),this.urlSerializer.serialize(c.urlAfterRedirects),c.targetSnapshot,!!c.guardsResult);this.events.next(u)}),Yl(c=>!!c.guardsResult||(this.cancelNavigationTransition(c,"",iu.GuardRejected),!1)),LF(c=>{if(c.guards.canActivateChecks.length)return Pn(c).pipe(jr(u=>{const l=new e3e(u.id,this.urlSerializer.serialize(u.extractedUrl),this.urlSerializer.serialize(u.urlAfterRedirects),u.targetSnapshot);this.events.next(l)}),To(u=>{let l=!1;return Pn(u).pipe(function cPe(e,t){return fa(n=>{const{targetSnapshot:r,guards:{canActivateChecks:i}}=n;if(!i.length)return Pn(n);const o=new Set(i.map(c=>c.route)),s=new Set;for(const c of o)if(!s.has(c))for(const u of cZ(c))s.add(u);let a=0;return $i(s).pipe(Sb(c=>o.has(c)?function uPe(e,t,n,r){const i=e.routeConfig,o=e._resolve;return void 0!==i?.title&&!KK(i)&&(o[Px]=i.title),function lPe(e,t,n,r){const i=yF(e);if(0===i.length)return Pn({});const o={};return $i(i).pipe(fa(s=>function dPe(e,t,n,r){const i=Lx(t)??r,o=Rb(e,i);return zh(o.resolve?o.resolve(t,n):Md(i,()=>o(t,n)))}(e[s],t,n,r).pipe(Cg(),jr(a=>{o[s]=a}))),gF(1),function SEe(e){return qt(()=>e)}(o),Cb(s=>iZ(s)?$l:pI(s)))}(o,e,t,r).pipe(qt(s=>(e._resolvedData=s,e.data=TF(e,e.parent,n).resolve,null)))}(c,r,e,t):(c.data=TF(c,c.parent,e).resolve,Pn(void 0))),jr(()=>a++),gF(1),fa(c=>a===s.size?Pn(n):$l))})}(this.paramsInheritanceStrategy,this.environmentInjector),jr({next:()=>l=!0,complete:()=>{l||this.cancelNavigationTransition(u,"",iu.NoDataFromResolver)}}))}),jr(u=>{const l=new t3e(u.id,this.urlSerializer.serialize(u.extractedUrl),this.urlSerializer.serialize(u.urlAfterRedirects),u.targetSnapshot);this.events.next(l)}))}),LF(c=>{const u=l=>{const d=[];l.routeConfig?.loadComponent&&!l.routeConfig._loadedComponent&&d.push(this.configLoader.loadComponent(l.routeConfig).pipe(jr(f=>{l.component=f}),qt(()=>{})));for(const f of l.children)d.push(...u(f));return d};return dI(u(c.targetSnapshot.root)).pipe(hI(null),Sg(1))}),LF(()=>this.afterPreactivation()),To(()=>{const{currentSnapshot:c,targetSnapshot:u}=o,l=this.createViewTransition?.(this.environmentInjector,c.root,u.root);return l?$i(l).pipe(qt(()=>o)):Pn(o)}),qt(c=>{const u=function d3e(e,t,n){const r=Ox(e,t._root,n?n._root:void 0);return new WK(r,t)}(n.routeReuseStrategy,c.targetSnapshot,c.currentRouterState);return this.currentTransition=o={...c,targetRouterState:u},this.currentNavigation.targetRouterState=u,o}),jr(()=>{this.events.next(new CF)}),((e,t,n,r)=>qt(i=>(new x3e(t,i.targetRouterState,i.currentRouterState,n,r).activate(e),i)))(this.rootContexts,n.routeReuseStrategy,c=>this.events.next(c),this.inputBindingEnabled),Sg(1),jr({next:c=>{s=!0,this.lastSuccessfulNavigation=this.currentNavigation,this.events.next(new np(c.id,this.urlSerializer.serialize(c.extractedUrl),this.urlSerializer.serialize(c.urlAfterRedirects))),this.titleStrategy?.updateTitle(c.targetRouterState.snapshot),c.resolve(!0)},complete:()=>{s=!0}}),function CEe(e){return mo((t,n)=>{ru(e).subscribe(Io(n,()=>n.complete(),dM)),!n.closed&&t.subscribe(n)})}(this.transitionAbortSubject.pipe(jr(c=>{throw c}))),Ex(()=>{!s&&!a&&this.cancelNavigationTransition(o,"",iu.SupersededByNewNavigation),this.currentTransition?.id===o.id&&(this.currentNavigation=null,this.currentTransition=null)}),Cb(c=>{if(a=!0,tZ(c))this.events.next(new Db(o.id,this.urlSerializer.serialize(o.extractedUrl),c.message,c.cancellationCode)),function h3e(e){return tZ(e)&&Tb(e.url)}(c)?this.events.next(new wF(c.url)):o.resolve(!1);else{this.events.next(new CI(o.id,this.urlSerializer.serialize(o.extractedUrl),c,o.targetSnapshot??void 0));try{o.resolve(n.errorHandler(c))}catch(u){this.options.resolveNavigationPromiseOnError?o.resolve(!1):o.reject(u)}}return $l}))}))}cancelNavigationTransition(n,r,i){const o=new Db(n.id,this.urlSerializer.serialize(n.extractedUrl),r,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}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function bPe(e){return e!==Fx}let vPe=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>bt(xPe),providedIn:"root"})}return e})();class _Pe{shouldDetach(t){return!1}store(t,n){}shouldAttach(t){return!1}retrieve(t){return null}shouldReuseRoute(t,n){return t.routeConfig===n.routeConfig}}let xPe=(()=>{class e extends _Pe{static#e=this.\u0275fac=(()=>{let n;return function(i){return(n||(n=gR(e)))(i||e)}})();static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})(),pZ=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>bt(SPe),providedIn:"root"})}return e})(),SPe=(()=>{class e extends pZ{constructor(){super(...arguments),this.location=bt(xx),this.urlSerializer=bt(Ib),this.options=bt(Fb,{optional:!0})||{},this.canceledNavigationResolution=this.options.canceledNavigationResolution||"replace",this.urlHandlingStrategy=bt(VF),this.urlUpdateStrategy=this.options.urlUpdateStrategy||"deferred",this.currentUrlTree=new Ab,this.rawUrlTree=this.currentUrlTree,this.currentPageId=0,this.lastSuccessfulId=-1,this.routerState=$K(null),this.stateMemento=this.createStateMemento()}getCurrentUrlTree(){return this.currentUrlTree}getRawUrlTree(){return this.rawUrlTree}restoredState(){return this.location.getState()}get browserPageId(){return"computed"!==this.canceledNavigationResolution?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(r=>{"popstate"===r.type&&n(r.url,r.state)})}handleRouterEvent(n,r){if(n instanceof xI)this.stateMemento=this.createStateMemento();else if(n instanceof Eb)this.rawUrlTree=r.initialUrl;else if(n instanceof jK){if("eager"===this.urlUpdateStrategy&&!r.extras.skipLocationChange){const i=this.urlHandlingStrategy.merge(r.finalUrl,r.initialUrl);this.setBrowserUrl(i,r)}}else n instanceof CF?(this.currentUrlTree=r.finalUrl,this.rawUrlTree=this.urlHandlingStrategy.merge(r.finalUrl,r.initialUrl),this.routerState=r.targetRouterState,"deferred"===this.urlUpdateStrategy&&(r.extras.skipLocationChange||this.setBrowserUrl(this.rawUrlTree,r))):n instanceof Db&&(n.code===iu.GuardRejected||n.code===iu.NoDataFromResolver)?this.restoreHistory(r):n instanceof CI?this.restoreHistory(r,!0):n instanceof np&&(this.lastSuccessfulId=n.id,this.currentPageId=this.browserPageId)}setBrowserUrl(n,r){const i=this.urlSerializer.serialize(n);if(this.location.isCurrentPathEqualTo(i)||r.extras.replaceUrl){const s={...r.extras.state,...this.generateNgRouterState(r.id,this.browserPageId)};this.location.replaceState(i,"",s)}else{const o={...r.extras.state,...this.generateNgRouterState(r.id,this.browserPageId+1)};this.location.go(i,"",o)}}restoreHistory(n,r=!1){if("computed"===this.canceledNavigationResolution){const o=this.currentPageId-this.browserPageId;0!==o?this.location.historyGo(o):this.currentUrlTree===n.finalUrl&&0===o&&(this.resetState(n),this.resetUrlToCurrentUrlTree())}else"replace"===this.canceledNavigationResolution&&(r&&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,r){return"computed"===this.canceledNavigationResolution?{navigationId:n,\u0275routerPageId:r}:{navigationId:n}}static#e=this.\u0275fac=(()=>{let n;return function(i){return(n||(n=gR(e)))(i||e)}})();static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();var Gx=function(e){return e[e.COMPLETE=0]="COMPLETE",e[e.FAILED=1]="FAILED",e[e.REDIRECTING=2]="REDIRECTING",e}(Gx||{});function hZ(e,t){e.events.pipe(Yl(n=>n instanceof np||n instanceof Db||n instanceof CI||n instanceof Eb),qt(n=>n instanceof np||n instanceof Eb?Gx.COMPLETE:n instanceof Db&&(n.code===iu.Redirect||n.code===iu.SupersededByNewNavigation)?Gx.REDIRECTING:Gx.FAILED),Yl(n=>n!==Gx.REDIRECTING),Sg(1)).subscribe(()=>{t()})}function CPe(e){throw e}const wPe={paths:"exact",fragment:"ignored",matrixParams:"ignored",queryParams:"exact"},APe={paths:"subset",fragment:"ignored",matrixParams:"ignored",queryParams:"subset"};let Kl=(()=>{class e{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=bt(pY),this.stateManager=bt(pZ),this.options=bt(Fb,{optional:!0})||{},this.pendingTasks=bt(kh),this.urlUpdateStrategy=this.options.urlUpdateStrategy||"deferred",this.navigationTransitions=bt(DI),this.urlSerializer=bt(Ib),this.location=bt(xx),this.urlHandlingStrategy=bt(VF),this._events=new mr,this.errorHandler=this.options.errorHandler||CPe,this.navigated=!1,this.routeReuseStrategy=bt(vPe),this.onSameUrlNavigation=this.options.onSameUrlNavigation||"ignore",this.config=bt(Bb,{optional:!0})?.flat()??[],this.componentInputBindingEnabled=!!bt(wI,{optional:!0}),this.eventsSubscription=new Fa,this.isNgZoneEnabled=bt(Qr)instanceof Qr&&Qr.isInAngularZone(),this.resetConfig(this.config),this.navigationTransitions.setupNavigations(this,this.currentUrlTree,this.routerState).subscribe({error:n=>{this.console.warn(n)}}),this.subscribeToNavigationEvents()}subscribeToNavigationEvents(){const n=this.navigationTransitions.events.subscribe(r=>{try{const i=this.navigationTransitions.currentTransition,o=this.navigationTransitions.currentNavigation;if(null!==i&&null!==o)if(this.stateManager.handleRouterEvent(r,o),r instanceof Db&&r.code!==iu.Redirect&&r.code!==iu.SupersededByNewNavigation)this.navigated=!0;else if(r instanceof np)this.navigated=!0;else if(r instanceof wF){const s=this.urlHandlingStrategy.merge(r.url,i.currentRawUrl),a={info:i.extras.info,skipLocationChange:i.extras.skipLocationChange,replaceUrl:"eager"===this.urlUpdateStrategy||bPe(i.source)};this.scheduleNavigation(s,Fx,null,a,{resolve:i.resolve,reject:i.reject,promise:i.promise})}(function TPe(e){return!(e instanceof CF||e instanceof wF)})(r)&&this._events.next(r)}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),Fx,this.stateManager.restoredState())}setUpLocationChangeListener(){this.nonRouterCurrentEntryChangeSubscription??=this.stateManager.registerNonRouterCurrentEntryChangeListener((n,r)=>{setTimeout(()=>{this.navigateToSyncWithBrowser(n,"popstate",r)},0)})}navigateToSyncWithBrowser(n,r,i){const o={replaceUrl:!0},s=i?.navigationId?i:null;if(i){const c={...i};delete c.navigationId,delete c.\u0275routerPageId,0!==Object.keys(c).length&&(o.state=c)}const a=this.parseUrl(n);this.scheduleNavigation(a,r,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(kF),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,r={}){const{relativeTo:i,queryParams:o,fragment:s,queryParamsHandling:a,preserveFragment:c}=r,u=c?this.currentUrlTree.fragment:s;let d,l=null;switch(a){case"merge":l={...this.currentUrlTree.queryParams,...o};break;case"preserve":l=this.currentUrlTree.queryParams;break;default:l=o||null}null!==l&&(l=this.removeEmptyProps(l));try{d=BK(i?i.snapshot:this.routerState.snapshot.root)}catch{("string"!=typeof n[0]||!n[0].startsWith("/"))&&(n=[]),d=this.currentUrlTree.root}return OK(d,n,l,u??null)}navigateByUrl(n,r={skipLocationChange:!1}){const i=Tb(n)?n:this.parseUrl(n),o=this.urlHandlingStrategy.merge(i,this.rawUrlTree);return this.scheduleNavigation(o,Fx,null,r)}navigate(n,r={skipLocationChange:!1}){return function IPe(e){for(let t=0;t(null!=o&&(r[i]=o),r),{})}scheduleNavigation(n,r,i,o,s){if(this.disposed)return Promise.resolve(!1);let a,c,u;s?(a=s.resolve,c=s.reject,u=s.promise):u=new Promise((d,f)=>{a=d,c=f});const l=this.pendingTasks.add();return hZ(this,()=>{queueMicrotask(()=>this.pendingTasks.remove(l))}),this.navigationTransitions.handleNavigationRequest({source:r,restoredState:i,currentUrlTree:this.currentUrlTree,currentRawUrl:this.currentUrlTree,rawUrl:n,extras:o,resolve:a,reject:c,promise:u,currentSnapshot:this.routerState.snapshot,currentRouterState:this.routerState}),u.catch(d=>Promise.reject(d))}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})(),EI=(()=>{class e{constructor(n,r,i,o,s,a){this.router=n,this.route=r,this.tabIndexAttribute=i,this.renderer=o,this.el=s,this.locationStrategy=a,this.href=null,this.commands=null,this.onChanges=new mr,this.preserveFragment=!1,this.skipLocationChange=!1,this.replaceUrl=!1;const c=s.nativeElement.tagName?.toLowerCase();this.isAnchorElement="a"===c||"area"===c,this.isAnchorElement?this.subscription=n.events.subscribe(u=>{u instanceof np&&this.updateHref()}):this.setTabIndexIfNotOnNativeEl("0")}setTabIndexIfNotOnNativeEl(n){null!=this.tabIndexAttribute||this.isAnchorElement||this.applyAttributeValue("tabindex",n)}ngOnChanges(n){this.isAnchorElement&&this.updateHref(),this.onChanges.next(this)}set routerLink(n){null!=n?(this.commands=Array.isArray(n)?n:[n],this.setTabIndexIfNotOnNativeEl("0")):(this.commands=null,this.setTabIndexIfNotOnNativeEl(null))}onClick(n,r,i,o,s){const a=this.urlTree;return!!(null===a||this.isAnchorElement&&(0!==n||r||i||o||s||"string"==typeof this.target&&"_self"!=this.target))||(this.router.navigateByUrl(a,{skipLocationChange:this.skipLocationChange,replaceUrl:this.replaceUrl,state:this.state,info:this.info}),!this.isAnchorElement)}ngOnDestroy(){this.subscription?.unsubscribe()}updateHref(){const n=this.urlTree;this.href=null!==n&&this.locationStrategy?this.locationStrategy?.prepareExternalUrl(this.router.serializeUrl(n)):null;const r=null===this.href?null:function zj(e,t,n){return function jve(e,t){return"src"===t&&("embed"===e||"frame"===e||"iframe"===e||"media"===e||"script"===e)||"href"===t&&("base"===e||"link"===e)?Vj:Uj}(t,n)(e)}(this.href,this.el.nativeElement.tagName.toLowerCase(),"href");this.applyAttributeValue("href",r)}applyAttributeValue(n,r){const i=this.renderer,o=this.el.nativeElement;null!==r?i.setAttribute(o,n,r):i.removeAttribute(o,n)}get urlTree(){return null===this.commands?null:this.router.createUrlTree(this.commands,{relativeTo:void 0!==this.relativeTo?this.relativeTo:this.route,queryParams:this.queryParams,fragment:this.fragment,queryParamsHandling:this.queryParamsHandling,preserveFragment:this.preserveFragment})}static#e=this.\u0275fac=function(r){return new(r||e)(cn(Kl),cn(Mb),function I_(e){return function xbe(e,t){if("class"===t)return e.classes;if("style"===t)return e.styles;const n=e.attrs;if(n){const r=n.length;let i=0;for(;i{class e{constructor(n,r,i,o,s){this.router=n,this.injector=i,this.preloadingStrategy=o,this.loader=s}setUpPreloading(){this.subscription=this.router.events.pipe(Yl(n=>n instanceof np),Sb(()=>this.preload())).subscribe(()=>{})}preload(){return this.processRoutes(this.injector,this.router.config)}ngOnDestroy(){this.subscription&&this.subscription.unsubscribe()}processRoutes(n,r){const i=[];for(const o of r){o.providers&&!o._injector&&(o._injector=hA(o.providers,n,`Route: ${o.path}`));const s=o._injector??n,a=o._loadedInjector??s;(o.loadChildren&&!o._loadedRoutes&&void 0===o.canLoad||o.loadComponent&&!o._loadedComponent)&&i.push(this.preloadConfig(s,o)),(o.children||o._loadedRoutes)&&i.push(this.processRoutes(a,o.children??o._loadedRoutes))}return $i(i).pipe(xg())}preloadConfig(n,r){return this.preloadingStrategy.preload(r,()=>{let i;i=r.loadChildren&&void 0===r.canLoad?this.loader.loadChildren(n,r):Pn(null);const o=i.pipe(fa(s=>null===s?Pn(void 0):(r._loadedRoutes=s.routes,r._loadedInjector=s.injector,this.processRoutes(s.injector??n,s.routes))));return r.loadComponent&&!r._loadedComponent?$i([o,this.loader.loadComponent(r)]).pipe(xg()):o})}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(Kl),Zt(CY),Zt(xc),Zt(mZ),Zt(UF))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();const zF=new Yt("");let gZ=(()=>{class e{constructor(n,r,i,o,s={}){this.urlSerializer=n,this.transitions=r,this.viewportScroller=i,this.zone=o,this.options=s,this.lastId=0,this.lastSource="imperative",this.restoredId=0,this.store={},s.scrollPositionRestoration||="disabled",s.anchorScrolling||="disabled"}init(){"disabled"!==this.options.scrollPositionRestoration&&this.viewportScroller.setHistoryScrollRestoration("manual"),this.routerEventsSubscription=this.createScrollEvents(),this.scrollEventsSubscription=this.consumeScrollEvents()}createScrollEvents(){return this.transitions.events.subscribe(n=>{n instanceof xI?(this.store[this.lastId]=this.viewportScroller.getScrollPosition(),this.lastSource=n.navigationTrigger,this.restoredId=n.restoredState?n.restoredState.navigationId:0):n instanceof np?(this.lastId=n.id,this.scheduleScrollEvent(n,this.urlSerializer.parse(n.urlAfterRedirects).fragment)):n instanceof Eb&&n.code===SI.IgnoredSameUrlNavigation&&(this.lastSource=void 0,this.restoredId=0,this.scheduleScrollEvent(n,this.urlSerializer.parse(n.url).fragment))})}consumeScrollEvents(){return this.transitions.events.subscribe(n=>{n instanceof HK&&(n.position?"top"===this.options.scrollPositionRestoration?this.viewportScroller.scrollToPosition([0,0]):"enabled"===this.options.scrollPositionRestoration&&this.viewportScroller.scrollToPosition(n.position):n.anchor&&"enabled"===this.options.anchorScrolling?this.viewportScroller.scrollToAnchor(n.anchor):"disabled"!==this.options.scrollPositionRestoration&&this.viewportScroller.scrollToPosition([0,0]))})}scheduleScrollEvent(n,r){this.zone.runOutsideAngular(()=>{setTimeout(()=>{this.zone.run(()=>{this.transitions.events.next(new HK(n,"popstate"===this.lastSource?this.store[this.restoredId]:null,r))})},0)})}ngOnDestroy(){this.routerEventsSubscription?.unsubscribe(),this.scrollEventsSubscription?.unsubscribe()}static#e=this.\u0275fac=function(r){!function fH(){throw new Error("invalid")}()};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();function yZ(e){return e.routerState.root}function $d(e,t){return{\u0275kind:e,\u0275providers:t}}function bZ(){const e=bt(Sc);return t=>{const n=e.get(Oh);if(t!==n.components[0])return;const r=e.get(Kl),i=e.get(vZ);1===e.get(GF)&&r.initialNavigation(),e.get(_Z,null,yr.Optional)?.setUpPreloading(),e.get(zF,null,yr.Optional)?.init(),r.resetRootComponentType(n.componentTypes[0]),i.closed||(i.next(),i.complete(),i.unsubscribe())}}const vZ=new Yt("",{factory:()=>new mr}),GF=new Yt("",{providedIn:"root",factory:()=>1}),_Z=new Yt("");function FPe(e){return $d(0,[{provide:_Z,useExisting:PPe},{provide:mZ,useExisting:e}])}function OPe(e){return $d(9,[{provide:dZ,useValue:gPe},{provide:fZ,useValue:{skipNextTransition:!!e?.skipInitialTransition,...e}}])}const xZ=new Yt("ROUTER_FORROOT_GUARD"),LPe=[xx,{provide:Ib,useClass:bF},Kl,Bx,{provide:Mb,useFactory:yZ,deps:[Kl]},UF,[]];let jF=(()=>{class e{constructor(n){}static forRoot(n,r){return{ngModule:e,providers:[LPe,[],{provide:Bb,multi:!0,useValue:n},{provide:xZ,useFactory:GPe,deps:[[Kl,new uw,new lw]]},{provide:Fb,useValue:r||{}},r?.useHash?{provide:_g,useClass:eIe}:{provide:_g,useClass:dX},{provide:zF,useFactory:()=>{const e=bt(_Te),t=bt(Qr),n=bt(Fb),r=bt(DI),i=bt(Ib);return n.scrollOffset&&e.setOffset(n.scrollOffset),new gZ(i,r,e,t,n)}},r?.preloadingStrategy?FPe(r.preloadingStrategy).\u0275providers:[],r?.initialNavigation?jPe(r):[],r?.bindToComponentInputs?$d(8,[ZK,{provide:wI,useExisting:ZK}]).\u0275providers:[],r?.enableViewTransitions?OPe().\u0275providers:[],[{provide:SZ,useFactory:bZ},{provide:LA,multi:!0,useExisting:SZ}]]}}static forChild(n){return{ngModule:e,providers:[{provide:Bb,multi:!0,useValue:n}]}}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(xZ,8))};static#t=this.\u0275mod=f_({type:e});static#n=this.\u0275inj=Sy({})}return e})();function GPe(e){return"guarded"}function jPe(e){return["disabled"===e.initialNavigation?$d(3,[{provide:IN,multi:!0,useFactory:()=>{const t=bt(Kl);return()=>{t.setUpLocationChangeListener()}}},{provide:GF,useValue:2}]).\u0275providers:[],"enabledBlocking"===e.initialNavigation?$d(2,[{provide:GF,useValue:0},{provide:IN,multi:!0,deps:[Sc],useFactory:t=>{const n=t.get(QAe,Promise.resolve());return()=>n.then(()=>new Promise(r=>{const i=t.get(Kl),o=t.get(vZ);hZ(i,()=>{r(!0)}),t.get(DI).afterPreactivation=()=>(r(!0),o.closed?Pn(void 0):o),i.initialNavigation()}))}}]).\u0275providers:[]]}const SZ=new Yt(""),HF={now:()=>(HF.delegate||Date).now(),delegate:void 0};class ou extends mr{constructor(t=1/0,n=1/0,r=HF){super(),this._bufferSize=t,this._windowTime=n,this._timestampProvider=r,this._buffer=[],this._infiniteTimeWindow=!0,this._infiniteTimeWindow=n===1/0,this._bufferSize=Math.max(1,t),this._windowTime=Math.max(1,n)}next(t){const{isStopped:n,_buffer:r,_infiniteTimeWindow:i,_timestampProvider:o,_windowTime:s}=this;n||(r.push(t),!i&&r.push(o.now()+s)),this._trimBuffer(),super.next(t)}_subscribe(t){this._throwIfClosed(),this._trimBuffer();const n=this._innerSubscribe(t),{_infiniteTimeWindow:r,_buffer:i}=this,o=i.slice();for(let s=0;s{vK([n,...CZ(e)])(r)})}function Ob(...e){return wZ(...e)}function qF(e,t,...n){if(!0===t)return void e();if(!1===t)return;const r=new s_({next:()=>{r.unsubscribe(),e()}});return ru(t(...n)).subscribe(r)}function Zl(e,t,n){let r,i=!1;return e&&"object"==typeof e?({bufferSize:r=1/0,windowTime:t=1/0,refCount:i=!1,scheduler:n}=e):r=e??1/0,function WPe(e={}){const{connector:t=(()=>new mr),resetOnError:n=!0,resetOnComplete:r=!0,resetOnRefCountZero:i=!0}=e;return o=>{let s,a,c,u=0,l=!1,d=!1;const f=()=>{a?.unsubscribe(),a=void 0},p=()=>{f(),s=c=void 0,l=d=!1},m=()=>{const h=s;p(),h?.unsubscribe()};return mo((h,g)=>{u++,!d&&!l&&f();const y=c=c??t();g.add(()=>{u--,0===u&&!d&&!l&&(a=qF(m,i))}),y.subscribe(g),!s&&u>0&&(s=new s_({next:b=>y.next(b),error:b=>{d=!0,f(),a=qF(p,n,b),y.error(b)},complete:()=>{l=!0,f(),a=qF(p,r),y.complete()}}),ru(h).subscribe(s))})(o)}}({connector:()=>new ou(r,t,n),resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:i})}var ea,e,ir;(e=ea||(ea={})).create=function t(i){return i},e.has=function n(i,o){return!!(i&o)},e.hasAll=function r(i,o){return!!o&&(i&o)===o},function(e){e.create=function t(_=512){return{current:[],offset:0,capacity:_,chunks:[]}},e.getString=function n(_){return _.chunks.length?(_.offset>0&&(_.chunks[_.chunks.length]=_.current.length===_.offset?_.current.join(""):_.current.slice(0,_.offset).join("")),_.chunks.join("")):_.current.length===_.offset?_.current.join(""):_.current.splice(0,_.offset).join("")},e.getSize=function r(_){let S=0;for(const A of _.chunks)S+=A.length;for(let A=0;A<_.offset;A++)S+=_.current[A].length;return S},e.getChunks=function i(_){return _.offset>0&&(_.chunks[_.chunks.length]=_.current.length===_.offset?_.current.join(""):_.current.slice(0,_.offset).join(""),_.offset=0),_.chunks};const o=[];function a(_,S){S>0&&l(_,o[S])}function l(_,S){_.offset===_.capacity&&(_.chunks[_.chunks.length]=_.current.join(""),_.offset=0),_.current[_.offset++]=S}!function(){let _="";for(let S=0;S<512;S++)o[S]=_,_+=" "}(),e.newline=function s(_){l(_,"\n")},e.whitespace=a,e.whitespace1=function c(_){l(_," ")},e.write=function u(_,S){S&&(_.offset===_.capacity&&(_.chunks[_.chunks.length]=_.current.join(""),_.offset=0),_.current[_.offset++]=S)},e.writeSafe=l,e.writePadLeft=function d(_,S,A){S?(a(_,A-S.length),l(_,S)):a(_,A)},e.writePadRight=function f(_,S,A){if(!S)return void a(_,A);const E=A-S.length;l(_,S),a(_,E)},e.writeInteger=function p(_,S){l(_,""+S)},e.writeIntegerAndSpace=function m(_,S){l(_,S+" ")},e.writeIntegerPadLeft=function h(_,S,A){const E=""+S;a(_,A-E.length),l(_,E)},e.writeIntegerPadRight=function g(_,S,A){const E=""+S,w=A-E.length;l(_,E),a(_,w)},e.writeFloat=function y(_,S,A){l(_,""+Math.round(A*S)/A)},e.writeFloatPadLeft=function b(_,S,A,E){const w=""+Math.round(A*S)/A;a(_,E-w.length),l(_,w)},e.writeFloatPadRight=function x(_,S,A,E){const w=""+Math.round(A*S)/A,D=E-w.length;l(_,w),a(_,D)}}(ir||(ir={}));const yi=function(){if(typeof window<"u"&&window.performance){const e=window.performance;return()=>e.now()}return typeof process<"u"&&"undefined"!==process.hrtime&&"function"==typeof process.hrtime?()=>{const e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:Date.now?()=>Date.now():()=>+new Date}();function WF(e,t=!0){if(isNaN(e))return"n/a";const n=Math.floor(e/36e5),r=Math.floor(e/6e4%60),i=Math.floor(e/1e3%60);let o=Math.floor(e%1e3).toString();for(;o.length<3;)o="0"+o;for(;!t&&o.length>1&&"0"===o[o.length-1];)o=o.substr(0,o.length-1);return n>0?`${n}h${r}m${i}.${o}s`:r>0?`${r}m${i}.${o}s`:i>0?`${i}.${o}s`:`${e.toFixed(0)}ms`}var Hr,AZ,jx;function $Pe(e,t){return e-t}function pa(e=0,t=Number.MAX_SAFE_INTEGER){let n=e;return()=>{const r=n;return n=(n+1)%t,r}}!function(e){const t=typeof btoa<"u"?btoa:s=>Buffer.from(s).toString("base64"),n=[];e.create22=function r(){let s=+new Date+yi();for(let a=0;a<16;a++)n[a]=String.fromCharCode((s+255*Math.random())%255|0),s=Math.floor(s/255);return t(n.join("")).replace(/\+/g,"-").replace(/\//g,"_").substr(0,22)},e.createv4=function i(){let s=+new Date+yi();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){const u=(s+16*Math.random())%16|0;return s=Math.floor(s/16),("x"===c?u:3&u|8).toString(16)})},e.is=function o(s){return"string"==typeof s}}(Hr||(Hr={})),function(e){class t{has(m){return!1}forEach(m,h){return h}constructor(){this.size=0}}class n{has(m){return m===this.idx}forEach(m,h){return m(this.idx,h),h}constructor(m){this.idx=m,this.size=1}}class r{has(m){return mm[h++]=g),function YPe(e){Array.prototype.sort.call(e,$Pe)}(m),this._flat=m,this._flat}forEach(m,h){return this._forEach(m,h),h}constructor(m){this.set=m,this._flat=void 0,this.size=m.size}}function a(p){return new o(p)}function l(p,m){return new r(p,m)}e.always=function s(p){return new i(p)},e.never=new t,e.ofSet=a,e.singleton=function c(p){return new n(p)},e.ofUniqueIndices=function u(p){const m=p.length;if(0===m)return new t;if(1===m)return new n(p[0]);let h=0;for(const b of p)b>h&&(h=b);if(m===h)return new i(m);if(m/h<1/12){const b=new Set;for(const x of p)b.add(x);return new o(b)}const y=new Int8Array(h+1);for(const b of p)y[b]=1;return new r(y,p.length)},e.ofMask=l,e.hasAny=function d(p,m){for(const h of m)if(p.has(h))return!0;return!1},e.complement=function f(p,m){let h=0,g=0;if(m.forEach(y=>{p.has(y)||(h++,y>g&&(g=y))}),h/g<1/12){const y=new Set;return m.forEach(b=>{p.has(b)||y.add(b)}),a(y)}{const y=new Uint8Array(g+1);return m.forEach(b=>{p.has(b)||(y[b]=1)}),l(y,h)}}}(AZ||(AZ={})),function(e){e.create=function t(r){return{ref:r}},e.set=function n(r,i){return r.ref=i,r}}(jx||(jx={}));const XPe=pa(0,2147483647);var Gh,k;!function(e){e.create=function t(r,i){return{id:XPe(),version:0,value:r,metadata:i}},e.withValue=function n(r,i){return{id:r.id,version:r.version+1,value:i,metadata:r.metadata}}}(Gh||(Gh={})),function(e){function n(o,s){return jx.set(o,Gh.withValue(o.ref,s))}e.create=function t(o,s){return jx.create(Gh.create(o,s))},e.update=n,e.set=function r(o,s){return jx.set(o,s)},e.updateIfChanged=function i(o,s){return o.ref.value!==s?n(o,s):o}}(k||(k={}));const Ag=function(){};function Wa(e,t){const n=e.length;if(n!==t.length)return!1;for(let r=0;r0&&(xt=1/Math.sqrt(xt),se[0]=he[0]*xt,se[1]=he[1]*xt,se[2]=he[2]*xt),se}function ee(se,he){return se[0]*he[0]+se[1]*he[1]+se[2]*he[2]}function q(se,he,ve){const Te=he[0],yt=he[1],xt=he[2],Ut=ve[0],Nn=ve[1],hn=ve[2];return se[0]=yt*hn-xt*Nn,se[1]=xt*Ut-Te*hn,se[2]=Te*Nn-yt*Ut,se}e.zero=t,e.clone=function n(se){const he=t();return he[0]=se[0],he[1]=se[1],he[2]=se[2],he},e.isFinite=function r(se){return ZF(se[0])&&ZF(se[1])&&ZF(se[2])},e.hasNaN=function i(se){return isNaN(se[0])||isNaN(se[1])||isNaN(se[2])},e.setNaN=function o(se){return se[0]=NaN,se[1]=NaN,se[2]=NaN,se},e.fromObj=function s(se){return l(se.x,se.y,se.z)},e.toObj=function a(se){return{x:se[0],y:se[1],z:se[2]}},e.fromArray=function c(se,he,ve){return se[0]=he[ve+0],se[1]=he[ve+1],se[2]=he[ve+2],se},e.toArray=function u(se,he,ve){return he[ve+0]=se[0],he[ve+1]=se[1],he[ve+2]=se[2],he},e.create=l,e.ofArray=function d(se){const he=t();return he[0]=se[0],he[1]=se[1],he[2]=se[2],he},e.set=function f(se,he,ve,Te){return se[0]=he,se[1]=ve,se[2]=Te,se},e.copy=p,e.add=m,e.sub=h,e.mul=function g(se,he,ve){return se[0]=he[0]*ve[0],se[1]=he[1]*ve[1],se[2]=he[2]*ve[2],se},e.div=function y(se,he,ve){return se[0]=he[0]/ve[0],se[1]=he[1]/ve[1],se[2]=he[2]/ve[2],se},e.scale=b,e.scaleAndAdd=x,e.scaleAndSub=function _(se,he,ve,Te){return se[0]=he[0]-ve[0]*Te,se[1]=he[1]-ve[1]*Te,se[2]=he[2]-ve[2]*Te,se},e.addScalar=function S(se,he,ve){return se[0]=he[0]+ve,se[1]=he[1]+ve,se[2]=he[2]+ve,se},e.subScalar=function A(se,he,ve){return se[0]=he[0]-ve,se[1]=he[1]-ve,se[2]=he[2]-ve,se},e.round=function E(se,he){return se[0]=Math.round(he[0]),se[1]=Math.round(he[1]),se[2]=Math.round(he[2]),se},e.ceil=function w(se,he){return se[0]=Math.ceil(he[0]),se[1]=Math.ceil(he[1]),se[2]=Math.ceil(he[2]),se},e.floor=function D(se,he){return se[0]=Math.floor(he[0]),se[1]=Math.floor(he[1]),se[2]=Math.floor(he[2]),se},e.trunc=function I(se,he){return se[0]=Math.trunc(he[0]),se[1]=Math.trunc(he[1]),se[2]=Math.trunc(he[2]),se},e.abs=function R(se,he){return se[0]=Math.abs(he[0]),se[1]=Math.abs(he[1]),se[2]=Math.abs(he[2]),se},e.min=function T(se,he,ve){return se[0]=Math.min(he[0],ve[0]),se[1]=Math.min(he[1],ve[1]),se[2]=Math.min(he[2],ve[2]),se},e.max=function M(se,he,ve){return se[0]=Math.max(he[0],ve[0]),se[1]=Math.max(he[1],ve[1]),se[2]=Math.max(he[2],ve[2]),se},e.clamp=function N(se,he,ve,Te){return se[0]=Math.max(ve[0],Math.min(Te[0],he[0])),se[1]=Math.max(ve[1],Math.min(Te[1],he[1])),se[2]=Math.max(ve[2],Math.min(Te[2],he[2])),se},e.distance=function V(se,he){const ve=he[0]-se[0],Te=he[1]-se[1],yt=he[2]-se[2];return Math.sqrt(ve*ve+Te*Te+yt*yt)},e.squaredDistance=function F(se,he){const ve=he[0]-se[0],Te=he[1]-se[1],yt=he[2]-se[2];return ve*ve+Te*Te+yt*yt},e.magnitude=function G(se){const he=se[0],ve=se[1],Te=se[2];return Math.sqrt(he*he+ve*ve+Te*Te)},e.squaredMagnitude=L,e.setMagnitude=function z(se,he,ve){return b(se,$(se,he),ve)},e.negate=j,e.inverse=function Z(se,he){return se[0]=1/he[0],se[1]=1/he[1],se[2]=1/he[2],se},e.normalize=$,e.dot=ee,e.cross=q,e.lerp=function O(se,he,ve,Te){const yt=he[0],xt=he[1],Ut=he[2];return se[0]=yt+Te*(ve[0]-yt),se[1]=xt+Te*(ve[1]-xt),se[2]=Ut+Te*(ve[2]-Ut),se};const H=t();function ne(se,he){const ve=Math.sqrt(L(se)*L(he));if(0===ve)return Math.PI/2;const Te=ee(se,he)/ve;return Math.acos(os(Te,-1,1))}e.slerp=function W(se,he,ve,Te){const yt=os(ee(he,ve),-1,1),xt=Math.acos(yt)*Te;return x(H,ve,he,-yt),$(H,H),m(se,b(se,he,Math.cos(xt)),b(H,H,Math.sin(xt)))},e.hermite=function Q(se,he,ve,Te,yt,xt){const Ut=xt*xt,Nn=Ut*(2*xt-3)+1,hn=Ut*(xt-2)+xt,hr=Ut*(xt-1),Pi=Ut*(3-2*xt);return se[0]=he[0]*Nn+ve[0]*hn+Te[0]*hr+yt[0]*Pi,se[1]=he[1]*Nn+ve[1]*hn+Te[1]*hr+yt[1]*Pi,se[2]=he[2]*Nn+ve[2]*hn+Te[2]*hr+yt[2]*Pi,se},e.bezier=function fe(se,he,ve,Te,yt,xt){const Ut=1-xt,Nn=Ut*Ut,hn=xt*xt,hr=Nn*Ut,Pi=3*xt*Nn,Ks=3*hn*Ut,ho=hn*xt;return se[0]=he[0]*hr+ve[0]*Pi+Te[0]*Ks+yt[0]*ho,se[1]=he[1]*hr+ve[1]*Pi+Te[1]*Ks+yt[1]*ho,se[2]=he[2]*hr+ve[2]*Pi+Te[2]*Ks+yt[2]*ho,se},e.quadraticBezier=function X(se,he,ve,Te,yt){return se[0]=KF(he[0],ve[0],Te[0],yt),se[1]=KF(he[1],ve[1],Te[1],yt),se[2]=KF(he[2],ve[2],Te[2],yt),se},e.spline=function J(se,he,ve,Te,yt,xt,Ut){return se[0]=kI(he[0],ve[0],Te[0],yt[0],xt,Ut),se[1]=kI(he[1],ve[1],Te[1],yt[1],xt,Ut),se[2]=kI(he[2],ve[2],Te[2],yt[2],xt,Ut),se},e.random=function ce(se,he){const ve=2*Math.random()*Math.PI,Te=2*Math.random()-1,yt=Math.sqrt(1-Te*Te)*he;return se[0]=Math.cos(ve)*yt,se[1]=Math.sin(ve)*yt,se[2]=Te*he,se},e.transformMat4=function be(se,he,ve){const Te=he[0],yt=he[1],xt=he[2],Ut=1/(ve[3]*Te+ve[7]*yt+ve[11]*xt+ve[15]||1);return se[0]=(ve[0]*Te+ve[4]*yt+ve[8]*xt+ve[12])*Ut,se[1]=(ve[1]*Te+ve[5]*yt+ve[9]*xt+ve[13])*Ut,se[2]=(ve[2]*Te+ve[6]*yt+ve[10]*xt+ve[14])*Ut,se},e.transformDirection=function ae(se,he,ve){const Te=he[0],yt=he[1],xt=he[2];return se[0]=ve[0]*Te+ve[4]*yt+ve[8]*xt,se[1]=ve[1]*Te+ve[5]*yt+ve[9]*xt,se[2]=ve[2]*Te+ve[6]*yt+ve[10]*xt,$(se,se)},e.transformMat4Offset=function me(se,he,ve,Te,yt,xt){const Ut=he[0+yt],Nn=he[1+yt],hn=he[2+yt],hr=1/(ve[3+xt]*Ut+ve[7+xt]*Nn+ve[11+xt]*hn+ve[15+xt]||1);return se[0+Te]=(ve[0+xt]*Ut+ve[4+xt]*Nn+ve[8+xt]*hn+ve[12+xt])*hr,se[1+Te]=(ve[1+xt]*Ut+ve[5+xt]*Nn+ve[9+xt]*hn+ve[13+xt])*hr,se[2+Te]=(ve[2+xt]*Ut+ve[6+xt]*Nn+ve[10+xt]*hn+ve[14+xt])*hr,se},e.transformMat3=function oe(se,he,ve){const Te=he[0],yt=he[1],xt=he[2];return se[0]=Te*ve[0]+yt*ve[3]+xt*ve[6],se[1]=Te*ve[1]+yt*ve[4]+xt*ve[7],se[2]=Te*ve[2]+yt*ve[5]+xt*ve[8],se},e.transformQuat=function K(se,he,ve){const Te=he[0],yt=he[1],xt=he[2],Ut=ve[0],Nn=ve[1],hn=ve[2],hr=ve[3],Pi=hr*Te+Nn*xt-hn*yt,Ks=hr*yt+hn*Te-Ut*xt,ho=hr*xt+Ut*yt-Nn*Te,mc=-Ut*Te-Nn*yt-hn*xt;return se[0]=Pi*hr+mc*-Ut+Ks*-hn-ho*-Nn,se[1]=Ks*hr+mc*-Nn+ho*-Ut-Pi*-hn,se[2]=ho*hr+mc*-hn+Pi*-Nn-Ks*-Ut,se},e.angle=ne;const de=t(),we=t(),Le=t(),We=t(),U=t(),Y=t(),ge=t();e.dihedralAngle=function Se(se,he,ve,Te){h(de,se,he),h(we,ve,he),h(Le,he,ve),h(We,Te,ve),q(U,de,we),q(Y,Le,We);const yt=ne(U,Y);return q(ge,U,Y),ee(we,ge)>0?yt:-yt},e.directionFromSpherical=function Re(se,he,ve,Te){return e.set(se,Te*Math.cos(ve)*Math.sin(he),Te*Math.sin(ve)*Math.sin(he),Te*Math.cos(he))},e.exactEquals=function Ne(se,he){return se[0]===he[0]&&se[1]===he[1]&&se[2]===he[2]},e.equals=function Ge(se,he){const ve=se[0],Te=se[1],yt=se[2],xt=he[0],Ut=he[1],Nn=he[2];return Math.abs(ve-xt)<=vr*Math.max(1,Math.abs(ve),Math.abs(xt))&&Math.abs(Te-Ut)<=vr*Math.max(1,Math.abs(Te),Math.abs(Ut))&&Math.abs(yt-Nn)<=vr*Math.max(1,Math.abs(yt),Math.abs(Nn))};const $e=t();e.makeRotation=function tt(se,he,ve){const Te=ne(he,ve);if(Math.abs(Te)<1e-4)return le.setIdentity(se);if(Math.abs(Te-Math.PI)0?p(se,he):j(se,p(se,he)),se};const Qn=t(),qe=t();e.triangleNormal=function dt(se,he,ve,Te){return h(Qn,ve,he),h(qe,Te,he),$(se,q(se,Qn,qe))},e.toString=function gt(se,he){return`[${se[0].toPrecision(he)} ${se[1].toPrecision(he)} ${se[2].toPrecision(he)}]`},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)}(v||(v={}));const Wx=Math.PI/2,EZ=Math.PI/180;function Yn(e){return e*EZ}function su(e){return e/EZ}function $x(e){return 0!==e&&!(e&e-1)}function PZ(e,t){return e*t}function le(){return le.zero()}function Kt(){return Kt.zero()}function Me(){return Me.zero()}function nn(){return nn.zero()}function NI(e){return Object.keys(e)}function Rr(e){throw new Error("unreachable")}function FI(e){return"function"==typeof e?.then}function _r(){return _r.zero()}var wn,te,Xn,JF,Dg,Yx;function Ig(e,t,n){for(;t9||s<0)return o*i|0;i=10*i+s|0}return o*i}function MZ(e,t,n,r){return 43===t.charCodeAt(n)&&n++,e*Math.pow(10,jh(t,n,r))}function rp(e,t,n){let r=t,i=1,o=0,s=0,a=1;for(45===e.charCodeAt(r)?(i=-1,++r):43===e.charCodeAt(r)&&++r;r=0&&c<10)){if(-2===c){for(++r;r=0&&c<10))return 53===c||21===c?MZ(i*(o+s/a),e,r+1,n):i*(o+s/a);s=10*s+c,a*=10,++r}return i*(o+s/a)}if(53===c||21===c)return MZ(i*o,e,r+1,n);break}o=10*o+c,++r}return i*o}function kZ(e,t,n,r){return{schema:n,__array:void 0,isDefined:0===r,rowCount:t,value:o=>e,valueKind:o=>r,toArray:o=>{const{array:s}=qx(t,o);for(let a=0,c=s.length;a!0}}function BI({value:e,valueKind:t,areValuesEqual:n,rowCount:r,schema:i}){return{schema:i,__array:void 0,isDefined:!0,rowCount:r,value:e,valueKind:t||(o=>0),toArray:o=>{const{array:s,start:a}=qx(r,o);for(let c=0,u=s.length;ce(o)===e(s))}}function ip({array:e,schema:t,valueKind:n}){const r=e.length,i=t.T,o="str"===t.valueType?"lowercase"===t.transform?a=>{const c=e[a];return"string"==typeof c?c.toLowerCase():`${c??i}`.toLowerCase()}:"uppercase"===t.transform?a=>{const c=e[a];return"string"==typeof c?c.toUpperCase():`${c??i}`.toUpperCase()}:a=>{const c=e[a];return"string"==typeof c?c:`${c??i}`}:a=>e[a],s=$F(e);return{schema:t,__array:e,isDefined:!0,rowCount:r,value:o,valueKind:n||(a=>0),toArray:"str"===t.valueType?"lowercase"===t.transform?a=>{const{start:c,end:u}=Lb(r,a),l=new(a&&typeof a.array<"u"?a.array:e.constructor)(u-c);for(let d=0,f=u-c;d{const{start:c,end:u}=Lb(r,a),l=new(a&&typeof a.array<"u"?a.array:e.constructor)(u-c);for(let d=0,f=u-c;d{const{start:c,end:u}=Lb(r,a),l=new(a&&typeof a.array<"u"?a.array:e.constructor)(u-c);for(let d=0,f=u-c;dRI(e,a):a=>{const{start:c,end:u}=Lb(r,a);if(0===c&&u===e.length)return e;const l=new(a&&typeof a.array<"u"?a.array:e.constructor)(u-c);for(let d=0,f=u-c;de[a]===e[c]}}function OI(e,t,n){return e[t]-e[n]}function Tg(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function NZ(e,t,n,r){const i=n+r>>1;return t(e,n,r)>0?t(e,n,i)>0?t(e,i,r)>0?i:r:n:t(e,r,i)>0?t(e,i,n)>0?i:n:r}function _Me(e,t,n){const{cmp:r,swap:i,data:o,parts:s}=e;let a=t+1,c=n;for(i(o,t,NZ(o,r,t,n));r(o,c,t)>0;)--c;for(let u=t+1;u<=c;u++){const l=r(o,u,t);if(l>0){for(i(o,u,c),--c;r(o,c,t)>0;)--c;u--}else 0===l&&(i(o,u,a),a++)}for(let u=t;u=r&&t(e,s,s+1)>0;)n(e,s,s+1),s-=1}}function LI(e,t,n){const{parts:r}=e;for(;ts;)--o;for(let a=n+1;a<=o;a++){const c=e[a];if(c>s){for(Tg(e,a,o),--o;e[o]>s;)--o;a--}else c===s&&(Tg(e,a,i),++i)}for(let a=n;a=t&&e[o]>i;)e[o+1]=e[o],o-=1;e[o+1]=i}}function QF(e,t,n,r){for(;nge)return!1;return!0}function l(U,Y,ge,Se){U[4*ge+Y]=Se}function h(U,Y){return U[0]=Y[0],U[1]=Y[1],U[2]=Y[2],U[3]=Y[3],U[4]=Y[4],U[5]=Y[5],U[6]=Y[6],U[7]=Y[7],U[8]=Y[8],U[9]=Y[9],U[10]=Y[10],U[11]=Y[11],U[12]=Y[12],U[13]=Y[13],U[14]=Y[14],U[15]=Y[15],U}function x(U,Y){const ge=Y[0]+Y[5]+Y[10];let Se=0;return ge>0?(Se=2*Math.sqrt(ge+1),U[3]=.25*Se,U[0]=(Y[6]-Y[9])/Se,U[1]=(Y[8]-Y[2])/Se,U[2]=(Y[1]-Y[4])/Se):Y[0]>Y[5]&&Y[0]>Y[10]?(Se=2*Math.sqrt(1+Y[0]-Y[5]-Y[10]),U[3]=(Y[6]-Y[9])/Se,U[0]=.25*Se,U[1]=(Y[1]+Y[4])/Se,U[2]=(Y[8]+Y[2])/Se):Y[5]>Y[10]?(Se=2*Math.sqrt(1+Y[5]-Y[0]-Y[10]),U[3]=(Y[8]-Y[2])/Se,U[0]=(Y[1]+Y[4])/Se,U[1]=.25*Se,U[2]=(Y[6]+Y[9])/Se):(Se=2*Math.sqrt(1+Y[10]-Y[0]-Y[5]),U[3]=(Y[1]-Y[4])/Se,U[0]=(Y[8]+Y[2])/Se,U[1]=(Y[6]+Y[9])/Se,U[2]=.25*Se),U}function A(U,Y){const ge=Y[0],Se=Y[1],Re=Y[2],Ne=Y[3],Ge=Y[4],$e=Y[5],tt=Y[6],ke=Y[7],Xe=Y[8],ot=Y[9],_t=Y[10],ut=Y[11],Ct=Y[12],Et=Y[13],Xt=Y[14],ln=Y[15],Qn=ge*$e-Se*Ge,qe=ge*tt-Re*Ge,dt=ge*ke-Ne*Ge,gt=Se*tt-Re*$e,se=Se*ke-Ne*$e,he=Re*ke-Ne*tt,ve=Xe*Et-ot*Ct,Te=Xe*Xt-_t*Ct,yt=Xe*ln-ut*Ct,xt=ot*Xt-_t*Et,Ut=ot*ln-ut*Et,Nn=_t*ln-ut*Xt;let hn=Qn*Nn-qe*Ut+dt*xt+gt*yt-se*Te+he*ve;return!!hn&&(hn=1/hn,U[0]=($e*Nn-tt*Ut+ke*xt)*hn,U[1]=(Re*Ut-Se*Nn-Ne*xt)*hn,U[2]=(Et*he-Xt*se+ln*gt)*hn,U[3]=(_t*se-ot*he-ut*gt)*hn,U[4]=(tt*yt-Ge*Nn-ke*Te)*hn,U[5]=(ge*Nn-Re*yt+Ne*Te)*hn,U[6]=(Xt*dt-Ct*he-ln*qe)*hn,U[7]=(Xe*he-_t*dt+ut*qe)*hn,U[8]=(Ge*Ut-$e*yt+ke*ve)*hn,U[9]=(Se*yt-ge*Ut-Ne*ve)*hn,U[10]=(Ct*se-Et*dt+ln*Qn)*hn,U[11]=(ot*dt-Xe*se-ut*Qn)*hn,U[12]=($e*Te-Ge*xt-tt*ve)*hn,U[13]=(ge*xt-Se*Te+Re*ve)*hn,U[14]=(Et*qe-Ct*gt-Xt*Qn)*hn,U[15]=(Xe*gt-ot*qe+_t*Qn)*hn,!0)}function w(U,Y,ge){const Se=Y[0],Re=Y[1],Ne=Y[2],Ge=Y[3],$e=Y[4],tt=Y[5],ke=Y[6],Xe=Y[7],ot=Y[8],_t=Y[9],ut=Y[10],Ct=Y[11],Et=Y[12],Xt=Y[13],ln=Y[14],Qn=Y[15];let qe=ge[0],dt=ge[1],gt=ge[2],se=ge[3];return U[0]=qe*Se+dt*$e+gt*ot+se*Et,U[1]=qe*Re+dt*tt+gt*_t+se*Xt,U[2]=qe*Ne+dt*ke+gt*ut+se*ln,U[3]=qe*Ge+dt*Xe+gt*Ct+se*Qn,qe=ge[4],dt=ge[5],gt=ge[6],se=ge[7],U[4]=qe*Se+dt*$e+gt*ot+se*Et,U[5]=qe*Re+dt*tt+gt*_t+se*Xt,U[6]=qe*Ne+dt*ke+gt*ut+se*ln,U[7]=qe*Ge+dt*Xe+gt*Ct+se*Qn,qe=ge[8],dt=ge[9],gt=ge[10],se=ge[11],U[8]=qe*Se+dt*$e+gt*ot+se*Et,U[9]=qe*Re+dt*tt+gt*_t+se*Xt,U[10]=qe*Ne+dt*ke+gt*ut+se*ln,U[11]=qe*Ge+dt*Xe+gt*Ct+se*Qn,qe=ge[12],dt=ge[13],gt=ge[14],se=ge[15],U[12]=qe*Se+dt*$e+gt*ot+se*Et,U[13]=qe*Re+dt*tt+gt*_t+se*Xt,U[14]=qe*Ne+dt*ke+gt*ut+se*ln,U[15]=qe*Ge+dt*Xe+gt*Ct+se*Qn,U}function F(U,Y,ge){let Se=ge[0],Re=ge[1],Ne=ge[2],Ge=Math.sqrt(Se*Se+Re*Re+Ne*Ne);if(Math.abs(Ge)"u"?vr:Y)},e.hasNaN=function c(U){for(let Y=0;Y<16;Y++)if(isNaN(U[Y]))return!0;return!1},e.areEqual=u,e.setValue=l,e.getValue=function d(U,Y,ge){return U[4*ge+Y]},e.toArray=function f(U,Y,ge){return Y[ge+0]=U[0],Y[ge+1]=U[1],Y[ge+2]=U[2],Y[ge+3]=U[3],Y[ge+4]=U[4],Y[ge+5]=U[5],Y[ge+6]=U[6],Y[ge+7]=U[7],Y[ge+8]=U[8],Y[ge+9]=U[9],Y[ge+10]=U[10],Y[ge+11]=U[11],Y[ge+12]=U[12],Y[ge+13]=U[13],Y[ge+14]=U[14],Y[ge+15]=U[15],Y},e.fromArray=function p(U,Y,ge){return U[0]=Y[ge+0],U[1]=Y[ge+1],U[2]=Y[ge+2],U[3]=Y[ge+3],U[4]=Y[ge+4],U[5]=Y[ge+5],U[6]=Y[ge+6],U[7]=Y[ge+7],U[8]=Y[ge+8],U[9]=Y[ge+9],U[10]=Y[ge+10],U[11]=Y[ge+11],U[12]=Y[ge+12],U[13]=Y[ge+13],U[14]=Y[ge+14],U[15]=Y[ge+15],U},e.fromBasis=function m(U,Y,ge,Se){return i(U),l(U,0,0,Y[0]),l(U,1,0,Y[1]),l(U,2,0,Y[2]),l(U,0,1,ge[0]),l(U,1,1,ge[1]),l(U,2,1,ge[2]),l(U,0,2,Se[0]),l(U,1,2,Se[1]),l(U,2,2,Se[2]),l(U,3,3,1),U},e.copy=h,e.clone=function g(U){return h(t(),U)},e.getTranslation=function y(U,Y){return U[0]=Y[12],U[1]=Y[13],U[2]=Y[14],U},e.getScaling=function b(U,Y){const ge=Y[0],Se=Y[1],Re=Y[2],Ne=Y[4],Ge=Y[5],$e=Y[6],tt=Y[8],ke=Y[9],Xe=Y[10];return U[0]=Math.sqrt(ge*ge+Se*Se+Re*Re),U[1]=Math.sqrt(Ne*Ne+Ge*Ge+$e*$e),U[2]=Math.sqrt(tt*tt+ke*ke+Xe*Xe),U},e.getRotation=x,e.extractRotation=function _(U,Y){const ge=1/Math.sqrt(Y[0]*Y[0]+Y[1]*Y[1]+Y[2]*Y[2]),Se=1/Math.sqrt(Y[4]*Y[4]+Y[5]*Y[5]+Y[6]*Y[6]),Re=1/Math.sqrt(Y[8]*Y[8]+Y[9]*Y[9]+Y[10]*Y[10]);return U[0]=Y[0]*ge,U[1]=Y[1]*ge,U[2]=Y[2]*ge,U[3]=0,U[4]=Y[4]*Se,U[5]=Y[5]*Se,U[6]=Y[6]*Se,U[7]=0,U[8]=Y[8]*Re,U[9]=Y[9]*Re,U[10]=Y[10]*Re,U[11]=0,U[12]=0,U[13]=0,U[14]=0,U[15]=1,U},e.transpose=function S(U,Y){if(U===Y){const ge=Y[1],Se=Y[2],Re=Y[3],Ne=Y[6],Ge=Y[7],$e=Y[11];U[1]=Y[4],U[2]=Y[8],U[3]=Y[12],U[4]=ge,U[6]=Y[9],U[7]=Y[13],U[8]=Se,U[9]=Ne,U[11]=Y[14],U[12]=Re,U[13]=Ge,U[14]=$e}else U[0]=Y[0],U[1]=Y[4],U[2]=Y[8],U[3]=Y[12],U[4]=Y[1],U[5]=Y[5],U[6]=Y[9],U[7]=Y[13],U[8]=Y[2],U[9]=Y[6],U[10]=Y[10],U[11]=Y[14],U[12]=Y[3],U[13]=Y[7],U[14]=Y[11],U[15]=Y[15];return U},e.tryInvert=A,e.invert=function E(U,Y){return A(U,Y)||console.warn("non-invertible matrix.",Y),U},e.mul=w,e.mulOffset=function D(U,Y,ge,Se,Re,Ne){const Ge=Y[0+Re],$e=Y[1+Re],tt=Y[2+Re],ke=Y[3+Re],Xe=Y[4+Re],ot=Y[5+Re],_t=Y[6+Re],ut=Y[7+Re],Ct=Y[8+Re],Et=Y[9+Re],Xt=Y[10+Re],ln=Y[11+Re],Qn=Y[12+Re],qe=Y[13+Re],dt=Y[14+Re],gt=Y[15+Re];let se=ge[0+Ne],he=ge[1+Ne],ve=ge[2+Ne],Te=ge[3+Ne];return U[0+Se]=se*Ge+he*Xe+ve*Ct+Te*Qn,U[1+Se]=se*$e+he*ot+ve*Et+Te*qe,U[2+Se]=se*tt+he*_t+ve*Xt+Te*dt,U[3+Se]=se*ke+he*ut+ve*ln+Te*gt,se=ge[4+Ne],he=ge[5+Ne],ve=ge[6+Ne],Te=ge[7+Ne],U[4+Se]=se*Ge+he*Xe+ve*Ct+Te*Qn,U[5+Se]=se*$e+he*ot+ve*Et+Te*qe,U[6+Se]=se*tt+he*_t+ve*Xt+Te*dt,U[7+Se]=se*ke+he*ut+ve*ln+Te*gt,se=ge[8+Ne],he=ge[9+Ne],ve=ge[10+Ne],Te=ge[11+Ne],U[8+Se]=se*Ge+he*Xe+ve*Ct+Te*Qn,U[9+Se]=se*$e+he*ot+ve*Et+Te*qe,U[10+Se]=se*tt+he*_t+ve*Xt+Te*dt,U[11+Se]=se*ke+he*ut+ve*ln+Te*gt,se=ge[12+Ne],he=ge[13+Ne],ve=ge[14+Ne],Te=ge[15+Ne],U[12+Se]=se*Ge+he*Xe+ve*Ct+Te*Qn,U[13+Se]=se*$e+he*ot+ve*Et+Te*qe,U[14+Se]=se*tt+he*_t+ve*Xt+Te*dt,U[15+Se]=se*ke+he*ut+ve*ln+Te*gt,U},e.mul3=function I(U,Y,ge,Se){return w(U,w(U,Y,ge),Se)},e.translate=function R(U,Y,ge){const Se=ge[0],Re=ge[1],Ne=ge[2];let Ge,$e,tt,ke,Xe,ot,_t,ut,Ct,Et,Xt,ln;return Y===U?(U[12]=Y[0]*Se+Y[4]*Re+Y[8]*Ne+Y[12],U[13]=Y[1]*Se+Y[5]*Re+Y[9]*Ne+Y[13],U[14]=Y[2]*Se+Y[6]*Re+Y[10]*Ne+Y[14],U[15]=Y[3]*Se+Y[7]*Re+Y[11]*Ne+Y[15]):(Ge=Y[0],$e=Y[1],tt=Y[2],ke=Y[3],Xe=Y[4],ot=Y[5],_t=Y[6],ut=Y[7],Ct=Y[8],Et=Y[9],Xt=Y[10],ln=Y[11],U[0]=Ge,U[1]=$e,U[2]=tt,U[3]=ke,U[4]=Xe,U[5]=ot,U[6]=_t,U[7]=ut,U[8]=Ct,U[9]=Et,U[10]=Xt,U[11]=ln,U[12]=Ge*Se+Xe*Re+Ct*Ne+Y[12],U[13]=$e*Se+ot*Re+Et*Ne+Y[13],U[14]=tt*Se+_t*Re+Xt*Ne+Y[14],U[15]=ke*Se+ut*Re+ln*Ne+Y[15]),U},e.fromTranslation=function T(U,Y){return U[0]=1,U[1]=0,U[2]=0,U[3]=0,U[4]=0,U[5]=1,U[6]=0,U[7]=0,U[8]=0,U[9]=0,U[10]=1,U[11]=0,U[12]=Y[0],U[13]=Y[1],U[14]=Y[2],U[15]=1,U},e.setTranslation=function M(U,Y){return U[12]=Y[0],U[13]=Y[1],U[14]=Y[2],U},e.setAxes=function N(U,Y,ge,Se){return U[0]=ge[0],U[4]=ge[1],U[8]=ge[2],U[1]=Se[0],U[5]=Se[1],U[9]=Se[2],U[2]=Y[0],U[6]=Y[1],U[10]=Y[2],U},e.rotate=function V(U,Y,ge,Se){let Re=Se[0],Ne=Se[1],Ge=Se[2],$e=Math.sqrt(Re*Re+Ne*Ne+Ge*Ge);if(Math.abs($e)0&&(ut=1/Math.sqrt(ut),Xe*=ut,ot*=ut,_t*=ut);let Ct=tt*_t-ke*ot,Et=ke*Xe-$e*_t,Xt=$e*ot-tt*Xe;return ut=Ct*Ct+Et*Et+Xt*Xt,ut>0&&(ut=1/Math.sqrt(ut),Ct*=ut,Et*=ut,Xt*=ut),U[0]=Ct,U[1]=Et,U[2]=Xt,U[3]=0,U[4]=ot*Xt-_t*Et,U[5]=_t*Ct-Xe*Xt,U[6]=Xe*Et-ot*Ct,U[7]=0,U[8]=Xe,U[9]=ot,U[10]=_t,U[11]=0,U[12]=Re,U[13]=Ne,U[14]=Ge,U[15]=1,U},e.fromPermutation=function ne(U,Y){i(U);for(let ge=0;ge<4;ge++)l(U,ge,Y[ge],1);return U},e.getMaxScaleOnAxis=function de(U){return Math.sqrt(Math.max(U[0]*U[0]+U[1]*U[1]+U[2]*U[2],U[4]*U[4]+U[5]*U[5]+U[6]*U[6],U[8]*U[8]+U[9]*U[9]+U[10]*U[10]))};const we=[1,0,0],Le=[0,1,0],We=[0,0,1];e.rotX90=F(t(),Yn(90),we),e.rotX180=F(t(),Yn(180),we),e.rotY90=F(t(),Yn(90),Le),e.rotY180=F(t(),Yn(180),Le),e.rotY270=F(t(),Yn(270),Le),e.rotZ90=F(t(),Yn(90),We),e.rotZ180=F(t(),Yn(180),We),e.rotXY90=w(t(),e.rotX90,e.rotY90),e.rotZY90=w(t(),e.rotZ90,e.rotY90),e.rotZYZ90=w(t(),e.rotZY90,e.rotZ90),e.rotZ90X180=w(t(),e.rotZ90,e.rotX180),e.rotY90Z180=w(t(),e.rotY90,e.rotZ180),e.id=n()}(le||(le={})),function(e){function t(){const O=[.1,0,0,0,0,0,0,0,0];return O[0]=0,O}function n(){const O=t();return O[0]=1,O[1]=0,O[2]=0,O[3]=0,O[4]=1,O[5]=0,O[6]=0,O[7]=0,O[8]=1,O}function a(O,H){return O[0]=H[0],O[1]=H[1],O[2]=H[2],O[3]=H[4],O[4]=H[5],O[5]=H[6],O[6]=H[8],O[7]=H[9],O[8]=H[10],O}e.zero=t,e.identity=n,e.setIdentity=function r(O){return O[0]=1,O[1]=0,O[2]=0,O[3]=0,O[4]=1,O[5]=0,O[6]=0,O[7]=0,O[8]=1,O},e.toArray=function i(O,H,W){return H[W+0]=O[0],H[W+1]=O[1],H[W+2]=O[2],H[W+3]=O[3],H[W+4]=O[4],H[W+5]=O[5],H[W+6]=O[6],H[W+7]=O[7],H[W+8]=O[8],H},e.fromArray=function o(O,H,W){return O[0]=H[W+0],O[1]=H[W+1],O[2]=H[W+2],O[3]=H[W+3],O[4]=H[W+4],O[5]=H[W+5],O[6]=H[W+6],O[7]=H[W+7],O[8]=H[W+8],O},e.fromColumns=function s(O,H,W,Q){return O[0]=H[0],O[1]=H[1],O[2]=H[2],O[3]=W[0],O[4]=W[1],O[5]=W[2],O[6]=Q[0],O[7]=Q[1],O[8]=Q[2],O},e.fromMat4=a,e.create=function c(O,H,W,Q,fe,X,J,ce,be){const ae=t();return ae[0]=O,ae[1]=H,ae[2]=W,ae[3]=Q,ae[4]=fe,ae[5]=X,ae[6]=J,ae[7]=ce,ae[8]=be,ae};const u=n();function p(O,H,W){for(let Q=0;Q<9;Q++)if(Math.abs(O[Q]-H[Q])>W)return!1;return!0}function g(O,H){return O[0]=H[0],O[1]=H[1],O[2]=H[2],O[3]=H[3],O[4]=H[4],O[5]=H[5],O[6]=H[6],O[7]=H[7],O[8]=H[8],O}function y(O,H){if(O===H){const W=H[1],Q=H[2],fe=H[5];O[1]=H[3],O[2]=H[6],O[3]=W,O[5]=H[7],O[6]=Q,O[7]=fe}else O[0]=H[0],O[1]=H[3],O[2]=H[6],O[3]=H[1],O[4]=H[4],O[5]=H[7],O[6]=H[2],O[7]=H[5],O[8]=H[8];return O}function b(O,H){const W=H[0],Q=H[1],fe=H[2],X=H[3],J=H[4],ce=H[5],be=H[6],ae=H[7],me=H[8],oe=me*J-ce*ae,K=-me*X+ce*be,ne=ae*X-J*be;let de=W*oe+Q*K+fe*ne;return de?(de=1/de,O[0]=oe*de,O[1]=(-me*Q+fe*ae)*de,O[2]=(ce*Q-fe*J)*de,O[3]=K*de,O[4]=(me*W-fe*be)*de,O[5]=(-ce*W+fe*X)*de,O[6]=ne*de,O[7]=(-ae*W+Q*be)*de,O[8]=(J*W-Q*X)*de,O):(console.warn("non-invertible matrix.",H),O)}function S(O){const fe=O[3],X=O[4],J=O[5],ce=O[6],be=O[7],ae=O[8];return O[0]*(ae*X-J*be)+O[1]*(-ae*fe+J*ce)+O[2]*(be*fe-X*ce)}function A(O){return O[0]+O[4]+O[8]}function E(O,H,W){return O[0]=H[0]-W[0],O[1]=H[1]-W[1],O[2]=H[2]-W[2],O[3]=H[3]-W[3],O[4]=H[4]-W[4],O[5]=H[5]-W[5],O[6]=H[6]-W[6],O[7]=H[7]-W[7],O[8]=H[8]-W[8],O}function T(O,H,W){return O[0]=H[0]*W,O[1]=H[1]*W,O[2]=H[2]*W,O[3]=H[3]*W,O[4]=H[4]*W,O[5]=H[5]*W,O[6]=H[6]*W,O[7]=H[7]*W,O[8]=H[8]*W,O}e.isIdentity=function l(O,H){return p(O,u,typeof H>"u"?vr:H)},e.hasNaN=function d(O){for(let H=0;H<9;H++)if(isNaN(O[H]))return!0;return!1},e.clone=function f(O){return g(t(),O)},e.areEqual=p,e.setValue=function m(O,H,W,Q){O[3*W+H]=Q},e.getValue=function h(O,H,W){return O[3*W+H]},e.copy=g,e.transpose=y,e.invert=b,e.symmtricFromUpper=function x(O,H){return O===H?(O[3]=H[1],O[6]=H[2],O[7]=H[5]):(O[0]=H[0],O[1]=H[1],O[2]=H[2],O[3]=H[1],O[4]=H[4],O[5]=H[5],O[6]=H[2],O[7]=H[5],O[8]=H[8]),O},e.symmtricFromLower=function _(O,H){return O===H?(O[1]=H[3],O[2]=H[6],O[5]=H[7]):(O[0]=H[0],O[1]=H[3],O[2]=H[6],O[3]=H[3],O[4]=H[4],O[5]=H[7],O[6]=H[6],O[7]=H[7],O[8]=H[8]),O},e.determinant=S,e.trace=A,e.sub=E,e.add=function w(O,H,W){return O[0]=H[0]+W[0],O[1]=H[1]+W[1],O[2]=H[2]+W[2],O[3]=H[3]+W[3],O[4]=H[4]+W[4],O[5]=H[5]+W[5],O[6]=H[6]+W[6],O[7]=H[7]+W[7],O[8]=H[8]+W[8],O},e.mul=function D(O,H,W){const Q=H[0],fe=H[1],X=H[2],J=H[3],ce=H[4],be=H[5],ae=H[6],me=H[7],oe=H[8],K=W[0],ne=W[1],de=W[2],we=W[3],Le=W[4],We=W[5],U=W[6],Y=W[7],ge=W[8];return O[0]=K*Q+ne*J+de*ae,O[1]=K*fe+ne*ce+de*me,O[2]=K*X+ne*be+de*oe,O[3]=we*Q+Le*J+We*ae,O[4]=we*fe+Le*ce+We*me,O[5]=we*X+Le*be+We*oe,O[6]=U*Q+Y*J+ge*ae,O[7]=U*fe+Y*ce+ge*me,O[8]=U*X+Y*be+ge*oe,O},e.subScalar=function I(O,H,W){return O[0]=H[0]-W,O[1]=H[1]-W,O[2]=H[2]-W,O[3]=H[3]-W,O[4]=H[4]-W,O[5]=H[5]-W,O[6]=H[6]-W,O[7]=H[7]-W,O[8]=H[8]-W,O},e.addScalar=function R(O,H,W){return O[0]=H[0]+W,O[1]=H[1]+W,O[2]=H[2]+W,O[3]=H[3]+W,O[4]=H[4]+W,O[5]=H[5]+W,O[6]=H[6]+W,O[7]=H[7]+W,O[8]=H[8]+W,O},e.mulScalar=T;const M=Math.PI/3,N=t();e.symmetricEigenvalues=function V(O,H){const W=H[1]*H[1]+H[2]*H[2]+H[5]*H[5];if(0===W)O[0]=H[0],O[1]=H[4],O[2]=H[8];else{const Q=A(H)/3,fe=H[0]-Q,X=H[4]-Q,J=H[8]-Q,be=Math.sqrt((fe*fe+X*X+J*J+2*W)/6);T(N,e.Identity,Q),E(N,H,N),T(N,N,1/be);const ae=S(N)/2,me=ae<=-1?M:ae>=1?0:Math.acos(ae)/3;O[0]=Q+2*be*Math.cos(me),O[2]=Q+2*be*Math.cos(me+2*M),O[1]=3*Q-O[0]-O[2]}return O};const F=[.1,0,0],G=[.1,0,0],L=[.1,0,0],z=[.1,0,0],j=[.1,0,0],Z=[.1,0,0];e.eigenvector=function $(O,H,W){v.set(F,H[0]-W,H[1],H[2]),v.set(G,H[1],H[4]-W,H[5]),v.set(L,H[2],H[5],H[8]-W),v.cross(z,F,G),v.cross(j,F,L),v.cross(Z,G,L);const Q=v.dot(z,z),fe=v.dot(j,j),X=v.dot(Z,Z);let J=Q,ce=0;return fe>J&&(J=fe,ce=1),X>J&&(ce=2),0===ce?v.scale(O,z,1/Math.sqrt(Q)):1===ce?v.scale(O,j,1/Math.sqrt(fe)):v.scale(O,Z,1/Math.sqrt(X)),O},e.directionTransform=function ee(O,H){return a(O,H),b(O,O),y(O,O),O},e.Identity=n(),e.innerProduct=function q(O,H){return O[0]*H[0]+O[1]*H[1]+O[2]*H[2]+O[3]*H[3]+O[4]*H[4]+O[5]*H[5]+O[6]*H[6]+O[7]*H[7]+O[8]*H[8]}}(Kt||(Kt={})),function(e){function t(){const w=[.1,0];return w[0]=0,w}e.zero=t,e.clone=function n(w){const D=t();return D[0]=w[0],D[1]=w[1],D},e.create=function r(w,D){const I=t();return I[0]=w,I[1]=D,I},e.hasNaN=function i(w){return isNaN(w[0])||isNaN(w[1])},e.toArray=function o(w,D,I){return D[I+0]=w[0],D[I+1]=w[1],D},e.fromArray=function s(w,D,I){return w[0]=D[I+0],w[1]=D[I+1],w},e.copy=function a(w,D){return w[0]=D[0],w[1]=D[1],w},e.set=function c(w,D,I){return w[0]=D,w[1]=I,w},e.add=function u(w,D,I){return w[0]=D[0]+I[0],w[1]=D[1]+I[1],w},e.sub=function l(w,D,I){return w[0]=D[0]-I[0],w[1]=D[1]-I[1],w},e.mul=function d(w,D,I){return w[0]=D[0]*I[0],w[1]=D[1]*I[1],w},e.div=function f(w,D,I){return w[0]=D[0]/I[0],w[1]=D[1]/I[1],w},e.scale=function p(w,D,I){return w[0]=D[0]*I,w[1]=D[1]*I,w},e.round=function m(w,D){return w[0]=Math.round(D[0]),w[1]=Math.round(D[1]),w},e.ceil=function h(w,D){return w[0]=Math.ceil(D[0]),w[1]=Math.ceil(D[1]),w},e.floor=function g(w,D){return w[0]=Math.floor(D[0]),w[1]=Math.floor(D[1]),w},e.distance=function y(w,D){const I=D[0]-w[0],R=D[1]-w[1];return Math.sqrt(I*I+R*R)},e.squaredDistance=function b(w,D){const I=D[0]-w[0],R=D[1]-w[1];return I*I+R*R},e.magnitude=function x(w){const D=w[0],I=w[1];return Math.sqrt(D*D+I*I)},e.squaredMagnitude=function _(w){const D=w[0],I=w[1];return D*D+I*I},e.inverse=function S(w,D){return w[0]=1/D[0],w[1]=1/D[1],w},e.areEqual=function A(w,D){return w[0]===D[0]&&w[1]===D[1]},e.toString=function E(w,D){return`[${w[0].toPrecision(D)} ${w[1].toPrecision(D)}}]`}}(Me||(Me={})),function(e){function t(){const T=[.1,0,0,0];return T[0]=0,T}function i(T,M){return T[0]=M.center[0],T[1]=M.center[1],T[2]=M.center[2],T[3]=M.radius,T}e.zero=t,e.clone=function n(T){const M=t();return M[0]=T[0],M[1]=T[1],M[2]=T[2],M[3]=T[3],M},e.create=function r(T,M,N,V){const F=t();return F[0]=T,F[1]=M,F[2]=N,F[3]=V,F},e.fromSphere=i,e.ofSphere=function o(T){return i(t(),T)},e.hasNaN=function s(T){return isNaN(T[0])||isNaN(T[1])||isNaN(T[2])||isNaN(T[3])},e.toArray=function a(T,M,N){return M[N+0]=T[0],M[N+1]=T[1],M[N+2]=T[2],M[N+3]=T[3],M},e.fromArray=function c(T,M,N){return T[0]=M[N+0],T[1]=M[N+1],T[2]=M[N+2],T[3]=M[N+3],T},e.toVec3Array=function u(T,M,N){M[N+0]=T[0],M[N+1]=T[1],M[N+2]=T[2]},e.fromVec3Array=function l(T,M,N){return T[0]=M[N+0],T[1]=M[N+1],T[2]=M[N+2],T[3]=0,T},e.copy=function d(T,M){return T[0]=M[0],T[1]=M[1],T[2]=M[2],T[3]=M[3],T},e.set=function f(T,M,N,V,F){return T[0]=M,T[1]=N,T[2]=V,T[3]=F,T},e.add=function p(T,M,N){return T[0]=M[0]+N[0],T[1]=M[1]+N[1],T[2]=M[2]+N[2],T[3]=M[3]+N[3],T},e.distance=function m(T,M){const N=M[0]-T[0],V=M[1]-T[1],F=M[2]-T[2],G=M[3]-T[3];return Math.sqrt(N*N+V*V+F*F+G*G)},e.scale=function h(T,M,N){return T[0]=M[0]*N,T[1]=M[1]*N,T[2]=M[2]*N,T[4]=M[4]*N,T},e.round=function g(T,M){return T[0]=Math.round(M[0]),T[1]=Math.round(M[1]),T[2]=Math.round(M[2]),T[3]=Math.round(M[3]),T},e.ceil=function y(T,M){return T[0]=Math.ceil(M[0]),T[1]=Math.ceil(M[1]),T[2]=Math.ceil(M[2]),T[3]=Math.ceil(M[3]),T},e.floor=function b(T,M){return T[0]=Math.floor(M[0]),T[1]=Math.floor(M[1]),T[2]=Math.floor(M[2]),T[3]=Math.floor(M[3]),T},e.squaredDistance=function x(T,M){const N=M[0]-T[0],V=M[1]-T[1],F=M[2]-T[2],G=M[3]-T[3];return N*N+V*V+F*F+G*G},e.norm=function _(T){const M=T[0],N=T[1],V=T[2],F=T[3];return Math.sqrt(M*M+N*N+V*V+F*F)},e.squaredNorm=function S(T){const M=T[0],N=T[1],V=T[2],F=T[3];return M*M+N*N+V*V+F*F},e.transformMat4=function A(T,M,N){const V=M[0],F=M[1],G=M[2],L=M[3];return T[0]=N[0]*V+N[4]*F+N[8]*G+N[12]*L,T[1]=N[1]*V+N[5]*F+N[9]*G+N[13]*L,T[2]=N[2]*V+N[6]*F+N[10]*G+N[14]*L,T[3]=N[3]*V+N[7]*F+N[11]*G+N[15]*L,T},e.dot=function E(T,M){return T[0]*M[0]+T[1]*M[1]+T[2]*M[2]+T[3]*M[3]},e.inverse=function w(T,M){return T[0]=1/M[0],T[1]=1/M[1],T[2]=1/M[2],T[3]=1/M[3],T},e.exactEquals=function D(T,M){return T[0]===M[0]&&T[1]===M[1]&&T[2]===M[2]&&T[3]===M[3]},e.equals=function I(T,M){const N=T[0],V=T[1],F=T[2],G=T[3],L=M[0],z=M[1],j=M[2],Z=M[3];return Math.abs(N-L)<=vr*Math.max(1,Math.abs(N),Math.abs(L))&&Math.abs(V-z)<=vr*Math.max(1,Math.abs(V),Math.abs(z))&&Math.abs(F-j)<=vr*Math.max(1,Math.abs(F),Math.abs(j))&&Math.abs(G-Z)<=vr*Math.max(1,Math.abs(G),Math.abs(Z))},e.toString=function R(T,M){return`[${T[0].toPrecision(M)} ${T[1].toPrecision(M)} ${T[2].toPrecision(M)} ${T[3].toPrecision(M)}]`}}(nn||(nn={})),function(e){function t(){const q=[.1,0,0,0];return q[0]=0,q}function n(){const q=t();return q[3]=1,q}function s(q,O,H){H*=.5;const W=Math.sin(H);return q[0]=W*O[0],q[1]=W*O[1],q[2]=W*O[2],q[3]=Math.cos(H),q}function p(q,O,H,W){const Q=O[0],fe=O[1],X=O[2],J=O[3];let oe,K,ne,de,we,ce=H[0],be=H[1],ae=H[2],me=H[3];return K=Q*ce+fe*be+X*ae+J*me,K<0&&(K=-K,ce=-ce,be=-be,ae=-ae,me=-me),1-K>1e-6?(oe=Math.acos(K),ne=Math.sin(oe),de=Math.sin((1-W)*oe)/ne,we=Math.sin(W*oe)/ne):(de=1-W,we=W),q[0]=de*Q+we*ce,q[1]=de*fe+we*be,q[2]=de*X+we*ae,q[3]=de*J+we*me,q}function y(q,O){const H=O[0]+O[4]+O[8];let W;if(H>0)W=Math.sqrt(H+1),q[3]=.5*W,W=.5/W,q[0]=(O[5]-O[7])*W,q[1]=(O[6]-O[2])*W,q[2]=(O[1]-O[3])*W;else{let Q=0;O[4]>O[0]&&(Q=1),O[8]>O[3*Q+Q]&&(Q=2);const fe=(Q+1)%3,X=(Q+2)%3;W=Math.sqrt(O[3*Q+Q]-O[3*fe+fe]-O[3*X+X]+1),q[Q]=.5*W,W=.5/W,q[3]=(O[3*fe+X]-O[3*X+fe])*W,q[fe]=(O[3*fe+Q]+O[3*Q+fe])*W,q[X]=(O[3*X+Q]+O[3*Q+X])*W}return q}e.zero=t,e.identity=n,e.setIdentity=function r(q){q[0]=0,q[1]=0,q[2]=0,q[3]=1},e.hasNaN=function i(q){return isNaN(q[0])||isNaN(q[1])||isNaN(q[2])||isNaN(q[3])},e.create=function o(q,O,H,W){const Q=n();return Q[0]=q,Q[1]=O,Q[2]=H,Q[3]=W,Q},e.setAxisAngle=s,e.getAxisAngle=function a(q,O){const H=2*Math.acos(O[3]),W=Math.sin(H/2);return 0!==W?(q[0]=O[0]/W,q[1]=O[1]/W,q[2]=O[2]/W):(q[0]=1,q[1]=0,q[2]=0),H},e.multiply=function c(q,O,H){const W=O[0],Q=O[1],fe=O[2],X=O[3],J=H[0],ce=H[1],be=H[2],ae=H[3];return q[0]=W*ae+X*J+Q*be-fe*ce,q[1]=Q*ae+X*ce+fe*J-W*be,q[2]=fe*ae+X*be+W*ce-Q*J,q[3]=X*ae-W*J-Q*ce-fe*be,q},e.rotateX=function u(q,O,H){H*=.5;const W=O[0],Q=O[1],fe=O[2],X=O[3],J=Math.sin(H),ce=Math.cos(H);return q[0]=W*ce+X*J,q[1]=Q*ce+fe*J,q[2]=fe*ce-Q*J,q[3]=X*ce-W*J,q},e.rotateY=function l(q,O,H){H*=.5;const W=O[0],Q=O[1],fe=O[2],X=O[3],J=Math.sin(H),ce=Math.cos(H);return q[0]=W*ce-fe*J,q[1]=Q*ce+X*J,q[2]=fe*ce+W*J,q[3]=X*ce-Q*J,q},e.rotateZ=function d(q,O,H){H*=.5;const W=O[0],Q=O[1],fe=O[2],X=O[3],J=Math.sin(H),ce=Math.cos(H);return q[0]=W*ce+Q*J,q[1]=Q*ce-W*J,q[2]=fe*ce+X*J,q[3]=X*ce-fe*J,q},e.calculateW=function f(q,O){const H=O[0],W=O[1],Q=O[2];return q[0]=H,q[1]=W,q[2]=Q,q[3]=Math.sqrt(Math.abs(1-H*H-W*W-Q*Q)),q},e.slerp=p,e.invert=function m(q,O){const H=O[0],W=O[1],Q=O[2],fe=O[3],X=H*H+W*W+Q*Q+fe*fe,J=X?1/X:0;return q[0]=-H*J,q[1]=-W*J,q[2]=-Q*J,q[3]=fe*J,q},e.conjugate=function h(q,O){return q[0]=-O[0],q[1]=-O[1],q[2]=-O[2],q[3]=O[3],q},e.dot=function g(q,O){return q[0]*O[0]+q[1]*O[1]+q[2]*O[2]+q[3]*O[3]},e.fromMat3=y,e.fromEuler=function b(q,O,H){const[W,Q,fe]=O,X=Math.cos(W/2),J=Math.cos(Q/2),ce=Math.cos(fe/2),be=Math.sin(W/2),ae=Math.sin(Q/2),me=Math.sin(fe/2);switch(H){case"XYZ":q[0]=be*J*ce+X*ae*me,q[1]=X*ae*ce-be*J*me,q[2]=X*J*me+be*ae*ce,q[3]=X*J*ce-be*ae*me;break;case"YXZ":q[0]=be*J*ce+X*ae*me,q[1]=X*ae*ce-be*J*me,q[2]=X*J*me-be*ae*ce,q[3]=X*J*ce+be*ae*me;break;case"ZXY":q[0]=be*J*ce-X*ae*me,q[1]=X*ae*ce+be*J*me,q[2]=X*J*me+be*ae*ce,q[3]=X*J*ce-be*ae*me;break;case"ZYX":q[0]=be*J*ce-X*ae*me,q[1]=X*ae*ce+be*J*me,q[2]=X*J*me-be*ae*ce,q[3]=X*J*ce+be*ae*me;break;case"YZX":q[0]=be*J*ce+X*ae*me,q[1]=X*ae*ce+be*J*me,q[2]=X*J*me-be*ae*ce,q[3]=X*J*ce-be*ae*me;break;case"XZY":q[0]=be*J*ce-X*ae*me,q[1]=X*ae*ce-be*J*me,q[2]=X*J*me+be*ae*ce,q[3]=X*J*ce+be*ae*me;break;default:Rr()}return q};const x=[0,0,0];function M(q,O){const H=O[0],W=O[1],Q=O[2],fe=O[3];let X=H*H+W*W+Q*Q+fe*fe;return X>0&&(X=1/Math.sqrt(X),q[0]=H*X,q[1]=W*X,q[2]=Q*X,q[3]=fe*X),q}e.fromUnitVec3=function _(q,O,H){let W=v.dot(O,H)+1;return WMath.abs(O[2])?v.set(x,-O[1],O[0],0):v.set(x,0,-O[2],O[1])):v.cross(x,O,H),q[0]=x[0],q[1]=x[1],q[2]=x[2],q[3]=W,M(q,q),q},e.clone=function S(q){const O=t();return O[0]=q[0],O[1]=q[1],O[2]=q[2],O[3]=q[3],O},e.toArray=function A(q,O,H){return O[H+0]=q[0],O[H+1]=q[1],O[H+2]=q[2],O[H+3]=q[3],O},e.fromArray=function E(q,O,H){return q[0]=O[H+0],q[1]=O[H+1],q[2]=O[H+2],q[3]=O[H+3],q},e.copy=function w(q,O){return q[0]=O[0],q[1]=O[1],q[2]=O[2],q[3]=O[3],q},e.set=function D(q,O,H,W,Q){return q[0]=O,q[1]=H,q[2]=W,q[3]=Q,q},e.exactEquals=function I(q,O){return q[0]===O[0]&&q[1]===O[1]&&q[2]===O[2]&&q[3]===O[3]},e.equals=function R(q,O){const H=q[0],W=q[1],Q=q[2],fe=q[3],X=O[0],J=O[1],ce=O[2],be=O[3];return Math.abs(H-X)<=vr*Math.max(1,Math.abs(H),Math.abs(X))&&Math.abs(W-J)<=vr*Math.max(1,Math.abs(W),Math.abs(J))&&Math.abs(Q-ce)<=vr*Math.max(1,Math.abs(Q),Math.abs(ce))&&Math.abs(fe-be)<=vr*Math.max(1,Math.abs(fe),Math.abs(be))},e.add=function T(q,O,H){return q[0]=O[0]+H[0],q[1]=O[1]+H[1],q[2]=O[2]+H[2],q[3]=O[3]+H[3],q},e.normalize=M;const N=[0,0,0],V=[1,0,0],F=[0,1,0];e.rotationTo=function G(q,O,H){const W=v.dot(O,H);return W<-.999999?(v.cross(N,V,O),v.magnitude(N)<1e-6&&v.cross(N,F,O),v.normalize(N,N),s(q,N,Math.PI),q):W>.999999?(q[0]=0,q[1]=0,q[2]=0,q[3]=1,q):(v.cross(N,O,H),q[0]=N[0],q[1]=N[1],q[2]=N[2],q[3]=1+W,M(q,q))};const L=t(),z=t();e.sqlerp=function j(q,O,H,W,Q,fe){return p(L,O,Q,fe),p(z,H,W,fe),p(q,L,z,2*fe*(1-fe)),q};const Z=[0,0,0,0,0,0,0,0,0];e.setAxes=function $(q,O,H,W){return Z[0]=H[0],Z[3]=H[1],Z[6]=H[2],Z[1]=W[0],Z[4]=W[1],Z[7]=W[2],Z[2]=-O[0],Z[5]=-O[1],Z[8]=-O[2],M(q,y(q,Z))},e.toString=function ee(q,O){return`[${q[0].toPrecision(O)} ${q[1].toPrecision(O)} ${q[2].toPrecision(O)} ${q[3].toPrecision(O)}]`},e.Identity=n()}(_r||(_r={})),function(e){function r(S,A,E){const w=function t(S,A,E){const w=[];for(let I=0;Iw[D],set:(w,D,I)=>w[D]=I,add:(w,D,I)=>w[D]+=I,dataOffset:w=>w,getCoords:(w,D)=>(D[0]=w,D)};case 2:if(0===E[0]&&1===E[1]){const w=A[0];return{get:(D,I,R)=>D[R*w+I],set:(D,I,R,T)=>D[R*w+I]=T,add:(D,I,R,T)=>D[R*w+I]+=T,dataOffset:(D,I)=>I*w+D,getCoords:(D,I)=>(I[0]=D%w,I[1]=Math.floor(D/w),I)}}if(1===E[0]&&0===E[1]){const w=A[1];return{get:(D,I,R)=>D[I*w+R],set:(D,I,R,T)=>D[I*w+R]=T,add:(D,I,R,T)=>D[I*w+R]+=T,dataOffset:(D,I)=>D*w+I,getCoords:(D,I)=>(I[0]=Math.floor(D/w),I[1]=D%w,I)}}throw new Error("bad axis order");case 3:if(0===E[0]&&1===E[1]&&2===E[2]){const w=A[0],D=A[1],I=w*D;return{get:(R,T,M,N)=>R[T+M*w+N*I],set:(R,T,M,N,V)=>R[T+M*w+N*I]=V,add:(R,T,M,N,V)=>R[T+M*w+N*I]+=V,dataOffset:(R,T,M)=>R+T*w+M*I,getCoords:(R,T)=>{const M=Math.floor(R/w);return T[0]=R%w,T[1]=M%D,T[2]=Math.floor(M/D),T}}}if(0===E[0]&&2===E[1]&&1===E[2]){const w=A[0],D=A[2],I=w*D;return{get:(R,T,M,N)=>R[T+N*w+M*I],set:(R,T,M,N,V)=>R[T+N*w+M*I]=V,add:(R,T,M,N,V)=>R[T+N*w+M*I]+=V,dataOffset:(R,T,M)=>R+M*w+T*I,getCoords:(R,T)=>{const M=Math.floor(R/w);return T[0]=R%w,T[1]=Math.floor(M/D),T[2]=M%D,T}}}if(1===E[0]&&0===E[1]&&2===E[2]){const w=A[1],D=A[0],I=w*D;return{get:(R,T,M,N)=>R[M+T*w+N*I],set:(R,T,M,N,V)=>R[M+T*w+N*I]=V,add:(R,T,M,N,V)=>R[M+T*w+N*I]+=V,dataOffset:(R,T,M)=>T+R*w+M*I,getCoords:(R,T)=>{const M=Math.floor(R/w);return T[0]=M%D,T[1]=R%w,T[2]=Math.floor(M/D),T}}}if(1===E[0]&&2===E[1]&&0===E[2]){const w=A[1],D=A[2],I=w*D;return{get:(R,T,M,N)=>R[M+N*w+T*I],set:(R,T,M,N,V)=>R[M+N*w+T*I]=V,add:(R,T,M,N,V)=>R[M+N*w+T*I]+=V,dataOffset:(R,T,M)=>T+M*w+R*I,getCoords:(R,T)=>{const M=Math.floor(R/w);return T[0]=Math.floor(M/D),T[1]=R%w,T[2]=M%D,T}}}if(2===E[0]&&0===E[1]&&1===E[2]){const w=A[2],D=A[0],I=w*D;return{get:(R,T,M,N)=>R[N+T*w+M*I],set:(R,T,M,N,V)=>R[N+T*w+M*I]=V,add:(R,T,M,N,V)=>R[N+T*w+M*I]+=V,dataOffset:(R,T,M)=>M+R*w+T*I,getCoords:(R,T)=>{const M=Math.floor(R/w);return T[0]=M%D,T[1]=Math.floor(M/D),T[2]=R%w,T}}}if(2===E[0]&&1===E[1]&&0===E[2]){const w=A[2],D=A[1],I=w*D;return{get:(R,T,M,N)=>R[N+M*w+T*I],set:(R,T,M,N,V)=>R[N+M*w+T*I]=V,add:(R,T,M,N,V)=>R[N+M*w+T*I]+=V,dataOffset:(R,T,M)=>M+T*w+R*I,getCoords:(R,T)=>{const M=Math.floor(R/w);return T[0]=Math.floor(M/D),T[1]=M%D,T[2]=R%w,T}}}throw new Error("bad axis order");default:return{get:(w,...D)=>w[h(S,D)],set:(w,...D)=>w[h(S,D)]=D[D.length-1],add:(w,...D)=>w[h(S,D)]+=D[D.length-1],dataOffset:(...w)=>h(S,w),getCoords:(w,D)=>function g(S,A,E){const{dimensions:w,axisOrderFastToSlow:D}=S,I=w.length;let R=A;for(let T=0;Tnew(w||S.defaultCtor)(E)}function h(S,A){const{accessDimensions:E,axisOrderFastToSlow:w}=S,D=E.length-1;let I=E[D]*A[w[D]];for(let R=D-1;R>=0;R--)I=(I+A[w[R]])*E[R];return I}function b(S,A){const E=[];for(let w=0;wb(E,A)},e.convertToCanonicalAxisIndicesSlowToFast=function _(S){const A=new Int32Array(S.length);for(let E=0;Eb(E,A)}}(wn||(wn={})),function(e){let t;function r(I,R){return kZ(R.T,I,R,1)}function o(I){return BI(I)}!function(I){function N(z,j=I.float){return{"@type":"tensor",T:z.create(),space:z,valueType:"tensor",baseType:j}}I.str={"@type":"str",T:"",valueType:"str"},I.ustr={"@type":"str",T:"",valueType:"str",transform:"uppercase"},I.lstr={"@type":"str",T:"",valueType:"str",transform:"lowercase"},I.int={"@type":"int",T:0,valueType:"int"},I.coord={"@type":"coord",T:0,valueType:"float"},I.float={"@type":"float",T:0,valueType:"float"},I.Str=function R(z){var j;return{"@type":"str",T:null!==(j=z?.defaultValue)&&void 0!==j?j:"",transform:z?.transform,valueType:"str"}},I.Int=function T(z=0){return{"@type":"int",T:z,valueType:"int"}},I.Float=function M(z=0){return{"@type":"float",T:z,valueType:"float"}},I.Tensor=N,I.Vector=function V(z,j=I.float){return N(wn.Vector(z,"int"===j["@type"]?Int32Array:Float64Array),j)},I.Matrix=function F(z,j,Z=I.float){return N(wn.ColumnMajorMatrix(z,j,"int"===Z["@type"]?Int32Array:Float64Array),Z)},I.Aliased=function G(z){return z},I.List=function L(z,j,Z=[]){return{"@type":"list",T:Z,separator:z,itemParse:j,valueType:"list"}}}(t=e.Schema||(e.Schema={})),e.is=function n(I){return!!I&&!!I.schema&&!!I.value},e.ValueKind={Present:0,NotPresent:1,Unknown:2},e.Undefined=r,e.ofConst=function i(I,R,T){return kZ(I,R,T,0)},e.ofLambda=o,e.range=function s(I,R){return o({value:T=>T+I,rowCount:Math.max(R-I+1,0),schema:t.int})},e.ofArray=function a(I){return ip(I)},e.ofIntArray=function c(I){return ip({array:I,schema:t.int})},e.ofFloatArray=function u(I){return ip({array:I,schema:t.float})},e.ofStringArray=function l(I){return ip({array:I,schema:t.str})},e.ofStringAliasArray=function d(I){return ip({array:I,schema:t.Aliased(t.str)})},e.ofStringListArray=function f(I,R=","){return ip({array:I,schema:t.List(R,T=>T)})},e.ofIntTokens=function p(I){const{count:R,data:T,indices:M}=I;return BI({value:N=>jh(T,M[2*N],M[2*N+1])||0,rowCount:R,schema:t.int})},e.ofFloatTokens=function m(I){const{count:R,data:T,indices:M}=I;return BI({value:N=>rp(T,M[2*N],M[2*N+1])||0,rowCount:R,schema:t.float})},e.ofStringTokens=function h(I){const{count:R,data:T,indices:M}=I;return BI({value:N=>{const V=T.substring(M[2*N],M[2*N+1]);return"."===V||"?"===V?"":V},rowCount:R,schema:t.str})},e.window=function g(I,R,T){return function cMe(e,t,n){return e.isDefined?0===t&&n===e.rowCount?e:e.__array&&$F(e.__array)?function uMe(e,t,n){const r=RI(e.__array,{start:t,end:n}),i=e.valueKind;return ip({array:r,schema:e.schema,valueKind:o=>i(t+o)})}(e,t,n):function lMe(e,t,n){const r=e.value,i=e.valueKind,o=e.areValuesEqual,s=0===t?r:c=>r(c+t),a=n-t;return{schema:e.schema,__array:void 0,isDefined:e.isDefined,rowCount:a,value:s,valueKind:0===t?i:c=>i(c+t),toArray:c=>{const{array:u}=qx(a,c);for(let l=0,d=u.length;lo(c+t,u+t)}}(e,t,n):te.Undefined(n-t,e.schema)}(I,R,T)},e.view=function y(I,R,T=!0){return function fMe(e,t,n){return 0===e.rowCount||n&&function dMe(e,t){if(e.length!==t)return!1;for(let n=0,r=e.length;ni(t[o])})}(e,t):function hMe(e,t){const n=e.value,r=e.valueKind,i=e.areValuesEqual,s=t.length;return{schema:e.schema,__array:void 0,isDefined:e.isDefined,rowCount:s,value:a=>n(t[a]),valueKind:a=>r(t[a]),toArray:a=>{const{array:c}=qx(s,a);for(let u=0,l=c.length;ui(t[a],t[c])}}(e,t)}(I,R,T)},e.createFirstIndexMap=function b(I){return function sMe(e){const t=new Map;for(let n=0,r=e.rowCount;nt.has(n)?t.get(n):-1}(I)},e.mapToArray=function _(I,R,T){return function mMe(e,t,n){const r=new n(e.rowCount);for(let i=0,o=e.rowCount;iS[I][D],valueKind:I=>typeof S[I][D]>"u"?1:0});return A},e.ofArrays=function a(_,S){var A;const E=Object.create(null),w=Object.keys(_);E._rowCount=0,E._columns=w,E._schema=_;for(const D of w)typeof S[D]<"u"?(E[D]=te.ofArray({array:S[D],schema:_[D]}),E._rowCount=null===(A=S[D])||void 0===A?void 0:A.length):E[D]=te.Undefined(E._rowCount,_[D]);return E},e.view=c,e.pick=function u(_,S,A){const E=[];for(let w=0,D=_._rowCount;wS(I,R));let E=!0;for(let D=0,I=A.length;D0}has(t){return this._set.has(t)}assets(t,n){const r=this._assets.get(t);if(r)for(const i of r)i.dispose();n?this._assets.set(t,n):this._assets.delete(t)}dispose(){this._assets.forEach(t=>{for(const n of t)n.dispose()})}}const UI=Object.prototype.hasOwnProperty;function IMe(e,t){let n=!1;for(const r of Object.keys(t))if(UI.call(t,r)&&t[r]!==e[r]){n=!0;break}return n?Object.assign({},e,t):e}function eB(e,t){if(!e)return!t;if(!t)return!1;const n=Object.keys(e);if(Object.keys(t).length!==n.length)return!1;for(const r of n)if(!UI.call(e,r)||e[r]!==t[r])return!1;return!0}function Jl(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Array){const t=[];for(let n=0,r=e.length;nt&&(t=e[n]);return t}function VI(e){let t=1/0;for(let n=0,r=e.length;nn&&(n=e[r]);return[t,n]}function OZ(e,t=1,n=0){const r=e.length;let i=0;for(let o=n;o=0||(e.push(t),0))}function Eg(e,t){const n=e.indexOf(t);if(n<0)return!1;for(let r=n,i=e.length-1;rwindow.setImmediate(e,...t),clearImmediate:e=>window.clearImmediate(e)}:{setImmediate,clearImmediate}:function kMe(){const e=function(){const h=typeof window<"u"&&window,g=typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&self;return h||typeof global<"u"&&global||g}(),t={},n=typeof document<"u"?document:void 0;let i,r=1;function s(h){delete t[h]}function c(h){const g=t[h];s(h),function a(h){const g=h.callback,y=h.args;switch(y.length){case 0:g();break;case 1:g(y[0]);break;case 2:g(y[0],y[1]);break;case 3:g(y[0],y[1],y[2]);break;default:g.apply(void 0,y)}}(g)}return typeof process<"u"&&"[object process]"==={}.toString.call(process)?function u(){i=function(h){process.nextTick(function(){c(h)})}}():function l(){if(e&&e.postMessage&&!e.importScripts){let h=!0;const g=e.onmessage;return e.onmessage=function(){h=!1},e.postMessage("","*"),e.onmessage=g,h}}()?function d(){const h="setImmediate$"+Math.random()+"$",g=function(y){y.source===e&&"string"==typeof y.data&&0===y.data.indexOf(h)&&c(+y.data.slice(h.length))};window.addEventListener?window.addEventListener("message",g,!1):window.attachEvent("onmessage",g),i=function(y){window.postMessage(h+y,"*")}}():typeof MessageChannel<"u"?function f(){const h=new MessageChannel;h.port1.onmessage=function(g){c(g.data)},i=function(g){h.port2.postMessage(g)}}():n&&"onreadystatechange"in n.createElement("script")?function p(){const h=n.documentElement;i=function(g){let y=n.createElement("script");y.onreadystatechange=function(){c(g),y.onreadystatechange=null,h.removeChild(y),y=null},h.appendChild(y)}}():function m(){i=function(h){setTimeout(c,0,h)}}(),{setImmediate:function o(h,...g){return"function"!=typeof h&&(h=new Function(""+h)),t[r]={callback:h,args:g},i(r),r++},clearImmediate:s}}();function NMe(e){nB.setImmediate(e)}const Zx={setImmediate:nB.setImmediate,clearImmediate:nB.clearImmediate,immediatePromise:()=>new Promise(NMe),delay:(e,t=void 0)=>new Promise(n=>setTimeout(n,e,t))};let Qx=function(){try{return!0}catch{return!1}}(),un=function(){try{const t=process.env.DEBUG;return"*"===t||"molstar"===t}catch{return!1}}(),lt=!1;const Jx=[],rB=typeof performance<"u"&&!!performance.mark&&performance.measure&<var e2;function LMe(e,t,n=250){const r=zZ(e,t,n);return new qI(r,r.root)}function UZ(e,t){return iB(t,e)}function VZ(e){return{taskId:e.id,taskName:e.name,message:"",startedTime:0,canAbort:!0,isIndeterminate:!0,current:0,max:0}}function zZ(e,t,n){const r={abortRequested:!1,treeAborted:!1,reason:""};return{updateRateMs:n,lastNotified:yi(),observer:t,abortToken:r,taskId:e.id,root:{progress:VZ(e),children:[]},tryAbort:VMe(r)}}function VMe(e){return t=>{e.abortRequested=!0,e.reason=t||e.reason}}function GZ(e){return{progress:{...e.progress},children:e.children.map(GZ)}}function jZ(e){return e.progress.canAbort&&e.children.every(jZ)}function iB(e,t){return oB.apply(this,arguments)}function oB(){return oB=ie(function*(e,t){e2.markStart(e),t.node.progress.startedTime=yi();try{const n=yield e.f(t);return e2.markEnd(e),e2.measure(e),t.info.abortToken.abortRequested&&HZ(t.info),n}catch(n){throw Oe.isAbort(n)&&(t.isAborted=!0,t.node.children.length>0&&(yield new Promise(r=>{t.onChildrenFinished=r})),e.onAbort&&e.onAbort()),n}}),oB.apply(this,arguments)}function HZ(e){throw e.abortToken.treeAborted||(e.abortToken.treeAborted=!0,qZ(e.root),WZ(e,yi())),Oe.Aborted(e.abortToken.reason)}function qZ(e){const t=e.progress;t.isIndeterminate=!0,t.canAbort=!1,t.message="Aborting...";for(const n of e.children)qZ(n)}function WZ(e,t){e.lastNotified=t;const n=function zMe(e){return{root:GZ(e.root),canAbort:jZ(e.root),requestAbort:e.tryAbort}}(e);e.observer(n)}!function(e){function t(s){return`startTask${s.id}`}function n(s){return`endTask${s.id}`}e.markStart=function r(s){rB&&performance.mark(t(s))},e.markEnd=function i(s){rB&&performance.mark(n(s))},e.measure=function o(s){rB&&performance.measure(`\u2733\ufe0f ${s.name}`,t(s),n(s))}}(e2||(e2={}));class qI{checkAborted(){this.info.abortToken.abortRequested&&(this.isAborted=!0,HZ(this.info))}get shouldUpdate(){return this.checkAborted(),yi()-this.lastUpdatedTime>this.info.updateRateMs}updateProgress(t){if(this.checkAborted(),!t)return;const n=this.node.progress;"string"==typeof t?(n.message=t,n.isIndeterminate=!0):(typeof t.canAbort<"u"&&(n.canAbort=t.canAbort),typeof t.message<"u"&&(n.message=t.message),typeof t.current<"u"&&(n.current=t.current),typeof t.max<"u"&&(n.max=t.max),n.isIndeterminate=typeof n.current>"u"||typeof n.max>"u",typeof t.isIndeterminate<"u"&&(n.isIndeterminate=t.isIndeterminate))}update(t,n){if(this.lastUpdatedTime=yi(),this.updateProgress(t),!n)return WZ(this.info,this.lastUpdatedTime),this.checkAborted(),Zx.immediatePromise()}runChild(t,n){var r=this;return ie(function*(){r.updateProgress(n);const i={progress:VZ(t),children:[]},o=r.node.children;o.push(i);const s=new qI(r.info,i);try{return yield iB(t,s)}catch(a){if(Oe.isAbort(a)&&r.isAborted)return;throw a}finally{const a=o.indexOf(i);if(a>=0){for(let c=a,u=o.length-1;c0;){s+=u;const d=yi()-c;l+=d,a+=d,e.shouldUpdate&&(yield i(e,n,s),o=Math.round(l*s/a)+1,c=yi(),l=0)}return e.shouldUpdate&&(yield i(e,n,s)),n}),sB.apply(this,arguments)}function HMe(e,t,n){return e[t].keys[p].key){l=!1;break}if(c&&l){for(let p=0;p"Aborted"+(d?": "+d:"")}},e.create=o,e.constant=function s(d,f){return o(d,function(){var p=ie(function*(m){return f});return function(m){return p.apply(this,arguments)}}())},e.empty=function a(){return o("",function(){var d=ie(function*(f){});return function(f){return d.apply(this,arguments)}}())},e.fail=function c(d,f){return o(d,function(){var p=ie(function*(m){throw new Error(f)});return function(m){return p.apply(this,arguments)}}())},e.resolveInContext=function u(d,f){return n(d)?f?d.runInContext(f):d.run():d};const l=pa(0,1073741823)}(Oe||(Oe={})),function(e){function t(r,i=""){const o=r.progress;if(!r.children.length)return o.isIndeterminate?`${i}${o.taskName}: ${o.message}`:`${i}${o.taskName}: [${o.current}/${o.max}] ${o.message}`;const s=i+" |_ ",a=r.children.map(c=>t(c,s));return o.isIndeterminate?`${i}${o.taskName}: ${o.message}\n${a.join("\n")}`:`${i}${o.taskName}: [${o.current}/${o.max}] ${o.message}\n${a.join("\n")}`}e.format=function n(r){return t(r.root)}}($Z||($Z={})),function(e){function n(f){const p=f.growBy*f.elementSize;f.currentSize=p,f.currentIndex=0,f.currentChunk=new f.ctor(p),f.allocatedSize+=p,f.chunks[f.chunks.length]=f.currentChunk}function l(f,p){const{ctor:m,chunks:h,currentIndex:g}=f;if(!h.length)return new m(0);if(1===h.length&&(p||g===f.allocatedSize))return h[0];let y=0;for(let S=0,A=h.length-1;S=f.currentSize)b.set(_,x);else for(let S=0,A=_.length;S=f.currentSize&&n(f);const y=f.currentChunk,b=f.currentIndex;return y[b]=p,y[b+1]=m,y[b+2]=h,y[b+3]=g,f.currentIndex+=4,f.elementCount++},e.add3=function i(f,p,m,h){f.currentIndex>=f.currentSize&&n(f);const g=f.currentChunk,y=f.currentIndex;return g[y]=p,g[y+1]=m,g[y+2]=h,f.currentIndex+=3,f.elementCount++},e.add2=function o(f,p,m){f.currentIndex>=f.currentSize&&n(f);const h=f.currentChunk,g=f.currentIndex;return h[g]=p,h[g+1]=m,f.currentIndex+=2,f.elementCount++},e.add=function s(f,p){return f.currentIndex>=f.currentSize&&n(f),f.currentChunk[f.currentIndex]=p,f.currentIndex+=1,f.elementCount++},e.addRepeat=function a(f,p,m){for(let h=0;h=f.currentSize&&n(f),f.currentChunk[f.currentIndex++]=m,f.elementCount++;return f.elementCount},e.addMany=function c(f,p){const{elementSize:m}=f;for(let h=0,g=p.length;h=f.currentSize&&n(f);const{currentChunk:y}=f;for(let b=0;b"u")return g;if("number"==typeof h)return g.currentChunk=new f(h*p),g.allocatedSize=h*p,g.currentSize=g.currentChunk.length,g.chunks[0]=g.currentChunk,g;const y=h;if(y.length%p!=0)throw new Error("initialChunk length must be a multiple of the element size.");return g.currentChunk=y,g.allocatedSize=y.length,g.currentSize=y.length,g.chunks[0]=y,g}}(ze||(ze={}));class WMe{createGroup(t,n){const r=this.id++,i=[t];return this.groups[r]=i,{id:r,keys:i,value:n}}add(t,n){const r=this.getHash(n);if(this.byHash.has(r)){const i=this.byHash.get(r);for(let s=0,a=i.length;s>4;return t=(3735928559^t)+(t<<5),t^=t>>11,t}function Pg(e,t){let n=23;return n=31*n+e|0,n=31*n+t|0,n^=n>>4,n=(3735928559^n)+(n<<5),n^=n>>11,n}function cB(e){let t=0;for(let n=0,r=e.length;n>>0}function uB(e,t){for(let n=0,r=e.length;n=n&&t0&&r>0&&YI(e)>=$I(t)&&$I(e)<=YI(t)}function cRe(e,t){return Mg(e)?!Mg(t)||sp(e)<=sp(t)&&Hh(e)>=Hh(t):0===Mg(t)}function pB(e,t){const n=sp(e);if(t<=n)return 0;const r=Hh(e);return t>=r?r-n:t-n}function uRe(e,t,n){const r=sp(n),i=sp(e);if(t<=r+i)return r;const o=Hh(n);return t>=o+i?o:t-i}function JZ(e,t,n){return fB(pB(e,t),pB(e,n+1))}function lRe(e,t){return QZ(e,t)?fB(Math.max(sp(e),sp(t)),Math.min(Hh(e),Hh(t))):KZ}function dRe(e,t){return Mg(JZ(e,$I(t),YI(t)))}var Ce;!function(e){e.Empty=KZ,e.ofSingleton=t=>ZZ(t,t),e.ofRange=ZZ,e.ofBounds=fB,e.ofLength=eRe,e.is=tRe,e.has=iRe,e.indexOf=oRe,e.getAt=sRe,e.start=sp,e.end=Hh,e.min=$I,e.max=YI,e.size=Mg,e.hashCode=nRe,e.toString=rRe,e.areEqual=aRe,e.areIntersecting=QZ,e.isSubInterval=cRe,e.findPredecessorIndex=pB,e.findPredecessorIndexInInterval=uRe,e.findRange=JZ,e.intersectionSize=dRe,e.intersect=lRe}(Ce||(Ce={}));const n2=[];function fRe(e){return[e]}function pRe(e){return e}function hRe(e){return Ou(e),e}function eQ(e,t){if(t2?function XMe(e,t,n,r){let i=23;return i=31*i+e|0,i=31*i+t|0,i=31*i+n|0,i=31*i+r|0,i^=i>>4,i=(3735928559^i)+(i<<5),i^=i>>11,i}(t,e[0],e[t-1],e[t>>1]):function YMe(e,t,n){let r=23;return r=31*r+e|0,r=31*r+t|0,r=31*r+n|0,r^=r>>4,r=(3735928559^r)+(r<<5),r^=r>>11,r}(t,e[0],e[t-1]):0}function vRe(e){const t=e.length;return t>5?`[${e[0]}, ${e[1]}, ..., ${e[t-1]}], length ${t}`:`[${e.join(", ")}]`}function rQ(e,t){const n=e.length;return 0===n?-1:e[0]<=t&&t<=e[n-1]?sQ(e,t,0,n):-1}function _Re(e,t,n){return iQ(e,t,Ce.start(n),Ce.end(n))}function iQ(e,t,n,r){return 0===e.length||r<=n?-1:e[n]<=t&&t<=e[r-1]?sQ(e,t,n,r):-1}function xRe(e,t){return rQ(e,t)>=0}function oQ(e,t){if(e===t)return!0;let n=e.length;if(n!==t.length||e[0]!==t[0]||e[n-1]!==t[n-1])return!1;if(tQ(e))return!0;n--;for(let r=1;re[n-1]?n:aQ(e,t,0,n)}function SRe(e,t,n){const r=Ce.start(n),i=Ce.end(n),o=e[r];return t<=o?r:i>r&&t>e[i-1]?i:t-o<=11?function wRe(e,t,n,r){for(let i=n;io){for(let c=i;c<=o;c++)if(t===e[c])return c;return-1}const s=i+o>>1,a=e[s];if(ta))return s;i=s+1}}return-1}function aQ(e,t,n,r){let i=n,o=r-1;for(;io){for(let c=i;c<=o;c++)if(t<=e[c])return c;return o+1}const s=i+o>>1,a=e[s];if(ta))return s;i=s+1}}return i>o?o+1:e[i]>=t?i:i+1}function ARe(e,t){if(e===t)return!0;let{startI:n,startJ:r,endI:i,endJ:o}=kg(e,t);for(;na))return!0;r++}}return!1}function IRe(e,t){if(e===t)return!0;const n=t.length;let{startI:r,startJ:i,endI:o,endJ:s}=kg(e,t);if(s-iu?i++:(r++,i++,a++)}return a===n}function cQ(e,t){if(e===t)return e;const n=e.length,r=t.length;if(0===n)return t;if(0===r)return e;if(e[0]>t[0])return cQ(t,e);const{startI:i,startJ:o,endI:s,endJ:a}=kg(e,t),c=gB(e,t,i,o,s,a);if(c===n&&c===r||c===r)return e;if(c===n)return t;const u=new Int32Array(n+r-c);let l=0,d=0,f=0;for(l=0;lt[d];)u[f++]=t[d++];for(;lm?(u[f++]=m,d++):(u[f++]=p,l++,d++)}for(;ll?a++:(s++,a++,c++)}return c}function DRe(e,t){if(e===t)return e;const{startI:n,startJ:r,endI:i,endJ:o}=kg(e,t),s=gB(e,t,n,r,i,o),a=e.length,c=t.length;if(!s)return n2;if(s===a&&s===c||s===c)return t;if(s===a)return e;const u=new Int32Array(s);let l=0,d=n,f=r;for(;dm||(u[l++]=p,d++),f++)}return u}function ERe(e,t){if(e===t)return n2;const n=e.length,{startI:r,startJ:i,endI:o,endJ:s}=kg(e,t);let a=r,c=i,u=0;for(;ap?c++:(a++,c++,u++)}if(!u)return e;if(u>=n)return n2;const l=new Int32Array(n-u);let d=0;for(let f=0;fp||a++,c++)}for(;ap?a++:(s++,a++,c++)}if(!c)return n2;if(c===e.length)return dB(0,e.length-1);const l=new Int32Array(c);let d=0;for(s=n,a=r;sp||(l[d++]=s,s++),a++)}return l}const ap={startI:0,startJ:0,endI:0,endJ:0};function kg(e,t){const n=e.length,r=t.length,i=n/r;return n>=128||r>=128||i<=.34||i>=2.99?(ap.startI=Rg(e,hB(t)),ap.startJ=Rg(t,hB(e)),ap.endI=Rg(e,mB(t)),ap.endJ=Rg(t,mB(e))):(ap.startI=0,ap.startJ=0,ap.endI=n,ap.endJ=r),ap}var je;!function(e){e.Empty=n2,e.ofUnsortedArray=hRe,e.ofSingleton=fRe,e.ofSortedArray=pRe,e.ofRange=eQ,e.ofBounds=(t,n)=>eQ(t,n-1),e.is=mRe,e.isRange=tQ,e.has=xRe,e.indexOf=rQ,e.indexOfInInterval=_Re,e.indexOfInRange=iQ,e.start=hB,e.end=mB,e.min=gRe,e.max=yRe,e.size=nQ,e.hashCode=bRe,e.toString=vRe,e.areEqual=oQ,e.areIntersecting=ARe,e.isSubset=IRe,e.union=cQ,e.intersect=DRe,e.subtract=ERe,e.findPredecessorIndex=Rg,e.findPredecessorIndexInInterval=SRe,e.findRange=CRe,e.intersectionSize=TRe,e.deduplicate=PRe,e.indicesOf=MRe}(je||(je={}));const Kd=Ce.Empty,RRe=Ce.ofSingleton,kRe=Ce.ofRange,NRe=Ce.ofBounds;function ed(e){return e.length?je.isRange(e)?Ce.ofRange(e[0],e[e.length-1]):e:Kd}function Ng(e){return Ce.is(e)?Ce.size(e):je.size(e)}function FRe(e,t){return Ce.is(e)?Ce.has(e,t):je.has(e,t)}function BRe(e,t){return Ce.is(e)?Ce.indexOf(e,t):je.indexOf(e,t)}function yB(e,t){return Ce.is(e)?Ce.getAt(e,t):e[t]}function Ub(e){return Ce.is(e)?Ce.min(e):je.min(e)}function Vb(e){return Ce.is(e)?Ce.max(e):je.max(e)}function ORe(e){return Ce.is(e)?Ce.start(e):je.start(e)}function LRe(e){return Ce.is(e)?Ce.end(e):je.end(e)}function URe(e){return Ce.is(e)?Ce.hashCode(e):je.hashCode(e)}function zRe(e,t){return Ce.is(e)?Ce.is(t)?Ce.areEqual(e,t):uQ(e,t):Ce.is(t)?uQ(t,e):je.areEqual(e,t)}function GRe(e,t){return Ce.is(e)?Ce.is(t)?Ce.areIntersecting(e,t):lQ(t,e):Ce.is(t)?lQ(e,t):je.areIntersecting(e,t)}function jRe(e,t){return Ce.is(e)?Ce.is(t)?Ce.isSubInterval(e,t):function QRe(e,t){const n=Ce.min(e),r=Ce.max(e);if(r-n+1==0)return!1;const i=je.min(t),o=je.max(t);return i>=n&&o<=r}(e,t):Ce.is(t)?function ZRe(e,t){const n=Ce.min(t),r=Ce.max(t);if(r-n+1==0)return!0;const i=je.min(e),o=je.max(e);if(no)return!1;const s=je.findRange(e,n,r);return Ce.size(s)===Ce.size(t)}(e,t):je.isSubset(e,t)}function HRe(e,t){return Ce.is(e)?Ce.findPredecessorIndex(e,t):je.findPredecessorIndex(e,t)}function qRe(e,t,n){return Ce.is(e)?Ce.findPredecessorIndexInInterval(e,t,n):je.findPredecessorIndexInInterval(e,t,n)}function WRe(e,t,n){return Ce.is(e)?Ce.findRange(e,t,n):je.findRange(e,t,n)}function $Re(e,t){return Ce.is(e)?Ce.is(t)?Ce.intersectionSize(e,t):fQ(t,e):Ce.is(t)?fQ(e,t):je.intersectionSize(e,t)}function YRe(e,t){return Ce.is(e)?Ce.is(t)?function tke(e,t){if(Ce.areEqual(e,t))return e;const n=Ce.size(e),r=Ce.size(t);if(!r)return e;if(!n)return t;const i=Ce.min(e),o=Ce.min(t);if(function JRe(e,t){const n=Ng(e),r=Ng(t);return 0===n&&0===r||n>0&&r>0&&Vb(e)>=Ub(t)&&Ub(e)<=Vb(t)}(e,t))return Ce.ofRange(Math.min(i,o),Math.max(Ce.max(e),Ce.max(t)));let s,a,c,u;i=Vb(t):0===Ng(t)}(t,e))return t;const r=Ce.min(t),i=Ce.max(t),o=je.findRange(e,r,i),s=Ce.start(o),a=Ce.end(o),c=new Int32Array(s+(e.length-a)+n);let u=0;for(let l=0;lm||(c++,l++),d++)}if(0===c)return Kd;if(c===i&&c===o)return e;const f=new Int32Array(c);for(u=0,l=0,d=s;lm||(f[u++]=d,l++),d++)}return ed(f)}var Fe,en,Lu,XI,Dc,td,Ms,ft,zb,ui;function hQ(e){const t=je.ofSortedArray(e),n=je.max(t),r=new Int32Array(n);for(let i=0,o=e.length-1;i=Fe.max(e)?-1:Fe.findPredecessorIndex(e,n-1);return Fe.findRange(t,Fe.getAt(e,i),Fe.getAt(e,i+1)-1)}!function(e){e.Empty=Kd,e.ofSingleton=RRe,e.ofRange=kRe,e.ofBounds=NRe,e.ofSortedArray=ed,e.has=FRe,e.indexOf=BRe,e.getAt=yB,e.min=Ub,e.max=Vb,e.start=ORe,e.end=LRe,e.size=Ng,e.hashCode=URe,e.areEqual=zRe,e.areIntersecting=GRe,e.isSubset=jRe,e.union=YRe,e.intersect=XRe,e.indexedIntersect=ake,e.subtract=KRe,e.findPredecessorIndex=HRe,e.findPredecessorIndexInInterval=qRe,e.findRange=WRe,e.intersectionSize=$Re,e.forEach=function t(a,c,u){return function oke(e,t,n){if(Ce.is(e)){const r=Ce.min(e);for(let i=r,o=Ce.max(e);i<=o;i++)t(i,i-r,n)}else for(let r=0,i=e.length;rc.push(u)),c},e.toString=function s(a){return function VRe(e){return Ce.is(e)?Ce.toString(e):je.toString(e)}(a)}}(Fe||(Fe={}));class fke{move(){for(;this.hasNext;){if(this.updateValue()){this.value.index=this.segmentMin++,this.hasNext=this.segmentMax>=this.segmentMin&&Ce.size(this.setRange)>0;break}this.updateSegmentRange()}return this.value}updateValue(){const n=Fe.findPredecessorIndexInInterval(this.set,this.segments[this.segmentMin+1],this.setRange);return this.value.start=Ce.start(this.setRange),this.value.end=n,this.setRange=Ce.ofBounds(n,Ce.end(this.setRange)),n>this.value.start}updateSegmentRange(){const t=Ce.min(this.setRange),n=Ce.max(this.setRange);n=this.segmentMin)}setSegment(t){this.setRange=Ce.ofBounds(t.start,t.end),this.updateSegmentRange()}constructor(t,n,r,i){this.segments=t,this.segmentMap=n,this.set=r,this.segmentMin=0,this.segmentMax=0,this.setRange=Ce.Empty,this.value={index:0,start:0,end:0},this.hasNext=!1,this.setRange=i,this.updateSegmentRange()}}function pke(e,t,n){const r=typeof n<"u"?Ce.ofBounds(n.start,n.end):Ce.ofBounds(0,Fe.size(t));return new fke(e.offsets,e.index,t,r)}!function(e){e.create=hQ,e.ofOffsets=cke,e.count=uke,e.getSegment=lke,e.projectValue=dke,e.transientSegments=pke}(en||(en={}));class mke{remove(t){const{prev:n,next:r}=this,i=n[t],o=r[t];i>=0&&(r[i]=o,n[t]=-1),o>=0&&(n[o]=i,r[t]=-1),t===this.head&&(this.head=i<0?o:i)}has(t){return this.prev[t]>=0||this.next[t]>=0||this.head===t}constructor(t){this.head=t>0?0:-1,this.prev=new Int32Array(t),this.next=new Int32Array(t);for(let n=0;n0,this.xs=t,this.index=-1,this.lastValue=t.length>0?t[0]:void 0}}class mQ{move(){return++this.value,this.hasNext=this.value=t}}class yke{move(){return this.hasNext=!1,this.value}constructor(t){this.value=t,this.hasNext=!0}}class bke{move(){const t=this.f(this.base.move());return this.hasNext=this.base.hasNext,t}constructor(t,n){this.base=t,this.f=n,this.hasNext=!1,this.hasNext=t.hasNext}}class vke{move(){const t=this.next;return this.hasNext=this.findNext(),t}findNext(){for(;this.base.hasNext;)if(this.next=this.base.move(),this.p(this.next))return!0;return!1}constructor(t,n){this.base=t,this.p=n,this.hasNext=this.findNext()}}function gQ(e,t,n,r,i){const{b:o,offset:s}=e,a=[];for(let c=0,u=t.length;c1&&gQ(e,a,n,r-1,i)}!function(e){e.Empty=new mQ(0,-1),e.Array=function t(a){return new gke(a)},e.Value=function n(a){return new yke(a)},e.Range=function r(a,c){return new mQ(a,c)},e.map=function i(a,c){return new bke(a,c)},e.filter=function o(a,c){return new vke(a,c)},e.forEach=function s(a,c,u){for(;a.hasNext;)if(c(a.move(),u))return u;return u}}(XI||(XI={})),function(e){e.areEqual=function t(d,f){if(d===f)return!0;if(d.vertexCount!==f.vertexCount||d.edgeCount!==f.edgeCount)return!1;const{a:p,b:m,offset:h}=d,{a:g,b:y,offset:b}=f;for(let x=0,_=d.a.length;x<_;x++)if(p[x]!==g[x])return!1;for(let x=0,_=d.b.length;x<_;x++)if(m[x]!==y[x])return!1;for(let x=0,_=d.offset.length;x<_;x++)if(h[x]!==b[x])return!1;for(const x of Object.keys(d.edgeProps)){const _=d.edgeProps[x],S=f.edgeProps[x];if(!S)return!1;for(let A=0,E=_.length;Ap&&(m=p,h=f);const g=uu(m,h);return!this.included.has(g)&&(this.included.add(g),this.xs[this.xs.length]=m,this.ys[this.ys.length]=h,!0)}getGraph(){return a(this.vertexCount,this.xs,this.ys)}getEdgeBuiler(){return new i(this.vertexCount,this.xs,this.ys)}constructor(f){this.vertexCount=f,this.xs=[],this.ys=[],this.included=new Set}},e.fromVertexPairs=a,e.induceByVertices=function c(d,f,p){const{b:m,offset:h,vertexCount:g,edgeProps:y}=d,b=new Int32Array(g);for(let R=0,T=f.length;RR&&0!==b[m[T]]&&x++;const _=new Int32Array(f.length+1),S=new Int32Array(2*x),A=new Int32Array(2*x),E=new Int32Array(2*x);let w=0,D=0;for(let R=0;R0;){const x=y.pop(),_=p[x];for(let S=h[x],A=h[x+1];S=0&&(y.push(b.head),p[b.head]=++m,b.remove(b.head))}return{componentCount:f,componentIndex:p}},e.areVertexSetsConnected=function l(d,f,p,m){if(je.areIntersecting(f,p))return!0;if(m<1)return!1;const h=new Set;for(let g=0,y=f.length;gn.substring(r[2*a],r[2*a+1]):"int"===o?a=>jh(n,r[2*a],r[2*a+1])||0:a=>rp(n,r[2*a],r[2*a+1])||0;return{schema:t,__array:void 0,isDefined:!0,rowCount:i,value:s,valueKind:a=>0,toArray:a=>Ps(i,s,a),areValuesEqual:yQ(e)}}function yQ(e){const{data:t,indices:n}=e;return function(r,i){const o=n[2*r],s=n[2*i],a=n[2*r+1]-o;if(a!==n[2*i+1]-s)return!1;for(let c=0;cr[i]}}function Zd(e,t,n){return function Rke(e,t,n){const r=Object.create(null);for(const i of Object.keys(e))r[i]=Fke(i,e[i],t,n);return JF.ofTables(t.header,e,r)}(e,t,n)}function Dke(e){switch(e.valueType){case"str":return(t,n,r)=>function Eke(e,t,n,r){return{schema:e,__array:t.__array,isDefined:t.isDefined,rowCount:t.rowCount,value:"lowercase"===e.transform?i=>n(i).toLowerCase():"uppercase"===e.transform?i=>n(i).toUpperCase():n,valueKind:t.valueKind,areValuesEqual:t.areValuesEqual,toArray:"lowercase"===e.transform?i=>Array.from(r(i)).map(o=>o.toLowerCase()):"uppercase"===e.transform?i=>Array.from(r(i)).map(o=>o.toUpperCase()):r}}(e,t,t.str,t.toStringArray);case"int":return(t,n,r)=>vQ(e,t,t.int,t.toIntArray);case"float":return(t,n,r)=>vQ(e,t,t.float,t.toFloatArray);case"list":throw new Error("Use createListColumn instead.");case"tensor":throw new Error("Use createTensorColumn instead.")}}function vQ(e,t,n,r){return{schema:e,__array:t.__array,isDefined:t.isDefined,rowCount:t.rowCount,value:n,valueKind:t.valueKind,areValuesEqual:t.areValuesEqual,toArray:r}}function Pke(e,t,n){const r=e.separator,i=e.itemParse,o=t.getField(n),s=o?c=>o.str(c).split(r).map(u=>i(u.trim())).filter(u=>!!u):c=>[];return{schema:e,__array:void 0,isDefined:!!o,rowCount:t.rowCount,value:s,valueKind:o?o.valueKind:()=>1,areValuesEqual:(c,u)=>Wa(s(c),s(u)),toArray:c=>Ps(t.rowCount,s,c)}}function Mke(e,t,n){const r=e.space,i=t.fieldNames.includes(`${n}[0]`)||t.fieldNames.includes(`${n}[0][0]`)||t.fieldNames.includes(`${n}[0][0][0]`),o=i?0:1,s=t.fieldNames.includes(`${n}_1`)||t.fieldNames.includes(`${n}_11`)||t.fieldNames.includes(`${n}_111`)?"underscore":"brackets",a=function wke(e,t,n,r){const i=n?0:1;switch(t){case 1:return"brackets"===r?o=>`${e}[${o+i}]`:o=>`${e}_${o+i}`;case 2:return"brackets"===r?(o,s)=>`${e}[${o+i}][${s+i}]`:(o,s)=>`${e}_${o+i}${s+i}`;case 3:return"brackets"===r?(o,s,a)=>`${e}[${o+i}][${s+i}][${a+i}]`:(o,s,a)=>`${e}_${o+i}${s+i}${a+i}`;default:throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.")}}(n,r.rank,i,s),c=t.getField(a(o,o,o))||te.Undefined(t.rowCount,e),u=d=>function Ake(e,t,n,r){const i=t.create();if(1===t.rank){const o=t.dimensions[0];for(let s=0;s 3 or rank 0 are currently not supported.");{const o=t.dimensions[0],s=t.dimensions[1],a=t.dimensions[2];for(let c=0;cwn.areEqualExact(u(d),u(f)),toArray:d=>Ps(t.rowCount,u,d)}}!function(e){e.create=function t(n,r){const{name:i}=n,o=new _ke;return{descriptor:n,formatRegistry:o,isApplicable:s=>o.isApplicable(s),get(s){const a=r?.asDynamic?s._dynamicPropertyData:s._staticPropertyData;if(a[i])return a[i];if(s.customProperties.has(n))return;const c=o.get(s.sourceData.kind);return c?(a[i]=c(s),s.customProperties.add(n),a[i]):void 0},set(s,a){r?.asDynamic?s._dynamicPropertyData[i]=a:s._staticPropertyData[i]=a},delete(s){r?.asDynamic?delete s._dynamicPropertyData[i]:delete s._staticPropertyData[i]}}}}(td||(td={})),function(e){e.Descriptor={name:"index_pair_bonds"},e.Provider=td.create(e.Descriptor,{asDynamic:!0}),e.DefaultProps={maxDistance:-1},e.fromData=function t(r,i={}){const o={...e.DefaultProps,...i},{pairs:s,count:a}=r;return{bonds:xke(s.indexA.toArray(),s.indexB.toArray(),{key:s.key&&s.key.toArray(),operatorA:s.operatorA&&s.operatorA.toArray(),operatorB:s.operatorB&&s.operatorB.toArray(),order:s.order&&s.order.toArray(),distance:s.distance&&s.distance.toArray(),flag:s.flag&&s.flag.toArray()},a),maxDistance:o.maxDistance}},e.getEdgeIndexForOperators=function n(r,i,o,s,a){let c,u,l,d;i0?o[s[0]].rowCount:0,name:i,fieldNames:s,getField:a=>o[a]}}e.empty=function t(i){return{rowCount:0,name:i,fieldNames:[],getField(o){}}},e.ofFields=n,e.ofTable=function r(i,o){const s={};for(const a of o._columns)s[a]=ft.ofColumn(o[a]);return n(i,s)}}(ss||(ss={})),function(e){function n(a){const c=a.length,u=p=>{const m=a[p];return m&&"."!==m&&"?"!==m?m:""},l=p=>{const m=a[p];return jh(m,0,m.length)||0},d=p=>{const m=a[p];return rp(m,0,m.length)||0};return{__array:void 0,binaryEncoding:void 0,isDefined:!0,rowCount:c,str:u,int:l,float:d,valueKind:p=>{const m=a[p],h=m.length;if(h>1)return 0;if(0===h)return 1;const g=m.charCodeAt(0);return 46===g?1:63===g?2:0},areValuesEqual:(p,m)=>a[p]===a[m],toStringArray:p=>p?Ps(c,u,p):a,toIntArray:p=>Ps(c,l,p),toFloatArray:p=>Ps(c,d,p)}}function o(a){const{rowCount:c,valueKind:u,areValuesEqual:l,isDefined:d}=a;let f,p,m;switch(a.schema.valueType){case"float":case"int":f=g=>""+a.value(g),p=a.value,m=a.value;break;case"str":f=a.value,p=g=>{const y=a.value(g);return jh(y,0,y.length)||0},m=g=>{const y=a.value(g);return rp(y,0,y.length)||0};break;case"list":const{separator:h}=a.schema;f=g=>a.value(g).join(h),p=g=>NaN,m=g=>NaN;break;default:throw new Error(`unsupported valueType '${a.schema.valueType}'`)}return{__array:void 0,binaryEncoding:void 0,isDefined:d,rowCount:c,str:f,int:p,float:m,valueKind:u,areValuesEqual:l,toStringArray:h=>Ps(c,f,h),toIntArray:h=>Ps(c,p,h),toFloatArray:h=>Ps(c,m,h)}}e.ofString=function t(a){return n([a])},e.ofStrings=n,e.ofNumbers=function r(a){const c=a.length,u=p=>""+a[p],l=p=>a[p],f=p=>!p||p.array&&a instanceof p.array?a:Ps(c,l,p);return{__array:void 0,binaryEncoding:void 0,isDefined:!0,rowCount:c,str:u,int:l,float:l,valueKind:p=>0,areValuesEqual:(p,m)=>a[p]===a[m],toStringArray:p=>Ps(c,u,p),toIntArray:f,toFloatArray:f}},e.ofTokens=function i(a){const{data:c,indices:u,count:l}=a,d=h=>{const g=c.substring(u[2*h],u[2*h+1]);return"."===g||"?"===g?"":g},f=h=>jh(c,u[2*h],u[2*h+1])||0,p=h=>rp(c,u[2*h],u[2*h+1])||0;return{__array:void 0,binaryEncoding:void 0,isDefined:!0,rowCount:l,str:d,int:f,float:p,valueKind:h=>{const g=u[2*h],y=u[2*h+1]-g;if(y>1)return 0;if(0===y)return 1;const b=c.charCodeAt(g);return 46===b?1:63===b?2:0},areValuesEqual:yQ(a),toStringArray:h=>Ps(l,d,h),toIntArray:h=>Ps(l,f,h),toFloatArray:h=>Ps(l,p,h)}},e.ofColumn=o,e.ofUndefined=function s(a,c){return o(te.Undefined(a,c))}}(ft||(ft={})),function(e){function t(i){return i.replace(".","_").replace(/\[/,"_").replace(/(\[|\])/g,"")}e.canonical=t,e.equal=function n(i,o){return t(i)===t(o)},e.create=function r(i,o,s=!1){const a=`${i}${o?`.${o}`:""}`;return s?t(a):a}}(zb||(zb={}));class _Q{constructor(t,n,r){this._isDefined=r;const i=Object.keys(n);this._rowCount=t.rowCount,this._columns=i,this._schema=n;const o=Object.create(null);for(const s of i)Object.defineProperty(this,s,{get:function(){if(o[s])return o[s];const a=n[s];if("list"===a.valueType)o[s]=Pke(a,t,s);else if("tensor"===a.valueType)o[s]=Mke(a,t,s);else{const c=Dke(a),u=t.getField(s);o[s]=u?c(u,t,s):te.Undefined(t.rowCount,a)}return o[s]},enumerable:!0,configurable:!1})}}function Nke(e,t,n,r){const i=zb.create(t,e),o=zb.canonical(i);if(o in n)return n[o];if(r&&i in r)for(const s of r[i]){const a=zb.canonical(s);if(a in n)return n[a]}}function Fke(e,t,n,r){let i=n.categories[e];if(r){const o=function kke(e){const t=Object.create(null);for(const n of Object.keys(e.categories))for(const r of e.categories[n].fieldNames)t[zb.create(n,r,!0)]=e.categories[n].getField(r);return t}(n),s=Object.create(null),a=[];let c=0;for(const u of Object.keys(t)){const l=Nke(u,e,o,r);l&&(s[u]=l,a.push(u),c=l.rowCount)}i={rowCount:c,name:e,fieldNames:[...a],getField:u=>s[u]}}return new _Q(i||ss.empty(e),t,!!i)}function Gb(e,t,n){const r=new Float32Array(e);for(let i=0;i(t=Math.abs(t))?(t/=e,e*Math.sqrt(1+t*t)):t>0?(e/=t,t*Math.sqrt(1+e*e)):0}!function(e){function n(r,i,o){const s=function Gke(e){const t="number"==typeof e?function Uke(e){switch(e){case 1146:return 146;case 1148:return 149;case 1155:return 157;case 1160:return 163;case 1161:return 165;case 1166:return 171;case 1167:return 173;case 1003:return 237;case 1004:return 238;case 1005:return 239;case 2005:return 240;case 3005:return 241;case 4005:return 242;case 5005:return 243;case 1006:return 244;case 1007:return 245;case 1008:return 246;case 1009:return 247;case 1010:return 248;case 1011:return 249;case 1012:return 250;case 1013:return 251;case 1014:return 252;case 2014:return 253;case 3014:return 254;case 1015:return 255;case 1017:return 256;case 2017:return 257;case 1018:return 258;case 2018:return 259;case 3018:return 260;case 1020:return 261;case 1021:return 262;case 1022:return 263;case 1023:return 264;case 1059:return 265;case 1094:return 266;case 1197:return 267}let t=0;return e>146&&++t,e>148&&++t,e>155&&++t,e>160&&++t,e>161&&++t,e>166&&++t,e>167&&++t,e-1+t}(e):r2[e];return typeof t>"u"||typeof xQ[t]>"u"?-1:t}(r);if(s<0)return console.warn(`Unknown spacegroup '${r}', returning a 'P 1' with cellsize [1, 1, 1]`),e.Zero;const a=i[0]*i[1]*i[2],c=o[0],u=o[1],l=o[2],d=i[0],f=i[1],p=i[2],m=Math.cos(u),h=(Math.cos(c)-Math.cos(u)*Math.cos(l))/Math.sin(l),g=Math.sqrt(1-m*m-h*h),y=[d,0,0],b=[Math.cos(l)*f,Math.sin(l)*f,0],x=[m*p,h*p,g*p],_=le.ofRows([[y[0],b[0],x[0],0],[0,b[1],x[1],0],[0,0,x[2],0],[0,0,0,1]]);return{index:s,size:i,volume:a,anglesInRadians:o,toFractional:le.invert(le.zero(),_),fromFractional:_}}e.Zero=n("P 1",v.create(1,1,1),v.create(Math.PI/2,Math.PI/2,Math.PI/2)),e.isZero=function t(r){return!r||0===r.index&&1===r.size[0]&&1===r.size[1]&&1===r.size[1]},e.create=n}(ma||(ma={})),function(e){function t(g){const y=Lke[g.index].map(_=>function d(g){return le.ofRows([_B[g[0]],_B[g[1]],_B[g[2]],[0,0,0,1]])}(Oke[_]));return{name:xQ[g.index],num:zke[g.index],cell:g,operators:y}}e.ZeroP1=t(ma.Zero),e.create=t;const n=v(),r=le();function i(g,y,b,x,_,S){return v.set(n,b,x,_),le.fromTranslation(r,n),le.mul(S,le.mul(S,le.mul(S,g.cell.fromFractional,r),g.operators[y]),g.cell.toFractional)}e.setOperatorMatrix=i,e.getSymmetryOperator=function o(g,y,b,x,_){const S=i(g,y,b,x,_,le.zero());return ui.create(`${y+1}_${5+b}${5+x}${5+_}`,S,{hkl:v.create(b,x,_),spgrOp:y})};const s=v(),a=v(),c=v(),u=v();function p(g,y,b){const x=[];if(g>0?x.push("+X"):g<0&&x.push("-X"),y>0?x.push("+Y"):y<0&&x.push("-Y"),b>0?x.push("+Z"):b<0&&x.push("-Z"),1===x.length)return"+"===x[0].charAt(0)?x[0].substr(1):x[0];if(2===x.length){const _=x[0].charAt(0),S=x[1].charAt(0);if("+"===_)return`${x[0].substr(1)}${x[1]}`;if("+"===S)return`${x[1].substr(1)}${x[0]}`}throw new Error(`unknown rotation '${x}', ${g} ${y} ${b}`)}function m(g){switch(g){case.5: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 h(g,y){return""===y?g:g.length>2?`${g}+${y}`:"-"===g.charAt(0)?`${y}${g}`:`${y}+${g}`}e.getSymmetryOperatorRef=function l(g,y,b,x,_,S){const A=le.zero();v.set(n,b,x,_),v.floor(s,S),le.copy(A,g.operators[y]),v.floor(a,v.transformMat4(a,S,A)),le.getTranslation(u,A),v.sub(u,u,a),v.add(u,u,s),v.add(u,u,n),le.setTranslation(A,u),le.mul(A,g.cell.fromFractional,A),le.mul(A,A,g.cell.toFractional),v.sub(c,a,s);const E=b-c[0],w=x-c[1],D=_-c[2];return ui.create(`${y+1}_${5+E}${5+w}${5+D}`,A,{hkl:v.create(E,w,D),spgrOp:y})},e.getOperatorXyz=function f(g){return[h(p(g[0],g[4],g[8]),m(g[12])),h(p(g[1],g[5],g[9]),m(g[13])),h(p(g[2],g[6],g[10]),m(g[14]))].join(",")}}(Ec||(Ec={})),function(e){e.add=function t(o,s,a){o.squaredDistances[o.count]=a,o.indices[o.count++]=s},e.reset=function n(o){o.count=0},e.create=function r(){return{count:0,indices:[],squaredDistances:[]}},e.copy=function i(o,s){for(let a=0;a>16?L:-L,e[l*t+f]=G;for(p=0;p<2;p++)for(d=0;d0?M>c&&(c=M):M>u&&(u=M),v.projectPointOnVector(m,v.fromArray(m,s,I),y.dirB,g);const N=v.dot(y.dirB,v.normalize(h,v.sub(h,m,g))),V=v.distance(m,g);N>0?V>l&&(l=V):V>d&&(d=V),v.projectPointOnVector(m,v.fromArray(m,s,I),y.dirC,g);const F=v.dot(y.dirC,v.normalize(h,v.sub(h,m,g))),G=v.distance(m,g);F>0?G>f&&(f=G):G>p&&(p=G)}const b=v.setMagnitude(v(),y.dirA,(c+u)/2),x=v.setMagnitude(v(),y.dirB,(l+d)/2),_=v.setMagnitude(v(),y.dirC,(f+p)/2),S=v.isFinite(b),A=v.isFinite(x),E=v.isFinite(_),w=v(),D=function(I,R,T){v.copy(i,g),S&&v.scaleAndAdd(i,i,y.dirA,I),A&&v.scaleAndAdd(i,i,y.dirB,R),E&&v.scaleAndAdd(i,i,y.dirC,T),v.add(w,w,i)};return D(c,l,f),D(c,l,-p),D(c,-d,-p),D(c,-d,f),D(-u,-d,-p),D(-u,-d,f),D(-u,l,f),D(-u,l,-p),v.scale(w,w,1/8),Rs.create(w,b,x,_)}e.calculateBoxAxes=o}(nd||(nd={})),function(e){function t(T){return void 0!==T.extrema}function n(T,M){return{center:T,radius:M}}function a(T,M){return void 0!==T.extrema?(T.extrema.length=0,T.extrema.push(...M)):T.extrema=M,T}e.hasExtrema=t,e.create=n,e.zero=function r(){return{center:v(),radius:0}},e.clone=function i(T){const M=n(v.clone(T.center),T.radius);return t(T)&&(M.extrema=T.extrema.map(N=>v.clone(N))),M},e.set=function o(T,M,N){return v.copy(T.center,M),T.radius=N,T},e.copy=function s(T,M){return v.copy(T.center,M.center),T.radius=M.radius,t(M)&&a(T,M.extrema.map(N=>v.clone(N))),T},e.setExtrema=a,e.computeBounding=function c(T){const{x:M,y:N,z:V,indices:F}=T;let G=0,L=0,z=0,j=0;const Z=Fe.size(F);for(let $=0;$0&&(G/=Z,L/=Z,z/=Z);for(let $=0;$j&&(j=W)}return{center:v.create(G,L,z),radius:Math.sqrt(j)}},e.transform=function u(T,M,N){return v.transformMat4(T.center,M.center,N),T.radius=M.radius*le.getMaxScaleOnAxis(N),t(M)&&a(T,M.extrema.map(V=>v.transformMat4(v(),V,N))),T},e.translate=function l(T,M,N){return v.add(T.center,M.center,N),t(M)&&a(T,M.extrema.map(V=>v.add(v(),V,N))),T},e.toArray=function d(T,M,N){return v.toArray(T.center,M,N),M[N+3]=T.radius,M},e.fromArray=function f(T,M,N){return v.fromArray(T.center,M,N),T.radius=M[N+3],T},e.fromBox3D=function p(T,M){return v.scale(T.center,v.add(T.center,M.max,M.min),.5),T.radius=v.distance(T.center,M.max),e.setExtrema(T,[v.create(M.min[0],M.min[1],M.min[2]),v.create(M.max[0],M.max[1],M.max[2]),v.create(M.max[0],M.min[1],M.min[2]),v.create(M.min[0],M.max[1],M.max[2]),v.create(M.min[0],M.min[1],M.max[2]),v.create(M.max[0],M.min[1],M.max[2]),v.create(M.max[0],M.max[1],M.min[2]),v.create(M.min[0],M.max[1],M.min[2])]),T},e.fromAxes3D=function m(T,M){return v.copy(T.center,M.origin),T.radius=Math.max(v.magnitude(M.dirA),v.magnitude(M.dirB),v.magnitude(M.dirC)),T};const h=v();e.fromDimensionsAndTransform=function g(T,M,N){const[V,F,G]=M,L=v.create(0,0,0);v.transformMat4(L,L,N);const z=v.create(V,F,G);v.transformMat4(z,z,N);const j=v.create(V,0,0);v.transformMat4(j,j,N);const Z=v.create(0,F,G);v.transformMat4(Z,Z,N);const $=v.create(0,0,G);v.transformMat4($,$,N);const ee=v.create(V,0,G);v.transformMat4(ee,ee,N);const q=v.create(V,F,0);v.transformMat4(q,q,N);const O=v.create(0,F,0);v.transformMat4(O,O,N),v.add(h,L,z),v.scale(h,h,.5);const H=Math.max(v.distance(L,z),v.distance(j,Z));return e.set(T,h,H/2),e.setExtrema(T,[L,z,j,Z,$,ee,q,O]),T};const y=v();e.addVec3=function b(T,M,N){return v.distance(M.center,N)v.clone(V)),...N.extrema.map(V=>v.clone(V))]),T};const _=v();e.expand=function S(T,M,N){var V,F;if(v.copy(T.center,M.center),T.radius=M.radius+N,M.radius<1e-12||(null!==(F=null===(V=M.extrema)||void 0===V?void 0:V.length)&&void 0!==F?F:0)<=1)return T.extrema=void 0,T;if(t(M)){const G=new Float32Array(3*M.extrema.length);for(let z=0;z{v.normalize(_,v.sub(_,z,M.center));const j=v.clone(z),Z=v.dot(_,L.dirA)<0?-1:1;v.scaleAndAdd(j,j,L.dirA,Z);const $=v.dot(_,L.dirB)<0?-1:1;v.scaleAndAdd(j,j,L.dirB,$);const ee=v.dot(_,L.dirC)<0?-1:1;return v.scaleAndAdd(j,j,L.dirC,ee),v.distance(T.center,j)>T.radius&&(M.extrema.length>=14&&v.normalize(_,v.sub(_,j,M.center)),v.scaleAndAdd(j,T.center,_,T.radius)),j}))}return T},e.exactEquals=function A(T,M){return T.radius===M.radius&&v.exactEquals(T.center,M.center)},e.equals=function E(T,M){const N=T.radius,V=M.radius;return Math.abs(N-V)<=vr*Math.max(1,Math.abs(N),Math.abs(V))&&v.equals(T.center,M.center)},e.includes=function w(T,M){if(t(M)){for(const N of M.extrema)if(v.distance(T.center,N)>T.radius)return!1;return!0}return v.distance(T.center,M.center)+M.radius<=T.radius},e.overlaps=function D(T,M){return v.distance(T.center,M.center)<=T.radius+M.radius},e.distance=function I(T,M){return v.distance(T.center,M.center)-T.radius+M.radius},e.distanceToVec=function R(T,M){const{center:N,radius:V}=T;return v.distance(M,N)-V}}(_e||(_e={})),function(e){function n(){return{min:v(),max:v()}}function r(D,I){return v.copy(D.min,I.min),v.copy(D.max,I.max),D}e.create=function t(D,I){return{min:D,max:I}},e.zero=n,e.copy=r,e.clone=function i(D){return r(n(),D)};const o=v();function a(D,I){for(let R=0,T=I.length;R=14?c(D,I.extrema):(v.set(o,I.radius,I.radius,I.radius),v.sub(D.min,I.center,o),v.add(D.max,I.center,o),D)},e.addVec3Array=a,e.fromVec3Array=c,e.addSphere3D=function u(D,I){return _e.hasExtrema(I)&&I.extrema.length>=14?a(D,I.extrema):(g(D,v.subScalar(o,I.center,I.radius)),g(D,v.addScalar(o,I.center,I.radius)),D)},e.intersectsSphere3D=function l(D,I){return v.clamp(o,I.center,D.min,D.max),v.squaredDistance(o,I.center)<=I.radius*I.radius},e.computeBounding=function d(D){const I=v.create(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),R=v.create(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),{x:T,y:M,z:N,indices:V}=D;for(let F=0,G=Fe.size(V);FD.max[0]||I[1]D.max[1]||I[2]D.max[2])},e.overlaps=function A(D,I){return!(D.max[0]I.max[0]||D.max[1]I.max[1]||D.max[2]I.max[2])},e.containsSphere3D=function E(D,I){const R=I.center,T=I.radius;return!(R[0]-TD.max[0]||R[1]-TD.max[1]||R[2]-TD.max[2])},e.nearestIntersectionWithRay=function w(D,I,R,T){const[M,N,V]=I.min,[F,G,L]=I.max,[z,j,Z]=R,$=1/T[0],ee=1/T[1],q=1/T[2];let O,H,W,Q,fe,X;return $>=0?(O=(M-z)*$,H=(F-z)*$):(O=(F-z)*$,H=(M-z)*$),ee>=0?(W=(N-j)*ee,Q=(G-j)*ee):(W=(G-j)*ee,Q=(N-j)*ee),q>=0?(fe=(V-Z)*q,X=(L-Z)*q):(fe=(L-Z)*q,X=(V-Z)*q),W>O&&(O=W),QO&&(O=fe),X0)throw new Error("New key is larger than old key");t.key=n;const r=t.parent;r&&this._compare(t,r)<0&&(this._cut(t,r,this._minNode),this._cascadingCut(r,this._minNode)),this._compare(t,this._minNode)<0&&(this._minNode=t)}delete(t){const n=t.parent;n&&(this._cut(t,n,this._minNode),this._cascadingCut(n,this._minNode)),this._minNode=t,this.extractMinimum()}extractMinimum(){const t=this._minNode;if(t){if(t.child){let r=t.child;do{r.parent=null,r=r.next}while(r!==t.child)}let 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}findMinimum(){return this._minNode}insert(t,n){const r=new Yke(t,n);return this._minNode=this._mergeLists(this._minNode,r),this._nodeCount++,r}isEmpty(){return null===this._minNode}size(){return null===this._minNode?0:this._getNodeListSize(this._minNode)}union(t){this._minNode=this._mergeLists(this._minNode,t._minNode),this._nodeCount+=t._nodeCount}_defaultCompare(t,n){return t.key>n.key?1:t.key0){const s=i;i=o,o=s}this._linkHeaps(o,i),n[i.degree]=null,i.degree++,o=n[i.degree]}n[i.degree]=i}let r=null;for(let i=0;i=d.length;const fe=d[j];if(0!==fe){const X=L,J=fe-1,ce=c[J],ae=ce+u[J];for(let me=ce;meL&&(L=Le),jb.insert(Le,oe)}X=o))for(let J=-O;J<=O;J++){const ce=I+J;if(!(ce<0||ce>=s))for(let be=-H;be<=H;be++){const ae=R+be;if(!(ae<0||ae>=a||(j=(X*s+ce)*a+ae,CB.has(j)||(CB.add(j),i2.has(j))))){if(!N){const me=n[0]+X*y[0]-x,oe=n[1]+ce*y[1]-_,K=n[2]+ae*y[2]-S;if(me*me+oe*oe+K*K-ee>L){$.push(X,ce,ae,j);continue}}G.push(X,ce,ae,j),V++}}}}}if(N=!1,0===V){if(1===A){const Q=jb.findMinimum();if(Q){const{key:fe,value:X}=Q;return Uu.add(t,X,fe),!0}}else for(;!jb.isEmpty()&&(Z||jb.findMinimum().key<=L)&&t.count=A||T||t.count>=w)return t.count>0;if(N=!0,z=!0,$.length>0){for(let Q=0,fe=$.length;Q0){const p=Math.ceil(c/u),m=Math.pow(p/(o[0]*o[1]*o[2]),1/3);a=[Math.ceil(o[0]*m),Math.ceil(o[1]*m),Math.ceil(o[2]*m)],s=[o[0]/a[0],o[1]/a[1],o[2]/a[2]]}else s=o,a=[1,1,1];return function Zke(e){const{expandedBox:t,size:[n,r,i],data:{x:o,y:s,z:a,radius:c,indices:u},elementCount:l,delta:d}=e,f=n*r*i,{min:[p,m,h]}=t;let g=0,y=0;const b=new Uint32Array(f),x=new Int32Array(l);for(let w=0;wg&&(g=c[D])}const _=new Int32Array(y);for(let w=0,D=0;w0&&(b[w]=D+1,_[D]=I,D+=1)}const S=new Uint32Array(y);for(let w=1;w0){const I=D-1;E[S[I]+A[I]]=w,A[I]+=1}}return{size:e.size,bucketArray:E,bucketCounts:_,bucketOffset:S,grid:b,delta:d,min:e.expandedBox.min,data:e.data,maxRadius:g,expandedBox:e.expandedBox,boundingBox:e.boundingBox,boundingSphere:e.boundingSphere}}({size:a,data:{x:e.x,y:e.y,z:e.z,indices:i,radius:e.radius},expandedBox:r,boundingBox:t.box,boundingSphere:t.sphere,elementCount:c,delta:s})}(t,n,r);this.ctx=function Jke(e){return{grid:e,x:.1,y:.1,z:.1,k:1,stopIf:void 0,radius:.1,isCheck:!1}}(i),this.boundary={box:i.boundingBox,sphere:i.boundingSphere},this.buckets={offset:i.bucketOffset,count:i.bucketCounts,array:i.bucketArray},this.result=Uu.create()}}function CQ(e,t){const{min:n,size:[r,i,o],bucketOffset:s,bucketCounts:a,bucketArray:c,grid:u,data:{x:l,y:d,z:f,indices:p,radius:m},delta:h,maxRadius:g}=e.grid,{radius:y,isCheck:b,x,y:_,z:S}=e,A=y+g,E=A*A;Uu.reset(t);const w=Math.max(0,Math.floor((x-A-n[0])/h[0])),D=Math.max(0,Math.floor((_-A-n[1])/h[1])),I=Math.max(0,Math.floor((S-A-n[2])/h[2])),R=Math.min(r-1,Math.floor((x+A-n[0])/h[0])),T=Math.min(i-1,Math.floor((_+A-n[1])/h[1])),M=Math.min(o-1,Math.floor((S+A-n[2])/h[2]));if(w>R||D>T||I>M)return!1;for(let N=w;N<=R;N++)for(let V=D;V<=T;V++)for(let F=I;F<=M;F++){const G=u[(N*i+V)*o+F];if(0===G)continue;const L=G-1,z=s[L],Z=z+a[L];for(let $=z;$0&&Math.sqrt(W)-m[ee]>y)continue;if(b)return!0;Uu.add(t,c[$],W)}}}return t.count>0}const wQ=v(),qh=v(),i2=new Set,CB=new Set,eNe=[.1],tNe=[.1],nNe=[.1],jb=new SQ;var nt,kr,Ae,as,Ot,zn;!function(e){function t(p,m,h){return{kind:"element-location",structure:p,unit:m,element:h||0}}e.create=t,e.clone=function n(p){return t(p.structure,p.unit,p.element)},e.set=function r(p,m,h,g){return m&&(p.structure=m),h&&(p.unit=h),void 0!==g&&(p.element=g),p},e.copy=function i(p,m){return p.unit=m.unit,p.element=m.element,p},e.is=function o(p){return!!p&&"element-location"===p.kind},e.areEqual=function s(p,m){return p.unit===m.unit&&p.element===m.element};const a=v(),c=v();e.distance=function u(p,m){return p.unit.conformation.position(p.element,a),m.unit.conformation.position(m.element,c),v.distance(a,c)},e.position=function l(p,m){return m.unit.conformation.position(m.element,p)},e.residueIndex=function d(p){return p.unit.model.atomicHierarchy.residueAtomSegments.index[p.element]},e.chainIndex=function f(p){return p.unit.model.atomicHierarchy.chainAtomSegments.index[p.element]}}(nt||(nt={}));class iNe{add(t){const n=this.getHash(t);if(this.byHash.has(n)){const r=this.byHash.get(n);for(let i=0,o=r.length;i`${r}-${i.toLocaleLowerCase()}${o}`).replace(t,(n,r,i,o)=>`${r}-${i.toLocaleLowerCase()}${o}`)}function PQ(e,t,n){if(ZI(n))return n.info.namespace=e,n.info.name=n.info.name||EQ(t),void(n.id=`${n.info.namespace}.${n.info.name}`);const r=`${n["@namespace"]||EQ(t)}`,i=e?`${e}.${r}`:r;for(const o of Object.keys(n))"object"!=typeof n[o]&&!ZI(n[o])||PQ(i,o,n[o])}function MQ(e,t){if(ZI(e))t.push(e);else for(const n of Object.keys(e))"object"!=typeof e[n]&&!ZI(e[n])||MQ(e[n],t)}function $o(e,t){return $t(Ot.Dictionary({0:ct(e)}),e,t)}function Wh(e,t){return $t(Ot.List(e,{nonEmpty:!0}),e,t)}function Vu(e,t,n){return $t(Ot.Dictionary({0:ct(e),1:ct(e)}),t,n)}!function(e){e.create=function t(){return{keys:new Set,array:[]}},e.add=function n({keys:i,array:o},s,a){return!i.has(s)&&(i.add(s),o[o.length]=a,!0)},e.has=function r({keys:i},o){return i.has(o)}}(kr||(kr={})),function(e){function n(a,c,u){return{kind:"value",namespace:a,name:c,parent:u}}function o(a,c,u,l){const d=Object.create(null);for(const f of l)d[f]=!0;return{kind:"oneof",namespace:a,name:c,type:u,values:d}}e.Variable=function t(a,c,u){return{kind:"variable",name:a,type:c,isConstraint:u}},e.Value=n,e.Container=function r(a,c,u,l){return{kind:"container",namespace:a,name:c,child:u,alias:l}},e.Union=function i(a){return{kind:"union",types:a}},e.OneOf=o,e.Any={kind:"any"},e.AnyValue={kind:"any-value"},e.Num=n("","Number"),e.Str=n("","String"),e.Bool=o("","Bool",e.Str,["true","false"]),e.oneOfValues=function s({values:a}){return Object.keys(a).sort()}}(Ae||(Ae={})),function(e){function s(c){return!!c&&!!c.head&&"object"==typeof c}function a(c){return!!c&&"string"==typeof c.name}e.Symbol=function t(c){return{name:c}},e.Apply=function n(c,u){return u?{head:c,args:u}:{head:c}},e.isArgumentsArray=function r(c){return!!c&&Array.isArray(c)},e.isArgumentsMap=function i(c){return!!c&&!Array.isArray(c)},e.isLiteral=function o(c){return!s(c)&&!a(c)},e.isApply=s,e.isSymbol=a}(as||(as={})),function(e){function t(r){return{kind:"dictionary",map:r,"@type":0}}e.None=t({}),e.Dictionary=t,e.List=function n(r,i){const{nonEmpty:o=!1}=i||{};return{kind:"list",type:r,nonEmpty:o,"@type":0}}}(Ot||(Ot={})),function(e){e.AnyVar=Ae.Variable("a",Ae.Any),e.AnyValueVar=Ae.Variable("a",Ae.Any),e.ConstrainedVar=Ae.Variable("a",Ae.Any,!0),e.Regex=Ae.Value("Core","Regex"),e.Set=t=>Ae.Container("Core","Set",t||e.AnyValueVar),e.List=t=>Ae.Container("Core","List",t||e.AnyVar),e.Fn=(t,n)=>Ae.Container("Core","Fn",t||e.AnyVar,n),e.Flags=(t,n)=>Ae.Container("Core","Flags",t,n),e.BitFlags=e.Flags(Ae.Num,"BitFlags")}(zn||(zn={})),Ot.Dictionary({0:ct(Ae.Num),1:ct(Ae.Num)});const IB={"@header":"Language Primitives",type:{"@header":"Types",bool:$t(Ot.Dictionary({0:ct(Ae.AnyValue)}),Ae.Bool,"Convert a value to boolean."),num:$t(Ot.Dictionary({0:ct(Ae.AnyValue)}),Ae.Num,"Convert a value to number."),str:$t(Ot.Dictionary({0:ct(Ae.AnyValue)}),Ae.Str,"Convert a value to string."),regex:$t(Ot.Dictionary({0:ct(Ae.Str,{description:"Expression"}),1:ct(Ae.Str,{isOptional:!0,description:"Flags, e.g. 'i' for ignore case"})}),zn.Regex,"Creates a regular expression from a string using the ECMAscript syntax."),list:$t(Ot.List(zn.AnyVar),zn.List()),set:$t(Ot.List(zn.AnyValueVar),zn.Set()),bitflags:$t(Ot.Dictionary({0:ct(Ae.Num)}),zn.BitFlags,"Interpret a number as bitflags."),compositeKey:$t(Ot.List(Ae.AnyValue),Ae.AnyValue)},logic:{"@header":"Logic",not:$o(Ae.Bool),and:Wh(Ae.Bool),or:Wh(Ae.Bool)},ctrl:{"@header":"Control",eval:$t(Ot.Dictionary({0:ct(zn.Fn(zn.AnyVar))}),zn.AnyVar,"Evaluate a function."),fn:$t(Ot.Dictionary({0:ct(zn.AnyVar)}),zn.Fn(zn.AnyVar),'Wrap an expression to a "lazy" function.'),if:$t(Ot.Dictionary({0:ct(Ae.Bool,{description:"Condition"}),1:ct(Ae.Variable("a",Ae.Any),{description:"If true"}),2:ct(Ae.Variable("b",Ae.Any),{description:"If false"})}),Ae.Union([Ae.Variable("a",Ae.Any),Ae.Variable("b",Ae.Any)])),assoc:$t(Ot.Dictionary({0:ct(Ae.Str,{description:"Name"}),1:ct(Ae.Variable("a",Ae.Any),{description:"Value to assign"})}),Ae.Variable("a",Ae.Any))},rel:{"@header":"Relational",eq:Vu(Ae.Variable("a",Ae.AnyValue,!0),Ae.Bool),neq:Vu(Ae.Variable("a",Ae.AnyValue,!0),Ae.Bool),lt:Vu(Ae.Num,Ae.Bool),lte:Vu(Ae.Num,Ae.Bool),gr:Vu(Ae.Num,Ae.Bool),gre:Vu(Ae.Num,Ae.Bool),inRange:$t(Ot.Dictionary({0:ct(Ae.Num,{description:"Value to test"}),1:ct(Ae.Num,{description:"Minimum value"}),2:ct(Ae.Num,{description:"Maximum value"})}),Ae.Bool,"Check if the value of the 1st argument is >= 2nd and <= 3rd.")},math:{"@header":"Math",add:Wh(Ae.Num),sub:Wh(Ae.Num),mult:Wh(Ae.Num),div:Vu(Ae.Num,Ae.Num),pow:Vu(Ae.Num,Ae.Num),mod:Vu(Ae.Num,Ae.Num),min:Wh(Ae.Num),max:Wh(Ae.Num),cantorPairing:Vu(Ae.Num,Ae.Num),sortedCantorPairing:Vu(Ae.Num,Ae.Num),invertCantorPairing:$t(Ot.Dictionary({0:ct(Ae.Num)}),zn.List(Ae.Num)),floor:$o(Ae.Num),ceil:$o(Ae.Num),roundInt:$o(Ae.Num),trunc:$o(Ae.Num),abs:$o(Ae.Num),sign:$o(Ae.Num),sqrt:$o(Ae.Num),cbrt:$o(Ae.Num),sin:$o(Ae.Num),cos:$o(Ae.Num),tan:$o(Ae.Num),asin:$o(Ae.Num),acos:$o(Ae.Num),atan:$o(Ae.Num),sinh:$o(Ae.Num),cosh:$o(Ae.Num),tanh:$o(Ae.Num),exp:$o(Ae.Num),log:$o(Ae.Num),log10:$o(Ae.Num),atan2:Vu(Ae.Num,Ae.Num)},str:{"@header":"Strings",concat:Wh(Ae.Str),match:$t(Ot.Dictionary({0:ct(zn.Regex),1:ct(Ae.Str)}),Ae.Bool)},list:{"@header":"Lists",getAt:$t(Ot.Dictionary({0:ct(zn.List()),1:ct(Ae.Num)}),zn.AnyVar),equal:$t(Ot.Dictionary({0:ct(zn.List()),1:ct(zn.List())}),Ae.Bool)},set:{"@header":"Sets",has:$t(Ot.Dictionary({0:ct(zn.Set(zn.ConstrainedVar)),1:ct(zn.ConstrainedVar)}),Ae.Bool,"Check if the the 1st argument includes the value of the 2nd."),isSubset:$t(Ot.Dictionary({0:ct(zn.Set(zn.ConstrainedVar)),1:ct(zn.Set(zn.ConstrainedVar))}),Ae.Bool,"Check if the the 1st argument is a subset of the 2nd.")},flags:{"@header":"Flags",hasAny:$t(Ot.Dictionary({0:ct(zn.Flags(zn.ConstrainedVar)),1:ct(zn.Flags(zn.ConstrainedVar))}),Ae.Bool,"Check if the the 1st argument has at least one of the 2nd one's flags."),hasAll:$t(Ot.Dictionary({0:ct(zn.Flags(zn.ConstrainedVar)),1:ct(zn.Flags(zn.ConstrainedVar))}),Ae.Bool,"Check if the the 1st argument has all 2nd one's flags.")}};TQ(IB);const mNe=DQ(IB);var wt;function Bn(e,t){return $t(Ot.Dictionary({0:ct(wt.ElementReference,{isOptional:!0,defaultValue:"slot.current-atom"})}),e,t)}function Hb(e,t){return $t(Ot.None,e,t)}!function(){const e=Object.create(null);for(const t of mNe)e[t.id]=t}(),function(e){e.ElementSymbol=Ae.Value("Structure","ElementSymbol"),e.AtomName=Ae.Value("Structure","AtomName"),e.BondFlag=Ae.OneOf("Structure","BondFlag",Ae.Str,["covalent","metallic","ion","hydrogen","sulfide","computed","aromatic"]),e.BondFlags=zn.Flags(e.BondFlag,"BondFlags"),e.SecondaryStructureFlag=Ae.OneOf("Structure","SecondaryStructureFlag",Ae.Str,["alpha","beta","3-10","pi","sheet","strand","helix","turn","none"]),e.SecondaryStructureFlags=zn.Flags(e.SecondaryStructureFlag,"SecondaryStructureFlag"),e.RingFingerprint=Ae.Value("Structure","RingFingerprint"),e.EntityType=Ae.OneOf("Structure","EntityType",Ae.Str,["polymer","non-polymer","water","branched"]),e.EntitySubtype=Ae.OneOf("Structure","EntitySubtype",Ae.Str,["other","polypeptide(D)","polypeptide(L)","polydeoxyribonucleotide","polyribonucleotide","polydeoxyribonucleotide/polyribonucleotide hybrid","cyclic-pseudo-peptide","peptide nucleic acid","oligosaccharide"]),e.ObjectPrimitive=Ae.OneOf("Structure","ObjectPrimitive",Ae.Str,["atomistic","sphere","gaussian","other"]),e.ResidueId=Ae.Value("Structure","ResidueId"),e.ElementSet=Ae.Value("Structure","ElementSet"),e.ElementSelection=Ae.Value("Structure","ElementSelection"),e.ElementReference=Ae.Value("Structure","ElementReference"),e.ElementSelectionQuery=zn.Fn(e.ElementSelection,"ElementSelectionQuery")}(wt||(wt={}));const ye={core:IB,structureQuery:{"@header":"Structure Queries",type:{"@header":"Types",elementSymbol:$t(Ot.Dictionary({0:ct(Ae.Str)}),wt.ElementSymbol,"Create element symbol representation from a string value."),atomName:$t(Ot.Dictionary({0:ct(Ae.AnyValue)}),wt.AtomName,"Convert a value to an atom name."),entityType:$t(Ot.Dictionary({0:ct(wt.EntityType)}),wt.EntityType,`Create normalized representation of entity type: ${Ae.oneOfValues(wt.EntityType).join(", ")}.`),bondFlags:$t(Ot.List(wt.BondFlag),wt.BondFlags,`Create bond flags representation from a list of strings. Allowed flags: ${Ae.oneOfValues(wt.BondFlag).join(", ")}.`),ringFingerprint:$t(Ot.List(wt.ElementSymbol,{nonEmpty:!0}),wt.RingFingerprint,"Create ring fingerprint from the supplied atom element list."),secondaryStructureFlags:$t(Ot.List(wt.SecondaryStructureFlag),wt.SecondaryStructureFlags,`Create secondary structure flags representation from a list of strings. Allowed flags: ${Ae.oneOfValues(wt.SecondaryStructureFlag).join(", ")}.`),authResidueId:$t(Ot.Dictionary({0:ct(Ae.Str,{description:"auth_asym_id"}),1:ct(Ae.Num,{description:"auth_seq_id"}),2:ct(Ae.Str,{description:"pdbx_PDB_ins_code",isOptional:!0})}),wt.ResidueId,'Residue identifier based on "auth_" annotation.'),labelResidueId:$t(Ot.Dictionary({0:ct(Ae.Str,{description:"label_entity_id"}),1:ct(Ae.Str,{description:"label_asym_id"}),2:ct(Ae.Num,{description:"label_seq_id"}),3:ct(Ae.Str,{description:"pdbx_PDB_ins_code",isOptional:!0})}),wt.ResidueId,'Residue identifier based on mmCIF\'s "label_" annotation.')},slot:{"@header":"Iteration Slots",element:$t(Ot.None,wt.ElementReference,"A reference to the current element."),elementSetReduce:$t(Ot.None,Ae.Variable("a",Ae.AnyValue,!0),"Current value of the element set reducer.")},generator:{"@header":"Generators",all:$t(Ot.None,wt.ElementSelectionQuery,"The entire structure."),atomGroups:$t(Ot.Dictionary({"entity-test":ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test for the 1st atom of every entity"}),"chain-test":ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test for the 1st atom of every chain"}),"residue-test":ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test for the 1st atom every residue"}),"atom-test":ct(Ae.Bool,{isOptional:!0,defaultValue:!0}),"group-by":ct(Ae.Any,{isOptional:!0,defaultValue:"atom-key",description:"Group atoms to sets based on this property. Default: each atom has its own set"})}),wt.ElementSelectionQuery,"Return all atoms for which the tests are satisfied, grouped into sets."),bondedAtomicPairs:$t(Ot.Dictionary({0:ct(Ae.Bool,{isOptional:!0,defaultValue:"true for covalent bonds",description:"Test each bond with this predicate. Each bond is visited twice with swapped atom order."})}),wt.ElementSelectionQuery,"Return all pairs of atoms for which the test is satisfied."),rings:$t(Ot.Dictionary({fingerprint:ct(wt.RingFingerprint,{isOptional:!0}),"only-aromatic":ct(Ae.Bool,{isOptional:!0,defaultValue:!1})}),wt.ElementSelectionQuery,"Return all rings or those with the specified fingerprint and/or only aromatic rings."),queryInSelection:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),query:ct(wt.ElementSelectionQuery),"in-complement":ct(Ae.Bool,{isOptional:!0,defaultValue:!1})}),wt.ElementSelectionQuery,"Executes query only on atoms that are in the source selection."),empty:$t(Ot.None,wt.ElementSelectionQuery,"Nada.")},modifier:{"@header":"Selection Modifications",queryEach:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),query:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Query every atom set in the input selection separately."),intersectBy:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),by:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Intersect each atom set from the first sequence from atoms in the second one."),exceptBy:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),by:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Remove all atoms from 'selection' that occur in 'by'."),unionBy:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),by:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"For each atom set A in the orginal sequence, combine all atoms sets in the target selection that intersect with A."),union:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Collects all atom sets in the sequence into a single atom set."),cluster:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),"min-distance":ct(Ae.Num,{isOptional:!0,defaultValue:0}),"max-distance":ct(Ae.Num),"min-size":ct(Ae.Num,{description:"Minimal number of sets to merge, must be at least 2",isOptional:!0,defaultValue:2}),"max-size":ct(Ae.Num,{description:"Maximal number of sets to merge, if not set, no limit",isOptional:!0})}),wt.ElementSelectionQuery,"Combines atom sets that have mutual distance in the interval [min-radius, max-radius]. Minimum/maximum size determines how many atom sets can be combined."),includeSurroundings:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),radius:ct(Ae.Num),"atom-radius":ct(Ae.Num,{isOptional:!0,defaultValue:0,description:"Value added to each atom before the distance check, for example VDW radius. Using this argument is computationally demanding."}),"as-whole-residues":ct(Ae.Bool,{isOptional:!0})}),wt.ElementSelectionQuery,"For each atom set in the selection, include all surrouding atoms/residues that are within the specified radius."),surroundingLigands:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),radius:ct(Ae.Num),"include-water":ct(Ae.Bool,{isOptional:!0,defaultValue:!0})}),wt.ElementSelectionQuery,"Find all ligands components around the source query."),includeConnected:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),"bond-test":ct(Ae.Bool,{isOptional:!0,defaultValue:"true for covalent bonds"}),"layer-count":ct(Ae.Num,{isOptional:!0,defaultValue:1,description:"Number of bonded layers to include."}),"fixed-point":ct(Ae.Bool,{isOptional:!0,defaultValue:!1,description:"Continue adding layers as long as new connections exist."}),"as-whole-residues":ct(Ae.Bool,{isOptional:!0})}),wt.ElementSelectionQuery,"Pick all atom sets that are connected to the target."),wholeResidues:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Expand the selection to whole residues."),expandProperty:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),property:ct(Ae.AnyValue)}),wt.ElementSelectionQuery,"To each atom set in the selection, add all atoms that have the same property value that was already present in the set.")},filter:{"@header":"Selection Filters",pick:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),test:ct(Ae.Bool)}),wt.ElementSelectionQuery,"Pick all atom sets that satisfy the test."),first:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Take the 1st atom set in the sequence."),withSameAtomProperties:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),source:ct(wt.ElementSelectionQuery),property:ct(Ae.Any)}),wt.ElementSelectionQuery,"Pick all atom sets for which the set of given atom properties is a subset of the source properties."),intersectedBy:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),by:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Pick all atom sets that have non-zero intersection with the target."),within:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),target:ct(wt.ElementSelectionQuery),"min-radius":ct(Ae.Num,{isOptional:!0,defaultValue:0}),"max-radius":ct(Ae.Num),"atom-radius":ct(Ae.Num,{isOptional:!0,defaultValue:0,description:"Value added to each atom before the distance check, for example VDW radius. Using this argument is computationally demanding."}),invert:ct(Ae.Bool,{isOptional:!0,defaultValue:!1,description:"If true, pick only atom sets that are further than the specified radius."})}),wt.ElementSelectionQuery,"Pick all atom sets from selection that have any atom within the radius of any atom from target."),isConnectedTo:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),target:ct(wt.ElementSelectionQuery),"bond-test":ct(Ae.Bool,{isOptional:!0,defaultValue:"true for covalent bonds"}),disjunct:ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"If true, there must exist a bond to an atom that lies outside the given atom set to pass test."}),invert:ct(Ae.Bool,{isOptional:!0,defaultValue:!1,description:"If true, return atom sets that are not connected."})}),wt.ElementSelectionQuery,"Pick all atom sets that are connected to the target.")},combinator:{"@header":"Selection Combinators",intersect:$t(Ot.List(wt.ElementSelectionQuery),wt.ElementSelectionQuery,"Return all unique atom sets that appear in all of the source selections."),merge:$t(Ot.List(wt.ElementSelectionQuery),wt.ElementSelectionQuery,"Merges multiple selections into a single one. Only unique atom sets are kept."),distanceCluster:$t(Ot.Dictionary({matrix:ct(zn.List(zn.List(Ae.Num)),{description:"Distance matrix, represented as list of rows (num[][])). Lower triangle is min distance, upper triangle is max distance."}),selections:ct(zn.List(wt.ElementSelectionQuery),{description:"A list of held selections."})}),wt.ElementSelectionQuery,"Pick combinations of atom sets from the source sequences that are mutually within distances specified by a matrix.")},atomSet:{"@header":"Atom Sets",atomCount:$t(Ot.None,Ae.Num),countQuery:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery)}),Ae.Num,"Counts the number of occurences of a specific query inside the current atom set."),reduce:$t(Ot.Dictionary({initial:ct(Ae.Variable("a",Ae.AnyValue,!0),{description:"Initial value assigned to slot.atom-set-reduce. Current atom is set to the 1st atom of the current set for this."}),value:ct(Ae.Variable("a",Ae.AnyValue,!0),{description:"Expression executed for each atom in the set"})}),Ae.Variable("a",Ae.AnyValue,!0),"Execute the value expression for each atom in the current atom set and return the result. Works the same way as Array.reduce in JavaScript (``result = value(value(...value(initial)))``)"),propertySet:$t(Ot.Dictionary({0:ct(zn.ConstrainedVar)}),zn.Set(zn.ConstrainedVar),"Returns a set with all values of the given property in the current atom set.")},atomProperty:{"@header":"Atom Properties",core:{"@header":"Core Properties",elementSymbol:Bn(wt.ElementSymbol),vdw:Bn(Ae.Num,"Van der Waals radius"),mass:Bn(Ae.Num,"Atomic weight"),atomicNumber:Bn(Ae.Num,"Atomic number"),x:Bn(Ae.Num,"Cartesian X coordinate"),y:Bn(Ae.Num,"Cartesian Y coordinate"),z:Bn(Ae.Num,"Cartesian Z coordinate"),atomKey:Bn(Ae.AnyValue,"Unique value for each atom. Main use case is grouping of atoms."),bondCount:$t(Ot.Dictionary({0:ct(wt.ElementReference,{isOptional:!0,defaultValue:"slot.current-atom"}),flags:ct(wt.BondFlags,{isOptional:!0,defaultValue:"covalent"})}),Ae.Num,"Number of bonds (by default only covalent bonds are counted)."),sourceIndex:Bn(Ae.Num,"Index of the atom/element in the input file."),operatorName:Bn(Ae.Str,"Name of the symmetry operator applied to this element."),operatorKey:Bn(Ae.Num,"Key of the symmetry operator applied to this element."),modelIndex:Bn(Ae.Num,"Index of the model in the input file."),modelLabel:Bn(Ae.Str,"Label/header of the model in the input file.")},topology:{connectedComponentKey:Bn(Ae.AnyValue,"Unique value for each connected component.")},macromolecular:{"@header":"Macromolecular Properties (derived from the mmCIF format)",authResidueId:Bn(wt.ResidueId,"type.auth-residue-id symbol executed on current atom's residue"),labelResidueId:Bn(wt.ResidueId,"type.label-residue-id symbol executed on current atom's residue"),residueKey:Bn(Ae.AnyValue,"Unique value for each tuple ``(label_entity_id,auth_asym_id, auth_seq_id, pdbx_PDB_ins_code)``, main use case is grouping of atoms"),chainKey:Bn(Ae.AnyValue,"Unique value for each tuple ``(label_entity_id, auth_asym_id)``, main use case is grouping of atoms"),entityKey:Bn(Ae.AnyValue,"Unique value for each tuple ``label_entity_id``, main use case is grouping of atoms"),isHet:Bn(Ae.Bool,"Equivalent to atom_site.group_PDB !== ATOM"),id:Bn(Ae.Num,"_atom_site.id"),label_atom_id:Bn(wt.AtomName),label_alt_id:Bn(Ae.Str),label_comp_id:Bn(Ae.Str),label_asym_id:Bn(Ae.Str),label_entity_id:Bn(Ae.Str),label_seq_id:Bn(Ae.Num),auth_atom_id:Bn(wt.AtomName),auth_comp_id:Bn(Ae.Str),auth_asym_id:Bn(Ae.Str),auth_seq_id:Bn(Ae.Num),pdbx_PDB_ins_code:Bn(Ae.Str),pdbx_formal_charge:Bn(Ae.Num),occupancy:Bn(Ae.Num),B_iso_or_equiv:Bn(Ae.Num),entityType:Bn(wt.EntityType,"Type of the entity as defined in mmCIF (polymer, non-polymer, branched, water)"),entitySubtype:Bn(wt.EntitySubtype,"Subtype of the entity as defined in mmCIF _entity_poly.type and _pdbx_entity_branch.type (other, polypeptide(D), polypeptide(L), polydeoxyribonucleotide, polyribonucleotide, polydeoxyribonucleotide/polyribonucleotide hybrid, cyclic-pseudo-peptide, peptide nucleic acid, oligosaccharide)"),entityPrdId:Bn(Ae.Str,"The PRD ID of the entity."),entityDescription:Bn(zn.List(Ae.Str)),objectPrimitive:Bn(wt.ObjectPrimitive,"Type of the primitive object used to model this segment as defined in mmCIF/IHM (atomistic, sphere, gaussian, other)"),secondaryStructureKey:Bn(Ae.AnyValue,"Unique value for each secondary structure element."),secondaryStructureFlags:Bn(wt.SecondaryStructureFlags),isModified:Bn(Ae.Bool,"True if the atom belongs to modification of a standard residue."),modifiedParentName:Bn(Ae.Str,"'3-letter' code of the modifed parent residue."),isNonStandard:Bn(Ae.Bool,"True if this is a non-standard residue."),chemCompType:Bn(Ae.Str,"Type of the chemical component as defined in mmCIF.")}},bondProperty:{"@header":"Bond Properties",flags:Hb(wt.BondFlags),order:Hb(Ae.Num),key:Hb(Ae.Num),length:Hb(Ae.Num),atomA:Hb(wt.ElementReference),atomB:Hb(wt.ElementReference)}},internal:{"@header":"Internal Queries",generator:{"@header":"Generators",bundleElement:$t(Ot.Dictionary({groupedUnits:ct(Ae.Any),set:ct(Ae.Any),ranges:ct(Ae.Any)}),Ae.Any),bundle:$t(Ot.Dictionary({elements:ct(Ae.Any)}),wt.ElementSelectionQuery,"A selection with single structure containing represented by the bundle."),current:$t(Ot.None,wt.ElementSelectionQuery,"Current selection provided by the query context. Avoid using this in State Transforms.")}}};TQ(ye);const TNe=DQ(ye);var ue;function Yo(){return Yo.zero()}function id(){return id.zero()}function st(e){return e}function Gn(e,t,n,r){return{label:e,description:n,list:r,type:t}}function QI(e,t,n){const r={};for(const i in e){let o=e[i];o=st.saturate(o,t),o=st.darken(o,-n),r[i]=o}return r}function RQ(e,t=" "){return e.replace(/([a-z\xE0-\xFF])([A-Z\xC0\xDF])/g,`$1${t}$2`)}!function(){const e=Object.create(null);for(const t of TNe)e[t.id]=t}(),function(e){e.core=ye.core,e.struct=ye.structureQuery,e.internal=ye.internal,e.atomName=function t(b){return e.struct.type.atomName([b])},e.es=function n(b){return e.struct.type.elementSymbol([b])},e.list=function r(...b){return e.core.type.list(b)},e.set=function i(...b){return e.core.type.set(b)},e.re=function o(b,x){return e.core.type.regex([b,x])},e.fn=function s(b){return e.core.ctrl.fn([b])},e.evaluate=function a(b){return e.core.ctrl.eval([b])};const c=e.struct.atomProperty.core,u=e.struct.atomProperty.macromolecular,l=e.struct.atomProperty.topology;function d(b){return c[b]()}function f(b){return l[b]()}function p(b){return u[b]()}e.acp=d,e.atp=f,e.ammp=p;const m=e.struct.atomSet.propertySet;e.acpSet=function h(b){return m([d(b)])},e.atpSet=function g(b){return m([f(b)])},e.ammpSet=function y(b){return m([p(b)])}}(ue||(ue={})),function(e){function t(){const T=[.1,0,0];return T[0]=0,T}function c(T,M){const[N,V,F]=M,G=Math.sqrt(V*V+F*F);let L=(su(Math.atan2(F,V))+360)%360;return 0===Math.round(1e4*G)&&(L=Number.NaN),T[0]=L,T[1]=G,T[2]=N,T}function l(T,M,N){return T[0]=M[0]-h*N,T[1]=M[1],T[2]=M[2],T}e.zero=t,e.create=function n(T,M,N){const V=t();return V[0]=T,V[1]=M,V[2]=N,V},e.set=function r(T,M,N,V){return T[0]=M,T[1]=N,T[2]=V,T},e.distance=function i(T,M){const N=M[0]-T[0],V=M[1]-T[1],F=M[2]-T[2];return Math.sqrt(N*N+V*V+F*F)},e.fromColor=function o(T,M){const[N,V,F]=st.toRgb(M),[G,L,z]=function R(T,M,N){return[I((.4124564*(T=D(T))+.3575761*(M=D(M))+.1804375*(N=D(N)))/g),I((.2126729*T+.7151522*M+.072175*N)/y),I((.0193339*T+.119192*M+.9503041*N)/b)]}(N,V,F),j=116*L-16;return T[0]=j<0?0:j,T[1]=500*(G-L),T[2]=200*(L-z),T},e.fromHcl=function s(T,M){return id.toLab(T,M)},e.toColor=function a(T){let M=(T[0]+16)/116,N=isNaN(T[1])?M:M+T[1]/500,V=isNaN(T[2])?M:M-T[2]/200;M=y*w(M),N=g*w(N),V=b*w(V);const F=E(3.2404542*N-1.5371385*M-.4985314*V),G=E(-.969266*N+1.8760108*M+.041556*V),L=E(.0556434*N-.2040259*M+1.0572252*V);return st.fromRgb(Math.round(os(F,0,255)),Math.round(os(G,0,255)),Math.round(os(L,0,255)))},e.toHcl=c,e.copy=function u(T,M){return T[0]=M[0],T[1]=M[1],T[2]=M[2],T},e.darken=l,e.lighten=function d(T,M,N){return l(T,M,-N)};const f=[0,0,0];function p(T,M,N){return c(f,M),id.toLab(T,id.saturate(f,f,N))}e.saturate=p,e.desaturate=function m(T,M,N){return p(T,M,-N)};const h=18,g=.95047,y=1,b=1.08883,x=.137931034,_=.206896552,S=.12841855,A=.008856452;function E(T){return 255*(T<=.00304?12.92*T:1.055*Math.pow(T,1/2.4)-.055)}function w(T){return T>_?T*T*T:S*(T-x)}function D(T){return(T/=255)<=.04045?T/12.92:Math.pow((T+.055)/1.055,2.4)}function I(T){return T>A?Math.pow(T,1/3):T/S+x}}(Yo||(Yo={})),function(e){function t(){const b=[.1,0,0];return b[0]=0,b}e.zero=t,e.create=function n(b,x,_){const S=t();return S[0]=b,S[1]=x,S[2]=_,S},e.set=function r(b,x,_,S){return b[0]=x,b[1]=_,b[2]=S,b},e.hasHue=function i(b){return!isNaN(b[0])};const o=[0,0,0];e.fromColor=function s(b,x){return Yo.toHcl(b,Yo.fromColor(o,x))},e.fromLab=function a(b,x){return Yo.toHcl(b,x)};const c=[0,0,0];function l(b,x){let[_,S,A]=x;return isNaN(_)&&(_=0),_=Yn(_),b[0]=A,b[1]=Math.cos(_)*S,b[2]=Math.sin(_)*S,b}function f(b,x,_){return b[0]=x[0],b[1]=Math.max(0,x[1]+y*_),b[2]=x[2],b}e.toColor=function u(b){return Yo.toColor(l(c,b))},e.toLab=l,e.copy=function d(b,x){return b[0]=x[0],b[1]=x[1],b[2]=x[2],b},e.saturate=f,e.desaturate=function p(b,x,_){return f(b,x,-_)};const m=[0,0,0];function h(b,x,_){return l(m,x),Yo.toHcl(b,Yo.darken(m,m,_))}e.darken=h,e.lighten=function g(b,x,_){return h(b,x,-_)};const y=18}(id||(id={})),function(e){function u(F,G,L){return F<<16|G<<8|L}function l(F,G,L){return 255*F<<16|255*G<<8|255*L}function b(F){const G=F>>16&255;return G!==(F>>8&255)||G!==(255&F)}e.toStyle=function t(F){return`rgb(${F>>16&255}, ${F>>8&255}, ${255&F})`},e.toHexStyle=function n(F){return"#"+("000000"+F.toString(16)).slice(-6)},e.toHexString=function r(F){return"0x"+("000000"+F.toString(16)).slice(-6)},e.toRgbString=function i(F){return`RGB: ${e.toRgb(F).join(", ")}`},e.toRgb=function o(F){return[F>>16&255,F>>8&255,255&F]},e.toRgbNormalized=function s(F){return[(F>>16&255)/255,(F>>8&255)/255,(255&F)/255]},e.fromHexStyle=function a(F){return parseInt(F.replace("#","0x"))},e.fromHexString=function c(F){return parseInt(F)},e.fromRgb=u,e.fromNormalizedRgb=l,e.fromArray=function d(F,G){return u(F[G],F[G+1],F[G+2])},e.fromNormalizedArray=function f(F,G){return l(F[G],F[G+1],F[G+2])},e.toArray=function p(F,G,L){return G[L]=F>>16&255,G[L+1]=F>>8&255,G[L+2]=255&F,G},e.toArrayNormalized=function m(F,G,L){return G[L]=(F>>16&255)/255,G[L+1]=(F>>8&255)/255,G[L+2]=(255&F)/255,G},e.toVec3=function h(F,G){return F[0]=G>>16&255,F[1]=G>>8&255,F[2]=255&G,F},e.toVec3Normalized=function g(F,G){return F[0]=(G>>16&255)/255,F[1]=(G>>8&255)/255,F[2]=(255&G)/255,F},e.interpolate=function y(F,G,L){const z=F>>16&255,j=F>>8&255,Z=255&F;return z+((G>>16&255)-z)*L<<16|j+((G>>8&255)-j)*L<<8|Z+((255&G)-Z)*L},e.hasHue=b;const x=[0,0,0];function _(F,G){return b(F)?(id.fromColor(x,F),id.toColor(id.saturate(x,x,G))):F}e.saturate=_,e.desaturate=function S(F,G){return _(F,-G)};const A=[0,0,0];function E(F,G){return Yo.fromColor(A,F),Yo.toColor(Yo.darken(A,A,G))}function D(F){return F<=.03928?F/12.92:Math.pow((F+.055)/1.055,2.4)}function I(F){return.2126*D((F>>16&255)/255)+.7152*D((F>>8&255)/255)+.0722*D((255&F)/255)}function T(F){return F<.04045?.0773993808*F:Math.pow(.9478672986*F+.0521327014,2.4)}function N(F){return F<.0031308?12.92*F:1.055*Math.pow(F,.41666)-.055}e.darken=E,e.lighten=function w(F,G){return E(F,-G)},e.luminance=I,e.contrast=function R(F,G){const L=I(F),z=I(G);return L>z?(L+.05)/(z+.05):(z+.05)/(L+.05)},e.sRGBToLinear=function M(F){return l(T((F>>16&255)/255),T((F>>8&255)/255),T((255&F)/255))},e.linearToSRGB=function V(F){return l(N((F>>16&255)/255),N((F>>8&255)/255),N((255&F)/255))}}(st||(st={}));const PNe=e=>e.toUpperCase();function Fg(e){return e.toLowerCase().replace(/^\w|\s\w/g,PNe)}function zu(e){return Fg(RQ(function kQ(e){return e.replace(/_/g," ")}(function NQ(e){return e.replace(/-/g," ")}(e))))}function to(e,t,n,r){const i=r.length;if(i>n-t)return!1;for(let o=0;o]+>/g,"")}function s2(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Pc={"orange-red":Gn("Orange-Red","sequential","Orange-Red, sequential color scheme from ColorBrewer 2.0",[16775148,16705736,16635038,16628612,16551257,15689032,14102559,11730944,8323072]),"purple-blue":Gn("Purple-Blue","sequential","Purple-Blue, sequential color scheme from ColorBrewer 2.0",[16775163,15525874,13685222,10927579,7645647,3576e3,356528,285325,145496]),"blue-purple":Gn("Blue-Purple","sequential","Blue-Purple, sequential color scheme from ColorBrewer 2.0",[16252157,14740724,12571622,10403034,9213638,9202609,8929693,8458108,5046347]),oranges:Gn("Oranges","sequential","",[16774635,16705230,16634018,16625259,16616764,15821075,14239745,10892803,8333060]),"blue-green":Gn("Blue-Green","sequential","",[16252157,15070713,13429990,10082505,6734500,4304502,2329413,27948,17435]),"yellow-orange-brown":Gn("Yellow-Orange-Brown","sequential","",[16777189,16775100,16704401,16696399,16685353,15495188,13388802,10040324,6694150]),"yellow-green":Gn("Yellow-Green","sequential","",[16777189,16252089,14282915,11394446,7915129,4303709,2327619,26679,17705]),reds:Gn("Reds","sequential","",[16774640,16703698,16563105,16552562,16476746,15678252,13309981,10817301,6750221]),"red-purple":Gn("Red-Purple","sequential","",[16775155,16638173,16565696,16424885,16214177,14496919,11403646,7995767,4784234]),greens:Gn("Greens","sequential","",[16252149,15070688,13101504,10607003,7652470,4303709,2329413,27948,17435]),"yellow-green-blue":Gn("Yellow-Green-Blue","sequential","",[16777177,15595697,13101492,8375739,4306628,1937856,2252456,2438292,531800]),purples:Gn("Purples","sequential","",[16579581,15724021,14342891,12369372,10394312,8420794,6967715,5515151,4128893]),"green-blue":Gn("Green-Blue","sequential","",[16252144,14742491,13429701,11066805,8113348,5157843,2854078,551084,540801]),greys:Gn("Greys","sequential","",[16777215,15790320,14277081,12434877,9868950,7566195,5395026,2434341,0]),"yellow-orange-red":Gn("Yellow-Orange-Red","sequential","",[16777164,16772512,16701814,16691788,16616764,16535082,14883356,12386342,8388646]),"purple-red":Gn("Purple-Red","sequential","",[16250105,15196655,13941210,13210823,14640560,15149450,13505110,9961539,6750239]),blues:Gn("Blues","sequential","",[16251903,14609399,13032431,10406625,7057110,4362950,2191797,545180,536683]),"purple-blue-green":Gn("Purple-Blue-Green","sequential","",[16775163,15524592,13685222,10927579,6793679,3576e3,164234,93273,83510]),spectral:Gn("Spectral","diverging","",[10355010,13975119,16018755,16625249,16703627,16777151,15136152,11263396,6734501,3311805,6180770]),"red-yellow-green":Gn("Red-Yellow-Green","diverging","",[10813478,14102567,16018755,16625249,16703627,16777151,14282635,10934634,6733155,1742928,26679]),"red-blue":Gn("Red-Blue","diverging","",[6750239,11671595,14049357,16033154,16636871,16250871,13755888,9618910,4428739,2188972,340065]),"pink-yellow-green":Gn("Pink-Yellow-Green","diverging","",[9306450,12917629,14579630,15840986,16638191,16250871,15136208,12116358,8371265,5083681,2581529]),"purple-green":Gn("Purple-Green","diverging","",[4194379,7744131,10055851,12756431,15193320,16250871,14282963,10935200,5942881,1800247,17435]),"red-yellow-blue":Gn("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":Gn("Brown-White-Green","diverging","",[5517317,9195786,12550445,14664317,16181443,16119285,13101797,8441281,3512207,91742,15408]),"red-grey":Gn("Red-Grey","diverging","",[6750239,11671595,14049357,16033154,16636871,16777215,14737632,12237498,8882055,5066061,1710618]),"orange-purple":Gn("Orange-Purple","diverging","",[8338184,11753478,14713364,16627811,16703670,16250871,14211819,11709394,8418220,5515144,2949195]),"set-2":Gn("Set-2","qualitative","",[6734501,16551266,9281739,15174339,10934356,16767279,15058068,11776947]),accent:Gn("Accent","qualitative","",[8374655,12496596,16629894,16777113,3697840,15729279,12540695,6710886]),"set-1":Gn("Set-1","qualitative","",[14948892,3636920,5091146,9981603,16744192,16777011,10901032,16220607,10066329]),"set-3":Gn("Set-3","qualitative","",[9294791,16777139,12499674,16482418,8434131,16626786,11787881,16567781,14277081,12353725,13429701,16772463]),"dark-2":Gn("Dark-2","qualitative","",[1810039,14245634,7696563,15149450,6727198,15117058,10909213,6710886]),paired:Gn("Paired","qualitative","",[10931939,2062516,11722634,3383340,16489113,14883356,16629615,16744192,13284054,6962586,16777113,11622696]),"pastel-2":Gn("Pastel-2","qualitative","",[11789005,16633260,13358568,16042724,15136201,16773806,15852236,13421772]),"pastel-1":Gn("Pastel-1","qualitative","",[16495790,11783651,13429701,14601188,16701862,16777164,15063229,16636652,15921906]),"many-distinct":Gn("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:Gn("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:Gn("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:Gn("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:Gn("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:Gn("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:Gn("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:Gn("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:Gn("Rainbow","sequential","",[3367393,3516485,16383744,15501073,12526114]),"red-white-blue":Gn("Red-White-Blue","diverging","",[12526114,16777215,3367393])},FQ=Object.keys(Pc).map(e=>[e,Pc[e].label,Fg(Pc[e].type)]);function cp(e){return e in Pc?Pc[e]:(console.warn(`unknown color list named '${e}'`),Pc["red-yellow-blue"])}function $h(e){return{kind:"table-legend",table:e}}FQ.filter(e=>"diverging"===Pc[e[0]].type||"sequential"===Pc[e[0]].type),FQ.filter(e=>"qualitative"===Pc[e[0]].type);const NNe={domain:[0,1],reverse:!1,listOrName:"red-yellow-blue",minLabel:"",maxLabel:""};var Gu;!function(e){e.create=function t(n){const{domain:r,reverse:i,listOrName:o}={...NNe,...n},s="string"==typeof o?cp(o).list:o,a=i?s.slice().reverse():s,c=a.length-1;let u=0,l=0,d=0;function f(y,b){l=y,d=b,u=d-l||1}f(r[0],r[1]);const p=Ds(n.minLabel,l.toString()),m=Ds(n.maxLabel,d.toString());let h;if(a.every(y=>Array.isArray(y))){const y=[...a];y.sort((S,A)=>S[1]-A[1]);const b=y.map(S=>S[0]),x=je.ofSortedArray(y.map(S=>S[1])),_=b.length-1;h=S=>{const A=os((S-l)/u,0,1),E=je.findPredecessorIndex(x,A);if(0===E)return b[l];if(E>_)return b[_];const w=x[E-1],I=os((A-w)/(x[E]-w),0,1);return st.interpolate(b[E-1],b[E],I)}}else h=y=>{const b=Math.min(a.length-1,Math.max(0,(y-l)/u*c)),x=Math.floor(b),_=a[x],S=a[Math.ceil(b)];return st.interpolate(_,S,b-x)};return{color:h,colorToArray:(y,b,x)=>{st.toArray(h(y),b,x)},normalizedColorToArray:(y,b,x)=>{st.toArrayNormalized(h(y),b,x)},setDomain:f,get legend(){return function kNe(e,t,n){return{kind:"scale-legend",minLabel:e,maxLabel:t,colors:n}}(p,m,a)}}}}(Gu||(Gu={}));const BQ=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","VDF","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 Nr=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}(Nr||{});var vt=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}(vt||{});const BNe={[vt.Hexose]:Nr.FilledSphere,[vt.HexNAc]:Nr.FilledCube,[vt.Hexosamine]:Nr.CrossedCube,[vt.Hexuronate]:Nr.DividedDiamond,[vt.Deoxyhexose]:Nr.FilledCone,[vt.DeoxyhexNAc]:Nr.DevidedCone,[vt.DiDeoxyhexose]:Nr.FlatBox,[vt.Pentose]:Nr.FilledStar,[vt.Deoxynonulosonate]:Nr.FilledDiamond,[vt.DiDeoxynonulosonate]:Nr.FlatDiamond,[vt.Unknown]:Nr.FlatHexagon,[vt.Assigned]:Nr.Pentagon};function ONe(e,t){return e===vt.Unknown?4===t?Nr.DiamondPrism:5===t?Nr.PentagonalPrism:6===t?Nr.HexagonalPrism:7===t?Nr.HeptagonalPrism:Nr.FlatHexagon:BNe[e]}const DB={abbr:"Unk",name:"Unknown",color:15854817,type:vt.Unknown},qb=[{abbr:"Glc",name:"Glucose",color:37052,type:vt.Hexose},{abbr:"Man",name:"Mannose",color:42577,type:vt.Hexose},{abbr:"Gal",name:"Galactose",color:16765952,type:vt.Hexose},{abbr:"Gul",name:"Gulose",color:16021792,type:vt.Hexose},{abbr:"Alt",name:"Altrose",color:16162465,type:vt.Hexose},{abbr:"All",name:"Allose",color:10830745,type:vt.Hexose},{abbr:"Tal",name:"Talose",color:9424105,type:vt.Hexose},{abbr:"Ido",name:"Idose",color:10582605,type:vt.Hexose},{abbr:"GlcNAc",name:"N-Acetyl Glucosamine",color:37052,type:vt.HexNAc},{abbr:"ManNAc",name:"N-Acetyl Mannosamine",color:42577,type:vt.HexNAc},{abbr:"GalNAc",name:"N-Acetyl Galactosamine",color:16765952,type:vt.HexNAc},{abbr:"GulNAc",name:"N-Acetyl Gulosamine",color:16021792,type:vt.HexNAc},{abbr:"AltNAc",name:"N-Acetyl Altrosamine",color:16162465,type:vt.HexNAc},{abbr:"AllNAc",name:"N-Acetyl Allosamine",color:10830745,type:vt.HexNAc},{abbr:"TalNAc",name:"N-Acetyl Talosamine",color:9424105,type:vt.HexNAc},{abbr:"IdoNAc",name:"N-Acetyl Idosamine",color:10582605,type:vt.HexNAc},{abbr:"GlcN",name:"Glucosamine",color:37052,type:vt.Hexosamine},{abbr:"ManN",name:"Mannosamine",color:42577,type:vt.Hexosamine},{abbr:"GalN",name:"Galactosamine",color:16765952,type:vt.Hexosamine},{abbr:"GulN",name:"Gulosamine",color:16021792,type:vt.Hexosamine},{abbr:"AltN",name:"Altrosamine",color:16162465,type:vt.Hexosamine},{abbr:"AllN",name:"Allosamine",color:10830745,type:vt.Hexosamine},{abbr:"TalN",name:"Talosamine",color:9424105,type:vt.Hexosamine},{abbr:"IdoN",name:"Idosamine",color:10582605,type:vt.Hexosamine},{abbr:"GlcA",name:"Glucuronic Acid",color:37052,type:vt.Hexuronate},{abbr:"ManA",name:"Mannuronic Acid",color:42577,type:vt.Hexuronate},{abbr:"GalA",name:"Galacturonic Acid",color:16765952,type:vt.Hexuronate},{abbr:"GulA",name:"Guluronic Acid",color:16021792,type:vt.Hexuronate},{abbr:"AltA",name:"Altruronic Acid",color:16162465,type:vt.Hexuronate},{abbr:"AllA",name:"Alluronic Acid",color:10830745,type:vt.Hexuronate},{abbr:"TalA",name:"Taluronic Acid",color:9424105,type:vt.Hexuronate},{abbr:"IdoA",name:"Iduronic Acid",color:10582605,type:vt.Hexuronate},{abbr:"Qui",name:"Quinovose",color:37052,type:vt.Deoxyhexose},{abbr:"Rha",name:"Rhamnose",color:42577,type:vt.Deoxyhexose},{abbr:"6dGul",name:"6-Deoxy Gulose",color:16021792,type:vt.Deoxyhexose},{abbr:"6dAlt",name:"6-Deoxy Altrose",color:16162465,type:vt.Deoxyhexose},{abbr:"6dTal",name:"6-Deoxy Talose",color:9424105,type:vt.Deoxyhexose},{abbr:"Fuc",name:"Fucose",color:15539236,type:vt.Deoxyhexose},{abbr:"QuiNAc",name:"N-Acetyl Quinovosamine",color:37052,type:vt.DeoxyhexNAc},{abbr:"RhaNAc",name:"N-Acetyl Rhamnosamine",color:42577,type:vt.DeoxyhexNAc},{abbr:"6dAltNAc",name:"N-Acetyl 6-Deoxy Altrosamine",color:16162465,type:vt.DeoxyhexNAc},{abbr:"6dTalNAc",name:"N-Acetyl 6-Deoxy Talosamine",color:9424105,type:vt.DeoxyhexNAc},{abbr:"FucNAc",name:"N-Acetyl Fucosamine",color:15539236,type:vt.DeoxyhexNAc},{abbr:"Oli",name:"Olivose",color:37052,type:vt.DiDeoxyhexose},{abbr:"Tyv",name:"Tyvelose",color:42577,type:vt.DiDeoxyhexose},{abbr:"Abe",name:"Abequose",color:16021792,type:vt.DiDeoxyhexose},{abbr:"Par",name:"Paratose",color:16162465,type:vt.DiDeoxyhexose},{abbr:"Dig",name:"Digitoxose",color:10830745,type:vt.DiDeoxyhexose},{abbr:"Col",name:"Colitose",color:9424105,type:vt.DiDeoxyhexose},{abbr:"Ara",name:"Arabinose",color:42577,type:vt.Pentose},{abbr:"Lyx",name:"Lyxose",color:16765952,type:vt.Pentose},{abbr:"Xyl",name:"Xylose",color:16021792,type:vt.Pentose},{abbr:"Rib",name:"Ribose",color:16162465,type:vt.Pentose},{abbr:"Kdn",name:"Keto-Deoxy Nonulonic Acid",color:42577,type:vt.Deoxynonulosonate},{abbr:"Neu5Ac",name:"N-Acetyl Neuraminic Acid",color:10830745,type:vt.Deoxynonulosonate},{abbr:"Neu5Gc",name:"N-Glycolyl Neuraminic Acid",color:9424105,type:vt.Deoxynonulosonate},{abbr:"Neu",name:"Neuraminic Acid",color:10582605,type:vt.Deoxynonulosonate},{abbr:"Sia",name:"Sialic acid",color:15539236,type:vt.Deoxynonulosonate},{abbr:"Pse",name:"Pseudaminic Acid",color:42577,type:vt.DiDeoxynonulosonate},{abbr:"Leg",name:"Legionaminic Acid",color:16765952,type:vt.DiDeoxynonulosonate},{abbr:"Aci",name:"Acinetaminic Acid",color:16162465,type:vt.DiDeoxynonulosonate},{abbr:"4eLeg",name:"4-Epilegionaminic Acid",color:9424105,type:vt.DiDeoxynonulosonate},{abbr:"Bac",name:"Bacillosamine",color:37052,type:vt.Unknown},{abbr:"LDmanHep",name:"L-Glycero-D-Manno Heptose",color:42577,type:vt.Unknown},{abbr:"Kdo",name:"Keto-Deoxy Octulonic Acid",color:16765952,type:vt.Unknown},{abbr:"Dha",name:"3-Deoxy Lyxo-Heptulosaric Acid",color:16021792,type:vt.Unknown},{abbr:"DDmanHep",name:"D-Glycero-D-Manno-Heptose",color:16162465,type:vt.Unknown},{abbr:"MurNAc",name:"N-Acetyl Muramic Acid",color:10830745,type:vt.Unknown},{abbr:"MurNGc",name:"N-Glycolyl Muramic Acid",color:9424105,type:vt.Unknown},{abbr:"Mur",name:"Muramic Acid",color:10582605,type:vt.Unknown},{abbr:"Api",name:"Apicose",color:42577,type:vt.Assigned},{abbr:"Fru",name:"Fructose",color:42577,type:vt.Assigned},{abbr:"Tag",name:"Tagatose",color:16765952,type:vt.Assigned},{abbr:"Sor",name:"Sorbose",color:16021792,type:vt.Assigned},{abbr:"Psi",name:"Psicose",color:16162465,type:vt.Assigned}],LNe=function(){const e=new Map;for(let t=0,n=qb.length;t{e.has(t)||e.set(t,DB)}),e}(),zNe=function(){const e=new Map;for(let t=0,n=qb.length;t{e.has(t)||e.set(t,DB)}),e}();let up=UQ;var Si;!function(e){e.toArray=function t(p){return Array.from(p.values())},e.isSuperset=function n(p,m){if(p.size[e[0],Bg(e[1])])),WNe={0:{trace:new Set,directionFrom:new Set,directionTo:new Set,backboneStart:new Set,backboneEnd:new Set,coarseBackbone:new Set},1:{trace:new Set(["CA"]),directionFrom:new Set(["C"]),directionTo:new Set(["O","OC1","O1","OX1","OXT","OT1"]),backboneStart:new Set(["N"]),backboneEnd:new Set(["C"]),coarseBackbone:new Set(["CA","BB","CA1"])},2:{trace:new Set(["CA"]),directionFrom:new Set(["C"]),directionTo:new Set(["O"]),backboneStart:new Set(["N"]),backboneEnd:new Set(["CD"]),coarseBackbone:new Set(["CA"])},3:{trace:new Set(["CA"]),directionFrom:new Set(["C"]),directionTo:new Set(["O"]),backboneStart:new Set(["N"]),backboneEnd:new Set(["CG"]),coarseBackbone:new Set(["CA"])},4:{trace:new Set(["O3'","O3*"]),directionFrom:new Set(["C4'","C4*"]),directionTo:new Set(["C3'","C3*"]),backboneStart:new Set(["P"]),backboneEnd:new Set(["O3'","O3*"]),coarseBackbone:new Set(["P"])},5:{trace:new Set(["O3'","O3*"]),directionFrom:new Set(["C3'","C3*"]),directionTo:new Set(["C1'","C1*"]),backboneStart:new Set(["P"]),backboneEnd:new Set(["O3'","O3*"]),coarseBackbone:new Set(["P"])},6:{trace:new Set(["N4'","N4*"]),directionFrom:new Set(["N4'","N4*"]),directionTo:new Set(["C7'","C7*"]),backboneStart:new Set(["N1'","N1*"]),backboneEnd:new Set(["C'","C*"]),coarseBackbone:new Set(["P"])}},lp=new Set(["CA","C","N","O","O1","O2","OC1","OC2","OT1","OT2","OX1","OXT","H","H1","H2","H3","HA","HN","HXT","BB"]),JI=new Set(["P","OP1","OP2","HOP2","HOP3","O2'","O3'","O4'","O5'","C1'","C2'","C3'","C4'","C5'","H1'","H2'","H2''","HO2'","H3'","H4'","H5'","H5''","HO3'","HO5'","O2*","O3*","O4*","O5*","C1*","C2*","C3*","C4*","C5*"]),jQ=new Set(["d-peptide linking","d-peptide nh3 amino terminus","d-peptide cooh carboxy terminus","d-gamma-peptide, c-delta linking","d-beta-peptide, c-gamma linking"]),HQ=new Set(["l-peptide linking","l-peptide nh3 amino terminus","l-peptide cooh carboxy terminus","l-gamma-peptide, c-delta linking","l-beta-peptide, c-gamma linking"]),$Ne=new Set(["d-gamma-peptide, c-delta linking","l-gamma-peptide, c-delta linking"]),YNe=new Set(["d-beta-peptide, c-gamma linking","l-beta-peptide, c-gamma linking"]),XNe=new Set(["d-peptide nh3 amino terminus","d-peptide cooh carboxy terminus","l-peptide nh3 amino terminus","l-peptide cooh carboxy terminus"]),qQ=new Set(["peptide linking","peptide-like"]),KNe=Si.unionMany(jQ,HQ,qQ),WQ=new Set(["dna linking","l-dna linking","dna oh 5 prime terminus","dna oh 3 prime terminus"]),$Q=new Set(["rna linking","l-rna linking","rna oh 5 prime terminus","rna oh 3 prime terminus"]),YQ=Si.unionMany(new Set(["d-saccharide, beta linking","l-saccharide, beta linking","d-saccharide, alpha linking","l-saccharide, alpha linking","l-saccharide","d-saccharide","saccharide"]),new Set(["d-saccharide 1,4 and 1,4 linking","l-saccharide 1,4 and 1,4 linking","d-saccharide 1,4 and 1,6 linking","l-saccharide 1,4 and 1,6 linking"])),ZNe=new Set(["non-polymer","other"]),QNe=new Set(["ion"]),JNe=new Set(["lipid"]),eT=new Set(["SOL","WAT","HOH","H2O","W","DOD","D3O","TIP","TIP3","TIP4","SPC"]),EB=new Set(["HIS","ARG","LYS","ILE","PHE","LEU","TRP","ALA","MET","PRO","CYS","ASN","VAL","GLY","SER","GLN","TYR","ASP","GLU","THR","SEC","PYL","UNK","MSE","SEP","TPO","PTR","PCA","HYP","HSD","HSE","HSP","LSN","ASPP","GLUP","HID","HIE","HIP","LYN","ASH","GLH"]),XQ=new Set(["DAL","DAR","DSG","DAS","DCY","DGL","DGN","DHI","DIL","DLE","DLY","MED","DPN","DPR","DSN","DTH","DTR","DTY","DVA","DNE"]),a2=Si.unionMany(EB,XQ),eFe=new Set(["NME","ACE","NH2","FOR","FMT"]),c2=new Set(["A","C","T","G","I","U","N"]),u2=new Set(["DA","DC","DT","DG","DI","DU","DN"]),PB=new Set(["APN","CPN","TPN","GPN"]),tFe=new Set(["A","G","I","DA","DG","DI","APN","GPN"]),nFe=new Set(["C","T","U","DC","DT","DU","CPN","TPN"]),tT=Si.unionMany(c2,u2,PB),rFe=e=>tFe.has(e.toUpperCase()),iFe=e=>nFe.has(e.toUpperCase()),Wb=Si.unionMany(a2,tT);function Yh(e,t){return t=t.toUpperCase(),PB.has(t)?8:KNe.has(e)?5:$Q.has(e)?6:WQ.has(e)?7:YQ.has(e)?9:eT.has(t)?2:zQ.has(t)?3:VQ.has(t)?4:ZNe.has(e)?up.has(t)?9:a2.has(t)?5:c2.has(t)?6:u2.has(t)?7:1:0}function oFe(e,t){return 5===t?$Ne.has(e)?2:YNe.has(e)?3:XNe.has(e)?0:1:6===t?4:7===t?5:8===t?6:0}function KQ(e){return e=e.toUpperCase(),a2.has(e)?"peptide linking":c2.has(e)?"rna linking":u2.has(e)?"dna linking":up.has(e)?"saccharide":"other"}function aFe(e){return e=e.toUpperCase(),eT.has(e)?"water":Wb.has(e)?"polymer":up.has(e)?"branched":"non-polymer"}function cFe(e,t){return e=e.toUpperCase(),HQ.has(t)?"polypeptide(L)":jQ.has(t)?"polypeptide(D)":$Q.has(t)?"polyribonucleotide":WQ.has(t)?"polydeoxyribonucleotide":YQ.has(t)||up.has(e)?"oligosaccharide":PB.has(e)?"peptide nucleic acid":EB.has(e)?"polypeptide(L)":XQ.has(e)?"polypeptide(D)":c2.has(e)?"polyribonucleotide":u2.has(e)?"polydeoxyribonucleotide":QNe.has(t)||zQ.has(e)?"ion":JNe.has(t)||VQ.has(e)?"lipid":qQ.has(t)?"peptide-like":"other"}function nT(e){return Ya(e)||ZQ(e)}function Ya(e){return 7===e||6===e||8===e}function ZQ(e){return 5===e}var cr,jn;!function(e){e.is=ea.has,e.create=ea.create,e.SecondaryStructureMmcif={helx_lh_27_p:1058,helx_lh_3t_p:2082,helx_lh_al_p:4130,helx_lh_a_n:524321,helx_lh_b_n:1048609,helx_lh_ga_p:8226,helx_lh_n:33,helx_lh_om_p:16418,helx_lh_ot_n:131105,helx_lh_ot_p:546,helx_lh_p:34,helx_lh_pi_p:32802,helx_lh_pp_p:65570,helx_lh_z_n:262177,helx_n:1,helx_ot_n:1,helx_ot_p:2,helx_p:2,helx_rh_27_p:1090,helx_rh_3t_p:2114,helx_rh_al_p:4162,helx_rh_a_n:524353,helx_rh_b_n:1048641,helx_rh_ga_p:8258,helx_rh_n:65,helx_rh_om_p:16450,helx_rh_ot_n:131137,helx_rh_ot_p:578,helx_rh_p:66,helx_rh_pi_p:32834,helx_rh_pp_p:65602,helx_rh_z_n:262209,strn:4194308,turn_ot_p:33554448,turn_p:16,turn_ty1p_p:67109136,turn_ty1_p:67109008,turn_ty2p_p:134218e3,turn_ty2_p:134217872,turn_ty3p_p:268435728,turn_ty3_p:268435600,bend:8,other:0},e.SecondaryStructurePdb={1:4162,2:16450,3:32834,4:8258,5:2114,6:4130,7:16418,8:8226,9:1026,10:65538},e.SecondaryStructureStride={H:4098,G:2050,I:32770,E:8388612,B:4194308,T:16,C:536870912},e.SecondaryStructureDssp={H:4098,B:4194308,E:8388612,G:2050,I:32770,T:16,S:8}}(cr||(cr={})),function(e){function o(a){switch(a){case"covalent":return 1;case"metal-coordination":return 2;case"hydrogen-bond":return 4;case"disulfide":return 8;case"aromatic":return 16;case"computed":return 32}}e.is=ea.has,e.create=function t(a){return ea.create(a)},e.isCovalent=function n(a){return!!(1&a)},e.isAll=function r(a){return a===Math.pow(2,6)-1},e.Names={covalent:1,"metal-coordination":2,"hydrogen-bond":4,disulfide:8,aromatic:16,computed:32},e.isName=function i(a){return a in e.Names},e.fromName=o,e.fromNames=function s(a){let c=0;for(let u=0,l=a.length;uthis.radiusSq&&(this.radiusSq=n)}radiusSphereStep(t,n){const r=dFe(t,this.center)+n,i=r*r;i>this.radiusSq&&(this.radiusSq=i)}getSphere(t){return t||(t=_e()),v.copy(t.center,this.center),t.radius=Math.sqrt(this.radiusSq),t}getCount(){return this.count}constructor(){this.count=0,this.center=v(),this.radiusSq=0}}!function(e){const t=new e,n=v(),r=v();e.fromArrays=function i({x:a,y:c,z:u},l){t.reset();const d=a.length;for(let f=0;f{s.forEach(a=>{n+=a.edgeCount,a.connectedIndices.forEach(c=>{a.getEdges(c).forEach(u=>{const{unitA:l,unitB:d}=a,f=ju.getEdgeKey(c,l,u.indexB,d);i.set(f,r.length);const p=ju.getVertexKey(c,l),m=o.get(p);void 0===m?o.set(p,[r.length]):m.push(r.length),r.push({...u,indexA:c,unitA:l,unitB:d})})})})}),this.edgeCount=n,this.edges=r,this.edgeKeyIndex=i,this.vertexKeyIndex=o}}!function(e){class t{hasEdges(a){return this.edgeMap.has(a)}getEdges(a){return this.edgeMap.has(a)?this.edgeMap.get(a):QQ}get areUnitsOrdered(){return this.unitA0?i:t<0?n:(n+r)/1.95}const gFe=kB.H;function dp(e){return e===gFe}const yFe=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 bFe(e,t,n){return[t,n]=tn&&([e,n]=[n,e],[t,r]=[r,t]),vFe.get(`${e}|${t}|${n}|${r}`)||1}var fp=te.Schema;const re=fp.str,Ie=fp.int,_n=fp.float,NB=fp.coord,Tt=fp.Aliased,Kh=fp.Matrix,iT=fp.Vector,xr=fp.lstr,Lg=fp.List,On={atom_site:{auth_asym_id:re,auth_atom_id:re,auth_comp_id:re,auth_seq_id:Ie,B_iso_or_equiv:_n,Cartn_x:NB,Cartn_y:NB,Cartn_z:NB,group_PDB:Tt(re),id:Ie,label_alt_id:re,label_asym_id:re,label_atom_id:re,label_comp_id:re,label_entity_id:re,label_seq_id:Ie,occupancy:_n,type_symbol:re,pdbx_PDB_ins_code:re,pdbx_PDB_model_num:Ie,pdbx_formal_charge:Ie,pdbx_label_index:Ie,pdbx_sifts_xref_db_name:re,pdbx_sifts_xref_db_acc:re,pdbx_sifts_xref_db_num:re,pdbx_sifts_xref_db_res:re,ihm_model_id:Ie},atom_site_anisotrop:{id:Ie,type_symbol:re,U:Kh(3,3),U_esd:Kh(3,3),pdbx_auth_seq_id:re,pdbx_auth_asym_id:re,pdbx_auth_atom_id:re,pdbx_auth_comp_id:re,pdbx_label_seq_id:Ie,pdbx_label_alt_id:re,pdbx_label_asym_id:re,pdbx_label_atom_id:re,pdbx_label_comp_id:re,pdbx_PDB_ins_code:re},atom_sites:{entry_id:re,fract_transf_matrix:Kh(3,3),fract_transf_vector:iT(3)},audit_author:{name:re,pdbx_ordinal:Ie,identifier_ORCID:re},audit_conform:{dict_location:re,dict_name:re,dict_version:re},cell:{angle_alpha:_n,angle_beta:_n,angle_gamma:_n,entry_id:re,length_a:_n,length_b:_n,length_c:_n,Z_PDB:Ie,pdbx_unique_axis:re},chem_comp:{formula:re,formula_weight:_n,id:re,mon_nstd_flag:Tt(xr),name:re,type:Tt(xr),pdbx_synonyms:Lg(";",e=>e)},chem_comp_bond:{atom_id_1:re,atom_id_2:re,comp_id:re,value_order:Tt(xr),pdbx_ordinal:Ie,pdbx_stereo_config:Tt(xr),pdbx_aromatic_flag:Tt(xr)},citation:{book_publisher:re,country:re,id:re,journal_abbrev:re,journal_id_ASTM:re,journal_id_CSD:re,journal_id_ISSN:re,journal_volume:re,page_first:re,page_last:re,title:re,year:Ie,pdbx_database_id_DOI:re,pdbx_database_id_PubMed:Ie},citation_author:{citation_id:re,name:re,ordinal:Ie},database_2:{database_id:Tt(xr),database_code:re},entity:{details:re,formula_weight:_n,id:re,src_method:Tt(xr),type:Tt(xr),pdbx_description:Lg(",",e=>e),pdbx_number_of_molecules:Ie,pdbx_mutation:re,pdbx_fragment:re,pdbx_ec:Lg(",",e=>e)},entity_poly:{entity_id:re,nstd_linkage:Tt(xr),nstd_monomer:Tt(xr),type:Tt(re),pdbx_strand_id:Lg(",",e=>e),pdbx_seq_one_letter_code:re,pdbx_seq_one_letter_code_can:re,pdbx_target_identifier:re},entity_poly_seq:{entity_id:re,hetero:Tt(xr),mon_id:re,num:Ie},entry:{id:re},exptl:{entry_id:re,method:Tt(re)},software:{classification:re,date:re,description:re,name:re,type:Tt(xr),version:re,pdbx_ordinal:Ie},struct:{entry_id:re,title:re,pdbx_descriptor:re},struct_asym:{details:re,entity_id:re,id:re,pdbx_modified:re,pdbx_blank_PDB_chainid_flag:Tt(re)},struct_conf:{beg_label_asym_id:re,beg_label_comp_id:re,beg_label_seq_id:Ie,beg_auth_asym_id:re,beg_auth_comp_id:re,beg_auth_seq_id:Ie,conf_type_id:Tt(xr),details:re,end_label_asym_id:re,end_label_comp_id:re,end_label_seq_id:Ie,end_auth_asym_id:re,end_auth_comp_id:re,end_auth_seq_id:Ie,id:re,pdbx_beg_PDB_ins_code:re,pdbx_end_PDB_ins_code:re,pdbx_PDB_helix_class:re,pdbx_PDB_helix_length:Ie,pdbx_PDB_helix_id:re},struct_conn:{conn_type_id:Tt(xr),details:re,id:re,ptnr1_label_asym_id:re,ptnr1_label_atom_id:re,ptnr1_label_comp_id:re,ptnr1_label_seq_id:Ie,ptnr1_auth_asym_id:re,ptnr1_auth_comp_id:re,ptnr1_auth_seq_id:Ie,ptnr1_symmetry:re,ptnr2_label_asym_id:re,ptnr2_label_atom_id:re,ptnr2_label_comp_id:re,ptnr2_label_seq_id:Ie,ptnr2_auth_asym_id:re,ptnr2_auth_comp_id:re,ptnr2_auth_seq_id:Ie,ptnr2_symmetry:re,pdbx_ptnr1_PDB_ins_code:re,pdbx_ptnr1_label_alt_id:re,pdbx_ptnr1_standard_comp_id:re,pdbx_ptnr2_PDB_ins_code:re,pdbx_ptnr2_label_alt_id:re,pdbx_ptnr3_PDB_ins_code:re,pdbx_ptnr3_label_alt_id:re,pdbx_ptnr3_label_asym_id:re,pdbx_ptnr3_label_atom_id:re,pdbx_ptnr3_label_comp_id:re,pdbx_ptnr3_label_seq_id:Ie,pdbx_PDB_id:re,pdbx_dist_value:_n,pdbx_value_order:Tt(xr)},struct_conn_type:{criteria:re,id:Tt(xr),reference:re},struct_keywords:{entry_id:re,text:Lg(",",e=>e),pdbx_keywords:re},struct_ncs_oper:{code:Tt(re),details:re,id:Ie,matrix:Kh(3,3),vector:iT(3)},struct_sheet_range:{beg_label_asym_id:re,beg_label_comp_id:re,beg_label_seq_id:Ie,end_label_asym_id:re,end_label_comp_id:re,end_label_seq_id:Ie,beg_auth_asym_id:re,beg_auth_comp_id:re,beg_auth_seq_id:Ie,end_auth_asym_id:re,end_auth_comp_id:re,end_auth_seq_id:Ie,id:re,sheet_id:re,pdbx_beg_PDB_ins_code:re,pdbx_end_PDB_ins_code:re},struct_site:{details:re,id:re,pdbx_num_residues:Ie,pdbx_evidence_code:re,pdbx_auth_asym_id:re,pdbx_auth_comp_id:re,pdbx_auth_seq_id:re,pdbx_auth_ins_code:re},struct_site_gen:{details:re,id:re,label_alt_id:re,label_asym_id:re,label_atom_id:re,label_comp_id:re,label_seq_id:Ie,auth_asym_id:re,auth_comp_id:re,auth_seq_id:re,site_id:re,symmetry:re,pdbx_auth_ins_code:re,pdbx_num_res:Ie},symmetry:{entry_id:re,cell_setting:Tt(xr),Int_Tables_number:Ie,space_group_name_Hall:re,"space_group_name_H-M":re},pdbx_database_status:{status_code:Tt(re),status_code_sf:Tt(re),status_code_mr:Tt(re),entry_id:re,recvd_initial_deposition_date:re,SG_entry:Tt(xr),deposit_site:Tt(re),process_site:Tt(re),status_code_cs:Tt(re),methods_development_category:Tt(re),pdb_format_compatible:Tt(xr)},pdbx_nonpoly_scheme:{asym_id:re,entity_id:re,mon_id:re,pdb_strand_id:re,ndb_seq_num:re,pdb_seq_num:re,auth_seq_num:re,pdb_mon_id:re,auth_mon_id:re,pdb_ins_code:re},pdbx_database_related:{db_name:re,details:re,db_id:re,content_type:Tt(re)},pdbx_entity_nonpoly:{entity_id:re,comp_id:re,name:re},pdbx_chem_comp_synonyms:{name:re,comp_id:re,provenance:Tt(re)},pdbx_chem_comp_identifier:{comp_id:re,identifier:re,type:Tt(re),program:re,program_version:re},pdbx_unobs_or_zero_occ_residues:{id:Ie,polymer_flag:Tt(xr),occupancy_flag:Tt(Ie),PDB_model_num:Ie,auth_asym_id:re,auth_comp_id:re,auth_seq_id:re,PDB_ins_code:re,label_asym_id:re,label_comp_id:re,label_seq_id:Ie},pdbx_struct_mod_residue:{id:Ie,auth_asym_id:re,auth_comp_id:re,auth_seq_id:Ie,PDB_ins_code:re,label_asym_id:re,label_comp_id:re,label_seq_id:Ie,parent_comp_id:re,details:re},pdbx_struct_oper_list:{id:re,type:Tt(re),name:re,symmetry_operation:re,matrix:Kh(3,3),vector:iT(3)},pdbx_struct_assembly:{method_details:re,oligomeric_details:re,oligomeric_count:Ie,details:re,id:re},pdbx_struct_assembly_gen:{asym_id_list:Lg(",",e=>e),assembly_id:re,oper_expression:re},pdbx_reference_entity_list:{prd_id:re,ref_entity_id:re,type:Tt(xr),details:re,component_id:Ie},pdbx_reference_entity_link:{link_id:Ie,prd_id:re,details:re,ref_entity_id_1:re,ref_entity_id_2:re,entity_seq_num_1:Ie,entity_seq_num_2:Ie,comp_id_1:re,comp_id_2:re,atom_id_1:re,atom_id_2:re,value_order:Tt(xr),component_1:Ie,component_2:Ie,link_class:Tt(re)},pdbx_reference_entity_poly_link:{link_id:Ie,prd_id:re,ref_entity_id:re,component_id:Ie,entity_seq_num_1:Ie,entity_seq_num_2:Ie,comp_id_1:re,comp_id_2:re,atom_id_1:re,atom_id_2:re,value_order:Tt(xr)},pdbx_molecule:{prd_id:re,instance_id:Ie,asym_id:re},pdbx_molecule_features:{prd_id:re,class:Tt(xr),type:Tt(xr),name:re,details:re},entity_src_nat:{entity_id:re,pdbx_organism_scientific:re,pdbx_plasmid_name:re,pdbx_src_id:Ie,pdbx_beg_seq_num:Ie,pdbx_end_seq_num:Ie},entity_src_gen:{entity_id:re,pdbx_gene_src_gene:Lg(",",e=>e),pdbx_gene_src_scientific_name:re,plasmid_name:re,pdbx_src_id:Ie,pdbx_beg_seq_num:Ie,pdbx_end_seq_num:Ie},pdbx_entity_src_syn:{organism_scientific:re,entity_id:re,pdbx_src_id:Ie,pdbx_beg_seq_num:Ie,pdbx_end_seq_num:Ie},pdbx_entity_branch_descriptor:{entity_id:re,descriptor:re,type:Tt(xr),program:re,program_version:re,ordinal:Ie},pdbx_entity_instance_feature:{details:re,feature_type:Tt(re),auth_asym_id:re,asym_id:re,auth_seq_num:re,seq_num:Ie,comp_id:re,auth_comp_id:re,ordinal:Ie},pdbx_entity_branch_list:{entity_id:re,hetero:Tt(xr),comp_id:re,num:Ie},pdbx_entity_branch_link:{link_id:Ie,details:re,entity_id:re,entity_branch_list_num_1:Ie,entity_branch_list_num_2:Ie,comp_id_1:re,comp_id_2:re,atom_id_1:re,leaving_atom_id_1:re,atom_stereo_config_1:Tt(xr),atom_id_2:re,leaving_atom_id_2:re,atom_stereo_config_2:Tt(xr),value_order:Tt(xr)},pdbx_entity_branch:{entity_id:re,type:Tt(re)},pdbx_branch_scheme:{entity_id:re,hetero:Tt(xr),asym_id:re,mon_id:re,num:Ie,pdb_asym_id:re,pdb_seq_num:re,pdb_mon_id:re,auth_asym_id:re,auth_seq_num:re,auth_mon_id:re},pdbx_chem_comp_related:{comp_id:re,related_comp_id:re,relationship_type:Tt(re),details:re},ihm_starting_model_details:{starting_model_id:re,entity_id:re,entity_description:re,asym_id:re,entity_poly_segment_id:Ie,starting_model_source:Tt(re),starting_model_auth_asym_id:re,starting_model_sequence_offset:Ie,dataset_list_id:Ie},ihm_starting_comparative_models:{id:Ie,starting_model_id:re,starting_model_auth_asym_id:re,starting_model_seq_id_begin:Ie,starting_model_seq_id_end:Ie,template_auth_asym_id:re,template_seq_id_begin:Ie,template_seq_id_end:Ie,template_sequence_identity:_n,template_sequence_identity_denominator:Tt(Ie),template_dataset_list_id:Ie,alignment_file_id:Ie},ihm_starting_model_seq_dif:{id:Ie,entity_id:re,asym_id:re,seq_id:Ie,comp_id:re,starting_model_id:re,db_asym_id:re,db_seq_id:Ie,db_comp_id:re,details:re},ihm_model_representation:{id:Ie,name:re,details:re},ihm_model_representation_details:{id:Ie,representation_id:Ie,entity_poly_segment_id:Ie,entity_id:re,entity_description:re,entity_asym_id:re,model_object_primitive:Tt(re),starting_model_id:re,model_mode:Tt(re),model_granularity:Tt(re),model_object_count:Ie},ihm_struct_assembly_details:{id:Ie,assembly_id:Ie,parent_assembly_id:Ie,entity_description:re,entity_id:re,asym_id:re,entity_poly_segment_id:Ie},ihm_struct_assembly:{id:Ie,name:re,description:re},ihm_modeling_protocol:{id:Ie,num_steps:Ie,protocol_name:re},ihm_modeling_protocol_details:{id:Ie,protocol_id:Ie,step_id:Ie,struct_assembly_id:Ie,dataset_group_id:Ie,struct_assembly_description:re,step_name:re,step_method:re,num_models_begin:Ie,num_models_end:Ie,multi_scale_flag:Tt(xr),multi_state_flag:Tt(xr),ordered_flag:Tt(xr),script_file_id:Ie,software_id:Ie},ihm_multi_state_modeling:{state_id:Ie,state_group_id:Ie,population_fraction:_n,population_fraction_sd:_n,state_type:re,state_name:re,experiment_type:Tt(re),details:re},ihm_modeling_post_process:{id:Ie,protocol_id:Ie,analysis_id:Ie,step_id:Ie,type:Tt(re),feature:Tt(re),num_models_begin:Ie,num_models_end:Ie},ihm_ensemble_info:{ensemble_id:Ie,ensemble_name:re,post_process_id:Ie,model_group_id:Ie,ensemble_clustering_method:Tt(re),ensemble_clustering_feature:Tt(re),num_ensemble_models:Ie,num_ensemble_models_deposited:Ie,ensemble_precision_value:_n,ensemble_file_id:Ie},ihm_model_list:{model_id:Ie,model_name:re,assembly_id:Ie,protocol_id:Ie,representation_id:Ie},ihm_model_group:{id:Ie,name:re,details:re},ihm_model_group_link:{model_id:Ie,group_id:Ie},ihm_model_representative:{id:Ie,model_group_id:Ie,model_id:Ie,selection_criteria:Tt(re)},ihm_dataset_list:{id:Ie,data_type:Tt(re),database_hosted:Tt(xr)},ihm_dataset_group:{id:Ie,name:re,application:Tt(re),details:re},ihm_dataset_group_link:{dataset_list_id:Ie,group_id:Ie},ihm_related_datasets:{dataset_list_id_derived:Ie,dataset_list_id_primary:Ie},ihm_dataset_related_db_reference:{id:Ie,dataset_list_id:Ie,db_name:Tt(re),accession_code:re,version:re,details:re},ihm_external_reference_info:{reference_id:Ie,reference_provider:re,reference_type:Tt(re),reference:re,refers_to:Tt(re),associated_url:re},ihm_external_files:{id:Ie,reference_id:Ie,file_path:re,content_type:Tt(re),file_size_bytes:_n,details:re},ihm_dataset_external_reference:{id:Ie,dataset_list_id:Ie,file_id:Ie},ihm_localization_density_files:{id:Ie,file_id:Ie,ensemble_id:Ie,entity_id:re,entity_poly_segment_id:Ie,asym_id:re},ihm_predicted_contact_restraint:{id:Ie,group_id:Ie,entity_id_1:re,entity_id_2:re,asym_id_1:re,asym_id_2:re,comp_id_1:re,comp_id_2:re,seq_id_1:Ie,seq_id_2:Ie,rep_atom_1:Tt(re),rep_atom_2:Tt(re),distance_lower_limit:_n,distance_upper_limit:_n,probability:_n,restraint_type:Tt(re),model_granularity:Tt(re),dataset_list_id:Ie,software_id:Ie},ihm_cross_link_list:{id:Ie,group_id:Ie,entity_description_1:re,entity_description_2:re,entity_id_1:re,entity_id_2:re,comp_id_1:re,comp_id_2:re,seq_id_1:Ie,seq_id_2:Ie,linker_type:Tt(re),dataset_list_id:Ie},ihm_cross_link_restraint:{id:Ie,group_id:Ie,entity_id_1:re,entity_id_2:re,asym_id_1:re,asym_id_2:re,comp_id_1:re,comp_id_2:re,seq_id_1:Ie,seq_id_2:Ie,atom_id_1:re,atom_id_2:re,restraint_type:Tt(re),conditional_crosslink_flag:Tt(re),model_granularity:Tt(re),distance_threshold:_n,psi:_n,sigma_1:_n,sigma_2:_n},ihm_cross_link_result_parameters:{id:Ie,restraint_id:Ie,model_id:Ie,psi:_n,sigma_1:_n,sigma_2:_n},ihm_2dem_class_average_restraint:{id:Ie,dataset_list_id:Ie,number_raw_micrographs:Ie,pixel_size_width:_n,pixel_size_height:_n,image_resolution:_n,image_segment_flag:Tt(xr),number_of_projections:Ie,struct_assembly_id:Ie,details:re},ihm_2dem_class_average_fitting:{id:Ie,restraint_id:Ie,model_id:Ie,cross_correlation_coefficient:_n,rot_matrix:Kh(3,3),tr_vector:iT(3)},ihm_3dem_restraint:{id:Ie,dataset_list_id:Ie,model_id:Ie,struct_assembly_id:Ie,fitting_method:re,number_of_gaussians:Ie,cross_correlation_coefficient:_n},ihm_sas_restraint:{id:Ie,dataset_list_id:Ie,model_id:Ie,struct_assembly_id:Ie,profile_segment_flag:Tt(xr),fitting_atom_type:re,fitting_method:re,fitting_state:Tt(re),radius_of_gyration:_n,chi_value:_n,details:re},ihm_starting_model_coord:{ordinal_id:Ie,starting_model_id:re,group_PDB:Tt(re),id:Ie,type_symbol:re,entity_id:re,atom_id:re,comp_id:re,seq_id:Ie,asym_id:re,Cartn_x:_n,Cartn_y:_n,Cartn_z:_n,B_iso_or_equiv:_n},ihm_sphere_obj_site:{id:Ie,entity_id:re,seq_id_begin:Ie,seq_id_end:Ie,asym_id:re,Cartn_x:_n,Cartn_y:_n,Cartn_z:_n,object_radius:_n,rmsf:_n,model_id:Ie},ihm_gaussian_obj_site:{id:Ie,entity_id:re,seq_id_begin:Ie,seq_id_end:Ie,asym_id:re,mean_Cartn_x:_n,mean_Cartn_y:_n,mean_Cartn_z:_n,weight:_n,covariance_matrix:Kh(3,3),model_id:Ie},ihm_gaussian_obj_ensemble:{id:Ie,entity_id:re,seq_id_begin:Ie,seq_id_end:Ie,asym_id:re,mean_Cartn_x:_n,mean_Cartn_y:_n,mean_Cartn_z:_n,weight:_n,covariance_matrix:Kh(3,3),ensemble_id:Ie},ihm_feature_list:{feature_id:Ie,feature_type:Tt(re),entity_type:Tt(re)},ihm_poly_residue_feature:{ordinal_id:Ie,feature_id:Ie,entity_id:re,asym_id:re,comp_id_begin:re,comp_id_end:re,seq_id_begin:Ie,seq_id_end:Ie},ihm_derived_distance_restraint:{id:Ie,group_id:Ie,feature_id_1:Ie,feature_id_2:Ie,group_conditionality:Tt(re),random_exclusion_fraction:_n,distance_upper_limit:_n,restraint_type:Tt(re),dataset_list_id:Ie},ma_model_list:{ordinal_id:Ie,model_id:Ie,model_group_id:Ie,model_name:re,model_group_name:re,model_type:Tt(re),data_id:Ie},ma_target_entity:{entity_id:re,data_id:Ie,origin:Tt(re)},ma_target_entity_instance:{asym_id:re,entity_id:re,details:re},ma_target_ref_db_details:{target_entity_id:re,db_name:Tt(re),db_code:re,db_accession:re,seq_db_isoform:re,seq_db_align_begin:re,seq_db_align_end:re,ncbi_taxonomy_id:re,organism_scientific:re},ma_data:{id:Ie,content_type:Tt(re),content_type_other_details:re,name:re},ma_software_group:{ordinal_id:Ie,group_id:Ie,software_id:Ie},ma_qa_metric:{id:Ie,name:re,type:Tt(re),mode:Tt(re),software_group_id:Ie},ma_qa_metric_global:{ordinal_id:Ie,model_id:Ie,metric_id:Ie,metric_value:_n},ma_qa_metric_local:{ordinal_id:Ie,model_id:Ie,label_asym_id:re,label_seq_id:Ie,label_comp_id:re,metric_id:Ie,metric_value:_n}};var Jn;!function(e){let t;var o;let n;(o=t=e.IntDataType||(e.IntDataType={}))[o.Int8=1]="Int8",o[o.Int16=2]="Int16",o[o.Int32=3]="Int32",o[o.Uint8=4]="Uint8",o[o.Uint16=5]="Uint16",o[o.Uint32=6]="Uint32",function(o){o[o.Float32=32]="Float32",o[o.Float64=33]="Float64"}(n=e.FloatDataType||(e.FloatDataType={})),e.getDataType=function r(o){let s;return s=o instanceof Int8Array?e.IntDataType.Int8:o instanceof Int16Array?e.IntDataType.Int16:o instanceof Int32Array?e.IntDataType.Int32:o instanceof Uint8Array?e.IntDataType.Uint8:o instanceof Uint16Array?e.IntDataType.Uint16:o instanceof Uint32Array?e.IntDataType.Uint32:o instanceof Float32Array?e.FloatDataType.Float32:o instanceof Float64Array?e.FloatDataType.Float64:e.IntDataType.Int32,s},e.isSignedIntegerDataType=function i(o){if(o instanceof Int8Array||o instanceof Int16Array||o instanceof Int32Array)return!0;for(let s=0,a=o.length;s=0;n--)t=wFe(t,e.encoding[n]);return t}function wFe(e,t){switch(t.kind){case"ByteArray":switch(t.type){case Jn.IntDataType.Uint8:return e;case Jn.IntDataType.Int8:return function AFe(e){return new Int8Array(e.buffer,e.byteOffset)}(e);case Jn.IntDataType.Int16:return function IFe(e){return $b(e,2,Int16Array)}(e);case Jn.IntDataType.Uint16:return function TFe(e){return $b(e,2,Uint16Array)}(e);case Jn.IntDataType.Int32:return function DFe(e){return $b(e,4,Int32Array)}(e);case Jn.IntDataType.Uint32:return function EFe(e){return $b(e,4,Uint32Array)}(e);case Jn.FloatDataType.Float32:return function PFe(e){return $b(e,4,Float32Array)}(e);case Jn.FloatDataType.Float64:return function MFe(e){return $b(e,8,Float64Array)}(e);default:Rr()}case"FixedPoint":return function RFe(e,t){const n=e.length,r=rJ(t.srcType,n),i=1/t.factor;for(let o=0;o=0?Math.ceil((p+1)/m):Math.ceil((p+1)/(-m-1))}function i({limit8:p,limit16:m},h,g){h.pack8+=t(g,p),h.pack16+=t(g,m),h.count+=1}function o(p,m){p.pack8+=t(m,127),p.pack16+=t(m,32767),p.count+=1}function s(p){return 4*p.count<2*p.pack16?{length:4*p.count,elem:4}:2*p.pack16g.length-y.length),h}e.getSize=d,e.classify=function f(p){if(p.length<2)return Ln.by(Ln.byteArray);switch(d(p)[0].kind){case"pack":return Ln.by(Ln.integerPacking);case"rle":return Ln.by(Ln.runLength).and(Ln.integerPacking);case"delta":return Ln.by(Ln.delta).and(Ln.integerPacking);case"delta-rle":return Ln.by(Ln.delta).and(Ln.runLength).and(Ln.integerPacking);default:Rr()}}}(f2||(f2={})),function(e){e.classify=function n(i){const{mantissaDigits:s,integerDigits:a}=function GFe(e,t,n){let r=1,i=0;for(let o=0,s=e.length;o=0){const c=VFe(e[o],t,n);c<0?r=-1:c>r&&(r=c)}const a=Math.abs(e[o]);if(a>n){const c=Math.floor(Math.log10(Math.abs(a)))+1;c>i&&(i=c)}}return{mantissaDigits:r,integerDigits:i}}(i,4,1e-6);if(s<0||s+a>10)return Ln.by(Ln.byteArray);if(0===s)return f2.classify(i);const c=function r(i){let o=1;for(let s=0;sn[e].value(t)}function qFe(e){return(t,n)=>n[e].value(t).join(n[e].schema.separator)}function zB(e,...t){return(n,r)=>r[e].schema.space.get(r[e].value(n),...t)}function p2(e){return(t,n)=>n[e].valueKind(t)}function WFe(e,t){const n=[],i=p2(e);if(1===t.rank){const o=t.dimensions[0];for(let s=0;s 3 or rank 0 are currently not supported.");{const o=t.dimensions[0],s=t.dimensions[1],a=t.dimensions[2];for(let c=0;c!!t.shouldInclude)?e.fields.filter(t=>!t.shouldInclude||e.source.some(n=>t.shouldInclude(n.data))):e.fields}function sJ(e,t){const n=e.instance(t),r=n.source.filter(s=>s.rowCount>0);return r.length?{instance:n,rowCount:r.reduce((s,a)=>s+a.rowCount,0),source:r.map(s=>({data:s.data,keys:()=>s.keys?s.keys():XI.Range(0,s.rowCount-1),rowCount:s.rowCount}))}:{instance:n,rowCount:0,source:[]}}!function(e){function t(i){return new sT([i])}function r(i){switch(i.kind){case"ByteArray":return Ln.byteArray;case"FixedPoint":return Ln.fixedPoint(i.factor);case"IntervalQuantization":return Ln.intervalQuantizaiton(i.min,i.max,i.numSteps);case"RunLength":return Ln.runLength;case"Delta":return Ln.delta;case"IntegerPacking":return Ln.integerPacking;case"StringArray":return Ln.stringArray}}e.by=t,e.fromEncoding=function n(i){let o=t(r(i[0]));for(let s=1;s=0?I/S|0:I/A|0}return E+=_.length,E}e.byteArray=s,e.fixedPoint=function c(_){return S=>function a(_,S){const A=Jn.getDataType(_),E=new Int32Array(_.length);for(let w=0,D=_.length;wfunction u(_,S,A,E,w){const D=Jn.getDataType(_);if(!_.length)return{encodings:[{kind:"IntervalQuantization",min:S,max:A,numSteps:E,srcType:D}],data:new Int32Array(0)};if(A=A?E-1:0|Math.round((N-S)/I)}return{encodings:[{kind:"IntervalQuantization",min:S,max:A,numSteps:E,srcType:D}],data:R}}(w,_,S,A,E)},e.runLength=function d(_){let S=Jn.getDataType(_);if(void 0===S&&(_=new Int32Array(_),S=Jn.IntDataType.Int32),!_.length)return{encodings:[{kind:"RunLength",srcType:S,srcSize:0}],data:new Int32Array(0)};let A=2;for(let I=1,R=_.length;I=0)for(;M>=A;)D[I]=A,++I,M-=A;else for(;M<=E;)D[I]=E,++I,M-=E;D[I]=M,++I}const R=s(D);return{encodings:[{kind:"IntegerPacking",byteCount:S.bytesPerElement,isUnsigned:!S.isSigned,srcSize:w},R.encodings[0]],data:R.data}}(_,S)},e.stringArray=function x(_){const S=Object.create(null),A=[],E=new Int32Array(_.length),w=ze.create(Int32Array,1,Math.min(1024,_.length<32?_.length+1:Math.round(_.length/8)+1));ze.add(w,0);let D=0,I=0;for(const F of _){if(null==F){E[I++]=-1;continue}let G=S[F];void 0===G&&(D+=F.length,G=A.length,A[G]=F,S[F]=G,ze.add(w,D)),E[I++]=G}const R=ze.compact(w),M=BB(R).encode(R),V=BB(E).encode(E);return{encodings:[{kind:"StringArray",dataEncoding:V.encoding,stringData:A.join(""),offsetEncoding:M.encoding,offsets:M.data}],data:V.data}}}(Ln||(Ln={})),function(e){function n(a,c,u){return{name:a,type:1,value:c,valueKind:u&&u.valueKind,defaultFormat:u?{encoder:u.encoder,typedArray:u.typedArray}:void 0,shouldInclude:u&&u.shouldInclude}}e.str=function t(a,c,u){return{name:a,type:0,value:c,valueKind:u&&u.valueKind,defaultFormat:u&&u.encoder?{encoder:u.encoder}:void 0,shouldInclude:u&&u.shouldInclude}},e.int=n,e.float=function r(a,c,u){return{name:a,type:2,value:c,valueKind:u&&u.valueKind,defaultFormat:u?{encoder:u.encoder,typedArray:u.typedArray,digitCount:typeof u.digitCount<"u"?u.digitCount:void 0}:void 0,shouldInclude:u&&u.shouldInclude}},e.index=function i(a){return n(a,(c,u,l)=>l+1,{typedArray:Int32Array,encoder:Ln.by(Ln.delta).and(Ln.runLength).and(Ln.integerPacking)})};class o{constructor(){this.fields=[]}index(c){return this.fields.push(e.index(c)),this}str(c,u,l){return this.fields.push(e.str(c,u,l)),this}int(c,u,l){return this.fields.push(e.int(c,u,l)),this}vec(c,u,l){for(let d=0;du.split(".")[0]);return{includeCategory:u=>!o.includes(u)&&(i.length<=0||-1!==i.indexOf(u)),includeField(u,l){const d=u+"."+l;return!a.includes(d)&&(!c.includes(u)||s.includes(d))}}},e.DefaultFilter={includeCategory:r=>!0,includeField:(r,i)=>!0},e.DefaultFormatter={getFormat(r,i){}},e.ofTable=function n(r,i){return i?{fields:oJ(r._schema),source:[{data:r,rowCount:i.length,keys:()=>XI.Array(i)}]}:{fields:oJ(r._schema),source:[{data:r,rowCount:r._rowCount}]}}}(lu||(lu={})),function(e){function t(r,i,o){r.startDataBlock(i);for(const s of o._tableNames)r.writeCategory({name:s,instance:()=>lu.ofTable(o[s])})}e.writeDatabase=t,e.writeDatabaseCollection=function n(r,i){for(const o of Object.keys(i))t(r,o,i[o])}}(UB||(UB={}));class YFe{constructor(){this.builder=ir.create(),this.encoded=!1,this.dataBlockCreated=!1,this.filter=lu.DefaultFilter,this.formatter=lu.DefaultFormatter,this.isBinary=!1,this.binaryEncodingProvider=void 0}setFilter(t){this.filter=t||lu.DefaultFilter}isCategoryIncluded(t){return this.filter.includeCategory(t)}setFormatter(t){this.formatter=t||lu.DefaultFormatter}startDataBlock(t){this.dataBlockCreated=!0,ir.write(this.builder,`data_${(t||"").replace(/[ \n\t]/g,"").toUpperCase()}\n#\n`)}writeCategory(t,n,r){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(!r?.ignoreFilter&&!this.filter.includeCategory(t.name))return;const{instance:i,rowCount:o,source:s}=sJ(t,n);o&&(1===o?function XFe(e,t,n,r,i,o){const s=GB(t),a=n[0],c=a.data;let u=s.reduce((p,m)=>i.includeField(e.name,m.name)?Math.max(p,m.name.length):0,0);if(0===u)return;u+=e.name.length+6;const d=a.keys().move(),f=cJ(e.name,t.fields,o);for(let p=0;pi.includeField(e.name,d.name)),c=a.length;if(0===c)return;const u=cJ(e.name,a,o);uJ(r,"loop_");for(let d=0;d=0}(c)?(aT(e,c),!0):function nBe(e,t){if(!t)return ir.writeSafe(e,". "),!1;const n=t.charCodeAt(0);let r=!1,i=0,o=!1,s=!1;for(let a=0,c=t.length-1;a<=c;a++)switch(t.charCodeAt(a)){case 9:case 32:r=!0;break;case 10:return aT(e,t),!0;case 34:if(a&&a===c)break;if(o)return aT(e,t),!0;s=!0,r=!0,i=0;break;case 39:if(a&&a===c)break;if(s)return aT(e,t),!0;o=!0,r=!0,i=1}return!r&&(35===n||36===n||59===n||91===n||93===n||95===n)&&(r=!0),r?(ir.writeSafe(e,i?'"':"'"),ir.writeSafe(e,t),ir.writeSafe(e,i?'" ':"' ")):(ir.writeSafe(e,t),ir.writeSafe(e," ")),!1}(e,c);1===u?function QFe(e,t){ir.writeInteger(e,t),ir.whitespace1(e)}(e,c):function JFe(e,t,n){ir.writeFloat(e,t,n),ir.whitespace1(e)}(e,c,i)}return!1}function cJ(e,t,n){const r=[];for(const i of t){const o=n.getFormat(e,i.name);r[r.length]=o&&typeof o.digitCount<"u"?2===i.type?Math.pow(10,Math.max(0,Math.min(o.digitCount,15))):0:2===i.type?Math.pow(10,$Fe(i)):0}return r}function uJ(e,t){ir.write(e,t),ir.newline(e)}function aT(e,t){ir.writeSafe(e,"\n;"+t),ir.writeSafe(e,"\n;\n")}function Yb(e,t,n){for(let r=0,i=n.length;r>>0&127;else if(o<2048)e[t++]=o>>>6&31|192,e[t++]=o>>>0&63|128;else if(o<65536)e[t++]=o>>>12&15|224,e[t++]=o>>>6&63|128,e[t++]=o>>>0&63|128;else{if(!(o<1114112))throw new Error("bad codepoint "+o);e[t++]=o>>>18&7|240,e[t++]=o>>>12&63|128,e[t++]=o>>>6&63|128,e[t++]=o>>>0&63|128}}}const rBe=function(){const e=[];for(let t=0;t<1024;t++)e[t]=String.fromCharCode(t);return e}();function lJ(e){throw new Error(e)}const dJ=typeof TextDecoder<"u"?new TextDecoder:void 0;function jB(e,t,n){if(dJ){const r=t||n!==e.length?e.subarray(t,t+n):e;return dJ.decode(r)}return function iBe(e,t,n){const r=rBe;let i,o=0;const s=[];for(let c=t,u=t+n;c0&&(i[i.length]=s.slice(0,o).join("")),i.join("")):s.slice(0,o).join("")}(e,t,n)}function cT(e){let t=0;for(let n=0,r=e.length;n=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("boolean"===t||null==e)return 1;if("object"===t){let n,r=0;if(Array.isArray(e)){n=e.length;for(let i=0;i=0){if(e<128)return t.setUint8(r,e),1;if(e<256)return t.setUint8(r,204),t.setUint8(r+1,e),2;if(e<65536)return t.setUint8(r,205),t.setUint16(r+1,e),3;if(e<4294967296)return t.setUint8(r,206),t.setUint32(r+1,e),5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return t.setInt8(r,e),1;if(e>=-128)return t.setUint8(r,208),t.setInt8(r+1,e),2;if(e>=-32768)return t.setUint8(r,209),t.setInt16(r+1,e),3;if(e>=-2147483648)return t.setUint8(r,210),t.setInt32(r+1,e),5;throw new Error("Number too small -0x"+(-e).toString(16).substr(1))}if(null==e)return t.setUint8(r,192),1;if("boolean"===i)return t.setUint8(r,e?195:194),1;if("object"===i){let o,s=0;const a=Array.isArray(e);let c;if(a?o=e.length:(c=Object.keys(e),o=c.length),o<16?(t.setUint8(r,o|(a?144:128)),s=1):o<65536?(t.setUint8(r,a?220:222),t.setUint16(r+1,o),s=3):o<4294967296&&(t.setUint8(r,a?221:223),t.setUint32(r+1,o),s=5),a)for(let u=0;ui.properties.chemicalComponentMap.has(o.comp_id.value(s)))},e.getEntriesFromChemCompBond=function n(i){const o=new Map;function s(h){if(o.has(h))return o.get(h);const g=new r(h);return o.set(h,g),g}const{comp_id:a,atom_id_1:c,atom_id_2:u,value_order:l,pdbx_aromatic_flag:d,_rowCount:f,pdbx_ordinal:p}=i;let m=s(a.value(0));for(let h=0;h=0)return!0;return!1}e.Descriptor={name:"struct_conn",cifExport:{prefix:"",categories:[{name:"struct_conn",instance(o){const s=e.Provider.get(o.firstModel);if(!s||0===s.entries.length)return Bi.Category.Empty;const a=o.structures[0],c=[];for(const u of s.entries)n(a,u.partnerA.atomIndex)&&n(a,u.partnerB.atomIndex)&&(c[c.length]=u.rowIndex);return Bi.Category.ofTable(s.data,c)}}]}},e.Provider=td.create(e.Descriptor),e.isExhaustive=function t(o){const s=e.Provider.get(o);return!!s&&s.data.id.rowCount/o.atomicConformation.atomId.rowCount>.95},e.getAtomIndexFromEntries=function r(o){const s=new Map;for(const a of o){const{partnerA:{atomIndex:c},partnerB:{atomIndex:u}}=a;s.has(c)?s.get(c).push(a):s.set(c,[a]),s.has(u)?s.get(u).push(a):s.set(u,[a])}return s},e.getEntriesFromStructConn=function i(o,s){const{conn_type_id:a,pdbx_dist_value:c,pdbx_value_order:u}=o,l={label_asym_id:o.ptnr1_label_asym_id,label_seq_id:o.ptnr1_label_seq_id,auth_seq_id:o.ptnr1_auth_seq_id,label_atom_id:o.ptnr1_label_atom_id,label_alt_id:o.pdbx_ptnr1_label_alt_id,ins_code:o.pdbx_ptnr1_PDB_ins_code,symmetry:o.ptnr1_symmetry},d={label_asym_id:o.ptnr2_label_asym_id,label_seq_id:o.ptnr2_label_seq_id,auth_seq_id:o.ptnr2_auth_seq_id,label_atom_id:o.ptnr2_label_atom_id,label_alt_id:o.pdbx_ptnr2_label_alt_id,ins_code:o.pdbx_ptnr2_PDB_ins_code,symmetry:o.ptnr2_symmetry},f=Array.from(s.entities.data.id.toArray()),p=(h,g)=>{if(0!==g.label_asym_id.valueKind(h))return;const y=g.label_asym_id.value(h),b=g.label_atom_id.value(h);if(!b)return;const x=g.auth_seq_id.valueKind(h)===te.ValueKind.Present?g.auth_seq_id.value(h):g.label_seq_id.value(h),_=g.ins_code.value(h),S=g.label_alt_id.value(h);for(const A of f){const E=s.atomicHierarchy.index.findResidue(A,y,x,_);if(E<0)continue;const w=s.atomicHierarchy.index.findAtomOnResidue(E,b,S);if(!(w<0))return{residueIndex:E,atomIndex:w,symmetry:g.symmetry.value(h)}}},m=[];for(let h=0;hMs.Provider.get(o)),i=e.models.some(o=>du.isExhaustive(o));return t.noCompute||e.isCoarseGrained&&!r&&!i||Ve.eachUnitPair(e,(o,s)=>{!function wBe(e,t,n,r){const{maxRadius:i}=n,{elements:o,residueIndex:s}=e,{x:a,y:c,z:u}=e.model.atomicConformation,{elements:l,residueIndex:d}=t,f=e.elements.length,{type_symbol:p,label_alt_id:m,label_atom_id:h,label_comp_id:g}=e.model.atomicHierarchy.atoms,{type_symbol:y,label_alt_id:b,label_atom_id:x,label_comp_id:_}=t.model.atomicHierarchy.atoms,{auth_seq_id:S}=e.model.atomicHierarchy.residues,{auth_seq_id:A}=t.model.atomicHierarchy.residues,{occupancy:E}=e.model.atomicConformation,{occupancy:w}=t.model.atomicConformation,D=E.isDefined&&w.isDefined,I=e.model===t.model&&du.Provider.get(e.model),R=!n.forceCompute&&e.model===t.model&&Ms.Provider.get(e.model),{atomSourceIndex:T}=e.model.atomicHierarchy,{invertedIndex:M}=R?sn.getInvertedAtomSourceIndex(t.model):{invertedIndex:void 0},N=e.model===t.model&&du.isExhaustive(e.model),V=le.mul(CBe,t.conformation.operator.inverse,e.conformation.operator.matrix),F=!le.isIdentity(V),{center:G,radius:L}=t.boundary.sphere,z=(L+i)*(L+i);r.startUnitPair(e.id,t.id);const j=e.conformation.operator.key,Z=t.conformation.operator.key;for(let $=0;$z)continue;if(!n.forceCompute&&R){const{maxDistance:K}=R,{offset:ne,b:de,edgeProps:{order:we,distance:Le,flag:We,key:U,operatorA:Y,operatorB:ge}}=R.bonds,Se=T.value(ee),Re=Qd(p.value(ee));for(let Ne=ne[Se],Ge=ne[Se+1];Ne=0&&ke!==j&&ke!==Z||Xe>=0&&Xe!==Z&&Xe!==j)continue;const ot=Qd(p.value($e)),_t=Le[Ne],ut=yJ(e,ee,t,$e);let Ct=!1;_t>=0?Ct=ai(ut,_t,.3):K>=0?Ct=uti||(r.add($,We,{order:ne.order,flag:ne.flags,key:ne.rowIndex}),K=!0)}if(K)continue}if(N)continue;const O=E.value(ee),{lookup3d:H}=t,{indices:W,count:Q,squaredDistances:fe}=H.find(Vg[0],Vg[1],Vg[2],i);if(0===Q)continue;const X=Qd(p.value(ee)),J=dp(X),ce=Xh(X),be=m.value(ee),ae=d2.has(X),me=h.value(ee),oe=g.value(s[ee]);for(let K=0;Kt.validUnit(o),validUnitPair:(o,s)=>t.validUnitPair(e,o,s)}),new l2(n.getMap())}(e,{...n,validUnit:t&&t.validUnit||(r=>Ee.isAtomic(r)),validUnitPair:t&&t.validUnitPair||((r,i,o)=>{if(!Ve.validUnitPair(r,i,o))return!1;const a=i.model.atomicHierarchy.derived.residue.moleculeType,c=o.model.atomicHierarchy.derived.residue.moleculeType,u=!(Ee.isAtomic(i)&&2===a[i.residueIndex[i.elements[0]]]||Ee.isAtomic(o)&&2===c[o.residueIndex[o.elements[0]]]),l=!Ee.isAtomic(i)||3!==a[i.residueIndex[i.elements[0]]],d=!Ee.isAtomic(o)||3!==c[o.residueIndex[o.elements[0]]];return!(!u&&n.ignoreWater||(!l||!d)&&n.ignoreIon)||function DBe(e,t){if(e.model!==t.model||!Ee.isAtomic(e)||!Ee.isAtomic(t))return!1;const n=du.Provider.get(e.model);if(!n)return!1;const r=e.elements.length=t.elements.length?e:t,{elements:o}=r,{elements:s}=i,{indexOf:a}=je;for(let c=0,u=o.length;c=0)return!0}return!1}(i,o)})})}var Lt;function bJ(e){e.count=e.endVertex-e.startVertex;const{isRingAtom:t,pred:n,color:r,depth:i,marked:o}=e;for(let s=0;s=0;y--)h[g++]=e.startVertex+a[y],r[a[y]]=1;Ou(h);for(let y=0,b=e.currentRings.length;yx.length&&je.isSubset(h,x))return!1}return e.currentRings.push(je.ofSortedArray(h)),!0}function xJ(e,t,n){const{bonds:r,startVertex:i,endVertex:o,isRingAtom:s,marked:a,queue:c,pred:u,depth:l}=e,{elements:d}=e.unit,{b:f,edgeProps:{flags:p},offset:m}=r;a[t]=n,l[t]=0,c[0]=t;let h=0,g=1;for(;h=o||!jn.isCovalent(p[A]))continue;if(e.hasAltLoc){const I=e.altLoc.value(d[E]);if(I&&e.currentAltLoc!==I)continue}const w=E-i;if(a[w]===n){if(u[w]!==y&&u[y]!==w&&kBe(e,y,w,s))return n+1;continue}const D=Math.min(l[w],b+1);D>5||(l[w]=D,a[w]=n,c[g++]=w,u[w]=y)}}return n+1}function SJ(e){const t=e.length,n=new Int32Array(2*t);for(let s=0;s{const _=y.unitMap.get(x.aUnit.id);if(!_)return;const S=y.unitMap.get(x.bUnit.id);if(!S)return;const E=je.indexOf(_.elements,x.aUnit.elements[x.aIndex]);if(-1===E)return;const D=je.indexOf(S.elements,x.bUnit.elements[x.bIndex]);-1!==D&&b.push(t(g.structure,_,E,g.structure,S,D))}),i(y,b)},e.toStructureElementLoci=function u(g){const y=[],b=new Map;for(const x of g.bonds){const{aIndex:_,aUnit:S,bIndex:A,bUnit:E}=x;S===E?b.has(S.id)?b.get(S.id).push(_,A):b.set(S.id,[_,A]):(b.has(S.id)?b.get(S.id).push(_):b.set(S.id,[_]),b.has(E.id)?b.get(E.id).push(A):b.set(E.id,[A]))}return b.forEach((x,_)=>{y.push({unit:g.structure.unitMap.get(_),indices:je.deduplicate(je.ofUnsortedArray(x))})}),De(g.structure,y)},e.toFirstStructureElementLoci=function l(g){const{aUnit:y,aIndex:b}=g.bonds[0];return De(g.structure,[{unit:y,indices:Fe.ofSingleton(b)}])},e.getType=function d(g,y){if(y.aUnit===y.bUnit){const b=y.aUnit.bonds,x=b.getEdgeIndex(y.aIndex,y.bIndex);return jn.create(x<0?0:b.edgeProps.flags[x])}{const b=g.interUnitBonds.getBondFromLocation(y);return jn.create(b?b.props.flag:0)}},e.getOrder=function f(g,y){if(y.aUnit===y.bUnit){const b=y.aUnit.bonds,x=b.getEdgeIndex(y.aIndex,y.bIndex);return x<0?0:b.edgeProps.order[x]}{const b=g.interUnitBonds.getBondFromLocation(y);return b?b.props.order:0}},e.getIntraUnitBondCount=function p(g){let y=0;for(let b=0,x=g.units.length;b{const{aUnit:S,aIndex:A,bUnit:E,bIndex:w}=g.bonds[b];S.conformation.position(S.elements[A],x),E.conformation.position(E.elements[w],_)},y)}}(Lt||(Lt={}));const OBe=new Set;function Qh(e,t){const n=WNe[e];if(void 0!==n){const r=n[t];if(void 0!==r)return r}return OBe}const wJ=v.zero();function AJ(e,t){const n=e.conformation,r=new Float32Array(3*t.length),{elements:i}=e;for(let o=0,s=t.length;o=y||i.addEdge(c,y)}}}const o=Dc.connectedComponents(i.getGraph()),s=o.componentIndex,a=[];for(let c=0;c=0&&(n.has(a)?n.get(a).push(s):n.set(a,[s]))}}(function(e){function n(a){return function NBe(e){const t=e.length,n=new Array(t);for(let s=0;s0)return!1;const y=nd.calculateMomentsAxes(AJ(a,c));return v.magnitude(y.dirC)<.05},e.getAltId=function s(a,c){const{label_alt_id:u}=a.model.atomicHierarchy.atoms,{elements:l}=a;for(let d=0,f=c.length;dFe.max(S)||o(_)this.maxDist[t]&&(this.maxDist[t]=r,EJ(this.extrema[2*t+1],n))}computeSphereExtrema(t,n,r){const i=this.dir[t],o=DJ(i,n);o-rthis.maxDist[t]&&(this.maxDist[t]=o+r,KBe(this.extrema[2*t+1],n,i,r))}includeSphere(t){if(_e.hasExtrema(t)&&t.extrema.length>1)for(const n of t.extrema)this.includePosition(n);else this.includePositionRadius(t.center,t.radius)}includePosition(t){for(let n=0;n1)for(const n of t.extrema)this.radiusPosition(n);else this.radiusPositionRadius(t.center,t.radius)}radiusPosition(t){this.centroidHelper.radiusStep(t)}radiusPositionRadius(t,n){this.centroidHelper.radiusSphereStep(t,n)}getSphere(t){return _e.setExtrema(this.centroidHelper.getSphere(t),this.extrema.slice())}getBox(t){return St.fromVec3Array(t||St(),this.extrema)}reset(){for(let t=0;t{const r=v.create(n[0],n[1],n[2]);return v.normalize(r,r)})}(t),this.dirLength=this.dir.length,this.reset()}}const fT=[[1,0,0],[0,1,0],[0,0,1]],qB=[[1,1,1],[-1,1,1],[-1,-1,1],[1,-1,1]],PJ=[[1,1,0],[1,-1,0],[1,0,1],[1,0,-1],[0,1,1],[0,1,-1]],QBe=[[0,1,2],[0,2,1],[1,0,2],[2,0,1],[1,2,0],[2,1,0],[0,1,-2],[0,2,-1],[1,0,-2],[2,0,-1],[1,-2,0],[2,-1,0]],JBe=[[1,1,2],[2,1,1],[1,2,1],[1,-1,2],[1,1,-2],[1,-1,-2],[2,-1,1],[2,1,-1],[2,-1,-1],[1,-2,1],[1,2,-1],[1,-2,-1]],eOe=[[2,2,1],[1,2,2],[2,1,2],[2,-2,1],[2,2,-1],[2,-2,-1],[1,-2,2],[1,2,-2],[1,-2,-2],[2,-1,2],[2,1,-2],[2,-1,-2]],MJ=v.set,tOe=new fu("14"),nOe=new fu("98");function WB(e){const t=St.computeBounding(e);return{box:t,sphere:_e.fromBox3D(_e(),t)}}const pT=v();function pp(e){const{x:t,y:n,z:r,radius:i,indices:o}=e,s=Fe.size(o);if(s>25e4)return WB(e);const a=function rOe(e){return e>1e4?tOe:nOe}(s);a.reset();for(let u=0;u{const n=[];let r=0;for(let i=0;iZe.unit.operator_name(l.element),ui.DefaultName),Sr.pred.inSet(l=>Ze.chain.label_asym_id(l.element),o.asymIds))});n[n.length]={selector:u,operators:c,asymIds:o.asymIds},r+=c.length}return n}}(s,r))}function cOe(e){const t=[],n=[];for(let r=0;r{const s=[];o.split(",").forEach(a=>{const c=a.indexOf("-");if(c>0){const u=parseInt(a.substring(0,c)),l=parseInt(a.substr(c+1));for(let d=u;d<=l;d++)s[s.length]=d.toString()}else s[s.length]=a.trim()}),r[r.length]=s}),r}function hOe(e){if(0===e._rowCount)return;const{id:t,matrix:n,vector:r}=e,i=On.struct_ncs_oper.matrix.space,o=On.struct_ncs_oper.vector.space,s=[];for(let a=0;a{const h=c.length;c.push(je.ofUnsortedArray([f,p,m])),u.set(t2(f,p),m),l.has(f)?l.get(f).push(h):l.set(f,[h])};for(let f=0;f=2){d(f,m[0],m[1]);for(let h=1,g=m.length;hu.get(t2(f,p)),getTripletIndices:f=>l.get(f),triplets:c}}function kJ(){return{result:Xb.create(),closeUnitsResult:Uu.create(),unitGroupResult:Uu.create()}}!function(e){e.create=function t(n,r,i){return new e(n,r,i)}}(YB||(YB={})),function(e){e.Default={assemblies:[],spacegroup:Ec.ZeroP1,isNonStandardCrystalFrame:!1},e.findAssembly=function t(r,i){const o=i.toLocaleLowerCase(),s=no.Provider.get(r);return s?uB(s.assemblies,a=>a.id.toLowerCase()===o):void 0},e.getUnitcellLabel=function n(r){const{cell:i,name:o,num:s}=r.spacegroup,{size:a,anglesInRadians:c}=i,u=a[0].toFixed(2),l=a[1].toFixed(2),d=a[2].toFixed(2),f=su(c[0]).toFixed(2),p=su(c[1]).toFixed(2),m=su(c[2]).toFixed(2),h=[];return h.push(`Unit Cell ${o} #${s}`),h.push(`${u}\xd7${l}\xd7${d} \u212b`),h.push(`\u03b1=${f}\xb0 \u03b2=${p}\xb0 \u03b3=${m}\xb0`),h.join(" | ")}}(h2||(h2={})),function(e){e.Descriptor={name:"model_symmetry"},e.Provider=td.create(e.Descriptor),e.fromData=function t(r){const i=function iOe(e,t,n){if(!e._rowCount)return[];const r=function aOe(e){const{id:t,matrix:n,vector:r,_schema:i}=e,o=new Map,s=v();for(let a=0,c=e._rowCount;az[j]}(L=t=e.Kinds||(e.Kinds={}))[L.Atomic=0]="Atomic",L[L.Spheres=1]="Spheres",L[L.Gaussians=2]="Gaussians",e.isAtomic=function n(L){return 0===L.kind},e.isCoarse=function r(L){return 1===L.kind||2===L.kind},e.isSpheres=function i(L){return 1===L.kind},e.isGaussians=function o(L){return 2===L.kind},e.create=function s(L,z,j,Z,$,ee,q,O,H){switch($){case 0:return new y(L,z,j,Z,ee,O,ui.createMapping(q,ee.atomicConformation),H??{});case 1:return w(L,z,j,Z,ee,1,O,ui.createMapping(q,ee.coarseConformation.spheres,h(ee)),H??{});case 2:return w(L,z,j,Z,ee,2,O,ui.createMapping(q,ee.coarseConformation.gaussians,z=>0),H??{})}},e.SymmetryGroup=u,function(L){L.areInvariantElementsEqual=function z(Z,$){return Z.hashCode===$.hashCode&&je.areEqual(Z.elements,$.elements)},L.getUnitSymmetryGroupsIndexMap=function j(Z){const $=Lu.Mutable();for(let ee=0,q=Z.length;ee=M)continue;const N=je.indexOf(e.elements,M);if(N<0)continue;const V=f[R],F=p[R];if(V>=0&&V!==S||F>=0&&F!==S)continue;const G=Qd(r.value(M)),L=u[R],z=hBe(e,E,M);let j=!1;L>=0?j=ai(z,L,.3):o>=0?j=z1&&(N=!1)}}}return fJ(S,A,w,E,D,s,T||M&&N)}(e,n)}(this),z.set(this.elements,j)),this.props.bonds=j,this.props.bonds}get rings(){return this.props.rings||(this.props.rings=dT.create(this)),this.props.rings}get resonance(){return this.props.resonance||(this.props.resonance=function mOe(e){return{delocalizedTriplets:gOe(e)}}(this)),this.props.resonance}get polymerElements(){return this.props.polymerElements||(this.props.polymerElements=function GBe(e){const t=[],{elements:n,model:r}=e,{residueAtomSegments:i}=e.model.atomicHierarchy,{traceElementIndex:o}=r.atomicHierarchy.derived.residue,s=wr.transientSegments(e.model.atomicRanges.polymerRanges,n),a=en.transientSegments(i,n);for(;s.hasNext;){const c=s.move();for(a.setSegment(c);a.hasNext;){const u=a.move(),{start:l,end:d,index:f}=u;if(Fe.areIntersecting(Ce.ofRange(n[l],n[d-1]),n)){const p=o[f];t.push(-1===p?i.offsets[f]:p)}}}return je.ofSortedArray(t)}(this)),this.props.polymerElements}get gapElements(){return this.props.gapElements||(this.props.gapElements=function HBe(e){const t=[],{elements:n,model:r,residueIndex:i}=e,{residueAtomSegments:o}=e.model.atomicHierarchy,{traceElementIndex:s}=r.atomicHierarchy.derived.residue,a=wr.transientSegments(e.model.atomicRanges.gapRanges,e.elements);for(;a.hasNext;){const c=a.move(),u=i[n[c.start]],l=i[n[c.end-1]],d=s[u],f=s[l];t.push(-1===d?o.offsets[u]:d),t.push(-1===f?o.offsets[l]:f)}return je.ofSortedArray(t)}(this)),this.props.gapElements}get nucleotideElements(){return this.props.nucleotideElements||(this.props.nucleotideElements=function WBe(e){const t=[],{elements:n,model:r}=e,{chainAtomSegments:i,residueAtomSegments:o}=r.atomicHierarchy,{moleculeType:s,traceElementIndex:a}=r.atomicHierarchy.derived.residue,c=en.transientSegments(i,n),u=en.transientSegments(o,n);for(;c.hasNext;)for(u.setSegment(c.move());u.hasNext;){const{index:l}=u.move();if(Ya(s[l])){const d=a[l];t.push(-1===d?o.offsets[l]:d)}}return je.ofSortedArray(t)}(this)),this.props.nucleotideElements}get proteinElements(){return this.props.proteinElements||(this.props.proteinElements=function $Be(e){const t=[],{elements:n,model:r}=e,{chainAtomSegments:i,residueAtomSegments:o}=r.atomicHierarchy,{moleculeType:s,traceElementIndex:a}=r.atomicHierarchy.derived.residue,c=en.transientSegments(i,n),u=en.transientSegments(o,n);for(;c.hasNext;)for(u.setSegment(c.move());u.hasNext;){const{index:l}=u.move();if(ZQ(s[l])){const d=a[l];t.push(-1===d?o.offsets[l]:d)}}return je.ofSortedArray(t)}(this)),this.props.proteinElements}get residueCount(){if(void 0!==this.props.residueCount)return this.props.residueCount;let z=0;const j=en.transientSegments(this.model.atomicHierarchy.residueAtomSegments,this.elements);for(;j.hasNext;)j.move(),z+=1;return this.props.residueCount=z,this.props.residueCount}getResidueIndex(z){return this.residueIndex[this.elements[z]]}constructor(z,j,Z,$,ee,q,O,H){this.kind=0,this.objectPrimitive="atomistic",this.id=z,this.invariantId=j,this.chainGroupId=Z,this.traits=$,this.model=ee,this.elements=q,this.conformation=O,this.residueIndex=ee.atomicHierarchy.residueAtomSegments.index,this.chainIndex=ee.atomicHierarchy.chainAtomSegments.index,this.props=H}}e.Atomic=y;class x{getChild(z){return z.length===this.elements.length?this:w(this.id,this.invariantId,this.chainGroupId,this.traits,this.model,this.kind,z,this.conformation,{})}applyOperator(z,j,Z=!1){const $=Z?j:ui.compose(this.conformation.operator,j);return w(z,this.invariantId,this.chainGroupId,this.traits,this.model,this.kind,this.elements,ui.createMapping($,this.getCoarseConformation(),this.conformation.r),this.props)}remapModel(z,j,Z){const $=this.getCoarseConformation(),ee=_(this.kind,z);Z||(Z={...this.props},e.isSameConformation(this,z)||(Z.boundary=void 0,Z.lookup3d=void 0,Z.principalAxes=void 0));const q=$!==ee?ui.createMapping(this.conformation.operator,ee,1===this.kind?h(z):z=>0):this.conformation;return new x(this.id,this.invariantId,this.chainGroupId,this.traits,z,this.kind,this.elements,q,Z)}get boundary(){if(this.props.boundary)return this.props.boundary;const{x:z,y:j,z:Z}=this.getCoarseConformation();return this.props.boundary=p.is(this.traits,f.FastBoundary)?WB({x:z,y:j,z:Z,indices:this.elements}):pp({x:z,y:j,z:Z,indices:this.elements}),this.props.boundary}get lookup3d(){if(this.props.lookup3d)return this.props.lookup3d;const{x:z,y:j,z:Z}=this.getCoarseConformation();return this.props.lookup3d=rd({x:z,y:j,z:Z,indices:this.elements},this.boundary),this.props.lookup3d}get principalAxes(){return this.props.principalAxes||(this.props.principalAxes=TJ(this)),this.props.principalAxes}get polymerElements(){return this.props.polymerElements||(this.props.polymerElements=function jBe(e){const t=[],{elements:n,model:r}=e,{spheres:i,gaussians:o}=r.coarseHierarchy,s=Ee.isSpheres(e)?i.polymerRanges:o.polymerRanges,a=wr.transientSegments(s,n);for(;a.hasNext;){const{start:c,end:u}=a.move();for(let l=c;l(u+=c[p].elements.length)>=i,o.closeUnitsResult);if(0===l.count)return s;let d=0,f=-Number.MAX_VALUE;for(let p=0,m=l.count;p=i&&fs||c.addElement(b[y.indices[x]])}c.commitUnit()}}check(t,n,r,i){const{units:o}=this.structure,s=this.unitLookup.find(t,n,r,i);if(0===s.count)return!1;for(let a=0,c=s.count;a0&&(i[i.length]=a.getChild(u))}return Ve.create(i,{parent:e.parent||t.parent})}function KB(e){return jn.isCovalent(e.atomicBond.type)}function _Oe(){return function(t){const{inputStructure:n}=t,r=nt.create(n),i=[];for(const o of n.units){if(0!==o.kind)continue;r.unit=o;const s=o.elements;if(r.element=s[0],"polymer"!==Ze.entity.type(r))continue;const a=en.transientSegments(o.model.atomicHierarchy.residueAtomSegments,s);let c=0;for(;a.hasNext;)c++,a.move();c<8||i.push(o)}return pt.Singletons(n,Ve.create(i,{parent:n}))}}function xOe(){return function(t){const{inputStructure:n}=t,r=nt.create(n),i=[];for(const o of n.units)0===o.kind&&(r.unit=o,r.element=o.elements[0],"water"===Ze.entity.type(r)&&i.push(o));return pt.Singletons(n,Ve.create(i,{parent:n}))}}function SOe(){return function(t){const{inputStructure:n}=t,r=nt.create(n),i=[];for(const o of n.units){if(0!==o.kind)continue;r.unit=o;const s=o.elements;if(r.element=s[0],"water"!==Ze.entity.type(r)){if("polymer"===Ze.entity.type(r)){const a=en.transientSegments(o.model.atomicHierarchy.residueAtomSegments,s);let c=0;for(;a.hasNext;)c++,a.move();if(c>=8)continue}i.push(o)}}return pt.Singletons(n,Ve.create(i,{parent:n}))}}function COe(){return function(t){const{inputStructure:n}=t,r=[];for(const i of n.units)1===i.kind&&r.push(i);return pt.Singletons(n,Ve.create(r,{parent:n}))}}function FJ(e,t,n){return{groupedUnits:e,ranges:t,set:n}}function BJ(e){return function(n){return pt.Sequence(n.inputStructure,[Kn.toStructure({hash:n.inputStructure.hashCode,elements:e},n.inputStructure)])}}!function(e){function t(y,b){return{kind:"singletons",source:y,structure:b}}function n(y,b){return{kind:"sequence",source:y,structures:b}}function r(y){return t(y,Ve.Empty)}function i(y){return"singletons"===y.kind}function o(y){return i(y)?0===y.structure.units.length:0===y.structures.length}function a(y){return o(y)?Ve.Empty:i(y)?y.structure:m2(y.source,y.structures)}function l(y,b,x){return 0===b.length?r(y):x?t(y,m2(y,b)):n(y,b)}e.Singletons=t,e.Sequence=n,e.Empty=r,e.isSingleton=i,e.isEmpty=o,e.structureCount=function s(y){return i(y)?y.structure.elementCount:y.structures.length},e.unionStructure=a,e.toLociWithCurrentUnits=function c(y){const b=[],{unitMap:x}=y.source;for(const _ of a(y).units)b[b.length]=_===x.get(_.id)?{unit:_,indices:Fe.ofBounds(0,_.elements.length)}:{unit:_,indices:Fe.ofSortedArray(je.indicesOf(x.get(_.id).elements,_.elements))};return De(y.source,b)},e.toLociWithSourceUnits=function u(y){const b=[],{unitMap:x}=y.source;for(const _ of a(y).units){const S=x.get(_.id);b[b.length]=S===_?{unit:S,indices:Fe.ofBounds(0,S.elements.length)}:{unit:S,indices:Fe.ofSortedArray(je.indicesOf(S.elements,_.elements))}}return De(y.source,b)};class d{add(b){const x=b.elementCount;0!==x&&(this.structures[this.structures.length]=b,1!==x&&(this.allSingletons=!1))}getSelection(){return l(this.source,this.structures,this.allSingletons)}constructor(b){this.source=b,this.structures=[],this.allSingletons=!0}}class f{add(b){const x=b.elementCount;0===x||!this.uniqueSets.add(b)||(this.structures[this.structures.length]=b,1!==x&&(this.allSingletons=!1))}getSelection(){return l(this.structure,this.structures,this.allSingletons)}constructor(b){this.structure=b,this.structures=[],this.allSingletons=!0,this.uniqueSets=wB(Ve.hashCode,Ve.areUnitIdsAndIndicesEqual)}}e.LinearBuilder=function p(y){return new d(y)},e.UniqueBuilder=function m(y){return new f(y)},e.forEach=function h(y,b){let x=0;if(e.isSingleton(y))for(const _ of y.structure.units){const{elements:S}=_;for(let A=0,E=S.length;A2)y.push(g[S],g[A-1]);else for(let E=S;E{const h=[];m.groupedUnits.forEach(g=>h.push(je.ofUnsortedArray(g))),h.sort((g,y)=>g[0]-y[0]),p.push({groupedUnits:h,set:m.set,ranges:m.ranges})}),{hash:l.structure.hashCode,elements:p}}function i(l,d){const f=[];for(let p=0,m=l.length;pue.core.type.list(d))),ranges:ue.core.type.list(l.ranges),set:ue.core.type.list(l.set)})}e.Empty={hash:-1,elements:[]},e.fromSubStructure=function t(l,d){return r(pt.toLociWithSourceUnits(pt.Singletons(l,d)))},e.fromSelection=function n(l){return r(pt.toLociWithSourceUnits(l))},e.fromLoci=r,e.toLoci=function o(l,d){-1!==l.hash&&l.hash!==d.hashCode&&new Error("Bundle not compatible with given structure");const f=[];for(const p of l.elements)for(const m of p.groupedUnits){const h=i(m,d);if(0===h.length)continue;let g;if(0===p.ranges.length)g=p.set;else if(0===p.set.length)if(2===p.ranges.length)g=Ce.ofRange(p.ranges[0],p.ranges[1]);else{const y=new Int32Array(wr.size(p.ranges));wr.forEach(p.ranges,(b,x)=>y[x]=b),g=je.ofSortedArray(y)}else{const y=wr.size(p.ranges),b=new Int32Array(p.set.length+y);wr.forEach(p.ranges,(x,_)=>b[_]=x),b.set(p.set,y),g=je.ofUnsortedArray(b)}for(const y of h)f.push({unit:y,indices:g})}return De(d,f)},e.toStructure=function s(l,d){-1!==l.hash&&l.hash!==d.hashCode&&new Error("Bundle not compatible with given structure");const f=[];for(const p of l.elements)for(const m of p.groupedUnits){const h=i(m,d);if(0===h.length)continue;const g=h[0].elements,y=wr.size(p.ranges),b=p.set.length,x=new Int32Array(b+y);let _;if(0===y){for(let S=0,A=b;Sx[A]=g[S]),_=je.ofSortedArray(x);else if(je.min(p.set)>wr.max(p.ranges)){wr.forEach(p.ranges,(S,A)=>x[A]=g[S]);for(let S=0,A=b;Sje.max(p.set)){for(let S=0,A=b;Sx[A+b]=g[S]),_=je.ofSortedArray(x)}else{wr.forEach(p.ranges,(S,A)=>x[A]=g[S]);for(let S=0,A=b;S0?this.currentAtomicBondStack.pop():void 0}pushCurrentStructure(){this.currentStructure&&this.currentStructureStack.push(this.currentStructure)}popCurrentStructure(){this.currentStructure=this.currentStructureStack.length?this.currentStructureStack.pop():void 0}pushInputStructure(t){this.inputStructureStack.push(this.inputStructure),this.inputStructure=t}popInputStructure(){if(0===this.inputStructureStack.length)throw new Error("Must push before pop.");this.inputStructure=this.inputStructureStack.pop()}throwIfTimedOut(){if(0!==this.timeoutMs&&yi()-this.timeCreated>this.timeoutMs)throw new Error(`The query took too long to execute (> ${this.timeoutMs/1e3}s).`)}tryGetCurrentSelection(){if(!this.currentSelection)throw new Error("The current selection is not assigned.");return this.currentSelection}constructor(t,n){this.currentElementStack=[],this.currentAtomicBondStack=[],this.currentStructureStack=[],this.inputStructureStack=[],this.timeCreated=yi(),this.element=nt.create(void 0),this.currentStructure=void 0,this.atomicBond=new OJ,this.currentSelection=void 0,this.inputStructure=t,this.timeoutMs=n&&n.timeoutMs||0,this.currentSelection=n&&n.currentSelection}}class OJ{constructor(){this.a=nt.create(void 0),this.aIndex=0,this.b=nt.create(void 0),this.bIndex=0,this.type=0,this.order=0,this.key=-1,this.testFn=KB}setStructure(t){this.a.structure=t,this.b.structure=t}setTestFn(t){this.testFn=t||KB}test(t,n){return!!this.testFn(t)||!!n&&(this.swap(),this.testFn(t))}swap(){const t=this.aIndex;this.aIndex=this.bIndex,this.bIndex=t;const n=this.a.unit;this.a.unit=this.b.unit,this.b.unit=n;const r=this.a.element;this.a.element=this.b.element,this.b.element=r}get length(){return nt.distance(this.a,this.b)}}!function(e){e.run=function t(n,r,i){return n(new qu(r,i))}}(LJ||(LJ={}));class ZB{add(t){t.elementCount&&(1!==t.elementCount&&(this.allSingletons=!1),this.set.add(t)&&(this.structures[this.structures.length]=t))}getSelection(){return this.allSingletons?pt.Singletons(this.source,m2(this.source,this.structures)):pt.Sequence(this.source,this.structures)}constructor(t){this.source=t,this.set=wB(Ve.hashCode,Ve.areUnitIdsAndIndicesEqual),this.structures=[],this.allSingletons=!0}}class wOe{add(t,n,r){let i=this.builderMap.get(t);i||(i=this.source.subsetBuilder(!0),this.builders[this.builders.length]=i,this.builderMap.set(t,i)),i.addToUnit(n,r)}allSingletons(){for(let t=0,n=this.builders.length;t1)return!1;return!0}singletonSelection(){const t=this.source.subsetBuilder(!0),n=nt.create(this.source);for(let r=0,i=this.builders.length;rpt.Sequence(e.inputStructure,[]),UJ=e=>pt.Singletons(e.inputStructure,e.inputStructure);function AOe(e){return JB({...e,groupBy:t=>Ze.residue.key(t.element)})}function IOe(e){return JB({...e,groupBy:t=>Ze.chain.key(t.element)})}function Jh(e){return!0}function TOe(e){return 0}function JB(e){if(!e||!(e.atomTest||e.residueTest||e.chainTest||e.entityTest||e.unitTest||e.groupBy))return UJ;if(e.atomTest&&!e.residueTest&&!e.chainTest&&!e.entityTest&&!e.unitTest&&!e.groupBy)return function DOe(e){return function(n){const{inputStructure:r}=n,{units:i}=r,o=n.pushCurrentElement(),s=r.subsetBuilder(!0);o.structure=r;for(const a of i){o.unit=a;const c=a.elements;s.beginUnit(a.id);for(let u=0,l=c.length;u0?kr.create():this.currentUnit}addElement(t){kr.add(this.currentUnit,t,t)&&this.elementCount++}commitUnit(){0===this.currentUnit.array.length||this.unitMap.has(this.parentId)||(this.ids[this.ids.length]=this.parentId,this.unitMap.set(this.parentId,this.currentUnit),this.parentId=-1)}getStructure(){if(this.isEmpty)return Ve.Empty;const t=[];Ou(this.ids);const n=nf.UnitEquivalenceBuilder();for(let r=0,i=this.ids.length;r1&&Ou(a);let u=s.getChild(je.ofSortedArray(a));const l=n.add(u.id,u);u!==l&&(u=l.applyOperator(u.id,u.conformation.operator,!0)),t[t.length]=u}return Ve.create(t,{parent:this.parent})}get isEmpty(){return 0===this.elementCount}constructor(t){this.parent=t,this.ids=[],this.unitMap=Lu.Mutable(),this.parentId=-1,this.currentUnit=kr.create(),this.elementCount=0}}function ht(e){return{data:e,position:0,length:e.length,lineNumber:1,tokenStart:0,tokenEnd:0}}var He,Fr;function VJ(e){for(;e.position=e.length)return void(e.tokenType=6);e.tokenStart=e.position,e.tokenEnd=e.position,e.isEscaped=!1;const n=e.data.charCodeAt(e.position);switch(n){case 35:(function UOe(e){for(;e.position=5&&95===e.data.charCodeAt(e.tokenStart+4)?function zOe(e){let t=e.data.charCodeAt(e.tokenStart);return!(68!==t&&100!==t||(t=e.data.charCodeAt(e.tokenStart+1),65!==t&&97!==t)||(t=e.data.charCodeAt(e.tokenStart+2),84!==t&&116!==t)||(t=e.data.charCodeAt(e.tokenStart+3),65!==t&&97!==t))}(e)?0:function GOe(e){let t=e.data.charCodeAt(e.tokenStart);return!(83!==t&&115!==t||(t=e.data.charCodeAt(e.tokenStart+1),65!==t&&97!==t)||(t=e.data.charCodeAt(e.tokenStart+2),86!==t&&118!==t)||(t=e.data.charCodeAt(e.tokenStart+3),69!==t&&101!==t))}(e)?1:function jOe(e){if(e.tokenEnd-e.tokenStart!=5)return!1;let t=e.data.charCodeAt(e.tokenStart);return!(76!==t&&108!==t||(t=e.data.charCodeAt(e.tokenStart+1),79!==t&&111!==t)||(t=e.data.charCodeAt(e.tokenStart+2),79!==t&&111!==t)||(t=e.data.charCodeAt(e.tokenStart+3),80!==t&&112!==t))}(e)?2:3:3}}function em(e){for(HJ(e);5===e.tokenType;)HJ(e)}function gT(){return{categoryNames:[],categoryData:Object.create(null)}}function nO(e,t){const n=Object.create(null);for(const r of e){const i=t[r];n[r]=ss(i.name,i.rowCount,i.fieldNames,i.fields)}return n}function qJ(e,t,n){return vB(e.categoryNames,nO(e.categoryNames,e.categoryData),t,n)}function YOe(e,t){return vB(e.categoryNames,nO(e.categoryNames,e.categoryData),t)}function rO(e,t,n,r,i){if(t in e.categoryData){const o=e.categoryData[t];o.fieldNames.push(...r),Object.assign(o.fields,i)}else e.categoryData[t]={name:t,rowCount:n,fieldNames:r,fields:i},e.categoryNames.push(t)}function XOe(e,t){const n=e.tokenStart,r=GJ(e),i=jJ(e,r),o=Object.create(null),s=[];let a=!0;for(;a;){if(4!==e.tokenType||!qOe(e,n,r)){a=!1;break}const c=tO(e).substring(i.length+1);if(em(e),3!==e.tokenType)return{hasError:!0,errorLine:e.lineNumber,errorMessage:"Expected value."};o[c]=ft.ofTokens({data:e.data,indices:[e.tokenStart,e.tokenEnd],count:1}),s[s.length]=c,em(e)}return rO(t,i.substr(1),1,s,o),{hasError:!1,errorLine:0,errorMessage:""}}function KOe(e,t){const{tokenizer:n,tokens:r,fieldCount:i}=t;let o=t.tokenCount,s=0;for(;3===n.tokenType&&s0&&n.push(qJ(o,i,s)),i=e.substring(r.tokenStart+5,r.tokenEnd),o=gT(),s=[],em(r)}else if(1===l){if(r.tokenEnd-r.tokenStart==5)a.categoryNames.length>0&&(s[s.length]=YOe(a,u)),r.inSaveFrame=!1;else{if(r.inSaveFrame)return Kb(r.lineNumber,"Save frames cannot be nested.");r.inSaveFrame=!0,u=e.substring(r.tokenStart+5,r.tokenEnd),a=gT()}em(r)}else if(2===l){const d=yield QOe(r,r.inSaveFrame?a:o);if(d.hasError)return Kb(d.errorLine,d.errorMessage)}else{if(4!==l)return console.log(r.tokenType,ht.getTokenString(r)),Kb(r.lineNumber,"Unexpected token. Expected data_, loop_, or data name.");{const d=XOe(r,r.inSaveFrame?a:o);if(d.hasError)return Kb(d.errorLine,d.errorMessage)}}}return r.inSaveFrame?Kb(r.lineNumber,`Unfinished save frame (${c.header}).`):((o.categoryNames.length>0||s.length>0)&&n.push(qJ(o,i,s)),function JOe(e){return Fr.success(e)}(bQ(n)))}),oO.apply(this,arguments)}function WJ(e){return Oe.create("Parse CIF",function(){var t=ie(function*(n){return yield function e4e(e,t){return oO.apply(this,arguments)}(e,n)});return function(n){return t.apply(this,arguments)}}())}function $J(e){return bT({buffer:e,offset:0,dataView:new DataView(e.buffer)})}function sO(e,t){const n={};for(let r=0;rr.name),getField(r){const i=t[r];if(i)return n[r]||(n[r]=function t4e(e){const t=e.mask?oT(e.mask):void 0,n=oT(e.data),r=$F(n),i=r?t?u=>0===t[u]?""+n[u]:"":u=>""+n[u]:t?u=>0===t[u]?n[u]:"":u=>n[u],o=r?u=>n[u]:u=>{const l=n[u];return jh(l,0,l.length)},s=r?u=>n[u]:u=>{const l=n[u];return rp(l,0,l.length)},c=n.length;return{__array:n,binaryEncoding:e.data.encoding,isDefined:!0,rowCount:c,str:i,int:o,float:s,valueKind:t?u=>t[u]:u=>0,areValuesEqual:(u,l)=>n[u]===n[l],toStringArray:u=>Ps(c,i,u),toIntArray:r?u=>RI(n,u):u=>Ps(c,o,u),toFloatArray:r?u=>RI(n,u):u=>Ps(c,s,u)}}(i)),n[r]}}}function YJ(e){return Oe.create("Parse BinaryCIF",function(){var t=ie(function*(n){const r=[0,3];try{const i=$J(e);if(!function n4e(e,t){for(let n=0;n<2;n++)if(e[n]>t[n])return!1;return!0}(r,i.version.match(/(\d)\.(\d)\.\d/).slice(1).map(s=>+s)))return Fr.error(`Unsupported format version. Current ${i.version}, required ${r.join(".")}.`);const o=bQ(i.dataBlocks.map(s=>{const a=Object.create(null);for(const c of s.categories)a[c.name.substr(1)]=r4e(c);return vB(s.categories.map(c=>c.name.substr(1)),a,s.header)}));return Fr.success(o)}catch(i){return Fr.error(""+i)}});return function(n){return t.apply(this,arguments)}}())}!function(e){function t(_){return _.data.substring(_.tokenStart,_.tokenEnd)}function r(_){const{data:S}=_;for(;_.position<_.length;)switch(S.charCodeAt(_.position)){case 10:return _.tokenEnd=_.position,++_.position,++_.lineNumber,!0;case 13:return _.tokenEnd=_.position,++_.position,++_.lineNumber,10===S.charCodeAt(_.position)&&++_.position,!0;default:++_.position}return _.tokenEnd=_.position,_.tokenStart!==_.tokenEnd}function o(_){return _.tokenStart=_.position,r(_)}function c(_,S,A){let E=0;for(let w=0;w{const T=Math.min(S-D,I);return c(R,T,w),D+=T,T},(I,R)=>I.update({message:"Parsing...",current:R.position,max:R.length})),w})).apply(this,arguments)}function g(){return(g=ie(function*(_,S,A=1e5){const E=e(_),w=He.create(E.data,Math.max(_.length/80,2));return yield op(S,A,E,(D,I)=>(function m(_,S,A){let E=0;for(let w=0;wD.update({message:"Parsing...",current:I.position,max:I.length})),w})).apply(this,arguments)}function x(_,S,A){const{data:E}=_;let w=S,D=A-1,I=E.charCodeAt(w);for(;(9===I||32===I)&&w<=D;)I=E.charCodeAt(++w);for(I=E.charCodeAt(D);(9===I||32===I)&&D>=w;)I=E.charCodeAt(--D);return _.tokenStart=w,_.tokenEnd=D+1,_.position=A,_}e.getTokenString=t,e.reset=function n(_){_.position=0,_.lineNumber=1,_.tokenStart=0,_.tokenEnd=0},e.eatLine=r,e.markStart=function i(_){_.tokenStart=_.position},e.markLine=o,e.readLine=function s(_){return o(_),t(_)},e.readLineTrim=function a(_){o(_);const S=_.position;return x(_,_.tokenStart,_.tokenEnd),_.position=S,t(_)},e.markLines=function u(_,S){const A=He.create(_.data,2*S);return c(_,S,A),A},e.readLines=function l(_,S){const A=[];for(let E=0;Eu.indicesLenMinus2&&function t(s){const a=new Uint32Array(1.61*s.indices.length|0);a.set(s.indices),s.indices=a,s.indicesLenMinus2=a.length-2|0}(u),u.indices[u.offset++]=a,u.indices[u.offset++]=c,s.count++}e.add=n,e.addToken=function r(s,a){n(s,a.tokenStart,a.tokenEnd)},e.addUnchecked=function i(s,a,c){s.indices[s.offset++]=a,s.indices[s.offset++]=c,s.count++},e.create=function o(s,a){return{data:s,indicesLenMinus2:(a=Math.max(10,a))-2|0,count:0,offset:0,indices:new Uint32Array(a)}}}(He||(He={})),function(e){e.error=function t(o,s=-1){return new r(o,s)},e.success=function n(o,s=[]){return new i(o,s)};class r{toString(){return this.line>=0?`[Line ${this.line}] ${this.message}`:this.message}constructor(s,a){this.message=s,this.line=a,this.isError=!0}}e.Error=r;class i{constructor(s,a){this.result=s,this.warnings=a,this.isError=!1}}e.Success=i}(Fr||(Fr={}));var zg=te.Schema;const qr=zg.str,XJ=zg.List,Jd=zg.lstr,pu=zg.Aliased,g2=zg.int,Zb=zg.coord,o4e={chem_comp:{formula:qr,formula_weight:zg.float,id:qr,mon_nstd_parent_comp_id:XJ(",",e=>e),name:qr,one_letter_code:qr,three_letter_code:qr,type:pu(Jd),pdbx_synonyms:XJ(";",e=>e),pdbx_type:qr,pdbx_ambiguous_flag:qr,pdbx_replaced_by:qr,pdbx_replaces:qr,pdbx_formal_charge:g2,pdbx_model_coordinates_details:qr,pdbx_model_coordinates_db_code:qr,pdbx_ideal_coordinates_details:qr,pdbx_ideal_coordinates_missing_flag:pu(Jd),pdbx_model_coordinates_missing_flag:pu(Jd),pdbx_initial_date:qr,pdbx_modified_date:qr,pdbx_release_status:pu(qr),pdbx_processing_site:pu(qr)},chem_comp_atom:{alt_atom_id:qr,atom_id:qr,charge:g2,model_Cartn_x:Zb,model_Cartn_y:Zb,model_Cartn_z:Zb,comp_id:qr,type_symbol:qr,pdbx_align:g2,pdbx_ordinal:g2,pdbx_model_Cartn_x_ideal:Zb,pdbx_model_Cartn_y_ideal:Zb,pdbx_model_Cartn_z_ideal:Zb,pdbx_stereo_config:pu(Jd),pdbx_aromatic_flag:pu(Jd),pdbx_leaving_atom_flag:pu(Jd)},chem_comp_bond:{atom_id_1:qr,atom_id_2:qr,comp_id:qr,value_order:pu(Jd),pdbx_ordinal:g2,pdbx_stereo_config:pu(Jd),pdbx_aromatic_flag:pu(Jd)},pdbx_chem_comp_descriptor:{comp_id:qr,descriptor:qr,type:pu(Jd),program:qr,program_version:qr},pdbx_chem_comp_identifier:{comp_id:qr,identifier:qr,type:pu(qr),program:qr,program_version:qr}};var y2=te.Schema;const mn=y2.str,hp=y2.lstr,Xa=y2.Aliased,Wu=y2.int,a4e={pdbx_reference_molecule:{prd_id:mn,formula_weight:y2.float,formula:mn,type:Xa(hp),type_evidence_code:mn,class:Xa(hp),class_evidence_code:mn,name:mn,represent_as:Xa(hp),chem_comp_id:mn,compound_details:mn,description:mn,representative_PDB_id_code:mn,release_status:Xa(hp),replaces:mn,replaced_by:mn},pdbx_reference_entity_list:{prd_id:mn,ref_entity_id:mn,type:Xa(hp),details:mn,component_id:Wu},pdbx_reference_entity_nonpoly:{prd_id:mn,ref_entity_id:mn,name:mn,chem_comp_id:mn},pdbx_reference_entity_link:{link_id:Wu,prd_id:mn,details:mn,ref_entity_id_1:mn,ref_entity_id_2:mn,entity_seq_num_1:Wu,entity_seq_num_2:Wu,comp_id_1:mn,comp_id_2:mn,atom_id_1:mn,atom_id_2:mn,value_order:Xa(hp),component_1:Wu,component_2:Wu,link_class:Xa(mn)},pdbx_reference_entity_poly_link:{link_id:Wu,prd_id:mn,ref_entity_id:mn,component_id:Wu,entity_seq_num_1:Wu,entity_seq_num_2:Wu,comp_id_1:mn,comp_id_2:mn,atom_id_1:mn,atom_id_2:mn,value_order:Xa(hp)},pdbx_reference_entity_poly:{prd_id:mn,ref_entity_id:mn,type:Xa(mn),db_code:mn,db_name:mn},pdbx_reference_entity_poly_seq:{prd_id:mn,ref_entity_id:mn,mon_id:mn,parent_mon_id:mn,num:Wu,observed:Xa(hp),hetero:Xa(hp)},pdbx_reference_entity_sequence:{prd_id:mn,ref_entity_id:mn,type:Xa(mn),NRP_flag:Xa(mn),one_letter_codes:mn},pdbx_reference_entity_src_nat:{prd_id:mn,ref_entity_id:mn,ordinal:Wu,organism_scientific:mn,taxid:mn,db_code:mn,db_name:mn},pdbx_prd_audit:{prd_id:mn,date:mn,processing_site:Xa(mn),action_type:Xa(mn)}};var KJ=te.Schema;const Eo=KJ.str,u4e={datablock:{id:Eo,description:Eo},dictionary:{title:Eo,datablock_id:Eo,version:Eo},dictionary_history:{version:Eo,update:Eo,revision:Eo},sub_category:{id:Eo,description:Eo},category_group_list:{id:Eo,parent_id:Eo,description:Eo},item_type_list:{code:Eo,primitive_code:Eo,construct:Eo,detail:Eo},item_units_list:{code:Eo,detail:Eo},item_units_conversion:{from_code:Eo,to_code:Eo,operator:Eo,factor:KJ.float}};var b2=te.Schema;const ef=b2.str,vT=b2.int,mp=b2.float,_T=b2.Aliased,tm=b2.Vector,ZJ=(_T(ef),_T(ef),_T(ef),_T(ef),tm(3),tm(3),{volume_data_3d_info:{name:ef,axis_order:tm(3,vT),origin:tm(3),dimensions:tm(3),sample_rate:vT,sample_count:tm(3,vT),spacegroup_number:vT,spacegroup_cell_size:tm(3),spacegroup_cell_angles:tm(3),mean_source:mp,mean_sampled:mp,sigma_source:mp,sigma_sampled:mp,min_source:mp,min_sampled:mp,max_source:mp,max_sampled:mp},volume_data_3d:{values:mp}});var xT=te.Schema;const ro=xT.float,uO=xT.int,ti=xT.str,d4e={cell:{angle_alpha:ro,angle_beta:ro,angle_gamma:ro,formula_units_z:uO,length_a:ro,length_b:ro,length_c:ro,volume:ro},chemical:{melting_point:ro,name_common:ti,name_systematic:ti},chemical_formula:{moiety:ti,sum:ti,weight:ro},space_group:{crystal_system:ti,it_number:uO,"name_h-m_full":ti},space_group_symop:{operation_xyz:ti},geom_bond:{atom_site_label_1:ti,atom_site_label_2:ti,distance:ro,publ_flag:ti,site_symmetry_1:ti,site_symmetry_2:ti,valence:ro},audit:{block_doi:ti},database_code:{cod:ti,csd:ti,depnum_ccdc_archive:ti,depnum_ccdc_fiz:ti,icsd:ti,mdf:ti,nbs:ti},atom_site:{adp_type:ti,calc_flag:ti,disorder_assembly:ti,disorder_group:ti,fract_x:ro,fract_y:ro,fract_z:ro,label:ti,occupancy:ro,refinement_flags:ti,site_symmetry_multiplicity:uO,type_symbol:ti,u_iso_or_equiv:ro},atom_site_aniso:{label:ti,u_11:ro,u:(0,xT.Matrix)(3,3),u_12:ro,u_13:ro,u_22:ro,u_23:ro,u_33:ro},atom_type:{description:ti,symbol:ti},atom_type_scat:{dispersion_imag:ro,dispersion_real:ro,source:ti}},f4e={"cell.formula_units_z":["cell_formula_units_Z"],"space_group.it_number":["space_group_IT_number","symmetry_Int_Tables_number"],"space_group.name_h-m_full":["symmetry_space_group_name_H-M"],"space_group_symop.operation_xyz":["symmetry_equiv_pos_as_xyz"],"geom_bond.atom_site_label_1":["geom_bond_atom_site_id_1"],"geom_bond.atom_site_label_2":["geom_bond_atom_site_id_2"],"geom_bond.distance":["geom_bond_dist"],"audit.block_doi":["audit_block_DOI"],"database_code.cod":["database_code_COD"],"database_code.csd":["database_code_CSD"],"database_code.depnum_ccdc_archive":["database_code_depnum_CCDC_archive"],"database_code.depnum_ccdc_fiz":["database_code_depnum_CCDC_fiz"],"database_code.icsd":["database_code_ICSD"],"database_code.mdf":["database_code_MDF"],"database_code.nbs":["database_code_NBS"],"atom_site.adp_type":["atom_site_ADP_type","atom_site_thermal_displace_type"],"atom_site.label":["atom_site_id"],"atom_site.site_symmetry_multiplicity":["atom_site_symmetry_multiplicity"],"atom_site.u_iso_or_equiv":["atom_site_U_iso_or_equiv"],"atom_site_aniso.label":["atom_site_anisotrop_id"],"atom_site_aniso.u_11":["atom_site_aniso_U_11","atom_site_anisotrop_U_11"],"atom_site_aniso.u_12":["atom_site_aniso_U_12","atom_site_anisotrop_U_12"],"atom_site_aniso.u_13":["atom_site_aniso_U_13","atom_site_anisotrop_U_13"],"atom_site_aniso.u_22":["atom_site_aniso_U_22","atom_site_anisotrop_U_22"],"atom_site_aniso.u_23":["atom_site_aniso_U_23","atom_site_anisotrop_U_23"],"atom_site_aniso.u_33":["atom_site_aniso_U_33","atom_site_anisotrop_U_33"]},lO=te.Schema.int,h4e={volume_data_3d_info:ZJ.volume_data_3d_info,segmentation_data_table:{set_id:lO,segment_id:lO},segmentation_data_3d:{values:lO}},od={parse:e=>"string"==typeof e?WJ(e):YJ(e),parseText:WJ,parseBinary:YJ,toDatabaseCollection:function Ike(e,t,n){const r={};for(const i of t.blocks)r[i.header]=Zd(e,i,n);return r},toDatabase:Zd,schema:{mmCIF:e=>Zd(On,e),CCD:e=>Zd(o4e,e),BIRD:e=>Zd(a4e,e),dic:e=>Zd(u4e,e),cifCore:e=>Zd(d4e,e,f4e),densityServer:e=>Zd(ZJ,e),segmentation:e=>Zd(h4e,e)}},m4e={type_symbol:te.Schema.Aliased(On.atom_site.type_symbol),label_atom_id:On.atom_site.label_atom_id,auth_atom_id:On.atom_site.auth_atom_id,label_alt_id:On.atom_site.label_alt_id,label_comp_id:On.atom_site.label_comp_id,auth_comp_id:On.atom_site.auth_comp_id,pdbx_formal_charge:On.atom_site.pdbx_formal_charge},g4e={group_PDB:On.atom_site.group_PDB,label_seq_id:On.atom_site.label_seq_id,auth_seq_id:On.atom_site.auth_seq_id,pdbx_PDB_ins_code:On.atom_site.pdbx_PDB_ins_code},y4e={label_asym_id:On.atom_site.label_asym_id,auth_asym_id:On.atom_site.auth_asym_id,label_entity_id:On.atom_site.label_entity_id};var dO,Gg;!function(e){e.EmptyResidueKey=function t(){return{label_entity_id:"",label_asym_id:"",auth_seq_id:0,pdbx_PDB_ins_code:void 0}}}(dO||(dO={})),function(e){function t(i,o){return i.residueAtomSegments.index[i.chainAtomSegments.offsets[o]]}function n(i,o){return i.residueAtomSegments.index[i.chainAtomSegments.offsets[o+1]-1]+1}e.chainStartResidueIndex=t,e.chainEndResidueIndexExcl=n,e.chainResidueCount=function r(i,o){return n(i,o)-t(i,o)}}(Gg||(Gg={}));const ST={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},b4e={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},v4e={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},_4e=1.7,S4e=0;function v2(e){const t=ST[e];return void 0===t?_4e:b4e[t]}function _2(e){const t=ST[e];return void 0===t?S4e:t}function QJ(e,t,n,r){return{type:e,key:t,elements:n,getIndex:r}}var jg;function T4e(e,t,n,r,i,o){const{auth_seq_id:s,label_seq_id:a,pdbx_PDB_ins_code:c}=e.residues,{endSeqId:u,endInsCode:l,key:d,type:f}=n,p="label"===t?a:s;let m=r;for(;mu||h===u&&c.value(m)===l)break;m++}}!function(e){e.Descriptor={name:"model_secondary_structure"},e.Provider=td.create(e.Descriptor),e.fromStruct=function t(n,r,i){const o=new Map,s=[{kind:"none"}],a=function w4e(e,t){if(e._rowCount>0){if(0!==e.beg_label_seq_id.valueKind(0)||0!==e.end_label_seq_id.valueKind(0))return"auth"}else if(t&&(0!==t.beg_label_seq_id.valueKind(0)||0!==t.end_label_seq_id.valueKind(0)))return"auth";return"label"}(n,r);(function A4e(e,t,n,r){if(!e._rowCount)return;const{beg_label_asym_id:i,beg_label_seq_id:o,beg_auth_seq_id:s,pdbx_beg_PDB_ins_code:a}=e,{end_label_seq_id:c,end_auth_seq_id:u,pdbx_end_PDB_ins_code:l}=e,{pdbx_PDB_helix_class:d,conf_type_id:f,details:p}=e,m="label"===t?o:s,h="label"===t?c:u;for(let g=0,y=e._rowCount;g0&&function D4e(e,t,n,r){const{count:i}=e.chainAtomSegments,{label_asym_id:o}=e.chains,{auth_seq_id:s,label_seq_id:a,pdbx_PDB_ins_code:c}=e.residues,u="label"===t?a:s;for(let l=0;ld)}}(jg||(jg={}));const E4e={U:On.atom_site_anisotrop.U,U_esd:On.atom_site_anisotrop.U_esd};var tf,Hg;!function(e){e.Schema=E4e,e.Descriptor={name:"atom_site_anisotrop",cifExport:{prefix:"",categories:[{name:"atom_site_anisotrop",instance:r=>e.Provider.get(r.firstModel)&&Er.is(r.firstModel.sourceData)?Bi.Category.ofTable(r.firstModel.sourceData.data.db.atom_site_anisotrop):Bi.Category.Empty}]}},e.Provider=td.create(e.Descriptor),e.getElementToAnsiotrop=function t(r,i){const o=new Int32Array(r.rowCount);o.fill(-1);for(let a=0,c=r.rowCount;a0},e.writeMmCif=function s(a,c){a.writeCategory({name:t,instance(){const u=Xn.ofRows(e.Schema.molstar_global_model_transform_info,[{matrix:c}]);return Bi.Category.ofTable(u)}})}}(Hg||(Hg={})),te.Schema.Str();const P4e={...On.chem_comp,type:te.Schema.Aliased(te.Schema.str)};function M4e(e,t){const{ihm_model_group:n,ihm_model_group_link:r}=t,i=Xn.pickRow(r,o=>r.model_id.value(o)===e);if(i){const o=Xn.pickRow(n,s=>n.id.value(s)===i.group_id);if(o)return o.name}return""}function JJ(e){for(let t=0,n=e.rowCount;tthis.namesMap.set(n[0],n[1]))}}const k4e=[new Set(["CA"]),new Set(["C"]),new Set(["N"])],N4e=[new Set(["P","O3'","O3*"]),new Set(["C4'","C4*"]),new Set(["O2'","O2*","F2'","F2*"])],F4e=[new Set(["P","O3'","O3*"]),new Set(["C3'","C3*"]),new Set(["O2'","O2*","F2'","F2*"])],B4e=new Set(["FMN","NCN","FNS","FMA","ATP","ADP","AMP","GTP","GDP","GMP","LIG"]),eee=function(){const e=new Map;return[{id:"HIS",name:"HISTIDINE",type:"l-peptide linking"},{id:"ARG",name:"ARGININE",type:"l-peptide linking"},{id:"LYS",name:"LYSINE",type:"l-peptide linking"},{id:"ILE",name:"ISOLEUCINE",type:"l-peptide linking"},{id:"PHE",name:"PHENYLALANINE",type:"l-peptide linking"},{id:"LEU",name:"LEUCINE",type:"l-peptide linking"},{id:"TRP",name:"TRYPTOPHAN",type:"l-peptide linking"},{id:"ALA",name:"ALANINE",type:"l-peptide linking"},{id:"MET",name:"METHIONINE",type:"l-peptide linking"},{id:"CYS",name:"CYSTEINE",type:"l-peptide linking"},{id:"ASN",name:"ASPARAGINE",type:"l-peptide linking"},{id:"VAL",name:"VALINE",type:"l-peptide linking"},{id:"GLY",name:"GLYCINE",type:"peptide linking"},{id:"SER",name:"SERINE",type:"l-peptide linking"},{id:"GLN",name:"GLUTAMINE",type:"l-peptide linking"},{id:"TYR",name:"TYROSINE",type:"l-peptide linking"},{id:"ASP",name:"ASPARTIC ACID",type:"l-peptide linking"},{id:"GLU",name:"GLUTAMIC ACID",type:"l-peptide linking"},{id:"THR",name:"THREONINE",type:"l-peptide linking"},{id:"PRO",name:"PROLINE",type:"l-peptide linking"},{id:"SEC",name:"SELENOCYSTEINE",type:"l-peptide linking"},{id:"PYL",name:"PYRROLYSINE",type:"l-peptide linking"},{id:"MSE",name:"SELENOMETHIONINE",type:"l-peptide linking"},{id:"SEP",name:"PHOSPHOSERINE",type:"l-peptide linking"},{id:"TPO",name:"PHOSPHOTHREONINE",type:"l-peptide linking"},{id:"PTR",name:"O-PHOSPHOTYROSINE",type:"l-peptide linking"},{id:"PCA",name:"PYROGLUTAMIC ACID",type:"l-peptide linking"},{id:"A",name:"ADENOSINE-5'-MONOPHOSPHATE",type:"rna linking"},{id:"C",name:"CYTIDINE-5'-MONOPHOSPHATE",type:"rna linking"},{id:"T",name:"THYMIDINE-5'-MONOPHOSPHATE",type:"rna linking"},{id:"G",name:"GUANOSINE-5'-MONOPHOSPHATE",type:"rna linking"},{id:"I",name:"INOSINIC ACID",type:"rna linking"},{id:"U",name:"URIDINE-5'-MONOPHOSPHATE",type:"rna linking"},{id:"DA",name:"2'-DEOXYADENOSINE-5'-MONOPHOSPHATE",type:"dna linking"},{id:"DC",name:"2'-DEOXYCYTIDINE-5'-MONOPHOSPHATE",type:"dna linking"},{id:"DT",name:"THYMIDINE-5'-MONOPHOSPHATE",type:"dna linking"},{id:"DG",name:"2'-DEOXYGUANOSINE-5'-MONOPHOSPHATE",type:"dna linking"},{id:"DI",name:"2'-DEOXYINOSINE-5'-MONOPHOSPHATE",type:"dna linking"},{id:"DU",name:"2'-DEOXYURIDINE-5'-MONOPHOSPHATE",type:"dna linking"}].forEach(n=>e.set(n.id,n)),e}(),tee=function(){const e=new Map;return[{id:"ZN2",name:"ZINC ION",type:"ion"},{id:"SOD",name:"SODIUM ION",type:"ion"},{id:"CES",name:"CESIUM ION",type:"ion"},{id:"CLA",name:"CHLORIDE ION",type:"ion"},{id:"CAL",name:"CALCIUM ION",type:"ion"},{id:"POT",name:"POTASSIUM ION",type:"ion"}].forEach(n=>e.set(n.id,n)),e}();class ad{set(t){this.comps.set(t.id,t),this.ids.push(t.id),this.names.push(t.name),this.types.push(t.type),this.mon_nstd_flags.push(Wb.has(t.id)?"y":"n")}getAtomIds(t){const n=new Set,r=this.seqId.value(t);for(;tthis.namesMap.set(n[0],n[1]))}constructor(t,n){this.seqId=t,this.atomId=n,this.namesMap=new Map,this.comps=new Map,this.ids=[],this.names=[],this.types=[],this.mon_nstd_flags=[]}}var Er,x2;function fO(e,t){const n=Er.fromFrame(e,void 0,void 0,t),r=$u(n.data.db,!0);return Oe.create("Create mmCIF Model",i=>af(r,n,i))}function pO(){return pO=ie(function*(e,t,n){const r=yield nee(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"},n),i=yield nee(e,t,{coordinateType:"model",cartn_x:"model_Cartn_x",cartn_y:"model_Cartn_y",cartn_z:"model_Cartn_z"},n),o=[];r&&o.push(r),i&&o.push(i);for(let s=0,a=o.length;s0||(x[x.length]=O);const _=x.length,S=te.ofConst("A",_,te.Schema.str),A=te.ofConst(1,_,te.Schema.int),E=te.ofConst("1",_,te.Schema.str),w=te.ofConst(1,_,te.Schema.float),D=te.ofConst(1,_,te.Schema.int),I=te.view(p,x),R=te.view(h,x),T=te.view(o[c],x),M=te.view(o[u],x),N=te.view(o[l],x),V=te.view(g,x),F=te.view(y,x),G=te.view(m,x),L=Xn.ofPartialColumns(ks.atom_site,{auth_asym_id:S,auth_atom_id:I,auth_comp_id:R,auth_seq_id:A,Cartn_x:T,Cartn_y:M,Cartn_z:N,id:V,label_asym_id:S,label_atom_id:I,label_comp_id:R,label_seq_id:A,label_entity_id:E,occupancy:w,type_symbol:F,pdbx_PDB_model_num:D,pdbx_formal_charge:G},_),z=new sd;z.setNames([[f,`${d} (${a})`]]),z.getEntityId(f,0,"A");const j=new ad(A,y);j.setNames([[f,`${d} (${a})`]]),j.add(f,0);const Z=$u({entity:z.getEntityTable(),chem_comp:j.getChemCompTable(),atom_site:L}),$=yield af(Z,t,r);if(!$.representative)return;const ee=$.representative,q=Ug.getEntriesFromChemCompBond(s);return Ug.Provider.set(ee,{data:s,entries:q}),x2.CoordinateType.set(ee,a),$.representative}),hO.apply(this,arguments)}no.Provider.formatRegistry.add("mmCIF",function O4e(e){if(Er.is(e.sourceData))return no.fromData(e.sourceData.data.db)}),jg.Provider.formatRegistry.add("mmCIF",function L4e(e){if(!Er.is(e.sourceData))return;const{struct_conf:t,struct_sheet_range:n}=e.sourceData.data.db;return jg.fromStruct(t,n,e.atomicHierarchy)}),tf.Provider.formatRegistry.add("mmCIF",function U4e(e){if(!Er.is(e.sourceData))return;const{atom_site_anisotrop:t}=e.sourceData.data.db;return{data:Xn.ofColumns(tf.Schema,t),elementToAnsiotrop:tf.getElementToAnsiotrop(e.atomicConformation.atomId,t.id)}},function V4e(e){return!!Er.is(e.sourceData)&&e.sourceData.data.db.atom_site_anisotrop.U.isDefined}),Ug.Provider.formatRegistry.add("mmCIF",function z4e(e){if(!Er.is(e.sourceData))return;const{chem_comp_bond:t}=e.sourceData.data.db;return 0!==t._rowCount?{data:t,entries:Ug.getEntriesFromChemCompBond(t)}:void 0}),du.Provider.formatRegistry.add("mmCIF",function G4e(e){if(!Er.is(e.sourceData))return;const{struct_conn:t}=e.sourceData.data.db;if(0===t._rowCount)return;const n=du.getEntriesFromStructConn(t,e);return{data:t,byAtomIndex:du.getAtomIndexFromEntries(n),entries:n}}),Hg.Provider.formatRegistry.add("mmCIF",Hg.fromMmCif,Hg.hasData),function(e){e.is=function t(r){return"mmCIF"===r?.kind},e.fromFrame=function n(r,i,o,s){return i||(i=od.schema.mmCIF(r)),{kind:"mmCIF",name:i._name,data:{db:i,file:s,frame:r,source:o}}}}(Er||(Er={})),function(e){const t="__CcdCoordinateType__";e.CoordinateType={get:i=>i._staticPropertyData[t],set:(i,o)=>i._staticPropertyData[t]=o},e.is=function n(i){return"CCD"===i?.kind},e.fromFrame=function r(i,o){return o||(o=od.schema.CCD(i)),{kind:"CCD",name:o._name,data:{db:o,frame:i}}}}(x2||(x2={}));const qg=typeof process<"u"&&null!=process.versions&&null!=process.versions.node,S2=function q4e(){return typeof XMLHttpRequest>"u"||qg?Fn(684):XMLHttpRequest}(),mO=function W4e(){if(typeof File>"u"||qg){class e{arrayBuffer(){return this.blob.arrayBuffer()}slice(n,r,i){return this.blob.slice(n,r,i)}stream(){return this.blob.stream()}text(){return this.blob.text()}constructor(n,r,i){var o;this.blob=new Blob(n,i),this.size=this.blob.size,this.type=this.blob.type,this.name=r,this.lastModified=null!==(o=i?.lastModified)&&void 0!==o?o:0,this.webkitRelativePath=""}}return e}return File}();function gp(e,t){return e[t]|e[t+1]<<8}function Wg(e,t,n){e[t]=255&n,e[t+1]=n>>8&255}function $g(e,t){return 16777216*e[t+3]+(e[t+2]<<16|e[t+1]<<8|e[t])}function yp(e,t,n){e[t]=255&n,e[t+1]=n>>8&255,e[t+2]=n>>16&255,e[t+3]=n>>24&255}function X4e(e){return e.length<2?"0"+e:e}function ree(e){const t=e.length;let n=0;for(let r=0;r>>1:n>>>=1;e[t]=n}return e}();function iee(e,t,n){return 4294967295^function J4e(e,t,n,r){for(let i=0;i>>8;return e}(4294967295,e,t,n)}const mt=function(){const 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 C2(e,t,n){const r=e.length,i=mt.rev15;for(let o=0;o>1<<4|a,u=t-a;let l=e[o]<>>15-t]=c,l++}}function nm(e,t){const n=e.length,r=mt.bl_count;for(let s=0;s<=t;s++)r[s]=0;for(let s=1;s>>r}function tLe(e,t){const{data:n,noBuf:r}=e;let{buf:i,BFINAL:o,off:s,pos:a}=e,c=0;for(;0===o&&cy&&(y=S)}a+=3*g,nm(mt.itree,y),C2(mt.itree,y,mt.imap),u=mt.lmap,l=mt.dmap,a=rLe(mt.imap,(1<>>4;if(h>>>8){if(256===h)break;{let g=s+h-254;if(h>264){const S=mt.ldef[h-257];g=s+(S>>>3)+rm(n,a,7&S),a+=7&S}const y=l[vO(n,a)&f];a+=15&y;const x=mt.ddef[y>>>4],_=(x>>>4)+bO(n,a,15&x);for(a+=15&x,r&&(i=yO(i,s+(1<<17)));s>>3),h=n[m-4]|n[m-3]<<8;r&&(i=yO(i,s+h)),i.set(new Uint8Array(n.buffer,n.byteOffset+m,h),s),a=m+h<<3,s+=h}}e.buf=i,e.BFINAL=o,e.off=s,e.pos=a}function gO(){return gO=ie(function*(e,t,n){if(3===t[0]&&0===t[1])return n||new Uint8Array(0);const r=function eLe(e,t){const n=void 0===t;return void 0===t&&(t=new Uint8Array(e.length>>>2<<3)),{data:e,buf:t,noBuf:n,BFINAL:0,off:0,pos:0}}(t,n);for(;0===r.BFINAL;)e.shouldUpdate&&(yield e.update({message:"Inflating blocks...",current:r.pos,max:t.length})),tLe(r,100);return r.buf.length===r.off?r.buf:r.buf.slice(0,r.off)}),gO.apply(this,arguments)}function yO(e,t){const n=e.length;if(t<=n)return e;const r=new Uint8Array(Math.max(n<<1,t));return r.set(e,0),r}function rLe(e,t,n,r,i,o){let s=0;for(;s>>4;if(c<=15)o[s]=c,s++;else{let u=0,l=0;16===c?(l=3+rm(r,i,2),i+=2,u=o[s-1]):17===c?(l=3+rm(r,i,3),i+=3):18===c&&(l=11+rm(r,i,7),i+=7);const d=s+l;for(;s>>1;for(;oi&&(i=a),o++}for(;o>>3]|e[1+(t>>>3)]<<8)>>>(7&t)&(1<>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)&(1<>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)}function _O(e,t,n){const r=[],i=e.length,o=t.length;for(let m=0;mn&&(function iLe(e,t,n){let r=0,i=0;const o=1<t;r++){const s=e[r].d;e[r].d=t,i+=o-(1<>>=n-t;i>0;){const s=e[r].d;s=0;r--)e[r].d===t&&i<0&&(e[r].d--,i++);0!==i&&console.log("debt left")}(a,n,p),p=n);for(let m=0;m14e3||l>26697)&&r-s>100&&(c>>16,S=65535&x,A=lee(_,mt.of0);mt.lhst[257+A]++;const E=lee(S,mt.df0);mt.dhst[E]++,f+=mt.exb[A]+mt.dxb[E],h[u]=_<<23|s-c,h[u+1]=S<<16|A<<8|E,u+=2,c=s+_}else mt.lhst[n[s]]++;l++}}e.i=s,e.pos=a,e.cvrd=c,e.li=u,e.lc=l,e.bs=d,e.ebits=f,e.c=p,e.nc=m}!function(){for(let n=0;n<32768;n++){let r=n;r=(2863311530&r)>>>1|(1431655765&r)<<1,r=(3435973836&r)>>>2|(858993459&r)<<2,r=(4042322160&r)>>>4|(252645135&r)<<4,r=(4278255360&r)>>>8|(16711935&r)<<8,mt.rev15[n]=(r>>>16|r<<16)>>>17}function t(n,r,i){for(;0!=r--;)n.push(0,i)}for(let n=0;n<32;n++)mt.ldef[n]=mt.of0[n]<<3|mt.exb[n],mt.ddef[n]=mt.df0[n]<<4|mt.dxb[n];t(mt.fltree,144,8),t(mt.fltree,112,9),t(mt.fltree,24,7),t(mt.fltree,8,8),nm(mt.fltree,9),C2(mt.fltree,9,mt.flmap),w2(mt.fltree,9),t(mt.fdtree,32,5),nm(mt.fdtree,5),C2(mt.fdtree,5,mt.fdmap),w2(mt.fdtree,5),t(mt.itree,19,0),t(mt.ltree,286,0),t(mt.dtree,30,0),t(mt.ttree,320,0)}();const aLe=[[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 SO(){return SO=ie(function*(e,t,n,r,i){const o=function oLe(e,t,n,r){const{lits:i,strt:o,prev:s}=mt;return{data:e,out:t,opt:aLe[r],i:0,pos:n<<3,cvrd:0,dlen:e.length,li:0,lc:0,bs:0,ebits:0,c:0,nc:0,lits:i,strt:o,prev:s}}(t,n,r,i),{dlen:s}=o;if(0===i){let{i:m,pos:h}=o;for(;m>>3}for(s>2&&(o.nc=CO(t,0),o.strt[o.nc]=0);o.i>>3}),SO.apply(this,arguments)}function uLe(e,t,n,r,i,o){let s=32767&t,a=n[s],c=s-a+32768&32767;if(a===s||r!==CO(e,t-c))return 0;let u=0,l=0;const d=Math.min(32767,t);for(;c<=d&&0!=--o&&a!==s;){if(0===u||e[t+u]===e[t+u-c]){let f=lLe(e,t,c);if(f>u){if(u=f,l=c,u>=i)break;c+2p&&(p=y,a=h)}}}s=a,a=n[s],c+=s-a+32768&32767}return u<<16|l}function lLe(e,t,n){if(e[t]!==e[t-n]||e[t+1]!==e[t+1-n]||e[t+2]!==e[t+2-n])return 0;const r=t,i=Math.min(e.length,t+258);for(t+=3;t4&&0===mt.itree[1+(mt.ordr[a-1]<<1)];)a--;return[e,t,s,r,o,a,n,i]}(),y=32+(c+3&7?8-(c+3&7):0)+(s<<3),b=r+A2(mt.fltree,mt.lhst)+A2(mt.fdtree,mt.dhst);let x=r+A2(mt.ltree,mt.lhst)+A2(mt.dtree,mt.dhst);x+=14+3*m+A2(mt.itree,mt.ihst)+(2*mt.ihst[16]+3*mt.ihst[17]+7*mt.ihst[18]);for(let S=0;S<286;S++)mt.lhst[S]=0;for(let S=0;S<30;S++)mt.dhst[S]=0;for(let S=0;S<19;S++)mt.ihst[S]=0;const _=y>>23,R=E+(8388607&D);for(;E>16,N=T>>8&255,V=255&T;Yg(a,c=I2(257+N,S,a,c),I-mt.of0[N]),wT(a,c=I2(V,A,a,c+=mt.exb[N]),M-mt.df0[V]),c+=mt.dxb[V],E+=I}}c=I2(256,S,a,c)}return c}function aee(e,t,n,r,i){let o=i>>>3;return r[o]=n,r[o+1]=n>>>8,r[o+2]=255-r[o],r[o+3]=255-r[o+1],o+=4,r.set(new Uint8Array(e.buffer,t,n),o),i+(n+4<<3)}function A2(e,t){let n=0;for(let r=0;r15&&(Yg(n,r,s),r+=a)}return r}function uee(e,t){let n=e.length;for(;2!==n&&0===e[n-1];)n-=2;for(let r=0;r>>1,138);u<11?t.push(17,u-3):t.push(18,u-11),r+=2*u-2}else if(i===a&&o===i&&s===i){let c=r+5;for(;c+2>>1,6);t.push(16,u-3),r+=2*u-2}else t.push(i,0)}return n>>>1}function lee(e,t){let n=0;return t[16|n]<=e&&(n|=16),t[8|n]<=e&&(n|=8),t[4|n]<=e&&(n|=4),t[2|n]<=e&&(n|=2),t[1|n]<=e&&(n|=1),n}function I2(e,t,n,r){return wT(n,r,t[e<<1]),r+t[1+(e<<1)]}function Yg(e,t,n){const r=t>>>3;e[r]|=n<<=7&t,e[r+1]|=n>>>8}function wT(e,t,n){const r=t>>>3;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16}function T2(e,t){return wO.apply(this,arguments)}function wO(){return wO=ie(function*(e,t,n=!1){const r=Object.create(null),i=new Uint8Array(t);if(19280!==gp(i,0))throw new Error('Invalid ZIP file. A valid ZIP file must start with two magic bytes \\x50\\x4b ("PK" in ASCII).');let o=i.length-4;for(;101010256!==$g(i,o);)o--;let s=o;s+=4,s+=4;const a=gp(i,s);s+=2,s+=2,s+=4;const c=$g(i,s);s+=4,s=c;for(let u=0;u>18,e[t+i+1]=128|s>>12&63,e[t+i+2]=128|s>>6&63,e[t+i+3]=128|63&s,i+=4}else e[t+i]=224|s>>12,e[t+i+1]=128|s>>6&63,e[t+i+2]=128|63&s,i+=3;else e[t+i]=192|s>>6,e[t+i+1]=128|63&s,i+=2;else e[t+i]=s,i++}return i}(e,t,n);return t+=a,0===i&&(e.set(s,t),t+=s.length),t}var Yu=function(e){return e[e.None=0]="None",e[e.Gzip=1]="Gzip",e[e.Zip=2]="Zip",e}(Yu||{});function bp(e,t){return function FO(e,t){if(qg)return function xLe(e,t){return Oe.create("Read File",function(){var n=ie(function*(r){const i="zip"===t?Yu.None:hee(e.name);let o;return yield r.update({message:"Opening file...",canAbort:!1}),o="binary"===t||"zip"===t||i!==Yu.None?yield e.arrayBuffer():yield e.text(),yield r.update({message:"Processing file...",canAbort:!1}),yield mee(r,o,t,i)});return function(r){return n.apply(this,arguments)}}())}(e,t);let n;return Oe.create("Read File",function(){var r=ie(function*(i){try{n=new FileReader;const o="zip"===t?Yu.None:hee(e.name);"binary"===t||"zip"===t||o!==Yu.None?n.readAsArrayBuffer(e):n.readAsText(e),yield i.update({message:"Opening file...",canAbort:!0});const s=yield pee(i,"Reading...",n);return yield i.update({message:"Processing file...",canAbort:!1}),yield mee(i,s.result,t,o)}finally{n=void 0}});return function(i){return r.apply(this,arguments)}}(),()=>{n&&n.abort()})}(e,t)}function RO(e){return"string"==typeof e?gee(e,e,"string"):gee(e.title,e.url,e.type||"string",e.body,e.headers)}function fee(e){return e?"Failed to download data. Possible reasons: Resource is not available, or CORS is not allowed on the server.":"Failed to open file."}function pee(e,t,n){return new Promise((r,i)=>{if(function bLe(e){if(!qg&&e instanceof FileReader)return e.readyState===FileReader.DONE;if(e instanceof S2)return e.readyState===S2.DONE;throw new Error("unknown data type")}(n)){const{error:s}=n;return void(null!=s?i(s??fee(n instanceof S2)):r(n))}let o=!1;n.onerror=s=>{if(o)return;const{error:a}=s.target;i(a??fee(n instanceof S2))},n.onprogress=s=>{if(e.shouldUpdate&&!o)try{e.update(s.lengthComputable?{message:t,isIndeterminate:!1,current:s.loaded,max:s.total}:{message:`${t} ${(s.loaded/1024/1024).toFixed(2)} MB`,isIndeterminate:!0})}catch(a){o=!0,i(a)}},n.onload=s=>{r(n)}})}function hee(e){return/\.gz$/i.test(e)?Yu.Gzip:/\.zip$/i.test(e)?Yu.Zip:Yu.None}const vLe=/^(__MACOSX|.DS_Store)/;function kO(){return kO=ie(function*(e,t,n){switch(n){case Yu.None:return t;case Yu.Gzip:return function pLe(e,t,n){return DO.apply(this,arguments)}(e,t);case Yu.Zip:const r=yield T2(e,t.buffer),i=Object.keys(r).filter(o=>!vLe.test(o));if(1!==i.length)throw new Error("can only decompress zip files with a single entry");return r[i[0]]}}),kO.apply(this,arguments)}function mee(e,t,n,r){return NO.apply(this,arguments)}function NO(){return NO=ie(function*(e,t,n,r){let i=t instanceof ArrayBuffer?new Uint8Array(t):t;if(null===i)throw new Error("no data given");if(r!==Yu.None){if(!(i instanceof Uint8Array))throw new Error("need Uint8Array for decompression");const o=yield function _Le(e,t,n){return kO.apply(this,arguments)}(e,i,r);"string"===n?(yield e.update({message:"Decoding text..."}),i=jB(o,0,o.length)):i=o}if("binary"===n&&i instanceof Uint8Array)return i;if("zip"===n&&i instanceof Uint8Array)return yield T2(e,i.buffer);if("string"===n&&"string"==typeof i)return i;if("xml"===n&&"string"==typeof i)return(new DOMParser).parseFromString(i,"application/xml");if("json"===n&&"string"==typeof i)return JSON.parse(i);throw new Error(`could not get requested response data '${n}'`)}),NO.apply(this,arguments)}let OO,BO=(()=>{class e{static get(){return this.pool.length?this.pool.pop():new S2}static emptyFunc(){}static deposit(n){this.pool.length=200&&e.status<400){const{response:n}=e;if(BO.deposit(e),("binary"===t||"zip"===t)&&n instanceof ArrayBuffer)return new Uint8Array(n);if("string"===t&&"string"==typeof n)return n;if("xml"===t&&n instanceof XMLDocument)return n;if("json"===t&&"object"==typeof n)return n;throw new Error(`could not get requested response data '${t}'`)}throw BO.deposit(e),new Error(`Download failed with status code ${e.status}`)}(c,n)});return function(a){return s.apply(this,arguments)}}(),()=>{o&&(o.abort(),o=void 0)})}function LO(){return LO=ie(function*(e,t,n,r){const i=n.length,o=new Array(n.length);yield e.update({message:"Downloading...",current:0,max:i});let s=[],a=[],c=0;for(let l=Math.min(i,r);c0;){const l=yield Promise.race(s),d=n[l.index],f=a.indexOf(l.index);if(u++,"error"===l.kind&&!d.canFail)throw new Error(`${d.url}: ${l.error}`);if(e.shouldUpdate&&(yield e.update({message:"Downloading...",current:u,max:i})),o[l.index]=l,s=s.filter(yee,f),a=a.filter(yee,f),c{l.release(u)}}},e.getUrl=function s(c){return"string"==typeof c?c:c.url},e.getUrlAsset=function a(c,u,l){return"string"==typeof u?c.tryFindUrl(u,l)||t(u,{body:l}):u}}(fr||(fr={}));class TLe{constructor(){this._assets=new Map}get assets(){return lB(this._assets.values())}tryFindUrl(t,n){const r=this.assets.values();for(;;){const i=r.next();if(i.done)return;const o=i.value.asset;if(fr.isUrl(o)&&o.url===t&&(o.body||"")===(n||""))return o}}set(t,n){this._assets.set(t.id,{asset:t,file:n,refCount:0})}get(t){return this._assets.get(t.id)}delete(t){return this._assets.delete(t.id)}has(t){return this._assets.has(t.id)}resolve(t,n,r=!0){var i=this;return fr.isUrl(t)?Oe.create(`Download ${t.title||t.url}`,function(){var o=ie(function*(s){if(i._assets.has(t.id)){const u=i._assets.get(t.id);return u.refCount++,fr.Wrapper(yield bp(u.file,n).runInContext(s),t,i)}if(!r)return fr.Wrapper(yield RO({...t,type:n}).runInContext(s),t,i);const a=yield RO({...t,type:"binary"}).runInContext(s),c=new mO([a],"raw-data");return i._assets.set(t.id,{asset:t,file:c,refCount:1}),fr.Wrapper(yield bp(c,n).runInContext(s),t,i)});return function(s){return o.apply(this,arguments)}}()):Oe.create(`Read ${t.name}`,function(){var o=ie(function*(s){if(i._assets.has(t.id)){const a=i._assets.get(t.id);return a.refCount++,fr.Wrapper(yield bp(a.file,n).runInContext(s),t,i)}if(!(t.file instanceof mO))throw new Error(`Cannot resolve file asset '${t.name}' (${t.id})`);return r&&i._assets.set(t.id,{asset:t,file:t.file,refCount:1}),fr.Wrapper(yield bp(t.file,n).runInContext(s),t,i)});return function(s){return o.apply(this,arguments)}}())}release(t){const n=this._assets.get(t.id);n&&(n.refCount--,n.refCount<=0&&this._assets.delete(t.id))}clear(){this._assets.clear()}dispose(){this.clear()}}!function(e){function t(oe,K){return K&&(K.label&&(oe.label=K.label),K.description&&(oe.description=K.description),K.legend&&(oe.legend=K.legend),K.fieldLabels&&(oe.fieldLabels=K.fieldLabels),K.isHidden&&(oe.isHidden=K.isHidden),K.shortLabel&&(oe.shortLabel=K.shortLabel),K.twoColumns&&(oe.twoColumns=K.twoColumns),K.isEssential&&(oe.isEssential=K.isEssential),K.category&&(oe.category=K.category),K.hideIf&&(oe.hideIf=K.hideIf),K.help&&(oe.help=K.help)),oe}function i(oe,K,ne){return t({type:"select",defaultValue:me(oe,K),options:K,cycle:ne?.cycle},ne)}function h(oe,K){return K&&(typeof K.min<"u"&&(oe.min=K.min),typeof K.max<"u"&&(oe.max=K.max),typeof K.step<"u"&&(oe.step=K.step)),oe}function x(oe,K){const ne=t({type:"group",defaultValue:K?.customDefault||F(oe),params:oe},K);return K?.presets&&(ne.presets=K.presets),K?.isExpanded&&(ne.isExpanded=K.isExpanded),K?.isFlat&&(ne.isFlat=K.isFlat),K?.pivot&&(ne.pivot=K.pivot),ne}function w(){return F(this.element)}function D(){throw new Error("getValue not set. Fix runtime.")}function F(oe){const K={};for(const ne of Object.keys(oe))oe[ne].isOptional||(K[ne]=oe[ne].defaultValue);return K}function G(oe,K,ne){return()=>oe(K,ne)}function L(oe,K,ne){if(K)if("value-ref"===oe.type){K.getValue=K.ref?G(oe.resolveRef,K.ref,ne):()=>{throw new Error("Unset ref in ValueRef value.")}}else if("data-ref"===oe.type){K.getValue=K.ref?G(ne,K.ref,ne):()=>{throw new Error("Unset ref in ValueRef value.")}}else if("group"===oe.type)Z(oe.params,K,ne);else if("mapped"===oe.type){const de=K;L(oe.map(de.name),de.params,ne)}else if("object-list"===oe.type){if(!j(oe.element))return;for(const de of K)Z(oe.element,de,ne)}}function z(oe){if("value-ref"===oe.type||"data-ref"===oe.type)return!0;if("group"===oe.type){if(j(oe.params))return!0}else if("mapped"===oe.type){for(const[K]of oe.select.options)if(z(oe.map(K)))return!0}else if("object-list"===oe.type)return j(oe.element);return!1}function j(oe){for(const K of Object.keys(oe))if(z(oe[K]))return!0;return!1}function Z(oe,K,ne){for(const de of Object.keys(oe))L(oe[de],K?.[de],ne)}function O(oe,K,ne){if(K===ne)return!0;if("object"!=typeof K||"object"!=typeof ne)return!1;for(const de of Object.keys(oe))if(!H(oe[de],K[de],ne[de]))return!1;return!0}function H(oe,K,ne){if(K===ne)return!0;if("group"===oe.type)return O(oe.params,K,ne);if("mapped"===oe.type){const de=K,we=ne;return de.name===we.name&&H(oe.map(de.name),de.params,we.params)}if("multi-select"===oe.type){const de=K,we=ne;if(de.length!==we.length)return!1;if(de.length<10){for(let Le=0,We=de.length;Le"u")return ne?oe.defaultValue:void 0;if(!fe(oe.select,de.name))return oe.defaultValue;const we=oe.map(de.name);return{name:de.name,params:X(we,de.params,ne)}}if("select"===oe.type)return fe(oe,K)?K:oe.defaultValue;if("multi-select"===oe.type){if(!Array.isArray(K))return oe.defaultValue;const de=K.filter(function(we){return fe(this,we)},oe);return K.length>0&&0===de.length?oe.defaultValue:de}return"object-list"===oe.type?Array.isArray(K)?K.map(de=>J(oe.element,de,ne?"all":"skip")):oe.defaultValue:K}function J(oe,K,ne){if("object"!=typeof K||null===K)return ne?F(oe):K;const de=Object.create(null);for(const we of Object.keys(oe)){const Le=oe[we];void 0===K[we]?"all"===ne&&(de[we]=Le.defaultValue):de[we]=X(Le,K[we],"skip"!==ne)}return de}function me(oe,K){for(const ne of K)if(ne[0]===oe)return oe;return K.length>0?K[0][0]:void 0}e.Essential={isEssential:!0},e.Optional=function n(oe){const K={...oe};return K.isOptional=!0,K},e.Value=function r(oe,K){return t({type:"value",defaultValue:oe},K)},e.Select=i,e.MultiSelect=function o(oe,K,ne){const de=t({type:"multi-select",defaultValue:oe,options:K},ne);return ne?.emptyValue&&(de.emptyValue=ne.emptyValue),de},e.Boolean=function s(oe,K){return t({type:"boolean",defaultValue:oe},K)},e.Text=function a(oe="",K){return t({type:"text",defaultValue:oe,multiline:K?.multiline,placeholder:K?.placeholder,disableInteractiveUpdates:K?.disableInteractiveUpdates},K)},e.Color=function c(oe,K){const ne=t({type:"color",defaultValue:oe},K);return K?.isExpanded&&(ne.isExpanded=K.isExpanded),ne},e.ColorList=function u(oe,K){let ne;if("string"==typeof oe){const de=cp(oe);ne={kind:"qualitative"!==de.type?"interpolate":"set",colors:de.list}}else ne=oe;return t({type:"color-list",presetKind:K?.presetKind||"all",defaultValue:ne,offsets:!!K?.offsets},K)},e.Vec3=function l(oe,K,ne){return t(h({type:"vec3",defaultValue:oe},K),ne)},e.Mat4=function d(oe,K){return t({type:"mat4",defaultValue:oe},K)},e.Url=function f(oe,K){return t({type:"url",defaultValue:"string"==typeof oe?fr.Url(oe):fr.Url(oe.url,{body:oe.body})},K)},e.File=function p(oe){const K=t({type:"file",defaultValue:null},oe);return oe?.accept&&(K.accept=oe.accept),K},e.FileList=function m(oe){const K=t({type:"file-list",defaultValue:null},oe);return oe?.accept&&(K.accept=oe.accept),K},e.Numeric=function g(oe,K,ne){const de=t(h({type:"number",defaultValue:oe},K),ne);return ne?.immediateUpdate&&(de.immediateUpdate=!0),de},e.Interval=function y(oe,K,ne){return t(h({type:"interval",defaultValue:oe},K),ne)},e.LineGraph=function b(oe,K){const ne=t({type:"line-graph",defaultValue:oe},K);return K?.getVolume&&(ne.getVolume=K.getVolume),ne},e.Group=x,e.EmptyGroup=function _(oe){return x({},oe)},e.Mapped=function S(oe,K,ne,de){const we=me(oe,K);return t({type:"mapped",defaultValue:{name:we,params:ne(we).defaultValue},select:i(we,K,de),map:ne},de)},e.MappedStatic=function A(oe,K,ne){const de=ne?.options?ne.options:Object.keys(K).map(Le=>[Le,K[Le].label||zu(Le)]),we=me(oe,de);return t({type:"mapped",defaultValue:{name:we,params:K[we].defaultValue},select:i(we,de,ne),map:Le=>K[Le]},ne)},e.ObjectList=function E(oe,K,ne){return t({type:"object-list",element:oe,getLabel:K,ctor:w,defaultValue:ne?.defaultValue||[]},ne)},e.ValueRef=function I(oe,K,ne){var de;return t({type:"value-ref",defaultValue:{ref:null!==(de=ne?.defaultRef)&&void 0!==de?de:"",getValue:D},getOptions:oe,resolveRef:K},ne)},e.DataRef=function R(oe){var K;return t({type:"data-ref",defaultValue:{ref:null!==(K=oe?.defaultRef)&&void 0!==K?K:"",getValue:D}},oe)},e.Converted=function T(oe,K,ne){return t({type:"converted",defaultValue:K(ne.defaultValue),converted:ne,fromValue:oe,toValue:K},ne)},e.Conditioned=function M(oe,K,ne,de,we){const Le=Object.keys(K).map(We=>[We,We]);return t({type:"conditioned",select:i(ne(oe),Le,we),defaultValue:oe,conditionParams:K,conditionForValue:ne,conditionedValue:de},we)},e.Script=function N(oe,K){return t({type:"script",defaultValue:oe},K)},e.For=function V(oe){return 0},e.getDefaultValues=F,e.resolveRefs=Z,e.setDefaultValues=function $(oe,K){for(const ne of Object.keys(oe))oe[ne].isOptional||(oe[ne].defaultValue=K[ne])},e.clone=function ee(oe){return Jl(oe)},e.validate=function q(oe,K){},e.areEqual=O,e.isParamEqual=H,e.merge=W,e.mergeParam=Q,e.normalizeParams=J,e.objectToOptions=function ce(oe,K){const ne=[];for(const de of Object.keys(oe))if(K){const we=K(de,oe[de]);ne.push("string"==typeof we?[de,we]:[de,we[0],we[1]])}else ne.push("string"==typeof oe[de]?[de,oe[de]]:[de,null===K?de:zu(de)]);return ne},e.arrayToOptions=function be(oe,K){const ne=[];for(const de of oe)ne.push(K?[de,K(de)]:[de,null===K?de:zu(de)]);return ne},e.optionLabel=function ae(oe,K){for(const ne of oe.options)if(ne[0]===K)return ne[1];return""}}(C||(C={}));const ELe=9,AT=-27.888,PLe=-.5,vee=-9.9;function MLe(e,t,n,r){const i=v.distance(e,r),o=v.distance(t,r),s=v.distance(t,n),a=v.distance(e,n),l=AT/i-AT/o+(AT/s-AT/a);return l0&&(t.secondStart-e.secondEnd<6&&t.firstStart-e.firstEnd<3||t.secondStart-e.secondEnd<3)}function xee(e){return vn.is(e,8)||vn.is(e,1)||vn.is(e,16)}const HLe={oldDefinition:C.Boolean(!0,{description:"Whether to use the old DSSP convention for the annotation of turns and helices, causes them to be two residues shorter"}),oldOrdering:C.Boolean(!0,{description:"Alpha-helices are preferred over 3-10 helices"})};function qLe(e,t){return VO.apply(this,arguments)}function VO(){return VO=ie(function*(e,t){const n=function jLe(e){const{index:t}=e.model.atomicHierarchy,{proteinElements:n,residueIndex:r}=e,i=n.length,o=new Uint32Array(i),s=new Int32Array(i),a=new Int32Array(i),c=new Int32Array(i),u=new Int32Array(i);for(let l=0;lPLe||(f[f.length]=w,p[p.length]=F,m[m.length]=z)}}return function kLe(e,t,n,r){const i=new Dc.DirectedEdgeBuilder(e,t,n),o=new Float32Array(i.slotCount);for(let s=0,a=i.edgeCount;s-1===S?v.setNaN(A):o.position(S,A);let l=v(),d=v(),f=v(),p=v(),m=v(),h=v();const g=v(),y=v(),b=v();if(0===c)return{phi:new Float32Array(0),psi:new Float32Array(0)};const x=new Float32Array(c-1),_=new Float32Array(c-1);u(-1,l),u(-1,d),u(-1,f),u(n[0],p),u(a[i[0]],m),u(r[0],h),u(n[1],g),u(a[i[1]],y),u(r[1],b);for(let S=0;S-1===y?v.setNaN(b):i.position(y,b),l=v(),d=v(),f=v(),p=v(),m=v(),h=v(),g=v();e:for(let y=2;y6.25)continue e}const A=o[s[y]],E=o[s[y+2]];u(o[s[y-2]],l),u(A,d),u(E,f),v.sub(h,l,d),v.sub(g,d,f);const w=su(v.angle(h,g));w&&w>70&&(n[y]|=32)}}(p),function ULe(e){const{proteinInfo:t,hbonds:n,flags:r,bridges:i}=e,{offset:o,b:s}=n;let a,c;for(let u=0,l=t.residueIndices.length;up||(a=u+1,c=p,a!==c&&-1!==n.getDirectedEdgeIndex(c,a+1)&&(r[a]|=2,r[c]|=2,i[i.length]=new IT(a,c,0)),a=u,c=p-1,a!==c&&-1!==n.getDirectedEdgeIndex(c-1,a)&&(r[a]|=2,r[c]|=2,i[i.length]=new IT(c,a,0)),a=u,c=p,a!==c&&-1!==n.getDirectedEdgeIndex(c,a)&&(r[a]|=2,r[c]|=2,i[i.length]=new IT(c,a,1)),a=u+1,c=p-1,a!==c&&-1!==n.getDirectedEdgeIndex(c-1,a+1)&&(r[a]|=2,r[c]|=2,i[i.length]=new IT(c,a,1)))}i.sort((u,l)=>u.partner1>l.partner1?1:u.partner1je.indexOf(r,x))}),VO.apply(this,arguments)}function WLe(e,t,n){return"helix"===e?{kind:"helix",flags:n(t)}:"sheet"===e?{kind:"sheet",flags:n(t)}:"turn"===e||"bend"===e?{kind:"turn",flags:n(t)}:{kind:"none"}}function $Le(e){return e===cr.SecondaryStructureDssp.H||e===cr.SecondaryStructureDssp.G||e===cr.SecondaryStructureDssp.I?"helix":e===cr.SecondaryStructureDssp.B||e===cr.SecondaryStructureDssp.E?"sheet":e===cr.SecondaryStructureDssp.T?"turn":e===cr.SecondaryStructureDssp.S?"bend":"none"}function YLe(e){return vn.is(e,1)?cr.SecondaryStructureDssp.H:vn.is(e,4)?cr.SecondaryStructureDssp.E:vn.is(e,2)?cr.SecondaryStructureDssp.B:vn.is(e,8)?cr.SecondaryStructureDssp.G:vn.is(e,16)?cr.SecondaryStructureDssp.I:vn.is(e,64)?cr.SecondaryStructureDssp.T:vn.is(e,32)?cr.SecondaryStructureDssp.S:0}function XLe(e){return vn.is(e,1)?"H":vn.is(e,4)?"E":vn.is(e,2)?"B":vn.is(e,8)?"G":vn.is(e,16)?"I":vn.is(e,64)?"T":vn.is(e,32)?"S":"-"}function KLe(e){return vn.is(e,16)?cr.SecondaryStructureDssp.I:vn.is(e,1)?cr.SecondaryStructureDssp.H:vn.is(e,4)?cr.SecondaryStructureDssp.E:vn.is(e,2)?cr.SecondaryStructureDssp.B:vn.is(e,8)?cr.SecondaryStructureDssp.G:vn.is(e,64)?cr.SecondaryStructureDssp.T:vn.is(e,32)?cr.SecondaryStructureDssp.S:0}function ZLe(e){return vn.is(e,16)?"I":vn.is(e,1)?"H":vn.is(e,4)?"E":vn.is(e,2)?"B":vn.is(e,8)?"G":vn.is(e,64)?"T":vn.is(e,32)?"S":"-"}var vp;function See(e){let t="model";if(e){t="dssp";for(let n=0,r=e.models.length;n(i in c[o]||(c[o][i]={props:{...C.getDefaultValues(r.getParams(c))},data:Gh.create(void 0)}),c[o][i]),a=(c,u,l)=>{const d=s(c);c[o][i]={props:u,data:Gh.withValue(d.data,l)}};return{label:r.label,descriptor:r.descriptor,isHidden:r.isHidden,getParams:c=>{const u=C.clone(r.getParams(c));return C.setDefaultValues(u,s(c).props),u},defaultParams:r.defaultParams,isApplicable:r.isApplicable,attach:(c=ie(function*(u,l,d={},f){f&&l.customPropertyDescriptors.reference(r.descriptor,!0),"root"===r.type&&(l=l.root);const p=s(l.root).props,m=s(l),h=C.merge(r.defaultParams,p,d);if(m.data.value&&C.areEqual(r.defaultParams,m.props,h))return;const{value:g,assets:y}=yield r.obtain(u,l,h);l.customPropertyDescriptors.add(r.descriptor),l.customPropertyDescriptors.assets(r.descriptor,y),a(l,h,g)}),function(l,d){return c.apply(this,arguments)}),ref:(c,u)=>c.customPropertyDescriptors.reference(r.descriptor,u),get:c=>s(c).data,set:(c,u={},l)=>{"root"===r.type&&(c=c.root);const d=s(c),f=C.merge(r.defaultParams,d.props,u);C.areEqual(r.defaultParams,d.props,f)||(a(c,f,l),c.customPropertyDescriptors.assets(r.descriptor))},props:c=>s(c).props};var c}e.createProvider=t,e.createSimple=function n(r,i,o){const s={value:C.Value(o,{isHidden:!0})};return t({label:zu(r),descriptor:au({name:r}),isHidden:!0,type:i,defaultParams:s,getParams:()=>({value:C.Value(o,{isHidden:!0})}),isApplicable:()=>!0,obtain:(a=ie(function*(c,u,l){return{...C.getDefaultValues(s),...l}}),function(u,l,d){return a.apply(this,arguments)})});var a}}(vp||(vp={}));const Cee=See(),Xu=vp.createProvider({label:"Secondary Structure",descriptor:au({name:"molstar_computed_secondary_structure"}),type:"root",defaultParams:Cee,getParams:See,isApplicable:e=>!0,obtain:function(){var e=ie(function*(t,n,r){const i={...C.getDefaultValues(Cee),...r};switch(i.type.name){case"dssp":return{value:yield JLe(n,i.type.params)};case"model":return{value:yield e5e(n)}}});return function(n,r,i){return e.apply(this,arguments)}}()});function JLe(e,t){return zO.apply(this,arguments)}function zO(){return zO=ie(function*(e,t){const n=new Map;for(let r=0,i=e.unitSymmetryGroups.length;re.element,x:e=>e.unit.conformation.x(e.element),y:e=>e.unit.conformation.y(e.element),z:e=>e.unit.conformation.z(e.element),id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicConformation.atomId.value(e.element):Oi(),occupancy:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicConformation.occupancy.value(e.element):Oi(),B_iso_or_equiv:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicConformation.B_iso_or_equiv.value(e.element):Oi(),sourceIndex:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atomSourceIndex.value(e.element):e.element,type_symbol:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atoms.type_symbol.value(e.element):Oi(),label_atom_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atoms.label_atom_id.value(e.element):Oi(),auth_atom_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atoms.auth_atom_id.value(e.element):Oi(),label_alt_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atoms.label_alt_id.value(e.element):Oi(),label_comp_id:TT,auth_comp_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atoms.auth_comp_id.value(e.element):Oi(),pdbx_formal_charge:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.value(e.element):Oi(),vdw_radius:e=>Ee.isAtomic(e.unit)?v2(e.unit.model.atomicHierarchy.atoms.type_symbol.value(e.element)):Oi()};function TT(e){return Ee.isAtomic(e.unit)||Oi(),e.unit.model.atomicHierarchy.atoms.label_comp_id.value(e.element)}function jO(e){return Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.residues.label_seq_id.value(e.unit.residueIndex[e.element]):Oi()}function wee(e){Ee.isAtomic(e.unit)||Oi();const t=e.unit.model.sequence.byEntityKey[Ka(e)];return t&&t.sequence.microHet.get(jO(e))||[TT(e)]}const r5e={key:e=>Ee.isAtomic(e.unit)?e.unit.residueIndex[e.element]:Oi(),group_PDB:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.residues.group_PDB.value(e.unit.residueIndex[e.element]):Oi(),label_seq_id:jO,auth_seq_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.residues.auth_seq_id.value(e.unit.residueIndex[e.element]):Oi(),pdbx_PDB_ins_code:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(e.unit.residueIndex[e.element]):Oi(),isNonStandard:e=>Ee.isAtomic(e.unit)?wee(e).some(t=>"n"===e.unit.model.properties.chemicalComponentMap.get(t).mon_nstd_flag[0]):Oi(),hasMicroheterogeneity:function n5e(e){Ee.isAtomic(e.unit)||Oi();const t=e.unit.model.sequence.byEntityKey[Ka(e)];return t&&t.sequence.microHet.has(jO(e))},microheterogeneityCompIds:wee,secondary_structure_type:e=>{var t;Ee.isAtomic(e.unit)||Oi();const n=null===(t=Xu.get(e.structure).value)||void 0===t?void 0:t.get(e.unit.invariantId);return n?n.type[n.getIndex(e.unit.residueIndex[e.element])]:536870912},secondary_structure_key:e=>{var t;Ee.isAtomic(e.unit)||Oi();const n=null===(t=Xu.get(e.structure).value)||void 0===t?void 0:t.get(e.unit.invariantId);return n?n.key[n.getIndex(e.unit.residueIndex[e.element])]:-1},chem_comp_type:e=>Ee.isAtomic(e.unit)?e.unit.model.properties.chemicalComponentMap.get(TT(e)).type:Oi()},i5e={key:e=>Ee.isAtomic(e.unit)?e.unit.chainIndex[e.element]:Oi(),label_asym_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.chains.label_asym_id.value(e.unit.chainIndex[e.element]):Oi(),auth_asym_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.chains.auth_asym_id.value(e.unit.chainIndex[e.element]):Oi(),label_entity_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.chains.label_entity_id.value(e.unit.chainIndex[e.element]):Oi()},o5e={key:D2.key,entityKey:e=>Ee.isCoarse(e.unit)?e.unit.coarseElements.entityKey[e.element]:_p(),x:D2.x,y:D2.y,z:D2.z,asym_id:e=>Ee.isCoarse(e.unit)?e.unit.coarseElements.asym_id.value(e.element):_p(),entity_id:e=>Ee.isCoarse(e.unit)?e.unit.coarseElements.entity_id.value(e.element):_p(),seq_id_begin:e=>Ee.isCoarse(e.unit)?e.unit.coarseElements.seq_id_begin.value(e.element):_p(),seq_id_end:e=>Ee.isCoarse(e.unit)?e.unit.coarseElements.seq_id_end.value(e.element):_p(),sphere_radius:e=>Ee.isSpheres(e.unit)?e.unit.coarseConformation.radius[e.element]:_p("spheres"),sphere_rmsf:e=>Ee.isSpheres(e.unit)?e.unit.coarseConformation.rmsf[e.element]:_p("spheres"),gaussian_weight:e=>Ee.isGaussians(e.unit)?e.unit.coarseConformation.weight[e.element]:_p("gaussians"),gaussian_covariance_matrix:e=>Ee.isGaussians(e.unit)?e.unit.coarseConformation.covariance_matrix[e.element]:_p("gaussians")};function Ka(e){switch(e.unit.kind){case 0:return e.unit.model.atomicHierarchy.index.getEntityFromChain(e.unit.chainIndex[e.element]);case 1:return e.unit.model.coarseHierarchy.spheres.entityKey[e.element];case 2:return e.unit.model.coarseHierarchy.gaussians.entityKey[e.element]}}const s5e={key:Ka,id:e=>e.unit.model.entities.data.id.value(Ka(e)),type:e=>e.unit.model.entities.data.type.value(Ka(e)),src_method:e=>e.unit.model.entities.data.src_method.value(Ka(e)),pdbx_description:e=>e.unit.model.entities.data.pdbx_description.value(Ka(e)),formula_weight:e=>e.unit.model.entities.data.formula_weight.value(Ka(e)),pdbx_number_of_molecules:e=>e.unit.model.entities.data.pdbx_number_of_molecules.value(Ka(e)),details:e=>e.unit.model.entities.data.details.value(Ka(e)),pdbx_mutation:e=>e.unit.model.entities.data.pdbx_mutation.value(Ka(e)),pdbx_fragment:e=>e.unit.model.entities.data.pdbx_fragment.value(Ka(e)),pdbx_ec:e=>e.unit.model.entities.data.pdbx_ec.value(Ka(e)),subtype:e=>e.unit.model.entities.subtype.value(Ka(e)),prd_id:e=>{var t,n;return null!==(n=null===(t=e.unit.model.entities.prd_id)||void 0===t?void 0:t.value(Ka(e)))&&void 0!==n?n:""}},a5e=[],c5e={id:e=>e.unit.id,chainGroupId:e=>e.unit.chainGroupId,multiChain:e=>Ee.Traits.is(e.unit.traits,Ee.Trait.MultiChain),object_primitive:e=>e.unit.objectPrimitive,operator_name:e=>e.unit.conformation.operator.name,operator_key:e=>e.unit.conformation.operator.key,model_index:e=>e.unit.model.modelNum,model_label:e=>e.unit.model.label,model_entry_id:e=>e.unit.model.entryId,hkl:e=>e.unit.conformation.operator.hkl,spgrOp:e=>e.unit.conformation.operator.spgrOp,model_num:e=>e.unit.model.modelNum,pdbx_struct_assembly_id:e=>{var t;return(null===(t=e.unit.conformation.operator.assembly)||void 0===t?void 0:t.id)||ui.DefaultName},pdbx_struct_oper_list_ids:e=>{var t;return(null===(t=e.unit.conformation.operator.assembly)||void 0===t?void 0:t.operList)||a5e},struct_ncs_oper_id:e=>e.unit.conformation.operator.ncsId},Ze={constant:{true:e=>!0,false:e=>!1,zero:e=>0},atom:D2,residue:r5e,chain:i5e,entity:s5e,unit:c5e,coarse:o5e};class E2{add(t){let n=this.index.get(t.label_asym_id);n||(n=new Map,this.index.set(t.label_asym_id,n));let r=n.get(t.label_seq_id);return r||(r=[],n.set(t.label_seq_id,r)),!this._find(t,r)&&(r.push(t),!0)}hasLabelAsymId(t){return this.index.has(t)}has(t){var n,r;const i=Aee(t);if(!this.index.has(i))return;const o=this.index.get(i),s=Iee(t);if(!o.has(s))return;const a=o.get(s),c=Tee(t),u=Dee(t),l=Eee(t),d=null!==(n=Pee(t))&&void 0!==n?n:"1_555";for(const f of a)if(f.label_comp_id===c&&f.label_alt_id===u&&f.ins_code===l&&(!this.checkOperator||(null!==(r=f.operator_name)&&void 0!==r?r:"1_555")===d))return f}static getLabel(t,n=!1){var r;return`${t.label_asym_id} ${t.label_comp_id} ${t.label_seq_id}:${t.ins_code}:${t.label_alt_id}${n?" "+(null!==(r=t.operator_name)&&void 0!==r?r:"1_555"):""}`}static getEntryFromLocation(t){var n;return{label_asym_id:Aee(t),label_comp_id:Tee(t),label_seq_id:Iee(t),label_alt_id:Dee(t),ins_code:Eee(t),operator_name:null!==(n=Pee(t))&&void 0!==n?n:"1_555"}}_find(t,n){var r,i;for(const o of n)if(o.label_comp_id===t.label_comp_id&&o.label_alt_id===t.label_alt_id&&o.ins_code===t.ins_code&&(!this.checkOperator||(null!==(r=o.operator_name)&&void 0!==r?r:"1_555")===(null!==(i=t.operator_name)&&void 0!==i?i:"1_555")))return!0;return!1}constructor(t){var n;this.index=new Map,this.checkOperator=!1,this.checkOperator=null!==(n=t?.checkOperator)&&void 0!==n&&n}}const Aee=Ze.chain.label_asym_id,Iee=Ze.residue.label_seq_id,Tee=Ze.atom.label_comp_id,Dee=Ze.atom.label_alt_id,Eee=Ze.residue.pdbx_PDB_ins_code,Pee=Ze.unit.operator_name;function Qb(e,t,n){const r=t.subsetBuilder(!0);for(const i of n.units){if(0!==i.kind){r.setUnit(i.id,i.elements);continue}const{residueAtomSegments:o}=i.model.atomicHierarchy,s=t.unitMap.get(i.id).elements,a=i.elements;r.beginUnit(i.id);const c=en.transientSegments(o,a);for(;c.hasNext;){const u=c.move().index;for(let l=o.offsets[u],d=o.offsets[u+1];l(e.element.structure=n.structure,e.element.unit=n.unit,e.element.element=n.element,t(e))}function d5e(e,t){let n=0;e.element.structure=e.inputStructure;for(const r of e.inputStructure.units){e.element.unit=r;const i=r.elements;for(let o=0,s=i.length;on&&(n=c)}}return e.throwIfTimedOut(),n}function f5e(e,t){return function(r){const i=e(r);if(t.elementRadius){const o={...t,elementRadius:t.elementRadius,elementRadiusClosure:l5e(r,t.elementRadius),sourceMaxRadius:d5e(r,t.elementRadius)};if(pt.isSingleton(i)){const s=Mee(r,r.inputStructure,i.structure,o);return pt.Singletons(r.inputStructure,s)}{const s=new ZB(r.inputStructure);for(const a of i.structures)s.add(Mee(r,r.inputStructure,a,o));return s.getSelection()}}if(pt.isSingleton(i)){const o=HO(r,r.inputStructure,i.structure,t);return pt.Singletons(r.inputStructure,o)}{const o=new ZB(r.inputStructure);for(const s of i.structures)o.add(HO(r,r.inputStructure,s,t));return o.getSelection()}}}function p5e(e,t){return function(r){const i=e(r);if(0===pt.structureCount(i))return i;const o=pt.UniqueBuilder(r.inputStructure),s=a=>o.add(a);return pt.forEach(i,(a,c)=>{r.pushInputStructure(a),pt.forEach(t(r),s),r.popInputStructure(),c%10==0&&r.throwIfTimedOut()}),o.getSelection()}}function h5e(e,t){return function(r){const i=e(r);if(0===pt.structureCount(i))return i;const o=t(r);if(0===pt.structureCount(o))return pt.Empty(r.inputStructure);const s=pt.unionStructure(o),a=pt.UniqueBuilder(r.inputStructure);return pt.forEach(i,(c,u)=>{const l=NJ(s,c);0!==l.elementCount&&a.add(l),u%50==0&&r.throwIfTimedOut()}),a.getSelection()}}function m5e(e,t){return function(r){const i=e(r);if(0===pt.structureCount(i))return i;const o=t(r);if(0===pt.structureCount(o))return i;const s=pt.unionStructure(o),a=pt.UniqueBuilder(r.inputStructure);return pt.forEach(i,(c,u)=>{const l=XB(c,s);0!==l.elementCount&&a.add(l),u%50==0&&r.throwIfTimedOut()}),a.getSelection()}}function g5e(e){return function(n){const r=pt.LinearBuilder(n.inputStructure);return r.add(pt.unionStructure(e(n))),r.getSelection()}}function y5e(e,t){return function(r){const i=e(r),o=new Map,s=[];r.pushCurrentElement(),pt.forEach(i,(c,u)=>{r.element.structure=c;for(const l of c.units){r.element.unit=l;const d=l.elements;for(let f=0,p=d.length;f{let f=l;if(i)for(;;){const p=f.elementCount;if(f=Ree(a,n,f),f.elementCount===p)break}else for(let p=0;p=0)f.addElementRange(h,b.start,b.end);else if(d.hasLabelAsymId(x))for(y.setSegment(b);y.hasNext;){const S=y.move();u.element=h[S.start],d.has(u)&&f.addElementRange(h,S.start,S.end)}}f.commitUnit(),i.throwIfTimedOut()}const p=m2(i.inputStructure,[f.getStructure(),o]);if(n){const m=new mT(i.inputStructure),h=i.inputStructure.lookup3d;for(const g of p.units){const y=g.conformation,b=g.elements;for(let x=0,_=b.length;x<_;x++){const S=b[x];h.findIntoBuilderIf(y.x(S),y.y(S),y.z(S),t,m,S5e),m.addToUnit(g.id,S)}i.throwIfTimedOut()}return pt.Sequence(i.inputStructure,[m.getStructure()])}return pt.Sequence(i.inputStructure,[p])}}const x5e=Ze.entity.type;function S5e(e){return"water"===x5e(e)}class A5e{constructor(){this.vertices=new Map,this.edges=new Map}addVertex(t,n){this.vertices.has(n)||(this.vertices.set(n,t),this.edges.set(n,[]))}addEdge(t,n){const r=E2.getLabel(t),i=E2.getLabel(n);this.addVertex(t,r),this.addVertex(n,i),eo(this.edges.get(r),i),eo(this.edges.get(i),r)}addComponent(t,n){const r=E2.getLabel(t);if(!this.vertices.has(r))return void n.add(t);const i=new Set,o=new Set,s=[r];for(o.add(r),n.add(t);s.length>0;){const a=s.pop();i.add(a);const c=this.vertices.get(a);for(const u of this.edges.get(a)){if(i.has(u)||(s.push(u),o.has(u)))continue;o.add(u);const l=this.vertices.get(u);n.add(c.operator_name===l.operator_name?{...l,operator_name:t.operator_name}:l)}}}}var DT,ET,qO;function D5e(e,t){return n=>{const r=e(n),i=pt.LinearBuilder(n.inputStructure);return n.pushCurrentElement(),pt.forEach(r,(o,s)=>{n.currentStructure=o,t(n)&&i.add(o),s%100&&n.throwIfTimedOut()}),n.popCurrentStructure(),i.getSelection()}}function E5e(e){return t=>{const n=e(t),r=pt.LinearBuilder(t.inputStructure);if("singletons"===n.kind){if(n.structure.elementCount>0){const i=n.structure.units[0],o=Ve.create([i.getChild(je.ofSingleton(i.elements[0]))],{parent:t.inputStructure});r.add(o)}}else n.structures.length>0&&r.add(n.structures[0]);return r.getSelection()}}function PT(e,t,n){const{units:r}=e.currentStructure,i=e.pushCurrentElement();i.structure=e.currentStructure;for(const o of r){i.unit=o;const s=o.elements,a=t;if(a){for(let c=0,u=s.length;c{const i=e(r),o=function P5e(e,t,n){const r=new Set,i=t(e);return e.pushCurrentElement(),pt.forEach(i,(o,s)=>{e.currentStructure=o,PT(e,n,r),s%10&&e.throwIfTimedOut()}),e.popCurrentElement(),r}(r,t,n),s=pt.LinearBuilder(r.inputStructure);return r.pushCurrentStructure(),pt.forEach(i,(a,c)=>{r.currentStructure=a;const u=PT(r,n,new Set);Si.isSuperset(o,u)&&s.add(a),c%10&&r.throwIfTimedOut()}),r.popCurrentStructure(),s.getSelection()}}function R5e(e,t){return n=>{const r=pt.unionStructure(t(n)),i=pt.LinearBuilder(n.inputStructure);return pt.forEach(e(n),(o,s)=>{hT(r,o)&&i.add(o),s%10&&n.throwIfTimedOut()}),i.getSelection()}}function k5e(e){return t=>{const n={queryCtx:t,selection:e.query(t),target:e.target(t),maxRadius:e.maxRadius,minRadius:e.minRadius?Math.max(0,e.minRadius):0,elementRadius:e.elementRadius,invert:!!e.invert};return 0===n.minRadius&&typeof e.minRadius>"u"?function N5e({queryCtx:e,selection:t,target:n,maxRadius:r,invert:i}){const o=pt.unionStructure(n).lookup3d,s=pt.LinearBuilder(e.inputStructure),a=v.zero();return pt.forEach(t,(c,u)=>{const{units:l}=c;let d=!1;for(let f=0,p=l.length;f{let l=function T5e(e,t,n,r,i){return 0===t.elementCount||0===n.elementCount||(t.elementCount<=n.elementCount?ET.check(e,t,n,r,i):ET.check(e,n,t,r,i))}(e,s,c,r,o);i&&(l=!l),l&&a.add(c),u%10==0&&e.throwIfTimedOut()}),e.popCurrentElement(),a.getSelection()}(n):function B5e({queryCtx:e,selection:t,target:n,minRadius:r,maxRadius:i,invert:o,elementRadius:s}){const a=pt.unionStructure(n),c=pt.LinearBuilder(e.inputStructure);return e.pushCurrentElement(),pt.forEach(t,(u,l)=>{let d=function I5e(e,t,n,r,i,o){return 0===t.elementCount||0===n.elementCount||(t.elementCount<=n.elementCount?DT.check(e,t,n,r,i,o):DT.check(e,n,t,r,i,o))}(e,a,u,r,i,s);o&&(d=!d),d&&c.add(u),l%10==0&&e.throwIfTimedOut()}),e.popCurrentElement(),c.getSelection()}(n)}}function L5e({query:e,target:t,disjunct:n,invert:r,bondTest:i}){return o=>{const s=t(o);if(pt.isEmpty(s))return s;const a=e(o);if(pt.isEmpty(a))return a;const c={queryCtx:o,input:o.inputStructure,disjunct:n,target:pt.unionStructure(s)},u=pt.LinearBuilder(o.inputStructure);return o.pushCurrentBond(),o.atomicBond.setTestFn(i),pt.forEach(a,(l,d)=>{(function O5e(e,t){const{queryCtx:n,input:r,target:i,disjunct:o}=e,s=n.atomicBond,a=r.interUnitBonds;s.setStructure(r);for(const c of t.units){if(!Ee.isAtomic(c))continue;const u=r.unitMap.get(c.id),{offset:l,b:d,edgeProps:{flags:f,order:p,key:m}}=u.bonds,h=a.getConnectedUnits(c.id),g=h.length,y=c.elements,b=u.elements;for(let x=0,_=y.length;x<_;x++){const S=je.indexOf(b,y[x]);s.a.unit=u,s.b.unit=u;for(let A=l[S],E=l[S+1];A{const n=pt.UniqueBuilder(t.inputStructure);for(let r=0;r{n.add(i),r%100&&t.throwIfTimedOut()});return n.getSelection()}}function V5e(e){return 0===e.length?QB:1===e.length?e[0]:t=>{const n=[];for(let a=0;aa.hashCode,Ve.areUnitIdsAndIndicesEqual);pt.forEach(n[r],a=>o.add(a));const s=pt.UniqueBuilder(t.inputStructure);for(let a=0;a{o.has(c)&&s.add(c)}),t.throwIfTimedOut());return s.getSelection()}}function z5e(e){return e.currentStructure.elementCount}function G5e(e){return t=>{const n=e(t);return pt.structureCount(n)}}function j5e(e){return t=>PT(t,e,new Set)}!function(e){const t=v();function n(s,a,c,u,l,d,f){const{elements:p,conformation:m}=a,h=t;s.element.unit=a;let g=!1;for(let y=0,b=p.length;yf(m)===p},e.lt=function r(f,p){return m=>f(m)f(m)<=p},e.gt=function o(f,p){return m=>f(m)>p},e.gte=function s(f,p){return m=>f(m)>=p},e.inSet=function u(f,p){if(function t(f){return!!f&&!!f.has}(p))return m=>p.has(f(m));{if(0===p.length)return c;const m=new Set;for(let h=0;hm.has(f(h))}},e.and=function l(...f){switch(f.length){case 0:return a;case 1:return f[0];case 2:{const p=f[0],m=f[1];return h=>p(h)&&m(h)}case 3:{const p=f[0],m=f[1],h=f[2];return g=>p(g)&&m(g)&&h(g)}case 4:{const p=f[0],m=f[1],h=f[2],g=f[3];return y=>p(y)&&m(y)&&h(y)&&g(y)}case 5:{const p=f[0],m=f[1],h=f[2],g=f[3],y=f[4];return b=>p(b)&&m(b)&&h(b)&&g(b)&&y(b)}case 6:{const p=f[0],m=f[1],h=f[2],g=f[3],y=f[4],b=f[5];return x=>p(x)&&m(x)&&h(x)&&g(x)&&y(x)&&b(x)}default:{const p=f.length;return m=>{for(let h=0;hp(h)||m(h)}case 3:{const p=f[0],m=f[1],h=f[2];return g=>p(g)||m(g)||h(g)}case 4:{const p=f[0],m=f[1],h=f[2],g=f[3];return y=>p(y)||m(y)||h(y)||g(y)}case 5:{const p=f[0],m=f[1],h=f[2],g=f[3],y=f[4];return b=>p(b)||m(b)||h(b)||g(b)||y(b)}case 6:{const p=f[0],m=f[1],h=f[2],g=f[3],y=f[4],b=f[5];return x=>p(x)||m(x)||h(x)||g(x)||y(x)||b(x)}default:{const p=f.length;return m=>{for(let h=0;hZe.unit.operator_name(t.element),ui.DefaultName),Sr.pred.inSet(t=>Ze.chain.label_asym_id(t.element),e))})}function kee(e,t,n,r,i,o){const{spacegroup:s,ncsOperators:a}=e,c=[],{toFractional:u}=s.cell,l=v.transformMat4(v(),o,u),d=Ec.getSymmetryOperatorRef(s,t,n,r,i,l);if(a&&a.length)for(let f=0,p=a.length;f=0&&t[1]<=0&&n[1]>=0&&t[2]<=0&&n[2]>=0&&(a[0]=Ec.getSymmetryOperator(i,0,0,0,0));for(let c=0;cfunction Y5e(e,t,n){return YO.apply(this,arguments)}(f,l,d))},e.buildSymmetryRange=function i(l,d,f){return Oe.create("Build Symmetry",p=>function $5e(e,t,n,r){return $O.apply(this,arguments)}(p,l,d,f))},e.buildNcs=function o(l){return Oe.create("Build NCS",d=>function W5e(e,t){return WO.apply(this,arguments)}(d,l))},e.areUnitsEquivalent=s,e.UnitEquivalenceBuilder=a,e.computeTransformGroups=function c(l){const d=a();for(const p of l.units)d.add(p.id,p);const f=[];for(const p of d.groups)f.push(Ee.SymmetryGroup(p.map(m=>l.unitMap.get(m))));return f},e.areTransformGroupsEquivalent=function u(l,d){if(l.length!==d.length)return!1;for(let f=0,p=l.length;f0?[]:this.currentUnit}addElement(t){this.currentUnit[this.currentUnit.length]=t,this.elementCount++}addElementRange(t,n,r){for(let i=n;i1&&Ou(c);let d=a.getChild(je.ofSortedArray(c));const f=r.add(d.id,d);d!==f&&(d=f.applyOperator(d.id,d.conformation.operator,!0)),n[n.length]=d}return Ve.create(n,{parent:this.parent})}getStructure(){return this._getStructure(!1)}getStructureDeduplicate(){return this._getStructure(!0)}setSingletonLocation(t){const n=this.ids[0];t.unit=this.parent.unitMap.get(n),t.element=this.unitMap.get(n)[0]}get isEmpty(){return 0===this.elementCount}constructor(t,n){this.parent=t,this.isSorted=n,this.ids=[],this.unitMap=Lu.Mutable(),this.parentId=-1,this.currentUnit=[],this.elementCount=0}}function Bee(e,t){let n=1;for(;t--;)n*=e--;return n}class Q5e{move(){if(this.hasNext){let t=0,n=0,r=this.index;for(;r;r>>>=1,t++)1&r&&(this.value[n++]=this.array[t]);this.index=function Z5e(e){const t=e&-e,n=e+t;return n|((n&-n)/t>>1)-1}(this.index),this.hasNext=this.indexe?0:Bee(e,t)/Bee(t,t)}(t.length,n),this.maxIndex=1<0&&n<=t.length}}function Oee(e,t){const n=[],r=new Q5e(e,t);for(;r.hasNext;)n.push(r.move().slice());return n}const Xg=[],J5e={links:Xg,terminalLinks:Xg,elements:Xg,partialElements:Xg,getElementIndices:()=>Xg,getLinkIndices:()=>Xg,getTerminalLinkIndices:()=>Xg},cs=Bg("C"),P2=Bg("O"),e6e=[Hu.elementFingerprint([cs,cs,cs,P2]),Hu.elementFingerprint([cs,cs,cs,cs,P2]),Hu.elementFingerprint([cs,cs,cs,cs,cs,P2]),Hu.elementFingerprint([cs,cs,cs,cs,cs,cs,P2])];function t6e(e,t){let n=-1,r=-1,i=-1,o=-1;const{elements:s}=e,{type_symbol:a,label_atom_id:c}=e.model.atomicHierarchy.atoms,{b:u,offset:l}=e.bonds;for(let d=0,f=t.length;d0}get customPropertyDescriptors(){return this.state.customProps||(this.state.customProps=new Ql),this.state.customProps}get currentPropertyData(){return this.state.propertyData||(this.state.propertyData=Object.create(null)),this.state.propertyData}get inheritedPropertyData(){return this.parent?this.parent.currentPropertyData:this.currentPropertyData}get polymerResidueCount(){return-1===this.state.polymerResidueCount&&(this.state.polymerResidueCount=function v6e(e){const{units:t}=e;let n=0;for(let r=0,i=t.length;r0&&(n+=1);return n}(this)),this.state.polymerUnitCount}get uniqueElementCount(){return-1===this.state.uniqueElementCount&&(this.state.uniqueElementCount=function b6e(e){const{unitSymmetryGroups:t}=e;let n=0;for(let r=0,i=t.length;rsn.isCoarseGrained(t))}get isEmpty(){return 0===this.units.length}get hashCode(){return-1!==this.state.hashCode?this.state.hashCode:this.computeHash()}get transformHash(){return-1!==this.state.transformHash||(this.state.transformHash=ha(this.units.map(t=>t.id))),this.state.transformHash}computeHash(){let t=23;for(let n=0,r=this.units.length;n500?c6e:u6e}(t.length);n.reset();for(let r=0,i=t.length;rf+p.properties.saccharideComponentMap.size,0))return J5e;const t=[],n=[],r=[],i=[],o=new Map;function s(f,p,m){return`${f}|${p}|${m}`}function a(f,p){o.has(f)?o.get(f).push(p):o.set(f,[p])}function c(f,p){v.sub(r[f].geometry.direction,r[p].geometry.center,r[f].geometry.center),v.normalize(r[f].geometry.direction,r[f].geometry.direction)}const u=v();function l(f,p,m){const g=r[f].geometry;v.sub(g.direction,m.conformation.position(m.elements[p],u),g.center),v.normalize(g.direction,g.direction)}for(let f=0,p=e.units.length;f{h.connectedIndices.forEach(g=>{h.getEdges(g).forEach(({props:y,indexB:b})=>{if(!jn.isCovalent(y.flag))return;const x=e.unitMap.get(h.unitA),_=e.unitMap.get(h.unitB),S=d(x,g),A=d(_,b);if(S.length>0&&A.length>0){const E=S.length,w=A.length;for(let D=0,I=Math.max(E,w);Di[r.get(a.id)]+Fe.indexOf(a.elements,c)}}(this))}get model(){if(this.state.model)return this.state.model;if(this.state.representativeModel)return this.state.representativeModel;if(this.state.masterModel)return this.state.masterModel;const t=this.models;if(t.length>1)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}get masterModel(){return this.state.masterModel}get representativeModel(){return this.state.representativeModel}hasElement(t){return!!this.unitMap.has(t.unit.id)&&je.has(this.unitMap.get(t.unit.id).elements,t.element)}getModelIndex(t){return this.models.indexOf(t)}remapModel(t){const{dynamicBonds:n,interUnitBonds:r,parent:i}=this.state,o=[];for(const s of this.unitSymmetryGroups){const a=s.units[0].remapModel(t,n);o.push(a);for(let c=1,u=s.units.length;c0?X[0].id:0;for(let ne=0,de=X.length;ne2e5||p(X,ne)?g(X,U,oe,We,de):oe.addUnit(0,X,de,U,We?Ee.Trait.MultiChain:Ee.Trait.None):oe.addUnit(0,X,de,U,We?Ee.Trait.MultiChain:Ee.Trait.None)}const K=X.coarseHierarchy;return K.isDefined&&(K.spheres.count>0&&y(oe,X,X.coarseHierarchy.spheres,1),K.gaussians.count>0&&y(oe,X,X.coarseHierarchy.gaussians,2)),oe.getStructure()}function p(X,J){const ce=X.atomicHierarchy.index.getEntityFromChain(J);return"water"===X.entities.data.type.value(ce)}function m(X,J){const ce=X.atomicHierarchy.index.getEntityFromChain(J);return"polymer"===X.entities.data.type.value(ce)}function h(X,J,ce,be,ae){const{x:me,y:oe,z:K}=X.atomicConformation,ne={x:me,y:oe,z:K,indices:J},de=rd(ne,pp(ne),8192),{offset:we,count:Le,array:We}=de.buckets,U=(be?Ee.Trait.MultiChain:Ee.Trait.None)|(we.length>1?Ee.Trait.Partitioned:Ee.Trait.None);ce.beginChainGroup();for(let Y=0,ge=we.length;Y1?Ee.Trait.Partitioned:Ee.Trait.None);ce.beginChainGroup();for(let $e=0,tt=Se.length;$eEe.conformationId(J)).join("|"))},e.areUnitIdsEqual=E,e.areUnitIdsAndIndicesEqual=function w(X,J){if(X===J)return!0;if(!E(X,J))return!1;for(let ce=0,be=X.units.length;ce=this.structure.units.length?this.hasNext=!1:(this.current.unit=this.structure.units[this.unitIndex],this.elements=this.current.unit.elements,this.maxIdx=this.elements.length-1,0===this.maxIdx&&(this.hasNext=this.unitIndex+10,this.hasNext&&(this.elements=J.units[0].elements,this.maxIdx=this.elements.length-1,this.current.unit=J.units[0])}};const N=v();function V(X,J,ce){const{elements:be,conformation:ae}=X,me=N;let oe=Number.MAX_VALUE;for(let K=0,ne=be.length;KJ.units[0].polymerElements.length>0)}let H;var X;e.distance=function L(X,J){if(0===X.elementCount||0===J.elementCount)return 0;const{units:ce}=X;let be=Number.MAX_VALUE;for(let ae=0,me=ce.length;aeae(ne)))return;const oe=X.lookup3d,K=v();for(const ne of X.units){if(!ae(ne))continue;const de=ne.boundary.sphere;v.transformMat4(K,de.center,ne.conformation.operator.matrix);const we=oe.findUnitIndices(K[0],K[1],K[2],de.radius+be);for(let Le=0;Le=We.id||!ae(We)||!me(ne,We)||(We.elements.length>=ne.elements.length?J(ne,We):J(We,ne))}}},e.eachAtomicHierarchyElement=function $(X,{chain:J,residue:ce,atom:be}){const ae=nt.create(X);for(const me of X.units){if(0!==me.kind)continue;ae.unit=me;const{elements:oe}=me,K=en.transientSegments(me.model.atomicHierarchy.chainAtomSegments,oe),ne=en.transientSegments(me.model.atomicHierarchy.residueAtomSegments,oe);for(;K.hasNext;){const de=K.move();if(J&&(ae.element=oe[de.start],J(ae)),ce||be)for(ne.setSegment(de);ne.hasNext;){const we=ne.move();if(ce&&(ae.element=oe[we.start],ce(ae)),be)for(let Le=we.start,We=we.end;Le=be.largeResidueCount*ce?function O(X,J){const ce=ee(X);return ce.length>=1&&ce[0].units.length>J.highSymmetryUnitCount}(X,be)?H.Huge:H.Gigantic:function q(X,J){const ce=ee(X);return 1===ce.length&&ce[0].units.length>2&&ce[0].units[0].polymerElements.length0)return!1;return!0}function o(Q){let fe=0;for(const{indices:X}of Q.elements)fe+="number"==typeof X?w6e(X):X.length;return fe}function u(Q){return r(Q)?Q:e(Q.structure,[{unit:Q.elements[0].unit,indices:Fe.ofSingleton(Fe.start(Q.elements[0].indices))}])}function _(Q){return Q.length>3&&je.isRange(Q)?Ce.ofRange(Q[0],Q[Q.length-1]):je.ofSortedArray(Q)}function S(Q,fe){const X=[],J=new Set;for(const ce of Q.elements)if(E(ce))X[X.length]=ce;else if(0===ce.unit.kind){const be=ce.unit.elements,ae=ce.unit.model.atomicHierarchy,{label_alt_id:me}=ce.unit.model.atomicHierarchy.atoms,{index:oe,offsets:K}=ae.residueAtomSegments,ne=[],de=ce.indices,we=Fe.size(de);let Le=0;for(;Le=0){const Ne=me.value(ge);(!fe||Y||!Ne||J.has(Ne))&&(ne[ne.length]=Re)}}}X[X.length]={unit:ce.unit,indices:_(ne)}}else X[X.length]=ce;return e(Q.structure,X)}function A(Q){switch(Q.kind){case 0:return Q.model.atomicHierarchy.chainAtomSegments;case 1:return Q.model.coarseHierarchy.spheres.chainElementSegments;case 2:return Q.model.coarseHierarchy.gaussians.chainElementSegments}}function E(Q){return Q.unit.elements.length===Fe.size(Q.indices)}function w(Q,fe,X){const{index:J}=A(Q),ce=Q.elements;let be=0;for(let me=0,oe=ce.length;me0&&(X[X.length]={unit:Q,indices:_(ae)})}function D(Q,fe,X,J,ce){const{index:be}=A(Q.elements[0].unit),ae=new Set;for(let me=fe;me({unit:fe,indices:Fe.ofBounds(0,fe.elements.length)})))},e.none=function a(Q){return e(Q,[])},e.getFirstLocation=function c(Q,fe){if(r(Q))return;const X=Q.elements[0].unit,J=X.elements[Fe.getAt(Q.elements[0].indices,0)];return fe?(fe.structure=Q.structure,fe.unit=Q.elements[0].unit,fe.element=J,fe):nt.create(Q.structure,X,J)},e.firstElement=u,e.firstResidue=function l(Q){return r(Q)?Q:S(u(Q))},e.firstChain=function d(Q){return r(Q)?Q:I(u(Q))},e.toStructure=function f(Q){const fe=[];for(const X of Q.elements){const{unit:J,indices:ce}=X,be=new Int32Array(Fe.size(ce));Fe.forEach(ce,(ae,me)=>be[me]=J.elements[ae]),fe.push(J.getChild(je.ofSortedArray(be)))}return Ve.create(fe,{parent:Q.structure.parent})},e.forEachLocation=function p(Q,fe){if(e.isEmpty(Q))return;const X=nt.create(Q.structure);for(const J of Q.elements){const{unit:ce,indices:be}=J;X.unit=ce;const{elements:ae}=J.unit;for(let me=0,oe=Fe.size(be);me{if(!fe.unitMap.has(J.unit.id))return;const ce=fe.unitMap.get(J.unit.id),be=Fe.indexedIntersect(J.indices,J.unit.elements,ce.elements);Fe.size(be)>0&&X.push({unit:ce,indices:be})}),e(fe,X)},e.union=function h(Q,fe){if(Q.elements.length>fe.elements.length)return h(fe,Q);if(e.isEmpty(Q))return fe;const X=new Map;for(const ce of Q.elements)X.set(ce.unit.id,ce.indices);const J=[];for(const ce of fe.elements)X.has(ce.unit.id)?(J[J.length]={unit:ce.unit,indices:Fe.union(X.get(ce.unit.id),ce.indices)},X.delete(ce.unit.id)):J[J.length]=ce;return X.forEach((ce,be)=>{J[J.length]={unit:Q.structure.unitMap.get(be),indices:ce}}),e(Q.structure,J)},e.subtract=function g(Q,fe){const X=new Map;for(const ce of fe.elements)X.set(ce.unit.id,ce.indices);const J=[];for(const ce of Q.elements)if(X.has(ce.unit.id)){const be=Fe.subtract(ce.indices,X.get(ce.unit.id));if(0===Fe.size(be))continue;J[J.length]={unit:ce.unit,indices:be}}else J[J.length]=ce;return e(Q.structure,J)},e.intersect=function y(Q,fe){const X=new Map;for(const ce of Q.elements)X.set(ce.unit.id,ce.indices);const J=[];for(const ce of fe.elements){if(!X.has(ce.unit.id))continue;const be=Fe.intersect(X.get(ce.unit.id),ce.indices);0!==Fe.size(be)&&(J[J.length]={unit:ce.unit,indices:be})}return e(Q.structure,J)},e.areIntersecting=function b(Q,fe){if(Q.elements.length>fe.elements.length)return b(fe,Q);if(e.isEmpty(Q))return e.isEmpty(fe);const X=new Map;for(const J of Q.elements)X.set(J.unit.id,J.indices);for(const J of fe.elements)if(X.has(J.unit.id)&&Fe.areIntersecting(X.get(J.unit.id),J.indices))return!0;return!1},e.isSubset=function x(Q,fe){if(e.isEmpty(Q))return e.isEmpty(fe);const X=new Map;for(const ce of Q.elements)X.set(ce.unit.id,ce.indices);let J=!1;for(const ce of fe.elements)if(X.has(ce.unit.id)){if(!Fe.isSubset(X.get(ce.unit.id),ce.indices))return!1;J=!0}return J},e.extendToWholeResidues=S,e.extendToWholeChains=I,e.extendToWholeEntities=function T(Q){const fe=[],X=nt.create(Q.structure),J=new Set,{units:ce}=Q.structure;for(let be=0,ae=Q.elements.length;be12)be[be.length]=fe[K],be[be.length]=fe[ne-1];else for(let de=K;de{fe+=o(ce)});const X=new Float32Array(3*fe);let J=0;return Q.forEach(ce=>{$(ce,X,J),J+=3*o(ce)}),nd.ofPositions(X)},e.toExpression=function H(Q){if(e.isEmpty(Q))return ue.struct.generator.empty();const fe=Q.structure.models,X=new Map;for(const me of Q.elements){const{indices:oe}=me,{elements:K}=me.unit,ne=me.unit.conformation.operator.name;let de;X.has(ne)?de=X.get(ne).xs:(de=kr.create(),X.set(ne,{modelLabel:me.unit.model.label,modelIndex:me.unit.model.modelNum,xs:de}));for(let we=0,Le=Fe.size(oe);we1,oe.modelLabel,oe.modelIndex))}const be=new Map;for(let me=0,oe=J.length;me{const{ranges:oe,set:K}=me.atom,{opName:ne}=me.chain,de=ue.struct.atomProperty.core.operatorName(),we=ue.struct.atomProperty.core.sourceIndex(),Le=[];K.length>0&&(Le[Le.length]=ue.core.set.has([ue.core.type.set(K),we]));for(let We=0,U=oe.length/2;We1?ue.core.logic.or(Le):Le[0],"chain-test":ne.length>1?ue.core.set.has([ue.core.type.set(ne),de]):ue.core.rel.eq([de,ne[0]]),"entity-test":ue.core.logic.and([ue.core.rel.eq([ue.struct.atomProperty.core.modelLabel(),We]),ue.core.rel.eq([ue.struct.atomProperty.core.modelIndex(),U])])}))}else ae.push(ue.struct.generator.atomGroups({"atom-test":Le.length>1?ue.core.logic.or(Le):Le[0],"chain-test":ne.length>1?ue.core.set.has([ue.core.type.set(ne),de]):ue.core.rel.eq([de,ne[0]])}))}),ue.struct.modifier.union([1===ae.length?ae[0]:ue.struct.combinator.merge(ae.map(me=>ue.struct.modifier.union([me])))])}}(De||(De={})),function(e){function t(){return{elementCount:0,conformationCount:0,residueCount:0,chainCount:0,unitCount:0,structureCount:0,firstElementLoc:nt.create(void 0),firstConformationLoc:nt.create(void 0),firstResidueLoc:nt.create(void 0),firstChainLoc:nt.create(void 0),firstUnitLoc:nt.create(void 0),firstStructureLoc:nt.create(void 0)}}function n(c,u,l){const d=c.get(u)||0;c.set(u,d+l)}function r(c,u,l){const{indices:d,unit:f}=l,{elements:p}=f,m=Fe.size(d),h=new Map,g=new Map;if(m>0&&nt.set(c.firstElementLoc,u,f,p[Fe.start(d)]),m===p.length)c.unitCount+=1,1===c.unitCount&&nt.set(c.firstUnitLoc,u,f,p[Fe.start(d)]);else if(1===m){if(Ee.Traits.is(f.traits,Ee.Trait.MultiChain))return;c.elementCount+=1,1===c.elementCount&&nt.set(c.firstElementLoc,u,f,p[Fe.start(d)])}else if(Ee.isAtomic(f)){const{index:y,offsets:b}=f.model.atomicHierarchy.residueAtomSegments,{label_alt_id:x}=f.model.atomicHierarchy.atoms;let _=0;for(;_{if(g.get(D)===w){if(""!==D&&(c.conformationCount+=1,1===c.conformationCount))for(let I=b[E],R=b[E+1];I{g[_+1]-g[_]===x&&(c.chainCount+=1,1===c.chainCount&&(b=_))}),!(b<0))for(let x=d;x(i in c[o]||(c[o][i]={props:{...C.getDefaultValues(r.getParams(c))},data:Gh.create(void 0)}),c[o][i]),a=(c,u,l)=>{const d=s(c);c[o][i]={props:u,data:Gh.withValue(d.data,l)}};return{label:r.label,descriptor:r.descriptor,isHidden:r.isHidden,getParams:c=>{const u=C.clone(r.getParams(c));return C.setDefaultValues(u,s(c).props),u},defaultParams:r.defaultParams,isApplicable:r.isApplicable,attach:(c=ie(function*(u,l,d={},f){f&&l.customProperties.reference(r.descriptor,!0);const p=s(l),m=C.merge(r.defaultParams,p.props,d);if(p.data.value&&C.areEqual(r.defaultParams,p.props,m))return;const{value:h,assets:g}=yield r.obtain(u,l,m);l.customProperties.add(r.descriptor),l.customProperties.assets(r.descriptor,g),a(l,m,h)}),function(l,d){return c.apply(this,arguments)}),ref:(c,u)=>c.customProperties.reference(r.descriptor,u),get:c=>{var u;return null===(u=s(c))||void 0===u?void 0:u.data},set:(c,u={},l)=>{const d=s(c),f=C.merge(r.defaultParams,d.props,u);C.areEqual(r.defaultParams,d.props,f)||(a(c,f,l),c.customProperties.assets(r.descriptor))},props:c=>s(c).props};var c}e.createProvider=t,e.createSimple=function n(r,i,o){const s={value:C.Value(o,{isHidden:!0})};return t({label:zu(r),descriptor:au({name:r}),isHidden:!0,type:i,defaultParams:s,getParams:()=>({value:C.Value(o,{isHidden:!0})}),isApplicable:()=>!0,obtain:(a=ie(function*(c,u,l){return{...C.getDefaultValues(s),...l}}),function(u,l,d){return a.apply(this,arguments)})});var a}}(Kg||(Kg={})),function(e){var o;function t(o){if(!Er.is(o.sourceData))return!1;const{pdbx_sifts_xref_db_name:s,pdbx_sifts_xref_db_acc:a,pdbx_sifts_xref_db_num:c,pdbx_sifts_xref_db_res:u}=o.sourceData.data.db.atom_site;return s.isDefined&&a.isDefined&&c.isDefined&&u.isDefined}function i(o){if(!Er.is(o.sourceData))return;const{pdbx_sifts_xref_db_name:s,pdbx_sifts_xref_db_acc:a,pdbx_sifts_xref_db_num:c,pdbx_sifts_xref_db_res:u}=o.sourceData.data.db.atom_site;if(!(s.isDefined&&a.isDefined&&c.isDefined&&u.isDefined))return;const{atomSourceIndex:l}=o.atomicHierarchy,{count:d,offsets:f}=o.atomicHierarchy.residueAtomSegments,p=new Array(d),m=new Array(d),h=new Array(d),g=new Array(d);for(let y=0;y({}),isApplicable:o=>t(o),obtain:(o=ie(function*(s,a){return{value:i(a)}}),function(a,c){return o.apply(this,arguments)})}),e.isAvailable=t,e.getKey=function n(o){const s=o.unit.model,a=e.Provider.get(s).value;return a?a.accession[s.atomicHierarchy.residueAtomSegments.index[o.element]]:""},e.getLabel=function r(o){const s=o.unit.model,a=e.Provider.get(s).value;if(!a)return;const c=s.atomicHierarchy.residueAtomSegments.index[o.element],u=a.dbName[c];return u?`${u} ${a.accession[c]} ${a.num[c]} ${a.residue[c]}`:void 0}}(sf||(sf={}));function M2(e,t){if(Er.is(e.sourceData))return e.sourceData.data.db[t]}function Hee(e){if(0===e.length)return[];if(1===e.length)return e[0].entityIndices;const t=kr.create();for(const n of e)for(const r of n.entityIndices)kr.add(t,r,r);return Ou(t.array),t.array}function Zu(e,t){return{name:e,instance({structures:n}){if(t&&!t(n[0]))return Bi.Category.Empty;const r=n[0].model;if(!Er.is(r.sourceData))return Bi.Category.Empty;const i=r.sourceData.data.db[e];return i&&i._rowCount?Bi.Category.ofTable(i):Bi.Category.Empty}}}var qee=Bi.Category;KO("struct_asym"),KO("entity_poly"),KO("entity_poly_seq");function KO(e){return{name:e,instance:({structures:t,cache:n})=>function W6e(e,t,n){const r=M2(e[0].model,t);if(!r)return qee.Empty;const{entity_id:i}=r,o=n.uniqueEntityIds||(n.uniqueEntityIds=function O6e(e){if(0===e.length)return new Set;const t=e[0].model.entities.data.id;return new Set(Hee(e).map(n=>t.value(n)))}(e)),s=te.indicesOf(i,a=>o.has(a));return qee.ofTable(r,s)}(t,e,n)}}var ZO;!function(e){e.create=function t(n){const r=Array.isArray(n)?n:[n];return{structures:r,firstModel:r[0].model,cache:Object.create(null)}}}(ZO||(ZO={}));function QO(e){return e.units.every(t=>t.conformation.operator.isIdentity)}function JO(e){return QO(e)&&e.units.every(t=>!t.conformation.operator.assembly&&!t.conformation.operator.suffix)}var e4;Zu("entry"),Zu("exptl"),Zu("cell",QO),Zu("symmetry",QO),Zu("pdbx_struct_assembly",JO),Zu("pdbx_struct_assembly_gen",JO),Zu("pdbx_struct_oper_list",JO),Zu("pdbx_entity_branch"),Zu("pdbx_entity_branch_link"),Zu("pdbx_branch_scheme"),Zu("struct_conn"),Zu("atom_sites"),function(e){e.AtomSitePositionsFieldNames=new Set(["id","Cartn_x","Cartn_y","Cartn_z"])}(e4||(e4={}));const Q6e={molstar_atom_site_operator_mapping:{label_asym_id:te.Schema.Str(),auth_asym_id:te.Schema.Str(),operator_name:te.Schema.Str(),suffix:te.Schema.Str(),assembly_id:te.Schema.Str(),assembly_operator_id:te.Schema.Int(),symmetry_operator_index:te.Schema.Int(),symmetry_hkl:te.Schema.Vector(3),ncs_id:te.Schema.Int()}},$ee=(e,t)=>typeof t[e].operator.assembly>"u"?1:0,t4=(e,t)=>-1===t[e].operator.spgrOp?1:0;function ev(e,t){return t?1===t.length?uu(t.charCodeAt(0),e):2===t.length?uu(t.charCodeAt(0),uu(t.charCodeAt(1),e)):`${e} ${t}`:e}function r8e(e,t,n,r){if(e.has(t)){const i=e.get(t);i.has(n)||i.set(n,r)}else{const i=new Map;e.set(t,i),i.set(n,r)}}function i8e(e){throw new Error(`Missing entity entry for entity id '${e}'.`)}Bi.fields().str("label_asym_id",(e,t)=>t[e].label_asym_id).str("auth_asym_id",(e,t)=>t[e].auth_asym_id).str("operator_name",(e,t)=>t[e].operator.name).str("suffix",(e,t)=>t[e].operator.suffix).str("assembly_id",(e,t)=>{var n;return(null===(n=t[e].operator.assembly)||void 0===n?void 0:n.id)||""},{valueKind:$ee}).int("assembly_operator_id",(e,t)=>{var n;return(null===(n=t[e].operator.assembly)||void 0===n?void 0:n.operId)||0},{valueKind:$ee}).int("symmetry_operator_index",(e,t)=>t[e].operator.spgrOp,{valueKind:t4}).vec("symmetry_hkl",[(e,t)=>t[e].operator.hkl[0],(e,t)=>t[e].operator.hkl[1],(e,t)=>t[e].operator.hkl[2]],{valueKind:t4}).int("ncs_id",(e,t)=>t[e].operator.ncsId,{valueKind:t4}).getFields();const R2=dO.EmptyResidueKey();class s8e{getEntityFromChain(t){return this.map.chain_index_entity_index[t]}findEntity(t){const n=this.map.label_asym_id.get(t);return void 0!==n?n:-1}findChainLabel(t){const n=this.entityIndex(t.label_entity_id);if(n<0||!this.map.entity_index_label_asym_id.has(n))return-1;const r=this.map.entity_index_label_asym_id.get(n);return r&&r.has(t.label_asym_id)?r.get(t.label_asym_id):-1}findChainAuth(t){if(!this.map.auth_asym_id_auth_seq_id.has(t.auth_asym_id))return-1;const n=this.map.auth_asym_id_auth_seq_id.get(t.auth_asym_id);return n.has(t.auth_seq_id)?n.get(t.auth_seq_id):-1}findResidue(t,n,r,i){let o;1===arguments.length?o=t:(R2.label_entity_id=t,R2.label_asym_id=n,R2.auth_seq_id=r,R2.pdbx_PDB_ins_code=i,o=R2);const s=this.findChainLabel(o);if(s<0)return-1;const a=this.map.chain_index_auth_seq_id.get(s),c=ev(o.auth_seq_id,o.pdbx_PDB_ins_code||"");return a.has(c)?a.get(c):-1}findResidueLabel(t){const n=this.findChainLabel(t);if(n<0)return-1;const r=this.map.chain_index_label_seq_id.get(n),i=ev(t.label_seq_id,t.pdbx_PDB_ins_code||"");return r.has(i)?r.get(i):-1}findResidueAuth(t){const n=this.findChainAuth(t);if(n<0)return-1;const r=this.map.chain_index_auth_seq_id.get(n),i=ev(t.auth_seq_id,t.pdbx_PDB_ins_code||"");return r.has(i)?r.get(i):-1}findResidueInsertion(t){const n=this.findChainLabel(t);if(n<0)return-1;const r=this.map.chain_index_label_seq_id.get(n),i=ev(t.label_seq_id,t.pdbx_PDB_ins_code||"");if(r.has(i))return r.get(i);const o=je.findPredecessorIndex(this.map.label_seq_id,t.label_seq_id),s=Gg.chainStartResidueIndex(this.map.segments,n);if(o=a?a:o}findAtom(t){const n=this.findResidue(t);return n<0?-1:typeof t.label_alt_id>"u"?n4(this.residueOffsets[n],this.residueOffsets[n+1],this.map.label_atom_id,t.label_atom_id):r4(this.residueOffsets[n],this.residueOffsets[n+1],this.map.label_atom_id,this.map.label_alt_id,t.label_atom_id,t.label_alt_id)}findAtomAuth(t){const n=this.findResidueAuth(t);return n<0?-1:typeof t.label_alt_id>"u"?n4(this.residueOffsets[n],this.residueOffsets[n+1],this.map.auth_atom_id,t.auth_atom_id):r4(this.residueOffsets[n],this.residueOffsets[n+1],this.map.auth_atom_id,this.map.label_alt_id,t.auth_atom_id,t.label_alt_id)}findAtomOnResidue(t,n,r){return typeof r>"u"?n4(this.residueOffsets[t],this.residueOffsets[t+1],this.map.label_atom_id,n):r4(this.residueOffsets[t],this.residueOffsets[t+1],this.map.label_atom_id,this.map.label_alt_id,n,r)}findAtomsOnResidue(t,n){return function a8e(e,t,n,r){for(let i=e;i=c[u+1]&&(u+=1,l=0),s[d]=++l;i.label_seq_id=te.ofIntArray(s)}return Xn.columnToArray(i,"label_seq_id",Int32Array),Xn.columnToArray(i,"auth_seq_id",Int32Array),{atoms:r,residues:i,chains:o,atomSourceIndex:t}}(e,t,s),c=function h8e(e,t){const n=new Map;if(!Er.is(t))return n;const{molstar_atom_site_operator_mapping:r}=Zd(Q6e,t.data.frame);if(0===r._rowCount)return n;const i=new Map,o=new Map;for(let l=0;l-1,findChainKey:()=>-1,getEntityFromChain:()=>-1,count:0,entity_id:te.Undefined(0,te.Schema.str),asym_id:te.Undefined(0,te.Schema.str),seq_id_begin:te.Undefined(0,te.Schema.int),seq_id_end:te.Undefined(0,te.Schema.int),chainElementSegments:en.create([]),polymerRanges:wr.ofSortedRanges([]),gapRanges:wr.ofSortedRanges([])};var Kee=function(e){return e.Empty={isDefined:!1,spheres:Xee,gaussians:Xee},e}(Kee||{});function g8e(e,t,n){if(e.has(t))return e.get(t);const r=n.index++;return e.set(t,r),r}function y8e(e,t){if(e.has(t))return e.get(t);const n=new Map;return e.set(t,n),n}function v8e(e){throw new Error(`Missing entity entry for entity id '${e}'.`)}function Zee(e,t){const{entity_id:n,asym_id:r,seq_id_begin:i,seq_id_end:o,count:s,chainElementSegments:a}=e,c=new Map,u=new Map,l={index:0},d=new Int32Array(s),f=new Int32Array(s),p=new Int32Array(a.count);for(let y=0;y{const c=r(s);if(c<0)return-1;const u=t.get(c);return u.has(a)?u.get(a):-1},findSequenceKey:(s,a,c)=>{const u=r(s);if(u<0)return-1;const l=t.get(u);if(void 0===l)return-1;const d=l.get(a);if(void 0===d)return-1;const f=n.get(d),{elementIndices:p,seqRanges:m}=f,h=wr.firstIntersectionIndex(m,Fe.ofSingleton(c));return-1!==h?p[h]:-1}}}(t,u,c);return{chainKey:d,entityKey:f,findSequenceKey:h,findChainKey:m,getEntityFromChain:y=>p[y]}}function Qee(e,t){const n=[],r=[],i=en.transientSegments(e.chainElementSegments,Ce.ofBounds(0,e.count)),{seq_id_begin:o,seq_id_end:s}=e;for(;i.hasNext;){const{start:a,end:c}=i.move();let u=-1,l=-1;for(let d=a;d1&&(n.push(u,d-1),r.push(d-1,d),u=d),d===c-1&&n.push(u,d),l=f}}return{polymerRanges:wr.ofSortedRanges(n),gapRanges:wr.ofSortedRanges(r)}}const Jee={hierarchy:Kee.Empty,conformation:void 0};function C8e(e,t,n){const r=[0];for(let i=1,o=e.rowCount;i{if(t.has(n))return t.get(n);const r=e(n);return t.set(n,r),r}}function T8e(e){const t=new Map,n=(i,o,s)=>`${i}|${o}|${s}`,r=e.pdbx_unobs_or_zero_occ_residues;for(let i=0,o=r._rowCount;it.has(n(i,o,s)),get:(i,o,s)=>t.get(n(i,o,s)),size:t.size}}function D8e(e){const t=new Map;if(e.chem_comp._rowCount>0){const{id:n}=e.chem_comp;for(let r=0,i=n.rowCount;r{t.set(r,function sFe(e){return{formula:"",formula_weight:0,id:e,name:e,mon_nstd_flag:Wb.has(e)?"y":"n",pdbx_synonyms:[],type:KQ(e)}}(r))});return t}function E8e(e){const t=new Map;if(e.pdbx_chem_comp_identifier._rowCount>0){const{comp_id:n,type:r,identifier:i}=e.pdbx_chem_comp_identifier;for(let o=0,s=n.rowCount;o0){const{id:n,type:r}=e.chem_comp;for(let i=0,o=n.rowCount;i{!t.has(i)&&n.has(i)&&t.set(i,r)})}return t}!function(e){let t;var u;(u=t=e.Kind||(e.Kind={})).Protein="protein",u.RNA="RNA",u.DNA="DNA",u.Generic="generic",e.getSequenceString=function n(u){const l=u.code.toArray();return(l instanceof Array?l:Array.from(l)).join("")},e.ofResidueNames=function o(u,l){if(0===l.rowCount)throw new Error("cannot be empty");const d=function r(u){for(let l=0,d=Math.min(u.rowCount,10);l"X";break;default:Rr()}return l&&l.size>0?f=>{const p=d(f);return"X"===p&&l.has(f)?d(l.get(f)):p}:d}(l),m=[],h=[],g=[],y=new Map;let b=0;const x=new Map;for(let S=0,A=f.rowCount;S{const I=p(D);return"X"===I?D:I});_[S]=`(${w.join("|")})`}else _[S]="X"===m[S]?h[S]:m[S]}this.length=b,this.code=te.ofStringArray(m),this.compId=te.ofStringArray(h),this.seqId=te.ofIntArray(g),this.label=te.ofStringArray(_),this.microHet=y,this.indexMap=x}}e.ofSequenceRanges=function a(u,l){return new c(t.Generic,u,l)};class c{index(l){return l-this.minSeqId}constructor(l,d,f){this.kind=l,this.seqIdStart=d,this.seqIdEnd=f,this.microHet=new Map;let p=0,m=Number.MAX_SAFE_INTEGER;for(let g=0,y=this.seqIdStart.rowCount;gg+m+1,rowCount:h,schema:te.Schema.int}),this.compId=te.ofConst("",h,te.Schema.str),this.length=h,this.minSeqId=m}}}(k2||(k2={})),function(e){const t={byEntityKey:{},sequences:[]};function n(...a){const c=[],u={};for(let l=0,d=a.length;l{const t=new Set,{label_comp_id:n,auth_comp_id:r}=e.atom_site,i=n.isDefined?n:r;for(let o=0,s=i.rowCount;o0?yield function F8e(e,t,n,r){return u4.apply(this,arguments)}(n,e,r,t):yield function N8e(e,t,n,r){return a4.apply(this,arguments)}(n,e,r,t);for(let o=0;o0?i[i.length-1]:void 0);i.push(d),a=c}}return i}),a4.apply(this,arguments)}function c4(e,t){const n=new Map,r=e._rowCount;let i=0;for(;iF._dynamicPropertyData[u]||{index:0,size:1},set:(F,G)=>F._dynamicPropertyData[u]=G};const l="__AsymIdCount__";e.AsymIdCount={get(F){if(F._dynamicPropertyData[l])return F._dynamicPropertyData[l];const G=function RMe(e){const t=new Set,n=new Set;return e.properties.structAsymMap.forEach(({auth_id:r},i)=>{t.add(r),n.add(i)}),{auth:t.size,label:n.size}}(F);return F._dynamicPropertyData[l]=G,G}},e.AsymIdOffset=Kg.createSimple("asym_id_offset","static"),e.Index=Kg.createSimple("index","static"),e.MaxIndex=Kg.createSimple("max_index","static"),e.getRoot=function d(F){return F.parent||F},e.areHierarchiesEqual=function f(F,G){return F.atomicHierarchy===G.atomicHierarchy&&F.coarseHierarchy===G.coarseHierarchy};const p="__CoordinatesHistory__";e.CoordinatesHistory={get:F=>F._staticPropertyData[p],set:(F,G)=>F._staticPropertyData[p]=G};const m="__CoarseGrained__";function h(F){let G=e.CoarseGrained.get(F);if(void 0===G){let L=0;const{polymerType:z}=F.atomicHierarchy.derived.residue;for(let q=0;qF._staticPropertyData[m],set:(F,G)=>F._staticPropertyData[m]=G},e.isCoarseGrained=h,e.hasCarbohydrate=function g(F){return F.properties.saccharideComponentMap.size>0},e.hasProtein=function y(F){const{subtype:G}=F.entities;for(let L=0,z=G.rowCount;L=0)return!0;return!1}function I(F){if(!Er.is(F.sourceData))return!1;const{db:G}=F.sourceData.data;for(let L=0;L=0)return!0;return!1}function T(F){if(!Er.is(F.sourceData)||!D(F))return!1;const{db:G}=F.sourceData.data,{status_code_sf:L}=G.pdbx_database_status;return L.isDefined&&"REL"===L.value(0)}function M(F){if(!Er.is(F.sourceData))return!1;const{db:G}=F.sourceData.data,{db_name:L,content_type:z}=G.pdbx_database_related;for(let j=0,Z=G.pdbx_database_related._rowCount;j=0)return!0;return!1},e.hasXrayMap=T,e.hasEmMap=M,e.hasDensityMap=N,e.probablyHasDensityMap=function V(F){if(!Er.is(F.sourceData))return!1;const{db:G}=F.sourceData.data;return N(F)||_(F)&&(!G.exptl.method.isDefined||D(F)&&(!G.pdbx_database_status.status_code_sf.isDefined||2===G.pdbx_database_status.status_code_sf.valueKind(0))||I(F)&&!G.pdbx_database_related.db_name.isDefined)}}(sn||(sn={})),function(e){e.getCifDataSource=function t(d,f,p){if(!f)return{rowCount:0};if(p&&p[f.id])return p[f.id];const m=f.getElements(d),h={data:m,rowCount:m.elements.length};return p&&(p[f.id]=h),h},e.fromAtomMap=function n(d){return new mte(d)},e.fromAtomArray=function r(d){return new mte(l4(d))};const i=d=>d.atomicHierarchy.residueAtomSegments;e.fromResidueMap=function o(d){return new NT("residue",d,i,0)},e.fromResidueArray=function s(d){return new NT("residue",l4(d),i,0)};const a=d=>d.atomicHierarchy.chainAtomSegments;e.fromChainMap=function c(d){return new NT("chain",d,a,0)},e.fromChainArray=function u(d){return new NT("chain",l4(d),a,0)},e.fromEntityMap=function l(d){return new B8e(d)}}(hte||(hte={}));class NT{has(t){return this.map.has(t)}get(t){return this.map.get(t)}getStructureElements(t){const n=t.models;if(1!==n.length)throw new Error("Only works on structures with a single model.");const r=new Set,i=t.unitSymmetryGroups,o=[],s=this.segmentGetter(n[0]);for(const a of i){const c=a.units[0];if(c.kind!==this.kind)continue;const u=en.transientSegments(s,c.elements);for(;u.hasNext;){const l=u.move();!this.has(l.index)||r.has(l.index)||(r.add(l.index),o[o.length]=nt.create(t,c,c.elements[l.start]))}}return o.sort((a,c)=>a.element-c.element),o}getElements(t){const n=this.segmentGetter(t.model).index,r=this.getStructureElements(t);return{elements:r,property:i=>this.get(n[r[i].element])}}constructor(t,n,r,i){this.level=t,this.map=n,this.segmentGetter=r,this.id=Hr.create22(),this.kind=i}}class mte{has(t){return this.map.has(t)}get(t){return this.map.get(t)}getStructureElements(t){if(1!==t.models.length)throw new Error("Only works on structures with a single model.");const r=new Set,i=t.unitSymmetryGroups,o=[];for(const s of i){const a=s.units[0];if(a.kind!==this.kind)continue;const c=a.elements;for(let u=0,l=c.length;us.element-a.element),o}getElements(t){const n=this.getStructureElements(t);return{elements:n,property:r=>this.get(n[r].element)}}constructor(t){this.map=t,this.id=Hr.create22(),this.level="atom",this.kind=0}}class B8e{has(t){return this.map.has(t)}get(t){return this.map.get(t)}getStructureElements(t){const n=t.models;if(1!==n.length)throw new Error("Only works on structures with a single model.");const r=n[0].atomicHierarchy.index,i=new Set,o=t.unitSymmetryGroups,s=[],a=n[0].atomicHierarchy.chainAtomSegments;for(const c of o){const u=c.units[0];if(u.kind!==this.kind)continue;const l=en.transientSegments(a,u.elements);for(;l.hasNext;){const d=l.move(),f=r.getEntityFromChain(d.index);!this.has(f)||i.has(f)||(i.add(f),s[s.length]=nt.create(t,u,u.elements[d.start]))}}return s.sort((c,u)=>c.element-u.element),s}getElements(t){const n=this.getStructureElements(t),r=t.model.atomicHierarchy.chainAtomSegments.index,i=t.model.atomicHierarchy.index;return{elements:n,property:o=>this.get(i.getEntityFromChain(r[n[o].element]))}}constructor(t){this.map=t,this.id=Hr.create22(),this.level="entity",this.kind=0}}!function(e){function t(a){const c=new DataView(a.buffer);return Object.assign(a.subarray(0),{readInt8:u=>c.getInt8(u),readUInt8:u=>c.getUint8(u),writeInt8:(u,l)=>c.setInt8(l,u),writeUInt8:(u,l)=>c.setUint8(l,u),readInt16LE:u=>c.getInt16(u,!0),readInt32LE:u=>c.getInt32(u,!0),readUInt16LE:u=>c.getUint16(u,!0),readUInt32LE:u=>c.getUint32(u,!0),readFloatLE:u=>c.getFloat32(u,!0),readDoubleLE:u=>c.getFloat64(u,!0),writeInt16LE:(u,l)=>c.setInt16(l,u,!0),writeInt32LE:(u,l)=>c.setInt32(l,u,!0),writeUInt16LE:(u,l)=>c.setUint16(l,u,!0),writeUInt32LE:(u,l)=>c.setUint32(l,u,!0),writeFloatLE:(u,l)=>c.setFloat32(l,u,!0),writeDoubleLE:(u,l)=>c.setFloat64(l,u,!0),readInt16BE:u=>c.getInt16(u,!1),readInt32BE:u=>c.getInt32(u,!1),readUInt16BE:u=>c.getUint16(u,!1),readUInt32BE:u=>c.getUint32(u,!1),readFloatBE:u=>c.getFloat32(u,!1),readDoubleBE:u=>c.getFloat64(u,!1),writeInt16BE:(u,l)=>c.setInt16(l,u,!1),writeInt32BE:(u,l)=>c.setInt32(l,u,!1),writeUInt16BE:(u,l)=>c.setUint16(l,u,!1),writeUInt32BE:(u,l)=>c.setUint32(l,u,!1),writeFloatBE:(u,l)=>c.setFloat32(l,u,!1),writeDoubleBE:(u,l)=>c.setFloat64(l,u,!1),copy:(u,l,d,f)=>(l=Ds(l,0),d=Ds(d,0),f=Ds(f,a.length),u.set(a.subarray(d,f),l),f-d)})}function i(a,c,u,l,d){for(let f=0,p=u;f>8&255}},e.ensureLittleEndian=function s(a,c,u,l,d){e.IsNativeEndianLittle||!u||l<=1||i(a,c,u,l,d)}}(cd||(cd={})),function(e){e.fromBuffer=function t(n,r){return{name:r,readBuffer:(i,o,s,a)=>{let c,u;if("number"==typeof o){s=Ds(s,o);const l=i,d=Math.min(n.length,l+s);c=d-l,u=cd.fromUint8Array(new Uint8Array(n.buffer,l,d-l))}else{s=Ds(s,o.length);const l=i,d=Math.min(n.length,l+s);o.set(n.subarray(l,d),a),c=d-l,u=o}return s!==c&&console.warn(`byteCount ${s} and bytesRead ${c} differ`),Promise.resolve({bytesRead:c,buffer:u})},writeBuffer:(i,o,s)=>(s=Ds(s,o.length),console.error(".writeBuffer not implemented for FileHandle.fromBuffer"),Promise.resolve(0)),writeBufferSync:(i,o,s)=>(s=Ds(s,o.length),console.error(".writeSync not implemented for FileHandle.fromBuffer"),0),close:Ag}}}(FT||(FT={}));var us=function(e){return e.Float32="float32",e.Int8="int8",e.Int16="int16",e.Uint16="uint16",e}(us||{});function gte(e){return e===us.Float32?4:e===us.Int16||e===us.Uint16?2:1}function O8e(e,t,n=0,r){return e===us.Float32?new Float32Array(t,n,r):e===us.Int16?new Int16Array(t,n,r):e===us.Uint16?new Uint16Array(t,n,r):new Int8Array(t,n,r)}function d4(){return d4=ie(function*(e,t,n,r,i,o){return yield t.readBuffer(n,e.readBuffer,r,i),e.elementByteSize>1&&(void 0!==o&&o!==cd.IsNativeEndianLittle||!cd.IsNativeEndianLittle)&&cd.flipByteOrder(e.readBuffer,e.valuesBuffer,r,e.elementByteSize,i),e.values}),d4.apply(this,arguments)}function f4(){return f4=ie(function*(e){const{buffer:n}=yield e.readBuffer(0,1024),r=String.fromCharCode(n.readUInt8(208),n.readUInt8(209),n.readUInt8(210),n.readUInt8(211));if("MAP "!==r)throw new Error('ccp4 format error, missing "MAP " string');const i=[n.readUInt8(212),n.readUInt8(213)];let o=!1;68===i[0]&&65===i[1]?o=!0:17===i[0]&&17===i[1]?o=!1:n.readInt32LE(12)<=16&&(o=!0);const s=o?u=>n.readInt32LE(4*u):u=>n.readInt32BE(4*u),a=o?u=>n.readFloatLE(4*u):u=>n.readFloatBE(4*u);return{header:{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:a(10),yLength:a(11),zLength:a(12),alpha:a(13),beta:a(14),gamma:a(15),MAPC:s(16),MAPR:s(17),MAPS:s(18),AMIN:a(19),AMAX:a(20),AMEAN:a(21),ISPG:s(22),NSYMBT:s(23),LSKFLG:s(24),SKWMAT:[],SKWTRN:[],userFlag1:s(39),userFlag2:s(40),originX:a(49),originY:a(50),originZ:a(51),MAP:r,MACHST:i,ARMS:a(54)},littleEndian:o}}),f4.apply(this,arguments)}function p4(){return p4=ie(function*(e,t,n,r,i,o){if(bte(e)){const s=3*i;yield n.readBuffer(r,t.readBuffer,i,s);const a=new Int8Array(t.valuesBuffer.buffer,s),c=(e.AMAX-e.AMIN)/255,u=.5*(e.AMIN+e.AMAX+c);for(let l=0,d=i;le.readInt16LE(2*i):i=>e.readInt16BE(2*i),r=1/n(17);return{xStart:n(0),yStart:n(1),zStart:n(2),xExtent:n(3),yExtent:n(4),zExtent:n(5),xRate:n(6),yRate:n(7),zRate:n(8),xlen:n(9)*r,ylen:n(10)*r,zlen:n(11)*r,alpha:n(12)*r,beta:n(13)*r,gamma:n(14)*r,divisor:n(15)/100,summand:n(16),sigma:void 0}}function _te(e){const{xExtent:t,yExtent:n,zExtent:r}=e;return{xBlocks:Math.ceil(t/8),yBlocks:Math.ceil(n/8),zBlocks:Math.ceil(r/8)}}function g4(){return g4=ie(function*(e){const{buffer:t}=yield e.readBuffer(0,m4),n=String.fromCharCode.apply(null,t),r=n.startsWith(":-)"),i=r||100===t.readInt16LE(36);return{header:r?W8e(n):$8e(t,i),littleEndian:i}}),g4.apply(this,arguments)}function y4(){return y4=ie(function*(e,t,n,r){r||cd.flipByteOrderInPlace2(t.buffer);const{divisor:i,summand:o,xExtent:s,yExtent:a,zExtent:c}=e,{xBlocks:u,yBlocks:l,zBlocks:d}=_te(e);let f=0;for(let p=0;pl.get(d)})}function cUe(e,t){const{elements:n,tokenizer:r}=e,{count:i,property:o}=t,s=He.create(r.data,2*i*3),a=new Uint32Array(i+1);let c=0;for(let d=0,f=i;d{const f=a[d]+1,p=l.value(f-1);for(let m=f,h=f+p;mr.get(i)}}(r,i.map(c=>c.name),o);return Fr.success(a)}),_4.apply(this,arguments)}const{readLine:BT,skipWhitespace:Ste,eatValue:Cte,eatLine:dUe,markStart:x4}=ht,OT=/\s+/,fUe=/(^\*|REMARK)*/;function hUe(e,t){return S4.apply(this,arguments)}function S4(){return S4=ie(function*(e,t){const{tokenizer:n}=e,r=He.create(n.data,2*t),i=He.create(n.data,2*t),o=He.create(n.data,2*t),s=He.create(n.data,2*t),a=He.create(n.data,2*t),c=He.create(n.data,2*t),u=He.create(n.data,2*t),l=He.create(n.data,2*t),{position:d}=n,f=BT(n).trim();n.position=d;const p=7===f.split(OT).length,m=p?6:8,{length:h}=n;let g=0;return yield op(e.runtimeCtx,1e5,void 0,y=>{const b=Math.min(t-g,y);for(let x=0;xy.update({message:"Parsing...",current:n.position,max:h})),{count:t,atomId:Jt(r)(te.Schema.int),segmentName:p?Jt(o)(te.Schema.str):Jt(i)(te.Schema.str),residueId:Jt(o)(te.Schema.int),residueName:p?Jt(o)(te.Schema.str):Jt(s)(te.Schema.str),atomName:Jt(a)(te.Schema.str),atomType:Jt(c)(te.Schema.str),charge:Jt(u)(te.Schema.float),mass:Jt(l)(te.Schema.float)}}),S4.apply(this,arguments)}function mUe(e,t){return C4.apply(this,arguments)}function C4(){return C4=ie(function*(e,t){const{tokenizer:n}=e,r=He.create(n.data,2*t),i=He.create(n.data,2*t),{length:o}=n;let s=0;return yield op(e.runtimeCtx,10,void 0,a=>{const c=Math.min(t-s,a);for(let u=0;ua.update({message:"Parsing...",current:n.position,max:o})),{count:t,atomIdA:Jt(r)(te.Schema.int),atomIdB:Jt(i)(te.Schema.int)}}),C4.apply(this,arguments)}function gUe(e,t){const n=[];for(let r=0;rn(i)},e.create=n,e.hasTag=function r(i,o){if(!i.tags)return!1;for(const s of i.tags)if(s===o)return!0;return!1},e.Null={id:Hr.create22(),type:{name:"Null",typeClass:"Null"},data:void 0,label:"Null"}}(li||(li={})),function(e){e.is=function t(r){return!!(r&&r.transform&&r.parent&&r.status)},e.resolve=function n(r,i){const o="string"==typeof i?i:e.is(i)?i.transform.ref:i.ref;return r.cells.get(o)}}(N2||(N2={}));class wte{get cell(){var t;return null===(t=this.state)||void 0===t?void 0:t.cells.get(this.ref)}get obj(){var t,n;return null===(n=null===(t=this.state)||void 0===t?void 0:t.cells.get(this.ref))||void 0===n?void 0:n.obj}get data(){var t;return null===(t=this.obj)||void 0===t?void 0:t.data}update(t,n){if(!this.state)throw new Error("To use update() from StateObjectSelector, 'state' must be defined.");return n||(n=this.state.build()),(n||this.state.build()).to(this).update(t),n}checkValid(){if(!this.state)throw new Error("Unassigned State.");const t=this.cell;if(!t)throw new Error("Not created at all. Did you await/then the corresponding state update?");if("ok"===t.status)return!0;throw"error"===t.status?new Error(t.errorText):t.obj===li.Null?new Error("The object is Null."):new Error("Unresolved. Did you await/then the corresponding state update?")}get isOk(){const t=this.cell;return t&&"ok"===t.status&&t.obj!==li.Null}constructor(t,n){this.ref=t,this.state=n}}!function(e){function n(i,o){if(o)return N2.is(o)?o:"string"==typeof o?i.cells.get(o):o.cell}e.resolveRef=function t(i){var o;if(i)return"string"==typeof i?i:N2.is(i)?i.transform.ref:null===(o=i.cell)||void 0===o?void 0:o.transform.ref},e.resolve=n,e.resolveAndCheck=function r(i,o){const s=n(i,o);if(s&&s.obj&&"ok"===s.status)return s}}(ls||(ls={}));var F2="delete",Yi=5,Qu=1<>>0;if(""+n!==t||4294967295===n)return NaN;t=n}return t<0?tv(e)+t:t}function Ate(){return!0}function B2(e,t,n){return(0===e&&!Tte(e)||void 0!==n&&e<=-n)&&(void 0===t||void 0!==n&&t>=n)}function nv(e,t){return Ite(e,t,0)}function O2(e,t){return Ite(e,t,t)}function Ite(e,t,n){return void 0===e?n:Tte(e)?t===1/0?t:0|Math.max(0,t+e):void 0===t||t===e?e:0|Math.min(t,e)}function Tte(e){return e<0||0===e&&1/e==-1/0}var Dte="@@__IMMUTABLE_ITERABLE__@@";function Qa(e){return!(!e||!e[Dte])}var Ete="@@__IMMUTABLE_KEYED__@@";function Li(e){return!(!e||!e[Ete])}var Pte="@@__IMMUTABLE_INDEXED__@@";function ga(e){return!(!e||!e[Pte])}function L2(e){return Li(e)||ga(e)}var yo=function(t){return Qa(t)?t:ec(t)},el=function(e){function t(n){return Li(n)?n:am(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t}(yo),Zg=function(e){function t(n){return ga(n)?n:il(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t}(yo),rv=function(e){function t(n){return Qa(n)&&!L2(n)?n:sv(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t}(yo);yo.Keyed=el,yo.Indexed=Zg,yo.Set=rv;var Mte="@@__IMMUTABLE_SEQ__@@";function LT(e){return!(!e||!e[Mte])}var Rte="@@__IMMUTABLE_RECORD__@@";function Qg(e){return!(!e||!e[Rte])}function tl(e){return Qa(e)||Qg(e)}var iv="@@__IMMUTABLE_ORDERED__@@";function nl(e){return!(!e||!e[iv])}var U2=0,ud=1,rl=2,T4="function"==typeof Symbol&&Symbol.iterator,kte="@@iterator",UT=T4||kte,Wr=function(t){this.next=t};function Xi(e,t,n,r){var i=0===e?t:1===e?n:[t,n];return r?r.value=i:r={value:i,done:!1},r}function Ja(){return{value:void 0,done:!0}}function D4(e){return!!Array.isArray(e)||!!VT(e)}function Nte(e){return e&&"function"==typeof e.next}function E4(e){var t=VT(e);return t&&t.call(e)}function VT(e){var t=e&&(T4&&e[T4]||e[kte]);if("function"==typeof t)return t}Wr.prototype.toString=function(){return"[Iterator]"},Wr.KEYS=U2,Wr.VALUES=ud,Wr.ENTRIES=rl,Wr.prototype.inspect=Wr.prototype.toSource=function(){return this.toString()},Wr.prototype[UT]=function(){return this};var ov=Object.prototype.hasOwnProperty;function P4(e){return!(!Array.isArray(e)&&"string"!=typeof e)||e&&"object"==typeof e&&Number.isInteger(e.length)&&e.length>=0&&(0===e.length?1===Object.keys(e).length:e.hasOwnProperty(e.length-1))}var ec=function(e){function t(n){return null==n?R4():tl(n)?n.toSeq():function SUe(e){var t=N4(e);if(t)return function vUe(e){var t=VT(e);return t&&t===e.entries}(e)?t.fromEntrySeq():function _Ue(e){var t=VT(e);return t&&t===e.keys}(e)?t.toSetSeq():t;if("object"==typeof e)return new M4(e);throw new TypeError("Expected Array or collection object of values, or keyed object: "+e)}(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.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(r,i){var o=this._cache;if(o){for(var s=o.length,a=0;a!==s;){var c=o[i?s-++a:a++];if(!1===r(c[1],c[0],this))break}return a}return this.__iterateUncached(r,i)},t.prototype.__iterator=function(r,i){var o=this._cache;if(o){var s=o.length,a=0;return new Wr(function(){if(a===s)return{value:void 0,done:!0};var c=o[i?s-++a:a++];return Xi(r,c[0],c[1])})}return this.__iteratorUncached(r,i)},t}(yo),am=function(e){function t(n){return null==n?R4().toKeyedSeq():Qa(n)?Li(n)?n.toSeq():n.fromEntrySeq():Qg(n)?n.toSeq():k4(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.toKeyedSeq=function(){return this},t}(ec),il=function(e){function t(n){return null==n?R4():Qa(n)?Li(n)?n.entrySeq():n.toIndexedSeq():Qg(n)?n.toSeq().entrySeq():Bte(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.of=function(){return t(arguments)},t.prototype.toIndexedSeq=function(){return this},t.prototype.toString=function(){return this.__toString("Seq [","]")},t}(ec),sv=function(e){function t(n){return(Qa(n)&&!L2(n)?n:il(n)).toSetSeq()}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.of=function(){return t(arguments)},t.prototype.toSetSeq=function(){return this},t}(ec);ec.isSeq=LT,ec.Keyed=am,ec.Set=sv,ec.Indexed=il,ec.prototype[Mte]=!0;var Jg=function(e){function t(n){this._array=n,this.size=n.length}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.get=function(r,i){return this.has(r)?this._array[sm(this,r)]:i},t.prototype.__iterate=function(r,i){for(var o=this._array,s=o.length,a=0;a!==s;){var c=i?s-++a:a++;if(!1===r(o[c],c,this))break}return a},t.prototype.__iterator=function(r,i){var o=this._array,s=o.length,a=0;return new Wr(function(){if(a===s)return{value:void 0,done:!0};var c=i?s-++a:a++;return Xi(r,c,o[c])})},t}(il),M4=function(e){function t(n){var r=Object.keys(n).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(n):[]);this._object=n,this._keys=r,this.size=r.length}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.get=function(r,i){return void 0===i||this.has(r)?this._object[r]:i},t.prototype.has=function(r){return ov.call(this._object,r)},t.prototype.__iterate=function(r,i){for(var o=this._object,s=this._keys,a=s.length,c=0;c!==a;){var u=s[i?a-++c:c++];if(!1===r(o[u],u,this))break}return c},t.prototype.__iterator=function(r,i){var o=this._object,s=this._keys,a=s.length,c=0;return new Wr(function(){if(c===a)return{value:void 0,done:!0};var u=s[i?a-++c:c++];return Xi(r,u,o[u])})},t}(am);M4.prototype[iv]=!0;var Fte,xUe=function(e){function t(n){this._collection=n,this.size=n.length||n.size}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.__iterateUncached=function(r,i){if(i)return this.cacheResult().__iterate(r,i);var s=E4(this._collection),a=0;if(Nte(s))for(var c;!(c=s.next()).done&&!1!==r(c.value,a++,this););return a},t.prototype.__iteratorUncached=function(r,i){if(i)return this.cacheResult().__iterator(r,i);var s=E4(this._collection);if(!Nte(s))return new Wr(Ja);var a=0;return new Wr(function(){var c=s.next();return c.done?c:Xi(r,a++,c.value)})},t}(il);function R4(){return Fte||(Fte=new Jg([]))}function k4(e){var t=N4(e);if(t)return t.fromEntrySeq();if("object"==typeof e)return new M4(e);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+e)}function Bte(e){var t=N4(e);if(t)return t;throw new TypeError("Expected Array or collection object of values: "+e)}function N4(e){return P4(e)?new Jg(e):D4(e)?new xUe(e):void 0}var Ote="@@__IMMUTABLE_MAP__@@";function zT(e){return!(!e||!e[Ote])}function F4(e){return zT(e)&&nl(e)}function B4(e){return!(!e||"function"!=typeof e.equals||"function"!=typeof e.hashCode)}function Ns(e,t){if(e===t||e!=e&&t!=t)return!0;if(!e||!t)return!1;if("function"==typeof e.valueOf&&"function"==typeof t.valueOf){if((e=e.valueOf())===(t=t.valueOf())||e!=e&&t!=t)return!0;if(!e||!t)return!1}return!!(B4(e)&&B4(t)&&e.equals(t))}var V2="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,n){var r=65535&(t|=0),i=65535&(n|=0);return r*i+((t>>>16)*i+r*(n>>>16)<<16>>>0)|0};function GT(e){return e>>>1&1073741824|3221225471&e}var CUe=Object.prototype.valueOf;function Mc(e){if(null==e)return Lte(e);if("function"==typeof e.hashCode)return GT(e.hashCode(e));var t=function EUe(e){return e.valueOf!==CUe&&"function"==typeof e.valueOf?e.valueOf(e):e}(e);if(null==t)return Lte(t);switch(typeof t){case"boolean":return t?1108378657:1108378656;case"number":return function wUe(e){if(e!=e||e===1/0)return 0;var t=0|e;for(t!==e&&(t^=4294967295*e);e>4294967295;)t^=e/=4294967295;return GT(t)}(t);case"string":return t.length>PUe?function AUe(e){var t=G4[e];return void 0===t&&(t=O4(e),z4===MUe&&(z4=0,G4={}),z4++,G4[e]=t),t}(t):O4(t);case"object":case"function":return function TUe(e){var t;if(L4&&void 0!==(t=U4.get(e))||void 0!==(t=e[e0])||!Vte&&(void 0!==(t=e.propertyIsEnumerable&&e.propertyIsEnumerable[e0])||(t=function DUe(e){if(e&&e.nodeType>0)switch(e.nodeType){case 1:return e.uniqueID;case 9:return e.documentElement&&e.documentElement.uniqueID}}(e),void 0!==t)))return t;if(t=zte(),L4)U4.set(e,t);else{if(void 0!==Ute&&!1===Ute(e))throw new Error("Non-extensible objects are not allowed as keys.");if(Vte)Object.defineProperty(e,e0,{enumerable:!1,configurable:!1,writable:!1,value:t});else if(void 0!==e.propertyIsEnumerable&&e.propertyIsEnumerable===e.constructor.prototype.propertyIsEnumerable)e.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},e.propertyIsEnumerable[e0]=t;else{if(void 0===e.nodeType)throw new Error("Unable to set a non-enumerable property on object.");e[e0]=t}}return t}(t);case"symbol":return function IUe(e){var t=Gte[e];return void 0!==t||(t=zte(),Gte[e]=t),t}(t);default:if("function"==typeof t.toString)return O4(t.toString());throw new Error("Value type "+typeof t+" cannot be hashed.")}}function Lte(e){return null===e?1108378658:1108378659}function O4(e){for(var t=0,n=0;n=0&&(u.get=function(l,d){return(l=sm(this,l))>=0&&lc)return{value:void 0,done:!0};var h=f.next();return r||l===ud||h.done?h:Xi(l,m-1,l===U2?void 0:h.value[1],h)})},u}function Xte(e,t,n,r){var i=cf(e);return i.__iterateUncached=function(o,s){var a=this;if(s)return this.cacheResult().__iterate(o,s);var c=!0,u=0;return e.__iterate(function(l,d,f){if(!c||!(c=t.call(n,l,d,f)))return u++,o(l,r?d:u-1,a)}),u},i.__iteratorUncached=function(o,s){var a=this;if(s)return this.cacheResult().__iterator(o,s);var c=e.__iterator(rl,s),u=!0,l=0;return new Wr(function(){var d,f,p;do{if((d=c.next()).done)return r||o===ud?d:Xi(o,l++,o===U2?void 0:d.value[1],d);var m=d.value;f=m[0],p=m[1],u&&(u=t.call(n,p,f,a))}while(u);return o===rl?d:Xi(o,f,p,d)})},i}function Kte(e,t,n){var r=cf(e);return r.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var s=0,a=!1;return function c(u,l){u.__iterate(function(d,f){return(!t||l0}function qT(e,t,n,r){var i=cf(e),o=new Jg(n).map(function(s){return s.size});return i.size=r?o.max():o.min(),i.__iterate=function(s,a){for(var u,c=this.__iterator(ud,a),l=0;!(u=c.next()).done&&!1!==s(u.value,l++,this););return l},i.__iteratorUncached=function(s,a){var c=n.map(function(d){return d=yo(d),E4(a?d.reverse():d)}),u=0,l=!1;return new Wr(function(){var d;return l||(d=c.map(function(f){return f.next()}),l=r?d.every(function(f){return f.done}):d.some(function(f){return f.done})),l?{value:void 0,done:!0}:Xi(s,u++,t.apply(null,d.map(function(f){return f.value})))})},i}function Ti(e,t){return e===t?e:LT(e)?t:e.constructor(t)}function Qte(e){if(e!==Object(e))throw new TypeError("Expected [K, V] tuple: "+e)}function q4(e){return Li(e)?el:ga(e)?Zg:rv}function cf(e){return Object.create((Li(e)?am:ga(e)?il:sv).prototype)}function W4(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):ec.prototype.cacheResult.call(this)}function Jte(e,t){return void 0===e&&void 0===t?0:void 0===e?1:void 0===t?-1:e>t?1:e0;)t[n]=arguments[n+1];if("function"!=typeof e)throw new TypeError("Invalid merger function: "+e);return une(this,t,e)}function une(e,t,n){for(var r=[],i=0;i0;)t[n]=arguments[n+1];return G2(this,t,e)}function tL(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return t0(this,e,ld(),function(r){return j2(r,t)})}function nL(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return t0(this,e,ld(),function(r){return G2(r,t)})}function H2(e){var t=this.asMutable();return e(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this}function q2(){return this.__ownerID?this:this.__ensureOwner(new I4)}function W2(){return this.__ensureOwner()}function rL(){return this.__altered}var gu=function(e){function t(n){return null==n?ld():zT(n)&&!nl(n)?n:ld().withMutations(function(r){var i=e(n);mu(i.size),i.forEach(function(o,s){return r.set(s,o)})})}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.of=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];return ld().withMutations(function(o){for(var s=0;s=r.length)throw new Error("Missing value for key: "+r[s]);o.set(r[s],r[s+1])}})},t.prototype.toString=function(){return this.__toString("Map {","}")},t.prototype.get=function(r,i){return this._root?this._root.get(0,void 0,r,i):i},t.prototype.set=function(r,i){return hne(this,r,i)},t.prototype.remove=function(r){return hne(this,r,Pr)},t.prototype.deleteAll=function(r){var i=yo(r);return 0===i.size?this:this.withMutations(function(o){i.forEach(function(s){return o.remove(s)})})},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):ld()},t.prototype.sort=function(r){return ol(av(this,r))},t.prototype.sortBy=function(r,i){return ol(av(this,i,r))},t.prototype.map=function(r,i){var o=this;return this.withMutations(function(s){s.forEach(function(a,c){s.set(c,r.call(i,a,c,o))})})},t.prototype.__iterator=function(r,i){return new WUe(this,r,i)},t.prototype.__iterate=function(r,i){var o=this,s=0;return this._root&&this._root.iterate(function(a){return s++,r(a[1],a[0],o)},i),s},t.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?oL(this.size,this._root,r,this.__hash):0===this.size?ld():(this.__ownerID=r,this.__altered=!1,this)},t}(el);gu.isMap=zT;var Ki=gu.prototype;Ki[Ote]=!0,Ki[F2]=Ki.remove,Ki.removeAll=Ki.deleteAll,Ki.setIn=K4,Ki.removeIn=Ki.deleteIn=Z4,Ki.update=J4,Ki.updateIn=eL,Ki.merge=Ki.concat=ane,Ki.mergeWith=cne,Ki.mergeDeep=lne,Ki.mergeDeepWith=dne,Ki.mergeIn=tL,Ki.mergeDeepIn=nL,Ki.withMutations=H2,Ki.wasAltered=rL,Ki.asImmutable=W2,Ki["@@transducer/init"]=Ki.asMutable=q2,Ki["@@transducer/step"]=function(e,t){return e.set(t[0],t[1])},Ki["@@transducer/result"]=function(e){return e.asImmutable()};var $2=function(t,n){this.ownerID=t,this.entries=n};$2.prototype.get=function(t,n,r,i){for(var o=this.entries,s=0,a=o.length;s=QUe)return function $Ue(e,t,n,r){e||(e=new I4);for(var i=new Sp(e,Mc(n),[n,r]),o=0;o>>t)&Za),s=this.bitmap;return s&o?this.nodes[gne(s&o-1)].get(t+Yi,n,r,i):i},cv.prototype.update=function(t,n,r,i,o,s,a){void 0===r&&(r=Mc(i));var c=(0===n?r:r>>>n)&Za,u=1<=JUe)return function XUe(e,t,n,r,i){for(var o=0,s=new Array(Qu),a=0;0!==n;a++,n>>>=1)s[a]=1&n?t[o++]:void 0;return s[r]=i,new Y2(e,o+1,s)}(t,p,l,c,h);if(d&&!h&&2===p.length&&mne(p[1^f]))return p[1^f];if(d&&h&&1===p.length&&mne(h))return h;var g=t&&t===this.ownerID,y=d?h?l:l^u:l|u,b=d?h?yne(p,f,h,g):function ZUe(e,t,n){var r=e.length-1;if(n&&t===r)return e.pop(),e;for(var i=new Array(r),o=0,s=0;s>>t)&Za];return s?s.get(t+Yi,n,r,i):i},Y2.prototype.update=function(t,n,r,i,o,s,a){void 0===r&&(r=Mc(i));var c=(0===n?r:r>>>n)&Za,l=this.nodes,d=l[c];if(o===Pr&&!d)return this;var f=sL(d,t,n+Yi,r,i,o,s,a);if(f===d)return this;var p=this.count;if(d){if(!f&&--p>>n)&Za,s=(0===n?r:r>>>n)&Za,c=o===s?[aL(e,t,n+Yi,r,i)]:(a=new Sp(t,r,i),o>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,127&(e+=e>>8)+(e>>16)}function yne(e,t,n,r){var i=r?e:uf(e);return i[t]=n,i}var QUe=Qu/4,JUe=Qu/2,eVe=Qu/4,bne="@@__IMMUTABLE_LIST__@@";function cL(e){return!(!e||!e[bne])}var Cp=function(e){function t(n){var r=$T();if(null==n)return r;if(cL(n))return n;var i=e(n),o=i.size;return 0===o?r:(mu(o),o>0&&o=0&&r=e.size||t<0)return e.withMutations(function(s){t<0?lm(s,t).set(0,n):lm(s,0,t+1).set(t,n)});var r=e._tail,i=e._root,o={value:!1};return(t+=e._origin)>=Z2(e._capacity)?r=uL(r,e.__ownerID,0,t,n,o):i=uL(i,e.__ownerID,e._level,t,n,o),o.value?e.__ownerID?(e._root=i,e._tail=r,e.__hash=void 0,e.__altered=!0,e):K2(e._origin,e._capacity,e._level,i,r):e}(this,r,i)},t.prototype.remove=function(r){return this.has(r)?0===r?this.shift():r===this.size-1?this.pop():this.splice(r,1):this},t.prototype.insert=function(r,i){return this.splice(r,0,i)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=Yi,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):$T()},t.prototype.push=function(){var r=arguments,i=this.size;return this.withMutations(function(o){lm(o,0,i+r.length);for(var s=0;s>>n&Za;if(i>=this.array.length)return new um([],t);var s,o=0===i;if(n>0){var a=this.array[i];if((s=a&&a.removeBefore(t,n-Yi,r))===a&&o)return this}if(o&&!s)return this;var c=lv(this,t);if(!o)for(var u=0;u>>n&Za;if(i>=this.array.length)return this;if(n>0){var s=this.array[i];if((o=s&&s.removeAfter(t,n-Yi,r))===s&&i===this.array.length-1)return this}var a=lv(this,t);return a.array.splice(i+1),o&&(a.array[i]=o),a};var _ne,X2={};function vne(e,t){var n=e._origin,r=e._capacity,i=Z2(r),o=e._tail;return function s(u,l,d){return 0===l?function a(u,l){var d=l===i?o&&o.array:u&&u.array,f=l>n?0:n-l,p=r-l;return p>Qu&&(p=Qu),function(){if(f===p)return X2;var m=t?--p:f++;return d&&d[m]}}(u,d):function c(u,l,d){var f,p=u&&u.array,m=d>n?0:n-d>>l,h=1+(r-d>>l);return h>Qu&&(h=Qu),function(){for(;;){if(f){var g=f();if(g!==X2)return g;f=null}if(m===h)return X2;var y=t?--h:m++;f=s(p&&p[y],l-Yi,d+(y<>>n&Za,a=e&&s0){var u=e&&e.array[s],l=uL(u,t,n-Yi,r,i,o);return l===u?e:((c=lv(e,t)).array[s]=l,c)}return a&&e.array[s]===i?e:(o&&Ju(o),c=lv(e,t),void 0===i&&s===c.array.length-1?c.array.pop():c.array[s]=i,c)}function lv(e,t){return t&&e&&t===e.ownerID?e:new um(e?e.array.slice():[],t)}function xne(e,t){if(t>=Z2(e._capacity))return e._tail;if(t<1<0;)n=n.array[t>>>r&Za],r-=Yi;return n}}function lm(e,t,n){void 0!==t&&(t|=0),void 0!==n&&(n|=0);var r=e.__ownerID||new I4,i=e._origin,o=e._capacity,s=i+t,a=void 0===n?o:n<0?o+n:i+n;if(s===i&&a===o)return e;if(s>=a)return e.clear();for(var c=e._level,u=e._root,l=0;s+l<0;)u=new um(u&&u.array.length?[void 0,u]:[],r),l+=1<<(c+=Yi);l&&(s+=l,i+=l,a+=l,o+=l);for(var d=Z2(o),f=Z2(a);f>=1<d?new um([],r):p;if(p&&f>d&&sYi;g-=Yi){var y=d>>>g&Za;h=h.array[y]=lv(h.array[y],r)}h.array[d>>>Yi&Za]=p}if(a=f)s-=f,a-=f,c=Yi,u=null,m=m&&m.removeBefore(r,0,s);else if(s>i||f>>c&Za;if(b!==f>>>c&Za)break;b&&(l+=(1<i&&(u=u.removeBefore(r,c,s-l)),u&&f>>Yi<=Qu&&i.size>=2*r.size?(a=(c=i.filter(function(u,l){return void 0!==u&&o!==l})).toKeyedSeq().map(function(u){return u[0]}).flip().toMap(),e.__ownerID&&(a.__ownerID=c.__ownerID=e.__ownerID)):(a=r.remove(t),c=o===i.size-1?i.pop():i.set(o,void 0))}else if(s){if(n===i.get(o)[1])return e;a=r,c=i.set(o,[t,n])}else a=r.set(t,i.size),c=i.set(i.size,[t,n]);return e.__ownerID?(e.size=a.size,e._map=a,e._list=c,e.__hash=void 0,e.__altered=!0,e):lL(a,c)}ol.isOrderedMap=F4,ol.prototype[iv]=!0,ol.prototype[F2]=ol.prototype.remove;var wne="@@__IMMUTABLE_STACK__@@";function YT(e){return!(!e||!e[wne])}var XT=function(e){function t(n){return null==n?KT():YT(n)?n:KT().pushAll(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("Stack [","]")},t.prototype.get=function(r,i){var o=this._head;for(r=sm(this,r);o&&r--;)o=o.next;return o?o.value:i},t.prototype.peek=function(){return this._head&&this._head.value},t.prototype.push=function(){var r=arguments;if(0===arguments.length)return this;for(var i=this.size+arguments.length,o=this._head,s=arguments.length-1;s>=0;s--)o={value:r[s],next:o};return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):J2(i,o)},t.prototype.pushAll=function(r){if(0===(r=e(r)).size)return this;if(0===this.size&&YT(r))return r;mu(r.size);var i=this.size,o=this._head;return r.__iterate(function(s){i++,o={value:s,next:o}},!0),this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):J2(i,o)},t.prototype.pop=function(){return this.slice(1)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):KT()},t.prototype.slice=function(r,i){if(B2(r,i,this.size))return this;var o=nv(r,this.size);if(O2(i,this.size)!==this.size)return e.prototype.slice.call(this,r,i);for(var a=this.size-o,c=this._head;o--;)c=c.next;return this.__ownerID?(this.size=a,this._head=c,this.__hash=void 0,this.__altered=!0,this):J2(a,c)},t.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?J2(this.size,this._head,r,this.__hash):0===this.size?KT():(this.__ownerID=r,this.__altered=!1,this)},t.prototype.__iterate=function(r,i){var o=this;if(i)return new Jg(this.toArray()).__iterate(function(c,u){return r(c,u,o)},i);for(var s=0,a=this._head;a&&!1!==r(a.value,s++,this);)a=a.next;return s},t.prototype.__iterator=function(r,i){if(i)return new Jg(this.toArray()).__iterator(r,i);var o=0,s=this._head;return new Wr(function(){if(s){var a=s.value;return s=s.next,Xi(r,o++,a)}return{value:void 0,done:!0}})},t}(Zg);XT.isStack=YT;var Ane,tc=XT.prototype;function J2(e,t,n,r){var i=Object.create(tc);return i.size=e,i._head=t,i.__ownerID=n,i.__hash=r,i.__altered=!1,i}function KT(){return Ane||(Ane=J2(0))}tc[wne]=!0,tc.shift=tc.pop,tc.unshift=tc.push,tc.unshiftAll=tc.pushAll,tc.withMutations=H2,tc.wasAltered=rL,tc.asImmutable=W2,tc["@@transducer/init"]=tc.asMutable=q2,tc["@@transducer/step"]=function(e,t){return e.unshift(t)},tc["@@transducer/result"]=function(e){return e.asImmutable()};var Ine="@@__IMMUTABLE_SET__@@";function ZT(e){return!(!e||!e[Ine])}function dL(e){return ZT(e)&&nl(e)}function fL(e,t){if(e===t)return!0;if(!Qa(t)||void 0!==e.size&&void 0!==t.size&&e.size!==t.size||void 0!==e.__hash&&void 0!==t.__hash&&e.__hash!==t.__hash||Li(e)!==Li(t)||ga(e)!==ga(t)||nl(e)!==nl(t))return!1;if(0===e.size&&0===t.size)return!0;var n=!L2(e);if(nl(e)){var r=e.entries();return t.every(function(c,u){var l=r.next().value;return l&&Ns(l[1],c)&&(n||Ns(l[0],u))})&&r.next().done}var i=!1;if(void 0===e.size)if(void 0===t.size)"function"==typeof e.cacheResult&&e.cacheResult();else{i=!0;var o=e;e=t,t=o}var s=!0,a=t.__iterate(function(c,u){if(n?!e.has(c):i?!Ns(c,e.get(u,Pr)):!Ns(e.get(u,Pr),c))return s=!1,!1});return s&&e.size===a}function n0(e,t){var n=function(r){e.prototype[r]=t[r]};return Object.keys(t).forEach(n),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(t).forEach(n),e}function QT(e){if(!e||"object"!=typeof e)return e;if(!Qa(e)){if(!cm(e))return e;e=ec(e)}if(Li(e)){var t={};return e.__iterate(function(r,i){t[i]=QT(r)}),t}var n=[];return e.__iterate(function(r){n.push(QT(r))}),n}var eS=function(e){function t(n){return null==n?tS():ZT(n)&&!nl(n)?n:tS().withMutations(function(r){var i=e(n);mu(i.size),i.forEach(function(o){return r.add(o)})})}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.of=function(){return this(arguments)},t.fromKeys=function(r){return this(el(r).keySeq())},t.intersect=function(r){return(r=yo(r).toArray()).length?ta.intersect.apply(t(r.pop()),r):tS()},t.union=function(r){return(r=yo(r).toArray()).length?ta.union.apply(t(r.pop()),r):tS()},t.prototype.toString=function(){return this.__toString("Set {","}")},t.prototype.has=function(r){return this._map.has(r)},t.prototype.add=function(r){return JT(this,this._map.set(r,r))},t.prototype.remove=function(r){return JT(this,this._map.remove(r))},t.prototype.clear=function(){return JT(this,this._map.clear())},t.prototype.map=function(r,i){var o=this,s=!1,a=JT(this,this._map.mapEntries(function(c){var u=c[1],l=r.call(i,u,u,o);return l!==u&&(s=!0),[l,l]},i));return s?a:this},t.prototype.union=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];return 0===(r=r.filter(function(o){return 0!==o.size})).length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(o){for(var s=0;s=0&&i=0&&o>>-15,461845907),t=V2(t<<13|t>>>-13,5),t=V2((t=t+3864292196^e)^t>>>16,2246822507),t=GT((t=V2(t^t>>>13,3266489909))^t>>>16)}(e.__iterate(n?t?function(o,s){r=31*r+One(Mc(o),Mc(s))|0}:function(o,s){r=r+One(Mc(o),Mc(s))|0}:t?function(o){r=31*r+Mc(o)|0}:function(o){r=r+Mc(o)|0}),r)}(this))}});var ya=yo.prototype;ya[Dte]=!0,ya[UT]=ya.values,ya.toJSON=ya.toArray,ya.__toStringMapper=z2,ya.inspect=ya.toSource=function(){return this.toString()},ya.chain=ya.flatMap,ya.contains=ya.includes,n0(el,{flip:function(){return Ti(this,Wte(this))},mapEntries:function(t,n){var r=this,i=0;return Ti(this,this.toSeq().map(function(o,s){return t.call(n,[s,o],i++,r)}).fromEntrySeq())},mapKeys:function(t,n){var r=this;return Ti(this,this.toSeq().flip().map(function(i,o){return t.call(n,i,o,r)}).flip())}});var nS=el.prototype;nS[Ete]=!0,nS[UT]=ya.entries,nS.toJSON=Rne,nS.__toStringMapper=function(e,t){return z2(t)+": "+z2(e)},n0(Zg,{toKeyedSeq:function(){return new jT(this,!1)},filter:function(t,n){return Ti(this,Yte(this,t,n,!1))},findIndex:function(t,n){var r=this.findEntry(t,n);return r?r[0]:-1},indexOf:function(t){var n=this.keyOf(t);return void 0===n?-1:n},lastIndexOf:function(t){var n=this.lastKeyOf(t);return void 0===n?-1:n},reverse:function(){return Ti(this,j4(this,!1))},slice:function(t,n){return Ti(this,H4(this,t,n,!1))},splice:function(t,n){var r=arguments.length;if(n=Math.max(n||0,0),0===r||2===r&&!n)return this;t=nv(t,t<0?this.count():this.size);var i=this.slice(0,t);return Ti(this,1===r?i:i.concat(uf(arguments,2),this.slice(t+n)))},findLastIndex:function(t,n){var r=this.findLastEntry(t,n);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Ti(this,Kte(this,t,!1))},get:function(t,n){return(t=sm(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?n:this.find(function(r,i){return i===t},void 0,n)},has:function(t){return(t=sm(this,t))>=0&&(void 0!==this.size?this.size===1/0||tt?-1:0}function One(e,t){return e^t+2654435769+(e<<6)+(e>>2)}fv.has=ya.includes,fv.contains=fv.includes,fv.keys=fv.values,n0(am,nS),n0(il,dv),n0(sv,fv);var sl=function(e){function t(n){return null==n?gL():dL(n)?n:gL().withMutations(function(r){var i=rv(n);mu(i.size),i.forEach(function(o){return r.add(o)})})}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.of=function(){return this(arguments)},t.fromKeys=function(r){return this(el(r).keySeq())},t.prototype.toString=function(){return this.__toString("OrderedSet {","}")},t}(eS);sl.isOrderedSet=dL;var Une,r0=sl.prototype;function Lne(e,t){var n=Object.create(r0);return n.size=e?e.size:0,n._map=e,n.__ownerID=t,n}function gL(){return Une||(Une=Lne(Q2()))}r0[iv]=!0,r0.zip=dv.zip,r0.zipWith=dv.zipWith,r0.zipAll=dv.zipAll,r0.__empty=gL,r0.__make=Lne;var Es=function(t,n){var r;!function cVe(e){if(Qg(e))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(tl(e))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===e||"object"!=typeof e)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var i=function(a){var c=this;if(a instanceof i)return a;if(!(this instanceof i))return new i(a);if(!r){r=!0;var u=Object.keys(t),l=o._indices={};o._name=n,o._keys=u,o._defaultValues=t;for(var d=0;d({action:o,params:s}),id:Hr.create22(),definition:i,createDefaultParams:(s,a)=>i.params?C.getDefaultValues(i.params(s,a)):{}};return o}let r;e.create=t,e.fromTransformer=function n(i){const o=i.definition;return t({from:o.from,display:o.display,params:o.params,isApplicable:i.definition.isApplicable?(s,a,c)=>i.definition.isApplicable(s,c):void 0,run({cell:s,state:a,params:c}){const u=a.build().to(s.transform.ref).apply(i,c);return a.updateTree(u)}})},(r=e.Builder||(e.Builder={})).build=s=>function o(s){return a=>t({from:s.from instanceof Array?s.from:s.from?[s.from]:[],display:"string"==typeof s.display?{name:s.display}:s.display?s.display:{name:"Unnamed State Action"},params:"object"==typeof s.params?()=>s.params:s.params?s.params:void 0,isApplicable:s.isApplicable,..."function"==typeof a?{run:a}:a})}(s),e.build=r.build}(nc||(nc={})),function(e){let r;var h;e.getParamDefinition=function t(h,g,y){return h.definition.params?h.definition.params(g,y):{}},e.is=function n(h){return!!h&&"function"==typeof h.toAction&&"function"==typeof h.apply},(h=r=e.UpdateResult||(e.UpdateResult={}))[h.Unchanged=0]="Unchanged",h[h.Updated=1]="Updated",h[h.Recreate=2]="Recreate",h[h.Null=3]="Null";const i=new Map,o=new Map;function l(h,g){const{name:y}=g,b=`${h}.${y}`;if(i.has(b))throw new Error(`A transform with id '${y}' is already registered. Please pick a unique identifier for your transforms and/or register them only once. This is to ensure that transforms can be serialized and replayed.`);const x={apply:(_,S,A)=>ur.create(_,x,S,A),toAction:()=>nc.fromTransformer(x),namespace:h,id:b,definition:g,createDefaultParams:(_,S)=>g.params?C.getDefaultValues(g.params(_,S)):{}};return i.set(b,x),function s(h){for(const g of h.definition.from)o.has(g.type)?o.get(g.type).push(h):o.set(g.type,[h])}(x),x}let p;e.getAll=function a(){return Array.from(i.values())},e.get=function c(h){const g=i.get(h);if(!g)throw new Error(`A transformer with signature '${h}' is not registered.`);return g},e.fromType=function u(h){return o.get(h)||[]},e.create=l,e.factory=function d(h){return g=>l(h,g)},e.builderFactory=function f(h){return p.build(h)},function(h){h.build=function y(b){return x=>function g(b,x){return _=>l(b,{name:x.name,from:x.from instanceof Array?x.from:[x.from],to:x.to instanceof Array?x.to:[x.to],display:"string"==typeof x.display?{name:x.display}:x.display?x.display:{name:Fg(x.name.replace(/[-]/g," "))},params:"object"==typeof x.params?()=>x.params:x.params?x.params:void 0,isDecorator:x.isDecorator,..._})}(b,x)}}(p=e.Builder||(e.Builder={})),e.build=function m(h){return p.build(h)},e.ROOT=l("build-in",{name:"root",from:[],to:[],display:{name:"Root",description:"For internal use."},apply(){throw new Error("should never be applied")},update:()=>r.Unchanged})}(Qe||(Qe={})),function(e){function o(g,y,b,x){const _=x&&x.ref?x.ref:Hr.create22();let S;return x&&x.tags&&(S="string"==typeof x.tags?[x.tags]:x.tags,0===S.length?S=void 0:S.sort()),{parent:g,transformer:y,state:x?.state||{},tags:S,ref:_,dependsOn:x&&x.dependsOn,params:b,version:Hr.create22()}}function d(g,y){return!!g.tags&&g.tags.indexOf(y)>=0}function p(g){return g}e.RootRef="-=root=-",e.areStatesEqual=function t(g,y){return!!g.isHidden!=!!y.isHidden||!!g.isCollapsed!=!!y.isCollapsed||!!g.isGhost!=!!y.isGhost||!!g.isLocked!=!!y.isLocked},e.isStateChange=function n(g,y){return!!y&&(typeof y.isCollapsed<"u"&&g.isCollapsed!==y.isCollapsed||typeof y.isHidden<"u"&&g.isHidden!==y.isHidden||typeof y.isGhost<"u"&&g.isGhost!==y.isGhost||typeof y.isLocked<"u"&&g.isLocked!==y.isLocked)},e.assignState=function r(g,y){if(!y)return!1;let b=!1;for(const x of Object.keys(y)){const _=y[x];!!_!=!!g[x]&&(b=!0,g[x]=_)}return b},e.syncState=function i(g,y){if(!y)return!1;let b=!1;for(const x of Object.keys(y)){const _=y[x];!!_!=!!g[x]&&(b=!0,void 0!==_?g[x]=_:delete g[x])}for(const x of Object.keys(g)){const _=y[x];!!_!=!!g[x]&&(b=!0,void 0!==_?g[x]=_:delete g[x])}return b},e.create=o,e.withParams=function s(g,y){return{...g,params:y,version:Hr.create22()}},e.withState=function a(g,y){return y?{...g,state:{...g.state,...y}}:g},e.withTags=function c(g,y){let b;return y&&(b="string"==typeof y?[y]:y,0===b.length?b=void 0:b.sort()),{...g,tags:b,version:Hr.create22()}},e.withParent=function u(g,y){return{...g,parent:y,version:Hr.create22()}},e.createRoot=function l(g){return o(e.RootRef,Qe.ROOT,{},{ref:e.RootRef,state:g})},e.hasTag=d,e.hasTags=function f(g,y){if(!g.tags)return"string"!=typeof y&&0===y.length;if("string"==typeof y)return d(g,y);for(const b of y)if(g.tags.indexOf(b)<0)return!1;return!0},e.toJSON=function m(g){const y=g.transformer.definition.customSerialization?g.transformer.definition.customSerialization.toJSON:p;let b;for(const x of Object.keys(g.state))g.state[x]&&(b||(b={}),b[x]=!0);return{parent:g.parent,transformer:g.transformer.id,params:g.params?y(g.params):void 0,state:b,tags:g.tags,ref:g.ref,dependsOn:g.dependsOn,version:g.version}},e.fromJSON=function h(g){const y=Qe.get(g.transformer);return{parent:g.parent,transformer:y,params:g.params?(y.definition.customSerialization?y.definition.customSerialization.fromJSON:p)(g.params):void 0,state:g.state||{},tags:g.tags,ref:g.ref,dependsOn:g.dependsOn,version:g.version}}}(ur||(ur={}));class hVe{get childMutations(){return this._childMutations||(this._childMutations=new Map),this._childMutations}get dependencyMutations(){return this._dependencyMutations||(this._dependencyMutations=new Map),this._dependencyMutations}changeNodes(){this.changedNodes||(this.changedNodes=!0,this.transforms=this.transforms.asMutable())}changeChildren(){this.changedChildren||(this.changedChildren=!0,this.children=this.children.asMutable())}changeDependencies(){this.changedDependencies||(this.changedDependencies=!0,this.dependencies=this.dependencies.asMutable())}get root(){return this.transforms.get(ur.RootRef)}asTransient(){return this.asImmutable().asTransient()}addChild(t,n){if(this.changeChildren(),this.childMutations.has(t))this.childMutations.get(t).add(n);else{const r=this.children.get(t).asMutable();r.add(n),this.children.set(t,r),this.childMutations.set(t,r)}}removeChild(t,n){if(this.changeChildren(),this.childMutations.has(t))this.childMutations.get(t).remove(n);else{const r=this.children.get(t).asMutable();r.remove(n),this.children.set(t,r),this.childMutations.set(t,r)}}clearRoot(){const t=ur.RootRef;if(0===this.children.get(t).size)return;this.changeChildren();const n=sl();this.children.set(t,n),this.childMutations.set(t,n)}mutateDependency(t,n,r){let i=this.dependencyMutations.get(t);if(!i){const o=this.dependencies.get(t);if(!o&&"remove"===r)return;this.changeDependencies(),i=o?o.asMutable():sl().asMutable(),this.dependencyMutations.set(t,i),this.dependencies.set(t,i)}"add"===r?i.add(n):i.remove(n)}changeParent(t,n){eD(this.transforms,t);const r=this.transforms.get(t);this.removeChild(r.parent,t),this.addChild(n,t),this.changeNodes(),this.transforms.set(t,ur.withParent(r,n))}add(t){const n=t.ref;this.transforms.has(t.ref)&&this.transforms.get(t.ref).parent!==t.parent&&function yVe(e){throw new Error(`Transform '${e}' is already present in the tree.`)}(t.ref);const r=this.children.get(t.parent);if(r||function bVe(e){throw new Error(`Parent '${e}' must be present in the tree.`)}(t.parent),r.has(t.ref)||this.addChild(t.parent,t.ref),this.children.has(t.ref)||(this.changedChildren||(this.changedChildren=!0,this.children=this.children.asMutable()),this.children.set(t.ref,sl())),this.changeNodes(),this.transforms.set(n,t),t.dependsOn)for(const i of t.dependsOn)this.mutateDependency(i,n,"add");return this}setParams(t,n){eD(this.transforms,t);const r=this.transforms.get(t);return!eB(r.params,n)&&(this.changedNodes||(this.changedNodes=!0,this.transforms=this.transforms.asMutable()),this.transforms.set(r.ref,ur.withParams(r,n)),!0)}setTags(t,n){eD(this.transforms,t);const r=this.transforms.get(t),i=ur.withParams(r,n);return!LZ(r.tags,i.tags)&&(this.changedNodes||(this.changedNodes=!0,this.transforms=this.transforms.asMutable()),this.transforms.set(r.ref,i),!0)}assignState(t,n){eD(this.transforms,t);const r=this.transforms.get(t);if(this._stateUpdates&&this._stateUpdates.has(t))return ur.assignState(r.state,n),r;{this._stateUpdates||(this._stateUpdates=new Set),this._stateUpdates.add(r.ref),this.changeNodes();const i=ur.withState(r,n);return this.transforms.set(t,i),i}}remove(t){const n=this.transforms.get(t);if(!n)return[];const r=bo.subtreePostOrder(this,n);if(t===ur.RootRef){if(r.pop(),0===r.length)return r;this.clearRoot()}else{if(0===r.length)return r;this.removeChild(n.parent,n.ref)}this.changeNodes(),this.changeChildren();for(const o of r)this.transforms.delete(o.ref),this.children.delete(o.ref),this._childMutations&&this._childMutations.delete(o.ref);const i=[];for(const o of r){if(o.dependsOn)for(const s of o.dependsOn)this.transforms.has(s)&&this.mutateDependency(s,o.ref,"remove");if(this.dependencies.has(o.ref)){const s=this.dependencies.get(o.ref).toArray();this.changeDependencies(),this.dependencies.delete(o.ref),this._dependencyMutations&&this._dependencyMutations.delete(o.ref);for(const a of s)if(this.transforms.has(a))for(const c of this.remove(a))i[i.length]=c}}for(const o of i)r[r.length]=o;return r}asImmutable(){return this.changedNodes||this.changedChildren||this._childMutations?(this._childMutations&&this._childMutations.forEach(mVe,this.children),this._dependencyMutations&&this._dependencyMutations.forEach(gVe,this.dependencies),bo.create(this.changedNodes?this.transforms.asImmutable():this.transforms,this.changedChildren?this.children.asImmutable():this.children,this.changedDependencies?this.dependencies.asImmutable():this.dependencies)):this.tree}constructor(t){this.tree=t,this.transforms=this.tree.transforms,this.children=this.tree.children,this.dependencies=this.tree.dependencies,this.changedNodes=!1,this.changedChildren=!1,this.changedDependencies=!1,this._childMutations=void 0,this._dependencyMutations=void 0,this._stateUpdates=void 0}}function mVe(e,t){this.set(t,e.asImmutable())}function gVe(e,t){0===e.size?this.delete(t):this.set(t,e.asImmutable())}function eD(e,t){if(!e.has(t))throw new Error(`Node '${t}' is not present in the tree.`)}!function(e){class t{get root(){return this.transforms.get(ur.RootRef)}asTransient(){return new hVe(this)}constructor(_,S,A){this.transforms=_,this.children=S,this.dependencies=A}}function r(x,_,S){return new t(x,_,S)}function i(x){o(this,this.tree.transforms.get(x))}function o(x,_){const S=x.tree.children.get(_.ref);S&&S.size&&S.forEach(i,x),x.f(_,x.tree,x.state)}function s(x,_,S,A){const E={tree:x,state:S,f:A};return o(E,_),E.state}function a(x){c(this,this.tree.transforms.get(x))}function c(x,_){const S=x.f(_,x.tree,x.state);if("boolean"==typeof S&&!S)return;const A=x.tree.children.get(_.ref);A&&A.size&&A.forEach(a,x)}function u(x,_,S,A){const E={tree:x,state:S,f:A};return c(E,_),E.state}function l(x,_,S){S.push(x)}function f(x,_,S){S.push(ur.toJSON(x))}function g(x,_,S){if(_===S)return!0;const E=x.children.get(_).values();for(;;){const w=E.next();if(w.done)return!1;if(g(x,w.value,S))return!0}}e.createEmpty=function n(x){const _=x||ur.createRoot();return r(gu([[_.ref,_]]),gu([[_.ref,sl()]]),gu())},e.create=r,e.doPostOrder=s,e.doPreOrder=u,e.subtreePostOrder=function d(x,_){return s(x,_,[],l)},e.toJSON=function p(x){const _=[];return u(x,x.root,_,f),{transforms:_}},e.fromJSON=function m(x){const _=gu().asMutable(),S=gu().asMutable(),A=gu().asMutable();for(const w of x.transforms){const D=ur.fromJSON(w);_.set(D.ref,D),S.has(D.ref)||S.set(D.ref,sl().asMutable()),D.ref!==D.parent&&S.get(D.parent).add(D.ref)}const E=new Set;for(const w of x.transforms){const D=w.ref;if(S.set(D,S.get(D).asImmutable()),w.dependsOn)for(const I of w.dependsOn)E.add(I),A.has(I)?A.get(I).add(D):A.set(I,sl([D]).asMutable())}return E.forEach(w=>{A.set(w,A.get(w).asImmutable())}),r(_.asImmutable(),S.asImmutable(),A.asImmutable())},e.dump=function h(x){console.log({tr:x.transforms.keySeq().toArray(),tr1:x.transforms.valueSeq().toArray().map(_=>_.ref),ch:x.children.keySeq().toArray()})},e.subtreeHasRef=function y(x,_,S){return!(!x.transforms.has(_)||!x.transforms.has(S))&&g(x,_,S)},e.getDecoratorRoot=function b(x,_){const S=x.children.get(_);if(1!==S.size)return _;const A=x.transforms.get(S.first());return A.transformer.definition.isDecorator?b(x,A.ref):_}}(bo||(bo={})),function(e){function t(O,H){return n(O)(H)}function n(O){const H=O||u.root;let W;return W=function i(O){return void 0!==O.compile}(H)?H.compile():function r(O){return void 0!==O.transform&&void 0!==O.status}(H)?u.byValue(H).compile():function o(O){return"function"==typeof O}(H)?H:u.byRef(H).compile(),W}e.select=t,e.compile=n;const s={select(O){return t(this,O||this.state)}};function a(O,H){s[O]=function(...W){return H.call(void 0,this,...W)}}function c(O){return Object.create(s,{compile:{writable:!1,configurable:!1,value:O}})}let u;function l(O,H){const W=n(O);return c(()=>Q=>{const fe=[];for(const X of W(Q))for(const J of H(X,Q))fe.push(J);return fe})}function d(O,H){const W=n(O);return c(()=>Q=>{const fe=[];for(const X of W(Q)){const J=H(X,Q);J&&fe.push(J)}return fe})}function f(O){const H=n(O);return c(()=>W=>{const Q=new Set,fe=[];for(const X of H(W))X&&(Q.has(X.transform.ref)||(Q.add(X.transform.ref),fe.push(X)));return fe})}function p(O){const H=n(O);return c(()=>W=>{const Q=H(W);return Q.length?[Q[0]]:[]})}function m(O,H){return l(O,W=>H(W)?[W]:[])}function h(O,H){return m(O,W=>W.status===H)}function g(O,H){return m(O,W=>!!W.transform.tags&&W.transform.tags.indexOf(H)>=0)}function y(O){return l(O,(H,W)=>{const Q=[];return bo.doPreOrder(W.tree,W.tree.transforms.get(H.transform.ref),Q,(fe,X,J)=>{J.push(fe.ref)}),Q.map(fe=>W.cells.get(fe))})}function b(O){return l(O,(H,W)=>{const Q=[];return W.tree.children.get(H.transform.ref).forEach(fe=>Q.push(W.cells.get(fe))),Q})}function x(O,H){return m(O,W=>!!W.obj&&W.obj.type===H.type)}function _(O,H){return f(d(O,(W,Q)=>T(Q.tree,Q.cells,W.transform.ref,H)))}function S(O,H){return f(d(O,(W,Q)=>V(Q.tree,Q.cells,W.transform.ref,H)))}function A(O,H){return f(d(O,(W,Q)=>N(Q.tree,Q.cells,W.transform.ref,H)))}function E(O,H){return m(O,W=>W.transform.transformer===H)}function w(O,H){return f(d(O,(W,Q)=>M(Q.tree,Q.cells,W.transform.ref,H)))}function D(O,H){return f(d(O,(W,Q)=>F(Q.tree,Q.cells,W.transform.ref,H)))}function I(O){return f(d(O,(H,W)=>W.cells.get(W.tree.transforms.get(H.transform.ref).parent)))}function R(O,H,W,Q,fe){let J,X=O.transforms.get(W);for(;;){X=O.transforms.get(X.parent);const ce=H.get(X.ref);if(ce.obj&&Q(ce)&&(J=ce,fe)||X.ref===ur.RootRef)return J}}function T(O,H,W,Q){return R(O,H,W,Q,!0)}function M(O,H,W,Q){return R(O,H,W,Q,!1)}function N(O,H,W,Q){return T(O,H,W,Array.isArray(Q)?fe=>Q.indexOf(fe.transform.transformer)>=0:fe=>fe.transform.transformer===Q)}function V(O,H,W,Q){return T(O,H,W,G(Q))}function F(O,H,W,Q){return M(O,H,W,G(Q))}function G(O){return Array.isArray(O)?H=>{for(const W of O)if(W.type===H.obj.type)return!0}:H=>H.obj.type===O.type}function z(O,H,W){if(O.tags)for(const Q of O.tags)if(W.tags.has(Q)){W.refs[Q]=O.ref;break}return!0}function Z(O,H,W){return!(O.tags&&O.tags.indexOf(W.tag)>=0&&(W.ref=O.ref,1))}function ee(O,H,W){if(O.tags){const Q=W.tags.size;let fe=0;for(const X of O.tags)if(W.tags.has(X)&&(fe++,fe===Q)){W.refs.push(O);break}}else 0===W.tags.size&&W.refs.push(O)}(function(O){function ce(oe,K,ne){const de=ne.cells.get(oe.ref);return!de||!de.obj||de.obj.type!==ne.type||(ne.roots.push(de),!1)}function be(oe,K,ne){const de=ne.cells.get(oe.ref);return de&&de.obj&&de.obj.type===ne.type&&ne.ret.push(de),!0}function ae(oe,K,ne){const de=ne.cells.get(oe.ref);return de&&de.obj&&de.transform.transformer===ne.t&&ne.ret.push(de),!0}function me(oe,K,ne){const de=ne.cells.get(oe.ref);return de&&"error"===de.status&&de.transform.transformer===ne.t&&ne.ret.push(de),!0}O.root=c(()=>oe=>[oe.cells.get(oe.tree.root.ref)]),O.byRef=function H(...oe){return c(()=>K=>{const ne=[];for(const de of oe){const we=K.cells.get(de);we&&ne.push(we)}return ne})},O.byValue=function W(...oe){return c(()=>K=>oe)},O.rootsOfType=function Q(oe,K=ur.RootRef){return c(()=>ne=>{const de={roots:[],cells:ne.cells,type:oe.type};return bo.doPreOrder(ne.tree,ne.tree.transforms.get(K),de,ce),de.roots})},O.ofType=function fe(oe,K=ur.RootRef){return c(()=>ne=>{const de={ret:[],cells:ne.cells,type:oe.type};return bo.doPreOrder(ne.tree,ne.tree.transforms.get(K),de,be),de.ret})},O.ofTransformer=function X(oe,K=ur.RootRef){return c(()=>ne=>{const de={ret:[],cells:ne.cells,t:oe};return bo.doPreOrder(ne.tree,ne.tree.transforms.get(K),de,ae),de.ret})},O.ofTransformerWithError=function J(oe,K=ur.RootRef){return c(()=>ne=>{const de={ret:[],cells:ne.cells,t:oe};return bo.doPreOrder(ne.tree,ne.tree.transforms.get(K),de,me),de.ret})}})(u=e.Generators||(e.Generators={})),a("flatMap",l),e.flatMap=l,a("mapObject",d),e.mapObject=d,a("unique",f),e.unique=f,a("first",p),e.first=p,a("filter",m),e.filter=m,a("withStatus",h),e.withStatus=h,a("withTag",g),e.withTag=g,a("subtree",y),e.subtree=y,a("children",b),e.children=b,a("ofType",x),e.ofType=x,a("ancestor",_),e.ancestor=_,a("ancestorOfType",S),e.ancestorOfType=S,a("ancestorWithTransformer",A),e.ancestorWithTransformer=A,a("withTransformer",E),e.withTransformer=E,a("root",w),e.root=w,a("rootOfType",D),e.rootOfType=D,a("parent",I),e.parent=I,e.findAncestor=T,e.findRoot=M,e.findAncestorWithTransformer=N,e.findAncestorOfType=V,e.findRootOfType=F,e.findUniqueTagsInSubtree=function L(O,H,W){return bo.doPreOrder(O,O.transforms.get(H),{refs:{},tags:W},z).refs},e.findTagInSubtree=function j(O,H,W){return bo.doPreOrder(O,O.transforms.get(H),{ref:void 0,tag:W},Z).ref},e.findWithAllTags=function $(O,H,W){return bo.doPreOrder(O,O.transforms.get(H),{refs:[],tags:W},ee).refs},e.tryFindDecorator=function q(O,H,W){if(O.transforms.get(H).transformer===W)return O.cells.get(H);const fe=O.tree.children.get(H);if(1!==fe.size)return;const X=fe.first();return O.transforms.get(X).transformer.definition.isDecorator?q(O,X,W):void 0}}(In||(In={})),function(e){e.create=function t(){const n=new vVe,r=()=>n.create();return r.dispose=()=>n.dispose(),r.behavior=i=>n.behavior(i),r}}(wp||(wp={}));class vVe{constructor(){this._eventList=[],this._disposed=!1}create(){const t=new mr;return this._eventList.push(t),t}behavior(t){const n=new Ao(t);return this._eventList.push(n),n}dispose(){if(!this._disposed){for(const t of this._eventList)t.complete();this._disposed=!0}}}var _L=Symbol.for("immer-nothing"),rS=Symbol.for("immer-draftable"),zr=Symbol.for("immer-state");function Fs(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var o0=Object.getPrototypeOf;function dm(e){return!!e&&!!e[zr]}function lf(e){return!!e&&(zne(e)||Array.isArray(e)||!!e[rS]||!!e.constructor?.[rS]||oS(e)||sS(e))}var _Ve=Object.prototype.constructor.toString();function zne(e){if(!e||"object"!=typeof e)return!1;const t=o0(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===_Ve}function hv(e,t){0===s0(e)?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function s0(e){const t=e[zr];return t?t.type_:Array.isArray(e)?1:oS(e)?2:sS(e)?3:0}function iS(e,t){return 2===s0(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Gne(e,t,n){const r=s0(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function oS(e){return e instanceof Map}function sS(e){return e instanceof Set}function Bs(e){return e.copy_||e.base_}function SL(e,t){if(oS(e))return new Map(e);if(sS(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&zne(e))return o0(e)?{...e}:Object.assign(Object.create(null),e);const n=Object.getOwnPropertyDescriptors(e);delete n[zr];let r=Reflect.ownKeys(n);for(let i=0;i1&&(e.set=e.add=e.clear=e.delete=SVe),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>CL(r,!0))),e}function SVe(){Fs(2)}function tD(e){return Object.isFrozen(e)}var aS,wL={};function a0(e){const t=wL[e];return t||Fs(0),t}function nD(){return aS}function Hne(e,t){t&&(a0("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function AL(e){IL(e),e.drafts_.forEach(wVe),e.drafts_=null}function IL(e){e===aS&&(aS=e.parent_)}function qne(e){return aS=function CVe(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}(aS,e)}function wVe(e){const t=e[zr];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Wne(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[zr].modified_&&(AL(t),Fs(4)),lf(e)&&(e=rD(t,e),t.parent_||iD(t,e)),t.patches_&&a0("Patches").generateReplacementPatches_(n[zr].base_,e,t.patches_,t.inversePatches_)):e=rD(t,n,[]),AL(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==_L?e:void 0}function rD(e,t,n){if(tD(t))return t;const r=t[zr];if(!r)return hv(t,(i,o)=>$ne(e,r,t,i,o,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return iD(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const i=r.copy_;let o=i,s=!1;3===r.type_&&(o=new Set(i),i.clear(),s=!0),hv(o,(a,c)=>$ne(e,r,i,a,c,n,s)),iD(e,i,!1),n&&e.patches_&&a0("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function $ne(e,t,n,r,i,o,s){if(dm(i)){const c=rD(e,i,o&&t&&3!==t.type_&&!iS(t.assigned_,r)?o.concat(r):void 0);if(Gne(n,r,c),!dm(c))return;e.canAutoFreeze_=!1}else s&&n.add(i);if(lf(i)&&!tD(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;rD(e,i),(!t||!t.scope_.parent_)&&"symbol"!=typeof r&&Object.prototype.propertyIsEnumerable.call(n,r)&&iD(e,i)}}function iD(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&CL(t,n)}var TL={get(e,t){if(t===zr)return e;const n=Bs(e);if(!iS(n,t))return function IVe(e,t,n){const r=Yne(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}(e,n,t);const r=n[t];return e.finalized_||!lf(r)?r:r===DL(e.base_,t)?(EL(e),e.copy_[t]=uS(r,e)):r},has:(e,t)=>t in Bs(e),ownKeys:e=>Reflect.ownKeys(Bs(e)),set(e,t,n){const r=Yne(Bs(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=DL(Bs(e),t),o=i?.[zr];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function xVe(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,i)&&(void 0!==n||iS(e.base_,t)))return!0;EL(e),Ap(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==DL(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,EL(e),Ap(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Bs(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:r.enumerable,value:n[t]}},defineProperty(){Fs(11)},getPrototypeOf:e=>o0(e.base_),setPrototypeOf(){Fs(12)}},cS={};function DL(e,t){const n=e[zr];return(n?Bs(n):e)[t]}function Yne(e,t){if(!(t in e))return;let n=o0(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=o0(n)}}function Ap(e){e.modified_||(e.modified_=!0,e.parent_&&Ap(e.parent_))}function EL(e){e.copy_||(e.copy_=SL(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function uS(e,t){const n=oS(e)?a0("MapSet").proxyMap_(e,t):sS(e)?a0("MapSet").proxySet_(e,t):function AVe(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:nD(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,o=TL;n&&(i=[r],o=cS);const{revoke:s,proxy:a}=Proxy.revocable(i,o);return r.draft_=a,r.revoke_=s,a}(e,t);return(t?t.scope_:nD()).drafts_.push(n),n}function Xne(e){if(!lf(e)||tD(e))return e;const t=e[zr];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=SL(e,t.scope_.immer_.useStrictShallowCopy_)}else n=SL(e,!0);return hv(n,(r,i)=>{Gne(n,r,Xne(i))}),t&&(t.finalized_=!1),n}hv(TL,(e,t)=>{cS[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),cS.deleteProperty=function(e,t){return cS.set.call(this,e,t,void 0)},cS.set=function(e,t,n){return TL.set.call(this,e[0],t,n,e[0])};var u0,df,oD,yu=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if("function"==typeof t&&"function"!=typeof n){const o=n;n=t;const s=this;return function(c=o,...u){return s.produce(c,l=>n.call(this,l,...u))}}let i;if("function"!=typeof n&&Fs(6),void 0!==r&&"function"!=typeof r&&Fs(7),lf(t)){const o=qne(this),s=uS(t,void 0);let a=!0;try{i=n(s),a=!1}finally{a?AL(o):IL(o)}return Hne(o,r),Wne(i,o)}if(!t||"object"!=typeof t){if(i=n(t),void 0===i&&(i=t),i===_L&&(i=void 0),this.autoFreeze_&&CL(i,!0),r){const o=[],s=[];a0("Patches").generateReplacementPatches_(t,i,o,s),r(o,s)}return i}Fs(1)},this.produceWithPatches=(t,n)=>{if("function"==typeof t)return(s,...a)=>this.produceWithPatches(s,c=>t(c,...a));let r,i;return[this.produce(t,n,(s,a)=>{r=s,i=a}),r,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){lf(e)||Fs(8),dm(e)&&(e=function DVe(e){return dm(e)||Fs(10),Xne(e)}(e));const t=qne(this),n=uS(e,void 0);return n[zr].isManual_=!0,IL(t),n}finishDraft(e,t){const n=e&&e[zr];(!n||!n.isManual_)&&Fs(9);const{scope_:r}=n;return Hne(r,t),Wne(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=a0("Patches").applyPatches_;return dm(e)?r(e,t):this.produce(e,i=>r(i,t))}},c0=yu.produce,EVe=(yu.produceWithPatches.bind(yu),yu.setAutoFreeze.bind(yu));function Kne(...e){let t;const n=[];for(const r of e)if(r)if(t||(t=new Set),"string"==typeof r){if(t.has(r))continue;t.add(r),n.push(r)}else for(const i of r)t.has(i)||(t.add(i),n.push(i));return n}yu.setUseStrictShallowCopy.bind(yu),yu.applyPatches.bind(yu),yu.createDraft.bind(yu),yu.finishDraft.bind(yu),function(e){function t(s){if(!s.state||s.state.tree===s.editInfo.sourceTree)return s.tree.asImmutable();const a=s.state.tree.asTransient();for(const c of s.actions)switch(c.kind){case"add":a.add(c.transform);break;case"update":a.setParams(c.ref,c.params);break;case"delete":a.remove(c.ref);break;case"insert":{const u=a.children.get(c.ref).toArray();a.add(c.transform);for(const l of u)a.changeParent(l,c.transform.ref);break}}return s.editInfo.sourceTree=s.tree,a.asImmutable()}e.is=function n(s){return!!s&&"function"==typeof s.getTree},e.isTo=function r(s){return!!s&&"function"==typeof s.getTree&&"string"==typeof s.ref},e.Root=class i{get editInfo(){return this.state.editInfo}get currentTree(){return this.state.tree}to(a){const c="string"==typeof a?a:N2.is(a)?a.transform.ref:a.ref;return new o(this.state,c,this)}toRoot(){return new o(this.state,this.state.tree.root.ref,this)}delete(a){const c=ls.resolveRef(a);return c&&this.state.tree.transforms.has(c)?(this.editInfo.count++,this.state.tree.remove(c),this.state.actions.push({kind:"delete",ref:c}),this):this}getTree(){return t(this.state)}commit(a){if(!this.state.state)throw new Error("Cannot commit template tree");return this.state.state.runTask(this.state.state.updateTree(this,a))}constructor(a,c){this.state={state:c,tree:a.asTransient(),actions:[],editInfo:{applied:!1,sourceTree:a,count:0,lastUpdate:void 0}}}};class o{get editInfo(){return this.state.editInfo}get selector(){return new wte(this.ref,this.state.state)}getApplyRoot(){return bo.getDecoratorRoot(this.state.tree,this.ref)}apply(a,c,u){if(a.definition.isDecorator)return this.insert(a,c,u);const l=this.getApplyRoot(),d=a.apply(l,c,u);return this.state.tree.add(d),this.editInfo.count++,this.editInfo.lastUpdate=d.ref,this.state.actions.push({kind:"add",transform:d}),new o(this.state,d.ref,this.root)}applyOrUpdate(a,c,u,l){if(this.state.tree.transforms.has(a)){const d=this.to(a);return u&&d.update(u),d}return this.apply(c,u,{...l,ref:a})}applyOrUpdateTagged(a,c,u,l){if(c.definition.isDecorator)throw new Error("Can't use applyOrUpdateTagged on decorator transformers.");const d=this.getApplyRoot(),f=this.state.tree.children.get(d).values();for(;;){const m=f.next();if(m.done)break;const h=this.state.tree.transforms.get(m.value);if(h&&ur.hasTags(h,a)){const g=this.to(m.value);return g.updateTagged(u,Kne(h.tags,a,l&&l.tags)),g}}const p=c.apply(d,u,{...l,tags:Kne(a,l&&l.tags)});return this.state.tree.add(p),this.editInfo.count++,this.editInfo.lastUpdate=p.ref,this.state.actions.push({kind:"add",transform:p}),new o(this.state,p.ref,this.root)}group(a,c,u){return this.apply(a,c,u)}insert(a,c,u){const l=this.state.tree.children.get(this.ref).toArray(),d=a.apply(this.ref,c,u);this.state.tree.add(d);for(const f of l)this.state.tree.changeParent(f,d.ref);return this.editInfo.count++,this.editInfo.lastUpdate=d.ref,this.state.actions.push({kind:"insert",ref:this.ref,transform:d}),new o(this.state,d.ref,this.root)}updateTagged(a,c){(this.state.tree.setParams(this.ref,a)||this.state.tree.setTags(this.ref,c))&&(this.editInfo.count++,this.editInfo.lastUpdate=this.ref,this.state.actions.push({kind:"update",ref:this.ref,params:a}))}update(a,c){let u;if(c){const l=this.state.tree.transforms.get(this.ref);u=c0(l.params,c)}else u="function"==typeof a?c0(this.state.tree.transforms.get(this.ref).params,a):a;return this.state.tree.setParams(this.ref,u)&&(this.editInfo.count++,this.editInfo.lastUpdate=this.ref,this.state.actions.push({kind:"update",ref:this.ref,params:u})),this.root}to(a){return this.root.to(a)}toRoot(){return this.root.toRoot()}delete(a){return this.root.delete(a)}getTree(){return t(this.state)}commit(a){if(!this.state.state)throw new Error("Cannot commit template tree");return this.state.state.runTask(this.state.state.updateTree(this,a))}constructor(a,c,u){if(this.state=a,this.root=u,this.ref=c,!this.state.tree.transforms.has(c))throw new Error(`Could not find node '${c}'.`)}}e.To=o}(u0||(u0={}));class PVe{constructor(){this.ev=wp.create(),this.actions=new Map,this.fromTypeIndex=new Map,this.events={added:this.ev(),removed:this.ev()}}add(t){const n=Qe.is(t)?t.toAction():t;if(this.actions.has(n.id))return this;this.actions.set(n.id,n);for(const r of n.definition.from)this.fromTypeIndex.has(r.type)?this.fromTypeIndex.get(r.type).push(n):this.fromTypeIndex.set(r.type,[n]);return this.events.added.next(void 0),this}remove(t){const n=Qe.is(t)?t.toAction().id:Hr.is(t)?t:t.id,r=this.actions.get(n);if(!r)return this;this.actions.delete(n);for(const i of r.definition.from){const o=this.fromTypeIndex.get(i.type);o&&(Eg(o,r),0===o.length&&this.fromTypeIndex.delete(i.type))}return this.events.removed.next(void 0),this}fromCell(t,n){const r=t.obj;if(!r)return[];const i=this.fromTypeIndex.get(r.type);if(!i)return[];let o=!1;for(const a of i)if(a.definition.isApplicable){o=!0;break}if(!o)return i;const s=[];for(const a of i)a.definition.isApplicable?a.definition.isApplicable(r,t.transform,n)&&s.push(a):s.push(a);return s}dispose(){this.ev.dispose()}}!function(e){e.message=function t(o){return{type:"message",timestamp:new Date,message:o}},e.error=function n(o){return{type:"error",timestamp:new Date,message:o}},e.warning=function r(o){return{type:"warning",timestamp:new Date,message:o}},e.info=function i(o){return{type:"info",timestamp:new Date,message:o}}}(df||(df={})),function(e){e.Impl=class t{get current(){return this._current}set current(o){this._current=o}getAncestorOfType(o){if(!this._current)return;let s=this._current;for(;;){if(s=this.cells.get(s.transform.parent),!s.obj)return;if(s.obj.type===o.type)return s.obj;if(s.transform.ref===ur.RootRef)return}}getRootOfType(o){if(!this._current)return;let a,s=this._current;for(;;){if(!s.obj)return;if(s.obj.type===o.type&&(a=s),s.transform.ref===ur.RootRef)return a?a.obj:void 0;s=this.cells.get(s.transform.parent)}}constructor(o){this.cells=o,this._current=void 0}},e.getDecoratorChain=function n(i,o){const s=i.cells;let a=s.get(o);const c=[a];for(;a?.transform.transformer.definition.isDecorator;)a=s.get(a.transform.parent),c.push(a);return c},e.getRootOfType=function r(i,o,s){let a,c=i.cells.get(s);if(c)for(;;){if(!c.obj)return;if(c.obj.type===o.type&&(a=c),c.transform.ref===ur.RootRef)return a?a.obj:void 0;c=i.cells.get(c.transform.parent)}}}(oD||(oD={}));class MVe{constructor(){this.queue=[],this.signal=new mr}get length(){return this.queue.length}enqueue(t){return this.queue.push(t),1===this.queue.length||this.waitFor(t)}handled(t){Xx(this.queue,t),this.queue.length>0&&this.signal.next({v:this.queue[0],stillPresent:!0})}remove(t){const n=Xx(this.queue,t);return n&&this.signal.next({v:t,stillPresent:!1}),n}waitFor(t){return new Promise(n=>{const r=this.signal.subscribe(({v:i,stillPresent:o})=>{i===t&&(r.unsubscribe(),n(o))})})}}class sD{get tree(){return this._tree}get transforms(){return this._tree.transforms}get current(){return this.behaviors.currentObject.value.ref}get root(){return this.cells.get(this._tree.root.ref)}build(){return new u0.Root(this.tree,this)}addHistory(t,n){0!==this.historyCapacity&&(this.history.unshift([t,n||"Update"]),this.history.length>this.historyCapacity&&this.history.pop(),this.events.historyUpdated.next({state:this}))}clearHistory(){0!==this.history.length&&(this.history=[],this.events.historyUpdated.next({state:this}))}get latestUndoLabel(){return this.history.length>0?this.history[0][1]:void 0}get canUndo(){return this.history.length>0}undo(){var t=this;return Oe.create("Undo",function(){var n=ie(function*(r){const i=t.history.shift();if(i){t.events.historyUpdated.next({state:t}),t.undoingHistory=!0;try{yield t.updateTree(i[0],{canUndo:!1}).runInContext(r)}finally{t.undoingHistory=!1}}});return function(r){return n.apply(this,arguments)}}())}getSnapshot(){return{tree:bo.toJSON(this._tree)}}setSnapshot(t){const n=bo.fromJSON(t.tree);return this.updateTree(n)}setCurrent(t){this.behaviors.currentObject.next({state:this,ref:t})}updateCellState(t,n){const r=this.cells.get(t);if(!r)return;const i="function"==typeof n?n(r.state):n;ur.assignState(r.state,i)&&(r.transform=this._tree.assignState(r.transform.ref,i),this.events.cell.stateUpdated.next({state:this,ref:t,cell:r}))}dispose(){this.ev.dispose(),this.actions.dispose()}select(t){return In.select(t,this)}selectQ(t){return In.select("string"==typeof t?t:t(In.Generators),this)}applyAction(t,n,r=ur.RootRef){return Oe.create("Apply Action",i=>{const o=this.cells.get(r);if(!o)throw new Error(`'${r}' does not exist.`);if("ok"!==o.status)throw new Error(`Action cannot be applied to a cell with status '${o.status}'`);return FL(t.definition.run({ref:r,cell:o,a:o.obj,params:n,state:this},this.globalContext),i)})}transaction(t,n){var r=this;return Oe.create("State Transaction",function(){var i=ie(function*(o){const s=r.inTransaction,a=r._tree.asImmutable();let c=!1;try{s||r.behaviors.isUpdating.next(!0),r.inTransaction=!0,r.inTransactionError=!1,yield t(o),r.inTransactionError&&(c=!0,yield r.updateTree(a).runInContext(o))}catch(u){if(c||(c=!0,yield r.updateTree(a).runInContext(o),r.events.log.next(df.error("Error during state transaction, reverting"))),s)throw r.inTransactionError=!0,u;if(n?.rethrowErrors)throw u;console.error(u)}finally{s||(r.inTransaction=!1,r.events.changed.next({state:r,inTransaction:!1}),r.behaviors.isUpdating.next(!1),c||(n?.canUndo?r.addHistory(a,"string"==typeof n.canUndo?n.canUndo:void 0):r.clearHistory()))}});return function(o){return i.apply(this,arguments)}}())}get inUpdate(){return this._inUpdate}updateTree(t,n){var r=this;const i={tree:t,options:n};return Oe.create("Update Tree",function(){var o=ie(function*(s){if(!(yield r.updateQueue.enqueue(i)))return;r._inUpdate=!0;const c=n?.canUndo?r._tree.asImmutable():void 0;let u=!1;r.inTransaction||r.behaviors.isUpdating.next(!0);try{if(u0.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}r.reverted=!1;const l=n&&(n.revertIfAborted||n.revertOnError)?yield r._revertibleTreeUpdate(s,i,n):yield r._updateTree(s,i);return u=r.reverted,l.ctx.hadError&&(r.inTransactionError=!0),l.cell?new wte(l.cell.transform.ref,r):void 0}finally{r._inUpdate=!1,r.updateQueue.handled(i),r.inTransaction||(r.behaviors.isUpdating.next(!1),n?.canUndo?u||r.addHistory(c,"string"==typeof n.canUndo?n.canUndo:void 0):r.undoingHistory||r.clearHistory())}});return function(s){return o.apply(this,arguments)}}(),()=>{this.updateQueue.remove(i)})}_revertibleTreeUpdate(t,n,r){var i=this;return ie(function*(){const o=i.tree,s=yield i._updateTree(t,n);return(s.ctx.hadError||s.ctx.wasAborted)&&r.revertOnError||s.ctx.wasAborted&&r.revertIfAborted?(i.reverted=!0,yield i._updateTree(t,{tree:o,options:n.options})):s})()}_updateTree(t,n){var r=this;return ie(function*(){let i=!1;const o=r.updateTreeAndCreateCtx(n.tree,t,n.options);try{return i=yield function kVe(e){return PL.apply(this,arguments)}(o),u0.isTo(n.tree)?{ctx:o,cell:r.select(n.tree.ref)[0]}:{ctx:o}}finally{r.spine.current=void 0,i&&r.events.changed.next({state:r,inTransaction:r.inTransaction})}})()}updateTreeAndCreateCtx(t,n,r){const i=(u0.is(t)?t.getTree():t).asTransient(),o=this._tree;this._tree=i;const s=this.cells,a={parent:this,editInfo:u0.is(t)?t.editInfo:void 0,errorFree:this.errorFree,taskCtx:n,oldTree:o,tree:i,cells:this.cells,spine:this.spine,results:[],options:{...RVe,...r},changed:!1,hadError:!1,wasAborted:!1,newCurrent:void 0,getCellData:c=>{var u;return null===(u=s.get(c).obj)||void 0===u?void 0:u.data}};return this.errorFree=!0,a}constructor(t,n){this.errorFree=!0,this.ev=wp.create(),this.globalContext=void 0,this.events={cell:{stateUpdated:this.ev(),created:this.ev(),removed:this.ev()},object:{updated:this.ev(),created:this.ev(),removed:this.ev()},log:this.ev(),changed:this.ev(),historyUpdated:this.ev()},this.behaviors={currentObject:this.ev.behavior({state:this,ref:ur.RootRef}),isUpdating:this.ev.behavior(!1)},this.actions=new PVe,this.cells=new Map,this.spine=new oD.Impl(this.cells),this.tryGetCellData=o=>{var s,a;const c=null===(a=null===(s=this.cells.get(o))||void 0===s?void 0:s.obj)||void 0===a?void 0:a.data;if(void 0===c)throw new Error(`Cell '${o}' data undefined.`);return c},this.historyCapacity=5,this.history=[],this.undoingHistory=!1,this.inTransaction=!1,this.inTransactionError=!1,this._inUpdate=!1,this.reverted=!1,this.updateQueue=new MVe,this._tree=bo.createEmpty(ur.createRoot(n&&n.rootState)).asTransient();const i=this._tree.root;this.runTask=n.runTask,void 0!==n?.historyCapacity&&(this.historyCapacity=n.historyCapacity),this.cells.set(i.ref,{parent:this,transform:i,sourceRef:void 0,obj:t,status:"ok",state:{...i.state},errorText:void 0,params:{definition:{},values:{}},paramsNormalizedVersion:i.version,dependencies:{dependentBy:[],dependsOn:[]},cache:{}}),this.globalContext=n&&n.globalContext}}!function(e){let n;e.create=function t(r,i){return new e(r,i)},(n=e.ObjectEvent||(e.ObjectEvent={})).isCell=function i(o,s){return!!s&&o.ref===s.transform.ref&&o.state===s.parent}}(sD||(sD={}));const RVe={doNotLogTiming:!1,doNotUpdateCurrent:!0,revertIfAborted:!1,revertOnError:!1,canUndo:!1};function PL(){return PL=ie(function*(e){let n,i,r=[];if(e.editInfo&&1===e.editInfo.count&&e.editInfo.lastUpdate&&e.editInfo.sourceTree===e.oldTree)n=[],i=[e.editInfo.lastUpdate];else{n=function OVe(e){const t={newTree:e.tree,cells:e.cells,deletes:[]};return bo.doPostOrder(e.oldTree,e.oldTree.root,t,BVe),t.deletes}(e);const a=e.parent.current;let c=!1;for(const u of n)if(u===a){c=!0;break}if(c){const u=Zne(e.oldTree,a,n,e.cells);e.parent.setCurrent(u)}for(let u=n.length-1;u>=0;u--){const l=e.cells.get(n[u]);l&&cD(l.transform,l.obj,l?.transform.params,l.cache,e.parent.globalContext)}for(const u of n){const l=e.cells.get(u);l&&(l.parent=void 0,GVe(l));const d=l&&l.obj;e.cells.delete(u),r.push(d)}i=function NVe(e,t){const n={roots:[],cells:e};return bo.doPreOrder(t,t.root,n,FVe),n.roots}(e.cells,e.tree)}const o=function qVe(e,t){const n={ctx:e,visited:new Set,added:[]};for(const i of t)bo.doPreOrder(e.tree,e.tree.transforms.get(i),n,jVe);for(const i of n.added)HVe(i,e);let r;return n.visited.forEach(i=>{const o=e.cells.get(i);for(const s of o.dependencies.dependentBy)n.visited.has(s.transform.ref)||(r||(r=kr.create()),kr.add(r,s.transform.ref,s))}),{added:n.added,dependent:r?r.array:void 0}}(e,i);for(const a of o.added)e.parent.events.cell.created.next({state:e.parent,ref:a.transform.ref,cell:a});for(let a=0;a0||i.length>0||e.changed}),PL.apply(this,arguments)}function FVe(e,t,n){const r=n.cells.get(e.ref);return r&&r.transform.version===e.version?!("error"===r.status||r&&r.obj===li.Null):(n.roots.push(e.ref),!1)}function BVe(e,t,n){!n.newTree.transforms.has(e.ref)&&n.cells.has(e.ref)&&n.deletes.push(e.ref)}function LVe(e,t,n){const r=n.cells.get(e.ref);!r||!ur.syncState(r.state,e.state)||n.parent.events.cell.stateUpdated.next({state:n.parent,ref:e.ref,cell:r})}function aD(e,t,n,r){const i=e.cells.get(t),o=i.status!==n;i.status=n,i.errorText=r,o&&e.parent.events.cell.stateUpdated.next({state:e.parent,ref:t,cell:i})}function VVe(e,t,n){n.cells.get(e.ref).transform=e,aD(n,e.ref,"pending")}function GVe(e){for(const t of e.dependencies.dependsOn)Eg(t.dependencies.dependentBy,e)}function jVe(e,t,{ctx:n,added:r,visited:i}){if(i.add(e.ref),n.cells.has(e.ref))return;const o={parent:n.parent,transform:e,sourceRef:void 0,status:"pending",state:{...e.state},errorText:void 0,params:void 0,paramsNormalizedVersion:"",dependencies:{dependentBy:[],dependsOn:[]},cache:void 0};n.cells.set(e.ref,o),r.push(o)}function HVe(e,t){if(e.transform.dependsOn)for(const n of e.transform.dependsOn){if(!t.tree.transforms.get(n))throw new Error("Cannot depend on a non-existent transform.");const i=t.cells.get(n);eo(e.dependencies.dependsOn,i),eo(i.dependencies.dependentBy,e)}}function Zne(e,t,n,r){return Qne(e,t,new Set(n),r)}function Qne(e,t,n,r){if(t===ur.RootRef)return t;const i=e.transforms.get(t),o=e.children.get(i.parent).values();let s,a=!1;for(;;){const c=o.next();if(c.done)break;if(n.has(c.value))continue;const u=r.get(c.value);if(!u||"error"===u.status||u.obj===li.Null)continue;const l=e.transforms.get(c.value);if(!l.state.isGhost){if(c.value===t){a=!0,n.has(t)||(s=t);continue}if(a)return l.ref;s=l.ref}}return s||Qne(e,i.parent,n,r)}function ML(e,t,n,r){r||(e.hadError=!0,e.parent.errorFree=!1);const i=e.cells.get(t);if(n){e.wasAborted=e.wasAborted||Oe.isAbort(n);const s=""+n;aD(e,t,"error",s),r||e.parent.events.log.next({type:"error",timestamp:new Date,message:s})}else i.params=void 0;if(i.obj){const s=i.obj;i.obj=void 0,i.cache=void 0,e.parent.events.object.removed.next({state:e.parent,ref:t,obj:s})}const o=e.tree.children.get(t).values();for(;;){const s=o.next();if(s.done)return;ML(e,s.value,void 0,r)}}const WVe="Parent is null";function Jne(e,t){return RL.apply(this,arguments)}function RL(){return RL=ie(function*(e,t){aD(e,t,"processing");let n=!1;try{const i=yi(),o=yield function YVe(e,t){return kL.apply(this,arguments)}(e,t),s=yi()-i;"none"!==o.action&&(e.changed=!0),aD(e,t,"ok"),e.results.push(o),"created"===o.action?(n=o.obj===li.Null,!n&&!e.options.doNotLogTiming&&e.parent.events.log.next(df.info(`Created ${o.obj.label} in ${WF(s)}.`))):("updated"===o.action||"replaced"===o.action)&&(n=o.obj===li.Null,!n&&!e.options.doNotLogTiming&&e.parent.events.log.next(df.info(`Updated ${o.obj.label} in ${WF(s)}.`)))}catch(i){return e.changed=!0,e.hadError||(e.newCurrent=t),ML(e,t,i,!1),void console.error(i)}const r=e.tree.children.get(t).values();for(;;){const i=r.next();if(i.done)return;n?ML(e,i.value,void 0,!0):yield Jne(e,i.value)}}),RL.apply(this,arguments)}function kL(){return kL=ie(function*(e,t){var n;const{oldTree:r,tree:i}=e,o=e.cells.get(t),s=o.transform;if(o.transform.ref===ur.RootRef)return{action:"none"};const a=e.cells.get(o.transform.parent);if(a?.obj===li.Null)return o.sourceRef=a.transform.ref,r.transforms.has(t)&&o.params?(cD(s,o.obj,o.params.values,o.cache,e.parent.globalContext),o.params=void 0,o.obj=li.Null,{ref:t,action:"updated",obj:o.obj}):(o.params=void 0,{ref:t,action:"created",obj:li.Null});const u=0===s.transformer.definition.from.length?a:In.findAncestorOfType(i,e.cells,t,s.transformer.definition.from);if(!u)throw new Error(`No suitable parent found for '${t}'`);e.spine.current=o;const l=u.obj;o.sourceRef=u.transform.ref;const d=function $Ve(e,t,n,r){const i=t.transformer.definition.params,o=i?i(n,e.parent.globalContext):{};if(r.paramsNormalizedVersion!==t.version)t.params=C.normalizeParams(o,t.params,"all"),r.paramsNormalizedVersion=t.version;else{const s=C.getDefaultValues(o);t.params=t.params?function AMe(e,t){for(const n of Object.keys(t))UI.call(t,n)&&typeof e[n]>"u"&&(e[n]=t[n]);return e}(t.params,s):s}return C.resolveRefs(o,t.params,e.getCellData),{definition:o,values:t.params}}(e,s,l,o);if(!r.transforms.has(t)||!o.params){o.params=d;const f=yield tre(e,o,s.transformer,l,d.values);return NL(f,s),o.obj=f,{ref:t,action:"created",obj:f}}{const f=o.params.values,p=o.cache,m=null===(n=o.obj)||void 0===n?void 0:n.data,h=d.values;switch(o.params=d,o.obj&&o.obj!==li.Null?yield function XVe(e,t,n,r,i,o,s){return BL.apply(this,arguments)}(e,o,s.transformer,l,o.obj,f,h):Qe.UpdateResult.Recreate){case Qe.UpdateResult.Recreate:{const y=o.obj;cD(s,y,f,p,e.parent.globalContext);const b=yield tre(e,o,s.transformer,l,h);return NL(b,s),o.obj=b,{ref:t,action:"replaced",oldObj:y,obj:b}}case Qe.UpdateResult.Updated:return NL(o.obj,s),{ref:t,action:"updated",oldData:m,obj:o.obj};case Qe.UpdateResult.Null:return cD(s,o.obj,f,p,e.parent.globalContext),o.obj=li.Null,{ref:t,action:"updated",obj:o.obj};default:return{action:"none"}}}}),kL.apply(this,arguments)}function cD(e,t,n,r,i){var o,s;null===(s=(o=e.transformer.definition).dispose)||void 0===s||s.call(o,{b:t!==li.Null?t:void 0,params:n,cache:r},i)}function NL(e,t){!e||e===li.Null||(e.tags=t.tags)}function FL(e,t){return"function"==typeof e.runInContext?e.runInContext(t):e}function ere(e){if(0===e.dependencies.dependsOn.length)return;const t=Object.create(null);for(const n of e.dependencies.dependsOn){if(!n.obj)throw new Error("Unresolved dependency.");t[n.transform.ref]=n.obj}return t}function tre(e,t,n,r,i){return t.cache||(t.cache=Object.create(null)),FL(n.definition.apply({a:r,params:i,cache:t.cache,spine:e.spine,dependencies:ere(t)},e.parent.globalContext),e.taskCtx)}function BL(){return BL=ie(function*(e,t,n,r,i,o,s){return n.definition.update?(t.cache||(t.cache=Object.create(null)),FL(n.definition.update({a:r,oldParams:o,b:i,newParams:s,cache:t.cache,spine:e.spine,dependencies:ere(t)},e.parent.globalContext),e.taskCtx)):Qe.UpdateResult.Recreate}),BL.apply(this,arguments)}var pe,Rt;!function(e){function r(f){return e.Create({...f,typeClass:"Representation3D"})}e.Create=li.factory(),e.isRepresentation3D=function t(f){return!!f&&"Representation3D"===f.type.typeClass},e.isBehavior=function n(f){return!!f&&"Behavior"===f.type.typeClass},e.CreateRepresentation3D=r,e.CreateBehavior=function i(f){return e.Create({...f,typeClass:"Behavior"})};class o extends(e.Create({name:"Root",typeClass:"Root"})){}e.Root=o;class s extends(e.Create({name:"Group",typeClass:"Group"})){}let a,c,u,l,d;e.Group=s,function(f){class p extends(e.Create({name:"String Data",typeClass:"Data"})){}f.String=p;class m extends(e.Create({name:"Binary Data",typeClass:"Data"})){}f.Binary=m;class h extends(e.Create({name:"Data Blob",typeClass:"Data"})){}f.Blob=h}(a=e.Data||(e.Data={})),function(f){class p extends(e.Create({name:"JSON Data",typeClass:"Data"})){}f.Json=p;class m extends(e.Create({name:"CIF File",typeClass:"Data"})){}f.Cif=m;class h extends(e.Create({name:"Cube File",typeClass:"Data"})){}f.Cube=h;class g extends(e.Create({name:"PSF File",typeClass:"Data"})){}f.Psf=g;class y extends(e.Create({name:"PRMTOP File",typeClass:"Data"})){}f.Prmtop=y;class b extends(e.Create({name:"TOP File",typeClass:"Data"})){}f.Top=b;class x extends(e.Create({name:"PLY File",typeClass:"Data"})){}f.Ply=x;class _ extends(e.Create({name:"CCP4/MRC/MAP File",typeClass:"Data"})){}f.Ccp4=_;class S extends(e.Create({name:"DSN6/BRIX File",typeClass:"Data"})){}f.Dsn6=S;class A extends(e.Create({name:"DX File",typeClass:"Data"})){}f.Dx=A;class E extends(e.Create({name:"Format Blob",typeClass:"Data"})){}f.Blob=E}(c=e.Format||(e.Format={})),function(f){class p extends(e.Create({name:"Coordinates",typeClass:"Object"})){}f.Coordinates=p;class m extends(e.Create({name:"Topology",typeClass:"Object"})){}f.Topology=m;class h extends(e.Create({name:"Model",typeClass:"Object"})){}f.Model=h;class g extends(e.Create({name:"Trajectory",typeClass:"Object"})){}f.Trajectory=g;class y extends(e.Create({name:"Structure",typeClass:"Object"})){}f.Structure=y,function(b){class x extends(r({name:"Structure 3D"})){}b.Representation3D=x;class _ extends(e.Create({name:"Structure 3D State",typeClass:"Object"})){}b.Representation3DState=_;class S extends(e.Create({name:"Selections",typeClass:"Object"})){}b.Selections=S}(y=f.Structure||(f.Structure={}))}(u=e.Molecule||(e.Molecule={})),function(f){class p extends(e.Create({name:"Volume",typeClass:"Object"})){}f.Data=p;class m extends(e.Create({name:"Lazy Volume",typeClass:"Object"})){}f.Lazy=m;class h extends(r({name:"Volume 3D"})){}f.Representation3D=h}(l=e.Volume||(e.Volume={})),function(f){class p extends(e.Create({name:"Shape Provider",typeClass:"Object"})){}f.Provider=p;class m extends(r({name:"Shape 3D"})){}f.Representation3D=m}(d=e.Shape||(e.Shape={}))}(pe||(pe={})),function(e){e.CreateBuiltIn=Qe.factory("ms-plugin"),e.BuiltIn=Qe.builderFactory("ms-plugin")}(Rt||(Rt={}));const nre=.529177210859;function JVe(e,t){return Oe.create("Parse Cube",function(){var n=ie(function*(r){yield r.update("Reading header...");const i=ht(e),{header:o,atoms:s}=function KVe(e){const t=ht.readLines(e,6),n=(b,x)=>{const _=+t[b].trim().split(/\s+/g)[x];return Number.isNaN(_)?0:_},r=b=>{const x=n(b+2,0),_=nre;return[Math.abs(x),v.create(n(b+2,1)*_,n(b+2,2)*_,n(b+2,3)*_),x]},i=t[0].trim(),o=t[1].trim(),[s,a,c]=r(0),[u,l]=r(1),[d,f]=r(2),[p,m]=r(3),h=function ZVe(e,t,n){const r=new Int32Array(t),i=new Float64Array(t),o=new Float32Array(t),s=new Float32Array(t),a=new Float32Array(t);for(let c=0;c=0){let b=n(2,4);0===b&&(b=1);for(let x=0;x{const u=Math.min(r,s+a);for(let l=s;la.update({current:Math.min(u,r),max:r}))}(r,i,o);return Fr.success({header:o,atoms:s,values:a,name:t})});return function(r){return n.apply(this,arguments)}}())}function rre(e){const t={h:v()};let n=0,r=0;const i=/\s+/g;for(;;){const o=ht.readLine(e);let s;if(o.startsWith("object 1"))s=o.split(i),t.dim=v.create(parseInt(s[5]),parseInt(s[6]),parseInt(s[7]));else if(o.startsWith("origin"))s=o.split(i),t.min=v.create(parseFloat(s[1]),parseFloat(s[2]),parseFloat(s[3]));else if(o.startsWith("delta"))s=o.split(i),0===r?t.h[0]=parseFloat(s[1]):1===r?t.h[1]=parseFloat(s[2]):2===r&&(t.h[2]=parseFloat(s[3])),r+=1;else if(o.startsWith("object 3")){n+=o.length+1;break}n+=o.length+1}return{header:t,headerByteCount:n}}function OL(){return OL=ie(function*(e,t,n){yield e.update("Reading header...");const r=ht(t),{header:i}=rre(r);yield e.update("Reading values...");const o=yield function eze(e,t,n){const r=n.dim[0]*n.dim[1]*n.dim[2],i=1e6,o=new Float64Array(r);let s=0;return op(e,i,o,(a,c)=>{const u=Math.min(r,s+a);for(let l=s;la.update({current:Math.min(u,r),max:r}))}(e,r,i);return Fr.success({header:i,values:o,name:n})}),OL.apply(this,arguments)}function LL(){return LL=ie(function*(e,t,n){yield e.update("Reading header...");const i=ht(jB(t,0,1e3)),{header:o,headerByteCount:s}=rre(i);yield e.update("Reading values...");const a=o.dim[0]*o.dim[1]*o.dim[2],c=new DataView(t.buffer,t.byteOffset+s),u=new Float64Array(a);for(let l=0;l{e.set(xn[t],t)})}(),Object.keys({NATOM:"",NTYPES:"",NBONH:"",MBONA:"",NTHETH:"",MTHETA:"",NPHIH:"",MPHIA:"",NHPARM:"",NPARM:"",NNB:"",NRES:"",NBONA:"",NTHETA:"",NPHIA:"",NUMBND:"",NUMANG:"",NPTRA:"",NATYP:"",NPHB:"",IFPERT:"",NBPER:"",NGPER:"",NDPER:"",MBPER:"",MGPER:"",MDPER:"",IFBOX:"",NMXRS:"",IFCAP:"",NUMEXTRA:"",NCOPY:""})),{readLine:uD,markLine:ore,trim:ize}=ht;function sze(e){const{tokenizer:t}=e,n=[];for(;t.tokenEnd{n[i]=0});let r=0;for(;t.tokenEnd1e5&&t.shouldUpdate&&(o=n.position,yield t.update({current:n.position,max:n.length}));const s=uD(r.tokenizer).trim();if(s.startsWith("%VERSION"))i.version=s.substring(8).trim();else if(s.startsWith("%FLAG")){const a=s.substring(5).trim();if(!uD(r.tokenizer).trim().startsWith("%FORMAT"))throw new Error("expected %FORMAT");if("TITLE"===a)i.title=sze(r);else if("POINTERS"===a)i.pointers=aze(r);else if("ATOM_NAME"===a){const u=fm(r,i.pointers.NATOM,20,4);i.atomName=Jt(u)(te.Schema.str)}else if("CHARGE"===a){const u=fm(r,i.pointers.NATOM,5,16);i.charge=Jt(u)(te.Schema.float)}else if("MASS"===a){const u=fm(r,i.pointers.NATOM,5,16);i.mass=Jt(u)(te.Schema.float)}else if("RESIDUE_LABEL"===a){const u=fm(r,i.pointers.NRES,20,4);i.residueLabel=Jt(u)(te.Schema.str)}else if("RESIDUE_POINTER"===a){const u=fm(r,i.pointers.NRES,10,8);i.residuePointer=Jt(u)(te.Schema.int)}else if("BONDS_INC_HYDROGEN"===a){const u=fm(r,3*i.pointers.NBONH,10,8);i.bondsIncHydrogen=Jt(u)(te.Schema.int)}else if("BONDS_WITHOUT_HYDROGEN"===a){const u=fm(r,3*i.pointers.NBONA,10,8);i.bondsWithoutHydrogen=Jt(u)(te.Schema.int)}else if("RADII"===a){const u=fm(r,i.pointers.NATOM,5,16);i.radii=Jt(u)(te.Schema.float)}else for(;n.tokenEnd=t.length));){const i=t.data[t.position];if("["===i)break;if(";"!==i&&"*"!==i){for(let o=0;o<2;++o)switch(hm(t),lD(t),zL(t),o){case 0:He.add(n,t.tokenStart,t.tokenEnd);break;case 1:He.add(r,t.tokenStart,t.tokenEnd)}pze(t),lD(t)}else pm(t)}return Xn.ofColumns(fze,{compound:Jt(n)(te.Schema.str),molCount:Jt(r)(te.Schema.int)})}function GL(){return GL=ie(function*(e,t){const n=ht(e),r=function hze(e,t){return{tokenizer:e,runtimeCtx:t}}(n,t),i=Object.create(null);let o=0;i.compounds={};let s={},a="";function c(){a&&s.atoms&&(i.compounds[a]=s,s={},a="")}for(;n.tokenEnd1e5&&t.shouldUpdate&&(o=n.position,yield t.update({current:n.position,max:n.length}));const u=VL(r.tokenizer).trim();if(u&&"*"!==u[0]&&";"!==u[0]){if(u.startsWith("#include"))throw new Error("#include statements not allowed");if(u.startsWith("[")){const l=u.match(mze);if(null===l)throw new Error("expected field name");const d=l[1];if("moleculetype"===d)c(),a=yze(r);else if("atoms"===d)s.atoms=bze(r);else if("bonds"===d)s.bonds=vze(r);else if("system"===d)i.system=_ze(r);else if("molecules"===d)c(),i.molecules=xze(r);else for(;n.tokenEndOe.create("Download",function(){var r=ie(function*(i){const o=fr.getUrlAsset(n.managers.asset,e.url),s=yield n.managers.asset.resolve(o,e.isBinary?"binary":"string").runInContext(i);return t.asset=s,e.isBinary?new pe.Data.Binary(s.data,{label:e.label?e.label:o.url}):new pe.Data.String(s.data,{label:e.label?e.label:o.url})});return function(i){return r.apply(this,arguments)}}()),dispose({cache:e}){var t;null===(t=e?.asset)||void 0===t||t.dispose()},update:({oldParams:e,newParams:t,b:n})=>e.url!==t.url||e.isBinary!==t.isBinary?Qe.UpdateResult.Recreate:e.label!==t.label?(n.label=t.label||("string"==typeof t.url?t.url:t.url.url),Qe.UpdateResult.Updated):Qe.UpdateResult.Unchanged}),are=Rt.BuiltIn({name:"download-blob",display:{name:"Download Blob",description:"Download multiple string or binary data from the specified URLs."},from:pe.Root,to:pe.Data.Blob,params:{sources:C.ObjectList({id:C.Text("",{label:"Unique ID"}),url:C.Url("https://www.ebi.ac.uk/pdbe/static/entry/1cbs_updated.cif",{description:"Resource URL. Must be the same domain or support CORS."}),isBinary:C.Optional(C.Boolean(!1,{description:"If true, download data as binary (string otherwise)"})),canFail:C.Optional(C.Boolean(!1,{description:"Indicate whether the download can fail and not be included in the blob as a result."}))},e=>`${e.id}: ${e.url}`),maxConcurrency:C.Optional(C.Numeric(4,{min:1,max:12,step:1},{description:"The maximum number of concurrent downloads."}))}})({apply:({params:e,cache:t},n)=>Oe.create("Download Blob",function(){var r=ie(function*(i){const o=[],s=yield function ILe(e,t,n,r){return LO.apply(this,arguments)}(i,n.managers.asset,e.sources,e.maxConcurrency||4),a=[];for(let c=0;cOe.create("Raw Data",ie(function*(){return"string"==typeof e.data?new pe.Data.String(e.data,{label:e.label?e.label:"String"}):Array.isArray(e.data)||e.data instanceof ArrayBuffer?new pe.Data.Binary(new Uint8Array(e.data),{label:e.label?e.label:"Binary"}):e.data instanceof Uint8Array?new pe.Data.Binary(e.data,{label:e.label?e.label:"Binary"}):void Rr()})),update:({oldParams:e,newParams:t,b:n})=>e.data!==t.data?Qe.UpdateResult.Recreate:e.label!==t.label?(n.label=t.label||n.label,Qe.UpdateResult.Updated):Qe.UpdateResult.Unchanged,customSerialization:{toJSON(e){if("string"==typeof e.data||Array.isArray(e.data))return e;if(e.data instanceof ArrayBuffer){const t=new Uint8Array(e.data),n=new Array(t.length);for(let r=0,i=t.length;re}}),ure=Rt.BuiltIn({name:"read-file",display:{name:"Read File",description:"Read string or binary data from the specified file"},from:pe.Root,to:[pe.Data.String,pe.Data.Binary],params:{file:C.File(),label:C.Optional(C.Text("")),isBinary:C.Optional(C.Boolean(!1,{description:"If true, open file as as binary (string otherwise)"}))}})({apply:({params:e,cache:t},n)=>Oe.create("Open File",function(){var r=ie(function*(i){if(null===e.file)return n.log.error("No file(s) selected"),li.Null;const o=yield n.managers.asset.resolve(e.file,e.isBinary?"binary":"string").runInContext(i);return t.asset=o,e.isBinary?new pe.Data.Binary(o.data,{label:e.label?e.label:e.file.name}):new pe.Data.String(o.data,{label:e.label?e.label:e.file.name})});return function(i){return r.apply(this,arguments)}}()),dispose({cache:e}){var t;null===(t=e?.asset)||void 0===t||t.dispose()},update({oldParams:e,newParams:t,b:n}){var r;return e.label!==t.label?(n.label=t.label||(null===(r=e.file)||void 0===r?void 0:r.name)||"",Qe.UpdateResult.Updated):Qe.UpdateResult.Unchanged},isSerializable:()=>({isSerializable:!1,reason:"Cannot serialize user loaded files."})}),wze=Rt.BuiltIn({name:"parse-blob",display:{name:"Parse Blob",description:"Parse multiple data enties"},from:pe.Data.Blob,to:pe.Format.Blob,params:{formats:C.ObjectList({id:C.Text("",{label:"Unique ID"}),format:C.Select("cif",[["cif","cif"]])},e=>`${e.id}: ${e.format}`)}})({apply:({a:e,params:t},n)=>Oe.create("Parse Blob",function(){var r=ie(function*(i){const o=new Map;for(const a of t.formats)o.set(a.id,a.format);const s=[];for(const a of e.data){if(!o.has(a.id))continue;const c=yield("string"===a.kind?od.parse(a.data):od.parseBinary(a.data)).runInContext(i);if(c.isError)throw new Error(`${a.id}: ${c.message}`);s.push({id:a.id,kind:"cif",data:c.result})}return new pe.Format.Blob(s,{label:"Format Blob",description:`${s.length} ${1===s.length?"entry":"entries"}`})});return function(i){return r.apply(this,arguments)}}())}),Aze=Rt.BuiltIn({name:"parse-cif",display:{name:"Parse CIF",description:"Parse CIF from String or Binary data"},from:[pe.Data.String,pe.Data.Binary],to:pe.Format.Cif})({apply:({a:e})=>Oe.create("Parse CIF",function(){var t=ie(function*(n){const r=yield("string"==typeof e.data?od.parse(e.data):od.parseBinary(e.data)).runInContext(n);if(r.isError)throw new Error(r.message);return 0===r.result.blocks.length?li.Null:new pe.Format.Cif(r.result)});return function(n){return t.apply(this,arguments)}}())}),Ize=Rt.BuiltIn({name:"parse-cube",display:{name:"Parse Cube",description:"Parse Cube from String data"},from:pe.Data.String,to:pe.Format.Cube})({apply:({a:e})=>Oe.create("Parse Cube",function(){var t=ie(function*(n){const r=yield JVe(e.data,e.label).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Cube(r.result)});return function(n){return t.apply(this,arguments)}}())}),Tze=Rt.BuiltIn({name:"parse-psf",display:{name:"Parse PSF",description:"Parse PSF from String data"},from:[pe.Data.String],to:pe.Format.Psf})({apply:({a:e})=>Oe.create("Parse PSF",function(){var t=ie(function*(n){const r=yield function bUe(e){return Oe.create("Parse PSF",function(){var t=ie(function*(n){return yield function yUe(e,t){return w4.apply(this,arguments)}(e,n)});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Psf(r.result)});return function(n){return t.apply(this,arguments)}}())}),Dze=Rt.BuiltIn({name:"parse-prmtop",display:{name:"Parse PRMTOP",description:"Parse PRMTOP from String data"},from:[pe.Data.String],to:pe.Format.Prmtop})({apply:({a:e})=>Oe.create("Parse PRMTOP",function(){var t=ie(function*(n){const r=yield function uze(e){return Oe.create("Parse PRMTOP",function(){var t=ie(function*(n){return yield function cze(e,t){return UL.apply(this,arguments)}(e,n)});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Prmtop(r.result)});return function(n){return t.apply(this,arguments)}}())}),Eze=Rt.BuiltIn({name:"parse-top",display:{name:"Parse TOP",description:"Parse TOP from String data"},from:[pe.Data.String],to:pe.Format.Top})({apply:({a:e})=>Oe.create("Parse TOP",function(){var t=ie(function*(n){const r=yield function Cze(e){return Oe.create("Parse TOP",function(){var t=ie(function*(n){return yield function Sze(e,t){return GL.apply(this,arguments)}(e,n)});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Top(r.result)});return function(n){return t.apply(this,arguments)}}())}),Pze=Rt.BuiltIn({name:"parse-ply",display:{name:"Parse PLY",description:"Parse PLY from String data"},from:[pe.Data.String],to:pe.Format.Ply})({apply:({a:e})=>Oe.create("Parse PLY",function(){var t=ie(function*(n){const r=yield function lUe(e){return Oe.create("Parse PLY",function(){var t=ie(function*(n){return yield function uUe(e,t){return _4.apply(this,arguments)}(e,n)});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Ply(r.result,{label:r.result.comments[0]||"PLY Data"})});return function(n){return t.apply(this,arguments)}}())}),Mze=Rt.BuiltIn({name:"parse-ccp4",display:{name:"Parse CCP4/MRC/MAP",description:"Parse CCP4/MRC/MAP from Binary data"},from:[pe.Data.Binary],to:pe.Format.Ccp4})({apply:({a:e})=>Oe.create("Parse CCP4/MRC/MAP",function(){var t=ie(function*(n){const r=yield function q8e(e,t){return function H8e(e,t){return Oe.create("Parse CCP4/MRC/MAP",function(){var n=ie(function*(r){try{return Fr.success(yield function j8e(e,t,n){return h4.apply(this,arguments)}(e,t,r))}catch(i){return Fr.error(i)}});return function(r){return n.apply(this,arguments)}}())}(FT.fromBuffer(cd.fromUint8Array(e),t),e.length)}(e.data,e.label).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Ccp4(r.result)});return function(n){return t.apply(this,arguments)}}())}),Rze=Rt.BuiltIn({name:"parse-dsn6",display:{name:"Parse DSN6/BRIX",description:"Parse CCP4/BRIX from Binary data"},from:[pe.Data.Binary],to:pe.Format.Dsn6})({apply:({a:e})=>Oe.create("Parse DSN6/BRIX",function(){var t=ie(function*(n){const r=yield function J8e(e,t){return function Q8e(e,t){return Oe.create("Parse DSN6/BRIX",function(){var n=ie(function*(r){try{return Fr.success(yield function Z8e(e,t,n){return b4.apply(this,arguments)}(e,t,r))}catch(i){return Fr.error(i)}});return function(r){return n.apply(this,arguments)}}())}(FT.fromBuffer(cd.fromUint8Array(e),t),e.length)}(e.data,e.label).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Dsn6(r.result)});return function(n){return t.apply(this,arguments)}}())}),kze=Rt.BuiltIn({name:"parse-dx",display:{name:"Parse DX",description:"Parse DX from Binary/String data"},from:[pe.Data.Binary,pe.Data.String],to:pe.Format.Dx})({apply:({a:e})=>Oe.create("Parse DX",function(){var t=ie(function*(n){const r=yield function rze(e,t){return Oe.create("Parse DX",n=>"string"==typeof e?function tze(e,t,n){return OL.apply(this,arguments)}(n,e,t):function nze(e,t,n){return LL.apply(this,arguments)}(n,e,t))}(e.data,e.label).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Dx(r.result)});return function(n){return t.apply(this,arguments)}}())}),Nze=Rt.BuiltIn({name:"import-string",display:{name:"Import String",description:"Import given data as a string"},from:pe.Root,to:pe.Data.String,params:{data:C.Value(""),label:C.Optional(C.Text(""))}})({apply:({params:{data:e,label:t}})=>new pe.Data.String(e,{label:t||""}),update:({oldParams:e,newParams:t,b:n})=>e.data!==t.data?Qe.UpdateResult.Recreate:e.label!==t.label?(n.label=t.label||"",Qe.UpdateResult.Updated):Qe.UpdateResult.Unchanged,isSerializable:()=>({isSerializable:!1,reason:"Cannot serialize user imported strings."})}),Fze=Rt.BuiltIn({name:"import-json",display:{name:"Import JSON",description:"Import given data as a JSON"},from:pe.Root,to:pe.Format.Json,params:{data:C.Value({}),label:C.Optional(C.Text(""))}})({apply:({params:{data:e,label:t}})=>new pe.Format.Json(e,{label:t||""}),update:({oldParams:e,newParams:t,b:n})=>e.data!==t.data?Qe.UpdateResult.Recreate:e.label!==t.label?(n.label=t.label||"",Qe.UpdateResult.Updated):Qe.UpdateResult.Unchanged,isSerializable:()=>({isSerializable:!1,reason:"Cannot serialize user imported JSON."})}),Bze=Rt.BuiltIn({name:"parse-json",display:{name:"Parse JSON",description:"Parse JSON from String data"},from:[pe.Data.String],to:pe.Format.Json})({apply:({a:e})=>Oe.create("Parse JSON",function(){var t=ie(function*(n){const r=yield new Response(e.data).json();return new pe.Format.Json(r)});return function(n){return t.apply(this,arguments)}}())}),Oze=Rt.BuiltIn({name:"lazy-volume",display:{name:"Lazy Volume",description:"A placeholder for lazy loaded volume representation"},from:pe.Root,to:pe.Volume.Lazy,params:{url:C.Url(""),isBinary:C.Boolean(!1),format:C.Text("ccp4"),entryId:C.Value("",{isHidden:!0}),isovalues:C.ObjectList({type:C.Text("relative"),value:C.Numeric(0),color:C.Color(xn.black),alpha:C.Numeric(1,{min:0,max:1,step:.01}),volumeIndex:C.Numeric(0)},e=>`${e.type} ${e.value}`)}})({apply:({params:t})=>Oe.create("Lazy Volume",function(){var n=ie(function*(r){const i=Array.isArray(t.entryId)?t.entryId.join(", "):t.entryId;return new pe.Volume.Lazy(t,{label:`${i||t.url}`,description:"Lazy Volume"})});return function(r){return n.apply(this,arguments)}}())}),Lze=Rt.BuiltIn({name:"create-group",display:{name:"Group"},from:[],to:pe.Group,params:{label:C.Text("Group"),description:C.Optional(C.Text(""))}})({apply:({params:e})=>new pe.Group({},e),update:({oldParams:e,newParams:t,b:n})=>MI(e,t)?Qe.UpdateResult.Unchanged:(n.label=t.label,n.description=t.description,Qe.UpdateResult.Updated)});function Hze(e,t){return{tokenizer:e,header:{title:"",timeInPs:0,hasVelocities:!1,precision:{position:0,velocity:0},box:[0,0,0]},numberOfAtoms:0,runtimeCtx:t}}function qze(e){const{tokenizer:t,header:n}=e;let r=ht.readLine(t);0===r.trim().length&&(r=ht.readLine(t));const i=r.lastIndexOf("t=");i>=0?(n.timeInPs=parseFloat(r.substring(i+2)),n.title=r.substring(0,i).trim(),n.title&&","===n.title[n.title.length-1]&&(n.title=n.title.substring(0,n.title.length-1))):n.title=r}function Wze(e){const{tokenizer:t}=e;ht.markLine(t);const n=ht.getTokenString(t);e.numberOfAtoms=parseInt(n)}function $ze(e){return jL.apply(this,arguments)}function jL(){return jL=ie(function*(e){const{tokenizer:t,numberOfAtoms:n}=e,r=yield ht.readLinesAsync(t,n,e.runtimeCtx,1e5),o=t.data.substring(r.indices[0],r.indices[1]).substring(20).match(/\.\d+/g),s=6===o.length;e.header.hasVelocities=s,e.header.precision.position=o[0].length-1,e.header.precision.velocity=s?o[3].length-1:0;const c=e.header.precision.position+5,u=20+3*c,l=e.header.precision.velocity+4,d=function zze(e){return function(t,n,r){return function Gze(e,t,n,r){const{data:i,indices:o,count:s}=e,{valueType:a}=r,c="str"===a?u=>{const l=o[2*u]+t,d=o[2*u+1];if(l>=d)return"";let f=l+n;return f>d&&(f=d),function NOe(e,t,n){let r=t,i=n-1,o=e.charCodeAt(r);for(;(9===o||32===o)&&r<=i;)o=e.charCodeAt(++r);for(o=e.charCodeAt(i);(9===o||32===o)&&i>=r;)o=e.charCodeAt(--i);return e.substring(r,i+1)}(i,l,f)}:"int"===a?u=>{const l=o[2*u]+t;return l>o[2*u+1]?0:Ig(i,l,l+n)}:u=>{const l=o[2*u]+t;return l>o[2*u+1]?0:function iMe(e,t,n){for(;t0,toArray:u=>Ps(s,c,u),areValuesEqual:(u,l)=>c(u)===c(l)}}(e,t,n,r)}}(r),f=te.Undefined(e.numberOfAtoms,te.Schema.float);return{count:e.numberOfAtoms,residueNumber:d(0,5,te.Schema.int),residueName:d(5,5,te.Schema.str),atomName:d(10,5,te.Schema.str),atomNumber:d(15,5,te.Schema.int),x:d(20,c,te.Schema.float),y:d(20+c,c,te.Schema.float),z:d(20+2*c,c,te.Schema.float),vx:s?d(u,l,te.Schema.float):f,vy:s?d(u+l,l,te.Schema.float):f,vz:s?d(u+2*l,l,te.Schema.float):f}}),jL.apply(this,arguments)}function Yze(e){const{tokenizer:t}=e,n=ht.readLine(t).trim().split(/\s+/g);e.header.box=[+n[0],+n[1],+n[2]]}function HL(){return HL=ie(function*(e,t){const n=ht(e);yield t.update({message:"Parsing...",current:0,max:e.length});const r=[];for(;n.position0?Math.ceil(e/r):0;return{width:r,height:i,length:r*i*t}}(e,t);return{array:r=r&&r.length>=i?r:new n(i),width:o,height:s}}const al=v(),r7e=new fu("14"),i7e=new fu("98");function hre(e){return e>1e5?r7e:i7e}function Ip(e,t,n){const r=3*n,i=hre(t);i.reset();for(let s=0,a=3*t;s>2),r=t-4>>2,i=4*r;let o=0;if(r<0)for(let s=0;s>16]}for(let s=i;s!1),s){if(e%n!=0)throw new Error("incompatible groupCount and stride");const a={location:rc,location2:rc,index:0,groupIndex:0,instanceIndex:0,isSecondary:!1};let c=a.groupIndex(c&&(a.groupIndex=l,a.instanceIndex=d,a.index=d*e+l,a.location=r(l,f?-1:d),p&&(a.location2=s(l,f?-1:d)),a.isSecondary=o(l,f?-1:d),l+=n,l===e?(++d,u=!0,d=85}return!1}(e);return{instancedArrays:t,standardDerivatives:r,elementIndexUint:n,textureFloat:i,textureFloatLinear:o,textureHalfFloat:s,textureHalfFloatLinear:a,depthTexture:c,blendMinMax:u,vertexArrayObject:l,fragDepth:d,colorBufferFloat:f,colorBufferHalfFloat:p,drawBuffers:m,drawBuffersIndexed:h,shaderTextureLod:g,sRGB:y,disjointTimerQuery:b,multiDraw:x,drawInstancedBaseVertexBaseInstance:_,multiDrawInstancedBaseVertexBaseInstance:S,parallelShaderCompile:A,fboRenderMipmap:E,provokingVertex:w,clipCullDistance:D,conservativeDepth:I,stencilTexturing:R,clipControl:T,noNonInstancedActiveAttribs:M}}var d0;!function(e){e.create=function t(i,o,s){return{array:i,width:o,height:s}},e.flipY=function n(i){const{array:o,width:s,height:a}=i,u=s*(o.length/(s*a));for(let l=0,d=a/2;l 0.0 && uBumpAmplitude > 0.0 && bumpiness > 0.0) {\n material.rgb += fbm(vModelPosition * uBumpFrequency) * uBumpAmplitude * bumpiness;\n material.rgb -= 0.5 * uBumpAmplitude * bumpiness;\n }\n #endif\n\n gl_FragColor = material;\n#else\n #ifdef bumpEnabled\n if (uBumpFrequency > 0.0 && uBumpAmplitude > 0.0 && bumpiness > 0.0) {\n normal = perturbNormal(-vViewPosition, normal, fbm(vModelPosition * uBumpFrequency), (uBumpAmplitude * bumpiness) / uBumpFrequency);\n }\n #endif\n\n vec4 color = material;\n\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n\n PhysicalMaterial physicalMaterial;\n physicalMaterial.diffuseColor = color.rgb * (1.0 - metalness);\n #ifdef enabledFragDepth\n physicalMaterial.roughness = min(max(roughness, 0.0525), 1.0);\n #else\n vec3 dxy = max(abs(dFdx(normal)), abs(dFdy(normal)));\n float geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\n physicalMaterial.roughness = min(max(roughness, 0.0525) + geometryRoughness, 1.0);\n #endif\n physicalMaterial.specularColor = mix(vec3(0.04), color.rgb, metalness);\n physicalMaterial.specularF90 = 1.0;\n\n GeometricContext geometry;\n geometry.position = -vViewPosition;\n geometry.normal = normal;\n geometry.viewDir = normalize(vViewPosition);\n\n IncidentLight directLight;\n #pragma unroll_loop_start\n for (int i = 0; i < dLightCount; ++i) {\n directLight.direction = uLightDirection[i];\n directLight.color = uLightColor[i] * PI; // * PI for punctual light\n RE_Direct_Physical(directLight, geometry, physicalMaterial, reflectedLight);\n }\n #pragma unroll_loop_end\n\n vec3 irradiance = uAmbientColor * PI; // * PI for punctual light\n RE_IndirectDiffuse_Physical(irradiance, geometry, physicalMaterial, reflectedLight);\n\n // indirect specular only metals\n vec3 radiance = uAmbientColor * metalness;\n vec3 iblIrradiance = uAmbientColor * metalness;\n vec3 clearcoatRadiance = vec3(0.0);\n RE_IndirectSpecular_Physical(radiance, iblIrradiance, clearcoatRadiance, geometry, physicalMaterial, reflectedLight);\n\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n outgoingLight = clamp(outgoingLight, 0.01, 0.99); // prevents black artifacts on specular highlight with transparent background\n\n gl_FragColor = vec4(outgoingLight, color.a);\n#endif\n\n#if defined(dXrayShaded_on)\n gl_FragColor.a *= 1.0 - pow(abs(dot(normal, vec3(0.0, 0.0, 1.0))), uXrayEdgeFalloff);\n#elif defined(dXrayShaded_inverted)\n gl_FragColor.a *= pow(abs(dot(normal, vec3(0.0, 0.0, 1.0))), uXrayEdgeFalloff);\n#endif\n\ngl_FragColor.rgb *= uExposure;\n",apply_marker_color:"\n\n#if defined(dColorMarker)\n if (marker > 0.0) {\n if ((uMarkerPriority == 1 && marker != 2.0) || (uMarkerPriority != 1 && marker == 1.0)) {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, uHighlightColor, uHighlightStrength);\n gl_FragColor.a = max(gl_FragColor.a, uHighlightStrength * 0.002); // for direct-volume rendering\n } else {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, uSelectColor, uSelectStrength);\n gl_FragColor.a = max(gl_FragColor.a, uSelectStrength * 0.002); // for direct-volume rendering\n }\n } else if (uMarkerAverage > 0.0) {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, uDimColor, uDimStrength);\n gl_FragColor.a = max(gl_FragColor.a, uDimStrength * 0.002); // for direct-volume rendering\n }\n#endif\n",assign_clipping_varying:"\n#if dClipObjectCount != 0 && defined(dClipping)\n #if defined(dClippingType_instance)\n vClipping = readFromTexture(tClipping, aInstance, uClippingTexDim).a;\n #elif defined(dMarkerType_groupInstance)\n vClipping = readFromTexture(tClipping, aInstance * float(uGroupCount) + group, uClippingTexDim).a;\n #endif\n#endif\n",assign_color_varying:"\n#if defined(dRenderVariant_color)\n #if defined(dColorType_attribute)\n vColor.rgb = aColor;\n #elif defined(dColorType_instance)\n vColor.rgb = readFromTexture(tColor, aInstance, uColorTexDim).rgb;\n #elif defined(dColorType_group)\n #if defined(dDualColor)\n vec4 color2;\n if (aColorMode == 2.0) {\n vColor.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;\n } else {\n vColor.rgb = readFromTexture(tColor, group * 2.0, uColorTexDim).rgb;\n color2.rgb = readFromTexture(tColor, group * 2.0 + 1.0, uColorTexDim).rgb;\n }\n #else\n vColor.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;\n #endif\n #elif defined(dColorType_groupInstance)\n #if defined(dDualColor)\n vec4 color2;\n if (aColorMode == 2.0) {\n vColor.rgb = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim).rgb;\n } else {\n vColor.rgb = readFromTexture(tColor, (aInstance * float(uGroupCount) + group) * 2.0, uColorTexDim).rgb;\n color2.rgb = readFromTexture(tColor, (aInstance * float(uGroupCount) + group) * 2.0 + 1.0, uColorTexDim).rgb;\n }\n #else\n vColor.rgb = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim).rgb;\n #endif\n #elif defined(dColorType_vertex)\n vColor.rgb = readFromTexture(tColor, VertexID, uColorTexDim).rgb;\n #elif defined(dColorType_vertexInstance)\n vColor.rgb = readFromTexture(tColor, int(aInstance) * uVertexCount + VertexID, uColorTexDim).rgb;\n #elif defined(dColorType_volume)\n vec3 cgridPos = (uColorGridTransform.w * (position - uColorGridTransform.xyz)) / uColorGridDim;\n vColor.rgb = texture3dFrom2dLinear(tColorGrid, cgridPos, uColorGridDim, uColorTexDim).rgb;\n #elif defined(dColorType_volumeInstance)\n vec3 cgridPos = (uColorGridTransform.w * (vModelPosition - uColorGridTransform.xyz)) / uColorGridDim;\n vColor.rgb = texture3dFrom2dLinear(tColorGrid, cgridPos, uColorGridDim, uColorTexDim).rgb;\n #endif\n\n #ifdef dUsePalette\n vPaletteV = ((vColor.r * 256.0 * 256.0 * 255.0 + vColor.g * 256.0 * 255.0 + vColor.b * 255.0) - 1.0) / 16777215.0;\n #endif\n\n #ifdef dOverpaint\n #if defined(dOverpaintType_instance)\n vOverpaint = readFromTexture(tOverpaint, aInstance, uOverpaintTexDim);\n #elif defined(dOverpaintType_groupInstance)\n vOverpaint = readFromTexture(tOverpaint, aInstance * float(uGroupCount) + group, uOverpaintTexDim);\n #elif defined(dOverpaintType_vertexInstance)\n vOverpaint = readFromTexture(tOverpaint, int(aInstance) * uVertexCount + VertexID, uOverpaintTexDim);\n #elif defined(dOverpaintType_volumeInstance)\n vec3 ogridPos = (uOverpaintGridTransform.w * (vModelPosition - uOverpaintGridTransform.xyz)) / uOverpaintGridDim;\n vOverpaint = texture3dFrom2dLinear(tOverpaintGrid, ogridPos, uOverpaintGridDim, uOverpaintTexDim);\n #endif\n\n // pre-mix to avoid darkening due to empty overpaint\n #ifdef dColorType_uniform\n vOverpaint.rgb = mix(uColor.rgb, vOverpaint.rgb, vOverpaint.a);\n #else\n vOverpaint.rgb = mix(vColor.rgb, vOverpaint.rgb, vOverpaint.a);\n #endif\n vOverpaint *= uOverpaintStrength;\n #endif\n\n #ifdef dSubstance\n #if defined(dSubstanceType_instance)\n vSubstance = readFromTexture(tSubstance, aInstance, uSubstanceTexDim);\n #elif defined(dSubstanceType_groupInstance)\n vSubstance = readFromTexture(tSubstance, aInstance * float(uGroupCount) + group, uSubstanceTexDim);\n #elif defined(dSubstanceType_vertexInstance)\n vSubstance = readFromTexture(tSubstance, int(aInstance) * uVertexCount + VertexID, uSubstanceTexDim);\n #elif defined(dSubstanceType_volumeInstance)\n vec3 sgridPos = (uSubstanceGridTransform.w * (vModelPosition - uSubstanceGridTransform.xyz)) / uSubstanceGridDim;\n vSubstance = texture3dFrom2dLinear(tSubstanceGrid, sgridPos, uSubstanceGridDim, uSubstanceTexDim);\n #endif\n\n // pre-mix to avoid artifacts due to empty substance\n vSubstance.rgb = mix(vec3(uMetalness, uRoughness, uBumpiness), vSubstance.rgb, vSubstance.a);\n vSubstance *= uSubstanceStrength;\n #endif\n#elif defined(dRenderVariant_pick)\n #ifdef requiredDrawBuffers\n vObject = vec4(packIntToRGB(float(uObjectId)), 1.0);\n vInstance = vec4(packIntToRGB(aInstance), 1.0);\n vGroup = vec4(packIntToRGB(group), 1.0);\n #else\n if (uPickType == 1) {\n vColor = vec4(packIntToRGB(float(uObjectId)), 1.0);\n } else if (uPickType == 2) {\n vColor = vec4(packIntToRGB(aInstance), 1.0);\n } else {\n vColor = vec4(packIntToRGB(group), 1.0);\n }\n #endif\n#endif\n\n#ifdef dTransparency\n #if defined(dTransparencyType_instance)\n vTransparency = readFromTexture(tTransparency, aInstance, uTransparencyTexDim).a;\n #elif defined(dTransparencyType_groupInstance)\n vTransparency = readFromTexture(tTransparency, aInstance * float(uGroupCount) + group, uTransparencyTexDim).a;\n #elif defined(dTransparencyType_vertexInstance)\n vTransparency = readFromTexture(tTransparency, int(aInstance) * uVertexCount + VertexID, uTransparencyTexDim).a;\n #elif defined(dTransparencyType_volumeInstance)\n vec3 tgridPos = (uTransparencyGridTransform.w * (vModelPosition - uTransparencyGridTransform.xyz)) / uTransparencyGridDim;\n vTransparency = texture3dFrom2dLinear(tTransparencyGrid, tgridPos, uTransparencyGridDim, uTransparencyTexDim).a;\n #endif\n vTransparency *= uTransparencyStrength;\n#endif\n",assign_group:"\n#ifdef dGeometryType_textureMesh\n float group = unpackRGBToInt(readFromTexture(tGroup, VertexID, uGeoTexDim).rgb);\n#else\n float group = aGroup;\n#endif\n",assign_marker_varying:"\n#if defined(dNeedsMarker)\n #if defined(dMarkerType_instance)\n vMarker = readFromTexture(tMarker, aInstance, uMarkerTexDim).a;\n #elif defined(dMarkerType_groupInstance)\n vMarker = readFromTexture(tMarker, aInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n #endif\n#endif\n",assign_material_color:"\n#if defined(dNeedsMarker)\n float marker = uMarker;\n if (uMarker == -1.0) {\n marker = floor(vMarker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n#endif\n\n#if defined(dRenderVariant_color)\n #if defined(dUsePalette)\n vec4 material = vec4(texture2D(tPalette, vec2(vPaletteV, 0.5)).rgb, uAlpha);\n #elif defined(dColorType_uniform)\n vec4 material = vec4(uColor, uAlpha);\n #elif defined(dColorType_varying)\n vec4 material = vec4(vColor.rgb, uAlpha);\n #endif\n\n // mix material with overpaint\n #if defined(dOverpaint)\n material.rgb = mix(material.rgb, vOverpaint.rgb, vOverpaint.a);\n #endif\n\n float metalness = uMetalness;\n float roughness = uRoughness;\n float bumpiness = uBumpiness;\n #ifdef dSubstance\n metalness = mix(metalness, vSubstance.r, vSubstance.a);\n roughness = mix(roughness, vSubstance.g, vSubstance.a);\n bumpiness = mix(bumpiness, vSubstance.b, vSubstance.a);\n #endif\n#elif defined(dRenderVariant_depth)\n if (fragmentDepth > getDepth(gl_FragCoord.xy / uDrawingBufferSize)) {\n discard;\n }\n\n #ifndef dXrayShaded\n #if defined(dTransparency)\n float dta = 1.0 - vTransparency;\n if (vTransparency < 0.2) dta = 1.0; // hard cutoff looks better\n\n if (uRenderMask == MaskTransparent && uAlpha * dta == 1.0) {\n discard;\n } else if (uRenderMask == MaskOpaque && uAlpha * dta < 1.0) {\n discard;\n }\n #else\n if (uRenderMask == MaskTransparent && uAlpha == 1.0) {\n discard;\n } else if (uRenderMask == MaskOpaque && uAlpha < 1.0) {\n discard;\n }\n #endif\n #else\n if (uRenderMask == MaskOpaque) {\n discard;\n }\n #endif\n\n vec4 material = packDepthToRGBA(fragmentDepth);\n#elif defined(dRenderVariant_marking)\n vec4 material;\n if(uMarkingType == 1) {\n if (marker > 0.0)\n discard;\n #ifdef enabledFragDepth\n material = packDepthToRGBA(gl_FragDepthEXT);\n #else\n material = packDepthToRGBA(gl_FragCoord.z);\n #endif\n } else {\n if (marker == 0.0)\n discard;\n float depthTest = 1.0;\n if (uMarkingDepthTest) {\n depthTest = (fragmentDepth >= getDepthPacked(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0;\n }\n bool isHighlight = intMod(marker, 2.0) > 0.1;\n float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);\n float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));\n if (fogFactor == 1.0)\n discard;\n material = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0 - fogFactor);\n }\n#endif\n\n// apply per-group transparency\n#if defined(dTransparency) && (defined(dRenderVariant_pick) || defined(dRenderVariant_color))\n float ta = 1.0 - vTransparency;\n if (vTransparency < 0.09) ta = 1.0; // hard cutoff looks better\n\n #if defined(dRenderVariant_pick)\n if (ta < uPickingAlphaThreshold)\n discard; // ignore so the element below can be picked\n #elif defined(dRenderVariant_color)\n material.a *= ta;\n\n #if defined(dRenderVariant_colorBlended)\n #if defined(dTransparentBackfaces_off)\n if ((uRenderMask == MaskOpaque && material.a < 1.0) ||\n (uRenderMask == MaskTransparent && material.a == 1.0) ||\n (interior && material.a < 1.0)\n ) {\n discard;\n }\n #elif defined(dTransparentBackfaces_on)\n if ((uRenderMask == MaskOpaque && material.a < 1.0) ||\n (uRenderMask == MaskTransparent && material.a == 1.0)\n ) {\n discard;\n }\n #elif defined(dTransparentBackfaces_opaque)\n if (interior) {\n material.a = 1.0;\n } else if (\n (uRenderMask == MaskOpaque && material.a < 1.0) ||\n (uRenderMask == MaskTransparent && material.a == 1.0)\n ) {\n discard;\n }\n #endif\n #endif\n #endif\n#endif\n",assign_position:"\nmat4 model = uModel * aTransform;\nmat4 modelView = uView * model;\n#ifdef dGeometryType_textureMesh\n vec3 position = readFromTexture(tPosition, VertexID, uGeoTexDim).xyz;\n#else\n vec3 position = aPosition;\n#endif\nvec4 position4 = vec4(position, 1.0);\n// for accessing tColorGrid in vert shader and for clipping in frag shader\nvModelPosition = (model * position4).xyz;\nvec4 mvPosition = modelView * position4;\nvViewPosition = mvPosition.xyz;\ngl_Position = uProjection * mvPosition;\n",assign_size:"\n#if defined(dSizeType_uniform)\n float size = uSize;\n#elif defined(dSizeType_attribute)\n float size = aSize;\n#elif defined(dSizeType_instance)\n float size = unpackRGBToInt(readFromTexture(tSize, aInstance, uSizeTexDim).rgb);\n#elif defined(dSizeType_group)\n float size = unpackRGBToInt(readFromTexture(tSize, group, uSizeTexDim).rgb);\n#elif defined(dSizeType_groupInstance)\n float size = unpackRGBToInt(readFromTexture(tSize, aInstance * float(uGroupCount) + group, uSizeTexDim).rgb);\n#endif\n\n#if defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance)\n size /= 100.0; // NOTE factor also set in TypeScript\n#endif\n\nsize *= uSizeFactor;\n",check_picking_alpha:"\nfloat viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);\nfloat fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));\nfloat alpha = (1.0 - fogFactor) * uAlpha;\n// if not opaque enough ignore so the element below can be picked\nif (uAlpha < uPickingAlphaThreshold || alpha < 0.1) {\n #ifdef dTransparentBackfaces_opaque\n if (!interior) discard;\n #else\n discard;\n #endif\n}\n",clip_instance:"\n#if defined(dClipVariant_instance) && dClipObjectCount != 0\n vec4 mCenter = uModel * aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0);\n if (clipTest(vec4(mCenter.xyz, uInvariantBoundingSphere.w)))\n // move out of [ -w, +w ] to 'discard' in vert shader\n gl_Position.z = 2.0 * gl_Position.w;\n#endif\n",clip_pixel:"\n#if defined(dClipVariant_pixel) && dClipObjectCount != 0\n if (clipTest(vec4(vModelPosition, 0.0)))\n discard;\n#endif\n",color_frag_params:"\nuniform float uMetalness;\nuniform float uRoughness;\nuniform float uBumpiness;\n#ifdef bumpEnabled\n uniform float uBumpFrequency;\n uniform float uBumpAmplitude;\n#endif\n\n#if defined(dRenderVariant_color)\n #if defined(dColorType_uniform)\n uniform vec3 uColor;\n #elif defined(dColorType_varying)\n varying vec4 vColor;\n #endif\n\n #ifdef dUsePalette\n uniform sampler2D tPalette;\n varying float vPaletteV;\n #endif\n\n #ifdef dOverpaint\n varying vec4 vOverpaint;\n #endif\n\n #ifdef dSubstance\n varying vec4 vSubstance;\n #endif\n#elif defined(dRenderVariant_pick)\n #if __VERSION__ == 100 || !defined(dVaryingGroup)\n #ifdef requiredDrawBuffers\n varying vec4 vObject;\n varying vec4 vInstance;\n varying vec4 vGroup;\n #else\n varying vec4 vColor;\n #endif\n #else\n #ifdef requiredDrawBuffers\n flat in vec4 vObject;\n flat in vec4 vInstance;\n flat in vec4 vGroup;\n #else\n flat in vec4 vColor;\n #endif\n #endif\n#endif\n\n#ifdef dTransparency\n varying float vTransparency;\n#endif\n",color_vert_params:"\nuniform float uMetalness;\nuniform float uRoughness;\nuniform float uBumpiness;\n\n#if defined(dRenderVariant_color)\n #if defined(dColorType_uniform)\n uniform vec3 uColor;\n #elif defined(dColorType_attribute)\n varying vec4 vColor;\n attribute vec3 aColor;\n #elif defined(dColorType_texture)\n varying vec4 vColor;\n uniform vec2 uColorTexDim;\n uniform sampler2D tColor;\n #elif defined(dColorType_grid)\n varying vec4 vColor;\n uniform vec2 uColorTexDim;\n uniform vec3 uColorGridDim;\n uniform vec4 uColorGridTransform;\n uniform sampler2D tColorGrid;\n #elif defined(dColorType_direct)\n varying vec4 vColor;\n #endif\n\n #ifdef dUsePalette\n varying float vPaletteV;\n #endif\n\n #ifdef dOverpaint\n #if defined(dOverpaintType_instance) || defined(dOverpaintType_groupInstance) || defined(dOverpaintType_vertexInstance)\n varying vec4 vOverpaint;\n uniform vec2 uOverpaintTexDim;\n uniform sampler2D tOverpaint;\n #elif defined(dOverpaintType_volumeInstance)\n varying vec4 vOverpaint;\n uniform vec2 uOverpaintTexDim;\n uniform vec3 uOverpaintGridDim;\n uniform vec4 uOverpaintGridTransform;\n uniform sampler2D tOverpaintGrid;\n #endif\n uniform float uOverpaintStrength;\n #endif\n\n #ifdef dSubstance\n #if defined(dSubstanceType_instance) || defined(dSubstanceType_groupInstance) || defined(dSubstanceType_vertexInstance)\n varying vec4 vSubstance;\n uniform vec2 uSubstanceTexDim;\n uniform sampler2D tSubstance;\n #elif defined(dSubstanceType_volumeInstance)\n varying vec4 vSubstance;\n uniform vec2 uSubstanceTexDim;\n uniform vec3 uSubstanceGridDim;\n uniform vec4 uSubstanceGridTransform;\n uniform sampler2D tSubstanceGrid;\n #endif\n uniform float uSubstanceStrength;\n #endif\n#elif defined(dRenderVariant_pick)\n #if __VERSION__ == 100 || !defined(dVaryingGroup)\n #ifdef requiredDrawBuffers\n varying vec4 vObject;\n varying vec4 vInstance;\n varying vec4 vGroup;\n #else\n varying vec4 vColor;\n #endif\n #else\n #ifdef requiredDrawBuffers\n flat out vec4 vObject;\n flat out vec4 vInstance;\n flat out vec4 vGroup;\n #else\n flat out vec4 vColor;\n #endif\n #endif\n#endif\n\n#ifdef dTransparency\n #if defined(dTransparencyType_instance) || defined(dTransparencyType_groupInstance) || defined(dTransparencyType_vertexInstance)\n varying float vTransparency;\n uniform vec2 uTransparencyTexDim;\n uniform sampler2D tTransparency;\n #elif defined(dTransparencyType_volumeInstance)\n varying float vTransparency;\n uniform vec2 uTransparencyTexDim;\n uniform vec3 uTransparencyGridDim;\n uniform vec4 uTransparencyGridTransform;\n uniform sampler2D tTransparencyGrid;\n #endif\n uniform float uTransparencyStrength;\n#endif\n",common_clip:"\n#if dClipObjectCount != 0\n vec3 quaternionTransform(const in vec4 q, const in vec3 v) {\n vec3 t = 2.0 * cross(q.xyz, v);\n return v + q.w * t + cross(q.xyz, t);\n }\n\n vec4 computePlane(const in vec3 normal, const in vec3 inPoint) {\n return vec4(normalize(normal), -dot(normal, inPoint));\n }\n\n float planeSD(const in vec4 plane, const in vec3 center) {\n return -dot(plane.xyz, center - plane.xyz * -plane.w);\n }\n\n float sphereSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in vec3 center) {\n return (\n length(quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position) / size) - 1.0\n ) * min(min(size.x, size.y), size.z);\n }\n\n float cubeSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in vec3 center) {\n vec3 d = abs(quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position)) - size;\n return min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0));\n }\n\n float cylinderSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in vec3 center) {\n vec3 t = quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position);\n\n vec2 d = abs(vec2(length(t.xz), t.y)) - size.xy;\n return min(max(d.x, d.y), 0.0) + length(max(d, 0.0));\n }\n\n float infiniteConeSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in vec3 center) {\n vec3 t = quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position);\n\n float q = length(t.xy);\n return dot(size.xy, vec2(q, t.z));\n }\n\n float getSignedDistance(const in vec3 center, const in int type, const in vec3 position, const in vec4 rotation, const in vec3 scale) {\n if (type == 1) {\n vec3 normal = quaternionTransform(rotation, vec3(0.0, 1.0, 0.0));\n vec4 plane = computePlane(normal, position);\n return planeSD(plane, center);\n } else if (type == 2) {\n return sphereSD(position, rotation, scale * 0.5, center);\n } else if (type == 3) {\n return cubeSD(position, rotation, scale * 0.5, center);\n } else if (type == 4) {\n return cylinderSD(position, rotation, scale * 0.5, center);\n } else if (type == 5) {\n return infiniteConeSD(position, rotation, scale * 0.5, center);\n } else {\n return 0.1;\n }\n }\n\n #if __VERSION__ == 100\n // 8-bit\n int bitwiseAnd(in int a, in int b) {\n int d = 128;\n int result = 0;\n for (int i = 0; i < 8; ++i) {\n if (d <= 0) break;\n if (a >= d && b >= d) result += d;\n if (a >= d) a -= d;\n if (b >= d) b -= d;\n d /= 2;\n }\n return result;\n }\n\n bool hasBit(const in int mask, const in int bit) {\n return bitwiseAnd(mask, bit) == 0;\n }\n #else\n bool hasBit(const in int mask, const in int bit) {\n return (mask & bit) == 0;\n }\n #endif\n\n bool clipTest(const in vec4 sphere) {\n // flag is a bit-flag for clip-objects to ignore (note, object ids start at 1 not 0)\n #if defined(dClipping)\n int flag = int(floor(vClipping * 255.0 + 0.5));\n #else\n int flag = 0;\n #endif\n\n #pragma unroll_loop_start\n for (int i = 0; i < dClipObjectCount; ++i) {\n if (flag == 0 || hasBit(flag, UNROLLED_LOOP_INDEX + 1)) {\n // TODO take sphere radius into account?\n bool test = getSignedDistance(sphere.xyz, uClipObjectType[i], uClipObjectPosition[i], uClipObjectRotation[i], uClipObjectScale[i]) <= 0.0;\n if ((!uClipObjectInvert[i] && test) || (uClipObjectInvert[i] && !test)) {\n return true;\n }\n }\n }\n #pragma unroll_loop_end\n return false;\n }\n#endif\n",common_frag_params:'\nuniform int uObjectId;\nuniform int uInstanceCount;\nuniform int uGroupCount;\n\nuniform int uPickType;\nuniform int uMarkingType;\n\nuniform vec4 uCameraPlane;\nuniform vec4 uLod;\n\n#if dClipObjectCount != 0\n uniform int uClipObjectType[dClipObjectCount];\n uniform bool uClipObjectInvert[dClipObjectCount];\n uniform vec3 uClipObjectPosition[dClipObjectCount];\n uniform vec4 uClipObjectRotation[dClipObjectCount];\n uniform vec3 uClipObjectScale[dClipObjectCount];\n\n #if defined(dClipping)\n #if __VERSION__ == 100 || defined(dClippingType_instance) || !defined(dVaryingGroup)\n varying float vClipping;\n #else\n flat in float vClipping;\n #endif\n #endif\n#endif\n\n#if defined(dColorMarker)\n uniform vec3 uHighlightColor;\n uniform vec3 uSelectColor;\n uniform vec3 uDimColor;\n uniform float uHighlightStrength;\n uniform float uSelectStrength;\n uniform float uDimStrength;\n uniform int uMarkerPriority;\n uniform float uMarkerAverage;\n#endif\n\n#if defined(dNeedsMarker)\n uniform float uMarker;\n #if __VERSION__ == 100 || defined(dMarkerType_instance) || !defined(dVaryingGroup)\n varying float vMarker;\n #else\n flat in float vMarker;\n #endif\n#endif\n\n#if defined(dRenderVariant_colorDpoit)\n #define MAX_DPOIT_DEPTH 99999.0 // NOTE constant also set in TypeScript\n uniform sampler2D tDpoitDepth;\n uniform sampler2D tDpoitFrontColor;\n#endif\n\nvarying vec3 vModelPosition;\nvarying vec3 vViewPosition;\n\nuniform vec2 uViewOffset;\n\nuniform float uNear;\nuniform float uFar;\nuniform float uIsOrtho;\n\nuniform bool uFog;\nuniform float uFogNear;\nuniform float uFogFar;\nuniform vec3 uFogColor;\n\nuniform float uAlpha;\nuniform float uPickingAlphaThreshold;\nuniform bool uTransparentBackground;\n\nuniform bool uDoubleSided;\nuniform float uInteriorDarkening;\nuniform bool uInteriorColorFlag;\nuniform vec3 uInteriorColor;\nbool interior;\n\nuniform float uXrayEdgeFalloff;\nuniform float uExposure;\n\nuniform mat4 uProjection;\n\nuniform int uRenderMask;\nuniform bool uMarkingDepthTest;\n\nuniform sampler2D tDepth;\nuniform vec2 uDrawingBufferSize;\n\nfloat getDepthPacked(const in vec2 coords) {\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n}\n\nfloat getDepth(const in vec2 coords) {\n #ifdef depthTextureSupport\n return texture2D(tDepth, coords).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n #endif\n}\n\nfloat calcDepth(const in vec3 pos) {\n vec2 clipZW = pos.z * uProjection[2].zw + uProjection[3].zw;\n return 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\n\n// "Bump Mapping Unparametrized Surfaces on the GPU" Morten S. Mikkelsen\n// https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf\nvec3 perturbNormal(in vec3 position, in vec3 normal, in float height, in float scale) {\n vec3 sigmaS = dFdx(position);\n vec3 sigmaT = dFdy(position);\n\n vec3 r1 = cross(sigmaT, normal);\n vec3 r2 = cross(normal, sigmaS);\n float det = dot(sigmaS, r1);\n\n float bs = dFdx(height);\n float bt = dFdy(height);\n\n vec3 surfGrad = sign(det) * (bs * r1 + bt * r2);\n return normalize(abs(det) * normal - scale * surfGrad);\n}\n\nfloat hash(in float h) {\n return fract(sin(h) * 43758.5453123);\n}\n\nfloat noise(in vec3 x) {\n vec3 p = floor(x);\n vec3 f = fract(x);\n f = f * f * (3.0 - 2.0 * f);\n\n float n = p.x + p.y * 157.0 + 113.0 * p.z;\n return mix(\n mix(mix(hash(n + 0.0), hash(n + 1.0), f.x),\n mix(hash(n + 157.0), hash(n + 158.0), f.x), f.y),\n mix(mix(hash(n + 113.0), hash(n + 114.0), f.x),\n mix(hash(n + 270.0), hash(n + 271.0), f.x), f.y), f.z);\n}\n\nfloat fbm(in vec3 p) {\n float f = 0.0;\n f += 0.5 * noise(p);\n p *= 2.01;\n f += 0.25 * noise(p);\n p *= 2.02;\n f += 0.125 * noise(p);\n\n return f;\n}\n',common_vert_params:"\nuniform mat4 uProjection, uModel, uView;\nuniform vec3 uCameraPosition;\nuniform vec4 uCameraPlane;\n\nuniform int uObjectId;\nuniform int uVertexCount;\nuniform int uInstanceCount;\nuniform int uGroupCount;\nuniform vec4 uInvariantBoundingSphere;\nuniform vec4 uLod;\n\nuniform bool uDoubleSided;\nuniform int uPickType;\n\n#if dClipObjectCount != 0\n uniform int uClipObjectType[dClipObjectCount];\n uniform bool uClipObjectInvert[dClipObjectCount];\n uniform vec3 uClipObjectPosition[dClipObjectCount];\n uniform vec4 uClipObjectRotation[dClipObjectCount];\n uniform vec3 uClipObjectScale[dClipObjectCount];\n\n #if defined(dClipping)\n uniform vec2 uClippingTexDim;\n uniform sampler2D tClipping;\n #if __VERSION__ == 100 || defined(dClippingType_instance) || !defined(dVaryingGroup)\n varying float vClipping;\n #else\n flat out float vClipping;\n #endif\n #endif\n#endif\n\n#if defined(dNeedsMarker)\n uniform float uMarker;\n uniform vec2 uMarkerTexDim;\n uniform sampler2D tMarker;\n #if __VERSION__ == 100 || defined(dMarkerType_instance) || !defined(dVaryingGroup)\n varying float vMarker;\n #else\n flat out float vMarker;\n #endif\n#endif\n\nvarying vec3 vModelPosition;\nvarying vec3 vViewPosition;\n\n#if defined(noNonInstancedActiveAttribs)\n // int() is needed for some Safari versions\n // see https://bugs.webkit.org/show_bug.cgi?id=244152\n #define VertexID int(gl_VertexID)\n#else\n attribute float aVertex;\n #define VertexID int(aVertex)\n#endif\n\n#if defined(enabledMultiDraw)\n #define DrawID gl_DrawID\n#else\n #define DrawID uDrawId\n#endif\n",common:"\n// TODO find a better place for these convenience defines\n\n#if defined(dRenderVariant_colorBlended) || defined(dRenderVariant_colorWboit) || defined(dRenderVariant_colorDpoit)\n #define dRenderVariant_color\n#endif\n\n#if defined(dColorType_instance) || defined(dColorType_group) || defined(dColorType_groupInstance) || defined(dColorType_vertex) || defined(dColorType_vertexInstance)\n #define dColorType_texture\n#endif\n\n#if defined(dColorType_volume) || defined(dColorType_volumeInstance)\n #define dColorType_grid\n#endif\n\n#if defined(dColorType_attribute) || defined(dColorType_texture) || defined(dColorType_grid)\n #define dColorType_varying\n#endif\n\n#if (defined(dRenderVariant_color) && defined(dColorMarker)) || defined(dRenderVariant_marking)\n #define dNeedsMarker\n#endif\n\n#if defined(dXrayShaded_on) || defined(dXrayShaded_inverted)\n #define dXrayShaded\n#endif\n\n#define MaskAll 0\n#define MaskOpaque 1\n#define MaskTransparent 2\n\n//\n\n#define PI 3.14159265\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n\n#define saturate(a) clamp(a, 0.0, 1.0)\n\n#if __VERSION__ == 100\n #define round(x) floor((x) + 0.5)\n#endif\n\nfloat intDiv(const in float a, const in float b) { return float(int(a) / int(b)); }\nvec2 ivec2Div(const in vec2 a, const in vec2 b) { return vec2(ivec2(a) / ivec2(b)); }\nfloat intMod(const in float a, const in float b) { return a - b * float(int(a) / int(b)); }\nint imod(const in int a, const in int b) { return a - b * (a / b); }\n\nfloat pow2(const in float x) { return x * x; }\n\nvec3 packIntToRGB(in float value) {\n value = clamp(round(value), 0.0, 16777216.0 - 1.0) + 1.0;\n vec3 c = vec3(0.0);\n c.b = mod(value, 256.0);\n value = floor(value / 256.0);\n c.g = mod(value, 256.0);\n value = floor(value / 256.0);\n c.r = mod(value, 256.0);\n return c / 255.0;\n}\nfloat unpackRGBToInt(const in vec3 rgb) {\n 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;\n}\n\nvec2 packUnitIntervalToRG(const in float v) {\n vec2 enc;\n enc.xy = vec2(fract(v * 256.0), v);\n enc.y -= enc.x * (1.0 / 256.0);\n enc.xy *= 256.0 / 255.0;\n\n return enc;\n}\n\nfloat unpackRGToUnitInterval(const in vec2 enc) {\n return dot(enc, vec2(255.0 / (256.0 * 256.0), 255.0 / 256.0));\n}\n\nvec3 screenSpaceToViewSpace(const in vec3 ssPos, const in mat4 invProjection) {\n vec4 p = vec4(ssPos * 2.0 - 1.0, 1.0);\n p = invProjection * p;\n return p.xyz / p.w;\n}\n\nconst float PackUpscale = 256.0 / 255.0; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255.0 / 256.0; // 0..1 -> fraction (excluding 1)\nconst vec3 PackFactors = vec3(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0);\nconst vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.0);\nconst float ShiftRight8 = 1.0 / 256.0;\n\nvec4 packDepthToRGBA(const in float v) {\n vec4 r = vec4(fract(v * PackFactors), v);\n r.yzw -= r.xyz * ShiftRight8; // tidy overflow\n return r * PackUpscale;\n}\nfloat unpackRGBAToDepth(const in vec4 v) {\n return dot(v, UnpackFactors);\n}\n\nvec4 sRGBToLinear(const in vec4 c) {\n 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);\n}\nvec4 linearTosRGB(const in vec4 c) {\n 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);\n}\n\nfloat linearizeDepth(const in float depth, const in float near, const in float far) {\n return (2.0 * near) / (far + near - depth * (far - near));\n}\n\nfloat perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {\n return (near * far) / ((far - near) * invClipZ - far);\n}\n\nfloat orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {\n return linearClipZ * (near - far) - near;\n}\n\nfloat depthToViewZ(const in float isOrtho, const in float linearClipZ, const in float near, const in float far) {\n return isOrtho == 1.0 ? orthographicDepthToViewZ(linearClipZ, near, far) : perspectiveDepthToViewZ(linearClipZ, near, far);\n}\n\n#if __VERSION__ == 100\n // transpose\n\n float transpose(const in float m) {\n return m;\n }\n\n mat2 transpose2(const in mat2 m) {\n return mat2(\n m[0][0], m[1][0],\n m[0][1], m[1][1]\n );\n }\n\n mat3 transpose3(const in mat3 m) {\n return mat3(\n m[0][0], m[1][0], m[2][0],\n m[0][1], m[1][1], m[2][1],\n m[0][2], m[1][2], m[2][2]\n );\n }\n\n mat4 transpose4(const in mat4 m) {\n return mat4(\n m[0][0], m[1][0], m[2][0], m[3][0],\n m[0][1], m[1][1], m[2][1], m[3][1],\n m[0][2], m[1][2], m[2][2], m[3][2],\n m[0][3], m[1][3], m[2][3], m[3][3]\n );\n }\n\n // inverse\n\n float inverse(const in float m) {\n return 1.0 / m;\n }\n\n mat2 inverse2(const in mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n }\n\n mat3 inverse3(const in mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n }\n\n mat4 inverse4(const in mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n }\n\n #define isNaN(x) ((x) != (x))\n #define isInf(x) ((x) == (x) + 1.0)\n#else\n #define transpose2(m) transpose(m)\n #define transpose3(m) transpose(m)\n #define transpose4(m) transpose(m)\n\n #define inverse2(m) inverse(m)\n #define inverse3(m) inverse(m)\n #define inverse4(m) inverse(m)\n\n #define isNaN isnan\n #define isInf isinf\n#endif\n",fade_lod:"\nif (uLod.w == 0.0 && (uLod.x != 0.0 || uLod.y != 0.0)) {\n float d = dot(uCameraPlane.xyz, vModelPosition) + uCameraPlane.w;\n float ta = min(\n smoothstep(uLod.x, uLod.x + uLod.z, d),\n 1.0 - smoothstep(uLod.y - uLod.z, uLod.y, d)\n );\n\n #if defined(dRenderVariant_color)\n float at = 0.0;\n\n // shift by view-offset during multi-sample rendering to allow for blending\n vec2 coord = gl_FragCoord.xy + uViewOffset * 0.25;\n\n const mat4 thresholdMatrix = mat4(\n 1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,\n 13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,\n 4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,\n 16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0\n );\n int ci = int(intMod(coord.x, 4.0));\n int ri = int(intMod(coord.y, 4.0));\n #if __VERSION__ == 100\n vec4 i = vec4(float(ci * 4 + ri));\n vec4 v = thresholdMatrix[0] * vec4(equal(i, vec4(0.0, 1.0, 2.0, 3.0))) +\n thresholdMatrix[1] * vec4(equal(i, vec4(4.0, 5.0, 6.0, 7.0))) +\n thresholdMatrix[2] * vec4(equal(i, vec4(8.0, 9.0, 10.0, 11.0))) +\n thresholdMatrix[3] * vec4(equal(i, vec4(12.0, 13.0, 14.0, 15.0)));\n at = v.x + v.y + v.z + v.w;\n #else\n at = thresholdMatrix[ci][ri];\n #endif\n\n if (ta < 0.99 && (ta < 0.01 || ta < at)) {\n discard;\n }\n #else\n if (ta < uPickingAlphaThreshold) {\n discard;\n }\n #endif\n}\n",float_to_rgba:"\n // floatToRgba adapted from https://github.com/equinor/glsl-float-to-rgba\n // MIT License, Copyright (c) 2020 Equinor\n\n float shiftRight (float v, float amt) {\n v = floor(v) + 0.5;\n return floor(v / exp2(amt));\n }\n float shiftLeft (float v, float amt) {\n return floor(v * exp2(amt) + 0.5);\n }\n float maskLast (float v, float bits) {\n return mod(v, shiftLeft(1.0, bits));\n }\n float extractBits (float num, float from, float to) {\n from = floor(from + 0.5); to = floor(to + 0.5);\n return maskLast(shiftRight(num, from), to - from);\n }\n\n vec4 floatToRgba(float texelFloat, bool littleEndian) {\n if (texelFloat == 0.0) return vec4(0.0, 0.0, 0.0, 0.0);\n float sign = texelFloat > 0.0 ? 0.0 : 1.0;\n texelFloat = abs(texelFloat);\n float exponent = floor(log2(texelFloat));\n float biased_exponent = exponent + 127.0;\n float fraction = ((texelFloat / exp2(exponent)) - 1.0) * 8388608.0;\n float t = biased_exponent / 2.0;\n float last_bit_of_biased_exponent = fract(t) * 2.0;\n float remaining_bits_of_biased_exponent = floor(t);\n float byte4 = extractBits(fraction, 0.0, 8.0) / 255.0;\n float byte3 = extractBits(fraction, 8.0, 16.0) / 255.0;\n float byte2 = (last_bit_of_biased_exponent * 128.0 + extractBits(fraction, 16.0, 23.0)) / 255.0;\n float byte1 = (sign * 128.0 + remaining_bits_of_biased_exponent) / 255.0;\n return (\n littleEndian\n ? vec4(byte4, byte3, byte2, byte1)\n : vec4(byte1, byte2, byte3, byte4)\n );\n }\n",light_frag_params:"\n#if dLightCount != 0\n uniform vec3 uLightDirection[dLightCount];\n uniform vec3 uLightColor[dLightCount];\n#endif\nuniform vec3 uAmbientColor;\n\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n float roughness;\n vec3 specularColor;\n float specularF90;\n};\n\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n};\n\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n\nstruct GeometricContext {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n};\n\nvec3 BRDF_Lambert(const in vec3 diffuseColor) {\n return RECIPROCAL_PI * diffuseColor;\n}\n\nvec3 F_Schlick(const in vec3 f0, const in float f90, const in float dotVH) {\n // Original approximation by Christophe Schlick '94\n // float fresnel = pow( 1.0 - dotVH, 5.0 );\n // Optimized variant (presented by Epic at SIGGRAPH '13)\n // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n float fresnel = exp2((-5.55473 * dotVH - 6.98316) * dotVH);\n return f0 * (1.0 - fresnel) + (f90 * fresnel);\n}\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat V_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {\n float a2 = pow2(alpha);\n float gv = dotNL * sqrt(a2 + (1.0 - a2) * pow2(dotNV));\n float gl = dotNV * sqrt(a2 + (1.0 - a2) * pow2(dotNL));\n return 0.5 / max(gv + gl, EPSILON);\n}\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is \"roughness squared\" in Disney\u2019s reparameterization\nfloat D_GGX(const in float alpha, const in float dotNH) {\n float a2 = pow2(alpha);\n float denom = pow2(dotNH) * (a2 - 1.0) + 1.0; // avoid alpha = 0 with dotNH = 1\n return RECIPROCAL_PI * a2 / pow2(denom);\n}\n\n// GGX Distribution, Schlick Fresnel, GGX_SmithCorrelated Visibility\nvec3 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) {\n float alpha = pow2(roughness); // UE4's roughness\n vec3 halfDir = normalize( lightDir + viewDir);\n float dotNL = saturate(dot(normal, lightDir));\n float dotNV = saturate(dot(normal, viewDir));\n float dotNH = saturate(dot(normal, halfDir));\n float dotVH = saturate(dot(viewDir, halfDir));\n vec3 F = F_Schlick(f0, f90, dotVH);\n float V = V_GGX_SmithCorrelated(alpha, dotNL, dotNV);\n float D = D_GGX(alpha, dotNH);\n return F * (V * D);\n}\n\n// Analytical approximation of the DFG LUT, one half of the\n// split-sum approximation used in indirect specular lighting.\n// via 'environmentBRDF' from \"Physically Based Shading on Mobile\"\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile\nvec2 DFGApprox(const in vec3 normal, const in vec3 viewDir, const in float roughness) {\n float dotNV = saturate(dot(normal, viewDir));\n const vec4 c0 = vec4(-1, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y;\n vec2 fab = vec2(-1.04, 1.04) * a004 + r.zw;\n return fab;\n}\n\n// Fdez-Ag\xfcera's \"Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting\"\n// Approximates multiscattering in order to preserve energy.\n// http://www.jcgt.org/published/0008/01/03/\nvoid 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) {\n vec2 fab = DFGApprox(normal, viewDir, roughness);\n vec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = specularColor + (1.0 - specularColor) * 0.047619; // 1/21\n vec3 Fms = FssEss * Favg / (1.0 - Ems * Favg);\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\n\nvoid RE_Direct_Physical(const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n float dotNL = saturate(dot(geometry.normal, directLight.direction));\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directSpecular += irradiance * BRDF_GGX(directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness);\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\n\nvoid RE_IndirectDiffuse_Physical(const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\n\nvoid 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) {\n // Both indirect specular and indirect diffuse light accumulate here\n vec3 singleScattering = vec3(0.0);\n vec3 multiScattering = vec3(0.0);\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n computeMultiscattering(geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering);\n vec3 diffuse = material.diffuseColor * (1.0 - ( singleScattering + multiScattering));\n reflectedLight.indirectSpecular += radiance * singleScattering;\n reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n",matrix_scale:"\nfloat matrixScale(in mat4 m){\n vec4 r = m[0];\n return sqrt(r[0] * r[0] + r[1] * r[1] + r[2] * r[2]);\n}\n",normal_frag_params:"\nvarying vec3 vNormal;\n",read_from_texture:"\nvec4 readFromTexture(const in sampler2D tex, const in float i, const in vec2 dim) {\n float x = intMod(i, dim.x);\n float y = floor(intDiv(i, dim.x));\n vec2 uv = (vec2(x, y) + 0.5) / dim;\n return texture2D(tex, uv);\n}\n\nvec4 readFromTexture(const in sampler2D tex, const in int i, const in vec2 dim) {\n int x = imod(i, int(dim.x));\n int y = i / int(dim.x);\n vec2 uv = (vec2(x, y) + 0.5) / dim;\n return texture2D(tex, uv);\n}\n",rgba_to_float:'\n // rgbaToFloat adapted from https://github.com/ihmeuw/glsl-rgba-to-float\n // BSD 3-Clause License\n //\n // Copyright (c) 2019, Institute for Health Metrics and Evaluation All rights reserved.\n // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n // - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n // - 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.\n // - 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.\n //\n // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,\n // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\n // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n // OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ivec4 floatsToBytes(vec4 inputFloats, bool littleEndian) {\n ivec4 bytes = ivec4(inputFloats * 255.0);\n return (\n littleEndian\n ? bytes.abgr\n : bytes\n );\n }\n\n // Break the four bytes down into an array of 32 bits.\n void bytesToBits(const in ivec4 bytes, out bool bits[32]) {\n for (int channelIndex = 0; channelIndex < 4; ++channelIndex) {\n float acc = float(bytes[channelIndex]);\n for (int indexInByte = 7; indexInByte >= 0; --indexInByte) {\n float powerOfTwo = exp2(float(indexInByte));\n bool bit = acc >= powerOfTwo;\n bits[channelIndex * 8 + (7 - indexInByte)] = bit;\n acc = mod(acc, powerOfTwo);\n }\n }\n }\n\n // Compute the exponent of the 32-bit float.\n float getExponent(bool bits[32]) {\n const int startIndex = 1;\n const int bitStringLength = 8;\n const int endBeforeIndex = startIndex + bitStringLength;\n float acc = 0.0;\n int pow2 = bitStringLength - 1;\n for (int bitIndex = startIndex; bitIndex < endBeforeIndex; ++bitIndex) {\n acc += float(bits[bitIndex]) * exp2(float(pow2--));\n }\n return acc;\n }\n\n // Compute the mantissa of the 32-bit float.\n float getMantissa(bool bits[32], bool subnormal) {\n const int startIndex = 9;\n const int bitStringLength = 23;\n const int endBeforeIndex = startIndex + bitStringLength;\n // Leading/implicit/hidden bit convention:\n // If the number is not subnormal (with exponent 0), we add a leading 1 digit.\n float acc = float(!subnormal) * exp2(float(bitStringLength));\n int pow2 = bitStringLength - 1;\n for (int bitIndex = startIndex; bitIndex < endBeforeIndex; ++bitIndex) {\n acc += float(bits[bitIndex]) * exp2(float(pow2--));\n }\n return acc;\n }\n\n // Parse the float from its 32 bits.\n float bitsToFloat(bool bits[32]) {\n float signBit = float(bits[0]) * -2.0 + 1.0;\n float exponent = getExponent(bits);\n bool subnormal = abs(exponent - 0.0) < 0.01;\n float mantissa = getMantissa(bits, subnormal);\n float exponentBias = 127.0;\n return signBit * mantissa * exp2(exponent - exponentBias - 23.0);\n }\n\n float rgbaToFloat(vec4 texelRGBA, bool littleEndian) {\n ivec4 rgbaBytes = floatsToBytes(texelRGBA, littleEndian);\n bool bits[32];\n bytesToBits(rgbaBytes, bits);\n return bitsToFloat(bits);\n }\n',size_vert_params:"\n#if defined(dSizeType_uniform)\n uniform float uSize;\n#elif defined(dSizeType_attribute)\n attribute float aSize;\n#elif defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance)\n uniform vec2 uSizeTexDim;\n uniform sampler2D tSize;\n#endif\n\nuniform float uSizeFactor;\n",texture3d_from_1d_trilinear:"\nvec4 texture3dFrom1dTrilinear(const in sampler2D tex, const in vec3 pos, const in vec3 gridDim, const in vec2 texDim, const in float offset) {\n float gdYZ = gridDim.z * gridDim.y;\n float gdZ = gridDim.z;\n vec3 p0 = floor(pos * gridDim);\n vec3 p1 = ceil(pos * gridDim);\n vec3 pd = (pos * gridDim - p0) / (p1 - p0);\n vec4 s000 = readFromTexture(tex, offset + p0.z + p0.y * gdZ + p0.x * gdYZ, texDim);\n vec4 s100 = readFromTexture(tex, offset + p0.z + p0.y * gdZ + p1.x * gdYZ, texDim);\n vec4 s001 = readFromTexture(tex, offset + p1.z + p0.y * gdZ + p0.x * gdYZ, texDim);\n vec4 s101 = readFromTexture(tex, offset + p1.z + p0.y * gdZ + p1.x * gdYZ, texDim);\n vec4 s010 = readFromTexture(tex, offset + p0.z + p1.y * gdZ + p0.x * gdYZ, texDim);\n vec4 s110 = readFromTexture(tex, offset + p0.z + p1.y * gdZ + p1.x * gdYZ, texDim);\n vec4 s011 = readFromTexture(tex, offset + p1.z + p1.y * gdZ + p0.x * gdYZ, texDim);\n vec4 s111 = readFromTexture(tex, offset + p1.z + p1.y * gdZ + p1.x * gdYZ, texDim);\n vec4 s00 = mix(s000, s100, pd.x);\n vec4 s01 = mix(s001, s101, pd.x);\n vec4 s10 = mix(s010, s110, pd.x);\n vec4 s11 = mix(s011, s111, pd.x);\n vec4 s0 = mix(s00, s10, pd.y);\n vec4 s1 = mix(s01, s11, pd.y);\n return mix(s0, s1, pd.z);\n}\n",texture3d_from_2d_linear:"\nvec4 texture3dFrom2dLinear(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {\n float zSlice0 = floor(pos.z * gridDim.z);\n float column0 = intMod(zSlice0 * gridDim.x, texDim.x) / gridDim.x;\n float row0 = floor(intDiv(zSlice0 * gridDim.x, texDim.x));\n vec2 coord0 = (vec2(column0 * gridDim.x, row0 * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;\n vec4 color0 = texture2D(tex, coord0);\n\n float zSlice1 = zSlice0 + 1.0;\n float column1 = intMod(zSlice1 * gridDim.x, texDim.x) / gridDim.x;\n float row1 = floor(intDiv(zSlice1 * gridDim.x, texDim.x));\n vec2 coord1 = (vec2(column1 * gridDim.x, row1 * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;\n vec4 color1 = texture2D(tex, coord1);\n\n float delta0 = abs((pos.z * gridDim.z) - zSlice0);\n return mix(color0, color1, delta0);\n}\n",texture3d_from_2d_nearest:"\nvec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {\n float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice\n float column = intMod(zSlice * gridDim.x, texDim.x) / gridDim.x;\n float row = floor(intDiv(zSlice * gridDim.x, texDim.x));\n vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;\n return texture2D(tex, coord);\n}\n",wboit_write:"\n#if defined(dRenderVariant_colorWboit)\n if (uRenderMask == MaskOpaque) {\n if (preFogAlpha < 1.0) {\n discard;\n }\n } else if (uRenderMask == MaskTransparent) {\n if (preFogAlpha != 1.0 && fragmentDepth < getDepth(gl_FragCoord.xy / uDrawingBufferSize)) {\n #ifdef dTransparentBackfaces_off\n if (interior) discard;\n #endif\n float alpha = gl_FragColor.a;\n float wboitWeight = alpha * clamp(pow(1.0 - fragmentDepth, 2.0), 0.01, 1.0);\n gl_FragColor = vec4(gl_FragColor.rgb * alpha * wboitWeight, alpha);\n // extra alpha is to handle pre-multiplied alpha\n #ifndef dGeometryType_directVolume\n gl_FragData[1] = vec4((uTransparentBackground ? alpha : 1.0) * alpha * wboitWeight);\n #else\n gl_FragData[1] = vec4(alpha * alpha * wboitWeight);\n #endif\n } else {\n discard;\n }\n }\n#endif\n",dpoit_write:"\n#if defined(dRenderVariant_colorDpoit)\n if (uRenderMask == MaskOpaque) {\n if (preFogAlpha < 1.0) {\n discard;\n }\n } else if (uRenderMask == MaskTransparent) {\n vec2 coords = gl_FragCoord.xy / uDrawingBufferSize;\n if (preFogAlpha != 1.0 && fragmentDepth < getDepth(coords)) {\n #ifdef dTransparentBackfaces_off\n if (interior) discard;\n #endif\n\n // adapted from https://github.com/tsherif/webgl2examples\n // The MIT License, Copyright 2017 Tarek Sherif, Shuai Shao\n\n vec2 lastDepth = texture2D(tDpoitDepth, coords).rg;\n vec4 lastFrontColor = texture2D(tDpoitFrontColor, coords);\n\n vec4 fragColor = gl_FragColor;\n\n // depth value always increases\n // so we can use MAX blend equation\n gl_FragData[2].rg = vec2(-MAX_DPOIT_DEPTH);\n\n // front color always increases\n // so we can use MAX blend equation\n gl_FragColor = lastFrontColor;\n\n // back color is separately blend afterwards each pass\n gl_FragData[1] = vec4(0.0);\n\n float nearestDepth = -lastDepth.x;\n float furthestDepth = lastDepth.y;\n float alphaMultiplier = 1.0 - lastFrontColor.a;\n\n if (fragmentDepth < nearestDepth || fragmentDepth > furthestDepth) {\n // Skip this depth since it's been peeled.\n return;\n }\n\n if (fragmentDepth > nearestDepth && fragmentDepth < furthestDepth) {\n // This needs to be peeled.\n // The ones remaining after MAX blended for\n // all need-to-peel will be peeled next pass.\n gl_FragData[2].rg = vec2(-fragmentDepth, fragmentDepth);\n return;\n }\n\n // write to back and front color buffer\n if (fragmentDepth == nearestDepth) {\n gl_FragColor.rgb += fragColor.rgb * fragColor.a * alphaMultiplier;\n gl_FragColor.a = 1.0 - alphaMultiplier * (1.0 - fragColor.a);\n } else {\n gl_FragData[1] += fragColor;\n }\n\n } else {\n discard;\n }\n }\n#endif\n"},sGe=/^(?!\/\/)\s*#include\s+(\S+)/gm,aGe=/#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,cGe=/[ \t]*\/\/.*\n/g,uGe=/[ \t]*\/\*[\s\S]*?\*\//g,lGe=/\n{2,}/g;function Sre(e){return e.replace(sGe,(t,n)=>{const r=oGe[n];if(!r)throw new Error(`empty chunk, '${n}'`);return r}).trim().replace(cGe,"\n").replace(uGe,"\n").replace(lGe,"\n")}function fGe(e,t,n,r){let i="";for(let o=parseInt(t);o radius) discard;\n #elif defined(dPointStyle_fuzzy)\n float dist = distance(gl_PointCoord, center);\n float fuzzyAlpha = 1.0 - smoothstep(0.0, radius, dist);\n if (fuzzyAlpha < 0.0001) discard;\n #endif\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #ifdef requiredDrawBuffers\n gl_FragColor = vObject;\n gl_FragData[1] = vInstance;\n gl_FragData[2] = vGroup;\n gl_FragData[3] = packDepthToRGBA(fragmentDepth);\n #else\n gl_FragColor = vColor;\n #endif\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n gl_FragColor = material;\n\n #if defined(dPointStyle_fuzzy)\n gl_FragColor.a *= fuzzyAlpha;\n #endif\n\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{drawBuffers:"optional"},{},gD),mGe=Br("spheres","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include size_vert_params\n#include common_clip\n\nuniform mat4 uModelView;\nuniform mat4 uInvProjection;\nuniform float uIsOrtho;\n\nuniform vec2 uTexDim;\nuniform sampler2D tPositionGroup;\n\nattribute mat4 aTransform;\nattribute float aInstance;\n\nvarying float vRadius;\nvarying vec3 vPoint;\nvarying vec3 vPointViewPosition;\n\n#include matrix_scale\n\n/**\n * Bounding rectangle of a clipped, perspective-projected 3D Sphere.\n * Michael Mara, Morgan McGuire. 2013\n *\n * Specialization by Arseny Kapoulkine, MIT License Copyright (c) 2018\n * https://github.com/zeux/niagara\n */\nvoid sphereProjection(const in vec3 p, const in float r, const in vec2 mapping) {\n vec3 pr = p * r;\n float pzr2 = p.z * p.z - r * r;\n\n float vx = sqrt(p.x * p.x + pzr2);\n float minx = ((vx * p.x - pr.z) / (vx * p.z + pr.x)) * uProjection[0][0];\n float maxx = ((vx * p.x + pr.z) / (vx * p.z - pr.x)) * uProjection[0][0];\n\n float vy = sqrt(p.y * p.y + pzr2);\n float miny = ((vy * p.y - pr.z) / (vy * p.z + pr.y)) * uProjection[1][1];\n float maxy = ((vy * p.y + pr.z) / (vy * p.z - pr.y)) * uProjection[1][1];\n\n gl_Position.xy = vec2(maxx + minx, maxy + miny) * -0.5;\n gl_Position.xy -= mapping * vec2(maxx - minx, maxy - miny) * 0.5;\n gl_Position.xy *= gl_Position.w;\n}\n\nvoid main(void){\n vec2 mapping = vec2(1.0, 1.0); // vertices 2 and 5\n #if __VERSION__ == 100\n int m = imod(VertexID, 6);\n #else\n int m = VertexID % 6;\n #endif\n if (m == 0) {\n mapping = vec2(-1.0, 1.0);\n } else if (m == 1 || m == 3) {\n mapping = vec2(-1.0, -1.0);\n } else if (m == 4) {\n mapping = vec2(1.0, -1.0);\n }\n\n vec4 positionGroup = readFromTexture(tPositionGroup, VertexID / 6, uTexDim);\n vec3 position = positionGroup.rgb;\n float group = positionGroup.a;\n\n #include assign_color_varying\n #include assign_marker_varying\n #include assign_clipping_varying\n #include assign_size\n\n vRadius = size * matrixScale(uModelView);\n\n vec4 position4 = vec4(position, 1.0);\n vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader\n\n float d;\n if (uLod.w != 0.0 && (uLod.x != 0.0 || uLod.y != 0.0)) {\n d = dot(uCameraPlane.xyz, vModelPosition) + uCameraPlane.w;\n float f = min(\n smoothstep(uLod.x, uLod.x + uLod.z, d),\n 1.0 - smoothstep(uLod.y - uLod.z, uLod.y, d)\n ) * uLod.w;\n vRadius *= f;\n }\n\n vec4 mvPosition = uModelView * aTransform * position4;\n\n #ifdef dApproximate\n vec4 mvCorner = vec4(mvPosition.xyz, 1.0);\n mvCorner.xy += mapping * vRadius;\n gl_Position = uProjection * mvCorner;\n #else\n if (uIsOrtho == 1.0) {\n vec4 mvCorner = vec4(mvPosition.xyz, 1.0);\n mvCorner.xy += mapping * vRadius;\n gl_Position = uProjection * mvCorner;\n } else {\n gl_Position = uProjection * vec4(mvPosition.xyz, 1.0);\n sphereProjection(mvPosition.xyz, vRadius, mapping);\n }\n #endif\n\n vec4 vPoint4 = uInvProjection * gl_Position;\n vPoint = vPoint4.xyz / vPoint4.w;\n vPointViewPosition = -mvPosition.xyz / mvPosition.w;\n\n if (gl_Position.z < -gl_Position.w) {\n mvPosition.z -= 2.0 * vRadius; // avoid clipping\n gl_Position.z = (uProjection * vec4(mvPosition.xyz, 1.0)).z;\n }\n\n if (uLod.w != 0.0 && (uLod.x != 0.0 || uLod.y != 0.0)) {\n if (d < uLod.x || d > uLod.y) {\n // move out of [ -w, +w ] to 'discard' in vert shader\n gl_Position.z = 2.0 * gl_Position.w;\n }\n }\n\n #if defined(dClipPrimitive) && !defined(dClipVariant_instance) && dClipObjectCount != 0\n if (clipTest(vec4(vModelPosition.xyz, 0.0))) {\n // move out of [ -w, +w ] to 'discard' in vert shader\n gl_Position.z = 2.0 * gl_Position.w;\n }\n #else\n #include clip_instance\n #endif\n}\n","\nprecision highp float;\nprecision highp int;\n\n#define bumpEnabled\n\n#include common\n#include common_frag_params\n#include color_frag_params\n#include light_frag_params\n#include common_clip\n\nuniform mat4 uInvView;\nuniform float uAlphaThickness;\n\nvarying float vRadius;\nvarying vec3 vPoint;\nvarying vec3 vPointViewPosition;\n\n#ifdef dSolidInterior\n const bool solidInterior = true;\n#else\n const bool solidInterior = false;\n#endif\n\nbool SphereImpostor(out vec3 modelPos, out vec3 cameraPos, out vec3 cameraNormal, out bool interior, out float fragmentDepth){\n vec3 cameraSpherePos = -vPointViewPosition;\n\n vec3 rayOrigin = mix(vec3(0.0, 0.0, 0.0), vPoint, uIsOrtho);\n vec3 rayDirection = mix(normalize(vPoint), vec3(0.0, 0.0, 1.0), uIsOrtho);\n vec3 cameraSphereDir = mix(cameraSpherePos, rayOrigin - cameraSpherePos, uIsOrtho);\n\n float B = dot(rayDirection, cameraSphereDir);\n float det = B * B + vRadius * vRadius - dot(cameraSphereDir, cameraSphereDir);\n\n if (det < 0.0) return false;\n\n float sqrtDet = sqrt(det);\n float posT = mix(B + sqrtDet, B - sqrtDet, uIsOrtho);\n float negT = mix(B - sqrtDet, B + sqrtDet, uIsOrtho);\n\n cameraPos = rayDirection * negT + rayOrigin;\n modelPos = (uInvView * vec4(cameraPos, 1.0)).xyz;\n fragmentDepth = calcDepth(cameraPos);\n\n bool objectClipped = false;\n\n #if !defined(dClipPrimitive) && defined(dClipVariant_pixel) && dClipObjectCount != 0\n if (clipTest(vec4(modelPos, 0.0))) {\n objectClipped = true;\n fragmentDepth = -1.0;\n }\n #endif\n\n if (fragmentDepth > 0.0) {\n cameraNormal = normalize(cameraPos - cameraSpherePos);\n interior = false;\n return true;\n } else if (uDoubleSided || solidInterior) {\n cameraPos = rayDirection * posT + rayOrigin;\n modelPos = (uInvView * vec4(cameraPos, 1.0)).xyz;\n fragmentDepth = calcDepth(cameraPos);\n cameraNormal = -normalize(cameraPos - cameraSpherePos);\n interior = true;\n if (fragmentDepth > 0.0) {\n #ifdef dSolidInterior\n if (!objectClipped) {\n fragmentDepth = 0.0 + (0.0000001 / vRadius);\n cameraNormal = -mix(normalize(vPoint), vec3(0.0, 0.0, 1.0), uIsOrtho);\n }\n #endif\n return true;\n }\n }\n\n return false;\n}\n\nvoid main(void){\n vec3 cameraNormal;\n float fragmentDepth;\n\n #ifdef dApproximate\n vec3 pointDir = -vPointViewPosition - vPoint;\n if (dot(pointDir, pointDir) > vRadius * vRadius) discard;\n vec3 vViewPosition = -vPointViewPosition;\n fragmentDepth = gl_FragCoord.z;\n #if !defined(dIgnoreLight) || defined(dXrayShaded)\n pointDir.z -= cos(length(pointDir) / vRadius);\n cameraNormal = -normalize(pointDir / vRadius);\n #endif\n interior = false;\n #else\n vec3 modelPos;\n vec3 cameraPos;\n bool hit = SphereImpostor(modelPos, cameraPos, cameraNormal, interior, fragmentDepth);\n if (!hit) discard;\n\n if (fragmentDepth < 0.0) discard;\n if (fragmentDepth > 1.0) discard;\n\n gl_FragDepthEXT = fragmentDepth;\n\n vec3 vModelPosition = modelPos;\n vec3 vViewPosition = cameraPos;\n #endif\n\n #include fade_lod\n #if !defined(dClipPrimitive) && defined(dClipVariant_pixel) && dClipObjectCount != 0\n #include clip_pixel\n #endif\n #include assign_material_color\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #ifdef requiredDrawBuffers\n gl_FragColor = vObject;\n gl_FragData[1] = vInstance;\n gl_FragData[2] = vGroup;\n gl_FragData[3] = packDepthToRGBA(fragmentDepth);\n #else\n gl_FragColor = vColor;\n #endif\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n vec3 normal = -cameraNormal;\n #include apply_light_color\n\n if (uRenderMask == MaskTransparent && uAlphaThickness > 0.0) {\n gl_FragColor.a *= min(1.0, vRadius / uAlphaThickness);\n }\n\n #include apply_interior_color\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{fragDepth:"required",drawBuffers:"optional"},{},lS),gGe=Br("cylinders","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include size_vert_params\n#include common_clip\n\nuniform mat4 uModelView;\n\nattribute mat4 aTransform;\nattribute float aInstance;\nattribute float aGroup;\n\nattribute vec3 aMapping;\nattribute vec3 aStart;\nattribute vec3 aEnd;\nattribute float aScale;\nattribute float aCap;\nattribute float aColorMode;\n\nvarying mat4 vTransform;\nvarying vec3 vStart;\nvarying vec3 vEnd;\nvarying float vSize;\nvarying float vCap;\n\nuniform float uIsOrtho;\nuniform vec3 uCameraDir;\n\nvoid main() {\n #include assign_group\n #include assign_color_varying\n #include assign_marker_varying\n #include assign_clipping_varying\n #include assign_size\n\n mat4 modelTransform = uModel * aTransform;\n\n vTransform = aTransform;\n vStart = (modelTransform * vec4(aStart, 1.0)).xyz;\n vEnd = (modelTransform * vec4(aEnd, 1.0)).xyz;\n vSize = size * aScale;\n vCap = aCap;\n\n vModelPosition = (vStart + vEnd) * 0.5;\n vec3 camDir = -mix(normalize(vModelPosition - uCameraPosition), uCameraDir, uIsOrtho);\n vec3 dir = vEnd - vStart;\n float f = aMapping.x > 0.0 ? 1.0 : 0.0;\n // ensure cylinder 'dir' is pointing towards the camera\n if(dot(camDir, dir) < 0.0) {\n dir = -dir;\n f = 1.0 - f;\n }\n\n vec3 left = cross(camDir, dir);\n vec3 up = cross(left, dir);\n left = vSize * normalize(left);\n up = vSize * normalize(up);\n\n // move vertex in object-space from center to corner\n vModelPosition += aMapping.x * dir + aMapping.y * left + aMapping.z * up;\n\n vec4 mvPosition = uView * vec4(vModelPosition, 1.0);\n vViewPosition = mvPosition.xyz;\n gl_Position = uProjection * mvPosition;\n\n if (gl_Position.z < -gl_Position.w) {\n mvPosition.z -= 2.0 * (length(vEnd - vStart) + vSize); // avoid clipping\n gl_Position.z = (uProjection * mvPosition).z;\n }\n\n #if defined(dDualColor) && defined(dRenderVariant_color) && (defined(dColorType_group) || defined(dColorType_groupInstance))\n // dual-color mixing\n // - for aColorMode between 0 and 1 use aColorMode to interpolate\n // - for aColorMode == 2 do nothing, i.e., use vColor\n // - for aColorMode == 3 use position on cylinder axis to interpolate\n if (aColorMode <= 1.0){\n vColor.rgb = mix(vColor.rgb, color2.rgb, aColorMode);\n } else if (aColorMode == 3.0) {\n vColor.rgb = mix(vColor.rgb, color2.rgb, mix(-0.25, 1.25, f / 1.5));\n }\n #endif\n\n #include clip_instance\n}\n","\nprecision highp float;\nprecision highp int;\n\n#define bumpEnabled\n\nuniform mat4 uView;\n\nvarying mat4 vTransform;\nvarying vec3 vStart;\nvarying vec3 vEnd;\nvarying float vSize;\nvarying float vCap;\n\nuniform vec3 uCameraDir;\nuniform vec3 uCameraPosition;\nuniform mat4 uInvView;\n\n#include common\n#include common_frag_params\n#include color_frag_params\n#include light_frag_params\n#include common_clip\n\n#ifdef dSolidInterior\n const bool solidInterior = true;\n#else\n const bool solidInterior = false;\n#endif\n\n// adapted from https://www.shadertoy.com/view/4lcSRn\n// The MIT License, Copyright 2016 Inigo Quilez\nbool CylinderImpostor(\n in vec3 rayOrigin, in vec3 rayDir,\n in vec3 start, in vec3 end, in float radius,\n out vec3 cameraNormal, out bool interior,\n out vec3 modelPosition, out vec3 viewPosition, out float fragmentDepth\n){\n vec3 ba = end - start;\n vec3 oc = rayOrigin - start;\n\n float baba = dot(ba, ba);\n float bard = dot(ba, rayDir);\n float baoc = dot(ba, oc);\n\n float k2 = baba - bard * bard;\n float k1 = baba * dot(oc, rayDir) - baoc * bard;\n float k0 = baba * dot(oc, oc) - baoc * baoc - radius * radius * baba;\n\n float h = k1 * k1 - k2 * k0;\n if (h < 0.0) return false;\n\n bool topCap = (vCap > 0.9 && vCap < 1.1) || vCap >= 2.9;\n bool bottomCap = (vCap > 1.9 && vCap < 2.1) || vCap >= 2.9;\n\n #ifdef dSolidInterior\n bool topInterior = !topCap;\n bool bottomInterior = !bottomCap;\n topCap = true;\n bottomCap = true;\n #else\n bool topInterior = false;\n bool bottomInterior = false;\n #endif\n\n bool clipped = false;\n bool objectClipped = false;\n\n // body outside\n h = sqrt(h);\n float t = (-k1 - h) / k2;\n float y = baoc + t * bard;\n if (y > 0.0 && y < baba) {\n interior = false;\n cameraNormal = (oc + t * rayDir - ba * y / baba) / radius;\n modelPosition = rayOrigin + t * rayDir;\n viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;\n fragmentDepth = calcDepth(viewPosition);\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n if (clipTest(vec4(modelPosition, 0.0))) {\n objectClipped = true;\n fragmentDepth = -1.0;\n #ifdef dSolidInterior\n topCap = !topInterior;\n bottomCap = !bottomInterior;\n #endif\n }\n #endif\n if (fragmentDepth > 0.0) return true;\n clipped = true;\n }\n\n if (!clipped) {\n if (topCap && y < 0.0) {\n // top cap\n t = -baoc / bard;\n if (abs(k1 + k2 * t) < h) {\n interior = topInterior;\n cameraNormal = -ba / baba;\n modelPosition = rayOrigin + t * rayDir;\n viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;\n fragmentDepth = calcDepth(viewPosition);\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n if (clipTest(vec4(modelPosition, 0.0))) {\n objectClipped = true;\n fragmentDepth = -1.0;\n #ifdef dSolidInterior\n topCap = !topInterior;\n bottomCap = !bottomInterior;\n #endif\n }\n #endif\n if (fragmentDepth > 0.0) {\n #ifdef dSolidInterior\n if (interior) cameraNormal = -rayDir;\n #endif\n return true;\n }\n }\n } else if (bottomCap && y >= 0.0) {\n // bottom cap\n t = (baba - baoc) / bard;\n if (abs(k1 + k2 * t) < h) {\n interior = bottomInterior;\n cameraNormal = ba / baba;\n modelPosition = rayOrigin + t * rayDir;\n viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;\n fragmentDepth = calcDepth(viewPosition);\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n if (clipTest(vec4(modelPosition, 0.0))) {\n objectClipped = true;\n fragmentDepth = -1.0;\n #ifdef dSolidInterior\n topCap = !topInterior;\n bottomCap = !bottomInterior;\n #endif\n }\n #endif\n if (fragmentDepth > 0.0) {\n #ifdef dSolidInterior\n if (interior) cameraNormal = -rayDir;\n #endif\n return true;\n }\n }\n }\n }\n\n if (uDoubleSided || solidInterior) {\n // body inside\n h = -h;\n t = (-k1 - h) / k2;\n y = baoc + t * bard;\n if (y > 0.0 && y < baba) {\n interior = true;\n cameraNormal = -(oc + t * rayDir - ba * y / baba) / radius;\n modelPosition = rayOrigin + t * rayDir;\n viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;\n fragmentDepth = calcDepth(viewPosition);\n if (fragmentDepth > 0.0) {\n #ifdef dSolidInterior\n if (!objectClipped) {\n fragmentDepth = 0.0 + (0.0000002 / vSize);\n cameraNormal = -rayDir;\n }\n #endif\n return true;\n }\n }\n\n if (topCap && y < 0.0) {\n // top cap\n t = -baoc / bard;\n if (abs(k1 + k2 * t) < -h) {\n interior = true;\n cameraNormal = ba / baba;\n modelPosition = rayOrigin + t * rayDir;\n viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;\n fragmentDepth = calcDepth(viewPosition);\n if (fragmentDepth > 0.0) {\n #ifdef dSolidInterior\n if (!objectClipped) {\n fragmentDepth = 0.0 + (0.0000002 / vSize);\n cameraNormal = -rayDir;\n }\n #endif\n return true;\n }\n }\n } else if (bottomCap && y >= 0.0) {\n // bottom cap\n t = (baba - baoc) / bard;\n if (abs(k1 + k2 * t) < -h) {\n interior = true;\n cameraNormal = -ba / baba;\n modelPosition = rayOrigin + t * rayDir;\n viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;\n fragmentDepth = calcDepth(viewPosition);\n if (fragmentDepth > 0.0) {\n #ifdef dSolidInterior\n if (!objectClipped) {\n fragmentDepth = 0.0 + (0.0000002 / vSize);\n cameraNormal = -rayDir;\n }\n #endif\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\nvoid main() {\n vec3 rayOrigin = vModelPosition;\n vec3 rayDir = mix(normalize(vModelPosition - uCameraPosition), uCameraDir, uIsOrtho);\n\n vec3 cameraNormal;\n vec3 modelPosition;\n vec3 viewPosition;\n float fragmentDepth;\n bool hit = CylinderImpostor(rayOrigin, rayDir, vStart, vEnd, vSize, cameraNormal, interior, modelPosition, viewPosition, fragmentDepth);\n if (!hit) discard;\n\n if (fragmentDepth < 0.0) discard;\n if (fragmentDepth > 1.0) discard;\n\n gl_FragDepthEXT = fragmentDepth;\n\n vec3 vViewPosition = viewPosition;\n vec3 vModelPosition = modelPosition;\n\n #include fade_lod\n #include clip_pixel\n #include assign_material_color\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #ifdef requiredDrawBuffers\n gl_FragColor = vObject;\n gl_FragData[1] = vInstance;\n gl_FragData[2] = vGroup;\n gl_FragData[3] = packDepthToRGBA(fragmentDepth);\n #else\n gl_FragColor = vColor;\n #endif\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n mat3 normalMatrix = transpose3(inverse3(mat3(uView)));\n vec3 normal = normalize(normalMatrix * -normalize(cameraNormal));\n #include apply_light_color\n\n #include apply_interior_color\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{fragDepth:"required",drawBuffers:"optional"},{},lS),yGe=Br("text","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include size_vert_params\n#include common_clip\n\nuniform mat4 uModelView;\n\nattribute vec3 aPosition;\nattribute vec2 aMapping;\nattribute float aDepth;\nattribute vec2 aTexCoord;\nattribute mat4 aTransform;\nattribute float aInstance;\nattribute float aGroup;\n\nuniform float uOffsetX;\nuniform float uOffsetY;\nuniform float uOffsetZ;\n\nuniform float uIsOrtho;\nuniform float uPixelRatio;\nuniform vec4 uViewport;\n\nvarying vec2 vTexCoord;\n\n#include matrix_scale\n\nvoid main(void){\n #include assign_group\n #include assign_color_varying\n #include assign_marker_varying\n #include assign_clipping_varying\n #include assign_size\n\n vTexCoord = aTexCoord;\n\n float scale = matrixScale(uModelView);\n\n float offsetX = uOffsetX * scale;\n float offsetY = uOffsetY * scale;\n float offsetZ = (uOffsetZ + aDepth * 0.95) * scale;\n\n vec4 position4 = vec4(aPosition, 1.0);\n vec4 mvPosition = uModelView * aTransform * position4;\n\n vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader\n\n // TODO\n // #ifdef FIXED_SIZE\n // if (ortho) {\n // scale /= pixelRatio * ((uViewport.w / 2.0) / -uCameraPosition.z) * 0.1;\n // } else {\n // scale /= pixelRatio * ((uViewport.w / 2.0) / -mvPosition.z) * 0.1;\n // }\n // #endif\n\n vec4 mvCorner = vec4(mvPosition.xyz, 1.0);\n\n if (vTexCoord.x == 10.0) { // indicates background plane\n // move a bit to the back, taking distance to camera into account to avoid z-fighting\n offsetZ -= 0.001 * distance(uCameraPosition, (uProjection * mvCorner).xyz);\n }\n\n mvCorner.xy += aMapping * size * scale;\n mvCorner.x += offsetX;\n mvCorner.y += offsetY;\n\n if (uIsOrtho == 1.0) {\n mvCorner.z += offsetZ;\n } else {\n mvCorner.xyz += normalize(-mvCorner.xyz) * offsetZ;\n }\n\n gl_Position = uProjection * mvCorner;\n\n vViewPosition = -mvCorner.xyz;\n\n #include clip_instance\n}\n","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include common_frag_params\n#include color_frag_params\n#include common_clip\n\nuniform sampler2D tFont;\n\nuniform vec3 uBorderColor;\nuniform float uBorderWidth;\nuniform vec3 uBackgroundColor;\nuniform float uBackgroundOpacity;\n\nvarying vec2 vTexCoord;\n\nconst float smoothness = 32.0;\nconst float gamma = 2.2;\n\nvoid main2(){\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n}\n\nvoid main(){\n #include fade_lod\n #include clip_pixel\n\n float fragmentDepth = gl_FragCoord.z;\n #include assign_material_color\n\n if (vTexCoord.x > 1.0) {\n #if defined(dRenderVariant_color)\n material = vec4(uBackgroundColor, uBackgroundOpacity * material.a);\n #endif\n } else {\n // retrieve signed distance\n float sdf = texture2D(tFont, vTexCoord).a + uBorderWidth;\n\n // perform adaptive anti-aliasing of the edges\n float w = clamp(smoothness * (abs(dFdx(vTexCoord.x)) + abs(dFdy(vTexCoord.y))), 0.0, 0.5);\n float a = smoothstep(0.5 - w, 0.5 + w, sdf);\n\n // gamma correction for linear attenuation\n a = pow(a, 1.0 / gamma);\n\n if (a < 0.5) discard;\n\n #if defined(dRenderVariant_color)\n material.a *= a;\n\n // add border\n float t = 0.5 + uBorderWidth;\n if (uBorderWidth > 0.0 && sdf < t) {\n material.xyz = mix(uBorderColor, material.xyz, smoothstep(t - w, t, sdf));\n }\n #endif\n }\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #ifdef requiredDrawBuffers\n gl_FragColor = vObject;\n gl_FragData[1] = vInstance;\n gl_FragData[2] = vGroup;\n gl_FragData[3] = packDepthToRGBA(fragmentDepth);\n #else\n gl_FragColor = vColor;\n #endif\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n gl_FragColor = material;\n\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{drawBuffers:"optional"},{},gD),bGe=Br("lines","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include size_vert_params\n#include common_clip\n\nuniform float uPixelRatio;\nuniform vec4 uViewport;\n\nattribute mat4 aTransform;\nattribute float aInstance;\nattribute float aGroup;\n\nattribute vec2 aMapping;\nattribute vec3 aStart;\nattribute vec3 aEnd;\n\nvoid trimSegment(const in vec4 start, inout vec4 end) {\n // trim end segment so it terminates between the camera plane and the near plane\n // conservative estimate of the near plane\n float a = uProjection[2][2]; // 3rd entry in 3rd column\n float b = uProjection[3][2]; // 3rd entry in 4th column\n float nearEstimate = -0.5 * b / a;\n float alpha = (nearEstimate - start.z) / (end.z - start.z);\n end.xyz = mix(start.xyz, end.xyz, alpha);\n}\n\nvoid main(){\n float aspect = uViewport.z / uViewport.w;\n\n #include assign_group\n #include assign_color_varying\n #include assign_marker_varying\n #include assign_clipping_varying\n #include assign_size\n\n mat4 modelView = uView * uModel * aTransform;\n\n // camera space\n vec4 start = modelView * vec4(aStart, 1.0);\n vec4 end = modelView * vec4(aEnd, 1.0);\n\n // assign position\n vec4 position4 = vec4((aMapping.y < 0.5) ? aStart : aEnd, 1.0);\n vec4 mvPosition = modelView * position4;\n vViewPosition = mvPosition.xyz;\n\n vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader\n\n // special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n // but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n // perhaps there is a more elegant solution -- WestLangley\n bool perspective = (uProjection[2][3] == -1.0); // 4th entry in the 3rd column\n if (perspective) {\n if (start.z < 0.0 && end.z >= 0.0) {\n trimSegment(start, end);\n } else if (end.z < 0.0 && start.z >= 0.0) {\n trimSegment(end, start);\n }\n }\n\n // clip space\n vec4 clipStart = uProjection * start;\n vec4 clipEnd = uProjection * end;\n\n // ndc space\n vec2 ndcStart = clipStart.xy / clipStart.w;\n vec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n // direction\n vec2 dir = ndcEnd - ndcStart;\n\n // account for clip-space aspect ratio\n dir.x *= aspect;\n dir = normalize(dir);\n\n // perpendicular to dir\n vec2 offset = vec2(dir.y, - dir.x);\n\n // undo aspect ratio adjustment\n dir.x /= aspect;\n offset.x /= aspect;\n\n // sign flip\n if (aMapping.x < 0.0) offset *= -1.0;\n\n // calculate linewidth\n float linewidth;\n #ifdef dLineSizeAttenuation\n linewidth = size * uPixelRatio * ((uViewport.w / 2.0) / -start.z) * 5.0;\n #else\n linewidth = size * uPixelRatio;\n #endif\n linewidth = max(1.0, linewidth);\n\n // adjust for linewidth\n offset *= linewidth;\n\n // adjust for clip-space to screen-space conversion\n offset /= uViewport.w;\n\n // select end\n vec4 clip = (aMapping.y < 0.5) ? clipStart : clipEnd;\n\n // back to clip space\n offset *= clip.w;\n clip.xy += offset;\n gl_Position = clip;\n\n #include clip_instance\n}\n","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include common_frag_params\n#include color_frag_params\n#include common_clip\n\nvoid main(){\n #include fade_lod\n #include clip_pixel\n\n float fragmentDepth = gl_FragCoord.z;\n #include assign_material_color\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #ifdef requiredDrawBuffers\n gl_FragColor = vObject;\n gl_FragData[1] = vInstance;\n gl_FragData[2] = vGroup;\n gl_FragData[3] = packDepthToRGBA(fragmentDepth);\n #else\n gl_FragColor = vColor;\n #endif\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n gl_FragColor = material;\n\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{drawBuffers:"optional"},{},gD),wre=Br("mesh","\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include common_clip\n#include texture3d_from_2d_linear\n\n#ifdef dGeometryType_textureMesh\n uniform vec2 uGeoTexDim;\n uniform sampler2D tPosition;\n uniform sampler2D tGroup;\n uniform sampler2D tNormal;\n#else\n attribute vec3 aPosition;\n attribute float aGroup;\n attribute vec3 aNormal;\n#endif\nattribute mat4 aTransform;\nattribute float aInstance;\n\nvarying vec3 vNormal;\n\nvoid main(){\n #include assign_group\n #include assign_marker_varying\n #include assign_clipping_varying\n #include assign_position\n #include assign_color_varying\n #include clip_instance\n\n #ifdef dGeometryType_textureMesh\n vec3 normal = readFromTexture(tNormal, VertexID, uGeoTexDim).xyz;\n #else\n vec3 normal = aNormal;\n #endif\n mat3 normalMatrix = transpose3(inverse3(mat3(modelView)));\n vec3 transformedNormal = normalize(normalMatrix * normalize(normal));\n #if defined(dFlipSided)\n if (!uDoubleSided) { // TODO checking uDoubleSided should not be required, ASR\n transformedNormal = -transformedNormal;\n }\n #endif\n vNormal = transformedNormal;\n}\n","\nprecision highp float;\nprecision highp int;\n\n#define bumpEnabled\n\n#include common\n#include common_frag_params\n#include color_frag_params\n#include light_frag_params\n#include normal_frag_params\n#include common_clip\n\nvoid main() {\n #include fade_lod\n #include clip_pixel\n\n // Workaround for buggy gl_FrontFacing (e.g. on some integrated Intel GPUs)\n vec3 fdx = dFdx(vViewPosition);\n vec3 fdy = dFdy(vViewPosition);\n vec3 faceNormal = normalize(cross(fdx,fdy));\n bool frontFacing = dot(vNormal, faceNormal) > 0.0;\n\n #if defined(dFlipSided)\n interior = frontFacing;\n #else\n interior = !frontFacing;\n #endif\n\n float fragmentDepth = gl_FragCoord.z;\n #include assign_material_color\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #ifdef requiredDrawBuffers\n gl_FragColor = vObject;\n gl_FragData[1] = vInstance;\n gl_FragData[2] = vGroup;\n gl_FragData[3] = packDepthToRGBA(fragmentDepth);\n #else\n gl_FragColor = vColor;\n #endif\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n #if defined(dFlatShaded)\n vec3 normal = -faceNormal;\n #else\n vec3 normal = -normalize(vNormal);\n if (uDoubleSided) normal *= float(frontFacing) * 2.0 - 1.0;\n #endif\n #include apply_light_color\n\n #include apply_interior_color\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{drawBuffers:"optional"},{},lS),vGe=Br("direct-volume","\nprecision highp float;\n\nattribute vec3 aPosition;\nattribute mat4 aTransform;\nattribute float aInstance;\n\nuniform mat4 uModelView;\nuniform mat4 uProjection;\nuniform vec4 uInvariantBoundingSphere;\n\nvarying vec3 vOrigPos;\nvarying float vInstance;\nvarying vec4 vBoundingSphere;\nvarying mat4 vTransform;\n\nuniform vec3 uBboxSize;\nuniform vec3 uBboxMin;\nuniform vec3 uBboxMax;\nuniform vec3 uGridDim;\nuniform mat4 uTransform;\n\nuniform mat4 uUnitToCartn;\n\nvoid main() {\n vec4 unitCoord = vec4(aPosition + vec3(0.5), 1.0);\n vec4 mvPosition = uModelView * aTransform * uUnitToCartn * unitCoord;\n\n vOrigPos = (aTransform * uUnitToCartn * unitCoord).xyz;\n vInstance = aInstance;\n vBoundingSphere = vec4(\n (aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0)).xyz,\n uInvariantBoundingSphere.w\n );\n vTransform = aTransform;\n\n gl_Position = uProjection * mvPosition;\n\n // move z position to near clip plane (but not too close to get precision issues)\n gl_Position.z = gl_Position.w - 0.01;\n}\n","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include light_frag_params\n\n#if dClipObjectCount != 0\n uniform int uClipObjectType[dClipObjectCount];\n uniform bool uClipObjectInvert[dClipObjectCount];\n uniform vec3 uClipObjectPosition[dClipObjectCount];\n uniform vec4 uClipObjectRotation[dClipObjectCount];\n uniform vec3 uClipObjectScale[dClipObjectCount];\n#endif\n#include common_clip\n\n#include read_from_texture\n#include texture3d_from_1d_trilinear\n#include texture3d_from_2d_nearest\n#include texture3d_from_2d_linear\n\nuniform mat4 uProjection, uTransform, uModelView, uModel, uView;\nuniform vec3 uCameraDir;\n\nuniform sampler2D tDepth;\nuniform vec2 uDrawingBufferSize;\n\nvarying vec3 vOrigPos;\nvarying float vInstance;\nvarying vec4 vBoundingSphere;\nvarying mat4 vTransform;\n\nuniform mat4 uInvView;\nuniform vec3 uGridDim;\nuniform vec3 uBboxSize;\nuniform sampler2D tTransferTex;\nuniform float uTransferScale;\nuniform float uStepScale;\nuniform float uJumpLength;\n\nuniform int uObjectId;\nuniform int uVertexCount;\nuniform int uInstanceCount;\nuniform int uGroupCount;\n\n#if defined(dColorMarker)\n uniform vec3 uHighlightColor;\n uniform vec3 uSelectColor;\n uniform vec3 uDimColor;\n uniform float uHighlightStrength;\n uniform float uSelectStrength;\n uniform float uDimStrength;\n uniform int uMarkerPriority;\n uniform float uMarkerAverage;\n\n uniform float uMarker;\n uniform vec2 uMarkerTexDim;\n uniform sampler2D tMarker;\n#endif\n\nuniform float uMetalness;\nuniform float uRoughness;\n\nuniform bool uFog;\nuniform float uFogNear;\nuniform float uFogFar;\nuniform vec3 uFogColor;\n\nuniform float uAlpha;\nuniform bool uTransparentBackground;\nuniform float uXrayEdgeFalloff;\nuniform float uExposure;\n\nuniform int uRenderMask;\n\nuniform float uNear;\nuniform float uFar;\nuniform float uIsOrtho;\n\nuniform vec3 uCellDim;\nuniform vec3 uCameraPosition;\nuniform mat4 uCartnToUnit;\n\n#if __VERSION__ != 100\n // for webgl1 this is given as a 'define'\n uniform int uMaxSteps;\n#endif\n\n#if defined(dGridTexType_2d)\n precision highp sampler2D;\n uniform sampler2D tGridTex;\n uniform vec3 uGridTexDim;\n#elif defined(dGridTexType_3d)\n precision highp sampler3D;\n uniform sampler3D tGridTex;\n#endif\n\n#if defined(dColorType_uniform)\n uniform vec3 uColor;\n#elif defined(dColorType_texture)\n uniform vec2 uColorTexDim;\n uniform sampler2D tColor;\n#endif\n\n#ifdef dOverpaint\n #if defined(dOverpaintType_groupInstance) || defined(dOverpaintType_vertexInstance)\n uniform vec2 uOverpaintTexDim;\n uniform sampler2D tOverpaint;\n #endif\n#endif\n\n#ifdef dUsePalette\n uniform sampler2D tPalette;\n#endif\n\n#if defined(dGridTexType_2d)\n vec4 textureVal(vec3 pos) {\n return texture3dFrom2dLinear(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy);\n }\n vec4 textureGroup(vec3 pos) {\n return texture3dFrom2dNearest(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy);\n }\n#elif defined(dGridTexType_3d)\n vec4 textureVal(vec3 pos) {\n return texture(tGridTex, pos + (vec3(0.5) / uGridDim));\n }\n vec4 textureGroup(vec3 pos) {\n return texelFetch(tGridTex, ivec3(pos * uGridDim), 0);\n }\n#endif\n\nfloat calcDepth(const in vec3 pos) {\n vec2 clipZW = pos.z * uProjection[2].zw + uProjection[3].zw;\n return 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\n\nfloat transferFunction(float value) {\n return texture2D(tTransferTex, vec2(value, 0.0)).a;\n}\n\nfloat getDepth(const in vec2 coords) {\n #ifdef depthTextureSupport\n return texture2D(tDepth, coords).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n #endif\n}\n\nconst float gradOffset = 0.5;\n\nvec3 v3m4(vec3 p, mat4 m) {\n return (m * vec4(p, 1.0)).xyz;\n}\n\nfloat preFogAlphaBlended = 0.0;\n\nvec4 raymarch(vec3 startLoc, vec3 step, vec3 rayDir) {\n mat3 normalMatrix = transpose3(inverse3(mat3(uModelView * vTransform)));\n mat4 cartnToUnit = uCartnToUnit * inverse4(vTransform);\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n mat4 modelTransform = uModel * vTransform * uTransform;\n #endif\n mat4 modelViewTransform = uModelView * vTransform * uTransform;\n\n vec3 scaleVol = vec3(1.0) / uGridDim;\n vec3 pos = startLoc;\n vec4 cell;\n float prevValue = -1.0;\n float value = 0.0;\n vec4 src = vec4(0.0);\n vec4 dst = vec4(0.0);\n float fragmentDepth;\n\n vec3 posMin = vec3(0.0);\n vec3 posMax = vec3(1.0) - vec3(1.0) / uGridDim;\n\n vec3 unitPos;\n\n vec3 nextPos;\n float nextValue;\n\n vec4 material;\n vec4 overpaint;\n float metalness = uMetalness;\n float roughness = uRoughness;\n\n vec3 gradient = vec3(1.0);\n vec3 dx = vec3(gradOffset * scaleVol.x, 0.0, 0.0);\n vec3 dy = vec3(0.0, gradOffset * scaleVol.y, 0.0);\n vec3 dz = vec3(0.0, 0.0, gradOffset * scaleVol.z);\n\n float maxDist = min(vBoundingSphere.w * 2.0, uFar - uNear);\n float maxDistSq = maxDist * maxDist;\n\n for (int i = 0; i < uMaxSteps; ++i) {\n // break when beyond bounding-sphere or far-plane\n vec3 distVec = startLoc - pos;\n if (dot(distVec, distVec) > maxDistSq) break;\n\n unitPos = v3m4(pos, cartnToUnit);\n\n // continue when outside of grid\n if (unitPos.x > posMax.x || unitPos.y > posMax.y || unitPos.z > posMax.z ||\n unitPos.x < posMin.x || unitPos.y < posMin.y || unitPos.z < posMin.z\n ) {\n prevValue = value;\n pos += step;\n continue;\n }\n\n cell = textureVal(unitPos);\n value = cell.a; // current voxel value\n\n if (uJumpLength > 0.0 && value < 0.01) {\n nextPos = pos + rayDir * uJumpLength;\n nextValue = textureVal(v3m4(nextPos, cartnToUnit)).a;\n if (nextValue < 0.01) {\n prevValue = nextValue;\n pos = nextPos;\n continue;\n }\n }\n\n vec4 mvPosition = modelViewTransform * vec4(unitPos * uGridDim, 1.0);\n if (calcDepth(mvPosition.xyz) > getDepth(gl_FragCoord.xy / uDrawingBufferSize))\n break;\n\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n vec3 vModelPosition = v3m4(unitPos * uGridDim, modelTransform);\n if (clipTest(vec4(vModelPosition, 0.0))) {\n prevValue = value;\n pos += step;\n continue;\n }\n #endif\n\n vec3 vViewPosition = mvPosition.xyz;\n material.a = transferFunction(value);\n\n #ifdef dPackedGroup\n float group = unpackRGBToInt(textureGroup(floor(unitPos * uGridDim + 0.5) / uGridDim).rgb);\n #else\n vec3 g = floor(unitPos * uGridDim + 0.5);\n // note that we swap x and z because the texture is flipped around y\n #if defined(dAxisOrder_012)\n float group = g.z + g.y * uGridDim.z + g.x * uGridDim.z * uGridDim.y; // 210\n #elif defined(dAxisOrder_021)\n float group = g.y + g.z * uGridDim.y + g.x * uGridDim.y * uGridDim.z; // 120\n #elif defined(dAxisOrder_102)\n float group = g.z + g.x * uGridDim.z + g.y * uGridDim.z * uGridDim.x; // 201\n #elif defined(dAxisOrder_120)\n float group = g.x + g.z * uGridDim.x + g.y * uGridDim.x * uGridDim.z; // 021\n #elif defined(dAxisOrder_201)\n float group = g.y + g.x * uGridDim.y + g.z * uGridDim.y * uGridDim.x; // 102\n #elif defined(dAxisOrder_210)\n float group = g.x + g.y * uGridDim.x + g.z * uGridDim.x * uGridDim.y; // 012\n #endif\n #endif\n\n #if defined(dColorType_direct) && defined(dUsePalette)\n material.rgb = texture2D(tPalette, vec2(value, 0.0)).rgb;\n #elif defined(dColorType_uniform)\n material.rgb = uColor;\n #elif defined(dColorType_instance)\n material.rgb = readFromTexture(tColor, vInstance, uColorTexDim).rgb;\n #elif defined(dColorType_group)\n material.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;\n #elif defined(dColorType_groupInstance)\n material.rgb = readFromTexture(tColor, vInstance * float(uGroupCount) + group, uColorTexDim).rgb;\n #elif defined(dColorType_vertex)\n material.rgb = texture3dFrom1dTrilinear(tColor, unitPos, uGridDim, uColorTexDim, 0.0).rgb;\n #elif defined(dColorType_vertexInstance)\n material.rgb = texture3dFrom1dTrilinear(tColor, unitPos, uGridDim, uColorTexDim, vInstance * float(uVertexCount)).rgb;\n #endif\n\n #ifdef dOverpaint\n #if defined(dOverpaintType_groupInstance)\n overpaint = readFromTexture(tOverpaint, vInstance * float(uGroupCount) + group, uOverpaintTexDim);\n #elif defined(dOverpaintType_vertexInstance)\n overpaint = texture3dFrom1dTrilinear(tOverpaint, unitPos, uGridDim, uOverpaintTexDim, vInstance * float(uVertexCount));\n #endif\n\n material.rgb = mix(material.rgb, overpaint.rgb, overpaint.a);\n #endif\n\n #ifdef dIgnoreLight\n gl_FragColor.rgb = material.rgb;\n #else\n if (material.a >= 0.01) {\n #ifdef dPackedGroup\n // compute gradient by central differences\n gradient.x = textureVal(unitPos - dx).a - textureVal(unitPos + dx).a;\n gradient.y = textureVal(unitPos - dy).a - textureVal(unitPos + dy).a;\n gradient.z = textureVal(unitPos - dz).a - textureVal(unitPos + dz).a;\n #else\n gradient = cell.xyz * 2.0 - 1.0;\n #endif\n vec3 normal = -normalize(normalMatrix * normalize(gradient));\n #include apply_light_color\n } else {\n gl_FragColor.rgb = material.rgb;\n }\n #endif\n\n gl_FragColor.a = material.a * uAlpha * uTransferScale;\n\n #if defined(dColorMarker)\n float marker = uMarker;\n if (uMarker == -1.0) {\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n #endif\n #include apply_marker_color\n\n preFogAlphaBlended = (1.0 - preFogAlphaBlended) * gl_FragColor.a + preFogAlphaBlended;\n fragmentDepth = calcDepth(mvPosition.xyz);\n #include apply_fog\n\n src = gl_FragColor;\n\n if (!uTransparentBackground) {\n // done in 'apply_fog' otherwise\n src.rgb *= src.a;\n }\n dst = (1.0 - dst.a) * src + dst; // standard blending\n\n // break if the color is opaque enough\n if (dst.a > 0.95)\n break;\n\n pos += step;\n }\n\n return dst;\n}\n\n// TODO: support float texture for higher precision values???\n// TODO: support clipping exclusion texture support\n\nvoid main() {\n if (gl_FrontFacing)\n discard;\n\n vec3 rayDir = mix(normalize(vOrigPos - uCameraPosition), uCameraDir, uIsOrtho);\n vec3 step = rayDir * uStepScale;\n\n float boundingSphereNear = distance(vBoundingSphere.xyz, uCameraPosition) - vBoundingSphere.w;\n float d = max(uNear, boundingSphereNear) - mix(0.0, distance(vOrigPos, uCameraPosition), uIsOrtho);\n vec3 start = mix(uCameraPosition, vOrigPos, uIsOrtho) + (d * rayDir);\n gl_FragColor = raymarch(start, step, rayDir);\n\n float fragmentDepth = calcDepth((uModelView * vec4(start, 1.0)).xyz);\n float preFogAlpha = clamp(preFogAlphaBlended, 0.0, 1.0);\n #include wboit_write\n}\n",{fragDepth:"optional",drawBuffers:"optional"},{},lS),_Ge=Br("image","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include common_vert_params\n\nattribute vec3 aPosition;\nattribute vec2 aUv;\nattribute mat4 aTransform;\nattribute float aInstance;\n\nvarying vec2 vUv;\nvarying float vInstance;\n\nvoid main() {\n #include assign_position\n\n vUv = aUv;\n vInstance = aInstance;\n}\n","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_frag_params\n#include common_clip\n\nuniform vec2 uImageTexDim;\nuniform sampler2D tImageTex;\nuniform sampler2D tGroupTex;\n\nuniform vec2 uMarkerTexDim;\nuniform sampler2D tMarker;\n\nvarying vec2 vUv;\nvarying float vInstance;\n\n#if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell) || defined(dInterpolation_bspline)\n #define dInterpolation_cubic\n#endif\n\n#if defined(dInterpolation_cubic)\n #if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell)\n #if defined(dInterpolation_catmulrom)\n const float B = 0.0;\n const float C = 0.5;\n #elif defined(dInterpolation_mitchell)\n const float B = 0.333;\n const float C = 0.333;\n #endif\n\n float cubicFilter(float x){\n float f = x;\n if (f < 0.0) {\n f = -f;\n }\n if (f < 1.0) {\n return ((12.0 - 9.0 * B - 6.0 * C) * (f * f * f) +\n (-18.0 + 12.0 * B + 6.0 * C) * (f * f) +\n (6.0 - 2.0 * B)) / 6.0;\n }else if (f >= 1.0 && f < 2.0){\n return ((-B - 6.0 * C) * ( f * f * f)\n + (6.0 * B + 30.0 * C) * (f * f) +\n (-(12.0 * B) - 48.0 * C) * f +\n 8.0 * B + 24.0 * C) / 6.0;\n }else{\n return 0.0;\n }\n }\n #elif defined(dInterpolation_bspline)\n float cubicFilter(float x) {\n float f = x;\n if (f < 0.0) {\n f = -f;\n }\n if (f >= 0.0 && f <= 1.0){\n return (2.0 / 3.0) + (0.5) * (f * f * f) - (f * f);\n } else if (f > 1.0 && f <= 2.0) {\n return 1.0 / 6.0 * pow((2.0 - f), 3.0);\n }\n return 1.0;\n }\n #endif\n\n vec4 biCubic(sampler2D tex, vec2 texCoord) {\n vec2 texelSize = 1.0 / uImageTexDim;\n texCoord -= texelSize / 2.0;\n vec4 nSum = vec4(0.0);\n float nDenom = 0.0;\n vec2 cell = fract(texCoord * uImageTexDim);\n for (float m = -1.0; m <= 2.0; ++m) {\n for (float n = -1.0; n <= 2.0; ++n) {\n vec4 vecData = texture2D(tex, texCoord + texelSize * vec2(m, n));\n float c = cubicFilter(m - cell.x) * cubicFilter(-n + cell.y);\n nSum += vecData * c;\n nDenom += c;\n }\n }\n return nSum / nDenom;\n }\n#endif\n\nvoid main() {\n #include fade_lod\n #include clip_pixel\n\n #if defined(dInterpolation_cubic)\n vec4 imageData = biCubic(tImageTex, vUv);\n #else\n vec4 imageData = texture2D(tImageTex, vUv);\n #endif\n imageData.a = clamp(imageData.a, 0.0, 1.0);\n if (imageData.a > 0.9) imageData.a = 1.0;\n\n float fragmentDepth = gl_FragCoord.z;\n\n #if defined(dRenderVariant_pick)\n if (imageData.a < 0.3)\n discard;\n #ifdef requiredDrawBuffers\n gl_FragColor = vec4(packIntToRGB(float(uObjectId)), 1.0);\n gl_FragData[1] = vec4(packIntToRGB(vInstance), 1.0);\n gl_FragData[2] = vec4(texture2D(tGroupTex, vUv).rgb, 1.0);\n gl_FragData[3] = packDepthToRGBA(gl_FragCoord.z);\n #else\n gl_FragColor = vColor;\n if (uPickType == 1) {\n gl_FragColor = vec4(packIntToRGB(float(uObjectId)), 1.0);\n } else if (uPickType == 2) {\n gl_FragColor = vec4(packIntToRGB(vInstance), 1.0);\n } else {\n gl_FragColor = vec4(texture2D(tGroupTex, vUv).rgb, 1.0);\n }\n #endif\n #elif defined(dRenderVariant_depth)\n if (imageData.a < 0.05)\n discard;\n gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n #elif defined(dRenderVariant_marking)\n float marker = uMarker;\n if (uMarker == -1.0) {\n float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb);\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n if (uMarkingType == 1) {\n if (marker > 0.0 || imageData.a < 0.05)\n discard;\n gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n } else {\n if (marker == 0.0 || imageData.a < 0.05)\n discard;\n float depthTest = 1.0;\n if (uMarkingDepthTest) {\n depthTest = (fragmentDepth >= getDepthPacked(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0;\n }\n bool isHighlight = intMod(marker, 2.0) > 0.1;\n gl_FragColor = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0);\n }\n #elif defined(dRenderVariant_color)\n if (imageData.a < 0.05)\n discard;\n gl_FragColor = imageData;\n gl_FragColor.a *= uAlpha;\n\n float marker = uMarker;\n if (uMarker == -1.0) {\n float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb);\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{drawBuffers:"optional"},{},gD);function Are(e,t){var n;if(void 0===e)return"";const r=(null===(n=e.dRenderVariant)||void 0===n?void 0:n.ref.value)||"",i=[];for(const o in e){if(t?.(o,r,e))continue;const a=e[o].ref.value;void 0!==a&&("string"==typeof a?i.push(`#define ${o}_${a}`):"number"==typeof a?i.push(`#define ${o} ${a}`):"boolean"==typeof a?a&&i.push(`#define ${o}`):Rr())}return i.join("\n")+"\n"}const CGe="\n#define attribute in\n#define varying out\n#define texture2D texture\n",wGe="\n#define varying in\n#define texture2D texture\n#define textureCube texture\n#define texture2DLodEXT textureLod\n#define textureCubeLodEXT textureLod\n\n#define gl_FragColor out_FragData0\n#define gl_FragDepthEXT gl_FragDepth\n\n#define depthTextureSupport\n";function EGe(e,t){switch(t){case"b":case"b[]":return e.BOOL;case"f":case"f[]":return e.FLOAT;case"i":case"i[]":return e.INT;case"v2":case"v2[]":return e.FLOAT_VEC2;case"v3":case"v3[]":return e.FLOAT_VEC3;case"v4":case"v4[]":return e.FLOAT_VEC4;case"iv2":case"iv2[]":return e.INT_VEC2;case"iv3":case"iv3[]":return e.INT_VEC3;case"iv4":case"iv4[]":return e.INT_VEC4;case"m3":case"m3[]":return e.FLOAT_MAT3;case"m4":case"m4[]":return e.FLOAT_MAT4;default:console.error(`unknown uniform kind '${t}'`)}}function MGe(e,t,n){e.uniform1f(t,n)}function RGe(e,t,n){e.uniform1fv(t,n)}function kGe(e,t,n){e.uniform1i(t,n)}function NGe(e,t,n){e.uniform1iv(t,n)}function FGe(e,t,n){e.uniform2fv(t,n)}function BGe(e,t,n){e.uniform3fv(t,n)}function OGe(e,t,n){e.uniform4fv(t,n)}function LGe(e,t,n){e.uniform2iv(t,n)}function UGe(e,t,n){e.uniform3iv(t,n)}function VGe(e,t,n){e.uniform4iv(t,n)}function zGe(e,t,n){e.uniformMatrix3fv(t,!1,n)}function GGe(e,t,n){e.uniformMatrix4fv(t,!1,n)}function Ire(e){switch(e){case"f":return MGe;case"f[]":return RGe;case"i":case"t":case"b":return kGe;case"i[]":case"t[]":case"b[]":return NGe;case"v2":case"v2[]":return FGe;case"v3":case"v3[]":return BGe;case"v4":case"v4[]":return OGe;case"iv2":case"iv2[]":return LGe;case"iv3":case"iv3[]":return UGe;case"iv4":case"iv4[]":return VGe;case"m3":case"m3[]":return zGe;case"m4":case"m4[]":return GGe}}const qGe=pa();function $L(e){const t=e.createBuffer();if(null===t)throw new Error("Could not create WebGL buffer");return t}function Tre(e,t,n,r){let i=$L(e);const o=function WGe(e,t){switch(t){case"static":return e.STATIC_DRAW;case"dynamic":return e.DYNAMIC_DRAW;case"stream":return e.STREAM_DRAW}}(e,n),s=function YGe(e,t){switch(t){case"attribute":return e.ARRAY_BUFFER;case"elements":return e.ELEMENT_ARRAY_BUFFER;case"uniform":if(Wt(e))return e.UNIFORM_BUFFER;throw new Error("WebGL2 is required for uniform buffers")}}(e,r),a=function $Ge(e,t){return t instanceof Uint8Array?e.UNSIGNED_BYTE:t instanceof Int8Array?e.BYTE:t instanceof Uint16Array?e.UNSIGNED_SHORT:t instanceof Int16Array?e.SHORT:t instanceof Uint32Array?e.UNSIGNED_INT:t instanceof Int32Array?e.INT:t instanceof Float32Array?e.FLOAT:void Rr()}(e,t),c=t.BYTES_PER_ELEMENT,u=t.length;function l(f){e.bindBuffer(s,i),e.bufferData(s,f,o)}l(t);let d=!1;return{id:qGe(),_usageHint:o,_bufferType:s,_dataType:a,_bpe:c,length:u,getBuffer:()=>i,updateData:l,updateSubData:(f,p,m)=>{e.bindBuffer(s,i),m-p===f.length?e.bufferSubData(s,0,f):e.bufferSubData(s,p*c,f.subarray(p,p+m))},reset:()=>{i=$L(e),l(t)},destroy:()=>{d||(e.deleteBuffer(i),d=!0)}}}function XGe(e,t,n){if("float32"===t)switch(n){case 1:return e.FLOAT;case 2:return e.FLOAT_VEC2;case 3:return e.FLOAT_VEC3;case 4:return e.FLOAT_VEC4;case 16:return e.FLOAT_MAT4}Rr()}const JGe=pa();function YL(e){const t=e.createProgram();if(null===t)throw new Error("Could not create WebGL program");return t}function i9e(e,t,n,r,i){const{defineValues:o,shaderCode:s,schema:a}=i;let c=YL(e);const u=JGe(),l=function DGe(e,t,n,r){const i=Are(n,r.ignoreDefine),o=Are(n,r.ignoreDefine),s=Wt(e)?function AGe(e,t){const n=["#version 300 es"];if(t.drawBuffers&&e.drawBuffers&&n.push("#define requiredDrawBuffers"),t.multiDraw)if(e.multiDraw)n.push("#extension GL_ANGLE_multi_draw : require"),n.push("#define enabledMultiDraw");else if("required"===t.multiDraw)throw new Error("required 'GL_ANGLE_multi_draw' extension not available");if(t.clipCullDistance)if(e.clipCullDistance)n.push("#extension GL_ANGLE_clip_cull_distance : enable"),n.push("#define enabledClipCullDistance");else if("required"===t.clipCullDistance)throw new Error("required 'GL_ANGLE_clip_cull_distance' extension not available");if(t.conservativeDepth)if(e.conservativeDepth)n.push("#extension GL_EXT_conservative_depth : enable"),n.push("#define enabledConservativeDepth");else if("required"===t.conservativeDepth)throw new Error("required 'GL_EXT_conservative_depth' extension not available");return e.noNonInstancedActiveAttribs&&n.push("#define noNonInstancedActiveAttribs"),n.push(CGe),n.join("\n")+"\n"}(t,r.extensions):function xGe(e,t){const n=[];if(t.drawBuffers)if(e.drawBuffers)n.push("#define requiredDrawBuffers");else if("required"===t.drawBuffers)throw new Error("required 'GL_EXT_draw_buffers' extension not available");if(t.multiDraw)if(e.multiDraw)n.push("#extension GL_ANGLE_multi_draw : require"),n.push("#define enabledMultiDraw");else if("required"===t.multiDraw)throw new Error("required 'GL_ANGLE_multi_draw' extension not available");return n.join("\n")+"\n"}(t,r.extensions),a=Wt(e)?function IGe(e,t,n,r){const i=["#version 300 es",`layout(location = 0) out highp ${r[0]||"vec4"} out_FragData0;`];if(n.fragDepth&&t.fragDepth&&i.push("#define enabledFragDepth"),n.drawBuffers&&t.drawBuffers){i.push("#define requiredDrawBuffers");for(let s=1,a=e.getParameter(e.MAX_DRAW_BUFFERS);s{const o=n[i];if("attribute"===o.type){const s=e.getAttribLocation(t,i);r[i]=s}else if("uniform"===o.type){let s=e.getUniformLocation(t,i);null===s&&function PGe(e){return e.endsWith("[]")}(o.kind)&&(s=e.getUniformLocation(t,i+"[0]")),r[i]=s}else if("texture"===o.type){const s=e.getUniformLocation(t,i);r[i]=s}}),r}(e,c,a),m=function jGe(e){const t={};return Object.keys(e).forEach(n=>{const r=e[n];"uniform"===r.type?t[n]=Ire(r.kind):"texture"===r.type&&(t[n]=Ire("t"))}),t}(a),un&&(function t9e(e,t,n){const r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i{t.currentProgramId=u,e.useProgram(c)},setUniforms:y=>{for(let b=0,x=y.length;b{const x=p[y];null!==x&&m[y](e,x,b)},bindAttributes:y=>{t.clearVertexAttribsState();for(let b=0,x=y.length;b{for(let x=0,_=y.length;x<_;++x){const[S,A]=y[x],E=p[S];-1!==E&&A.changeOffset(E,b)}},bindTextures:(y,b)=>{for(let x=0,_=y.length;x<_;++x){const[S,A]=y[x],E=p[S];null!=E&&(A.bind(x+b),m[S](e,E,x+b))}},reset:()=>{c=YL(e),h()},destroy:()=>{g||(d.destroy(),f.destroy(),e.deleteProgram(c),g=!0)}}}const o9e=pa();function yD(e,t){const{type:n,source:r}=t,i=e.createShader("vert"===n?e.VERTEX_SHADER:e.FRAGMENT_SHADER);if(null===i)throw new Error(`Error creating ${n} shader`);if(e.shaderSource(i,r),e.compileShader(i),un&&!1===e.getShaderParameter(i,e.COMPILE_STATUS))throw console.warn(`'${n}' shader info log '${e.getShaderInfoLog(i)}'\n${function s9e(e){const t=e.split("\n");for(let n=0;n{const o=e(i);let s=r.get(o);return s||(s=function c9e(e,t=0){return{value:e,usageCount:t}}(t(i)),r.set(o,s)),s.usageCount+=1,function u9e(e){return{free:()=>{e.usageCount-=1},value:e.value}}(s)},clear:()=>{r.forEach((i,o)=>{i.usageCount<=0&&(i.usageCount<0&&console.warn("Reference usageCount below zero."),n(i.value),r.delete(o))})},get count(){return r.size},dispose:()=>{r.forEach(i=>n(i.value)),r.clear()}}}const l9e=pa();function Ere(e){const t=e.createRenderbuffer();if(null===t)throw new Error("Could not create WebGL renderbuffer");return t}const h9e=pa();function Pre(e){const{vertexArrayObject:t}=e;if(!t)throw new Error("VertexArrayObject not supported");const n=t.createVertexArray();if(!n)throw new Error("Could not create WebGL vertex array");return n}function Mre(e){const{vertexArrayObject:t}=e;if(null===t)throw new Error("VertexArrayObject not supported");return t}function Rre(e){return{...e.value,destroy:()=>{e.free()}}}function y9e(e,t,n,r){const i={attribute:new Set,elements:new Set,framebuffer:new Set,program:new Set,renderbuffer:new Set,shader:new Set,texture:new Set,cubeTexture:new Set,vertexArray:new Set};function o(u,l){return i[u].add(l),n.resourceCounts[u]+=1,{...l,destroy:()=>{l.destroy(),i[u].delete(l),n.resourceCounts[u]-=1}}}const s=Dre(u=>JSON.stringify(u),u=>o("shader",function a9e(e,t){let n=yD(e,t);return{id:o9e(),attach:r=>{e.attachShader(r,n)},reset:()=>{n=yD(e,t)},destroy:()=>{e.deleteShader(n)}}}(e,u)),u=>{u.destroy()});function a(u,l){return Rre(s.get({type:u,source:l}))}const c=Dre(u=>{var l;const d=[u.shaderCode.id],f=(null===(l=u.defineValues.dRenderVariant)||void 0===l?void 0:l.ref.value)||"";return Object.keys(u.defineValues).forEach(p=>{var m,h;null!==(h=(m=u.shaderCode).ignoreDefine)&&void 0!==h&&h.call(m,p,f,u.defineValues)||d.push(cB(p),function g9e(e){return"boolean"==typeof e?e?1:0:"number"==typeof e?1e4*e:cB(e)}(u.defineValues[p].ref.value))}),ha(d).toString()},u=>o("program",i9e(e,t,r,a,u)),u=>{u.destroy()});return{attribute:(u,l,d,f)=>o("attribute",function KGe(e,t,n,r,i,o,s="static"){const{instancedArrays:a}=n,c=Tre(e,r,s,"attribute"),{_bufferType:u,_dataType:l,_bpe:d}=c;return{...c,divisor:o,bind:f=>{if(e.bindBuffer(u,c.getBuffer()),16===i)for(let p=0;p<4;++p)t.enableVertexAttrib(f+p),e.vertexAttribPointer(f+p,4,l,!1,16*d,4*p*d),a.vertexAttribDivisor(f+p,o);else t.enableVertexAttrib(f),e.vertexAttribPointer(f,i,l,!1,0,0),a.vertexAttribDivisor(f,o)},changeOffset:(f,p)=>{const m=p*d*i;if(e.bindBuffer(u,c.getBuffer()),16===i)for(let h=0;h<4;++h)e.vertexAttribPointer(f+h,4,l,!1,16*d,4*h*d+m);else e.vertexAttribPointer(f,i,l,!1,0,m)}}}(e,t,r,u,l,d,f)),elements:(u,l)=>o("elements",function QGe(e,t,n="static"){const r=Tre(e,t,n,"elements");return{...r,bind:()=>{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r.getBuffer())}}}(e,u,l)),framebuffer:()=>o("framebuffer",function a7e(e){let t=vre(e),n=!1;return{id:bre(),bind:()=>e.bindFramebuffer(e.FRAMEBUFFER,t),reset:()=>{t=vre(e)},destroy:()=>{n||(e.deleteFramebuffer(t),n=!0)}}}(e)),program:(u,l,d)=>Rre(c.get({defineValues:u,shaderCode:l,schema:d})),renderbuffer:(u,l,d,f)=>o("renderbuffer",function p9e(e,t,n,r,i){let o=Ere(e);const s=()=>e.bindRenderbuffer(e.RENDERBUFFER,o),a=function d9e(e,t){switch(t){case"depth16":return e.DEPTH_COMPONENT16;case"stencil8":return e.STENCIL_INDEX8;case"rgba4":return e.RGBA4;case"depth-stencil":return e.DEPTH_STENCIL;case"depth24":if(Wt(e))return e.DEPTH_COMPONENT24;throw new Error("WebGL2 needed for `depth24` renderbuffer format");case"depth32f":if(Wt(e))return e.DEPTH_COMPONENT32F;throw new Error("WebGL2 needed for `depth32f` renderbuffer format");case"depth24-stencil8":if(Wt(e))return e.DEPTH24_STENCIL8;throw new Error("WebGL2 needed for `depth24-stencil8` renderbuffer format");case"depth32f-stencil8":if(Wt(e))return e.DEPTH32F_STENCIL8;throw new Error("WebGL2 needed for `depth32f-stencil8` renderbuffer format")}}(e,t),c=function f9e(e,t){switch(t){case"depth":return e.DEPTH_ATTACHMENT;case"stencil":return e.STENCIL_ATTACHMENT;case"depth-stencil":return e.DEPTH_STENCIL_ATTACHMENT;case"color0":return e.COLOR_ATTACHMENT0}}(e,n);function u(){s(),e.renderbufferStorage(e.RENDERBUFFER,a,r,i)}u();let l=!1;return{id:l9e(),bind:s,attachFramebuffer:d=>{d.bind(),s(),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,o),un&&mD(e)},detachFramebuffer:d=>{d.bind(),s(),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,null),un&&mD(e)},setSize:(d,f)=>{r=d,i=f,u()},reset:()=>{o=Ere(e),u()},destroy:()=>{l||(e.deleteRenderbuffer(o),l=!0)}}}(e,u,l,d,f)),shader:a,texture:(u,l,d,f)=>o("texture",function mje(e,t,n,r,i,o){const s=KL();let a=Xre(e);if(n.endsWith("float32")&&"float"!==i||n.endsWith("float16")&&"fp16"!==i||n.endsWith("uint8")&&"ubyte"!==i||n.endsWith("int32")&&"int"!==i||n.endsWith("depth")&&"ushort"!==i&&"float"!==i)throw new Error(`texture kind '${n}' and type '${i}' are incompatible`);if(!t.depthTexture&&"depth"===r)throw new Error("extension 'WEBGL_depth_texture' needed for 'depth' texture format");const c=function uje(e,t){switch(t){case"image-uint8":case"image-float32":case"image-float16":case"image-depth":return e.TEXTURE_2D}if(Wt(e))switch(t){case"image-int32":return e.TEXTURE_2D;case"volume-uint8":case"volume-float32":case"volume-float16":return e.TEXTURE_3D}throw new Error(`unknown texture kind '${t}'`)}(e,n),u=Wre(e,o),l=Hre(e,r,i),d=function lje(e,t,n){if(Wt(e))switch(t){case"alpha":switch(n){case"ubyte":return e.ALPHA;case"float":return e.R32F;case"fp16":return e.R16F;case"int":return e.R32I}case"rg":switch(n){case"ubyte":return e.RG;case"float":return e.RG32F;case"fp16":return e.RG16F;case"int":return e.RG32I}case"rgb":switch(n){case"ubyte":return e.RGB;case"float":return e.RGB32F;case"fp16":return e.RGB16F;case"int":return e.RGB32I}case"rgba":switch(n){case"ubyte":return e.RGBA;case"float":return e.RGBA32F;case"fp16":return e.RGBA16F;case"int":return e.RGBA32I}case"depth":switch(n){case"ushort":return e.DEPTH_COMPONENT16;case"float":return e.DEPTH_COMPONENT32F}}return Hre(e,t,n)}(e,r,i),f=function pje(e,t,n){switch(n){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(Wt(e))return e.INT;throw new Error('texture type "int" requires webgl2')}}(e,t,i);function p(){e.bindTexture(c,a),e.texParameteri(c,e.TEXTURE_MAG_FILTER,u),e.texParameteri(c,e.TEXTURE_MIN_FILTER,u),e.texParameteri(c,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(c,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(c,null)}p();let y,m=0,h=0,g=0,b=!1,x=!1;function _(w,D,I){if(0===w||0===D||Wt(e)&&c===e.TEXTURE_3D&&0===I)throw new Error("empty textures are not allowed");if(m!==w||h!==D||g!==(I||0))if(m=w,h=D,g=I||0,e.bindTexture(c,a),c===e.TEXTURE_2D)e.texImage2D(c,0,d,m,h,0,l,f,null);else{if(!Wt(e)||c!==e.TEXTURE_3D||void 0===g)throw new Error("unknown texture target");e.texImage3D(c,0,d,m,h,g,0,l,f,null)}}function S(w,D=!1){if(0===w.width||0===w.height||!$re(w)&&Wt(e)&&Yre(0,c,e)&&0===w.depth)throw new Error("empty textures are not allowed");if(e.bindTexture(c,a),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),$re(w))m=w.width,h=w.height,e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.bindTexture(e.TEXTURE_2D,a),e.texImage2D(e.TEXTURE_2D,0,d,l,f,w);else if(function hje(e,t,n){return t===n.TEXTURE_2D}(0,c,e)){const I=w.filter?Wre(e,w.filter):u;e.texParameteri(c,e.TEXTURE_MAG_FILTER,I),e.texParameteri(c,e.TEXTURE_MIN_FILTER,I),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!!w.flipY),D?e.texSubImage2D(c,0,0,0,w.width,w.height,l,f,w.array):(m=w.width,h=w.height,e.texImage2D(c,0,d,m,h,0,l,f,w.array))}else{if(!Wt(e)||!Yre(0,c,e))throw new Error("unknown texture target");e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),D?e.texSubImage3D(c,0,0,0,0,w.width,w.height,w.depth,l,f,w.array):(m=w.width,h=w.height,g=w.depth,e.texImage3D(c,0,d,m,h,g,0,l,f,w.array))}e.bindTexture(c,null),y=w}function A(){if(c!==e.TEXTURE_2D)throw new Error("mipmap only supported for 2d textures");if(!(Wt(e)||$x(m)&&$x(h)))throw new Error("mipmap unsupported for non-power-of-two textures and webgl1");e.bindTexture(c,a),e.texParameteri(c,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.generateMipmap(c),e.bindTexture(c,null),b=!0}return _(1,1,Wt(e)&&c===e.TEXTURE_3D?1:0),{id:s,target:c,format:l,internalFormat:d,type:f,filter:u,getWidth:()=>m,getHeight:()=>h,getDepth:()=>g,getByteCount:()=>qre(r,i,m,h,g),define:_,load:S,mipmap:A,bind:w=>{e.activeTexture(e.TEXTURE0+w),e.bindTexture(c,a)},unbind:w=>{e.activeTexture(e.TEXTURE0+w),e.bindTexture(c,null)},attachFramebuffer:function E(w,D,I){if(w.bind(),c===e.TEXTURE_2D)e.framebufferTexture2D(e.FRAMEBUFFER,vD(e,t,D),e.TEXTURE_2D,a,0);else{if(!Wt(e)||c!==e.TEXTURE_3D)throw new Error("unknown/unsupported texture target");if(void 0===I)throw new Error("need `layer` to attach 3D texture");e.framebufferTextureLayer(e.FRAMEBUFFER,vD(e,t,D),a,0,I)}},detachFramebuffer:(w,D)=>{if(w.bind(),c===e.TEXTURE_2D)e.framebufferTexture2D(e.FRAMEBUFFER,vD(e,t,D),e.TEXTURE_2D,null,0);else{if(!Wt(e)||c!==e.TEXTURE_3D)throw new Error("unknown texture target");e.framebufferTextureLayer(e.FRAMEBUFFER,vD(e,t,D),null,0,0)}},reset:()=>{a=Xre(e),p();const[w,D,I]=[m,h,g];m=0,h=0,g=0,_(w,D,I),y&&S(y),b&&A()},destroy:()=>{x||(e.deleteTexture(a),x=!0)}}}(e,r,u,l,d,f)),cubeTexture:(u,l,d)=>o("cubeTexture",function yje(e,t,n,r){const i=e.TEXTURE_CUBE_MAP,o=e.LINEAR,s=e.RGBA,a=e.RGBA,c=e.UNSIGNED_BYTE;let u=0;const l=e.createTexture();e.bindTexture(i,l);let d=0;$a(t,(p,m)=>{if(!p)return;const g=function gje(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}}(e,m),y=new Image;p instanceof File?y.src=URL.createObjectURL(p):FI(p)?p.then(b=>{y.src=URL.createObjectURL(b)}):y.src=p,y.addEventListener("load",()=>{0===u&&(u=y.width),e.texImage2D(g,0,s,u,u,0,a,c,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(i,l),e.texImage2D(g,0,s,a,c,y),d+=1,6===d&&(f||(n?(e.texParameteri(i,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.generateMipmap(i)):e.texParameteri(i,e.TEXTURE_MIN_FILTER,o),e.texParameteri(i,e.TEXTURE_MAG_FILTER,o)),r?.(f))}),y.addEventListener("error",()=>{r?.(!0)})});let f=!1;return{id:KL(),target:i,format:a,internalFormat:s,type:c,filter:o,getWidth:()=>u,getHeight:()=>u,getDepth:()=>0,getByteCount:()=>6*qre("rgba","ubyte",u,u,0)*(n?2:1),define:()=>{},load:()=>{},mipmap:()=>{},bind:p=>{e.activeTexture(e.TEXTURE0+p),e.bindTexture(i,l)},unbind:p=>{e.activeTexture(e.TEXTURE0+p),e.bindTexture(i,null)},attachFramebuffer:()=>{},detachFramebuffer:()=>{},reset:()=>{},destroy:()=>{f||(e.deleteTexture(l),f=!0)}}}(e,u,l,d)),vertexArray:(u,l,d)=>o("vertexArray",function m9e(e,t,n,r,i){const o=h9e();let s=Pre(t),a=Mre(t);function c(){a.bindVertexArray(s),i&&i.bind(),n.bindAttributes(r),a.bindVertexArray(null)}c();let u=!1;return{id:o,bind:()=>{a.bindVertexArray(s)},update:c,reset:()=>{s=Pre(t),a=Mre(t),c()},destroy:()=>{u||(i&&(a.bindVertexArray(s),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),a.deleteVertexArray(s),u=!0)}}}(e,r,u,l,d)),getByteCounts:()=>{let u=0;i.texture.forEach(f=>{u+=f.getByteCount()}),i.cubeTexture.forEach(f=>{u+=f.getByteCount()});let l=0;i.attribute.forEach(f=>{l+=4*f.length});let d=0;return i.elements.forEach(f=>{d+=4*f.length}),{texture:u,attribute:l,elements:d}},reset:()=>{i.attribute.forEach(u=>u.reset()),i.elements.forEach(u=>u.reset()),i.framebuffer.forEach(u=>u.reset()),i.renderbuffer.forEach(u=>u.reset()),i.shader.forEach(u=>u.reset()),i.program.forEach(u=>u.reset()),i.vertexArray.forEach(u=>u.reset()),i.texture.forEach(u=>u.reset())},destroy:()=>{i.attribute.forEach(u=>u.destroy()),i.elements.forEach(u=>u.destroy()),i.framebuffer.forEach(u=>u.destroy()),i.renderbuffer.forEach(u=>u.destroy()),i.shader.forEach(u=>u.destroy()),i.program.forEach(u=>u.destroy()),i.vertexArray.forEach(u=>u.destroy()),i.texture.forEach(u=>u.destroy()),s.clear(),c.clear()}}}const kre=pa();class Nre{add(t,n){let r=this.avgs.get(t)||n;return r=function _9e(e,t,n){return(e-=e/n)+t/n}(r,n,this.count),this.avgs.set(t,r),r}get(t){return this.avgs.get(t)}stats(){return Object.fromEntries(this.avgs.entries())}constructor(t){this.count=t,this.avgs=new Map}}function Fre(e){e.map(t=>{const n=function w9e(e){const t=`${(e.gpuElapsed/1e3/1e3).toFixed(2)}`,n=`${(e.gpuAvg/1e3/1e3).toFixed(2)}`,r=`${e.cpuElapsed.toFixed(2)}`,i=`${e.cpuAvg.toFixed(2)}`;return`${e.label} ${t} ms (avg. ${n} ms) | CPU: ${r} ms (avg. ${i} ms)`}(t);t.children.length||t.calls?(console.groupCollapsed(n),t.calls&&console.log(t.calls),Fre(t.children),console.groupEnd()):console.log(n)})}function Bre(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 Ore(e){const t=e.getError();if(t!==e.NO_ERROR)throw new Error(`WebGL error: '${Bre(e,t)}'`)}function bD(e){e.bindFramebuffer(e.FRAMEBUFFER,null)}const Lre=new Uint8Array(4);function Ure(e,t,n){e.getSyncParameter(t,e.SYNC_STATUS)===e.SIGNALED?(e.deleteSync(t),n()):Zx.setImmediate(Ure,e,t,n)}function Vre(e,t){const n=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);n?Zx.setImmediate(Ure,e,n,t):(console.warn("Could not create a WebGLSync object"),e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,Lre),t())}let zre=!1;function Gre(e){e.bindFramebuffer(e.FRAMEBUFFER,null),e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,Lre)}function XL(e,t,n,r,i,o){if(un&&mD(e),o instanceof Uint8Array)e.readPixels(t,n,r,i,e.RGBA,e.UNSIGNED_BYTE,o);else if(o instanceof Float32Array)e.readPixels(t,n,r,i,e.RGBA,e.FLOAT,o);else{if(!(o instanceof Int32Array&&Wt(e)))throw new Error("unsupported readPixels buffer type");e.readPixels(t,n,r,i,e.RGBA_INTEGER,e.INT,o)}un&&Ore(e)}function Wt(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext}const sje="\nattribute vec4 aPosition;\n\nvoid main() {\n gl_Position = aPosition;\n}",aje="\nprecision mediump float;\nuniform vec4 uColor;\nuniform sampler2D uTexture;\n\nvoid main() {\n gl_FragColor = texture2D(uTexture, vec2(0.5, 0.5)) * uColor;\n}",cje=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function jre(e,t){const n=yD(e,{type:"vert",source:sje}),r=yD(e,{type:"frag",source:aje});if(!n||!r)return!1;const i=YL(e);e.attachShader(i,n),e.attachShader(i,r),e.linkProgram(i),e.useProgram(i);const o=e.getAttribLocation(i,"aPosition"),s=e.getUniformLocation(i,"uColor");if(!s)return un&&console.log("error getting 'uColor' uniform location"),!1;const a=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,cje,e.STATIC_DRAW),e.enableVertexAttribArray(o),e.vertexAttribPointer(o,2,e.FLOAT,!1,0,0);const c=e.createTexture(),u=new Uint8Array([255,255,255,255]);e.bindTexture(e.TEXTURE_2D,c),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,u);const 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);const d=e.createFramebuffer();if(e.bindFramebuffer(e.FRAMEBUFFER,d),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l,0),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE)return un&&console.log(`error creating framebuffer for '${t}'`),!1;e.bindTexture(e.TEXTURE_2D,c),e.uniform4fv(s,[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(s,[0,.1,.05,1]),e.drawArrays(e.TRIANGLES,0,6);const p=new Uint8Array(4);if(e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,p),0!==p[0]||p[1]<248||p[2]<248||p[3]<254)return un&&console.log(`not able to actually render to '${t}' texture`),!1;if(t===e.FLOAT){e.bindFramebuffer(e.FRAMEBUFFER,d);const m=new Float32Array(4);e.readPixels(0,0,1,1,e.RGBA,e.FLOAT,m);const h=e.getError();if(h)return un&&console.log(`error reading float pixels: '${Bre(e,h)}'`),!1}return!0}const KL=pa();function Hre(e,t,n){switch(t){case"alpha":return Wt(e)&&"float"===n?e.RED:Wt(e)&&"int"===n?e.RED_INTEGER:e.ALPHA;case"rgb":return Wt(e)&&"int"===n?e.RGB_INTEGER:e.RGB;case"rg":if(Wt(e)&&"float"===n)return e.RG;if(Wt(e)&&"int"===n)return e.RG_INTEGER;throw new Error('texture format "rg" requires webgl2 and type "float" or int"');case"rgba":return Wt(e)&&"int"===n?e.RGBA_INTEGER:e.RGBA;case"depth":return e.DEPTH_COMPONENT}}function qre(e,t,n,r,i){return function dje(e){switch(e){case"alpha":return 1;case"rg":return 2;case"rgb":return 3;case"rgba":case"depth":return 4}}(e)*function fje(e){switch(e){case"ubyte":return 1;case"ushort":case"fp16":return 2;case"float":case"int":return 4}}(t)*n*r*(i||1)}function Wre(e,t){switch(t){case"nearest":return e.NEAREST;case"linear":return e.LINEAR}}function vD(e,t,n){switch(n){case"depth":return e.DEPTH_ATTACHMENT;case"stencil":return e.STENCIL_ATTACHMENT;case"color0":case 0:return e.COLOR_ATTACHMENT0}if(t.drawBuffers)switch(n){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 $re(e){return typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement}function Yre(e,t,n){return t===n.TEXTURE_3D}function Xre(e){const t=e.createTexture();if(null===t)throw new Error("Could not create WebGL texture");return t}function Kre(e,t,n){const{resources:r}=e,i=[];return Object.keys(t).forEach(o=>{const s=t[o];if("texture"===s.type){const a=n[o];if(a)if("texture"===s.kind)i[i.length]=[o,a.ref.value];else{const c=r.texture(s.kind,s.format,s.dataType,s.filter);c.load(a.ref.value),i[i.length]=[o,c]}}}),i}function Zre(e,t,n){const r=new Image;r.onload=function(){n.load(r),k.update(t,n)},r.src=e}const Qre=-1;function Os(e){var t;const n=null!==(t=e?.TEXTURE_2D)&&void 0!==t?t:3553;return{id:KL(),target:n,format:Qre,internalFormat:0,type:0,filter:0,getWidth:()=>0,getHeight:()=>0,getDepth:()=>0,getByteCount:()=>0,define:()=>{},load:()=>{},mipmap:()=>{},bind:r=>{e&&(e.activeTexture(e.TEXTURE0+r),e.bindTexture(n,null))},unbind:r=>{e&&(e.activeTexture(e.TEXTURE0+r),e.bindTexture(n,null))},attachFramebuffer:()=>{throw new Error("cannot attach null-texture to a framebuffer")},detachFramebuffer:()=>{throw new Error("cannot detach null-texture from a framebuffer")},reset:()=>{},destroy:()=>{}}}function bu(e,t,n,r){const i=function vje(e,t,n,r){switch(n.granularity){case"uniform":return function Sje(e,t,n){return function xje(e,t){return t?(k.update(t.uColor,st.toVec3Normalized(t.uColor.ref.value,e)),k.updateIfChanged(t.dColorType,"uniform"),t):{uColor:k.create(st.toVec3Normalized(v(),e)),tColor:k.create({array:new Uint8Array(3),width:1,height:1}),tColorGrid:k.create(Os()),tPalette:k.create({array:new Uint8Array(3),width:1,height:1}),uColorTexDim:k.create(Me.create(1,1)),uColorGridDim:k.create(v.create(1,1,1)),uColorGridTransform:k.create(nn.create(0,0,0,1)),dColorType:k.create("uniform"),dUsePalette:k.create(!1)}}(t(rc,!1),n)}(0,n.color,r);case"instance":return e.nonInstanceable?Jre(e,n.color,r):function Cje(e,t,n){const{instanceCount:r}=e,i=Po(Math.max(1,r),3,Uint8Array,n&&n.tColor.ref.value.array);for(e.reset();e.hasNext;){const{location:o,isSecondary:s,instanceIndex:a}=e.move();st.toArray(t(o,s),i.array,3*a),e.skipInstance()}return dS(i,"instance",n)}(e,n.color,r);case"group":return Jre(e,n.color,r);case"groupInstance":return function wje(e,t,n){const{groupCount:r,instanceCount:i,hasLocation2:o}=e,a=Po(Math.max(1,i*r*(o?2:1)),3,Uint8Array,n&&n.tColor.ref.value.array);e.reset();const c=o?6:3;for(;e.hasNext;){const{location:u,location2:l,isSecondary:d,index:f}=e.move();st.toArray(t(u,d),a.array,f*c),o&&st.toArray(t(l,d),a.array,f*c+3)}return dS(a,"groupInstance",n)}(e,n.color,r);case"vertex":return function Aje(e,t,n){const{groupCount:r,stride:i}=e,o=Po(Math.max(1,r),3,Uint8Array,n&&n.tColor.ref.value.array);for(e.reset(),e.voidInstances();e.hasNext&&!e.isNextNewInstance;){const{location:s,isSecondary:a,groupIndex:c}=e.move(),u=t(s,a);for(let l=0;l=16*t?o.transform.ref.value:new Float32Array(16*t);a.set(e),k.update(o.transform,a),k.updateIfChanged(o.uInstanceCount,t),k.updateIfChanged(o.instanceCount,t);const c=o.aTransform.ref.value.length>=16*t?o.aTransform.ref.value:new Float32Array(16*t);k.update(o.aTransform,c);const u=o.extraTransform.ref.value.length>=16*t?o.extraTransform.ref.value:new Float32Array(16*t);k.update(o.extraTransform,xD(u,t));const l=o.aInstance.ref.value.length>=t?o.aInstance.ref.value:new Float32Array(t);k.update(o.aInstance,Tc(l,t)),k.update(o.hasReflection,s)}else o={aTransform:k.create(new Float32Array(16*t)),matrix:k.create(le.identity()),transform:k.create(new Float32Array(e)),extraTransform:k.create(xD(new Float32Array(16*t),t)),uInstanceCount:k.create(t),instanceCount:k.create(t),aInstance:k.create(Tc(new Float32Array(t))),hasReflection:k.create(s),instanceGrid:k.create({cellSize:0,cellCount:0,cellOffsets:new Uint32Array,cellSpheres:new Float32Array,cellTransform:new Float32Array,cellInstance:new Float32Array,batchSize:0,batchCount:0,batchOffsets:new Uint32Array,batchSpheres:new Float32Array,batchCell:new Uint32Array})};return nie(o,n,r,i),o}const JL=new Float32Array(16);function e5(e){return QL(new Float32Array(JL),1,void 0,0,0,e)}function xD(e,t){for(let n=0;n0){const l=function Pje(e,t,n){const r=function Mje(e,t){const{instanceCount:n,instance:r,transform:i,invariantBoundingSphere:o}=e,s=new Float32Array(n),a=new Float32Array(n),c=new Float32Array(n),u=Fe.ofBounds(0,n),l=St.setEmpty(St()),{center:d,radius:f}=o,p=v.create(f,f,f),m=v();for(let M=0;Mn,props:t,description:Fje,legend:$h([["uniform",n]])}}const Oje={name:"uniform",label:"Uniform",category:ni.Misc,factory:f0,getParams:function Bje(e){return yv},defaultValues:C.getDefaultValues(yv),isApplicable:e=>!0},iie={value:C.Numeric(1,{min:0,max:20,step:.1})};function t5(e,t){const n=t.value;return{factory:t5,granularity:"uniform",size:()=>n,props:t,description:"Gives everything the same, uniform size."}}const Vje={name:"uniform",label:"Uniform",category:"",factory:t5,getParams:function Uje(e){return iie},defaultValues:C.getDefaultValues(iie),isApplicable:e=>!0};function ba(e){return{...ba.Zero,...e}}function gm(){}!function(e){e.Zero={metalness:0,roughness:0,bumpiness:0},e.toArray=function t(i,o,s){return o[s]=255*i.metalness,o[s+1]=255*i.roughness,o[s+2]=255*i.bumpiness,o},e.toString=function n({metalness:i,roughness:o,bumpiness:s}){return`M ${i.toFixed(2)} | R ${o.toFixed(2)} | B ${s.toFixed(2)}`},e.getParam=function r(i){return C.Group({metalness:C.Numeric(0,{min:0,max:1,step:.01}),roughness:C.Numeric(1,{min:0,max:1,step:.01}),bumpiness:C.Numeric(0,{min:0,max:1,step:.01})},{...i,presets:[[{metalness:0,roughness:1,bumpiness:0},"Matte"],[{metalness:0,roughness:.2,bumpiness:0},"Plastic"],[{metalness:0,roughness:.6,bumpiness:0},"Glossy"],[{metalness:1,roughness:.6,bumpiness:0},"Metallic"]]})}}(ba||(ba={})),function(e){e.Type={none:0,plane:1,sphere:2,cube:3,cylinder:4,infiniteCone:5},e.Params={variant:C.Select("pixel",C.arrayToOptions(["instance","pixel"])),objects:C.ObjectList({type:C.Select("plane",C.objectToOptions(e.Type,c=>zu(c))),invert:C.Boolean(!1),position:C.Vec3(v()),rotation:C.Group({axis:C.Vec3(v.create(1,0,0)),angle:C.Numeric(0,{min:-180,max:180,step:1},{description:"Angle in Degrees"})},{isExpanded:!0}),scale:C.Vec3(v.create(1,1,1))},c=>zu(c.type))};const n=_r(),r=_r(),i=v(),o=v();e.getClip=function s(c,u){const l=c.objects.length,{type:d,invert:f,position:p,rotation:m,scale:h}=u?.objects||function t(c){return{count:0,type:new Array(c).fill(1),invert:new Array(c).fill(!1),position:new Array(3*c).fill(0),rotation:new Array(4*c).fill(0),scale:new Array(3*c).fill(1)}}(l);for(let g=0;g1.2&&(r=2)),{resolution:n,stride:r}}}var rt;function Gje(e,t,n,r){for(let i=t;itypeof s.quality<"u"&&"custom"!==s.quality},e.Params={alpha:C.Numeric(1,{min:0,max:1,step:.01},{label:"Opacity",isEssential:!0,description:"How opaque/transparent the representation is rendered."}),quality:C.Select("auto",n5,{isEssential:!0,description:"Visual/rendering quality of the representation."}),material:ba.getParam(),clip:C.Group(gm.Params),instanceGranularity:C.Boolean(!1,{description:"Use instance granularity for marker, transparency, clipping, overpaint, substance data to save memory."}),lod:C.Vec3(v(),void 0,{...e.CullingLodCategory,description:"Level of detail.",fieldLabels:{x:"Min Distance",y:"Max Distance",z:"Overlap (Shader)"}}),cellSize:C.Numeric(200,{min:0,max:5e3,step:100},{...e.CullingLodCategory,description:"Instance grid cell size."}),batchSize:C.Numeric(2e3,{min:0,max:5e4,step:500},{...e.CullingLodCategory,description:"Instance grid batch size."})},e.createSimple=function t(s=xn.grey,a=1,c){return c||(c=e5()),{transform:c,locationIterator:Mr(1,c.instanceCount.ref.value,1,()=>rc,!1,()=>!1),theme:{color:f0(0,{value:s,lightness:0,saturation:0}),size:t5(0,{value:a})}}},e.createValues=function n(s,a){const c=gm.getClip(s.clip);return{alpha:k.create(s.alpha),uAlpha:k.create(s.alpha),uVertexCount:k.create(a.vertexCount),uGroupCount:k.create(a.groupCount),drawCount:k.create(a.drawCount),uMetalness:k.create(s.material.metalness),uRoughness:k.create(s.material.roughness),uBumpiness:k.create(s.material.bumpiness),dLightCount:k.create(1),dColorMarker:k.create(!0),dClipObjectCount:k.create(c.objects.count),dClipVariant:k.create(c.variant),uClipObjectType:k.create(c.objects.type),uClipObjectInvert:k.create(c.objects.invert),uClipObjectPosition:k.create(c.objects.position),uClipObjectRotation:k.create(c.objects.rotation),uClipObjectScale:k.create(c.objects.scale),instanceGranularity:k.create(s.instanceGranularity),uLod:k.create(nn.create(s.lod[0],s.lod[1],s.lod[2],0))}},e.updateValues=function r(s,a){k.updateIfChanged(s.alpha,a.alpha),k.updateIfChanged(s.uMetalness,a.material.metalness),k.updateIfChanged(s.uRoughness,a.material.roughness),k.updateIfChanged(s.uBumpiness,a.material.bumpiness);const c=gm.getClip(a.clip);k.updateIfChanged(s.dClipObjectCount,c.objects.count),k.updateIfChanged(s.dClipVariant,c.variant),k.update(s.uClipObjectType,c.objects.type),k.update(s.uClipObjectInvert,c.objects.invert),k.update(s.uClipObjectPosition,c.objects.position),k.update(s.uClipObjectRotation,c.objects.rotation),k.update(s.uClipObjectScale,c.objects.scale),k.updateIfChanged(s.instanceGranularity,a.instanceGranularity),k.update(s.uLod,nn.set(s.uLod.ref.value,a.lod[0],a.lod[1],a.lod[2],0))},e.createRenderableState=function i(s={}){const a=void 0===s.alpha||1===s.alpha;return{disposed:!1,visible:!0,alphaFactor:1,pickable:!0,colorOnly:!1,opaque:a,writeDepth:a}},e.updateRenderableState=function o(s,a){s.opaque=a.alpha*s.alphaFactor>=1,s.writeDepth=s.opaque}}(rt||(rt={}));const aie={array:new Uint8Array(4),width:1,height:1};function Dp(e){return e?(k.update(e.tOverpaint,aie),k.update(e.uOverpaintTexDim,Me.create(1,1)),e):{tOverpaint:k.create(aie),uOverpaintTexDim:k.create(Me.create(1,1)),dOverpaint:k.create(!1),tOverpaintGrid:k.create(Os()),uOverpaintGridDim:k.create(v.create(1,1,1)),uOverpaintGridTransform:k.create(nn.create(0,0,0,1)),dOverpaintType:k.create("groupInstance"),uOverpaintStrength:k.create(1)}}function Hje(e,t,n,r){for(let i=t;i=3*T?R.normalBuffer.ref.value:new Float32Array(3*T);F===R.normalBuffer.ref.value&&F.fill(0,0,3*T),dre(N,V,F,T,M),k.update(R.normalBuffer,F)},e.checkForDuplicateVertices=function a(R,T=3){const M=R.vertexBuffer.ref.value,N=new Map,V=(L,z)=>`${L[0].toFixed(z)}|${L[1].toFixed(z)}|${L[2].toFixed(z)}`;let F=0;const G=v();for(let L=0,z=R.vertexCount;L{const L=t2(F,G),z=N.get(L)||0;N.set(L,z+1)};for(let F=0;F{1===N&&(XZ(M,V),T.add(M[0]),T.add(M[1]))}),T}function h(R,T,M){const N=new Map,V=(F,G)=>{N.has(F)?eo(N.get(F),G):N.set(F,[G])};return T.forEach(F=>{const G=R[F];for(const L of G)T.has(L)&&1===M.get(t2(F,L))&&V(F,L)}),N}function y(R,T,M,N){var V;const{vertexBuffer:F,indexBuffer:G,normalBuffer:L,triangleCount:z}=R,j=F.ref.value,Z=G.ref.value,$=L.ref.value,ee=ze.create(Uint32Array,3,1024,z);let q=0;for(let de=0;deM.get(de).length<2).map(de=>{const we=M.get(de);return v.fromArray(O,j,3*de),v.fromArray(H,j,3*we[0]),v.fromArray(W,j,3*we[1]),v.sub(fe,H,O),v.sub(X,W,O),[de,v.angle(fe,X)]});K.sort(([,de],[,we])=>de-we);for(const[de,we]of K){if(oe.has(de)||we>me)continue;const Le=M.get(de);if(T[Le[0]].includes(Le[1])&&(null===(V=M.get(Le[0]))||void 0===V||!V.includes(Le[1]))||(v.fromArray(O,j,3*de),v.fromArray(H,j,3*Le[0]),v.fromArray(W,j,3*Le[1]),v.sub(fe,H,O),v.sub(X,W,O),v.add(ce,fe,X),v.squaredDistance(O,H)>=N))continue;let We=!1;for(const U of T[de])if(!Le.includes(U)&&(v.fromArray(Q,j,3*U),v.sub(J,Q,O),v.dot(ce,J)<0)){We=!0;break}We&&(v.fromArray(be,$,3*de),v.triangleNormal(ae,O,H,W),v.dot(ae,be)>0?ze.add3(ee,de,Le[0],Le[1]):ze.add3(ee,Le[1],Le[0],de),oe.add(de),oe.add(Le[0]),oe.add(Le[1]),q+=1)}const ne=ze.compact(ee);return R.triangleCount=q,k.update(G,ne),R}function _(R,T){const M=R.vertexCount,N=T.instanceCount.ref.value,V=mm(),F=V.position,G=R.vertexBuffer.ref.value,L=T.aTransform.ref.value;return Mr(M,N,1,(j,Z)=>(Z<0?v.fromArray(F,G,3*j):v.transformMat4Offset(F,G,L,0,3*j,16*Z),V))}function S(R,T,M,N,V){const{instanceCount:F,groupCount:G}=M,z=bu(M,_(R,T),N.color),j=V.instanceGranularity?Vi(F,"instance"):Vi(F*G,"groupInstance"),Z=Dp(),$=Ep(),ee=Mp(),q=Pp(),O={drawCount:3*R.triangleCount,vertexCount:R.vertexCount,groupCount:G,instanceCount:F},H=_e.clone(R.boundingSphere),W=fs(H,T.aTransform.ref.value,F,0);return{dGeometryType:k.create("mesh"),aPosition:R.vertexBuffer,aNormal:R.normalBuffer,aGroup:R.groupBuffer,elements:R.indexBuffer,dVaryingGroup:R.varyingGroup,boundingSphere:k.create(W),invariantBoundingSphere:k.create(H),uInvariantBoundingSphere:k.create(nn.ofSphere(H)),...z,...j,...Z,...$,...ee,...q,...T,...rt.createValues(V,O),uDoubleSided:k.create(V.doubleSided),dFlatShaded:k.create(V.flatShaded),dFlipSided:k.create(V.flipSided),dIgnoreLight:k.create(V.ignoreLight),dXrayShaded:k.create("inverted"===V.xrayShaded?"inverted":!0===V.xrayShaded?"on":"off"),dTransparentBackfaces:k.create(V.transparentBackfaces),uBumpFrequency:k.create(V.bumpFrequency),uBumpAmplitude:k.create(V.bumpAmplitude),meta:k.create(R.meta)}}function I(R,T){rt.updateRenderableState(R,T),R.opaque=R.opaque&&!T.xrayShaded,R.writeDepth=R.opaque}e.transform=function u(R,T){const M=R.vertexBuffer.ref.value;l0(T,M,0,R.vertexCount),le.isTranslationAndUniformScaling(T)||function Qze(e,t,n,r){for(let i=0,o=3*r;i{const q=R.vertexBuffer.ref.value;Z.set(q),T.forEach((H,W)=>{if(2!==H.length)return;v.fromArray(F,q,3*W),v.fromArray(G,q,3*H[0]),v.fromArray(L,q,3*H[1]);const Q=1/v.distance(F,G),fe=1/v.distance(F,L);v.scale(G,G,Q),v.scale(L,L,fe),v.add(z,G,L),v.scale(z,z,1/(Q+fe)),v.sub(z,z,F),v.scale(z,z,ee),v.add(z,F,z),v.toArray(z,Z,3*W)});const O=R.vertexBuffer.ref.value;k.update(R.vertexBuffer,Z),Z=O};for(let ee=0;ee{v.toArray(a,n,o),v.toArray(c,n,o+3),v.toArray(u,n,o+6),v.triangleNormal(CD,a,c,u);for(let l=0;l<3;++l)v.toArray(CD,r,o+3*l),i[s+l]=o/3+l;o+=9,s+=3},addQuad:(a,c,u,l)=>{v.toArray(a,n,o),v.toArray(c,n,o+3),v.toArray(u,n,o+6),v.toArray(l,n,o+9),v.triangleNormal(CD,a,c,u);for(let f=0;f<4;++f)v.toArray(CD,r,o+3*f);const d=o/3;i[s]=d,i[s+1]=d+1,i[s+2]=d+2,i[s+3]=d+2,i[s+4]=d+3,i[s+5]=d,o+=12,s+=6},getPrimitive:()=>({vertices:n,normals:r,indices:i})}}const vv=v(),tHe=Kt();function r5(e,t){const{vertices:n,normals:r}=e,i=Kt.directionTransform(tHe,t);for(let o=0,s=n.length;o{t.push(r(i),r(o),r(s))}}}(),{vertices:s,indices:a}=o;(function u(d){const f=v(),p=v(),m=v();for(let h=0;h0&&y(!0),a&&n>0&&y(!1),{vertices:new Float32Array(d),normals:new Float32Array(f),indices:new Uint32Array(l)};function y(b){const x=!0===b?t:n,_=!0===b?1:-1,S=p;for(let E=1;E<=i;++E)d.push(0,h*_,0),f.push(0,_,0),++p;const A=p;for(let E=0;E<=i;++E){const D=E/i*u+c,I=Math.cos(D),R=Math.sin(D);d.push(x*R,h*_,x*I),f.push(0,_,0),++p}for(let E=0;E(w<0?v.fromArray(x,_,3*E):v.transformMat4Offset(x,_,S,0,3*E,16*w),b))}function c(m,h,g,y,b){const{instanceCount:x,groupCount:_}=g,A=bu(g,a(m,h),y.color),E=kp(g,y.size),w=b.instanceGranularity?Vi(x,"instance"):Vi(x*_,"groupInstance"),D=Dp(),I=Ep(),R=Mp(),T=Pp(),M={drawCount:m.pointCount,vertexCount:m.pointCount,groupCount:_,instanceCount:x},N=_e.clone(m.boundingSphere),V=fs(N,h.aTransform.ref.value,x,0);return{dGeometryType:k.create("points"),aPosition:m.centerBuffer,aGroup:m.groupBuffer,boundingSphere:k.create(V),invariantBoundingSphere:k.create(N),uInvariantBoundingSphere:k.create(nn.ofSphere(N)),...A,...E,...w,...D,...I,...R,...T,...h,...rt.createValues(b,M),uSizeFactor:k.create(b.sizeFactor),dPointSizeAttenuation:k.create(b.pointSizeAttenuation),dPointStyle:k.create(b.pointStyle)}}function p(m,h){rt.updateRenderableState(m,h),m.opaque=m.opaque&&"fuzzy"!==h.pointStyle,m.writeDepth=m.opaque}e.create=t,e.createEmpty=n,e.transform=function s(m,h){const g=m.centerBuffer.ref.value;l0(h,g,0,m.pointCount),k.update(m.centerBuffer,g)},e.StyleTypes={square:"Square",circle:"Circle",fuzzy:"Fuzzy"},e.StyleTypeNames=Object.keys(e.StyleTypes),e.Params={...rt.Params,sizeFactor:C.Numeric(3,{min:0,max:10,step:.1}),pointSizeAttenuation:C.Boolean(!1),pointStyle:C.Select("square",C.objectToOptions(e.StyleTypes))},e.Utils={Params:e.Params,createEmpty:n,createValues:c,createValuesSimple:function u(m,h,g,y,b){const x=rt.createSimple(g,y,b),_={...C.getDefaultValues(e.Params),...h};return c(m,x.transform,x.locationIterator,x.theme,_)},updateValues:function l(m,h){rt.updateValues(m,h),k.updateIfChanged(m.uSizeFactor,h.sizeFactor),k.updateIfChanged(m.dPointSizeAttenuation,h.pointSizeAttenuation),k.updateIfChanged(m.dPointStyle,h.pointStyle)},updateBoundingSphere:function d(m,h){const g=_e.clone(h.boundingSphere),y=fs(g,m.aTransform.ref.value,m.instanceCount.ref.value,0);_e.equals(y,m.boundingSphere.ref.value)||k.update(m.boundingSphere,y),_e.equals(g,m.invariantBoundingSphere.ref.value)||(k.update(m.invariantBoundingSphere,g),k.update(m.uInvariantBoundingSphere,nn.fromSphere(m.uInvariantBoundingSphere.ref.value,g)))},createRenderableState:function f(m){const h=rt.createRenderableState(m);return p(h,m),h},updateRenderableState:p,createPositionIterator:a}}(ym||(ym={}));const v5={},Fie={fontFamily:C.Select("sans-serif",[["sans-serif","Sans Serif"],["monospace","Monospace"],["serif","Serif"],["cursive","Cursive"]]),fontQuality:C.Select(3,[[0,"lower"],[1,"low"],[2,"medium"],[3,"high"],[4,"higher"]]),fontStyle:C.Select("normal",[["normal","Normal"],["italic","Italic"],["oblique","Oblique"]]),fontVariant:C.Select("normal",[["normal","Normal"],["small-caps","Small Caps"]]),fontWeight:C.Select("normal",[["normal","Normal"],["bold","Bold"]])};class MHe{constructor(t={}){this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.5;const n={...C.getDefaultValues(Fie),...t};this.props=n;const r=32*(n.fontQuality+1);this.buffer=r/8,this.radius=r/3,this.lineHeight=Math.round(r+2*this.buffer+this.radius),this.maxWidth=Math.round(.75*this.lineHeight),this.texture=Po(350*this.lineHeight*this.maxWidth,1,Uint8Array),this.scratchContext=function kHe(e,t,n){if(qg)return function RHe(){throw new Error("When running in Node.js and wanting to use Canvas API, call mol-util/data-source's setCanvasModule function first and pass imported `canvas` module to it.")}().createCanvas(e,t).getContext("2d",n);{const r=document.createElement("canvas");return r.width=e,r.height=t,r.getContext("2d",n)}}(this.maxWidth,this.lineHeight,{willReadFrequently:!0}),this.scratchContext.font=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${r}px ${n.fontFamily}`,this.scratchContext.fillStyle="black",this.scratchContext.textBaseline="middle",this.scratchData=new Uint8Array(this.lineHeight*this.maxWidth),this.gridOuter=new Float64Array(this.lineHeight*this.maxWidth),this.gridInner=new Float64Array(this.lineHeight*this.maxWidth),this.f=new Float64Array(Math.max(this.lineHeight,this.maxWidth)),this.d=new Float64Array(Math.max(this.lineHeight,this.maxWidth)),this.z=new Float64Array(Math.max(this.lineHeight,this.maxWidth)+1),this.v=new Int16Array(Math.max(this.lineHeight,this.maxWidth)),this.middle=Math.ceil(this.lineHeight/2),this.placeholder=this.get("\ufffd")}get(t){if(void 0===this.mapped[t]){this.draw(t);const{array:n,width:r,height:i}=this.texture,o=this.scratchData;if(this.currentX+this.scratchW>r&&(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(let s=0;si&&(i=u);const l=Math.abs(e[c+1]);l>i&&(i=l);const d=Math.abs(t[s]);d>o&&(o=d)}return Math.max(o,r+r*i)}!function(e){function t(p,m,h,g,y,b,x,_,S){return S?function o(p,m,h,g,y,b,x,_,S){return S.charCount=_,k.update(S.fontTexture,p),k.update(S.centerBuffer,m),k.update(S.mappingBuffer,h),k.update(S.depthBuffer,g),k.update(S.indexBuffer,y),k.update(S.groupBuffer,b),k.update(S.tcoordBuffer,x),S}(p,m,h,g,y,b,x,_,S):function i(p,m,h,g,y,b,x,_){const S=_e();let A,E=-1,w=-1;const D={kind:"text",charCount:_,fontTexture:k.create(p),centerBuffer:k.create(m),mappingBuffer:k.create(h),depthBuffer:k.create(g),indexBuffer:k.create(y),groupBuffer:k.create(b),tcoordBuffer:k.create(x),get boundingSphere(){const I=r(D);if(I!==E){const R=Ip(D.centerBuffer.ref.value,4*D.charCount,4);_e.copy(S,R),E=I}return S},get groupMapping(){return D.groupBuffer.ref.version!==w&&(A=gv(D.groupBuffer.ref.value,D.charCount,4),w=D.groupBuffer.ref.version),A},setBoundingSphere(I){_e.copy(S,I),E=r(D)}};return D}(p,m,h,g,y,b,x,_)}function n(p){return t(p?p.fontTexture.ref.value:Po(0,1,Uint8Array),p?p.centerBuffer.ref.value:new Float32Array(0),p?p.mappingBuffer.ref.value:new Float32Array(0),p?p.depthBuffer.ref.value:new Float32Array(0),p?p.indexBuffer.ref.value:new Uint32Array(0),p?p.groupBuffer.ref.value:new Float32Array(0),p?p.tcoordBuffer.ref.value:new Float32Array(0),0,p)}function r(p){return ha([p.charCount,p.fontTexture.ref.version,p.centerBuffer.ref.version,p.mappingBuffer.ref.version,p.depthBuffer.ref.version,p.indexBuffer.ref.version,p.groupBuffer.ref.version,p.tcoordBuffer.ref.version])}function s(p,m){const h=4*p.charCount,g=m.instanceCount.ref.value,y=mm(),b=y.position,x=p.centerBuffer.ref.value,_=m.aTransform.ref.value;return Mr(h,g,4,(A,E)=>(E<0?v.fromArray(b,x,3*A):v.transformMat4Offset(b,x,_,0,3*A,16*E),y))}function a(p,m,h,g,y){const{instanceCount:b,groupCount:x}=h,S=bu(h,s(p,m),g.color),A=kp(h,g.size),E=y.instanceGranularity?Vi(b,"instance"):Vi(b*x,"groupInstance"),w=Dp(),D=Ep(),I=Mp(),R=Pp(),T={drawCount:2*p.charCount*3,vertexCount:4*p.charCount,groupCount:x,instanceCount:b},M=Bie(p.mappingBuffer.ref.value,p.depthBuffer.ref.value,p.charCount,gS(A)),N=_e.expand(_e(),p.boundingSphere,M),V=fs(N,m.aTransform.ref.value,b,0);return{dGeometryType:k.create("text"),aPosition:p.centerBuffer,aMapping:p.mappingBuffer,aDepth:p.depthBuffer,aGroup:p.groupBuffer,elements:p.indexBuffer,boundingSphere:k.create(V),invariantBoundingSphere:k.create(N),uInvariantBoundingSphere:k.create(nn.ofSphere(N)),...S,...A,...E,...w,...D,...I,...R,...m,aTexCoord:p.tcoordBuffer,tFont:p.fontTexture,padding:k.create(M),...rt.createValues(y,T),uSizeFactor:k.create(y.sizeFactor),uBorderWidth:k.create(os(y.borderWidth,0,.5)),uBorderColor:k.create(st.toArrayNormalized(y.borderColor,v.zero(),0)),uOffsetX:k.create(y.offsetX),uOffsetY:k.create(y.offsetY),uOffsetZ:k.create(y.offsetZ),uBackgroundColor:k.create(st.toArrayNormalized(y.backgroundColor,v.zero(),0)),uBackgroundOpacity:k.create(y.backgroundOpacity)}}function f(p,m){rt.updateRenderableState(p,m),p.pickable=!1,p.opaque=!1,p.writeDepth=!0}e.create=t,e.createEmpty=n,e.Params={...rt.Params,...Fie,sizeFactor:C.Numeric(1,{min:0,max:10,step:.1}),borderWidth:C.Numeric(0,{min:0,max:.5,step:.01}),borderColor:C.Color(xn.grey),offsetX:C.Numeric(0,{min:0,max:10,step:.1}),offsetY:C.Numeric(0,{min:0,max:10,step:.1}),offsetZ:C.Numeric(0,{min:0,max:10,step:.1}),background:C.Boolean(!1),backgroundMargin:C.Numeric(.2,{min:0,max:1,step:.01}),backgroundColor:C.Color(xn.grey),backgroundOpacity:C.Numeric(1,{min:0,max:1,step:.01}),tether:C.Boolean(!1),tetherLength:C.Numeric(1,{min:0,max:5,step:.1}),tetherBaseWidth:C.Numeric(.3,{min:0,max:1,step:.01}),attachment:C.Select("middle-center",[["bottom-left","bottom-left"],["bottom-center","bottom-center"],["bottom-right","bottom-right"],["middle-left","middle-left"],["middle-center","middle-center"],["middle-right","middle-right"],["top-left","top-left"],["top-center","top-center"],["top-right","top-right"]])},e.Utils={Params:e.Params,createEmpty:n,createValues:a,createValuesSimple:function c(p,m,h,g,y){const b=rt.createSimple(h,g,y),x={...C.getDefaultValues(e.Params),...m};return a(p,b.transform,b.locationIterator,b.theme,x)},updateValues:function u(p,m){rt.updateValues(p,m),k.updateIfChanged(p.uSizeFactor,m.sizeFactor),k.updateIfChanged(p.uBorderWidth,m.borderWidth),st.fromNormalizedArray(p.uBorderColor.ref.value,0)!==m.borderColor&&(st.toArrayNormalized(m.borderColor,p.uBorderColor.ref.value,0),k.update(p.uBorderColor,p.uBorderColor.ref.value)),k.updateIfChanged(p.uOffsetX,m.offsetX),k.updateIfChanged(p.uOffsetY,m.offsetY),k.updateIfChanged(p.uOffsetZ,m.offsetZ),st.fromNormalizedArray(p.uBackgroundColor.ref.value,0)!==m.backgroundColor&&(st.toArrayNormalized(m.backgroundColor,p.uBackgroundColor.ref.value,0),k.update(p.uBackgroundColor,p.uBackgroundColor.ref.value)),k.updateIfChanged(p.uBackgroundOpacity,m.backgroundOpacity)},updateBoundingSphere:function l(p,m){const h=Bie(p.aMapping.ref.value,p.aDepth.ref.value,m.charCount,gS(p)),g=_e.expand(_e(),m.boundingSphere,h),y=fs(g,p.aTransform.ref.value,p.instanceCount.ref.value,0);_e.equals(y,p.boundingSphere.ref.value)||k.update(p.boundingSphere,y),_e.equals(g,p.invariantBoundingSphere.ref.value)||(k.update(p.invariantBoundingSphere,g),k.update(p.uInvariantBoundingSphere,nn.fromSphere(p.uInvariantBoundingSphere.ref.value,g))),k.update(p.padding,h)},createRenderableState:function d(p){const m=rt.createRenderableState(p);return f(m,p),m},updateRenderableState:f,createPositionIterator:s}}(vu||(vu={}));const ic=v(),fd=v(),yS=v(),Oie=ze.add,MD=ze.add3;var Fc,di;!function(e){e.create=function t(n=2048,r=1024,i){const o=ze.create(Float32Array,1,r,i?i.groupBuffer.ref.value:n),s=ze.create(Float32Array,3,r,i?i.startBuffer.ref.value:n),a=ze.create(Float32Array,3,r,i?i.endBuffer.ref.value:n),c=(d,f,p,m,h,g,y)=>{for(let b=0;b<4;++b)MD(s,d,f,p),MD(a,m,h,g),Oie(o,y)},l=(d,f,p,m)=>{const h=v.distance(d,f),g=p%2!=0,y=Math.floor((p+1)/2),b=h/(p+.5);v.setMagnitude(yS,v.sub(yS,f,d),b),v.copy(ic,d);for(let x=0;x{for(let m=0;m<4;++m)MD(s,d[0],d[1],d[2]),MD(a,f[0],f[1],f[2]),Oie(o,p)},addFixedCountDashes:l,addFixedLengthDashes:(d,f,p,m)=>{const h=v.distance(d,f);l(d,f,h/p,m)},addCage:(d,f,p)=>{const{vertices:m,edges:h}=f;for(let g=0,y=h.length;g{const d=o.elementCount/4,f=ze.compact(o,!0),p=ze.compact(s,!0),m=ze.compact(a,!0),h=i&&d<=i.lineCount?i.mappingBuffer.ref.value:new Float32Array(8*d),g=i&&d<=i.lineCount?i.indexBuffer.ref.value:new Uint32Array(6*d);return(!i||d>i.lineCount)&&function NHe(e,t,n){for(let r=0;rx.lineCount&&(k.update(x.mappingBuffer,p),k.update(x.indexBuffer,m)),x.lineCount=b,k.update(x.groupBuffer,h),k.update(x.startBuffer,g),k.update(x.endBuffer,y),x}(p,m,h,g,y,b,x):function o(p,m,h,g,y,b){const x=_e();let _,S=-1,A=-1;const E={kind:"lines",lineCount:b,mappingBuffer:k.create(p),indexBuffer:k.create(m),groupBuffer:k.create(h),startBuffer:k.create(g),endBuffer:k.create(y),get boundingSphere(){const w=i(E);if(w!==S){const D=Ip(E.startBuffer.ref.value,4*E.lineCount,4),I=Ip(E.endBuffer.ref.value,4*E.lineCount,4);_e.expandBySphere(x,D,I),S=w}return x},get groupMapping(){return E.groupBuffer.ref.version!==A&&(_=gv(E.groupBuffer.ref.value,E.lineCount,4),A=E.groupBuffer.ref.version),_},setBoundingSphere(w){_e.copy(x,w),S=i(E)}};return E}(p,m,h,g,y,b)}function n(p){return t(p?p.mappingBuffer.ref.value:new Float32Array(0),p?p.indexBuffer.ref.value:new Uint32Array(0),p?p.groupBuffer.ref.value:new Float32Array(0),p?p.startBuffer.ref.value:new Float32Array(0),p?p.endBuffer.ref.value:new Float32Array(0),0,p)}function i(p){return ha([p.lineCount,p.mappingBuffer.ref.version,p.indexBuffer.ref.version,p.groupBuffer.ref.version,p.startBuffer.ref.version,p.endBuffer.ref.version])}function c(p,m){const h=4*p.lineCount,g=m.instanceCount.ref.value,y=mm(),b=y.position,x=p.startBuffer.ref.value,_=p.endBuffer.ref.value,S=m.aTransform.ref.value;return Mr(h,g,2,(E,w)=>{const D=E%4==0?x:_;return w<0?v.fromArray(b,D,3*E):v.transformMat4Offset(b,D,S,0,3*E,16*w),y})}function u(p,m,h,g,y){const{instanceCount:b,groupCount:x}=h,S=bu(h,c(p,m),g.color),A=kp(h,g.size),E=y.instanceGranularity?Vi(b,"instance"):Vi(b*x,"groupInstance"),w=Dp(),D=Ep(),I=Mp(),R=Pp(),T={drawCount:2*p.lineCount*3,vertexCount:4*p.lineCount,groupCount:x,instanceCount:b},M=_e.clone(p.boundingSphere),N=fs(M,m.aTransform.ref.value,b,0);return{dGeometryType:k.create("lines"),aMapping:p.mappingBuffer,aGroup:p.groupBuffer,aStart:p.startBuffer,aEnd:p.endBuffer,elements:p.indexBuffer,boundingSphere:k.create(N),invariantBoundingSphere:k.create(M),uInvariantBoundingSphere:k.create(nn.ofSphere(M)),...S,...A,...E,...w,...D,...I,...R,...m,...rt.createValues(y,T),uSizeFactor:k.create(y.sizeFactor),dLineSizeAttenuation:k.create(y.lineSizeAttenuation),uDoubleSided:k.create(!0),dFlipSided:k.create(!1)}}e.create=t,e.createEmpty=n,e.fromMesh=function r(p,m){const h=p.vertexBuffer.ref.value,g=p.indexBuffer.ref.value,y=p.groupBuffer.ref.value,b=Fc.create(3*p.triangleCount,p.triangleCount/10,m);for(let x=0,_=3*p.triangleCount;x<_;x+=3){const S=g[x],A=g[x+1],E=g[x+2],w=h[3*S],D=h[3*S+1],I=h[3*S+2],R=h[3*A],T=h[3*A+1],M=h[3*A+2],N=h[3*E],V=h[3*E+1],F=h[3*E+2];b.add(w,D,I,R,T,M,y[S]),b.add(w,D,I,N,V,F,y[S]),b.add(R,T,M,N,V,F,y[A])}return b.getLines()},e.transform=function a(p,m){const h=p.startBuffer.ref.value;l0(m,h,0,4*p.lineCount),k.update(p.startBuffer,h);const g=p.endBuffer.ref.value;l0(m,g,0,4*p.lineCount),k.update(p.endBuffer,g)},e.Params={...rt.Params,sizeFactor:C.Numeric(2,{min:0,max:10,step:.1}),lineSizeAttenuation:C.Boolean(!1)},e.Utils={Params:e.Params,createEmpty:n,createValues:u,createValuesSimple:function l(p,m,h,g,y){const b=rt.createSimple(h,g,y),x={...C.getDefaultValues(e.Params),...m};return u(p,b.transform,b.locationIterator,b.theme,x)},updateValues:function d(p,m){rt.updateValues(p,m),k.updateIfChanged(p.uSizeFactor,m.sizeFactor),k.updateIfChanged(p.dLineSizeAttenuation,m.lineSizeAttenuation)},updateBoundingSphere:function f(p,m){const h=_e.clone(m.boundingSphere),g=fs(h,p.aTransform.ref.value,p.instanceCount.ref.value,0);_e.equals(g,p.boundingSphere.ref.value)||k.update(p.boundingSphere,g),_e.equals(h,p.invariantBoundingSphere.ref.value)||(k.update(p.invariantBoundingSphere,h),k.update(p.uInvariantBoundingSphere,nn.fromSphere(p.uInvariantBoundingSphere.ref.value,h)))},createRenderableState:rt.createRenderableState,updateRenderableState:rt.updateRenderableState,createPositionIterator:c}}(di||(di={}));const Np=v(),Fp=v(),Bp=v(),wv=v(),ao=hf(4,!0);function Lie(e){const r=bv(12,e?36:24);for(let i=0;i<4;++i){const o=(i+1)%4;v.set(Np,ao[3*i],ao[3*i+1],-.5),v.set(Fp,ao[3*o],ao[3*o+1],-.5),v.set(Bp,ao[3*o],ao[3*o+1],.5),v.set(wv,ao[3*i],ao[3*i+1],.5),e?r.add(Np,Fp,Bp):r.addQuad(Np,Fp,Bp,wv)}return v.set(Np,ao[0],ao[1],-.5),v.set(Fp,ao[3],ao[4],-.5),v.set(Bp,ao[6],ao[7],-.5),v.set(wv,ao[9],ao[10],-.5),e?r.add(Bp,Fp,Np):r.addQuad(wv,Bp,Fp,Np),v.set(Np,ao[0],ao[1],.5),v.set(Fp,ao[3],ao[4],.5),v.set(Bp,ao[6],ao[7],.5),v.set(wv,ao[9],ao[10],.5),e?r.add(Np,Fp,Bp):r.addQuad(Np,Fp,Bp,wv),r.getPrimitive()}let x5,C5,w5;function S5(){return x5||(x5=Lie(!1)),x5}function Uie(){return w5||(w5=fS([.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])),w5}function Vie(e){return e.map(t=>({x:t[0],alpha:t[1]}))}function zie(e,t){const n=[{x:0,alpha:0},{x:0,alpha:0},...e,{x:1,alpha:0},{x:1,alpha:0}],i=t?t.ref.value.array:new Uint8Array(256);let s,a,c,u,l,d,o=0;const f=e.length+1;for(let m=0;m=t?c=t-1:c<0&&(c=0),o[c]++}return{min:n,max:r,binWidth:i,counts:o}}var Ko,RD,kD,et;function jie(e,t){return Oe.create("Create Volume",function(){var n=ie(function*(r){const{volume_data_3d_info:i,volume_data_3d:o}=e,s=ma.create(i.spacegroup_number.value(0),v.ofArray(i.spacegroup_cell_size.value(0)),v.scale(v.zero(),v.ofArray(i.spacegroup_cell_angles.value(0)),Math.PI/180)),a=i.axis_order.value(0),c=wn.convertToCanonicalAxisIndicesFastToSlow(a),u=c(i.sample_count.value(0)),l=wn.Space(u,wn.invertAxisOrder(a),Float32Array),d=wn.create(l,wn.Data1(o.values.toArray({array:Float32Array}))),f=v.ofArray(c(i.origin.value(0))),p=v.ofArray(c(i.dimensions.value(0)));return{label:t?.label,entryId:t?.entryId,grid:{transform:{kind:"spacegroup",cell:s,fractionalBox:St.create(f,v.add(v.zero(),f,p))},cells:d,stats:{min:i.min_sampled.value(0),max:i.max_sampled.value(0),mean:i.mean_sampled.value(0),sigma:i.sigma_sampled.value(0)}},sourceData:kD.create(e),customProperties:new Ql,_propertyData:Object.create(null)}});return function(r){return n.apply(this,arguments)}}())}!function(e){e.One={transform:{kind:"matrix",matrix:le.identity()},cells:wn.create(wn.Space([1,1,1],[0,1,2]),wn.Data1([0])),stats:{min:0,max:0,mean:0,sigma:0}};const t=le.zero(),n=le.zero();e.getGridToCartesianTransform=function r(c){if("matrix"===c.transform.kind)return le.copy(le(),c.transform.matrix);if("spacegroup"===c.transform.kind){const{cells:{space:u}}=c,l=le.fromScaling(t,v.div(v.zero(),St.size(v.zero(),c.transform.fractionalBox),v.ofArray(u.dimensions))),d=le.fromTranslation(n,c.transform.fractionalBox.min);return le.mul3(le.zero(),c.transform.cell.fromFractional,d,l)}return le.identity()},e.areEquivalent=function i(c,u){return c===u},e.isEmpty=function o(c){return 0===c.cells.data.length},e.getBoundingSphere=function s(c,u){u||(u=_e());const l=c.cells.space.dimensions,d=e.getGridToCartesianTransform(c);return _e.fromDimensionsAndTransform(u,l,d)},e.getHistogram=function a(c,u){let l=c._historams;return l||(l=c._historams={}),l[u]||(l[u]=function BHe(e,t,n){if(n)return Gie(e,t,n.min,n.max);{const[r,i]=cu(e);return Gie(e,t,r,i)}}(c.cells.data,u,{min:c.stats.min,max:c.stats.max})),l[u]}}(Ko||(Ko={})),function(e){e.is=function t(r){return"cube"===r?.kind},e.create=function n(r){return{kind:"cube",name:r.name,data:r}}}(RD||(RD={})),function(e){e.is=function t(r){return"dscif"===r?.kind},e.create=function n(r){return{kind:"dscif",name:r._name,data:r}}}(kD||(kD={})),function(e){let n;e.is=function t(y){var b,x,_,S;return(null===(S=null===(_=null===(x=null===(b=y?.grid)||void 0===b?void 0:b.cells)||void 0===x?void 0:x.space)||void 0===_?void 0:_.dimensions)||void 0===S?void 0:S.length)&&y?.sourceData&&y?.customProperties&&y?._propertyData},function(y){function E(I,R){return"absolute"===I.kind?I:{kind:"absolute",absoluteValue:y.calcAbsolute(R,I.relativeValue)}}y.areSame=function b(I,R,T){return ai(E(I,T).absoluteValue,E(R,T).absoluteValue,T.sigma/100)},y.absolute=function x(I){return{kind:"absolute",absoluteValue:I}},y.relative=function _(I){return{kind:"relative",relativeValue:I}},y.calcAbsolute=function S(I,R){return R*I.sigma+I.mean},y.calcRelative=function A(I,R){return 0===I.sigma?0:(R-I.mean)/I.sigma},y.toAbsolute=E,y.toRelative=function w(I,R){return"relative"===I.kind?I:{kind:"relative",relativeValue:y.calcRelative(R,I.absoluteValue)}},y.toString=function D(I){return"relative"===I.kind?`${I.relativeValue.toFixed(2)} \u03c3`:`${I.absoluteValue.toPrecision(4)}`}}(n=e.IsoValue||(e.IsoValue={})),e.adjustedIsoValue=function r(y,b,x){if("relative"===x)return n.relative(b);const _=n.absolute(b);if(kD.is(y.sourceData)){const S={min:y.sourceData.data.volume_data_3d_info.min_source.value(0),max:y.sourceData.data.volume_data_3d_info.max_source.value(0),mean:y.sourceData.data.volume_data_3d_info.mean_source.value(0),sigma:y.sourceData.data.volume_data_3d_info.sigma_source.value(0)};return e.IsoValue.toRelative(_,S)}return _};const i={min:-1,max:1,mean:0,sigma:.1};function o(y,b){const x=b||i,{min:_,max:S,mean:A,sigma:E}=x,w=(_-A)/E,D=(S-A)/E;let I=y;return"absolute"===y.kind?y.absoluteValue<_?I=e.IsoValue.absolute(_):y.absoluteValue>S&&(I=e.IsoValue.absolute(S)):y.relativeValueD&&(I=e.IsoValue.relative(D)),C.Conditioned(I,{absolute:C.Converted(R=>e.IsoValue.toAbsolute(R,Ko.One.stats).absoluteValue,R=>e.IsoValue.absolute(R),C.Numeric(A,{min:_,max:S,step:iJ(E/100,2)},{immediateUpdate:!0})),relative:C.Converted(R=>e.IsoValue.toRelative(R,Ko.One.stats).relativeValue,R=>e.IsoValue.relative(R),C.Numeric(Math.min(1,D),{min:w,max:D,step:iJ(Math.round((S-_)/E)/100,2)},{immediateUpdate:!0}))},R=>"absolute"===R.kind?"absolute":"relative",(R,T)=>"absolute"===T?e.IsoValue.toAbsolute(R,x):e.IsoValue.toRelative(R,x),{isEssential:!0})}let m,h,g;e.createIsoValueParam=o,e.IsoValueParam=o(e.IsoValue.relative(2)),e.One={label:"",grid:Ko.One,sourceData:{kind:"",name:"",data:{}},customProperties:new Ql,_propertyData:Object.create(null)},e.areEquivalent=function s(y,b){return Ko.areEquivalent(y.grid,b.grid)},e.isEmpty=function a(y){return Ko.isEmpty(y.grid)},e.isOrbitals=function c(y){return!!RD.is(y.sourceData)&&y.sourceData.data.header.orbitals},e.Loci=function u(y){return{kind:"volume-loci",volume:y}},e.isLoci=function l(y){return!!y&&"volume-loci"===y.kind},e.areLociEqual=function d(y,b){return y.volume===b.volume},e.isLociEmpty=function f(y){return Ko.isEmpty(y.volume.grid)},e.getBoundingSphere=function p(y,b){return Ko.getBoundingSphere(y.grid,b)},function(y){y.Loci=function b(w,D){return{kind:"isosurface-loci",volume:w,isoValue:D}},y.isLoci=function x(w){return!!w&&"isosurface-loci"===w.kind},y.areLociEqual=function _(w,D){return w.volume===D.volume&&e.IsoValue.areSame(w.isoValue,D.isoValue,w.volume.grid.stats)},y.isLociEmpty=function S(w){return 0===w.volume.grid.cells.data.length};const A=St();y.getBoundingSphere=function E(w,D,I){const R=e.IsoValue.toAbsolute(D,w.grid.stats).absoluteValue,T=R<0,M=[0,0,0],N=w.grid.cells.space.getCoords,V=w.grid.cells.data,[F,G,L]=w.grid.cells.space.dimensions;let z=F-1,j=G-1,Z=L-1,$=0,ee=0,q=0;for(let H=0,W=V.length;H=R)&&(N(H,M),M[0]$&&($=M[0]),M[1]>ee&&(ee=M[1]),M[2]>q&&(q=M[2]));v.set(A.min,z-1,j-1,Z-1),v.set(A.max,$+1,ee+1,q+1);const O=Ko.getGridToCartesianTransform(w.grid);return St.transform(A,A,O),_e.fromBox3D(I||_e(),A)}}(m=e.Isosurface||(e.Isosurface={})),function(y){y.Loci=function b(D,I){return{kind:"cell-loci",volume:D,indices:I}},y.isLoci=function x(D){return!!D&&"cell-loci"===D.kind},y.areLociEqual=function _(D,I){return D.volume===I.volume&&Fe.areEqual(D.indices,I.indices)},y.isLociEmpty=function S(D){return 0===Fe.size(D.indices)};const A=new fu("98"),E=v();y.getBoundingSphere=function w(D,I,R){A.reset();const T=Ko.getGridToCartesianTransform(D.grid),{getCoords:M}=D.grid.cells.space;for(let V=0,F=Fe.size(I);Vy._propertyData.__segmentation__}}(et||(et={}));const A5=S5();var _u,fl,xa;function Ar(e,t,n){return{type:"attribute",kind:e,itemSize:t,divisor:n}}function xe(e,t){return{type:"uniform",kind:e,variant:t}}function jt(e,t,n,r,i){return{type:"texture",kind:e,format:t,dataType:n,filter:r,variant:i}}function Av(e){return{type:"elements",kind:e}}function Ft(e,t){return{type:"define",kind:e,options:t}}function ri(e){return{type:"value",kind:e}}!function(e){function t(g,y,b,x,_,S,A,E,w,D){return D?function i(g,y,b,x,_,S,A,E,w,D){const I=S.getWidth(),R=S.getHeight(),T=S.getDepth();return k.update(D.gridDimension,y),k.update(D.gridTexture,S),k.update(D.gridTextureDim,v.set(D.gridTextureDim.ref.value,I,R,T)),k.update(D.gridStats,nn.set(D.gridStats.ref.value,A.min,A.max,A.mean,A.sigma)),k.update(D.bboxMin,g.min),k.update(D.bboxMax,g.max),k.update(D.bboxSize,v.sub(D.bboxSize.ref.value,g.max,g.min)),k.update(D.transform,b),k.update(D.cellDim,_),k.update(D.unitToCartn,x),k.update(D.cartnToUnit,le.invert(le(),x)),k.updateIfChanged(D.packedGroup,E),k.updateIfChanged(D.axisOrder,v.fromArray(D.axisOrder.ref.value,w,0)),D}(g,y,b,x,_,S,A,E,w,D):function r(g,y,b,x,_,S,A,E,w){const D=_e();let I=-1;const R=S.getWidth(),T=S.getHeight(),M=S.getDepth(),N={kind:"direct-volume",gridDimension:k.create(y),gridTexture:k.create(S),gridTextureDim:k.create(v.create(R,T,M)),gridStats:k.create(nn.create(A.min,A.max,A.mean,A.sigma)),bboxMin:k.create(g.min),bboxMax:k.create(g.max),bboxSize:k.create(v.sub(v(),g.max,g.min)),transform:k.create(b),cellDim:k.create(_),unitToCartn:k.create(x),cartnToUnit:k.create(le.invert(le(),x)),get boundingSphere(){const V=n(N);if(V!==I){const F=function LHe(e,t){return _e.fromDimensionsAndTransform(_e(),e,t)}(N.gridDimension.ref.value,N.transform.ref.value);_e.copy(D,F),I=V}return D},packedGroup:k.create(E),axisOrder:k.create(w),setBoundingSphere(V){_e.copy(D,V),I=n(N)}};return N}(g,y,b,x,_,S,A,E,w)}function n(g){return ha([g.bboxSize.ref.version,g.gridDimension.ref.version,g.gridTexture.ref.version,g.transform.ref.version,g.gridStats.ref.version])}function o(g){return t(St(),v(),le.identity(),le.identity(),v(),Os(),Ko.One.stats,!1,v.create(0,1,2),g)}function a(g,y){return Math.ceil(v.magnitude(g)*y)}function c(g,y){return Math.min(...g)*(1/y)}function u(g){return 1/g}function l(g,y,b,x,_){const{gridTexture:S,gridTextureDim:A,gridStats:E}=g,{bboxSize:w,bboxMin:D,bboxMax:I,gridDimension:R,transform:T}=g,{instanceCount:M,groupCount:N}=b,F=bu(b,e.Utils.createPositionIterator(g,y),x.color),G=_.instanceGranularity?Vi(M,"instance"):Vi(M*N,"groupInstance"),L=Dp(),z=Ep(),j=Mp(),Z=Pp(),[$,ee,q]=R.ref.value,O={drawCount:A5.indices.length,vertexCount:$*ee*q,groupCount:N,instanceCount:M},H=_e.clone(g.boundingSphere),W=fs(H,y.aTransform.ref.value,M,0),fe=zie(Vie(_.controlPoints));return{dGeometryType:k.create("directVolume"),...F,...G,...L,...z,...j,...Z,...y,...rt.createValues(_,O),aPosition:k.create(A5.vertices),elements:k.create(A5.indices),boundingSphere:k.create(W),invariantBoundingSphere:k.create(H),uInvariantBoundingSphere:k.create(nn.ofSphere(H)),uBboxMin:D,uBboxMax:I,uBboxSize:w,uMaxSteps:k.create(a(R.ref.value,_.stepsPerCell)),uStepScale:k.create(c(g.cellDim.ref.value,_.stepsPerCell)),uJumpLength:k.create(_.jumpLength),uTransform:T,uGridDim:R,tTransferTex:fe,uTransferScale:k.create(u(_.stepsPerCell)),dGridTexType:k.create(S.ref.value.getDepth()>0?"3d":"2d"),uGridTexDim:A,tGridTex:S,uGridStats:E,uCellDim:g.cellDim,uCartnToUnit:g.cartnToUnit,uUnitToCartn:g.unitToCartn,dPackedGroup:g.packedGroup,dAxisOrder:k.create(g.axisOrder.ref.value.join("")),dIgnoreLight:k.create(_.ignoreLight),dXrayShaded:k.create("inverted"===_.xrayShaded?"inverted":!0===_.xrayShaded?"on":"off")}}e.create=t,e.createEmpty=o,e.Params={...rt.Params,ignoreLight:C.Boolean(!1,rt.ShadingCategory),xrayShaded:C.Select(!1,[[!1,"Off"],[!0,"On"],["inverted","Inverted"]],rt.ShadingCategory),controlPoints:C.LineGraph([Me.create(.19,0),Me.create(.2,.05),Me.create(.25,.05),Me.create(.26,0),Me.create(.79,0),Me.create(.8,.05),Me.create(.85,.05),Me.create(.86,0)],{isEssential:!0}),stepsPerCell:C.Numeric(3,{min:1,max:10,step:1}),jumpLength:C.Numeric(0,{min:0,max:20,step:.1})},e.Utils={Params:e.Params,createEmpty:o,createValues:l,createValuesSimple:function d(g,y,b,x,_){const S=rt.createSimple(b,x,_),A={...C.getDefaultValues(e.Params),...y};return l(g,S.transform,S.locationIterator,S.theme,A)},updateValues:function f(g,y){rt.updateValues(g,y),k.updateIfChanged(g.dIgnoreLight,y.ignoreLight),k.updateIfChanged(g.dXrayShaded,"inverted"===y.xrayShaded?"inverted":!0===y.xrayShaded?"on":"off"),zie(Vie(y.controlPoints),g.tTransferTex),k.updateIfChanged(g.uMaxSteps,a(g.uGridDim.ref.value,y.stepsPerCell)),k.updateIfChanged(g.uStepScale,c(g.uCellDim.ref.value,y.stepsPerCell)),k.updateIfChanged(g.uTransferScale,u(y.stepsPerCell)),k.updateIfChanged(g.uJumpLength,y.jumpLength)},updateBoundingSphere:function p(g,y){const b=_e.clone(y.boundingSphere),x=fs(b,g.aTransform.ref.value,g.instanceCount.ref.value,0);_e.equals(x,g.boundingSphere.ref.value)||k.update(g.boundingSphere,x),_e.equals(b,g.invariantBoundingSphere.ref.value)||(k.update(g.invariantBoundingSphere,b),k.update(g.uInvariantBoundingSphere,nn.fromSphere(g.uInvariantBoundingSphere.ref.value,b)))},createRenderableState:function m(g){const y=rt.createRenderableState(g);return y.opaque=!1,y.writeDepth=!1,y},updateRenderableState:function h(g,y){rt.updateRenderableState(g,y),g.opaque=!1,g.writeDepth=!1},createPositionIterator:function s(g,y){const b=g.transform.ref.value,[x,_,S]=g.gridDimension.ref.value,A=x*_*S,E=y.instanceCount.ref.value,w=mm(),D=w.position,I=y.aTransform.ref.value;return Mr(A,E,1,(T,M)=>{const N=Math.floor(T/S);return D[0]=Math.floor(N/_),D[1]=N%_,D[2]=T%S,v.transformMat4(D,D,b),M>=0&&v.transformMat4Offset(D,D,I,0,0,16*M),w})}}}(_u||(_u={})),function(e){function t(x,_,S,A){return A?function o(x,_,S,A){return A.sphereCount=S,k.update(A.centerBuffer,x),k.update(A.groupBuffer,_),A.shaderData.update(),A}(x,_,S,A):function i(x,_,S){const A=_e();let E,w=-1,D=-1;const I=k.create(Po(1,4,Float32Array)),R=k.create(Me.create(0,0)),T=k.create([]),M=k.create(0),N={kind:"spheres",sphereCount:S,centerBuffer:k.create(x),groupBuffer:k.create(_),get boundingSphere(){const V=r(N);if(V!==w){const F=Ip(N.centerBuffer.ref.value,4*N.sphereCount,4);_e.copy(A,F),w=V}return A},get groupMapping(){return N.groupBuffer.ref.version!==D&&(E=gv(N.groupBuffer.ref.value,N.sphereCount,4),D=N.groupBuffer.ref.version),E},setBoundingSphere(V){_e.copy(A,V),w=r(N)},shaderData:{positionGroup:I,texDim:R,lodLevels:T,sizeFactor:M,update(V){var F,G;const L=null!==(F=V?.lodLevels)&&void 0!==F?F:u(T.ref.value),z=null!==(G=V?.sizeFactor)&&void 0!==G?G:M.ref.value,j=d(L,z),Z=Po(N.sphereCount,4,Float32Array,I.ref.value.array),$=s(Z,N.centerBuffer.ref.value,N.groupBuffer.ref.value,N.sphereCount,j),ee=$?c(L,z,$,N.sphereCount):[];k.update(I,Z),k.update(R,Me.set(R.ref.value,Z.width,Z.height)),k.update(T,ee),k.update(M,z)}}};return N}(x,_,S)}function n(x){return t(x?x.centerBuffer.ref.value:new Float32Array(0),x?x.groupBuffer.ref.value:new Float32Array(0),0,x)}function r(x){return ha([x.sphereCount,x.centerBuffer.ref.version,x.groupBuffer.ref.version])}function s(x,_,S,A,E){const{array:w}=x;if(0===E.length){for(let R=0;R{const D=l(E,_);return[E.minDistance,E.maxDistance,E.overlap,S[S.length-1-w],Math.pow(Math.min(A,D),1/E.scaleBias),E.stride,E.scaleBias]})}function u(x){return x.map(_=>({minDistance:_[0],maxDistance:_[1],overlap:_[2],stride:_[5],scaleBias:_[6]}))}function l(x,_){return Math.max(1,Math.round(x.stride/Math.pow(_,x.scaleBias)))}function d(x,_){return x.map(S=>l(S,_)).reverse()}function f(x,_){const S=x.sphereCount,A=_.instanceCount.ref.value,E=mm(),w=E.position,D=x.centerBuffer.ref.value,I=_.aTransform.ref.value;return Mr(S,A,1,(T,M)=>(M<0?v.fromArray(w,D,3*T):v.transformMat4Offset(w,D,I,0,3*T,16*M),E))}function p(x,_,S,A,E){const{instanceCount:w,groupCount:D}=S,R=bu(S,f(x,_),A.color),T=kp(S,A.size),M=E.instanceGranularity?Vi(w,"instance"):Vi(w*D,"groupInstance"),N=Dp(),V=Ep(),F=Mp(),G=Pp(),L={drawCount:2*x.sphereCount*3,vertexCount:6*x.sphereCount,groupCount:D,instanceCount:w},z=x.boundingSphere.radius?gS(T)*E.sizeFactor:0,j=_e.expand(_e(),x.boundingSphere,z),Z=fs(j,_.aTransform.ref.value,w,0);return x.shaderData.update({lodLevels:E.lodLevels,sizeFactor:E.sizeFactor}),{dGeometryType:k.create("spheres"),uTexDim:x.shaderData.texDim,tPositionGroup:x.shaderData.positionGroup,boundingSphere:k.create(Z),invariantBoundingSphere:k.create(j),uInvariantBoundingSphere:k.create(nn.ofSphere(j)),...R,...T,...M,...N,...V,...F,...G,..._,padding:k.create(z),...rt.createValues(E,L),uSizeFactor:x.shaderData.sizeFactor,uDoubleSided:k.create(E.doubleSided),dIgnoreLight:k.create(E.ignoreLight),dXrayShaded:k.create("inverted"===E.xrayShaded?"inverted":!0===E.xrayShaded?"on":"off"),dTransparentBackfaces:k.create(E.transparentBackfaces),dSolidInterior:k.create(E.solidInterior),dClipPrimitive:k.create(E.clipPrimitive),dApproximate:k.create(E.approximate),uAlphaThickness:k.create(E.alphaThickness),uBumpFrequency:k.create(E.bumpFrequency),uBumpAmplitude:k.create(E.bumpAmplitude),lodLevels:x.shaderData.lodLevels,centerBuffer:x.centerBuffer,groupBuffer:x.groupBuffer}}function b(x,_){rt.updateRenderableState(x,_),x.opaque=x.opaque&&!_.xrayShaded,x.writeDepth=x.opaque}e.create=t,e.createEmpty=n,e.Params={...rt.Params,sizeFactor:C.Numeric(1,{min:0,max:10,step:.1}),doubleSided:C.Boolean(!1,rt.CustomQualityParamInfo),ignoreLight:C.Boolean(!1,rt.ShadingCategory),xrayShaded:C.Select(!1,[[!1,"Off"],[!0,"On"],["inverted","Inverted"]],rt.ShadingCategory),transparentBackfaces:C.Select("off",C.arrayToOptions(["off","on","opaque"]),rt.ShadingCategory),solidInterior:C.Boolean(!0,rt.ShadingCategory),clipPrimitive:C.Boolean(!1,{...rt.ShadingCategory,description:"Clip whole sphere instead of cutting it."}),approximate:C.Boolean(!1,{...rt.ShadingCategory,description:"Faster rendering, but has artifacts."}),alphaThickness:C.Numeric(0,{min:0,max:20,step:1},{...rt.ShadingCategory,description:"If not zero, adjusts alpha for radius."}),bumpFrequency:C.Numeric(0,{min:0,max:10,step:.1},rt.ShadingCategory),bumpAmplitude:C.Numeric(1,{min:0,max:5,step:.1},rt.ShadingCategory),lodLevels:C.ObjectList({minDistance:C.Numeric(0),maxDistance:C.Numeric(0),overlap:C.Numeric(0),stride:C.Numeric(0),scaleBias:C.Numeric(3,{min:.1,max:10,step:.1})},x=>`${x.stride}`,{...rt.CullingLodCategory,defaultValue:[]})},e.Utils={Params:e.Params,createEmpty:n,createValues:p,createValuesSimple:function m(x,_,S,A,E){const w=rt.createSimple(S,A,E),D={...C.getDefaultValues(e.Params),..._};return p(x,w.transform,w.locationIterator,w.theme,D)},updateValues:function h(x,_){rt.updateValues(x,_),k.updateIfChanged(x.uSizeFactor,_.sizeFactor),k.updateIfChanged(x.uDoubleSided,_.doubleSided),k.updateIfChanged(x.dIgnoreLight,_.ignoreLight),k.updateIfChanged(x.dXrayShaded,"inverted"===_.xrayShaded?"inverted":!0===_.xrayShaded?"on":"off"),k.updateIfChanged(x.dTransparentBackfaces,_.transparentBackfaces),k.updateIfChanged(x.dSolidInterior,_.solidInterior),k.updateIfChanged(x.dClipPrimitive,_.clipPrimitive),k.updateIfChanged(x.dApproximate,_.approximate),k.updateIfChanged(x.uAlphaThickness,_.alphaThickness),k.updateIfChanged(x.uBumpFrequency,_.bumpFrequency),k.updateIfChanged(x.uBumpAmplitude,_.bumpAmplitude);const S=u(x.lodLevels.ref.value);if(!function a(x,_){if(x.length!==_.length)return!1;for(let S=0,A=x.length;Src);m.namedFramebuffers[i]||(m.namedFramebuffers[i]=m.resources.framebuffer());const h=m.namedFramebuffers[i],[g,y]=f.geoTextureDim.ref.value,b=new Float32Array(g*y*4);h.bind(),f.vertexTexture.ref.value.attachFramebuffer(h,0),m.readPixels(0,0,g,y,b);const x=f.vertexCount,_=p.instanceCount.ref.value,S=mm(),A=S.position,E=b,w=p.aTransform.ref.value;return Mr(x,_,1,(I,R)=>(R<0?v.fromArray(A,E,4*I):v.transformMat4Offset(A,E,w,0,4*I,16*R),S))}};const i="texture-mesh";function s(f,p,m,h,g){const{instanceCount:y,groupCount:b}=m,_=bu(m,e.Utils.createPositionIterator(f,p),h.color),S=g.instanceGranularity?Vi(y,"instance"):Vi(y*b,"groupInstance"),A=Dp(),E=Ep(),w=Mp(),D=Pp(),I={drawCount:f.vertexCount,vertexCount:f.vertexCount,groupCount:b,instanceCount:y},R=_e.clone(f.boundingSphere),T=fs(R,p.aTransform.ref.value,y,0);return{dGeometryType:k.create("textureMesh"),uGeoTexDim:f.geoTextureDim,tPosition:f.vertexTexture,tGroup:f.groupTexture,tNormal:f.normalTexture,dVaryingGroup:f.varyingGroup,boundingSphere:k.create(T),invariantBoundingSphere:k.create(R),uInvariantBoundingSphere:k.create(nn.ofSphere(R)),..._,...S,...A,...E,...w,...D,...p,...rt.createValues(g,I),uDoubleSided:k.create(g.doubleSided),dFlatShaded:k.create(g.flatShaded),dFlipSided:k.create(g.flipSided),dIgnoreLight:k.create(g.ignoreLight),dXrayShaded:k.create("inverted"===g.xrayShaded?"inverted":!0===g.xrayShaded?"on":"off"),dTransparentBackfaces:k.create(g.transparentBackfaces),uBumpFrequency:k.create(g.bumpFrequency),uBumpAmplitude:k.create(g.bumpAmplitude),meta:k.create(f.meta)}}function d(f,p){rt.updateRenderableState(f,p),f.opaque=f.opaque&&!p.xrayShaded,f.writeDepth=f.opaque}}(xa||(xa={}));const Op={uDrawId:xe("i"),uModel:xe("m4"),uView:xe("m4"),uInvView:xe("m4"),uModelView:xe("m4"),uInvModelView:xe("m4"),uProjection:xe("m4"),uInvProjection:xe("m4"),uModelViewProjection:xe("m4"),uInvModelViewProjection:xe("m4"),uIsOrtho:xe("f"),uPixelRatio:xe("f"),uViewport:xe("v4"),uViewOffset:xe("v2"),uDrawingBufferSize:xe("v2"),uCameraPosition:xe("v3"),uCameraDir:xe("v3"),uCameraPlane:xe("v4"),uNear:xe("f"),uFar:xe("f"),uFog:xe("b"),uFogNear:xe("f"),uFogFar:xe("f"),uFogColor:xe("v3"),uTransparentBackground:xe("b"),uLightDirection:xe("v3[]"),uLightColor:xe("v3[]"),uAmbientColor:xe("v3"),uPickingAlphaThreshold:xe("f"),uInteriorDarkening:xe("f"),uInteriorColorFlag:xe("b"),uInteriorColor:xe("v3"),uHighlightColor:xe("v3"),uSelectColor:xe("v3"),uDimColor:xe("v3"),uHighlightStrength:xe("f"),uSelectStrength:xe("f"),uDimStrength:xe("f"),uMarkerPriority:xe("i"),uMarkerAverage:xe("f"),uXrayEdgeFalloff:xe("f"),uExposure:xe("f"),uRenderMask:xe("i"),uMarkingDepthTest:xe("b"),uMarkingType:xe("i"),uPickType:xe("i")},Lp={tDepth:jt("texture","depth","ushort","nearest"),tDpoitDepth:jt("texture","rg","float","nearest"),tDpoitFrontColor:jt("texture","rgba","float","nearest"),tDpoitBackColor:jt("texture","rgba","float","nearest")},Up={uObjectId:xe("i")},zHe={uColor:xe("v3","material"),uColorTexDim:xe("v2"),uColorGridDim:xe("v3"),uColorGridTransform:xe("v4"),tColor:jt("image-uint8","rgb","ubyte","nearest"),tPalette:jt("image-uint8","rgb","ubyte","nearest"),tColorGrid:jt("texture","rgb","ubyte","linear"),dColorType:Ft("string",["uniform","attribute","instance","group","groupInstance","vertex","vertexInstance","volume","volumeInstance","direct"]),dUsePalette:Ft("boolean")},bS={uSize:xe("f","material"),uSizeTexDim:xe("v2"),tSize:jt("image-uint8","rgb","ubyte","nearest"),dSizeType:Ft("string",["uniform","attribute","instance","group","groupInstance"]),uSizeFactor:xe("f","material")},GHe={uMarker:xe("f"),uMarkerTexDim:xe("v2"),tMarker:jt("image-uint8","alpha","ubyte","nearest"),markerAverage:ri("number"),markerStatus:ri("number"),dMarkerType:Ft("string",["instance","groupInstance"])},jHe={uOverpaintTexDim:xe("v2"),tOverpaint:jt("image-uint8","rgba","ubyte","nearest"),dOverpaint:Ft("boolean"),uOverpaintGridDim:xe("v3"),uOverpaintGridTransform:xe("v4"),tOverpaintGrid:jt("texture","rgba","ubyte","linear"),dOverpaintType:Ft("string",["instance","groupInstance","volumeInstance"]),uOverpaintStrength:xe("f","material")},HHe={uTransparencyTexDim:xe("v2"),tTransparency:jt("image-uint8","alpha","ubyte","nearest"),dTransparency:Ft("boolean"),transparencyAverage:ri("number"),uTransparencyGridDim:xe("v3"),uTransparencyGridTransform:xe("v4"),tTransparencyGrid:jt("texture","alpha","ubyte","linear"),dTransparencyType:Ft("string",["instance","groupInstance","volumeInstance"]),uTransparencyStrength:xe("f","material")},qHe={uSubstanceTexDim:xe("v2"),tSubstance:jt("image-uint8","rgba","ubyte","nearest"),dSubstance:Ft("boolean"),uSubstanceGridDim:xe("v3"),uSubstanceGridTransform:xe("v4"),tSubstanceGrid:jt("texture","rgba","ubyte","linear"),dSubstanceType:Ft("string",["instance","groupInstance","volumeInstance"]),uSubstanceStrength:xe("f","material")},WHe={uClippingTexDim:xe("v2"),tClipping:jt("image-uint8","alpha","ubyte","nearest"),dClipping:Ft("boolean"),dClippingType:Ft("string",["instance","groupInstance"])},Vp={dGeometryType:Ft("string",["cylinders","directVolume","image","lines","mesh","points","spheres","text","textureMesh"]),...zHe,...GHe,...jHe,...HHe,...qHe,...WHe,dLightCount:Ft("number"),dColorMarker:Ft("boolean"),dClipObjectCount:Ft("number"),dClipVariant:Ft("string",["instance","pixel"]),uClipObjectType:xe("i[]","material"),uClipObjectInvert:xe("b[]","material"),uClipObjectPosition:xe("v3[]","material"),uClipObjectRotation:xe("v4[]","material"),uClipObjectScale:xe("v3[]","material"),aInstance:Ar("float32",1,1),aTransform:Ar("float32",16,1),uAlpha:xe("f","material"),uMetalness:xe("f","material"),uRoughness:xe("f","material"),uBumpiness:xe("f","material"),uVertexCount:xe("i"),uInstanceCount:xe("i"),uGroupCount:xe("i"),uInvariantBoundingSphere:xe("v4"),uLod:xe("v4"),drawCount:ri("number"),instanceCount:ri("number"),alpha:ri("number"),matrix:ri("m4"),transform:ri("float32"),extraTransform:ri("float32"),hasReflection:ri("boolean"),instanceGranularity:ri("boolean"),boundingSphere:ri("sphere"),invariantBoundingSphere:ri("sphere"),instanceGrid:ri("instanceGrid")},ps="\nprecision highp float;\n\nattribute vec2 aPosition;\nuniform vec2 uQuadScale;\n\nvoid main(void) {\n vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n",YHe=pa(),KHe=Object.keys({color:"",pick:"",depth:"",marking:""}),ZHe=Object.keys({compute:""});function I5(e,t,n,r,i){return n={...n,dRenderVariant:k.create(t)},void 0===i.dRenderVariant&&Object.defineProperty(i,"dRenderVariant",{value:Ft("string")}),e.resources.program(n,r,i)}function T5(e,t){if("color"===e)switch(t){case"blended":return"colorBlended";case"wboit":return"colorWboit";case"dpoit":return"colorDpoit"}return e}function zp(e,t,n,r,i,o,s){return Hie(e,t,n,r,i,o,KHe,s)}function zi(e,t,n,r,i,o=-1){return Hie(e,t,n,r,i,o,ZHe,void 0)}function Hie(e,t,n,r,i,o,s,a){const c=YHe(),{stats:u,state:l,resources:d}=e,{instancedArrays:f,vertexArrayObject:p,multiDrawInstancedBaseVertexBaseInstance:m,drawInstancedBaseVertexBaseInstance:h}=e.extensions;i.uVertexCount&&!e.extensions.noNonInstancedActiveAttribs&&(i.aVertex=k.create(Tc(new Float32Array(i.uVertexCount.ref.value))),r.aVertex=Ar("float32",1,0));const{attributeValues:g,defineValues:y,textureValues:b,materialTextureValues:x,uniformValues:_,materialUniformValues:S,bufferedUniformValues:A}=function UHe(e,t){const n={},r={},i={},o={},s={},a={},c={};return Object.keys(e).forEach(u=>{const l=e[u];"attribute"===l.type&&(n[u]=t[u]),"define"===l.type&&(r[u]=t[u]),"texture"===l.type&&void 0!==t[u]&&("material"===l.variant?o[u]=t[u]:i[u]=t[u]),"uniform"===l.type&&void 0!==t[u]&&("material"===l.variant?a[u]=t[u]:"buffered"===l.variant?c[u]=t[u]:s[u]=t[u])}),{attributeValues:n,defineValues:r,textureValues:i,materialTextureValues:o,uniformValues:s,materialUniformValues:a,bufferedUniformValues:c}}(r,i),E=Object.entries(_),w=Object.entries(S),D=Object.entries(A),I=Object.entries(function HGe(e){const t={};return Object.keys(e).forEach(n=>{t[n]=k.create(Jl(e[n].ref.value))}),t}(A)),R=Object.entries(y),T=function VHe(e){const t={};return Object.keys(e).forEach(n=>{t[n]=e[n].ref.version}),t}(i),M=function XHe(e,t){const{gl:n}=e;switch(t){case"points":return n.POINTS;case"lines":return n.LINES;case"line-strip":return n.LINE_STRIP;case"line-loop":return n.LINE_LOOP;case"triangles":return n.TRIANGLES;case"triangle-strip":return n.TRIANGLE_STRIP;case"triangle-fan":return n.TRIANGLE_FAN}}(e,t),N={};for(const W of s)N[W]=I5(e,T5(W,a),y,n,r);const V=Kre(e,r,b),F=Kre(e,r,x),G=function ZGe(e,t,n){const r=[];return Object.keys(t).forEach(i=>{const o=t[i];"attribute"===o.type&&(r[r.length]=[i,e.resources.attribute(n[i].ref.value,o.itemSize,o.divisor)])}),r}(e,r,g),L=[];for(let W=0,Q=G.length;WN[W],setTransparency:W=>{if(W!==a){a=W;for(const Q of s)N[Q].destroy(),N[Q]=I5(e,T5(Q,a),y,n,r)}},render:(W,Q,fe)=>{if(0===$||0===ee)return;const X=N[W];if(X.id===H&&l.currentRenderItemId===c)X.setUniforms(E),X.bindTextures(V,Q);else{const J=Z[W];(X.id!==l.currentProgramId||X.id!==H||-1===o||o!==l.currentMaterialId)&&(X.id!==l.currentProgramId&&X.use(),X.setUniforms(w),X.bindTextures(F,Q+V.length),l.currentMaterialId=o,H=X.id),X.setUniforms(E),X.setUniforms(I),X.bindTextures(V,Q),J?(J.bind(),z&&z.bind()):(z&&z.bind(),X.bindAttributes(G)),l.currentRenderItemId=c}if(un)try{mD(e.gl)}catch(J){throw new Error(`Framebuffer error rendering item id ${c}: '${J}'`)}if(fe){for(const J of fe)if(0!==J.count){if(X.setUniforms(J.uniforms),m)z?m.multiDrawElementsInstancedBaseVertexBaseInstance(M,J.counts,0,z._dataType,J.offsets,0,J.instanceCounts,0,J.baseVertices,0,J.baseInstances,0,J.count):m.multiDrawArraysInstancedBaseInstance(M,J.firsts,0,J.counts,0,J.instanceCounts,0,J.baseInstances,0,J.count);else if(h)if(z)for(let ce=0;ce0&&(X.uniform("uDrawId",ce),h.drawElementsInstancedBaseVertexBaseInstance(M,J.counts[ce],z._dataType,J.offsets[ce],J.instanceCounts[ce],J.baseVertices[ce],J.baseInstances[ce]));else for(let ce=0;ce0&&(X.uniform("uDrawId",ce),h.drawArraysInstancedBaseInstance(M,J.firsts[ce],J.counts[ce],J.instanceCounts[ce],J.baseInstances[ce]));else if(z)for(let ce=0;ce0&&(X.uniform("uDrawId",ce),X.offsetAttributes(L,J.baseInstances[ce]),f.drawElementsInstanced(M,J.counts[ce],z._dataType,J.offsets[ce],J.instanceCounts[ce]));else for(let ce=0;ce0&&(X.uniform("uDrawId",ce),X.offsetAttributes(L,J.baseInstances[ce]),f.drawArraysInstanced(M,0,J.counts[ce],J.instanceCounts[ce]));if(lt){m?u.calls.multiDrawInstancedBase+=1:h?u.calls.drawInstancedBase+=J.count:u.calls.drawInstanced+=J.count;for(let ce=0;ce{if(function JHe(e){e.attributes=!1,e.defines=!1,e.elements=!1,e.textures=!1}(q),i.aVertex){const W=i.uVertexCount.ref.value;i.aVertex.ref.value.length=J.ref.value.length)X.updateSubData(J.ref.value,0,X.length);else{X.destroy();const{itemSize:ce,divisor:be}=r[fe];G[W][1]=d.attribute(J.ref.value,ce,be),q.attributes=!0}T[fe]=J.ref.version}}if(z&&i.elements.ref.version!==T.elements&&(z.length>=i.elements.ref.value.length?z.updateSubData(i.elements.ref.value,0,z.length):(z.destroy(),z=d.elements(i.elements.ref.value),q.elements=!0),T.elements=i.elements.ref.version),q.attributes||q.defines||q.elements)for(const W of s){const Q=Z[W];Q&&Q.destroy(),Z[W]=p?d.vertexArray(N[W],G,z):null}for(let W=0,Q=V.length;W{if(!O){for(const W of s){N[W].destroy();const Q=Z[W];Q&&Q.destroy()}V.forEach(([W,Q])=>{"texture"!==r[W].kind&&Q.destroy()}),F.forEach(([W,Q])=>{"texture"!==r[W].kind&&Q.destroy()}),G.forEach(([W,Q])=>Q.destroy()),z&&z.destroy(),u.drawCount-=$,u.instanceCount-=ee,u.instancedDrawCount-=ee*$,O=!0}}}}function Gi(){return Gi.create(v.create(1,0,0),0)}function p0(){return p0.create(Gi(),Gi(),Gi(),Gi(),Gi(),Gi())}!function(e){function n(h,g){return v.copy(h.normal,g.normal),h.constant=g.constant,h}function c(h,g,y){return v.copy(h.normal,g),h.constant=-v.dot(h.normal,y),h}e.create=function t(h,g){return{normal:h,constant:g}},e.copy=n,e.clone=function r(h){return n(e(),h)},e.normalize=function i(h,g){const y=1/v.magnitude(g.normal);return v.scale(h.normal,g.normal,y),h.constant=g.constant*y,h},e.negate=function o(h,g){return v.negate(h.normal,g.normal),h.constant=-g.constant,h},e.toArray=function s(h,g,y){return v.toArray(h.normal,g,y),g[y+3]=h.constant,g},e.fromArray=function a(h,g,y){return v.fromArray(h.normal,g,y),h.constant=g[y+3],h},e.fromNormalAndCoplanarPoint=c,e.fromCoplanarPoints=function u(h,g,y,b){return c(h,v.triangleNormal(v(),g,y,b),g),h};const l=v();function f(h,g){return v.dot(h.normal,g)+h.constant}e.setUnnormalized=function d(h,g,y,b,x){v.set(l,g,y,b);const _=1/v.magnitude(l);return v.scale(h.normal,l,_),h.constant=x*_,h},e.distanceToPoint=f,e.distanceToSpher3D=function p(h,g){return f(h,g.center)-g.radius},e.projectPoint=function m(h,g,y){return v.scaleAndAdd(h,h,g.normal,-f(g,y))}}(Gi||(Gi={})),function(e){function n(u,l){for(let d=0;d<6;++d)Gi.copy(u[d],l[d]);return u}e.create=function t(u,l,d,f,p,m){return[u,l,d,f,p,m]},e.copy=n,e.clone=function r(u){return n(e(),u)},e.fromProjectionMatrix=function i(u,l){const d=l[0],f=l[1],p=l[2],m=l[3],h=l[4],g=l[5],y=l[6],b=l[7],x=l[8],_=l[9],S=l[10],A=l[11],E=l[12],w=l[13],D=l[14],I=l[15];return Gi.setUnnormalized(u[0],m-d,b-h,A-x,I-E),Gi.setUnnormalized(u[1],m+d,b+h,A+x,I+E),Gi.setUnnormalized(u[2],m+f,b+g,A+_,I+w),Gi.setUnnormalized(u[3],m-f,b-g,A-_,I-w),Gi.setUnnormalized(u[4],m-p,b-y,A-S,I-D),Gi.setUnnormalized(u[5],m+p,b+y,A+S,I+D),u},e.intersectsSphere3D=function o(u,l){const d=l.center,f=-l.radius;for(let p=0;p<6;++p)if(Gi.distanceToPoint(u[p],d)0?l.max[0]:l.min[0],s[1]=f.normal[1]>0?l.max[1]:l.min[1],s[2]=f.normal[2]>0?l.max[2]:l.min[2],Gi.distanceToPoint(f,s)<0)return!1}return!0},e.containsPoint=function c(u,l){for(let d=0;d<6;++d)if(Gi.distanceToPoint(u[d],l)<0)return!1;return!0}}(p0||(p0={}));const ND=Gi.distanceToPoint,FD=p0.intersectsSphere3D,BD=_e.fromArray,qie=pa();function D5(e,t){return t&&t.instanceCounts.length>=e?t:{firsts:new Int32Array(e),counts:new Int32Array(e),offsets:new Int32Array(e),instanceCounts:new Int32Array(e),baseVertices:new Int32Array(e),baseInstances:new Uint32Array(e),count:0,uniforms:[]}}function Gp(e,t,n){const r=qie();let i=D5(0);const o=[];let s=!1,a=-1;const c=_e(),u=()=>{var l;const d=null===(l=t.lodLevels)||void 0===l?void 0:l.ref.value;if(d&&d.length>0){const{cellCount:f}=t.instanceGrid.ref.value;o.length=d.length;for(let p=0,m=d.length;p{var m,h;if(s=!1,0===t.drawCount.ref.value||0===t.instanceCount.ref.value||!t.instanceGrid.ref.value)return;const{cellOffsets:g,cellSpheres:y,cellCount:b,batchOffsets:x,batchSpheres:_,batchCount:S,batchCell:A,batchSize:E}=t.instanceGrid.ref.value,[w,D]=t.uLod.ref.value,I=0!==w||0!==D,R=2*E,T=null===(m=t.lodLevels)||void 0===m?void 0:m.ref.value;if(T&&T.length>0){if((null===(h=t.lodLevels)||void 0===h?void 0:h.ref.version)!==a)u();else for(let M=0,N=T.length;MD))lt&&(p.culled.lod+=g[A[V-1]+1]-g[A[N]]);else if(FD(d,c))if(null!==f&&f(c))lt&&(p.culled.occlusion+=g[A[V-1]+1]-g[A[N]]);else for(let L=N;LD))lt&&(p.culled.lod+=$);else if(FD(d,c))if(null!==f&&ee-c.radiusT[q][1])continue;const H=o[q],W=H.count;W>0&&H.baseInstances[W-1]+H.instanceCounts[W-1]===j&&H.counts[W-1]===T[q][3]?H.instanceCounts[W-1]+=$:(H.counts[W]=T[q][3],H.instanceCounts[W]=$,H.baseInstances[W]=j,H.count+=1)}else lt&&(p.culled.frustum+=$)}else lt&&(p.culled.frustum+=g[A[V-1]+1]-g[A[N]])}}else{i=D5(b,i);const{baseInstances:M,instanceCounts:N,counts:V}=i;let F=0;for(let G=0;GD){lt&&(p.culled.lod+=g[A[z-1]+1]-g[A[L]]);continue}}if(!FD(d,c)){lt&&(p.culled.frustum+=g[A[z-1]+1]-g[A[L]]);continue}if(null!==f&&f(c)){lt&&(p.culled.occlusion+=g[A[z-1]+1]-g[A[L]]);continue}for(let Z=L;ZD)?lt&&(p.culled.lod+=O):FD(d,c)?null!==f&&H-c.radius0&&M[F-1]+N[F-1]===ee?N[F-1]+=O:(V[F]=t.drawCount.ref.value,N[F]=O,M[F]=ee,F+=1):lt&&(p.culled.frustum+=O)}}}i.count=F,o.length=1,o[0]=i,o[0].uniforms.length=0}s=!0},uncull:()=>{s=!1},render:(l,d)=>{t.uAlpha&&t.alpha&&k.updateIfChanged(t.uAlpha,os(t.alpha.ref.value*n.alphaFactor,0,1)),e.render(l,d,s?o:void 0)},getProgram:l=>e.getProgram(l),setTransparency:l=>e.setTransparency(l),update:()=>{e.update(),u()},dispose:()=>e.destroy()}}function ji(e,t){return{id:qie(),values:t,render:()=>e.render("compute",0),update:()=>e.update(),dispose:()=>e.destroy()}}const E5=new Float32Array([1,1,-1,1,-1,-1,-1,-1,1,-1,1,1]),vo={drawCount:ri("number"),instanceCount:ri("number"),aPosition:Ar("float32",2,0),uQuadScale:xe("v2")},_o={drawCount:k.create(6),instanceCount:k.create(1),aPosition:k.create(E5),uQuadScale:k.create(Me.create(1,1))},eqe={...vo,tColor:jt("texture","rgba","ubyte","nearest"),uTexSize:xe("v2")},tqe=Br("copy",ps,"\nprecision highp float;\nprecision highp sampler2D;\n\nuniform sampler2D tColor;\nuniform vec2 uTexSize;\n\nvoid main() {\n vec2 coords = gl_FragCoord.xy / uTexSize;\n gl_FragColor = texture2D(tColor, coords);\n}\n");function Iv(e,t){const n={..._o,tColor:k.create(t),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight()))},r={...eqe};return ji(zi(e,"triangles",tqe,r,n),n)}const Wie=new Uint32Array([0,1,2,1,3,2]),rqe=new Float32Array([0,1,0,0,1,1,1,0]),$ie={nearest:"Nearest",catmulrom:"Catmulrom (Cubic)",mitchell:"Mitchell (Cubic)",bspline:"B-Spline (Cubic)"},iqe=Object.keys($ie);var jp,oc,Zo;!function(e){function t(f,p,m,h){return h?function i(f,p,m,h){const g=f.width,y=f.height;return k.update(h.imageTexture,f),k.update(h.imageTextureDim,Me.set(h.imageTextureDim.ref.value,g,y)),k.update(h.cornerBuffer,p),k.update(h.groupTexture,m),h}(f,p,m,h):function r(f,p,m){const h=_e();let g=-1;const y=f.width,b=f.height,x={kind:"image",imageTexture:k.create(f),imageTextureDim:k.create(Me.create(y,b)),cornerBuffer:k.create(p),groupTexture:k.create(m),get boundingSphere(){const _=function n(f){return ha([f.cornerBuffer.ref.version])}(x);if(_!==g){const S=function oqe(e){const t=v(),n=[];for(let o=0,s=e.length;or&&(r=s)}const i=_e.create(t,r);return _e.setExtrema(i,n),i}(x.cornerBuffer.ref.value);_e.copy(h,S),g=_}return h}};return x}(f,p,m)}function o(f){return t(Po(0,4,Uint8Array),f?f.cornerBuffer.ref.value:new Float32Array(24),Po(0,4,Uint8Array),f)}function s(f,p,m,h,g){const{instanceCount:y,groupCount:b}=m,_=bu(m,e.Utils.createPositionIterator(f,p),h.color),S=g.instanceGranularity?Vi(y,"instance"):Vi(y*b,"groupInstance"),A=Dp(),E=Ep(),w=Mp(),D=Pp(),I={drawCount:Wie.length,vertexCount:E5.length/3,groupCount:b,instanceCount:y},R=_e.clone(f.boundingSphere),T=fs(R,p.aTransform.ref.value,y,0);return{dGeometryType:k.create("image"),..._,...S,...A,...E,...w,...D,...p,...rt.createValues(g,I),aPosition:f.cornerBuffer,aUv:k.create(rqe),elements:k.create(Wie),aGroup:k.create(Tc(new Float32Array(4))),boundingSphere:k.create(T),invariantBoundingSphere:k.create(R),uInvariantBoundingSphere:k.create(nn.ofSphere(R)),dInterpolation:k.create(g.interpolation),uImageTexDim:f.imageTextureDim,tImageTex:f.imageTexture,tGroupTex:f.groupTexture}}e.create=t,e.createEmpty=o,e.Params={...rt.Params,interpolation:C.Select("bspline",C.objectToOptions($ie))},e.Utils={Params:e.Params,createEmpty:o,createValues:s,createValuesSimple:function a(f,p,m,h,g){const y=rt.createSimple(m,h,g),b={...C.getDefaultValues(e.Params),...p};return s(f,y.transform,y.locationIterator,y.theme,b)},updateValues:function c(f,p){rt.updateValues(f,p),k.updateIfChanged(f.dInterpolation,p.interpolation)},updateBoundingSphere:function u(f,p){const m=_e.clone(p.boundingSphere),h=fs(m,f.aTransform.ref.value,f.instanceCount.ref.value,0);_e.equals(h,f.boundingSphere.ref.value)||k.update(f.boundingSphere,h),_e.equals(m,f.invariantBoundingSphere.ref.value)||(k.update(f.invariantBoundingSphere,m),k.update(f.uInvariantBoundingSphere,nn.fromSphere(f.uInvariantBoundingSphere.ref.value,m)))},createRenderableState:function l(f){const p=rt.createRenderableState(f);return p.opaque=!1,p},updateRenderableState:function d(f,p){rt.updateRenderableState(f,p),f.opaque=!1},createPositionIterator:()=>Mr(1,1,1,()=>rc)}}(jp||(jp={})),function(e){function t(m,h,g,y,b,x,_,S,A,E){return E?function o(m,h,g,y,b,x,_,S,A,E){return A>E.cylinderCount&&(k.update(E.mappingBuffer,m),k.update(E.indexBuffer,h)),E.cylinderCount=A,k.update(E.groupBuffer,g),k.update(E.startBuffer,y),k.update(E.endBuffer,b),k.update(E.scaleBuffer,x),k.update(E.capBuffer,_),k.update(E.colorModeBuffer,S),E}(m,h,g,y,b,x,_,S,A,E):function i(m,h,g,y,b,x,_,S,A){const E=_e();let w,D=-1,I=-1;const R={kind:"cylinders",cylinderCount:A,mappingBuffer:k.create(m),indexBuffer:k.create(h),groupBuffer:k.create(g),startBuffer:k.create(y),endBuffer:k.create(b),scaleBuffer:k.create(x),capBuffer:k.create(_),colorModeBuffer:k.create(S),get boundingSphere(){const T=r(R);if(T!==D){const M=Ip(R.startBuffer.ref.value,6*R.cylinderCount,6),N=Ip(R.endBuffer.ref.value,6*R.cylinderCount,6);_e.expandBySphere(E,M,N),D=T}return E},get groupMapping(){return R.groupBuffer.ref.version!==I&&(w=gv(R.groupBuffer.ref.value,R.cylinderCount,6),I=R.groupBuffer.ref.version),w},setBoundingSphere(T){_e.copy(E,T),D=r(R)}};return R}(m,h,g,y,b,x,_,S,A)}function n(m){return t(m?m.mappingBuffer.ref.value:new Float32Array(0),m?m.indexBuffer.ref.value:new Uint32Array(0),m?m.groupBuffer.ref.value:new Float32Array(0),m?m.startBuffer.ref.value:new Float32Array(0),m?m.endBuffer.ref.value:new Float32Array(0),m?m.scaleBuffer.ref.value:new Float32Array(0),m?m.capBuffer.ref.value:new Float32Array(0),m?m.colorModeBuffer.ref.value:new Float32Array(0),0,m)}function r(m){return ha([m.cylinderCount,m.mappingBuffer.ref.version,m.indexBuffer.ref.version,m.groupBuffer.ref.version,m.startBuffer.ref.version,m.endBuffer.ref.version,m.scaleBuffer.ref.version,m.capBuffer.ref.version,m.colorModeBuffer.ref.version])}function a(m,h){const g=6*m.cylinderCount,y=h.instanceCount.ref.value,b=mm(),x=b.position,_=m.startBuffer.ref.value,S=m.endBuffer.ref.value,A=h.aTransform.ref.value;return Mr(g,y,2,(w,D)=>{const I=w%6==0?_:S;return D<0?v.fromArray(x,I,3*w):v.transformMat4Offset(x,I,A,0,3*w,16*D),b})}function c(m,h,g,y,b){const{instanceCount:x,groupCount:_}=g,A=bu(g,a(m,h),y.color),E=kp(g,y.size),w=b.instanceGranularity?Vi(x,"instance"):Vi(x*_,"groupInstance"),D=Dp(),I=Ep(),R=Mp(),T=Pp(),M={drawCount:4*m.cylinderCount*3,vertexCount:6*m.cylinderCount,groupCount:_,instanceCount:x},N=gS(E)*b.sizeFactor,V=_e.clone(m.boundingSphere),F=fs(V,h.aTransform.ref.value,x,0);return{dGeometryType:k.create("cylinders"),aMapping:m.mappingBuffer,aGroup:m.groupBuffer,aStart:m.startBuffer,aEnd:m.endBuffer,aScale:m.scaleBuffer,aCap:m.capBuffer,aColorMode:m.colorModeBuffer,elements:m.indexBuffer,boundingSphere:k.create(F),invariantBoundingSphere:k.create(V),uInvariantBoundingSphere:k.create(nn.ofSphere(V)),...A,...E,...w,...D,...I,...R,...T,...h,padding:k.create(N),...rt.createValues(b,M),uSizeFactor:k.create(b.sizeFactor*b.sizeAspectRatio),uDoubleSided:k.create(b.doubleSided),dIgnoreLight:k.create(b.ignoreLight),dXrayShaded:k.create("inverted"===b.xrayShaded?"inverted":!0===b.xrayShaded?"on":"off"),dTransparentBackfaces:k.create(b.transparentBackfaces),dSolidInterior:k.create(b.solidInterior),uBumpFrequency:k.create(b.bumpFrequency),uBumpAmplitude:k.create(b.bumpAmplitude),dDualColor:k.create("interpolate"===b.colorMode)}}function p(m,h){rt.updateRenderableState(m,h),m.opaque=m.opaque&&!h.xrayShaded,m.writeDepth=m.opaque}e.create=t,e.createEmpty=n,e.transform=function s(m,h){const g=m.startBuffer.ref.value;l0(h,g,0,6*m.cylinderCount),k.update(m.startBuffer,g);const y=m.endBuffer.ref.value;l0(h,y,0,6*m.cylinderCount),k.update(m.endBuffer,y)},e.Params={...rt.Params,sizeFactor:C.Numeric(1,{min:0,max:10,step:.1}),sizeAspectRatio:C.Numeric(1,{min:0,max:3,step:.01}),doubleSided:C.Boolean(!1,rt.CustomQualityParamInfo),ignoreLight:C.Boolean(!1,rt.ShadingCategory),xrayShaded:C.Select(!1,[[!1,"Off"],[!0,"On"],["inverted","Inverted"]],rt.ShadingCategory),transparentBackfaces:C.Select("off",C.arrayToOptions(["off","on","opaque"]),rt.ShadingCategory),solidInterior:C.Boolean(!0,rt.ShadingCategory),bumpFrequency:C.Numeric(0,{min:0,max:10,step:.1},rt.ShadingCategory),bumpAmplitude:C.Numeric(1,{min:0,max:5,step:.1},rt.ShadingCategory),colorMode:C.Select("default",C.arrayToOptions(["default","interpolate"]),rt.ShadingCategory)},e.Utils={Params:e.Params,createEmpty:n,createValues:c,createValuesSimple:function u(m,h,g,y,b){const x=rt.createSimple(g,y,b),_={...C.getDefaultValues(e.Params),...h};return c(m,x.transform,x.locationIterator,x.theme,_)},updateValues:function l(m,h){rt.updateValues(m,h),k.updateIfChanged(m.uSizeFactor,h.sizeFactor*h.sizeAspectRatio),k.updateIfChanged(m.uDoubleSided,h.doubleSided),k.updateIfChanged(m.dIgnoreLight,h.ignoreLight),k.updateIfChanged(m.dXrayShaded,"inverted"===h.xrayShaded?"inverted":!0===h.xrayShaded?"on":"off"),k.updateIfChanged(m.dTransparentBackfaces,h.transparentBackfaces),k.updateIfChanged(m.dSolidInterior,h.solidInterior),k.updateIfChanged(m.uBumpFrequency,h.bumpFrequency),k.updateIfChanged(m.uBumpAmplitude,h.bumpAmplitude),k.updateIfChanged(m.dDualColor,"interpolate"===h.colorMode)},updateBoundingSphere:function d(m,h){const g=_e.clone(h.boundingSphere),y=fs(g,m.aTransform.ref.value,m.instanceCount.ref.value,0);_e.equals(y,m.boundingSphere.ref.value)||k.update(m.boundingSphere,y),_e.equals(g,m.invariantBoundingSphere.ref.value)||(k.update(m.invariantBoundingSphere,g),k.update(m.uInvariantBoundingSphere,nn.fromSphere(m.uInvariantBoundingSphere.ref.value,g)))},createRenderableState:function f(m){const h=rt.createRenderableState(m);return p(h,m),h},updateRenderableState:p,createPositionIterator:a}}(oc||(oc={})),function(e){function t(s){switch(s.kind){case"mesh":return 3*s.triangleCount;case"points":return s.pointCount;case"spheres":return 2*s.sphereCount*3;case"cylinders":return 4*s.cylinderCount*3;case"text":return 2*s.charCount*3;case"lines":return 2*s.lineCount*3;case"direct-volume":return 36;case"image":return 6;case"texture-mesh":return s.vertexCount}}e.getDrawCount=t,e.getVertexCount=function n(s){switch(s.kind){case"mesh":case"texture-mesh":return s.vertexCount;case"points":return s.pointCount;case"spheres":return 6*s.sphereCount;case"cylinders":return 6*s.cylinderCount;case"text":return 4*s.charCount;case"lines":return 4*s.lineCount;case"direct-volume":const[a,c,u]=s.gridDimension.ref.value;return a*c*u;case"image":return 4}},e.getGroupCount=function r(s){switch(s.kind){case"mesh":case"points":case"spheres":case"cylinders":case"text":case"lines":return 0===t(s)?0:Xd(s.groupBuffer.ref.value)+1;case"direct-volume":return 1;case"image":return Xd(s.groupTexture.ref.value.array)+1;case"texture-mesh":return s.groupCount}},e.getUtils=function i(s){switch(s.kind){case"mesh":return Nt.Utils;case"points":return ym.Utils;case"spheres":return fl.Utils;case"cylinders":return oc.Utils;case"text":return vu.Utils;case"lines":return di.Utils;case"direct-volume":return _u.Utils;case"image":return jp.Utils;case"texture-mesh":return xa.Utils}},e.getGranularity=function o(s,a){return"instance"===a&&s.nonInstanceable?"group":a}}(Zo||(Zo={}));const Yie={};function R5(e,t){return{factory:R5,granularity:"groupInstance",size:n=>ra.isLocation(n)?n.shape.getSize(n.group,n.instance):1,props:t,description:"Assigns sizes as defined by the shape object."}}const uqe={name:"shape-group",label:"Shape Group",category:"",factory:R5,getParams:function cqe(e){return Yie},defaultValues:C.getDefaultValues(Yie),isApplicable:e=>!!e.shape},lqe=st(13421772),Xie={};function k5(e,t){return{factory:k5,granularity:"groupInstance",color:n=>ra.isLocation(n)?n.shape.getColor(n.group,n.instance):lqe,props:t,description:"Assigns colors as defined by the shape object."}}const pqe={name:"shape-group",label:"Shape Group",category:ni.Misc,factory:k5,getParams:function fqe(e){return Xie},defaultValues:C.getDefaultValues(Xie),isApplicable:e=>!!e.shape},hqe={...Vp,aPosition:Ar("float32",3,0),elements:Av("uint32"),uBboxMin:xe("v3"),uBboxMax:xe("v3"),uBboxSize:xe("v3"),uMaxSteps:xe("i"),uStepScale:xe("f"),uJumpLength:xe("f"),uTransform:xe("m4"),uGridDim:xe("v3"),tTransferTex:jt("image-uint8","alpha","ubyte","linear"),uTransferScale:xe("f","material"),dGridTexType:Ft("string",["2d","3d"]),uGridTexDim:xe("v3"),tGridTex:jt("texture","rgba","ubyte","linear"),uGridStats:xe("v4"),uCellDim:xe("v3"),uCartnToUnit:xe("m4"),uUnitToCartn:xe("m4"),dPackedGroup:Ft("boolean"),dAxisOrder:Ft("string",["012","021","102","120","201","210"]),dIgnoreLight:Ft("boolean"),dXrayShaded:Ft("string",["off","on","inverted"])},gqe={...Vp,aGroup:Ar("float32",1,0),aPosition:Ar("float32",3,0),aNormal:Ar("float32",3,0),elements:Av("uint32"),dVaryingGroup:Ft("boolean"),dFlatShaded:Ft("boolean"),uDoubleSided:xe("b","material"),dFlipSided:Ft("boolean"),dIgnoreLight:Ft("boolean"),dXrayShaded:Ft("string",["off","on","inverted"]),dTransparentBackfaces:Ft("string",["off","on","opaque"]),uBumpFrequency:xe("f","material"),uBumpAmplitude:xe("f","material"),meta:ri("unknown")},bqe={...Vp,...bS,aGroup:Ar("float32",1,0),aPosition:Ar("float32",3,0),dPointSizeAttenuation:Ft("boolean"),dPointStyle:Ft("string",["square","circle","fuzzy"])},_qe={...Vp,...bS,aGroup:Ar("float32",1,0),aMapping:Ar("float32",2,0),aStart:Ar("float32",3,0),aEnd:Ar("float32",3,0),elements:Av("uint32"),dLineSizeAttenuation:Ft("boolean"),uDoubleSided:xe("b","material"),dFlipSided:Ft("boolean")},Sqe={...Vp,...bS,uTexDim:xe("v2"),tPositionGroup:jt("image-float32","rgba","float","nearest"),padding:ri("number"),uDoubleSided:xe("b","material"),dIgnoreLight:Ft("boolean"),dXrayShaded:Ft("string",["off","on","inverted"]),dTransparentBackfaces:Ft("string",["off","on","opaque"]),dSolidInterior:Ft("boolean"),dClipPrimitive:Ft("boolean"),dApproximate:Ft("boolean"),uAlphaThickness:xe("f"),uBumpFrequency:xe("f","material"),uBumpAmplitude:xe("f","material"),lodLevels:ri("unknown"),centerBuffer:ri("float32"),groupBuffer:ri("float32")},wqe={...Vp,...bS,aGroup:Ar("float32",1,0),aPosition:Ar("float32",3,0),aMapping:Ar("float32",2,0),aDepth:Ar("float32",1,0),elements:Av("uint32"),aTexCoord:Ar("float32",2,0),tFont:jt("image-uint8","alpha","ubyte","linear"),padding:ri("number"),uBorderWidth:xe("f","material"),uBorderColor:xe("v3","material"),uOffsetX:xe("f","material"),uOffsetY:xe("f","material"),uOffsetZ:xe("f","material"),uBackgroundColor:xe("v3","material"),uBackgroundOpacity:xe("f","material")},Iqe={...Vp,uGeoTexDim:xe("v2","buffered"),tPosition:jt("texture","rgb","float","nearest"),tGroup:jt("texture","alpha","float","nearest"),tNormal:jt("texture","rgb","float","nearest"),dVaryingGroup:Ft("boolean"),dFlatShaded:Ft("boolean"),uDoubleSided:xe("b","material"),dFlipSided:Ft("boolean"),dIgnoreLight:Ft("boolean"),dXrayShaded:Ft("string",["off","on","inverted"]),dTransparentBackfaces:Ft("string",["off","on","opaque"]),uBumpFrequency:xe("f","material"),uBumpAmplitude:xe("f","material"),meta:ri("unknown")},Dqe={...Vp,aGroup:Ar("float32",1,0),aPosition:Ar("float32",3,0),aUv:Ar("float32",2,0),elements:Av("uint32"),uImageTexDim:xe("v2"),tImageTex:jt("image-uint8","rgba","ubyte","nearest"),tGroupTex:jt("image-uint8","rgba","ubyte","nearest"),dInterpolation:Ft("string",iqe)},Pqe={...Vp,...bS,aGroup:Ar("float32",1,0),aStart:Ar("float32",3,0),aEnd:Ar("float32",3,0),aMapping:Ar("float32",3,0),aScale:Ar("float32",1,0),aCap:Ar("float32",1,0),aColorMode:Ar("float32",1,0),elements:Av("uint32"),padding:ri("number"),uDoubleSided:xe("b","material"),dIgnoreLight:Ft("boolean"),dXrayShaded:Ft("string",["off","on","inverted"]),dTransparentBackfaces:Ft("string",["off","on","opaque"]),dSolidInterior:Ft("boolean"),uBumpFrequency:xe("f","material"),uBumpAmplitude:xe("f","material"),dDualColor:Ft("boolean")},Rqe=pa(0,2147483647),Hp=pa(0,2147483647);function Dv(e,t,n,r){return{id:Rqe(),type:e,values:t,state:n,materialId:r}}var qn,ra;function Kie(e){const t=e&&e.getElement("vertex"),n=e&&e.getElement("material"),r={group:"",vRed:"",vGreen:"",vBlue:"",mRed:"",mGreen:"",mBlue:""},i=[["",""]],o=[["",""]];if(t){for(let c=0,u=t.propertyNames.length;c(f.group=m,f.instance=h,f))}function i(l,d,f,p,m){const h=m&&m.aTransform.ref.value.length>=16*l.length?m.aTransform.ref.value:new Float32Array(16*l.length);for(let g=0,y=l.length;g{for(let A=b[S],E=b[S+1];A{for(let A=b[S],E=b[S+1];A{const A=p.shape.getSize(S,_);h{const m="material"===i?p:u[p];return st.fromRgb(o.value(m),s.value(m),a.value(m))},()=>1,p=>`${l} ${c[p]}`,f)}function Lqe(){let e,t,n,r,i,o;return function(){var a=ie(function*(c,u,l,d){const f=u.source.getElement("vertex");if(!f)throw new Error("missing vertex element");const p=u.source.getElement("face");if(!p)throw new Error("missing face element");const m=u.source.getElement("material");let h=!1,g=!1;return(!e||e!=e)&&(h=!0),(!t||!C.isParamEqual(Zie.grouping,t.grouping,l.grouping))&&(h=!0),(!t||!C.isParamEqual(Zie.coloring,t.coloring,l.coloring))&&(g=!0),h?(i=Qie(f,m,l),o=function Oqe(e,t){const{grouping:n}=t,{rowCount:r}=e,i="vertex"===n.name?e.getProperty(n.params.group):void 0,o="vertex"===n.name?zu(n.params.group):"Vertex",s=i?i.toArray({array:Uint32Array}):Tc(new Uint32Array(r)),a=i?Xd(s):r-1,c=new Uint32Array(a+1);for(let u=0,l=s.length;u=48&&s<=57)&&i<=o;)s=t.charCodeAt(++i);for(s=t.charCodeAt(o);(32===s||s>=48&&s<=57)&&o>=i;)s=t.charCodeAt(--o);if(++o,i===o||i+1===o)return He.add(e,i,o);if(s=t.charCodeAt(i),i+2===o){const a=t.charCodeAt(i+1);if(!((78!==s&&110!==s||65!==a&&97!==a)&&(67!==s&&99!==s||76!==a&&108!==a)&&(70!==s&&102!==s||69!==a&&101!==a)&&(83!==s&&115!==s||73!==a&&105!==a)&&(66!==s&&98!==s||82!==a&&114!==a)&&(65!==s&&97!==s||83!==a&&115!==a)))return He.add(e,i,i+2)}if(67===s||99===s||72===s||104===s||78===s||110===s||79===s||111===s||80===s||112===s||83===s||115===s)return He.add(e,i,i+1);He.add(e,i,i)}!function(e){function t(i,o){return{size:i,anglesInRadians:o}}function n(){return t(v(),v())}e.create=t,e.empty=n,e.fromBasis=function r(i,o,s){const a=v.magnitude(i),c=v.magnitude(o),u=v.magnitude(s),l=Math.acos(v.dot(o,s)/(c*u)),d=Math.acos(v.dot(i,s)/(a*u)),f=Math.acos(v.dot(i,o)/(a*c));return a<=0||c<=0||u<=0||l>=Math.PI||d>=Math.PI||f>=Math.PI?n():t(v.create(a,c,u),v.create(l,d,f))}}(Wp||(Wp={}));const Gqe=new Set(["NA","CL","FE","SI","BR","AS","LI"]),jqe=new Set(["C","H","N","O","P","S","F","B"]),Hqe=/^[\s\d]+|[\s\d]+$/g;function Ev(e,t){const n=(e=e.replace(Hqe,"").toUpperCase()).length;if(0===n||1===n||Gqe.has(e))return e;if(3===n&&t===e){if("SOD"===e)return"NA";if("POT"===e)return"K";if("CES"===e)return"CS";if("CAL"===e)return"CA";if("CLA"===e)return"CL"}return jqe.has(e[0])?e[0]:""}const F5="ABCDEFGHIJKLMNOPQRSTUVWXYZ",vS=cte(function qqe(e){let n=e,r=0,i=F5[n%26];for(;n>=26;)n=Math.floor(n/26),i+=F5[n%26],r+=1;return r>=5&&console.warn("getChainId overflow"),i});function Wqe(e,t){const n=e.atomName,r=e.residueName,i=new Array(e.count),o=new Array(e.count),s=new Uint32Array(e.count),a=new Uint32Array(e.count),c=new Array(e.count),u=new sd,l=new ad(e.residueNumber,e.atomName);let d="",f=0,p="",m=0,h=0,g=-1;for(let x=0,_=e.count;x<_;++x){const S=e.residueNumber.value(x);if(S!==g){const A=e.residueName.value(x),E=Yh(l.add(A,x).type,A);(E!==h||S!==g+1&&!(99999===g&&0===S))&&(p=vS(f),f+=1,m=0),d=u.getEntityId(A,E,p),m+=1,g=S,h=E}i[x]=d,o[x]=p,s[x]=m,a[x]=x,c[x]=Ev(e.atomName.value(x),e.residueName.value(x))}const y=te.ofStringArray(o),b=Xn.ofPartialColumns(ks.atom_site,{auth_asym_id:y,auth_atom_id:n,auth_comp_id:r,auth_seq_id:e.residueNumber,Cartn_x:te.ofFloatArray(te.mapToArray(e.x,x=>10*x,Float32Array)),Cartn_y:te.ofFloatArray(te.mapToArray(e.y,x=>10*x,Float32Array)),Cartn_z:te.ofFloatArray(te.mapToArray(e.z,x=>10*x,Float32Array)),id:te.ofIntArray(a),label_asym_id:y,label_atom_id:n,label_comp_id:r,label_seq_id:te.ofIntArray(s),label_entity_id:te.ofStringArray(i),occupancy:te.ofConst(1,e.count,te.Schema.float),type_symbol:te.ofStringArray(c),pdbx_PDB_model_num:te.ofConst(t,e.count,te.Schema.int)},e.count);return $u({entity:u.getEntityTable(),chem_comp:l.getChemCompTable(),atom_site:b})}var B5;function Yqe(e,t){const n=(o,s)=>(t.substr(o,s)||"").trim(),r={entry_id:ft.ofString(e),length_a:ft.ofString(n(6,9)),length_b:ft.ofString(n(15,9)),length_c:ft.ofString(n(24,9)),angle_alpha:ft.ofString(n(33,7)),angle_beta:ft.ofString(n(40,7)),angle_gamma:ft.ofString(n(47,7)),Z_PDB:ft.ofString(n(66,4)),pdbx_unique_axis:ft.ofString("?")},i={entry_id:ft.ofString(e),"space_group_name_H-M":ft.ofString(n(55,11)),Int_Tables_number:ft.ofString("?"),cell_setting:ft.ofString("?"),space_group_name_Hall:ft.ofString("?")};return[ss.ofFields("cell",r),ss.ofFields("symmetry",i)]}function eoe(e,t){return{id:e,details:t,groups:[]}}function Xqe(e,t,n){const r=[];let i,o,s,a=1,c=1;const u=h=>e.data.substring(e.indices[2*h],e.indices[2*h+1]);for(let h=t;hh.id)),details:ft.ofStrings(r.map(h=>h.details))},d=[];for(const h of r)for(const g of h.groups)d.push({assembly_id:h.id,oper_expression:g.operators.map(y=>y.id).join(","),asym_id_list:g.chains.join(",")});const f={assembly_id:ft.ofStrings(d.map(h=>h.assembly_id)),oper_expression:ft.ofStrings(d.map(h=>h.oper_expression)),asym_id_list:ft.ofStrings(d.map(h=>h.asym_id_list))},p=[];for(const h of r)for(const g of h.groups)for(const y of g.operators){const b={id:""+y.id,type:"?",name:"?",symmetry_operation:"?"};for(let x=0;x<3;x++){for(let _=0;_<3;_++)b[`matrix[${x+1}][${_+1}]`]=""+le.getValue(y.matrix,x,_);b[`vector[${x+1}]`]=""+le.getValue(y.matrix,x,3)}p.push(b)}const m={id:ft.ofStrings(p.map(h=>h.id)),type:ft.ofStrings(p.map(h=>h.type)),name:ft.ofStrings(p.map(h=>h.name)),symmetry_operation:ft.ofStrings(p.map(h=>h.symmetry_operation))};for(let h=0;h<3;h++){for(let y=0;y<3;y++){const b=`matrix[${h+1}][${y+1}]`;m[b]=ft.ofStrings(p.map(x=>x[b]))}const g=`vector[${h+1}]`;m[g]=ft.ofStrings(p.map(y=>y[g]))}return[ss.ofFields("pdbx_struct_assembly",l),ss.ofFields("pdbx_struct_assembly_gen",f),ss.ofFields("pdbx_struct_oper_list",m)]}function Kqe(e,t,n){const r=[];let i;const o=u=>e.data.substring(e.indices[2*u],e.indices[2*u+1]);for(let u=t;uu.id)),code:ft.ofStrings(s.map(u=>u.code)),details:ft.ofStrings(s.map(u=>u.details))};for(let u=0;u<3;u++){for(let d=0;d<3;d++){const f=`matrix[${u+1}][${d+1}]`;c[f]=ft.ofStrings(s.map(p=>p[f]))}const l=`vector[${u+1}]`;c[l]=ft.ofStrings(s.map(d=>d[l]))}return[ss.ofFields("struct_ncs_oper",c)]}!function(e){e.is=function t(r){return"gro"===r?.kind},e.fromGro=function n(r){return{kind:"gro",name:r.structures[0].header.title,data:r}}}(B5||(B5={}));const Zqe={1:"helx_rh_al_p",2:"helx_rh_om_p",3:"helx_rh_pi_p",4:"helx_rh_ga_p",5:"helx_rh_3t_p",6:"helx_lh_al_p",7:"helx_lh_om_p",8:"helx_lh_ga_p",9:"helx_rh_27_p",10:"helx_rh_pp_p"};function Jqe(e,t,n){const r=[],i=l=>e.data.substring(e.indices[2*l],e.indices[2*l+1]);for(let l=t;ll.initChainID)),s=ft.ofStrings(r.map(l=>l.initResName)),a=ft.ofStrings(r.map(l=>l.endChainID)),c=ft.ofStrings(r.map(l=>l.endResName)),u={beg_label_asym_id:o,beg_label_comp_id:s,beg_label_seq_id:ft.ofUndefined(r.length,te.Schema.int),beg_auth_asym_id:o,beg_auth_comp_id:s,beg_auth_seq_id:ft.ofStrings(r.map(l=>l.initSeqNum)),conf_type_id:ft.ofStrings(r.map(l=>function Qqe(e){return Zqe[e]||"helx_p"}(l.helixClass))),details:ft.ofStrings(r.map(l=>l.comment)),end_label_asym_id:a,end_label_comp_id:c,end_label_seq_id:ft.ofUndefined(r.length,te.Schema.int),end_auth_asym_id:a,end_auth_comp_id:c,end_auth_seq_id:ft.ofStrings(r.map(l=>l.endSeqNum)),id:ft.ofStrings(r.map(l=>l.serNum)),pdbx_beg_PDB_ins_code:ft.ofStrings(r.map(l=>l.initICode)),pdbx_end_PDB_ins_code:ft.ofStrings(r.map(l=>l.endICode)),pdbx_PDB_helix_class:ft.ofStrings(r.map(l=>l.helixClass)),pdbx_PDB_helix_length:ft.ofStrings(r.map(l=>l.length)),pdbx_PDB_helix_id:ft.ofStrings(r.map(l=>l.helixID))};return ss.ofFields("struct_conf",u)}function eWe(e,t,n){const r=[],i=f=>e.data.substring(e.indices[2*f],e.indices[2*f+1]);for(let f=t;ff.initChainID)),s=ft.ofStrings(r.map(f=>f.initResName)),a=ft.ofStrings(r.map(f=>f.initSeqNum)),c=ft.ofStrings(r.map(f=>f.endChainID)),u=ft.ofStrings(r.map(f=>f.endResName)),l=ft.ofStrings(r.map(f=>f.endSeqNum)),d={beg_label_asym_id:o,beg_label_comp_id:s,beg_label_seq_id:a,beg_auth_asym_id:o,beg_auth_comp_id:s,beg_auth_seq_id:a,end_label_asym_id:c,end_label_comp_id:c,end_label_seq_id:l,end_auth_asym_id:c,end_auth_comp_id:u,end_auth_seq_id:l,id:ft.ofStrings(r.map(f=>f.strand)),sheet_id:ft.ofStrings(r.map(f=>f.sheetID)),pdbx_beg_PDB_ins_code:ft.ofStrings(r.map(f=>f.initICode)),pdbx_end_PDB_ins_code:ft.ofStrings(r.map(f=>f.endICode))};return ss.ofFields("struct_sheet_range",d)}const tWe={MOL_ID:"",MOLECULE:"",CHAIN:"",FRAGMENT:"",SYNONYM:"",EC:"",ENGINEERED:"",MUTATION:"",OTHER_DETAILS:""};function nWe(e,t,n){const r=c=>e.data.substring(e.indices[2*c],e.indices[2*c+1]);let i,o={chains:[],description:""};const s=[];for(let c=t;ce.data.substring(e.indices[2*o],e.indices[2*o+1]),i=new Map;for(let o=t;o=66?He.addToken(e.B_iso_or_equiv,ht.trim(n,r+60,r+66)):He.add(e.B_iso_or_equiv,0,0),o&&He.addToken(e.partial_charge,ht.trim(n,r+70,r+76)),a>=78&&!o?(ht.trim(n,r+76,r+78),n.tokenStart=78?(ht.trim(n,r+76,r+78),n.tokenStartHe.create(e,2*t);return{index:0,group_PDB:r(),id:[],auth_atom_id:r(),label_alt_id:r(),auth_comp_id:r(),auth_asym_id:r(),auth_seq_id:r(),pdbx_PDB_ins_code:r(),Cartn_x:r(),Cartn_y:r(),Cartn_z:r(),occupancy:r(),B_iso_or_equiv:r(),type_symbol:r(),pdbx_PDB_model_num:[],label_entity_id:[],partial_charge:r()}}(n,s),l=function sWe(e,t){const r=()=>new Float32Array(t),i=()=>He.create(e,2*t);return{index:0,count:t,id:[],type_symbol:i(),pdbx_label_atom_id:i(),pdbx_label_alt_id:i(),pdbx_label_comp_id:i(),pdbx_label_asym_id:i(),pdbx_label_seq_id:i(),pdbx_PDB_ins_code:i(),"U[1][1]":r(),"U[2][2]":r(),"U[3][3]":r(),"U[1][2]":r(),"U[1][3]":r(),"U[2][3]":r(),pdbx_auth_seq_id:i(),pdbx_auth_comp_id:i(),pdbx_auth_asym_id:i(),pdbx_auth_atom_id:i()}}(n,a),d=new sd,f=[],p=[];let g,m=0,h="",y=!1;const b=new Set;for(let I=0,R=t.count;Ie.data.substring(e.indices[2*E],e.indices[2*E+1]),s=[],a=[],c=[],u=[],l=[],d=[],f=[],p=[],m=[],h=[],g=[],y=[],b=[],x=[],_=[11,16,21,26];let S=1;for(let E=t;EM||void 0===I[M]&&(s.push(`covale${S}`),a.push("covale"),c.push(r.label_asym_id.str(D)),u.push(r.label_seq_id.int(D)),l.push(r.auth_seq_id.int(D)),d.push(r.label_atom_id.str(D)),f.push(r.label_alt_id.str(D)),p.push(r.pdbx_PDB_ins_code.str(D)),m.push(r.label_asym_id.str(M)),h.push(r.label_seq_id.int(M)),g.push(r.auth_seq_id.int(M)),y.push(r.label_atom_id.str(M)),b.push(r.label_alt_id.str(M)),x.push(r.pdbx_PDB_ins_code.str(M)),S+=1))}}const A={id:ft.ofStrings(s),conn_type_id:ft.ofStrings(a),ptnr1_label_asym_id:ft.ofStrings(c),ptnr1_label_seq_id:ft.ofNumbers(u),ptnr1_auth_seq_id:ft.ofNumbers(l),ptnr1_label_atom_id:ft.ofStrings(d),pdbx_ptnr1_label_alt_id:ft.ofStrings(f),pdbx_ptnr1_PDB_ins_code:ft.ofStrings(p),ptnr2_label_asym_id:ft.ofStrings(m),ptnr2_label_seq_id:ft.ofNumbers(h),ptnr2_auth_seq_id:ft.ofNumbers(g),ptnr2_label_atom_id:ft.ofStrings(y),pdbx_ptnr2_label_alt_id:ft.ofStrings(b),pdbx_ptnr2_PDB_ins_code:ft.ofStrings(x)};return ss.ofFields("struct_conn",A)}(t,g[0],g[1],w));const D={entity:ss.ofTable("entity",d.getEntityTable()),chem_comp:ss.ofTable("chem_comp",E.getChemCompTable()),atom_site:ss.ofFields("atom_site",w),atom_site_anisotrop:ss.ofFields("atom_site_anisotrop",aWe(l))};for(const I of f)D[I.name]=I;return{header:e.id||"PDB",categoryNames:Object.keys(D),categories:D}}),O5.apply(this,arguments)}var Pv,L5,U5;function mWe(e){return Object.keys(e).filter(t=>!isNaN(t)).map(t=>+t).sort((t,n)=>t-n).map(t=>e[t])}function V5(e,t,n){return e&&void 0!==e[t]?e[t]:n}function Je(e,...t){return{kind:"alias",aliases:t,symbol:e}}function LD(e,t,...n){return e.info.namespace="molscript-macro",e.id=`molscript-macro.${e.info.name}`,{kind:"macro",symbol:e,translate:t,aliases:[e.info.name,...n]}}function gWe(e){return"alias"===e.kind||"macro"===e.kind}!function(e){e.Descriptor={name:"atom_partial_charge"},e.Provider=td.create(e.Descriptor)}(Pv||(Pv={})),function(e){e.is=function t(r){return"pdb"===r?.kind},e.create=function n(r){return{kind:"pdb",name:r.id||"",data:r}}}(L5||(L5={})),function(e){e.is=function t(r){return"psf"===r?.kind},e.fromPsf=function n(r){return{kind:"psf",name:r.id,data:r}}}(U5||(U5={}));const yWe=[["Core symbols",Je(ye.core.type.bool,"bool"),Je(ye.core.type.num,"num"),Je(ye.core.type.str,"str"),Je(ye.core.type.regex,"regex"),Je(ye.core.type.list,"list"),Je(ye.core.type.set,"set"),Je(ye.core.type.compositeKey,"composite-key"),Je(ye.core.logic.not,"not"),Je(ye.core.logic.and,"and"),Je(ye.core.logic.or,"or"),Je(ye.core.ctrl.if,"if"),Je(ye.core.ctrl.fn,"fn"),Je(ye.core.ctrl.eval,"eval"),Je(ye.core.math.add,"add","+"),Je(ye.core.math.sub,"sub","-"),Je(ye.core.math.mult,"mult","*"),Je(ye.core.math.div,"div","/"),Je(ye.core.math.pow,"pow","**"),Je(ye.core.math.mod,"mod"),Je(ye.core.math.min,"min"),Je(ye.core.math.max,"max"),Je(ye.core.math.cantorPairing,"cantor-pairing"),Je(ye.core.math.sortedCantorPairing,"sorted-cantor-pairing"),Je(ye.core.math.invertCantorPairing,"invert-cantor-pairing"),Je(ye.core.math.floor,"floor"),Je(ye.core.math.ceil,"ceil"),Je(ye.core.math.roundInt,"round"),Je(ye.core.math.trunc,"trunc"),Je(ye.core.math.abs,"abs"),Je(ye.core.math.sign,"sign"),Je(ye.core.math.sqrt,"sqrt"),Je(ye.core.math.cbrt,"cbrt"),Je(ye.core.math.sin,"sin"),Je(ye.core.math.cos,"cos"),Je(ye.core.math.tan,"tan"),Je(ye.core.math.asin,"asin"),Je(ye.core.math.acos,"acos"),Je(ye.core.math.atan,"atan"),Je(ye.core.math.sinh,"sinh"),Je(ye.core.math.cosh,"cosh"),Je(ye.core.math.tanh,"tanh"),Je(ye.core.math.exp,"exp"),Je(ye.core.math.log,"log"),Je(ye.core.math.log10,"log10"),Je(ye.core.math.atan2,"atan2"),Je(ye.core.rel.eq,"eq","="),Je(ye.core.rel.neq,"neq","!="),Je(ye.core.rel.lt,"lt","<"),Je(ye.core.rel.lte,"lte","<="),Je(ye.core.rel.gr,"gr",">"),Je(ye.core.rel.gre,"gre",">="),Je(ye.core.rel.inRange,"in-range"),Je(ye.core.str.concat,"concat"),Je(ye.core.str.match,"regex.match"),Je(ye.core.list.getAt,"list.get"),Je(ye.core.set.has,"set.has"),Je(ye.core.set.isSubset,"set.subset")],["Structure",["Types",Je(ye.structureQuery.type.entityType,"ent-type"),Je(ye.structureQuery.type.authResidueId,"auth-resid"),Je(ye.structureQuery.type.labelResidueId,"label-resid"),Je(ye.structureQuery.type.ringFingerprint,"ringfp"),Je(ye.structureQuery.type.bondFlags,"bond-flags")],["Slots",Je(ye.structureQuery.slot.elementSetReduce,"atom.set.reduce.value")],["Generators",Je(ye.structureQuery.generator.atomGroups,"sel.atom.atom-groups"),Je(ye.structureQuery.generator.queryInSelection,"sel.atom.query-in-selection"),Je(ye.structureQuery.generator.rings,"sel.atom.rings"),Je(ye.structureQuery.generator.empty,"sel.atom.empty"),Je(ye.structureQuery.generator.all,"sel.atom.all"),Je(ye.structureQuery.generator.bondedAtomicPairs,"sel.atom.bonded-pairs"),LD(o2("sel.atom.atoms",Ot.Dictionary({0:ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test applied to each atom."})}),wt.ElementSelection,"A selection of singleton atom sets."),e=>ue.struct.generator.atomGroups({"atom-test":V5(e,0,!0)})),LD(o2("sel.atom.res",Ot.Dictionary({0:ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test applied to the 1st atom of each residue."})}),wt.ElementSelection,"A selection of atom sets grouped by residue."),e=>ue.struct.generator.atomGroups({"residue-test":V5(e,0,!0),"group-by":ue.ammp("residueKey")})),LD(o2("sel.atom.chains",Ot.Dictionary({0:ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test applied to the 1st atom of each chain."})}),wt.ElementSelection,"A selection of atom sets grouped by chain."),e=>ue.struct.generator.atomGroups({"chain-test":V5(e,0,!0),"group-by":ue.ammp("chainKey")}))],["Modifiers",Je(ye.structureQuery.modifier.queryEach,"sel.atom.query-each"),Je(ye.structureQuery.modifier.intersectBy,"sel.atom.intersect-by"),Je(ye.structureQuery.modifier.exceptBy,"sel.atom.except-by"),Je(ye.structureQuery.modifier.unionBy,"sel.atom.union-by"),Je(ye.structureQuery.modifier.union,"sel.atom.union"),Je(ye.structureQuery.modifier.cluster,"sel.atom.cluster"),Je(ye.structureQuery.modifier.includeSurroundings,"sel.atom.include-surroundings"),Je(ye.structureQuery.modifier.surroundingLigands,"sel.atom.surrounding-ligands"),Je(ye.structureQuery.modifier.includeConnected,"sel.atom.include-connected"),Je(ye.structureQuery.modifier.expandProperty,"sel.atom.expand-property")],["Filters",Je(ye.structureQuery.filter.pick,"sel.atom.pick"),Je(ye.structureQuery.filter.first,"sel.atom.first"),Je(ye.structureQuery.filter.withSameAtomProperties,"sel.atom.with-same-atom-properties"),Je(ye.structureQuery.filter.intersectedBy,"sel.atom.intersected-by"),Je(ye.structureQuery.filter.within,"sel.atom.within"),Je(ye.structureQuery.filter.isConnectedTo,"sel.atom.is-connected-to")],["Combinators",Je(ye.structureQuery.combinator.intersect,"sel.atom.intersect"),Je(ye.structureQuery.combinator.merge,"sel.atom.merge"),Je(ye.structureQuery.combinator.distanceCluster,"sel.atom.dist-cluster")],["Atom Set Properties",Je(ye.structureQuery.atomSet.atomCount,"atom.set.atom-count"),Je(ye.structureQuery.atomSet.countQuery,"atom.set.count-query"),Je(ye.structureQuery.atomSet.reduce,"atom.set.reduce"),Je(ye.structureQuery.atomSet.propertySet,"atom.set.property")],["Atom Properties",Je(ye.structureQuery.atomProperty.core.elementSymbol,"atom.el"),Je(ye.structureQuery.atomProperty.core.vdw,"atom.vdw"),Je(ye.structureQuery.atomProperty.core.mass,"atom.mass"),Je(ye.structureQuery.atomProperty.core.atomicNumber,"atom.atomic-number"),Je(ye.structureQuery.atomProperty.core.x,"atom.x"),Je(ye.structureQuery.atomProperty.core.y,"atom.y"),Je(ye.structureQuery.atomProperty.core.z,"atom.z"),Je(ye.structureQuery.atomProperty.core.sourceIndex,"atom.src-index"),Je(ye.structureQuery.atomProperty.core.operatorName,"atom.op-name"),Je(ye.structureQuery.atomProperty.core.operatorKey,"atom.op-key"),Je(ye.structureQuery.atomProperty.core.modelIndex,"atom.model-index"),Je(ye.structureQuery.atomProperty.core.modelLabel,"atom.model-label"),Je(ye.structureQuery.atomProperty.core.atomKey,"atom.key"),Je(ye.structureQuery.atomProperty.core.bondCount,"atom.bond-count"),Je(ye.structureQuery.atomProperty.topology.connectedComponentKey,"atom.key.molecule"),Je(ye.structureQuery.atomProperty.macromolecular.authResidueId,"atom.auth-resid"),Je(ye.structureQuery.atomProperty.macromolecular.labelResidueId,"atom.label-resid"),Je(ye.structureQuery.atomProperty.macromolecular.residueKey,"atom.key.res"),Je(ye.structureQuery.atomProperty.macromolecular.chainKey,"atom.key.chain"),Je(ye.structureQuery.atomProperty.macromolecular.entityKey,"atom.key.entity"),Je(ye.structureQuery.atomProperty.macromolecular.isHet,"atom.is-het"),Je(ye.structureQuery.atomProperty.macromolecular.id,"atom.id"),Je(ye.structureQuery.atomProperty.macromolecular.label_atom_id,"atom.label_atom_id"),Je(ye.structureQuery.atomProperty.macromolecular.label_alt_id,"atom.label_alt_id","atom.altloc"),Je(ye.structureQuery.atomProperty.macromolecular.label_comp_id,"atom.label_comp_id"),Je(ye.structureQuery.atomProperty.macromolecular.label_asym_id,"atom.label_asym_id"),Je(ye.structureQuery.atomProperty.macromolecular.label_entity_id,"atom.label_entity_id"),Je(ye.structureQuery.atomProperty.macromolecular.label_seq_id,"atom.label_seq_id"),Je(ye.structureQuery.atomProperty.macromolecular.auth_atom_id,"atom.auth_atom_id","atom.name"),Je(ye.structureQuery.atomProperty.macromolecular.auth_comp_id,"atom.auth_comp_id","atom.resname"),Je(ye.structureQuery.atomProperty.macromolecular.auth_asym_id,"atom.auth_asym_id","atom.chain"),Je(ye.structureQuery.atomProperty.macromolecular.auth_seq_id,"atom.auth_seq_id","atom.resno"),Je(ye.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code,"atom.pdbx_PDB_ins_code","atom.inscode"),Je(ye.structureQuery.atomProperty.macromolecular.pdbx_formal_charge,"atom.pdbx_formal_charge"),Je(ye.structureQuery.atomProperty.macromolecular.occupancy,"atom.occupancy"),Je(ye.structureQuery.atomProperty.macromolecular.B_iso_or_equiv,"atom.B_iso_or_equiv","atom.bfactor"),Je(ye.structureQuery.atomProperty.macromolecular.entityType,"atom.entity-type"),Je(ye.structureQuery.atomProperty.macromolecular.entitySubtype,"atom.entity-subtype"),Je(ye.structureQuery.atomProperty.macromolecular.entityPrdId,"atom.entity-prd-id"),Je(ye.structureQuery.atomProperty.macromolecular.entityDescription,"atom.entity-description"),Je(ye.structureQuery.atomProperty.macromolecular.objectPrimitive,"atom.object-primitive"),Je(ye.structureQuery.atomProperty.macromolecular.chemCompType,"atom.chem-comp-type"),Je(ye.structureQuery.atomProperty.macromolecular.secondaryStructureKey,"atom.key.sec-struct"),Je(ye.structureQuery.atomProperty.macromolecular.isModified,"atom.is-modified"),Je(ye.structureQuery.atomProperty.macromolecular.modifiedParentName,"atom.modified-parent")],["Bond Properties",Je(ye.structureQuery.bondProperty.order,"bond.order"),Je(ye.structureQuery.bondProperty.length,"bond.length"),Je(ye.structureQuery.bondProperty.key,"bond.key"),Je(ye.structureQuery.bondProperty.atomA,"bond.atom-a"),Je(ye.structureQuery.bondProperty.atomB,"bond.atom-b"),LD(o2("bond.is",Ot.List(wt.BondFlag),Ae.Bool,`Test if the current bond has at least one (or all if partial = false) of the specified flags: ${Ae.oneOfValues(wt.BondFlag).join(", ")}`),e=>ue.core.flags.hasAny([ue.struct.bondProperty.flags(),ue.struct.type.bondFlags(mWe(e))]))]]],noe=[];!function roe(e){for(const t of e)gWe(t)?noe.push(t):t instanceof Array&&roe(t)}(yWe);const UD=function(){const e=[],t=Object.create(null),n=kr.create(),r=kr.create();for(const i of noe){for(const s of i.aliases){if(e.push([s,i]),t[s])throw new Error(`Alias '${s}' already in use.`);t[s]=i}const o=i.symbol.args;if("dictionary"===o.kind)for(const s of Object.keys(o.map)){isNaN(s)&&kr.add(n,s,s);const a=o.map[s];"oneof"===a.type.kind&&Ae.oneOfValues(a.type).forEach(c=>kr.add(r,c,c))}else"oneof"===o.type.kind&&Ae.oneOfValues(o.type).forEach(s=>kr.add(r,s,s))}return{symbolList:e,symbolMap:t,namedArgs:n.array,constants:r.array}}(),Mv=UD.symbolMap;function _S(e){if(as.isLiteral(e))return e;if(as.isSymbol(e)){if(!Mv[e.name])return e;const s=Mv[e.name];if("alias"===s.kind)return as.Symbol(Mv[e.name].symbol.id);throw s.translate([])}const t=as.isSymbol(e.head)&&!!Mv[e.head.name]&&"macro"===Mv[e.head.name].kind,n=t?e.head:_S(e.head),r=n!==e.head;if(!e.args)return t?_S(e.head):r?as.Apply(n):e;let o,i=!1;if(as.isArgumentsArray(e.args)){o=[];for(let s=0,a=e.args.length;s12?"...'":"'";return` at line ${n.line} column ${n.column}, got ${r>0?"'...":"'"}${e.slice(r,r+12)}${o}`}(e,t)}`}(t,n);throw new Error(r)}}or(t){return Be.alt(this,t)}trim(t){return this.wrap(t,t)}wrap(t,n){return z5(1,"string"==typeof t?Be.string(t):t,this,"string"==typeof n?Be.string(n):n)}thru(t){return t(this)}then(t){return z5(1,this,t)}many(){return new Be((t,n)=>{const r=[];let i;for(;;){if(i=pl(this._(t,n),i),!i.status)return pl(Sa(n,r),i);if(n===i.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");n=i.index,r.push(i.value)}})}times(t,n){const r=typeof n>"u"?t:n;return new Be((i,o)=>{const s=[];let a,c,u;for(u=0;ut)}atMost(t){return this.times(0,t)}atLeast(t){return Be.seq(this.times(t),this.many()).map(n=>[...n[0],...n[1]])}map(t){return new Be((n,r)=>{const i=this._(n,r);return i.status?pl(Sa(i.index,t(i.value)),i):i})}skip(t){return z5(0,this,t)}mark(){return Be.seq(Be.index,this,Be.index).map(t=>({start:t[0],value:t[1],end:t[2]}))}node(t){return Be.seq(Be.index,this,Be.index).map(n=>({name:t,start:n[0],value:n[1],end:n[2]}))}sepBy(t){return Be.sepBy(this,t)}sepBy1(t){return Be.sepBy1(this,t)}lookahead(t){return this.skip(Be.lookahead(t))}notFollowedBy(t){return this.skip(Be.notFollowedBy(t))}desc(t){return new Be((n,r)=>{const i=this._(n,r);return i.status||(i.expected=[t]),i})}fallback(t){return this.or(Be.succeed(t))}ap(t){return Be.seq(t,this).map(([n,r])=>n(r))}chain(t){return new Be((n,r)=>{const i=this._(n,r);return i.status?pl(t(i.value)._(n,i.index),i):i})}}function z5(e,...t){const n=t.length;return new Be((r,i)=>{let o,s,a=i;for(let c=0;ct.furthest)return e;const n=e.furthest===t.furthest?function SWe(e,t){const n=e.length,r=t.length;if(0===n)return t;if(0===r)return e;const i=new Set,o=[];for(let s=0;s{let T;const M=new Array(D);let N=R;for(let V=0;V{let T;for(let M=0;M[R[0],...R[1]])}function a(w){const D=`'${w}'`;if(1===w.length){const I=w.charCodeAt(0);return new e((R,T)=>R.charCodeAt(T)===I?Sa(T+1,w):$p(T,D))}return new e((I,R)=>{const T=R+w.length;return I.slice(R,T)===w?Sa(T,w):$p(R,D)})}function l(w,D=0){const I=function u(w){return RegExp("^(?:"+w.source+")",function c(w){const D=""+w;return D.slice(D.lastIndexOf("/")+1)}(w))}(w),R=""+w;return new e((T,M)=>{const N=I.exec(T.slice(M));return N?0<=D&&D<=N.length?Sa(M+N[0].length,N[D]):$p(M,`invalid match group (0 to ${N.length}) in ${R}`):$p(M,R)})}function d(w){return new e((D,I)=>Sa(I,w))}function f(w){return new e((D,I)=>$p(I,w))}function h(w){return new e((D,I)=>{const R=D.charAt(I);return I{const T=w()._;return D._=T,T(I,R)});return D}e.seqMap=function t(w,D,I){const R=[].slice.call(arguments);if(0===R.length)throw new Error("seqMap needs at least one argument");const T=R.pop();return function wWe(e){if("function"!=typeof e)throw new Error("not a function: "+e)}(T),r.apply(null,R).map(function(M){return T.apply(null,M)})},e.createLanguage=function n(w){const D={};for(const I of Object.keys(w))!function(R){D[R]=_(()=>w[R](D))}(I);return D},e.seq=r,e.alt=i,e.sepBy=function o(w,D){return s(w,D).or(d([]))},e.sepBy1=s,e.string=a,e.regexp=l,e.succeed=d,e.fail=f,e.lookahead=function p(w){if(function CWe(e){return e instanceof Be}(w))return new e((D,I)=>{const R=w._(D,I);return R.status&&(R.index=I,R.value=null),R});if("string"==typeof w)return p(a(w));if(w instanceof RegExp)return p(l(w));throw new Error("not a string, regexp, or parser: "+w)},e.notFollowedBy=function m(w){return new e((D,I)=>{const R=w._(D,I);return R.status?$p(I,'not "'+D.slice(I,R.index)+'"'):Sa(I,null)})},e.test=h,e.oneOf=function g(w){return h(D=>w.indexOf(D)>=0)},e.noneOf=function y(w){return h(D=>w.indexOf(D)<0)},e.range=function b(w,D){return h(I=>w<=I&&I<=D).desc(w+"-"+D)},e.takeWhile=function x(w){return new e((D,I)=>{let R=I;for(;RD>=w.length?$p(D,"any character"):Sa(D+1,w.charAt(D))),e.all=new e(function(w,D){return Sa(w.length,w.slice(D))}),e.eof=new e(function(w,D){return DBe.alt(i,d,o,s).trim(n)),i=Be.takeWhile(_=>"`"!==_).trim("`").map(t.str),o=Be.regexp(/[^()\[\]{};`,\n\r\s]+/).map(t.symb),s=Be.regexp(/\s*;+([^\n\r]*)\n/,1).map(t.comment),a=r.many(),c=a.wrap("(",")").map(_=>t.list("(",_)),u=a.wrap("[","]").map(_=>t.list("[",_)),l=a.wrap("{","}").map(_=>t.list("{",_)),d=Be.alt(c,u,l),f=r.many();function m(_){switch(_.kind){case"string":return _.value;case"symbol":{const S=_.value;if(S.length>1)switch(S.charAt(0)){case".":return ue.atomName(S.substr(1));case"_":return ue.struct.type.elementSymbol([S.substr(1)])}return"true"===S||"false"!==S&&(function b(_){return/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/.test(_)&&!isNaN(+_)}(S)?+S:as.Symbol(S))}case"list":switch(_.bracket){case"[":return ue.core.type.list(y(_.nodes).map(m));case"{":return ue.core.type.set(y(_.nodes).map(m));case"(":{if("comment"===_.nodes[0].kind)throw new Error("Invalid expression");const S=m(_.nodes[0]);return as.Apply(S,function h(_){if(_.length<=1)return;if(!function g(_){for(let S=1,A=_.length;S1&&":"===E.value.charAt(0))return!0}return!1}(_)){const w=[];for(let D=1,I=_.length;D1&&":"===I.value.charAt(0)){const R=I.value.substr(1);for(++w;w=D)throw new Error(`There must be a value foolowed a named arg ':${R}'.`);if("comment"===_[w].kind)throw new Error("Invalid expression");S[R]=m(_[w]),isNaN(+R)&&(A=!1)}else S[E++]=m(I)}if(A){const w=Object.keys(S).map(I=>+I).sort((I,R)=>I-R);let D=!0;for(let I=0,R=w.length;I"comment"!==A.kind):_}e.parse=function x(_){const S=function p(_){return f.tryParse(_)}(_),A=[];for(const E of S)"comment"!==E.kind&&(A[A.length]=m(E));return A}}(G5||(G5={}));const $r=ue;function Ca(e,t,n){const r=Be.lazy(()=>Be.seq(e,r).map(i=>n(...i)).or(t));return r}function VD(e,t,n){return Be.seqMap(t,e.many(),(r,i)=>i.reduce((o,s)=>n(s,o),r))}function sc(e,t,n){return Be.seqMap(t,Be.seq(e,t).many(),(r,i)=>i.reduce((o,s)=>{const[a,c]=s;return n(a,o,c)},r))}function xS(e,t){return e.reduce((r,i)=>{const o=i.isUnsupported?bm(`operator '${i.name}' not supported`):i.map;return i.type(i.rule,r,o)},t)}function Yp(e,t=0){return Be.optWhitespace.then(Be.regexp(e,t).skip(Be.optWhitespace))}function xu(e,t=0){return Be.regexp(e,t).skip(Be.optWhitespace)}function zD(e,t=0){return Be.optWhitespace.then(Be.regexp(e,t))}function j5(e,t){const n=t?`${e}|${s2(t)}`:e;return Yp(RegExp(`(${n})\\s+([-+]?[0-9]*\\.?[0-9]+)\\s+OF`,"i"),2).map(parseFloat)}function bm(e){return function(){throw new Error(e)}}function H5(e){return 1===e.length?e[0]:e.length>1?$r.core.logic.and(e):void 0}function q5(e,t){if(!t||void 0===t.op||void 0===t.val)return t&&void 0!==t.flags?$r.core.flags.hasAny([e,t.flags]):t&&void 0!==t.min&&void 0!==t.max?$r.core.rel.inRange([e,t.min,t.max]):Array.isArray(t)?t.length>1?$r.core.set.has([$r.core.type.set(t),e]):$r.core.rel.eq([e,t[0]]):$r.core.rel.eq([e,t]);{const n=[e,t.val];switch(t.op){case"=":return $r.core.rel.eq(n);case"!=":return $r.core.rel.neq(n);case">":return $r.core.rel.gr(n);case"<":return $r.core.rel.lt(n);case">=":return $r.core.rel.gre(n);case"<=":return $r.core.rel.lte(n);default:throw new Error(`operator '${t.op}' not supported`)}}}function Su(e){return $r.struct.generator.queryInSelection({0:e,query:$r.struct.generator.all(),"in-complement":!0})}function vf(e,t){return e.length{const r=e[n],i=bm(`property '${n}' not supported`),o=Be.regexp(r.regex).map(c=>(r.isUnsupported&&i(),q5(r.property,r.map(c)))),s=Be.regexp(W5(n,r.abbr)).trim(Be.optWhitespace),a=c=>$r.struct.generator.atomGroups({[r.level]:c});t.push(r.isNumeric?s.then(Be.seq(Be.regexp(/>=|<=|=|!=|>|(r.isUnsupported&&i(),q5(r.property,{op:c[0],val:c[1]}))).map(a):s.then(o).map(a))}),t}function $5(e){const t=[];return Object.keys(e).sort(vf).forEach(n=>{const r=e[n],i=r.map?r.map:bm(`keyword '${n}' not supported`),o=Be.regexp(W5(n,r.abbr)).map(i);t.push(o)}),t}function Y5(e,t){const n=[];return Object.keys(e).sort(vf).forEach(r=>{const i=e[r],o=bm(`property '${r}' not supported`),s=Be.regexp(W5(r,i.abbr)).lookahead(t).map(()=>(i.isUnsupported&&o(),i.property));n.push(s)}),n}function X5(e,t,n,r){const i=[];for(const o in e)i.push(o),e[o].abbr&&i.push(...e[o].abbr);for(const o in t)i.push(o),t[o].abbr&&i.push(...t[o].abbr);return n.forEach(o=>{i.push(o.name),o.abbr&&i.push(...o.abbr)}),i}function _f(e){return $r.core.type.set(e.map($r.atomName))}function xf(e){return $r.struct.generator.queryInSelection({0:e,query:$r.struct.generator.all()})}function SS(e,t,n){switch(e.head.name){case"structure-query.atom-property.macromolecular.label_atom_id":return $r.atomName(t);case"structure-query.atom-property.core.element-symbol":return $r.es(t);case"structure-query.atom-property.macromolecular.secondary-structure-flags":return n&&(t=[n[t.toUpperCase()]||"none"]),$r.struct.type.secondaryStructureFlags([t]);default:return t}}const EWe=["entityKey","label_entity_id","entityType"],PWe=["chainKey","label_asym_id","label_entity_id","auth_asym_id","entityType"],MWe=["residueKey","label_comp_id","label_seq_id","auth_comp_id","auth_seq_id","pdbx_formal_charge","secondaryStructureKey","secondaryStructureFlags","isModified","modifiedParentName"];function RWe(e){if(e.head.name.startsWith("structure-query.atom-property.macromolecular.")){const t=e.head.name.substr(45);if(EWe.includes(t))return"entity-test";if(PWe.includes(t))return"chain-test";if(MWe.includes(t))return"residue-test"}return"atom-test"}const kWe=["structure-query.atom-property.macromolecular.secondary-structure-flags"];function er(e){return $r.struct.generator.atomGroups({"residue-test":$r.core.set.has([$r.core.type.set(e),$r.ammp("label_comp_id")])})}const xo=ue,hl=/[-+]?[0-9]*\.?[0-9]+/,CS=/[0-9]+/;function Qt(e){return e}const FWe={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 aoe(e){if(e.head){if(e.head.name&&"core.type.regex"===e.head.name&&(e=e.args[0].replace(/^\^|\$$/g,"")),e=FWe[e.toString().toLowerCase()]||"none",-1!==["dna","rna","carbohydrate"].indexOf(e))throw new Error("values 'dna', 'rna', 'carbohydrate' not yet supported for 'structure' property");return xo.struct.type.secondaryStructureFlags([e])}}const coe={adpmax:{"@desc":"the maximum anisotropic displacement parameter for the selected atom","@examples":[""],isUnsupported:!0,regex:hl,map:e=>parseFloat(e),level:"atom-test"},adpmin:{"@desc":"the minimum anisotropic displacement parameter for the selected atom","@examples":[""],isUnsupported:!0,regex:hl,map:e=>parseFloat(e),level:"atom-test"},altloc:{"@desc":"PDB alternate location identifier","@examples":["altloc = A"],regex:/[a-zA-Z0-9]/,map:Qt,level:"atom-test",property:xo.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:Qt,level:"atom-test"},atomID:{"@desc":"special atom IDs for PDB atoms assigned by Jmol","@examples":[""],isUnsupported:!0,regex:CS,map:e=>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:CS,map:e=>parseInt(e),level:"atom-test"},atomName:{"@desc":"atom name","@examples":["atomName = CA"],regex:/[a-zA-Z0-9]+/,map:e=>xo.atomName(e),level:"atom-test",property:xo.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:CS,map:e=>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:e=>xo.atomName(e),level:"atom-test",property:xo.ammp("label_atom_id")},atomX:{"@desc":"Cartesian X coordinate (or just X)","@examples":["x = 4.2"],abbr:["X"],isNumeric:!0,regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.acp("x")},atomY:{"@desc":"Cartesian Y coordinate (or just Y)","@examples":["y < 42"],abbr:["Y"],isNumeric:!0,regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.acp("y")},atomZ:{"@desc":"Cartesian Z coordinate (or just Z)","@examples":["Z > 10"],abbr:["Z"],isNumeric:!0,regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.acp("z")},bondcount:{"@desc":"covalent bond count","@examples":["bondcount = 0"],isNumeric:!0,regex:CS,map:e=>parseInt(e),level:"atom-test",property:xo.acp("bondCount")},bondingRadius:{"@desc":"radius used for auto bonding; synonymous with ionic and ionicRadius","@examples":[""],abbr:["ionic","ionicRadius"],isUnsupported:!0,regex:hl,map:e=>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:Qt,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:CS,map:e=>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:Qt,level:"chain-test",property:xo.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:Qt,level:"atom-test"},color:{"@desc":"the atom color","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,level:"atom-test"},cs:{"@desc":"chemical shift calculated using computational results that include magnetic shielding tensors.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:e=>xo.es(e),level:"atom-test",property:xo.acp("elementSymbol")},elemno:{"@desc":"atomic element number","@examples":["elemno=8"],regex:/[0-9\s{}-]+/,map:e=>parseInt(e),level:"atom-test",property:xo.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:Qt,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:Qt,level:"atom-test"},file:{"@desc":"file number containing this atom","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},formalCharge:{"@desc":"formal charge","@examples":["formalCharge=1"],regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.ammp("pdbx_formal_charge")},format:{"@desc":"format (label) of the atom.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fXyz:{"@desc":"fractional XYZ coordinates","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fX:{"@desc":"fractional X coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fY:{"@desc":"fractional Y coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fZ:{"@desc":"fractional Z coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fuxyz:{"@desc":"fractional XYZ coordinates in the unitcell coordinate system","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fux:{"@desc":"fractional X coordinate in the unitcell coordinate system","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fuy:{"@desc":"fractional Y coordinate in the unitcell coordinate system","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fuz:{"@desc":"fractional Z coordinate in the unit cell coordinate system","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},group:{"@desc":"3-letter residue code","@examples":["group = ALA"],regex:/[a-zA-Z0-9]{1,3}/,map:Qt,level:"residue-test",property:xo.ammp("label_comp_id")},group1:{"@desc":"single-letter residue code (amino acids only)","@examples":["group1 = G"],regex:/[a-zA-Z]/,map:Qt,level:"residue-test",property:xo.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:Qt,level:"atom-test"},groupindex:{"@desc":"overall group index","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,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:Qt,level:"atom-test"},insertion:{"@desc":"protein residue insertion code","@examples":["insertion=A"],regex:/[a-zA-Z0-9]/,map:Qt,level:"atom-test",property:xo.ammp("pdbx_PDB_ins_code")},label:{"@desc":"current atom label (same as format)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},mass:{"@desc":"atomic mass -- especially useful with appended .max or .sum","@examples":["mass > 13"],regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.acp("mass")},model:{"@desc":"model number","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,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:Qt,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:Qt,level:"atom-test"},molecule:{"@desc":"molecule number","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,level:"atom-test"},ms:{"@desc":"magnetic shielding calculated from file-loaded tensors.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.ammp("occupancy")},partialCharge:{"@desc":"partial charge","@examples":[""],isUnsupported:!0,regex:hl,map:e=>parseFloat(e),level:"atom-test"},phi:{"@desc":"protein group PHI angle for atom's residue","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},polymer:{"@desc":"sequential polymer number in a model, starting with 1.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},polymerLength:{"@desc":"polymer length","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},property_xx:{"@desc":"a property created using the DATA command","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},psi:{"@desc":"protein group PSI angle for the atom's residue","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,level:"atom-test"},resno:{"@desc":"PDB residue number, not including insertion code (see also seqcode, below)","@examples":["resno = 100"],regex:/-?[0-9]+/,map:e=>parseInt(e),level:"residue-test",property:xo.ammp("auth_seq_id")},selected:{"@desc":"1.0 if atom is selected; 0.0 if not","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,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:Qt,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:Qt,level:"atom-test"},shape:{"@desc":'hybridization geometry such as "tetrahedral"',"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},site:{"@desc":"crystallographic site number","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},spacefill:{"@desc":"currently displayed radius","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,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:Qt,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:Qt,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:Qt,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:Qt,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:Qt,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:Qt,level:"atom-test"},temperature:{"@desc":"yes yes temperature factor (B-factor)","@examples":["temperature >= 20"],regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.ammp("B_iso_or_equiv")},unitXyz:{"@desc":"unit cell XYZ coordinates","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},uX:{"@desc":"unit cell X coordinate normalized to [0,1)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},uY:{"@desc":"unit cell Y coordinate normalized to [0,1)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},uZ:{"@desc":"unit cell Z coordinate normalized to [0,1)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,level:"atom-test"},vanderwaals:{"@desc":"van der Waals radius","@examples":["vanderwaals >2"],regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.acp("vdw")},vectorScale:{"@desc":"vibration vector scale","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,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:Qt,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:Qt,level:"atom-test"},vY:{"@desc":"vibration vector Y coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},vZ:{"@desc":"vibration vector Z coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,level:"atom-test"}},uoe=ue,loe=[{"@desc":"Selects atoms that are not included in s1.","@examples":["not ARG"],name:"not",type:Ca,rule:Be.alt(Be.regex(/NOT/i).skip(Be.whitespace),Be.string("!").skip(Be.optWhitespace)),map:(e,t)=>Su(t)},{"@desc":"Selects atoms included in both s1 and s2.","@examples":["ASP and .CA"],name:"and",type:sc,rule:Yp(/AND|&/i),map:(e,t,n)=>uoe.struct.modifier.intersectBy({0:t,by:n})},{"@desc":"Selects atoms included in either s1 or s2.","@examples":["ASP or GLU"],name:"or",type:sc,rule:Yp(/OR|\||,/i),map:(e,t,n)=>uoe.struct.combinator.merge([t,n])}],Pe=ue,Ci={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"]},doe_nucleic=["P","O3'","O5'","C5'","C4'","C3'","OP1","OP2","O3*","O5*","C5*","C4*","C3*","C2'","C1'","O4'","O2'"],doe_protein=["C","N","CA"];function wS(){return Pe.struct.combinator.merge([Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.set(...Ci.nucleic),Pe.ammp("label_comp_id")])}),Pe.struct.filter.pick({0:Pe.struct.generator.atomGroups({"group-by":Pe.ammp("residueKey")}),test:Pe.core.logic.and([Pe.core.rel.eq([Pe.struct.atomSet.atomCount(),1]),Pe.core.rel.eq([Pe.ammp("label_atom_id"),Pe.atomName("P")])])}),Pe.struct.filter.pick({0:Pe.struct.generator.atomGroups({"group-by":Pe.ammp("residueKey")}),test:Pe.core.logic.or([Pe.core.set.isSubset([_f(["C1'","C2'","O3'","C3'","C4'","C5'","O5'"]),Pe.ammpSet("label_atom_id")]),Pe.core.set.isSubset([_f(["C1*","C2*","O3*","C3*","C4*","C5*","O5*"]),Pe.ammpSet("label_atom_id")])])})])}const foe={all:{"@desc":"all atoms; same as *",abbr:["*"],map:()=>Pe.struct.generator.all()},bonded:{"@desc":"covalently bonded",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.rel.gr([Pe.struct.atomProperty.core.bondCount({flags:Pe.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:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.rel.gr([Pe.struct.atomProperty.core.bondCount({flags:Pe.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:()=>Pe.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:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.set(...["H","He","B","C","N","O","F","Ne","Si","P","S","Cl","Ar","As","Se","Br","Kr","Te","I","Xe","At","Rn"].map(Pe.es)),Pe.acp("elementSymbol")])})},metal:{"@desc":"!nonmetal",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.logic.not([Pe.core.set.has([Pe.set(...["H","He","B","C","N","O","F","Ne","Si","P","S","Cl","Ar","As","Se","Br","Kr","Te","I","Xe","At","Rn"].map(Pe.es)),Pe.acp("elementSymbol")])])})},alkaliMetal:{"@desc":"_Li,_Na,_K,_Rb,_Cs,_Fr",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.set(...["Li","Na","K","Rb","Cs","Fr"].map(Pe.es)),Pe.acp("elementSymbol")])})},alkalineEarth:{"@desc":"_Be,_Mg,_Ca,_Sr,_Ba,_Ra",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.set(...["Be","Mg","Ca","Sr","Ba","Ra"].map(Pe.es)),Pe.acp("elementSymbol")])})},nobleGas:{"@desc":"_He,_Ne,_Ar,_Kr,_Xe,_Rn",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.set(...["He","Ne","Ar","Kr","Xe","Rn"].map(Pe.es)),Pe.acp("elementSymbol")])})},metalloid:{"@desc":"_B,_Si,_Ge,_As,_Sb,_Te",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.set(...["B","Si","Ge","As","Sb","Te"].map(Pe.es)),Pe.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:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.logic.or([Pe.core.rel.inRange([Pe.acp("atomicNumber"),21,30]),Pe.core.rel.inRange([Pe.acp("atomicNumber"),39,48]),Pe.core.rel.inRange([Pe.acp("atomicNumber"),72,80]),Pe.core.rel.inRange([Pe.acp("atomicNumber"),104,112]),Pe.core.set.has([Pe.set(57,89),Pe.acp("atomicNumber")])])})},lanthanide:{"@desc":"(does not include La) elemno>57 and elemno<=71",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.rel.inRange([Pe.acp("atomicNumber"),57,71])})},actinide:{"@desc":"(does not include Ac) elemno>89 and elemno<=103",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.rel.inRange([Pe.acp("atomicNumber"),89,103])})},isaromatic:{"@desc":"atoms connected with the AROMATIC, AROMATICSINGLE, or AROMATICDOUBLE bond types",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.rel.gr([Pe.struct.atomProperty.core.bondCount({flags:Pe.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:()=>wS()},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:()=>Pe.struct.modifier.intersectBy({0:wS(),by:Pe.struct.combinator.merge([Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.set("A","G","I","DA","DG","DI","+A","+G","+I"),Pe.ammp("label_comp_id")])}),Pe.struct.filter.pick({0:Pe.struct.generator.atomGroups({"group-by":Pe.ammp("residueKey")}),test:Pe.core.set.isSubset([_f(["N7","C8","N9"]),Pe.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:()=>Pe.struct.modifier.intersectBy({0:wS(),by:Pe.struct.combinator.merge([Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.set("C","T","U","DC","DT","DU","+C","+T","+U"),Pe.ammp("label_comp_id")])}),Pe.struct.filter.pick({0:Pe.struct.generator.atomGroups({"group-by":Pe.ammp("residueKey")}),test:Pe.core.logic.or([Pe.core.set.has([Pe.ammpSet("label_atom_id"),Pe.atomName("O2*")]),Pe.core.set.has([Pe.ammpSet("label_atom_id"),Pe.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:()=>Pe.struct.modifier.intersectBy({0:wS(),by:Pe.struct.combinator.merge([Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.set("DG","DC","DA","DT","DU","DI","T","+G","+C","+A","+T"),Pe.ammp("label_comp_id")])}),Pe.struct.filter.pick({0:Pe.struct.generator.atomGroups({"group-by":Pe.ammp("residueKey")}),test:Pe.core.logic.not([Pe.core.logic.or([Pe.core.set.has([Pe.ammpSet("label_atom_id"),Pe.atomName("O2*")]),Pe.core.set.has([Pe.ammpSet("label_atom_id"),Pe.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:()=>Pe.struct.modifier.intersectBy({0:wS(),by:Pe.struct.combinator.merge([Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.set("G","C","A","U","I","+U","+I"),Pe.ammp("label_comp_id")])}),Pe.struct.filter.pick({0:Pe.struct.generator.atomGroups({"group-by":Pe.ammp("residueKey")}),test:Pe.core.logic.or([Pe.core.set.has([Pe.ammpSet("label_atom_id"),Pe.atomName("O2*")]),Pe.core.set.has([Pe.ammpSet("label_atom_id"),Pe.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 BWe(){return Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.set(...Ci.amino),Pe.ammp("label_comp_id")])})}()},acidic:{"@desc":"ASP GLU",map:()=>er(Ci.acidic)},acyclic:{"@desc":"amino and not cyclic",map:()=>Pe.struct.modifier.intersectBy({0:er(Ci.amino),by:Su(er(Ci.cyclic))})},aliphatic:{"@desc":"ALA GLY ILE LEU VAL",map:()=>er(Ci.aliphatic)},amino:{"@desc":"all twenty standard amino acids, plus ASX, GLX, UNK",map:()=>er(Ci.amino)},aromatic:{"@desc":'HIS PHE TRP TYR (see also "isaromatic" for aromatic bonds)',map:()=>er(Ci.aromatic)},basic:{"@desc":"ARG HIS LYS",map:()=>er(Ci.basic)},buried:{"@desc":"ALA CYS ILE LEU MET PHE TRP VAL",map:()=>er(Ci.buried)},charged:{"@desc":"same as acidic or basic -- ASP GLU, ARG HIS LYS",map:()=>er(Ci.acidic.concat(Ci.basic))},cyclic:{"@desc":"HIS PHE PRO TRP TYR",map:()=>er(Ci.cyclic)},helix:{"@desc":"secondary structure-related.",map:()=>Pe.struct.generator.atomGroups({"residue-test":Pe.core.flags.hasAny([Pe.struct.type.secondaryStructureFlags(["helix"]),Pe.ammp("secondaryStructureFlags")])})},helixalpha:{"@desc":"secondary structure-related.",map:()=>Pe.struct.generator.atomGroups({"residue-test":Pe.core.flags.hasAny([Pe.struct.type.secondaryStructureFlags(["alpha"]),Pe.ammp("secondaryStructureFlags")])})},helix310:{"@desc":"secondary structure-related.",map:()=>Pe.struct.generator.atomGroups({"residue-test":Pe.core.flags.hasAny([Pe.struct.type.secondaryStructureFlags(["3-10"]),Pe.ammp("secondaryStructureFlags")])})},helixpi:{"@desc":"secondary structure-related.",map:()=>Pe.struct.generator.atomGroups({"residue-test":Pe.core.flags.hasAny([Pe.struct.type.secondaryStructureFlags(["pi"]),Pe.ammp("secondaryStructureFlags")])})},hetero:{"@desc":"PDB atoms designated as HETATM",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.ammp("isHet")})},hydrophobic:{"@desc":"ALA GLY ILE LEU MET PHE PRO TRP TYR VAL",map:()=>er(Ci.hydrophobic)},large:{"@desc":"ARG GLU GLN HIS ILE LEU LYS MET PHE TRP TYR",map:()=>er(Ci.large)},medium:{"@desc":"ASN ASP CYS PRO THR VAL",map:()=>er(Ci.medium)},negative:{"@desc":"same as acidic -- ASP GLU",map:()=>er(Ci.acidic)},neutral:{"@desc":"amino and not (acidic or basic)",map:()=>Pe.struct.modifier.intersectBy({0:er(Ci.amino),by:Su(er(Ci.acidic.concat(Ci.basic)))})},polar:{"@desc":"amino and not hydrophobic",map:()=>Pe.struct.modifier.intersectBy({0:er(Ci.amino),by:Su(er(Ci.hydrophobic))})},positive:{"@desc":"same as basic -- ARG HIS LYS",map:()=>er(Ci.basic)},sheet:{"@desc":"secondary structure-related",map:()=>Pe.struct.generator.atomGroups({"residue-test":Pe.core.flags.hasAny([Pe.struct.type.secondaryStructureFlags(["sheet"]),Pe.ammp("secondaryStructureFlags")])})},small:{"@desc":"ALA GLY SER",map:()=>er(Ci.small)},surface:{"@desc":"amino and not buried",map:()=>Pe.struct.modifier.intersectBy({0:er(Ci.amino),by:Su(er(Ci.buried))})},turn:{"@desc":"secondary structure-related",map:()=>Pe.struct.generator.atomGroups({"residue-test":Pe.core.flags.hasAny([Pe.struct.type.secondaryStructureFlags(["turn"]),Pe.ammp("secondaryStructureFlags")])})},alpha:{"@desc":"(*.CA)",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.rel.eq([Pe.atomName("CA"),Pe.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 OWe(){return Pe.struct.combinator.merge([Pe.struct.modifier.intersectBy({0:Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.core.type.set(Ci.amino),Pe.ammp("label_comp_id")])}),by:Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.core.type.set(doe_protein),Pe.ammp("label_atom_id")])})}),Pe.struct.modifier.intersectBy({0:Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.core.type.set(Ci.nucleic),Pe.ammp("label_comp_id")])}),by:Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.core.type.set(doe_nucleic),Pe.ammp("label_atom_id")])})})])}()},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'}},An=ue,LWe=[{"@desc":"value comparisons","@examples":[],name:"=",abbr:["=="],type:sc,rule:Be.regexp(/\s*(LIKE|>=|<=|=|!=|>|<)\s*/i,1),map:(e,t,n)=>{let r;if("structure"===t?r=An.core.flags.hasAny([An.ammp("secondaryStructureFlags"),aoe(n)]):"structure"===n?r=An.core.flags.hasAny([An.ammp("secondaryStructureFlags"),aoe(t)]):void 0!==t.head?"core.type.regex"===t.head.name&&(r=An.core.str.match([t,An.core.type.str([n])])):void 0!==n.head?"core.type.regex"===n.head.name&&(r=An.core.str.match([n,An.core.type.str([t])])):"LIKE"===e.toUpperCase()&&(r=An.core.str.match(t.head?[An.core.type.regex([`^${n}$`,"i"]),An.core.type.str([t])]:[An.core.type.regex([`^${t}$`,"i"]),An.core.type.str([n])])),!r)switch(t.head&&(n=SS(t,n)),n.head&&(t=SS(n,t)),e){case"=":r=An.core.rel.eq([t,n]);break;case"!=":r=An.core.rel.neq([t,n]);break;case">":r=An.core.rel.gr([t,n]);break;case"<":r=An.core.rel.lt([t,n]);break;case">=":r=An.core.rel.gre([t,n]);break;case"<=":r=An.core.rel.lte([t,n]);break;default:throw new Error(`value operator '${e}' not supported`)}return An.struct.generator.atomGroups({"atom-test":r})}}];function UWe(e){const[t,n,r,i,o,s,a]=e[1],c={};o&&(c["chain-test"]=An.core.rel.eq([An.ammp("auth_asym_id"),o]));const u=[];t&&u.push(An.core.rel.eq([An.ammp("label_comp_id"),t])),n&&u.push(An.core.logic.and([An.core.rel.gre([An.ammp("auth_seq_id"),n[0]]),An.core.rel.lte([An.ammp("auth_seq_id"),n[1]])])),r&&u.push(An.core.rel.eq([An.ammp("auth_seq_id"),r])),i&&u.push(An.core.rel.eq([An.ammp("pdbx_PDB_ins_code"),i])),u.length&&(c["residue-test"]=H5(u));const l=[];return s&&l.push(An.core.rel.eq([An.ammp("auth_atom_id"),s])),a&&l.push(An.core.rel.eq([An.ammp("label_alt_id"),a])),l.length&&(c["atom-test"]=H5(l)),An.struct.generator.atomGroups(c)}const VWe=Be.createLanguage({Integer:()=>Be.regexp(/-?[0-9]+/).map(Number).desc("integer"),Parens:function(e){return Be.alt(e.Parens,e.Operator,e.Expression).wrap(Be.regexp(/\(\s*/),Be.regexp(/\s*\)/))},Expression:function(e){return Be.alt(e.Keywords,e.AtomExpression.map(UWe),e.Within.map(t=>An.struct.modifier.includeSurroundings({0:t[1],radius:t[0]})),e.ValueQuery,e.Element.map(t=>An.struct.generator.atomGroups({"atom-test":An.core.rel.eq([An.acp("elementSymbol"),An.struct.type.elementSymbol(t)])})),e.Resname.map(t=>An.struct.generator.atomGroups({"residue-test":An.core.rel.eq([An.ammp("label_comp_id"),t])})))},Operator:function(e){return xS(loe,Be.alt(e.Parens,e.Expression))},AtomExpression:function(e){return Be.seq(Be.lookahead(e.AtomPrefix),Be.seq(e.BracketedResname.or(Be.of(null)),e.ResnoRange.or(Be.of(null)),e.Resno.or(Be.of(null)),e.Inscode.or(Be.of(null)),e.Chainname.or(Be.of(null)),e.Atomname.or(Be.of(null)),e.Altloc.or(Be.of(null)),e.Model.or(Be.of(null)))).desc("expression")},AtomPrefix:()=>Be.regexp(/[\[0-9:^%/.-]/).desc("atom-prefix"),Chainname:()=>Be.regexp(/:([A-Za-z]{1,3})/,1).desc("chainname"),Model:()=>Be.regexp(/\/([0-9]+)/,1).map(Number).desc("model"),Element:()=>Be.regexp(/_([A-Za-z]{1,3})/,1).desc("element"),Atomname:()=>Be.regexp(/\.([a-zA-Z0-9]{1,4})/,1).map(An.atomName).desc("atomname"),Resname:()=>Be.regexp(/[a-zA-Z0-9]{1,4}/).desc("resname"),Resno:e=>e.Integer.desc("resno"),Altloc:()=>Be.regexp(/%([a-zA-Z0-9])/,1).desc("altloc"),Inscode:()=>Be.regexp(/\^([a-zA-Z0-9])/,1).desc("inscode"),BracketedResname:()=>Be.regexp(/\[([a-zA-Z0-9]{1,4})\]/,1).desc("bracketed-resname"),ResnoRange:e=>Be.seq(e.Integer.skip(Be.seq(Be.optWhitespace,Be.string("-"),Be.optWhitespace)),e.Integer).desc("resno-range"),Within:e=>Be.regexp(/within/i).skip(Be.regexp(/\s*\(\s*/)).then(Be.seq(e.Integer.skip(Be.regexp(/\s*,\s*/)),e.Query)).skip(Be.regexp(/\)/)),Keywords:()=>Be.alt(...$5(foe)).desc("keyword"),Query:function(e){return Be.alt(e.Operator,e.Parens,e.Expression).trim(Be.optWhitespace)},Number:function(){return Be.regexp(/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/).map(Number).desc("number")},String:function(){const e=X5(coe,foe,loe).sort(vf).map(s2).join("|");return Be.alt(Be.regexp(new RegExp(`(?!(${e}))[A-Z0-9_]+`,"i")),Be.regexp(/'((?:[^"\\]|\\.)*)'/,1),Be.regexp(/"((?:[^"\\]|\\.)*)"/,1).map(t=>An.core.type.regex([`^${t}$`,"i"]))).desc("string")},Value:function(e){return Be.alt(e.Number,e.String)},ValueParens:function(e){return Be.alt(e.ValueParens,e.ValueOperator,e.ValueExpressions).wrap(Be.string("("),Be.string(")"))},ValuePropertyNames:function(){return Be.alt(...Y5(coe,/LIKE|>=|<=|=|!=|>|<|\)|\s/i))},ValueOperator:function(e){return xS(LWe,Be.alt(e.ValueParens,e.ValueExpressions))},ValueExpressions:function(e){return Be.alt(e.Value,e.ValuePropertyNames)},ValueQuery:function(e){return Be.alt(e.ValueOperator.map(t=>{if(t.head){if(t.head.name.startsWith("structure-query.generator"))return t}else if("string"==typeof t&&t.length<=4)return An.struct.generator.atomGroups({"residue-test":An.core.rel.eq([An.ammp("label_comp_id"),t])});throw new Error(`values must be part of an comparison, value '${t}'`)}))}}),Ls=ue,GD=/[-+]?[0-9]*\.?[0-9]+/;function Rv(e){return e.split("+").map(t=>t.replace(/^["']|["']$/g,""))}function K5(e){if(e.includes("-")&&e.includes("+")){const t=e.split("+").map(r=>r.replace(/^["']|["']$/g,"")),n=[];return t.forEach(r=>{if(r.includes("-")&&!r.startsWith("-")){const[i,o]=r.split("-").map(s=>parseInt(s));for(let s=i;s<=o;s++)n.push(s)}else if(r.includes("-")&&r.startsWith("-")&&r.match(/[0-9]+-[-0-9]+/)){const i=-parseInt(r.split("-")[1]);let o;o=r.includes("--")?-parseInt(r.split("-")[3]):parseInt(r.split("-")[2]);for(let s=i;s<=o;s++)n.push(s)}else r.includes("-")&&r.startsWith("-")&&r.match(/[0-9]+-[-0-9]+/),n.push(parseInt(r))}),n}if(e.includes("-")&&!e.includes("+")){const t=[];if(e.startsWith("-"))if(e.startsWith("-")&&e.match(/[0-9]+-[-0-9]+/)){const n=-parseInt(e.split("-")[1]);let r;r=e.includes("--")?-parseInt(e.split("-")[3]):parseInt(e.split("-")[2]);for(let i=n;i<=r;i++)t.push(i)}else e.startsWith("-")&&e.match(/[0-9]+-[-0-9]+/),t.push(parseInt(e));else{const[n,r]=e.split("-").map(i=>parseInt(i));for(let i=n;i<=r;i++)t.push(i)}return t}return!e.includes("-")&&e.includes("+")?Rv(e).map(t=>parseInt(t)):[parseInt(e)]}const HWe={H:"helix",S:"beta",L:"none"},jD={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:function jWe(e){return e.split("+").map(Ls.struct.type.elementSymbol)},level:"atom-test",property:Ls.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:function GWe(e){return e.split("+").map(Ls.atomName)},level:"atom-test",property:Ls.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:Rv,level:"residue-test",property:Ls.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:K5,level:"residue-test",property:Ls.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:Rv,level:"atom-test",property:Ls.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:Rv,level:"chain-test",property:Ls.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:Rv,level:"chain-test",property:Ls.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:e=>parseInt(e),level:"atom-test"},numeric_type:{"@desc":"type-number a single integer","@examples":["nt. 5"],isUnsupported:!0,abbr:["nt."],regex:/[0-9]+/,map:e=>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:Rv,level:"atom-test"},id:{"@desc":"external-index-number a single integer","@examples":["id 23"],regex:/[0-9+-]+/,map:K5,level:"atom-test",property:Ls.ammp("id")},index:{"@desc":"internal-index-number a single integer","@examples":["index 11"],regex:/[0-9+-]+/,map:K5,level:"atom-test",property:Ls.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:function qWe(e){return{flags:Ls.struct.type.secondaryStructureFlags(e.toUpperCase().split("+").map(t=>HWe[t]||"none"))}},level:"residue-test",property:Ls.ammp("secondaryStructureFlags")},b:{"@desc":"comparison-operator b-factor-value a real number","@examples":["b > 10"],isNumeric:!0,abbr:[],regex:GD,map:e=>parseFloat(e),level:"atom-test",property:Ls.ammp("B_iso_or_equiv")},q:{"@desc":"comparison-operator occupancy-value a real number","@examples":["q <0.50"],isNumeric:!0,abbr:[],regex:GD,map:e=>parseFloat(e),level:"atom-test",property:Ls.ammp("occupancy")},formal_charge:{"@desc":"comparison-operator formal charge-value an integer","@examples":["fc. = -1"],isNumeric:!0,abbr:["fc."],regex:GD,map:e=>parseFloat(e),level:"atom-test",property:Ls.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:GD,map:e=>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:e=>Ls.es(e),level:"atom-test",property:Ls.acp("elementSymbol")}},gn=ue,poe=[{"@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:Ca,rule:Be.alt(Be.regexp(/NOT/i).skip(Be.whitespace),Be.string("!").skip(Be.optWhitespace)),map:(e,t)=>Su(t)},{"@desc":"Selects atoms included in both s1 and s2.","@examples":["chain A AND name CA"],name:"and",type:sc,rule:Yp(/AND|&/i),map:(e,t,n)=>gn.struct.modifier.intersectBy({0:t,by:n})},{"@desc":"Selects atoms included in either s1 or s2.","@examples":["chain A OR chain B"],name:"or",type:sc,rule:Yp(/OR|\|/i),map:(e,t,n)=>gn.struct.combinator.merge([t,n])},{"@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:sc,rule:Yp(/IN/i),map:(e,t,n)=>gn.struct.filter.withSameAtomProperties({0:t,source:n,property:gn.core.type.compositeKey([gn.ammp("label_atom_id"),gn.ammp("label_seq_id"),gn.ammp("label_comp_id"),gn.ammp("auth_asym_id"),gn.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:sc,rule:Yp(/LIKE|l\./i),map:(e,t,n)=>gn.struct.filter.withSameAtomProperties({0:t,source:n,property:gn.core.type.compositeKey([gn.ammp("label_atom_id"),gn.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:VD,rule:zD(/GAP\s+([-+]?[0-9]*\.?[0-9]+)/i,1).map(e=>parseFloat(e)),map:(e,t)=>gn.struct.filter.within({0:gn.struct.generator.all(),target:t,"atom-radius":gn.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:VD,rule:zD(/(AROUND|a\.)\s+([-+]?[0-9]*\.?[0-9]+)/i,2).map(e=>parseFloat(e)),map:(e,t)=>gn.struct.modifier.exceptBy({0:gn.struct.filter.within({0:gn.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:VD,rule:zD(/(EXPAND|x\.)\s+([-+]?[0-9]*\.?[0-9]+)/i,2).map(e=>parseFloat(e)),map:(e,t)=>gn.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:sc,rule:j5("WITHIN","w."),map:(e,t,n)=>gn.struct.filter.within({0:t,target:n,"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:sc,rule:j5("NEAR_TO","nto."),map:(e,t,n)=>gn.struct.modifier.exceptBy({0:gn.struct.filter.within({0:t,target:n,"max-radius":e}),by:n})},{"@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:sc,rule:j5("BEYOND","be."),map:(e,t,n)=>gn.struct.modifier.exceptBy({0:gn.struct.filter.within({0:t,target:n,"max-radius":e,invert:!0}),by:n})},{"@desc":"Expands selection to complete residues.","@examples":["BYRESIDUE name N"],name:"byresidue",abbr:["byresi","byres","br."],type:Ca,rule:xu(/BYRESIDUE|byresi|byres|br\./i),map:(e,t)=>xf(gn.struct.modifier.expandProperty({0:gn.struct.modifier.union({0:t}),property:gn.ammp("residueKey")}))},{"@desc":"Completely selects all alpha carbons in all residues covered by a selection.","@examples":["BYCALPHA chain A"],name:"bycalpha",abbr:["bca."],type:Ca,rule:xu(/BYCALPHA|bca\./i),map:(e,t)=>gn.struct.generator.queryInSelection({0:gn.struct.modifier.expandProperty({0:gn.struct.modifier.union({0:t}),property:gn.ammp("residueKey")}),query:gn.struct.generator.atomGroups({"atom-test":gn.core.rel.eq([gn.atomName("CA"),gn.ammp("label_atom_id")])})})},{"@desc":"Expands selection to complete molecules.","@examples":["BYMOLECULE resi 20-30"],name:"bymolecule",isUnsupported:!0,abbr:["bymol","bm."],type:Ca,rule:xu(/BYMOLECULE|bymol|bm\./i),map:(e,t)=>xf(gn.struct.modifier.expandProperty({0:gn.struct.modifier.union({0:t}),property:gn.atp("connectedComponentKey")}))},{"@desc":"Expands selection to complete fragments.","@examples":["BYFRAGMENT resi 10"],name:"byfragment",abbr:["byfrag","bf."],isUnsupported:!0,type:Ca,rule:xu(/BYFRAGMENT|byfrag|bf\./i),map:(e,t)=>[e,t]},{"@desc":"Expands selection to complete segments.","@examples":["BYSEGMENT resn CYS"],name:"bysegment",abbr:["bysegi","byseg","bs."],type:Ca,rule:xu(/BYSEGMENT|bysegi|byseg|bs\./i),map:(e,t)=>xf(gn.struct.modifier.expandProperty({0:gn.struct.modifier.union({0:t}),property:gn.ammp("chainKey")}))},{"@desc":"Expands selection to complete objects.","@examples":["BYOBJECT chain A"],name:"byobject",abbr:["byobj","bo."],isUnsupported:!0,type:Ca,rule:xu(/BYOBJECT|byobj|bo\./i),map:(e,t)=>[e,t]},{"@desc":"Expands selection to unit cell.","@examples":["BYCELL chain A"],name:"bycell",isUnsupported:!0,type:Ca,rule:xu(/BYCELL/i),map:(e,t)=>[e,t]},{"@desc":"All rings of size \u2264 7 which have at least one atom in s1.","@examples":["BYRING resn HEM"],name:"byring",type:Ca,rule:xu(/BYRING/i),map:(e,t)=>xf(gn.struct.modifier.intersectBy({0:gn.struct.filter.pick({0:gn.struct.generator.rings(),test:gn.core.logic.and([gn.core.rel.lte([gn.struct.atomSet.atomCount(),7]),gn.core.rel.gr([gn.struct.atomSet.countQuery([t]),1])])}),by:t}))},{"@desc":"Selects atoms directly bonded to s1, excludes s1.","@examples":["NEIGHBOR resn CYS"],name:"neighbor",type:Ca,abbr:["nbr."],rule:xu(/NEIGHBOR|nbr\./i),map:(e,t)=>gn.struct.modifier.exceptBy({0:xf(gn.struct.modifier.includeConnected({0:gn.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:Ca,rule:xu(/BOUND_TO|bto\./i),map:(e,t)=>xf(gn.struct.modifier.includeConnected({0:gn.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:VD,rule:zD(/(EXTEND|xt\.)\s+([0-9]+)/i,2).map(e=>parseInt(e)),map:(e,t)=>xf(gn.struct.modifier.includeConnected({0:gn.struct.modifier.union({0:t}),"bond-test":!0,"layer-count":e}))}],Dt=ue,wa={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"]},hoe_nucleic=["P","O3'","O5'","C5'","C4'","C3'","OP1","OP2","O3*","O5*","C5*","C4*","C3*","C2'","C1'","O4'","O2'"],hoe_protein=["C","N","CA","O"];function moe(){return Dt.struct.combinator.merge([Dt.struct.modifier.intersectBy({0:Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.protein),Dt.ammp("label_comp_id")])}),by:Dt.struct.generator.atomGroups({"atom-test":Dt.core.set.has([Dt.core.type.set(hoe_protein),Dt.ammp("label_atom_id")])})}),Dt.struct.modifier.intersectBy({0:Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.nucleic),Dt.ammp("label_comp_id")])}),by:Dt.struct.generator.atomGroups({"atom-test":Dt.core.set.has([Dt.core.type.set(hoe_nucleic),Dt.ammp("label_atom_id")])})})])}const goe={all:{"@desc":"All atoms currently loaded into PyMOL",abbr:["*"],map:()=>Dt.struct.generator.all()},none:{"@desc":"No atoms (empty selection)",map:()=>Dt.struct.generator.empty()},hydrogens:{"@desc":"All hydrogen atoms currently loaded into PyMOL",abbr:["hydro","h."],map:()=>Dt.struct.generator.atomGroups({"atom-test":Dt.core.rel.eq([Dt.acp("elementSymbol"),Dt.es("H")])})},hetatm:{"@desc":"All atoms loaded from Protein Data Bank HETATM records",abbr:["het"],map:()=>Dt.struct.generator.atomGroups({"atom-test":Dt.core.rel.eq([Dt.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:()=>Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.nucleic.concat(wa.protein)),Dt.ammp("label_comp_id")])})},sidechain:{"@desc":"Polymer non-backbone atoms (new in PyMOL 1.6.1)",abbr:["sc."],map:()=>Dt.struct.modifier.exceptBy({0:Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.nucleic.concat(wa.protein)),Dt.ammp("label_comp_id")])}),by:moe()})},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:()=>Dt.struct.generator.atomGroups({"atom-test":Dt.core.rel.gr([Dt.struct.atomProperty.core.bondCount({flags:Dt.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:()=>xf(Dt.struct.modifier.expandProperty({0:Dt.struct.modifier.union([Dt.struct.generator.queryInSelection({0:Dt.struct.generator.atomGroups({"residue-test":Dt.core.logic.not([Dt.core.set.has([Dt.core.type.set(wa.nucleic.concat(wa.protein)),Dt.ammp("label_comp_id")])])}),query:Dt.struct.generator.atomGroups({"atom-test":Dt.core.rel.eq([Dt.es("C"),Dt.acp("elementSymbol")])})})]),property:Dt.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:()=>xf(Dt.struct.modifier.expandProperty({0:Dt.struct.modifier.union([Dt.struct.filter.pick({0:Dt.struct.generator.atomGroups({"residue-test":Dt.core.logic.not([Dt.core.set.has([Dt.core.type.set(wa.nucleic.concat(wa.protein).concat(wa.solvent)),Dt.ammp("label_comp_id")])]),"group-by":Dt.ammp("residueKey")}),test:Dt.core.logic.not([Dt.core.set.has([Dt.struct.atomSet.propertySet([Dt.acp("elementSymbol")]),Dt.es("C")])])})]),property:Dt.ammp("residueKey")}))},solvent:{"@desc":"All water molecules. The hardcoded solvent residue identifiers are currently: HOH, WAT, H20, TIP, SOL.",abbr:["sol."],map:()=>Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.solvent),Dt.ammp("label_comp_id")])})},guide:{"@desc":"All protein CA and nucleic acid C4*/C4",map:()=>Dt.struct.combinator.merge([Dt.struct.generator.atomGroups({"atom-test":Dt.core.rel.eq([Dt.atomName("CA"),Dt.ammp("label_atom_id")]),"residue-test":Dt.core.set.has([Dt.core.type.set(wa.protein),Dt.ammp("label_comp_id")])}),Dt.struct.generator.atomGroups({"atom-test":Dt.core.set.has([_f(["C4*","C4'"]),Dt.ammp("label_atom_id")]),"residue-test":Dt.core.set.has([Dt.core.type.set(wa.nucleic),Dt.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:()=>moe()},"polymer.protein":{"@desc":"Protein (New in PyMOL 2.1)",abbr:["polymer.protein"],map:()=>Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.protein),Dt.ammp("label_comp_id")])})},"polymer.nucleic":{"@desc":"Nucleic Acid (New in PyMOL 2.1)",abbr:["polymer.nucleic"],map:()=>Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.nucleic),Dt.ammp("label_comp_id")])})}},WWe=ue,So=function TWe(e){const t={};return Object.keys(e).sort(vf).forEach(n=>{const r=e[n],i=bm(`property '${n}' not supported`),o=Be.regexp(r.regex).map(s=>(r.isUnsupported&&i(),q5(r.property,r.map(s))));r.isNumeric||(t[n]=o)}),t}(jD),Mo=Be.string("/");function bi(e){return e.or(Be.of(null))}function $We(e){const t={},n={};for(const r in e){const i=jD[r];if(!i)throw new Error(`property '${r}' not supported, value '${e[r]}'`);null!==e[r]&&(n[i.level]||(n[i.level]=[]),n[i.level].push(e[r]))}for(const r in n)t[r]=H5(n[r]);return WWe.struct.generator.atomGroups(t)}const YWe=Be.createLanguage({Parens:function(e){return Be.alt(e.Parens,e.Operator,e.Expression).wrap(Be.string("("),Be.string(")"))},Expression:function(e){return Be.alt(e.Keywords,e.AtomSelectionMacro.map($We),e.NamedAtomProperties,e.Pepseq,e.Rep,e.Object)},AtomSelectionMacro:function(e){return Be.alt(Mo.then(Be.alt(Be.seq(bi(e.ObjectProperty).skip(Mo),bi(So.segi).skip(Mo),bi(So.chain).skip(Mo),bi(So.resi).skip(Mo),bi(So.name)).map(t=>({object:t[0],segi:t[1],chain:t[2],resi:t[3],name:t[4]})),Be.seq(bi(e.ObjectProperty).skip(Mo),bi(So.segi).skip(Mo),bi(So.chain).skip(Mo),bi(So.resi)).map(t=>({object:t[0],segi:t[1],chain:t[2],resi:t[3]})),Be.seq(bi(e.ObjectProperty).skip(Mo),bi(So.segi).skip(Mo),bi(So.chain)).map(t=>({object:t[0],segi:t[1],chain:t[2]})),Be.seq(bi(e.ObjectProperty).skip(Mo),bi(So.segi)).map(t=>({object:t[0],segi:t[1]})),Be.seq(bi(e.ObjectProperty)).map(t=>({object:t[0]})))),Be.alt(Be.seq(bi(e.ObjectProperty).skip(Mo),bi(So.segi).skip(Mo),bi(So.chain).skip(Mo),bi(So.resi).skip(Mo),bi(So.name)).map(t=>({object:t[0],segi:t[1],chain:t[2],resi:t[3],name:t[4]})),Be.seq(bi(So.segi).skip(Mo),bi(So.chain).skip(Mo),bi(So.resi).skip(Mo),bi(So.name)).map(t=>({segi:t[0],chain:t[1],resi:t[2],name:t[3]})),Be.seq(bi(So.chain).skip(Mo),bi(So.resi).skip(Mo),bi(So.name)).map(t=>({chain:t[0],resi:t[1],name:t[2]})),Be.seq(bi(So.resi).skip(Mo),bi(So.name)).map(t=>({resi:t[0],name:t[1]}))))},NamedAtomProperties:function(){return Be.alt(...ooe(jD))},Keywords:()=>Be.alt(...$5(goe)),ObjectProperty:()=>{const e=X5(jD,goe,poe).sort(vf).map(s2).join("|");return Be.regexp(new RegExp(`(?!(${e}))[A-Z0-9_]+`,"i"))},Object:e=>e.ObjectProperty.notFollowedBy(Mo).map(t=>{throw new Error(`property 'object' not supported, value '${t}'`)}),Pepseq:()=>Be.regexp(/(PEPSEQ|ps\.)\s+([a-z]+)/i,2).map(bm("operator 'pepseq' not supported")),Rep:()=>Be.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(bm("operator 'rep' not supported")),Operator:function(e){return xS(poe,Be.alt(e.Parens,e.Expression,e.Operator))},Query:function(e){return Be.alt(e.Operator,e.Parens,e.Expression).trim(Be.optWhitespace)}}),co=ue,Bc=/[-+]?[0-9]*\.?[0-9]+/,HD=/[+]?[0-9]+/,AS=/[-+]?[0-9]+/;function h0(e){return e}const yoe={T:"turn",E:"sheet",B:"strand",H:"alpha",G:"3-10",I:"pi",C:"none"};function Z5(e){return co.struct.type.secondaryStructureFlags([yoe[e.toUpperCase()]||"none"])}const m0={name:{"@desc":"str atom name","@examples":["name CA"],regex:/[a-zA-Z0-9]+/,map:co.atomName,level:"atom-test",property:co.ammp("label_atom_id")},type:{"@desc":"str atom type","@examples":["type C3"],isUnsupported:!0,regex:/[a-zA-Z0-9]+/,map:h0,level:"atom-test"},index:{"@desc":"num the atom number, starting at 0","@examples":["index 10"],isNumeric:!0,regex:HD,map:e=>parseInt(e)-1,level:"atom-test",property:co.ammp("id")},serial:{"@desc":"num the atom number, starting at 1","@examples":["serial 11"],isNumeric:!0,regex:HD,map:e=>parseInt(e),level:"atom-test",property:co.ammp("id")},atomicnumber:{"@desc":"num atomic number (0 if undefined)","@examples":["atomicnumber 13"],isNumeric:!0,regex:HD,map:e=>parseInt(e),level:"atom-test",property:co.acp("atomicNumber")},element:{"@desc":'str atomic element symbol string ("X" if undefined)',"@examples":["element N"],regex:/[a-zA-Z0-9]{1,3}/,map:e=>co.es(e),level:"atom-test",property:co.acp("elementSymbol")},altloc:{"@desc":"str alternate location/conformation identifier","@examples":["altloc C"],regex:/[a-zA-Z0-9]+/,map:h0,level:"atom-test",property:co.ammp("label_alt_id")},chain:{"@desc":"str the one-character chain identifier","@examples":["chain A"],regex:/[a-zA-Z0-9]+/,map:h0,level:"residue-test",property:co.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:AS,map:e=>parseInt(e),level:"residue-test",property:co.ammp("auth_seq_id")},fragment:{"@desc":"num a set of connected residues","@examples":["fragment 42"],isUnsupported:!0,isNumeric:!0,regex:AS,map:e=>parseInt(e),level:"residue-test"},pfrag:{"@desc":"num a set of connected protein residues","@examples":["pfrag 42"],isUnsupported:!0,isNumeric:!0,regex:AS,map:e=>parseInt(e),level:"residue-test"},nfrag:{"@desc":"num a set of connected nucleic residues","@examples":["nfrag 42"],isUnsupported:!0,isNumeric:!0,regex:AS,map:e=>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:h0,level:"residue-test"},numbonds:{"@desc":"num number of bonds","@examples":["numbonds = 2","numbonds >= 3"],isNumeric:!0,regex:HD,map:e=>parseInt(e),level:"atom-test",property:co.acp("bondCount")},resname:{"@desc":"str residue name","@examples":["resname ALA"],regex:/[a-zA-Z0-9]+/,map:h0,level:"residue-test",property:co.ammp("auth_comp_id")},resid:{"@desc":"num residue id","@examples":["resid 42"],isNumeric:!0,regex:AS,map:e=>parseInt(e),level:"residue-test",property:co.ammp("auth_seq_id")},segname:{"@desc":"str segment name","@examples":["segname B"],regex:/[a-zA-Z0-9]+/,map:h0,level:"residue-test",property:co.ammp("label_asym_id")},x:{"@desc":"float x coordinate","@examples":["x 42"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.acp("x")},y:{"@desc":"float y coordinate","@examples":["y > 1.7"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.acp("y")},z:{"@desc":"float z coordinate","@examples":["z < 11","z > -21"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.acp("z")},radius:{"@desc":"float atomic radius","@examples":["radius > 1.3"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.acp("vdw")},mass:{"@desc":"float atomic mass","@examples":["mass > 2"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.acp("mass")},charge:{"@desc":"float atomic charge","@examples":["charge > 0","charge 1"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.ammp("pdbx_formal_charge")},beta:{"@desc":"float temperature factor","@examples":["beta < 20","beta > 35"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.ammp("B_iso_or_equiv")},occupancy:{"@desc":"float occupancy","@examples":["occupancy 1","occupancy < 1"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.ammp("occupancy")},user:{"@desc":"float time-varying user-specified value","@examples":["user < 0.1"],isUnsupported:!0,isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test"},rasmol:{"@desc":"str translates Rasmol selection string to VMD","@examples":["rasmol 'all'"],isUnsupported:!0,regex:/[^']*/,map:h0,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:Z5,level:"atom-test",property:co.ammp("secondaryStructureFlags")},phi:{"@desc":"float phi backbone conformational angles","@examples":["phi < 160"],isUnsupported:!0,isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"residue-test"},psi:{"@desc":"float psi backbone conformational angles","@examples":["psi < 160"],isUnsupported:!0,isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"residue-test"},ufx:{"@desc":"num force to apply in the x coordinate","@examples":["ufx 1"],isUnsupported:!0,isNumeric:!0,regex:Bc,map:e=>parseInt(e),level:"atom-test"},ufy:{"@desc":"num force to apply in the y coordinate","@examples":["ufy 1"],isUnsupported:!0,isNumeric:!0,regex:Bc,map:e=>parseInt(e),level:"atom-test"},ufz:{"@desc":"num force to apply in the z coordinate","@examples":["ufz 1"],isUnsupported:!0,isNumeric:!0,regex:Bc,map:e=>parseInt(e),level:"atom-test"}},g0=ue,KWe=Object.keys(m0).sort(vf).filter(e=>!m0[e].isUnsupported).join("|"),boe=[{"@desc":"Selects atoms that are not included in s1.","@examples":["not protein"],name:"not",type:Ca,rule:Be.regexp(/NOT/i).skip(Be.whitespace),map:(e,t)=>Su(t)},{"@desc":"Selects atoms within a specified distance of a selection","@examples":["within 5 of name FE"],name:"within",type:Ca,rule:xu(/WITHIN\s+([-+]?[0-9]*\.?[0-9]+)\s+OF/i,1).map(e=>parseFloat(e)),map:(e,t)=>g0.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:Ca,rule:xu(/EXWITHIN\s+([-+]?[0-9]*\.?[0-9]+)\s+OF/i,1).map(e=>parseFloat(e)),map:(e,t)=>g0.struct.modifier.exceptBy({0:g0.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:Ca,rule:xu(new RegExp(`SAME\\s+(${KWe})\\s+AS`,"i"),1).map(e=>m0[e].property),map:(e,t)=>g0.struct.filter.withSameAtomProperties({0:g0.struct.generator.all(),source:t,property:e})},{"@desc":"Selects atoms included in both s1 and s2.","@examples":["backbone and protein"],name:"and",type:sc,rule:Be.alt(Yp(/AND/i),Be.whitespace),map:(e,t,n)=>g0.struct.modifier.intersectBy({0:t,by:n})},{"@desc":"Selects atoms included in either s1 or s2.","@examples":["water or protein"],name:"or",type:sc,rule:Yp(/OR/i),map:(e,t,n)=>g0.struct.combinator.merge([t,n])}],Dn=ue;function Xp(){return Dn.struct.filter.pick({0:Dn.struct.generator.atomGroups({"group-by":Dn.ammp("residueKey")}),test:Dn.core.set.isSubset([_f(["C","N","CA","O"]),Dn.ammpSet("label_atom_id")])})}function Q5(){return Dn.struct.filter.pick({0:Dn.struct.generator.atomGroups({"group-by":Dn.ammp("residueKey")}),test:Dn.core.logic.and([Dn.core.set.isSubset([_f(["P"]),Dn.ammpSet("label_atom_id")]),Dn.core.logic.or([Dn.core.set.isSubset([_f(["O3'","C3'","C4'","C5'","O5'"]),Dn.ammpSet("label_atom_id")]),Dn.core.set.isSubset([_f(["O3*","C3*","C4*","C5*","O5*"]),Dn.ammpSet("label_atom_id")])])])})}function voe(){return Dn.struct.combinator.merge([Dn.struct.generator.queryInSelection({0:Xp(),query:Dn.struct.generator.atomGroups({"atom-test":Dn.core.set.has([_f(_oe.protein),Dn.ammp("label_atom_id")])})}),Dn.struct.generator.queryInSelection({0:Q5(),query:Dn.struct.generator.atomGroups({"atom-test":Dn.core.set.has([_f(_oe.nucleic),Dn.ammp("label_atom_id")])})})])}function Sf(e){return Dn.struct.generator.atomGroups({"residue-test":Dn.core.flags.hasAll([Dn.ammp("secondaryStructureFlags"),Dn.struct.type.secondaryStructureFlags(e)])})}const _oe={nucleic:["P","O3'","O5'","C5'","C4'","C3'","OP1","OP2","O3*","O5*","C5*","C4*","C3*"],protein:["C","N","CA","O"]},Ro={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"]},xoe={all:{"@desc":"everything",map:()=>Dn.struct.generator.all()},none:{"@desc":"nothing",map:()=>Dn.struct.generator.empty()},protein:{"@desc":"a residue with atoms named C, N, CA, and O",map:()=>Xp()},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:()=>Q5()},backbone:{"@desc":"the C, N, CA, and O atoms of a protein and the equivalent atoms in a nucleic acid.",map:()=>voe()},sidechain:{"@desc":"non-backbone atoms and bonds",map:()=>Su(voe())},water:{"@desc":"all atoms with the resname H2O, HH0, OHH, HOH, OH2, SOL, WAT, TIP, TIP2, TIP3 or TIP4",abbr:["waters"],map:()=>er(Ro.water)},at:{"@desc":"residues named ADA A THY T",map:()=>er(Ro.at)},acidic:{"@desc":"residues named ASP GLU",map:()=>er(Ro.acidic)},acyclic:{"@desc":'"protein and not cyclic"',map:()=>Dn.struct.modifier.intersectBy({0:Xp(),by:Su(er(Ro.cyclic))})},aliphatic:{"@desc":"residues named ALA GLY ILE LEU VAL",map:()=>er(Ro.aliphatic)},alpha:{"@desc":"atom's residue is an alpha helix",map:()=>Sf(["alpha"])},amino:{"@desc":"a residue with atoms named C, N, CA, and O",map:()=>Xp()},aromatic:{"@desc":"residues named HIS PHE TRP TYR",map:()=>er(Ro.aromatic)},basic:{"@desc":"residues named ARG HIS LYS",map:()=>er(Ro.basic)},bonded:{"@desc":"atoms for which numbonds > 0",map:()=>xf(Dn.struct.filter.pick({0:Dn.struct.modifier.includeConnected({0:Dn.struct.generator.all(),"bond-test":Dn.core.flags.hasAny([Dn.struct.bondProperty.flags(),Dn.struct.type.bondFlags(["covalent","metallic","sulfide"])])}),test:Dn.core.rel.gr([Dn.struct.atomSet.atomCount(),1])}))},buried:{"@desc":"residues named ALA LEU VAL ILE PHE CYS MET TRP",map:()=>er(Ro.buried)},cg:{"@desc":"residues named CYT C GUA G",map:()=>er(Ro.cg)},charged:{"@desc":'"basic or acidic"',map:()=>er(Ro.basic.concat(Ro.acidic))},cyclic:{"@desc":"residues named HIS PHE PRO TRP TYR",map:()=>er(Ro.cyclic)},hetero:{"@desc":'"not (protein or nucleic)"',map:()=>Su(Dn.struct.combinator.merge([Xp(),Q5()]))},hydrogen:{"@desc":'name "[0-9]?H.*"',map:()=>Dn.struct.generator.atomGroups({"atom-test":Dn.core.str.match([Dn.core.type.regex(["^[0-9]?[H].*$","i"]),Dn.core.type.str([Dn.ammp("label_atom_id")])])})},large:{"@desc":'"protein and not (small or medium)"',map:()=>Dn.struct.modifier.intersectBy({0:Xp(),by:Su(er(Ro.small.concat(Ro.medium)))})},medium:{"@desc":"residues named VAL THR ASP ASN PRO CYS ASX PCA HYP",map:()=>er(Ro.medium)},neutral:{"@desc":"residues named VAL PHE GLN TYR HIS CYS MET TRP ASX GLX PCA HYP",map:()=>er(Ro.neutral)},hydrophobic:{"@desc":"hydrophobic resname ALA LEU VAL ILE PRO PHE MET TRP",map:()=>er(Ro.hydrophobic)},polar:{"@desc":'"protein and not hydrophobic"',map:()=>Dn.struct.modifier.intersectBy({0:Xp(),by:Su(er(Ro.hydrophobic))})},purine:{"@desc":"residues named ADE A GUA G",map:()=>er(Ro.purine)},pyrimidine:{"@desc":"residues named CYT C THY T URI U",map:()=>er(Ro.pyrimidine)},small:{"@desc":"residues named ALA GLY SER",map:()=>er(Ro.small)},surface:{"@desc":'"protein and not buried"',map:()=>Dn.struct.modifier.intersectBy({0:Xp(),by:Su(er(Ro.buried))})},alpha_helix:{"@desc":"atom's residue is in an alpha helix",map:()=>Sf(["alpha"])},pi_helix:{"@desc":"atom's residue is in a pi helix",map:()=>Sf(["pi"])},helix_3_10:{"@desc":"atom's residue is in a 3-10 helix",map:()=>Sf(["3-10"])},helix:{"@desc":"atom's residue is in an alpha or pi or 3-10 helix",map:()=>Sf(["helix"])},extended_beta:{"@desc":"atom's residue is a beta sheet",map:()=>Sf(["sheet"])},bridge_beta:{"@desc":"atom's residue is a beta sheet",map:()=>Sf(["strand"])},sheet:{"@desc":"atom's residue is a beta sheet",map:()=>Sf(["beta"])},turn:{"@desc":"atom's residue is in a turn conformation",map:()=>Sf(["turn"])},coil:{"@desc":"atom's residue is in a coil conformation",map:()=>Dn.struct.modifier.intersectBy({0:Xp(),by:Sf(["none"])})}},ia=ue,ZWe={sqr:{"@desc":"square of x","@examples":["sqr(2)"],map:e=>ia.core.math.pow([e,2])},sqrt:{"@desc":"square root of x","@examples":["sqrt(2)"],map:e=>ia.core.math.sqrt([e])},abs:{"@desc":"absolute value of x","@examples":["abs(2)"],map:e=>ia.core.math.abs([e])},floor:{"@desc":"largest integer not greater than x","@examples":["floor(2)"],map:e=>ia.core.math.floor([e])},ceil:{"@desc":"smallest integer not less than x","@examples":["ceil(2)"],map:e=>ia.core.math.ceil([e])},sin:{"@desc":"sine of x","@examples":["sin(2)"],map:e=>ia.core.math.sin([e])},cos:{"@desc":"cosine of x","@examples":["cos(2)"],map:e=>ia.core.math.cos([e])},tan:{"@desc":"tangent of x","@examples":["tan(2)"],map:e=>ia.core.math.tan([e])},atan:{"@desc":"arctangent of x","@examples":["atan(2)"],map:e=>ia.core.math.atan([e])},asin:{"@desc":"arcsin of x","@examples":["asin(2)"],map:e=>ia.core.math.asin([e])},acos:{"@desc":"arccos of x","@examples":["acos(2)"],map:e=>ia.core.math.acos([e])},sinh:{"@desc":"hyperbolic sine of x","@examples":["sinh(2)"],map:e=>ia.core.math.sinh([e])},cosh:{"@desc":"hyperbolic cosine of x","@examples":["cosh(2)"],map:e=>ia.core.math.cosh([e])},tanh:{"@desc":"hyperbolic tangent of x","@examples":["tanh(2)"],map:e=>ia.core.math.tanh([e])},exp:{"@desc":"e to the power x","@examples":["exp(2)"],map:e=>ia.core.math.exp([e])},log:{"@desc":"natural log of x","@examples":["log(2)"],map:e=>ia.core.math.log([e])},log10:{"@desc":"log base 10 of x","@examples":["log10(2)"],map:e=>ia.core.math.log10([e])}},Di=ue,QWe=[{"@desc":"multiplication, division","@examples":[],name:"mul-div",type:sc,rule:Be.regexp(/\s*(\*|\/)\s*/,1),map:(e,t,n)=>{switch(e){case"*":return Di.core.math.mult([t,n]);case"/":return Di.core.math.div([t,n]);default:throw new Error(`value operator '${e}' not supported`)}}},{"@desc":"addition, substraction","@examples":[],name:"add-sub",type:sc,rule:Be.regexp(/\s*(-|\+)\s*/,1),map:(e,t,n)=>{switch(e){case"-":return Di.core.math.sub([t,n]);case"+":return Di.core.math.add([t,n]);default:throw new Error(`value operator '${e}' not supported`)}}},{"@desc":"value comparisons","@examples":[],name:"comparison",type:sc,rule:Be.alt(Be.regexp(/\s*(=~|==|>=|<=|=|!=|>|<)\s*/,1),Be.whitespace.result("=")),map:(e,t,n)=>{let r;if(void 0!==t.head?("structure-query.atom-property.macromolecular.secondary-structure-flags"===t.head.name&&(r=Di.core.flags.hasAny([t,Z5(n)])),"core.type.regex"===t.head.name&&(r=Di.core.str.match([t,Di.core.type.str([n])]))):void 0!==n.head?("structure-query.atom-property.macromolecular.secondary-structure-flags"===n.head.name&&(r=Di.core.flags.hasAny([n,Z5(t)])),"core.type.regex"===n.head.name&&(r=Di.core.str.match([n,Di.core.type.str([t])]))):"=~"===e&&(r=Di.core.str.match(t.head?[Di.core.type.regex([`^${n}$`,"i"]),Di.core.type.str([t])]:[Di.core.type.regex([`^${t}$`,"i"]),Di.core.type.str([n])])),!r)switch(t.head&&(n=SS(t,n)),n.head&&(t=SS(n,t)),e){case"=":case"==":r=Di.core.rel.eq([t,n]);break;case"!=":r=Di.core.rel.neq([t,n]);break;case">":r=Di.core.rel.gr([t,n]);break;case"<":r=Di.core.rel.lt([t,n]);break;case">=":r=Di.core.rel.gre([t,n]);break;case"<=":r=Di.core.rel.lte([t,n]);break;default:throw new Error(`value operator '${e}' not supported`)}return Di.struct.generator.atomGroups({"atom-test":r})}}],JWe=Be.createLanguage({Parens:function(e){return Be.alt(e.Parens,e.Operator,e.Expression).wrap(Be.string("("),Be.string(")"))},Expression:function(e){return Be.alt(e.RangeListProperty,e.ValueQuery,e.Keywords)},NamedAtomProperties:function(){return Be.alt(...ooe(m0))},Keywords:()=>Be.alt(...$5(xoe)),ValueRange:function(e){return Be.seq(e.Value.skip(Be.regexp(/\s+TO\s+/i)),e.Value).map(t=>({range:t}))},RangeListProperty:function(e){return Be.seq(Be.alt(...Y5(m0,/\s/)).skip(Be.whitespace),Be.alt(e.ValueRange,e.Value).sepBy1(Be.whitespace)).map(t=>{const[n,r]=t,i=[],o=[];r.forEach(u=>{u.range?o.push(Di.core.rel.inRange([n,u.range[0],u.range[1]])):i.push(SS(n,u,yoe))});const s=function IWe(e){return 1===e.length?e[0]:e.length>1?$r.core.logic.or(e):void 0}(o),a=function NWe(e,t){if(kWe.includes(e.head.name)){const n=t[0].head,r=[];return t.forEach(i=>r.push(...i.args[0])),$r.core.flags.hasAny([e,{head:n,args:r}])}return 1===t.length?$r.core.rel.eq([e,t[0]]):t.length>1?$r.core.set.has([$r.core.type.set(t),e]):void 0}(n,i);let c;return c=s&&a?Di.core.logic.or([s,a]):s||a,Di.struct.generator.atomGroups({[RWe(n)]:c})})},Operator:function(e){return xS(boe,Be.alt(e.Parens,e.Expression,e.ValueQuery))},Query:function(e){return Be.alt(e.Operator,e.Parens,e.Expression).trim(Be.optWhitespace)},Number:function(){return Be.regexp(/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/).map(Number).desc("number")},String:function(){const e=X5(m0,xoe,boe).sort(vf).map(s2).join("|");return Be.alt(Be.regexp(new RegExp(`(?!(${e}))[A-Z0-9_]+`,"i")),Be.regexp(/'((?:[^"\\]|\\.)*)'/,1),Be.regexp(/"((?:[^"\\]|\\.)*)"/,1).map(t=>Di.core.type.regex([`^${t}$`,"i"]))).desc("string")},Value:function(e){return Be.alt(e.Number,e.String)},ValueParens:function(e){return Be.alt(e.ValueParens,e.ValueOperator,e.ValueExpressions).wrap(Be.string("("),Be.string(")"))},ValuePropertyNames:function(){return Be.alt(...Y5(m0,/=~|==|>=|<=|=|!=|>|<|\)|\s|\+|-|\*|\//i))},ValueOperator:function(e){return xS(QWe,Be.alt(e.ValueParens,e.ValueExpressions))},ValueExpressions:function(e){return Be.alt(e.ValueFunctions,e.Value,e.ValuePropertyNames)},ValueFunctions:function(e){return Be.alt(...function DWe(e,t){const n=[],r=Be.regexp(/\(\s*/),i=Be.regexp(/\s*\)/);return Object.keys(e).sort(vf).forEach(o=>{const s=e[o],a=s.map?s.map:bm(`function '${o}' not supported`),c=Be.regexp(new RegExp(o,"i")).skip(r).then(t).skip(i).map(a);n.push(c)}),n}(ZWe,e.ValueOperator))},ValueQuery:function(e){return Be.alt(e.ValueOperator.map(t=>{if(!t.head.name||!t.head.name.startsWith("structure-query.generator"))throw new Error(`values must be part of an comparison, value '${t}'`);return t}))}}),e$e={pymol:e=>YWe.Query.tryParse(e),vmd:e=>JWe.Query.tryParse(e),jmol:e=>VWe.Query.tryParse(e)},qD=new class n$e{constructor(){this.map=new Map}removeSymbol(t){this.map.delete(t.symbol.id)}addSymbol(t){this.map.has(t.symbol.id)&&console.warn(`Symbol '${t.symbol.id}' already added. Call removeSymbol/removeCustomProps re-adding the symbol.`),this.map.set(t.symbol.id,t)}addCustomProp(t){if(t.symbols)for(const n of Object.keys(t.symbols))this.addSymbol(t.symbols[n])}removeCustomProp(t){if(t.symbols)for(const n of Object.keys(t.symbols))this.removeSymbol(t.symbols[n])}getRuntime(t){return this.map.get(t)}};class r$e{constructor(t){this.table=t,this.constQueryContext=new qu(Ve.Empty)}}var Soe,y0,IS,kv;!function(e){e.Const=function t(r){return{kind:"const",value:r}},e.Dynamic=function n(r){return{kind:"dynamic",runtime:r}}}(Soe||(Soe={})),function(e){e.Const=function t(r){return{isConst:!0,fn:function(o){return r}}},e.Dynamic=function n(r){return{isConst:!1,fn:r}}}(y0||(y0={})),function(e){e.forEachEval=function t(n,r,i,o){if("number"==typeof n.length)for(let s=0,a=n.length;so[i]=r,[])}),rn(ye.core.type.set,function(t,n){return IS.forEachEval(n,t,function(i,o,s){return s.add(i)},new Set)}),rn(ye.core.type.regex,function(t,n){return new RegExp(n[0](t),n[1]&&n[1](t)||"")}),rn(ye.core.type.bitflags,function(t,n){return+n[0](t)}),rn(ye.core.type.compositeKey,function(t,n){return IS.forEachEval(n,t,(r,i,o)=>o[i]=""+r,[]).join("-")}),rn(ye.core.logic.not,(e,t)=>!t[0](e)),rn(ye.core.logic.and,(e,t)=>{if("number"==typeof t.length){for(let n=0,r=t.length;n{if("number"==typeof t.length){for(let n=0,r=t.length;nt[0](e)===t[1](e)),rn(ye.core.rel.neq,(e,t)=>t[0](e)!==t[1](e)),rn(ye.core.rel.lt,(e,t)=>t[0](e)t[0](e)<=t[1](e)),rn(ye.core.rel.gr,(e,t)=>t[0](e)>t[1](e)),rn(ye.core.rel.gre,(e,t)=>t[0](e)>=t[1](e)),rn(ye.core.rel.inRange,(e,t)=>{const n=t[0](e);return n>=t[1](e)&&n<=t[2](e)}),rn(ye.core.math.add,(e,t)=>{let n=0;if("number"==typeof t.length)for(let r=0,i=t.length;r{let n=0;if("number"==typeof t.length){if(1===t.length)return-t[0](e);n=t[0](e)||0;for(let r=1,i=t.length;r{let n=1;if("number"==typeof t.length)for(let r=0,i=t.length;rt[0](e)/t[1](e)),rn(ye.core.math.pow,(e,t)=>Math.pow(t[0](e),t[1](e))),rn(ye.core.math.mod,(e,t)=>t[0](e)%t[1](e)),rn(ye.core.math.min,(e,t)=>{let n=Number.POSITIVE_INFINITY;if("number"==typeof t.length)for(let r=0,i=t.length;r{let n=Number.NEGATIVE_INFINITY;if("number"==typeof t.length)for(let r=0,i=t.length;ruu(t[0](e),t[1](e))),rn(ye.core.math.sortedCantorPairing,(e,t)=>t2(t[0](e),t[1](e))),rn(ye.core.math.invertCantorPairing,(e,t)=>XZ([0,0],t[0](e))),rn(ye.core.math.floor,(e,t)=>Math.floor(t[0](e))),rn(ye.core.math.ceil,(e,t)=>Math.ceil(t[0](e))),rn(ye.core.math.roundInt,(e,t)=>Math.round(t[0](e))),rn(ye.core.math.trunc,(e,t)=>Math.trunc(t[0](e))),rn(ye.core.math.abs,(e,t)=>Math.abs(t[0](e))),rn(ye.core.math.sign,(e,t)=>Math.sign(t[0](e))),rn(ye.core.math.sqrt,(e,t)=>Math.sqrt(t[0](e))),rn(ye.core.math.cbrt,(e,t)=>Math.cbrt(t[0](e))),rn(ye.core.math.sin,(e,t)=>Math.sin(t[0](e))),rn(ye.core.math.cos,(e,t)=>Math.cos(t[0](e))),rn(ye.core.math.tan,(e,t)=>Math.tan(t[0](e))),rn(ye.core.math.asin,(e,t)=>Math.asin(t[0](e))),rn(ye.core.math.acos,(e,t)=>Math.acos(t[0](e))),rn(ye.core.math.atan,(e,t)=>Math.atan(t[0](e))),rn(ye.core.math.sinh,(e,t)=>Math.sinh(t[0](e))),rn(ye.core.math.cosh,(e,t)=>Math.cosh(t[0](e))),rn(ye.core.math.tanh,(e,t)=>Math.tanh(t[0](e))),rn(ye.core.math.exp,(e,t)=>Math.exp(t[0](e))),rn(ye.core.math.log,(e,t)=>Math.log(t[0](e))),rn(ye.core.math.log10,(e,t)=>Math.log10(t[0](e))),rn(ye.core.math.atan2,(e,t)=>Math.atan2(t[0](e),t[1](e))),rn(ye.core.str.match,(e,t)=>t[0](e).test(t[1](e))),rn(ye.core.str.concat,(e,t)=>{const n=[];if("number"==typeof t.length)for(let r=0,i=t.length;rt[0](e)[t[1](e)]),rn(ye.core.list.equal,(e,t)=>LZ(t[0](e),t[1](e))),rn(ye.core.set.has,function(t,n){return n[0](t).has(n[1](t))}),rn(ye.core.set.isSubset,function(t,n){return Si.isSuperset(n[1](t),n[0](t))}),rn(ye.core.flags.hasAny,(e,t)=>{const n=t[1](e),r=t[0](e);return n?!!(r&n):!!r}),rn(ye.core.flags.hasAll,(e,t)=>{const n=t[1](e),r=t[0](e);return n?(r&n)===n:!r}),rn(ye.structureQuery.type.elementSymbol,(e,t)=>Bg(t[0](e))),rn(ye.structureQuery.type.atomName,(e,t)=>function MNe(e){return e?"string"==typeof e?e.toUpperCase():`${e}`.toUpperCase():""}(t[0](e))),rn(ye.structureQuery.type.bondFlags,(e,t)=>{let n=0;if("number"==typeof t.length)for(let r=0,i=t.length;rHu.elementFingerprint(function o$e(e,t){const n=[];if(!t)return n;if("number"==typeof t.length)for(let r=0,i=t.length;r{let n=0;if("number"==typeof t.length)for(let r=0,i=t.length;rSr.filters.pick(t[0],t.test)(e)),Vt(ye.structureQuery.filter.first,(e,t)=>Sr.filters.first(t[0])(e)),Vt(ye.structureQuery.filter.withSameAtomProperties,(e,t)=>Sr.filters.withSameAtomProperties(t[0],t.source,t.property)(e)),Vt(ye.structureQuery.filter.intersectedBy,(e,t)=>Sr.filters.areIntersectedBy(t[0],t.by)(e)),Vt(ye.structureQuery.filter.within,(e,t)=>{var n,r,i;return Sr.filters.within({query:t[0],target:t.target,minRadius:null===(n=t["min-radius"])||void 0===n?void 0:n.call(t,e),maxRadius:null===(r=t["max-radius"])||void 0===r?void 0:r.call(t,e),elementRadius:t["atom-radius"],invert:null===(i=t.invert)||void 0===i?void 0:i.call(t,e)})(e)}),Vt(ye.structureQuery.filter.isConnectedTo,(e,t)=>{var n,r;return Sr.filters.isConnectedTo({query:t[0],target:t.target,disjunct:null===(n=t.disjunct)||void 0===n?void 0:n.call(t,e),invert:null===(r=t.invert)||void 0===r?void 0:r.call(t,e),bondTest:t["bond-test"]})(e)}),Vt(ye.structureQuery.generator.atomGroups,function(t,n){return Sr.generators.atoms({entityTest:n["entity-test"],chainTest:n["chain-test"],residueTest:n["residue-test"],atomTest:n["atom-test"],groupBy:n["group-by"]})(t)}),Vt(ye.structureQuery.generator.all,function(t){return Sr.generators.all(t)}),Vt(ye.structureQuery.generator.empty,function(t){return Sr.generators.none(t)}),Vt(ye.structureQuery.generator.bondedAtomicPairs,function(t,n){return Sr.generators.bondedAtomicPairs(n&&n[0])(t)}),Vt(ye.structureQuery.generator.rings,function(t,n){var r,i;return Sr.generators.rings(null===(r=n?.fingerprint)||void 0===r?void 0:r.call(n,t),null===(i=n?.["only-aromatic"])||void 0===i?void 0:i.call(n,t))(t)}),Vt(ye.structureQuery.generator.queryInSelection,function(t,n){var r;return Sr.generators.querySelection(n[0],n.query,null===(r=n["in-complement"])||void 0===r?void 0:r.call(n,t))(t)}),Vt(ye.structureQuery.modifier.includeSurroundings,function(t,n){return Sr.modifiers.includeSurroundings(n[0],{radius:n.radius(t),wholeResidues:!(!n["as-whole-residues"]||!n["as-whole-residues"](t)),elementRadius:n["atom-radius"]})(t)}),Vt(ye.structureQuery.modifier.surroundingLigands,function(t,n){return Sr.modifiers.surroundingLigands({query:n[0],radius:n.radius(t),includeWater:!(!n["include-water"]||!n["include-water"](t))})(t)}),Vt(ye.structureQuery.modifier.wholeResidues,function(t,n){return Sr.modifiers.wholeResidues(n[0])(t)}),Vt(ye.structureQuery.modifier.union,function(t,n){return Sr.modifiers.union(n[0])(t)}),Vt(ye.structureQuery.modifier.expandProperty,function(t,n){return Sr.modifiers.expandProperty(n[0],n.property)(t)}),Vt(ye.structureQuery.modifier.exceptBy,function(t,n){return Sr.modifiers.exceptBy(n[0],n.by)(t)}),Vt(ye.structureQuery.modifier.includeConnected,function(t,n){var r,i;return Sr.modifiers.includeConnected({query:n[0],bondTest:n["bond-test"],wholeResidues:!(!n["as-whole-residues"]||!n["as-whole-residues"](t)),layerCount:n["layer-count"]&&n["layer-count"](t)||1,fixedPoint:null!==(i=null===(r=n["fixed-point"])||void 0===r?void 0:r.call(n,t))&&void 0!==i&&i})(t)}),Vt(ye.structureQuery.modifier.intersectBy,function(t,n){return Sr.modifiers.intersectBy(n[0],n.by)(t)}),Vt(ye.structureQuery.combinator.merge,(e,t)=>Sr.combinators.merge(t)(e)),Vt(ye.structureQuery.atomProperty.core.elementSymbol,Gr(Ze.atom.type_symbol)),Vt(ye.structureQuery.atomProperty.core.vdw,(e,t)=>v2(Ze.atom.type_symbol(t&&t[0]&&t[0](e)||e.element))),Vt(ye.structureQuery.atomProperty.core.mass,(e,t)=>function C4e(e){const t=ST[e];return void 0===t?10.81:v4e[t]}(Ze.atom.type_symbol(t&&t[0]&&t[0](e)||e.element))),Vt(ye.structureQuery.atomProperty.core.atomicNumber,(e,t)=>_2(Ze.atom.type_symbol(t&&t[0]&&t[0](e)||e.element))),Vt(ye.structureQuery.atomProperty.core.x,Gr(Ze.atom.x)),Vt(ye.structureQuery.atomProperty.core.y,Gr(Ze.atom.y)),Vt(ye.structureQuery.atomProperty.core.z,Gr(Ze.atom.z)),Vt(ye.structureQuery.atomProperty.core.sourceIndex,Gr(Ze.atom.sourceIndex)),Vt(ye.structureQuery.atomProperty.core.operatorName,Gr(Ze.unit.operator_name)),Vt(ye.structureQuery.atomProperty.core.operatorKey,Gr(Ze.unit.operator_key)),Vt(ye.structureQuery.atomProperty.core.modelIndex,Gr(Ze.unit.model_index)),Vt(ye.structureQuery.atomProperty.core.modelLabel,Gr(Ze.unit.model_label)),Vt(ye.structureQuery.atomProperty.core.atomKey,(e,t)=>{const n=t&&t[0]&&t[0](e)||e.element;return uu(n.unit.id,n.element)}),Vt(ye.structureQuery.atomProperty.macromolecular.residueKey,(e,t)=>function A6e(e){return Ee.isAtomic(e.unit)?e.unit.residueIndex[e.element]:-1}(t&&t[0]&&t[0](e)||e.element)),Vt(ye.structureQuery.atomProperty.macromolecular.chainKey,(e,t)=>function I6e(e){return Ee.isAtomic(e.unit)?e.unit.chainIndex[e.element]:-1}(t&&t[0]&&t[0](e)||e.element)),Vt(ye.structureQuery.atomProperty.macromolecular.entityKey,(e,t)=>function T6e(e){return Ze.entity.key(e)}(t&&t[0]&&t[0](e)||e.element)),Vt(ye.structureQuery.atomProperty.macromolecular.id,Gr(Ze.atom.id)),Vt(ye.structureQuery.atomProperty.macromolecular.isHet,(e,t)=>"ATOM"!==Ze.residue.group_PDB(t&&t[0]&&t[0](e)||e.element)),Vt(ye.structureQuery.atomProperty.macromolecular.label_atom_id,Gr(Ze.atom.label_atom_id)),Vt(ye.structureQuery.atomProperty.macromolecular.label_alt_id,Gr(Ze.atom.label_alt_id)),Vt(ye.structureQuery.atomProperty.macromolecular.label_comp_id,Gr(Ze.atom.label_comp_id)),Vt(ye.structureQuery.atomProperty.macromolecular.label_seq_id,Gr(Ze.residue.label_seq_id)),Vt(ye.structureQuery.atomProperty.macromolecular.label_asym_id,Gr(Ze.chain.label_asym_id)),Vt(ye.structureQuery.atomProperty.macromolecular.label_entity_id,Gr(Ze.entity.id)),Vt(ye.structureQuery.atomProperty.macromolecular.auth_atom_id,Gr(Ze.atom.auth_atom_id)),Vt(ye.structureQuery.atomProperty.macromolecular.auth_comp_id,Gr(Ze.atom.auth_comp_id)),Vt(ye.structureQuery.atomProperty.macromolecular.auth_seq_id,Gr(Ze.residue.auth_seq_id)),Vt(ye.structureQuery.atomProperty.macromolecular.auth_asym_id,Gr(Ze.chain.auth_asym_id)),Vt(ye.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code,Gr(Ze.residue.pdbx_PDB_ins_code)),Vt(ye.structureQuery.atomProperty.macromolecular.pdbx_formal_charge,Gr(Ze.atom.pdbx_formal_charge)),Vt(ye.structureQuery.atomProperty.macromolecular.occupancy,Gr(Ze.atom.occupancy)),Vt(ye.structureQuery.atomProperty.macromolecular.B_iso_or_equiv,Gr(Ze.atom.B_iso_or_equiv)),Vt(ye.structureQuery.atomProperty.macromolecular.entityType,Gr(Ze.entity.type)),Vt(ye.structureQuery.atomProperty.macromolecular.entitySubtype,Gr(Ze.entity.subtype)),Vt(ye.structureQuery.atomProperty.macromolecular.entityPrdId,Gr(Ze.entity.prd_id)),Vt(ye.structureQuery.atomProperty.macromolecular.entityDescription,Gr(Ze.entity.pdbx_description)),Vt(ye.structureQuery.atomProperty.macromolecular.objectPrimitive,Gr(Ze.unit.object_primitive)),Vt(ye.structureQuery.atomProperty.macromolecular.isNonStandard,Gr(Ze.residue.isNonStandard)),Vt(ye.structureQuery.atomProperty.macromolecular.secondaryStructureKey,Gr(Ze.residue.secondary_structure_key)),Vt(ye.structureQuery.atomProperty.macromolecular.secondaryStructureFlags,Gr(Ze.residue.secondary_structure_type)),Vt(ye.structureQuery.atomProperty.macromolecular.chemCompType,Gr(Ze.residue.chem_comp_type)),Vt(ye.structureQuery.atomSet.atomCount,function(t,n){return Sr.atomset.atomCount(t)}),Vt(ye.structureQuery.atomSet.countQuery,function(t,n){return Sr.atomset.countQuery(n[0])(t)}),Vt(ye.structureQuery.atomSet.propertySet,function(t,n){return Sr.atomset.propertySet(n[0])(t)}),Vt(ye.structureQuery.bondProperty.order,(e,t)=>e.atomicBond.order),Vt(ye.structureQuery.bondProperty.flags,(e,t)=>e.atomicBond.type),Vt(ye.structureQuery.bondProperty.key,(e,t)=>e.atomicBond.key),Vt(ye.structureQuery.bondProperty.atomA,(e,t)=>e.atomicBond.a),Vt(ye.structureQuery.bondProperty.atomB,(e,t)=>e.atomicBond.b),Vt(ye.structureQuery.bondProperty.length,(e,t)=>e.atomicBond.length),Vt(ye.internal.generator.bundleElement,function(t,n){return FJ(n.groupedUnits(t),n.ranges(t),n.set(t))}),Vt(ye.internal.generator.bundle,function(t,n){return BJ(n.elements(t))(t)}),Vt(ye.internal.generator.current,function(t,n){return t.tryGetCurrentSelection()})];function Gr(e){return(t,n)=>e(n&&n[0]&&n[0](t)||t.element)}function Aoe(e,t){return e|(jn.isName(t)?jn.fromName(t):0)}function Ioe(e,t){switch(t.toLowerCase()){case"helix":return 2|e;case"alpha":return 4098|e;case"pi":return 32770|e;case"310":return 2050|e;case"beta":return 4|e;case"strand":return 4194308|e;case"sheet":return 8388612|e;case"turn":return 16|e;case"bend":return 8|e;case"coil":return 536870912|e;default:return e}}function ko(e,t){return{expression:e,language:t}}!function(){for(const e of i$e)qD.addSymbol(e)}(),function(e){function r(a){switch(a.language){case"mol-script":const c=function AWe(e){return G5.parse(e)}(a.expression);if(0===c.length)throw new Error("No query");return bWe(c[0]);case"pymol":case"jmol":case"vmd":return function t$e(e,t){try{return e$e[e](t)}catch(n){throw console.error(n.message),n}}(a.language,a.expression);default:Rr()}}function i(a){return TS(r(a))}e.Info={"mol-script":"Mol-Script",pymol:"PyMOL",vmd:"VMD",jmol:"Jmol"},e.is=function t(a){return!!a&&"string"==typeof a.expression&&!!a.language},e.areEqual=function n(a,c){return a.language===c.language&&a.expression===c.expression},e.toExpression=r,e.toQuery=i,e.toLoci=function o(a,c){const l=i(a)(new qu(c));return pt.toLociWithSourceUnits(l)},e.getStructureSelection=function s(a,c,u){return TS("function"==typeof a?a(ue):a)(new qu(c,u))}}(ko||(ko={}));const Nv={dynamicBonds:C.Optional(C.Boolean(!1,{description:"Ensure bonds are recalculated upon model changes. Also enables calculation of inter-unit bonds in water molecules and ions."}))};var b0,Aa;!function(e){function r(p,m,h,g,y){return i.apply(this,arguments)}function i(){return(i=ie(function*(p,m,h,g,y){let b;const x=no.Provider.get(h);!g&&x&&0!==x.assemblies.length&&(g=x.assemblies[0].id),x&&0!==x.assemblies.length?(b=h2.findAssembly(h,g||""),b||p.log.warn(`Model '${h.entryId}' has no assembly called '${g}', returning model structure.`)):p.log.warn(`Model '${h.entryId}' has no assembly, returning model structure.`);const _=Ve.ofModel(h,y);if(!b){const E={label:"Model",description:Ve.elementDescription(_)};return new pe.Molecule.Structure(_,E)}g=b.id;const S=yield nf.buildAssembly(_,g).runInContext(m),A={label:`Assembly ${g}`,description:Ve.elementDescription(S)};return new pe.Molecule.Structure(S,A)})).apply(this,arguments)}function s(){return(s=ie(function*(p,m,h,g,y){const b=Ve.ofModel(m,y),x=yield nf.buildSymmetryRange(b,h,g).runInContext(p),_={label:`Symmetry [${h}] to [${g}]`,description:Ve.elementDescription(x)};return new pe.Molecule.Structure(x,_)})).apply(this,arguments)}function c(){return(c=ie(function*(p,m,h,g){const y=Ve.ofModel(m,g),b=yield nf.builderSymmetryMates(y,h).runInContext(p),x={label:"Symmetry Mates",description:Ve.elementDescription(b)};return new pe.Molecule.Structure(b,x)})).apply(this,arguments)}function l(){return(l=ie(function*(p,m,h,g,y){const b=Ve.ofModel(m,y),x=yield nf.buildSymmetryAssembly(b,h,g).runInContext(p),_={label:"Symmetry Assembly",description:Ve.elementDescription(x)};return new pe.Molecule.Structure(x,_)})).apply(this,arguments)}function f(){return f=ie(function*(p,m,h,g){const y=g?.params,b=no.Provider.get(h);if(!b||!g||"model"===g.name){const x=Ve.ofModel(h,y);return new pe.Molecule.Structure(x,{label:"Model",description:Ve.elementDescription(x)})}if("auto"===g.name){if(0===b.assemblies.length){const x=Ve.ofModel(h,y);return new pe.Molecule.Structure(x,{label:"Model",description:Ve.elementDescription(x)})}return r(p,m,h,void 0,y)}return"assembly"===g.name?r(p,m,h,g.params.id,y):"symmetry"===g.name?function o(p,m,h,g,y){return s.apply(this,arguments)}(m,h,g.params.ijkMin,g.params.ijkMax,y):"symmetry-mates"===g.name?function a(p,m,h,g){return c.apply(this,arguments)}(m,h,g.params.radius,y):"symmetry-assembly"===g.name?function u(p,m,h,g,y){return l.apply(this,arguments)}(m,h,g.params.generators,b,y):void Rr()}),f.apply(this,arguments)}e.getParams=function t(p,m){const h=p&&no.Provider.get(p),g=h?h.assemblies.map(A=>[A.id,`${A.id}: ${zu(A.details)}`]):[],y=!h||!ma.isZero(h.spacegroup.cell),b=[];if(h){const{operators:A}=h.spacegroup;for(let E=0,w=A.length;E{x.push([A.id,A.id===A.auth_id?A.id:`${A.id} [auth ${A.auth_id}]`])});const _={auto:C.Group(Nv),model:C.Group(Nv),assembly:C.Group({id:C.Optional(p?C.Select(g.length?g[0][0]:"",g,{label:"Asm Id",description:"Assembly Id"}):C.Text("",{label:"Asm Id",description:"Assembly Id (use empty for the 1st assembly)"})),...Nv},{isFlat:!0}),"symmetry-mates":C.Group({radius:C.Numeric(5,{min:0,max:50,step:1}),...Nv},{isFlat:!0}),symmetry:C.Group({ijkMin:C.Vec3(v.create(-1,-1,-1),{step:1},{label:"Min IJK",fieldLabels:{x:"I",y:"J",z:"K"}}),ijkMax:C.Vec3(v.create(1,1,1),{step:1},{label:"Max IJK",fieldLabels:{x:"I",y:"J",z:"K"}}),...Nv},{isFlat:!0}),"symmetry-assembly":C.Group({generators:C.ObjectList({operators:C.ObjectList({index:C.Select(0,b),shift:C.Vec3(v(),{step:1},{label:"IJK",fieldLabels:{x:"I",y:"J",z:"K"}})},A=>`${A.index+1}_${A.shift.map(E=>E+5).join("")}`,{defaultValue:[]}),asymIds:C.MultiSelect([],x)},A=>`${A.asymIds.length} asym ids, ${A.operators.length} operators`,{defaultValue:[]}),...Nv},{isFlat:!0})},S=[];return"auto"===m&&S.push(["auto","Auto"]),S.push(["model","Model"]),g.length>0&&S.push(["assembly","Assembly"]),y&&(S.push(["symmetry-mates","Symmetry Mates"]),S.push(["symmetry","Symmetry (indices)"]),S.push(["symmetry-assembly","Symmetry (assembly)"])),{type:C.MappedStatic(m||"model",_,{options:S})}},e.canAutoUpdate=function n(p,m){return!("symmetry-assembly"===m.name||"symmetry"===m.name&&"symmetry"===p.name)},e.create=function d(p,m,h,g){return f.apply(this,arguments)}}(b0||(b0={})),function(e){function n(a,c){const u=ko.is(c)?c:void 0,l=ko.is(c)?ko.toExpression(c):c;return{script:u,expression:l,compiled:TS(l),originalStructure:a,currentStructure:a}}function r(a,c){return a.compiled(new qu(c))}e.isUnchanged=function t(a,c,u){return a.currentStructure===u&&(ko.is(c)?!!a.script&&ko.areEqual(a.script,c):a.expression===c)},e.create=n,e.run=r,e.createAndRun=function i(a,c){const u=n(a,c);return{entry:u,selection:r(u,a)}},e.updateStructure=function o(a,c){return a.currentStructure=c,a.compiled(new qu(c))},e.updateStructureObject=function s(a,c,u){const l=pt.unionStructure(c);a.label=`${u||"Selection"}`,a.description=Ve.elementDescription(l),a.data=l}}(Aa||(Aa={}));const s$e=new Set(["LI","NA","K","RB","CS","FR"]),c$e=new Set(["BE","MG","CA","SR","BA","RA"]),g$e=new Set(["ZN","GA","CD","IN","SN","HG","TI","PB","BI","PO","CN"]),v$e=new Set(["F","CL","BR","I","AT"]);function _$e(e){return v$e.has(e)}function Toe(e){const t=_2(e);return t>=21&&t<=29||t>=39&&t<=47||t>=72&&t<=79||t>=104&&t<=108}function C$e(e){return function a$e(e){return s$e.has(e)}(e)||function u$e(e){return c$e.has(e)}(e)||function x$e(e){const t=_2(e);return t>=57&&t<=71}(e)||function S$e(e){const t=_2(e);return t>=89&&t<=103}(e)||Toe(e)||function y$e(e){return g$e.has(e)}(e)}var pr=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}(pr||{});function lr(e,t,n={}){var r;let i;return{label:e,expression:t,description:n.description||"",category:null!==(r=n.category)&&void 0!==r?r:pr.Misc,isHidden:!!n.isHidden,priority:n.priority||0,referencesCurrent:!!n.referencesCurrent,get query(){return i||(i=TS(t)),i},ensureCustomProperties:n.ensureCustomProperties,getSelection:(o,s,a)=>ie(function*(){const c=o.managers.structure.selection.getStructure(a),u=c?pt.Sequence(a,[c]):pt.Empty(a);return n.ensureCustomProperties&&(yield n.ensureCustomProperties({runtime:s,assetManager:o.managers.asset},a)),i||(i=TS(t)),i(new qu(a,{currentSelection:u}))})()}}const w$e=lr("All",ue.struct.generator.all(),{category:"",priority:1e3}),A$e=lr("Current Selection",ue.internal.generator.current(),{category:"",referencesCurrent:!0}),I$e=lr("Polymer",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.logic.and([ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),ue.core.str.match([ue.re("(polypeptide|cyclic-pseudo-peptide|peptide-like|nucleotide|peptide nucleic acid)","i"),ue.ammp("entitySubtype")])])})]),{category:pr.Type}),T$e=lr("Trace",ue.struct.modifier.union([ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),"chain-test":ue.core.set.has([ue.set("sphere","gaussian"),ue.ammp("objectPrimitive")])})]),ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"atom-test":ue.core.set.has([ue.set("CA","P"),ue.ammp("label_atom_id")])})])])]),{category:pr.Structure}),Fv=ue.core.logic.and([ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),ue.core.str.match([ue.re("(polypeptide|cyclic-pseudo-peptide|peptide-like)","i"),ue.ammp("entitySubtype")])]),WD=ue.core.logic.and([ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),ue.core.str.match([ue.re("(nucleotide|peptide nucleic acid)","i"),ue.ammp("entitySubtype")])]),v0=ue.core.str.match([ue.re("non-polymer|(amino|carboxy) terminus|peptide-like","i"),ue.ammp("chemCompType")]),D$e=lr("Backbone",ue.struct.modifier.union([ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":Fv,"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([v0]),"atom-test":ue.core.set.has([ue.set(...Si.toArray(lp)),ue.ammp("label_atom_id")])})]),ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":WD,"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([v0]),"atom-test":ue.core.set.has([ue.set(...Si.toArray(JI)),ue.ammp("label_atom_id")])})])])]),{category:pr.Structure}),E$e=lr("Sidechain",ue.struct.modifier.union([ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":Fv,"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([v0]),"atom-test":ue.core.logic.or([ue.core.logic.not([ue.core.set.has([ue.set(...Si.toArray(lp)),ue.ammp("label_atom_id")])])])})]),ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":WD,"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([v0]),"atom-test":ue.core.logic.or([ue.core.logic.not([ue.core.set.has([ue.set(...Si.toArray(JI)),ue.ammp("label_atom_id")])])])})])])]),{category:pr.Structure}),P$e=lr("Sidechain with Trace",ue.struct.modifier.union([ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":Fv,"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([v0]),"atom-test":ue.core.logic.or([ue.core.logic.not([ue.core.set.has([ue.set(...Si.toArray(lp)),ue.ammp("label_atom_id")])]),ue.core.rel.eq([ue.ammp("label_atom_id"),"CA"]),ue.core.logic.and([ue.core.rel.eq([ue.ammp("auth_comp_id"),"PRO"]),ue.core.rel.eq([ue.ammp("label_atom_id"),"N"])])])})]),ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":WD,"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([v0]),"atom-test":ue.core.logic.or([ue.core.logic.not([ue.core.set.has([ue.set(...Si.toArray(JI)),ue.ammp("label_atom_id")])]),ue.core.rel.eq([ue.ammp("label_atom_id"),"P"])])})])])]),{category:pr.Structure}),M$e=lr("Protein",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":Fv})]),{category:pr.Type}),R$e=lr("Nucleic",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":WD})]),{category:pr.Type}),k$e=lr("Helix",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":Fv,"residue-test":ue.core.flags.hasAny([ue.ammp("secondaryStructureFlags"),ue.core.type.bitflags([2])])})]),{category:pr.Structure,ensureCustomProperties:(e,t)=>Xu.attach(e,t)}),N$e=lr("Beta Strand/Sheet",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":Fv,"residue-test":ue.core.flags.hasAny([ue.ammp("secondaryStructureFlags"),ue.core.type.bitflags([4])])})]),{category:pr.Structure,ensureCustomProperties:(e,t)=>Xu.attach(e,t)}),F$e=lr("Water",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entityType"),"water"])})]),{category:pr.Type}),B$e=lr("Ion",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entitySubtype"),"ion"])})]),{category:pr.Type}),O$e=lr("Lipid",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entitySubtype"),"lipid"])})]),{category:pr.Type}),$D=lr("Carbohydrate",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.logic.or([ue.core.rel.eq([ue.ammp("entityType"),"branched"]),ue.core.logic.and([ue.core.rel.eq([ue.ammp("entityType"),"non-polymer"]),ue.core.str.match([ue.re("oligosaccharide","i"),ue.ammp("entitySubtype")])])])})]),{category:pr.Type}),Doe=lr("Carbohydrate with Connected",ue.struct.modifier.union([ue.struct.modifier.includeConnected({0:$D.expression,"layer-count":1,"as-whole-residues":!0})]),{category:pr.Internal,isHidden:!0}),Eoe=lr("Connected to Carbohydrate",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:Doe.expression,by:$D.expression})]),{category:pr.Internal,isHidden:!0}),e6=lr("Ligand",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:ue.struct.modifier.union([ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.logic.and([ue.core.logic.or([ue.core.rel.eq([ue.ammp("entityType"),"non-polymer"]),ue.core.rel.neq([ue.ammp("entityPrdId"),""])]),ue.core.logic.not([ue.core.str.match([ue.re("(oligosaccharide|lipid|ion)","i"),ue.ammp("entitySubtype")])])]),"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([ue.core.str.match([ue.re("saccharide","i"),ue.ammp("chemCompType")])])})]),ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":v0})])])]),by:ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.set.has([ue.set(...Si.toArray(Wb)),ue.ammp("label_comp_id")])})]),ue.struct.generator.atomGroups({"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.set.has([ue.set(...Si.toArray(eFe)),ue.ammp("label_comp_id")])})])})]),{category:pr.Type}),Poe=lr("Ligand with Connected",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:ue.struct.modifier.union([ue.struct.modifier.includeConnected({0:e6.expression,"layer-count":1,"as-whole-residues":!0,"bond-test":ue.core.flags.hasAny([ue.struct.bondProperty.flags(),ue.core.type.bitflags([3])])})]),by:$D.expression})]),{category:pr.Internal,isHidden:!0}),Moe=lr("Connected to Ligand",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:Poe.expression,by:e6.expression})]),{category:pr.Internal,isHidden:!0}),L$e=lr("Connected to Ligand or Carbohydrate",ue.struct.modifier.union([ue.struct.combinator.merge([Eoe.expression,Moe.expression])]),{category:pr.Internal,isHidden:!0}),U$e=lr("Disulfide Bridges",ue.struct.modifier.union([ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.modifier.wholeResidues([ue.struct.filter.isConnectedTo({0:ue.struct.generator.atomGroups({"residue-test":ue.core.set.has([ue.set("CYS"),ue.ammp("auth_comp_id")]),"atom-test":ue.core.set.has([ue.set("SG"),ue.ammp("label_atom_id")])}),target:ue.struct.generator.atomGroups({"residue-test":ue.core.set.has([ue.set("CYS"),ue.ammp("auth_comp_id")]),"atom-test":ue.core.set.has([ue.set("SG"),ue.ammp("label_atom_id")])}),"bond-test":!0})])]),ue.struct.modifier.union([ue.struct.modifier.wholeResidues([ue.struct.modifier.union([ue.struct.generator.bondedAtomicPairs({0:ue.core.flags.hasAny([ue.struct.bondProperty.flags(),ue.core.type.bitflags([8])])})])])])])]),{category:pr.Bond}),V$e=lr("NOS Bridges",ue.struct.modifier.union([ue.struct.modifier.wholeResidues([ue.struct.filter.isConnectedTo({0:ue.struct.generator.atomGroups({"residue-test":ue.core.set.has([ue.set("CSO","LYS"),ue.ammp("auth_comp_id")]),"atom-test":ue.core.set.has([ue.set("OD","NZ"),ue.ammp("label_atom_id")])}),target:ue.struct.generator.atomGroups({"residue-test":ue.core.set.has([ue.set("CSO","LYS"),ue.ammp("auth_comp_id")]),"atom-test":ue.core.set.has([ue.set("OD","NZ"),ue.ammp("label_atom_id")])}),"bond-test":!0})])]),{category:pr.Bond}),z$e=lr("Non-standard Residues in Polymers",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.ammp("isNonStandard")})]),{category:pr.Residue}),G$e=lr("Coarse Elements",ue.struct.modifier.union([ue.struct.generator.atomGroups({"chain-test":ue.core.set.has([ue.set("sphere","gaussian"),ue.ammp("objectPrimitive")])})]),{category:pr.Type}),j$e=lr("Rings in Residues",ue.struct.modifier.union([ue.struct.generator.rings()]),{category:pr.Residue}),H$e=lr("Aromatic Rings in Residues",ue.struct.modifier.union([ue.struct.generator.rings({"only-aromatic":!0})]),{category:pr.Residue}),q$e=lr("Surrounding Residues (5 \u212b) of Selection",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:ue.struct.modifier.includeSurroundings({0:ue.internal.generator.current(),radius:5,"as-whole-residues":!0}),by:ue.internal.generator.current()})]),{description:"Select residues within 5 \u212b of the current selection.",category:pr.Manipulate,referencesCurrent:!0}),W$e=lr("Surrounding Ligands (5 \u212b) of Selection",ue.struct.modifier.union([ue.struct.modifier.surroundingLigands({0:ue.internal.generator.current(),radius:5,"include-water":!0})]),{description:"Select ligand components within 5 \u212b of the current selection.",category:pr.Manipulate,referencesCurrent:!0}),$$e=lr("Surrounding Atoms (5 \u212b) of Selection",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:ue.struct.modifier.includeSurroundings({0:ue.internal.generator.current(),radius:5,"as-whole-residues":!1}),by:ue.internal.generator.current()})]),{description:"Select atoms within 5 \u212b of the current selection.",category:pr.Manipulate,referencesCurrent:!0}),Y$e=lr("Inverse / Complement of Selection",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:ue.struct.generator.all(),by:ue.internal.generator.current()})]),{description:"Select everything not in the current selection.",category:pr.Manipulate,referencesCurrent:!0}),X$e=lr("Residues Covalently Bonded to Selection",ue.struct.modifier.union([ue.struct.modifier.includeConnected({0:ue.internal.generator.current(),"layer-count":1,"as-whole-residues":!0})]),{description:"Select residues covalently bonded to current selection.",category:pr.Manipulate,referencesCurrent:!0}),K$e=lr("Covalently Bonded Component",ue.struct.modifier.union([ue.struct.modifier.includeConnected({0:ue.internal.generator.current(),"fixed-point":!0})]),{description:"Select covalently bonded component based on current selection.",category:pr.Manipulate,referencesCurrent:!0}),Z$e=lr("Residues with Cov. or Metallic Bond to Selection",ue.struct.modifier.union([ue.struct.modifier.includeConnected({0:ue.internal.generator.current(),"layer-count":1,"as-whole-residues":!0,"bond-test":ue.core.flags.hasAny([ue.struct.bondProperty.flags(),ue.core.type.bitflags([3])])})]),{description:"Select residues with covalent or metallic bond to current selection.",category:pr.Manipulate,referencesCurrent:!0}),Q$e=lr("Whole Residues of Selection",ue.struct.modifier.union([ue.struct.modifier.wholeResidues({0:ue.internal.generator.current()})]),{description:"Expand current selection to whole residues.",category:pr.Manipulate,referencesCurrent:!0}),J$e=[[["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((e,t)=>e[1]t[1]?1:0),eYe=[[["A","DA"],"Adenosine"],[["C","DC"],"Cytidine"],[["T","DT"],"Thymidine"],[["G","DG"],"Guanosine"],[["I","DI"],"Inosine"],[["U","DU"],"Uridine"],[["N","DN"],"Unknown"]].sort((e,t)=>e[1]t[1]?1:0);function t6([e,t],n,r=0){const i=1!==e.length||Roe.has(e[0])?`${t} (${e.join(", ")})`:`[${e[0]}] ${t}`;return lr(i,ue.struct.modifier.union([ue.struct.generator.atomGroups({"residue-test":ue.core.set.has([ue.set(...e),ue.ammp("auth_comp_id")])})]),{category:n,priority:r,description:i})}const Roe=Si.unionMany(EB,c2,u2,eT),No={all:w$e,current:A$e,polymer:I$e,trace:T$e,backbone:D$e,sidechain:E$e,sidechainWithTrace:P$e,protein:M$e,nucleic:R$e,helix:k$e,beta:N$e,water:F$e,ion:B$e,lipid:O$e,branched:$D,branchedPlusConnected:Doe,branchedConnectedOnly:Eoe,ligand:e6,ligandPlusConnected:Poe,ligandConnectedOnly:Moe,connectedOnly:L$e,disulfideBridges:U$e,nosBridges:V$e,nonStandardPolymer:z$e,coarse:G$e,ring:j$e,aromaticRing:H$e,surroundings:q$e,surroundingLigands:W$e,surroundingAtoms:$$e,complement:Y$e,covalentlyBonded:X$e,covalentlyOrMetallicBonded:Z$e,covalentlyBondedComponent:K$e,wholeResidues:Q$e};class rYe{add(t){this.list.push(t),this.options.push([t,t.label,t.category]),this.version+=1}remove(t){const n=this.list.indexOf(t);-1!==n&&(this.list.splice(n,1),this.options.splice(n,1),this.version+=1)}constructor(){this.list=[],this.options=[],this.version=1,this.list.push(...Object.values(No),...J$e.map(t=>t6(t,pr.AminoAcid)),...eYe.map(t=>t6(t,pr.NucleicBase))),this.options.push(...this.list.map(t=>[t,t.label,t.category]))}}function aYe(e){switch(e){case 7:return-3;case 6:return-2;case 5:return-1;case 0:case 4:return 0;case 3:return 1;case 2:return 2;case 1:return 3;default:return console.error(`Value ${e} is outside the 0-7 range, defaulting to 0.`),0}}function koe(e,t){const n=He.create(e.data,2*t),r=He.create(e.data,2*t),i=He.create(e.data,2*t),o=He.create(e.data,2*t),s=He.create(e.data,2*t);for(let a=0;a0)for(let g=0;g0){const g=te.ofIntArray(te.mapToArray(i.atomIdxA,_=>_-1,Int32Array)),y=te.ofIntArray(te.mapToArray(i.atomIdxB,_=>_-1,Int32Array)),b=te.asArrayColumn(i.order,Int32Array),x=Ms.fromData({pairs:{indexA:g,indexB:y,order:b},count:r.count},{maxDistance:1/0});Ms.Provider.set(h.representative,x)}return h}),n6.apply(this,arguments)}var r6,DS,s6;function i6(){return i6=ie(function*(e,t,n){var r;const i=e.atom_site._rowCount,o=te.ofConst("MOL",i,te.Schema.str),s=te.ofConst("A",i,te.Schema.str),a=te.ofConst(1,i,te.Schema.int),c=function pYe(e){const{cell:t,space_group:n}=e,r=function fYe(e){const t=e.it_number.value(0),n=e["name_h-m_full"].value(0).replace("-"," ");return e.it_number.isDefined?t:n}(n),i=ma.create(r,v.create(t.length_a.value(0),t.length_b.value(0),t.length_c.value(0)),v.scale(v(),v.create(t.angle_alpha.value(0),t.angle_beta.value(0),t.angle_gamma.value(0)),Math.PI/180));return{spacegroup:Ec.create(i),assemblies:[],isNonStandardCrystalFrame:!1,ncsOperators:[]}}(e),u=c.spacegroup.cell.fromFractional,{fract_x:l,fract_y:d,fract_z:f}=e.atom_site,p=new Float32Array(i),m=new Float32Array(i),h=new Float32Array(i),g=v();for(let R=0;R0){const R=I.representative;no.Provider.set(R,c);const T=e.geom_bond._rowCount;if(T>0){const M={},{label:N}=e.atom_site;for(let W=0,Q=N.rowCount;Wfunction HNe(e){return GQ.has(e)?GQ.get(e):Bg("H")}(d)),schema:te.Schema.Aliased(te.Schema.str)}),s=te.ofConst(1,n.count,te.Schema.int),a=Xn.ofPartialColumns(ks.atom_site,{auth_asym_id:i,auth_atom_id:o,auth_comp_id:r,auth_seq_id:s,Cartn_x:te.asArrayColumn(n.x,Float32Array),Cartn_y:te.asArrayColumn(n.y,Float32Array),Cartn_z:te.asArrayColumn(n.z,Float32Array),id:te.range(0,n.count-1),label_asym_id:i,label_atom_id:o,label_comp_id:r,label_seq_id:s,label_entity_id:te.ofConst("1",n.count,te.Schema.str),occupancy:te.ofConst(1,n.count,te.Schema.float),type_symbol:o,pdbx_PDB_model_num:te.ofConst(1,n.count,te.Schema.int)},n.count),c=new sd;c.setNames([["MOL","Unknown Entity"]]),c.getEntityId("MOL",0,"A");const u=new ad(s,o);u.setNames([["MOL","Unknown Molecule"]]),u.add("MOL",0);const l=$u({entity:c.getEntityTable(),chem_comp:u.getChemCompTable(),atom_site:a});return yield af(l,s6.create(e),t)}),o6.apply(this,arguments)}!function(e){e.is=function t(r){return"mol"===r?.kind},e.create=function n(r){return{kind:"mol",name:r.title,data:r}}}(r6||(r6={})),tf.Provider.formatRegistry.add("cifCore",function mYe(e){if(!DS.is(e.sourceData))return;const{atom_site:t,atom_site_aniso:n}=e.sourceData.data.db;return{data:Xn.ofPartialColumns(tf.Schema,{U:n.u},n._rowCount),elementToAnsiotrop:tf.getElementToAnsiotropFromLabel(t.label,n.label)}},function gYe(e){return!!DS.is(e.sourceData)&&e.sourceData.data.db.atom_site_aniso.u.isDefined}),function(e){e.is=function t(r){return"cifCore"===r?.kind},e.fromFrame=function n(r,i){return i||(i=od.schema.cifCore(r)),{kind:"cifCore",name:i.database_code.depnum_ccdc_archive.value(0)||i.database_code.depnum_ccdc_fiz.value(0)||i.database_code.icsd.value(0)||i.database_code.mdf.value(0)||i.database_code.nbs.value(0)||i.database_code.csd.value(0)||i.database_code.cod.value(0)||i._name,data:{db:i,frame:r}}}}(DS||(DS={})),function(e){e.is=function t(r){return"cube"===r?.kind},e.create=function n(r){return{kind:"cube",name:r.header.comment1,data:r}}}(s6||(s6={}));const{skipWhitespace:a6,eatValue:Ooe,markLine:ml,getTokenString:gl,readLine:Loe}=ht;function xYe(e,t){return{tokenizer:e,molecule:{mol_name:"",num_atoms:0,num_bonds:0,num_subst:0,num_feat:0,num_sets:0,mol_type:"",charge_type:"",status_bits:"",mol_comment:""},runtimeCtx:t}}const Uoe=/\s+/g;function SYe(e){const{tokenizer:t,molecule:n}=e;for(;"@MOLECULE"!==gl(t)&&t.position"))return;n.mol_type=i,ml(t);const o=gl(t);if(o.startsWith("@"))return;n.charge_type=o,ml(t);const s=gl(t);if(s.startsWith("@"))return;n.status_bits=s,ml(t);const a=gl(t);a.startsWith("@")||(n.mol_comment=a)}function CYe(e){return c6.apply(this,arguments)}function c6(){return c6=ie(function*(e){const{tokenizer:t,molecule:n}=e;for(;"@ATOM"!==gl(t)&&t.position{const D=Math.min(n.num_atoms-A,w);for(let I=0;Iw.update({message:"Parsing...",current:t.position,max:S})),{count:n.num_atoms,atom_id:Jt(c)(te.Schema.int),atom_name:Jt(u)(te.Schema.str),x:Jt(l)(te.Schema.float),y:Jt(d)(te.Schema.float),z:Jt(f)(te.Schema.float),atom_type:a>5?Jt(p)(te.Schema.str):_,subst_id:a>6?Jt(m)(te.Schema.int):x,subst_name:a>7?Jt(h)(te.Schema.str):_,charge:a>8?Jt(g)(te.Schema.float):b,status_bit:a>9?Jt(y)(te.Schema.str):_}}),c6.apply(this,arguments)}function wYe(e){return u6.apply(this,arguments)}function u6(){return u6=ie(function*(e){const{tokenizer:t,molecule:n}=e;for(;"@BOND"!==gl(t)&&t.position{const y=Math.min(n.num_bonds-m,g);for(let b=0;bg.update({message:"Parsing...",current:t.position,max:p})),{count:n.num_bonds,bond_id:Jt(c)(te.Schema.int),origin_atom_id:Jt(u)(te.Schema.int),target_atom_id:Jt(l)(te.Schema.int),bond_type:Jt(d)(te.Schema.str),status_bits:a>4?Jt(f)(te.Schema.str):te.Undefined(n.num_bonds,te.Schema.str)}}),u6.apply(this,arguments)}function AYe(e){const{tokenizer:t}=e;for(;t.positionMOLECULE"===r)return;if("@CRYSIN"===r)break;ml(t)}if(t.position>=t.data.length)return;ml(t);const n=gl(t).trim().split(Uoe);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 l6(){return l6=ie(function*(e,t,n){const r=ht(t);e.update({message:"Parsing...",current:0,max:t.length});const i=[];for(;r.positionMOLECULE"!==gl(r)&&r.position0){const y=te.ofIntArray(te.mapToArray(a.origin_atom_id,w=>w-1,Int32Array)),b=te.ofIntArray(te.mapToArray(a.target_atom_id,w=>w-1,Int32Array)),x=a.bond_id,_=te.ofIntArray(te.mapToArray(a.bond_type,w=>{switch(w){case"ar":case"am":case"un":return 1;case"du":case"nc":return 0;default:return parseInt(w)}},Int8Array)),S=te.ofIntArray(te.mapToArray(a.bond_type,w=>{switch(w){case"ar":case"am":return 17;case"du":case"nc":return 0;default:return 1}},Int8Array)),A=Ms.fromData({pairs:{key:x,indexA:y,indexB:b,order:_,flag:S},count:s.count},{maxDistance:c?-1:1/0}),E=g.representative;if(Ms.Provider.set(E,A),Pv.Provider.set(E,{data:s.charge,type:o.charge_type}),c){const w=EYe(c);w&&no.Provider.set(E,w)}n.push(E)}}return new xp(n)}),d6.apply(this,arguments)}function EYe(e){if(1!==e.setting)return;const t=ma.create(e.spaceGroup,v.create(e.a,e.b,e.c),v.scale(v(),v.create(e.alpha,e.beta,e.gamma),Math.PI/180));return{spacegroup:Ec.create(t),assemblies:[],isNonStandardCrystalFrame:!1,ncsOperators:[]}}var f6;!function(e){e.is=function t(r){return"mol2"===r?.kind},e.create=function n(r){return{kind:"mol2",name:r.name,data:r}}}(f6||(f6={}));const Bv=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]),p6=9;var Oc,m6;function MYe(){throw new Error("(xdrfile error) Undefined error.")}function h6(){return h6=ie(function*(e,t){const n=new DataView(t.buffer,t.byteOffset),r={frames:[],boxes:[],times:[],timeOffset:0,deltaTime:0},i=r.frames,o=r.boxes,s=r.times,a=[0,0,0,0,0,0],c=[0,0,0],u=[0,0,0],l=[0,0,0],d=[.1,.1,.1],f=[.1,.1,.1];let p=0;const m=Oc.buf;for(;;){let h;const g=n.getInt32(p+4);p+=12,s.push(n.getFloat32(p)),p+=4;const y=new Float32Array(9);for(let b=0;b<9;++b)y[b]=10*n.getFloat32(p),p+=4;if(o.push(y),g<=9){h={count:g/3,x:new Float32Array(g/3),y:new Float32Array(g/3),z:new Float32Array(g/3)};for(let b=0;b16777215?(u[0]=Oc.sizeOfInt(c[0]),u[1]=Oc.sizeOfInt(c[1]),u[2]=Oc.sizeOfInt(c[2]),S=0):S=Oc.sizeOfInts(3,c);let A=n.getInt32(p);p+=4;let E=A-1;E=p6>E?p6:E;let w=Bv[E]/2|0,D=Bv[A]/2|0;l[0]=l[1]=l[2]=Bv[A];const I=4*Math.ceil(n.getInt32(p)/4);p+=4;const R=1/_;let T=0,M=0;for(d[0]=d[1]=d[2]=0;M0){d[0]=d[1]=d[2]=0;for(let F=0;Fp6?Bv[A-1]/2|0:0):V>0&&(w=D,D=Bv[A]/2|0),l[0]=l[1]=l[2]=Bv[A],(0===l[0]||0===l[1]||0===l[2])&&MYe()}p+=I}for(let b=0;b=t.length)break}return s.length>=1&&(r.timeOffset=s[0]),s.length>=2&&(r.deltaTime=s[1]-s[0]),r}),h6.apply(this,arguments)}function FYe(e){let t=e.position>=e.data.length-1?0:+ht.readLine(e);isNaN(t)&&(t=0);const n=ht.readLine(e),r=new Float64Array(t),i=new Float64Array(t),o=new Float64Array(t),s=new Array(t);for(let a=0;a=d&&f<32;)f++,d<<=1;return f};const n=new Uint8Array(32);e.sizeOfInts=function r(l,d){let f=1,p=0;n[0]=1;for(let h=0;h>=8;for(;0!==y;)n[g++]=255&y,y>>=8;f=g}let m=1;for(f--;n[f]>=m;)p++,m*=2;return p+8*f};const i=new ArrayBuffer(24);e.buf=new Int32Array(i);const o=new Uint32Array(i);function s(l,d,f){let p=f;const m=(1<=8;)g=g<<8|l[d+y++],b|=g>>h<0&&(h>h&(1<>o[1]&255}e.decodeBits=s;const c=[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];e.decodeInts=function u(l,d,f,p,m){let h=f,g=0;for(c[0]=0,c[1]=0,c[2]=0,c[3]=0;h>8;)c[g++]=a(l,d),h-=8;h>0&&(c[g++]=s(l,d,h));for(let y=2;y>0;y--){let b=0;const x=p[y];for(let _=g-1;_>=0;_--){b=b<<8|c[_];const S=b/x|0;c[_]=S,b-=S*x}m[y]=b}m[0]=c[0]|c[1]<<8|c[2]<<16|c[3]<<24}}(Oc||(Oc={})),function(e){e.is=function t(r){return"xyz"===r?.kind},e.create=function n(r){return{kind:"xyz",name:"xyz",data:r}}}(m6||(m6={}));const g6="$$$$";function WYe(e){const t=ht.readLine(e).trim(),n=ht.readLine(e).trim(),r=ht.readLine(e).trim(),i=ht.readLine(e),o=function VYe(e){return e.trim().endsWith("V3000")}(i),{atomCount:s,bondCount:a}=o?function zYe(e){const t=He.create(e.data,1),n=He.create(e.data,1);return ht.eatLine(e),Kp(e),Kp(e),Kp(e),Zp(e,t),Zp(e,n),ht.eatLine(e),{atomCount:Jt(t)(te.Schema.int).value(0),bondCount:Jt(n)(te.Schema.int).value(0)}}(e):function qYe(e){return{atomCount:+e.substr(0,3),bondCount:+e.substr(3,3)}}(i);if(Number.isNaN(s)||Number.isNaN(a)){for(;e.position ")){He.add(t,e.tokenStart+2,e.tokenEnd),ht.markLine(e);const i=e.tokenStart;let o=e.tokenEnd,s=!1;for(;e.position ")){He.add(n,i,o),s=!0;break}o=e.tokenEnd}s||He.add(n,i,o)}}return{dataHeader:Jt(t)(te.Schema.str),data:Jt(n)(te.Schema.str)}}(e);return{molFile:{title:t,program:n,comment:r,atoms:u,bonds:l,formalCharges:d},dataItems:f}}var y6;function XYe(e){return Oe.create("Parse SDF",t=>Boe(e.molFile,y6.create(e),t))}function b6(){return b6=ie(function*(e){const t=new DataView(e.buffer),n={frames:[],boxes:[],times:[],timeOffset:0,deltaTime:0},r=n.frames,i=n.boxes,o=n.times;let s=0;for(;;){s+=8;const a=t.getInt32(s);s+=4,s+=a;const c=t.getInt32(s+8),u=t.getInt32(s+12),l=t.getInt32(s+16),d=t.getInt32(s+28),f=t.getInt32(s+32),p=t.getInt32(s+36),m=t.getInt32(s+40);s+=52;const h=c/9,g=3*m;if(o.push(8===h?t.getFloat64(s):t.getFloat32(s)),s+=2*h,c){const y=new Float32Array(9);if(8===h)for(let b=0;b<9;++b)y[b]=10*t.getFloat64(s),s+=8;else for(let b=0;b<9;++b)y[b]=10*t.getFloat32(s),s+=4;i.push(y)}if(s+=u,s+=l,d){const y=new Float32Array(m),b=new Float32Array(m),x=new Float32Array(m);if(8===h)for(let _=0;_>8&65280|E>>24&255}const S=new Float32Array(e.buffer,s,g);for(let A=0;A=e.byteLength)break}return o.length>=1&&(n.timeOffset=o[0]),o.length>=2&&(n.deltaTime=o[1]-o[0]),n}),b6.apply(this,arguments)}!function(e){e.is=function t(r){return"sdf"===r?.kind},e.create=function n(r){return{kind:"sdf",name:r.molFile.title,data:r}}}(y6||(y6={}));const v6=[];class eXe{constructor(t,n={}){this._mark=0,this._marks=[],this.offset=0,this.littleEndian=!0;let r=!1;void 0===t&&(t=8192),"number"==typeof t?t=new ArrayBuffer(t):r=!0;const i=n.offset?n.offset>>>0:0,o=t.byteLength-i;let s=i;t instanceof ArrayBuffer||(t.byteLength!==t.buffer.byteLength&&(s=t.byteOffset+i),t=t.buffer),this._lastWrittenByte=r?o:0,this.buffer=t,this.length=o,this.byteLength=o,this.byteOffset=s,this._data=new DataView(this.buffer,s,o)}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t){return void 0===t&&(t=1),this.offset+=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t){if(void 0===t&&(t=1),!this.available(t)){const r=2*(this.offset+t),i=new Uint8Array(r);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=this.byteLength=r,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t){void 0===t&&(t=1);const n=new Uint8Array(t);for(let r=0;rthis._lastWrittenByte&&(this._lastWrittenByte=this.offset)}}function yl(e,t){if(e)throw new TypeError("Not a valid NetCDF v3.x file: "+t)}function Voe(e){e.offset%4!=0&&e.skip(4-e.offset%4)}function _6(e){const t=e.readUint32(),n=e.readChars(t);return Voe(e),n}const uo={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function zoe(e){switch(Number(e)){case uo.BYTE:return"byte";case uo.CHAR:return"char";case uo.SHORT:return"short";case uo.INT:return"int";case uo.FLOAT:return"float";case uo.DOUBLE:return"double";default:return"undefined"}}function Goe(e){switch(Number(e)){case uo.BYTE:case uo.CHAR:return 1;case uo.SHORT:return 2;case uo.INT:case uo.FLOAT:return 4;case uo.DOUBLE:return 8;default:return-1}}function joe(e){switch(String(e)){case"byte":return uo.BYTE;case"char":return uo.CHAR;case"short":return uo.SHORT;case"int":return uo.INT;case"float":return uo.FLOAT;case"double":return uo.DOUBLE;default:return-1}}function YD(e,t){if(1!==e){const n=new Array(e);for(let r=0;r6,"non valid type "+s);const a=e.readUint32(),c=x6(e,s,a);Voe(e),t[i]={name:o,type:zoe(s),value:c}}}return t}class lXe{constructor(t){const n=new eXe(t);n.setBigEndian(),yl("CDF"!==n.readChars(3),"should start with CDF");const r=n.readByte();yl(r>2,"unknown version"),this.header=function aXe(e,t){const n={recordDimension:{length:e.readUint32()}};n.version=t;const r=function cXe(e){let t,n,r;const i=e.readUint32();if(i===Ov)return yl(e.readUint32()!==Ov,"wrong empty tag for list of dimensions"),[];{yl(10!==i,"wrong tag for list of dimensions");const o=e.readUint32();t=new Array(o);for(let s=0;s6,"non valid type "+f);const p=e.readUint32();let m=e.readUint32();2===n&&(yl(m>0,"offsets larger than 4GB not supported"),m=e.readUint32()),l[0]===t&&(i+=p),o[a]={name:c,dimensions:l,attributes:d,type:zoe(f),size:p,offset:m,record:l[0]===t}}}return{variables:o,recordStep:i}}(e,r.recordId,t);return n.variables=i.variables,n.recordDimension.recordStep=i.recordStep,n}(n,r),this.buffer=n}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}get variables(){return this.header.variables}hasDataVariable(t){return this.header.variables&&-1!==this.header.variables.findIndex(n=>n.name===t)}getDataVariable(t){var n;let r;if(r="string"==typeof t?null===(n=this.header.variables)||void 0===n?void 0:n.find(i=>i.name===t):t,void 0===r)throw new Error("variable not found");return this.buffer.seek(r.offset),r.record?function rXe(e,t,n){const r=joe(t.type),i=t.size?t.size/Goe(r):1,o=n.length,s=new Array(o),a=n.recordStep;for(let c=0;c=1&&(n.timeOffset=n.time[0]),n.time.length>=2&&(n.deltaTime=n.time[1]-n.time[0])),n}),S6.apply(this,arguments)}var C6,w6;!function(e){e.is=function t(r){return"prmtop"===r?.kind},e.fromPrmtop=function n(r){return{kind:"prmtop",name:r.title.join(" ")||"PRMTOP",data:r}}}(C6||(C6={})),function(e){e.is=function t(r){return"top"===r?.kind},e.fromTop=function n(r){return{kind:"top",name:r.system||"TOP",data:r}}}(w6||(w6={}));const vXe=Rt.BuiltIn({name:"coordinates-from-dcd",display:{name:"Parse DCD",description:"Parse DCD binary data."},from:[pe.Data.Binary],to:pe.Molecule.Coordinates})({apply:({a:e})=>Oe.create("Parse DCD",function(){var t=ie(function*(n){const r=yield function Vze(e){return Oe.create("Parse DCD",function(){var t=ie(function*(n){try{const r=function Uze(e){const t=new DataView(e.buffer),n=Object.create(null),r=[];let i=0;const o=new Int32Array(e.buffer,0,23),s=o[0]!==t.getInt32(0);if(84!==o[0]){const h=e.byteLength;for(let g=0;g28672){const t=[];for(let n=0;n0)throw new Error("dcd format with fixed atoms unsupported, aborting");const p=n.NATOM,m=4*p;for(let h=0,g=n.NSET;h=1?(r.ISTART-1)*i.value:0,i.unit),s=[];for(let a=0,c=e.frames.length;a=-1&&d[1]<=1&&d[3]>=-1&&d[3]<=1&&d[4]>=-1&&d[4]<=1?Wp.create(v.create(d[0],d[2],d[5]),v.create(Yn(90-90*Math.asin(d[1])/Wx),Yn(90-90*Math.asin(d[3])/Wx),Yn(90-90*Math.asin(d[4])/Wx))):d[0]<0||d[1]<0||d[2]<0||d[3]<0||d[4]<0||d[5]<0||d[3]>180||d[4]>180||d[5]>180?Wp.fromBasis(v.create(d[0],d[1],d[3]),v.create(d[1],d[2],d[4]),v.create(d[3],d[4],d[5])):Wp.create(v.create(d[0],d[2],d[5]),v.create(Yn(ai(d[1],0,vr)?90:d[1]),Yn(ai(d[3],0,vr)?90:d[3]),Yn(ai(d[4],0,vr)?90:d[4])))}s.push(l)}return Dg.create(s,i,o)});return function(n){return t.apply(this,arguments)}}())}(r.result).runInContext(n);return new pe.Molecule.Coordinates(i,{label:e.label,description:"Coordinates"})});return function(n){return t.apply(this,arguments)}}())}),_Xe=Rt.BuiltIn({name:"coordinates-from-xtc",display:{name:"Parse XTC",description:"Parse XTC binary data."},from:[pe.Data.Binary],to:pe.Molecule.Coordinates})({apply:({a:e})=>Oe.create("Parse XTC",function(){var t=ie(function*(n){const r=yield function kYe(e){return Oe.create("Parse XTC",function(){var t=ie(function*(n){try{n.update({canAbort:!0,message:"Parsing trajectory..."});const r=yield function RYe(e,t){return h6.apply(this,arguments)}(n,e);return Fr.success(r)}catch(r){return Fr.error(""+r)}});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function NYe(e){return Oe.create("Parse XTC",function(){var t=ie(function*(n){yield n.update("Converting to coordinates");const r=Ic(e.deltaTime,"step"),i=Ic(e.timeOffset,r.unit),o=[];for(let s=0,a=e.frames.length;sOe.create("Parse TRR",function(){var t=ie(function*(n){const r=yield function ZYe(e){return Oe.create("Parse TRR",function(){var t=ie(function*(n){try{n.update({canAbort:!0,message:"Parsing trajectory..."});const r=yield function KYe(e){return b6.apply(this,arguments)}(e);return Fr.success(r)}catch(r){return Fr.error(""+r)}});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function QYe(e){return Oe.create("Parse TRR",function(){var t=ie(function*(n){yield n.update("Converting to coordinates");const r=Ic(e.deltaTime,"step"),i=Ic(e.timeOffset,r.unit),o=[];for(let s=0,a=e.frames.length;sOe.create("Parse NCTRAJ",function(){var t=ie(function*(n){const r=yield function fXe(e){return Oe.create("Parse NCTRAJ",function(){var t=ie(function*(n){try{n.update({canAbort:!0,message:"Parsing trajectory..."});const r=yield function dXe(e){return S6.apply(this,arguments)}(e);return Fr.success(r)}catch(r){return Fr.error(""+r)}});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function pXe(e){return Oe.create("Parse NCTRAJ",function(){var t=ie(function*(n){yield n.update("Converting to coordinates");const r=Ic(e.deltaTime,"step"),i=Ic(e.timeOffset,r.unit),o=[];for(let s=0,a=e.coordinates.length;sOe.create("Create Topology",function(){var t=ie(function*(n){const r=yield function hWe(e){return Oe.create("Parse PSF",function(){var t=ie(function*(n){const r=U5.fromPsf(e),i=function pWe(e){const t=new Array(e.count),n=new Array(e.count),r=new Uint32Array(e.count),i=new Uint32Array(e.count),o=new Array(e.count),s=new sd,a=new ad(e.residueId,e.atomName);let c="",u=0,l="",d=0,f=e.segmentName.value(0),p=!1,m=0,h=-1;for(let y=0,b=e.count;yo.value(c)-1,rowCount:o.rowCount,schema:o.schema}),indexB:te.ofLambda({value:c=>s.value(c)-1,rowCount:s.rowCount,schema:s.schema}),order:te.ofConst(1,e.bonds.count,te.Schema.int)};return Yx.create(e.id,i,a,r)});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);return new pe.Molecule.Topology(r,{label:r.label||e.label,description:"Topology"})});return function(n){return t.apply(this,arguments)}}())}),wXe=Rt.BuiltIn({name:"topology-from-prmtop",display:{name:"PRMTOP Topology",description:"Create topology from PRMTOP."},from:[pe.Format.Prmtop],to:pe.Molecule.Topology})({apply:({a:e})=>Oe.create("Create Topology",function(){var t=ie(function*(n){const r=yield function mXe(e){return Oe.create("Parse PRMTOP",function(){var t=ie(function*(n){const r=C6.fromPrmtop(e),i=function hXe(e){const{pointers:t,residuePointer:n,residueLabel:r,atomName:i}=e,o=t.NATOM,s=t.NRES,a=new Uint32Array(o),c=[],u=(M,N,V)=>{const F=r.value(M);for(let G=N,L=V;GddOe.create("Create Topology",function(){var t=ie(function*(n){const r=yield function bXe(e){return Oe.create("Parse TOP",function(){var t=ie(function*(n){const r=w6.fromTop(e),i=function gXe(e){const{molecules:t,compounds:n}=e,r={};let i=0;for(let M=0,N=t._rowCount;MOe.create("Create trajectory from model/topology and coordinates",function(){var n=ie(function*(r){const i=t[e.coordinatesRef].data,o=yield function IXe(e,t,n){return A6.apply(this,arguments)}(r,t[e.modelRef],i);return new pe.Molecule.Trajectory(o,{label:"Trajectory",description:`${o.frameCount} model${1===o.frameCount?"":"s"}`})});return function(r){return n.apply(this,arguments)}}())}),TXe=Rt.BuiltIn({name:"trajectory-from-blob",display:{name:"Parse Blob",description:"Parse format blob into a single trajectory."},from:pe.Format.Blob,to:pe.Molecule.Trajectory})({apply:({a:e})=>Oe.create("Parse Format Blob",function(){var t=ie(function*(n){const r=[];for(const o of e.data){if("cif"!==o.kind)continue;const s=o.data.blocks[0],a=yield fO(s).runInContext(n);if(0===a.frameCount)throw new Error("No models found.");for(let c=0;c!0===r.loadAllBlocks})),blockIndex:C.Optional(C.Numeric(0,{min:0,step:1},{description:"Zero-based index of the block to parse. Only applies when Block Header parameter is not specified.",hideIf:r=>!0===r.loadAllBlocks||r.blockHeader}))};const{blocks:t}=e.data,n=t.map(r=>[r.header,r.header]);return n.push(["","[Use Block Index]"]),{loadAllBlocks:C.Optional(C.Boolean(!1,{description:"If True, ignore Block Header and Block Index parameters and parse all data blocks into a single trajectory."})),blockHeader:C.Optional(C.Select(t[0]&&t[0].header,n,{description:"Header of the block to parse. If not specifed, Block Index parameter applies.",hideIf:r=>!0===r.loadAllBlocks})),blockIndex:C.Optional(C.Numeric(0,{min:0,step:1,max:t.length-1},{description:"Zero-based index of the block to parse. Only applies when Block Header parameter is not specified.",hideIf:r=>!0===r.loadAllBlocks||r.blockHeader}))}}})({isApplicable:e=>e.data.blocks.length>0,apply:({a:e,params:t})=>Oe.create("Parse mmCIF",function(){var n=ie(function*(r){var i;let o;if(t.loadAllBlocks){const a=[];for(const c of e.data.blocks){r.shouldUpdate&&(yield r.update(`Parsing ${c.header}...`));const u=yield fO(c).runInContext(r);for(let l=0;ll.header===a);if(!c)throw new Error(`Data block '${[a]}' not found.`);o=!c.categoryNames.includes("chem_comp_atom")||c.categoryNames.includes("atom_site")||c.categoryNames.includes("ihm_sphere_obj_site")||c.categoryNames.includes("ihm_gaussian_obj_site")?yield fO(c,e.data).runInContext(r):yield function j4e(e){const t=x2.fromFrame(e);return Oe.create("Create CCD Models",n=>function H4e(e,t,n){return pO.apply(this,arguments)}(t.data.db,x2.fromFrame(e),n))}(c).runInContext(r)}if(0===o.frameCount)throw new Error("No models found.");const s=Qp(o);return new pe.Molecule.Trajectory(o,s)});return function(r){return n.apply(this,arguments)}}())}),EXe=Rt.BuiltIn({name:"trajectory-from-pdb",display:{name:"Parse PDB",description:"Parse PDB string and create trajectory."},from:[pe.Data.String],to:pe.Molecule.Trajectory,params:{isPdbqt:C.Boolean(!1)}})({apply:({a:e,params:t})=>Oe.create("Parse PDB",function(){var n=ie(function*(r){const i=yield function Zze(e,t,n=!1){return Oe.create("Parse PDB",function(){var r=ie(function*(i){return Fr.success({lines:yield ht.readAllLinesAsync(e,i),id:t,isPdbqt:n})});return function(i){return r.apply(this,arguments)}}())}(e.data,e.label,t.isPdbqt).runInContext(r);if(i.isError)throw new Error(i.message);const o=yield function fWe(e){return Oe.create("Parse PDB",function(){var t=ie(function*(n){var r;yield n.update("Converting to mmCIF");const i=yield function dWe(e){return O5.apply(this,arguments)}(e),o=Er.fromFrame(i,void 0,L5.create(e)),s=$u(o.data.db,!0),a=yield af(s,o,n),c=null===(r=i.categories.atom_site)||void 0===r?void 0:r.getField("partial_charge");if(c&&1===a.frameCount){const u=a.representative,l=u.atomicHierarchy.atomSourceIndex,f=te.isIdentity(l)?void 0:l.toArray({array:Int32Array}),p=c.toFloatArray(),m=te.ofFloatArray(f?te.mapToArray(l,h=>p[h],Float32Array):p);Pv.Provider.set(u,{data:m,type:"GASTEIGER"})}return a});return function(n){return t.apply(this,arguments)}}())}(i.result).runInContext(r),s=Qp(o);return new pe.Molecule.Trajectory(o,s)});return function(r){return n.apply(this,arguments)}}())}),PXe=Rt.BuiltIn({name:"trajectory-from-gro",display:{name:"Parse GRO",description:"Parse GRO string and create trajectory."},from:[pe.Data.String],to:pe.Molecule.Trajectory})({apply:({a:e})=>Oe.create("Parse GRO",function(){var t=ie(function*(n){const r=yield function Kze(e){return Oe.create("Parse GRO",function(){var t=ie(function*(n){return yield function Xze(e,t){return HL.apply(this,arguments)}(e,n)});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function $qe(e){return Oe.create("Parse GRO",function(){var t=ie(function*(n){const r=B5.fromGro(e),i=[];for(let o=0,s=e.structures.length;oOe.create("Parse XYZ",function(){var t=ie(function*(n){const r=yield function OYe(e){return Oe.create("Parse Mol",ie(function*(){return function BYe(e){const t=ht(e),n=[];for(;;){const i=FYe(t);if(0===i.count)break;n.push(i)}return Fr.success({molecules:n})}(e)}))}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function UYe(e){return Oe.create("Parse XYZ",t=>function LYe(e,t){const{molecules:n}=e;let r=0;for(const x of n)r+=x.count;const i=new Array(r),o=new Int32Array(r),s=new Float32Array(r),a=new Float32Array(r),c=new Float32Array(r),u=new Int32Array(r);let l=0;for(let x=0;xOe.create("Parse MOL",function(){var t=ie(function*(n){const r=yield function lYe(e){return Oe.create("Parse Mol",ie(function*(){return function uYe(e){const t=ht(e),n=ht.readLine(t).trim(),r=ht.readLine(t).trim(),i=ht.readLine(t).trim(),o=ht.readLine(t),s=+o.substr(0,3),a=+o.substr(3,3),c=koe(t,s),u=Noe(t,a),l=Foe(t);return Fr.success({title:n,program:r,comment:i,atoms:c,bonds:u,formalCharges:l})}(e)}))}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function dYe(e){return Oe.create("Parse MOL",t=>Boe(e,void 0,t))}(r.result).runInContext(n),o=Qp(i);return new pe.Molecule.Trajectory(i,o)});return function(n){return t.apply(this,arguments)}}())}),kXe=Rt.BuiltIn({name:"trajectory-from-sdf",display:{name:"Parse SDF",description:"Parse SDF string and create trajectory."},from:[pe.Data.String],to:pe.Molecule.Trajectory})({apply:({a:e})=>Oe.create("Parse SDF",function(){var t=ie(function*(n){const r=yield function YYe(e){return Oe.create("Parse Sdf",ie(function*(){return function $Ye(e){const t=ht(e),n=[];for(;t.positionOe.create("Parse MOL2",function(){var t=ie(function*(n){const r=yield function TYe(e,t){return Oe.create("Parse MOL2",function(){var n=ie(function*(r){return yield function IYe(e,t,n){return l6.apply(this,arguments)}(r,e,t)});return function(r){return n.apply(this,arguments)}}())}(e.data,e.label).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function PYe(e){return Oe.create("Parse MOL2",t=>function DYe(e,t){return d6.apply(this,arguments)}(e,t))}(r.result).runInContext(n),o=Qp(i);return new pe.Molecule.Trajectory(i,o)});return function(n){return t.apply(this,arguments)}}())}),FXe=Rt.BuiltIn({name:"trajectory-from-cube",display:{name:"Parse Cube",description:"Parse Cube file to create a trajectory."},from:pe.Format.Cube,to:pe.Molecule.Trajectory})({apply:({a:e})=>Oe.create("Parse MOL",function(){var t=ie(function*(n){const r=yield function vYe(e){return Oe.create("Parse Cube",t=>function bYe(e,t){return o6.apply(this,arguments)}(e,t))}(e.data).runInContext(n),i=Qp(r);return new pe.Molecule.Trajectory(r,i)});return function(n){return t.apply(this,arguments)}}())}),BXe=Rt.BuiltIn({name:"trajectory-from-cif-core",display:{name:"Parse CIF Core",description:"Identify and create all separate models in the specified CIF data block"},from:pe.Format.Cif,to:pe.Molecule.Trajectory,params(e){if(!e)return{blockHeader:C.Optional(C.Text(void 0,{description:"Header of the block to parse. If none is specifed, the 1st data block in the file is used."}))};const{blocks:t}=e.data;return{blockHeader:C.Optional(C.Select(t[0]&&t[0].header,t.map(n=>[n.header,n.header]),{description:"Header of the block to parse"}))}}})({apply:({a:e,params:t})=>Oe.create("Parse CIF Core",function(){var n=ie(function*(r){const i=t.blockHeader||e.data.blocks[0].header,o=e.data.blocks.find(c=>c.header===i);if(!o)throw new Error(`Data block '${[i]}' not found.`);const s=yield function yYe(e){const t=DS.fromFrame(e);return Oe.create("Parse CIF Core",n=>function hYe(e,t,n){return i6.apply(this,arguments)}(t.data.db,t,n))}(o).runInContext(r);if(0===s.frameCount)throw new Error("No models found.");const a=Qp(s);return new pe.Molecule.Trajectory(s,a)});return function(r){return n.apply(this,arguments)}}())}),OXe=e=>e+1,LXe=e=>e-1,qoe=Rt.BuiltIn({name:"model-from-trajectory",display:{name:"Molecular Model",description:"Create a molecular model from specified index in a trajectory."},from:pe.Molecule.Trajectory,to:pe.Molecule.Model,params:e=>e?{modelIndex:C.Converted(OXe,LXe,C.Numeric(1,{min:1,max:e.data.frameCount,step:1},{description:"Model Index",immediateUpdate:!0}))}:{modelIndex:C.Numeric(0,{},{description:"Zero-based index of the model",immediateUpdate:!0})}})({isApplicable:e=>e.data.frameCount>0,apply:({a:e,params:t})=>Oe.create("Model from Trajectory",function(){var n=ie(function*(r){let i=t.modelIndex%e.data.frameCount;i<0&&(i+=e.data.frameCount);const o=yield Oe.resolveInContext(e.data.getFrameAtIndex(i),r);return new pe.Molecule.Model(o,{label:`Model ${i+1}`,description:1===e.data.frameCount?void 0:`of ${e.data.frameCount}`})});return function(r){return n.apply(this,arguments)}}()),interpolate:(e,t,n)=>({modelIndex:n>=1?t.modelIndex:e.modelIndex+Math.floor((t.modelIndex-e.modelIndex+1)*n)}),dispose({b:e}){e?.data.customProperties.dispose()}}),UXe=Rt.BuiltIn({name:"structure-from-trajectory",display:{name:"Structure from Trajectory",description:"Create a molecular structure from a trajectory."},from:pe.Molecule.Trajectory,to:pe.Molecule.Structure})({apply:({a:e})=>Oe.create("Build Structure",function(){var t=ie(function*(n){const r=yield Ve.ofTrajectory(e.data,n),i={label:"Ensemble",description:Ve.elementDescription(r)};return new pe.Molecule.Structure(r,i)});return function(n){return t.apply(this,arguments)}}()),dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),VXe=Rt.BuiltIn({name:"structure-from-model",display:{name:"Structure",description:"Create a molecular structure (model, assembly, or symmetry) from the specified model."},from:pe.Molecule.Model,to:pe.Molecule.Structure,params:e=>b0.getParams(e&&e.data)})({canAutoUpdate:({oldParams:e,newParams:t})=>b0.canAutoUpdate(e.type,t.type),apply:({a:e,params:t},n)=>Oe.create("Build Structure",function(){var r=ie(function*(i){return b0.create(n,i,e.data,t&&t.type)});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,oldParams:n,newParams:r})=>Yd(n,r)?t.data.model===e.data?Qe.UpdateResult.Unchanged:sn.areHierarchiesEqual(e.data,t.data.model)?(t.data=t.data.remapModel(e.data),Qe.UpdateResult.Updated):Qe.UpdateResult.Recreate:Qe.UpdateResult.Recreate,dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),Woe=v(),$oe=le(),Yoe=le(),zXe=Rt.BuiltIn({name:"transform-structure-conformation",display:{name:"Transform Conformation"},isDecorator:!0,from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:{transform:C.MappedStatic("components",{components:C.Group({axis:C.Vec3(v.create(1,0,0)),angle:C.Numeric(0,{min:-180,max:180,step:.1}),translation:C.Vec3(v.create(0,0,0))},{isFlat:!0}),matrix:C.Group({data:C.Mat4(le.identity()),transpose:C.Boolean(!1)},{isFlat:!0})},{label:"Kind"})}})({canAutoUpdate:({newParams:e})=>"matrix"!==e.transform.name,apply({a:e,params:t}){const n=le();if("components"===t.transform.name){const{axis:i,angle:o,translation:s}=t.transform.params,a=e.data.boundary.sphere.center;le.fromTranslation($oe,v.negate(Woe,a)),le.fromTranslation(Yoe,v.add(Woe,a,s));const c=le.fromRotation(le(),Math.PI/180*o,v.normalize(v(),i));le.mul3(n,Yoe,c,$oe)}else"matrix"===t.transform.name&&(le.copy(n,t.transform.params.data),t.transform.params.transpose&&le.transpose(n,n));const r=Ve.transform(e.data,n);return new pe.Molecule.Structure(r,{label:e.label,description:`${e.description} [Transformed]`})},dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),GXe=Rt.BuiltIn({name:"structure-selection-from-expression",display:{name:"Selection",description:"Create a molecular structure from the specified expression."},from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:()=>({expression:C.Value(ue.struct.generator.all,{isHidden:!0}),label:C.Optional(C.Text("",{isHidden:!0}))})})({apply({a:e,params:t,cache:n}){const{selection:r,entry:i}=Aa.createAndRun(e.data,t.expression);if(n.entry=i,pt.isEmpty(r))return li.Null;const o=pt.unionStructure(r),s={label:`${t.label||"Selection"}`,description:Ve.elementDescription(o)};return new pe.Molecule.Structure(o,s)},update:({a:e,b:t,oldParams:n,newParams:r,cache:i})=>{if(n.expression!==r.expression)return Qe.UpdateResult.Recreate;const o=i.entry;if(o.currentStructure===e.data)return Qe.UpdateResult.Unchanged;const s=Aa.updateStructure(o,e.data);return pt.isEmpty(s)?Qe.UpdateResult.Null:(Aa.updateStructureObject(t,s,r.label),Qe.UpdateResult.Updated)},dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),jXe=Rt.BuiltIn({name:"structure-multi-selection-from-expression",display:{name:"Multi-structure Measurement Selection",description:"Create selection object from multiple structures."},from:pe.Root,to:pe.Molecule.Structure.Selections,params:()=>({selections:C.ObjectList({key:C.Text(void 0,{description:"A unique key."}),ref:C.Text(),groupId:C.Optional(C.Text()),expression:C.Value(ue.struct.generator.empty)},e=>e.ref,{isHidden:!0}),isTransitive:C.Optional(C.Boolean(!1,{isHidden:!0,description:"Remap the selections from the original structure if structurally equivalent."})),label:C.Optional(C.Text("",{isHidden:!0}))})})({apply({params:e,cache:t,dependencies:n}){const r=new Map,i=[];let o=0;for(const a of e.selections){const{selection:c,entry:u}=Aa.createAndRun(n[a.ref].data,a.expression);r.set(a.key,u);const l=pt.toLociWithSourceUnits(c);i.push({key:a.key,loci:l,groupId:a.groupId}),o+=De.size(l)}return t.entries=r,new pe.Molecule.Structure.Selections(i,{label:`${e.label||"Multi-selection"}`,description:`${e.selections.length} source(s), ${o} element(s) total`})},update:({b:e,oldParams:t,newParams:n,cache:r,dependencies:i})=>{if(!!t.isTransitive!=!!n.isTransitive)return Qe.UpdateResult.Recreate;const o=r.entries,s=new Map,a=new Map;for(const d of e.data)a.set(d.key,d);let c=!1,u=0;const l=[];for(const d of n.selections){const f=i[d.ref].data;let p=!1;if(o.has(d.key)){const m=o.get(d.key);if(Aa.isUnchanged(m,d.expression,f)&&a.has(d.key)){const h=a.get(d.key);h.groupId!==d.groupId&&(h.groupId=d.groupId,c=!0),s.set(d.key,m),l.push(h),u+=De.size(h.loci);continue}if(m.expression!==d.expression)p=!0;else{let h=!1;if(n.isTransitive)if(Ve.areUnitIdsAndIndicesEqual(m.originalStructure,f)){const g=Aa.run(m,m.originalStructure);m.currentStructure=f,s.set(d.key,m);const y=De.remap(pt.toLociWithSourceUnits(g),f);l.push({key:d.key,loci:y,groupId:d.groupId}),u+=De.size(y),c=!0}else h=!0;else h=!0;if(h){c=!0;const g=Aa.updateStructure(m,f);s.set(d.key,m);const y=pt.toLociWithSourceUnits(g);l.push({key:d.key,loci:y,groupId:d.groupId}),u+=De.size(y)}}}else p=!0;if(p){c=!0;const{selection:m,entry:h}=Aa.createAndRun(f,d.expression);s.set(d.key,h);const g=pt.toLociWithSourceUnits(m);l.push({key:d.key,loci:g}),u+=De.size(g)}}return c?(r.entries=s,e.data=l,e.label=`${n.label||"Multi-selection"}`,e.description=`${l.length} source(s), ${u} element(s) total`,Qe.UpdateResult.Updated):Qe.UpdateResult.Unchanged}}),HXe=Rt.BuiltIn({name:"structure-selection-from-script",display:{name:"Selection",description:"Create a molecular structure from the specified script."},from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:()=>({script:C.Script({language:"mol-script",expression:"(sel.atom.atom-groups :residue-test (= atom.resname ALA))"}),label:C.Optional(C.Text(""))})})({apply({a:e,params:t,cache:n}){const{selection:r,entry:i}=Aa.createAndRun(e.data,t.script);n.entry=i;const o=pt.unionStructure(r),s={label:`${t.label||"Selection"}`,description:Ve.elementDescription(o)};return new pe.Molecule.Structure(o,s)},update:({a:e,b:t,oldParams:n,newParams:r,cache:i})=>{if(!ko.areEqual(n.script,r.script))return Qe.UpdateResult.Recreate;const o=i.entry;if(o.currentStructure===e.data)return Qe.UpdateResult.Unchanged;const s=Aa.updateStructure(o,e.data);return Aa.updateStructureObject(t,s,r.label),Qe.UpdateResult.Updated},dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),qXe=Rt.BuiltIn({name:"structure-selection-from-bundle",display:{name:"Selection",description:"Create a molecular structure from the specified structure-element bundle."},from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:()=>({bundle:C.Value(Kn.Empty,{isHidden:!0}),label:C.Optional(C.Text("",{isHidden:!0}))})})({apply({a:e,params:t,cache:n}){if(t.bundle.hash!==e.data.hashCode)return li.Null;n.source=e.data;const r=Kn.toStructure(t.bundle,e.data);if(0===r.elementCount)return li.Null;const i={label:`${t.label||"Selection"}`,description:Ve.elementDescription(r)};return new pe.Molecule.Structure(r,i)},update:({a:e,b:t,oldParams:n,newParams:r,cache:i})=>{if(!Kn.areEqual(n.bundle,r.bundle))return Qe.UpdateResult.Recreate;if(r.bundle.hash!==e.data.hashCode)return Qe.UpdateResult.Null;if(i.source===e.data)return Qe.UpdateResult.Unchanged;i.source=e.data;const o=Kn.toStructure(r.bundle,e.data);return 0===o.elementCount?Qe.UpdateResult.Null:(t.label=`${r.label||"Selection"}`,t.description=Ve.elementDescription(o),t.data=o,Qe.UpdateResult.Updated)},dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),Xoe={polymer:"polymer",protein:"protein",nucleic:"nucleic",water:"water",branched:"branched",ligand:"ligand","non-standard":"non-standard",coarse:"coarse","atomic-sequence":"atomic-sequence","atomic-het":"atomic-het",spheres:"spheres"},WXe=C.objectToOptions(Xoe),$Xe=Rt.BuiltIn({name:"structure-complex-element",display:{name:"Complex Element",description:"Create a molecular structure from the specified model."},from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:{type:C.Select("atomic-sequence",WXe,{isHidden:!0})}})({apply({a:e,params:t}){let n,r;switch(t.type){case"polymer":n=No.polymer.query,r="Polymer";break;case"protein":n=No.protein.query,r="Protein";break;case"nucleic":n=No.nucleic.query,r="Nucleic";break;case"water":n=Sr.internal.water(),r="Water";break;case"branched":n=No.branchedPlusConnected.query,r="Branched";break;case"ligand":n=No.ligandPlusConnected.query,r="Ligand";break;case"non-standard":n=No.nonStandardPolymer.query,r="Non-standard";break;case"coarse":n=No.coarse.query,r="Coarse";break;case"atomic-sequence":n=Sr.internal.atomicSequence(),r="Sequence";break;case"atomic-het":n=Sr.internal.atomicHet(),r="HET Groups/Ligands";break;case"spheres":n=Sr.internal.spheres(),r="Coarse Spheres";break;default:Rr()}const i=n(new qu(e.data)),o=pt.unionStructure(i);return 0===o.elementCount?li.Null:new pe.Molecule.Structure(o,{label:r,description:Ve.elementDescription(o)})},dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),YXe=Rt.BuiltIn({name:"structure-component",display:{name:"Component",description:"A molecular structure component."},from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:()=>({type:C.MappedStatic("static",{static:C.Text("polymer"),expression:C.Value(ue.struct.generator.all),bundle:C.Value(Kn.Empty),script:C.Script({language:"mol-script",expression:"(sel.atom.all)"})},{isHidden:!0}),nullIfEmpty:C.Optional(C.Boolean(!0,{isHidden:!0})),label:C.Text("",{isHidden:!0})})})({apply:({a:e,params:t,cache:n})=>function oYe(e,t,n){n.source=e;let i,r=Ve.Empty;switch(t.type.name){case"static":{let s;switch(t.type.params){case"all":s=No.all.query,i="All";break;case"polymer":s=No.polymer.query,i="Polymer";break;case"protein":s=No.protein.query,i="Protein";break;case"nucleic":s=No.nucleic.query,i="Nucleic";break;case"water":s=Sr.internal.water(),i="Water";break;case"ion":s=No.ion.query,i="Ion";break;case"lipid":s=No.lipid.query,i="Lipid";break;case"branched":s=No.branchedPlusConnected.query,i="Branched";break;case"ligand":s=No.ligandPlusConnected.query,i="Ligand";break;case"non-standard":s=No.nonStandardPolymer.query,i="Non-standard";break;case"coarse":s=No.coarse.query,i="Coarse";break;default:Rr()}const a=s(new qu(e));r=pt.unionStructure(a);break}case"script":case"expression":{const{selection:s,entry:a}=Aa.createAndRun(e,t.type.params);n.entry=a,r=pt.unionStructure(s);break}case"bundle":if(t.type.params.hash!==e.hashCode)break;r=Kn.toStructure(t.type.params,e)}if(t.nullIfEmpty&&0===r.elementCount)return li.Null;const o={label:`${t.label||i||"Component"}`,description:Ve.elementDescription(r)};return new pe.Molecule.Structure(r,o)}(e.data,t,n),update:({a:e,b:t,oldParams:n,newParams:r,cache:i})=>function sYe(e,t,n,r,i){if(n.type.name!==r.type.name)return Qe.UpdateResult.Recreate;let o=!1;switch(r.type.name){case"static":return n.type.params===r.type.params&&Ve.areEquivalent(e,i.source)?t.data.model===e.model?Qe.UpdateResult.Unchanged:sn.areHierarchiesEqual(e.model,t.data.model)?(t.data=t.data.remapModel(e.model),Qe.UpdateResult.Updated):Qe.UpdateResult.Recreate:Qe.UpdateResult.Recreate;case"script":if(!ko.areEqual(n.type.params,r.type.params))return Qe.UpdateResult.Recreate;case"expression":{if(n.type.params!==r.type.params)return Qe.UpdateResult.Recreate;if(e===i.source)break;const a=Aa.updateStructure(i.entry,e);i.source=e,t.data=pt.unionStructure(a),Aa.updateStructureObject(t,a,r.label),o=!0;break}case"bundle":if(e===i.source&&Kn.areEqual(n.type.params,r.type.params))break;i.source=e,r.type.params.hash!==e.hashCode?(o=0!==t.data.elementCount,t.data=0===t.data.elementCount?t.data:Ve.Empty):(o=!0,t.data=Kn.toStructure(r.type.params,e))}if(o){if(r.nullIfEmpty&&0===t.data.elementCount)return Qe.UpdateResult.Null;t.description=Ve.elementDescription(t.data)}return n.label!==r.label&&(o=!0,t.label=`${r.label||t.label}`),o?Qe.UpdateResult.Updated:Qe.UpdateResult.Unchanged}(e.data,t,n,r,i),dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),Koe=Rt.BuiltIn({name:"custom-model-properties",display:{name:"Custom Model Properties"},isDecorator:!0,from:pe.Molecule.Model,to:pe.Molecule.Model,params:(e,t)=>t.customModelProperties.getParams(e?.data)})({apply:({a:e,params:t},n)=>Oe.create("Custom Props",function(){var r=ie(function*(i){return yield Zoe(e.data,n,i,t),new pe.Molecule.Model(e.data,{label:e.label,description:e.description})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,oldParams:n,newParams:r},i)=>Oe.create("Custom Props",function(){var o=ie(function*(s){t.data=e.data,t.label=e.label,t.description=e.description;for(const a of n.autoAttach){const c=i.customModelProperties.get(a);c&&e.data.customProperties.reference(c.descriptor,!1)}return yield Zoe(e.data,i,s,r),Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}()),dispose({b:e}){e?.data.customProperties.dispose()}});function Zoe(e,t,n,r){return T6.apply(this,arguments)}function T6(){return T6=ie(function*(e,t,n,r){const i={runtime:n,assetManager:t.managers.asset},{autoAttach:o,properties:s}=r;for(const a of Object.keys(s)){const c=t.customModelProperties.get(a),u=s[a];if(o.includes(a)||c.isHidden)try{yield c.attach(i,e,u,!0)}catch(l){t.log.warn(`Error attaching model prop '${a}': ${l}`)}else c.set(e,u)}}),T6.apply(this,arguments)}const Qoe=Rt.BuiltIn({name:"custom-structure-properties",display:{name:"Custom Structure Properties"},isDecorator:!0,from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:(e,t)=>t.customStructureProperties.getParams(e?.data.root)})({apply:({a:e,params:t},n)=>Oe.create("Custom Props",function(){var r=ie(function*(i){return yield Joe(e.data.root,n,i,t),new pe.Molecule.Structure(e.data,{label:e.label,description:e.description})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,oldParams:n,newParams:r},i)=>e.data!==t.data?Qe.UpdateResult.Recreate:Oe.create("Custom Props",function(){var o=ie(function*(s){t.data=e.data,t.label=e.label,t.description=e.description;for(const a of n.autoAttach){const c=i.customStructureProperties.get(a);c&&e.data.customPropertyDescriptors.reference(c.descriptor,!1)}return yield Joe(e.data.root,i,s,r),Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}()),dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}});function Joe(e,t,n,r){return D6.apply(this,arguments)}function D6(){return D6=ie(function*(e,t,n,r){const i={runtime:n,assetManager:t.managers.asset},{autoAttach:o,properties:s}=r;for(const a of Object.keys(s)){const c=t.customStructureProperties.get(a),u=s[a];if(o.includes(a)||c.isHidden)try{yield c.attach(i,e,u,!0)}catch(l){t.log.warn(`Error attaching structure prop '${a}': ${l}`)}else c.set(e,u)}}),D6.apply(this,arguments)}const XXe=Rt.BuiltIn({name:"shape-from-ply",display:{name:"Shape from PLY",description:"Create Shape from PLY data"},from:pe.Format.Ply,to:pe.Shape.Provider,params:e=>({transforms:C.Optional(C.Value([],{isHidden:!0})),label:C.Optional(C.Text("",{isHidden:!0}))})})({apply:({a:e,params:t})=>Oe.create("Create shape from PLY",function(){var n=ie(function*(r){const i=yield function Uqe(e,t){return Oe.create("Shape Provider",function(){var n=ie(function*(r){return{label:"Mesh",data:{source:e,transforms:t?.transforms},params:Kie(e),getShape:Lqe(),geometryUtils:Nt.Utils}});return function(r){return n.apply(this,arguments)}}())}(e.data,t).runInContext(r);return new pe.Shape.Provider(i,{label:t.label||"Shape"})});return function(r){return n.apply(this,arguments)}}())});var E6,P6,M6,R6;!function(e){e.is=function t(r){return"ccp4"===r?.kind},e.create=function n(r){return{kind:"ccp4",name:r.name,data:r}}}(E6||(E6={})),function(e){e.is=function t(r){return"dsn6"===r?.kind},e.create=function n(r){return{kind:"dsn6",name:r.name,data:r}}}(P6||(P6={})),function(e){e.is=function t(r){return"dx"===r?.kind},e.create=function n(r){return{kind:"dx",name:r.name,data:r}}}(M6||(M6={})),function(e){e.is=function t(r){return"segcif"===r?.kind},e.create=function n(r){return{kind:"segcif",name:r._name,data:r}}}(R6||(R6={}));const nKe=Rt.BuiltIn({name:"volume-from-ccp4",display:{name:"Volume from CCP4/MRC/MAP",description:"Create Volume from CCP4/MRC/MAP data"},from:pe.Format.Ccp4,to:pe.Volume.Data,params:e=>({voxelSize:C.Vec3(v.create(1,1,1)),offset:C.Vec3(v.create(0,0,0)),entryId:C.Text("")})})({apply:({a:e,params:t})=>Oe.create("Create volume from CCP4/MRC/MAP",function(){var n=ie(function*(r){const i=yield function QXe(e,t){return Oe.create("Create Volume",function(){var n=ie(function*(r){const{header:i,values:o}=e,s=v.create(i.xLength,i.yLength,i.zLength);t&&t.voxelSize&&v.mul(s,s,t.voxelSize);const a=v.create(Yn(i.alpha),Yn(i.beta),Yn(i.gamma)),u=ma.create((i.ISPG>65536?0:i.ISPG)||"P 1",s,a),l=v.create(i.MAPC-1,i.MAPR-1,i.MAPS-1),d=wn.convertToCanonicalAxisIndicesFastToSlow(l),f=[i.NX,i.NY,i.NZ],p=d([i.NC,i.NR,i.NS]),m=function KXe(e){return 0===e.originX&&0===e.originY&&0===e.originZ?v.create(e.NCSTART,e.NRSTART,e.NSSTART):v.create(e.originX/(e.xLength/e.NX),e.originY/(e.yLength/e.NY),e.originZ/(e.zLength/e.NZ))}(i);t?.offset&&v.add(m,m,t.offset);const h=d(m),g=v.create(h[0]/f[0],h[1]/f[1],h[2]/f[2]),y=v.create(p[0]/f[0],p[1]/f[1],p[2]/f[2]),b=wn.Space(p,wn.invertAxisOrder(l),function ZXe(e){const t=vte(e);switch(t){case us.Float32:return Float32Array;case us.Int8:return Int8Array;case us.Int16:return Int16Array;case us.Uint16:return Uint16Array}throw Error(`${t} is not a supported value format.`)}(i)),x=wn.create(b,wn.Data1(o)),_=0===i.AMIN&&0===i.AMAX&&0===i.AMEAN&&0===i.ARMS;return{label:t?.label,entryId:t?.entryId,grid:{transform:{kind:"spacegroup",cell:u,fractionalBox:St.create(g,v.add(v.zero(),g,y))},cells:x,stats:{min:isNaN(i.AMIN)||_?VI(o):i.AMIN,max:isNaN(i.AMAX)||_?Xd(o):i.AMAX,mean:isNaN(i.AMEAN)||_?zI(o):i.AMEAN,sigma:isNaN(i.ARMS)||0===i.ARMS?GI(o):i.ARMS}},sourceData:E6.create(e),customProperties:new Ql,_propertyData:Object.create(null)}});return function(r){return n.apply(this,arguments)}}())}(e.data,{...t,label:e.data.name||e.label}).runInContext(r);return new pe.Volume.Data(i,{label:i.label||"Volume",description:`Volume ${e.data.header.NX}\xd7${e.data.header.NX}\xd7${e.data.header.NX}`})});return function(r){return n.apply(this,arguments)}}()),dispose({b:e}){e?.data.customProperties.dispose()}}),rKe=Rt.BuiltIn({name:"volume-from-dsn6",display:{name:"Volume from DSN6/BRIX",description:"Create Volume from DSN6/BRIX data"},from:pe.Format.Dsn6,to:pe.Volume.Data,params:e=>({voxelSize:C.Vec3(v.create(1,1,1)),entryId:C.Text("")})})({apply:({a:e,params:t})=>Oe.create("Create volume from DSN6/BRIX",function(){var n=ie(function*(r){const i=yield function JXe(e,t){return Oe.create("Create Volume",function(){var n=ie(function*(r){const{header:i,values:o}=e,s=v.create(i.xlen,i.ylen,i.zlen);t&&t.voxelSize&&v.mul(s,s,t.voxelSize);const a=v.create(Yn(i.alpha),Yn(i.beta),Yn(i.gamma)),c=ma.create("P 1",s,a),u=[i.xRate,i.yRate,i.zRate],l=[i.xExtent,i.yExtent,i.zExtent],d=[i.xStart,i.yStart,i.zStart],f=v.create(d[0]/u[0],d[1]/u[1],d[2]/u[2]),p=v.create(l[0]/u[0],l[1]/u[1],l[2]/u[2]),m=wn.Space(l,[0,1,2],Float32Array),h=wn.create(m,wn.Data1(o));return{label:t?.label,entryId:t?.entryId,grid:{transform:{kind:"spacegroup",cell:c,fractionalBox:St.create(f,v.add(v.zero(),f,p))},cells:h,stats:{min:VI(o),max:Xd(o),mean:zI(o),sigma:void 0!==i.sigma?i.sigma:GI(o)}},sourceData:P6.create(e),customProperties:new Ql,_propertyData:Object.create(null)}});return function(r){return n.apply(this,arguments)}}())}(e.data,{...t,label:e.data.name||e.label}).runInContext(r);return new pe.Volume.Data(i,{label:i.label||"Volume",description:`Volume ${e.data.header.xExtent}\xd7${e.data.header.yExtent}\xd7${e.data.header.zExtent}`})});return function(r){return n.apply(this,arguments)}}()),dispose({b:e}){e?.data.customProperties.dispose()}}),iKe=Rt.BuiltIn({name:"volume-from-cube",display:{name:"Volume from Cube",description:"Create Volume from Cube data"},from:pe.Format.Cube,to:pe.Volume.Data,params:e=>({dataIndex:e?C.Select(0,e.data.header.dataSetIds.map((n,r)=>[r,`${n}`])):C.Numeric(0),entryId:C.Text("")})})({apply:({a:e,params:t})=>Oe.create("Create volume from Cube",function(){var n=ie(function*(r){const i=yield function OHe(e,t){return Oe.create("Create Volume",ie(function*(){const{header:n,values:r}=e,i=wn.Space(n.dim,[0,1,2],Float64Array);let o;if(0===n.dataSetIds.length)o=r;else{const[u,l,d]=n.dim,f=(t?.dataIndex||0)+1;let p=0,m=0;o=new Float64Array(u*l*d);for(let h=0;hOe.create("Parse DX",function(){var t=ie(function*(n){const r=yield function eKe(e,t){return Oe.create("Create Volume",ie(function*(){const{header:n,values:r}=e,i=wn.Space(n.dim,[0,1,2],Float64Array),o=wn.create(i,wn.Data1(r)),s=le.fromTranslation(le(),n.min),a=le.fromScaling(le(),n.h);return le.mul(s,s,a),{label:t?.label,entryId:t?.entryId,grid:{transform:{kind:"matrix",matrix:s},cells:o,stats:{min:VI(r),max:Xd(r),mean:zI(r),sigma:GI(r)}},sourceData:M6.create(e),customProperties:new Ql,_propertyData:Object.create(null)}}))}(e.data,{label:e.data.name||e.label}).runInContext(n);return new pe.Volume.Data(r,{label:r.label||"Volume",description:`Volume ${e.data.header.dim[0]}\xd7${e.data.header.dim[1]}\xd7${e.data.header.dim[2]}`})});return function(n){return t.apply(this,arguments)}}()),dispose({b:e}){e?.data.customProperties.dispose()}}),sKe=Rt.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:pe.Format.Cif,to:pe.Volume.Data,params(e){if(!e)return{blockHeader:C.Optional(C.Text(void 0,{description:"Header of the block to parse. If none is specifed, the 1st data block in the file is used."})),entryId:C.Text("")};const t=e.data.blocks.slice(1);return{blockHeader:C.Optional(C.Select(t[0]&&t[0].header,t.map(n=>[n.header,n.header]),{description:"Header of the block to parse"})),entryId:C.Text("")}}})({isApplicable:e=>e.data.blocks.length>0,apply:({a:e,params:t})=>Oe.create("Parse density-server CIF",function(){var n=ie(function*(r){var i;const o=t.blockHeader||e.data.blocks[1].header,s=e.data.blocks.find(p=>p.header===o);if(!s)throw new Error(`Data block '${[o]}' not found.`);const a=od.schema.densityServer(s),c=yield jie(a,{entryId:t.entryId}).runInContext(r),[u,l,d]=c.grid.cells.space.dimensions,f={label:null!==(i=t.entryId)&&void 0!==i?i:a.volume_data_3d_info.name.value(0),description:`Volume ${u}\xd7${l}\xd7${d}`};return new pe.Volume.Data(c,f)});return function(r){return n.apply(this,arguments)}}()),dispose({b:e}){e?.data.customProperties.dispose()}}),aKe=Rt.BuiltIn({name:"volume-from-segmentation-cif",display:{name:"Volume from Segmentation CIF"},from:pe.Format.Cif,to:pe.Volume.Data,params(e){const t=e?.data.blocks.slice(1);return{blockHeader:C.Optional(t?C.Select(t[0]&&t[0].header,t.map(r=>[r.header,r.header]),{description:"Header of the block to parse"}):C.Text(void 0,{description:"Header of the block to parse. If none is specifed, the 1st data block in the file is used."})),segmentLabels:C.ObjectList({id:C.Numeric(-1),label:C.Text("")},r=>`${r.id} = ${r.label}`,{description:"Mapping of segment IDs to segment labels"}),ownerId:C.Text("",{isHidden:!0,description:"Reference to the object which manages this volume"})}}})({isApplicable:e=>e.data.blocks.length>0,apply:({a:e,params:t})=>Oe.create("Parse segmentation CIF",function(){var n=ie(function*(r){const i=t.blockHeader||e.data.blocks[1].header,o=e.data.blocks.find(p=>p.header===i);if(!o)throw new Error(`Data block '${[i]}' not found.`);const s=od.schema.segmentation(o),a={};for(const p of t.segmentLabels)a[p.id]=p.label;const c=yield function tKe(e,t){return Oe.create("Create Segmentation Volume",function(){var n=ie(function*(r){var i;const{volume_data_3d_info:o,segmentation_data_3d:s}=e,a=ma.create(o.spacegroup_number.value(0),v.ofArray(o.spacegroup_cell_size.value(0)),v.scale(v(),v.ofArray(o.spacegroup_cell_angles.value(0)),Math.PI/180)),c=o.axis_order.value(0),u=wn.convertToCanonicalAxisIndicesFastToSlow(c),l=u(o.sample_count.value(0)),d=wn.Space(l,wn.invertAxisOrder(c),Float32Array),f=wn.create(d,wn.Data1(s.values.toArray({array:Float32Array}))),p=v.ofArray(u(o.origin.value(0))),m=v.ofArray(u(o.dimensions.value(0))),h={label:t?.label,entryId:void 0,grid:{transform:{kind:"spacegroup",cell:a,fractionalBox:St.create(p,v.add(v(),p,m))},cells:f,stats:{min:0,max:1,mean:0,sigma:1}},sourceData:R6.create(e),customProperties:new Ql,_propertyData:{ownerId:t?.ownerId}};et.PickingGranularity.set(h,"object");const g=new Map,y=new Map,{segment_id:b,set_id:x}=e.segmentation_data_table;for(let V=0,F=b.rowCount;V{V.forEach(G=>{g.has(G)||g.set(G,new Set),g.get(G).add(F)})});const _=[0,0,0],S=f.space.getCoords,A=f.data,[E,w,D]=h.grid.cells.space.dimensions,I=E-1,R=w-1,T=D-1,M={};y.forEach((V,F)=>{M[F]=[I,R,T,-1,-1,-1]});for(let V=0,F=A.length;VL[3]&&(L[3]=_[0]),_[1]>L[4]&&(L[4]=_[1]),_[2]>L[5]&&(L[5]=_[2])}const N={};return g.forEach((V,F)=>{N[F]=St.create(v.create(I,R,T),v.create(-1,-1,-1))}),$a(M,(V,F)=>{y.get(parseInt(F)).forEach(G=>{const L=N[G];V[0]L.max[0]&&(L.max[0]=V[3]),V[4]>L.max[1]&&(L.max[1]=V[4]),V[5]>L.max[2]&&(L.max[2]=V[5])})}),et.Segmentation.set(h,{segments:g,sets:y,bounds:N,labels:null!==(i=t?.segmentLabels)&&void 0!==i?i:{}}),h});return function(r){return n.apply(this,arguments)}}())}(s,{segmentLabels:a,ownerId:t.ownerId}).runInContext(r),[u,l,d]=c.grid.cells.space.dimensions,f={label:s.volume_data_3d_info.name.value(0),description:`Segmentation ${u}\xd7${l}\xd7${d}`};return new pe.Volume.Data(c,f)});return function(r){return n.apply(this,arguments)}}()),dispose({b:e}){e?.data.customProperties.dispose()}}),cKe=Rt.BuiltIn({name:"assign-color-volume",display:{name:"Assign Color Volume",description:"Assigns another volume to be available for coloring."},from:pe.Volume.Data,to:pe.Volume.Data,isDecorator:!0,params(e,t){if(!e)return{ref:C.Text()};const n=t.state.data.select(In.Generators.root.subtree().ofType(pe.Volume.Data).filter(r=>{var i;return!(!r.obj||null!==(i=r.obj)&&void 0!==i&&i.data.colorVolume||r.obj===e)}));return 0===n.length?{ref:C.Text("",{isHidden:!0})}:{ref:C.Select(n[0].transform.ref,n.map(r=>[r.transform.ref,r.obj.label]))}}})({apply:({a:e,params:t,dependencies:n})=>Oe.create("Assign Color Volume",function(){var r=ie(function*(i){if(!n||!n[t.ref])throw new Error("Dependency not available.");const s={...e.data,colorVolume:n[t.ref].data};return new pe.Volume.Data(s,{label:e.label,description:"Volume + Colors"})});return function(i){return r.apply(this,arguments)}}())}),XD=st(13421772),ese={},dKe={name:"carbohydrate-symbol",label:"Carbohydrate Symbol",category:ni.Residue,factory:function tse(e,t){let n;if(e.structure){const{elements:r,getElementIndices:i}=e.structure.carbohydrates,o=(s,a)=>{if(!Ee.isAtomic(s))return XD;const c=i(s,a);return c.length>0?r[c[0]].component.color:XD};n=(s,a)=>a?15854817:nt.is(s)?o(s.unit,s.element):Lt.isLocation(s)?o(s.aUnit,s.aUnit.elements[s.aIndex]):XD}else n=()=>XD;return{factory:tse,granularity:"group",color:n,props:t,description:"Assigns colors according to the Symbol Nomenclature for Glycans (SNFG).",legend:$h(UNe)}},getParams:function lKe(e){return ese},defaultValues:C.getDefaultValues(ese),isApplicable:e=>!!e.structure&&e.structure.models.some(t=>sn.hasCarbohydrate(t))},nse={hue:C.Interval([1,360],{min:0,max:360,step:1}),chroma:C.Interval([40,70],{min:0,max:100,step:1}),luminance:C.Interval([15,85],{min:0,max:100,step:1}),sort:C.Select("contrast",C.arrayToOptions(["none","contrast"]),{description:"no sorting leaves colors approximately ordered by hue"}),clusteringStepCount:C.Numeric(50,{min:10,max:200,step:1},{isHidden:!0}),minSampleCount:C.Numeric(800,{min:100,max:5e3,step:100},{isHidden:!0}),sampleCountFactor:C.Numeric(5,{min:1,max:100,step:1},{isHidden:!0})},Lv=2,_0=[0,0,0],x0=[0,0,0];function fKe(e,t){return Yo.toHcl(_0,e),Yo.fromColor(x0,Yo.toColor(e)),_0[0]>=t.hue[0]&&_0[0]<=t.hue[1]&&_0[1]>=t.chroma[0]&&_0[1]<=t.chroma[1]&&_0[2]>=t.luminance[0]&&_0[2]<=t.luminance[1]&&x0[0]>=e[0]-Lv&&x0[0]<=e[0]+Lv&&x0[1]>=e[1]-Lv&&x0[1]<=e[1]+Lv&&x0[2]>=e[2]-Lv&&x0[2]<=e[2]+Lv}function rse(e,t){let n=1/0,r=0;for(let i=0;i`${e+1}`,minLabel:"Start",maxLabel:"End"};function ac(e,t,n={}){var r;let i,o;if("colors"===t.palette.name&&"interpolate"===t.palette.params.list.kind){const{list:s}=t.palette.params,a=[0,e-1],{minLabel:c,maxLabel:u}={...ose,...n};let l=s.colors;0===l.length&&(l=cp(ise.colorList).list);const d=Gu.create({listOrName:l,domain:a,minLabel:c,maxLabel:u});o=d.legend,i=d.color}else{let s;"colors"===t.palette.name?(s=t.palette.params.list.colors.map(l=>Array.isArray(l)?l[0]:l),0===s.length&&(s=cp("dark-2").list.map(l=>Array.isArray(l)?l[0]:l))):(e=Math.min(e,t.palette.params.maxCount),s=function mKe(e,t={}){const n={...C.getDefaultValues(nse),...t};if(e<=0)return[];const r=function hKe(e,t){const n=new Map,r=Math.ceil(Math.cbrt(e)),i=id(),o=Math.max((t.hue[1]-t.hue[0])/r,1),s=Math.max((t.chroma[1]-t.chroma[0])/r,1),a=Math.max((t.luminance[1]-t.luminance[0])/r,1);for(let c=t.hue[0]+o/2;c<=t.hue[1];c+=o)for(let u=t.chroma[0]+s/2;u<=t.chroma[1];u+=s)for(let l=t.luminance[0]+a/2;l<=t.luminance[1];l+=a){const d=Yo.fromHcl(Yo(),id.set(i,c,u,l));fKe(d,t)&&n.set(Yo.toColor(d),d)}return Array.from(n.values())}(Math.max(n.minSampleCount,e*n.sampleCountFactor),n);if(r.length=e));c+=s);for(let c=1;c<=n.clusteringStepCount;++c){const u=Jl(o),l=Jl(r);for(let f=0;f0;){const r=n[n.length-1];let i=0,o=Number.NEGATIVE_INFINITY;for(let s=0;so&&(o=a,i=s)}n.push(t.splice(i,1)[0])}return n}(i):i).map(c=>Yo.toColor(c))}(e,t.palette.params));const a=null!==(r=n.valueLabel)&&void 0!==r?r:ose.valueLabel,c=s.length,u=[];for(let l=0;ls[l%c]}return{color:i,legend:o}}const sse=st(16448250),yKe="Gives every chain a color based on its `asym_id` value.",ES={asymId:C.Select("auth",C.arrayToOptions(["auth","label"])),...Ia({type:"colors",colorList:"many-distinct"})};function ase(e,t){const n=function vKe(e,t){switch(e.kind){case 0:return"auth"===t?Ze.chain.auth_asym_id:Ze.chain.label_asym_id;case 1:case 2:return Ze.coarse.asym_id}}(e.unit,t)(e);return e.structure.root.models.length>1?cse(e.unit.model,n):n}function cse(e,t){return`${t}|${(sn.Index.get(e).value||0)+1}`}function PS(e,t){let n,r;if(e.structure){const i=nt.create(e.structure.root),o=function _Ke(e,t){const n=new Map;for(const r of e.models){const i=sn.AsymIdOffset.get(r).value,o=("auth"===t?i?.auth:i?.label)||0;let s=0;r.properties.structAsymMap.forEach(({auth_id:a},c)=>{const u="auth"===t?a:c,l=e.models.length>1?cse(r,u):u;n.has(l)||(n.set(l,s+o),++s)})}return n}(e.structure.root,t.asymId),s=Array.from(o.keys()),c=ac(o.size,t,{valueLabel:u=>s[u]});r=c.legend,n=u=>{let l;if(nt.is(u)){const d=ase(u,t.asymId);l=o.get(d)}else if(Lt.isLocation(u)){i.unit=u.aUnit,i.element=u.aUnit.elements[u.aIndex];const d=ase(i,t.asymId);l=o.get(d)}return void 0===l?sse:c.color(l)}}else n=()=>sse;return{factory:PS,granularity:"group",color:n,props:t,description:yKe,legend:r}}const use={name:"chain-id",label:"Chain Id",category:ni.Chain,factory:PS,getParams:function bKe(e){var t;const n=C.clone(ES);return!(null===(t=e.structure)||void 0===t)&&t.models.some(r=>r.coarseHierarchy.isDefined)&&(n.asymId.defaultValue="label"),n},defaultValues:C.getDefaultValues(ES),isApplicable:e=>!!e.structure},lse=st(13421772),dse={...Ia({type:"colors",colorList:"red-yellow-blue"})},CKe={name:"element-index",label:"Element Index",category:ni.Atom,factory:function fse(e,t){let n,r;if(e.structure){const{units:i}=e.structure.root,o=i.length,s=new Map,a=new Map;let c=0;for(let l=0;l{if(nt.is(l)){const d=a.get(l.unit.id),f=Fe.findPredecessorIndex(i[d].elements,l.element);return u.color(s.get(d)+f)}if(Lt.isLocation(l)){const d=a.get(l.aUnit.id),f=Fe.findPredecessorIndex(i[d].elements,l.aUnit.elements[l.aIndex]);return u.color(s.get(d)+f)}return lse}}else n=()=>lse;return{factory:fse,granularity:"groupInstance",preferSmoothing:!0,color:n,props:t,description:"Gives every element (atom or coarse sphere/gaussian) a unique color based on the position (index) of the element in the list of elements in the structure.",legend:r}},getParams:function SKe(e){return dse},defaultValues:C.getDefaultValues(dse),isApplicable:e=>!!e.structure};function KD(e){const t={};return $a(e,(n,r)=>{t[r]=C.Color(e[r])}),t}const pse=st(13421772),AKe="Assigns a color based on the operator name of a transformed chain.",k6={...Ia({type:"colors",colorList:"many-distinct"})};function N6(e,t){let n,r;if(e.structure){const i=function TKe(e){const t=new Map;for(let n=0,r=e.units.length;no[c]});r=a.legend,n=c=>{let u;return nt.is(c)?u=i.get(c.unit.conformation.operator.name):Lt.isLocation(c)&&(u=i.get(c.aUnit.conformation.operator.name)),void 0===u?pse:a.color(u)}}else n=()=>pse;return{factory:N6,granularity:"instance",color:n,props:t,description:AKe,legend:r}}const F6={name:"operator-name",label:"Operator Name",category:ni.Symmetry,factory:N6,getParams:function IKe(e){return C.clone(k6)},defaultValues:C.getDefaultValues(k6),isApplicable:e=>!!e.structure},hse=st(16448250),EKe="Gives every chain a color based on its `label_entity_id` value.",RS={...Ia({type:"colors",colorList:"many-distinct"})};function kS(e,t){return`${e}|${t}`}function mse(e){switch(e.unit.kind){case 0:return Ze.chain.label_entity_id(e);case 1:case 2:return Ze.coarse.entity_id(e)}}function NS(e,t){let n,r;if(e.structure){const i=nt.create(e.structure.root),o=function MKe(e){const t=new Map;for(let n=0,r=e.models.length;ns[u]});r=c.legend,n=u=>{let l;if(nt.is(u)){const p=kS(mse(u),u.structure.models.indexOf(u.unit.model));l=o.get(p)}else if(Lt.isLocation(u)){i.unit=u.aUnit,i.element=u.aUnit.elements[u.aIndex];const p=kS(mse(i),i.structure.models.indexOf(i.unit.model));l=o.get(p)}return void 0===l?hse:c.color(l)}}else n=()=>hse;return{factory:NS,granularity:"group",color:n,props:t,description:EKe,legend:r}}const RKe={name:"entity-id",label:"Entity Id",category:ni.Chain,factory:NS,getParams:function PKe(e){return C.clone(RS)},defaultValues:C.getDefaultValues(RS),isApplicable:e=>!!e.structure},B6="dark-2",ZD=st(16448250),kKe="Gives ranges of a polymer chain a color based on the entity source it originates from (e.g. gene, plasmid, organism).",FS={...Ia({type:"colors",colorList:B6})};function gse(e,t){return`${e}|${t}`}function FKe(e,t,n,r,i,o){return`${e}|${t}|${n}|${o||i||r}`}function O6(e,t,n,r,i,o,s,a){const{entity_id:c,pdbx_src_id:u,pdbx_beg_seq_num:l,pdbx_end_seq_num:d}=i;for(let f=0,p=i._rowCount;f{const r=n.split("|"),i=r[2];return`${function jFe(e){e=e.trim();const t=parseInt(e,10);return!isNaN(t)&&t.toString()===e}(r[3])?"Unnamed "+ ++t:r[3]}${i?` (${i})`:""}`})}(a),l=ac(a.size,t,{valueLabel:f=>c[f]});r=l.legend;const d=f=>{const h=gse(o.indexOf(f.unit.model),Ze.entity.id(f)),g=s.get(h);if(g){const y=g[Ze.residue.label_seq_id(f)-1]-1;return-1===y?ZD:l.color(y)}return ZD};n=f=>nt.is(f)?d(f):Lt.isLocation(f)?(i.unit=f.aUnit,i.element=f.aUnit.elements[f.aIndex],d(i)):ZD}else n=()=>ZD;return{factory:BS,granularity:"group",color:n,props:t,description:kKe,legend:r}}const OKe={name:"entity-source",label:"Entity Source",category:ni.Chain,factory:BS,getParams:function NKe(e){const t=C.clone(FS);return e.structure&&yse(e.structure.root.models).srcKeySerialMap.size>Pc[B6].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params={...t.palette.defaultValue.params,list:{kind:"interpolate",colors:cp(B6).list}}),t},defaultValues:C.getDefaultValues(FS),isApplicable:e=>!!e.structure},bse=st(13421772),LKe="Gives every model a unique color based on its index.",OS={...Ia({type:"colors",colorList:"many-distinct"})};function LS(e,t){var n;let r,i;if(e.structure){const s=ac((null!==(n=sn.MaxIndex.get(e.structure.models[0]).value)&&void 0!==n?n:-1)+1,t);i=s.legend,r=a=>nt.is(a)?s.color(sn.Index.get(a.unit.model).value||0):Lt.isLocation(a)?s.color(sn.Index.get(a.aUnit.model).value||0):bse}else r=()=>bse;return{factory:LS,granularity:"instance",color:r,props:t,description:LKe,legend:i}}const VKe={name:"model-index",label:"Model Index",category:ni.Chain,factory:LS,getParams:function UKe(e){return C.clone(OS)},defaultValues:C.getDefaultValues(OS),isApplicable:e=>!!e.structure&&e.structure.elementCount>0},vse=st(13421772),zKe="Gives every structure a unique color based on its index.",US={...Ia({type:"colors",colorList:"many-distinct"})};function VS(e,t){var n;let r,i;if(e.structure){const s=ac((null!==(n=Ve.MaxIndex.get(e.structure).value)&&void 0!==n?n:-1)+1,t);i=s.legend,r=a=>nt.is(a)?s.color(Ve.Index.get(a.structure).value||0):Lt.isLocation(a)?s.color(Ve.Index.get(a.aStructure).value||0):vse}else r=()=>vse;return{factory:VS,granularity:"instance",color:r,props:t,description:zKe,legend:i}}const jKe={name:"structure-index",label:"Structure Index",category:ni.Chain,factory:VS,getParams:function GKe(e){return C.clone(US)},defaultValues:C.getDefaultValues(US),isApplicable:e=>!!e.structure&&e.structure.elementCount>0},L6="dark-2",_se=st(13421772),HKe="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.",U6={...Ia({type:"colors",colorList:L6})};function V6(e,t){let n,r;if(e.structure){const{units:i}=e.structure.root,o=ac(i.length,t);r=o.legend;const s=new Map;for(let a=0,c=i.length;ant.is(a)?s.get(a.unit.id):Lt.isLocation(a)?s.get(a.aUnit.id):_se}else n=()=>_se;return{factory:V6,granularity:"instance",color:n,props:t,description:HKe,legend:r}}const WKe={name:"unit-index",label:"Chain Instance",category:ni.Chain,factory:V6,getParams:function qKe(e){const t=C.clone(U6);return e.structure&&e.structure.root.units.length>Pc[L6].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params={...t.palette.defaultValue.params,list:{kind:"interpolate",colors:cp(L6).list}}),t},defaultValues:C.getDefaultValues(U6),isApplicable:e=>!!e.structure},xse={H:16777215,D:16777152,T:16777120,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215},Sse=st(16777215),z6={carbonColor:C.MappedStatic("chain-id",{"chain-id":C.Group(ES),"unit-index":C.Group(U6,{label:"Chain Instance"}),"entity-id":C.Group(RS),"entity-source":C.Group(FS),"operator-name":C.Group(k6),"model-index":C.Group(OS),"structure-index":C.Group(US),uniform:C.Group(yv),"element-symbol":C.EmptyGroup()},{description:"Use chain-id coloring for carbon atoms."}),saturation:C.Numeric(0,{min:-6,max:6,step:.1}),lightness:C.Numeric(.2,{min:-6,max:6,step:.1}),colors:C.MappedStatic("default",{default:C.EmptyGroup(),custom:C.Group(KD(xse))})};function G6(e,t){var n;const r=QI("default"===t.colors.name?xse:t.colors.params,t.saturation,t.lightness),i=null===(n=function KKe(e,t){switch(t.name){case"chain-id":return PS(e,t.params);case"unit-index":return V6(e,t.params);case"entity-id":return NS(e,t.params);case"entity-source":return BS(e,t.params);case"operator-name":return N6(e,t.params);case"model-index":return LS(e,t.params);case"structure-index":return VS(e,t.params);case"uniform":return f0(0,t.params);case"element-symbol":return;default:Rr()}}(e,t.carbonColor))||void 0===n?void 0:n.color;function o(c,u){return i&&"C"===c?i(u,!1):function XKe(e,t){const n=e[t];return void 0===n?Sse:n}(r,c)}return{factory:G6,granularity:"operator-name"===t.carbonColor.name||"unit-index"===t.carbonColor.name?"groupInstance":"group",preferSmoothing:!0,color:function s(c){if(nt.is(c)){if(Ee.isAtomic(c.unit)){const{type_symbol:u}=c.unit.model.atomicHierarchy.atoms;return o(u.value(c.element),c)}}else if(Lt.isLocation(c)&&Ee.isAtomic(c.aUnit)){const{type_symbol:u}=c.aUnit.model.atomicHierarchy.atoms;return o(u.value(c.aUnit.elements[c.aIndex]),c)}return Sse},props:t,description:"Assigns a color to every atom according to its chemical element.",legend:$h(Object.keys(r).map(c=>[c,r[c]]))}}const ZKe={name:"element-symbol",label:"Element Symbol",category:ni.Atom,factory:G6,getParams:function YKe(e){return C.clone(z6)},defaultValues:C.getDefaultValues(z6),isApplicable:e=>!!e.structure},Cse={water:3697840,ion:15729279,protein:12496596,RNA:16629894,DNA:12540695,PNA:4367514,saccharide:8374655},j6=st(16777113),QD={saturation:C.Numeric(0,{min:-6,max:6,step:.1}),lightness:C.Numeric(0,{min:-6,max:6,step:.1}),colors:C.MappedStatic("default",{default:C.EmptyGroup(),custom:C.Group(KD(Cse))})};function wse(e,t,n){switch(HB(t,n)){case 2:return e.water;case 3:return e.ion;case 5:return e.protein;case 6:return e.RNA;case 7:return e.DNA;case 8:return e.PNA;case 9:return e.saccharide}return j6}function JD(e,t){const n=QI("default"===t.colors.name?Cse:t.colors.params,t.saturation,t.lightness);return{factory:JD,granularity:"group",color:function r(i){return nt.is(i)?wse(n,i.unit,i.element):Lt.isLocation(i)?wse(n,i.aUnit,i.aUnit.elements[i.aIndex]):j6},props:t,description:"Assigns a color based on the molecule type of a residue.",legend:$h(Object.keys(n).map(i=>[i,n[i]]).concat([["Other/unknown",j6]]))}}const eZe={name:"molecule-type",label:"Molecule Type",category:ni.Residue,factory:JD,getParams:function JKe(e){return QD},defaultValues:C.getDefaultValues(QD),isApplicable:e=>!!e.structure},H6="dark-2",Ase=st(16448250),Ise={...Ia({type:"colors",colorList:H6})};function Tse(e){switch(e.kind){case 0:return Ze.chain.label_asym_id;case 1:case 2:return Ze.coarse.asym_id}}function Dse(e){const t=new Map;for(let n=0,r=e.unitSymmetryGroups.length;ns[u]});r=c.legend,n=u=>{let l;if(nt.is(u)){const d=Tse(u.unit);l=o.get(d(u))}else if(Lt.isLocation(u)){const d=Tse(u.aUnit);i.unit=u.aUnit,i.element=u.aUnit.elements[u.aIndex],l=o.get(d(i))}return void 0===l?Ase:c.color(l)}}else n=()=>Ase;return{factory:Ese,granularity:"group",color:n,props:t,description:"Gives every polymer chain a color based on its `asym_id` value.",legend:r}},getParams:function nZe(e){const t=C.clone(Ise);return e.structure&&Dse(e.structure.root).size>Pc[H6].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params={...t.palette.defaultValue.params,list:{kind:"interpolate",colors:cp(H6).list}}),t},defaultValues:C.getDefaultValues(Ise),isApplicable:e=>!!e.structure},q6="dark-2",Pse=st(13421772),Mse={...Ia({type:"colors",colorList:q6})};function Rse(e){let t=0;const{units:n}=e;for(let r=0,i=n.length;r0&&++t;return t}const sZe={name:"polymer-index",label:"Polymer Chain Instance",category:ni.Chain,factory:function kse(e,t){let n,r;if(e.structure){const i=ac(Rse(e.structure.root),t);r=i.legend;const{units:o}=e.structure.root,s=new Map;for(let a=0,c=0,u=o.length;a0&&(s.set(o[a].id,i.color(c)),++c);n=a=>{let c;return nt.is(a)?c=s.get(a.unit.id):Lt.isLocation(a)&&(c=s.get(a.aUnit.id)),void 0!==c?c:Pse}}else n=()=>Pse;return{factory:kse,granularity:"instance",color:n,props:t,description:"Gives every polymer chain instance a unique color based on the position (index) of the polymer in the list of polymers in the structure.",legend:r}},getParams:function oZe(e){const t=C.clone(Mse);return e.structure&&Rse(e.structure.root)>Pc[q6].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params={...t.palette.defaultValue.params,list:{kind:"interpolate",colors:cp(q6).list}}),t},defaultValues:C.getDefaultValues(Mse),isApplicable:e=>!!e.structure},Nse={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},W6=st(16711935),$6={saturation:C.Numeric(0,{min:-6,max:6,step:.1}),lightness:C.Numeric(1,{min:-6,max:6,step:.1}),colors:C.MappedStatic("default",{default:C.EmptyGroup(),custom:C.Group(KD(Nse))})};function Fse(e,t){return e.model.atomicHierarchy.atoms.label_comp_id.value(t)}function Bse(e,t){const n=e.coarseElements.seq_id_begin.value(t);if(n===e.coarseElements.seq_id_end.value(t))return e.model.sequence.byEntityKey[e.coarseElements.entityKey[t]].sequence.compId.value(n-1)}function eE(e,t){const n=e[t];return void 0===n?W6:n}function Y6(e,t){const n=QI("default"===t.colors.name?Nse:t.colors.params,t.saturation,t.lightness);return{factory:Y6,granularity:"group",preferSmoothing:!0,color:function r(i){if(nt.is(i)){if(Ee.isAtomic(i.unit)){const o=Fse(i.unit,i.element);return eE(n,o)}{const o=Bse(i.unit,i.element);if(o)return eE(n,o)}}else if(Lt.isLocation(i)){if(Ee.isAtomic(i.aUnit)){const o=Fse(i.aUnit,i.aUnit.elements[i.aIndex]);return eE(n,o)}{const o=Bse(i.aUnit,i.aUnit.elements[i.aIndex]);if(o)return eE(n,o)}}return W6},props:t,description:"Assigns a color to every residue according to its name.",legend:$h(Object.keys(n).map(i=>[i,n[i]]).concat([["Unknown",W6]]))}}const uZe={name:"residue-name",label:"Residue Name",category:ni.Residue,factory:Y6,getParams:function cZe(e){return $6},defaultValues:C.getDefaultValues($6),isApplicable:e=>!!e.structure},Ose={alphaHelix:16711808,threeTenHelix:10485888,piHelix:6291584,betaTurn:6324479,betaStrand:16762880,coil:16777215,bend:6740169,turn:45670,dna:11403518,rna:16580962,carbohydrate:10921722},X6=st(8421504),K6={saturation:C.Numeric(-1,{min:-6,max:6,step:.1}),lightness:C.Numeric(0,{min:-6,max:6,step:.1}),colors:C.MappedStatic("default",{default:C.EmptyGroup(),custom:C.Group(KD(Ose))})};function Lse(e,t,n,r){let i=cr.create(0);if(r&&Ee.isAtomic(t)){const o=r.get(t.invariantId);o&&(i=o.type[o.getIndex(t.residueIndex[n])])}if(cr.is(i,2))return cr.is(i,2048)?e.threeTenHelix:cr.is(i,32768)?e.piHelix:e.alphaHelix;if(cr.is(i,4))return e.betaStrand;if(cr.is(i,8))return e.bend;if(cr.is(i,16))return e.turn;{const o=HB(t,n);if(7===o)return e.dna;if(6===o)return e.rna;if(9===o)return e.carbohydrate;if(5===o)return e.coil}return X6}function Z6(e,t){const n=e.structure&&Xu.get(e.structure),r=n?Pg(n.id,n.version):-1,i=QI("default"===t.colors.name?Ose:t.colors.params,t.saturation,t.lightness);return{factory:Z6,granularity:"group",preferSmoothing:!0,color:function o(s){return nt.is(s)?Lse(i,s.unit,s.element,n?.value):Lt.isLocation(s)?Lse(i,s.aUnit,s.aUnit.elements[s.aIndex],n?.value):X6},props:t,contextHash:r,description:"Assigns a color based on the type of secondary structure and basic molecule type.",legend:$h(Object.keys(i).map(s=>[s,i[s]]).concat([["Other",X6]]))}}const fZe={name:"secondary-structure",label:"Secondary Structure",category:ni.Residue,factory:Z6,getParams:function dZe(e){return K6},defaultValues:C.getDefaultValues(K6),isApplicable:e=>!!e.structure,ensureCustomProperties:{attach:(e,t)=>t.structure?Xu.attach(e,t.structure,void 0,!0):Promise.resolve(),detach:e=>e.structure&&Xu.ref(e.structure,!1)}},pZe=st(13421772),Use={list:C.ColorList("turbo",{presetKind:"scale"})};function Vse(e,t){const{model:n}=e;switch(e.kind){case 0:return n.atomicHierarchy.residues.label_seq_id.value(n.atomicHierarchy.residueAtomSegments.index[t]);case 1:return Math.round((n.coarseHierarchy.spheres.seq_id_begin.value(t)+n.coarseHierarchy.spheres.seq_id_end.value(t))/2);case 2:return Math.round((n.coarseHierarchy.gaussians.seq_id_begin.value(t)+n.coarseHierarchy.gaussians.seq_id_end.value(t))/2)}}function zse(e,t){const{model:n}=e;let r="";switch(e.kind){case 0:r=n.atomicHierarchy.chains.label_entity_id.value(n.atomicHierarchy.chainAtomSegments.index[t]);break;case 1:r=n.coarseHierarchy.spheres.entity_id.value(t);break;case 2:r=n.coarseHierarchy.gaussians.entity_id.value(t)}if(""===r)return 0;const i=n.entities.getEntityIndex(r);if(-1===i)return 0;const o=n.sequence.byEntityKey[i];return void 0===o?0:o.sequence.length}const gZe={name:"sequence-id",label:"Sequence Id",category:ni.Residue,factory:function Gse(e,t){const n=Gu.create({listOrName:t.list.colors,minLabel:"Start",maxLabel:"End"});return{factory:Gse,granularity:"group",preferSmoothing:!0,color:i=>{if(nt.is(i)){const{unit:o,element:s}=i,a=Vse(o,s);if(a>0){const c=zse(o,s);if(c)return n.setDomain(0,c-1),n.color(a)}}else if(Lt.isLocation(i)){const{aUnit:o,aIndex:s}=i,a=Vse(o,o.elements[s]);if(a>0){const c=zse(o,o.elements[s]);if(c)return n.setDomain(0,c-1),n.color(a)}}return pZe},props:t,description:"Gives every polymer residue a color based on its `seq_id` value.",legend:n?n.legend:void 0}},getParams:function mZe(e){return Use},defaultValues:C.getDefaultValues(Use),isApplicable:e=>!!e.structure},yZe=st(16777113),jse={domain:C.Interval([0,100]),list:C.ColorList("red-white-blue",{presetKind:"scale"})};function Hse(e,t){return Ee.isAtomic(e)?e.model.atomicConformation.B_iso_or_equiv.value(t):Ee.isSpheres(e)?e.model.coarseConformation.spheres.rmsf[t]:0}const _Ze={name:"uncertainty",label:"Uncertainty/Disorder",category:ni.Atom,factory:function qse(e,t){const n=Gu.create({reverse:!0,domain:t.domain,listOrName:t.list.colors});return{factory:qse,granularity:"group",preferSmoothing:!0,color:function r(i){return nt.is(i)?n.color(Hse(i.unit,i.element)):Lt.isLocation(i)?n.color(Hse(i.aUnit,i.aUnit.elements[i.aIndex])):yZe},props:t,description:"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.",legend:n?n.legend:void 0}},getParams:function vZe(e){return jse},defaultValues:C.getDefaultValues(jse),isApplicable:e=>!!e.structure&&e.structure.models.some(t=>t.atomicConformation.B_iso_or_equiv.isDefined||t.coarseHierarchy.isDefined)},xZe=st(15658734),Wse={style:C.MappedStatic("entity-id",{uniform:C.Group(yv),"chain-id":C.Group(ES),"entity-id":C.Group(RS),"entity-source":C.Group(FS),"molecule-type":C.Group(QD),"model-index":C.Group(OS),"structure-index":C.Group(US)}),carbonLightness:C.Numeric(.8,{min:-6,max:6,step:.1})},AZe={name:"illustrative",label:"Illustrative",category:ni.Misc,factory:function $se(e,t){const{color:n,legend:r}=function wZe(e,t){switch(t.name){case"uniform":return f0(0,t.params);case"chain-id":return PS(e,t.params);case"entity-id":return NS(e,t.params);case"entity-source":return BS(e,t.params);case"molecule-type":return JD(0,t.params);case"model-index":return LS(e,t.params);case"structure-index":return VS(e,t.params);default:Rr()}}(e,t.style);function i(s,a){const c=n(s,!1);return"C"===a?st.lighten(c,t.carbonLightness):c}return{factory:$se,granularity:"group",preferSmoothing:!0,color:function o(s){if(nt.is(s)&&Ee.isAtomic(s.unit)){const a=s.unit.model.atomicHierarchy.atoms.type_symbol.value(s.element);return i(s,a)}if(Lt.isLocation(s)&&Ee.isAtomic(s.aUnit)){const c=s.aUnit.model.atomicHierarchy.atoms.type_symbol.value(s.aUnit.elements[s.aIndex]);return i(s,c)}return xZe},props:t,description:"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).",legend:r}},getParams:function CZe(e){return C.clone(Wse)},defaultValues:C.getDefaultValues(Wse),isApplicable:e=>!!e.structure},Yse={list:C.ColorList("red-yellow-green",{presetKind:"scale"}),scale:C.Select("DGwif",[["DGwif","DG water-membrane"],["DGwoct","DG water-octanol"],["Oct-IF","DG difference"]])},DZe={DGwif:0,DGwoct:1,"Oct-IF":2};function Xse(e,t){return e.model.atomicHierarchy.atoms.label_comp_id.value(t)}function Kse(e,t){const n=e.coarseElements.seq_id_begin.value(t);if(n===e.coarseElements.seq_id_end.value(t))return e.model.sequence.byEntityKey[e.coarseElements.entityKey[t]].sequence.compId.value(n-1)}const PZe={name:"hydrophobicity",label:"Hydrophobicity",category:ni.Residue,factory:function Zse(e,t){const n=DZe[t.scale];let r=1/0,i=-1/0;for(const a in MB){const c=MB[a][n];r=Math.min(r,c),i=Math.max(i,c)}const o=Gu.create({listOrName:t.list.colors,domain:[i,r],minLabel:"Hydrophilic",maxLabel:"Hydrophobic"});return{factory:Zse,granularity:"group",preferSmoothing:!0,color:function s(a){let c;return nt.is(a)?c=Ee.isAtomic(a.unit)?Xse(a.unit,a.element):Kse(a.unit,a.element):Lt.isLocation(a)&&(c=Ee.isAtomic(a.aUnit)?Xse(a.aUnit,a.aUnit.elements[a.aIndex]):Kse(a.aUnit,a.aUnit.elements[a.aIndex])),o.color(c?function EZe(e,t){const n=MB[e];return void 0===n?0:n[t]}(c,n):0)},props:t,description:'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).',legend:o?o.legend:void 0}},getParams:function TZe(e){return Yse},defaultValues:C.getDefaultValues(Yse),isApplicable:e=>!!e.structure},Qse=st(13421772),Jse={...Ia({type:"colors",colorList:"purples"})},kZe={name:"trajectory-index",label:"Trajectory Index",category:ni.Chain,factory:function eae(e,t){var n,r;let i,o;if(e.structure){const{models:s}=e.structure.root;let a=0;for(const l of s)a=Math.max(a,(null===(n=sn.TrajectoryInfo.get(l))||void 0===n?void 0:n.size)||0);const c=ac(a,t);o=c.legend;const u=new Map;for(let l=0,d=s.length;lnt.is(l)?u.get(sn.TrajectoryInfo.get(l.unit.model).index):Lt.isLocation(l)?u.get(sn.TrajectoryInfo.get(l.aUnit.model).index):Qse}else i=()=>Qse;return{factory:eae,granularity:"instance",color:i,props:t,description:"Gives every model (frame) a unique color based on the index in its trajectory.",legend:o}},getParams:function RZe(e){return C.clone(Jse)},defaultValues:C.getDefaultValues(Jse),isApplicable:e=>!!e.structure&&e.structure.elementCount>0&&sn.TrajectoryInfo.get(e.structure.models[0]).size>1},NZe=st(13421772),tae={domain:C.Interval([0,1]),list:C.ColorList("purples",{presetKind:"scale"})};function nae(e,t){return Ee.isAtomic(e)?e.model.atomicConformation.occupancy.value(t):0}const OZe={name:"occupancy",label:"Occupancy",category:ni.Atom,factory:function rae(e,t){const n=Gu.create({reverse:!1,domain:t.domain,listOrName:t.list.colors});return{factory:rae,granularity:"group",preferSmoothing:!0,color:function r(i){return nt.is(i)?n.color(nae(i.unit,i.element)):Lt.isLocation(i)?n.color(nae(i.aUnit,i.aUnit.elements[i.aIndex])):NZe},props:t,description:"Assigns a color based on the occupancy of an atom.",legend:n?n.legend:void 0}},getParams:function BZe(e){return tae},defaultValues:C.getDefaultValues(tae),isApplicable:e=>!!e.structure&&e.structure.models.some(t=>t.atomicConformation.occupancy.isDefined)},Q6="dark-2",iae=st(13421772),oae={...Ia({type:"colors",colorList:Q6})},zS=1e4;function J6(e){return e.map(t=>`${t+zS}`.padStart(5,"0")).join("")}function e8(e){const t=function zFe(e,t){return Math.abs(e)t+5).join("")}function sae(e){const t=new Map,n=new Set;for(let s=0,a=e.units.length;st.set(s,t.size)),{min:e8(r[0]),max:e8(r[r.length-1]),map:t}}const VZe={name:"operator-hkl",label:"Operator HKL",category:ni.Symmetry,factory:function aae(e,t){let n,r;if(e.structure){const{min:i,max:o,map:s}=sae(e.structure.root),a=[];s.forEach((l,d)=>{const f=l%s.size,p=t8(e8(d));void 0===a[f]?a[f]=p:a[f]+=`, ${p}`});const c={minLabel:t8(i),maxLabel:t8(o),valueLabel:l=>a[l]},u=ac(s.size,t,c);r=u.legend,n=l=>{let d;if(nt.is(l)){const f=J6(l.unit.conformation.operator.hkl);d=s.get(f)}else if(Lt.isLocation(l)){const f=J6(l.aUnit.conformation.operator.hkl);d=s.get(f)}return void 0===d?iae:u.color(d)}}else n=()=>iae;return{factory:aae,granularity:"instance",color:n,props:t,description:"Assigns a color based on the operator HKL value of a transformed chain.",legend:r}},getParams:function UZe(e){const t=C.clone(oae);return e.structure&&sae(e.structure.root).map.size>Pc[Q6].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params={...t.palette.defaultValue.params,list:{kind:"interpolate",colors:cp(Q6).list}}),t},defaultValues:C.getDefaultValues(oae),isApplicable:e=>!!e.structure},n8=st(16777113),cae={domain:C.Interval([-1,1]),list:C.ColorList("red-white-blue",{presetKind:"scale"})};function uae(e,t){var n;return null===(n=Pv.Provider.get(e.model))||void 0===n?void 0:n.data.value(t)}const jZe={name:"partial-charge",label:"Partial Charge",category:ni.Atom,factory:function lae(e,t){const n=Gu.create({domain:t.domain,listOrName:t.list.colors});return{factory:lae,granularity:"group",preferSmoothing:!0,color:function r(i){if(nt.is(i)){const o=uae(i.unit,i.element);return void 0!==o?n.color(o):n8}if(Lt.isLocation(i)){const o=uae(i.aUnit,i.aUnit.elements[i.aIndex]);return void 0!==o?n.color(o):n8}return n8},props:t,description:"Assigns a color based on the partial charge of an atom.",legend:n?n.legend:void 0}},getParams:function GZe(e){return cae},defaultValues:C.getDefaultValues(cae),isApplicable:e=>!!e.structure&&e.structure.models.some(t=>void 0!==Pv.Provider.get(t))},dae=st(16448250),fae={...Ia({type:"colors",colorList:"many-distinct"})},YZe={name:"atom-id",label:"Atom Id",category:ni.Atom,factory:function pae(e,t){let n,r;if(e.structure){const i=nt.create(e.structure.root),o=function $Ze(e){const t=new Map;for(const n of e.models){const{label_atom_id:r}=n.atomicHierarchy.atoms;for(let i=0,o=r.rowCount;is[u]});r=c.legend,n=u=>{let l;if(nt.is(u)){const d=Ze.atom.label_atom_id(u);l=o.get(d)}else if(Lt.isLocation(u)){i.unit=u.aUnit,i.element=u.aUnit.elements[u.aIndex];const d=Ze.atom.label_atom_id(i);l=o.get(d)}return void 0===l?dae:c.color(l)}}else n=()=>dae;return{factory:pae,granularity:"group",preferSmoothing:!0,color:n,props:t,description:"Gives every atom a color based on its `label_atom_id` value.",legend:r}},getParams:function WZe(e){return C.clone(fae)},defaultValues:C.getDefaultValues(fae),isApplicable:e=>!!e.structure},hae={colorList:C.ColorList({kind:"interpolate",colors:[[xn.white,0],[xn.red,.25],[xn.white,.5],[xn.blue,.75],[xn.white,1]]},{offsets:!0,isEssential:!0})},ZZe={name:"volume-value",label:"Volume Value",category:ni.Misc,factory:function mae(e,t){const n=Gu.create({domain:[0,1],listOrName:t.colorList.colors}),r=[];for(let o=0;o<256;++o)r[o]=n.color(o/255);return{factory:mae,granularity:"direct",props:t,description:"Assign color based on the given value of a volume cell.",legend:n.legend,palette:{colors:r,filter:"linear"}}},getParams:function KZe(e){return hae},defaultValues:C.getDefaultValues(hae),isApplicable:e=>!!e.volume&&!et.Segmentation.get(e.volume)},gae=st(13421772),yae={...Ia({type:"colors",colorList:"many-distinct"})},eQe={name:"volume-segment",label:"Volume Segment",category:ni.Misc,factory:function bae(e,t){let n,r;const i=e.volume&&et.Segmentation.get(e.volume);if(i){const o=i.segments.size,s=Array.from(i.segments.keys()),a=ac(o,t);r=a.legend,n=c=>et.Segment.isLocation(c)?a.color(s.indexOf(c.segment)):gae}else n=()=>gae;return{factory:bae,granularity:"instance",color:n,props:t,description:"Gives every volume segment a unique color.",legend:r}},getParams:function JZe(e){return C.clone(yae)},defaultValues:C.getDefaultValues(yae),isApplicable:e=>!!e.volume&&!!et.Segmentation.get(e.volume)},vae={volume:C.ValueRef(e=>e.state.data.selectQ(n=>n.root.subtree().filter(r=>{var i;return et.is(null===(i=r.obj)||void 0===i?void 0:i.data)})).map(n=>{var r,i;return[n.transform.ref,null!==(i=null===(r=n.obj)||void 0===r?void 0:r.label)&&void 0!==i?i:""]}),(e,t)=>t(e)),coloring:C.MappedStatic("absolute-value",{"absolute-value":C.Group({domain:C.MappedStatic("auto",{custom:C.Interval([-1,1]),auto:C.Group({symmetric:C.Boolean(!1,{description:"If true the automatic range is determined as [-|max|, |max|]."})})}),list:C.ColorList("red-white-blue",{presetKind:"scale"})}),"relative-value":C.Group({domain:C.MappedStatic("auto",{custom:C.Interval([-1,1]),auto:C.Group({symmetric:C.Boolean(!1,{description:"If true the automatic range is determined as [-|max|, |max|]."})})}),list:C.ColorList("red-white-blue",{presetKind:"scale"})})}),defaultColor:C.Color(st(13421772))},nQe={name:"external-volume",label:"External Volume",category:ni.Misc,factory:function _ae(e,t){let n,r;try{n=t.volume.getValue()}catch{}if(n){const i=t.coloring.params,{stats:o}=n.grid,s="custom"===i.domain.name?i.domain.params:[o.min,o.max],a="relative-value"===t.coloring.name;if("auto"===i.domain.name&&a&&(s[0]=(s[0]-o.mean)/o.sigma,s[1]=(s[1]-o.mean)/o.sigma),"auto"===t.coloring.params.domain.name&&t.coloring.params.domain.params.symmetric){const y=Math.max(Math.abs(s[0]),Math.abs(s[1]));s[0]=-y,s[1]=y}const c=Gu.create({domain:s,listOrName:i.list.colors}),u=Ko.getGridToCartesianTransform(n.grid);le.invert(u,u);const l=v(),{dimensions:d,get:f}=n.grid.cells.space,p=n.grid.cells.data,[m,h,g]=d;r=y=>{if(!function o7e(e){return!!e&&"position-location"===e.kind}(y))return t.defaultColor;v.copy(l,y.position),v.transformMat4(l,l,u);const b=Math.floor(l[0]),x=Math.floor(l[1]),_=Math.floor(l[2]);if(b<0||b>=m||x<0||x>=h||_<0||_>=g)return t.defaultColor;const S=l[0]-b,A=l[1]-x,E=l[2]-_,w=Math.min(b+1,m-1),D=Math.min(x+1,h-1),I=Math.min(_+1,g-1);let R=f(p,b,x,_),T=f(p,w,x,_),M=f(p,b,D,_),N=f(p,w,D,_);const V=ci(ci(R,T,S),ci(M,N,S),A);R=f(p,b,x,I),T=f(p,w,x,I),M=f(p,b,D,I),N=f(p,w,D,I);const F=ci(ci(R,T,S),ci(M,N,S),A);let G=ci(V,F,E);return a&&(G=(G-o.mean)/o.sigma),c.color(G)}}else r=()=>t.defaultColor;return{factory:_ae,granularity:"vertex",preferSmoothing:!0,color:r,props:t,description:"Assigns a color based volume value at a given vertex."}},getParams:()=>vae,defaultValues:C.getDefaultValues(vae),isApplicable:e=>!0},xae={mainchain:C.MappedStatic("molecule-type",{uniform:C.Group(yv),"chain-id":C.Group(ES),"entity-id":C.Group(RS),"entity-source":C.Group(FS),"molecule-type":C.Group(QD),"model-index":C.Group(OS),"structure-index":C.Group(US),"secondary-structure":C.Group(K6)}),sidechain:C.MappedStatic("residue-name",{uniform:C.Group(yv),"residue-name":C.Group($6),"element-symbol":C.Group(z6)})},aQe={name:"cartoon",label:"Cartoon",category:ni.Misc,factory:function Sae(e,t){var n,r;const i=function oQe(e,t){switch(t.name){case"uniform":return f0(0,t.params);case"chain-id":return PS(e,t.params);case"entity-id":return NS(e,t.params);case"entity-source":return BS(e,t.params);case"molecule-type":return JD(0,t.params);case"model-index":return LS(e,t.params);case"structure-index":return VS(e,t.params);case"secondary-structure":return Z6(e,t.params);default:Rr()}}(e,t.mainchain),o=function sQe(e,t){switch(t.name){case"uniform":return f0(0,t.params);case"residue-name":return Y6(0,t.params);case"element-symbol":return G6(e,t.params);default:Rr()}}(e,t.sidechain);let a=i.legend;return"table-legend"===(null===(n=i.legend)||void 0===n?void 0:n.kind)&&"table-legend"===(null===(r=o.legend)||void 0===r?void 0:r.kind)&&(a={kind:"table-legend",table:[...i.legend.table,...o.legend.table]}),{factory:Sae,granularity:"group",preferSmoothing:!1,color:function s(c,u){return u?i.color(c,!1):o.color(c,!1)},props:t,description:"Uses separate themes for coloring mainchain and sidechain visuals.",legend:a}},getParams:function iQe(e){return C.clone(xae)},defaultValues:C.getDefaultValues(xae),isApplicable:e=>!!e.structure};var Lc;!function(e){e.Category=ni,e.PaletteScale=16777215,e.EmptyFactory=()=>e.Empty;const t=st(13421772);e.Empty={factory:e.EmptyFactory,granularity:"uniform",color:()=>t,props:{}},e.areEqual=function n(i,o){return i.contextHash===o.contextHash&&i.factory===o.factory&&Yd(i.props,o.props)},e.EmptyProvider={name:"",label:"",category:"",factory:e.EmptyFactory,getParams:()=>({}),defaultValues:{},isApplicable:()=>!0},e.createRegistry=function r(){return new Eae(e.BuiltIn,e.EmptyProvider)},e.BuiltIn={"atom-id":YZe,"carbohydrate-symbol":dKe,cartoon:aQe,"chain-id":use,"element-index":CKe,"element-symbol":ZKe,"entity-id":RKe,"entity-source":OKe,hydrophobicity:PZe,illustrative:AZe,"model-index":VKe,"molecule-type":eZe,occupancy:OZe,"operator-hkl":VZe,"operator-name":F6,"partial-charge":jZe,"polymer-id":rZe,"polymer-index":sZe,"residue-name":uZe,"secondary-structure":fZe,"sequence-id":gZe,"shape-group":pqe,"structure-index":jKe,"trajectory-index":kZe,uncertainty:_Ze,"unit-index":WKe,uniform:Oje,"volume-segment":eQe,"volume-value":ZZe,"external-volume":nQe}}(Lc||(Lc={}));const Cae={scale:C.Numeric(1,{min:.1,max:5,step:.1})};function r8(e,t){return Ee.isAtomic(e)?v2(e.model.atomicHierarchy.atoms.type_symbol.value(t)):Ee.isSpheres(e)?e.model.coarseConformation.spheres.radius[t]:0}const dQe={name:"physical",label:"Physical",category:"",factory:function wae(e,t){const n=void 0===t.scale?1:t.scale;return{factory:wae,granularity:"group",size:function r(i){let o;return o=nt.is(i)?n*r8(i.unit,i.element):Lt.isLocation(i)?n*Math.min(r8(i.aUnit,i.aUnit.elements[i.aIndex]),r8(i.bUnit,i.bUnit.elements[i.bIndex])):1*n,o},props:t,description:"Assigns a physical size, i.e. vdW radius for atoms or given radius for coarse spheres."}},getParams:function lQe(e){return Cae},defaultValues:C.getDefaultValues(Cae),isApplicable:e=>!!e.structure},Aae={bfactorFactor:C.Numeric(.1,{min:0,max:1,step:.01}),rmsfFactor:C.Numeric(.05,{min:0,max:1,step:.01}),baseSize:C.Numeric(.2,{min:0,max:2,step:.1})};function Iae(e,t,n){return Ee.isAtomic(e)?e.model.atomicConformation.B_iso_or_equiv.value(t)*n.bfactorFactor:Ee.isSpheres(e)?e.model.coarseConformation.spheres.rmsf[t]*n.rmsfFactor:0}const hQe={name:"uncertainty",label:"Uncertainty/Disorder",category:"",factory:function Tae(e,t){return{factory:Tae,granularity:"group",size:function n(r){let i=t.baseSize;return nt.is(r)?i+=Iae(r.unit,r.element,t):Lt.isLocation(r)&&(i+=Iae(r.aUnit,r.aUnit.elements[r.aIndex],t)),i},props:t,description:"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."}},getParams:function pQe(e){return Aae},defaultValues:C.getDefaultValues(Aae),isApplicable:e=>!!e.structure&&e.structure.models.some(t=>t.atomicConformation.B_iso_or_equiv.isDefined||t.coarseHierarchy.isDefined)};var Qo,Fo;function Dae(e){return e.map(t=>[t.name,t.provider.label,t.provider.category])}!function(e){e.EmptyFactory=()=>e.Empty,e.Empty={factory:e.EmptyFactory,granularity:"uniform",size:()=>1,props:{}},e.areEqual=function t(r,i){return r.contextHash===i.contextHash&&r.factory===i.factory&&Yd(r.props,i.props)},e.EmptyProvider={name:"",label:"",category:"",factory:e.EmptyFactory,getParams:()=>({}),defaultValues:{},isApplicable:()=>!0},e.createRegistry=function n(){return new Eae(e.BuiltIn,e.EmptyProvider)},e.BuiltIn={physical:dQe,"shape-group":uqe,uncertainty:hQe,uniform:Vje}}(Qo||(Qo={})),function(e){function n(){return{color:Lc.Empty,size:Qo.Empty}}function i(){return(i=ie(function*(s,a,c,u){var l,d;yield null===(l=a.colorThemeRegistry.get(u.colorTheme.name).ensureCustomProperties)||void 0===l?void 0:l.attach(s,c),yield null===(d=a.sizeThemeRegistry.get(u.sizeTheme.name).ensureCustomProperties)||void 0===d?void 0:d.attach(s,c)})).apply(this,arguments)}e.create=function t(s,a,c,u){u=u||n();const l=c.colorTheme,d=c.sizeTheme;return u.color=s.colorThemeRegistry.create(l.name,a,l.params),u.size=s.sizeThemeRegistry.create(d.name,a,d.params),u},e.createEmpty=n,e.ensureDependencies=function r(s,a,c,u){return i.apply(this,arguments)},e.releaseDependencies=function o(s,a,c){var u,l;null===(u=s.colorThemeRegistry.get(c.colorTheme.name).ensureCustomProperties)||void 0===u||u.detach(a),null===(l=s.sizeThemeRegistry.get(c.sizeTheme.name).ensureCustomProperties)||void 0===l||l.detach(a)}}(Fo||(Fo={}));class Eae{get default(){return this._list[0]}get list(){return this._list}get types(){return Dae(this._list)}constructor(t,n){this.emptyProvider=n,this._list=[],this._map=new Map,this._name=new Map,$a(t,(r,i)=>{if(r.name!==i)throw new Error(`Fix build in themes to have matching names. ${r.name} ${i}`);this.add(r)})}sort(){this._list.sort((t,n)=>t.provider.category===n.provider.category?t.provider.labeln.provider.label?1:0:t.provider.categoryr.name===t.name),1);const n=this._map.get(t.name);n&&(this._map.delete(t.name),this._name.delete(n))}has(t){return this._map.has(t.name)}get(t){return this._map.get(t)||this.emptyProvider}getName(t){if(!this._name.has(t))throw new Error(`'${t.label}' is not a registered theme provider.`);return this._name.get(t)}create(t,n,r={}){const i=this.get(t);return i.factory(n,{...C.getDefaultValues(i.getParams(n)),...r})}getApplicableList(t){return this._list.filter(n=>n.provider.isApplicable(t))}getApplicableTypes(t){return Dae(this.getApplicableList(t))}clear(){this._list.length=0,this._map.clear(),this._name.clear()}}var Us,Bt=function(e){return e[e.None=0]="None",e[e.Highlight=1]="Highlight",e[e.RemoveHighlight=2]="RemoveHighlight",e[e.Select=4]="Select",e[e.Deselect=8]="Deselect",e[e.Toggle=16]="Toggle",e[e.Clear=32]="Clear",e}(Bt||{});function i8(e,t,n){switch(n){case Bt.Highlight:e[t]|=1;break;case Bt.RemoveHighlight:e[t]&=-2;break;case Bt.Select:e[t]|=2;break;case Bt.Deselect:e[t]&=-3;break;case Bt.Toggle:e[t]^=2;break;case Bt.Clear:e[t]=0}}function o8(e,t,n){if(n===Bt.None)return!1;if(Ce.is(t)){const r=Ce.start(t),i=Ce.end(t),o=r+3>>2,s=o+(i-4*o>>2);if(s<=o){for(let f=r;f>2),c=r,u=Math.min(4*o,i),l=Math.max(r,4*s),d=i;switch(n){case Bt.Highlight:for(let f=o;fa(y)).filter(y=>!!y);t.reset();for(const y of g)t.includePositionRadius(y.center,y.radius);t.finishedIncludeStep();for(const y of g)t.radiusPositionRadius(y.center,y.radius);return t.getSphere()},e.areEqual=function r(h,g){return!!(Uc(h)&&Uc(g)||Ta(h)&&Ta(g))||(GS(h)&&GS(g)?function bQe(e,t){if(!Hx(e.data,t.data)||e.tag!==t.tag||e.elements.length!==t.elements.length)return!1;for(let n=0,r=e.elements.length;nh,residue:h=>De.is(h)?De.extendToWholeResidues(h,!0):h,chain:h=>De.is(h)?De.extendToWholeChains(h):h,entity:h=>De.is(h)?De.extendToWholeEntities(h):h,model:h=>De.is(h)?De.extendToWholeModels(h):h,operator:h=>De.is(h)?De.extendToWholeOperators(h):h,structure:h=>De.is(h)?Ve.toStructureElementLoci(h.structure):ra.isLoci(h)?qn.Loci(h.shape):et.Cell.isLoci(h)?et.Loci(h.volume):h,elementInstances:h=>De.is(h)?De.extendToAllInstances(h):h,residueInstances:h=>De.is(h)?De.extendToAllInstances(De.extendToWholeResidues(h,!0)):h,chainInstances:h=>De.is(h)?De.extendToAllInstances(De.extendToWholeChains(h)):h};function p(h,g){return d[g](h)}e.GranularityOptions=C.objectToOptions(d,h=>{switch(h){case"element":return"Atom/Coarse Element";case"elementInstances":return["Atom/Coarse Element Instances","With Symmetry"];case"structure":return"Structure/Shape";default:return h.indexOf("Instances")?[zu(h),"With Symmetry"]:zu(h)}}),e.simpleGranularity=function f(h){return h.replace("Instances","")},e.applyGranularity=p,e.normalize=function m(h,g,y=!1){return("element"!==g||y)&&Lt.isLoci(h)&&(h=Lt.toStructureElementLoci(h)),Ve.isLoci(h)&&(h=Ve.toStructureElementLoci(h.structure)),De.is(h)&&(h=De.remap(h,h.structure.root)),g&&(h=p(h,g)),h}}(pn||(pn={})),function(e){function n(u){return 0===u.layers.length}e.Empty={kind:"empty-loci",layers:[]},e.areEqual=function t(u,l){if(0===u.layers.length&&0===l.layers.length)return!0;if(u.layers.length!==l.layers.length)return!1;for(let d=0,f=u.layers.length;d{const g=-1===h,y=g?st(0):h;p.push({loci:m,color:y,clear:g})}),{kind:"element-loci",layers:p}}return u},e.filter=function o(u,l){if(n(u))return u;if("element-loci"===u.kind){const{structure:d}=u.layers[0].loci,f=[];for(const p of u.layers){let{loci:m,color:h,clear:g}=p;const y=De.remap(m,l);m=De.remap(y,d),De.isEmpty(m)||f.push({loci:m,color:h,clear:g})}return{kind:"element-loci",layers:f}}return u},e.ofScript=function s(u,l){const d=[];for(let f=0,p=u.length;f{p.push({loci:m,value:h})}),{kind:"element-loci",layers:p}}return u},e.filter=function o(u,l){if(n(u))return u;if("element-loci"===u.kind){const{structure:d}=u.layers[0].loci,f=[];for(const p of u.layers){let{loci:m,value:h}=p;const g=De.remap(m,l);m=De.remap(g,d),De.isEmpty(m)||f.push({loci:m,value:h})}return{kind:"element-loci",layers:f}}return u},e.ofScript=function s(u,l){const d=[];for(let f=0,p=u.length;fn.lowestElementCount?"lowest":r>n.lowerElementCount?"lower":r>n.lowElementCount?"low":r>n.mediumElementCount?"medium":r>n.highElementCount?"high":"higher"}function s8(e,t){let n=Ds(e.quality,"auto"),r=Ds(e.detail,1),i=Ds(e.radialSegments,12),o=Ds(e.linearSegments,8),s=Ds(e.resolution,2),a=Ds(e.probePositions,12),c=Ds(e.doubleSided,!0),u=0;if("auto"===n)if(t instanceof Ve)n=Pae(t.root),u=function xQe(e){if(1===e.root.models.length){const t=no.Provider.get(e.root.model);if(t&&"P 1"===t.spacegroup.name&&!ma.isZero(t.spacegroup.cell))return t.spacegroup.cell.volume}return St.volume(e.root.boundary.box)}(t);else if(et.is(t)){const[l,d,f]=t.grid.cells.space.dimensions;u=l*d*f,n=u<1e7?"medium":"low"}switch(n){case"highest":r=3,i=36,o=18,s=.1,a=72,c=!0;break;case"higher":r=3,i=28,o=14,s=.3,a=48,c=!0;break;case"high":r=2,i=20,o=10,s=.5,a=36,c=!0;break;case"medium":r=1,i=12,o=8,s=.8,a=24,c=!0;break;case"low":r=0,i=8,o=3,s=1.3,a=24,c=!1;break;case"lower":r=0,i=4,o=2,s=3,a=12,c=!1;break;case"lowest":r=0,i=2,o=1,s=8,a=12,c=!1}return s=Math.max(s,u/5e8),s=Math.min(s,20),"off"===e.transparentBackfaces&&(void 0!==e.alpha&&e.alpha<1||e.xrayShaded)&&(c=!1),{detail:r,radialSegments:i,linearSegments:o,resolution:s,probePositions:a,doubleSided:c}}const rE=v.set,Mae=v.normalize,Rae=v.sub,kae=v.addScalar,iE=v.scale,Nae=v.toArray;function oE(e,t,n,r){let i=!1;if(et.isLoci(e)){if(!et.areEquivalent(e.volume,t))return!1;r(Ce.ofLength(t.grid.cells.data.length))&&(i=!0)}else if(et.Isosurface.isLoci(e)){if(!et.areEquivalent(e.volume,t))return!1;if(n?.isoValue){if(!et.IsoValue.areSame(e.isoValue,n.isoValue,t.grid.stats))return!1;r(Ce.ofLength(t.grid.cells.data.length))&&(i=!0)}else{const{stats:o,cells:{data:s}}=t.grid,a=o.sigma,c=et.IsoValue.toAbsolute(e.isoValue,o).absoluteValue;for(let u=0,l=s.length;u{r(Ce.ofSingleton(o))&&(i=!0)})}else if(et.Segment.isLoci(e)){if(!et.areEquivalent(e.volume,t))return!1;if(n?.segments){if(!je.areIntersecting(e.segments,n.segments))return!1;r(Ce.ofLength(t.grid.cells.data.length))&&(i=!0)}else{const o=et.Segmentation.get(t);if(o){const s=new Set;for(let u=0,l=e.segments.length;u2)continue;const ge=2-Y,Se=N(ne,we,We);for(let Re=0;Reu)throw new Error("outputStride + itemOffset must NOT be larger than colorStride");const f=e.colorType.endsWith("Instance"),p=f?e.instanceCount:1,m=Po(Math.max(1,p*t),d,Uint8Array),{array:h}=m,[g,y]=o,b=s[0],x=v.fromArray(v(),a,0),_=a[3];function S(I,R,T){const M=Math.floor(T*g%b/g),N=Math.floor(T*g/b);return u*(N*y*b+R*b+(M*g+I))}const A=v(),E=v(),w=v(),D=v();for(let I=0;Is.drawCount.ref.value||i!==s.stride.ref.value)&&k.update(s.aSample,Bae(a,i)),k.updateIfChanged(s.drawCount,a),k.updateIfChanged(s.instanceCount,t.instanceCount),k.updateIfChanged(s.stride,i),k.updateIfChanged(s.uGroupCount,t.groupCount),k.update(s.aTransform,t.transformBuffer),k.update(s.aInstance,t.instanceBuffer),k.update(s.uGeoTexDim,Me.set(s.uGeoTexDim.ref.value,t.positionTexture.getWidth(),t.positionTexture.getHeight())),k.update(s.tPosition,t.positionTexture),k.update(s.tGroup,t.groupTexture),k.update(s.uColorTexDim,Me.set(s.uColorTexDim.ref.value,t.colorData.getWidth(),t.colorData.getHeight())),k.update(s.tColor,t.colorData),k.updateIfChanged(s.dColorType,t.colorType),k.updateIfChanged(s.uCurrentSlice,0),k.updateIfChanged(s.uCurrentX,0),k.updateIfChanged(s.uCurrentY,0),k.update(s.uBboxMin,n.min),k.update(s.uBboxSize,o),k.updateIfChanged(s.uResolution,r),e.namedComputeRenderables[Cu].update()}else e.namedComputeRenderables[Cu]=function OQe(e,t,n,r,i){const o=v.sub(v(),n.max,n.min),s=Math.round(t.vertexCount/i),a={drawCount:k.create(s),instanceCount:k.create(t.instanceCount),stride:k.create(i),uGroupCount:k.create(t.groupCount),aTransform:k.create(t.transformBuffer),aInstance:k.create(t.instanceBuffer),aSample:k.create(Bae(s,i)),uGeoTexDim:k.create(Me.create(t.positionTexture.getWidth(),t.positionTexture.getHeight())),tPosition:k.create(t.positionTexture),tGroup:k.create(t.groupTexture),uColorTexDim:k.create(Me.create(t.colorData.getWidth(),t.colorData.getHeight())),tColor:k.create(t.colorData),dColorType:k.create(t.colorType),uCurrentSlice:k.create(0),uCurrentX:k.create(0),uCurrentY:k.create(0),uBboxMin:k.create(n.min),uBboxSize:k.create(o),uResolution:k.create(r)},c={...FQe};return ji(zi(e,"points",Br("accumulate",NQe,kQe,{drawBuffers:"required"}),c,a),a)}(e,t,n,r,i);return e.namedComputeRenderables[Cu]}(r,e,m,t,n);c.currentRenderItemId=-1,D.bind(),o.drawBuffers([o.COLOR_ATTACHMENT0,o.COLOR_ATTACHMENT1]);const{uCurrentSlice:M,uCurrentX:N,uCurrentY:V}=T.values;lt&&r.timer.mark("ColorAccumulate.render"),function LQe(e){const{gl:t,state:n}=e;n.disable(t.CULL_FACE),n.enable(t.BLEND),n.disable(t.DEPTH_TEST),n.enable(t.SCISSOR_TEST),n.depthMask(!1),n.clearColor(0,0,0,0),n.blendFunc(t.ONE,t.ONE),n.blendEquation(t.FUNC_ADD)}(r),c.viewport(0,0,A,E),c.scissor(0,0,A,E),s.clear(s.COLOR_BUFFER_BIT),k.update(V,0);let F=0,G=0,L=0;for(let $=0;$=w&&(F-=w,G+=_,L=0,k.update(V,G)),k.update(N,L),k.update(M,$),c.viewport(L,G,x,_),c.scissor(L,G,x,_),T.render(),++F,L+=x;I.detachFramebuffer(D,0),R.detachFramebuffer(D,1),o.drawBuffers([s.COLOR_ATTACHMENT0,s.NONE]),lt&&r.timer.markEnd("ColorAccumulate.render"),lt&&r.timer.mark("ColorNormalize.render"),(!i||function bje(e){return e.format===Qre}(i))&&(i=a.texture("image-uint8","rgba","ubyte","linear")),i.define(A,E);const z=function VQe(e,t,n){if(e.namedComputeRenderables[HS]){const r=e.namedComputeRenderables[HS].values;k.update(r.tColor,t),k.update(r.tCount,n),k.update(r.uTexSize,Me.set(r.uTexSize.ref.value,t.getWidth(),t.getHeight())),e.namedComputeRenderables[HS].update()}else e.namedComputeRenderables[HS]=function zQe(e,t,n){const r={..._o,tColor:k.create(t),tCount:k.create(n),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight()))},i={...UQe};return ji(zi(e,"triangles",Br("normalize",ps,RQe),i,r),r)}(e,t,n);return e.namedComputeRenderables[HS]}(r,I,R);c.currentRenderItemId=-1,function GQe(e){const{gl:t,state:n}=e;n.disable(t.CULL_FACE),n.enable(t.BLEND),n.disable(t.DEPTH_TEST),n.enable(t.SCISSOR_TEST),n.depthMask(!1),n.clearColor(0,0,0,0),n.blendFunc(t.ONE,t.ONE),n.blendEquation(t.FUNC_ADD)}(r),i.attachFramebuffer(D,0),c.viewport(0,0,A,E),c.scissor(0,0,A,E),s.clear(s.COLOR_BUFFER_BIT),z.render(),lt&&r.timer.markEnd("ColorNormalize.render");const j=nn.create(b[0],b[1],b[2],h),Z=d?"volumeInstance":"volume";return lt&&r.timer.markEnd("calcTextureMeshColorSmoothing"),{texture:i,gridDim:y,gridTexDim:Me.create(A,E),gridTransform:j,type:Z}}const a8="color-smoothing-rgb",Uv="color-smoothing-rgba",c8="color-smoothing-alpha";function Oae(e,t,n,r,i){if(!function HQe(e){return"group"===e||"groupInstance"===e}(e.dColorType.ref.value))return;n*=3,r.namedTextures[a8]||(r.namedTextures[a8]=r.resources.texture("image-uint8","rgb","ubyte","nearest"));const o=r.namedTextures[a8];o.load(e.tColor.ref.value);const s=cE({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:o,colorType:e.dColorType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value},t,n,r,i);k.updateIfChanged(e.dColorType,s.type),k.update(e.tColorGrid,s.texture),k.update(e.uColorTexDim,s.gridTexDim),k.update(e.uColorGridDim,s.gridDim),k.update(e.uColorGridTransform,s.gridTransform)}var Sn,Lae;function Yr(e,t){return{kind:e,layers:t}}function zs(e,t){return{kind:e,layers:t}}!function(e){e.setVisibility=function t(f,p){f&&(f.state.visible=p)},e.setAlphaFactor=function n(f,p){f&&(f.state.alphaFactor=p)},e.setPickable=function r(f,p){f&&(f.state.pickable=p)},e.setColorOnly=function i(f,p){f&&(f.state.colorOnly=p)},e.mark=function o(f,p,m,h,g){if(!f||Ta(p))return!1;const{tMarker:y,uMarker:b,markerAverage:x,markerStatus:_,uGroupCount:S,instanceCount:A,instanceGranularity:E}=f.values,w=E.ref.value?A.ref.value:S.ref.value*A.ref.value,{array:D}=y.ref.value,I=_.ref.value;if(!Uc(p)){let N=0;if(h(p,V=>(N+=Ce.size(V),!0),!0),0===N)return!1;N===w&&(p=tE)}let R=!1,T=-1,M=-1;if(Uc(p)){const N=function gQe(e,t){let n=-1,r=-1;switch(e){case Bt.Highlight:0===t||1===t?(n=1,r=1):2===t||3===t?(n=1,r=3):n=1;break;case Bt.RemoveHighlight:0===t||1===t?(n=0,r=0):(2===t||3===t)&&(n=1,r=2);break;case Bt.Select:1===t||3===t?(n=1,r=3):0===t||2===t?(n=1,r=2):n=1;break;case Bt.Deselect:1===t||3===t?(n=1,r=1):(0===t||2===t)&&(n=0,r=0);break;case Bt.Toggle:1===t?(n=1,r=3):2===t?(n=0,r=0):3===t?(n=1,r=1):0===t&&(n=1,r=2);break;case Bt.Clear:n=0,r=0}return{average:n,status:r}}(m,I);-1!==N.status?(R=I!==N.status,R&&function mQe(e,t,n){e.fill(t,0,n)}(D,N.status,w)):R=o8(D,Ce.ofLength(w),m),T=N.average,M=N.status}else R=h(p,N=>o8(D,N,m),!0),R&&(T=function yQe(e,t){switch(e){case Bt.Highlight:return.5;case Bt.RemoveHighlight:return 0===t?0:2===t||3===t?.5:-1;case Bt.Select:return.5;case Bt.Deselect:return 1===t||3===t?.5:0===t?0:-1;case Bt.Toggle:return-1===t?-1:.5;case Bt.Clear:return-1===t?-1:0===t?0:.5;case Bt.None:return-1;default:Rr()}}(m,I),g&&-1!==g.status&&-1===T&&Us.isReverse(g.action,m)&&pn.areEqual(p,g.loci)&&(M=g.status,T=0===M?0:.5));return R&&(-1===T&&(T=mre(D,w),0===T&&(M=0)),g&&(g.action=m,g.loci=p,g.status=I),k.updateIfChanged(b,M),-1===M&&k.update(y,y.ref.value),k.updateIfChanged(x,T),k.updateIfChanged(_,M)),R},e.setOverpaint=function s(f,p,m,h,g){if(!f)return;const{tOverpaint:y,dOverpaintType:b,dOverpaint:x,uGroupCount:_,instanceCount:S,instanceGranularity:A}=f.values,E=A.ref.value?S.ref.value:_.ref.value*S.ref.value,w=A.ref.value?"instance":"groupInstance";!function jje(e,t,n){const r=Po(Math.max(1,e),4,Uint8Array,n&&n.tOverpaint.ref.value.array);n?(k.update(n.tOverpaint,r),k.update(n.uOverpaintTexDim,Me.create(r.width,r.height)),k.updateIfChanged(n.dOverpaint,e>0),k.updateIfChanged(n.dOverpaintType,t)):(k.create(r),k.create(Me.create(r.width,r.height)),k.create(e>0),k.create(Os()),k.create(v.create(1,1,1)),k.create(nn.create(0,0,0,1)),k.create(t),k.create(1))}(p.layers.length?E:0,w,f.values);const{array:D}=y.ref.value;h&&sie(D,0,E);for(let I=0,R=p.layers.length;I{const G=Ce.start(F),L=Ce.end(F);return N?sie(D,G,L):Gje(D,G,L,M)},!1)}if(k.update(y,y.ref.value),k.updateIfChanged(b,w),k.updateIfChanged(x,p.layers.length>0),0!==p.layers.length&&"instance"!==w&&g&&Tp(g.props)){const{geometry:I,props:R,webgl:T}=g;if("mesh"===I.kind){const{resolution:M,overpaintTexture:N}=I.meta,V=cl(R.smoothColors,!0,M);V&&(function TQe(e,t,n,r,i){if(!function IQe(e){return"groupInstance"===e}(e.dOverpaintType.ref.value))return;const o=sE({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,positionBuffer:e.aPosition.ref.value,groupBuffer:e.aGroup.ref.value,colorData:e.tOverpaint.ref.value,colorType:e.dOverpaintType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value,itemSize:4},t,n,r,i);"volume"===o.kind?(k.updateIfChanged(e.dOverpaintType,o.type),k.update(e.tOverpaintGrid,o.texture),k.update(e.uOverpaintTexDim,o.gridTexDim),k.update(e.uOverpaintGridDim,o.gridDim),k.update(e.uOverpaintGridTransform,o.gridTransform)):"vertex"===o.kind&&(k.updateIfChanged(e.dOverpaintType,o.type),k.update(e.tOverpaint,o.texture),k.update(e.uOverpaintTexDim,o.texDim))}(f.values,V.resolution,V.stride,T,N),I.meta.overpaintTexture=f.values.tOverpaintGrid.ref.value)}else if(T&&"texture-mesh"===I.kind){const{resolution:M,overpaintTexture:N}=I.meta,V=cl(R.smoothColors,!0,M);V&&(function WQe(e,t,n,r,i){if(!function qQe(e){return"groupInstance"===e}(e.dOverpaintType.ref.value))return;n*=3,r.namedTextures[Uv]||(r.namedTextures[Uv]=r.resources.texture("image-uint8","rgba","ubyte","nearest"));const o=r.namedTextures[Uv];o.load(e.tOverpaint.ref.value);const s=cE({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:o,colorType:e.dOverpaintType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value},t,n,r,i);k.updateIfChanged(e.dOverpaintType,s.type),k.update(e.tOverpaintGrid,s.texture),k.update(e.uOverpaintTexDim,s.gridTexDim),k.update(e.uOverpaintGridDim,s.gridDim),k.update(e.uOverpaintGridTransform,s.gridTransform)}(f.values,V.resolution,V.stride,T,N),I.meta.overpaintTexture=f.values.tOverpaintGrid.ref.value)}}},e.setTransparency=function a(f,p,m,h,g){if(!f)return;const{tTransparency:y,dTransparencyType:b,transparencyAverage:x,dTransparency:_,uGroupCount:S,instanceCount:A,instanceGranularity:E}=f.values,w=E.ref.value?A.ref.value:S.ref.value*A.ref.value,D=E.ref.value?"instance":"groupInstance";!function Wje(e,t,n){const r=Po(Math.max(1,e),1,Uint8Array,n&&n.tTransparency.ref.value.array);n?(k.update(n.tTransparency,r),k.update(n.uTransparencyTexDim,Me.create(r.width,r.height)),k.updateIfChanged(n.dTransparency,e>0),k.updateIfChanged(n.transparencyAverage,cie(r.array,e)),k.updateIfChanged(n.dTransparencyType,t)):(k.create(r),k.create(Me.create(r.width,r.height)),k.create(e>0),k.create(0),k.create(Os()),k.create(v.create(1,1,1)),k.create(nn.create(0,0,0,1)),k.create(t),k.create(1))}(p.layers.length?w:0,D,f.values);const{array:I}=y.ref.value;h&&function qje(e,t,n){e.fill(0,t,n)}(I,0,w);for(let R=0,T=p.layers.length;R{const G=Ce.start(F),L=Ce.end(F);return Hje(I,G,L,N)},!1)}if(k.update(y,y.ref.value),k.updateIfChanged(x,cie(I,w)),k.updateIfChanged(b,D),k.updateIfChanged(_,p.layers.length>0),0!==p.layers.length&&"instance"!==D&&g&&Tp(g.props)){const{geometry:R,props:T,webgl:M}=g;if("mesh"===R.kind){const{resolution:N,transparencyTexture:V}=R.meta,F=cl(T.smoothColors,!0,N);F&&(function EQe(e,t,n,r,i){if(!function DQe(e){return"groupInstance"===e}(e.dTransparencyType.ref.value))return;const o=sE({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,positionBuffer:e.aPosition.ref.value,groupBuffer:e.aGroup.ref.value,colorData:e.tTransparency.ref.value,colorType:e.dTransparencyType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value,itemSize:1},t,n,r,i);"volume"===o.kind?(k.updateIfChanged(e.dTransparencyType,o.type),k.update(e.tTransparencyGrid,o.texture),k.update(e.uTransparencyTexDim,o.gridTexDim),k.update(e.uTransparencyGridDim,o.gridDim),k.update(e.uTransparencyGridTransform,o.gridTransform)):"vertex"===o.kind&&(k.updateIfChanged(e.dTransparencyType,o.type),k.update(e.tTransparency,o.texture),k.update(e.uTransparencyTexDim,o.texDim))}(f.values,F.resolution,F.stride,M,V),R.meta.transparencyTexture=f.values.tTransparencyGrid.ref.value)}else if(M&&"texture-mesh"===R.kind){const{resolution:N,transparencyTexture:V}=R.meta,F=cl(T.smoothColors,!0,N);F&&(function YQe(e,t,n,r,i){if(!function $Qe(e){return"groupInstance"===e}(e.dTransparencyType.ref.value))return;n*=3,r.namedTextures[c8]||(r.namedTextures[c8]=r.resources.texture("image-uint8","alpha","ubyte","nearest"));const o=r.namedTextures[c8];o.load(e.tTransparency.ref.value);const s=cE({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:o,colorType:e.dTransparencyType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value},t,n,r,i);k.updateIfChanged(e.dTransparencyType,s.type),k.update(e.tTransparencyGrid,s.texture),k.update(e.uTransparencyTexDim,s.gridTexDim),k.update(e.uTransparencyGridDim,s.gridDim),k.update(e.uTransparencyGridTransform,s.gridTransform)}(f.values,F.resolution,F.stride,M,V),R.meta.transparencyTexture=f.values.tTransparencyGrid.ref.value)}}},e.setSubstance=function c(f,p,m,h,g){if(!f)return;const{tSubstance:y,dSubstanceType:b,dSubstance:x,uGroupCount:_,instanceCount:S,instanceGranularity:A}=f.values,E=A.ref.value?S.ref.value:_.ref.value*S.ref.value,w=A.ref.value?"instance":"groupInstance";!function Zje(e,t,n){const r=Po(Math.max(1,e),4,Uint8Array,n&&n.tSubstance.ref.value.array);n?(k.update(n.tSubstance,r),k.update(n.uSubstanceTexDim,Me.create(r.width,r.height)),k.updateIfChanged(n.dSubstance,e>0),k.updateIfChanged(n.dSubstanceType,t)):(k.create(r),k.create(Me.create(r.width,r.height)),k.create(e>0),k.create(Os()),k.create(v.create(1,1,1)),k.create(nn.create(0,0,0,1)),k.create(t),k.create(1))}(p.layers.length?E:0,w,f.values);const{array:D}=y.ref.value;h&&die(D,0,E);for(let I=0,R=p.layers.length;I{const G=Ce.start(F),L=Ce.end(F);return N?die(D,G,L):Kje(D,G,L,M)},!1)}if(k.update(y,y.ref.value),k.updateIfChanged(b,w),k.updateIfChanged(x,p.layers.length>0),0!==p.layers.length&&"instance"!==w&&g&&Tp(g.props)){const{geometry:I,props:R,webgl:T}=g;if("mesh"===I.kind){const{resolution:M,substanceTexture:N}=I.meta,V=cl(R.smoothColors,!0,M);V&&(function MQe(e,t,n,r,i){if(!function PQe(e){return"groupInstance"===e}(e.dSubstanceType.ref.value))return;const o=sE({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,positionBuffer:e.aPosition.ref.value,groupBuffer:e.aGroup.ref.value,colorData:e.tSubstance.ref.value,colorType:e.dSubstanceType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value,itemSize:4},t,n,r,i);"volume"===o.kind?(k.updateIfChanged(e.dSubstanceType,o.type),k.update(e.tSubstanceGrid,o.texture),k.update(e.uSubstanceTexDim,o.gridTexDim),k.update(e.uSubstanceGridDim,o.gridDim),k.update(e.uSubstanceGridTransform,o.gridTransform)):"vertex"===o.kind&&(k.updateIfChanged(e.dSubstanceType,o.type),k.update(e.tSubstance,o.texture),k.update(e.uSubstanceTexDim,o.texDim))}(f.values,V.resolution,V.stride,T,N),I.meta.substanceTexture=f.values.tSubstanceGrid.ref.value)}else if(T&&"texture-mesh"===I.kind){const{resolution:M,substanceTexture:N}=I.meta,V=cl(R.smoothColors,!0,M);V&&(function KQe(e,t,n,r,i){if(!function XQe(e){return"groupInstance"===e}(e.dSubstanceType.ref.value))return;n*=3,r.namedTextures[Uv]||(r.namedTextures[Uv]=r.resources.texture("image-uint8","rgba","ubyte","nearest"));const o=r.namedTextures[Uv];o.load(e.tSubstance.ref.value);const s=cE({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:o,colorType:e.dSubstanceType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value},t,n,r,i);k.updateIfChanged(e.dSubstanceType,s.type),k.update(e.tSubstanceGrid,s.texture),k.update(e.uSubstanceTexDim,s.gridTexDim),k.update(e.uSubstanceGridDim,s.gridDim),k.update(e.uSubstanceGridTransform,s.gridTransform)}(f.values,V.resolution,V.stride,T,N),I.meta.substanceTexture=f.values.tSubstanceGrid.ref.value)}}},e.setClipping=function u(f,p,m,h){if(!f)return;const{tClipping:g,dClippingType:y,dClipping:b,uGroupCount:x,instanceCount:_,instanceGranularity:S}=f.values,A=S.ref.value?_.ref.value:x.ref.value*_.ref.value,{layers:E}=p,w=S.ref.value?"instance":"groupInstance";!function Xje(e,t,n){const r=Po(Math.max(1,e),1,Uint8Array,n&&n.tClipping.ref.value.array);n?(k.update(n.tClipping,r),k.update(n.uClippingTexDim,Me.create(r.width,r.height)),k.updateIfChanged(n.dClipping,e>0),k.updateIfChanged(n.dClippingType,t)):(k.create(r),k.create(Me.create(r.width,r.height)),k.create(e>0),k.create(t))}(E.length?A:0,w,f.values);const{array:D}=g.ref.value;h&&function Yje(e,t,n){e.fill(0,t,n)}(D,0,A);for(let I=0,R=p.layers.length;I{const F=Ce.start(V),G=Ce.end(V);return $je(D,F,G,M)},!1)}k.update(g,g.ref.value),k.updateIfChanged(y,w),k.updateIfChanged(b,p.layers.length>0)},e.setThemeStrength=function l(f,p){f&&(k.updateIfChanged(f.values.uOverpaintStrength,p.overpaint),k.updateIfChanged(f.values.uTransparencyStrength,p.transparency),k.updateIfChanged(f.values.uSubstanceStrength,p.substance))},e.setTransform=function d(f,p,m){if(!f||!p&&!m)return;const{values:h}=f;p&&(le.copy(h.matrix.ref.value,p),k.update(h.matrix,h.matrix.ref.value)),m?(h.extraTransform.ref.value.set(m),k.update(h.extraTransform,h.extraTransform.ref.value)):null===m&&(xD(h.extraTransform.ref.value,h.instanceCount.ref.value),k.update(h.extraTransform,h.extraTransform.ref.value)),nie(h,h.invariantBoundingSphere.ref.value,h.instanceGrid.ref.value.cellSize,h.instanceGrid.ref.value.batchSize);const g=fs(h.invariantBoundingSphere.ref.value,h.transform.ref.value,h.instanceCount.ref.value,0);k.update(h.boundingSphere,g)}}(Sn||(Sn={})),function(e){let t;function r(l){return 0===l.layers.length}e.Empty={kind:"empty-loci",layers:[]},function(l){let d;var y;function m(y){switch(y){case"one":return d.One;case"two":return d.Two;case"three":return d.Three;case"four":return d.Four;case"five":return d.Five;case"six":return d.Six}}l.is=ea.has,(y=d=l.Flag||(l.Flag={}))[y.None=0]="None",y[y.One=1]="One",y[y.Two=2]="Two",y[y.Three=4]="Three",y[y.Four=8]="Four",y[y.Five=16]="Five",y[y.Six=32]="Six",l.create=function f(y){return ea.create(y)},l.Names={one:d.One,two:d.Two,three:d.Three,four:d.Four,five:d.Five,six:d.Six},l.isName=function p(y){return y in l.Names},l.fromName=m,l.fromNames=function h(y){let b=d.None;for(let x=0,_=y.length;x<_;++x)b|=m(y[x]);return b},l.toNames=function g(y){const b=[];return l.is(y,d.One)&&b.push("one"),l.is(y,d.Two)&&b.push("two"),l.is(y,d.Three)&&b.push("three"),l.is(y,d.Four)&&b.push("four"),l.is(y,d.Five)&&b.push("five"),l.is(y,d.Six)&&b.push("six"),b}}(t=e.Groups||(e.Groups={})),e.areEqual=function n(l,d){if(l.layers.length!==d.layers.length)return!1;for(let f=0,p=l.layers.length;f{m.push({loci:h,groups:g})}),{kind:"element-loci",layers:m}}return l},e.filter=function s(l,d){if(r(l))return l;if("element-loci"===l.kind){const{structure:f}=l.layers[0].loci,p=[];for(const m of l.layers){let{loci:h,groups:g}=m;const y=De.remap(h,d);h=De.remap(y,f),De.isEmpty(h)||p.push({loci:h,groups:g})}return{kind:"element-loci",layers:p}}return l},e.ofScript=function a(l,d){const f=[];for(let p=0,m=l.length;p{m.push({loci:h,material:g,clear:!1})}),{kind:"element-loci",layers:m}}return u},e.filter=function o(u,l){if(n(u))return u;if("element-loci"===u.kind){const{structure:d}=u.layers[0].loci,f=[];for(const p of u.layers){let{loci:m,material:h,clear:g}=p;const y=De.remap(m,l);m=De.remap(y,d),De.isEmpty(m)||f.push({loci:m,material:h,clear:g})}return{kind:"element-loci",layers:f}}return u},e.ofScript=function s(u,l){const d=[];for(let f=0,p=u.length;fyn.Empty,getParams:()=>({}),defaultValues:{},defaultColorTheme:Lc.EmptyProvider,defaultSizeTheme:Qo.EmptyProvider,isApplicable:()=>!0};function Uae(e){return e.map(t=>[t.name,t.provider.label])}class Vae{get default(){return this._list[0]}get types(){return Uae(this._list)}constructor(){this._list=[],this._map=new Map,this._name=new Map}add(t){if(this._map.has(t.name))throw new Error(`${t.name} already registered.`);this._list.push({name:t.name,provider:t}),this._map.set(t.name,t),this._name.set(t,t.name)}getName(t){if(!this._name.has(t))throw new Error(`'${t.label}' is not a registered represenatation provider.`);return this._name.get(t)}remove(t){const n=t.name;this._list.splice(this._list.findIndex(i=>i.name===n),1);const r=this._map.get(n);r&&(this._map.delete(n),this._name.delete(r))}get(t){return this._map.get(t)||ZQe}get list(){return this._list}getApplicableList(t){return this._list.filter(n=>n.provider.isApplicable(t))}getApplicableTypes(t){return Uae(this.getApplicableList(t))}clear(){this._list.length=0,this._map.clear(),this._name.clear()}}var yn;function Jo(e,t,n={}){let r=0;const i=new mr,o=yn.createState(),s=Hp(),a=[];let c,u,l=-1;const d=Fo.createEmpty();let m,h,f=C.getDefaultValues(t.Params);n.modifyState&&yn.updateState(o,n.modifyState(o));const g=Cf.create();function _(S,A){return Uc(S)||qn.isLoci(S)&&S.shape===u?A(Ce.ofBounds(0,f.instanceGranularity?u.transforms.length:u.groupCount*u.transforms.length)):f.instanceGranularity?function x(S,A,E){let w=!1;if(!ra.isLoci(S)||ra.isLociEmpty(S)||S.shape!==A)return!1;for(const D of S.groups)E(Ce.ofSingleton(D.instance))&&(w=!0);return w}(S,u,A):function QQe(e,t,n){if(!ra.isLoci(e)||e.shape!==t)return!1;let r=!1;const{groupCount:i}=t,{groups:o}=e;for(const{ids:s,instance:a}of o)if(Ce.is(s)){const c=a*i+Ce.start(s),u=a*i+Ce.end(s);n(Ce.ofBounds(c,u))&&(r=!0)}else for(let c=0,u=s.length;c[qn.Loci(u)],eachLocation:S=>{for(m.reset();m.hasNext;){const{location:A,isSecondary:E}=m.move();S(A,E)}},mark(S,A){if(!Us.is(o.markerActions,A))return!1;if(ra.isLoci(S)||qn.isLoci(S)){if(S.shape!==u)return!1}else if(!Uc(S))return!1;return Sn.mark(c,S,A,_)},setState(S){n.modifyState&&(S=n.modifyState(S)),c&&(void 0!==S.visible&&Sn.setVisibility(c,S.visible),void 0!==S.alphaFactor&&Sn.setAlphaFactor(c,S.alphaFactor),void 0!==S.pickable&&Sn.setPickable(c,S.pickable),void 0!==S.colorOnly&&Sn.setColorOnly(c,S.colorOnly),void 0!==S.overpaint&&Sn.setOverpaint(c,S.overpaint,_,!0),void 0!==S.transparency&&Sn.setTransparency(c,S.transparency,_,!0),void 0!==S.substance&&Sn.setSubstance(c,S.substance,_,!0),void 0!==S.transform&&Sn.setTransform(c,S.transform)),yn.updateState(o,S)},setTheme(S){un&&console.warn("The `ShapeRepresentation` theme is fixed to `ShapeGroupColorTheme` and `ShapeGroupSizeTheme`. Colors are taken from `Shape.getColor` and sizes from `Shape.getSize`")},destroy(){a.length=0,c&&(c.state.disposed=!0,c=void 0)}}}!function(e){let t;var a;function n(){return{visible:!0,alphaFactor:1,pickable:!0,colorOnly:!1,syncManually:!1,transform:le.identity(),overpaint:Bo.Empty,transparency:Vs.Empty,substance:zs.Empty,clipping:Yr.Empty,themeStrength:{overpaint:1,transparency:1,substance:1},markerActions:Us.All}}function r(a,c){void 0!==c.visible&&(a.visible=c.visible),void 0!==c.alphaFactor&&(a.alphaFactor=c.alphaFactor),void 0!==c.pickable&&(a.pickable=c.pickable),void 0!==c.colorOnly&&(a.colorOnly=c.colorOnly),void 0!==c.overpaint&&(a.overpaint=c.overpaint),void 0!==c.transparency&&(a.transparency=c.transparency),void 0!==c.substance&&(a.substance=c.substance),void 0!==c.clipping&&(a.clipping=c.clipping),void 0!==c.themeStrength&&(a.themeStrength=c.themeStrength),void 0!==c.syncManually&&(a.syncManually=c.syncManually),void 0!==c.transform&&le.copy(a.transform,c.transform),void 0!==c.markerActions&&(a.markerActions=c.markerActions)}(a=t=e.Loci||(e.Loci={})).areEqual=function c(l,d){return l.repr===d.repr&&pn.areEqual(l.loci,d.loci)},a.isEmpty=function u(l){return pn.isEmpty(l.loci)},a.Empty={loci:$n},e.createState=n,e.updateState=r,e.StateBuilder={create:n,update:r},e.Empty={label:"",groupCount:0,renderObjects:[],geometryVersion:-1,props:{},params:{},updated:new mr,state:n(),theme:Fo.createEmpty(),createOrUpdate:()=>Oe.constant("",void 0),setState:()=>{},setTheme:()=>{},getLoci:()=>$n,getAllLoci:()=>[],eachLocation:()=>{},mark:()=>!1,destroy:()=>{}};class i{constructor(){this.curr=new Set,this.next=new Set,this._version=-1}get version(){return this._version}add(c,u){this.next.add(uu(c,u))}snapshot(){Si.areEqual(this.curr,this.next)||(this._version+=1),[this.curr,this.next]=[this.next,this.curr],this.next.clear()}}e.GeometryState=i,e.createMulti=function o(a,c,u,l,d){let f=0;const p=new mr,m=new i,h=l.create();let y,b,x,g=Fo.createEmpty();const _={},S=Object.keys(d).map((A,E)=>{_[E]=A;const w=d[A](c,u);return w.setState(h),w});return{label:a,updated:p,get groupCount(){let A=0;if(b){const{visuals:E}=b;for(let w=0,D=S.length;w{E&&E!==x&&(y=u(c,E),x=E,b||(b=C.getDefaultValues(y)));const w=s8(Object.assign({},b,A),x);Object.assign(b,A,w);const{visuals:D}=b;return Oe.create(`Creating or updating '${a}' representation`,function(){var I=ie(function*(R){for(let T=0,M=S.length;T{const{visuals:E}=b;for(let w=0,D=S.length;w{const A=[],{visuals:E}=b;for(let w=0,D=S.length;w{const{visuals:E}=b;for(let w=0,D=S.length;w{let w=!1;for(let D=0,I=S.length;D{l.update(h,A);for(let E=0,w=S.length;E{g=A;for(let E=0,w=S.length;E{const y=s8(Object.assign({},h,g));return Object.assign(h,g,y),Oe.create(`Updating '${a}' representation`,function(){var b=ie(function*(x){d.add(0,c.id),d.snapshot(),l.next(u++)});return function(x){return b.apply(this,arguments)}}())},get state(){return f},get theme(){return p},getLoci:()=>$n,getAllLoci:()=>[],eachLocation:()=>{},mark:(g,y)=>!1,setState:g=>{void 0!==g.visible&&Sn.setVisibility(c,g.visible),void 0!==g.alphaFactor&&Sn.setAlphaFactor(c,g.alphaFactor),void 0!==g.pickable&&Sn.setPickable(c,g.pickable),void 0!==g.colorOnly&&Sn.setColorOnly(c,g.colorOnly),void 0!==g.themeStrength&&Sn.setThemeStrength(c,g.themeStrength),void 0!==g.transform&&Sn.setTransform(c,g.transform),e.updateState(f,g)},setTheme:()=>{},destroy(){}}}}(yn||(yn={}));const zae=le();class Vv{constructor(t){this.structure=t,this.groupUnitTransforms=[],this.unitOffsetMap=Lu.Mutable(),this.groupIndexMap=Lu.Mutable(),this._isIdentity=void 0,this.version=0,this.unitTransforms=new Float32Array(16*t.units.length),this.size=t.units.length,this.reset();let n=0;for(let r=0,i=t.unitSymmetryGroups.length;rJo(aJe,Nt.Utils)},Zae={...iJe};function aJe(e,t,n,r){const i=function sJe(e,t,n){const r=at.createState(256,128,n),{fromFractional:i}=e.symmetry.spacegroup.cell;v.copy(pd,e.ref),"center"===t.attachment?(v.trunc(pd,pd),v.subScalar(pd,pd,.5)):v.floor(pd,pd),le.fromTranslation(Kae,pd);const o=yie(gie(tJe),Kae),s=Math.cbrt(e.symmetry.spacegroup.cell.volume)/300*t.cellScale;r.currentGroup=1,at.addCage(r,i,o,s,2,20);const a=_e.fromDimensionsAndTransform(_e(),v.unit,i);v.transformMat4(pd,pd,i),_e.translate(a,a,pd),_e.expand(a,a,s);const c=at.getMesh(r);return c.setBoundingSphere(a),c}(t,n,r&&r.geometry),o=h2.getUnitcellLabel(t.symmetry);return qn.create(o,t,i,()=>n.cellColor,()=>1,()=>o)}function Qae(e,t,n){const r=v();return"model"===n.ref&&v.transformMat4(r,sn.getCenter(e),t.spacegroup.cell.toFractional),{symmetry:t,ref:r}}const bl=new Uint16Array([0,1,2,1,3,2]),S0=ze.add3,Gs=ze.add2,Jae=ze.add;var wf;!function(e){e.create=function t(n={},r=2048,i=1024,o){r*=2,i*=2;const s=ze.create(Float32Array,3,i,o?o.centerBuffer.ref.value:r),a=ze.create(Float32Array,2,i,o?o.mappingBuffer.ref.value:r),c=ze.create(Float32Array,1,i,o?o.depthBuffer.ref.value:r),u=ze.create(Uint32Array,3,i,o?o.indexBuffer.ref.value:r),l=ze.create(Float32Array,1,i,o?o.groupBuffer.ref.value:r),d=ze.create(Float32Array,2,i,o?o.tcoordBuffer.ref.value:r),f={...C.getDefaultValues(vu.Params),...n},{attachment:p,background:m,backgroundMargin:h,tether:g,tetherLength:y,tetherBaseWidth:b}=f,x=function PHe(e){const t=JSON.stringify(e);return void 0===v5[t]&&(v5[t]=new MHe(e)),v5[t]}(f),_=.4*h,S=x.buffer/x.lineHeight,A=(E,w,D,I,R)=>{S0(s,E,w,D),Jae(c,I),Jae(l,R)};return{add:(E,w,D,I,R,T,M)=>{let N=0;const V=E.length;for(let q=0;q{const E=x.texture,w=ze.compact(s,!0),D=ze.compact(a,!0),I=ze.compact(c,!0),R=ze.compact(u,!0),T=ze.compact(l,!0),M=ze.compact(d,!0);return vu.create(E,w,D,I,R,T,M,u.elementCount/2,o)}}}}(wf||(wf={}));const Gv={granularity:"element",condensed:!1,reverse:!1,countsOnly:!1,hidePrefix:!1,htmlStyling:!0};function dE(e,t={}){var n;switch(e.kind){case"structure-loci":return e.structure.models.map(d=>d.entry).filter(d=>!!d).join(", ");case"element-loci":return fE(rf.ofLoci(e),t);case"bond-loci":const r=e.bonds[0];return r?u8(r,t):"";case"shape-loci":return e.shape.name;case"group-loci":const i=e.groups[0];return i?e.shape.getLabel(Fe.start(i.ids),i.instance):"";case"every-loci":return"Everything";case"empty-loci":return"Nothing";case"data-loci":return e.getLabel();case"volume-loci":return e.volume.label||"Volume";case"isosurface-loci":return[`${e.volume.label||"Volume"}`,`Isosurface at ${et.IsoValue.toString(e.isoValue)}`].join(" | ");case"cell-loci":const o=Fe.size(e.indices),s=Fe.start(e.indices),a=et.IsoValue.absolute(e.volume.grid.cells.data[s]),c=et.IsoValue.toRelative(a,e.volume.grid.stats),u=[`${e.volume.label||"Volume"}`,1===o?`Cell #${s}`:`${o} Cells`];return 1===o&&u.push(`${et.IsoValue.toString(a)} (${et.IsoValue.toString(c)})`),u.join(" | ");case"segment-loci":const l=null===(n=et.Segmentation.get(e.volume))||void 0===n?void 0:n.labels;if(l&&1===e.segments.length){const d=l[e.segments[0]];if(d)return d}return[`${e.volume.label||"Volume"}`,1===e.segments.length?`Segment ${e.segments[0]}`:`${e.segments.length} Segments`].join(" | ")}}function jv(e,t){return 1===e?`1 ${t}`:`${e} ${t}s`}function qS(e,t,n,r,i,o){return`${Jp(t,{granularity:n,hidePrefix:r,reverse:i,condensed:o})} [+ ${jv(e-1,`other ${Fg(n)}`)}]`}function fE(e,t={}){const n={...Gv,...t},r=function lJe(e,t=!1,n=!1,r=!1,i=!1){const{structureCount:o,chainCount:s,residueCount:a,conformationCount:c,elementCount:u}=e;if(!t&&1===u&&0===a&&0===s)return Jp(e.firstElementLoc,{hidePrefix:n,condensed:r,granularity:"element",reverse:i});if(!t&&0===u&&1===a&&0===s)return Jp(e.firstResidueLoc,{hidePrefix:n,condensed:r,granularity:"residue",reverse:i});if(t||0!==u||0!==a||1!==s){if(t){const l=[];return o>0&&l.push(jv(o,"Structure")),s>0&&l.push(jv(s,"Chain")),a>0&&l.push(jv(a,"Residue")),c>0&&l.push(jv(c,"Conformation")),u>0&&l.push(jv(u,"Element")),l.join(" + ")}{const l=[];return o>0&&l.push(1===o?Jp(e.firstStructureLoc,{hidePrefix:n,condensed:r,granularity:"structure",reverse:i}):qS(o,e.firstStructureLoc,"structure",n,i,r)),s>0&&(l.push(1===s?Jp(e.firstChainLoc,{condensed:r,granularity:"chain",hidePrefix:n,reverse:i}):qS(s,e.firstChainLoc,"chain",n,i,r)),n=!0),a>0&&(l.push(1===a?Jp(e.firstResidueLoc,{condensed:r,granularity:"residue",hidePrefix:n,reverse:i}):qS(a,e.firstResidueLoc,"residue",n,i,r)),n=!0),c>0&&(l.push(1===c?Jp(e.firstConformationLoc,{condensed:r,granularity:"conformation",hidePrefix:n,reverse:i}):qS(c,e.firstConformationLoc,"conformation",n,i,r)),n=!0),u>0&&l.push(1===u?Jp(e.firstElementLoc,{condensed:r,granularity:"element",hidePrefix:n,reverse:i}):qS(u,e.firstElementLoc,"element",n,i,r)),l.join(" + ")}}{const{unit:l}=e.firstChainLoc,d=Ee.isAtomic(l)&&1===function uJe(e){const{elements:t,model:n}=e,{chainAtomSegments:r,residueAtomSegments:i}=n.atomicHierarchy;return i.index[r.offsets[r.index[t[t.length-1]]+1]-1]-i.index[r.offsets[r.index[t[0]]]]+1}(l)||Ee.Traits.is(l.traits,Ee.Trait.MultiChain)?"residue":"chain";return Jp(e.firstChainLoc,{hidePrefix:n,condensed:r,granularity:d,reverse:i})}}(e,n.countsOnly,n.hidePrefix,n.condensed,n.reverse);return n.htmlStyling?r:TB(r)}function pE(e,t={}){const n=rf.create();for(const r of e)rf.add(n,n,rf.ofLoci(r));return fE(n,t)}function u8(e,t={}){return hE({loci:[De(e.aStructure,[{unit:e.aUnit,indices:Fe.ofSingleton(e.aIndex)}]),De(e.bStructure,[{unit:e.bUnit,indices:Fe.ofSingleton(e.bIndex)}])]},t)}function hE(e,t={}){const n={...Gv,...t},r=function dJe(e,t){const{granularity:n,hidePrefix:r,reverse:i,condensed:o}=t;let s=!0;for(const a of e.loci)if(!De.is(a)||1!==De.size(a)){s=!1;break}if(s){const c=e.loci.map(l=>{const{unit:d,indices:f}=l.elements[0];return nt.create(l.structure,d,d.elements[Fe.start(f)])}).map(l=>ece(l,n,r,i||o));if(o)return c.map(l=>l[0].replace(/\[.*\]/g,"").trim()).filter(l=>!!l).join(" \u2014 ");let u=0;for(let l=0,d=Math.min(...c.map(f=>f.length))-1;l0){const l=[c[0].join(" | ")];for(let d=1,f=c.length;d!!p).join(" | "));return l.join(" \u2014 ")}return c.map(l=>l.filter(d=>!!d).join(" | ")).filter(l=>!!l).join("
")}return e.loci.map(c=>dE(c,t)).filter(c=>!!c).join(o?" \u2014 ":"
")}(e,n);return n.htmlStyling?r:TB(r)}function Jp(e,t={}){var n,r;const i={...Gv,...t},o=ece(e,i.granularity,i.hidePrefix,i.reverse||i.condensed),s=i.condensed?null!==(r=null===(n=o[0])||void 0===n?void 0:n.replace(/\[.*\]/g,"").trim())&&void 0!==r?r:"":o.filter(a=>!!a).join(" | ");return i.htmlStyling?s:TB(s)}function ece(e,t="element",n=!1,r=!1){const i=[];if(!n){let o=e.unit.model.entry;o.length>30&&(o=o.substr(0,27)+"\u2026"),i.push(`${o}`),"structure"!==t&&(i.push(`Model ${e.unit.model.modelNum}`),i.push(`Instance ${e.unit.conformation.operator.name}`))}return Ee.isAtomic(e.unit)?i.push(...function fJe(e,t,n=!1){const r=nt.residueIndex(e),i=Ze.chain.label_asym_id(e),o=Ze.chain.auth_asym_id(e),s=0===e.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(r),a=Ze.residue.label_seq_id(e),c=Ze.residue.auth_seq_id(e),u=Ze.residue.pdbx_PDB_ins_code(e),l=Ze.atom.label_comp_id(e),d=Ze.atom.label_atom_id(e),f=Ze.atom.label_alt_id(e),p=Ze.atom.occupancy(e),m=Ze.residue.microheterogeneityCompIds(e),h="residue"===t&&m.length>1?`(${m.join("|")})`:l,g=[];switch(t){case"element":g.push(`${d}${f?`%${f}`:""}`);case"conformation":"conformation"===t&&f&&g.push(`Conformation ${f}`);case"residue":const y=a!==c&&s?a:c;g.push(`${h} ${y}${y!==c?` [auth ${c}]`:""}${u||""}`);case"chain":i===o?g.push(`${i}`):"chain"===t&&Ee.Traits.is(e.unit.traits,Ee.Trait.MultiChain)?g.push(`[auth ${o}]`):g.push(`${i} [auth ${o}]`)}return g.length>0&&1!==p&&!n&&(g[0]=`${g[0]} [occupancy ${Math.round(100*p)/100}]`),g.reverse()}(e,t,r)):Ee.isCoarse(e.unit)?i.push(...function pJe(e,t){const n=Ze.coarse.asym_id(e),r=Ze.coarse.seq_id_begin(e),i=Ze.coarse.seq_id_end(e),o=[];switch(t){case"element":case"conformation":case"residue":if(r===i){const s=Ze.coarse.entityKey(e),c=e.unit.model.sequence.byEntityKey[s].sequence.compId.value(r-1);o.push(`${c} ${r}`)}else o.push(`${r}-${i}`);case"chain":o.push(`${n}`)}return o.reverse()}(e,t)):i.push("Unknown"),r?i.reverse():i}function l8(e,t={}){const n={...Gv,measureOnly:!1,unitLabel:"\u212b",...t},[r,i]=e.loci.map(a=>pn.getCenter(a)),o=`${v.distance(r,i).toFixed(2)} ${n.unitLabel}`;if(n.measureOnly)return o;const s=hE(e,n);return n.condensed?`${o} | ${s}`:`Distance ${o}
${s}`}function d8(e,t={}){const n={...Gv,measureOnly:!1,...t},[r,i,o]=e.loci.map(l=>pn.getCenter(l)),s=v.sub(v(),r,i),a=v.sub(v(),o,i),c=`${su(v.angle(s,a)).toFixed(2)}\xb0`;if(n.measureOnly)return c;const u=hE(e,n);return n.condensed?`${c} | ${u}`:`Angle ${c}
${u}`}function f8(e,t={}){const n={...Gv,measureOnly:!1,...t},[r,i,o,s]=e.loci.map(u=>pn.getCenter(u)),a=`${su(v.dihedralAngle(r,i,o,s)).toFixed(2)}\xb0`;if(n.measureOnly)return a;const c=hE(e,n);return n.condensed?`${a} | ${c}`:`Dihedral ${a}
${c}`}const tce={customText:C.Text("",{label:"Text",description:"Override the label with custom value.",isEssential:!0}),textColor:C.Color(xn.black,{isEssential:!0}),textSize:C.Numeric(.5,{min:.1,max:10,step:.1},{isEssential:!0})},mE={...vu.Params,...tce,borderWidth:C.Numeric(.2,{min:0,max:.5,step:.01})},nce={unitLabel:C.Text("\u212b",{isEssential:!0})},hJe={...di.Params,...nce,lineSizeAttenuation:C.Boolean(!0),linesColor:C.Color(xn.lightgreen,{isEssential:!0}),linesSize:C.Numeric(.075,{min:.01,max:5,step:.01}),dashLength:C.Numeric(.2,{min:.01,max:.2,step:.01})},mJe={...mE,...nce},rce={lines:(e,t)=>Jo(bJe,di.Utils,{modifyState:n=>({...n,markerActions:Us.Highlighting})}),text:(e,t)=>Jo(_Je,vu.Utils,{modifyState:n=>({...n,markerActions:Bt.None})})},ice={...hJe,...mJe,visuals:C.MultiSelect(["lines","text"],C.objectToOptions(rce))};function oce(e,t){const{sphereA:n,sphereB:r,center:i}=t,[o,s]=e.loci;return pn.getBoundingSphere(o,n),pn.getBoundingSphere(s,r),v.add(i,n.center,r.center),v.scale(i,i,.5),t.distance=v.distance(n.center,r.center),t}const WS=function gJe(){return{sphereA:_e(),sphereB:_e(),center:v(),distance:0}}();function sce(e,t){return 1===e.pairs.length?`Distance ${l8(e.pairs[0],{unitLabel:t,measureOnly:!0})}`:`${e.pairs.length} Distances`}function bJe(e,t,n,r){const i=function yJe(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.pairs.length;in.linesColor,()=>n.linesSize,a=>l8(t.pairs[a],n))}function _Je(e,t,n,r){const i=function vJe(e,t,n){const r=wf.create(t,128,64,n);for(let i=0,o=e.pairs.length;in.textColor,()=>n.textSize,a=>l8(t.pairs[a],n))}function ace(e){return{pairs:[{loci:[e[0].loci,e[1].loci]}]}}function cce(e){return{triples:[{loci:[e[0].loci,e[1].loci,e[2].loci]}]}}function uce(e){return{quads:[{loci:[e[0].loci,e[1].loci,e[2].loci,e[3].loci]}]}}function lce(e){return{infos:[{loci:e[0].loci}]}}function dce(e){return{locis:e.map(t=>t.loci)}}function fce(e){return{locis:e.map(t=>t.loci)}}const SJe={...mE},pce={text:(e,t)=>Jo(IJe,vu.Utils)},hce={...SJe,scaleByRadius:C.Boolean(!0),visuals:C.MultiSelect(["text"],C.objectToOptions(pce)),snapshotKey:C.Text("",{isEssential:!0,disableInteractiveUpdates:!0,description:"Activate the snapshot with the provided key when clicking on the label"}),tooltip:C.Text("",{isEssential:!0,multiline:!0,disableInteractiveUpdates:!0,placeholder:"Tooltip",description:"Tooltip text to be displayed when hovering over the label"})},CJe=_e();function p8(e,t=!1){return e.label||dE(e.loci,{hidePrefix:!0,htmlStyling:!1,condensed:t})}function IJe(e,t,n,r){var i,o;const s=function AJe(e,t,n){const r=wf.create(t,128,64,n),i=t.customText.trim();for(let o=0,s=e.infos.length;oc:u?d=>u:d=>p8(t.infos[d]),qn.create(a,t,s,()=>n.textColor,()=>n.textSize,l)}const C0=v(),DJe=le.identity(),w0=new Float32Array(18),EJe=new Uint8Array([0,1,2,3,4,5]);v.zero(),v.zero();const _m=v(),MJe=v(),RJe=v(),kJe=v(),NJe=le.identity(),mce=new Float32Array(24),FJe=new Uint8Array([0,1,0,3,0,6,1,2,1,7,2,3,2,4,3,5,4,5,4,7,5,6,6,7]),OJe=le.identity(),gce=v();function h8(e,t,n,r,i,o){at.addPrimitive(e,function LJe(e,t,n,r,i){return v.add(gce,t,n),le.targetTo(e,t,gce,r),le.setTranslation(e,t),le.scale(e,e,i)}(OJe,t,n,r,i),_ie(o))}const m8={color:C.Color(xn.orange),scaleFactor:C.Numeric(1,{min:.1,max:10,step:.1}),radiusScale:C.Numeric(2,{min:.1,max:10,step:.1})},UJe={...Nt.Params,...m8},VJe={...Nt.Params,...m8},zJe={...Nt.Params,...m8},yce={axes:(e,t)=>Jo(HJe,Nt.Utils),box:(e,t)=>Jo($Je,Nt.Utils),ellipsoid:(e,t)=>Jo(KJe,Nt.Utils)},bce={...UJe,...VJe,...zJe,visuals:C.MultiSelect(["box"],C.objectToOptions(yce))};function HJe(e,t,n,r){const i=function jJe(e,t,n){const r=at.createState(256,128,n),i=De.getPrincipalAxesMany(e.locis);return Rs.scale(i.momentsAxes,i.momentsAxes,t.scaleFactor),r.currentGroup=0,function PJe(e,t,n,r,i){const{origin:o,dirA:s,dirB:a,dirC:c}=t;v.add(C0,o,s),v.toArray(v.add(C0,o,s),w0,0),v.toArray(v.sub(C0,o,s),w0,3),v.toArray(v.add(C0,o,a),w0,6),v.toArray(v.sub(C0,o,a),w0,9),v.toArray(v.add(C0,o,c),w0,12),v.toArray(v.sub(C0,o,c),w0,15);const u=fS(w0,EJe),l=Rs.volume(t),d=Math.cbrt(l)/300*n;at.addCage(e,DJe,u,d,r,i)}(r,i.momentsAxes,t.radiusScale,2,20),at.getMesh(r)}(t,n,r&&r.geometry),o=function GJe(e){return`Principal Axes of ${pE(e,{countsOnly:!0})}`}(t.locis);return qn.create(o,t,i,()=>n.color,()=>1,()=>o)}function $Je(e,t,n,r){const i=function WJe(e,t,n){const r=at.createState(256,128,n),i=De.getPrincipalAxesMany(e.locis);return Rs.scale(i.boxAxes,i.boxAxes,t.scaleFactor),r.currentGroup=0,function BJe(e,t,n,r,i){const{origin:o,dirA:s,dirB:a,dirC:c}=t,u=v.negate(MJe,s),l=v.negate(RJe,a),d=v.negate(kJe,c);let f=0;const p=function(y,b,x){v.copy(_m,o),v.add(_m,_m,y),v.add(_m,_m,b),v.add(_m,_m,x),v.toArray(_m,mce,f),f+=3};p(s,a,c),p(s,a,d),p(s,l,d),p(s,l,c),p(u,l,d),p(u,l,c),p(u,a,c),p(u,a,d);const m=fS(mce,FJe),h=Rs.volume(t),g=Math.cbrt(h)/300*n;at.addCage(e,NJe,m,g,r,i)}(r,i.boxAxes,t.radiusScale,2,20),at.getMesh(r)}(t,n,r&&r.geometry),o=function qJe(e){return`Oriented Box of ${pE(e,{countsOnly:!0})}`}(t.locis);return qn.create(o,t,i,()=>n.color,()=>1,()=>o)}function KJe(e,t,n,r){const i=function XJe(e,t,n){const r=at.createState(256,128,n),o=De.getPrincipalAxesMany(e.locis).boxAxes,{origin:s,dirA:a,dirB:c}=o,u=Rs.size(v(),o);v.scale(u,u,.5*t.scaleFactor);const l=v.create(u[2],u[1],u[0]);return r.currentGroup=0,h8(r,s,a,c,l,2),at.getMesh(r)}(t,n,r&&r.geometry),o=function YJe(e){return`Oriented Ellipsoid of ${pE(e,{countsOnly:!0})}`}(t.locis);return qn.create(o,t,i,()=>n.color,()=>1,()=>o)}const QJe={radius:1,segments:36,thetaStart:0,thetaLength:2*Math.PI};function vce(e){const{radius:t,segments:n,thetaStart:r,thetaLength:i}={...QJe,...e},o=i===2*Math.PI,s=o?n+1:n+2,a=new Float32Array(3*s),c=new Float32Array(3*s),u=new Uint32Array(3*n);a[0]=0,a[1]=0,a[2]=0,c[0]=0,c[1]=1,c[2]=0;for(let l=0,d=3;lJo(iet,di.Utils,{modifyState:n=>({...n,pickable:!1})}),arc:(e,t)=>Jo(set,di.Utils,{modifyState:n=>({...n,pickable:!1})}),sector:(e,t)=>Jo(cet,Nt.Utils,{modifyProps:n=>({...n,alpha:n.sectorOpacity}),modifyState:n=>({...n,markerActions:Us.Highlighting})}),text:(e,t)=>Jo(det,vu.Utils,{modifyState:n=>({...n,markerActions:Bt.None})})},Cce={...JJe,...eet,...tet,...mE,visuals:C.MultiSelect(["vectors","sector","text"],C.objectToOptions(Sce))},xm=v(),$S=le();function gE(e,t,n){const{sphereA:r,sphereB:i,sphereC:o}=t,{arcDirA:s,arcDirC:a,arcNormal:c}=t,[u,l,d]=e.loci;pn.getBoundingSphere(u,r),pn.getBoundingSphere(l,i),pn.getBoundingSphere(d,o),v.sub(s,r.center,i.center),v.sub(a,o.center,i.center),v.cross(c,s,a);const p=Math.min(v.magnitude(s),v.magnitude(a))*n;return t.radius=p,t.angle=v.angle(s,a),t}function wce(e,t){const{radius:n,angle:r}=e,i=t?PZ(r,n)/t:32;return le.targetTo($S,e.sphereB.center,e.sphereA.center,e.arcNormal),le.setTranslation($S,e.sphereB.center),le.mul($S,$S,le.rotY180),r5(vce({radius:n,thetaLength:r,segments:i}),$S)}const js=function net(){return{sphereA:_e(),sphereB:_e(),sphereC:_e(),arcDirA:v(),arcDirC:v(),arcNormal:v(),radius:0,angle:0}}();function yE(e){return 1===e.triples.length?`Angle ${d8(e.triples[0],{measureOnly:!0})}`:`${e.triples.length} Angles`}function iet(e,t,n,r){const i=function ret(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.triples.length;in.color,()=>n.linesSize,()=>"")}function set(e,t,n,r){const i=function oet(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.triples.length;in.color,()=>n.linesSize,()=>"")}function cet(e,t,n,r){const i=function aet(e,t,n){const r=at.createState(128,64,n);for(let i=0,o=e.triples.length;in.color,()=>1,a=>d8(t.triples[a]))}function det(e,t,n,r){const i=function uet(e,t,n){const r=wf.create(t,128,64,n);for(let i=0,o=e.triples.length;in.textColor,()=>n.textSize,a=>d8(t.triples[a]))}const Ace={color:C.Color(xn.lightgreen),arcScale:C.Numeric(.7,{min:.01,max:1,step:.01})},bE={...di.Params,...Ace,lineSizeAttenuation:C.Boolean(!0),linesSize:C.Numeric(.04,{min:.01,max:5,step:.01}),dashLength:C.Numeric(.04,{min:.01,max:.2,step:.01})},pet={...bE},het={...bE},met={...bE},get={...bE},yet={...Nt.Params,...Ace,ignoreLight:C.Boolean(!0),sectorOpacity:C.Numeric(.75,{min:0,max:1,step:.01})},Ice={vectors:(e,t)=>Jo(_et,di.Utils,{modifyState:n=>({...n,pickable:!1})}),extenders:(e,t)=>Jo(Tet,di.Utils,{modifyState:n=>({...n,pickable:!1})}),connector:(e,t)=>Jo(Cet,di.Utils,{modifyState:n=>({...n,pickable:!1})}),arms:(e,t)=>Jo(Aet,di.Utils,{modifyState:n=>({...n,pickable:!1})}),arc:(e,t)=>Jo(Eet,di.Utils,{modifyState:n=>({...n,pickable:!1})}),sector:(e,t)=>Jo(Met,Nt.Utils,{modifyProps:n=>({...n,alpha:n.sectorOpacity}),modifyState:n=>({...n,markerActions:Us.Highlighting})}),text:(e,t)=>Jo(ket,vu.Utils,{modifyState:n=>({...n,markerActions:Bt.None})})},Tce={...pet,...het,...met,...get,...yet,...mE,visuals:C.MultiSelect(["extenders","arms","sector","text"],C.objectToOptions(Ice))},Da=v(),YS=le();function A0(e,t,n){const{sphereA:r,sphereB:i,sphereC:o,sphereD:s,dirBA:a,dirCD:c,projA:u,projD:l}=t,{arcPointA:d,arcPointD:f,arcDirA:p,arcDirD:m,arcCenter:h,arcNormal:g}=t,[y,b,x,_]=e.loci;pn.getBoundingSphere(y,r),pn.getBoundingSphere(b,i),pn.getBoundingSphere(x,o),pn.getBoundingSphere(_,s),v.add(h,i.center,o.center),v.scale(h,h,.5),v.sub(a,r.center,i.center),v.sub(c,s.center,o.center),v.add(d,h,a),v.add(f,h,c),v.sub(g,o.center,i.center),v.orthogonalize(p,g,a),v.orthogonalize(m,g,c),v.projectPointOnVector(u,d,p,h),v.projectPointOnVector(l,f,m,h);const A=Math.min(v.distance(u,h),v.distance(l,h))*n;v.setMagnitude(p,p,A),v.setMagnitude(m,m,A),v.add(d,h,p),v.add(f,h,m),t.radius=A,t.angle=v.dihedralAngle(r.center,i.center,o.center,s.center),v.matchDirection(Da,g,v.sub(Da,d,r.center));const E=v.angle(a,Da),w=A/Math.cos(E-Wx);v.add(u,i.center,v.setMagnitude(Da,a,w)),v.matchDirection(Da,g,v.sub(Da,f,s.center));const D=v.angle(c,Da),I=A/Math.cos(D-Wx);return v.add(l,o.center,v.setMagnitude(Da,c,I)),t}function Dce(e,t){const{radius:n,angle:r}=e,i=t?PZ(r,n)/t:32;return le.targetTo(YS,e.arcCenter,r<0?e.arcPointD:e.arcPointA,e.arcNormal),le.setTranslation(YS,e.arcCenter),le.mul(YS,YS,le.rotY180),r5(vce({radius:n,thetaLength:Math.abs(r),segments:i}),YS)}const Xr=function bet(){return{sphereA:_e(),sphereB:_e(),sphereC:_e(),sphereD:_e(),dirBA:v(),dirCD:v(),projA:v(),projD:v(),arcPointA:v(),arcPointD:v(),arcDirA:v(),arcDirD:v(),arcCenter:v(),arcNormal:v(),radius:0,angle:0}}();function I0(e){return 1===e.quads.length?`Dihedral ${f8(e.quads[0],{measureOnly:!0})}`:`${e.quads.length} Dihedrals`}function _et(e,t,n,r){const i=function vet(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.quads.length;in.color,()=>n.linesSize,()=>"")}function Cet(e,t,n,r){const i=function xet(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.quads.length;in.color,()=>n.linesSize,()=>"")}function Aet(e,t,n,r){const i=function wet(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.quads.length;in.color,()=>n.linesSize,()=>"")}function Tet(e,t,n,r){const i=function Iet(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.quads.length;in.color,()=>n.linesSize,()=>"")}function Eet(e,t,n,r){const i=function Det(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.quads.length;in.color,()=>n.linesSize,()=>"")}function Met(e,t,n,r){const i=function Pet(e,t,n){const r=at.createState(128,64,n);for(let i=0,o=e.quads.length;in.color,()=>1,a=>f8(t.quads[a]))}function ket(e,t,n,r){const i=function Ret(e,t,n){const r=wf.create(t,128,64,n);for(let i=0,o=e.quads.length;in.textColor,()=>n.textSize,a=>f8(t.quads[a]))}const Fet=Rt.BuiltIn({name:"box-shape-3d",display:"Box Shape",from:pe.Root,to:pe.Shape.Provider,params:{bottomLeft:C.Vec3(v()),topRight:C.Vec3(v.create(1,1,1)),radius:C.Numeric(.15,{min:.01,max:4,step:.01}),color:C.Color(xn.red)}})({canAutoUpdate:()=>!0,apply:({params:e})=>Oe.create("Shape Representation",function(){var t=ie(function*(n){return new pe.Shape.Provider({label:"Box",data:e,params:Nt.Params,getShape:(r,i)=>{const o=g8(St.create(e.bottomLeft,e.topRight),e.radius);return qn.create("Box",i,o,()=>i.color,()=>1,()=>"Box")},geometryUtils:Nt.Utils},{label:"Box"})});return function(n){return t.apply(this,arguments)}}())});function g8(e,t,n){const r=v.sub(v(),e.max,e.min),i=le.fromTranslation(le(),v.create(.5,.5,.5)),o=le.fromScaling(le(),r),s=le.fromTranslation(le(),e.min),a=le.mul3(le(),s,o,i),c=at.createState(256,128,n);c.currentGroup=1,at.addCage(c,a,Uie(),t,2,20);const u=at.getMesh(c),l=v.scaleAndAdd(v(),e.min,r,.5),d=v.distance(e.min,l);return u.setBoundingSphere(_e.create(l,d)),u}const Ece={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])};new Uint32Array([0,1,2,3,3,1,2,0]);const Let={...Nt.Params,color:C.Color(xn.orange),scaleFactor:C.Numeric(1,{min:.1,max:10,step:.1})},Pce={plane:(e,t)=>Jo(zet,Nt.Utils)},Mce={...Let,visuals:C.MultiSelect(["plane"],C.objectToOptions(Pce))},Sm=le(),y8=v();function zet(e,t,n,r){const i=function Vet(e,t,n){const r=at.createState(256,128,n),o=De.getPrincipalAxesMany(e.locis).boxAxes,s=function Oet(){return Ece}();return v.add(y8,o.origin,o.dirC),le.targetTo(Sm,y8,o.origin,o.dirB),le.scale(Sm,Sm,Rs.size(y8,o)),le.scaleUniformly(Sm,Sm,t.scaleFactor),le.setTranslation(Sm,o.origin),r.currentGroup=0,at.addPrimitive(r,Sm,s),at.addPrimitiveFlipped(r,Sm,s),at.getMesh(r)}(t,n,r&&r.geometry),o=function Uet(e){return`Best Fit Plane of ${pE(e,{countsOnly:!0})}`}(t.locis);return qn.create(o,t,i,()=>n.color,()=>1,()=>o)}const vE=Rt.BuiltIn({name:"structure-representation-3d",display:"3D Representation",from:pe.Molecule.Structure,to:pe.Molecule.Structure.Representation3D,params:(e,t)=>{const{registry:n,themes:r}=t.representation.structure,i=n.get(n.default.name);if(!e){const a={help:c=>{const{name:u,params:l}=c,f=r.colorThemeRegistry.get(u).factory({},l);return{description:f.description,legend:f.legend}}};return{type:C.Mapped(n.default.name,n.types,c=>C.Group(n.get(c).getParams(r,Ve.Empty))),colorTheme:C.Mapped(i.defaultColorTheme.name,r.colorThemeRegistry.types,c=>C.Group(r.colorThemeRegistry.get(c).getParams({structure:Ve.Empty})),a),sizeTheme:C.Mapped(i.defaultSizeTheme.name,r.sizeThemeRegistry.types,c=>C.Group(r.sizeThemeRegistry.get(c).getParams({structure:Ve.Empty})))}}const o={structure:e.data},s={help:a=>{const{name:c,params:u}=a,d=r.colorThemeRegistry.get(c).factory(o,u);return{description:d.description,legend:d.legend}}};return{type:C.Mapped(n.default.name,n.getApplicableTypes(e.data),a=>C.Group(n.get(a).getParams(r,e.data))),colorTheme:C.Mapped(i.defaultColorTheme.name,r.colorThemeRegistry.getApplicableTypes(o),a=>C.Group(r.colorThemeRegistry.get(a).getParams(o)),s),sizeTheme:C.Mapped(i.defaultSizeTheme.name,r.sizeThemeRegistry.getApplicableTypes(o),a=>C.Group(r.sizeThemeRegistry.get(a).getParams(o)))}}})({canAutoUpdate:({a:e,oldParams:t,newParams:n})=>e.data.elementCount<1e4||t.type.name===n.type.name&&"custom"!==n.type.params.quality,apply:({a:e,params:t},r)=>Oe.create("Structure Representation",function(){var i=ie(function*(o){var s,a;const c={runtime:o,assetManager:r.managers.asset},u=r.representation.structure.registry.get(t.type.name),l=(null===(s=u.getData)||void 0===s?void 0:s.call(u,e.data,t.type.params))||e.data;u.ensureCustomProperties&&(yield u.ensureCustomProperties.attach(c,l));const d=u.factory({webgl:null===(a=r.canvas3d)||void 0===a?void 0:a.webgl,...r.representation.structure.themes},u.getParams);yield Fo.ensureDependencies(c,r.representation.structure.themes,{structure:l},t),d.setTheme(Fo.create(r.representation.structure.themes,{structure:l},t));const f=t.type.params||{};return yield d.createOrUpdate(f,l).runInContext(o),new pe.Molecule.Structure.Representation3D({repr:d,sourceData:e.data},{label:u.label})});return function(o){return i.apply(this,arguments)}}()),update:({a:e,b:t,oldParams:n,newParams:r},o)=>Oe.create("Structure Representation",function(){var s=ie(function*(a){var c,u;if(r.type.name!==n.type.name)return Qe.UpdateResult.Recreate;const l=o.representation.structure.registry.get(r.type.name);if(null!==(c=l.mustRecreate)&&void 0!==c&&c.call(l,n.type.params,r.type.params))return Qe.UpdateResult.Recreate;const d=(null===(u=l.getData)||void 0===u?void 0:u.call(l,e.data,r.type.params))||e.data,f={runtime:a,assetManager:o.managers.asset};l.ensureCustomProperties&&(yield l.ensureCustomProperties.attach(f,d)),Fo.releaseDependencies(o.representation.structure.themes,{structure:t.data.sourceData},n),yield Fo.ensureDependencies(f,o.representation.structure.themes,{structure:d},r),t.data.repr.setTheme(Fo.create(o.representation.structure.themes,{structure:d},r));const p={...t.data.repr.props,...r.type.params};return yield t.data.repr.createOrUpdate(p,d).runInContext(a),t.data.sourceData=e.data,Qe.UpdateResult.Updated});return function(a){return s.apply(this,arguments)}}()),dispose({b:e,params:t},n){if(!e||!t)return;const r=e.data.sourceData,i=n.representation.structure.registry.get(t.type.name);i.ensureCustomProperties&&i.ensureCustomProperties.detach(r),Fo.releaseDependencies(n.representation.structure.themes,{structure:r},t)},interpolate(e,t,n){if("uniform"!==e.colorTheme.name||"uniform"!==t.colorTheme.name)return n<=.5?e:t;const o=st.interpolate(e.colorTheme.params.value,t.colorTheme.params.value,n);return{type:n<=.5?e.type:t.type,colorTheme:{name:"uniform",params:{value:o}},sizeTheme:n<=.5?e.sizeTheme:t.sizeTheme}}}),jet=Rt.BuiltIn({name:"unwind-structure-assembly-representation-3d",display:"Unwind Assembly 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:{t:C.Numeric(0,{min:0,max:1,step:.01})}})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=new Vv(n);return jae(n,r,t.t),new pe.Molecule.Structure.Representation3DState({state:{unitTransforms:r},initialState:{unitTransforms:new Vv(n)},info:n,repr:e.data.repr},{label:`Unwind T = ${t.t.toFixed(2)}`})},update({a:e,b:t,newParams:n,oldParams:r}){const i=t.data.info;return e.data.sourceData!==i||e.data.repr!==t.data.repr?Qe.UpdateResult.Recreate:r.t===n.t?Qe.UpdateResult.Unchanged:(jae(i,t.data.state.unitTransforms,n.t),t.label=`Unwind T = ${n.t.toFixed(2)}`,t.data.repr=e.data.repr,Qe.UpdateResult.Updated)}}),Het=Rt.BuiltIn({name:"explode-structure-representation-3d",display:"Explode 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:{t:C.Numeric(0,{min:0,max:1,step:.01})}})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=new Vv(n);return qae(n,r,t.t,n.root.boundary.sphere),new pe.Molecule.Structure.Representation3DState({state:{unitTransforms:r},initialState:{unitTransforms:new Vv(n)},info:n,repr:e.data.repr},{label:`Explode T = ${t.t.toFixed(2)}`})},update({a:e,b:t,newParams:n,oldParams:r}){const i=e.data.sourceData;return t.data.info!==i||e.data.repr!==t.data.repr?Qe.UpdateResult.Recreate:r.t===n.t?Qe.UpdateResult.Unchanged:(qae(i,t.data.state.unitTransforms,n.t,i.root.boundary.sphere),t.label=`Explode T = ${n.t.toFixed(2)}`,t.data.repr=e.data.repr,Qe.UpdateResult.Updated)}}),qet=Rt.BuiltIn({name:"spin-structure-representation-3d",display:"Spin 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:{t:C.Numeric(0,{min:0,max:1,step:.01}),...JQe}})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=new Vv(n),{axis:i,origin:o}=Wae(n.root,t);return Xae(n,r,t.t,i,o),new pe.Molecule.Structure.Representation3DState({state:{unitTransforms:r},initialState:{unitTransforms:new Vv(n)},info:n,repr:e.data.repr},{label:`Spin T = ${t.t.toFixed(2)}`})},update({a:e,b:t,newParams:n,oldParams:r}){const i=e.data.sourceData;if(t.data.info!==i||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;if(r.t===n.t&&r.axis===n.axis&&r.origin===n.origin)return Qe.UpdateResult.Unchanged;const o=t.data.state.unitTransforms,{axis:s,origin:a}=Wae(i.root,n);return Xae(i,o,n.t,s,a),t.label=`Spin T = ${n.t.toFixed(2)}`,t.data.repr=e.data.repr,Qe.UpdateResult.Updated}}),Wet=Rt.BuiltIn({name:"overpaint-structure-representation-3d-from-script",display:"Overpaint 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({script:C.Script(ko("(sel.atom.all)","mol-script")),color:C.Color(xn.blueviolet),clear:C.Boolean(!1)},e=>`${e.clear?"Clear":st.toRgbString(e.color)}`,{defaultValue:[{script:ko("(sel.atom.all)","mol-script"),color:xn.blueviolet,clear:!1}]})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=e.data.repr.geometryVersion,i=Bo.ofScript(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{overpaint:i},initialState:{overpaint:Bo.Empty},info:{structure:n,geometryVersion:r},repr:e.data.repr},{label:`Overpaint (${i.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info,o=e.data.sourceData;if(o!==i.structure||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const s=e.data.repr.geometryVersion;if(s!==i.geometryVersion&&Tp(e.data.repr.props))return Qe.UpdateResult.Recreate;const a=t.data.state.overpaint,c=Bo.ofScript(n.layers,o);return Bo.areEqual(a,c)?Qe.UpdateResult.Unchanged:(i.geometryVersion=s,t.data.state.overpaint=c,t.data.repr=e.data.repr,t.label=`Overpaint (${c.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),$et=Rt.BuiltIn({name:"overpaint-structure-representation-3d-from-bundle",display:"Overpaint 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({bundle:C.Value(Kn.Empty),color:C.Color(xn.blueviolet),clear:C.Boolean(!1)},e=>`${e.clear?"Clear":st.toRgbString(e.color)}`,{defaultValue:[{bundle:Kn.Empty,color:xn.blueviolet,clear:!1}],isHidden:!0})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=e.data.repr.geometryVersion,i=Bo.ofBundle(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{overpaint:i},initialState:{overpaint:Bo.Empty},info:{structure:n,geometryVersion:r},repr:e.data.repr},{label:`Overpaint (${i.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info,o=e.data.sourceData;if(o!==i.structure||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const s=e.data.repr.geometryVersion;if(s!==i.geometryVersion&&Tp(e.data.repr.props))return Qe.UpdateResult.Recreate;const a=t.data.state.overpaint,c=Bo.ofBundle(n.layers,o);return Bo.areEqual(a,c)?Qe.UpdateResult.Unchanged:(i.geometryVersion=s,t.data.state.overpaint=c,t.data.repr=e.data.repr,t.label=`Overpaint (${c.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),Yet=Rt.BuiltIn({name:"transparency-structure-representation-3d-from-script",display:"Transparency 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({script:C.Script(ko("(sel.atom.all)","mol-script")),value:C.Numeric(.5,{min:0,max:1,step:.01},{label:"Transparency"})},e=>`Transparency (${e.value})`,{defaultValue:[{script:ko("(sel.atom.all)","mol-script"),value:.5}]})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=e.data.repr.geometryVersion,i=Vs.ofScript(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{transparency:i},initialState:{transparency:Vs.Empty},info:{structure:n,geometryVersion:r},repr:e.data.repr},{label:`Transparency (${i.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info,o=e.data.sourceData;if(o!==i.structure||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const s=e.data.repr.geometryVersion;if(s!==i.geometryVersion&&Tp(e.data.repr.props))return Qe.UpdateResult.Recreate;const a=t.data.state.transparency,c=Vs.ofScript(n.layers,o);return Vs.areEqual(a,c)?Qe.UpdateResult.Unchanged:(i.geometryVersion=s,t.data.state.transparency=c,t.data.repr=e.data.repr,t.label=`Transparency (${c.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),Xet=Rt.BuiltIn({name:"transparency-structure-representation-3d-from-bundle",display:"Transparency 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({bundle:C.Value(Kn.Empty),value:C.Numeric(.5,{min:0,max:1,step:.01},{label:"Transparency"})},e=>`Transparency (${e.value})`,{defaultValue:[{bundle:Kn.Empty,value:.5}],isHidden:!0})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=e.data.repr.geometryVersion,i=Vs.ofBundle(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{transparency:i},initialState:{transparency:Vs.Empty},info:{structure:n,geometryVersion:r},repr:e.data.repr},{label:`Transparency (${i.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info,o=e.data.sourceData;if(o!==i.structure||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const s=e.data.repr.geometryVersion;if(s!==i.geometryVersion&&Tp(e.data.repr.props))return Qe.UpdateResult.Recreate;const a=t.data.state.transparency,c=Vs.ofBundle(n.layers,o);return Vs.areEqual(a,c)?Qe.UpdateResult.Unchanged:(i.geometryVersion=s,t.data.state.transparency=c,t.data.repr=e.data.repr,t.label=`Transparency (${c.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),Ket=Rt.BuiltIn({name:"substance-structure-representation-3d-from-script",display:"Substance 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({script:C.Script(ko("(sel.atom.all)","mol-script")),material:ba.getParam(),clear:C.Boolean(!1)},e=>`${e.clear?"Clear":ba.toString(e.material)}`,{defaultValue:[{script:ko("(sel.atom.all)","mol-script"),material:ba({roughness:1}),clear:!1}]})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=e.data.repr.geometryVersion,i=zs.ofScript(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{substance:i},initialState:{substance:zs.Empty},info:{structure:n,geometryVersion:r},repr:e.data.repr},{label:`Substance (${i.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info,o=e.data.sourceData;if(o!==i.structure||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const s=e.data.repr.geometryVersion;if(s!==i.geometryVersion&&Tp(e.data.repr.props))return Qe.UpdateResult.Recreate;const a=t.data.state.substance,c=zs.ofScript(n.layers,o);return zs.areEqual(a,c)?Qe.UpdateResult.Unchanged:(i.geometryVersion=s,t.data.state.substance=c,t.data.repr=e.data.repr,t.label=`Substance (${c.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),Zet=Rt.BuiltIn({name:"substance-structure-representation-3d-from-bundle",display:"Substance 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({bundle:C.Value(Kn.Empty),material:ba.getParam(),clear:C.Boolean(!1)},e=>`${e.clear?"Clear":ba.toString(e.material)}`,{defaultValue:[{bundle:Kn.Empty,material:ba({roughness:1}),clear:!1}],isHidden:!0})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=e.data.repr.geometryVersion,i=zs.ofBundle(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{substance:i},initialState:{substance:zs.Empty},info:{structure:n,geometryVersion:r},repr:e.data.repr},{label:`Substance (${i.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info,o=e.data.sourceData;if(o!==i.structure||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const s=e.data.repr.geometryVersion;if(s!==i.geometryVersion&&Tp(e.data.repr.props))return Qe.UpdateResult.Recreate;const a=t.data.state.substance,c=zs.ofBundle(n.layers,o);return zs.areEqual(a,c)?Qe.UpdateResult.Unchanged:(i.geometryVersion=s,t.data.state.substance=c,t.data.repr=e.data.repr,t.label=`Substance (${c.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),Qet=Rt.BuiltIn({name:"clipping-structure-representation-3d-from-script",display:"Clipping 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({script:C.Script(ko("(sel.atom.all)","mol-script")),groups:C.Converted(e=>Yr.Groups.toNames(e),e=>Yr.Groups.fromNames(e),C.MultiSelect(NI(Yr.Groups.Names),C.objectToOptions(Yr.Groups.Names)))},e=>`${Yr.Groups.toNames(e.groups).length} group(s)`,{defaultValue:[{script:ko("(sel.atom.all)","mol-script"),groups:Yr.Groups.Flag.None}]})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=Yr.ofScript(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{clipping:r},initialState:{clipping:Yr.Empty},info:n,repr:e.data.repr},{label:`Clipping (${r.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info;if(e.data.sourceData!==i||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const o=t.data.state.clipping,s=Yr.ofScript(n.layers,i);return Yr.areEqual(o,s)?Qe.UpdateResult.Unchanged:(t.data.state.clipping=s,t.data.repr=e.data.repr,t.label=`Clipping (${s.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),Jet=Rt.BuiltIn({name:"clipping-structure-representation-3d-from-bundle",display:"Clipping 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({bundle:C.Value(Kn.Empty),groups:C.Converted(e=>Yr.Groups.toNames(e),e=>Yr.Groups.fromNames(e),C.MultiSelect(NI(Yr.Groups.Names),C.objectToOptions(Yr.Groups.Names)))},e=>`${Yr.Groups.toNames(e.groups).length} group(s)`,{defaultValue:[{bundle:Kn.Empty,groups:Yr.Groups.Flag.None}],isHidden:!0})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=Yr.ofBundle(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{clipping:r},initialState:{clipping:Yr.Empty},info:n,repr:e.data.repr},{label:`Clipping (${r.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info;if(e.data.sourceData!==i||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const o=t.data.state.clipping,s=Yr.ofBundle(n.layers,i);return Yr.areEqual(o,s)?Qe.UpdateResult.Unchanged:(t.data.state.clipping=s,t.data.repr=e.data.repr,t.label=`Clipping (${s.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),ett=Rt.BuiltIn({name:"theme-strength-representation-3d",display:"Theme Strength 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({overpaintStrength:C.Numeric(1,{min:0,max:1,step:.01}),transparencyStrength:C.Numeric(1,{min:0,max:1,step:.01}),substanceStrength:C.Numeric(1,{min:0,max:1,step:.01})})})({canAutoUpdate:()=>!0,apply:({a:e,params:t})=>new pe.Molecule.Structure.Representation3DState({state:{themeStrength:{overpaint:t.overpaintStrength,transparency:t.transparencyStrength,substance:t.substanceStrength}},initialState:{themeStrength:{overpaint:1,transparency:1,substance:1}},info:{},repr:e.data.repr},{label:"Theme Strength",description:`${t.overpaintStrength.toFixed(2)}, ${t.transparencyStrength.toFixed(2)}, ${t.substanceStrength.toFixed(2)}`}),update({a:e,b:t,newParams:n}){var i,o,s;return n.overpaintStrength===(null===(i=t.data.state.themeStrength)||void 0===i?void 0:i.overpaint)&&n.transparencyStrength===(null===(o=t.data.state.themeStrength)||void 0===o?void 0:o.transparency)&&n.substanceStrength===(null===(s=t.data.state.themeStrength)||void 0===s?void 0:s.substance)?Qe.UpdateResult.Unchanged:(t.data.state.themeStrength={overpaint:n.overpaintStrength,transparency:n.transparencyStrength,substance:n.substanceStrength},t.data.repr=e.data.repr,t.label="Theme Strength",t.description=`${n.overpaintStrength.toFixed(2)}, ${n.transparencyStrength.toFixed(2)}, ${n.substanceStrength.toFixed(2)}`,Qe.UpdateResult.Updated)},interpolate:(e,t,n)=>({overpaintStrength:ci(e.overpaintStrength,t.overpaintStrength,n),transparencyStrength:ci(e.transparencyStrength,t.transparencyStrength,n),substanceStrength:ci(e.substanceStrength,t.substanceStrength,n)})});var Af;!function(e){e.getDefaultParams=function t(i,o,s,a,c,u,l,d){const f=i.representation.volume.registry.get(o),p=i.representation.volume.themes.colorThemeRegistry.get(c||f.defaultColorTheme.name),m=i.representation.volume.themes.sizeThemeRegistry.get(l||f.defaultSizeTheme.name),h=C.getDefaultValues(f.getParams(i.representation.volume.themes,s));return{type:{name:o,params:a?{...h,...a}:h},colorTheme:{name:p.name,params:u?{...p.defaultValues,...u}:p.defaultValues},sizeTheme:{name:m.name,params:d?{...m.defaultValues,...d}:m.defaultValues}}},e.getDefaultParamsStatic=function n(i,o,s,a,c,u,l){const d=i.representation.volume.registry.get(o),f=i.representation.volume.themes.colorThemeRegistry.get(a||d.defaultColorTheme.name),p=i.representation.volume.themes.sizeThemeRegistry.get(u||d.defaultSizeTheme.name);return{type:{name:o,params:s?{...d.defaultValues,...s}:d.defaultValues},colorTheme:{name:d.defaultColorTheme.name,params:c?{...f.defaultValues,...c}:f.defaultValues},sizeTheme:{name:d.defaultSizeTheme.name,params:l?{...p.defaultValues,...l}:p.defaultValues}}},e.getDescription=function r(i){var o,s,a,c;return i.isoValue?et.IsoValue.toString(i.isoValue):null!==(s=null===(o=i.renderMode)||void 0===o?void 0:o.params)&&void 0!==s&&s.isoValue?et.IsoValue.toString(null===(c=null===(a=i.renderMode)||void 0===a?void 0:a.params)||void 0===c?void 0:c.isoValue):void 0}}(Af||(Af={}));const ttt=Rt.BuiltIn({name:"volume-representation-3d",display:"3D Representation",from:pe.Volume.Data,to:pe.Volume.Representation3D,params:(e,t)=>{const{registry:n,themes:r}=t.representation.volume,i=n.get(n.default.name);if(!e)return{type:C.Mapped(n.default.name,n.types,s=>C.Group(n.get(s).getParams(r,et.One))),colorTheme:C.Mapped(i.defaultColorTheme.name,r.colorThemeRegistry.types,s=>C.Group(r.colorThemeRegistry.get(s).getParams({volume:et.One}))),sizeTheme:C.Mapped(i.defaultSizeTheme.name,r.sizeThemeRegistry.types,s=>C.Group(r.sizeThemeRegistry.get(s).getParams({volume:et.One})))};const o={volume:e.data};return{type:C.Mapped(n.default.name,n.types,s=>C.Group(n.get(s).getParams(r,e.data))),colorTheme:C.Mapped(i.defaultColorTheme.name,r.colorThemeRegistry.getApplicableTypes(o),s=>C.Group(r.colorThemeRegistry.get(s).getParams(o))),sizeTheme:C.Mapped(i.defaultSizeTheme.name,r.sizeThemeRegistry.getApplicableTypes(o),s=>C.Group(r.sizeThemeRegistry.get(s).getParams(o)))}}})({canAutoUpdate:({oldParams:e,newParams:t})=>e.type.name===t.type.name,apply:({a:e,params:t},n)=>Oe.create("Volume Representation",function(){var r=ie(function*(i){var o;const s={runtime:i,assetManager:n.managers.asset},a=n.representation.volume.registry.get(t.type.name);a.ensureCustomProperties&&(yield a.ensureCustomProperties.attach(s,e.data));const c=a.factory({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.volume.themes},a.getParams);c.setTheme(Fo.create(n.representation.volume.themes,{volume:e.data},t));const u=t.type.params||{};return yield c.createOrUpdate(u,e.data).runInContext(i),new pe.Volume.Representation3D({repr:c,sourceData:e.data},{label:a.label,description:Af.getDescription(u)})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,oldParams:n,newParams:r},i)=>Oe.create("Volume Representation",function(){var o=ie(function*(s){var a;if(r.type.name!==n.type.name)return null===(a=i.representation.volume.registry.get(n.type.name).ensureCustomProperties)||void 0===a||a.detach(e.data),Qe.UpdateResult.Recreate;const c={...t.data.repr.props,...r.type.params};return t.data.repr.setTheme(Fo.create(i.representation.volume.themes,{volume:e.data},r)),yield t.data.repr.createOrUpdate(c,e.data).runInContext(s),t.data.sourceData=e.data,t.description=Af.getDescription(c),Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),ntt=Rt.BuiltIn({name:"shape-representation-3d",display:"3D Representation",from:pe.Shape.Provider,to:pe.Shape.Representation3D,params:(e,t)=>e?e.data.params:rt.Params})({canAutoUpdate:()=>!0,apply:({a:e,params:t},n)=>Oe.create("Shape Representation",function(){var r=ie(function*(i){const o={...C.getDefaultValues(e.data.params),...t},s=Jo(e.data.getShape,e.data.geometryUtils);return yield s.createOrUpdate(o,e.data.data).runInContext(i),new pe.Shape.Representation3D({repr:s,sourceData:e.data},{label:e.data.label})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Shape Representation",function(){var o=ie(function*(s){const a={...t.data.repr.props,...r};return yield t.data.repr.createOrUpdate(a,e.data.data).runInContext(s),t.data.sourceData=e.data,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),rtt=Rt.BuiltIn({name:"model-unitcell-3d",display:"Model Unit Cell",from:pe.Molecule.Model,to:pe.Shape.Representation3D,params:()=>({...Zae})})({isApplicable:e=>!!no.Provider.get(e.data),canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Model Unit Cell",function(){var r=ie(function*(i){var o;const s=no.Provider.get(e.data);if(!s)return li.Null;const a=Qae(e.data,s,t),c=function cJe(e,t){return yn.createMulti("Unit Cell",e,t,yn.StateBuilder,oJe)}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>Zae);return yield c.createOrUpdate(t,a).runInContext(i),new pe.Shape.Representation3D({repr:c,sourceData:a},{label:"Unit Cell",description:s.spacegroup.name})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:n})=>Oe.create("Model Unit Cell",function(){var r=ie(function*(i){const o=no.Provider.get(e.data);if(!o)return Qe.UpdateResult.Null;const s={...t.data.repr.props,...n},a=Qae(e.data,o,s);return yield t.data.repr.createOrUpdate(s,a).runInContext(i),t.data.sourceData=a,Qe.UpdateResult.Updated});return function(i){return r.apply(this,arguments)}}())}),itt=Rt.BuiltIn({name:"structure-bounding-box-3d",display:"Bounding Box",from:pe.Molecule.Structure,to:pe.Shape.Representation3D,params:{radius:C.Numeric(.05,{min:.01,max:4,step:.01},{isEssential:!0}),color:C.Color(xn.red,{isEssential:!0}),...Nt.Params}})({canAutoUpdate:()=>!0,apply:({a:e,params:t},n)=>Oe.create("Bounding Box",function(){var r=ie(function*(i){const o=Jo((s,a,c,u)=>{const l=g8(a.box,a.radius,u?.geometry);return qn.create("Bouding Box",a,l,()=>a.color,()=>1,()=>"Bounding Box")},Nt.Utils);return yield o.createOrUpdate(t,{box:e.data.boundary.box,radius:t.radius,color:t.color}).runInContext(i),new pe.Shape.Representation3D({repr:o,sourceData:e.data},{label:"Bounding Box"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Bounding Box",function(){var o=ie(function*(s){return yield t.data.repr.createOrUpdate(r,{box:e.data.boundary.box,radius:r.radius,color:r.color}).runInContext(s),t.data.sourceData=e.data,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),ott=Rt.BuiltIn({name:"structure-selections-distance-3d",display:"3D Distance",from:pe.Molecule.Structure.Selections,to:pe.Shape.Representation3D,params:()=>({...ice})})({canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Structure Distance",function(){var r=ie(function*(i){var o;const s=ace(e.data),a=function xJe(e,t){return yn.createMulti("Distance",e,t,yn.StateBuilder,rce)}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>ice);return yield a.createOrUpdate(t,s).runInContext(i),new pe.Shape.Representation3D({repr:a,sourceData:s},{label:"Distance"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Structure Distance",function(){var o=ie(function*(s){const a={...t.data.repr.props,...r},c=ace(e.data);return yield t.data.repr.createOrUpdate(a,c).runInContext(s),t.data.sourceData=c,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),stt=Rt.BuiltIn({name:"structure-selections-angle-3d",display:"3D Angle",from:pe.Molecule.Structure.Selections,to:pe.Shape.Representation3D,params:()=>({...Cce})})({canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Structure Angle",function(){var r=ie(function*(i){var o;const s=cce(e.data),a=function fet(e,t){return yn.createMulti("Angle",e,t,yn.StateBuilder,Sce)}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>Cce);return yield a.createOrUpdate(t,s).runInContext(i),new pe.Shape.Representation3D({repr:a,sourceData:s},{label:"Angle"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Structure Angle",function(){var o=ie(function*(s){const a={...t.data.repr.props,...r},c=cce(e.data);return yield t.data.repr.createOrUpdate(a,c).runInContext(s),t.data.sourceData=c,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),att=Rt.BuiltIn({name:"structure-selections-dihedral-3d",display:"3D Dihedral",from:pe.Molecule.Structure.Selections,to:pe.Shape.Representation3D,params:()=>({...Tce})})({canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Structure Dihedral",function(){var r=ie(function*(i){var o;const s=uce(e.data),a=function Net(e,t){return yn.createMulti("Dihedral",e,t,yn.StateBuilder,Ice)}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>Tce);return yield a.createOrUpdate(t,s).runInContext(i),new pe.Shape.Representation3D({repr:a,sourceData:s},{label:"Dihedral"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Structure Dihedral",function(){var o=ie(function*(s){const a={...t.data.repr.props,...r},c=uce(e.data);return yield t.data.repr.createOrUpdate(a,c).runInContext(s),t.data.sourceData=c,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),ctt=Rt.BuiltIn({name:"structure-selections-label-3d",display:"3D Label",from:pe.Molecule.Structure.Selections,to:pe.Shape.Representation3D,params:()=>({...hce})})({canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Structure Label",function(){var r=ie(function*(i){var o,s,a;const c=lce(e.data),u=function TJe(e,t){return yn.createMulti("Label",e,t,yn.StateBuilder,pce)}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>hce);yield u.createOrUpdate(t,c).runInContext(i);const l=!!(null!==(s=t.snapshotKey)&&void 0!==s&&s.trim()||null!==(a=t.tooltip)&&void 0!==a&&a.trim());return u.setState({pickable:l,markerActions:l?Us.Highlighting:Bt.None}),new pe.Shape.Representation3D({repr:u,sourceData:c},{label:"Label"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Structure Label",function(){var o=ie(function*(s){var a,c;const u={...t.data.repr.props,...r},l=lce(e.data);yield t.data.repr.createOrUpdate(u,l).runInContext(s),t.data.sourceData=l;const d=!!(null!==(a=r.snapshotKey)&&void 0!==a&&a.trim()||null!==(c=r.tooltip)&&void 0!==c&&c.trim());return t.data.repr.setState({pickable:d,markerActions:d?Us.Highlighting:Bt.None}),Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),utt=Rt.BuiltIn({name:"structure-selections-orientation-3d",display:"3D Orientation",from:pe.Molecule.Structure.Selections,to:pe.Shape.Representation3D,params:()=>({...bce})})({canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Structure Orientation",function(){var r=ie(function*(i){var o;const s=dce(e.data),a=function ZJe(e,t){const n=yn.createMulti("Orientation",e,t,yn.StateBuilder,yce);return n.setState({markerActions:Us.Highlighting}),n}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>bce);return yield a.createOrUpdate(t,s).runInContext(i),new pe.Shape.Representation3D({repr:a,sourceData:s},{label:"Orientation"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Structure Orientation",function(){var o=ie(function*(s){const a={...t.data.repr.props,...r},c=dce(e.data);return yield t.data.repr.createOrUpdate(a,c).runInContext(s),t.data.sourceData=c,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),ltt=Rt.BuiltIn({name:"structure-selections-plane-3d",display:"3D Plane",from:pe.Molecule.Structure.Selections,to:pe.Shape.Representation3D,params:()=>({...Mce})})({canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Structure Plane",function(){var r=ie(function*(i){var o;const s=fce(e.data),a=function Get(e,t){const n=yn.createMulti("Plane",e,t,yn.StateBuilder,Pce);return n.setState({markerActions:Us.Highlighting}),n}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>Mce);return yield a.createOrUpdate(t,s).runInContext(i),new pe.Shape.Representation3D({repr:a,sourceData:s},{label:"Plane"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Structure Plane",function(){var o=ie(function*(s){const a={...t.data.repr.props,...r},c=fce(e.data);return yield t.data.repr.createOrUpdate(a,c).runInContext(s),t.data.sourceData=c,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),Ye={Data:HP,Misc:qP,Model:WP,Volume:$P,Representation:XP,Shape:YP};function XS(e){let t;return e=e.replace(/^#/,""),[t,e]=[e.slice(6,8),e.slice(0,6)],[st.fromHexStyle("#"+e),1-+("0x"+(t||"ff"))/255]}const ftt=Qe.builderFactory("interactions")({name:"interactions",from:pe.Root,to:pe.Shape.Provider,params:{data:C.Value(void 0,{isHidden:!1})}})({apply:({params:e})=>new pe.Shape.Provider({label:"",data:e.data,params:Nt.Params,geometryUtils:Nt.Utils,getShape:(t,n)=>function dtt(e){const t=at.createState(512,512);for(let n=0;ne[n].color,()=>1,n=>e[n].label)}(n)},{label:""})});let KS=(()=>{class e{constructor(){this.settings$=new ou}set settings(n){this.settings$.next(this._settings=n)}get settings(){return this._settings}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();var eh;function ii(){const e=(t,n)=>t.commands.dispatch(e,n||{});return e.subscribe=(t,n)=>t.commands.subscribe(e,n),e.id=Hr.create22(),e}!function(e){e.create=function t(r){return r},e.getDuration=function n(r,i){var o,s;if(i.customDurationMs)return i.customDurationMs;const a=null===(s=(o=i.definition).getDuration)||void 0===s?void 0:s.call(o,i.params,r);return"fixed"===a?.kind?a.durationMs:void 0}}(eh||(eh={}));class ptt{constructor(){this.subs=new Map,this.disposing=!1}subscribe(t,n){let r=this.subs.get(t.id);return r||(r=[],this.subs.set(t.id,r)),r.push(n),{unsubscribe:()=>{const i=this.subs.get(t.id);if(!i)return;const o=i.indexOf(n);if(!(o<0)){for(let s=o+1;s{this.disposing?i("disposed"):this.subs.get(t.id)?this.resolve({cmd:t,params:n,resolve:r,reject:i}):r()})}dispose(){this.subs.clear()}resolve(t){var n=this;return ie(function*(){const r=n.subs.get(t.cmd.id);if(r)try{for(const i of r)yield i(t.params);t.resolve()}catch(i){t.reject(i)}else t.resolve()})()}}const Cn={State:{SetCurrentObject:ii(),ApplyAction:ii(),Update:ii(),RemoveObject:ii(),ToggleExpanded:ii(),ToggleVisibility:ii(),Snapshots:{Add:ii(),Replace:ii(),Move:ii(),Remove:ii(),Apply:ii(),Clear:ii(),Upload:ii(),Fetch:ii(),DownloadToFile:ii(),OpenFile:ii(),OpenUrl:ii()}},Interactivity:{Object:{Highlight:ii()},Structure:{Highlight:ii(),Select:ii()},ClearHighlights:ii()},Layout:{Update:ii()},Toast:{Show:ii(),Hide:ii()},Camera:{Reset:ii(),SetSnapshot:ii(),Focus:ii(),OrientAxes:ii(),ResetAxes:ii()},Canvas3D:{SetSettings:ii(),ResetSettings:ii()}},htt=eh.create({name:"built-in.animate-assembly-unwind",display:{name:"Unwind Assembly"},isExportable:!0,params:e=>{const t=[["all","All"]],n=e.state.data.select(In.Generators.rootsOfType(pe.Molecule.Structure));for(const r of n)t.push([r.transform.ref,r.obj.data.models[0].label]);return{durationInMs:C.Numeric(3e3,{min:100,max:1e4,step:100}),playOnce:C.Boolean(!1),target:C.Select(t[0][0],t)}},canApply:e=>({canApply:e.state.data.select(In.Generators.ofType(pe.Molecule.Structure.Representation3D,ur.RootRef)).length>0}),getDuration:e=>({kind:"fixed",durationMs:e.durationInMs}),initialState:()=>({t:0}),setup(e,t,n){const r=n.state.data,o=r.select(In.Generators.ofType(pe.Molecule.Structure.Representation3D,e.target&&"all"!==e.target?e.target:ur.RootRef)),s=r.build();let a=!1;for(const c of o)r.select(In.Generators.ofTransformer(Ye.Representation.UnwindStructureAssemblyRepresentation3D,c.transform.ref)).length>0||(a=!0,s.to(c).apply(Ye.Representation.UnwindStructureAssemblyRepresentation3D,{t:0},{tags:"animate-assembly-unwind"}));if(a)return s.commit({doNotUpdateCurrent:!0})},teardown(e,t,n){const r=n.state.data,i=r.select(In.Generators.ofType(pe.Molecule.Structure.Representation3DState).withTag("animate-assembly-unwind"));if(0===i.length)return;const o=r.build();for(const s of i)o.delete(s.transform.ref);return o.commit()},apply:(e,t,n)=>ie(function*(){const r=n.plugin.state.data,o=r.select(In.Generators.ofTransformer(Ye.Representation.UnwindStructureAssemblyRepresentation3D,n.params.target&&"all"!==n.params.target?n.params.target:ur.RootRef));if(0===o.length)return{kind:"finished"};const s=r.build();let c=e.t+(t.current-t.lastApplied)/n.params.durationInMs,u=!1;n.params.playOnce&&c>=1?(u=!0,c=1):c%=1;for(const l of o)s.to(l).update({t:c});return yield Cn.State.Update(n.plugin,{state:r,tree:s,options:{doNotLogTiming:!0}}),u?{kind:"finished"}:{kind:"next",state:{t:c}}})()}),_E=v(),Rce=v(),kce=_r(),mtt=eh.create({name:"built-in.animate-camera-spin",display:{name:"Camera Spin",description:"Spin the 3D scene around the x-axis in view space"},isExportable:!0,params:()=>({durationInMs:C.Numeric(4e3,{min:100,max:2e4,step:100}),speed:C.Numeric(1,{min:1,max:10,step:1},{description:"How many times to spin in the specified duration."}),direction:C.Select("cw",[["cw","Clockwise"],["ccw","Counter Clockwise"]],{cycle:!0})}),initialState:(e,t)=>{var n;return{snapshot:null===(n=t.canvas3d)||void 0===n?void 0:n.camera.getSnapshot()}},getDuration:e=>({kind:"fixed",durationMs:e.durationInMs}),teardown:(e,t,n)=>{var r;null===(r=n.canvas3d)||void 0===r||r.requestCameraReset({snapshot:t.snapshot,durationMs:0})},apply:(e,t,n)=>ie(function*(){var r,i;if(0===t.current)return{kind:"next",state:e};const o=e.snapshot;if(o.radiusMax<1e-4)return{kind:"finished"};const s=t.animation?(null===(r=t.animation)||void 0===r?void 0:r.currentFrame)/(t.animation.frameCount+1):os(t.current/n.params.durationInMs,0,1),a=2*Math.PI*s*n.params.speed*("ccw"===n.params.direction?-1:1);v.sub(_E,o.position,o.target),v.normalize(Rce,o.up),_r.setAxisAngle(kce,Rce,a),v.transformQuat(_E,_E,kce);const c=v.add(v(),o.target,_E);return null===(i=n.plugin.canvas3d)||void 0===i||i.requestCameraReset({snapshot:{...o,position:c},durationMs:0}),s>=.99999?{kind:"finished"}:{kind:"next",state:e}})()}),gtt=eh.create({name:"built-in.animate-model-index",display:{name:"Animate Trajectory"},isExportable:!0,params:()=>({mode:C.MappedStatic("loop",{palindrome:C.Group({}),loop:C.Group({direction:C.Select("forward",[["forward","Forward"],["backward","Backward"]])}),once:C.Group({direction:C.Select("forward",[["forward","Forward"],["backward","Backward"]])},{isFlat:!0})},{options:[["palindrome","Palindrome"],["loop","Loop"],["once","Once"]]}),duration:C.MappedStatic("fixed",{fixed:C.Group({durationInS:C.Numeric(5,{min:1,max:120,step:.1},{description:"Duration in seconds"})},{isFlat:!0}),computed:C.Group({targetFps:C.Numeric(30,{min:5,max:250,step:1},{label:"Target FPS"})},{isFlat:!0}),sequential:C.Group({maxFps:C.Numeric(30,{min:5,max:60,step:1})},{isFlat:!0})})}),canApply(e){const t=e.state.data,n=t.select(In.Generators.ofTransformer(Ye.Model.ModelFromTrajectory));for(const r of n){const i=In.findAncestorOfType(t.tree,t.cells,r.transform.ref,pe.Molecule.Trajectory);if(i&&i.obj&&i.obj.data.frameCount>1)return{canApply:!0}}return{canApply:!1,reason:"No trajectory to animate"}},getDuration:(e,t)=>{var n;if("fixed"===(null===(n=e.duration)||void 0===n?void 0:n.name))return{kind:"fixed",durationMs:1e3*e.duration.params.durationInS};if("computed"===e.duration.name){const r=t.state.data,i=r.select(In.Generators.ofTransformer(Ye.Model.ModelFromTrajectory));let o=0;for(const s of i){const a=In.findAncestorOfType(r.tree,r.cells,s.transform.ref,pe.Molecule.Trajectory);a&&a.obj&&(o=Math.max(Math.ceil(1e3*a.obj.data.frameCount/e.duration.params.targetFps),o))}return{kind:"fixed",durationMs:o}}return{kind:"unknown"}},initialState:()=>({}),apply:(e,t,n)=>ie(function*(){if("sequential"===n.params.duration.name&&t.current>0&&t.current-t.lastApplied<1e3/n.params.duration.params.maxFps)return{kind:"skip"};const r=n.plugin.state.data,i=r.select(In.Generators.ofTransformer(Ye.Model.ModelFromTrajectory));if(0===i.length)return{kind:"finished"};const o=r.build(),s=n.params,a=e.palindromeDirections||{};let c=!1,u=!0;for(const l of i){const d=In.findAncestorOfType(r.tree,r.cells,l.transform.ref,pe.Molecule.Trajectory);if(!d||!d.obj)continue;const f=d.obj;f.data.frameCount<=1||o.to(l).update(p=>{const m=f.data.frameCount;if(1===m)return p;if(u=!1,"sequential"===s.duration.name){let h=1;if("once"===s.mode.name){if(h="backward"===s.mode.params.direction?-1:1,-1===h&&0===p.modelIndex||1===h&&p.modelIndex===m-1)return c=!0,p}else"palindrome"===s.mode.name&&(h=0===p.modelIndex?1:p.modelIndex===m-1?-1:a[l.transform.ref]||1);a[l.transform.ref]=h;let g=(p.modelIndex+h)%m;return g<0&&(g+=m),c=c||-1===h&&0===g||1===h&&g===m-1,{modelIndex:g}}{const h="fixed"===s.duration.name?1e3*s.duration.params.durationInS:Math.ceil(1e3*f.data.frameCount/s.duration.params.targetFps);if("once"===s.mode.name&&t.current>=h)return c=!0,{modelIndex:f.data.frameCount-1};let g=t.current%h/h;return"loop"===s.mode.name&&"backward"===s.mode.params.direction&&(g=1-g),"palindrome"===s.mode.name&&(g*=2,g>1&&(g=2-g)),{modelIndex:Math.min(Math.floor(f.data.frameCount*g),f.data.frameCount-1)}}})}return u||(yield Cn.State.Update(n.plugin,{state:r,tree:o,options:{doNotLogTiming:!0}})),u||"once"===s.mode.name&&c?{kind:"finished"}:"palindrome"===s.mode.name?{kind:"next",state:{palindromeDirections:a}}:{kind:"next",state:{}}})()});function Nce(e,t){return b8.apply(this,arguments)}function b8(){return b8=ie(function*(e,t,n=!1){var r;t.snapshot.data&&(yield e.runTask(e.state.data.setSnapshot(t.snapshot.data))),t.snapshot.camera&&(null===(r=e.canvas3d)||void 0===r||r.requestCameraReset({snapshot:t.snapshot.camera.current,durationMs:n||"instant"===t.snapshot.camera.transitionStyle?0:t.snapshot.camera.transitionDurationInMs}))}),b8.apply(this,arguments)}const ytt=eh.create({name:"built-in.animate-state-snapshots",display:{name:"State Snapshots"},isExportable:!0,params:()=>({}),canApply(e){const t=e.managers.snapshot.state.entries;return t.size<2?{canApply:!1,reason:"At least 2 states required."}:t.some(n=>!!n?.snapshot.startAnimation)?{canApply:!1,reason:"Nested animations not supported."}:{canApply:e.managers.snapshot.state.entries.size>1}},setup(e,t,n){const r=n.managers.snapshot.state.entries.get(0);Nce(n,r,!0)},getDuration:(e,t)=>({kind:"fixed",durationMs:t.managers.snapshot.state.entries.toArray().reduce((n,r)=>{var i;return n+(null!==(i=r.snapshot.durationInMs)&&void 0!==i?i:0)},0)}),initialState:(e,t)=>{const n=t.managers.snapshot.state.entries.toArray();return{totalDuration:n.reduce((r,i)=>{var o;return r+(null!==(o=i.snapshot.durationInMs)&&void 0!==o?o:0)},0),snapshots:n,currentIndex:0}},apply:(e,t,n)=>ie(function*(){var r;if(t.current>=e.totalDuration)return{kind:"finished"};let i=0,o=0;for(const s of e.snapshots){if(i+=null!==(r=s.snapshot.durationInMs)&&void 0!==r?r:0,t.current=e.snapshots.length?{kind:"finished"}:o===e.currentIndex?{kind:"skip"}:(Nce(n.plugin,e.snapshots[o]),{kind:"next",state:{...e,currentIndex:o}})})()});var tr;!function(e){class t extends(pe.Create({name:"Root",typeClass:"Root"})){}e.Root=t;class n extends(pe.Create({name:"Category",typeClass:"Object"})){}e.Category=n;class r extends(pe.CreateBehavior({name:"Behavior"})){}e.Behavior=r,e.Categories={common:"Common",representation:"Representation",interaction:"Interaction","custom-props":"Custom Properties",misc:"Miscellaneous"},e.CreateCategory=Rt.BuiltIn({name:"create-behavior-category",display:{name:"Behavior Category"},from:t,to:n,params:{label:C.Text("",{isHidden:!0})}})({apply:({params:l})=>new n({},{label:l.label})});const i=new Map;e.getCategoryId=function o(l){return i.get(l.id)},e.create=function s(l){const d=Rt.CreateBuiltIn({name:l.name,display:l.display,from:[t],to:[r],params:l.params,apply({params:f},p){const m=l.label?l.label(f):{label:l.display.name,description:l.display.description};return new r(new l.ctor(p,f),m)},update:({b:f,newParams:p})=>Oe.create("Update Behavior",ie(function*(){return f.data.update&&(yield f.data.update(p))?Qe.UpdateResult.Updated:Qe.UpdateResult.Unchanged})),canAutoUpdate:l.canAutoUpdate});return i.set(d.id,l.category),d},e.simpleCommandHandler=function a(l,d){return class{register(){this.sub=l.subscribe(this.ctx,f=>d(f,this.ctx))}dispose(){this.sub&&this.sub.unsubscribe(),this.sub=void 0}constructor(f){this.ctx=f,this.sub=void 0}}},e.Handler=class c{subscribeCommand(d,f){this.subs.push(d.subscribe(this.ctx,f))}subscribeObservable(d,f){this.subs.push(d.subscribe(f))}track(d){this.subs.push(d)}dispose(){for(const d of this.subs)d.unsubscribe();this.subs=[]}update(d){return!MI(d,this.params)&&(this.params=d,!0)}constructor(d,f){this.ctx=d,this.params=f,this.subs=[]}},e.WithSubscribers=class u{subscribeCommand(d,f){this.subs.push(d.subscribe(this.plugin,f))}subscribeObservable(d,f){const p=d.subscribe(f);return this.subs.push(p),{unsubscribe:()=>{const m=this.subs.indexOf(p);m>=0&&(this.subs.splice(m,1),p.unsubscribe())}}}dispose(){for(const d of this.subs)d.unsubscribe();this.subs=[]}constructor(d,f){this.plugin=d,this.params=f,this.subs=[]}}}(tr||(tr={}));class ZS{constructor(){this.subs=void 0}subscribe(t,n){typeof this.subs>"u"&&(this.subs=[]);let r=t.subscribe(n);return this.subs.push(r),{unsubscribe:()=>{r&&this.subs&&Eg(this.subs,r)&&(r.unsubscribe(),r=void 0)}}}get ev(){return this._ev||(this._ev=wp.create())}dispose(){if(this._ev&&this._ev.dispose(),this.subs){for(const t of this.subs)t.unsubscribe();this.subs=void 0}}}class th extends ZS{updateState(...t){const n=this.state,r=function BZ(e,t){let n=e;for(let r=0;r{const o=s=>{s?r(s):i("no blob returned")};HTMLCanvasElement.prototype.toBlob?e.toBlob(o,t,n):function xtt(e,t,n,r){const i=atob(e.toDataURL(n,r).split(",")[1]),o=i.length,s=o>>2,a=new Uint8Array(o),c=new Uint32Array(a.buffer,0,s);let u=0;for(let d=0;d{class e extends th{getIndex(n){return this.state.entries.indexOf(n)}getEntry(n){if(n)return this.entryMap.get(n)}remove(n){const r=this.entryMap.get(n);r&&(r?.image&&this.plugin.managers.asset.delete(r.image),this.entryMap.delete(n),this.updateState({current:this.state.current===n?void 0:this.state.current,entries:this.state.entries.delete(this.getIndex(r))}),this.events.changed.next(void 0))}add(n){this.entryMap.set(n.snapshot.id,n),this.updateState({current:n.snapshot.id,entries:this.state.entries.push(n)}),this.events.changed.next(void 0)}replace(n,r,i){var o,s,a;const c=this.getEntry(n);if(!c)return;this.defaultSnapshotId=void 0,c?.image&&this.plugin.managers.asset.delete(c.image);const u=this.getIndex(c),l=e.Entry(r,{key:null!==(o=i?.key)&&void 0!==o?o:c.key,name:null!==(s=i?.name)&&void 0!==s?s:c.name,description:null!==(a=i?.description)&&void 0!==a?a:c.description,image:i?.image});this.entryMap.set(r.id,l),this.updateState({current:l.snapshot.id,entries:this.state.entries.set(u,l)}),this.events.changed.next(void 0)}move(n,r){const i=this.state.entries.size;if(i<2)return;const o=this.getEntry(n);if(!o)return;const s=this.getIndex(o);let a=(s+r)%i;a<0&&(a+=i);const c=this.state.entries.get(a),u=this.state.entries.asMutable();u.set(a,o),u.set(s,c),this.updateState({current:o.snapshot.id,entries:u.asImmutable()}),this.events.changed.next(void 0)}update(n,r){var i,o,s;const a=this.getIndex(n);if(a<0)return;const c=this.state.entries.set(a,{...n,key:(null===(i=r.key)||void 0===i?void 0:i.trim())||void 0,name:(null===(o=r.name)||void 0===o?void 0:o.trim())||void 0,description:(null===(s=r.description)||void 0===s?void 0:s.trim())||void 0});this.updateState({entries:c}),this.entryMap.set(n.snapshot.id,this.state.entries.get(a)),this.events.changed.next(void 0)}clear(){0!==this.state.entries.size&&(this.entryMap.forEach(n=>{n?.image&&this.plugin.managers.asset.delete(n.image)}),this.entryMap.clear(),this.updateState({current:void 0,entries:Cp()}),this.events.changed.next(void 0))}applyKey(n){const r=this.state.entries.find(i=>i.key===n);r&&(this.updateState({current:r.snapshot.id}),this.events.changed.next(void 0),this.plugin.state.setSnapshot(r.snapshot))}setCurrent(n){const r=this.getEntry(n);return r&&(this.updateState({current:n}),this.events.changed.next(void 0)),r&&r.snapshot}getNextId(n,r){const i=this.state.entries.size;if(!n){if(0===i)return;return this.state.entries.get(-1===r?i-1:0).snapshot.id}const o=this.getEntry(n);if(!o)return;let s=this.getIndex(o);return s<0?void 0:(s=(s+r)%i,s<0&&(s+=i),this.state.entries.get(s).snapshot.id)}setStateSnapshot(n){var r=this;return ie(function*(){r.clear();const i=Cp().asMutable();for(const c of n.entries)r.entryMap.set(c.snapshot.id,c),i.push(c);const o=n.current?n.current:n.entries.length>0?n.entries[0].snapshot.id:void 0;if(r.updateState({current:o,entries:i.asImmutable(),isPlaying:!1,nextSnapshotDelayInMs:n.playback?n.playback.nextSnapshotDelayInMs:e.DefaultNextSnapshotDelayInMs}),r.events.changed.next(void 0),!o)return;const s=r.getEntry(o),a=s&&s.snapshot;return a?(yield r.plugin.state.setSnapshot(a),n.playback&&n.playback.isPlaying&&r.play(!0),a):void 0})()}syncCurrent(n){var r=this;return ie(function*(){var i,o;const s=0===r.state.entries.size,a=1===r.state.entries.size&&r.state.current&&r.state.current===r.defaultSnapshotId;if(!s&&!a)return;const c=r.plugin.state.getSnapshot(n?.params),u=(null!==(o=null===(i=n?.params)||void 0===i?void 0:i.image)&&void 0!==o?o:r.plugin.state.snapshotParams.value.image)?yield e.getCanvasImageAsset(r.plugin,`${c.id}-image.png`):void 0;if(s)r.add(e.Entry(c,{name:n?.name,description:n?.description,image:u}));else if(a){const l=r.getEntry(r.state.current);l?.image&&r.plugin.managers.asset.delete(l.image),r.replace(r.state.current,c,{image:u})}r.defaultSnapshotId=c.id})()}getStateSnapshot(n){var r=this;return ie(function*(){return yield r.syncCurrent(n),{timestamp:+new Date,version:"4.0.1",name:n&&n.name,description:n&&n.description,current:r.state.current,playback:{isPlaying:!(!n||!n.playOnLoad),nextSnapshotDelayInMs:r.state.nextSnapshotDelayInMs},entries:r.state.entries.valueSeq().toArray()}})()}serialize(n){var r=this;return ie(function*(){const i=JSON.stringify(yield r.getStateSnapshot({params:n?.params}),null,2);if(!n?.type||"json"===n.type||"molj"===n.type)return new Blob([i],{type:"application/json;charset=utf-8"});{const o=new Uint8Array(cT(i));Yb(o,0,i);const s={"state.json":o},a=[];for(const{asset:u,file:l}of r.plugin.managers.asset.assets)a.push([u.id,u]),s[`assets/${u.id}`]=new Uint8Array(yield l.arrayBuffer());if(a.length>0){const u=JSON.stringify(a,null,2),l=new Uint8Array(cT(u));Yb(l,0,u),s["assets.json"]=l}const c=yield r.plugin.runTask(function mLe(e,t=!1){return Oe.create("Zip",n=>function gLe(e,t){return MO.apply(this,arguments)}(n,e,t))}(s));return new Blob([c],{type:"application/zip"})}})()}open(n){var r=this;return ie(function*(){try{const i=n.name.toLowerCase();if(i.endsWith("json")||i.endsWith("molj")){const o=yield r.plugin.runTask(bp(n,"string")),s=JSON.parse(o);e.isStateSnapshot(s)?yield r.setStateSnapshot(s):e.isStateSnapshot(s.data)?yield r.setStateSnapshot(s.data):yield r.plugin.state.setSnapshot(s)}else{const o=yield r.plugin.runTask(bp(n,"zip")),s=Object.create(null);$a(o,(l,d)=>{if("state.json"===d||"assets.json"===d)return;const f=d.substring(d.indexOf("/")+1);s[f]=l});const a=new File([o["state.json"]],"state.json"),c=yield r.plugin.runTask(bp(a,"string"));if(o["assets.json"]){const l=new File([o["assets.json"]],"assets.json"),d=JSON.parse(yield r.plugin.runTask(bp(l,"string")));for(const[f,p]of d)r.plugin.managers.asset.set(p,new File([s[f]],p.name))}const u=JSON.parse(c);yield r.setStateSnapshot(u)}r.events.opened.next(void 0)}catch(i){console.error(i),r.plugin.log.error("Error reading state")}})()}play(n=!1){if(this.updateState({isPlaying:!0}),n){const r=this.getEntry(this.state.current);if(!r)return void this.next();this.events.changed.next(void 0);const i=r.snapshot;this.timeoutHandle=setTimeout(this.next,typeof i.durationInMs<"u"?i.durationInMs:this.state.nextSnapshotDelayInMs)}else this.next()}stop(){this.updateState({isPlaying:!1}),typeof this.timeoutHandle<"u"&&clearTimeout(this.timeoutHandle),this.timeoutHandle=void 0,this.events.changed.next(void 0)}togglePlay(){this.state.isPlaying?(this.stop(),this.plugin.managers.animation.stop()):this.play()}dispose(){super.dispose(),this.entryMap.clear()}constructor(n){var r;super({current:void 0,entries:Cp(),isPlaying:!1,nextSnapshotDelayInMs:e.DefaultNextSnapshotDelayInMs}),r=this,this.plugin=n,this.entryMap=new Map,this.defaultSnapshotId=void 0,this.events={changed:this.ev(),opened:this.ev()},this.timeoutHandle=void 0,this.next=ie(function*(){r.timeoutHandle=void 0;const i=r.getNextId(r.state.current,1);if(!i||i===r.state.current)return void r.stop();const o=r.setCurrent(i);yield r.plugin.state.setSnapshot(o),r.state.isPlaying&&(r.timeoutHandle=setTimeout(r.next,typeof o.durationInMs<"u"?o.durationInMs:r.state.nextSnapshotDelayInMs))})}}return e.DefaultNextSnapshotDelayInMs=1500,e})();function Fce(e){try{e.dispatchEvent(new MouseEvent("click"))}catch{const n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(n)}}function Bce(e,t="download"){if(e)if("download"in HTMLAnchorElement.prototype){const n=document.createElement("a");n.download=t,n.rel="noopener","string"==typeof e?(n.href=e,Fce(n)):(n.href=URL.createObjectURL(e),setTimeout(()=>URL.revokeObjectURL(n.href),4e4),setTimeout(()=>Fce(n)))}else if(typeof navigator<"u"&&navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(e,t);else{const n=window.navigator.userAgent,r=/Safari/i.test(n),i=/CriOS\/[\d]+/.test(n),o=s=>{!function Ctt(e){window.open(e,"_blank")||(window.location.href=e)}(i?s:s.replace(/^data:[^;]*;/,"data:attachment/file;"))};if((r||i)&&FileReader)if(e instanceof Blob){const s=new FileReader;s.onloadend=()=>o(s.result),s.readAsDataURL(e)}else o(e);else{const s=URL.createObjectURL("string"==typeof e?new Blob([e]):e);location.href=s,setTimeout(()=>URL.revokeObjectURL(s),4e4)}}}function S8(e,t){return`${e}${"/"===e[e.length-1]||"/"===t[0]?"":"/"}${t}`}!function(e){function i(){return(i=ie(function*(o,s){if(!o.helpers.viewportScreenshot)return;const a=o.helpers.viewportScreenshot.getPreview(512);if(!a)return;const c=yield _8(a.canvas,"png"),u=new File([c],s),l={kind:"file",id:Hr.create22(),name:s};return o.managers.asset.set(l,u),l})).apply(this,arguments)}e.Entry=function t(o,s){return{timestamp:+new Date,snapshot:o,...s}},e.isStateSnapshot=function n(o){return!!o&&!!o.timestamp&&!!o.entries},e.getCanvasImageAsset=function r(o,s){return i.apply(this,arguments)}}(Hv||(Hv={}));const wtt={get preferWebGl1(){if(typeof navigator>"u"||typeof window>"u")return!1;if(["Version/15.1 Safari","Version/15.2 Safari","Version/15.3 Safari"].some(i=>navigator.userAgent.indexOf(i)>0))return!0;const t=/iPad|iPhone|iPod/.test(navigator.userAgent),n=navigator.userAgent.includes("Macintosh"),r=navigator.maxTouchPoints>=4;return!window.MSStream&&(t||n&&r)}};class Att{toString(){return this.key}valueOf(){return this.key}constructor(t,n){this.key=t,this.defaultValue=n}}function fi(e,t){return new Att(e,t)}const qi={item:fi,General:{IsBusyTimeoutMs:fi("plugin-config.is-busy-timeout",750),DisableAntialiasing:fi("plugin-config.disable-antialiasing",!1),DisablePreserveDrawingBuffer:fi("plugin-config.disable-preserve-drawing-buffer",!1),PixelScale:fi("plugin-config.pixel-scale",1),PickScale:fi("plugin-config.pick-scale",.25),Transparency:fi("plugin-config.transparency","wboit"),PreferWebGl1:fi("plugin-config.prefer-webgl1",wtt.preferWebGl1),AllowMajorPerformanceCaveat:fi("plugin-config.allow-major-performance-caveat",!1),PowerPreference:fi("plugin-config.power-preference","high-performance")},State:{DefaultServer:fi("plugin-state.server","https://webchem.ncbr.muni.cz/molstar-state"),CurrentServer:fi("plugin-state.server","https://webchem.ncbr.muni.cz/molstar-state"),HistoryCapacity:fi("history-capacity.server",5)},VolumeStreaming:{Enabled:fi("volume-streaming.enabled",!0),DefaultServer:fi("volume-streaming.server","https://ds.litemol.org"),CanStream:fi("volume-streaming.can-stream",(e,t)=>1===e.models.length&&sn.probablyHasDensityMap(e.models[0])),EmdbHeaderServer:fi("volume-streaming.emdb-header-server","https://files.wwpdb.org/pub/emdb/structures")},Viewport:{ShowExpand:fi("viewer.show-expand-button",!0),ShowControls:fi("viewer.show-controls-button",!0),ShowSettings:fi("viewer.show-settings-button",!0),ShowSelectionMode:fi("viewer.show-selection-model-button",!0),ShowAnimation:fi("viewer.show-animation-button",!0),ShowTrajectoryControls:fi("viewer.show-trajectory-controls",!0)},Download:{DefaultPdbProvider:fi("download.default-pdb-provider","pdbe"),DefaultEmdbProvider:fi("download.default-emdb-provider","pdbe")},Structure:{SizeThresholds:fi("structure.size-thresholds",Ve.DefaultSizeThresholds),DefaultRepresentationPreset:fi("structure.default-representation-preset","auto"),DefaultRepresentationPresetParams:fi("structure.default-representation-preset-params",{}),SaccharideCompIdMapType:fi("structure.saccharide-comp-id-map-type","default")},Background:{Styles:fi("background.styles",[])}};class Itt{get(t){return this._config.has(t)?this._config.get(t):t.defaultValue}set(t,n){this._config.set(t,n)}delete(t){this._config.delete(t)}constructor(t){this._config=new Map,t&&t.forEach(([n,r])=>this._config.set(n,r))}}function Ttt(e){Oce(e),Lce(e),Uce(e),Vce(e),zce(e),Gce(e),jce(e),Hce(e),qce(e),Wce(e)}function Oce(e){e.state.events.object.created.subscribe(t=>{pe.isBehavior(t.obj)&&t.obj.data.register(t.ref)}),e.state.events.object.removed.subscribe(t=>{var n,r,i,o;pe.isBehavior(t.obj)&&(null===(r=(n=t.obj.data).unregister)||void 0===r||r.call(n),null===(o=(i=t.obj.data).dispose)||void 0===o||o.call(i))}),e.state.events.object.updated.subscribe(t=>{var n,r,i,o;"recreate"===t.action&&(t.oldObj&&pe.isBehavior(t.oldObj)&&(null===(r=(n=t.oldObj.data).unregister)||void 0===r||r.call(n),null===(o=(i=t.oldObj.data).dispose)||void 0===o||o.call(i)),t.obj&&pe.isBehavior(t.obj)&&t.obj.data.register(t.ref))})}function Lce(e){Cn.State.SetCurrentObject.subscribe(e,({state:t,ref:n})=>t.setCurrent(n))}function Uce(e){Cn.State.Update.subscribe(e,({state:t,tree:n,options:r})=>e.runTask(t.updateTree(n,r)))}function Vce(e){Cn.State.ApplyAction.subscribe(e,({state:t,action:n,ref:r})=>e.runTask(t.applyAction(n.action,n.params,r)))}function zce(e){function t(n,r){const i=n.build().delete(r);return e.runTask(n.updateTree(i))}Cn.State.RemoveObject.subscribe(e,({state:n,ref:r,removeParentGhosts:i})=>{if(!i)return t(n,r);{const o=n.tree;let s=o.transforms.get(r);if(s.parent===r)return t(n,r);for(;;){const a=o.children.get(s.parent);if(s.parent===s.ref||a.size>1)return t(n,s.ref);const c=o.transforms.get(s.parent);if(!c.state.isGhost)return t(n,s.ref);s=c}}})}function Gce(e){Cn.State.ToggleExpanded.subscribe(e,({state:t,ref:n})=>t.updateCellState(n,({isCollapsed:r})=>({isCollapsed:!r})))}function jce(e){Cn.State.ToggleVisibility.subscribe(e,({state:t,ref:n})=>qv(t,n,!t.cells.get(n).state.isHidden))}function qv(e,t,n){bo.doPreOrder(e.tree,e.transforms.get(t),{state:e,value:n},Dtt)}function Dtt(e,t,n){n.state.updateCellState(e.ref,{isHidden:n.value})}function Hce(e){Cn.Interactivity.Object.Highlight.subscribe(e,({state:t,ref:n})=>{if(!e.canvas3d||e.isBusy)return;e.managers.interactivity.lociHighlights.clearHighlights();const r="string"==typeof n?[n]:n;for(const i of r){const o=t.cells.get(i);if(o)if(pe.Molecule.Structure.is(o.obj))e.managers.interactivity.lociHighlights.highlight({loci:Ve.Loci(o.obj.data)},!1);else if(o&&pe.isRepresentation3D(o.obj)){const{repr:s}=o.obj.data;for(const a of s.getAllLoci())e.managers.interactivity.lociHighlights.highlight({loci:a,repr:s},!1)}else if(pe.Molecule.Structure.Selections.is(o.obj))for(const s of o.obj.data)e.managers.interactivity.lociHighlights.highlight({loci:s.loci},!1)}})}function qce(e){Cn.Interactivity.ClearHighlights.subscribe(e,()=>{e.managers.interactivity.lociHighlights.clearHighlights()})}function Wce(e){e.config.set(qi.State.CurrentServer,e.config.get(qi.State.DefaultServer)),Cn.State.Snapshots.Clear.subscribe(e,()=>{e.managers.snapshot.clear()}),Cn.State.Snapshots.Remove.subscribe(e,({id:t})=>{e.managers.snapshot.remove(t)}),Cn.State.Snapshots.Add.subscribe(e,function(){var t=ie(function*({key:n,name:r,description:i,params:o}){var s;const a=e.state.getSnapshot(o),c=(null!==(s=o?.image)&&void 0!==s?s:e.state.snapshotParams.value.image)?yield Hv.getCanvasImageAsset(e,`${a.id}-image.png`):void 0,u=Hv.Entry(a,{key:n,name:r,description:i,image:c});e.managers.snapshot.add(u)});return function(n){return t.apply(this,arguments)}}()),Cn.State.Snapshots.Replace.subscribe(e,function(){var t=ie(function*({id:n,params:r}){var i;const o=e.state.getSnapshot(r),s=(null!==(i=r?.image)&&void 0!==i?i:e.state.snapshotParams.value.image)?yield Hv.getCanvasImageAsset(e,`${o.id}-image.png`):void 0;e.managers.snapshot.replace(n,e.state.getSnapshot(r),{image:s})});return function(n){return t.apply(this,arguments)}}()),Cn.State.Snapshots.Move.subscribe(e,({id:t,dir:n})=>{e.managers.snapshot.move(t,n)}),Cn.State.Snapshots.Apply.subscribe(e,({id:t})=>{const n=e.managers.snapshot.setCurrent(t);if(n)return e.state.setSnapshot(n)}),Cn.State.Snapshots.Upload.subscribe(e,function(){var t=ie(function*({name:n,description:r,playOnLoad:i,serverUrl:o}){return fetch(S8(o,`set?name=${encodeURIComponent(n||"")}&description=${encodeURIComponent(r||"")}`),{method:"POST",mode:"cors",referrer:"no-referrer",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(yield e.managers.snapshot.getStateSnapshot({name:n,description:r,playOnLoad:i}))})});return function(n){return t.apply(this,arguments)}}()),Cn.State.Snapshots.Fetch.subscribe(e,function(){var t=ie(function*({url:n}){const r=yield e.runTask(e.fetch({url:n,type:"json"}));yield e.managers.snapshot.setStateSnapshot(r.data)});return function(n){return t.apply(this,arguments)}}()),Cn.State.Snapshots.DownloadToFile.subscribe(e,function(){var t=ie(function*({name:n,type:r,params:i}){const o=`mol-star_state_${n||function Stt(){const e=new Date;return e.getFullYear()+"-"+(e.getMonth()+1)+"-"+e.getDate()+"-"+e.getHours()+"-"+e.getMinutes()+"-"+e.getSeconds()}()}.${"json"===r?"molj":"molx"}`;Bce(yield e.managers.snapshot.serialize({type:r,params:i}),`${o}`)});return function(n){return t.apply(this,arguments)}}()),Cn.State.Snapshots.OpenFile.subscribe(e,({file:t})=>e.managers.snapshot.open(t)),Cn.State.Snapshots.OpenUrl.subscribe(e,function(){var t=ie(function*({url:n,type:r}){const i=yield e.runTask(e.fetch({url:n,type:"binary"}));return e.managers.snapshot.open(new File([i],`state.${r}`))});return function(n){return t.apply(this,arguments)}}())}function Ett(e){$ce(e),Yce(e),Xce(e)}function $ce(e){const t=e.state.data.events;t.object.created.subscribe(n=>{var r;pe.isRepresentation3D(n.obj)&&(C8(n.state.cells.get(n.ref),n.obj.data.repr),n.obj.data.repr.setState({syncManually:!0}),null===(r=e.canvas3d)||void 0===r||r.add(n.obj.data.repr))}),t.object.updated.subscribe(n=>{var r,i;n.oldObj&&pe.isRepresentation3D(n.oldObj)&&(null===(r=e.canvas3d)||void 0===r||r.remove(n.oldObj.data.repr),n.oldObj.data.repr.destroy()),pe.isRepresentation3D(n.obj)&&(C8(n.state.cells.get(n.ref),n.obj.data.repr),"recreate"===n.action&&n.obj.data.repr.setState({syncManually:!0}),null===(i=e.canvas3d)||void 0===i||i.add(n.obj.data.repr))}),t.object.removed.subscribe(n=>{var r;pe.isRepresentation3D(n.obj)&&(null===(r=e.canvas3d)||void 0===r||r.remove(n.obj.data.repr),n.obj.data.repr.destroy())})}function Yce(e){const t=e.state.data.events;t.object.created.subscribe(n=>{var r;if(!pe.Molecule.Structure.Representation3DState.is(n.obj))return;const i=n.obj.data;i.repr.setState(i.state),null===(r=e.canvas3d)||void 0===r||r.update(i.repr)}),t.object.updated.subscribe(n=>{var r;if(!pe.Molecule.Structure.Representation3DState.is(n.obj))return;const i=n.obj.data;i.repr.setState(i.state),null===(r=e.canvas3d)||void 0===r||r.update(i.repr)}),t.object.removed.subscribe(n=>{var r;if(!pe.Molecule.Structure.Representation3DState.is(n.obj))return;const i=n.obj.data;i.repr.setState(i.initialState),null===(r=e.canvas3d)||void 0===r||r.update(i.repr)})}function Xce(e){e.state.data.events.cell.stateUpdated.subscribe(t=>{var n;const r=t.state.cells.get(t.ref);pe.isRepresentation3D(r.obj)&&C8(r,r.obj.data.repr)&&(null===(n=e.canvas3d)||void 0===n||n.syncVisibility())})}function C8(e,t){return t.state.visible===!!e.state.isHidden&&(t.setState({visible:!e.state.isHidden}),!0)}function Ptt(e){Kce(e),Qce(e),Zce(e),Jce(e),eue(e)}function Kce(e){Cn.Camera.Reset.subscribe(e,t=>{e.managers.camera.reset(t?.snapshot,t?.durationMs)})}function Zce(e){Cn.Camera.SetSnapshot.subscribe(e,({snapshot:t,durationMs:n})=>{e.managers.camera.setSnapshot(t,n)})}function Qce(e){Cn.Camera.Focus.subscribe(e,({center:t,radius:n,durationMs:r})=>{e.managers.camera.focusSphere({center:t,radius:n},{durationMs:r}),e.events.canvas3d.settingsUpdated.next(void 0)})}function Jce(e){Cn.Camera.OrientAxes.subscribe(e,({structures:t,durationMs:n})=>{e.managers.camera.orientAxes(t,n)})}function eue(e){Cn.Camera.ResetAxes.subscribe(e,({durationMs:t})=>{e.managers.camera.resetAxes(t)})}function Lo(){return Lo.zero()}!function(e){e.zero=function t(){return{x:0,y:0,width:0,height:0}},e.create=function n(c,u,l,d){return{x:c,y:u,width:l,height:d}},e.clone=function r(c){return{...c}},e.copy=function i(c,u){return Object.assign(c,u)},e.set=function o(c,u,l,d,f){return c.x=u,c.y=l,c.width=d,c.height=f,c},e.toVec4=function s(c,u){return c[0]=u.x,c[1]=u.y,c[2]=u.width,c[3]=u.height,c},e.equals=function a(c,u){return c.x===u.x&&c.y===u.y&&c.width===u.width&&c.height===u.height}}(Lo||(Lo={}));const If=nn();function xE(e,t,n,r){const{x:i,y:o,width:s,height:a}=n,u=t[1]-o,l=t[2];return e[0]=2*(t[0]-i)/s-1,e[1]=2*u/a-1,e[2]=2*l-1,v.transformMat4(e,e,r)}function w8(e){if("object"==typeof e){if("buttons"in e)return e.buttons;if("which"in e){const t=e.which;if(2===t)return 4;if(3===t)return 2;if(t>0)return 1<=0)return 1<!0,pixelScale:1};var wu,Zi;!function(e){function t(o,s){return o.shift===s.shift&&o.alt===s.alt&&o.control===s.control&&o.meta===s.meta}function i(o={}){return{shift:!!o.shift,alt:!!o.alt,control:!!o.control,meta:!!o.meta}}e.None=i(),e.areEqual=t,e.areNone=function n(o){return t(o,e.None)},e.size=function r(o){if(!o)return 0;let s=0;return o.shift&&s++,o.alt&&s++,o.control&&s++,o.meta&&s++,s},e.create=i}(wu||(wu={})),function(e){let t;var n;e.has=ea.has,e.create=ea.create,(n=t=e.Flag||(e.Flag={}))[n.None=0]="None",n[n.Primary=1]="Primary",n[n.Secondary=2]="Secondary",n[n.Auxilary=4]="Auxilary",n[n.Forth=8]="Forth",n[n.Five=16]="Five"}(Zi||(Zi={}));const rue={key:"",code:"",modifiers:wu.None,x:-1,y:-1,pageX:-1,pageY:-1,preventDefault:Ag};var T0=function(e){return e[e.Stopped=0]="Stopped",e[e.Started=1]="Started",e[e.Moving=2]="Moving",e}(T0||{});function iue(){return{drag:new mr,interactionEnd:new mr,click:new mr,move:new mr,wheel:new mr,pinch:new mr,gesture:new mr,resize:new mr,leave:new mr,enter:new mr,modifiers:new mr,key:new mr,keyUp:new mr,keyDown:new mr,lock:new mr}}const Rtt=["Backspace","Delete"];var A8;!function(e){e.create=function t(r={}){const{noScroll:i,noContextMenu:o}={...nue,...r};return{noScroll:i,noContextMenu:o,pointerLock:!1,width:0,height:0,pixelRatio:1,...iue(),setPixelScale:Ag,requestPointerLock:Ag,exitPointerLock:Ag,dispose:Ag}},e.fromElement=function n(r,i={}){let{noScroll:o,noContextMenu:a,noPinchZoom:c,noTextSelect:u,mask:l,pixelScale:d,preventGestures:f}={...nue,...i},p=r.clientWidth*I(),m=r.clientHeight*I(),h=!1,g=Lo(),y=0,b=0;const x=Me(),_=Me(),S=Me(),A=Me(),E=Me(),w={shift:!1,alt:!1,control:!1,meta:!1},D={x:-1,y:-1,pageX:-1,pageY:-1};function I(){return window.devicePixelRatio*d}function R(){return{...w}}function T(Ue){return Ue.target===document.body||Ue.target===r}let z,M=T0.Stopped,N=!1,V=Zi.create(Zi.Flag.None),F=Zi.Flag.None,G=!1,L=!1;typeof window.ResizeObserver<"u"&&(z=new window.ResizeObserver(Ut));const j=iue(),{drag:Z,interactionEnd:$,wheel:ee,pinch:q,gesture:O,click:H,move:W,leave:Q,enter:fe,resize:X,modifiers:J,key:ce,keyUp:be,keyDown:ae,lock:me}=j;function ne(){h=r.ownerDocument.pointerLockElement===r,Ed(h),me.next(h)}function de(){console.error("Unable to use Pointer Lock API"),h=!1,Ed(h),me.next(h)}function we(Ue){l(Ue.clientX,Ue.clientY)&&a&&Ue.preventDefault()}function Le(Ue){w.alt=Ue.altKey,w.shift=Ue.shiftKey,w.control=Ue.ctrlKey,w.meta=Ue.metaKey}function We(){(V||w.shift||w.alt||w.meta||w.control)&&(V=0,w.shift=w.alt=w.control=w.meta=!1)}function U(Ue){let tn=!1;!w.alt&&Ue.altKey&&(tn=!0,w.alt=!0),!w.shift&&Ue.shiftKey&&(tn=!0,w.shift=!0),!w.control&&Ue.ctrlKey&&(tn=!0,w.control=!0),!w.meta&&Ue.metaKey&&(tn=!0,w.meta=!0),tn&&G&&J.next(R()),T(Ue)&&G&&ae.next({key:Ue.key,code:Ue.code,modifiers:R(),...D,preventDefault:()=>Ue.preventDefault()})}function Y(Ue){let tn=!1;w.alt&&!Ue.altKey&&(tn=!0,w.alt=!1),w.shift&&!Ue.shiftKey&&(tn=!0,w.shift=!1),w.control&&!Ue.ctrlKey&&(tn=!0,w.control=!1),w.meta&&!Ue.metaKey&&(tn=!0,w.meta=!1),tn&&G&&J.next(R()),Rtt.includes(Ue.key)&&ge(Ue),T(Ue)&&G&&be.next({key:Ue.key,code:Ue.code,modifiers:R(),...D,preventDefault:()=>Ue.preventDefault()})}function ge(Ue){!T(Ue)||!G||ce.next({key:Ue.key,code:Ue.code,modifiers:R(),...D,preventDefault:()=>Ue.preventDefault()})}function Se(Ue){const tn=Ue.touches[0],Ke=Ue.touches[1];return{clientX:(tn.clientX+Ke.clientX)/2,clientY:(tn.clientY+Ke.clientY)/2,pageX:(tn.pageX+Ke.pageX)/2,pageY:(tn.pageY+Ke.pageY)/2,target:Ue.target}}function Re(Ue){const tn=Ue.touches[0].pageX-Ue.touches[1].pageX,Ke=Ue.touches[0].pageY-Ue.touches[1].pageY;return Math.sqrt(tn*tn+Ke*Ke)}!function oe(){r.addEventListener("contextmenu",we,!1),r.addEventListener("wheel",dt,!1),r.addEventListener("mousedown",ut,!1),window.addEventListener("mousemove",Ct,!1),window.addEventListener("mouseup",Et,!1),r.addEventListener("touchstart",Xe,!1),r.addEventListener("touchmove",_t,!1),r.addEventListener("touchend",ot,!1),r.addEventListener("gesturechange",yt,!1),r.addEventListener("gesturestart",ve,!1),r.addEventListener("gestureend",xt,!1),window.addEventListener("blur",We),window.addEventListener("keyup",Y,!1),window.addEventListener("keydown",U,!1),window.addEventListener("keypress",ge,!1),document.addEventListener("pointerlockchange",ne,!1),document.addEventListener("pointerlockerror",de,!1),null!=z?z.observe(r.parentElement):window.addEventListener("resize",Ut,!1)}();let Ge,Ne=-1;const $e=Me(),tt=Me();function Xe(Ue){if(Ue.preventDefault(),Ge=void 0,Ne=-1,1===Ue.touches.length)Ne=0,Me.set($e,Ue.touches[0].pageX,Ue.touches[0].pageY),Ge=Ue.touches[0],V=F=Zi.Flag.Primary,ln(Ue.touches[0]);else if(2===Ue.touches.length){V=Zi.Flag.Secondary&Zi.Flag.Auxilary,F=Zi.Flag.Secondary,ln(Se(Ue));const tn=Re(Ue);y=tn,q.next({distance:tn,fraction:1,fractionDelta:0,delta:0,isStart:!0,buttons:V,button:F,modifiers:R()})}else 3===Ue.touches.length&&(V=F=Zi.Flag.Forth,ln(Se(Ue)))}function ot(Ue){if(Xt(),Ge&&Ne<=4){const tn=Ge;if(!l(tn.clientX,tn.clientY))return;hr(tt,tn);const{pageX:Ke,pageY:Pt}=Pi(tn),[Ht,Ur]=tt;H.next({x:Ht,y:Ur,pageX:Ke,pageY:Pt,buttons:V,button:F,modifiers:R()})}Ge=void 0}function _t(Ue){if(F=Zi.Flag.None,c&&(Ue.preventDefault(),Ue.stopPropagation(),Ue.originalEvent&&(Ue.originalEvent.preventDefault(),Ue.originalEvent.stopPropagation())),Ge=void 0,1===Ue.touches.length)V=Zi.Flag.Primary,Ge=Ue.touches[0],function ke(Ue){Ne<0||(Me.set(tt,Ue.touches[0].pageX,Ue.touches[0].pageY),Ne+=Me.distance($e,tt),Me.copy($e,tt))}(Ue),qe(Ue.touches[0]);else if(2===Ue.touches.length){const tn=Re(Ue),Ke=y-tn;if(Math.abs(Ke)<4)V=Zi.Flag.Secondary,qe(Se(Ue));else{V=Zi.Flag.Auxilary,Le(Ue);const Pt=y/tn;q.next({delta:Ke,fraction:Pt,fractionDelta:b-Pt,distance:tn,isStart:!1,buttons:V,button:F,modifiers:R()}),b=Pt}y=tn}else 3===Ue.touches.length&&(V=Zi.Flag.Forth,qe(Se(Ue)))}function ut(Ue){Le(Ue),V=w8(Ue),F=tue(Ue),ln(Ue)}function Ct(Ue){Le(Ue),V=w8(Ue),F=Zi.Flag.None,qe(Ue)}function Et(Ue){Le(Ue),V=w8(Ue),F=tue(Ue),function Qn(Ue){if(M=T0.Stopped,l(Ue.clientX,Ue.clientY)){if(hr(S,Ue),!L&&Me.distance(S,x)<4){const{pageX:tn,pageY:Ke}=Pi(Ue),[Pt,Ht]=S;H.next({x:Pt,y:Ht,pageX:tn,pageY:Ke,buttons:V,button:F,modifiers:R()})}L=!1}}(Ue),Xt()}function Xt(){$.next(void 0)}function ln(Ue){l(Ue.clientX,Ue.clientY)&&(hr(_,Ue),Me.copy(x,_),Nn(_)&&(M=T0.Started))}function qe(Ue){var tn;hr(S,Ue);const{pageX:Ke,pageY:Pt}=Pi(Ue),[Ht,Ur]=S,{movementX:Zs,movementY:Na}=Ue,gc=Nn(S)&&l(Ue.clientX,Ue.clientY);if(G&&!gc?Q.next(void 0):!G&&gc&&fe.next(void 0),G=gc,D.x=Ht,D.y=Ur,D.pageX=Ke,D.pageY=Pt,W.next({x:Ht,y:Ur,pageX:Ke,pageY:Pt,movementX:Zs,movementY:Na,buttons:V,button:F,modifiers:R(),inside:gc,onElement:Ue.target===r}),M===T0.Stopped||(u&&(null===(tn=Ue.preventDefault)||void 0===tn||tn.call(Ue)),Me.div(A,Me.sub(A,S,_),function hn(Ue){return Ue[0]=r.clientWidth,Ue[1]=r.clientHeight,Ue}(E)),Me.magnitude(A)=4&&(L=!0);const[Jm,eg]=A;Z.next({x:Ht,y:Ur,dx:Jm,dy:eg,pageX:Ke,pageY:Pt,buttons:V,button:F,modifiers:R(),isStart:yc}),Me.copy(_,S),M=T0.Moving}function dt(Ue){if(!l(Ue.clientX,Ue.clientY))return;hr(S,Ue);const{pageX:tn,pageY:Ke}=Pi(Ue),[Pt,Ht]=S;o&&Ue.preventDefault();const Ur=function ktt(e){let i=0,o=0,s=0,a=0,c=0;return"detail"in e&&(o=e.detail),"wheelDelta"in e&&(o=-e.wheelDelta/120),"wheelDeltaY"in e&&(o=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(i=-e.wheelDeltaX/120),"axis"in e&&e.axis===e.HORIZONTAL_AXIS&&(i=o,o=0),s=10*i,a=10*o,"deltaY"in e&&(a=e.deltaY),"deltaX"in e&&(s=e.deltaX),"deltaZ"in e&&(c=e.deltaZ),(s||a||c)&&e.deltaMode&&(1===e.deltaMode?(s*=40,a*=40,c*=40):(s*=800,a*=800,c*=800)),s&&!i&&(i=s<1?-1:1),a&&!o&&(o=a<1?-1:1),{spinX:i,spinY:o,dx:s,dy:a,dz:c}}(Ue);V=F=Zi.Flag.Auxilary,(Ur.dx||Ur.dy||Ur.dz)&&ee.next({x:Pt,y:Ht,pageX:tn,pageY:Ke,...Ur,buttons:V,button:F,modifiers:R()})}function gt(Ue){var tn,Ke;f&&(Ue.preventDefault(),null===(tn=Ue.stopImmediatePropagation)||void 0===tn||tn.call(Ue),null===(Ke=Ue.stopPropagation)||void 0===Ke||Ke.call(Ue))}let se=0,he=0;function ve(Ue){gt(Ue),se=Ue.scale,he=Ue.rotation,O.next({scale:Ue.scale,rotation:Ue.rotation,deltaRotation:0,deltaScale:0,isStart:!0})}function Te(Ue,tn){O.next({scale:Ue.scale,rotation:Ue.rotation,deltaRotation:he-Ue.rotation,deltaScale:se-Ue.scale,isEnd:tn}),he=Ue.rotation,se=Ue.scale}function yt(Ue){gt(Ue),Te(Ue)}function xt(Ue){gt(Ue),Te(Ue,!0)}function Ut(){X.next({})}function Nn(Ue){if(r instanceof Window||r instanceof Document||r===document.body)return!0;{const tn=r.getBoundingClientRect();return Ue[0]>=0&&Ue[1]>=0&&Ue[0]{d=Ue,p=r.clientWidth*I(),m=r.clientHeight*I()},requestPointerLock:Ue=>{g=Ue,h||r.requestPointerLock()},exitPointerLock:()=>{h&&r.ownerDocument.exitPointerLock()},dispose:function K(){N||(N=!0,r.removeEventListener("contextmenu",we,!1),r.removeEventListener("wheel",dt,!1),r.removeEventListener("mousedown",ut,!1),window.removeEventListener("mousemove",Ct,!1),window.removeEventListener("mouseup",Et,!1),r.removeEventListener("touchstart",Xe,!1),r.removeEventListener("touchmove",_t,!1),r.removeEventListener("touchend",ot,!1),r.removeEventListener("gesturechange",yt,!1),r.removeEventListener("gesturestart",ve,!1),r.removeEventListener("gestureend",xt,!1),window.removeEventListener("blur",We),window.removeEventListener("keyup",Y,!1),window.removeEventListener("keydown",U,!1),window.removeEventListener("keypress",ge,!1),document.removeEventListener("pointerlockchange",ne,!1),document.removeEventListener("pointerlockerror",de,!1),ho.remove(),null!=z?(z.unobserve(r.parentElement),z.disconnect()):window.removeEventListener("resize",Ut,!1))}}}}(A8||(A8={}));var D0=function(e){return e[e.None=0]="None",e[e.Object=1]="Object",e[e.Instance=2]="Instance",e[e.Group=3]="Group",e}(D0||{}),SE=function(e){return e[e.None=0]="None",e[e.Depth=1]="Depth",e[e.Mask=2]="Mask",e}(SE||{});const I8={backgroundColor:C.Color(st(0),{description:"Background color of the 3D canvas"}),pickingAlphaThreshold:C.Numeric(.5,{min:0,max:1,step:.01},{description:"The minimum opacity value needed for an object to be pickable."}),interiorDarkening:C.Numeric(.5,{min:0,max:1,step:.01}),interiorColorFlag:C.Boolean(!0,{label:"Use Interior Color"}),interiorColor:C.Color(st.fromNormalizedRgb(.3,.3,.3)),colorMarker:C.Boolean(!0,{description:"Enable color marker"}),highlightColor:C.Color(st.fromNormalizedRgb(1,.4,.6)),selectColor:C.Color(st.fromNormalizedRgb(.2,1,.1)),dimColor:C.Color(st.fromNormalizedRgb(1,1,1)),highlightStrength:C.Numeric(.3,{min:0,max:1,step:.1}),selectStrength:C.Numeric(.3,{min:0,max:1,step:.1}),dimStrength:C.Numeric(0,{min:0,max:1,step:.1}),markerPriority:C.Select(1,[[1,"Highlight"],[2,"Select"]]),xrayEdgeFalloff:C.Numeric(1,{min:0,max:3,step:.1}),exposure:C.Numeric(1,{min:0,max:3,step:.01}),light:C.ObjectList({inclination:C.Numeric(150,{min:0,max:180,step:1}),azimuth:C.Numeric(320,{min:0,max:360,step:1}),color:C.Color(st.fromNormalizedRgb(1,1,1)),intensity:C.Numeric(.6,{min:0,max:5,step:.01})},e=>st.toHexString(e.color),{defaultValue:[{inclination:150,azimuth:320,color:st.fromNormalizedRgb(1,1,1),intensity:.6}]}),ambientColor:C.Color(st.fromNormalizedRgb(1,1,1)),ambientIntensity:C.Numeric(.4,{min:0,max:2,step:.01})},oue=v(),T8=v();function sue(e,t){const n=e.length,{direction:r,color:i}=t||{direction:new Array(3*n).fill(0),color:new Array(3*n).fill(0)};for(let o=0;o{var K,ne,de;if(ae.state.disposed||!ae.state.visible||!ae.state.pickable&&"pick"===me||!p0.intersectsSphere3D(R,ae.values.boundingSphere.ref.value))return;const[we,Le]=ae.values.uLod.ref.value;if(0!==we||0!==Le){const{center:Y,radius:ge}=ae.values.boundingSphere.ref.value,Se=Gi.distanceToPoint(D,Y);if(Se+geLe)return}ae.values.instanceGrid.ref.value.cellSize>1||ae.values.lodLevels?ae.cull(D,R,p,n.stats):ae.uncull();let We=!1;ae.values.dLightCount.ref.value!==c.count&&(k.update(ae.values.dLightCount,c.count),We=!0),ae.values.dColorMarker.ref.value!==a.colorMarker&&(k.update(ae.values.dColorMarker,a.colorMarker),We=!0),We&&ae.update();const U=ae.getProgram(me);if(o.currentProgramId!==U.id&&(V=!0,U.use()),V&&(U.setUniforms(N),U.bindTextures(h,0),V=!1),"directVolume"===ae.values.dGeometryType.ref.value){if("color"!==me)return;o.disable(i.CULL_FACE),o.frontFace(i.CCW),3===oe&&(o.disable(i.DEPTH_TEST),o.depthMask(!1))}else 1===oe?(o.enable(i.CULL_FACE),null!==(K=ae.values.dFlipSided)&&void 0!==K&&K.ref.value?(o.frontFace(i.CW),o.cullFace(i.FRONT)):(o.frontFace(i.CCW),o.cullFace(i.BACK))):2===oe?(o.enable(i.CULL_FACE),null!==(ne=ae.values.dFlipSided)&&void 0!==ne&&ne.ref.value?(o.frontFace(i.CW),o.cullFace(i.BACK)):(o.frontFace(i.CCW),o.cullFace(i.FRONT))):(ae.values.uDoubleSided?ae.values.uDoubleSided.ref.value||ae.values.hasReflection.ref.value?o.disable(i.CULL_FACE):o.enable(i.CULL_FACE):o.disable(i.CULL_FACE),null!==(de=ae.values.dFlipSided)&&void 0!==de&&de.ref.value?(o.frontFace(i.CW),o.cullFace(i.FRONT)):(o.frontFace(i.CCW),o.cullFace(i.BACK)));ae.render(me,h.length)},L=(ae,me,oe,K,ne)=>{HI(h,"tDepth",oe||m),k.update(M.uModel,ae.view),k.update(M.uModelView,le.mul(b,me.view,ae.view)),k.update(M.uInvModelView,le.invert(x,b)),k.update(M.uModelViewProjection,le.mul(S,b,me.projection)),k.update(M.uInvModelViewProjection,le.invert(A,S)),k.updateIfChanged(M.uRenderMask,K),k.updateIfChanged(M.uMarkingDepthTest,ne),o.enable(i.SCISSOR_TEST),o.colorMask(!0,!0,!0,!0);const{x:de,y:we,width:Le,height:We}=u;o.viewport(de,we,Le,We),o.scissor(de,we,Le,We),V=!0,o.currentRenderItemId=-1},H=(ae,me,oe)=>{var K,ne;lt&&n.timer.mark("Renderer.renderBlendedOpaque"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,1,!1);const{renderables:de}=ae;for(let we=0,Le=de.length;we{var K,ne;lt&&n.timer.mark("Renderer.renderBlendedTransparent"),o.enable(i.DEPTH_TEST),L(ae,me,oe,2,!1);const{renderables:de}=ae;f?o.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA):o.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA),o.enable(i.BLEND),o.depthMask(!0);for(let we=0,Le=de.length;we0)&&(null!==(K=We.values.uDoubleSided)&&void 0!==K&&K.ref.value?("opaque"!==(null===(ne=We.values.dTransparentBackfaces)||void 0===ne?void 0:ne.ref.value)&&F(We,"color",2),F(We,"color",1)):F(We,"color",0))}lt&&n.timer.markEnd("Renderer.renderBlendedTransparent")};return{clear:(ae,me)=>{o.enable(i.SCISSOR_TEST),o.enable(i.DEPTH_TEST),o.colorMask(!0,!0,!0,!0),o.depthMask(!0),f&&!me?o.clearColor(0,0,0,0):ae?o.clearColor(d[0],d[1],d[2],1):o.clearColor(1,1,1,1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT)},clearDepth:(ae=!1)=>{o.enable(i.SCISSOR_TEST),ae?(o.colorMask(!0,!0,!0,!0),o.clearColor(1,1,1,1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT)):(o.enable(i.DEPTH_TEST),o.depthMask(!0),i.clear(i.DEPTH_BUFFER_BIT))},update:(ae,me)=>{k.update(M.uView,ae.view),k.update(M.uInvView,le.invert(y,ae.view)),k.update(M.uProjection,ae.projection),k.update(M.uInvProjection,le.invert(_,ae.projection)),k.updateIfChanged(M.uIsOrtho,"orthographic"===ae.state.mode?1:0),k.update(M.uViewOffset,ae.viewOffset.enabled?Me.set(I,16*ae.viewOffset.offsetX,16*ae.viewOffset.offsetY):Me.set(I,0,0)),k.update(M.uCameraPosition,v.copy(w,ae.state.position)),k.update(M.uCameraDir,v.normalize(E,v.sub(E,ae.state.target,ae.state.position))),k.updateIfChanged(M.uFar,ae.far),k.updateIfChanged(M.uNear,ae.near),k.updateIfChanged(M.uFog,ae.state.fog>0),k.updateIfChanged(M.uFogFar,ae.fogFar),k.updateIfChanged(M.uFogNear,ae.fogNear),k.updateIfChanged(M.uTransparentBackground,f),p0.fromProjectionMatrix(R,ae.projectionView),Gi.copy(D,R[5]),D.constant-=Gi.distanceToPoint(D,w),k.update(M.uCameraPlane,Gi.toArray(D,M.uCameraPlane.ref.value,0)),k.updateIfChanged(M.uMarkerAverage,me.markerAverage)},renderPick:(ae,me,oe,K,ne)=>{lt&&n.timer.mark("Renderer.renderPick"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,K,0,!1),k.updateIfChanged(M.uPickType,ne);const{renderables:de}=ae;for(let we=0,Le=de.length;we{lt&&n.timer.mark("Renderer.renderDepth"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,0,!1);const{renderables:K}=ae;for(let ne=0,de=K.length;ne{var K,ne;lt&&n.timer.mark("Renderer.renderDepthOpaque"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,1,!1);const{renderables:de}=ae;for(let we=0,Le=de.length;we{var K,ne;lt&&n.timer.mark("Renderer.renderDepthTransparent"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,2,!1);const{renderables:de}=ae;for(let we=0,Le=de.length;we0||U)&&F(We,"depth",0)}lt&&n.timer.markEnd("Renderer.renderDepthTransparent")},renderMarkingDepth:(ae,me,oe)=>{lt&&n.timer.mark("Renderer.renderMarkingDepth"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,0,!1),k.updateIfChanged(M.uMarkingType,SE.Depth);const{renderables:K}=ae;for(let ne=0,de=K.length;ne{lt&&n.timer.mark("Renderer.renderMarkingMask"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,0,!!oe),k.updateIfChanged(M.uMarkingType,SE.Mask);const{renderables:K}=ae;for(let ne=0,de=K.length;ne0&&F(K[ne],"marking",0);lt&&n.timer.markEnd("Renderer.renderMarkingMask")},renderBlended:(ae,me)=>{ae.hasOpaque&&H(ae,me,null),ae.opacityAverage<1&&W(ae,me,null)},renderBlendedOpaque:H,renderBlendedTransparent:W,renderBlendedVolume:(ae,me,oe)=>{lt&&n.timer.mark("Renderer.renderBlendedVolume"),o.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA),o.enable(i.BLEND),L(ae,me,oe,2,!1);const{renderables:K}=ae;for(let ne=0,de=K.length;ne{var K,ne,de,we;lt&&n.timer.mark("Renderer.renderWboitOpaque"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,1,!1);const{renderables:Le}=ae;for(let We=0,U=Le.length;We{var K,ne,de;lt&&n.timer.mark("Renderer.renderWboitTransparent"),L(ae,me,oe,2,!1);const{renderables:we}=ae;for(let Le=0,We=we.length;Le0||"directVolume"===U.values.dGeometryType.ref.value||"fuzzy"===(null===(de=U.values.dPointStyle)||void 0===de?void 0:de.ref.value)||"text"===U.values.dGeometryType.ref.value||ge)&&F(U,"color",0)}lt&&n.timer.markEnd("Renderer.renderWboitTransparent")},renderDpoitOpaque:(ae,me,oe)=>{var K,ne,de,we;lt&&n.timer.mark("Renderer.renderDpoitOpaque"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,1,!1);const{renderables:Le}=ae;for(let We=0,U=Le.length;We{var ne,de,we;lt&&n.timer.mark("Renderer.renderDpoitTransparent"),o.enable(i.BLEND),HI(h,"tDpoitDepth",K.depth),HI(h,"tDpoitFrontColor",K.frontColor),HI(h,"tDpoitBackColor",K.backColor),L(ae,me,oe,2,!1);const{renderables:Le}=ae;for(let We=0,U=Le.length;We0||"fuzzy"===(null===(we=Y.values.dPointStyle)||void 0===we?void 0:we.ref.value)||"text"===Y.values.dGeometryType.ref.value||Se)&&F(Y,"color",0)}lt&&n.timer.markEnd("Renderer.renderDpoitTransparent")},renderDpoitVolume:(ae,me,oe)=>{lt&&n.timer.mark("Renderer.renderDpoitVolume"),o.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA),o.enable(i.BLEND),L(ae,me,oe,2,!1);const{renderables:K}=ae;for(let ne=0,de=K.length;ne{void 0!==ae.backgroundColor&&ae.backgroundColor!==a.backgroundColor&&(a.backgroundColor=ae.backgroundColor,st.toVec3Normalized(d,a.backgroundColor),k.update(M.uFogColor,v.copy(M.uFogColor.ref.value,d))),void 0!==ae.pickingAlphaThreshold&&ae.pickingAlphaThreshold!==a.pickingAlphaThreshold&&(a.pickingAlphaThreshold=ae.pickingAlphaThreshold,k.update(M.uPickingAlphaThreshold,a.pickingAlphaThreshold)),void 0!==ae.interiorDarkening&&ae.interiorDarkening!==a.interiorDarkening&&(a.interiorDarkening=ae.interiorDarkening,k.update(M.uInteriorDarkening,a.interiorDarkening)),void 0!==ae.interiorColorFlag&&ae.interiorColorFlag!==a.interiorColorFlag&&(a.interiorColorFlag=ae.interiorColorFlag,k.update(M.uInteriorColorFlag,a.interiorColorFlag)),void 0!==ae.interiorColor&&ae.interiorColor!==a.interiorColor&&(a.interiorColor=ae.interiorColor,k.update(M.uInteriorColor,st.toVec3Normalized(M.uInteriorColor.ref.value,a.interiorColor))),void 0!==ae.colorMarker&&ae.colorMarker!==a.colorMarker&&(a.colorMarker=ae.colorMarker),void 0!==ae.highlightColor&&ae.highlightColor!==a.highlightColor&&(a.highlightColor=ae.highlightColor,k.update(M.uHighlightColor,st.toVec3Normalized(M.uHighlightColor.ref.value,a.highlightColor))),void 0!==ae.selectColor&&ae.selectColor!==a.selectColor&&(a.selectColor=ae.selectColor,k.update(M.uSelectColor,st.toVec3Normalized(M.uSelectColor.ref.value,a.selectColor))),void 0!==ae.dimColor&&ae.dimColor!==a.dimColor&&(a.dimColor=ae.dimColor,k.update(M.uDimColor,st.toVec3Normalized(M.uDimColor.ref.value,a.dimColor))),void 0!==ae.highlightStrength&&ae.highlightStrength!==a.highlightStrength&&(a.highlightStrength=ae.highlightStrength,k.update(M.uHighlightStrength,a.highlightStrength)),void 0!==ae.selectStrength&&ae.selectStrength!==a.selectStrength&&(a.selectStrength=ae.selectStrength,k.update(M.uSelectStrength,a.selectStrength)),void 0!==ae.dimStrength&&ae.dimStrength!==a.dimStrength&&(a.dimStrength=ae.dimStrength,k.update(M.uDimStrength,a.dimStrength)),void 0!==ae.markerPriority&&ae.markerPriority!==a.markerPriority&&(a.markerPriority=ae.markerPriority,k.update(M.uMarkerPriority,a.markerPriority)),void 0!==ae.xrayEdgeFalloff&&ae.xrayEdgeFalloff!==a.xrayEdgeFalloff&&(a.xrayEdgeFalloff=ae.xrayEdgeFalloff,k.update(M.uXrayEdgeFalloff,a.xrayEdgeFalloff)),void 0!==ae.exposure&&ae.exposure!==a.exposure&&(a.exposure=ae.exposure,k.update(M.uExposure,a.exposure)),void 0!==ae.light&&!Yd(ae.light,a.light)&&(a.light=ae.light,Object.assign(c,sue(ae.light,c)),k.update(M.uLightDirection,c.direction),k.update(M.uLightColor,c.color)),void 0!==ae.ambientColor&&ae.ambientColor!==a.ambientColor&&(a.ambientColor=ae.ambientColor,v.scale(T,st.toArrayNormalized(a.ambientColor,T,0),a.ambientIntensity),k.update(M.uAmbientColor,T)),void 0!==ae.ambientIntensity&&ae.ambientIntensity!==a.ambientIntensity&&(a.ambientIntensity=ae.ambientIntensity,v.scale(T,st.toArrayNormalized(a.ambientColor,T,0),a.ambientIntensity),k.update(M.uAmbientColor,T))},setViewport:(ae,me,oe,K)=>{o.viewport(ae,me,oe,K),o.scissor(ae,me,oe,K),(ae!==u.x||me!==u.y||oe!==u.width||K!==u.height)&&(Lo.set(u,ae,me,oe,K),k.update(M.uViewport,nn.set(M.uViewport.ref.value,ae,me,oe,K)))},setTransparentBackground:ae=>{f=ae},setDrawingBufferSize:(ae,me)=>{(ae!==l[0]||me!==l[1])&&k.update(M.uDrawingBufferSize,Me.set(l,ae,me))},setPixelRatio:ae=>{k.update(M.uPixelRatio,ae)},setOcclusionTest:ae=>{p=ae},props:a,get stats(){return{programCount:n.stats.resourceCounts.program,shaderCount:n.stats.resourceCounts.shader,attributeCount:n.stats.resourceCounts.attribute,elementsCount:n.stats.resourceCounts.elements,framebufferCount:n.stats.resourceCounts.framebuffer,renderbufferCount:n.stats.resourceCounts.renderbuffer,textureCount:n.stats.resourceCounts.texture,vertexArrayCount:n.stats.resourceCounts.vertexArray,drawCount:s.drawCount,instanceCount:s.instanceCount,instancedDrawCount:s.instancedDrawCount}},get light(){return c},dispose:()=>{}}}}(D8||(D8={})),function(e){function s(l){return l.triggers.map(c.format).join(" or ")}function c(l,d){return c.create(l,d)}var l;e.create=function t(l,d="",f=""){return{triggers:l,action:d,description:f}},e.isBinding=function n(l){return!!l&&Array.isArray(l.triggers)&&"string"==typeof l.action},e.Empty={triggers:[],action:"",description:""},e.isEmpty=function r(l){return 0===l.triggers.length||l.triggers.every(d=>void 0===d.buttons&&void 0===d.modifiers&&!d.code)},e.match=function i(l,d,f){return l.triggers.some(p=>c.match(p,d,f))},e.matchKey=function o(l,d,f,p){return l.triggers.some(m=>c.matchKey(m,d,f,p))},e.formatTriggers=s,e.format=function a(l,d=""){return function RNe(e,t){const n=Object.keys(t),r=Object.values(t);return new Function(...n,`return \`${e}\`;`)(...r)}(l.description||zu(d),{triggers:""+s(l)+""})},e.Trigger=c,e.TriggerKey=function u(l,d){return c.create(void 0,d,l)},(l=c=e.Trigger||(e.Trigger={})).create=function d(h,g,y){return{buttons:h,modifiers:g,code:y}},l.Empty={},l.match=function f(h,g,y){const{buttons:b,modifiers:x}=h;return void 0!==b&&(b===g||Zi.has(b,g))&&(!x||wu.areEqual(x,y))},l.matchKey=function p(h,g,y,b){const{modifiers:x,code:_}=h;return void 0!==_&&(_===g||1===_.length&&4===g.length&&g.startsWith("Key")&&!!b&&1===b.length&&b.toUpperCase()===_.toUpperCase())&&(!x||wu.areEqual(x,y))},l.format=function m(h){const g=[],y=function Ntt(e,t){const n=[];return void 0!==e||t?0===e?n.push("mouse hover"):void 0!==e&&(Cm.has(e,Cm.Flag.Primary)&&n.push("left mouse button"),Cm.has(e,Cm.Flag.Secondary)&&n.push("right mouse button"),Cm.has(e,Cm.Flag.Auxilary)&&n.push("wheel/middle mouse button"),Cm.has(e,Cm.Flag.Forth)&&n.push("three fingers")):n.push("any mouse button"),n.join(" + ")}(h.buttons,h.code);y&&g.push(y);const b=function Btt(e){return e?.startsWith("Key")&&(e=e.substring(3)),e&&function ENe(e){return Fg(RQ(e))}(e).toLowerCase()}(h.code);b&&g.push(b);const x=function Ftt(e,t){const n=[];return e?(e.alt&&n.push("alt key"),e.control&&n.push("control key"),e.meta&&n.push("meta/command key"),e.shift&&n.push("shift key"),t&&0===n.length&&n.push("no key")):t&&n.push("any key"),n.join(" + ")}(h.modifiers);return x&&g.push(x),g.join(" + ")}}(At||(At={}));const Cm=Zi,wm=Zi,Au=wu,Am=At.Trigger,Vc=At.TriggerKey,aue={dragRotate:At([Am(wm.Flag.Primary,Au.create())],"Rotate","Drag using ${triggers}"),dragRotateZ:At([Am(wm.Flag.Primary,Au.create({shift:!0,control:!0}))],"Rotate around z-axis (roll)","Drag using ${triggers}"),dragPan:At([Am(wm.Flag.Secondary,Au.create()),Am(wm.Flag.Primary,Au.create({control:!0}))],"Pan","Drag using ${triggers}"),dragZoom:At.Empty,dragFocus:At([Am(wm.Flag.Forth,Au.create())],"Focus","Drag using ${triggers}"),dragFocusZoom:At([Am(wm.Flag.Auxilary,Au.create())],"Focus and zoom","Drag using ${triggers}"),scrollZoom:At([Am(wm.Flag.Auxilary,Au.create())],"Zoom","Scroll using ${triggers}"),scrollFocus:At([Am(wm.Flag.Auxilary,Au.create({shift:!0}))],"Clip","Scroll using ${triggers}"),scrollFocusZoom:At.Empty,keyMoveForward:At([Vc("KeyW")],"Move forward","Press ${triggers}"),keyMoveBack:At([Vc("KeyS")],"Move back","Press ${triggers}"),keyMoveLeft:At([Vc("KeyA")],"Move left","Press ${triggers}"),keyMoveRight:At([Vc("KeyD")],"Move right","Press ${triggers}"),keyMoveUp:At([Vc("KeyR")],"Move up","Press ${triggers}"),keyMoveDown:At([Vc("KeyF")],"Move down","Press ${triggers}"),keyRollLeft:At([Vc("KeyQ")],"Roll left","Press ${triggers}"),keyRollRight:At([Vc("KeyE")],"Roll right","Press ${triggers}"),keyPitchUp:At([Vc("ArrowUp",Au.create({shift:!0}))],"Pitch up","Press ${triggers}"),keyPitchDown:At([Vc("ArrowDown",Au.create({shift:!0}))],"Pitch down","Press ${triggers}"),keyYawLeft:At([Vc("ArrowLeft",Au.create({shift:!0}))],"Yaw left","Press ${triggers}"),keyYawRight:At([Vc("ArrowRight",Au.create({shift:!0}))],"Yaw right","Press ${triggers}"),boostMove:At([Vc("ShiftLeft")],"Boost move","Press ${triggers}"),enablePointerLock:At([Vc("Space",Au.create({control:!0}))],"Enable pointer lock","Press ${triggers}")},cue={noScroll:C.Boolean(!0,{isHidden:!0}),rotateSpeed:C.Numeric(5,{min:1,max:10,step:1}),zoomSpeed:C.Numeric(7,{min:1,max:15,step:1}),panSpeed:C.Numeric(1,{min:.1,max:5,step:.1}),moveSpeed:C.Numeric(.75,{min:.1,max:3,step:.1}),boostMoveFactor:C.Numeric(5,{min:.1,max:10,step:.1}),flyMode:C.Boolean(!1),animate:C.MappedStatic("off",{off:C.EmptyGroup(),spin:C.Group({speed:C.Numeric(1,{min:-20,max:20,step:1})},{description:"Spin the 3D scene around the x-axis in view space"}),rock:C.Group({speed:C.Numeric(.3,{min:-5,max:5,step:.1}),angle:C.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:C.Boolean(!0,{isHidden:!0}),dynamicDampingFactor:C.Numeric(.2,{},{isHidden:!0}),minDistance:C.Numeric(.01,{},{isHidden:!0}),maxDistance:C.Numeric(1e150,{},{isHidden:!0}),gestureScaleFactor:C.Numeric(1,{},{isHidden:!0}),maxWheelDelta:C.Numeric(.02,{},{isHidden:!0}),bindings:C.Value(aue,{isHidden:!0}),autoAdjustMinMaxDistance:C.MappedStatic("on",{off:C.EmptyGroup(),on:C.Group({minDistanceFactor:C.Numeric(0),minDistancePadding:C.Numeric(5),maxDistanceFactor:C.Numeric(10),maxDistanceMin:C.Numeric(20)})},{isHidden:!0})};var E8,CE;!function(e){e.create=function t(n,r,i,o={}){const s={...C.getDefaultValues(cue),...o,bindings:{...aue,...o.bindings}},a=s.bindings,c=Lo.clone(r.viewport);let u=!1;const l=n.drag.subscribe(function Qn({x:Ke,y:Pt,pageX:Ht,pageY:Ur,buttons:Zs,modifiers:Na,isStart:gc}){const yc=Ct(Ke,Pt);if(gc&&yc||!gc&&!_)return;_=!0,Ue();const Jm=At.match(a.dragRotate,Zs,Na),eg=At.match(a.dragRotateZ,Zs,Na),K1=At.match(a.dragPan,Zs,Na),Z1=At.match(a.dragZoom,Zs,Na),Q1=At.match(a.dragFocus,Zs,Na),hy=At.match(a.dragFocusZoom,Zs,Na);Q(Ht,Ur),function H(Ke,Pt){Me.set(O,(Ke-c.x)/c.width,(Pt-c.y)/c.height)}(Ht,Ur);const J1=n.pixelRatio,e_=(Ke*J1-c.width/2-c.x)/c.width,t_=-(n.height-Pt*J1-c.height/2-c.y)/c.height;if(gc&&(Jm&&(Me.copy(w,W),Me.copy(E,w)),eg&&(Me.set(T,e_,t_),Me.copy(R,T)),(Z1||hy)&&(Me.copy(F,O),Me.copy(G,F)),Q1&&(Me.copy(L,O),Me.copy(z,L)),K1&&(Me.copy(j,O),Me.copy(Z,j))),Jm&&Me.copy(w,W),eg&&Me.set(T,e_,t_),(Z1||hy)&&Me.copy(G,O),Q1&&Me.copy(z,O),hy){const my=v.distance(r.state.position,r.state.target);r.setState({radius:my/5})}K1&&Me.copy(Z,O)}),d=n.interactionEnd.subscribe(function qe(){_=!1}),f=n.wheel.subscribe(function dt({x:Ke,y:Pt,spinX:Ht,spinY:Ur,dz:Zs,buttons:Na,modifiers:gc}){if(Ct(Ke,Pt))return;let yc=function nMe(...e){let t=0,n=0;for(let r=0,i=e.length;rn&&(t=o,n=s)}return t}(.075*Ht,.075*Ur,1e-4*Zs);yc<-s.maxWheelDelta?yc=-s.maxWheelDelta:yc>s.maxWheelDelta&&(yc=s.maxWheelDelta),At.match(a.scrollZoom,Na,gc)&&(G[1]+=yc),At.match(a.scrollFocus,Na,gc)&&(z[1]+=yc)}),p=n.pinch.subscribe(function gt({fractionDelta:Ke,buttons:Pt,modifiers:Ht}){At.match(a.scrollZoom,Pt,Ht)&&(_=!0,G[1]+=s.gestureScaleFactor*Ke)}),m=n.gesture.subscribe(function se({deltaScale:Ke}){_=!0,G[1]+=s.gestureScaleFactor*Ke}),h=n.keyDown.subscribe(function ve({modifiers:Ke,code:Pt,key:Ht,x:Ur,y:Zs}){Ct(Ur,Zs)||(At.matchKey(a.keyMoveForward,Pt,Ke,Ht)?ke.moveForward=1:At.matchKey(a.keyMoveBack,Pt,Ke,Ht)?ke.moveBack=1:At.matchKey(a.keyMoveLeft,Pt,Ke,Ht)?ke.moveLeft=1:At.matchKey(a.keyMoveRight,Pt,Ke,Ht)?ke.moveRight=1:At.matchKey(a.keyMoveUp,Pt,Ke,Ht)?ke.moveUp=1:At.matchKey(a.keyMoveDown,Pt,Ke,Ht)?ke.moveDown=1:At.matchKey(a.keyRollLeft,Pt,Ke,Ht)?ke.rollLeft=1:At.matchKey(a.keyRollRight,Pt,Ke,Ht)?ke.rollRight=1:At.matchKey(a.keyPitchUp,Pt,Ke,Ht)?ke.pitchUp=1:At.matchKey(a.keyPitchDown,Pt,Ke,Ht)?ke.pitchDown=1:At.matchKey(a.keyYawLeft,Pt,Ke,Ht)?ke.yawLeft=1:At.matchKey(a.keyYawRight,Pt,Ke,Ht)&&(ke.yawRight=1),At.matchKey(a.boostMove,Pt,Ke,Ht)&&(ke.boostMove=1),At.matchKey(a.enablePointerLock,Pt,Ke,Ht)&&n.requestPointerLock(c))}),g=n.keyUp.subscribe(function Te({modifiers:Ke,code:Pt,key:Ht,x:Ur,y:Zs}){var Na,gc,yc,Jm,eg,K1,Z1,Q1,hy,J1,e_,t_;if(Ct(Ur,Zs))return;let my=!1;Pt.startsWith("Alt")?(my=!0,Ke.alt=!0):Pt.startsWith("Shift")?(my=!0,Ke.shift=!0):Pt.startsWith("Control")?(my=!0,Ke.control=!0):Pt.startsWith("Meta")&&(my=!0,Ke.meta=!0);const Wc=[];my?(ke.moveForward&&Wc.push((null===(Na=a.keyMoveForward.triggers[0])||void 0===Na?void 0:Na.code)||""),ke.moveBack&&Wc.push((null===(gc=a.keyMoveBack.triggers[0])||void 0===gc?void 0:gc.code)||""),ke.moveLeft&&Wc.push((null===(yc=a.keyMoveLeft.triggers[0])||void 0===yc?void 0:yc.code)||""),ke.moveRight&&Wc.push((null===(Jm=a.keyMoveRight.triggers[0])||void 0===Jm?void 0:Jm.code)||""),ke.moveUp&&Wc.push((null===(eg=a.keyMoveUp.triggers[0])||void 0===eg?void 0:eg.code)||""),ke.moveDown&&Wc.push((null===(K1=a.keyMoveDown.triggers[0])||void 0===K1?void 0:K1.code)||""),ke.rollLeft&&Wc.push((null===(Z1=a.keyRollLeft.triggers[0])||void 0===Z1?void 0:Z1.code)||""),ke.rollRight&&Wc.push((null===(Q1=a.keyRollRight.triggers[0])||void 0===Q1?void 0:Q1.code)||""),ke.pitchUp&&Wc.push((null===(hy=a.keyPitchUp.triggers[0])||void 0===hy?void 0:hy.code)||""),ke.pitchDown&&Wc.push((null===(J1=a.keyPitchDown.triggers[0])||void 0===J1?void 0:J1.code)||""),ke.yawLeft&&Wc.push((null===(e_=a.keyYawLeft.triggers[0])||void 0===e_?void 0:e_.code)||""),ke.yawRight&&Wc.push((null===(t_=a.keyYawRight.triggers[0])||void 0===t_?void 0:t_.code)||"")):Wc.push(Pt);for(const Nl of Wc)At.matchKey(a.keyMoveForward,Nl,Ke,Ht)?ke.moveForward=0:At.matchKey(a.keyMoveBack,Nl,Ke,Ht)?ke.moveBack=0:At.matchKey(a.keyMoveLeft,Nl,Ke,Ht)?ke.moveLeft=0:At.matchKey(a.keyMoveRight,Nl,Ke,Ht)?ke.moveRight=0:At.matchKey(a.keyMoveUp,Nl,Ke,Ht)?ke.moveUp=0:At.matchKey(a.keyMoveDown,Nl,Ke,Ht)?ke.moveDown=0:At.matchKey(a.keyRollLeft,Nl,Ke,Ht)?ke.rollLeft=0:At.matchKey(a.keyRollRight,Nl,Ke,Ht)?ke.rollRight=0:At.matchKey(a.keyPitchUp,Nl,Ke,Ht)?ke.pitchUp=0:At.matchKey(a.keyPitchDown,Nl,Ke,Ht)?ke.pitchDown=0:At.matchKey(a.keyYawLeft,Nl,Ke,Ht)?ke.yawLeft=0:At.matchKey(a.keyYawRight,Nl,Ke,Ht)&&(ke.yawRight=0);At.matchKey(a.boostMove,Pt,Ke,Ht)&&(ke.boostMove=0)}),y=n.move.subscribe(function he({movementX:Ke,movementY:Pt}){if(!n.pointerLock||void 0===Ke||void 0===Pt)return;const Ht=.5*c.width-c.x,Ur=.5*c.height-c.y;Me.copy(E,Q(Ht,Ur)),Me.copy(w,Q(Ke+Ht,Pt+Ur))}),b=n.lock.subscribe(function Ut(Ke){Ke?yt():xt()}),x=n.leave.subscribe(function hn(){!function Nn(){ke.moveForward=0,ke.moveBack=0,ke.moveLeft=0,ke.moveRight=0,ke.moveUp=0,ke.moveDown=0,ke.rollLeft=0,ke.rollRight=0,ke.pitchUp=0,ke.pitchDown=0,ke.yawLeft=0,ke.yawRight=0,ke.boostMove=0}()});let _=!1;const S=v(),A=v(),E=Me(),w=Me(),D=v();let I=0;const R=Me(),T=Me();let M=0,N=0,V=0;const F=Me(),G=Me(),L=Me(),z=Me(),j=Me(),Z=Me(),$=v.clone(r.target),ee=v.clone(r.position),q=v.clone(r.up),O=Me(),W=Me();function Q(Ke,Pt){return Me.set(W,(Ke-.5*c.width-c.x)/(.5*c.width),(c.height+2*(c.y-Pt))/c.width)}function fe(){return s.rotateSpeed*n.pixelRatio*(n.width/n.height)}const X=v(),J=_r(),ce=v(),be=v(),ae=v(),me=v(),K=_r(),ne=v(),we=_r(),Le=v(),U=_r(),Y=v(),Ne=Me(),Ge=v(),$e=v(),ke={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},Xe=v(),ot=v();function ut(){const Ke=Math.min(Math.max(1e3*r.state.radiusMax,.01),s.maxDistance);v.squaredMagnitude(A)>Ke*Ke&&(v.setMagnitude(A,A,Ke),v.add(r.position,r.target,A),Me.copy(F,G),Me.copy(L,z)),v.squaredMagnitude(A)c.x+c.width||n.height-Pt>c.y+c.height||Ke0&&("spin"===s.animate.name?function Ks(Ke){if("spin"!==s.animate.name||0===s.animate.params.speed||_)return;const Pt=s.animate.params.speed/1e3;Pi[0]=60*Math.min(Math.abs(Ke),125)/1e3*Pt,Me.add(w,E,Pi)}(Pt):"rock"===s.animate.name&&function Ed(Ke){if("rock"!==s.animate.name||0===s.animate.params.speed||_)return;const Pt=Ke/1e3*s.animate.params.speed,Ht=Yn(s.animate.params.angle)/fe(),Ur=Math.sin(ho*Math.PI*2)*Ht,Zs=Math.sin((ho+Pt)*Math.PI*2)*Ht;mc[0]=Zs-Ur,Me.add(w,E,mc),ho+=Pt,ho>=1&&(ho=0)}(Pt)),v.sub(A,r.position,r.target),function oe(){const Ke=w[0]-E[0],Pt=w[1]-E[1];v.set(me,Ke,Pt,0);const Ht=v.magnitude(me)*fe();Ht?(v.sub(A,r.position,r.target),v.normalize(ce,A),v.normalize(be,r.up),v.normalize(ae,v.cross(ae,be,ce)),v.setMagnitude(be,be,Pt),v.setMagnitude(ae,ae,Ke),v.add(me,be,ae),v.normalize(X,v.cross(X,me,A)),_r.setAxisAngle(J,X,Ht),v.transformQuat(A,A,J),v.transformQuat(r.up,r.up,J),v.copy(D,X),I=Ht):!s.staticMoving&&I&&(I*=Math.sqrt(1-s.dynamicDampingFactor),v.sub(A,r.position,r.target),_r.setAxisAngle(J,D,I),v.transformQuat(A,A,J),v.transformQuat(r.up,r.up,J)),Me.copy(E,w)}(),function de(){const Ke=(ke.rollRight-ke.rollLeft)/45,Pt=(T[0]-R[0])*-Math.sign(T[1]),Ht=(T[1]-R[1])*-Math.sign(T[0]),Ur=-s.rotateSpeed*(-Pt+Ht)+Ke;Ur?(v.normalize(ne,A),_r.setAxisAngle(K,ne,Ur),v.transformQuat(r.up,r.up,K),M=Ur):!s.staticMoving&&M&&(M*=Math.sqrt(1-s.dynamicDampingFactor),v.normalize(ne,A),_r.setAxisAngle(K,ne,M),v.transformQuat(r.up,r.up,K)),Me.copy(R,T)}(),function We(){const Pt=(ke.pitchUp-ke.pitchDown)/(s.flyMode?360:90)*-s.rotateSpeed;Pt?(v.cross(Le,A,r.up),v.normalize(Le,Le),_r.setAxisAngle(we,Le,Pt),v.transformQuat(A,A,we),v.transformQuat(r.up,r.up,we),N=Pt):!s.staticMoving&&N&&(N*=Math.sqrt(1-s.dynamicDampingFactor),v.cross(Le,A,r.up),v.normalize(Le,Le),_r.setAxisAngle(we,Le,N),v.transformQuat(A,A,we),v.transformQuat(r.up,r.up,we))}(),function ge(){const Pt=(ke.yawRight-ke.yawLeft)/(s.flyMode?360:90)*-s.rotateSpeed;Pt?(v.normalize(Y,r.up),_r.setAxisAngle(U,Y,Pt),v.transformQuat(A,A,U),v.transformQuat(r.up,r.up,U),V=Pt):!s.staticMoving&&V&&(V*=Math.sqrt(1-s.dynamicDampingFactor),v.normalize(Y,r.up),_r.setAxisAngle(U,Y,V),v.transformQuat(A,A,U),v.transformQuat(r.up,r.up,U))}(),function Se(){const Ke=1+(G[1]-F[1])*s.zoomSpeed;1!==Ke&&Ke>0&&v.scale(A,A,Ke),s.staticMoving?Me.copy(F,G):F[1]+=(G[1]-F[1])*s.dynamicDampingFactor}(),function Re(){const Ke=(z[1]-L[1])*s.zoomSpeed;if(0!==Ke){const Pt=Math.max(1,r.state.radius+r.state.radius*Ke);r.setState({radius:Pt})}s.staticMoving?Me.copy(L,z):L[1]+=(z[1]-L[1])*s.dynamicDampingFactor}(),function tt(){if(Me.sub(Ne,Me.copy(Ne,Z),j),Me.squaredMagnitude(Ne)){const Ke=n.pixelRatio*s.panSpeed;Ne[0]*=1/r.zoom*r.viewport.width*Ke,Ne[1]*=1/r.zoom*r.viewport.height*Ke,v.cross($e,v.copy($e,A),r.up),v.setMagnitude($e,$e,Ne[0]),v.setMagnitude(Ge,r.up,Ne[1]),v.add($e,$e,Ge),v.add(r.position,r.position,$e),v.add(r.target,r.target,$e),s.staticMoving?Me.copy(j,Z):(Me.sub(Ne,Z,j),Me.scale(Ne,Ne,s.dynamicDampingFactor),Me.add(j,j,Ne))}}(),v.add(r.position,r.target,A),ut(),Et>0&&function _t(Ke){v.sub(ot,r.position,r.target);const Pt=Math.max(r.state.minNear,s.minDistance);v.setMagnitude(ot,ot,Pt);const Ht=.06*Ke*s.moveSpeed*(1===ke.boostMove?s.boostMoveFactor:1);if(1===ke.moveForward&&(v.normalize(Xe,ot),v.scaleAndSub(r.position,r.position,Xe,Ht),(s.flyMode||n.pointerLock)&&v.sub(r.target,r.position,ot)),1===ke.moveBack&&(v.normalize(Xe,ot),v.scaleAndAdd(r.position,r.position,Xe,Ht),(s.flyMode||n.pointerLock)&&v.sub(r.target,r.position,ot)),1===ke.moveLeft&&(v.cross(Xe,ot,r.up),v.normalize(Xe,Xe),s.flyMode||n.pointerLock?(v.scaleAndAdd(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,ot)):(v.scaleAndSub(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,A))),1===ke.moveRight&&(v.cross(Xe,ot,r.up),v.normalize(Xe,Xe),s.flyMode||n.pointerLock?(v.scaleAndSub(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,ot)):(v.scaleAndAdd(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,A))),1===ke.moveUp&&(v.normalize(Xe,r.up),s.flyMode||n.pointerLock?(v.scaleAndAdd(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,ot)):(v.scaleAndSub(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,A))),1===ke.moveDown&&(v.normalize(Xe,r.up),s.flyMode||n.pointerLock?(v.scaleAndSub(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,ot)):(v.scaleAndAdd(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,A))),s.flyMode||n.pointerLock){const Ur=v.distance(r.position,i.boundingSphereVisible.center);r.setState({minFar:Ur+i.boundingSphereVisible.radius})}}(Math.min(Pt,250)),v.sub(A,r.position,r.target),ut(),v.squaredDistance(S,r.position)>vr&&v.copy(S,r.position),Et=Ke}function yt(){v.sub(ot,r.position,r.target);const Ke=Math.max(r.state.minNear,s.minDistance);v.setMagnitude(ot,ot,Ke),v.sub(r.target,r.position,ot);const Pt=v.distance(r.position,i.boundingSphereVisible.center);r.setState({minFar:Pt+i.boundingSphereVisible.radius})}function xt(){const{center:Ke,radius:Pt}=i.boundingSphereVisible;if(v.distance(r.position,Ke)>Pt){const Ur=r.getFocus(Ke,Pt);r.setState({...Ur,minFar:0})}else r.setState({minFar:0,radius:i.boundingSphereVisible.radius})}const Pi=Me.create(.005,0);let ho=0;const mc=Me.create(.005,0);function Ue(){ho=0}return{viewport:c,get isAnimating(){return"off"!==s.animate.name},get isMoving(){return 1===ke.moveForward||1===ke.moveBack||1===ke.moveLeft||1===ke.moveRight||1===ke.moveUp||1===ke.moveDown||1===ke.rollLeft||1===ke.rollRight||1===ke.pitchUp||1===ke.pitchDown||1===ke.yawLeft||1===ke.yawRight},get props(){return s},setProps:Ke=>{var Pt;"rock"===(null===(Pt=Ke.animate)||void 0===Pt?void 0:Pt.name)&&"rock"!==s.animate.name&&Ue(),void 0!==Ke.flyMode&&Ke.flyMode!==s.flyMode&&(Ke.flyMode?yt():xt()),Object.assign(s,Ke),Object.assign(a,Ke.bindings)},start:function tn(Ke){Et=-1,Xt(Ke)},update:Xt,reset:function ln(){v.copy(r.target,$),v.copy(r.position,ee),v.copy(r.up,q),v.sub(A,r.position,r.target),v.copy(S,r.position)},dispose:function hr(){u||(u=!0,l.unsubscribe(),f.unsubscribe(),p.unsubscribe(),m.unsubscribe(),d.unsubscribe(),h.unsubscribe(),g.unsubscribe(),y.unsubscribe(),b.unsubscribe(),x.unsubscribe())}}}}(E8||(E8={})),function(e){e.create=function t(){return{view:le.identity(),position:v.create(0,0,0),direction:v.create(0,0,-1),up:v.create(0,1,0)}};const n=v.zero();e.update=function r(i){v.add(n,i.position,i.direction),le.lookAt(i.view,i.position,n,i.up)}}(CE||(CE={}));class Ott{constructor(){this.removeList=AB(),this.removeMap=new Map,this.addList=AB(),this.addMap=new Map}get isEmpty(){return 0===this.removeList.count&&0===this.addList.count}get size(){return this.removeMap.size+this.addMap.size}add(t){if(this.removeMap.has(t)){const r=this.removeMap.get(t);this.removeMap.delete(t),this.removeList.remove(r)}if(this.addMap.has(t))return;const n=this.addList.addLast(t);this.addMap.set(t,n)}remove(t){if(this.addMap.has(t)){const r=this.addMap.get(t);this.addMap.delete(t),this.addList.remove(r)}if(this.removeMap.has(t))return;const n=this.removeList.addLast(t);this.removeMap.set(t,n)}tryGetRemove(){const t=this.removeList.removeFirst();return t&&this.removeMap.delete(t),t}tryGetAdd(){const t=this.addList.removeFirst();return t&&this.addMap.delete(t),t}}const QS=new fu("98");function uue(e,t,n){QS.reset();for(let r=0,i=e.length;r{r=L;for(let z=0,j=o.length;zR.add(L),remove:L=>R.remove(L),commit:(L=Number.MAX_VALUE)=>function I(L){const z=yi();let j=0;for(;;){const Z=R.tryGetRemove();if(!Z)break;if(w(Z),++j%100==0&&yi()-z>L)return!1}for(;;){const Z=R.tryGetAdd();if(!Z)break;if(E(Z),++j%100==0&&yi()-z>L)return!1}return o.sort(Ltt),f=!0,p=!0,m=!0,!0}(L),get commitQueueSize(){return R.size},get needsCommit(){return!R.isEmpty},has:L=>i.has(L),clear:()=>{for(let L=0,z=o.length;L{i.forEach(L)},get count(){return o.length},get boundingSphere(){return l&&(uue(o,s,!1),l=!1),s},get boundingSphereVisible(){return d&&(uue(o,a,!0),d=!1),a},get markerAverage(){return f&&(h=function V(){if(0===c.length)return 0;let L=0,z=0;for(let j=0,Z=c.length;j0?z/L:0}(),f=!1),h},get opacityAverage(){return p&&(g=function F(){var L,z;if(0===c.length)return 0;let j=0,Z=0;for(let $=0,ee=c.length;$0?Z/j:0}(),p=!1),g},get hasOpaque(){return m&&(y=function G(){var L;if(0===c.length)return!1;for(let z=0,j=c.length;z0)&&gr.copySnapshot(this._source,this.camera.state),this.inTransition||gr.copySnapshot(this._target,this.camera.state),gr.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&&n<=0||typeof t.mode<"u"&&t.mode!==this.camera.state.mode?this.finish(this._target):(this.inTransition=!0,this.func=r||$v.defaultTransition,(!this.inTransition||n>0)&&(this.start=this.t,this.durationMs=n))}tick(t){this.t=t,this.update()}finish(t){gr.copySnapshot(this.camera.state,t),this.inTransition=!1}update(){if(!this.inTransition)return;const t=Math.min((this.t-this.start)/this.durationMs,1);1!==t?(this.func(this._current,t,this._source,this._target),gr.copySnapshot(this.camera.state,this._current)):this.finish(this._target)}constructor(t){this.camera=t,this.t=0,this.func=$v.defaultTransition,this.start=0,this.inTransition=!1,this.durationMs=0,this._source=gr.createDefaultSnapshot(),this._target=gr.createDefaultSnapshot(),this._current=gr.createDefaultSnapshot()}}!function(e){const t=_r.identity();e.defaultTransition=function n(r,i,o,s){gr.copySnapshot(r,s),_r.slerp(t,_r.Identity,_r.rotationTo(t,o.up,s.up),i),v.transformQuat(r.up,o.up,t),v.lerp(r.target,o.target,s.target,i),v.lerp(r.position,o.position,s.position,i),r.radius=ci(o.radius,s.radius,i),r.radiusMax=ci(o.radiusMax,s.radiusMax,i),r.fov=ci(o.fov,s.fov,i),r.fog=ci(o.fog,s.fog,i)}}($v||($v={}));const lue=v(),due=v(),wE=nn();class gr{get position(){return this.state.position}set position(t){v.copy(this.state.position,t)}get up(){return this.state.up}set up(t){v.copy(this.state.up,t)}get target(){return this.state.target}set target(t){v.copy(this.state.target,t)}update(){const t=this.state;if(0===t.radiusMax)return!1;const n=2*Math.tan(t.fov/2)*v.distance(t.position,t.target);switch(this.zoom=this.viewport.height/n,function ztt(e){let{radius:t,radiusMax:n,fog:i,clipFar:o,minNear:s,minFar:a}=e.state;t<.01&&(t=.01);const c=Math.max(o?t:n,a),u=v.distance(e.position,e.target);let l=u-t,d=u+c;l=Math.max(Math.min(n,s),l),d=Math.max(s,d),l===d&&(d=l+.01);const p=u-c*(-(50-i)/50),m=d;e.near=l,e.far=d,e.fogNear=p,e.fogFar=m}(this),this.state.mode){case"orthographic":!function Utt(e){const{viewport:t,zoom:n,near:r,far:i,viewOffset:o}=e,s=-t.width/2,a=t.width/2,c=t.height/2,u=-t.height/2,l=(a-s)/(2*n),d=(c-u)/(2*n),f=(a+s)/2,p=(c+u)/2;let m=f-l,h=f+l,g=p+d,y=p-d;if(o.enabled){const b=n/(o.width/o.fullWidth),x=n/(o.height/o.fullHeight),_=(a-s)/o.width,S=(c-u)/o.height;m+=_*(o.offsetX/b),h=m+_*(o.width/b),g-=S*(o.offsetY/x),y=g-S*(o.height/x)}le.ortho(e.projection,m,h,g,y,r,i),le.lookAt(e.view,e.position,e.target,e.up)}(this);break;case"perspective":!function Vtt(e){const t=e.viewport.width/e.viewport.height,{near:n,far:r,viewOffset:i}=e;let o=n*Math.tan(.5*e.state.fov),s=2*o,a=t*s,c=-.5*a;i.enabled&&(c+=i.offsetX*a/i.fullWidth,o-=i.offsetY*s/i.fullHeight,a*=i.width/i.fullWidth,s*=i.height/i.fullHeight),le.perspective(e.projection,c,c+a,o,o-s,n,r),le.lookAt(e.view,e.position,e.target,e.up)}(this);break;default:Rr()}const r=!le.areEqual(this.projection,this.prevProjection,vr)||!le.areEqual(this.view,this.prevView,vr);if(r){if(le.mul(this.projectionView,this.projection,this.view),!le.tryInvert(this.inverseProjectionView,this.projectionView))return le.copy(this.view,this.prevView),le.copy(this.projection,this.prevProjection),le.mul(this.projectionView,this.projection,this.view),!1;le.copy(this.prevView,this.view),le.copy(this.prevProjection,this.projection)}return r}setState(t,n){this.transition.apply(t,n),this.stateChanged.next(t)}getSnapshot(){return gr.copySnapshot(gr.createDefaultSnapshot(),this.state)}getTargetDistance(t){return gr.targetDistance(t,this.state.mode,this.state.fov,this.viewport.width,this.viewport.height)}getFocus(t,n,r,i,o){var s,a;const c=Math.max(n,.01),u=this.getTargetDistance(c);v.sub(this.deltaDirection,null!==(s=o?.target)&&void 0!==s?s:this.target,null!==(a=o?.position)&&void 0!==a?a:this.position),i&&v.matchDirection(this.deltaDirection,i,this.deltaDirection),v.setMagnitude(this.deltaDirection,this.deltaDirection,u),v.sub(this.newPosition,t,this.deltaDirection);const l=gr.copySnapshot(gr.createDefaultSnapshot(),this.state);return l.target=v.clone(t),l.radius=c,l.position=v.clone(this.newPosition),r&&v.matchDirection(l.up,r,l.up),l}getCenter(t,n){v.sub(this.deltaDirection,this.target,this.position),v.sub(this.newPosition,t,this.deltaDirection);const r=gr.copySnapshot(gr.createDefaultSnapshot(),this.state);return r.target=v.clone(t),r.position=v.clone(this.newPosition),n&&(r.radius=Math.max(n,.01)),r}getInvariantFocus(t,n,r,i){const o=Math.max(n,.01),s=this.getTargetDistance(o);v.copy(this.deltaDirection,i),v.setMagnitude(this.deltaDirection,this.deltaDirection,s),v.sub(this.newPosition,t,this.deltaDirection);const a=gr.copySnapshot(gr.createDefaultSnapshot(),this.state);return a.target=v.clone(t),a.radius=o,a.position=v.clone(this.newPosition),v.copy(a.up,r),a}focus(t,n,r,i,o){n>0&&this.setState(this.getFocus(t,n,i,o),r)}center(t,n){this.setState(this.getCenter(t),n)}project(t,n){return function Mtt(e,t,n,r){const{x:i,y:o,width:s,height:a}=n;nn.set(If,t[0],t[1],t[2],1),nn.transformMat4(If,If,r);const c=If[3];return 0!==c&&(If[0]/=c,If[1]/=c,If[2]/=c),e[0]=(If[0]+1)*s*.5+i,e[1]=(If[1]+1)*a*.5+o,e[2]=.5*(If[2]+1),e[3]=0===c?0:1/c,e}(t,n,this.viewport,this.projectionView)}unproject(t,n){return xE(t,n,this.viewport,this.inverseProjectionView)}getPixelSize(t){return this.project(wE,t),this.unproject(lue,wE),wE[0]+=1,this.unproject(due,wE),v.distance(lue,due)}constructor(t,n=Lo.create(0,0,128,128)){this.view=le.identity(),this.projection=le.identity(),this.projectionView=le.identity(),this.inverseProjectionView=le.identity(),this.state=gr.createDefaultSnapshot(),this.viewOffset=gr.ViewOffset(),this.near=1,this.far=1e4,this.fogNear=5e3,this.fogFar=1e4,this.zoom=1,this.transition=new $v(this),this.stateChanged=new Ao(this.state),this.prevProjection=le.identity(),this.prevView=le.identity(),this.deltaDirection=v(),this.newPosition=v(),this.viewport=n,gr.copySnapshot(this.state,t)}}!function(e){e.ViewOffset=function t(){return{enabled:!1,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}},e.setViewOffset=function n(c,u,l,d,f,p,m){c.fullWidth=u,c.fullHeight=l,c.offsetX=d,c.offsetY=f,c.width=p,c.height=m},e.copyViewOffset=function r(c,u){c.enabled=u.enabled,c.fullWidth=u.fullWidth,c.fullHeight=u.fullHeight,c.offsetX=u.offsetX,c.offsetY=u.offsetY,c.width=u.width,c.height=u.height},e.targetDistance=function i(c,u,l,d,f){const p=Math.max(c,.01),h=f{const o=this.objectsData.get(i),s=AE(this.scene,r.values.boundingSphere.ref.value,o,xn.tomato,Wtt);s&&this.objectsData.set(i,s);const a=this.instancesData.get(i),c=AE(this.scene,r.values.invariantBoundingSphere.ref.value,a,xn.skyblue,$tt,{aTransform:i.values.aTransform,matrix:i.values.matrix,transform:i.values.transform,extraTransform:i.values.extraTransform,uInstanceCount:i.values.uInstanceCount,instanceCount:i.values.instanceCount,aInstance:i.values.aInstance,hasReflection:i.values.hasReflection,instanceGrid:i.values.instanceGrid});c&&this.instancesData.set(i,c)}),this.objectsData.forEach((r,i)=>{this.parent.has(i)||(this.scene.remove(r.renderObject),this.objectsData.delete(i))}),this.instancesData.forEach((r,i)=>{this.parent.has(i)||(this.scene.remove(r.renderObject),this.instancesData.delete(i))}),this.scene.update(void 0,!1),this.scene.commit()}syncVisibility(){this.sceneData&&(this.sceneData.renderObject.state.visible=this._props.sceneBoundingSpheres),this.visibleSceneData&&(this.visibleSceneData.renderObject.state.visible=this._props.visibleSceneBoundingSpheres),this.parent.forEach((t,n)=>{const r=this.objectsData.get(n);r&&(r.renderObject.state.visible=n.state.visible&&this._props.objectBoundingSpheres);const i=this.instancesData.get(n);i&&(i.renderObject.state.visible=n.state.visible&&this._props.instanceBoundingSpheres)})}clear(){this.sceneData=void 0,this.objectsData.clear(),this.scene.clear()}get isEnabled(){return this._props.sceneBoundingSpheres||this._props.visibleSceneBoundingSpheres||this._props.objectBoundingSpheres||this._props.instanceBoundingSpheres}get props(){return this._props}setProps(t){Object.assign(this._props,t),this.isEnabled&&this.update()}}function AE(e,t,n,r,i,o){if(!n||!_e.equals(n.boundingSphere,t)){const s=function jtt(e,t){const r=_v(2),i=at.createState(r,r/2,t);if(e.radius&&(Zn(i,e.center,e.radius,2),_e.hasExtrema(e)))for(const o of e.extrema)Zn(i,o,1,0);return at.getMesh(i)}(t,n&&n.mesh),a=n?n.renderObject:function Ytt(e,t,n,r){return Dv("mesh",Nt.Utils.createValuesSimple(e,{alpha:.1,doubleSided:!1,cellSize:0,batchSize:0},t,1,r),{disposed:!1,visible:!0,alphaFactor:1,pickable:!1,colorOnly:!1,opaque:!1,writeDepth:!1},n)}(s,r,i,o);return n?k.updateIfChanged(a.values.drawCount,Zo.getDrawCount(s)):e.add(a),{boundingSphere:_e.clone(t),renderObject:a,mesh:s}}}const Htt=Hp(),qtt=Hp(),Wtt=Hp(),$tt=Hp();var E0=function(e){return e[e.Move=0]="Move",e[e.Click=1]="Click",e[e.Drag=2]="Drag",e}(E0||{});const M8=v(),R8=v(),fue=v(),pue={maxFps:C.Numeric(30,{min:10,max:60,step:10}),preferAtomPixelPadding:C.Numeric(3,{min:0,max:20,step:1},{description:"Number of extra pixels at which to prefer atoms over bonds."})};class Xtt{setProps(t){Object.assign(this.props,t)}identify(t,n){const r=this.startX!==this.endX||this.startY!==this.endY||this.input.pointerLock&&!this.controls.isMoving;if(t===E0.Drag)return void(r&&!this.outsideViewport(this.startX,this.startY)&&(this.events.drag.next({current:this.prevLoci,buttons:this.buttons,button:this.button,modifiers:this.modifiers,pageStart:Me.create(this.startX,this.startY),pageEnd:Me.create(this.endX,this.endY)}),this.startX=this.endX,this.startY=this.endY));if(r){const o=this.canvasIdentify(this.endX,this.endY);this.id=o?.id,this.position=o?.position,this.startX=this.endX,this.startY=this.endY}if(t===E0.Click){const o=this.getLoci(this.id,this.position);return this.events.click.next({current:o,buttons:this.buttons,button:this.button,modifiers:this.modifiers,page:Me.create(this.endX,this.endY),position:this.position}),void(this.prevLoci=o)}if(!this.inside||this.currentIdentifyT!==n||!r||this.outsideViewport(this.endX,this.endY))return;const i=this.getLoci(this.id,this.position);this.events.hover.next({current:i,buttons:this.buttons,button:this.button,modifiers:this.modifiers,page:Me.create(this.endX,this.endY),position:this.position}),this.prevLoci=i}tick(t){this.inside&&t-this.prevT>1e3/this.props.maxFps&&(this.prevT=t,this.currentIdentifyT=t,this.identify(this.isInteracting?E0.Drag:E0.Move,t))}leave(){this.inside=!1,yn.Loci.isEmpty(this.prevLoci)||(this.prevLoci=yn.Loci.Empty,this.events.hover.next({current:this.prevLoci,buttons:this.buttons,button:this.button,modifiers:this.modifiers}))}move(t,n,r,i,o){this.inside=!0,this.buttons=r,this.button=i,this.modifiers=o,this.endX=t,this.endY=n}click(t,n,r,i,o){this.endX=t,this.endY=n,this.buttons=r,this.button=i,this.modifiers=o,this.identify(E0.Click,0)}drag(t,n,r,i,o){this.endX=t,this.endY=n,this.buttons=r,this.button=i,this.modifiers=o,this.identify(E0.Drag,0)}modify(t){wu.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}))}outsideViewport(t,n){const{input:r,camera:{viewport:i}}=this;return n*=r.pixelRatio,(t*=r.pixelRatio)>i.x+i.width||r.height-n>i.y+i.height||t{this.isInteracting=!0,this.drag(a,c,u,l,d)}),r.move.subscribe(({x:a,y:c,inside:u,buttons:l,button:d,modifiers:f,onElement:p})=>{if(u&&!this.isInteracting){if(!p)return void this.leave();this.move(a,c,l,d,f)}}),r.leave.subscribe(()=>{this.leave()}),r.click.subscribe(({x:a,y:c,buttons:u,button:l,modifiers:d})=>{this.outsideViewport(a,c)||this.click(a,c,u,l,d)}),r.interactionEnd.subscribe(()=>{this.isInteracting=!1}),r.modifiers.subscribe(a=>{this.modify(a)})}}const tnt={edgeThresholdMin:C.Numeric(.0312,{min:.0312,max:.0833,step:1e-4},{description:"Trims the algorithm from processing darks."}),edgeThresholdMax:C.Numeric(.063,{min:.063,max:.333,step:.001},{description:"The minimum amount of local contrast required to apply algorithm."}),iterations:C.Numeric(12,{min:0,max:16,step:1},{description:"Number of edge exploration steps."}),subpixelQuality:C.Numeric(.3,{min:0,max:1,step:.01},{description:"Choose the amount of sub-pixel aliasing removal."})};class nnt{constructor(t,n){this.webgl=t,this.renderable=function ont(e,t){const n=t.getWidth(),r=t.getHeight(),i={..._o,tColor:k.create(t),uTexSizeInv:k.create(Me.create(1/n,1/r)),dEdgeThresholdMin:k.create(.0312),dEdgeThresholdMax:k.create(.125),dIterations:k.create(12),dSubpixelQuality:k.create(.3)},o={...rnt};return ji(zi(e,"triangles",int,o,i),i)}(t,n)}updateState(t){const{gl:n,state:r}=this.webgl;r.enable(n.SCISSOR_TEST),r.disable(n.BLEND),r.disable(n.DEPTH_TEST),r.depthMask(!1);const{x:i,y:o,width:s,height:a}=t;r.viewport(i,o,s,a),r.scissor(i,o,s,a),r.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT)}setSize(t,n){k.update(this.renderable.values.uTexSizeInv,Me.set(this.renderable.values.uTexSizeInv.ref.value,1/t,1/n))}update(t,n){const{values:r}=this.renderable,{edgeThresholdMin:i,edgeThresholdMax:o,iterations:s,subpixelQuality:a}=n;let c=!1;r.tColor.ref.value!==t&&(k.update(this.renderable.values.tColor,t),c=!0),r.dEdgeThresholdMin.ref.value!==i&&(c=!0),k.updateIfChanged(r.dEdgeThresholdMin,i),r.dEdgeThresholdMax.ref.value!==o&&(c=!0),k.updateIfChanged(r.dEdgeThresholdMax,o),r.dIterations.ref.value!==s&&(c=!0),k.updateIfChanged(r.dIterations,s),r.dSubpixelQuality.ref.value!==a&&(c=!0),k.updateIfChanged(r.dSubpixelQuality,a),c&&this.renderable.update()}render(t,n){lt&&this.webgl.timer.mark("FxaaPass.render"),n?n.bind():this.webgl.unbindFramebuffer(),this.updateState(t),this.renderable.render(),lt&&this.webgl.timer.markEnd("FxaaPass.render")}}const rnt={...vo,tColor:jt("texture","rgba","ubyte","linear"),uTexSizeInv:xe("v2"),dEdgeThresholdMin:Ft("number"),dEdgeThresholdMax:Ft("number"),dIterations:Ft("number"),dSubpixelQuality:Ft("number")},int=Br("fxaa",ps,"\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tColor;\nuniform vec2 uTexSizeInv;\n\n// adapted from https://github.com/kosua20/Rendu\n// MIT License Copyright (c) 2017 Simon Rodriguez\n\n#define QUALITY(q) ((q) < 5 ? 1.0 : ((q) > 5 ? ((q) < 10 ? 2.0 : ((q) < 11 ? 4.0 : 8.0)) : 1.5))\n\nfloat rgb2luma(vec3 rgb){\n return sqrt(dot(rgb, vec3(0.299, 0.587, 0.114)));\n}\n\nfloat sampleLuma(vec2 uv) {\n return rgb2luma(texture2D(tColor, uv).rgb);\n}\n\nfloat sampleLuma(vec2 uv, float uOffset, float vOffset) {\n uv += uTexSizeInv * vec2(uOffset, vOffset);\n return sampleLuma(uv);\n}\n\nvoid main(void) {\n vec2 coords = gl_FragCoord.xy * uTexSizeInv;\n vec2 inverseScreenSize = uTexSizeInv;\n\n vec4 colorCenter = texture2D(tColor, coords);\n\n // Luma at the current fragment\n float lumaCenter = rgb2luma(colorCenter.rgb);\n\n // Luma at the four direct neighbours of the current fragment.\n float lumaDown = sampleLuma(coords, 0.0, -1.0);\n float lumaUp = sampleLuma(coords, 0.0, 1.0);\n float lumaLeft = sampleLuma(coords, -1.0, 0.0);\n float lumaRight = sampleLuma(coords, 1.0, 0.0);\n\n // Find the maximum and minimum luma around the current fragment.\n float lumaMin = min(lumaCenter, min(min(lumaDown, lumaUp), min(lumaLeft, lumaRight)));\n float lumaMax = max(lumaCenter, max(max(lumaDown, lumaUp), max(lumaLeft, lumaRight)));\n\n // Compute the delta.\n float lumaRange = lumaMax - lumaMin;\n\n // If the luma variation is lower that a threshold (or if we are in a really dark area),\n // we are not on an edge, don't perform any AA.\n if (lumaRange < max(dEdgeThresholdMin, lumaMax * dEdgeThresholdMax)) {\n gl_FragColor = colorCenter;\n return;\n }\n\n // Query the 4 remaining corners lumas.\n float lumaDownLeft = sampleLuma(coords, -1.0, -1.0);\n float lumaUpRight = sampleLuma(coords, 1.0, 1.0);\n float lumaUpLeft = sampleLuma(coords, -1.0, 1.0);\n float lumaDownRight = sampleLuma(coords, 1.0, -1.0);\n\n // Combine the four edges lumas (using intermediary variables for future computations\n // with the same values).\n float lumaDownUp = lumaDown + lumaUp;\n float lumaLeftRight = lumaLeft + lumaRight;\n\n // Same for corners\n float lumaLeftCorners = lumaDownLeft + lumaUpLeft;\n float lumaDownCorners = lumaDownLeft + lumaDownRight;\n float lumaRightCorners = lumaDownRight + lumaUpRight;\n float lumaUpCorners = lumaUpRight + lumaUpLeft;\n\n // Compute an estimation of the gradient along the horizontal and vertical axis.\n float edgeHorizontal = abs(-2.0 * lumaLeft + lumaLeftCorners) + abs(-2.0 * lumaCenter + lumaDownUp) * 2.0 + abs(-2.0 * lumaRight + lumaRightCorners);\n float edgeVertical = abs(-2.0 * lumaUp + lumaUpCorners) + abs(-2.0 * lumaCenter + lumaLeftRight) * 2.0 + abs(-2.0 * lumaDown + lumaDownCorners);\n\n // Is the local edge horizontal or vertical ?\n bool isHorizontal = (edgeHorizontal >= edgeVertical);\n\n // Choose the step size (one pixel) accordingly.\n float stepLength = isHorizontal ? inverseScreenSize.y : inverseScreenSize.x;\n\n // Select the two neighboring texels lumas in the opposite direction to the local edge.\n float luma1 = isHorizontal ? lumaDown : lumaLeft;\n float luma2 = isHorizontal ? lumaUp : lumaRight;\n // Compute gradients in this direction.\n float gradient1 = luma1 - lumaCenter;\n float gradient2 = luma2 - lumaCenter;\n\n // Which direction is the steepest ?\n bool is1Steepest = abs(gradient1) >= abs(gradient2);\n\n // Gradient in the corresponding direction, normalized.\n float gradientScaled = 0.25 * max(abs(gradient1), abs(gradient2));\n\n // Average luma in the correct direction.\n float lumaLocalAverage = 0.0;\n if(is1Steepest){\n // Switch the direction\n stepLength = -stepLength;\n lumaLocalAverage = 0.5 * (luma1 + lumaCenter);\n } else {\n lumaLocalAverage = 0.5 * (luma2 + lumaCenter);\n }\n\n // Shift UV in the correct direction by half a pixel.\n vec2 currentUv = coords;\n if(isHorizontal){\n currentUv.y += stepLength * 0.5;\n } else {\n currentUv.x += stepLength * 0.5;\n }\n\n // Compute offset (for each iteration step) in the right direction.\n vec2 offset = isHorizontal ? vec2(inverseScreenSize.x, 0.0) : vec2(0.0, inverseScreenSize.y);\n // Compute UVs to explore on each side of the edge, orthogonally.\n // The QUALITY allows us to step faster.\n vec2 uv1 = currentUv - offset * QUALITY(0);\n vec2 uv2 = currentUv + offset * QUALITY(0);\n\n // Read the lumas at both current extremities of the exploration segment,\n // and compute the delta wrt to the local average luma.\n float lumaEnd1 = sampleLuma(uv1);\n float lumaEnd2 = sampleLuma(uv2);\n lumaEnd1 -= lumaLocalAverage;\n lumaEnd2 -= lumaLocalAverage;\n\n // If the luma deltas at the current extremities is larger than the local gradient,\n // we have reached the side of the edge.\n bool reached1 = abs(lumaEnd1) >= gradientScaled;\n bool reached2 = abs(lumaEnd2) >= gradientScaled;\n bool reachedBoth = reached1 && reached2;\n\n // If the side is not reached, we continue to explore in this direction.\n if(!reached1){\n uv1 -= offset * QUALITY(1);\n }\n if(!reached2){\n uv2 += offset * QUALITY(1);\n }\n\n // If both sides have not been reached, continue to explore.\n if(!reachedBoth){\n for(int i = 2; i < dIterations; i++){\n // If needed, read luma in 1st direction, compute delta.\n if(!reached1){\n lumaEnd1 = sampleLuma(uv1);\n lumaEnd1 = lumaEnd1 - lumaLocalAverage;\n }\n // If needed, read luma in opposite direction, compute delta.\n if(!reached2){\n lumaEnd2 = sampleLuma(uv2);\n lumaEnd2 = lumaEnd2 - lumaLocalAverage;\n }\n // If the luma deltas at the current extremities is larger than the local gradient,\n // we have reached the side of the edge.\n reached1 = abs(lumaEnd1) >= gradientScaled;\n reached2 = abs(lumaEnd2) >= gradientScaled;\n reachedBoth = reached1 && reached2;\n\n // If the side is not reached, we continue to explore in this direction,\n // with a variable quality.\n if(!reached1){\n uv1 -= offset * QUALITY(i);\n }\n if(!reached2){\n uv2 += offset * QUALITY(i);\n }\n\n // If both sides have been reached, stop the exploration.\n if(reachedBoth){\n break;\n }\n }\n }\n\n // Compute the distances to each side edge of the edge (!).\n float distance1 = isHorizontal ? (coords.x - uv1.x) : (coords.y - uv1.y);\n float distance2 = isHorizontal ? (uv2.x - coords.x) : (uv2.y - coords.y);\n\n // In which direction is the side of the edge closer ?\n bool isDirection1 = distance1 < distance2;\n float distanceFinal = min(distance1, distance2);\n\n // Thickness of the edge.\n float edgeThickness = (distance1 + distance2);\n\n // Is the luma at center smaller than the local average ?\n bool isLumaCenterSmaller = lumaCenter < lumaLocalAverage;\n\n // If the luma at center is smaller than at its neighbour,\n // the delta luma at each end should be positive (same variation).\n bool correctVariation1 = (lumaEnd1 < 0.0) != isLumaCenterSmaller;\n bool correctVariation2 = (lumaEnd2 < 0.0) != isLumaCenterSmaller;\n\n // Only keep the result in the direction of the closer side of the edge.\n bool correctVariation = isDirection1 ? correctVariation1 : correctVariation2;\n\n // UV offset: read in the direction of the closest side of the edge.\n float pixelOffset = - distanceFinal / edgeThickness + 0.5;\n\n // If the luma variation is incorrect, do not offset.\n float finalOffset = correctVariation ? pixelOffset : 0.0;\n\n // Sub-pixel shifting\n // Full weighted average of the luma over the 3x3 neighborhood.\n float lumaAverage = (1.0 / 12.0) * (2.0 * (lumaDownUp + lumaLeftRight) + lumaLeftCorners + lumaRightCorners);\n // Ratio of the delta between the global average and the center luma,\n // over the luma range in the 3x3 neighborhood.\n float subPixelOffset1 = clamp(abs(lumaAverage - lumaCenter) / lumaRange, 0.0, 1.0);\n float subPixelOffset2 = (-2.0 * subPixelOffset1 + 3.0) * subPixelOffset1 * subPixelOffset1;\n // Compute a sub-pixel offset based on this delta.\n float subPixelOffsetFinal = subPixelOffset2 * subPixelOffset2 * float(dSubpixelQuality);\n\n // Pick the biggest of the two offsets.\n finalOffset = max(finalOffset, subPixelOffsetFinal);\n\n // Compute the final UV coordinates.\n vec2 finalUv = coords;\n if(isHorizontal){\n finalUv.y += finalOffset * stepLength;\n } else {\n finalUv.x += finalOffset * stepLength;\n }\n\n // Read the color at the new UV coordinates, and use it.\n gl_FragColor = texture2D(tColor, finalUv);\n}\n"),fnt={edgeThreshold:C.Numeric(.1,{min:.05,max:.15,step:.01}),maxSearchSteps:C.Numeric(16,{min:0,max:32,step:1})};class pnt{get supported(){return this._supported}constructor(t,n){if(this.webgl=t,this._supported=!1,typeof HTMLImageElement>"u")return void(un&&console.log('Missing "HTMLImageElement" required for "SMAA"'));const r=n.getWidth(),i=n.getHeight();this.edgesTarget=t.createRenderTarget(r,i,!1,"uint8","linear"),this.weightsTarget=t.createRenderTarget(r,i,!1,"uint8","linear"),this.edgesRenderable=function gnt(e,t){const n=t.getWidth(),r=t.getHeight(),i={..._o,tColor:k.create(t),uTexSizeInv:k.create(Me.create(1/n,1/r)),uViewport:k.create(nn()),dEdgeThreshold:k.create(.1)},o={...hnt};return ji(zi(e,"triangles",mnt,o,i),i)}(t,n),this.weightsRenderable=function vnt(e,t){const n=t.getWidth(),r=t.getHeight(),i=e.resources.texture("image-uint8","rgb","ubyte","linear"),o=e.resources.texture("image-uint8","rgba","ubyte","nearest"),s={..._o,tEdges:k.create(t),tArea:k.create(i),tSearch:k.create(o),uTexSizeInv:k.create(Me.create(1/n,1/r)),uViewport:k.create(nn()),dMaxSearchSteps:k.create(16)};Zre("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=",s.tArea,i),Zre("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII=",s.tSearch,o);const a={...ynt};return ji(zi(e,"triangles",bnt,a,s),s)}(t,this.edgesTarget.texture),this.blendRenderable=function Snt(e,t,n){const r=t.getWidth(),i=t.getHeight(),o={..._o,tColor:k.create(t),tWeights:k.create(n),uTexSizeInv:k.create(Me.create(1/r,1/i)),uViewport:k.create(nn())},s={..._nt};return ji(zi(e,"triangles",xnt,s,o),o)}(t,n,this.weightsTarget.texture),this._supported=!0}updateState(t){const{gl:n,state:r}=this.webgl;r.enable(n.SCISSOR_TEST),r.disable(n.BLEND),r.disable(n.DEPTH_TEST),r.depthMask(!1);const{x:i,y:o,width:s,height:a}=t;r.viewport(i,o,s,a),r.scissor(i,o,s,a),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT),k.update(this.edgesRenderable.values.uViewport,Lo.toVec4(this.edgesRenderable.values.uViewport.ref.value,t)),k.update(this.weightsRenderable.values.uViewport,Lo.toVec4(this.weightsRenderable.values.uViewport.ref.value,t)),k.update(this.blendRenderable.values.uViewport,Lo.toVec4(this.blendRenderable.values.uViewport.ref.value,t))}setSize(t,n){const r=this.edgesTarget.getWidth(),i=this.edgesTarget.getHeight();(t!==r||n!==i)&&(this.edgesTarget.setSize(t,n),this.weightsTarget.setSize(t,n),k.update(this.edgesRenderable.values.uTexSizeInv,Me.set(this.edgesRenderable.values.uTexSizeInv.ref.value,1/t,1/n)),k.update(this.weightsRenderable.values.uTexSizeInv,Me.set(this.weightsRenderable.values.uTexSizeInv.ref.value,1/t,1/n)),k.update(this.blendRenderable.values.uTexSizeInv,Me.set(this.blendRenderable.values.uTexSizeInv.ref.value,1/t,1/n)))}update(t,n){let r=!1;this.edgesRenderable.values.tColor.ref.value!==t&&(k.update(this.edgesRenderable.values.tColor,t),r=!0),this.edgesRenderable.values.dEdgeThreshold.ref.value!==n.edgeThreshold&&(k.update(this.edgesRenderable.values.dEdgeThreshold,n.edgeThreshold),r=!0),r&&this.edgesRenderable.update(),this.weightsRenderable.values.dMaxSearchSteps.ref.value!==n.maxSearchSteps&&(k.update(this.weightsRenderable.values.dMaxSearchSteps,n.maxSearchSteps),this.weightsRenderable.update()),this.blendRenderable.values.tColor.ref.value!==t&&(k.update(this.blendRenderable.values.tColor,t),this.blendRenderable.update())}render(t,n){lt&&this.webgl.timer.mark("SmaaPass.render"),this.edgesTarget.bind(),this.updateState(t),this.edgesRenderable.render(),this.weightsTarget.bind(),this.updateState(t),this.weightsRenderable.render(),n?n.bind():this.webgl.unbindFramebuffer(),this.updateState(t),this.blendRenderable.render(),lt&&this.webgl.timer.markEnd("SmaaPass.render")}}const hnt={...vo,tColor:jt("texture","rgba","ubyte","linear"),uTexSizeInv:xe("v2"),uViewport:xe("v4"),dEdgeThreshold:Ft("number")},mnt=Br("smaa-edges","\nprecision highp float;\n\nattribute vec2 aPosition;\nuniform vec2 uQuadScale;\n\nuniform vec2 uTexSizeInv;\nuniform vec4 uViewport;\n\nvarying vec2 vUv;\nvarying vec4 vOffset[3];\n\nvoid SMAAEdgeDetectionVS(vec2 texCoord) {\n vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-1.0, 0.0, 0.0, 1.0); // WebGL port note: Changed sign in W component\n vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(1.0, 0.0, 0.0, -1.0); // WebGL port note: Changed sign in W component\n vOffset[2] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-2.0, 0.0, 0.0, 2.0); // WebGL port note: Changed sign in W component\n}\n\nvoid main() {\n vec2 scale = uViewport.zw * uTexSizeInv;\n vec2 shift = uViewport.xy * uTexSizeInv;\n vUv = (aPosition + 1.0) * 0.5 * scale + shift;\n SMAAEdgeDetectionVS(vUv);\n vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n","\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tColor;\nuniform vec2 uTexSizeInv;\n\nvarying vec2 vUv;\nvarying vec4 vOffset[3];\n\nvec4 SMAAColorEdgeDetectionPS(vec2 texcoord, vec4 offset[3], sampler2D colorTex) {\n vec2 threshold = vec2(dEdgeThreshold, dEdgeThreshold);\n\n // Calculate color deltas:\n vec4 delta;\n vec3 C = texture2D(colorTex, texcoord).rgb;\n\n vec3 Cleft = texture2D(colorTex, offset[0].xy).rgb;\n vec3 t = abs(C - Cleft);\n delta.x = max(max(t.r, t.g), t.b);\n\n vec3 Ctop = texture2D(colorTex, offset[0].zw).rgb;\n t = abs(C - Ctop);\n delta.y = max(max(t.r, t.g), t.b);\n\n // We do the usual threshold:\n vec2 edges = step(threshold, delta.xy);\n\n // Then discard if there is no edge:\n if (dot(edges, vec2(1.0, 1.0 )) == 0.0)\n discard;\n\n // Calculate right and bottom deltas:\n vec3 Cright = texture2D(colorTex, offset[1].xy).rgb;\n t = abs( C - Cright );\n delta.z = max(max(t.r, t.g), t.b);\n\n vec3 Cbottom = texture2D(colorTex, offset[1].zw).rgb;\n t = abs(C - Cbottom);\n delta.w = max(max(t.r, t.g), t.b);\n\n // Calculate the maximum delta in the direct neighborhood:\n float maxDelta = max(max(max(delta.x, delta.y), delta.z), delta.w );\n\n // Calculate left-left and top-top deltas:\n vec3 Cleftleft = texture2D(colorTex, offset[2].xy).rgb;\n t = abs( C - Cleftleft );\n delta.z = max(max(t.r, t.g), t.b);\n\n vec3 Ctoptop = texture2D(colorTex, offset[2].zw).rgb;\n t = abs(C - Ctoptop);\n delta.w = max(max(t.r, t.g), t.b);\n\n // Calculate the final maximum delta:\n maxDelta = max(max(maxDelta, delta.z), delta.w);\n\n // Local contrast adaptation in action:\n edges.xy *= step(0.5 * maxDelta, delta.xy);\n\n return vec4(edges, 0.0, 0.0);\n}\n\nvoid main() {\n gl_FragColor = SMAAColorEdgeDetectionPS(vUv, vOffset, tColor);\n}\n"),ynt={...vo,tEdges:jt("texture","rgba","ubyte","linear"),tArea:jt("texture","rgb","ubyte","linear"),tSearch:jt("texture","rgba","ubyte","nearest"),uTexSizeInv:xe("v2"),uViewport:xe("v4"),dMaxSearchSteps:Ft("number")},bnt=Br("smaa-weights","\nprecision highp float;\n\nattribute vec2 aPosition;\nuniform vec2 uQuadScale;\n\nuniform vec2 uTexSizeInv;\nuniform vec4 uViewport;\n\nvarying vec2 vUv;\nvarying vec4 vOffset[3];\nvarying vec2 vPixCoord;\n\nvoid SMAABlendingWeightCalculationVS(vec2 texCoord) {\n vPixCoord = texCoord / uTexSizeInv;\n\n // We will use these offsets for the searches later on (see @PSEUDO_GATHER4):\n 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\n 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\n\n // And these for the searches, they indicate the ends of the loops:\n vOffset[2] = vec4(vOffset[0].xz, vOffset[1].yw) + vec4(-2.0, 2.0, -2.0, 2.0) * uTexSizeInv.xxyy * float(dMaxSearchSteps);\n}\n\nvoid main() {\n vec2 scale = uViewport.zw * uTexSizeInv;\n vec2 shift = uViewport.xy * uTexSizeInv;\n vUv = (aPosition + 1.0) * 0.5 * scale + shift;\n SMAABlendingWeightCalculationVS(vUv);\n vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n","\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#define SMAASampleLevelZeroOffset(tex, coord, offset) texture2D(tex, coord + float(offset) * uTexSizeInv, 0.0)\n\n#define SMAA_AREATEX_MAX_DISTANCE 16\n#define SMAA_AREATEX_PIXEL_SIZE (1.0 / vec2(160.0, 560.0))\n#define SMAA_AREATEX_SUBTEX_SIZE (1.0 / 7.0)\n\nuniform sampler2D tEdges;\nuniform sampler2D tArea;\nuniform sampler2D tSearch;\nuniform vec2 uTexSizeInv;\n\nvarying vec2 vUv;\nvarying vec4 vOffset[3];\nvarying vec2 vPixCoord;\n\n#if __VERSION__ == 100\n vec2 round(vec2 x) {\n return sign(x) * floor(abs(x) + 0.5);\n }\n#endif\n\nfloat SMAASearchLength(sampler2D searchTex, vec2 e, float bias, float scale) {\n // Not required if searchTex accesses are set to point:\n // float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);\n // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +\n // e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;\n e.r = bias + e.r * scale;\n return 255.0 * texture2D(searchTex, e, 0.0).r;\n}\n\nfloat SMAASearchXLeft(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {\n /**\n * @PSEUDO_GATHER4\n * This texCoord has been offset by (-0.25, -0.125) in the vertex shader to\n * sample between edge, thus fetching four edges in a row.\n * Sampling with different offsets in each direction allows to disambiguate\n * which edges are active from the four fetched ones.\n */\n vec2 e = vec2(0.0, 1.0);\n\n for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for\n e = texture2D( edgesTex, texCoord, 0.0).rg;\n texCoord -= vec2(2.0, 0.0) * uTexSizeInv;\n if (!(texCoord.x > end && e.g > 0.8281 && e.r == 0.0)) break;\n }\n\n // We correct the previous (-0.25, -0.125) offset we applied:\n texCoord.x += 0.25 * uTexSizeInv.x;\n\n // The searches are bias by 1, so adjust the coords accordingly:\n texCoord.x += uTexSizeInv.x;\n\n // Disambiguate the length added by the last step:\n texCoord.x += 2.0 * uTexSizeInv.x; // Undo last step\n texCoord.x -= uTexSizeInv.x * SMAASearchLength(searchTex, e, 0.0, 0.5);\n\n return texCoord.x;\n}\n\nfloat SMAASearchXRight(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {\n vec2 e = vec2( 0.0, 1.0 );\n\n for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for\n e = texture2D(edgesTex, texCoord, 0.0).rg;\n texCoord += vec2(2.0, 0.0) * uTexSizeInv;\n if (!(texCoord.x < end && e.g > 0.8281 && e.r == 0.0)) break;\n }\n\n texCoord.x -= 0.25 * uTexSizeInv.x;\n texCoord.x -= uTexSizeInv.x;\n texCoord.x -= 2.0 * uTexSizeInv.x;\n texCoord.x += uTexSizeInv.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );\n\n return texCoord.x;\n}\n\nfloat SMAASearchYUp(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {\n vec2 e = vec2( 1.0, 0.0 );\n\n for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for\n e = texture2D(edgesTex, texCoord, 0.0).rg;\n texCoord += vec2(0.0, 2.0) * uTexSizeInv; // WebGL port note: Changed sign\n if (!(texCoord.y > end && e.r > 0.8281 && e.g == 0.0)) break;\n }\n\n texCoord.y -= 0.25 * uTexSizeInv.y; // WebGL port note: Changed sign\n texCoord.y -= uTexSizeInv.y; // WebGL port note: Changed sign\n texCoord.y -= 2.0 * uTexSizeInv.y; // WebGL port note: Changed sign\n texCoord.y += uTexSizeInv.y * SMAASearchLength(searchTex, e.gr, 0.0, 0.5); // WebGL port note: Changed sign\n\n return texCoord.y;\n}\n\nfloat SMAASearchYDown(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {\n vec2 e = vec2( 1.0, 0.0 );\n\n for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for\n e = texture2D(edgesTex, texCoord, 0.0).rg;\n texCoord -= vec2( 0.0, 2.0 ) * uTexSizeInv; // WebGL port note: Changed sign\n if (!(texCoord.y < end && e.r > 0.8281 && e.g == 0.0)) break;\n }\n\n texCoord.y += 0.25 * uTexSizeInv.y; // WebGL port note: Changed sign\n texCoord.y += uTexSizeInv.y; // WebGL port note: Changed sign\n texCoord.y += 2.0 * uTexSizeInv.y; // WebGL port note: Changed sign\n texCoord.y -= uTexSizeInv.y * SMAASearchLength(searchTex, e.gr, 0.5, 0.5); // WebGL port note: Changed sign\n\n return texCoord.y;\n}\n\nvec2 SMAAArea(sampler2D areaTex, vec2 dist, float e1, float e2, float offset) {\n // Rounding prevents precision errors of bilinear filtering:\n vec2 texCoord = float(SMAA_AREATEX_MAX_DISTANCE) * round(4.0 * vec2(e1, e2)) + dist;\n\n // We do a scale and bias for mapping to texel space:\n texCoord = SMAA_AREATEX_PIXEL_SIZE * texCoord + (0.5 * SMAA_AREATEX_PIXEL_SIZE);\n\n // Move to proper place, according to the subpixel offset:\n texCoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;\n\n return texture2D(areaTex, texCoord, 0.0).rg;\n}\n\nvec4 SMAABlendingWeightCalculationPS(vec2 texCoord, vec2 pixCoord, vec4 offset[3], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices) {\n vec4 weights = vec4(0.0, 0.0, 0.0, 0.0);\n\n vec2 e = texture2D(edgesTex, texCoord).rg;\n\n if (e.g > 0.0) { // Edge at north\n vec2 d;\n\n // Find the distance to the left:\n vec2 coords;\n coords.x = SMAASearchXLeft(edgesTex, searchTex, offset[0].xy, offset[2].x );\n coords.y = offset[1].y; // offset[1].y = texCoord.y - 0.25 * uTexSizeInv.y (@CROSSING_OFFSET)\n d.x = coords.x;\n\n // Now fetch the left crossing edges, two at a time using bilinear\n // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to\n // discern what value each edge has:\n float e1 = texture2D(edgesTex, coords, 0.0).r;\n\n // Find the distance to the right:\n coords.x = SMAASearchXRight(edgesTex, searchTex, offset[0].zw, offset[2].y);\n d.y = coords.x;\n\n // We want the distances to be in pixel units (doing this here allow to\n // better interleave arithmetic and memory accesses):\n d = d / uTexSizeInv.x - pixCoord.x;\n\n // SMAAArea below needs a sqrt, as the areas texture is compressed\n // quadratically:\n vec2 sqrt_d = sqrt(abs(d));\n\n // Fetch the right crossing edges:\n coords.y -= 1.0 * uTexSizeInv.y; // WebGL port note: Added\n float e2 = SMAASampleLevelZeroOffset(edgesTex, coords, ivec2(1, 0)).r;\n\n // Ok, we know how this pattern looks like, now it is time for getting\n // the actual area:\n weights.rg = SMAAArea(areaTex, sqrt_d, e1, e2, float(subsampleIndices.y));\n }\n\n if (e.r > 0.0) { // Edge at west\n vec2 d;\n\n // Find the distance to the top:\n vec2 coords;\n\n coords.y = SMAASearchYUp(edgesTex, searchTex, offset[1].xy, offset[2].z );\n coords.x = offset[0].x; // offset[1].x = texCoord.x - 0.25 * uTexSizeInv.x;\n d.x = coords.y;\n\n // Fetch the top crossing edges:\n float e1 = texture2D(edgesTex, coords, 0.0).g;\n\n // Find the distance to the bottom:\n coords.y = SMAASearchYDown(edgesTex, searchTex, offset[1].zw, offset[2].w);\n d.y = coords.y;\n\n // We want the distances to be in pixel units:\n d = d / uTexSizeInv.y - pixCoord.y;\n\n // SMAAArea below needs a sqrt, as the areas texture is compressed\n // quadratically:\n vec2 sqrt_d = sqrt(abs(d));\n\n // Fetch the bottom crossing edges:\n coords.y -= 1.0 * uTexSizeInv.y; // WebGL port note: Added\n float e2 = SMAASampleLevelZeroOffset(edgesTex, coords, ivec2(0, 1)).g;\n\n // Get the area for this direction:\n weights.ba = SMAAArea(areaTex, sqrt_d, e1, e2, float(subsampleIndices.x));\n }\n\n return weights;\n}\n\nvoid main() {\n gl_FragColor = SMAABlendingWeightCalculationPS(vUv, vPixCoord, vOffset, tEdges, tArea, tSearch, ivec4(0.0));\n}\n"),_nt={...vo,tColor:jt("texture","rgba","ubyte","linear"),tWeights:jt("texture","rgba","ubyte","linear"),uTexSizeInv:xe("v2"),uViewport:xe("v4")},xnt=Br("smaa-blend","\nprecision highp float;\n\nattribute vec2 aPosition;\nuniform vec2 uQuadScale;\n\nuniform vec2 uTexSizeInv;\nuniform vec4 uViewport;\n\nvarying vec2 vUv;\nvarying vec4 vOffset[2];\n\nvoid SMAANeighborhoodBlendingVS(vec2 texCoord) {\n vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-1.0, 0.0, 0.0, 1.0); // WebGL port note: Changed sign in W component\n vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(1.0, 0.0, 0.0, -1.0); // WebGL port note: Changed sign in W component\n}\n\nvoid main() {\n vec2 scale = uViewport.zw * uTexSizeInv;\n vec2 shift = uViewport.xy * uTexSizeInv;\n vUv = (aPosition + 1.0) * 0.5 * scale + shift;\n SMAANeighborhoodBlendingVS(vUv);\n vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n","\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tWeights;\nuniform sampler2D tColor;\nuniform vec2 uTexSizeInv;\n\nvarying vec2 vUv;\nvarying vec4 vOffset[2];\n\nvec4 SMAANeighborhoodBlendingPS(vec2 texCoord, vec4 offset[2], sampler2D colorTex, sampler2D blendTex) {\n // Fetch the blending weights for current pixel:\n vec4 a;\n a.xz = texture2D(blendTex, texCoord).xz;\n a.y = texture2D(blendTex, offset[1].zw).g;\n a.w = texture2D(blendTex, offset[1].xy).a;\n\n // Is there any blending weight with a value greater than 0.0?\n if (dot(a, vec4(1.0, 1.0, 1.0, 1.0)) < 1e-5) {\n return texture2D(colorTex, texCoord, 0.0);\n } else {\n // Up to 4 lines can be crossing a pixel (one through each edge). We\n // favor blending by choosing the line with the maximum weight for each\n // direction:\n vec2 offset;\n offset.x = a.a > a.b ? a.a : -a.b; // left vs. right\n offset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs\n\n // Then we go in the direction that has the maximum weight:\n if (abs(offset.x) > abs(offset.y)) { // horizontal vs. vertical\n offset.y = 0.0;\n } else {\n offset.x = 0.0;\n }\n\n // Fetch the opposite color and lerp by hand:\n vec4 C = texture2D(colorTex, texCoord, 0.0);\n texCoord += sign(offset) * uTexSizeInv;\n vec4 Cop = texture2D(colorTex, texCoord, 0.0);\n float s = abs(offset.x) > abs(offset.y) ? abs(offset.x) : abs(offset.y);\n\n // WebGL port note: Added gamma correction\n C.xyz = pow(C.xyz, vec3(2.2));\n Cop.xyz = pow(Cop.xyz, vec3(2.2));\n vec4 mixed = mix(C, Cop, s);\n mixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));\n\n return mixed;\n }\n}\n\nvoid main() {\n gl_FragColor = SMAANeighborhoodBlendingPS(vUv, vOffset, tColor, tWeights);\n}\n"),hue={opacity:C.Numeric(1,{min:0,max:1,step:.01}),saturation:C.Numeric(0,{min:-1,max:1,step:.01}),lightness:C.Numeric(0,{min:-1,max:1,step:.01})},Tnt={faces:C.MappedStatic("urls",{urls:C.Group({nx:C.Text("",{label:"Negative X / Left"}),ny:C.Text("",{label:"Negative Y / Bottom"}),nz:C.Text("",{label:"Negative Z / Back"}),px:C.Text("",{label:"Positive X / Right"}),py:C.Text("",{label:"Positive Y / Top"}),pz:C.Text("",{label:"Positive Z / Front"})},{isExpanded:!0,label:"URLs"}),files:C.Group({nx:C.File({label:"Negative X / Left",accept:"image/*"}),ny:C.File({label:"Negative Y / Bottom",accept:"image/*"}),nz:C.File({label:"Negative Z / Back",accept:"image/*"}),px:C.File({label:"Positive X / Right",accept:"image/*"}),py:C.File({label:"Positive Y / Top",accept:"image/*"}),pz:C.File({label:"Positive Z / Front",accept:"image/*"})},{isExpanded:!0,label:"Files"})}),blur:C.Numeric(0,{min:0,max:1,step:.01},{description:'Note, this only works in WebGL2 or when "EXT_shader_texture_lod" is available.'}),...hue},Dnt={source:C.MappedStatic("url",{url:C.Text(""),file:C.File({accept:"image/*"})}),blur:C.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.'}),...hue,coverage:C.Select("viewport",C.arrayToOptions(["viewport","canvas"]))},Ent={topColor:C.Color(st(14540253)),bottomColor:C.Color(st(15658734)),ratio:C.Numeric(.5,{min:0,max:1,step:.01}),coverage:C.Select("viewport",C.arrayToOptions(["viewport","canvas"]))},Pnt={centerColor:C.Color(st(14540253)),edgeColor:C.Color(st(15658734)),ratio:C.Numeric(.5,{min:0,max:1,step:.01}),coverage:C.Select("viewport",C.arrayToOptions(["viewport","canvas"]))},Mnt={variant:C.MappedStatic("off",{off:C.EmptyGroup(),skybox:C.Group(Tnt,{isExpanded:!0}),image:C.Group(Dnt,{isExpanded:!0}),horizontalGradient:C.Group(Ent,{isExpanded:!0}),radialGradient:C.Group(Pnt,{isExpanded:!0})},{label:"Environment"})};class Rnt{constructor(t,n,r,i){this.webgl=t,this.assetManager=n,this.camera=new gr,this.target=v(),this.position=v(),this.dir=v(),this.renderable=function znt(e,t,n){const r={drawCount:k.create(6),instanceCount:k.create(1),aPosition:k.create(E5),tSkybox:k.create(Os()),tImage:k.create(Os()),uImageScale:k.create(Me()),uImageOffset:k.create(Me()),uTexSize:k.create(Me.create(t,n)),uViewport:k.create(nn()),uViewportAdjusted:k.create(!0),uViewDirectionProjectionInverse:k.create(le()),uGradientColorA:k.create(v()),uGradientColorB:k.create(v()),uGradientRatio:k.create(.5),uBlur:k.create(0),uOpacity:k.create(1),uSaturation:k.create(0),uLightness:k.create(0),dVariant:k.create("skybox")},i={...Unt};return ji(zi(e,"triangles",Vnt,i,r),r)}(t,r,i)}setSize(t,n){const[r,i]=this.renderable.values.uTexSize.ref.value;(t!==r||n!==i)&&k.update(this.renderable.values.uTexSize,Me.set(this.renderable.values.uTexSize.ref.value,t,n))}clearSkybox(){void 0!==this.skybox&&(this.skybox.texture.destroy(),this.skybox.assets.forEach(t=>this.assetManager.release(t)),this.skybox=void 0)}updateSkybox(t,n,r){var i;const o=null===(i=this.skybox)||void 0===i?void 0:i.props.faces,s=n.faces.params;if(!(s.nx&&s.ny&&s.nz&&s.px&&s.py&&s.pz))return this.clearSkybox(),void r?.(!1);if(this.skybox&&o&&function Fnt(e,t){return gue(e)===gue(t)}(n.faces,this.skybox.props.faces))r?.(!1);else{this.clearSkybox();const{texture:u,assets:l}=function Bnt(e,t,n,r){const i=function knt(e,t){return"urls"===t.name?{nx:fr.getUrlAsset(e,t.params.nx),ny:fr.getUrlAsset(e,t.params.ny),nz:fr.getUrlAsset(e,t.params.nz),px:fr.getUrlAsset(e,t.params.px),py:fr.getUrlAsset(e,t.params.py),pz:fr.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}}(t,n),o=function Nnt(e,t){const n=r=>e.resolve(r,"binary").run().then(i=>new Blob([i.data]));return{nx:n(t.nx),ny:n(t.ny),nz:n(t.nz),px:n(t.px),py:n(t.py),pz:n(t.pz)}}(t,i),s=[i.nx,i.ny,i.nz,i.px,i.py,i.pz];return typeof HTMLImageElement>"u"?(console.error('Missing "HTMLImageElement" required for background skybox'),r?.(!0),{texture:Os(),assets:s}):{texture:e.resources.cubeTexture(o,!0,r),assets:s}}(this.webgl,this.assetManager,n.faces,d=>{this.skybox&&(this.skybox.loaded=!d),r?.(!0)});this.skybox={texture:u,props:{...n},assets:l,loaded:!1},k.update(this.renderable.values.tSkybox,u),this.renderable.update()}if(!this.skybox)return;let a=t;"orthographic"===t.state.mode&&(this.camera.setState({...t.state,mode:"perspective"}),this.camera.update(),a=this.camera);const c=this.renderable.values.uViewDirectionProjectionInverse.ref.value;v.sub(this.dir,a.state.position,a.state.target),v.setMagnitude(this.dir,this.dir,.1),v.copy(this.position,this.dir),le.lookAt(c,this.position,this.target,a.state.up),le.mul(c,a.projection,c),le.invert(c,c),k.update(this.renderable.values.uViewDirectionProjectionInverse,c),k.updateIfChanged(this.renderable.values.uBlur,n.blur),k.updateIfChanged(this.renderable.values.uOpacity,n.opacity),k.updateIfChanged(this.renderable.values.uSaturation,n.saturation),k.updateIfChanged(this.renderable.values.uLightness,n.lightness),k.updateIfChanged(this.renderable.values.dVariant,"skybox"),this.renderable.update()}clearImage(){void 0!==this.image&&(this.image.texture.destroy(),this.assetManager.release(this.image.asset),this.image=void 0)}updateImage(t,n){if(!t.source.params)return this.clearImage(),void n?.(!1);if(this.image&&this.image.props.source.params&&function Ont(e,t){return bue(e)===bue(t)}(t.source,this.image.props.source))n?.(!1);else{this.clearImage();const{texture:r,asset:i}=function Lnt(e,t,n,r){const i="url"===n.name?fr.getUrlAsset(t,n.params):n.params;if(typeof HTMLImageElement>"u")return console.error('Missing "HTMLImageElement" required for background image'),r?.(!0),{texture:Os(),asset:i};const o=e.resources.texture("image-uint8","rgba","ubyte","linear"),s=new Image;return s.onload=()=>{o.load(s),(e.isWebGL2||$x(s.width)&&$x(s.height))&&o.mipmap(),r?.()},s.onerror=()=>{r?.(!0)},t.resolve(i,"binary").run().then(a=>{const c=new Blob([a.data]);s.src=URL.createObjectURL(c)}),{texture:o,asset:i}}(this.webgl,this.assetManager,t.source,o=>{this.image&&(this.image.loaded=!o),n?.(!0)});this.image={texture:r,props:{...t},asset:i,loaded:!1},k.update(this.renderable.values.tImage,r),this.renderable.update()}this.image&&(k.updateIfChanged(this.renderable.values.uBlur,t.blur),k.updateIfChanged(this.renderable.values.uOpacity,t.opacity),k.updateIfChanged(this.renderable.values.uSaturation,t.saturation),k.updateIfChanged(this.renderable.values.uLightness,t.lightness),k.updateIfChanged(this.renderable.values.uViewportAdjusted,"viewport"===t.coverage),k.updateIfChanged(this.renderable.values.dVariant,"image"),this.renderable.update())}updateImageScaling(){var t,n;const r=this.renderable.values,[i,o]=r.uTexSize.ref.value,s=(null===(t=this.image)||void 0===t?void 0:t.texture.getWidth())||0,a=(null===(n=this.image)||void 0===n?void 0:n.texture.getHeight())||0,c=i/o;k.update(r.uImageScale,cc?Me.set(r.uImageOffset.ref.value,(1-c/f)/2,0):Me.set(r.uImageOffset.ref.value,0,(1-f/c)/2))}updateGradient(t,n,r,i,o){k.update(this.renderable.values.uGradientColorA,st.toVec3Normalized(this.renderable.values.uGradientColorA.ref.value,t)),k.update(this.renderable.values.uGradientColorB,st.toVec3Normalized(this.renderable.values.uGradientColorB.ref.value,n)),k.updateIfChanged(this.renderable.values.uGradientRatio,r),k.updateIfChanged(this.renderable.values.uViewportAdjusted,o),k.updateIfChanged(this.renderable.values.dVariant,i),this.renderable.update()}update(t,n,r){if("off"===n.variant.name)return this.clearSkybox(),this.clearImage(),void r?.(!1);"skybox"===n.variant.name?(this.clearImage(),this.updateSkybox(t,n.variant.params,r)):"image"===n.variant.name?(this.clearSkybox(),this.updateImage(n.variant.params,r)):"horizontalGradient"===n.variant.name?(this.clearSkybox(),this.clearImage(),this.updateGradient(n.variant.params.topColor,n.variant.params.bottomColor,n.variant.params.ratio,n.variant.name,"viewport"===n.variant.params.coverage),r?.(!1)):"radialGradient"===n.variant.name&&(this.clearSkybox(),this.clearImage(),this.updateGradient(n.variant.params.centerColor,n.variant.params.edgeColor,n.variant.params.ratio,n.variant.name,"viewport"===n.variant.params.coverage),r?.(!1));const{x:i,y:o,width:s,height:a}=t.viewport;k.update(this.renderable.values.uViewport,nn.set(this.renderable.values.uViewport.ref.value,i,o,s,a))}isEnabled(t){return!!(this.skybox&&this.skybox.loaded||this.image&&this.image.loaded||"horizontalGradient"===t.variant.name||"radialGradient"===t.variant.name)}isReady(){return!!(this.skybox&&this.skybox.loaded||this.image&&this.image.loaded||"horizontalGradient"===this.renderable.values.dVariant.ref.value||"radialGradient"===this.renderable.values.dVariant.ref.value)}render(){this.isReady()&&("image"===this.renderable.values.dVariant.ref.value&&this.updateImageScaling(),lt&&this.webgl.timer.mark("BackgroundPass.render"),this.renderable.render(),lt&&this.webgl.timer.markEnd("BackgroundPass.render"))}dispose(){this.clearSkybox(),this.clearImage()}}const mue="background-skybox";function gue(e){var t,n,r,i,o,s;return"urls"===e.name?`${mue}_${e.params.nx}|${e.params.ny}|${e.params.nz}|${e.params.px}|${e.params.py}|${e.params.pz}`:`${mue}_${null===(t=e.params.nx)||void 0===t?void 0:t.id}|${null===(n=e.params.ny)||void 0===n?void 0:n.id}|${null===(r=e.params.nz)||void 0===r?void 0:r.id}|${null===(i=e.params.px)||void 0===i?void 0:i.id}|${null===(o=e.params.py)||void 0===o?void 0:o.id}|${null===(s=e.params.pz)||void 0===s?void 0:s.id}`}const yue="background-image";function bue(e){var t;return"url"===e.name?`${yue}_${e.params}`:`${yue}_${null===(t=e.params)||void 0===t?void 0:t.id}`}const Unt={drawCount:ri("number"),instanceCount:ri("number"),aPosition:Ar("float32",2,0),tSkybox:jt("texture","rgba","ubyte","linear"),tImage:jt("texture","rgba","ubyte","linear"),uImageScale:xe("v2"),uImageOffset:xe("v2"),uTexSize:xe("v2"),uViewport:xe("v4"),uViewportAdjusted:xe("b"),uViewDirectionProjectionInverse:xe("m4"),uGradientColorA:xe("v3"),uGradientColorB:xe("v3"),uGradientRatio:xe("f"),uBlur:xe("f"),uOpacity:xe("f"),uSaturation:xe("f"),uLightness:xe("f"),dVariant:Ft("string",["skybox","image","verticalGradient","horizontalGradient","radialGradient"])},Vnt=Br("background","\nprecision mediump float;\n\nattribute vec2 aPosition;\n\nvarying vec4 vPosition;\n\nvoid main() {\n vPosition = vec4(aPosition, 1.0, 1.0);\n gl_Position = vec4(aPosition, 1.0, 1.0);\n}\n","\nprecision mediump float;\nprecision mediump samplerCube;\nprecision mediump sampler2D;\n\n#if defined(dVariant_skybox)\n uniform samplerCube tSkybox;\n uniform mat4 uViewDirectionProjectionInverse;\n uniform float uBlur;\n uniform float uOpacity;\n uniform float uSaturation;\n uniform float uLightness;\n#elif defined(dVariant_image)\n uniform sampler2D tImage;\n uniform vec2 uImageScale;\n uniform vec2 uImageOffset;\n uniform float uBlur;\n uniform float uOpacity;\n uniform float uSaturation;\n uniform float uLightness;\n#elif defined(dVariant_horizontalGradient) || defined(dVariant_radialGradient)\n uniform vec3 uGradientColorA;\n uniform vec3 uGradientColorB;\n uniform float uGradientRatio;\n#endif\n\nuniform vec2 uTexSize;\nuniform vec4 uViewport;\nuniform bool uViewportAdjusted;\nvarying vec4 vPosition;\n\n// TODO: add as general pp option to remove banding?\n// Iestyn's RGB dither from http://alex.vlachos.com/graphics/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf\nvec3 ScreenSpaceDither(vec2 vScreenPos) {\n vec3 vDither = vec3(dot(vec2(171.0, 231.0), vScreenPos.xy));\n vDither.rgb = fract(vDither.rgb / vec3(103.0, 71.0, 97.0));\n return vDither.rgb / 255.0;\n}\n\nvec3 saturateColor(vec3 c, float amount) {\n // https://www.w3.org/TR/WCAG21/#dfn-relative-luminance\n const vec3 W = vec3(0.2125, 0.7154, 0.0721);\n vec3 intensity = vec3(dot(c, W));\n return mix(intensity, c, 1.0 + amount);\n}\n\nvec3 lightenColor(vec3 c, float amount) {\n return c + amount;\n}\n\nvoid main() {\n #if defined(dVariant_skybox)\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n #ifdef enabledShaderTextureLod\n gl_FragColor = textureCubeLodEXT(tSkybox, normalize(t.xyz / t.w), uBlur * 8.0);\n #else\n gl_FragColor = textureCube(tSkybox, normalize(t.xyz / t.w));\n #endif\n gl_FragColor.a = uOpacity;\n gl_FragColor.rgb = lightenColor(saturateColor(gl_FragColor.rgb, uSaturation), uLightness);\n #elif defined(dVariant_image)\n vec2 coords;\n if (uViewportAdjusted) {\n coords = ((gl_FragCoord.xy - uViewport.xy) * (uTexSize / uViewport.zw) / uImageScale) + uImageOffset;\n } else {\n coords = (gl_FragCoord.xy / uImageScale) + uImageOffset;\n }\n #ifdef enabledShaderTextureLod\n gl_FragColor = texture2DLodEXT(tImage, vec2(coords.x, 1.0 - coords.y), uBlur * 8.0);\n #else\n gl_FragColor = texture2D(tImage, vec2(coords.x, 1.0 - coords.y));\n #endif\n gl_FragColor.a = uOpacity;\n gl_FragColor.rgb = lightenColor(saturateColor(gl_FragColor.rgb, uSaturation), uLightness);\n #elif defined(dVariant_horizontalGradient)\n float d;\n if (uViewportAdjusted) {\n d = ((gl_FragCoord.y - uViewport.y) * (uTexSize.y / uViewport.w) / uTexSize.y) + 1.0 - (uGradientRatio * 2.0);\n } else {\n d = (gl_FragCoord.y / uTexSize.y) + 1.0 - (uGradientRatio * 2.0);\n }\n gl_FragColor = vec4(mix(uGradientColorB, uGradientColorA, clamp(d, 0.0, 1.0)), 1.0);\n gl_FragColor.rgb += ScreenSpaceDither(gl_FragCoord.xy);\n #elif defined(dVariant_radialGradient)\n float d;\n if (uViewportAdjusted) {\n d = distance(vec2(0.5), (gl_FragCoord.xy - uViewport.xy) * (uTexSize / uViewport.zw) / uTexSize) + uGradientRatio - 0.5;\n } else {\n d = distance(vec2(0.5), gl_FragCoord.xy / uTexSize) + uGradientRatio - 0.5;\n }\n gl_FragColor = vec4(mix(uGradientColorB, uGradientColorA, 1.0 - clamp(d, 0.0, 1.0)), 1.0);\n gl_FragColor.rgb += ScreenSpaceDither(gl_FragCoord.xy);\n #endif\n}\n",{shaderTextureLod:"optional"}),Hnt={sharpness:C.Numeric(.5,{min:0,max:1,step:.05}),denoise:C.Boolean(!0)};class qnt{constructor(t,n){this.webgl=t,this.renderable=function Ynt(e,t){const n=t.getWidth(),r=t.getHeight(),i={..._o,tColor:k.create(t),uTexSizeInv:k.create(Me.create(1/n,1/r)),uSharpness:k.create(.5),dDenoise:k.create(!0)},o={...Wnt};return ji(zi(e,"triangles",$nt,o,i),i)}(t,n)}updateState(t){const{gl:n,state:r}=this.webgl;r.enable(n.SCISSOR_TEST),r.disable(n.BLEND),r.disable(n.DEPTH_TEST),r.depthMask(!1);const{x:i,y:o,width:s,height:a}=t;r.viewport(i,o,s,a),r.scissor(i,o,s,a),r.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT)}setSize(t,n){k.update(this.renderable.values.uTexSizeInv,Me.set(this.renderable.values.uTexSizeInv.ref.value,1/t,1/n))}update(t,n){const{values:r}=this.renderable,{sharpness:i,denoise:o}=n;let s=!1;r.tColor.ref.value!==t&&(k.update(this.renderable.values.tColor,t),s=!0),k.updateIfChanged(r.uSharpness,2-2*Math.pow(i,.25)),r.dDenoise.ref.value!==o&&(s=!0),k.updateIfChanged(r.dDenoise,o),s&&this.renderable.update()}render(t,n){lt&&this.webgl.timer.mark("CasPass.render"),n?n.bind():this.webgl.unbindFramebuffer(),this.updateState(t),this.renderable.render(),lt&&this.webgl.timer.markEnd("CasPass.render")}}const Wnt={...vo,tColor:jt("texture","rgba","ubyte","linear"),uTexSizeInv:xe("v2"),uSharpness:xe("f"),dDenoise:Ft("boolean")},$nt=Br("cas",ps,"\nprecision mediump float;\nprecision mediump sampler2D;\n\nuniform sampler2D tColor;\nuniform vec2 uTexSizeInv;\n\nuniform float uSharpness;\n\n// adapted from https://www.shadertoy.com/view/stXSWB\n\n/*\n* FidelityFX Super Resolution scales up a low resolution\n* image, while adding fine detail.\n*\n* MIT Open License\n*\n* https://gpuopen.com/fsr\n*\n* Left: FSR processed\n* Right: Original texture, bilinear interpolation\n*\n* Mouse at top: Sharpness 0 stops (maximum)\n* Mouse at bottom: Sharpness 2 stops (minimum)\n*\n* It works in two passes-\n* EASU upsamples the image with a clamped Lanczos kernel.\n* RCAS sharpens the image at the target resolution.\n*\n* I needed to make a few changes to improve readability and\n* WebGL compatibility in an algorithm I don't fully understand.\n* Expect bugs.\n*\n* Shader not currently running for WebGL1 targets (eg. mobile Safari)\n*\n* There is kind of no point to using FSR in Shadertoy, as it renders buffers\n* at full target resolution. But this might be useful for WebGL based demos\n* running smaller-than-target render buffers.\n*\n* For sharpening with a full resolution render buffer,\n* FidelityFX CAS is a better option.\n* https://www.shadertoy.com/view/ftsXzM\n*\n* For readability and compatibility, these optimisations have been removed:\n* * Fast approximate inverse and inversesqrt\n* * textureGather fetches (not WebGL compatible)\n* * Multiplying by reciprocal instead of division\n*\n* Apologies to AMD for the numerous slowdowns and errors I have introduced.\n*\n*/\n\n/***** RCAS *****/\n#define FSR_RCAS_LIMIT (0.25-(1.0/16.0))\n\n// Input callback prototypes that need to be implemented by calling shader\nvec4 FsrRcasLoadF(vec2 p);\n//------------------------------------------------------------------------------------------------------------------------------\nvoid FsrRcasCon(\n out float con,\n // The scale is {0.0 := maximum, to N>0, where N is the number of stops (halving) of the reduction of sharpness}.\n float sharpness\n) {\n // Transform from stops to linear value.\n con = exp2(-sharpness);\n}\n\nvec3 FsrRcasF(\n vec2 ip, // Integer pixel position in output.\n float con\n) {\n // Constant generated by RcasSetup().\n // Algorithm uses minimal 3x3 pixel neighborhood.\n // b\n // d e f\n // h\n vec2 sp = vec2(ip);\n vec3 b = FsrRcasLoadF(sp + vec2( 0,-1)).rgb;\n vec3 d = FsrRcasLoadF(sp + vec2(-1, 0)).rgb;\n vec3 e = FsrRcasLoadF(sp).rgb;\n vec3 f = FsrRcasLoadF(sp + vec2( 1, 0)).rgb;\n vec3 h = FsrRcasLoadF(sp + vec2( 0, 1)).rgb;\n\n // Luma times 2.\n float bL = b.g + .5 * (b.b + b.r);\n float dL = d.g + .5 * (d.b + d.r);\n float eL = e.g + .5 * (e.b + e.r);\n float fL = f.g + .5 * (f.b + f.r);\n float hL = h.g + .5 * (h.b + h.r);\n\n // Noise detection.\n #ifdef dDenoise\n float nz = .25 * (bL + dL + fL + hL) - eL;\n nz=clamp(\n abs(nz)\n /(\n max(max(bL,dL),max(eL,max(fL,hL)))\n -min(min(bL,dL),min(eL,min(fL,hL)))\n ),\n 0., 1.\n );\n nz=1.-.5*nz;\n #endif\n\n // Min and max of ring.\n vec3 mn4 = min(b, min(f, h));\n vec3 mx4 = max(b, max(f, h));\n\n // Immediate constants for peak range.\n vec2 peakC = vec2(1., -4.);\n\n // Limiters, these need to be high precision RCPs.\n vec3 hitMin = mn4 / (4. * mx4);\n vec3 hitMax = (peakC.x - mx4) / (4.* mn4 + peakC.y);\n vec3 lobeRGB = max(-hitMin, hitMax);\n float lobe = max(\n -FSR_RCAS_LIMIT,\n min(max(lobeRGB.r, max(lobeRGB.g, lobeRGB.b)), 0.)\n )*con;\n\n // Apply noise removal.\n #ifdef dDenoise\n lobe *= nz;\n #endif\n\n // Resolve, which needs the medium precision rcp approximation to avoid visible tonality changes.\n return (lobe * (b + d + h + f) + e) / (4. * lobe + 1.);\n}\n\n\nvec4 FsrRcasLoadF(vec2 p) {\n return texture2D(tColor, p * uTexSizeInv);\n}\n\nvoid main() {\n // Set up constants\n float con;\n FsrRcasCon(con, uSharpness);\n\n // Perform RCAS pass\n vec3 col = FsrRcasF(gl_FragCoord.xy, con);\n\n gl_FragColor = vec4(col, FsrRcasLoadF(gl_FragCoord.xy).a);\n}\n"),Xnt={...vo,tDepthOpaque:jt("texture","rgba","ubyte","nearest"),tDepthTransparent:jt("texture","rgba","ubyte","nearest"),uTexSize:xe("v2"),dOrthographic:Ft("number"),uNear:xe("f"),uFar:xe("f"),uInvProjection:xe("m4"),uOutlineThreshold:xe("f"),dTransparentOutline:Ft("boolean")},Znt={...vo,tDepth:jt("texture","rgba","ubyte","nearest"),uTexSize:xe("v2"),uProjection:xe("m4"),uInvProjection:xe("m4"),uBounds:xe("v4"),dOrthographic:Ft("number"),uNear:xe("f"),uFar:xe("f"),dSteps:Ft("number"),uMaxDistance:xe("f"),uTolerance:xe("f"),uBias:xe("f"),uLightDirection:xe("v3[]"),uLightColor:xe("v3[]"),dLightCount:Ft("number")},Jnt={...vo,tDepth:jt("texture","rgba","ubyte","nearest"),tDepthHalf:jt("texture","rgba","ubyte","nearest"),tDepthQuarter:jt("texture","rgba","ubyte","nearest"),uSamples:xe("v3[]"),dNSamples:Ft("number"),uProjection:xe("m4"),uInvProjection:xe("m4"),uBounds:xe("v4"),uTexSize:xe("v2"),uRadius:xe("f"),uBias:xe("f"),dMultiScale:Ft("boolean"),dLevels:Ft("number"),uLevelRadius:xe("f[]"),uLevelBias:xe("f[]"),uNearThreshold:xe("f"),uFarThreshold:xe("f")},trt={...vo,tSsaoDepth:jt("texture","rgba","ubyte","nearest"),uTexSize:xe("v2"),uKernel:xe("f[]"),dOcclusionKernelSize:Ft("number"),uBlurDirectionX:xe("f"),uBlurDirectionY:xe("f"),uInvProjection:xe("m4"),uNear:xe("f"),uFar:xe("f"),uBounds:xe("v4"),dOrthographic:Ft("number")};function vue(e,t,n){const r={..._o,tSsaoDepth:k.create(t),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight())),uKernel:k.create(_ue(15)),dOcclusionKernelSize:k.create(15),uBlurDirectionX:k.create("horizontal"===n?1:0),uBlurDirectionY:k.create("vertical"===n?1:0),uInvProjection:k.create(le.identity()),uNear:k.create(0),uFar:k.create(1e4),uBounds:k.create(nn()),dOrthographic:k.create(0)},i={...trt};return ji(zi(e,"triangles",Br("ssao_blur",ps,"\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tSsaoDepth;\nuniform vec2 uTexSize;\nuniform vec4 uBounds;\n\nuniform float uKernel[dOcclusionKernelSize];\n\nuniform float uBlurDirectionX;\nuniform float uBlurDirectionY;\n\nuniform mat4 uInvProjection;\nuniform float uNear;\nuniform float uFar;\n\n#include common\n\nfloat getViewZ(const in float depth) {\n #if dOrthographic == 1\n return orthographicDepthToViewZ(depth, uNear, uFar);\n #else\n return perspectiveDepthToViewZ(depth, uNear, uFar);\n #endif\n}\n\nbool isBackground(const in float depth) {\n return depth == 1.0;\n}\n\nbool outsideBounds(const in vec2 p) {\n return p.x < uBounds.x || p.y < uBounds.y || p.x > uBounds.z || p.y > uBounds.w;\n}\n\nfloat getPixelSize(const in vec2 coords, const in float depth) {\n vec3 viewPos0 = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection);\n vec3 viewPos1 = screenSpaceToViewSpace(vec3(coords + vec2(1.0, 0.0) / uTexSize, depth), uInvProjection);\n return distance(viewPos0, viewPos1);\n}\n\nvoid main(void) {\n vec2 coords = gl_FragCoord.xy / uTexSize;\n\n vec2 packedDepth = texture2D(tSsaoDepth, coords).zw;\n\n if (outsideBounds(coords)) {\n gl_FragColor = vec4(packUnitIntervalToRG(1.0), packedDepth);\n return;\n }\n\n float selfDepth = unpackRGToUnitInterval(packedDepth);\n // if background and if second pass\n if (isBackground(selfDepth) && uBlurDirectionY != 0.0) {\n gl_FragColor = vec4(packUnitIntervalToRG(1.0), packedDepth);\n return;\n }\n\n float selfViewZ = getViewZ(selfDepth);\n float pixelSize = getPixelSize(coords, selfDepth);\n float maxDiffViewZ = pixelSize * 10.0;\n\n vec2 offset = vec2(uBlurDirectionX, uBlurDirectionY) / uTexSize;\n\n float sum = 0.0;\n float kernelSum = 0.0;\n // only if kernelSize is odd\n for (int i = -dOcclusionKernelSize / 2; i <= dOcclusionKernelSize / 2; i++) {\n if (abs(float(i)) > 1.0 && abs(float(i)) * pixelSize > 0.8) continue;\n\n vec2 sampleCoords = coords + float(i) * offset;\n if (outsideBounds(sampleCoords)) {\n continue;\n }\n\n vec4 sampleSsaoDepth = texture2D(tSsaoDepth, sampleCoords);\n\n float sampleDepth = unpackRGToUnitInterval(sampleSsaoDepth.zw);\n if (isBackground(sampleDepth)) {\n continue;\n }\n\n if (abs(float(i)) > 1.0) {\n float sampleViewZ = getViewZ(sampleDepth);\n if (abs(selfViewZ - sampleViewZ) > maxDiffViewZ) {\n continue;\n }\n }\n\n float kernel = uKernel[int(abs(float(i)))]; // abs is not defined for int in webgl1\n float sampleValue = unpackRGToUnitInterval(sampleSsaoDepth.xy);\n\n sum += kernel * sampleValue;\n kernelSum += kernel;\n }\n\n gl_FragColor = vec4(packUnitIntervalToRG(sum / kernelSum), packedDepth);\n}\n"),i,r),r)}function _ue(e){const t=e/3,n=Math.floor((e+1)/2),r=[];for(let i=0;i`${e.radius}, ${e.bias}`,{defaultValue:[{radius:2,bias:1},{radius:5,bias:1},{radius:8,bias:1},{radius:11,bias:1}]}),nearThreshold:C.Numeric(10,{min:0,max:50,step:1}),farThreshold:C.Numeric(1500,{min:0,max:1e4,step:100})}),off:C.Group({})},{cycle:!0}),radius:C.Numeric(5,{min:0,max:20,step:.1},{description:"Final occlusion radius is 2^x",hideIf:e=>"on"===e?.multiScale.name}),bias:C.Numeric(.8,{min:0,max:3,step:.1}),blurKernelSize:C.Numeric(15,{min:1,max:25,step:2}),resolutionScale:C.Numeric(1,{min:.1,max:1,step:.05},{description:"Adjust resolution of occlusion calculation"}),color:C.Color(st(0))}),off:C.Group({})},{cycle:!0,description:"Darken occluded crevices with the ambient occlusion effect"}),shadow:C.MappedStatic("off",{on:C.Group({steps:C.Numeric(1,{min:1,max:64,step:1}),bias:C.Numeric(.6,{min:0,max:1,step:.01}),maxDistance:C.Numeric(3,{min:0,max:256,step:1}),tolerance:C.Numeric(1,{min:0,max:10,step:.1})}),off:C.Group({})},{cycle:!0,description:"Simplistic shadows"}),outline:C.MappedStatic("off",{on:C.Group({scale:C.Numeric(1,{min:1,max:5,step:1}),threshold:C.Numeric(.33,{min:.01,max:1,step:.01}),color:C.Color(st(0)),includeTransparent:C.Boolean(!0,{description:"Whether to show outline for transparent objects"})}),off:C.Group({})},{cycle:!0,description:"Draw outline around 3D objects"}),antialiasing:C.MappedStatic("smaa",{fxaa:C.Group(tnt),smaa:C.Group(fnt),off:C.Group({})},{options:[["fxaa","FXAA"],["smaa","SMAA"],["off","Off"]],description:"Smooth pixel edges"}),sharpening:C.MappedStatic("off",{on:C.Group(Hnt),off:C.Group({})},{cycle:!0,description:"Contrast Adaptive Sharpening"}),background:C.Group(Mnt,{isFlat:!0})};class uc{static isEnabled(t){return"on"===t.occlusion.name||"on"===t.shadow.name||"on"===t.outline.name||"off"!==t.background.variant.name}static isTransparentOutlineEnabled(t){return"on"===t.outline.name&&t.outline.params.includeTransparent}calcSsaoScale(t){return Math.min(1,1/this.webgl.pixelRatio)*t}constructor(t,n,r){this.webgl=t,this.drawPass=r,this.bgColor=v(),this.occlusionOffset=[0,0],this.transparentBackground=!1;const{colorTarget:i,depthTextureTransparent:o,depthTextureOpaque:s}=r,a=i.getWidth(),c=i.getHeight();this.nSamples=1,this.blurKernelSize=1,this.ssaoScale=this.calcSsaoScale(1),this.levels=[],this.target=t.createRenderTarget(a,c,!1,"uint8","linear"),this.outlinesTarget=t.createRenderTarget(a,c,!1),this.outlinesRenderable=function Knt(e,t,n,r){const i=t.getWidth(),o=t.getHeight(),s={..._o,tDepthOpaque:k.create(t),tDepthTransparent:k.create(n),uTexSize:k.create(Me.create(i,o)),dOrthographic:k.create(0),uNear:k.create(1),uFar:k.create(1e4),uInvProjection:k.create(le.identity()),uOutlineThreshold:k.create(.33),dTransparentOutline:k.create(r)},a={...Xnt};return ji(zi(e,"triangles",Br("outlines",ps,"\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tDepthOpaque;\nuniform sampler2D tDepthTransparent;\nuniform vec2 uTexSize;\n\nuniform float uNear;\nuniform float uFar;\nuniform mat4 uInvProjection;\n\nuniform float uOutlineThreshold;\n\n#include common\n\nfloat getViewZ(const in float depth) {\n #if dOrthographic == 1\n return orthographicDepthToViewZ(depth, uNear, uFar);\n #else\n return perspectiveDepthToViewZ(depth, uNear, uFar);\n #endif\n}\n\nfloat getDepthOpaque(const in vec2 coords) {\n #ifdef depthTextureSupport\n return texture2D(tDepthOpaque, coords).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepthOpaque, coords));\n #endif\n}\n\nfloat getDepthTransparent(const in vec2 coords) {\n #ifdef dTransparentOutline\n return unpackRGBAToDepth(texture2D(tDepthTransparent, coords));\n #else\n return 1.0;\n #endif\n}\n\nbool isBackground(const in float depth) {\n return depth == 1.0;\n}\n\nfloat getPixelSize(const in vec2 coords, const in float depth) {\n vec3 viewPos0 = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection);\n vec3 viewPos1 = screenSpaceToViewSpace(vec3(coords + vec2(1.0, 0.0) / uTexSize, depth), uInvProjection);\n return distance(viewPos0, viewPos1);\n}\n\nvoid main(void) {\n float backgroundViewZ = 2.0 * uFar;\n\n vec2 coords = gl_FragCoord.xy / uTexSize;\n vec2 invTexSize = 1.0 / uTexSize;\n\n float selfDepthOpaque = getDepthOpaque(coords);\n float selfViewZOpaque = isBackground(selfDepthOpaque) ? backgroundViewZ : getViewZ(selfDepthOpaque);\n float pixelSizeOpaque = getPixelSize(coords, selfDepthOpaque) * uOutlineThreshold;\n\n float selfDepthTransparent = getDepthTransparent(coords);\n float selfViewZTransparent = isBackground(selfDepthTransparent) ? backgroundViewZ : getViewZ(selfDepthTransparent);\n float pixelSizeTransparent = getPixelSize(coords, selfDepthTransparent) * uOutlineThreshold;\n\n float outline = 1.0;\n float bestDepth = 1.0;\n float transparentFlag = 0.0;\n\n for (int y = -1; y <= 1; y++) {\n for (int x = -1; x <= 1; x++) {\n vec2 sampleCoords = coords + vec2(float(x), float(y)) * invTexSize;\n\n float sampleDepthOpaque = getDepthOpaque(sampleCoords);\n float sampleDepthTransparent = getDepthTransparent(sampleCoords);\n\n float sampleViewZOpaque = isBackground(sampleDepthOpaque) ? backgroundViewZ : getViewZ(sampleDepthOpaque);\n if (abs(selfViewZOpaque - sampleViewZOpaque) > pixelSizeOpaque && selfDepthOpaque > sampleDepthOpaque && sampleDepthOpaque <= bestDepth) {\n outline = 0.0;\n bestDepth = sampleDepthOpaque;\n }\n\n if (sampleDepthTransparent < sampleDepthOpaque) {\n float sampleViewZTransparent = isBackground(sampleDepthTransparent) ? backgroundViewZ : getViewZ(sampleDepthTransparent);\n if (abs(selfViewZTransparent - sampleViewZTransparent) > pixelSizeTransparent && selfDepthTransparent > sampleDepthTransparent && sampleDepthTransparent <= bestDepth) {\n outline = 0.0;\n bestDepth = sampleDepthTransparent;\n transparentFlag = 1.0;\n }\n }\n }\n }\n\n gl_FragColor = vec4(outline, packUnitIntervalToRG(bestDepth), transparentFlag);\n}\n"),a,s),s)}(t,s,o,!0),this.shadowsTarget=t.createRenderTarget(a,c,!1),this.shadowsRenderable=function Qnt(e,t){const n=t.getWidth(),r=t.getHeight(),i={..._o,tDepth:k.create(t),uTexSize:k.create(Me.create(n,r)),uProjection:k.create(le.identity()),uInvProjection:k.create(le.identity()),uBounds:k.create(nn()),dOrthographic:k.create(0),uNear:k.create(1),uFar:k.create(1e4),dSteps:k.create(1),uMaxDistance:k.create(3),uTolerance:k.create(1),uBias:k.create(.6),uLightDirection:k.create([]),uLightColor:k.create([]),dLightCount:k.create(0)},o={...Znt};return ji(zi(e,"triangles",Br("shadows",ps,"\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#include common\n\nuniform sampler2D tDepth;\nuniform vec2 uTexSize;\nuniform vec4 uBounds;\n\nuniform float uNear;\nuniform float uFar;\n\n#if dLightCount != 0\n uniform vec3 uLightDirection[dLightCount];\n uniform vec3 uLightColor[dLightCount];\n#endif\n\nuniform mat4 uProjection;\nuniform mat4 uInvProjection;\n\nuniform float uMaxDistance;\nuniform float uTolerance;\nuniform float uBias;\n\nbool isBackground(const in float depth) {\n return depth == 1.0;\n}\n\nbool outsideBounds(const in vec2 p) {\n return p.x < uBounds.x || p.y < uBounds.y || p.x > uBounds.z || p.y > uBounds.w;\n}\n\nfloat getViewZ(const in float depth) {\n #if dOrthographic == 1\n return orthographicDepthToViewZ(depth, uNear, uFar);\n #else\n return perspectiveDepthToViewZ(depth, uNear, uFar);\n #endif\n}\n\nfloat getDepth(const in vec2 coords) {\n #ifdef depthTextureSupport\n return texture2D(tDepth, coords).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n #endif\n}\n\nfloat screenFade(const in vec2 coords) {\n vec2 c = (coords - uBounds.xy) / (uBounds.zw - uBounds.xy);\n vec2 fade = max(12.0 * abs(c - 0.5) - 5.0, vec2(0.0));\n return saturate(1.0 - dot(fade, fade));\n}\n\n// based on https://panoskarabelas.com/posts/screen_space_shadows/\nfloat screenSpaceShadow(const in vec3 position, const in vec3 lightDirection, const in float stepLength) {\n // Ray position and direction (in view-space)\n vec3 rayPos = position;\n vec3 rayDir = -lightDirection;\n\n // Compute ray step\n vec3 rayStep = rayDir * stepLength;\n\n // Ray march towards the light\n float occlusion = 0.0;\n vec4 rayCoords = vec4(0.0);\n for (int i = 0; i < dSteps; ++i) {\n // Step the ray\n rayPos += rayStep;\n\n rayCoords = uProjection * vec4(rayPos, 1.0);\n rayCoords.xyz = (rayCoords.xyz / rayCoords.w) * 0.5 + 0.5;\n\n if (outsideBounds(rayCoords.xy))\n return 1.0;\n\n // Compute the difference between the ray's and the camera's depth\n float depth = getDepth(rayCoords.xy);\n float viewZ = getViewZ(depth);\n float zDelta = rayPos.z - viewZ;\n\n if (zDelta < uTolerance) {\n occlusion = 1.0;\n\n // Fade out as we approach the edges of the screen\n occlusion *= screenFade(rayCoords.xy);\n\n break;\n }\n }\n\n return 1.0 - (uBias * occlusion);\n}\n\nvoid main(void) {\n vec2 invTexSize = 1.0 / uTexSize;\n vec2 selfCoords = gl_FragCoord.xy * invTexSize;\n\n float selfDepth = getDepth(selfCoords);\n\n if (isBackground(selfDepth)) {\n gl_FragColor = vec4(0.0);\n return;\n }\n\n vec3 selfViewPos = screenSpaceToViewSpace(vec3(selfCoords, selfDepth), uInvProjection);\n float stepLength = uMaxDistance / float(dSteps);\n\n float o = 1.0;\n #if dLightCount != 0\n float sh[dLightCount];\n #pragma unroll_loop_start\n for (int i = 0; i < dLightCount; ++i) {\n sh[i] = screenSpaceShadow(selfViewPos, uLightDirection[i], stepLength);\n o = min(o, sh[i]);\n }\n #pragma unroll_loop_end\n #endif\n\n gl_FragColor = vec4(o);\n}\n"),o,i),i)}(t,s),this.ssaoFramebuffer=t.resources.framebuffer(),this.ssaoBlurFirstPassFramebuffer=t.resources.framebuffer(),this.ssaoBlurSecondPassFramebuffer=t.resources.framebuffer();const u=Math.floor(a*this.ssaoScale),l=Math.floor(c*this.ssaoScale),d=Math.max(1,Math.floor(.5*u)),f=Math.max(1,Math.floor(.5*l)),p=Math.max(1,Math.floor(.25*u)),m=Math.max(1,Math.floor(.25*l));this.downsampledDepthTarget=r.packedDepth?t.createRenderTarget(u,l,!1,"uint8","linear","rgba"):t.createRenderTarget(u,l,!1,"float32","linear",t.isWebGL2?"alpha":"rgba"),this.downsampleDepthRenderable=Iv(t,s);const h=1===this.ssaoScale?s:this.downsampledDepthTarget.texture;this.depthHalfTarget=r.packedDepth?t.createRenderTarget(d,f,!1,"uint8","linear","rgba"):t.createRenderTarget(d,f,!1,"float32","linear",t.isWebGL2?"alpha":"rgba"),this.depthHalfRenderable=Iv(t,h),this.depthQuarterTarget=r.packedDepth?t.createRenderTarget(p,m,!1,"uint8","linear","rgba"):t.createRenderTarget(p,m,!1,"float32","linear",t.isWebGL2?"alpha":"rgba"),this.depthQuarterRenderable=Iv(t,this.depthHalfTarget.texture),this.ssaoDepthTexture=t.resources.texture("image-uint8","rgba","ubyte","linear"),this.ssaoDepthTexture.define(u,l),this.ssaoDepthTexture.attachFramebuffer(this.ssaoFramebuffer,"color0"),this.ssaoDepthBlurProxyTexture=t.resources.texture("image-uint8","rgba","ubyte","linear"),this.ssaoDepthBlurProxyTexture.define(u,l),this.ssaoDepthBlurProxyTexture.attachFramebuffer(this.ssaoBlurFirstPassFramebuffer,"color0"),this.ssaoDepthTexture.attachFramebuffer(this.ssaoBlurSecondPassFramebuffer,"color0"),this.ssaoRenderable=function ert(e,t,n,r){const i={..._o,tDepth:k.create(t),tDepthHalf:k.create(n),tDepthQuarter:k.create(r),uSamples:k.create(xue(32)),dNSamples:k.create(32),uProjection:k.create(le.identity()),uInvProjection:k.create(le.identity()),uBounds:k.create(nn()),uTexSize:k.create(Me.create(e.gl.drawingBufferWidth,e.gl.drawingBufferHeight)),uRadius:k.create(Math.pow(2,5)),uBias:k.create(.8),dMultiScale:k.create(!1),dLevels:k.create(3),uLevelRadius:k.create([Math.pow(2,2),Math.pow(2,5),Math.pow(2,8)]),uLevelBias:k.create([.8,.8,.8]),uNearThreshold:k.create(10),uFarThreshold:k.create(1500)},o={...Jnt};return ji(zi(e,"triangles",Br("ssao",ps,"\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#include common\n\nuniform sampler2D tDepth;\nuniform sampler2D tDepthHalf;\nuniform sampler2D tDepthQuarter;\nuniform vec2 uTexSize;\nuniform vec4 uBounds;\n\nuniform vec3 uSamples[dNSamples];\n\nuniform mat4 uProjection;\nuniform mat4 uInvProjection;\n\n#ifdef dMultiScale\n uniform float uLevelRadius[dLevels];\n uniform float uLevelBias[dLevels];\n uniform float uNearThreshold;\n uniform float uFarThreshold;\n#else\n uniform float uRadius;\n#endif\nuniform float uBias;\n\nfloat smootherstep(float edge0, float edge1, float x) {\n x = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\n return x * x * x * (x * (x * 6.0 - 15.0) + 10.0);\n}\n\nfloat noise(const in vec2 coords) {\n float a = 12.9898;\n float b = 78.233;\n float c = 43758.5453;\n float dt = dot(coords, vec2(a,b));\n float sn = mod(dt, PI);\n return abs(fract(sin(sn) * c)); // is abs necessary?\n}\n\nvec2 getNoiseVec2(const in vec2 coords) {\n return vec2(noise(coords), noise(coords + vec2(PI, 2.71828)));\n}\n\nbool isBackground(const in float depth) {\n return depth == 1.0;\n}\n\nfloat getDepth(const in vec2 coords) {\n vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w));\n #ifdef depthTextureSupport\n return texture2D(tDepth, c).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepth, c));\n #endif\n}\n\n#define dQuarterThreshold 0.1\n#define dHalfThreshold 0.05\n\nfloat getMappedDepth(const in vec2 coords, const in vec2 selfCoords) {\n vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w));\n float d = distance(coords, selfCoords);\n #ifdef depthTextureSupport\n if (d > dQuarterThreshold) {\n return texture2D(tDepthQuarter, c).r;\n } else if (d > dHalfThreshold) {\n return texture2D(tDepthHalf, c).r;\n } else {\n return texture2D(tDepth, c).r;\n }\n #else\n if (d > dQuarterThreshold) {\n return unpackRGBAToDepth(texture2D(tDepthQuarter, c));\n } else if (d > dHalfThreshold) {\n return unpackRGBAToDepth(texture2D(tDepthHalf, c));\n } else {\n return unpackRGBAToDepth(texture2D(tDepth, c));\n }\n #endif\n}\n\nvec3 normalFromDepth(const in float depth, const in float depth1, const in float depth2, vec2 offset1, vec2 offset2) {\n vec3 p1 = vec3(offset1, depth1 - depth);\n vec3 p2 = vec3(offset2, depth2 - depth);\n\n vec3 normal = cross(p1, p2);\n normal.z = -normal.z;\n\n return normalize(normal);\n}\n\nfloat getPixelSize(const in vec2 coords, const in float depth) {\n vec3 viewPos0 = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection);\n vec3 viewPos1 = screenSpaceToViewSpace(vec3(coords + vec2(1.0, 0.0) / uTexSize, depth), uInvProjection);\n return distance(viewPos0, viewPos1);\n}\n\n// StarCraft II Ambient Occlusion by [Filion and McNaughton 2008]\nvoid main(void) {\n vec2 invTexSize = 1.0 / uTexSize;\n vec2 selfCoords = gl_FragCoord.xy * invTexSize;\n\n float selfDepth = getDepth(selfCoords);\n vec2 selfPackedDepth = packUnitIntervalToRG(selfDepth);\n\n if (isBackground(selfDepth)) {\n gl_FragColor = vec4(packUnitIntervalToRG(1.0), selfPackedDepth);\n return;\n }\n\n vec2 offset1 = vec2(0.0, invTexSize.y);\n vec2 offset2 = vec2(invTexSize.x, 0.0);\n\n float selfDepth1 = getDepth(selfCoords + offset1);\n float selfDepth2 = getDepth(selfCoords + offset2);\n\n vec3 selfViewNormal = normalFromDepth(selfDepth, selfDepth1, selfDepth2, offset1, offset2);\n vec3 selfViewPos = screenSpaceToViewSpace(vec3(selfCoords, selfDepth), uInvProjection);\n\n vec3 randomVec = normalize(vec3(getNoiseVec2(selfCoords) * 2.0 - 1.0, 0.0));\n vec3 tangent = normalize(randomVec - selfViewNormal * dot(randomVec, selfViewNormal));\n vec3 bitangent = cross(selfViewNormal, tangent);\n mat3 TBN = mat3(tangent, bitangent, selfViewNormal);\n\n float occlusion = 0.0;\n #ifdef dMultiScale\n float pixelSize = getPixelSize(selfCoords, selfDepth);\n\n for(int l = 0; l < dLevels; l++) {\n // TODO: smooth transition\n if (pixelSize * uNearThreshold > uLevelRadius[l]) continue;\n if (pixelSize * uFarThreshold < uLevelRadius[l]) continue;\n\n float levelOcclusion = 0.0;\n for(int i = 0; i < dNSamples; i++) {\n vec3 sampleViewPos = TBN * uSamples[i];\n sampleViewPos = selfViewPos + sampleViewPos * uLevelRadius[l];\n\n vec4 offset = vec4(sampleViewPos, 1.0);\n offset = uProjection * offset;\n offset.xyz = (offset.xyz / offset.w) * 0.5 + 0.5;\n\n float sampleDepth = getMappedDepth(offset.xy, selfCoords);\n float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, sampleDepth), uInvProjection).z;\n\n levelOcclusion += step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uLevelRadius[l] / abs(selfViewPos.z - sampleViewZ)) * uLevelBias[l];\n }\n occlusion = max(occlusion, levelOcclusion);\n }\n #else\n for(int i = 0; i < dNSamples; i++) {\n vec3 sampleViewPos = TBN * uSamples[i];\n sampleViewPos = selfViewPos + sampleViewPos * uRadius;\n\n vec4 offset = vec4(sampleViewPos, 1.0);\n offset = uProjection * offset;\n offset.xyz = (offset.xyz / offset.w) * 0.5 + 0.5;\n\n float sampleDepth = getMappedDepth(offset.xy, selfCoords);\n float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, sampleDepth), uInvProjection).z;\n\n occlusion += step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uRadius / abs(selfViewPos.z - sampleViewZ));\n }\n #endif\n occlusion = 1.0 - (uBias * occlusion / float(dNSamples));\n\n vec2 packedOcclusion = packUnitIntervalToRG(clamp(occlusion, 0.01, 1.0));\n\n gl_FragColor = vec4(packedOcclusion, selfPackedDepth);\n}\n"),o,i),i)}(t,h,this.depthHalfTarget.texture,this.depthQuarterTarget.texture),this.ssaoBlurFirstPassRenderable=vue(t,this.ssaoDepthTexture,"horizontal"),this.ssaoBlurSecondPassRenderable=vue(t,this.ssaoDepthBlurProxyTexture,"vertical"),this.renderable=function rrt(e,t,n,r,i,o,s,a){const c={..._o,tSsaoDepth:k.create(s),tColor:k.create(t),tDepthOpaque:k.create(n),tDepthTransparent:k.create(r),tShadows:k.create(i),tOutlines:k.create(o),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight())),dOrthographic:k.create(0),uNear:k.create(1),uFar:k.create(1e4),uFogNear:k.create(1e4),uFogFar:k.create(1e4),uFogColor:k.create(v.create(1,1,1)),uOutlineColor:k.create(v.create(0,0,0)),uOcclusionColor:k.create(v.create(0,0,0)),uTransparentBackground:k.create(!1),dOcclusionEnable:k.create(!0),uOcclusionOffset:k.create(Me.create(0,0)),dShadowEnable:k.create(!1),dOutlineEnable:k.create(!1),dOutlineScale:k.create(1),dTransparentOutline:k.create(a)},u={...nrt};return ji(zi(e,"triangles",Br("postprocessing",ps,"\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tSsaoDepth;\nuniform sampler2D tColor;\nuniform sampler2D tDepthOpaque;\nuniform sampler2D tDepthTransparent;\nuniform sampler2D tShadows;\nuniform sampler2D tOutlines;\nuniform vec2 uTexSize;\n\nuniform float uNear;\nuniform float uFar;\nuniform float uFogNear;\nuniform float uFogFar;\nuniform vec3 uFogColor;\nuniform vec3 uOutlineColor;\nuniform vec3 uOcclusionColor;\nuniform bool uTransparentBackground;\nuniform vec2 uOcclusionOffset;\n\n#include common\n\nfloat getViewZ(const in float depth) {\n #if dOrthographic == 1\n return orthographicDepthToViewZ(depth, uNear, uFar);\n #else\n return perspectiveDepthToViewZ(depth, uNear, uFar);\n #endif\n}\n\nfloat getDepthOpaque(const in vec2 coords) {\n #ifdef depthTextureSupport\n return texture2D(tDepthOpaque, coords).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepthOpaque, coords));\n #endif\n}\n\nfloat getDepthTransparent(const in vec2 coords) {\n #ifdef dTransparentOutline\n return unpackRGBAToDepth(texture2D(tDepthTransparent, coords));\n #else\n return 1.0;\n #endif\n}\n\nbool isBackground(const in float depth) {\n return depth == 1.0;\n}\n\nfloat getOutline(const in vec2 coords, const in float opaqueDepth, out float closestTexel) {\n float backgroundViewZ = 2.0 * uFar;\n vec2 invTexSize = 1.0 / uTexSize;\n\n float transparentDepth = getDepthTransparent(coords);\n float opaqueSelfViewZ = isBackground(opaqueDepth) ? backgroundViewZ : getViewZ(opaqueDepth);\n float transparentSelfViewZ = isBackground(transparentDepth) ? backgroundViewZ : getViewZ(transparentDepth);\n float selfDepth = min(opaqueDepth, transparentDepth);\n\n float outline = 1.0;\n closestTexel = 1.0;\n for (int y = -dOutlineScale; y <= dOutlineScale; y++) {\n for (int x = -dOutlineScale; x <= dOutlineScale; x++) {\n if (x * x + y * y > dOutlineScale * dOutlineScale) {\n continue;\n }\n\n vec2 sampleCoords = coords + vec2(float(x), float(y)) * invTexSize;\n\n vec4 sampleOutlineCombined = texture2D(tOutlines, sampleCoords);\n float sampleOutline = sampleOutlineCombined.r;\n float sampleOutlineDepth = unpackRGToUnitInterval(sampleOutlineCombined.gb);\n float sampleOutlineViewZ = isBackground(sampleOutlineDepth) ? backgroundViewZ : getViewZ(sampleOutlineDepth);\n\n float selfViewZ = sampleOutlineCombined.a == 0.0 ? opaqueSelfViewZ : transparentSelfViewZ;\n if (sampleOutline == 0.0 && sampleOutlineDepth < closestTexel) {\n outline = 0.0;\n closestTexel = sampleOutlineDepth;\n }\n }\n }\n return closestTexel < opaqueDepth ? outline : 1.0;\n}\n\nfloat getSsao(vec2 coords) {\n float rawSsao = unpackRGToUnitInterval(texture2D(tSsaoDepth, coords).xy);\n if (rawSsao > 0.999) {\n return 1.0;\n } else if (rawSsao > 0.001) {\n return rawSsao;\n }\n // treat values close to 0.0 as errors and return no occlusion\n return 1.0;\n}\n\nvoid main(void) {\n vec2 coords = gl_FragCoord.xy / uTexSize;\n vec4 color = texture2D(tColor, coords);\n\n float viewDist;\n float fogFactor;\n float opaqueDepth = getDepthOpaque(coords);\n\n #ifdef dOcclusionEnable\n if (!isBackground(opaqueDepth)) {\n viewDist = abs(getViewZ(opaqueDepth));\n fogFactor = smoothstep(uFogNear, uFogFar, viewDist);\n float occlusionFactor = getSsao(coords + uOcclusionOffset);\n if (!uTransparentBackground) {\n color.rgb = mix(mix(uOcclusionColor, uFogColor, fogFactor), color.rgb, occlusionFactor);\n } else {\n color.rgb = mix(uOcclusionColor * (1.0 - fogFactor), color.rgb, occlusionFactor);\n }\n }\n #endif\n\n #ifdef dShadowEnable\n if (!isBackground(opaqueDepth)) {\n viewDist = abs(getViewZ(opaqueDepth));\n fogFactor = smoothstep(uFogNear, uFogFar, viewDist);\n vec4 shadow = texture2D(tShadows, coords);\n if (!uTransparentBackground) {\n color.rgb = mix(mix(vec3(0), uFogColor, fogFactor), color.rgb, shadow.a);\n } else {\n color.rgb = mix(vec3(0) * (1.0 - fogFactor), color.rgb, shadow.a);\n }\n }\n #endif\n\n // outline needs to be handled after occlusion and shadow to keep them clean\n #ifdef dOutlineEnable\n float closestTexel;\n float outline = getOutline(coords, opaqueDepth, closestTexel);\n if (outline == 0.0) {\n viewDist = abs(getViewZ(closestTexel));\n fogFactor = smoothstep(uFogNear, uFogFar, viewDist);\n if (!uTransparentBackground) {\n color.rgb = mix(uOutlineColor, uFogColor, fogFactor);\n } else {\n color.a = 1.0 - fogFactor;\n color.rgb = mix(uOutlineColor, color.rgb, fogFactor);\n }\n }\n #endif\n\n gl_FragColor = color;\n}\n"),u,c),c)}(t,i.texture,s,o,this.shadowsTarget.texture,this.outlinesTarget.texture,this.ssaoDepthTexture,!0),this.background=new Rnt(t,n,a,c)}setSize(t,n){const[r,i]=this.renderable.values.uTexSize.ref.value,o=this.calcSsaoScale(1);if(t!==r||n!==i||this.ssaoScale!==o){this.ssaoScale=o,this.target.setSize(t,n),this.outlinesTarget.setSize(t,n),this.shadowsTarget.setSize(t,n);const s=Math.floor(t*this.ssaoScale),a=Math.floor(n*this.ssaoScale);this.downsampledDepthTarget.setSize(s,a),this.ssaoDepthTexture.define(s,a),this.ssaoDepthBlurProxyTexture.define(s,a);const c=Math.max(1,Math.floor(.5*s)),u=Math.max(1,Math.floor(.5*a));this.depthHalfTarget.setSize(c,u);const l=Math.max(1,Math.floor(.25*s)),d=Math.max(1,Math.floor(.25*a));this.depthQuarterTarget.setSize(l,d),k.update(this.renderable.values.uTexSize,Me.set(this.renderable.values.uTexSize.ref.value,t,n)),k.update(this.outlinesRenderable.values.uTexSize,Me.set(this.outlinesRenderable.values.uTexSize.ref.value,t,n)),k.update(this.shadowsRenderable.values.uTexSize,Me.set(this.shadowsRenderable.values.uTexSize.ref.value,t,n)),k.update(this.downsampleDepthRenderable.values.uTexSize,Me.set(this.downsampleDepthRenderable.values.uTexSize.ref.value,s,a)),k.update(this.depthHalfRenderable.values.uTexSize,Me.set(this.depthHalfRenderable.values.uTexSize.ref.value,c,u)),k.update(this.depthQuarterRenderable.values.uTexSize,Me.set(this.depthQuarterRenderable.values.uTexSize.ref.value,l,d)),k.update(this.ssaoRenderable.values.uTexSize,Me.set(this.ssaoRenderable.values.uTexSize.ref.value,s,a)),k.update(this.ssaoBlurFirstPassRenderable.values.uTexSize,Me.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value,s,a)),k.update(this.ssaoBlurSecondPassRenderable.values.uTexSize,Me.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value,s,a));const f=1===this.ssaoScale?this.drawPass.depthTextureOpaque:this.downsampledDepthTarget.texture;k.update(this.depthHalfRenderable.values.tColor,f),k.update(this.ssaoRenderable.values.tDepth,f),this.depthHalfRenderable.update(),this.ssaoRenderable.update(),this.background.setSize(t,n)}}updateState(t,n,r,i,o){var s;let a=!1,c=!1,u=!1,l=!1,d=!1,f=!1;const p="orthographic"===t.state.mode?1:0,m="on"===i.outline.name,h="on"===i.shadow.name,g="on"===i.occlusion.name,y=le.identity();le.invert(y,t.projection);const[b,x]=this.renderable.values.uTexSize.ref.value,_=t.viewport;if("on"===i.occlusion.name){k.update(this.ssaoRenderable.values.uProjection,t.projection),k.update(this.ssaoRenderable.values.uInvProjection,y);const E=this.ssaoRenderable.values.uBounds,w=this.ssaoScale;nn.set(E.ref.value,Math.floor(_.x*w)/(b*w),Math.floor(_.y*w)/(x*w),Math.ceil((_.x+_.width)*w)/(b*w),Math.ceil((_.y+_.height)*w)/(x*w)),k.update(E,E.ref.value),k.update(this.ssaoBlurFirstPassRenderable.values.uBounds,E.ref.value),k.update(this.ssaoBlurSecondPassRenderable.values.uBounds,E.ref.value),k.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uNear,t.near),k.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uNear,t.near),k.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uFar,t.far),k.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uFar,t.far),k.update(this.ssaoBlurFirstPassRenderable.values.uInvProjection,y),k.update(this.ssaoBlurSecondPassRenderable.values.uInvProjection,y),this.ssaoBlurFirstPassRenderable.values.dOrthographic.ref.value!==p&&(l=!0,k.update(this.ssaoBlurFirstPassRenderable.values.dOrthographic,p),k.update(this.ssaoBlurSecondPassRenderable.values.dOrthographic,p)),this.nSamples!==i.occlusion.params.samples&&(u=!0,this.nSamples=i.occlusion.params.samples,k.update(this.ssaoRenderable.values.uSamples,xue(this.nSamples)),k.updateIfChanged(this.ssaoRenderable.values.dNSamples,this.nSamples));const D="on"===i.occlusion.params.multiScale.name;if(this.ssaoRenderable.values.dMultiScale.ref.value!==D&&(u=!0,k.update(this.ssaoRenderable.values.dMultiScale,D)),"on"===i.occlusion.params.multiScale.name){const R=i.occlusion.params.multiScale.params;if(!Yd(this.levels,R.levels)){u=!0,this.levels=R.levels;const T=function irt(e,t){const n=e.length,{radius:r,bias:i}=t||{radius:new Array(3*n).fill(0),bias:new Array(3*n).fill(0)};e=e.slice().sort((o,s)=>o.radius-s.radius);for(let o=0;o=p.length)return-2;const{x:m,y:h,width:g,height:y}=o.viewport,b=1/p.length;if(-1===t)u.render(n,r,!1),k.update(s.values.uWeight,1),k.update(s.values.tColor,u.getColorTarget(r.postprocessing).texture),s.update(),c.bind(),f.disable(d.BLEND),f.disable(d.DEPTH_TEST),f.depthMask(!1),f.viewport(m,h,g,y),f.scissor(m,h,g,y),s.render(),t+=1;else{o.viewOffset.enabled=!0,k.update(s.values.tColor,u.getColorTarget(r.postprocessing).texture),k.update(s.values.uWeight,b),s.update();const _=Math.pow(2,Math.max(0,r.multiSample.sampleLevel-2));for(let S=0;S<_;++S){const A=p[t];if(gr.setViewOffset(o.viewOffset,g,y,A[0],A[1],g,y),o.update(),0===t?u.postprocessing.setOcclusionOffset(0,0):u.postprocessing.setOcclusionOffset(A[0]/g,A[1]/y),u.render(n,r,!1),a.bind(),f.enable(d.BLEND),f.blendEquationSeparate(d.FUNC_ADD,d.FUNC_ADD),f.blendFuncSeparate(d.ONE,d.ONE,d.ONE,d.ONE),f.disable(d.DEPTH_TEST),f.depthMask(!1),f.viewport(m,h,g,y),f.scissor(m,h,g,y),0===t&&(f.clearColor(0,0,0,0),d.clear(d.COLOR_BUFFER_BIT)),s.render(),(t+=1)>=p.length)break}}u.postprocessing.setOcclusionOffset(0,0),this.bindOutputTarget(i),f.viewport(m,h,g,y),f.scissor(m,h,g,y);const x=t*b;return x>0&&(k.update(s.values.uWeight,1),k.update(s.values.tColor,a.texture),s.update(),f.disable(d.BLEND),s.render()),x<1&&(k.update(s.values.uWeight,1-x),k.update(s.values.tColor,c.texture),s.update(),0===x?f.disable(d.BLEND):f.enable(d.BLEND),s.render()),o.viewOffset.enabled=!1,o.update(),lt&&l.timer.markEnd("MultiSamplePass.renderTemporalMultiSample"),t>=p.length?-2:t}}const N8=[[[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]]];N8.forEach(e=>{e.forEach(t=>{t[0]*=.0625,t[1]*=.0625})});class wue{update(t,n){return t&&(this.sampleIndex=-1),"temporal"===n.mode&&-2!==this.sampleIndex}render(t,n,r,i){return this.sampleIndex=this.multiSamplePass.render(this.sampleIndex,t,n,r,!!i),this.sampleIndex<0}constructor(t){this.multiSamplePass=t,this.sampleIndex=-2}}const Aue={eyeSeparation:C.Numeric(.062,{min:.02,max:.1,step:.001},{description:"Distance between left and right camera."}),focus:C.Numeric(10,{min:1,max:20,step:.1},{description:"Apparent object distance."})},urt=C.getDefaultValues(Aue);class Yv{get viewport(){return this.parent.viewport}get viewOffset(){return this.parent.viewOffset}constructor(t,n={}){this.parent=t,this.left=new Iue,this.right=new Iue,this.props={...urt,...n}}setProps(t){Object.assign(this.props,t)}update(){this.parent.update(),function lrt(e,t,n,r){Lo.copy(n.viewport,e.viewport),le.copy(n.view,e.view),le.copy(n.projection,e.projection),gr.copySnapshot(n.state,e.state),gr.copyViewOffset(n.viewOffset,e.viewOffset),n.far=e.far,n.near=e.near,n.fogFar=e.fogFar,n.fogNear=e.fogNear,Lo.copy(r.viewport,e.viewport),le.copy(r.view,e.view),le.copy(r.projection,e.projection),gr.copySnapshot(r.state,e.state),gr.copyViewOffset(r.viewOffset,e.viewOffset),r.far=e.far,r.near=e.near,r.fogFar=e.fogFar,r.fogNear=e.fogNear;const i=Math.floor(e.viewport.width/2),o=i/e.viewport.height;n.viewport.width=i,r.viewport.x+=i,r.viewport.width-=i;const s=t.eyeSeparation/2,a=s*e.near/t.focus,c=e.near*Math.tan(.5*e.state.fov);let u,l;Tue[12]=-s,Due[12]=s,u=-c*o+a,l=c*o+a,n.projection[0]=2*e.near/(l-u),n.projection[8]=(l+u)/(l-u),le.mul(n.view,n.view,Tue),le.mul(n.projectionView,n.projection,n.view),le.invert(n.inverseProjectionView,n.projectionView),u=-c*o-a,l=c*o-a,r.projection[0]=2*e.near/(l-u),r.projection[8]=(l+u)/(l-u),le.mul(r.view,r.view,Due),le.mul(r.projectionView,r.projection,r.view),le.invert(r.inverseProjectionView,r.projectionView)}(this.parent,this.props,this.left,this.right)}}!function(e){e.is=function t(n){return"left"in n&&"right"in n}}(Yv||(Yv={}));class Iue{constructor(){this.viewport=Lo.create(0,0,0,0),this.view=le(),this.projection=le(),this.projectionView=le(),this.inverseProjectionView=le(),this.state=gr.createDefaultSnapshot(),this.viewOffset=gr.ViewOffset(),this.far=0,this.near=0,this.fogFar=0,this.fogNear=0}}const Tue=le.identity(),Due=le.identity(),F8=Math.pow(2,24)-2;class drt{constructor(t,n,r){this.webgl=t,this.drawPass=n,this.pickScale=r;const i=r/t.pixelRatio;this.pickWidth=Math.ceil(n.colorTarget.getWidth()*i),this.pickHeight=Math.ceil(n.colorTarget.getHeight()*i);const{resources:o,extensions:{drawBuffers:s},gl:a}=t;s?(this.objectPickTexture=o.texture("image-uint8","rgba","ubyte","nearest"),this.objectPickTexture.define(this.pickWidth,this.pickHeight),this.instancePickTexture=o.texture("image-uint8","rgba","ubyte","nearest"),this.instancePickTexture.define(this.pickWidth,this.pickHeight),this.groupPickTexture=o.texture("image-uint8","rgba","ubyte","nearest"),this.groupPickTexture.define(this.pickWidth,this.pickHeight),this.depthPickTexture=o.texture("image-uint8","rgba","ubyte","nearest"),this.depthPickTexture.define(this.pickWidth,this.pickHeight),this.framebuffer=o.framebuffer(),this.objectPickFramebuffer=o.framebuffer(),this.instancePickFramebuffer=o.framebuffer(),this.groupPickFramebuffer=o.framebuffer(),this.depthPickFramebuffer=o.framebuffer(),this.framebuffer.bind(),s.drawBuffers([s.COLOR_ATTACHMENT0,s.COLOR_ATTACHMENT1,s.COLOR_ATTACHMENT2,s.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=Wt(a)?o.renderbuffer("depth32f","depth",this.pickWidth,this.pickHeight):o.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))}get pickRatio(){return this.pickScale/this.webgl.pixelRatio}setPickScale(t){this.pickScale=t,this.syncSize()}bindObject(){this.webgl.extensions.drawBuffers?this.objectPickFramebuffer.bind():this.objectPickTarget.bind()}bindInstance(){this.webgl.extensions.drawBuffers?this.instancePickFramebuffer.bind():this.instancePickTarget.bind()}bindGroup(){this.webgl.extensions.drawBuffers?this.groupPickFramebuffer.bind():this.groupPickTarget.bind()}bindDepth(){this.webgl.extensions.drawBuffers?this.depthPickFramebuffer.bind():this.depthPickTarget.bind()}get drawingBufferHeight(){return this.drawPass.colorTarget.getHeight()}syncSize(){const t=this.pickScale/this.webgl.pixelRatio,n=Math.ceil(this.drawPass.colorTarget.getWidth()*t),r=Math.ceil(this.drawPass.colorTarget.getHeight()*t);(n!==this.pickWidth||r!==this.pickHeight)&&(this.pickWidth=n,this.pickHeight=r,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)))}renderVariant(t,n,r,i,o,s){t.clear(!1),t.update(n,r),t.renderPick(r.primitives,n,o,null,s),i.handle.isEnabled&&t.renderPick(i.handle.scene,n,o,null,s),i.camera.isEnabled&&(i.camera.update(n),t.update(i.camera.camera,i.camera.scene),t.renderPick(i.camera.scene,i.camera.camera,o,null,s))}render(t,n,r,i){this.webgl.extensions.drawBuffers?(this.framebuffer.bind(),this.renderVariant(t,n,r,i,"pick",D0.None)):(this.objectPickTarget.bind(),this.renderVariant(t,n,r,i,"pick",D0.Object),this.instancePickTarget.bind(),this.renderVariant(t,n,r,i,"pick",D0.Instance),this.groupPickTarget.bind(),this.renderVariant(t,n,r,i,"pick",D0.Group),this.depthPickTarget.bind(),this.renderVariant(t,n,r,i,"depth",D0.None))}}class frt{setupBuffers(){const 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))}setViewport(t,n,r,i){Lo.set(this.viewport,t,n,r,i),this.pickRatio=this.pickPass.pickRatio,this.pickX=Math.ceil(t*this.pickRatio),this.pickY=Math.ceil(n*this.pickRatio);const o=Math.floor(r*this.pickRatio),s=Math.floor(i*this.pickRatio);(o!==this.pickWidth||s!==this.pickHeight)&&(this.pickWidth=o,this.pickHeight=s,this.halfPickWidth=Math.floor(this.pickWidth/2),this.setupBuffers()),this.spiral=function rMe(e){let t=0,n=0;const r=[0,-1],i=2*e+1,o=i/2,s=[];for(let a=Math.pow(i,2);a>0;--a)-o0&&t===1-n)&&([r[0],r[1]]=[-r[1],r[0]]),t+=r[0],n+=r[1];return s}(Math.round(this.pickRatio*this.pickPadding))}syncBuffers(){lt&&this.webgl.timer.mark("PickHelper.syncBuffers");const{pickX:t,pickY:n,pickWidth:r,pickHeight:i}=this;this.pickPass.bindObject(),this.webgl.readPixels(t,n,r,i,this.objectBuffer),this.pickPass.bindInstance(),this.webgl.readPixels(t,n,r,i,this.instanceBuffer),this.pickPass.bindGroup(),this.webgl.readPixels(t,n,r,i,this.groupBuffer),this.pickPass.bindDepth(),this.webgl.readPixels(t,n,r,i,this.depthBuffer),lt&&this.webgl.timer.markEnd("PickHelper.syncBuffers")}getBufferIdx(t,n){return 4*(n*this.pickWidth+t)}getDepth(t,n){const r=this.getBufferIdx(t,n),i=this.depthBuffer;return function SHe(e,t,n,r){return nn.set(Rie,e/255,t/255,n/255,r/255),nn.dot(Rie,xHe)}(i[r],i[r+1],i[r+2],i[r+3])}getId(t,n,r){const i=this.getBufferIdx(t,n);return g5(r[i],r[i+1],r[i+2])}render(t){lt&&this.webgl.timer.mark("PickHelper.render",!0);const{pickX:n,pickY:r,pickWidth:i,pickHeight:o,halfPickWidth:s}=this,{renderer:a,scene:c,helper:u}=this;a.setTransparentBackground(!1),a.setDrawingBufferSize(i,o),a.setPixelRatio(this.pickRatio),Yv.is(t)?(a.setViewport(n,r,s,o),this.pickPass.render(a,t.left,c,u),a.setViewport(n+s,r,i-s,o),this.pickPass.render(a,t.right,c,u)):(a.setViewport(n,r,i,o),this.pickPass.render(a,t,c,u)),this.dirty=!1,lt&&this.webgl.timer.markEnd("PickHelper.render")}identifyInternal(t,n,r){const{webgl:i,pickRatio:o}=this;if(i.isContextLost)return;t*=i.pixelRatio,n=this.pickPass.drawingBufferHeight-(n*=i.pixelRatio);const{viewport:s}=this;if(ts.x+s.width||n>s.y+s.height)return;this.dirty&&(lt&&this.webgl.timer.mark("PickHelper.identify"),this.render(r),this.syncBuffers(),lt&&this.webgl.timer.markEnd("PickHelper.identify"));const a=t-s.x,c=n-s.y,u=Math.floor(a*o),l=Math.floor(c*o),d=this.getId(u,l,this.objectBuffer);if(-1===d||d===F8)return;const f=this.getId(u,l,this.instanceBuffer);if(-1===f||f===F8)return;const p=this.getId(u,l,this.groupBuffer);if(-1===p||p===F8)return;const m=this.getDepth(u,l),h=v.create(t,n,m);if(Yv.is(r)){const g=Math.floor(s.width/2);t>s.x+g?(h[0]=s.x+2*(a-g),xE(h,h,s,r.right.inverseProjectionView)):(h[0]=s.x+2*a,xE(h,h,s,r.left.inverseProjectionView))}else xE(h,h,s,r.inverseProjectionView);return{id:{objectId:d,instanceId:f,groupId:p},position:h}}identify(t,n,r){for(const i of this.spiral){const o=this.identifyInternal(t+i[0],n+i[1],r);if(o)return o}}constructor(t,n,r,i,o,s,a=1){this.webgl=t,this.renderer=n,this.scene=r,this.helper=i,this.pickPass=o,this.pickPadding=a,this.dirty=!0,this.viewport=Lo(),this.setViewport(s.x,s.y,s.width,s.height)}}const hrt={...vo,tWboitA:jt("texture","rgba","float","nearest"),tWboitB:jt("texture","rgba","float","nearest"),uTexSize:xe("v2")},mrt=Br("evaluate-wboit",ps,"\nprecision highp float;\n\nuniform sampler2D tWboitA;\nuniform sampler2D tWboitB;\nuniform vec2 uTexSize;\n\nvoid main() {\n vec2 coords = gl_FragCoord.xy / uTexSize;\n\n vec4 accum = texture2D(tWboitA, coords);\n float r = 1.0 - accum.a;\n\n accum.a = texture2D(tWboitB, coords).r;\n // divisor needs to allow very small values for nice fading\n gl_FragColor = vec4(accum.rgb / clamp(accum.a, 0.00000001, 50000.0), r);\n}\n");class B8{get supported(){return this._supported}bind(){const{state:t,gl:n}=this.webgl;this.framebuffer.bind(),t.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT),t.disable(n.DEPTH_TEST),t.blendFuncSeparate(n.ONE,n.ONE,n.ZERO,n.ONE_MINUS_SRC_ALPHA),t.enable(n.BLEND)}render(){lt&&this.webgl.timer.mark("WboitPass.render");const{state:t,gl:n}=this.webgl;t.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA),t.enable(n.BLEND),this.renderable.update(),this.renderable.render(),lt&&this.webgl.timer.markEnd("WboitPass.render")}setSize(t,n){const[r,i]=this.renderable.values.uTexSize.ref.value;(t!==r||n!==i)&&(this.textureA.define(t,n),this.textureB.define(t,n),this.depthRenderbuffer.setSize(t,n),k.update(this.renderable.values.uTexSize,Me.set(this.renderable.values.uTexSize.ref.value,t,n)))}reset(){this._supported&&this._init()}_init(){const{extensions:{drawBuffers:t}}=this.webgl;this.framebuffer.bind(),t.drawBuffers([t.COLOR_ATTACHMENT0,t.COLOR_ATTACHMENT1]),this.textureA.attachFramebuffer(this.framebuffer,"color0"),this.textureB.attachFramebuffer(this.framebuffer,"color1"),this.depthRenderbuffer.attachFramebuffer(this.framebuffer)}static isSupported(t){const{extensions:{drawBuffers:n,textureFloat:r,colorBufferFloat:i,depthTexture:o}}=t;if(r&&i&&o&&n)return!0;if(un){const s=[];r||s.push("textureFloat"),i||s.push("colorBufferFloat"),o||s.push("depthTexture"),n||s.push("drawBuffers"),console.log(`Missing "${s.join('", "')}" extensions required for "wboit"`)}return!1}constructor(t,n,r){if(this.webgl=t,this._supported=!1,!B8.isSupported(t))return;const{resources:i,gl:o}=t;this.textureA=i.texture("image-float32","rgba","float","nearest"),this.textureA.define(n,r),this.textureB=i.texture("image-float32","rgba","float","nearest"),this.textureB.define(n,r),this.depthRenderbuffer=Wt(o)?i.renderbuffer("depth32f","depth",n,r):i.renderbuffer("depth16","depth",n,r),this.renderable=function grt(e,t,n){const r={..._o,tWboitA:k.create(t),tWboitB:k.create(n),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight()))},i={...hrt};return ji(zi(e,"triangles",mrt,i,r),r)}(t,this.textureA,this.textureB),this.framebuffer=i.framebuffer(),this._supported=!0,this._init()}}const vrt={...vo,tDpoitBackColor:jt("texture","rgba","float","nearest"),uTexSize:xe("v2")},_rt=Br("blend-back-dpoit",ps,"\n precision highp float;\n\n uniform sampler2D tDpoitBackColor;\n uniform vec2 uTexSize;\n\n void main() {\n vec2 coords = gl_FragCoord.xy / uTexSize;\n gl_FragColor = texture2D(tDpoitBackColor, coords);\n if (gl_FragColor.a == 0.0) {\n discard;\n }\n }\n"),Srt={...vo,tDpoitFrontColor:jt("texture","rgba","float","nearest"),uTexSize:xe("v2")},Crt=Br("evaluate-dpoit",ps,"\nprecision highp float;\n\nuniform sampler2D tDpoitFrontColor;\nuniform vec2 uTexSize;\n\nvoid main() {\n vec2 coords = gl_FragCoord.xy / uTexSize;\n gl_FragColor = texture2D(tDpoitFrontColor, coords);\n}\n");class O8{get supported(){return this._supported}bind(){const{state:t,gl:n,extensions:{blendMinMax:r}}=this.webgl;return this.passCount=0,this.depthFramebuffers[0].bind(),t.clearColor(this.DEPTH_CLEAR_VALUE,this.DEPTH_CLEAR_VALUE,0,0),n.clear(n.COLOR_BUFFER_BIT),this.depthFramebuffers[1].bind(),t.clearColor(-this.MIN_DEPTH,this.MAX_DEPTH,0,0),n.clear(n.COLOR_BUFFER_BIT),this.colorFramebuffers[0].bind(),t.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),this.colorFramebuffers[1].bind(),t.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),this.depthFramebuffers[0].bind(),t.blendEquation(r.MAX),t.depthMask(!1),{depth:this.depthTextures[1],frontColor:this.colorFrontTextures[1],backColor:this.colorBackTextures[1]}}bindDualDepthPeeling(){const{state:t,gl:n,extensions:{blendMinMax:r}}=this.webgl;return this.readId=this.passCount%2,this.writeId=1-this.readId,this.passCount+=1,this.depthFramebuffers[this.writeId].bind(),t.clearColor(this.DEPTH_CLEAR_VALUE,this.DEPTH_CLEAR_VALUE,0,0),n.clear(n.COLOR_BUFFER_BIT),this.colorFramebuffers[this.writeId].bind(),t.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),this.depthFramebuffers[this.writeId].bind(),t.blendEquation(r.MAX),t.depthMask(!1),{depth:this.depthTextures[this.readId],frontColor:this.colorFrontTextures[this.readId],backColor:this.colorBackTextures[this.readId]}}renderBlendBack(){lt&&this.webgl.timer.mark("DpoitPass.renderBlendBack");const{state:t,gl:n}=this.webgl;t.blendEquation(n.FUNC_ADD),t.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA),k.update(this.blendBackRenderable.values.tDpoitBackColor,this.colorBackTextures[this.writeId]),this.blendBackRenderable.update(),this.blendBackRenderable.render(),lt&&this.webgl.timer.markEnd("DpoitPass.renderBlendBack")}render(){lt&&this.webgl.timer.mark("DpoitPass.render");const{state:t,gl:n}=this.webgl;t.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA),k.update(this.renderable.values.tDpoitFrontColor,this.colorFrontTextures[this.writeId]),this.renderable.update(),this.renderable.render(),lt&&this.webgl.timer.markEnd("DpoitPass.render")}setSize(t,n){const[r,i]=this.renderable.values.uTexSize.ref.value;if(t!==r||n!==i){for(let o=0;o<2;o++)this.depthTextures[o].define(t,n),this.colorFrontTextures[o].define(t,n),this.colorBackTextures[o].define(t,n);k.update(this.renderable.values.uTexSize,Me.set(this.renderable.values.uTexSize.ref.value,t,n)),k.update(this.blendBackRenderable.values.uTexSize,Me.set(this.blendBackRenderable.values.uTexSize.ref.value,t,n))}}reset(){this._supported&&this._init()}_init(){const{extensions:{drawBuffers:t}}=this.webgl;for(let n=0;n<2;n++)this.depthFramebuffers[n].bind(),t.drawBuffers([t.COLOR_ATTACHMENT0,t.COLOR_ATTACHMENT1,t.COLOR_ATTACHMENT2]),this.colorFrontTextures[n].attachFramebuffer(this.depthFramebuffers[n],"color0"),this.colorBackTextures[n].attachFramebuffer(this.depthFramebuffers[n],"color1"),this.depthTextures[n].attachFramebuffer(this.depthFramebuffers[n],"color2"),this.colorFramebuffers[n].bind(),t.drawBuffers([t.COLOR_ATTACHMENT0,t.COLOR_ATTACHMENT1]),this.colorFrontTextures[n].attachFramebuffer(this.colorFramebuffers[n],"color0"),this.colorBackTextures[n].attachFramebuffer(this.colorFramebuffers[n],"color1")}static isSupported(t){const{extensions:{drawBuffers:n,textureFloat:r,colorBufferFloat:i,blendMinMax:o}}=t;if(r&&i&&n&&o)return!0;if(un){const s=[];r||s.push("textureFloat"),i||s.push("colorBufferFloat"),n||s.push("drawBuffers"),o||s.push("blendMinMax"),console.log(`Missing "${s.join('", "')}" extensions required for "dpoit"`)}return!1}constructor(t,n,r){if(this.webgl=t,this.DEPTH_CLEAR_VALUE=-99999,this.MAX_DEPTH=1,this.MIN_DEPTH=0,this.passCount=0,this._supported=!1,!O8.isSupported(t))return;const{resources:i,extensions:{colorBufferHalfFloat:o,textureHalfFloat:s}}=t;Wt(t.gl)?(this.depthTextures=[i.texture("image-float32","rg","float","nearest"),i.texture("image-float32","rg","float","nearest")],this.colorFrontTextures=o&&s?[i.texture("image-float16","rgba","fp16","nearest"),i.texture("image-float16","rgba","fp16","nearest")]:[i.texture("image-float32","rgba","float","nearest"),i.texture("image-float32","rgba","float","nearest")],this.colorBackTextures=o&&s?[i.texture("image-float16","rgba","fp16","nearest"),i.texture("image-float16","rgba","fp16","nearest")]:[i.texture("image-float32","rgba","float","nearest"),i.texture("image-float32","rgba","float","nearest")]):(this.depthTextures=[i.texture("image-float32","rgba","float","nearest"),i.texture("image-float32","rgba","float","nearest")],this.colorFrontTextures=[i.texture("image-float32","rgba","float","nearest"),i.texture("image-float32","rgba","float","nearest")],this.colorBackTextures=[i.texture("image-float32","rgba","float","nearest"),i.texture("image-float32","rgba","float","nearest")]),this.depthTextures[0].define(n,r),this.depthTextures[1].define(n,r),this.colorFrontTextures[0].define(n,r),this.colorFrontTextures[1].define(n,r),this.colorBackTextures[0].define(n,r),this.colorBackTextures[1].define(n,r),this.depthFramebuffers=[i.framebuffer(),i.framebuffer()],this.colorFramebuffers=[i.framebuffer(),i.framebuffer()],this.blendBackRenderable=function xrt(e,t){const n={..._o,tDpoitBackColor:k.create(t),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight()))},r={...vrt};return ji(zi(e,"triangles",_rt,r,n),n)}(t,this.colorBackTextures[0]),this.renderable=function wrt(e,t){const n={..._o,tDpoitFrontColor:k.create(t),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight()))},r={...Srt};return ji(zi(e,"triangles",Crt,r,n),n)}(t,this.colorFrontTextures[0]),this._supported=!0,this._init()}}const Eue={enabled:C.Boolean(!0),highlightEdgeColor:C.Color(st.darken(st.fromNormalizedRgb(1,.4,.6),1)),selectEdgeColor:C.Color(st.darken(st.fromNormalizedRgb(.2,1,.1),1)),edgeScale:C.Numeric(1,{min:1,max:3,step:1},{description:"Thickness of the edge."}),highlightEdgeStrength:C.Numeric(1,{min:0,max:1,step:.1}),selectEdgeStrength:C.Numeric(1,{min:0,max:1,step:.1}),ghostEdgeStrength:C.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:C.Numeric(1.5,{min:0,max:3,step:.1},{description:"Factor to multiply the inner edge color with - for added contrast."})};class Pue{static isEnabled(t){return t.enabled}constructor(t,n,r){this.webgl=t,this.depthTarget=t.createRenderTarget(n,r),this.maskTarget=t.createRenderTarget(n,r),this.edgesTarget=t.createRenderTarget(n,r),this.edge=function Ert(e,t){const n=t.getWidth(),r=t.getHeight(),i={..._o,tMaskTexture:k.create(t),uTexSizeInv:k.create(Me.create(1/n,1/r)),dEdgeScale:k.create(1)},o={...Trt};return ji(zi(e,"triangles",Drt,o,i),i)}(t,this.maskTarget.texture),this.overlay=function Rrt(e,t){const n=t.getWidth(),r=t.getHeight(),i={..._o,tEdgeTexture:k.create(t),uTexSizeInv:k.create(Me.create(1/n,1/r)),uHighlightEdgeColor:k.create(v()),uSelectEdgeColor:k.create(v()),uHighlightEdgeStrength:k.create(1),uSelectEdgeStrength:k.create(1),uGhostEdgeStrength:k.create(0),uInnerEdgeFactor:k.create(0)},o={...Prt};return ji(zi(e,"triangles",Mrt,o,i),i)}(t,this.edgesTarget.texture)}setEdgeState(t){const{gl:n,state:r}=this.webgl;r.enable(n.SCISSOR_TEST),r.enable(n.BLEND),r.blendFunc(n.ONE,n.ONE),r.blendEquation(n.FUNC_ADD),r.disable(n.DEPTH_TEST),r.depthMask(!1);const{x:i,y:o,width:s,height:a}=t;r.viewport(i,o,s,a),r.scissor(i,o,s,a),r.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT)}setOverlayState(t){const{gl:n,state:r}=this.webgl;r.enable(n.SCISSOR_TEST),r.enable(n.BLEND),r.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),r.blendEquation(n.FUNC_ADD),r.disable(n.DEPTH_TEST),r.depthMask(!1);const{x:i,y:o,width:s,height:a}=t;r.viewport(i,o,s,a),r.scissor(i,o,s,a)}setSize(t,n){const r=this.depthTarget.getWidth(),i=this.depthTarget.getHeight();(t!==r||n!==i)&&(this.depthTarget.setSize(t,n),this.maskTarget.setSize(t,n),this.edgesTarget.setSize(t,n),k.update(this.edge.values.uTexSizeInv,Me.set(this.edge.values.uTexSizeInv.ref.value,1/t,1/n)),k.update(this.overlay.values.uTexSizeInv,Me.set(this.overlay.values.uTexSizeInv.ref.value,1/t,1/n)))}update(t){const{highlightEdgeColor:n,selectEdgeColor:r,edgeScale:i,innerEdgeFactor:o,ghostEdgeStrength:s,highlightEdgeStrength:a,selectEdgeStrength:c}=t,{values:u}=this.edge,l=Math.max(1,Math.round(i*this.webgl.pixelRatio));u.dEdgeScale.ref.value!==l&&(k.update(u.dEdgeScale,l),this.edge.update());const{values:d}=this.overlay;k.update(d.uHighlightEdgeColor,st.toVec3Normalized(d.uHighlightEdgeColor.ref.value,n)),k.update(d.uSelectEdgeColor,st.toVec3Normalized(d.uSelectEdgeColor.ref.value,r)),k.updateIfChanged(d.uInnerEdgeFactor,o),k.updateIfChanged(d.uGhostEdgeStrength,s),k.updateIfChanged(d.uHighlightEdgeStrength,a),k.updateIfChanged(d.uSelectEdgeStrength,c)}render(t,n){lt&&this.webgl.timer.mark("MarkingPass.render"),this.edgesTarget.bind(),this.setEdgeState(t),this.edge.render(),n?n.bind():this.webgl.unbindFramebuffer(),this.setOverlayState(t),this.overlay.render(),lt&&this.webgl.timer.markEnd("MarkingPass.render")}}const Trt={...vo,tMaskTexture:jt("texture","rgba","ubyte","linear"),uTexSizeInv:xe("v2"),dEdgeScale:Ft("number")},Drt=Br("edge",ps,"\nprecision highp float;\nprecision highp sampler2D;\n\nuniform sampler2D tMaskTexture;\nuniform vec2 uTexSizeInv;\n\nvoid main() {\n vec2 coords = gl_FragCoord.xy * uTexSizeInv;\n vec4 offset = vec4(float(dEdgeScale), 0.0, 0.0, float(dEdgeScale)) * vec4(uTexSizeInv, uTexSizeInv);\n vec4 c0 = texture2D(tMaskTexture, coords);\n vec4 c1 = texture2D(tMaskTexture, coords + offset.xy);\n vec4 c2 = texture2D(tMaskTexture, coords - offset.xy);\n vec4 c3 = texture2D(tMaskTexture, coords + offset.yw);\n vec4 c4 = texture2D(tMaskTexture, coords - offset.yw);\n float diff1 = (c1.r - c2.r) * 0.5;\n float diff2 = (c3.r - c4.r) * 0.5;\n float d = length(vec2(diff1, diff2));\n if (d <= 0.0)\n discard;\n float a1 = min(c1.g, c2.g);\n float a2 = min(c3.g, c4.g);\n float visibility = min(a1, a2) > 0.001 ? 1.0 : 0.0;\n float mask = c0.r;\n float marker = min(c1.b, min(c2.b, min(c3.b, c4.b)));\n float fogAlpha = min(c1.a, min(c2.a, min(c3.a, c4.a)));\n gl_FragColor = vec4(visibility, mask, marker, fogAlpha);\n}\n"),Prt={...vo,tEdgeTexture:jt("texture","rgba","ubyte","linear"),uTexSizeInv:xe("v2"),uHighlightEdgeColor:xe("v3"),uSelectEdgeColor:xe("v3"),uHighlightEdgeStrength:xe("f"),uSelectEdgeStrength:xe("f"),uGhostEdgeStrength:xe("f"),uInnerEdgeFactor:xe("f")},Mrt=Br("overlay",ps,"\nprecision highp float;\nprecision highp sampler2D;\n\nuniform vec2 uTexSizeInv;\nuniform sampler2D tEdgeTexture;\nuniform vec3 uHighlightEdgeColor;\nuniform vec3 uSelectEdgeColor;\nuniform float uHighlightEdgeStrength;\nuniform float uSelectEdgeStrength;\nuniform float uGhostEdgeStrength;\nuniform float uInnerEdgeFactor;\n\nvoid main() {\n vec2 coords = gl_FragCoord.xy * uTexSizeInv;\n vec4 edgeValue = texture2D(tEdgeTexture, coords);\n if (edgeValue.a > 0.0) {\n vec3 edgeColor = edgeValue.b == 1.0 ? uHighlightEdgeColor : uSelectEdgeColor;\n gl_FragColor.rgb = edgeValue.g > 0.0 ? edgeColor : edgeColor * uInnerEdgeFactor;\n gl_FragColor.a = (edgeValue.r == 1.0 ? uGhostEdgeStrength : 1.0) * edgeValue.a;\n float edgeStrength = edgeValue.b == 1.0 ? uHighlightEdgeStrength : uSelectEdgeStrength;\n gl_FragColor.a *= edgeStrength;\n } else {\n gl_FragColor = vec4(0.0);\n }\n}\n");class Mue{setTransparency(t){this.transparencyMode="wboit"===t?this.wboit.supported?"wboit":"blended":"dpoit"===t&&this.dpoit.supported?"dpoit":"blended",this.depthTextureOpaque.detachFramebuffer(this.postprocessing.target.framebuffer,"depth")}get transparency(){return this.transparencyMode}constructor(t,n,r,i,o){this.webgl=t,this.transparencyMode="blended";const{extensions:s,resources:a,isWebGL2:c}=t;this.drawTarget=function v9e(e){return{id:kre(),texture:Os(e),framebuffer:{id:bre(),bind:()=>{},reset:()=>{},destroy:()=>{}},depthRenderbuffer:null,getWidth:()=>0,getHeight:()=>0,bind:()=>{e.bindFramebuffer(e.FRAMEBUFFER,null)},setSize:()=>{},reset:()=>{},destroy:()=>{}}}(t.gl),this.colorTarget=t.createRenderTarget(r,i,!0,"uint8","linear"),this.packedDepth=!s.depthTexture,this.depthTargetTransparent=t.createRenderTarget(r,i),this.depthTextureTransparent=this.depthTargetTransparent.texture,this.depthTargetOpaque=this.packedDepth?t.createRenderTarget(r,i):null,this.depthTextureOpaque=this.depthTargetOpaque?this.depthTargetOpaque.texture:a.texture("image-depth","depth",c?"float":"ushort","nearest"),this.packedDepth||this.depthTextureOpaque.define(r,i),this.wboit=new B8(t,r,i),this.dpoit=new O8(t,r,i),this.marking=new Pue(t,r,i),this.postprocessing=new uc(t,n,this),this.antialiasing=new k8(t,this),this.copyFboTarget=Iv(t,this.colorTarget.texture),this.copyFboPostprocessing=Iv(t,this.postprocessing.target.texture),this.setTransparency(o)}reset(){this.wboit.reset(),this.dpoit.reset()}setSize(t,n){const r=this.colorTarget.getWidth(),i=this.colorTarget.getHeight();(t!==r||n!==i)&&(this.colorTarget.setSize(t,n),this.depthTargetTransparent.setSize(t,n),this.depthTargetOpaque?this.depthTargetOpaque.setSize(t,n):this.depthTextureOpaque.define(t,n),k.update(this.copyFboTarget.values.uTexSize,Me.set(this.copyFboTarget.values.uTexSize.ref.value,t,n)),k.update(this.copyFboPostprocessing.values.uTexSize,Me.set(this.copyFboPostprocessing.values.uTexSize.ref.value,t,n))),this.wboit.supported&&this.wboit.setSize(t,n),this.dpoit.supported&&this.dpoit.setSize(t,n),this.marking.setSize(t,n),this.postprocessing.setSize(t,n),this.antialiasing.setSize(t,n)}_renderDpoit(t,n,r,i,o,s){if(!this.dpoit.supported)throw new Error("expected dpoit to be supported");if(this.depthTextureOpaque.attachFramebuffer(this.colorTarget.framebuffer,"depth"),t.clear(!0),r.hasOpaque&&t.renderDpoitOpaque(r.primitives,n,null),uc.isEnabled(s)&&(uc.isTransparentOutlineEnabled(s)&&(this.depthTargetTransparent.bind(),t.clearDepth(!0),r.opacityAverage<1&&t.renderDepthTransparent(r.primitives,n,this.depthTextureOpaque)),this.postprocessing.render(n,!1,o,t.props.backgroundColor,s,t.light)),this.depthTextureOpaque.detachFramebuffer(this.colorTarget.framebuffer,"depth"),r.opacityAverage<1){const a=uc.isEnabled(s)?this.postprocessing.target:this.colorTarget,c=this.dpoit.bind();t.renderDpoitTransparent(r.primitives,n,this.depthTextureOpaque,c);for(let u=0;u0&&t.renderDpoitVolume(r.volumes,n,this.depthTextureOpaque)}_renderWboit(t,n,r,i,o){if(!this.wboit.supported)throw new Error("expected wboit to be supported");this.depthTextureOpaque.attachFramebuffer(this.colorTarget.framebuffer,"depth"),t.clear(!0),r.hasOpaque&&t.renderWboitOpaque(r.primitives,n,null),uc.isEnabled(o)&&(uc.isTransparentOutlineEnabled(o)&&(this.depthTargetTransparent.bind(),t.clearDepth(!0),r.opacityAverage<1&&t.renderDepthTransparent(r.primitives,n,this.depthTextureOpaque)),this.postprocessing.render(n,!1,i,t.props.backgroundColor,o,t.light)),(r.opacityAverage<1||r.volumes.renderables.length>0)&&(this.wboit.bind(),r.opacityAverage<1&&t.renderWboitTransparent(r.primitives,n,this.depthTextureOpaque),r.volumes.renderables.length>0&&t.renderWboitTransparent(r.volumes,n,this.depthTextureOpaque),uc.isEnabled(o)?this.postprocessing.target.bind():this.colorTarget.bind(),this.wboit.render())}_renderBlended(t,n,r,i,o,s){var a,c,u,l;if(i?this.drawTarget.bind():this.packedDepth?this.colorTarget.bind():this.depthTextureOpaque.attachFramebuffer(this.colorTarget.framebuffer,"depth"),t.clear(!0),r.hasOpaque&&t.renderBlendedOpaque(r.primitives,n,null),!i&&(this.depthTargetOpaque&&(this.depthTargetOpaque.bind(),t.clearDepth(!0),t.renderDepthOpaque(r.primitives,n,null),this.colorTarget.bind()),uc.isEnabled(s)&&(this.packedDepth?null===(a=this.colorTarget.depthRenderbuffer)||void 0===a||a.detachFramebuffer(this.postprocessing.target.framebuffer):this.depthTextureOpaque.detachFramebuffer(this.postprocessing.target.framebuffer,"depth"),uc.isTransparentOutlineEnabled(s)&&(this.depthTargetTransparent.bind(),t.clearDepth(!0),r.opacityAverage<1&&t.renderDepthTransparent(r.primitives,n,this.depthTextureOpaque)),this.postprocessing.render(n,!1,o,t.props.backgroundColor,s,t.light),this.packedDepth?null===(c=this.colorTarget.depthRenderbuffer)||void 0===c||c.attachFramebuffer(this.postprocessing.target.framebuffer):this.depthTextureOpaque.attachFramebuffer(this.postprocessing.target.framebuffer,"depth")),r.volumes.renderables.length>0)){const d=uc.isEnabled(s)?this.postprocessing.target:this.colorTarget;this.packedDepth?null===(u=this.colorTarget.depthRenderbuffer)||void 0===u||u.detachFramebuffer(d.framebuffer):this.depthTextureOpaque.detachFramebuffer(d.framebuffer,"depth"),d.bind(),t.renderBlendedVolume(r.volumes,n,this.depthTextureOpaque),this.packedDepth?null===(l=this.colorTarget.depthRenderbuffer)||void 0===l||l.attachFramebuffer(d.framebuffer):this.depthTextureOpaque.attachFramebuffer(d.framebuffer,"depth"),d.bind()}r.opacityAverage<1&&t.renderBlendedTransparent(r.primitives,n,null)}_render(t,n,r,i,o,s,a){const c=r.volumes.renderables.length>0,u=uc.isEnabled(a.postprocessing),l=k8.isEnabled(a.postprocessing),d=Pue.isEnabled(a.marking),{x:f,y:p,width:m,height:h}=n.viewport;t.setViewport(f,p,m,h),t.update(n,r),s&&!l&&o&&(this.drawTarget.bind(),t.clear(!1));let g=!1;"wboit"===this.transparencyMode&&this.wboit.supported?(this._renderWboit(t,n,r,s,a.postprocessing),g=!0):"dpoit"===this.transparencyMode&&this.dpoit.supported?(this._renderDpoit(t,n,r,a.dpoitIterations,s,a.postprocessing),g=!0):this._renderBlended(t,n,r,!c&&!u&&!l&&o,s,a.postprocessing);const y=u?this.postprocessing.target:!o||c||g?this.colorTarget:this.drawTarget;if(d&&r.markerAverage>0){const b=a.marking.ghostEdgeStrength<1;b&&1!==r.markerAverage&&(this.marking.depthTarget.bind(),t.clear(!1,!0),t.renderMarkingDepth(r.primitives,n,null)),this.marking.maskTarget.bind(),t.clear(!1,!0),t.renderMarkingMask(r.primitives,n,b?this.marking.depthTarget.texture:null),this.marking.update(a.marking),this.marking.render(n.viewport,y)}else y.bind();i.debug.isEnabled&&(i.debug.syncVisibility(),t.renderBlended(i.debug.scene,n)),i.handle.isEnabled&&t.renderBlended(i.handle.scene,n),i.camera.isEnabled&&(i.camera.update(n),t.update(i.camera.camera,i.camera.scene),t.renderBlended(i.camera.scene,i.camera.camera)),l?this.antialiasing.render(n,o,a.postprocessing):o&&(this.drawTarget.bind(),this.webgl.state.disable(this.webgl.gl.DEPTH_TEST),u?this.copyFboPostprocessing.render():(c||g)&&this.copyFboTarget.render()),this.webgl.gl.flush()}render(t,n,r){lt&&this.webgl.timer.mark("DrawPass.render");const{renderer:i,camera:o,scene:s,helper:a}=t;this.postprocessing.setTransparentBackground(n.transparentBackground);const c=n.transparentBackground||this.postprocessing.background.isEnabled(n.postprocessing.background);i.setTransparentBackground(c),i.setDrawingBufferSize(this.colorTarget.getWidth(),this.colorTarget.getHeight()),i.setPixelRatio(this.webgl.pixelRatio),Yv.is(o)?(lt&&this.webgl.timer.mark("StereoCamera.left"),this._render(i,o.left,s,a,r,c,n),lt&&this.webgl.timer.markEnd("StereoCamera.left"),lt&&this.webgl.timer.mark("StereoCamera.right"),this._render(i,o.right,s,a,r,c,n),lt&&this.webgl.timer.markEnd("StereoCamera.right")):this._render(i,o,s,a,r,c,n),lt&&this.webgl.timer.markEnd("DrawPass.render")}getColorTarget(t){return k8.isEnabled(t)?this.antialiasing.target:uc.isEnabled(t)?this.postprocessing.target:this.colorTarget}}const krt={alpha:C.Numeric(.51,{min:0,max:1,step:.01},{isEssential:!0,label:"Opacity"}),colorX:C.Color(xn.red,{isEssential:!0}),colorY:C.Color(xn.green,{isEssential:!0}),colorZ:C.Color(xn.blue,{isEssential:!0}),scale:C.Numeric(.33,{min:.1,max:2,step:.1},{isEssential:!0}),location:C.Select("bottom-left",C.arrayToOptions(["bottom-left","bottom-right","top-left","top-right"])),locationOffsetX:C.Numeric(0),locationOffsetY:C.Numeric(0),originColor:C.Color(xn.grey),radiusScale:C.Numeric(.075,{min:.01,max:.3,step:.001}),showPlanes:C.Boolean(!0),planeColorXY:C.Color(xn.grey,{label:"Plane Color XY"}),planeColorXZ:C.Color(xn.grey,{label:"Plane Color XZ"}),planeColorYZ:C.Color(xn.grey,{label:"Plane Color YZ"}),showLabels:C.Boolean(!1),labelX:C.Text("X"),labelY:C.Text("Y"),labelZ:C.Text("Z"),labelColorX:C.Color(xn.grey),labelColorY:C.Color(xn.grey),labelColorZ:C.Color(xn.grey),labelOpacity:C.Numeric(1,{min:0,max:1,step:.01}),labelScale:C.Numeric(.25,{min:.1,max:1,step:.01})},DE={axes:C.MappedStatic("on",{on:C.Group(krt),off:C.Group({})},{cycle:!0,description:"Show camera orientation axes"})};class Rue{constructor(t,n={}){this.webgl=t,this.props={axes:{name:"off",params:{}}},this.pixelRatio=1,this.eachGroup=(r,i)=>{if(!L8(r))return!1;let o=!1;if(this.meshRenderObject){const s=this.meshRenderObject.values.uGroupCount.ref.value;for(const{groupId:a,instanceId:c}of r.elements)i(Ce.ofSingleton(c*s+a))&&(o=!0)}if(this.textRenderObject){const s=this.textRenderObject.values.uGroupCount.ref.value;for(const{groupId:a,instanceId:c}of r.elements)i(Ce.ofSingleton(c*s+a))&&(o=!0)}return o},this.scene=Wv.create(t,"blended"),this.camera=new gr,v.set(this.camera.up,0,1,0),v.set(this.camera.target,0,0,0),this.setProps(n)}setProps(t){this.props=c0(this.props,n=>{if(void 0!==t.axes&&(n.axes.name=t.axes.name,"on"===t.axes.name)){this.scene.clear(),this.pixelRatio=this.webgl.pixelRatio;const r={...t.axes.params,scale:t.axes.params.scale*this.pixelRatio,labelScale:t.axes.params.labelScale*this.pixelRatio};this.meshRenderObject=function Urt(e){const t=function Lrt(e,t){const n=100*e.scale,r=function Ort(e,t){const n=at.createState(512,256,t),r=100*e.scale,i=e.radiusScale*r,o=e.showLabels?100*e.labelScale/3:0,s=v.scale(v(),v.unitX,r-o),a=v.scale(v(),v.unitY,r-o),c=v.scale(v(),v.unitZ,r-o),u={radiusTop:i,radiusBottom:i,radialSegments:32};if(n.currentGroup=Cr.Origin,Zn(n,v.origin,i,2),n.currentGroup=Cr.X,Zn(n,s,i,2),Hn(n,v.origin,s,1,u),n.currentGroup=Cr.Y,Zn(n,a,i,2),Hn(n,v.origin,a,1,u),n.currentGroup=Cr.Z,Zn(n,c,i,2),Hn(n,v.origin,c,1,u),e.showPlanes){v.scale(s,s,.5),v.scale(a,a,.5),v.scale(c,c,.5),n.currentGroup=Cr.XY,at.addTriangle(n,v.origin,s,a),at.addTriangle(n,v.origin,a,s);const l=v.add(v(),s,a);at.addTriangle(n,l,s,a),at.addTriangle(n,l,a,s),n.currentGroup=Cr.XZ,at.addTriangle(n,v.origin,s,c),at.addTriangle(n,v.origin,c,s);const d=v.add(v(),s,c);at.addTriangle(n,d,s,c),at.addTriangle(n,d,c,s),n.currentGroup=Cr.YZ,at.addTriangle(n,v.origin,a,c),at.addTriangle(n,v.origin,c,a);const f=v.add(v(),a,c);at.addTriangle(n,f,a,c),at.addTriangle(n,f,c,a)}return at.getMesh(n)}(e,t?.geometry);r.setBoundingSphere(_e.create(v.create(n/2,n/2,n/2),n+n/4));return qn.create("axes-mesh",{},r,o=>{switch(o){case Cr.X:return e.colorX;case Cr.Y:return e.colorY;case Cr.Z:return e.colorZ;case Cr.XY:return e.planeColorXY;case Cr.XZ:return e.planeColorXZ;case Cr.YZ:return e.planeColorYZ;case Cr.Origin:return e.originColor;default:return xn.grey}},()=>1,()=>"")}(e);return qn.createRenderObject(t,{...C.getDefaultValues(Nt.Params),...e,ignoreLight:!0,cellSize:0})}(r),this.scene.add(this.meshRenderObject),t.axes.params.showLabels?(this.textRenderObject=function Grt(e){const t=function zrt(e,t){const n=100*e.scale,r=function Vrt(e,t){const n=wf.create(e,8,8,t),r=100*e.scale,i=v.scale(v(),v.unitX,r),o=v.scale(v(),v.unitY,r),s=v.scale(v(),v.unitZ,r),a=100*e.labelScale;return n.add(e.labelX,i[0],i[1],i[2],0,a,Cr.X),n.add(e.labelY,o[0],o[1],o[2],0,a,Cr.Y),n.add(e.labelZ,s[0],s[1],s[2],0,a,Cr.Z),n.getText()}(e,t?.geometry);r.setBoundingSphere(_e.create(v.create(n/2,n/2,n/2),n));return qn.create("axes-text",{},r,o=>{switch(o){case Cr.X:return e.labelColorX;case Cr.Y:return e.labelColorY;case Cr.Z:return e.labelColorZ;default:return xn.grey}},()=>1,()=>"")}(e);return qn.createRenderObject(t,{...C.getDefaultValues(vu.Params),...e,alpha:e.labelOpacity,cellSize:0})}(r),this.scene.add(this.textRenderObject)):this.textRenderObject=void 0,this.scene.commit(),v.set(this.camera.position,0,0,200*r.scale),le.lookAt(this.camera.view,this.camera.position,this.camera.target,this.camera.up),n.axes.params={...t.axes.params}}})}get isEnabled(){return"on"===this.props.axes.name}getLoci(t){const{objectId:n,groupId:r,instanceId:i}=t;return(this.meshRenderObject&&n===this.meshRenderObject.id||this.textRenderObject&&n===this.textRenderObject.id)&&r!==Cr.None?function Frt(e,t,n){return nE("camera-axes",e,[{groupId:t,instanceId:n}],void 0,()=>function Nrt(e,t){const n=t.props.axes,r="on"===n.name?n.params.labelX:"X",i="on"===n.name?n.params.labelY:"Y",o="on"===n.name?n.params.labelZ:"Z";switch(e){case Cr.X:return`${r} Axis`;case Cr.Y:return`${i} Axis`;case Cr.Z:return`${o} Axis`;case Cr.XY:return`${r}${i} Plane`;case Cr.XZ:return`${r}${o} Plane`;case Cr.YZ:return`${i}${o} Plane`;case Cr.Origin:return"Origin";default:return"Axes"}}(t,e))}(this,r,i):$n}mark(t,n){return!(!Us.is(Us.Highlighting,n)||!(Uc(t)||L8(t)&&t.data===this))&&(Sn.mark(this.meshRenderObject,t,n,this.eachGroup)||Sn.mark(this.textRenderObject,t,n,this.eachGroup))}update(t){if(!this.meshRenderObject||"off"===this.props.axes.name)return;this.pixelRatio!==this.webgl.pixelRatio&&this.setProps(this.props),function Brt(e,t,n){const{near:r,far:i}=e,o=-t.width/2,s=t.width/2,a=t.height/2,c=-t.height/2,u=(s-o)/2,l=(a-c)/2,d=(s+o)/2,f=(a+c)/2;let p=d-u,m=d+u,h=f+l,g=f-l;if(n.enabled){const y=(s-o)/n.width,b=(a-c)/n.height;p+=y*n.offsetX,m=p+y*n.width,h-=b*n.offsetY,g=h-b*n.height}le.ortho(e.projection,p,m,h,g,r,i)}(this.camera,t.viewport,t.viewOffset),le.extractRotation(this.scene.view,t.view);const n=this.textRenderObject?this.textRenderObject.values.boundingSphere.ref.value.radius:this.meshRenderObject.values.boundingSphere.ref.value.radius,r=this.props.axes.params.location,i=this.props.axes.params.locationOffsetX*this.pixelRatio,o=this.props.axes.params.locationOffsetY*this.pixelRatio;"bottom-left"===r?le.setTranslation(this.scene.view,v.create(-t.viewport.width/2+n+i,-t.viewport.height/2+n+o,0)):"bottom-right"===r?le.setTranslation(this.scene.view,v.create(t.viewport.width/2-n-i,-t.viewport.height/2+n+o,0)):"top-left"===r?le.setTranslation(this.scene.view,v.create(-t.viewport.width/2+n+i,t.viewport.height/2-n-o,0)):"top-right"===r?le.setTranslation(this.scene.view,v.create(t.viewport.width/2-n-i,t.viewport.height/2-n-o,0)):Rr()}}var Cr=function(e){return e[e.None=0]="None",e[e.X=1]="X",e[e.Y=2]="Y",e[e.Z=3]="Z",e[e.XY=4]="XY",e[e.XZ=5]="XZ",e[e.YZ=6]="YZ",e[e.Origin=7]="Origin",e}(Cr||{});function L8(e){return"data-loci"===e.kind&&"camera-axes"===e.tag}const jrt={transparentBackground:C.Boolean(!1),dpoitIterations:C.Numeric(2,{min:1,max:10,step:1}),multiSample:C.Group(Cue),postprocessing:C.Group(Sue),marking:C.Group(Eue),cameraHelper:C.Group(DE)};class Hrt{get colorTarget(){return this._colorTarget}get width(){return this._width}get height(){return this._height}constructor(t,n,r,i,o,s,a,c){this.webgl=t,this.renderer=r,this.scene=i,this.camera=o,this._width=0,this._height=0,this._camera=new gr,this.props={...C.getDefaultValues(jrt),...c},this.drawPass=new Mue(t,n,128,128,a),this.multiSamplePass=new TE(t,this.drawPass),this.multiSampleHelper=new wue(this.multiSamplePass),this.helper={camera:new Rue(t,this.props.cameraHelper),debug:s.debug,handle:s.handle},this.setSize(1024,768)}updateBackground(){return new Promise(t=>{this.drawPass.postprocessing.background.update(this.camera,this.props.postprocessing.background,()=>{t()})})}setSize(t,n){t===this._width&&n===this._height||(this._width=t,this._height=n,this.drawPass.setSize(t,n),this.multiSamplePass.syncSize())}setProps(t={}){Object.assign(this.props,t),t.cameraHelper&&this.helper.camera.setProps(t.cameraHelper)}render(){gr.copySnapshot(this._camera.state,this.camera.state),Lo.set(this._camera.viewport,0,0,this._width,this._height),this._camera.update();const t={renderer:this.renderer,camera:this._camera,scene:this.scene,helper:this.helper};TE.isEnabled(this.props.multiSample)?(this.multiSampleHelper.render(t,this.props,!1),this._colorTarget=this.multiSamplePass.colorTarget):(this.drawPass.render(t,this.props,!1),this._colorTarget=this.drawPass.getColorTarget(this.props.postprocessing))}getImageData(t,n,r){var i,o;this.setSize(t,n),this.render(),this.colorTarget.bind();const s=null!==(i=r?.width)&&void 0!==i?i:t,a=null!==(o=r?.height)&&void 0!==o?o:n,c=new Uint8Array(s*a*4);r?this.webgl.readPixels(r.x,n-r.y-r.height,s,a,c):this.webgl.readPixels(0,0,s,a,c);const u=d0.create(c,s,a);return d0.flipY(u),d0.divideByAlpha(u),new ImageData(new Uint8ClampedArray(c),s,a)}}const qrt={...Nt.Params,alpha:{...Nt.Params.alpha,defaultValue:1},ignoreLight:{...Nt.Params.ignoreLight,defaultValue:!0},colorX:C.Color(xn.red,{isEssential:!0}),colorY:C.Color(xn.green,{isEssential:!0}),colorZ:C.Color(xn.blue,{isEssential:!0}),scale:C.Numeric(.33,{min:.1,max:2,step:.1},{isEssential:!0})},kue={handle:C.MappedStatic("off",{on:C.Group(qrt),off:C.Group({})},{cycle:!0,description:"Show handle tool"})};class Wrt{getBoundingSphere(t,n){return this.renderObject&&(_e.copy(t,this.renderObject.values.invariantBoundingSphere.ref.value),le.fromArray(this._transform,this.renderObject.values.aTransform.ref.value,16*n),_e.transform(t,t,this._transform)),t}setProps(t){this.props=c0(this.props,n=>{if(void 0!==t.handle&&(n.handle.name=t.handle.name,"on"===t.handle.name)){this.scene.clear(),this.pixelRatio=this.webgl.pixelRatio;const r={...t.handle.params,scale:t.handle.params.scale*this.webgl.pixelRatio,cellSize:0};this.renderObject=function Krt(e){const t=function Xrt(e,t){const n=10*e.scale,r=function $rt(e,t){const n=at.createState(512,256,t),r=.05*e,i=v.scale(v(),v.unitX,e),o=v.scale(v(),v.unitY,e),s=v.scale(v(),v.unitZ,e),a={radiusTop:r,radiusBottom:r,radialSegments:32};return n.currentGroup=P0.TranslateScreenXY,Zn(n,v.origin,3*r,2),n.currentGroup=P0.TranslateObjectX,Zn(n,i,r,2),Hn(n,v.origin,i,1,a),n.currentGroup=P0.TranslateObjectY,Zn(n,o,r,2),Hn(n,v.origin,o,1,a),n.currentGroup=P0.TranslateObjectZ,Zn(n,s,r,2),Hn(n,v.origin,s,1,a),at.getMesh(n)}(n,t?.geometry);r.setBoundingSphere(_e.create(v.create(n/2,n/2,n/2),n+n/4));return qn.create("handle",{},r,o=>{switch(o){case P0.TranslateObjectX:return e.colorX;case P0.TranslateObjectY:return e.colorY;case P0.TranslateObjectZ:return e.colorZ;default:return xn.grey}},()=>1,()=>"")}(e);return qn.createRenderObject(t,e)}(r),this.scene.add(this.renderObject),this.scene.commit(),n.handle.params={...t.handle.params}}})}get isEnabled(){return"on"===this.props.handle.name}update(t,n,r){this.renderObject&&(this.pixelRatio!==this.webgl.pixelRatio&&this.setProps(this.props),le.setTranslation(this.renderObject.values.aTransform.ref.value,n),le.fromMat3(this.renderObject.values.aTransform.ref.value,r),k.update(this.renderObject.values.aTransform,this.renderObject.values.aTransform.ref.value),this.scene.update([this.renderObject],!0))}getLoci(t){const{objectId:n,groupId:r,instanceId:i}=t;return this.renderObject&&n===this.renderObject.id?function Yrt(e,t,n){return nE("handle",e,[{groupId:t,instanceId:n}],r=>e.getBoundingSphere(r,n),()=>`Handle Helper | Group Id ${t} | Instance Id ${n}`)}(this,r,i):$n}mark(t,n){return!(!Us.is(Us.Highlighting,n)||!(Uc(t)||Nue(t)&&t.data===this))&&Sn.mark(this.renderObject,t,n,this.eachGroup)}constructor(t,n={}){this.webgl=t,this.props={handle:{name:"off",params:{}}},this.pixelRatio=1,this._transform=le(),this.eachGroup=(r,i)=>{if(!this.renderObject||!Nue(r))return!1;let o=!1;const s=this.renderObject.values.uGroupCount.ref.value,{elements:a}=r;for(const{groupId:c,instanceId:u}of a)i(Ce.ofSingleton(u*s+c))&&(o=!0);return o},this.scene=Wv.create(t,"blended"),this.setProps(n)}}const P0={None:0,TranslateScreenXY:1,TranslateObjectX:3,TranslateObjectY:4,TranslateObjectZ:5};function Nue(e){return"data-loci"===e.kind&&"handle"===e.tag}const Zrt={debug:C.Group(P8),camera:C.Group({helper:C.Group(DE)}),handle:C.Group(kue)},Qrt=C.getDefaultValues(Zrt);class Jrt{constructor(t,n,r={}){const i={...Qrt,...r};this.debug=new Gtt(t,n,i.debug),this.camera=new Rue(t,i.camera.helper),this.handle=new Wrt(t,i.handle)}}class eit{constructor(t,n,r={}){this.webgl=t;const{gl:i}=t;this.draw=new Mue(t,n,i.drawingBufferWidth,i.drawingBufferHeight,r.transparency||"blended"),this.pick=new drt(t,this.draw,r.pickScale||.25),this.multiSample=new TE(t,this.draw)}setPickScale(t){this.pick.setPickScale(t)}setTransparency(t){this.draw.setTransparency(t)}updateSize(){const{gl:t}=this.webgl,n=Math.max(t.drawingBufferWidth,2),r=Math.max(t.drawingBufferHeight,2);this.draw.setSize(n,r),this.pick.syncSize(),this.multiSample.syncSize()}}const nit={...vo,tPreviousLevel:jt("texture","alpha","float","nearest"),uInvSize:xe("v2"),uOffset:xe("v2")},rit=Br("hi-z",ps,"\nprecision highp float;\nprecision highp sampler2D;\n\nuniform sampler2D tPreviousLevel;\nuniform vec2 uInvSize;\nuniform vec2 uOffset;\n\nvoid main(void) {\n vec2 position = gl_FragCoord.xy * uInvSize + uOffset;\n\n float x = texture(tPreviousLevel, position).r;\n float y = textureOffset(tPreviousLevel, position, ivec2(-1, 0)).r;\n float z = textureOffset(tPreviousLevel, position, ivec2(-1, -1)).r;\n float w = textureOffset(tPreviousLevel, position, ivec2(0, -1)).r;\n\n gl_FragColor = vec4(max(max(x, y), max(z, w)));\n}\n"),Fue=new ArrayBuffer(4);new Int32Array(Fue),new Float32Array(Fue);const Bue=new ArrayBuffer(4),cit=new Int32Array(Bue),uit=new Float32Array(Bue);function Xv(e){return function lit(e){return cit[0]=(1<<23)*((e<-126?-126:e)+126.94269504),uit[0]}(1.44269504*e)}const Oue=new ArrayBuffer(8);new Int32Array(Oue),new Float32Array(Oue);const Uue=new ArrayBuffer(4),dit=new Int32Array(Uue),fit=new Float32Array(Uue);Math,Math,Math,Math,Math,Math,Math,Math,Math;const Gue=new ArrayBuffer(16);new Int32Array(Gue),new Float32Array(Gue);const jue=new ArrayBuffer(8);new Int32Array(jue),new Float32Array(jue);const que=new ArrayBuffer(4);new Int32Array(que),new Float32Array(que),Math;const Ait=v.transformMat4,$ue=nn.set,Iit=function z8(e){return fit[0]=e,1.1920928955078125e-7*dit[0]-126.94269504};function RE(e,t,n,r){return-1===r[11]?function Tit(e,t,n){return t*n/((n-t)*e-n)}(e,t,n):function Dit(e,t,n){return e*(t-n)-t}(e,t,n)}const Yue={enabled:C.Boolean(!1,{description:"Hierarchical Z-buffer occlusion culling. Only available for WebGL2."}),maxFrameLag:C.Numeric(10,{min:1,max:30,step:1},{description:"Maximum number of frames to wait for Z-buffer data."}),minLevel:C.Numeric(3,{min:1,max:10,step:1})};class Rit{clear(){if(!this.supported)return;const{gl:t}=this.webgl;Wt(t)&&(null!==this.sync&&(t.deleteSync(this.sync),this.sync=null),this.frameLag=0,this.ready=!1,this.debug&&(this.debug.rect.style.display="none",this.debug.container.style.display="none"))}render(t){if(!this.supported||!this.props.enabled)return;const{gl:n,state:r}=this.webgl;if(!Wt(n)||null!==this.sync)return;this.nextNear=t.near,this.nextFar=t.far,le.copy(this.nextView,t.view),le.copy(this.nextProjection,t.projection),lt&&this.webgl.timer.mark("hi-Z"),r.disable(n.CULL_FACE),r.disable(n.BLEND),r.disable(n.DEPTH_TEST),r.disable(n.SCISSOR_TEST),r.depthMask(!1),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0);const i=this.renderable.values,o=Math.pow(2,Math.ceil(Math.log(Math.max(n.drawingBufferWidth,n.drawingBufferHeight))/Math.log(2))-1);for(let c=0,u=this.levelData.length;c0?(k.update(i.uInvSize,l.invSize),k.update(i.uOffset,Me.set(i.uOffset.ref.value,0,0)),k.update(i.tPreviousLevel,this.levelData[c-1].texture)):(k.update(i.uInvSize,Me.set(i.uInvSize.ref.value,1/o,1/o)),k.update(i.uOffset,Me.set(i.uOffset.ref.value,this.viewport.x/n.drawingBufferWidth,this.viewport.y/n.drawingBufferHeight)),k.update(i.tPreviousLevel,this.drawPass.depthTextureOpaque)),r.currentRenderItemId=-1,r.viewport(0,0,l.size[0],l.size[1]),n.clear(n.COLOR_BUFFER_BIT),this.renderable.update(),this.renderable.render(),c>=this.props.minLevel&&(this.tex.bind(0),n.copyTexSubImage2D(n.TEXTURE_2D,0,l.offset,0,0,0,l.size[0],l.size[1]),this.tex.unbind(0))}this.tex.attachFramebuffer(this.fb,0);const s=this.tex.getWidth(),a=this.tex.getHeight();n.bindBuffer(n.PIXEL_PACK_BUFFER,this.buf),n.bufferData(n.PIXEL_PACK_BUFFER,this.buffer.byteLength,n.STREAM_READ),n.readPixels(0,0,s,a,n.RED,n.FLOAT,0),n.bindBuffer(n.PIXEL_PACK_BUFFER,null),this.sync=n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE,0),n.flush(),lt&&this.webgl.timer.markEnd("hi-Z")}tick(){if(!this.supported||!this.props.enabled||null===this.sync)return;const{gl:t}=this.webgl;if(!Wt(t))return;const n=t.clientWaitSync(this.sync,0,0);n===t.WAIT_FAILED||this.frameLag>=this.props.maxFrameLag?(t.deleteSync(this.sync),this.sync=null,this.frameLag=0,this.ready=!1):n===t.TIMEOUT_EXPIRED?this.frameLag+=1:(t.bindBuffer(t.PIXEL_PACK_BUFFER,this.buf),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this.buffer),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),t.deleteSync(this.sync),this.sync=null,this.frameLag=0,this.ready=!0,this.near=this.nextNear,this.far=this.nextFar,le.copy(this.view,this.nextView),le.copy(this.projection,this.nextProjection))}transform(t){const{view:n,vp:r}=this;return Ait(r,t.center,n),{vp:r,r:1.2*t.radius+1.52}}project(t,n){const{projection:r,aabb:i,viewport:o}=this;!function Mit(e,t,n,r){return-1===r[11]?function Eit(e,t,n,r){const i=t[0]*n,o=t[1]*n,s=t[2]*n,a=t[2]*t[2]-n*n,c=Math.sqrt(t[0]*t[0]+a),u=(c*t[0]-s)/(c*t[2]+i)*r[0],l=(c*t[0]+s)/(c*t[2]-i)*r[0],d=Math.sqrt(t[1]*t[1]+a);return $ue(e,-.5*l+.5,(d*t[1]-s)/(d*t[2]+o)*r[5]*.5+.5,-.5*u+.5,(d*t[1]+s)/(d*t[2]-o)*r[5]*.5+.5)}(e,t,n,r):function Pit(e,t,n,r){const i=r[0],o=r[5];return $ue(e,(t[0]-n)*i*.5+.5,(t[1]+n)*o*-.5+.5,(t[0]+n)*i*.5+.5,(t[1]-n)*o*-.5+.5)}(e,t,n,r)}(i,t,n,r);const s=i[2]-i[0],a=i[3]-i[1],c=Math.max(s*o.width,a*o.height);return{aabb:i,w:s,h:a,pr:c,lod:Math.ceil(Iit(c/2))}}setViewport(t,n,r,i){if(!this.supported)return;r=Math.max(r,2),i=Math.max(i,2),Lo.set(this.viewport,t,n,r,i);const o=Math.ceil(Math.log(Math.max(r,i))/Math.log(2));if(o===this.levelData.length)return;const{minLevel:s}=this.props;this.buffer=new Float32Array(Math.pow(2,o-s)*Math.pow(2,o-1-s)),this.tex.define(Math.pow(2,o-s),Math.pow(2,o-1-s));for(const c of this.levelData)c.framebuffer.destroy(),c.texture.destroy();this.levelData.length=0;for(let c=0;c=s&&(this.levelData[c].offset=a,a+=l.size[0])}this.clear()}setProps(t){if(this.supported)if(this.props.minLevel!==t.minLevel){Object.assign(this.props,t);const{x:n,y:r,width:i,height:o}=this.viewport;this.setViewport(n,r,i,o)}else Object.assign(this.props,t),this.props.enabled||this.clear()}initDebug(t){if(!t.parentElement)return;const n=document.createElement("div");Object.assign(n.style,{display:"block",position:"absolute",pointerEvents:"none"}),t.parentElement.appendChild(n);const r=document.createElement("canvas"),i=r.getContext("2d");if(!i)throw new Error("Could not create canvas 2d context");Object.assign(r.style,{width:"100%",height:"100%",imageRendering:"pixelated",position:"relative",pointerEvents:"none"}),n.appendChild(r);const o=document.createElement("div");Object.assign(o.style,{display:"none",position:"absolute",pointerEvents:"none"}),t.parentElement.appendChild(o),this.debug={container:n,canvas:r,ctx:i,rect:o}}canDebug(t){return this.supported&&this.props.enabled&&this.ready&&!!this.debug}showRect(t,n){if(!this.canDebug(this.debug))return;const{gl:{drawingBufferHeight:r},pixelRatio:i}=this.webgl,{viewport:{x:o,y:s,width:a,height:c}}=this,u=(t[0]*a+o)/i,l=(t[1]*c-s)/i;Object.assign(this.debug.rect.style,{border:n?"solid red":"solid green",display:"block",left:`${u}px`,top:`${l+(r-c)/i}px`,width:(t[2]*a+o)/i-u+"px",height:(t[3]*c-s)/i-l+"px"})}showBuffer(t){if(!this.canDebug(this.debug))return;if(t>=this.levelData.length||t{if(!this.supported||!this.props.enabled||!this.ready)return!1;const{vp:l,r:d}=this.transform(u),{near:f,far:p,projection:m}=this,h=l[2]+d;if(-h=this.levelData.length||x=w||T+1>=w)return!1;const N=(w-T-1)*M+R+_;if(h>RE(this.buffer[N],f,p,m)||h>RE(this.buffer[N+1],f,p,m))return!1;const V=(w-T+1-1)*M+R+_;return!(h>RE(this.buffer[V],f,p,m)||h>RE(this.buffer[V+1],f,p,m))};const{gl:o,extensions:s}=t;if(!Wt(o)||!s.colorBufferFloat)return un&&console.log('Missing webgl2 and/or colorBufferFloat support required for "Hi-Z"'),void(this.supported=!1);this.fb=t.resources.framebuffer(),this.tex=t.resources.texture("image-float32","alpha","float","nearest"),this.tex.attachFramebuffer(this.fb,0);const a=o.getParameter(o.IMPLEMENTATION_COLOR_READ_FORMAT),c=o.getParameter(o.IMPLEMENTATION_COLOR_READ_TYPE);if(a!==o.RED||c!==o.FLOAT)return un&&console.log('Missing red/float reading support required for "Hi-Z"'),void(this.supported=!1);this.supported=!0,this.props={...C.getDefaultValues(Yue),...i},this.buf=$L(o),this.renderable=function iit(e,t){const n={..._o,tPreviousLevel:k.create(t),uInvSize:k.create(Me()),uOffset:k.create(Me())},r={...nit};return ji(zi(e,"triangles",rit,r,n),n)}(t,this.drawPass.depthTextureOpaque),un&&r&&this.initDebug(r)}}const Xue={camera:C.Group({mode:C.Select("perspective",C.arrayToOptions(["perspective","orthographic"]),{label:"Camera"}),helper:C.Group(DE,{isFlat:!0}),stereo:C.MappedStatic("off",{on:C.Group(Aue),off:C.Group({})},{cycle:!0,hideIf:e=>"perspective"!==e?.mode}),fov:C.Numeric(45,{min:10,max:130,step:1},{label:"Field of View"}),manualReset:C.Boolean(!1,{isHidden:!0})},{pivot:"mode"}),cameraFog:C.MappedStatic("on",{on:C.Group({intensity:C.Numeric(15,{min:1,max:100,step:1})}),off:C.Group({})},{cycle:!0,description:"Show fog in the distance"}),cameraClipping:C.Group({radius:C.Numeric(100,{min:0,max:99,step:1},{label:"Clipping",description:"How much of the scene to show."}),far:C.Boolean(!0,{description:"Hide scene in the distance"}),minNear:C.Numeric(5,{min:.1,max:100,step:.1},{description:"Note, may cause performance issues rendering impostors when set too small and cause issues with outline rendering when too close to 0."})},{pivot:"radius"}),viewport:C.MappedStatic("canvas",{canvas:C.Group({}),"static-frame":C.Group({x:C.Numeric(0),y:C.Numeric(0),width:C.Numeric(128),height:C.Numeric(128)}),"relative-frame":C.Group({x:C.Numeric(.33,{min:0,max:1,step:.01}),y:C.Numeric(.33,{min:0,max:1,step:.01}),width:C.Numeric(.5,{min:.01,max:1,step:.01}),height:C.Numeric(.5,{min:.01,max:1,step:.01})})}),cameraResetDurationMs:C.Numeric(250,{min:0,max:1e3,step:1},{description:"The time it takes to reset the camera."}),sceneRadiusFactor:C.Numeric(1,{min:1,max:10,step:.1}),transparentBackground:C.Boolean(!1),dpoitIterations:C.Numeric(2,{min:1,max:10,step:1}),pickPadding:C.Numeric(3,{min:0,max:10,step:1},{description:"extra pixels to around target to check in case target is empty"}),multiSample:C.Group(Cue),postprocessing:C.Group(Sue),marking:C.Group(Eue),hiZ:C.Group(Yue),renderer:C.Group(I8),trackball:C.Group(cue),interaction:C.Group(pue),debug:C.Group(P8),handle:C.Group(kue)},H8=C.getDefaultValues(Xue);var kE;!function(e){e.DefaultAttribs={powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,antialias:!0,preserveDrawingBuffer:!0,preferWebGl1:!1,handleResize:()=>{}},e.Params={pixelScale:C.Numeric(1,{min:.1,max:2,step:.05}),pickScale:C.Numeric(.25,{min:.1,max:1,step:.05}),transparency:C.Select("wboit",[["blended","Blended"],["wboit","Weighted, Blended"],["dpoit","Depth Peeling"]])},e.DefaultProps=C.getDefaultValues(e.Params),e.fromCanvas=function t(n,r,i={},o={}){const s={...e.DefaultAttribs,...i},a={...e.DefaultProps,...o},{powerPreference:c,failIfMajorPerformanceCaveat:u,antialias:l,preserveDrawingBuffer:d,preferWebGl1:f}=s,p=function A9e(e,t){function n(i){try{return e.getContext(i,t)}catch{return null}}const r=(t?.preferWebGl1?null:n("webgl2"))||n("webgl")||n("experimental-webgl");return un&&console.log(`isWebgl2: ${Wt(r)}`),r}(n,{powerPreference:c,failIfMajorPerformanceCaveat:u,antialias:l,preserveDrawingBuffer:d,alpha:!0,depth:!0,premultipliedAlpha:!0,preferWebGl1:f});if(null===p)throw new Error("Could not create a WebGL rendering context");const{pixelScale:m,pickScale:h,transparency:g}=a,y=A8.fromElement(n,{pixelScale:m,preventGestures:!0}),b=function P9e(e,t={}){const n=_re(e),r=function u7e(e,t){let n={},r=e.getParameter(e.FRONT_FACE),i=e.getParameter(e.CULL_FACE_MODE),o=e.getParameter(e.DEPTH_WRITEMASK),s=e.getParameter(e.DEPTH_CLEAR_VALUE),a=e.getParameter(e.DEPTH_FUNC),c=e.getParameter(e.COLOR_WRITEMASK),u=e.getParameter(e.COLOR_CLEAR_VALUE),l=e.getParameter(e.BLEND_SRC_RGB),d=e.getParameter(e.BLEND_DST_RGB),f=e.getParameter(e.BLEND_SRC_ALPHA),p=e.getParameter(e.BLEND_DST_ALPHA),m=e.getParameter(e.BLEND_COLOR),h=e.getParameter(e.BLEND_EQUATION_RGB),g=e.getParameter(e.BLEND_EQUATION_ALPHA),y=e.getParameter(e.STENCIL_FUNC),b=e.getParameter(e.STENCIL_VALUE_MASK),x=e.getParameter(e.STENCIL_REF),_=e.getParameter(e.STENCIL_BACK_FUNC),S=e.getParameter(e.STENCIL_BACK_VALUE_MASK),A=e.getParameter(e.STENCIL_BACK_REF),E=e.getParameter(e.STENCIL_WRITEMASK),w=e.getParameter(e.STENCIL_BACK_WRITEMASK),D=e.getParameter(e.STENCIL_FAIL),I=e.getParameter(e.STENCIL_PASS_DEPTH_PASS),R=e.getParameter(e.STENCIL_PASS_DEPTH_FAIL),T=e.getParameter(e.STENCIL_BACK_FAIL),M=e.getParameter(e.STENCIL_BACK_PASS_DEPTH_PASS),N=e.getParameter(e.STENCIL_BACK_PASS_DEPTH_FAIL),V=e.getParameter(e.MAX_VERTEX_ATTRIBS);const F=[];let G=e.getParameter(e.VIEWPORT),L=e.getParameter(e.SCISSOR_BOX),z=t.clipControl?e.getParameter(t.clipControl.CLIP_ORIGIN):-1,j=t.clipControl?e.getParameter(t.clipControl.CLIP_DEPTH_MODE):-1;const Z=()=>{for(let $=0;${!0!==n[$]&&(e.enable($),n[$]=!0)},disable:$=>{!1!==n[$]&&(e.disable($),n[$]=!1)},frontFace:$=>{$!==r&&(e.frontFace($),r=$)},cullFace:$=>{$!==i&&(e.cullFace($),i=$)},depthMask:$=>{$!==o&&(e.depthMask($),o=$)},clearDepth:$=>{$!==s&&(e.clearDepth($),s=$)},depthFunc:$=>{$!==a&&(e.depthFunc($),a=$)},colorMask:($,ee,q,O)=>{($!==c[0]||ee!==c[1]||q!==c[2]||O!==c[3])&&(e.colorMask($,ee,q,O),c[0]=$,c[1]=ee,c[2]=q,c[3]=O)},clearColor:($,ee,q,O)=>{($!==u[0]||ee!==u[1]||q!==u[2]||O!==u[3])&&(e.clearColor($,ee,q,O),u[0]=$,u[1]=ee,u[2]=q,u[3]=O)},blendFunc:($,ee)=>{($!==l||ee!==d||$!==f||ee!==p)&&(e.blendFunc($,ee),l=$,d=ee,f=$,p=ee)},blendFuncSeparate:($,ee,q,O)=>{($!==l||ee!==d||q!==f||O!==p)&&(e.blendFuncSeparate($,ee,q,O),l=$,d=ee,f=q,p=O)},blendEquation:$=>{($!==h||$!==g)&&(e.blendEquation($),h=$,g=$)},blendEquationSeparate:($,ee)=>{($!==h||ee!==g)&&(e.blendEquationSeparate($,ee),h=$,g=ee)},blendColor:($,ee,q,O)=>{($!==m[0]||ee!==m[1]||q!==m[2]||O!==m[3])&&(e.blendColor($,ee,q,O),m[0]=$,m[1]=ee,m[2]=q,m[3]=O)},stencilFunc:($,ee,q)=>{($!==y||ee!==x||q!==b||$!==_||ee!==A||q!==S)&&(e.stencilFunc($,ee,q),y=$,x=ee,b=q,_=$,A=ee,S=q)},stencilFuncSeparate:($,ee,q,O)=>{$===e.FRONT?(ee!==y||q!==x||O!==b)&&(e.stencilFuncSeparate($,ee,q,O),y=ee,x=q,b=O):$===e.BACK?(ee!==_||q!==A||O!==S)&&(e.stencilFuncSeparate($,ee,q,O),_=ee,A=q,S=O):$===e.FRONT_AND_BACK&&(ee!==y||q!==x||O!==b||ee!==_||q!==A||O!==S)&&(e.stencilFuncSeparate($,ee,q,O),y=ee,x=q,b=O,_=ee,A=q,S=O)},stencilMask:$=>{($!==E||$!==w)&&(e.stencilMask($),E=$,w=$)},stencilMaskSeparate:($,ee)=>{$===e.FRONT?ee!==E&&(e.stencilMaskSeparate($,ee),E=ee):$===e.BACK?ee!==w&&(e.stencilMaskSeparate($,ee),w=ee):$===e.FRONT_AND_BACK&&(ee!==E||ee!==w)&&(e.stencilMaskSeparate($,ee),E=ee,w=ee)},stencilOp:($,ee,q)=>{($!==D||ee!==R||q!==I||$!==T||ee!==N||q!==M)&&(e.stencilOp($,ee,q),D=$,R=ee,I=q,T=$,N=ee,M=q)},stencilOpSeparate:($,ee,q,O)=>{$===e.FRONT?(ee!==D||q!==R||O!==I)&&(e.stencilOpSeparate($,ee,q,O),D=ee,R=q,I=O):$===e.BACK?(ee!==T||q!==N||O!==M)&&(e.stencilOpSeparate($,ee,q,O),T=ee,N=q,M=O):$===e.FRONT_AND_BACK&&(ee!==D||q!==R||O!==I||ee!==T||q!==N||O!==M)&&(e.stencilOpSeparate($,ee,q,O),D=ee,R=q,I=O,T=ee,N=q,M=O)},enableVertexAttrib:$=>{e.enableVertexAttribArray($),F[$]=1},clearVertexAttribsState:Z,disableUnusedVertexAttribs:()=>{for(let $=0;${($!==G[0]||ee!==G[1]||q!==G[2]||O!==G[3])&&(e.viewport($,ee,q,O),G[0]=$,G[1]=ee,G[2]=q,G[3]=O)},scissor:($,ee,q,O)=>{($!==L[0]||ee!==L[1]||q!==L[2]||O!==L[3])&&(e.scissor($,ee,q,O),L[0]=$,L[1]=ee,L[2]=q,L[3]=O)},clipControl:t.clipControl?($,ee)=>{($!==z||ee!==j)&&(t.clipControl.clipControl($,ee),z=$,j=ee)}:void 0,reset:()=>{n={},r=e.getParameter(e.FRONT_FACE),i=e.getParameter(e.CULL_FACE_MODE),o=e.getParameter(e.DEPTH_WRITEMASK),s=e.getParameter(e.DEPTH_CLEAR_VALUE),a=e.getParameter(e.DEPTH_FUNC),c=e.getParameter(e.COLOR_WRITEMASK),u=e.getParameter(e.COLOR_CLEAR_VALUE),l=e.getParameter(e.BLEND_SRC_RGB),d=e.getParameter(e.BLEND_DST_RGB),f=e.getParameter(e.BLEND_SRC_ALPHA),p=e.getParameter(e.BLEND_DST_ALPHA),m=e.getParameter(e.BLEND_COLOR),h=e.getParameter(e.BLEND_EQUATION_RGB),g=e.getParameter(e.BLEND_EQUATION_ALPHA),y=e.getParameter(e.STENCIL_FUNC),b=e.getParameter(e.STENCIL_VALUE_MASK),x=e.getParameter(e.STENCIL_REF),_=e.getParameter(e.STENCIL_BACK_FUNC),S=e.getParameter(e.STENCIL_BACK_VALUE_MASK),A=e.getParameter(e.STENCIL_BACK_REF),E=e.getParameter(e.STENCIL_WRITEMASK),w=e.getParameter(e.STENCIL_BACK_WRITEMASK),D=e.getParameter(e.STENCIL_FAIL),I=e.getParameter(e.STENCIL_PASS_DEPTH_PASS),R=e.getParameter(e.STENCIL_PASS_DEPTH_FAIL),T=e.getParameter(e.STENCIL_BACK_FAIL),M=e.getParameter(e.STENCIL_BACK_PASS_DEPTH_PASS),N=e.getParameter(e.STENCIL_BACK_PASS_DEPTH_FAIL),V=e.getParameter(e.MAX_VERTEX_ATTRIBS),F.length=0;for(let $=0;${o&&(a.forEach((y,b)=>{o.deleteQuery(b)}),c.clear(),f=[],p=null)},g=()=>{if(!o)return;const y=function S9e(e){return e.disjointTimerQuery?e.disjointTimerQuery.createQuery():null}(t);y&&(o.beginQuery(o.TIME_ELAPSED,y),c.forEach((b,x)=>{b.queries.push(y)}),a.set(y,{refCount:c.size}),p=y)};return{resolve:()=>{const y=[];if(!o||!f.length)return y;a.forEach((x,_)=>{if(void 0!==x.timeElapsed)return;const S=o.getQueryParameter(_,o.QUERY_RESULT_AVAILABLE),A=e.getParameter(o.GPU_DISJOINT);if(S&&!A){const E=o.getQueryParameter(_,o.QUERY_RESULT);x.timeElapsed=E}(S||A)&&o.deleteQuery(_)});const b=[];for(const x of f)if(x.queries.every(_=>{var S;return void 0!==(null===(S=a.get(_))||void 0===S?void 0:S.timeElapsed)})){let _=0;for(const S of x.queries){const A=a.get(S);_+=A.timeElapsed,A.refCount-=1}if(x.timeElapsed=_,x.root){const S=[],A=(w,D)=>{for(const I of w){const R=I.timeElapsed,T=I.cpu.end-I.cpu.start,M={label:I.label,gpuElapsed:R,gpuAvg:l.add(I.label,R),cpuElapsed:T,cpuAvg:d.add(I.label,T),children:[],calls:I.calls};D.push(M),A(I.children,M.children)}};A(x.children,S);const E=x.cpu.end-x.cpu.start;y.push({label:x.label,gpuElapsed:_,gpuAvg:l.add(x.label,_),cpuElapsed:E,cpuAvg:d.add(x.label,E),children:S,calls:x.calls})}}else b.push(x);return f=b,a.forEach((x,_)=>{0===x.refCount&&a.delete(_)}),y},mark:(y,b=!1)=>{if(!o)return;if(c.has(y))throw new Error(`Timer mark for '${y}' already exists`);null!==p&&o.endQuery(o.TIME_ELAPSED);const x={label:y,queries:[],children:[],root:null===p,cpu:{start:yi(),end:-1},captureStats:b};if(c.set(y,x),u.length&&u[u.length-1].children.push(x),u.push(x),b){if(m)throw new Error("Already capturing stats");(function x9e(e){e.calls.drawInstanced=0,e.calls.drawInstancedBase=0,e.calls.multiDrawInstancedBase=0,e.calls.counts=0,e.culled.lod=0,e.culled.frustum=0,e.culled.occlusion=0})(n),m=!0}g()},markEnd:y=>{var b;if(!o)return;const x=c.get(y);if(!x)throw new Error(`Timer mark for '${y}' does not exist`);if((null===(b=u.pop())||void 0===b?void 0:b.label)!==y)throw new Error(`Timer mark for '${y}' has pending nested mark`);o.endQuery(o.TIME_ELAPSED),c.delete(y),x.cpu.end=yi(),x.captureStats&&(x.calls={...n.calls},m=!1),f.push(x),c.size>0?g():p=null},stats:()=>({gpu:l.stats(),cpu:d.stats()}),formatedStats:()=>{const y={},b=l.stats(),x=d.stats();for(const _ of Object.keys(b)){const S=`${(b[_]/1e3/1e3).toFixed(2)}`,A=`${x[_].toFixed(2)}`;y[_]=`${S} ms | CPU: ${A} ms`}return y},clear:h,destroy:()=>{h()}}}(e,n,i),a={maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),max3dTextureSize:Wt(e)?e.getParameter(e.MAX_3D_TEXTURE_SIZE):0,maxRenderbufferSize:e.getParameter(e.MAX_RENDERBUFFER_SIZE),maxDrawBuffers:n.drawBuffers?e.getParameter(n.drawBuffers.MAX_DRAW_BUFFERS):0,maxTextureImageUnits:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextureImageUnits:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)};if(a.maxVertexTextureImageUnits<8)throw new Error('Need "MAX_VERTEX_TEXTURE_IMAGE_UNITS" >= 8');const c=n.provokingVertex;c?.provokingVertex(c.FIRST_VERTEX_CONVENTION);let u=!1;const l=new Ao(0);let f,d=t.pixelScale||1;if(Wt(e)){const m=e.createBuffer();let h,g,y=!1;const b=()=>{e.bindBuffer(e.PIXEL_PACK_BUFFER,m),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,h),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),y=!1,g(),g=void 0,h=void 0};f=(x,_,S,A,E)=>new Promise((w,D)=>{y?D("Can not call multiple readPixelsAsync at the same time"):(y=!0,e.bindBuffer(e.PIXEL_PACK_BUFFER,m),e.bufferData(e.PIXEL_PACK_BUFFER,S*A*4,e.STREAM_READ),e.readPixels(x,_,S,A,e.RGBA,e.UNSIGNED_BYTE,0),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),g=w,h=E,Vre(e,b))})}else f=function(){var m=ie(function*(h,g,y,b,x){XL(e,h,g,y,b,x)});return function(g,y,b,x,_){return m.apply(this,arguments)}}();const p=new Set;return{gl:e,isWebGL2:Wt(e),get pixelRatio(){return(typeof window<"u"&&window.devicePixelRatio||1)*(d||1)},extensions:n,state:r,stats:i,resources:o,timer:s,get maxTextureSize(){return a.maxTextureSize},get max3dTextureSize(){return a.max3dTextureSize},get maxRenderbufferSize(){return a.maxRenderbufferSize},get maxDrawBuffers(){return a.maxDrawBuffers},get maxTextureImageUnits(){return a.maxTextureImageUnits},namedComputeRenderables:Object.create(null),namedFramebuffers:Object.create(null),namedTextures:Object.create(null),get isContextLost(){return u||e.isContextLost()},contextRestored:l,setContextLost:()=>{u=!0},handleContextRestored:m=>{Object.assign(n,_re(e)),r.reset(),r.currentMaterialId=-1,r.currentProgramId=-1,r.currentRenderItemId=-1,o.reset(),p.forEach(h=>h.reset()),m?.(),u=!1,l.next(yi())},setPixelScale:m=>{d=m},createRenderTarget:(m,h,g,y,b,x)=>{const _=function b9e(e,t,n,r,i=!0,o="uint8",s="nearest",a="rgba"){if("alpha"===a&&!Wt(e))throw new Error("cannot render to alpha format in webgl1");const c=t.framebuffer(),u="fp16"===o?t.texture("image-float16",a,"fp16",s):"float32"===o?t.texture("image-float32",a,"float",s):t.texture("image-uint8",a,"ubyte",s),l=i?Wt(e)?t.renderbuffer("depth32f","depth",n,r):t.renderbuffer("depth16","depth",n,r):null;function d(){u.define(n,r),u.attachFramebuffer(c,"color0"),l&&l.attachFramebuffer(c)}d();let f=!1;return{id:kre(),texture:u,framebuffer:c,depthRenderbuffer:l,getWidth:()=>n,getHeight:()=>r,bind:()=>{c.bind()},setSize:(p,m)=>{n===p&&r===m||(u.define(n=p,r=m),l&&l.setSize(n,r))},reset:()=>{d()},destroy:()=>{f||(u.destroy(),c.destroy(),l&&l.destroy(),f=!0)}}}(e,o,m,h,g,y,b,x);return p.add(_),{..._,destroy:()=>{_.destroy(),p.delete(_)}}},unbindFramebuffer:()=>bD(e),readPixels:(m,h,g,y,b)=>{XL(e,m,h,g,y,b)},readPixelsAsync:f,waitForGpuCommandsComplete:()=>function T9e(e){return new Promise(t=>{Wt(e)?Vre(e,t):(zre||(console.info("Sync object not supported in WebGL"),zre=!0),Gre(e),t())})}(e),waitForGpuCommandsCompleteSync:()=>Gre(e),getDrawingBufferPixelData:()=>function D9e(e,t){const n=e.drawingBufferWidth,r=e.drawingBufferHeight,i=new Uint8Array(n*r*4);return bD(e),t.viewport(0,0,n,r),XL(e,0,0,n,r,i),d0.flipY(d0.create(i,n,r))}(e,r),clear:(m,h,g,y)=>{bD(e),r.enable(e.SCISSOR_TEST),r.depthMask(!0),r.colorMask(!0,!0,!0,!0),r.clearColor(m,h,g,y),r.viewport(0,0,e.drawingBufferWidth,e.drawingBufferHeight),r.scissor(0,0,e.drawingBufferWidth,e.drawingBufferHeight),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)},destroy:m=>{var h,g;o.destroy(),function I9e(e){const t=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);for(let i=0;i{b.isContextLost||!D.shiftKey||!D.ctrlKey||!D.altKey||(un&&console.log("lose context"),w.loseContext(),setTimeout(()=>{b.isContextLost&&(un&&console.log("restore context"),w.restoreContext())},1e3))},!1)}const _=new Ao(0),S=w=>{b.setContextLost(),w.preventDefault(),un&&console.log("context lost"),_.next(yi())},A=()=>{b.isContextLost&&(b.handleContextRestored(()=>{x.draw.reset()}),un&&console.log("context restored"))};n.addEventListener("webglcontextlost",S,!1),n.addEventListener("webglcontextrestored",A,!1);const E=new Ao(void 0);return{canvas:n,webgl:b,input:y,passes:x,attribs:s,get props(){return{...a}},contextLost:_,contextRestored:b.contextRestored,assetManager:r,changed:E,setProps:w=>{if(!w)return;let D=!1;void 0!==w.pixelScale&&w.pixelScale!==a.pixelScale&&(a.pixelScale=w.pixelScale,y.setPixelScale(w.pixelScale),b.setPixelScale(w.pixelScale),s.handleResize(),D=!0),void 0!==w.pickScale&&w.pickScale!==a.pickScale&&(a.pickScale=w.pickScale,x.setPickScale(w.pickScale),D=!0),void 0!==w.transparency&&w.transparency!==a.transparency&&(a.transparency=w.transparency,x.setTransparency(w.transparency),D=!0),D&&E.next(void 0)},dispose:w=>{y.dispose(),n.removeEventListener("webglcontextlost",S,!1),n.removeEventListener("webglcontextrestored",A,!1),b.destroy(w)}}}}(kE||(kE={}));const kit=typeof window<"u"?window.requestAnimationFrame:e=>setImmediate(()=>e(Date.now())),Kue=typeof window<"u"?window.cancelAnimationFrame:e=>clearImmediate(e);var q8;function Nit(e){Zue(e)}function Zue(e){Cn.Canvas3D.ResetSettings.subscribe(e,()=>{var t;null===(t=e.canvas3d)||void 0===t||t.setProps(H8),e.events.canvas3d.settingsUpdated.next(void 0)}),Cn.Canvas3D.SetSettings.subscribe(e,t=>{var n;e.canvas3d&&(null===(n=e.canvas3d)||void 0===n||n.setProps(t.settings),e.events.canvas3d.settingsUpdated.next(void 0))})}!function(e){e.create=function t(n,r={}){var i;const{webgl:o,input:s,passes:a,assetManager:c,canvas:u}=n,l={...Jl(H8),...Jl(r)},d=new Map,f=new Map,p=new Ao(0);let m=yi();const h=new Ao(0),g=new Ao(0),y=new Ao(0),{gl:b,contextRestored:x}=o;let _=0,S=0,A=128,E=128,w=!1,D=0;ln();const I=Wv.create(o,n.props.transparency);function R(){return I.boundingSphere.radius*l.sceneRadiusFactor}const T=new gr({position:v.create(0,0,100),mode:l.camera.mode,fog:"on"===l.cameraFog.name?l.cameraFog.params.intensity:0,clipFar:l.cameraClipping.far,minNear:l.cameraClipping.minNear,fov:Yn(l.camera.fov)},{x:_,y:S,width:A,height:E}),M=new Yv(T,l.camera.stereo.params),N=E8.create(s,T,I,l.trackball),V=new Jrt(o,I,l),F=new Rit(o,a.draw,u,l.hiZ),G=D8.create(o,l.renderer);G.setOcclusionTest(F.isOccluded);const L=new frt(o,G,I,V,a.pick,{x:_,y:S,width:A,height:E},l.pickPadding),z=new Xtt(We,H,s,T,N,l.interaction),j=new wue(a.multiSample);a.draw.postprocessing.background.update(T,l.postprocessing.background,qe=>{qe&&me()});let $,ee,Z=!1,q=!1,O=!0;function H(qe){let dt=$n,gt=yn.Empty;if(qe){const se=V.camera.getLoci(qe);if(se!==$n)return{loci:se,repr:gt};dt=V.handle.getLoci(qe),d.forEach((he,ve)=>{const Te=ve.getLoci(qe);Ta(Te)||(Ta(dt)||console.warn("found another loci, this should not happen"),dt=Te,gt=ve)})}return{loci:dt,repr:gt}}let W=[];function X(qe,dt){const{repr:gt,loci:se}=qe;let he=!1;return gt?he=gt.mark(se,dt)||he:d.forEach((ve,Te)=>{he=Te.mark(se,dt)||he}),he=V.handle.mark(se,dt)||he,he=V.camera.mark(se,dt)||he,he}let ce=!1,be=!1;function ae(qe){be||function J(qe){if(o.isContextLost)return!1;let dt=!1;if(q&&(Et(!1),q=!1,dt=!0),_>b.drawingBufferWidth||_+A<0||S>b.drawingBufferHeight||S+E<0)return!1;const gt=function fe(){let qe=!1;for(const[dt,gt]of W)qe=X(dt,gt)||qe;return W=[],qe&&(I.update(void 0,!0),V.handle.scene.update(void 0,!0),V.camera.scene.update(void 0,!0)),qe}()&&(G.props.colorMarker||l.marking.enabled);let se=!1;N.update(D);const he=T.update(),ve=qe||he||dt||w;w=!1;const Te=j.update(gt||ve,l.multiSample);if(ve||Te||gt){let yt=T;"on"===l.camera.stereo.name&&(M.update(),yt=M),lt&&o.timer.mark("Canvas3D.render",!0);const xt={renderer:G,camera:yt,scene:I,helper:V};TE.isEnabled(l.multiSample)?j.render(xt,l,!0,l.multiSample.reduceFlicker&&!he&>&&!N.isAnimating):a.draw.render(xt,l,!0),F.render(T),lt&&o.timer.markEnd("Canvas3D.render"),L.dirty=L.dirty||ve,se=!0}return se}(!!qe?.force)&&O&&h.next(yi()-m)}function me(){w=!0}let oe=0;function K(qe,dt){D=qe,U(dt?.isSynchronous),T.transition.tick(D),F.tick(),!dt?.manualDraw&&(ae(),!T.transition.inTransition&&!o.isContextLost&&z.tick(D))}function ne(){K(yi()),oe=kit(ne)}function We(qe,dt){return o.isContextLost?void 0:L.identify(qe,dt,"on"===l.camera.stereo.name?M:T)}function U(qe=!1){(function Ge(qe){return!I.needsCommit||(_e.copy(ge,I.boundingSphereVisible),F.clear(),I.commit(qe?void 0:Ne)?(y.next(0),V.debug.isEnabled&&V.debug.update(),!l.camera.manualReset&&(0===p.value||function Re(){if(0===T.state.radiusMax)return!0;if(T.transition.inTransition||ee)return!1;let qe=!0,dt=!0;_e.set(Se,T.state.target,T.state.radius);for(const gt of I.renderables){if(!gt.state.visible)continue;const se=gt.values.boundingSphere.ref.value;if(!se.radius)continue;dt=!1;const he=v.distance(Se.center,se.center);if((he>Se.radius||he>se.radius||se.radius>T.state.radiusMax)&&!_e.includes(ge,se))return!0;_e.overlaps(Se,se)&&(qe=!1)}return qe||!dt&&Se.radius<=.1}())&&(Z=!0),0===ge.radius&&($=0),l.camera.manualReset||T.setState({radiusMax:R()},0),p.next(d.size),un&&$e(),!0):(y.next(I.commitQueueSize),!1))})(qe)&&(function Y(){if(!Z)return;const qe=I.boundingSphereVisible,{center:dt,radius:gt}=qe,se=N.props.autoAdjustMinMaxDistance;if("on"===se.name){const he=se.params.minDistanceFactor*gt+se.params.minDistancePadding,ve=Math.max(se.params.maxDistanceFactor*gt,se.params.maxDistanceMin);N.setProps({minDistance:he,maxDistance:ve})}if(gt>0){const he=void 0===$?l.cameraResetDurationMs:$,ve=T.getFocus(dt,gt),Te="function"==typeof ee?ee(I,T):ee,yt=Te?{...ve,...Te}:ve;T.setState({...yt,radiusMax:R()},he)}$=void 0,ee=void 0,Z=!1}(),ce&&(V.debug.isEnabled&&V.debug.update(),ae({force:!0}),ce=!1),g.next(yi()))}const ge=_e(),Se=_e(),Ne=250;function $e(){const qe=I.renderables.map(he=>({drawCount:he.values.drawCount.ref.value,instanceCount:he.values.instanceCount.ref.value,materialId:he.materialId,renderItemId:he.id}));console.groupCollapsed(`${qe.length} RenderItems`),qe.length<50?console.table(qe):console.log(qe),console.log(JSON.stringify(o.stats,void 0,4));const{texture:dt,attribute:gt,elements:se}=o.resources.getByteCounts();console.log(JSON.stringify({texture:`${(dt/1024/1024).toFixed(3)} MiB`,attribute:`${(gt/1024/1024).toFixed(3)} MiB`,elements:`${(se/1024/1024).toFixed(3)} MiB`},void 0,4)),console.log(JSON.stringify(o.timer.formatedStats(),void 0,4)),console.groupEnd()}function _t(){const qe=I.boundingSphere.radius>0?100-Math.round(T.transition.target.radius/R()*100):0;return{camera:{mode:T.state.mode,helper:{...V.camera.props},stereo:{...l.camera.stereo},fov:Math.round(su(T.state.fov)),manualReset:!!l.camera.manualReset},cameraFog:T.state.fog>0?{name:"on",params:{intensity:T.state.fog}}:{name:"off",params:{}},cameraClipping:{far:T.state.clipFar,radius:qe,minNear:T.state.minNear},cameraResetDurationMs:l.cameraResetDurationMs,sceneRadiusFactor:l.sceneRadiusFactor,transparentBackground:l.transparentBackground,dpoitIterations:l.dpoitIterations,pickPadding:l.pickPadding,viewport:l.viewport,postprocessing:{...l.postprocessing},marking:{...l.marking},multiSample:{...l.multiSample},hiZ:{...F.props},renderer:{...G.props},trackball:{...N.props},interaction:{...z.props},debug:{...V.debug.props},handle:{...V.handle.props}}}const ut=x.subscribe(()=>{L.dirty=!0,ae({force:!0}),ae({force:!0})}),Ct=new Ao(0);function Et(qe=!0){a.updateSize(),ln(),Qn(),qe&&me(),Ct.next(+new Date)}!function FMe(e){Jx.includes(e)||Jx.push(e)}($e);const Xt=null===(i=n.changed)||void 0===i?void 0:i.subscribe(()=>{I.setTransparency(n.props.transparency),me()});if(un&&u){let qe;const dt=gt=>{const se=gt&&pn.getBoundingSphere(pn.normalize(gt,"residue"));F.debugOcclusion(se)};s.click.subscribe(gt=>{if(!gt.modifiers.control||2!==gt.button)return;const se=We(gt.x,gt.y);if(!se)return qe=void 0,void dt(qe);qe=H(se.id).loci,dt(qe)}),h.subscribe(()=>{setTimeout(()=>{dt(qe)},100)})}return{webgl:o,add:function tt(qe){!function Xe(qe){f.has(qe)||f.set(qe,qe.updated.subscribe(dt=>{qe.state.syncManually||tt(qe)}))}(qe);const dt=d.get(qe),gt=new Set;qe.renderObjects.forEach(se=>gt.add(se)),dt?Si.areEqual(gt,dt)||(gt.forEach(se=>{dt.has(se)||I.add(se)}),dt.forEach(se=>{gt.has(se)||I.remove(se)})):qe.renderObjects.forEach(se=>I.add(se)),d.set(qe,gt),I.update(qe.renderObjects,!1),ce=!0,un&&$e()},remove:function ke(qe){!function ot(qe){const dt=f.get(qe);dt&&(dt.unsubscribe(),f.delete(qe))}(qe);const dt=d.get(qe);dt&&(dt.forEach(gt=>I.remove(gt)),d.delete(qe),ce=!0,un&&$e())},commit:U,update:(qe,dt)=>{if(qe){if(!d.has(qe))return;I.update(qe.renderObjects,!!dt)}else I.update(void 0,!!dt);ce=!0},clear:()=>{f.forEach(qe=>qe.unsubscribe()),f.clear(),d.clear(),I.clear(),V.debug.clear(),me(),p.next(d.size)},syncVisibility:()=>{0===T.state.radiusMax&&(Z=!0,$=0),I.syncVisibility()&&V.debug.isEnabled&&V.debug.update(),me()},requestDraw:me,tick:K,animate:function we(){be=!1,N.start(yi()),0===oe&&ne()},resetTime:function de(qe){m=qe,N.start(qe)},pause:function Le(qe=!1){be=qe,Kue(oe),oe=0},resume:()=>{be=!1},identify:We,mark:function Q(qe,dt){W.push([qe,dt])},getLoci:H,handleResize:Et,requestResize:()=>{q=!0},requestCameraReset:qe=>{$=qe?.durationMs,ee=qe?.snapshot,Z=!0},camera:T,boundingSphere:I.boundingSphere,boundingSphereVisible:I.boundingSphereVisible,get notifyDidDraw(){return O},set notifyDidDraw(qe){O=qe},didDraw:h,commited:g,commitQueueSize:y,reprCount:p,resized:Ct,setProps:(qe,dt=!1)=>{var gt,se,he,ve;const Te="function"==typeof qe?c0(_t(),qe):qe;void 0!==Te.sceneRadiusFactor&&(l.sceneRadiusFactor=Te.sceneRadiusFactor,T.setState({radiusMax:R()},0));const yt=Object.create(null);Te.camera&&void 0!==Te.camera.mode&&Te.camera.mode!==T.state.mode&&(yt.mode=Te.camera.mode);const xt=Math.round(su(T.state.fov));if(Te.camera&&void 0!==Te.camera.fov&&Te.camera.fov!==xt&&(yt.fov=Yn(Te.camera.fov)),void 0!==Te.cameraFog&&Te.cameraFog.params){const Ut="on"===Te.cameraFog.name?Te.cameraFog.params.intensity:0;Ut!==T.state.fog&&(yt.fog=Ut)}if(void 0!==Te.cameraClipping&&(void 0!==Te.cameraClipping.far&&Te.cameraClipping.far!==T.state.clipFar&&(yt.clipFar=Te.cameraClipping.far),void 0!==Te.cameraClipping.minNear&&Te.cameraClipping.minNear!==T.state.minNear&&(yt.minNear=Te.cameraClipping.minNear),void 0!==Te.cameraClipping.radius)){const Ut=R()/100*(100-Te.cameraClipping.radius);Ut>0&&Ut!==yt.radius&&(yt.radius=Math.max(Ut,.01))}Object.keys(yt).length>0&&T.setState(yt),!(null===(gt=Te.camera)||void 0===gt)&>.helper&&V.camera.setProps(Te.camera.helper),void 0!==(null===(se=Te.camera)||void 0===se?void 0:se.manualReset)&&(l.camera.manualReset=Te.camera.manualReset),void 0!==(null===(he=Te.camera)||void 0===he?void 0:he.stereo)&&(Object.assign(l.camera.stereo,Te.camera.stereo),M.setProps(l.camera.stereo.params)),void 0!==Te.cameraResetDurationMs&&(l.cameraResetDurationMs=Te.cameraResetDurationMs),void 0!==Te.transparentBackground&&(l.transparentBackground=Te.transparentBackground),void 0!==Te.dpoitIterations&&(l.dpoitIterations=Te.dpoitIterations),void 0!==Te.pickPadding&&(l.pickPadding=Te.pickPadding),void 0!==Te.viewport&&(l.viewport===Te.viewport||l.viewport.name===Te.viewport.name&&Hx(l.viewport.params,Te.viewport.params)||(l.viewport=Te.viewport,ln(),Qn())),!(null===(ve=Te.postprocessing)||void 0===ve)&&ve.background&&(Object.assign(l.postprocessing.background,Te.postprocessing.background),a.draw.postprocessing.background.update(T,l.postprocessing.background,Ut=>{Ut&&!dt&&me()})),Te.postprocessing&&Object.assign(l.postprocessing,Te.postprocessing),Te.marking&&Object.assign(l.marking,Te.marking),Te.multiSample&&Object.assign(l.multiSample,Te.multiSample),Te.hiZ&&F.setProps(Te.hiZ),Te.renderer&&G.setProps(Te.renderer),Te.trackball&&N.setProps(Te.trackball),Te.interaction&&z.setProps(Te.interaction),Te.debug&&V.debug.setProps(Te.debug),Te.handle&&V.handle.setProps(Te.handle),"orthographic"===yt.mode&&(l.camera.stereo.name="off"),dt||me()},getImagePass:(qe={})=>new Hrt(o,c,G,I,T,V,a.draw.transparency,qe),getRenderObjects(){const qe=[];return I.forEach((dt,gt)=>qe.push(gt)),qe},get props(){return _t()},get input(){return s},get stats(){return G.stats},get interaction(){return z.events},dispose:()=>{ut.unsubscribe(),Xt?.unsubscribe(),Kue(oe),W=[],I.clear(),V.debug.clear(),N.dispose(),G.dispose(),z.dispose(),F.dispose(),function BMe(e){const t=Jx.indexOf(e);-1!==t&&Jx.splice(t,1)}($e)}};function ln(){const qe=_,dt=S,gt=A,se=E;"canvas"===l.viewport.name?(_=0,S=0,A=b.drawingBufferWidth,E=b.drawingBufferHeight):"static-frame"===l.viewport.name?(_=l.viewport.params.x*o.pixelRatio,E=l.viewport.params.height*o.pixelRatio,S=b.drawingBufferHeight-E-l.viewport.params.y*o.pixelRatio,A=l.viewport.params.width*o.pixelRatio):"relative-frame"===l.viewport.name&&(_=Math.round(l.viewport.params.x*b.drawingBufferWidth),E=Math.round(l.viewport.params.height*b.drawingBufferHeight),S=Math.round(b.drawingBufferHeight-E-l.viewport.params.y*b.drawingBufferHeight),A=Math.round(l.viewport.params.width*b.drawingBufferWidth)),(qe!==_||dt!==S||gt!==A||se!==E)&&(w=!0)}function Qn(){L.setViewport(_,S,A,E),G.setViewport(_,S,A,E),Lo.set(T.viewport,_,S,A,E),Lo.set(N.viewport,_,S,A,E),F.setViewport(_,S,A,E)}}}(q8||(q8={}));const M0=Zi,Tm=wu,R0=At.Trigger,Fit={hoverHighlightOnly:At([R0(M0.Flag.None)],"Highlight","Hover element using ${triggers}"),hoverHighlightOnlyExtend:At([R0(M0.Flag.None,Tm.create({shift:!0}))],"Extend highlight","From selected to hovered element along polymer using ${triggers}")},Bit={bindings:C.Value(Fit,{isHidden:!0}),ignore:C.Value([],{isHidden:!0}),preferAtoms:C.Boolean(!1,{description:"Always prefer atoms over bonds"}),mark:C.Boolean(!0)},Oit=tr.create({name:"representation-highlight-loci",category:"interaction",ctor:class extends tr.Handler{constructor(){super(...arguments),this.lociMarkProvider=(e,t)=>{!this.ctx.canvas3d||!this.params.mark||this.ctx.canvas3d.mark(e,t)}}getLoci(e){return this.params.preferAtoms&&Lt.isLoci(e)&&2===e.bonds.length?Lt.toFirstStructureElementLoci(e):e}register(){this.subscribeObservable(this.ctx.behaviors.interaction.hover,({current:e,buttons:t,modifiers:n})=>{if(!this.ctx.canvas3d||this.ctx.isBusy)return;const r=this.getLoci(e.loci);if(this.params.ignore.includes(r.kind))return void this.ctx.managers.interactivity.lociHighlights.highlightOnly({repr:e.repr,loci:$n});let i=!1;At.match(this.params.bindings.hoverHighlightOnly,t,n)&&(this.ctx.managers.interactivity.lociHighlights.highlightOnly({loci:r}),i=!0),At.match(this.params.bindings.hoverHighlightOnlyExtend,t,n)&&(this.ctx.managers.interactivity.lociHighlights.highlightOnlyExtend({loci:r}),i=!0),i||this.ctx.managers.interactivity.lociHighlights.highlightOnly({repr:e.repr,loci:$n})}),this.ctx.managers.interactivity.lociHighlights.addProvider(this.lociMarkProvider)}unregister(){this.ctx.managers.interactivity.lociHighlights.removeProvider(this.lociMarkProvider)}},params:()=>Bit,display:{name:"Highlight Loci on Canvas"}}),Que={clickSelect:At.Empty,clickToggleExtend:At([R0(M0.Flag.Primary,Tm.create({shift:!0}))],"Toggle extended selection","Click on element using ${triggers} to extend selection along polymer"),clickSelectOnly:At.Empty,clickToggle:At([R0(M0.Flag.Primary,Tm.create())],"Toggle selection","Click on element using ${triggers}"),clickDeselect:At.Empty,clickDeselectAllOnEmpty:At([R0(M0.Flag.Primary,Tm.create())],"Deselect all","Click on nothing using ${triggers}")},Lit={bindings:C.Value(Que,{isHidden:!0}),ignore:C.Value([],{isHidden:!0}),preferAtoms:C.Boolean(!1,{description:"Always prefer atoms over bonds"}),mark:C.Boolean(!0)},Uit=tr.create({name:"representation-select-loci",category:"interaction",ctor:class extends tr.Handler{getLoci(e){return this.params.preferAtoms&&Lt.isLoci(e)&&2===e.bonds.length?Lt.toFirstStructureElementLoci(e):e}applySelectMark(e,t){const n=this.ctx.state.data.cells.get(e);if(n&&pe.isRepresentation3D(n.obj)){this.spine.current=n;const r=this.spine.getRootOfType(pe.Molecule.Structure);if(r){t&&this.lociMarkProvider({loci:Ve.Loci(r.data)},Bt.Deselect);const i=this.ctx.managers.structure.selection.getLoci(r.data);this.lociMarkProvider({loci:i},Bt.Select)}}}register(){const t=r=>!pn.isEmpty(r),n=[["clickSelect",r=>this.ctx.managers.interactivity.lociSelects.select(r),t],["clickToggle",r=>this.ctx.managers.interactivity.lociSelects.toggle(r),t],["clickToggleExtend",r=>this.ctx.managers.interactivity.lociSelects.toggleExtend(r),t],["clickSelectOnly",r=>this.ctx.managers.interactivity.lociSelects.selectOnly(r),t],["clickDeselect",r=>this.ctx.managers.interactivity.lociSelects.deselect(r),t],["clickDeselectAllOnEmpty",()=>this.ctx.managers.interactivity.lociSelects.deselectAll(),r=>pn.isEmpty(r)]];n.sort((r,i)=>{const o=this.params.bindings[r[0]],s=this.params.bindings[i[0]],a=0===o.triggers.length?0:Xd(o.triggers.map(u=>Tm.size(u.modifiers)));return(0===s.triggers.length?0:Xd(s.triggers.map(u=>Tm.size(u.modifiers))))-a}),this.subscribeObservable(this.ctx.behaviors.interaction.click,({current:r,button:i,modifiers:o})=>{if(!this.ctx.canvas3d||this.ctx.isBusy||!this.ctx.selectionMode)return;const s=this.getLoci(r.loci);if(!this.params.ignore.includes(s.kind))for(const[a,c,u]of n)if(At.match(this.params.bindings[a],i,o)&&(!u||u(s))){c({repr:r.repr,loci:s});break}}),this.ctx.managers.interactivity.lociSelects.addProvider(this.lociMarkProvider),this.subscribeObservable(this.ctx.state.events.object.created,({ref:r})=>this.applySelectMark(r)),this.subscribeObservable(this.ctx.state.events.object.updated,({ref:r,obj:i,oldObj:o,oldData:s,action:a})=>{const c=this.ctx.state.data.cells.get(r);if(c&&pe.Molecule.Structure.is(c.obj)){const u=i.data,l="recreate"===a?o?.data:"in-place"===a?s:void 0;if(l&&Ve.areEquivalent(u,l)&&Ve.areHierarchiesEqual(u,l))return;const d=this.ctx.state.data.select(In.children(r).ofType(pe.Molecule.Structure.Representation3D));for(const f of d)this.applySelectMark(f.transform.ref,!0)}})}unregister(){this.ctx.managers.interactivity.lociSelects.removeProvider(this.lociMarkProvider)}constructor(e,t){super(e,t),this.lociMarkProvider=(n,r)=>{!this.ctx.canvas3d||!this.params.mark||this.ctx.canvas3d.mark({loci:n.loci},r)},this.spine=new oD.Impl(e.state.data.cells)}},params:()=>Lit,display:{name:"Select Loci on Canvas"}}),Vit=tr.create({name:"default-loci-label-provider",category:"interaction",ctor:class{register(){this.ctx.managers.lociLabels.addProvider(this.f)}unregister(){this.ctx.managers.lociLabels.removeProvider(this.f)}constructor(e){this.ctx=e,this.f={label:t=>{const n=[];if(De.is(t)){const r=new Set;for(const{unit:i}of t.elements){const o=nt.create(t.structure,i,i.elements[0]),s=Ze.entity.pdbx_description(o).join(", ");r.add(s)}1===r.size&&r.forEach(i=>n.push(i))}return n.push(dE(t)),n.filter(r=>!!r).join("
")},group:t=>t.toString().replace(/Model [0-9]+/g,"Models"),priority:100}}},display:{name:"Provide Default Loci Label"}}),Jue={clickFocus:At([R0(M0.Flag.Primary,Tm.create())],"Representation Focus","Click element using ${triggers}"),clickFocusAdd:At([R0(M0.Flag.Primary,Tm.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}")},zit={bindings:C.Value(Jue,{isHidden:!0})},Git=tr.create({name:"representation-focus-loci",category:"interaction",ctor:class extends tr.Handler{register(){this.subscribeObservable(this.ctx.behaviors.interaction.click,({current:e,button:t,modifiers:n})=>{var r,i,o,s,a;const{clickFocus:c,clickFocusAdd:u,clickFocusSelectMode:l,clickFocusAddSelectMode:d}=this.params.bindings,p=At.match(this.ctx.selectionMode?l:c,t,n),m=null!==(s=null===(o=null===(i=null===(r=e.repr)||void 0===r?void 0:r.props)||void 0===i?void 0:i.snapshotKey)||void 0===o?void 0:o.trim())&&void 0!==s?s:"";if(!this.ctx.selectionMode&&p&&m)return void this.ctx.managers.snapshot.applyKey(m);const{granularity:h}=this.ctx.managers.interactivity.props;if("residue"!==h&&"element"!==h)return;const y=At.match(this.ctx.selectionMode?d:u,t,n);if(!p&&!y)return;const b=pn.normalize(e.loci,"residue"),x=this.ctx.managers.structure.focus.current;if(x&&pn.areEqual(x.loci,b))this.ctx.managers.structure.focus.clear();else if(p)this.ctx.managers.structure.focus.setFromLoci(b);else{this.ctx.managers.structure.focus.addFromLoci(b);const _=null===(a=this.ctx.managers.structure.focus.current)||void 0===a?void 0:a.loci;_&&this.ctx.managers.camera.focusLoci(_)}})}},params:()=>zit,display:{name:"Representation Focus Loci on Canvas"}}),Tf=Zi,hd=wu,Df=At.Trigger,NE=At.TriggerKey,W8=At([Df(Tf.Flag.Primary,hd.create()),Df(Tf.Flag.Secondary,hd.create()),Df(Tf.Flag.Primary,hd.create({control:!0}))],"Reset camera focus","Click on nothing using ${triggers}"),$8=At([Df(Tf.Flag.Secondary,hd.create()),Df(Tf.Flag.Primary,hd.create({control:!0}))],"Reset camera focus","Click on nothing using ${triggers}"),ele={clickCenterFocus:At([Df(Tf.Flag.Primary,hd.create()),Df(Tf.Flag.Secondary,hd.create()),Df(Tf.Flag.Primary,hd.create({control:!0}))],"Camera center and focus","Click element using ${triggers}"),clickCenterFocusSelectMode:At([Df(Tf.Flag.Secondary,hd.create()),Df(Tf.Flag.Primary,hd.create({control:!0}))],"Camera center and focus","Click element using ${triggers}"),clickResetCameraOnEmpty:W8,clickResetCameraOnEmptySelectMode:$8},jit={minRadius:C.Numeric(8,{min:1,max:50,step:1}),extraRadius:C.Numeric(4,{min:1,max:50,step:1},{description:"Value added to the bounding-sphere radius of the Loci"}),durationMs:C.Numeric(250,{min:0,max:1e3,step:1},{description:"Camera transition duration"}),bindings:C.Value(ele,{isHidden:!0})},Hit=tr.create({name:"camera-focus-loci",category:"interaction",ctor:class extends tr.Handler{register(){this.subscribeObservable(this.ctx.behaviors.interaction.click,({current:e,button:t,modifiers:n})=>{var r,i;if(!this.ctx.canvas3d)return;const o=this.ctx.selectionMode?this.params.bindings.clickCenterFocusSelectMode:this.params.bindings.clickCenterFocus,s=this.ctx.selectionMode?null!==(r=this.params.bindings.clickResetCameraOnEmptySelectMode)&&void 0!==r?r:$8:null!==(i=this.params.bindings.clickResetCameraOnEmpty)&&void 0!==i?i:W8;if(pn.isEmpty(e.loci)&&At.match(s,t,n))Cn.Camera.Reset(this.ctx,{});else if(At.match(o,t,n)){const a=pn.normalize(e.loci,this.ctx.managers.interactivity.props.granularity);this.ctx.managers.camera.focusLoci(a,this.params)}})}},params:()=>jit,display:{name:"Camera Focus Loci on Canvas"}}),qit=tr.create({name:"camera-axis-helper",category:"interaction",ctor:class extends tr.Handler{register(){let e=Cr.None,t=0;this.subscribeObservable(this.ctx.behaviors.interaction.click,({current:n})=>{if(!this.ctx.canvas3d||!L8(n.loci))return;const r=n.loci.elements[0].groupId;if(r===Cr.None)return e=Cr.None,void(t=0);const{camera:i}=this.ctx.canvas3d;let o,s;if(r>=Cr.X&&r<=Cr.Z){e=Cr.None,t=0;const a=v.sub(v(),i.target,i.position),c=v.cross(v(),a,i.up);s=v(),s[r-1]=1,o=v.cross(v(),s,c),0===v.magnitude(o)&&(o=a)}else e===r?t=(t+1)%2:(e=r,t=0),r===Cr.XY?(s=t?v.unitX:v.unitY,o=v.negUnitZ):r===Cr.XZ?(s=t?v.unitX:v.unitZ,o=v.negUnitY):(s=t?v.unitY:v.unitZ,o=v.negUnitX);this.ctx.canvas3d.requestCameraReset({snapshot:(a,c)=>c.getInvariantFocus(a.boundingSphereVisible.center,a.boundingSphereVisible.radius,s,o)})})}},params:()=>({}),display:{name:"Camera Axis Helper"}}),tle={keySpinAnimation:At([NE("I")],"Spin Animation","Press ${triggers}"),keyRockAnimation:At([NE("O")],"Rock Animation","Press ${triggers}"),keyToggleFlyMode:At([NE("Space",hd.create({shift:!0}))],"Toggle Fly Mode","Press ${triggers}"),keyResetView:At([NE("T")],"Reset View","Press ${triggers}")},Wit={bindings:C.Value(tle,{isHidden:!0})},$it=tr.create({name:"camera-controls",category:"interaction",ctor:class extends tr.Handler{register(){this.subscribeObservable(this.ctx.behaviors.interaction.key,({code:e,key:t,modifiers:n})=>{var r;if(!this.ctx.canvas3d)return;const i={...tle,...this.params.bindings},o=this.ctx.canvas3d.props.trackball;if(At.matchKey(i.keySpinAnimation,e,n,t)){const s="spin"!==o.animate.name?"spin":"off";this.ctx.canvas3d.setProps("off"===s?{trackball:{animate:{name:s,params:{}}}}:{trackball:{animate:{name:s,params:{speed:1}}}})}if(At.matchKey(i.keyRockAnimation,e,n,t)){const s="rock"!==o.animate.name?"rock":"off";this.ctx.canvas3d.setProps("off"===s?{trackball:{animate:{name:s,params:{}}}}:{trackball:{animate:{name:s,params:{speed:.3,angle:10}}}})}if(At.matchKey(i.keyToggleFlyMode,e,n,t)){const s=!o.flyMode;this.ctx.canvas3d.setProps({trackball:{flyMode:s}}),null!==(r=this.ctx.canvas3dContext)&&void 0!==r&&r.canvas&&(this.ctx.canvas3dContext.canvas.style.cursor=s?"crosshair":"unset")}At.matchKey(i.keyResetView,e,n,t)&&Cn.Camera.Reset(this.ctx,{})})}},params:()=>Wit,display:{name:"Camera Controls on Canvas"}}),Yit=tr.create({name:"structure-info-prop",category:"custom-props",display:{name:"Structure Info"},ctor:class extends tr.Handler{get maxModelIndex(){var e,t;let n=-1;const r=this.ctx.state.data.select(In.Generators.rootsOfType(pe.Molecule.Model));for(const i of r){const o=(null===(e=i.obj)||void 0===e?void 0:e.data)&&sn.Index.get(null===(t=i.obj)||void 0===t?void 0:t.data).value;void 0!==o&&o>n&&(n=o)}return n}get maxStructureIndex(){var e,t;let n=-1;const r=this.ctx.state.data.select(In.Generators.rootsOfType(pe.Molecule.Structure));for(const i of r){const o=(null===(e=i.obj)||void 0===e?void 0:e.data)&&Ve.Index.get(null===(t=i.obj)||void 0===t?void 0:t.data).value;void 0!==o&&o>n&&(n=o)}return n}get asymIdOffset(){var e;let t=0,n=0;const r=this.ctx.state.data.select(In.Generators.rootsOfType(pe.Molecule.Model));for(const i of r){const o=null===(e=i.obj)||void 0===e?void 0:e.data;if(o){const s=sn.AsymIdCount.get(o),a=sn.AsymIdOffset.get(o).value;void 0!==s&&void 0!==a&&(t=Math.max(t,a.auth+s.auth),n=Math.max(n,a.label+s.label))}}return{auth:t,label:n}}setModelMaxIndex(){var e;const t=this.maxModelIndex,n=this.ctx.state.data.select(In.Generators.rootsOfType(pe.Molecule.Model));for(const r of n){const i=null===(e=r.obj)||void 0===e?void 0:e.data;i&&sn.MaxIndex.get(i).value!==t&&sn.MaxIndex.set(i,{value:t},t)}}setStructureMaxIndex(){var e;const t=this.maxModelIndex,n=this.ctx.state.data.select(In.Generators.rootsOfType(pe.Molecule.Structure));for(const r of n){const i=null===(e=r.obj)||void 0===e?void 0:e.data;i&&Ve.MaxIndex.get(i).value!==t&&Ve.MaxIndex.set(i,{value:t},t)}}handleModel(e,t){if(void 0===sn.Index.get(e).value){const r=(t&&sn.Index.get(t).value)??this.maxModelIndex+1;sn.Index.set(e,{value:r},r)}if(void 0===sn.AsymIdOffset.get(e).value){const r=(t&&sn.AsymIdOffset.get(t).value)??{...this.asymIdOffset};sn.AsymIdOffset.set(e,{value:r},r)}}handleStructure(e,t){if(void 0!==e.parent||void 0!==Ve.Index.get(e).value)return;const r=(t&&Ve.Index.get(t).value)??this.maxStructureIndex+1;Ve.Index.set(e,{value:r},r)}handle(e,t,n){pe.Molecule.Structure.is(t)?!this.ctx.state.data.tree.transforms.get(e).transformer.definition.isDecorator&&void 0===t.data.parent&&this.handleStructure(t.data,n?.data):pe.Molecule.Model.is(t)&&(this.ctx.state.data.tree.transforms.get(e).transformer.definition.isDecorator||this.handleModel(t.data,n?.data))}register(){this.ctx.customModelProperties.register(sn.AsymIdOffset,!0),this.ctx.customModelProperties.register(sn.Index,!0),this.ctx.customModelProperties.register(sn.MaxIndex,!0),this.ctx.customStructureProperties.register(Ve.Index,!0),this.ctx.customStructureProperties.register(Ve.MaxIndex,!0),this.subscribeObservable(this.ctx.state.data.events.object.created,e=>{this.handle(e.ref,e.obj),this.setModelMaxIndex(),this.setStructureMaxIndex()}),this.subscribeObservable(this.ctx.state.data.events.object.updated,e=>{this.handle(e.ref,e.obj,e.oldObj)})}unregister(){this.ctx.customModelProperties.unregister(sn.AsymIdOffset.descriptor.name),this.ctx.customModelProperties.unregister(sn.Index.descriptor.name),this.ctx.customModelProperties.unregister(sn.MaxIndex.descriptor.name),this.ctx.customStructureProperties.unregister(Ve.Index.descriptor.name),this.ctx.customStructureProperties.unregister(Ve.MaxIndex.descriptor.name)}}}),Dm=[-1,1.76,1.87,1.65,1.5,1.4,1.85,1.8,1.6,1.4],nle={ALA:121,ARG:265,ASN:187,ASP:187,CYS:148,GLU:214,GLN:214,GLY:97,HIS:216,ILE:195,LEU:191,LYS:230,MET:203,PHE:228,PRO:154,SER:143,THR:163,TRP:264,TYR:255,VAL:165};function Zit(e,t,n){switch(t){case"O":return 5;case"S":return 6;case"N":return"NZ"===e?4:3;case"C":switch(e){case"C":case"CE1":case"CE2":case"CE3":case"CH2":case"CZ":case"CZ2":case"CZ3":return 1;case"CA":case"CB":case"CE":case"CG1":case"CG2":return 2;default:switch(n){case"PHE":case"TRP":case"TYR":case"HIS":case"ASP":case"ASN":return 1;case"PRO":case"LYS":case"ARG":case"MET":case"ILE":case"LEU":return 2;case"GLU":case"GLN":return"CD"===e?1:2}}}return Y8(t)}function Qit(e,t,n){switch(t){case"C":return 7;case"N":return 8;case"P":return 9;case"O":return 5}return Y8(t)}function Y8(e){const t=v2(e);let n=Dm.indexOf(t);return-1===n&&(n=Dm.length,Dm[n]=t),n}function X8(){return X8=ie(function*(e,t){const{atomRadiusType:n}=t;for(let r=0;rG[0]-L[0]);let F=0;e:for(let G=0;G$)continue e}++F}s[o[b]]+=c*F*M*M}}const ile={numberOfSpherePoints:C.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:C.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:C.Boolean(!1,{description:"Include non-polymer atoms as occluders."}),traceOnly:C.Boolean(!1,{description:"Compute only using alpha-carbons, if true increase probeSize accordingly (e.g., 4 A). Considers only canonical amino acids."})};var Zv;!function(e){function r(){return r=ie(function*(l,d,f){const p=function i(l,d){const{elementCount:f,atomicResidueCount:p}=l,{probeSize:m,nonPolymer:h,traceOnly:g,numberOfSpherePoints:y}=d;return{structure:l,probeSize:m,nonPolymer:h,traceOnly:g,spherePoints:o(y),scalingConstant:4*Math.PI/y,maxLookupRadius:2*d.probeSize+2*Dm[2],atomRadiusType:new Int8Array(f),serialResidueIndex:new Int32Array(f),area:new Float32Array(p)}}(d,f);(function Kit(e){const{key:t}=Ze.residue,{type_symbol:n,label_atom_id:r,label_comp_id:i}=Ze.atom,{structure:o,atomRadiusType:s,serialResidueIndex:a}=e,c=nt.create(o);let u=0,l=0,d=-1;c.structure=o;for(let f=0,p=0,m=o.units.length;f{if(!Ee.isAtomic(e.element.unit))return!1;const t=vl.get(e.element.structure).value;return!!t&&1===Zv.getFlag(e.element,t)}),isAccessible:kv.Dynamic(IQ("computed","accessible-surface-area.is-accessible",Ae.Bool),e=>{if(!Ee.isAtomic(e.element.unit))return!1;const t=vl.get(e.element.structure).value;return!!t&&2===Zv.getFlag(e.element,t)})},vl=vp.createProvider({label:"Accessible Surface Area",descriptor:au({name:"molstar_accessible_surface_area",symbols:Z8}),type:"root",defaultParams:K8,getParams:e=>K8,isApplicable:e=>!0,obtain:function(){var e=ie(function*(t,n,r){const i={...C.getDefaultValues(K8),...r};return{value:yield Zv.compute(n,i).runInContext(t.runtime)}});return function(n,r,i){return e.apply(this,arguments)}}()}),Q8=st(16448250),ole={list:C.ColorList("rainbow",{presetKind:"scale"})},ale={name:"accessible-surface-area",label:"Accessible Surface Area",category:Lc.Category.Residue,factory:function sle(e,t){let n;const r=Gu.create({listOrName:t.list.colors,minLabel:"buried",maxLabel:"exposed",domain:[0,1]}),i=e.structure&&vl.get(e.structure),o=i?Pg(i.id,i.version):-1;if(i?.value&&e.structure){const s=nt.create(e.structure),a=i.value,c=u=>{const l=Zv.getNormalizedValue(u,a);return-1===l?Q8:r.color(l)};n=u=>nt.is(u)&&Ee.isAtomic(u.unit)?c(u):Lt.isLocation(u)?(s.unit=u.aUnit,s.element=u.aUnit.elements[u.aIndex],c(s)):Q8}else n=()=>Q8;return{factory:sle,granularity:"group",preferSmoothing:!0,color:n,props:t,contextHash:o,description:"Assigns a color based on the relative accessible surface area of a residue.",legend:r?r.legend:void 0}},getParams:function not(e){return ole},defaultValues:C.getDefaultValues(ole),isApplicable:e=>!!e.structure,ensureCustomProperties:{attach:(e,t)=>t.structure?vl.attach(e,t.structure,void 0,!0):Promise.resolve(),detach:e=>e.structure&&vl.ref(e.structure,!1)}},rot=tr.create({name:"computed-accessible-surface-area-prop",category:"custom-props",display:{name:"Accessible Surface Area"},ctor:class extends tr.Handler{constructor(){super(...arguments),this.provider=vl,this.labelProvider={label:e=>{if(this.params.showTooltip)return function iot(e){if("element-loci"===e.kind){if(0===e.elements.length)return;const t=vl.get(e.structure).value;if(!t||e.structure.customPropertyDescriptors.hasReference(vl.descriptor))return;const{getSerialIndex:n}=e.structure.root.serialMapping,{area:r,serialResidueIndex:i}=t,o=new Set;let s=0;for(const{indices:c,unit:u}of e.elements){const{elements:l}=u;Fe.forEach(c,d=>{const f=i[n(u,l[d])];-1!==f&&!o.has(f)&&(s+=r[f],o.add(f))})}return 0===o.size?void 0:`Accessible Surface Area (${o.size} ${o.size>1?"Residues sum":"Residue"}): ${s.toFixed(2)} \u212b2`}if("structure-loci"===e.kind){const t=vl.get(e.structure).value;return!t||e.structure.customPropertyDescriptors.hasReference(vl.descriptor)?void 0:`Accessible Surface Area (Whole Structure): ${OZ(t.area).toFixed(2)} \u212b2`}}(e)}}}update(e){const t=this.params.autoAttach!==e.autoAttach||this.params.showTooltip!==e.showTooltip;return this.params.autoAttach=e.autoAttach,this.params.showTooltip=e.showTooltip,this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name,this.params.autoAttach),t}register(){qD.addCustomProp(this.provider.descriptor),this.ctx.customStructureProperties.register(this.provider,this.params.autoAttach),this.ctx.representation.structure.themes.colorThemeRegistry.add(ale),this.ctx.managers.lociLabels.addProvider(this.labelProvider),this.ctx.query.structure.registry.add(cle),this.ctx.query.structure.registry.add(ule)}unregister(){qD.removeCustomProp(this.provider.descriptor),this.ctx.customStructureProperties.unregister(this.provider.descriptor.name),this.ctx.representation.structure.themes.colorThemeRegistry.remove(ale),this.ctx.managers.lociLabels.removeProvider(this.labelProvider),this.ctx.query.structure.registry.remove(cle),this.ctx.query.structure.registry.remove(ule)}},params:()=>({autoAttach:C.Boolean(!1),showTooltip:C.Boolean(!0)})}),cle=lr("Buried Protein Residues",ue.struct.modifier.union([ue.struct.modifier.wholeResidues([ue.struct.modifier.union([ue.struct.generator.atomGroups({"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":Z8.isBuried.symbol()})])])]),{description:"Select buried protein residues.",category:pr.Residue,ensureCustomProperties:(e,t)=>vl.attach(e,t)}),ule=lr("Accessible Protein Residues",ue.struct.modifier.union([ue.struct.modifier.wholeResidues([ue.struct.modifier.union([ue.struct.generator.atomGroups({"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":Z8.isAccessible.symbol()})])])]),{description:"Select accessible protein residues.",category:pr.Residue,ensureCustomProperties:(e,t)=>vl.attach(e,t)});function or(e,t){return e.model.atomicHierarchy.atoms.type_symbol.value(e.elements[t])}function lle(e,t){return e.model.atomicHierarchy.atoms.pdbx_formal_charge.value(e.elements[t])}function tC(e,t){return e.model.atomicHierarchy.atoms.label_atom_id.value(e.elements[t])}function FE(e,t){return e.model.atomicHierarchy.atoms.label_alt_id.value(e.elements[t])}function J8(e,t){return e.model.atomicHierarchy.atoms.label_comp_id.value(e.elements[t])}function Ef(e,t,n){return function oot(e,t,n){let r=0;const i=e.interUnitBonds.getEdgeIndices(n,t.id);for(let o=0,s=i.length;o{or(o,s)===r&&(i+=1)}),i}function eU(e,t,n){const{offset:r,b:i,edgeProps:{flags:o}}=e.bonds;for(let s=r[t],a=r[t+1];s{"H"!==or(s,a)&&(s.conformation.position(s.elements[a],Jv),v.sub(OE,Jv,k0),o.push(v.angle(BE,OE)))}),o}function fle(e,t,n,r,i){t.conformation.position(t.elements[n],k0),r.conformation.position(r.elements[i],LE),v.sub(BE,LE,k0);const o=[v(),v()];let a,c,s=0;if(dc(e,t,n,(u,l)=>{s>1||"H"!==or(u,l)&&(a=u,c=l,u.conformation.position(u.elements[l],Jv),v.sub(o[s++],Jv,k0))}),1===s&&a&&c&&dc(e,a,c,(u,l)=>{s>1||u===t&&l===n||"H"!==or(u,l)&&(u.conformation.position(u.elements[l],Jv),v.sub(o[s++],Jv,k0))}),2===s)return v.cross(OE,o[0],o[1]),Math.abs(Math.PI/2-v.angle(OE,BE))}const tU=new Lt.ElementBondIterator,nU=new Lt.ElementBondIterator,e1=new Lt.ElementBondIterator,rU=new Lt.ElementBondIterator;function hot(e,t,n,r){const i=lc(e,t,n,"H"),o=or(t,n);let s=lle(t,n);const a="always"===r.assignCharge||"auto"===r.assignCharge&&0===s,c="always"===r.assignH||"auto"===r.assignH&&0===i,u=Ef(e,t,n),l=function pot(e,t,n){let r=0;const{offset:i,edgeProps:{flags:o,order:s}}=t.bonds;for(let a=i[n],c=i[n+1];a{const c=e.interUnitBonds.edges[a];jn.isCovalent(c.props.flag)&&(r+=c.props.order)}),r}(e,t,n),d=function fot(e,t,n){const r=or(t,n),i="O"===r||"N"===r;if(i&&4===Ef(e,t,n))return!1;for(tU.setElement(e,t,n);tU.hasNext;){const o=tU.move();if(o.order>1)return!0;if(i){const s=or(o.otherUnit,o.otherIndex);for(nU.setElement(e,o.otherUnit,o.otherIndex);nU.hasNext;){const a=nU.move();if(a.order>1){if(("P"===s||"S"===s)&&"O"===or(a.otherUnit,a.otherIndex))continue;return!0}}}}return!1}(e,t,n),f=l-u>0;let p=0,m=wi.Unknown;switch(o){case"H":a&&(0===u?(s=1,m=wi.Spherical):1===u&&(s=0,m=wi.Terminal));break;case"C":a&&(s=0),c&&(p=Math.max(0,4-l-Math.abs(s))),m=Qv(u+p+Math.max(0,-s));break;case"N":if(a)if(c)if(d&&l<4)s=u-i==1&&l-i==2?1:0;else for(e1.setElement(e,t,n);e1.hasNext;){const h=e1.move(),g=or(h.otherUnit,h.otherIndex);if("S"===g||C$e(g)){s=0;break}s=1}else s=l-3;c&&(p=Math.max(0,3-l+s)),m=Qv(d&&!f?u+p-s:u+p+1-s);break;case"O":if(a&&(c||(s=l-2),1===l)){e1.setElement(e,t,n);e:for(;e1.hasNext;){const h=e1.move();for(rU.setElement(e,h.otherUnit,h.otherIndex);rU.hasNext;){const g=rU.move();if((g.otherUnit!==t||g.otherIndex!==n)&&"O"===or(g.otherUnit,g.otherIndex)&&2===g.order){s=-1;break e}}}}c&&(p=Math.max(0,2-l+s)),m=Qv(d&&!f?u+p-s+1:u+p-s+2);break;case"S":a&&(c||(s=l<=3&&0===lc(e,t,n,"O")?l-2:0)),c&&l<2&&(p=Math.max(0,2-l+s)),l<=3&&(m=Qv(u+p-s+2));break;case"F":case"CL":case"BR":case"I":case"AT":a&&(s=l-1);break;case"LI":case"NA":case"K":case"RB":case"CS":case"FR":a&&(s=1-l);break;case"BE":case"MG":case"CA":case"SR":case"BA":case"RA":a&&(s=2-l);break;default:un&&console.warn("Requested charge, protonation for an unhandled element",o)}return[s,p,p+i,m]}function mot(e,t,n){const r=t.elements.length,i=new Int8Array(r),o=new Int8Array(r),s=new Int8Array(r),a=new Int8Array(r),c=!!e.parent;let u;if(c){const l=e.root.unitMap.get(t.id);if(u=je.indicesOf(l.elements,t.elements),u.length!==t.elements.length)throw new Error("expected to find an index for every element");t=l,e=e.root}for(let l=0;loU,isApplicable:e=>!0,obtain:function(){var e=ie(function*(t,n,r){const i={...C.getDefaultValues(oU),...r};return{value:yield got(t.runtime,n,i)}});return function(n,r,i){return e.apply(this,arguments)}}()});var Ai,sU,aU;!function(e){function n(d,f){const p=new Int32Array(f+1),m=new Int32Array(f),h=new Int32Array(f),{members:g,count:y,offsets:b}=d;for(let S=0,A=b[y];Si(f,h)}},e.createSubset=i,e.Info=function o(d,f,p){const m=nC.get(d).value;if(!m||!m.has(f.id))throw new Error("valence model required");return{unit:f,types:p.types,feature:-1,x:p.x,y:p.y,z:p.z,members:p.members,offsets:p.offsets,idealGeometry:m.get(f.id).idealGeometry}},e.position=function s(d,f){return v.set(d,f.x[f.feature],f.y[f.feature],f.z[f.feature]),v.transformMat4(d,d,f.unit.conformation.operator.matrix),d};const a=v(),c=v();e.distance=function u(d,f){const m=f.members[f.offsets[f.feature]];return d.unit.conformation.position(d.unit.elements[d.members[d.offsets[d.feature]]],a),f.unit.conformation.position(f.unit.elements[m],c),v.distance(a,c)},e.Provider=function l(d,f){return{types:new Set(d),add:f}}}(Ai||(Ai={})),function(e){e.create=function t(n=2048,r=1024,i){const o=ze.create(Float32Array,1,r,i?i.x:n),s=ze.create(Float32Array,1,r,i?i.y:n),a=ze.create(Float32Array,1,r,i?i.z:n),c=ze.create(Uint8Array,1,r,i?i.types:n),u=ze.create(Uint8Array,1,r,i?i.groups:n),l=ze.create(Uint32Array,1,r,i?i.offsets:n),d=ze.create(Uint32Array,1,r,i?i.members:n),f={x:0,y:0,z:0,offset:0,count:0};return{startState:()=>{f.x=0,f.y=0,f.z=0,f.offset=d.elementCount,f.count=0},pushMember:(p,m,h,g)=>{ze.add(d,g),f.x+=p,f.y+=m,f.z+=h,f.count+=1},finishState:(p,m)=>{const{count:h}=f;0!==h&&(ze.add(c,p),ze.add(u,m),ze.add(o,f.x/h),ze.add(s,f.y/h),ze.add(a,f.z/h),ze.add(l,f.offset))},add:(p,m,h,g,y,b)=>{ze.add(c,p),ze.add(u,m),ze.add(o,h),ze.add(s,g),ze.add(a,y),ze.add(l,d.elementCount),ze.add(d,b)},getFeatures:p=>{ze.add(l,d.elementCount);const m=ze.compact(o,!0),h=ze.compact(s,!0),g=ze.compact(a,!0);return Ai.create(p,{x:m,y:h,z:g,count:o.elementCount,types:ze.compact(c,!0),groups:ze.compact(u,!0),offsets:ze.compact(l,!0),members:ze.compact(d,!0)})}}}}(sU||(sU={})),function(e){e.createElementsIndex=function t(n,r,i){const o=new Int32Array(i+1),s=new Int32Array(i),a=new Int32Array(i),{members:c,offsets:u}=r;for(let f=0,p=2*n.edgeCount;fh)){for(let g=u[m],y=u[m+1];gh)){for(let g=u[m],y=u[m+1];gd||(d=aU.createElementsIndex(l,n,r))})}}}}(cU||(cU={})),function(e){e.create=function t(){const n=new ju.Builder;return{startUnitPair(r,i){n.startUnitPair(r.id,i.id)},finishUnitPair(){n.finishUnitPair()},add(r,i,o){n.add(r,i,{type:o,flag:Pf.None})},getContacts:r=>new yot(n.getMap(),r)}}}(uU||(uU={}));const xot={lineOfSightDistFactor:C.Numeric(1,{min:0,max:3,step:.1})},Sot=3;function mle(e,t,n){const r=t.members[t.offsets[t.feature]],i=n.members[n.offsets[n.feature]];if(r===i&&t.unit===n.unit)return!1;const o=FE(t.unit,r),s=FE(n.unit,i);return!(o&&s&&o!==s||t.unit===n.unit&&t.unit.model.atomicHierarchy.residueAtomSegments.count>1&&t.unit.residueIndex[t.unit.elements[r]]===n.unit.residueIndex[n.unit.elements[i]]||function uot(e,t,n,r,i){return t===r?function aot(e,t,n){const{offset:r,b:i,edgeProps:{flags:o}}=e.bonds;for(let s=r[t],a=r[t+1];s{Rot.includes(or(d,f))&&(l=!0)}),l&&n.add(7,Ir.None,i[r[a]],o[r[a]],s[r[a]],a)}}}),zot={name:"halogen-bonds",params:Dot,createTester:e=>{const t=function Oot(e){return{angleMax:Yn(e.angleMax)}}(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([6,7]),getType:(n,r,i)=>function Lot(e,t,n,r){const i=t.types[t.feature];if(!function Not(e,t){return 7===e&&6===t||6===e&&7===t}(i,n.types[n.feature]))return;const[s,a]=6===i?[t,n]:[n,t],c=s.members[s.offsets[s.feature]],u=a.members[a.offsets[a.feature]],l=UE(e,s.unit,c,a.unit,u);if(1!==l.length||Fot-l[0]>r.angleMax)return;const d=UE(e,a.unit,u,s.unit,c);return 0===d.length||d.some(f=>Bot-f>r.angleMax)?void 0:kn.HalogenBond}(n,r,i,t)}}},vle={distanceMax:C.Numeric(3.5,{min:1,max:5,step:.1}),backbone:C.Boolean(!0,{description:"Include backbone-to-backbone hydrogen bonds"}),accAngleDevMax:C.Numeric(45,{min:0,max:180,step:1},{description:"Max deviation from ideal acceptor angle"}),donAngleDevMax:C.Numeric(45,{min:0,max:180,step:1},{description:"Max deviation from ideal donor angle"}),accOutOfPlaneAngleMax:C.Numeric(90,{min:0,max:180,step:1}),donOutOfPlaneAngleMax:C.Numeric(45,{min:0,max:180,step:1})},Got={...vle,water:C.Boolean(!1,{description:"Include water-to-water hydrogen bonds"}),sulfurDistanceMax:C.Numeric(4.1,{min:1,max:5,step:.1})},jot={...vle};function fU(e,t){const n=nC.get(e).value;if(!n)throw Error("expected valence model to be available");const r=n.get(t.id);if(!r)throw Error("expected valence model for unit to be available");return r}function Wot(e,t){const{elementAromaticRingIndices:n,all:r}=e.rings,i=n.get(t);if(void 0===i)return!1;for(let o=0,s=i.length;oMath.abs(a-l)>r.maxDonAngleDev))return;if(t.idealGeometry[i]===wi.Trigonal){const l=fle(e,t.unit,i,n.unit,o);if(void 0!==l&&l>r.maxDonOutOfPlaneAngle)return}const c=UE(e,n.unit,o,t.unit,i),u=dle.get(n.idealGeometry[o])||wle;if(!c.some(l=>u-l>r.maxAccAngleDev)){if(n.idealGeometry[o]===wi.Trigonal){const l=fle(e,n.unit,o,t.unit,i);if(void 0!==l&&l>r.maxAccOutOfPlaneAngle)return}return!0}}const nst=Ai.Provider([4],function Hot(e,t,n){const{totalH:r}=fU(e,t),{elements:i}=t,{x:o,y:s,z:a}=t.model.atomicConformation;for(let c=0,u=i.length;c0&&("N"===l||"O"===l||"S"===l))&&n.add(4,Ir.None,o[i[c]],s[i[c]],a[i[c]],c)}}),rst=Ai.Provider([9],function qot(e,t,n){const{totalH:r}=fU(e,t),{elements:i}=t,{x:o,y:s,z:a}=t.model.atomicConformation;for(let c=0,u=i.length;c0&&(lc(e,t,c,"N")>0||lc(e,t,c,"O")>0||Wot(t,c))&&n.add(9,Ir.None,o[i[c]],s[i[c]],a[i[c]],c)}),ist=Ai.Provider([5],function $ot(e,t,n){const{charge:r,implicitH:i,idealGeometry:o}=fU(e,t),{elements:s}=t,{x:a,y:c,z:u}=t.model.atomicConformation,l=d=>{n.add(5,Ir.None,a[s[d]],c[s[d]],u[s[d]],d)};for(let d=0,f=s.length;d{const t=Math.max(e.distanceMax,e.sulfurDistanceMax),n=function Jot(e){return{...Cle(e),includeWater:e.water,maxSulfurDistSq:e.sulfurDistanceMax*e.sulfurDistanceMax,maxDistSq:e.distanceMax*e.distanceMax}}(e);return{maxDistance:t,requiredFeatures:new Set([4,5]),getType:(r,i,o,s)=>function est(e,t,n,r,i){const s=n.types[n.feature];if(!function Zot(e,t){return 5===e&&4===t||4===e&&5===t}(t.types[t.feature],s))return;const[a,c]=5===s?[t,n]:[n,t],u=a.members[a.offsets[a.feature]],l=c.members[c.offsets[c.feature]];return r>("S"===or(a.unit,u)||"S"===or(c.unit,l)?i.maxSulfurDistSq:i.maxDistSq)||!i.includeWater&&function Kot(e,t,n,r){return _le(e,t)&&_le(n,r)}(a.unit,u,c.unit,l)||!Ale(e,a,c,i)?void 0:kn.HydrogenBond}(r,i,o,s,n)}}},sst={name:"weak-hydrogen-bonds",params:jot,createTester:e=>{const t=Cle(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([9,5]),getType:(n,r,i,o)=>function tst(e,t,n,r,i){const s=n.types[n.feature];if(!function Qot(e,t){return 9===e&&5===t||5===e&&9===t}(t.types[t.feature],s))return;const[a,c]=5===s?[t,n]:[n,t];return Ale(e,a,c,i)?kn.WeakHydrogenBond:void 0}(n,r,i,0,t)}}};function cst(e,t,n){return"S"===or(t,n)&&3===lc(e,t,n,"O")}function ust(e,t,n){return"S"===or(t,n)&&4===lc(e,t,n,"O")}function Tle(e,t,n){return"P"===or(t,n)&&lc(e,t,n,"O")===Ef(e,t,n)}function dst(e,t,n){let r=0;return"C"===or(t,n)&&2===lc(e,t,n,"O")&&1===lc(e,t,n,"C")&&dc(e,t,n,(i,o)=>{"O"===or(i,o)&&Ef(e,i,o)-lc(e,i,o,"H")==1&&(r+=1)}),2===r}function fst(e,t,n){let r=0;return"C"===or(t,n)&&3===Ef(e,t,n)&&3===lc(e,t,n,"N")&&dc(e,t,n,(i,o)=>{Ef(e,i,o)-lc(e,i,o,"H")==1&&(r+=1)}),2===r}function pst(e,t,n){let r=0;return"C"===or(t,n)&&3===Ef(e,t,n)&&2===lc(e,t,n,"N")&&1===lc(e,t,n,"C")&&dc(e,t,n,(i,o)=>{Ef(e,i,o)-lc(e,i,o,"H")==1&&(r+=1)}),2===r}const hst=new Set(["N","O","S","F","CL","BR","I"]);const yst={distanceMax:C.Numeric(5,{min:0,max:8,step:.1})},bst={distanceMax:C.Numeric(5.5,{min:1,max:8,step:.1}),offsetMax:C.Numeric(2,{min:0,max:4,step:.1}),angleDevMax:C.Numeric(30,{min:0,max:180,step:1})},vst={distanceMax:C.Numeric(6,{min:1,max:8,step:.1}),offsetMax:C.Numeric(2,{min:0,max:4,step:.1})},_st=["ARG","HIS","LYS"],xst=["GLU","ASP"];function Dle(e,t){const n=nC.get(e).value;if(!n)throw Error("expected valence model to be available");const r=n.get(t.id);if(!r)throw Error("expected valence model for unit to be available");return r}const Ele=v(),Ple=v(),VE=v(),t1=v(),zE=v(),GE=v();function pU(e,t){const{unit:n,feature:r,offsets:i,members:o}=t,{elements:s}=n,a=i[r];return t.unit.conformation.position(s[o[a]],VE),t.unit.conformation.position(s[o[a+1]],t1),t.unit.conformation.position(s[o[a+2]],zE),v.triangleNormal(e,VE,t1,zE)}const hU=function(e,t,n){return Ai.position(VE,e),Ai.position(t1,t),v.sub(zE,VE,t1),v.projectOnPlane(GE,zE,n),v.add(GE,GE,t1),v.distance(GE,t1)},Rst=Yn(180),Mle=Yn(90),rC=v(),mU=v();const Bst=Ai.Provider([2],function Cst(e,t,n){const{charge:r}=Dle(e,t),{elements:i}=t,{x:o,y:s,z:a}=t.model.atomicConformation,c=new Set,{label_comp_id:u}=t.model.atomicHierarchy.atoms,l=en.transientSegments(t.model.atomicHierarchy.residueAtomSegments,i);for(;l.hasNext;){const{index:d,start:f,end:p}=l.move(),m=u.value(t.model.atomicHierarchy.residueAtomSegments.offsets[d]);if(xst.includes(m)){n.startState();for(let h=f;h{"O"===or(t,y)&&n.pushMember(o[i[y]],s[i[y]],a[i[y]],y)}),n.finishState(2,Ir.Phosphate));else if(!Wb.has(m)){for(let h=f;h{"O"===or(t,b)&&(c.add(b),n.pushMember(o[i[b]],s[i[b]],a[i[b]],b))}),n.finishState(2,g))}for(let h=f;h{"N"===or(t,b)&&(c.add(b),n.pushMember(o[i[b]],s[i[b]],a[i[b]],b))}),n.finishState(1,g))}for(let h=f;h0&&!c.has(h)&&n.add(1,Ir.None,o[i[h]],s[i[h]],a[i[h]],h)}}}),Lst=Ai.Provider([3],function wst(e,t,n){const{elements:r}=t,{x:i,y:o,z:s}=t.model.atomicConformation;for(const a of t.rings.aromaticRings){const c=t.rings.all[a];n.startState();for(let u=0,l=c.length;u{const t=function Est(e){return{distanceMaxSq:e.distanceMax*e.distanceMax}}(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([2,1]),getType:(n,r,i,o)=>function kst(e,t,n,r,i){if(function Ast(e,t){return 2===e&&1===t||1===e&&2===t}(t.types[t.feature],n.types[n.feature])&&function Dst(e,t,n){const{feature:r,offsets:i,members:o}=e,{feature:s,offsets:a,members:c}=t;for(let u=i[r],l=i[r+1];u{const t=function Pst(e){return{offsetMax:e.offsetMax,angleDevMax:Yn(e.angleDevMax)}}(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([3]),getType:(n,r,i,o)=>function Nst(e,t,n,r,i){if(function Ist(e,t){return 3===e&&3===t}(t.types[t.feature],n.types[n.feature])){pU(rC,t),pU(mU,n);const a=v.angle(rC,mU);if(Math.min(hU(t,n,mU),hU(n,t,rC))<=i.offsetMax){if(a<=i.angleDevMax||a>=Rst-i.angleDevMax)return kn.PiStacking;if(a<=i.angleDevMax+Mle&&a>=Mle-i.angleDevMax)return kn.PiStacking}}}(0,r,i,0,t)}}},zst={name:"cation-pi",params:vst,createTester:e=>{const t=function Mst(e){return{offsetMax:e.offsetMax}}(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([3,1]),getType:(n,r,i,o)=>function Fst(e,t,n,r,i){const o=t.types[t.feature];if(function Tst(e,t){return 3===e&&1===t||1===e&&3===t}(o,n.types[n.feature])){const[a,c]=3===o?[t,n]:[n,t];if(pU(rC,a),hU(c,a,rC)<=i.offsetMax)return kn.CationPi}}(0,r,i,0,t)}}},Gst={distanceMax:C.Numeric(4,{min:1,max:5,step:.1})},Wst=Ai.Provider([8],function jst(e,t,n){const{elements:r}=t,{x:i,y:o,z:s}=t.model.atomicConformation;for(let a=0,c=r.length;a{const p=or(d,f);"C"!==p&&"H"!==p&&(l=!1)})):"F"===u&&(l=!0),l&&n.add(8,Ir.None,i[r[a]],o[r[a]],s[r[a]],a)}}),$st={name:"hydrophobic",params:Gst,createTester:e=>({maxDistance:e.distanceMax,requiredFeatures:new Set([8]),getType:(t,n,r,i)=>function qst(e,t,n,r){if(!function Hst(e,t){return 8===e&&8===t}(t.types[t.feature],n.types[n.feature]))return;const a=n.members[n.offsets[n.feature]];return"F"!==or(t.unit,t.members[t.offsets[t.feature]])||"F"!==or(n.unit,a)?kn.Hydrophobic:void 0}(0,n,r)})},Yst={distanceMax:C.Numeric(3,{min:1,max:5,step:.1})},Xst=["LI","NA","K","RB","CS","MG","CA","SR","BA","AL","GA","IN","TL","SC","SN","PB","BI","SB","HG"];function Rle(e){return!lp.has(e)}function Zst(e){return lp.has(e)}function Qst(e){return JI.has(e)}function kle(e,t){return 12===e?11===t||12===t:13===e?10===t:void 0}const tat=Ai.Provider([13,12],function Kst(e,t,n){const{elements:r}=t,{x:i,y:o,z:s}=t.model.atomicConformation;for(let a=0,c=r.length;a({maxDistance:e.distanceMax,requiredFeatures:new Set([13,12,10,11]),getType:(t,n,r,i)=>function eat(e,t,n,r){const i=t.types[t.feature],o=n.types[n.feature];if(kle(i,o)||kle(o,i))return kn.MetalCoordination}(0,n,r)})};function oat(e,t){const{contacts:n}=t,r=function(u,l,d,f,p){const[m,h]=f.get(d)||[1/0,-1];un.edges[u].props.flag=Pf.Filtered;let a,c;return{isApplicable:u=>u===kn.Hydrophobic,handleInterContact:(u,l,d)=>{i(u,l,d,o,s)},startUnit:(u,l,d)=>{a=new Map,c=f=>l.edgeProps.flag[f]=Pf.Filtered},handleIntraContact:(u,l,d)=>{i(u,l,d,a,c)}}}function sat(e,t){const{contacts:n}=t,r=(i,o)=>{const s=9===i.types[i.feature]?o:i,a=s.members[s.offsets[s.feature]],{edgeProps:{type:c},elementsIndex:{offsets:u,indices:l}}=t.unitsContacts.get(s.unit.id);for(let f=u[a],p=u[a+1];fi===kn.WeakHydrogenBond,handleInterContact:(i,o,s)=>{r(o,s)&&(n.edges[i].props.flag=Pf.Filtered)},startUnit:()=>{},handleIntraContact:(i,o,s)=>{if(r(o,s)){const{flag:a}=t.unitsContacts.get(o.unit.id).edgeProps;a[i]=Pf.Filtered}}}}function gU(e,t,n,r,i){const{offsets:o,feature:s}=n,{offsets:a,feature:c}=r;for(let u=o[s],l=o[s+1];ur===kn.Ionic,handleInterContact:(r,i,o)=>{gU([kn.HydrogenBond,kn.WeakHydrogenBond],r,i,o,n)},startUnit:()=>{},handleIntraContact:(r,i,o)=>{yU([kn.HydrogenBond,kn.WeakHydrogenBond],r,i,o,t.unitsContacts.get(i.unit.id))}}}function cat(e,t){const{contacts:n}=t;return{isApplicable:r=>r===kn.Hydrophobic||r===kn.CationPi,handleInterContact:(r,i,o)=>{gU([kn.PiStacking],r,i,o,n)},startUnit:()=>{},handleIntraContact:(r,i,o)=>{yU([kn.PiStacking],r,i,o,t.unitsContacts.get(i.unit.id))}}}function uat(e,t){const{contacts:n}=t;return{isApplicable:r=>r===kn.Ionic,handleInterContact:(r,i,o)=>{gU([kn.MetalCoordination],r,i,o,n)},startUnit:()=>{},handleIntraContact:(r,i,o)=>{yU([kn.MetalCoordination],r,i,o,t.unitsContacts.get(i.unit.id))}}}var nh;!function(e){function i(l,d){const{unitA:f,indexA:p,unitB:m,indexB:h}=d,{contacts:g,unitsContacts:y}=l;if(f===m){const b=y.get(f.id),x=b.getDirectedEdgeIndex(p,h);return hle(b.edgeProps.type[x])}{const b=g.getEdgeIndex(p,f.id,h,m.id);return hle(g.edges[b].props.type)}}function c(l,d,f){const{unitsFeatures:p}=l;return Og.fromPairProvider(d.length,(m,h,g)=>{const y=d[m];Ai.setPosition(h,y.unitA,y.indexA,p.get(y.unitA.id)),Ai.setPosition(g,y.unitB,y.indexB,p.get(y.unitB.id))},f)}function u(l,d,f){const p=f[0];if(void 0===p)return"";const{unitA:m,indexA:h,unitB:g,indexB:y}=p,{unitsFeatures:b}=d,{members:x,offsets:_}=b.get(m.id),{members:S,offsets:A}=b.get(g.id),E={granularity:"element"};return(_[h+1]-_[h]>1||A[y+1]-A[y]>1)&&(E.granularity="residue"),[i(d,p),u8(Lt.Location(l,m,x[_[h]],l,g,S[A[y]]),E)].join("
")}e.Location=function t(l,d,f,p,m,h){return yre("interactions",{structure:d,interactions:l},{unitA:f,indexA:p,unitB:m,indexB:h})},e.isLocation=function n(l){return!!l&&"data-location"===l.kind&&"interactions"===l.tag},e.areLocationsEqual=function r(l,d){return l.data.structure===d.data.structure&&l.data.interactions===d.data.interactions&&l.element.indexA===d.element.indexA&&l.element.indexB===d.element.indexB&&l.element.unitA===d.element.unitA&&l.element.unitB===d.element.unitB},e.locationLabel=function o(l){return i(l.data.interactions,l.element)},e.Loci=function s(l,d,f){return nE("interactions",{structure:l,interactions:d},f,p=>c(d,f,p),()=>u(l,d,f))},e.isLoci=function a(l){return!!l&&"data-loci"===l.kind&&"interactions"===l.tag},e.getBoundingSphere=c,e.getLabel=u}(nh||(nh={}));const lat=[nst,rst,ist,Bst,Ost,Lst,Uot,Vot,Wst,tat,nat],jE={ionic:Ust,"pi-stacking":Vst,"cation-pi":zst,"halogen-bonds":zot,"hydrogen-bonds":ost,"weak-hydrogen-bonds":sst,hydrophobic:$st,"metal-coordination":rat},fat=function dat(e=[]){const t=Object.create(null);return Object.keys(jE).forEach(n=>{t[n]=C.MappedStatic(e.includes(n)?"on":"off",{on:C.Group(jE[n].params),off:C.Group({})},{cycle:!0})}),t}(["cation-pi","pi-stacking","hydrogen-bonds","halogen-bonds","metal-coordination"]),Nle={providers:C.Group(fat,{isFlat:!0}),contacts:C.Group(xot,{label:"Advanced Options"})};function pat(e,t,n){return bU.apply(this,arguments)}function bU(){return bU=ie(function*(e,t,n){const r={...C.getDefaultValues(Nle),...n};yield nC.attach(e,t);const i=[];NI(jE).forEach(d=>{const{name:f,params:p}=r.providers[d];"on"===f&&i.push(jE[d].createTester(p))});const o=new Set;i.forEach(d=>Si.add(o,d.requiredFeatures));const s=lat.filter(d=>Si.areIntersecting(o,d.types)),a=Lu.Mutable(),c=Lu.Mutable();for(let d=0,f=t.unitSymmetryGroups.length;d{const a=t.get(o.id),c=t.get(s.id);!function Tot(e,t,n,r,i,o,s,a){const{count:c,x:u,y:l,z:d}=n,{lookup3d:f}=i,p=le.mul(Iot,r.conformation.operator.inverse,t.conformation.operator.matrix),m=!le.isIdentity(p),h=v(),g=Math.max(...s.map(E=>E.maxDistance)),{center:y,radius:b}=f.boundary.sphere,x=(b+g)*(b+g),_=a.lineOfSightDistFactor,S=Ai.Info(e,t,n),A=Ai.Info(e,r,i);o.startUnitPair(t,r);for(let E=0;Ex)continue;const{indices:w,count:D,squaredDistances:I}=f.find(h[0],h[1],h[2],g);if(0!==D){S.feature=E;for(let R=0;Ro.maxDistance)),validUnit:o=>Ee.isAtomic(o),validUnitPair:(o,s)=>Ve.validUnitPair(e,o,s)}),i.getContacts(t)}(t,a,i,r.contacts),l={unitsFeatures:a,unitsContacts:c,contacts:u};return function iat(e,t){const{contacts:n,unitsContacts:r,unitsFeatures:i}=t,o=[oat(0,t),sat(0,t),aat(0,t),cat(0,t),uat(0,t)];for(let a=0,c=n.edgeCount;avU,isApplicable:e=>!e.isCoarseGrained,obtain:function(){var e=ie(function*(t,n,r){const i={...C.getDefaultValues(vU),...r};return{value:yield pat(t,n,i)}});return function(n,r,i){return e.apply(this,arguments)}}()}),_U=st(13421772),Ea_HydrogenBond=2851770,Ea_Hydrophobic=8421504,Ea_HalogenBond=4259775,Ea_Ionic=15779860,Ea_MetalCoordination=9191577,Ea_CationPi=16744448,Ea_PiStacking=9220966,Ea_WeakHydrogenBond=12967404,bat=[["Hydrogen Bond",Ea_HydrogenBond],["Hydrophobic",Ea_Hydrophobic],["Halogen Bond",Ea_HalogenBond],["Ionic",Ea_Ionic],["Metal Coordination",Ea_MetalCoordination],["Cation Pi",Ea_CationPi],["Pi Stacking",Ea_PiStacking],["Weak HydrogenBond",Ea_WeakHydrogenBond]];function Fle(e){switch(e){case kn.HydrogenBond:return Ea_HydrogenBond;case kn.Hydrophobic:return Ea_Hydrophobic;case kn.HalogenBond:return Ea_HalogenBond;case kn.Ionic:return Ea_Ionic;case kn.MetalCoordination:return Ea_MetalCoordination;case kn.CationPi:return Ea_CationPi;case kn.PiStacking:return Ea_PiStacking;case kn.WeakHydrogenBond:return Ea_WeakHydrogenBond;case kn.Unknown:return _U}}const Ble={},xU={name:"interaction-type",label:"Interaction Type",category:Lc.Category.Misc,factory:function Ole(e,t){let n;const r=e.structure?Qi.get(e.structure):void 0,i=r?Pg(r.id,r.version):-1;return n=r&&r.value?o=>{if(nh.isLocation(o)){const{unitsContacts:s,contacts:a}=o.data.interactions,{unitA:c,unitB:u,indexA:l,indexB:d}=o.element;if(c===u){const f=s.get(c.id),p=f.getDirectedEdgeIndex(l,d);return Fle(f.edgeProps.type[p])}{const f=a.getEdgeIndex(l,c.id,d,u.id);return Fle(a.edges[f].props.type)}}return _U}:()=>_U,{factory:Ole,granularity:"group",color:n,props:t,contextHash:i,description:"Assigns colors according the interaction type of a link.",legend:$h(bat)}},getParams:function vat(e){return Ble},defaultValues:C.getDefaultValues(Ble),isApplicable:e=>!!e.structure,ensureCustomProperties:{attach:(e,t)=>t.structure?Qi.attach(e,t.structure,void 0,!0):Promise.resolve(),detach:e=>e.structure&&Qi.ref(e.structure,!1)}};function Iu(e,t,n,r){let i=0;const{webgl:o}=t,s=new mr,a=new yn.GeometryState,c=Hp(),u=[],l=ms.create();let d,f,p,m,h=Fo.createEmpty();function S(w){if(ms.update(l,w),void 0!==w.visible&&d&&d.setVisibility(w.visible&&(null===l.unitTransforms||l.unitTransforms.isIdentity)),void 0!==w.alphaFactor&&d&&d.setAlphaFactor(w.alphaFactor),void 0!==w.pickable&&d&&d.setPickable(w.pickable),void 0!==w.overpaint&&d){const D=Bo.remap(w.overpaint,f);d.setOverpaint(D,o)}if(void 0!==w.transparency&&d){const D=Vs.remap(w.transparency,f);d.setTransparency(D,o)}if(void 0!==w.substance&&d){const D=zs.remap(w.substance,f);d.setSubstance(D,o)}if(void 0!==w.clipping&&d){const D=Yr.remap(w.clipping,f);d.setClipping(D)}void 0!==w.themeStrength&&d&&d.setThemeStrength(w.themeStrength),void 0!==w.transform&&d&&d.setTransform(w.transform),void 0!==w.unitTransforms&&d&&d.setVisibility(l.visible&&(null===w.unitTransforms||w.unitTransforms.isIdentity))}return{label:e,get groupCount(){return d?d.groupCount:0},get props(){return m},get params(){return p},get state(){return l},get theme(){return h},get geometryVersion(){return a.version},renderObjects:u,updated:s,createOrUpdate:function g(w={},D){return D&&D!==f&&(p=n(t,D),f=D,m||(m=C.getDefaultValues(p))),m=Object.assign({},m,w),Oe.create("Creating or updating ComplexRepresentation",function(){var I=ie(function*(R){var T;let M=!1;d?null!==(T=d.mustRecreate)&&void 0!==T&&T.call(d,f,m,o)&&(d.destroy(),d=r(c,f,m,o),M=!0):(d=r(c,f,m,o),M=!0);const N=d.createOrUpdate({webgl:o,runtime:R},h,m,D);N&&(yield N),M&&S(l),u.length=0,d&&d.renderObject&&(u.push(d.renderObject),a.add(d.renderObject.id,d.geometryVersion)),a.snapshot(),i+=1,s.next(i)});return function(R){return I.apply(this,arguments)}}())},setState:S,setTheme:function A(w){h=w},getLoci:function y(w){return d?d.getLoci(w):$n},getAllLoci:function b(){var w;return[Ve.Loci(null!==(w=f.child)&&void 0!==w?w:f)]},eachLocation:function x(w){d?.eachLocation(w)},mark:function _(w,D){if(!f||!Us.is(l.markerActions,D))return!1;if(Ve.isLoci(w)||De.is(w)||Lt.isLoci(w)){if(!Ve.areRootsEquivalent(w.structure,f))return!1;w=pn.remap(w,f),(Ve.isLoci(w)||De.is(w)&&De.isWholeStructure(w))&&(w=tE)}else if(!Uc(w)&&!GS(w))return!1;return!pn.isEmpty(w)&&!!d&&d.mark(w,D)},destroy:function E(){d&&d.destroy()}}}const _at=le.toArray;function Lle(e,t,n){const{elements:r,model:i}=t;if(-1!==Fe.indexOf(r,n)){const{index:o,offsets:s}=i.atomicHierarchy.residueAtomSegments,a=o[n],c=[];for(let l=s[a],d=s[a+1];ls.unitMap.has(d.id)):e.group.units,c=a.length,u=16*c,l=o&&o.aTransform.ref.value.length>=u?o.aTransform.ref.value:new Float32Array(u);for(let d=0;dc-a);const i=Math.floor(Math.cbrt(n)*Math.cbrt(n)),o=r[0]*r[1];return{area:o,areaCells:Math.ceil(o/(t*t)),maxAreaCells:i}}function Pm(e,t,n=Vle){const{area:r,areaCells:i,maxAreaCells:o}=zle(e,t.resolution,n),s=i>o?Math.sqrt(r/o):t.resolution;return{...t,resolution:s}}const HE={ignoreHydrogens:C.Boolean(!1,{description:"Whether or not to include hydrogen atoms in the surface calculation."}),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),traceOnly:C.Boolean(!1,{description:"Whether or not to only use trace atoms in the surface calculation."}),includeParent:C.Boolean(!1,{description:"Include elements of the parent structure in surface calculation to get a surface patch of the current structure."})},Iat=(C.getDefaultValues(HE),v());function Gle(e,t,n,r){return v.squaredDistance(v.set(Iat,e,t,n),r)}function qE(e,t,n,r){const{ignoreHydrogens:i,ignoreHydrogensVariant:o,traceOnly:s,includeParent:a}=r,c=a?e.root.unitMap.get(t.id):t,u=a&&c!==t,{x:l,y:d,z:f}=function Aat(e){switch(e.kind){case 0:return e.model.atomicConformation;case 1:return e.model.coarseConformation.spheres;case 2:return e.model.coarseConformation.gaussians}}(c),{elements:p}=c,{center:m,radius:h}=t.boundary.sphere,y=(h+11)*(h+11);let b,x;if(i||s||u){const w=[],D=[];for(let I=0,R=p.length;Iy||(w.push(T),D.push(I))}b=je.ofSortedArray(w),x=D}else b=p,x=Tc(new Int32Array(b.length));a&&c!==t&&function Tat(e,t,n){let r=0;const i=t.length;for(let o=0,s=n.length;o(A.element=w,n.size(A))}}function WE(e,t,n){const{ignoreHydrogens:r,ignoreHydrogensVariant:i,traceOnly:o,includeParent:s}=n,a=s&&!!e.parent,c=nt.create(e.root),{center:u,radius:l}=e.boundary.sphere,f=(l+11)*(l+11);let p,m,h,g,y,b;if(r||o||a){const{getSerialIndex:A}=e.serialMapping,E=a?e.root.units:e.units,w=[],D=[],I=[],R=[],T=[];for(let M=0,N=E.length;Mf||(w.push($),D.push(ee),I.push(q),c.element=Z,R.push(t.size(c)),a?-1===(L?je.indexOf(L.elements,Z):-1)?T.push(-2):T.push(A(L,Z)):T.push(A(V,Z)))}}p=w,m=D,h=I,g=R,y=T,b=Fe.ofRange(0,y.length)}else{const{elementCount:A}=e,E=new Float32Array(A),w=new Float32Array(A),D=new Float32Array(A),I=new Float32Array(A);for(let R=0,T=0,M=e.units.length;Rg[A]}}const jle=ST.H;function md(e,t,n,r){if(Ee.isCoarse(t)||t.model.atomicHierarchy.derived.atom.atomicNumber[n]!==jle)return!1;if("all"===r)return!0;const i=function gst(e,t,n){let r=!1;return dc(e,t,n,(i,o)=>{(function mst(e){return hst.has(e)})(or(i,o))&&(r=!0)}),r}(e,t,je.indexOf(t.elements,n));return!!(i&&"polar"===r||!i&&"non-polar"===r)}function Dat(e,t){return e[t]===jle}function SU(e,t){if(Ee.isCoarse(e))return!0;const n=e.model.atomicHierarchy.atoms.label_atom_id.value(t);return"CA"===n||"BB"===n||"P"===n}function oC(e){return C.MultiSelect(e,Cat,{description:"For which kinds of units/chains to show the representation visuals."})}const fc={unitKinds:oC(["atomic","spheres"]),includeParent:C.Boolean(!1,{isHidden:!0})},Hle={...Nt.Params},qle={...fl.Params},Wle={...oc.Params},Eat={...ym.Params},$le={...di.Params},Yle={...vu.Params},Xle={..._u.Params},Kle={...xa.Params};function N0(e,t){const{defaultProps:n,createGeometry:r,createLocationIterator:i,getLoci:o,eachLocation:s,setUpdateState:a,mustRecreate:c,processValues:u,dispose:l}=e,{updateValues:d,updateBoundingSphere:f,updateRenderableState:p,createPositionIterator:m}=e.geometryUtils,h=Cf.create(),g={loci:$n,action:Bt.None,status:-1};let y,b,x,_,E,w,I,R,S=Object.assign({},n),A=Fo.createEmpty(),D=-1;function M(L){if(h.createNew){if(I=i(_,b),!L)throw new Error("expected geometry to be given");y=function Pat(e,t,n,r,i,o){const{createValues:s,createRenderableState:a}=Zo.getUtils(t),u=s(t,e5(),n,r,i),l=a(i);return Dv(t.kind,u,l,o)}(0,L,I,x,b,t),R=m(L,y.values)}else{if(!y)throw new Error("expected renderObject to be available");if(h.updateTransform){I=i(_,b);const{instanceCount:z,groupCount:j}=I;b.instanceGranularity?Vi(z,"instance",y.values):Vi(z*j,"groupInstance",y.values)}if(h.createGeometry){if(!L)throw new Error("expected geometry to be given");k.updateIfChanged(y.values.drawCount,Zo.getDrawCount(L)),k.updateIfChanged(y.values.uVertexCount,Zo.getVertexCount(L)),k.updateIfChanged(y.values.uGroupCount,Zo.getGroupCount(L))}(h.updateTransform||h.createGeometry)&&(f(y.values,L||w),R=m(w,y.values)),h.updateSize&&"uSize"in y.values&&kp(I,x.size,y.values),h.updateColor&&bu(I,R,x.color,y.values),d(y.values,b),p(y.state,b)}S=b,A=x,E=_,L&&(w=L,D+=1)}function F(L,z,j){return function N(L){return!!(Uc(L)||Ve.isLoci(L)&&Ve.areRootsEquivalent(L.structure,E)||De.is(L)&&Ve.areRootsEquivalent(L.structure,E)&&De.isWholeStructure(L))}(L)?z(Ce.ofBounds(0,S.instanceGranularity?I.instanceCount:I.groupCount*I.instanceCount)):S.instanceGranularity?function V(L,z,j){let Z=!1;return!(!De.is(L)&&!Lt.isLoci(L)||!Ve.areEquivalent(L.structure,z))&&(j(Ce.ofSingleton(0))&&(Z=!0),Z)}(L,E,z):s(L,E,z,j)}function G(L){y&&u?.(y.values,w,S,A,L.webgl)}return{get groupCount(){return I?I.count:0},get renderObject(){return I&&I.count?y:void 0},get geometryVersion(){return D},createOrUpdate(L,z,j={},Z){if(function T(L,z,j){if(!j&&!E)throw new Error("missing structure");if(b=Object.assign({},S,z),x=L,_=j,Cf.reset(h),!y||!E)return h.createNew=!0,void(h.createGeometry=!0);a(h,b,S,x,A,_,E),Ve.areEquivalent(_,E)||(h.createGeometry=!0),Ve.areHierarchiesEqual(_,E)||(h.updateTransform=!0,h.createGeometry=!0),Lc.areEqual(L.color,A.color)||(h.updateColor=!0),Yd(b.unitKinds,S.unitKinds)||(h.createGeometry=!0),E.child!==_.child&&(h.createGeometry=!0),b.instanceGranularity!==S.instanceGranularity&&(h.updateTransform=!0),h.updateSize&&!("uSize"in y.values)&&(h.createGeometry=!0),h.createGeometry&&(h.updateColor=!0,h.updateSize=!0)}(z,j,Z||E),h.createGeometry){const $=r(L,_,x,b,w);if(FI($))return $.then(ee=>{M(ee),G(L)});M($)}else M();G(L)},getLoci:L=>y?o(L,E,y.id):$n,eachLocation(L){for(I.reset();I.hasNext;){const{location:z,isSecondary:j}=I.move();L(z,j)}},mark:(L,z)=>Sn.mark(y,L,z,F,g),setVisibility(L){Sn.setVisibility(y,L)},setAlphaFactor(L){Sn.setAlphaFactor(y,L)},setPickable(L){Sn.setPickable(y,L)},setColorOnly(L){Sn.setColorOnly(y,L)},setTransform(L,z){Sn.setTransform(y,L,z)},setOverpaint(L,z){Sn.setOverpaint(y,L,F,!0,{geometry:w,props:S,webgl:z})},setTransparency(L,z){Sn.setTransparency(y,L,F,!0,{geometry:w,props:S,webgl:z})},setSubstance(L,z){Sn.setSubstance(y,L,F,!0,{geometry:w,props:S,webgl:z})},setClipping(L){Sn.setClipping(y,L,F,!0)},setThemeStrength(L){Sn.setThemeStrength(y,L)},destroy(){l?.(w),y&&(y.state.disposed=!0,y=void 0)},mustRecreate:c}}const n1={...Hle,...fc};function rh(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.createGeometry=!0)},geometryUtils:Nt.Utils},t)}const Mat={...qle,...fc},kat={...Wle,...fc},Fat={...$le,...fc},Oat={...Yle,...fc},Uat={...Xle,...fc},zat={...Kle,...fc};function vi(e,t,n,r){let i=0;const{webgl:o}=t,s=new mr,a=Hp(),c=[],u=new yn.GeometryState,l=ms.create();let f,p,m,h,d=new Map,g=Fo.createEmpty();function A(I,R,T){const{visible:M,alphaFactor:N,pickable:V,overpaint:F,transparency:G,substance:L,clipping:z,themeStrength:j,transform:Z,unitTransforms:$}=T;void 0!==M&&I.setVisibility(M),void 0!==N&&I.setAlphaFactor(N),void 0!==V&&I.setPickable(V),void 0!==F&&I.setOverpaint(F,o),void 0!==G&&I.setTransparency(G,o),void 0!==L&&I.setSubstance(L,o),void 0!==z&&I.setClipping(z),void 0!==j&&I.setThemeStrength(j),void 0!==Z&&(Z!==l.transform||!le.areEqual(Z,l.transform,vr))&&I.setTransform(Z),void 0!==$&&($?I.setTransform(void 0,$.getSymmetryGroupTransforms(R)):$!==l.unitTransforms&&I.setTransform(void 0,null))}return{label:e,get groupCount(){let I=0;return d.forEach(({visual:R})=>{R.renderObject&&(I+=R.groupCount)}),I},get geometryVersion(){return u.version},get props(){return h},get params(){return m},get state(){return l},get theme(){return g},renderObjects:c,updated:s,createOrUpdate:function y(I={},R){return R&&R!==f&&(m=n(t,R),h||(h=C.getDefaultValues(m))),h=Object.assign({},h,I),Oe.create("Creating or updating UnitsRepresentation",function(){var T=ie(function*(M){var N,V,F;if(!f&&!R)throw new Error("missing structure");if(R&&!f){p=R.unitSymmetryGroups;for(let G=0;GG.push(L));for(let L=0,z=G.length;L{L.destroy()})}c.length=0,d.forEach(({visual:G})=>{G.renderObject&&(c.push(G.renderObject),u.add(G.renderObject.id,G.geometryVersion))}),u.snapshot(),R&&(f=R),s.next(i++)});return function(M){return T.apply(this,arguments)}}())},setState:function E(I){const{visible:R,alphaFactor:T,pickable:M,overpaint:N,transparency:V,substance:F,clipping:G,themeStrength:L,transform:z,unitTransforms:j,syncManually:Z,markerActions:$}=I,ee={};void 0!==R&&(ee.visible=R),void 0!==T&&(ee.alphaFactor=T),void 0!==M&&(ee.pickable=M),void 0!==N&&f&&(ee.overpaint=Bo.remap(N,f)),void 0!==V&&f&&(ee.transparency=Vs.remap(V,f)),void 0!==F&&f&&(ee.substance=zs.remap(F,f)),void 0!==G&&f&&(ee.clipping=Yr.remap(G,f)),void 0!==L&&(ee.themeStrength=L),void 0!==z&&!le.areEqual(z,l.transform,vr)&&(ee.transform=z),(j!==l.unitTransforms||j?.version!==l.unitTransformsVersion)&&(ee.unitTransforms=j,l.unitTransformsVersion=j?j?.version:-1),void 0!==Z&&(ee.syncManually=Z),void 0!==$&&(ee.markerActions=$),d.forEach(({visual:q,group:O})=>A(q,O,ee)),ms.update(l,ee)},setTheme:function w(I){g=I},getLoci:function b(I){let R=$n;return d.forEach(({visual:T})=>{const M=T.getLoci(I);Ta(M)||(R=M)}),R},getAllLoci:function _(){var I;return[Ve.Loci(null!==(I=f.child)&&void 0!==I?I:f)]},eachLocation:function x(I){d.forEach(({visual:R})=>{R.eachLocation(I)})},mark:function S(I,R){if(!f||!Us.is(l.markerActions,R))return!1;if(Ve.isLoci(I)||De.is(I)||Lt.isLoci(I)){if(!Ve.areRootsEquivalent(I.structure,f))return!1;I=pn.remap(I,f),(Ve.isLoci(I)||De.is(I)&&De.isWholeStructure(I))&&(I=tE)}else if(!Uc(I)&&!GS(I))return!1;if(pn.isEmpty(I))return!1;let T=!1;return d.forEach(({visual:M})=>{T=M.mark(I,R)||T}),T},destroy:function D(){d.forEach(({visual:I})=>I.destroy()),d.clear()}}}function Mm(e,t){const{defaultProps:n,createGeometry:r,createLocationIterator:i,getLoci:o,eachLocation:s,setUpdateState:a,mustRecreate:c,processValues:u,dispose:l}=e,{createEmpty:d,updateValues:f,updateBoundingSphere:p,updateRenderableState:m,createPositionIterator:h}=e.geometryUtils,g=Cf.create(),y={loci:$n,action:Bt.None,status:-1};let b,S,A,E,w,D,R,T,x=Object.assign({},n),_=Fo.createEmpty(),I=-1;function N(j){if(g.createNew){if(R=i(S,x),!j)throw new Error("expected geometry to be given");b=function jat(e,t,n,r,i,o){const{createValues:s,createRenderableState:a}=Zo.getUtils(t),u=s(t,Ule(e,i.includeParent,t.boundingSphere,i.cellSize,i.batchSize),n,r,i),l=a(i);return Dv(t.kind,u,l,o)}(S,j,R,_,x,t),T=h(j,b.values)}else{if(!b)throw new Error("expected renderObject to be available");if(g.updateTransform){R=i(S,x);const{instanceCount:Z,groupCount:$}=R;x.instanceGranularity?Vi(Z,"instance",b.values):Vi(Z*$,"groupInstance",b.values)}if(g.updateMatrix&&(Ule(S,x.includeParent,b.values.invariantBoundingSphere.ref.value,x.cellSize,x.batchSize,b.values),"lodLevels"in b.values&&k.update(b.values.lodLevels,b.values.lodLevels.ref.value)),g.createGeometry){if(!j)throw new Error("expected geometry to be given");k.updateIfChanged(b.values.drawCount,Zo.getDrawCount(j)),k.updateIfChanged(b.values.uVertexCount,Zo.getVertexCount(j)),k.updateIfChanged(b.values.uGroupCount,Zo.getGroupCount(j))}(g.updateTransform||g.createGeometry)&&(p(b.values,j||D),T=h(j||D,b.values)),g.updateSize&&"uSize"in b.values&&kp(R,_.size,b.values),g.updateColor&&bu(R,T,_.color,b.values),f(b.values,x),m(b.state,x)}A=x,E=_,w=S,j&&(D=j,I+=1)}function L(j,Z,$){return function F(j){return!!(Uc(j)||Ve.isLoci(j)&&Ve.areRootsEquivalent(j.structure,w.structure)||De.is(j)&&Ve.areRootsEquivalent(j.structure,w.structure)&&De.isWholeStructure(j))}(j)?Z(Ce.ofBounds(0,A.instanceGranularity?R.instanceCount:R.groupCount*R.instanceCount)):A.instanceGranularity?function G(j,Z,$){let ee=!1;if(Lt.isLoci(j)){const{structure:q,group:O}=Z;if(!Ve.areEquivalent(j.structure,q))return!1;for(const H of j.bonds){if(H.aUnit!==H.bUnit)continue;const W=O.unitIndexMap.get(H.aUnit.id);void 0!==W&&$(Ce.ofSingleton(W))&&(ee=!0)}}else if(De.is(j)){const{structure:q,group:O}=Z;if(!Ve.areEquivalent(j.structure,q))return!1;for(const H of j.elements){const W=O.unitIndexMap.get(H.unit.id);void 0!==W&&$(Ce.ofSingleton(W))&&(ee=!0)}}return ee}(j,w,Z):s(j,w,Z,$)}function z(j){b&&u?.(b.values,D,A,E,j.webgl)}return{get groupCount(){return R?R.count:0},get renderObject(){return R&&R.count?b:void 0},get geometryVersion(){return I},createOrUpdate(j,Z,$,ee){if(function M(j,Z,$){if(!$&&!w)throw new Error("missing structureGroup");if(x=Z,_=j,S=$,Cf.reset(g),!b||!w)return g.createNew=!0,void(g.createGeometry=!0);a(g,x,A,_,E,S,w),Ve.areHierarchiesEqual(w.structure,S.structure)||(g.updateTransform=!0,g.updateColor=!0,g.updateSize=!0),Lc.areEqual(_.color,E.color)||(g.updateColor=!0),w.structure.child!==S.structure.child&&(g.createGeometry=!0),(x.instanceGranularity!==A.instanceGranularity||x.cellSize!==A.cellSize||x.batchSize!==A.batchSize)&&(g.updateTransform=!0),Yd(x.unitKinds,A.unitKinds)||(g.createGeometry=!0),S.group.transformHash!==w.group.transformHash&&(S.group.units.length!==w.group.units.length||g.updateColor?g.updateTransform=!0:g.updateMatrix=!0);const ee=S.group.units[0],q=w.group.units[0];Ee.areOperatorsEqual(ee,q)||(g.updateTransform=!0),Ee.areConformationsEqual(ee,q)||(g.createGeometry=!0),g.updateTransform&&(g.updateMatrix=!0),g.updateSize&&!("uSize"in b.values)&&(g.createGeometry=!0),(g.createGeometry||g.updateTransform)&&(w.structure.hashCode!==S.structure.hashCode&&(g.updateColor=!0,g.updateSize=!0),(_.color.granularity.startsWith("vertex")||b.values.dColorType.ref.value.startsWith("vertex")||_.color.granularity.startsWith("volume")||b.values.dColorType.ref.value.startsWith("volume"))&&(g.updateColor=!0))}(Z,$,ee||w),g.createGeometry){const q=function V(j,Z,$,ee,q,O){return function wat(e,t){for(let n=0,r=e.length;n{N(O),z(j)});N(q)}else N();z(j)},getLoci:j=>b?o(j,w,b.id):$n,eachLocation(j){for(R.reset();R.hasNext;){const{location:Z,isSecondary:$}=R.move();j(Z,$)}},mark(j,Z){let $=!0;if(De.is(j)){$=!1;const{invariantId:ee}=w.group.units[0];for(const q of j.elements)if(q.unit.invariantId===ee){$=!0;break}}return!!$&&Sn.mark(b,j,Z,L,y)},setVisibility(j){Sn.setVisibility(b,j)},setAlphaFactor(j){Sn.setAlphaFactor(b,j)},setPickable(j){Sn.setPickable(b,j)},setColorOnly(j){Sn.setColorOnly(b,j)},setTransform(j,Z){Sn.setTransform(b,j,Z)},setOverpaint(j,Z){Sn.setOverpaint(b,j,L,!0,{geometry:D,props:A,webgl:Z})},setTransparency(j,Z){Sn.setTransparency(b,j,L,!0,{geometry:D,props:A,webgl:Z})},setSubstance(j,Z){Sn.setSubstance(b,j,L,!0,{geometry:D,props:A,webgl:Z})},setClipping(j){Sn.setClipping(b,j,L,!0)},setThemeStrength(j){Sn.setThemeStrength(b,j)},destroy(){l?.(D),b&&(b.state.disposed=!0,b=void 0)},mustRecreate:c}}const hs={...Hle,...fc};function Hs(e,t){return Mm({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.createGeometry=!0)},geometryUtils:Nt.Utils},t)}const CU={...qle,...fc};function wU(e,t){return Mm({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:fl.Utils},t)}const AU={...Wle,...fc};function IU(e,t){return Mm({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:oc.Utils},t)}const Hat={...Eat,...fc},$E={...$le,...fc};function YE(e,t){return Mm({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:di.Utils},t)}const Wat={...Xle,...fc},Yat={...Kle,...fc},ms={create:()=>({...yn.createState(),unitTransforms:null,unitTransformsVersion:-1}),update:(e,t)=>{yn.updateState(e,t),void 0!==t.unitTransforms&&(e.unitTransforms=t.unitTransforms)}},ih=v(),r1=v(),sC=v(),XE=ze.add,Zle=ze.add3;var aC;!function(e){e.create=function t(n=2048,r=1024,i){const o=ze.create(Float32Array,1,r,i?i.groupBuffer.ref.value:n),s=ze.create(Float32Array,3,r,i?i.startBuffer.ref.value:n),a=ze.create(Float32Array,3,r,i?i.endBuffer.ref.value:n),c=ze.create(Float32Array,1,r,i?i.scaleBuffer.ref.value:n),u=ze.create(Float32Array,1,r,i?i.capBuffer.ref.value:n),l=ze.create(Float32Array,1,r,i?i.colorModeBuffer.ref.value:n),d=(p,m,h,g,y,b,x,_,S,A,E)=>{for(let w=0;w<6;++w)Zle(s,p,m,h),Zle(a,g,y,b),XE(o,E),XE(c,x),XE(u,(_?1:0)+(S?2:0)),XE(l,A)},f=(p,m,h,g,y,b,x,_,S)=>{const A=v.distance(p,m),E=h%2!=0,w=Math.floor((h+1)/2),D=A/(h+.5);let I=2;v.setMagnitude(sC,v.sub(sC,m,p),D),v.copy(ih,p);for(let R=0;R{const S=v.distance(p,m);f(p,m,S/h,g,y,b,!0,x,_)},getCylinders:()=>{const p=o.elementCount/6,m=ze.compact(o,!0),h=ze.compact(s,!0),g=ze.compact(a,!0),y=ze.compact(c,!0),b=ze.compact(u,!0),x=ze.compact(l,!0),_=i&&p<=i.cylinderCount?i.mappingBuffer.ref.value:new Float32Array(18*p),S=i&&p<=i.cylinderCount?i.indexBuffer.ref.value:new Uint32Array(12*p);return(!i||p>i.cylinderCount)&&function Kat(e,t,n){for(let r=0;r0,z=c(F),j=a?a(F):0,Z=S&&!!l&&l(F),[$,ee]=L?[Z,m]:[m,Z];if(E.currentGroup=F,0===j)M.radiusTop=M.radiusBottom=z,M.topCap=$,M.bottomCap=ee,Hn(E,w,D,.5,M);else if(1===j)M.radiusTop=M.radiusBottom=z*x,M.topCap=M.bottomCap=_,Cv(E,w,D,.5,b,Z,M);else if(2===j||3===j||4===j||5===j||7===j||8===j){const q=2===j||3===j?2:4===j||5===j?3:1.5,O=z*(d/(.5*q)),H=(z-O)*f;if(TU(I,w,D,o?o(F):null),M.topCap=$,M.bottomCap=ee,7===j||8===j){M.radiusTop=M.radiusBottom=z,Hn(E,w,D,.5,M);const W=z+h*z+h*z*g;qs(Or,Co(Or,D,w),.5*z),Ei(w,w,Or),Co(D,D,Or),M.radiusTop=M.radiusBottom=z*h,M.topCap=M.bottomCap=_,qs(I,I,W),Co(w,w,I),Co(D,D,I),Cv(E,w,D,.5,y,Z,M),8===j&&(qs(I,I,2*W),Ei(w,w,I),Ei(D,D,I),Cv(E,w,D,.5,y,Z,M))}else if(3===j||5===j){const W=z+O+d*z*f;qs(I,I,W),M.radiusTop=M.radiusBottom=z,Hn(E,w,D,.5,M),gd(Or,Or,f*d*.2),Ei(w,w,Or),Co(D,D,Or),M.radiusTop=M.radiusBottom=O,M.topCap=L?Z:_,M.bottomCap=L?_:Z,qs(I,I,W),Co(w,w,I),Co(D,D,I),Hn(E,w,D,.5,M),3===q&&(qs(I,I,2*W),Ei(w,w,I),Ei(D,D,I),Hn(E,w,D,.5,M))}else qs(I,I,H),M.radiusTop=M.radiusBottom=O,3===q&&Hn(E,w,D,.5,M),vHe(E,w,D,.5,I,M)}else 6===j&&(gd(Or,Or,.475),Ei(w,w,Or),Co(D,D,Or),M.radiusTop=M.radiusBottom=z,M.topCap=$,M.bottomCap=ee,Hn(E,w,D,.5,M))}const N=r?_e.clone(r.boundingSphere):void 0,V=at.getMesh(E);return 0===T?{mesh:V}:(v.scale(R,R,1/T),N&&v.distance(R,N.center)/N.radius<.1?{mesh:V,boundingSphere:N}:{mesh:V})}function Jle(e,t,n,r){const{linkCount:i,referencePosition:o,position:s,style:a,radius:c,ignore:u,stub:l}=t;if(!i)return{cylinders:oc.createEmpty(r)};const{linkScale:d,linkSpacing:f,linkCap:p,aromaticScale:m,aromaticSpacing:h,aromaticDashCount:g,dashCount:y,dashScale:b,dashCap:x,stubCap:_,colorMode:S}=n,A="interpolate"===S,E=!0===A?3:2,w=2*i,D=aC.create(w,w/4,r),I=v(),R=v(),T=v(),M=v(),N=v();let V=0;for(let L=0,z=i;L{const Z=S[j];if(E&&"all"===w||Z!==kn.HydrogenBond&&Z!==kn.WeakHydrogenBond)v.set(L,f[b[j]],p[b[j]],m[b[j]]),v.set(z,f[x[j]],p[x[j]],m[x[j]]);else{const $=h[g[b[j]]],ee=h[g[x[j]]];R.invariantPosition(I[$],M),R.invariantPosition(I[ee],N);let q=v.distance(M,N),O=q;v.copy(L,M),v.copy(z,N),eU(t,$,(H,W)=>{if(md(n,t,I[W],"polar")){R.invariantPosition(I[W],T);const Q=v.distance(T,N);Q{if(md(n,t,I[W],"polar")){R.invariantPosition(I[W],T);const Q=v.distance(T,M);Q1,radius:L=>{c.element=I[h[g[b[L]]]];const z=r.size.size(c);c.element=I[h[g[x[L]]]];const j=r.size.size(c);return Math.min(z,j)*A},ignore:L=>{if(_[L]===Pf.Filtered)return!0;if(a)if("stub"===D){const z=b[L];for(let j=g[z],Z=g[z+1];j0){const L=_e.expand(_e(),(a??t).boundary.sphere,1*A);F.setBoundingSphere(L)}return F})).apply(this,arguments)}const nde={...hs,...F0,...tde};function ect(e){return Hs({defaultProps:C.getDefaultValues(nde),createGeometry:Jat,createLocationIterator:rct,getLoci:tct,eachLocation:nct,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.dashCount!==r.dashCount||n.dashScale!==r.dashScale||n.dashCap!==r.dashCap||n.radialSegments!==r.radialSegments||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.parentDisplay!==r.parentDisplay;const c=Qi.get(s.structure).version;t.info.interactionsHash!==c&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.info.interactionsHash=c)}},e)}function tct(e,t,n){const{objectId:r,instanceId:i,groupId:o}=e;if(n===r){const{structure:s,group:a}=t,c=s.unitMap.get(a.units[i].id),u=Qi.get(s).value,{a:l,b:d}=u.unitsContacts.get(c.id);return nh.Loci(s,u,[{unitA:c,indexA:l[o],unitB:c,indexB:d[o]},{unitA:c,indexA:d[o],unitB:c,indexB:l[o]}])}return $n}const EU=new Set;function nct(e,t,n,r){let i=!1;if(nh.isLoci(e)){const{structure:o,group:s}=t;if(!Ve.areEquivalent(e.data.structure,o))return!1;const a=Qi.get(o).value;if(e.data.interactions!==a)return!1;const u=a.unitsContacts.get(s.units[0].id),l=2*u.edgeCount;for(const d of e.elements){if(d.unitA!==d.unitB)continue;const f=s.unitIndexMap.get(d.unitA.id);if(void 0!==f){const p=u.getDirectedEdgeIndex(d.indexA,d.indexB);-1!==p&&n(Ce.ofSingleton(f*l+p))&&(i=!0)}}}else if(De.is(e)){const{structure:o,group:s}=t;if(!Ve.areEquivalent(e.structure,o))return!1;const a=Qi.get(o).value;if(!a)return!1;const c=s.units[0],u=a.unitsContacts.get(c.id),l=a.unitsFeatures.get(c.id),d=2*u.edgeCount,{offset:f}=u,{offsets:p,indices:m}=l.elementsIndex,{members:h,offsets:g}=l;for(const y of e.elements){const b=s.unitIndexMap.get(y.unit.id);void 0!==b&&(Fe.forEach(y.indices,x=>{for(let _=p[x],S=p[x+1];_{if(r){const _=u.a[x];for(let A=g[_],E=g[_+1];A{const p=n.units[f];return u.unitA=p,u.indexA=o.a[d],u.unitB=p,u.indexB=o.b[d],c})}function ict(e,t,n,r,i){if(!t.hasAtomic)return Nt.createEmpty(i);const o=nt.create(t),s=Qi.get(t).value,{contacts:a,unitsFeatures:c}=s,{edgeCount:u,edges:l}=a,{sizeFactor:d,ignoreHydrogens:f,ignoreHydrogensVariant:p,parentDisplay:m}=r;if(!u)return Nt.createEmpty(i);const{child:h}=t,g=v(),y=v(),b=v(),x={linkCount:u,position:(A,E,w)=>{const{unitA:D,indexA:I,unitB:R,indexB:T,props:{type:M}}=l[w],N=c.get(D),V=c.get(R),F=t.unitMap.get(D),G=t.unitMap.get(R);if(f&&"all"===p||M!==kn.HydrogenBond&&M!==kn.WeakHydrogenBond)v.set(A,N.x[I],N.y[I],N.z[I]),v.transformMat4(A,A,F.conformation.operator.matrix),v.set(E,V.x[T],V.y[T],V.z[T]),v.transformMat4(E,E,G.conformation.operator.matrix);else{const L=N.members[N.offsets[I]],z=V.members[V.offsets[T]];F.conformation.position(F.elements[L],y),G.conformation.position(G.elements[z],b);let j=v.distance(y,b),Z=j;v.copy(A,y),v.copy(E,b),dc(t,F,L,($,ee)=>{const q=$.elements[ee];if(md(t,$,q,"polar")){$.conformation.position(q,g);const O=v.distance(g,b);O{const q=$.elements[ee];if(md(t,$,q,"polar")){$.conformation.position(q,g);const O=v.distance(g,y);O1,radius:A=>{const E=l[A],w=c.get(E.unitA);o.unit=t.unitMap.get(E.unitA),o.element=o.unit.elements[w.members[w.offsets[E.indexA]]];const D=n.size.size(o),I=c.get(E.unitB);o.unit=t.unitMap.get(E.unitB),o.element=o.unit.elements[I.members[I.offsets[E.indexB]]];const R=n.size.size(o);return Math.min(D,R)*d},ignore:A=>{if(l[A].props.flag===Pf.Filtered)return!0;if(h){const E=l[A];if("stub"===m){const w=h.unitMap.get(E.unitA);if(!w)return!0;const D=t.unitMap.get(E.unitA),{offsets:I,members:R}=c.get(E.unitA);for(let T=I[E.indexA],M=I[E.indexA+1];T0){const{child:A}=t,E=_e.expand(_e(),(A??t).boundary.sphere,1*d);_.setBoundingSphere(E)}return _}const rde={...n1,...F0,...tde};function oct(e){return rh({defaultProps:C.getDefaultValues(rde),createGeometry:ict,createLocationIterator:cct,getLoci:sct,eachLocation:act,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.dashCount!==r.dashCount||n.dashScale!==r.dashScale||n.dashCap!==r.dashCap||n.radialSegments!==r.radialSegments||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.parentDisplay!==r.parentDisplay;const c=Qi.get(s).version;t.info.interactionsHash!==c&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.info.interactionsHash=c)}},e)}function sct(e,t,n){const{objectId:r,groupId:i}=e;if(n===r){const o=Qi.get(t).value,s=o.contacts.edges[i],a=t.unitMap.get(s.unitA),c=t.unitMap.get(s.unitB);return nh.Loci(t,o,[{unitA:a,indexA:s.indexA,unitB:c,indexB:s.indexB},{unitA:c,indexA:s.indexB,unitB:a,indexB:s.indexA}])}return $n}const KE=new Map,PU=new Set;function act(e,t,n,r){let i=!1;if(nh.isLoci(e)){if(!Ve.areEquivalent(e.data.structure,t))return!1;const o=Qi.get(t).value;if(e.data.interactions!==o)return!1;const{contacts:s}=o;for(const a of e.elements){const c=s.getEdgeIndex(a.indexA,a.unitA.id,a.indexB,a.unitB.id);-1!==c&&n(Ce.ofSingleton(c))&&(i=!0)}}else if(De.is(e)){if(!Ve.areEquivalent(e.structure,t)||r&&1===e.elements.length)return!1;const o=Qi.get(t).value;if(!o)return!1;const{contacts:s,unitsFeatures:a}=o;for(const c of e.elements)KE.set(c.unit.id,c.indices);for(const c of e.elements){const{unit:u}=c;Ee.isAtomic(u)&&Fe.forEach(c.indices,l=>{for(const d of s.getContactIndicesForElement(l,u))PU.add(d)})}PU.forEach(c=>{if(r){const{indexA:u,unitA:l,indexB:d,unitB:f}=s.edges[c],p=KE.get(l),m=KE.get(f);if(!p||!m)return;const{offsets:h,members:g}=a.get(l);for(let x=h[u],_=h[u+1];x<_;++x)if(!Fe.has(p,g[x]))return;const{offsets:y,members:b}=a.get(f);for(let x=y[d],_=y[d+1];x<_;++x)if(!Fe.has(m,b[x]))return}n(Ce.ofSingleton(c))&&(i=!0)}),KE.clear(),PU.clear()}return i}function cct(e){const t=Qi.get(e).value,{contacts:n}=t,r=n.edgeCount,o=nh.Location(t,e),{element:s}=o;return Mr(r,1,1,c=>{const u=n.edges[c];return s.unitA=e.unitMap.get(u.unitA),s.indexA=u.indexA,s.unitB=e.unitMap.get(u.unitB),s.indexB=u.indexB,o},!0)}const ide={"intra-unit":(e,t)=>vi("Intra-unit interactions cylinder",e,t,ect),"inter-unit":(e,t)=>Iu("Inter-unit interactions cylinder",e,t,oct)},ode={...nde,...rde,unitKinds:oC(["atomic"]),sizeFactor:C.Numeric(.2,{min:.01,max:1,step:.01}),visuals:C.MultiSelect(["intra-unit","inter-unit"],C.objectToOptions(ide))},ZE={name:"interactions",label:"Non-covalent Interactions",description:"Displays non-covalent interactions as dashed cylinders.",factory:function lct(e,t){return yn.createMulti("Interactions",e,t,ms,ide)},getParams:function uct(e,t){return C.clone(ode)},defaultValues:C.getDefaultValues(ode),defaultColorTheme:{name:"interaction-type"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.elementCount>0&&Qi.isApplicable(e),ensureCustomProperties:{attach:(e,t)=>Qi.attach(e,t,void 0,!0),detach:e=>Qi.ref(e,!1)},getData:(e,t)=>t.includeParent?e.asParent():e,mustRecreate:(e,t)=>e.includeParent!==t.includeParent},dct=tr.create({name:"computed-interactions-prop",category:"custom-props",display:{name:"Interactions"},ctor:class extends tr.Handler{constructor(){super(...arguments),this.provider=Qi,this.labelProvider={label:e=>{if(this.params.showTooltip&&"element-loci"===e.kind){if(0===e.elements.length)return;const t=[],n=this.getStructures(e.structure);for(const r of n){const i=this.provider.get(r).value;if(!i)continue;const o=De.remap(e,r);if(1!==o.elements.length)continue;const s=o.elements[0];if(1!==Fe.size(s.indices))continue;const a=i.unitsFeatures.get(s.unit.id);if(!a)continue;const c=[],u=[],l=[],d=Fe.start(s.indices),{types:f,groups:p,elementsIndex:{indices:m,offsets:h}}=a;for(let g=h[d],y=h[d+1];gTypes ${c.join(", ")}`),u.length&&l.push(`Groups ${u.join(", ")}`),l.length&&t.push(`Interaction Feature: ${l.join(" | ")}`)}return t.length?t.join("
"):void 0}}}}getStructures(e){const t=[],n=this.ctx.helpers.substructureParent.get(e);if(n){const i=this.ctx.state.data.select(In.Generators.ofType(pe.Molecule.Structure,n.transform.ref));for(const o of i)o.obj&&eo(t,o.obj.data)}return t}update(e){const t=this.params.autoAttach!==e.autoAttach||this.params.showTooltip!==e.showTooltip;return this.params.autoAttach=e.autoAttach,this.params.showTooltip=e.showTooltip,this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name,this.params.autoAttach),t}register(){this.ctx.customStructureProperties.register(this.provider,this.params.autoAttach),this.ctx.representation.structure.themes.colorThemeRegistry.add(xU),this.ctx.managers.lociLabels.addProvider(this.labelProvider),this.ctx.representation.structure.registry.add(ZE)}unregister(){this.ctx.customStructureProperties.unregister(this.provider.descriptor.name),this.ctx.representation.structure.themes.colorThemeRegistry.remove(xU),this.ctx.managers.lociLabels.removeProvider(this.labelProvider),this.ctx.representation.structure.registry.remove(ZE)}},params:()=>({autoAttach:C.Boolean(!1),showTooltip:C.Boolean(!0)})}),fct=tr.create({name:"computed-secondary-structure-prop",category:"custom-props",display:{name:"Secondary Structure"},ctor:class extends tr.Handler{constructor(){super(...arguments),this.provider=Xu}update(e){const t=this.params.autoAttach!==e.autoAttach;return this.params.autoAttach=e.autoAttach,this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name,this.params.autoAttach),t}register(){this.ctx.customStructureProperties.register(this.provider,this.params.autoAttach)}unregister(){this.ctx.customStructureProperties.unregister(this.provider.descriptor.name)}},params:()=>({autoAttach:C.Boolean(!1)})}),pct=tr.create({name:"computed-valence-model-prop",category:"custom-props",display:{name:"Valence Model"},ctor:class extends tr.Handler{constructor(){super(...arguments),this.provider=nC,this.labelProvider={label:e=>{if(this.params.showTooltip&&"element-loci"===e.kind){if(0===e.elements.length)return;const t=[],n=this.getStructures(e.structure);for(const r of n){const i=this.provider.get(r).value;if(!i)continue;const o=De.remap(e,r);if(1!==o.elements.length)continue;const s=o.elements[0];if(1!==Fe.size(s.indices))continue;const a=i.get(s.unit.id);if(!a)continue;const c=Fe.start(s.indices),d=a.implicitH[c],f=a.totalH[c];t.push(`Valence Model: Charge ${a.charge[c]} | Ideal Geometry ${dot(a.idealGeometry[c])} | Implicit H ${d} | Total H ${f}`)}return t.length?t.join("
"):void 0}}}}getStructures(e){const t=[],n=this.ctx.helpers.substructureParent.get(e);if(n){const i=this.ctx.state.data.select(In.Generators.ofType(pe.Molecule.Structure,n.transform.ref));for(const o of i)o.obj&&eo(t,o.obj.data)}return t}update(e){const t=this.params.autoAttach!==e.autoAttach||this.params.showTooltip!==e.showTooltip;return this.params.autoAttach=e.autoAttach,this.params.showTooltip=e.showTooltip,this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name,this.params.autoAttach),t}register(){this.ctx.customStructureProperties.register(this.provider,this.params.autoAttach),this.ctx.managers.lociLabels.addProvider(this.labelProvider)}unregister(){this.ctx.customStructureProperties.unregister(this.provider.descriptor.name),this.ctx.managers.lociLabels.removeProvider(this.labelProvider)}},params:()=>({autoAttach:C.Boolean(!1),showTooltip:C.Boolean(!0)})}),MU=st(16448250),cC=new Map,sde={...Ia({type:"colors",colorList:"set-1"})},cde={name:"sifts-mapping",label:"SIFTS Mapping",category:Lc.Category.Residue,factory:function ade(e,t){let n;if(e.structure){for(const a of e.structure.models){const c=sf.Provider.get(a).value;if(c)for(const u of c.accession)!u||cC.has(u)||cC.set(u,cC.size)}const r=nt.create(e.structure),i=ac(cC.size+1,t,{valueLabel:a=>`${a}`}),o=new Map,s=a=>{const c=sf.getKey(a);if(!c)return MU;if(o.has(c))return o.get(c);const u=i.color(cC.get(c));return o.set(c,u),u};n=a=>nt.is(a)&&Ee.isAtomic(a.unit)?s(a):Lt.isLocation(a)?(r.unit=a.aUnit,r.element=a.aUnit.elements[a.aIndex],s(r)):MU}else n=()=>MU;return{factory:ade,granularity:"group",preferSmoothing:!0,color:n,props:t,description:"Assigns a color based on SIFTS mapping."}},getParams:function mct(e){return sde},defaultValues:C.getDefaultValues(sde),isApplicable:e=>{var t;return!(null===(t=e.structure)||void 0===t||!t.models.some(n=>sf.Provider.isApplicable(n)))},ensureCustomProperties:{attach:function(){var e=ie(function*(t,n){if(n.structure)for(const r of n.structure.models)yield sf.Provider.attach(t,r,void 0,!0)});return function(n,r){return e.apply(this,arguments)}}(),detach:e=>{if(e.structure)for(const t of e.structure.models)sf.Provider.ref(t,!1)}}},gct=tr.create({name:"sifts-mapping-prop",category:"custom-props",display:{name:"SIFTS Mapping"},ctor:class extends tr.Handler{constructor(){super(...arguments),this.provider=sf.Provider,this.labelProvider={label:e=>{if(this.params.showTooltip)return function yct(e){if("element-loci"===e.kind){if(0===e.elements.length)return;const t=e.elements[0],n=t.unit,r=nt.create(e.structure,n,n.elements[Fe.getAt(t.indices,0)]);return sf.getLabel(r)}}(e)}}}update(e){const t=this.params.autoAttach!==e.autoAttach||this.params.showTooltip!==e.showTooltip;return this.params.autoAttach=e.autoAttach,this.params.showTooltip=e.showTooltip,this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name,this.params.autoAttach),t}register(){this.ctx.customModelProperties.register(this.provider,this.params.autoAttach),this.ctx.representation.structure.themes.colorThemeRegistry.add(cde),this.ctx.managers.lociLabels.addProvider(this.labelProvider)}unregister(){this.ctx.customModelProperties.unregister(this.provider.descriptor.name),this.ctx.representation.structure.themes.colorThemeRegistry.remove(cde),this.ctx.managers.lociLabels.removeProvider(this.labelProvider)}},params:()=>({autoAttach:C.Boolean(!0),showTooltip:C.Boolean(!0)})});var oh;!function(e){e.Descriptor={name:"ihm_cross_link_restraint"},e.Provider=td.create(e.Descriptor),e.fromTable=function t(n,r){const i={entity_id:n.entity_id_1,asym_id:n.asym_id_1,seq_id:n.seq_id_1,atom_id:n.atom_id_1},o={entity_id:n.entity_id_2,asym_id:n.asym_id_2,seq_id:n.seq_id_2,atom_id:n.atom_id_2};function s(p,m,h){const g=p.get(m);g?g.push(h):p.set(m,[h])}function a(p,m){const h=m.entity_id.value(p),g=m.asym_id.value(p),y=m.seq_id.value(p);if("by-atom"===n.model_granularity.value(p)){const b=r.atomicHierarchy.index.findAtom({auth_seq_id:y,label_asym_id:g,label_atom_id:m.atom_id.value(p),label_entity_id:h});b>=0&&s(u,b,p)}else if(r.coarseHierarchy.isDefined){const b=r.coarseHierarchy.spheres.findSequenceKey(h,g,y);if(b>=0)s(l,b,p);else{const x=r.coarseHierarchy.gaussians.findSequenceKey(h,g,y);x>=0&&s(d,x,p)}}}const u=new Map,l=new Map,d=new Map,f=[];for(let p=0;p{const g=function c(p){switch(p){case 0:return u;case 1:return l;case 2:return d}}(m).get(p);return void 0!==g?g:f},data:n}}}(oh||(oh={}));const bct=[];function ude(e,t,n,r){return`${e}|${t.id}|${n}|${r.id}`}class lde{getPairIndices(t,n,r,i){const o=ude(t,n,r,i);return this.pairKeyIndices.get(o)||bct}getPairs(t,n,r,i){return this.getPairIndices(t,n,r,i).map(s=>this.pairs[s])}constructor(t){this.pairs=t;const n=new Map;this.pairs.forEach((r,i)=>{const o=ude(r.indexA,r.unitA,r.indexB,r.unitB),s=n.get(o);s?s.push(i):n.set(o,[i])}),this.count=t.length,this.pairKeyIndices=n}}const sh=vp.createProvider({label:"Cross Link Restraint",descriptor:au({name:"integrative-cross-link-restraint"}),type:"local",defaultParams:{},getParams:e=>({}),isApplicable:e=>e.models.some(t=>!!oh.Provider.get(t)),obtain:function(){var e=ie(function*(t,n,r){return{value:xct(n)}});return function(n,r,i){return e.apply(this,arguments)}}()});var yd;function dde(e,t,n){const{elements:r}=t,i=r.length,o=t.kind;for(let s=0;se.set(c,s))}function vct(e,t,n){if(t.model!==n.model||"mmCIF"!==t.model.sourceData.kind)return;const r=oh.Provider.get(t.model);if(!r)return;const i=new Map,o=new Map;dde(i,t,r),dde(o,n,r),i.forEach((s,a)=>{const c=o.get(a);void 0!==c&&e.push(QE(t,s,n,c,r,a),QE(n,c,t,s,r,a))})}function _ct(e,t){if("mmCIF"!==t.model.sourceData.kind)return;const n=oh.Provider.get(t.model);if(!n)return;const{elements:r}=t,i=r.length,o=t.kind,s=new Map;for(let a=0;a{const l=s.get(u);l?l.push(a):s.set(u,[a])});s.forEach((a,c)=>{if(a.length<2)return;const[u,l]=a;e.push(QE(t,u,t,l,n,c),QE(t,l,t,u,n,c))})}function QE(e,t,n,r,i,o){return{unitA:e,indexA:t,unitB:n,indexB:r,restraintType:i.data.restraint_type.value(o),distanceThreshold:i.data.distance_threshold.value(o),psi:i.data.psi.value(o),sigma1:i.data.sigma_1.value(o),sigma2:i.data.sigma_2.value(o)}}function xct(e){const t=[];if(!e.models.some(r=>oh.Provider.get(r)))return new lde(t);const n=e.units.length;for(let r=0;r{const m=o.pairs[p],h=m.unitA,g=m.unitB;h.conformation.position(h.elements[m.indexA],d),g.conformation.position(g.elements[m.indexB],f)},radius:d=>{const f=o.pairs[d];return a.unit=f.unitA,a.element=f.unitA.elements[f.indexA],n.size.size(a)*s}},{mesh:u,boundingSphere:l}=B0(0,c,r,i);if(l)u.setBoundingSphere(l);else if(u.triangleCount>0){const d=_e.expand(_e(),t.boundary.sphere,1*s);u.setBoundingSphere(d)}return u}!function(e){let t;(t=e.Tag||(e.Tag={})).CrossLinkRestraint="cross-link-restraint",e.isApplicable=function n(h){return h.models.some(g=>!!oh.Provider.get(g))};const r=v(),i=v();function o(h){return h.unitA.conformation.position(h.unitA.elements[h.indexA],r),h.unitB.conformation.position(h.unitB.elements[h.indexB],i),v.distance(r,i)}function u(h,g){const y=h.pairs[g];return`Cross Link Restraint | Type: ${y.restraintType} | Threshold: ${y.distanceThreshold} \u212b | Psi: ${y.psi} | Sigma 1: ${y.sigma1} | Sigma 2: ${y.sigma2} | Distance: ${o(y).toFixed(2)} \u212b`}function p(h,g,y){return Og.fromPairProvider(g.length,(b,x,_)=>{const S=h.pairs[g[b]];S.unitA.conformation.position(S.unitA.elements[S.indexA],x),S.unitB.conformation.position(S.unitB.elements[S.indexB],_)},y)}function m(h,g,y){const b=y[0];if(void 0===b)return"";const x=g.pairs[b];return[u(g,b),u8(Lt.Location(h,x.unitA,x.indexA,h,x.unitB,x.indexB))].join("
")}e.distance=o,e.Location=function s(h,g,y){return yre("cross-link-restraints",{structure:g,crossLinkRestraints:h},y)},e.isLocation=function a(h){return!!h&&"data-location"===h.kind&&"cross-link-restraints"===h.tag},e.areLocationsEqual=function c(h,g){return h.data.structure===g.data.structure&&h.data.crossLinkRestraints===g.data.crossLinkRestraints&&h.element===g.element},e.locationLabel=function l(h){return u(h.data.crossLinkRestraints,h.element)},e.Loci=function d(h,g,y){return nE("cross-link-restraints",{structure:h,crossLinkRestraints:g},y,b=>p(g,y,b),()=>m(h,g,y))},e.isLoci=function f(h){return!!h&&"data-loci"===h.kind&&"interactions"===h.tag},e.getBoundingSphere=p,e.getLabel=m}(yd||(yd={}));const fde={...n1,...F0,sizeFactor:C.Numeric(.5,{min:0,max:10,step:.1})};function Cct(e){return rh({defaultProps:C.getDefaultValues(fde),createGeometry:Sct,createLocationIterator:wct,getLoci:Act,eachLocation:Ict,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.radialSegments!==r.radialSegments||n.linkCap!==r.linkCap}},e)}function wct(e){const t=sh.get(e).value,{pairs:n}=t,r=n.length,o=yd.Location(t,e);return Mr(r,1,1,a=>(o.element=a,o),!0)}function Act(e,t,n){const{objectId:r,groupId:i}=e;if(n===r){const o=sh.get(t).value;if(o.pairs[i])return yd.Loci(t,o,[i])}return $n}function Ict(e,t,n){let r=!1;if(yd.isLoci(e)){if(!Ve.areEquivalent(e.data.structure,t))return!1;const i=sh.get(t).value;if(e.data.crossLinkRestraints!==i)return!1;for(const o of e.elements)n(Ce.ofSingleton(o))&&(r=!0)}return r}const Tct={"cross-link-restraint":(e,t)=>Iu("Cross-link restraint",e,t,Cct)},pde={...fde},hde={name:yd.Tag.CrossLinkRestraint,label:"Cross Link Restraint",description:"Displays cross-link restraints.",factory:function Ect(e,t){return yn.createMulti("CrossLinkRestraint",e,t,ms,Tct)},getParams:function Dct(e,t){return C.clone(pde)},defaultValues:C.getDefaultValues(pde),defaultColorTheme:{name:yd.Tag.CrossLinkRestraint},defaultSizeTheme:{name:"uniform"},isApplicable:e=>yd.isApplicable(e),ensureCustomProperties:{attach:(e,t)=>sh.attach(e,t,void 0,!0),detach:e=>sh.ref(e,!1)}},mde=st(13421772),gde={domain:C.Interval([.5,1.5],{step:.01}),list:C.ColorList("red-grey",{presetKind:"scale"})},bde={name:"cross-link",label:"Cross Link",category:Lc.Category.Misc,factory:function yde(e,t){let n,r;const i=e.structure&&sh.get(e.structure).value;if(i){r=Gu.create({domain:t.domain,listOrName:t.list.colors});const o=r.color;n=s=>{if(yd.isLocation(s)){const a=i.pairs[s.element];if(a)return o(yd.distance(a)/a.distanceThreshold)}return mde}}else n=()=>mde;return{factory:yde,granularity:"group",color:n,props:t,description:"Colors cross-links by the deviation of the observed distance versus the modeled distance (e.g. modeled / `ihm_cross_link_restraint.distance_threshold`).",legend:r?r.legend:void 0}},getParams:function Mct(e){return gde},defaultValues:C.getDefaultValues(gde),isApplicable:e=>!!e.structure&&yd.isApplicable(e.structure),ensureCustomProperties:{attach:(e,t)=>t.structure?sh.attach(e,t.structure,void 0,!0):Promise.resolve(),detach:e=>e.structure&&sh.ref(e.structure,!1)}},Rct=tr.create({name:"integrative-cross-link-restraint",category:"custom-props",display:{name:"Cross Link Restraint"},ctor:class extends tr.Handler{constructor(){super(...arguments),this.provider=oh.Provider}register(){this.provider.formatRegistry.add("mmCIF",kct),this.ctx.representation.structure.themes.colorThemeRegistry.add(bde),this.ctx.representation.structure.registry.add(hde)}unregister(){this.provider.formatRegistry.remove("mmCIF"),this.ctx.representation.structure.themes.colorThemeRegistry.remove(bde),this.ctx.representation.structure.registry.remove(hde)}}});function kct(e){if(!Er.is(e.sourceData))return;const{ihm_cross_link_restraint:t}=e.sourceData.data.db;return 0!==t._rowCount?oh.fromTable(t,e):void 0}const JE={State:KP,Representation:ZP,Camera:QP,Misc:JP},zc={Representation:eM,Camera:tM,CustomProps:nM};function e3(e,t,n={}){return"string"==typeof n.type||"string"==typeof n.color||"string"==typeof n.size?function Nct(e,t,n){const r=n.type&&e.representation.structure.registry.get(n.type)||e.representation.structure.registry.default.provider,i=n.color&&e.representation.structure.themes.colorThemeRegistry.get(n.color)||e.representation.structure.themes.colorThemeRegistry.get(r.defaultColorTheme.name),o=n.size&&e.representation.structure.themes.sizeThemeRegistry.get(n.size)||e.representation.structure.themes.sizeThemeRegistry.get(r.defaultSizeTheme.name);return _de(e,t,{type:r,typeParams:n.typeParams,color:i,colorParams:n.colorParams,size:o,sizeParams:n.sizeParams})}(e,t||Ve.Empty,n):_de(e,t||Ve.Empty,n)}function RU(e,t,n,r,i){const{registry:o,themes:s}=e.representation.structure,a=o.get(n||o.default.name),c=s.colorThemeRegistry.get(r||a.defaultColorTheme.name),u=C.getDefaultValues(c.getParams({structure:t||Ve.Empty}));return c.name===a.defaultColorTheme.name&&Object.assign(u,a.defaultColorTheme.props),{name:c.name,params:Object.assign(u,i)}}function vde(e,t,n,r,i){const{registry:o,themes:s}=e.representation.structure,a=o.get(n||o.default.name),c=s.sizeThemeRegistry.get(r||a.defaultSizeTheme.name),u=C.getDefaultValues(c.getParams({structure:t||Ve.Empty}));return c.name===a.defaultSizeTheme.name&&Object.assign(u,a.defaultSizeTheme.props),{name:c.name,params:Object.assign(u,i)}}function _de(e,t,n={}){const{themes:r}=e.representation.structure,i={structure:t},o=n.type||e.representation.structure.registry.default.provider,s=C.getDefaultValues(o.getParams(r,t)),a=Object.assign(s,n.typeParams),c=n.color||r.colorThemeRegistry.get(o.defaultColorTheme.name),u=C.getDefaultValues(c.getParams(i));c.name===o.defaultColorTheme.name&&Object.assign(u,o.defaultColorTheme.props);const l=Object.assign(u,n.colorParams),d=n.size||r.sizeThemeRegistry.get(o.defaultSizeTheme.name),f=C.getDefaultValues(d.getParams(i));d.name===o.defaultSizeTheme.name&&Object.assign(f,o.defaultSizeTheme.props);const p=Object.assign(f,n.sizeParams);return{type:{name:o.name,params:a},colorTheme:{name:c.name,params:l},sizeTheme:{name:d.name,params:p}}}const xde=["target","surroundings","interactions"];var oi=function(e){return e.TargetSel="structure-focus-target-sel",e.TargetRepr="structure-focus-target-repr",e.SurrSel="structure-focus-surr-sel",e.SurrRepr="structure-focus-surr-repr",e.SurrNciRepr="structure-focus-surr-nci-repr",e}(oi||{});const Bct=new Set([oi.TargetSel,oi.TargetRepr,oi.SurrSel,oi.SurrRepr,oi.SurrNciRepr]),t3=tr.create({name:"create-structure-focus-representation",display:{name:"Structure Focus Representation"},category:"interaction",ctor:class Oct extends tr.WithSubscribers{constructor(){super(...arguments),this.currentSource=void 0}get surrLabel(){return`[Focus] Surroundings (${this.params.expandRadius} \xc5)`}getReprParams(t){return{...t,type:{name:t.type.name,params:{...t.type.params,ignoreHydrogens:this.params.ignoreHydrogens,ignoreHydrogensVariant:this.params.ignoreHydrogensVariant,ignoreLight:this.params.ignoreLight,material:this.params.material,clip:this.params.clip}}}}ensureShape(t){var n;const r=this.plugin.state.data,i=r.tree,o=r.build(),s=In.findUniqueTagsInSubtree(i,t.transform.ref,Bct);s[oi.TargetSel]||(s[oi.TargetSel]=o.to(t).apply(Ye.Model.StructureSelectionFromBundle,{bundle:Kn.Empty,label:"[Focus] Target"},{tags:oi.TargetSel}).ref),s[oi.SurrSel]||(s[oi.SurrSel]=o.to(t).apply(Ye.Model.StructureSelectionFromExpression,{expression:ue.struct.generator.empty(),label:this.surrLabel},{tags:oi.SurrSel}).ref);const a=this.params.components;return a.indexOf("target")>=0&&!s[oi.TargetRepr]&&(s[oi.TargetRepr]=o.to(s[oi.TargetSel]).apply(Ye.Representation.StructureRepresentation3D,this.getReprParams(this.params.targetParams),{tags:oi.TargetRepr}).ref),a.indexOf("surroundings")>=0&&!s[oi.SurrRepr]&&(s[oi.SurrRepr]=o.to(s[oi.SurrSel]).apply(Ye.Representation.StructureRepresentation3D,this.getReprParams(this.params.surroundingsParams),{tags:oi.SurrRepr}).ref),a.indexOf("interactions")>=0&&!s[oi.SurrNciRepr]&&t.obj&&ZE.isApplicable(null===(n=t.obj)||void 0===n?void 0:n.data)&&(s[oi.SurrNciRepr]=o.to(s[oi.SurrSel]).apply(Ye.Representation.StructureRepresentation3D,this.getReprParams(this.params.nciParams),{tags:oi.SurrNciRepr}).ref),{state:r,builder:o,refs:s}}clear(t){const n=this.plugin.state.data;this.currentSource=void 0;const r=n.select(In.Generators.byRef(t).subtree().withTag(oi.TargetSel)),i=n.select(In.Generators.byRef(t).subtree().withTag(oi.SurrSel));if(0===r.length&&0===i.length)return;const o=n.build(),s=Kn.Empty;for(const c of r)o.to(c).update(Ye.Model.StructureSelectionFromBundle,u=>({...u,bundle:s}));const a=ue.struct.generator.empty();for(const c of i)o.to(c).update(Ye.Model.StructureSelectionFromExpression,u=>({...u,expression:a}));return Cn.State.Update(this.plugin,{state:n,tree:o,options:{doNotLogTiming:!0,doNotUpdateCurrent:!0}})}focus(t){var n=this;return ie(function*(){const r=n.plugin.helpers.substructureParent.get(t.structure);if(!r||!r.obj)return;n.currentSource=t;const i=De.remap(t,r.obj.data),o=De.extendToWholeResidues(i),s=Kn.fromLoci(o),a=Kn.toExpression(s);let c=ue.struct.modifier.includeSurroundings({0:a,radius:n.params.expandRadius,"as-whole-residues":!0});n.params.excludeTargetFromSurroundings&&(c=ue.struct.modifier.exceptBy({0:c,by:a}));const{state:u,builder:l,refs:d}=n.ensureShape(r);l.to(d[oi.TargetSel]).update(Ye.Model.StructureSelectionFromBundle,f=>({...f,bundle:s})),l.to(d[oi.SurrSel]).update(Ye.Model.StructureSelectionFromExpression,f=>({...f,expression:c,label:n.surrLabel})),yield Cn.State.Update(n.plugin,{state:u,tree:l,options:{doNotLogTiming:!0,doNotUpdateCurrent:!0}})})()}register(t){this.subscribeObservable(this.plugin.managers.structure.focus.behaviors.current,n=>{n?this.focus(n.loci):this.clear(ur.RootRef)})}update(t){var n=this;return ie(function*(){const r=n.params;if(n.params=t,r.excludeTargetFromSurroundings!==t.excludeTargetFromSurroundings)return n.currentSource&&n.focus(n.currentSource),!0;const i=n.plugin.state.data,o=i.build(),s=In.Generators.root.subtree(),a=n.params.components;let c=a.indexOf("target")>=0;for(const u of i.select(s.withTag(oi.TargetRepr)))c?o.to(u).update(n.getReprParams(n.params.targetParams)):o.delete(u.transform.ref);c=a.indexOf("surroundings")>=0;for(const u of i.select(s.withTag(oi.SurrRepr)))c?o.to(u).update(n.getReprParams(n.params.surroundingsParams)):o.delete(u.transform.ref);c=a.indexOf("interactions")>=0;for(const u of i.select(s.withTag(oi.SurrNciRepr)))c?o.to(u).update(n.getReprParams(n.params.nciParams)):o.delete(u.transform.ref);return yield Cn.State.Update(n.plugin,{state:i,tree:o,options:{doNotLogTiming:!0,doNotUpdateCurrent:!0}}),t.expandRadius!==r.expandRadius&&n.currentSource&&n.focus(n.currentSource),!0})()}},params:(e,t)=>(e=>{const t=Ye.Representation.StructureRepresentation3D.definition.params(void 0,e);return{expandRadius:C.Numeric(5,{min:1,max:10,step:1}),targetParams:C.Group(t,{label:"Target",customDefault:e3(e,void 0,{type:"ball-and-stick",size:"physical",typeParams:{sizeFactor:.22,sizeAspectRatio:.73,adjustCylinderLength:!0,xrayShaded:!0,aromaticBonds:!1,multipleBonds:"off",excludeTypes:["hydrogen-bond","metal-coordination"]}})}),surroundingsParams:C.Group(t,{label:"Surroundings",customDefault:e3(e,void 0,{type:"ball-and-stick",size:"physical",typeParams:{sizeFactor:.16,excludeTypes:["hydrogen-bond","metal-coordination"]}})}),nciParams:C.Group(t,{label:"Non-covalent Int.",customDefault:e3(e,void 0,{type:ZE,color:xU,size:Qo.BuiltIn.uniform})}),components:C.MultiSelect(xde,C.arrayToOptions(xde)),excludeTargetFromSurroundings:C.Boolean(!1,{label:"Exclude Target",description:'Exclude the focus "target" from the surroudings component.'}),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),ignoreLight:C.Boolean(!1),material:ba.getParam(),clip:C.Group(gm.Params)}})(t)});function oa(e){return e}!function(e){function t(o){return"chain-id"===o?{name:o,params:use.defaultValues}:"operator-name"===o?{name:o,params:F6.defaultValues}:{name:o,params:{}}}e.CommonParams={ignoreHydrogens:C.Optional(C.Boolean(!1)),ignoreHydrogensVariant:C.Optional(C.Select("all",C.arrayToOptions(["all","non-polar"]))),ignoreLight:C.Optional(C.Boolean(!1)),quality:C.Optional(C.Select("auto",n5)),theme:C.Optional(C.Group({globalName:C.Optional(C.Text("")),globalColorParams:C.Optional(C.Value({},{isHidden:!0})),carbonColor:C.Optional(C.Select("chain-id",C.arrayToOptions(["chain-id","operator-name","element-symbol"]))),symmetryColor:C.Optional(C.Text("")),symmetryColorParams:C.Optional(C.Value({},{isHidden:!0})),focus:C.Optional(C.Group({name:C.Optional(C.Text("")),params:C.Optional(C.Value({}))}))}))},e.reprBuilder=function r(o,s,a){var c,u,l,d,f,p,m,h,g,y,b,x,_,S;const A=o.state.data.build(),E=o.builders.structure.representation,w=o.managers.structure.component.state.options.hydrogens,D={quality:o.managers.structure.component.state.options.visualQuality,ignoreHydrogens:"all"!==w,ignoreHydrogensVariant:"only-polar"===w?"non-polar":"all",ignoreLight:o.managers.structure.component.state.options.ignoreLight};s.quality&&"auto"!==s.quality&&(D.quality=s.quality),void 0!==s.ignoreHydrogens&&(D.ignoreHydrogens=!!s.ignoreHydrogens),void 0!==s.ignoreHydrogensVariant&&(D.ignoreHydrogensVariant=s.ignoreHydrogensVariant),void 0!==s.ignoreLight&&(D.ignoreLight=!!s.ignoreLight);const I=null!==(c=s.theme)&&void 0!==c&&c.globalName?null===(u=s.theme)||void 0===u?void 0:u.globalName:void 0,R=void 0!==(null===(l=s.theme)||void 0===l?void 0:l.carbonColor)?{carbonColor:t(null===(d=s.theme)||void 0===d?void 0:d.carbonColor),...null===(f=s.theme)||void 0===f?void 0:f.globalColorParams}:{...null===(p=s.theme)||void 0===p?void 0:p.globalColorParams},T=a&&null!==(m=s.theme)&&void 0!==m&&m.symmetryColor&&function n(o){return o.units.some(s=>!s.conformation.operator.assembly&&s.conformation.operator.spgrOp>=0)}(a)?null===(h=s.theme)||void 0===h?void 0:h.symmetryColor:I;return{update:A,builder:E,color:I,symmetryColor:T,symmetryColorParams:null!==(g=s.theme)&&void 0!==g&&g.symmetryColorParams?{...null===(y=s.theme)||void 0===y?void 0:y.globalColorParams,...null===(b=s.theme)||void 0===b?void 0:b.symmetryColorParams}:{...null===(x=s.theme)||void 0===x?void 0:x.globalColorParams},globalColorParams:null!==(_=s.theme)&&void 0!==_&&_.globalColorParams?{...null===(S=s.theme)||void 0===S?void 0:S.globalColorParams}:void 0,typeParams:D,ballAndStickColor:R}},e.updateFocusRepr=function i(o,s,a,c){if(o.state.hasBehavior(t3))return o.state.updateBehavior(t3,u=>{const l=RU(o,s,"ball-and-stick",a||"element-symbol",c);u.surroundingsParams.colorTheme=l,u.targetParams.colorTheme=l})}}(oa||(oa={}));const km=oa.CommonParams,O0=oa.reprBuilder,L0=oa.updateFocusRepr,Lct=oa({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:()=>km,apply(e,t,n){var r,i;const o=null===(i=null===(r=ls.resolveAndCheck(n.state.data,e))||void 0===r?void 0:r.obj)||void 0===i?void 0:i.data;if(!o)return{};const s=n.config.get(qi.Structure.SizeThresholds)||Ve.DefaultSizeThresholds,a=Ve.getSize(o,s),c=o.polymerResidueCount/o.polymerGapCount;switch(a){case Ve.Size.Gigantic:case Ve.Size.Huge:return Cde.apply(e,t,n);case Ve.Size.Large:return wde.apply(e,t,n);case Ve.Size.Medium:if(c>3)return Sde.apply(e,t,n);case Ve.Size.Small:return Ade.apply(e,{...t,showCarbohydrateSymbol:!0},n);default:Rr()}}}),Uct=oa({id:"preset-structure-representation-empty",display:{name:"Empty",description:"Removes all existing representations."},apply:(e,t,n)=>ie(function*(){return{}})()}),uC="Basic",Sde=oa({id:"preset-structure-representation-polymer-and-ligand",display:{name:"Polymer & Ligand",group:uC,description:"Shows polymers as Cartoon, ligands as Ball & Stick, carbohydrates as 3D-SNFG and water molecules semi-transparent."},params:()=>km,apply:(e,t,n)=>ie(function*(){var r,i,o,s,a,c,u,l,d,f;const p=ls.resolveAndCheck(n.state.data,e);if(!p)return{};const m={polymer:yield pc(n,p,"polymer"),ligand:yield pc(n,p,"ligand"),nonStandard:yield pc(n,p,"non-standard"),branched:yield pc(n,p,"branched",{label:"Carbohydrate"}),water:yield pc(n,p,"water"),ion:yield pc(n,p,"ion"),lipid:yield pc(n,p,"lipid"),coarse:yield pc(n,p,"coarse")},h=p.obj.data,g={sizeFactor:h.isCoarseGrained?.8:.2},y=((null===(o=null===(i=null===(r=m.water)||void 0===r?void 0:r.obj)||void 0===i?void 0:i.data)||void 0===o?void 0:o.elementCount)||0)>5e4?"line":"ball-and-stick",b=((null===(c=null===(a=null===(s=m.lipid)||void 0===s?void 0:s.obj)||void 0===a?void 0:a.data)||void 0===c?void 0:c.elementCount)||0)>2e4?"line":"ball-and-stick",{update:x,builder:_,typeParams:S,color:A,symmetryColor:E,symmetryColorParams:w,globalColorParams:D,ballAndStickColor:I}=O0(n,t,h),R={polymer:_.buildRepresentation(x,m.polymer,{type:"cartoon",typeParams:{...S,...g},color:E,colorParams:w},{tag:"polymer"}),ligand:_.buildRepresentation(x,m.ligand,{type:"ball-and-stick",typeParams:S,color:A,colorParams:I},{tag:"ligand"}),nonStandard:_.buildRepresentation(x,m.nonStandard,{type:"ball-and-stick",typeParams:S,color:A,colorParams:I},{tag:"non-standard"}),branchedBallAndStick:_.buildRepresentation(x,m.branched,{type:"ball-and-stick",typeParams:{...S,alpha:.3},color:A,colorParams:I},{tag:"branched-ball-and-stick"}),branchedSnfg3d:_.buildRepresentation(x,m.branched,{type:"carbohydrate",typeParams:S,color:A,colorParams:D},{tag:"branched-snfg-3d"}),water:_.buildRepresentation(x,m.water,{type:y,typeParams:{...S,alpha:.6,visuals:"line"===y?["intra-bond","element-point"]:void 0},color:A,colorParams:{carbonColor:{name:"element-symbol",params:{}},...D}},{tag:"water"}),ion:_.buildRepresentation(x,m.ion,{type:"ball-and-stick",typeParams:S,color:A,colorParams:{carbonColor:{name:"element-symbol",params:{}},...D}},{tag:"ion"}),lipid:_.buildRepresentation(x,m.lipid,{type:b,typeParams:{...S,alpha:.6,visuals:"line"===b?["intra-bond"]:void 0},color:A,colorParams:{carbonColor:{name:"element-symbol",params:{}},...D}},{tag:"lipid"}),coarse:_.buildRepresentation(x,m.coarse,{type:"spacefill",typeParams:S,color:A||"chain-id",colorParams:D},{tag:"coarse"})};return yield x.commit({revertOnError:!1}),yield L0(n,h,null===(l=null===(u=t.theme)||void 0===u?void 0:u.focus)||void 0===l?void 0:l.name,null===(f=null===(d=t.theme)||void 0===d?void 0:d.focus)||void 0===f?void 0:f.params),{components:m,representations:R}})()}),Vct=oa({id:"preset-structure-representation-protein-and-nucleic",display:{name:"Protein & Nucleic",group:uC,description:"Shows proteins as Cartoon and RNA/DNA as Gaussian Surface."},params:()=>km,apply:(e,t,n)=>ie(function*(){var r,i,o,s;const a=ls.resolveAndCheck(n.state.data,e);if(!a)return{};const c={protein:yield Ide(n,a,"protein"),nucleic:yield Ide(n,a,"nucleic")},u=a.obj.data,l={sizeFactor:u.isCoarseGrained?.8:.2},d={radiusOffset:u.isCoarseGrained?2:0,smoothness:u.isCoarseGrained?1:1.5},{update:f,builder:p,typeParams:m,symmetryColor:h,symmetryColorParams:g}=O0(n,t,u),y={protein:p.buildRepresentation(f,c.protein,{type:"cartoon",typeParams:{...m,...l},color:h,colorParams:g},{tag:"protein"}),nucleic:p.buildRepresentation(f,c.nucleic,{type:"gaussian-surface",typeParams:{...m,...d},color:h,colorParams:g},{tag:"nucleic"})};return yield f.commit({revertOnError:!0}),yield L0(n,u,null===(i=null===(r=t.theme)||void 0===r?void 0:r.focus)||void 0===i?void 0:i.name,null===(s=null===(o=t.theme)||void 0===o?void 0:o.focus)||void 0===s?void 0:s.params),{components:c,representations:y}})()}),Cde=oa({id:"preset-structure-representation-coarse-surface",display:{name:"Coarse Surface",group:uC,description:"Shows polymers and lipids as coarse Gaussian Surface."},params:()=>km,apply:(e,t,n)=>ie(function*(){var r,i,o,s;const a=ls.resolveAndCheck(n.state.data,e);if(!a)return{};const c={polymer:yield pc(n,a,"polymer"),lipid:yield pc(n,a,"lipid")},u=a.obj.data,l=n.config.get(qi.Structure.SizeThresholds)||Ve.DefaultSizeThresholds,d=Ve.getSize(u,l),f=Object.create(null);d===Ve.Size.Gigantic?Object.assign(f,{traceOnly:!u.isCoarseGrained,radiusOffset:2,smoothness:1,visuals:["structure-gaussian-surface-mesh"]}):d===Ve.Size.Huge?Object.assign(f,{radiusOffset:u.isCoarseGrained?2:0,smoothness:1}):u.isCoarseGrained&&Object.assign(f,{radiusOffset:2,smoothness:1});const{update:p,builder:m,typeParams:h,symmetryColor:g,symmetryColorParams:y}=O0(n,t,u),b={polymer:m.buildRepresentation(p,c.polymer,{type:"gaussian-surface",typeParams:{...h,...f},color:g,colorParams:y},{tag:"polymer"}),lipid:m.buildRepresentation(p,c.lipid,{type:"gaussian-surface",typeParams:{...h,...f},color:g,colorParams:y},{tag:"lipid"})};return yield p.commit({revertOnError:!0}),yield L0(n,u,null===(i=null===(r=t.theme)||void 0===r?void 0:r.focus)||void 0===i?void 0:i.name,null===(s=null===(o=t.theme)||void 0===o?void 0:o.focus)||void 0===s?void 0:s.params),{components:c,representations:b}})()}),wde=oa({id:"preset-structure-representation-polymer-cartoon",display:{name:"Polymer Cartoon",group:uC,description:"Shows polymers as Cartoon."},params:()=>km,apply:(e,t,n)=>ie(function*(){var r,i,o,s;const a=ls.resolveAndCheck(n.state.data,e);if(!a)return{};const c={polymer:yield pc(n,a,"polymer")},u=a.obj.data,l={sizeFactor:u.isCoarseGrained?.8:.2},{update:d,builder:f,typeParams:p,symmetryColor:m,symmetryColorParams:h}=O0(n,t,u),g={polymer:f.buildRepresentation(d,c.polymer,{type:"cartoon",typeParams:{...p,...l},color:m,colorParams:h},{tag:"polymer"})};return yield d.commit({revertOnError:!0}),yield L0(n,u,null===(i=null===(r=t.theme)||void 0===r?void 0:r.focus)||void 0===i?void 0:i.name,null===(s=null===(o=t.theme)||void 0===o?void 0:o.focus)||void 0===s?void 0:s.params),{components:c,representations:g}})()}),Ade=oa({id:"preset-structure-representation-atomic-detail",display:{name:"Atomic Detail",group:uC,description:"Shows everything in atomic detail with Ball & Stick."},params:()=>({...km,showCarbohydrateSymbol:C.Boolean(!1)}),apply:(e,t,n)=>ie(function*(){var r,i,o,s,a,c;const u=ls.resolveAndCheck(n.state.data,e);if(!u)return{};const l={all:yield pc(n,u,"all"),branched:void 0},d=u.obj.data,f=d.elementCount>1e5,p=d.atomicResidueCount&&d.elementCount>1e3&&d.atomicResidueCount/d.elementCount<3,m=d.models[0],h=!!Ms.Provider.get(m)||du.isExhaustive(m);let g="ball-and-stick";d.isCoarseGrained?g=d.elementCount>1e6?"point":"spacefill":p&&!h?g="spacefill":f&&(g="line");const y=t.showCarbohydrateSymbol&&!f&&!p;y&&Object.assign(l,{branched:yield pc(n,u,"branched",{label:"Carbohydrate"})});const{update:b,builder:x,typeParams:_,color:S,ballAndStickColor:A,globalColorParams:E}=O0(n,t,d),w=p&&!h?{carbonColor:{name:"element-symbol",params:{}},...E}:A,D={all:x.buildRepresentation(b,l.all,{type:g,typeParams:_,color:S,colorParams:w},{tag:"all"})};return y&&Object.assign(D,{snfg3d:x.buildRepresentation(b,l.branched,{type:"carbohydrate",typeParams:{..._,alpha:.4,visuals:["carbohydrate-symbol"]},color:S,colorParams:E},{tag:"snfg-3d"})}),yield b.commit({revertOnError:!0}),yield L0(n,d,null!==(o=null===(i=null===(r=t.theme)||void 0===r?void 0:r.focus)||void 0===i?void 0:i.name)&&void 0!==o?o:S,null!==(c=null===(a=null===(s=t.theme)||void 0===s?void 0:s.focus)||void 0===a?void 0:a.params)&&void 0!==c?c:w),{components:l,representations:D}})()}),zct=oa({id:"preset-structure-representation-illustrative",display:{name:"Illustrative",group:"Miscellaneous",description:"..."},params:()=>({...km,showCarbohydrateSymbol:C.Boolean(!1)}),apply:(e,t,n)=>ie(function*(){var r,i,o,s,a;const c=ls.resolveAndCheck(n.state.data,e);if(!c)return{};const u={all:yield pc(n,c,"all"),branched:void 0},l=c.obj.data,{update:d,builder:f,typeParams:p,color:m}=O0(n,t,l),h={all:f.buildRepresentation(d,u.all,{type:"spacefill",typeParams:{...p,ignoreLight:!0},color:"illustrative"},{tag:"all"})};return yield d.commit({revertOnError:!0}),yield L0(n,l,null!==(o=null===(i=null===(r=t.theme)||void 0===r?void 0:r.focus)||void 0===i?void 0:i.name)&&void 0!==o?o:m,null===(a=null===(s=t.theme)||void 0===s?void 0:s.focus)||void 0===a?void 0:a.params),{components:u,representations:h}})()}),Gct=oa({id:"preset-structure-representation-auto-lod",display:{name:"Automatic Detail",group:"Miscellaneous",description:"Shows more (or less) detailed representations automatically based on camera distance."},params:()=>km,apply:(e,t,n)=>ie(function*(){var r,i,o,s;const a=ls.resolveAndCheck(n.state.data,e);if(!a)return{};const c={all:yield pc(n,a,"all")},u=a.obj.data,l={sizeFactor:u.isCoarseGrained?.8:.2},{update:d,builder:f,typeParams:p,color:m,symmetryColor:h,symmetryColorParams:g,ballAndStickColor:y}=O0(n,t,u),b={gaussianSurface:f.buildRepresentation(d,c.all,{type:"gaussian-surface",typeParams:{...p,lod:v.create(30,1e7,100)},color:h,colorParams:g},{tag:"gaussian-surface"}),cartoon:f.buildRepresentation(d,c.all,{type:"cartoon",typeParams:{...p,...l,lod:v.create(-20,300,100)},color:h,colorParams:g},{tag:"cartoon"}),ballAndStick:f.buildRepresentation(d,c.all,{type:"ball-and-stick",typeParams:{...p,lod:v.create(-20,40,20)},color:m,colorParams:y},{tag:"ball-and-stick"})};return yield d.commit({revertOnError:!1}),yield L0(n,u,null===(i=null===(r=t.theme)||void 0===r?void 0:r.focus)||void 0===i?void 0:i.name,null===(s=null===(o=t.theme)||void 0===o?void 0:o.focus)||void 0===s?void 0:s.params),{components:c,representations:b}})()});function pc(e,t,n,r){return e.builders.structure.tryCreateComponentStatic(t,n,r)}function Ide(e,t,n,r){return e.builders.structure.tryCreateComponentFromSelection(t,No[n],`selection-${n}`,r)}const Mf={empty:Uct,auto:Lct,"atomic-detail":Ade,"polymer-cartoon":wde,"polymer-and-ligand":Sde,"protein-and-nucleic":Vct,"coarse-surface":Cde,illustrative:zct,"auto-lod":Gct};function n3(e,t){if("bcif"===e.ext)try{const{encoder:n}=$J(t);if(n.startsWith("VolumeServer"))return"dscif";if(n.startsWith("volseg-volume-server"))return"segcif"}catch(n){console.error(n)}else if("cif"===e.ext){const n=t;if(n.startsWith("data_SERVER\n#\n_density_server_result"))return"dscif";if(n.startsWith("data_SERVER\n#\ndata_SEGMENTATION_DATA"))return"segcif";if(n.includes("atom_site_fract_x")||n.includes("atom_site.fract_x"))return"coreCif"}return-1}const bd="Trajectory";function ah(e,t){return e.builders.structure.hierarchy.applyPreset(t.trajectory,"default")}const jct={label:"mmCIF",description:"mmCIF",category:bd,stringExtensions:["cif","mmcif","mcif"],binaryExtensions:["bcif"],isApplicable:(e,t)=>"mmcif"===e.ext||"mcif"===e.ext||("cif"===e.ext||"bcif"===e.ext)&&-1===n3(e,t),parse:function(){var e=ie(function*(t,n,r){var i,o;const a=t.state.data.build().to(n).apply(Ye.Data.ParseCif,void 0,{state:{isGhost:!0}}),c=yield a.apply(Ye.Model.TrajectoryFromMmCif,void 0,{tags:r?.trajectoryTags}).commit({revertOnError:!0});return((null===(o=null===(i=a.selector.cell)||void 0===i?void 0:i.obj)||void 0===o?void 0:o.data.blocks.length)||0)>1&&t.state.data.updateCellState(a.ref,{isGhost:!1}),{trajectory:c}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:ah},Hct={label:"cifCore",description:"CIF Core",category:bd,stringExtensions:["cif"],isApplicable:(e,t)=>"cif"===e.ext&&"coreCif"===n3(e,t),parse:function(){var e=ie(function*(t,n,r){var i,o;const a=t.state.data.build().to(n).apply(Ye.Data.ParseCif,void 0,{state:{isGhost:!0}}),c=yield a.apply(Ye.Model.TrajectoryFromCifCore,void 0,{tags:r?.trajectoryTags}).commit({revertOnError:!0});return((null===(o=null===(i=a.selector.cell)||void 0===i?void 0:i.obj)||void 0===o?void 0:o.data.blocks.length)||0)>1&&t.state.data.updateCellState(a.ref,{isGhost:!1}),{trajectory:c}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:ah};function U0(e,t){return function(){var n=ie(function*(r,i,o){return{trajectory:yield r.state.data.build().to(i).apply(e,t,{tags:o?.trajectoryTags}).commit({revertOnError:!0})}});return function(r,i,o){return n.apply(this,arguments)}}()}const qct={label:"PDB",description:"PDB",category:bd,stringExtensions:["pdb","ent"],parse:U0(Ye.Model.TrajectoryFromPDB),visuals:ah},Wct={label:"PDBQT",description:"PDBQT",category:bd,stringExtensions:["pdbqt"],parse:U0(Ye.Model.TrajectoryFromPDB,{isPdbqt:!0}),visuals:ah},$ct={label:"XYZ",description:"XYZ",category:bd,stringExtensions:["xyz"],parse:U0(Ye.Model.TrajectoryFromXYZ),visuals:ah},Tde=[["mmcif",jct],["cifCore",Hct],["pdb",qct],["pdbqt",Wct],["gro",{label:"GRO",description:"GRO",category:bd,stringExtensions:["gro"],binaryExtensions:[],parse:U0(Ye.Model.TrajectoryFromGRO),visuals:ah}],["xyz",$ct],["mol",{label:"MOL",description:"MOL",category:bd,stringExtensions:["mol"],parse:U0(Ye.Model.TrajectoryFromMOL),visuals:ah}],["sdf",{label:"SDF",description:"SDF",category:bd,stringExtensions:["sdf","sd"],parse:U0(Ye.Model.TrajectoryFromSDF),visuals:ah}],["mol2",{label:"MOL2",description:"MOL2",category:bd,stringExtensions:["mol2"],parse:U0(Ye.Model.TrajectoryFromMOL2),visuals:ah}]],Qct=["gz","zip"];function i1(e){let t=e,n="";const r=t.lastIndexOf("?"),i=-1!==r?t.substring(r):"";t=t.substring(0,-1===r?t.length:r);const o=t.replace(/^.*[\\/]/,"");let s=o.substring(0,o.lastIndexOf("."));const a=o.split(".");let c=a.length>1?(a.pop()||"").toLowerCase():"";const u=t.match(/^(.+):\/\/(.+)$/);u&&(n=u[1].toLowerCase(),t=u[2]||"");const l=t.substring(0,t.lastIndexOf("/")+1);return Qct.includes(c)&&(c=(t.substr(0,t.length-c.length-1).split(".").pop()||"").toLowerCase(),s=s.substr(0,s.length-c.length-1)),{path:t,name:o,ext:c,base:s,dir:l,protocol:n,query:i}}const lC="Topology",Jct={label:"PSF",description:"PSF",category:lC,stringExtensions:["psf"],parse:function(){var e=ie(function*(t,n){const r=t.state.data.build().to(n).apply(Ye.Data.ParsePsf,{},{state:{isGhost:!0}}),i=r.apply(Ye.Model.TopologyFromPsf);return yield r.commit(),{format:r.selector,topology:i.selector}});return function(n,r){return e.apply(this,arguments)}}()},eut={label:"PRMTOP",description:"PRMTOP",category:lC,stringExtensions:["prmtop","parm7"],parse:function(){var e=ie(function*(t,n){const r=t.state.data.build().to(n).apply(Ye.Data.ParsePrmtop,{},{state:{isGhost:!0}}),i=r.apply(Ye.Model.TopologyFromPrmtop);return yield r.commit(),{format:r.selector,topology:i.selector}});return function(n,r){return e.apply(this,arguments)}}()},tut={label:"TOP",description:"TOP",category:lC,stringExtensions:["top"],parse:function(){var e=ie(function*(t,n){const r=t.state.data.build().to(n).apply(Ye.Data.ParseTop,{},{state:{isGhost:!0}}),i=r.apply(Ye.Model.TopologyFromTop);return yield r.commit(),{format:r.selector,topology:i.selector}});return function(n,r){return e.apply(this,arguments)}}()},nut=[["psf",Jct],["prmtop",eut],["top",tut]],o1="Coordinates",rut={label:"DCD",description:"DCD",category:o1,binaryExtensions:["dcd"],parse:(e,t)=>e.state.data.build().to(t).apply(Ye.Model.CoordinatesFromDcd).commit()},iut={label:"XTC",description:"XTC",category:o1,binaryExtensions:["xtc"],parse:(e,t)=>e.state.data.build().to(t).apply(Ye.Model.CoordinatesFromXtc).commit()},out={label:"TRR",description:"TRR",category:o1,binaryExtensions:["trr"],parse:(e,t)=>e.state.data.build().to(t).apply(Ye.Model.CoordinatesFromTrr).commit()},sut={label:"NCTRAJ",description:"NCTRAJ",category:o1,binaryExtensions:["nc","nctraj"],parse:(e,t)=>e.state.data.build().to(t).apply(Ye.Model.CoordinatesFromNctraj).commit()},aut=[["dcd",rut],["xtc",iut],["trr",out],["nctraj",sut]],Dde={rcsb:C.Group({encoding:C.Select("bcif",C.arrayToOptions(["cif","bcif"]))},{label:"RCSB PDB",isFlat:!0}),pdbe:C.Group({variant:C.Select("updated-bcif",[["updated-bcif","Updated (bcif)"],["updated","Updated"],["archival","Archival"]])},{label:"PDBe",isFlat:!0}),pdbj:C.EmptyGroup({label:"PDBj"})},uut=nc.build({from:pe.Root,display:{name:"Download Structure",description:"Load a structure from the provided source and create its representation."},params:(e,t)=>{const n=(e=>{const t=e.config.get(qi.Structure.DefaultRepresentationPreset)||Mf.auto.id;return C.Group({type:b0.getParams(void 0,"auto").type,representation:C.Select(t,e.builders.structure.representation.getPresets().map(n=>[n.id,n.display.name,n.display.group]),{description:"Which representation preset to use."}),representationParams:C.Group(oa.CommonParams,{isHidden:!0}),asTrajectory:C.Optional(C.Boolean(!1,{description:"Load all entries into a single trajectory."}))},{isExpanded:!1})})(t),r=t.config.get(qi.Download.DefaultPdbProvider)||"pdbe";return{source:C.MappedStatic("pdb",{pdb:C.Group({provider:C.Group({id:C.Text("1tqn",{label:"PDB Id(s)",description:"One or more comma/space separated PDB ids."}),server:C.MappedStatic(r,Dde)},{pivot:"id"}),options:n},{isFlat:!0,label:"PDB"}),"pdb-dev":C.Group({provider:C.Group({id:C.Text("PDBDEV_00000001",{label:"PDB-Dev Id(s)",description:"One or more comma/space separated ids."}),encoding:C.Select("bcif",C.arrayToOptions(["cif","bcif"]))},{pivot:"id"}),options:n},{isFlat:!0,label:"PDB-Dev"}),swissmodel:C.Group({id:C.Text("Q9Y2I8",{label:"UniProtKB AC(s)",description:"One or more comma/space separated ACs."}),options:n},{isFlat:!0,label:"SWISS-MODEL",description:"Loads the best homology model or experimental structure"}),alphafolddb:C.Group({id:C.Text("Q8W3K0",{label:"UniProtKB AC(s)",description:"One or more comma/space separated ACs."}),options:n},{isFlat:!0,label:"AlphaFold DB",description:"Loads the predicted model if available"}),modelarchive:C.Group({id:C.Text("ma-bak-cepc-0003",{label:"Accession Code(s)",description:"One or more comma/space separated ACs."}),options:n},{isFlat:!0,label:"Model Archive"}),pubchem:C.Group({id:C.Text("2244,2245",{label:"PubChem ID",description:"One or more comma/space separated IDs."}),options:n},{isFlat:!0,label:"PubChem",description:"Loads 3D conformer from PubChem."}),url:C.Group({url:C.Url(""),format:C.Select("mmcif",C.arrayToOptions(Tde.map(i=>i[0]),i=>i)),isBinary:C.Boolean(!1),label:C.Optional(C.Text("")),options:n},{isFlat:!0,label:"URL"})})}}})(({params:e,state:t},n)=>Oe.create("Download Structure",function(){var r=ie(function*(i){n.behaviors.layout.leftPanelTabName.next("data");const o=e.source;let s,a=!1,c="mmcif";switch(o.name){case"url":s=[{url:o.params.url,isBinary:o.params.isBinary,label:o.params.label||void 0}],c=o.params.format;break;case"pdb":s=yield"pdbe"===o.params.provider.server.name?function lut(e){return NU.apply(this,arguments)}(o):"pdbj"===o.params.provider.server.name?function dut(e){return FU.apply(this,arguments)}(o):"rcsb"===o.params.provider.server.name?function fut(e){return BU.apply(this,arguments)}(o):Rr(),a=!!o.params.options.asTrajectory;break;case"pdb-dev":s=yield vd(o.params.provider.id,f=>{const p=f.toUpperCase().startsWith("PDBDEV_")?f:`PDBDEV_${f.padStart(8,"0")}`;return"bcif"===o.params.provider.encoding?`https://pdb-dev.wwpdb.org/bcif/${p.toUpperCase()}.bcif`:`https://pdb-dev.wwpdb.org/cif/${p.toUpperCase()}.cif`},f=>f.toUpperCase().startsWith("PDBDEV_")?f:`PDBDEV_${f.padStart(8,"0")}`,"bcif"===o.params.provider.encoding),a=!!o.params.options.asTrajectory;break;case"swissmodel":s=yield vd(o.params.id,f=>`https://swissmodel.expasy.org/repository/uniprot/${f.toUpperCase()}.pdb`,f=>`SWISS-MODEL: ${f}`,!1),a=!!o.params.options.asTrajectory,c="pdb";break;case"alphafolddb":s=yield vd(o.params.id,function(){var f=ie(function*(p){const m=`https://www.alphafold.ebi.ac.uk/api/prediction/${p.toUpperCase()}`,h=yield n.runTask(n.fetch({url:m,type:"json"}));if(Array.isArray(h)&&h.length>0)return h[0].cifUrl;throw new Error(`No AlphaFold DB entry for '${p}'`)});return function(p){return f.apply(this,arguments)}}(),f=>`AlphaFold DB: ${f}`,!1),a=!!o.params.options.asTrajectory,c="mmcif";break;case"modelarchive":s=yield vd(o.params.id,f=>`https://www.modelarchive.org/doi/10.5452/${f.toLowerCase()}.cif`,f=>`Model Archive: ${f}`,!1),a=!!o.params.options.asTrajectory,c="mmcif";break;case"pubchem":s=yield vd(o.params.id,f=>`https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/CID/${f.trim()}/record/SDF/?record_type=3d`,f=>`PubChem: ${f}`,!1),a=!!o.params.options.asTrajectory,c="mol";break;default:Rr()}const u=e.source.params.options.representation||n.config.get(qi.Structure.DefaultRepresentationPreset)||Mf.auto.id,l=u!==Mf.empty.id,d="auto"===o.params.options.type.name?void 0:o.params.options.type;yield t.transaction(ie(function*(){var f;if(s.length>0&&a){const p=yield n.builders.data.downloadBlob({sources:s.map((h,g)=>({id:""+g,url:h.url,isBinary:h.isBinary})),maxConcurrency:6},{state:{isGhost:!0}}),m=yield n.builders.structure.parseTrajectory(p,{formats:s.map((h,g)=>({id:""+g,format:"cif"}))});yield n.builders.structure.hierarchy.applyPreset(m,"default",{structure:d,showUnitcell:l,representationPreset:u,representationPresetParams:e.source.params.options.representationParams})}else for(const p of s){const m=yield n.builders.data.download(p,{state:{isGhost:!0}}),h="auto"===c?n.dataFormats.auto(i1(fr.getUrl(p.url)),null===(f=m.cell)||void 0===f?void 0:f.obj):n.dataFormats.get(c);if(!h)throw new Error("unknown file format");const g=yield n.builders.structure.parseTrajectory(m,h);yield n.builders.structure.hierarchy.applyPreset(g,"default",{structure:d,showUnitcell:l,representationPreset:u,representationPresetParams:e.source.params.options.representationParams})}})).runInContext(i)});return function(i){return r.apply(this,arguments)}}()));function vd(e,t,n,r){return kU.apply(this,arguments)}function kU(){return kU=ie(function*(e,t,n,r){const i=e.split(/[,\s]/).map(s=>s.trim()).filter(s=>!!s&&(s.length>=4||/^[1-9][0-9]*$/.test(s))),o=[];for(const s of i)o.push({url:fr.Url(yield t(s)),isBinary:r,label:n(s)});return o}),kU.apply(this,arguments)}function NU(){return NU=ie(function*(e){if("pdb"!==e.name||"pdbe"!==e.params.provider.server.name)throw new Error("expected pdbe");return"updated"===e.params.provider.server.params.variant?vd(e.params.provider.id,t=>`https://www.ebi.ac.uk/pdbe/static/entry/${t.toLowerCase()}_updated.cif`,t=>`PDBe: ${t} (updated cif)`,!1):"updated-bcif"===e.params.provider.server.params.variant?vd(e.params.provider.id,t=>`https://www.ebi.ac.uk/pdbe/entry-files/download/${t.toLowerCase()}.bcif`,t=>`PDBe: ${t} (updated cif)`,!0):vd(e.params.provider.id,t=>`https://www.ebi.ac.uk/pdbe/static/entry/${t.toLowerCase()}.cif`,t=>`PDBe: ${t} (cif)`,!1)}),NU.apply(this,arguments)}function FU(){return FU=ie(function*(e){if("pdb"!==e.name||"pdbj"!==e.params.provider.server.name)throw new Error("expected pdbj");return vd(e.params.provider.id,t=>`https://data.pdbjbk1.pdbj.org/pub/pdb/data/structures/divided/mmCIF/${t.toLowerCase().substring(1,3)}/${t.toLowerCase()}.cif`,t=>`PDBj: ${t} (cif)`,!1)}),FU.apply(this,arguments)}function BU(){return BU=ie(function*(e){if("pdb"!==e.name||"rcsb"!==e.params.provider.server.name)throw new Error("expected rcsb");return"cif"===e.params.provider.server.params.encoding?vd(e.params.provider.id,t=>`https://files.rcsb.org/download/${t.toUpperCase()}.cif`,t=>`RCSB PDB: ${t} (cif)`,!1):vd(e.params.provider.id,t=>`https://models.rcsb.org/${t.toUpperCase()}.bcif`,t=>`RCSB PDB: ${t} (bcif)`,!0)}),BU.apply(this,arguments)}const put=nc.build({display:{name:"Update Trajectory"},params:{action:C.Select("advance",C.arrayToOptions(["advance","reset"])),by:C.Optional(C.Numeric(1,{min:-1,max:1,step:1}))}})(({params:e,state:t})=>{const n=t.selectQ(i=>i.ofTransformer(Ye.Model.ModelFromTrajectory)),r=t.build();if("reset"===e.action)for(const i of n)r.to(i).update({modelIndex:0});else for(const i of n){const o=In.findAncestorOfType(t.tree,t.cells,i.transform.ref,pe.Molecule.Trajectory);if(!o||!o.obj)continue;const s=o.obj;r.to(i).update(a=>{let c=(a.modelIndex+e.by)%s.data.frameCount;return c<0&&(c+=s.data.frameCount),{modelIndex:c}})}return t.updateTree(r)}),hut=nc.build({display:{name:"Custom Model Properties",description:"Enable parameters for custom properties of the model."},from:pe.Molecule.Model,params:(e,t)=>t.customModelProperties.getParams(e?.data),isApplicable:(e,t,n)=>t.transformer!==Koe})(({ref:e,params:t},n)=>n.builders.structure.insertModelProperties(e,t)),mut=nc.build({display:{name:"Custom Structure Properties",description:"Enable parameters for custom properties of the structure."},from:pe.Molecule.Structure,params:(e,t)=>t.customStructureProperties.getParams(e?.data),isApplicable:(e,t,n)=>t.transformer!==Qoe})(({ref:e,params:t},n)=>n.builders.structure.insertStructureProperties(e,t)),gut=nc.build({display:{name:"Add Trajectory",description:"Add trajectory from existing model/topology and coordinates."},from:pe.Root,params(e,t){const n=t.state.data,i=[...n.selectQ(a=>a.rootsOfType(pe.Molecule.Model)),...n.selectQ(a=>a.rootsOfType(pe.Molecule.Topology))].map(a=>[a.transform.ref,a.obj.label]),s=n.selectQ(a=>a.rootsOfType(pe.Molecule.Coordinates)).map(a=>[a.transform.ref,a.obj.label]);return{model:C.Select(i.length?i[0][0]:"",i),coordinates:C.Select(s.length?s[0][0]:"",s)}}})(({params:e,state:t},n)=>Oe.create("Add Trajectory",r=>t.transaction(ie(function*(){const i=[e.model,e.coordinates],o=t.build().toRoot().apply(I6,{modelRef:e.model,coordinatesRef:e.coordinates},{dependsOn:i}).apply(Ye.Model.ModelFromTrajectory,{modelIndex:0});yield t.updateTree(o).runInContext(r);const s=yield n.builders.structure.createStructure(o.selector);yield n.builders.structure.representation.applyPreset(s,"auto")})).runInContext(r))),yut=nc.build({display:{name:"Load Trajectory",description:"Load trajectory of model/topology and coordinates from URL or file."},from:pe.Root,params(e,t){const{options:n}=t.dataFormats,r=n.filter(a=>a[2]===bd||a[2]===lC),i=n.filter(a=>a[2]===o1),o=[],s=[];for(const{provider:a}of t.dataFormats.list)a.category===bd||a.category===lC?(a.binaryExtensions&&o.push(...a.binaryExtensions),a.stringExtensions&&o.push(...a.stringExtensions)):a.category===o1&&(a.binaryExtensions&&s.push(...a.binaryExtensions),a.stringExtensions&&s.push(...a.stringExtensions));return{source:C.MappedStatic("file",{url:C.Group({model:C.Group({url:C.Url(""),format:C.Select(r[0][0],r),isBinary:C.Boolean(!1)},{isExpanded:!0}),coordinates:C.Group({url:C.Url(""),format:C.Select(i[0][0],i)},{isExpanded:!0})},{isFlat:!0}),file:C.Group({model:C.File({accept:o.map(a=>`.${a}`).join(","),label:"Model"}),coordinates:C.File({accept:s.map(a=>`.${a}`).join(","),label:"Coordinates"})},{isFlat:!0})},{options:[["url","URL"],["file","File"]]})}}})(({params:e,state:t},n)=>Oe.create("Load Trajectory",r=>t.transaction(ie(function*(){const i=e.source;if("file"===i.name&&(null===i.params.model||null===i.params.coordinates))return void n.log.error("No file(s) selected");if(!("url"!==i.name||i.params.model&&i.params.coordinates))return void n.log.error("No URL(s) given");const o=function(){var a=ie(function*(c,u,l){const d=yield n.builders.data.download({url:c,isBinary:l}),f=n.dataFormats.get(u);if(f)return f.parse(n,d);n.log.warn(`LoadTrajectory: could not find data provider for '${u}'`)});return function(u,l,d){return a.apply(this,arguments)}}(),s=function(){var a=ie(function*(c){var u,l,d;if(!c)throw new Error("No file selected");const f=i1(null!==(l=null===(u=c.file)||void 0===u?void 0:u.name)&&void 0!==l?l:""),p=n.dataFormats.binaryExtensions.has(f.ext),{data:m}=yield n.builders.data.readFile({file:c,isBinary:p}),h=n.dataFormats.auto(f,null===(d=m.cell)||void 0===d?void 0:d.obj);return h?h.parse(n,m):(n.log.warn(`LoadTrajectory: could not find data provider for '${f.ext}'`),void(yield n.state.data.build().delete(m).commit()))});return function(u){return a.apply(this,arguments)}}();try{const a="url"===i.name?yield o(i.params.model.url,i.params.model.format,i.params.model.isBinary):yield s(i.params.model);let c;c="trajectory"in a?yield t.build().to(a.trajectory).apply(qoe,{modelIndex:0}).commit():a.topology;const u="url"===i.name?yield o(i.params.coordinates.url,i.params.coordinates.format,!0):yield s(i.params.coordinates),l=[c.ref,u.ref],d=t.build().toRoot().apply(I6,{modelRef:c.ref,coordinatesRef:u.ref},{dependsOn:l}).apply(Ye.Model.ModelFromTrajectory,{modelIndex:0});yield t.updateTree(d).runInContext(r);const f=yield n.builders.structure.createStructure(d.selector);yield n.builders.structure.representation.applyPreset(f,"auto")}catch(a){console.error(a),n.log.error("Error loading trajectory")}})).runInContext(r))),but=nc.build({from:pe.Root,display:{name:"Download Density",description:"Load a density from the provided source and create its default visual."},params:(e,t)=>{const{options:n}=t.dataFormats;return{source:C.MappedStatic("pdb-xray",{"pdb-xray":C.Group({provider:C.Group({id:C.Text("1tqn",{label:"Id"}),server:C.Select("rcsb",[["pdbe","PDBe"],["rcsb","RCSB PDB"]])},{pivot:"id"}),type:C.Select("2fofc",[["2fofc","2Fo-Fc"],["fofc","Fo-Fc"]])},{isFlat:!0}),"pdb-xray-ds":C.Group({provider:C.Group({id:C.Text("1tqn",{label:"Id"}),server:C.Select("pdbe",[["pdbe","PDBe"],["rcsb","RCSB PDB"]])},{pivot:"id"}),detail:C.Numeric(3,{min:0,max:6,step:1},{label:"Detail"})},{isFlat:!0}),"pdb-emd-ds":C.Group({provider:C.Group({id:C.Text("emd-8004",{label:"Id"}),server:C.Select("pdbe",[["pdbe","PDBe"],["rcsb","RCSB PDB"]])},{pivot:"id"}),detail:C.Numeric(3,{min:0,max:6,step:1},{label:"Detail"})},{isFlat:!0}),url:C.Group({url:C.Url(""),isBinary:C.Boolean(!1),format:C.Select("auto",n)},{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"]]})}}})(({params:e},t)=>Oe.create("Download Density",function(){var n=ie(function*(r){var i,o;const s=e.source;let a,c;switch(s.name){case"url":a=s.params;break;case"pdb-xray":a="pdbe"===s.params.provider.server?{url:fr.Url("2fofc"===s.params.type?`https://www.ebi.ac.uk/pdbe/coordinates/files/${s.params.provider.id.toLowerCase()}.ccp4`:`https://www.ebi.ac.uk/pdbe/coordinates/files/${s.params.provider.id.toLowerCase()}_diff.ccp4`),isBinary:!0,label:`PDBe X-ray map: ${s.params.provider.id}`}:{url:fr.Url("2fofc"===s.params.type?`https://edmaps.rcsb.org/maps/${s.params.provider.id.toLowerCase()}_2fofc.dsn6`:`https://edmaps.rcsb.org/maps/${s.params.provider.id.toLowerCase()}_fofc.dsn6`),isBinary:!0,label:`RCSB X-ray map: ${s.params.provider.id}`};break;case"pdb-emd-ds":a="pdbe"===s.params.provider.server?{url:fr.Url(`https://www.ebi.ac.uk/pdbe/densities/emd/${s.params.provider.id.toLowerCase()}/cell?detail=${s.params.detail}`),isBinary:!0,label:`PDBe EMD Density Server: ${s.params.provider.id}`}:{url:fr.Url(`https://maps.rcsb.org/em/${s.params.provider.id.toLowerCase()}/cell?detail=${s.params.detail}`),isBinary:!0,label:`RCSB PDB EMD Density Server: ${s.params.provider.id}`};break;case"pdb-xray-ds":a="pdbe"===s.params.provider.server?{url:fr.Url(`https://www.ebi.ac.uk/pdbe/densities/x-ray/${s.params.provider.id.toLowerCase()}/cell?detail=${s.params.detail}`),isBinary:!0,label:`PDBe X-ray Density Server: ${s.params.provider.id}`}:{url:fr.Url(`https://maps.rcsb.org/x-ray/${s.params.provider.id.toLowerCase()}/cell?detail=${s.params.detail}`),isBinary:!0,label:`RCSB PDB X-ray Density Server: ${s.params.provider.id}`};break;default:Rr()}const u=yield t.builders.data.download(a);let l;switch(s.name){case"url":a=s.params,c="auto"===s.params.format?t.dataFormats.auto(i1(fr.getUrl(a.url)),null===(i=u.cell)||void 0===i?void 0:i.obj):t.dataFormats.get(s.params.format);break;case"pdb-xray":l=s.params.provider.id,c=t.dataFormats.get("pdbe"===s.params.provider.server?"ccp4":"dsn6");break;case"pdb-emd-ds":case"pdb-xray-ds":l=s.params.provider.id,c=t.dataFormats.get("dscif");break;default:Rr()}if(!c)return void t.log.warn("DownloadDensity: Format provider not found.");const d=yield c.parse(t,u,{entryId:l});yield null===(o=c.visuals)||void 0===o?void 0:o.call(c,t,d)});return function(r){return n.apply(this,arguments)}}())),Ede=nc.build({display:{name:"Assign Volume Colors",description:"Assigns another volume to be available for coloring."},from:pe.Volume.Data,isApplicable:e=>!e.data.colorVolume,params(e,t){const n=t.state.data.select(In.Generators.root.subtree().ofType(pe.Volume.Data).filter(r=>{var i;return!(!r.obj||null!==(i=r.obj)&&void 0!==i&&i.data.colorVolume||r.obj===e)}));return 0===n.length?{ref:C.Text("",{isHidden:!0,label:"Volume"})}:{ref:C.Select(n[0].transform.ref,n.map(r=>[r.transform.ref,r.obj.label]),{label:"Volume"})}}})(({ref:e,params:t},r)=>r.build().to(e).apply(Ye.Volume.AssignColorVolume,{ref:t.ref},{dependsOn:[t.ref]}).commit());function r3(e,t,n,r){return OU.apply(this,arguments)}function OU(){return OU=ie(function*(e,t,n,r){var i,o,s,a;const c=i1(null!==(o=null===(i=e.file)||void 0===i?void 0:i.name)&&void 0!==o?o:""),u=t.dataFormats.binaryExtensions.has(c.ext),{data:l}=yield t.builders.data.readFile({file:e,isBinary:u}),d="auto"===n?t.dataFormats.auto(c,null===(s=l.cell)||void 0===s?void 0:s.obj):t.dataFormats.get(n);if(!d)return t.log.warn(`OpenFiles: could not find data provider for '${c.ext}'`),void(yield t.state.data.build().delete(l).commit());const f=yield d.parse(t,l);r&&(yield null===(a=d.visuals)||void 0===a?void 0:a.call(d,t,f))}),OU.apply(this,arguments)}const Pde=nc.build({display:{name:"Open Files",description:"Load one or more files and optionally create default visuals"},from:pe.Root,params:(e,t)=>{const{extensions:n,options:r}=t.dataFormats;return{files:C.FileList({accept:Array.from(n.values()).map(i=>`.${i}`).join(",")+",.gz,.zip",multiple:!0}),format:C.MappedStatic("auto",{auto:C.EmptyGroup(),specific:C.Select(r[0][0],r)}),visuals:C.Boolean(!0,{description:"Add default visuals"})}}})(({params:e,state:t},n)=>Oe.create("Open Files",function(){var r=ie(function*(i){n.behaviors.layout.leftPanelTabName.next("data"),yield t.transaction(ie(function*(){if(null!==e.files)for(const o of e.files)try{if(o.file&&o.name.toLowerCase().endsWith(".zip")){const s=yield T2(i,yield o.file.arrayBuffer());for(const[a,c]of Object.entries(s)){if(!(c instanceof Uint8Array)||0===c.length)continue;const u=fr.File(new File([c],a));yield r3(u,n,"auto",e.visuals)}}else{const s="auto"===e.format.name?"auto":e.format.params;yield r3(o,n,s,e.visuals)}}catch(s){console.error(s),n.log.error(`Error opening file '${o.name}'`)}else n.log.error("No file(s) selected")})).runInContext(i)});return function(i){return r.apply(this,arguments)}}())),vut=nc.build({display:{name:"Download File",description:"Load one or more file from an URL"},from:pe.Root,params:(e,t)=>{const n=[...t.dataFormats.options,["zip","Zip"],["gzip","Gzip"]];return{url:C.Url(""),format:C.Select(n[0][0],n),isBinary:C.Boolean(!1),visuals:C.Boolean(!0,{description:"Add default visuals"})}}})(({params:e,state:t},n)=>Oe.create("Open Files",function(){var r=ie(function*(i){n.behaviors.layout.leftPanelTabName.next("data"),yield t.transaction(ie(function*(){var o,s,a;try{if("zip"===e.format||"gzip"===e.format){const c=yield n.builders.data.download({url:e.url,isBinary:!0});if("zip"===e.format){const u=yield T2(i,(null===(o=c.obj)||void 0===o?void 0:o.data).buffer);for(const[l,d]of Object.entries(u)){if(!(d instanceof Uint8Array)||0===d.length)continue;const f=fr.File(new File([d],l));yield r3(f,n,"auto",e.visuals)}}else{const l=i1(fr.getUrl(e.url)).name;yield r3(fr.File(new File([null===(s=c.obj)||void 0===s?void 0:s.data],l)),n,"auto",e.visuals)}}else{const c=n.dataFormats.get(e.format);if(!c)return void n.log.warn(`DownloadFile: could not find data provider for '${e.format}'`);const u=yield n.builders.data.download({url:e.url,isBinary:e.isBinary}),l=yield c.parse(n,u);e.visuals&&(yield null===(a=c.visuals)||void 0===a?void 0:a.call(c,n,l))}}catch(c){console.error(c),n.log.error(`Error downloading '${"string"==typeof e.url?e.url:e.url.url}'`)}})).runInContext(i)});return function(i){return r.apply(this,arguments)}}())),V0={Structure:rM,Volume:iM,DataFormat:oM};class LU extends(pe.Create({name:"Volume Streaming",typeClass:"Object"})){}var Mde,dC;function Rde(e,t,n,r){return UU.apply(this,arguments)}function UU(){return UU=ie(function*(e,t,n,r){switch(e){case"emdb":return kde(t,n,r);case"pdbe":return function wut(e,t,n){return zU.apply(this,arguments)}(t,n,r)}}),UU.apply(this,arguments)}function kde(e,t,n){return VU.apply(this,arguments)}function VU(){return VU=ie(function*(e,t,n){const r=e.config.get(qi.VolumeStreaming.EmdbHeaderServer),s=(yield e.fetch({url:`${r}/${n.toUpperCase()}/header/${n.toLowerCase()}.xml`,type:"xml"}).runInContext(t)).getElementsByTagName("map")[0].getElementsByTagName("contour");let a=s[0];for(let u=1;uu.primary))||void 0===o?void 0:o.level)&&void 0!==s?s:c[0].level:function Aut(e,t,n){return GU.apply(this,arguments)}(e,t,n)}),zU.apply(this,arguments)}function GU(){return GU=ie(function*(e,t,n){var r,i,o;n=n.toUpperCase();const s=yield e.fetch({url:`https://www.ebi.ac.uk/pdbe/api/emdb/entry/map/${n}`,type:"json"}).runInContext(t),a=s?.[n];let c;return void 0!==(null===(o=null===(i=null===(r=a?.[0])||void 0===r?void 0:r.map)||void 0===i?void 0:i.contour_level)||void 0===o?void 0:o.value)&&(c=+a[0].map.contour_level.value),c}),GU.apply(this,arguments)}function Iut(e,t,n){return jU.apply(this,arguments)}function jU(){return jU=ie(function*(e,t,n){var r;const i=yield e.fetch({url:`https://www.ebi.ac.uk/pdbe/api/pdb/entry/summary/${n}`,type:"json"}).runInContext(t),o=i?.[n],s=[];if(null===(r=o?.[0])||void 0===r||!r.related_structures)throw new Error(`No related EMDB entry found for '${n}'.`);{const a=o[0].related_structures.filter(c=>"EMDB"===c.resource&&"associated EM volume"===c.relationship);if(!a.length)throw new Error(`No related EMDB entry found for '${n}'.`);s.push(...a.map(c=>c.accession))}return s}),jU.apply(this,arguments)}!function(e){let t;var n;(n=t=e.ValueType||(e.ValueType={})).Float32="float32",n.Int8="int8"}(Mde||(Mde={})),function(e){e.create=function n(s){return{entries:AB(),capacity:Math.max(1,s)}},e.get=function r(s,a){for(let c=s.entries.first;c;c=c.next)if(c.value.key===a)return s.entries.remove(c),s.entries.addLast(c.value),c.value.data},e.set=function i(s,a,c){let u;if(s.entries.count>=s.capacity){const l=s.entries.first;u=l.value.data,s.entries.remove(l)}return s.entries.addLast(function t(s,a){return{key:s,data:a}}(a,c)),u},e.remove=function o(s,a){for(let c=s.entries.first;c;c=c.next)if(c.value.key===a){s.entries.remove(c);break}}}(dC||(dC={}));class Tut extends Fa{constructor(t,n){super()}schedule(t,n=0){return this}}const i3={setInterval(e,t,...n){const{delegate:r}=i3;return r?.setInterval?r.setInterval(e,t,...n):setInterval(e,t,...n)},clearInterval(e){const{delegate:t}=i3;return(t?.clearInterval||clearInterval)(e)},delegate:void 0};class fC{constructor(t,n=fC.now){this.schedulerActionCtor=t,this.now=n}schedule(t,n=0,r){return new this.schedulerActionCtor(this,t).schedule(r,n)}}fC.now=HF.now;const o3=new class Eut extends fC{constructor(t,n=fC.now){super(t,n),this.actions=[],this._active=!1}flush(t){const{actions:n}=this;if(this._active)return void n.push(t);let r;this._active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=n.shift());if(this._active=!1,r){for(;t=n.shift();)t.unsubscribe();throw r}}}(class Dut extends Tut{constructor(t,n){super(t,n),this.scheduler=t,this.work=n,this.pending=!1}schedule(t,n=0){var r;if(this.closed)return this;this.state=t;const i=this.id,o=this.scheduler;return null!=i&&(this.id=this.recycleAsyncId(o,i,n)),this.pending=!0,this.delay=n,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(o,this.id,n),this}requestAsyncId(t,n,r=0){return i3.setInterval(t.flush.bind(t,this),r)}recycleAsyncId(t,n,r=0){if(null!=r&&this.delay===r&&!1===this.pending)return n;null!=n&&i3.clearInterval(n)}execute(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;const r=this._execute(t,n);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))}_execute(t,n){let i,r=!1;try{this.work(t)}catch(o){r=!0,i=o||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),i}unsubscribe(){if(!this.closed){const{id:t,scheduler:n}=this,{actions:r}=n;this.work=this.state=this.scheduler=null,this.pending=!1,QC(r,this),null!=t&&(this.id=this.recycleAsyncId(n,t,null)),this.delay=null,super.unsubscribe()}}}),Put=o3;function Nde(e=0,t,n=Put){let r=-1;return null!=t&&(mK(t)?n=t:r=t),new ns(i=>{let o=function Rut(e){return e instanceof Date&&!isNaN(e)}(e)?+e-n.now():e;o<0&&(o=0);let s=0;return n.schedule(function(){i.closed||(i.next(s++),0<=r?this.schedule(void 0,r):i.complete())},o)})}function Fde(e,t=o3,n){const r=Nde(e,t);return function Mut(e,t){return mo((n,r)=>{const{leading:i=!0,trailing:o=!1}=t??{};let s=!1,a=null,c=null,u=!1;const l=()=>{c?.unsubscribe(),c=null,o&&(p(),u&&r.complete())},d=()=>{c=null,u&&r.complete()},f=m=>c=ru(e(m)).subscribe(Io(r,l,d)),p=()=>{if(s){s=!1;const m=a;a=null,r.next(m),!u&&f(m)}};n.subscribe(Io(r,m=>{s=!0,a=m,(!c||c.closed)&&(i?p():f(m))},()=>{u=!0,(!(o&&s&&c)||c.closed)&&r.complete()}))})}(()=>r,n)}function Bde(e,t=vh){return e=e??kut,mo((n,r)=>{let i,o=!0;n.subscribe(Io(r,s=>{const a=t(s);(o||!e(i,a))&&(o=!1,i=a,r.next(s))}))})}function kut(e,t){return e===t}class Nut{constructor(t=!1){this.isRunning=!1,this.queue=[],this.counter=0,this.log=t}enqueue(t){this.log&&console.log("SingleAsyncQueue enqueue",this.counter),this.queue[0]={id:this.counter,func:t},this.counter++,this.run()}run(){var t=this;return ie(function*(){if(t.isRunning)return;const n=t.queue.pop();if(n){t.isRunning=!0;try{t.log&&console.log("SingleAsyncQueue run",n.id),yield n.func(),t.log&&console.log("SingleAsyncQueue complete",n.id)}finally{t.isRunning=!1,t.run()}}})()}}class Tu extends(pe.CreateBehavior({name:"Volume Streaming"})){}function Nm(e,t,n){return{i:e,j:t,k:n}}function xl(e,t){return{a:e,b:t}}!function(e){function t(c,u,l,d,f={}){var p,m,h,g;return C.Group({isoValue:et.createIsoValueParam(null!==(p=f.isoValue)&&void 0!==p?p:l,d),color:C.Color(null!==(m=f.color)&&void 0!==m?m:u),wireframe:C.Boolean(null!==(h=f.wireframe)&&void 0!==h&&h),opacity:C.Numeric(null!==(g=f.opacity)&&void 0!==g?g:.3,{min:0,max:1,step:.01})},{label:c,isExpanded:!0})}e.RootTag="volume-streaming-info";const n={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 i(c){const{entryData:u,defaultView:l,structure:d,channelParams:f={}}=c,p=u||{kind:"em",header:{sampling:[n],availablePrecisions:[{precision:0,maxVoxels:0}]},emDefaultContourLevel:et.IsoValue.relative(0)},m=d&&d.boundary.box||St();return{view:C.MappedStatic(l||("em"===p.kind?"auto":"selection-box"),{off:C.Group({}),box:C.Group({bottomLeft:C.Vec3(m.min),topRight:C.Vec3(m.max)},{description:"Static box defined by cartesian coords.",isFlat:!0}),"selection-box":C.Group({radius:C.Numeric(5,{min:0,max:50,step:.5},{description:"Radius in \u212b within which the volume is shown."}),bottomLeft:C.Vec3(v.create(0,0,0),{},{isHidden:!0}),topRight:C.Vec3(v.create(0,0,0),{},{isHidden:!0})},{description:"Box around focused element.",isFlat:!0}),"camera-target":C.Group({radius:C.Numeric(.5,{min:0,max:1,step:.05},{description:"Radius within which the volume is shown (relative to the field of view)."}),dynamicDetailLevel:o(p.header.availablePrecisions,0,{label:"Dynamic Detail"}),bottomLeft:C.Vec3(v.create(0,0,0),{},{isHidden:!0}),topRight:C.Vec3(v.create(0,0,0),{},{isHidden:!0})},{description:"Box around camera target.",isFlat:!0}),cell:C.Group({}),auto:C.Group({radius:C.Numeric(5,{min:0,max:50,step:.5},{description:"Radius in \u212b within which the volume is shown."}),selectionDetailLevel:o(p.header.availablePrecisions,6,{label:"Selection Detail"}),isSelection:C.Boolean(!1,{isHidden:!0}),bottomLeft:C.Vec3(m.min,{},{isHidden:!0}),topRight:C.Vec3(m.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:o(p.header.availablePrecisions,3),channels:C.Group("em"===p.kind?{em:t("EM",st(6524815),p.emDefaultContourLevel||et.IsoValue.relative(1),p.header.sampling[0].valuesInfo[0],f.em)}:{"2fo-fc":t("2Fo-Fc",st(3367602),et.IsoValue.relative(1.5),p.header.sampling[0].valuesInfo[0],f["2fo-fc"]),"fo-fc(+ve)":t("Fo-Fc(+ve)",st(3390259),et.IsoValue.relative(3),p.header.sampling[0].valuesInfo[1],f["fo-fc(+ve)"]),"fo-fc(-ve)":t("Fo-Fc(-ve)",st(12268339),et.IsoValue.relative(-3),p.header.sampling[0].valuesInfo[1],f["fo-fc(-ve)"])},{isFlat:!0})}}function o(c,u,l){return C.Select(Math.min(u,c.length-1),c.map((d,f)=>[f,`${f+1} [ ${0|Math.pow(d.maxVoxels,1/3)}^3 cells ]`]),{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 s(c){return{entry:{name:c.entry.name,params:{detailLevel:c.entry.params.detailLevel,channels:c.entry.params.channels,view:{name:c.entry.params.view.name,params:{...c.entry.params.view.params}}}}}}e.createParams=function r(c={}){const{data:u,defaultView:l,channelParams:d}=c,f=new Map;u&&u.entries.forEach(h=>f.set(h.dataId,h));const p=u?u.entries.map(h=>[h.dataId,h.dataId]):[];return{entry:C.Mapped(u?u.entries[0].dataId:"",p,h=>C.Group(i({entryData:f.get(h),defaultView:l,structure:u&&u.structure,channelParams:d})))}},e.createEntryParams=i,e.copyParams=s,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)"]],e.Behavior=class a extends tr.WithSubscribers{get info(){return this.infoMap.get(this.params.entry.name)}queryData(u){var l=this;return ie(function*(){let d=S8(l.data.serverUrl,`${l.info.kind}/${l.info.dataId.toLowerCase()}`);if(u){const{min:b,max:x}=u;d+=`/box/${b.map(_=>Math.round(1e3*_)/1e3).join(",")}/${x.map(_=>Math.round(1e3*_)/1e3).join(",")}`}else d+="/cell";let f=l.params.entry.params.detailLevel;"auto"===l.params.entry.params.view.name&&l.params.entry.params.view.params.isSelection&&(f=l.params.entry.params.view.params.selectionDetailLevel),"camera-target"===l.params.entry.params.view.name&&u&&(f=l.decideDetail(u,l.params.entry.params.view.params.dynamicDetailLevel)),d+=`?detail=${f}`;const p=dC.get(l.cache,d);if(p)return p.data;const m=fr.getUrlAsset(l.plugin.managers.asset,d),h=yield l.plugin.runTask(l.plugin.managers.asset.resolve(m,"binary")),g=yield l.parseCif(h.data);if(!g)return;const y=dC.set(l.cache,d,{data:g,asset:h});return y&&y.asset.dispose(),g})()}parseCif(u){var l=this;return ie(function*(){const d=yield l.plugin.runTask(od.parseBinary(u));if(d.isError)return void l.plugin.log.error("VolumeStreaming, parsing CIF: "+d.toString());if(d.result.blocks.length<2)return void l.plugin.log.error("VolumeStreaming: Invalid data.");const f={};for(let p=1;p{!pe.Molecule.Structure.is(l.obj)||!De.is(this.lastLoci)||this.lastLoci.structure===l.obj.data&&(this.lastLoci=$n)}),this.subscribeObservable(this.plugin.state.events.object.updated,l=>{!pe.Molecule.Structure.is(l.oldObj)||!De.is(this.lastLoci)||this.lastLoci.structure===l.oldObj.data&&(this.lastLoci=$n)}),this.subscribeObservable(this.plugin.managers.structure.focus.behaviors.current,l=>{if(!this.plugin.state.data.tree.children.has(this.ref))return;const d=l?l.loci:$n;switch(this.params.entry.params.view.name){case"auto":this.updateAuto(d);break;case"selection-box":this.updateSelectionBox(d);break;default:this.lastLoci=d}})}unregister(){let u=this.cache.entries.first;for(;u;)u.value.data.asset.dispose(),u=u.next}isCameraTargetSame(u,l){if(!u||!l)return!1;const d=v.equals(u.target,l.target),f=v.squaredDistance(u.target,u.position),p=v.squaredDistance(l.target,l.position),m=Math.abs(f-p)/f<.001;return d&&m}cameraTargetDistance(u){return v.distance(u.target,u.position)}getBoxFromLoci(u){var l,d,f;if(pn.isEmpty(u)||Ta(u))return St();const p=this.plugin.helpers.substructureParent.get(u.structure,!0);if(!p)return St();const m=this.getStructureRoot();if(!m||(null===(l=m.obj)||void 0===l?void 0:l.data)!==(null===(d=p.obj)||void 0===d?void 0:d.data))return St();const h=Hg.get(null===(f=m.obj)||void 0===f?void 0:f.data.models[0]);h&&le.invert(this._invTransform,h);const g=De.extendToWholeResidues(u),y=De.getBoundary(g,h&&!Number.isNaN(this._invTransform[0])?this._invTransform:void 0).box;return 1===De.size(g)&&St.expand(y,y,v.create(1,1,1)),y}updateAuto(u){var l=this;this.updateQueue.enqueue(ie(function*(){l.lastLoci=u,Ta(u)?yield l.updateParams("x-ray"===l.info.kind?l.data.structure.boundary.box:void 0,!1):yield l.updateParams(l.getBoxFromLoci(u),!0)}))}updateSelectionBox(u){var l=this;this.updateQueue.enqueue(ie(function*(){l.lastLoci=pn.areEqual(l.lastLoci,u)?$n:u;const d=l.getBoxFromLoci(l.lastLoci);yield l.updateParams(d)}))}updateCameraTarget(u){var l=this;this.updateQueue.enqueue(ie(function*(){var d,f,p;const m=null===(d=l.plugin.canvas3d)||void 0===d?void 0:d.props.camera.manualReset;try{m||null===(f=l.plugin.canvas3d)||void 0===f||f.setProps({camera:{manualReset:!0}});const h=l.boxFromCameraTarget(u,!0);yield l.updateParams(h)}finally{m||null===(p=l.plugin.canvas3d)||void 0===p||p.setProps({camera:{manualReset:m}})}}))}boxFromCameraTarget(u,l){var d;const f=u.target,p=this.cameraTargetDistance(u);let h=Math.tan(.5*u.fov)*p;const g=null===(d=this.plugin.canvas3d)||void 0===d?void 0:d.camera.viewport;let b,x,_;if(g&&g.width>g.height&&(h*=g.width/g.height),h*="camera-target"===this.params.entry.params.view.name?this.params.entry.params.view.params.radius:.5,l){const S=v.zero();St.size(S,this.data.structure.boundary.box),b=Math.min(h,.5*S[0]),x=Math.min(h,.5*S[1]),_=Math.min(h,.5*S[2])}else b=x=_=h;return St.create(v.create(f[0]-b,f[1]-x,f[2]-_),v.create(f[0]+b,f[1]+x,f[2]+_))}decideDetail(u,l){const d="x-ray"===this.info.kind?St.volume(this.data.structure.boundary.box):this.info.header.spacegroup.size.reduce((g,y)=>g*y,1);let p=St.volume(u)/d;const m=this.info.header.availablePrecisions.length-1;let h=l;for(;p<=.5&&hl.updateCameraTarget(g))),f=l.boxFromCameraTarget(l.plugin.canvas3d.camera.getSnapshot(),!0);break;case"cell":f="x-ray"===l.info.kind?l.data.structure.boundary.box:void 0;break;case"auto":if(f=u.entry.params.view.params.isSelection||"x-ray"===l.info.kind?St.create(v.clone(u.entry.params.view.params.bottomLeft),v.clone(u.entry.params.view.params.topRight)):void 0,f&&(p=St.volume(f)<1e-4,u.entry.params.view.params.isSelection)){const g=u.entry.params.view.params.radius;St.expand(f,f,v.create(g,g,g))}}const m=p?{}:yield l.queryData(f);if(!m)return!1;const h=u.entry.params.channels;return"x-ray"===l.info.kind?(l.channels["2fo-fc"]=l.createChannel(m["2FO-FC"]||et.One,h["2fo-fc"],l.info.header.sampling[0].valuesInfo[0]),l.channels["fo-fc(+ve)"]=l.createChannel(m["FO-FC"]||et.One,h["fo-fc(+ve)"],l.info.header.sampling[0].valuesInfo[1]),l.channels["fo-fc(-ve)"]=l.createChannel(m["FO-FC"]||et.One,h["fo-fc(-ve)"],l.info.header.sampling[0].valuesInfo[1])):l.channels.em=l.createChannel(m.EM||et.One,h.em,l.info.header.sampling[0].valuesInfo[0]),!0})()}createChannel(u,l,d){return{data:u,color:l.color,wireframe:l.wireframe,opacity:l.opacity,isoValue:"relative"===l.isoValue.kind?l.isoValue:et.IsoValue.toRelative(l.isoValue,d)}}getDescription(){return"selection-box"===this.params.entry.params.view.name?"Selection":"camera-target"===this.params.entry.params.view.name?"Camera":"box"===this.params.entry.params.view.name?"Static Box":"cell"===this.params.entry.params.view.name?"Cell":""}constructor(u,l){super(u,{}),this.plugin=u,this.data=l,this.cache=dC.create(25),this.params={},this.lastLoci=$n,this.ref="",this.cameraTargetObservable=this.plugin.canvas3d.didDraw.pipe(Fde(500,void 0,{leading:!0,trailing:!0}),qt(()=>{var d;return null===(d=this.plugin.canvas3d)||void 0===d?void 0:d.camera.getSnapshot()}),Bde((d,f)=>this.isCameraTargetSame(d,f)),Yl(d=>void 0!==d)),this.cameraTargetSubscription=void 0,this.channels={},this._invTransform=le(),this.infoMap=new Map,this.data.entries.forEach(d=>this.infoMap.set(d.dataId,d)),this.updateQueue=new Nut}}}(Tu||(Tu={}));const lo=[Nm(0,0,0),Nm(1,0,0),Nm(1,1,0),Nm(0,1,0),Nm(0,0,1),Nm(1,0,1),Nm(1,1,1),Nm(0,1,1)],Fut=[xl(lo[0],lo[1]),xl(lo[1],lo[2]),xl(lo[2],lo[3]),xl(lo[3],lo[0]),xl(lo[4],lo[5]),xl(lo[5],lo[6]),xl(lo[6],lo[7]),xl(lo[7],lo[4]),xl(lo[0],lo[4]),xl(lo[1],lo[5]),xl(lo[2],lo[6]),xl(lo[3],lo[7])],But=[{i:0,j:0,k:0,e:0},{i:1,j:0,k:0,e:1},{i:0,j:1,k:0,e:0},{i:0,j:0,k:0,e:1},{i:0,j:0,k:1,e:0},{i:1,j:0,k:1,e:1},{i:0,j:1,k:1,e:0},{i:0,j:0,k:1,e:1},{i:0,j:0,k:0,e:2},{i:1,j:0,k:0,e:2},{i:1,j:1,k:0,e:2},{i:0,j:1,k:0,e:2}],Out=[0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0],s1=[[],[0,8,3],[0,1,9],[1,8,3,9,8,1],[1,2,10],[0,8,3,1,2,10],[9,2,10,0,2,9],[2,8,3,2,10,8,10,9,8],[3,11,2],[0,11,2,8,11,0],[1,9,0,2,3,11],[1,11,2,1,9,11,9,8,11],[3,10,1,11,10,3],[0,10,1,0,8,10,8,11,10],[3,9,0,3,11,9,11,10,9],[9,8,10,10,8,11],[4,7,8],[4,3,0,7,3,4],[0,1,9,8,4,7],[4,1,9,4,7,1,7,3,1],[1,2,10,8,4,7],[3,4,7,3,0,4,1,2,10],[9,2,10,9,0,2,8,4,7],[2,10,9,2,9,7,2,7,3,7,9,4],[8,4,7,3,11,2],[11,4,7,11,2,4,2,0,4],[9,0,1,8,4,7,2,3,11],[4,7,11,9,4,11,9,11,2,9,2,1],[3,10,1,3,11,10,7,8,4],[1,11,10,1,4,11,1,0,4,7,11,4],[4,7,8,9,0,11,9,11,10,11,0,3],[4,7,11,4,11,9,9,11,10],[9,5,4],[9,5,4,0,8,3],[0,5,4,1,5,0],[8,5,4,8,3,5,3,1,5],[1,2,10,9,5,4],[3,0,8,1,2,10,4,9,5],[5,2,10,5,4,2,4,0,2],[2,10,5,3,2,5,3,5,4,3,4,8],[9,5,4,2,3,11],[0,11,2,0,8,11,4,9,5],[0,5,4,0,1,5,2,3,11],[2,1,5,2,5,8,2,8,11,4,8,5],[10,3,11,10,1,3,9,5,4],[4,9,5,0,8,1,8,10,1,8,11,10],[5,4,0,5,0,11,5,11,10,11,0,3],[5,4,8,5,8,10,10,8,11],[9,7,8,5,7,9],[9,3,0,9,5,3,5,7,3],[0,7,8,0,1,7,1,5,7],[1,5,3,3,5,7],[9,7,8,9,5,7,10,1,2],[10,1,2,9,5,0,5,3,0,5,7,3],[8,0,2,8,2,5,8,5,7,10,5,2],[2,10,5,2,5,3,3,5,7],[7,9,5,7,8,9,3,11,2],[9,5,7,9,7,2,9,2,0,2,7,11],[2,3,11,0,1,8,1,7,8,1,5,7],[11,2,1,11,1,7,7,1,5],[9,5,8,8,5,7,10,1,3,10,3,11],[5,7,0,5,0,9,7,11,0,1,0,10,11,10,0],[11,10,0,11,0,3,10,5,0,8,0,7,5,7,0],[11,10,5,7,11,5],[10,6,5],[0,8,3,5,10,6],[9,0,1,5,10,6],[1,8,3,1,9,8,5,10,6],[1,6,5,2,6,1],[1,6,5,1,2,6,3,0,8],[9,6,5,9,0,6,0,2,6],[5,9,8,5,8,2,5,2,6,3,2,8],[2,3,11,10,6,5],[11,0,8,11,2,0,10,6,5],[0,1,9,2,3,11,5,10,6],[5,10,6,1,9,2,9,11,2,9,8,11],[6,3,11,6,5,3,5,1,3],[0,8,11,0,11,5,0,5,1,5,11,6],[3,11,6,0,3,6,0,6,5,0,5,9],[6,5,9,6,9,11,11,9,8],[5,10,6,4,7,8],[4,3,0,4,7,3,6,5,10],[1,9,0,5,10,6,8,4,7],[10,6,5,1,9,7,1,7,3,7,9,4],[6,1,2,6,5,1,4,7,8],[1,2,5,5,2,6,3,0,4,3,4,7],[8,4,7,9,0,5,0,6,5,0,2,6],[7,3,9,7,9,4,3,2,9,5,9,6,2,6,9],[3,11,2,7,8,4,10,6,5],[5,10,6,4,7,2,4,2,0,2,7,11],[0,1,9,4,7,8,2,3,11,5,10,6],[9,2,1,9,11,2,9,4,11,7,11,4,5,10,6],[8,4,7,3,11,5,3,5,1,5,11,6],[5,1,11,5,11,6,1,0,11,7,11,4,0,4,11],[0,5,9,0,6,5,0,3,6,11,6,3,8,4,7],[6,5,9,6,9,11,4,7,9,7,11,9],[10,4,9,6,4,10],[4,10,6,4,9,10,0,8,3],[10,0,1,10,6,0,6,4,0],[8,3,1,8,1,6,8,6,4,6,1,10],[1,4,9,1,2,4,2,6,4],[3,0,8,1,2,9,2,4,9,2,6,4],[0,2,4,4,2,6],[8,3,2,8,2,4,4,2,6],[10,4,9,10,6,4,11,2,3],[0,8,2,2,8,11,4,9,10,4,10,6],[3,11,2,0,1,6,0,6,4,6,1,10],[6,4,1,6,1,10,4,8,1,2,1,11,8,11,1],[9,6,4,9,3,6,9,1,3,11,6,3],[8,11,1,8,1,0,11,6,1,9,1,4,6,4,1],[3,11,6,3,6,0,0,6,4],[6,4,8,11,6,8],[7,10,6,7,8,10,8,9,10],[0,7,3,0,10,7,0,9,10,6,7,10],[10,6,7,1,10,7,1,7,8,1,8,0],[10,6,7,10,7,1,1,7,3],[1,2,6,1,6,8,1,8,9,8,6,7],[2,6,9,2,9,1,6,7,9,0,9,3,7,3,9],[7,8,0,7,0,6,6,0,2],[7,3,2,6,7,2],[2,3,11,10,6,8,10,8,9,8,6,7],[2,0,7,2,7,11,0,9,7,6,7,10,9,10,7],[1,8,0,1,7,8,1,10,7,6,7,10,2,3,11],[11,2,1,11,1,7,10,6,1,6,7,1],[8,9,6,8,6,7,9,1,6,11,6,3,1,3,6],[0,9,1,11,6,7],[7,8,0,7,0,6,3,11,0,11,6,0],[7,11,6],[7,6,11],[3,0,8,11,7,6],[0,1,9,11,7,6],[8,1,9,8,3,1,11,7,6],[10,1,2,6,11,7],[1,2,10,3,0,8,6,11,7],[2,9,0,2,10,9,6,11,7],[6,11,7,2,10,3,10,8,3,10,9,8],[7,2,3,6,2,7],[7,0,8,7,6,0,6,2,0],[2,7,6,2,3,7,0,1,9],[1,6,2,1,8,6,1,9,8,8,7,6],[10,7,6,10,1,7,1,3,7],[10,7,6,1,7,10,1,8,7,1,0,8],[0,3,7,0,7,10,0,10,9,6,10,7],[7,6,10,7,10,8,8,10,9],[6,8,4,11,8,6],[3,6,11,3,0,6,0,4,6],[8,6,11,8,4,6,9,0,1],[9,4,6,9,6,3,9,3,1,11,3,6],[6,8,4,6,11,8,2,10,1],[1,2,10,3,0,11,0,6,11,0,4,6],[4,11,8,4,6,11,0,2,9,2,10,9],[10,9,3,10,3,2,9,4,3,11,3,6,4,6,3],[8,2,3,8,4,2,4,6,2],[0,4,2,4,6,2],[1,9,0,2,3,4,2,4,6,4,3,8],[1,9,4,1,4,2,2,4,6],[8,1,3,8,6,1,8,4,6,6,10,1],[10,1,0,10,0,6,6,0,4],[4,6,3,4,3,8,6,10,3,0,3,9,10,9,3],[10,9,4,6,10,4],[4,9,5,7,6,11],[0,8,3,4,9,5,11,7,6],[5,0,1,5,4,0,7,6,11],[11,7,6,8,3,4,3,5,4,3,1,5],[9,5,4,10,1,2,7,6,11],[6,11,7,1,2,10,0,8,3,4,9,5],[7,6,11,5,4,10,4,2,10,4,0,2],[3,4,8,3,5,4,3,2,5,10,5,2,11,7,6],[7,2,3,7,6,2,5,4,9],[9,5,4,0,8,6,0,6,2,6,8,7],[3,6,2,3,7,6,1,5,0,5,4,0],[6,2,8,6,8,7,2,1,8,4,8,5,1,5,8],[9,5,4,10,1,6,1,7,6,1,3,7],[1,6,10,1,7,6,1,0,7,8,7,0,9,5,4],[4,0,10,4,10,5,0,3,10,6,10,7,3,7,10],[7,6,10,7,10,8,5,4,10,4,8,10],[6,9,5,6,11,9,11,8,9],[3,6,11,0,6,3,0,5,6,0,9,5],[0,11,8,0,5,11,0,1,5,5,6,11],[6,11,3,6,3,5,5,3,1],[1,2,10,9,5,11,9,11,8,11,5,6],[0,11,3,0,6,11,0,9,6,5,6,9,1,2,10],[11,8,5,11,5,6,8,0,5,10,5,2,0,2,5],[6,11,3,6,3,5,2,10,3,10,5,3],[5,8,9,5,2,8,5,6,2,3,8,2],[9,5,6,9,6,0,0,6,2],[1,5,8,1,8,0,5,6,8,3,8,2,6,2,8],[1,5,6,2,1,6],[1,3,6,1,6,10,3,8,6,5,6,9,8,9,6],[10,1,0,10,0,6,9,5,0,5,6,0],[0,3,8,5,6,10],[10,5,6],[11,5,10,7,5,11],[11,5,10,11,7,5,8,3,0],[5,11,7,5,10,11,1,9,0],[10,7,5,10,11,7,9,8,1,8,3,1],[11,1,2,11,7,1,7,5,1],[0,8,3,1,2,7,1,7,5,7,2,11],[9,7,5,9,2,7,9,0,2,2,11,7],[7,5,2,7,2,11,5,9,2,3,2,8,9,8,2],[2,5,10,2,3,5,3,7,5],[8,2,0,8,5,2,8,7,5,10,2,5],[9,0,1,5,10,3,5,3,7,3,10,2],[9,8,2,9,2,1,8,7,2,10,2,5,7,5,2],[1,3,5,3,7,5],[0,8,7,0,7,1,1,7,5],[9,0,3,9,3,5,5,3,7],[9,8,7,5,9,7],[5,8,4,5,10,8,10,11,8],[5,0,4,5,11,0,5,10,11,11,3,0],[0,1,9,8,4,10,8,10,11,10,4,5],[10,11,4,10,4,5,11,3,4,9,4,1,3,1,4],[2,5,1,2,8,5,2,11,8,4,5,8],[0,4,11,0,11,3,4,5,11,2,11,1,5,1,11],[0,2,5,0,5,9,2,11,5,4,5,8,11,8,5],[9,4,5,2,11,3],[2,5,10,3,5,2,3,4,5,3,8,4],[5,10,2,5,2,4,4,2,0],[3,10,2,3,5,10,3,8,5,4,5,8,0,1,9],[5,10,2,5,2,4,1,9,2,9,4,2],[8,4,5,8,5,3,3,5,1],[0,4,5,1,0,5],[8,4,5,8,5,3,9,0,5,0,3,5],[9,4,5],[4,11,7,4,9,11,9,10,11],[0,8,3,4,9,7,9,11,7,9,10,11],[1,10,11,1,11,4,1,4,0,7,4,11],[3,1,4,3,4,8,1,10,4,7,4,11,10,11,4],[4,11,7,9,11,4,9,2,11,9,1,2],[9,7,4,9,11,7,9,1,11,2,11,1,0,8,3],[11,7,4,11,4,2,2,4,0],[11,7,4,11,4,2,8,3,4,3,2,4],[2,9,10,2,7,9,2,3,7,7,4,9],[9,10,7,9,7,4,10,2,7,8,7,0,2,0,7],[3,7,10,3,10,2,7,4,10,1,10,0,4,0,10],[1,10,2,8,7,4],[4,9,1,4,1,7,7,1,3],[4,9,1,4,1,7,0,8,1,8,7,1],[4,0,3,7,4,3],[4,8,7],[9,10,8,10,11,8],[3,0,9,3,9,11,11,9,10],[0,1,10,0,10,8,8,10,11],[3,1,10,11,3,10],[1,2,11,1,11,9,9,11,8],[3,0,9,3,9,11,1,2,9,2,11,9],[0,2,11,8,0,11],[3,2,11],[2,3,8,2,8,10,10,8,9],[9,10,2,0,9,2],[2,3,8,2,8,10,0,1,8,1,10,8],[1,10,2],[1,3,8,9,1,8],[0,9,1],[0,3,8],[]],HU=[[0,4,4,4,2,0,0,0,2,2,0,0],[4,0,4,4,0,8,0,0,0,8,8,0],[4,4,0,4,0,0,8,0,0,0,8,8],[4,4,4,0,0,0,0,1,1,0,0,1],[2,0,0,0,0,8,8,8,2,2,0,0],[0,8,0,0,8,0,8,8,0,8,8,0],[0,0,8,0,8,8,0,8,0,0,8,8],[0,0,0,1,8,8,8,0,1,0,0,1],[2,0,0,1,2,0,0,1,0,2,0,1],[2,8,0,0,2,8,0,0,2,0,8,0],[0,8,8,0,0,8,8,0,0,8,0,8],[0,0,8,1,0,0,8,1,1,0,8,0]];function Ode(e){return{...e,bottomLeft:Ds(e.bottomLeft,[0,0,0]),topRight:Ds(e.topRight,e.scalarField.space.dimensions)}}function Lde(e){return{dX:e.topRight[0]-e.bottomLeft[0],dY:e.topRight[1]-e.bottomLeft[1],dZ:e.topRight[2]-e.bottomLeft[2]}}function a1(e,t){return Oe.create("Marching Cubes Mesh",function(){var n=ie(function*(r){const i=Ode(e),{dX:o,dY:s,dZ:a}=Lde(i),u=function Lut(e,t){const n=Math.min(65536,4*e),r=ze.create(Float32Array,3,e,t&&t.vertexBuffer.ref.value),i=ze.create(Float32Array,3,e,t&&t.normalBuffer.ref.value),o=ze.create(Float32Array,1,e,t&&t.groupBuffer.ref.value),s=ze.create(Uint32Array,3,n,t&&t.indexBuffer.ref.value);let a=0,c=0;return{addVertex:(u,l,d)=>(++a,ze.add3(r,u,l,d)),addNormal:(u,l,d)=>{ze.add3(i,u,l,d)},addGroup:u=>{ze.add(o,u)},addTriangle:(u,l,d,f)=>{const p=u[l],m=u[d],h=u[f];p>=0&&m>=0&&h>=0&&(++c,ze.add3(s,p,m,h))},get:()=>{const u=ze.compact(r,!0),l=ze.compact(i,!0),d=ze.compact(s,!0),f=ze.compact(o,!0);return Nt.create(u,d,l,f,a,c,t)}}}(Math.min(262144,Math.max(o*s*a/32,1024)),t);return yield new Ude(r,u,i).run(),u.get()});return function(r){return n.apply(this,arguments)}}())}function qU(e,t){return Oe.create("Marching Cubes Lines",function(){var n=ie(function*(r){const i=Ode(e),{dX:o,dY:s,dZ:a}=Lde(i),u=function Uut(e,t){const n=ze.create(Float32Array,3,e),r=ze.create(Float32Array,1,e),i=ze.create(Float32Array,2,e);let o=0;return{addVertex:(s,a,c)=>ze.add3(n,s,a,c),addNormal:()=>Ag,addGroup:s=>{ze.add(r,s)},addTriangle:(s,a,c,u,l)=>{s[a]>=0&&s[c]>=0&&s[u]>=0&&(HU[a][c]&l&&(++o,ze.add2(i,s[a],s[c])),HU[c][u]&l&&(++o,ze.add2(i,s[c],s[u])),HU[a][u]&l&&(++o,ze.add2(i,s[a],s[u])))},get:()=>{const s=ze.compact(n,!0),a=ze.compact(i,!0),c=ze.compact(r,!0),u=Fc.create(o,o/10,t);for(let l=0;l0)return i-1;const o=this.scalarField,s=this.scalarFieldGet,a=Fut[t],c=a.a,u=a.b,l=c.i+this.i,d=c.j+this.j,f=c.k+this.k,p=u.i+this.i,m=u.j+this.j,h=u.k+this.k,g=s(o,l,d,f),y=s(o,p,m,h),b=(this.isoLevel-g)/(g-y);if(this.idField){const M=this.idFieldGet(this.idField,l,d,f),N=this.idFieldGet(this.idField,p,m,h);let V=b<.5?M:N;if(-1===V&&(V=b<.5?N:M),-2===V)return-1;this.builder.addGroup(V)}else this.builder.addGroup(0);const x=this.builder.addVertex(l+b*(l-p),d+b*(d-m),f+b*(f-h));this.verticesOnEdges[r]=x+1;const _=s(o,Math.max(0,l-1),d,f)-s(o,Math.min(this.nX-1,l+1),d,f),S=s(o,l,Math.max(0,d-1),f)-s(o,l,Math.min(this.nY-1,d+1),f),A=s(o,l,d,Math.max(0,f-1))-s(o,l,d,Math.min(this.nZ,f+1)),I=_+b*(_-(s(o,Math.max(0,p-1),m,h)-s(o,Math.min(this.nX-1,p+1),m,h))),R=S+b*(S-(s(o,p,Math.max(0,m-1),h)-s(o,p,Math.min(this.nY-1,m+1),h))),T=A+b*(A-(s(o,p,m,Math.max(0,h-1))-s(o,p,m,Math.min(this.nZ-1,h+1))));return this.isoLevel>=0?this.builder.addNormal(I,R,T):this.builder.addNormal(-I,-R,-T),x}constructor(t,n){this.builder=t,this.vertList=[0,0,0,0,0,0,0,0,0,0,0,0],this.i=0,this.j=0,this.k=0;const r=n.scalarField.space.dimensions;this.nX=r[0],this.nY=r[1],this.nZ=r[2],this.isoLevel=n.isoLevel,this.scalarFieldGet=n.scalarField.space.get,this.scalarField=n.scalarField.data,n.idField&&(this.idField=n.idField.data,this.idFieldGet=n.idField.space.get),this.verticesOnEdges=new Int32Array(3*this.nX*this.nY*2)}get(t,n,r){return this.scalarFieldGet(this.scalarField,t,n,r)}processCell(t,n,r,i){let o=0;if(this.get(t,n,r)0&&(this.vertList[0]=this.interpolate(0)),(2&s)>0&&(this.vertList[1]=this.interpolate(1)),(4&s)>0&&(this.vertList[2]=this.interpolate(2)),(8&s)>0&&(this.vertList[3]=this.interpolate(3)),(16&s)>0&&(this.vertList[4]=this.interpolate(4)),(32&s)>0&&(this.vertList[5]=this.interpolate(5)),(64&s)>0&&(this.vertList[6]=this.interpolate(6)),(128&s)>0&&(this.vertList[7]=this.interpolate(7)),(256&s)>0&&(this.vertList[8]=this.interpolate(8)),(512&s)>0&&(this.vertList[9]=this.interpolate(9)),(1024&s)>0&&(this.vertList[10]=this.interpolate(10)),(2048&s)>0&&(this.vertList[11]=this.interpolate(11));const a=s1[o];for(let c=0;c=0?this.builder.addTriangle(this.vertList,u,l,d,i):this.builder.addTriangle(this.vertList,d,l,u,i)}}}function z0(e,t){const{defaultProps:n,createGeometry:r,createLocationIterator:i,getLoci:o,eachLocation:s,setUpdateState:a,mustRecreate:c,dispose:u}=e,{updateValues:l,updateBoundingSphere:d,updateRenderableState:f,createPositionIterator:p}=e.geometryUtils,m=Cf.create();let h,g,y,b,x,A,E,w,I,R,_=Object.assign({},n),S=Fo.createEmpty(),D=-1;function M(F){if(m.createNew){if(I=i(b,x),!F)throw new Error("expected geometry to be given");h=function zut(e,t,n,r,i,o){const{createValues:s,createRenderableState:a}=Zo.getUtils(t),u=s(t,e5(),n,r,i),l=a(i);return Dv(t.kind,u,l,o)}(0,F,I,y,g,t),R=p(F,h.values)}else{if(!h)throw new Error("expected renderObject to be available");if(m.updateTransform){I=i(b,x);const{instanceCount:G,groupCount:L}=I;g.instanceGranularity?Vi(G,"instance",h.values):Vi(G*L,"groupInstance",h.values)}else I.reset();if(m.createGeometry){if(!F)throw new Error("expected geometry to be given");k.updateIfChanged(h.values.drawCount,Zo.getDrawCount(F)),k.updateIfChanged(h.values.uVertexCount,Zo.getVertexCount(F)),k.updateIfChanged(h.values.uGroupCount,Zo.getGroupCount(F))}(m.updateTransform||m.createGeometry)&&(d(h.values,F||w),R=p(F||w,h.values)),m.updateSize&&"uSize"in h.values&&kp(I,y.size,h.values),m.updateColor&&bu(I,R,y.color,h.values),l(h.values,g),f(h.state,g)}_=g,S=y,A=b,E=x,F&&(w=F,D+=1)}function V(F,G){return Uc(F)?G(Ce.ofBounds(0,_.instanceGranularity?I.instanceCount:I.groupCount*I.instanceCount)):_.instanceGranularity?function N(F,G,L,z){let j=!1;if(et.Cell.isLoci(F)){if(et.Cell.isLociEmpty(F)||!et.areEquivalent(F.volume,G))return!1;z(Ce.ofSingleton(0))&&(j=!0)}else if(et.Segment.isLoci(F)){if(et.Segment.isLociEmpty(F)||!et.areEquivalent(F.volume,G)||!je.has(F.segments,L))return!1;z(Ce.ofSingleton(0))&&(j=!0)}return j}(F,A,E,G):s(F,A,E,_,G)}return{get groupCount(){return I?I.count:0},get renderObject(){return h},get geometryVersion(){return D},createOrUpdate:(F,G,L={},z)=>ie(function*(){if(function T(F,G,L,z){if(!L&&!A)throw new Error("missing volume");g=Object.assign({},_,G),y=F,b=L,x=z,Cf.reset(m),h?(!et.areEquivalent(b,A)||x!==E)&&(m.createNew=!0):m.createNew=!0,m.createNew?m.createGeometry=!0:(a(m,L,g,_,y,S),Lc.areEqual(F.color,S.color)||(m.updateColor=!0),m.createGeometry&&(m.updateColor=!0),g.instanceGranularity!==_.instanceGranularity&&(m.updateTransform=!0))}(G,L,z?.volume||A,z?.key||E),m.createGeometry){const j=r(F,b,x,y,g,w);return FI(j)?j.then(M):M(j)}M()})(),getLoci:F=>h?o(F,A,E,_,h.id):$n,eachLocation(F){for(I.reset();I.hasNext;){const{location:G,isSecondary:L}=I.move();F(G,L)}},mark:(F,G)=>Sn.mark(h,F,G,V),setVisibility(F){Sn.setVisibility(h,F)},setAlphaFactor(F){Sn.setAlphaFactor(h,F)},setPickable(F){Sn.setPickable(h,F)},setColorOnly(F){Sn.setColorOnly(h,F)},setTransform(F,G){Sn.setTransform(h,F,G)},setOverpaint:F=>Sn.setOverpaint(h,F,V,!0),setTransparency:F=>Sn.setTransparency(h,F,V,!0),setSubstance:F=>Sn.setSubstance(h,F,V,!0),setClipping:F=>Sn.setClipping(h,F,V,!0),setThemeStrength(F){Sn.setThemeStrength(h,F)},destroy(){u?.(w),h&&(h.state.disposed=!0,h=void 0)},mustRecreate:c}}function pC(e,t,n,r,i,o=(()=>[-1])){let s=0;const{webgl:a}=t,c=new mr,u=new yn.GeometryState,l=Hp(),d=[],f=yn.createState(),p=new Map;let m,h,g,y,b=Fo.createEmpty();function x(R,T){return _.apply(this,arguments)}function _(){return(_=ie(function*(R,T){var M;let N=p.get(T);return N?!(null===(M=N.mustRecreate)||void 0===M)&&M.call(N,{volume:m,key:T},y,a)&&(N.destroy(),N=r(l,m,T,y,a),p.set(T,N)):(N=r(l,m,T,y,a),p.set(T,N)),N.createOrUpdate({webgl:a,runtime:R},b,y,{volume:m,key:T})})).apply(this,arguments)}return{label:e,get groupCount(){let R=0;return p.forEach(T=>{T.renderObject&&(R+=T.groupCount)}),R},get props(){return y},get params(){return g},get state(){return f},get theme(){return b},get geometryVersion(){return u.version},renderObjects:d,updated:c,createOrUpdate:function S(R={},T){T&&T!==m&&(g=n(t,T),m=T,y||(y=C.getDefaultValues(g)));const M=s8(Object.assign({},y,R),m);return Object.assign(y,R,M),h=o(y),Oe.create("Creating or updating VolumeRepresentation",function(){var N=ie(function*(V){const F=new Set(p.keys());for(let G=0,L=h.length;G{var L;null===(L=p.get(G))||void 0===L||L.destroy(),p.delete(G)}),d.length=0,p.forEach(G=>{G.renderObject&&(d.push(G.renderObject),u.add(G.renderObject.id,G.geometryVersion))}),u.snapshot(),c.next(s++)});return function(V){return N.apply(this,arguments)}}())},setState:function w(R){const{visible:T,alphaFactor:M,pickable:N,overpaint:V,transparency:F,substance:G,clipping:L,transform:z,themeStrength:j,syncManually:Z,markerActions:$}=R,ee={};void 0!==T&&(ee.visible=T),void 0!==M&&(ee.alphaFactor=M),void 0!==N&&(ee.pickable=N),void 0!==V&&(ee.overpaint=V),void 0!==F&&(ee.transparency=F),void 0!==G&&(ee.substance=G),void 0!==L&&(ee.clipping=L),void 0!==j&&(ee.themeStrength=j),void 0!==z&&!le.areEqual(z,f.transform,vr)&&(ee.transform=z),void 0!==Z&&(ee.syncManually=Z),void 0!==$&&(ee.markerActions=$),p.forEach(q=>function E(R,T){void 0!==T.visible&&R&&R.setVisibility(T.visible),void 0!==T.alphaFactor&&R&&R.setAlphaFactor(T.alphaFactor),void 0!==T.pickable&&R&&R.setPickable(T.pickable),void 0!==T.overpaint&&R&&R.setOverpaint(T.overpaint),void 0!==T.transparency&&R&&R.setTransparency(T.transparency),void 0!==T.substance&&R&&R.setSubstance(T.substance),void 0!==T.clipping&&R&&R.setClipping(T.clipping),void 0!==T.transform&&R&&R.setTransform(T.transform),void 0!==T.themeStrength&&R&&R.setThemeStrength(T.themeStrength)}(q,ee)),yn.updateState(f,R)},setTheme:function D(R){b=R},getLoci:R=>{let T=$n;return p.forEach(M=>{const N=M.getLoci(R);Ta(N)||(T=N)}),T},getAllLoci:()=>[i(m,y)],eachLocation:R=>{p.forEach(T=>{T.eachLocation(R)})},mark:function A(R,T){let M=!1;return p.forEach(N=>{M=N.mark(R,T)||M}),M},destroy:function I(){p.forEach(R=>R.destroy()),p.clear()}}}const Gut="\nprecision highp float;\nprecision highp int;\n\n#if __VERSION__ == 100\n precision highp sampler2D;\n uniform sampler2D tTexture;\n#else\n precision highp isampler2D;\n uniform isampler2D tTexture;\n#endif\n\nvoid main(void) {\n #if __VERSION__ == 100\n gl_FragColor = texture2D(tTexture, vec2(0.5));\n #else\n gl_FragColor = ivec4(texture2D(tTexture, vec2(0.5)).r);\n #endif\n}\n",jut={...vo,tTexture:jt("texture","rgba","float","nearest")},Sl="histopyramid-sum";const s3=new Uint8Array(4),Vde=new Int32Array(4),Yut="\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tInputLevel;\n\n// previous level used to evaluate the new level\n#if __VERSION__ == 100\n uniform sampler2D tPreviousLevel;\n#else\n precision highp isampler2D;\n uniform isampler2D tPreviousLevel;\n#endif\n\n// inverted size of the previous level texture.\nuniform float uSize;\nuniform float uTexSize;\nuniform bool uFirst;\n\n#include common\n\nvoid main(void) {\n float k = 0.5 * uSize;\n vec2 position = floor((gl_FragCoord.xy / uTexSize) / uSize) * uSize;\n\n #if __VERSION__ == 100\n float a, b, c, d;\n\n if (uFirst) {\n a = texture2D(tInputLevel, position).r * 255.0;\n b = texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0;\n c = texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0;\n d = texture2D(tInputLevel, position + vec2(k, k)).r * 255.0;\n } else {\n a = unpackRGBToInt(texture2D(tPreviousLevel, position).rgb);\n b = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(k, 0.0)).rgb);\n c = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(0.0, k)).rgb);\n d = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(k, k)).rgb);\n }\n gl_FragColor = vec4(packIntToRGB(a + b + c + d), 1.0);\n #else\n int a, b, c, d;\n\n if (uFirst) {\n a = int(texture2D(tInputLevel, position).r * 255.0);\n b = int(texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0);\n c = int(texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0);\n d = int(texture2D(tInputLevel, position + vec2(k, k)).r * 255.0);\n } else {\n a = texture2D(tPreviousLevel, position).r;\n b = texture2D(tPreviousLevel, position + vec2(k, 0.0)).r;\n c = texture2D(tPreviousLevel, position + vec2(0.0, k)).r;\n d = texture2D(tPreviousLevel, position + vec2(k, k)).r;\n }\n gl_FragColor = ivec4(a + b + c + d);\n #endif\n}\n",Xut={...vo,tInputLevel:jt("texture","rgba","float","nearest"),tPreviousLevel:jt("texture","rgba","float","nearest"),uSize:xe("f"),uTexSize:xe("f"),uFirst:xe("b")},Fm="histogram-pyramid";function Qut(e,t){const n=Math.pow(2,t),r=`level${t}`,i=e.isWebGL2?a3(r,e,"image-int32","alpha","int","nearest"):a3(r,e,"image-uint8","rgba","ubyte","nearest");i.define(n,n);let o=function elt(e,t){return t.namedFramebuffers[`${Fm}-${e}`]}(r,e);return o||(o=zde(r,e),i.attachFramebuffer(o,0)),{texture:i,framebuffer:o}}function zde(e,t){const n=`${Fm}-${e}`;return t.namedFramebuffers[n]||(t.namedFramebuffers[n]=t.resources.framebuffer()),t.namedFramebuffers[n]}function a3(e,t,n,r,i,o){const s=`${Fm}-${e}`;return t.namedTextures[s]||(t.namedTextures[s]=t.resources.texture(n,r,i,o)),t.namedTextures[s]}function tlt(e,t,n,r){lt&&e.timer.mark("createHistogramPyramid");const{gl:i,state:o}=e,s=t.getWidth();if(s!==t.getHeight()||!$x(s))throw new Error("inputTexture must be of square power-of-two size");const c=Math.ceil(Math.log(s)/Math.log(2)),u=Math.pow(2,c),l=Math.pow(2,c),d=Math.pow(2,c-1),f=e.isWebGL2?a3("pyramid",e,"image-int32","alpha","int","nearest"):a3("pyramid",e,"image-uint8","rgba","ubyte","nearest");f.define(l,d);const p=zde("pyramid",e);f.attachFramebuffer(p,0),o.viewport(0,0,l,d),Wt(i)?i.clearBufferiv(i.COLOR,0,[0,0,0,0]):i.clear(i.COLOR_BUFFER_BIT);const m=[];for(let x=0;x0&&(k.update(h.values.tPreviousLevel,m[c-x].texture),h.update()),o.currentRenderItemId=-1,o.viewport(0,0,A,A),o.scissor(0,0,A,A),Wt(i)?i.clearBufferiv(i.COLOR,0,[0,0,0,0]):i.clear(i.COLOR_BUFFER_BIT),o.scissor(0,0,r[0],r[1]),h.render(),f.bind(0),i.copyTexSubImage2D(i.TEXTURE_2D,0,g,0,0,0,A,A),f.unbind(0),g+=A}i.finish(),lt&&e.timer.markEnd("createHistogramPyramid");const y=Math.max(1,function $ut(e,t){lt&&e.timer.mark("getHistopyramidSum");const{gl:n,state:r,resources:i}=e,o=function Hut(e,t){return e.namedComputeRenderables[Sl]?(k.update(e.namedComputeRenderables[Sl].values.tTexture,t),e.namedComputeRenderables[Sl].update()):e.namedComputeRenderables[Sl]=function qut(e,t){const n={..._o,tTexture:k.create(t)},r={...jut};return ji(zi(e,"triangles",Br("sum",ps,Gut,{},{0:"ivec4"}),r,n),n)}(e,t),e.namedComputeRenderables[Sl]}(e,t);e.state.currentRenderItemId=-1,e.namedFramebuffers[Sl]||(e.namedFramebuffers[Sl]=i.framebuffer());const s=e.namedFramebuffers[Sl];return e.namedTextures[Sl]||(e.namedTextures[Sl]=Wt(n)?i.texture("image-int32","rgba","int","nearest"):i.texture("image-uint8","rgba","ubyte","nearest"),e.namedTextures[Sl].define(1,1)),e.namedTextures[Sl].attachFramebuffer(s,0),function Wut(e){const{gl:t,state:n}=e;n.disable(t.CULL_FACE),n.disable(t.BLEND),n.disable(t.DEPTH_TEST),n.disable(t.SCISSOR_TEST),n.depthMask(!1),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0)}(e),r.viewport(0,0,1,1),o.render(),n.finish(),e.readPixels(0,0,1,1,Wt(n)?Vde:s3),e.unbindFramebuffer(),lt&&e.timer.markEnd("getHistopyramidSum"),Wt(n)?Vde[0]:g5(s3[0],s3[1],s3[2])}(e,m[0].texture));return{pyramidTex:f,count:y,height:Math.ceil(y/Math.pow(2,c)),levels:c,scale:n}}let hC,mC;function nlt(){if(void 0!==hC)return hC;hC=Po(256,1,Uint8Array);const{array:e}=hC;for(let t=0,n=s1.length;tMr(t.grid.cells.data.length,1,1,()=>rc),getLoci:$U,eachLocation:YU,setUpdateState:(t,n,r,i)=>{et.IsoValue.areSame(r.isoValue,i.isoValue,n.grid.stats)||(t.createGeometry=!0)},geometryUtils:xa.Utils,mustRecreate:(t,n,r)=>!n.tryUseGpu||!r||!WU(t.volume,r),dispose:t=>{t.vertexTexture.ref.value.destroy(),t.groupTexture.ref.value.destroy(),t.normalTexture.ref.value.destroy(),t.doubleBuffer.destroy()}},e)}(e):function vlt(e){return z0({defaultProps:C.getDefaultValues(KU),createGeometry:blt,createLocationIterator:t=>Mr(t.grid.cells.data.length,1,1,()=>rc),getLoci:$U,eachLocation:YU,setUpdateState:(t,n,r,i)=>{et.IsoValue.areSame(r.isoValue,i.isoValue,n.grid.stats)||(t.createGeometry=!0)},geometryUtils:Nt.Utils,mustRecreate:(t,n,r)=>n.tryUseGpu&&!!r&&WU(t.volume,r)},e)}(e)}function jde(e,t){return et.Isosurface.Loci(e,t.isoValue)}function $U(e,t,n,r,i){const{objectId:o,groupId:s}=e;if(i===o){const a=et.PickingGranularity.get(t);return"volume"===a?et.Loci(t):"object"===a?et.Isosurface.Loci(t,r.isoValue):et.Cell.Loci(t,Ce.ofSingleton(s))}return $n}function YU(e,t,n,r,i){return oE(e,t,{isoValue:r.isoValue},i)}function blt(e,t,n,r,i,o){return XU.apply(this,arguments)}function XU(){return XU=ie(function*(e,t,n,r,i,o){e.runtime.update({message:"Marching cubes..."});const s=Tc(new Int32Array(t.grid.cells.data.length)),a=yield a1({isoLevel:et.IsoValue.toAbsolute(i.isoValue,t.grid.stats).absoluteValue,scalarField:t.grid.cells,idField:wn.create(t.grid.cells.space,wn.Data1(s))},o).runAsChild(e.runtime),c=Ko.getGridToCartesianTransform(t.grid);return Nt.transform(a,c),e.webgl&&!e.webgl.isWebGL2?(Nt.uniformTriangleGroup(a,!1),k.updateIfChanged(a.varyingGroup,!1)):k.updateIfChanged(a.varyingGroup,!0),a.setBoundingSphere(et.Isosurface.getBoundingSphere(t,i.isoValue)),a}),XU.apply(this,arguments)}const KU={...Nt.Params,...xa.Params,...Gde,quality:{...Nt.Params.quality,isEssential:!1},tryUseGpu:C.Boolean(!0)};var ZU;function _lt(e,t,n,r,i,o){return QU.apply(this,arguments)}function QU(){return QU=ie(function*(e,t,n,r,i,o){if(!e.webgl)throw new Error("webgl context required to create volume isosurface texture-mesh");if(t.grid.cells.data.length<=1)return xa.createEmpty(o);const{max:s,min:a}=t.grid.stats,c=s-a,u=et.IsoValue.toAbsolute(i.isoValue,t.grid.stats).absoluteValue,l=(u-a)/c,{texture:d,gridDimension:f,gridTexDim:p,gridTexScale:m,transform:h}=ZU.get(t,e.webgl),g=t.grid.cells.space.axisOrderSlowToFast,y=o?.doubleBuffer.get(),b=c3(e.webgl,d,f,p,m,h,l,u<0,!1,g,!0,y?.vertex,y?.group,y?.normal),x=t.grid.cells.data.length,_=et.getBoundingSphere(t),S=xa.create(b.vertexCount,x,b.vertexTexture,b.groupTexture,b.normalTexture,_,o);return S.meta.webgl=e.webgl,S}),QU.apply(this,arguments)}function Slt(e,t,n,r,i,o){return JU.apply(this,arguments)}function JU(){return JU=ie(function*(e,t,n,r,i,o){e.runtime.update({message:"Marching cubes..."});const s=Tc(new Int32Array(t.grid.cells.data.length)),a=yield qU({isoLevel:et.IsoValue.toAbsolute(i.isoValue,t.grid.stats).absoluteValue,scalarField:t.grid.cells,idField:wn.create(t.grid.cells.space,wn.Data1(s))},o).runAsChild(e.runtime),c=Ko.getGridToCartesianTransform(t.grid);return di.transform(a,c),a.setBoundingSphere(et.Isosurface.getBoundingSphere(t,i.isoValue)),a}),JU.apply(this,arguments)}!function(e){const t="volume-isosurface-texture";e.descriptor=au({name:t}),e.get=function n(r,i){const{resources:o}=i,s=Ko.getGridToCartesianTransform(r.grid),a=v.clone(r.grid.cells.space.dimensions),{width:c,height:u,powerOfTwoSize:l}=vm(a,gC),d=v.create(c,u,0),f=Me.create(c/l,u/l);if(l>i.maxTextureSize/2)throw new Error("volume too large for gpu isosurface extraction");if(!r._propertyData[t]){r._propertyData[t]=o.texture("image-uint8","alpha","ubyte","linear");const p=r._propertyData[t];p.define(l,l),p.load(Fae(r,"data",gC),!0),r.customProperties.add(e.descriptor),r.customProperties.assets(e.descriptor,[{dispose:()=>p.destroy()}])}return a[0]+=gC,a[1]+=gC,{texture:r._propertyData[t],transform:s,gridDimension:a,gridTexDim:d,gridTexScale:f}}}(ZU||(ZU={}));const Hde={...di.Params,...Gde,quality:{...di.Params.quality,isEssential:!1},sizeFactor:C.Numeric(3,{min:0,max:10,step:.1})};function Clt(e){return z0({defaultProps:C.getDefaultValues(Hde),createGeometry:Slt,createLocationIterator:t=>Mr(t.grid.cells.data.length,1,1,()=>rc),getLoci:$U,eachLocation:YU,setUpdateState:(t,n,r,i)=>{et.IsoValue.areSame(r.isoValue,i.isoValue,n.grid.stats)||(t.createGeometry=!0)},geometryUtils:di.Utils},e)}const qde={solid:(e,t)=>pC("Isosurface mesh",e,t,ylt,jde),wireframe:(e,t)=>pC("Isosurface wireframe",e,t,Clt,jde)},Wde={...KU,...Hde,visuals:C.MultiSelect(["solid"],C.objectToOptions(qde)),bumpFrequency:C.Numeric(1,{min:0,max:10,step:.1},rt.ShadingCategory)},Ilt={name:"isosurface",label:"Isosurface",description:"Displays a triangulated isosurface of volumetric data.",factory:function Alt(e,t){return yn.createMulti("Isosurface",e,t,yn.StateBuilder,qde)},getParams:function wlt(e,t){const n=C.clone(Wde);return n.isoValue=et.createIsoValueParam(et.IsoValue.relative(2),t.grid.stats),n},defaultValues:C.getDefaultValues(Wde),defaultColorTheme:{name:"uniform"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>!et.isEmpty(e)&&!et.Segmentation.get(e)};function Tlt(e,t,n,r,i,o){return eV.apply(this,arguments)}function eV(){return eV=ie(function*(e,t,n,r,i,o){const{dimension:{name:s},isoValue:a}=i,{space:c,data:u}=t.grid.cells,{min:l,max:d}=t.grid.stats,f=et.IsoValue.toAbsolute(a,t.grid.stats).absoluteValue,p="color"in r.color?r.color.color(rc,!1):st(16777215),[m,h,g]=st.toRgbNormalized(p),{width:y,height:b,x,y:_,z:S,x0:A,y0:E,z0:w,nx:D,ny:I,nz:R}=tV(t.grid,i),T=new Float32Array("x"===s?[x,0,0,x,_,0,x,0,S,x,_,S]:"y"===s?[0,_,0,x,_,0,0,_,S,x,_,S]:[0,0,S,0,_,S,x,0,S,x,_,S]),M=new Uint8Array(y*b*4),N=function Dlt(e,t){const{space:n}=e.cells,{width:r,height:i,x0:o,y0:s,z0:a,nx:c,ny:u,nz:l}=tV(e,t),d=new Uint8Array(r*i*4);let f=0;for(let p=s;p=f?255:0,V+=4}const F={width:y,height:b,array:M,flipY:!0},G={width:y,height:b,array:N,flipY:!0};return l0(Ko.getGridToCartesianTransform(t.grid),T,0,4),jp.create(F,T,G,o)}),eV.apply(this,arguments)}function tV(e,t){const{dimension:{name:n,params:r}}=t,{space:i}=e.cells;let o,s,a,c,u,l=0,d=0,f=0,[p,m,h]=i.dimensions;return"x"===n?(a=r,c=m-1,u=h-1,o=h,s=m,l=a,p=l+1):"y"===n?(a=p-1,c=r,u=h-1,o=h,s=p,d=c,m=d+1):(a=p-1,c=m-1,u=r,o=p,s=m,f=u,h=f+1),{width:o,height:s,x:a,y:c,z:u,x0:l,y0:d,z0:f,nx:p,ny:m,nz:h}}function $de(e,t){const n=function Elt(e,t){const{space:n}=e.cells,{width:r,height:i,x0:o,y0:s,z0:a,nx:c,ny:u,nz:l}=tV(e,t),d=new Uint32Array(r*i);let f=0;for(let p=s;pMr(t.grid.cells.data.length,1,1,()=>rc),getLoci:Plt,eachLocation:Mlt,setUpdateState:(t,n,r,i,o,s)=>{t.createGeometry=r.dimension.name!==i.dimension.name||r.dimension.params!==i.dimension.params||!et.IsoValue.areSame(r.isoValue,i.isoValue,n.grid.stats)||!Lc.areEqual(o.color,s.color)},geometryUtils:{...jp.Utils,createRenderableState:t=>{const n=jp.Utils.createRenderableState(t);return Yde(n,t),n},updateRenderableState:Yde}},e)}function Yde(e,t){jp.Utils.updateRenderableState(e,t),e.opaque=!1,e.writeDepth=!0}const Flt={name:"slice",label:"Slice",description:"Slice of volume rendered as image with interpolation.",factory:function Nlt(e,t){return pC("Slice",e,t,klt,$de)},getParams:function Rlt(e,t){const n=C.clone(nV),r=t.grid.cells.space.dimensions;return n.dimension=C.MappedStatic("x",{x:C.Numeric(0,{min:0,max:r[0]-1,step:1}),y:C.Numeric(0,{min:0,max:r[1]-1,step:1}),z:C.Numeric(0,{min:0,max:r[2]-1,step:1})},{isEssential:!0}),n.isoValue=et.createIsoValueParam(et.IsoValue.absolute(t.grid.stats.min),t.grid.stats),n},defaultValues:C.getDefaultValues(nV),defaultColorTheme:{name:"uniform"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>!et.isEmpty(e)&&!et.Segmentation.get(e)};function Xde(e,t){const n=St();return St.add(n,e),St.transform(n,n,t),n}function Kde(e){if("matrix"===e.transform.kind)return{unitToCartn:le.mul(le(),e.transform.matrix,le.fromScaling(le(),e.cells.space.dimensions)),cellDim:le.getScaling(v(),e.transform.matrix)};const t=e.transform.fractionalBox,n=St.size(v(),t);return{unitToCartn:le.mul3(le(),e.transform.cell.fromFractional,le.fromTranslation(le(),t.min),le.fromScaling(le(),n)),cellDim:v.div(v(),e.transform.cell.size,e.cells.space.dimensions)}}function Llt(e,t,n,r,i,o){return rV.apply(this,arguments)}function rV(){return rV=ie(function*(e,t,n,r,i,o){const{webgl:a}=e;if(void 0===a)throw new Error("DirectVolumeVisual requires `webgl` in props");return a.isWebGL2?function Olt(e,t,n,r){const i=n.grid.cells.space.dimensions;if(Math.max(...i)>t.max3dTextureSize/2)throw new Error("volume too large for direct-volume rendering");const o=function SQe(e){const{cells:{space:t,data:n},stats:{max:r,min:i}}=e.grid,[o,s,a]=t.dimensions,{dataOffset:c}=t,u=new Uint8Array(o*s*a*4),l={array:u,width:o,height:s,depth:a},d=r-i,f=v(),p=v(),m=o-1,h=s-1,g=a-1;let y=0;for(let b=0;bt.maxTextureSize/2)throw new Error("volume too large for direct-volume rendering");const a=Fae(n,"normals"),c=Ko.getGridToCartesianTransform(n.grid),u=Xde(i,c),l=r?r.gridTexture.ref.value:t.resources.texture("image-uint8","rgba","ubyte","linear");l.load(a);const{unitToCartn:d,cellDim:f}=Kde(n.grid);return _u.create(u,i,c,d,f,l,n.grid.stats,!1,n.grid.cells.space.axisOrderSlowToFast,r)}(0,a,t,o)}),rV.apply(this,arguments)}function Ult(e,t){return et.Loci(e)}function Vlt(e,t,n,r,i){const{objectId:o,groupId:s}=e;return i===o?et.Cell.Loci(t,Ce.ofSingleton(s)):$n}function zlt(e,t,n,r,i){return oE(e,t,void 0,i)}const iV={..._u.Params,quality:{..._u.Params.quality,isEssential:!1}};function jlt(e){return z0({defaultProps:C.getDefaultValues(iV),createGeometry:Llt,createLocationIterator:t=>Mr(t.grid.cells.data.length,1,1,()=>rc),getLoci:Vlt,eachLocation:zlt,setUpdateState:(t,n,r,i)=>{},geometryUtils:_u.Utils,dispose:t=>{t.gridTexture.ref.value.destroy()}},e)}const qlt={name:"direct-volume",label:"Direct Volume",description:"Direct rendering of volumetric data.",factory:function Hlt(e,t){return pC("Direct Volume",e,t,jlt,Ult)},getParams:function Glt(e,t){const n=C.clone(iV);return n.controlPoints.getVolume=()=>t,n},defaultValues:C.getDefaultValues(iV),defaultColorTheme:{name:"volume-value"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>!et.isEmpty(e)&&!et.Segmentation.get(e)},Wlt={segments:C.Converted(e=>e.map(t=>`${t}`),e=>e.map(t=>parseInt(t)),C.MultiSelect(["0"],C.arrayToOptions(["0"]),{isEssential:!0}))},yC=1;function oV(e,t){if(e.grid.cells.data.length{const r=et.Segment.Location(t,n);return Mr(t.grid.cells.data.length,1,1,()=>r)},getLoci:Qde,eachLocation:Jde,setUpdateState:(t,n,r,i)=>{},geometryUtils:xa.Utils,mustRecreate:(t,n,r)=>!n.tryUseGpu||!r||!oV(t.volume,r),dispose:t=>{t.vertexTexture.ref.value.destroy(),t.groupTexture.ref.value.destroy(),t.normalTexture.ref.value.destroy(),t.doubleBuffer.destroy()}},e)}(e):function Jlt(e){return z0({defaultProps:C.getDefaultValues(aV),createGeometry:Qlt,createLocationIterator:(t,n)=>{const r=et.Segment.Location(t,n);return Mr(t.grid.cells.data.length,1,1,()=>r)},getLoci:Qde,eachLocation:Jde,setUpdateState:(t,n,r,i)=>{},geometryUtils:Nt.Utils,mustRecreate:(t,n,r)=>n.tryUseGpu&&!!r&&oV(t.volume,r)},e)}(e)}function Klt(e,t){return et.Segment.Loci(e,t.segments)}function Qde(e,t,n,r,i){const{objectId:o,groupId:s}=e;if(i===o){const a=et.PickingGranularity.get(t);return"volume"===a?et.Loci(t):"object"===a?et.Segment.Loci(t,[n]):et.Cell.Loci(t,Ce.ofSingleton(s))}return $n}function Jde(e,t,n,r,i){return oE(e,t,{segments:je.ofSingleton(n)},i)}function Qlt(e,t,n,r,i,o){return sV.apply(this,arguments)}function sV(){return sV=ie(function*(e,t,n,r,i,o){const s=et.Segmentation.get(t);if(!s)throw new Error("missing volume segmentation");e.runtime.update({message:"Marching cubes..."});const a=St.clone(s.bounds[n]);St.expand(a,a,v.create(2,2,2));const u=function Zlt(e,t,n){const r=n.data,i=n.space.dataOffset,o=St.size(v(),t),[s,a,c]=o,u=s-1,l=a-1,d=c-1,[f,p,m]=t.min,[h,g,y]=t.max,b=[...n.space.axisOrderSlowToFast],x=wn.Space(o,b,Uint8Array),_=wn.create(x,x.create()),S=_.data,A=x.set;for(let E=0;En.maxTextureSize/2)throw new Error("volume too large for gpu segment extraction");n.namedTextures[cV]||(n.namedTextures[cV]=i.texture("image-uint8","alpha","ubyte","linear"));const p=n.namedTextures[cV];p.define(l,l);const m=Array.from(r.segments.get(t).values());return p.load(function CQe(e,t,n,r=0){const i=e.grid.cells.data,o=St.size(v(),n),s=e.grid.cells.space.dataOffset,{width:a,height:c}=vm(o,r),l=new Uint8Array(a*c*1),d={array:l,width:a,height:c},[f,p,m]=o,h=f-1,g=p-1,y=m-1,b=f+r,x=p+r,[_,S,A]=n.min,[E,w,D]=n.max;for(let I=0;IpC("Segment mesh",e,t,Xlt,Klt,rdt)},tfe={...aV,visuals:C.MultiSelect(["segment"],C.objectToOptions(efe)),bumpFrequency:C.Numeric(1,{min:0,max:10,step:.1},rt.ShadingCategory)},sdt={name:"segment",label:"Segment",description:"Displays a triangulated segment of volumetric data.",factory:function odt(e,t){return yn.createMulti("Segment",e,t,yn.StateBuilder,efe)},getParams:function idt(e,t){const n=C.clone(tfe),r=et.Segmentation.get(t);if(r){const i=Array.from(r.segments.keys());n.segments=C.Converted(o=>o.map(s=>`${s}`),o=>o.map(s=>parseInt(s)),C.MultiSelect(i.map(o=>`${o}`),C.arrayToOptions(i.map(o=>`${o}`)),{isEssential:!0}))}return n},defaultValues:C.getDefaultValues(tfe),defaultColorTheme:{name:"volume-segment"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>!et.isEmpty(e)&&!!et.Segmentation.get(e)};class c1 extends Vae{constructor(){super(),$a(c1.BuiltIn,(t,n)=>{if(t.name!==n)throw new Error(`Fix BuiltInVolumeRepresentations to have matching names. ${t.name} ${n}`);this.add(t)})}}function nfe(e,t,n,r){e.push({source:"em"===t?{name:"em",params:{isoValue:et.IsoValue.absolute(r||0)}}:{name:"x-ray",params:{}},dataId:n})}!function(e){e.BuiltIn={isosurface:Ilt,slice:Flt,"direct-volume":qlt,segment:sdt}}(c1||(c1={}));const adt=nc.build({display:{name:"Volume Streaming"},from:pe.Molecule.Structure,params(e,t){const n=function _ut(e,t="x-ray"){if(!e)return t;const n=e.models[0];return Er.is(n.sourceData)?sn.hasEmMap(n)?"em":sn.hasXrayMap(n)?"x-ray":sn.isFromEm(n)?"em":sn.isFromXray(n)?"x-ray":t:t}(e&&e.data),r=function Cut(e,t){if(!t||!t.models.length)return[];const n=t.models[0];switch(e){case"em":return function xut(e){const t=[];if(!Er.is(e.sourceData))return[e.entryId];const{db_id:n,db_name:r,content_type:i}=e.sourceData.data.db.pdbx_database_related;if(!r.isDefined)return[e.entryId];for(let o=0,s=r.rowCount;oi,{defaultValue:r.map(i=>({id:i}))}),defaultView:C.Select("em"===n?"auto":"selection-box",Tu.ViewTypeOptions),options:C.Group({serverUrl:C.Text(t.config.get(qi.VolumeStreaming.DefaultServer)||"https://ds.litemol.org"),behaviorRef:C.Text("",{isHidden:!0}),emContourProvider:C.Select("emdb",[["emdb","EMDB"],["pdbe","PDBe"]],{isHidden:!0}),channelParams:C.Value({},{isHidden:!0})})}},isApplicable:(e,t,n)=>{const r=n.config.get(qi.VolumeStreaming.CanStream);return r?r(e.data,n):1===e.data.models.length&&sn.probablyHasDensityMap(e.data.models[0])}})(({ref:e,state:t,params:n},r)=>Oe.create("Volume Streaming",function(){var i=ie(function*(o){const s=[];for(let f=0,p=n.entries.length;f0&&(yield r.managers.structure.hierarchy.remove(u?.toArray()));const l=c.cell.obj,d=t.build().to(a.ref).apply(rfe,C.getDefaultValues(Tu.createParams({data:l.data,defaultView:n.defaultView,channelParams:n.options.channelParams})),{ref:n.options.behaviorRef?n.options.behaviorRef:void 0});"em"===n.method?d.apply(u3,{channel:"em"},{state:{isGhost:!0},tags:"em"}):(d.apply(u3,{channel:"2fo-fc"},{state:{isGhost:!0},tags:"2fo-fc"}),d.apply(u3,{channel:"fo-fc(+ve)"},{state:{isGhost:!0},tags:"fo-fc(+ve)"}),d.apply(u3,{channel:"fo-fc(-ve)"},{state:{isGhost:!0},tags:"fo-fc(-ve)"})),yield t.updateTree(d).runInContext(o)});return function(o){return i.apply(this,arguments)}}())),cdt=nc.build({display:{name:"Boxify Volume Streaming",description:"Make the current box permanent."},from:Tu,isApplicable:e=>"selection-box"===e.data.params.entry.params.view.name})(({a:e,ref:t,state:n},r)=>{const i=e.data.params;if("selection-box"!==i.entry.params.view.name)return;const o=St.create(v.clone(i.entry.params.view.params.bottomLeft),v.clone(i.entry.params.view.params.topRight)),s=i.entry.params.view.params.radius;St.expand(o,o,v.create(s,s,s));const a={...i,entry:{name:i.entry.name,params:{...i.entry.params,view:{name:"box",params:{bottomLeft:o.min,topRight:o.max}}}}};return n.updateTree(n.build().to(t).update(a))}),udt={dataId:C.Text(""),source:C.MappedStatic("x-ray",{em:C.Group({isoValue:et.createIsoValueParam(et.IsoValue.relative(1))}),"x-ray":C.Group({})})},ldt=Rt.BuiltIn({name:"create-volume-streaming-info",display:{name:"Volume Streaming Info"},from:pe.Molecule.Structure,to:LU,params:e=>({serverUrl:C.Text("https://ds.litemol.org"),entries:C.ObjectList(udt,({dataId:t})=>t,{defaultValue:[{dataId:"",source:{name:"x-ray",params:{}}}]})})})({apply:({a:e,params:t},n)=>Oe.create("",function(){var r=ie(function*(i){const o=[];for(let a=0,c=t.entries.length;aa.dataId).join(", ")}`})});return function(i){return r.apply(this,arguments)}}())}),rfe=Rt.BuiltIn({name:"create-volume-streaming-behavior",display:{name:"Volume Streaming Behavior"},from:LU,to:Tu,params:e=>Tu.createParams({data:e&&e.data})})({canAutoUpdate:({oldParams:e,newParams:t})=>e.entry.params.view===t.entry.params.view||"selection-box"===t.entry.params.view.name||"camera-target"===t.entry.params.view.name||"off"===t.entry.params.view.name,apply:({a:e,params:t},n)=>Oe.create("Volume streaming",function(){var r=ie(function*(i){const o=new Tu.Behavior(n,e.data);return yield o.update(t),new Tu(o,{label:"Volume Streaming",description:o.getDescription()})});return function(i){return r.apply(this,arguments)}}()),update:({b:t,oldParams:n,newParams:r})=>Oe.create("Update Volume Streaming",function(){var i=ie(function*(o){if(n.entry.name!==r.entry.name&&"em"in r.entry.params.channels){const{emDefaultContourLevel:a}=t.data.infoMap.get(r.entry.name);a&&(r.entry.params.channels.em.isoValue=a)}const s=(yield t.data.update(r))?Qe.UpdateResult.Updated:Qe.UpdateResult.Unchanged;return t.description=t.data.getDescription(),s});return function(o){return i.apply(this,arguments)}}())}),u3=Rt.BuiltIn({name:"create-volume-streaming-visual",display:{name:"Volume Streaming Visual"},from:Tu,to:pe.Volume.Representation3D,params:{channel:C.Select("em",Tu.ChannelTypeOptions,{isHidden:!0})}})({apply:({a:e,params:t,spine:n},r)=>Oe.create("Volume Representation",function(){var i=ie(function*(o){var s,a;const c=e.data.channels[t.channel];if(!c)return li.Null;const u=ife(e.data,t.channel),l=c1.BuiltIn.isosurface,d=u.type.params||{},f=l.factory({webgl:null===(s=r.canvas3d)||void 0===s?void 0:s.webgl,...r.representation.volume.themes},l.getParams);f.setTheme(Fo.create(r.representation.volume.themes,{volume:c.data},u));const p=null===(a=n.getAncestorOfType(pe.Molecule.Structure))||void 0===a?void 0:a.data,m=0===p?.models.length?void 0:Hg.get(p?.models[0]);return yield f.createOrUpdate(d,c.data).runInContext(o),m&&f.setState({transform:m}),new pe.Volume.Representation3D({repr:f,sourceData:c.data},{label:`${Math.round(100*c.isoValue.relativeValue)/100} \u03c3 [${t.channel}]`})});return function(o){return i.apply(this,arguments)}}()),update:({a:e,b:t,newParams:n},i)=>Oe.create("Volume Representation",function(){var o=ie(function*(s){const a=e.data.channels[n.channel];if(!a)return Qe.UpdateResult.Unchanged;const c=t.data.repr.state.visible,u=ife(e.data,n.channel),l={...t.data.repr.props,...u.type.params};return t.data.repr.setTheme(Fo.create(i.representation.volume.themes,{volume:a.data},u)),yield t.data.repr.createOrUpdate(l,a.data).runInContext(s),t.data.repr.setState({visible:c}),t.data.sourceData=a.data,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())});function ife(e,t){const n=e.channels[t];return Af.getDefaultParamsStatic(e.plugin,"isosurface",{isoValue:n.isoValue,alpha:n.opacity,visuals:n.wireframe?["wireframe"]:["solid"]},"uniform",{value:n.color})}const ddt=eh.create({name:"built-in.animate-state-interpolation",display:{name:"Animate State (experimental)"},params:()=>({transtionDurationInMs:C.Numeric(2e3,{min:100,max:3e4,step:10})}),canApply:e=>({canApply:e.managers.snapshot.state.entries.size>1}),initialState:()=>({}),apply:(e,t,n)=>ie(function*(){const r=n.plugin.managers.snapshot.state.entries;if(r.size<2)return{kind:"finished"};const i=t.current%n.params.transtionDurationInMs/n.params.transtionDurationInMs,o=Math.floor(t.current/n.params.transtionDurationInMs)%r.size;let s=Math.ceil(t.current/n.params.transtionDurationInMs);s===o&&s++,s%=r.size;const a=r.get(o).snapshot,c=r.get(s).snapshot;if(!a.data||!c.data)return{kind:"skip"};const u=a.data.tree.transforms,l=c.data.tree.transforms,d=n.plugin.state.data,f=d.build();for(const p of u)for(const m of l){if(m.ref!==p.ref||m.version===p.version)continue;const h=ur.fromJSON(p),g=ur.fromJSON(m),y=d.cells.get(p.ref);if(!y)continue;let b;b=h.transformer.definition.interpolate?h.transformer.definition.interpolate(h.params,g.params,i,n.plugin):i<=.5?h.params:g.params,Hx(y,b)||f.to(p.ref).update(b)}return yield Cn.State.Update(n.plugin,{state:d,tree:f,options:{doNotLogTiming:!0}}),{kind:"next",state:{}}})()}),fdt=eh.create({name:"built-in.animate-structure-spin",display:{name:"Spin Structure"},isExportable:!0,params:()=>({durationInMs:C.Numeric(3e3,{min:100,max:1e4,step:100})}),initialState:()=>({t:0}),getDuration:e=>({kind:"fixed",durationMs:e.durationInMs}),setup:(e,t,n)=>ie(function*(){const r=n.state.data,i=r.select(In.Generators.ofType(pe.Molecule.Structure.Representation3D)),o=r.build();let s=!1;for(const a of i)r.select(In.Generators.ofTransformer(Ye.Representation.SpinStructureRepresentation3D,a.transform.ref)).length>0||(s=!0,o.to(a.transform.ref).apply(Ye.Representation.SpinStructureRepresentation3D,{t:0},{tags:"animate-structure-spin"}));if(s)return o.commit({doNotUpdateCurrent:!0})})(),teardown(e,t,n){const r=n.state.data,i=r.select(In.Generators.ofType(pe.Molecule.Structure.Representation3DState).withTag("animate-structure-spin"));if(0===i.length)return;const o=r.build();for(const s of i)o.delete(s.transform.ref);return o.commit()},apply:(e,t,n)=>ie(function*(){var r;const i=n.plugin.state.data,o=i.select(In.Generators.ofTransformer(Ye.Representation.SpinStructureRepresentation3D));if(0===o.length)return{kind:"finished"};const s=i.build(),c=(e.t+(t.current-t.lastApplied)/n.params.durationInMs)%1;for(const u of o)s.to(u).update({...null===(r=u.params)||void 0===r?void 0:r.values,t:c});return yield Cn.State.Update(n.plugin,{state:i,tree:s,options:{doNotLogTiming:!0}}),{kind:"next",state:{t:c}}})()}),l3=v(),ofe=v(),sfe=_r(),pdt=eh.create({name:"built-in.animate-camera-rock",display:{name:"Camera Rock",description:"Rock the 3D scene around the x-axis in view space"},isExportable:!0,params:()=>({durationInMs:C.Numeric(4e3,{min:100,max:2e4,step:100}),speed:C.Numeric(1,{min:1,max:10,step:1},{description:"How many times to rock from side to side."}),angle:C.Numeric(10,{min:0,max:180,step:1},{description:"How many degrees to rotate in each direction."})}),initialState:(e,t)=>({snapshot:t.canvas3d.camera.getSnapshot()}),getDuration:e=>({kind:"fixed",durationMs:e.durationInMs}),teardown:(e,t,n)=>{var r;null===(r=n.canvas3d)||void 0===r||r.requestCameraReset({snapshot:t.snapshot,durationMs:0})},apply:(e,t,n)=>ie(function*(){var r,i;if(0===t.current)return{kind:"next",state:e};const o=e.snapshot;if(o.radiusMax<1e-4)return{kind:"finished"};const s=t.animation?(null===(r=t.animation)||void 0===r?void 0:r.currentFrame)/(t.animation.frameCount+1):os(t.current/n.params.durationInMs,0,1),a=Math.sin(s*n.params.speed*Math.PI*2)*Yn(n.params.angle);v.sub(l3,o.position,o.target),v.normalize(ofe,o.up),_r.setAxisAngle(sfe,ofe,a),v.transformQuat(l3,l3,sfe);const c=v.add(v(),o.target,l3);return null===(i=n.plugin.canvas3d)||void 0===i||i.requestCameraReset({snapshot:{...o,position:c},durationMs:0}),s>=.99999?{kind:"finished"}:{kind:"next",state:e}})()});var an,d3;function ch(...e){const t=xb(e),n=yK(e,1/0),r=e;return r.length?1===r.length?ru(r[0]):xg(n)($i(r,t)):$l}function afe(e,t=o3){return mo((n,r)=>{let i=null,o=null,s=null;const a=()=>{if(i){i.unsubscribe(),i=null;const u=o;o=null,r.next(u)}};function c(){const u=s+e,l=t.now();if(l{o=u,s=t.now(),i||(i=t.schedule(c,e),r.add(i))},()=>{a(),r.complete()},void 0,()=>{o=i=null}))})}!function(e){e.Action=function t(r,i){return{action:r,customControl:i&&i.customControl,autoUpdate:i&&i.autoUpdate}},e.Behavior=function n(r,i={}){return{transformer:r,defaultParams:i}}}(an||(an={})),function(e){e.Registry=class t{constructor(){this.providers=ol().asMutable(),this.defaultAutoAttachValues=new Map}getParams(r){const i={},o=[],s=[];if(r){const a=this.providers.values();for(;;){const c=a.next();if(c.done)break;const u=c.value;u.isApplicable(r)&&(u.isHidden||(o.push([u.descriptor.name,u.label]),this.defaultAutoAttachValues.get(u.descriptor.name)&&s.push(u.descriptor.name)),i[u.descriptor.name]=C.Group({...u.getParams(r)},{label:u.label,isHidden:u.isHidden}))}}return{autoAttach:C.MultiSelect(s,o),properties:C.Group(i,{isFlat:!0})}}setDefaultAutoAttach(r,i){this.defaultAutoAttachValues.set(r,i)}get(r){if(!this.providers.get(r))throw new Error(`Custom property '${r}' is not registered.`);return this.providers.get(r)}register(r,i){this.providers.set(r.descriptor.name,r),this.defaultAutoAttachValues.set(r.descriptor.name,i)}unregister(r){this.providers.delete(r),this.defaultAutoAttachValues.delete(r)}}}(d3||(d3={}));class mdt{get dataState(){return this.plugin.state.data}rawData(t,n){return this.dataState.build().toRoot().apply(cre,t,n).commit({revertOnError:!0})}download(t,n){return this.dataState.build().toRoot().apply(sre,t,n).commit({revertOnError:!0})}downloadBlob(t,n){return this.dataState.build().toRoot().apply(are,t,n).commit({revertOnError:!0})}readFile(t,n){var r=this;return ie(function*(){var i,o,s;return{data:yield r.dataState.build().toRoot().apply(ure,t,n).commit({revertOnError:!0}),fileInfo:i1(null!==(s=null===(o=null===(i=t.file)||void 0===i?void 0:i.file)||void 0===o?void 0:o.name)&&void 0!==s?s:"")}})()}constructor(t){this.plugin=t}}class gdt{get dataState(){return this.plugin.state.data}resolveProvider(t){var n;return"string"==typeof t?null!==(n=Mf[t])&&void 0!==n?n:uB(this._providers,r=>r.id===t):t}hasPreset(t){for(const n of this._providers)if(!n.isApplicable||n.isApplicable(t,this.plugin))return!0;return!1}get providers(){return this._providers}getPresets(t){if(!t)return this.providers;const n=[];for(const r of this._providers)r.isApplicable&&!r.isApplicable(t,this.plugin)||n.push(r);return n}getPresetSelect(t){const n=[];for(const r of this._providers)t&&r.isApplicable&&!r.isApplicable(t,this.plugin)||n.push([r.id,r.display.name,r.display.group]);return C.Select("auto",n)}getPresetsWithOptions(t){const n=[],r=Object.create(null);for(const i of this._providers)i.isApplicable&&!i.isApplicable(t,this.plugin)||(n.push([i.id,i.display.name]),r[i.id]=i.params?C.Group(i.params(t,this.plugin)):C.EmptyGroup());return 0===n.length?C.MappedStatic("",{"":C.EmptyGroup()}):C.MappedStatic(n[0][0],r,{options:n})}registerPreset(t){if(this.providerMap.has(t.id))throw new Error(`Representation provider with id '${t.id}' already registered.`);this._providers.push(t),this.providerMap.set(t.id,t)}unregisterPreset(t){this.providerMap.delete(t.id),Xx(this._providers,t)}applyPreset(t,n,r){var i;const o=this.resolveProvider(n);if(!o)return;const a=ls.resolveAndCheck(this.plugin.state.data,t);if(!a)return void(Qx||console.warn("Applying structure repr. provider to bad cell."));const c=(null===(i=o.params)||void 0===i?void 0:i.call(o,a.obj,this.plugin))||{};let u=r||(o.params?C.getDefaultValues(c):{});const l=this.plugin.config.get(qi.Structure.DefaultRepresentationPresetParams);u=C.merge(c,l,u);const d=Oe.create(`${o.display.name}`,()=>o.apply(a,u,this.plugin));return this.plugin.runTask(d)}addRepresentation(t,n,r){var i=this;return ie(function*(){const o=i.dataState.build(),s=i.buildRepresentation(o,t,n,r);if(s)return yield o.commit(),s})()}buildRepresentation(t,n,r,i){var o,s;if(!n)return;const a=null===(s=null===(o=ls.resolveAndCheck(this.dataState,n))||void 0===o?void 0:o.obj)||void 0===s?void 0:s.data;if(!a)return;const c=e3(this.plugin,a,r);return i?.tag?t.to(n).applyOrUpdateTagged(i.tag,vE,c,{state:i?.initialState}).selector:t.to(n).apply(vE,c,{state:i?.initialState}).selector}constructor(t){this.plugin=t,this._providers=[],this.providerMap=new Map,this.defaultProvider=Mf.auto,$a(Mf,n=>this.registerPreset(n))}}function Om(e){return e}!function(e){e.CommonParams=(t,n)=>({modelProperties:C.Optional(C.Group(Qe.getParamDefinition(Ye.Model.CustomModelProperties,void 0,n))),structureProperties:C.Optional(C.Group(Qe.getParamDefinition(Ye.Model.CustomStructureProperties,void 0,n))),representationPreset:C.Optional(C.Text("auto"))})}(Om||(Om={}));const f3=Om.CommonParams,cfe=Om({id:"preset-trajectory-default",display:{name:"Default (Assembly)",group:"Preset",description:"Shows the first assembly or, if that is unavailable, the first model."},isApplicable:e=>!0,params:(e,t)=>({model:C.Optional(C.Group(Qe.getParamDefinition(Ye.Model.ModelFromTrajectory,e,t))),showUnitcell:C.Optional(C.Boolean(!1)),structure:C.Optional(b0.getParams(void 0,"assembly").type),representationPresetParams:C.Optional(C.Group(oa.CommonParams)),...f3(e,t)}),apply:(e,t,n)=>ie(function*(){const r=n.builders.structure,i=yield r.createModel(e,t.model),o=yield r.insertModelProperties(i,t.modelProperties),s=yield r.createStructure(o||i,t.structure),a=yield r.insertStructureProperties(s,t.structureProperties),c=void 0===t.showUnitcell||t.showUnitcell?yield r.tryCreateUnitcell(o,void 0,{isHidden:!0}):void 0,u=t.representationPreset||n.config.get(qi.Structure.DefaultRepresentationPreset)||Mf.auto.id;return{model:i,modelProperties:o,unitcell:c,structure:s,structureProperties:a,representation:yield n.builders.structure.representation.applyPreset(a,u,t.representationPresetParams)}})()}),ydt=Om({id:"preset-trajectory-all-models",display:{name:"All Models",group:"Preset",description:"Shows all models; colored by trajectory-index."},isApplicable:e=>e.data.frameCount>1,params:(e,t)=>({useDefaultIfSingleModel:C.Optional(C.Boolean(!1)),representationPresetParams:C.Optional(C.Group(oa.CommonParams)),...f3(e,t)}),apply:(e,t,n)=>ie(function*(){var r,i;const o=null===(i=null===(r=ls.resolveAndCheck(n.state.data,e))||void 0===r?void 0:r.obj)||void 0===i?void 0:i.data;if(!o)return{};if(1===o.frameCount&&t.useDefaultIfSingleModel)return cfe.apply(e,t,n);const s=n.builders.structure,a=[],c=[];for(let u=0;u({model:C.Optional(C.Group(Qe.getParamDefinition(Ye.Model.ModelFromTrajectory,e,t))),...f3(e,t)});function lfe(e,t,n,r){return lV.apply(this,arguments)}function lV(){return lV=ie(function*(e,t,n,r){const i=r.builders.structure,o=yield i.createModel(t,n.model),s=yield i.insertModelProperties(o,n.modelProperties),a=yield i.createStructure(s||o,{name:"symmetry",params:e}),c=yield i.insertStructureProperties(a,n.structureProperties),u=yield i.tryCreateUnitcell(s,void 0,{isHidden:!1}),l=n.representationPreset||r.config.get(qi.Structure.DefaultRepresentationPreset)||Mf.auto.id;return{model:o,modelProperties:s,unitcell:u,structure:a,structureProperties:c,representation:yield r.builders.structure.representation.applyPreset(c,l,{theme:{globalName:e.theme}})}}),lV.apply(this,arguments)}const bdt=Om({id:"preset-trajectory-unitcell",display:{name:"Unit Cell",group:"Preset",description:"Shows the fully populated unit cell."},isApplicable:e=>sn.hasCrystalSymmetry(e.data.representative),params:ufe,apply:(e,t,n)=>ie(function*(){return yield lfe({ijkMin:v.create(0,0,0),ijkMax:v.create(0,0,0)},e,t,n)})()}),vdt=Om({id:"preset-trajectory-supercell",display:{name:"Super Cell",group:"Preset",description:"Shows the super cell, i.e. the central unit cell and all adjacent unit cells."},isApplicable:e=>sn.hasCrystalSymmetry(e.data.representative),params:ufe,apply:(e,t,n)=>ie(function*(){return yield lfe({ijkMin:v.create(-1,-1,-1),ijkMax:v.create(1,1,1),theme:"operator-hkl"},e,t,n)})()}),_dt=Om({id:"preset-trajectory-crystal-contacts",display:{name:"Crystal Contacts",group:"Preset",description:"Showsasymetric unit and chains from neighbours within 5 \u212b, i.e., symmetry mates."},isApplicable:e=>sn.hasCrystalSymmetry(e.data.representative),params:(e,t)=>({model:C.Optional(C.Group(Qe.getParamDefinition(Ye.Model.ModelFromTrajectory,e,t))),...f3(e,t)}),apply:(e,t,n)=>ie(function*(){const r=n.builders.structure,i=yield r.createModel(e,t.model),o=yield r.insertModelProperties(i,t.modelProperties),s=yield r.createStructure(o||i,{name:"symmetry-mates",params:{radius:5}}),a=yield r.insertStructureProperties(s,t.structureProperties),c=yield r.tryCreateUnitcell(o,void 0,{isHidden:!0}),u=t.representationPreset||n.config.get(qi.Structure.DefaultRepresentationPreset)||Mf.auto.id;return{model:i,modelProperties:o,unitcell:c,structure:s,structureProperties:a,representation:yield n.builders.structure.representation.applyPreset(a,u,{theme:{globalName:"operator-name",carbonColor:"operator-name",focus:{name:"element-symbol",params:{carbonColor:{name:"operator-name",params:F6.defaultValues}}}}})}})()}),dV={default:cfe,"all-models":ydt,unitcell:bdt,supercell:vdt,crystalContacts:_dt};class xdt{resolveProvider(t){var n;return"string"==typeof t?null!==(n=dV[t])&&void 0!==n?n:uB(this._providers,r=>r.id===t):t}hasPreset(t){for(const n of this._providers)if(!n.isApplicable||n.isApplicable(t,this.plugin))return!0;return!1}get providers(){return this._providers}getPresets(t){if(!t)return this.providers;const n=[];for(const r of this._providers)r.isApplicable&&!r.isApplicable(t,this.plugin)||n.push(r);return n}getPresetSelect(t){const n=[];for(const r of this._providers)t&&r.isApplicable&&!r.isApplicable(t,this.plugin)||n.push([r.id,r.display.name]);return C.Select("auto",n)}getPresetsWithOptions(t){const n=[],r=Object.create(null);for(const i of this._providers)i.isApplicable&&!i.isApplicable(t,this.plugin)||(n.push([i.id,i.display.name]),r[i.id]=i.params?C.Group(i.params(t,this.plugin)):C.EmptyGroup());return 0===n.length?C.MappedStatic("",{"":C.EmptyGroup()}):C.MappedStatic(n[0][0],r,{options:n})}registerPreset(t){if(this.providerMap.has(t.id))throw new Error(`Hierarchy provider with id '${t.id}' already registered.`);this._providers.push(t),this.providerMap.set(t.id,t)}unregisterPreset(t){this.providerMap.delete(t.id),Xx(this._providers,t)}applyPreset(t,n,r){const i=this.resolveProvider(n);if(!i)return;const s=ls.resolveAndCheck(this.plugin.state.data,t);if(!s)return void(Qx||console.warn("Applying hierarchy preset provider to bad cell."));const a=r||(i.params?C.getDefaultValues(i.params(s.obj,this.plugin)):{}),c=Oe.create(`${i.display.name}`,()=>i.apply(s,a,this.plugin));return this.plugin.runTask(c)}constructor(t){this.plugin=t,this._providers=[],this.providerMap=new Map,this.defaultProvider=dV.default,$a(dV,n=>this.registerPreset(n))}}class Sdt{get dataState(){return this.plugin.state.data}parseTrajectoryData(t,n){var r=this;return ie(function*(){const i="string"==typeof n?r.plugin.dataFormats.get(n):n;if(!i)throw new Error(`'${n}' is not a supported data format.`);const{trajectory:o}=yield i.parse(r.plugin,t);return o})()}parseTrajectoryBlob(t,n){return this.dataState.build().to(t).apply(Ye.Data.ParseBlob,n,{state:{isGhost:!0}}).apply(Ye.Model.TrajectoryFromBlob,void 0).commit({revertOnError:!0})}parseTrajectory(t,n){const r=ls.resolveAndCheck(this.dataState,t);if(!r)throw new Error("Invalid data cell.");return pe.Data.Blob.is(r.obj)?this.parseTrajectoryBlob(t,n):this.parseTrajectoryData(t,n)}createModel(t,n,r){return this.dataState.build().to(t).apply(Ye.Model.ModelFromTrajectory,n||{modelIndex:0},{state:r}).commit({revertOnError:!0})}insertModelProperties(t,n,r){return this.dataState.build().to(t).apply(Ye.Model.CustomModelProperties,n,{state:r}).commit({revertOnError:!0})}tryCreateUnitcell(t,n,r){var i,o,s;const a=this.dataState,c=null===(o=null===(i=ls.resolveAndCheck(a,t))||void 0===i?void 0:i.obj)||void 0===o?void 0:o.data;if(!c)return;const u=null===(s=no.Provider.get(c))||void 0===s?void 0:s.spacegroup.cell;return ma.isZero(u)?void 0:a.build().to(t).apply(Ye.Representation.ModelUnitcell3D,n,{state:r}).commit({revertOnError:!0})}createStructure(t,n,r,i){var o;const s=this.dataState;if(!n){const c=ls.resolveAndCheck(s,t);if(c){const u=no.Provider.get(null===(o=c.obj)||void 0===o?void 0:o.data);(!u||0===u?.assemblies.length)&&(n={name:"model",params:{}})}}return s.build().to(t).apply(Ye.Model.StructureFromModel,{type:n||{name:"assembly",params:{}}},{state:r,tags:i}).commit({revertOnError:!0})}insertStructureProperties(t,n){return this.dataState.build().to(t).apply(Ye.Model.CustomStructureProperties,n).commit({revertOnError:!0})}isComponentTransform(t){return t.transform.transformer===Ye.Model.StructureComponent}tryCreateComponent(t,n,r,i){var o=this;return ie(function*(){var s,a;const c=o.dataState,u=c.build().to(t),l=`structure-component-${r}`,d=u.applyOrUpdateTagged(l,Ye.Model.StructureComponent,n,{tags:i?[...i,l]:[l]});yield d.commit();const f=d.selector;if(f.isOk&&0!==(null===(a=null===(s=f.cell)||void 0===s?void 0:s.obj)||void 0===a?void 0:a.data.elementCount))return f;yield c.build().delete(f.ref).commit()})()}tryCreateComponentFromExpression(t,n,r,i){return this.tryCreateComponent(t,{type:{name:"expression",params:n},nullIfEmpty:!0,label:(i?.label||"").trim()},r,i?.tags)}tryCreateComponentStatic(t,n,r){return this.tryCreateComponent(t,{type:{name:"static",params:n},nullIfEmpty:!0,label:(r?.label||"").trim()},`static-${n}`,r?.tags)}tryCreateComponentFromSelection(t,n,r,i){var o=this;return this.plugin.runTask(Oe.create("Query Component",function(){var s=ie(function*(a){var c,u;let{label:l,tags:d}=i||{};l=(l||"").trim();const f=null===(u=null===(c=ls.resolveAndCheck(o.dataState,t))||void 0===c?void 0:c.obj)||void 0===u?void 0:u.data;if(!f)return;const p=n.referencesCurrent?{type:{name:"bundle",params:Kn.fromSelection(yield n.getSelection(o.plugin,a,f))},nullIfEmpty:!0,label:l||n.label}:{type:{name:"expression",params:n.expression},nullIfEmpty:!0,label:l||n.label};return n.ensureCustomProperties&&(yield n.ensureCustomProperties({runtime:a,assetManager:o.plugin.managers.asset},f)),o.tryCreateComponent(t,p,r,d)});return function(a){return s.apply(this,arguments)}}()))}constructor(t){this.plugin=t,this.hierarchy=new xdt(this.plugin),this.representation=new gdt(this.plugin)}}function bC(e,t,n={}){return"string"==typeof n.type||"string"==typeof n.color||"string"==typeof n.size?function Cdt(e,t,n){const r=n.type&&e.representation.volume.registry.get(n.type)||e.representation.volume.registry.default.provider,i=n.color&&e.representation.volume.themes.colorThemeRegistry.get(n.color)||e.representation.volume.themes.colorThemeRegistry.get(r.defaultColorTheme.name),o=n.size&&e.representation.volume.themes.sizeThemeRegistry.get(n.size)||e.representation.volume.themes.sizeThemeRegistry.get(r.defaultSizeTheme.name);return dfe(e,t,{type:r,typeParams:n.typeParams,color:i,colorParams:n.colorParams,size:o,sizeParams:n.sizeParams})}(e,t||et.One,n):dfe(e,t||et.One,n)}function dfe(e,t,n={}){const{themes:r}=e.representation.volume,i={volume:t},o=n.type||e.representation.volume.registry.default.provider,s=C.getDefaultValues(o.getParams(r,t)),a=Object.assign(s,n.typeParams),c=n.color||r.colorThemeRegistry.get(o.defaultColorTheme.name),u=C.getDefaultValues(c.getParams(i));c.name===o.defaultColorTheme.name&&Object.assign(u,o.defaultColorTheme.props);const l=Object.assign(u,n.colorParams),d=n.size||r.sizeThemeRegistry.get(o.defaultSizeTheme.name),f=C.getDefaultValues(d.getParams(i));d.name===o.defaultSizeTheme.name&&Object.assign(f,o.defaultSizeTheme.props);const p=Object.assign(f,n.sizeParams);return{type:{name:o.name,params:a},colorTheme:{name:c.name,params:l},sizeTheme:{name:d.name,params:p}}}var fV,p3;!function(e){e.create=function t(n){const{name:r}=n;return{descriptor:n,get:i=>i._propertyData[r],set(i,o){i.customProperties.add(n),i._propertyData[r]=o}}}}(fV||(fV={})),function(e){e.Descriptor={name:"recommended_iso_value"},e.Provider=fV.create(e.Descriptor)}(p3||(p3={}));const u1="Volume";function vC(e,t){return pV.apply(this,arguments)}function pV(){return pV=ie(function*(e,t){if(!t)return;const{entryId:n}=t;return n&&n.toLowerCase().startsWith("emd")?e.runTask(Oe.create("Try Set Recommended IsoValue",function(){var r=ie(function*(i){try{const o=yield kde(e,i,n);p3.Provider.set(t,et.IsoValue.absolute(o))}catch(o){console.warn(o)}});return function(i){return r.apply(this,arguments)}}())):void 0}),pV.apply(this,arguments)}function ffe(e){const t=p3.Provider.get(e);if(t)return"relative"===t.kind?t:et.adjustedIsoValue(e,t.absoluteValue,"absolute")}function hV(e,t){return mV.apply(this,arguments)}function mV(){return mV=ie(function*(e,t){const n={},r=t.volume.data&&ffe(t.volume.data);return r&&(n.isoValue=r),[yield e.build().to(t.volume).apply(Ye.Representation.VolumeRepresentation3D,bC(e,t.volume.data,{type:"isosurface",typeParams:n})).commit()]}),mV.apply(this,arguments)}const wdt={label:"CCP4/MRC/MAP",description:"CCP4/MRC/MAP",category:u1,binaryExtensions:["ccp4","mrc","map"],parse:function(){var e=ie(function*(t,n,r){const i=t.build().to(n).apply(Ye.Data.ParseCcp4,{},{state:{isGhost:!0}}),o=i.apply(Ye.Volume.VolumeFromCcp4,{entryId:r?.entryId});return yield i.commit({revertOnError:!0}),yield vC(t,o.selector.data),{format:i.selector,volume:o.selector}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:hV},Adt={label:"DSN6/BRIX",description:"DSN6/BRIX",category:u1,binaryExtensions:["dsn6","brix"],parse:function(){var e=ie(function*(t,n,r){const i=t.build().to(n).apply(Ye.Data.ParseDsn6,{},{state:{isGhost:!0}}),o=i.apply(Ye.Volume.VolumeFromDsn6,{entryId:r?.entryId});return yield i.commit({revertOnError:!0}),yield vC(t,o.selector.data),{format:i.selector,volume:o.selector}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:hV},Idt={label:"DX",description:"DX",category:u1,stringExtensions:["dx"],binaryExtensions:["dxbin"],parse:function(){var e=ie(function*(t,n,r){const o=t.build().to(n).apply(Ye.Data.ParseDx,{},{state:{isGhost:!0}}).apply(Ye.Volume.VolumeFromDx,{entryId:r?.entryId});return yield o.commit({revertOnError:!0}),yield vC(t,o.selector.data),{volume:o.selector}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:hV},Tdt={label:"Cube",description:"Cube",category:u1,stringExtensions:["cub","cube"],parse:function(){var e=ie(function*(t,n,r){const i=t.build().to(n).apply(Ye.Data.ParseCube,{},{state:{isGhost:!0}}),o=i.apply(Ye.Volume.VolumeFromCube,{entryId:r?.entryId}),s=i.apply(Ye.Model.TrajectoryFromCube,void 0,{state:{isGhost:!0}}).apply(Ye.Model.ModelFromTrajectory).apply(Ye.Model.StructureFromModel);return yield i.commit({revertOnError:!0}),yield vC(t,o.selector.data),{format:i.selector,volume:o.selector,structure:s.selector}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:function(){var e=ie(function*(t,n){var r,i;const o=t.build(),s=[],a=null===(i=null===(r=n.volume.cell)||void 0===r?void 0:r.obj)||void 0===i?void 0:i.data;if(a&&et.isOrbitals(a)){const l=o.to(n.volume).apply(Ye.Representation.VolumeRepresentation3D,bC(t,a,{type:"isosurface",typeParams:{isoValue:et.IsoValue.relative(1),alpha:.4},color:"uniform",colorParams:{value:xn.blue}})),d=o.to(n.volume).apply(Ye.Representation.VolumeRepresentation3D,bC(t,a,{type:"isosurface",typeParams:{isoValue:et.IsoValue.relative(-1),alpha:.4},color:"uniform",colorParams:{value:xn.red}}));s.push(l.selector,d.selector)}else{const l=o.to(n.volume).apply(Ye.Representation.VolumeRepresentation3D,bC(t,a,{type:"isosurface",typeParams:{isoValue:et.IsoValue.relative(2),alpha:.4},color:"uniform",colorParams:{value:xn.grey}}));s.push(l.selector)}const c=yield t.builders.structure.representation.applyPreset(n.structure,"auto");yield o.commit();const u=[];return $a(c?.representations,l=>{l&&u.push(l)}),[...s,...u]});return function(n,r){return e.apply(this,arguments)}}()},Ddt={label:"DensityServer CIF",description:"DensityServer CIF",category:u1,stringExtensions:["cif"],binaryExtensions:["bcif"],isApplicable:(e,t)=>"dscif"===n3(e,t),parse:function(){var e=ie(function*(t,n,r){var i;const o=yield t.build().to(n).apply(Ye.Data.ParseCif).commit(),s=t.build().to(o),a=o.obj.data.blocks;if(0===a.length)throw new Error("no data blocks");const c=[];let u=0;for(const l of a){if("SERVER"===l.header.toUpperCase())continue;const d=Array.isArray(r?.entryId)?r?.entryId[u]:r?.entryId;(null===(i=l.categories.volume_data_3d_info)||void 0===i?void 0:i.rowCount)>0&&(c.push(s.apply(Ye.Volume.VolumeFromDensityServerCif,{blockHeader:l.header,entryId:d}).selector),u++)}yield s.commit();for(const l of c)yield vC(t,l.data);return{volumes:c}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:function(){var e=ie(function*(t,n){const{volumes:r}=n,i=t.build(),o=[];if(r.length>0){const s=r[0].data&&ffe(r[0].data)||et.IsoValue.relative(1.5);o[0]=i.to(r[0]).apply(Ye.Representation.VolumeRepresentation3D,Af.getDefaultParamsStatic(t,"isosurface",{isoValue:s,alpha:1},"uniform",{value:xn.teal})).selector}if(r.length>1){const s=Af.getDefaultParamsStatic(t,"isosurface",{isoValue:et.IsoValue.relative(3),alpha:.3},"uniform",{value:xn.green}),a=Af.getDefaultParamsStatic(t,"isosurface",{isoValue:et.IsoValue.relative(-3),alpha:.3},"uniform",{value:xn.red});o[o.length]=i.to(r[1]).apply(Ye.Representation.VolumeRepresentation3D,s).selector,o[o.length]=i.to(r[1]).apply(Ye.Representation.VolumeRepresentation3D,a).selector}return yield i.commit(),o});return function(n,r){return e.apply(this,arguments)}}()},Edt={label:"Segmentation CIF",description:"Segmentation CIF",category:u1,stringExtensions:["cif"],binaryExtensions:["bcif"],isApplicable:(e,t)=>"segcif"===n3(e,t),parse:function(){var e=ie(function*(t,n){var r;const i=yield t.build().to(n).apply(Ye.Data.ParseCif).commit(),o=t.build().to(i),s=i.obj.data.blocks;if(0===s.length)throw new Error("no data blocks");const a=[];for(const c of s)"SERVER"!==c.header.toUpperCase()&&(null===(r=c.categories.volume_data_3d_info)||void 0===r?void 0:r.rowCount)>0&&a.push(o.apply(Ye.Volume.VolumeFromSegmentationCif,{blockHeader:c.header}).selector);return yield o.commit(),{volumes:a}});return function(n,r){return e.apply(this,arguments)}}(),visuals:function(){var e=ie(function*(t,n){const{volumes:r}=n,i=t.build(),o=[];return r.length>0&&et.Segmentation.get(r[0].data)&&(o[o.length]=i.to(r[0]).apply(Ye.Representation.VolumeRepresentation3D,Af.getDefaultParams(t,"segment",r[0].data,{alpha:1,instanceGranularity:!0},"volume-segment",{})).selector),yield i.commit(),o});return function(n,r){return e.apply(this,arguments)}}()},Pdt=[["ccp4",wdt],["dsn6",Adt],["cube",Tdt],["dx",Idt],["dscif",Ddt],["segcif",Edt]],Mdt=[["ply",{label:"PLY",description:"PLY",category:"Shape",stringExtensions:["ply"],parse:function(){var e=ie(function*(t,n){const r=t.state.data.build().to(n).apply(Ye.Data.ParsePly,{},{state:{isGhost:!0}}),i=r.apply(Ye.Model.ShapeFromPly);return yield r.commit(),{format:r.selector,shape:i.selector}});return function(n,r){return e.apply(this,arguments)}}(),visuals:(e,t)=>e.state.data.build().to(t.shape).apply(Ye.Representation.ShapeRepresentation3D).commit()}]];class Rdt{get types(){return this._list.map(t=>[t.name,t.provider.label])}get extensions(){if(this._extensions)return this._extensions;const t=new Set;return this._list.forEach(({provider:n})=>{var r,i;null===(r=n.stringExtensions)||void 0===r||r.forEach(o=>t.add(o)),null===(i=n.binaryExtensions)||void 0===i||i.forEach(o=>t.add(o))}),this._extensions=t,t}get binaryExtensions(){if(this._binaryExtensions)return this._binaryExtensions;const t=new Set;return this._list.forEach(({provider:n})=>{var r;return null===(r=n.binaryExtensions)||void 0===r?void 0:r.forEach(i=>t.add(i))}),this._binaryExtensions=t,t}get options(){if(this._options)return this._options;const t=[];return this._list.forEach(({name:n,provider:r})=>t.push([n,r.label,r.category||""])),this._options=t,t}constructor(){this._list=[],this._map=new Map,this._extensions=void 0,this._binaryExtensions=void 0,this._options=void 0;for(const[t,n]of Pdt)this.add(t,n);for(const[t,n]of nut)this.add(t,n);for(const[t,n]of aut)this.add(t,n);for(const[t,n]of Mdt)this.add(t,n);for(const[t,n]of Tde)this.add(t,n)}_clear(){this._extensions=void 0,this._binaryExtensions=void 0,this._options=void 0}add(t,n){this._clear(),this._list.push({name:t,provider:n}),this._map.set(t,n)}remove(t){this._clear(),this._list.splice(this._list.findIndex(n=>n.name===t),1),this._map.delete(t)}auto(t,n){var r,i;for(let o=0,s=this.list.length;o[t.name,t.display.name]),{label:"Animation"})}),this._params}updateParams(t){if(this.isEmpty)return;this.updateState({params:{...this.state.params,...t}});const n=this.map.get(this.state.params.current),r=n.params(this.context);this._current={anim:n,params:r,paramValues:C.getDefaultValues(r),state:{},startedTime:-1,lastTime:0},this.triggerUpdate()}updateCurrentParams(t){this.isEmpty||(this._current.paramValues={...this._current.paramValues,...t},this.triggerUpdate())}register(t){this.map.has(t.name)?this.context.log.error(`Animation '${t.name}' is already registered.`):(this._params=void 0,this.map.set(t.name,t),this._animations.push(t),1===this._animations.length?this.updateParams({current:t.name}):this.triggerUpdate())}play(t,n){var r=this;return ie(function*(){yield r.stop(),r.map.has(t.name)||r.register(t),r.updateParams({current:t.name}),r.updateCurrentParams(n),yield r.start()})()}tick(t,n,r){var i=this;return ie(function*(){i.currentTime=t,!i.isStopped&&(n||r?yield i.applyFrame(r):i.applyAsync())})()}start(){var t=this;return ie(function*(){t.updateState({animationState:"playing"}),t.context.behaviors.state.isAnimating.value||t.context.behaviors.state.isAnimating.next(!0),t.triggerUpdate();const n=t._current.anim;let r=t._current.anim.initialState(t._current.paramValues,t.context);if(n.setup){const i=yield n.setup(t._current.paramValues,r,t.context);i&&(r=i)}t._current.lastTime=0,t._current.startedTime=-1,t._current.state=r,t.isStopped=!1})()}stop(){var t=this;return ie(function*(){if(t.isStopped=!0,"stopped"!==t.state.animationState){const n=t._current.anim;n.teardown&&(yield n.teardown(t._current.paramValues,t._current.state,t.context)),t.updateState({animationState:"stopped"}),t.triggerUpdate()}t.context.behaviors.state.isAnimating.value&&t.context.behaviors.state.isAnimating.next(!1)})()}get isAnimating(){return"playing"===this.state.animationState}applyAsync(){var t=this;return ie(function*(){if(!t.isApplying){t.isApplying=!0;try{yield t.applyFrame()}finally{t.isApplying=!1}}})()}applyFrame(t){var n=this;return ie(function*(){const r=n.currentTime;n._current.startedTime<0&&(n._current.startedTime=r);const i=yield n._current.anim.apply(n._current.state,{lastApplied:n._current.lastTime,current:r-n._current.startedTime,animation:t},{params:n._current.paramValues,plugin:n.context});"finished"===i.kind?n.stop():"next"===i.kind&&(n._current.state=i.state,n._current.lastTime=r-n._current.startedTime),n.triggerApply()})()}getSnapshot(){return this.current?{state:this.state,current:{paramValues:this._current.paramValues,state:this._current.anim.stateSerialization?this._current.anim.stateSerialization.toJSON(this._current.state):this._current.state}}:{state:this.state}}setSnapshot(t){this.isEmpty||(this.updateState({animationState:t.state.animationState}),this.updateParams(t.state.params),t.current&&(this.current.paramValues=t.current.paramValues,this.current.state=this._current.anim.stateSerialization?this._current.anim.stateSerialization.fromJSON(t.current.state):t.current.state,this.triggerUpdate(),"playing"===this.state.animationState&&this.resume()))}resume(){var t=this;return ie(function*(){t._current.lastTime=0,t._current.startedTime=-1;const n=t._current.anim;t.context.behaviors.state.isAnimating.value||t.context.behaviors.state.isAnimating.next(!0),n.setup&&(yield n.setup(t._current.paramValues,t._current.state,t.context)),t.isStopped=!1})()}constructor(t){super({params:{current:""},animationState:"stopped"}),this.context=t,this.map=new Map,this._animations=[],this.currentTime=0,this._params=void 0,this.events={updated:this.ev(),applied:this.ev()},this.isStopped=!0,this.isApplying=!1}}function pfe(e,t,n){const r=n[0],i=n[1],o=n[2];return(r*e[0]+i*e[1]+o*e[2]+(-r*t[0]-i*t[1]-o*t[2]))/Math.sqrt(r*r+i*i+o*o)}const Rf={identity:Kt.create(1,0,0,0,1,0,0,0,1),rotX90:Kt.create(1,0,0,0,0,1,0,-1,0),rotY90:Kt.create(0,0,-1,0,1,0,1,0,0),rotZ90:Kt.create(0,1,0,-1,0,0,0,0,1),rotX270:Kt.create(1,0,0,0,0,-1,0,1,0),rotY270:Kt.create(0,0,1,0,1,0,-1,0,0),rotZ270:Kt.create(0,-1,0,1,0,0,0,0,1),rotX180:Kt.create(1,0,0,0,-1,0,0,0,-1),rotY180:Kt.create(-1,0,0,0,1,0,0,0,-1),rotZ180:Kt.create(-1,0,0,0,-1,0,0,0,1)};function gV(e,t){const{onlyTrace:n,skipHydrogens:r,skipWater:i}=t,{x:o,y:s,z:a,type_symbol:c,label_comp_id:u}=Ze.atom,l=[];for(const d of e){const f=nt.create(d);for(const p of d.units){f.unit=p;const m=n?p.polymerElements:p.elements;for(let h=0;hi,n)}focusLoci(t,n){let r;if(Array.isArray(t)&&t.length>1){const i=[];for(const o of t){const s=pn.getBoundingSphere(this.transformedLoci(o));s&&i.push(s)}if(0===i.length)return;this.boundaryHelper.reset();for(const o of i)this.boundaryHelper.includeSphere(o);this.boundaryHelper.finishedIncludeStep();for(const o of i)this.boundaryHelper.radiusSphere(o);r=this.boundaryHelper.getSphere()}else if(Array.isArray(t)){if(0===t.length)return;r=pn.getBoundingSphere(this.transformedLoci(t[0]))}else r=pn.getBoundingSphere(this.transformedLoci(t));r&&this.focusSphere(r,n)}focusSpheres(t,n,r){const i=[];for(const o of t){const s=n(o);s&&i.push(s)}if(0!==i.length){if(1===i.length)return this.focusSphere(i[0],r);this.boundaryHelper.reset();for(const o of i)this.boundaryHelper.includeSphere(o);this.boundaryHelper.finishedIncludeStep();for(const o of i)this.boundaryHelper.radiusSphere(o);this.focusSphere(this.boundaryHelper.getSphere(),r)}}focusSphere(t,n){var r;const{canvas3d:i}=this.plugin;if(!i)return;const{extraRadius:o,minRadius:s,durationMs:a}={...$dt,...n},c=Math.max(t.radius+o,s);if(n?.principalAxes){const u=function Odt(e,t,n){if(!e.canvas3d)return;const{origin:r,dirA:i,dirB:o,dirC:s}=n.principalAxes.boxAxes,a=v.clone(i),c=v.clone(s);if(n.positionToFlip){const{aroundX:l,aroundY:d}=function Fdt(e,t,n,r){const i=pfe(e,t,r);return{aroundX:pfe(e,t,n)<0,aroundY:i<0}}(n.positionToFlip,r,a,o);l&&(v.negate(c,c),v.negate(a,a)),d&&v.negate(c,c)}const u=v.scale(v(),r,-100);return v.dot(u,a)<=0&&v.negate(c,c),v.dot(v.unitY,c)<=0&&v.negate(a,a),e.canvas3d.camera.getFocus(r,t,a,c,gr.createDefaultSnapshot())}(this.plugin,c,n);null===(r=this.plugin.canvas3d)||void 0===r||r.requestCameraReset({durationMs:a,snapshot:u})}else{const u=i.camera.getFocus(t.center,c);i.requestCameraReset({durationMs:a,snapshot:u})}}orientAxes(t,n){if(!this.plugin.canvas3d)return;t||(t=this.plugin.state.data.selectQ(a=>a.ofType(pe.Molecule.Structure)).filter(a=>a.obj&&!a.transform.transformer.definition.isDecorator&&!a.obj.data.parent).map(a=>{var c;return null===(c=a.obj)||void 0===c?void 0:c.data}).filter(a=>!!a));const{rotation:r}=function Udt(e,t){const n=function zdt(e,t){let n;return n=gV(e,{onlyTrace:!0}),n.length>=3*t||(n=gV(e,{skipHydrogens:!0,skipWater:!0}),n.length>=3*t)||(n=gV(e,{})),n}(e,3);return function Vdt(e,t){if(0===e.length)return console.warn("Skipping PCA, no atoms"),{rotation:Rf.identity,origin:v.zero()};const n=nd.calculateMomentsAxes(e),r=nd.calculateNormalizedAxes(n),i=function qdt(e,t,n){const r=Kt();return Kt.setValue(r,0,0,e[0]),Kt.setValue(r,0,1,e[1]),Kt.setValue(r,0,2,e[2]),Kt.setValue(r,1,0,t[0]),Kt.setValue(r,1,1,t[1]),Kt.setValue(r,1,2,t[2]),Kt.setValue(r,2,0,n[0]),Kt.setValue(r,2,1,n[1]),Kt.setValue(r,2,2,n[2]),r}(r.dirA,r.dirB,r.dirC);!function Wdt(e){Kt.determinant(e)<0&&(Kt.setValue(e,2,0,-Kt.getValue(e,2,0)),Kt.setValue(e,2,1,-Kt.getValue(e,2,1)),Kt.setValue(e,2,2,-Kt.getValue(e,2,2)))}(i);const o=t?function Gdt(e,t){let n=Rf.identity,r=0;const i=Kt();for(const o of[Rf.identity,Rf.rotX180,Rf.rotY180,Rf.rotZ180]){const s=Kt.innerProduct(Kt.mul(i,o,e),t);s>r&&(n=o,r=s)}return n}(i,t):function jdt(e,t,n){const r=v.create(Kt.getValue(t,0,0),Kt.getValue(t,0,1),Kt.getValue(t,0,2)),i=v.create(Kt.getValue(t,1,0),Kt.getValue(t,1,1),Kt.getValue(t,1,2)),o=v.create(Kt.getValue(t,2,0),Kt.getValue(t,2,1),Kt.getValue(t,2,2)),s=Math.floor(e.length/3),a=v();let c=0,u=0,l=0;for(let p=0;ps!==o)}normalizedLoci(o,s,a=!1){const{loci:c,repr:u}=o;return{loci:pn.normalize(c,s?this.props.granularity:void 0,a),repr:u}}mark(o,s,a=!1){if(!pn.isEmpty(o.loci))for(const c of this.providers)c(o,s,a)}dispose(){this.providers.length=0,this.sel.dispose()}constructor(o,s={}){this.ctx=o,this.providers=[],this.props=C.getDefaultValues(e.Params),this.sel=o.managers.structure.selection,this.setProps(s)}}e.LociMarkManager=t,e.LociHighlightManager=class n extends t{constructor(){super(...arguments),this.prev=[],this.clearHighlights=(o=!1)=>{for(const s of this.prev)this.mark(s,Bt.RemoveHighlight,o);this.prev.length=0}}isHighlighted(o){for(const s of this.prev)if(yn.Loci.areEqual(s,o))return!0;return!1}addHighlight(o){this.mark(o,Bt.Highlight),this.prev.push(o)}highlight(o,s=!0){const a=this.normalizedLoci(o,s);this.isHighlighted(a)||this.addHighlight(a)}highlightOnly(o,s=!0){const a=this.normalizedLoci(o,s);this.isHighlighted(a)||(pn.isEmpty(a.loci)?this.clearHighlights():(this.clearHighlights(!0),this.addHighlight(a)))}highlightOnlyExtend(o,s=!0){const a=this.normalizedLoci(o,s);if(De.is(a.loci)){const c={loci:this.sel.tryGetRange(a.loci)||a.loci,repr:a.repr};this.isHighlighted(c)||(pn.isEmpty(c.loci)?this.clearHighlights():(this.clearHighlights(!0),this.addHighlight(c)))}}dispose(){super.dispose(),this.prev.length=0}},e.LociSelectManager=class r extends t{toggle(o,s=!0){if(pn.isEmpty(o.loci))return;const a=this.normalizedLoci(o,s,!0);De.is(a.loci)?this.toggleSel(a):super.mark(a,Bt.Toggle)}toggleExtend(o,s=!0){if(pn.isEmpty(o.loci))return;const a=this.normalizedLoci(o,s,!0);if(De.is(a.loci)){const c=this.sel.tryGetRange(a.loci)||a.loci;this.toggleSel({loci:c,repr:a.repr})}}select(o,s=!0){const a=this.normalizedLoci(o,s,!0);De.is(a.loci)&&this.sel.modify("add",a.loci),this.mark(a,Bt.Select)}selectJoin(o,s=!0){const a=this.normalizedLoci(o,s,!0);De.is(a.loci)&&this.sel.modify("intersect",a.loci),this.mark(a,Bt.Select)}selectOnly(o,s=!0){const a=this.normalizedLoci(o,s,!0);De.is(a.loci)&&(this.mark({loci:Ve.Loci(a.loci.structure),repr:a.repr},Bt.Deselect),this.sel.modify("set",a.loci)),this.mark(a,Bt.Select)}deselect(o,s=!0){const a=this.normalizedLoci(o,s,!0);De.is(a.loci)&&this.sel.modify("remove",a.loci),this.mark(a,Bt.Deselect)}deselectAll(){this.sel.clear(),this.mark({loci:tE},Bt.Deselect)}deselectAllOnEmpty(o){Ta(o.loci)&&this.deselectAll()}mark(o,s){const{loci:a}=o;if(!pn.isEmpty(a))if(De.is(a)){const c=this.sel.getLoci(a.structure);super.mark({loci:Ve.Loci(a.structure)},Bt.Deselect,!pn.isEmpty(c)),super.mark({loci:c},Bt.Select)}else super.mark(o,s)}toggleSel(o){this.sel.has(o.loci)?(this.sel.modify("remove",o.loci),this.mark(o,Bt.Deselect)):(this.sel.modify("add",o.loci),this.mark(o,Bt.Select))}}}(Lm||(Lm={}));class Xdt{clearProviders(){this.providers=[],this.isDirty=!0,this.showLabels()}addProvider(t){this.providers.push(t),this.providers.sort((n,r)=>(r.priority||0)-(n.priority||0)),this.isDirty=!0,this.showLabels()}removeProvider(t){this.providers=this.providers.filter(n=>n!==t),this.isDirty=!0,this.showLabels()}mark(t,n){const r=this.locis.findIndex(i=>yn.Loci.areEqual(t,i));-1===r&&n===Bt.Highlight?(this.locis.push(t),this.isDirty=!0):-1!==r&&n===Bt.RemoveHighlight&&(Kx(this.locis,r),this.isDirty=!0)}showLabels(){this.ctx.behaviors.labels.highlight.next({labels:this.getLabels()})}getLabels(){if(this.isDirty){this.groupedLabels.clear(),this.labels.length=0;for(const t of this.providers)for(const n of this.locis){if(pn.isEmpty(n.loci))continue;const r=t.label(n.loci,n.repr);if(r){const i=t.group?t.group(r):r.toString(),o=this.groupedLabels.get(i);o?o.push(r):this.groupedLabels.set(i,[r])}}this.labels.length=0,this.groupedLabels.forEach((t,n)=>{const r=t.length,i=r>1&&t[0]!==t[1]?n:t[0];this.labels.push(1===r?i:`${i} || \xd7 ${r}`)}),this.isDirty=!1}return this.labels}constructor(t){this.ctx=t,this.providers=[],this.locis=[],this.isDirty=!1,this.labels=[],this.groupedLabels=new Map,t.managers.interactivity.lociHighlights.addProvider((n,r,i)=>{0!==this.providers.length&&(this.mark(n,r),i||this.showLabels())})}}const mfe="overpaint-controls";function gfe(e,t,n,r,i){return yV.apply(this,arguments)}function yV(){return yV=ie(function*(e,t,n,r,i){yield function yfe(e,t,n){return vV.apply(this,arguments)}(e,t,function(){var o=ie(function*(s,a,c){if(i&&i.length>0&&!i.includes(a.params.values.type.name))return;const u=a.obj.data.sourceData,l=yield r(u.root);if(pn.isEmpty(l)||Ta(l))return;const d={bundle:Kn.fromLoci(l),color:-1===n?st(0):n,clear:-1===n};if(c){const p=bfe([...c.params.values.layers,d],u);s.to(c).update(Bo.toBundle(p))}else{const f=bfe([d],u);s.to(a.transform.ref).apply(Ye.Representation.OverpaintStructureRepresentation3DFromBundle,Bo.toBundle(f),{tags:mfe})}});return function(s,a,c){return o.apply(this,arguments)}}())}),yV.apply(this,arguments)}function vV(){return vV=ie(function*(e,t,n){const r=e.state.data,i=r.build();for(const o of t)for(const s of o.representations){const a=r.select(In.Generators.ofTransformer(Ye.Representation.OverpaintStructureRepresentation3DFromBundle,s.cell.transform.ref).withTag(mfe));yield n(i,s.cell,a[0])}return i.commit({doNotUpdateCurrent:!0})}),vV.apply(this,arguments)}function bfe(e,t){const n=Bo.ofBundle(e,t.root),r=Bo.merge(n);return Bo.filter(r,t)}const vfe="clipping-controls";function Kdt(e,t,n,r,i){return _V.apply(this,arguments)}function _V(){return _V=ie(function*(e,t,n,r,i){yield function Zdt(e,t,n){return xV.apply(this,arguments)}(e,t,function(){var o=ie(function*(s,a,c){if(i&&i.length>0&&!i.includes(a.params.values.type.name))return;const u=a.obj.data.sourceData,l=yield r(u.root);if(pn.isEmpty(l)||Ta(l))return;const d={bundle:Kn.fromLoci(l),groups:n};if(c){const p=_fe([...c.params.values.layers,d],u);s.to(c).update(Yr.toBundle(p))}else{const f=_fe([d],u);s.to(a.transform.ref).apply(Ye.Representation.ClippingStructureRepresentation3DFromBundle,Yr.toBundle(f),{tags:vfe})}});return function(s,a,c){return o.apply(this,arguments)}}())}),_V.apply(this,arguments)}function xV(){return xV=ie(function*(e,t,n){const r=e.state.data,i=r.build();for(const o of t)for(const s of o.representations){const a=r.select(In.Generators.ofTransformer(Ye.Representation.ClippingStructureRepresentation3DFromBundle,s.cell.transform.ref).withTag(vfe));yield n(i,s.cell,a[0])}return i.commit({doNotUpdateCurrent:!0})}),xV.apply(this,arguments)}function _fe(e,t){const n=Yr.ofBundle(e,t.root),r=Yr.merge(n);return Yr.filter(r,t)}const xfe="transparency-controls";function Qdt(e,t,n,r,i){return SV.apply(this,arguments)}function SV(){return SV=ie(function*(e,t,n,r,i){yield function Sfe(e,t,n){return wV.apply(this,arguments)}(e,t,function(){var o=ie(function*(s,a,c){if(i&&i.length>0&&!i.includes(a.params.values.type.name))return;const u=a.obj.data.sourceData,l=yield r(u.root);if(pn.isEmpty(l)||Ta(l))return;const d={bundle:Kn.fromLoci(l),value:n};if(c){const p=Cfe([...c.params.values.layers,d],u);s.to(c).update(Vs.toBundle(p))}else{const f=Cfe([d],u);s.to(a.transform.ref).apply(Ye.Representation.TransparencyStructureRepresentation3DFromBundle,Vs.toBundle(f),{tags:xfe})}});return function(s,a,c){return o.apply(this,arguments)}}())}),SV.apply(this,arguments)}function wV(){return wV=ie(function*(e,t,n){const r=e.state.data,i=r.build();for(const o of t)for(const s of o.representations){const a=r.select(In.Generators.ofTransformer(Ye.Representation.TransparencyStructureRepresentation3DFromBundle,s.cell.transform.ref).withTag(xfe));yield n(i,s.cell,a[0])}return i.commit({doNotUpdateCurrent:!0})}),wV.apply(this,arguments)}function Cfe(e,t){const n=Vs.ofBundle(e,t.root),r=Vs.merge(n);return Vs.filter(r,t)}const wfe="substance-controls";function Afe(e,t,n,r,i){return AV.apply(this,arguments)}function AV(){return AV=ie(function*(e,t,n,r,i){yield function Ife(e,t,n){return TV.apply(this,arguments)}(e,t,function(){var o=ie(function*(s,a,c){if(i&&i.length>0&&!i.includes(a.params.values.type.name))return;const u=a.obj.data.sourceData,l=yield r(u.root);if(pn.isEmpty(l)||Ta(l))return;const d={bundle:Kn.fromLoci(l),material:n??ba(),clear:!n};if(c){const p=Tfe([...c.params.values.layers,d],u);s.to(c).update(zs.toBundle(p))}else{const f=Tfe([d],u);s.to(a.transform.ref).apply(Ye.Representation.SubstanceStructureRepresentation3DFromBundle,zs.toBundle(f),{tags:wfe})}});return function(s,a,c){return o.apply(this,arguments)}}())}),AV.apply(this,arguments)}function TV(){return TV=ie(function*(e,t,n){const r=e.state.data,i=r.build();for(const o of t)for(const s of o.representations){const a=r.select(In.Generators.ofTransformer(Ye.Representation.SubstanceStructureRepresentation3DFromBundle,s.cell.transform.ref).withTag(wfe));yield n(i,s.cell,a[0])}return i.commit({doNotUpdateCurrent:!0})}),TV.apply(this,arguments)}function Tfe(e,t){const n=zs.ofBundle(e,t.root),r=zs.merge(n);return zs.filter(r,t)}class _C extends th{get currentStructures(){return this.plugin.managers.structure.hierarchy.selection.structures}get pivotStructure(){return this.currentStructures[0]}_setSnapshotState(t){this.updateState({options:t}),this.events.optionsUpdated.next(void 0)}setOptions(t){var n=this;return ie(function*(){const r=t.interactions!==n.state.options.interactions;n.updateState({options:t}),n.events.optionsUpdated.next(void 0);const i=n.dataState.build();for(const o of n.currentStructures)for(const s of o.components)n.updateReprParams(i,s);return n.plugin.dataTransaction(ie(function*(){yield i.commit(),yield n.plugin.state.updateBehavior(t3,o=>{o.ignoreHydrogens="all"!==t.hydrogens,o.ignoreHydrogensVariant="only-polar"===t.hydrogens?"non-polar":"all",o.ignoreLight=t.ignoreLight,o.material=t.materialStyle,o.clip=t.clipObjects}),r&&(yield n.updateInterationProps())}))})()}updateReprParams(t,n){const{hydrogens:r,visualQuality:i,ignoreLight:o,materialStyle:s,clipObjects:a}=this.state.options,c="all"!==r,u="only-polar"===r?"non-polar":"all";for(const l of n.representations){if(l.cell.transform.transformer!==vE)continue;const d=l.cell.transform.params;(!!d.type.params.ignoreHydrogens!==c||d.type.params.ignoreHydrogensVariant!==u||d.type.params.quality!==i||d.type.params.ignoreLight!==o||!Hx(d.type.params.material,s)||!C.areEqual(gm.Params,d.type.params.clip,a))&&t.to(l.cell).update(f=>{f.type.params.ignoreHydrogens=c,f.type.params.ignoreHydrogensVariant=u,f.type.params.quality=i,f.type.params.ignoreLight=o,f.type.params.material=s,f.type.params.clip=a})}}updateInterationProps(){var t=this;return ie(function*(){var n,r,i;for(const o of t.currentStructures){const s=Qi.getParams(null===(n=o.cell.obj)||void 0===n?void 0:n.data);if(o.properties){const a=null===(r=o.properties.cell.transform.params)||void 0===r?void 0:r.properties[Qi.descriptor.name];if(C.areEqual(s,a,t.state.options.interactions))continue;yield t.dataState.build().to(o.properties.cell).update(c=>{c.properties[Qi.descriptor.name]=t.state.options.interactions}).commit()}else{const a=t.plugin.customStructureProperties.getParams(null===(i=o.cell.obj)||void 0===i?void 0:i.data),c=C.getDefaultValues(a);if(C.areEqual(s,c.properties[Qi.descriptor.name],t.state.options.interactions))continue;c.properties[Qi.descriptor.name]=t.state.options.interactions,yield t.plugin.builders.structure.insertStructureProperties(o.cell,c)}}})()}applyPreset(t,n,r){var i=this;return this.plugin.dataTransaction(ie(function*(){for(const o of t){const s=yield i.plugin.builders.structure.representation.applyPreset(o.cell,n,r);yield i.syncPreset(o,s)}}),{canUndo:"Preset"})}syncPreset(t,n){if(!n||!n.components)return this.clearComponents([t]);const r=new Set;if($a(n.components,a=>{a&&r.add(a.ref)}),n.representations&&$a(n.representations,a=>{a&&r.add(a.ref)}),0===r.size)return this.clearComponents([t]);let i=!1;const o=this.dataState.build(),s=a=>{r.has(a.cell.transform.ref)||(i=!0,o.delete(a.cell))};for(const a of t.components){s(a);for(const c of a.representations)s(c);if(a.genericRepresentations)for(const c of a.genericRepresentations)s(c)}if(t.genericRepresentations)for(const a of t.genericRepresentations)s(a);return i?o.commit():void 0}clear(t){return this.clearComponents(t)}selectThis(t){var n;const r=this.plugin.managers.structure.selection;r.clear();for(const i of t){const o=Ve.toSubStructureElementLoci(i.structure.cell.obj.data,null===(n=i.cell.obj)||void 0===n?void 0:n.data);r.fromLoci("set",o)}}canBeModified(t){return this.plugin.builders.structure.isComponentTransform(t.cell)}modifyByCurrentSelection(t,n){var r=this;return this.plugin.runTask(Oe.create("Modify Component",function(){var i=ie(function*(o){const s=r.dataState.build();for(const a of t){if(!r.canBeModified(a))continue;const c=r.plugin.managers.structure.selection.getStructure(a.structure.cell.obj.data);!c||0===c.elementCount||r.modifyComponent(s,a,c,n)}yield r.dataState.updateTree(s,{canUndo:"Modify Selection"}).runInContext(o)});return function(o){return i.apply(this,arguments)}}()))}toggleVisibility(t,n){if(0!==t.length)if(n){const r=t[0].representations.indexOf(n),i=!n.cell.state.isHidden;for(const o of t){const s=o.representations[r];s&&qv(this.dataState,s.cell.transform.ref,i)}}else{const r=!t[0].cell.state.isHidden;for(const i of t)qv(this.dataState,i.cell.transform.ref,r)}}removeRepresentations(t,n){if(0===t.length)return;const r=[];if(n){const i=t[0].representations.indexOf(n);if(i<0)return;for(const o of t)o.representations[i]&&r.push(o.representations[i])}else for(const i of t)for(const o of i.representations)r.push(o);return this.plugin.managers.structure.hierarchy.remove(r,!0)}updateRepresentations(t,n,r){if(0===t.length)return Promise.resolve();const i=t[0].representations.indexOf(n);if(i<0)return Promise.resolve();const o=this.dataState.build();for(const s of t){const a=s.representations[i];a&&a.cell.transform.transformer===n.cell.transform.transformer&&o.to(a.cell).update(r)}return o.commit({canUndo:"Update Representation"})}updateRepresentationsTheme(t,n){var r,i,o,s;if(0===t.length)return;const a=this.dataState.build();for(const c of t)for(const u of c.representations){const l=u.cell.transform.params,d="function"==typeof n?n(c,u):n,f="default"===d.color?RU(this.plugin,null===(r=c.structure.cell.obj)||void 0===r?void 0:r.data,l?.type.name):d.color?RU(this.plugin,null===(i=c.structure.cell.obj)||void 0===i?void 0:i.data,l?.type.name,d.color,d.colorParams):void 0,p="default"===d.size?vde(this.plugin,null===(o=c.structure.cell.obj)||void 0===o?void 0:o.data,l?.type.name):d.color?vde(this.plugin,null===(s=c.structure.cell.obj)||void 0===s?void 0:s.data,l?.type.name,d.size,d.sizeParams):void 0;(f||p)&&a.to(u.cell).update(m=>{f&&(m.colorTheme=f),p&&(m.sizeTheme=p)})}return a.commit({canUndo:"Update Theme"})}addRepresentation(t,n){var r=this;if(0===t.length)return;const{hydrogens:i,visualQuality:o,ignoreLight:s,materialStyle:a,clipObjects:c}=this.state.options,d={ignoreHydrogens:"all"!==i,ignoreHydrogensVariant:"only-polar"===i?"non-polar":"all",quality:o,ignoreLight:s,material:a,clip:c};return this.plugin.dataTransaction(ie(function*(){for(const f of t)yield r.plugin.builders.structure.representation.addRepresentation(f.cell,{type:r.plugin.representation.structure.registry.get(n),typeParams:d})}),{canUndo:"Add Representation"})}tryFindComponent(t,n){var r=this;if(0!==t.components.length)return this.plugin.runTask(Oe.create("Find Component",function(){var i=ie(function*(o){var s,a;const c=null===(s=t.cell.obj)||void 0===s?void 0:s.data;if(!c)return;const u=pt.unionStructure(yield n.getSelection(r.plugin,o,c));for(const l of t.components){const d=null===(a=l.cell.obj)||void 0===a?void 0:a.data;if(d&&l.cell.parent&&vOe(u,d))return l.cell}});return function(o){return i.apply(this,arguments)}}()))}add(t,n){var r=this;return ie(function*(){return r.plugin.dataTransaction(ie(function*(){const i=n||r.currentStructures;if(0===i.length)return;const{hydrogens:o,visualQuality:s,ignoreLight:a,materialStyle:c,clipObjects:u}=r.state.options,f={ignoreHydrogens:"all"!==o,ignoreHydrogensVariant:"only-polar"===o?"non-polar":"all",quality:s,ignoreLight:a,material:c,clip:u},p=Hr.create22();for(const m of i){let h;t.options.checkExisting&&(h=yield r.tryFindComponent(m,t.selection)),h||(h=yield r.plugin.builders.structure.tryCreateComponentFromSelection(m.cell,t.selection,p,{label:t.options.label||(t.selection===No.current?"Custom Selection":"")})),"none"!==t.representation&&h&&(yield r.plugin.builders.structure.representation.addRepresentation(h,{type:r.plugin.representation.structure.registry.get(t.representation),typeParams:f}))}}),{canUndo:"Add Selection"})})()}applyTheme(t,n){var r=this;return ie(function*(){return r.plugin.dataTransaction(function(){var i=ie(function*(o){const s=n||r.currentStructures;if(0===s.length)return;const a=function(){var c=ie(function*(u){return pt.toLociWithSourceUnits(yield t.selection.getSelection(r.plugin,o,u))});return function(l){return c.apply(this,arguments)}}();for(const c of s)if("color"===t.action.name){const u=t.action.params;yield gfe(r.plugin,c.components,u.color,a,t.representations)}else if("resetColor"===t.action.name)yield gfe(r.plugin,c.components,-1,a,t.representations);else if("transparency"===t.action.name){const u=t.action.params;yield Qdt(r.plugin,c.components,u.value,a,t.representations)}else if("material"===t.action.name){const u=t.action.params;yield Afe(r.plugin,c.components,u.material,a,t.representations)}else if("resetMaterial"===t.action.name)yield Afe(r.plugin,c.components,void 0,a,t.representations);else if("clipping"===t.action.name){const u=t.action.params;yield Kdt(r.plugin,c.components,Yr.Groups.fromNames(u.excludeGroups),a,t.representations)}});return function(o){return i.apply(this,arguments)}}(),{canUndo:"Apply Theme"})})()}modifyComponent(t,n,r,i){var o,s,a;const c=null===(o=n.cell.obj)||void 0===o?void 0:o.data;if(!c||("subtract"===i||"intersect"===i)&&!hT(c,r))return;const u=null===(s=n.structure.cell.obj)||void 0===s?void 0:s.data,l="union"===i?m2(u,[c,r]):"intersect"===i?NJ(c,r):XB(c,r);if(0===l.elementCount)t.delete(n.cell.transform.ref);else{const f={type:{name:"bundle",params:Kn.fromSubStructure(u,l)},nullIfEmpty:!0,label:null===(a=n.cell.obj)||void 0===a?void 0:a.label};t.to(n.cell).update(f)}}updateLabel(t,n){var r,i;const o={type:null===(r=t.cell.params)||void 0===r?void 0:r.values.type,nullIfEmpty:null===(i=t.cell.params)||void 0===i?void 0:i.values.nullIfEmpty,label:n};this.dataState.build().to(t.cell).update(o).commit()}get dataState(){return this.plugin.state.data}clearComponents(t){const n=this.dataState.build();for(const r of t)for(const i of r.components)n.delete(i.cell.transform.ref);return n.commit({canUndo:"Clear Selections"})}constructor(t){super({options:C.getDefaultValues(_C.OptionsParams)}),this.plugin=t,this.events={optionsUpdated:this.ev()}}}!function(e){function r(o,s){var a,c;return null!==(a=s?.cell.obj)&&void 0!==a&&a.data?o.representation.structure.registry.getApplicableTypes(null===(c=s.cell.obj)||void 0===c?void 0:c.data):o.representation.structure.registry.types}function i(o,s,a,c){const u=[...a,...r(o,s)];return C.Select(u[0][0],u,{label:c})}e.OptionsParams={hydrogens:C.Select("all",[["all","Show All"],["hide-all","Hide All"],["only-polar","Only Polar"]],{description:"Determine display of hydrogen atoms in representations"}),visualQuality:C.Select("auto",n5,{description:"Control the visual/rendering quality of representations"}),ignoreLight:C.Boolean(!1,{description:"Ignore light for stylized rendering of representations"}),materialStyle:ba.getParam(),clipObjects:C.Group(gm.Params),interactions:C.Group(Qi.defaultParams,{label:"Non-covalent Interactions"})},e.getAddParams=function t(o,s){const{options:a}=o.query.structure.registry;return s={pivot:o.managers.structure.component.pivotStructure,allowNone:!0,hideSelection:!1,checkExisting:!1,...s},{selection:C.Select(a[1][0],a,{isHidden:s?.hideSelection}),representation:i(o,s?.pivot,s?.allowNone?[["none","< Create Later >"]]:[]),options:C.Group({label:C.Text(""),checkExisting:C.Boolean(!!s?.checkExisting,{help:()=>({description:"Checks if a selection with the specifield elements already exists to avoid creating duplicate components."})})})}},e.getThemeParams=function n(o,s){const{options:a}=o.query.structure.registry;return{selection:C.Select(a[1][0],a,{isHidden:!1}),action:C.MappedStatic("color",{color:C.Group({color:C.Color(xn.blue,{isExpanded:!0})},{isFlat:!0}),resetColor:C.EmptyGroup({label:"Reset Color"}),transparency:C.Group({value:C.Numeric(.5,{min:0,max:1,step:.01})},{isFlat:!0}),material:C.Group({material:ba.getParam({isFlat:!0})},{isFlat:!0}),resetMaterial:C.EmptyGroup({label:"Reset Material"}),clipping:C.Group({excludeGroups:C.MultiSelect([],C.objectToOptions(Yr.Groups.Names))},{isFlat:!0})}),representations:C.MultiSelect([],r(o,s),{emptyValue:"All"})}},e.getRepresentationTypes=r}(_C||(_C={}));class eft extends th{get current(){return this.state.current}get history(){return this.state.history}tryAddHistory(t){if(De.isEmpty(t.loci))return;let r,n=0;for(const i of this.state.history){if(De.areEqual(i.loci,t.loci)){r=i;break}n++}if(r)return Kx(this.state.history,n),this.state.history.unshift(t),void this.events.historyUpdated.next(void 0);this.state.history.unshift(t),this.state.history.length>8&&this.state.history.pop(),this.events.historyUpdated.next(void 0)}set(t){this.tryAddHistory(t),(!this.state.current||!De.areEqual(this.state.current.loci,t.loci))&&(this.state.current=t,this.behaviors.current.next(t))}setFromLoci(t){const n=pn.normalize(t);De.is(n)&&!De.isEmpty(n)?this.set({loci:n,label:dE(n,{reverse:!0,hidePrefix:!0,htmlStyling:!1})}):this.clear()}addFromLoci(t){const n=this.state.current&&De.is(t)&&t.structure===this.state.current.loci.structure?De.union(t,this.state.current.loci):t;this.setFromLoci(n)}clear(){this.state.current&&(this.state.current=void 0,this.behaviors.current.next(void 0))}getSnapshot(){if(!this.current)return{};const t=this.plugin.helpers.substructureParent.get(this.current.loci.structure),n=t?.transform.ref;return n?{current:{label:this.current.label,ref:n,bundle:Kn.fromLoci(this.current.loci),category:this.current.category}}:{}}setSnapshot(t){var n,r;if(!t.current)return void this.clear();const{label:i,ref:o,bundle:s,category:a}=t.current,c=null===(r=null===(n=this.plugin.state.data.select(In.Generators.byRef(o))[0])||void 0===n?void 0:n.obj)||void 0===r?void 0:r.data;if(!c)return;const u=Kn.toLoci(s,c);this.set({label:i,loci:u,category:a})}constructor(t){super({history:[]}),this.plugin=t,this.events={historyUpdated:this.ev()},this.behaviors={current:this.ev.behavior(void 0)},t.state.data.events.object.removed.subscribe(({obj:r})=>{var i;if(!pe.Molecule.Structure.is(r))return;(null===(i=this.current)||void 0===i?void 0:i.loci.structure)===r.data&&this.clear();const o=[];for(const s of this.history)s.loci.structure===r.data&&o.push(s);o.length!==this.history.length&&(this.history.length=0,this.history.push(...o),this.events.historyUpdated.next(void 0))});const n=_e();t.state.data.events.object.updated.subscribe(({oldData:r,obj:i,action:o})=>{var s;if(pe.Molecule.Structure.is(i)&&r!==i.data&&"in-place"===o){const a=this.state.current;if(a&&a.loci.structure===r){const u=De.remap(a.loci,i.data);this.state.current={...a,loci:u},this.behaviors.current.next(this.state.current),pn.getBoundingSphere(u,n);const l=null===(s=this.plugin.canvas3d)||void 0===s?void 0:s.camera,d=l.getTargetDistance(n.radius+4);(v.distance(l.target,n.center)>n.radius||d>l.viewport.height/l.zoom)&&this.plugin.managers.camera.focusSphere(n,{durationMs:0})}}})}}function DV(){return{trajectories:[],models:[],structures:[],refs:new Map}}function nft(e){return{kind:"trajectory",cell:e,version:e.transform.version,models:[]}}function Dfe(e,t){return{kind:"model",cell:e,version:e.transform.version,trajectory:t,structures:[]}}function rft(e,t){return{kind:"model-properties",cell:e,version:e.transform.version,model:t}}function ift(e,t){return{kind:"model-unitcell",cell:e,version:e.transform.version,model:t}}function Efe(e,t){return{kind:"structure",cell:e,version:e.transform.version,model:t,components:[]}}function oft(e,t){return{kind:"structure-properties",cell:e,version:e.transform.version,structure:t}}function sft(e,t){return{kind:"structure-transform",cell:e,version:e.transform.version,structure:t}}function aft(e,t){return{kind:"structure-volume-streaming",cell:e,version:e.transform.version,structure:t}}function cft(e){return e.transform.tags?[...e.transform.tags].sort().join():e.transform.ref}function uft(e,t){return{kind:"structure-component",cell:e,version:e.transform.version,structure:t,key:cft(e),representations:[]}}function lft(e,t){return{kind:"structure-representation",cell:e,version:e.transform.version,component:t}}function dft(e,t){return{kind:"generic-representation",cell:e,version:e.transform.version,parent:t}}function l1(e,t,n,r,...i){const o=r(...i);n.push(o),e.hierarchy.refs.set(t.transform.ref,o);const s=e.oldHierarchy.refs.get(t.transform.ref);return s?s.version!==t.transform.version&&(e.changed=!0):(e.added.add(o.cell.transform.ref),e.changed=!0),o}function G0(e,t,n,...r){const i=n(...r);e.hierarchy.refs.set(t.transform.ref,i);const o=e.oldHierarchy.refs.get(t.transform.ref);return o?o.version!==t.transform.version&&(e.changed=!0):(e.added.add(i.cell.transform.ref),e.changed=!0),i}function Pfe(e){return t=>e.is(t.obj)}function Mfe(e,t){return(n,r)=>!t(r)&&e.is(n.obj)}function h3(e){return t=>t.transform.transformer===e}function j0(){}const pft=[[Pfe(pe.Molecule.Trajectory),(e,t)=>{e.currentTrajectory=l1(e,t,e.hierarchy.trajectories,nft,t)},e=>e.currentTrajectory=void 0],[Mfe(pe.Molecule.Model,e=>e.currentModel),(e,t)=>{e.currentModel=e.currentTrajectory?l1(e,t,e.currentTrajectory.models,Dfe,t,e.currentTrajectory):G0(e,t,Dfe,t),e.hierarchy.models.push(e.currentModel)},e=>e.currentModel=void 0],[h3(Ye.Model.CustomModelProperties),(e,t)=>{if(!e.currentModel)return!1;e.currentModel.properties=G0(e,t,rft,t,e.currentModel)},j0],[h3(Ye.Representation.ModelUnitcell3D),(e,t)=>{if(!e.currentModel)return!1;e.currentModel.unitcell=G0(e,t,ift,t,e.currentModel)},j0],[Mfe(pe.Molecule.Structure,e=>e.currentStructure),(e,t)=>{e.currentStructure=e.currentModel?l1(e,t,e.currentModel.structures,Efe,t,e.currentModel):G0(e,t,Efe,t),e.hierarchy.structures.push(e.currentStructure)},e=>e.currentStructure=void 0],[h3(Ye.Model.CustomStructureProperties),(e,t)=>{if(!e.currentStructure)return!1;e.currentStructure.properties=G0(e,t,oft,t,e.currentStructure)},j0],[h3(Ye.Model.TransformStructureConformation),(e,t)=>{if(!e.currentStructure)return!1;e.currentStructure.transform=G0(e,t,sft,t,e.currentStructure)},j0],[Pfe(Tu),(e,t)=>(e.currentStructure&&(e.currentStructure.volumeStreaming=G0(e,t,aft,t,e.currentStructure)),!1),j0],[(e,t)=>!(t.currentComponent||!t.currentStructure||e.transform.transformer.definition.isDecorator)&&pe.Molecule.Structure.is(e.obj),(e,t)=>{e.currentStructure&&(e.currentComponent=l1(e,t,e.currentStructure.components,uft,t,e.currentStructure))},e=>e.currentComponent=void 0],[(e,t)=>!e.state.isGhost&&!!t.currentComponent&&pe.Molecule.Structure.Representation3D.is(e.obj),(e,t)=>(e.currentComponent&&l1(e,t,e.currentComponent.representations,lft,t,e.currentComponent),!1),j0],[e=>!e.state.isGhost&&pe.isRepresentation3D(e.obj),(e,t)=>{const n=e.currentComponent||e.currentStructure||e.currentModel;n&&(n.genericRepresentations||(n.genericRepresentations=[]),l1(e,t,n.genericRepresentations,dft,t,n))},j0]];function Rfe(e){if(!e||!e?.parent||!e.parent.cells.has(e.transform.ref))return!1;const{obj:t}=e;return!(!t||t===li.Null||"ok"!==e.status&&"error"!==e.status)}function hft(e){const{cell:t}=e;Rfe(t)||(this.changed=!0)}function mft(e){kfe(this,this.tree.transforms.get(e))}function kfe(e,t){const{state:n}=e,r=n.state.cells.get(t.ref);if(!Rfe(r))return;let i,o=!1;for(const[a,c,u]of pft)if(a(r,n)){if(!1===c(n,r)){o=!0;break}i=u;break}if(o)return;const s=e.tree.children.get(t.ref);s&&s.size&&s.forEach(mft,e),i&&i(n)}class xC extends ZS{get dataState(){return this.plugin.state.data}get currentComponentGroups(){return this._currentComponentGroups||(this._currentComponentGroups=xC.getComponentGroups(this.selection.structures)),this._currentComponentGroups}get seletionSet(){if(this._currentSelectionSet)return this._currentSelectionSet;this._currentSelectionSet=new Set;for(const t of this.selection.trajectories)this._currentSelectionSet.add(t.cell.transform.ref);for(const t of this.selection.models)this._currentSelectionSet.add(t.cell.transform.ref);for(const t of this.selection.structures)this._currentSelectionSet.add(t.cell.transform.ref);return this._currentSelectionSet}get current(){return this.sync(!1),this.state.hierarchy}get selection(){return this.sync(!1),this.state.selection}getStructuresWithSelection(){const t=this.plugin.managers.structure.hierarchy.current.structures,n=[];for(const r of t)this.plugin.managers.structure.selection.structureHasSelection(r)&&n.push(r);return n}findStructure(t){if(!t)return;const n=this.plugin.helpers.substructureParent.get(t);if(!n)return;const r=this.plugin.state.data.selectQ(i=>i.byValue(n).rootOfType(pe.Molecule.Structure))[0];return r?this.behaviors.selection.value.structures.find(i=>i.cell===r):void 0}syncCurrent(t,n){const r=this.seletionSet,i=[];for(const o of t){const s=o.cell.transform.ref;(r.has(s)||n.has(s))&&i.push(o)}return 0===i.length?t.length>0?[t[0]]:[]:i}sync(t){if(!t&&this.dataState.inUpdate)return;if(this.state.syncedTree===this.dataState.tree)return void(t&&!this.state.notified&&(this.state.notified=!0,this.behaviors.selection.next({hierarchy:this.state.hierarchy,...this.state.selection})));this.state.syncedTree=this.dataState.tree;const n=function tft(e,t){const n=function fft(e,t){return{state:e,oldHierarchy:t,hierarchy:DV(),changed:!1,added:new Set}}(e,t||DV());return function gft(e,t){kfe({tree:e,state:t},e.root)}(e.tree,n),t&&t.refs.forEach(hft,n),{hierarchy:n.hierarchy,added:n.added,changed:n.changed}}(this.plugin.state.data,this.current);if(!n.changed)return;const{hierarchy:r}=n,i=this.syncCurrent(r.trajectories,n.added),o=this.syncCurrent(r.models,n.added),s=this.syncCurrent(r.structures,n.added);this._currentComponentGroups=void 0,this._currentSelectionSet=void 0,this.state.hierarchy=r,this.state.selection.trajectories=i,this.state.selection.models=o,this.state.selection.structures=s,t?(this.state.notified=!0,this.behaviors.selection.next({hierarchy:r,trajectories:i,models:o,structures:s})):this.state.notified=!1}updateCurrent(t,n){const r=this.current,i="add"===n?Si.union(this.seletionSet,new Set(t.map(c=>c.cell.transform.ref))):Si.difference(this.seletionSet,new Set(t.map(c=>c.cell.transform.ref))),o=[],s=[],a=[];for(const c of r.trajectories)i.has(c.cell.transform.ref)&&o.push(c);for(const c of r.models)i.has(c.cell.transform.ref)&&s.push(c);for(const c of r.structures)i.has(c.cell.transform.ref)&&a.push(c);this._currentComponentGroups=void 0,this._currentSelectionSet=void 0,this.state.selection.trajectories=o,this.state.selection.models=s,this.state.selection.structures=a,this.behaviors.selection.next({hierarchy:r,trajectories:o,models:s,structures:a})}remove(t,n){if(0===t.length)return;const r=this.plugin.state.data.build();for(const i of t)r.delete("string"==typeof i?i:i.cell.transform.ref);return r.commit({canUndo:!!n&&"Remove"})}toggleVisibility(t,n){if(0===t.length)return;const r=void 0!==n?"show"!==n:!t[0].cell.state.isHidden;for(const i of t)qv(this.dataState,i.cell.transform.ref,r)}applyPreset(t,n,r){var i=this;return this.plugin.dataTransaction(ie(function*(){for(const o of t)o.models.length>0&&(yield i.clearTrajectory(o)),yield i.plugin.builders.structure.hierarchy.applyPreset(o.cell,n,r)}))}updateStructure(t,n){var r=this;return ie(function*(){yield r.plugin.dataTransaction(ie(function*(){const i=bo.getDecoratorRoot(r.dataState.tree,t.cell.transform.ref),o=r.dataState.tree.children.get(i).toArray();yield r.remove(o,!1),yield r.plugin.state.updateTransform(r.plugin.state.data,t.cell.transform.ref,n,"Structure Type"),yield r.plugin.builders.structure.representation.applyPreset(t.cell.transform.ref,"auto")}),{canUndo:"Structure Type"}),Cn.Camera.Reset(r.plugin)})()}clearTrajectory(t){const n=this.dataState.build();for(const r of t.models)n.delete(r.cell);return n.commit()}constructor(t){super(),this.plugin=t,this.state={syncedTree:this.dataState.tree,notified:!1,hierarchy:DV(),selection:{trajectories:[],models:[],structures:[]}},this.behaviors={selection:this.ev.behavior({hierarchy:this.current,trajectories:this.selection.trajectories,models:this.selection.models,structures:this.selection.structures})},this._currentComponentGroups=void 0,this._currentSelectionSet=void 0,this.subscribe(t.state.data.events.changed,n=>{n.inTransaction||t.behaviors.state.isAnimating.value||this.sync(!0)}),this.subscribe(t.behaviors.state.isAnimating,n=>{!n&&!t.behaviors.state.isUpdating.value&&this.sync(!0)})}}!function(e){e.getComponentGroups=function t(r){if(!r.length)return[];if(1===r.length)return r[0].components.map(s=>[s]);const i=[],o=new Map;for(const s of r)for(const a of s.components){const c=a.key;if(!c)continue;let u=o.get(c);u||(u=[],o.set(c,u),i.push(u)),u.push(a)}return i},e.getSelectedStructuresDescription=function n(r){var i,o,s,a,c,u,l,d,f;const{structures:p}=r.managers.structure.hierarchy.selection;if(0===p.length)return"";if(1===p.length){const y=p[0],b=null===(i=y.cell.obj)||void 0===i?void 0:i.data;if(!b)return(null===(o=y.cell.obj)||void 0===o?void 0:o.label)||"Structure";const x=b.models[0]||b.representativeModel||b.masterModel;if(!x)return(null===(s=y.cell.obj)||void 0===s?void 0:s.label)||"Structure";const _=x.entryId;return null!==(c=null===(a=y.model)||void 0===a?void 0:a.trajectory)&&void 0!==c&&c.models&&1===y.model.trajectory.models.length?_:y.model?`${null===(u=y.model.cell.obj)||void 0===u?void 0:u.label} | ${_}`:_}const m=p[0],h=null===(l=m?.model)||void 0===l?void 0:l.trajectory;let g=!0;for(const y of p)if((null===(d=y?.model)||void 0===d?void 0:d.trajectory)!==h){g=!1;break}return g&&h?`${null===(f=h.cell.obj)||void 0===f?void 0:f.label} | ${p.length} structures`:`${p.length} structures`}}(xC||(xC={}));const EV="measurement-group",m3="measurement-order-label",yft={distanceUnitLabel:C.Text("\u212b",{isEssential:!0}),textColor:tce.textColor},bft=C.getDefaultValues(yft);class vft extends th{stateUpdated(){this.behaviors.state.next(this.state)}getGroup(){const n=In.findTagInSubtree(this.plugin.state.data.tree,ur.RootRef,EV),r=this.plugin.state.data.build();return n?r.to(n):r.toRoot().group(Ye.Misc.CreateGroup,{label:"Measurements"},{tags:EV})}setOptions(t){var n=this;return ie(function*(){n.updateState({options:t})&&n.stateUpdated();const r=n.plugin.state.data.build();for(const i of n.state.distances)r.to(i).update(o=>{o.unitLabel=t.distanceUnitLabel,o.textColor=t.textColor});for(const i of n.state.labels)r.to(i).update(o=>{o.textColor=t.textColor});for(const i of n.state.angles)r.to(i).update(o=>{o.textColor=t.textColor});for(const i of n.state.dihedrals)r.to(i).update(o=>{o.textColor=t.textColor});0!==r.editInfo.count&&(yield Cn.State.Update(n.plugin,{state:n.plugin.state.data,tree:r,options:{doNotLogTiming:!0}}))})()}addDistance(t,n,r){var i=this;return ie(function*(){const o=i.plugin.helpers.substructureParent.get(t.structure),s=i.plugin.helpers.substructureParent.get(n.structure);if(!o||!s)return;const a=[o.transform.ref];eo(a,s.transform.ref);const c=i.getGroup();c.apply(Ye.Model.MultiStructureSelectionFromExpression,{selections:[{key:"a",groupId:"a",ref:o.transform.ref,expression:De.toExpression(t)},{key:"b",groupId:"b",ref:s.transform.ref,expression:De.toExpression(n)}],isTransitive:!0,label:"Distance"},{dependsOn:a,tags:r?.selectionTags}).apply(Ye.Representation.StructureSelectionsDistance3D,{customText:r?.customText||"",unitLabel:i.state.options.distanceUnitLabel,textColor:i.state.options.textColor,...r?.lineParams,...r?.labelParams,...r?.visualParams},{tags:r?.reprTags});const u=i.plugin.state.data;yield Cn.State.Update(i.plugin,{state:u,tree:c,options:{doNotLogTiming:!0}})})()}addAngle(t,n,r,i){var o=this;return ie(function*(){const s=o.plugin.helpers.substructureParent.get(t.structure),a=o.plugin.helpers.substructureParent.get(n.structure),c=o.plugin.helpers.substructureParent.get(r.structure);if(!s||!a||!c)return;const u=[s.transform.ref];eo(u,a.transform.ref),eo(u,c.transform.ref);const l=o.getGroup();l.apply(Ye.Model.MultiStructureSelectionFromExpression,{selections:[{key:"a",ref:s.transform.ref,expression:De.toExpression(t)},{key:"b",ref:a.transform.ref,expression:De.toExpression(n)},{key:"c",ref:c.transform.ref,expression:De.toExpression(r)}],isTransitive:!0,label:"Angle"},{dependsOn:u,tags:i?.selectionTags}).apply(Ye.Representation.StructureSelectionsAngle3D,{customText:i?.customText||"",textColor:o.state.options.textColor,...i?.lineParams,...i?.labelParams,...i?.visualParams},{tags:i?.reprTags});const d=o.plugin.state.data;yield Cn.State.Update(o.plugin,{state:d,tree:l,options:{doNotLogTiming:!0}})})()}addDihedral(t,n,r,i,o){var s=this;return ie(function*(){const a=s.plugin.helpers.substructureParent.get(t.structure),c=s.plugin.helpers.substructureParent.get(n.structure),u=s.plugin.helpers.substructureParent.get(r.structure),l=s.plugin.helpers.substructureParent.get(i.structure);if(!(a&&c&&u&&l))return;const d=[a.transform.ref];eo(d,c.transform.ref),eo(d,u.transform.ref),eo(d,l.transform.ref);const f=s.getGroup();f.apply(Ye.Model.MultiStructureSelectionFromExpression,{selections:[{key:"a",ref:a.transform.ref,expression:De.toExpression(t)},{key:"b",ref:c.transform.ref,expression:De.toExpression(n)},{key:"c",ref:u.transform.ref,expression:De.toExpression(r)},{key:"d",ref:l.transform.ref,expression:De.toExpression(i)}],isTransitive:!0,label:"Dihedral"},{dependsOn:d,tags:o?.selectionTags}).apply(Ye.Representation.StructureSelectionsDihedral3D,{customText:o?.customText||"",textColor:s.state.options.textColor,...o?.lineParams,...o?.labelParams,...o?.visualParams},{tags:o?.reprTags});const p=s.plugin.state.data;yield Cn.State.Update(s.plugin,{state:p,tree:f,options:{doNotLogTiming:!0}})})()}addLabel(t,n){var r=this;return ie(function*(){const i=r.plugin.helpers.substructureParent.get(t.structure);if(!i)return;const o=[i.transform.ref],s=r.getGroup();s.apply(Ye.Model.MultiStructureSelectionFromExpression,{selections:[{key:"a",ref:i.transform.ref,expression:De.toExpression(t)}],isTransitive:!0,label:"Label"},{dependsOn:o,tags:n?.selectionTags}).apply(Ye.Representation.StructureSelectionsLabel3D,{textColor:r.state.options.textColor,...n?.labelParams,...n?.visualParams},{tags:n?.reprTags});const a=r.plugin.state.data;yield Cn.State.Update(r.plugin,{state:a,tree:s,options:{doNotLogTiming:!0}})})()}addOrientation(t){var n=this;return ie(function*(){const r=[],i=[];for(let a=0,c=t.length;a{n.inTransaction||t.behaviors.state.isAnimating.value||this.sync()}),t.behaviors.state.isAnimating.subscribe(n=>{!n&&!t.behaviors.state.isUpdating.value&&this.sync()})}}const SC=new fu("98");class xft extends th{get entries(){return this.state.entries}get additionsHistory(){return this.state.additionsHistory}get stats(){return this.state.stats||(this.state.stats=this.calcStats()),this.state.stats}getEntry(t){const n=this.plugin.helpers.substructureParent.get(t,!0);if(!n)return;const r=n.transform.ref;if(!this.entries.has(r)){const i=new PV(De(t,[]));return this.entries.set(r,i),i}return this.entries.get(r)}calcStats(){let t=0,n=0;const r=rf.create();this.entries.forEach(o=>{const{elements:s}=o.selection;if(s.length){t+=1;for(let a=0,c=s.length;a24&&this.additionsHistory.pop(),this.events.additionsHistoryUpdated.next(void 0)}clearHistory(){0!==this.state.additionsHistory.length&&(this.state.additionsHistory=[],this.events.additionsHistoryUpdated.next(void 0))}clearHistoryForStructure(t){const n=[];for(const r of this.state.additionsHistory)r.loci.structure.root===t.root&&n.push(r);for(const r of n)this.modifyHistory(r,"remove");0!==n.length&&this.events.additionsHistoryUpdated.next(void 0)}onRemove(t,n){var r;this.entries.has(t)&&(this.entries.delete(t),n?.data&&this.clearHistoryForStructure(n.data),(null===(r=this.referenceLoci)||void 0===r?void 0:r.structure)===n?.data&&(this.referenceLoci=void 0),this.state.stats=void 0,this.events.changed.next(void 0))}onUpdate(t,n,r){var i,o,s,a;if(n===r||n?.data===r.data)return;const c=this.plugin.helpers.substructureParent.get(r.data,!0);if(!c||t!==c.transform.ref||!this.entries.has(t))return;const u=null===(o=null===(i=this.plugin.helpers.substructureParent.get(r.data))||void 0===i?void 0:i.obj)||void 0===o?void 0:o.data;if(u)if(!n?.data||Ve.areUnitIdsAndIndicesEqual(n.data,r.data)){this.entries.set(t,function Cft(e,t){return new PV(De.remap(e.selection,t))}(this.entries.get(t),u)),(null===(s=this.referenceLoci)||void 0===s?void 0:s.structure.root)===u.root&&(this.referenceLoci=De.remap(this.referenceLoci,u));let l=!1;for(const d of this.state.additionsHistory)d.loci.structure.root===u.root&&(d.loci=De.remap(d.loci,u),l=!0);l&&this.events.additionsHistoryUpdated.next(void 0)}else this.entries.set(t,new PV(De(u,[]))),(null===(a=this.referenceLoci)||void 0===a?void 0:a.structure.root)===u.root&&(this.referenceLoci=void 0),this.clearHistoryForStructure(u),this.state.stats=void 0,this.events.changed.next(void 0)}clear(){const t=this.entries.keys(),n=[];for(;;){const r=t.next();if(r.done)break;const i=this.entries.get(r.value);De.isEmpty(i.selection)||n.push(i.selection),i.selection=De(i.selection.structure,[])}return this.referenceLoci=void 0,this.state.stats=void 0,this.events.changed.next(void 0),this.events.loci.clear.next(void 0),this.clearHistory(),n}getLoci(t){const n=this.getEntry(t);return n?n.selection:$n}getStructure(t){const n=this.getEntry(t);if(n)return n.structure}structureHasSelection(t){var n,r;const i=null===(r=null===(n=t.cell)||void 0===n?void 0:n.obj)||void 0===r?void 0:r.data;if(!i)return!1;const o=this.getEntry(i);return!!o&&!De.isEmpty(o.selection)}has(t){if(De.is(t)){const n=this.getEntry(t.structure);if(n)return De.isSubset(n.selection,t)}return!1}tryGetRange(t){if(!De.is(t)||1!==t.elements.length||!this.getEntry(t.structure))return;const r=t.elements[0];if(!r)return;const i=this.referenceLoci;if(!i||!De.is(i)||i.structure!==t.structure)return;let o;for(const s of i.elements)if(r.unit===s.unit){o=s;break}return o&&r.unit===o.unit?function wft(e,t,n){const r=Math.min(Fe.min(t.indices),Fe.min(n.indices)),i=Math.max(Fe.max(t.indices),Fe.max(n.indices));return De(e,[{unit:t.unit,indices:Fe.ofRange(r,i)}])}(t.structure,o,r):void 0}elementCount(){let t=0;return this.entries.forEach(n=>{t+=De.size(n.selection)}),t}getBoundary(){const t=v.create(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=v.create(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);SC.reset();const r=[];this.entries.forEach(i=>{const o=i.selection;De.isEmpty(o)||r.push(De.getBoundary(o))});for(let i=0,o=r.length;in.selection))}modify(t,n){let r=!1;switch(t){case"add":r=this.add(n);break;case"remove":r=this.remove(n);break;case"intersect":r=this.intersect(n);break;case"set":r=this.set(n)}r&&(this.state.stats=void 0,this.events.changed.next(void 0))}get applicableStructures(){return this.plugin.managers.structure.hierarchy.selection.structures.filter(t=>!!t.cell.obj).map(t=>t.cell.obj.data)}triggerInteraction(t,n,r=!0){switch(t){case"add":this.plugin.managers.interactivity.lociSelects.select({loci:n},r);break;case"remove":this.plugin.managers.interactivity.lociSelects.deselect({loci:n},r);break;case"intersect":this.plugin.managers.interactivity.lociSelects.selectJoin({loci:n},r);break;case"set":this.plugin.managers.interactivity.lociSelects.selectOnly({loci:n},r)}}fromLoci(t,n,r=!0){this.triggerInteraction(t,n,r)}fromCompiledQuery(t,n,r=!0){for(const i of this.applicableStructures){const o=n(new qu(i));this.triggerInteraction(t,pt.toLociWithSourceUnits(o),r)}}fromSelectionQuery(t,n,r=!0){var i=this;this.plugin.runTask(Oe.create("Structure Selection",function(){var o=ie(function*(s){for(const a of i.applicableStructures){const c=yield n.getSelection(i.plugin,s,a);i.triggerInteraction(t,pt.toLociWithSourceUnits(c),r)}});return function(s){return o.apply(this,arguments)}}()))}fromSelections(t){var n;const r=ls.resolveAndCheck(this.plugin.state.data,t);if(r&&r.obj){if(!pe.Molecule.Structure.Selections.is(r.obj))return void console.warn("fromSelections applied to wrong object type.",r.obj);this.clear();for(const i of null===(n=r.obj)||void 0===n?void 0:n.data)this.fromLoci("set",i.loci)}}getSnapshot(){const t=[];return this.entries.forEach((n,r)=>{t.push({ref:r,bundle:Kn.fromLoci(n.selection)})}),{entries:t}}setSnapshot(t){var n,r;this.entries.clear();for(const{ref:i,bundle:o}of t.entries){const s=null===(r=null===(n=this.plugin.state.data.select(In.Generators.byRef(i))[0])||void 0===n?void 0:n.obj)||void 0===r?void 0:r.data;if(!s)continue;const a=Kn.toLoci(o,s);this.fromLoci("set",a,!1)}}constructor(t){super({entries:new Map,additionsHistory:[],stats:{structureCount:0,elementCount:0,label:"Nothing Selected"}}),this.plugin=t,this.events={changed:this.ev(),additionsHistoryUpdated:this.ev(),loci:{add:this.ev(),remove:this.ev(),clear:this.ev()}},t.helpers.substructureParent.events.removed.subscribe(n=>this.onRemove(n.ref,n.obj)),t.helpers.substructureParent.events.updated.subscribe(n=>this.onUpdate(n.ref,n.oldObj,n.obj))}}class PV{get selection(){return this._selection}set selection(t){this._selection=t,this._structure=void 0}get structure(){return this._structure||(this._structure=pn.isEmpty(this._selection)?void 0:De.toStructure(this._selection)),this._structure}constructor(t){this._structure=void 0,this._selection=t}}function MV(){return{volumes:[],lazyVolumes:[],refs:new Map}}function Ift(e){return{kind:"volume",cell:e,version:e.transform.version,representations:[]}}function Tft(e){return{kind:"lazy-volume",cell:e,version:e.transform.version}}function Dft(e,t){return{kind:"volume-representation",cell:e,version:e.transform.version,volume:t}}function RV(e,t,n,r,...i){const o=r(...i);n.push(o),e.hierarchy.refs.set(t.transform.ref,o);const s=e.oldHierarchy.refs.get(t.transform.ref);return s?s.version!==t.transform.version&&(e.changed=!0):(e.added.add(o.cell.transform.ref),e.changed=!0),o}function Nfe(){}const Mft=[[function Pft(e,t){return(n,r)=>!t(r)&&e.is(n.obj)}(pe.Volume.Data,e=>e.currentVolume),(e,t)=>{e.currentVolume=RV(e,t,e.hierarchy.volumes,Ift,t)},e=>e.currentVolume=void 0],[e=>pe.Volume.Lazy.is(e.obj),(e,t)=>{RV(e,t,e.hierarchy.lazyVolumes,Tft,t)},Nfe],[(e,t)=>!e.state.isGhost&&!!t.currentVolume&&pe.Volume.Representation3D.is(e.obj),(e,t)=>(e.currentVolume&&RV(e,t,e.currentVolume.representations,Dft,t,e.currentVolume),!1),Nfe]];function Ffe(e){if(!e||!e?.parent||!e.parent.cells.has(e.transform.ref))return!1;const{obj:t}=e;return!(!t||t===li.Null||"ok"!==e.status&&"error"!==e.status)}function Rft(e){const{cell:t}=e;Ffe(t)||(this.changed=!0)}function kft(e){Bfe(this,this.tree.transforms.get(e))}function Bfe(e,t){const{state:n}=e,r=n.state.cells.get(t.ref);if(!Ffe(r))return;let i,o=!1;for(const[a,c,u]of Mft)if(a(r,n)){if(!1===c(n,r)){o=!0;break}i=u;break}if(o)return;const s=e.tree.children.get(t.ref);s&&s.size&&s.forEach(kft,e),i&&i(n)}class kV extends ZS{get dataState(){return this.plugin.state.data}get current(){return this.sync(!1),this.state.hierarchy}get selection(){return this.sync(!1),this.state.selection}sync(t){if(!t&&this.dataState.inUpdate)return;if(this.state.syncedTree===this.dataState.tree)return void(t&&!this.state.notified&&(this.state.notified=!0,this.behaviors.selection.next({hierarchy:this.state.hierarchy,volume:this.state.selection})));this.state.syncedTree=this.dataState.tree;const n=function Aft(e,t){const n=function Eft(e,t){return{state:e,oldHierarchy:t,hierarchy:MV(),changed:!1,added:new Set}}(e,t||MV());return function Nft(e,t){Bfe({tree:e,state:t},e.root)}(e.tree,n),t&&t.refs.forEach(Rft,n),{hierarchy:n.hierarchy,added:n.added,changed:n.changed}}(this.plugin.state.data,this.current);if(!n.changed)return;const{hierarchy:r}=n;this.state.hierarchy=r,this.state.selection=this.state.selection&&r.refs.has(this.state.selection.cell.transform.ref)?r.refs.get(this.state.selection.cell.transform.ref):r.volumes[0],t?(this.state.notified=!0,this.behaviors.selection.next({hierarchy:r,volume:this.state.selection})):this.state.notified=!1}setCurrent(t){this.state.selection=t||this.state.hierarchy.volumes[0],this.behaviors.selection.next({hierarchy:this.state.hierarchy,volume:t||this.state.hierarchy.volumes[0]})}remove(t,n){if(0===t.length)return;const r=this.plugin.state.data.build();for(const i of t)r.delete("string"==typeof i?i:i.cell.transform.ref);return r.commit({canUndo:!!n&&"Remove"})}toggleVisibility(t,n){if(0===t.length)return;const r=void 0!==n?"show"!==n:!t[0].cell.state.isHidden;for(const i of t)qv(this.dataState,i.cell.transform.ref,r)}addRepresentation(t,n){var r;return this.dataState.build().to(t.cell).apply(Ye.Representation.VolumeRepresentation3D,bC(this.plugin,null===(r=t.cell.obj)||void 0===r?void 0:r.data,{type:n})).commit({canUndo:"Add Representation"})}constructor(t){super(),this.plugin=t,this.state={syncedTree:this.dataState.tree,notified:!1,hierarchy:MV(),selection:void 0},this.behaviors={selection:this.ev.behavior({hierarchy:this.current,volume:this.selection})},this.subscribe(t.state.data.events.changed,n=>{n.inTransaction||t.behaviors.state.isAnimating.value||this.sync(!0)}),this.subscribe(t.behaviors.state.isAnimating,n=>{!n&&!t.behaviors.state.isUpdating.value&&this.sync(!0)})}}!function(e){e.getRepresentationTypes=function t(n,r){var i,o;return null!==(i=r?.cell.obj)&&void 0!==i&&i.data?n.representation.volume.registry.getApplicableTypes(null===(o=r.cell.obj)||void 0===o?void 0:o.data):n.representation.volume.registry.types}}(kV||(kV={}));const NV=[["full","Full"],["hidden","Hidden"]],Bft={isExpanded:C.Boolean(!1),showControls:C.Boolean(!0),regionState:C.Group({left:C.Select("full",[["full","Full"],["collapsed","Collapsed"],["hidden","Hidden"]]),top:C.Select("full",NV),right:C.Select("full",NV),bottom:C.Select("full",NV)}),controlsDisplay:C.Value("outside",{isHidden:!0})};class Oft extends th{updateProps(t){const n=!!this.state.isExpanded;this.updateState(t),this.root&&"boolean"==typeof t.isExpanded&&t.isExpanded!==n&&this.handleExpand(),this.events.updated.next(void 0)}setProps(t){this.updateState(t)}setRoot(t){this.root=t,this.state.isExpanded&&this.handleExpand()}getScrollElement(){return document.scrollingElement?document.scrollingElement:document.documentElement?document.documentElement:document.body}handleExpand(){try{const t=document.getElementsByTagName("body")[0],n=document.getElementsByTagName("head")[0];if(!t||!n||!this.root)return;if(this.state.isExpanded){const r=n.children,i=[];let o=!1;for(let l=0;lthis.updateProps(n.state)),typeof document<"u"&&(this.expandedViewport=document.createElement("meta"),this.expandedViewport.name="viewport",this.expandedViewport.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0")}}const FV={includeTypes:C.MultiSelect(NI(jn.Names),C.objectToOptions(jn.Names)),excludeTypes:C.MultiSelect([],C.objectToOptions(jn.Names)),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),aromaticBonds:C.Boolean(!0,{description:"Display aromatic bonds with dashes"}),multipleBonds:C.Select("symmetric",C.arrayToOptions(["off","symmetric","offset"]))},BV=(C.getDefaultValues(FV),{...F0,...FV,adjustCylinderLength:C.Boolean(!1,{description:"Shorten cylinders to reduce overlap with spheres. Useful for for transparent bonds. Not working well with aromatic bonds."})}),OV=(C.getDefaultValues(BV),{...Qle,...FV});function g3(e,t,n){return!jn.is(e,n)||jn.is(t,n)}function Ofe(e,t,n){const r=t.elements,i=t.bonds,{a:o,b:s,edgeProps:a}=i,{flags:c}=a,{ignoreHydrogens:u,ignoreHydrogensVariant:l,includeTypes:d,excludeTypes:f}=n,p=jn.fromNames(d),m=jn.fromNames(f),h=jn.isAll(p)&&0===m,{child:g}=e,y=g?.unitMap.get(t.id);if(g&&!y)throw new Error("expected childUnit to exist if child exists");if(!h||u||g)return b=>{const x=o[b],_=s[b];return!!(y&&!je.has(y.elements,r[x])||!h&&g3(p,m,c[b]))||!!u&&!(!md(e,t,r[x],l)&&!md(e,t,r[_],l))}}function Lfe(e,t){const n=e.interUnitBonds,{edges:r}=n,{ignoreHydrogens:i,ignoreHydrogensVariant:o,includeTypes:s,excludeTypes:a}=t,c=jn.fromNames(s),u=jn.fromNames(a),l=jn.isAll(c)&&0===u,{child:d}=e;if(!l||i||d)return f=>{if(d){const p=r[f],m=d.unitMap.get(p.unitA);if(!m)return!0;const g=e.unitMap.get(p.unitA).elements[p.indexA];if(!je.has(m.elements,g))return!0}if(i){const p=r[f],m=e.unitMap.get(p.unitA),h=e.unitMap.get(p.unitB);if(md(e,m,m.elements[p.indexA],o)||md(e,h,h.elements[p.indexB],o))return!0}return!(l||!g3(c,u,r[f].props.flag))}}var Um;function LV(e,t,n){const{objectId:r,instanceId:i,groupId:o}=e;if(n===r){const{structure:s,group:a}=t,c=a.units[i];if(Ee.isAtomic(c)){const{target:u}=s,l=c.bonds.a[o],d=c.bonds.b[o];return Lt.Loci(u,[Lt.Location(u,c,l,u,c,d),Lt.Location(u,c,d,u,c,l)])}}return $n}function UV(e,t,n,r){let i=!1;if(Lt.isLoci(e)){const{structure:o,group:s}=t;if(!Ve.areEquivalent(e.structure,o))return!1;const a=s.units[0];if(!Ee.isAtomic(a))return!1;const c=2*a.bonds.edgeCount;for(const u of e.bonds){if(u.aUnit!==u.bUnit)continue;const l=s.unitIndexMap.get(u.aUnit.id);if(void 0!==l){const d=a.bonds.getDirectedEdgeIndex(u.aIndex,u.bIndex);-1!==d&&n(Ce.ofSingleton(l*c+d))&&(i=!0)}}}else if(De.is(e)){const{structure:o,group:s}=t;if(!Ve.areEquivalent(e.structure,o))return!1;const a=s.units[0];if(!Ee.isAtomic(a))return!1;const c=2*a.bonds.edgeCount;for(const u of e.elements){const l=s.unitIndexMap.get(u.unit.id);if(void 0!==l){const{offset:d,b:f}=a.bonds;Fe.forEach(u.indices,p=>{for(let m=d[p],h=d[p+1];m{const m=o.units[p];return l.aUnit=m,l.bUnit=m,l.aIndex=m.bonds.a[f],l.bIndex=m.bonds.b[f],l};if(i?.includeLocation2){const f=Lt.Location(s,void 0,void 0,s,void 0,void 0);return Mr(c,u,1,d,!1,()=>!1,(m,h)=>{const g=o.units[h];return f.aUnit=g,f.bUnit=g,f.aIndex=g.bonds.b[m],f.bIndex=g.bonds.a[m],f})}return Mr(c,u,1,d)},e.fromStructure=function n(r,i){const o=r.interUnitBonds.edgeCount,a=Lt.Location(r,void 0,void 0,r,void 0,void 0),c=u=>{const l=r.interUnitBonds.edges[u];return a.aUnit=r.unitMap.get(l.unitA),a.aIndex=l.indexA,a.bUnit=r.unitMap.get(l.unitB),a.bIndex=l.indexB,a};if(i?.includeLocation2){const u=Lt.Location(r,void 0,void 0,r,void 0,void 0);return Mr(o,1,1,c,!0,()=>!1,d=>{const f=r.interUnitBonds.edges[d];return u.aUnit=r.unitMap.get(f.unitB),u.aIndex=f.indexB,u.bUnit=r.unitMap.get(f.unitA),u.bIndex=f.indexA,u})}return Mr(o,1,1,c,!0)}}(Um||(Um={}));const zV=new Map;function GV(e,t,n,r){let i=!1;if(Lt.isLoci(e)){if(!Ve.areEquivalent(e.structure,t))return!1;for(const o of e.bonds){const s=t.interUnitBonds.getBondIndexFromLocation(o);-1!==s&&n(Ce.ofSingleton(s))&&(i=!0)}}else if(De.is(e)){if(!Ve.areEquivalent(e.structure,t)||r&&1===e.elements.length)return!1;for(const o of e.elements)zV.set(o.unit.id,o.indices);for(const o of e.elements){const{unit:s}=o;Ee.isAtomic(s)&&t.interUnitBonds.getConnectedUnits(s.id).forEach(a=>{const c=zV.get(a.unitB);(!r||c)&&Fe.forEach(o.indices,u=>{a.connectedIndices.includes(u)&&a.getEdges(u).forEach(l=>{if(!r||c&&Fe.has(c,l.indexB)){const d=t.interUnitBonds.getEdgeIndex(u,s.id,l.indexB,a.unitB);n(Ce.ofSingleton(d))&&(i=!0)}})})})}zV.clear()}return i}const jV=jn.is;function Ufe(e,t,n,r){const i=e.elements,o=e.bonds,{edgeCount:s,a,b:c,edgeProps:u,offset:l}=o,{order:d,flags:f}=u,{sizeFactor:p,sizeAspectRatio:m,adjustCylinderLength:h,aromaticBonds:g,includeTypes:y,excludeTypes:b,multipleBonds:x}=r,_="off"===x,S="symmetric"===x,w=g3(jn.fromNames(y),jn.fromNames(b),32),D=v(),I=v(),R=e.conformation;let T;const M=nt.create(t,e),N=Lt.Location(t,e,void 0,t,e,void 0),{child:V}=t;if(r.includeParent&&V){const $=V.unitMap.get(e.id);if(!$)throw new Error("expected childUnit to exist");T=ee=>{const O=i[c[ee]];return je.has($.elements,i[a[ee]])&&!je.has($.elements,O)}}const{elementRingIndices:z,elementAromaticRingIndices:j}=e.rings,Z=g?e.resonance.delocalizedTriplets:void 0;return{linkCount:2*s,referencePosition:$=>{let ee=a[$],q=c[$];const O=Z?.getThirdElement(ee,q);if(void 0!==O)return R.invariantPosition(i[O],D);ee>q&&([ee,q]=[q,ee]),l[ee+1]-l[ee]==1&&([ee,q]=[q,ee]);const H=j.get(ee)||z.get(ee);let W=0;for(let Q=l[ee],fe=l[ee+1];QW&&(W=ce,R.invariantPosition(i[X],D))}}}return W>0?D:null},position:($,ee,q)=>{if(R.invariantPosition(i[a[q]],$),R.invariantPosition(i[c[q]],ee),h){const O=($=>(M.element=i[a[$]],n.size.size(M)*p))(q),H=($=>(M.element=i[c[$]],n.size.size(M)*p))(q),W=Math.min(O,H)*m,Q=Math.sqrt(Math.max(0,O*O-W*W))-.05,fe=Math.sqrt(Math.max(0,H*H-W*W))-.05;if(Q<=.01&&fe<=.01)return;v.normalize(I,v.sub(I,ee,$)),v.scaleAndAdd($,$,I,Q),v.scaleAndAdd(ee,ee,I,-fe)}},style:$=>{const ee=d[$],q=f[$];if(jV(q,2)||jV(q,4))return 1;if(3===ee)return _?0:S?4:5;if(g){const H=c[$],W=j.get(a[$]),Q=j.get(H),fe=W&&Q?jI(W,Q):0;if(jV(q,16)||fe&&!w)return 2===fe?8:7}return 2!==ee||_?0:S?2:3},radius:$=>($=>(N.aIndex=a[$],N.bIndex=c[$],n.size.size(N)*p))($)*m,ignore:Ofe(t,e,r),stub:T}}function Lft(e,t,n,r,i,o){if(!Ee.isAtomic(t)||!t.bonds.edgeCount)return oc.createEmpty(o);const{child:s}=n,a=s?.unitMap.get(t.id);if(s&&!a)return oc.createEmpty(o);const c=Ufe(t,n,r,i),{cylinders:u,boundingSphere:l}=Jle(0,c,i,o);if(l)u.setBoundingSphere(l);else if(u.cylinderCount>0){const d=_e.expand(_e(),(a??t).boundary.sphere,1*i.sizeFactor);u.setBoundingSphere(d)}return u}function Uft(e,t,n,r,i,o){if(!Ee.isAtomic(t)||!t.bonds.edgeCount)return Nt.createEmpty(o);const{child:s}=n,a=s?.unitMap.get(t.id);if(s&&!a)return Nt.createEmpty(o);const c=Ufe(t,n,r,i),{mesh:u,boundingSphere:l}=B0(0,c,i,o);if(l)u.setBoundingSphere(l);else if(u.triangleCount>0){const d=_e.expand(_e(),(a??t).boundary.sphere,1*i.sizeFactor);u.setBoundingSphere(d)}return u}const y3={...hs,...AU,...BV,sizeFactor:C.Numeric(.3,{min:0,max:10,step:.01}),sizeAspectRatio:C.Numeric(2/3,{min:0,max:3,step:.01}),tryUseImpostor:C.Boolean(!0),includeParent:C.Boolean(!1)};function Vfe(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth?function Vft(e){return IU({defaultProps:C.getDefaultValues(y3),createGeometry:Lft,createLocationIterator:(t,n)=>Um.fromGroup(t,{includeLocation2:"interpolate"===n.colorMode}),getLoci:LV,eachLocation:UV,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.sizeAspectRatio!==r.sizeAspectRatio||n.linkScale!==r.linkScale||n.linkSpacing!==r.linkSpacing||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.linkCap!==r.linkCap||n.aromaticScale!==r.aromaticScale||n.aromaticSpacing!==r.aromaticSpacing||n.aromaticDashCount!==r.aromaticDashCount||n.dashCount!==r.dashCount||n.dashScale!==r.dashScale||n.dashCap!==r.dashCap||n.stubCap!==r.stubCap||!Wa(n.includeTypes,r.includeTypes)||!Wa(n.excludeTypes,r.excludeTypes)||n.adjustCylinderLength!==r.adjustCylinderLength||n.aromaticBonds!==r.aromaticBonds||n.multipleBonds!==r.multipleBonds,n.colorMode!==r.colorMode&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0);const c=s.group.units[0],u=a.group.units[0];Ee.isAtomic(c)&&Ee.isAtomic(u)&&(Dc.areEqual(c.bonds,u.bonds)||(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0))},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function zft(e){return Hs({defaultProps:C.getDefaultValues(y3),createGeometry:Uft,createLocationIterator:t=>Um.fromGroup(t),getLoci:LV,eachLocation:UV,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.sizeAspectRatio!==r.sizeAspectRatio||n.radialSegments!==r.radialSegments||n.linkScale!==r.linkScale||n.linkSpacing!==r.linkSpacing||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.linkCap!==r.linkCap||n.aromaticScale!==r.aromaticScale||n.aromaticSpacing!==r.aromaticSpacing||n.aromaticDashCount!==r.aromaticDashCount||n.dashCount!==r.dashCount||n.dashScale!==r.dashScale||n.dashCap!==r.dashCap||n.stubCap!==r.stubCap||!Wa(n.includeTypes,r.includeTypes)||!Wa(n.excludeTypes,r.excludeTypes)||n.adjustCylinderLength!==r.adjustCylinderLength||n.aromaticBonds!==r.aromaticBonds||n.multipleBonds!==r.multipleBonds;const c=s.group.units[0],u=a.group.units[0];Ee.isAtomic(c)&&Ee.isAtomic(u)&&(Dc.areEqual(c.bonds,u.bonds)||(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0))},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}const HV=new Lt.ElementBondIterator;function zfe(e,t,n,r){for(HV.setElement(t,n,r);HV.hasNext;){const i=HV.move();return i.otherUnit.conformation.position(i.otherUnit.elements[i.otherIndex],e),e}return null}const Gfe=v();function jfe(e,t,n){const r=nt.create(e),i=Lt.Location(e,void 0,void 0,e,void 0,void 0),o=e.interUnitBonds,{edgeCount:s,edges:a}=o,{sizeFactor:c,sizeAspectRatio:u,adjustCylinderLength:l,aromaticBonds:d,multipleBonds:f}=n,p="off"===f,m="symmetric"===f,h=v();let g;const{child:y}=e;return n.includeParent&&y&&(g=S=>{const A=a[S],E=y.unitMap.get(A.unitA),w=y.unitMap.get(A.unitB),I=e.unitMap.get(A.unitA).elements[A.indexA],T=e.unitMap.get(A.unitB).elements[A.indexB];return E&&je.has(E.elements,I)&&(!w||!je.has(w.elements,T))}),{linkCount:s,referencePosition:S=>{const A=a[S];let E,w,D,I;if(A.unitAA.unitB))throw new Error("same units in createInterUnitBondCylinderMesh");E=e.unitMap.get(A.unitB),w=e.unitMap.get(A.unitA),D=A.indexB,I=A.indexA}return zfe(Gfe,e,E,D)||zfe(Gfe,e,w,I)},position:(S,A,E)=>{const w=a[E],D=e.unitMap.get(w.unitA),I=e.unitMap.get(w.unitB);if(D.conformation.position(D.elements[w.indexA],S),I.conformation.position(I.elements[w.indexB],A),l){const R=(S=>{const A=a[S];return r.unit=e.unitMap.get(A.unitA),r.element=r.unit.elements[A.indexA],t.size.size(r)*c})(E),T=(S=>{const A=a[S];return r.unit=e.unitMap.get(A.unitB),r.element=r.unit.elements[A.indexB],t.size.size(r)*c})(E),M=Math.min(R,T)*u,N=Math.sqrt(Math.max(0,R*R-M*M))-.05,V=Math.sqrt(Math.max(0,T*T-M*M))-.05;if(N<=.01&&V<=.01)return;v.normalize(h,v.sub(h,A,S)),v.scaleAndAdd(S,S,h,N),v.scaleAndAdd(A,A,h,-V)}},style:S=>{const A=a[S].props.order,E=ea.create(a[S].props.flag);return jn.is(E,2)||jn.is(E,4)?1:3===A?p?0:m?4:5:d&&jn.is(E,16)?7:2!==A||p?0:m?2:3},radius:S=>(S=>{const A=a[S];return i.aUnit=e.unitMap.get(A.unitA),i.aIndex=A.indexA,i.bUnit=e.unitMap.get(A.unitB),i.bIndex=A.indexB,t.size.size(i)*c})(S)*u,ignore:Lfe(e,n),stub:g}}function Gft(e,t,n,r,i){if(!t.interUnitBonds.edgeCount)return oc.createEmpty(i);const o=jfe(t,n,r),{cylinders:s,boundingSphere:a}=Jle(0,o,r,i);if(a)s.setBoundingSphere(a);else if(s.cylinderCount>0){const{child:c}=t,u=_e.expand(_e(),(c??t).boundary.sphere,1*r.sizeFactor);s.setBoundingSphere(u)}return s}function jft(e,t,n,r,i){if(!t.interUnitBonds.edgeCount)return Nt.createEmpty(i);const o=jfe(t,n,r),{mesh:s,boundingSphere:a}=B0(0,o,r,i);if(a)s.setBoundingSphere(a);else if(s.triangleCount>0){const{child:c}=t,u=_e.expand(_e(),(c??t).boundary.sphere,1*r.sizeFactor);s.setBoundingSphere(u)}return s}const b3={...n1,...kat,...BV,sizeFactor:C.Numeric(.3,{min:0,max:10,step:.01}),sizeAspectRatio:C.Numeric(2/3,{min:0,max:3,step:.01}),tryUseImpostor:C.Boolean(!0),includeParent:C.Boolean(!1)};function Hfe(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth?function Hft(e){return function Nat(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:oc.Utils},t)}({defaultProps:C.getDefaultValues(b3),createGeometry:Gft,createLocationIterator:(t,n)=>Um.fromStructure(t,{includeLocation2:"interpolate"===n.colorMode}),getLoci:VV,eachLocation:GV,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.sizeAspectRatio!==r.sizeAspectRatio||n.linkScale!==r.linkScale||n.linkSpacing!==r.linkSpacing||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.linkCap!==r.linkCap||n.aromaticScale!==r.aromaticScale||n.aromaticSpacing!==r.aromaticSpacing||n.aromaticDashCount!==r.aromaticDashCount||n.dashCount!==r.dashCount||n.dashScale!==r.dashScale||n.dashCap!==r.dashCap||n.stubCap!==r.stubCap||!Wa(n.includeTypes,r.includeTypes)||!Wa(n.excludeTypes,r.excludeTypes)||n.adjustCylinderLength!==r.adjustCylinderLength||n.multipleBonds!==r.multipleBonds,n.colorMode!==r.colorMode&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0),s.interUnitBonds!==a.interUnitBonds&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0)},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function qft(e){return rh({defaultProps:C.getDefaultValues(b3),createGeometry:jft,createLocationIterator:t=>Um.fromStructure(t),getLoci:VV,eachLocation:GV,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.sizeAspectRatio!==r.sizeAspectRatio||n.radialSegments!==r.radialSegments||n.linkScale!==r.linkScale||n.linkSpacing!==r.linkSpacing||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.linkCap!==r.linkCap||n.aromaticScale!==r.aromaticScale||n.aromaticSpacing!==r.aromaticSpacing||n.aromaticDashCount!==r.aromaticDashCount||n.dashCount!==r.dashCount||n.dashScale!==r.dashScale||n.dashCap!==r.dashCap||n.stubCap!==r.stubCap||!Wa(n.includeTypes,r.includeTypes)||!Wa(n.excludeTypes,r.excludeTypes)||n.adjustCylinderLength!==r.adjustCylinderLength||n.multipleBonds!==r.multipleBonds,s.interUnitBonds!==a.interUnitBonds&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0)},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}const Wft=ze.add3,$ft=ze.add;var d1;!function(e){e.create=function t(n=2048,r=1024,i){const o=ze.create(Float32Array,3,r,i?i.centerBuffer.ref.value:n),s=ze.create(Float32Array,1,r,i?i.groupBuffer.ref.value:n);return{add:(a,c,u,l)=>{Wft(o,a,c,u),$ft(s,l)},getSpheres:()=>{const a=ze.compact(o,!0),c=ze.compact(s,!0);return fl.create(a,c,o.elementCount,i)}}}}(d1||(d1={}));const f1=v.add;function H0(e,t,n){const{ignoreHydrogens:r,ignoreHydrogensVariant:i,traceOnly:o}=n,s=Ee.isCoarse(t),{child:a}=e,c=a?.unitMap.get(t.id);if(a&&!c)throw new Error("expected childUnit to exist if child exists");if(a||r||o)return u=>!!c&&!je.has(c.elements,u)||!s&&r&&md(e,t,u,i)||o&&!SU(t,u)}function Yft(e,t,n,r,i,o){const{child:s}=n,a=s?.unitMap.get(t.id);if(s&&!a)return Nt.createEmpty(o);const{detail:c,sizeFactor:u,stride:l}=i,{elements:d,conformation:f}=t,p=d.length,m=p*_v(c),h=at.createState(m,m/2,o),g=v(),y=H0(n,t,i),b=nt.create(n,t),x=r.size.size,_=v();let S=0,A=0;for(let I=0;IS&&(S=R),h.currentGroup=I,Zn(h,g,R*u,c)}const E=o?_e.clone(o.boundingSphere):void 0,w=at.getMesh(h);if(0===A)return w;let D;return v.scale(_,_,1/A),D=E&&v.distance(_,E.center)/E.radius<.1?E:_e.expand(_e(),(a??t).boundary.sphere,S*u+.05),w.setBoundingSphere(D),w}function Xft(e,t,n,r,i,o){const{child:s}=n,a=s?.unitMap.get(t.id);if(s&&!a)return fl.createEmpty(o);const{sizeFactor:c,stride:u}=i,{elements:l,conformation:d}=t,f=l.length,p=d1.create(f,f/2,o),m=v(),h=H0(n,t,i),g=nt.create(n,t),y=r.size.size,b=v();let x=0,_=0;if(u&&u>1||h||"uniform"!==r.size.granularity)for(let w=0;wx&&(x=D)}else{for(let w=0;wh&&(h=N),f.currentGroup=u(_,M),Zn(f,D,N*a,s)}}const y=i?_e.clone(i.boundingSphere):void 0,b=at.getMesh(f);if(0===g)return b;let x;return v.scale(m,m,1/g),x=y&&v.distance(m,y.center)/y.radius<1?y:_e.expand(_e(),(o??t).boundary.sphere,h*a+.05),b.setBoundingSphere(x),b}function Zft(e,t,n,r,i){const{child:o}=t,{sizeFactor:s,stride:a}=r,{getSerialIndex:c}=t.serialMapping,u=t.elementCount,l=d1.create(u,u/2,i),d=n.size.size,f=v();let p=0,m=0;for(const b of t.units){const x=o?.unitMap.get(b.id);if(o&&!x)return fl.createEmpty(i);const{elements:_,conformation:S}=b,A=_.length,E=v(),w=H0(t,b,r),D=nt.create(t,b);if(a&&a>1||w||"uniform"!==n.size.granularity)for(let I=0;Ip&&(p=T)}else{for(let I=0;I{const f=i.units[d];return c.unit=f,c.element=f.elements[l],c})},e.fromStructure=function n(r){const{units:i,elementCount:o}=r,s=o,{unitIndices:c,elementIndices:u}=r.serialMapping,l=nt.create(r);return Mr(s,1,1,f=>(l.unit=i[c[f]],l.element=u[f],l),!0)}}(gs||(gs={}));const qfe={sizeFactor:C.Numeric(1,{min:0,max:10,step:.1}),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),traceOnly:C.Boolean(!1),tryUseImpostor:C.Boolean(!0),stride:C.Numeric(1,{min:1,max:100,step:1})},v3={...hs,...CU,...qfe};function Wfe(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth&&r.extensions.textureFloat?function Qft(e){return wU({defaultProps:C.getDefaultValues(v3),createGeometry:Xft,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{t.createGeometry=n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.traceOnly!==r.traceOnly||n.stride!==r.stride},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function Jft(e){return Hs({defaultProps:C.getDefaultValues(v3),createGeometry:Yft,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.traceOnly!==r.traceOnly||n.stride!==r.stride},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}const $fe={...n1,...Mat,...qfe};function ept(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth&&r.extensions.textureFloat?function tpt(e){return function Rat(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:fl.Utils},t)}({defaultProps:C.getDefaultValues($fe),createGeometry:Zft,createLocationIterator:gs.fromStructure,getLoci:W0,eachLocation:q0,setUpdateState:(t,n,r)=>{t.createGeometry=n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.traceOnly!==r.traceOnly||n.stride!==r.stride},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function npt(e){return rh({defaultProps:C.getDefaultValues($fe),createGeometry:Kft,createLocationIterator:gs.fromStructure,getLoci:W0,eachLocation:q0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.traceOnly!==r.traceOnly||n.stride!==r.stride},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}const Yfe={"element-sphere":(e,t)=>vi("Element sphere",e,t,Wfe),"intra-bond":(e,t)=>vi("Intra-unit bond cylinder",e,t,Vfe),"inter-bond":(e,t)=>Iu("Inter-unit bond cylinder",e,t,Hfe)},qV={...v3,traceOnly:C.Boolean(!1,{isHidden:!0}),...y3,...b3,includeParent:C.Boolean(!1),unitKinds:oC(["atomic"]),sizeFactor:C.Numeric(.15,{min:.01,max:10,step:.01}),sizeAspectRatio:C.Numeric(2/3,{min:.01,max:3,step:.01}),visuals:C.MultiSelect(["element-sphere","intra-bond","inter-bond"],C.objectToOptions(Yfe)),bumpFrequency:C.Numeric(0,{min:0,max:10,step:.1},rt.ShadingCategory)},opt={name:"ball-and-stick",label:"Ball & Stick",description:"Displays atoms as spheres and bonds as cylinders.",factory:function ipt(e,t){return yn.createMulti("Ball & Stick",e,t,ms,Yfe)},getParams:function rpt(e,t){if(Ve.getSize(t)>=Ve.Size.Huge){const r=C.clone(qV);return r.visuals.defaultValue=["element-sphere","intra-bond"],r}return qV},defaultValues:C.getDefaultValues(qV),defaultColorTheme:{name:"element-symbol"},defaultSizeTheme:{name:"physical"},isApplicable:e=>e.elementCount>0,getData:(e,t)=>t.includeParent?e.asParent():e,mustRecreate:(e,t)=>e.includeParent!==t.includeParent};function spt(e,t,n,r,i){const{links:o,elements:s}=t.carbohydrates,{linkSizeFactor:a}=r,c=nt.create(t),u={linkCount:o.length,position:(f,p,m)=>{const h=o[m];v.copy(f,s[h.carbohydrateIndexA].geometry.center),v.copy(p,s[h.carbohydrateIndexB].geometry.center)},radius:f=>{const m=s[o[f].carbohydrateIndexA],h=m.unit.rings.all[m.ringIndex];return c.unit=m.unit,c.element=m.unit.elements[h[0]],n.size.size(c)*a}},{mesh:l,boundingSphere:d}=B0(0,u,r,i);if(d)l.setBoundingSphere(d);else if(l.triangleCount>0){const f=_e.expand(_e(),t.boundary.sphere,1*a);l.setBoundingSphere(f)}return l}const Xfe={...hs,...F0,linkSizeFactor:C.Numeric(.3,{min:0,max:3,step:.01})};function apt(e){return rh({defaultProps:C.getDefaultValues(Xfe),createGeometry:spt,createLocationIterator:cpt,getLoci:upt,eachLocation:lpt,setUpdateState:(t,n,r)=>{t.createGeometry=n.linkSizeFactor!==r.linkSizeFactor||n.radialSegments!==r.radialSegments||n.linkCap!==r.linkCap}},e)}function cpt(e){const{elements:t,links:n}=e.carbohydrates,r=n.length,o=nt.create(e);return Mr(r,1,1,a=>{const u=t[n[a].carbohydrateIndexA],l=u.unit.rings.all[u.ringIndex];return o.unit=u.unit,o.element=u.unit.elements[l[0]],o},!0)}function upt(e,t,n){const{objectId:r,groupId:i}=e;if(n===r){const{links:o,elements:s}=t.carbohydrates,a=o[i],c=s[a.carbohydrateIndexA],u=s[a.carbohydrateIndexB];return De.union(iC(t,c.unit,c.residueIndex,c.altId),iC(t,u.unit,u.residueIndex,u.altId))}return $n}const WV=new Set;function lpt(e,t,n){let r=!1;if(!De.is(e)||!Ve.areEquivalent(e.structure,t))return!1;const{getLinkIndices:i}=t.carbohydrates;for(const{unit:o,indices:s}of e.elements)Ee.isAtomic(o)&&(WV.clear(),Fe.forEach(s,a=>{const c=i(o,o.elements[a]);for(let u=0,l=c.length;u{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail}},e)}function kpt(e){const t=e.carbohydrates.elements,n=2*t.length,i=nt.create(e);return Mr(n,1,1,function o(a,c){const u=t[Math.floor(a/2)],l=u.unit.rings.all[u.ringIndex];return i.unit=u.unit,i.element=u.unit.elements[l[0]],i},!0,function s(a,c){return a%2==1})}function Npt(e,t,n){const{objectId:r,groupId:i}=e;if(n===r){const o=t.carbohydrates.elements[Math.floor(i/2)];return iC(t,o.unit,o.residueIndex,o.altId)}return $n}const iz=new Set;function Fpt(e,t,n){const{getElementIndices:r}=t.carbohydrates;let i=!1;if(!De.is(e)||!Ve.areEquivalent(e.structure,t))return!1;for(const{unit:o,indices:s}of e.elements)Ee.isAtomic(o)&&(iz.clear(),Fe.forEach(s,a=>{const c=r(o,o.elements[a]);for(let u=0,l=c.length;u{const h=o[m];h.fromCarbohydrate?(v.copy(f,s[h.carbohydrateIndex].geometry.center),h.elementUnit.conformation.position(h.elementUnit.elements[h.elementIndex],p)):(h.elementUnit.conformation.position(h.elementUnit.elements[h.elementIndex],f),v.copy(p,s[h.carbohydrateIndex].geometry.center))},radius:f=>{const p=o[f];if(p.fromCarbohydrate){const m=s[p.carbohydrateIndex],h=m.unit.rings.all[m.ringIndex];c.unit=m.unit,c.element=m.unit.elements[h[0]]}else c.unit=p.elementUnit,c.element=p.elementUnit.elements[p.elementIndex];return n.size.size(c)*a},style:f=>{const p=o[f],h=Qd(p.elementUnit.model.atomicHierarchy.atoms.type_symbol.value(p.elementUnit.elements[p.elementIndex]));return d2.has(h)?1:0}},{mesh:l,boundingSphere:d}=B0(0,u,r,i);if(d)l.setBoundingSphere(d);else if(l.triangleCount>0){const f=_e.expand(_e(),t.boundary.sphere,1*a);l.setBoundingSphere(f)}return l}const ope={...hs,...F0,terminalLinkSizeFactor:C.Numeric(.2,{min:0,max:3,step:.01})};function Opt(e){return rh({defaultProps:C.getDefaultValues(ope),createGeometry:Bpt,createLocationIterator:Lpt,getLoci:Upt,eachLocation:Vpt,setUpdateState:(t,n,r)=>{t.createGeometry=n.terminalLinkSizeFactor!==r.terminalLinkSizeFactor||n.radialSegments!==r.radialSegments||n.linkCap!==r.linkCap}},e)}function Lpt(e){const{elements:t,terminalLinks:n}=e.carbohydrates,r=n.length,o=nt.create(e);return Mr(r,1,1,a=>{const c=n[a];if(c.fromCarbohydrate){const u=t[c.carbohydrateIndex],l=u.unit.rings.all[u.ringIndex];o.unit=u.unit,o.element=u.unit.elements[l[0]]}else o.unit=c.elementUnit,o.element=c.elementUnit.elements[c.elementIndex];return o},!0)}function Upt(e,t,n){const{objectId:r,groupId:i}=e;if(n===r){const{terminalLinks:o,elements:s}=t.carbohydrates,a=o[i],c=s[a.carbohydrateIndex];return De.union(iC(t,c.unit,c.residueIndex,c.altId),function xat(e,t,n){const{elements:r,model:i}=t,{label_alt_id:o}=i.atomicHierarchy.atoms,s=o.value(n);if(-1!==Fe.indexOf(r,n)){const{index:a}=i.atomicHierarchy.residueAtomSegments;return iC(e,t,a[n],s)}return De(e,[])}(t,a.elementUnit,a.elementUnit.elements[a.elementIndex]))}return $n}const oz=new Set;function Vpt(e,t,n){let r=!1;if(!De.is(e)||!Ve.areEquivalent(e.structure,t))return!1;const{getTerminalLinkIndices:i}=t.carbohydrates;for(const{unit:o,indices:s}of e.elements)Ee.isAtomic(o)&&(oz.clear(),Fe.forEach(s,a=>{const c=i(o,o.elements[a]);for(let u=0,l=c.length;uIu("Carbohydrate symbol mesh",e,t,Rpt),"carbohydrate-link":(e,t)=>Iu("Carbohydrate link cylinder",e,t,apt),"carbohydrate-terminal-link":(e,t)=>Iu("Carbohydrate terminal link cylinder",e,t,Opt)},ape={...ipe,...Xfe,...ope,visuals:C.MultiSelect(["carbohydrate-symbol","carbohydrate-link","carbohydrate-terminal-link"],C.objectToOptions(spe)),bumpFrequency:C.Numeric(0,{min:0,max:10,step:.1},rt.ShadingCategory)},jpt={name:"carbohydrate",label:"Carbohydrate",description:"Displays carbohydrate symbols (3D SNFG).",factory:function Gpt(e,t){return yn.createMulti("Carbohydrate",e,t,ms,spe)},getParams:function zpt(e,t){return ape},defaultValues:C.getDefaultValues(ape),defaultColorTheme:{name:"carbohydrate-symbol"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.models.some(t=>sn.hasCarbohydrate(t))};function cpe(e,t){switch(e.kind){case 0:return function Hpt(e,t){const n=e.model.atomicRanges.cyclicPolymerMap,r=wr.transientSegments(AC(e),e.elements),i=en.transientSegments(e.model.atomicHierarchy.residueAtomSegments,e.elements),o=e.model.atomicHierarchy.derived.residue.traceElementIndex,{moleculeType:s}=e.model.atomicHierarchy.derived.residue;let a=-1,c=-1,u=!0,l=-1,d=0;for(;r.hasNext;){for(u=!0,l=d,i.setSegment(r.move());i.hasNext;){if(u){const p=i.move().index;if(++d,!i.hasNext)continue;u=!1,c=p}a=c,c=i.move().index,t(o[a],o[c],d-1,d,s[a]),++d}n.has(c)&&(a=c,c=n.get(a),t(o[a],o[c],d-1,l,s[a]))}}(e,t);case 1:case 2:return function qpt(e,t){const n=wr.transientSegments(AC(e),e.elements),{elements:r}=e;let i=!0,o=0;for(;n.hasNext;){i=!0;const s=n.move();for(let u=s.start,l=s.end;ul)continue;i=!1}t(r[u-1],r[u],o-1,o,0),++o}}}(e,t)}}function upe(e,t){switch(e.kind){case 0:return function Wpt(e,t){const n=wr.transientSegments(AC(e),e.elements),r=en.transientSegments(e.model.atomicHierarchy.residueAtomSegments,e.elements),i=e.model.atomicHierarchy.derived.residue.traceElementIndex;let o=0;for(;n.hasNext;)for(r.setSegment(n.move());r.hasNext;)t(i[r.move().index],o),++o}(e,t);case 1:case 2:return function $pt(e,t){const n=wr.transientSegments(AC(e),e.elements),{elements:r}=e;let i=0;for(;n.hasNext;){const o=n.move();for(let c=o.start,u=o.end;c({}),isApplicable:e=>!0,obtain:function(){var e=ie(function*(t,n){return{value:Zpt(n)}});return function(n,r){return e.apply(this,arguments)}}()});function Cd(e){return cr.is(e,2)}function az(e,t,n={}){switch(e.kind){case 0:return new Jpt(e,t,n);case 1:case 2:return new eht(e,t)}}const S3=cr.create(536870912);function dpe(e,t){return{center:nt.create(e,t),centerPrev:nt.create(e,t),centerNext:nt.create(e,t),first:!1,last:!1,initial:!1,final:!1,secStrucFirst:!1,secStrucLast:!1,secStrucType:S3,moleculeType:0,coarseBackboneFirst:!1,coarseBackboneLast:!1,isCoarseBackbone:!1,p0:v(),p1:v(),p2:v(),p3:v(),p4:v(),d12:v(),d23:v()}}const on=v(),C3=v(),w3=v();class Jpt{atomicPos(t,n){-1!==n&&(t[0]=this.atomicConformation.x[n],t[1]=this.atomicConformation.y[n],t[2]=this.atomicConformation.z[n])}pos(t,n,r){const i=this.traceElementIndex[n];this.helixOrientationCenters&&Cd(r)?v.fromArray(t,this.helixOrientationCenters,3*n):this.atomicPos(t,i)}updateResidueSegmentRange(t){const{index:n}=this.residueAtomSegments;this.residueSegmentMin=n[this.polymerRanges[2*t.index]],this.residueSegmentMax=n[this.polymerRanges[2*t.index+1]]}getResidueIndex(t){if(tthis.residueSegmentMax){const n=this.cyclicPolymerMap.get(this.residueSegmentMax);t=void 0!==n?n+(t-this.residueSegmentMax-1):this.residueSegmentMax}return t}getSecStruc(t){if(this.secondaryStructure){const{type:n,getIndex:r}=this.secondaryStructure,i=n[r(t)];return Cd(i)?2:i}return S3}setControlPoint(t,n,r,i,o){(function Qpt(e){return cr.is(e,4)})(o)||this.helixOrientationCenters&&Cd(o)?v.scale(t,v.add(t,n,v.add(t,i,v.add(t,r,r))),1/4):v.copy(t,r)}setFromToVector(t,n,r){this.value.isCoarseBackbone||this.helixOrientationCenters&&Cd(r)?v.set(t,1,0,0):(this.atomicPos(C3,this.directionFromElementIndex[n]),this.atomicPos(w3,this.directionToElementIndex[n]),v.sub(t,w3,C3))}setDirection(t,n,r,i){v.matchDirection(C3,n,r),v.matchDirection(w3,i,r),v.scale(t,v.add(t,C3,v.add(t,w3,v.add(t,r,r))),1/4)}move(){const{residueIt:t,polymerIt:n,value:r}=this;if(0===this.state)for(;n.hasNext;)if(this.polymerSegment=n.move(),t.setSegment(this.polymerSegment),this.updateResidueSegmentRange(this.polymerSegment),t.hasNext){this.state=1;const i=this.residueAtomSegments.index[this.unit.elements[this.polymerSegment.start]],o=this.getResidueIndex(i-1);this.currSecStrucType=i===o?S3:this.getSecStruc(o),this.nextSecStrucType=this.getSecStruc(i),this.currCoarseBackbone=-1===this.directionFromElementIndex[o]||-1===this.directionToElementIndex[o],this.nextCoarseBackbone=-1===this.directionFromElementIndex[i]||-1===this.directionToElementIndex[i];break}if(1===this.state){const{index:i}=t.move(),o=this.getResidueIndex(i-3),s=this.getResidueIndex(i-2),a=this.getResidueIndex(i-1),c=this.getResidueIndex(i+1),u=this.getResidueIndex(i+2),l=this.getResidueIndex(i+3);this.prevSecStrucType=this.getSecStruc(a),this.currSecStrucType=this.getSecStruc(i),this.nextSecStrucType=i===c?S3:this.getSecStruc(c),this.prevCoarseBackbone=this.currCoarseBackbone,this.currCoarseBackbone=this.nextCoarseBackbone,this.nextCoarseBackbone=-1===this.directionFromElementIndex[c]||-1===this.directionToElementIndex[c],r.secStrucType=this.currSecStrucType,r.secStrucFirst=this.prevSecStrucType!==this.currSecStrucType,r.secStrucLast=this.currSecStrucType!==this.nextSecStrucType,r.isCoarseBackbone=this.currCoarseBackbone,r.coarseBackboneFirst=this.prevCoarseBackbone!==this.currCoarseBackbone,r.coarseBackboneLast=this.currCoarseBackbone!==this.nextCoarseBackbone,r.first=i===this.residueSegmentMin,r.last=i===this.residueSegmentMax,r.moleculeType=this.moleculeType[i],r.initial=i===a,r.final=i===c,r.centerPrev.element=this.traceElementIndex[a],r.center.element=this.traceElementIndex[i],r.centerNext.element=this.traceElementIndex[c];const d=this.getSecStruc(o),f=this.getSecStruc(s),p=this.getSecStruc(a),m=this.getSecStruc(i),h=this.getSecStruc(c),g=this.getSecStruc(u),y=this.getSecStruc(l);this.pos(this.p0,o,d),this.pos(this.p1,s,f),this.pos(this.p2,a,p),this.pos(this.p3,i,m),this.pos(this.p4,c,h),this.pos(this.p5,u,g),this.pos(this.p6,l,y);const b=Cd(d),x=Cd(f),_=Cd(p),S=Cd(m),A=Cd(h),E=Cd(g),w=Cd(y);this.helixOrientationCenters&&(S!==_?S?(v.copy(this.p0,this.p3),v.copy(this.p1,this.p3),v.copy(this.p2,this.p3)):_&&(v.scale(on,v.sub(on,this.p2,this.p3),2),v.add(this.p2,this.p3,on),v.add(this.p1,this.p2,on),v.add(this.p0,this.p1,on)):S!==x?S?(v.copy(this.p0,this.p2),v.copy(this.p1,this.p2)):x&&(v.scale(on,v.sub(on,this.p1,this.p2),2),v.add(this.p1,this.p2,on),v.add(this.p0,this.p1,on)):S!==b&&(S?v.copy(this.p0,this.p1):b&&(v.scale(on,v.sub(on,this.p0,this.p1),2),v.add(this.p0,this.p1,on))),S!==A?S?(v.copy(this.p4,this.p3),v.copy(this.p5,this.p3),v.copy(this.p6,this.p3)):A&&(v.scale(on,v.sub(on,this.p4,this.p3),2),v.add(this.p4,this.p3,on),v.add(this.p5,this.p4,on),v.add(this.p6,this.p5,on)):S!==E?S?(v.copy(this.p5,this.p4),v.copy(this.p6,this.p4)):E&&(v.scale(on,v.sub(on,this.p5,this.p4),2),v.add(this.p5,this.p4,on),v.add(this.p6,this.p5,on)):S!==w&&(S?v.copy(this.p6,this.p5):w&&(v.scale(on,v.sub(on,this.p6,this.p5),2),v.add(this.p6,this.p5,on)))),this.setFromToVector(this.d01,a,p),this.setFromToVector(this.d12,i,m),this.setFromToVector(this.d23,c,h),this.setFromToVector(this.d34,u,g);const D=S&&this.helixOrientationCenters,I=1.5;i===a||m!==p&&D?(v.setMagnitude(on,v.sub(on,this.p3,this.p4),I),v.add(this.p2,this.p3,on),v.add(this.p1,this.p2,on),v.add(this.p0,this.p1,on)):a===s||m!==f&&D?(v.setMagnitude(on,v.sub(on,this.p2,this.p3),I),v.add(this.p1,this.p2,on),v.add(this.p0,this.p1,on)):(s===o||m!==d&&D)&&(v.setMagnitude(on,v.sub(on,this.p1,this.p2),I),v.add(this.p0,this.p1,on)),i===c||m!==h&&D?(v.setMagnitude(on,v.sub(on,this.p3,this.p2),I),v.add(this.p4,this.p3,on),v.add(this.p5,this.p4,on),v.add(this.p6,this.p5,on)):c===u||m!==g&&D?(v.setMagnitude(on,v.sub(on,this.p4,this.p3),I),v.add(this.p5,this.p4,on),v.add(this.p6,this.p5,on)):(u===l||m!==y&&D)&&(v.setMagnitude(on,v.sub(on,this.p5,this.p4),I),v.add(this.p6,this.p5,on)),this.setControlPoint(r.p0,this.p0,this.p1,this.p2,f),this.setControlPoint(r.p1,this.p1,this.p2,this.p3,p),this.setControlPoint(r.p2,this.p2,this.p3,this.p4,m),this.setControlPoint(r.p3,this.p3,this.p4,this.p5,h),this.setControlPoint(r.p4,this.p4,this.p5,this.p6,g),this.setDirection(r.d12,this.d01,this.d12,this.d23),this.setDirection(r.d23,this.d12,this.d23,this.d34),t.hasNext||(this.state=0)}return this.hasNext=t.hasNext||n.hasNext,this.value}constructor(t,n,r={}){var i;if(this.unit=t,this.state=0,this.p0=v(),this.p1=v(),this.p2=v(),this.p3=v(),this.p4=v(),this.p5=v(),this.p6=v(),this.d01=v(),this.d12=v(),this.d23=v(),this.d34=v(),this.hasNext=!1,this.atomicConformation=t.model.atomicConformation,this.residueAtomSegments=t.model.atomicHierarchy.residueAtomSegments,this.polymerRanges=t.model.atomicRanges.polymerRanges,this.traceElementIndex=t.model.atomicHierarchy.derived.residue.traceElementIndex,this.directionFromElementIndex=t.model.atomicHierarchy.derived.residue.directionFromElementIndex,this.directionToElementIndex=t.model.atomicHierarchy.derived.residue.directionToElementIndex,this.moleculeType=t.model.atomicHierarchy.derived.residue.moleculeType,this.cyclicPolymerMap=t.model.atomicRanges.cyclicPolymerMap,this.polymerIt=wr.transientSegments(this.polymerRanges,t.elements),this.residueIt=en.transientSegments(this.residueAtomSegments,t.elements),this.value=dpe(n,t),this.hasNext=this.residueIt.hasNext&&this.polymerIt.hasNext,r.ignoreSecondaryStructure||(this.secondaryStructure=null===(i=Xu.get(n).value)||void 0===i?void 0:i.get(t.invariantId)),r.useHelixOrientation){const o=sz.get(t.model).value;if(!o)throw new Error("missing helix-orientation");this.helixOrientationCenters=o.centers}}}class eht{getElementIndex(t){return Math.min(Math.max(this.polymerSegment.start,t),this.polymerSegment.end-1)}pos(t,n){const r=this.unit.elements[n];t[0]=this.conformation.x[r],t[1]=this.conformation.y[r],t[2]=this.conformation.z[r]}move(){if(0===this.state)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)){a=u;break}}if(s<0)return!1;let c=s;for(let u=o;u>a;u--){const l=n[u];if(l<0)continue;const d=Fe.indexOf(t,l);if(d>=0){c=d;break}}return r(Ce.ofRange(e+s,e+c))}function xpe(e,t,n,r,i){let o=!1;const{elements:s}=i.unit,{traceElementIndex:a}=i.unit.model.atomicHierarchy.derived.residue,{index:c}=i.unit.model.atomicHierarchy.residueAtomSegments,u=n(i.unit);if(Ce.is(i.indices))o=0===Ce.start(i.indices)&&Ce.end(i.indices)===i.unit.elements.length?r(Ce.ofBounds(e,e+t))||o:_pe(e,u,a,r,c[s[Ce.min(i.indices)]],c[s[Ce.max(i.indices)]])||o;else{const{indices:l}=i;for(let d=0,f=l.length;d1)break;m=g,h++}d=h-1,o=_pe(e,u,a,r,p,m)||o}}return o}function uht(e){return e.polymerElements}function X0(e,t,n){let r=!1;if(!De.is(e))return!1;const{structure:i,group:o}=t;if(!Ve.areEquivalent(e.structure,i))return!1;const s=o.units[0].polymerElements.length;for(const a of e.elements){if(!o.unitIndexMap.has(a.unit.id))continue;const c=o.unitIndexMap.get(a.unit.id)*s;if(Ee.isAtomic(a.unit))r=xpe(c,s,uht,n,a)||r;else if(Ce.is(a.indices)){const u=c+Ce.start(a.indices),l=c+Ce.end(a.indices);r=n(Ce.ofBounds(u,l))||r}else for(let u=0,l=a.indices.length;u{const l=Fe.indexOf(a.unit.gapElements,a.unit.elements[u]);-1!==l&&n(Ce.ofSingleton(c*s+l))&&(r=!0)})}}return r}function K0(e,t,n){const{objectId:r,instanceId:i,groupId:o}=e;if(n===r){const{structure:s,group:a}=t,c=a.units[i];if(Ee.isAtomic(c))return Lle(s,c,c.nucleotideElements[o])}return $n}function fht(e){return e.nucleotideElements}function Z0(e,t,n){let r=!1;if(!De.is(e))return!1;const{structure:i,group:o}=t;if(!Ve.areEquivalent(e.structure,i))return!1;const s=o.units[0];if(!Ee.isAtomic(s))return!1;const{nucleotideElements:a}=s,c=a.length;for(const u of e.elements){if(!Ee.isAtomic(u.unit)||!o.unitIndexMap.has(u.unit.id))continue;const l=o.unitIndexMap.get(u.unit.id)*c;Ee.isAtomic(u.unit)&&(r=xpe(l,c,fht,n,u)||r)}return r}!function(e){e.fromGroup=function t(n,r){const{group:i,structure:o}=n,s=i.units[0].polymerElements,a=s.length,c=i.units.length,u=nt.create(o),d=!!r?.asSecondary;return Mr(a,c,1,(p,m)=>(u.unit=i.units[m],u.element=s[p],u),!1,function f(p,m){return d})}}(lh||(lh={})),function(e){e.fromGroup=function t(n){const{group:r,structure:i}=n,o=r.units[0].gapElements,s=o.length,a=r.units.length,c=nt.create(i);return Mr(s,a,1,(l,d)=>(c.unit=r.units[d],c.element=o[l],c))}}(yz||(yz={})),function(e){e.fromGroup=function t(n){const{group:r,structure:i}=n,o=r.units[0],s=Ee.isAtomic(o)?o.nucleotideElements:[],a=s.length,c=r.units.length,u=nt.create(i);return Mr(a,c,1,(d,f)=>(u.unit=r.units[f],u.element=s[d],u))}}(dh||(dh={}));const pht=v(),hht=v();function Q0(e,t){const{model:n,conformation:r}=e,{residueAtomSegments:i,atoms:o,index:s}=n.atomicHierarchy,{label_comp_id:a}=o,c=a.value(i.offsets[t]);let u=rFe(c),l=iFe(c);if(!u&&!l){const d=s.findAtomOnResidue(t,"C4"),f=s.findAtomOnResidue(t,"N9");-1!==d&&-1!==f&&v.distance(r.invariantPosition(d,pht),r.invariantPosition(f,hht))<1.6?u=!0:l=!0}return{isPurine:u,isPyrimidine:l}}function ey(e,t,n){const r=t.model.atomicHierarchy.index,{traceElementIndex:i}=t.model.atomicHierarchy.derived.residue;return e.trace=i[n],e.N1=r.findAtomOnResidue(n,"N1"),e.C2=r.findAtomOnResidue(n,"C2"),e.N3=r.findAtomOnResidue(n,"N3"),e.C4=r.findAtomOnResidue(n,"C4"),e.C5=r.findAtomOnResidue(n,"C5"),-1===e.C5&&(e.C5=r.findAtomOnResidue(n,"N5")),e.C6=r.findAtomOnResidue(n,"C6"),e.N7=r.findAtomOnResidue(n,"N7"),-1===e.N7&&(e.N7=r.findAtomOnResidue(n,"C7")),e.C8=r.findAtomOnResidue(n,"C8"),e.N9=r.findAtomOnResidue(n,"N9"),e}function g1(e){return-1!==e.trace&&-1!==e.N1&&-1!==e.C2&&-1!==e.N3&&-1!==e.C4&&-1!==e.C5&&-1!==e.C6&&-1!==e.N7&&-1!==e.C8&&-1!==e.N9}function ty(e,t,n){const r=t.model.atomicHierarchy.index,{traceElementIndex:i}=t.model.atomicHierarchy.derived.residue;return e.trace=i[n],e.N1=r.findAtomOnResidue(n,"N1"),-1===e.N1&&(e.N1=r.findAtomOnResidue(n,"C1")),e.C2=r.findAtomOnResidue(n,"C2"),e.N3=r.findAtomOnResidue(n,"N3"),e.C4=r.findAtomOnResidue(n,"C4"),e.C5=r.findAtomOnResidue(n,"C5"),e.C6=r.findAtomOnResidue(n,"C6"),e}function y1(e){return-1!==e.trace&&-1!==e.N1&&-1!==e.C2&&-1!==e.N3&&-1!==e.C4&&-1!==e.C5&&-1!==e.C6}function IC(e,t,n){const r=t.model.atomicHierarchy.index,{traceElementIndex:i}=t.model.atomicHierarchy.derived.residue;return e.trace=i[n],e.C1_1=r.findAtomOnResidue(n,"C1'"),e.C2_1=r.findAtomOnResidue(n,"C2'"),e.C3_1=r.findAtomOnResidue(n,"C3'"),e.C4_1=r.findAtomOnResidue(n,"C4'"),e.O4_1=r.findAtomOnResidue(n,"O4'"),e}function TC(e){return-1!==e.trace&&-1!==e.C1_1&&-1!==e.C2_1&&-1!==e.C3_1&&-1!==e.C4_1&&-1!==e.O4_1}const E3=v(),bz=v(),Spe=v(),Cpe=v(),wpe=v(),Ape=v(),P3=v(),vz=v(),_z=v(),Ipe=v(),DC=le.identity(),mht=v(),Tpe=S5(),Dpe={sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),thicknessFactor:C.Numeric(1,{min:0,max:2,step:.01}),radialSegments:C.Numeric(16,{min:2,max:56,step:2},rt.CustomQualityParamInfo)};function ght(e,t,n,r,i,o){if(!Ee.isAtomic(t))return Nt.createEmpty(o);const s=t.nucleotideElements.length;if(!s)return Nt.createEmpty(o);const{sizeFactor:a,thicknessFactor:c,radialSegments:u}=i,l=s*(Tpe.vertices.length/3+2*u),d=at.createState(l,l/4,o),{elements:f,model:p,conformation:m}=t,{chainAtomSegments:h,residueAtomSegments:g}=p.atomicHierarchy,{moleculeType:y}=p.atomicHierarchy.derived.residue,b=en.transientSegments(h,f),x=en.transientSegments(g,f),_=1*a,A=c*a*2,E={radiusTop:_,radiusBottom:_,radialSegments:u,bottomCap:!0};let w=0;for(;b.hasNext;)for(x.setSegment(b.move());x.hasNext;){const{index:R}=x.move();if(Ya(y[R])){const T={trace:-1,N1:-1,C2:-1,N3:-1,C4:-1,C5:-1,C6:-1,N7:-1,C8:-1,N9:-1,C1_1:-1,C2_1:-1,C3_1:-1,C4_1:-1,O4_1:-1};let M=-1,N=-1,V=-1,F=-1,G=-1,L=4.5;const{isPurine:z,isPyrimidine:j}=Q0(t,R);z?(L=4.5,ey(T,t,R),M=T.N1,N=T.C4,V=T.C6,F=T.C2,G=T.N9):j&&(L=3,ty(T,t,R),M=T.N3,N=T.C6,V=T.C4,F=T.C2,G=T.N1),-1!==G&&-1!==T.trace&&(m.invariantPosition(G,wpe),m.invariantPosition(T.trace,Ape),d.currentGroup=w,Hn(d,wpe,Ape,1,E),-1!==M&&-1!==N&&-1!==V&&-1!==F&&(m.invariantPosition(M,E3),m.invariantPosition(N,bz),m.invariantPosition(V,Spe),m.invariantPosition(F,Cpe),v.normalize(P3,v.sub(P3,bz,E3)),v.normalize(vz,v.sub(vz,Cpe,Spe)),v.normalize(_z,v.cross(_z,P3,vz)),le.targetTo(DC,E3,bz,_z),v.scaleAndAdd(Ipe,E3,P3,L/2-.2),le.scale(DC,DC,v.set(mht,4.5,A,L)),le.setTranslation(DC,Ipe),at.addPrimitive(d,DC,Tpe))),++w}}const D=at.getMesh(d),I=_e.expand(_e(),t.boundary.sphere,_);return D.setBoundingSphere(I),D}C.getDefaultValues(Dpe);const Epe={...hs,...Dpe};function yht(e){return Hs({defaultProps:C.getDefaultValues(Epe),createGeometry:ght,createLocationIterator:dh.fromGroup,getLoci:K0,eachLocation:Z0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.thicknessFactor!==r.thicknessFactor||n.radialSegments!==r.radialSegments}},e)}const M3=v(),jm=v(),R3=v(),k3=v(),b1=v(),v1=v(),N3=v(),Ppe=v(),Mpe=v(),F3=v(),Hm=v(),Rpe={sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),thicknessFactor:C.Numeric(1,{min:0,max:2,step:.01}),radialSegments:C.Numeric(16,{min:2,max:56,step:2},rt.CustomQualityParamInfo),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo)},B3=(C.getDefaultValues(Rpe),new Float32Array(54)),bht=new Uint32Array([0,1,2,3,4,5,6,7,16,17,14,15,12,13,8,9,10,11,0,1]),vht=new Uint32Array([8,12,14,16,6,4,2,0,10]),_ht=new Uint32Array([9,11,1,3,5,7,17,15,13]),O3=new Float32Array(36),xht=new Uint32Array([0,1,2,3,4,5,6,7,8,9,10,11,0,1]),Sht=new Uint32Array([0,10,8,6,4,2]),Cht=new Uint32Array([1,3,5,7,9,11]),kpe=v();function Npe(e,t,...n){for(let r=0,i=n.length;r{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.thicknessFactor!==r.thicknessFactor||n.radialSegments!==r.radialSegments}},e)}const _1=v(),L3=v(),U3=v(),x1=v(),S1=v(),V3=v(),Bpe=v(),Ope=v(),Lpe=v(),z3=v(),xz=v(),G3=v(),j3=v(),Sz=v(),C1=v(),Ws=v(),w1=v(),Upe={sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),thicknessFactor:C.Numeric(1,{min:0,max:2,step:.01})},H3=(C.getDefaultValues(Upe),new Float32Array(54)),Iht=new Uint32Array([0,1,2,3,4,5,6,7,16,17,14,15,12,13,8,9,10,11,0,1]),Tht=new Uint32Array([8,12,14,16,6,4,2,0,10]),Dht=new Uint32Array([9,11,1,3,5,7,17,15,13]),q3=new Float32Array(36),Eht=new Uint32Array([2,3,4,5,6,7,8,9,10,11,2,3]),Pht=new Uint32Array([0,10,8,6,4,2,10]),Mht=new Uint32Array([1,3,5,7,9,11,3]),W3=new Float32Array(36),Rht=new Uint32Array([0,1,2,3,4,5,6,7,8,9,10,11,0,1]),kht=new Uint32Array([0,10,8,6,4,2]),Nht=new Uint32Array([1,3,5,7,9,11]),Vpe=v();function Cz(e,t,...n){for(let r=0,i=n.length;r{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.thicknessFactor!==r.thicknessFactor}},e)}const $s=v(),Kr=v(),ys=v(),bs=v(),fo=v(),po=v(),vs=v(),kf=v(),Nf=v(),Uo=v(),Vo=v(),Ff=v(),Gc=v(),Bf=v(),Of=v(),wz={...hs,...AU,sizeFactor:C.Numeric(.3,{min:0,max:10,step:.01}),radialSegments:C.Numeric(16,{min:2,max:56,step:2},rt.CustomQualityParamInfo),tryUseImpostor:C.Boolean(!0)};function Oht(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth?function Uht(e){return IU({defaultProps:C.getDefaultValues(wz),createGeometry:Lht,createLocationIterator:dh.fromGroup,getLoci:K0,eachLocation:Z0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function zht(e){return Hs({defaultProps:C.getDefaultValues(wz),createGeometry:Vht,createLocationIterator:dh.fromGroup,getLoci:K0,eachLocation:Z0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.radialSegments!==r.radialSegments},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}function Lht(e,t,n,r,i,o){if(!Ee.isAtomic(t))return oc.createEmpty(o);const s=t.nucleotideElements.length;if(!s)return oc.createEmpty(o);const a=15*s,c=aC.create(a,a/4,o),{elements:u,model:l,conformation:d}=t,{chainAtomSegments:f,residueAtomSegments:p}=l.atomicHierarchy,{moleculeType:m}=l.atomicHierarchy.derived.residue,h=en.transientSegments(f,u),g=en.transientSegments(p,u);let y=0;for(;h.hasNext;)for(g.setSegment(h.move());g.hasNext;){const{index:S}=g.move();if(Ya(m[S])){const A={trace:-1,N1:-1,C2:-1,N3:-1,C4:-1,C5:-1,C6:-1,N7:-1,C8:-1,N9:-1,C1_1:-1,C2_1:-1,C3_1:-1,C4_1:-1,O4_1:-1};IC(A,t,S),TC(A)&&(d.invariantPosition(A.C1_1,Vo),d.invariantPosition(A.C2_1,Ff),d.invariantPosition(A.C3_1,Gc),d.invariantPosition(A.C4_1,Bf),d.invariantPosition(A.O4_1,Of),d.invariantPosition(A.trace,$s),c.add(Gc[0],Gc[1],Gc[2],$s[0],$s[1],$s[2],1,!0,!0,2,y),c.add(Gc[0],Gc[1],Gc[2],Bf[0],Bf[1],Bf[2],1,!0,!0,2,y),c.add(Bf[0],Bf[1],Bf[2],Of[0],Of[1],Of[2],1,!0,!0,2,y),c.add(Of[0],Of[1],Of[2],Vo[0],Vo[1],Vo[2],1,!0,!0,2,y),c.add(Vo[0],Vo[1],Vo[2],Ff[0],Ff[1],Ff[2],1,!0,!0,2,y),c.add(Ff[0],Ff[1],Ff[2],Gc[0],Gc[1],Gc[2],1,!0,!0,2,y));const{isPurine:E,isPyrimidine:w}=Q0(t,S);E?(ey(A,t,S),-1!==A.C1_1&&-1!==A.N9?(d.invariantPosition(A.C1_1,Vo),d.invariantPosition(A.N9,Uo),c.add(Uo[0],Uo[1],Uo[2],Vo[0],Vo[1],Vo[2],1,!0,!0,2,y)):-1!==A.N9&&-1!==A.trace&&(d.invariantPosition(A.N9,Uo),d.invariantPosition(A.trace,$s),c.add(Uo[0],Uo[1],Uo[2],$s[0],$s[1],$s[2],1,!0,!0,2,y)),g1(A)&&(d.invariantPosition(A.N1,Kr),d.invariantPosition(A.C2,ys),d.invariantPosition(A.N3,bs),d.invariantPosition(A.C4,fo),d.invariantPosition(A.C5,po),d.invariantPosition(A.C6,vs),d.invariantPosition(A.N7,kf),d.invariantPosition(A.C8,Nf),d.invariantPosition(A.N9,Uo),c.add(Uo[0],Uo[1],Uo[2],Nf[0],Nf[1],Nf[2],1,!0,!0,2,y),c.add(Nf[0],Nf[1],Nf[2],kf[0],kf[1],kf[2],1,!0,!0,2,y),c.add(kf[0],kf[1],kf[2],po[0],po[1],po[2],1,!0,!0,2,y),c.add(po[0],po[1],po[2],vs[0],vs[1],vs[2],1,!0,!0,2,y),c.add(vs[0],vs[1],vs[2],Kr[0],Kr[1],Kr[2],1,!0,!0,2,y),c.add(Kr[0],Kr[1],Kr[2],ys[0],ys[1],ys[2],1,!0,!0,2,y),c.add(ys[0],ys[1],ys[2],bs[0],bs[1],bs[2],1,!0,!0,2,y),c.add(bs[0],bs[1],bs[2],fo[0],fo[1],fo[2],1,!0,!0,2,y),c.add(fo[0],fo[1],fo[2],po[0],po[1],po[2],1,!0,!0,2,y),c.add(fo[0],fo[1],fo[2],Uo[0],Uo[1],Uo[2],1,!0,!0,2,y))):w&&(ty(A,t,S),-1!==A.C1_1&&-1!==A.N1?(d.invariantPosition(A.N1,Kr),d.invariantPosition(A.C1_1,Vo),c.add(Kr[0],Kr[1],Kr[2],Vo[0],Vo[1],Vo[2],1,!0,!0,2,y)):-1!==A.N1&&-1!==A.trace&&(d.invariantPosition(A.N1,Kr),d.invariantPosition(A.trace,$s),c.add(Kr[0],Kr[1],Kr[2],$s[0],$s[1],$s[2],1,!0,!0,2,y)),y1(A)&&(d.invariantPosition(A.N1,Kr),d.invariantPosition(A.C2,ys),d.invariantPosition(A.N3,bs),d.invariantPosition(A.C4,fo),d.invariantPosition(A.C5,po),d.invariantPosition(A.C6,vs),c.add(Kr[0],Kr[1],Kr[2],vs[0],vs[1],vs[2],1,!0,!0,2,y),c.add(vs[0],vs[1],vs[2],po[0],po[1],po[2],1,!0,!0,2,y),c.add(po[0],po[1],po[2],fo[0],fo[1],fo[2],1,!0,!0,2,y),c.add(fo[0],fo[1],fo[2],bs[0],bs[1],bs[2],1,!0,!0,2,y),c.add(bs[0],bs[1],bs[2],ys[0],ys[1],ys[2],1,!0,!0,2,y),c.add(ys[0],ys[1],ys[2],Kr[0],Kr[1],Kr[2],1,!0,!0,2,y))),++y}}const x=c.getCylinders(),_=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return x.setBoundingSphere(_),x}function Vht(e,t,n,r,i,o){if(!Ee.isAtomic(t))return Nt.createEmpty(o);const s=t.nucleotideElements.length;if(!s)return Nt.createEmpty(o);const{sizeFactor:a,radialSegments:c}=i,u=s*(15*c),l=at.createState(u,u/4,o),{elements:d,model:f,conformation:p}=t,{chainAtomSegments:m,residueAtomSegments:h}=f.atomicHierarchy,{moleculeType:g}=f.atomicHierarchy.derived.residue,y=en.transientSegments(m,d),b=en.transientSegments(h,d),x={radiusTop:1*a,radiusBottom:1*a,radialSegments:c};let _=0;for(;y.hasNext;)for(b.setSegment(y.move());b.hasNext;){const{index:E}=b.move();if(Ya(g[E])){const w={trace:-1,N1:-1,C2:-1,N3:-1,C4:-1,C5:-1,C6:-1,N7:-1,C8:-1,N9:-1,C1_1:-1,C2_1:-1,C3_1:-1,C4_1:-1,O4_1:-1};l.currentGroup=_,IC(w,t,E),TC(w)&&(p.invariantPosition(w.C1_1,Vo),p.invariantPosition(w.C2_1,Ff),p.invariantPosition(w.C3_1,Gc),p.invariantPosition(w.C4_1,Bf),p.invariantPosition(w.O4_1,Of),p.invariantPosition(w.trace,$s),Hn(l,Gc,$s,1,x),Hn(l,Gc,Bf,1,x),Hn(l,Bf,Of,1,x),Hn(l,Of,Vo,1,x),Hn(l,Vo,Ff,1,x),Hn(l,Ff,Gc,1,x));const{isPurine:D,isPyrimidine:I}=Q0(t,E);D?(ey(w,t,E),-1!==w.C1_1&&-1!==w.N9?(p.invariantPosition(w.C1_1,Vo),p.invariantPosition(w.N9,Uo),Hn(l,Uo,Vo,1,x)):-1!==w.N9&&-1!==w.trace&&(p.invariantPosition(w.N9,Uo),p.invariantPosition(w.trace,$s),Hn(l,Uo,$s,1,x)),g1(w)&&(p.invariantPosition(w.N1,Kr),p.invariantPosition(w.C2,ys),p.invariantPosition(w.N3,bs),p.invariantPosition(w.C4,fo),p.invariantPosition(w.C5,po),p.invariantPosition(w.C6,vs),p.invariantPosition(w.N7,kf),p.invariantPosition(w.C8,Nf),p.invariantPosition(w.N9,Uo),Hn(l,Uo,Nf,1,x),Hn(l,Nf,kf,1,x),Hn(l,kf,po,1,x),Hn(l,po,vs,1,x),Hn(l,vs,Kr,1,x),Hn(l,Kr,ys,1,x),Hn(l,ys,bs,1,x),Hn(l,bs,fo,1,x),Hn(l,fo,po,1,x),Hn(l,fo,Uo,1,x))):I&&(ty(w,t,E),-1!==w.C1_1&&-1!==w.N1?(p.invariantPosition(w.N1,Kr),p.invariantPosition(w.C1_1,Vo),Hn(l,Kr,Vo,1,x)):-1!==w.N1&&-1!==w.trace&&(p.invariantPosition(w.N1,Kr),p.invariantPosition(w.trace,$s),Hn(l,Kr,$s,1,x)),y1(w)&&(p.invariantPosition(w.N1,Kr),p.invariantPosition(w.C2,ys),p.invariantPosition(w.N3,bs),p.invariantPosition(w.C4,fo),p.invariantPosition(w.C5,po),p.invariantPosition(w.C6,vs),Hn(l,Kr,vs,1,x),Hn(l,vs,po,1,x),Hn(l,po,fo,1,x),Hn(l,fo,bs,1,x),Hn(l,bs,ys,1,x),Hn(l,ys,Kr,1,x))),++_}}const S=at.getMesh(l),A=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return S.setBoundingSphere(A),S}const A1=v(),Cl=v(),wl=v(),Al=v(),Il=v(),Du=v(),Tl=v(),I1=v(),T1=v(),D1=v(),E1=v(),P1=v(),M1=v(),R1=v(),k1=v(),Az={...hs,...CU,sizeFactor:C.Numeric(.3,{min:0,max:10,step:.01}),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo),tryUseImpostor:C.Boolean(!0)};function Ght(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth?function Hht(e){return wU({defaultProps:C.getDefaultValues(Az),createGeometry:jht,createLocationIterator:dh.fromGroup,getLoci:K0,eachLocation:Z0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function Wht(e){return Hs({defaultProps:C.getDefaultValues(Az),createGeometry:qht,createLocationIterator:dh.fromGroup,getLoci:K0,eachLocation:Z0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}function jht(e,t,n,r,i,o){if(!Ee.isAtomic(t))return fl.createEmpty(o);const s=t.nucleotideElements.length;if(!s)return fl.createEmpty(o);const a=15*s,c=d1.create(a,a/4,o),{elements:u,model:l,conformation:d}=t,{chainAtomSegments:f,residueAtomSegments:p}=l.atomicHierarchy,{moleculeType:m}=l.atomicHierarchy.derived.residue,h=en.transientSegments(f,u),g=en.transientSegments(p,u);let y=0;for(;h.hasNext;)for(g.setSegment(h.move());g.hasNext;){const{index:_}=g.move();if(Ya(m[_])){const S={trace:-1,N1:-1,C2:-1,N3:-1,C4:-1,C5:-1,C6:-1,N7:-1,C8:-1,N9:-1,C1_1:-1,C2_1:-1,C3_1:-1,C4_1:-1,O4_1:-1};IC(S,t,_),TC(S)&&(d.invariantPosition(S.C1_1,E1),d.invariantPosition(S.C2_1,P1),d.invariantPosition(S.C3_1,M1),d.invariantPosition(S.C4_1,R1),d.invariantPosition(S.O4_1,k1),d.invariantPosition(S.trace,A1),c.add(A1[0],A1[1],A1[2],y),c.add(M1[0],M1[1],M1[2],y),c.add(R1[0],R1[1],R1[2],y),c.add(k1[0],k1[1],k1[2],y),c.add(E1[0],E1[1],E1[2],y),c.add(P1[0],P1[1],P1[2],y));const{isPurine:A,isPyrimidine:E}=Q0(t,_);A?(ey(S,t,_),g1(S)&&(d.invariantPosition(S.N1,Cl),d.invariantPosition(S.C2,wl),d.invariantPosition(S.N3,Al),d.invariantPosition(S.C4,Il),d.invariantPosition(S.C5,Du),d.invariantPosition(S.C6,Tl),d.invariantPosition(S.N7,I1),d.invariantPosition(S.C8,T1),d.invariantPosition(S.N9,D1),c.add(D1[0],D1[1],D1[2],y),c.add(T1[0],T1[1],T1[2],y),c.add(I1[0],I1[1],I1[2],y),c.add(Du[0],Du[1],Du[2],y),c.add(Tl[0],Tl[1],Tl[2],y),c.add(Cl[0],Cl[1],Cl[2],y),c.add(wl[0],wl[1],wl[2],y),c.add(Al[0],Al[1],Al[2],y),c.add(Il[0],Il[1],Il[2],y))):E&&(ty(S,t,_),y1(S)&&(d.invariantPosition(S.N1,Cl),d.invariantPosition(S.C2,wl),d.invariantPosition(S.N3,Al),d.invariantPosition(S.C4,Il),d.invariantPosition(S.C5,Du),d.invariantPosition(S.C6,Tl),c.add(Cl[0],Cl[1],Cl[2],y),c.add(Tl[0],Tl[1],Tl[2],y),c.add(Du[0],Du[1],Du[2],y),c.add(Il[0],Il[1],Il[2],y),c.add(Al[0],Al[1],Al[2],y),c.add(wl[0],wl[1],wl[2],y))),++y}}const b=c.getSpheres(),x=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return b.setBoundingSphere(x),b}function qht(e,t,n,r,i,o){if(!Ee.isAtomic(t))return Nt.createEmpty(o);const s=t.nucleotideElements.length;if(!s)return Nt.createEmpty(o);const{sizeFactor:a,detail:c}=i,u=s*_v(c),l=at.createState(u,u/2,o),{elements:d,model:f,conformation:p}=t,{chainAtomSegments:m,residueAtomSegments:h}=f.atomicHierarchy,{moleculeType:g}=f.atomicHierarchy.derived.residue,y=en.transientSegments(m,d),b=en.transientSegments(h,d),x=1*a;let _=0;for(;y.hasNext;)for(b.setSegment(y.move());b.hasNext;){const{index:E}=b.move();if(Ya(g[E])){const w={trace:-1,N1:-1,C2:-1,N3:-1,C4:-1,C5:-1,C6:-1,N7:-1,C8:-1,N9:-1,C1_1:-1,C2_1:-1,C3_1:-1,C4_1:-1,O4_1:-1};l.currentGroup=_,IC(w,t,E),TC(w)&&(p.invariantPosition(w.C1_1,E1),p.invariantPosition(w.C2_1,P1),p.invariantPosition(w.C3_1,M1),p.invariantPosition(w.C4_1,R1),p.invariantPosition(w.O4_1,k1),p.invariantPosition(w.trace,A1),Zn(l,A1,x,c),Zn(l,R1,x,c),Zn(l,k1,x,c),Zn(l,E1,x,c),Zn(l,P1,x,c),Zn(l,M1,x,c));const{isPurine:D,isPyrimidine:I}=Q0(t,E);D?(ey(w,t,E),g1(w)&&(p.invariantPosition(w.N1,Cl),p.invariantPosition(w.C2,wl),p.invariantPosition(w.N3,Al),p.invariantPosition(w.C4,Il),p.invariantPosition(w.C5,Du),p.invariantPosition(w.C6,Tl),p.invariantPosition(w.N7,I1),p.invariantPosition(w.C8,T1),p.invariantPosition(w.N9,D1),Zn(l,T1,x,c),Zn(l,I1,x,c),Zn(l,Du,x,c),Zn(l,Tl,x,c),Zn(l,Cl,x,c),Zn(l,wl,x,c),Zn(l,Al,x,c),Zn(l,Il,x,c),Zn(l,Du,x,c),Zn(l,D1,x,c))):I&&(ty(w,t,E),y1(w)&&(p.invariantPosition(w.N1,Cl),p.invariantPosition(w.C2,wl),p.invariantPosition(w.N3,Al),p.invariantPosition(w.C4,Il),p.invariantPosition(w.C5,Du),p.invariantPosition(w.C6,Tl),Zn(l,Tl,x,c),Zn(l,Du,x,c),Zn(l,Il,x,c),Zn(l,Al,x,c),Zn(l,wl,x,c),Zn(l,Cl,x,c))),++_}}const S=at.getMesh(l),A=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return S.setBoundingSphere(A),S}const ny=v.zero(),N1=v.zero(),ry=v.zero(),Gpe=v.zero(),es=hf(3,!1);let Iz;const iy=le.identity(),Xht=v.zero(),jpe=v.zero(),Hpe=v.zero(),Dz=v.zero(),Kht=4,Zht=4,Qht=6,Jht=function Yht(){return Iz||(Iz=function $ht(){const e=bv(8);for(let t=0;t<3;++t){const n=(t+1)%3;v.set(ny,es[3*t],es[3*t+1],-.5),v.set(N1,es[3*n],es[3*n+1],-.5),v.set(ry,es[3*n],es[3*n+1],.5),v.set(Gpe,es[3*t],es[3*t+1],.5),e.add(ny,N1,ry),e.add(ry,Gpe,ny)}return v.set(ny,es[0],es[1],-.5),v.set(N1,es[3],es[4],-.5),v.set(ry,es[6],es[7],-.5),e.add(ry,N1,ny),v.set(ny,es[0],es[1],.5),v.set(N1,es[3],es[4],.5),v.set(ry,es[6],es[7],.5),e.add(ny,N1,ry),e.getPrimitive()}()),Iz}(),qpe={sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01})};function emt(e,t,n,r,i,o){const s=t.polymerElements.length;if(!s)return Nt.createEmpty(o);const{sizeFactor:a}=i,c=24*s,u=at.createState(c,c/10,o),d=lz(1),{normalVectors:f,binormalVectors:p}=d;let m=0;const h=az(t,n);for(;h.hasNext;){const b=h.move();u.currentGroup=m;const x=Ya(b.moleculeType),_=cr.is(b.secStrucType,4);if(dz(d,b,x||_?.5:.9,x?.3:.5),_&&!b.secStrucLast||!_){const E=r.size.size(b.center)*a,w=Kht*E,D=Zht*E,I=Qht*E,R=x?p:f;v.fromArray(jpe,R,0),v.fromArray(Hpe,R,3),v.normalize(Dz,v.add(Dz,jpe,Hpe)),le.targetTo(iy,b.p3,b.p1,Dz),le.mul(iy,iy,le.rotY90Z180),le.scale(iy,iy,v.set(Xht,I,D,w)),le.setTranslation(iy,b.p2),at.addPrimitive(u,iy,Jht)}++m}const g=at.getMesh(u),y=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return g.setBoundingSphere(y),g}C.getDefaultValues(qpe);const Wpe={...hs,...qpe};function tmt(e){return Hs({defaultProps:C.getDefaultValues(Wpe),createGeometry:emt,createLocationIterator:t=>lh.fromGroup(t),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor}},e)}const Ez=10,$pe={sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),radialSegments:C.Numeric(16,{min:2,max:56,step:2},rt.CustomQualityParamInfo)};function nmt(e,t,n,r,i,o){const s=t.gapElements.length;if(!s)return Nt.createEmpty(o);const{sizeFactor:a,radialSegments:c}=i,u=Ez*c*2*s*2,l=at.createState(u,u/10,o),d=v(),f=v(),p={radiusTop:1,radiusBottom:1,topCap:!0,bottomCap:!0,radialSegments:c};let m=0;const h=function Ypt(e,t){switch(t.kind){case 0:return new Xpt(e,t);case 1:case 2:return new Kpt(e,t)}}(n,t);for(;h.hasNext;){const{centerA:b,centerB:x}=h.move();b.element===x.element||(t.conformation.invariantPosition(b.element,d),t.conformation.invariantPosition(x.element,f),p.radiusTop=p.radiusBottom=r.size.size(b)*a,l.currentGroup=m,Cv(l,d,f,.5,Ez,!1,p),p.radiusTop=p.radiusBottom=r.size.size(x)*a,l.currentGroup=m+1,Cv(l,f,d,.5,Ez,!1,p)),m+=2}const g=at.getMesh(l),y=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return g.setBoundingSphere(y),g}C.getDefaultValues($pe);const $3={...hs,...$pe};function Pz(e){return Hs({defaultProps:C.getDefaultValues($3),createGeometry:nmt,createLocationIterator:yz.fromGroup,getLoci:lht,eachLocation:dht,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.radialSegments!==r.radialSegments}},e)}const nr=v(),Tr=v(),rmt=v(),Eu=v(),Lf=v(),Y3=v(),X3=v(),EC=v(),Ad=v(),Uf=v(),Mz=v(),qm=v(),Wm=v(),$m=v(),Ym=v(),Dl=v.fromArray,F1=v.scale,El=v.add,fh=v.sub,imt=v.magnitude,Ype=v.negate,Rz=v.copy,Xpe=v.cross,omt=v.set,Lr=ze.add3,smt=ze.add;function K3(e,t,n,r,i,o,s,a,c){const{vertices:u,normals:l,indices:d}=t,f=u.elementCount;if(Dl(nr,r,e),F1(X3,nr,s),F1(Y3,nr,a),Dl(Tr,i,e),F1(Eu,Tr,o),Xpe(Uf,Tr,nr),Dl(Ad,n,e),El(qm,El(qm,Ad,Eu),Y3),fh(Wm,El(Wm,Ad,Eu),X3),fh($m,fh($m,Ad,Eu),X3),El(Ym,fh(Ym,Ad,Eu),Y3),s0?(Dl(nr,t,0),Dl(Tr,t,3*i),g=a/imt(fh(rmt,Tr,nr))):omt(EC,0,0,0);for(let b=0;b<=i;++b){const x=o[b],S=0===a?s[b]:a*(1-b/i),A=3*b;Dl(Lf,n,A),F1(Lf,Lf,S),Dl(Eu,r,A),F1(Eu,Eu,x),a>0&&(Dl(nr,n,A),Dl(Tr,r,A),F1(EC,Xpe(EC,nr,Tr),g)),Dl(Ad,t,A),Dl(Uf,n,A),Dl(Mz,r,A),El(nr,El(nr,Ad,Eu),Lf),El(Tr,Uf,EC),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),El(nr,fh(nr,Ad,Eu),Lf),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),Ype(Tr,Mz),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),fh(nr,fh(nr,Ad,Eu),Lf),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),El(Tr,Ype(Tr,Uf),EC),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),fh(nr,El(nr,Ad,Eu),Lf),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),Rz(Tr,Mz),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),El(nr,El(nr,Ad,Eu),Lf),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2])}for(let b=0;b0){const b=o[0],x=s[0];K3(0,e,t,n,r,b,a,-x,!1),K3(0,e,t,n,r,b,-a,x,!1)}if(u&&0===a){const x=s[i];K3(3*i,e,t,n,r,o[i],x,x,!0)}for(let b=0,x=8*(i+1)+(c?4:a>0?8:0)+(u&&0===a?4:0);bD;for(let T=0;T=_?I-D:-I+D:T>=x&&T<_?-I+D:I-D;kz(ts,ts,Ys,M),T===x||T===x-1?Q3(wo,Ys,Pa,0,1):T===_||T===_-1?Q3(wo,Ys,Pa,0,-1):Q3(wo,Ys,Pa,y[T],b[T])}else B1(ts,Ys,Pa,hc,I*y[T],D*b[T]),Q3(wo,Ys,Pa,D*y[T],I*b[T]);amt(wo,wo),Ma(f,ts[0],ts[1],ts[2]),Ma(p,wo[0],wo[1],wo[2])}}const S=Math.round(o/2);for(let E=0;ED;R&&(I-=D),g=f.elementCount;for(let T=0;T=_?I:-I)):B1(ts,Ys,Pa,hc,I*y[T],D*b[T]),Ma(f,ts[0],ts[1],ts[2]),Ma(p,wo[0],wo[1],wo[2]),Ma(m,g+(T+1)%o,g+T,w)}if(u){const E=3*i,w=f.elementCount;ph(Ys,n,E),ph(Pa,r,E),ph(hc,t,E),Kpe(wo,Ys,Pa),Ma(f,hc[0],hc[1],hc[2]),Ma(p,wo[0],wo[1],wo[2]);const D=s[i];let I=a[i];const R="rounded"===l&&I>D;R&&(I-=D),g=f.elementCount;for(let T=0;T=_?I:-I)):B1(ts,Ys,Pa,hc,I*y[T],D*b[T]),Ma(f,ts[0],ts[1],ts[2]),Ma(p,wo[0],wo[1],wo[2]),Ma(m,g+T,g+(T+1)%o,w)}ze.addRepeat(h,(i+1)*o+(c?o+1:0)+(u?o+1:0),d)}const hh=v.fromArray,dmt=v.magnitude,Bz=v.sub,Zpe=v.add,Oz=v.scale,fmt=v.negate,pmt=v.copy,hmt=v.cross,Pl=ze.add3,mmt=ze.add,_s=v(),Xs=v(),gmt=v(),Lz=v(),oy=v(),Qpe=v(),PC=v(),ymt=v(),Uz=v();function J3(e,t,n,r,i,o,s,a){const{currentGroup:c,vertices:u,normals:l,indices:d,groups:f}=e,p=u.elementCount;let m=0;a>0&&(hh(_s,t,0),hh(Xs,t,3*i),m=a/dmt(Bz(gmt,Xs,_s)));for(let g=0;g<=i;++g){const y=o[g],x=0===a?s[g]:a*(1-g/i),_=3*g;hh(oy,n,_),Oz(oy,oy,x),hh(Lz,r,_),Oz(Lz,Lz,y),a>0&&(hh(_s,n,_),hh(Xs,r,_),Oz(Qpe,hmt(Qpe,_s,Xs),m)),hh(PC,t,_),hh(ymt,n,_),hh(Uz,r,_),Zpe(_s,PC,oy),fmt(Xs,Uz),Pl(u,_s[0],_s[1],_s[2]),Pl(l,Xs[0],Xs[1],Xs[2]),Bz(_s,PC,oy),Pl(u,_s[0],_s[1],_s[2]),Pl(l,Xs[0],Xs[1],Xs[2]),Zpe(_s,PC,oy),pmt(Xs,Uz),Pl(u,_s[0],_s[1],_s[2]),Pl(l,Xs[0],Xs[1],Xs[2]),Bz(_s,PC,oy),Pl(u,_s[0],_s[1],_s[2]),Pl(l,Xs[0],Xs[1],Xs[2])}for(let g=0;glh.fromGroup(t,{asSecondary:!0}),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.tubularHelices!==r.tubularHelices||n.detail!==r.detail||n.linearSegments!==r.linearSegments||n.radialSegments!==r.radialSegments||n.aspectRatio!==r.aspectRatio||n.arrowFactor!==r.arrowFactor||n.helixProfile!==r.helixProfile||n.nucleicProfile!==r.nucleicProfile;const c=Xu.get(s.structure).version;t.info.secondaryStructureHash!==c&&(void 0!==t.info.secondaryStructureHash&&(t.createGeometry=!0),t.info.secondaryStructureHash=c)}},e)}const the={"polymer-trace":(e,t)=>vi("Polymer trace mesh",e,t,vmt),"polymer-gap":(e,t)=>vi("Polymer gap cylinder",e,t,Pz),"nucleotide-block":(e,t)=>vi("Nucleotide block mesh",e,t,yht),"nucleotide-ring":(e,t)=>vi("Nucleotide ring mesh",e,t,Aht),"nucleotide-atomic-ring-fill":(e,t)=>vi("Nucleotide atomic ring fill",e,t,Bht),"nucleotide-atomic-bond":(e,t)=>vi("Nucleotide atomic bond",e,t,Oht),"nucleotide-atomic-element":(e,t)=>vi("Nucleotide atomic element",e,t,Ght),"direction-wedge":(e,t)=>vi("Polymer direction wedge",e,t,tmt)},nhe={...ehe,...$3,...Epe,...Fpe,...wz,...Az,...zpe,...Wpe,sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),visuals:C.MultiSelect(["polymer-trace","polymer-gap","nucleotide-ring","nucleotide-atomic-ring-fill","nucleotide-atomic-bond","nucleotide-atomic-element"],C.objectToOptions(the)),bumpFrequency:C.Numeric(2,{min:0,max:10,step:.1},rt.ShadingCategory),colorMode:C.Select("default",C.arrayToOptions(["default","interpolate"]),{...rt.ShadingCategory,isHidden:!0})},Smt={name:"cartoon",label:"Cartoon",description:"Displays ribbons, planks, tubes smoothly following the trace atoms of polymers.",factory:function xmt(e,t){return yn.createMulti("Cartoon",e,t,ms,the)},getParams:function _mt(e,t){const n=C.clone(nhe);let r=!1,i=!1;return t.units.forEach(o=>{!r&&Ee.isAtomic(o)&&o.nucleotideElements.length&&(r=!0),!i&&o.gapElements.length&&(i=!0)}),n.visuals.defaultValue=["polymer-trace"],r&&n.visuals.defaultValue.push("nucleotide-ring"),i&&n.visuals.defaultValue.push("polymer-gap"),n},defaultValues:C.getDefaultValues(nhe),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.polymerResidueCount>0,ensureCustomProperties:{attach:function(){var e=ie(function*(t,n){yield Xu.attach(t,n,void 0,!0);for(const r of n.models)yield sz.attach(t,r,void 0,!0)});return function(n,r){return e.apply(this,arguments)}}(),detach:e=>{Xu.ref(e,!1);for(const t of e.models)sz.ref(t,!1)}}},rhe={...hs,sizeFactor:C.Numeric(1,{min:0,max:10,step:.1}),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo),ignoreHydrogens:C.Boolean(!1)};function Cmt(e){return Hs({defaultProps:C.getDefaultValues(rhe),createGeometry:wmt,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail||n.ignoreHydrogens!==r.ignoreHydrogens}},e)}function wmt(e,t,n,r,i,o){const{child:s}=n,a=s?.unitMap.get(t.id);if(s&&!a)return Nt.createEmpty(o);const{detail:c,sizeFactor:u,ignoreHydrogens:l}=i,{elements:d,model:f}=t,{atomicNumber:p}=t.model.atomicHierarchy.derived.atom,m=d.length,h=m*_v(c),g=at.createState(h,h/2,o),y=tf.Provider.get(f);if(!y)return Nt.createEmpty(o);const b=v(),x=Kt(),_=v(),S=v(),A=v(),{elementToAnsiotrop:E,data:w}=y,{U:D}=w,I=w._schema.U.space,R=t.conformation,T=nt.create(n);T.unit=t;for(let V=0;Vvi("Ellipsoid Mesh",e,t,Cmt),"intra-bond":(e,t)=>vi("Intra-unit bond cylinder",e,t,Vfe),"inter-bond":(e,t)=>Iu("Inter-unit bond cylinder",e,t,Hfe)},ohe={...rhe,...y3,...b3,includeParent:C.Boolean(!1),adjustCylinderLength:C.Boolean(!1,{isHidden:!0}),unitKinds:oC(["atomic"]),sizeFactor:C.Numeric(1,{min:.01,max:10,step:.01}),sizeAspectRatio:C.Numeric(.1,{min:.01,max:3,step:.01}),linkCap:C.Boolean(!0),visuals:C.MultiSelect(["ellipsoid-mesh","intra-bond","inter-bond"],C.objectToOptions(ihe)),bumpFrequency:C.Numeric(0,{min:0,max:10,step:.1},rt.ShadingCategory)},Tmt={name:"ellipsoid",label:"Ellipsoid",description:"Displays anisotropic displacement ellipsoids of atomic elements plus bonds as cylinders.",factory:function Imt(e,t){return yn.createMulti("Ellipsoid",e,t,ms,ihe)},getParams:function Amt(e,t){return ohe},defaultValues:C.getDefaultValues(ohe),defaultColorTheme:{name:"element-symbol"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.elementCount>0&&e.models.some(t=>tf.Provider.isApplicable(t)),getData:(e,t)=>t.includeParent?e.asParent():e,mustRecreate:(e,t)=>e.includeParent!==t.includeParent},Dmt="\nprecision highp float;\n\nattribute vec3 aPosition;\nattribute float aRadius;\n\nvarying vec3 vPosition;\nvarying float vRadiusSqInv;\n\n#if defined(dCalcType_groupId)\n attribute float aGroup;\n varying float vGroup;\n#endif\n\nuniform vec3 uBboxSize;\nuniform vec3 uBboxMin;\nuniform float uResolution;\n\nvoid main() {\n vRadiusSqInv = 1.0 / (aRadius * aRadius);\n #if defined(dCalcType_groupId)\n vGroup = aGroup;\n #endif\n gl_PointSize = ceil(((aRadius * 3.0) / uResolution) + uResolution);\n vPosition = (aPosition - uBboxMin) / uResolution;\n gl_Position = vec4(((aPosition - uBboxMin) / uBboxSize) * 2.0 - 1.0, 1.0);\n}\n",Emt="\nprecision highp float;\n\nvarying vec3 vPosition;\nvarying float vRadiusSqInv;\n#if defined(dCalcType_groupId)\n #if defined(dGridTexType_2d)\n precision highp sampler2D;\n uniform sampler2D tMinDistanceTex;\n uniform vec3 uGridTexDim;\n #elif defined(dGridTexType_3d)\n precision highp sampler3D;\n uniform sampler3D tMinDistanceTex;\n #endif\n varying float vGroup;\n#endif\n\n#include common\n\nuniform vec3 uGridDim;\nuniform vec2 uGridTexScale;\nuniform float uCurrentSlice;\nuniform float uCurrentX;\nuniform float uCurrentY;\nuniform float uAlpha;\nuniform float uResolution;\nuniform float uRadiusFactorInv;\n\nvoid main() {\n vec2 v = gl_FragCoord.xy - vec2(uCurrentX, uCurrentY) - 0.5;\n vec3 fragPos = vec3(v.x, v.y, uCurrentSlice);\n float dist = distance(fragPos, vPosition) * uResolution;\n\n #if defined(dCalcType_density)\n float density = exp(-uAlpha * ((dist * dist) * vRadiusSqInv));\n gl_FragColor.a = density * uRadiusFactorInv;\n #elif defined(dCalcType_minDistance)\n gl_FragColor.a = 1.0 - dist * uRadiusFactorInv;\n #elif defined(dCalcType_groupId)\n #if defined(dGridTexType_2d)\n float minDistance = 1.0 - texture2D(tMinDistanceTex, (gl_FragCoord.xy) / (uGridTexDim.xy / uGridTexScale)).a;\n #elif defined(dGridTexType_3d)\n float minDistance = 1.0 - texelFetch(tMinDistanceTex, ivec3(gl_FragCoord.xy, uCurrentSlice), 0).a;\n #endif\n if (dist * uRadiusFactorInv > minDistance + uResolution * 0.05)\n discard;\n gl_FragColor.rgb = packIntToRGB(vGroup);\n #endif\n}\n",Pmt={drawCount:ri("number"),instanceCount:ri("number"),aRadius:Ar("float32",1,0),aPosition:Ar("float32",3,0),aGroup:Ar("float32",1,0),uCurrentSlice:xe("f"),uCurrentX:xe("f"),uCurrentY:xe("f"),uBboxMin:xe("v3","material"),uBboxSize:xe("v3","material"),uGridDim:xe("v3","material"),uGridTexDim:xe("v3","material"),uGridTexScale:xe("v2","material"),uAlpha:xe("f","material"),uResolution:xe("f","material"),uRadiusFactorInv:xe("f","material"),tMinDistanceTex:jt("texture","rgba","float","nearest","material"),dGridTexType:Ft("string",["2d","3d"]),dCalcType:Ft("string",["density","minDistance","groupId"])},Vf="gaussian-density";function Vz(e){return e.namedFramebuffers[Vf]||(e.namedFramebuffers[Vf]=e.resources.framebuffer()),e.namedFramebuffers[Vf]}function zz(e,t,n,r,i,o){const s=`${Vf}-${e}`;return t.namedTextures[s]||(t.namedTextures[s]=t.resources.texture(n,r,i,o)),t.namedTextures[s]}function she(e,t,n,r,i,o){return e.isWebGL2?function Mmt(e,t,n,r,i,o){lt&&e.timer.mark("GaussianDensityTexture3d");const s=function Rmt(e,t,n,r,i,o){const{gl:s,resources:a,state:c,extensions:{colorBufferFloat:u,textureFloat:l,colorBufferHalfFloat:d,textureHalfFloat:f}}=e,{smoothness:p,resolution:m}=i,{drawCount:h,positions:g,radii:y,groups:b,scale:x,expandedBox:_,dim:S,maxRadius:A}=lhe(t,n,r,i),[E,w,D]=S,I=zz("min-dist-3d",e,"volume-uint8","rgba","ubyte","nearest");I.define(E,w,D);const R=Me.create(1,1),T=2*A,M=dhe(e,h,g,y,b,I,_,S,S,R,p,m,T),{uCurrentSlice:N}=M.values,V=Vz(e);function F(G,L){c.currentRenderItemId=-1;for(let z=0;z=N&&(X-=N,J+=I,ce=0,k.update(O,J)),k.update(q,ce),k.update(ee,be),u.viewport(ce,J,D,I),u.scissor(ce,J,D,I),$.render(),++X,ce+=D;a.flush()}return H.bind(),fhe(e),s||(s=f&&p?c.texture("image-float16","rgba","fp16","linear"):l&&d?c.texture("image-float32","rgba","float","linear"):c.texture("image-uint8","rgba","ubyte","linear")),s.define(z,j),hhe(e,$),W(s,!0),m&&(phe(e,$),W(Z,!0),mhe(e,$),W(s,!1)),{texture:s,scale:S,bbox:A,gridDim:E,gridTexDim:F,gridTexScale:G,radiusFactor:L,resolution:g,maxRadius:w}}(e,t,n,r,i,o,s);return lt&&e.timer.markEnd("GaussianDensityTexture2d"),ahe(a)}function ahe({texture:e,scale:t,bbox:n,gridDim:r,gridTexDim:i,gridTexScale:o,radiusFactor:s,resolution:a,maxRadius:c}){return{transform:che(t,n),texture:e,bbox:n,gridDim:r,gridTexDim:i,gridTexScale:o,radiusFactor:s,resolution:a,maxRadius:c}}function che(e,t){const n=le.identity();return le.fromScaling(n,e),le.setTranslation(n,t.min),n}function lhe(e,t,n,r){const{resolution:i,radiusOffset:o}=r,s=1/i,{indices:a,x:c,y:u,z:l,id:d}=e,f=Fe.size(a),p=new Float32Array(3*f),m=new Float32Array(f),h=new Float32Array(f);let g=0;for(let A=0;A0?"3d":"2d"),k.updateIfChanged(m.dCalcType,"density"),e.namedComputeRenderables[Vf].update()}else e.namedComputeRenderables[Vf]=function kmt(e,t,n,r,i,o,s,a,c,u,l,d,f){const p=v.sub(v(),s.max,s.min),m={drawCount:k.create(t),instanceCount:k.create(1),aRadius:k.create(r),aPosition:k.create(n),aGroup:k.create(i),uCurrentSlice:k.create(0),uCurrentX:k.create(0),uCurrentY:k.create(0),uBboxMin:k.create(s.min),uBboxSize:k.create(p),uGridDim:k.create(a),uGridTexDim:k.create(c),uGridTexScale:k.create(u),uAlpha:k.create(l),uResolution:k.create(d),uRadiusFactorInv:k.create(1/f),tMinDistanceTex:k.create(o),dGridTexType:k.create(o.getDepth()>0?"3d":"2d"),dCalcType:k.create("density")},h={...Pmt};return ji(zi(e,"points",Br(Vf,Dmt,Emt),h,m),m)}(e,t,n,r,i,o,s,a,c,u,l,d,f);return e.namedComputeRenderables[Vf]}function fhe(e){const{gl:t,state:n}=e;n.disable(t.CULL_FACE),n.enable(t.BLEND),n.disable(t.DEPTH_TEST),n.enable(t.SCISSOR_TEST),n.depthMask(!1),n.clearColor(0,0,0,0)}function phe(e,t){const{gl:n,state:r}=e;if(k.update(t.values.dCalcType,"minDistance"),t.update(),r.colorMask(!1,!1,!1,!0),r.blendFunc(n.ONE,n.ONE),!e.extensions.blendMinMax)throw new Error("GPU gaussian surface calculation requires EXT_blend_minmax");r.blendEquation(e.extensions.blendMinMax.MAX)}function hhe(e,t){const{gl:n,state:r}=e;k.update(t.values.dCalcType,"density"),t.update(),r.colorMask(!1,!1,!1,!0),r.blendFunc(n.ONE,n.ONE),r.blendEquation(n.FUNC_ADD)}function mhe(e,t){const{gl:n,state:r}=e;k.update(t.values.dCalcType,"groupId"),t.update(),r.colorMask(!0,!0,!0,!1),r.blendFunc(n.ONE,n.ZERO),r.blendEquation(n.FUNC_ADD)}function ghe(e,t,n,r,i){return jz.apply(this,arguments)}function jz(){return jz=ie(function*(e,t,n,r,i){const{resolution:o,radiusOffset:s,smoothness:a}=i,c=1/o,{indices:u,x:l,y:d,z:f,id:p}=t,m=Fe.size(u),h=new Float32Array(m);let g=0;for(let W=0;Wj[ln]&&(j[ln]=Xt,D[ln]=p?p[fe]:fe)}}}}}}function O(){return(O=ie(function*(){for(let W=0;W1)return!1;const r=n.maxTextureSize/3,{areaCells:i,maxAreaCells:o}=zle(e.boundary.box,t.resolution,r*r);return i{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.createGeometry=!0)},geometryUtils:xa.Utils},t)}({defaultProps:C.getDefaultValues(Hz),createGeometry:$mt,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0),n.smoothColors.name!==r.smoothColors.name?t.updateColor=!0:"on"===n.smoothColors.name&&"on"===r.smoothColors.name&&(n.smoothColors.params.resolutionFactor!==r.smoothColors.params.resolutionFactor&&(t.updateColor=!0),n.smoothColors.params.sampleStride!==r.smoothColors.params.sampleStride&&(t.updateColor=!0))},mustRecreate:(t,n,r)=>!n.tryUseGpu||!r||!O1(t.structure,n,r),processValues:(t,n,r,i,o)=>{const{resolution:s,colorTexture:a}=n.meta,c=cl(r.smoothColors,i.color.preferSmoothing,s);c&&o&&(Oae(t,c.resolution,c.stride,o,a),n.meta.colorTexture=t.tColorGrid.ref.value)},dispose:t=>{var n;t.vertexTexture.ref.value.destroy(),t.groupTexture.ref.value.destroy(),t.normalTexture.ref.value.destroy(),t.doubleBuffer.destroy(),null===(n=t.meta.colorTexture)||void 0===n||n.destroy()}},e)}(e):function Hmt(e){return Hs({defaultProps:C.getDefaultValues(Hz),createGeometry:jmt,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0),n.smoothColors.name!==r.smoothColors.name?t.updateColor=!0:"on"===n.smoothColors.name&&"on"===r.smoothColors.name&&(n.smoothColors.params.resolutionFactor!==r.smoothColors.params.resolutionFactor&&(t.updateColor=!0),n.smoothColors.params.sampleStride!==r.smoothColors.params.sampleStride&&(t.updateColor=!0))},mustRecreate:(t,n,r)=>n.tryUseGpu&&!!r&&O1(t.structure,n,r),processValues:(t,n,r,i,o)=>{const{resolution:s,colorTexture:a}=n.meta,c=cl(r.smoothColors,i.color.preferSmoothing,s);c&&(aE(t,c.resolution,c.stride,o,a),n.meta.colorTexture=t.tColorGrid.ref.value)},dispose:t=>{var n;null===(n=t.meta.colorTexture)||void 0===n||n.destroy()}},e)}(e)}function Gmt(e,t,n,r){return n.tryUseGpu&&r&&xhe(r)&&O1(t,n,r)?function Kmt(e){return function Gat(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.createGeometry=!0)},geometryUtils:xa.Utils},t)}({defaultProps:C.getDefaultValues(_he),createGeometry:Xmt,createLocationIterator:gs.fromStructure,getLoci:W0,eachLocation:q0,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0),n.smoothColors.name!==r.smoothColors.name?t.updateColor=!0:"on"===n.smoothColors.name&&"on"===r.smoothColors.name&&(n.smoothColors.params.resolutionFactor!==r.smoothColors.params.resolutionFactor&&(t.updateColor=!0),n.smoothColors.params.sampleStride!==r.smoothColors.params.sampleStride&&(t.updateColor=!0))},mustRecreate:(t,n,r)=>!n.tryUseGpu||!r||!O1(t,n,r),processValues:(t,n,r,i,o)=>{const{resolution:s,colorTexture:a}=n.meta,c=cl(r.smoothColors,i.color.preferSmoothing,s);c&&o&&(Oae(t,c.resolution,c.stride,o,a),n.meta.colorTexture=t.tColorGrid.ref.value)},dispose:t=>{var n;t.vertexTexture.ref.value.destroy(),t.groupTexture.ref.value.destroy(),t.normalTexture.ref.value.destroy(),t.doubleBuffer.destroy(),null===(n=t.meta.colorTexture)||void 0===n||n.destroy()}},e)}(e):function Wmt(e){return rh({defaultProps:C.getDefaultValues(_he),createGeometry:qmt,createLocationIterator:gs.fromStructure,getLoci:W0,eachLocation:q0,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.smoothColors.name!==r.smoothColors.name?t.updateColor=!0:"on"===n.smoothColors.name&&"on"===r.smoothColors.name&&(n.smoothColors.params.resolutionFactor!==r.smoothColors.params.resolutionFactor&&(t.updateColor=!0),n.smoothColors.params.sampleStride!==r.smoothColors.params.sampleStride&&(t.updateColor=!0))},mustRecreate:(t,n,r)=>n.tryUseGpu&&!!r&&O1(t,n,r),processValues:(t,n,r,i,o)=>{const{resolution:s,colorTexture:a}=n.meta,c=cl(r.smoothColors,i.color.preferSmoothing,s);c&&(aE(t,c.resolution,c.stride,o,a),n.meta.colorTexture=t.tColorGrid.ref.value)},dispose:t=>{var n;null===(n=t.meta.colorTexture)||void 0===n||n.destroy()}},e)}(e)}function jmt(e,t,n,r,i,o){return qz.apply(this,arguments)}function qz(){return qz=ie(function*(e,t,n,r,i,o){const{smoothness:s}=i,{transform:a,field:c,idField:u,radiusFactor:l,resolution:d,maxRadius:f}=yield bhe(n,t,r.size,i).runInContext(e.runtime),p={isoLevel:Math.exp(-s)/l,scalarField:c,idField:u},m=yield a1(p,o).runAsChild(e.runtime);m.meta.resolution=d,Nt.transform(m,a),e.webgl&&!e.webgl.isWebGL2?(Nt.uniformTriangleGroup(m),k.updateIfChanged(m.varyingGroup,!1)):k.updateIfChanged(m.varyingGroup,!0);const h=_e.expand(_e(),t.boundary.sphere,f);return m.setBoundingSphere(h),m}),qz.apply(this,arguments)}function qmt(e,t,n,r,i){return Wz.apply(this,arguments)}function Wz(){return Wz=ie(function*(e,t,n,r,i){const{smoothness:o}=r,{transform:s,field:a,idField:c,radiusFactor:u,resolution:l,maxRadius:d}=yield function Lmt(e,t,n){const{position:r,boundary:i,radius:o}=WE(e,t,n),s=Pm(i.box,n);return Oe.create("Gaussian Density",function(){var a=ie(function*(c){return yield ghe(c,r,i.box,o,s)});return function(c){return a.apply(this,arguments)}}())}(t,n.size,r).runInContext(e.runtime),f={isoLevel:Math.exp(-o)/u,scalarField:a,idField:c},p=yield a1(f,i).runAsChild(e.runtime);p.meta.resolution=l,Nt.transform(p,s),e.webgl&&!e.webgl.isWebGL2?(Nt.uniformTriangleGroup(p),k.updateIfChanged(p.varyingGroup,!1)):k.updateIfChanged(p.varyingGroup,!0);const m=_e.expand(_e(),t.boundary.sphere,d);return p.setBoundingSphere(m),p}),Wz.apply(this,arguments)}const L1="gaussian-surface";function $mt(e,t,n,r,i,o){return $z.apply(this,arguments)}function $z(){return $z=ie(function*(e,t,n,r,i,o){if(!e.webgl)throw new Error("webgl context required to create gaussian surface texture-mesh");lt&&e.webgl.timer.mark("createGaussianSurfaceTextureMesh");const{namedTextures:s,resources:a,extensions:{colorBufferFloat:c,textureFloat:u,colorBufferHalfFloat:l,textureHalfFloat:d}}=e.webgl;s[L1]||(s[L1]=l&&d?a.texture("image-float16","rgba","fp16","linear"):c&&u?a.texture("image-float32","rgba","float","linear"):a.texture("image-uint8","rgba","ubyte","linear"));const f=yield function Omt(e,t,n,r,i,o,s){const{position:a,boundary:c,radius:u}=qE(e,t,n,i),l=Pm(c.box,i,yhe(o,e));return Oe.create("Gaussian Density",function(){var d=ie(function*(f){return Gz(o,a,c.box,u,r,l,s)});return function(f){return d.apply(this,arguments)}}())}(n,t,r.size,!0,i,e.webgl,s[L1]).runInContext(e.runtime),p=Math.exp(-i.smoothness)/f.radiusFactor,m=v.create(0,1,2),h=o?.doubleBuffer.get(),g=c3(e.webgl,f.texture,f.gridDim,f.gridTexDim,f.gridTexScale,f.transform,p,!1,!0,m,!0,h?.vertex,h?.group,h?.normal);lt&&e.webgl.timer.markEnd("createGaussianSurfaceTextureMesh");const y=t.elements.length,b=_e.expand(_e(),t.boundary.sphere,f.maxRadius),x=xa.create(g.vertexCount,y,g.vertexTexture,g.groupTexture,g.normalTexture,b,o);return x.meta.resolution=f.resolution,x.meta.webgl=e.webgl,x}),$z.apply(this,arguments)}function Xmt(e,t,n,r,i){return Yz.apply(this,arguments)}function Yz(){return Yz=ie(function*(e,t,n,r,i){if(!e.webgl)throw new Error("webgl context required to create structure gaussian surface texture-mesh");lt&&e.webgl.timer.mark("createStructureGaussianSurfaceTextureMesh");const{namedTextures:o,resources:s,extensions:{colorBufferFloat:a,textureFloat:c,colorBufferHalfFloat:u,textureHalfFloat:l}}=e.webgl;o[L1]||(o[L1]=u&&l?s.texture("image-float16","rgba","fp16","linear"):a&&c?s.texture("image-float32","rgba","float","linear"):s.texture("image-uint8","rgba","ubyte","linear"));const d=yield function Vmt(e,t,n,r,i,o){const{box:s}=e.lookup3d.boundary,{position:a,boundary:c,radius:u}=WE(e,t,r),l=Pm(c.box,r);return Oe.create("Gaussian Density",function(){var d=ie(function*(f){return Gz(i,a,s,u,n,l,o)});return function(f){return d.apply(this,arguments)}}())}(t,n.size,!0,r,e.webgl,o[L1]).runInContext(e.runtime),f=Math.exp(-r.smoothness)/d.radiusFactor,p=v.create(0,1,2),m=i?.doubleBuffer.get(),h=c3(e.webgl,d.texture,d.gridDim,d.gridTexDim,d.gridTexScale,d.transform,f,!1,!0,p,!0,m?.vertex,m?.group,m?.normal);lt&&e.webgl.timer.markEnd("createStructureGaussianSurfaceTextureMesh");const g=t.elementCount,y=_e.expand(_e(),t.boundary.sphere,d.maxRadius),b=xa.create(h.vertexCount,g,h.vertexTexture,h.groupTexture,h.normalTexture,y,i);return b.meta.resolution=d.resolution,b.meta.webgl=e.webgl,b}),Yz.apply(this,arguments)}function Zmt(e,t,n,r,i,o){return Xz.apply(this,arguments)}function Xz(){return Xz=ie(function*(e,t,n,r,i,o){const{smoothness:s}=i,{transform:a,field:c,idField:u,maxRadius:l}=yield bhe(n,t,r.size,i).runInContext(e.runtime),d={isoLevel:Math.exp(-s),scalarField:c,idField:u},f=yield qU(d,o).runAsChild(e.runtime);di.transform(f,a);const p=_e.expand(_e(),t.boundary.sphere,l);return f.setBoundingSphere(p),f}),Xz.apply(this,arguments)}const She={...$E,...MC,sizeFactor:C.Numeric(3,{min:0,max:10,step:.1}),lineSizeAttenuation:C.Boolean(!1),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),includeParent:C.Boolean(!1,{isHidden:!0})};function Qmt(e){return YE({defaultProps:C.getDefaultValues(She),createGeometry:Zmt,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0)}},e)}const Che={"gaussian-surface-mesh":(e,t)=>vi("Gaussian surface mesh",e,t,zmt),"structure-gaussian-surface-mesh":(e,t)=>Iu("Structure-Gaussian surface mesh",e,t,Gmt),"gaussian-surface-wireframe":(e,t)=>vi("Gaussian surface wireframe",e,t,Qmt)},whe={...Hz,...She,visuals:C.MultiSelect(["gaussian-surface-mesh"],C.objectToOptions(Che)),bumpFrequency:C.Numeric(1,{min:0,max:10,step:.1},rt.ShadingCategory)},tgt={name:"gaussian-surface",label:"Gaussian Surface",description:"Displays a gaussian molecular surface.",factory:function egt(e,t){return yn.createMulti("Gaussian Surface",e,t,ms,Che)},getParams:function Jmt(e,t){return whe},defaultValues:C.getDefaultValues(whe),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"physical"},isApplicable:e=>e.elementCount>0},Ahe={...Oat,background:C.Boolean(!1),backgroundMargin:C.Numeric(0,{min:0,max:1,step:.01}),backgroundColor:C.Color(xn.black),backgroundOpacity:C.Numeric(.5,{min:0,max:1,step:.01}),borderWidth:C.Numeric(.25,{min:0,max:.5,step:.01}),level:C.Select("residue",[["chain","Chain"],["residue","Residue"],["element","Element"]],{isEssential:!0}),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),chainScale:C.Numeric(10,{min:0,max:20,step:.1}),residueScale:C.Numeric(1,{min:0,max:20,step:.1}),elementScale:C.Numeric(.5,{min:0,max:20,step:.1})};function ngt(e){return function Lat(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0),r.background!==i.background&&(n.createGeometry=!0),r.backgroundMargin!==i.backgroundMargin&&(n.createGeometry=!0),r.tether!==i.tether&&(n.createGeometry=!0),r.tetherLength!==i.tetherLength&&(n.createGeometry=!0),r.tetherBaseWidth!==i.tetherBaseWidth&&(n.createGeometry=!0),r.attachment!==i.attachment&&(n.createGeometry=!0),r.fontFamily!==i.fontFamily&&(n.createGeometry=!0),r.fontQuality!==i.fontQuality&&(n.createGeometry=!0),r.fontStyle!==i.fontStyle&&(n.createGeometry=!0),r.fontVariant!==i.fontVariant&&(n.createGeometry=!0),r.fontWeight!==i.fontWeight&&(n.createGeometry=!0)},geometryUtils:vu.Utils},t)}({defaultProps:C.getDefaultValues(Ahe),createGeometry:rgt,createLocationIterator:gs.fromStructure,getLoci:W0,eachLocation:q0,setUpdateState:(t,n,r)=>{t.createGeometry=n.level!==r.level||"chain"===n.level&&n.chainScale!==r.chainScale||"residue"===n.level&&n.residueScale!==r.residueScale||"element"===n.level&&n.elementScale!==r.elementScale||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant}},e)}function rgt(e,t,n,r,i){switch(r.level){case"chain":return function igt(e,t,n,r,i){const o=nt.create(t),{units:s,serialMapping:a}=t,{auth_asym_id:c,label_asym_id:u}=Ze.chain,{cumulativeUnitElementCount:l}=a,d=s.length,{chainScale:f}=r,p=wf.create(r,d,d/2,i);for(let m=0,h=s.length;mIu("Label text",e,t,ngt)},The={...Ahe,visuals:C.MultiSelect(["label-text"],C.objectToOptions(Ihe))},ugt={name:"label",label:"Label",description:"Displays labels.",factory:function cgt(e,t){const n=yn.createMulti("Label",e,t,ms,Ihe);return n.setState({pickable:!1,markerActions:Bt.None}),n},getParams:function agt(e,t){return The},defaultValues:C.getDefaultValues(The),defaultColorTheme:{name:"uniform"},defaultSizeTheme:{name:"physical"},isApplicable:e=>e.elementCount>0},Kz={probeRadius:C.Numeric(1.4,{min:0,max:10,step:.1},{description:"Radius of the probe tracing the molecular surface."}),resolution:C.Numeric(.5,{min:.01,max:20,step:.01},{description:"Grid resolution/cell spacing.",...rt.CustomQualityParamInfo}),probePositions:C.Numeric(36,{min:12,max:90,step:1},{description:"Number of positions tested for probe target intersection.",...rt.CustomQualityParamInfo})};function Zz(){return Zz=ie(function*(e,t,n,r,i,o){let s=-1;function a(Y,ge,Se,Re,Ne){if(-1!==s){const Ge=s;if(Ge!==Re&&Ge!==Ne&&c(Ge,Y,ge,Se))return Ge;s=-1}for(let Ge=0,$e=R.count;Ge<$e;++Ge){const tt=Fe.getAt(T,R.indices[Ge]);if(tt!==Re&&tt!==Ne&&c(tt,Y,ge,Se))return s=tt,tt}return-1}function c(Y,ge,Se,Re){const Ne=G[Y],Ge=M[Y]-ge,$e=N[Y]-Se,tt=V[Y]-Re;return Ge*Ge+$e*$e+tt*tt0&&Ue{n.resolution!==r.resolution&&(t.createGeometry=!0),n.probeRadius!==r.probeRadius&&(t.createGeometry=!0),n.probePositions!==r.probePositions&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0),n.smoothColors.name!==r.smoothColors.name?t.updateColor=!0:"on"===n.smoothColors.name&&"on"===r.smoothColors.name&&(n.smoothColors.params.resolutionFactor!==r.smoothColors.params.resolutionFactor&&(t.updateColor=!0),n.smoothColors.params.sampleStride!==r.smoothColors.params.sampleStride&&(t.updateColor=!0))},processValues:(t,n,r,i,o)=>{const{resolution:s,colorTexture:a}=n.meta,c=cl(r.smoothColors,i.color.preferSmoothing,s);c&&(aE(t,c.resolution,c.stride,o,a),n.meta.colorTexture=t.tColorGrid.ref.value)},dispose:t=>{var n;null===(n=t.meta.colorTexture)||void 0===n||n.destroy()}},e)}function bgt(e,t,n,r,i){return t7.apply(this,arguments)}function t7(){return t7=ie(function*(e,t,n,r,i){const{transform:o,field:s,idField:a,resolution:c,maxRadius:u}=yield function mgt(e,t,n){const{position:r,boundary:i,maxRadius:o}=function hgt(e,t,n){const{probeRadius:r}=n,{position:i,boundary:o,radius:s}=WE(e,t,n),{indices:a}=i,c=Fe.size(a),u=new Float32Array(Fe.end(a));let l=0;for(let d=0;d{n.resolution!==r.resolution&&(t.createGeometry=!0),n.probeRadius!==r.probeRadius&&(t.createGeometry=!0),n.probePositions!==r.probePositions&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0),n.smoothColors.name!==r.smoothColors.name?t.updateColor=!0:"on"===n.smoothColors.name&&"on"===r.smoothColors.name&&(n.smoothColors.params.resolutionFactor!==r.smoothColors.params.resolutionFactor&&(t.updateColor=!0),n.smoothColors.params.sampleStride!==r.smoothColors.params.sampleStride&&(t.updateColor=!0))},processValues:(t,n,r,i,o)=>{const{resolution:s,colorTexture:a}=n.meta,c=cl(r.smoothColors,i.color.preferSmoothing,s);c&&(aE(t,c.resolution,c.stride,o,a),n.meta.colorTexture=t.tColorGrid.ref.value)},dispose:t=>{var n;null===(n=t.meta.colorTexture)||void 0===n||n.destroy()}},e)}const Phe={...$E,...Kz,...HE,sizeFactor:C.Numeric(1.5,{min:0,max:10,step:.1})};function _gt(e,t,n,r,i,o){return n7.apply(this,arguments)}function n7(){return n7=ie(function*(e,t,n,r,i,o){const{transform:s,field:a,idField:c,maxRadius:u}=yield Dhe(n,t,r.size,i).runInContext(e.runtime),l={isoLevel:i.probeRadius,scalarField:a,idField:c},d=yield qU(l,o).runAsChild(e.runtime);di.transform(d,s);const f=_e.expand(_e(),t.boundary.sphere,u);return d.setBoundingSphere(f),d}),n7.apply(this,arguments)}function xgt(e){return YE({defaultProps:C.getDefaultValues(Phe),createGeometry:_gt,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.probeRadius!==r.probeRadius&&(t.createGeometry=!0),n.probePositions!==r.probePositions&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0)}},e)}const Mhe={"molecular-surface-mesh":(e,t)=>vi("Molecular surface mesh",e,t,ygt),"structure-molecular-surface-mesh":(e,t)=>Iu("Structure Molecular surface mesh",e,t,vgt),"molecular-surface-wireframe":(e,t)=>vi("Molecular surface wireframe",e,t,xgt)},Rhe={...Jz,...Phe,visuals:C.MultiSelect(["molecular-surface-mesh"],C.objectToOptions(Mhe)),bumpFrequency:C.Numeric(1,{min:0,max:10,step:.1},rt.ShadingCategory)},wgt={name:"molecular-surface",label:"Molecular Surface",description:"Displays a molecular surface.",factory:function Cgt(e,t){return yn.createMulti("Molecular Surface",e,t,ms,Mhe)},getParams:function Sgt(e,t){return Rhe},defaultValues:C.getDefaultValues(Rhe),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"physical"},isApplicable:e=>e.elementCount>0},khe={...hs,sizeFactor:C.Numeric(1,{min:0,max:2,step:.1}),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo)};function Agt(e){return Hs({defaultProps:C.getDefaultValues(khe),createGeometry:Tgt,createLocationIterator:Dgt,getLoci:Egt,eachLocation:Pgt,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail}},e)}function Tgt(e,t,n,r,i,o){if(!function Igt(e){if(Ee.Traits.is(e.traits,Ee.Trait.MultiChain)||Ee.Traits.is(e.traits,Ee.Trait.Partitioned))return!1;if(Ee.isCoarse(e))return!0;if(0===e.elements.length)return!1;const n=e.model.atomicHierarchy.derived.residue.moleculeType[e.residueIndex[e.elements[0]]];return!(3===n||2===n)}(t))return Nt.createEmpty(o);const{detail:s,sizeFactor:a}=i,u=at.createState(256,128,o),l=t.principalAxes.boxAxes,{origin:d,dirA:f,dirB:p}=l,m=Rs.size(v(),l);v.scale(m,m,a/2);const h=v.create(m[2],m[1],m[0]);u.currentGroup=0,h8(u,d,f,p,h,s+1);const g=at.getMesh(u),y=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return g.setBoundingSphere(y),g}function Dgt(e){const{group:t,structure:n}=e,i=t.units.length,o=nt.create(n);return Mr(1,i,1,(a,c)=>{const u=t.units[c];return o.unit=u,o.element=u.elements[a],o})}function Egt(e,t,n){const{objectId:r,instanceId:i}=e;if(n===r){const{structure:o,group:s}=t,a=s.units[i];return De(o,[{unit:a,indices:Fe.ofBounds(0,a.elements.length)}])}return $n}function Pgt(e,t,n){let r=!1;if(!De.is(e))return!1;const{structure:i,group:o}=t;if(!Ve.areEquivalent(e.structure,i))return!1;const s=o.elements.length;for(const a of e.elements){const c=o.unitIndexMap.get(a.unit.id);void 0!==c&&Fe.size(a.indices)===s&&n(Ce.ofSingleton(c))&&(r=!0)}return r}const Nhe={"orientation-ellipsoid-mesh":(e,t)=>vi("Orientation ellipsoid mesh",e,t,Agt)},Fhe={...khe,visuals:C.MultiSelect(["orientation-ellipsoid-mesh"],C.objectToOptions(Nhe)),bumpFrequency:C.Numeric(1,{min:0,max:10,step:.1},rt.ShadingCategory)},kgt={name:"orientation",label:"Orientation",description:"Displays orientation ellipsoids for polymer chains.",factory:function Rgt(e,t){return yn.createMulti("Orientation",e,t,ms,Nhe)},getParams:function Mgt(e,t){return Fhe},defaultValues:C.getDefaultValues(Fhe),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.elementCount>0},Ngt=ze.add3,Fgt=ze.add;var r7;!function(e){e.create=function t(n=2048,r=1024,i){const o=ze.create(Float32Array,3,r,i?i.centerBuffer.ref.value:n),s=ze.create(Float32Array,1,r,i?i.groupBuffer.ref.value:n);return{add:(a,c,u,l)=>{Ngt(o,a,c,u),Fgt(s,l)},getPoints:()=>{const a=ze.compact(o,!0),c=ze.compact(s,!0);return ym.create(a,c,o.elementCount,i)}}}}(r7||(r7={}));const Bhe=v.add,i7={...Hat,pointSizeAttenuation:C.Boolean(!1),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),traceOnly:C.Boolean(!1),stride:C.Numeric(1,{min:1,max:100,step:1})};function Bgt(e,t,n,r,i,o){const{child:s}=n;if(s&&!s.unitMap.get(t.id))return ym.createEmpty(o);const a=t.elements,c=a.length,u=r7.create(c,c/10,o),l=v(),d=t.conformation,f=H0(n,t,i),p=v();let m=0;if(f)for(let b=0;b{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:ym.Utils},t)}({defaultProps:C.getDefaultValues(i7),createGeometry:Bgt,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{t.createGeometry=n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.traceOnly!==r.traceOnly||n.stride!==r.stride}},e)}const Ogt={"element-point":(e,t)=>vi("Points",e,t,Ohe)},Lhe={...i7},Vgt={name:"point",label:"Point",description:"Displays elements (atoms, coarse spheres) as points.",factory:function Ugt(e,t){return yn.createMulti("Point",e,t,ms,Ogt)},getParams:function Lgt(e,t){return Lhe},defaultValues:C.getDefaultValues(Lhe),defaultColorTheme:{name:"element-symbol"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.elementCount>0},Uhe={sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo),linearSegments:C.Numeric(8,{min:1,max:48,step:1},rt.CustomQualityParamInfo),radialSegments:C.Numeric(16,{min:2,max:56,step:2},rt.CustomQualityParamInfo)},Hc=(C.getDefaultValues(Uhe),v());function zgt(e,t,n,r,i,o){const s=t.polymerElements.length;if(!s)return Nt.createEmpty(o);const{sizeFactor:a,detail:c,linearSegments:u,radialSegments:l}=i,d=u*l*s+(l+1)*s*2,f=at.createState(d,d/10,o),p=lz(u),{curvePoints:m,normalVectors:h,binormalVectors:g,widthValues:y,heightValues:b}=p;let x=0;const _=az(t,n,{ignoreSecondaryStructure:!0});for(;_.hasNext;){const E=_.move();f.currentGroup=x;const D=Ya(E.moleculeType)?T3:I3;dz(p,E,bpe,D);const I=E.coarseBackboneFirst||E.first,R=E.coarseBackboneLast||E.last,T=r.size.size(E.centerPrev)*a,M=r.size.size(E.center)*a,N=r.size.size(E.centerNext)*a;gz(p,T,M,N,T,M,N,D);let V=u;if(E.initial){V=Math.max(Math.round(u*D),1);const F=u-V;m.copyWithin(0,3*F),g.copyWithin(0,3*F),h.copyWithin(0,3*F),y.copyWithin(0,3*F),b.copyWithin(0,3*F),v.fromArray(Hc,m,3),v.normalize(Hc,v.sub(Hc,E.p2,Hc)),v.scaleAndAdd(Hc,E.p2,Hc,M*D3),v.toArray(Hc,m,0)}else E.final&&(V=Math.max(Math.round(u*(1-D)),1),v.fromArray(Hc,m,3*V-3),v.normalize(Hc,v.sub(Hc,E.p2,Hc)),v.scaleAndAdd(Hc,E.p2,Hc,M*D3),v.toArray(Hc,m,3*V));!0===E.initial&&!0===E.final?Zn(f,E.p2,2*M,c):2===l?J3(f,m,h,g,V,y,b,0):4===l?Z3(f,m,h,g,V,y,b,0,I,R):Fz(f,m,h,g,V,l,y,b,I,R,"elliptical"),++x}const S=at.getMesh(f),A=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return S.setBoundingSphere(A),S}const Vhe={...hs,...Uhe};function Ggt(e){return Hs({defaultProps:C.getDefaultValues(Vhe),createGeometry:zgt,createLocationIterator:t=>lh.fromGroup(t,{asSecondary:!0}),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail||n.linearSegments!==r.linearSegments||n.radialSegments!==r.radialSegments}},e)}const zhe={"polymer-tube":(e,t)=>vi("Polymer tube mesh",e,t,Ggt),"polymer-gap":(e,t)=>vi("Polymer gap cylinder",e,t,Pz)},Ghe={...Vhe,...$3,sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),visuals:C.MultiSelect(["polymer-tube","polymer-gap"],C.objectToOptions(zhe)),bumpFrequency:C.Numeric(2,{min:0,max:10,step:.1},rt.ShadingCategory)},qgt={name:"putty",label:"Putty",description:"Displays a tube smoothly following the trace atoms of polymers.",factory:function Hgt(e,t){return yn.createMulti("Putty",e,t,ms,zhe)},getParams:function jgt(e,t){const n=C.clone(Ghe);let r=!1,i=!1;return t.units.forEach(o=>{!r&&Ee.isAtomic(o)&&o.nucleotideElements.length&&(r=!0),!i&&o.gapElements.length&&(i=!0)}),n.visuals.defaultValue=["polymer-tube"],i&&n.visuals.defaultValue.push("polymer-gap"),n},defaultValues:C.getDefaultValues(Ghe),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"uncertainty"},isApplicable:e=>e.polymerResidueCount>0},jhe={"element-sphere":(e,t)=>vi("Sphere mesh/impostor",e,t,Wfe),"structure-element-sphere":(e,t)=>Iu("Structure sphere mesh/impostor",e,t,ept)},o7={...v3,bumpFrequency:C.Numeric(1,{min:0,max:10,step:.1},rt.ShadingCategory),visuals:C.MultiSelect(["element-sphere"],C.objectToOptions(jhe))};let eP;const Ygt={name:"spacefill",label:"Spacefill",description:"Displays atomic/coarse elements as spheres.",factory:function $gt(e,t){return yn.createMulti("Spacefill",e,t,ms,jhe)},getParams:function Wgt(e,t){return t.isCoarseGrained?(eP||(eP=C.clone(o7),eP.sizeFactor.defaultValue=2),eP):o7},defaultValues:C.getDefaultValues(o7),defaultColorTheme:{name:"element-symbol"},defaultSizeTheme:{name:"physical"},isApplicable:e=>e.elementCount>0},s7=jn.is;function Xgt(e,t,n,r,i,o){if(!Ee.isAtomic(t))return di.createEmpty(o);const{child:s}=n,a=s?.unitMap.get(t.id);if(s&&!a)return di.createEmpty(o);const c=nt.create(n,t),u=t.elements,l=t.bonds,{edgeCount:d,a:f,b:p,edgeProps:m,offset:h}=l;if(!d)return di.createEmpty(o);const{order:g,flags:y}=m,{sizeFactor:b,aromaticBonds:x,includeTypes:_,excludeTypes:S,multipleBonds:A}=i,E="off"===A,w="symmetric"===A,R=g3(jn.fromNames(_),jn.fromNames(S),32),T=v(),M=t.conformation,{elementRingIndices:N,elementAromaticRingIndices:V}=t.rings,F=x?t.resonance.delocalizedTriplets:void 0,G={linkCount:2*d,referencePosition:j=>{let Z=f[j],$=p[j];const ee=F?.getThirdElement(Z,$);if(void 0!==ee)return M.invariantPosition(u[ee],T);Z>$&&([Z,$]=[$,Z]),h[Z+1]-h[Z]==1&&([Z,$]=[$,Z]);const q=V.get(Z)||N.get(Z);let O=0;for(let H=h[Z],W=h[Z+1];HO&&(O=X,M.invariantPosition(u[Q],T))}}}return O>0?T:null},position:(j,Z,$)=>{M.invariantPosition(u[f[$]],j),M.invariantPosition(u[p[$]],Z)},style:j=>{const Z=g[j],$=y[j];if(s7($,2)||s7($,4))return 1;if(3===Z)return E?0:w?4:5;if(x){const q=p[j],O=V.get(f[j]),H=V.get(q),W=O&&H?jI(O,H):0;if(s7($,16)||W&&!R)return 2===W?8:7}return 2!==Z||E?0:w?2:3},radius:j=>{c.element=u[f[j]];const Z=r.size.size(c);c.element=u[p[j]];const $=r.size.size(c);return Math.min(Z,$)*b},ignore:Ofe(n,t,i)},{lines:L,boundingSphere:z}=ede(0,G,i,o);if(z)L.setBoundingSphere(z);else if(L.lineCount>0){const j=_e.expand(_e(),(a??t).boundary.sphere,1*b);L.setBoundingSphere(j)}return L}const Hhe={...$E,...OV,includeParent:C.Boolean(!1)};function Kgt(e){return YE({defaultProps:C.getDefaultValues(Hhe),createGeometry:Xgt,createLocationIterator:t=>Um.fromGroup(t),getLoci:LV,eachLocation:UV,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.linkScale!==r.linkScale||n.linkSpacing!==r.linkSpacing||n.aromaticDashCount!==r.aromaticDashCount||n.dashCount!==r.dashCount||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||!Wa(n.includeTypes,r.includeTypes)||!Wa(n.excludeTypes,r.excludeTypes)||n.aromaticBonds!==r.aromaticBonds||n.multipleBonds!==r.multipleBonds;const c=s.group.units[0],u=a.group.units[0];Ee.isAtomic(c)&&Ee.isAtomic(u)&&(Dc.areEqual(c.bonds,u.bonds)||(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0))}},e)}const a7=new Lt.ElementBondIterator;function qhe(e,t,n,r){for(a7.setElement(t,n,r);a7.hasNext;){const i=a7.move();return i.otherUnit.conformation.position(i.otherUnit.elements[i.otherIndex],e),e}return null}function Zgt(e,t,n,r,i){const o=t.interUnitBonds,{edgeCount:s,edges:a}=o;if(!s)return di.createEmpty(i);const{sizeFactor:c,aromaticBonds:u,multipleBonds:l}=r,d="off"===l,f="symmetric"===l,p=v(),m=nt.create(),h={linkCount:s,referencePosition:b=>{const x=a[b];let _,S,A,E;if(x.unitAx.unitB))throw new Error("same units in createInterUnitBondLines");_=t.unitMap.get(x.unitB),S=t.unitMap.get(x.unitA),A=x.indexB,E=x.indexA}return qhe(p,t,_,A)||qhe(p,t,S,E)},position:(b,x,_)=>{const S=a[_],A=t.unitMap.get(S.unitA),E=t.unitMap.get(S.unitB);A.conformation.position(A.elements[S.indexA],b),E.conformation.position(E.elements[S.indexB],x)},style:b=>{const x=a[b].props.order,_=ea.create(a[b].props.flag);return jn.is(_,2)||jn.is(_,4)?1:3===x?d?0:f?4:5:u&&jn.is(_,16)?7:2!==x||d?0:f?2:3},radius:b=>{const x=a[b];m.structure=t,m.unit=t.unitMap.get(x.unitA),m.element=m.unit.elements[x.indexA];const _=n.size.size(m);m.unit=t.unitMap.get(x.unitB),m.element=m.unit.elements[x.indexB];const S=n.size.size(m);return Math.min(_,S)*c},ignore:Lfe(t,r)},{lines:g,boundingSphere:y}=ede(0,h,r,i);if(y)g.setBoundingSphere(y);else if(g.lineCount>0){const{child:b}=t,x=_e.expand(_e(),(b??t).boundary.sphere,1*c);g.setBoundingSphere(x)}return g}const Whe={...Fat,...OV,includeParent:C.Boolean(!1)};function Qgt(e){return function Bat(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:di.Utils},t)}({defaultProps:C.getDefaultValues(Whe),createGeometry:Zgt,createLocationIterator:t=>Um.fromStructure(t),getLoci:VV,eachLocation:GV,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.linkScale!==r.linkScale||n.linkSpacing!==r.linkSpacing||n.aromaticDashCount!==r.aromaticDashCount||n.dashCount!==r.dashCount||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||!Wa(n.includeTypes,r.includeTypes)||!Wa(n.excludeTypes,r.excludeTypes)||n.multipleBonds!==r.multipleBonds,s.interUnitBonds!==a.interUnitBonds&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0)}},e)}const U1=v.scaleAndAdd,$he=v.unitX,Yhe=v.unitY,Xhe=v.unitZ,Khe={...$E,lineSizeAttenuation:C.Boolean(!1),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),traceOnly:C.Boolean(!1),crosses:C.Select("lone",C.arrayToOptions(["lone","all"])),crossSize:C.Numeric(.35,{min:0,max:2,step:.01})};function Jgt(e,t,n,r,i,o){const{child:s}=n;if(s&&!s.unitMap.get(t.id))return di.createEmpty(o);const a=t.elements,c=a.length,u=Fc.create(c,c/10,o),l=v(),d=v(),f=v(),p=t.conformation,m=H0(n,t,i),h=i.crossSize/2,g="lone"===i.crosses;for(let x=0;x{t.createGeometry=n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.traceOnly!==r.traceOnly||n.crosses!==r.crosses||n.crossSize!==r.crossSize}},e)}const Zhe={"intra-bond":(e,t)=>vi("Intra-unit bond line",e,t,Kgt),"inter-bond":(e,t)=>Iu("Inter-unit bond line",e,t,Qgt),"element-point":(e,t)=>vi("Points",e,t,Ohe),"element-cross":(e,t)=>vi("Crosses",e,t,e0t)},c7={...Hhe,...Whe,...i7,...Khe,pointStyle:C.Select("circle",C.objectToOptions(ym.StyleTypes)),multipleBonds:C.Select("offset",C.arrayToOptions(["off","symmetric","offset"])),includeParent:C.Boolean(!1),sizeFactor:C.Numeric(2,{min:.01,max:10,step:.01}),unitKinds:oC(["atomic"]),visuals:C.MultiSelect(["intra-bond","inter-bond","element-point","element-cross"],C.objectToOptions(Zhe))},r0t={name:"line",label:"Line",description:"Displays bonds as lines and atoms as points or croses.",factory:function n0t(e,t){return yn.createMulti("Line",e,t,ms,Zhe)},getParams:function t0t(e,t){if(Ve.getSize(t)>=Ve.Size.Huge){const r=C.clone(c7);return r.visuals.defaultValue=["intra-bond","element-point","element-cross"],r}return c7},defaultValues:C.getDefaultValues(c7),defaultColorTheme:{name:"element-symbol"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.elementCount>0,getData:(e,t)=>t.includeParent?e.asParent():e,mustRecreate:(e,t)=>e.includeParent!==t.includeParent};function i0t(e,t,n,r,i){return u7.apply(this,arguments)}function u7(){return u7=ie(function*(e,t,n,r,i){const{runtime:o,webgl:s}=e;if(!s||!s.extensions.blendMinMax)throw new Error("GaussianDensityVolume requires `webgl` and `blendMinMax` extension");const a=i?i.gridTexture.ref.value:void 0,c=yield function Umt(e,t,n,r,i){const{position:o,boundary:s,radius:a}=WE(e,t,n),c=Pm(s.box,n);return Oe.create("Gaussian Density",function(){var u=ie(function*(l){return she(r,o,s.box,a,c,i)});return function(l){return u.apply(this,arguments)}}())}(t,n.size,r,s,a).runInContext(o),{transform:u,texture:l,bbox:d,gridDim:f}=c,m=le.mul(le(),u,le.fromScaling(le(),f)),h=le.getScaling(v(),u),g=v.create(0,1,2),y=_u.create(d,f,u,m,h,l,{min:0,max:1,mean:.04,sigma:.01},!0,g,i),b=_e.expand(_e(),t.boundary.sphere,c.maxRadius);return y.setBoundingSphere(b),y}),u7.apply(this,arguments)}const Qhe={...Uat,...MC,ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),includeParent:C.Boolean(!1,{isHidden:!0})};function o0t(e){return function Vat(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.createGeometry=!0)},geometryUtils:_u.Utils},t)}({defaultProps:C.getDefaultValues(Qhe),createGeometry:i0t,createLocationIterator:gs.fromStructure,getLoci:W0,eachLocation:q0,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0)},dispose:t=>{t.gridTexture.ref.value.destroy()}},e)}function s0t(e,t,n,r,i,o){return l7.apply(this,arguments)}function l7(){return l7=ie(function*(e,t,n,r,i,o){const{runtime:s,webgl:a}=e;if(!a)throw new Error("GaussianDensityVolume requires `webgl`");const c=o?o.gridTexture.ref.value:void 0,u=yield function Bmt(e,t,n,r,i,o){const{position:s,boundary:a,radius:c}=qE(e,t,n,r),u=Pm(a.box,r,yhe(i,e));return Oe.create("Gaussian Density",function(){var l=ie(function*(d){return she(i,s,a.box,c,u,o)});return function(d){return l.apply(this,arguments)}}())}(n,t,r.size,i,a,c).runInContext(s),{transform:l,texture:d,bbox:f,gridDim:p}=u,h=le.mul(le(),l,le.fromScaling(le(),p)),g=le.getScaling(v(),l),y=v.create(0,1,2),b=_u.create(f,p,l,h,g,d,{min:0,max:1,mean:.04,sigma:.01},!0,y,o),x=_e.expand(_e(),t.boundary.sphere,u.maxRadius);return b.setBoundingSphere(x),b}),l7.apply(this,arguments)}const a0t={...Wat,...MC,ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),includeParent:C.Boolean(!1,{isHidden:!0})};function c0t(e){return function $at(e,t){return Mm({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.createGeometry=!0)},geometryUtils:_u.Utils},t)}({defaultProps:C.getDefaultValues(a0t),createGeometry:s0t,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0)},dispose:t=>{t.gridTexture.ref.value.destroy()}},e)}const Jhe={"gaussian-volume":(e,t)=>Iu("Gaussian volume",e,t,o0t),"units-gaussian-volume":(e,t)=>vi("Units-Gaussian volume",e,t,c0t)},eme={...Qhe,jumpLength:C.Numeric(4,{min:0,max:20,step:.1}),visuals:C.MultiSelect(["gaussian-volume"],C.objectToOptions(Jhe))},d0t={name:"gaussian-volume",label:"Gaussian Volume",description:"Displays a gaussian molecular density using direct volume rendering.",factory:function l0t(e,t){return yn.createMulti("Gaussian Volume",e,t,ms,Jhe)},getParams:function u0t(e,t){return eme},defaultValues:C.getDefaultValues(eme),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"physical"},isApplicable:e=>e.elementCount>0},f0t=v.scale,p0t=v.add,h0t=v.sub,d7={...hs,...AU,sizeFactor:C.Numeric(.3,{min:0,max:10,step:.01}),radialSegments:C.Numeric(16,{min:2,max:56,step:2},rt.CustomQualityParamInfo),tryUseImpostor:C.Boolean(!0)};function m0t(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth?function y0t(e){return IU({defaultProps:C.getDefaultValues(d7),createGeometry:g0t,createLocationIterator:t=>lh.fromGroup(t),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r)=>{},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function v0t(e){return Hs({defaultProps:C.getDefaultValues(d7),createGeometry:b0t,createLocationIterator:t=>lh.fromGroup(t),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.radialSegments!==r.radialSegments},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}function g0t(e,t,n,r,i,o){const s=t.polymerElements.length;if(!s)return oc.createEmpty(o);const a=2*s,c=aC.create(a,a/4,o),u=t.conformation,l=v(),d=v(),f=v();cpe(t,function(g,y,b,x,_){u.invariantPosition(g,l),u.invariantPosition(y,d);const A=Ya(_)?T3:I3;p0t(f,l,f0t(f,h0t(f,d,l),A)),c.add(l[0],l[1],l[2],f[0],f[1],f[2],1,!1,!1,2,b),c.add(f[0],f[1],f[2],d[0],d[1],d[2],1,!1,!1,2,x)});const m=c.getCylinders(),h=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return m.setBoundingSphere(h),m}function b0t(e,t,n,r,i,o){const s=t.polymerElements.length;if(!s)return Nt.createEmpty(o);const{radialSegments:a,sizeFactor:c}=i,u=2*a*s*2,l=at.createState(u,u/10,o),d=t.conformation,f=v(),p=v(),m={radiusTop:1,radiusBottom:1,radialSegments:a},h=nt.create(n,t),g=nt.create(n,t);cpe(t,function(_,S,A,E,w){h.element=_,g.element=S,d.invariantPosition(h.element,f),d.invariantPosition(g.element,p);const I=Ya(w)?T3:I3;m.radiusTop=m.radiusBottom=r.size.size(h)*c,l.currentGroup=A,Hn(l,f,p,I,m),m.radiusTop=m.radiusBottom=r.size.size(g)*c,l.currentGroup=E,Hn(l,p,f,1-I,m)});const b=at.getMesh(l),x=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return b.setBoundingSphere(x),b}const f7={...hs,...CU,sizeFactor:C.Numeric(.3,{min:0,max:10,step:.01}),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo),tryUseImpostor:C.Boolean(!0)};function _0t(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth&&r.extensions.textureFloat?function S0t(e){return wU({defaultProps:C.getDefaultValues(f7),createGeometry:x0t,createLocationIterator:t=>lh.fromGroup(t),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r)=>{},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function w0t(e){return Hs({defaultProps:C.getDefaultValues(f7),createGeometry:C0t,createLocationIterator:t=>lh.fromGroup(t),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}function x0t(e,t,n,r,i,o){const s=t.polymerElements.length;if(!s)return fl.createEmpty(o);const a=d1.create(s,s/2,o),c=t.conformation,u=v();upe(t,(p,m)=>{c.invariantPosition(p,u),a.add(u[0],u[1],u[2],m)});const d=a.getSpheres(),f=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return d.setBoundingSphere(f),d}function C0t(e,t,n,r,i,o){const s=t.polymerElements.length;if(!s)return Nt.createEmpty(o);const{detail:a,sizeFactor:c}=i,u=s*_v(a),l=at.createState(u,u/2,o),d=t.conformation,f=v(),p=nt.create(n,t);upe(t,(y,b)=>{p.element=y,d.invariantPosition(p.element,f),l.currentGroup=b,Zn(l,f,r.size.size(p)*c,a)});const h=at.getMesh(l),g=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return h.setBoundingSphere(g),h}const tme={"polymer-backbone-cylinder":(e,t)=>vi("Polymer backbone cylinder",e,t,m0t),"polymer-backbone-sphere":(e,t)=>vi("Polymer backbone sphere",e,t,_0t),"polymer-gap":(e,t)=>vi("Polymer gap cylinder",e,t,Pz)},nme={...f7,...d7,...$3,sizeAspectRatio:C.Numeric(1,{min:.1,max:3,step:.1}),visuals:C.MultiSelect(["polymer-backbone-cylinder","polymer-backbone-sphere","polymer-gap"],C.objectToOptions(tme)),bumpFrequency:C.Numeric(0,{min:0,max:10,step:.1},rt.ShadingCategory),colorMode:C.Select("default",C.arrayToOptions(["default","interpolate"]),{...rt.ShadingCategory,isHidden:!0})},T0t={name:"backbone",label:"Backbone",description:"Displays polymer backbone with cylinders and spheres.",factory:function I0t(e,t){return yn.createMulti("Backbone",e,t,ms,tme)},getParams:function A0t(e,t){const n=C.clone(nme);let r=!1;return t.units.forEach(i=>{!r&&i.gapElements.length&&(r=!0)}),n.visuals.defaultValue=["polymer-backbone-cylinder","polymer-backbone-sphere"],r&&n.visuals.defaultValue.push("polymer-gap"),n},defaultValues:C.getDefaultValues(nme),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.polymerResidueCount>0};class kC extends Vae{constructor(){super(),$a(kC.BuiltIn,(t,n)=>{if(t.name!==n)throw new Error(`Fix BuiltInStructureRepresentations to have matching names. ${t.name} ${n}`);this.add(t)})}}!function(e){e.BuiltIn={cartoon:Smt,backbone:T0t,"ball-and-stick":opt,carbohydrate:jpt,ellipsoid:Tmt,"gaussian-surface":tgt,"gaussian-volume":d0t,label:ugt,line:r0t,"molecular-surface":wgt,orientation:kgt,point:Vgt,putty:qgt,spacefill:Ygt}}(kC||(kC={}));class D0t{get isAnimating(){return this._isAnimating}tick(t,n){var r=this;return ie(function*(){var i,o;if(yield r.plugin.managers.animation.tick(t,n?.isSynchronous,n?.animation),null===(i=r.plugin.canvas3d)||void 0===i||i.tick(t,n),lt){const s=null===(o=r.plugin.canvas3d)||void 0===o?void 0:o.webgl.timer.resolve();if(s)for(const a of s)Fre([a])}})()}resetTime(t=yi()){var n;null===(n=this.plugin.canvas3d)||void 0===n||n.resetTime(t)}start(t){var n;null===(n=this.plugin.canvas3d)||void 0===n||n.resume(),this._isAnimating=!0,this.resetTime(),t?.immediate?this.frame():this.currentFrame=requestAnimationFrame(this.frame)}stop(t){var n;this._isAnimating=!1,void 0!==this.currentFrame&&(cancelAnimationFrame(this.currentFrame),this.currentFrame=void 0),t?.noDraw&&(null===(n=this.plugin.canvas3d)||void 0===n||n.pause(t?.noDraw))}constructor(t){this.plugin=t,this.currentFrame=void 0,this._isAnimating=!1,this.frame=()=>{this.tick(yi()),this._isAnimating&&(this.currentFrame=requestAnimationFrame(this.frame))}}}class V1 extends ZS{get animation(){return this.plugin.managers.animation}getSnapshot(t){var n,r,i;const o={...this.snapshotParams.value,...t};return{id:Hr.create22(),data:o.data?this.data.getSnapshot():void 0,behaviour:o.behavior?this.behaviors.getSnapshot():void 0,animation:o.animation?this.animation.getSnapshot():void 0,startAnimation:o.startAnimation?!!o.startAnimation:void 0,camera:o.camera?{current:this.plugin.canvas3d.camera.getSnapshot(),transitionStyle:o.cameraTransition.name,transitionDurationInMs:"animate"===(null===(n=o?.cameraTransition)||void 0===n?void 0:n.name)?o.cameraTransition.params.durationInMs:void 0}:void 0,canvas3dContext:o.canvas3dContext?{props:null===(r=this.plugin.canvas3dContext)||void 0===r?void 0:r.props}:void 0,canvas3d:o.canvas3d?{props:null===(i=this.plugin.canvas3d)||void 0===i?void 0:i.props}:void 0,interactivity:o.interactivity?{props:this.plugin.managers.interactivity.props}:void 0,structureFocus:this.plugin.managers.structure.focus.getSnapshot(),structureSelection:o.structureSelection?this.plugin.managers.structure.selection.getSnapshot():void 0,structureComponentManager:o.componentManager?{options:this.plugin.managers.structure.component.state.options}:void 0,durationInMs:o?.durationInMs}}setSnapshot(t){var n=this;return ie(function*(){var r,i,o,s,a;if(yield n.animation.stop(),!(null===(r=t.structureComponentManager)||void 0===r)&&r.options&&n.plugin.managers.structure.component._setSnapshotState(null===(i=t.structureComponentManager)||void 0===i?void 0:i.options),t.behaviour&&(yield n.plugin.runTask(n.behaviors.setSnapshot(t.behaviour))),t.data&&(yield n.plugin.runTask(n.data.setSnapshot(t.data))),null!==(o=t.canvas3d)&&void 0!==o&&o.props){const c=C.normalizeParams(Xue,t.canvas3d.props,"children");yield Cn.Canvas3D.SetSettings(n.plugin,{settings:c})}if(null!==(s=t.canvas3dContext)&&void 0!==s&&s.props){const c=C.normalizeParams(kE.Params,t.canvas3dContext.props,"children");null===(a=n.plugin.canvas3dContext)||void 0===a||a.setProps(c)}t.interactivity&&t.interactivity.props&&n.plugin.managers.interactivity.setProps(t.interactivity.props),t.structureFocus&&n.plugin.managers.structure.focus.setSnapshot(t.structureFocus),t.structureSelection&&n.plugin.managers.structure.selection.setSnapshot(t.structureSelection),t.animation&&n.animation.setSnapshot(t.animation),t.camera&&Cn.Camera.Reset(n.plugin,{snapshot:t.camera.current,durationMs:"animate"===t.camera.transitionStyle?t.camera.transitionDurationInMs:void 0}),t.startAnimation&&n.animation.start()})()}updateTransform(t,n,r,i){const o=t.build().to(n).update(r);return Cn.State.Update(this.plugin,{state:t,tree:o,options:{canUndo:i}})}hasBehavior(t){return this.behaviors.tree.transforms.has(t.id)}updateBehavior(t,n){const r=this.behaviors.build();if(this.behaviors.tree.transforms.has(t.id))r.to(t.id).update(n);else{const i=t.createDefaultParams(void 0,this.plugin);r.to(tr.getCategoryId(t)).apply(t,c0(i,n),{ref:t.id})}return this.plugin.runTask(this.behaviors.updateTree(r))}dispose(){this.behaviors.cells.forEach(t=>{var n,r,i,o;tr.Behavior.is(t.obj)&&(null===(r=(n=t.obj.data).unregister)||void 0===r||r.call(n),null===(o=(i=t.obj.data).dispose)||void 0===o||o.call(i))}),super.dispose(),this.data.dispose(),this.behaviors.dispose(),this.animation.dispose()}constructor(t){super(),this.plugin=t,this.data=sD.create(new pe.Root({}),{runTask:this.plugin.runTask,globalContext:this.plugin,historyCapacity:this.plugin.config.get(qi.State.HistoryCapacity)}),this.behaviors=sD.create(new tr.Root({}),{runTask:this.plugin.runTask,globalContext:this.plugin,rootState:{isLocked:!0}}),this.events={cell:{stateUpdated:ch(this.data.events.cell.stateUpdated,this.behaviors.events.cell.stateUpdated),created:ch(this.data.events.cell.created,this.behaviors.events.cell.created),removed:ch(this.data.events.cell.removed,this.behaviors.events.cell.removed)},object:{created:ch(this.data.events.object.created,this.behaviors.events.object.created),removed:ch(this.data.events.object.removed,this.behaviors.events.object.removed),updated:ch(this.data.events.object.updated,this.behaviors.events.object.updated)}},this.snapshotParams=this.ev.behavior(V1.DefaultSnapshotParams),this.setSnapshotParams=n=>{this.snapshotParams.next({...V1.DefaultSnapshotParams,...n})}}}!function(e){e.SnapshotParams={durationInMs:C.Numeric(1500,{min:100,max:15e3,step:100},{label:"Duration in ms"}),data:C.Boolean(!0),behavior:C.Boolean(!1),structureSelection:C.Boolean(!1),componentManager:C.Boolean(!0),animation:C.Boolean(!0),startAnimation:C.Boolean(!1),canvas3d:C.Boolean(!0),canvas3dContext:C.Boolean(!0),interactivity:C.Boolean(!0),camera:C.Boolean(!0),cameraTransition:C.MappedStatic("animate",{animate:C.Group({durationInMs:C.Numeric(250,{min:100,max:5e3,step:500},{label:"Duration in ms"})}),instant:C.Group({})},{options:[["animate","Animate"],["instant","Instant"]]}),image:C.Boolean(!1)},e.DefaultSnapshotParams=C.getDefaultValues(e.SnapshotParams)}(V1||(V1={}));class E0t{getDecorator(t){const n=this.plugin.state.data.tree,r=n.children.get(t);if(1!==r.size)return t;const i=r.first();return n.transforms.get(i).transformer.definition.isDecorator?this.getDecorator(i):t}get(t,n=!1){const r=this.root.get(t);if(r)return this.plugin.state.data.cells.get(n?r.ref:this.getDecorator(r.ref))}addMapping(t,n,r){if(!pe.Molecule.Structure.is(r))return!1;if(this.tracked.set(n,r.data),this.root.has(r.data))this.root.get(r.data).count++;else{const i=t.select(In.Generators.byRef(n).rootOfType([pe.Molecule.Structure]))[0];this.root.set(r.data,i?{ref:i.transform.ref,count:1}:{ref:n,count:1})}return!0}removeMapping(t){if(!this.tracked.has(t))return!1;const n=this.tracked.get(t);this.tracked.delete(t);const r=this.root.get(n);return r.count>1?r.count--:this.root.delete(n),!0}updateMapping(t,n,r,i){return!!pe.Molecule.Structure.is(i)&&(this.removeMapping(n),this.addMapping(t,n,i),!0)}dispose(){this.ev.dispose()}constructor(t){this.plugin=t,this.ev=wp.create(),this.events={updated:this.ev(),removed:this.ev()},this.root=new Map,this.tracked=new Map,t.state.data.events.object.created.subscribe(n=>{this.addMapping(n.state,n.ref,n.obj)}),t.state.data.events.object.removed.subscribe(n=>{this.removeMapping(n.ref)&&this.events.removed.next({ref:n.ref,obj:n.obj})}),t.state.data.events.object.updated.subscribe(n=>{this.updateMapping(n.state,n.ref,n.oldObj,n.obj)&&this.events.updated.next({ref:n.ref,oldObj:n.oldObj,obj:n.obj})})}}class p7{constructor(){this.ev=wp.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()}}tryGetAbortTaskId(t){if(this.abortRequests.has(t.progress.taskId))return t.progress.taskId;for(const n of t.children){const r=this.tryGetAbortTaskId(n);if(void 0!==r)return r}}track(t,n){return r=>{var i;if(r.canAbort&&r.requestAbort){const s=this.tryGetAbortTaskId(r.root);void 0!==s&&r.requestAbort(this.abortRequests.get(s))}const o=yi()-r.root.progress.startedTime;this.events.progress.next({id:t,useOverlay:null===(i=this.options.get(n))||void 0===i?void 0:i.useOverlay,level:o<250?"none":"background",progress:r})}}run(t,n){var r=this;return ie(function*(){const i=r.id++;let o;n?.createNewContext||0===r.currentContext.length?o={ctx:LMe(t,r.track(i,t.id),100),refCount:1}:(o=r.currentContext[r.currentContext.length-1],o.refCount++);try{return r.options.set(t.id,{useOverlay:!!n?.useOverlay}),r.runningTasks.add(t.id),yield UZ(o.ctx,t)}finally{r.options.delete(t.id),r.runningTasks.delete(t.id),r.events.finished.next({id:i}),r.abortRequests.delete(t.id),o.refCount--,0===o.refCount&&Xx(r.currentContext,o)}})()}requestAbortAll(t){this.runningTasks.forEach(n=>this.abortRequests.set(n,t))}requestAbort(t,n){this.abortRequests.set("number"==typeof t?t:t.root.progress.taskId,n)}dispose(){this.ev.dispose()}}!function(e){function t(r){return new Promise(i=>setTimeout(i,r))}e.testTask=function n(r){return Oe.create("Test",function(){var i=ie(function*(o){let s=0;for(;s!!n&&n.key===t)}show(t){let r,n=this.state.entries;const i=++this.serialId;let o;t.key&&(r=this.findByKey(t.key))?(void 0!==r.timeout&&clearTimeout(r.timeout),o=r.serialNumber,n=n.remove(r.id)):o=++this.serialNumber,r={id:i,serialNumber:o,key:t.key,title:t.title,message:t.message,timeout:this.timeout(i,t.timeoutMs),hide:()=>this.hideId(i)},this.updateState({entries:n.set(i,r)})&&this.events.changed.next(void 0)}timeout(t,n){if(void 0!==n)return n<0&&(n=500),setTimeout(()=>{const r=this.state.entries.get(t);r.timeout=void 0,this.hide(r)},n)}hideId(t){this.hide(this.state.entries.get(t))}hide(t){t&&(void 0!==t.timeout&&clearTimeout(t.timeout),t.hide=void 0,this.updateState({entries:this.state.entries.delete(t.id)})&&this.events.changed.next(void 0))}constructor(t){super({entries:ol()}),this.events={changed:this.ev()},this.serialNumber=0,this.serialId=0,Cn.Toast.Show.subscribe(t,n=>this.show(n)),Cn.Toast.Hide.subscribe(t,n=>this.hide(this.findByKey(n.key)))}}class M0t extends ZS{createParams(){const t=Math.min(this.plugin.canvas3d?this.plugin.canvas3d.webgl.maxRenderbufferSize:4096,4096);return{resolution:C.MappedStatic("viewport",{viewport:C.Group({}),hd:C.Group({}),"full-hd":C.Group({}),"ultra-hd":C.Group({}),custom:C.Group({width:C.Numeric(1920,{min:128,max:t,step:1}),height:C.Numeric(1080,{min:128,max:t,step:1})},{isFlat:!0})},{options:[["viewport","Viewport"],["hd","HD (1280 x 720)"],["full-hd","Full HD (1920 x 1080)"],["ultra-hd","Ultra HD (3840 x 2160)"],["custom","Custom"]]}),transparent:C.Boolean(!1),axes:DE.axes}}get params(){return this._params?this._params:this._params=this.createParams()}get values(){return this.behaviors.values.value}get cropParams(){return this.behaviors.cropParams.value}get relativeCrop(){return this.behaviors.relativeCrop.value}getCanvasSize(){var t,n;return{width:(null===(t=this.plugin.canvas3d)||void 0===t?void 0:t.webgl.gl.drawingBufferWidth)||0,height:(null===(n=this.plugin.canvas3d)||void 0===n?void 0:n.webgl.gl.drawingBufferHeight)||0}}getSize(){const t=this.values;switch(t.resolution.name){case"viewport":return this.getCanvasSize();case"hd":return{width:1280,height:720};case"full-hd":return{width:1920,height:1080};case"ultra-hd":return{width:3840,height:2160};default:return{width:t.resolution.params.width,height:t.resolution.params.height}}}createPass(t){const n=this.plugin.canvas3d,{colorBufferFloat:r,textureFloat:i}=n.webgl.extensions,o=n.props.postprocessing.occlusion;return n.getImagePass({transparentBackground:this.values.transparent,cameraHelper:{axes:this.values.axes},multiSample:{...n.props.multiSample,mode:t?"on":"off",sampleLevel:r&&i?4:2},postprocessing:{...n.props.postprocessing,occlusion:"on"===o.name?{name:"on",params:{...o.params,samples:128,resolutionScale:n.webgl.pixelRatio}}:o},marking:{...n.props.marking}})}get previewPass(){return this._previewPass||(this._previewPass=this.createPass(!1))}get imagePass(){if(this._imagePass){const t=this.plugin.canvas3d,n=t.props.postprocessing.occlusion;return this._imagePass.setProps({cameraHelper:{axes:this.values.axes},transparentBackground:this.values.transparent,postprocessing:{...t.props.postprocessing,occlusion:"on"===n.name?{name:"on",params:{...n.params,samples:128,resolutionScale:t.webgl.pixelRatio}}:n},marking:{...t.props.marking}}),this._imagePass}return this._imagePass=this.createPass(!0)}getFilename(t=".png"){const n=this.plugin.state.data.select(In.Generators.rootsOfType(pe.Molecule.Model)).map(o=>o.obj.data),r=new Set;return n.forEach(o=>r.add(o.entryId.toUpperCase())),`${Si.toArray(r).join("-")||"molstar-image"}${t}`}resetCrop(){this.behaviors.relativeCrop.next({x:0,y:0,width:1,height:1})}toggleAutocrop(){this.cropParams.auto?(this.behaviors.cropParams.next({...this.cropParams,auto:!1}),this.resetCrop()):this.behaviors.cropParams.next({...this.cropParams,auto:!0})}get isFullFrame(){const t=this.relativeCrop;return ai(t.x,0,1e-5)&&ai(t.y,0,1e-5)&&ai(t.width,1,1e-5)&&ai(t.height,1,1e-5)}autocrop(t=this.cropParams.relativePadding){const{data:n,width:r,height:i}=this.previewData.image,o=this.previewData.transparent,s=o?this.previewData.background:4278190080|this.previewData.background;let a=r,c=0,u=i,l=0;for(let m=0;mc&&(c=g),ml&&(l=m)}}if(a>c){const m=a;a=c,c=m}if(u>l){const m=u;u=l,l=m}const d=c-a+1,f=l-u+1;a-=t*d,c+=t*d,u-=t*f,l+=t*f;const p={x:Math.max(0,a/r),y:Math.max(0,u/i),width:Math.min(1,(c-a+1)/r),height:Math.min(1,(l-u+1)/i)};this.behaviors.relativeCrop.next(p)}getPreview(t=320){const{width:n,height:r}=this.getSize();if(n<=0||r<=0)return;const i=n/r;let o=0,s=0;i>1?(o=t,s=Math.round(t/i)):(s=t,o=Math.round(t*i));const a=this.plugin.canvas3d.props;this.previewPass.setProps({cameraHelper:{axes:this.values.axes},transparentBackground:this.values.transparent,postprocessing:a.postprocessing,marking:a.marking});const c=this.previewPass.getImageData(o,s),u=this.previewCanvas;u.width=c.width,u.height=c.height,this.previewData.image=c,this.previewData.background=a.renderer.backgroundColor,this.previewData.transparent=this.values.transparent;const l=u.getContext("2d");if(!l)throw new Error("Could not create canvas 2d context");return l.putImageData(c,0,0),this.cropParams.auto&&this.autocrop(),this.events.previewed.next(void 0),{canvas:u,width:o,height:s}}getSizeAndViewport(){const{width:t,height:n}=this.getSize(),r=this.relativeCrop,i={x:Math.floor(r.x*t),y:Math.floor(r.y*n),width:Math.ceil(r.width*t),height:Math.ceil(r.height*n)};return i.width+i.x>t&&(i.width=t-i.x),i.height+i.y>n&&(i.height=n-i.y),{width:t,height:n,viewport:i}}draw(t){var n=this;return ie(function*(){const{width:r,height:i,viewport:o}=n.getSizeAndViewport();if(r<=0||i<=0)return;yield t.update("Rendering image...");const s=n.imagePass;yield s.updateBackground();const a=s.getImageData(r,i,o);yield t.update("Encoding image...");const c=n.canvas;c.width=a.width,c.height=a.height;const u=c.getContext("2d");if(!u)throw new Error("Could not create canvas 2d context");u.putImageData(a,0,0)})()}copyToClipboardTask(){var t=this;const n=navigator.clipboard;if(n?.write)return Oe.create("Copy Image",function(){var r=ie(function*(i){yield t.draw(i),yield i.update("Converting image...");const o=yield _8(t.canvas,"png"),s=new ClipboardItem({"image/png":o});yield n.write([s]),t.plugin.log.message("Image copied to clipboard.")});return function(i){return r.apply(this,arguments)}}());this.plugin.log.error("clipboard.write not supported!")}getImageDataUri(){var t=this;return this.plugin.runTask(Oe.create("Generate Image",function(){var n=ie(function*(r){return yield t.draw(r),yield r.update("Converting image..."),t.canvas.toDataURL("png")});return function(r){return n.apply(this,arguments)}}()))}copyToClipboard(){const t=this.copyToClipboardTask();if(t)return this.plugin.runTask(t)}downloadTask(t){var n=this;return Oe.create("Download Image",function(){var r=ie(function*(i){yield n.draw(i),yield i.update("Downloading image..."),Bce(yield _8(n.canvas,"png"),t??n.getFilename())});return function(i){return r.apply(this,arguments)}}())}download(t){this.plugin.runTask(this.downloadTask(t))}constructor(t){super(),this.plugin=t,this._params=void 0,this.behaviors={values:this.ev.behavior({transparent:this.params.transparent.defaultValue,axes:{name:"off",params:{}},resolution:this.params.resolution.defaultValue}),cropParams:this.ev.behavior({auto:!0,relativePadding:.1}),relativeCrop:this.ev.behavior({x:0,y:0,width:1,height:1})},this.events={previewed:this.ev()},this.canvas=document.createElement("canvas"),this.previewCanvas=document.createElement("canvas"),this.previewData={image:{data:new Uint8ClampedArray(1),width:1,height:0},background:st(0),transparent:!1}}}class R0t{addHandler(t,n){const r=this.handlers.findIndex(i=>i[0]===t);r<0?this.handlers.push([t,n]):this.handlers[r][1]=n}removeHandler(t){const n=this.handlers.findIndex(r=>r[0]===t);n>=0&&this.handlers.splice(n,1)}handle(t){var n=this;return ie(function*(){for(let r=n.handlers.length-1;r>=0;r--){const i=n.handlers[r][1];if(yield i(t,n.plugin))return}!function k0t(e,t){const n=t.filter(r=>{const i=r.name.toLowerCase();return i.endsWith(".molx")||i.endsWith(".molj")});n.length>0?Cn.State.Snapshots.OpenFile(e,{file:n[0]}):e.runTask(e.state.data.applyAction(Pde,{files:t.map(r=>fr.File(r)),format:{name:"auto",params:{}},visuals:!0}))}(n.plugin,t)})()}dispose(){this.handlers.length=0}constructor(t){this.plugin=t,this.handlers=[]}}class N0t{get isInitialized(){return this._isInitialized}build(){return this.state.data.build()}initContainer(t){var n;if(this.canvasContainer)return!0;const r=document.createElement("div");Object.assign(r.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"});let i=null===(n=t?.canvas3dContext)||void 0===n?void 0:n.canvas;return i||(i=document.createElement("canvas"),t?.checkeredCanvasBackground&&Object.assign(i.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"}),r.appendChild(i)),!!this.initViewer(i,r,t?.canvas3dContext)&&(this.canvasContainer=r,!0)}mount(t,n){var r;if(this.disposed)throw new Error("Cannot mount a disposed context");return!!this.initContainer(n)&&(this.canvasContainer.parentElement!==t&&(null===(r=this.canvasContainer.parentElement)||void 0===r||r.removeChild(this.canvasContainer)),t.appendChild(this.canvasContainer),this.handleResize(),!0)}unmount(){var t,n;null===(n=null===(t=this.canvasContainer)||void 0===t?void 0:t.parentElement)||void 0===n||n.removeChild(this.canvasContainer)}initViewer(t,n,r){var i,o,s,a,c,u;try{this.layout.setRoot(n),this.spec.layout&&this.spec.layout.initial&&this.layout.setProps(this.spec.layout.initial),r||(r=kE.fromCanvas(t,this.managers.asset,{antialias:!(null!==(i=this.config.get(qi.General.DisableAntialiasing))&&void 0!==i&&i),preserveDrawingBuffer:!(null!==(o=this.config.get(qi.General.DisablePreserveDrawingBuffer))&&void 0!==o&&o),preferWebGl1:this.config.get(qi.General.PreferWebGl1)||!1,failIfMajorPerformanceCaveat:!(null!==(s=this.config.get(qi.General.AllowMajorPerformanceCaveat))&&void 0!==s&&s),powerPreference:this.config.get(qi.General.PowerPreference)||"high-performance",handleResize:this.handleResize},{pixelScale:this.config.get(qi.General.PixelScale)||1,pickScale:this.config.get(qi.General.PickScale)||.25,transparency:this.config.get(qi.General.Transparency)||"wboit"})),this.canvas3dContext=r,this.canvas3d=q8.create(this.canvas3dContext),this.canvas3dInit.next(!0);let l=this.spec.canvas3d;const d=st(16579577);return l?(void 0===(null===(c=l.renderer)||void 0===c?void 0:c.backgroundColor)&&(l=c0(l,f=>{f.renderer?f.renderer.backgroundColor=d:f.renderer={backgroundColor:d}})),null===(u=this.canvas3d)||void 0===u||u.setProps(l)):null===(a=this.canvas3d)||void 0===a||a.setProps({renderer:{backgroundColor:d}}),this.animationLoop.start(),this.helpers.viewportScreenshot=new M0t(this),this.subs.push(this.canvas3d.interaction.click.subscribe(f=>this.behaviors.interaction.click.next(f))),this.subs.push(this.canvas3d.interaction.drag.subscribe(f=>this.behaviors.interaction.drag.next(f))),this.subs.push(this.canvas3d.interaction.hover.subscribe(f=>this.behaviors.interaction.hover.next(f))),this.subs.push(this.canvas3d.input.resize.pipe(afe(50),Fde(100,void 0,{leading:!1,trailing:!0})).subscribe(()=>this.handleResize())),this.subs.push(this.canvas3d.input.keyDown.subscribe(f=>this.behaviors.interaction.key.next(f))),this.subs.push(this.canvas3d.input.keyUp.subscribe(f=>this.behaviors.interaction.keyReleased.next(f))),this.subs.push(this.layout.events.updated.subscribe(()=>requestAnimationFrame(()=>this.handleResize()))),this.handleResize(),Zx.setImmediate(()=>this.initCanvas3dPromiseCallbacks[0]()),!0}catch(l){return this.log.error(""+l),console.error(l),Zx.setImmediate(()=>this.initCanvas3dPromiseCallbacks[1](l)),!1}}get isBusy(){return this.behaviors.state.isAnimating.value||this.behaviors.state.isUpdating.value}get selectionMode(){return this.behaviors.interaction.selectionMode.value}set selectionMode(t){this.behaviors.interaction.selectionMode.next(t)}dataTransaction(t,n){return this.runTask(this.state.data.transaction(t,n))}clear(t=!1){var n;return t&&(null===(n=this.canvas3d)||void 0===n||n.setProps(H8)),Cn.State.RemoveObject(this,{state:this.state.data,ref:ur.RootRef})}dispose(t){var n,r;if(!this.disposed){for(const i of this.subs)i.unsubscribe();this.subs=[],this.animationLoop.stop(),this.commands.dispose(),null===(n=this.canvas3d)||void 0===n||n.dispose(),null===(r=this.canvas3dContext)||void 0===r||r.dispose(t),this.ev.dispose(),this.state.dispose(),this.helpers.substructureParent.dispose(),$a(this.managers,i=>{var o;return null===(o=i?.dispose)||void 0===o?void 0:o.call(i)}),$a(this.managers.structure,i=>{var o;return null===(o=i?.dispose)||void 0===o?void 0:o.call(i)}),$a(this.managers.volume,i=>{var o;return null===(o=i?.dispose)||void 0===o?void 0:o.call(i)}),this.unmount(),this.canvasContainer=void 0,this.customState={},this.disposed=!0}}initBehaviorEvents(){this.subs.push(ch(this.state.data.behaviors.isUpdating,this.state.behaviors.behaviors.isUpdating).subscribe(s=>{this.behaviors.state.isUpdating.value!==s&&this.behaviors.state.isUpdating.next(s)}));const t=this.config.get(qi.General.IsBusyTimeoutMs)||750,n=this.behaviors.state.isBusy;let r;const i=()=>{n.value||n.next(!0)},o=()=>{void 0!==r&&clearTimeout(r),r=void 0};this.subs.push(ch(this.behaviors.state.isUpdating,this.behaviors.state.isAnimating).subscribe(s=>{this.behaviors.state.isUpdating.value||this.behaviors.state.isAnimating.value?n.value||(o(),r=setTimeout(i,t)):(o(),n.next(!1))})),this.subs.push(this.behaviors.interaction.selectionMode.subscribe(s=>{var a;s||null===(a=this.managers.interactivity)||void 0===a||a.lociSelects.deselectAll()}))}initBuiltInBehavior(){JE.State.registerDefault(this),JE.Representation.registerDefault(this),JE.Camera.registerDefault(this),JE.Misc.registerDefault(this),this.subs.push(ch(this.state.data.events.log,this.state.behaviors.events.log).subscribe(t=>this.events.log.next(t)))}initBehaviors(){var t=this;return ie(function*(){let n=t.state.behaviors.build();for(const r of Object.keys(tr.Categories))n.toRoot().apply(tr.CreateCategory,{label:tr.Categories[r]},{ref:r,state:{isLocked:!0}});for(const r of t.spec.behaviors)"custom-props"===tr.getCategoryId(r.transformer)&&n.to(tr.getCategoryId(r.transformer)).apply(r.transformer,r.defaultParams,{ref:r.transformer.id});yield t.runTask(t.state.behaviors.updateTree(n,{doNotUpdateCurrent:!0,doNotLogTiming:!0})),n=t.state.behaviors.build();for(const r of t.spec.behaviors)"custom-props"!==tr.getCategoryId(r.transformer)&&n.to(tr.getCategoryId(r.transformer)).apply(r.transformer,r.defaultParams,{ref:r.transformer.id});yield t.runTask(t.state.behaviors.updateTree(n,{doNotUpdateCurrent:!0,doNotLogTiming:!0}))})()}initCustomFormats(){if(this.spec.customFormats)for(const t of this.spec.customFormats)this.dataFormats.add(t[0],t[1])}initAnimations(){if(this.spec.animations)for(const t of this.spec.animations)this.managers.animation.register(t)}initDataActions(){if(this.spec.actions)for(const t of this.spec.actions)this.state.data.actions.add(t.action)}init(){var t=this;return ie(function*(){try{t.subs.push(t.events.log.subscribe(n=>t.log.entries=t.log.entries.push(n))),t.initCustomFormats(),t.initBehaviorEvents(),t.initBuiltInBehavior(),t.managers.interactivity=new Lm(t),t.managers.lociLabels=new Xdt(t),t.builders.structure=new Sdt(t),t.initAnimations(),t.initDataActions(),yield t.initBehaviors(),t.log.message(`Mol* Plugin 4.0.1 [${btt.toLocaleString()}]`),Qx||t.log.message("Development mode enabled"),un&&t.log.message("Debug mode enabled"),t._isInitialized=!0,t.initializedPromiseCallbacks[0]()}catch(n){throw t.initializedPromiseCallbacks[1](n),n}})()}constructor(t){var n;this.spec=t,this.runTask=(r,i)=>this.managers.task.run(r,i),this.resolveTask=r=>{if(r)return Oe.is(r)?this.runTask(r):r},this.subs=[],this.initCanvas3dPromiseCallbacks=[()=>{},()=>{}],this._isInitialized=!1,this.initializedPromiseCallbacks=[()=>{},()=>{}],this.disposed=!1,this.canvasContainer=void 0,this.ev=wp.create(),this.config=new Itt(this.spec.config),this.state=new V1(this),this.commands=new ptt,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:yn.Loci.Empty,modifiers:wu.None,buttons:0,button:0}),click:this.ev.behavior({current:yn.Loci.Empty,modifiers:wu.None,buttons:0,button:0}),drag:this.ev.behavior({current:yn.Loci.Empty,modifiers:wu.None,buttons:0,button:0,pageStart:Me(),pageEnd:Me()}),key:this.ev.behavior(rue),keyReleased:this.ev.behavior(rue),selectionMode:this.ev.behavior(!1)},labels:{highlight:this.ev.behavior({labels:[]})},layout:{leftPanelTabName:this.ev.behavior("root")},canvas3d:{initialized:this.canvas3dInit.pipe(Yl(r=>!!r),Sg(1))}},this.canvas3dInitialized=new Promise((r,i)=>{this.initCanvas3dPromiseCallbacks=[r,i]}),this.initialized=new Promise((r,i)=>{this.initializedPromiseCallbacks=[r,i]}),this.layout=new Oft(this),this.animationLoop=new D0t(this),this.representation={structure:{registry:new kC,themes:{colorThemeRegistry:Lc.createRegistry(),sizeThemeRegistry:Qo.createRegistry()}},volume:{registry:new c1,themes:{colorThemeRegistry:Lc.createRegistry(),sizeThemeRegistry:Qo.createRegistry()}}},this.query={structure:{registry:new rYe}},this.dataFormats=new Rdt,this.builders={data:new mdt(this),structure:void 0},this.helpers={substructureParent:new E0t(this),viewportScreenshot:void 0},this.managers={structure:{hierarchy:new xC(this),component:new _C(this),measurement:new vft(this),selection:new xft(this),focus:new eft(this)},volume:{hierarchy:new kV(this)},interactivity:void 0,camera:new Ydt(this),animation:new kdt(this),snapshot:new Hv(this),lociLabels:void 0,toast:new P0t(this),asset:new TLe,task:new p7,dragAndDrop:new R0t(this)},this.events={log:this.ev(),task:this.managers.task.events,canvas3d:{settingsUpdated:this.ev()}},this.customModelProperties=new d3.Registry,this.customStructureProperties=new d3.Registry,this.customStructureControls=new Map,this.customImportControls=new Map,this.genericRepresentationControls=new Map,this.customState=Object.create(null),this.handleResize=()=>{var r,i;const o=null===(r=this.canvas3dContext)||void 0===r?void 0:r.canvas,s=this.layout.root;s&&o&&(function _tt(e,t,n=1){let r=window.innerWidth,i=window.innerHeight;t!==document.body&&(r=t.offsetWidth,i=t.offsetHeight),function vtt(e,t,n,r=1){e.width=Math.round(window.devicePixelRatio*r*t),e.height=Math.round(window.devicePixelRatio*r*n),Object.assign(e.style,{width:`${t}px`,height:`${n}px`})}(e,r,i,n)}(o,s,this.canvas3dContext.props.pixelScale),null===(i=this.canvas3d)||void 0===i||i.requestResize())},this.log={entries:Cp(),entry:r=>this.events.log.next(r),error:r=>this.events.log.next(df.error(r)),message:r=>this.events.log.next(df.message(r)),info:r=>this.events.log.next(df.info(r)),warn:r=>this.events.log.next(df.warning(r))},this.fetch=RO,EVe(!1),function GNe(e){up="default"===e?UQ:zNe}(null!==(n=this.config.get(qi.Structure.SaccharideCompIdMapType))&&void 0!==n?n:"default")}}let NC=(()=>{class e{set container(n){this.container$.next(n)}constructor(n){this.settingsService=n,this.container$=new ou(1),this.plugin=new N0t({actions:[an.Action(V0.Structure.DownloadStructure),an.Action(V0.Volume.DownloadDensity),an.Action(V0.DataFormat.DownloadFile),an.Action(V0.DataFormat.OpenFiles),an.Action(V0.Structure.LoadTrajectory),an.Action(V0.Structure.EnableModelCustomProps),an.Action(V0.Structure.EnableStructureCustomProps),an.Action(adt),an.Action(cdt),an.Action(rfe),an.Action(Ye.Data.Download),an.Action(Ye.Data.ParseCif),an.Action(Ye.Data.ParseCcp4),an.Action(Ye.Data.ParseDsn6),an.Action(Ye.Model.TrajectoryFromMmCif),an.Action(Ye.Model.TrajectoryFromCifCore),an.Action(Ye.Model.TrajectoryFromPDB),an.Action(Ye.Model.TransformStructureConformation),an.Action(Ye.Model.StructureFromModel),an.Action(Ye.Model.StructureFromTrajectory),an.Action(Ye.Model.ModelFromTrajectory),an.Action(Ye.Model.StructureSelectionFromScript),an.Action(Ye.Representation.StructureRepresentation3D),an.Action(Ye.Representation.StructureSelectionsDistance3D),an.Action(Ye.Representation.StructureSelectionsAngle3D),an.Action(Ye.Representation.StructureSelectionsDihedral3D),an.Action(Ye.Representation.StructureSelectionsLabel3D),an.Action(Ye.Representation.StructureSelectionsOrientation3D),an.Action(Ye.Representation.ModelUnitcell3D),an.Action(Ye.Representation.StructureBoundingBox3D),an.Action(Ye.Representation.ExplodeStructureRepresentation3D),an.Action(Ye.Representation.SpinStructureRepresentation3D),an.Action(Ye.Representation.UnwindStructureAssemblyRepresentation3D),an.Action(Ye.Representation.OverpaintStructureRepresentation3DFromScript),an.Action(Ye.Representation.TransparencyStructureRepresentation3DFromScript),an.Action(Ye.Representation.ClippingStructureRepresentation3DFromScript),an.Action(Ye.Representation.SubstanceStructureRepresentation3DFromScript),an.Action(Ye.Representation.ThemeStrengthRepresentation3D),an.Action(Ede),an.Action(Ye.Volume.VolumeFromCcp4),an.Action(Ye.Volume.VolumeFromDsn6),an.Action(Ye.Volume.VolumeFromCube),an.Action(Ye.Volume.VolumeFromDx),an.Action(Ye.Representation.VolumeRepresentation3D)],behaviors:[an.Behavior(zc.Representation.HighlightLoci),an.Behavior(zc.Representation.SelectLoci),an.Behavior(zc.Representation.DefaultLociLabelProvider),an.Behavior(zc.Representation.FocusLoci),an.Behavior(zc.Camera.FocusLoci),an.Behavior(zc.Camera.CameraAxisHelper),an.Behavior(zc.Camera.CameraControls),an.Behavior(t3),an.Behavior(zc.CustomProps.StructureInfo),an.Behavior(zc.CustomProps.AccessibleSurfaceArea),an.Behavior(zc.CustomProps.BestDatabaseSequenceMapping),an.Behavior(zc.CustomProps.Interactions),an.Behavior(zc.CustomProps.SecondaryStructure),an.Behavior(zc.CustomProps.ValenceModel),an.Behavior(zc.CustomProps.CrossLinkRestraint)],animations:[gtt,mtt,pdt,ytt,htt,fdt,ddt]});const r=this.settingsService.settings$;this.plugin$=this.container$.pipe(qt(i=>{const o=i.nativeElement;return{div:o,canvas:o.firstElementChild}}),jr(({div:i,canvas:o})=>this.plugin.initViewer(o,i)),To(()=>$i(this.plugin.init())),qt(()=>this.plugin),Zl(1),Ob(r),qt(([i,o])=>{if(i.canvas3d){const[s,a]=XS(o["background-color"]);i.canvas3d.setProps({renderer:{backgroundColor:s,pickingAlphaThreshold:a}})}return i}))}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(KS))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})(),tP=(()=>{class e{set source(n){this.source$.next(n)}constructor(n,r){var i=this;this.settingsService=n,this.pluginService=r,this.source$=new ou,this.structure$=dI([this.pluginService.plugin$,this.source$]).pipe(qt(([a,c])=>({plugin:a,source:c})),To(({source:a})=>$i(ie(function*(){return"local"===a.type?{data:yield i.parseLocalSource(a),source:a}:{data:yield i.parseRemoteSource(a),source:a}})())),To(({data:a,source:c})=>$i(ie(function*(){const u=i.pluginService.plugin,l=yield u.builders.structure.parseTrajectory(a,c.format),d=yield u.builders.structure.createModel(l,{modelIndex:0}),m=yield u.builders.structure.createStructure(d,{name:"model",params:{}}),h=yield u.builders.structure.tryCreateComponentStatic(m,"polymer",{label:c.label}),[g]=XS(i.settingsService.settings["backbone-color"]);return yield u.builders.structure.representation.addRepresentation(h,{type:"cartoon",color:"uniform",colorParams:{value:g}}),m.cell?.obj?.data})())),jr(a=>{let c=0;const u=this.r2i=new Map,l=this.i2r=new Map;Ve.eachAtomicHierarchyElement(a,{residue:d=>{const f=Ze.residue.auth_seq_id(d),p=Ze.residue.pdbx_PDB_ins_code(d),h=(Ze.chain.auth_asym_id(d)+f+p).trim();u.set(h,c),l.set(c,h),c++}})}),Zl(1))}parseRemoteSource(n){var r=this;return ie(function*(){const i=fr.Url(n.link);return r.pluginService.plugin.builders.data.download({url:i,label:n.label,isBinary:n.binary})})()}parseLocalSource(n){var r=this;return ie(function*(){const i=n.binary,o=n.label,s=r.pluginService.plugin;if("string"==typeof n.data)return s.builders.data.rawData({data:n.data,label:o});let a;a=n.data instanceof File?fr.File(n.data):fr.File(new File([n.data],`${o}.${"mmcif"===n.format?"cif":"ent"}`));const{data:c}=yield s.builders.data.readFile({file:a,label:o,isBinary:i});return c})()}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(KS),Zt(NC))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();function h7(e,t){return function F0t(e,t){const n=ko.getStructureSelection(e,t);return pt.toLociWithSourceUnits(n)}(ue.struct.generator.atomGroups({"residue-test":ue.core.set.has([ue.set(...e),ue.core.str.concat([ue.ammp("auth_asym_id"),ue.ammp("auth_seq_id"),ue.ammp("pdbx_PDB_ins_code")])])}),t)}let rme=(()=>{class e{set loci(n){this.loci$.next(n)}set interactions(n){this.interactions$.next(n)}constructor(n,r,i){this.structureService=n,this.settingsService=r,this.pluginService=i,this.loci$=new ou(1),this.interactions$=new ou(1);const o=this.getLociRepresentation(),s=this.getInteractionsRepresentation();this.representation$=this.structureService.structure$.pipe(Ob(o),Ob(s),qt(()=>{}),Zl(1)),this._representation=this.representation$.subscribe()}ngOnDestroy(){this._representation.unsubscribe()}getLociRepresentation(){return this.structureService.structure$.pipe(Ob(this.loci$),qt(([n,r])=>({structure:n,loci:r})),qt(({structure:n,loci:r})=>{const i=[...this.structureService.i2r.values()];return{structure:n,loci:r.map(s=>{if(s.start){s={...s,end:s.end||s.start};const a=this.structureService.r2i.get(s.chain+s.start),c=this.structureService.r2i.get(s.chain+s.end);return{...s,ids:i.slice(a,c+1)}}return{...s,ids:i.filter(a=>a.startsWith(s.chain))}})}}),To(({structure:n,loci:r})=>{const i=[];for(const{ids:c,color:u}of r){const l=h7(c,n),d=Kn.fromLoci(l),[f]=XS(u||this.settingsService.settings["backbone-color"]);i.push({bundle:d,color:f,clear:!1})}const o=this.pluginService.plugin,s=o.state.data.build(),a=function B0t(e,t){const n=Bo.ofBundle(e,t.root),r=Bo.merge(n);return Bo.filter(r,t)}(i,n);for(const c of o.managers.structure.hierarchy.current.structures)for(const u of c.components)for(const l of u.representations){s.to(l.cell.transform.ref).apply(Ye.Representation.OverpaintStructureRepresentation3DFromBundle,Bo.toBundle(a));const d=h7([...this.structureService.i2r.values()],n),f=Kn.fromLoci(d),[p,m]=XS(this.settingsService.settings["backbone-color"]);s.to(l.cell.transform.ref).apply(Ye.Representation.TransparencyStructureRepresentation3DFromBundle,{layers:[{bundle:f,value:m}]})}return $i(s.commit({doNotUpdateCurrent:!0}))}))}getInteractionsRepresentation(){let n;return this.structureService.structure$.pipe(Ob(this.interactions$),qt(([r,i])=>({structure:r,interactions:i})),qt(({structure:r,interactions:i})=>{const o=i.reduce((s,{from:a,to:c})=>[...s,a,c],[]);return Ve.eachAtomicHierarchyElement(r,{atom:s=>{const a=v.create(Ze.atom.x(s),Ze.atom.y(s),Ze.atom.z(s));for(const c of o)c.coordinates||(c["atom.id"]===Ze.atom.id(s)||c["chain.id"]===Ze.chain.auth_asym_id(s)&&c["residue.id"]===Ze.residue.auth_seq_id(s)+Ze.residue.pdbx_PDB_ins_code(s)&&c["atom.name"]===Ze.atom.auth_atom_id(s))&&(c.coordinates=a)}}),{structure:r,interactions:i=i.filter(({from:s,to:a})=>s.coordinates&&a.coordinates)}}),To(({interactions:r})=>{const o=this.pluginService.plugin.state.data.build(),s=r.map(({from:c,to:u,color:l,label:d,size:f})=>({from:c.coordinates,to:u.coordinates,color:XS(l||this.settingsService.settings["interaction-color"]).at(0),size:f||this.settingsService.settings["interaction-size"],label:d}));return n&&o.delete(n),n=o.toRoot().apply(ftt,{data:s}).apply(Ye.Representation.ShapeRepresentation3D).ref,$i(o.commit({doNotUpdateCurrent:!0}))}),Zl(1))}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tP),Zt(KS),Zt(NC))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();let ime=(()=>{class e{set highlights(n){this.input$.next(n)}constructor(n,r){this.structureService=n,this.pluginService=r,this.input$=new ou(1);const i=this.pluginService.plugin,o=i.behaviors.interaction.hover,s=this.structureService.structure$.pipe(Ob(this.input$),qt(([c,u])=>({structure:c,highlights:u})),qt(({structure:c,highlights:u})=>{if(u){const l=[...this.structureService.i2r.values()],d=this.structureService.r2i.get(u.chain+u.start),f=this.structureService.r2i.get(u.chain+u.end);return{structure:c,highlights:{...u,ids:l.slice(d,f+1)}}}return{structure:c,highlights:{start:"",end:"",chain:"",ids:[]}}}),qt(({structure:c,highlights:u})=>{if(u.ids.length>0){const l=h7(u.ids,c);i.managers.interactivity.lociHighlights.highlightOnly({loci:l})}}));this.output$=o.pipe(qt(c=>{if(c&&"element-loci"===c.current.loci.kind&&De.is(c.current.loci)){const u=De.getFirstLocation(c.current.loci);if(u){const l=Ze.chain.auth_asym_id(u),p=Ze.residue.auth_seq_id(u)+Ze.residue.pdbx_PDB_ins_code(u);return{start:p,end:p+"",chain:l}}}}),Zl(1),jr(c=>console.log("Highlighted",c)));const a=s.pipe(function L0t(...e){return function O0t(...e){const t=xb(e),n=yK(e,1/0);return e=CZ(e),mo((r,i)=>{xg(n)($i([r,...e],t)).subscribe(i)})}(...e)}(this.output$),qt(()=>{}));this._highlights=a.subscribe()}ngOnDestroy(){this._highlights.unsubscribe()}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tP),Zt(NC))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();const U0t=["container"];let nP=(()=>{class e{set container(n){this.pluginService.container=n}set source(n){this.structureService.source=n}set loci(n){this.representationService.loci=n}set interactions(n){this.representationService.interactions=n}set settings(n){this.settingsService.settings=n}set highlights(n){this.highlightService.highlights=n}constructor(n,r,i,o,s){this.representationService=n,this.highlightService=r,this.structureService=i,this.settingsService=o,this.pluginService=s,this.highlights$=this.highlightService.output$}static#e=this.\u0275fac=function(r){return new(r||e)(cn(rme),cn(ime),cn(tP),cn(KS),cn(NC))};static#t=this.\u0275cmp=Mu({type:e,selectors:[["ngx-structure-viewer"]],viewQuery:function(r,i){if(1&r&&dN(U0t,5),2&r){let o;EA(o=PA())&&(i.container=o.first)}},inputs:{source:"source",loci:"loci",interactions:"interactions",settings:"settings",highlights:"highlights"},outputs:{highlights$:"highlights"},standalone:!0,features:[MA([rme,ime,tP,KS,NC]),Nu],decls:4,vars:0,consts:[["container",""],["canvas",""],[2,"position","relative","width","100%","height","100%"],[2,"position","absolute","left","0","top","0","width","100%","height","100%"]],template:function(r,i){1&r&&(dn(0,"div",2,0),gi(2,"canvas",3,1),fn())}})}return e})();function ome(e=0,t=o3){return e<0&&(e=0),Nde(e,e,t)}const sme=e=>({coordinates:e}),ame=e=>({"atom.id":e}),cme=(e,t,n)=>({"chain.id":e,"residue.id":t,"atom.id":n});function V0t(e,t){1&e&&gi(0,"div",9),2&e&&pb("background-color",t)}function z0t(e,t){1&e&&(dn(0,"code",6)(1,"pre",10),ar(2),Ga(3,"json"),fn()()),2&e&&(mi(2),ku(ja(3,1,hx(3,sme,t.coordinates))))}function G0t(e,t){1&e&&(dn(0,"code",6)(1,"pre",10),ar(2),Ga(3,"json"),fn()()),2&e&&(mi(2),ku(ja(3,1,hx(3,sme,t.coordinates))))}function j0t(e,t){1&e&&gi(0,"div",9),2&e&&pb("background-color",t)}function H0t(e,t){1&e&&(dn(0,"code",6)(1,"pre",10),ar(2),Ga(3,"json"),fn()()),2&e&&(mi(2),ku(ja(3,1,hx(3,ame,t["atom.id"]))))}function q0t(e,t){1&e&&(dn(0,"code",6)(1,"pre",10),ar(2),Ga(3,"json"),fn()()),2&e&&(mi(2),ku(ja(3,1,hx(3,ame,t["atom.id"]))))}function W0t(e,t){1&e&&gi(0,"div",9),2&e&&pb("background-color",t)}function $0t(e,t){if(1&e&&(dn(0,"code",6)(1,"pre",10),ar(2),Ga(3,"json"),fn()()),2&e){const n=t;mi(2),ku(ja(3,1,yN(3,cme,n["chain.id"],n["residue.id"],n["atom.id"])))}}function Y0t(e,t){if(1&e&&(dn(0,"code",6)(1,"pre",10),ar(2),Ga(3,"json"),fn()()),2&e){const n=t;mi(2),ku(ja(3,1,yN(3,cme,n["chain.id"],n["residue.id"],n["atom.id"])))}}function X0t(e,t){if(1&e&&gi(0,"ngx-structure-viewer",8),2&e){const n=px();Bh("settings",n.settings)("source",n.source)("interactions",t)}}let K0t=(()=>{class e{constructor(n){this.baseHref=n,this.settings={"background-color":"#2b3035ff","backbone-color":"#6ea8fe40","interaction-color":"#ff0000ff","interaction-size":.5},this.source={type:"remote",format:"mmcif",label:"8VAP.A",binary:!1,link:this.baseHref+"assets/8vap.A.cif"},this.interactions=[{from:{coordinates:v.create(165.36768,188.18981,113.00826)},to:{coordinates:v.create(160.33379,162.30181,108.49545)},color:"#ff4500"},{from:{"atom.id":211},to:{"atom.id":374},color:"#adff2f"},{from:{"chain.id":"A","residue.id":"148","atom.name":"CA"},to:{"chain.id":"A","residue.id":"89","atom.name":"CD"},color:"#8a2be2"}],this.interactions$=ome(3e3).pipe(qt(()=>this.interactions.map(r=>({...r}))),qt(r=>r.sort(()=>Math.random()-.5)),qt(r=>[r[0]]),Dx([this.interactions[0]]),Zl(1))}static#e=this.\u0275fac=function(r){return new(r||e)(cn(KA))};static#t=this.\u0275cmp=Mu({type:e,selectors:[["app-section-interactions"]],standalone:!0,features:[MA([{provide:KA,useValue:"/"}]),Nu],decls:29,vars:12,consts:[[1,"row","mb-3"],[1,"col-6"],[1,"mb-3"],[1,"mb-1"],[1,"d-flex","flex-row","align-items-stretch","gap-1"],[1,"d-block","p-2",3,"background-color"],[1,"d-block","flex-1"],[1,"rounded","squared","overflow-hidden","bg-body-tertiary"],[3,"settings","source","interactions"],[1,"d-block","p-2"],[1,"bg-body-tertiary","p-3","m-0"]],template:function(r,i){if(1&r&&(dn(0,"div",0)(1,"div",1)(2,"h2"),ar(3,"Interactions"),fn(),dn(4,"div",2)(5,"p",3),ar(6,"1. Provide atom coordinates"),fn(),dn(7,"div",4),Jc(8,V0t,1,2,"div",5)(9,z0t,4,5,"code",6)(10,G0t,4,5,"code",6),fn()(),dn(11,"div",2)(12,"p",3),ar(13,"2. Provide atom identifier"),fn(),dn(14,"div",4),Jc(15,j0t,1,2,"div",5)(16,H0t,4,5,"code",6)(17,q0t,4,5,"code",6),fn()(),dn(18,"div",2)(19,"p",3),ar(20,"3. Provide chain, residue identifier and atom name"),fn(),dn(21,"div",4),Jc(22,W0t,1,2,"div",5)(23,$0t,4,7,"code",6)(24,Y0t,4,7,"code",6),fn()()(),dn(25,"div",1)(26,"div",7),Jc(27,X0t,1,3,"ngx-structure-viewer",8),Ga(28,"async"),fn()()()),2&r){let o,s,a,c,u,l,d,f,p,m;mi(8),Va(8,(o=i.interactions[0].color)?8:-1,o),mi(),Va(9,(s=i.interactions[0].from)?9:-1,s),mi(),Va(10,(a=i.interactions[0].to)?10:-1,a),mi(5),Va(15,(c=i.interactions[1].color)?15:-1,c),mi(),Va(16,(u=i.interactions[1].from)?16:-1,u),mi(),Va(17,(l=i.interactions[1].to)?17:-1,l),mi(5),Va(22,(d=i.interactions[2].color)?22:-1,d),mi(),Va(23,(f=i.interactions[2].from)?23:-1,f),mi(),Va(24,(p=i.interactions[2].to)?24:-1,p),mi(3),Va(27,(m=ja(28,10,i.interactions$))?27:-1,m)}},dependencies:[nP,Uh,Cx,cI]})}return e})();class rP{}class iP{}class Rl{constructor(t){this.normalizedNames=new Map,this.lazyUpdate=null,t?"string"==typeof t?this.lazyInit=()=>{this.headers=new Map,t.split("\n").forEach(n=>{const r=n.indexOf(":");if(r>0){const i=n.slice(0,r),o=i.toLowerCase(),s=n.slice(r+1).trim();this.maybeSetNormalizedName(i,o),this.headers.has(o)?this.headers.get(o).push(s):this.headers.set(o,[s])}})}:typeof Headers<"u"&&t instanceof Headers?(this.headers=new Map,t.forEach((n,r)=>{this.setHeaderEntries(r,n)})):this.lazyInit=()=>{this.headers=new Map,Object.entries(t).forEach(([n,r])=>{this.setHeaderEntries(n,r)})}:this.headers=new Map}has(t){return this.init(),this.headers.has(t.toLowerCase())}get(t){this.init();const n=this.headers.get(t.toLowerCase());return n&&n.length>0?n[0]:null}keys(){return this.init(),Array.from(this.normalizedNames.values())}getAll(t){return this.init(),this.headers.get(t.toLowerCase())||null}append(t,n){return this.clone({name:t,value:n,op:"a"})}set(t,n){return this.clone({name:t,value:n,op:"s"})}delete(t,n){return this.clone({name:t,value:n,op:"d"})}maybeSetNormalizedName(t,n){this.normalizedNames.has(n)||this.normalizedNames.set(n,t)}init(){this.lazyInit&&(this.lazyInit instanceof Rl?this.copyFrom(this.lazyInit):this.lazyInit(),this.lazyInit=null,this.lazyUpdate&&(this.lazyUpdate.forEach(t=>this.applyUpdate(t)),this.lazyUpdate=null))}copyFrom(t){t.init(),Array.from(t.headers.keys()).forEach(n=>{this.headers.set(n,t.headers.get(n)),this.normalizedNames.set(n,t.normalizedNames.get(n))})}clone(t){const n=new Rl;return n.lazyInit=this.lazyInit&&this.lazyInit instanceof Rl?this.lazyInit:this,n.lazyUpdate=(this.lazyUpdate||[]).concat([t]),n}applyUpdate(t){const n=t.name.toLowerCase();switch(t.op){case"a":case"s":let r=t.value;if("string"==typeof r&&(r=[r]),0===r.length)return;this.maybeSetNormalizedName(t.name,n);const i=("a"===t.op?this.headers.get(n):void 0)||[];i.push(...r),this.headers.set(n,i);break;case"d":const o=t.value;if(o){let s=this.headers.get(n);if(!s)return;s=s.filter(a=>-1===o.indexOf(a)),0===s.length?(this.headers.delete(n),this.normalizedNames.delete(n)):this.headers.set(n,s)}else this.headers.delete(n),this.normalizedNames.delete(n)}}setHeaderEntries(t,n){const r=(Array.isArray(n)?n:[n]).map(o=>o.toString()),i=t.toLowerCase();this.headers.set(i,r),this.maybeSetNormalizedName(t,i)}forEach(t){this.init(),Array.from(this.normalizedNames.keys()).forEach(n=>t(this.normalizedNames.get(n),this.headers.get(n)))}}class Z0t{encodeKey(t){return ume(t)}encodeValue(t){return ume(t)}decodeKey(t){return decodeURIComponent(t)}decodeValue(t){return decodeURIComponent(t)}}const J0t=/%(\d[a-f0-9])/gi,eyt={40:"@","3A":":",24:"$","2C":",","3B":";","3D":"=","3F":"?","2F":"/"};function ume(e){return encodeURIComponent(e).replace(J0t,(t,n)=>eyt[n]??t)}function oP(e){return`${e}`}class Xm{constructor(t={}){if(this.updates=null,this.cloneFrom=null,this.encoder=t.encoder||new Z0t,t.fromString){if(t.fromObject)throw new Error("Cannot specify both fromString and fromObject.");this.map=function Q0t(e,t){const n=new Map;return e.length>0&&e.replace(/^\?/,"").split("&").forEach(i=>{const o=i.indexOf("="),[s,a]=-1==o?[t.decodeKey(i),""]:[t.decodeKey(i.slice(0,o)),t.decodeValue(i.slice(o+1))],c=n.get(s)||[];c.push(a),n.set(s,c)}),n}(t.fromString,this.encoder)}else t.fromObject?(this.map=new Map,Object.keys(t.fromObject).forEach(n=>{const r=t.fromObject[n],i=Array.isArray(r)?r.map(oP):[oP(r)];this.map.set(n,i)})):this.map=null}has(t){return this.init(),this.map.has(t)}get(t){this.init();const n=this.map.get(t);return n?n[0]:null}getAll(t){return this.init(),this.map.get(t)||null}keys(){return this.init(),Array.from(this.map.keys())}append(t,n){return this.clone({param:t,value:n,op:"a"})}appendAll(t){const n=[];return Object.keys(t).forEach(r=>{const i=t[r];Array.isArray(i)?i.forEach(o=>{n.push({param:r,value:o,op:"a"})}):n.push({param:r,value:i,op:"a"})}),this.clone(n)}set(t,n){return this.clone({param:t,value:n,op:"s"})}delete(t,n){return this.clone({param:t,value:n,op:"d"})}toString(){return this.init(),this.keys().map(t=>{const n=this.encoder.encodeKey(t);return this.map.get(t).map(r=>n+"="+this.encoder.encodeValue(r)).join("&")}).filter(t=>""!==t).join("&")}clone(t){const n=new Xm({encoder:this.encoder});return n.cloneFrom=this.cloneFrom||this,n.updates=(this.updates||[]).concat(t),n}init(){null===this.map&&(this.map=new Map),null!==this.cloneFrom&&(this.cloneFrom.init(),this.cloneFrom.keys().forEach(t=>this.map.set(t,this.cloneFrom.map.get(t))),this.updates.forEach(t=>{switch(t.op){case"a":case"s":const n=("a"===t.op?this.map.get(t.param):void 0)||[];n.push(oP(t.value)),this.map.set(t.param,n);break;case"d":if(void 0===t.value){this.map.delete(t.param);break}{let r=this.map.get(t.param)||[];const i=r.indexOf(oP(t.value));-1!==i&&r.splice(i,1),r.length>0?this.map.set(t.param,r):this.map.delete(t.param)}}}),this.cloneFrom=this.updates=null)}}class tyt{constructor(){this.map=new Map}set(t,n){return this.map.set(t,n),this}get(t){return this.map.has(t)||this.map.set(t,t.defaultValue()),this.map.get(t)}delete(t){return this.map.delete(t),this}has(t){return this.map.has(t)}keys(){return this.map.keys()}}function lme(e){return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer}function dme(e){return typeof Blob<"u"&&e instanceof Blob}function fme(e){return typeof FormData<"u"&&e instanceof FormData}class FC{constructor(t,n,r,i){let o;if(this.url=n,this.body=null,this.reportProgress=!1,this.withCredentials=!1,this.responseType="json",this.method=t.toUpperCase(),function nyt(e){switch(e){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"JSONP":return!1;default:return!0}}(this.method)||i?(this.body=void 0!==r?r:null,o=i):o=r,o&&(this.reportProgress=!!o.reportProgress,this.withCredentials=!!o.withCredentials,o.responseType&&(this.responseType=o.responseType),o.headers&&(this.headers=o.headers),o.context&&(this.context=o.context),o.params&&(this.params=o.params),this.transferCache=o.transferCache),this.headers??=new Rl,this.context??=new tyt,this.params){const s=this.params.toString();if(0===s.length)this.urlWithParams=n;else{const a=n.indexOf("?");this.urlWithParams=n+(-1===a?"?":ad.set(f,t.setHeaders[f]),c)),t.setParams&&(u=Object.keys(t.setParams).reduce((d,f)=>d.set(f,t.setParams[f]),u)),new FC(n,r,o,{params:u,headers:c,context:l,reportProgress:a,responseType:i,withCredentials:s})}}var Km=function(e){return e[e.Sent=0]="Sent",e[e.UploadProgress=1]="UploadProgress",e[e.ResponseHeader=2]="ResponseHeader",e[e.DownloadProgress=3]="DownloadProgress",e[e.Response=4]="Response",e[e.User=5]="User",e}(Km||{});class m7{constructor(t,n=BC.Ok,r="OK"){this.headers=t.headers||new Rl,this.status=void 0!==t.status?t.status:n,this.statusText=t.statusText||r,this.url=t.url||null,this.ok=this.status>=200&&this.status<300}}class sP extends m7{constructor(t={}){super(t),this.type=Km.ResponseHeader}clone(t={}){return new sP({headers:t.headers||this.headers,status:void 0!==t.status?t.status:this.status,statusText:t.statusText||this.statusText,url:t.url||this.url||void 0})}}class sy extends m7{constructor(t={}){super(t),this.type=Km.Response,this.body=void 0!==t.body?t.body:null}clone(t={}){return new sy({body:void 0!==t.body?t.body:this.body,headers:t.headers||this.headers,status:void 0!==t.status?t.status:this.status,statusText:t.statusText||this.statusText,url:t.url||this.url||void 0})}}class z1 extends m7{constructor(t){super(t,0,"Unknown Error"),this.name="HttpErrorResponse",this.ok=!1,this.message=this.status>=200&&this.status<300?`Http failure during parsing for ${t.url||"(unknown url)"}`:`Http failure response for ${t.url||"(unknown url)"}: ${t.status} ${t.statusText}`,this.error=t.error||null}}var BC=function(e){return e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.EarlyHints=103]="EarlyHints",e[e.Ok=200]="Ok",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultiStatus=207]="MultiStatus",e[e.AlreadyReported=208]="AlreadyReported",e[e.ImUsed=226]="ImUsed",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.Unused=306]="Unused",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.UriTooLong=414]="UriTooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.ImATeapot=418]="ImATeapot",e[e.MisdirectedRequest=421]="MisdirectedRequest",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.Locked=423]="Locked",e[e.FailedDependency=424]="FailedDependency",e[e.TooEarly=425]="TooEarly",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HttpVersionNotSupported=505]="HttpVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired",e}(BC||{});function g7(e,t){return{body:t,headers:e.headers,context:e.context,observe:e.observe,params:e.params,reportProgress:e.reportProgress,responseType:e.responseType,withCredentials:e.withCredentials,transferCache:e.transferCache}}let pme=(()=>{class e{constructor(n){this.handler=n}request(n,r,i={}){let o;if(n instanceof FC)o=n;else{let c,u;c=i.headers instanceof Rl?i.headers:new Rl(i.headers),i.params&&(u=i.params instanceof Xm?i.params:new Xm({fromObject:i.params})),o=new FC(n,r,void 0!==i.body?i.body:null,{headers:c,context:i.context,params:u,reportProgress:i.reportProgress,responseType:i.responseType||"json",withCredentials:i.withCredentials,transferCache:i.transferCache})}const s=Pn(o).pipe(Sb(c=>this.handler.handle(c)));if(n instanceof FC||"events"===i.observe)return s;const a=s.pipe(Yl(c=>c instanceof sy));switch(i.observe||"body"){case"body":switch(o.responseType){case"arraybuffer":return a.pipe(qt(c=>{if(null!==c.body&&!(c.body instanceof ArrayBuffer))throw new Error("Response is not an ArrayBuffer.");return c.body}));case"blob":return a.pipe(qt(c=>{if(null!==c.body&&!(c.body instanceof Blob))throw new Error("Response is not a Blob.");return c.body}));case"text":return a.pipe(qt(c=>{if(null!==c.body&&"string"!=typeof c.body)throw new Error("Response is not a string.");return c.body}));default:return a.pipe(qt(c=>c.body))}case"response":return a;default:throw new Error(`Unreachable: unhandled observe type ${i.observe}}`)}}delete(n,r={}){return this.request("DELETE",n,r)}get(n,r={}){return this.request("GET",n,r)}head(n,r={}){return this.request("HEAD",n,r)}jsonp(n,r){return this.request("JSONP",n,{params:(new Xm).append(r,"JSONP_CALLBACK"),observe:"body",responseType:"json"})}options(n,r={}){return this.request("OPTIONS",n,r)}patch(n,r,i={}){return this.request("PATCH",n,g7(i,r))}post(n,r,i={}){return this.request("POST",n,g7(i,r))}put(n,r,i={}){return this.request("PUT",n,g7(i,r))}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(rP))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();function mme(e,t){return t(e)}function cyt(e,t){return(n,r)=>t.intercept(n,{handle:i=>e(i,r)})}const lyt=new Yt(""),OC=new Yt(""),gme=new Yt(""),yme=new Yt("");function dyt(){let e=null;return(t,n)=>{null===e&&(e=(bt(lyt,{optional:!0})??[]).reduceRight(cyt,mme));const r=bt(kh),i=r.add();return e(t,n).pipe(Ex(()=>r.remove(i)))}}let bme=(()=>{class e extends rP{constructor(n,r){super(),this.backend=n,this.injector=r,this.chain=null,this.pendingTasks=bt(kh);const i=bt(yme,{optional:!0});this.backend=i??n}handle(n){if(null===this.chain){const i=Array.from(new Set([...this.injector.get(OC),...this.injector.get(gme,[])]));this.chain=i.reduceRight((o,s)=>function uyt(e,t,n){return(r,i)=>Md(n,()=>t(r,o=>e(o,i)))}(o,s,this.injector),mme)}const r=this.pendingTasks.add();return this.chain(n,i=>this.backend.handle(i)).pipe(Ex(()=>this.pendingTasks.remove(r)))}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(iP),Zt(xc))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();const gyt=/^\)\]\}',?\n/;let _me=(()=>{class e{constructor(n){this.xhrFactory=n}handle(n){if("JSONP"===n.method)throw new It(-2800,!1);const r=this.xhrFactory;return(r.\u0275loadImpl?$i(r.\u0275loadImpl()):Pn(null)).pipe(To(()=>new ns(o=>{const s=r.build();if(s.open(n.method,n.urlWithParams),n.withCredentials&&(s.withCredentials=!0),n.headers.forEach((h,g)=>s.setRequestHeader(h,g.join(","))),n.headers.has("Accept")||s.setRequestHeader("Accept","application/json, text/plain, */*"),!n.headers.has("Content-Type")){const h=n.detectContentTypeHeader();null!==h&&s.setRequestHeader("Content-Type",h)}if(n.responseType){const h=n.responseType.toLowerCase();s.responseType="json"!==h?h:"text"}const a=n.serializeBody();let c=null;const u=()=>{if(null!==c)return c;const h=s.statusText||"OK",g=new Rl(s.getAllResponseHeaders()),y=function yyt(e){return"responseURL"in e&&e.responseURL?e.responseURL:/^X-Request-URL:/m.test(e.getAllResponseHeaders())?e.getResponseHeader("X-Request-URL"):null}(s)||n.url;return c=new sP({headers:g,status:s.status,statusText:h,url:y}),c},l=()=>{let{headers:h,status:g,statusText:y,url:b}=u(),x=null;g!==BC.NoContent&&(x=typeof s.response>"u"?s.responseText:s.response),0===g&&(g=x?BC.Ok:0);let _=g>=200&&g<300;if("json"===n.responseType&&"string"==typeof x){const S=x;x=x.replace(gyt,"");try{x=""!==x?JSON.parse(x):null}catch(A){x=S,_&&(_=!1,x={error:A,text:x})}}_?(o.next(new sy({body:x,headers:h,status:g,statusText:y,url:b||void 0})),o.complete()):o.error(new z1({error:x,headers:h,status:g,statusText:y,url:b||void 0}))},d=h=>{const{url:g}=u(),y=new z1({error:h,status:s.status||0,statusText:s.statusText||"Unknown Error",url:g||void 0});o.error(y)};let f=!1;const p=h=>{f||(o.next(u()),f=!0);let g={type:Km.DownloadProgress,loaded:h.loaded};h.lengthComputable&&(g.total=h.total),"text"===n.responseType&&s.responseText&&(g.partialText=s.responseText),o.next(g)},m=h=>{let g={type:Km.UploadProgress,loaded:h.loaded};h.lengthComputable&&(g.total=h.total),o.next(g)};return s.addEventListener("load",l),s.addEventListener("error",d),s.addEventListener("timeout",d),s.addEventListener("abort",d),n.reportProgress&&(s.addEventListener("progress",p),null!==a&&s.upload&&s.upload.addEventListener("progress",m)),s.send(a),o.next({type:Km.Sent}),()=>{s.removeEventListener("error",d),s.removeEventListener("abort",d),s.removeEventListener("load",l),s.removeEventListener("timeout",d),n.reportProgress&&(s.removeEventListener("progress",p),null!==a&&s.upload&&s.upload.removeEventListener("progress",m)),s.readyState!==s.DONE&&s.abort()}})))}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(PX))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();const v7=new Yt(""),xme=new Yt("",{providedIn:"root",factory:()=>"XSRF-TOKEN"}),Sme=new Yt("",{providedIn:"root",factory:()=>"X-XSRF-TOKEN"});class Cme{}let _yt=(()=>{class e{constructor(n,r,i){this.doc=n,this.platform=r,this.cookieName=i,this.lastCookieString="",this.lastToken=null,this.parseCount=0}getToken(){if("server"===this.platform)return null;const n=this.doc.cookie||"";return n!==this.lastCookieString&&(this.parseCount++,this.lastToken=xX(n,this.cookieName),this.lastCookieString=n),this.lastToken}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tu),Zt(Th),Zt(xme))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();function xyt(e,t){const n=e.url.toLowerCase();if(!bt(v7)||"GET"===e.method||"HEAD"===e.method||n.startsWith("http://")||n.startsWith("https://"))return t(e);const r=bt(Cme).getToken(),i=bt(Sme);return null!=r&&!e.headers.has(i)&&(e=e.clone({headers:e.headers.set(i,r)})),t(e)}var Zm=function(e){return e[e.Interceptors=0]="Interceptors",e[e.LegacyInterceptors=1]="LegacyInterceptors",e[e.CustomXsrfConfiguration=2]="CustomXsrfConfiguration",e[e.NoXsrfProtection=3]="NoXsrfProtection",e[e.JsonpSupport=4]="JsonpSupport",e[e.RequestsMadeViaParent=5]="RequestsMadeViaParent",e[e.Fetch=6]="Fetch",e}(Zm||{});function Syt(...e){const t=[pme,_me,bme,{provide:rP,useExisting:bme},{provide:iP,useExisting:_me},{provide:OC,useValue:xyt,multi:!0},{provide:v7,useValue:!0},{provide:Cme,useClass:_yt}];for(const n of e)t.push(...n.\u0275providers);return Iy(t)}const wme=new Yt("");function Cyt(){return function ay(e,t){return{\u0275kind:e,\u0275providers:t}}(Zm.LegacyInterceptors,[{provide:wme,useFactory:dyt},{provide:OC,useExisting:wme,multi:!0}])}let wyt=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275mod=f_({type:e});static#n=this.\u0275inj=Sy({providers:[Syt(Cyt())]})}return e})();function Pyt(e,t){1&e&&gi(0,"ngx-structure-viewer",5),2&e&&Bh("settings",px().settings)("source",t)}function Myt(e,t){1&e&&gi(0,"ngx-structure-viewer",5),2&e&&Bh("settings",px().settings)("source",t)}let Ryt=(()=>{class e{constructor(n){this.http=n,this.local={type:"local",format:"mmcif",label:"8VAP.A",binary:!1,data:"..."},this.remote={type:"remote",format:"mmcif",label:"8VAP",binary:!1,link:"..."},this.settings={"background-color":"#2b3035ff","backbone-color":"#6ea8fecc","interaction-color":"#ff0000ff","interaction-size":1},this.local$=this.http.get("assets/8vap.A.cif",{responseType:"text"}).pipe(qt(r=>new Blob([r],{type:"text/plain"})),qt(r=>({...this.local,data:r}))),this.remote$=Pn({...this.remote,link:"https://files.rcsb.org/view/8VAP.cif"})}static#e=this.\u0275fac=function(r){return new(r||e)(cn(pme))};static#t=this.\u0275cmp=Mu({type:e,selectors:[["app-section-sources"]],standalone:!0,features:[Nu],decls:25,vars:12,consts:[[1,"row","mb-3"],[1,"col-6"],[1,"d-flex","flex-row","align-items-start","gap-3","mb-3"],[1,"d-block","flex-grow-1"],[1,"rounded","squared","bg-body-tertiary","overflow-hidden"],[3,"settings","source"],[1,"d-block","flex-shrink-0","bg-body-tertiary","p-3"],[1,"mb-0"]],template:function(r,i){if(1&r&&(dn(0,"div",0)(1,"div",1)(2,"h2"),ar(3,"Upload local structure"),fn(),dn(4,"div",2)(5,"div",3)(6,"div",4),Jc(7,Pyt,1,2,"ngx-structure-viewer",5),Ga(8,"async"),fn()(),dn(9,"code",6)(10,"pre",7),ar(11),Ga(12,"json"),fn()()()(),dn(13,"div",1)(14,"h2"),ar(15,"Download remote structure"),fn(),dn(16,"div",2)(17,"div",3)(18,"div",4),Jc(19,Myt,1,2,"ngx-structure-viewer",5),Ga(20,"async"),fn()(),dn(21,"code",6)(22,"pre",7),ar(23),Ga(24,"json"),fn()()()()()),2&r){let o,s;mi(7),Va(7,(o=ja(8,4,i.local$))?7:-1,o),mi(4),ku(ja(12,6,i.local)),mi(8),Va(19,(s=ja(20,8,i.remote$))?19:-1,s),mi(4),ku(ja(24,10,i.remote))}},dependencies:[nP,wyt,Uh,Cx,cI]})}return e})();function kyt(e,t){if(1&e&&(dn(0,"div",6)(1,"div",7),gi(2,"div",8),dn(3,"code",9)(4,"pre",10),ar(5),Ga(6,"json"),fn()()()()),2&e){const n=t.$implicit;mi(2),pb("background-color",n.color),mi(3),ku(ja(6,3,n))}}function Nyt(e,t){if(1&e&&(dn(0,"div",0)(1,"div",1)(2,"div",2),gi(3,"ngx-structure-viewer",3),fn()(),dn(4,"div",4)(5,"h2"),ar(6,"Color chain"),fn(),dn(7,"div",5),function MW(e,t,n,r,i,o,s,a,c,u,l,d,f){Vd("NgControlFlow");const p=void 0!==c,m=it(),h=a?s.bind(m[go][Mi]):s,g=new Y2e(p,h);m[Vn+e]=g,Jc(e+1,t,n,r,i,o),p&&Jc(e+2,c,u,l,d,f)}(8,kyt,7,5,"div",6,PW),fn()()()),2&e){const n=t,r=px();mi(3),Bh("settings",r.settings)("source",r.source)("loci",n),mi(5),function RW(e){const t=sr(null),n=la();try{const r=it(),i=r[Mt],o=r[n];if(void 0===o.liveCollection){const a=n+1,c=rN(r,a),u=iN(i,a);o.liveCollection=new X2e(c,r,u)}else o.liveCollection.reset();const s=o.liveCollection;if(function q2e(e,t,n){let r,i,o=0,s=e.length-1;if(Array.isArray(t)){let a=t.length-1;for(;o<=s&&o<=a;){const c=e.at(o),u=t[o],l=tN(o,c,o,u,n);if(0!==l){l<0&&e.updateValue(o,u),o++;continue}const d=e.at(s),f=t[a],p=tN(s,d,a,f,n);if(0!==p){p<0&&e.updateValue(s,f),s--,a--;continue}const m=n(o,c),h=n(s,d),g=n(o,u);if(Object.is(g,h)){const y=n(a,f);Object.is(y,m)?(e.swap(o,s),e.updateValue(s,f),a--,s--):e.move(s,o),e.updateValue(o,u),o++}else if(r??=new EW,i??=DW(e,o,s,n),nN(e,r,o,g))e.updateValue(o,u),o++,s++;else if(i.has(g))r.set(m,e.detach(o)),s--;else{const y=e.create(o,t[o]);e.attach(o,y),o++,s++}}for(;o<=a;)TW(e,r,n,o,t[o]),o++}else if(null!=t){const a=t[Symbol.iterator]();let c=a.next();for(;!c.done&&o<=s;){const u=e.at(o),l=c.value,d=tN(o,u,o,l,n);if(0!==d)d<0&&e.updateValue(o,l),o++,c=a.next();else{r??=new EW,i??=DW(e,o,s,n);const f=n(o,l);if(nN(e,r,o,f))e.updateValue(o,l),o++,s++,c=a.next();else if(i.has(f)){const p=n(o,u);r.set(p,e.detach(o)),s--}else e.attach(o,e.create(o,l)),o++,s++,c=a.next()}}for(;!c.done;)TW(e,r,n,e.length,c.value),c=a.next()}for(;o<=s;)e.destroy(e.detach(s--));r?.forEach(a=>{e.destroy(a)})}(s,e,o.trackByFn),s.updateIndexes(),o.hasEmptyBlock){const a=zl(),c=0===s.length;if(jo(r,a,c)){const u=n+2,l=rN(r,u);if(c){const d=iN(i,u),f=Xy(l,d.tView.ssrId);z_(l,V_(r,d,void 0,{dehydratedView:f}),0,Yy(d,f))}else pk(l,0)}}}finally{sr(t)}}(n)}}let Fyt=(()=>{class e{constructor(){this.settings={"background-color":"#2b3035ff","backbone-color":"#6ea8fecc","interaction-color":"#ff0000ff","interaction-size":1},this.source={type:"remote",format:"mmcif",label:"8VAP",binary:!1,link:"assets/8vap.cif"};const n=[{chain:"A",color:"#6f42c1"},{chain:"B",color:"#0d6efd"},{chain:"C",color:"#dc3545"},{chain:"D",color:"#ffc107"},{chain:"E",color:"#28a745"},{chain:"F",color:"#17a2b8"},{chain:"G",color:"#fd7e14"}];this.chains$=ome(3e3).pipe(qt(()=>n.map(r=>r.color)),qt(r=>r.sort(()=>Math.random()-.5)),qt(r=>r.map((i,o)=>({...n[o],color:i}))),Dx(n),Zl(1))}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["app-section-chains"]],standalone:!0,features:[Nu],decls:2,vars:3,consts:[[1,"row","mb-3"],[1,"col-9"],[1,"rounded","squared","overflow-hidden","shadow-sm"],[3,"settings","source","loci"],[1,"col-3","pt-0","p-3"],[1,"d-flex","flex-column","gap-2"],[1,"flex-1"],[1,"d-flex","flex-row","gap-2"],[1,"d-block","flex-shrink-0","p-2"],[1,"bg-body-tertiary","flex-grow-1","p-3"],[1,"m-0"]],template:function(r,i){if(1&r&&(Jc(0,Nyt,10,3,"div",0),Ga(1,"async")),2&r){let o;Va(0,(o=ja(1,1,i.chains$))?0:-1,o)}},dependencies:[nP,Uh,Cx,cI],changeDetection:0})}return e})();function Byt(e,t){1&e&&(dn(0,"div",4)(1,"code",6),ar(2),fn()()),2&e&&(mi(2),ku(t))}let Oyt=(()=>{class e{constructor(){this.label$=new ou(1),this.settings={"background-color":"#2b3035ff","backbone-color":"#6ea8fecc","interaction-color":"#ff0000ff","interaction-size":1},this.source={type:"remote",format:"mmcif",label:"8VAP",binary:!1,link:"assets/8vap.cif"}}onHighlights(n){this.label$.next(n?`Chain: ${n.chain}; Start: ${n.start}; End: ${n.end}.`:"")}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["app-section-highlights"]],standalone:!0,features:[Nu],decls:9,vars:5,consts:[[1,"row","mb-3"],[1,"col-6","position-relative"],[1,"squared","rounded","overflow-hidden","bg-body-tertiary"],[3,"highlights","settings","source"],[1,"d-block","position-absolute","bottom-0","end-0","w-auto","h-auto","pe-3"],[1,"col-6"],[1,"d-block","p-3"]],template:function(r,i){if(1&r&&(dn(0,"div",0)(1,"div",1)(2,"div",2)(3,"ngx-structure-viewer",3),fx("highlights",function(s){return i.onHighlights(s)}),fn()(),Jc(4,Byt,3,1,"div",4),Ga(5,"async"),fn(),dn(6,"div",5)(7,"h2"),ar(8,"Highlights"),fn()()()),2&r){let o;mi(3),Bh("settings",i.settings)("source",i.source),mi(),Va(4,(o=ja(5,3,i.label$))?4:-1,o)}},dependencies:[nP,Uh,Cx],changeDetection:0})}return e})(),Lyt=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["page-structure-viewer"]],standalone:!0,features:[Nu],decls:13,vars:0,consts:[[1,"container","pt-3"],[1,"mb-3"]],template:function(r,i){1&r&&(dn(0,"div",0)(1,"div",1)(2,"h1"),ar(3,"Structure viewer"),fn(),dn(4,"p"),ar(5," The "),dn(6,"b"),ar(7,"ngx-structure-viewer"),fn(),ar(8," is a Mol* wrapper for Angular. It is a viewer for molecular structures and can be used to visualize and interact with 3D molecular structures. It works out of the box with the latest releases of Angular and automatized the most common features of Mol*. "),fn()(),gi(9,"app-section-sources")(10,"app-section-chains")(11,"app-section-interactions")(12,"app-section-highlights"),fn())},dependencies:[K0t,Oyt,Ryt,Fyt,jF,Uh],styles:[".progress-bar[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_progress 10s linear infinite;width:0}@keyframes _ngcontent-%COMP%_progress{0%{width:0}to{width:100%}}"]})}return e})();function Uyt(e){return e}function Vyt(e){return"translate("+e+",0)"}function zyt(e){return"translate(0,"+e+")"}function Gyt(e){return t=>+e(t)}function jyt(e,t){return t=Math.max(0,e.bandwidth()-2*t)/2,e.round()&&(t=Math.round(t)),n=>+e(n)+t}function Hyt(){return!this.__axis}function lP(e,t){var n=[],r=null,i=null,o=6,s=6,a=3,c=typeof window<"u"&&window.devicePixelRatio>1?0:.5,u=1===e||4===e?-1:1,l=4===e||2===e?"x":"y",d=1===e||3===e?Vyt:zyt;function f(p){var m=r??(t.ticks?t.ticks.apply(t,n):t.domain()),h=i??(t.tickFormat?t.tickFormat.apply(t,n):Uyt),g=Math.max(o,0)+a,y=t.range(),b=+y[0]+c,x=+y[y.length-1]+c,_=(t.bandwidth?jyt:Gyt)(t.copy(),c),S=p.selection?p.selection():p,A=S.selectAll(".domain").data([null]),E=S.selectAll(".tick").data(m,t).order(),w=E.exit(),D=E.enter().append("g").attr("class","tick"),I=E.select("line"),R=E.select("text");A=A.merge(A.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),E=E.merge(D),I=I.merge(D.append("line").attr("stroke","currentColor").attr(l+"2",u*o)),R=R.merge(D.append("text").attr("fill","currentColor").attr(l,u*g).attr("dy",1===e?"0em":3===e?"0.71em":"0.32em")),p!==S&&(A=A.transition(p),E=E.transition(p),I=I.transition(p),R=R.transition(p),w=w.transition(p).attr("opacity",1e-6).attr("transform",function(T){return isFinite(T=_(T))?d(T+c):this.getAttribute("transform")}),D.attr("opacity",1e-6).attr("transform",function(T){var M=this.parentNode.__axis;return d((M&&isFinite(M=M(T))?M:_(T))+c)})),w.remove(),A.attr("d",4===e||2===e?s?"M"+u*s+","+b+"H"+c+"V"+x+"H"+u*s:"M"+c+","+b+"V"+x:s?"M"+b+","+u*s+"V"+c+"H"+x+"V"+u*s:"M"+b+","+c+"H"+x),E.attr("opacity",1).attr("transform",function(T){return d(_(T)+c)}),I.attr(l+"2",u*o),R.attr(l,u*g).text(h),S.filter(Hyt).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===e?"start":4===e?"end":"middle"),S.each(function(){this.__axis=_})}return f.scale=function(p){return arguments.length?(t=p,f):t},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(p){return arguments.length?(n=null==p?[]:Array.from(p),f):n.slice()},f.tickValues=function(p){return arguments.length?(r=null==p?null:Array.from(p),f):r&&r.slice()},f.tickFormat=function(p){return arguments.length?(i=p,f):i},f.tickSize=function(p){return arguments.length?(o=s=+p,f):o},f.tickSizeInner=function(p){return arguments.length?(o=+p,f):o},f.tickSizeOuter=function(p){return arguments.length?(s=+p,f):s},f.tickPadding=function(p){return arguments.length?(a=+p,f):a},f.offset=function(p){return arguments.length?(c=+p,f):c},f}function Wyt(){}function x7(e){return null==e?Wyt:function(){return this.querySelector(e)}}function Xyt(){return[]}function Rme(e){return null==e?Xyt:function(){return this.querySelectorAll(e)}}function kme(e){return function(){return this.matches(e)}}function Nme(e){return function(t){return t.matches(e)}}var Qyt=Array.prototype.find;function ebt(){return this.firstElementChild}var nbt=Array.prototype.filter;function rbt(){return Array.from(this.children)}function Fme(e){return new Array(e.length)}function dP(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function ubt(e,t,n,r,i,o){for(var a,s=0,c=t.length,u=o.length;st?1:e>=t?0:NaN}dP.prototype={constructor:dP,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};var S7="http://www.w3.org/1999/xhtml";const Bme={svg:"http://www.w3.org/2000/svg",xhtml:S7,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function fP(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),Bme.hasOwnProperty(t)?{space:Bme[t],local:e}:e}function Ibt(e){return function(){this.removeAttribute(e)}}function Tbt(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Dbt(e,t){return function(){this.setAttribute(e,t)}}function Ebt(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Pbt(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function Mbt(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Ome(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function kbt(e){return function(){this.style.removeProperty(e)}}function Nbt(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Fbt(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function G1(e,t){return e.style.getPropertyValue(t)||Ome(e).getComputedStyle(e,null).getPropertyValue(t)}function Obt(e){return function(){delete this[e]}}function Lbt(e,t){return function(){this[e]=t}}function Ubt(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function Lme(e){return e.trim().split(/^|\s+/)}function C7(e){return e.classList||new Ume(e)}function Ume(e){this._node=e,this._names=Lme(e.getAttribute("class")||"")}function Vme(e,t){for(var n=C7(e),r=-1,i=t.length;++r=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var jme=[null];function Pu(e,t){this._groups=e,this._parents=t}function Hme(){return new Pu([[document.documentElement]],jme)}Pu.prototype=Hme.prototype={constructor:Pu,select:function $yt(e){"function"!=typeof e&&(e=x7(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=x&&(x=b+1);!(S=g[x])&&++x=0;)(s=r[i])&&(o&&4^s.compareDocumentPosition(o)&&o.parentNode.insertBefore(s,o),o=s);return this},sort:function bbt(e){function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}e||(e=vbt);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==t?kbt:"function"==typeof t?Fbt:Nbt)(e,t,n??"")):G1(this.node(),e)},property:function Vbt(e,t){return arguments.length>1?this.each((null==t?Obt:"function"==typeof t?Ubt:Lbt)(e,t)):this.node()[e]},classed:function Hbt(e,t){var n=Lme(e+"");if(arguments.length<2){for(var r=C7(this.node()),i=-1,o=n.length;++i=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}(e+""),o=r.length;if(!(arguments.length<2)){for(a=t?yvt:gvt,i=0;i{}};function qme(){for(var r,e=0,t=arguments.length,n={};e=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}(e+"",n),o=-1,s=r.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++o0)for(var i,o,n=new Array(i),r=0;r=0&&e._call.call(void 0,t),e=e._next;--j1}()}finally{j1=0,function Pvt(){for(var e,n,t=hP,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:hP=n);GC=e,I7(r)}(),cy=0}}function Evt(){var e=jC.now(),t=e-mP;t>Yme&&(gP-=t,mP=e)}function I7(e){j1||(VC&&(VC=clearTimeout(VC)),e-cy>24?(e<1/0&&(VC=setTimeout(Zme,e-jC.now()-gP)),zC&&(zC=clearInterval(zC))):(zC||(mP=jC.now(),zC=setInterval(Evt,Yme)),j1=1,Xme(Zme)))}function Qme(e,t,n){var r=new yP;return r.restart(i=>{r.stop(),e(i+t)},t=null==t?0:+t,n),r}yP.prototype=Kme.prototype={constructor:yP,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?A7():+n)+(null==t?0:+t),!this._next&&GC!==this&&(GC?GC._next=this:hP=this,GC=this),this._call=e,this._time=n,I7()},stop:function(){this._call&&(this._call=null,this._time=1/0,I7())}};var Mvt=$me("start","end","cancel","interrupt"),Rvt=[],Jme=0,T7=2,bP=3,D7=5,vP=6;function _P(e,t,n,r,i,o){var s=e.__transition;if(s){if(n in s)return}else e.__transition={};!function kvt(e,t,n){var i,r=e.__transition;function s(u){var l,d,f,p;if(1!==n.state)return c();for(l in r)if((p=r[l]).name===n.name){if(p.state===bP)return Qme(s);4===p.state?(p.state=vP,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete r[l]):+lJme)throw new Error("too late; already scheduled");return n}function zf(e,t){var n=Id(e,t);if(n.state>bP)throw new Error("too late; already running");return n}function Id(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function xP(e,t){var r,i,s,n=e.__transition,o=!0;if(n){for(s in t=null==t?null:t+"",n)(r=n[s]).name===t?(i=r.state>T7&&r.state180?l+=360:l-u>180&&(u+=360),f.push({i:d.push(i(d)+"rotate(",null,r)-2,x:Td(u,l)})):l&&d.push(i(d)+"rotate("+l+r)}(u.rotate,l.rotate,d,f),function a(u,l,d,f){u!==l?f.push({i:d.push(i(d)+"skewX(",null,r)-2,x:Td(u,l)}):l&&d.push(i(d)+"skewX("+l+r)}(u.skewX,l.skewX,d,f),function c(u,l,d,f,p,m){if(u!==d||l!==f){var h=p.push(i(p)+"scale(",null,",",null,")");m.push({i:h-4,x:Td(u,d)},{i:h-2,x:Td(l,f)})}else(1!==d||1!==f)&&p.push(i(p)+"scale("+d+","+f+")")}(u.scaleX,u.scaleY,l.scaleX,l.scaleY,d,f),u=l=null,function(p){for(var g,m=-1,h=f.length;++m>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?wP(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?wP(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=jvt.exec(e))?new qc(t[1],t[2],t[3],1):(t=Hvt.exec(e))?new qc(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=qvt.exec(e))?wP(t[1],t[2],t[3],t[4]):(t=Wvt.exec(e))?wP(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=$vt.exec(e))?fge(t[1],t[2]/100,t[3]/100,1):(t=Yvt.exec(e))?fge(t[1],t[2]/100,t[3]/100,t[4]):sge.hasOwnProperty(e)?uge(sge[e]):"transparent"===e?new qc(NaN,NaN,NaN,0):null}function uge(e){return new qc(e>>16&255,e>>8&255,255&e,1)}function wP(e,t,n,r){return r<=0&&(e=t=n=NaN),new qc(e,t,n,r)}function AP(e,t,n,r){return 1===arguments.length?function Zvt(e){return e instanceof HC||(e=uy(e)),e?new qc((e=e.rgb()).r,e.g,e.b,e.opacity):new qc}(e):new qc(e,t,n,r??1)}function qc(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function lge(){return`#${dy(this.r)}${dy(this.g)}${dy(this.b)}`}function dge(){const e=IP(this.opacity);return`${1===e?"rgb(":"rgba("}${ly(this.r)}, ${ly(this.g)}, ${ly(this.b)}${1===e?")":`, ${e})`}`}function IP(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ly(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function dy(e){return((e=ly(e))<16?"0":"")+e.toString(16)}function fge(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Dd(e,t,n,r)}function pge(e){if(e instanceof Dd)return new Dd(e.h,e.s,e.l,e.opacity);if(e instanceof HC||(e=uy(e)),!e)return new Dd;if(e instanceof Dd)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),s=NaN,a=o-i,c=(o+i)/2;return a?(s=t===o?(n-r)/a+6*(n0&&c<1?0:s,new Dd(s,a,c,e.opacity)}function Dd(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function hge(e){return(e=(e||0)%360)<0?e+360:e}function TP(e){return Math.max(0,Math.min(1,e||0))}function k7(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}function mge(e,t,n,r,i){var o=e*e,s=o*e;return((1-3*e+3*o-s)*t+(4-6*o+3*s)*n+(1+3*e+3*o-3*s)*r+s*i)/6}R7(HC,uy,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:age,formatHex:age,formatHex8:function Xvt(){return this.rgb().formatHex8()},formatHsl:function Kvt(){return pge(this).formatHsl()},formatRgb:cge,toString:cge}),R7(qc,AP,oge(HC,{brighter(e){return e=null==e?CP:Math.pow(CP,e),new qc(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new qc(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new qc(ly(this.r),ly(this.g),ly(this.b),IP(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:lge,formatHex:lge,formatHex8:function Qvt(){return`#${dy(this.r)}${dy(this.g)}${dy(this.b)}${dy(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:dge,toString:dge})),R7(Dd,function Jvt(e,t,n,r){return 1===arguments.length?pge(e):new Dd(e,t,n,r??1)},oge(HC,{brighter(e){return e=null==e?CP:Math.pow(CP,e),new Dd(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new Dd(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new qc(k7(e>=240?e-240:e+120,i,r),k7(e,i,r),k7(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Dd(hge(this.h),TP(this.s),TP(this.l),IP(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=IP(this.opacity);return`${1===e?"hsl(":"hsla("}${hge(this.h)}, ${100*TP(this.s)}%, ${100*TP(this.l)}%${1===e?")":`, ${e})`}`}}));const N7=e=>()=>e;function yge(e,t){var n=t-e;return n?function gge(e,t){return function(n){return e+n*t}}(e,n):N7(isNaN(e)?t:e)}const DP=function e(t){var n=function r1t(e){return 1==(e=+e)?yge:function(t,n){return n-t?function n1t(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}(t,n,e):N7(isNaN(t)?n:t)}}(t);function r(i,o){var s=n((i=AP(i)).r,(o=AP(o)).r),a=n(i.g,o.g),c=n(i.b,o.b),u=yge(i.opacity,o.opacity);return function(l){return i.r=s(l),i.g=a(l),i.b=c(l),i.opacity=u(l),i+""}}return r.gamma=e,r}(1);function bge(e){return function(t){var s,a,n=t.length,r=new Array(n),i=new Array(n),o=new Array(n);for(s=0;s=1?(n=1,t-1):Math.floor(n*t),i=e[r],o=e[r+1];return mge((n-r/t)*t,r>0?e[r-1]:2*i-o,i,o,rn&&(o=t.slice(n,o),a[s]?a[s]+=o:a[++s]=o),(r=r[0])===(i=i[0])?a[s]?a[s]+=i:a[++s]=i:(a[++s]=null,c.push({i:s,x:Td(r,i)})),n=B7.lastIndex;return n=0&&(t=t.slice(0,n)),!t||"start"===t})}(t)?E7:zf;return function(){var s=o(this,e),a=s.on;a!==r&&(i=(r=a).copy()).on(t,n),s.on=i}}(n,e,t))},attr:function f1t(e,t){var n=fP(e),r="transform"===n?Lvt:_ge;return this.attrTween(e,"function"==typeof t?(n.local?d1t:l1t)(n,r,M7(this,"attr."+e,t)):null==t?(n.local?a1t:s1t)(n):(n.local?u1t:c1t)(n,r,t))},attrTween:function y1t(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var r=fP(e);return this.tween(n,(r.local?m1t:g1t)(r,t))},style:function j1t(e,t,n){var r="transform"==(e+="")?Ovt:_ge;return null==t?this.styleTween(e,function U1t(e,t){var n,r,i;return function(){var o=G1(this,e),s=(this.style.removeProperty(e),G1(this,e));return o===s?null:o===n&&s===r?i:i=t(n=o,r=s)}}(e,r)).on("end.style."+e,xge(e)):"function"==typeof t?this.styleTween(e,function z1t(e,t,n){var r,i,o;return function(){var s=G1(this,e),a=n(this),c=a+"";return null==a&&(this.style.removeProperty(e),c=a=G1(this,e)),s===c?null:s===r&&c===i?o:(i=c,o=t(r=s,a))}}(e,r,M7(this,"style."+e,t))).each(function G1t(e,t){var n,r,i,a,o="style."+t,s="end."+o;return function(){var c=zf(this,e),u=c.on,l=null==c.value[o]?a||(a=xge(t)):void 0;(u!==n||i!==l)&&(r=(n=u).copy()).on(s,i=l),c.on=r}}(this._id,e)):this.styleTween(e,function V1t(e,t,n){var r,o,i=n+"";return function(){var s=G1(this,e);return s===i?null:s===r?o:o=t(r=s,n)}}(e,r,t),n).on("end.style."+e,null)},styleTween:function W1t(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==t)return this.tween(r,null);if("function"!=typeof t)throw new Error;return this.tween(r,function q1t(e,t,n){var r,i;function o(){var s=t.apply(this,arguments);return s!==i&&(r=(i=s)&&function H1t(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}(e,s,n)),r}return o._value=t,o}(e,t,n??""))},text:function X1t(e){return this.tween("text","function"==typeof e?function Y1t(e){return function(){var t=e(this);this.textContent=t??""}}(M7(this,"text",e)):function $1t(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function Q1t(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function Z1t(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&function K1t(e){return function(t){this.textContent=e.call(this,t)}}(i)),t}return r._value=e,r}(e))},remove:function N1t(){return this.on("end.remove",function k1t(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function zvt(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s,r=Id(this.node(),n).tween,i=0,o=r.length;i1?r[0]+r.slice(2):r,+e.slice(n+1)]}function $1(e){return(e=MP(Math.abs(e)))?e[1]:NaN}["w","e"].map($C),["n","s"].map($C),["n","w","e","s","nw","ne","sw","se"].map($C);var Dge,y_t=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function RP(e){if(!(t=y_t.exec(e)))throw new Error("invalid format: "+e);var t;return new z7({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function z7(e){this.fill=void 0===e.fill?" ":e.fill+"",this.align=void 0===e.align?">":e.align+"",this.sign=void 0===e.sign?"-":e.sign+"",this.symbol=void 0===e.symbol?"":e.symbol+"",this.zero=!!e.zero,this.width=void 0===e.width?void 0:+e.width,this.comma=!!e.comma,this.precision=void 0===e.precision?void 0:+e.precision,this.trim=!!e.trim,this.type=void 0===e.type?"":e.type+""}function Ege(e,t){var n=MP(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}RP.prototype=z7.prototype,z7.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};const Pge={"%":(e,t)=>(100*e).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:function h_t(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)},e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Ege(100*e,t),r:Ege,s:function v_t(e,t){var n=MP(e,t);if(!n)return e+"";var r=n[0],i=n[1],o=i-(Dge=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,s=r.length;return o===s?r:o>s?r+new Array(o-s+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+MP(e,Math.max(0,t+o-1))[0]},X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Mge(e){return e}var kP,G7,Nge,Rge=Array.prototype.map,kge=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"];!function x_t(e){kP=function __t(e){var t=void 0===e.grouping||void 0===e.thousands?Mge:function m_t(e,t){return function(n,r){for(var i=n.length,o=[],s=0,a=e[0],c=0;i>0&&a>0&&(c+a+1>r&&(a=Math.max(1,r-c)),o.push(n.substring(i-=a,i+a)),!((c+=a+1)>r));)a=e[s=(s+1)%e.length];return o.reverse().join(t)}}(Rge.call(e.grouping,Number),e.thousands+""),n=void 0===e.currency?"":e.currency[0]+"",r=void 0===e.currency?"":e.currency[1]+"",i=void 0===e.decimal?".":e.decimal+"",o=void 0===e.numerals?Mge:function g_t(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}(Rge.call(e.numerals,String)),s=void 0===e.percent?"%":e.percent+"",a=void 0===e.minus?"\u2212":e.minus+"",c=void 0===e.nan?"NaN":e.nan+"";function u(d){var f=(d=RP(d)).fill,p=d.align,m=d.sign,h=d.symbol,g=d.zero,y=d.width,b=d.comma,x=d.precision,_=d.trim,S=d.type;"n"===S?(b=!0,S="g"):Pge[S]||(void 0===x&&(x=12),_=!0,S="g"),(g||"0"===f&&"="===p)&&(g=!0,f="0",p="=");var A="$"===h?n:"#"===h&&/[boxX]/.test(S)?"0"+S.toLowerCase():"",E="$"===h?r:/[%p]/.test(S)?s:"",w=Pge[S],D=/[defgprs%]/.test(S);function I(R){var N,V,F,T=A,M=E;if("c"===S)M=w(R)+M,R="";else{var G=(R=+R)<0||1/R<0;if(R=isNaN(R)?c:w(Math.abs(R),x),_&&(R=function b_t(e){e:for(var i,t=e.length,n=1,r=-1;n0&&(r=0)}return r>0?e.slice(0,r)+e.slice(i+1):e}(R)),G&&0==+R&&"+"!==m&&(G=!1),T=(G?"("===m?m:a:"-"===m||"("===m?"":m)+T,M=("s"===S?kge[8+Dge/3]:"")+M+(G&&"("===m?")":""),D)for(N=-1,V=R.length;++N(F=R.charCodeAt(N))||F>57){M=(46===F?i+R.slice(N+1):R.slice(N))+M,R=R.slice(0,N);break}}b&&!g&&(R=t(R,1/0));var L=T.length+R.length+M.length,z=L>1)+T+R+M+z.slice(L);break;default:R=z+T+R+M}return o(R)}return x=void 0===x?6:/[gprs]/.test(S)?Math.max(1,Math.min(21,x)):Math.max(0,Math.min(20,x)),I.toString=function(){return d+""},I}return{format:u,formatPrefix:function l(d,f){var p=u(((d=RP(d)).type="f",d)),m=3*Math.max(-8,Math.min(8,Math.floor($1(f)/3))),h=Math.pow(10,-m),g=kge[8+m/3];return function(y){return p(h*y)+g}}}}(e),G7=kP.format,Nge=kP.formatPrefix}({thousands:",",grouping:[3],currency:["$",""]});const S_t=Math.sqrt(50),C_t=Math.sqrt(10),w_t=Math.sqrt(2);function NP(e,t,n){const r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),s=o>=S_t?10:o>=C_t?5:o>=w_t?2:1;let a,c,u;return i<0?(u=Math.pow(10,-i)/s,a=Math.round(e*u),c=Math.round(t*u),a/ut&&--c,u=-u):(u=Math.pow(10,i)*s,a=Math.round(e/u),c=Math.round(t/u),a*ut&&--c),ct?1:e>=t?0:NaN}function T_t(e,t){return null==e||null==t?NaN:te?1:t>=e?0:NaN}function Fge(e){let t,n,r;function i(a,c,u=0,l=a.length){if(u>>1;n(a[d],c)<0?u=d+1:l=d}while(uFP(e(a),c),r=(a,c)=>e(a)-c):(t=e===FP||e===T_t?e:D_t,n=e,r=e),{left:i,center:function s(a,c,u=0,l=a.length){const d=i(a,c,u,l-1);return d>u&&r(a[d-1],c)>-r(a[d],c)?d-1:d},right:function o(a,c,u=0,l=a.length){if(u>>1;n(a[d],c)<=0?u=d+1:l=d}while(u0))return[];if((e=+e)==(t=+t))return[e];const r=t=i))return[];const a=o-i+1,c=new Array(a);if(r)if(s<0)for(let u=0;u0;){if((u=j7(s,a,n))===c)return r[i]=s,r[o]=a,t(r);if(u>0)s=Math.floor(s/u)*u,a=Math.ceil(a/u)*u;else{if(!(u<0))break;s=Math.ceil(s*u)/u,a=Math.floor(a*u)/u}c=u}return e},e}function Vge(){var e=function H_t(){return function j_t(){var r,i,o,a,c,u,e=Lge,t=Lge,n=H7,s=Y1;function l(){var f=Math.min(e.length,t.length);return s!==Y1&&(s=function U_t(e,t){var n;return e>t&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}(e[0],e[f-1])),a=f>2?z_t:V_t,c=u=null,d}function d(f){return null==f||isNaN(f=+f)?o:(c||(c=a(e.map(r),t,n)))(r(s(f)))}return d.invert=function(f){return s(i((u||(u=a(t,e.map(r),Td)))(f)))},d.domain=function(f){return arguments.length?(e=Array.from(f,L_t),l()):e.slice()},d.range=function(f){return arguments.length?(t=Array.from(f),l()):t.slice()},d.rangeRound=function(f){return t=Array.from(f),n=B_t,l()},d.clamp=function(f){return arguments.length?(s=!!f||Y1,l()):s!==Y1},d.interpolate=function(f){return arguments.length?(n=f,l()):n},d.unknown=function(f){return arguments.length?(o=f,d):o},function(f,p){return r=f,i=p,l()}}()(Y1,Y1)}();return e.copy=function(){return function G_t(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}(e,Vge())},Uge.apply(e,arguments),X_t(e)}class zge extends Map{constructor(t,n=Hge){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),null!=t)for(const[r,i]of t)this.set(r,i)}get(t){return super.get(W7(this,t))}has(t){return super.has(W7(this,t))}set(t,n){return super.set(function Gge({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}(this,t),n)}delete(t){return super.delete(function jge({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}(this,t))}}function W7({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function Hge(e){return null!==e&&"object"==typeof e?e.valueOf():e}Set;const qge=Symbol("implicit");function Wge(){var e=new zge,t=[],n=[],r=qge;function i(o){let s=e.get(o);if(void 0===s){if(r!==qge)return r;e.set(o,s=t.push(o)-1)}return n[s%n.length]}return i.domain=function(o){if(!arguments.length)return t.slice();t=[],e=new zge;for(const s of o)e.has(s)||e.set(s,t.push(s)-1);return i},i.range=function(o){return arguments.length?(n=Array.from(o),i):n.slice()},i.unknown=function(o){return arguments.length?(r=o,i):r},i.copy=function(){return Wge(t,n).unknown(r)},Uge.apply(i,arguments),i}function kl(e){return"string"==typeof e?new Pu([[document.querySelector(e)]],[document.documentElement]):new Pu([[e]],jme)}function X1(e){return function(){return e}}function $ge(e){this._context=e}function Q_t(e){return new $ge(e)}$ge.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};const $7=Math.PI,Y7=2*$7,fy=1e-6,J_t=Y7-fy;function Yge(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return Yge;const n=10**t;return function(r){this._+=r[0];for(let i=1,o=r.length;ify)if(Math.abs(d*c-u*l)>fy&&o){let p=r-s,m=i-a,h=c*c+u*u,g=p*p+m*m,y=Math.sqrt(h),b=Math.sqrt(f),x=o*Math.tan(($7-Math.acos((h+f-g)/(2*y*b)))/2),_=x/b,S=x/y;Math.abs(_-1)>fy&&this._append`L${t+_*l},${n+_*d}`,this._append`A${o},${o},0,0,${+(d*p>l*m)},${this._x1=t+S*c},${this._y1=n+S*u}`}else this._append`L${this._x1=t},${this._y1=n}`}arc(t,n,r,i,o,s){if(t=+t,n=+n,s=!!s,(r=+r)<0)throw new Error(`negative radius: ${r}`);let a=r*Math.cos(i),c=r*Math.sin(i),u=t+a,l=n+c,d=1^s,f=s?i-o:o-i;null===this._x1?this._append`M${u},${l}`:(Math.abs(this._x1-u)>fy||Math.abs(this._y1-l)>fy)&&this._append`L${u},${l}`,r&&(f<0&&(f=f%Y7+Y7),f>J_t?this._append`A${r},${r},0,1,${d},${t-a},${n-c}A${r},${r},0,1,${d},${this._x1=u},${this._y1=l}`:f>fy&&this._append`A${r},${r},0,${+(f>=$7)},${d},${this._x1=t+r*Math.cos(o)},${this._y1=n+r*Math.sin(o)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function rxt(e){return e[0]}function ixt(e){return e[1]}function Xge(e){return e<0?-1:1}function Kge(e,t,n){var r=e._x1-e._x0,i=t-e._x1,o=(e._y1-e._y0)/(r||i<0&&-0),s=(n-e._y1)/(i||r<0&&-0),a=(o*i+s*r)/(r+i);return(Xge(o)+Xge(s))*Math.min(Math.abs(o),Math.abs(s),.5*Math.abs(a))||0}function Zge(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function X7(e,t,n){var r=e._x0,o=e._x1,s=e._y1,a=(o-r)/3;e._context.bezierCurveTo(r+a,e._y0+a*t,o-a,s-a*n,o,s)}function OP(e){this._context=e}function Jge(e){this._context=e}function sxt(e){return new OP(e)}OP.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:X7(this,this._t0,Zge(this,this._t0))}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(t=+t,(e=+e)!==this._x1||t!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,X7(this,Zge(this,n=Kge(this,e,t)),n);break;default:X7(this,this._t0,n=Kge(this,e,t))}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}},(function Qge(e){this._context=new Jge(e)}.prototype=Object.create(OP.prototype)).point=function(e,t){OP.prototype.point.call(this,t,e)},Jge.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,o){this._context.bezierCurveTo(t,e,r,n,o,i)}};const K7={capture:!0,passive:!1};function Z7(e){e.preventDefault(),e.stopImmediatePropagation()}function e0e(e){return((e=Math.exp(e))+1/e)/2}const fxt=function e(t,n,r){function i(o,s){var g,y,a=o[0],c=o[1],u=o[2],f=s[2],p=s[0]-a,m=s[1]-c,h=p*p+m*m;if(h<1e-12)y=Math.log(f/u)/t,g=function(E){return[a+E*p,c+E*m,u*Math.exp(t*E*y)]};else{var b=Math.sqrt(h),x=(f*f-u*u+r*h)/(2*u*n*b),_=(f*f-u*u-r*h)/(2*f*n*b),S=Math.log(Math.sqrt(x*x+1)-x),A=Math.log(Math.sqrt(_*_+1)-_);y=(A-S)/t,g=function(E){var w=E*y,D=e0e(S),I=u/(n*b)*(D*function dxt(e){return((e=Math.exp(2*e))-1)/(e+1)}(t*w+S)-function lxt(e){return((e=Math.exp(e))-1/e)/2}(S));return[a+I*p,c+I*m,u*D/e0e(t*w+S)]}}return g.duration=1e3*y*t/Math.SQRT2,g}return i.rho=function(o){var s=Math.max(.001,+o),a=s*s;return e(s,a,a*a)},i}(Math.SQRT2,2,4);function py(e,t){if(e=function pxt(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,[(r=r.matrixTransform(t.getScreenCTM().inverse())).x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const LP=e=>()=>e;function hxt(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function bh(e,t,n){this.k=e,this.x=t,this.y=n}bh.prototype={constructor:bh,scale:function(e){return 1===e?this:new bh(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new bh(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Q7=new bh(1,0,0);function J7(e){e.stopImmediatePropagation()}function YC(e){e.preventDefault(),e.stopImmediatePropagation()}function gxt(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function yxt(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function t0e(){return this.__zoom||Q7}function bxt(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function vxt(){return navigator.maxTouchPoints||"ontouchstart"in this}function _xt(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}let XC=(()=>{class e{get div(){return this.root.nativeElement}get width(){return this.div.offsetWidth}get margin(){const{"margin-top":n,"margin-right":r,"margin-bottom":i,"margin-left":o}=this.settings;return{top:n,right:r,bottom:i,left:o}}constructor(){this.initialize$=new ou(1),this.initialized$=this.initialize$.pipe(jr(n=>this.root=n),qt(()=>{const n=function K_t(e){return kl(w7(e).call(document.documentElement))}("svg"),r=n.node();if(!r)throw new Error("Could not create SVG node");return this.div.append(r),n}),jr(n=>this.svg=n),jr(n=>{const r=n.append("defs");this.clip=r.append("SVG:clipPath").attr("id","clip").append("SVG:rect"),this.draw=n.append("g").attr("class","features").attr("clip-path","url(#clip)"),this.zoom=function xxt(){var l,d,f,e=gxt,t=yxt,n=_xt,r=bxt,i=vxt,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=fxt,u=$me("start","zoom","end"),p=500,m=150,h=0,g=10;function y(N){N.property("__zoom",t0e).on("wheel.zoom",w,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",I).filter(i).on("touchstart.zoom",R).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(N,V){return(V=Math.max(o[0],Math.min(o[1],V)))===N.k?N:new bh(V,N.x,N.y)}function x(N,V,F){var G=V[0]-F[0]*N.k,L=V[1]-F[1]*N.k;return G===N.x&&L===N.y?N:new bh(N.k,G,L)}function _(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function S(N,V,F,G){N.on("start.zoom",function(){A(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(G).end()}).tween("zoom",function(){var L=this,z=arguments,j=A(L,z).event(G),Z=t.apply(L,z),$=null==F?_(Z):"function"==typeof F?F.apply(L,z):F,ee=Math.max(Z[1][0]-Z[0][0],Z[1][1]-Z[0][1]),q=L.__zoom,O="function"==typeof V?V.apply(L,z):V,H=c(q.invert($).concat(ee/q.k),O.invert($).concat(ee/O.k));return function(W){if(1===W)W=O;else{var Q=H(W),fe=ee/Q[2];W=new bh(fe,$[0]-Q[0]*fe,$[1]-Q[1]*fe)}j.zoom(null,W)}})}function A(N,V,F){return!F&&N.__zooming||new E(N,V)}function E(N,V){this.that=N,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply(N,V),this.taps=0}function w(N,...V){if(e.apply(this,arguments)){var F=A(this,V).event(N),G=this.__zoom,L=Math.max(o[0],Math.min(o[1],G.k*Math.pow(2,r.apply(this,arguments)))),z=py(N);if(F.wheel)(F.mouse[0][0]!==z[0]||F.mouse[0][1]!==z[1])&&(F.mouse[1]=G.invert(F.mouse[0]=z)),clearTimeout(F.wheel);else{if(G.k===L)return;F.mouse=[z,G.invert(z)],xP(this),F.start()}YC(N),F.wheel=setTimeout(function j(){F.wheel=null,F.end()},m),F.zoom("mouse",n(x(b(G,L),F.mouse[0],F.mouse[1]),F.extent,s))}}function D(N,...V){if(!f&&e.apply(this,arguments)){var F=N.currentTarget,G=A(this,V,!0).event(N),L=kl(N.view).on("mousemove.zoom",function $(q){if(YC(q),!G.moved){var O=q.clientX-j,H=q.clientY-Z;G.moved=O*O+H*H>h}G.event(q).zoom("mouse",n(x(G.that.__zoom,G.mouse[0]=py(q,F),G.mouse[1]),G.extent,s))},!0).on("mouseup.zoom",function ee(q){L.on("mousemove.zoom mouseup.zoom",null),function cxt(e,t){var n=e.document.documentElement,r=kl(e).on("dragstart.drag",null);t&&(r.on("click.drag",Z7,K7),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}(q.view,G.moved),YC(q),G.event(q).end()},!0),z=py(N,F),j=N.clientX,Z=N.clientY;(function axt(e){var t=e.document.documentElement,n=kl(e).on("dragstart.drag",Z7,K7);"onselectstart"in t?n.on("selectstart.drag",Z7,K7):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")})(N.view),J7(N),G.mouse=[z,this.__zoom.invert(z)],xP(this),G.start()}}function I(N,...V){if(e.apply(this,arguments)){var F=this.__zoom,G=py(N.changedTouches?N.changedTouches[0]:N,this),L=F.invert(G),j=n(x(b(F,F.k*(N.shiftKey?.5:2)),G,L),t.apply(this,V),s);YC(N),a>0?kl(this).transition().duration(a).call(S,j,G,N):kl(this).call(y.transform,j,G,N)}}function R(N,...V){if(e.apply(this,arguments)){var z,j,Z,$,F=N.touches,G=F.length,L=A(this,V,N.changedTouches.length===G).event(N);for(J7(N),j=0;j{const r=n.append("g").attr("class","x axis"),i=n.append("g").attr("class","y axis");this.axes={x:r,y:i}}),jr(()=>this.scale={x:Vge(),y:Wge()}),Zl(1))}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();function Sxt(e){return"trace"!==e.type?{type:"trace",values:[e],label:e.label}:{...e,type:"trace"}}let eG=(()=>{class e{set hierarchy(n){let r=0;for(n=[...n],this._traces=new Map,this._parent=new Map,this._children=new Map;n.length>0;){const i=n.splice(0,1).at(0),{nested:o,...s}=i,a=Object.assign(i,Sxt(s));this._children.set(a,[]);for(const u of o||[])this._parent.set(u,r),n.push(u);const c=this.getParent(a);c&&this._children.get(c).push(r),this._traces.set(r,a),r++}}get traces(){return this._traces}getTrace(n){return this.traces.get(n)}getParent(n){const r=this._parent.get(n);return r&&this._traces.get(r)}getBranch(n){const r=[],i=[n];for(;i.length>0;){const o=i.pop();r.push(o);const s=this.getChildren(o);i.push(...s)}return r}getChildren(n){return this._children.get(n).map(i=>this._traces.get(i))}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function n0e(e,t,n){e.attr("height",t.height).attr("width",t.width).attr("y",n.top).attr("x",n.left)}let tG=(()=>{class e{get svg(){return this.initializeService.svg}get div(){return this.initializeService.div}get height(){return this.div.offsetHeight}get width(){return this.div.offsetWidth}get margin(){return this.initializeService.margin}get scale(){return this.initializeService.scale}get axes(){return this.initializeService.axes}constructor(n){this.initializeService=n,this.resize$=new ou(1);const r=this.resize$.pipe(qt(()=>({width:this.width,height:this.height})),afe(100),Bde((i,o)=>i.width===o.width),qt(()=>{}),Dx(void 0));this.resized$=r.pipe(qt(()=>this.updateRoot()),qt(()=>this.updateDraw()),qt(()=>this.updateAxes()),qt(()=>this.updateRangeX()),qt(()=>this.updateRangeY()),jr(()=>console.log("Resized!")))}updateRoot(){const{y:n}=this.scale,i=n.range().at(-1)+this.margin.bottom,o=this.width;this.svg.attr("height",i).attr("width",o)}updateDraw(){const n={width:0,height:0};n.height=this.height-this.margin.top-this.margin.bottom,n.width=this.width-this.margin.left-this.margin.right,n0e(this.initializeService.clip,n,this.margin),n0e(this.initializeService.events,n,this.margin)}updateAxes(){const{x:n,y:r}=this.axes;n.attr("transform",`translate(0, ${this.height-this.margin.top})`),r.attr("transform",`translate(${this.margin.left}, 0)`)}updateRangeX(){const n=this.scale.x,r=this.width,{left:i,right:o}=this.margin;n.range([i,r-o])}updateRangeY(){}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(XC))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})(),r0e=(()=>{class e{get draw(){return this.initService.draw}constructor(n){this.initService=n,this.zoom$=new ou(1);const i=this.initService.initialized$.pipe(qt(()=>this._scale={x:this.initService.scale.x.copy(),y:this.initService.scale.y.copy()}),Zl(1)).pipe(To(()=>this.zoom$),qt(o=>{const{x:s}=this._scale,{x:a}=this.initService.scale,c=o.transform.rescaleX(s),[u,l]=c.domain();return a.domain([u,l]),this.initService.scale}),Dx(this.initService.scale));this.zoomed$=i.pipe(qt(()=>{const o=this.initService.axes,s=this.initService.scale,a=s.x.ticks().filter(u=>Number.isInteger(u)).slice(1,-1),c=function qyt(e){return lP(3,e)}(s.x).tickValues(a).tickFormat(G7(".0f"));o.x.call(c)}),jr(()=>console.log("Zoomed!")))}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(XC))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();const i0e={H:"blue",K:"blue",R:"blue",D:"red",E:"red",S:"green",T:"green",N:"green",Q:"green",A:"white",V:"white",L:"white",I:"white",M:"white",F:"magenta",W:"magenta",Y:"magenta",P:"brown",G:"brown",C:"yellow",B:"grey",Z:"grey",X:"grey","-":"grey"},nG=(parseFloat(getComputedStyle(document.documentElement).fontSize),e=>e.id),Qm=(e,t)=>t;let o0e=(()=>{class e{constructor(n,r,i){this.initializeService=n,this.featuresService=r,this.resizeService=i,this.traces$=new ou(1),this.sequence$=new ou(1),this.draw$=this.sequence$.pipe(jr(o=>{this.initializeService.scale.x.domain([0,o.length+1])}),qt(o=>this.createSequence(o)),Zl(1),To(()=>this.traces$),jr(o=>this.updateScale(o)),jr(o=>this.createLabels(o)),jr(o=>this.createGrid(o)),jr(o=>this.createTraces(o)),Zl(1)),this.drawn$=this.draw$.pipe(qt(()=>this.updateSequence()),qt(()=>this.updateGrid()),qt(()=>this.updateLabels()),qt(()=>this.updateTraces()),jr(()=>console.log("Re-drawn!")))}updateScale(n){const r=this.initializeService.scale.y,i=["sequence",...n.map(({id:s})=>String(s))],o=i.reduce((s,a,c)=>{if(0===c&&"sequence"===a){const d=this.initializeService.settings["margin-top"];return[d,d+this.initializeService.settings["line-height"]]}const u=this.featuresService.getTrace(+a);if(u){const l=s.at(-1);let d=u["line-height"]||this.initializeService.settings["line-height"];return"dodge"===u.position&&(d=u.values.reduce((f,p)=>f+(p["line-height"]||this.initializeService.settings["line-height"]),0)),[...s,l+d]}throw new Error("Trace not found")},[]);r.domain(i).range(o)}createSequence(n){const i=this.initializeService.draw.selectAll("g.sequence").data([n]).join("g").attr("class","sequence");this.residues=i.selectAll("g.residue").data(n).join("g").attr("id",(o,s)=>`residue-${s+1}`).attr("class","residue"),this.residues.append("rect").attr("class","color").attr("fill",o=>(o=>i0e[o]||i0e.X)(o)).attr("fill-opacity",.1),this.residues.append("text").attr("class","name").text(o=>""+o)}updateSequence(){const n=this.initializeService.settings["line-height"],r=this.initializeService.margin,{x:i,y:o}=this.initializeService.scale,s=i(1)-i(0);this.residues.select("rect.color").attr("x",(a,c)=>i(c+.5)).attr("y",r.top).attr("width",()=>s).attr("height","100%"),this.residues.select("text.name").attr("x",(a,c)=>i(c+1)).attr("y",o("sequence")+n/2).attr("width",()=>s).attr("height",n).attr("dominant-baseline","central").style("text-anchor","middle")}createLabels(n){const r=this.initializeService.settings,{left:i}=this.initializeService.margin,o=this.initializeService.svg.selectAll("g.labels").data([n],Qm).join("g").attr("class","labels");this.labels=o.selectAll("g.label").data([{id:"sequence",label:"Sequence",visible:!0},...n],nG).join("g").attr("id",s=>"label-"+String(s.id)).attr("class","label"),this.labels.selectAll("rect").data(s=>[s],Qm).join("rect").attr("height",s=>s["line-height"]||r["line-height"]).attr("width",()=>i).attr("fill","none").attr("stroke","#D3D3D380"),this.labels.selectAll("text").data(s=>[s],Qm).join("text").text(s=>(s.label||"")+" "+(s.visible?"(visible)":"(hidden)")).attr("height",s=>s["line-height"]||r["line-height"]).attr("width",()=>i).filter(s=>"sequence"!==s.id).on("click",(s,a)=>{a.visible=!1===a.visible;const c=Array.from(this.featuresService.traces.values()),u=new Array;for(const l of c){const{visible:d}={visible:!0,...l};if(!0!==d){const f=this.featuresService.getBranch(l).slice(1);u.push(...f)}}this.traces$.next(c.filter(l=>!u.includes(l)))})}updateLabels(){const n=this.initializeService.scale.y,r=this.initializeService.settings;this.labels.select("rect").attr("y",i=>n(String(i.id))).attr("x",0),this.labels.select("text").attr("y",i=>n(String(i.id))+(i["line-height"]||r["line-height"])/2).attr("x",0).attr("dominant-baseline","central")}createGrid(n){const r=this.initializeService.svg.selectAll("g.grid").data([n],Qm).join("g").attr("class","grid");this.grid=r.selectAll("rect.grid-line").data(n,nG).join("rect").attr("id",i=>"grid-"+String(i.id)).attr("class","grid-line")}updateGrid(){const n=this.initializeService.scale.y,r=this.initializeService.width,i=this.initializeService.margin,o=this.initializeService.settings;this.grid.attr("x",i.left).attr("y",s=>{const c=s.values.sort((f,p)=>"continuous"===f.type?-1:"continuous"===p.type?1:0)[0],u=n(String(s.id)),l=c["line-height"]||s["line-height"]||o["line-height"];return"continuous"!==c.type?u+l/2-.5:u+l/2-(c["content-size"]||s["content-size"]||o["content-size"])/2}).attr("width",r-i.left-i.right).attr("height",s=>{const a=s.values[0];return"continuous"===a.type?a["content-size"]||s["content-size"]||o["content-size"]:1}).attr("fill",this.initializeService.settings["grid-color"])}createTraces(n){this.traces=this.initializeService.draw.selectAll("g.trace").data(n,nG).join("g").attr("id",r=>"trace-"+String(r.id)).attr("class","trace"),this.traces.each(function(r){kl(this).selectAll("g.feature").data(r.values,Qm).join("g").attr("class","feature").each(function(o){const s=kl(this);"continuous"===o.type?s.selectAll("path.continuous").data([o],Qm).join("path").attr("class","continuous").attr("fill","pink").attr("fill-opacity",0).attr("stroke","#ff1493").attr("stroke-opacity",1).attr("stroke-width",2):s.selectAll("rect.locus").data(o.values,Qm).join("rect").attr("class","locus").attr("fill","steelblue").attr("fill-opacity",.3).attr("stroke","steelblue").attr("stroke-opacity",1).attr("stroke-width",1.5)})})}updateTraces(){const n=this.initializeService.scale,r=this.initializeService.settings;this.traces.each(function(i){const o=i.values;kl(this).selectAll("g.feature").each(function(a,c){const u=kl(this),l=o[c],d=n.y(String(i.id)),f=l["line-height"]||i["line-height"]||r["line-height"],p=l["content-size"]||i["content-size"]||r["content-size"];if("continuous"===l.type){const m=l.values,h=void 0!==l.min?l.min:Math.min(...l.values),g=void 0!==l.max?l.max:Math.max(...l.values),y=m.map((_,S)=>[S+1,1-(_-h)/(g-h)]),b=u.select("path.continuous"),x=function oxt(e,t){var n=X1(!0),r=null,i=Q_t,o=null,s=function nxt(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(null==n)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new BP(t)}(a);function a(c){var u,d,p,l=(c=function Z_t(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}(c)).length,f=!1;for(null==r&&(o=i(p=s())),u=0;u<=l;++u)!(un.x(_)).y(([_,S])=>d+f/2-p/2+p*S);b.attr("d",x(y))}else{const m=n.x(1)-n.x(0);u.selectAll("rect.locus").data(l.values,Qm).attr("x",h=>n.x(h.start-.5)).attr("y",d+f/2-p/2).attr("height",p).attr("width",h=>{const{start:g,end:y}={end:h.start+1,...h};return m*(y-g)})}})})}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(XC),Zt(eG),Zt(tG))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();const Cxt=["root"];let wxt=(()=>{class e{set settings(n){this.initService.settings=n}set features(n){this.featuresService.hierarchy=n;const r=Array.from(this.featuresService.traces.entries()).map(([i,o])=>Object.assign(o,{id:i,visible:!0}));this.traces$.next(r)}constructor(n,r,i,o,s){this.featuresService=n,this.initService=r,this.resizeService=i,this.zoomService=o,this.drawService=s,this.traces$=this.drawService.traces$,this.sequence$=this.drawService.sequence$,this.update$=this.initService.initialized$.pipe(To(()=>this.drawService.draw$),To(()=>this.resizeService.resized$),jr(()=>{const{margin:a,width:c}=this.resizeService,u=this.sequence.length+1;this.initService.zoom.extent([[a.left,0],[c-a.right,1/0]]).scaleExtent([1,u/5]).translateExtent([[a.left,0],[c-a.right,0]]).on("zoom",l=>{this.onFeaturesZoom(l)})}),To(()=>this.zoomService.zoomed$),To(()=>this.drawService.drawn$)),this._update=this.update$.subscribe()}ngOnChanges(n){n&&n.sequence&&this.sequence$.next(this.sequence)}ngAfterViewInit(){this.initService.initialize$.next(this._root)}ngOnDestroy(){this._update.unsubscribe()}onResize(n){this.resizeService.resize$.next(n)}onFeaturesZoom(n){this.zoomService.zoom$.next(n)}static#e=this.\u0275fac=function(r){return new(r||e)(cn(eG),cn(XC),cn(tG),cn(r0e),cn(o0e))};static#t=this.\u0275cmp=Mu({type:e,selectors:[["ngx-features-viewer"]],viewQuery:function(r,i){if(1&r&&dN(Cxt,5),2&r){let o;EA(o=PA())&&(i._root=o.first)}},hostBindings:function(r,i){1&r&&fx("resize",function(s){return i.onResize(s)},0,qj)},inputs:{settings:"settings",features:"features",sequence:"sequence"},standalone:!0,features:[MA([XC,eG,tG,o0e,r0e]),wh,Nu],decls:2,vars:0,consts:[["root",""],[2,"position","relative","display","block","width","100%","height","100%"]],template:function(r,i){1&r&&gi(0,"div",1,0)},styles:['@charset "UTF-8";.labels #label-sequence .parent div{cursor:default}.labels #label-sequence .parent div i{display:none}.labels .label .children-0>i{visibility:hidden}.labels .label i:before{transition:transform .4s}.labels .label.active i:before{transform:roate(0deg)}.labels .label:not(.active) i:before{transform:rotate(-90deg)}.labels .label div{display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between;align-items:center;box-sizing:border-box;height:100%;width:100%;cursor:pointer}.labels .label div span{text-wrap:wrap;line-break:anywhere;flex-shrink:1;flex-grow:1}.labels .label div i{flex-shrink:0;flex-grow:0}.labels div.depth-0{width:100%;padding:0 .25rem 0 .75rem}.labels div.depth-1{width:100%;padding:0 .25rem 0 1.5rem}.labels div.depth-2{width:100%;padding:0 .25rem 0 2.25rem}.labels div.depth-3{width:100%;padding:0 .25rem 0 3rem}.labels div.depth-4{width:100%;padding:0 .25rem 0 3.75rem}.labels div.depth-5{width:100%;padding:0 .25rem 0 4.5rem}/*!\n * Bootstrap Icons v1.11.3 (https://icons.getbootstrap.com/)\n * Copyright 2019-2024 The Bootstrap Authors\n * Licensed under MIT (https://github.com/twbs/icons/blob/main/LICENSE)\n */@font-face{font-display:block;font-family:bootstrap-icons;src:url(bootstrap-icons.bfa90bda92a84a6a.woff2) format("woff2"),url(bootstrap-icons.70a9dee9e5ab72aa.woff) format("woff")}.bi:before,[class^=bi-]:before,[class*=" bi-"]:before{display:inline-block;font-family:bootstrap-icons!important;font-style:normal;font-weight:400!important;font-variant:normal;text-transform:none;line-height:1;vertical-align:-.125em;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.bi-123:before{content:"\\f67f"}.bi-alarm-fill:before{content:"\\f101"}.bi-alarm:before{content:"\\f102"}.bi-align-bottom:before{content:"\\f103"}.bi-align-center:before{content:"\\f104"}.bi-align-end:before{content:"\\f105"}.bi-align-middle:before{content:"\\f106"}.bi-align-start:before{content:"\\f107"}.bi-align-top:before{content:"\\f108"}.bi-alt:before{content:"\\f109"}.bi-app-indicator:before{content:"\\f10a"}.bi-app:before{content:"\\f10b"}.bi-archive-fill:before{content:"\\f10c"}.bi-archive:before{content:"\\f10d"}.bi-arrow-90deg-down:before{content:"\\f10e"}.bi-arrow-90deg-left:before{content:"\\f10f"}.bi-arrow-90deg-right:before{content:"\\f110"}.bi-arrow-90deg-up:before{content:"\\f111"}.bi-arrow-bar-down:before{content:"\\f112"}.bi-arrow-bar-left:before{content:"\\f113"}.bi-arrow-bar-right:before{content:"\\f114"}.bi-arrow-bar-up:before{content:"\\f115"}.bi-arrow-clockwise:before{content:"\\f116"}.bi-arrow-counterclockwise:before{content:"\\f117"}.bi-arrow-down-circle-fill:before{content:"\\f118"}.bi-arrow-down-circle:before{content:"\\f119"}.bi-arrow-down-left-circle-fill:before{content:"\\f11a"}.bi-arrow-down-left-circle:before{content:"\\f11b"}.bi-arrow-down-left-square-fill:before{content:"\\f11c"}.bi-arrow-down-left-square:before{content:"\\f11d"}.bi-arrow-down-left:before{content:"\\f11e"}.bi-arrow-down-right-circle-fill:before{content:"\\f11f"}.bi-arrow-down-right-circle:before{content:"\\f120"}.bi-arrow-down-right-square-fill:before{content:"\\f121"}.bi-arrow-down-right-square:before{content:"\\f122"}.bi-arrow-down-right:before{content:"\\f123"}.bi-arrow-down-short:before{content:"\\f124"}.bi-arrow-down-square-fill:before{content:"\\f125"}.bi-arrow-down-square:before{content:"\\f126"}.bi-arrow-down-up:before{content:"\\f127"}.bi-arrow-down:before{content:"\\f128"}.bi-arrow-left-circle-fill:before{content:"\\f129"}.bi-arrow-left-circle:before{content:"\\f12a"}.bi-arrow-left-right:before{content:"\\f12b"}.bi-arrow-left-short:before{content:"\\f12c"}.bi-arrow-left-square-fill:before{content:"\\f12d"}.bi-arrow-left-square:before{content:"\\f12e"}.bi-arrow-left:before{content:"\\f12f"}.bi-arrow-repeat:before{content:"\\f130"}.bi-arrow-return-left:before{content:"\\f131"}.bi-arrow-return-right:before{content:"\\f132"}.bi-arrow-right-circle-fill:before{content:"\\f133"}.bi-arrow-right-circle:before{content:"\\f134"}.bi-arrow-right-short:before{content:"\\f135"}.bi-arrow-right-square-fill:before{content:"\\f136"}.bi-arrow-right-square:before{content:"\\f137"}.bi-arrow-right:before{content:"\\f138"}.bi-arrow-up-circle-fill:before{content:"\\f139"}.bi-arrow-up-circle:before{content:"\\f13a"}.bi-arrow-up-left-circle-fill:before{content:"\\f13b"}.bi-arrow-up-left-circle:before{content:"\\f13c"}.bi-arrow-up-left-square-fill:before{content:"\\f13d"}.bi-arrow-up-left-square:before{content:"\\f13e"}.bi-arrow-up-left:before{content:"\\f13f"}.bi-arrow-up-right-circle-fill:before{content:"\\f140"}.bi-arrow-up-right-circle:before{content:"\\f141"}.bi-arrow-up-right-square-fill:before{content:"\\f142"}.bi-arrow-up-right-square:before{content:"\\f143"}.bi-arrow-up-right:before{content:"\\f144"}.bi-arrow-up-short:before{content:"\\f145"}.bi-arrow-up-square-fill:before{content:"\\f146"}.bi-arrow-up-square:before{content:"\\f147"}.bi-arrow-up:before{content:"\\f148"}.bi-arrows-angle-contract:before{content:"\\f149"}.bi-arrows-angle-expand:before{content:"\\f14a"}.bi-arrows-collapse:before{content:"\\f14b"}.bi-arrows-expand:before{content:"\\f14c"}.bi-arrows-fullscreen:before{content:"\\f14d"}.bi-arrows-move:before{content:"\\f14e"}.bi-aspect-ratio-fill:before{content:"\\f14f"}.bi-aspect-ratio:before{content:"\\f150"}.bi-asterisk:before{content:"\\f151"}.bi-at:before{content:"\\f152"}.bi-award-fill:before{content:"\\f153"}.bi-award:before{content:"\\f154"}.bi-back:before{content:"\\f155"}.bi-backspace-fill:before{content:"\\f156"}.bi-backspace-reverse-fill:before{content:"\\f157"}.bi-backspace-reverse:before{content:"\\f158"}.bi-backspace:before{content:"\\f159"}.bi-badge-3d-fill:before{content:"\\f15a"}.bi-badge-3d:before{content:"\\f15b"}.bi-badge-4k-fill:before{content:"\\f15c"}.bi-badge-4k:before{content:"\\f15d"}.bi-badge-8k-fill:before{content:"\\f15e"}.bi-badge-8k:before{content:"\\f15f"}.bi-badge-ad-fill:before{content:"\\f160"}.bi-badge-ad:before{content:"\\f161"}.bi-badge-ar-fill:before{content:"\\f162"}.bi-badge-ar:before{content:"\\f163"}.bi-badge-cc-fill:before{content:"\\f164"}.bi-badge-cc:before{content:"\\f165"}.bi-badge-hd-fill:before{content:"\\f166"}.bi-badge-hd:before{content:"\\f167"}.bi-badge-tm-fill:before{content:"\\f168"}.bi-badge-tm:before{content:"\\f169"}.bi-badge-vo-fill:before{content:"\\f16a"}.bi-badge-vo:before{content:"\\f16b"}.bi-badge-vr-fill:before{content:"\\f16c"}.bi-badge-vr:before{content:"\\f16d"}.bi-badge-wc-fill:before{content:"\\f16e"}.bi-badge-wc:before{content:"\\f16f"}.bi-bag-check-fill:before{content:"\\f170"}.bi-bag-check:before{content:"\\f171"}.bi-bag-dash-fill:before{content:"\\f172"}.bi-bag-dash:before{content:"\\f173"}.bi-bag-fill:before{content:"\\f174"}.bi-bag-plus-fill:before{content:"\\f175"}.bi-bag-plus:before{content:"\\f176"}.bi-bag-x-fill:before{content:"\\f177"}.bi-bag-x:before{content:"\\f178"}.bi-bag:before{content:"\\f179"}.bi-bar-chart-fill:before{content:"\\f17a"}.bi-bar-chart-line-fill:before{content:"\\f17b"}.bi-bar-chart-line:before{content:"\\f17c"}.bi-bar-chart-steps:before{content:"\\f17d"}.bi-bar-chart:before{content:"\\f17e"}.bi-basket-fill:before{content:"\\f17f"}.bi-basket:before{content:"\\f180"}.bi-basket2-fill:before{content:"\\f181"}.bi-basket2:before{content:"\\f182"}.bi-basket3-fill:before{content:"\\f183"}.bi-basket3:before{content:"\\f184"}.bi-battery-charging:before{content:"\\f185"}.bi-battery-full:before{content:"\\f186"}.bi-battery-half:before{content:"\\f187"}.bi-battery:before{content:"\\f188"}.bi-bell-fill:before{content:"\\f189"}.bi-bell:before{content:"\\f18a"}.bi-bezier:before{content:"\\f18b"}.bi-bezier2:before{content:"\\f18c"}.bi-bicycle:before{content:"\\f18d"}.bi-binoculars-fill:before{content:"\\f18e"}.bi-binoculars:before{content:"\\f18f"}.bi-blockquote-left:before{content:"\\f190"}.bi-blockquote-right:before{content:"\\f191"}.bi-book-fill:before{content:"\\f192"}.bi-book-half:before{content:"\\f193"}.bi-book:before{content:"\\f194"}.bi-bookmark-check-fill:before{content:"\\f195"}.bi-bookmark-check:before{content:"\\f196"}.bi-bookmark-dash-fill:before{content:"\\f197"}.bi-bookmark-dash:before{content:"\\f198"}.bi-bookmark-fill:before{content:"\\f199"}.bi-bookmark-heart-fill:before{content:"\\f19a"}.bi-bookmark-heart:before{content:"\\f19b"}.bi-bookmark-plus-fill:before{content:"\\f19c"}.bi-bookmark-plus:before{content:"\\f19d"}.bi-bookmark-star-fill:before{content:"\\f19e"}.bi-bookmark-star:before{content:"\\f19f"}.bi-bookmark-x-fill:before{content:"\\f1a0"}.bi-bookmark-x:before{content:"\\f1a1"}.bi-bookmark:before{content:"\\f1a2"}.bi-bookmarks-fill:before{content:"\\f1a3"}.bi-bookmarks:before{content:"\\f1a4"}.bi-bookshelf:before{content:"\\f1a5"}.bi-bootstrap-fill:before{content:"\\f1a6"}.bi-bootstrap-reboot:before{content:"\\f1a7"}.bi-bootstrap:before{content:"\\f1a8"}.bi-border-all:before{content:"\\f1a9"}.bi-border-bottom:before{content:"\\f1aa"}.bi-border-center:before{content:"\\f1ab"}.bi-border-inner:before{content:"\\f1ac"}.bi-border-left:before{content:"\\f1ad"}.bi-border-middle:before{content:"\\f1ae"}.bi-border-outer:before{content:"\\f1af"}.bi-border-right:before{content:"\\f1b0"}.bi-border-style:before{content:"\\f1b1"}.bi-border-top:before{content:"\\f1b2"}.bi-border-width:before{content:"\\f1b3"}.bi-border:before{content:"\\f1b4"}.bi-bounding-box-circles:before{content:"\\f1b5"}.bi-bounding-box:before{content:"\\f1b6"}.bi-box-arrow-down-left:before{content:"\\f1b7"}.bi-box-arrow-down-right:before{content:"\\f1b8"}.bi-box-arrow-down:before{content:"\\f1b9"}.bi-box-arrow-in-down-left:before{content:"\\f1ba"}.bi-box-arrow-in-down-right:before{content:"\\f1bb"}.bi-box-arrow-in-down:before{content:"\\f1bc"}.bi-box-arrow-in-left:before{content:"\\f1bd"}.bi-box-arrow-in-right:before{content:"\\f1be"}.bi-box-arrow-in-up-left:before{content:"\\f1bf"}.bi-box-arrow-in-up-right:before{content:"\\f1c0"}.bi-box-arrow-in-up:before{content:"\\f1c1"}.bi-box-arrow-left:before{content:"\\f1c2"}.bi-box-arrow-right:before{content:"\\f1c3"}.bi-box-arrow-up-left:before{content:"\\f1c4"}.bi-box-arrow-up-right:before{content:"\\f1c5"}.bi-box-arrow-up:before{content:"\\f1c6"}.bi-box-seam:before{content:"\\f1c7"}.bi-box:before{content:"\\f1c8"}.bi-braces:before{content:"\\f1c9"}.bi-bricks:before{content:"\\f1ca"}.bi-briefcase-fill:before{content:"\\f1cb"}.bi-briefcase:before{content:"\\f1cc"}.bi-brightness-alt-high-fill:before{content:"\\f1cd"}.bi-brightness-alt-high:before{content:"\\f1ce"}.bi-brightness-alt-low-fill:before{content:"\\f1cf"}.bi-brightness-alt-low:before{content:"\\f1d0"}.bi-brightness-high-fill:before{content:"\\f1d1"}.bi-brightness-high:before{content:"\\f1d2"}.bi-brightness-low-fill:before{content:"\\f1d3"}.bi-brightness-low:before{content:"\\f1d4"}.bi-broadcast-pin:before{content:"\\f1d5"}.bi-broadcast:before{content:"\\f1d6"}.bi-brush-fill:before{content:"\\f1d7"}.bi-brush:before{content:"\\f1d8"}.bi-bucket-fill:before{content:"\\f1d9"}.bi-bucket:before{content:"\\f1da"}.bi-bug-fill:before{content:"\\f1db"}.bi-bug:before{content:"\\f1dc"}.bi-building:before{content:"\\f1dd"}.bi-bullseye:before{content:"\\f1de"}.bi-calculator-fill:before{content:"\\f1df"}.bi-calculator:before{content:"\\f1e0"}.bi-calendar-check-fill:before{content:"\\f1e1"}.bi-calendar-check:before{content:"\\f1e2"}.bi-calendar-date-fill:before{content:"\\f1e3"}.bi-calendar-date:before{content:"\\f1e4"}.bi-calendar-day-fill:before{content:"\\f1e5"}.bi-calendar-day:before{content:"\\f1e6"}.bi-calendar-event-fill:before{content:"\\f1e7"}.bi-calendar-event:before{content:"\\f1e8"}.bi-calendar-fill:before{content:"\\f1e9"}.bi-calendar-minus-fill:before{content:"\\f1ea"}.bi-calendar-minus:before{content:"\\f1eb"}.bi-calendar-month-fill:before{content:"\\f1ec"}.bi-calendar-month:before{content:"\\f1ed"}.bi-calendar-plus-fill:before{content:"\\f1ee"}.bi-calendar-plus:before{content:"\\f1ef"}.bi-calendar-range-fill:before{content:"\\f1f0"}.bi-calendar-range:before{content:"\\f1f1"}.bi-calendar-week-fill:before{content:"\\f1f2"}.bi-calendar-week:before{content:"\\f1f3"}.bi-calendar-x-fill:before{content:"\\f1f4"}.bi-calendar-x:before{content:"\\f1f5"}.bi-calendar:before{content:"\\f1f6"}.bi-calendar2-check-fill:before{content:"\\f1f7"}.bi-calendar2-check:before{content:"\\f1f8"}.bi-calendar2-date-fill:before{content:"\\f1f9"}.bi-calendar2-date:before{content:"\\f1fa"}.bi-calendar2-day-fill:before{content:"\\f1fb"}.bi-calendar2-day:before{content:"\\f1fc"}.bi-calendar2-event-fill:before{content:"\\f1fd"}.bi-calendar2-event:before{content:"\\f1fe"}.bi-calendar2-fill:before{content:"\\f1ff"}.bi-calendar2-minus-fill:before{content:"\\f200"}.bi-calendar2-minus:before{content:"\\f201"}.bi-calendar2-month-fill:before{content:"\\f202"}.bi-calendar2-month:before{content:"\\f203"}.bi-calendar2-plus-fill:before{content:"\\f204"}.bi-calendar2-plus:before{content:"\\f205"}.bi-calendar2-range-fill:before{content:"\\f206"}.bi-calendar2-range:before{content:"\\f207"}.bi-calendar2-week-fill:before{content:"\\f208"}.bi-calendar2-week:before{content:"\\f209"}.bi-calendar2-x-fill:before{content:"\\f20a"}.bi-calendar2-x:before{content:"\\f20b"}.bi-calendar2:before{content:"\\f20c"}.bi-calendar3-event-fill:before{content:"\\f20d"}.bi-calendar3-event:before{content:"\\f20e"}.bi-calendar3-fill:before{content:"\\f20f"}.bi-calendar3-range-fill:before{content:"\\f210"}.bi-calendar3-range:before{content:"\\f211"}.bi-calendar3-week-fill:before{content:"\\f212"}.bi-calendar3-week:before{content:"\\f213"}.bi-calendar3:before{content:"\\f214"}.bi-calendar4-event:before{content:"\\f215"}.bi-calendar4-range:before{content:"\\f216"}.bi-calendar4-week:before{content:"\\f217"}.bi-calendar4:before{content:"\\f218"}.bi-camera-fill:before{content:"\\f219"}.bi-camera-reels-fill:before{content:"\\f21a"}.bi-camera-reels:before{content:"\\f21b"}.bi-camera-video-fill:before{content:"\\f21c"}.bi-camera-video-off-fill:before{content:"\\f21d"}.bi-camera-video-off:before{content:"\\f21e"}.bi-camera-video:before{content:"\\f21f"}.bi-camera:before{content:"\\f220"}.bi-camera2:before{content:"\\f221"}.bi-capslock-fill:before{content:"\\f222"}.bi-capslock:before{content:"\\f223"}.bi-card-checklist:before{content:"\\f224"}.bi-card-heading:before{content:"\\f225"}.bi-card-image:before{content:"\\f226"}.bi-card-list:before{content:"\\f227"}.bi-card-text:before{content:"\\f228"}.bi-caret-down-fill:before{content:"\\f229"}.bi-caret-down-square-fill:before{content:"\\f22a"}.bi-caret-down-square:before{content:"\\f22b"}.bi-caret-down:before{content:"\\f22c"}.bi-caret-left-fill:before{content:"\\f22d"}.bi-caret-left-square-fill:before{content:"\\f22e"}.bi-caret-left-square:before{content:"\\f22f"}.bi-caret-left:before{content:"\\f230"}.bi-caret-right-fill:before{content:"\\f231"}.bi-caret-right-square-fill:before{content:"\\f232"}.bi-caret-right-square:before{content:"\\f233"}.bi-caret-right:before{content:"\\f234"}.bi-caret-up-fill:before{content:"\\f235"}.bi-caret-up-square-fill:before{content:"\\f236"}.bi-caret-up-square:before{content:"\\f237"}.bi-caret-up:before{content:"\\f238"}.bi-cart-check-fill:before{content:"\\f239"}.bi-cart-check:before{content:"\\f23a"}.bi-cart-dash-fill:before{content:"\\f23b"}.bi-cart-dash:before{content:"\\f23c"}.bi-cart-fill:before{content:"\\f23d"}.bi-cart-plus-fill:before{content:"\\f23e"}.bi-cart-plus:before{content:"\\f23f"}.bi-cart-x-fill:before{content:"\\f240"}.bi-cart-x:before{content:"\\f241"}.bi-cart:before{content:"\\f242"}.bi-cart2:before{content:"\\f243"}.bi-cart3:before{content:"\\f244"}.bi-cart4:before{content:"\\f245"}.bi-cash-stack:before{content:"\\f246"}.bi-cash:before{content:"\\f247"}.bi-cast:before{content:"\\f248"}.bi-chat-dots-fill:before{content:"\\f249"}.bi-chat-dots:before{content:"\\f24a"}.bi-chat-fill:before{content:"\\f24b"}.bi-chat-left-dots-fill:before{content:"\\f24c"}.bi-chat-left-dots:before{content:"\\f24d"}.bi-chat-left-fill:before{content:"\\f24e"}.bi-chat-left-quote-fill:before{content:"\\f24f"}.bi-chat-left-quote:before{content:"\\f250"}.bi-chat-left-text-fill:before{content:"\\f251"}.bi-chat-left-text:before{content:"\\f252"}.bi-chat-left:before{content:"\\f253"}.bi-chat-quote-fill:before{content:"\\f254"}.bi-chat-quote:before{content:"\\f255"}.bi-chat-right-dots-fill:before{content:"\\f256"}.bi-chat-right-dots:before{content:"\\f257"}.bi-chat-right-fill:before{content:"\\f258"}.bi-chat-right-quote-fill:before{content:"\\f259"}.bi-chat-right-quote:before{content:"\\f25a"}.bi-chat-right-text-fill:before{content:"\\f25b"}.bi-chat-right-text:before{content:"\\f25c"}.bi-chat-right:before{content:"\\f25d"}.bi-chat-square-dots-fill:before{content:"\\f25e"}.bi-chat-square-dots:before{content:"\\f25f"}.bi-chat-square-fill:before{content:"\\f260"}.bi-chat-square-quote-fill:before{content:"\\f261"}.bi-chat-square-quote:before{content:"\\f262"}.bi-chat-square-text-fill:before{content:"\\f263"}.bi-chat-square-text:before{content:"\\f264"}.bi-chat-square:before{content:"\\f265"}.bi-chat-text-fill:before{content:"\\f266"}.bi-chat-text:before{content:"\\f267"}.bi-chat:before{content:"\\f268"}.bi-check-all:before{content:"\\f269"}.bi-check-circle-fill:before{content:"\\f26a"}.bi-check-circle:before{content:"\\f26b"}.bi-check-square-fill:before{content:"\\f26c"}.bi-check-square:before{content:"\\f26d"}.bi-check:before{content:"\\f26e"}.bi-check2-all:before{content:"\\f26f"}.bi-check2-circle:before{content:"\\f270"}.bi-check2-square:before{content:"\\f271"}.bi-check2:before{content:"\\f272"}.bi-chevron-bar-contract:before{content:"\\f273"}.bi-chevron-bar-down:before{content:"\\f274"}.bi-chevron-bar-expand:before{content:"\\f275"}.bi-chevron-bar-left:before{content:"\\f276"}.bi-chevron-bar-right:before{content:"\\f277"}.bi-chevron-bar-up:before{content:"\\f278"}.bi-chevron-compact-down:before{content:"\\f279"}.bi-chevron-compact-left:before{content:"\\f27a"}.bi-chevron-compact-right:before{content:"\\f27b"}.bi-chevron-compact-up:before{content:"\\f27c"}.bi-chevron-contract:before{content:"\\f27d"}.bi-chevron-double-down:before{content:"\\f27e"}.bi-chevron-double-left:before{content:"\\f27f"}.bi-chevron-double-right:before{content:"\\f280"}.bi-chevron-double-up:before{content:"\\f281"}.bi-chevron-down:before{content:"\\f282"}.bi-chevron-expand:before{content:"\\f283"}.bi-chevron-left:before{content:"\\f284"}.bi-chevron-right:before{content:"\\f285"}.bi-chevron-up:before{content:"\\f286"}.bi-circle-fill:before{content:"\\f287"}.bi-circle-half:before{content:"\\f288"}.bi-circle-square:before{content:"\\f289"}.bi-circle:before{content:"\\f28a"}.bi-clipboard-check:before{content:"\\f28b"}.bi-clipboard-data:before{content:"\\f28c"}.bi-clipboard-minus:before{content:"\\f28d"}.bi-clipboard-plus:before{content:"\\f28e"}.bi-clipboard-x:before{content:"\\f28f"}.bi-clipboard:before{content:"\\f290"}.bi-clock-fill:before{content:"\\f291"}.bi-clock-history:before{content:"\\f292"}.bi-clock:before{content:"\\f293"}.bi-cloud-arrow-down-fill:before{content:"\\f294"}.bi-cloud-arrow-down:before{content:"\\f295"}.bi-cloud-arrow-up-fill:before{content:"\\f296"}.bi-cloud-arrow-up:before{content:"\\f297"}.bi-cloud-check-fill:before{content:"\\f298"}.bi-cloud-check:before{content:"\\f299"}.bi-cloud-download-fill:before{content:"\\f29a"}.bi-cloud-download:before{content:"\\f29b"}.bi-cloud-drizzle-fill:before{content:"\\f29c"}.bi-cloud-drizzle:before{content:"\\f29d"}.bi-cloud-fill:before{content:"\\f29e"}.bi-cloud-fog-fill:before{content:"\\f29f"}.bi-cloud-fog:before{content:"\\f2a0"}.bi-cloud-fog2-fill:before{content:"\\f2a1"}.bi-cloud-fog2:before{content:"\\f2a2"}.bi-cloud-hail-fill:before{content:"\\f2a3"}.bi-cloud-hail:before{content:"\\f2a4"}.bi-cloud-haze-fill:before{content:"\\f2a6"}.bi-cloud-haze:before{content:"\\f2a7"}.bi-cloud-haze2-fill:before{content:"\\f2a8"}.bi-cloud-lightning-fill:before{content:"\\f2a9"}.bi-cloud-lightning-rain-fill:before{content:"\\f2aa"}.bi-cloud-lightning-rain:before{content:"\\f2ab"}.bi-cloud-lightning:before{content:"\\f2ac"}.bi-cloud-minus-fill:before{content:"\\f2ad"}.bi-cloud-minus:before{content:"\\f2ae"}.bi-cloud-moon-fill:before{content:"\\f2af"}.bi-cloud-moon:before{content:"\\f2b0"}.bi-cloud-plus-fill:before{content:"\\f2b1"}.bi-cloud-plus:before{content:"\\f2b2"}.bi-cloud-rain-fill:before{content:"\\f2b3"}.bi-cloud-rain-heavy-fill:before{content:"\\f2b4"}.bi-cloud-rain-heavy:before{content:"\\f2b5"}.bi-cloud-rain:before{content:"\\f2b6"}.bi-cloud-slash-fill:before{content:"\\f2b7"}.bi-cloud-slash:before{content:"\\f2b8"}.bi-cloud-sleet-fill:before{content:"\\f2b9"}.bi-cloud-sleet:before{content:"\\f2ba"}.bi-cloud-snow-fill:before{content:"\\f2bb"}.bi-cloud-snow:before{content:"\\f2bc"}.bi-cloud-sun-fill:before{content:"\\f2bd"}.bi-cloud-sun:before{content:"\\f2be"}.bi-cloud-upload-fill:before{content:"\\f2bf"}.bi-cloud-upload:before{content:"\\f2c0"}.bi-cloud:before{content:"\\f2c1"}.bi-clouds-fill:before{content:"\\f2c2"}.bi-clouds:before{content:"\\f2c3"}.bi-cloudy-fill:before{content:"\\f2c4"}.bi-cloudy:before{content:"\\f2c5"}.bi-code-slash:before{content:"\\f2c6"}.bi-code-square:before{content:"\\f2c7"}.bi-code:before{content:"\\f2c8"}.bi-collection-fill:before{content:"\\f2c9"}.bi-collection-play-fill:before{content:"\\f2ca"}.bi-collection-play:before{content:"\\f2cb"}.bi-collection:before{content:"\\f2cc"}.bi-columns-gap:before{content:"\\f2cd"}.bi-columns:before{content:"\\f2ce"}.bi-command:before{content:"\\f2cf"}.bi-compass-fill:before{content:"\\f2d0"}.bi-compass:before{content:"\\f2d1"}.bi-cone-striped:before{content:"\\f2d2"}.bi-cone:before{content:"\\f2d3"}.bi-controller:before{content:"\\f2d4"}.bi-cpu-fill:before{content:"\\f2d5"}.bi-cpu:before{content:"\\f2d6"}.bi-credit-card-2-back-fill:before{content:"\\f2d7"}.bi-credit-card-2-back:before{content:"\\f2d8"}.bi-credit-card-2-front-fill:before{content:"\\f2d9"}.bi-credit-card-2-front:before{content:"\\f2da"}.bi-credit-card-fill:before{content:"\\f2db"}.bi-credit-card:before{content:"\\f2dc"}.bi-crop:before{content:"\\f2dd"}.bi-cup-fill:before{content:"\\f2de"}.bi-cup-straw:before{content:"\\f2df"}.bi-cup:before{content:"\\f2e0"}.bi-cursor-fill:before{content:"\\f2e1"}.bi-cursor-text:before{content:"\\f2e2"}.bi-cursor:before{content:"\\f2e3"}.bi-dash-circle-dotted:before{content:"\\f2e4"}.bi-dash-circle-fill:before{content:"\\f2e5"}.bi-dash-circle:before{content:"\\f2e6"}.bi-dash-square-dotted:before{content:"\\f2e7"}.bi-dash-square-fill:before{content:"\\f2e8"}.bi-dash-square:before{content:"\\f2e9"}.bi-dash:before{content:"\\f2ea"}.bi-diagram-2-fill:before{content:"\\f2eb"}.bi-diagram-2:before{content:"\\f2ec"}.bi-diagram-3-fill:before{content:"\\f2ed"}.bi-diagram-3:before{content:"\\f2ee"}.bi-diamond-fill:before{content:"\\f2ef"}.bi-diamond-half:before{content:"\\f2f0"}.bi-diamond:before{content:"\\f2f1"}.bi-dice-1-fill:before{content:"\\f2f2"}.bi-dice-1:before{content:"\\f2f3"}.bi-dice-2-fill:before{content:"\\f2f4"}.bi-dice-2:before{content:"\\f2f5"}.bi-dice-3-fill:before{content:"\\f2f6"}.bi-dice-3:before{content:"\\f2f7"}.bi-dice-4-fill:before{content:"\\f2f8"}.bi-dice-4:before{content:"\\f2f9"}.bi-dice-5-fill:before{content:"\\f2fa"}.bi-dice-5:before{content:"\\f2fb"}.bi-dice-6-fill:before{content:"\\f2fc"}.bi-dice-6:before{content:"\\f2fd"}.bi-disc-fill:before{content:"\\f2fe"}.bi-disc:before{content:"\\f2ff"}.bi-discord:before{content:"\\f300"}.bi-display-fill:before{content:"\\f301"}.bi-display:before{content:"\\f302"}.bi-distribute-horizontal:before{content:"\\f303"}.bi-distribute-vertical:before{content:"\\f304"}.bi-door-closed-fill:before{content:"\\f305"}.bi-door-closed:before{content:"\\f306"}.bi-door-open-fill:before{content:"\\f307"}.bi-door-open:before{content:"\\f308"}.bi-dot:before{content:"\\f309"}.bi-download:before{content:"\\f30a"}.bi-droplet-fill:before{content:"\\f30b"}.bi-droplet-half:before{content:"\\f30c"}.bi-droplet:before{content:"\\f30d"}.bi-earbuds:before{content:"\\f30e"}.bi-easel-fill:before{content:"\\f30f"}.bi-easel:before{content:"\\f310"}.bi-egg-fill:before{content:"\\f311"}.bi-egg-fried:before{content:"\\f312"}.bi-egg:before{content:"\\f313"}.bi-eject-fill:before{content:"\\f314"}.bi-eject:before{content:"\\f315"}.bi-emoji-angry-fill:before{content:"\\f316"}.bi-emoji-angry:before{content:"\\f317"}.bi-emoji-dizzy-fill:before{content:"\\f318"}.bi-emoji-dizzy:before{content:"\\f319"}.bi-emoji-expressionless-fill:before{content:"\\f31a"}.bi-emoji-expressionless:before{content:"\\f31b"}.bi-emoji-frown-fill:before{content:"\\f31c"}.bi-emoji-frown:before{content:"\\f31d"}.bi-emoji-heart-eyes-fill:before{content:"\\f31e"}.bi-emoji-heart-eyes:before{content:"\\f31f"}.bi-emoji-laughing-fill:before{content:"\\f320"}.bi-emoji-laughing:before{content:"\\f321"}.bi-emoji-neutral-fill:before{content:"\\f322"}.bi-emoji-neutral:before{content:"\\f323"}.bi-emoji-smile-fill:before{content:"\\f324"}.bi-emoji-smile-upside-down-fill:before{content:"\\f325"}.bi-emoji-smile-upside-down:before{content:"\\f326"}.bi-emoji-smile:before{content:"\\f327"}.bi-emoji-sunglasses-fill:before{content:"\\f328"}.bi-emoji-sunglasses:before{content:"\\f329"}.bi-emoji-wink-fill:before{content:"\\f32a"}.bi-emoji-wink:before{content:"\\f32b"}.bi-envelope-fill:before{content:"\\f32c"}.bi-envelope-open-fill:before{content:"\\f32d"}.bi-envelope-open:before{content:"\\f32e"}.bi-envelope:before{content:"\\f32f"}.bi-eraser-fill:before{content:"\\f330"}.bi-eraser:before{content:"\\f331"}.bi-exclamation-circle-fill:before{content:"\\f332"}.bi-exclamation-circle:before{content:"\\f333"}.bi-exclamation-diamond-fill:before{content:"\\f334"}.bi-exclamation-diamond:before{content:"\\f335"}.bi-exclamation-octagon-fill:before{content:"\\f336"}.bi-exclamation-octagon:before{content:"\\f337"}.bi-exclamation-square-fill:before{content:"\\f338"}.bi-exclamation-square:before{content:"\\f339"}.bi-exclamation-triangle-fill:before{content:"\\f33a"}.bi-exclamation-triangle:before{content:"\\f33b"}.bi-exclamation:before{content:"\\f33c"}.bi-exclude:before{content:"\\f33d"}.bi-eye-fill:before{content:"\\f33e"}.bi-eye-slash-fill:before{content:"\\f33f"}.bi-eye-slash:before{content:"\\f340"}.bi-eye:before{content:"\\f341"}.bi-eyedropper:before{content:"\\f342"}.bi-eyeglasses:before{content:"\\f343"}.bi-facebook:before{content:"\\f344"}.bi-file-arrow-down-fill:before{content:"\\f345"}.bi-file-arrow-down:before{content:"\\f346"}.bi-file-arrow-up-fill:before{content:"\\f347"}.bi-file-arrow-up:before{content:"\\f348"}.bi-file-bar-graph-fill:before{content:"\\f349"}.bi-file-bar-graph:before{content:"\\f34a"}.bi-file-binary-fill:before{content:"\\f34b"}.bi-file-binary:before{content:"\\f34c"}.bi-file-break-fill:before{content:"\\f34d"}.bi-file-break:before{content:"\\f34e"}.bi-file-check-fill:before{content:"\\f34f"}.bi-file-check:before{content:"\\f350"}.bi-file-code-fill:before{content:"\\f351"}.bi-file-code:before{content:"\\f352"}.bi-file-diff-fill:before{content:"\\f353"}.bi-file-diff:before{content:"\\f354"}.bi-file-earmark-arrow-down-fill:before{content:"\\f355"}.bi-file-earmark-arrow-down:before{content:"\\f356"}.bi-file-earmark-arrow-up-fill:before{content:"\\f357"}.bi-file-earmark-arrow-up:before{content:"\\f358"}.bi-file-earmark-bar-graph-fill:before{content:"\\f359"}.bi-file-earmark-bar-graph:before{content:"\\f35a"}.bi-file-earmark-binary-fill:before{content:"\\f35b"}.bi-file-earmark-binary:before{content:"\\f35c"}.bi-file-earmark-break-fill:before{content:"\\f35d"}.bi-file-earmark-break:before{content:"\\f35e"}.bi-file-earmark-check-fill:before{content:"\\f35f"}.bi-file-earmark-check:before{content:"\\f360"}.bi-file-earmark-code-fill:before{content:"\\f361"}.bi-file-earmark-code:before{content:"\\f362"}.bi-file-earmark-diff-fill:before{content:"\\f363"}.bi-file-earmark-diff:before{content:"\\f364"}.bi-file-earmark-easel-fill:before{content:"\\f365"}.bi-file-earmark-easel:before{content:"\\f366"}.bi-file-earmark-excel-fill:before{content:"\\f367"}.bi-file-earmark-excel:before{content:"\\f368"}.bi-file-earmark-fill:before{content:"\\f369"}.bi-file-earmark-font-fill:before{content:"\\f36a"}.bi-file-earmark-font:before{content:"\\f36b"}.bi-file-earmark-image-fill:before{content:"\\f36c"}.bi-file-earmark-image:before{content:"\\f36d"}.bi-file-earmark-lock-fill:before{content:"\\f36e"}.bi-file-earmark-lock:before{content:"\\f36f"}.bi-file-earmark-lock2-fill:before{content:"\\f370"}.bi-file-earmark-lock2:before{content:"\\f371"}.bi-file-earmark-medical-fill:before{content:"\\f372"}.bi-file-earmark-medical:before{content:"\\f373"}.bi-file-earmark-minus-fill:before{content:"\\f374"}.bi-file-earmark-minus:before{content:"\\f375"}.bi-file-earmark-music-fill:before{content:"\\f376"}.bi-file-earmark-music:before{content:"\\f377"}.bi-file-earmark-person-fill:before{content:"\\f378"}.bi-file-earmark-person:before{content:"\\f379"}.bi-file-earmark-play-fill:before{content:"\\f37a"}.bi-file-earmark-play:before{content:"\\f37b"}.bi-file-earmark-plus-fill:before{content:"\\f37c"}.bi-file-earmark-plus:before{content:"\\f37d"}.bi-file-earmark-post-fill:before{content:"\\f37e"}.bi-file-earmark-post:before{content:"\\f37f"}.bi-file-earmark-ppt-fill:before{content:"\\f380"}.bi-file-earmark-ppt:before{content:"\\f381"}.bi-file-earmark-richtext-fill:before{content:"\\f382"}.bi-file-earmark-richtext:before{content:"\\f383"}.bi-file-earmark-ruled-fill:before{content:"\\f384"}.bi-file-earmark-ruled:before{content:"\\f385"}.bi-file-earmark-slides-fill:before{content:"\\f386"}.bi-file-earmark-slides:before{content:"\\f387"}.bi-file-earmark-spreadsheet-fill:before{content:"\\f388"}.bi-file-earmark-spreadsheet:before{content:"\\f389"}.bi-file-earmark-text-fill:before{content:"\\f38a"}.bi-file-earmark-text:before{content:"\\f38b"}.bi-file-earmark-word-fill:before{content:"\\f38c"}.bi-file-earmark-word:before{content:"\\f38d"}.bi-file-earmark-x-fill:before{content:"\\f38e"}.bi-file-earmark-x:before{content:"\\f38f"}.bi-file-earmark-zip-fill:before{content:"\\f390"}.bi-file-earmark-zip:before{content:"\\f391"}.bi-file-earmark:before{content:"\\f392"}.bi-file-easel-fill:before{content:"\\f393"}.bi-file-easel:before{content:"\\f394"}.bi-file-excel-fill:before{content:"\\f395"}.bi-file-excel:before{content:"\\f396"}.bi-file-fill:before{content:"\\f397"}.bi-file-font-fill:before{content:"\\f398"}.bi-file-font:before{content:"\\f399"}.bi-file-image-fill:before{content:"\\f39a"}.bi-file-image:before{content:"\\f39b"}.bi-file-lock-fill:before{content:"\\f39c"}.bi-file-lock:before{content:"\\f39d"}.bi-file-lock2-fill:before{content:"\\f39e"}.bi-file-lock2:before{content:"\\f39f"}.bi-file-medical-fill:before{content:"\\f3a0"}.bi-file-medical:before{content:"\\f3a1"}.bi-file-minus-fill:before{content:"\\f3a2"}.bi-file-minus:before{content:"\\f3a3"}.bi-file-music-fill:before{content:"\\f3a4"}.bi-file-music:before{content:"\\f3a5"}.bi-file-person-fill:before{content:"\\f3a6"}.bi-file-person:before{content:"\\f3a7"}.bi-file-play-fill:before{content:"\\f3a8"}.bi-file-play:before{content:"\\f3a9"}.bi-file-plus-fill:before{content:"\\f3aa"}.bi-file-plus:before{content:"\\f3ab"}.bi-file-post-fill:before{content:"\\f3ac"}.bi-file-post:before{content:"\\f3ad"}.bi-file-ppt-fill:before{content:"\\f3ae"}.bi-file-ppt:before{content:"\\f3af"}.bi-file-richtext-fill:before{content:"\\f3b0"}.bi-file-richtext:before{content:"\\f3b1"}.bi-file-ruled-fill:before{content:"\\f3b2"}.bi-file-ruled:before{content:"\\f3b3"}.bi-file-slides-fill:before{content:"\\f3b4"}.bi-file-slides:before{content:"\\f3b5"}.bi-file-spreadsheet-fill:before{content:"\\f3b6"}.bi-file-spreadsheet:before{content:"\\f3b7"}.bi-file-text-fill:before{content:"\\f3b8"}.bi-file-text:before{content:"\\f3b9"}.bi-file-word-fill:before{content:"\\f3ba"}.bi-file-word:before{content:"\\f3bb"}.bi-file-x-fill:before{content:"\\f3bc"}.bi-file-x:before{content:"\\f3bd"}.bi-file-zip-fill:before{content:"\\f3be"}.bi-file-zip:before{content:"\\f3bf"}.bi-file:before{content:"\\f3c0"}.bi-files-alt:before{content:"\\f3c1"}.bi-files:before{content:"\\f3c2"}.bi-film:before{content:"\\f3c3"}.bi-filter-circle-fill:before{content:"\\f3c4"}.bi-filter-circle:before{content:"\\f3c5"}.bi-filter-left:before{content:"\\f3c6"}.bi-filter-right:before{content:"\\f3c7"}.bi-filter-square-fill:before{content:"\\f3c8"}.bi-filter-square:before{content:"\\f3c9"}.bi-filter:before{content:"\\f3ca"}.bi-flag-fill:before{content:"\\f3cb"}.bi-flag:before{content:"\\f3cc"}.bi-flower1:before{content:"\\f3cd"}.bi-flower2:before{content:"\\f3ce"}.bi-flower3:before{content:"\\f3cf"}.bi-folder-check:before{content:"\\f3d0"}.bi-folder-fill:before{content:"\\f3d1"}.bi-folder-minus:before{content:"\\f3d2"}.bi-folder-plus:before{content:"\\f3d3"}.bi-folder-symlink-fill:before{content:"\\f3d4"}.bi-folder-symlink:before{content:"\\f3d5"}.bi-folder-x:before{content:"\\f3d6"}.bi-folder:before{content:"\\f3d7"}.bi-folder2-open:before{content:"\\f3d8"}.bi-folder2:before{content:"\\f3d9"}.bi-fonts:before{content:"\\f3da"}.bi-forward-fill:before{content:"\\f3db"}.bi-forward:before{content:"\\f3dc"}.bi-front:before{content:"\\f3dd"}.bi-fullscreen-exit:before{content:"\\f3de"}.bi-fullscreen:before{content:"\\f3df"}.bi-funnel-fill:before{content:"\\f3e0"}.bi-funnel:before{content:"\\f3e1"}.bi-gear-fill:before{content:"\\f3e2"}.bi-gear-wide-connected:before{content:"\\f3e3"}.bi-gear-wide:before{content:"\\f3e4"}.bi-gear:before{content:"\\f3e5"}.bi-gem:before{content:"\\f3e6"}.bi-geo-alt-fill:before{content:"\\f3e7"}.bi-geo-alt:before{content:"\\f3e8"}.bi-geo-fill:before{content:"\\f3e9"}.bi-geo:before{content:"\\f3ea"}.bi-gift-fill:before{content:"\\f3eb"}.bi-gift:before{content:"\\f3ec"}.bi-github:before{content:"\\f3ed"}.bi-globe:before{content:"\\f3ee"}.bi-globe2:before{content:"\\f3ef"}.bi-google:before{content:"\\f3f0"}.bi-graph-down:before{content:"\\f3f1"}.bi-graph-up:before{content:"\\f3f2"}.bi-grid-1x2-fill:before{content:"\\f3f3"}.bi-grid-1x2:before{content:"\\f3f4"}.bi-grid-3x2-gap-fill:before{content:"\\f3f5"}.bi-grid-3x2-gap:before{content:"\\f3f6"}.bi-grid-3x2:before{content:"\\f3f7"}.bi-grid-3x3-gap-fill:before{content:"\\f3f8"}.bi-grid-3x3-gap:before{content:"\\f3f9"}.bi-grid-3x3:before{content:"\\f3fa"}.bi-grid-fill:before{content:"\\f3fb"}.bi-grid:before{content:"\\f3fc"}.bi-grip-horizontal:before{content:"\\f3fd"}.bi-grip-vertical:before{content:"\\f3fe"}.bi-hammer:before{content:"\\f3ff"}.bi-hand-index-fill:before{content:"\\f400"}.bi-hand-index-thumb-fill:before{content:"\\f401"}.bi-hand-index-thumb:before{content:"\\f402"}.bi-hand-index:before{content:"\\f403"}.bi-hand-thumbs-down-fill:before{content:"\\f404"}.bi-hand-thumbs-down:before{content:"\\f405"}.bi-hand-thumbs-up-fill:before{content:"\\f406"}.bi-hand-thumbs-up:before{content:"\\f407"}.bi-handbag-fill:before{content:"\\f408"}.bi-handbag:before{content:"\\f409"}.bi-hash:before{content:"\\f40a"}.bi-hdd-fill:before{content:"\\f40b"}.bi-hdd-network-fill:before{content:"\\f40c"}.bi-hdd-network:before{content:"\\f40d"}.bi-hdd-rack-fill:before{content:"\\f40e"}.bi-hdd-rack:before{content:"\\f40f"}.bi-hdd-stack-fill:before{content:"\\f410"}.bi-hdd-stack:before{content:"\\f411"}.bi-hdd:before{content:"\\f412"}.bi-headphones:before{content:"\\f413"}.bi-headset:before{content:"\\f414"}.bi-heart-fill:before{content:"\\f415"}.bi-heart-half:before{content:"\\f416"}.bi-heart:before{content:"\\f417"}.bi-heptagon-fill:before{content:"\\f418"}.bi-heptagon-half:before{content:"\\f419"}.bi-heptagon:before{content:"\\f41a"}.bi-hexagon-fill:before{content:"\\f41b"}.bi-hexagon-half:before{content:"\\f41c"}.bi-hexagon:before{content:"\\f41d"}.bi-hourglass-bottom:before{content:"\\f41e"}.bi-hourglass-split:before{content:"\\f41f"}.bi-hourglass-top:before{content:"\\f420"}.bi-hourglass:before{content:"\\f421"}.bi-house-door-fill:before{content:"\\f422"}.bi-house-door:before{content:"\\f423"}.bi-house-fill:before{content:"\\f424"}.bi-house:before{content:"\\f425"}.bi-hr:before{content:"\\f426"}.bi-hurricane:before{content:"\\f427"}.bi-image-alt:before{content:"\\f428"}.bi-image-fill:before{content:"\\f429"}.bi-image:before{content:"\\f42a"}.bi-images:before{content:"\\f42b"}.bi-inbox-fill:before{content:"\\f42c"}.bi-inbox:before{content:"\\f42d"}.bi-inboxes-fill:before{content:"\\f42e"}.bi-inboxes:before{content:"\\f42f"}.bi-info-circle-fill:before{content:"\\f430"}.bi-info-circle:before{content:"\\f431"}.bi-info-square-fill:before{content:"\\f432"}.bi-info-square:before{content:"\\f433"}.bi-info:before{content:"\\f434"}.bi-input-cursor-text:before{content:"\\f435"}.bi-input-cursor:before{content:"\\f436"}.bi-instagram:before{content:"\\f437"}.bi-intersect:before{content:"\\f438"}.bi-journal-album:before{content:"\\f439"}.bi-journal-arrow-down:before{content:"\\f43a"}.bi-journal-arrow-up:before{content:"\\f43b"}.bi-journal-bookmark-fill:before{content:"\\f43c"}.bi-journal-bookmark:before{content:"\\f43d"}.bi-journal-check:before{content:"\\f43e"}.bi-journal-code:before{content:"\\f43f"}.bi-journal-medical:before{content:"\\f440"}.bi-journal-minus:before{content:"\\f441"}.bi-journal-plus:before{content:"\\f442"}.bi-journal-richtext:before{content:"\\f443"}.bi-journal-text:before{content:"\\f444"}.bi-journal-x:before{content:"\\f445"}.bi-journal:before{content:"\\f446"}.bi-journals:before{content:"\\f447"}.bi-joystick:before{content:"\\f448"}.bi-justify-left:before{content:"\\f449"}.bi-justify-right:before{content:"\\f44a"}.bi-justify:before{content:"\\f44b"}.bi-kanban-fill:before{content:"\\f44c"}.bi-kanban:before{content:"\\f44d"}.bi-key-fill:before{content:"\\f44e"}.bi-key:before{content:"\\f44f"}.bi-keyboard-fill:before{content:"\\f450"}.bi-keyboard:before{content:"\\f451"}.bi-ladder:before{content:"\\f452"}.bi-lamp-fill:before{content:"\\f453"}.bi-lamp:before{content:"\\f454"}.bi-laptop-fill:before{content:"\\f455"}.bi-laptop:before{content:"\\f456"}.bi-layer-backward:before{content:"\\f457"}.bi-layer-forward:before{content:"\\f458"}.bi-layers-fill:before{content:"\\f459"}.bi-layers-half:before{content:"\\f45a"}.bi-layers:before{content:"\\f45b"}.bi-layout-sidebar-inset-reverse:before{content:"\\f45c"}.bi-layout-sidebar-inset:before{content:"\\f45d"}.bi-layout-sidebar-reverse:before{content:"\\f45e"}.bi-layout-sidebar:before{content:"\\f45f"}.bi-layout-split:before{content:"\\f460"}.bi-layout-text-sidebar-reverse:before{content:"\\f461"}.bi-layout-text-sidebar:before{content:"\\f462"}.bi-layout-text-window-reverse:before{content:"\\f463"}.bi-layout-text-window:before{content:"\\f464"}.bi-layout-three-columns:before{content:"\\f465"}.bi-layout-wtf:before{content:"\\f466"}.bi-life-preserver:before{content:"\\f467"}.bi-lightbulb-fill:before{content:"\\f468"}.bi-lightbulb-off-fill:before{content:"\\f469"}.bi-lightbulb-off:before{content:"\\f46a"}.bi-lightbulb:before{content:"\\f46b"}.bi-lightning-charge-fill:before{content:"\\f46c"}.bi-lightning-charge:before{content:"\\f46d"}.bi-lightning-fill:before{content:"\\f46e"}.bi-lightning:before{content:"\\f46f"}.bi-link-45deg:before{content:"\\f470"}.bi-link:before{content:"\\f471"}.bi-linkedin:before{content:"\\f472"}.bi-list-check:before{content:"\\f473"}.bi-list-nested:before{content:"\\f474"}.bi-list-ol:before{content:"\\f475"}.bi-list-stars:before{content:"\\f476"}.bi-list-task:before{content:"\\f477"}.bi-list-ul:before{content:"\\f478"}.bi-list:before{content:"\\f479"}.bi-lock-fill:before{content:"\\f47a"}.bi-lock:before{content:"\\f47b"}.bi-mailbox:before{content:"\\f47c"}.bi-mailbox2:before{content:"\\f47d"}.bi-map-fill:before{content:"\\f47e"}.bi-map:before{content:"\\f47f"}.bi-markdown-fill:before{content:"\\f480"}.bi-markdown:before{content:"\\f481"}.bi-mask:before{content:"\\f482"}.bi-megaphone-fill:before{content:"\\f483"}.bi-megaphone:before{content:"\\f484"}.bi-menu-app-fill:before{content:"\\f485"}.bi-menu-app:before{content:"\\f486"}.bi-menu-button-fill:before{content:"\\f487"}.bi-menu-button-wide-fill:before{content:"\\f488"}.bi-menu-button-wide:before{content:"\\f489"}.bi-menu-button:before{content:"\\f48a"}.bi-menu-down:before{content:"\\f48b"}.bi-menu-up:before{content:"\\f48c"}.bi-mic-fill:before{content:"\\f48d"}.bi-mic-mute-fill:before{content:"\\f48e"}.bi-mic-mute:before{content:"\\f48f"}.bi-mic:before{content:"\\f490"}.bi-minecart-loaded:before{content:"\\f491"}.bi-minecart:before{content:"\\f492"}.bi-moisture:before{content:"\\f493"}.bi-moon-fill:before{content:"\\f494"}.bi-moon-stars-fill:before{content:"\\f495"}.bi-moon-stars:before{content:"\\f496"}.bi-moon:before{content:"\\f497"}.bi-mouse-fill:before{content:"\\f498"}.bi-mouse:before{content:"\\f499"}.bi-mouse2-fill:before{content:"\\f49a"}.bi-mouse2:before{content:"\\f49b"}.bi-mouse3-fill:before{content:"\\f49c"}.bi-mouse3:before{content:"\\f49d"}.bi-music-note-beamed:before{content:"\\f49e"}.bi-music-note-list:before{content:"\\f49f"}.bi-music-note:before{content:"\\f4a0"}.bi-music-player-fill:before{content:"\\f4a1"}.bi-music-player:before{content:"\\f4a2"}.bi-newspaper:before{content:"\\f4a3"}.bi-node-minus-fill:before{content:"\\f4a4"}.bi-node-minus:before{content:"\\f4a5"}.bi-node-plus-fill:before{content:"\\f4a6"}.bi-node-plus:before{content:"\\f4a7"}.bi-nut-fill:before{content:"\\f4a8"}.bi-nut:before{content:"\\f4a9"}.bi-octagon-fill:before{content:"\\f4aa"}.bi-octagon-half:before{content:"\\f4ab"}.bi-octagon:before{content:"\\f4ac"}.bi-option:before{content:"\\f4ad"}.bi-outlet:before{content:"\\f4ae"}.bi-paint-bucket:before{content:"\\f4af"}.bi-palette-fill:before{content:"\\f4b0"}.bi-palette:before{content:"\\f4b1"}.bi-palette2:before{content:"\\f4b2"}.bi-paperclip:before{content:"\\f4b3"}.bi-paragraph:before{content:"\\f4b4"}.bi-patch-check-fill:before{content:"\\f4b5"}.bi-patch-check:before{content:"\\f4b6"}.bi-patch-exclamation-fill:before{content:"\\f4b7"}.bi-patch-exclamation:before{content:"\\f4b8"}.bi-patch-minus-fill:before{content:"\\f4b9"}.bi-patch-minus:before{content:"\\f4ba"}.bi-patch-plus-fill:before{content:"\\f4bb"}.bi-patch-plus:before{content:"\\f4bc"}.bi-patch-question-fill:before{content:"\\f4bd"}.bi-patch-question:before{content:"\\f4be"}.bi-pause-btn-fill:before{content:"\\f4bf"}.bi-pause-btn:before{content:"\\f4c0"}.bi-pause-circle-fill:before{content:"\\f4c1"}.bi-pause-circle:before{content:"\\f4c2"}.bi-pause-fill:before{content:"\\f4c3"}.bi-pause:before{content:"\\f4c4"}.bi-peace-fill:before{content:"\\f4c5"}.bi-peace:before{content:"\\f4c6"}.bi-pen-fill:before{content:"\\f4c7"}.bi-pen:before{content:"\\f4c8"}.bi-pencil-fill:before{content:"\\f4c9"}.bi-pencil-square:before{content:"\\f4ca"}.bi-pencil:before{content:"\\f4cb"}.bi-pentagon-fill:before{content:"\\f4cc"}.bi-pentagon-half:before{content:"\\f4cd"}.bi-pentagon:before{content:"\\f4ce"}.bi-people-fill:before{content:"\\f4cf"}.bi-people:before{content:"\\f4d0"}.bi-percent:before{content:"\\f4d1"}.bi-person-badge-fill:before{content:"\\f4d2"}.bi-person-badge:before{content:"\\f4d3"}.bi-person-bounding-box:before{content:"\\f4d4"}.bi-person-check-fill:before{content:"\\f4d5"}.bi-person-check:before{content:"\\f4d6"}.bi-person-circle:before{content:"\\f4d7"}.bi-person-dash-fill:before{content:"\\f4d8"}.bi-person-dash:before{content:"\\f4d9"}.bi-person-fill:before{content:"\\f4da"}.bi-person-lines-fill:before{content:"\\f4db"}.bi-person-plus-fill:before{content:"\\f4dc"}.bi-person-plus:before{content:"\\f4dd"}.bi-person-square:before{content:"\\f4de"}.bi-person-x-fill:before{content:"\\f4df"}.bi-person-x:before{content:"\\f4e0"}.bi-person:before{content:"\\f4e1"}.bi-phone-fill:before{content:"\\f4e2"}.bi-phone-landscape-fill:before{content:"\\f4e3"}.bi-phone-landscape:before{content:"\\f4e4"}.bi-phone-vibrate-fill:before{content:"\\f4e5"}.bi-phone-vibrate:before{content:"\\f4e6"}.bi-phone:before{content:"\\f4e7"}.bi-pie-chart-fill:before{content:"\\f4e8"}.bi-pie-chart:before{content:"\\f4e9"}.bi-pin-angle-fill:before{content:"\\f4ea"}.bi-pin-angle:before{content:"\\f4eb"}.bi-pin-fill:before{content:"\\f4ec"}.bi-pin:before{content:"\\f4ed"}.bi-pip-fill:before{content:"\\f4ee"}.bi-pip:before{content:"\\f4ef"}.bi-play-btn-fill:before{content:"\\f4f0"}.bi-play-btn:before{content:"\\f4f1"}.bi-play-circle-fill:before{content:"\\f4f2"}.bi-play-circle:before{content:"\\f4f3"}.bi-play-fill:before{content:"\\f4f4"}.bi-play:before{content:"\\f4f5"}.bi-plug-fill:before{content:"\\f4f6"}.bi-plug:before{content:"\\f4f7"}.bi-plus-circle-dotted:before{content:"\\f4f8"}.bi-plus-circle-fill:before{content:"\\f4f9"}.bi-plus-circle:before{content:"\\f4fa"}.bi-plus-square-dotted:before{content:"\\f4fb"}.bi-plus-square-fill:before{content:"\\f4fc"}.bi-plus-square:before{content:"\\f4fd"}.bi-plus:before{content:"\\f4fe"}.bi-power:before{content:"\\f4ff"}.bi-printer-fill:before{content:"\\f500"}.bi-printer:before{content:"\\f501"}.bi-puzzle-fill:before{content:"\\f502"}.bi-puzzle:before{content:"\\f503"}.bi-question-circle-fill:before{content:"\\f504"}.bi-question-circle:before{content:"\\f505"}.bi-question-diamond-fill:before{content:"\\f506"}.bi-question-diamond:before{content:"\\f507"}.bi-question-octagon-fill:before{content:"\\f508"}.bi-question-octagon:before{content:"\\f509"}.bi-question-square-fill:before{content:"\\f50a"}.bi-question-square:before{content:"\\f50b"}.bi-question:before{content:"\\f50c"}.bi-rainbow:before{content:"\\f50d"}.bi-receipt-cutoff:before{content:"\\f50e"}.bi-receipt:before{content:"\\f50f"}.bi-reception-0:before{content:"\\f510"}.bi-reception-1:before{content:"\\f511"}.bi-reception-2:before{content:"\\f512"}.bi-reception-3:before{content:"\\f513"}.bi-reception-4:before{content:"\\f514"}.bi-record-btn-fill:before{content:"\\f515"}.bi-record-btn:before{content:"\\f516"}.bi-record-circle-fill:before{content:"\\f517"}.bi-record-circle:before{content:"\\f518"}.bi-record-fill:before{content:"\\f519"}.bi-record:before{content:"\\f51a"}.bi-record2-fill:before{content:"\\f51b"}.bi-record2:before{content:"\\f51c"}.bi-reply-all-fill:before{content:"\\f51d"}.bi-reply-all:before{content:"\\f51e"}.bi-reply-fill:before{content:"\\f51f"}.bi-reply:before{content:"\\f520"}.bi-rss-fill:before{content:"\\f521"}.bi-rss:before{content:"\\f522"}.bi-rulers:before{content:"\\f523"}.bi-save-fill:before{content:"\\f524"}.bi-save:before{content:"\\f525"}.bi-save2-fill:before{content:"\\f526"}.bi-save2:before{content:"\\f527"}.bi-scissors:before{content:"\\f528"}.bi-screwdriver:before{content:"\\f529"}.bi-search:before{content:"\\f52a"}.bi-segmented-nav:before{content:"\\f52b"}.bi-server:before{content:"\\f52c"}.bi-share-fill:before{content:"\\f52d"}.bi-share:before{content:"\\f52e"}.bi-shield-check:before{content:"\\f52f"}.bi-shield-exclamation:before{content:"\\f530"}.bi-shield-fill-check:before{content:"\\f531"}.bi-shield-fill-exclamation:before{content:"\\f532"}.bi-shield-fill-minus:before{content:"\\f533"}.bi-shield-fill-plus:before{content:"\\f534"}.bi-shield-fill-x:before{content:"\\f535"}.bi-shield-fill:before{content:"\\f536"}.bi-shield-lock-fill:before{content:"\\f537"}.bi-shield-lock:before{content:"\\f538"}.bi-shield-minus:before{content:"\\f539"}.bi-shield-plus:before{content:"\\f53a"}.bi-shield-shaded:before{content:"\\f53b"}.bi-shield-slash-fill:before{content:"\\f53c"}.bi-shield-slash:before{content:"\\f53d"}.bi-shield-x:before{content:"\\f53e"}.bi-shield:before{content:"\\f53f"}.bi-shift-fill:before{content:"\\f540"}.bi-shift:before{content:"\\f541"}.bi-shop-window:before{content:"\\f542"}.bi-shop:before{content:"\\f543"}.bi-shuffle:before{content:"\\f544"}.bi-signpost-2-fill:before{content:"\\f545"}.bi-signpost-2:before{content:"\\f546"}.bi-signpost-fill:before{content:"\\f547"}.bi-signpost-split-fill:before{content:"\\f548"}.bi-signpost-split:before{content:"\\f549"}.bi-signpost:before{content:"\\f54a"}.bi-sim-fill:before{content:"\\f54b"}.bi-sim:before{content:"\\f54c"}.bi-skip-backward-btn-fill:before{content:"\\f54d"}.bi-skip-backward-btn:before{content:"\\f54e"}.bi-skip-backward-circle-fill:before{content:"\\f54f"}.bi-skip-backward-circle:before{content:"\\f550"}.bi-skip-backward-fill:before{content:"\\f551"}.bi-skip-backward:before{content:"\\f552"}.bi-skip-end-btn-fill:before{content:"\\f553"}.bi-skip-end-btn:before{content:"\\f554"}.bi-skip-end-circle-fill:before{content:"\\f555"}.bi-skip-end-circle:before{content:"\\f556"}.bi-skip-end-fill:before{content:"\\f557"}.bi-skip-end:before{content:"\\f558"}.bi-skip-forward-btn-fill:before{content:"\\f559"}.bi-skip-forward-btn:before{content:"\\f55a"}.bi-skip-forward-circle-fill:before{content:"\\f55b"}.bi-skip-forward-circle:before{content:"\\f55c"}.bi-skip-forward-fill:before{content:"\\f55d"}.bi-skip-forward:before{content:"\\f55e"}.bi-skip-start-btn-fill:before{content:"\\f55f"}.bi-skip-start-btn:before{content:"\\f560"}.bi-skip-start-circle-fill:before{content:"\\f561"}.bi-skip-start-circle:before{content:"\\f562"}.bi-skip-start-fill:before{content:"\\f563"}.bi-skip-start:before{content:"\\f564"}.bi-slack:before{content:"\\f565"}.bi-slash-circle-fill:before{content:"\\f566"}.bi-slash-circle:before{content:"\\f567"}.bi-slash-square-fill:before{content:"\\f568"}.bi-slash-square:before{content:"\\f569"}.bi-slash:before{content:"\\f56a"}.bi-sliders:before{content:"\\f56b"}.bi-smartwatch:before{content:"\\f56c"}.bi-snow:before{content:"\\f56d"}.bi-snow2:before{content:"\\f56e"}.bi-snow3:before{content:"\\f56f"}.bi-sort-alpha-down-alt:before{content:"\\f570"}.bi-sort-alpha-down:before{content:"\\f571"}.bi-sort-alpha-up-alt:before{content:"\\f572"}.bi-sort-alpha-up:before{content:"\\f573"}.bi-sort-down-alt:before{content:"\\f574"}.bi-sort-down:before{content:"\\f575"}.bi-sort-numeric-down-alt:before{content:"\\f576"}.bi-sort-numeric-down:before{content:"\\f577"}.bi-sort-numeric-up-alt:before{content:"\\f578"}.bi-sort-numeric-up:before{content:"\\f579"}.bi-sort-up-alt:before{content:"\\f57a"}.bi-sort-up:before{content:"\\f57b"}.bi-soundwave:before{content:"\\f57c"}.bi-speaker-fill:before{content:"\\f57d"}.bi-speaker:before{content:"\\f57e"}.bi-speedometer:before{content:"\\f57f"}.bi-speedometer2:before{content:"\\f580"}.bi-spellcheck:before{content:"\\f581"}.bi-square-fill:before{content:"\\f582"}.bi-square-half:before{content:"\\f583"}.bi-square:before{content:"\\f584"}.bi-stack:before{content:"\\f585"}.bi-star-fill:before{content:"\\f586"}.bi-star-half:before{content:"\\f587"}.bi-star:before{content:"\\f588"}.bi-stars:before{content:"\\f589"}.bi-stickies-fill:before{content:"\\f58a"}.bi-stickies:before{content:"\\f58b"}.bi-sticky-fill:before{content:"\\f58c"}.bi-sticky:before{content:"\\f58d"}.bi-stop-btn-fill:before{content:"\\f58e"}.bi-stop-btn:before{content:"\\f58f"}.bi-stop-circle-fill:before{content:"\\f590"}.bi-stop-circle:before{content:"\\f591"}.bi-stop-fill:before{content:"\\f592"}.bi-stop:before{content:"\\f593"}.bi-stoplights-fill:before{content:"\\f594"}.bi-stoplights:before{content:"\\f595"}.bi-stopwatch-fill:before{content:"\\f596"}.bi-stopwatch:before{content:"\\f597"}.bi-subtract:before{content:"\\f598"}.bi-suit-club-fill:before{content:"\\f599"}.bi-suit-club:before{content:"\\f59a"}.bi-suit-diamond-fill:before{content:"\\f59b"}.bi-suit-diamond:before{content:"\\f59c"}.bi-suit-heart-fill:before{content:"\\f59d"}.bi-suit-heart:before{content:"\\f59e"}.bi-suit-spade-fill:before{content:"\\f59f"}.bi-suit-spade:before{content:"\\f5a0"}.bi-sun-fill:before{content:"\\f5a1"}.bi-sun:before{content:"\\f5a2"}.bi-sunglasses:before{content:"\\f5a3"}.bi-sunrise-fill:before{content:"\\f5a4"}.bi-sunrise:before{content:"\\f5a5"}.bi-sunset-fill:before{content:"\\f5a6"}.bi-sunset:before{content:"\\f5a7"}.bi-symmetry-horizontal:before{content:"\\f5a8"}.bi-symmetry-vertical:before{content:"\\f5a9"}.bi-table:before{content:"\\f5aa"}.bi-tablet-fill:before{content:"\\f5ab"}.bi-tablet-landscape-fill:before{content:"\\f5ac"}.bi-tablet-landscape:before{content:"\\f5ad"}.bi-tablet:before{content:"\\f5ae"}.bi-tag-fill:before{content:"\\f5af"}.bi-tag:before{content:"\\f5b0"}.bi-tags-fill:before{content:"\\f5b1"}.bi-tags:before{content:"\\f5b2"}.bi-telegram:before{content:"\\f5b3"}.bi-telephone-fill:before{content:"\\f5b4"}.bi-telephone-forward-fill:before{content:"\\f5b5"}.bi-telephone-forward:before{content:"\\f5b6"}.bi-telephone-inbound-fill:before{content:"\\f5b7"}.bi-telephone-inbound:before{content:"\\f5b8"}.bi-telephone-minus-fill:before{content:"\\f5b9"}.bi-telephone-minus:before{content:"\\f5ba"}.bi-telephone-outbound-fill:before{content:"\\f5bb"}.bi-telephone-outbound:before{content:"\\f5bc"}.bi-telephone-plus-fill:before{content:"\\f5bd"}.bi-telephone-plus:before{content:"\\f5be"}.bi-telephone-x-fill:before{content:"\\f5bf"}.bi-telephone-x:before{content:"\\f5c0"}.bi-telephone:before{content:"\\f5c1"}.bi-terminal-fill:before{content:"\\f5c2"}.bi-terminal:before{content:"\\f5c3"}.bi-text-center:before{content:"\\f5c4"}.bi-text-indent-left:before{content:"\\f5c5"}.bi-text-indent-right:before{content:"\\f5c6"}.bi-text-left:before{content:"\\f5c7"}.bi-text-paragraph:before{content:"\\f5c8"}.bi-text-right:before{content:"\\f5c9"}.bi-textarea-resize:before{content:"\\f5ca"}.bi-textarea-t:before{content:"\\f5cb"}.bi-textarea:before{content:"\\f5cc"}.bi-thermometer-half:before{content:"\\f5cd"}.bi-thermometer-high:before{content:"\\f5ce"}.bi-thermometer-low:before{content:"\\f5cf"}.bi-thermometer-snow:before{content:"\\f5d0"}.bi-thermometer-sun:before{content:"\\f5d1"}.bi-thermometer:before{content:"\\f5d2"}.bi-three-dots-vertical:before{content:"\\f5d3"}.bi-three-dots:before{content:"\\f5d4"}.bi-toggle-off:before{content:"\\f5d5"}.bi-toggle-on:before{content:"\\f5d6"}.bi-toggle2-off:before{content:"\\f5d7"}.bi-toggle2-on:before{content:"\\f5d8"}.bi-toggles:before{content:"\\f5d9"}.bi-toggles2:before{content:"\\f5da"}.bi-tools:before{content:"\\f5db"}.bi-tornado:before{content:"\\f5dc"}.bi-trash-fill:before{content:"\\f5dd"}.bi-trash:before{content:"\\f5de"}.bi-trash2-fill:before{content:"\\f5df"}.bi-trash2:before{content:"\\f5e0"}.bi-tree-fill:before{content:"\\f5e1"}.bi-tree:before{content:"\\f5e2"}.bi-triangle-fill:before{content:"\\f5e3"}.bi-triangle-half:before{content:"\\f5e4"}.bi-triangle:before{content:"\\f5e5"}.bi-trophy-fill:before{content:"\\f5e6"}.bi-trophy:before{content:"\\f5e7"}.bi-tropical-storm:before{content:"\\f5e8"}.bi-truck-flatbed:before{content:"\\f5e9"}.bi-truck:before{content:"\\f5ea"}.bi-tsunami:before{content:"\\f5eb"}.bi-tv-fill:before{content:"\\f5ec"}.bi-tv:before{content:"\\f5ed"}.bi-twitch:before{content:"\\f5ee"}.bi-twitter:before{content:"\\f5ef"}.bi-type-bold:before{content:"\\f5f0"}.bi-type-h1:before{content:"\\f5f1"}.bi-type-h2:before{content:"\\f5f2"}.bi-type-h3:before{content:"\\f5f3"}.bi-type-italic:before{content:"\\f5f4"}.bi-type-strikethrough:before{content:"\\f5f5"}.bi-type-underline:before{content:"\\f5f6"}.bi-type:before{content:"\\f5f7"}.bi-ui-checks-grid:before{content:"\\f5f8"}.bi-ui-checks:before{content:"\\f5f9"}.bi-ui-radios-grid:before{content:"\\f5fa"}.bi-ui-radios:before{content:"\\f5fb"}.bi-umbrella-fill:before{content:"\\f5fc"}.bi-umbrella:before{content:"\\f5fd"}.bi-union:before{content:"\\f5fe"}.bi-unlock-fill:before{content:"\\f5ff"}.bi-unlock:before{content:"\\f600"}.bi-upc-scan:before{content:"\\f601"}.bi-upc:before{content:"\\f602"}.bi-upload:before{content:"\\f603"}.bi-vector-pen:before{content:"\\f604"}.bi-view-list:before{content:"\\f605"}.bi-view-stacked:before{content:"\\f606"}.bi-vinyl-fill:before{content:"\\f607"}.bi-vinyl:before{content:"\\f608"}.bi-voicemail:before{content:"\\f609"}.bi-volume-down-fill:before{content:"\\f60a"}.bi-volume-down:before{content:"\\f60b"}.bi-volume-mute-fill:before{content:"\\f60c"}.bi-volume-mute:before{content:"\\f60d"}.bi-volume-off-fill:before{content:"\\f60e"}.bi-volume-off:before{content:"\\f60f"}.bi-volume-up-fill:before{content:"\\f610"}.bi-volume-up:before{content:"\\f611"}.bi-vr:before{content:"\\f612"}.bi-wallet-fill:before{content:"\\f613"}.bi-wallet:before{content:"\\f614"}.bi-wallet2:before{content:"\\f615"}.bi-watch:before{content:"\\f616"}.bi-water:before{content:"\\f617"}.bi-whatsapp:before{content:"\\f618"}.bi-wifi-1:before{content:"\\f619"}.bi-wifi-2:before{content:"\\f61a"}.bi-wifi-off:before{content:"\\f61b"}.bi-wifi:before{content:"\\f61c"}.bi-wind:before{content:"\\f61d"}.bi-window-dock:before{content:"\\f61e"}.bi-window-sidebar:before{content:"\\f61f"}.bi-window:before{content:"\\f620"}.bi-wrench:before{content:"\\f621"}.bi-x-circle-fill:before{content:"\\f622"}.bi-x-circle:before{content:"\\f623"}.bi-x-diamond-fill:before{content:"\\f624"}.bi-x-diamond:before{content:"\\f625"}.bi-x-octagon-fill:before{content:"\\f626"}.bi-x-octagon:before{content:"\\f627"}.bi-x-square-fill:before{content:"\\f628"}.bi-x-square:before{content:"\\f629"}.bi-x:before{content:"\\f62a"}.bi-youtube:before{content:"\\f62b"}.bi-zoom-in:before{content:"\\f62c"}.bi-zoom-out:before{content:"\\f62d"}.bi-bank:before{content:"\\f62e"}.bi-bank2:before{content:"\\f62f"}.bi-bell-slash-fill:before{content:"\\f630"}.bi-bell-slash:before{content:"\\f631"}.bi-cash-coin:before{content:"\\f632"}.bi-check-lg:before{content:"\\f633"}.bi-coin:before{content:"\\f634"}.bi-currency-bitcoin:before{content:"\\f635"}.bi-currency-dollar:before{content:"\\f636"}.bi-currency-euro:before{content:"\\f637"}.bi-currency-exchange:before{content:"\\f638"}.bi-currency-pound:before{content:"\\f639"}.bi-currency-yen:before{content:"\\f63a"}.bi-dash-lg:before{content:"\\f63b"}.bi-exclamation-lg:before{content:"\\f63c"}.bi-file-earmark-pdf-fill:before{content:"\\f63d"}.bi-file-earmark-pdf:before{content:"\\f63e"}.bi-file-pdf-fill:before{content:"\\f63f"}.bi-file-pdf:before{content:"\\f640"}.bi-gender-ambiguous:before{content:"\\f641"}.bi-gender-female:before{content:"\\f642"}.bi-gender-male:before{content:"\\f643"}.bi-gender-trans:before{content:"\\f644"}.bi-headset-vr:before{content:"\\f645"}.bi-info-lg:before{content:"\\f646"}.bi-mastodon:before{content:"\\f647"}.bi-messenger:before{content:"\\f648"}.bi-piggy-bank-fill:before{content:"\\f649"}.bi-piggy-bank:before{content:"\\f64a"}.bi-pin-map-fill:before{content:"\\f64b"}.bi-pin-map:before{content:"\\f64c"}.bi-plus-lg:before{content:"\\f64d"}.bi-question-lg:before{content:"\\f64e"}.bi-recycle:before{content:"\\f64f"}.bi-reddit:before{content:"\\f650"}.bi-safe-fill:before{content:"\\f651"}.bi-safe2-fill:before{content:"\\f652"}.bi-safe2:before{content:"\\f653"}.bi-sd-card-fill:before{content:"\\f654"}.bi-sd-card:before{content:"\\f655"}.bi-skype:before{content:"\\f656"}.bi-slash-lg:before{content:"\\f657"}.bi-translate:before{content:"\\f658"}.bi-x-lg:before{content:"\\f659"}.bi-safe:before{content:"\\f65a"}.bi-apple:before{content:"\\f65b"}.bi-microsoft:before{content:"\\f65d"}.bi-windows:before{content:"\\f65e"}.bi-behance:before{content:"\\f65c"}.bi-dribbble:before{content:"\\f65f"}.bi-line:before{content:"\\f660"}.bi-medium:before{content:"\\f661"}.bi-paypal:before{content:"\\f662"}.bi-pinterest:before{content:"\\f663"}.bi-signal:before{content:"\\f664"}.bi-snapchat:before{content:"\\f665"}.bi-spotify:before{content:"\\f666"}.bi-stack-overflow:before{content:"\\f667"}.bi-strava:before{content:"\\f668"}.bi-wordpress:before{content:"\\f669"}.bi-vimeo:before{content:"\\f66a"}.bi-activity:before{content:"\\f66b"}.bi-easel2-fill:before{content:"\\f66c"}.bi-easel2:before{content:"\\f66d"}.bi-easel3-fill:before{content:"\\f66e"}.bi-easel3:before{content:"\\f66f"}.bi-fan:before{content:"\\f670"}.bi-fingerprint:before{content:"\\f671"}.bi-graph-down-arrow:before{content:"\\f672"}.bi-graph-up-arrow:before{content:"\\f673"}.bi-hypnotize:before{content:"\\f674"}.bi-magic:before{content:"\\f675"}.bi-person-rolodex:before{content:"\\f676"}.bi-person-video:before{content:"\\f677"}.bi-person-video2:before{content:"\\f678"}.bi-person-video3:before{content:"\\f679"}.bi-person-workspace:before{content:"\\f67a"}.bi-radioactive:before{content:"\\f67b"}.bi-webcam-fill:before{content:"\\f67c"}.bi-webcam:before{content:"\\f67d"}.bi-yin-yang:before{content:"\\f67e"}.bi-bandaid-fill:before{content:"\\f680"}.bi-bandaid:before{content:"\\f681"}.bi-bluetooth:before{content:"\\f682"}.bi-body-text:before{content:"\\f683"}.bi-boombox:before{content:"\\f684"}.bi-boxes:before{content:"\\f685"}.bi-dpad-fill:before{content:"\\f686"}.bi-dpad:before{content:"\\f687"}.bi-ear-fill:before{content:"\\f688"}.bi-ear:before{content:"\\f689"}.bi-envelope-check-fill:before{content:"\\f68b"}.bi-envelope-check:before{content:"\\f68c"}.bi-envelope-dash-fill:before{content:"\\f68e"}.bi-envelope-dash:before{content:"\\f68f"}.bi-envelope-exclamation-fill:before{content:"\\f691"}.bi-envelope-exclamation:before{content:"\\f692"}.bi-envelope-plus-fill:before{content:"\\f693"}.bi-envelope-plus:before{content:"\\f694"}.bi-envelope-slash-fill:before{content:"\\f696"}.bi-envelope-slash:before{content:"\\f697"}.bi-envelope-x-fill:before{content:"\\f699"}.bi-envelope-x:before{content:"\\f69a"}.bi-explicit-fill:before{content:"\\f69b"}.bi-explicit:before{content:"\\f69c"}.bi-git:before{content:"\\f69d"}.bi-infinity:before{content:"\\f69e"}.bi-list-columns-reverse:before{content:"\\f69f"}.bi-list-columns:before{content:"\\f6a0"}.bi-meta:before{content:"\\f6a1"}.bi-nintendo-switch:before{content:"\\f6a4"}.bi-pc-display-horizontal:before{content:"\\f6a5"}.bi-pc-display:before{content:"\\f6a6"}.bi-pc-horizontal:before{content:"\\f6a7"}.bi-pc:before{content:"\\f6a8"}.bi-playstation:before{content:"\\f6a9"}.bi-plus-slash-minus:before{content:"\\f6aa"}.bi-projector-fill:before{content:"\\f6ab"}.bi-projector:before{content:"\\f6ac"}.bi-qr-code-scan:before{content:"\\f6ad"}.bi-qr-code:before{content:"\\f6ae"}.bi-quora:before{content:"\\f6af"}.bi-quote:before{content:"\\f6b0"}.bi-robot:before{content:"\\f6b1"}.bi-send-check-fill:before{content:"\\f6b2"}.bi-send-check:before{content:"\\f6b3"}.bi-send-dash-fill:before{content:"\\f6b4"}.bi-send-dash:before{content:"\\f6b5"}.bi-send-exclamation-fill:before{content:"\\f6b7"}.bi-send-exclamation:before{content:"\\f6b8"}.bi-send-fill:before{content:"\\f6b9"}.bi-send-plus-fill:before{content:"\\f6ba"}.bi-send-plus:before{content:"\\f6bb"}.bi-send-slash-fill:before{content:"\\f6bc"}.bi-send-slash:before{content:"\\f6bd"}.bi-send-x-fill:before{content:"\\f6be"}.bi-send-x:before{content:"\\f6bf"}.bi-send:before{content:"\\f6c0"}.bi-steam:before{content:"\\f6c1"}.bi-terminal-dash:before{content:"\\f6c3"}.bi-terminal-plus:before{content:"\\f6c4"}.bi-terminal-split:before{content:"\\f6c5"}.bi-ticket-detailed-fill:before{content:"\\f6c6"}.bi-ticket-detailed:before{content:"\\f6c7"}.bi-ticket-fill:before{content:"\\f6c8"}.bi-ticket-perforated-fill:before{content:"\\f6c9"}.bi-ticket-perforated:before{content:"\\f6ca"}.bi-ticket:before{content:"\\f6cb"}.bi-tiktok:before{content:"\\f6cc"}.bi-window-dash:before{content:"\\f6cd"}.bi-window-desktop:before{content:"\\f6ce"}.bi-window-fullscreen:before{content:"\\f6cf"}.bi-window-plus:before{content:"\\f6d0"}.bi-window-split:before{content:"\\f6d1"}.bi-window-stack:before{content:"\\f6d2"}.bi-window-x:before{content:"\\f6d3"}.bi-xbox:before{content:"\\f6d4"}.bi-ethernet:before{content:"\\f6d5"}.bi-hdmi-fill:before{content:"\\f6d6"}.bi-hdmi:before{content:"\\f6d7"}.bi-usb-c-fill:before{content:"\\f6d8"}.bi-usb-c:before{content:"\\f6d9"}.bi-usb-fill:before{content:"\\f6da"}.bi-usb-plug-fill:before{content:"\\f6db"}.bi-usb-plug:before{content:"\\f6dc"}.bi-usb-symbol:before{content:"\\f6dd"}.bi-usb:before{content:"\\f6de"}.bi-boombox-fill:before{content:"\\f6df"}.bi-displayport:before{content:"\\f6e1"}.bi-gpu-card:before{content:"\\f6e2"}.bi-memory:before{content:"\\f6e3"}.bi-modem-fill:before{content:"\\f6e4"}.bi-modem:before{content:"\\f6e5"}.bi-motherboard-fill:before{content:"\\f6e6"}.bi-motherboard:before{content:"\\f6e7"}.bi-optical-audio-fill:before{content:"\\f6e8"}.bi-optical-audio:before{content:"\\f6e9"}.bi-pci-card:before{content:"\\f6ea"}.bi-router-fill:before{content:"\\f6eb"}.bi-router:before{content:"\\f6ec"}.bi-thunderbolt-fill:before{content:"\\f6ef"}.bi-thunderbolt:before{content:"\\f6f0"}.bi-usb-drive-fill:before{content:"\\f6f1"}.bi-usb-drive:before{content:"\\f6f2"}.bi-usb-micro-fill:before{content:"\\f6f3"}.bi-usb-micro:before{content:"\\f6f4"}.bi-usb-mini-fill:before{content:"\\f6f5"}.bi-usb-mini:before{content:"\\f6f6"}.bi-cloud-haze2:before{content:"\\f6f7"}.bi-device-hdd-fill:before{content:"\\f6f8"}.bi-device-hdd:before{content:"\\f6f9"}.bi-device-ssd-fill:before{content:"\\f6fa"}.bi-device-ssd:before{content:"\\f6fb"}.bi-displayport-fill:before{content:"\\f6fc"}.bi-mortarboard-fill:before{content:"\\f6fd"}.bi-mortarboard:before{content:"\\f6fe"}.bi-terminal-x:before{content:"\\f6ff"}.bi-arrow-through-heart-fill:before{content:"\\f700"}.bi-arrow-through-heart:before{content:"\\f701"}.bi-badge-sd-fill:before{content:"\\f702"}.bi-badge-sd:before{content:"\\f703"}.bi-bag-heart-fill:before{content:"\\f704"}.bi-bag-heart:before{content:"\\f705"}.bi-balloon-fill:before{content:"\\f706"}.bi-balloon-heart-fill:before{content:"\\f707"}.bi-balloon-heart:before{content:"\\f708"}.bi-balloon:before{content:"\\f709"}.bi-box2-fill:before{content:"\\f70a"}.bi-box2-heart-fill:before{content:"\\f70b"}.bi-box2-heart:before{content:"\\f70c"}.bi-box2:before{content:"\\f70d"}.bi-braces-asterisk:before{content:"\\f70e"}.bi-calendar-heart-fill:before{content:"\\f70f"}.bi-calendar-heart:before{content:"\\f710"}.bi-calendar2-heart-fill:before{content:"\\f711"}.bi-calendar2-heart:before{content:"\\f712"}.bi-chat-heart-fill:before{content:"\\f713"}.bi-chat-heart:before{content:"\\f714"}.bi-chat-left-heart-fill:before{content:"\\f715"}.bi-chat-left-heart:before{content:"\\f716"}.bi-chat-right-heart-fill:before{content:"\\f717"}.bi-chat-right-heart:before{content:"\\f718"}.bi-chat-square-heart-fill:before{content:"\\f719"}.bi-chat-square-heart:before{content:"\\f71a"}.bi-clipboard-check-fill:before{content:"\\f71b"}.bi-clipboard-data-fill:before{content:"\\f71c"}.bi-clipboard-fill:before{content:"\\f71d"}.bi-clipboard-heart-fill:before{content:"\\f71e"}.bi-clipboard-heart:before{content:"\\f71f"}.bi-clipboard-minus-fill:before{content:"\\f720"}.bi-clipboard-plus-fill:before{content:"\\f721"}.bi-clipboard-pulse:before{content:"\\f722"}.bi-clipboard-x-fill:before{content:"\\f723"}.bi-clipboard2-check-fill:before{content:"\\f724"}.bi-clipboard2-check:before{content:"\\f725"}.bi-clipboard2-data-fill:before{content:"\\f726"}.bi-clipboard2-data:before{content:"\\f727"}.bi-clipboard2-fill:before{content:"\\f728"}.bi-clipboard2-heart-fill:before{content:"\\f729"}.bi-clipboard2-heart:before{content:"\\f72a"}.bi-clipboard2-minus-fill:before{content:"\\f72b"}.bi-clipboard2-minus:before{content:"\\f72c"}.bi-clipboard2-plus-fill:before{content:"\\f72d"}.bi-clipboard2-plus:before{content:"\\f72e"}.bi-clipboard2-pulse-fill:before{content:"\\f72f"}.bi-clipboard2-pulse:before{content:"\\f730"}.bi-clipboard2-x-fill:before{content:"\\f731"}.bi-clipboard2-x:before{content:"\\f732"}.bi-clipboard2:before{content:"\\f733"}.bi-emoji-kiss-fill:before{content:"\\f734"}.bi-emoji-kiss:before{content:"\\f735"}.bi-envelope-heart-fill:before{content:"\\f736"}.bi-envelope-heart:before{content:"\\f737"}.bi-envelope-open-heart-fill:before{content:"\\f738"}.bi-envelope-open-heart:before{content:"\\f739"}.bi-envelope-paper-fill:before{content:"\\f73a"}.bi-envelope-paper-heart-fill:before{content:"\\f73b"}.bi-envelope-paper-heart:before{content:"\\f73c"}.bi-envelope-paper:before{content:"\\f73d"}.bi-filetype-aac:before{content:"\\f73e"}.bi-filetype-ai:before{content:"\\f73f"}.bi-filetype-bmp:before{content:"\\f740"}.bi-filetype-cs:before{content:"\\f741"}.bi-filetype-css:before{content:"\\f742"}.bi-filetype-csv:before{content:"\\f743"}.bi-filetype-doc:before{content:"\\f744"}.bi-filetype-docx:before{content:"\\f745"}.bi-filetype-exe:before{content:"\\f746"}.bi-filetype-gif:before{content:"\\f747"}.bi-filetype-heic:before{content:"\\f748"}.bi-filetype-html:before{content:"\\f749"}.bi-filetype-java:before{content:"\\f74a"}.bi-filetype-jpg:before{content:"\\f74b"}.bi-filetype-js:before{content:"\\f74c"}.bi-filetype-jsx:before{content:"\\f74d"}.bi-filetype-key:before{content:"\\f74e"}.bi-filetype-m4p:before{content:"\\f74f"}.bi-filetype-md:before{content:"\\f750"}.bi-filetype-mdx:before{content:"\\f751"}.bi-filetype-mov:before{content:"\\f752"}.bi-filetype-mp3:before{content:"\\f753"}.bi-filetype-mp4:before{content:"\\f754"}.bi-filetype-otf:before{content:"\\f755"}.bi-filetype-pdf:before{content:"\\f756"}.bi-filetype-php:before{content:"\\f757"}.bi-filetype-png:before{content:"\\f758"}.bi-filetype-ppt:before{content:"\\f75a"}.bi-filetype-psd:before{content:"\\f75b"}.bi-filetype-py:before{content:"\\f75c"}.bi-filetype-raw:before{content:"\\f75d"}.bi-filetype-rb:before{content:"\\f75e"}.bi-filetype-sass:before{content:"\\f75f"}.bi-filetype-scss:before{content:"\\f760"}.bi-filetype-sh:before{content:"\\f761"}.bi-filetype-svg:before{content:"\\f762"}.bi-filetype-tiff:before{content:"\\f763"}.bi-filetype-tsx:before{content:"\\f764"}.bi-filetype-ttf:before{content:"\\f765"}.bi-filetype-txt:before{content:"\\f766"}.bi-filetype-wav:before{content:"\\f767"}.bi-filetype-woff:before{content:"\\f768"}.bi-filetype-xls:before{content:"\\f76a"}.bi-filetype-xml:before{content:"\\f76b"}.bi-filetype-yml:before{content:"\\f76c"}.bi-heart-arrow:before{content:"\\f76d"}.bi-heart-pulse-fill:before{content:"\\f76e"}.bi-heart-pulse:before{content:"\\f76f"}.bi-heartbreak-fill:before{content:"\\f770"}.bi-heartbreak:before{content:"\\f771"}.bi-hearts:before{content:"\\f772"}.bi-hospital-fill:before{content:"\\f773"}.bi-hospital:before{content:"\\f774"}.bi-house-heart-fill:before{content:"\\f775"}.bi-house-heart:before{content:"\\f776"}.bi-incognito:before{content:"\\f777"}.bi-magnet-fill:before{content:"\\f778"}.bi-magnet:before{content:"\\f779"}.bi-person-heart:before{content:"\\f77a"}.bi-person-hearts:before{content:"\\f77b"}.bi-phone-flip:before{content:"\\f77c"}.bi-plugin:before{content:"\\f77d"}.bi-postage-fill:before{content:"\\f77e"}.bi-postage-heart-fill:before{content:"\\f77f"}.bi-postage-heart:before{content:"\\f780"}.bi-postage:before{content:"\\f781"}.bi-postcard-fill:before{content:"\\f782"}.bi-postcard-heart-fill:before{content:"\\f783"}.bi-postcard-heart:before{content:"\\f784"}.bi-postcard:before{content:"\\f785"}.bi-search-heart-fill:before{content:"\\f786"}.bi-search-heart:before{content:"\\f787"}.bi-sliders2-vertical:before{content:"\\f788"}.bi-sliders2:before{content:"\\f789"}.bi-trash3-fill:before{content:"\\f78a"}.bi-trash3:before{content:"\\f78b"}.bi-valentine:before{content:"\\f78c"}.bi-valentine2:before{content:"\\f78d"}.bi-wrench-adjustable-circle-fill:before{content:"\\f78e"}.bi-wrench-adjustable-circle:before{content:"\\f78f"}.bi-wrench-adjustable:before{content:"\\f790"}.bi-filetype-json:before{content:"\\f791"}.bi-filetype-pptx:before{content:"\\f792"}.bi-filetype-xlsx:before{content:"\\f793"}.bi-1-circle-fill:before{content:"\\f796"}.bi-1-circle:before{content:"\\f797"}.bi-1-square-fill:before{content:"\\f798"}.bi-1-square:before{content:"\\f799"}.bi-2-circle-fill:before{content:"\\f79c"}.bi-2-circle:before{content:"\\f79d"}.bi-2-square-fill:before{content:"\\f79e"}.bi-2-square:before{content:"\\f79f"}.bi-3-circle-fill:before{content:"\\f7a2"}.bi-3-circle:before{content:"\\f7a3"}.bi-3-square-fill:before{content:"\\f7a4"}.bi-3-square:before{content:"\\f7a5"}.bi-4-circle-fill:before{content:"\\f7a8"}.bi-4-circle:before{content:"\\f7a9"}.bi-4-square-fill:before{content:"\\f7aa"}.bi-4-square:before{content:"\\f7ab"}.bi-5-circle-fill:before{content:"\\f7ae"}.bi-5-circle:before{content:"\\f7af"}.bi-5-square-fill:before{content:"\\f7b0"}.bi-5-square:before{content:"\\f7b1"}.bi-6-circle-fill:before{content:"\\f7b4"}.bi-6-circle:before{content:"\\f7b5"}.bi-6-square-fill:before{content:"\\f7b6"}.bi-6-square:before{content:"\\f7b7"}.bi-7-circle-fill:before{content:"\\f7ba"}.bi-7-circle:before{content:"\\f7bb"}.bi-7-square-fill:before{content:"\\f7bc"}.bi-7-square:before{content:"\\f7bd"}.bi-8-circle-fill:before{content:"\\f7c0"}.bi-8-circle:before{content:"\\f7c1"}.bi-8-square-fill:before{content:"\\f7c2"}.bi-8-square:before{content:"\\f7c3"}.bi-9-circle-fill:before{content:"\\f7c6"}.bi-9-circle:before{content:"\\f7c7"}.bi-9-square-fill:before{content:"\\f7c8"}.bi-9-square:before{content:"\\f7c9"}.bi-airplane-engines-fill:before{content:"\\f7ca"}.bi-airplane-engines:before{content:"\\f7cb"}.bi-airplane-fill:before{content:"\\f7cc"}.bi-airplane:before{content:"\\f7cd"}.bi-alexa:before{content:"\\f7ce"}.bi-alipay:before{content:"\\f7cf"}.bi-android:before{content:"\\f7d0"}.bi-android2:before{content:"\\f7d1"}.bi-box-fill:before{content:"\\f7d2"}.bi-box-seam-fill:before{content:"\\f7d3"}.bi-browser-chrome:before{content:"\\f7d4"}.bi-browser-edge:before{content:"\\f7d5"}.bi-browser-firefox:before{content:"\\f7d6"}.bi-browser-safari:before{content:"\\f7d7"}.bi-c-circle-fill:before{content:"\\f7da"}.bi-c-circle:before{content:"\\f7db"}.bi-c-square-fill:before{content:"\\f7dc"}.bi-c-square:before{content:"\\f7dd"}.bi-capsule-pill:before{content:"\\f7de"}.bi-capsule:before{content:"\\f7df"}.bi-car-front-fill:before{content:"\\f7e0"}.bi-car-front:before{content:"\\f7e1"}.bi-cassette-fill:before{content:"\\f7e2"}.bi-cassette:before{content:"\\f7e3"}.bi-cc-circle-fill:before{content:"\\f7e6"}.bi-cc-circle:before{content:"\\f7e7"}.bi-cc-square-fill:before{content:"\\f7e8"}.bi-cc-square:before{content:"\\f7e9"}.bi-cup-hot-fill:before{content:"\\f7ea"}.bi-cup-hot:before{content:"\\f7eb"}.bi-currency-rupee:before{content:"\\f7ec"}.bi-dropbox:before{content:"\\f7ed"}.bi-escape:before{content:"\\f7ee"}.bi-fast-forward-btn-fill:before{content:"\\f7ef"}.bi-fast-forward-btn:before{content:"\\f7f0"}.bi-fast-forward-circle-fill:before{content:"\\f7f1"}.bi-fast-forward-circle:before{content:"\\f7f2"}.bi-fast-forward-fill:before{content:"\\f7f3"}.bi-fast-forward:before{content:"\\f7f4"}.bi-filetype-sql:before{content:"\\f7f5"}.bi-fire:before{content:"\\f7f6"}.bi-google-play:before{content:"\\f7f7"}.bi-h-circle-fill:before{content:"\\f7fa"}.bi-h-circle:before{content:"\\f7fb"}.bi-h-square-fill:before{content:"\\f7fc"}.bi-h-square:before{content:"\\f7fd"}.bi-indent:before{content:"\\f7fe"}.bi-lungs-fill:before{content:"\\f7ff"}.bi-lungs:before{content:"\\f800"}.bi-microsoft-teams:before{content:"\\f801"}.bi-p-circle-fill:before{content:"\\f804"}.bi-p-circle:before{content:"\\f805"}.bi-p-square-fill:before{content:"\\f806"}.bi-p-square:before{content:"\\f807"}.bi-pass-fill:before{content:"\\f808"}.bi-pass:before{content:"\\f809"}.bi-prescription:before{content:"\\f80a"}.bi-prescription2:before{content:"\\f80b"}.bi-r-circle-fill:before{content:"\\f80e"}.bi-r-circle:before{content:"\\f80f"}.bi-r-square-fill:before{content:"\\f810"}.bi-r-square:before{content:"\\f811"}.bi-repeat-1:before{content:"\\f812"}.bi-repeat:before{content:"\\f813"}.bi-rewind-btn-fill:before{content:"\\f814"}.bi-rewind-btn:before{content:"\\f815"}.bi-rewind-circle-fill:before{content:"\\f816"}.bi-rewind-circle:before{content:"\\f817"}.bi-rewind-fill:before{content:"\\f818"}.bi-rewind:before{content:"\\f819"}.bi-train-freight-front-fill:before{content:"\\f81a"}.bi-train-freight-front:before{content:"\\f81b"}.bi-train-front-fill:before{content:"\\f81c"}.bi-train-front:before{content:"\\f81d"}.bi-train-lightrail-front-fill:before{content:"\\f81e"}.bi-train-lightrail-front:before{content:"\\f81f"}.bi-truck-front-fill:before{content:"\\f820"}.bi-truck-front:before{content:"\\f821"}.bi-ubuntu:before{content:"\\f822"}.bi-unindent:before{content:"\\f823"}.bi-unity:before{content:"\\f824"}.bi-universal-access-circle:before{content:"\\f825"}.bi-universal-access:before{content:"\\f826"}.bi-virus:before{content:"\\f827"}.bi-virus2:before{content:"\\f828"}.bi-wechat:before{content:"\\f829"}.bi-yelp:before{content:"\\f82a"}.bi-sign-stop-fill:before{content:"\\f82b"}.bi-sign-stop-lights-fill:before{content:"\\f82c"}.bi-sign-stop-lights:before{content:"\\f82d"}.bi-sign-stop:before{content:"\\f82e"}.bi-sign-turn-left-fill:before{content:"\\f82f"}.bi-sign-turn-left:before{content:"\\f830"}.bi-sign-turn-right-fill:before{content:"\\f831"}.bi-sign-turn-right:before{content:"\\f832"}.bi-sign-turn-slight-left-fill:before{content:"\\f833"}.bi-sign-turn-slight-left:before{content:"\\f834"}.bi-sign-turn-slight-right-fill:before{content:"\\f835"}.bi-sign-turn-slight-right:before{content:"\\f836"}.bi-sign-yield-fill:before{content:"\\f837"}.bi-sign-yield:before{content:"\\f838"}.bi-ev-station-fill:before{content:"\\f839"}.bi-ev-station:before{content:"\\f83a"}.bi-fuel-pump-diesel-fill:before{content:"\\f83b"}.bi-fuel-pump-diesel:before{content:"\\f83c"}.bi-fuel-pump-fill:before{content:"\\f83d"}.bi-fuel-pump:before{content:"\\f83e"}.bi-0-circle-fill:before{content:"\\f83f"}.bi-0-circle:before{content:"\\f840"}.bi-0-square-fill:before{content:"\\f841"}.bi-0-square:before{content:"\\f842"}.bi-rocket-fill:before{content:"\\f843"}.bi-rocket-takeoff-fill:before{content:"\\f844"}.bi-rocket-takeoff:before{content:"\\f845"}.bi-rocket:before{content:"\\f846"}.bi-stripe:before{content:"\\f847"}.bi-subscript:before{content:"\\f848"}.bi-superscript:before{content:"\\f849"}.bi-trello:before{content:"\\f84a"}.bi-envelope-at-fill:before{content:"\\f84b"}.bi-envelope-at:before{content:"\\f84c"}.bi-regex:before{content:"\\f84d"}.bi-text-wrap:before{content:"\\f84e"}.bi-sign-dead-end-fill:before{content:"\\f84f"}.bi-sign-dead-end:before{content:"\\f850"}.bi-sign-do-not-enter-fill:before{content:"\\f851"}.bi-sign-do-not-enter:before{content:"\\f852"}.bi-sign-intersection-fill:before{content:"\\f853"}.bi-sign-intersection-side-fill:before{content:"\\f854"}.bi-sign-intersection-side:before{content:"\\f855"}.bi-sign-intersection-t-fill:before{content:"\\f856"}.bi-sign-intersection-t:before{content:"\\f857"}.bi-sign-intersection-y-fill:before{content:"\\f858"}.bi-sign-intersection-y:before{content:"\\f859"}.bi-sign-intersection:before{content:"\\f85a"}.bi-sign-merge-left-fill:before{content:"\\f85b"}.bi-sign-merge-left:before{content:"\\f85c"}.bi-sign-merge-right-fill:before{content:"\\f85d"}.bi-sign-merge-right:before{content:"\\f85e"}.bi-sign-no-left-turn-fill:before{content:"\\f85f"}.bi-sign-no-left-turn:before{content:"\\f860"}.bi-sign-no-parking-fill:before{content:"\\f861"}.bi-sign-no-parking:before{content:"\\f862"}.bi-sign-no-right-turn-fill:before{content:"\\f863"}.bi-sign-no-right-turn:before{content:"\\f864"}.bi-sign-railroad-fill:before{content:"\\f865"}.bi-sign-railroad:before{content:"\\f866"}.bi-building-add:before{content:"\\f867"}.bi-building-check:before{content:"\\f868"}.bi-building-dash:before{content:"\\f869"}.bi-building-down:before{content:"\\f86a"}.bi-building-exclamation:before{content:"\\f86b"}.bi-building-fill-add:before{content:"\\f86c"}.bi-building-fill-check:before{content:"\\f86d"}.bi-building-fill-dash:before{content:"\\f86e"}.bi-building-fill-down:before{content:"\\f86f"}.bi-building-fill-exclamation:before{content:"\\f870"}.bi-building-fill-gear:before{content:"\\f871"}.bi-building-fill-lock:before{content:"\\f872"}.bi-building-fill-slash:before{content:"\\f873"}.bi-building-fill-up:before{content:"\\f874"}.bi-building-fill-x:before{content:"\\f875"}.bi-building-fill:before{content:"\\f876"}.bi-building-gear:before{content:"\\f877"}.bi-building-lock:before{content:"\\f878"}.bi-building-slash:before{content:"\\f879"}.bi-building-up:before{content:"\\f87a"}.bi-building-x:before{content:"\\f87b"}.bi-buildings-fill:before{content:"\\f87c"}.bi-buildings:before{content:"\\f87d"}.bi-bus-front-fill:before{content:"\\f87e"}.bi-bus-front:before{content:"\\f87f"}.bi-ev-front-fill:before{content:"\\f880"}.bi-ev-front:before{content:"\\f881"}.bi-globe-americas:before{content:"\\f882"}.bi-globe-asia-australia:before{content:"\\f883"}.bi-globe-central-south-asia:before{content:"\\f884"}.bi-globe-europe-africa:before{content:"\\f885"}.bi-house-add-fill:before{content:"\\f886"}.bi-house-add:before{content:"\\f887"}.bi-house-check-fill:before{content:"\\f888"}.bi-house-check:before{content:"\\f889"}.bi-house-dash-fill:before{content:"\\f88a"}.bi-house-dash:before{content:"\\f88b"}.bi-house-down-fill:before{content:"\\f88c"}.bi-house-down:before{content:"\\f88d"}.bi-house-exclamation-fill:before{content:"\\f88e"}.bi-house-exclamation:before{content:"\\f88f"}.bi-house-gear-fill:before{content:"\\f890"}.bi-house-gear:before{content:"\\f891"}.bi-house-lock-fill:before{content:"\\f892"}.bi-house-lock:before{content:"\\f893"}.bi-house-slash-fill:before{content:"\\f894"}.bi-house-slash:before{content:"\\f895"}.bi-house-up-fill:before{content:"\\f896"}.bi-house-up:before{content:"\\f897"}.bi-house-x-fill:before{content:"\\f898"}.bi-house-x:before{content:"\\f899"}.bi-person-add:before{content:"\\f89a"}.bi-person-down:before{content:"\\f89b"}.bi-person-exclamation:before{content:"\\f89c"}.bi-person-fill-add:before{content:"\\f89d"}.bi-person-fill-check:before{content:"\\f89e"}.bi-person-fill-dash:before{content:"\\f89f"}.bi-person-fill-down:before{content:"\\f8a0"}.bi-person-fill-exclamation:before{content:"\\f8a1"}.bi-person-fill-gear:before{content:"\\f8a2"}.bi-person-fill-lock:before{content:"\\f8a3"}.bi-person-fill-slash:before{content:"\\f8a4"}.bi-person-fill-up:before{content:"\\f8a5"}.bi-person-fill-x:before{content:"\\f8a6"}.bi-person-gear:before{content:"\\f8a7"}.bi-person-lock:before{content:"\\f8a8"}.bi-person-slash:before{content:"\\f8a9"}.bi-person-up:before{content:"\\f8aa"}.bi-scooter:before{content:"\\f8ab"}.bi-taxi-front-fill:before{content:"\\f8ac"}.bi-taxi-front:before{content:"\\f8ad"}.bi-amd:before{content:"\\f8ae"}.bi-database-add:before{content:"\\f8af"}.bi-database-check:before{content:"\\f8b0"}.bi-database-dash:before{content:"\\f8b1"}.bi-database-down:before{content:"\\f8b2"}.bi-database-exclamation:before{content:"\\f8b3"}.bi-database-fill-add:before{content:"\\f8b4"}.bi-database-fill-check:before{content:"\\f8b5"}.bi-database-fill-dash:before{content:"\\f8b6"}.bi-database-fill-down:before{content:"\\f8b7"}.bi-database-fill-exclamation:before{content:"\\f8b8"}.bi-database-fill-gear:before{content:"\\f8b9"}.bi-database-fill-lock:before{content:"\\f8ba"}.bi-database-fill-slash:before{content:"\\f8bb"}.bi-database-fill-up:before{content:"\\f8bc"}.bi-database-fill-x:before{content:"\\f8bd"}.bi-database-fill:before{content:"\\f8be"}.bi-database-gear:before{content:"\\f8bf"}.bi-database-lock:before{content:"\\f8c0"}.bi-database-slash:before{content:"\\f8c1"}.bi-database-up:before{content:"\\f8c2"}.bi-database-x:before{content:"\\f8c3"}.bi-database:before{content:"\\f8c4"}.bi-houses-fill:before{content:"\\f8c5"}.bi-houses:before{content:"\\f8c6"}.bi-nvidia:before{content:"\\f8c7"}.bi-person-vcard-fill:before{content:"\\f8c8"}.bi-person-vcard:before{content:"\\f8c9"}.bi-sina-weibo:before{content:"\\f8ca"}.bi-tencent-qq:before{content:"\\f8cb"}.bi-wikipedia:before{content:"\\f8cc"}.bi-alphabet-uppercase:before{content:"\\f2a5"}.bi-alphabet:before{content:"\\f68a"}.bi-amazon:before{content:"\\f68d"}.bi-arrows-collapse-vertical:before{content:"\\f690"}.bi-arrows-expand-vertical:before{content:"\\f695"}.bi-arrows-vertical:before{content:"\\f698"}.bi-arrows:before{content:"\\f6a2"}.bi-ban-fill:before{content:"\\f6a3"}.bi-ban:before{content:"\\f6b6"}.bi-bing:before{content:"\\f6c2"}.bi-cake:before{content:"\\f6e0"}.bi-cake2:before{content:"\\f6ed"}.bi-cookie:before{content:"\\f6ee"}.bi-copy:before{content:"\\f759"}.bi-crosshair:before{content:"\\f769"}.bi-crosshair2:before{content:"\\f794"}.bi-emoji-astonished-fill:before{content:"\\f795"}.bi-emoji-astonished:before{content:"\\f79a"}.bi-emoji-grimace-fill:before{content:"\\f79b"}.bi-emoji-grimace:before{content:"\\f7a0"}.bi-emoji-grin-fill:before{content:"\\f7a1"}.bi-emoji-grin:before{content:"\\f7a6"}.bi-emoji-surprise-fill:before{content:"\\f7a7"}.bi-emoji-surprise:before{content:"\\f7ac"}.bi-emoji-tear-fill:before{content:"\\f7ad"}.bi-emoji-tear:before{content:"\\f7b2"}.bi-envelope-arrow-down-fill:before{content:"\\f7b3"}.bi-envelope-arrow-down:before{content:"\\f7b8"}.bi-envelope-arrow-up-fill:before{content:"\\f7b9"}.bi-envelope-arrow-up:before{content:"\\f7be"}.bi-feather:before{content:"\\f7bf"}.bi-feather2:before{content:"\\f7c4"}.bi-floppy-fill:before{content:"\\f7c5"}.bi-floppy:before{content:"\\f7d8"}.bi-floppy2-fill:before{content:"\\f7d9"}.bi-floppy2:before{content:"\\f7e4"}.bi-gitlab:before{content:"\\f7e5"}.bi-highlighter:before{content:"\\f7f8"}.bi-marker-tip:before{content:"\\f802"}.bi-nvme-fill:before{content:"\\f803"}.bi-nvme:before{content:"\\f80c"}.bi-opencollective:before{content:"\\f80d"}.bi-pci-card-network:before{content:"\\f8cd"}.bi-pci-card-sound:before{content:"\\f8ce"}.bi-radar:before{content:"\\f8cf"}.bi-send-arrow-down-fill:before{content:"\\f8d0"}.bi-send-arrow-down:before{content:"\\f8d1"}.bi-send-arrow-up-fill:before{content:"\\f8d2"}.bi-send-arrow-up:before{content:"\\f8d3"}.bi-sim-slash-fill:before{content:"\\f8d4"}.bi-sim-slash:before{content:"\\f8d5"}.bi-sourceforge:before{content:"\\f8d6"}.bi-substack:before{content:"\\f8d7"}.bi-threads-fill:before{content:"\\f8d8"}.bi-threads:before{content:"\\f8d9"}.bi-transparency:before{content:"\\f8da"}.bi-twitter-x:before{content:"\\f8db"}.bi-type-h4:before{content:"\\f8dc"}.bi-type-h5:before{content:"\\f8dd"}.bi-type-h6:before{content:"\\f8de"}.bi-backpack-fill:before{content:"\\f8df"}.bi-backpack:before{content:"\\f8e0"}.bi-backpack2-fill:before{content:"\\f8e1"}.bi-backpack2:before{content:"\\f8e2"}.bi-backpack3-fill:before{content:"\\f8e3"}.bi-backpack3:before{content:"\\f8e4"}.bi-backpack4-fill:before{content:"\\f8e5"}.bi-backpack4:before{content:"\\f8e6"}.bi-brilliance:before{content:"\\f8e7"}.bi-cake-fill:before{content:"\\f8e8"}.bi-cake2-fill:before{content:"\\f8e9"}.bi-duffle-fill:before{content:"\\f8ea"}.bi-duffle:before{content:"\\f8eb"}.bi-exposure:before{content:"\\f8ec"}.bi-gender-neuter:before{content:"\\f8ed"}.bi-highlights:before{content:"\\f8ee"}.bi-luggage-fill:before{content:"\\f8ef"}.bi-luggage:before{content:"\\f8f0"}.bi-mailbox-flag:before{content:"\\f8f1"}.bi-mailbox2-flag:before{content:"\\f8f2"}.bi-noise-reduction:before{content:"\\f8f3"}.bi-passport-fill:before{content:"\\f8f4"}.bi-passport:before{content:"\\f8f5"}.bi-person-arms-up:before{content:"\\f8f6"}.bi-person-raised-hand:before{content:"\\f8f7"}.bi-person-standing-dress:before{content:"\\f8f8"}.bi-person-standing:before{content:"\\f8f9"}.bi-person-walking:before{content:"\\f8fa"}.bi-person-wheelchair:before{content:"\\f8fb"}.bi-shadows:before{content:"\\f8fc"}.bi-suitcase-fill:before{content:"\\f8fd"}.bi-suitcase-lg-fill:before{content:"\\f8fe"}.bi-suitcase-lg:before{content:"\\f8ff"}.bi-suitcase:before{content:"\\f900"}.bi-suitcase2-fill:before{content:"\\f901"}.bi-suitcase2:before{content:"\\f902"}.bi-vignette:before{content:"\\f903"}foreignObject.loci{box-sizing:border-box;border-radius:.375rem;position:relative;display:block}foreignObject.loci div.foreground{position:relative;display:flex;height:100%;width:100%;justify-content:center;align-items:center;box-sizing:inherit;border-radius:inherit;border-width:1px;border-style:solid;opacity:1}foreignObject.loci div.background{position:absolute;left:0;top:0;display:block;height:100%;width:100%;opacity:.3}foreignObject.pins div.foreground{position:relative;display:flex;height:100%;width:100%;justify-content:center;align-items:flex-end;box-sizing:border-box}foreignObject.dssp div.foreground{position:relative;display:flex;height:100%;width:100%;justify-content:center;align-items:flex-end;box-sizing:border-box}foreignObject.dssp i[class^=dssp]{position:relative;visibility:hidden;display:flex;height:100%;width:100%}foreignObject.dssp i.dssp-helix{visibility:visible;background-color:inherit;-webkit-mask-image:url(dssp-helix.74d0a47e4d7ed27e.svg);mask-image:url(dssp-helix.74d0a47e4d7ed27e.svg);-webkit-mask-position:0 center;mask-position:0 center;-webkit-mask-size:auto 100%;mask-size:auto 100%}foreignObject.dssp i.dssp-strand{display:flex;visibility:hidden}foreignObject.dssp i.dssp-strand:before{visibility:visible;background-color:inherit;-webkit-mask-image:url(dssp-strand-tail.783864b28823e2c7.svg);mask-image:url(dssp-strand-tail.783864b28823e2c7.svg);-webkit-mask-position:0 center;mask-position:0 center;-webkit-mask-size:auto 100%;mask-size:auto 100%;flex-shrink:1;flex-grow:1;content:""}foreignObject.dssp i.dssp-strand:after{visibility:visible;background-color:inherit;-webkit-mask-image:url(dssp-strand-head.85a295955fb4c220.svg);mask-image:url(dssp-strand-head.85a295955fb4c220.svg);-webkit-mask-position:0 center;mask-position:0 center;-webkit-mask-size:auto 100%;mask-size:auto 100%;flex-shrink:0;flex-grow:0;content:"";width:31px}.axis-grid line{stroke-opacity:.3;stroke:gray}.axis-grid line:nth-child(1){stroke-dasharray:2}.y.axis .tick text{display:none}\n'],encapsulation:2})}return e})();const Axt={providers:[function MPe(e,...t){return Iy([{provide:Bb,multi:!0,useValue:e},[],{provide:Mb,useFactory:yZ,deps:[Kl]},{provide:LA,multi:!0,useFactory:bZ},t.map(n=>n.\u0275providers)])}([{path:"structure",component:Lyt},{path:"feature",component:(()=>{class e{constructor(){this.settings={"line-height":24,"content-size":16,"background-color":"transparent","trace-color":"pink","grid-color":"white","margin-top":24,"margin-right":24,"margin-bottom":24,"margin-left":128},this.sequence=["M","E","E","P","Q"],this.features=[{label:"Feature #1",type:"continuous",values:[1.2,2.7,5.4,2.8,3.7]},{label:"Feature #2",type:"loci",values:[{start:1,end:3},{start:4,end:5}]},{label:"Feature #3",type:"trace",position:"overlap",values:[{type:"loci",values:[{start:3,end:5}]},{type:"loci",values:[{start:1,end:4}]},{type:"continuous",values:[3.2,1.1,.7,.9,2.2]}]},{label:"Feature #4",type:"loci",values:[{start:1,end:2},{start:3,end:4}],nested:[{label:"Feature #5",type:"trace",values:[{type:"loci",values:[{start:1,end:1},{start:2,end:5}]},{type:"loci",values:[{start:2,end:4}]}]},{label:"Feature #6",type:"continuous",values:[.2,1.1,3.7,2.8,2.9]}]}]}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["page-features-viewer"]],standalone:!0,features:[Nu],decls:14,vars:3,consts:[[1,"container","pt-3"],[1,"mb-3"],[1,"d-flex","flex-row","gap-3","mb-3"],[2,"display","block","width","1rem","height","1rem","background","black","font-size","1rem","line-height","1rem"],[2,"display","block","width","1rem","height","auto","background","black","color","white","font-size","1rem","line-height",".5rem"],[2,"display","block","width","auto","height","1rem","background","black","color","white","font-size","1rem","line-height","1rem"],[2,"display","block","height","auto","width","100%"],[3,"sequence","features","settings"]],template:function(r,i){1&r&&(dn(0,"div",0)(1,"div",1)(2,"h1"),ar(3,"Feature viewer"),fn(),dn(4,"p"),ar(5," The feature viewer allows you to represent features on a reference seqeunce... "),fn()(),dn(6,"div",2),gi(7,"div",3),dn(8,"div",4),ar(9,"W"),fn(),dn(10,"div",5),ar(11,"W"),fn()(),dn(12,"div",6),gi(13,"ngx-features-viewer",7),fn()()),2&r&&(mi(13),Bh("sequence",i.sequence)("features",i.features)("settings",i.settings))},dependencies:[Uh,wxt],changeDetection:0})}return e})()},{path:"",component:(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["page-home"]],standalone:!0,features:[Nu],decls:48,vars:0,consts:[[1,"container","pt-3"],[1,"row"],[1,"col-12"],[1,"mb-3"],[1,"row","align-items-stretch","mb-3"],[1,"col-4"],["routerLink","/structure",1,"product-card","rounded","bg-body-tertiary","p-3","mb-3"],[1,"bi","bi-boxes","me-3"],["src","assets/structure-viewer.png","alt","Structure viewer",1,"w-100","h-auto","mb-3"],[1,"text-justify","mb-3"],[1,"text-center","mt-auto"],[1,"badge","rounded-pill","text-bg-warning"],[1,"bi","bi-chevron-right"],[1,"col-4","product"],["routerLink","/feature",1,"product-card","rounded","bg-body-tertiary","p-3","mb-3"],[1,"bi","bi-sliders"],["routerLink","/sequence",1,"product-card","rounded","bg-body-tertiary","p-3","mb-3"],[1,"bi","bi-body-text"],[1,"rounded","bg-body-tertiary","shadow-sm","p-3","mb-3"],[1,"bi","bi-share-fill"]],template:function(r,i){1&r&&(dn(0,"div",0)(1,"div",1)(2,"div",2)(3,"h1",3),ar(4,"Products"),fn()()(),dn(5,"div",4)(6,"div",5)(7,"div",6)(8,"h2"),gi(9,"i",7),ar(10," Structure viewer "),fn(),gi(11,"img",8),dn(12,"p",9),ar(13," Visualize and interact with 3D molecular structures. Provides Mol* functionalities out-of-the-box for Angular developers. "),fn(),dn(14,"div",10)(15,"span",11),ar(16," Try it out "),gi(17,"i",12),fn()()()(),dn(18,"div",13)(19,"div",14)(20,"h2"),gi(21,"i",15),ar(22," Feature viewer "),fn(),dn(23,"p",3),ar(24," The feature viewer is a powerful tool designed for visualizing features of biological sequences, such as proteins, DNA, or RNA. It provides a comprehensive set of functionalities to explore and analyze these sequences. With the feature viewer, users can easily identify and visualize various features, including structural elements, functional domains, mutations, and more. It offers a user-friendly interface with intuitive gestures and actions, allowing users to zoom in and out, pan across the sequence, highlight specific regions, and perform interactive selections. Whether you are a biologist, bioinformatician, or researcher, the feature viewer is an indispensable tool for gaining insights into the intricate details of biological sequences. "),fn(),dn(25,"div",10)(26,"span",11),ar(27," Try it out "),gi(28,"i",12),fn()()()(),dn(29,"div",5)(30,"div",16)(31,"h2"),gi(32,"i",17),ar(33," Sequence viewer "),fn(),dn(34,"p",3),ar(35," The sequence viewer is a specialized tool designed for visualizing multiple sequence alignments and other features across protein sequences. It provides a comprehensive view of the similarities and differences between multiple protein sequences, allowing users to easily identify conserved regions, mutations, and other important features. The sequence viewer supports various display options, enabling users to customize the view according to their needs. It also allows for interactive exploration, with features such as zooming and panning, highlighting specific regions, and hovering over specific points for more detailed information. This makes the sequence viewer an essential tool for bioinformaticians and researchers studying protein sequences and their relationships. "),fn(),dn(36,"div",10)(37,"span",11),ar(38," Try it out "),gi(39,"i",12),fn()()()()(),dn(40,"div",1)(41,"div",2)(42,"div",18)(43,"h2"),gi(44,"i",19),ar(45," Enhanced interactivity"),fn(),dn(46,"p"),ar(47," Our components are designed starting from the same, generic data structures. This is meant to easily wire up various compoents in the same page. Hence, implementing interactivity out-of-the-box "),fn()()()()())},dependencies:[Uh,jF,EI],styles:[".product-card[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:nowrap;height:100%;width:100%;cursor:pointer;box-shadow:0 .125rem .25rem #00000013}.product-card[_ngcontent-%COMP%]:hover{box-shadow:0 .5rem 1rem #00000026}"]})}return e})()},{path:"**",redirectTo:""}])]};(function hDe(e,t){return DAe({rootComponent:e,...YX(t)})})((()=>{class e{constructor(){this.title="ngx-bio-tools",this.sequence="MLPGLALLLLAAWTARALEVPTDGNAGLLAEPQIAMFCGRLNMHMNVQNGKWDSDPSGTKTCIDTKEGILQYCQEVYPELQITNVVEANQPVTIQNWCKRGRKQCKTHPHFVIPYRCLVGEFVSDALLVPDKCKFLHQERMDVCETHLHWHTVAKETCSEKSTNLHDYGMLLPCGIDKFRGVEFVCCPLAEESDNVDSADAEEDDSDVWWGGADTDYADGSEDKVVEVAEEEEVAEVEEEEADDDEDDEDGDEVEEEAEEPYEEATERTTSIATTTTTTTESVEEVVREVCSEQAETGPCRAMISRWYFDVTEGKCAPFFYGGCGGNRNNFDTEEYCMAVCGSAMSQSLLKTTQEPLARDPVKLPTTAASTPDAVDKYLETPGDENEHAHFQKAKERLEAKHRERMSQVMREWEEAERQAKNLPKADKKAVIQHFQEKVESLEQEAANERQQLVETHMARVEAMLNDRRRLALENYITALQAVPPRPRHVFNMLKKYVRAEQKDRQHTLKHFEHVRMVDPKKAAQIRSQVMTHLRVIYERMNQSLSLLYNVPAVAEEIQDEVDELLQKEQNYSDDVLANMISEPRISYGNDALMPSLTETKTTVELLPVNGEFSLDDLQPWHSFGADSVPANTENEVEPVDARPAADRGLTTRPGSGLTNIKTEEISEVKMDAEFRHDSGYEVHHQKLVFFAEDVGSNKGAIIGLMVGGVVIATVIVITLVMLKKKQYTSIHHGVVEVDAAVTPEERHLSKMQQNGYENPTYKFFEQMQN".split(""),this.features=[{id:0,type:"continuous",color:"blue",values:this.sequence.map(()=>Math.random()),parent:void 0,height:128},{id:1,type:"loci",color:"red",values:[{start:1,end:3},{start:5,end:6}],parent:void 0,height:96},{id:2,type:"pins",color:"green",values:[{start:5},{start:100,color:"blue"},{start:400,color:"red"}],parent:1},{id:3,type:"loci",color:"orange",values:[{start:10,end:20},{start:30,end:70}],parent:1},{id:4,type:"loci",color:"purple",values:[{start:100,end:300}],parent:void 0},{id:5,type:"dssp",color:"black",values:[{start:30,end:90,code:"H",color:"orange"},{start:120,end:300,code:"E",color:"purple"}],parent:void 0}]}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["app-root"]],standalone:!0,features:[Nu],decls:17,vars:0,consts:[[1,"navbar"],[1,"container-fluid"],["href","#",1,"navbar-brand"],["src","assets/ngx-biocomp-up-white.svg","alt","ngx-biocomp-up","height","32",1,"d-inline-block","align-text-top"],[1,"container-fluid","bg-dark","pt-2","pb-2"],[1,"row"],[1,"col-3","d-flex","justify-content-start"],["src","assets/biocomp.svg","alt","BioComputing UP","height","36"],[1,"col-6","d-flex","align-items-center","justify-content-center"],["href","https://github.com/damiclem",1,"text-light","small"],[1,"bi","bi-github"],[1,"col-3","d-flex","justify-content-end"],["src","assets/unipd.svg","alt","University of Padua","height","36"]],template:function(r,i){1&r&&(dn(0,"header")(1,"nav",0)(2,"div",1)(3,"a",2),gi(4,"img",3),fn()()()(),dn(5,"main"),gi(6,"router-outlet"),fn(),dn(7,"footer",4)(8,"div",5)(9,"div",6),gi(10,"img",7),fn(),dn(11,"div",8)(12,"a",9),ar(13," Developed by Damiano Clementel "),gi(14,"i",10),fn()(),dn(15,"div",11),gi(16,"img",12),fn()()())},dependencies:[Uh,jF,RF],styles:["[_nghost-%COMP%]{height:inherit;display:inherit;flex-direction:inherit}"]})}return e})(),Axt).catch(e=>console.error(e))},684:n_=>{n_.exports=XMLHttpRequest}},n_=>{n_(n_.s=540)}]); \ No newline at end of file +(self.webpackChunkdemo_showcase=self.webpackChunkdemo_showcase||[]).push([[792],{540:(r_,nG,Fn)=>{"use strict";var i_={};Fn.r(i_),Fn.d(i_,{atomicHet:()=>SOe,atomicSequence:()=>_Oe,bundleElementImpl:()=>FJ,bundleGenerator:()=>BJ,defaultBondTest:()=>XB,spheres:()=>COe,water:()=>xOe});var OP={};Fn.r(OP),Fn.d(OP,{all:()=>UJ,atoms:()=>QB,bondedAtomicPairs:()=>kOe,chains:()=>IOe,none:()=>ZB,querySelection:()=>ROe,residues:()=>AOe,rings:()=>MOe});var LP={};Fn.r(LP),Fn.d(LP,{exceptBy:()=>m5e,expandProperty:()=>y5e,includeConnected:()=>b5e,includeSurroundings:()=>f5e,intersectBy:()=>h5e,querySelection:()=>p5e,surroundingLigands:()=>_5e,union:()=>g5e,wholeResidues:()=>u5e});var UP={};Fn.r(UP),Fn.d(UP,{areIntersectedBy:()=>R5e,first:()=>E5e,getCurrentStructureProperties:()=>DT,isConnectedTo:()=>L5e,pick:()=>D5e,withSameAtomProperties:()=>M5e,within:()=>k5e});var VP={};Fn.r(VP),Fn.d(VP,{intersect:()=>V5e,merge:()=>U5e});var zP={};Fn.r(zP),Fn.d(zP,{atomCount:()=>z5e,countQuery:()=>G5e,propertySet:()=>j5e});var GP={};Fn.r(GP),Fn.d(GP,{Download:()=>sre,DownloadBlob:()=>are,ImportJson:()=>Fze,ImportString:()=>Nze,LazyVolume:()=>Oze,ParseBlob:()=>wze,ParseCcp4:()=>Mze,ParseCif:()=>Aze,ParseCube:()=>Ize,ParseDsn6:()=>Rze,ParseDx:()=>kze,ParseJson:()=>Bze,ParsePly:()=>Pze,ParsePrmtop:()=>Dze,ParsePsf:()=>Tze,ParseTop:()=>Eze,RawData:()=>cre,ReadFile:()=>ure});var jP={};Fn.r(jP),Fn.d(jP,{CreateGroup:()=>Lze});var HP={};Fn.r(HP),Fn.d(HP,{CoordinatesFromDcd:()=>vXe,CoordinatesFromNctraj:()=>SXe,CoordinatesFromTrr:()=>xXe,CoordinatesFromXtc:()=>_Xe,CustomModelProperties:()=>Koe,CustomStructureProperties:()=>Qoe,ModelFromTrajectory:()=>qoe,MultiStructureSelectionFromExpression:()=>jXe,ShapeFromPly:()=>XXe,StructureComplexElement:()=>$Xe,StructureComplexElementTypes:()=>Xoe,StructureComponent:()=>YXe,StructureFromModel:()=>VXe,StructureFromTrajectory:()=>UXe,StructureSelectionFromBundle:()=>qXe,StructureSelectionFromExpression:()=>GXe,StructureSelectionFromScript:()=>HXe,TopologyFromPrmtop:()=>wXe,TopologyFromPsf:()=>CXe,TopologyFromTop:()=>AXe,TrajectoryFromBlob:()=>TXe,TrajectoryFromCifCore:()=>BXe,TrajectoryFromCube:()=>FXe,TrajectoryFromGRO:()=>PXe,TrajectoryFromMOL:()=>RXe,TrajectoryFromMOL2:()=>NXe,TrajectoryFromMmCif:()=>DXe,TrajectoryFromModelAndCoordinates:()=>A6,TrajectoryFromPDB:()=>EXe,TrajectoryFromSDF:()=>kXe,TrajectoryFromXYZ:()=>MXe,TransformStructureConformation:()=>zXe});var qP={};Fn.r(qP),Fn.d(qP,{AssignColorVolume:()=>cKe,VolumeFromCcp4:()=>nKe,VolumeFromCube:()=>iKe,VolumeFromDensityServerCif:()=>sKe,VolumeFromDsn6:()=>rKe,VolumeFromDx:()=>oKe,VolumeFromSegmentationCif:()=>aKe});var WP={};Fn.r(WP),Fn.d(WP,{BoxShape3D:()=>Fet,getBoxMesh:()=>m8});var $P={};Fn.r($P),Fn.d($P,{ClippingStructureRepresentation3DFromBundle:()=>Jet,ClippingStructureRepresentation3DFromScript:()=>Qet,ExplodeStructureRepresentation3D:()=>Het,ModelUnitcell3D:()=>rtt,OverpaintStructureRepresentation3DFromBundle:()=>$et,OverpaintStructureRepresentation3DFromScript:()=>Wet,ShapeRepresentation3D:()=>ntt,SpinStructureRepresentation3D:()=>qet,StructureBoundingBox3D:()=>itt,StructureRepresentation3D:()=>yE,StructureSelectionsAngle3D:()=>stt,StructureSelectionsDihedral3D:()=>att,StructureSelectionsDistance3D:()=>ott,StructureSelectionsLabel3D:()=>ctt,StructureSelectionsOrientation3D:()=>utt,StructureSelectionsPlane3D:()=>ltt,SubstanceStructureRepresentation3DFromBundle:()=>Zet,SubstanceStructureRepresentation3DFromScript:()=>Ket,ThemeStrengthRepresentation3D:()=>ett,TransparencyStructureRepresentation3DFromBundle:()=>Xet,TransparencyStructureRepresentation3DFromScript:()=>Yet,UnwindStructureAssemblyRepresentation3D:()=>jet,VolumeRepresentation3D:()=>ttt,VolumeRepresentation3DHelpers:()=>Af});var YP={};Fn.r(YP),Fn.d(YP,{ApplyAction:()=>Vce,ClearHighlights:()=>qce,Highlight:()=>Hce,RemoveObject:()=>zce,SetCurrentObject:()=>Lce,Snapshots:()=>Wce,SyncBehaviors:()=>Oce,ToggleExpanded:()=>Gce,ToggleVisibility:()=>jce,Update:()=>Uce,registerDefault:()=>Ttt,setSubtreeVisibility:()=>Wv});var XP={};Fn.r(XP),Fn.d(XP,{SyncRepresentationToCanvas:()=>$ce,SyncStructureRepresentation3DState:()=>Yce,UpdateRepresentationVisibility:()=>Xce,registerDefault:()=>Ett});var KP={};Fn.r(KP),Fn.d(KP,{Focus:()=>Qce,OrientAxes:()=>Jce,Reset:()=>Kce,ResetAxes:()=>eue,SetSnapshot:()=>Zce,registerDefault:()=>Ptt});var ZP={};Fn.r(ZP),Fn.d(ZP,{Canvas3DSetSettings:()=>Zue,registerDefault:()=>Nit});var QP={};Fn.r(QP),Fn.d(QP,{DefaultFocusLociBindings:()=>Jue,DefaultLociLabelProvider:()=>Vit,DefaultSelectLociBindings:()=>Que,FocusLoci:()=>Git,HighlightLoci:()=>Oit,SelectLoci:()=>Uit});var JP={};Fn.r(JP),Fn.d(JP,{CameraAxisHelper:()=>qit,CameraControls:()=>$it,DefaultClickResetCameraOnEmpty:()=>q8,DefaultClickResetCameraOnEmptySelectMode:()=>W8,DefaultFocusLociBindings:()=>ele,FocusLoci:()=>Hit});var eM={};Fn.r(eM),Fn.d(eM,{AccessibleSurfaceArea:()=>rot,BestDatabaseSequenceMapping:()=>gct,CrossLinkRestraint:()=>Rct,Interactions:()=>dct,SecondaryStructure:()=>fct,StructureInfo:()=>Yit,ValenceModel:()=>pct});var tM={};Fn.r(tM),Fn.d(tM,{AddTrajectory:()=>gut,DownloadStructure:()=>uut,EnableModelCustomProps:()=>hut,EnableStructureCustomProps:()=>mut,LoadTrajectory:()=>yut,PdbDownloadProvider:()=>Dde,UpdateTrajectory:()=>put});var nM={};Fn.r(nM),Fn.d(nM,{AssignColorVolume:()=>Ede,DownloadDensity:()=>but});var rM={};function rG(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(u){return void n(u)}a.done?t(c):Promise.resolve(c).then(r,i)}function ie(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function s(c){rG(o,r,i,s,a,"next",c)}function a(c){rG(o,r,i,s,a,"throw",c)}s(void 0)})}}Fn.r(rM),Fn.d(rM,{DownloadFile:()=>vut,OpenFiles:()=>Pde});let xs=null,KC=1;const tg=Symbol("SIGNAL");function sr(e){const t=xs;return xs=e,t}function iG(e){if((!s_(e)||e.dirty)&&(e.dirty||e.lastCleanEpoch!==KC)){if(!e.producerMustRecompute(e)&&!oM(e))return e.dirty=!1,void(e.lastCleanEpoch=KC);e.producerRecomputeValue(e),e.dirty=!1,e.lastCleanEpoch=KC}}function oM(e){gy(e);for(let t=0;t0}function gy(e){e.producerNode??=[],e.producerIndexOfThis??=[],e.producerLastReadVersion??=[]}let pG=null;function Wi(e){return"function"==typeof e}function aM(e){const n=e(r=>{Error.call(r),r.stack=(new Error).stack});return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}const cM=aM(e=>function(n){e(this),this.message=n?`${n.length} errors occurred during unsubscription:\n${n.map((r,i)=>`${i+1}) ${r.toString()}`).join("\n ")}`:"",this.name="UnsubscriptionError",this.errors=n});function QC(e,t){if(e){const n=e.indexOf(t);0<=n&&e.splice(n,1)}}class Fa{constructor(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}unsubscribe(){let t;if(!this.closed){this.closed=!0;const{_parentage:n}=this;if(n)if(this._parentage=null,Array.isArray(n))for(const o of n)o.remove(this);else n.remove(this);const{initialTeardown:r}=this;if(Wi(r))try{r()}catch(o){t=o instanceof cM?o.errors:[o]}const{_finalizers:i}=this;if(i){this._finalizers=null;for(const o of i)try{bG(o)}catch(s){t=t??[],s instanceof cM?t=[...t,...s.errors]:t.push(s)}}if(t)throw new cM(t)}}add(t){var n;if(t&&t!==this)if(this.closed)bG(t);else{if(t instanceof Fa){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}}_hasParent(t){const{_parentage:n}=this;return n===t||Array.isArray(n)&&n.includes(t)}_addParent(t){const{_parentage:n}=this;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t}_removeParent(t){const{_parentage:n}=this;n===t?this._parentage=null:Array.isArray(n)&&QC(n,t)}remove(t){const{_finalizers:n}=this;n&&QC(n,t),t instanceof Fa&&t._removeParent(this)}}Fa.EMPTY=(()=>{const e=new Fa;return e.closed=!0,e})();const gG=Fa.EMPTY;function yG(e){return e instanceof Fa||e&&"closed"in e&&Wi(e.remove)&&Wi(e.add)&&Wi(e.unsubscribe)}function bG(e){Wi(e)?e():e.unsubscribe()}const ng={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},JC={setTimeout(e,t,...n){const{delegate:r}=JC;return r?.setTimeout?r.setTimeout(e,t,...n):setTimeout(e,t,...n)},clearTimeout(e){const{delegate:t}=JC;return(t?.clearTimeout||clearTimeout)(e)},delegate:void 0};function vG(e){JC.setTimeout(()=>{const{onUnhandledError:t}=ng;if(!t)throw e;t(e)})}function uM(){}const y0e=lM("C",void 0,void 0);function lM(e,t,n){return{kind:e,value:t,error:n}}let rg=null;function ew(e){if(ng.useDeprecatedSynchronousErrorHandling){const t=!rg;if(t&&(rg={errorThrown:!1,error:null}),e(),t){const{errorThrown:n,error:r}=rg;if(rg=null,n)throw r}}else e()}class dM extends Fa{constructor(t){super(),this.isStopped=!1,t?(this.destination=t,yG(t)&&t.add(this)):this.destination=w0e}static create(t,n,r){return new a_(t,n,r)}next(t){this.isStopped?pM(function v0e(e){return lM("N",e,void 0)}(t),this):this._next(t)}error(t){this.isStopped?pM(function b0e(e){return lM("E",void 0,e)}(t),this):(this.isStopped=!0,this._error(t))}complete(){this.isStopped?pM(y0e,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()}}}const x0e=Function.prototype.bind;function fM(e,t){return x0e.call(e,t)}class S0e{constructor(t){this.partialObserver=t}next(t){const{partialObserver:n}=this;if(n.next)try{n.next(t)}catch(r){tw(r)}}error(t){const{partialObserver:n}=this;if(n.error)try{n.error(t)}catch(r){tw(r)}else tw(t)}complete(){const{partialObserver:t}=this;if(t.complete)try{t.complete()}catch(n){tw(n)}}}class a_ extends dM{constructor(t,n,r){let i;if(super(),Wi(t)||!t)i={next:t??void 0,error:n??void 0,complete:r??void 0};else{let o;this&&ng.useDeprecatedNextContext?(o=Object.create(t),o.unsubscribe=()=>this.unsubscribe(),i={next:t.next&&fM(t.next,o),error:t.error&&fM(t.error,o),complete:t.complete&&fM(t.complete,o)}):i=t}this.destination=new S0e(i)}}function tw(e){ng.useDeprecatedSynchronousErrorHandling?function _0e(e){ng.useDeprecatedSynchronousErrorHandling&&rg&&(rg.errorThrown=!0,rg.error=e)}(e):vG(e)}function pM(e,t){const{onStoppedNotification:n}=ng;n&&JC.setTimeout(()=>n(e,t))}const w0e={closed:!0,next:uM,error:function C0e(e){throw e},complete:uM},hM="function"==typeof Symbol&&Symbol.observable||"@@observable";function vh(e){return e}function _G(...e){return xG(e)}function xG(e){return 0===e.length?vh:1===e.length?e[0]:function(n){return e.reduce((r,i)=>i(r),n)}}let ns=(()=>{class e{constructor(n){n&&(this._subscribe=n)}lift(n){const r=new e;return r.source=this,r.operator=n,r}subscribe(n,r,i){const o=function I0e(e){return e&&e instanceof dM||function A0e(e){return e&&Wi(e.next)&&Wi(e.error)&&Wi(e.complete)}(e)&&yG(e)}(n)?n:new a_(n,r,i);return ew(()=>{const{operator:s,source:a}=this;o.add(s?s.call(o,a):a?this._subscribe(o):this._trySubscribe(o))}),o}_trySubscribe(n){try{return this._subscribe(n)}catch(r){n.error(r)}}forEach(n,r){return new(r=SG(r))((i,o)=>{const s=new a_({next:a=>{try{n(a)}catch(c){o(c),s.unsubscribe()}},error:o,complete:i});this.subscribe(s)})}_subscribe(n){var r;return null===(r=this.source)||void 0===r?void 0:r.subscribe(n)}[hM](){return this}pipe(...n){return xG(n)(this)}toPromise(n){return new(n=SG(n))((r,i)=>{let o;this.subscribe(s=>o=s,s=>i(s),()=>r(o))})}}return e.create=t=>new e(t),e})();function SG(e){var t;return null!==(t=e??ng.Promise)&&void 0!==t?t:Promise}const T0e=aM(e=>function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"});let mr=(()=>{class e extends ns{constructor(){super(),this.closed=!1,this.currentObservers=null,this.observers=[],this.isStopped=!1,this.hasError=!1,this.thrownError=null}lift(n){const r=new CG(this,this);return r.operator=n,r}_throwIfClosed(){if(this.closed)throw new T0e}next(n){ew(()=>{if(this._throwIfClosed(),!this.isStopped){this.currentObservers||(this.currentObservers=Array.from(this.observers));for(const r of this.currentObservers)r.next(n)}})}error(n){ew(()=>{if(this._throwIfClosed(),!this.isStopped){this.hasError=this.isStopped=!0,this.thrownError=n;const{observers:r}=this;for(;r.length;)r.shift().error(n)}})}complete(){ew(()=>{if(this._throwIfClosed(),!this.isStopped){this.isStopped=!0;const{observers:n}=this;for(;n.length;)n.shift().complete()}})}unsubscribe(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null}get observed(){var n;return(null===(n=this.observers)||void 0===n?void 0:n.length)>0}_trySubscribe(n){return this._throwIfClosed(),super._trySubscribe(n)}_subscribe(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)}_innerSubscribe(n){const{hasError:r,isStopped:i,observers:o}=this;return r||i?gG:(this.currentObservers=null,o.push(n),new Fa(()=>{this.currentObservers=null,QC(o,n)}))}_checkFinalizedStatuses(n){const{hasError:r,thrownError:i,isStopped:o}=this;r?n.error(i):o&&n.complete()}asObservable(){const n=new ns;return n.source=this,n}}return e.create=(t,n)=>new CG(t,n),e})();class CG extends mr{constructor(t,n){super(),this.destination=t,this.source=n}next(t){var n,r;null===(r=null===(n=this.destination)||void 0===n?void 0:n.next)||void 0===r||r.call(n,t)}error(t){var n,r;null===(r=null===(n=this.destination)||void 0===n?void 0:n.error)||void 0===r||r.call(n,t)}complete(){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===n||n.call(t)}_subscribe(t){var n,r;return null!==(r=null===(n=this.source)||void 0===n?void 0:n.subscribe(t))&&void 0!==r?r:gG}}class Ao extends mr{constructor(t){super(),this._value=t}get value(){return this.getValue()}_subscribe(t){const n=super._subscribe(t);return!n.closed&&t.next(this._value),n}getValue(){const{hasError:t,thrownError:n,_value:r}=this;if(t)throw n;return this._throwIfClosed(),r}next(t){super.next(this._value=t)}}function wG(e){return Wi(e?.lift)}function mo(e){return t=>{if(wG(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function Io(e,t,n,r,i){return new D0e(e,t,n,r,i)}class D0e extends dM{constructor(t,n,r,i,o,s){super(t),this.onFinalize=o,this.shouldUnsubscribe=s,this._next=n?function(a){try{n(a)}catch(c){t.error(c)}}:super._next,this._error=i?function(a){try{i(a)}catch(c){t.error(c)}finally{this.unsubscribe()}}:super._error,this._complete=r?function(){try{r()}catch(a){t.error(a)}finally{this.unsubscribe()}}:super._complete}unsubscribe(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){const{closed:n}=this;super.unsubscribe(),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}}}function qt(e,t){return mo((n,r)=>{let i=0;n.subscribe(Io(r,o=>{r.next(e.call(t,o,i++))}))})}const AG="https://g.co/ng/security#xss";class It extends Error{constructor(t,n){super(function yy(e,t){return`NG0${Math.abs(e)}${t?": "+t:""}`}(t,n)),this.code=t}}function jf(e){return{toString:e}.toString()}const vy="__parameters__";function xy(e,t,n){return jf(()=>{const r=function mM(e){return function(...n){if(e){const r=e(...n);for(const i in r)this[i]=r[i]}}}(t);function i(...o){if(this instanceof i)return r.apply(this,o),this;const s=new i(...o);return a.annotation=s,a;function a(c,u,l){const d=c.hasOwnProperty(vy)?c[vy]:Object.defineProperty(c,vy,{value:[]})[vy];for(;d.length<=l;)d.push(null);return(d[l]=d[l]||[]).push(s),c}}return n&&(i.prototype=Object.create(n.prototype)),i.prototype.ngMetadataName=e,i.annotationCls=i,i})}const si=globalThis;function pi(e){for(let t in e)if(e[t]===pi)return t;throw Error("Could not find renamed property on target object.")}function Ss(e){if("string"==typeof e)return e;if(Array.isArray(e))return"["+e.map(Ss).join(", ")+"]";if(null==e)return""+e;if(e.overriddenName)return`${e.overriddenName}`;if(e.name)return`${e.name}`;const t=e.toString();if(null==t)return""+t;const n=t.indexOf("\n");return-1===n?t:t.substring(0,n)}function gM(e,t){return null==e||""===e?null===t?"":t:null==t||""===t?e:e+" "+t}const P0e=pi({__forward_ref__:pi});function yM(e){return e.__forward_ref__=yM,e.toString=function(){return Ss(this())},e}function En(e){return rw(e)?e():e}function rw(e){return"function"==typeof e&&e.hasOwnProperty(P0e)&&e.__forward_ref__===yM}function Gt(e){return{token:e.token,providedIn:e.providedIn||null,factory:e.factory,value:void 0}}function Sy(e){return{providers:e.providers||[],imports:e.imports||[]}}function iw(e){return EG(e,sw)||EG(e,PG)}function EG(e,t){return e.hasOwnProperty(t)?e[t]:null}function ow(e){return e&&(e.hasOwnProperty(bM)||e.hasOwnProperty(B0e))?e[bM]:null}const sw=pi({\u0275prov:pi}),bM=pi({\u0275inj:pi}),PG=pi({ngInjectableDef:pi}),B0e=pi({ngInjectorDef:pi});class Yt{constructor(t,n){this._desc=t,this.ngMetadataName="InjectionToken",this.\u0275prov=void 0,"number"==typeof n?this.__NG_ELEMENT_ID__=n:void 0!==n&&(this.\u0275prov=Gt({token:this,providedIn:n.providedIn||"root",factory:n.factory}))}get multi(){return this}toString(){return`InjectionToken ${this._desc}`}}function CM(e){return e&&!!e.\u0275providers}const c_=pi({\u0275cmp:pi}),wM=pi({\u0275dir:pi}),AM=pi({\u0275pipe:pi}),RG=pi({\u0275mod:pi}),Hf=pi({\u0275fac:pi}),u_=pi({__NG_ELEMENT_ID__:pi}),kG=pi({__NG_ENV_ID__:pi});function Un(e){return"string"==typeof e?e:null==e?"":String(e)}function IM(e,t){throw new It(-201,!1)}var yr=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}(yr||{});let TM;function NG(){return TM}function bc(e){const t=TM;return TM=e,t}function FG(e,t,n){const r=iw(e);return r&&"root"==r.providedIn?void 0===r.value?r.value=r.factory():r.value:n&yr.Optional?null:void 0!==t?t:void IM()}const l_={},DM="__NG_DI_FLAG__",aw="ngTempTokenPath",G0e=/\n/gm,BG="__source";let Cy;function xh(e){const t=Cy;return Cy=e,t}function q0e(e,t=yr.Default){if(void 0===Cy)throw new It(-203,!1);return null===Cy?FG(e,void 0,t):Cy.get(e,t&yr.Optional?null:void 0,t)}function Zt(e,t=yr.Default){return(NG()||q0e)(En(e),t)}function bt(e,t=yr.Default){return Zt(e,cw(t))}function cw(e){return typeof e>"u"||"number"==typeof e?e:(e.optional&&8)|(e.host&&1)|(e.self&&2)|(e.skipSelf&&4)}function EM(e){const t=[];for(let n=0;nArray.isArray(n)?wy(n,t):t(n))}function LG(e,t,n){t>=e.length?e.push(n):e.splice(t,0,n)}function dw(e,t){return t>=e.length-1?e.pop():e.splice(t,1)[0]}function Xc(e,t,n){let r=Ay(e,t);return r>=0?e[1|r]=n:(r=~r,function UG(e,t,n,r){let i=e.length;if(i==t)e.push(n,r);else if(1===i)e.push(r,e[0]),e[0]=n;else{for(i--,e.push(e[i-1],e[i]);i>t;)e[i]=e[i-2],i--;e[t]=n,e[t+1]=r}}(e,r,t,n)),r}function MM(e,t){const n=Ay(e,t);if(n>=0)return e[1|n]}function Ay(e,t){return function VG(e,t,n){let r=0,i=e.length>>n;for(;i!==r;){const o=r+(i-r>>1),s=e[o<t?i=o:r=o+1}return~(i<t){s=o-1;break}}}for(;o-1){let o;for(;++io?"":i[l+1].toLowerCase(),2&r&&u!==d){if(Ol(r))return!1;s=!0}}}}else{if(!s&&!Ol(r)&&!Ol(c))return!1;if(s&&Ol(c))continue;s=!1,r=c|1&r}}return Ol(r)||s}function Ol(e){return!(1&e)}function rye(e,t,n,r){if(null===t)return-1;let i=0;if(r||!n){let o=!1;for(;i-1)for(n++;n0?'="'+a+'"':"")+"]"}else 8&r?i+="."+s:4&r&&(i+=" "+s);else""!==i&&!Ol(s)&&(t+=$G(o,i),i=""),r=s,o=o||!Ol(r);n++}return""!==i&&(t+=$G(o,i)),t}function Mu(e){return jf(()=>{const t=XG(e),n={...t,decls:e.decls,vars:e.vars,template:e.template,consts:e.consts||null,ngContentSelectors:e.ngContentSelectors,onPush:e.changeDetection===hw.OnPush,directiveDefs:null,pipeDefs:null,dependencies:t.standalone&&e.dependencies||null,getStandaloneInjector:null,signals:e.signals??!1,data:e.data||{},encapsulation:e.encapsulation||Fl.Emulated,styles:e.styles||Vr,_:null,schemas:e.schemas||null,tView:null,id:""};KG(n);const r=e.dependencies;return n.directiveDefs=mw(r,!1),n.pipeDefs=mw(r,!0),n.id=function hye(e){let t=0;const n=[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(const i of n)t=Math.imul(31,t)+i.charCodeAt(0)|0;return t+=2147483648,"c"+t}(n),n})}function dye(e){return dr(e)||Cs(e)}function fye(e){return null!==e}function p_(e){return jf(()=>({type:e.type,bootstrap:e.bootstrap||Vr,declarations:e.declarations||Vr,imports:e.imports||Vr,exports:e.exports||Vr,transitiveCompileScopes:null,schemas:e.schemas||null,id:e.id||null}))}function YG(e,t){if(null==e)return Pd;const n={};for(const r in e)if(e.hasOwnProperty(r)){const i=e[r];let o,s,a=Bl.None;Array.isArray(i)?(a=i[0],o=i[1],s=i[2]??o):(o=i,s=i),t?(n[o]=a!==Bl.None?[r,a]:r,t[o]=s):n[o]=r}return n}function Ba(e){return jf(()=>{const t=XG(e);return KG(t),t})}function _c(e){return{type:e.type,name:e.name,factory:null,pure:!1!==e.pure,standalone:!0===e.standalone,onDestroy:e.type.prototype.ngOnDestroy||null}}function dr(e){return e[c_]||null}function Cs(e){return e[wM]||null}function Qs(e){return e[AM]||null}function sa(e,t){const n=e[RG]||null;if(!n&&!0===t)throw new Error(`Type ${Ss(e)} does not have '\u0275mod' property.`);return n}function XG(e){const 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||Pd,exportAs:e.exportAs||null,standalone:!0===e.standalone,signals:!0===e.signals,selectors:e.selectors||Vr,viewQuery:e.viewQuery||null,features:e.features||null,setInput:null,findHostDirectiveDefs:null,hostDirectives:null,inputs:YG(e.inputs,t),outputs:YG(e.outputs),debugInfo:null}}function KG(e){e.features?.forEach(t=>t(e))}function mw(e,t){if(!e)return null;const n=t?Qs:dye;return()=>("function"==typeof e?e():e).map(r=>n(r)).filter(fye)}function Iy(e){return{\u0275providers:e}}function mye(...e){return{\u0275providers:FM(0,e),\u0275fromNgModule:!0}}function FM(e,...t){const n=[],r=new Set;let i;const o=s=>{n.push(s)};return wy(t,s=>{const a=s;gw(a,o,[],r)&&(i||=[],i.push(a))}),void 0!==i&&ZG(i,o),n}function ZG(e,t){for(let n=0;n{t(o,r)})}}function gw(e,t,n,r){if(!(e=En(e)))return!1;let i=null,o=ow(e);const s=!o&&dr(e);if(o||s){if(s&&!s.standalone)return!1;i=e}else{const c=e.ngModule;if(o=ow(c),!o)return!1;i=c}const a=r.has(i);if(s){if(a)return!1;if(r.add(i),s.dependencies){const c="function"==typeof s.dependencies?s.dependencies():s.dependencies;for(const u of c)gw(u,t,n,r)}}else{if(!o)return!1;{if(null!=o.imports&&!a){let u;r.add(i);try{wy(o.imports,l=>{gw(l,t,n,r)&&(u||=[],u.push(l))})}finally{}void 0!==u&&ZG(u,t)}if(!a){const u=ig(i)||(()=>new i);t({provide:i,useFactory:u,deps:Vr},i),t({provide:RM,useValue:i,multi:!0},i),t({provide:og,useValue:()=>Zt(i),multi:!0},i)}const c=o.providers;if(null!=c&&!a){const u=e;BM(c,l=>{t(l,u)})}}}return i!==e&&void 0!==e.providers}function BM(e,t){for(let n of e)CM(n)&&(n=n.\u0275providers),Array.isArray(n)?BM(n,t):t(n)}const gye=pi({provide:String,useValue:pi});function OM(e){return null!==e&&"object"==typeof e&&gye in e}function sg(e){return"function"==typeof e}const LM=new Yt(""),yw={},bye={};let UM;function bw(){return void 0===UM&&(UM=new pw),UM}class xc{}class Ty extends xc{get destroyed(){return this._destroyed}constructor(t,n,r,i){super(),this.parent=n,this.source=r,this.scopes=i,this.records=new Map,this._ngOnDestroyHooks=new Set,this._onDestroyHooks=[],this._destroyed=!1,zM(t,s=>this.processProvider(s)),this.records.set(zG,Dy(void 0,this)),i.has("environment")&&this.records.set(xc,Dy(void 0,this));const o=this.records.get(LM);null!=o&&"string"==typeof o.value&&this.scopes.add(o.value),this.injectorDefTypes=new Set(this.get(RM,Vr,yr.Self))}destroy(){this.assertNotDestroyed(),this._destroyed=!0;const t=sr(null);try{for(const r of this._ngOnDestroyHooks)r.ngOnDestroy();const n=this._onDestroyHooks;this._onDestroyHooks=[];for(const r of n)r()}finally{this.records.clear(),this._ngOnDestroyHooks.clear(),this.injectorDefTypes.clear(),sr(t)}}onDestroy(t){return this.assertNotDestroyed(),this._onDestroyHooks.push(t),()=>this.removeOnDestroy(t)}runInContext(t){this.assertNotDestroyed();const n=xh(this),r=bc(void 0);try{return t()}finally{xh(n),bc(r)}}get(t,n=l_,r=yr.Default){if(this.assertNotDestroyed(),t.hasOwnProperty(kG))return t[kG](this);r=cw(r);const o=xh(this),s=bc(void 0);try{if(!(r&yr.SkipSelf)){let c=this.records.get(t);if(void 0===c){const u=function Cye(e){return"function"==typeof e||"object"==typeof e&&e instanceof Yt}(t)&&iw(t);c=u&&this.injectableDefInScope(u)?Dy(VM(t),yw):null,this.records.set(t,c)}if(null!=c)return this.hydrate(t,c)}return(r&yr.Self?bw():this.parent).get(t,n=r&yr.Optional&&n===l_?null:n)}catch(a){if("NullInjectorError"===a.name){if((a[aw]=a[aw]||[]).unshift(Ss(t)),o)throw a;return function $0e(e,t,n,r){const i=e[aw];throw t[BG]&&i.unshift(t[BG]),e.message=function Y0e(e,t,n,r=null){e=e&&"\n"===e.charAt(0)&&"\u0275"==e.charAt(1)?e.slice(2):e;let i=Ss(t);if(Array.isArray(t))i=t.map(Ss).join(" -> ");else if("object"==typeof t){let o=[];for(let s in t)if(t.hasOwnProperty(s)){let a=t[s];o.push(s+":"+("string"==typeof a?JSON.stringify(a):Ss(a)))}i=`{${o.join(", ")}}`}return`${n}${r?"("+r+")":""}[${i}]: ${e.replace(G0e,"\n ")}`}("\n"+e.message,i,n,r),e.ngTokenPath=i,e[aw]=null,e}(a,t,"R3InjectorError",this.source)}throw a}finally{bc(s),xh(o)}}resolveInjectorInitializers(){const t=sr(null),n=xh(this),r=bc(void 0);try{const o=this.get(og,Vr,yr.Self);for(const s of o)s()}finally{xh(n),bc(r),sr(t)}}toString(){const t=[],n=this.records;for(const r of n.keys())t.push(Ss(r));return`R3Injector[${t.join(", ")}]`}assertNotDestroyed(){if(this._destroyed)throw new It(205,!1)}processProvider(t){let n=sg(t=En(t))?t:En(t&&t.provide);const r=function _ye(e){return OM(e)?Dy(void 0,e.useValue):Dy(e9(e),yw)}(t);if(!sg(t)&&!0===t.multi){let i=this.records.get(n);i||(i=Dy(void 0,yw,!0),i.factory=()=>EM(i.multi),this.records.set(n,i)),n=t,i.multi.push(t)}this.records.set(n,r)}hydrate(t,n){const r=sr(null);try{return n.value===yw&&(n.value=bye,n.value=n.factory()),"object"==typeof n.value&&n.value&&function Sye(e){return null!==e&&"object"==typeof e&&"function"==typeof e.ngOnDestroy}(n.value)&&this._ngOnDestroyHooks.add(n.value),n.value}finally{sr(r)}}injectableDefInScope(t){if(!t.providedIn)return!1;const n=En(t.providedIn);return"string"==typeof n?"any"===n||this.scopes.has(n):this.injectorDefTypes.has(n)}removeOnDestroy(t){const n=this._onDestroyHooks.indexOf(t);-1!==n&&this._onDestroyHooks.splice(n,1)}}function VM(e){const t=iw(e),n=null!==t?t.factory:ig(e);if(null!==n)return n;if(e instanceof Yt)throw new It(204,!1);if(e instanceof Function)return function vye(e){if(e.length>0)throw new It(204,!1);const n=function F0e(e){return e&&(e[sw]||e[PG])||null}(e);return null!==n?()=>n.factory(e):()=>new e}(e);throw new It(204,!1)}function e9(e,t,n){let r;if(sg(e)){const i=En(e);return ig(i)||VM(i)}if(OM(e))r=()=>En(e.useValue);else if(function JG(e){return!(!e||!e.useFactory)}(e))r=()=>e.useFactory(...EM(e.deps||[]));else if(function QG(e){return!(!e||!e.useExisting)}(e))r=()=>Zt(En(e.useExisting));else{const i=En(e&&(e.useClass||e.provide));if(!function xye(e){return!!e.deps}(e))return ig(i)||VM(i);r=()=>new i(...EM(e.deps))}return r}function Dy(e,t,n=!1){return{factory:e,value:t,multi:n?[]:void 0}}function zM(e,t){for(const n of e)Array.isArray(n)?zM(n,t):n&&CM(n)?zM(n.\u0275providers,t):t(n)}function Md(e,t){e instanceof Ty&&e.assertNotDestroyed();const r=xh(e),i=bc(void 0);try{return t()}finally{xh(r),bc(i)}}function t9(){return void 0!==NG()||null!=function H0e(){return Cy}()}const Ji=0,Mt=1,bn=2,zo=3,Ll=4,aa=5,Kc=6,Py=7,Mi=8,Js=9,Ul=10,Mn=11,m_=12,r9=13,My=14,go=15,g_=16,Ry=17,qf=18,y_=19,i9=20,Ch=21,xw=22,ag=23,Vn=25,jM=1,Rd=7,ky=9,Go=10;var HM=function(e){return e[e.None=0]="None",e[e.HasTransplantedViews=2]="HasTransplantedViews",e}(HM||{});function ca(e){return Array.isArray(e)&&"object"==typeof e[jM]}function ua(e){return Array.isArray(e)&&!0===e[jM]}function qM(e){return!!(4&e.flags)}function cg(e){return e.componentOffset>-1}function Cw(e){return!(1&~e.flags)}function Vl(e){return!!e.template}function WM(e){return!!(512&e[bn])}class Bye{constructor(t,n,r){this.previousValue=t,this.currentValue=n,this.firstChange=r}isFirstChange(){return this.firstChange}}function c9(e,t,n,r){null!==t?t.applyValueToInputSignal(t,r):e[n]=r}function wh(){return u9}function u9(e){return e.type.prototype.ngOnChanges&&(e.setInput=Lye),Oye}function Oye(){const e=d9(this),t=e?.current;if(t){const n=e.previous;if(n===Pd)e.previous=t;else for(let r in t)n[r]=t[r];e.current=null,this.ngOnChanges(t)}}function Lye(e,t,n,r,i){const o=this.declaredInputs[r],s=d9(e)||function Uye(e,t){return e[l9]=t}(e,{previous:Pd,current:null}),a=s.current||(s.current={}),c=s.previous,u=c[o];a[o]=new Bye(u&&u.currentValue,n,c===Pd),c9(e,t,i,n)}wh.ngInherit=!0;const l9="__ngSimpleChanges__";function d9(e){return e[l9]||null}const kd=function(e,t,n){};let h9=!1;function _i(e){for(;Array.isArray(e);)e=e[Ji];return e}function v_(e,t){return _i(t[e])}function Oa(e,t){return _i(t[e.index])}function __(e,t){return e.data[t]}function Zc(e,t){const n=t[e];return ca(n)?n:n[Ji]}function ZM(e){return!(128&~e[bn])}function Nd(e,t){return null==t?null:e[t]}function m9(e){e[Ry]=0}function qye(e){1024&e[bn]||(e[bn]|=1024,ZM(e)&&x_(e))}function QM(e){return!!(9216&e[bn]||e[ag]?.dirty)}function JM(e){e[Ul].changeDetectionScheduler?.notify(1),QM(e)?x_(e):64&e[bn]&&(function zye(){return h9}()?(e[bn]|=1024,x_(e)):e[Ul].changeDetectionScheduler?.notify())}function x_(e){e[Ul].changeDetectionScheduler?.notify();let t=ug(e);for(;null!==t&&!(8192&t[bn])&&(t[bn]|=8192,ZM(t));)t=ug(t)}function ww(e,t){if(!(256&~e[bn]))throw new It(911,!1);null===e[Ch]&&(e[Ch]=[]),e[Ch].push(t)}function ug(e){const t=e[zo];return ua(t)?t[zo]:t}const Rn={lFrame:A9(null),bindingsEnabled:!0,skipHydrationRootTNode:null};function b9(){return Rn.bindingsEnabled}function it(){return Rn.lFrame.lView}function br(){return Rn.lFrame.tView}function hi(){let e=v9();for(;null!==e&&64===e.type;)e=e.parent;return e}function v9(){return Rn.lFrame.currentTNode}function Fd(e,t){const n=Rn.lFrame;n.currentTNode=e,n.isParent=t}function tR(){return Rn.lFrame.isParent}function La(){const e=Rn.lFrame;let t=e.bindingRootIndex;return-1===t&&(t=e.bindingRootIndex=e.tView.bindingStartIndex),t}function zl(){return Rn.lFrame.bindingIndex++}function ibe(e,t){const n=Rn.lFrame;n.bindingIndex=n.bindingRootIndex=e,rR(t)}function rR(e){Rn.lFrame.currentDirectiveIndex=e}function oR(){return Rn.lFrame.currentQueryIndex}function Aw(e){Rn.lFrame.currentQueryIndex=e}function sbe(e){const t=e[Mt];return 2===t.type?t.declTNode:1===t.type?e[aa]:null}function C9(e,t,n){if(n&yr.SkipSelf){let i=t,o=e;for(;!(i=i.parent,null!==i||n&yr.Host||(i=sbe(o),null===i||(o=o[My],10&i.type))););if(null===i)return!1;t=i,e=o}const r=Rn.lFrame=w9();return r.currentTNode=t,r.lView=e,!0}function sR(e){const t=w9(),n=e[Mt];Rn.lFrame=t,t.currentTNode=n.firstChild,t.lView=e,t.tView=n,t.contextLView=e,t.bindingIndex=n.bindingStartIndex,t.inI18n=!1}function w9(){const e=Rn.lFrame,t=null===e?null:e.child;return null===t?A9(e):t}function A9(e){const 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 null!==e&&(e.child=t),t}function I9(){const e=Rn.lFrame;return Rn.lFrame=e.parent,e.currentTNode=null,e.lView=null,e}const T9=I9;function aR(){const e=I9();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 la(){return Rn.lFrame.selectedIndex}function lg(e){Rn.lFrame.selectedIndex=e}function Ri(){const e=Rn.lFrame;return __(e.tView,e.selectedIndex)}let E9=!0;function C_(){return E9}function Bd(e){E9=e}function Iw(e,t){for(let n=t.directiveStart,r=t.directiveEnd;n=r)break}else t[c]<0&&(e[Ry]+=65536),(a>14>16&&(3&e[bn])===t&&(e[bn]+=16384,M9(a,o)):M9(a,o)}const By=-1;class w_{constructor(t,n,r){this.factory=t,this.resolving=!1,this.canSeeViewProviders=n,this.injectImpl=r}}function lR(e){return e!==By}function A_(e){return 32767&e}function I_(e,t){let n=function bbe(e){return e>>16}(e),r=t;for(;n>0;)r=r[My],n--;return r}let dR=!0;function Ew(e){const t=dR;return dR=e,t}const R9=255,k9=5;let vbe=0;const Od={};function Pw(e,t){const n=N9(e,t);if(-1!==n)return n;const r=t[Mt];r.firstCreatePass&&(e.injectorIndex=t.length,fR(r.data,e),fR(t,null),fR(r.blueprint,null));const i=Mw(e,t),o=e.injectorIndex;if(lR(i)){const s=A_(i),a=I_(i,t),c=a[Mt].data;for(let u=0;u<8;u++)t[o+u]=a[s+u]|c[s+u]}return t[o+8]=i,o}function fR(e,t){e.push(0,0,0,0,0,0,0,0,t)}function N9(e,t){return-1===e.injectorIndex||e.parent&&e.parent.injectorIndex===e.injectorIndex||null===t[e.injectorIndex+8]?-1:e.injectorIndex}function Mw(e,t){if(e.parent&&-1!==e.parent.injectorIndex)return e.parent.injectorIndex;let n=0,r=null,i=t;for(;null!==i;){if(r=z9(i),null===r)return By;if(n++,i=i[My],-1!==r.injectorIndex)return r.injectorIndex|n<<16}return By}function pR(e,t,n){!function _be(e,t,n){let r;"string"==typeof n?r=n.charCodeAt(0)||0:n.hasOwnProperty(u_)&&(r=n[u_]),null==r&&(r=n[u_]=vbe++);const i=r&R9;t.data[e+(i>>k9)]|=1<=0?t&R9:wbe:t}(n);if("function"==typeof o){if(!C9(t,e,r))return r&yr.Host?F9(i,0,r):B9(t,n,r,i);try{let s;if(s=o(r),null!=s||r&yr.Optional)return s;IM()}finally{T9()}}else if("number"==typeof o){let s=null,a=N9(e,t),c=By,u=r&yr.Host?t[go][aa]:null;for((-1===a||r&yr.SkipSelf)&&(c=-1===a?Mw(e,t):t[a+8],c!==By&&V9(r,!1)?(s=t[Mt],a=A_(c),t=I_(c,t)):a=-1);-1!==a;){const l=t[Mt];if(U9(o,a,l.data)){const d=Sbe(a,t,n,s,r,u);if(d!==Od)return d}c=t[a+8],c!==By&&V9(r,t[Mt].data[a+8]===u)&&U9(o,a,t)?(s=l,a=A_(c),t=I_(c,t)):a=-1}}return i}function Sbe(e,t,n,r,i,o){const s=t[Mt],a=s.data[e+8],l=Rw(a,s,n,null==r?cg(a)&&dR:r!=s&&!!(3&a.type),i&yr.Host&&o===a);return null!==l?dg(t,s,l,a):Od}function Rw(e,t,n,r,i){const o=e.providerIndexes,s=t.data,a=1048575&o,c=e.directiveStart,l=o>>20,f=i?a+l:e.directiveEnd;for(let p=r?a:a+l;p=c&&m.type===n)return p}if(i){const p=s[c];if(p&&Vl(p)&&p.type===n)return c}return null}function dg(e,t,n,r){let i=e[n];const o=t.data;if(function hbe(e){return e instanceof w_}(i)){const s=i;s.resolving&&function U0e(e,t){throw t&&t.join(" > "),new It(-200,e)}(function Zr(e){return"function"==typeof e?e.name||e.toString():"object"==typeof e&&null!=e&&"function"==typeof e.type?e.type.name||e.type.toString():Un(e)}(o[n]));const a=Ew(s.canSeeViewProviders);s.resolving=!0;const u=s.injectImpl?bc(s.injectImpl):null;C9(e,r,yr.Default);try{i=e[n]=s.factory(void 0,o,e,r),t.firstCreatePass&&n>=r.directiveStart&&function fbe(e,t,n){const{ngOnChanges:r,ngOnInit:i,ngDoCheck:o}=t.type.prototype;if(r){const s=u9(t);(n.preOrderHooks??=[]).push(e,s),(n.preOrderCheckHooks??=[]).push(e,s)}i&&(n.preOrderHooks??=[]).push(0-e,i),o&&((n.preOrderHooks??=[]).push(e,o),(n.preOrderCheckHooks??=[]).push(e,o))}(n,o[n],t)}finally{null!==u&&bc(u),Ew(a),s.resolving=!1,T9()}}return i}function U9(e,t,n){return!!(n[t+(e>>k9)]&1<{const t=e.prototype.constructor,n=t[Hf]||mR(t),r=Object.prototype;let i=Object.getPrototypeOf(e.prototype).constructor;for(;i&&i!==r;){const o=i[Hf]||mR(i);if(o&&o!==n)return o;i=Object.getPrototypeOf(i)}return o=>new o})}function mR(e){return rw(e)?()=>{const t=mR(En(e));return t&&t()}:ig(e)}function z9(e){const t=e[Mt],n=t.type;return 2===n?t.declTNode:1===n?e[aa]:null}function W9(e,t=null,n=null,r){const i=$9(e,t,n,r);return i.resolveInjectorInitializers(),i}function $9(e,t=null,n=null,r,i=new Set){const o=[n||Vr,mye(e)];return r=r||("object"==typeof e?void 0:Ss(e)),new Ty(o,t||bw(),r||null,i)}let Sc=(()=>{class e{static#e=this.THROW_IF_NOT_FOUND=l_;static#t=this.NULL=new pw;static create(n,r){if(Array.isArray(n))return W9({name:""},r,n,"");{const i=n.name??"";return W9({name:i},n.parent,n.providers,i)}}static#n=this.\u0275prov=Gt({token:e,providedIn:"any",factory:()=>Zt(zG)});static#r=this.__NG_ELEMENT_ID__=-1}return e})();function yR(e){return e.ngOriginalError}class Ld{constructor(){this._console=console}handleError(t){const n=this._findOriginalError(t);this._console.error("ERROR",t),n&&this._console.error("ORIGINAL ERROR",n)}_findOriginalError(t){let n=t&&yR(t);for(;n&&yR(n);)n=yR(n);return n||null}}const X9=new Yt("",{providedIn:"root",factory:()=>bt(Ld).handleError.bind(void 0)});let Uy=(()=>{class e{static#e=this.__NG_ELEMENT_ID__=Nbe;static#t=this.__NG_ENV_ID__=n=>n}return e})();class kbe extends Uy{constructor(t){super(),this._lView=t}onDestroy(t){return ww(this._lView,t),()=>function eR(e,t){if(null===e[Ch])return;const n=e[Ch].indexOf(t);-1!==n&&e[Ch].splice(n,1)}(this._lView,t)}}function Nbe(){return new kbe(it())}function Fbe(){return Vy(hi(),it())}function Vy(e,t){return new Ah(Oa(e,t))}let Ah=(()=>{class e{constructor(n){this.nativeElement=n}static#e=this.__NG_ELEMENT_ID__=Fbe}return e})();function Z9(e){return e instanceof Ah?e.nativeElement:e}function bR(e){return t=>{setTimeout(e,void 0,t)}}const Ua=class Bbe extends mr{constructor(t=!1){super(),this.destroyRef=void 0,this.__isAsync=t,t9()&&(this.destroyRef=bt(Uy,{optional:!0})??void 0)}emit(t){const n=sr(null);try{super.next(t)}finally{sr(n)}}subscribe(t,n,r){let i=t,o=n||(()=>null),s=r;if(t&&"object"==typeof t){const c=t;i=c.next?.bind(c),o=c.error?.bind(c),s=c.complete?.bind(c)}this.__isAsync&&(o=bR(o),i&&(i=bR(i)),s&&(s=bR(s)));const a=super.subscribe({next:i,error:o,complete:s});return t instanceof Fa&&t.add(a),a}};function Obe(){return this._results[Symbol.iterator]()}class vR{static#e=Symbol.iterator;get changes(){return this._changes??=new Ua}constructor(t=!1){this._emitDistinctChangesOnly=t,this.dirty=!0,this._onDirty=void 0,this._results=[],this._changesDetected=!1,this._changes=void 0,this.length=0,this.first=void 0,this.last=void 0;const n=vR.prototype;n[Symbol.iterator]||(n[Symbol.iterator]=Obe)}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,n){return this._results.reduce(t,n)}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,n){this.dirty=!1;const r=function vc(e){return e.flat(Number.POSITIVE_INFINITY)}(t);(this._changesDetected=!function Q0e(e,t,n){if(e.length!==t.length)return!1;for(let r=0;rove}),ove="ng",yj=new Yt(""),Th=new Yt("",{providedIn:"platform",factory:()=>"unknown"}),bj=new Yt("",{providedIn:"root",factory:()=>function Ih(){if(void 0!==CR)return CR;if(typeof document<"u")return document;throw new It(210,!1)}().body?.querySelector("[ngCspNonce]")?.getAttribute("ngCspNonce")||null});let vj=()=>null;function RR(e,t,n=!1){return vj(e,t,n)}const wj=new Yt("",{providedIn:"root",factory:()=>!1});let Hw;function Dj(e){return function OR(){if(void 0===Hw&&(Hw=null,si.trustedTypes))try{Hw=si.trustedTypes.createPolicy("angular#unsafe-bypass",{createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e})}catch{}return Hw}()?.createScriptURL(e)||e}class Ej{constructor(t){this.changingThisBreaksApplicationSecurity=t}toString(){return`SafeValue must use [property]=binding: ${this.changingThisBreaksApplicationSecurity} (see ${AG})`}}function Dh(e){return e instanceof Ej?e.changingThisBreaksApplicationSecurity:e}function N_(e,t){const n=function wve(e){return e instanceof Ej&&e.getTypeName()||null}(e);if(null!=n&&n!==t){if("ResourceURL"===n&&"URL"===t)return!0;throw new Error(`Required a safe ${t}, got a ${n} (see ${AG})`)}return n===t}const Dve=/^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:\/?#]*(?:[\/?#]|$))/i;var Hy=function(e){return e[e.NONE=0]="NONE",e[e.HTML=1]="HTML",e[e.STYLE=2]="STYLE",e[e.SCRIPT=3]="SCRIPT",e[e.URL=4]="URL",e[e.RESOURCE_URL=5]="RESOURCE_URL",e}(Hy||{});function Lj(e){const t=B_();return t?t.sanitize(Hy.URL,e)||"":N_(e,"URL")?Dh(e):function LR(e){return(e=String(e)).match(Dve)?e:"unsafe:"+e}(Un(e))}function Uj(e){const t=B_();if(t)return Dj(t.sanitize(Hy.RESOURCE_URL,e)||"");if(N_(e,"ResourceURL"))return Dj(Dh(e));throw new It(904,!1)}function B_(){const e=it();return e&&e[Ul].sanitizer}function Hj(e){return e.ownerDocument.defaultView}function Qc(e){return e instanceof Function?e():e}var Ph=function(e){return e[e.Important=1]="Important",e[e.DashCase=2]="DashCase",e}(Ph||{});let qR;function WR(e,t){return qR(e,t)}function Wy(e,t,n,r,i){if(null!=r){let o,s=!1;ua(r)?o=r:ca(r)&&(s=!0,r=r[Ji]);const a=_i(r);0===e&&null!==n?null==i?Jj(t,n,a):fg(t,n,a,i||null,!0):1===e&&null!==n?fg(t,n,a,i||null,!0):2===e?function U_(e,t,n){const r=Kw(e,t);r&&function l1e(e,t,n,r){e.removeChild(t,n,r)}(e,r,t,n)}(t,a,s):3===e&&t.destroyNode(a),null!=o&&function p1e(e,t,n,r,i){const o=n[Rd];o!==_i(n)&&Wy(t,e,r,o,i);for(let a=Go;a0&&(e[n-1][Ll]=r[Ll]);const o=dw(e,Go+t);!function r1e(e,t){Kj(e,t),t[Ji]=null,t[aa]=null}(r[Mt],r);const s=o[qf];null!==s&&s.detachView(o[Mt]),r[zo]=null,r[Ll]=null,r[bn]&=-129}return r}function Xw(e,t){if(!(256&t[bn])){const n=t[Mn];n.destroyNode&&Qw(e,t,n,3,null,null),function o1e(e){let t=e[m_];if(!t)return XR(e[Mt],e);for(;t;){let n=null;if(ca(t))n=t[m_];else{const r=t[Go];r&&(n=r)}if(!n){for(;t&&!t[Ll]&&t!==e;)ca(t)&&XR(t[Mt],t),t=t[zo];null===t&&(t=e),ca(t)&&XR(t[Mt],t),n=t&&t[Ll]}t=n}}(t)}}function XR(e,t){if(256&t[bn])return;const n=sr(null);try{t[bn]&=-129,t[bn]|=256,t[ag]&&function lG(e){if(gy(e),s_(e))for(let t=0;t=0?r[s]():r[-s].unsubscribe(),o+=2}else n[o].call(r[n[o+1]]);null!==r&&(t[Py]=null);const i=t[Ch];if(null!==i){t[Ch]=null;for(let o=0;o-1){const{encapsulation:o}=e.data[r.directiveStart+i];if(o===Fl.None||o===Fl.Emulated)return null}return Oa(r,n)}}(e,t.parent,n)}function fg(e,t,n,r,i){e.insertBefore(t,n,r,i)}function Jj(e,t,n){e.appendChild(t,n)}function eH(e,t,n,r,i){null!==r?fg(e,t,n,r,i):Jj(e,t,n)}function Kw(e,t){return e.parentNode(t)}let ZR,rH=function nH(e,t,n){return 40&e.type?Oa(e,n):null};function Zw(e,t,n,r){const i=KR(e,r,t),o=t[Mn],a=function tH(e,t,n){return rH(e,t,n)}(r.parent||t[aa],r,t);if(null!=i)if(Array.isArray(n))for(let c=0;cVn&&lH(e,t,Vn,!1),kd(s?2:0,i),n(r,i)}finally{lg(o),kd(s?3:1,i)}}function tk(e,t,n){if(qM(t)){const r=sr(null);try{const o=t.directiveEnd;for(let s=t.directiveStart;snull;function gH(e,t,n,r,i){for(let o in t){if(!t.hasOwnProperty(o))continue;const s=t[o];if(void 0===s)continue;r??={};let a,c=Bl.None;Array.isArray(s)?(a=s[0],c=s[1]):a=s;let u=o;if(null!==i){if(!i.hasOwnProperty(o))continue;u=i[o]}0===e?yH(r,n,u,a,c):yH(r,n,u,a)}return r}function yH(e,t,n,r,i){let o;e.hasOwnProperty(n)?(o=e[n]).push(t,r):o=e[n]=[t,r],void 0!==i&&o.push(i)}function ok(e,t,n,r){if(b9()){const i=null===r?null:{"":-1},o=function R1e(e,t){const n=e.directiveRegistry;let r=null,i=null;if(n)for(let o=0;o0;){const n=e[--t];if("number"==typeof n&&n<0)return n}return 0})(s)!=a&&s.push(a),s.push(n,r,o)}}(e,t,r,V_(e,n,i.hostVars,Wn),i)}function Ud(e,t,n,r,i,o){const s=Oa(e,t);!function ak(e,t,n,r,i,o,s){if(null==o)e.removeAttribute(t,i,n);else{const a=null==s?Un(o):s(o,r||"",i);e.setAttribute(t,i,a,n)}}(t[Mn],s,o,e.value,n,r,i)}function L1e(e,t,n,r,i,o){const s=o[t];if(null!==s)for(let a=0;a0&&(n[i-1][Ll]=t),r!1,producerRecomputeValue:()=>{},consumerMarkedDirty:()=>{},consumerOnSignalRead:()=>{},consumerIsAlwaysLive:!0,consumerMarkedDirty:e=>{x_(e.lView)},consumerOnSignalRead(){this.lView[ag]=this}},DH=100;function nA(e,t=!0,n=0){const r=e[Ul],i=r.rendererFactory;i.begin?.();try{!function $1e(e,t){fk(e,t);let n=0;for(;QM(e);){if(n===DH)throw new It(103,!1);n++,fk(e,1)}}(e,n)}catch(s){throw t&&tA(e,s),s}finally{i.end?.(),r.inlineEffectRunner?.flush()}}function Y1e(e,t,n,r){const i=t[bn];if(!(256&~i))return;t[Ul].inlineEffectRunner?.flush(),sR(t);let s=null,a=null;(function X1e(e){return 2!==e.type})(e)&&(a=function j1e(e){return e[ag]??function H1e(e){const t=TH.pop()??Object.create(W1e);return t.lView=e,t}(e)}(t),s=function cG(e){return e&&(e.nextProducerIndex=0),sr(e)}(a));try{m9(t),function x9(e){return Rn.lFrame.bindingIndex=e}(e.bindingStartIndex),null!==n&&pH(e,t,n,2,r);const c=!(3&~i);if(c){const d=e.preOrderCheckHooks;null!==d&&Tw(t,d,null)}else{const d=e.preOrderHooks;null!==d&&Dw(t,d,0,null),cR(t,0)}if(function K1e(e){for(let t=aj(e);null!==t;t=cj(t)){if(!(t[bn]&HM.HasTransplantedViews))continue;const n=t[ky];for(let r=0;re.nextProducerIndex;)e.producerNode.pop(),e.producerLastReadVersion.pop(),e.producerIndexOfThis.pop()}}(a,s),function q1e(e){e.lView[ag]!==e&&(e.lView=null,TH.push(e))}(a)),aR()}}function EH(e,t){for(let n=aj(e);null!==n;n=cj(n))for(let r=Go;r-1&&(O_(t,r),dw(n,r))}this._attachedToViewContainer=!1}Xw(this._lView[Mt],this._lView)}onDestroy(t){ww(this._lView,t)}markForCheck(){H_(this._cdRefInjectingView||this._lView)}detach(){this._lView[bn]&=-129}reattach(){JM(this._lView),this._lView[bn]|=128}detectChanges(){this._lView[bn]|=1024,nA(this._lView,this.notifyErrorHandler)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new It(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,Kj(this._lView[Mt],this._lView)}attachToAppRef(t){if(this._attachedToViewContainer)throw new It(902,!1);this._appRef=t,JM(this._lView)}}let Kf=(()=>{class e{static#e=this.__NG_ELEMENT_ID__=e_e}return e})();const Q1e=Kf,J1e=class extends Q1e{constructor(t,n,r){super(),this._declarationLView=t,this._declarationTContainer=n,this.elementRef=r}get ssrId(){return this._declarationTContainer.tView?.ssrId||null}createEmbeddedView(t,n){return this.createEmbeddedViewImpl(t,n)}createEmbeddedViewImpl(t,n,r){const i=z_(this._declarationLView,this._declarationTContainer,t,{embeddedViewInjector:n,dehydratedView:r});return new q_(i)}};function e_e(){return rA(hi(),it())}function rA(e,t){return 4&e.type?new J1e(t,e,Vy(e,t)):null}let OH=()=>null;function Xy(e,t){return OH(e,t)}class bk{}class w_e{}class LH{}class I_e{resolveComponentFactory(t){throw function A_e(e){const t=Error(`No component factory found for ${Ss(e)}.`);return t.ngComponent=e,t}(t)}}let cA=(()=>{class e{static#e=this.NULL=new I_e}return e})();class VH{}let uA=(()=>{class e{constructor(){this.destroyNode=null}static#e=this.__NG_ELEMENT_ID__=()=>function T_e(){const e=it(),n=Zc(hi().index,e);return(ca(n)?n:e)[Mn]}()}return e})(),D_e=(()=>{class e{static#e=this.\u0275prov=Gt({token:e,providedIn:"root",factory:()=>null})}return e})();const vk={},zH=new Set;function Vd(e){zH.has(e)||(zH.add(e),performance?.mark?.("mark_feature_usage",{detail:{feature:e}}))}function GH(...e){}class Qr{constructor({enableLongStackTrace:t=!1,shouldCoalesceEventChangeDetection:n=!1,shouldCoalesceRunChangeDetection:r=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new Ua(!1),this.onMicrotaskEmpty=new Ua(!1),this.onStable=new Ua(!1),this.onError=new Ua(!1),typeof Zone>"u")throw new It(908,!1);Zone.assertZonePatched();const i=this;i._nesting=0,i._outer=i._inner=Zone.current,Zone.TaskTrackingZoneSpec&&(i._inner=i._inner.fork(new Zone.TaskTrackingZoneSpec)),t&&Zone.longStackTraceZoneSpec&&(i._inner=i._inner.fork(Zone.longStackTraceZoneSpec)),i.shouldCoalesceEventChangeDetection=!r&&n,i.shouldCoalesceRunChangeDetection=r,i.lastRequestAnimationFrameId=-1,i.nativeRequestAnimationFrame=function E_e(){const e="function"==typeof si.requestAnimationFrame;let t=si[e?"requestAnimationFrame":"setTimeout"],n=si[e?"cancelAnimationFrame":"clearTimeout"];if(typeof Zone<"u"&&t&&n){const r=t[Zone.__symbol__("OriginalDelegate")];r&&(t=r);const i=n[Zone.__symbol__("OriginalDelegate")];i&&(n=i)}return{nativeRequestAnimationFrame:t,nativeCancelAnimationFrame:n}}().nativeRequestAnimationFrame,function R_e(e){const t=()=>{!function M_e(e){e.isCheckStableRunning||-1!==e.lastRequestAnimationFrameId||(e.lastRequestAnimationFrameId=e.nativeRequestAnimationFrame.call(si,()=>{e.fakeTopEventTask||(e.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{e.lastRequestAnimationFrameId=-1,xk(e),e.isCheckStableRunning=!0,_k(e),e.isCheckStableRunning=!1},void 0,()=>{},()=>{})),e.fakeTopEventTask.invoke()}),xk(e))}(e)};e._inner=e._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(n,r,i,o,s,a)=>{if(function k_e(e){return!(!Array.isArray(e)||1!==e.length)&&!0===e[0].data?.__ignore_ng_zone__}(a))return n.invokeTask(i,o,s,a);try{return jH(e),n.invokeTask(i,o,s,a)}finally{(e.shouldCoalesceEventChangeDetection&&"eventTask"===o.type||e.shouldCoalesceRunChangeDetection)&&t(),HH(e)}},onInvoke:(n,r,i,o,s,a,c)=>{try{return jH(e),n.invoke(i,o,s,a,c)}finally{e.shouldCoalesceRunChangeDetection&&t(),HH(e)}},onHasTask:(n,r,i,o)=>{n.hasTask(i,o),r===i&&("microTask"==o.change?(e._hasPendingMicrotasks=o.microTask,xk(e),_k(e)):"macroTask"==o.change&&(e.hasPendingMacrotasks=o.macroTask))},onHandleError:(n,r,i,o)=>(n.handleError(i,o),e.runOutsideAngular(()=>e.onError.emit(o)),!1)})}(i)}static isInAngularZone(){return typeof Zone<"u"&&!0===Zone.current.get("isAngularZone")}static assertInAngularZone(){if(!Qr.isInAngularZone())throw new It(909,!1)}static assertNotInAngularZone(){if(Qr.isInAngularZone())throw new It(909,!1)}run(t,n,r){return this._inner.run(t,n,r)}runTask(t,n,r,i){const o=this._inner,s=o.scheduleEventTask("NgZoneEvent: "+i,t,P_e,GH,GH);try{return o.runTask(s,n,r)}finally{o.cancelTask(s)}}runGuarded(t,n,r){return this._inner.runGuarded(t,n,r)}runOutsideAngular(t){return this._outer.run(t)}}const P_e={};function _k(e){if(0==e._nesting&&!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 xk(e){e.hasPendingMicrotasks=!!(e._hasPendingMicrotasks||(e.shouldCoalesceEventChangeDetection||e.shouldCoalesceRunChangeDetection)&&-1!==e.lastRequestAnimationFrameId)}function jH(e){e._nesting++,e.isStable&&(e.isStable=!1,e.onUnstable.emit(null))}function HH(e){e._nesting--,_k(e)}var pg=function(e){return e[e.EarlyRead=0]="EarlyRead",e[e.Write=1]="Write",e[e.MixedReadWrite=2]="MixedReadWrite",e[e.Read=3]="Read",e}(pg||{});const WH={destroy(){}};function $H(e,t){!t&&function vw(e){if(!t9())throw new It(-203,!1)}();const n=t?.injector??bt(Sc);if(!function Eh(e){return"browser"===(e??bt(Sc)).get(Th)}(n))return WH;Vd("NgAfterNextRender");const r=n.get(K_),i=r.handler??=new XH,o=t?.phase??pg.MixedReadWrite,s=()=>{i.unregister(c),a()},a=n.get(Uy).onDestroy(s),c=Md(n,()=>new YH(o,()=>{s(),e()}));return i.register(c),{destroy:s}}class YH{constructor(t,n){this.phase=t,this.callbackFn=n,this.zone=bt(Qr),this.errorHandler=bt(Ld,{optional:!0}),bt(bk,{optional:!0})?.notify(1)}invoke(){try{this.zone.runOutsideAngular(this.callbackFn)}catch(t){this.errorHandler?.handleError(t)}}}class XH{constructor(){this.executingCallbacks=!1,this.buckets={[pg.EarlyRead]:new Set,[pg.Write]:new Set,[pg.MixedReadWrite]:new Set,[pg.Read]:new Set},this.deferredCallbacks=new Set}register(t){(this.executingCallbacks?this.deferredCallbacks:this.buckets[t.phase]).add(t)}unregister(t){this.buckets[t.phase].delete(t),this.deferredCallbacks.delete(t)}execute(){this.executingCallbacks=!0;for(const t of Object.values(this.buckets))for(const n of t)n.invoke();this.executingCallbacks=!1;for(const t of this.deferredCallbacks)this.buckets[t.phase].add(t);this.deferredCallbacks.clear()}destroy(){for(const t of Object.values(this.buckets))t.clear();this.deferredCallbacks.clear()}}let K_=(()=>{class e{constructor(){this.handler=null,this.internalCallbacks=[]}execute(){this.executeInternalCallbacks(),this.handler?.execute()}executeInternalCallbacks(){const n=[...this.internalCallbacks];this.internalCallbacks.length=0;for(const r of n)r()}ngOnDestroy(){this.handler?.destroy(),this.handler=null,this.internalCallbacks.length=0}static#e=this.\u0275prov=Gt({token:e,providedIn:"root",factory:()=>new e})}return e})();function dA(e,t,n){let r=n?e.styles:null,i=n?e.classes:null,o=0;if(null!==t)for(let s=0;s0&&cH(e,n,o.join(" "))}}(p,A,h,r),void 0!==n&&function W_e(e,t,n){const r=e.projection=[];for(let i=0;i{class e{static#e=this.__NG_ELEMENT_ID__=Y_e}return e})();function Y_e(){return nq(hi(),it())}const X_e=Gl,eq=class extends X_e{constructor(t,n,r){super(),this._lContainer=t,this._hostTNode=n,this._hostLView=r}get element(){return Vy(this._hostTNode,this._hostLView)}get injector(){return new As(this._hostTNode,this._hostLView)}get parentInjector(){const t=Mw(this._hostTNode,this._hostLView);if(lR(t)){const n=I_(t,this._hostLView),r=A_(t);return new As(n[Mt].data[r+8],n)}return new As(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(t){const n=tq(this._lContainer);return null!==n&&n[t]||null}get length(){return this._lContainer.length-Go}createEmbeddedView(t,n,r){let i,o;"number"==typeof r?i=r:null!=r&&(i=r.index,o=r.injector);const s=Xy(this._lContainer,t.ssrId),a=t.createEmbeddedViewImpl(n||{},o,s);return this.insertImpl(a,i,Yy(this._hostTNode,s)),a}createComponent(t,n,r,i,o){const s=t&&!function h_(e){return"function"==typeof e}(t);let a;if(s)a=n;else{const m=n||{};a=m.index,r=m.injector,i=m.projectableNodes,o=m.environmentInjector||m.ngModuleRef}const c=s?t:new J_(dr(t)),u=r||this.parentInjector;if(!o&&null==c.ngModule){const h=(s?u:this.parentInjector).get(xc,null);h&&(o=h)}const l=dr(c.componentType??{}),d=Xy(this._lContainer,l?.id??null),p=c.create(u,i,d?.firstChild??null,o);return this.insertImpl(p.hostView,a,Yy(this._hostTNode,d)),p}insert(t,n){return this.insertImpl(t,n,!0)}insertImpl(t,n,r){const i=t._lView;if(function Hye(e){return ua(e[zo])}(i)){const a=this.indexOf(t);if(-1!==a)this.detach(a);else{const c=i[zo],u=new eq(c,c[aa],c[zo]);u.detach(u.indexOf(t))}}const o=this._adjustIndex(n),s=this._lContainer;return G_(s,i,o,r),t.attachToViewContainerRef(),LG(Ak(s),o,t),t}move(t,n){return this.insert(t,n)}indexOf(t){const n=tq(this._lContainer);return null!==n?n.indexOf(t):-1}remove(t){const n=this._adjustIndex(t,-1),r=O_(this._lContainer,n);r&&(dw(Ak(this._lContainer),n),Xw(r[Mt],r))}detach(t){const n=this._adjustIndex(t,-1),r=O_(this._lContainer,n);return r&&null!=dw(Ak(this._lContainer),n)?new q_(r):null}_adjustIndex(t,n=0){return t??this.length+n}};function tq(e){return e[8]}function Ak(e){return e[8]||(e[8]=[])}function nq(e,t){let n;const r=t[e.index];return ua(r)?n=r:(n=_H(r,t,null,e),t[e.index]=n,eA(t,n)),rq(n,t,e,r),new eq(n,e,t)}let rq=function oq(e,t,n,r){if(e[Rd])return;let i;i=8&n.type?_i(r):function K_e(e,t){const n=e[Mn],r=n.createComment(""),i=Oa(t,e);return fg(n,Kw(n,i),r,function d1e(e,t){return e.nextSibling(t)}(n,i),!1),r}(t,n),e[Rd]=i},Ik=()=>!1;class Tk{constructor(t){this.queryList=t,this.matches=null}clone(){return new Tk(this.queryList)}setDirty(){this.queryList.setDirty()}}class Dk{constructor(t=[]){this.queries=t}createEmbeddedView(t){const n=t.queries;if(null!==n){const r=null!==t.contentQueries?t.contentQueries[0]:n.length,i=[];for(let o=0;ot.trim())}(t):t}}class Ek{constructor(t=[]){this.queries=t}elementStart(t,n){for(let r=0;r0)r.push(s[a/2]);else{const u=o[a+1],l=t[-c];for(let d=Go;dn()),this.destroyCbs=null}onDestroy(t){this.destroyCbs.push(t)}}class Bk extends Rq{constructor(t){super(),this.moduleType=t}create(t){return new Fk(this.moduleType,t,[])}}class kq extends hg{constructor(t){super(),this.componentFactoryResolver=new QH(this),this.instance=null;const n=new Ty([...t.providers,{provide:hg,useValue:this},{provide:cA,useValue:this.componentFactoryResolver}],t.parent||bw(),t.debugName,new Set(["environment"]));this.injector=n,t.runEnvironmentInitializers&&n.resolveInjectorInitializers()}destroy(){this.injector.destroy()}onDestroy(t){this.injector.onDestroy(t)}}function hA(e,t,n=null){return new kq({providers:e,parent:t,debugName:n,runEnvironmentInitializers:!0}).injector}let kh=(()=>{class e{constructor(){this.taskId=0,this.pendingTasks=new Set,this.hasPendingTasks=new Ao(!1)}get _hasPendingTasks(){return this.hasPendingTasks.value}add(){this._hasPendingTasks||this.hasPendingTasks.next(!0);const n=this.taskId++;return this.pendingTasks.add(n),n}remove(n){this.pendingTasks.delete(n),0===this.pendingTasks.size&&this._hasPendingTasks&&this.hasPendingTasks.next(!1)}ngOnDestroy(){this.pendingTasks.clear(),this._hasPendingTasks&&this.hasPendingTasks.next(!1)}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function zd(e,t,n){return e[t]=n}function jo(e,t,n){return!Object.is(e[t],n)&&(e[t]=n,!0)}function yA(e,t,n,r,i){const o=function mg(e,t,n,r){const i=jo(e,t,n);return jo(e,t+1,r)||i}(e,t,n,r);return jo(e,t+2,i)||o}function Jc(e,t,n,r,i,o,s,a){const c=it(),u=br(),l=e+Vn,d=u.firstCreatePass?function kxe(e,t,n,r,i,o,s,a,c){const u=t.consts,l=$y(t,e,4,s||null,Nd(u,a));ok(t,n,l,Nd(u,c)),Iw(t,l);const d=l.tView=ik(2,l,r,i,o,t.directiveRegistry,t.pipeRegistry,null,t.schemas,u,null);return null!==t.queries&&(t.queries.template(t,l),d.queries=t.queries.embeddedTView(l)),l}(l,u,c,t,n,r,i,o,s):u.data[l];Fd(d,!1);const f=Nq(u,c,d,e);C_()&&Zw(u,c,f,d),da(f,c);const p=_H(f,c,f,d);return c[l]=p,eA(c,p),function iq(e,t,n){return Ik(e,t,n)}(p,d,c),Cw(d)&&nk(u,c,d),null!=s&&rk(c,d,a),Jc}let Nq=function Fq(e,t,n,r){return Bd(!0),t[Mn].createComment("")};function $k(e,t,n,r){const i=it();return jo(i,zl(),t)&&(br(),Ud(Ri(),i,e,t,n,r)),$k}function CA(e,t){return e<<17|t<<2}function Fh(e){return e>>17&32767}function Yk(e){return 2|e}function yg(e){return(131068&e)>>2}function Xk(e,t){return-131069&e|t<<2}function Kk(e){return 1|e}function fW(e,t,n,r){const i=e[n+1],o=null===t;let s=r?Fh(i):yg(i),a=!1;for(;0!==s&&(!1===a||o);){const u=e[s+1];y2e(e[s],t)&&(a=!0,e[s+1]=r?Kk(u):Yk(u)),s=r?Fh(u):yg(u)}a&&(e[n+1]=r?Yk(i):Kk(i))}function y2e(e,t){return null===e||null==t||(Array.isArray(e)?e[1]:e)===t||!(!Array.isArray(e)||"string"!=typeof t)&&Ay(e,t)>=0}function Bh(e,t,n){const r=it();return jo(r,zl(),t)&&function wc(e,t,n,r,i,o,s,a){const c=Oa(t,n);let l,u=t.inputs;!a&&null!=u&&(l=u[r])?(uk(e,n,l,r,i),cg(t)&&function I1e(e,t){const n=Zc(t,e);16&n[bn]||(n[bn]|=64)}(n,t.index)):3&t.type&&(r=function A1e(e){return"class"===e?"className":"for"===e?"htmlFor":"formaction"===e?"formAction":"innerHtml"===e?"innerHTML":"readonly"===e?"readOnly":"tabindex"===e?"tabIndex":e}(r),i=null!=s?s(i,t.value||"",r):i,o.setProperty(c,r,i))}(br(),Ri(),r,e,t,r[Mn],n,!1),Bh}function Zk(e,t,n,r,i){const s=i?"class":"style";uk(e,n,t.inputs[s],s,r)}function pb(e,t,n){return function jl(e,t,n,r){const i=it(),o=br(),s=function $f(e){const t=Rn.lFrame,n=t.bindingIndex;return t.bindingIndex=t.bindingIndex+e,n}(2);o.firstUpdatePass&&function xW(e,t,n,r){const i=e.data;if(null===i[n+1]){const o=i[la()],s=function _W(e,t){return t>=e.expandoStartIndex}(e,n);(function AW(e,t){return!!(e.flags&(t?8:16))})(o,r)&&null===t&&!s&&(t=!1),t=function I2e(e,t,n,r){const i=function iR(e){const t=Rn.lFrame.currentDirectiveIndex;return-1===t?null:e[t]}(e);let o=r?t.residualClasses:t.residualStyles;if(null===i)0===(r?t.classBindings:t.styleBindings)&&(n=sx(n=Qk(null,e,t,n,r),t.attrs,r),o=null);else{const s=t.directiveStylingLast;if(-1===s||e[s]!==i)if(n=Qk(i,e,t,n,r),null===o){let c=function T2e(e,t,n){const r=n?t.classBindings:t.styleBindings;if(0!==yg(r))return e[Fh(r)]}(e,t,r);void 0!==c&&Array.isArray(c)&&(c=Qk(null,e,t,c[1],r),c=sx(c,t.attrs,r),function D2e(e,t,n,r){e[Fh(n?t.classBindings:t.styleBindings)]=r}(e,t,r,c))}else o=function E2e(e,t,n){let r;const i=t.directiveEnd;for(let o=1+t.directiveStylingLast;o0)&&(u=!0)):l=n,i)if(0!==c){const f=Fh(e[a+1]);e[r+1]=CA(f,a),0!==f&&(e[f+1]=Xk(e[f+1],r)),e[a+1]=function p2e(e,t){return 131071&e|t<<17}(e[a+1],r)}else e[r+1]=CA(a,0),0!==a&&(e[a+1]=Xk(e[a+1],r)),a=r;else e[r+1]=CA(c,0),0===a?a=r:e[c+1]=Xk(e[c+1],r),c=r;u&&(e[r+1]=Yk(e[r+1])),fW(e,l,r,!0),fW(e,l,r,!1),function g2e(e,t,n,r,i){const o=i?e.residualClasses:e.residualStyles;null!=o&&"string"==typeof t&&Ay(o,t)>=0&&(n[r+1]=Kk(n[r+1]))}(t,l,e,r,o),s=CA(a,c),o?t.classBindings=s:t.styleBindings=s}(i,o,t,n,s,r)}}(o,e,s,r),t!==Wn&&jo(i,s,t)&&function CW(e,t,n,r,i,o,s,a){if(!(3&t.type))return;const c=e.data,u=c[a+1],l=function h2e(e){return!(1&~e)}(u)?wW(c,t,n,i,yg(u),s):void 0;wA(l)||(wA(o)||function f2e(e){return!(2&~e)}(u)&&(o=wW(c,null,n,i,a,s)),function h1e(e,t,n,r,i){if(t)i?e.addClass(n,r):e.removeClass(n,r);else{let o=-1===r.indexOf("-")?void 0:Ph.DashCase;null==i?e.removeStyle(n,r,o):("string"==typeof i&&i.endsWith("!important")&&(i=i.slice(0,-10),o|=Ph.Important),e.setStyle(n,r,i,o))}}(r,s,v_(la(),n),i,o))}(o,o.data[la()],i,i[Mn],e,i[s+1]=function k2e(e,t){return null==e||""===e||("string"==typeof t?e+=t:"object"==typeof e&&(e=Ss(Dh(e)))),e}(t,n),r,s)}(e,t,n,!1),pb}function Qk(e,t,n,r,i){let o=null;const s=n.directiveEnd;let a=n.directiveStylingLast;for(-1===a?a=n.directiveStart:a++;a0;){const c=e[i],u=Array.isArray(c),l=u?c[1]:c,d=null===l;let f=n[i+1];f===Wn&&(f=d?Vr:void 0);let p=d?MM(f,r):l===r?f:void 0;if(u&&!wA(p)&&(p=MM(c,r)),wA(p)&&(a=p,s))return a;const m=e[i+1];i=s?Fh(m):yg(m)}if(null!==t){let c=o?t.residualClasses:t.residualStyles;null!=c&&(a=MM(c,r))}return a}function wA(e){return void 0!==e}class H2e{destroy(t){}updateValue(t,n){}swap(t,n){const r=Math.min(t,n),i=Math.max(t,n),o=this.detach(i);if(i-r>1){const s=this.detach(r);this.attach(r,o),this.attach(i,s)}else this.attach(r,o)}move(t,n){this.attach(n,this.detach(t))}}function Jk(e,t,n,r,i){return e===n&&Object.is(t,r)?1:Object.is(i(e,t),i(n,r))?-1:0}function eN(e,t,n,r){return!(void 0===t||!t.has(r)||(e.attach(n,t.get(r)),t.delete(r),0))}function IW(e,t,n,r,i){if(eN(e,t,r,n(r,i)))e.updateValue(r,i);else{const o=e.create(r,i);e.attach(r,o)}}function TW(e,t,n,r){const i=new Set;for(let o=t;o<=n;o++)i.add(r(o,e.at(o)));return i}class DW{constructor(){this.kvMap=new Map,this._vMap=void 0}has(t){return this.kvMap.has(t)}delete(t){if(!this.has(t))return!1;const n=this.kvMap.get(t);return void 0!==this._vMap&&this._vMap.has(n)?(this.kvMap.set(t,this._vMap.get(n)),this._vMap.delete(n)):this.kvMap.delete(t),!0}get(t){return this.kvMap.get(t)}set(t,n){if(this.kvMap.has(t)){let r=this.kvMap.get(t);void 0===this._vMap&&(this._vMap=new Map);const i=this._vMap;for(;i.has(r);)r=i.get(r);i.set(r,n)}else this.kvMap.set(t,n)}forEach(t){for(let[n,r]of this.kvMap)if(t(r,n),void 0!==this._vMap){const i=this._vMap;for(;i.has(r);)r=i.get(r),t(r,n)}}}function Va(e,t,n){Vd("NgControlFlow");const r=it(),i=zl(),o=tN(r,Vn+e);if(jo(r,i,t)){const a=sr(null);try{if(dk(o,0),-1!==t){const c=nN(r[Mt],Vn+t),u=Xy(o,c.tView.ssrId);G_(o,z_(r,c,n,{dehydratedView:u}),0,Yy(c,u))}}finally{sr(a)}}else{const a=AH(o,0);void 0!==a&&(a[Mi]=n)}}class W2e{constructor(t,n,r){this.lContainer=t,this.$implicit=n,this.$index=r}get $count(){return this.lContainer.length-Go}}function EW(e){return e}class Y2e{constructor(t,n,r){this.hasEmptyBlock=t,this.trackByFn=n,this.liveCollection=r}}class X2e extends H2e{constructor(t,n,r){super(),this.lContainer=t,this.hostLView=n,this.templateTNode=r,this.needsIndexUpdate=!1}get length(){return this.lContainer.length-Go}at(t){return this.getLView(t)[Mi].$implicit}attach(t,n){const r=n[Kc];this.needsIndexUpdate||=t!==this.length,G_(this.lContainer,n,t,Yy(this.templateTNode,r))}detach(t){return this.needsIndexUpdate||=t!==this.length-1,function K2e(e,t){return O_(e,t)}(this.lContainer,t)}create(t,n){const r=Xy(this.lContainer,this.templateTNode.tView.ssrId);return z_(this.hostLView,this.templateTNode,new W2e(this.lContainer,n,t),{dehydratedView:r})}destroy(t){Xw(t[Mt],t)}updateValue(t,n){this.getLView(t)[Mi].$implicit=n}reset(){this.needsIndexUpdate=!1}updateIndexes(){if(this.needsIndexUpdate)for(let t=0;t(Bd(!0),Yw(r,i,function D9(){return Rn.lFrame.currentNamespace}()));const mb="en-US";let UW=mb;function px(e,t,n,r){const i=it(),o=br(),s=hi();return function aN(e,t,n,r,i,o,s){const a=Cw(r),u=e.firstCreatePass&&CH(e),l=t[Mi],d=SH(t);let f=!0;if(3&r.type||s){const h=Oa(r,t),g=s?s(h):h,y=d.length,b=s?_=>s(_i(_[r.index])):r.index;let x=null;if(!s&&a&&(x=function rCe(e,t,n,r){const i=e.cleanup;if(null!=i)for(let o=0;oc?a[c]:null}"string"==typeof s&&(o+=2)}return null}(e,t,i,r.index)),null!==x)(x.__ngLastListenerFn__||x).__ngNextListenerFn__=o,x.__ngLastListenerFn__=o,f=!1;else{o=p$(r,t,l,o,!1);const _=n.listen(g,i,o);d.push(o,_),u&&u.push(i,b,y,y+1)}}else o=p$(r,t,l,o,!1);const p=r.outputs;let m;if(f&&null!==p&&(m=p[i])){const h=m.length;if(h)for(let g=0;g-1?Zc(e.index,t):t);let c=f$(t,n,r,s),u=o.__ngNextListenerFn__;for(;u;)c=f$(t,n,u,s)&&c,u=u.__ngNextListenerFn__;return i&&!1===c&&s.preventDefault(),c}}function hx(e=1){return function abe(e){return(Rn.lFrame.contextLView=function g9(e,t){for(;e>0;)t=t[My],e--;return t}(e,Rn.lFrame.contextLView))[Mi]}(e)}function uN(e,t,n){uq(e,t,n)}function EA(e){const t=it(),n=br(),r=oR();Aw(r+1);const i=kk(n,r);if(e.dirty&&function jye(e){return!(4&~e[bn])}(t)===!(2&~i.metadata.flags)){if(null===i.matches)e.reset([]);else{const o=fq(t,r);e.reset(o,Z9),e.notifyOnChanges()}return!0}return!1}function PA(){return function Rk(e,t){return e[qf].queries[t].queryList}(it(),oR())}function ar(e,t=""){const n=it(),r=br(),i=e+Vn,o=r.firstCreatePass?$y(r,i,1,t,null):r.data[i],s=k$(r,n,o,t,e);n[i]=s,C_()&&Zw(r,n,s,o),Fd(o,!1)}let k$=(e,t,n,r,i)=>(Bd(!0),function $R(e,t){return e.createText(t)}(t[Mn],r));function ku(e){return lN("",e,""),ku}function lN(e,t,n){const r=it(),i=function ib(e,t,n,r){return jo(e,zl(),n)?t+Un(n)+r:Wn}(r,e,t,n);return i!==Wn&&function Xf(e,t,n){const r=v_(t,e);!function Xj(e,t,n){e.setValue(t,n)}(e[Mn],r,n)}(r,la(),i),lN}function dN(e,t,n,r,i){if(e=En(e),Array.isArray(e))for(let o=0;o>20;if(sg(e)||!e.multi){const p=new w_(u,i,cn),m=pN(c,t,i?l:l+f,d);-1===m?(pR(Pw(a,s),o,c),fN(o,e,t.length),t.push(c),a.directiveStart++,a.directiveEnd++,i&&(a.providerIndexes+=1048576),n.push(p),s.push(p)):(n[m]=p,s[m]=p)}else{const p=pN(c,t,l+f,d),m=pN(c,t,l,l+f),g=m>=0&&n[m];if(i&&!g||!i&&!(p>=0&&n[p])){pR(Pw(a,s),o,c);const y=function TCe(e,t,n,r,i){const o=new w_(e,n,cn);return o.multi=[],o.index=t,o.componentProviders=0,H$(o,i,r&&!n),o}(i?ICe:ACe,n.length,i,r,u);!i&&g&&(n[m].providerFactory=y),fN(o,e,t.length,0),t.push(c),a.directiveStart++,a.directiveEnd++,i&&(a.providerIndexes+=1048576),n.push(y),s.push(y)}else fN(o,e,p>-1?p:m,H$(n[i?m:p],u,!i&&r));!i&&r&&g&&n[m].componentProviders++}}}function fN(e,t,n,r){const i=sg(t),o=function yye(e){return!!e.useClass}(t);if(i||o){const c=(o?En(t.useClass):t).prototype.ngOnDestroy;if(c){const u=e.destroyHooks||(e.destroyHooks=[]);if(!i&&t.multi){const l=u.indexOf(n);-1===l?u.push(n,[r,c]):u[l+1].push(r,c)}else u.push(n,c)}}}function H$(e,t,n){return n&&e.componentProviders++,e.multi.push(t)-1}function pN(e,t,n,r){for(let i=n;i{n.providersResolver=(r,i)=>function wCe(e,t,n){const r=br();if(r.firstCreatePass){const i=Vl(e);dN(n,r.data,r.blueprint,i,!0),dN(t,r.data,r.blueprint,i,!1)}}(r,i?i(e):e,t)}}let DCe=(()=>{class e{constructor(n){this._injector=n,this.cachedInjectors=new Map}getOrCreateStandaloneInjector(n){if(!n.standalone)return null;if(!this.cachedInjectors.has(n)){const r=FM(0,n.type),i=r.length>0?hA([r],this._injector,`Standalone[${n.type.name}]`):null;this.cachedInjectors.set(n,i)}return this.cachedInjectors.get(n)}ngOnDestroy(){try{for(const n of this.cachedInjectors.values())null!==n&&n.destroy()}finally{this.cachedInjectors.clear()}}static#e=this.\u0275prov=Gt({token:e,providedIn:"environment",factory:()=>new e(Zt(xc))})}return e})();function Nu(e){Vd("NgStandalone"),e.getStandaloneInjector=t=>t.get(DCe).getOrCreateStandaloneInjector(e)}function mx(e,t,n,r){return W$(it(),La(),e,t,n,r)}function gN(e,t,n,r,i,o){return function Y$(e,t,n,r,i,o,s,a){const c=t+n;return yA(e,c,i,o,s)?zd(e,c+3,a?r.call(a,i,o,s):r(i,o,s)):gx(e,c+3)}(it(),La(),e,t,n,r,i,o)}function gx(e,t){const n=e[t];return n===Wn?void 0:n}function W$(e,t,n,r,i,o){const s=t+n;return jo(e,s,i)?zd(e,s+1,o?r.call(o,i):r(i)):gx(e,s+1)}function Ga(e,t){const n=br();let r;const i=e+Vn;n.firstCreatePass?(r=function UCe(e,t){if(t)for(let n=t.length-1;n>=0;n--){const r=t[n];if(e===r.name)return r}}(t,n.pipeRegistry),n.data[i]=r,r.onDestroy&&(n.destroyHooks??=[]).push(i,r.onDestroy)):r=n.data[i];const o=r.factory||(r.factory=ig(r.type)),a=bc(cn);try{const c=Ew(!1),u=o();return Ew(c),function lCe(e,t,n,r){n>=e.data.length&&(e.data[n]=null,e.blueprint[n]=null),t[n]=r}(n,it(),i,u),u}finally{bc(a)}}function ja(e,t,n){const r=e+Vn,i=it(),o=function Ny(e,t){return e[t]}(i,r);return function yx(e,t){return e[Mt].data[t].pure}(i,r)?W$(i,La(),t,o.transform,n,o):o.transform(n)}let fY=(()=>{class e{log(n){console.log(n)}warn(n){console.warn(n)}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();const yY=new Yt("");function BA(e){return!!e&&"function"==typeof e.then}function bY(e){return!!e&&"function"==typeof e.subscribe}const AN=new Yt("");let IN=(()=>{class e{constructor(){this.initialized=!1,this.done=!1,this.donePromise=new Promise((n,r)=>{this.resolve=n,this.reject=r}),this.appInits=bt(AN,{optional:!0})??[]}runInitializers(){if(this.initialized)return;const n=[];for(const i of this.appInits){const o=i();if(BA(o))n.push(o);else if(bY(o)){const s=new Promise((a,c)=>{o.subscribe({complete:a,error:c})});n.push(s)}}const r=()=>{this.done=!0,this.resolve()};Promise.all(n).then(()=>{r()}).catch(i=>{this.reject(i)}),0===n.length&&r(),this.initialized=!0}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();const OA=new Yt("");let Oh=(()=>{class e{constructor(){this._bootstrapListeners=[],this._runningTick=!1,this._destroyed=!1,this._destroyListeners=[],this._views=[],this.internalErrorHandler=bt(X9),this.afterRenderEffectManager=bt(K_),this.externalTestViews=new Set,this.beforeRender=new mr,this.afterTick=new mr,this.componentTypes=[],this.components=[],this.isStable=bt(kh).hasPendingTasks.pipe(qt(n=>!n)),this._injector=bt(xc)}get destroyed(){return this._destroyed}get injector(){return this._injector}bootstrap(n,r){const i=n instanceof LH;if(!this._injector.get(IN).done)throw!i&&function Sh(e){const t=dr(e)||Cs(e)||Qs(e);return null!==t&&t.standalone}(n),new It(405,!1);let s;s=i?n:this._injector.get(cA).resolveComponentFactory(n),this.componentTypes.push(s.componentType);const a=function Lwe(e){return e.isBoundToModule}(s)?void 0:this._injector.get(hg),u=s.create(Sc.NULL,[],r||s.selector,a),l=u.location.nativeElement,d=u.injector.get(yY,null);return d?.registerApplication(l),u.onDestroy(()=>{this.detachView(u.hostView),LA(this.components,u),d?.unregisterApplication(l)}),this._loadComponent(u),u}tick(){this._tick(!0)}_tick(n){if(this._runningTick)throw new It(101,!1);const r=sr(null);try{this._runningTick=!0,this.detectChangesInAttachedViews(n)}catch(i){this.internalErrorHandler(i)}finally{this.afterTick.next(),this._runningTick=!1,sr(r)}}detectChangesInAttachedViews(n){let r=0;const i=this.afterRenderEffectManager;for(;;){if(r===DH)throw new It(103,!1);if(n){const o=0===r;this.beforeRender.next(o);for(let{_lView:s,notifyErrorHandler:a}of this._views)Vwe(s,o,a)}if(r++,i.executeInternalCallbacks(),![...this.externalTestViews.keys(),...this._views].some(({_lView:o})=>TN(o))&&(i.execute(),![...this.externalTestViews.keys(),...this._views].some(({_lView:o})=>TN(o))))break}}attachView(n){const r=n;this._views.push(r),r.attachToAppRef(this)}detachView(n){const r=n;LA(this._views,r),r.detachFromAppRef()}_loadComponent(n){this.attachView(n.hostView),this.tick(),this.components.push(n);const r=this._injector.get(OA,[]);[...this._bootstrapListeners,...r].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),()=>LA(this._destroyListeners,n)}destroy(){if(this._destroyed)throw new It(406,!1);const n=this._injector;n.destroy&&!n.destroyed&&n.destroy()}get viewCount(){return this._views.length}warnIfDestroyed(){}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function LA(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}function Vwe(e,t,n){!t&&!TN(e)||function zwe(e,t,n){let r;n?(r=0,e[bn]|=1024):r=64&e[bn]?0:1,nA(e,t,r)}(e,n,t)}function TN(e){return QM(e)}class Gwe{constructor(t,n){this.ngModuleFactory=t,this.componentFactories=n}}let SY=(()=>{class e{compileModuleSync(n){return new Bk(n)}compileModuleAsync(n){return Promise.resolve(this.compileModuleSync(n))}compileModuleAndAllComponentsSync(n){const r=this.compileModuleSync(n),o=Qc(sa(n).declarations).reduce((s,a)=>{const c=dr(a);return c&&s.push(new J_(c)),s},[]);return new Gwe(r,o)}compileModuleAndAllComponentsAsync(n){return Promise.resolve(this.compileModuleAndAllComponentsSync(n))}clearCache(){}clearCacheFor(n){}getModuleId(n){}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})(),qwe=(()=>{class e{constructor(){this.zone=bt(Qr),this.applicationRef=bt(Oh)}initialize(){this._onMicrotaskEmptySubscription||(this._onMicrotaskEmptySubscription=this.zone.onMicrotaskEmpty.subscribe({next:()=>{this.zone.run(()=>{this.applicationRef.tick()})}}))}ngOnDestroy(){this._onMicrotaskEmptySubscription?.unsubscribe()}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function wY(e){return[{provide:Qr,useFactory:e},{provide:og,multi:!0,useFactory:()=>{const t=bt(qwe,{optional:!0});return()=>t.initialize()}},{provide:og,multi:!0,useFactory:()=>{const t=bt(Ywe);return()=>{t.initialize()}}},{provide:X9,useFactory:Wwe}]}function Wwe(){const e=bt(Qr),t=bt(Ld);return n=>e.runOutsideAngular(()=>t.handleError(n))}function $we(e){return Iy([[],wY(()=>new Qr(function AY(e){return{enableLongStackTrace:!1,shouldCoalesceEventChangeDetection:e?.eventCoalescing??!1,shouldCoalesceRunChangeDetection:e?.runCoalescing??!1}}(e)))])}let Ywe=(()=>{class e{constructor(){this.subscription=new Fa,this.initialized=!1,this.zone=bt(Qr),this.pendingTasks=bt(kh)}initialize(){if(this.initialized)return;this.initialized=!0;let n=null;!this.zone.isStable&&!this.zone.hasPendingMacrotasks&&!this.zone.hasPendingMicrotasks&&(n=this.pendingTasks.add()),this.zone.runOutsideAngular(()=>{this.subscription.add(this.zone.onStable.subscribe(()=>{Qr.assertNotInAngularZone(),queueMicrotask(()=>{null!==n&&!this.zone.hasPendingMacrotasks&&!this.zone.hasPendingMicrotasks&&(this.pendingTasks.remove(n),n=null)})}))}),this.subscription.add(this.zone.onUnstable.subscribe(()=>{Qr.assertInAngularZone(),n??=this.pendingTasks.add()}))}ngOnDestroy(){this.subscription.unsubscribe()}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();const Zf=new Yt("",{providedIn:"root",factory:()=>bt(Zf,yr.Optional|yr.SkipSelf)||function Xwe(){return typeof $localize<"u"&&$localize.locale||mb}()}),DN=new Yt("");let Lh=null;let VA=(()=>{class e{static#e=this.__NG_ELEMENT_ID__=tAe}return e})();function tAe(e){return function nAe(e,t,n){if(cg(e)&&!n){const r=Zc(e.index,t);return new q_(r,r)}return 47&e.type?new q_(t[go],t):null}(hi(),it(),!(16&~e))}function DAe(e){try{const{rootComponent:t,appProviders:n,platformProviders:r}=e,i=function eAe(e=[]){if(Lh)return Lh;const t=function DY(e=[],t){return Sc.create({name:t,providers:[{provide:LM,useValue:"platform"},{provide:DN,useValue:new Set([()=>Lh=null])},...e]})}(e);return Lh=t,function vY(){!function f0e(e){pG=e}(()=>{throw new It(600,!1)})}(),function EY(e){e.get(yj,null)?.forEach(n=>n())}(t),t}(r),o=[$we(),...n||[]],a=new kq({providers:o,parent:i,debugName:"",runEnvironmentInitializers:!1}).injector,c=a.get(Qr);return c.run(()=>{a.resolveInjectorInitializers();const u=a.get(Ld,null);let l;c.runOutsideAngular(()=>{l=c.onError.subscribe({next:p=>{u.handleError(p)}})});const d=()=>a.destroy(),f=i.get(DN);return f.add(d),a.onDestroy(()=>{l.unsubscribe(),f.delete(d)}),function _Y(e,t,n){try{const r=n();return BA(r)?r.catch(i=>{throw t.runOutsideAngular(()=>e.handleError(i)),i}):r}catch(r){throw t.runOutsideAngular(()=>e.handleError(r)),r}}(u,c,()=>{const p=a.get(IN);return p.runInitializers(),p.donePromise.then(()=>{!function VW(e){"string"==typeof e&&(UW=e.toLowerCase().replace(/_/g,"-"))}(a.get(Zf,mb)||mb);const h=a.get(Oh);return void 0!==t&&h.bootstrap(t),h})})})}catch(t){return Promise.reject(t)}}function ON(e){return"boolean"==typeof e?e:null!=e&&"false"!==e}function aX(e){const t=sr(null);try{return e()}finally{sr(t)}}let cX=null;function vb(){return cX}class ZAe{}const tu=new Yt("");let LN=(()=>{class e{historyGo(n){throw new Error("")}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>bt(JAe),providedIn:"platform"})}return e})();const QAe=new Yt("");let JAe=(()=>{class e extends LN{constructor(){super(),this._doc=bt(tu),this._location=window.location,this._history=window.history}getBaseHrefFromDOM(){return vb().getBaseHref(this._doc)}onPopState(n){const r=vb().getGlobalEventTarget(this._doc,"window");return r.addEventListener("popstate",n,!1),()=>r.removeEventListener("popstate",n)}onHashChange(n){const r=vb().getGlobalEventTarget(this._doc,"window");return r.addEventListener("hashchange",n,!1),()=>r.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,r,i){this._history.pushState(n,r,i)}replaceState(n,r,i){this._history.replaceState(n,r,i)}forward(){this._history.forward()}back(){this._history.back()}historyGo(n=0){this._history.go(n)}getState(){return this._history.state}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>new e,providedIn:"platform"})}return e})();function UN(e,t){if(0==e.length)return t;if(0==t.length)return e;let n=0;return e.endsWith("/")&&n++,t.startsWith("/")&&n++,2==n?e+t.substring(1):1==n?e+t:e+"/"+t}function uX(e){const t=e.match(/#|\?|$/),n=t&&t.index||e.length;return e.slice(0,n-("/"===e[n-1]?1:0))+e.slice(n)}function Qf(e){return e&&"?"!==e[0]?"?"+e:e}let _g=(()=>{class e{historyGo(n){throw new Error("")}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>bt(dX),providedIn:"root"})}return e})();const lX=new Yt("");let dX=(()=>{class e extends _g{constructor(n,r){super(),this._platformLocation=n,this._removeListenerFns=[],this._baseHref=r??this._platformLocation.getBaseHrefFromDOM()??bt(tu).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 UN(this._baseHref,n)}path(n=!1){const r=this._platformLocation.pathname+Qf(this._platformLocation.search),i=this._platformLocation.hash;return i&&n?`${r}${i}`:r}pushState(n,r,i,o){const s=this.prepareExternalUrl(i+Qf(o));this._platformLocation.pushState(n,r,s)}replaceState(n,r,i,o){const s=this.prepareExternalUrl(i+Qf(o));this._platformLocation.replaceState(n,r,s)}forward(){this._platformLocation.forward()}back(){this._platformLocation.back()}getState(){return this._platformLocation.getState()}historyGo(n=0){this._platformLocation.historyGo?.(n)}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(LN),Zt(lX,8))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})(),eIe=(()=>{class e extends _g{constructor(n,r){super(),this._platformLocation=n,this._baseHref="",this._removeListenerFns=[],null!=r&&(this._baseHref=r)}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}path(n=!1){const r=this._platformLocation.hash??"#";return r.length>0?r.substring(1):r}prepareExternalUrl(n){const r=UN(this._baseHref,n);return r.length>0?"#"+r:r}pushState(n,r,i,o){let s=this.prepareExternalUrl(i+Qf(o));0==s.length&&(s=this._platformLocation.pathname),this._platformLocation.pushState(n,r,s)}replaceState(n,r,i,o){let s=this.prepareExternalUrl(i+Qf(o));0==s.length&&(s=this._platformLocation.pathname),this._platformLocation.replaceState(n,r,s)}forward(){this._platformLocation.forward()}back(){this._platformLocation.back()}getState(){return this._platformLocation.getState()}historyGo(n=0){this._platformLocation.historyGo?.(n)}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(LN),Zt(lX,8))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})(),_b=(()=>{class e{constructor(n){this._subject=new Ua,this._urlChangeListeners=[],this._urlChangeSubscription=null,this._locationStrategy=n;const r=this._locationStrategy.getBaseHref();this._basePath=function rIe(e){if(new RegExp("^(https?:)?//").test(e)){const[,n]=e.split(/\/\/[^\/]+/);return n}return e}(uX(fX(r))),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,r=""){return this.path()==this.normalize(n+Qf(r))}normalize(n){return e.stripTrailingSlash(function nIe(e,t){if(!e||!t.startsWith(e))return t;const n=t.substring(e.length);return""===n||["/",";","?","#"].includes(n[0])?n:t}(this._basePath,fX(n)))}prepareExternalUrl(n){return n&&"/"!==n[0]&&(n="/"+n),this._locationStrategy.prepareExternalUrl(n)}go(n,r="",i=null){this._locationStrategy.pushState(i,"",n,r),this._notifyUrlChangeListeners(this.prepareExternalUrl(n+Qf(r)),i)}replaceState(n,r="",i=null){this._locationStrategy.replaceState(i,"",n,r),this._notifyUrlChangeListeners(this.prepareExternalUrl(n+Qf(r)),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.subscribe(r=>{this._notifyUrlChangeListeners(r.url,r.state)}),()=>{const r=this._urlChangeListeners.indexOf(n);this._urlChangeListeners.splice(r,1),0===this._urlChangeListeners.length&&(this._urlChangeSubscription?.unsubscribe(),this._urlChangeSubscription=null)}}_notifyUrlChangeListeners(n="",r){this._urlChangeListeners.forEach(i=>i(n,r))}subscribe(n,r,i){return this._subject.subscribe({next:n,error:r,complete:i})}static#e=this.normalizeQueryParams=Qf;static#t=this.joinWithSlash=UN;static#n=this.stripTrailingSlash=uX;static#r=this.\u0275fac=function(r){return new(r||e)(Zt(_g))};static#i=this.\u0275prov=Gt({token:e,factory:()=>function tIe(){return new _b(Zt(_g))}(),providedIn:"root"})}return e})();function fX(e){return e.replace(/\/index.html$/,"")}function xX(e,t){t=encodeURIComponent(t);for(const n of e.split(";")){const r=n.indexOf("="),[i,o]=-1==r?[n,""]:[n.slice(0,r),n.slice(r+1)];if(i.trim()===t)return decodeURIComponent(o)}return null}class KIe{createSubscription(t,n){return aX(()=>t.subscribe({next:n,error:r=>{throw r}}))}dispose(t){aX(()=>t.unsubscribe())}}class ZIe{createSubscription(t,n){return t.then(n,r=>{throw r})}dispose(t){}}const QIe=new ZIe,JIe=new KIe;let Cx=(()=>{class e{constructor(n){this._latestValue=null,this.markForCheckOnValueUpdate=!0,this._subscription=null,this._obj=null,this._strategy=null,this._ref=n}ngOnDestroy(){this._subscription&&this._dispose(),this._ref=null}transform(n){if(!this._obj){if(n)try{this.markForCheckOnValueUpdate=!1,this._subscribe(n)}finally{this.markForCheckOnValueUpdate=!0}return this._latestValue}return n!==this._obj?(this._dispose(),this.transform(n)):this._latestValue}_subscribe(n){this._obj=n,this._strategy=this._selectStrategy(n),this._subscription=this._strategy.createSubscription(n,r=>this._updateLatestValue(n,r))}_selectStrategy(n){if(BA(n))return QIe;if(bY(n))return JIe;throw function Wl(e,t){return new It(2100,!1)}()}_dispose(){this._strategy.dispose(this._subscription),this._latestValue=null,this._subscription=null,this._obj=null}_updateLatestValue(n,r){n===this._obj&&(this._latestValue=r,this.markForCheckOnValueUpdate&&this._ref?.markForCheck())}static#e=this.\u0275fac=function(r){return new(r||e)(cn(VA,16))};static#t=this.\u0275pipe=_c({name:"async",type:e,pure:!1,standalone:!0})}return e})(),sI=(()=>{class e{transform(n){return JSON.stringify(n,null,2)}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275pipe=_c({name:"json",type:e,pure:!1,standalone:!0})}return e})(),Uh=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275mod=p_({type:e});static#n=this.\u0275inj=Sy({})}return e})();const DX="browser";function EX(e){return"server"===e}let _Te=(()=>{class e{static#e=this.\u0275prov=Gt({token:e,providedIn:"root",factory:()=>function vTe(e){return e===DX}(bt(Th))?new xTe(bt(tu),window):new CTe})}return e})();class xTe{constructor(t,n){this.document=t,this.window=n,this.offset=()=>[0,0]}setOffset(t){this.offset=Array.isArray(t)?()=>t:t}getScrollPosition(){return[this.window.scrollX,this.window.scrollY]}scrollToPosition(t){this.window.scrollTo(t[0],t[1])}scrollToAnchor(t){const n=function STe(e,t){const n=e.getElementById(t)||e.getElementsByName(t)[0];if(n)return n;if("function"==typeof e.createTreeWalker&&e.body&&"function"==typeof e.body.attachShadow){const r=e.createTreeWalker(e.body,NodeFilter.SHOW_ELEMENT);let i=r.currentNode;for(;i;){const o=i.shadowRoot;if(o){const s=o.getElementById(t)||o.querySelector(`[name="${t}"]`);if(s)return s}i=r.nextNode()}}return null}(this.document,t);n&&(this.scrollToElement(n),n.focus())}setHistoryScrollRestoration(t){this.window.history.scrollRestoration=t}scrollToElement(t){const n=t.getBoundingClientRect(),r=n.left+this.window.pageXOffset,i=n.top+this.window.pageYOffset,o=this.offset();this.window.scrollTo(r-o[0],i-o[1])}}class CTe{setOffset(t){}getScrollPosition(){return[0,0]}scrollToPosition(t){}scrollToAnchor(t){}setHistoryScrollRestoration(t){}}class PX{}class ZTe extends ZAe{constructor(){super(...arguments),this.supportsDOMEvents=!0}}class tF extends ZTe{static makeCurrent(){!function KAe(e){cX??=e}(new tF)}onAndCancel(t,n,r){return t.addEventListener(n,r),()=>{t.removeEventListener(n,r)}}dispatchEvent(t,n){t.dispatchEvent(n)}remove(t){t.parentNode&&t.parentNode.removeChild(t)}createElement(t,n){return(n=n||this.getDefaultDocument()).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,n){return"window"===n?window:"document"===n?t:"body"===n?t.body:null}getBaseHref(t){const n=function QTe(){return Ix=Ix||document.querySelector("base"),Ix?Ix.getAttribute("href"):null}();return null==n?null:function JTe(e){return new URL(e,document.baseURI).pathname}(n)}resetBaseElement(){Ix=null}getUserAgent(){return window.navigator.userAgent}getCookie(t){return xX(document.cookie,t)}}let Ix=null,tDe=(()=>{class e{build(){return new XMLHttpRequest}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();const nF=new Yt("");let UX=(()=>{class e{constructor(n,r){this._zone=r,this._eventNameToPlugin=new Map,n.forEach(i=>{i.manager=this}),this._plugins=n.slice().reverse()}addEventListener(n,r,i){return this._findPluginFor(r).addEventListener(n,r,i)}getZone(){return this._zone}_findPluginFor(n){let r=this._eventNameToPlugin.get(n);if(r)return r;if(r=this._plugins.find(o=>o.supports(n)),!r)throw new It(5101,!1);return this._eventNameToPlugin.set(n,r),r}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(nF),Zt(Qr))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();class VX{constructor(t){this._doc=t}}const rF="ng-app-id";let zX=(()=>{class e{constructor(n,r,i,o={}){this.doc=n,this.appId=r,this.nonce=i,this.platformId=o,this.styleRef=new Map,this.hostNodes=new Set,this.styleNodesInDOM=this.collectServerRenderedStyles(),this.platformIsServer=EX(o),this.resetHostNodes()}addStyles(n){for(const r of n)1===this.changeUsageCount(r,1)&&this.onStyleAdded(r)}removeStyles(n){for(const r of n)this.changeUsageCount(r,-1)<=0&&this.onStyleRemoved(r)}ngOnDestroy(){const n=this.styleNodesInDOM;n&&(n.forEach(r=>r.remove()),n.clear());for(const r of this.getAllStyles())this.onStyleRemoved(r);this.resetHostNodes()}addHost(n){this.hostNodes.add(n);for(const r of this.getAllStyles())this.addStyleToHost(n,r)}removeHost(n){this.hostNodes.delete(n)}getAllStyles(){return this.styleRef.keys()}onStyleAdded(n){for(const r of this.hostNodes)this.addStyleToHost(r,n)}onStyleRemoved(n){const r=this.styleRef;r.get(n)?.elements?.forEach(i=>i.remove()),r.delete(n)}collectServerRenderedStyles(){const n=this.doc.head?.querySelectorAll(`style[${rF}="${this.appId}"]`);if(n?.length){const r=new Map;return n.forEach(i=>{null!=i.textContent&&r.set(i.textContent,i)}),r}return null}changeUsageCount(n,r){const i=this.styleRef;if(i.has(n)){const o=i.get(n);return o.usage+=r,o.usage}return i.set(n,{usage:r,elements:[]}),r}getStyleElement(n,r){const i=this.styleNodesInDOM,o=i?.get(r);if(o?.parentNode===n)return i.delete(r),o.removeAttribute(rF),o;{const s=this.doc.createElement("style");return this.nonce&&s.setAttribute("nonce",this.nonce),s.textContent=r,this.platformIsServer&&s.setAttribute(rF,this.appId),n.appendChild(s),s}}addStyleToHost(n,r){const i=this.getStyleElement(n,r),o=this.styleRef,s=o.get(r)?.elements;s?s.push(i):o.set(r,{elements:[i],usage:1})}resetHostNodes(){const n=this.hostNodes;n.clear(),n.add(this.doc.head)}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tu),Zt(wR),Zt(bj,8),Zt(Th))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();const iF={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/"},oF=/%COMP%/g,oDe=new Yt("",{providedIn:"root",factory:()=>!0});function jX(e,t){return t.map(n=>n.replace(oF,e))}let HX=(()=>{class e{constructor(n,r,i,o,s,a,c,u=null){this.eventManager=n,this.sharedStylesHost=r,this.appId=i,this.removeStylesOnCompDestroy=o,this.doc=s,this.platformId=a,this.ngZone=c,this.nonce=u,this.rendererByCompId=new Map,this.platformIsServer=EX(a),this.defaultRenderer=new sF(n,s,c,this.platformIsServer)}createRenderer(n,r){if(!n||!r)return this.defaultRenderer;this.platformIsServer&&r.encapsulation===Fl.ShadowDom&&(r={...r,encapsulation:Fl.Emulated});const i=this.getOrCreateRenderer(n,r);return i instanceof WX?i.applyToHost(n):i instanceof aF&&i.applyStyles(),i}getOrCreateRenderer(n,r){const i=this.rendererByCompId;let o=i.get(r.id);if(!o){const s=this.doc,a=this.ngZone,c=this.eventManager,u=this.sharedStylesHost,l=this.removeStylesOnCompDestroy,d=this.platformIsServer;switch(r.encapsulation){case Fl.Emulated:o=new WX(c,u,r,this.appId,l,s,a,d);break;case Fl.ShadowDom:return new uDe(c,u,n,r,s,a,this.nonce,d);default:o=new aF(c,u,r,l,s,a,d)}i.set(r.id,o)}return o}ngOnDestroy(){this.rendererByCompId.clear()}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(UX),Zt(zX),Zt(wR),Zt(oDe),Zt(tu),Zt(Th),Zt(Qr),Zt(bj))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();class sF{constructor(t,n,r,i){this.eventManager=t,this.doc=n,this.ngZone=r,this.platformIsServer=i,this.data=Object.create(null),this.throwOnSyntheticProps=!0,this.destroyNode=null}destroy(){}createElement(t,n){return n?this.doc.createElementNS(iF[n]||n,t):this.doc.createElement(t)}createComment(t){return this.doc.createComment(t)}createText(t){return this.doc.createTextNode(t)}appendChild(t,n){(qX(t)?t.content:t).appendChild(n)}insertBefore(t,n,r){t&&(qX(t)?t.content:t).insertBefore(n,r)}removeChild(t,n){t&&t.removeChild(n)}selectRootElement(t,n){let r="string"==typeof t?this.doc.querySelector(t):t;if(!r)throw new It(-5104,!1);return n||(r.textContent=""),r}parentNode(t){return t.parentNode}nextSibling(t){return t.nextSibling}setAttribute(t,n,r,i){if(i){n=i+":"+n;const o=iF[i];o?t.setAttributeNS(o,n,r):t.setAttribute(n,r)}else t.setAttribute(n,r)}removeAttribute(t,n,r){if(r){const i=iF[r];i?t.removeAttributeNS(i,n):t.removeAttribute(`${r}:${n}`)}else t.removeAttribute(n)}addClass(t,n){t.classList.add(n)}removeClass(t,n){t.classList.remove(n)}setStyle(t,n,r,i){i&(Ph.DashCase|Ph.Important)?t.style.setProperty(n,r,i&Ph.Important?"important":""):t.style[n]=r}removeStyle(t,n,r){r&Ph.DashCase?t.style.removeProperty(n):t.style[n]=""}setProperty(t,n,r){null!=t&&(t[n]=r)}setValue(t,n){t.nodeValue=n}listen(t,n,r){if("string"==typeof t&&!(t=vb().getGlobalEventTarget(this.doc,t)))throw new Error(`Unsupported event target ${t} for event ${n}`);return this.eventManager.addEventListener(t,n,this.decoratePreventDefault(r))}decoratePreventDefault(t){return n=>{if("__ngUnwrap__"===n)return t;!1===(this.platformIsServer?this.ngZone.runGuarded(()=>t(n)):t(n))&&n.preventDefault()}}}function qX(e){return"TEMPLATE"===e.tagName&&void 0!==e.content}class uDe extends sF{constructor(t,n,r,i,o,s,a,c){super(t,o,s,c),this.sharedStylesHost=n,this.hostEl=r,this.shadowRoot=r.attachShadow({mode:"open"}),this.sharedStylesHost.addHost(this.shadowRoot);const u=jX(i.id,i.styles);for(const l of u){const d=document.createElement("style");a&&d.setAttribute("nonce",a),d.textContent=l,this.shadowRoot.appendChild(d)}}nodeOrShadowRoot(t){return t===this.hostEl?this.shadowRoot:t}appendChild(t,n){return super.appendChild(this.nodeOrShadowRoot(t),n)}insertBefore(t,n,r){return super.insertBefore(this.nodeOrShadowRoot(t),n,r)}removeChild(t,n){return super.removeChild(this.nodeOrShadowRoot(t),n)}parentNode(t){return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(t)))}destroy(){this.sharedStylesHost.removeHost(this.shadowRoot)}}class aF extends sF{constructor(t,n,r,i,o,s,a,c){super(t,o,s,a),this.sharedStylesHost=n,this.removeStylesOnCompDestroy=i,this.styles=c?jX(c,r.styles):r.styles}applyStyles(){this.sharedStylesHost.addStyles(this.styles)}destroy(){this.removeStylesOnCompDestroy&&this.sharedStylesHost.removeStyles(this.styles)}}class WX extends aF{constructor(t,n,r,i,o,s,a,c){const u=i+"-"+r.id;super(t,n,r,o,s,a,c,u),this.contentAttr=function sDe(e){return"_ngcontent-%COMP%".replace(oF,e)}(u),this.hostAttr=function aDe(e){return"_nghost-%COMP%".replace(oF,e)}(u)}applyToHost(t){this.applyStyles(),this.setAttribute(t,this.hostAttr,"")}createElement(t,n){const r=super.createElement(t,n);return super.setAttribute(r,this.contentAttr,""),r}}let lDe=(()=>{class e extends VX{constructor(n){super(n)}supports(n){return!0}addEventListener(n,r,i){return n.addEventListener(r,i,!1),()=>this.removeEventListener(n,r,i)}removeEventListener(n,r,i){return n.removeEventListener(r,i)}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tu))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();const $X=["alt","control","meta","shift"],dDe={"\b":"Backspace","\t":"Tab","\x7f":"Delete","\x1b":"Escape",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown",Menu:"ContextMenu",Scroll:"ScrollLock",Win:"OS"},fDe={alt:e=>e.altKey,control:e=>e.ctrlKey,meta:e=>e.metaKey,shift:e=>e.shiftKey};let pDe=(()=>{class e extends VX{constructor(n){super(n)}supports(n){return null!=e.parseEventName(n)}addEventListener(n,r,i){const o=e.parseEventName(r),s=e.eventCallback(o.fullKey,i,this.manager.getZone());return this.manager.getZone().runOutsideAngular(()=>vb().onAndCancel(n,o.domEventName,s))}static parseEventName(n){const r=n.toLowerCase().split("."),i=r.shift();if(0===r.length||"keydown"!==i&&"keyup"!==i)return null;const o=e._normalizeKey(r.pop());let s="",a=r.indexOf("code");if(a>-1&&(r.splice(a,1),s="code."),$X.forEach(u=>{const l=r.indexOf(u);l>-1&&(r.splice(l,1),s+=u+".")}),s+=o,0!=r.length||0===o.length)return null;const c={};return c.domEventName=i,c.fullKey=s,c}static matchEventFullKeyCode(n,r){let i=dDe[n.key]||n.key,o="";return r.indexOf("code.")>-1&&(i=n.code,o="code."),!(null==i||!i)&&(i=i.toLowerCase()," "===i?i="space":"."===i&&(i="dot"),$X.forEach(s=>{s!==i&&(0,fDe[s])(n)&&(o+=s+".")}),o+=i,o===r)}static eventCallback(n,r,i){return o=>{e.matchEventFullKeyCode(o,n)&&i.runGuarded(()=>r(o))}}static _normalizeKey(n){return"esc"===n?"escape":n}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tu))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();function YX(e){return{appProviders:[..._De,...e?.providers??[]],platformProviders:bDe}}const bDe=[{provide:Th,useValue:DX},{provide:yj,useValue:function mDe(){tF.makeCurrent()},multi:!0},{provide:tu,useFactory:function yDe(){return function ive(e){CR=e}(document),document},deps:[]}],_De=[{provide:LM,useValue:"root"},{provide:Ld,useFactory:function gDe(){return new Ld},deps:[]},{provide:nF,useClass:lDe,multi:!0,deps:[tu,Qr,Th]},{provide:nF,useClass:pDe,multi:!0,deps:[tu]},HX,zX,UX,{provide:VH,useExisting:HX},{provide:PX,useClass:tDe,deps:[]},[]];let xDe=(()=>{class e{constructor(n){this._doc=n}getTitle(){return this._doc.title}setTitle(n){this._doc.title=n||""}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tu))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function Vh(e){return this instanceof Vh?(this.v=e,this):new Vh(e)}function tK(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,t=e[Symbol.asyncIterator];return t?t.call(e):(e=function dF(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(s){return new Promise(function(a,c){!function i(o,s,a,c){Promise.resolve(c).then(function(u){o({value:u,done:a})},s)}(a,c,(s=e[o](s)).done,s.value)})}}}"function"==typeof SuppressedError&&SuppressedError;const nK=e=>e&&"number"==typeof e.length&&"function"!=typeof e;function rK(e){return Wi(e?.then)}function iK(e){return Wi(e[hM])}function oK(e){return Symbol.asyncIterator&&Wi(e?.[Symbol.asyncIterator])}function sK(e){return new TypeError(`You provided ${null!==e&&"object"==typeof e?"an invalid object":`'${e}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}const aK=function $De(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}();function cK(e){return Wi(e?.[aK])}function uK(e){return function eK(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(e,t||[]),o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(f){r[f]&&(i[f]=function(p){return new Promise(function(m,h){o.push([f,p,m,h])>1||a(f,p)})})}function a(f,p){try{!function c(f){f.value instanceof Vh?Promise.resolve(f.value.v).then(u,l):d(o[0][2],f)}(r[f](p))}catch(m){d(o[0][3],m)}}function u(f){a("next",f)}function l(f){a("throw",f)}function d(f,p){f(p),o.shift(),o.length&&a(o[0][0],o[0][1])}}(this,arguments,function*(){const n=e.getReader();try{for(;;){const{value:r,done:i}=yield Vh(n.read());if(i)return yield Vh(void 0);yield yield Vh(r)}}finally{n.releaseLock()}})}function lK(e){return Wi(e?.getReader)}function ru(e){if(e instanceof ns)return e;if(null!=e){if(iK(e))return function YDe(e){return new ns(t=>{const n=e[hM]();if(Wi(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}(e);if(nK(e))return function XDe(e){return new ns(t=>{for(let n=0;n{e.then(n=>{t.closed||(t.next(n),t.complete())},n=>t.error(n)).then(null,vG)})}(e);if(oK(e))return dK(e);if(cK(e))return function ZDe(e){return new ns(t=>{for(const n of e)if(t.next(n),t.closed)return;t.complete()})}(e);if(lK(e))return function QDe(e){return dK(uK(e))}(e)}throw sK(e)}function dK(e){return new ns(t=>{(function JDe(e,t){var n,r,i,o;return function QX(e,t,n,r){return new(n||(n=Promise))(function(o,s){function a(l){try{u(r.next(l))}catch(d){s(d)}}function c(l){try{u(r.throw(l))}catch(d){s(d)}}function u(l){l.done?o(l.value):function i(o){return o instanceof n?o:new n(function(s){s(o)})}(l.value).then(a,c)}u((r=r.apply(e,t||[])).next())})}(this,void 0,void 0,function*(){try{for(n=tK(e);!(r=yield n.next()).done;)if(t.next(r.value),t.closed)return}catch(s){i={error:s}}finally{try{r&&!r.done&&(o=n.return)&&(yield o.call(n))}finally{if(i)throw i.error}}t.complete()})})(e,t).catch(n=>t.error(n))})}function tp(e,t,n,r=0,i=!1){const o=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(o),!i)return o}function fK(e,t=0){return mo((n,r)=>{n.subscribe(Io(r,i=>tp(r,e,()=>r.next(i),t),()=>tp(r,e,()=>r.complete(),t),i=>tp(r,e,()=>r.error(i),t)))})}function pK(e,t=0){return mo((n,r)=>{r.add(e.schedule(()=>n.subscribe(r),t))})}function hK(e,t){if(!e)throw new Error("Iterable cannot be null");return new ns(n=>{tp(n,t,()=>{const r=e[Symbol.asyncIterator]();tp(n,t,()=>{r.next().then(i=>{i.done?n.complete():n.next(i.value)})},0,!0)})})}function $i(e,t){return t?function oEe(e,t){if(null!=e){if(iK(e))return function eEe(e,t){return ru(e).pipe(pK(t),fK(t))}(e,t);if(nK(e))return function nEe(e,t){return new ns(n=>{let r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}(e,t);if(rK(e))return function tEe(e,t){return ru(e).pipe(pK(t),fK(t))}(e,t);if(oK(e))return hK(e,t);if(cK(e))return function rEe(e,t){return new ns(n=>{let r;return tp(n,t,()=>{r=e[aK](),tp(n,t,()=>{let i,o;try{({value:i,done:o}=r.next())}catch(s){return void n.error(s)}o?n.complete():n.next(i)},0,!0)}),()=>Wi(r?.return)&&r.return()})}(e,t);if(lK(e))return function iEe(e,t){return hK(uK(e),t)}(e,t)}throw sK(e)}(e,t):ru(e)}function mK(e){return e&&Wi(e.schedule)}function fF(e){return e[e.length-1]}function gK(e){return Wi(fF(e))?e.pop():void 0}function Sb(e){return mK(fF(e))?e.pop():void 0}function yK(e,t){return"number"==typeof fF(e)?e.pop():t}function Pn(...e){return $i(e,Sb(e))}const{isArray:sEe}=Array,{getPrototypeOf:aEe,prototype:cEe,keys:uEe}=Object;const{isArray:fEe}=Array;function bK(e){return qt(t=>function pEe(e,t){return fEe(t)?e(...t):e(t)}(e,t))}function uI(...e){const t=Sb(e),n=gK(e),{args:r,keys:i}=function lEe(e){if(1===e.length){const t=e[0];if(sEe(t))return{args:t,keys:null};if(function dEe(e){return e&&"object"==typeof e&&aEe(e)===cEe}(t)){const n=uEe(t);return{args:n.map(r=>t[r]),keys:n}}}return{args:e,keys:null}}(e);if(0===r.length)return $i([],t);const o=new ns(vK(r,t,i?s=>function hEe(e,t){return e.reduce((n,r,i)=>(n[r]=t[i],n),{})}(i,s):vh));return n?o.pipe(bK(n)):o}function vK(e,t,n=vh){return r=>{_K(t,()=>{const{length:i}=e,o=new Array(i);let s=i,a=i;for(let c=0;c{const u=$i(e[c],t);let l=!1;u.subscribe(Io(r,d=>{o[c]=d,l||(l=!0,a--),a||r.next(n(o.slice()))},()=>{--s||r.complete()}))},r)},r)}}function _K(e,t,n){e?tp(n,e,t):t()}const lI=aM(e=>function(){e(this),this.name="EmptyError",this.message="no elements in sequence"});function fa(e,t,n=1/0){return Wi(t)?fa((r,i)=>qt((o,s)=>t(r,o,i,s))(ru(e(r,i))),n):("number"==typeof t&&(n=t),mo((r,i)=>function mEe(e,t,n,r,i,o,s,a){const c=[];let u=0,l=0,d=!1;const f=()=>{d&&!c.length&&!u&&t.complete()},p=h=>u{o&&t.next(h),u++;let g=!1;ru(n(h,l++)).subscribe(Io(t,y=>{i?.(y),o?p(y):t.next(y)},()=>{g=!0},void 0,()=>{if(g)try{for(u--;c.length&&um(y)):m(y)}f()}catch(y){t.error(y)}}))};return e.subscribe(Io(t,p,()=>{d=!0,f()})),()=>{a?.()}}(r,i,e,n)))}function xg(e=1/0){return fa(vh,e)}function pF(...e){return function gEe(){return xg(1)}()($i(e,Sb(e)))}function xK(e){return new ns(t=>{ru(e()).subscribe(t)})}function dI(e,t){const n=Wi(e)?e:()=>e,r=i=>i.error(n());return new ns(t?i=>t.schedule(r,0,i):r)}const $l=new ns(e=>e.complete());function hF(){return mo((e,t)=>{let n=null;e._refCount++;const r=Io(t,void 0,void 0,void 0,()=>{if(!e||e._refCount<=0||0<--e._refCount)return void(n=null);const i=e._connection,o=n;n=null,i&&(!o||i===o)&&i.unsubscribe(),t.unsubscribe()});e.subscribe(r),r.closed||(n=e.connect())})}class SK extends ns{constructor(t,n){super(),this.source=t,this.subjectFactory=n,this._subject=null,this._refCount=0,this._connection=null,wG(t)&&(this.lift=t.lift)}_subscribe(t){return this.getSubject().subscribe(t)}getSubject(){const t=this._subject;return(!t||t.isStopped)&&(this._subject=this.subjectFactory()),this._subject}_teardown(){this._refCount=0;const{_connection:t}=this;this._subject=this._connection=null,t?.unsubscribe()}connect(){let t=this._connection;if(!t){t=this._connection=new Fa;const n=this.getSubject();t.add(this.source.subscribe(Io(n,void 0,()=>{this._teardown(),n.complete()},r=>{this._teardown(),n.error(r)},()=>this._teardown()))),t.closed&&(this._connection=null,t=Fa.EMPTY)}return t}refCount(){return hF()(this)}}function To(e,t){return mo((n,r)=>{let i=null,o=0,s=!1;const a=()=>s&&!i&&r.complete();n.subscribe(Io(r,c=>{i?.unsubscribe();let u=0;const l=o++;ru(e(c,l)).subscribe(i=Io(r,d=>r.next(t?t(c,d,l,u++):d),()=>{i=null,a()}))},()=>{s=!0,a()}))})}function Sg(e){return e<=0?()=>$l:mo((t,n)=>{let r=0;t.subscribe(Io(n,i=>{++r<=e&&(n.next(i),e<=r&&n.complete())}))})}function Dx(...e){const t=Sb(e);return mo((n,r)=>{(t?pF(e,n,t):pF(e,n)).subscribe(r)})}function Yl(e,t){return mo((n,r)=>{let i=0;n.subscribe(Io(r,o=>e.call(t,o,i++)&&r.next(o)))})}function fI(e){return mo((t,n)=>{let r=!1;t.subscribe(Io(n,i=>{r=!0,n.next(i)},()=>{r||n.next(e),n.complete()}))})}function CK(e=bEe){return mo((t,n)=>{let r=!1;t.subscribe(Io(n,i=>{r=!0,n.next(i)},()=>r?n.complete():n.error(e())))})}function bEe(){return new lI}function Cg(e,t){const n=arguments.length>=2;return r=>r.pipe(e?Yl((i,o)=>e(i,o,r)):vh,Sg(1),n?fI(t):CK(()=>new lI))}function Cb(e,t){return Wi(t)?fa(e,t,1):fa(e,1)}function jr(e,t,n){const r=Wi(e)||t||n?{next:e,error:t,complete:n}:e;return r?mo((i,o)=>{var s;null===(s=r.subscribe)||void 0===s||s.call(r);let a=!0;i.subscribe(Io(o,c=>{var u;null===(u=r.next)||void 0===u||u.call(r,c),o.next(c)},()=>{var c;a=!1,null===(c=r.complete)||void 0===c||c.call(r),o.complete()},c=>{var u;a=!1,null===(u=r.error)||void 0===u||u.call(r,c),o.error(c)},()=>{var c,u;a&&(null===(c=r.unsubscribe)||void 0===c||c.call(r)),null===(u=r.finalize)||void 0===u||u.call(r)}))}):vh}function wb(e){return mo((t,n)=>{let o,r=null,i=!1;r=t.subscribe(Io(n,void 0,void 0,s=>{o=ru(e(s,wb(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,o.subscribe(n))})}function mF(e){return e<=0?()=>$l:mo((t,n)=>{let r=[];t.subscribe(Io(n,i=>{r.push(i),e{for(const i of r)n.next(i);n.complete()},void 0,()=>{r=null}))})}function Ex(e){return mo((t,n)=>{try{t.subscribe(n)}finally{n.add(e)}})}const rr="primary",Px=Symbol("RouteTitle");class wEe{constructor(t){this.params=t||{}}has(t){return Object.prototype.hasOwnProperty.call(this.params,t)}get(t){if(this.has(t)){const n=this.params[t];return Array.isArray(n)?n[0]:n}return null}getAll(t){if(this.has(t)){const n=this.params[t];return Array.isArray(n)?n:[n]}return[]}get keys(){return Object.keys(this.params)}}function Ab(e){return new wEe(e)}function AEe(e,t,n){const r=n.path.split("/");if(r.length>e.length||"full"===n.pathMatch&&(t.hasChildren()||r.lengthr[o]===i)}return e===t}function AK(e){return e.length>0?e[e.length-1]:null}function zh(e){return function ADe(e){return!!e&&(e instanceof ns||Wi(e.lift)&&Wi(e.subscribe))}(e)?e:BA(e)?$i(Promise.resolve(e)):Pn(e)}const TEe={exact:function DK(e,t,n){if(!wg(e.segments,t.segments)||!pI(e.segments,t.segments,n)||e.numberOfChildren!==t.numberOfChildren)return!1;for(const r in t.children)if(!e.children[r]||!DK(e.children[r],t.children[r],n))return!1;return!0},subset:EK},IK={exact:function DEe(e,t){return Hd(e,t)},subset:function EEe(e,t){return Object.keys(t).length<=Object.keys(e).length&&Object.keys(t).every(n=>wK(e[n],t[n]))},ignored:()=>!0};function TK(e,t,n){return TEe[n.paths](e.root,t.root,n.matrixParams)&&IK[n.queryParams](e.queryParams,t.queryParams)&&!("exact"===n.fragment&&e.fragment!==t.fragment)}function EK(e,t,n){return PK(e,t,t.segments,n)}function PK(e,t,n,r){if(e.segments.length>n.length){const i=e.segments.slice(0,n.length);return!(!wg(i,n)||t.hasChildren()||!pI(i,n,r))}if(e.segments.length===n.length){if(!wg(e.segments,n)||!pI(e.segments,n,r))return!1;for(const i in t.children)if(!e.children[i]||!EK(e.children[i],t.children[i],r))return!1;return!0}{const i=n.slice(0,e.segments.length),o=n.slice(e.segments.length);return!!(wg(e.segments,i)&&pI(e.segments,i,r)&&e.children[rr])&&PK(e.children[rr],t,o,r)}}function pI(e,t,n){return t.every((r,i)=>IK[n](e[i].parameters,r.parameters))}class Ib{constructor(t=new xi([],{}),n={},r=null){this.root=t,this.queryParams=n,this.fragment=r}get queryParamMap(){return this._queryParamMap??=Ab(this.queryParams),this._queryParamMap}toString(){return REe.serialize(this)}}class xi{constructor(t,n){this.segments=t,this.children=n,this.parent=null,Object.values(n).forEach(r=>r.parent=this)}hasChildren(){return this.numberOfChildren>0}get numberOfChildren(){return Object.keys(this.children).length}toString(){return hI(this)}}class Mx{constructor(t,n){this.path=t,this.parameters=n}get parameterMap(){return this._parameterMap??=Ab(this.parameters),this._parameterMap}toString(){return kK(this)}}function wg(e,t){return e.length===t.length&&e.every((n,r)=>n.path===t[r].path)}let Tb=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>new yF,providedIn:"root"})}return e})();class yF{parse(t){const n=new jEe(t);return new Ib(n.parseRootSegment(),n.parseQueryParams(),n.parseFragment())}serialize(t){const n=`/${Rx(t.root,!0)}`,r=function FEe(e){const t=Object.entries(e).map(([n,r])=>Array.isArray(r)?r.map(i=>`${mI(n)}=${mI(i)}`).join("&"):`${mI(n)}=${mI(r)}`).filter(n=>n);return t.length?`?${t.join("&")}`:""}(t.queryParams);return`${n}${r}${"string"==typeof t.fragment?`#${function kEe(e){return encodeURI(e)}(t.fragment)}`:""}`}}const REe=new yF;function hI(e){return e.segments.map(t=>kK(t)).join("/")}function Rx(e,t){if(!e.hasChildren())return hI(e);if(t){const n=e.children[rr]?Rx(e.children[rr],!1):"",r=[];return Object.entries(e.children).forEach(([i,o])=>{i!==rr&&r.push(`${i}:${Rx(o,!1)}`)}),r.length>0?`${n}(${r.join("//")})`:n}{const n=function MEe(e,t){let n=[];return Object.entries(e.children).forEach(([r,i])=>{r===rr&&(n=n.concat(t(i,r)))}),Object.entries(e.children).forEach(([r,i])=>{r!==rr&&(n=n.concat(t(i,r)))}),n}(e,(r,i)=>i===rr?[Rx(e.children[rr],!1)]:[`${i}:${Rx(r,!1)}`]);return 1===Object.keys(e.children).length&&null!=e.children[rr]?`${hI(e)}/${n[0]}`:`${hI(e)}/(${n.join("//")})`}}function MK(e){return encodeURIComponent(e).replace(/%40/g,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",")}function mI(e){return MK(e).replace(/%3B/gi,";")}function bF(e){return MK(e).replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/%26/gi,"&")}function gI(e){return decodeURIComponent(e)}function RK(e){return gI(e.replace(/\+/g,"%20"))}function kK(e){return`${bF(e.path)}${function NEe(e){return Object.entries(e).map(([t,n])=>`;${bF(t)}=${bF(n)}`).join("")}(e.parameters)}`}const BEe=/^[^\/()?;#]+/;function vF(e){const t=e.match(BEe);return t?t[0]:""}const OEe=/^[^\/()?;=#]+/,UEe=/^[^=?&#]+/,zEe=/^[^&#]+/;class jEe{constructor(t){this.url=t,this.remaining=t}parseRootSegment(){return this.consumeOptional("/"),""===this.remaining||this.peekStartsWith("?")||this.peekStartsWith("#")?new xi([],{}):new xi([],this.parseChildren())}parseQueryParams(){const 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("/");const t=[];for(this.peekStartsWith("(")||t.push(this.parseSegment());this.peekStartsWith("/")&&!this.peekStartsWith("//")&&!this.peekStartsWith("/(");)this.capture("/"),t.push(this.parseSegment());let n={};this.peekStartsWith("/(")&&(this.capture("/"),n=this.parseParens(!0));let r={};return this.peekStartsWith("(")&&(r=this.parseParens(!1)),(t.length>0||Object.keys(n).length>0)&&(r[rr]=new xi(t,n)),r}parseSegment(){const t=vF(this.remaining);if(""===t&&this.peekStartsWith(";"))throw new It(4009,!1);return this.capture(t),new Mx(gI(t),this.parseMatrixParams())}parseMatrixParams(){const t={};for(;this.consumeOptional(";");)this.parseParam(t);return t}parseParam(t){const n=function LEe(e){const t=e.match(OEe);return t?t[0]:""}(this.remaining);if(!n)return;this.capture(n);let r="";if(this.consumeOptional("=")){const i=vF(this.remaining);i&&(r=i,this.capture(r))}t[gI(n)]=gI(r)}parseQueryParam(t){const n=function VEe(e){const t=e.match(UEe);return t?t[0]:""}(this.remaining);if(!n)return;this.capture(n);let r="";if(this.consumeOptional("=")){const s=function GEe(e){const t=e.match(zEe);return t?t[0]:""}(this.remaining);s&&(r=s,this.capture(r))}const i=RK(n),o=RK(r);if(t.hasOwnProperty(i)){let s=t[i];Array.isArray(s)||(s=[s],t[i]=s),s.push(o)}else t[i]=o}parseParens(t){const n={};for(this.capture("(");!this.consumeOptional(")")&&this.remaining.length>0;){const r=vF(this.remaining),i=this.remaining[r.length];if("/"!==i&&")"!==i&&";"!==i)throw new It(4010,!1);let o;r.indexOf(":")>-1?(o=r.slice(0,r.indexOf(":")),this.capture(o),this.capture(":")):t&&(o=rr);const s=this.parseChildren();n[o]=1===Object.keys(s).length?s[rr]:new xi([],s),this.consumeOptional("//")}return n}peekStartsWith(t){return this.remaining.startsWith(t)}consumeOptional(t){return!!this.peekStartsWith(t)&&(this.remaining=this.remaining.substring(t.length),!0)}capture(t){if(!this.consumeOptional(t))throw new It(4011,!1)}}function NK(e){return e.segments.length>0?new xi([],{[rr]:e}):e}function FK(e){const t={};for(const[r,i]of Object.entries(e.children)){const o=FK(i);if(r===rr&&0===o.segments.length&&o.hasChildren())for(const[s,a]of Object.entries(o.children))t[s]=a;else(o.segments.length>0||o.hasChildren())&&(t[r]=o)}return function HEe(e){if(1===e.numberOfChildren&&e.children[rr]){const t=e.children[rr];return new xi(e.segments.concat(t.segments),t.children)}return e}(new xi(e.segments,t))}function Db(e){return e instanceof Ib}function BK(e){let t;const r=function n(o){const s={};for(const c of o.children){const u=n(c);s[c.outlet]=u}const a=new xi(o.url,s);return o===e&&(t=a),a}(e.root),i=NK(r);return t??i}function OK(e,t,n,r){let i=e;for(;i.parent;)i=i.parent;if(0===t.length)return _F(i,i,i,n,r);const o=function WEe(e){if("string"==typeof e[0]&&1===e.length&&"/"===e[0])return new UK(!0,0,e);let t=0,n=!1;const r=e.reduce((i,o,s)=>{if("object"==typeof o&&null!=o){if(o.outlets){const a={};return Object.entries(o.outlets).forEach(([c,u])=>{a[c]="string"==typeof u?u.split("/"):u}),[...i,{outlets:a}]}if(o.segmentPath)return[...i,o.segmentPath]}return"string"!=typeof o?[...i,o]:0===s?(o.split("/").forEach((a,c)=>{0==c&&"."===a||(0==c&&""===a?n=!0:".."===a?t++:""!=a&&i.push(a))}),i):[...i,o]},[]);return new UK(n,t,r)}(t);if(o.toRoot())return _F(i,i,new xi([],{}),n,r);const s=function $Ee(e,t,n){if(e.isAbsolute)return new bI(t,!0,0);if(!n)return new bI(t,!1,NaN);if(null===n.parent)return new bI(n,!0,0);const r=yI(e.commands[0])?0:1;return function YEe(e,t,n){let r=e,i=t,o=n;for(;o>i;){if(o-=i,r=r.parent,!r)throw new It(4005,!1);i=r.segments.length}return new bI(r,!1,i-o)}(n,n.segments.length-1+r,e.numberOfDoubleDots)}(o,i,e),a=s.processChildren?Nx(s.segmentGroup,s.index,o.commands):VK(s.segmentGroup,s.index,o.commands);return _F(i,s.segmentGroup,a,n,r)}function yI(e){return"object"==typeof e&&null!=e&&!e.outlets&&!e.segmentPath}function kx(e){return"object"==typeof e&&null!=e&&e.outlets}function _F(e,t,n,r,i){let s,o={};r&&Object.entries(r).forEach(([c,u])=>{o[c]=Array.isArray(u)?u.map(l=>`${l}`):`${u}`}),s=e===t?n:LK(e,t,n);const a=NK(FK(s));return new Ib(a,o,i)}function LK(e,t,n){const r={};return Object.entries(e.children).forEach(([i,o])=>{r[i]=o===t?n:LK(o,t,n)}),new xi(e.segments,r)}class UK{constructor(t,n,r){if(this.isAbsolute=t,this.numberOfDoubleDots=n,this.commands=r,t&&r.length>0&&yI(r[0]))throw new It(4003,!1);const i=r.find(kx);if(i&&i!==AK(r))throw new It(4004,!1)}toRoot(){return this.isAbsolute&&1===this.commands.length&&"/"==this.commands[0]}}class bI{constructor(t,n,r){this.segmentGroup=t,this.processChildren=n,this.index=r}}function VK(e,t,n){if(e??=new xi([],{}),0===e.segments.length&&e.hasChildren())return Nx(e,t,n);const r=function KEe(e,t,n){let r=0,i=t;const o={match:!1,pathIndex:0,commandIndex:0};for(;i=n.length)return o;const s=e.segments[i],a=n[r];if(kx(a))break;const c=`${a}`,u=r0&&void 0===c)break;if(c&&u&&"object"==typeof u&&void 0===u.outlets){if(!GK(c,u,s))return o;r+=2}else{if(!GK(c,{},s))return o;r++}i++}return{match:!0,pathIndex:i,commandIndex:r}}(e,t,n),i=n.slice(r.commandIndex);if(r.match&&r.pathIndexo!==rr)&&e.children[rr]&&1===e.numberOfChildren&&0===e.children[rr].segments.length){const o=Nx(e.children[rr],t,n);return new xi(e.segments,o.children)}return Object.entries(r).forEach(([o,s])=>{"string"==typeof s&&(s=[s]),null!==s&&(i[o]=VK(e.children[o],t,s))}),Object.entries(e.children).forEach(([o,s])=>{void 0===r[o]&&(i[o]=s)}),new xi(e.segments,i)}}function xF(e,t,n){const r=e.segments.slice(0,t);let i=0;for(;i{"string"==typeof r&&(r=[r]),null!==r&&(t[n]=xF(new xi([],{}),0,r))}),t}function zK(e){const t={};return Object.entries(e).forEach(([n,r])=>t[n]=`${r}`),t}function GK(e,t,n){return e==n.path&&Hd(t,n.parameters)}const Fx="imperative";var Dr=function(e){return e[e.NavigationStart=0]="NavigationStart",e[e.NavigationEnd=1]="NavigationEnd",e[e.NavigationCancel=2]="NavigationCancel",e[e.NavigationError=3]="NavigationError",e[e.RoutesRecognized=4]="RoutesRecognized",e[e.ResolveStart=5]="ResolveStart",e[e.ResolveEnd=6]="ResolveEnd",e[e.GuardsCheckStart=7]="GuardsCheckStart",e[e.GuardsCheckEnd=8]="GuardsCheckEnd",e[e.RouteConfigLoadStart=9]="RouteConfigLoadStart",e[e.RouteConfigLoadEnd=10]="RouteConfigLoadEnd",e[e.ChildActivationStart=11]="ChildActivationStart",e[e.ChildActivationEnd=12]="ChildActivationEnd",e[e.ActivationStart=13]="ActivationStart",e[e.ActivationEnd=14]="ActivationEnd",e[e.Scroll=15]="Scroll",e[e.NavigationSkipped=16]="NavigationSkipped",e}(Dr||{});class qd{constructor(t,n){this.id=t,this.url=n}}class vI extends qd{constructor(t,n,r="imperative",i=null){super(t,n),this.type=Dr.NavigationStart,this.navigationTrigger=r,this.restoredState=i}toString(){return`NavigationStart(id: ${this.id}, url: '${this.url}')`}}class np extends qd{constructor(t,n,r){super(t,n),this.urlAfterRedirects=r,this.type=Dr.NavigationEnd}toString(){return`NavigationEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}')`}}var iu=function(e){return e[e.Redirect=0]="Redirect",e[e.SupersededByNewNavigation=1]="SupersededByNewNavigation",e[e.NoDataFromResolver=2]="NoDataFromResolver",e[e.GuardRejected=3]="GuardRejected",e}(iu||{}),_I=function(e){return e[e.IgnoredSameUrlNavigation=0]="IgnoredSameUrlNavigation",e[e.IgnoredByUrlHandlingStrategy=1]="IgnoredByUrlHandlingStrategy",e}(_I||{});class Eb extends qd{constructor(t,n,r,i){super(t,n),this.reason=r,this.code=i,this.type=Dr.NavigationCancel}toString(){return`NavigationCancel(id: ${this.id}, url: '${this.url}')`}}class Pb extends qd{constructor(t,n,r,i){super(t,n),this.reason=r,this.code=i,this.type=Dr.NavigationSkipped}}class xI extends qd{constructor(t,n,r,i){super(t,n),this.error=r,this.target=i,this.type=Dr.NavigationError}toString(){return`NavigationError(id: ${this.id}, url: '${this.url}', error: ${this.error})`}}class jK extends qd{constructor(t,n,r,i){super(t,n),this.urlAfterRedirects=r,this.state=i,this.type=Dr.RoutesRecognized}toString(){return`RoutesRecognized(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}}class QEe extends qd{constructor(t,n,r,i){super(t,n),this.urlAfterRedirects=r,this.state=i,this.type=Dr.GuardsCheckStart}toString(){return`GuardsCheckStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}}class JEe extends qd{constructor(t,n,r,i,o){super(t,n),this.urlAfterRedirects=r,this.state=i,this.shouldActivate=o,this.type=Dr.GuardsCheckEnd}toString(){return`GuardsCheckEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state}, shouldActivate: ${this.shouldActivate})`}}class e3e extends qd{constructor(t,n,r,i){super(t,n),this.urlAfterRedirects=r,this.state=i,this.type=Dr.ResolveStart}toString(){return`ResolveStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}}class t3e extends qd{constructor(t,n,r,i){super(t,n),this.urlAfterRedirects=r,this.state=i,this.type=Dr.ResolveEnd}toString(){return`ResolveEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}}class n3e{constructor(t){this.route=t,this.type=Dr.RouteConfigLoadStart}toString(){return`RouteConfigLoadStart(path: ${this.route.path})`}}class r3e{constructor(t){this.route=t,this.type=Dr.RouteConfigLoadEnd}toString(){return`RouteConfigLoadEnd(path: ${this.route.path})`}}class i3e{constructor(t){this.snapshot=t,this.type=Dr.ChildActivationStart}toString(){return`ChildActivationStart(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}}class o3e{constructor(t){this.snapshot=t,this.type=Dr.ChildActivationEnd}toString(){return`ChildActivationEnd(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}}class s3e{constructor(t){this.snapshot=t,this.type=Dr.ActivationStart}toString(){return`ActivationStart(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}}class a3e{constructor(t){this.snapshot=t,this.type=Dr.ActivationEnd}toString(){return`ActivationEnd(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}}class HK{constructor(t,n,r){this.routerEvent=t,this.position=n,this.anchor=r,this.type=Dr.Scroll}toString(){return`Scroll(anchor: '${this.anchor}', position: '${this.position?`${this.position[0]}, ${this.position[1]}`:null}')`}}class SF{}class CF{constructor(t){this.url=t}}class c3e{constructor(){this.outlet=null,this.route=null,this.injector=null,this.children=new Bx,this.attachRef=null}}let Bx=(()=>{class e{constructor(){this.contexts=new Map}onChildOutletCreated(n,r){const i=this.getOrCreateContext(n);i.outlet=r,this.contexts.set(n,i)}onChildOutletDestroyed(n){const r=this.getContext(n);r&&(r.outlet=null,r.attachRef=null)}onOutletDeactivated(){const n=this.contexts;return this.contexts=new Map,n}onOutletReAttached(n){this.contexts=n}getOrCreateContext(n){let r=this.getContext(n);return r||(r=new c3e,this.contexts.set(n,r)),r}getContext(n){return this.contexts.get(n)||null}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();class qK{constructor(t){this._root=t}get root(){return this._root.value}parent(t){const n=this.pathFromRoot(t);return n.length>1?n[n.length-2]:null}children(t){const n=wF(t,this._root);return n?n.children.map(r=>r.value):[]}firstChild(t){const n=wF(t,this._root);return n&&n.children.length>0?n.children[0].value:null}siblings(t){const n=AF(t,this._root);return n.length<2?[]:n[n.length-2].children.map(i=>i.value).filter(i=>i!==t)}pathFromRoot(t){return AF(t,this._root).map(n=>n.value)}}function wF(e,t){if(e===t.value)return t;for(const n of t.children){const r=wF(e,n);if(r)return r}return null}function AF(e,t){if(e===t.value)return[t];for(const n of t.children){const r=AF(e,n);if(r.length)return r.unshift(t),r}return[]}class Xl{constructor(t,n){this.value=t,this.children=n}toString(){return`TreeNode(${this.value})`}}function Mb(e){const t={};return e&&e.children.forEach(n=>t[n.value.outlet]=n),t}class WK extends qK{constructor(t,n){super(t),this.snapshot=n,DF(this,t)}toString(){return this.snapshot.toString()}}function $K(e){const t=function u3e(e){const o=new TF([],{},{},"",{},rr,e,null,{});return new YK("",new Xl(o,[]))}(e),n=new Ao([new Mx("",{})]),r=new Ao({}),i=new Ao({}),o=new Ao({}),s=new Ao(""),a=new Rb(n,r,o,s,i,rr,e,t.root);return a.snapshot=t.root,new WK(new Xl(a,[]),t)}class Rb{constructor(t,n,r,i,o,s,a,c){this.urlSubject=t,this.paramsSubject=n,this.queryParamsSubject=r,this.fragmentSubject=i,this.dataSubject=o,this.outlet=s,this.component=a,this._futureSnapshot=c,this.title=this.dataSubject?.pipe(qt(u=>u[Px]))??Pn(void 0),this.url=t,this.params=n,this.queryParams=r,this.fragment=i,this.data=o}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.params.pipe(qt(t=>Ab(t))),this._paramMap}get queryParamMap(){return this._queryParamMap??=this.queryParams.pipe(qt(t=>Ab(t))),this._queryParamMap}toString(){return this.snapshot?this.snapshot.toString():`Future(${this._futureSnapshot})`}}function IF(e,t,n="emptyOnly"){let r;const{routeConfig:i}=e;return r=null===t||"always"!==n&&""!==i?.path&&(t.component||t.routeConfig?.loadComponent)?{params:{...e.params},data:{...e.data},resolve:{...e.data,...e._resolvedData??{}}}:{params:{...t.params,...e.params},data:{...t.data,...e.data},resolve:{...e.data,...t.data,...i?.data,...e._resolvedData}},i&&KK(i)&&(r.resolve[Px]=i.title),r}class TF{get title(){return this.data?.[Px]}constructor(t,n,r,i,o,s,a,c,u){this.url=t,this.params=n,this.queryParams=r,this.fragment=i,this.data=o,this.outlet=s,this.component=a,this.routeConfig=c,this._resolve=u}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??=Ab(this.params),this._paramMap}get queryParamMap(){return this._queryParamMap??=Ab(this.queryParams),this._queryParamMap}toString(){return`Route(url:'${this.url.map(r=>r.toString()).join("/")}', path:'${this.routeConfig?this.routeConfig.path:""}')`}}class YK extends qK{constructor(t,n){super(n),this.url=t,DF(this,n)}toString(){return XK(this._root)}}function DF(e,t){t.value._routerState=e,t.children.forEach(n=>DF(e,n))}function XK(e){const t=e.children.length>0?` { ${e.children.map(XK).join(", ")} } `:"";return`${e.value}${t}`}function EF(e){if(e.snapshot){const t=e.snapshot,n=e._futureSnapshot;e.snapshot=n,Hd(t.queryParams,n.queryParams)||e.queryParamsSubject.next(n.queryParams),t.fragment!==n.fragment&&e.fragmentSubject.next(n.fragment),Hd(t.params,n.params)||e.paramsSubject.next(n.params),function IEe(e,t){if(e.length!==t.length)return!1;for(let n=0;nHd(n.parameters,t[r].parameters))}(e.url,t.url);return n&&!(!e.parent!=!t.parent)&&(!e.parent||PF(e.parent,t.parent))}function KK(e){return"string"==typeof e.title||null===e.title}let MF=(()=>{class e{constructor(){this.activated=null,this._activatedRoute=null,this.name=rr,this.activateEvents=new Ua,this.deactivateEvents=new Ua,this.attachEvents=new Ua,this.detachEvents=new Ua,this.parentContexts=bt(Bx),this.location=bt(Gl),this.changeDetector=bt(VA),this.environmentInjector=bt(xc),this.inputBinder=bt(SI,{optional:!0}),this.supportsBindingToComponentInputs=!0}get activatedComponentRef(){return this.activated}ngOnChanges(n){if(n.name){const{firstChange:r,previousValue:i}=n.name;if(r)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;const 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 It(4012,!1);return this.activated.instance}get activatedRoute(){if(!this.activated)throw new It(4012,!1);return this._activatedRoute}get activatedRouteData(){return this._activatedRoute?this._activatedRoute.snapshot.data:{}}detach(){if(!this.activated)throw new It(4012,!1);this.location.detach();const n=this.activated;return this.activated=null,this._activatedRoute=null,this.detachEvents.emit(n.instance),n}attach(n,r){this.activated=n,this._activatedRoute=r,this.location.insert(n.hostView),this.inputBinder?.bindActivatedRouteToOutletComponent(this),this.attachEvents.emit(n.instance)}deactivate(){if(this.activated){const n=this.component;this.activated.destroy(),this.activated=null,this._activatedRoute=null,this.deactivateEvents.emit(n)}}activateWith(n,r){if(this.isActivated)throw new It(4013,!1);this._activatedRoute=n;const i=this.location,s=n.snapshot.component,a=this.parentContexts.getOrCreateContext(this.name).children,c=new l3e(n,a,i.injector);this.activated=i.createComponent(s,{index:i.length,injector:c,environmentInjector:r??this.environmentInjector}),this.changeDetector.markForCheck(),this.inputBinder?.bindActivatedRouteToOutletComponent(this),this.activateEvents.emit(this.activated.instance)}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275dir=Ba({type:e,selectors:[["router-outlet"]],inputs:{name:"name"},outputs:{activateEvents:"activate",deactivateEvents:"deactivate",attachEvents:"attach",detachEvents:"detach"},exportAs:["outlet"],standalone:!0,features:[wh]})}return e})();class l3e{constructor(t,n,r){this.route=t,this.childContexts=n,this.parent=r}get(t,n){return t===Rb?this.route:t===Bx?this.childContexts:this.parent.get(t,n)}}const SI=new Yt("");let ZK=(()=>{class e{constructor(){this.outletDataSubscriptions=new Map}bindActivatedRouteToOutletComponent(n){this.unsubscribeFromRouteData(n),this.subscribeToRouteData(n)}unsubscribeFromRouteData(n){this.outletDataSubscriptions.get(n)?.unsubscribe(),this.outletDataSubscriptions.delete(n)}subscribeToRouteData(n){const{activatedRoute:r}=n,i=uI([r.queryParams,r.params,r.data]).pipe(To(([o,s,a],c)=>(a={...o,...s,...a},0===c?Pn(a):Promise.resolve(a)))).subscribe(o=>{if(!n.isActivated||!n.activatedComponentRef||n.activatedRoute!==r||null===r.component)return void this.unsubscribeFromRouteData(n);const s=function XAe(e){const t=dr(e);if(!t)return null;const n=new J_(t);return{get selector(){return n.selector},get type(){return n.componentType},get inputs(){return n.inputs},get outputs(){return n.outputs},get ngContentSelectors(){return n.ngContentSelectors},get isStandalone(){return t.standalone},get isSignal(){return t.signals}}}(r.component);if(s)for(const{templateName:a}of s.inputs)n.activatedComponentRef.setInput(a,o[a]);else this.unsubscribeFromRouteData(n)});this.outletDataSubscriptions.set(n,i)}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();function Ox(e,t,n){if(n&&e.shouldReuseRoute(t.value,n.value.snapshot)){const r=n.value;r._futureSnapshot=t.value;const i=function f3e(e,t,n){return t.children.map(r=>{for(const i of n.children)if(e.shouldReuseRoute(r.value,i.value.snapshot))return Ox(e,r,i);return Ox(e,r)})}(e,t,n);return new Xl(r,i)}{if(e.shouldAttach(t.value)){const o=e.retrieve(t.value);if(null!==o){const s=o.route;return s.value._futureSnapshot=t.value,s.children=t.children.map(a=>Ox(e,a)),s}}const r=function p3e(e){return new Rb(new Ao(e.url),new Ao(e.params),new Ao(e.queryParams),new Ao(e.fragment),new Ao(e.data),e.outlet,e.component,e)}(t.value),i=t.children.map(o=>Ox(e,o));return new Xl(r,i)}}const QK="ngNavigationCancelingError";function JK(e,t){const{redirectTo:n,navigationBehaviorOptions:r}=Db(t)?{redirectTo:t,navigationBehaviorOptions:void 0}:t,i=eZ(!1,iu.Redirect);return i.url=n,i.navigationBehaviorOptions=r,i}function eZ(e,t){const n=new Error(`NavigationCancelingError: ${e||""}`);return n[QK]=!0,n.cancellationCode=t,n}function tZ(e){return!!e&&e[QK]}let nZ=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["ng-component"]],standalone:!0,features:[Nu],decls:1,vars:0,template:function(r,i){1&r&&gi(0,"router-outlet")},dependencies:[MF],encapsulation:2})}return e})();function RF(e){const t=e.children&&e.children.map(RF),n=t?{...e,children:t}:{...e};return!n.component&&!n.loadComponent&&(t||n.loadChildren)&&n.outlet&&n.outlet!==rr&&(n.component=nZ),n}function Wd(e){return e.outlet||rr}function Lx(e){if(!e)return null;if(e.routeConfig?._injector)return e.routeConfig._injector;for(let t=e.parent;t;t=t.parent){const n=t.routeConfig;if(n?._loadedInjector)return n._loadedInjector;if(n?._injector)return n._injector}return null}class x3e{constructor(t,n,r,i,o){this.routeReuseStrategy=t,this.futureState=n,this.currState=r,this.forwardEvent=i,this.inputBindingEnabled=o}activate(t){const n=this.futureState._root,r=this.currState?this.currState._root:null;this.deactivateChildRoutes(n,r,t),EF(this.futureState.root),this.activateChildRoutes(n,r,t)}deactivateChildRoutes(t,n,r){const i=Mb(n);t.children.forEach(o=>{const s=o.value.outlet;this.deactivateRoutes(o,i[s],r),delete i[s]}),Object.values(i).forEach(o=>{this.deactivateRouteAndItsChildren(o,r)})}deactivateRoutes(t,n,r){const i=t.value,o=n?n.value:null;if(i===o)if(i.component){const s=r.getContext(i.outlet);s&&this.deactivateChildRoutes(t,n,s.children)}else this.deactivateChildRoutes(t,n,r);else o&&this.deactivateRouteAndItsChildren(n,r)}deactivateRouteAndItsChildren(t,n){t.value.component&&this.routeReuseStrategy.shouldDetach(t.value.snapshot)?this.detachAndStoreRouteSubtree(t,n):this.deactivateRouteAndOutlet(t,n)}detachAndStoreRouteSubtree(t,n){const r=n.getContext(t.value.outlet),i=r&&t.value.component?r.children:n,o=Mb(t);for(const s of Object.values(o))this.deactivateRouteAndItsChildren(s,i);if(r&&r.outlet){const s=r.outlet.detach(),a=r.children.onOutletDeactivated();this.routeReuseStrategy.store(t.value.snapshot,{componentRef:s,route:t,contexts:a})}}deactivateRouteAndOutlet(t,n){const r=n.getContext(t.value.outlet),i=r&&t.value.component?r.children:n,o=Mb(t);for(const s of Object.values(o))this.deactivateRouteAndItsChildren(s,i);r&&(r.outlet&&(r.outlet.deactivate(),r.children.onOutletDeactivated()),r.attachRef=null,r.route=null)}activateChildRoutes(t,n,r){const i=Mb(n);t.children.forEach(o=>{this.activateRoutes(o,i[o.value.outlet],r),this.forwardEvent(new a3e(o.value.snapshot))}),t.children.length&&this.forwardEvent(new o3e(t.value.snapshot))}activateRoutes(t,n,r){const i=t.value,o=n?n.value:null;if(EF(i),i===o)if(i.component){const s=r.getOrCreateContext(i.outlet);this.activateChildRoutes(t,n,s.children)}else this.activateChildRoutes(t,n,r);else if(i.component){const s=r.getOrCreateContext(i.outlet);if(this.routeReuseStrategy.shouldAttach(i.snapshot)){const a=this.routeReuseStrategy.retrieve(i.snapshot);this.routeReuseStrategy.store(i.snapshot,null),s.children.onOutletReAttached(a.contexts),s.attachRef=a.componentRef,s.route=a.route.value,s.outlet&&s.outlet.attach(a.componentRef,a.route.value),EF(a.route.value),this.activateChildRoutes(t,null,s.children)}else{const a=Lx(i.snapshot);s.attachRef=null,s.route=i,s.injector=a,s.outlet&&s.outlet.activateWith(i,s.injector),this.activateChildRoutes(t,null,s.children)}}else this.activateChildRoutes(t,null,r)}}class rZ{constructor(t){this.path=t,this.route=this.path[this.path.length-1]}}class CI{constructor(t,n){this.component=t,this.route=n}}function S3e(e,t,n){const r=e._root;return Ux(r,t?t._root:null,n,[r.value])}function kb(e,t){const n=Symbol(),r=t.get(e,n);return r===n?"function"!=typeof e||function N0e(e){return null!==iw(e)}(e)?t.get(e):e:r}function Ux(e,t,n,r,i={canDeactivateChecks:[],canActivateChecks:[]}){const o=Mb(t);return e.children.forEach(s=>{(function w3e(e,t,n,r,i={canDeactivateChecks:[],canActivateChecks:[]}){const o=e.value,s=t?t.value:null,a=n?n.getContext(e.value.outlet):null;if(s&&o.routeConfig===s.routeConfig){const c=function A3e(e,t,n){if("function"==typeof n)return n(e,t);switch(n){case"pathParamsChange":return!wg(e.url,t.url);case"pathParamsOrQueryParamsChange":return!wg(e.url,t.url)||!Hd(e.queryParams,t.queryParams);case"always":return!0;case"paramsOrQueryParamsChange":return!PF(e,t)||!Hd(e.queryParams,t.queryParams);default:return!PF(e,t)}}(s,o,o.routeConfig.runGuardsAndResolvers);c?i.canActivateChecks.push(new rZ(r)):(o.data=s.data,o._resolvedData=s._resolvedData),Ux(e,t,o.component?a?a.children:null:n,r,i),c&&a&&a.outlet&&a.outlet.isActivated&&i.canDeactivateChecks.push(new CI(a.outlet.component,s))}else s&&Vx(t,a,i),i.canActivateChecks.push(new rZ(r)),Ux(e,null,o.component?a?a.children:null:n,r,i)})(s,o[s.value.outlet],n,r.concat([s.value]),i),delete o[s.value.outlet]}),Object.entries(o).forEach(([s,a])=>Vx(a,n.getContext(s),i)),i}function Vx(e,t,n){const r=Mb(e),i=e.value;Object.entries(r).forEach(([o,s])=>{Vx(s,i.component?t?t.children.getContext(o):null:t,n)}),n.canDeactivateChecks.push(new CI(i.component&&t&&t.outlet&&t.outlet.isActivated?t.outlet.component:null,i))}function zx(e){return"function"==typeof e}function iZ(e){return e instanceof lI||"EmptyError"===e?.name}const wI=Symbol("INITIAL_VALUE");function Nb(){return To(e=>uI(e.map(t=>t.pipe(Sg(1),Dx(wI)))).pipe(qt(t=>{for(const n of t)if(!0!==n){if(n===wI)return wI;if(!1===n||n instanceof Ib)return n}return!0}),Yl(t=>t!==wI),Sg(1)))}function oZ(e){return _G(jr(t=>{if(Db(t))throw JK(0,t)}),qt(t=>!0===t))}class kF{constructor(t){this.segmentGroup=t||null}}class NF extends Error{constructor(t){super(),this.urlTree=t}}function Fb(e){return dI(new kF(e))}class H3e{constructor(t,n){this.urlSerializer=t,this.urlTree=n}lineralizeSegments(t,n){let r=[],i=n.root;for(;;){if(r=r.concat(i.segments),0===i.numberOfChildren)return Pn(r);if(i.numberOfChildren>1||!i.children[rr])return dI(new It(4e3,!1));i=i.children[rr]}}applyRedirectCommands(t,n,r){const i=this.applyRedirectCreateUrlTree(n,this.urlSerializer.parse(n),t,r);if(n.startsWith("/"))throw new NF(i);return i}applyRedirectCreateUrlTree(t,n,r,i){const o=this.createSegmentGroup(t,n.root,r,i);return new Ib(o,this.createQueryParams(n.queryParams,this.urlTree.queryParams),n.fragment)}createQueryParams(t,n){const r={};return Object.entries(t).forEach(([i,o])=>{if("string"==typeof o&&o.startsWith(":")){const a=o.substring(1);r[i]=n[a]}else r[i]=o}),r}createSegmentGroup(t,n,r,i){const o=this.createSegments(t,n.segments,r,i);let s={};return Object.entries(n.children).forEach(([a,c])=>{s[a]=this.createSegmentGroup(t,c,r,i)}),new xi(o,s)}createSegments(t,n,r,i){return n.map(o=>o.path.startsWith(":")?this.findPosParam(t,o,i):this.findOrReturn(o,r))}findPosParam(t,n,r){const i=r[n.path.substring(1)];if(!i)throw new It(4001,!1);return i}findOrReturn(t,n){let r=0;for(const i of n){if(i.path===t.path)return n.splice(r),i;r++}return t}}const FF={matched:!1,consumedSegments:[],remainingSegments:[],parameters:{},positionalParamSegments:{}};function q3e(e,t,n,r,i){const o=BF(e,t,n);return o.matched?(r=function m3e(e,t){return e.providers&&!e._injector&&(e._injector=hA(e.providers,t,`Route: ${e.path}`)),e._injector??t}(t,r),function z3e(e,t,n,r){const i=t.canMatch;return i&&0!==i.length?Pn(i.map(s=>{const a=kb(s,e);return zh(function M3e(e){return e&&zx(e.canMatch)}(a)?a.canMatch(t,n):Md(e,()=>a(t,n)))})).pipe(Nb(),oZ()):Pn(!0)}(r,t,n).pipe(qt(s=>!0===s?o:{...FF}))):Pn(o)}function BF(e,t,n){if("**"===t.path)return function W3e(e){return{matched:!0,parameters:e.length>0?AK(e).parameters:{},consumedSegments:e,remainingSegments:[],positionalParamSegments:{}}}(n);if(""===t.path)return"full"===t.pathMatch&&(e.hasChildren()||n.length>0)?{...FF}:{matched:!0,consumedSegments:[],remainingSegments:n,parameters:{},positionalParamSegments:{}};const i=(t.matcher||AEe)(n,e,t);if(!i)return{...FF};const o={};Object.entries(i.posParams??{}).forEach(([a,c])=>{o[a]=c.path});const s=i.consumed.length>0?{...o,...i.consumed[i.consumed.length-1].parameters}:o;return{matched:!0,consumedSegments:i.consumed,remainingSegments:n.slice(i.consumed.length),parameters:s,positionalParamSegments:i.posParams??{}}}function sZ(e,t,n,r){return n.length>0&&function X3e(e,t,n){return n.some(r=>AI(e,t,r)&&Wd(r)!==rr)}(e,n,r)?{segmentGroup:new xi(t,Y3e(r,new xi(n,e.children))),slicedSegments:[]}:0===n.length&&function K3e(e,t,n){return n.some(r=>AI(e,t,r))}(e,n,r)?{segmentGroup:new xi(e.segments,$3e(e,n,r,e.children)),slicedSegments:n}:{segmentGroup:new xi(e.segments,e.children),slicedSegments:n}}function $3e(e,t,n,r){const i={};for(const o of n)if(AI(e,t,o)&&!r[Wd(o)]){const s=new xi([],{});i[Wd(o)]=s}return{...r,...i}}function Y3e(e,t){const n={};n[rr]=t;for(const r of e)if(""===r.path&&Wd(r)!==rr){const i=new xi([],{});n[Wd(r)]=i}return n}function AI(e,t,n){return(!(e.hasChildren()||t.length>0)||"full"!==n.pathMatch)&&""===n.path}class J3e{}class nPe{constructor(t,n,r,i,o,s,a){this.injector=t,this.configLoader=n,this.rootComponentType=r,this.config=i,this.urlTree=o,this.paramsInheritanceStrategy=s,this.urlSerializer=a,this.applyRedirects=new H3e(this.urlSerializer,this.urlTree),this.absoluteRedirectCount=0,this.allowRedirects=!0}noMatchError(t){return new It(4002,`'${t.segmentGroup}'`)}recognize(){const t=sZ(this.urlTree.root,[],[],this.config).segmentGroup;return this.match(t).pipe(qt(n=>{const r=new TF([],Object.freeze({}),Object.freeze({...this.urlTree.queryParams}),this.urlTree.fragment,{},rr,this.rootComponentType,null,{}),i=new Xl(r,n),o=new YK("",i),s=function qEe(e,t,n=null,r=null){return OK(BK(e),t,n,r)}(r,[],this.urlTree.queryParams,this.urlTree.fragment);return s.queryParams=this.urlTree.queryParams,o.url=this.urlSerializer.serialize(s),this.inheritParamsAndData(o._root,null),{state:o,tree:s}}))}match(t){return this.processSegmentGroup(this.injector,this.config,t,rr).pipe(wb(r=>{if(r instanceof NF)return this.urlTree=r.urlTree,this.match(r.urlTree.root);throw r instanceof kF?this.noMatchError(r):r}))}inheritParamsAndData(t,n){const r=t.value,i=IF(r,n,this.paramsInheritanceStrategy);r.params=Object.freeze(i.params),r.data=Object.freeze(i.data),t.children.forEach(o=>this.inheritParamsAndData(o,r))}processSegmentGroup(t,n,r,i){return 0===r.segments.length&&r.hasChildren()?this.processChildren(t,n,r):this.processSegment(t,n,r,r.segments,i,!0).pipe(qt(o=>o instanceof Xl?[o]:[]))}processChildren(t,n,r){const i=[];for(const o of Object.keys(r.children))"primary"===o?i.unshift(o):i.push(o);return $i(i).pipe(Cb(o=>{const s=r.children[o],a=function v3e(e,t){const n=e.filter(r=>Wd(r)===t);return n.push(...e.filter(r=>Wd(r)!==t)),n}(n,o);return this.processSegmentGroup(t,a,s,o)}),function _Ee(e,t){return mo(function vEe(e,t,n,r,i){return(o,s)=>{let a=n,c=t,u=0;o.subscribe(Io(s,l=>{const d=u++;c=a?e(c,l,d):(a=!0,l),r&&s.next(c)},i&&(()=>{a&&s.next(c),s.complete()})))}}(e,t,arguments.length>=2,!0))}((o,s)=>(o.push(...s),o)),fI(null),function xEe(e,t){const n=arguments.length>=2;return r=>r.pipe(e?Yl((i,o)=>e(i,o,r)):vh,mF(1),n?fI(t):CK(()=>new lI))}(),fa(o=>{if(null===o)return Fb(r);const s=aZ(o);return function rPe(e){e.sort((t,n)=>t.value.outlet===rr?-1:n.value.outlet===rr?1:t.value.outlet.localeCompare(n.value.outlet))}(s),Pn(s)}))}processSegment(t,n,r,i,o,s){return $i(n).pipe(Cb(a=>this.processSegmentAgainstRoute(a._injector??t,n,a,r,i,o,s).pipe(wb(c=>{if(c instanceof kF)return Pn(null);throw c}))),Cg(a=>!!a),wb(a=>{if(iZ(a))return function Q3e(e,t,n){return 0===t.length&&!e.children[n]}(r,i,o)?Pn(new J3e):Fb(r);throw a}))}processSegmentAgainstRoute(t,n,r,i,o,s,a){return function Z3e(e,t,n,r){return!!(Wd(e)===r||r!==rr&&AI(t,n,e))&&BF(t,e,n).matched}(r,i,o,s)?void 0===r.redirectTo?this.matchSegmentAgainstRoute(t,i,r,o,s):this.allowRedirects&&a?this.expandSegmentAgainstRouteUsingRedirect(t,i,n,r,o,s):Fb(i):Fb(i)}expandSegmentAgainstRouteUsingRedirect(t,n,r,i,o,s){const{matched:a,consumedSegments:c,positionalParamSegments:u,remainingSegments:l}=BF(n,i,o);if(!a)return Fb(n);i.redirectTo.startsWith("/")&&(this.absoluteRedirectCount++,this.absoluteRedirectCount>31&&(this.allowRedirects=!1));const d=this.applyRedirects.applyRedirectCommands(c,i.redirectTo,u);return this.applyRedirects.lineralizeSegments(i,d).pipe(fa(f=>this.processSegment(t,r,n,f.concat(l),s,!1)))}matchSegmentAgainstRoute(t,n,r,i,o){const s=q3e(n,r,i,t);return"**"===r.path&&(n.children={}),s.pipe(To(a=>a.matched?this.getChildConfig(t=r._injector??t,r,i).pipe(To(({routes:c})=>{const u=r._loadedInjector??t,{consumedSegments:l,remainingSegments:d,parameters:f}=a,p=new TF(l,f,Object.freeze({...this.urlTree.queryParams}),this.urlTree.fragment,function oPe(e){return e.data||{}}(r),Wd(r),r.component??r._loadedComponent??null,r,function sPe(e){return e.resolve||{}}(r)),{segmentGroup:m,slicedSegments:h}=sZ(n,l,d,c);if(0===h.length&&m.hasChildren())return this.processChildren(u,c,m).pipe(qt(y=>null===y?null:new Xl(p,y)));if(0===c.length&&0===h.length)return Pn(new Xl(p,[]));const g=Wd(r)===o;return this.processSegment(u,c,m,h,g?rr:o,!0).pipe(qt(y=>new Xl(p,y instanceof Xl?[y]:[])))})):Fb(n)))}getChildConfig(t,n,r){return n.children?Pn({routes:n.children,injector:t}):n.loadChildren?void 0!==n._loadedRoutes?Pn({routes:n._loadedRoutes,injector:n._loadedInjector}):function V3e(e,t,n,r){const i=t.canLoad;return void 0===i||0===i.length?Pn(!0):Pn(i.map(s=>{const a=kb(s,e);return zh(function T3e(e){return e&&zx(e.canLoad)}(a)?a.canLoad(t,n):Md(e,()=>a(t,n)))})).pipe(Nb(),oZ())}(t,n,r).pipe(fa(i=>i?this.configLoader.loadChildren(t,n).pipe(jr(o=>{n._loadedRoutes=o.routes,n._loadedInjector=o.injector})):function j3e(e){return dI(eZ(!1,iu.GuardRejected))}())):Pn({routes:[],injector:t})}}function iPe(e){const t=e.value.routeConfig;return t&&""===t.path}function aZ(e){const t=[],n=new Set;for(const r of e){if(!iPe(r)){t.push(r);continue}const i=t.find(o=>r.value.routeConfig===o.value.routeConfig);void 0!==i?(i.children.push(...r.children),n.add(i)):t.push(r)}for(const r of n){const i=aZ(r.children);t.push(new Xl(r.value,i))}return t.filter(r=>!n.has(r))}function cZ(e){const t=e.children.map(n=>cZ(n)).flat();return[e,...t]}function OF(e){return To(t=>{const n=e(t);return n?$i(n).pipe(qt(()=>t)):Pn(t)})}let uZ=(()=>{class e{buildTitle(n){let r,i=n.root;for(;void 0!==i;)r=this.getResolvedTitleForRoute(i)??r,i=i.children.find(o=>o.outlet===rr);return r}getResolvedTitleForRoute(n){return n.data[Px]}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>bt(fPe),providedIn:"root"})}return e})(),fPe=(()=>{class e extends uZ{constructor(n){super(),this.title=n}updateTitle(n){const r=this.buildTitle(n);void 0!==r&&this.title.setTitle(r)}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(xDe))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();const Bb=new Yt("",{providedIn:"root",factory:()=>({})}),Ob=new Yt("");let LF=(()=>{class e{constructor(){this.componentLoaders=new WeakMap,this.childrenLoaders=new WeakMap,this.compiler=bt(SY)}loadComponent(n){if(this.componentLoaders.get(n))return this.componentLoaders.get(n);if(n._loadedComponent)return Pn(n._loadedComponent);this.onLoadStartListener&&this.onLoadStartListener(n);const r=zh(n.loadComponent()).pipe(qt(lZ),jr(o=>{this.onLoadEndListener&&this.onLoadEndListener(n),n._loadedComponent=o}),Ex(()=>{this.componentLoaders.delete(n)})),i=new SK(r,()=>new mr).pipe(hF());return this.componentLoaders.set(n,i),i}loadChildren(n,r){if(this.childrenLoaders.get(r))return this.childrenLoaders.get(r);if(r._loadedRoutes)return Pn({routes:r._loadedRoutes,injector:r._loadedInjector});this.onLoadStartListener&&this.onLoadStartListener(r);const o=function pPe(e,t,n,r){return zh(e.loadChildren()).pipe(qt(lZ),fa(i=>i instanceof Rq||Array.isArray(i)?Pn(i):$i(t.compileModuleAsync(i))),qt(i=>{r&&r(e);let o,s,a=!1;return Array.isArray(i)?(s=i,!0):(o=i.create(n).injector,s=o.get(Ob,[],{optional:!0,self:!0}).flat()),{routes:s.map(RF),injector:o}}))}(r,this.compiler,n,this.onLoadEndListener).pipe(Ex(()=>{this.childrenLoaders.delete(r)})),s=new SK(o,()=>new mr).pipe(hF());return this.childrenLoaders.set(r,s),s}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function lZ(e){return function hPe(e){return e&&"object"==typeof e&&"default"in e}(e)?e.default:e}let UF=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>bt(mPe),providedIn:"root"})}return e})(),mPe=(()=>{class e{shouldProcessUrl(n){return!0}extract(n){return n}merge(n,r){return n}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();const dZ=new Yt(""),fZ=new Yt("");function gPe(e,t,n){const r=e.get(fZ),i=e.get(tu);return e.get(Qr).runOutsideAngular(()=>{if(!i.startViewTransition||r.skipNextTransition)return r.skipNextTransition=!1,Promise.resolve();let o;const s=new Promise(u=>{o=u}),a=i.startViewTransition(()=>(o(),function yPe(e){return new Promise(t=>{$H(t,{injector:e})})}(e))),{onViewTransitionCreated:c}=r;return c&&Md(e,()=>c({transition:a,from:t,to:n})),s})}let II=(()=>{class e{get hasRequestedNavigation(){return 0!==this.navigationId}constructor(){this.currentNavigation=null,this.currentTransition=null,this.lastSuccessfulNavigation=null,this.events=new mr,this.transitionAbortSubject=new mr,this.configLoader=bt(LF),this.environmentInjector=bt(xc),this.urlSerializer=bt(Tb),this.rootContexts=bt(Bx),this.location=bt(_b),this.inputBindingEnabled=null!==bt(SI,{optional:!0}),this.titleStrategy=bt(uZ),this.options=bt(Bb,{optional:!0})||{},this.paramsInheritanceStrategy=this.options.paramsInheritanceStrategy||"emptyOnly",this.urlHandlingStrategy=bt(UF),this.createViewTransition=bt(dZ,{optional:!0}),this.navigationId=0,this.afterPreactivation=()=>Pn(void 0),this.rootComponentType=null,this.configLoader.onLoadEndListener=i=>this.events.next(new r3e(i)),this.configLoader.onLoadStartListener=i=>this.events.next(new n3e(i))}complete(){this.transitions?.complete()}handleNavigationRequest(n){const r=++this.navigationId;this.transitions?.next({...this.transitions.value,...n,id:r})}setupNavigations(n,r,i){return this.transitions=new Ao({id:0,currentUrlTree:r,currentRawUrl:r,extractedUrl:this.urlHandlingStrategy.extract(r),urlAfterRedirects:this.urlHandlingStrategy.extract(r),rawUrl:r,extras:{},resolve:null,reject:null,promise:Promise.resolve(!0),source:Fx,restoredState:null,currentSnapshot:i.snapshot,targetSnapshot:null,currentRouterState:i,targetRouterState:null,guards:{canActivateChecks:[],canDeactivateChecks:[]},guardsResult:null}),this.transitions.pipe(Yl(o=>0!==o.id),qt(o=>({...o,extractedUrl:this.urlHandlingStrategy.extract(o.rawUrl)})),To(o=>{let s=!1,a=!1;return Pn(o).pipe(To(c=>{if(this.navigationId>o.id)return this.cancelNavigationTransition(o,"",iu.SupersededByNewNavigation),$l;this.currentTransition=o,this.currentNavigation={id:c.id,initialUrl:c.rawUrl,extractedUrl:c.extractedUrl,trigger:c.source,extras:c.extras,previousNavigation:this.lastSuccessfulNavigation?{...this.lastSuccessfulNavigation,previousNavigation:null}:null};const u=!n.navigated||this.isUpdatingInternalState()||this.isUpdatedBrowserUrl();if(!u&&"reload"!==(c.extras.onSameUrlNavigation??n.onSameUrlNavigation)){const d="";return this.events.next(new Pb(c.id,this.urlSerializer.serialize(c.rawUrl),d,_I.IgnoredSameUrlNavigation)),c.resolve(null),$l}if(this.urlHandlingStrategy.shouldProcessUrl(c.rawUrl))return Pn(c).pipe(To(d=>{const f=this.transitions?.getValue();return this.events.next(new vI(d.id,this.urlSerializer.serialize(d.extractedUrl),d.source,d.restoredState)),f!==this.transitions?.getValue()?$l:Promise.resolve(d)}),function aPe(e,t,n,r,i,o){return fa(s=>function ePe(e,t,n,r,i,o,s="emptyOnly"){return new nPe(e,t,n,r,i,s,o).recognize()}(e,t,n,r,s.extractedUrl,i,o).pipe(qt(({state:a,tree:c})=>({...s,targetSnapshot:a,urlAfterRedirects:c}))))}(this.environmentInjector,this.configLoader,this.rootComponentType,n.config,this.urlSerializer,this.paramsInheritanceStrategy),jr(d=>{o.targetSnapshot=d.targetSnapshot,o.urlAfterRedirects=d.urlAfterRedirects,this.currentNavigation={...this.currentNavigation,finalUrl:d.urlAfterRedirects};const f=new jK(d.id,this.urlSerializer.serialize(d.extractedUrl),this.urlSerializer.serialize(d.urlAfterRedirects),d.targetSnapshot);this.events.next(f)}));if(u&&this.urlHandlingStrategy.shouldProcessUrl(c.currentRawUrl)){const{id:d,extractedUrl:f,source:p,restoredState:m,extras:h}=c,g=new vI(d,this.urlSerializer.serialize(f),p,m);this.events.next(g);const y=$K(this.rootComponentType).snapshot;return this.currentTransition=o={...c,targetSnapshot:y,urlAfterRedirects:f,extras:{...h,skipLocationChange:!1,replaceUrl:!1}},this.currentNavigation.finalUrl=f,Pn(o)}{const d="";return this.events.next(new Pb(c.id,this.urlSerializer.serialize(c.extractedUrl),d,_I.IgnoredByUrlHandlingStrategy)),c.resolve(null),$l}}),jr(c=>{const u=new QEe(c.id,this.urlSerializer.serialize(c.extractedUrl),this.urlSerializer.serialize(c.urlAfterRedirects),c.targetSnapshot);this.events.next(u)}),qt(c=>(this.currentTransition=o={...c,guards:S3e(c.targetSnapshot,c.currentSnapshot,this.rootContexts)},o)),function R3e(e,t){return fa(n=>{const{targetSnapshot:r,currentSnapshot:i,guards:{canActivateChecks:o,canDeactivateChecks:s}}=n;return 0===s.length&&0===o.length?Pn({...n,guardsResult:!0}):function k3e(e,t,n,r){return $i(e).pipe(fa(i=>function U3e(e,t,n,r,i){const o=t&&t.routeConfig?t.routeConfig.canDeactivate:null;return o&&0!==o.length?Pn(o.map(a=>{const c=Lx(t)??i,u=kb(a,c);return zh(function P3e(e){return e&&zx(e.canDeactivate)}(u)?u.canDeactivate(e,t,n,r):Md(c,()=>u(e,t,n,r))).pipe(Cg())})).pipe(Nb()):Pn(!0)}(i.component,i.route,n,t,r)),Cg(i=>!0!==i,!0))}(s,r,i,e).pipe(fa(a=>a&&function I3e(e){return"boolean"==typeof e}(a)?function N3e(e,t,n,r){return $i(t).pipe(Cb(i=>pF(function B3e(e,t){return null!==e&&t&&t(new i3e(e)),Pn(!0)}(i.route.parent,r),function F3e(e,t){return null!==e&&t&&t(new s3e(e)),Pn(!0)}(i.route,r),function L3e(e,t,n){const r=t[t.length-1],o=t.slice(0,t.length-1).reverse().map(s=>function C3e(e){const t=e.routeConfig?e.routeConfig.canActivateChild:null;return t&&0!==t.length?{node:e,guards:t}:null}(s)).filter(s=>null!==s).map(s=>xK(()=>Pn(s.guards.map(c=>{const u=Lx(s.node)??n,l=kb(c,u);return zh(function E3e(e){return e&&zx(e.canActivateChild)}(l)?l.canActivateChild(r,e):Md(u,()=>l(r,e))).pipe(Cg())})).pipe(Nb())));return Pn(o).pipe(Nb())}(e,i.path,n),function O3e(e,t,n){const r=t.routeConfig?t.routeConfig.canActivate:null;if(!r||0===r.length)return Pn(!0);const i=r.map(o=>xK(()=>{const s=Lx(t)??n,a=kb(o,s);return zh(function D3e(e){return e&&zx(e.canActivate)}(a)?a.canActivate(t,e):Md(s,()=>a(t,e))).pipe(Cg())}));return Pn(i).pipe(Nb())}(e,i.route,n))),Cg(i=>!0!==i,!0))}(r,o,e,t):Pn(a)),qt(a=>({...n,guardsResult:a})))})}(this.environmentInjector,c=>this.events.next(c)),jr(c=>{if(o.guardsResult=c.guardsResult,Db(c.guardsResult))throw JK(0,c.guardsResult);const u=new JEe(c.id,this.urlSerializer.serialize(c.extractedUrl),this.urlSerializer.serialize(c.urlAfterRedirects),c.targetSnapshot,!!c.guardsResult);this.events.next(u)}),Yl(c=>!!c.guardsResult||(this.cancelNavigationTransition(c,"",iu.GuardRejected),!1)),OF(c=>{if(c.guards.canActivateChecks.length)return Pn(c).pipe(jr(u=>{const l=new e3e(u.id,this.urlSerializer.serialize(u.extractedUrl),this.urlSerializer.serialize(u.urlAfterRedirects),u.targetSnapshot);this.events.next(l)}),To(u=>{let l=!1;return Pn(u).pipe(function cPe(e,t){return fa(n=>{const{targetSnapshot:r,guards:{canActivateChecks:i}}=n;if(!i.length)return Pn(n);const o=new Set(i.map(c=>c.route)),s=new Set;for(const c of o)if(!s.has(c))for(const u of cZ(c))s.add(u);let a=0;return $i(s).pipe(Cb(c=>o.has(c)?function uPe(e,t,n,r){const i=e.routeConfig,o=e._resolve;return void 0!==i?.title&&!KK(i)&&(o[Px]=i.title),function lPe(e,t,n,r){const i=gF(e);if(0===i.length)return Pn({});const o={};return $i(i).pipe(fa(s=>function dPe(e,t,n,r){const i=Lx(t)??r,o=kb(e,i);return zh(o.resolve?o.resolve(t,n):Md(i,()=>o(t,n)))}(e[s],t,n,r).pipe(Cg(),jr(a=>{o[s]=a}))),mF(1),function SEe(e){return qt(()=>e)}(o),wb(s=>iZ(s)?$l:dI(s)))}(o,e,t,r).pipe(qt(s=>(e._resolvedData=s,e.data=IF(e,e.parent,n).resolve,null)))}(c,r,e,t):(c.data=IF(c,c.parent,e).resolve,Pn(void 0))),jr(()=>a++),mF(1),fa(c=>a===s.size?Pn(n):$l))})}(this.paramsInheritanceStrategy,this.environmentInjector),jr({next:()=>l=!0,complete:()=>{l||this.cancelNavigationTransition(u,"",iu.NoDataFromResolver)}}))}),jr(u=>{const l=new t3e(u.id,this.urlSerializer.serialize(u.extractedUrl),this.urlSerializer.serialize(u.urlAfterRedirects),u.targetSnapshot);this.events.next(l)}))}),OF(c=>{const u=l=>{const d=[];l.routeConfig?.loadComponent&&!l.routeConfig._loadedComponent&&d.push(this.configLoader.loadComponent(l.routeConfig).pipe(jr(f=>{l.component=f}),qt(()=>{})));for(const f of l.children)d.push(...u(f));return d};return uI(u(c.targetSnapshot.root)).pipe(fI(null),Sg(1))}),OF(()=>this.afterPreactivation()),To(()=>{const{currentSnapshot:c,targetSnapshot:u}=o,l=this.createViewTransition?.(this.environmentInjector,c.root,u.root);return l?$i(l).pipe(qt(()=>o)):Pn(o)}),qt(c=>{const u=function d3e(e,t,n){const r=Ox(e,t._root,n?n._root:void 0);return new WK(r,t)}(n.routeReuseStrategy,c.targetSnapshot,c.currentRouterState);return this.currentTransition=o={...c,targetRouterState:u},this.currentNavigation.targetRouterState=u,o}),jr(()=>{this.events.next(new SF)}),((e,t,n,r)=>qt(i=>(new x3e(t,i.targetRouterState,i.currentRouterState,n,r).activate(e),i)))(this.rootContexts,n.routeReuseStrategy,c=>this.events.next(c),this.inputBindingEnabled),Sg(1),jr({next:c=>{s=!0,this.lastSuccessfulNavigation=this.currentNavigation,this.events.next(new np(c.id,this.urlSerializer.serialize(c.extractedUrl),this.urlSerializer.serialize(c.urlAfterRedirects))),this.titleStrategy?.updateTitle(c.targetRouterState.snapshot),c.resolve(!0)},complete:()=>{s=!0}}),function CEe(e){return mo((t,n)=>{ru(e).subscribe(Io(n,()=>n.complete(),uM)),!n.closed&&t.subscribe(n)})}(this.transitionAbortSubject.pipe(jr(c=>{throw c}))),Ex(()=>{!s&&!a&&this.cancelNavigationTransition(o,"",iu.SupersededByNewNavigation),this.currentTransition?.id===o.id&&(this.currentNavigation=null,this.currentTransition=null)}),wb(c=>{if(a=!0,tZ(c))this.events.next(new Eb(o.id,this.urlSerializer.serialize(o.extractedUrl),c.message,c.cancellationCode)),function h3e(e){return tZ(e)&&Db(e.url)}(c)?this.events.next(new CF(c.url)):o.resolve(!1);else{this.events.next(new xI(o.id,this.urlSerializer.serialize(o.extractedUrl),c,o.targetSnapshot??void 0));try{o.resolve(n.errorHandler(c))}catch(u){this.options.resolveNavigationPromiseOnError?o.resolve(!1):o.reject(u)}}return $l}))}))}cancelNavigationTransition(n,r,i){const o=new Eb(n.id,this.urlSerializer.serialize(n.extractedUrl),r,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}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function bPe(e){return e!==Fx}let vPe=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>bt(xPe),providedIn:"root"})}return e})();class _Pe{shouldDetach(t){return!1}store(t,n){}shouldAttach(t){return!1}retrieve(t){return null}shouldReuseRoute(t,n){return t.routeConfig===n.routeConfig}}let xPe=(()=>{class e extends _Pe{static#e=this.\u0275fac=(()=>{let n;return function(i){return(n||(n=hR(e)))(i||e)}})();static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})(),pZ=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:()=>bt(SPe),providedIn:"root"})}return e})(),SPe=(()=>{class e extends pZ{constructor(){super(...arguments),this.location=bt(_b),this.urlSerializer=bt(Tb),this.options=bt(Bb,{optional:!0})||{},this.canceledNavigationResolution=this.options.canceledNavigationResolution||"replace",this.urlHandlingStrategy=bt(UF),this.urlUpdateStrategy=this.options.urlUpdateStrategy||"deferred",this.currentUrlTree=new Ib,this.rawUrlTree=this.currentUrlTree,this.currentPageId=0,this.lastSuccessfulId=-1,this.routerState=$K(null),this.stateMemento=this.createStateMemento()}getCurrentUrlTree(){return this.currentUrlTree}getRawUrlTree(){return this.rawUrlTree}restoredState(){return this.location.getState()}get browserPageId(){return"computed"!==this.canceledNavigationResolution?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(r=>{"popstate"===r.type&&n(r.url,r.state)})}handleRouterEvent(n,r){if(n instanceof vI)this.stateMemento=this.createStateMemento();else if(n instanceof Pb)this.rawUrlTree=r.initialUrl;else if(n instanceof jK){if("eager"===this.urlUpdateStrategy&&!r.extras.skipLocationChange){const i=this.urlHandlingStrategy.merge(r.finalUrl,r.initialUrl);this.setBrowserUrl(i,r)}}else n instanceof SF?(this.currentUrlTree=r.finalUrl,this.rawUrlTree=this.urlHandlingStrategy.merge(r.finalUrl,r.initialUrl),this.routerState=r.targetRouterState,"deferred"===this.urlUpdateStrategy&&(r.extras.skipLocationChange||this.setBrowserUrl(this.rawUrlTree,r))):n instanceof Eb&&(n.code===iu.GuardRejected||n.code===iu.NoDataFromResolver)?this.restoreHistory(r):n instanceof xI?this.restoreHistory(r,!0):n instanceof np&&(this.lastSuccessfulId=n.id,this.currentPageId=this.browserPageId)}setBrowserUrl(n,r){const i=this.urlSerializer.serialize(n);if(this.location.isCurrentPathEqualTo(i)||r.extras.replaceUrl){const s={...r.extras.state,...this.generateNgRouterState(r.id,this.browserPageId)};this.location.replaceState(i,"",s)}else{const o={...r.extras.state,...this.generateNgRouterState(r.id,this.browserPageId+1)};this.location.go(i,"",o)}}restoreHistory(n,r=!1){if("computed"===this.canceledNavigationResolution){const o=this.currentPageId-this.browserPageId;0!==o?this.location.historyGo(o):this.currentUrlTree===n.finalUrl&&0===o&&(this.resetState(n),this.resetUrlToCurrentUrlTree())}else"replace"===this.canceledNavigationResolution&&(r&&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,r){return"computed"===this.canceledNavigationResolution?{navigationId:n,\u0275routerPageId:r}:{navigationId:n}}static#e=this.\u0275fac=(()=>{let n;return function(i){return(n||(n=hR(e)))(i||e)}})();static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();var Gx=function(e){return e[e.COMPLETE=0]="COMPLETE",e[e.FAILED=1]="FAILED",e[e.REDIRECTING=2]="REDIRECTING",e}(Gx||{});function hZ(e,t){e.events.pipe(Yl(n=>n instanceof np||n instanceof Eb||n instanceof xI||n instanceof Pb),qt(n=>n instanceof np||n instanceof Pb?Gx.COMPLETE:n instanceof Eb&&(n.code===iu.Redirect||n.code===iu.SupersededByNewNavigation)?Gx.REDIRECTING:Gx.FAILED),Yl(n=>n!==Gx.REDIRECTING),Sg(1)).subscribe(()=>{t()})}function CPe(e){throw e}const wPe={paths:"exact",fragment:"ignored",matrixParams:"ignored",queryParams:"exact"},APe={paths:"subset",fragment:"ignored",matrixParams:"ignored",queryParams:"subset"};let Kl=(()=>{class e{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=bt(fY),this.stateManager=bt(pZ),this.options=bt(Bb,{optional:!0})||{},this.pendingTasks=bt(kh),this.urlUpdateStrategy=this.options.urlUpdateStrategy||"deferred",this.navigationTransitions=bt(II),this.urlSerializer=bt(Tb),this.location=bt(_b),this.urlHandlingStrategy=bt(UF),this._events=new mr,this.errorHandler=this.options.errorHandler||CPe,this.navigated=!1,this.routeReuseStrategy=bt(vPe),this.onSameUrlNavigation=this.options.onSameUrlNavigation||"ignore",this.config=bt(Ob,{optional:!0})?.flat()??[],this.componentInputBindingEnabled=!!bt(SI,{optional:!0}),this.eventsSubscription=new Fa,this.isNgZoneEnabled=bt(Qr)instanceof Qr&&Qr.isInAngularZone(),this.resetConfig(this.config),this.navigationTransitions.setupNavigations(this,this.currentUrlTree,this.routerState).subscribe({error:n=>{this.console.warn(n)}}),this.subscribeToNavigationEvents()}subscribeToNavigationEvents(){const n=this.navigationTransitions.events.subscribe(r=>{try{const i=this.navigationTransitions.currentTransition,o=this.navigationTransitions.currentNavigation;if(null!==i&&null!==o)if(this.stateManager.handleRouterEvent(r,o),r instanceof Eb&&r.code!==iu.Redirect&&r.code!==iu.SupersededByNewNavigation)this.navigated=!0;else if(r instanceof np)this.navigated=!0;else if(r instanceof CF){const s=this.urlHandlingStrategy.merge(r.url,i.currentRawUrl),a={info:i.extras.info,skipLocationChange:i.extras.skipLocationChange,replaceUrl:"eager"===this.urlUpdateStrategy||bPe(i.source)};this.scheduleNavigation(s,Fx,null,a,{resolve:i.resolve,reject:i.reject,promise:i.promise})}(function TPe(e){return!(e instanceof SF||e instanceof CF)})(r)&&this._events.next(r)}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),Fx,this.stateManager.restoredState())}setUpLocationChangeListener(){this.nonRouterCurrentEntryChangeSubscription??=this.stateManager.registerNonRouterCurrentEntryChangeListener((n,r)=>{setTimeout(()=>{this.navigateToSyncWithBrowser(n,"popstate",r)},0)})}navigateToSyncWithBrowser(n,r,i){const o={replaceUrl:!0},s=i?.navigationId?i:null;if(i){const c={...i};delete c.navigationId,delete c.\u0275routerPageId,0!==Object.keys(c).length&&(o.state=c)}const a=this.parseUrl(n);this.scheduleNavigation(a,r,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(RF),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,r={}){const{relativeTo:i,queryParams:o,fragment:s,queryParamsHandling:a,preserveFragment:c}=r,u=c?this.currentUrlTree.fragment:s;let d,l=null;switch(a){case"merge":l={...this.currentUrlTree.queryParams,...o};break;case"preserve":l=this.currentUrlTree.queryParams;break;default:l=o||null}null!==l&&(l=this.removeEmptyProps(l));try{d=BK(i?i.snapshot:this.routerState.snapshot.root)}catch{("string"!=typeof n[0]||!n[0].startsWith("/"))&&(n=[]),d=this.currentUrlTree.root}return OK(d,n,l,u??null)}navigateByUrl(n,r={skipLocationChange:!1}){const i=Db(n)?n:this.parseUrl(n),o=this.urlHandlingStrategy.merge(i,this.rawUrlTree);return this.scheduleNavigation(o,Fx,null,r)}navigate(n,r={skipLocationChange:!1}){return function IPe(e){for(let t=0;t(null!=o&&(r[i]=o),r),{})}scheduleNavigation(n,r,i,o,s){if(this.disposed)return Promise.resolve(!1);let a,c,u;s?(a=s.resolve,c=s.reject,u=s.promise):u=new Promise((d,f)=>{a=d,c=f});const l=this.pendingTasks.add();return hZ(this,()=>{queueMicrotask(()=>this.pendingTasks.remove(l))}),this.navigationTransitions.handleNavigationRequest({source:r,restoredState:i,currentUrlTree:this.currentUrlTree,currentRawUrl:this.currentUrlTree,rawUrl:n,extras:o,resolve:a,reject:c,promise:u,currentSnapshot:this.routerState.snapshot,currentRouterState:this.routerState}),u.catch(d=>Promise.reject(d))}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})(),TI=(()=>{class e{constructor(n,r,i,o,s,a){this.router=n,this.route=r,this.tabIndexAttribute=i,this.renderer=o,this.el=s,this.locationStrategy=a,this.href=null,this.commands=null,this.onChanges=new mr,this.preserveFragment=!1,this.skipLocationChange=!1,this.replaceUrl=!1;const c=s.nativeElement.tagName?.toLowerCase();this.isAnchorElement="a"===c||"area"===c,this.isAnchorElement?this.subscription=n.events.subscribe(u=>{u instanceof np&&this.updateHref()}):this.setTabIndexIfNotOnNativeEl("0")}setTabIndexIfNotOnNativeEl(n){null!=this.tabIndexAttribute||this.isAnchorElement||this.applyAttributeValue("tabindex",n)}ngOnChanges(n){this.isAnchorElement&&this.updateHref(),this.onChanges.next(this)}set routerLink(n){null!=n?(this.commands=Array.isArray(n)?n:[n],this.setTabIndexIfNotOnNativeEl("0")):(this.commands=null,this.setTabIndexIfNotOnNativeEl(null))}onClick(n,r,i,o,s){const a=this.urlTree;return!!(null===a||this.isAnchorElement&&(0!==n||r||i||o||s||"string"==typeof this.target&&"_self"!=this.target))||(this.router.navigateByUrl(a,{skipLocationChange:this.skipLocationChange,replaceUrl:this.replaceUrl,state:this.state,info:this.info}),!this.isAnchorElement)}ngOnDestroy(){this.subscription?.unsubscribe()}updateHref(){const n=this.urlTree;this.href=null!==n&&this.locationStrategy?this.locationStrategy?.prepareExternalUrl(this.router.serializeUrl(n)):null;const r=null===this.href?null:function Vj(e,t,n){return function jve(e,t){return"src"===t&&("embed"===e||"frame"===e||"iframe"===e||"media"===e||"script"===e)||"href"===t&&("base"===e||"link"===e)?Uj:Lj}(t,n)(e)}(this.href,this.el.nativeElement.tagName.toLowerCase(),"href");this.applyAttributeValue("href",r)}applyAttributeValue(n,r){const i=this.renderer,o=this.el.nativeElement;null!==r?i.setAttribute(o,n,r):i.removeAttribute(o,n)}get urlTree(){return null===this.commands?null:this.router.createUrlTree(this.commands,{relativeTo:void 0!==this.relativeTo?this.relativeTo:this.route,queryParams:this.queryParams,fragment:this.fragment,queryParamsHandling:this.queryParamsHandling,preserveFragment:this.preserveFragment})}static#e=this.\u0275fac=function(r){return new(r||e)(cn(Kl),cn(Rb),function T_(e){return function xbe(e,t){if("class"===t)return e.classes;if("style"===t)return e.styles;const n=e.attrs;if(n){const r=n.length;let i=0;for(;i{class e{constructor(n,r,i,o,s){this.router=n,this.injector=i,this.preloadingStrategy=o,this.loader=s}setUpPreloading(){this.subscription=this.router.events.pipe(Yl(n=>n instanceof np),Cb(()=>this.preload())).subscribe(()=>{})}preload(){return this.processRoutes(this.injector,this.router.config)}ngOnDestroy(){this.subscription&&this.subscription.unsubscribe()}processRoutes(n,r){const i=[];for(const o of r){o.providers&&!o._injector&&(o._injector=hA(o.providers,n,`Route: ${o.path}`));const s=o._injector??n,a=o._loadedInjector??s;(o.loadChildren&&!o._loadedRoutes&&void 0===o.canLoad||o.loadComponent&&!o._loadedComponent)&&i.push(this.preloadConfig(s,o)),(o.children||o._loadedRoutes)&&i.push(this.processRoutes(a,o.children??o._loadedRoutes))}return $i(i).pipe(xg())}preloadConfig(n,r){return this.preloadingStrategy.preload(r,()=>{let i;i=r.loadChildren&&void 0===r.canLoad?this.loader.loadChildren(n,r):Pn(null);const o=i.pipe(fa(s=>null===s?Pn(void 0):(r._loadedRoutes=s.routes,r._loadedInjector=s.injector,this.processRoutes(s.injector??n,s.routes))));return r.loadComponent&&!r._loadedComponent?$i([o,this.loader.loadComponent(r)]).pipe(xg()):o})}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(Kl),Zt(SY),Zt(xc),Zt(mZ),Zt(LF))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();const VF=new Yt("");let gZ=(()=>{class e{constructor(n,r,i,o,s={}){this.urlSerializer=n,this.transitions=r,this.viewportScroller=i,this.zone=o,this.options=s,this.lastId=0,this.lastSource="imperative",this.restoredId=0,this.store={},s.scrollPositionRestoration||="disabled",s.anchorScrolling||="disabled"}init(){"disabled"!==this.options.scrollPositionRestoration&&this.viewportScroller.setHistoryScrollRestoration("manual"),this.routerEventsSubscription=this.createScrollEvents(),this.scrollEventsSubscription=this.consumeScrollEvents()}createScrollEvents(){return this.transitions.events.subscribe(n=>{n instanceof vI?(this.store[this.lastId]=this.viewportScroller.getScrollPosition(),this.lastSource=n.navigationTrigger,this.restoredId=n.restoredState?n.restoredState.navigationId:0):n instanceof np?(this.lastId=n.id,this.scheduleScrollEvent(n,this.urlSerializer.parse(n.urlAfterRedirects).fragment)):n instanceof Pb&&n.code===_I.IgnoredSameUrlNavigation&&(this.lastSource=void 0,this.restoredId=0,this.scheduleScrollEvent(n,this.urlSerializer.parse(n.url).fragment))})}consumeScrollEvents(){return this.transitions.events.subscribe(n=>{n instanceof HK&&(n.position?"top"===this.options.scrollPositionRestoration?this.viewportScroller.scrollToPosition([0,0]):"enabled"===this.options.scrollPositionRestoration&&this.viewportScroller.scrollToPosition(n.position):n.anchor&&"enabled"===this.options.anchorScrolling?this.viewportScroller.scrollToAnchor(n.anchor):"disabled"!==this.options.scrollPositionRestoration&&this.viewportScroller.scrollToPosition([0,0]))})}scheduleScrollEvent(n,r){this.zone.runOutsideAngular(()=>{setTimeout(()=>{this.zone.run(()=>{this.transitions.events.next(new HK(n,"popstate"===this.lastSource?this.store[this.restoredId]:null,r))})},0)})}ngOnDestroy(){this.routerEventsSubscription?.unsubscribe(),this.scrollEventsSubscription?.unsubscribe()}static#e=this.\u0275fac=function(r){!function dH(){throw new Error("invalid")}()};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();function yZ(e){return e.routerState.root}function $d(e,t){return{\u0275kind:e,\u0275providers:t}}function bZ(){const e=bt(Sc);return t=>{const n=e.get(Oh);if(t!==n.components[0])return;const r=e.get(Kl),i=e.get(vZ);1===e.get(zF)&&r.initialNavigation(),e.get(_Z,null,yr.Optional)?.setUpPreloading(),e.get(VF,null,yr.Optional)?.init(),r.resetRootComponentType(n.componentTypes[0]),i.closed||(i.next(),i.complete(),i.unsubscribe())}}const vZ=new Yt("",{factory:()=>new mr}),zF=new Yt("",{providedIn:"root",factory:()=>1}),_Z=new Yt("");function FPe(e){return $d(0,[{provide:_Z,useExisting:PPe},{provide:mZ,useExisting:e}])}function OPe(e){return $d(9,[{provide:dZ,useValue:gPe},{provide:fZ,useValue:{skipNextTransition:!!e?.skipInitialTransition,...e}}])}const xZ=new Yt("ROUTER_FORROOT_GUARD"),LPe=[_b,{provide:Tb,useClass:yF},Kl,Bx,{provide:Rb,useFactory:yZ,deps:[Kl]},LF,[]];let GF=(()=>{class e{constructor(n){}static forRoot(n,r){return{ngModule:e,providers:[LPe,[],{provide:Ob,multi:!0,useValue:n},{provide:xZ,useFactory:GPe,deps:[[Kl,new uw,new lw]]},{provide:Bb,useValue:r||{}},r?.useHash?{provide:_g,useClass:eIe}:{provide:_g,useClass:dX},{provide:VF,useFactory:()=>{const e=bt(_Te),t=bt(Qr),n=bt(Bb),r=bt(II),i=bt(Tb);return n.scrollOffset&&e.setOffset(n.scrollOffset),new gZ(i,r,e,t,n)}},r?.preloadingStrategy?FPe(r.preloadingStrategy).\u0275providers:[],r?.initialNavigation?jPe(r):[],r?.bindToComponentInputs?$d(8,[ZK,{provide:SI,useExisting:ZK}]).\u0275providers:[],r?.enableViewTransitions?OPe().\u0275providers:[],[{provide:SZ,useFactory:bZ},{provide:OA,multi:!0,useExisting:SZ}]]}}static forChild(n){return{ngModule:e,providers:[{provide:Ob,multi:!0,useValue:n}]}}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(xZ,8))};static#t=this.\u0275mod=p_({type:e});static#n=this.\u0275inj=Sy({})}return e})();function GPe(e){return"guarded"}function jPe(e){return["disabled"===e.initialNavigation?$d(3,[{provide:AN,multi:!0,useFactory:()=>{const t=bt(Kl);return()=>{t.setUpLocationChangeListener()}}},{provide:zF,useValue:2}]).\u0275providers:[],"enabledBlocking"===e.initialNavigation?$d(2,[{provide:zF,useValue:0},{provide:AN,multi:!0,deps:[Sc],useFactory:t=>{const n=t.get(QAe,Promise.resolve());return()=>n.then(()=>new Promise(r=>{const i=t.get(Kl),o=t.get(vZ);hZ(i,()=>{r(!0)}),t.get(II).afterPreactivation=()=>(r(!0),o.closed?Pn(void 0):o),i.initialNavigation()}))}}]).\u0275providers:[]]}const SZ=new Yt(""),jF={now:()=>(jF.delegate||Date).now(),delegate:void 0};class ou extends mr{constructor(t=1/0,n=1/0,r=jF){super(),this._bufferSize=t,this._windowTime=n,this._timestampProvider=r,this._buffer=[],this._infiniteTimeWindow=!0,this._infiniteTimeWindow=n===1/0,this._bufferSize=Math.max(1,t),this._windowTime=Math.max(1,n)}next(t){const{isStopped:n,_buffer:r,_infiniteTimeWindow:i,_timestampProvider:o,_windowTime:s}=this;n||(r.push(t),!i&&r.push(o.now()+s)),this._trimBuffer(),super.next(t)}_subscribe(t){this._throwIfClosed(),this._trimBuffer();const n=this._innerSubscribe(t),{_infiniteTimeWindow:r,_buffer:i}=this,o=i.slice();for(let s=0;s{vK([n,...CZ(e)])(r)})}function Lb(...e){return wZ(...e)}function HF(e,t,...n){if(!0===t)return void e();if(!1===t)return;const r=new a_({next:()=>{r.unsubscribe(),e()}});return ru(t(...n)).subscribe(r)}function Zl(e,t,n){let r,i=!1;return e&&"object"==typeof e?({bufferSize:r=1/0,windowTime:t=1/0,refCount:i=!1,scheduler:n}=e):r=e??1/0,function WPe(e={}){const{connector:t=(()=>new mr),resetOnError:n=!0,resetOnComplete:r=!0,resetOnRefCountZero:i=!0}=e;return o=>{let s,a,c,u=0,l=!1,d=!1;const f=()=>{a?.unsubscribe(),a=void 0},p=()=>{f(),s=c=void 0,l=d=!1},m=()=>{const h=s;p(),h?.unsubscribe()};return mo((h,g)=>{u++,!d&&!l&&f();const y=c=c??t();g.add(()=>{u--,0===u&&!d&&!l&&(a=HF(m,i))}),y.subscribe(g),!s&&u>0&&(s=new a_({next:b=>y.next(b),error:b=>{d=!0,f(),a=HF(p,n,b),y.error(b)},complete:()=>{l=!0,f(),a=HF(p,r),y.complete()}}),ru(h).subscribe(s))})(o)}}({connector:()=>new ou(r,t,n),resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:i})}var ea,e,ir;(e=ea||(ea={})).create=function t(i){return i},e.has=function n(i,o){return!!(i&o)},e.hasAll=function r(i,o){return!!o&&(i&o)===o},function(e){e.create=function t(_=512){return{current:[],offset:0,capacity:_,chunks:[]}},e.getString=function n(_){return _.chunks.length?(_.offset>0&&(_.chunks[_.chunks.length]=_.current.length===_.offset?_.current.join(""):_.current.slice(0,_.offset).join("")),_.chunks.join("")):_.current.length===_.offset?_.current.join(""):_.current.splice(0,_.offset).join("")},e.getSize=function r(_){let S=0;for(const A of _.chunks)S+=A.length;for(let A=0;A<_.offset;A++)S+=_.current[A].length;return S},e.getChunks=function i(_){return _.offset>0&&(_.chunks[_.chunks.length]=_.current.length===_.offset?_.current.join(""):_.current.slice(0,_.offset).join(""),_.offset=0),_.chunks};const o=[];function a(_,S){S>0&&l(_,o[S])}function l(_,S){_.offset===_.capacity&&(_.chunks[_.chunks.length]=_.current.join(""),_.offset=0),_.current[_.offset++]=S}!function(){let _="";for(let S=0;S<512;S++)o[S]=_,_+=" "}(),e.newline=function s(_){l(_,"\n")},e.whitespace=a,e.whitespace1=function c(_){l(_," ")},e.write=function u(_,S){S&&(_.offset===_.capacity&&(_.chunks[_.chunks.length]=_.current.join(""),_.offset=0),_.current[_.offset++]=S)},e.writeSafe=l,e.writePadLeft=function d(_,S,A){S?(a(_,A-S.length),l(_,S)):a(_,A)},e.writePadRight=function f(_,S,A){if(!S)return void a(_,A);const E=A-S.length;l(_,S),a(_,E)},e.writeInteger=function p(_,S){l(_,""+S)},e.writeIntegerAndSpace=function m(_,S){l(_,S+" ")},e.writeIntegerPadLeft=function h(_,S,A){const E=""+S;a(_,A-E.length),l(_,E)},e.writeIntegerPadRight=function g(_,S,A){const E=""+S,w=A-E.length;l(_,E),a(_,w)},e.writeFloat=function y(_,S,A){l(_,""+Math.round(A*S)/A)},e.writeFloatPadLeft=function b(_,S,A,E){const w=""+Math.round(A*S)/A;a(_,E-w.length),l(_,w)},e.writeFloatPadRight=function x(_,S,A,E){const w=""+Math.round(A*S)/A,D=E-w.length;l(_,w),a(_,D)}}(ir||(ir={}));const yi=function(){if(typeof window<"u"&&window.performance){const e=window.performance;return()=>e.now()}return typeof process<"u"&&"undefined"!==process.hrtime&&"function"==typeof process.hrtime?()=>{const e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:Date.now?()=>Date.now():()=>+new Date}();function qF(e,t=!0){if(isNaN(e))return"n/a";const n=Math.floor(e/36e5),r=Math.floor(e/6e4%60),i=Math.floor(e/1e3%60);let o=Math.floor(e%1e3).toString();for(;o.length<3;)o="0"+o;for(;!t&&o.length>1&&"0"===o[o.length-1];)o=o.substr(0,o.length-1);return n>0?`${n}h${r}m${i}.${o}s`:r>0?`${r}m${i}.${o}s`:i>0?`${i}.${o}s`:`${e.toFixed(0)}ms`}var Hr,AZ,jx;function $Pe(e,t){return e-t}function pa(e=0,t=Number.MAX_SAFE_INTEGER){let n=e;return()=>{const r=n;return n=(n+1)%t,r}}!function(e){const t=typeof btoa<"u"?btoa:s=>Buffer.from(s).toString("base64"),n=[];e.create22=function r(){let s=+new Date+yi();for(let a=0;a<16;a++)n[a]=String.fromCharCode((s+255*Math.random())%255|0),s=Math.floor(s/255);return t(n.join("")).replace(/\+/g,"-").replace(/\//g,"_").substr(0,22)},e.createv4=function i(){let s=+new Date+yi();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){const u=(s+16*Math.random())%16|0;return s=Math.floor(s/16),("x"===c?u:3&u|8).toString(16)})},e.is=function o(s){return"string"==typeof s}}(Hr||(Hr={})),function(e){class t{has(m){return!1}forEach(m,h){return h}constructor(){this.size=0}}class n{has(m){return m===this.idx}forEach(m,h){return m(this.idx,h),h}constructor(m){this.idx=m,this.size=1}}class r{has(m){return mm[h++]=g),function YPe(e){Array.prototype.sort.call(e,$Pe)}(m),this._flat=m,this._flat}forEach(m,h){return this._forEach(m,h),h}constructor(m){this.set=m,this._flat=void 0,this.size=m.size}}function a(p){return new o(p)}function l(p,m){return new r(p,m)}e.always=function s(p){return new i(p)},e.never=new t,e.ofSet=a,e.singleton=function c(p){return new n(p)},e.ofUniqueIndices=function u(p){const m=p.length;if(0===m)return new t;if(1===m)return new n(p[0]);let h=0;for(const b of p)b>h&&(h=b);if(m===h)return new i(m);if(m/h<1/12){const b=new Set;for(const x of p)b.add(x);return new o(b)}const y=new Int8Array(h+1);for(const b of p)y[b]=1;return new r(y,p.length)},e.ofMask=l,e.hasAny=function d(p,m){for(const h of m)if(p.has(h))return!0;return!1},e.complement=function f(p,m){let h=0,g=0;if(m.forEach(y=>{p.has(y)||(h++,y>g&&(g=y))}),h/g<1/12){const y=new Set;return m.forEach(b=>{p.has(b)||y.add(b)}),a(y)}{const y=new Uint8Array(g+1);return m.forEach(b=>{p.has(b)||(y[b]=1)}),l(y,h)}}}(AZ||(AZ={})),function(e){e.create=function t(r){return{ref:r}},e.set=function n(r,i){return r.ref=i,r}}(jx||(jx={}));const XPe=pa(0,2147483647);var Gh,k;!function(e){e.create=function t(r,i){return{id:XPe(),version:0,value:r,metadata:i}},e.withValue=function n(r,i){return{id:r.id,version:r.version+1,value:i,metadata:r.metadata}}}(Gh||(Gh={})),function(e){function n(o,s){return jx.set(o,Gh.withValue(o.ref,s))}e.create=function t(o,s){return jx.create(Gh.create(o,s))},e.update=n,e.set=function r(o,s){return jx.set(o,s)},e.updateIfChanged=function i(o,s){return o.ref.value!==s?n(o,s):o}}(k||(k={}));const Ag=function(){};function Wa(e,t){const n=e.length;if(n!==t.length)return!1;for(let r=0;r0&&(xt=1/Math.sqrt(xt),se[0]=he[0]*xt,se[1]=he[1]*xt,se[2]=he[2]*xt),se}function ee(se,he){return se[0]*he[0]+se[1]*he[1]+se[2]*he[2]}function q(se,he,ve){const Te=he[0],yt=he[1],xt=he[2],Ut=ve[0],Nn=ve[1],hn=ve[2];return se[0]=yt*hn-xt*Nn,se[1]=xt*Ut-Te*hn,se[2]=Te*Nn-yt*Ut,se}e.zero=t,e.clone=function n(se){const he=t();return he[0]=se[0],he[1]=se[1],he[2]=se[2],he},e.isFinite=function r(se){return KF(se[0])&&KF(se[1])&&KF(se[2])},e.hasNaN=function i(se){return isNaN(se[0])||isNaN(se[1])||isNaN(se[2])},e.setNaN=function o(se){return se[0]=NaN,se[1]=NaN,se[2]=NaN,se},e.fromObj=function s(se){return l(se.x,se.y,se.z)},e.toObj=function a(se){return{x:se[0],y:se[1],z:se[2]}},e.fromArray=function c(se,he,ve){return se[0]=he[ve+0],se[1]=he[ve+1],se[2]=he[ve+2],se},e.toArray=function u(se,he,ve){return he[ve+0]=se[0],he[ve+1]=se[1],he[ve+2]=se[2],he},e.create=l,e.ofArray=function d(se){const he=t();return he[0]=se[0],he[1]=se[1],he[2]=se[2],he},e.set=function f(se,he,ve,Te){return se[0]=he,se[1]=ve,se[2]=Te,se},e.copy=p,e.add=m,e.sub=h,e.mul=function g(se,he,ve){return se[0]=he[0]*ve[0],se[1]=he[1]*ve[1],se[2]=he[2]*ve[2],se},e.div=function y(se,he,ve){return se[0]=he[0]/ve[0],se[1]=he[1]/ve[1],se[2]=he[2]/ve[2],se},e.scale=b,e.scaleAndAdd=x,e.scaleAndSub=function _(se,he,ve,Te){return se[0]=he[0]-ve[0]*Te,se[1]=he[1]-ve[1]*Te,se[2]=he[2]-ve[2]*Te,se},e.addScalar=function S(se,he,ve){return se[0]=he[0]+ve,se[1]=he[1]+ve,se[2]=he[2]+ve,se},e.subScalar=function A(se,he,ve){return se[0]=he[0]-ve,se[1]=he[1]-ve,se[2]=he[2]-ve,se},e.round=function E(se,he){return se[0]=Math.round(he[0]),se[1]=Math.round(he[1]),se[2]=Math.round(he[2]),se},e.ceil=function w(se,he){return se[0]=Math.ceil(he[0]),se[1]=Math.ceil(he[1]),se[2]=Math.ceil(he[2]),se},e.floor=function D(se,he){return se[0]=Math.floor(he[0]),se[1]=Math.floor(he[1]),se[2]=Math.floor(he[2]),se},e.trunc=function I(se,he){return se[0]=Math.trunc(he[0]),se[1]=Math.trunc(he[1]),se[2]=Math.trunc(he[2]),se},e.abs=function R(se,he){return se[0]=Math.abs(he[0]),se[1]=Math.abs(he[1]),se[2]=Math.abs(he[2]),se},e.min=function T(se,he,ve){return se[0]=Math.min(he[0],ve[0]),se[1]=Math.min(he[1],ve[1]),se[2]=Math.min(he[2],ve[2]),se},e.max=function M(se,he,ve){return se[0]=Math.max(he[0],ve[0]),se[1]=Math.max(he[1],ve[1]),se[2]=Math.max(he[2],ve[2]),se},e.clamp=function N(se,he,ve,Te){return se[0]=Math.max(ve[0],Math.min(Te[0],he[0])),se[1]=Math.max(ve[1],Math.min(Te[1],he[1])),se[2]=Math.max(ve[2],Math.min(Te[2],he[2])),se},e.distance=function V(se,he){const ve=he[0]-se[0],Te=he[1]-se[1],yt=he[2]-se[2];return Math.sqrt(ve*ve+Te*Te+yt*yt)},e.squaredDistance=function F(se,he){const ve=he[0]-se[0],Te=he[1]-se[1],yt=he[2]-se[2];return ve*ve+Te*Te+yt*yt},e.magnitude=function G(se){const he=se[0],ve=se[1],Te=se[2];return Math.sqrt(he*he+ve*ve+Te*Te)},e.squaredMagnitude=L,e.setMagnitude=function z(se,he,ve){return b(se,$(se,he),ve)},e.negate=j,e.inverse=function Z(se,he){return se[0]=1/he[0],se[1]=1/he[1],se[2]=1/he[2],se},e.normalize=$,e.dot=ee,e.cross=q,e.lerp=function O(se,he,ve,Te){const yt=he[0],xt=he[1],Ut=he[2];return se[0]=yt+Te*(ve[0]-yt),se[1]=xt+Te*(ve[1]-xt),se[2]=Ut+Te*(ve[2]-Ut),se};const H=t();function ne(se,he){const ve=Math.sqrt(L(se)*L(he));if(0===ve)return Math.PI/2;const Te=ee(se,he)/ve;return Math.acos(os(Te,-1,1))}e.slerp=function W(se,he,ve,Te){const yt=os(ee(he,ve),-1,1),xt=Math.acos(yt)*Te;return x(H,ve,he,-yt),$(H,H),m(se,b(se,he,Math.cos(xt)),b(H,H,Math.sin(xt)))},e.hermite=function Q(se,he,ve,Te,yt,xt){const Ut=xt*xt,Nn=Ut*(2*xt-3)+1,hn=Ut*(xt-2)+xt,hr=Ut*(xt-1),Pi=Ut*(3-2*xt);return se[0]=he[0]*Nn+ve[0]*hn+Te[0]*hr+yt[0]*Pi,se[1]=he[1]*Nn+ve[1]*hn+Te[1]*hr+yt[1]*Pi,se[2]=he[2]*Nn+ve[2]*hn+Te[2]*hr+yt[2]*Pi,se},e.bezier=function fe(se,he,ve,Te,yt,xt){const Ut=1-xt,Nn=Ut*Ut,hn=xt*xt,hr=Nn*Ut,Pi=3*xt*Nn,Ks=3*hn*Ut,ho=hn*xt;return se[0]=he[0]*hr+ve[0]*Pi+Te[0]*Ks+yt[0]*ho,se[1]=he[1]*hr+ve[1]*Pi+Te[1]*Ks+yt[1]*ho,se[2]=he[2]*hr+ve[2]*Pi+Te[2]*Ks+yt[2]*ho,se},e.quadraticBezier=function X(se,he,ve,Te,yt){return se[0]=XF(he[0],ve[0],Te[0],yt),se[1]=XF(he[1],ve[1],Te[1],yt),se[2]=XF(he[2],ve[2],Te[2],yt),se},e.spline=function J(se,he,ve,Te,yt,xt,Ut){return se[0]=MI(he[0],ve[0],Te[0],yt[0],xt,Ut),se[1]=MI(he[1],ve[1],Te[1],yt[1],xt,Ut),se[2]=MI(he[2],ve[2],Te[2],yt[2],xt,Ut),se},e.random=function ce(se,he){const ve=2*Math.random()*Math.PI,Te=2*Math.random()-1,yt=Math.sqrt(1-Te*Te)*he;return se[0]=Math.cos(ve)*yt,se[1]=Math.sin(ve)*yt,se[2]=Te*he,se},e.transformMat4=function be(se,he,ve){const Te=he[0],yt=he[1],xt=he[2],Ut=1/(ve[3]*Te+ve[7]*yt+ve[11]*xt+ve[15]||1);return se[0]=(ve[0]*Te+ve[4]*yt+ve[8]*xt+ve[12])*Ut,se[1]=(ve[1]*Te+ve[5]*yt+ve[9]*xt+ve[13])*Ut,se[2]=(ve[2]*Te+ve[6]*yt+ve[10]*xt+ve[14])*Ut,se},e.transformDirection=function ae(se,he,ve){const Te=he[0],yt=he[1],xt=he[2];return se[0]=ve[0]*Te+ve[4]*yt+ve[8]*xt,se[1]=ve[1]*Te+ve[5]*yt+ve[9]*xt,se[2]=ve[2]*Te+ve[6]*yt+ve[10]*xt,$(se,se)},e.transformMat4Offset=function me(se,he,ve,Te,yt,xt){const Ut=he[0+yt],Nn=he[1+yt],hn=he[2+yt],hr=1/(ve[3+xt]*Ut+ve[7+xt]*Nn+ve[11+xt]*hn+ve[15+xt]||1);return se[0+Te]=(ve[0+xt]*Ut+ve[4+xt]*Nn+ve[8+xt]*hn+ve[12+xt])*hr,se[1+Te]=(ve[1+xt]*Ut+ve[5+xt]*Nn+ve[9+xt]*hn+ve[13+xt])*hr,se[2+Te]=(ve[2+xt]*Ut+ve[6+xt]*Nn+ve[10+xt]*hn+ve[14+xt])*hr,se},e.transformMat3=function oe(se,he,ve){const Te=he[0],yt=he[1],xt=he[2];return se[0]=Te*ve[0]+yt*ve[3]+xt*ve[6],se[1]=Te*ve[1]+yt*ve[4]+xt*ve[7],se[2]=Te*ve[2]+yt*ve[5]+xt*ve[8],se},e.transformQuat=function K(se,he,ve){const Te=he[0],yt=he[1],xt=he[2],Ut=ve[0],Nn=ve[1],hn=ve[2],hr=ve[3],Pi=hr*Te+Nn*xt-hn*yt,Ks=hr*yt+hn*Te-Ut*xt,ho=hr*xt+Ut*yt-Nn*Te,mc=-Ut*Te-Nn*yt-hn*xt;return se[0]=Pi*hr+mc*-Ut+Ks*-hn-ho*-Nn,se[1]=Ks*hr+mc*-Nn+ho*-Ut-Pi*-hn,se[2]=ho*hr+mc*-hn+Pi*-Nn-Ks*-Ut,se},e.angle=ne;const de=t(),we=t(),Le=t(),We=t(),U=t(),Y=t(),ge=t();e.dihedralAngle=function Se(se,he,ve,Te){h(de,se,he),h(we,ve,he),h(Le,he,ve),h(We,Te,ve),q(U,de,we),q(Y,Le,We);const yt=ne(U,Y);return q(ge,U,Y),ee(we,ge)>0?yt:-yt},e.directionFromSpherical=function Re(se,he,ve,Te){return e.set(se,Te*Math.cos(ve)*Math.sin(he),Te*Math.sin(ve)*Math.sin(he),Te*Math.cos(he))},e.exactEquals=function Ne(se,he){return se[0]===he[0]&&se[1]===he[1]&&se[2]===he[2]},e.equals=function Ge(se,he){const ve=se[0],Te=se[1],yt=se[2],xt=he[0],Ut=he[1],Nn=he[2];return Math.abs(ve-xt)<=vr*Math.max(1,Math.abs(ve),Math.abs(xt))&&Math.abs(Te-Ut)<=vr*Math.max(1,Math.abs(Te),Math.abs(Ut))&&Math.abs(yt-Nn)<=vr*Math.max(1,Math.abs(yt),Math.abs(Nn))};const $e=t();e.makeRotation=function tt(se,he,ve){const Te=ne(he,ve);if(Math.abs(Te)<1e-4)return le.setIdentity(se);if(Math.abs(Te-Math.PI)0?p(se,he):j(se,p(se,he)),se};const Qn=t(),qe=t();e.triangleNormal=function dt(se,he,ve,Te){return h(Qn,ve,he),h(qe,Te,he),$(se,q(se,Qn,qe))},e.toString=function gt(se,he){return`[${se[0].toPrecision(he)} ${se[1].toPrecision(he)} ${se[2].toPrecision(he)}]`},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)}(v||(v={}));const Wx=Math.PI/2,EZ=Math.PI/180;function Yn(e){return e*EZ}function su(e){return e/EZ}function $x(e){return 0!==e&&!(e&e-1)}function PZ(e,t){return e*t}function le(){return le.zero()}function Kt(){return Kt.zero()}function Me(){return Me.zero()}function nn(){return nn.zero()}function RI(e){return Object.keys(e)}function Rr(e){throw new Error("unreachable")}function kI(e){return"function"==typeof e?.then}function _r(){return _r.zero()}var wn,te,Xn,QF,Dg,Yx;function Ig(e,t,n){for(;t9||s<0)return o*i|0;i=10*i+s|0}return o*i}function MZ(e,t,n,r){return 43===t.charCodeAt(n)&&n++,e*Math.pow(10,jh(t,n,r))}function rp(e,t,n){let r=t,i=1,o=0,s=0,a=1;for(45===e.charCodeAt(r)?(i=-1,++r):43===e.charCodeAt(r)&&++r;r=0&&c<10)){if(-2===c){for(++r;r=0&&c<10))return 53===c||21===c?MZ(i*(o+s/a),e,r+1,n):i*(o+s/a);s=10*s+c,a*=10,++r}return i*(o+s/a)}if(53===c||21===c)return MZ(i*o,e,r+1,n);break}o=10*o+c,++r}return i*o}function kZ(e,t,n,r){return{schema:n,__array:void 0,isDefined:0===r,rowCount:t,value:o=>e,valueKind:o=>r,toArray:o=>{const{array:s}=qx(t,o);for(let a=0,c=s.length;a!0}}function NI({value:e,valueKind:t,areValuesEqual:n,rowCount:r,schema:i}){return{schema:i,__array:void 0,isDefined:!0,rowCount:r,value:e,valueKind:t||(o=>0),toArray:o=>{const{array:s,start:a}=qx(r,o);for(let c=0,u=s.length;ce(o)===e(s))}}function ip({array:e,schema:t,valueKind:n}){const r=e.length,i=t.T,o="str"===t.valueType?"lowercase"===t.transform?a=>{const c=e[a];return"string"==typeof c?c.toLowerCase():`${c??i}`.toLowerCase()}:"uppercase"===t.transform?a=>{const c=e[a];return"string"==typeof c?c.toUpperCase():`${c??i}`.toUpperCase()}:a=>{const c=e[a];return"string"==typeof c?c:`${c??i}`}:a=>e[a],s=WF(e);return{schema:t,__array:e,isDefined:!0,rowCount:r,value:o,valueKind:n||(a=>0),toArray:"str"===t.valueType?"lowercase"===t.transform?a=>{const{start:c,end:u}=Ub(r,a),l=new(a&&typeof a.array<"u"?a.array:e.constructor)(u-c);for(let d=0,f=u-c;d{const{start:c,end:u}=Ub(r,a),l=new(a&&typeof a.array<"u"?a.array:e.constructor)(u-c);for(let d=0,f=u-c;d{const{start:c,end:u}=Ub(r,a),l=new(a&&typeof a.array<"u"?a.array:e.constructor)(u-c);for(let d=0,f=u-c;dPI(e,a):a=>{const{start:c,end:u}=Ub(r,a);if(0===c&&u===e.length)return e;const l=new(a&&typeof a.array<"u"?a.array:e.constructor)(u-c);for(let d=0,f=u-c;de[a]===e[c]}}function FI(e,t,n){return e[t]-e[n]}function Tg(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function NZ(e,t,n,r){const i=n+r>>1;return t(e,n,r)>0?t(e,n,i)>0?t(e,i,r)>0?i:r:n:t(e,r,i)>0?t(e,i,n)>0?i:n:r}function _Me(e,t,n){const{cmp:r,swap:i,data:o,parts:s}=e;let a=t+1,c=n;for(i(o,t,NZ(o,r,t,n));r(o,c,t)>0;)--c;for(let u=t+1;u<=c;u++){const l=r(o,u,t);if(l>0){for(i(o,u,c),--c;r(o,c,t)>0;)--c;u--}else 0===l&&(i(o,u,a),a++)}for(let u=t;u=r&&t(e,s,s+1)>0;)n(e,s,s+1),s-=1}}function BI(e,t,n){const{parts:r}=e;for(;ts;)--o;for(let a=n+1;a<=o;a++){const c=e[a];if(c>s){for(Tg(e,a,o),--o;e[o]>s;)--o;a--}else c===s&&(Tg(e,a,i),++i)}for(let a=n;a=t&&e[o]>i;)e[o+1]=e[o],o-=1;e[o+1]=i}}function ZF(e,t,n,r){for(;nge)return!1;return!0}function l(U,Y,ge,Se){U[4*ge+Y]=Se}function h(U,Y){return U[0]=Y[0],U[1]=Y[1],U[2]=Y[2],U[3]=Y[3],U[4]=Y[4],U[5]=Y[5],U[6]=Y[6],U[7]=Y[7],U[8]=Y[8],U[9]=Y[9],U[10]=Y[10],U[11]=Y[11],U[12]=Y[12],U[13]=Y[13],U[14]=Y[14],U[15]=Y[15],U}function x(U,Y){const ge=Y[0]+Y[5]+Y[10];let Se=0;return ge>0?(Se=2*Math.sqrt(ge+1),U[3]=.25*Se,U[0]=(Y[6]-Y[9])/Se,U[1]=(Y[8]-Y[2])/Se,U[2]=(Y[1]-Y[4])/Se):Y[0]>Y[5]&&Y[0]>Y[10]?(Se=2*Math.sqrt(1+Y[0]-Y[5]-Y[10]),U[3]=(Y[6]-Y[9])/Se,U[0]=.25*Se,U[1]=(Y[1]+Y[4])/Se,U[2]=(Y[8]+Y[2])/Se):Y[5]>Y[10]?(Se=2*Math.sqrt(1+Y[5]-Y[0]-Y[10]),U[3]=(Y[8]-Y[2])/Se,U[0]=(Y[1]+Y[4])/Se,U[1]=.25*Se,U[2]=(Y[6]+Y[9])/Se):(Se=2*Math.sqrt(1+Y[10]-Y[0]-Y[5]),U[3]=(Y[1]-Y[4])/Se,U[0]=(Y[8]+Y[2])/Se,U[1]=(Y[6]+Y[9])/Se,U[2]=.25*Se),U}function A(U,Y){const ge=Y[0],Se=Y[1],Re=Y[2],Ne=Y[3],Ge=Y[4],$e=Y[5],tt=Y[6],ke=Y[7],Xe=Y[8],ot=Y[9],_t=Y[10],ut=Y[11],Ct=Y[12],Et=Y[13],Xt=Y[14],ln=Y[15],Qn=ge*$e-Se*Ge,qe=ge*tt-Re*Ge,dt=ge*ke-Ne*Ge,gt=Se*tt-Re*$e,se=Se*ke-Ne*$e,he=Re*ke-Ne*tt,ve=Xe*Et-ot*Ct,Te=Xe*Xt-_t*Ct,yt=Xe*ln-ut*Ct,xt=ot*Xt-_t*Et,Ut=ot*ln-ut*Et,Nn=_t*ln-ut*Xt;let hn=Qn*Nn-qe*Ut+dt*xt+gt*yt-se*Te+he*ve;return!!hn&&(hn=1/hn,U[0]=($e*Nn-tt*Ut+ke*xt)*hn,U[1]=(Re*Ut-Se*Nn-Ne*xt)*hn,U[2]=(Et*he-Xt*se+ln*gt)*hn,U[3]=(_t*se-ot*he-ut*gt)*hn,U[4]=(tt*yt-Ge*Nn-ke*Te)*hn,U[5]=(ge*Nn-Re*yt+Ne*Te)*hn,U[6]=(Xt*dt-Ct*he-ln*qe)*hn,U[7]=(Xe*he-_t*dt+ut*qe)*hn,U[8]=(Ge*Ut-$e*yt+ke*ve)*hn,U[9]=(Se*yt-ge*Ut-Ne*ve)*hn,U[10]=(Ct*se-Et*dt+ln*Qn)*hn,U[11]=(ot*dt-Xe*se-ut*Qn)*hn,U[12]=($e*Te-Ge*xt-tt*ve)*hn,U[13]=(ge*xt-Se*Te+Re*ve)*hn,U[14]=(Et*qe-Ct*gt-Xt*Qn)*hn,U[15]=(Xe*gt-ot*qe+_t*Qn)*hn,!0)}function w(U,Y,ge){const Se=Y[0],Re=Y[1],Ne=Y[2],Ge=Y[3],$e=Y[4],tt=Y[5],ke=Y[6],Xe=Y[7],ot=Y[8],_t=Y[9],ut=Y[10],Ct=Y[11],Et=Y[12],Xt=Y[13],ln=Y[14],Qn=Y[15];let qe=ge[0],dt=ge[1],gt=ge[2],se=ge[3];return U[0]=qe*Se+dt*$e+gt*ot+se*Et,U[1]=qe*Re+dt*tt+gt*_t+se*Xt,U[2]=qe*Ne+dt*ke+gt*ut+se*ln,U[3]=qe*Ge+dt*Xe+gt*Ct+se*Qn,qe=ge[4],dt=ge[5],gt=ge[6],se=ge[7],U[4]=qe*Se+dt*$e+gt*ot+se*Et,U[5]=qe*Re+dt*tt+gt*_t+se*Xt,U[6]=qe*Ne+dt*ke+gt*ut+se*ln,U[7]=qe*Ge+dt*Xe+gt*Ct+se*Qn,qe=ge[8],dt=ge[9],gt=ge[10],se=ge[11],U[8]=qe*Se+dt*$e+gt*ot+se*Et,U[9]=qe*Re+dt*tt+gt*_t+se*Xt,U[10]=qe*Ne+dt*ke+gt*ut+se*ln,U[11]=qe*Ge+dt*Xe+gt*Ct+se*Qn,qe=ge[12],dt=ge[13],gt=ge[14],se=ge[15],U[12]=qe*Se+dt*$e+gt*ot+se*Et,U[13]=qe*Re+dt*tt+gt*_t+se*Xt,U[14]=qe*Ne+dt*ke+gt*ut+se*ln,U[15]=qe*Ge+dt*Xe+gt*Ct+se*Qn,U}function F(U,Y,ge){let Se=ge[0],Re=ge[1],Ne=ge[2],Ge=Math.sqrt(Se*Se+Re*Re+Ne*Ne);if(Math.abs(Ge)"u"?vr:Y)},e.hasNaN=function c(U){for(let Y=0;Y<16;Y++)if(isNaN(U[Y]))return!0;return!1},e.areEqual=u,e.setValue=l,e.getValue=function d(U,Y,ge){return U[4*ge+Y]},e.toArray=function f(U,Y,ge){return Y[ge+0]=U[0],Y[ge+1]=U[1],Y[ge+2]=U[2],Y[ge+3]=U[3],Y[ge+4]=U[4],Y[ge+5]=U[5],Y[ge+6]=U[6],Y[ge+7]=U[7],Y[ge+8]=U[8],Y[ge+9]=U[9],Y[ge+10]=U[10],Y[ge+11]=U[11],Y[ge+12]=U[12],Y[ge+13]=U[13],Y[ge+14]=U[14],Y[ge+15]=U[15],Y},e.fromArray=function p(U,Y,ge){return U[0]=Y[ge+0],U[1]=Y[ge+1],U[2]=Y[ge+2],U[3]=Y[ge+3],U[4]=Y[ge+4],U[5]=Y[ge+5],U[6]=Y[ge+6],U[7]=Y[ge+7],U[8]=Y[ge+8],U[9]=Y[ge+9],U[10]=Y[ge+10],U[11]=Y[ge+11],U[12]=Y[ge+12],U[13]=Y[ge+13],U[14]=Y[ge+14],U[15]=Y[ge+15],U},e.fromBasis=function m(U,Y,ge,Se){return i(U),l(U,0,0,Y[0]),l(U,1,0,Y[1]),l(U,2,0,Y[2]),l(U,0,1,ge[0]),l(U,1,1,ge[1]),l(U,2,1,ge[2]),l(U,0,2,Se[0]),l(U,1,2,Se[1]),l(U,2,2,Se[2]),l(U,3,3,1),U},e.copy=h,e.clone=function g(U){return h(t(),U)},e.getTranslation=function y(U,Y){return U[0]=Y[12],U[1]=Y[13],U[2]=Y[14],U},e.getScaling=function b(U,Y){const ge=Y[0],Se=Y[1],Re=Y[2],Ne=Y[4],Ge=Y[5],$e=Y[6],tt=Y[8],ke=Y[9],Xe=Y[10];return U[0]=Math.sqrt(ge*ge+Se*Se+Re*Re),U[1]=Math.sqrt(Ne*Ne+Ge*Ge+$e*$e),U[2]=Math.sqrt(tt*tt+ke*ke+Xe*Xe),U},e.getRotation=x,e.extractRotation=function _(U,Y){const ge=1/Math.sqrt(Y[0]*Y[0]+Y[1]*Y[1]+Y[2]*Y[2]),Se=1/Math.sqrt(Y[4]*Y[4]+Y[5]*Y[5]+Y[6]*Y[6]),Re=1/Math.sqrt(Y[8]*Y[8]+Y[9]*Y[9]+Y[10]*Y[10]);return U[0]=Y[0]*ge,U[1]=Y[1]*ge,U[2]=Y[2]*ge,U[3]=0,U[4]=Y[4]*Se,U[5]=Y[5]*Se,U[6]=Y[6]*Se,U[7]=0,U[8]=Y[8]*Re,U[9]=Y[9]*Re,U[10]=Y[10]*Re,U[11]=0,U[12]=0,U[13]=0,U[14]=0,U[15]=1,U},e.transpose=function S(U,Y){if(U===Y){const ge=Y[1],Se=Y[2],Re=Y[3],Ne=Y[6],Ge=Y[7],$e=Y[11];U[1]=Y[4],U[2]=Y[8],U[3]=Y[12],U[4]=ge,U[6]=Y[9],U[7]=Y[13],U[8]=Se,U[9]=Ne,U[11]=Y[14],U[12]=Re,U[13]=Ge,U[14]=$e}else U[0]=Y[0],U[1]=Y[4],U[2]=Y[8],U[3]=Y[12],U[4]=Y[1],U[5]=Y[5],U[6]=Y[9],U[7]=Y[13],U[8]=Y[2],U[9]=Y[6],U[10]=Y[10],U[11]=Y[14],U[12]=Y[3],U[13]=Y[7],U[14]=Y[11],U[15]=Y[15];return U},e.tryInvert=A,e.invert=function E(U,Y){return A(U,Y)||console.warn("non-invertible matrix.",Y),U},e.mul=w,e.mulOffset=function D(U,Y,ge,Se,Re,Ne){const Ge=Y[0+Re],$e=Y[1+Re],tt=Y[2+Re],ke=Y[3+Re],Xe=Y[4+Re],ot=Y[5+Re],_t=Y[6+Re],ut=Y[7+Re],Ct=Y[8+Re],Et=Y[9+Re],Xt=Y[10+Re],ln=Y[11+Re],Qn=Y[12+Re],qe=Y[13+Re],dt=Y[14+Re],gt=Y[15+Re];let se=ge[0+Ne],he=ge[1+Ne],ve=ge[2+Ne],Te=ge[3+Ne];return U[0+Se]=se*Ge+he*Xe+ve*Ct+Te*Qn,U[1+Se]=se*$e+he*ot+ve*Et+Te*qe,U[2+Se]=se*tt+he*_t+ve*Xt+Te*dt,U[3+Se]=se*ke+he*ut+ve*ln+Te*gt,se=ge[4+Ne],he=ge[5+Ne],ve=ge[6+Ne],Te=ge[7+Ne],U[4+Se]=se*Ge+he*Xe+ve*Ct+Te*Qn,U[5+Se]=se*$e+he*ot+ve*Et+Te*qe,U[6+Se]=se*tt+he*_t+ve*Xt+Te*dt,U[7+Se]=se*ke+he*ut+ve*ln+Te*gt,se=ge[8+Ne],he=ge[9+Ne],ve=ge[10+Ne],Te=ge[11+Ne],U[8+Se]=se*Ge+he*Xe+ve*Ct+Te*Qn,U[9+Se]=se*$e+he*ot+ve*Et+Te*qe,U[10+Se]=se*tt+he*_t+ve*Xt+Te*dt,U[11+Se]=se*ke+he*ut+ve*ln+Te*gt,se=ge[12+Ne],he=ge[13+Ne],ve=ge[14+Ne],Te=ge[15+Ne],U[12+Se]=se*Ge+he*Xe+ve*Ct+Te*Qn,U[13+Se]=se*$e+he*ot+ve*Et+Te*qe,U[14+Se]=se*tt+he*_t+ve*Xt+Te*dt,U[15+Se]=se*ke+he*ut+ve*ln+Te*gt,U},e.mul3=function I(U,Y,ge,Se){return w(U,w(U,Y,ge),Se)},e.translate=function R(U,Y,ge){const Se=ge[0],Re=ge[1],Ne=ge[2];let Ge,$e,tt,ke,Xe,ot,_t,ut,Ct,Et,Xt,ln;return Y===U?(U[12]=Y[0]*Se+Y[4]*Re+Y[8]*Ne+Y[12],U[13]=Y[1]*Se+Y[5]*Re+Y[9]*Ne+Y[13],U[14]=Y[2]*Se+Y[6]*Re+Y[10]*Ne+Y[14],U[15]=Y[3]*Se+Y[7]*Re+Y[11]*Ne+Y[15]):(Ge=Y[0],$e=Y[1],tt=Y[2],ke=Y[3],Xe=Y[4],ot=Y[5],_t=Y[6],ut=Y[7],Ct=Y[8],Et=Y[9],Xt=Y[10],ln=Y[11],U[0]=Ge,U[1]=$e,U[2]=tt,U[3]=ke,U[4]=Xe,U[5]=ot,U[6]=_t,U[7]=ut,U[8]=Ct,U[9]=Et,U[10]=Xt,U[11]=ln,U[12]=Ge*Se+Xe*Re+Ct*Ne+Y[12],U[13]=$e*Se+ot*Re+Et*Ne+Y[13],U[14]=tt*Se+_t*Re+Xt*Ne+Y[14],U[15]=ke*Se+ut*Re+ln*Ne+Y[15]),U},e.fromTranslation=function T(U,Y){return U[0]=1,U[1]=0,U[2]=0,U[3]=0,U[4]=0,U[5]=1,U[6]=0,U[7]=0,U[8]=0,U[9]=0,U[10]=1,U[11]=0,U[12]=Y[0],U[13]=Y[1],U[14]=Y[2],U[15]=1,U},e.setTranslation=function M(U,Y){return U[12]=Y[0],U[13]=Y[1],U[14]=Y[2],U},e.setAxes=function N(U,Y,ge,Se){return U[0]=ge[0],U[4]=ge[1],U[8]=ge[2],U[1]=Se[0],U[5]=Se[1],U[9]=Se[2],U[2]=Y[0],U[6]=Y[1],U[10]=Y[2],U},e.rotate=function V(U,Y,ge,Se){let Re=Se[0],Ne=Se[1],Ge=Se[2],$e=Math.sqrt(Re*Re+Ne*Ne+Ge*Ge);if(Math.abs($e)0&&(ut=1/Math.sqrt(ut),Xe*=ut,ot*=ut,_t*=ut);let Ct=tt*_t-ke*ot,Et=ke*Xe-$e*_t,Xt=$e*ot-tt*Xe;return ut=Ct*Ct+Et*Et+Xt*Xt,ut>0&&(ut=1/Math.sqrt(ut),Ct*=ut,Et*=ut,Xt*=ut),U[0]=Ct,U[1]=Et,U[2]=Xt,U[3]=0,U[4]=ot*Xt-_t*Et,U[5]=_t*Ct-Xe*Xt,U[6]=Xe*Et-ot*Ct,U[7]=0,U[8]=Xe,U[9]=ot,U[10]=_t,U[11]=0,U[12]=Re,U[13]=Ne,U[14]=Ge,U[15]=1,U},e.fromPermutation=function ne(U,Y){i(U);for(let ge=0;ge<4;ge++)l(U,ge,Y[ge],1);return U},e.getMaxScaleOnAxis=function de(U){return Math.sqrt(Math.max(U[0]*U[0]+U[1]*U[1]+U[2]*U[2],U[4]*U[4]+U[5]*U[5]+U[6]*U[6],U[8]*U[8]+U[9]*U[9]+U[10]*U[10]))};const we=[1,0,0],Le=[0,1,0],We=[0,0,1];e.rotX90=F(t(),Yn(90),we),e.rotX180=F(t(),Yn(180),we),e.rotY90=F(t(),Yn(90),Le),e.rotY180=F(t(),Yn(180),Le),e.rotY270=F(t(),Yn(270),Le),e.rotZ90=F(t(),Yn(90),We),e.rotZ180=F(t(),Yn(180),We),e.rotXY90=w(t(),e.rotX90,e.rotY90),e.rotZY90=w(t(),e.rotZ90,e.rotY90),e.rotZYZ90=w(t(),e.rotZY90,e.rotZ90),e.rotZ90X180=w(t(),e.rotZ90,e.rotX180),e.rotY90Z180=w(t(),e.rotY90,e.rotZ180),e.id=n()}(le||(le={})),function(e){function t(){const O=[.1,0,0,0,0,0,0,0,0];return O[0]=0,O}function n(){const O=t();return O[0]=1,O[1]=0,O[2]=0,O[3]=0,O[4]=1,O[5]=0,O[6]=0,O[7]=0,O[8]=1,O}function a(O,H){return O[0]=H[0],O[1]=H[1],O[2]=H[2],O[3]=H[4],O[4]=H[5],O[5]=H[6],O[6]=H[8],O[7]=H[9],O[8]=H[10],O}e.zero=t,e.identity=n,e.setIdentity=function r(O){return O[0]=1,O[1]=0,O[2]=0,O[3]=0,O[4]=1,O[5]=0,O[6]=0,O[7]=0,O[8]=1,O},e.toArray=function i(O,H,W){return H[W+0]=O[0],H[W+1]=O[1],H[W+2]=O[2],H[W+3]=O[3],H[W+4]=O[4],H[W+5]=O[5],H[W+6]=O[6],H[W+7]=O[7],H[W+8]=O[8],H},e.fromArray=function o(O,H,W){return O[0]=H[W+0],O[1]=H[W+1],O[2]=H[W+2],O[3]=H[W+3],O[4]=H[W+4],O[5]=H[W+5],O[6]=H[W+6],O[7]=H[W+7],O[8]=H[W+8],O},e.fromColumns=function s(O,H,W,Q){return O[0]=H[0],O[1]=H[1],O[2]=H[2],O[3]=W[0],O[4]=W[1],O[5]=W[2],O[6]=Q[0],O[7]=Q[1],O[8]=Q[2],O},e.fromMat4=a,e.create=function c(O,H,W,Q,fe,X,J,ce,be){const ae=t();return ae[0]=O,ae[1]=H,ae[2]=W,ae[3]=Q,ae[4]=fe,ae[5]=X,ae[6]=J,ae[7]=ce,ae[8]=be,ae};const u=n();function p(O,H,W){for(let Q=0;Q<9;Q++)if(Math.abs(O[Q]-H[Q])>W)return!1;return!0}function g(O,H){return O[0]=H[0],O[1]=H[1],O[2]=H[2],O[3]=H[3],O[4]=H[4],O[5]=H[5],O[6]=H[6],O[7]=H[7],O[8]=H[8],O}function y(O,H){if(O===H){const W=H[1],Q=H[2],fe=H[5];O[1]=H[3],O[2]=H[6],O[3]=W,O[5]=H[7],O[6]=Q,O[7]=fe}else O[0]=H[0],O[1]=H[3],O[2]=H[6],O[3]=H[1],O[4]=H[4],O[5]=H[7],O[6]=H[2],O[7]=H[5],O[8]=H[8];return O}function b(O,H){const W=H[0],Q=H[1],fe=H[2],X=H[3],J=H[4],ce=H[5],be=H[6],ae=H[7],me=H[8],oe=me*J-ce*ae,K=-me*X+ce*be,ne=ae*X-J*be;let de=W*oe+Q*K+fe*ne;return de?(de=1/de,O[0]=oe*de,O[1]=(-me*Q+fe*ae)*de,O[2]=(ce*Q-fe*J)*de,O[3]=K*de,O[4]=(me*W-fe*be)*de,O[5]=(-ce*W+fe*X)*de,O[6]=ne*de,O[7]=(-ae*W+Q*be)*de,O[8]=(J*W-Q*X)*de,O):(console.warn("non-invertible matrix.",H),O)}function S(O){const fe=O[3],X=O[4],J=O[5],ce=O[6],be=O[7],ae=O[8];return O[0]*(ae*X-J*be)+O[1]*(-ae*fe+J*ce)+O[2]*(be*fe-X*ce)}function A(O){return O[0]+O[4]+O[8]}function E(O,H,W){return O[0]=H[0]-W[0],O[1]=H[1]-W[1],O[2]=H[2]-W[2],O[3]=H[3]-W[3],O[4]=H[4]-W[4],O[5]=H[5]-W[5],O[6]=H[6]-W[6],O[7]=H[7]-W[7],O[8]=H[8]-W[8],O}function T(O,H,W){return O[0]=H[0]*W,O[1]=H[1]*W,O[2]=H[2]*W,O[3]=H[3]*W,O[4]=H[4]*W,O[5]=H[5]*W,O[6]=H[6]*W,O[7]=H[7]*W,O[8]=H[8]*W,O}e.isIdentity=function l(O,H){return p(O,u,typeof H>"u"?vr:H)},e.hasNaN=function d(O){for(let H=0;H<9;H++)if(isNaN(O[H]))return!0;return!1},e.clone=function f(O){return g(t(),O)},e.areEqual=p,e.setValue=function m(O,H,W,Q){O[3*W+H]=Q},e.getValue=function h(O,H,W){return O[3*W+H]},e.copy=g,e.transpose=y,e.invert=b,e.symmtricFromUpper=function x(O,H){return O===H?(O[3]=H[1],O[6]=H[2],O[7]=H[5]):(O[0]=H[0],O[1]=H[1],O[2]=H[2],O[3]=H[1],O[4]=H[4],O[5]=H[5],O[6]=H[2],O[7]=H[5],O[8]=H[8]),O},e.symmtricFromLower=function _(O,H){return O===H?(O[1]=H[3],O[2]=H[6],O[5]=H[7]):(O[0]=H[0],O[1]=H[3],O[2]=H[6],O[3]=H[3],O[4]=H[4],O[5]=H[7],O[6]=H[6],O[7]=H[7],O[8]=H[8]),O},e.determinant=S,e.trace=A,e.sub=E,e.add=function w(O,H,W){return O[0]=H[0]+W[0],O[1]=H[1]+W[1],O[2]=H[2]+W[2],O[3]=H[3]+W[3],O[4]=H[4]+W[4],O[5]=H[5]+W[5],O[6]=H[6]+W[6],O[7]=H[7]+W[7],O[8]=H[8]+W[8],O},e.mul=function D(O,H,W){const Q=H[0],fe=H[1],X=H[2],J=H[3],ce=H[4],be=H[5],ae=H[6],me=H[7],oe=H[8],K=W[0],ne=W[1],de=W[2],we=W[3],Le=W[4],We=W[5],U=W[6],Y=W[7],ge=W[8];return O[0]=K*Q+ne*J+de*ae,O[1]=K*fe+ne*ce+de*me,O[2]=K*X+ne*be+de*oe,O[3]=we*Q+Le*J+We*ae,O[4]=we*fe+Le*ce+We*me,O[5]=we*X+Le*be+We*oe,O[6]=U*Q+Y*J+ge*ae,O[7]=U*fe+Y*ce+ge*me,O[8]=U*X+Y*be+ge*oe,O},e.subScalar=function I(O,H,W){return O[0]=H[0]-W,O[1]=H[1]-W,O[2]=H[2]-W,O[3]=H[3]-W,O[4]=H[4]-W,O[5]=H[5]-W,O[6]=H[6]-W,O[7]=H[7]-W,O[8]=H[8]-W,O},e.addScalar=function R(O,H,W){return O[0]=H[0]+W,O[1]=H[1]+W,O[2]=H[2]+W,O[3]=H[3]+W,O[4]=H[4]+W,O[5]=H[5]+W,O[6]=H[6]+W,O[7]=H[7]+W,O[8]=H[8]+W,O},e.mulScalar=T;const M=Math.PI/3,N=t();e.symmetricEigenvalues=function V(O,H){const W=H[1]*H[1]+H[2]*H[2]+H[5]*H[5];if(0===W)O[0]=H[0],O[1]=H[4],O[2]=H[8];else{const Q=A(H)/3,fe=H[0]-Q,X=H[4]-Q,J=H[8]-Q,be=Math.sqrt((fe*fe+X*X+J*J+2*W)/6);T(N,e.Identity,Q),E(N,H,N),T(N,N,1/be);const ae=S(N)/2,me=ae<=-1?M:ae>=1?0:Math.acos(ae)/3;O[0]=Q+2*be*Math.cos(me),O[2]=Q+2*be*Math.cos(me+2*M),O[1]=3*Q-O[0]-O[2]}return O};const F=[.1,0,0],G=[.1,0,0],L=[.1,0,0],z=[.1,0,0],j=[.1,0,0],Z=[.1,0,0];e.eigenvector=function $(O,H,W){v.set(F,H[0]-W,H[1],H[2]),v.set(G,H[1],H[4]-W,H[5]),v.set(L,H[2],H[5],H[8]-W),v.cross(z,F,G),v.cross(j,F,L),v.cross(Z,G,L);const Q=v.dot(z,z),fe=v.dot(j,j),X=v.dot(Z,Z);let J=Q,ce=0;return fe>J&&(J=fe,ce=1),X>J&&(ce=2),0===ce?v.scale(O,z,1/Math.sqrt(Q)):1===ce?v.scale(O,j,1/Math.sqrt(fe)):v.scale(O,Z,1/Math.sqrt(X)),O},e.directionTransform=function ee(O,H){return a(O,H),b(O,O),y(O,O),O},e.Identity=n(),e.innerProduct=function q(O,H){return O[0]*H[0]+O[1]*H[1]+O[2]*H[2]+O[3]*H[3]+O[4]*H[4]+O[5]*H[5]+O[6]*H[6]+O[7]*H[7]+O[8]*H[8]}}(Kt||(Kt={})),function(e){function t(){const w=[.1,0];return w[0]=0,w}e.zero=t,e.clone=function n(w){const D=t();return D[0]=w[0],D[1]=w[1],D},e.create=function r(w,D){const I=t();return I[0]=w,I[1]=D,I},e.hasNaN=function i(w){return isNaN(w[0])||isNaN(w[1])},e.toArray=function o(w,D,I){return D[I+0]=w[0],D[I+1]=w[1],D},e.fromArray=function s(w,D,I){return w[0]=D[I+0],w[1]=D[I+1],w},e.copy=function a(w,D){return w[0]=D[0],w[1]=D[1],w},e.set=function c(w,D,I){return w[0]=D,w[1]=I,w},e.add=function u(w,D,I){return w[0]=D[0]+I[0],w[1]=D[1]+I[1],w},e.sub=function l(w,D,I){return w[0]=D[0]-I[0],w[1]=D[1]-I[1],w},e.mul=function d(w,D,I){return w[0]=D[0]*I[0],w[1]=D[1]*I[1],w},e.div=function f(w,D,I){return w[0]=D[0]/I[0],w[1]=D[1]/I[1],w},e.scale=function p(w,D,I){return w[0]=D[0]*I,w[1]=D[1]*I,w},e.round=function m(w,D){return w[0]=Math.round(D[0]),w[1]=Math.round(D[1]),w},e.ceil=function h(w,D){return w[0]=Math.ceil(D[0]),w[1]=Math.ceil(D[1]),w},e.floor=function g(w,D){return w[0]=Math.floor(D[0]),w[1]=Math.floor(D[1]),w},e.distance=function y(w,D){const I=D[0]-w[0],R=D[1]-w[1];return Math.sqrt(I*I+R*R)},e.squaredDistance=function b(w,D){const I=D[0]-w[0],R=D[1]-w[1];return I*I+R*R},e.magnitude=function x(w){const D=w[0],I=w[1];return Math.sqrt(D*D+I*I)},e.squaredMagnitude=function _(w){const D=w[0],I=w[1];return D*D+I*I},e.inverse=function S(w,D){return w[0]=1/D[0],w[1]=1/D[1],w},e.areEqual=function A(w,D){return w[0]===D[0]&&w[1]===D[1]},e.toString=function E(w,D){return`[${w[0].toPrecision(D)} ${w[1].toPrecision(D)}}]`}}(Me||(Me={})),function(e){function t(){const T=[.1,0,0,0];return T[0]=0,T}function i(T,M){return T[0]=M.center[0],T[1]=M.center[1],T[2]=M.center[2],T[3]=M.radius,T}e.zero=t,e.clone=function n(T){const M=t();return M[0]=T[0],M[1]=T[1],M[2]=T[2],M[3]=T[3],M},e.create=function r(T,M,N,V){const F=t();return F[0]=T,F[1]=M,F[2]=N,F[3]=V,F},e.fromSphere=i,e.ofSphere=function o(T){return i(t(),T)},e.hasNaN=function s(T){return isNaN(T[0])||isNaN(T[1])||isNaN(T[2])||isNaN(T[3])},e.toArray=function a(T,M,N){return M[N+0]=T[0],M[N+1]=T[1],M[N+2]=T[2],M[N+3]=T[3],M},e.fromArray=function c(T,M,N){return T[0]=M[N+0],T[1]=M[N+1],T[2]=M[N+2],T[3]=M[N+3],T},e.toVec3Array=function u(T,M,N){M[N+0]=T[0],M[N+1]=T[1],M[N+2]=T[2]},e.fromVec3Array=function l(T,M,N){return T[0]=M[N+0],T[1]=M[N+1],T[2]=M[N+2],T[3]=0,T},e.copy=function d(T,M){return T[0]=M[0],T[1]=M[1],T[2]=M[2],T[3]=M[3],T},e.set=function f(T,M,N,V,F){return T[0]=M,T[1]=N,T[2]=V,T[3]=F,T},e.add=function p(T,M,N){return T[0]=M[0]+N[0],T[1]=M[1]+N[1],T[2]=M[2]+N[2],T[3]=M[3]+N[3],T},e.distance=function m(T,M){const N=M[0]-T[0],V=M[1]-T[1],F=M[2]-T[2],G=M[3]-T[3];return Math.sqrt(N*N+V*V+F*F+G*G)},e.scale=function h(T,M,N){return T[0]=M[0]*N,T[1]=M[1]*N,T[2]=M[2]*N,T[4]=M[4]*N,T},e.round=function g(T,M){return T[0]=Math.round(M[0]),T[1]=Math.round(M[1]),T[2]=Math.round(M[2]),T[3]=Math.round(M[3]),T},e.ceil=function y(T,M){return T[0]=Math.ceil(M[0]),T[1]=Math.ceil(M[1]),T[2]=Math.ceil(M[2]),T[3]=Math.ceil(M[3]),T},e.floor=function b(T,M){return T[0]=Math.floor(M[0]),T[1]=Math.floor(M[1]),T[2]=Math.floor(M[2]),T[3]=Math.floor(M[3]),T},e.squaredDistance=function x(T,M){const N=M[0]-T[0],V=M[1]-T[1],F=M[2]-T[2],G=M[3]-T[3];return N*N+V*V+F*F+G*G},e.norm=function _(T){const M=T[0],N=T[1],V=T[2],F=T[3];return Math.sqrt(M*M+N*N+V*V+F*F)},e.squaredNorm=function S(T){const M=T[0],N=T[1],V=T[2],F=T[3];return M*M+N*N+V*V+F*F},e.transformMat4=function A(T,M,N){const V=M[0],F=M[1],G=M[2],L=M[3];return T[0]=N[0]*V+N[4]*F+N[8]*G+N[12]*L,T[1]=N[1]*V+N[5]*F+N[9]*G+N[13]*L,T[2]=N[2]*V+N[6]*F+N[10]*G+N[14]*L,T[3]=N[3]*V+N[7]*F+N[11]*G+N[15]*L,T},e.dot=function E(T,M){return T[0]*M[0]+T[1]*M[1]+T[2]*M[2]+T[3]*M[3]},e.inverse=function w(T,M){return T[0]=1/M[0],T[1]=1/M[1],T[2]=1/M[2],T[3]=1/M[3],T},e.exactEquals=function D(T,M){return T[0]===M[0]&&T[1]===M[1]&&T[2]===M[2]&&T[3]===M[3]},e.equals=function I(T,M){const N=T[0],V=T[1],F=T[2],G=T[3],L=M[0],z=M[1],j=M[2],Z=M[3];return Math.abs(N-L)<=vr*Math.max(1,Math.abs(N),Math.abs(L))&&Math.abs(V-z)<=vr*Math.max(1,Math.abs(V),Math.abs(z))&&Math.abs(F-j)<=vr*Math.max(1,Math.abs(F),Math.abs(j))&&Math.abs(G-Z)<=vr*Math.max(1,Math.abs(G),Math.abs(Z))},e.toString=function R(T,M){return`[${T[0].toPrecision(M)} ${T[1].toPrecision(M)} ${T[2].toPrecision(M)} ${T[3].toPrecision(M)}]`}}(nn||(nn={})),function(e){function t(){const q=[.1,0,0,0];return q[0]=0,q}function n(){const q=t();return q[3]=1,q}function s(q,O,H){H*=.5;const W=Math.sin(H);return q[0]=W*O[0],q[1]=W*O[1],q[2]=W*O[2],q[3]=Math.cos(H),q}function p(q,O,H,W){const Q=O[0],fe=O[1],X=O[2],J=O[3];let oe,K,ne,de,we,ce=H[0],be=H[1],ae=H[2],me=H[3];return K=Q*ce+fe*be+X*ae+J*me,K<0&&(K=-K,ce=-ce,be=-be,ae=-ae,me=-me),1-K>1e-6?(oe=Math.acos(K),ne=Math.sin(oe),de=Math.sin((1-W)*oe)/ne,we=Math.sin(W*oe)/ne):(de=1-W,we=W),q[0]=de*Q+we*ce,q[1]=de*fe+we*be,q[2]=de*X+we*ae,q[3]=de*J+we*me,q}function y(q,O){const H=O[0]+O[4]+O[8];let W;if(H>0)W=Math.sqrt(H+1),q[3]=.5*W,W=.5/W,q[0]=(O[5]-O[7])*W,q[1]=(O[6]-O[2])*W,q[2]=(O[1]-O[3])*W;else{let Q=0;O[4]>O[0]&&(Q=1),O[8]>O[3*Q+Q]&&(Q=2);const fe=(Q+1)%3,X=(Q+2)%3;W=Math.sqrt(O[3*Q+Q]-O[3*fe+fe]-O[3*X+X]+1),q[Q]=.5*W,W=.5/W,q[3]=(O[3*fe+X]-O[3*X+fe])*W,q[fe]=(O[3*fe+Q]+O[3*Q+fe])*W,q[X]=(O[3*X+Q]+O[3*Q+X])*W}return q}e.zero=t,e.identity=n,e.setIdentity=function r(q){q[0]=0,q[1]=0,q[2]=0,q[3]=1},e.hasNaN=function i(q){return isNaN(q[0])||isNaN(q[1])||isNaN(q[2])||isNaN(q[3])},e.create=function o(q,O,H,W){const Q=n();return Q[0]=q,Q[1]=O,Q[2]=H,Q[3]=W,Q},e.setAxisAngle=s,e.getAxisAngle=function a(q,O){const H=2*Math.acos(O[3]),W=Math.sin(H/2);return 0!==W?(q[0]=O[0]/W,q[1]=O[1]/W,q[2]=O[2]/W):(q[0]=1,q[1]=0,q[2]=0),H},e.multiply=function c(q,O,H){const W=O[0],Q=O[1],fe=O[2],X=O[3],J=H[0],ce=H[1],be=H[2],ae=H[3];return q[0]=W*ae+X*J+Q*be-fe*ce,q[1]=Q*ae+X*ce+fe*J-W*be,q[2]=fe*ae+X*be+W*ce-Q*J,q[3]=X*ae-W*J-Q*ce-fe*be,q},e.rotateX=function u(q,O,H){H*=.5;const W=O[0],Q=O[1],fe=O[2],X=O[3],J=Math.sin(H),ce=Math.cos(H);return q[0]=W*ce+X*J,q[1]=Q*ce+fe*J,q[2]=fe*ce-Q*J,q[3]=X*ce-W*J,q},e.rotateY=function l(q,O,H){H*=.5;const W=O[0],Q=O[1],fe=O[2],X=O[3],J=Math.sin(H),ce=Math.cos(H);return q[0]=W*ce-fe*J,q[1]=Q*ce+X*J,q[2]=fe*ce+W*J,q[3]=X*ce-Q*J,q},e.rotateZ=function d(q,O,H){H*=.5;const W=O[0],Q=O[1],fe=O[2],X=O[3],J=Math.sin(H),ce=Math.cos(H);return q[0]=W*ce+Q*J,q[1]=Q*ce-W*J,q[2]=fe*ce+X*J,q[3]=X*ce-fe*J,q},e.calculateW=function f(q,O){const H=O[0],W=O[1],Q=O[2];return q[0]=H,q[1]=W,q[2]=Q,q[3]=Math.sqrt(Math.abs(1-H*H-W*W-Q*Q)),q},e.slerp=p,e.invert=function m(q,O){const H=O[0],W=O[1],Q=O[2],fe=O[3],X=H*H+W*W+Q*Q+fe*fe,J=X?1/X:0;return q[0]=-H*J,q[1]=-W*J,q[2]=-Q*J,q[3]=fe*J,q},e.conjugate=function h(q,O){return q[0]=-O[0],q[1]=-O[1],q[2]=-O[2],q[3]=O[3],q},e.dot=function g(q,O){return q[0]*O[0]+q[1]*O[1]+q[2]*O[2]+q[3]*O[3]},e.fromMat3=y,e.fromEuler=function b(q,O,H){const[W,Q,fe]=O,X=Math.cos(W/2),J=Math.cos(Q/2),ce=Math.cos(fe/2),be=Math.sin(W/2),ae=Math.sin(Q/2),me=Math.sin(fe/2);switch(H){case"XYZ":q[0]=be*J*ce+X*ae*me,q[1]=X*ae*ce-be*J*me,q[2]=X*J*me+be*ae*ce,q[3]=X*J*ce-be*ae*me;break;case"YXZ":q[0]=be*J*ce+X*ae*me,q[1]=X*ae*ce-be*J*me,q[2]=X*J*me-be*ae*ce,q[3]=X*J*ce+be*ae*me;break;case"ZXY":q[0]=be*J*ce-X*ae*me,q[1]=X*ae*ce+be*J*me,q[2]=X*J*me+be*ae*ce,q[3]=X*J*ce-be*ae*me;break;case"ZYX":q[0]=be*J*ce-X*ae*me,q[1]=X*ae*ce+be*J*me,q[2]=X*J*me-be*ae*ce,q[3]=X*J*ce+be*ae*me;break;case"YZX":q[0]=be*J*ce+X*ae*me,q[1]=X*ae*ce+be*J*me,q[2]=X*J*me-be*ae*ce,q[3]=X*J*ce-be*ae*me;break;case"XZY":q[0]=be*J*ce-X*ae*me,q[1]=X*ae*ce-be*J*me,q[2]=X*J*me+be*ae*ce,q[3]=X*J*ce+be*ae*me;break;default:Rr()}return q};const x=[0,0,0];function M(q,O){const H=O[0],W=O[1],Q=O[2],fe=O[3];let X=H*H+W*W+Q*Q+fe*fe;return X>0&&(X=1/Math.sqrt(X),q[0]=H*X,q[1]=W*X,q[2]=Q*X,q[3]=fe*X),q}e.fromUnitVec3=function _(q,O,H){let W=v.dot(O,H)+1;return WMath.abs(O[2])?v.set(x,-O[1],O[0],0):v.set(x,0,-O[2],O[1])):v.cross(x,O,H),q[0]=x[0],q[1]=x[1],q[2]=x[2],q[3]=W,M(q,q),q},e.clone=function S(q){const O=t();return O[0]=q[0],O[1]=q[1],O[2]=q[2],O[3]=q[3],O},e.toArray=function A(q,O,H){return O[H+0]=q[0],O[H+1]=q[1],O[H+2]=q[2],O[H+3]=q[3],O},e.fromArray=function E(q,O,H){return q[0]=O[H+0],q[1]=O[H+1],q[2]=O[H+2],q[3]=O[H+3],q},e.copy=function w(q,O){return q[0]=O[0],q[1]=O[1],q[2]=O[2],q[3]=O[3],q},e.set=function D(q,O,H,W,Q){return q[0]=O,q[1]=H,q[2]=W,q[3]=Q,q},e.exactEquals=function I(q,O){return q[0]===O[0]&&q[1]===O[1]&&q[2]===O[2]&&q[3]===O[3]},e.equals=function R(q,O){const H=q[0],W=q[1],Q=q[2],fe=q[3],X=O[0],J=O[1],ce=O[2],be=O[3];return Math.abs(H-X)<=vr*Math.max(1,Math.abs(H),Math.abs(X))&&Math.abs(W-J)<=vr*Math.max(1,Math.abs(W),Math.abs(J))&&Math.abs(Q-ce)<=vr*Math.max(1,Math.abs(Q),Math.abs(ce))&&Math.abs(fe-be)<=vr*Math.max(1,Math.abs(fe),Math.abs(be))},e.add=function T(q,O,H){return q[0]=O[0]+H[0],q[1]=O[1]+H[1],q[2]=O[2]+H[2],q[3]=O[3]+H[3],q},e.normalize=M;const N=[0,0,0],V=[1,0,0],F=[0,1,0];e.rotationTo=function G(q,O,H){const W=v.dot(O,H);return W<-.999999?(v.cross(N,V,O),v.magnitude(N)<1e-6&&v.cross(N,F,O),v.normalize(N,N),s(q,N,Math.PI),q):W>.999999?(q[0]=0,q[1]=0,q[2]=0,q[3]=1,q):(v.cross(N,O,H),q[0]=N[0],q[1]=N[1],q[2]=N[2],q[3]=1+W,M(q,q))};const L=t(),z=t();e.sqlerp=function j(q,O,H,W,Q,fe){return p(L,O,Q,fe),p(z,H,W,fe),p(q,L,z,2*fe*(1-fe)),q};const Z=[0,0,0,0,0,0,0,0,0];e.setAxes=function $(q,O,H,W){return Z[0]=H[0],Z[3]=H[1],Z[6]=H[2],Z[1]=W[0],Z[4]=W[1],Z[7]=W[2],Z[2]=-O[0],Z[5]=-O[1],Z[8]=-O[2],M(q,y(q,Z))},e.toString=function ee(q,O){return`[${q[0].toPrecision(O)} ${q[1].toPrecision(O)} ${q[2].toPrecision(O)} ${q[3].toPrecision(O)}]`},e.Identity=n()}(_r||(_r={})),function(e){function r(S,A,E){const w=function t(S,A,E){const w=[];for(let I=0;Iw[D],set:(w,D,I)=>w[D]=I,add:(w,D,I)=>w[D]+=I,dataOffset:w=>w,getCoords:(w,D)=>(D[0]=w,D)};case 2:if(0===E[0]&&1===E[1]){const w=A[0];return{get:(D,I,R)=>D[R*w+I],set:(D,I,R,T)=>D[R*w+I]=T,add:(D,I,R,T)=>D[R*w+I]+=T,dataOffset:(D,I)=>I*w+D,getCoords:(D,I)=>(I[0]=D%w,I[1]=Math.floor(D/w),I)}}if(1===E[0]&&0===E[1]){const w=A[1];return{get:(D,I,R)=>D[I*w+R],set:(D,I,R,T)=>D[I*w+R]=T,add:(D,I,R,T)=>D[I*w+R]+=T,dataOffset:(D,I)=>D*w+I,getCoords:(D,I)=>(I[0]=Math.floor(D/w),I[1]=D%w,I)}}throw new Error("bad axis order");case 3:if(0===E[0]&&1===E[1]&&2===E[2]){const w=A[0],D=A[1],I=w*D;return{get:(R,T,M,N)=>R[T+M*w+N*I],set:(R,T,M,N,V)=>R[T+M*w+N*I]=V,add:(R,T,M,N,V)=>R[T+M*w+N*I]+=V,dataOffset:(R,T,M)=>R+T*w+M*I,getCoords:(R,T)=>{const M=Math.floor(R/w);return T[0]=R%w,T[1]=M%D,T[2]=Math.floor(M/D),T}}}if(0===E[0]&&2===E[1]&&1===E[2]){const w=A[0],D=A[2],I=w*D;return{get:(R,T,M,N)=>R[T+N*w+M*I],set:(R,T,M,N,V)=>R[T+N*w+M*I]=V,add:(R,T,M,N,V)=>R[T+N*w+M*I]+=V,dataOffset:(R,T,M)=>R+M*w+T*I,getCoords:(R,T)=>{const M=Math.floor(R/w);return T[0]=R%w,T[1]=Math.floor(M/D),T[2]=M%D,T}}}if(1===E[0]&&0===E[1]&&2===E[2]){const w=A[1],D=A[0],I=w*D;return{get:(R,T,M,N)=>R[M+T*w+N*I],set:(R,T,M,N,V)=>R[M+T*w+N*I]=V,add:(R,T,M,N,V)=>R[M+T*w+N*I]+=V,dataOffset:(R,T,M)=>T+R*w+M*I,getCoords:(R,T)=>{const M=Math.floor(R/w);return T[0]=M%D,T[1]=R%w,T[2]=Math.floor(M/D),T}}}if(1===E[0]&&2===E[1]&&0===E[2]){const w=A[1],D=A[2],I=w*D;return{get:(R,T,M,N)=>R[M+N*w+T*I],set:(R,T,M,N,V)=>R[M+N*w+T*I]=V,add:(R,T,M,N,V)=>R[M+N*w+T*I]+=V,dataOffset:(R,T,M)=>T+M*w+R*I,getCoords:(R,T)=>{const M=Math.floor(R/w);return T[0]=Math.floor(M/D),T[1]=R%w,T[2]=M%D,T}}}if(2===E[0]&&0===E[1]&&1===E[2]){const w=A[2],D=A[0],I=w*D;return{get:(R,T,M,N)=>R[N+T*w+M*I],set:(R,T,M,N,V)=>R[N+T*w+M*I]=V,add:(R,T,M,N,V)=>R[N+T*w+M*I]+=V,dataOffset:(R,T,M)=>M+R*w+T*I,getCoords:(R,T)=>{const M=Math.floor(R/w);return T[0]=M%D,T[1]=Math.floor(M/D),T[2]=R%w,T}}}if(2===E[0]&&1===E[1]&&0===E[2]){const w=A[2],D=A[1],I=w*D;return{get:(R,T,M,N)=>R[N+M*w+T*I],set:(R,T,M,N,V)=>R[N+M*w+T*I]=V,add:(R,T,M,N,V)=>R[N+M*w+T*I]+=V,dataOffset:(R,T,M)=>M+T*w+R*I,getCoords:(R,T)=>{const M=Math.floor(R/w);return T[0]=Math.floor(M/D),T[1]=M%D,T[2]=R%w,T}}}throw new Error("bad axis order");default:return{get:(w,...D)=>w[h(S,D)],set:(w,...D)=>w[h(S,D)]=D[D.length-1],add:(w,...D)=>w[h(S,D)]+=D[D.length-1],dataOffset:(...w)=>h(S,w),getCoords:(w,D)=>function g(S,A,E){const{dimensions:w,axisOrderFastToSlow:D}=S,I=w.length;let R=A;for(let T=0;Tnew(w||S.defaultCtor)(E)}function h(S,A){const{accessDimensions:E,axisOrderFastToSlow:w}=S,D=E.length-1;let I=E[D]*A[w[D]];for(let R=D-1;R>=0;R--)I=(I+A[w[R]])*E[R];return I}function b(S,A){const E=[];for(let w=0;wb(E,A)},e.convertToCanonicalAxisIndicesSlowToFast=function _(S){const A=new Int32Array(S.length);for(let E=0;Eb(E,A)}}(wn||(wn={})),function(e){let t;function r(I,R){return kZ(R.T,I,R,1)}function o(I){return NI(I)}!function(I){function N(z,j=I.float){return{"@type":"tensor",T:z.create(),space:z,valueType:"tensor",baseType:j}}I.str={"@type":"str",T:"",valueType:"str"},I.ustr={"@type":"str",T:"",valueType:"str",transform:"uppercase"},I.lstr={"@type":"str",T:"",valueType:"str",transform:"lowercase"},I.int={"@type":"int",T:0,valueType:"int"},I.coord={"@type":"coord",T:0,valueType:"float"},I.float={"@type":"float",T:0,valueType:"float"},I.Str=function R(z){var j;return{"@type":"str",T:null!==(j=z?.defaultValue)&&void 0!==j?j:"",transform:z?.transform,valueType:"str"}},I.Int=function T(z=0){return{"@type":"int",T:z,valueType:"int"}},I.Float=function M(z=0){return{"@type":"float",T:z,valueType:"float"}},I.Tensor=N,I.Vector=function V(z,j=I.float){return N(wn.Vector(z,"int"===j["@type"]?Int32Array:Float64Array),j)},I.Matrix=function F(z,j,Z=I.float){return N(wn.ColumnMajorMatrix(z,j,"int"===Z["@type"]?Int32Array:Float64Array),Z)},I.Aliased=function G(z){return z},I.List=function L(z,j,Z=[]){return{"@type":"list",T:Z,separator:z,itemParse:j,valueType:"list"}}}(t=e.Schema||(e.Schema={})),e.is=function n(I){return!!I&&!!I.schema&&!!I.value},e.ValueKind={Present:0,NotPresent:1,Unknown:2},e.Undefined=r,e.ofConst=function i(I,R,T){return kZ(I,R,T,0)},e.ofLambda=o,e.range=function s(I,R){return o({value:T=>T+I,rowCount:Math.max(R-I+1,0),schema:t.int})},e.ofArray=function a(I){return ip(I)},e.ofIntArray=function c(I){return ip({array:I,schema:t.int})},e.ofFloatArray=function u(I){return ip({array:I,schema:t.float})},e.ofStringArray=function l(I){return ip({array:I,schema:t.str})},e.ofStringAliasArray=function d(I){return ip({array:I,schema:t.Aliased(t.str)})},e.ofStringListArray=function f(I,R=","){return ip({array:I,schema:t.List(R,T=>T)})},e.ofIntTokens=function p(I){const{count:R,data:T,indices:M}=I;return NI({value:N=>jh(T,M[2*N],M[2*N+1])||0,rowCount:R,schema:t.int})},e.ofFloatTokens=function m(I){const{count:R,data:T,indices:M}=I;return NI({value:N=>rp(T,M[2*N],M[2*N+1])||0,rowCount:R,schema:t.float})},e.ofStringTokens=function h(I){const{count:R,data:T,indices:M}=I;return NI({value:N=>{const V=T.substring(M[2*N],M[2*N+1]);return"."===V||"?"===V?"":V},rowCount:R,schema:t.str})},e.window=function g(I,R,T){return function cMe(e,t,n){return e.isDefined?0===t&&n===e.rowCount?e:e.__array&&WF(e.__array)?function uMe(e,t,n){const r=PI(e.__array,{start:t,end:n}),i=e.valueKind;return ip({array:r,schema:e.schema,valueKind:o=>i(t+o)})}(e,t,n):function lMe(e,t,n){const r=e.value,i=e.valueKind,o=e.areValuesEqual,s=0===t?r:c=>r(c+t),a=n-t;return{schema:e.schema,__array:void 0,isDefined:e.isDefined,rowCount:a,value:s,valueKind:0===t?i:c=>i(c+t),toArray:c=>{const{array:u}=qx(a,c);for(let l=0,d=u.length;lo(c+t,u+t)}}(e,t,n):te.Undefined(n-t,e.schema)}(I,R,T)},e.view=function y(I,R,T=!0){return function fMe(e,t,n){return 0===e.rowCount||n&&function dMe(e,t){if(e.length!==t)return!1;for(let n=0,r=e.length;ni(t[o])})}(e,t):function hMe(e,t){const n=e.value,r=e.valueKind,i=e.areValuesEqual,s=t.length;return{schema:e.schema,__array:void 0,isDefined:e.isDefined,rowCount:s,value:a=>n(t[a]),valueKind:a=>r(t[a]),toArray:a=>{const{array:c}=qx(s,a);for(let u=0,l=c.length;ui(t[a],t[c])}}(e,t)}(I,R,T)},e.createFirstIndexMap=function b(I){return function sMe(e){const t=new Map;for(let n=0,r=e.rowCount;nt.has(n)?t.get(n):-1}(I)},e.mapToArray=function _(I,R,T){return function mMe(e,t,n){const r=new n(e.rowCount);for(let i=0,o=e.rowCount;iS[I][D],valueKind:I=>typeof S[I][D]>"u"?1:0});return A},e.ofArrays=function a(_,S){var A;const E=Object.create(null),w=Object.keys(_);E._rowCount=0,E._columns=w,E._schema=_;for(const D of w)typeof S[D]<"u"?(E[D]=te.ofArray({array:S[D],schema:_[D]}),E._rowCount=null===(A=S[D])||void 0===A?void 0:A.length):E[D]=te.Undefined(E._rowCount,_[D]);return E},e.view=c,e.pick=function u(_,S,A){const E=[];for(let w=0,D=_._rowCount;wS(I,R));let E=!0;for(let D=0,I=A.length;D0}has(t){return this._set.has(t)}assets(t,n){const r=this._assets.get(t);if(r)for(const i of r)i.dispose();n?this._assets.set(t,n):this._assets.delete(t)}dispose(){this._assets.forEach(t=>{for(const n of t)n.dispose()})}}const OI=Object.prototype.hasOwnProperty;function IMe(e,t){let n=!1;for(const r of Object.keys(t))if(OI.call(t,r)&&t[r]!==e[r]){n=!0;break}return n?Object.assign({},e,t):e}function JF(e,t){if(!e)return!t;if(!t)return!1;const n=Object.keys(e);if(Object.keys(t).length!==n.length)return!1;for(const r of n)if(!OI.call(e,r)||e[r]!==t[r])return!1;return!0}function Jl(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Array){const t=[];for(let n=0,r=e.length;nt&&(t=e[n]);return t}function LI(e){let t=1/0;for(let n=0,r=e.length;nn&&(n=e[r]);return[t,n]}function OZ(e,t=1,n=0){const r=e.length;let i=0;for(let o=n;o=0||(e.push(t),0))}function Eg(e,t){const n=e.indexOf(t);if(n<0)return!1;for(let r=n,i=e.length-1;rwindow.setImmediate(e,...t),clearImmediate:e=>window.clearImmediate(e)}:{setImmediate,clearImmediate}:function kMe(){const e=function(){const h=typeof window<"u"&&window,g=typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&self;return h||typeof global<"u"&&global||g}(),t={},n=typeof document<"u"?document:void 0;let i,r=1;function s(h){delete t[h]}function c(h){const g=t[h];s(h),function a(h){const g=h.callback,y=h.args;switch(y.length){case 0:g();break;case 1:g(y[0]);break;case 2:g(y[0],y[1]);break;case 3:g(y[0],y[1],y[2]);break;default:g.apply(void 0,y)}}(g)}return typeof process<"u"&&"[object process]"==={}.toString.call(process)?function u(){i=function(h){process.nextTick(function(){c(h)})}}():function l(){if(e&&e.postMessage&&!e.importScripts){let h=!0;const g=e.onmessage;return e.onmessage=function(){h=!1},e.postMessage("","*"),e.onmessage=g,h}}()?function d(){const h="setImmediate$"+Math.random()+"$",g=function(y){y.source===e&&"string"==typeof y.data&&0===y.data.indexOf(h)&&c(+y.data.slice(h.length))};window.addEventListener?window.addEventListener("message",g,!1):window.attachEvent("onmessage",g),i=function(y){window.postMessage(h+y,"*")}}():typeof MessageChannel<"u"?function f(){const h=new MessageChannel;h.port1.onmessage=function(g){c(g.data)},i=function(g){h.port2.postMessage(g)}}():n&&"onreadystatechange"in n.createElement("script")?function p(){const h=n.documentElement;i=function(g){let y=n.createElement("script");y.onreadystatechange=function(){c(g),y.onreadystatechange=null,h.removeChild(y),y=null},h.appendChild(y)}}():function m(){i=function(h){setTimeout(c,0,h)}}(),{setImmediate:function o(h,...g){return"function"!=typeof h&&(h=new Function(""+h)),t[r]={callback:h,args:g},i(r),r++},clearImmediate:s}}();function NMe(e){tB.setImmediate(e)}const Zx={setImmediate:tB.setImmediate,clearImmediate:tB.clearImmediate,immediatePromise:()=>new Promise(NMe),delay:(e,t=void 0)=>new Promise(n=>setTimeout(n,e,t))};let Qx=function(){try{return!0}catch{return!1}}(),un=function(){try{const t=process.env.DEBUG;return"*"===t||"molstar"===t}catch{return!1}}(),lt=!1;const Jx=[],nB=typeof performance<"u"&&!!performance.mark&&performance.measure&<var e2;function LMe(e,t,n=250){const r=zZ(e,t,n);return new jI(r,r.root)}function UZ(e,t){return rB(t,e)}function VZ(e){return{taskId:e.id,taskName:e.name,message:"",startedTime:0,canAbort:!0,isIndeterminate:!0,current:0,max:0}}function zZ(e,t,n){const r={abortRequested:!1,treeAborted:!1,reason:""};return{updateRateMs:n,lastNotified:yi(),observer:t,abortToken:r,taskId:e.id,root:{progress:VZ(e),children:[]},tryAbort:VMe(r)}}function VMe(e){return t=>{e.abortRequested=!0,e.reason=t||e.reason}}function GZ(e){return{progress:{...e.progress},children:e.children.map(GZ)}}function jZ(e){return e.progress.canAbort&&e.children.every(jZ)}function rB(e,t){return iB.apply(this,arguments)}function iB(){return iB=ie(function*(e,t){e2.markStart(e),t.node.progress.startedTime=yi();try{const n=yield e.f(t);return e2.markEnd(e),e2.measure(e),t.info.abortToken.abortRequested&&HZ(t.info),n}catch(n){throw Oe.isAbort(n)&&(t.isAborted=!0,t.node.children.length>0&&(yield new Promise(r=>{t.onChildrenFinished=r})),e.onAbort&&e.onAbort()),n}}),iB.apply(this,arguments)}function HZ(e){throw e.abortToken.treeAborted||(e.abortToken.treeAborted=!0,qZ(e.root),WZ(e,yi())),Oe.Aborted(e.abortToken.reason)}function qZ(e){const t=e.progress;t.isIndeterminate=!0,t.canAbort=!1,t.message="Aborting...";for(const n of e.children)qZ(n)}function WZ(e,t){e.lastNotified=t;const n=function zMe(e){return{root:GZ(e.root),canAbort:jZ(e.root),requestAbort:e.tryAbort}}(e);e.observer(n)}!function(e){function t(s){return`startTask${s.id}`}function n(s){return`endTask${s.id}`}e.markStart=function r(s){nB&&performance.mark(t(s))},e.markEnd=function i(s){nB&&performance.mark(n(s))},e.measure=function o(s){nB&&performance.measure(`\u2733\ufe0f ${s.name}`,t(s),n(s))}}(e2||(e2={}));class jI{checkAborted(){this.info.abortToken.abortRequested&&(this.isAborted=!0,HZ(this.info))}get shouldUpdate(){return this.checkAborted(),yi()-this.lastUpdatedTime>this.info.updateRateMs}updateProgress(t){if(this.checkAborted(),!t)return;const n=this.node.progress;"string"==typeof t?(n.message=t,n.isIndeterminate=!0):(typeof t.canAbort<"u"&&(n.canAbort=t.canAbort),typeof t.message<"u"&&(n.message=t.message),typeof t.current<"u"&&(n.current=t.current),typeof t.max<"u"&&(n.max=t.max),n.isIndeterminate=typeof n.current>"u"||typeof n.max>"u",typeof t.isIndeterminate<"u"&&(n.isIndeterminate=t.isIndeterminate))}update(t,n){if(this.lastUpdatedTime=yi(),this.updateProgress(t),!n)return WZ(this.info,this.lastUpdatedTime),this.checkAborted(),Zx.immediatePromise()}runChild(t,n){var r=this;return ie(function*(){r.updateProgress(n);const i={progress:VZ(t),children:[]},o=r.node.children;o.push(i);const s=new jI(r.info,i);try{return yield rB(t,s)}catch(a){if(Oe.isAbort(a)&&r.isAborted)return;throw a}finally{const a=o.indexOf(i);if(a>=0){for(let c=a,u=o.length-1;c0;){s+=u;const d=yi()-c;l+=d,a+=d,e.shouldUpdate&&(yield i(e,n,s),o=Math.round(l*s/a)+1,c=yi(),l=0)}return e.shouldUpdate&&(yield i(e,n,s)),n}),oB.apply(this,arguments)}function HMe(e,t,n){return e[t].keys[p].key){l=!1;break}if(c&&l){for(let p=0;p"Aborted"+(d?": "+d:"")}},e.create=o,e.constant=function s(d,f){return o(d,function(){var p=ie(function*(m){return f});return function(m){return p.apply(this,arguments)}}())},e.empty=function a(){return o("",function(){var d=ie(function*(f){});return function(f){return d.apply(this,arguments)}}())},e.fail=function c(d,f){return o(d,function(){var p=ie(function*(m){throw new Error(f)});return function(m){return p.apply(this,arguments)}}())},e.resolveInContext=function u(d,f){return n(d)?f?d.runInContext(f):d.run():d};const l=pa(0,1073741823)}(Oe||(Oe={})),function(e){function t(r,i=""){const o=r.progress;if(!r.children.length)return o.isIndeterminate?`${i}${o.taskName}: ${o.message}`:`${i}${o.taskName}: [${o.current}/${o.max}] ${o.message}`;const s=i+" |_ ",a=r.children.map(c=>t(c,s));return o.isIndeterminate?`${i}${o.taskName}: ${o.message}\n${a.join("\n")}`:`${i}${o.taskName}: [${o.current}/${o.max}] ${o.message}\n${a.join("\n")}`}e.format=function n(r){return t(r.root)}}($Z||($Z={})),function(e){function n(f){const p=f.growBy*f.elementSize;f.currentSize=p,f.currentIndex=0,f.currentChunk=new f.ctor(p),f.allocatedSize+=p,f.chunks[f.chunks.length]=f.currentChunk}function l(f,p){const{ctor:m,chunks:h,currentIndex:g}=f;if(!h.length)return new m(0);if(1===h.length&&(p||g===f.allocatedSize))return h[0];let y=0;for(let S=0,A=h.length-1;S=f.currentSize)b.set(_,x);else for(let S=0,A=_.length;S=f.currentSize&&n(f);const y=f.currentChunk,b=f.currentIndex;return y[b]=p,y[b+1]=m,y[b+2]=h,y[b+3]=g,f.currentIndex+=4,f.elementCount++},e.add3=function i(f,p,m,h){f.currentIndex>=f.currentSize&&n(f);const g=f.currentChunk,y=f.currentIndex;return g[y]=p,g[y+1]=m,g[y+2]=h,f.currentIndex+=3,f.elementCount++},e.add2=function o(f,p,m){f.currentIndex>=f.currentSize&&n(f);const h=f.currentChunk,g=f.currentIndex;return h[g]=p,h[g+1]=m,f.currentIndex+=2,f.elementCount++},e.add=function s(f,p){return f.currentIndex>=f.currentSize&&n(f),f.currentChunk[f.currentIndex]=p,f.currentIndex+=1,f.elementCount++},e.addRepeat=function a(f,p,m){for(let h=0;h=f.currentSize&&n(f),f.currentChunk[f.currentIndex++]=m,f.elementCount++;return f.elementCount},e.addMany=function c(f,p){const{elementSize:m}=f;for(let h=0,g=p.length;h=f.currentSize&&n(f);const{currentChunk:y}=f;for(let b=0;b"u")return g;if("number"==typeof h)return g.currentChunk=new f(h*p),g.allocatedSize=h*p,g.currentSize=g.currentChunk.length,g.chunks[0]=g.currentChunk,g;const y=h;if(y.length%p!=0)throw new Error("initialChunk length must be a multiple of the element size.");return g.currentChunk=y,g.allocatedSize=y.length,g.currentSize=y.length,g.chunks[0]=y,g}}(ze||(ze={}));class WMe{createGroup(t,n){const r=this.id++,i=[t];return this.groups[r]=i,{id:r,keys:i,value:n}}add(t,n){const r=this.getHash(n);if(this.byHash.has(r)){const i=this.byHash.get(r);for(let s=0,a=i.length;s>4;return t=(3735928559^t)+(t<<5),t^=t>>11,t}function Pg(e,t){let n=23;return n=31*n+e|0,n=31*n+t|0,n^=n>>4,n=(3735928559^n)+(n<<5),n^=n>>11,n}function aB(e){let t=0;for(let n=0,r=e.length;n>>0}function cB(e,t){for(let n=0,r=e.length;n=n&&t0&&r>0&&WI(e)>=qI(t)&&qI(e)<=WI(t)}function cRe(e,t){return Mg(e)?!Mg(t)||sp(e)<=sp(t)&&Hh(e)>=Hh(t):0===Mg(t)}function fB(e,t){const n=sp(e);if(t<=n)return 0;const r=Hh(e);return t>=r?r-n:t-n}function uRe(e,t,n){const r=sp(n),i=sp(e);if(t<=r+i)return r;const o=Hh(n);return t>=o+i?o:t-i}function JZ(e,t,n){return dB(fB(e,t),fB(e,n+1))}function lRe(e,t){return QZ(e,t)?dB(Math.max(sp(e),sp(t)),Math.min(Hh(e),Hh(t))):KZ}function dRe(e,t){return Mg(JZ(e,qI(t),WI(t)))}var Ce;!function(e){e.Empty=KZ,e.ofSingleton=t=>ZZ(t,t),e.ofRange=ZZ,e.ofBounds=dB,e.ofLength=eRe,e.is=tRe,e.has=iRe,e.indexOf=oRe,e.getAt=sRe,e.start=sp,e.end=Hh,e.min=qI,e.max=WI,e.size=Mg,e.hashCode=nRe,e.toString=rRe,e.areEqual=aRe,e.areIntersecting=QZ,e.isSubInterval=cRe,e.findPredecessorIndex=fB,e.findPredecessorIndexInInterval=uRe,e.findRange=JZ,e.intersectionSize=dRe,e.intersect=lRe}(Ce||(Ce={}));const n2=[];function fRe(e){return[e]}function pRe(e){return e}function hRe(e){return Ou(e),e}function eQ(e,t){if(t2?function XMe(e,t,n,r){let i=23;return i=31*i+e|0,i=31*i+t|0,i=31*i+n|0,i=31*i+r|0,i^=i>>4,i=(3735928559^i)+(i<<5),i^=i>>11,i}(t,e[0],e[t-1],e[t>>1]):function YMe(e,t,n){let r=23;return r=31*r+e|0,r=31*r+t|0,r=31*r+n|0,r^=r>>4,r=(3735928559^r)+(r<<5),r^=r>>11,r}(t,e[0],e[t-1]):0}function vRe(e){const t=e.length;return t>5?`[${e[0]}, ${e[1]}, ..., ${e[t-1]}], length ${t}`:`[${e.join(", ")}]`}function rQ(e,t){const n=e.length;return 0===n?-1:e[0]<=t&&t<=e[n-1]?sQ(e,t,0,n):-1}function _Re(e,t,n){return iQ(e,t,Ce.start(n),Ce.end(n))}function iQ(e,t,n,r){return 0===e.length||r<=n?-1:e[n]<=t&&t<=e[r-1]?sQ(e,t,n,r):-1}function xRe(e,t){return rQ(e,t)>=0}function oQ(e,t){if(e===t)return!0;let n=e.length;if(n!==t.length||e[0]!==t[0]||e[n-1]!==t[n-1])return!1;if(tQ(e))return!0;n--;for(let r=1;re[n-1]?n:aQ(e,t,0,n)}function SRe(e,t,n){const r=Ce.start(n),i=Ce.end(n),o=e[r];return t<=o?r:i>r&&t>e[i-1]?i:t-o<=11?function wRe(e,t,n,r){for(let i=n;io){for(let c=i;c<=o;c++)if(t===e[c])return c;return-1}const s=i+o>>1,a=e[s];if(ta))return s;i=s+1}}return-1}function aQ(e,t,n,r){let i=n,o=r-1;for(;io){for(let c=i;c<=o;c++)if(t<=e[c])return c;return o+1}const s=i+o>>1,a=e[s];if(ta))return s;i=s+1}}return i>o?o+1:e[i]>=t?i:i+1}function ARe(e,t){if(e===t)return!0;let{startI:n,startJ:r,endI:i,endJ:o}=kg(e,t);for(;na))return!0;r++}}return!1}function IRe(e,t){if(e===t)return!0;const n=t.length;let{startI:r,startJ:i,endI:o,endJ:s}=kg(e,t);if(s-iu?i++:(r++,i++,a++)}return a===n}function cQ(e,t){if(e===t)return e;const n=e.length,r=t.length;if(0===n)return t;if(0===r)return e;if(e[0]>t[0])return cQ(t,e);const{startI:i,startJ:o,endI:s,endJ:a}=kg(e,t),c=mB(e,t,i,o,s,a);if(c===n&&c===r||c===r)return e;if(c===n)return t;const u=new Int32Array(n+r-c);let l=0,d=0,f=0;for(l=0;lt[d];)u[f++]=t[d++];for(;lm?(u[f++]=m,d++):(u[f++]=p,l++,d++)}for(;ll?a++:(s++,a++,c++)}return c}function DRe(e,t){if(e===t)return e;const{startI:n,startJ:r,endI:i,endJ:o}=kg(e,t),s=mB(e,t,n,r,i,o),a=e.length,c=t.length;if(!s)return n2;if(s===a&&s===c||s===c)return t;if(s===a)return e;const u=new Int32Array(s);let l=0,d=n,f=r;for(;dm||(u[l++]=p,d++),f++)}return u}function ERe(e,t){if(e===t)return n2;const n=e.length,{startI:r,startJ:i,endI:o,endJ:s}=kg(e,t);let a=r,c=i,u=0;for(;ap?c++:(a++,c++,u++)}if(!u)return e;if(u>=n)return n2;const l=new Int32Array(n-u);let d=0;for(let f=0;fp||a++,c++)}for(;ap?a++:(s++,a++,c++)}if(!c)return n2;if(c===e.length)return lB(0,e.length-1);const l=new Int32Array(c);let d=0;for(s=n,a=r;sp||(l[d++]=s,s++),a++)}return l}const ap={startI:0,startJ:0,endI:0,endJ:0};function kg(e,t){const n=e.length,r=t.length,i=n/r;return n>=128||r>=128||i<=.34||i>=2.99?(ap.startI=Rg(e,pB(t)),ap.startJ=Rg(t,pB(e)),ap.endI=Rg(e,hB(t)),ap.endJ=Rg(t,hB(e))):(ap.startI=0,ap.startJ=0,ap.endI=n,ap.endJ=r),ap}var je;!function(e){e.Empty=n2,e.ofUnsortedArray=hRe,e.ofSingleton=fRe,e.ofSortedArray=pRe,e.ofRange=eQ,e.ofBounds=(t,n)=>eQ(t,n-1),e.is=mRe,e.isRange=tQ,e.has=xRe,e.indexOf=rQ,e.indexOfInInterval=_Re,e.indexOfInRange=iQ,e.start=pB,e.end=hB,e.min=gRe,e.max=yRe,e.size=nQ,e.hashCode=bRe,e.toString=vRe,e.areEqual=oQ,e.areIntersecting=ARe,e.isSubset=IRe,e.union=cQ,e.intersect=DRe,e.subtract=ERe,e.findPredecessorIndex=Rg,e.findPredecessorIndexInInterval=SRe,e.findRange=CRe,e.intersectionSize=TRe,e.deduplicate=PRe,e.indicesOf=MRe}(je||(je={}));const Kd=Ce.Empty,RRe=Ce.ofSingleton,kRe=Ce.ofRange,NRe=Ce.ofBounds;function ed(e){return e.length?je.isRange(e)?Ce.ofRange(e[0],e[e.length-1]):e:Kd}function Ng(e){return Ce.is(e)?Ce.size(e):je.size(e)}function FRe(e,t){return Ce.is(e)?Ce.has(e,t):je.has(e,t)}function BRe(e,t){return Ce.is(e)?Ce.indexOf(e,t):je.indexOf(e,t)}function gB(e,t){return Ce.is(e)?Ce.getAt(e,t):e[t]}function Vb(e){return Ce.is(e)?Ce.min(e):je.min(e)}function zb(e){return Ce.is(e)?Ce.max(e):je.max(e)}function ORe(e){return Ce.is(e)?Ce.start(e):je.start(e)}function LRe(e){return Ce.is(e)?Ce.end(e):je.end(e)}function URe(e){return Ce.is(e)?Ce.hashCode(e):je.hashCode(e)}function zRe(e,t){return Ce.is(e)?Ce.is(t)?Ce.areEqual(e,t):uQ(e,t):Ce.is(t)?uQ(t,e):je.areEqual(e,t)}function GRe(e,t){return Ce.is(e)?Ce.is(t)?Ce.areIntersecting(e,t):lQ(t,e):Ce.is(t)?lQ(e,t):je.areIntersecting(e,t)}function jRe(e,t){return Ce.is(e)?Ce.is(t)?Ce.isSubInterval(e,t):function QRe(e,t){const n=Ce.min(e),r=Ce.max(e);if(r-n+1==0)return!1;const i=je.min(t),o=je.max(t);return i>=n&&o<=r}(e,t):Ce.is(t)?function ZRe(e,t){const n=Ce.min(t),r=Ce.max(t);if(r-n+1==0)return!0;const i=je.min(e),o=je.max(e);if(no)return!1;const s=je.findRange(e,n,r);return Ce.size(s)===Ce.size(t)}(e,t):je.isSubset(e,t)}function HRe(e,t){return Ce.is(e)?Ce.findPredecessorIndex(e,t):je.findPredecessorIndex(e,t)}function qRe(e,t,n){return Ce.is(e)?Ce.findPredecessorIndexInInterval(e,t,n):je.findPredecessorIndexInInterval(e,t,n)}function WRe(e,t,n){return Ce.is(e)?Ce.findRange(e,t,n):je.findRange(e,t,n)}function $Re(e,t){return Ce.is(e)?Ce.is(t)?Ce.intersectionSize(e,t):fQ(t,e):Ce.is(t)?fQ(e,t):je.intersectionSize(e,t)}function YRe(e,t){return Ce.is(e)?Ce.is(t)?function tke(e,t){if(Ce.areEqual(e,t))return e;const n=Ce.size(e),r=Ce.size(t);if(!r)return e;if(!n)return t;const i=Ce.min(e),o=Ce.min(t);if(function JRe(e,t){const n=Ng(e),r=Ng(t);return 0===n&&0===r||n>0&&r>0&&zb(e)>=Vb(t)&&Vb(e)<=zb(t)}(e,t))return Ce.ofRange(Math.min(i,o),Math.max(Ce.max(e),Ce.max(t)));let s,a,c,u;i=zb(t):0===Ng(t)}(t,e))return t;const r=Ce.min(t),i=Ce.max(t),o=je.findRange(e,r,i),s=Ce.start(o),a=Ce.end(o),c=new Int32Array(s+(e.length-a)+n);let u=0;for(let l=0;lm||(c++,l++),d++)}if(0===c)return Kd;if(c===i&&c===o)return e;const f=new Int32Array(c);for(u=0,l=0,d=s;lm||(f[u++]=d,l++),d++)}return ed(f)}var Fe,en,Lu,$I,Dc,td,Ms,ft,Gb,ui;function hQ(e){const t=je.ofSortedArray(e),n=je.max(t),r=new Int32Array(n);for(let i=0,o=e.length-1;i=Fe.max(e)?-1:Fe.findPredecessorIndex(e,n-1);return Fe.findRange(t,Fe.getAt(e,i),Fe.getAt(e,i+1)-1)}!function(e){e.Empty=Kd,e.ofSingleton=RRe,e.ofRange=kRe,e.ofBounds=NRe,e.ofSortedArray=ed,e.has=FRe,e.indexOf=BRe,e.getAt=gB,e.min=Vb,e.max=zb,e.start=ORe,e.end=LRe,e.size=Ng,e.hashCode=URe,e.areEqual=zRe,e.areIntersecting=GRe,e.isSubset=jRe,e.union=YRe,e.intersect=XRe,e.indexedIntersect=ake,e.subtract=KRe,e.findPredecessorIndex=HRe,e.findPredecessorIndexInInterval=qRe,e.findRange=WRe,e.intersectionSize=$Re,e.forEach=function t(a,c,u){return function oke(e,t,n){if(Ce.is(e)){const r=Ce.min(e);for(let i=r,o=Ce.max(e);i<=o;i++)t(i,i-r,n)}else for(let r=0,i=e.length;rc.push(u)),c},e.toString=function s(a){return function VRe(e){return Ce.is(e)?Ce.toString(e):je.toString(e)}(a)}}(Fe||(Fe={}));class fke{move(){for(;this.hasNext;){if(this.updateValue()){this.value.index=this.segmentMin++,this.hasNext=this.segmentMax>=this.segmentMin&&Ce.size(this.setRange)>0;break}this.updateSegmentRange()}return this.value}updateValue(){const n=Fe.findPredecessorIndexInInterval(this.set,this.segments[this.segmentMin+1],this.setRange);return this.value.start=Ce.start(this.setRange),this.value.end=n,this.setRange=Ce.ofBounds(n,Ce.end(this.setRange)),n>this.value.start}updateSegmentRange(){const t=Ce.min(this.setRange),n=Ce.max(this.setRange);n=this.segmentMin)}setSegment(t){this.setRange=Ce.ofBounds(t.start,t.end),this.updateSegmentRange()}constructor(t,n,r,i){this.segments=t,this.segmentMap=n,this.set=r,this.segmentMin=0,this.segmentMax=0,this.setRange=Ce.Empty,this.value={index:0,start:0,end:0},this.hasNext=!1,this.setRange=i,this.updateSegmentRange()}}function pke(e,t,n){const r=typeof n<"u"?Ce.ofBounds(n.start,n.end):Ce.ofBounds(0,Fe.size(t));return new fke(e.offsets,e.index,t,r)}!function(e){e.create=hQ,e.ofOffsets=cke,e.count=uke,e.getSegment=lke,e.projectValue=dke,e.transientSegments=pke}(en||(en={}));class mke{remove(t){const{prev:n,next:r}=this,i=n[t],o=r[t];i>=0&&(r[i]=o,n[t]=-1),o>=0&&(n[o]=i,r[t]=-1),t===this.head&&(this.head=i<0?o:i)}has(t){return this.prev[t]>=0||this.next[t]>=0||this.head===t}constructor(t){this.head=t>0?0:-1,this.prev=new Int32Array(t),this.next=new Int32Array(t);for(let n=0;n0,this.xs=t,this.index=-1,this.lastValue=t.length>0?t[0]:void 0}}class mQ{move(){return++this.value,this.hasNext=this.value=t}}class yke{move(){return this.hasNext=!1,this.value}constructor(t){this.value=t,this.hasNext=!0}}class bke{move(){const t=this.f(this.base.move());return this.hasNext=this.base.hasNext,t}constructor(t,n){this.base=t,this.f=n,this.hasNext=!1,this.hasNext=t.hasNext}}class vke{move(){const t=this.next;return this.hasNext=this.findNext(),t}findNext(){for(;this.base.hasNext;)if(this.next=this.base.move(),this.p(this.next))return!0;return!1}constructor(t,n){this.base=t,this.p=n,this.hasNext=this.findNext()}}function gQ(e,t,n,r,i){const{b:o,offset:s}=e,a=[];for(let c=0,u=t.length;c1&&gQ(e,a,n,r-1,i)}!function(e){e.Empty=new mQ(0,-1),e.Array=function t(a){return new gke(a)},e.Value=function n(a){return new yke(a)},e.Range=function r(a,c){return new mQ(a,c)},e.map=function i(a,c){return new bke(a,c)},e.filter=function o(a,c){return new vke(a,c)},e.forEach=function s(a,c,u){for(;a.hasNext;)if(c(a.move(),u))return u;return u}}($I||($I={})),function(e){e.areEqual=function t(d,f){if(d===f)return!0;if(d.vertexCount!==f.vertexCount||d.edgeCount!==f.edgeCount)return!1;const{a:p,b:m,offset:h}=d,{a:g,b:y,offset:b}=f;for(let x=0,_=d.a.length;x<_;x++)if(p[x]!==g[x])return!1;for(let x=0,_=d.b.length;x<_;x++)if(m[x]!==y[x])return!1;for(let x=0,_=d.offset.length;x<_;x++)if(h[x]!==b[x])return!1;for(const x of Object.keys(d.edgeProps)){const _=d.edgeProps[x],S=f.edgeProps[x];if(!S)return!1;for(let A=0,E=_.length;Ap&&(m=p,h=f);const g=uu(m,h);return!this.included.has(g)&&(this.included.add(g),this.xs[this.xs.length]=m,this.ys[this.ys.length]=h,!0)}getGraph(){return a(this.vertexCount,this.xs,this.ys)}getEdgeBuiler(){return new i(this.vertexCount,this.xs,this.ys)}constructor(f){this.vertexCount=f,this.xs=[],this.ys=[],this.included=new Set}},e.fromVertexPairs=a,e.induceByVertices=function c(d,f,p){const{b:m,offset:h,vertexCount:g,edgeProps:y}=d,b=new Int32Array(g);for(let R=0,T=f.length;RR&&0!==b[m[T]]&&x++;const _=new Int32Array(f.length+1),S=new Int32Array(2*x),A=new Int32Array(2*x),E=new Int32Array(2*x);let w=0,D=0;for(let R=0;R0;){const x=y.pop(),_=p[x];for(let S=h[x],A=h[x+1];S=0&&(y.push(b.head),p[b.head]=++m,b.remove(b.head))}return{componentCount:f,componentIndex:p}},e.areVertexSetsConnected=function l(d,f,p,m){if(je.areIntersecting(f,p))return!0;if(m<1)return!1;const h=new Set;for(let g=0,y=f.length;gn.substring(r[2*a],r[2*a+1]):"int"===o?a=>jh(n,r[2*a],r[2*a+1])||0:a=>rp(n,r[2*a],r[2*a+1])||0;return{schema:t,__array:void 0,isDefined:!0,rowCount:i,value:s,valueKind:a=>0,toArray:a=>Ps(i,s,a),areValuesEqual:yQ(e)}}function yQ(e){const{data:t,indices:n}=e;return function(r,i){const o=n[2*r],s=n[2*i],a=n[2*r+1]-o;if(a!==n[2*i+1]-s)return!1;for(let c=0;cr[i]}}function Zd(e,t,n){return function Rke(e,t,n){const r=Object.create(null);for(const i of Object.keys(e))r[i]=Fke(i,e[i],t,n);return QF.ofTables(t.header,e,r)}(e,t,n)}function Dke(e){switch(e.valueType){case"str":return(t,n,r)=>function Eke(e,t,n,r){return{schema:e,__array:t.__array,isDefined:t.isDefined,rowCount:t.rowCount,value:"lowercase"===e.transform?i=>n(i).toLowerCase():"uppercase"===e.transform?i=>n(i).toUpperCase():n,valueKind:t.valueKind,areValuesEqual:t.areValuesEqual,toArray:"lowercase"===e.transform?i=>Array.from(r(i)).map(o=>o.toLowerCase()):"uppercase"===e.transform?i=>Array.from(r(i)).map(o=>o.toUpperCase()):r}}(e,t,t.str,t.toStringArray);case"int":return(t,n,r)=>vQ(e,t,t.int,t.toIntArray);case"float":return(t,n,r)=>vQ(e,t,t.float,t.toFloatArray);case"list":throw new Error("Use createListColumn instead.");case"tensor":throw new Error("Use createTensorColumn instead.")}}function vQ(e,t,n,r){return{schema:e,__array:t.__array,isDefined:t.isDefined,rowCount:t.rowCount,value:n,valueKind:t.valueKind,areValuesEqual:t.areValuesEqual,toArray:r}}function Pke(e,t,n){const r=e.separator,i=e.itemParse,o=t.getField(n),s=o?c=>o.str(c).split(r).map(u=>i(u.trim())).filter(u=>!!u):c=>[];return{schema:e,__array:void 0,isDefined:!!o,rowCount:t.rowCount,value:s,valueKind:o?o.valueKind:()=>1,areValuesEqual:(c,u)=>Wa(s(c),s(u)),toArray:c=>Ps(t.rowCount,s,c)}}function Mke(e,t,n){const r=e.space,i=t.fieldNames.includes(`${n}[0]`)||t.fieldNames.includes(`${n}[0][0]`)||t.fieldNames.includes(`${n}[0][0][0]`),o=i?0:1,s=t.fieldNames.includes(`${n}_1`)||t.fieldNames.includes(`${n}_11`)||t.fieldNames.includes(`${n}_111`)?"underscore":"brackets",a=function wke(e,t,n,r){const i=n?0:1;switch(t){case 1:return"brackets"===r?o=>`${e}[${o+i}]`:o=>`${e}_${o+i}`;case 2:return"brackets"===r?(o,s)=>`${e}[${o+i}][${s+i}]`:(o,s)=>`${e}_${o+i}${s+i}`;case 3:return"brackets"===r?(o,s,a)=>`${e}[${o+i}][${s+i}][${a+i}]`:(o,s,a)=>`${e}_${o+i}${s+i}${a+i}`;default:throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.")}}(n,r.rank,i,s),c=t.getField(a(o,o,o))||te.Undefined(t.rowCount,e),u=d=>function Ake(e,t,n,r){const i=t.create();if(1===t.rank){const o=t.dimensions[0];for(let s=0;s 3 or rank 0 are currently not supported.");{const o=t.dimensions[0],s=t.dimensions[1],a=t.dimensions[2];for(let c=0;cwn.areEqualExact(u(d),u(f)),toArray:d=>Ps(t.rowCount,u,d)}}!function(e){e.create=function t(n,r){const{name:i}=n,o=new _ke;return{descriptor:n,formatRegistry:o,isApplicable:s=>o.isApplicable(s),get(s){const a=r?.asDynamic?s._dynamicPropertyData:s._staticPropertyData;if(a[i])return a[i];if(s.customProperties.has(n))return;const c=o.get(s.sourceData.kind);return c?(a[i]=c(s),s.customProperties.add(n),a[i]):void 0},set(s,a){r?.asDynamic?s._dynamicPropertyData[i]=a:s._staticPropertyData[i]=a},delete(s){r?.asDynamic?delete s._dynamicPropertyData[i]:delete s._staticPropertyData[i]}}}}(td||(td={})),function(e){e.Descriptor={name:"index_pair_bonds"},e.Provider=td.create(e.Descriptor,{asDynamic:!0}),e.DefaultProps={maxDistance:-1},e.fromData=function t(r,i={}){const o={...e.DefaultProps,...i},{pairs:s,count:a}=r;return{bonds:xke(s.indexA.toArray(),s.indexB.toArray(),{key:s.key&&s.key.toArray(),operatorA:s.operatorA&&s.operatorA.toArray(),operatorB:s.operatorB&&s.operatorB.toArray(),order:s.order&&s.order.toArray(),distance:s.distance&&s.distance.toArray(),flag:s.flag&&s.flag.toArray()},a),maxDistance:o.maxDistance}},e.getEdgeIndexForOperators=function n(r,i,o,s,a){let c,u,l,d;i0?o[s[0]].rowCount:0,name:i,fieldNames:s,getField:a=>o[a]}}e.empty=function t(i){return{rowCount:0,name:i,fieldNames:[],getField(o){}}},e.ofFields=n,e.ofTable=function r(i,o){const s={};for(const a of o._columns)s[a]=ft.ofColumn(o[a]);return n(i,s)}}(ss||(ss={})),function(e){function n(a){const c=a.length,u=p=>{const m=a[p];return m&&"."!==m&&"?"!==m?m:""},l=p=>{const m=a[p];return jh(m,0,m.length)||0},d=p=>{const m=a[p];return rp(m,0,m.length)||0};return{__array:void 0,binaryEncoding:void 0,isDefined:!0,rowCount:c,str:u,int:l,float:d,valueKind:p=>{const m=a[p],h=m.length;if(h>1)return 0;if(0===h)return 1;const g=m.charCodeAt(0);return 46===g?1:63===g?2:0},areValuesEqual:(p,m)=>a[p]===a[m],toStringArray:p=>p?Ps(c,u,p):a,toIntArray:p=>Ps(c,l,p),toFloatArray:p=>Ps(c,d,p)}}function o(a){const{rowCount:c,valueKind:u,areValuesEqual:l,isDefined:d}=a;let f,p,m;switch(a.schema.valueType){case"float":case"int":f=g=>""+a.value(g),p=a.value,m=a.value;break;case"str":f=a.value,p=g=>{const y=a.value(g);return jh(y,0,y.length)||0},m=g=>{const y=a.value(g);return rp(y,0,y.length)||0};break;case"list":const{separator:h}=a.schema;f=g=>a.value(g).join(h),p=g=>NaN,m=g=>NaN;break;default:throw new Error(`unsupported valueType '${a.schema.valueType}'`)}return{__array:void 0,binaryEncoding:void 0,isDefined:d,rowCount:c,str:f,int:p,float:m,valueKind:u,areValuesEqual:l,toStringArray:h=>Ps(c,f,h),toIntArray:h=>Ps(c,p,h),toFloatArray:h=>Ps(c,m,h)}}e.ofString=function t(a){return n([a])},e.ofStrings=n,e.ofNumbers=function r(a){const c=a.length,u=p=>""+a[p],l=p=>a[p],f=p=>!p||p.array&&a instanceof p.array?a:Ps(c,l,p);return{__array:void 0,binaryEncoding:void 0,isDefined:!0,rowCount:c,str:u,int:l,float:l,valueKind:p=>0,areValuesEqual:(p,m)=>a[p]===a[m],toStringArray:p=>Ps(c,u,p),toIntArray:f,toFloatArray:f}},e.ofTokens=function i(a){const{data:c,indices:u,count:l}=a,d=h=>{const g=c.substring(u[2*h],u[2*h+1]);return"."===g||"?"===g?"":g},f=h=>jh(c,u[2*h],u[2*h+1])||0,p=h=>rp(c,u[2*h],u[2*h+1])||0;return{__array:void 0,binaryEncoding:void 0,isDefined:!0,rowCount:l,str:d,int:f,float:p,valueKind:h=>{const g=u[2*h],y=u[2*h+1]-g;if(y>1)return 0;if(0===y)return 1;const b=c.charCodeAt(g);return 46===b?1:63===b?2:0},areValuesEqual:yQ(a),toStringArray:h=>Ps(l,d,h),toIntArray:h=>Ps(l,f,h),toFloatArray:h=>Ps(l,p,h)}},e.ofColumn=o,e.ofUndefined=function s(a,c){return o(te.Undefined(a,c))}}(ft||(ft={})),function(e){function t(i){return i.replace(".","_").replace(/\[/,"_").replace(/(\[|\])/g,"")}e.canonical=t,e.equal=function n(i,o){return t(i)===t(o)},e.create=function r(i,o,s=!1){const a=`${i}${o?`.${o}`:""}`;return s?t(a):a}}(Gb||(Gb={}));class _Q{constructor(t,n,r){this._isDefined=r;const i=Object.keys(n);this._rowCount=t.rowCount,this._columns=i,this._schema=n;const o=Object.create(null);for(const s of i)Object.defineProperty(this,s,{get:function(){if(o[s])return o[s];const a=n[s];if("list"===a.valueType)o[s]=Pke(a,t,s);else if("tensor"===a.valueType)o[s]=Mke(a,t,s);else{const c=Dke(a),u=t.getField(s);o[s]=u?c(u,t,s):te.Undefined(t.rowCount,a)}return o[s]},enumerable:!0,configurable:!1})}}function Nke(e,t,n,r){const i=Gb.create(t,e),o=Gb.canonical(i);if(o in n)return n[o];if(r&&i in r)for(const s of r[i]){const a=Gb.canonical(s);if(a in n)return n[a]}}function Fke(e,t,n,r){let i=n.categories[e];if(r){const o=function kke(e){const t=Object.create(null);for(const n of Object.keys(e.categories))for(const r of e.categories[n].fieldNames)t[Gb.create(n,r,!0)]=e.categories[n].getField(r);return t}(n),s=Object.create(null),a=[];let c=0;for(const u of Object.keys(t)){const l=Nke(u,e,o,r);l&&(s[u]=l,a.push(u),c=l.rowCount)}i={rowCount:c,name:e,fieldNames:[...a],getField:u=>s[u]}}return new _Q(i||ss.empty(e),t,!!i)}function jb(e,t,n){const r=new Float32Array(e);for(let i=0;i(t=Math.abs(t))?(t/=e,e*Math.sqrt(1+t*t)):t>0?(e/=t,t*Math.sqrt(1+e*e)):0}!function(e){function n(r,i,o){const s=function Gke(e){const t="number"==typeof e?function Uke(e){switch(e){case 1146:return 146;case 1148:return 149;case 1155:return 157;case 1160:return 163;case 1161:return 165;case 1166:return 171;case 1167:return 173;case 1003:return 237;case 1004:return 238;case 1005:return 239;case 2005:return 240;case 3005:return 241;case 4005:return 242;case 5005:return 243;case 1006:return 244;case 1007:return 245;case 1008:return 246;case 1009:return 247;case 1010:return 248;case 1011:return 249;case 1012:return 250;case 1013:return 251;case 1014:return 252;case 2014:return 253;case 3014:return 254;case 1015:return 255;case 1017:return 256;case 2017:return 257;case 1018:return 258;case 2018:return 259;case 3018:return 260;case 1020:return 261;case 1021:return 262;case 1022:return 263;case 1023:return 264;case 1059:return 265;case 1094:return 266;case 1197:return 267}let t=0;return e>146&&++t,e>148&&++t,e>155&&++t,e>160&&++t,e>161&&++t,e>166&&++t,e>167&&++t,e-1+t}(e):r2[e];return typeof t>"u"||typeof xQ[t]>"u"?-1:t}(r);if(s<0)return console.warn(`Unknown spacegroup '${r}', returning a 'P 1' with cellsize [1, 1, 1]`),e.Zero;const a=i[0]*i[1]*i[2],c=o[0],u=o[1],l=o[2],d=i[0],f=i[1],p=i[2],m=Math.cos(u),h=(Math.cos(c)-Math.cos(u)*Math.cos(l))/Math.sin(l),g=Math.sqrt(1-m*m-h*h),y=[d,0,0],b=[Math.cos(l)*f,Math.sin(l)*f,0],x=[m*p,h*p,g*p],_=le.ofRows([[y[0],b[0],x[0],0],[0,b[1],x[1],0],[0,0,x[2],0],[0,0,0,1]]);return{index:s,size:i,volume:a,anglesInRadians:o,toFractional:le.invert(le.zero(),_),fromFractional:_}}e.Zero=n("P 1",v.create(1,1,1),v.create(Math.PI/2,Math.PI/2,Math.PI/2)),e.isZero=function t(r){return!r||0===r.index&&1===r.size[0]&&1===r.size[1]&&1===r.size[1]},e.create=n}(ma||(ma={})),function(e){function t(g){const y=Lke[g.index].map(_=>function d(g){return le.ofRows([vB[g[0]],vB[g[1]],vB[g[2]],[0,0,0,1]])}(Oke[_]));return{name:xQ[g.index],num:zke[g.index],cell:g,operators:y}}e.ZeroP1=t(ma.Zero),e.create=t;const n=v(),r=le();function i(g,y,b,x,_,S){return v.set(n,b,x,_),le.fromTranslation(r,n),le.mul(S,le.mul(S,le.mul(S,g.cell.fromFractional,r),g.operators[y]),g.cell.toFractional)}e.setOperatorMatrix=i,e.getSymmetryOperator=function o(g,y,b,x,_){const S=i(g,y,b,x,_,le.zero());return ui.create(`${y+1}_${5+b}${5+x}${5+_}`,S,{hkl:v.create(b,x,_),spgrOp:y})};const s=v(),a=v(),c=v(),u=v();function p(g,y,b){const x=[];if(g>0?x.push("+X"):g<0&&x.push("-X"),y>0?x.push("+Y"):y<0&&x.push("-Y"),b>0?x.push("+Z"):b<0&&x.push("-Z"),1===x.length)return"+"===x[0].charAt(0)?x[0].substr(1):x[0];if(2===x.length){const _=x[0].charAt(0),S=x[1].charAt(0);if("+"===_)return`${x[0].substr(1)}${x[1]}`;if("+"===S)return`${x[1].substr(1)}${x[0]}`}throw new Error(`unknown rotation '${x}', ${g} ${y} ${b}`)}function m(g){switch(g){case.5: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 h(g,y){return""===y?g:g.length>2?`${g}+${y}`:"-"===g.charAt(0)?`${y}${g}`:`${y}+${g}`}e.getSymmetryOperatorRef=function l(g,y,b,x,_,S){const A=le.zero();v.set(n,b,x,_),v.floor(s,S),le.copy(A,g.operators[y]),v.floor(a,v.transformMat4(a,S,A)),le.getTranslation(u,A),v.sub(u,u,a),v.add(u,u,s),v.add(u,u,n),le.setTranslation(A,u),le.mul(A,g.cell.fromFractional,A),le.mul(A,A,g.cell.toFractional),v.sub(c,a,s);const E=b-c[0],w=x-c[1],D=_-c[2];return ui.create(`${y+1}_${5+E}${5+w}${5+D}`,A,{hkl:v.create(E,w,D),spgrOp:y})},e.getOperatorXyz=function f(g){return[h(p(g[0],g[4],g[8]),m(g[12])),h(p(g[1],g[5],g[9]),m(g[13])),h(p(g[2],g[6],g[10]),m(g[14]))].join(",")}}(Ec||(Ec={})),function(e){e.add=function t(o,s,a){o.squaredDistances[o.count]=a,o.indices[o.count++]=s},e.reset=function n(o){o.count=0},e.create=function r(){return{count:0,indices:[],squaredDistances:[]}},e.copy=function i(o,s){for(let a=0;a>16?L:-L,e[l*t+f]=G;for(p=0;p<2;p++)for(d=0;d0?M>c&&(c=M):M>u&&(u=M),v.projectPointOnVector(m,v.fromArray(m,s,I),y.dirB,g);const N=v.dot(y.dirB,v.normalize(h,v.sub(h,m,g))),V=v.distance(m,g);N>0?V>l&&(l=V):V>d&&(d=V),v.projectPointOnVector(m,v.fromArray(m,s,I),y.dirC,g);const F=v.dot(y.dirC,v.normalize(h,v.sub(h,m,g))),G=v.distance(m,g);F>0?G>f&&(f=G):G>p&&(p=G)}const b=v.setMagnitude(v(),y.dirA,(c+u)/2),x=v.setMagnitude(v(),y.dirB,(l+d)/2),_=v.setMagnitude(v(),y.dirC,(f+p)/2),S=v.isFinite(b),A=v.isFinite(x),E=v.isFinite(_),w=v(),D=function(I,R,T){v.copy(i,g),S&&v.scaleAndAdd(i,i,y.dirA,I),A&&v.scaleAndAdd(i,i,y.dirB,R),E&&v.scaleAndAdd(i,i,y.dirC,T),v.add(w,w,i)};return D(c,l,f),D(c,l,-p),D(c,-d,-p),D(c,-d,f),D(-u,-d,-p),D(-u,-d,f),D(-u,l,f),D(-u,l,-p),v.scale(w,w,1/8),Rs.create(w,b,x,_)}e.calculateBoxAxes=o}(nd||(nd={})),function(e){function t(T){return void 0!==T.extrema}function n(T,M){return{center:T,radius:M}}function a(T,M){return void 0!==T.extrema?(T.extrema.length=0,T.extrema.push(...M)):T.extrema=M,T}e.hasExtrema=t,e.create=n,e.zero=function r(){return{center:v(),radius:0}},e.clone=function i(T){const M=n(v.clone(T.center),T.radius);return t(T)&&(M.extrema=T.extrema.map(N=>v.clone(N))),M},e.set=function o(T,M,N){return v.copy(T.center,M),T.radius=N,T},e.copy=function s(T,M){return v.copy(T.center,M.center),T.radius=M.radius,t(M)&&a(T,M.extrema.map(N=>v.clone(N))),T},e.setExtrema=a,e.computeBounding=function c(T){const{x:M,y:N,z:V,indices:F}=T;let G=0,L=0,z=0,j=0;const Z=Fe.size(F);for(let $=0;$0&&(G/=Z,L/=Z,z/=Z);for(let $=0;$j&&(j=W)}return{center:v.create(G,L,z),radius:Math.sqrt(j)}},e.transform=function u(T,M,N){return v.transformMat4(T.center,M.center,N),T.radius=M.radius*le.getMaxScaleOnAxis(N),t(M)&&a(T,M.extrema.map(V=>v.transformMat4(v(),V,N))),T},e.translate=function l(T,M,N){return v.add(T.center,M.center,N),t(M)&&a(T,M.extrema.map(V=>v.add(v(),V,N))),T},e.toArray=function d(T,M,N){return v.toArray(T.center,M,N),M[N+3]=T.radius,M},e.fromArray=function f(T,M,N){return v.fromArray(T.center,M,N),T.radius=M[N+3],T},e.fromBox3D=function p(T,M){return v.scale(T.center,v.add(T.center,M.max,M.min),.5),T.radius=v.distance(T.center,M.max),e.setExtrema(T,[v.create(M.min[0],M.min[1],M.min[2]),v.create(M.max[0],M.max[1],M.max[2]),v.create(M.max[0],M.min[1],M.min[2]),v.create(M.min[0],M.max[1],M.max[2]),v.create(M.min[0],M.min[1],M.max[2]),v.create(M.max[0],M.min[1],M.max[2]),v.create(M.max[0],M.max[1],M.min[2]),v.create(M.min[0],M.max[1],M.min[2])]),T},e.fromAxes3D=function m(T,M){return v.copy(T.center,M.origin),T.radius=Math.max(v.magnitude(M.dirA),v.magnitude(M.dirB),v.magnitude(M.dirC)),T};const h=v();e.fromDimensionsAndTransform=function g(T,M,N){const[V,F,G]=M,L=v.create(0,0,0);v.transformMat4(L,L,N);const z=v.create(V,F,G);v.transformMat4(z,z,N);const j=v.create(V,0,0);v.transformMat4(j,j,N);const Z=v.create(0,F,G);v.transformMat4(Z,Z,N);const $=v.create(0,0,G);v.transformMat4($,$,N);const ee=v.create(V,0,G);v.transformMat4(ee,ee,N);const q=v.create(V,F,0);v.transformMat4(q,q,N);const O=v.create(0,F,0);v.transformMat4(O,O,N),v.add(h,L,z),v.scale(h,h,.5);const H=Math.max(v.distance(L,z),v.distance(j,Z));return e.set(T,h,H/2),e.setExtrema(T,[L,z,j,Z,$,ee,q,O]),T};const y=v();e.addVec3=function b(T,M,N){return v.distance(M.center,N)v.clone(V)),...N.extrema.map(V=>v.clone(V))]),T};const _=v();e.expand=function S(T,M,N){var V,F;if(v.copy(T.center,M.center),T.radius=M.radius+N,M.radius<1e-12||(null!==(F=null===(V=M.extrema)||void 0===V?void 0:V.length)&&void 0!==F?F:0)<=1)return T.extrema=void 0,T;if(t(M)){const G=new Float32Array(3*M.extrema.length);for(let z=0;z{v.normalize(_,v.sub(_,z,M.center));const j=v.clone(z),Z=v.dot(_,L.dirA)<0?-1:1;v.scaleAndAdd(j,j,L.dirA,Z);const $=v.dot(_,L.dirB)<0?-1:1;v.scaleAndAdd(j,j,L.dirB,$);const ee=v.dot(_,L.dirC)<0?-1:1;return v.scaleAndAdd(j,j,L.dirC,ee),v.distance(T.center,j)>T.radius&&(M.extrema.length>=14&&v.normalize(_,v.sub(_,j,M.center)),v.scaleAndAdd(j,T.center,_,T.radius)),j}))}return T},e.exactEquals=function A(T,M){return T.radius===M.radius&&v.exactEquals(T.center,M.center)},e.equals=function E(T,M){const N=T.radius,V=M.radius;return Math.abs(N-V)<=vr*Math.max(1,Math.abs(N),Math.abs(V))&&v.equals(T.center,M.center)},e.includes=function w(T,M){if(t(M)){for(const N of M.extrema)if(v.distance(T.center,N)>T.radius)return!1;return!0}return v.distance(T.center,M.center)+M.radius<=T.radius},e.overlaps=function D(T,M){return v.distance(T.center,M.center)<=T.radius+M.radius},e.distance=function I(T,M){return v.distance(T.center,M.center)-T.radius+M.radius},e.distanceToVec=function R(T,M){const{center:N,radius:V}=T;return v.distance(M,N)-V}}(_e||(_e={})),function(e){function n(){return{min:v(),max:v()}}function r(D,I){return v.copy(D.min,I.min),v.copy(D.max,I.max),D}e.create=function t(D,I){return{min:D,max:I}},e.zero=n,e.copy=r,e.clone=function i(D){return r(n(),D)};const o=v();function a(D,I){for(let R=0,T=I.length;R=14?c(D,I.extrema):(v.set(o,I.radius,I.radius,I.radius),v.sub(D.min,I.center,o),v.add(D.max,I.center,o),D)},e.addVec3Array=a,e.fromVec3Array=c,e.addSphere3D=function u(D,I){return _e.hasExtrema(I)&&I.extrema.length>=14?a(D,I.extrema):(g(D,v.subScalar(o,I.center,I.radius)),g(D,v.addScalar(o,I.center,I.radius)),D)},e.intersectsSphere3D=function l(D,I){return v.clamp(o,I.center,D.min,D.max),v.squaredDistance(o,I.center)<=I.radius*I.radius},e.computeBounding=function d(D){const I=v.create(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),R=v.create(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),{x:T,y:M,z:N,indices:V}=D;for(let F=0,G=Fe.size(V);FD.max[0]||I[1]D.max[1]||I[2]D.max[2])},e.overlaps=function A(D,I){return!(D.max[0]I.max[0]||D.max[1]I.max[1]||D.max[2]I.max[2])},e.containsSphere3D=function E(D,I){const R=I.center,T=I.radius;return!(R[0]-TD.max[0]||R[1]-TD.max[1]||R[2]-TD.max[2])},e.nearestIntersectionWithRay=function w(D,I,R,T){const[M,N,V]=I.min,[F,G,L]=I.max,[z,j,Z]=R,$=1/T[0],ee=1/T[1],q=1/T[2];let O,H,W,Q,fe,X;return $>=0?(O=(M-z)*$,H=(F-z)*$):(O=(F-z)*$,H=(M-z)*$),ee>=0?(W=(N-j)*ee,Q=(G-j)*ee):(W=(G-j)*ee,Q=(N-j)*ee),q>=0?(fe=(V-Z)*q,X=(L-Z)*q):(fe=(L-Z)*q,X=(V-Z)*q),W>O&&(O=W),QO&&(O=fe),X0)throw new Error("New key is larger than old key");t.key=n;const r=t.parent;r&&this._compare(t,r)<0&&(this._cut(t,r,this._minNode),this._cascadingCut(r,this._minNode)),this._compare(t,this._minNode)<0&&(this._minNode=t)}delete(t){const n=t.parent;n&&(this._cut(t,n,this._minNode),this._cascadingCut(n,this._minNode)),this._minNode=t,this.extractMinimum()}extractMinimum(){const t=this._minNode;if(t){if(t.child){let r=t.child;do{r.parent=null,r=r.next}while(r!==t.child)}let 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}findMinimum(){return this._minNode}insert(t,n){const r=new Yke(t,n);return this._minNode=this._mergeLists(this._minNode,r),this._nodeCount++,r}isEmpty(){return null===this._minNode}size(){return null===this._minNode?0:this._getNodeListSize(this._minNode)}union(t){this._minNode=this._mergeLists(this._minNode,t._minNode),this._nodeCount+=t._nodeCount}_defaultCompare(t,n){return t.key>n.key?1:t.key0){const s=i;i=o,o=s}this._linkHeaps(o,i),n[i.degree]=null,i.degree++,o=n[i.degree]}n[i.degree]=i}let r=null;for(let i=0;i=d.length;const fe=d[j];if(0!==fe){const X=L,J=fe-1,ce=c[J],ae=ce+u[J];for(let me=ce;meL&&(L=Le),Hb.insert(Le,oe)}X=o))for(let J=-O;J<=O;J++){const ce=I+J;if(!(ce<0||ce>=s))for(let be=-H;be<=H;be++){const ae=R+be;if(!(ae<0||ae>=a||(j=(X*s+ce)*a+ae,SB.has(j)||(SB.add(j),i2.has(j))))){if(!N){const me=n[0]+X*y[0]-x,oe=n[1]+ce*y[1]-_,K=n[2]+ae*y[2]-S;if(me*me+oe*oe+K*K-ee>L){$.push(X,ce,ae,j);continue}}G.push(X,ce,ae,j),V++}}}}}if(N=!1,0===V){if(1===A){const Q=Hb.findMinimum();if(Q){const{key:fe,value:X}=Q;return Uu.add(t,X,fe),!0}}else for(;!Hb.isEmpty()&&(Z||Hb.findMinimum().key<=L)&&t.count=A||T||t.count>=w)return t.count>0;if(N=!0,z=!0,$.length>0){for(let Q=0,fe=$.length;Q0){const p=Math.ceil(c/u),m=Math.pow(p/(o[0]*o[1]*o[2]),1/3);a=[Math.ceil(o[0]*m),Math.ceil(o[1]*m),Math.ceil(o[2]*m)],s=[o[0]/a[0],o[1]/a[1],o[2]/a[2]]}else s=o,a=[1,1,1];return function Zke(e){const{expandedBox:t,size:[n,r,i],data:{x:o,y:s,z:a,radius:c,indices:u},elementCount:l,delta:d}=e,f=n*r*i,{min:[p,m,h]}=t;let g=0,y=0;const b=new Uint32Array(f),x=new Int32Array(l);for(let w=0;wg&&(g=c[D])}const _=new Int32Array(y);for(let w=0,D=0;w0&&(b[w]=D+1,_[D]=I,D+=1)}const S=new Uint32Array(y);for(let w=1;w0){const I=D-1;E[S[I]+A[I]]=w,A[I]+=1}}return{size:e.size,bucketArray:E,bucketCounts:_,bucketOffset:S,grid:b,delta:d,min:e.expandedBox.min,data:e.data,maxRadius:g,expandedBox:e.expandedBox,boundingBox:e.boundingBox,boundingSphere:e.boundingSphere}}({size:a,data:{x:e.x,y:e.y,z:e.z,indices:i,radius:e.radius},expandedBox:r,boundingBox:t.box,boundingSphere:t.sphere,elementCount:c,delta:s})}(t,n,r);this.ctx=function Jke(e){return{grid:e,x:.1,y:.1,z:.1,k:1,stopIf:void 0,radius:.1,isCheck:!1}}(i),this.boundary={box:i.boundingBox,sphere:i.boundingSphere},this.buckets={offset:i.bucketOffset,count:i.bucketCounts,array:i.bucketArray},this.result=Uu.create()}}function CQ(e,t){const{min:n,size:[r,i,o],bucketOffset:s,bucketCounts:a,bucketArray:c,grid:u,data:{x:l,y:d,z:f,indices:p,radius:m},delta:h,maxRadius:g}=e.grid,{radius:y,isCheck:b,x,y:_,z:S}=e,A=y+g,E=A*A;Uu.reset(t);const w=Math.max(0,Math.floor((x-A-n[0])/h[0])),D=Math.max(0,Math.floor((_-A-n[1])/h[1])),I=Math.max(0,Math.floor((S-A-n[2])/h[2])),R=Math.min(r-1,Math.floor((x+A-n[0])/h[0])),T=Math.min(i-1,Math.floor((_+A-n[1])/h[1])),M=Math.min(o-1,Math.floor((S+A-n[2])/h[2]));if(w>R||D>T||I>M)return!1;for(let N=w;N<=R;N++)for(let V=D;V<=T;V++)for(let F=I;F<=M;F++){const G=u[(N*i+V)*o+F];if(0===G)continue;const L=G-1,z=s[L],Z=z+a[L];for(let $=z;$0&&Math.sqrt(W)-m[ee]>y)continue;if(b)return!0;Uu.add(t,c[$],W)}}}return t.count>0}const wQ=v(),qh=v(),i2=new Set,SB=new Set,eNe=[.1],tNe=[.1],nNe=[.1],Hb=new SQ;var nt,kr,Ae,as,Ot,zn;!function(e){function t(p,m,h){return{kind:"element-location",structure:p,unit:m,element:h||0}}e.create=t,e.clone=function n(p){return t(p.structure,p.unit,p.element)},e.set=function r(p,m,h,g){return m&&(p.structure=m),h&&(p.unit=h),void 0!==g&&(p.element=g),p},e.copy=function i(p,m){return p.unit=m.unit,p.element=m.element,p},e.is=function o(p){return!!p&&"element-location"===p.kind},e.areEqual=function s(p,m){return p.unit===m.unit&&p.element===m.element};const a=v(),c=v();e.distance=function u(p,m){return p.unit.conformation.position(p.element,a),m.unit.conformation.position(m.element,c),v.distance(a,c)},e.position=function l(p,m){return m.unit.conformation.position(m.element,p)},e.residueIndex=function d(p){return p.unit.model.atomicHierarchy.residueAtomSegments.index[p.element]},e.chainIndex=function f(p){return p.unit.model.atomicHierarchy.chainAtomSegments.index[p.element]}}(nt||(nt={}));class iNe{add(t){const n=this.getHash(t);if(this.byHash.has(n)){const r=this.byHash.get(n);for(let i=0,o=r.length;i`${r}-${i.toLocaleLowerCase()}${o}`).replace(t,(n,r,i,o)=>`${r}-${i.toLocaleLowerCase()}${o}`)}function PQ(e,t,n){if(XI(n))return n.info.namespace=e,n.info.name=n.info.name||EQ(t),void(n.id=`${n.info.namespace}.${n.info.name}`);const r=`${n["@namespace"]||EQ(t)}`,i=e?`${e}.${r}`:r;for(const o of Object.keys(n))"object"!=typeof n[o]&&!XI(n[o])||PQ(i,o,n[o])}function MQ(e,t){if(XI(e))t.push(e);else for(const n of Object.keys(e))"object"!=typeof e[n]&&!XI(e[n])||MQ(e[n],t)}function $o(e,t){return $t(Ot.Dictionary({0:ct(e)}),e,t)}function Wh(e,t){return $t(Ot.List(e,{nonEmpty:!0}),e,t)}function Vu(e,t,n){return $t(Ot.Dictionary({0:ct(e),1:ct(e)}),t,n)}!function(e){e.create=function t(){return{keys:new Set,array:[]}},e.add=function n({keys:i,array:o},s,a){return!i.has(s)&&(i.add(s),o[o.length]=a,!0)},e.has=function r({keys:i},o){return i.has(o)}}(kr||(kr={})),function(e){function n(a,c,u){return{kind:"value",namespace:a,name:c,parent:u}}function o(a,c,u,l){const d=Object.create(null);for(const f of l)d[f]=!0;return{kind:"oneof",namespace:a,name:c,type:u,values:d}}e.Variable=function t(a,c,u){return{kind:"variable",name:a,type:c,isConstraint:u}},e.Value=n,e.Container=function r(a,c,u,l){return{kind:"container",namespace:a,name:c,child:u,alias:l}},e.Union=function i(a){return{kind:"union",types:a}},e.OneOf=o,e.Any={kind:"any"},e.AnyValue={kind:"any-value"},e.Num=n("","Number"),e.Str=n("","String"),e.Bool=o("","Bool",e.Str,["true","false"]),e.oneOfValues=function s({values:a}){return Object.keys(a).sort()}}(Ae||(Ae={})),function(e){function s(c){return!!c&&!!c.head&&"object"==typeof c}function a(c){return!!c&&"string"==typeof c.name}e.Symbol=function t(c){return{name:c}},e.Apply=function n(c,u){return u?{head:c,args:u}:{head:c}},e.isArgumentsArray=function r(c){return!!c&&Array.isArray(c)},e.isArgumentsMap=function i(c){return!!c&&!Array.isArray(c)},e.isLiteral=function o(c){return!s(c)&&!a(c)},e.isApply=s,e.isSymbol=a}(as||(as={})),function(e){function t(r){return{kind:"dictionary",map:r,"@type":0}}e.None=t({}),e.Dictionary=t,e.List=function n(r,i){const{nonEmpty:o=!1}=i||{};return{kind:"list",type:r,nonEmpty:o,"@type":0}}}(Ot||(Ot={})),function(e){e.AnyVar=Ae.Variable("a",Ae.Any),e.AnyValueVar=Ae.Variable("a",Ae.Any),e.ConstrainedVar=Ae.Variable("a",Ae.Any,!0),e.Regex=Ae.Value("Core","Regex"),e.Set=t=>Ae.Container("Core","Set",t||e.AnyValueVar),e.List=t=>Ae.Container("Core","List",t||e.AnyVar),e.Fn=(t,n)=>Ae.Container("Core","Fn",t||e.AnyVar,n),e.Flags=(t,n)=>Ae.Container("Core","Flags",t,n),e.BitFlags=e.Flags(Ae.Num,"BitFlags")}(zn||(zn={})),Ot.Dictionary({0:ct(Ae.Num),1:ct(Ae.Num)});const AB={"@header":"Language Primitives",type:{"@header":"Types",bool:$t(Ot.Dictionary({0:ct(Ae.AnyValue)}),Ae.Bool,"Convert a value to boolean."),num:$t(Ot.Dictionary({0:ct(Ae.AnyValue)}),Ae.Num,"Convert a value to number."),str:$t(Ot.Dictionary({0:ct(Ae.AnyValue)}),Ae.Str,"Convert a value to string."),regex:$t(Ot.Dictionary({0:ct(Ae.Str,{description:"Expression"}),1:ct(Ae.Str,{isOptional:!0,description:"Flags, e.g. 'i' for ignore case"})}),zn.Regex,"Creates a regular expression from a string using the ECMAscript syntax."),list:$t(Ot.List(zn.AnyVar),zn.List()),set:$t(Ot.List(zn.AnyValueVar),zn.Set()),bitflags:$t(Ot.Dictionary({0:ct(Ae.Num)}),zn.BitFlags,"Interpret a number as bitflags."),compositeKey:$t(Ot.List(Ae.AnyValue),Ae.AnyValue)},logic:{"@header":"Logic",not:$o(Ae.Bool),and:Wh(Ae.Bool),or:Wh(Ae.Bool)},ctrl:{"@header":"Control",eval:$t(Ot.Dictionary({0:ct(zn.Fn(zn.AnyVar))}),zn.AnyVar,"Evaluate a function."),fn:$t(Ot.Dictionary({0:ct(zn.AnyVar)}),zn.Fn(zn.AnyVar),'Wrap an expression to a "lazy" function.'),if:$t(Ot.Dictionary({0:ct(Ae.Bool,{description:"Condition"}),1:ct(Ae.Variable("a",Ae.Any),{description:"If true"}),2:ct(Ae.Variable("b",Ae.Any),{description:"If false"})}),Ae.Union([Ae.Variable("a",Ae.Any),Ae.Variable("b",Ae.Any)])),assoc:$t(Ot.Dictionary({0:ct(Ae.Str,{description:"Name"}),1:ct(Ae.Variable("a",Ae.Any),{description:"Value to assign"})}),Ae.Variable("a",Ae.Any))},rel:{"@header":"Relational",eq:Vu(Ae.Variable("a",Ae.AnyValue,!0),Ae.Bool),neq:Vu(Ae.Variable("a",Ae.AnyValue,!0),Ae.Bool),lt:Vu(Ae.Num,Ae.Bool),lte:Vu(Ae.Num,Ae.Bool),gr:Vu(Ae.Num,Ae.Bool),gre:Vu(Ae.Num,Ae.Bool),inRange:$t(Ot.Dictionary({0:ct(Ae.Num,{description:"Value to test"}),1:ct(Ae.Num,{description:"Minimum value"}),2:ct(Ae.Num,{description:"Maximum value"})}),Ae.Bool,"Check if the value of the 1st argument is >= 2nd and <= 3rd.")},math:{"@header":"Math",add:Wh(Ae.Num),sub:Wh(Ae.Num),mult:Wh(Ae.Num),div:Vu(Ae.Num,Ae.Num),pow:Vu(Ae.Num,Ae.Num),mod:Vu(Ae.Num,Ae.Num),min:Wh(Ae.Num),max:Wh(Ae.Num),cantorPairing:Vu(Ae.Num,Ae.Num),sortedCantorPairing:Vu(Ae.Num,Ae.Num),invertCantorPairing:$t(Ot.Dictionary({0:ct(Ae.Num)}),zn.List(Ae.Num)),floor:$o(Ae.Num),ceil:$o(Ae.Num),roundInt:$o(Ae.Num),trunc:$o(Ae.Num),abs:$o(Ae.Num),sign:$o(Ae.Num),sqrt:$o(Ae.Num),cbrt:$o(Ae.Num),sin:$o(Ae.Num),cos:$o(Ae.Num),tan:$o(Ae.Num),asin:$o(Ae.Num),acos:$o(Ae.Num),atan:$o(Ae.Num),sinh:$o(Ae.Num),cosh:$o(Ae.Num),tanh:$o(Ae.Num),exp:$o(Ae.Num),log:$o(Ae.Num),log10:$o(Ae.Num),atan2:Vu(Ae.Num,Ae.Num)},str:{"@header":"Strings",concat:Wh(Ae.Str),match:$t(Ot.Dictionary({0:ct(zn.Regex),1:ct(Ae.Str)}),Ae.Bool)},list:{"@header":"Lists",getAt:$t(Ot.Dictionary({0:ct(zn.List()),1:ct(Ae.Num)}),zn.AnyVar),equal:$t(Ot.Dictionary({0:ct(zn.List()),1:ct(zn.List())}),Ae.Bool)},set:{"@header":"Sets",has:$t(Ot.Dictionary({0:ct(zn.Set(zn.ConstrainedVar)),1:ct(zn.ConstrainedVar)}),Ae.Bool,"Check if the the 1st argument includes the value of the 2nd."),isSubset:$t(Ot.Dictionary({0:ct(zn.Set(zn.ConstrainedVar)),1:ct(zn.Set(zn.ConstrainedVar))}),Ae.Bool,"Check if the the 1st argument is a subset of the 2nd.")},flags:{"@header":"Flags",hasAny:$t(Ot.Dictionary({0:ct(zn.Flags(zn.ConstrainedVar)),1:ct(zn.Flags(zn.ConstrainedVar))}),Ae.Bool,"Check if the the 1st argument has at least one of the 2nd one's flags."),hasAll:$t(Ot.Dictionary({0:ct(zn.Flags(zn.ConstrainedVar)),1:ct(zn.Flags(zn.ConstrainedVar))}),Ae.Bool,"Check if the the 1st argument has all 2nd one's flags.")}};TQ(AB);const mNe=DQ(AB);var wt;function Bn(e,t){return $t(Ot.Dictionary({0:ct(wt.ElementReference,{isOptional:!0,defaultValue:"slot.current-atom"})}),e,t)}function qb(e,t){return $t(Ot.None,e,t)}!function(){const e=Object.create(null);for(const t of mNe)e[t.id]=t}(),function(e){e.ElementSymbol=Ae.Value("Structure","ElementSymbol"),e.AtomName=Ae.Value("Structure","AtomName"),e.BondFlag=Ae.OneOf("Structure","BondFlag",Ae.Str,["covalent","metallic","ion","hydrogen","sulfide","computed","aromatic"]),e.BondFlags=zn.Flags(e.BondFlag,"BondFlags"),e.SecondaryStructureFlag=Ae.OneOf("Structure","SecondaryStructureFlag",Ae.Str,["alpha","beta","3-10","pi","sheet","strand","helix","turn","none"]),e.SecondaryStructureFlags=zn.Flags(e.SecondaryStructureFlag,"SecondaryStructureFlag"),e.RingFingerprint=Ae.Value("Structure","RingFingerprint"),e.EntityType=Ae.OneOf("Structure","EntityType",Ae.Str,["polymer","non-polymer","water","branched"]),e.EntitySubtype=Ae.OneOf("Structure","EntitySubtype",Ae.Str,["other","polypeptide(D)","polypeptide(L)","polydeoxyribonucleotide","polyribonucleotide","polydeoxyribonucleotide/polyribonucleotide hybrid","cyclic-pseudo-peptide","peptide nucleic acid","oligosaccharide"]),e.ObjectPrimitive=Ae.OneOf("Structure","ObjectPrimitive",Ae.Str,["atomistic","sphere","gaussian","other"]),e.ResidueId=Ae.Value("Structure","ResidueId"),e.ElementSet=Ae.Value("Structure","ElementSet"),e.ElementSelection=Ae.Value("Structure","ElementSelection"),e.ElementReference=Ae.Value("Structure","ElementReference"),e.ElementSelectionQuery=zn.Fn(e.ElementSelection,"ElementSelectionQuery")}(wt||(wt={}));const ye={core:AB,structureQuery:{"@header":"Structure Queries",type:{"@header":"Types",elementSymbol:$t(Ot.Dictionary({0:ct(Ae.Str)}),wt.ElementSymbol,"Create element symbol representation from a string value."),atomName:$t(Ot.Dictionary({0:ct(Ae.AnyValue)}),wt.AtomName,"Convert a value to an atom name."),entityType:$t(Ot.Dictionary({0:ct(wt.EntityType)}),wt.EntityType,`Create normalized representation of entity type: ${Ae.oneOfValues(wt.EntityType).join(", ")}.`),bondFlags:$t(Ot.List(wt.BondFlag),wt.BondFlags,`Create bond flags representation from a list of strings. Allowed flags: ${Ae.oneOfValues(wt.BondFlag).join(", ")}.`),ringFingerprint:$t(Ot.List(wt.ElementSymbol,{nonEmpty:!0}),wt.RingFingerprint,"Create ring fingerprint from the supplied atom element list."),secondaryStructureFlags:$t(Ot.List(wt.SecondaryStructureFlag),wt.SecondaryStructureFlags,`Create secondary structure flags representation from a list of strings. Allowed flags: ${Ae.oneOfValues(wt.SecondaryStructureFlag).join(", ")}.`),authResidueId:$t(Ot.Dictionary({0:ct(Ae.Str,{description:"auth_asym_id"}),1:ct(Ae.Num,{description:"auth_seq_id"}),2:ct(Ae.Str,{description:"pdbx_PDB_ins_code",isOptional:!0})}),wt.ResidueId,'Residue identifier based on "auth_" annotation.'),labelResidueId:$t(Ot.Dictionary({0:ct(Ae.Str,{description:"label_entity_id"}),1:ct(Ae.Str,{description:"label_asym_id"}),2:ct(Ae.Num,{description:"label_seq_id"}),3:ct(Ae.Str,{description:"pdbx_PDB_ins_code",isOptional:!0})}),wt.ResidueId,'Residue identifier based on mmCIF\'s "label_" annotation.')},slot:{"@header":"Iteration Slots",element:$t(Ot.None,wt.ElementReference,"A reference to the current element."),elementSetReduce:$t(Ot.None,Ae.Variable("a",Ae.AnyValue,!0),"Current value of the element set reducer.")},generator:{"@header":"Generators",all:$t(Ot.None,wt.ElementSelectionQuery,"The entire structure."),atomGroups:$t(Ot.Dictionary({"entity-test":ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test for the 1st atom of every entity"}),"chain-test":ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test for the 1st atom of every chain"}),"residue-test":ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test for the 1st atom every residue"}),"atom-test":ct(Ae.Bool,{isOptional:!0,defaultValue:!0}),"group-by":ct(Ae.Any,{isOptional:!0,defaultValue:"atom-key",description:"Group atoms to sets based on this property. Default: each atom has its own set"})}),wt.ElementSelectionQuery,"Return all atoms for which the tests are satisfied, grouped into sets."),bondedAtomicPairs:$t(Ot.Dictionary({0:ct(Ae.Bool,{isOptional:!0,defaultValue:"true for covalent bonds",description:"Test each bond with this predicate. Each bond is visited twice with swapped atom order."})}),wt.ElementSelectionQuery,"Return all pairs of atoms for which the test is satisfied."),rings:$t(Ot.Dictionary({fingerprint:ct(wt.RingFingerprint,{isOptional:!0}),"only-aromatic":ct(Ae.Bool,{isOptional:!0,defaultValue:!1})}),wt.ElementSelectionQuery,"Return all rings or those with the specified fingerprint and/or only aromatic rings."),queryInSelection:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),query:ct(wt.ElementSelectionQuery),"in-complement":ct(Ae.Bool,{isOptional:!0,defaultValue:!1})}),wt.ElementSelectionQuery,"Executes query only on atoms that are in the source selection."),empty:$t(Ot.None,wt.ElementSelectionQuery,"Nada.")},modifier:{"@header":"Selection Modifications",queryEach:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),query:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Query every atom set in the input selection separately."),intersectBy:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),by:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Intersect each atom set from the first sequence from atoms in the second one."),exceptBy:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),by:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Remove all atoms from 'selection' that occur in 'by'."),unionBy:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),by:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"For each atom set A in the orginal sequence, combine all atoms sets in the target selection that intersect with A."),union:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Collects all atom sets in the sequence into a single atom set."),cluster:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),"min-distance":ct(Ae.Num,{isOptional:!0,defaultValue:0}),"max-distance":ct(Ae.Num),"min-size":ct(Ae.Num,{description:"Minimal number of sets to merge, must be at least 2",isOptional:!0,defaultValue:2}),"max-size":ct(Ae.Num,{description:"Maximal number of sets to merge, if not set, no limit",isOptional:!0})}),wt.ElementSelectionQuery,"Combines atom sets that have mutual distance in the interval [min-radius, max-radius]. Minimum/maximum size determines how many atom sets can be combined."),includeSurroundings:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),radius:ct(Ae.Num),"atom-radius":ct(Ae.Num,{isOptional:!0,defaultValue:0,description:"Value added to each atom before the distance check, for example VDW radius. Using this argument is computationally demanding."}),"as-whole-residues":ct(Ae.Bool,{isOptional:!0})}),wt.ElementSelectionQuery,"For each atom set in the selection, include all surrouding atoms/residues that are within the specified radius."),surroundingLigands:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),radius:ct(Ae.Num),"include-water":ct(Ae.Bool,{isOptional:!0,defaultValue:!0})}),wt.ElementSelectionQuery,"Find all ligands components around the source query."),includeConnected:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),"bond-test":ct(Ae.Bool,{isOptional:!0,defaultValue:"true for covalent bonds"}),"layer-count":ct(Ae.Num,{isOptional:!0,defaultValue:1,description:"Number of bonded layers to include."}),"fixed-point":ct(Ae.Bool,{isOptional:!0,defaultValue:!1,description:"Continue adding layers as long as new connections exist."}),"as-whole-residues":ct(Ae.Bool,{isOptional:!0})}),wt.ElementSelectionQuery,"Pick all atom sets that are connected to the target."),wholeResidues:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Expand the selection to whole residues."),expandProperty:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),property:ct(Ae.AnyValue)}),wt.ElementSelectionQuery,"To each atom set in the selection, add all atoms that have the same property value that was already present in the set.")},filter:{"@header":"Selection Filters",pick:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),test:ct(Ae.Bool)}),wt.ElementSelectionQuery,"Pick all atom sets that satisfy the test."),first:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Take the 1st atom set in the sequence."),withSameAtomProperties:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),source:ct(wt.ElementSelectionQuery),property:ct(Ae.Any)}),wt.ElementSelectionQuery,"Pick all atom sets for which the set of given atom properties is a subset of the source properties."),intersectedBy:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),by:ct(wt.ElementSelectionQuery)}),wt.ElementSelectionQuery,"Pick all atom sets that have non-zero intersection with the target."),within:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),target:ct(wt.ElementSelectionQuery),"min-radius":ct(Ae.Num,{isOptional:!0,defaultValue:0}),"max-radius":ct(Ae.Num),"atom-radius":ct(Ae.Num,{isOptional:!0,defaultValue:0,description:"Value added to each atom before the distance check, for example VDW radius. Using this argument is computationally demanding."}),invert:ct(Ae.Bool,{isOptional:!0,defaultValue:!1,description:"If true, pick only atom sets that are further than the specified radius."})}),wt.ElementSelectionQuery,"Pick all atom sets from selection that have any atom within the radius of any atom from target."),isConnectedTo:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery),target:ct(wt.ElementSelectionQuery),"bond-test":ct(Ae.Bool,{isOptional:!0,defaultValue:"true for covalent bonds"}),disjunct:ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"If true, there must exist a bond to an atom that lies outside the given atom set to pass test."}),invert:ct(Ae.Bool,{isOptional:!0,defaultValue:!1,description:"If true, return atom sets that are not connected."})}),wt.ElementSelectionQuery,"Pick all atom sets that are connected to the target.")},combinator:{"@header":"Selection Combinators",intersect:$t(Ot.List(wt.ElementSelectionQuery),wt.ElementSelectionQuery,"Return all unique atom sets that appear in all of the source selections."),merge:$t(Ot.List(wt.ElementSelectionQuery),wt.ElementSelectionQuery,"Merges multiple selections into a single one. Only unique atom sets are kept."),distanceCluster:$t(Ot.Dictionary({matrix:ct(zn.List(zn.List(Ae.Num)),{description:"Distance matrix, represented as list of rows (num[][])). Lower triangle is min distance, upper triangle is max distance."}),selections:ct(zn.List(wt.ElementSelectionQuery),{description:"A list of held selections."})}),wt.ElementSelectionQuery,"Pick combinations of atom sets from the source sequences that are mutually within distances specified by a matrix.")},atomSet:{"@header":"Atom Sets",atomCount:$t(Ot.None,Ae.Num),countQuery:$t(Ot.Dictionary({0:ct(wt.ElementSelectionQuery)}),Ae.Num,"Counts the number of occurences of a specific query inside the current atom set."),reduce:$t(Ot.Dictionary({initial:ct(Ae.Variable("a",Ae.AnyValue,!0),{description:"Initial value assigned to slot.atom-set-reduce. Current atom is set to the 1st atom of the current set for this."}),value:ct(Ae.Variable("a",Ae.AnyValue,!0),{description:"Expression executed for each atom in the set"})}),Ae.Variable("a",Ae.AnyValue,!0),"Execute the value expression for each atom in the current atom set and return the result. Works the same way as Array.reduce in JavaScript (``result = value(value(...value(initial)))``)"),propertySet:$t(Ot.Dictionary({0:ct(zn.ConstrainedVar)}),zn.Set(zn.ConstrainedVar),"Returns a set with all values of the given property in the current atom set.")},atomProperty:{"@header":"Atom Properties",core:{"@header":"Core Properties",elementSymbol:Bn(wt.ElementSymbol),vdw:Bn(Ae.Num,"Van der Waals radius"),mass:Bn(Ae.Num,"Atomic weight"),atomicNumber:Bn(Ae.Num,"Atomic number"),x:Bn(Ae.Num,"Cartesian X coordinate"),y:Bn(Ae.Num,"Cartesian Y coordinate"),z:Bn(Ae.Num,"Cartesian Z coordinate"),atomKey:Bn(Ae.AnyValue,"Unique value for each atom. Main use case is grouping of atoms."),bondCount:$t(Ot.Dictionary({0:ct(wt.ElementReference,{isOptional:!0,defaultValue:"slot.current-atom"}),flags:ct(wt.BondFlags,{isOptional:!0,defaultValue:"covalent"})}),Ae.Num,"Number of bonds (by default only covalent bonds are counted)."),sourceIndex:Bn(Ae.Num,"Index of the atom/element in the input file."),operatorName:Bn(Ae.Str,"Name of the symmetry operator applied to this element."),operatorKey:Bn(Ae.Num,"Key of the symmetry operator applied to this element."),modelIndex:Bn(Ae.Num,"Index of the model in the input file."),modelLabel:Bn(Ae.Str,"Label/header of the model in the input file.")},topology:{connectedComponentKey:Bn(Ae.AnyValue,"Unique value for each connected component.")},macromolecular:{"@header":"Macromolecular Properties (derived from the mmCIF format)",authResidueId:Bn(wt.ResidueId,"type.auth-residue-id symbol executed on current atom's residue"),labelResidueId:Bn(wt.ResidueId,"type.label-residue-id symbol executed on current atom's residue"),residueKey:Bn(Ae.AnyValue,"Unique value for each tuple ``(label_entity_id,auth_asym_id, auth_seq_id, pdbx_PDB_ins_code)``, main use case is grouping of atoms"),chainKey:Bn(Ae.AnyValue,"Unique value for each tuple ``(label_entity_id, auth_asym_id)``, main use case is grouping of atoms"),entityKey:Bn(Ae.AnyValue,"Unique value for each tuple ``label_entity_id``, main use case is grouping of atoms"),isHet:Bn(Ae.Bool,"Equivalent to atom_site.group_PDB !== ATOM"),id:Bn(Ae.Num,"_atom_site.id"),label_atom_id:Bn(wt.AtomName),label_alt_id:Bn(Ae.Str),label_comp_id:Bn(Ae.Str),label_asym_id:Bn(Ae.Str),label_entity_id:Bn(Ae.Str),label_seq_id:Bn(Ae.Num),auth_atom_id:Bn(wt.AtomName),auth_comp_id:Bn(Ae.Str),auth_asym_id:Bn(Ae.Str),auth_seq_id:Bn(Ae.Num),pdbx_PDB_ins_code:Bn(Ae.Str),pdbx_formal_charge:Bn(Ae.Num),occupancy:Bn(Ae.Num),B_iso_or_equiv:Bn(Ae.Num),entityType:Bn(wt.EntityType,"Type of the entity as defined in mmCIF (polymer, non-polymer, branched, water)"),entitySubtype:Bn(wt.EntitySubtype,"Subtype of the entity as defined in mmCIF _entity_poly.type and _pdbx_entity_branch.type (other, polypeptide(D), polypeptide(L), polydeoxyribonucleotide, polyribonucleotide, polydeoxyribonucleotide/polyribonucleotide hybrid, cyclic-pseudo-peptide, peptide nucleic acid, oligosaccharide)"),entityPrdId:Bn(Ae.Str,"The PRD ID of the entity."),entityDescription:Bn(zn.List(Ae.Str)),objectPrimitive:Bn(wt.ObjectPrimitive,"Type of the primitive object used to model this segment as defined in mmCIF/IHM (atomistic, sphere, gaussian, other)"),secondaryStructureKey:Bn(Ae.AnyValue,"Unique value for each secondary structure element."),secondaryStructureFlags:Bn(wt.SecondaryStructureFlags),isModified:Bn(Ae.Bool,"True if the atom belongs to modification of a standard residue."),modifiedParentName:Bn(Ae.Str,"'3-letter' code of the modifed parent residue."),isNonStandard:Bn(Ae.Bool,"True if this is a non-standard residue."),chemCompType:Bn(Ae.Str,"Type of the chemical component as defined in mmCIF.")}},bondProperty:{"@header":"Bond Properties",flags:qb(wt.BondFlags),order:qb(Ae.Num),key:qb(Ae.Num),length:qb(Ae.Num),atomA:qb(wt.ElementReference),atomB:qb(wt.ElementReference)}},internal:{"@header":"Internal Queries",generator:{"@header":"Generators",bundleElement:$t(Ot.Dictionary({groupedUnits:ct(Ae.Any),set:ct(Ae.Any),ranges:ct(Ae.Any)}),Ae.Any),bundle:$t(Ot.Dictionary({elements:ct(Ae.Any)}),wt.ElementSelectionQuery,"A selection with single structure containing represented by the bundle."),current:$t(Ot.None,wt.ElementSelectionQuery,"Current selection provided by the query context. Avoid using this in State Transforms.")}}};TQ(ye);const TNe=DQ(ye);var ue;function Yo(){return Yo.zero()}function id(){return id.zero()}function st(e){return e}function Gn(e,t,n,r){return{label:e,description:n,list:r,type:t}}function KI(e,t,n){const r={};for(const i in e){let o=e[i];o=st.saturate(o,t),o=st.darken(o,-n),r[i]=o}return r}function RQ(e,t=" "){return e.replace(/([a-z\xE0-\xFF])([A-Z\xC0\xDF])/g,`$1${t}$2`)}!function(){const e=Object.create(null);for(const t of TNe)e[t.id]=t}(),function(e){e.core=ye.core,e.struct=ye.structureQuery,e.internal=ye.internal,e.atomName=function t(b){return e.struct.type.atomName([b])},e.es=function n(b){return e.struct.type.elementSymbol([b])},e.list=function r(...b){return e.core.type.list(b)},e.set=function i(...b){return e.core.type.set(b)},e.re=function o(b,x){return e.core.type.regex([b,x])},e.fn=function s(b){return e.core.ctrl.fn([b])},e.evaluate=function a(b){return e.core.ctrl.eval([b])};const c=e.struct.atomProperty.core,u=e.struct.atomProperty.macromolecular,l=e.struct.atomProperty.topology;function d(b){return c[b]()}function f(b){return l[b]()}function p(b){return u[b]()}e.acp=d,e.atp=f,e.ammp=p;const m=e.struct.atomSet.propertySet;e.acpSet=function h(b){return m([d(b)])},e.atpSet=function g(b){return m([f(b)])},e.ammpSet=function y(b){return m([p(b)])}}(ue||(ue={})),function(e){function t(){const T=[.1,0,0];return T[0]=0,T}function c(T,M){const[N,V,F]=M,G=Math.sqrt(V*V+F*F);let L=(su(Math.atan2(F,V))+360)%360;return 0===Math.round(1e4*G)&&(L=Number.NaN),T[0]=L,T[1]=G,T[2]=N,T}function l(T,M,N){return T[0]=M[0]-h*N,T[1]=M[1],T[2]=M[2],T}e.zero=t,e.create=function n(T,M,N){const V=t();return V[0]=T,V[1]=M,V[2]=N,V},e.set=function r(T,M,N,V){return T[0]=M,T[1]=N,T[2]=V,T},e.distance=function i(T,M){const N=M[0]-T[0],V=M[1]-T[1],F=M[2]-T[2];return Math.sqrt(N*N+V*V+F*F)},e.fromColor=function o(T,M){const[N,V,F]=st.toRgb(M),[G,L,z]=function R(T,M,N){return[I((.4124564*(T=D(T))+.3575761*(M=D(M))+.1804375*(N=D(N)))/g),I((.2126729*T+.7151522*M+.072175*N)/y),I((.0193339*T+.119192*M+.9503041*N)/b)]}(N,V,F),j=116*L-16;return T[0]=j<0?0:j,T[1]=500*(G-L),T[2]=200*(L-z),T},e.fromHcl=function s(T,M){return id.toLab(T,M)},e.toColor=function a(T){let M=(T[0]+16)/116,N=isNaN(T[1])?M:M+T[1]/500,V=isNaN(T[2])?M:M-T[2]/200;M=y*w(M),N=g*w(N),V=b*w(V);const F=E(3.2404542*N-1.5371385*M-.4985314*V),G=E(-.969266*N+1.8760108*M+.041556*V),L=E(.0556434*N-.2040259*M+1.0572252*V);return st.fromRgb(Math.round(os(F,0,255)),Math.round(os(G,0,255)),Math.round(os(L,0,255)))},e.toHcl=c,e.copy=function u(T,M){return T[0]=M[0],T[1]=M[1],T[2]=M[2],T},e.darken=l,e.lighten=function d(T,M,N){return l(T,M,-N)};const f=[0,0,0];function p(T,M,N){return c(f,M),id.toLab(T,id.saturate(f,f,N))}e.saturate=p,e.desaturate=function m(T,M,N){return p(T,M,-N)};const h=18,g=.95047,y=1,b=1.08883,x=.137931034,_=.206896552,S=.12841855,A=.008856452;function E(T){return 255*(T<=.00304?12.92*T:1.055*Math.pow(T,1/2.4)-.055)}function w(T){return T>_?T*T*T:S*(T-x)}function D(T){return(T/=255)<=.04045?T/12.92:Math.pow((T+.055)/1.055,2.4)}function I(T){return T>A?Math.pow(T,1/3):T/S+x}}(Yo||(Yo={})),function(e){function t(){const b=[.1,0,0];return b[0]=0,b}e.zero=t,e.create=function n(b,x,_){const S=t();return S[0]=b,S[1]=x,S[2]=_,S},e.set=function r(b,x,_,S){return b[0]=x,b[1]=_,b[2]=S,b},e.hasHue=function i(b){return!isNaN(b[0])};const o=[0,0,0];e.fromColor=function s(b,x){return Yo.toHcl(b,Yo.fromColor(o,x))},e.fromLab=function a(b,x){return Yo.toHcl(b,x)};const c=[0,0,0];function l(b,x){let[_,S,A]=x;return isNaN(_)&&(_=0),_=Yn(_),b[0]=A,b[1]=Math.cos(_)*S,b[2]=Math.sin(_)*S,b}function f(b,x,_){return b[0]=x[0],b[1]=Math.max(0,x[1]+y*_),b[2]=x[2],b}e.toColor=function u(b){return Yo.toColor(l(c,b))},e.toLab=l,e.copy=function d(b,x){return b[0]=x[0],b[1]=x[1],b[2]=x[2],b},e.saturate=f,e.desaturate=function p(b,x,_){return f(b,x,-_)};const m=[0,0,0];function h(b,x,_){return l(m,x),Yo.toHcl(b,Yo.darken(m,m,_))}e.darken=h,e.lighten=function g(b,x,_){return h(b,x,-_)};const y=18}(id||(id={})),function(e){function u(F,G,L){return F<<16|G<<8|L}function l(F,G,L){return 255*F<<16|255*G<<8|255*L}function b(F){const G=F>>16&255;return G!==(F>>8&255)||G!==(255&F)}e.toStyle=function t(F){return`rgb(${F>>16&255}, ${F>>8&255}, ${255&F})`},e.toHexStyle=function n(F){return"#"+("000000"+F.toString(16)).slice(-6)},e.toHexString=function r(F){return"0x"+("000000"+F.toString(16)).slice(-6)},e.toRgbString=function i(F){return`RGB: ${e.toRgb(F).join(", ")}`},e.toRgb=function o(F){return[F>>16&255,F>>8&255,255&F]},e.toRgbNormalized=function s(F){return[(F>>16&255)/255,(F>>8&255)/255,(255&F)/255]},e.fromHexStyle=function a(F){return parseInt(F.replace("#","0x"))},e.fromHexString=function c(F){return parseInt(F)},e.fromRgb=u,e.fromNormalizedRgb=l,e.fromArray=function d(F,G){return u(F[G],F[G+1],F[G+2])},e.fromNormalizedArray=function f(F,G){return l(F[G],F[G+1],F[G+2])},e.toArray=function p(F,G,L){return G[L]=F>>16&255,G[L+1]=F>>8&255,G[L+2]=255&F,G},e.toArrayNormalized=function m(F,G,L){return G[L]=(F>>16&255)/255,G[L+1]=(F>>8&255)/255,G[L+2]=(255&F)/255,G},e.toVec3=function h(F,G){return F[0]=G>>16&255,F[1]=G>>8&255,F[2]=255&G,F},e.toVec3Normalized=function g(F,G){return F[0]=(G>>16&255)/255,F[1]=(G>>8&255)/255,F[2]=(255&G)/255,F},e.interpolate=function y(F,G,L){const z=F>>16&255,j=F>>8&255,Z=255&F;return z+((G>>16&255)-z)*L<<16|j+((G>>8&255)-j)*L<<8|Z+((255&G)-Z)*L},e.hasHue=b;const x=[0,0,0];function _(F,G){return b(F)?(id.fromColor(x,F),id.toColor(id.saturate(x,x,G))):F}e.saturate=_,e.desaturate=function S(F,G){return _(F,-G)};const A=[0,0,0];function E(F,G){return Yo.fromColor(A,F),Yo.toColor(Yo.darken(A,A,G))}function D(F){return F<=.03928?F/12.92:Math.pow((F+.055)/1.055,2.4)}function I(F){return.2126*D((F>>16&255)/255)+.7152*D((F>>8&255)/255)+.0722*D((255&F)/255)}function T(F){return F<.04045?.0773993808*F:Math.pow(.9478672986*F+.0521327014,2.4)}function N(F){return F<.0031308?12.92*F:1.055*Math.pow(F,.41666)-.055}e.darken=E,e.lighten=function w(F,G){return E(F,-G)},e.luminance=I,e.contrast=function R(F,G){const L=I(F),z=I(G);return L>z?(L+.05)/(z+.05):(z+.05)/(L+.05)},e.sRGBToLinear=function M(F){return l(T((F>>16&255)/255),T((F>>8&255)/255),T((255&F)/255))},e.linearToSRGB=function V(F){return l(N((F>>16&255)/255),N((F>>8&255)/255),N((255&F)/255))}}(st||(st={}));const PNe=e=>e.toUpperCase();function Fg(e){return e.toLowerCase().replace(/^\w|\s\w/g,PNe)}function zu(e){return Fg(RQ(function kQ(e){return e.replace(/_/g," ")}(function NQ(e){return e.replace(/-/g," ")}(e))))}function to(e,t,n,r){const i=r.length;if(i>n-t)return!1;for(let o=0;o]+>/g,"")}function s2(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Pc={"orange-red":Gn("Orange-Red","sequential","Orange-Red, sequential color scheme from ColorBrewer 2.0",[16775148,16705736,16635038,16628612,16551257,15689032,14102559,11730944,8323072]),"purple-blue":Gn("Purple-Blue","sequential","Purple-Blue, sequential color scheme from ColorBrewer 2.0",[16775163,15525874,13685222,10927579,7645647,3576e3,356528,285325,145496]),"blue-purple":Gn("Blue-Purple","sequential","Blue-Purple, sequential color scheme from ColorBrewer 2.0",[16252157,14740724,12571622,10403034,9213638,9202609,8929693,8458108,5046347]),oranges:Gn("Oranges","sequential","",[16774635,16705230,16634018,16625259,16616764,15821075,14239745,10892803,8333060]),"blue-green":Gn("Blue-Green","sequential","",[16252157,15070713,13429990,10082505,6734500,4304502,2329413,27948,17435]),"yellow-orange-brown":Gn("Yellow-Orange-Brown","sequential","",[16777189,16775100,16704401,16696399,16685353,15495188,13388802,10040324,6694150]),"yellow-green":Gn("Yellow-Green","sequential","",[16777189,16252089,14282915,11394446,7915129,4303709,2327619,26679,17705]),reds:Gn("Reds","sequential","",[16774640,16703698,16563105,16552562,16476746,15678252,13309981,10817301,6750221]),"red-purple":Gn("Red-Purple","sequential","",[16775155,16638173,16565696,16424885,16214177,14496919,11403646,7995767,4784234]),greens:Gn("Greens","sequential","",[16252149,15070688,13101504,10607003,7652470,4303709,2329413,27948,17435]),"yellow-green-blue":Gn("Yellow-Green-Blue","sequential","",[16777177,15595697,13101492,8375739,4306628,1937856,2252456,2438292,531800]),purples:Gn("Purples","sequential","",[16579581,15724021,14342891,12369372,10394312,8420794,6967715,5515151,4128893]),"green-blue":Gn("Green-Blue","sequential","",[16252144,14742491,13429701,11066805,8113348,5157843,2854078,551084,540801]),greys:Gn("Greys","sequential","",[16777215,15790320,14277081,12434877,9868950,7566195,5395026,2434341,0]),"yellow-orange-red":Gn("Yellow-Orange-Red","sequential","",[16777164,16772512,16701814,16691788,16616764,16535082,14883356,12386342,8388646]),"purple-red":Gn("Purple-Red","sequential","",[16250105,15196655,13941210,13210823,14640560,15149450,13505110,9961539,6750239]),blues:Gn("Blues","sequential","",[16251903,14609399,13032431,10406625,7057110,4362950,2191797,545180,536683]),"purple-blue-green":Gn("Purple-Blue-Green","sequential","",[16775163,15524592,13685222,10927579,6793679,3576e3,164234,93273,83510]),spectral:Gn("Spectral","diverging","",[10355010,13975119,16018755,16625249,16703627,16777151,15136152,11263396,6734501,3311805,6180770]),"red-yellow-green":Gn("Red-Yellow-Green","diverging","",[10813478,14102567,16018755,16625249,16703627,16777151,14282635,10934634,6733155,1742928,26679]),"red-blue":Gn("Red-Blue","diverging","",[6750239,11671595,14049357,16033154,16636871,16250871,13755888,9618910,4428739,2188972,340065]),"pink-yellow-green":Gn("Pink-Yellow-Green","diverging","",[9306450,12917629,14579630,15840986,16638191,16250871,15136208,12116358,8371265,5083681,2581529]),"purple-green":Gn("Purple-Green","diverging","",[4194379,7744131,10055851,12756431,15193320,16250871,14282963,10935200,5942881,1800247,17435]),"red-yellow-blue":Gn("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":Gn("Brown-White-Green","diverging","",[5517317,9195786,12550445,14664317,16181443,16119285,13101797,8441281,3512207,91742,15408]),"red-grey":Gn("Red-Grey","diverging","",[6750239,11671595,14049357,16033154,16636871,16777215,14737632,12237498,8882055,5066061,1710618]),"orange-purple":Gn("Orange-Purple","diverging","",[8338184,11753478,14713364,16627811,16703670,16250871,14211819,11709394,8418220,5515144,2949195]),"set-2":Gn("Set-2","qualitative","",[6734501,16551266,9281739,15174339,10934356,16767279,15058068,11776947]),accent:Gn("Accent","qualitative","",[8374655,12496596,16629894,16777113,3697840,15729279,12540695,6710886]),"set-1":Gn("Set-1","qualitative","",[14948892,3636920,5091146,9981603,16744192,16777011,10901032,16220607,10066329]),"set-3":Gn("Set-3","qualitative","",[9294791,16777139,12499674,16482418,8434131,16626786,11787881,16567781,14277081,12353725,13429701,16772463]),"dark-2":Gn("Dark-2","qualitative","",[1810039,14245634,7696563,15149450,6727198,15117058,10909213,6710886]),paired:Gn("Paired","qualitative","",[10931939,2062516,11722634,3383340,16489113,14883356,16629615,16744192,13284054,6962586,16777113,11622696]),"pastel-2":Gn("Pastel-2","qualitative","",[11789005,16633260,13358568,16042724,15136201,16773806,15852236,13421772]),"pastel-1":Gn("Pastel-1","qualitative","",[16495790,11783651,13429701,14601188,16701862,16777164,15063229,16636652,15921906]),"many-distinct":Gn("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:Gn("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:Gn("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:Gn("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:Gn("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:Gn("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:Gn("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:Gn("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:Gn("Rainbow","sequential","",[3367393,3516485,16383744,15501073,12526114]),"red-white-blue":Gn("Red-White-Blue","diverging","",[12526114,16777215,3367393])},FQ=Object.keys(Pc).map(e=>[e,Pc[e].label,Fg(Pc[e].type)]);function cp(e){return e in Pc?Pc[e]:(console.warn(`unknown color list named '${e}'`),Pc["red-yellow-blue"])}function $h(e){return{kind:"table-legend",table:e}}FQ.filter(e=>"diverging"===Pc[e[0]].type||"sequential"===Pc[e[0]].type),FQ.filter(e=>"qualitative"===Pc[e[0]].type);const NNe={domain:[0,1],reverse:!1,listOrName:"red-yellow-blue",minLabel:"",maxLabel:""};var Gu;!function(e){e.create=function t(n){const{domain:r,reverse:i,listOrName:o}={...NNe,...n},s="string"==typeof o?cp(o).list:o,a=i?s.slice().reverse():s,c=a.length-1;let u=0,l=0,d=0;function f(y,b){l=y,d=b,u=d-l||1}f(r[0],r[1]);const p=Ds(n.minLabel,l.toString()),m=Ds(n.maxLabel,d.toString());let h;if(a.every(y=>Array.isArray(y))){const y=[...a];y.sort((S,A)=>S[1]-A[1]);const b=y.map(S=>S[0]),x=je.ofSortedArray(y.map(S=>S[1])),_=b.length-1;h=S=>{const A=os((S-l)/u,0,1),E=je.findPredecessorIndex(x,A);if(0===E)return b[l];if(E>_)return b[_];const w=x[E-1],I=os((A-w)/(x[E]-w),0,1);return st.interpolate(b[E-1],b[E],I)}}else h=y=>{const b=Math.min(a.length-1,Math.max(0,(y-l)/u*c)),x=Math.floor(b),_=a[x],S=a[Math.ceil(b)];return st.interpolate(_,S,b-x)};return{color:h,colorToArray:(y,b,x)=>{st.toArray(h(y),b,x)},normalizedColorToArray:(y,b,x)=>{st.toArrayNormalized(h(y),b,x)},setDomain:f,get legend(){return function kNe(e,t,n){return{kind:"scale-legend",minLabel:e,maxLabel:t,colors:n}}(p,m,a)}}}}(Gu||(Gu={}));const BQ=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","VDF","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 Nr=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}(Nr||{});var vt=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}(vt||{});const BNe={[vt.Hexose]:Nr.FilledSphere,[vt.HexNAc]:Nr.FilledCube,[vt.Hexosamine]:Nr.CrossedCube,[vt.Hexuronate]:Nr.DividedDiamond,[vt.Deoxyhexose]:Nr.FilledCone,[vt.DeoxyhexNAc]:Nr.DevidedCone,[vt.DiDeoxyhexose]:Nr.FlatBox,[vt.Pentose]:Nr.FilledStar,[vt.Deoxynonulosonate]:Nr.FilledDiamond,[vt.DiDeoxynonulosonate]:Nr.FlatDiamond,[vt.Unknown]:Nr.FlatHexagon,[vt.Assigned]:Nr.Pentagon};function ONe(e,t){return e===vt.Unknown?4===t?Nr.DiamondPrism:5===t?Nr.PentagonalPrism:6===t?Nr.HexagonalPrism:7===t?Nr.HeptagonalPrism:Nr.FlatHexagon:BNe[e]}const TB={abbr:"Unk",name:"Unknown",color:15854817,type:vt.Unknown},Wb=[{abbr:"Glc",name:"Glucose",color:37052,type:vt.Hexose},{abbr:"Man",name:"Mannose",color:42577,type:vt.Hexose},{abbr:"Gal",name:"Galactose",color:16765952,type:vt.Hexose},{abbr:"Gul",name:"Gulose",color:16021792,type:vt.Hexose},{abbr:"Alt",name:"Altrose",color:16162465,type:vt.Hexose},{abbr:"All",name:"Allose",color:10830745,type:vt.Hexose},{abbr:"Tal",name:"Talose",color:9424105,type:vt.Hexose},{abbr:"Ido",name:"Idose",color:10582605,type:vt.Hexose},{abbr:"GlcNAc",name:"N-Acetyl Glucosamine",color:37052,type:vt.HexNAc},{abbr:"ManNAc",name:"N-Acetyl Mannosamine",color:42577,type:vt.HexNAc},{abbr:"GalNAc",name:"N-Acetyl Galactosamine",color:16765952,type:vt.HexNAc},{abbr:"GulNAc",name:"N-Acetyl Gulosamine",color:16021792,type:vt.HexNAc},{abbr:"AltNAc",name:"N-Acetyl Altrosamine",color:16162465,type:vt.HexNAc},{abbr:"AllNAc",name:"N-Acetyl Allosamine",color:10830745,type:vt.HexNAc},{abbr:"TalNAc",name:"N-Acetyl Talosamine",color:9424105,type:vt.HexNAc},{abbr:"IdoNAc",name:"N-Acetyl Idosamine",color:10582605,type:vt.HexNAc},{abbr:"GlcN",name:"Glucosamine",color:37052,type:vt.Hexosamine},{abbr:"ManN",name:"Mannosamine",color:42577,type:vt.Hexosamine},{abbr:"GalN",name:"Galactosamine",color:16765952,type:vt.Hexosamine},{abbr:"GulN",name:"Gulosamine",color:16021792,type:vt.Hexosamine},{abbr:"AltN",name:"Altrosamine",color:16162465,type:vt.Hexosamine},{abbr:"AllN",name:"Allosamine",color:10830745,type:vt.Hexosamine},{abbr:"TalN",name:"Talosamine",color:9424105,type:vt.Hexosamine},{abbr:"IdoN",name:"Idosamine",color:10582605,type:vt.Hexosamine},{abbr:"GlcA",name:"Glucuronic Acid",color:37052,type:vt.Hexuronate},{abbr:"ManA",name:"Mannuronic Acid",color:42577,type:vt.Hexuronate},{abbr:"GalA",name:"Galacturonic Acid",color:16765952,type:vt.Hexuronate},{abbr:"GulA",name:"Guluronic Acid",color:16021792,type:vt.Hexuronate},{abbr:"AltA",name:"Altruronic Acid",color:16162465,type:vt.Hexuronate},{abbr:"AllA",name:"Alluronic Acid",color:10830745,type:vt.Hexuronate},{abbr:"TalA",name:"Taluronic Acid",color:9424105,type:vt.Hexuronate},{abbr:"IdoA",name:"Iduronic Acid",color:10582605,type:vt.Hexuronate},{abbr:"Qui",name:"Quinovose",color:37052,type:vt.Deoxyhexose},{abbr:"Rha",name:"Rhamnose",color:42577,type:vt.Deoxyhexose},{abbr:"6dGul",name:"6-Deoxy Gulose",color:16021792,type:vt.Deoxyhexose},{abbr:"6dAlt",name:"6-Deoxy Altrose",color:16162465,type:vt.Deoxyhexose},{abbr:"6dTal",name:"6-Deoxy Talose",color:9424105,type:vt.Deoxyhexose},{abbr:"Fuc",name:"Fucose",color:15539236,type:vt.Deoxyhexose},{abbr:"QuiNAc",name:"N-Acetyl Quinovosamine",color:37052,type:vt.DeoxyhexNAc},{abbr:"RhaNAc",name:"N-Acetyl Rhamnosamine",color:42577,type:vt.DeoxyhexNAc},{abbr:"6dAltNAc",name:"N-Acetyl 6-Deoxy Altrosamine",color:16162465,type:vt.DeoxyhexNAc},{abbr:"6dTalNAc",name:"N-Acetyl 6-Deoxy Talosamine",color:9424105,type:vt.DeoxyhexNAc},{abbr:"FucNAc",name:"N-Acetyl Fucosamine",color:15539236,type:vt.DeoxyhexNAc},{abbr:"Oli",name:"Olivose",color:37052,type:vt.DiDeoxyhexose},{abbr:"Tyv",name:"Tyvelose",color:42577,type:vt.DiDeoxyhexose},{abbr:"Abe",name:"Abequose",color:16021792,type:vt.DiDeoxyhexose},{abbr:"Par",name:"Paratose",color:16162465,type:vt.DiDeoxyhexose},{abbr:"Dig",name:"Digitoxose",color:10830745,type:vt.DiDeoxyhexose},{abbr:"Col",name:"Colitose",color:9424105,type:vt.DiDeoxyhexose},{abbr:"Ara",name:"Arabinose",color:42577,type:vt.Pentose},{abbr:"Lyx",name:"Lyxose",color:16765952,type:vt.Pentose},{abbr:"Xyl",name:"Xylose",color:16021792,type:vt.Pentose},{abbr:"Rib",name:"Ribose",color:16162465,type:vt.Pentose},{abbr:"Kdn",name:"Keto-Deoxy Nonulonic Acid",color:42577,type:vt.Deoxynonulosonate},{abbr:"Neu5Ac",name:"N-Acetyl Neuraminic Acid",color:10830745,type:vt.Deoxynonulosonate},{abbr:"Neu5Gc",name:"N-Glycolyl Neuraminic Acid",color:9424105,type:vt.Deoxynonulosonate},{abbr:"Neu",name:"Neuraminic Acid",color:10582605,type:vt.Deoxynonulosonate},{abbr:"Sia",name:"Sialic acid",color:15539236,type:vt.Deoxynonulosonate},{abbr:"Pse",name:"Pseudaminic Acid",color:42577,type:vt.DiDeoxynonulosonate},{abbr:"Leg",name:"Legionaminic Acid",color:16765952,type:vt.DiDeoxynonulosonate},{abbr:"Aci",name:"Acinetaminic Acid",color:16162465,type:vt.DiDeoxynonulosonate},{abbr:"4eLeg",name:"4-Epilegionaminic Acid",color:9424105,type:vt.DiDeoxynonulosonate},{abbr:"Bac",name:"Bacillosamine",color:37052,type:vt.Unknown},{abbr:"LDmanHep",name:"L-Glycero-D-Manno Heptose",color:42577,type:vt.Unknown},{abbr:"Kdo",name:"Keto-Deoxy Octulonic Acid",color:16765952,type:vt.Unknown},{abbr:"Dha",name:"3-Deoxy Lyxo-Heptulosaric Acid",color:16021792,type:vt.Unknown},{abbr:"DDmanHep",name:"D-Glycero-D-Manno-Heptose",color:16162465,type:vt.Unknown},{abbr:"MurNAc",name:"N-Acetyl Muramic Acid",color:10830745,type:vt.Unknown},{abbr:"MurNGc",name:"N-Glycolyl Muramic Acid",color:9424105,type:vt.Unknown},{abbr:"Mur",name:"Muramic Acid",color:10582605,type:vt.Unknown},{abbr:"Api",name:"Apicose",color:42577,type:vt.Assigned},{abbr:"Fru",name:"Fructose",color:42577,type:vt.Assigned},{abbr:"Tag",name:"Tagatose",color:16765952,type:vt.Assigned},{abbr:"Sor",name:"Sorbose",color:16021792,type:vt.Assigned},{abbr:"Psi",name:"Psicose",color:16162465,type:vt.Assigned}],LNe=function(){const e=new Map;for(let t=0,n=Wb.length;t{e.has(t)||e.set(t,TB)}),e}(),zNe=function(){const e=new Map;for(let t=0,n=Wb.length;t{e.has(t)||e.set(t,TB)}),e}();let up=UQ;var Si;!function(e){e.toArray=function t(p){return Array.from(p.values())},e.isSuperset=function n(p,m){if(p.size[e[0],Bg(e[1])])),WNe={0:{trace:new Set,directionFrom:new Set,directionTo:new Set,backboneStart:new Set,backboneEnd:new Set,coarseBackbone:new Set},1:{trace:new Set(["CA"]),directionFrom:new Set(["C"]),directionTo:new Set(["O","OC1","O1","OX1","OXT","OT1"]),backboneStart:new Set(["N"]),backboneEnd:new Set(["C"]),coarseBackbone:new Set(["CA","BB","CA1"])},2:{trace:new Set(["CA"]),directionFrom:new Set(["C"]),directionTo:new Set(["O"]),backboneStart:new Set(["N"]),backboneEnd:new Set(["CD"]),coarseBackbone:new Set(["CA"])},3:{trace:new Set(["CA"]),directionFrom:new Set(["C"]),directionTo:new Set(["O"]),backboneStart:new Set(["N"]),backboneEnd:new Set(["CG"]),coarseBackbone:new Set(["CA"])},4:{trace:new Set(["O3'","O3*"]),directionFrom:new Set(["C4'","C4*"]),directionTo:new Set(["C3'","C3*"]),backboneStart:new Set(["P"]),backboneEnd:new Set(["O3'","O3*"]),coarseBackbone:new Set(["P"])},5:{trace:new Set(["O3'","O3*"]),directionFrom:new Set(["C3'","C3*"]),directionTo:new Set(["C1'","C1*"]),backboneStart:new Set(["P"]),backboneEnd:new Set(["O3'","O3*"]),coarseBackbone:new Set(["P"])},6:{trace:new Set(["N4'","N4*"]),directionFrom:new Set(["N4'","N4*"]),directionTo:new Set(["C7'","C7*"]),backboneStart:new Set(["N1'","N1*"]),backboneEnd:new Set(["C'","C*"]),coarseBackbone:new Set(["P"])}},lp=new Set(["CA","C","N","O","O1","O2","OC1","OC2","OT1","OT2","OX1","OXT","H","H1","H2","H3","HA","HN","HXT","BB"]),ZI=new Set(["P","OP1","OP2","HOP2","HOP3","O2'","O3'","O4'","O5'","C1'","C2'","C3'","C4'","C5'","H1'","H2'","H2''","HO2'","H3'","H4'","H5'","H5''","HO3'","HO5'","O2*","O3*","O4*","O5*","C1*","C2*","C3*","C4*","C5*"]),jQ=new Set(["d-peptide linking","d-peptide nh3 amino terminus","d-peptide cooh carboxy terminus","d-gamma-peptide, c-delta linking","d-beta-peptide, c-gamma linking"]),HQ=new Set(["l-peptide linking","l-peptide nh3 amino terminus","l-peptide cooh carboxy terminus","l-gamma-peptide, c-delta linking","l-beta-peptide, c-gamma linking"]),$Ne=new Set(["d-gamma-peptide, c-delta linking","l-gamma-peptide, c-delta linking"]),YNe=new Set(["d-beta-peptide, c-gamma linking","l-beta-peptide, c-gamma linking"]),XNe=new Set(["d-peptide nh3 amino terminus","d-peptide cooh carboxy terminus","l-peptide nh3 amino terminus","l-peptide cooh carboxy terminus"]),qQ=new Set(["peptide linking","peptide-like"]),KNe=Si.unionMany(jQ,HQ,qQ),WQ=new Set(["dna linking","l-dna linking","dna oh 5 prime terminus","dna oh 3 prime terminus"]),$Q=new Set(["rna linking","l-rna linking","rna oh 5 prime terminus","rna oh 3 prime terminus"]),YQ=Si.unionMany(new Set(["d-saccharide, beta linking","l-saccharide, beta linking","d-saccharide, alpha linking","l-saccharide, alpha linking","l-saccharide","d-saccharide","saccharide"]),new Set(["d-saccharide 1,4 and 1,4 linking","l-saccharide 1,4 and 1,4 linking","d-saccharide 1,4 and 1,6 linking","l-saccharide 1,4 and 1,6 linking"])),ZNe=new Set(["non-polymer","other"]),QNe=new Set(["ion"]),JNe=new Set(["lipid"]),QI=new Set(["SOL","WAT","HOH","H2O","W","DOD","D3O","TIP","TIP3","TIP4","SPC"]),DB=new Set(["HIS","ARG","LYS","ILE","PHE","LEU","TRP","ALA","MET","PRO","CYS","ASN","VAL","GLY","SER","GLN","TYR","ASP","GLU","THR","SEC","PYL","UNK","MSE","SEP","TPO","PTR","PCA","HYP","HSD","HSE","HSP","LSN","ASPP","GLUP","HID","HIE","HIP","LYN","ASH","GLH"]),XQ=new Set(["DAL","DAR","DSG","DAS","DCY","DGL","DGN","DHI","DIL","DLE","DLY","MED","DPN","DPR","DSN","DTH","DTR","DTY","DVA","DNE"]),a2=Si.unionMany(DB,XQ),eFe=new Set(["NME","ACE","NH2","FOR","FMT"]),c2=new Set(["A","C","T","G","I","U","N"]),u2=new Set(["DA","DC","DT","DG","DI","DU","DN"]),EB=new Set(["APN","CPN","TPN","GPN"]),tFe=new Set(["A","G","I","DA","DG","DI","APN","GPN"]),nFe=new Set(["C","T","U","DC","DT","DU","CPN","TPN"]),JI=Si.unionMany(c2,u2,EB),rFe=e=>tFe.has(e.toUpperCase()),iFe=e=>nFe.has(e.toUpperCase()),$b=Si.unionMany(a2,JI);function Yh(e,t){return t=t.toUpperCase(),EB.has(t)?8:KNe.has(e)?5:$Q.has(e)?6:WQ.has(e)?7:YQ.has(e)?9:QI.has(t)?2:zQ.has(t)?3:VQ.has(t)?4:ZNe.has(e)?up.has(t)?9:a2.has(t)?5:c2.has(t)?6:u2.has(t)?7:1:0}function oFe(e,t){return 5===t?$Ne.has(e)?2:YNe.has(e)?3:XNe.has(e)?0:1:6===t?4:7===t?5:8===t?6:0}function KQ(e){return e=e.toUpperCase(),a2.has(e)?"peptide linking":c2.has(e)?"rna linking":u2.has(e)?"dna linking":up.has(e)?"saccharide":"other"}function aFe(e){return e=e.toUpperCase(),QI.has(e)?"water":$b.has(e)?"polymer":up.has(e)?"branched":"non-polymer"}function cFe(e,t){return e=e.toUpperCase(),HQ.has(t)?"polypeptide(L)":jQ.has(t)?"polypeptide(D)":$Q.has(t)?"polyribonucleotide":WQ.has(t)?"polydeoxyribonucleotide":YQ.has(t)||up.has(e)?"oligosaccharide":EB.has(e)?"peptide nucleic acid":DB.has(e)?"polypeptide(L)":XQ.has(e)?"polypeptide(D)":c2.has(e)?"polyribonucleotide":u2.has(e)?"polydeoxyribonucleotide":QNe.has(t)||zQ.has(e)?"ion":JNe.has(t)||VQ.has(e)?"lipid":qQ.has(t)?"peptide-like":"other"}function eT(e){return Ya(e)||ZQ(e)}function Ya(e){return 7===e||6===e||8===e}function ZQ(e){return 5===e}var cr,jn;!function(e){e.is=ea.has,e.create=ea.create,e.SecondaryStructureMmcif={helx_lh_27_p:1058,helx_lh_3t_p:2082,helx_lh_al_p:4130,helx_lh_a_n:524321,helx_lh_b_n:1048609,helx_lh_ga_p:8226,helx_lh_n:33,helx_lh_om_p:16418,helx_lh_ot_n:131105,helx_lh_ot_p:546,helx_lh_p:34,helx_lh_pi_p:32802,helx_lh_pp_p:65570,helx_lh_z_n:262177,helx_n:1,helx_ot_n:1,helx_ot_p:2,helx_p:2,helx_rh_27_p:1090,helx_rh_3t_p:2114,helx_rh_al_p:4162,helx_rh_a_n:524353,helx_rh_b_n:1048641,helx_rh_ga_p:8258,helx_rh_n:65,helx_rh_om_p:16450,helx_rh_ot_n:131137,helx_rh_ot_p:578,helx_rh_p:66,helx_rh_pi_p:32834,helx_rh_pp_p:65602,helx_rh_z_n:262209,strn:4194308,turn_ot_p:33554448,turn_p:16,turn_ty1p_p:67109136,turn_ty1_p:67109008,turn_ty2p_p:134218e3,turn_ty2_p:134217872,turn_ty3p_p:268435728,turn_ty3_p:268435600,bend:8,other:0},e.SecondaryStructurePdb={1:4162,2:16450,3:32834,4:8258,5:2114,6:4130,7:16418,8:8226,9:1026,10:65538},e.SecondaryStructureStride={H:4098,G:2050,I:32770,E:8388612,B:4194308,T:16,C:536870912},e.SecondaryStructureDssp={H:4098,B:4194308,E:8388612,G:2050,I:32770,T:16,S:8}}(cr||(cr={})),function(e){function o(a){switch(a){case"covalent":return 1;case"metal-coordination":return 2;case"hydrogen-bond":return 4;case"disulfide":return 8;case"aromatic":return 16;case"computed":return 32}}e.is=ea.has,e.create=function t(a){return ea.create(a)},e.isCovalent=function n(a){return!!(1&a)},e.isAll=function r(a){return a===Math.pow(2,6)-1},e.Names={covalent:1,"metal-coordination":2,"hydrogen-bond":4,disulfide:8,aromatic:16,computed:32},e.isName=function i(a){return a in e.Names},e.fromName=o,e.fromNames=function s(a){let c=0;for(let u=0,l=a.length;uthis.radiusSq&&(this.radiusSq=n)}radiusSphereStep(t,n){const r=dFe(t,this.center)+n,i=r*r;i>this.radiusSq&&(this.radiusSq=i)}getSphere(t){return t||(t=_e()),v.copy(t.center,this.center),t.radius=Math.sqrt(this.radiusSq),t}getCount(){return this.count}constructor(){this.count=0,this.center=v(),this.radiusSq=0}}!function(e){const t=new e,n=v(),r=v();e.fromArrays=function i({x:a,y:c,z:u},l){t.reset();const d=a.length;for(let f=0;f{s.forEach(a=>{n+=a.edgeCount,a.connectedIndices.forEach(c=>{a.getEdges(c).forEach(u=>{const{unitA:l,unitB:d}=a,f=ju.getEdgeKey(c,l,u.indexB,d);i.set(f,r.length);const p=ju.getVertexKey(c,l),m=o.get(p);void 0===m?o.set(p,[r.length]):m.push(r.length),r.push({...u,indexA:c,unitA:l,unitB:d})})})})}),this.edgeCount=n,this.edges=r,this.edgeKeyIndex=i,this.vertexKeyIndex=o}}!function(e){class t{hasEdges(a){return this.edgeMap.has(a)}getEdges(a){return this.edgeMap.has(a)?this.edgeMap.get(a):QQ}get areUnitsOrdered(){return this.unitA0?i:t<0?n:(n+r)/1.95}const gFe=RB.H;function dp(e){return e===gFe}const yFe=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 bFe(e,t,n){return[t,n]=tn&&([e,n]=[n,e],[t,r]=[r,t]),vFe.get(`${e}|${t}|${n}|${r}`)||1}var fp=te.Schema;const re=fp.str,Ie=fp.int,_n=fp.float,kB=fp.coord,Tt=fp.Aliased,Kh=fp.Matrix,nT=fp.Vector,xr=fp.lstr,Lg=fp.List,On={atom_site:{auth_asym_id:re,auth_atom_id:re,auth_comp_id:re,auth_seq_id:Ie,B_iso_or_equiv:_n,Cartn_x:kB,Cartn_y:kB,Cartn_z:kB,group_PDB:Tt(re),id:Ie,label_alt_id:re,label_asym_id:re,label_atom_id:re,label_comp_id:re,label_entity_id:re,label_seq_id:Ie,occupancy:_n,type_symbol:re,pdbx_PDB_ins_code:re,pdbx_PDB_model_num:Ie,pdbx_formal_charge:Ie,pdbx_label_index:Ie,pdbx_sifts_xref_db_name:re,pdbx_sifts_xref_db_acc:re,pdbx_sifts_xref_db_num:re,pdbx_sifts_xref_db_res:re,ihm_model_id:Ie},atom_site_anisotrop:{id:Ie,type_symbol:re,U:Kh(3,3),U_esd:Kh(3,3),pdbx_auth_seq_id:re,pdbx_auth_asym_id:re,pdbx_auth_atom_id:re,pdbx_auth_comp_id:re,pdbx_label_seq_id:Ie,pdbx_label_alt_id:re,pdbx_label_asym_id:re,pdbx_label_atom_id:re,pdbx_label_comp_id:re,pdbx_PDB_ins_code:re},atom_sites:{entry_id:re,fract_transf_matrix:Kh(3,3),fract_transf_vector:nT(3)},audit_author:{name:re,pdbx_ordinal:Ie,identifier_ORCID:re},audit_conform:{dict_location:re,dict_name:re,dict_version:re},cell:{angle_alpha:_n,angle_beta:_n,angle_gamma:_n,entry_id:re,length_a:_n,length_b:_n,length_c:_n,Z_PDB:Ie,pdbx_unique_axis:re},chem_comp:{formula:re,formula_weight:_n,id:re,mon_nstd_flag:Tt(xr),name:re,type:Tt(xr),pdbx_synonyms:Lg(";",e=>e)},chem_comp_bond:{atom_id_1:re,atom_id_2:re,comp_id:re,value_order:Tt(xr),pdbx_ordinal:Ie,pdbx_stereo_config:Tt(xr),pdbx_aromatic_flag:Tt(xr)},citation:{book_publisher:re,country:re,id:re,journal_abbrev:re,journal_id_ASTM:re,journal_id_CSD:re,journal_id_ISSN:re,journal_volume:re,page_first:re,page_last:re,title:re,year:Ie,pdbx_database_id_DOI:re,pdbx_database_id_PubMed:Ie},citation_author:{citation_id:re,name:re,ordinal:Ie},database_2:{database_id:Tt(xr),database_code:re},entity:{details:re,formula_weight:_n,id:re,src_method:Tt(xr),type:Tt(xr),pdbx_description:Lg(",",e=>e),pdbx_number_of_molecules:Ie,pdbx_mutation:re,pdbx_fragment:re,pdbx_ec:Lg(",",e=>e)},entity_poly:{entity_id:re,nstd_linkage:Tt(xr),nstd_monomer:Tt(xr),type:Tt(re),pdbx_strand_id:Lg(",",e=>e),pdbx_seq_one_letter_code:re,pdbx_seq_one_letter_code_can:re,pdbx_target_identifier:re},entity_poly_seq:{entity_id:re,hetero:Tt(xr),mon_id:re,num:Ie},entry:{id:re},exptl:{entry_id:re,method:Tt(re)},software:{classification:re,date:re,description:re,name:re,type:Tt(xr),version:re,pdbx_ordinal:Ie},struct:{entry_id:re,title:re,pdbx_descriptor:re},struct_asym:{details:re,entity_id:re,id:re,pdbx_modified:re,pdbx_blank_PDB_chainid_flag:Tt(re)},struct_conf:{beg_label_asym_id:re,beg_label_comp_id:re,beg_label_seq_id:Ie,beg_auth_asym_id:re,beg_auth_comp_id:re,beg_auth_seq_id:Ie,conf_type_id:Tt(xr),details:re,end_label_asym_id:re,end_label_comp_id:re,end_label_seq_id:Ie,end_auth_asym_id:re,end_auth_comp_id:re,end_auth_seq_id:Ie,id:re,pdbx_beg_PDB_ins_code:re,pdbx_end_PDB_ins_code:re,pdbx_PDB_helix_class:re,pdbx_PDB_helix_length:Ie,pdbx_PDB_helix_id:re},struct_conn:{conn_type_id:Tt(xr),details:re,id:re,ptnr1_label_asym_id:re,ptnr1_label_atom_id:re,ptnr1_label_comp_id:re,ptnr1_label_seq_id:Ie,ptnr1_auth_asym_id:re,ptnr1_auth_comp_id:re,ptnr1_auth_seq_id:Ie,ptnr1_symmetry:re,ptnr2_label_asym_id:re,ptnr2_label_atom_id:re,ptnr2_label_comp_id:re,ptnr2_label_seq_id:Ie,ptnr2_auth_asym_id:re,ptnr2_auth_comp_id:re,ptnr2_auth_seq_id:Ie,ptnr2_symmetry:re,pdbx_ptnr1_PDB_ins_code:re,pdbx_ptnr1_label_alt_id:re,pdbx_ptnr1_standard_comp_id:re,pdbx_ptnr2_PDB_ins_code:re,pdbx_ptnr2_label_alt_id:re,pdbx_ptnr3_PDB_ins_code:re,pdbx_ptnr3_label_alt_id:re,pdbx_ptnr3_label_asym_id:re,pdbx_ptnr3_label_atom_id:re,pdbx_ptnr3_label_comp_id:re,pdbx_ptnr3_label_seq_id:Ie,pdbx_PDB_id:re,pdbx_dist_value:_n,pdbx_value_order:Tt(xr)},struct_conn_type:{criteria:re,id:Tt(xr),reference:re},struct_keywords:{entry_id:re,text:Lg(",",e=>e),pdbx_keywords:re},struct_ncs_oper:{code:Tt(re),details:re,id:Ie,matrix:Kh(3,3),vector:nT(3)},struct_sheet_range:{beg_label_asym_id:re,beg_label_comp_id:re,beg_label_seq_id:Ie,end_label_asym_id:re,end_label_comp_id:re,end_label_seq_id:Ie,beg_auth_asym_id:re,beg_auth_comp_id:re,beg_auth_seq_id:Ie,end_auth_asym_id:re,end_auth_comp_id:re,end_auth_seq_id:Ie,id:re,sheet_id:re,pdbx_beg_PDB_ins_code:re,pdbx_end_PDB_ins_code:re},struct_site:{details:re,id:re,pdbx_num_residues:Ie,pdbx_evidence_code:re,pdbx_auth_asym_id:re,pdbx_auth_comp_id:re,pdbx_auth_seq_id:re,pdbx_auth_ins_code:re},struct_site_gen:{details:re,id:re,label_alt_id:re,label_asym_id:re,label_atom_id:re,label_comp_id:re,label_seq_id:Ie,auth_asym_id:re,auth_comp_id:re,auth_seq_id:re,site_id:re,symmetry:re,pdbx_auth_ins_code:re,pdbx_num_res:Ie},symmetry:{entry_id:re,cell_setting:Tt(xr),Int_Tables_number:Ie,space_group_name_Hall:re,"space_group_name_H-M":re},pdbx_database_status:{status_code:Tt(re),status_code_sf:Tt(re),status_code_mr:Tt(re),entry_id:re,recvd_initial_deposition_date:re,SG_entry:Tt(xr),deposit_site:Tt(re),process_site:Tt(re),status_code_cs:Tt(re),methods_development_category:Tt(re),pdb_format_compatible:Tt(xr)},pdbx_nonpoly_scheme:{asym_id:re,entity_id:re,mon_id:re,pdb_strand_id:re,ndb_seq_num:re,pdb_seq_num:re,auth_seq_num:re,pdb_mon_id:re,auth_mon_id:re,pdb_ins_code:re},pdbx_database_related:{db_name:re,details:re,db_id:re,content_type:Tt(re)},pdbx_entity_nonpoly:{entity_id:re,comp_id:re,name:re},pdbx_chem_comp_synonyms:{name:re,comp_id:re,provenance:Tt(re)},pdbx_chem_comp_identifier:{comp_id:re,identifier:re,type:Tt(re),program:re,program_version:re},pdbx_unobs_or_zero_occ_residues:{id:Ie,polymer_flag:Tt(xr),occupancy_flag:Tt(Ie),PDB_model_num:Ie,auth_asym_id:re,auth_comp_id:re,auth_seq_id:re,PDB_ins_code:re,label_asym_id:re,label_comp_id:re,label_seq_id:Ie},pdbx_struct_mod_residue:{id:Ie,auth_asym_id:re,auth_comp_id:re,auth_seq_id:Ie,PDB_ins_code:re,label_asym_id:re,label_comp_id:re,label_seq_id:Ie,parent_comp_id:re,details:re},pdbx_struct_oper_list:{id:re,type:Tt(re),name:re,symmetry_operation:re,matrix:Kh(3,3),vector:nT(3)},pdbx_struct_assembly:{method_details:re,oligomeric_details:re,oligomeric_count:Ie,details:re,id:re},pdbx_struct_assembly_gen:{asym_id_list:Lg(",",e=>e),assembly_id:re,oper_expression:re},pdbx_reference_entity_list:{prd_id:re,ref_entity_id:re,type:Tt(xr),details:re,component_id:Ie},pdbx_reference_entity_link:{link_id:Ie,prd_id:re,details:re,ref_entity_id_1:re,ref_entity_id_2:re,entity_seq_num_1:Ie,entity_seq_num_2:Ie,comp_id_1:re,comp_id_2:re,atom_id_1:re,atom_id_2:re,value_order:Tt(xr),component_1:Ie,component_2:Ie,link_class:Tt(re)},pdbx_reference_entity_poly_link:{link_id:Ie,prd_id:re,ref_entity_id:re,component_id:Ie,entity_seq_num_1:Ie,entity_seq_num_2:Ie,comp_id_1:re,comp_id_2:re,atom_id_1:re,atom_id_2:re,value_order:Tt(xr)},pdbx_molecule:{prd_id:re,instance_id:Ie,asym_id:re},pdbx_molecule_features:{prd_id:re,class:Tt(xr),type:Tt(xr),name:re,details:re},entity_src_nat:{entity_id:re,pdbx_organism_scientific:re,pdbx_plasmid_name:re,pdbx_src_id:Ie,pdbx_beg_seq_num:Ie,pdbx_end_seq_num:Ie},entity_src_gen:{entity_id:re,pdbx_gene_src_gene:Lg(",",e=>e),pdbx_gene_src_scientific_name:re,plasmid_name:re,pdbx_src_id:Ie,pdbx_beg_seq_num:Ie,pdbx_end_seq_num:Ie},pdbx_entity_src_syn:{organism_scientific:re,entity_id:re,pdbx_src_id:Ie,pdbx_beg_seq_num:Ie,pdbx_end_seq_num:Ie},pdbx_entity_branch_descriptor:{entity_id:re,descriptor:re,type:Tt(xr),program:re,program_version:re,ordinal:Ie},pdbx_entity_instance_feature:{details:re,feature_type:Tt(re),auth_asym_id:re,asym_id:re,auth_seq_num:re,seq_num:Ie,comp_id:re,auth_comp_id:re,ordinal:Ie},pdbx_entity_branch_list:{entity_id:re,hetero:Tt(xr),comp_id:re,num:Ie},pdbx_entity_branch_link:{link_id:Ie,details:re,entity_id:re,entity_branch_list_num_1:Ie,entity_branch_list_num_2:Ie,comp_id_1:re,comp_id_2:re,atom_id_1:re,leaving_atom_id_1:re,atom_stereo_config_1:Tt(xr),atom_id_2:re,leaving_atom_id_2:re,atom_stereo_config_2:Tt(xr),value_order:Tt(xr)},pdbx_entity_branch:{entity_id:re,type:Tt(re)},pdbx_branch_scheme:{entity_id:re,hetero:Tt(xr),asym_id:re,mon_id:re,num:Ie,pdb_asym_id:re,pdb_seq_num:re,pdb_mon_id:re,auth_asym_id:re,auth_seq_num:re,auth_mon_id:re},pdbx_chem_comp_related:{comp_id:re,related_comp_id:re,relationship_type:Tt(re),details:re},ihm_starting_model_details:{starting_model_id:re,entity_id:re,entity_description:re,asym_id:re,entity_poly_segment_id:Ie,starting_model_source:Tt(re),starting_model_auth_asym_id:re,starting_model_sequence_offset:Ie,dataset_list_id:Ie},ihm_starting_comparative_models:{id:Ie,starting_model_id:re,starting_model_auth_asym_id:re,starting_model_seq_id_begin:Ie,starting_model_seq_id_end:Ie,template_auth_asym_id:re,template_seq_id_begin:Ie,template_seq_id_end:Ie,template_sequence_identity:_n,template_sequence_identity_denominator:Tt(Ie),template_dataset_list_id:Ie,alignment_file_id:Ie},ihm_starting_model_seq_dif:{id:Ie,entity_id:re,asym_id:re,seq_id:Ie,comp_id:re,starting_model_id:re,db_asym_id:re,db_seq_id:Ie,db_comp_id:re,details:re},ihm_model_representation:{id:Ie,name:re,details:re},ihm_model_representation_details:{id:Ie,representation_id:Ie,entity_poly_segment_id:Ie,entity_id:re,entity_description:re,entity_asym_id:re,model_object_primitive:Tt(re),starting_model_id:re,model_mode:Tt(re),model_granularity:Tt(re),model_object_count:Ie},ihm_struct_assembly_details:{id:Ie,assembly_id:Ie,parent_assembly_id:Ie,entity_description:re,entity_id:re,asym_id:re,entity_poly_segment_id:Ie},ihm_struct_assembly:{id:Ie,name:re,description:re},ihm_modeling_protocol:{id:Ie,num_steps:Ie,protocol_name:re},ihm_modeling_protocol_details:{id:Ie,protocol_id:Ie,step_id:Ie,struct_assembly_id:Ie,dataset_group_id:Ie,struct_assembly_description:re,step_name:re,step_method:re,num_models_begin:Ie,num_models_end:Ie,multi_scale_flag:Tt(xr),multi_state_flag:Tt(xr),ordered_flag:Tt(xr),script_file_id:Ie,software_id:Ie},ihm_multi_state_modeling:{state_id:Ie,state_group_id:Ie,population_fraction:_n,population_fraction_sd:_n,state_type:re,state_name:re,experiment_type:Tt(re),details:re},ihm_modeling_post_process:{id:Ie,protocol_id:Ie,analysis_id:Ie,step_id:Ie,type:Tt(re),feature:Tt(re),num_models_begin:Ie,num_models_end:Ie},ihm_ensemble_info:{ensemble_id:Ie,ensemble_name:re,post_process_id:Ie,model_group_id:Ie,ensemble_clustering_method:Tt(re),ensemble_clustering_feature:Tt(re),num_ensemble_models:Ie,num_ensemble_models_deposited:Ie,ensemble_precision_value:_n,ensemble_file_id:Ie},ihm_model_list:{model_id:Ie,model_name:re,assembly_id:Ie,protocol_id:Ie,representation_id:Ie},ihm_model_group:{id:Ie,name:re,details:re},ihm_model_group_link:{model_id:Ie,group_id:Ie},ihm_model_representative:{id:Ie,model_group_id:Ie,model_id:Ie,selection_criteria:Tt(re)},ihm_dataset_list:{id:Ie,data_type:Tt(re),database_hosted:Tt(xr)},ihm_dataset_group:{id:Ie,name:re,application:Tt(re),details:re},ihm_dataset_group_link:{dataset_list_id:Ie,group_id:Ie},ihm_related_datasets:{dataset_list_id_derived:Ie,dataset_list_id_primary:Ie},ihm_dataset_related_db_reference:{id:Ie,dataset_list_id:Ie,db_name:Tt(re),accession_code:re,version:re,details:re},ihm_external_reference_info:{reference_id:Ie,reference_provider:re,reference_type:Tt(re),reference:re,refers_to:Tt(re),associated_url:re},ihm_external_files:{id:Ie,reference_id:Ie,file_path:re,content_type:Tt(re),file_size_bytes:_n,details:re},ihm_dataset_external_reference:{id:Ie,dataset_list_id:Ie,file_id:Ie},ihm_localization_density_files:{id:Ie,file_id:Ie,ensemble_id:Ie,entity_id:re,entity_poly_segment_id:Ie,asym_id:re},ihm_predicted_contact_restraint:{id:Ie,group_id:Ie,entity_id_1:re,entity_id_2:re,asym_id_1:re,asym_id_2:re,comp_id_1:re,comp_id_2:re,seq_id_1:Ie,seq_id_2:Ie,rep_atom_1:Tt(re),rep_atom_2:Tt(re),distance_lower_limit:_n,distance_upper_limit:_n,probability:_n,restraint_type:Tt(re),model_granularity:Tt(re),dataset_list_id:Ie,software_id:Ie},ihm_cross_link_list:{id:Ie,group_id:Ie,entity_description_1:re,entity_description_2:re,entity_id_1:re,entity_id_2:re,comp_id_1:re,comp_id_2:re,seq_id_1:Ie,seq_id_2:Ie,linker_type:Tt(re),dataset_list_id:Ie},ihm_cross_link_restraint:{id:Ie,group_id:Ie,entity_id_1:re,entity_id_2:re,asym_id_1:re,asym_id_2:re,comp_id_1:re,comp_id_2:re,seq_id_1:Ie,seq_id_2:Ie,atom_id_1:re,atom_id_2:re,restraint_type:Tt(re),conditional_crosslink_flag:Tt(re),model_granularity:Tt(re),distance_threshold:_n,psi:_n,sigma_1:_n,sigma_2:_n},ihm_cross_link_result_parameters:{id:Ie,restraint_id:Ie,model_id:Ie,psi:_n,sigma_1:_n,sigma_2:_n},ihm_2dem_class_average_restraint:{id:Ie,dataset_list_id:Ie,number_raw_micrographs:Ie,pixel_size_width:_n,pixel_size_height:_n,image_resolution:_n,image_segment_flag:Tt(xr),number_of_projections:Ie,struct_assembly_id:Ie,details:re},ihm_2dem_class_average_fitting:{id:Ie,restraint_id:Ie,model_id:Ie,cross_correlation_coefficient:_n,rot_matrix:Kh(3,3),tr_vector:nT(3)},ihm_3dem_restraint:{id:Ie,dataset_list_id:Ie,model_id:Ie,struct_assembly_id:Ie,fitting_method:re,number_of_gaussians:Ie,cross_correlation_coefficient:_n},ihm_sas_restraint:{id:Ie,dataset_list_id:Ie,model_id:Ie,struct_assembly_id:Ie,profile_segment_flag:Tt(xr),fitting_atom_type:re,fitting_method:re,fitting_state:Tt(re),radius_of_gyration:_n,chi_value:_n,details:re},ihm_starting_model_coord:{ordinal_id:Ie,starting_model_id:re,group_PDB:Tt(re),id:Ie,type_symbol:re,entity_id:re,atom_id:re,comp_id:re,seq_id:Ie,asym_id:re,Cartn_x:_n,Cartn_y:_n,Cartn_z:_n,B_iso_or_equiv:_n},ihm_sphere_obj_site:{id:Ie,entity_id:re,seq_id_begin:Ie,seq_id_end:Ie,asym_id:re,Cartn_x:_n,Cartn_y:_n,Cartn_z:_n,object_radius:_n,rmsf:_n,model_id:Ie},ihm_gaussian_obj_site:{id:Ie,entity_id:re,seq_id_begin:Ie,seq_id_end:Ie,asym_id:re,mean_Cartn_x:_n,mean_Cartn_y:_n,mean_Cartn_z:_n,weight:_n,covariance_matrix:Kh(3,3),model_id:Ie},ihm_gaussian_obj_ensemble:{id:Ie,entity_id:re,seq_id_begin:Ie,seq_id_end:Ie,asym_id:re,mean_Cartn_x:_n,mean_Cartn_y:_n,mean_Cartn_z:_n,weight:_n,covariance_matrix:Kh(3,3),ensemble_id:Ie},ihm_feature_list:{feature_id:Ie,feature_type:Tt(re),entity_type:Tt(re)},ihm_poly_residue_feature:{ordinal_id:Ie,feature_id:Ie,entity_id:re,asym_id:re,comp_id_begin:re,comp_id_end:re,seq_id_begin:Ie,seq_id_end:Ie},ihm_derived_distance_restraint:{id:Ie,group_id:Ie,feature_id_1:Ie,feature_id_2:Ie,group_conditionality:Tt(re),random_exclusion_fraction:_n,distance_upper_limit:_n,restraint_type:Tt(re),dataset_list_id:Ie},ma_model_list:{ordinal_id:Ie,model_id:Ie,model_group_id:Ie,model_name:re,model_group_name:re,model_type:Tt(re),data_id:Ie},ma_target_entity:{entity_id:re,data_id:Ie,origin:Tt(re)},ma_target_entity_instance:{asym_id:re,entity_id:re,details:re},ma_target_ref_db_details:{target_entity_id:re,db_name:Tt(re),db_code:re,db_accession:re,seq_db_isoform:re,seq_db_align_begin:re,seq_db_align_end:re,ncbi_taxonomy_id:re,organism_scientific:re},ma_data:{id:Ie,content_type:Tt(re),content_type_other_details:re,name:re},ma_software_group:{ordinal_id:Ie,group_id:Ie,software_id:Ie},ma_qa_metric:{id:Ie,name:re,type:Tt(re),mode:Tt(re),software_group_id:Ie},ma_qa_metric_global:{ordinal_id:Ie,model_id:Ie,metric_id:Ie,metric_value:_n},ma_qa_metric_local:{ordinal_id:Ie,model_id:Ie,label_asym_id:re,label_seq_id:Ie,label_comp_id:re,metric_id:Ie,metric_value:_n}};var Jn;!function(e){let t;var o;let n;(o=t=e.IntDataType||(e.IntDataType={}))[o.Int8=1]="Int8",o[o.Int16=2]="Int16",o[o.Int32=3]="Int32",o[o.Uint8=4]="Uint8",o[o.Uint16=5]="Uint16",o[o.Uint32=6]="Uint32",function(o){o[o.Float32=32]="Float32",o[o.Float64=33]="Float64"}(n=e.FloatDataType||(e.FloatDataType={})),e.getDataType=function r(o){let s;return s=o instanceof Int8Array?e.IntDataType.Int8:o instanceof Int16Array?e.IntDataType.Int16:o instanceof Int32Array?e.IntDataType.Int32:o instanceof Uint8Array?e.IntDataType.Uint8:o instanceof Uint16Array?e.IntDataType.Uint16:o instanceof Uint32Array?e.IntDataType.Uint32:o instanceof Float32Array?e.FloatDataType.Float32:o instanceof Float64Array?e.FloatDataType.Float64:e.IntDataType.Int32,s},e.isSignedIntegerDataType=function i(o){if(o instanceof Int8Array||o instanceof Int16Array||o instanceof Int32Array)return!0;for(let s=0,a=o.length;s=0;n--)t=wFe(t,e.encoding[n]);return t}function wFe(e,t){switch(t.kind){case"ByteArray":switch(t.type){case Jn.IntDataType.Uint8:return e;case Jn.IntDataType.Int8:return function AFe(e){return new Int8Array(e.buffer,e.byteOffset)}(e);case Jn.IntDataType.Int16:return function IFe(e){return Yb(e,2,Int16Array)}(e);case Jn.IntDataType.Uint16:return function TFe(e){return Yb(e,2,Uint16Array)}(e);case Jn.IntDataType.Int32:return function DFe(e){return Yb(e,4,Int32Array)}(e);case Jn.IntDataType.Uint32:return function EFe(e){return Yb(e,4,Uint32Array)}(e);case Jn.FloatDataType.Float32:return function PFe(e){return Yb(e,4,Float32Array)}(e);case Jn.FloatDataType.Float64:return function MFe(e){return Yb(e,8,Float64Array)}(e);default:Rr()}case"FixedPoint":return function RFe(e,t){const n=e.length,r=rJ(t.srcType,n),i=1/t.factor;for(let o=0;o=0?Math.ceil((p+1)/m):Math.ceil((p+1)/(-m-1))}function i({limit8:p,limit16:m},h,g){h.pack8+=t(g,p),h.pack16+=t(g,m),h.count+=1}function o(p,m){p.pack8+=t(m,127),p.pack16+=t(m,32767),p.count+=1}function s(p){return 4*p.count<2*p.pack16?{length:4*p.count,elem:4}:2*p.pack16g.length-y.length),h}e.getSize=d,e.classify=function f(p){if(p.length<2)return Ln.by(Ln.byteArray);switch(d(p)[0].kind){case"pack":return Ln.by(Ln.integerPacking);case"rle":return Ln.by(Ln.runLength).and(Ln.integerPacking);case"delta":return Ln.by(Ln.delta).and(Ln.integerPacking);case"delta-rle":return Ln.by(Ln.delta).and(Ln.runLength).and(Ln.integerPacking);default:Rr()}}}(f2||(f2={})),function(e){e.classify=function n(i){const{mantissaDigits:s,integerDigits:a}=function GFe(e,t,n){let r=1,i=0;for(let o=0,s=e.length;o=0){const c=VFe(e[o],t,n);c<0?r=-1:c>r&&(r=c)}const a=Math.abs(e[o]);if(a>n){const c=Math.floor(Math.log10(Math.abs(a)))+1;c>i&&(i=c)}}return{mantissaDigits:r,integerDigits:i}}(i,4,1e-6);if(s<0||s+a>10)return Ln.by(Ln.byteArray);if(0===s)return f2.classify(i);const c=function r(i){let o=1;for(let s=0;sn[e].value(t)}function qFe(e){return(t,n)=>n[e].value(t).join(n[e].schema.separator)}function VB(e,...t){return(n,r)=>r[e].schema.space.get(r[e].value(n),...t)}function p2(e){return(t,n)=>n[e].valueKind(t)}function WFe(e,t){const n=[],i=p2(e);if(1===t.rank){const o=t.dimensions[0];for(let s=0;s 3 or rank 0 are currently not supported.");{const o=t.dimensions[0],s=t.dimensions[1],a=t.dimensions[2];for(let c=0;c!!t.shouldInclude)?e.fields.filter(t=>!t.shouldInclude||e.source.some(n=>t.shouldInclude(n.data))):e.fields}function sJ(e,t){const n=e.instance(t),r=n.source.filter(s=>s.rowCount>0);return r.length?{instance:n,rowCount:r.reduce((s,a)=>s+a.rowCount,0),source:r.map(s=>({data:s.data,keys:()=>s.keys?s.keys():$I.Range(0,s.rowCount-1),rowCount:s.rowCount}))}:{instance:n,rowCount:0,source:[]}}!function(e){function t(i){return new iT([i])}function r(i){switch(i.kind){case"ByteArray":return Ln.byteArray;case"FixedPoint":return Ln.fixedPoint(i.factor);case"IntervalQuantization":return Ln.intervalQuantizaiton(i.min,i.max,i.numSteps);case"RunLength":return Ln.runLength;case"Delta":return Ln.delta;case"IntegerPacking":return Ln.integerPacking;case"StringArray":return Ln.stringArray}}e.by=t,e.fromEncoding=function n(i){let o=t(r(i[0]));for(let s=1;s=0?I/S|0:I/A|0}return E+=_.length,E}e.byteArray=s,e.fixedPoint=function c(_){return S=>function a(_,S){const A=Jn.getDataType(_),E=new Int32Array(_.length);for(let w=0,D=_.length;wfunction u(_,S,A,E,w){const D=Jn.getDataType(_);if(!_.length)return{encodings:[{kind:"IntervalQuantization",min:S,max:A,numSteps:E,srcType:D}],data:new Int32Array(0)};if(A=A?E-1:0|Math.round((N-S)/I)}return{encodings:[{kind:"IntervalQuantization",min:S,max:A,numSteps:E,srcType:D}],data:R}}(w,_,S,A,E)},e.runLength=function d(_){let S=Jn.getDataType(_);if(void 0===S&&(_=new Int32Array(_),S=Jn.IntDataType.Int32),!_.length)return{encodings:[{kind:"RunLength",srcType:S,srcSize:0}],data:new Int32Array(0)};let A=2;for(let I=1,R=_.length;I=0)for(;M>=A;)D[I]=A,++I,M-=A;else for(;M<=E;)D[I]=E,++I,M-=E;D[I]=M,++I}const R=s(D);return{encodings:[{kind:"IntegerPacking",byteCount:S.bytesPerElement,isUnsigned:!S.isSigned,srcSize:w},R.encodings[0]],data:R.data}}(_,S)},e.stringArray=function x(_){const S=Object.create(null),A=[],E=new Int32Array(_.length),w=ze.create(Int32Array,1,Math.min(1024,_.length<32?_.length+1:Math.round(_.length/8)+1));ze.add(w,0);let D=0,I=0;for(const F of _){if(null==F){E[I++]=-1;continue}let G=S[F];void 0===G&&(D+=F.length,G=A.length,A[G]=F,S[F]=G,ze.add(w,D)),E[I++]=G}const R=ze.compact(w),M=FB(R).encode(R),V=FB(E).encode(E);return{encodings:[{kind:"StringArray",dataEncoding:V.encoding,stringData:A.join(""),offsetEncoding:M.encoding,offsets:M.data}],data:V.data}}}(Ln||(Ln={})),function(e){function n(a,c,u){return{name:a,type:1,value:c,valueKind:u&&u.valueKind,defaultFormat:u?{encoder:u.encoder,typedArray:u.typedArray}:void 0,shouldInclude:u&&u.shouldInclude}}e.str=function t(a,c,u){return{name:a,type:0,value:c,valueKind:u&&u.valueKind,defaultFormat:u&&u.encoder?{encoder:u.encoder}:void 0,shouldInclude:u&&u.shouldInclude}},e.int=n,e.float=function r(a,c,u){return{name:a,type:2,value:c,valueKind:u&&u.valueKind,defaultFormat:u?{encoder:u.encoder,typedArray:u.typedArray,digitCount:typeof u.digitCount<"u"?u.digitCount:void 0}:void 0,shouldInclude:u&&u.shouldInclude}},e.index=function i(a){return n(a,(c,u,l)=>l+1,{typedArray:Int32Array,encoder:Ln.by(Ln.delta).and(Ln.runLength).and(Ln.integerPacking)})};class o{constructor(){this.fields=[]}index(c){return this.fields.push(e.index(c)),this}str(c,u,l){return this.fields.push(e.str(c,u,l)),this}int(c,u,l){return this.fields.push(e.int(c,u,l)),this}vec(c,u,l){for(let d=0;du.split(".")[0]);return{includeCategory:u=>!o.includes(u)&&(i.length<=0||-1!==i.indexOf(u)),includeField(u,l){const d=u+"."+l;return!a.includes(d)&&(!c.includes(u)||s.includes(d))}}},e.DefaultFilter={includeCategory:r=>!0,includeField:(r,i)=>!0},e.DefaultFormatter={getFormat(r,i){}},e.ofTable=function n(r,i){return i?{fields:oJ(r._schema),source:[{data:r,rowCount:i.length,keys:()=>$I.Array(i)}]}:{fields:oJ(r._schema),source:[{data:r,rowCount:r._rowCount}]}}}(lu||(lu={})),function(e){function t(r,i,o){r.startDataBlock(i);for(const s of o._tableNames)r.writeCategory({name:s,instance:()=>lu.ofTable(o[s])})}e.writeDatabase=t,e.writeDatabaseCollection=function n(r,i){for(const o of Object.keys(i))t(r,o,i[o])}}(LB||(LB={}));class YFe{constructor(){this.builder=ir.create(),this.encoded=!1,this.dataBlockCreated=!1,this.filter=lu.DefaultFilter,this.formatter=lu.DefaultFormatter,this.isBinary=!1,this.binaryEncodingProvider=void 0}setFilter(t){this.filter=t||lu.DefaultFilter}isCategoryIncluded(t){return this.filter.includeCategory(t)}setFormatter(t){this.formatter=t||lu.DefaultFormatter}startDataBlock(t){this.dataBlockCreated=!0,ir.write(this.builder,`data_${(t||"").replace(/[ \n\t]/g,"").toUpperCase()}\n#\n`)}writeCategory(t,n,r){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(!r?.ignoreFilter&&!this.filter.includeCategory(t.name))return;const{instance:i,rowCount:o,source:s}=sJ(t,n);o&&(1===o?function XFe(e,t,n,r,i,o){const s=zB(t),a=n[0],c=a.data;let u=s.reduce((p,m)=>i.includeField(e.name,m.name)?Math.max(p,m.name.length):0,0);if(0===u)return;u+=e.name.length+6;const d=a.keys().move(),f=cJ(e.name,t.fields,o);for(let p=0;pi.includeField(e.name,d.name)),c=a.length;if(0===c)return;const u=cJ(e.name,a,o);uJ(r,"loop_");for(let d=0;d=0}(c)?(oT(e,c),!0):function nBe(e,t){if(!t)return ir.writeSafe(e,". "),!1;const n=t.charCodeAt(0);let r=!1,i=0,o=!1,s=!1;for(let a=0,c=t.length-1;a<=c;a++)switch(t.charCodeAt(a)){case 9:case 32:r=!0;break;case 10:return oT(e,t),!0;case 34:if(a&&a===c)break;if(o)return oT(e,t),!0;s=!0,r=!0,i=0;break;case 39:if(a&&a===c)break;if(s)return oT(e,t),!0;o=!0,r=!0,i=1}return!r&&(35===n||36===n||59===n||91===n||93===n||95===n)&&(r=!0),r?(ir.writeSafe(e,i?'"':"'"),ir.writeSafe(e,t),ir.writeSafe(e,i?'" ':"' ")):(ir.writeSafe(e,t),ir.writeSafe(e," ")),!1}(e,c);1===u?function QFe(e,t){ir.writeInteger(e,t),ir.whitespace1(e)}(e,c):function JFe(e,t,n){ir.writeFloat(e,t,n),ir.whitespace1(e)}(e,c,i)}return!1}function cJ(e,t,n){const r=[];for(const i of t){const o=n.getFormat(e,i.name);r[r.length]=o&&typeof o.digitCount<"u"?2===i.type?Math.pow(10,Math.max(0,Math.min(o.digitCount,15))):0:2===i.type?Math.pow(10,$Fe(i)):0}return r}function uJ(e,t){ir.write(e,t),ir.newline(e)}function oT(e,t){ir.writeSafe(e,"\n;"+t),ir.writeSafe(e,"\n;\n")}function Xb(e,t,n){for(let r=0,i=n.length;r>>0&127;else if(o<2048)e[t++]=o>>>6&31|192,e[t++]=o>>>0&63|128;else if(o<65536)e[t++]=o>>>12&15|224,e[t++]=o>>>6&63|128,e[t++]=o>>>0&63|128;else{if(!(o<1114112))throw new Error("bad codepoint "+o);e[t++]=o>>>18&7|240,e[t++]=o>>>12&63|128,e[t++]=o>>>6&63|128,e[t++]=o>>>0&63|128}}}const rBe=function(){const e=[];for(let t=0;t<1024;t++)e[t]=String.fromCharCode(t);return e}();function lJ(e){throw new Error(e)}const dJ=typeof TextDecoder<"u"?new TextDecoder:void 0;function GB(e,t,n){if(dJ){const r=t||n!==e.length?e.subarray(t,t+n):e;return dJ.decode(r)}return function iBe(e,t,n){const r=rBe;let i,o=0;const s=[];for(let c=t,u=t+n;c0&&(i[i.length]=s.slice(0,o).join("")),i.join("")):s.slice(0,o).join("")}(e,t,n)}function sT(e){let t=0;for(let n=0,r=e.length;n=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("boolean"===t||null==e)return 1;if("object"===t){let n,r=0;if(Array.isArray(e)){n=e.length;for(let i=0;i=0){if(e<128)return t.setUint8(r,e),1;if(e<256)return t.setUint8(r,204),t.setUint8(r+1,e),2;if(e<65536)return t.setUint8(r,205),t.setUint16(r+1,e),3;if(e<4294967296)return t.setUint8(r,206),t.setUint32(r+1,e),5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return t.setInt8(r,e),1;if(e>=-128)return t.setUint8(r,208),t.setInt8(r+1,e),2;if(e>=-32768)return t.setUint8(r,209),t.setInt16(r+1,e),3;if(e>=-2147483648)return t.setUint8(r,210),t.setInt32(r+1,e),5;throw new Error("Number too small -0x"+(-e).toString(16).substr(1))}if(null==e)return t.setUint8(r,192),1;if("boolean"===i)return t.setUint8(r,e?195:194),1;if("object"===i){let o,s=0;const a=Array.isArray(e);let c;if(a?o=e.length:(c=Object.keys(e),o=c.length),o<16?(t.setUint8(r,o|(a?144:128)),s=1):o<65536?(t.setUint8(r,a?220:222),t.setUint16(r+1,o),s=3):o<4294967296&&(t.setUint8(r,a?221:223),t.setUint32(r+1,o),s=5),a)for(let u=0;ui.properties.chemicalComponentMap.has(o.comp_id.value(s)))},e.getEntriesFromChemCompBond=function n(i){const o=new Map;function s(h){if(o.has(h))return o.get(h);const g=new r(h);return o.set(h,g),g}const{comp_id:a,atom_id_1:c,atom_id_2:u,value_order:l,pdbx_aromatic_flag:d,_rowCount:f,pdbx_ordinal:p}=i;let m=s(a.value(0));for(let h=0;h=0)return!0;return!1}e.Descriptor={name:"struct_conn",cifExport:{prefix:"",categories:[{name:"struct_conn",instance(o){const s=e.Provider.get(o.firstModel);if(!s||0===s.entries.length)return Bi.Category.Empty;const a=o.structures[0],c=[];for(const u of s.entries)n(a,u.partnerA.atomIndex)&&n(a,u.partnerB.atomIndex)&&(c[c.length]=u.rowIndex);return Bi.Category.ofTable(s.data,c)}}]}},e.Provider=td.create(e.Descriptor),e.isExhaustive=function t(o){const s=e.Provider.get(o);return!!s&&s.data.id.rowCount/o.atomicConformation.atomId.rowCount>.95},e.getAtomIndexFromEntries=function r(o){const s=new Map;for(const a of o){const{partnerA:{atomIndex:c},partnerB:{atomIndex:u}}=a;s.has(c)?s.get(c).push(a):s.set(c,[a]),s.has(u)?s.get(u).push(a):s.set(u,[a])}return s},e.getEntriesFromStructConn=function i(o,s){const{conn_type_id:a,pdbx_dist_value:c,pdbx_value_order:u}=o,l={label_asym_id:o.ptnr1_label_asym_id,label_seq_id:o.ptnr1_label_seq_id,auth_seq_id:o.ptnr1_auth_seq_id,label_atom_id:o.ptnr1_label_atom_id,label_alt_id:o.pdbx_ptnr1_label_alt_id,ins_code:o.pdbx_ptnr1_PDB_ins_code,symmetry:o.ptnr1_symmetry},d={label_asym_id:o.ptnr2_label_asym_id,label_seq_id:o.ptnr2_label_seq_id,auth_seq_id:o.ptnr2_auth_seq_id,label_atom_id:o.ptnr2_label_atom_id,label_alt_id:o.pdbx_ptnr2_label_alt_id,ins_code:o.pdbx_ptnr2_PDB_ins_code,symmetry:o.ptnr2_symmetry},f=Array.from(s.entities.data.id.toArray()),p=(h,g)=>{if(0!==g.label_asym_id.valueKind(h))return;const y=g.label_asym_id.value(h),b=g.label_atom_id.value(h);if(!b)return;const x=g.auth_seq_id.valueKind(h)===te.ValueKind.Present?g.auth_seq_id.value(h):g.label_seq_id.value(h),_=g.ins_code.value(h),S=g.label_alt_id.value(h);for(const A of f){const E=s.atomicHierarchy.index.findResidue(A,y,x,_);if(E<0)continue;const w=s.atomicHierarchy.index.findAtomOnResidue(E,b,S);if(!(w<0))return{residueIndex:E,atomIndex:w,symmetry:g.symmetry.value(h)}}},m=[];for(let h=0;hMs.Provider.get(o)),i=e.models.some(o=>du.isExhaustive(o));return t.noCompute||e.isCoarseGrained&&!r&&!i||Ve.eachUnitPair(e,(o,s)=>{!function wBe(e,t,n,r){const{maxRadius:i}=n,{elements:o,residueIndex:s}=e,{x:a,y:c,z:u}=e.model.atomicConformation,{elements:l,residueIndex:d}=t,f=e.elements.length,{type_symbol:p,label_alt_id:m,label_atom_id:h,label_comp_id:g}=e.model.atomicHierarchy.atoms,{type_symbol:y,label_alt_id:b,label_atom_id:x,label_comp_id:_}=t.model.atomicHierarchy.atoms,{auth_seq_id:S}=e.model.atomicHierarchy.residues,{auth_seq_id:A}=t.model.atomicHierarchy.residues,{occupancy:E}=e.model.atomicConformation,{occupancy:w}=t.model.atomicConformation,D=E.isDefined&&w.isDefined,I=e.model===t.model&&du.Provider.get(e.model),R=!n.forceCompute&&e.model===t.model&&Ms.Provider.get(e.model),{atomSourceIndex:T}=e.model.atomicHierarchy,{invertedIndex:M}=R?sn.getInvertedAtomSourceIndex(t.model):{invertedIndex:void 0},N=e.model===t.model&&du.isExhaustive(e.model),V=le.mul(CBe,t.conformation.operator.inverse,e.conformation.operator.matrix),F=!le.isIdentity(V),{center:G,radius:L}=t.boundary.sphere,z=(L+i)*(L+i);r.startUnitPair(e.id,t.id);const j=e.conformation.operator.key,Z=t.conformation.operator.key;for(let $=0;$z)continue;if(!n.forceCompute&&R){const{maxDistance:K}=R,{offset:ne,b:de,edgeProps:{order:we,distance:Le,flag:We,key:U,operatorA:Y,operatorB:ge}}=R.bonds,Se=T.value(ee),Re=Qd(p.value(ee));for(let Ne=ne[Se],Ge=ne[Se+1];Ne=0&&ke!==j&&ke!==Z||Xe>=0&&Xe!==Z&&Xe!==j)continue;const ot=Qd(p.value($e)),_t=Le[Ne],ut=yJ(e,ee,t,$e);let Ct=!1;_t>=0?Ct=ai(ut,_t,.3):K>=0?Ct=uti||(r.add($,We,{order:ne.order,flag:ne.flags,key:ne.rowIndex}),K=!0)}if(K)continue}if(N)continue;const O=E.value(ee),{lookup3d:H}=t,{indices:W,count:Q,squaredDistances:fe}=H.find(Vg[0],Vg[1],Vg[2],i);if(0===Q)continue;const X=Qd(p.value(ee)),J=dp(X),ce=Xh(X),be=m.value(ee),ae=d2.has(X),me=h.value(ee),oe=g.value(s[ee]);for(let K=0;Kt.validUnit(o),validUnitPair:(o,s)=>t.validUnitPair(e,o,s)}),new l2(n.getMap())}(e,{...n,validUnit:t&&t.validUnit||(r=>Ee.isAtomic(r)),validUnitPair:t&&t.validUnitPair||((r,i,o)=>{if(!Ve.validUnitPair(r,i,o))return!1;const a=i.model.atomicHierarchy.derived.residue.moleculeType,c=o.model.atomicHierarchy.derived.residue.moleculeType,u=!(Ee.isAtomic(i)&&2===a[i.residueIndex[i.elements[0]]]||Ee.isAtomic(o)&&2===c[o.residueIndex[o.elements[0]]]),l=!Ee.isAtomic(i)||3!==a[i.residueIndex[i.elements[0]]],d=!Ee.isAtomic(o)||3!==c[o.residueIndex[o.elements[0]]];return!(!u&&n.ignoreWater||(!l||!d)&&n.ignoreIon)||function DBe(e,t){if(e.model!==t.model||!Ee.isAtomic(e)||!Ee.isAtomic(t))return!1;const n=du.Provider.get(e.model);if(!n)return!1;const r=e.elements.length=t.elements.length?e:t,{elements:o}=r,{elements:s}=i,{indexOf:a}=je;for(let c=0,u=o.length;c=0)return!0}return!1}(i,o)})})}var Lt;function bJ(e){e.count=e.endVertex-e.startVertex;const{isRingAtom:t,pred:n,color:r,depth:i,marked:o}=e;for(let s=0;s=0;y--)h[g++]=e.startVertex+a[y],r[a[y]]=1;Ou(h);for(let y=0,b=e.currentRings.length;yx.length&&je.isSubset(h,x))return!1}return e.currentRings.push(je.ofSortedArray(h)),!0}function xJ(e,t,n){const{bonds:r,startVertex:i,endVertex:o,isRingAtom:s,marked:a,queue:c,pred:u,depth:l}=e,{elements:d}=e.unit,{b:f,edgeProps:{flags:p},offset:m}=r;a[t]=n,l[t]=0,c[0]=t;let h=0,g=1;for(;h=o||!jn.isCovalent(p[A]))continue;if(e.hasAltLoc){const I=e.altLoc.value(d[E]);if(I&&e.currentAltLoc!==I)continue}const w=E-i;if(a[w]===n){if(u[w]!==y&&u[y]!==w&&kBe(e,y,w,s))return n+1;continue}const D=Math.min(l[w],b+1);D>5||(l[w]=D,a[w]=n,c[g++]=w,u[w]=y)}}return n+1}function SJ(e){const t=e.length,n=new Int32Array(2*t);for(let s=0;s{const _=y.unitMap.get(x.aUnit.id);if(!_)return;const S=y.unitMap.get(x.bUnit.id);if(!S)return;const E=je.indexOf(_.elements,x.aUnit.elements[x.aIndex]);if(-1===E)return;const D=je.indexOf(S.elements,x.bUnit.elements[x.bIndex]);-1!==D&&b.push(t(g.structure,_,E,g.structure,S,D))}),i(y,b)},e.toStructureElementLoci=function u(g){const y=[],b=new Map;for(const x of g.bonds){const{aIndex:_,aUnit:S,bIndex:A,bUnit:E}=x;S===E?b.has(S.id)?b.get(S.id).push(_,A):b.set(S.id,[_,A]):(b.has(S.id)?b.get(S.id).push(_):b.set(S.id,[_]),b.has(E.id)?b.get(E.id).push(A):b.set(E.id,[A]))}return b.forEach((x,_)=>{y.push({unit:g.structure.unitMap.get(_),indices:je.deduplicate(je.ofUnsortedArray(x))})}),De(g.structure,y)},e.toFirstStructureElementLoci=function l(g){const{aUnit:y,aIndex:b}=g.bonds[0];return De(g.structure,[{unit:y,indices:Fe.ofSingleton(b)}])},e.getType=function d(g,y){if(y.aUnit===y.bUnit){const b=y.aUnit.bonds,x=b.getEdgeIndex(y.aIndex,y.bIndex);return jn.create(x<0?0:b.edgeProps.flags[x])}{const b=g.interUnitBonds.getBondFromLocation(y);return jn.create(b?b.props.flag:0)}},e.getOrder=function f(g,y){if(y.aUnit===y.bUnit){const b=y.aUnit.bonds,x=b.getEdgeIndex(y.aIndex,y.bIndex);return x<0?0:b.edgeProps.order[x]}{const b=g.interUnitBonds.getBondFromLocation(y);return b?b.props.order:0}},e.getIntraUnitBondCount=function p(g){let y=0;for(let b=0,x=g.units.length;b{const{aUnit:S,aIndex:A,bUnit:E,bIndex:w}=g.bonds[b];S.conformation.position(S.elements[A],x),E.conformation.position(E.elements[w],_)},y)}}(Lt||(Lt={}));const OBe=new Set;function Qh(e,t){const n=WNe[e];if(void 0!==n){const r=n[t];if(void 0!==r)return r}return OBe}const wJ=v.zero();function AJ(e,t){const n=e.conformation,r=new Float32Array(3*t.length),{elements:i}=e;for(let o=0,s=t.length;o=y||i.addEdge(c,y)}}}const o=Dc.connectedComponents(i.getGraph()),s=o.componentIndex,a=[];for(let c=0;c=0&&(n.has(a)?n.get(a).push(s):n.set(a,[s]))}}(function(e){function n(a){return function NBe(e){const t=e.length,n=new Array(t);for(let s=0;s0)return!1;const y=nd.calculateMomentsAxes(AJ(a,c));return v.magnitude(y.dirC)<.05},e.getAltId=function s(a,c){const{label_alt_id:u}=a.model.atomicHierarchy.atoms,{elements:l}=a;for(let d=0,f=c.length;dFe.max(S)||o(_)this.maxDist[t]&&(this.maxDist[t]=r,EJ(this.extrema[2*t+1],n))}computeSphereExtrema(t,n,r){const i=this.dir[t],o=DJ(i,n);o-rthis.maxDist[t]&&(this.maxDist[t]=o+r,KBe(this.extrema[2*t+1],n,i,r))}includeSphere(t){if(_e.hasExtrema(t)&&t.extrema.length>1)for(const n of t.extrema)this.includePosition(n);else this.includePositionRadius(t.center,t.radius)}includePosition(t){for(let n=0;n1)for(const n of t.extrema)this.radiusPosition(n);else this.radiusPositionRadius(t.center,t.radius)}radiusPosition(t){this.centroidHelper.radiusStep(t)}radiusPositionRadius(t,n){this.centroidHelper.radiusSphereStep(t,n)}getSphere(t){return _e.setExtrema(this.centroidHelper.getSphere(t),this.extrema.slice())}getBox(t){return St.fromVec3Array(t||St(),this.extrema)}reset(){for(let t=0;t{const r=v.create(n[0],n[1],n[2]);return v.normalize(r,r)})}(t),this.dirLength=this.dir.length,this.reset()}}const lT=[[1,0,0],[0,1,0],[0,0,1]],HB=[[1,1,1],[-1,1,1],[-1,-1,1],[1,-1,1]],PJ=[[1,1,0],[1,-1,0],[1,0,1],[1,0,-1],[0,1,1],[0,1,-1]],QBe=[[0,1,2],[0,2,1],[1,0,2],[2,0,1],[1,2,0],[2,1,0],[0,1,-2],[0,2,-1],[1,0,-2],[2,0,-1],[1,-2,0],[2,-1,0]],JBe=[[1,1,2],[2,1,1],[1,2,1],[1,-1,2],[1,1,-2],[1,-1,-2],[2,-1,1],[2,1,-1],[2,-1,-1],[1,-2,1],[1,2,-1],[1,-2,-1]],eOe=[[2,2,1],[1,2,2],[2,1,2],[2,-2,1],[2,2,-1],[2,-2,-1],[1,-2,2],[1,2,-2],[1,-2,-2],[2,-1,2],[2,1,-2],[2,-1,-2]],MJ=v.set,tOe=new fu("14"),nOe=new fu("98");function qB(e){const t=St.computeBounding(e);return{box:t,sphere:_e.fromBox3D(_e(),t)}}const dT=v();function pp(e){const{x:t,y:n,z:r,radius:i,indices:o}=e,s=Fe.size(o);if(s>25e4)return qB(e);const a=function rOe(e){return e>1e4?tOe:nOe}(s);a.reset();for(let u=0;u{const n=[];let r=0;for(let i=0;iZe.unit.operator_name(l.element),ui.DefaultName),Sr.pred.inSet(l=>Ze.chain.label_asym_id(l.element),o.asymIds))});n[n.length]={selector:u,operators:c,asymIds:o.asymIds},r+=c.length}return n}}(s,r))}function cOe(e){const t=[],n=[];for(let r=0;r{const s=[];o.split(",").forEach(a=>{const c=a.indexOf("-");if(c>0){const u=parseInt(a.substring(0,c)),l=parseInt(a.substr(c+1));for(let d=u;d<=l;d++)s[s.length]=d.toString()}else s[s.length]=a.trim()}),r[r.length]=s}),r}function hOe(e){if(0===e._rowCount)return;const{id:t,matrix:n,vector:r}=e,i=On.struct_ncs_oper.matrix.space,o=On.struct_ncs_oper.vector.space,s=[];for(let a=0;a{const h=c.length;c.push(je.ofUnsortedArray([f,p,m])),u.set(t2(f,p),m),l.has(f)?l.get(f).push(h):l.set(f,[h])};for(let f=0;f=2){d(f,m[0],m[1]);for(let h=1,g=m.length;hu.get(t2(f,p)),getTripletIndices:f=>l.get(f),triplets:c}}function kJ(){return{result:Kb.create(),closeUnitsResult:Uu.create(),unitGroupResult:Uu.create()}}!function(e){e.create=function t(n,r,i){return new e(n,r,i)}}($B||($B={})),function(e){e.Default={assemblies:[],spacegroup:Ec.ZeroP1,isNonStandardCrystalFrame:!1},e.findAssembly=function t(r,i){const o=i.toLocaleLowerCase(),s=no.Provider.get(r);return s?cB(s.assemblies,a=>a.id.toLowerCase()===o):void 0},e.getUnitcellLabel=function n(r){const{cell:i,name:o,num:s}=r.spacegroup,{size:a,anglesInRadians:c}=i,u=a[0].toFixed(2),l=a[1].toFixed(2),d=a[2].toFixed(2),f=su(c[0]).toFixed(2),p=su(c[1]).toFixed(2),m=su(c[2]).toFixed(2),h=[];return h.push(`Unit Cell ${o} #${s}`),h.push(`${u}\xd7${l}\xd7${d} \u212b`),h.push(`\u03b1=${f}\xb0 \u03b2=${p}\xb0 \u03b3=${m}\xb0`),h.join(" | ")}}(h2||(h2={})),function(e){e.Descriptor={name:"model_symmetry"},e.Provider=td.create(e.Descriptor),e.fromData=function t(r){const i=function iOe(e,t,n){if(!e._rowCount)return[];const r=function aOe(e){const{id:t,matrix:n,vector:r,_schema:i}=e,o=new Map,s=v();for(let a=0,c=e._rowCount;az[j]}(L=t=e.Kinds||(e.Kinds={}))[L.Atomic=0]="Atomic",L[L.Spheres=1]="Spheres",L[L.Gaussians=2]="Gaussians",e.isAtomic=function n(L){return 0===L.kind},e.isCoarse=function r(L){return 1===L.kind||2===L.kind},e.isSpheres=function i(L){return 1===L.kind},e.isGaussians=function o(L){return 2===L.kind},e.create=function s(L,z,j,Z,$,ee,q,O,H){switch($){case 0:return new y(L,z,j,Z,ee,O,ui.createMapping(q,ee.atomicConformation),H??{});case 1:return w(L,z,j,Z,ee,1,O,ui.createMapping(q,ee.coarseConformation.spheres,h(ee)),H??{});case 2:return w(L,z,j,Z,ee,2,O,ui.createMapping(q,ee.coarseConformation.gaussians,z=>0),H??{})}},e.SymmetryGroup=u,function(L){L.areInvariantElementsEqual=function z(Z,$){return Z.hashCode===$.hashCode&&je.areEqual(Z.elements,$.elements)},L.getUnitSymmetryGroupsIndexMap=function j(Z){const $=Lu.Mutable();for(let ee=0,q=Z.length;ee=M)continue;const N=je.indexOf(e.elements,M);if(N<0)continue;const V=f[R],F=p[R];if(V>=0&&V!==S||F>=0&&F!==S)continue;const G=Qd(r.value(M)),L=u[R],z=hBe(e,E,M);let j=!1;L>=0?j=ai(z,L,.3):o>=0?j=z1&&(N=!1)}}}return fJ(S,A,w,E,D,s,T||M&&N)}(e,n)}(this),z.set(this.elements,j)),this.props.bonds=j,this.props.bonds}get rings(){return this.props.rings||(this.props.rings=uT.create(this)),this.props.rings}get resonance(){return this.props.resonance||(this.props.resonance=function mOe(e){return{delocalizedTriplets:gOe(e)}}(this)),this.props.resonance}get polymerElements(){return this.props.polymerElements||(this.props.polymerElements=function GBe(e){const t=[],{elements:n,model:r}=e,{residueAtomSegments:i}=e.model.atomicHierarchy,{traceElementIndex:o}=r.atomicHierarchy.derived.residue,s=wr.transientSegments(e.model.atomicRanges.polymerRanges,n),a=en.transientSegments(i,n);for(;s.hasNext;){const c=s.move();for(a.setSegment(c);a.hasNext;){const u=a.move(),{start:l,end:d,index:f}=u;if(Fe.areIntersecting(Ce.ofRange(n[l],n[d-1]),n)){const p=o[f];t.push(-1===p?i.offsets[f]:p)}}}return je.ofSortedArray(t)}(this)),this.props.polymerElements}get gapElements(){return this.props.gapElements||(this.props.gapElements=function HBe(e){const t=[],{elements:n,model:r,residueIndex:i}=e,{residueAtomSegments:o}=e.model.atomicHierarchy,{traceElementIndex:s}=r.atomicHierarchy.derived.residue,a=wr.transientSegments(e.model.atomicRanges.gapRanges,e.elements);for(;a.hasNext;){const c=a.move(),u=i[n[c.start]],l=i[n[c.end-1]],d=s[u],f=s[l];t.push(-1===d?o.offsets[u]:d),t.push(-1===f?o.offsets[l]:f)}return je.ofSortedArray(t)}(this)),this.props.gapElements}get nucleotideElements(){return this.props.nucleotideElements||(this.props.nucleotideElements=function WBe(e){const t=[],{elements:n,model:r}=e,{chainAtomSegments:i,residueAtomSegments:o}=r.atomicHierarchy,{moleculeType:s,traceElementIndex:a}=r.atomicHierarchy.derived.residue,c=en.transientSegments(i,n),u=en.transientSegments(o,n);for(;c.hasNext;)for(u.setSegment(c.move());u.hasNext;){const{index:l}=u.move();if(Ya(s[l])){const d=a[l];t.push(-1===d?o.offsets[l]:d)}}return je.ofSortedArray(t)}(this)),this.props.nucleotideElements}get proteinElements(){return this.props.proteinElements||(this.props.proteinElements=function $Be(e){const t=[],{elements:n,model:r}=e,{chainAtomSegments:i,residueAtomSegments:o}=r.atomicHierarchy,{moleculeType:s,traceElementIndex:a}=r.atomicHierarchy.derived.residue,c=en.transientSegments(i,n),u=en.transientSegments(o,n);for(;c.hasNext;)for(u.setSegment(c.move());u.hasNext;){const{index:l}=u.move();if(ZQ(s[l])){const d=a[l];t.push(-1===d?o.offsets[l]:d)}}return je.ofSortedArray(t)}(this)),this.props.proteinElements}get residueCount(){if(void 0!==this.props.residueCount)return this.props.residueCount;let z=0;const j=en.transientSegments(this.model.atomicHierarchy.residueAtomSegments,this.elements);for(;j.hasNext;)j.move(),z+=1;return this.props.residueCount=z,this.props.residueCount}getResidueIndex(z){return this.residueIndex[this.elements[z]]}constructor(z,j,Z,$,ee,q,O,H){this.kind=0,this.objectPrimitive="atomistic",this.id=z,this.invariantId=j,this.chainGroupId=Z,this.traits=$,this.model=ee,this.elements=q,this.conformation=O,this.residueIndex=ee.atomicHierarchy.residueAtomSegments.index,this.chainIndex=ee.atomicHierarchy.chainAtomSegments.index,this.props=H}}e.Atomic=y;class x{getChild(z){return z.length===this.elements.length?this:w(this.id,this.invariantId,this.chainGroupId,this.traits,this.model,this.kind,z,this.conformation,{})}applyOperator(z,j,Z=!1){const $=Z?j:ui.compose(this.conformation.operator,j);return w(z,this.invariantId,this.chainGroupId,this.traits,this.model,this.kind,this.elements,ui.createMapping($,this.getCoarseConformation(),this.conformation.r),this.props)}remapModel(z,j,Z){const $=this.getCoarseConformation(),ee=_(this.kind,z);Z||(Z={...this.props},e.isSameConformation(this,z)||(Z.boundary=void 0,Z.lookup3d=void 0,Z.principalAxes=void 0));const q=$!==ee?ui.createMapping(this.conformation.operator,ee,1===this.kind?h(z):z=>0):this.conformation;return new x(this.id,this.invariantId,this.chainGroupId,this.traits,z,this.kind,this.elements,q,Z)}get boundary(){if(this.props.boundary)return this.props.boundary;const{x:z,y:j,z:Z}=this.getCoarseConformation();return this.props.boundary=p.is(this.traits,f.FastBoundary)?qB({x:z,y:j,z:Z,indices:this.elements}):pp({x:z,y:j,z:Z,indices:this.elements}),this.props.boundary}get lookup3d(){if(this.props.lookup3d)return this.props.lookup3d;const{x:z,y:j,z:Z}=this.getCoarseConformation();return this.props.lookup3d=rd({x:z,y:j,z:Z,indices:this.elements},this.boundary),this.props.lookup3d}get principalAxes(){return this.props.principalAxes||(this.props.principalAxes=TJ(this)),this.props.principalAxes}get polymerElements(){return this.props.polymerElements||(this.props.polymerElements=function jBe(e){const t=[],{elements:n,model:r}=e,{spheres:i,gaussians:o}=r.coarseHierarchy,s=Ee.isSpheres(e)?i.polymerRanges:o.polymerRanges,a=wr.transientSegments(s,n);for(;a.hasNext;){const{start:c,end:u}=a.move();for(let l=c;l(u+=c[p].elements.length)>=i,o.closeUnitsResult);if(0===l.count)return s;let d=0,f=-Number.MAX_VALUE;for(let p=0,m=l.count;p=i&&fs||c.addElement(b[y.indices[x]])}c.commitUnit()}}check(t,n,r,i){const{units:o}=this.structure,s=this.unitLookup.find(t,n,r,i);if(0===s.count)return!1;for(let a=0,c=s.count;a0&&(i[i.length]=a.getChild(u))}return Ve.create(i,{parent:e.parent||t.parent})}function XB(e){return jn.isCovalent(e.atomicBond.type)}function _Oe(){return function(t){const{inputStructure:n}=t,r=nt.create(n),i=[];for(const o of n.units){if(0!==o.kind)continue;r.unit=o;const s=o.elements;if(r.element=s[0],"polymer"!==Ze.entity.type(r))continue;const a=en.transientSegments(o.model.atomicHierarchy.residueAtomSegments,s);let c=0;for(;a.hasNext;)c++,a.move();c<8||i.push(o)}return pt.Singletons(n,Ve.create(i,{parent:n}))}}function xOe(){return function(t){const{inputStructure:n}=t,r=nt.create(n),i=[];for(const o of n.units)0===o.kind&&(r.unit=o,r.element=o.elements[0],"water"===Ze.entity.type(r)&&i.push(o));return pt.Singletons(n,Ve.create(i,{parent:n}))}}function SOe(){return function(t){const{inputStructure:n}=t,r=nt.create(n),i=[];for(const o of n.units){if(0!==o.kind)continue;r.unit=o;const s=o.elements;if(r.element=s[0],"water"!==Ze.entity.type(r)){if("polymer"===Ze.entity.type(r)){const a=en.transientSegments(o.model.atomicHierarchy.residueAtomSegments,s);let c=0;for(;a.hasNext;)c++,a.move();if(c>=8)continue}i.push(o)}}return pt.Singletons(n,Ve.create(i,{parent:n}))}}function COe(){return function(t){const{inputStructure:n}=t,r=[];for(const i of n.units)1===i.kind&&r.push(i);return pt.Singletons(n,Ve.create(r,{parent:n}))}}function FJ(e,t,n){return{groupedUnits:e,ranges:t,set:n}}function BJ(e){return function(n){return pt.Sequence(n.inputStructure,[Kn.toStructure({hash:n.inputStructure.hashCode,elements:e},n.inputStructure)])}}!function(e){function t(y,b){return{kind:"singletons",source:y,structure:b}}function n(y,b){return{kind:"sequence",source:y,structures:b}}function r(y){return t(y,Ve.Empty)}function i(y){return"singletons"===y.kind}function o(y){return i(y)?0===y.structure.units.length:0===y.structures.length}function a(y){return o(y)?Ve.Empty:i(y)?y.structure:m2(y.source,y.structures)}function l(y,b,x){return 0===b.length?r(y):x?t(y,m2(y,b)):n(y,b)}e.Singletons=t,e.Sequence=n,e.Empty=r,e.isSingleton=i,e.isEmpty=o,e.structureCount=function s(y){return i(y)?y.structure.elementCount:y.structures.length},e.unionStructure=a,e.toLociWithCurrentUnits=function c(y){const b=[],{unitMap:x}=y.source;for(const _ of a(y).units)b[b.length]=_===x.get(_.id)?{unit:_,indices:Fe.ofBounds(0,_.elements.length)}:{unit:_,indices:Fe.ofSortedArray(je.indicesOf(x.get(_.id).elements,_.elements))};return De(y.source,b)},e.toLociWithSourceUnits=function u(y){const b=[],{unitMap:x}=y.source;for(const _ of a(y).units){const S=x.get(_.id);b[b.length]=S===_?{unit:S,indices:Fe.ofBounds(0,S.elements.length)}:{unit:S,indices:Fe.ofSortedArray(je.indicesOf(S.elements,_.elements))}}return De(y.source,b)};class d{add(b){const x=b.elementCount;0!==x&&(this.structures[this.structures.length]=b,1!==x&&(this.allSingletons=!1))}getSelection(){return l(this.source,this.structures,this.allSingletons)}constructor(b){this.source=b,this.structures=[],this.allSingletons=!0}}class f{add(b){const x=b.elementCount;0===x||!this.uniqueSets.add(b)||(this.structures[this.structures.length]=b,1!==x&&(this.allSingletons=!1))}getSelection(){return l(this.structure,this.structures,this.allSingletons)}constructor(b){this.structure=b,this.structures=[],this.allSingletons=!0,this.uniqueSets=CB(Ve.hashCode,Ve.areUnitIdsAndIndicesEqual)}}e.LinearBuilder=function p(y){return new d(y)},e.UniqueBuilder=function m(y){return new f(y)},e.forEach=function h(y,b){let x=0;if(e.isSingleton(y))for(const _ of y.structure.units){const{elements:S}=_;for(let A=0,E=S.length;A2)y.push(g[S],g[A-1]);else for(let E=S;E{const h=[];m.groupedUnits.forEach(g=>h.push(je.ofUnsortedArray(g))),h.sort((g,y)=>g[0]-y[0]),p.push({groupedUnits:h,set:m.set,ranges:m.ranges})}),{hash:l.structure.hashCode,elements:p}}function i(l,d){const f=[];for(let p=0,m=l.length;pue.core.type.list(d))),ranges:ue.core.type.list(l.ranges),set:ue.core.type.list(l.set)})}e.Empty={hash:-1,elements:[]},e.fromSubStructure=function t(l,d){return r(pt.toLociWithSourceUnits(pt.Singletons(l,d)))},e.fromSelection=function n(l){return r(pt.toLociWithSourceUnits(l))},e.fromLoci=r,e.toLoci=function o(l,d){-1!==l.hash&&l.hash!==d.hashCode&&new Error("Bundle not compatible with given structure");const f=[];for(const p of l.elements)for(const m of p.groupedUnits){const h=i(m,d);if(0===h.length)continue;let g;if(0===p.ranges.length)g=p.set;else if(0===p.set.length)if(2===p.ranges.length)g=Ce.ofRange(p.ranges[0],p.ranges[1]);else{const y=new Int32Array(wr.size(p.ranges));wr.forEach(p.ranges,(b,x)=>y[x]=b),g=je.ofSortedArray(y)}else{const y=wr.size(p.ranges),b=new Int32Array(p.set.length+y);wr.forEach(p.ranges,(x,_)=>b[_]=x),b.set(p.set,y),g=je.ofUnsortedArray(b)}for(const y of h)f.push({unit:y,indices:g})}return De(d,f)},e.toStructure=function s(l,d){-1!==l.hash&&l.hash!==d.hashCode&&new Error("Bundle not compatible with given structure");const f=[];for(const p of l.elements)for(const m of p.groupedUnits){const h=i(m,d);if(0===h.length)continue;const g=h[0].elements,y=wr.size(p.ranges),b=p.set.length,x=new Int32Array(b+y);let _;if(0===y){for(let S=0,A=b;Sx[A]=g[S]),_=je.ofSortedArray(x);else if(je.min(p.set)>wr.max(p.ranges)){wr.forEach(p.ranges,(S,A)=>x[A]=g[S]);for(let S=0,A=b;Sje.max(p.set)){for(let S=0,A=b;Sx[A+b]=g[S]),_=je.ofSortedArray(x)}else{wr.forEach(p.ranges,(S,A)=>x[A]=g[S]);for(let S=0,A=b;S0?this.currentAtomicBondStack.pop():void 0}pushCurrentStructure(){this.currentStructure&&this.currentStructureStack.push(this.currentStructure)}popCurrentStructure(){this.currentStructure=this.currentStructureStack.length?this.currentStructureStack.pop():void 0}pushInputStructure(t){this.inputStructureStack.push(this.inputStructure),this.inputStructure=t}popInputStructure(){if(0===this.inputStructureStack.length)throw new Error("Must push before pop.");this.inputStructure=this.inputStructureStack.pop()}throwIfTimedOut(){if(0!==this.timeoutMs&&yi()-this.timeCreated>this.timeoutMs)throw new Error(`The query took too long to execute (> ${this.timeoutMs/1e3}s).`)}tryGetCurrentSelection(){if(!this.currentSelection)throw new Error("The current selection is not assigned.");return this.currentSelection}constructor(t,n){this.currentElementStack=[],this.currentAtomicBondStack=[],this.currentStructureStack=[],this.inputStructureStack=[],this.timeCreated=yi(),this.element=nt.create(void 0),this.currentStructure=void 0,this.atomicBond=new OJ,this.currentSelection=void 0,this.inputStructure=t,this.timeoutMs=n&&n.timeoutMs||0,this.currentSelection=n&&n.currentSelection}}class OJ{constructor(){this.a=nt.create(void 0),this.aIndex=0,this.b=nt.create(void 0),this.bIndex=0,this.type=0,this.order=0,this.key=-1,this.testFn=XB}setStructure(t){this.a.structure=t,this.b.structure=t}setTestFn(t){this.testFn=t||XB}test(t,n){return!!this.testFn(t)||!!n&&(this.swap(),this.testFn(t))}swap(){const t=this.aIndex;this.aIndex=this.bIndex,this.bIndex=t;const n=this.a.unit;this.a.unit=this.b.unit,this.b.unit=n;const r=this.a.element;this.a.element=this.b.element,this.b.element=r}get length(){return nt.distance(this.a,this.b)}}!function(e){e.run=function t(n,r,i){return n(new qu(r,i))}}(LJ||(LJ={}));class KB{add(t){t.elementCount&&(1!==t.elementCount&&(this.allSingletons=!1),this.set.add(t)&&(this.structures[this.structures.length]=t))}getSelection(){return this.allSingletons?pt.Singletons(this.source,m2(this.source,this.structures)):pt.Sequence(this.source,this.structures)}constructor(t){this.source=t,this.set=CB(Ve.hashCode,Ve.areUnitIdsAndIndicesEqual),this.structures=[],this.allSingletons=!0}}class wOe{add(t,n,r){let i=this.builderMap.get(t);i||(i=this.source.subsetBuilder(!0),this.builders[this.builders.length]=i,this.builderMap.set(t,i)),i.addToUnit(n,r)}allSingletons(){for(let t=0,n=this.builders.length;t1)return!1;return!0}singletonSelection(){const t=this.source.subsetBuilder(!0),n=nt.create(this.source);for(let r=0,i=this.builders.length;rpt.Sequence(e.inputStructure,[]),UJ=e=>pt.Singletons(e.inputStructure,e.inputStructure);function AOe(e){return QB({...e,groupBy:t=>Ze.residue.key(t.element)})}function IOe(e){return QB({...e,groupBy:t=>Ze.chain.key(t.element)})}function Jh(e){return!0}function TOe(e){return 0}function QB(e){if(!e||!(e.atomTest||e.residueTest||e.chainTest||e.entityTest||e.unitTest||e.groupBy))return UJ;if(e.atomTest&&!e.residueTest&&!e.chainTest&&!e.entityTest&&!e.unitTest&&!e.groupBy)return function DOe(e){return function(n){const{inputStructure:r}=n,{units:i}=r,o=n.pushCurrentElement(),s=r.subsetBuilder(!0);o.structure=r;for(const a of i){o.unit=a;const c=a.elements;s.beginUnit(a.id);for(let u=0,l=c.length;u0?kr.create():this.currentUnit}addElement(t){kr.add(this.currentUnit,t,t)&&this.elementCount++}commitUnit(){0===this.currentUnit.array.length||this.unitMap.has(this.parentId)||(this.ids[this.ids.length]=this.parentId,this.unitMap.set(this.parentId,this.currentUnit),this.parentId=-1)}getStructure(){if(this.isEmpty)return Ve.Empty;const t=[];Ou(this.ids);const n=nf.UnitEquivalenceBuilder();for(let r=0,i=this.ids.length;r1&&Ou(a);let u=s.getChild(je.ofSortedArray(a));const l=n.add(u.id,u);u!==l&&(u=l.applyOperator(u.id,u.conformation.operator,!0)),t[t.length]=u}return Ve.create(t,{parent:this.parent})}get isEmpty(){return 0===this.elementCount}constructor(t){this.parent=t,this.ids=[],this.unitMap=Lu.Mutable(),this.parentId=-1,this.currentUnit=kr.create(),this.elementCount=0}}function ht(e){return{data:e,position:0,length:e.length,lineNumber:1,tokenStart:0,tokenEnd:0}}var He,Fr;function VJ(e){for(;e.position=e.length)return void(e.tokenType=6);e.tokenStart=e.position,e.tokenEnd=e.position,e.isEscaped=!1;const n=e.data.charCodeAt(e.position);switch(n){case 35:(function UOe(e){for(;e.position=5&&95===e.data.charCodeAt(e.tokenStart+4)?function zOe(e){let t=e.data.charCodeAt(e.tokenStart);return!(68!==t&&100!==t||(t=e.data.charCodeAt(e.tokenStart+1),65!==t&&97!==t)||(t=e.data.charCodeAt(e.tokenStart+2),84!==t&&116!==t)||(t=e.data.charCodeAt(e.tokenStart+3),65!==t&&97!==t))}(e)?0:function GOe(e){let t=e.data.charCodeAt(e.tokenStart);return!(83!==t&&115!==t||(t=e.data.charCodeAt(e.tokenStart+1),65!==t&&97!==t)||(t=e.data.charCodeAt(e.tokenStart+2),86!==t&&118!==t)||(t=e.data.charCodeAt(e.tokenStart+3),69!==t&&101!==t))}(e)?1:function jOe(e){if(e.tokenEnd-e.tokenStart!=5)return!1;let t=e.data.charCodeAt(e.tokenStart);return!(76!==t&&108!==t||(t=e.data.charCodeAt(e.tokenStart+1),79!==t&&111!==t)||(t=e.data.charCodeAt(e.tokenStart+2),79!==t&&111!==t)||(t=e.data.charCodeAt(e.tokenStart+3),80!==t&&112!==t))}(e)?2:3:3}}function em(e){for(HJ(e);5===e.tokenType;)HJ(e)}function hT(){return{categoryNames:[],categoryData:Object.create(null)}}function tO(e,t){const n=Object.create(null);for(const r of e){const i=t[r];n[r]=ss(i.name,i.rowCount,i.fieldNames,i.fields)}return n}function qJ(e,t,n){return bB(e.categoryNames,tO(e.categoryNames,e.categoryData),t,n)}function YOe(e,t){return bB(e.categoryNames,tO(e.categoryNames,e.categoryData),t)}function nO(e,t,n,r,i){if(t in e.categoryData){const o=e.categoryData[t];o.fieldNames.push(...r),Object.assign(o.fields,i)}else e.categoryData[t]={name:t,rowCount:n,fieldNames:r,fields:i},e.categoryNames.push(t)}function XOe(e,t){const n=e.tokenStart,r=GJ(e),i=jJ(e,r),o=Object.create(null),s=[];let a=!0;for(;a;){if(4!==e.tokenType||!qOe(e,n,r)){a=!1;break}const c=eO(e).substring(i.length+1);if(em(e),3!==e.tokenType)return{hasError:!0,errorLine:e.lineNumber,errorMessage:"Expected value."};o[c]=ft.ofTokens({data:e.data,indices:[e.tokenStart,e.tokenEnd],count:1}),s[s.length]=c,em(e)}return nO(t,i.substr(1),1,s,o),{hasError:!1,errorLine:0,errorMessage:""}}function KOe(e,t){const{tokenizer:n,tokens:r,fieldCount:i}=t;let o=t.tokenCount,s=0;for(;3===n.tokenType&&s0&&n.push(qJ(o,i,s)),i=e.substring(r.tokenStart+5,r.tokenEnd),o=hT(),s=[],em(r)}else if(1===l){if(r.tokenEnd-r.tokenStart==5)a.categoryNames.length>0&&(s[s.length]=YOe(a,u)),r.inSaveFrame=!1;else{if(r.inSaveFrame)return Zb(r.lineNumber,"Save frames cannot be nested.");r.inSaveFrame=!0,u=e.substring(r.tokenStart+5,r.tokenEnd),a=hT()}em(r)}else if(2===l){const d=yield QOe(r,r.inSaveFrame?a:o);if(d.hasError)return Zb(d.errorLine,d.errorMessage)}else{if(4!==l)return console.log(r.tokenType,ht.getTokenString(r)),Zb(r.lineNumber,"Unexpected token. Expected data_, loop_, or data name.");{const d=XOe(r,r.inSaveFrame?a:o);if(d.hasError)return Zb(d.errorLine,d.errorMessage)}}}return r.inSaveFrame?Zb(r.lineNumber,`Unfinished save frame (${c.header}).`):((o.categoryNames.length>0||s.length>0)&&n.push(qJ(o,i,s)),function JOe(e){return Fr.success(e)}(bQ(n)))}),iO.apply(this,arguments)}function WJ(e){return Oe.create("Parse CIF",function(){var t=ie(function*(n){return yield function e4e(e,t){return iO.apply(this,arguments)}(e,n)});return function(n){return t.apply(this,arguments)}}())}function $J(e){return gT({buffer:e,offset:0,dataView:new DataView(e.buffer)})}function oO(e,t){const n={};for(let r=0;rr.name),getField(r){const i=t[r];if(i)return n[r]||(n[r]=function t4e(e){const t=e.mask?rT(e.mask):void 0,n=rT(e.data),r=WF(n),i=r?t?u=>0===t[u]?""+n[u]:"":u=>""+n[u]:t?u=>0===t[u]?n[u]:"":u=>n[u],o=r?u=>n[u]:u=>{const l=n[u];return jh(l,0,l.length)},s=r?u=>n[u]:u=>{const l=n[u];return rp(l,0,l.length)},c=n.length;return{__array:n,binaryEncoding:e.data.encoding,isDefined:!0,rowCount:c,str:i,int:o,float:s,valueKind:t?u=>t[u]:u=>0,areValuesEqual:(u,l)=>n[u]===n[l],toStringArray:u=>Ps(c,i,u),toIntArray:r?u=>PI(n,u):u=>Ps(c,o,u),toFloatArray:r?u=>PI(n,u):u=>Ps(c,s,u)}}(i)),n[r]}}}function YJ(e){return Oe.create("Parse BinaryCIF",function(){var t=ie(function*(n){const r=[0,3];try{const i=$J(e);if(!function n4e(e,t){for(let n=0;n<2;n++)if(e[n]>t[n])return!1;return!0}(r,i.version.match(/(\d)\.(\d)\.\d/).slice(1).map(s=>+s)))return Fr.error(`Unsupported format version. Current ${i.version}, required ${r.join(".")}.`);const o=bQ(i.dataBlocks.map(s=>{const a=Object.create(null);for(const c of s.categories)a[c.name.substr(1)]=r4e(c);return bB(s.categories.map(c=>c.name.substr(1)),a,s.header)}));return Fr.success(o)}catch(i){return Fr.error(""+i)}});return function(n){return t.apply(this,arguments)}}())}!function(e){function t(_){return _.data.substring(_.tokenStart,_.tokenEnd)}function r(_){const{data:S}=_;for(;_.position<_.length;)switch(S.charCodeAt(_.position)){case 10:return _.tokenEnd=_.position,++_.position,++_.lineNumber,!0;case 13:return _.tokenEnd=_.position,++_.position,++_.lineNumber,10===S.charCodeAt(_.position)&&++_.position,!0;default:++_.position}return _.tokenEnd=_.position,_.tokenStart!==_.tokenEnd}function o(_){return _.tokenStart=_.position,r(_)}function c(_,S,A){let E=0;for(let w=0;w{const T=Math.min(S-D,I);return c(R,T,w),D+=T,T},(I,R)=>I.update({message:"Parsing...",current:R.position,max:R.length})),w})).apply(this,arguments)}function g(){return(g=ie(function*(_,S,A=1e5){const E=e(_),w=He.create(E.data,Math.max(_.length/80,2));return yield op(S,A,E,(D,I)=>(function m(_,S,A){let E=0;for(let w=0;wD.update({message:"Parsing...",current:I.position,max:I.length})),w})).apply(this,arguments)}function x(_,S,A){const{data:E}=_;let w=S,D=A-1,I=E.charCodeAt(w);for(;(9===I||32===I)&&w<=D;)I=E.charCodeAt(++w);for(I=E.charCodeAt(D);(9===I||32===I)&&D>=w;)I=E.charCodeAt(--D);return _.tokenStart=w,_.tokenEnd=D+1,_.position=A,_}e.getTokenString=t,e.reset=function n(_){_.position=0,_.lineNumber=1,_.tokenStart=0,_.tokenEnd=0},e.eatLine=r,e.markStart=function i(_){_.tokenStart=_.position},e.markLine=o,e.readLine=function s(_){return o(_),t(_)},e.readLineTrim=function a(_){o(_);const S=_.position;return x(_,_.tokenStart,_.tokenEnd),_.position=S,t(_)},e.markLines=function u(_,S){const A=He.create(_.data,2*S);return c(_,S,A),A},e.readLines=function l(_,S){const A=[];for(let E=0;Eu.indicesLenMinus2&&function t(s){const a=new Uint32Array(1.61*s.indices.length|0);a.set(s.indices),s.indices=a,s.indicesLenMinus2=a.length-2|0}(u),u.indices[u.offset++]=a,u.indices[u.offset++]=c,s.count++}e.add=n,e.addToken=function r(s,a){n(s,a.tokenStart,a.tokenEnd)},e.addUnchecked=function i(s,a,c){s.indices[s.offset++]=a,s.indices[s.offset++]=c,s.count++},e.create=function o(s,a){return{data:s,indicesLenMinus2:(a=Math.max(10,a))-2|0,count:0,offset:0,indices:new Uint32Array(a)}}}(He||(He={})),function(e){e.error=function t(o,s=-1){return new r(o,s)},e.success=function n(o,s=[]){return new i(o,s)};class r{toString(){return this.line>=0?`[Line ${this.line}] ${this.message}`:this.message}constructor(s,a){this.message=s,this.line=a,this.isError=!0}}e.Error=r;class i{constructor(s,a){this.result=s,this.warnings=a,this.isError=!1}}e.Success=i}(Fr||(Fr={}));var zg=te.Schema;const qr=zg.str,XJ=zg.List,Jd=zg.lstr,pu=zg.Aliased,g2=zg.int,Qb=zg.coord,o4e={chem_comp:{formula:qr,formula_weight:zg.float,id:qr,mon_nstd_parent_comp_id:XJ(",",e=>e),name:qr,one_letter_code:qr,three_letter_code:qr,type:pu(Jd),pdbx_synonyms:XJ(";",e=>e),pdbx_type:qr,pdbx_ambiguous_flag:qr,pdbx_replaced_by:qr,pdbx_replaces:qr,pdbx_formal_charge:g2,pdbx_model_coordinates_details:qr,pdbx_model_coordinates_db_code:qr,pdbx_ideal_coordinates_details:qr,pdbx_ideal_coordinates_missing_flag:pu(Jd),pdbx_model_coordinates_missing_flag:pu(Jd),pdbx_initial_date:qr,pdbx_modified_date:qr,pdbx_release_status:pu(qr),pdbx_processing_site:pu(qr)},chem_comp_atom:{alt_atom_id:qr,atom_id:qr,charge:g2,model_Cartn_x:Qb,model_Cartn_y:Qb,model_Cartn_z:Qb,comp_id:qr,type_symbol:qr,pdbx_align:g2,pdbx_ordinal:g2,pdbx_model_Cartn_x_ideal:Qb,pdbx_model_Cartn_y_ideal:Qb,pdbx_model_Cartn_z_ideal:Qb,pdbx_stereo_config:pu(Jd),pdbx_aromatic_flag:pu(Jd),pdbx_leaving_atom_flag:pu(Jd)},chem_comp_bond:{atom_id_1:qr,atom_id_2:qr,comp_id:qr,value_order:pu(Jd),pdbx_ordinal:g2,pdbx_stereo_config:pu(Jd),pdbx_aromatic_flag:pu(Jd)},pdbx_chem_comp_descriptor:{comp_id:qr,descriptor:qr,type:pu(Jd),program:qr,program_version:qr},pdbx_chem_comp_identifier:{comp_id:qr,identifier:qr,type:pu(qr),program:qr,program_version:qr}};var y2=te.Schema;const mn=y2.str,hp=y2.lstr,Xa=y2.Aliased,Wu=y2.int,a4e={pdbx_reference_molecule:{prd_id:mn,formula_weight:y2.float,formula:mn,type:Xa(hp),type_evidence_code:mn,class:Xa(hp),class_evidence_code:mn,name:mn,represent_as:Xa(hp),chem_comp_id:mn,compound_details:mn,description:mn,representative_PDB_id_code:mn,release_status:Xa(hp),replaces:mn,replaced_by:mn},pdbx_reference_entity_list:{prd_id:mn,ref_entity_id:mn,type:Xa(hp),details:mn,component_id:Wu},pdbx_reference_entity_nonpoly:{prd_id:mn,ref_entity_id:mn,name:mn,chem_comp_id:mn},pdbx_reference_entity_link:{link_id:Wu,prd_id:mn,details:mn,ref_entity_id_1:mn,ref_entity_id_2:mn,entity_seq_num_1:Wu,entity_seq_num_2:Wu,comp_id_1:mn,comp_id_2:mn,atom_id_1:mn,atom_id_2:mn,value_order:Xa(hp),component_1:Wu,component_2:Wu,link_class:Xa(mn)},pdbx_reference_entity_poly_link:{link_id:Wu,prd_id:mn,ref_entity_id:mn,component_id:Wu,entity_seq_num_1:Wu,entity_seq_num_2:Wu,comp_id_1:mn,comp_id_2:mn,atom_id_1:mn,atom_id_2:mn,value_order:Xa(hp)},pdbx_reference_entity_poly:{prd_id:mn,ref_entity_id:mn,type:Xa(mn),db_code:mn,db_name:mn},pdbx_reference_entity_poly_seq:{prd_id:mn,ref_entity_id:mn,mon_id:mn,parent_mon_id:mn,num:Wu,observed:Xa(hp),hetero:Xa(hp)},pdbx_reference_entity_sequence:{prd_id:mn,ref_entity_id:mn,type:Xa(mn),NRP_flag:Xa(mn),one_letter_codes:mn},pdbx_reference_entity_src_nat:{prd_id:mn,ref_entity_id:mn,ordinal:Wu,organism_scientific:mn,taxid:mn,db_code:mn,db_name:mn},pdbx_prd_audit:{prd_id:mn,date:mn,processing_site:Xa(mn),action_type:Xa(mn)}};var KJ=te.Schema;const Eo=KJ.str,u4e={datablock:{id:Eo,description:Eo},dictionary:{title:Eo,datablock_id:Eo,version:Eo},dictionary_history:{version:Eo,update:Eo,revision:Eo},sub_category:{id:Eo,description:Eo},category_group_list:{id:Eo,parent_id:Eo,description:Eo},item_type_list:{code:Eo,primitive_code:Eo,construct:Eo,detail:Eo},item_units_list:{code:Eo,detail:Eo},item_units_conversion:{from_code:Eo,to_code:Eo,operator:Eo,factor:KJ.float}};var b2=te.Schema;const ef=b2.str,yT=b2.int,mp=b2.float,bT=b2.Aliased,tm=b2.Vector,ZJ=(bT(ef),bT(ef),bT(ef),bT(ef),tm(3),tm(3),{volume_data_3d_info:{name:ef,axis_order:tm(3,yT),origin:tm(3),dimensions:tm(3),sample_rate:yT,sample_count:tm(3,yT),spacegroup_number:yT,spacegroup_cell_size:tm(3),spacegroup_cell_angles:tm(3),mean_source:mp,mean_sampled:mp,sigma_source:mp,sigma_sampled:mp,min_source:mp,min_sampled:mp,max_source:mp,max_sampled:mp},volume_data_3d:{values:mp}});var vT=te.Schema;const ro=vT.float,cO=vT.int,ti=vT.str,d4e={cell:{angle_alpha:ro,angle_beta:ro,angle_gamma:ro,formula_units_z:cO,length_a:ro,length_b:ro,length_c:ro,volume:ro},chemical:{melting_point:ro,name_common:ti,name_systematic:ti},chemical_formula:{moiety:ti,sum:ti,weight:ro},space_group:{crystal_system:ti,it_number:cO,"name_h-m_full":ti},space_group_symop:{operation_xyz:ti},geom_bond:{atom_site_label_1:ti,atom_site_label_2:ti,distance:ro,publ_flag:ti,site_symmetry_1:ti,site_symmetry_2:ti,valence:ro},audit:{block_doi:ti},database_code:{cod:ti,csd:ti,depnum_ccdc_archive:ti,depnum_ccdc_fiz:ti,icsd:ti,mdf:ti,nbs:ti},atom_site:{adp_type:ti,calc_flag:ti,disorder_assembly:ti,disorder_group:ti,fract_x:ro,fract_y:ro,fract_z:ro,label:ti,occupancy:ro,refinement_flags:ti,site_symmetry_multiplicity:cO,type_symbol:ti,u_iso_or_equiv:ro},atom_site_aniso:{label:ti,u_11:ro,u:(0,vT.Matrix)(3,3),u_12:ro,u_13:ro,u_22:ro,u_23:ro,u_33:ro},atom_type:{description:ti,symbol:ti},atom_type_scat:{dispersion_imag:ro,dispersion_real:ro,source:ti}},f4e={"cell.formula_units_z":["cell_formula_units_Z"],"space_group.it_number":["space_group_IT_number","symmetry_Int_Tables_number"],"space_group.name_h-m_full":["symmetry_space_group_name_H-M"],"space_group_symop.operation_xyz":["symmetry_equiv_pos_as_xyz"],"geom_bond.atom_site_label_1":["geom_bond_atom_site_id_1"],"geom_bond.atom_site_label_2":["geom_bond_atom_site_id_2"],"geom_bond.distance":["geom_bond_dist"],"audit.block_doi":["audit_block_DOI"],"database_code.cod":["database_code_COD"],"database_code.csd":["database_code_CSD"],"database_code.depnum_ccdc_archive":["database_code_depnum_CCDC_archive"],"database_code.depnum_ccdc_fiz":["database_code_depnum_CCDC_fiz"],"database_code.icsd":["database_code_ICSD"],"database_code.mdf":["database_code_MDF"],"database_code.nbs":["database_code_NBS"],"atom_site.adp_type":["atom_site_ADP_type","atom_site_thermal_displace_type"],"atom_site.label":["atom_site_id"],"atom_site.site_symmetry_multiplicity":["atom_site_symmetry_multiplicity"],"atom_site.u_iso_or_equiv":["atom_site_U_iso_or_equiv"],"atom_site_aniso.label":["atom_site_anisotrop_id"],"atom_site_aniso.u_11":["atom_site_aniso_U_11","atom_site_anisotrop_U_11"],"atom_site_aniso.u_12":["atom_site_aniso_U_12","atom_site_anisotrop_U_12"],"atom_site_aniso.u_13":["atom_site_aniso_U_13","atom_site_anisotrop_U_13"],"atom_site_aniso.u_22":["atom_site_aniso_U_22","atom_site_anisotrop_U_22"],"atom_site_aniso.u_23":["atom_site_aniso_U_23","atom_site_anisotrop_U_23"],"atom_site_aniso.u_33":["atom_site_aniso_U_33","atom_site_anisotrop_U_33"]},uO=te.Schema.int,h4e={volume_data_3d_info:ZJ.volume_data_3d_info,segmentation_data_table:{set_id:uO,segment_id:uO},segmentation_data_3d:{values:uO}},od={parse:e=>"string"==typeof e?WJ(e):YJ(e),parseText:WJ,parseBinary:YJ,toDatabaseCollection:function Ike(e,t,n){const r={};for(const i of t.blocks)r[i.header]=Zd(e,i,n);return r},toDatabase:Zd,schema:{mmCIF:e=>Zd(On,e),CCD:e=>Zd(o4e,e),BIRD:e=>Zd(a4e,e),dic:e=>Zd(u4e,e),cifCore:e=>Zd(d4e,e,f4e),densityServer:e=>Zd(ZJ,e),segmentation:e=>Zd(h4e,e)}},m4e={type_symbol:te.Schema.Aliased(On.atom_site.type_symbol),label_atom_id:On.atom_site.label_atom_id,auth_atom_id:On.atom_site.auth_atom_id,label_alt_id:On.atom_site.label_alt_id,label_comp_id:On.atom_site.label_comp_id,auth_comp_id:On.atom_site.auth_comp_id,pdbx_formal_charge:On.atom_site.pdbx_formal_charge},g4e={group_PDB:On.atom_site.group_PDB,label_seq_id:On.atom_site.label_seq_id,auth_seq_id:On.atom_site.auth_seq_id,pdbx_PDB_ins_code:On.atom_site.pdbx_PDB_ins_code},y4e={label_asym_id:On.atom_site.label_asym_id,auth_asym_id:On.atom_site.auth_asym_id,label_entity_id:On.atom_site.label_entity_id};var lO,Gg;!function(e){e.EmptyResidueKey=function t(){return{label_entity_id:"",label_asym_id:"",auth_seq_id:0,pdbx_PDB_ins_code:void 0}}}(lO||(lO={})),function(e){function t(i,o){return i.residueAtomSegments.index[i.chainAtomSegments.offsets[o]]}function n(i,o){return i.residueAtomSegments.index[i.chainAtomSegments.offsets[o+1]-1]+1}e.chainStartResidueIndex=t,e.chainEndResidueIndexExcl=n,e.chainResidueCount=function r(i,o){return n(i,o)-t(i,o)}}(Gg||(Gg={}));const _T={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},b4e={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},v4e={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},_4e=1.7,S4e=0;function v2(e){const t=_T[e];return void 0===t?_4e:b4e[t]}function _2(e){const t=_T[e];return void 0===t?S4e:t}function QJ(e,t,n,r){return{type:e,key:t,elements:n,getIndex:r}}var jg;function T4e(e,t,n,r,i,o){const{auth_seq_id:s,label_seq_id:a,pdbx_PDB_ins_code:c}=e.residues,{endSeqId:u,endInsCode:l,key:d,type:f}=n,p="label"===t?a:s;let m=r;for(;mu||h===u&&c.value(m)===l)break;m++}}!function(e){e.Descriptor={name:"model_secondary_structure"},e.Provider=td.create(e.Descriptor),e.fromStruct=function t(n,r,i){const o=new Map,s=[{kind:"none"}],a=function w4e(e,t){if(e._rowCount>0){if(0!==e.beg_label_seq_id.valueKind(0)||0!==e.end_label_seq_id.valueKind(0))return"auth"}else if(t&&(0!==t.beg_label_seq_id.valueKind(0)||0!==t.end_label_seq_id.valueKind(0)))return"auth";return"label"}(n,r);(function A4e(e,t,n,r){if(!e._rowCount)return;const{beg_label_asym_id:i,beg_label_seq_id:o,beg_auth_seq_id:s,pdbx_beg_PDB_ins_code:a}=e,{end_label_seq_id:c,end_auth_seq_id:u,pdbx_end_PDB_ins_code:l}=e,{pdbx_PDB_helix_class:d,conf_type_id:f,details:p}=e,m="label"===t?o:s,h="label"===t?c:u;for(let g=0,y=e._rowCount;g0&&function D4e(e,t,n,r){const{count:i}=e.chainAtomSegments,{label_asym_id:o}=e.chains,{auth_seq_id:s,label_seq_id:a,pdbx_PDB_ins_code:c}=e.residues,u="label"===t?a:s;for(let l=0;ld)}}(jg||(jg={}));const E4e={U:On.atom_site_anisotrop.U,U_esd:On.atom_site_anisotrop.U_esd};var tf,Hg;!function(e){e.Schema=E4e,e.Descriptor={name:"atom_site_anisotrop",cifExport:{prefix:"",categories:[{name:"atom_site_anisotrop",instance:r=>e.Provider.get(r.firstModel)&&Er.is(r.firstModel.sourceData)?Bi.Category.ofTable(r.firstModel.sourceData.data.db.atom_site_anisotrop):Bi.Category.Empty}]}},e.Provider=td.create(e.Descriptor),e.getElementToAnsiotrop=function t(r,i){const o=new Int32Array(r.rowCount);o.fill(-1);for(let a=0,c=r.rowCount;a0},e.writeMmCif=function s(a,c){a.writeCategory({name:t,instance(){const u=Xn.ofRows(e.Schema.molstar_global_model_transform_info,[{matrix:c}]);return Bi.Category.ofTable(u)}})}}(Hg||(Hg={})),te.Schema.Str();const P4e={...On.chem_comp,type:te.Schema.Aliased(te.Schema.str)};function M4e(e,t){const{ihm_model_group:n,ihm_model_group_link:r}=t,i=Xn.pickRow(r,o=>r.model_id.value(o)===e);if(i){const o=Xn.pickRow(n,s=>n.id.value(s)===i.group_id);if(o)return o.name}return""}function JJ(e){for(let t=0,n=e.rowCount;tthis.namesMap.set(n[0],n[1]))}}const k4e=[new Set(["CA"]),new Set(["C"]),new Set(["N"])],N4e=[new Set(["P","O3'","O3*"]),new Set(["C4'","C4*"]),new Set(["O2'","O2*","F2'","F2*"])],F4e=[new Set(["P","O3'","O3*"]),new Set(["C3'","C3*"]),new Set(["O2'","O2*","F2'","F2*"])],B4e=new Set(["FMN","NCN","FNS","FMA","ATP","ADP","AMP","GTP","GDP","GMP","LIG"]),eee=function(){const e=new Map;return[{id:"HIS",name:"HISTIDINE",type:"l-peptide linking"},{id:"ARG",name:"ARGININE",type:"l-peptide linking"},{id:"LYS",name:"LYSINE",type:"l-peptide linking"},{id:"ILE",name:"ISOLEUCINE",type:"l-peptide linking"},{id:"PHE",name:"PHENYLALANINE",type:"l-peptide linking"},{id:"LEU",name:"LEUCINE",type:"l-peptide linking"},{id:"TRP",name:"TRYPTOPHAN",type:"l-peptide linking"},{id:"ALA",name:"ALANINE",type:"l-peptide linking"},{id:"MET",name:"METHIONINE",type:"l-peptide linking"},{id:"CYS",name:"CYSTEINE",type:"l-peptide linking"},{id:"ASN",name:"ASPARAGINE",type:"l-peptide linking"},{id:"VAL",name:"VALINE",type:"l-peptide linking"},{id:"GLY",name:"GLYCINE",type:"peptide linking"},{id:"SER",name:"SERINE",type:"l-peptide linking"},{id:"GLN",name:"GLUTAMINE",type:"l-peptide linking"},{id:"TYR",name:"TYROSINE",type:"l-peptide linking"},{id:"ASP",name:"ASPARTIC ACID",type:"l-peptide linking"},{id:"GLU",name:"GLUTAMIC ACID",type:"l-peptide linking"},{id:"THR",name:"THREONINE",type:"l-peptide linking"},{id:"PRO",name:"PROLINE",type:"l-peptide linking"},{id:"SEC",name:"SELENOCYSTEINE",type:"l-peptide linking"},{id:"PYL",name:"PYRROLYSINE",type:"l-peptide linking"},{id:"MSE",name:"SELENOMETHIONINE",type:"l-peptide linking"},{id:"SEP",name:"PHOSPHOSERINE",type:"l-peptide linking"},{id:"TPO",name:"PHOSPHOTHREONINE",type:"l-peptide linking"},{id:"PTR",name:"O-PHOSPHOTYROSINE",type:"l-peptide linking"},{id:"PCA",name:"PYROGLUTAMIC ACID",type:"l-peptide linking"},{id:"A",name:"ADENOSINE-5'-MONOPHOSPHATE",type:"rna linking"},{id:"C",name:"CYTIDINE-5'-MONOPHOSPHATE",type:"rna linking"},{id:"T",name:"THYMIDINE-5'-MONOPHOSPHATE",type:"rna linking"},{id:"G",name:"GUANOSINE-5'-MONOPHOSPHATE",type:"rna linking"},{id:"I",name:"INOSINIC ACID",type:"rna linking"},{id:"U",name:"URIDINE-5'-MONOPHOSPHATE",type:"rna linking"},{id:"DA",name:"2'-DEOXYADENOSINE-5'-MONOPHOSPHATE",type:"dna linking"},{id:"DC",name:"2'-DEOXYCYTIDINE-5'-MONOPHOSPHATE",type:"dna linking"},{id:"DT",name:"THYMIDINE-5'-MONOPHOSPHATE",type:"dna linking"},{id:"DG",name:"2'-DEOXYGUANOSINE-5'-MONOPHOSPHATE",type:"dna linking"},{id:"DI",name:"2'-DEOXYINOSINE-5'-MONOPHOSPHATE",type:"dna linking"},{id:"DU",name:"2'-DEOXYURIDINE-5'-MONOPHOSPHATE",type:"dna linking"}].forEach(n=>e.set(n.id,n)),e}(),tee=function(){const e=new Map;return[{id:"ZN2",name:"ZINC ION",type:"ion"},{id:"SOD",name:"SODIUM ION",type:"ion"},{id:"CES",name:"CESIUM ION",type:"ion"},{id:"CLA",name:"CHLORIDE ION",type:"ion"},{id:"CAL",name:"CALCIUM ION",type:"ion"},{id:"POT",name:"POTASSIUM ION",type:"ion"}].forEach(n=>e.set(n.id,n)),e}();class ad{set(t){this.comps.set(t.id,t),this.ids.push(t.id),this.names.push(t.name),this.types.push(t.type),this.mon_nstd_flags.push($b.has(t.id)?"y":"n")}getAtomIds(t){const n=new Set,r=this.seqId.value(t);for(;tthis.namesMap.set(n[0],n[1]))}constructor(t,n){this.seqId=t,this.atomId=n,this.namesMap=new Map,this.comps=new Map,this.ids=[],this.names=[],this.types=[],this.mon_nstd_flags=[]}}var Er,x2;function dO(e,t){const n=Er.fromFrame(e,void 0,void 0,t),r=$u(n.data.db,!0);return Oe.create("Create mmCIF Model",i=>af(r,n,i))}function fO(){return fO=ie(function*(e,t,n){const r=yield nee(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"},n),i=yield nee(e,t,{coordinateType:"model",cartn_x:"model_Cartn_x",cartn_y:"model_Cartn_y",cartn_z:"model_Cartn_z"},n),o=[];r&&o.push(r),i&&o.push(i);for(let s=0,a=o.length;s0||(x[x.length]=O);const _=x.length,S=te.ofConst("A",_,te.Schema.str),A=te.ofConst(1,_,te.Schema.int),E=te.ofConst("1",_,te.Schema.str),w=te.ofConst(1,_,te.Schema.float),D=te.ofConst(1,_,te.Schema.int),I=te.view(p,x),R=te.view(h,x),T=te.view(o[c],x),M=te.view(o[u],x),N=te.view(o[l],x),V=te.view(g,x),F=te.view(y,x),G=te.view(m,x),L=Xn.ofPartialColumns(ks.atom_site,{auth_asym_id:S,auth_atom_id:I,auth_comp_id:R,auth_seq_id:A,Cartn_x:T,Cartn_y:M,Cartn_z:N,id:V,label_asym_id:S,label_atom_id:I,label_comp_id:R,label_seq_id:A,label_entity_id:E,occupancy:w,type_symbol:F,pdbx_PDB_model_num:D,pdbx_formal_charge:G},_),z=new sd;z.setNames([[f,`${d} (${a})`]]),z.getEntityId(f,0,"A");const j=new ad(A,y);j.setNames([[f,`${d} (${a})`]]),j.add(f,0);const Z=$u({entity:z.getEntityTable(),chem_comp:j.getChemCompTable(),atom_site:L}),$=yield af(Z,t,r);if(!$.representative)return;const ee=$.representative,q=Ug.getEntriesFromChemCompBond(s);return Ug.Provider.set(ee,{data:s,entries:q}),x2.CoordinateType.set(ee,a),$.representative}),pO.apply(this,arguments)}no.Provider.formatRegistry.add("mmCIF",function O4e(e){if(Er.is(e.sourceData))return no.fromData(e.sourceData.data.db)}),jg.Provider.formatRegistry.add("mmCIF",function L4e(e){if(!Er.is(e.sourceData))return;const{struct_conf:t,struct_sheet_range:n}=e.sourceData.data.db;return jg.fromStruct(t,n,e.atomicHierarchy)}),tf.Provider.formatRegistry.add("mmCIF",function U4e(e){if(!Er.is(e.sourceData))return;const{atom_site_anisotrop:t}=e.sourceData.data.db;return{data:Xn.ofColumns(tf.Schema,t),elementToAnsiotrop:tf.getElementToAnsiotrop(e.atomicConformation.atomId,t.id)}},function V4e(e){return!!Er.is(e.sourceData)&&e.sourceData.data.db.atom_site_anisotrop.U.isDefined}),Ug.Provider.formatRegistry.add("mmCIF",function z4e(e){if(!Er.is(e.sourceData))return;const{chem_comp_bond:t}=e.sourceData.data.db;return 0!==t._rowCount?{data:t,entries:Ug.getEntriesFromChemCompBond(t)}:void 0}),du.Provider.formatRegistry.add("mmCIF",function G4e(e){if(!Er.is(e.sourceData))return;const{struct_conn:t}=e.sourceData.data.db;if(0===t._rowCount)return;const n=du.getEntriesFromStructConn(t,e);return{data:t,byAtomIndex:du.getAtomIndexFromEntries(n),entries:n}}),Hg.Provider.formatRegistry.add("mmCIF",Hg.fromMmCif,Hg.hasData),function(e){e.is=function t(r){return"mmCIF"===r?.kind},e.fromFrame=function n(r,i,o,s){return i||(i=od.schema.mmCIF(r)),{kind:"mmCIF",name:i._name,data:{db:i,file:s,frame:r,source:o}}}}(Er||(Er={})),function(e){const t="__CcdCoordinateType__";e.CoordinateType={get:i=>i._staticPropertyData[t],set:(i,o)=>i._staticPropertyData[t]=o},e.is=function n(i){return"CCD"===i?.kind},e.fromFrame=function r(i,o){return o||(o=od.schema.CCD(i)),{kind:"CCD",name:o._name,data:{db:o,frame:i}}}}(x2||(x2={}));const qg=typeof process<"u"&&null!=process.versions&&null!=process.versions.node,S2=function q4e(){return typeof XMLHttpRequest>"u"||qg?Fn(684):XMLHttpRequest}(),hO=function W4e(){if(typeof File>"u"||qg){class e{arrayBuffer(){return this.blob.arrayBuffer()}slice(n,r,i){return this.blob.slice(n,r,i)}stream(){return this.blob.stream()}text(){return this.blob.text()}constructor(n,r,i){var o;this.blob=new Blob(n,i),this.size=this.blob.size,this.type=this.blob.type,this.name=r,this.lastModified=null!==(o=i?.lastModified)&&void 0!==o?o:0,this.webkitRelativePath=""}}return e}return File}();function gp(e,t){return e[t]|e[t+1]<<8}function Wg(e,t,n){e[t]=255&n,e[t+1]=n>>8&255}function $g(e,t){return 16777216*e[t+3]+(e[t+2]<<16|e[t+1]<<8|e[t])}function yp(e,t,n){e[t]=255&n,e[t+1]=n>>8&255,e[t+2]=n>>16&255,e[t+3]=n>>24&255}function X4e(e){return e.length<2?"0"+e:e}function ree(e){const t=e.length;let n=0;for(let r=0;r>>1:n>>>=1;e[t]=n}return e}();function iee(e,t,n){return 4294967295^function J4e(e,t,n,r){for(let i=0;i>>8;return e}(4294967295,e,t,n)}const mt=function(){const 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 C2(e,t,n){const r=e.length,i=mt.rev15;for(let o=0;o>1<<4|a,u=t-a;let l=e[o]<>>15-t]=c,l++}}function nm(e,t){const n=e.length,r=mt.bl_count;for(let s=0;s<=t;s++)r[s]=0;for(let s=1;s>>r}function tLe(e,t){const{data:n,noBuf:r}=e;let{buf:i,BFINAL:o,off:s,pos:a}=e,c=0;for(;0===o&&cy&&(y=S)}a+=3*g,nm(mt.itree,y),C2(mt.itree,y,mt.imap),u=mt.lmap,l=mt.dmap,a=rLe(mt.imap,(1<>>4;if(h>>>8){if(256===h)break;{let g=s+h-254;if(h>264){const S=mt.ldef[h-257];g=s+(S>>>3)+rm(n,a,7&S),a+=7&S}const y=l[bO(n,a)&f];a+=15&y;const x=mt.ddef[y>>>4],_=(x>>>4)+yO(n,a,15&x);for(a+=15&x,r&&(i=gO(i,s+(1<<17)));s>>3),h=n[m-4]|n[m-3]<<8;r&&(i=gO(i,s+h)),i.set(new Uint8Array(n.buffer,n.byteOffset+m,h),s),a=m+h<<3,s+=h}}e.buf=i,e.BFINAL=o,e.off=s,e.pos=a}function mO(){return mO=ie(function*(e,t,n){if(3===t[0]&&0===t[1])return n||new Uint8Array(0);const r=function eLe(e,t){const n=void 0===t;return void 0===t&&(t=new Uint8Array(e.length>>>2<<3)),{data:e,buf:t,noBuf:n,BFINAL:0,off:0,pos:0}}(t,n);for(;0===r.BFINAL;)e.shouldUpdate&&(yield e.update({message:"Inflating blocks...",current:r.pos,max:t.length})),tLe(r,100);return r.buf.length===r.off?r.buf:r.buf.slice(0,r.off)}),mO.apply(this,arguments)}function gO(e,t){const n=e.length;if(t<=n)return e;const r=new Uint8Array(Math.max(n<<1,t));return r.set(e,0),r}function rLe(e,t,n,r,i,o){let s=0;for(;s>>4;if(c<=15)o[s]=c,s++;else{let u=0,l=0;16===c?(l=3+rm(r,i,2),i+=2,u=o[s-1]):17===c?(l=3+rm(r,i,3),i+=3):18===c&&(l=11+rm(r,i,7),i+=7);const d=s+l;for(;s>>1;for(;oi&&(i=a),o++}for(;o>>3]|e[1+(t>>>3)]<<8)>>>(7&t)&(1<>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)&(1<>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)}function vO(e,t,n){const r=[],i=e.length,o=t.length;for(let m=0;mn&&(function iLe(e,t,n){let r=0,i=0;const o=1<t;r++){const s=e[r].d;e[r].d=t,i+=o-(1<>>=n-t;i>0;){const s=e[r].d;s=0;r--)e[r].d===t&&i<0&&(e[r].d--,i++);0!==i&&console.log("debt left")}(a,n,p),p=n);for(let m=0;m14e3||l>26697)&&r-s>100&&(c>>16,S=65535&x,A=lee(_,mt.of0);mt.lhst[257+A]++;const E=lee(S,mt.df0);mt.dhst[E]++,f+=mt.exb[A]+mt.dxb[E],h[u]=_<<23|s-c,h[u+1]=S<<16|A<<8|E,u+=2,c=s+_}else mt.lhst[n[s]]++;l++}}e.i=s,e.pos=a,e.cvrd=c,e.li=u,e.lc=l,e.bs=d,e.ebits=f,e.c=p,e.nc=m}!function(){for(let n=0;n<32768;n++){let r=n;r=(2863311530&r)>>>1|(1431655765&r)<<1,r=(3435973836&r)>>>2|(858993459&r)<<2,r=(4042322160&r)>>>4|(252645135&r)<<4,r=(4278255360&r)>>>8|(16711935&r)<<8,mt.rev15[n]=(r>>>16|r<<16)>>>17}function t(n,r,i){for(;0!=r--;)n.push(0,i)}for(let n=0;n<32;n++)mt.ldef[n]=mt.of0[n]<<3|mt.exb[n],mt.ddef[n]=mt.df0[n]<<4|mt.dxb[n];t(mt.fltree,144,8),t(mt.fltree,112,9),t(mt.fltree,24,7),t(mt.fltree,8,8),nm(mt.fltree,9),C2(mt.fltree,9,mt.flmap),w2(mt.fltree,9),t(mt.fdtree,32,5),nm(mt.fdtree,5),C2(mt.fdtree,5,mt.fdmap),w2(mt.fdtree,5),t(mt.itree,19,0),t(mt.ltree,286,0),t(mt.dtree,30,0),t(mt.ttree,320,0)}();const aLe=[[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 xO(){return xO=ie(function*(e,t,n,r,i){const o=function oLe(e,t,n,r){const{lits:i,strt:o,prev:s}=mt;return{data:e,out:t,opt:aLe[r],i:0,pos:n<<3,cvrd:0,dlen:e.length,li:0,lc:0,bs:0,ebits:0,c:0,nc:0,lits:i,strt:o,prev:s}}(t,n,r,i),{dlen:s}=o;if(0===i){let{i:m,pos:h}=o;for(;m>>3}for(s>2&&(o.nc=SO(t,0),o.strt[o.nc]=0);o.i>>3}),xO.apply(this,arguments)}function uLe(e,t,n,r,i,o){let s=32767&t,a=n[s],c=s-a+32768&32767;if(a===s||r!==SO(e,t-c))return 0;let u=0,l=0;const d=Math.min(32767,t);for(;c<=d&&0!=--o&&a!==s;){if(0===u||e[t+u]===e[t+u-c]){let f=lLe(e,t,c);if(f>u){if(u=f,l=c,u>=i)break;c+2p&&(p=y,a=h)}}}s=a,a=n[s],c+=s-a+32768&32767}return u<<16|l}function lLe(e,t,n){if(e[t]!==e[t-n]||e[t+1]!==e[t+1-n]||e[t+2]!==e[t+2-n])return 0;const r=t,i=Math.min(e.length,t+258);for(t+=3;t4&&0===mt.itree[1+(mt.ordr[a-1]<<1)];)a--;return[e,t,s,r,o,a,n,i]}(),y=32+(c+3&7?8-(c+3&7):0)+(s<<3),b=r+A2(mt.fltree,mt.lhst)+A2(mt.fdtree,mt.dhst);let x=r+A2(mt.ltree,mt.lhst)+A2(mt.dtree,mt.dhst);x+=14+3*m+A2(mt.itree,mt.ihst)+(2*mt.ihst[16]+3*mt.ihst[17]+7*mt.ihst[18]);for(let S=0;S<286;S++)mt.lhst[S]=0;for(let S=0;S<30;S++)mt.dhst[S]=0;for(let S=0;S<19;S++)mt.ihst[S]=0;const _=y>>23,R=E+(8388607&D);for(;E>16,N=T>>8&255,V=255&T;Yg(a,c=I2(257+N,S,a,c),I-mt.of0[N]),ST(a,c=I2(V,A,a,c+=mt.exb[N]),M-mt.df0[V]),c+=mt.dxb[V],E+=I}}c=I2(256,S,a,c)}return c}function aee(e,t,n,r,i){let o=i>>>3;return r[o]=n,r[o+1]=n>>>8,r[o+2]=255-r[o],r[o+3]=255-r[o+1],o+=4,r.set(new Uint8Array(e.buffer,t,n),o),i+(n+4<<3)}function A2(e,t){let n=0;for(let r=0;r15&&(Yg(n,r,s),r+=a)}return r}function uee(e,t){let n=e.length;for(;2!==n&&0===e[n-1];)n-=2;for(let r=0;r>>1,138);u<11?t.push(17,u-3):t.push(18,u-11),r+=2*u-2}else if(i===a&&o===i&&s===i){let c=r+5;for(;c+2>>1,6);t.push(16,u-3),r+=2*u-2}else t.push(i,0)}return n>>>1}function lee(e,t){let n=0;return t[16|n]<=e&&(n|=16),t[8|n]<=e&&(n|=8),t[4|n]<=e&&(n|=4),t[2|n]<=e&&(n|=2),t[1|n]<=e&&(n|=1),n}function I2(e,t,n,r){return ST(n,r,t[e<<1]),r+t[1+(e<<1)]}function Yg(e,t,n){const r=t>>>3;e[r]|=n<<=7&t,e[r+1]|=n>>>8}function ST(e,t,n){const r=t>>>3;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16}function T2(e,t){return CO.apply(this,arguments)}function CO(){return CO=ie(function*(e,t,n=!1){const r=Object.create(null),i=new Uint8Array(t);if(19280!==gp(i,0))throw new Error('Invalid ZIP file. A valid ZIP file must start with two magic bytes \\x50\\x4b ("PK" in ASCII).');let o=i.length-4;for(;101010256!==$g(i,o);)o--;let s=o;s+=4,s+=4;const a=gp(i,s);s+=2,s+=2,s+=4;const c=$g(i,s);s+=4,s=c;for(let u=0;u>18,e[t+i+1]=128|s>>12&63,e[t+i+2]=128|s>>6&63,e[t+i+3]=128|63&s,i+=4}else e[t+i]=224|s>>12,e[t+i+1]=128|s>>6&63,e[t+i+2]=128|63&s,i+=3;else e[t+i]=192|s>>6,e[t+i+1]=128|63&s,i+=2;else e[t+i]=s,i++}return i}(e,t,n);return t+=a,0===i&&(e.set(s,t),t+=s.length),t}var Yu=function(e){return e[e.None=0]="None",e[e.Gzip=1]="Gzip",e[e.Zip=2]="Zip",e}(Yu||{});function bp(e,t){return function NO(e,t){if(qg)return function xLe(e,t){return Oe.create("Read File",function(){var n=ie(function*(r){const i="zip"===t?Yu.None:hee(e.name);let o;return yield r.update({message:"Opening file...",canAbort:!1}),o="binary"===t||"zip"===t||i!==Yu.None?yield e.arrayBuffer():yield e.text(),yield r.update({message:"Processing file...",canAbort:!1}),yield mee(r,o,t,i)});return function(r){return n.apply(this,arguments)}}())}(e,t);let n;return Oe.create("Read File",function(){var r=ie(function*(i){try{n=new FileReader;const o="zip"===t?Yu.None:hee(e.name);"binary"===t||"zip"===t||o!==Yu.None?n.readAsArrayBuffer(e):n.readAsText(e),yield i.update({message:"Opening file...",canAbort:!0});const s=yield pee(i,"Reading...",n);return yield i.update({message:"Processing file...",canAbort:!1}),yield mee(i,s.result,t,o)}finally{n=void 0}});return function(i){return r.apply(this,arguments)}}(),()=>{n&&n.abort()})}(e,t)}function MO(e){return"string"==typeof e?gee(e,e,"string"):gee(e.title,e.url,e.type||"string",e.body,e.headers)}function fee(e){return e?"Failed to download data. Possible reasons: Resource is not available, or CORS is not allowed on the server.":"Failed to open file."}function pee(e,t,n){return new Promise((r,i)=>{if(function bLe(e){if(!qg&&e instanceof FileReader)return e.readyState===FileReader.DONE;if(e instanceof S2)return e.readyState===S2.DONE;throw new Error("unknown data type")}(n)){const{error:s}=n;return void(null!=s?i(s??fee(n instanceof S2)):r(n))}let o=!1;n.onerror=s=>{if(o)return;const{error:a}=s.target;i(a??fee(n instanceof S2))},n.onprogress=s=>{if(e.shouldUpdate&&!o)try{e.update(s.lengthComputable?{message:t,isIndeterminate:!1,current:s.loaded,max:s.total}:{message:`${t} ${(s.loaded/1024/1024).toFixed(2)} MB`,isIndeterminate:!0})}catch(a){o=!0,i(a)}},n.onload=s=>{r(n)}})}function hee(e){return/\.gz$/i.test(e)?Yu.Gzip:/\.zip$/i.test(e)?Yu.Zip:Yu.None}const vLe=/^(__MACOSX|.DS_Store)/;function RO(){return RO=ie(function*(e,t,n){switch(n){case Yu.None:return t;case Yu.Gzip:return function pLe(e,t,n){return TO.apply(this,arguments)}(e,t);case Yu.Zip:const r=yield T2(e,t.buffer),i=Object.keys(r).filter(o=>!vLe.test(o));if(1!==i.length)throw new Error("can only decompress zip files with a single entry");return r[i[0]]}}),RO.apply(this,arguments)}function mee(e,t,n,r){return kO.apply(this,arguments)}function kO(){return kO=ie(function*(e,t,n,r){let i=t instanceof ArrayBuffer?new Uint8Array(t):t;if(null===i)throw new Error("no data given");if(r!==Yu.None){if(!(i instanceof Uint8Array))throw new Error("need Uint8Array for decompression");const o=yield function _Le(e,t,n){return RO.apply(this,arguments)}(e,i,r);"string"===n?(yield e.update({message:"Decoding text..."}),i=GB(o,0,o.length)):i=o}if("binary"===n&&i instanceof Uint8Array)return i;if("zip"===n&&i instanceof Uint8Array)return yield T2(e,i.buffer);if("string"===n&&"string"==typeof i)return i;if("xml"===n&&"string"==typeof i)return(new DOMParser).parseFromString(i,"application/xml");if("json"===n&&"string"==typeof i)return JSON.parse(i);throw new Error(`could not get requested response data '${n}'`)}),kO.apply(this,arguments)}let BO,FO=(()=>{class e{static get(){return this.pool.length?this.pool.pop():new S2}static emptyFunc(){}static deposit(n){this.pool.length=200&&e.status<400){const{response:n}=e;if(FO.deposit(e),("binary"===t||"zip"===t)&&n instanceof ArrayBuffer)return new Uint8Array(n);if("string"===t&&"string"==typeof n)return n;if("xml"===t&&n instanceof XMLDocument)return n;if("json"===t&&"object"==typeof n)return n;throw new Error(`could not get requested response data '${t}'`)}throw FO.deposit(e),new Error(`Download failed with status code ${e.status}`)}(c,n)});return function(a){return s.apply(this,arguments)}}(),()=>{o&&(o.abort(),o=void 0)})}function OO(){return OO=ie(function*(e,t,n,r){const i=n.length,o=new Array(n.length);yield e.update({message:"Downloading...",current:0,max:i});let s=[],a=[],c=0;for(let l=Math.min(i,r);c0;){const l=yield Promise.race(s),d=n[l.index],f=a.indexOf(l.index);if(u++,"error"===l.kind&&!d.canFail)throw new Error(`${d.url}: ${l.error}`);if(e.shouldUpdate&&(yield e.update({message:"Downloading...",current:u,max:i})),o[l.index]=l,s=s.filter(yee,f),a=a.filter(yee,f),c{l.release(u)}}},e.getUrl=function s(c){return"string"==typeof c?c:c.url},e.getUrlAsset=function a(c,u,l){return"string"==typeof u?c.tryFindUrl(u,l)||t(u,{body:l}):u}}(fr||(fr={}));class TLe{constructor(){this._assets=new Map}get assets(){return uB(this._assets.values())}tryFindUrl(t,n){const r=this.assets.values();for(;;){const i=r.next();if(i.done)return;const o=i.value.asset;if(fr.isUrl(o)&&o.url===t&&(o.body||"")===(n||""))return o}}set(t,n){this._assets.set(t.id,{asset:t,file:n,refCount:0})}get(t){return this._assets.get(t.id)}delete(t){return this._assets.delete(t.id)}has(t){return this._assets.has(t.id)}resolve(t,n,r=!0){var i=this;return fr.isUrl(t)?Oe.create(`Download ${t.title||t.url}`,function(){var o=ie(function*(s){if(i._assets.has(t.id)){const u=i._assets.get(t.id);return u.refCount++,fr.Wrapper(yield bp(u.file,n).runInContext(s),t,i)}if(!r)return fr.Wrapper(yield MO({...t,type:n}).runInContext(s),t,i);const a=yield MO({...t,type:"binary"}).runInContext(s),c=new hO([a],"raw-data");return i._assets.set(t.id,{asset:t,file:c,refCount:1}),fr.Wrapper(yield bp(c,n).runInContext(s),t,i)});return function(s){return o.apply(this,arguments)}}()):Oe.create(`Read ${t.name}`,function(){var o=ie(function*(s){if(i._assets.has(t.id)){const a=i._assets.get(t.id);return a.refCount++,fr.Wrapper(yield bp(a.file,n).runInContext(s),t,i)}if(!(t.file instanceof hO))throw new Error(`Cannot resolve file asset '${t.name}' (${t.id})`);return r&&i._assets.set(t.id,{asset:t,file:t.file,refCount:1}),fr.Wrapper(yield bp(t.file,n).runInContext(s),t,i)});return function(s){return o.apply(this,arguments)}}())}release(t){const n=this._assets.get(t.id);n&&(n.refCount--,n.refCount<=0&&this._assets.delete(t.id))}clear(){this._assets.clear()}dispose(){this.clear()}}!function(e){function t(oe,K){return K&&(K.label&&(oe.label=K.label),K.description&&(oe.description=K.description),K.legend&&(oe.legend=K.legend),K.fieldLabels&&(oe.fieldLabels=K.fieldLabels),K.isHidden&&(oe.isHidden=K.isHidden),K.shortLabel&&(oe.shortLabel=K.shortLabel),K.twoColumns&&(oe.twoColumns=K.twoColumns),K.isEssential&&(oe.isEssential=K.isEssential),K.category&&(oe.category=K.category),K.hideIf&&(oe.hideIf=K.hideIf),K.help&&(oe.help=K.help)),oe}function i(oe,K,ne){return t({type:"select",defaultValue:me(oe,K),options:K,cycle:ne?.cycle},ne)}function h(oe,K){return K&&(typeof K.min<"u"&&(oe.min=K.min),typeof K.max<"u"&&(oe.max=K.max),typeof K.step<"u"&&(oe.step=K.step)),oe}function x(oe,K){const ne=t({type:"group",defaultValue:K?.customDefault||F(oe),params:oe},K);return K?.presets&&(ne.presets=K.presets),K?.isExpanded&&(ne.isExpanded=K.isExpanded),K?.isFlat&&(ne.isFlat=K.isFlat),K?.pivot&&(ne.pivot=K.pivot),ne}function w(){return F(this.element)}function D(){throw new Error("getValue not set. Fix runtime.")}function F(oe){const K={};for(const ne of Object.keys(oe))oe[ne].isOptional||(K[ne]=oe[ne].defaultValue);return K}function G(oe,K,ne){return()=>oe(K,ne)}function L(oe,K,ne){if(K)if("value-ref"===oe.type){K.getValue=K.ref?G(oe.resolveRef,K.ref,ne):()=>{throw new Error("Unset ref in ValueRef value.")}}else if("data-ref"===oe.type){K.getValue=K.ref?G(ne,K.ref,ne):()=>{throw new Error("Unset ref in ValueRef value.")}}else if("group"===oe.type)Z(oe.params,K,ne);else if("mapped"===oe.type){const de=K;L(oe.map(de.name),de.params,ne)}else if("object-list"===oe.type){if(!j(oe.element))return;for(const de of K)Z(oe.element,de,ne)}}function z(oe){if("value-ref"===oe.type||"data-ref"===oe.type)return!0;if("group"===oe.type){if(j(oe.params))return!0}else if("mapped"===oe.type){for(const[K]of oe.select.options)if(z(oe.map(K)))return!0}else if("object-list"===oe.type)return j(oe.element);return!1}function j(oe){for(const K of Object.keys(oe))if(z(oe[K]))return!0;return!1}function Z(oe,K,ne){for(const de of Object.keys(oe))L(oe[de],K?.[de],ne)}function O(oe,K,ne){if(K===ne)return!0;if("object"!=typeof K||"object"!=typeof ne)return!1;for(const de of Object.keys(oe))if(!H(oe[de],K[de],ne[de]))return!1;return!0}function H(oe,K,ne){if(K===ne)return!0;if("group"===oe.type)return O(oe.params,K,ne);if("mapped"===oe.type){const de=K,we=ne;return de.name===we.name&&H(oe.map(de.name),de.params,we.params)}if("multi-select"===oe.type){const de=K,we=ne;if(de.length!==we.length)return!1;if(de.length<10){for(let Le=0,We=de.length;Le"u")return ne?oe.defaultValue:void 0;if(!fe(oe.select,de.name))return oe.defaultValue;const we=oe.map(de.name);return{name:de.name,params:X(we,de.params,ne)}}if("select"===oe.type)return fe(oe,K)?K:oe.defaultValue;if("multi-select"===oe.type){if(!Array.isArray(K))return oe.defaultValue;const de=K.filter(function(we){return fe(this,we)},oe);return K.length>0&&0===de.length?oe.defaultValue:de}return"object-list"===oe.type?Array.isArray(K)?K.map(de=>J(oe.element,de,ne?"all":"skip")):oe.defaultValue:K}function J(oe,K,ne){if("object"!=typeof K||null===K)return ne?F(oe):K;const de=Object.create(null);for(const we of Object.keys(oe)){const Le=oe[we];void 0===K[we]?"all"===ne&&(de[we]=Le.defaultValue):de[we]=X(Le,K[we],"skip"!==ne)}return de}function me(oe,K){for(const ne of K)if(ne[0]===oe)return oe;return K.length>0?K[0][0]:void 0}e.Essential={isEssential:!0},e.Optional=function n(oe){const K={...oe};return K.isOptional=!0,K},e.Value=function r(oe,K){return t({type:"value",defaultValue:oe},K)},e.Select=i,e.MultiSelect=function o(oe,K,ne){const de=t({type:"multi-select",defaultValue:oe,options:K},ne);return ne?.emptyValue&&(de.emptyValue=ne.emptyValue),de},e.Boolean=function s(oe,K){return t({type:"boolean",defaultValue:oe},K)},e.Text=function a(oe="",K){return t({type:"text",defaultValue:oe,multiline:K?.multiline,placeholder:K?.placeholder,disableInteractiveUpdates:K?.disableInteractiveUpdates},K)},e.Color=function c(oe,K){const ne=t({type:"color",defaultValue:oe},K);return K?.isExpanded&&(ne.isExpanded=K.isExpanded),ne},e.ColorList=function u(oe,K){let ne;if("string"==typeof oe){const de=cp(oe);ne={kind:"qualitative"!==de.type?"interpolate":"set",colors:de.list}}else ne=oe;return t({type:"color-list",presetKind:K?.presetKind||"all",defaultValue:ne,offsets:!!K?.offsets},K)},e.Vec3=function l(oe,K,ne){return t(h({type:"vec3",defaultValue:oe},K),ne)},e.Mat4=function d(oe,K){return t({type:"mat4",defaultValue:oe},K)},e.Url=function f(oe,K){return t({type:"url",defaultValue:"string"==typeof oe?fr.Url(oe):fr.Url(oe.url,{body:oe.body})},K)},e.File=function p(oe){const K=t({type:"file",defaultValue:null},oe);return oe?.accept&&(K.accept=oe.accept),K},e.FileList=function m(oe){const K=t({type:"file-list",defaultValue:null},oe);return oe?.accept&&(K.accept=oe.accept),K},e.Numeric=function g(oe,K,ne){const de=t(h({type:"number",defaultValue:oe},K),ne);return ne?.immediateUpdate&&(de.immediateUpdate=!0),de},e.Interval=function y(oe,K,ne){return t(h({type:"interval",defaultValue:oe},K),ne)},e.LineGraph=function b(oe,K){const ne=t({type:"line-graph",defaultValue:oe},K);return K?.getVolume&&(ne.getVolume=K.getVolume),ne},e.Group=x,e.EmptyGroup=function _(oe){return x({},oe)},e.Mapped=function S(oe,K,ne,de){const we=me(oe,K);return t({type:"mapped",defaultValue:{name:we,params:ne(we).defaultValue},select:i(we,K,de),map:ne},de)},e.MappedStatic=function A(oe,K,ne){const de=ne?.options?ne.options:Object.keys(K).map(Le=>[Le,K[Le].label||zu(Le)]),we=me(oe,de);return t({type:"mapped",defaultValue:{name:we,params:K[we].defaultValue},select:i(we,de,ne),map:Le=>K[Le]},ne)},e.ObjectList=function E(oe,K,ne){return t({type:"object-list",element:oe,getLabel:K,ctor:w,defaultValue:ne?.defaultValue||[]},ne)},e.ValueRef=function I(oe,K,ne){var de;return t({type:"value-ref",defaultValue:{ref:null!==(de=ne?.defaultRef)&&void 0!==de?de:"",getValue:D},getOptions:oe,resolveRef:K},ne)},e.DataRef=function R(oe){var K;return t({type:"data-ref",defaultValue:{ref:null!==(K=oe?.defaultRef)&&void 0!==K?K:"",getValue:D}},oe)},e.Converted=function T(oe,K,ne){return t({type:"converted",defaultValue:K(ne.defaultValue),converted:ne,fromValue:oe,toValue:K},ne)},e.Conditioned=function M(oe,K,ne,de,we){const Le=Object.keys(K).map(We=>[We,We]);return t({type:"conditioned",select:i(ne(oe),Le,we),defaultValue:oe,conditionParams:K,conditionForValue:ne,conditionedValue:de},we)},e.Script=function N(oe,K){return t({type:"script",defaultValue:oe},K)},e.For=function V(oe){return 0},e.getDefaultValues=F,e.resolveRefs=Z,e.setDefaultValues=function $(oe,K){for(const ne of Object.keys(oe))oe[ne].isOptional||(oe[ne].defaultValue=K[ne])},e.clone=function ee(oe){return Jl(oe)},e.validate=function q(oe,K){},e.areEqual=O,e.isParamEqual=H,e.merge=W,e.mergeParam=Q,e.normalizeParams=J,e.objectToOptions=function ce(oe,K){const ne=[];for(const de of Object.keys(oe))if(K){const we=K(de,oe[de]);ne.push("string"==typeof we?[de,we]:[de,we[0],we[1]])}else ne.push("string"==typeof oe[de]?[de,oe[de]]:[de,null===K?de:zu(de)]);return ne},e.arrayToOptions=function be(oe,K){const ne=[];for(const de of oe)ne.push(K?[de,K(de)]:[de,null===K?de:zu(de)]);return ne},e.optionLabel=function ae(oe,K){for(const ne of oe.options)if(ne[0]===K)return ne[1];return""}}(C||(C={}));const ELe=9,CT=-27.888,PLe=-.5,vee=-9.9;function MLe(e,t,n,r){const i=v.distance(e,r),o=v.distance(t,r),s=v.distance(t,n),a=v.distance(e,n),l=CT/i-CT/o+(CT/s-CT/a);return l0&&(t.secondStart-e.secondEnd<6&&t.firstStart-e.firstEnd<3||t.secondStart-e.secondEnd<3)}function xee(e){return vn.is(e,8)||vn.is(e,1)||vn.is(e,16)}const HLe={oldDefinition:C.Boolean(!0,{description:"Whether to use the old DSSP convention for the annotation of turns and helices, causes them to be two residues shorter"}),oldOrdering:C.Boolean(!0,{description:"Alpha-helices are preferred over 3-10 helices"})};function qLe(e,t){return UO.apply(this,arguments)}function UO(){return UO=ie(function*(e,t){const n=function jLe(e){const{index:t}=e.model.atomicHierarchy,{proteinElements:n,residueIndex:r}=e,i=n.length,o=new Uint32Array(i),s=new Int32Array(i),a=new Int32Array(i),c=new Int32Array(i),u=new Int32Array(i);for(let l=0;lPLe||(f[f.length]=w,p[p.length]=F,m[m.length]=z)}}return function kLe(e,t,n,r){const i=new Dc.DirectedEdgeBuilder(e,t,n),o=new Float32Array(i.slotCount);for(let s=0,a=i.edgeCount;s-1===S?v.setNaN(A):o.position(S,A);let l=v(),d=v(),f=v(),p=v(),m=v(),h=v();const g=v(),y=v(),b=v();if(0===c)return{phi:new Float32Array(0),psi:new Float32Array(0)};const x=new Float32Array(c-1),_=new Float32Array(c-1);u(-1,l),u(-1,d),u(-1,f),u(n[0],p),u(a[i[0]],m),u(r[0],h),u(n[1],g),u(a[i[1]],y),u(r[1],b);for(let S=0;S-1===y?v.setNaN(b):i.position(y,b),l=v(),d=v(),f=v(),p=v(),m=v(),h=v(),g=v();e:for(let y=2;y6.25)continue e}const A=o[s[y]],E=o[s[y+2]];u(o[s[y-2]],l),u(A,d),u(E,f),v.sub(h,l,d),v.sub(g,d,f);const w=su(v.angle(h,g));w&&w>70&&(n[y]|=32)}}(p),function ULe(e){const{proteinInfo:t,hbonds:n,flags:r,bridges:i}=e,{offset:o,b:s}=n;let a,c;for(let u=0,l=t.residueIndices.length;up||(a=u+1,c=p,a!==c&&-1!==n.getDirectedEdgeIndex(c,a+1)&&(r[a]|=2,r[c]|=2,i[i.length]=new wT(a,c,0)),a=u,c=p-1,a!==c&&-1!==n.getDirectedEdgeIndex(c-1,a)&&(r[a]|=2,r[c]|=2,i[i.length]=new wT(c,a,0)),a=u,c=p,a!==c&&-1!==n.getDirectedEdgeIndex(c,a)&&(r[a]|=2,r[c]|=2,i[i.length]=new wT(c,a,1)),a=u+1,c=p-1,a!==c&&-1!==n.getDirectedEdgeIndex(c-1,a+1)&&(r[a]|=2,r[c]|=2,i[i.length]=new wT(c,a,1)))}i.sort((u,l)=>u.partner1>l.partner1?1:u.partner1je.indexOf(r,x))}),UO.apply(this,arguments)}function WLe(e,t,n){return"helix"===e?{kind:"helix",flags:n(t)}:"sheet"===e?{kind:"sheet",flags:n(t)}:"turn"===e||"bend"===e?{kind:"turn",flags:n(t)}:{kind:"none"}}function $Le(e){return e===cr.SecondaryStructureDssp.H||e===cr.SecondaryStructureDssp.G||e===cr.SecondaryStructureDssp.I?"helix":e===cr.SecondaryStructureDssp.B||e===cr.SecondaryStructureDssp.E?"sheet":e===cr.SecondaryStructureDssp.T?"turn":e===cr.SecondaryStructureDssp.S?"bend":"none"}function YLe(e){return vn.is(e,1)?cr.SecondaryStructureDssp.H:vn.is(e,4)?cr.SecondaryStructureDssp.E:vn.is(e,2)?cr.SecondaryStructureDssp.B:vn.is(e,8)?cr.SecondaryStructureDssp.G:vn.is(e,16)?cr.SecondaryStructureDssp.I:vn.is(e,64)?cr.SecondaryStructureDssp.T:vn.is(e,32)?cr.SecondaryStructureDssp.S:0}function XLe(e){return vn.is(e,1)?"H":vn.is(e,4)?"E":vn.is(e,2)?"B":vn.is(e,8)?"G":vn.is(e,16)?"I":vn.is(e,64)?"T":vn.is(e,32)?"S":"-"}function KLe(e){return vn.is(e,16)?cr.SecondaryStructureDssp.I:vn.is(e,1)?cr.SecondaryStructureDssp.H:vn.is(e,4)?cr.SecondaryStructureDssp.E:vn.is(e,2)?cr.SecondaryStructureDssp.B:vn.is(e,8)?cr.SecondaryStructureDssp.G:vn.is(e,64)?cr.SecondaryStructureDssp.T:vn.is(e,32)?cr.SecondaryStructureDssp.S:0}function ZLe(e){return vn.is(e,16)?"I":vn.is(e,1)?"H":vn.is(e,4)?"E":vn.is(e,2)?"B":vn.is(e,8)?"G":vn.is(e,64)?"T":vn.is(e,32)?"S":"-"}var vp;function See(e){let t="model";if(e){t="dssp";for(let n=0,r=e.models.length;n(i in c[o]||(c[o][i]={props:{...C.getDefaultValues(r.getParams(c))},data:Gh.create(void 0)}),c[o][i]),a=(c,u,l)=>{const d=s(c);c[o][i]={props:u,data:Gh.withValue(d.data,l)}};return{label:r.label,descriptor:r.descriptor,isHidden:r.isHidden,getParams:c=>{const u=C.clone(r.getParams(c));return C.setDefaultValues(u,s(c).props),u},defaultParams:r.defaultParams,isApplicable:r.isApplicable,attach:(c=ie(function*(u,l,d={},f){f&&l.customPropertyDescriptors.reference(r.descriptor,!0),"root"===r.type&&(l=l.root);const p=s(l.root).props,m=s(l),h=C.merge(r.defaultParams,p,d);if(m.data.value&&C.areEqual(r.defaultParams,m.props,h))return;const{value:g,assets:y}=yield r.obtain(u,l,h);l.customPropertyDescriptors.add(r.descriptor),l.customPropertyDescriptors.assets(r.descriptor,y),a(l,h,g)}),function(l,d){return c.apply(this,arguments)}),ref:(c,u)=>c.customPropertyDescriptors.reference(r.descriptor,u),get:c=>s(c).data,set:(c,u={},l)=>{"root"===r.type&&(c=c.root);const d=s(c),f=C.merge(r.defaultParams,d.props,u);C.areEqual(r.defaultParams,d.props,f)||(a(c,f,l),c.customPropertyDescriptors.assets(r.descriptor))},props:c=>s(c).props};var c}e.createProvider=t,e.createSimple=function n(r,i,o){const s={value:C.Value(o,{isHidden:!0})};return t({label:zu(r),descriptor:au({name:r}),isHidden:!0,type:i,defaultParams:s,getParams:()=>({value:C.Value(o,{isHidden:!0})}),isApplicable:()=>!0,obtain:(a=ie(function*(c,u,l){return{...C.getDefaultValues(s),...l}}),function(u,l,d){return a.apply(this,arguments)})});var a}}(vp||(vp={}));const Cee=See(),Xu=vp.createProvider({label:"Secondary Structure",descriptor:au({name:"molstar_computed_secondary_structure"}),type:"root",defaultParams:Cee,getParams:See,isApplicable:e=>!0,obtain:function(){var e=ie(function*(t,n,r){const i={...C.getDefaultValues(Cee),...r};switch(i.type.name){case"dssp":return{value:yield JLe(n,i.type.params)};case"model":return{value:yield e5e(n)}}});return function(n,r,i){return e.apply(this,arguments)}}()});function JLe(e,t){return VO.apply(this,arguments)}function VO(){return VO=ie(function*(e,t){const n=new Map;for(let r=0,i=e.unitSymmetryGroups.length;re.element,x:e=>e.unit.conformation.x(e.element),y:e=>e.unit.conformation.y(e.element),z:e=>e.unit.conformation.z(e.element),id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicConformation.atomId.value(e.element):Oi(),occupancy:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicConformation.occupancy.value(e.element):Oi(),B_iso_or_equiv:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicConformation.B_iso_or_equiv.value(e.element):Oi(),sourceIndex:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atomSourceIndex.value(e.element):e.element,type_symbol:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atoms.type_symbol.value(e.element):Oi(),label_atom_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atoms.label_atom_id.value(e.element):Oi(),auth_atom_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atoms.auth_atom_id.value(e.element):Oi(),label_alt_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atoms.label_alt_id.value(e.element):Oi(),label_comp_id:AT,auth_comp_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atoms.auth_comp_id.value(e.element):Oi(),pdbx_formal_charge:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.value(e.element):Oi(),vdw_radius:e=>Ee.isAtomic(e.unit)?v2(e.unit.model.atomicHierarchy.atoms.type_symbol.value(e.element)):Oi()};function AT(e){return Ee.isAtomic(e.unit)||Oi(),e.unit.model.atomicHierarchy.atoms.label_comp_id.value(e.element)}function GO(e){return Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.residues.label_seq_id.value(e.unit.residueIndex[e.element]):Oi()}function wee(e){Ee.isAtomic(e.unit)||Oi();const t=e.unit.model.sequence.byEntityKey[Ka(e)];return t&&t.sequence.microHet.get(GO(e))||[AT(e)]}const r5e={key:e=>Ee.isAtomic(e.unit)?e.unit.residueIndex[e.element]:Oi(),group_PDB:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.residues.group_PDB.value(e.unit.residueIndex[e.element]):Oi(),label_seq_id:GO,auth_seq_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.residues.auth_seq_id.value(e.unit.residueIndex[e.element]):Oi(),pdbx_PDB_ins_code:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(e.unit.residueIndex[e.element]):Oi(),isNonStandard:e=>Ee.isAtomic(e.unit)?wee(e).some(t=>"n"===e.unit.model.properties.chemicalComponentMap.get(t).mon_nstd_flag[0]):Oi(),hasMicroheterogeneity:function n5e(e){Ee.isAtomic(e.unit)||Oi();const t=e.unit.model.sequence.byEntityKey[Ka(e)];return t&&t.sequence.microHet.has(GO(e))},microheterogeneityCompIds:wee,secondary_structure_type:e=>{var t;Ee.isAtomic(e.unit)||Oi();const n=null===(t=Xu.get(e.structure).value)||void 0===t?void 0:t.get(e.unit.invariantId);return n?n.type[n.getIndex(e.unit.residueIndex[e.element])]:536870912},secondary_structure_key:e=>{var t;Ee.isAtomic(e.unit)||Oi();const n=null===(t=Xu.get(e.structure).value)||void 0===t?void 0:t.get(e.unit.invariantId);return n?n.key[n.getIndex(e.unit.residueIndex[e.element])]:-1},chem_comp_type:e=>Ee.isAtomic(e.unit)?e.unit.model.properties.chemicalComponentMap.get(AT(e)).type:Oi()},i5e={key:e=>Ee.isAtomic(e.unit)?e.unit.chainIndex[e.element]:Oi(),label_asym_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.chains.label_asym_id.value(e.unit.chainIndex[e.element]):Oi(),auth_asym_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.chains.auth_asym_id.value(e.unit.chainIndex[e.element]):Oi(),label_entity_id:e=>Ee.isAtomic(e.unit)?e.unit.model.atomicHierarchy.chains.label_entity_id.value(e.unit.chainIndex[e.element]):Oi()},o5e={key:D2.key,entityKey:e=>Ee.isCoarse(e.unit)?e.unit.coarseElements.entityKey[e.element]:_p(),x:D2.x,y:D2.y,z:D2.z,asym_id:e=>Ee.isCoarse(e.unit)?e.unit.coarseElements.asym_id.value(e.element):_p(),entity_id:e=>Ee.isCoarse(e.unit)?e.unit.coarseElements.entity_id.value(e.element):_p(),seq_id_begin:e=>Ee.isCoarse(e.unit)?e.unit.coarseElements.seq_id_begin.value(e.element):_p(),seq_id_end:e=>Ee.isCoarse(e.unit)?e.unit.coarseElements.seq_id_end.value(e.element):_p(),sphere_radius:e=>Ee.isSpheres(e.unit)?e.unit.coarseConformation.radius[e.element]:_p("spheres"),sphere_rmsf:e=>Ee.isSpheres(e.unit)?e.unit.coarseConformation.rmsf[e.element]:_p("spheres"),gaussian_weight:e=>Ee.isGaussians(e.unit)?e.unit.coarseConformation.weight[e.element]:_p("gaussians"),gaussian_covariance_matrix:e=>Ee.isGaussians(e.unit)?e.unit.coarseConformation.covariance_matrix[e.element]:_p("gaussians")};function Ka(e){switch(e.unit.kind){case 0:return e.unit.model.atomicHierarchy.index.getEntityFromChain(e.unit.chainIndex[e.element]);case 1:return e.unit.model.coarseHierarchy.spheres.entityKey[e.element];case 2:return e.unit.model.coarseHierarchy.gaussians.entityKey[e.element]}}const s5e={key:Ka,id:e=>e.unit.model.entities.data.id.value(Ka(e)),type:e=>e.unit.model.entities.data.type.value(Ka(e)),src_method:e=>e.unit.model.entities.data.src_method.value(Ka(e)),pdbx_description:e=>e.unit.model.entities.data.pdbx_description.value(Ka(e)),formula_weight:e=>e.unit.model.entities.data.formula_weight.value(Ka(e)),pdbx_number_of_molecules:e=>e.unit.model.entities.data.pdbx_number_of_molecules.value(Ka(e)),details:e=>e.unit.model.entities.data.details.value(Ka(e)),pdbx_mutation:e=>e.unit.model.entities.data.pdbx_mutation.value(Ka(e)),pdbx_fragment:e=>e.unit.model.entities.data.pdbx_fragment.value(Ka(e)),pdbx_ec:e=>e.unit.model.entities.data.pdbx_ec.value(Ka(e)),subtype:e=>e.unit.model.entities.subtype.value(Ka(e)),prd_id:e=>{var t,n;return null!==(n=null===(t=e.unit.model.entities.prd_id)||void 0===t?void 0:t.value(Ka(e)))&&void 0!==n?n:""}},a5e=[],c5e={id:e=>e.unit.id,chainGroupId:e=>e.unit.chainGroupId,multiChain:e=>Ee.Traits.is(e.unit.traits,Ee.Trait.MultiChain),object_primitive:e=>e.unit.objectPrimitive,operator_name:e=>e.unit.conformation.operator.name,operator_key:e=>e.unit.conformation.operator.key,model_index:e=>e.unit.model.modelNum,model_label:e=>e.unit.model.label,model_entry_id:e=>e.unit.model.entryId,hkl:e=>e.unit.conformation.operator.hkl,spgrOp:e=>e.unit.conformation.operator.spgrOp,model_num:e=>e.unit.model.modelNum,pdbx_struct_assembly_id:e=>{var t;return(null===(t=e.unit.conformation.operator.assembly)||void 0===t?void 0:t.id)||ui.DefaultName},pdbx_struct_oper_list_ids:e=>{var t;return(null===(t=e.unit.conformation.operator.assembly)||void 0===t?void 0:t.operList)||a5e},struct_ncs_oper_id:e=>e.unit.conformation.operator.ncsId},Ze={constant:{true:e=>!0,false:e=>!1,zero:e=>0},atom:D2,residue:r5e,chain:i5e,entity:s5e,unit:c5e,coarse:o5e};class E2{add(t){let n=this.index.get(t.label_asym_id);n||(n=new Map,this.index.set(t.label_asym_id,n));let r=n.get(t.label_seq_id);return r||(r=[],n.set(t.label_seq_id,r)),!this._find(t,r)&&(r.push(t),!0)}hasLabelAsymId(t){return this.index.has(t)}has(t){var n,r;const i=Aee(t);if(!this.index.has(i))return;const o=this.index.get(i),s=Iee(t);if(!o.has(s))return;const a=o.get(s),c=Tee(t),u=Dee(t),l=Eee(t),d=null!==(n=Pee(t))&&void 0!==n?n:"1_555";for(const f of a)if(f.label_comp_id===c&&f.label_alt_id===u&&f.ins_code===l&&(!this.checkOperator||(null!==(r=f.operator_name)&&void 0!==r?r:"1_555")===d))return f}static getLabel(t,n=!1){var r;return`${t.label_asym_id} ${t.label_comp_id} ${t.label_seq_id}:${t.ins_code}:${t.label_alt_id}${n?" "+(null!==(r=t.operator_name)&&void 0!==r?r:"1_555"):""}`}static getEntryFromLocation(t){var n;return{label_asym_id:Aee(t),label_comp_id:Tee(t),label_seq_id:Iee(t),label_alt_id:Dee(t),ins_code:Eee(t),operator_name:null!==(n=Pee(t))&&void 0!==n?n:"1_555"}}_find(t,n){var r,i;for(const o of n)if(o.label_comp_id===t.label_comp_id&&o.label_alt_id===t.label_alt_id&&o.ins_code===t.ins_code&&(!this.checkOperator||(null!==(r=o.operator_name)&&void 0!==r?r:"1_555")===(null!==(i=t.operator_name)&&void 0!==i?i:"1_555")))return!0;return!1}constructor(t){var n;this.index=new Map,this.checkOperator=!1,this.checkOperator=null!==(n=t?.checkOperator)&&void 0!==n&&n}}const Aee=Ze.chain.label_asym_id,Iee=Ze.residue.label_seq_id,Tee=Ze.atom.label_comp_id,Dee=Ze.atom.label_alt_id,Eee=Ze.residue.pdbx_PDB_ins_code,Pee=Ze.unit.operator_name;function Jb(e,t,n){const r=t.subsetBuilder(!0);for(const i of n.units){if(0!==i.kind){r.setUnit(i.id,i.elements);continue}const{residueAtomSegments:o}=i.model.atomicHierarchy,s=t.unitMap.get(i.id).elements,a=i.elements;r.beginUnit(i.id);const c=en.transientSegments(o,a);for(;c.hasNext;){const u=c.move().index;for(let l=o.offsets[u],d=o.offsets[u+1];l(e.element.structure=n.structure,e.element.unit=n.unit,e.element.element=n.element,t(e))}function d5e(e,t){let n=0;e.element.structure=e.inputStructure;for(const r of e.inputStructure.units){e.element.unit=r;const i=r.elements;for(let o=0,s=i.length;on&&(n=c)}}return e.throwIfTimedOut(),n}function f5e(e,t){return function(r){const i=e(r);if(t.elementRadius){const o={...t,elementRadius:t.elementRadius,elementRadiusClosure:l5e(r,t.elementRadius),sourceMaxRadius:d5e(r,t.elementRadius)};if(pt.isSingleton(i)){const s=Mee(r,r.inputStructure,i.structure,o);return pt.Singletons(r.inputStructure,s)}{const s=new KB(r.inputStructure);for(const a of i.structures)s.add(Mee(r,r.inputStructure,a,o));return s.getSelection()}}if(pt.isSingleton(i)){const o=jO(r,r.inputStructure,i.structure,t);return pt.Singletons(r.inputStructure,o)}{const o=new KB(r.inputStructure);for(const s of i.structures)o.add(jO(r,r.inputStructure,s,t));return o.getSelection()}}}function p5e(e,t){return function(r){const i=e(r);if(0===pt.structureCount(i))return i;const o=pt.UniqueBuilder(r.inputStructure),s=a=>o.add(a);return pt.forEach(i,(a,c)=>{r.pushInputStructure(a),pt.forEach(t(r),s),r.popInputStructure(),c%10==0&&r.throwIfTimedOut()}),o.getSelection()}}function h5e(e,t){return function(r){const i=e(r);if(0===pt.structureCount(i))return i;const o=t(r);if(0===pt.structureCount(o))return pt.Empty(r.inputStructure);const s=pt.unionStructure(o),a=pt.UniqueBuilder(r.inputStructure);return pt.forEach(i,(c,u)=>{const l=NJ(s,c);0!==l.elementCount&&a.add(l),u%50==0&&r.throwIfTimedOut()}),a.getSelection()}}function m5e(e,t){return function(r){const i=e(r);if(0===pt.structureCount(i))return i;const o=t(r);if(0===pt.structureCount(o))return i;const s=pt.unionStructure(o),a=pt.UniqueBuilder(r.inputStructure);return pt.forEach(i,(c,u)=>{const l=YB(c,s);0!==l.elementCount&&a.add(l),u%50==0&&r.throwIfTimedOut()}),a.getSelection()}}function g5e(e){return function(n){const r=pt.LinearBuilder(n.inputStructure);return r.add(pt.unionStructure(e(n))),r.getSelection()}}function y5e(e,t){return function(r){const i=e(r),o=new Map,s=[];r.pushCurrentElement(),pt.forEach(i,(c,u)=>{r.element.structure=c;for(const l of c.units){r.element.unit=l;const d=l.elements;for(let f=0,p=d.length;f{let f=l;if(i)for(;;){const p=f.elementCount;if(f=Ree(a,n,f),f.elementCount===p)break}else for(let p=0;p=0)f.addElementRange(h,b.start,b.end);else if(d.hasLabelAsymId(x))for(y.setSegment(b);y.hasNext;){const S=y.move();u.element=h[S.start],d.has(u)&&f.addElementRange(h,S.start,S.end)}}f.commitUnit(),i.throwIfTimedOut()}const p=m2(i.inputStructure,[f.getStructure(),o]);if(n){const m=new pT(i.inputStructure),h=i.inputStructure.lookup3d;for(const g of p.units){const y=g.conformation,b=g.elements;for(let x=0,_=b.length;x<_;x++){const S=b[x];h.findIntoBuilderIf(y.x(S),y.y(S),y.z(S),t,m,S5e),m.addToUnit(g.id,S)}i.throwIfTimedOut()}return pt.Sequence(i.inputStructure,[m.getStructure()])}return pt.Sequence(i.inputStructure,[p])}}const x5e=Ze.entity.type;function S5e(e){return"water"===x5e(e)}class A5e{constructor(){this.vertices=new Map,this.edges=new Map}addVertex(t,n){this.vertices.has(n)||(this.vertices.set(n,t),this.edges.set(n,[]))}addEdge(t,n){const r=E2.getLabel(t),i=E2.getLabel(n);this.addVertex(t,r),this.addVertex(n,i),eo(this.edges.get(r),i),eo(this.edges.get(i),r)}addComponent(t,n){const r=E2.getLabel(t);if(!this.vertices.has(r))return void n.add(t);const i=new Set,o=new Set,s=[r];for(o.add(r),n.add(t);s.length>0;){const a=s.pop();i.add(a);const c=this.vertices.get(a);for(const u of this.edges.get(a)){if(i.has(u)||(s.push(u),o.has(u)))continue;o.add(u);const l=this.vertices.get(u);n.add(c.operator_name===l.operator_name?{...l,operator_name:t.operator_name}:l)}}}}var IT,TT,HO;function D5e(e,t){return n=>{const r=e(n),i=pt.LinearBuilder(n.inputStructure);return n.pushCurrentElement(),pt.forEach(r,(o,s)=>{n.currentStructure=o,t(n)&&i.add(o),s%100&&n.throwIfTimedOut()}),n.popCurrentStructure(),i.getSelection()}}function E5e(e){return t=>{const n=e(t),r=pt.LinearBuilder(t.inputStructure);if("singletons"===n.kind){if(n.structure.elementCount>0){const i=n.structure.units[0],o=Ve.create([i.getChild(je.ofSingleton(i.elements[0]))],{parent:t.inputStructure});r.add(o)}}else n.structures.length>0&&r.add(n.structures[0]);return r.getSelection()}}function DT(e,t,n){const{units:r}=e.currentStructure,i=e.pushCurrentElement();i.structure=e.currentStructure;for(const o of r){i.unit=o;const s=o.elements,a=t;if(a){for(let c=0,u=s.length;c{const i=e(r),o=function P5e(e,t,n){const r=new Set,i=t(e);return e.pushCurrentElement(),pt.forEach(i,(o,s)=>{e.currentStructure=o,DT(e,n,r),s%10&&e.throwIfTimedOut()}),e.popCurrentElement(),r}(r,t,n),s=pt.LinearBuilder(r.inputStructure);return r.pushCurrentStructure(),pt.forEach(i,(a,c)=>{r.currentStructure=a;const u=DT(r,n,new Set);Si.isSuperset(o,u)&&s.add(a),c%10&&r.throwIfTimedOut()}),r.popCurrentStructure(),s.getSelection()}}function R5e(e,t){return n=>{const r=pt.unionStructure(t(n)),i=pt.LinearBuilder(n.inputStructure);return pt.forEach(e(n),(o,s)=>{fT(r,o)&&i.add(o),s%10&&n.throwIfTimedOut()}),i.getSelection()}}function k5e(e){return t=>{const n={queryCtx:t,selection:e.query(t),target:e.target(t),maxRadius:e.maxRadius,minRadius:e.minRadius?Math.max(0,e.minRadius):0,elementRadius:e.elementRadius,invert:!!e.invert};return 0===n.minRadius&&typeof e.minRadius>"u"?function N5e({queryCtx:e,selection:t,target:n,maxRadius:r,invert:i}){const o=pt.unionStructure(n).lookup3d,s=pt.LinearBuilder(e.inputStructure),a=v.zero();return pt.forEach(t,(c,u)=>{const{units:l}=c;let d=!1;for(let f=0,p=l.length;f{let l=function T5e(e,t,n,r,i){return 0===t.elementCount||0===n.elementCount||(t.elementCount<=n.elementCount?TT.check(e,t,n,r,i):TT.check(e,n,t,r,i))}(e,s,c,r,o);i&&(l=!l),l&&a.add(c),u%10==0&&e.throwIfTimedOut()}),e.popCurrentElement(),a.getSelection()}(n):function B5e({queryCtx:e,selection:t,target:n,minRadius:r,maxRadius:i,invert:o,elementRadius:s}){const a=pt.unionStructure(n),c=pt.LinearBuilder(e.inputStructure);return e.pushCurrentElement(),pt.forEach(t,(u,l)=>{let d=function I5e(e,t,n,r,i,o){return 0===t.elementCount||0===n.elementCount||(t.elementCount<=n.elementCount?IT.check(e,t,n,r,i,o):IT.check(e,n,t,r,i,o))}(e,a,u,r,i,s);o&&(d=!d),d&&c.add(u),l%10==0&&e.throwIfTimedOut()}),e.popCurrentElement(),c.getSelection()}(n)}}function L5e({query:e,target:t,disjunct:n,invert:r,bondTest:i}){return o=>{const s=t(o);if(pt.isEmpty(s))return s;const a=e(o);if(pt.isEmpty(a))return a;const c={queryCtx:o,input:o.inputStructure,disjunct:n,target:pt.unionStructure(s)},u=pt.LinearBuilder(o.inputStructure);return o.pushCurrentBond(),o.atomicBond.setTestFn(i),pt.forEach(a,(l,d)=>{(function O5e(e,t){const{queryCtx:n,input:r,target:i,disjunct:o}=e,s=n.atomicBond,a=r.interUnitBonds;s.setStructure(r);for(const c of t.units){if(!Ee.isAtomic(c))continue;const u=r.unitMap.get(c.id),{offset:l,b:d,edgeProps:{flags:f,order:p,key:m}}=u.bonds,h=a.getConnectedUnits(c.id),g=h.length,y=c.elements,b=u.elements;for(let x=0,_=y.length;x<_;x++){const S=je.indexOf(b,y[x]);s.a.unit=u,s.b.unit=u;for(let A=l[S],E=l[S+1];A{const n=pt.UniqueBuilder(t.inputStructure);for(let r=0;r{n.add(i),r%100&&t.throwIfTimedOut()});return n.getSelection()}}function V5e(e){return 0===e.length?ZB:1===e.length?e[0]:t=>{const n=[];for(let a=0;aa.hashCode,Ve.areUnitIdsAndIndicesEqual);pt.forEach(n[r],a=>o.add(a));const s=pt.UniqueBuilder(t.inputStructure);for(let a=0;a{o.has(c)&&s.add(c)}),t.throwIfTimedOut());return s.getSelection()}}function z5e(e){return e.currentStructure.elementCount}function G5e(e){return t=>{const n=e(t);return pt.structureCount(n)}}function j5e(e){return t=>DT(t,e,new Set)}!function(e){const t=v();function n(s,a,c,u,l,d,f){const{elements:p,conformation:m}=a,h=t;s.element.unit=a;let g=!1;for(let y=0,b=p.length;yf(m)===p},e.lt=function r(f,p){return m=>f(m)f(m)<=p},e.gt=function o(f,p){return m=>f(m)>p},e.gte=function s(f,p){return m=>f(m)>=p},e.inSet=function u(f,p){if(function t(f){return!!f&&!!f.has}(p))return m=>p.has(f(m));{if(0===p.length)return c;const m=new Set;for(let h=0;hm.has(f(h))}},e.and=function l(...f){switch(f.length){case 0:return a;case 1:return f[0];case 2:{const p=f[0],m=f[1];return h=>p(h)&&m(h)}case 3:{const p=f[0],m=f[1],h=f[2];return g=>p(g)&&m(g)&&h(g)}case 4:{const p=f[0],m=f[1],h=f[2],g=f[3];return y=>p(y)&&m(y)&&h(y)&&g(y)}case 5:{const p=f[0],m=f[1],h=f[2],g=f[3],y=f[4];return b=>p(b)&&m(b)&&h(b)&&g(b)&&y(b)}case 6:{const p=f[0],m=f[1],h=f[2],g=f[3],y=f[4],b=f[5];return x=>p(x)&&m(x)&&h(x)&&g(x)&&y(x)&&b(x)}default:{const p=f.length;return m=>{for(let h=0;hp(h)||m(h)}case 3:{const p=f[0],m=f[1],h=f[2];return g=>p(g)||m(g)||h(g)}case 4:{const p=f[0],m=f[1],h=f[2],g=f[3];return y=>p(y)||m(y)||h(y)||g(y)}case 5:{const p=f[0],m=f[1],h=f[2],g=f[3],y=f[4];return b=>p(b)||m(b)||h(b)||g(b)||y(b)}case 6:{const p=f[0],m=f[1],h=f[2],g=f[3],y=f[4],b=f[5];return x=>p(x)||m(x)||h(x)||g(x)||y(x)||b(x)}default:{const p=f.length;return m=>{for(let h=0;hZe.unit.operator_name(t.element),ui.DefaultName),Sr.pred.inSet(t=>Ze.chain.label_asym_id(t.element),e))})}function kee(e,t,n,r,i,o){const{spacegroup:s,ncsOperators:a}=e,c=[],{toFractional:u}=s.cell,l=v.transformMat4(v(),o,u),d=Ec.getSymmetryOperatorRef(s,t,n,r,i,l);if(a&&a.length)for(let f=0,p=a.length;f=0&&t[1]<=0&&n[1]>=0&&t[2]<=0&&n[2]>=0&&(a[0]=Ec.getSymmetryOperator(i,0,0,0,0));for(let c=0;cfunction Y5e(e,t,n){return $O.apply(this,arguments)}(f,l,d))},e.buildSymmetryRange=function i(l,d,f){return Oe.create("Build Symmetry",p=>function $5e(e,t,n,r){return WO.apply(this,arguments)}(p,l,d,f))},e.buildNcs=function o(l){return Oe.create("Build NCS",d=>function W5e(e,t){return qO.apply(this,arguments)}(d,l))},e.areUnitsEquivalent=s,e.UnitEquivalenceBuilder=a,e.computeTransformGroups=function c(l){const d=a();for(const p of l.units)d.add(p.id,p);const f=[];for(const p of d.groups)f.push(Ee.SymmetryGroup(p.map(m=>l.unitMap.get(m))));return f},e.areTransformGroupsEquivalent=function u(l,d){if(l.length!==d.length)return!1;for(let f=0,p=l.length;f0?[]:this.currentUnit}addElement(t){this.currentUnit[this.currentUnit.length]=t,this.elementCount++}addElementRange(t,n,r){for(let i=n;i1&&Ou(c);let d=a.getChild(je.ofSortedArray(c));const f=r.add(d.id,d);d!==f&&(d=f.applyOperator(d.id,d.conformation.operator,!0)),n[n.length]=d}return Ve.create(n,{parent:this.parent})}getStructure(){return this._getStructure(!1)}getStructureDeduplicate(){return this._getStructure(!0)}setSingletonLocation(t){const n=this.ids[0];t.unit=this.parent.unitMap.get(n),t.element=this.unitMap.get(n)[0]}get isEmpty(){return 0===this.elementCount}constructor(t,n){this.parent=t,this.isSorted=n,this.ids=[],this.unitMap=Lu.Mutable(),this.parentId=-1,this.currentUnit=[],this.elementCount=0}}function Bee(e,t){let n=1;for(;t--;)n*=e--;return n}class Q5e{move(){if(this.hasNext){let t=0,n=0,r=this.index;for(;r;r>>>=1,t++)1&r&&(this.value[n++]=this.array[t]);this.index=function Z5e(e){const t=e&-e,n=e+t;return n|((n&-n)/t>>1)-1}(this.index),this.hasNext=this.indexe?0:Bee(e,t)/Bee(t,t)}(t.length,n),this.maxIndex=1<0&&n<=t.length}}function Oee(e,t){const n=[],r=new Q5e(e,t);for(;r.hasNext;)n.push(r.move().slice());return n}const Xg=[],J5e={links:Xg,terminalLinks:Xg,elements:Xg,partialElements:Xg,getElementIndices:()=>Xg,getLinkIndices:()=>Xg,getTerminalLinkIndices:()=>Xg},cs=Bg("C"),P2=Bg("O"),e6e=[Hu.elementFingerprint([cs,cs,cs,P2]),Hu.elementFingerprint([cs,cs,cs,cs,P2]),Hu.elementFingerprint([cs,cs,cs,cs,cs,P2]),Hu.elementFingerprint([cs,cs,cs,cs,cs,cs,P2])];function t6e(e,t){let n=-1,r=-1,i=-1,o=-1;const{elements:s}=e,{type_symbol:a,label_atom_id:c}=e.model.atomicHierarchy.atoms,{b:u,offset:l}=e.bonds;for(let d=0,f=t.length;d0}get customPropertyDescriptors(){return this.state.customProps||(this.state.customProps=new Ql),this.state.customProps}get currentPropertyData(){return this.state.propertyData||(this.state.propertyData=Object.create(null)),this.state.propertyData}get inheritedPropertyData(){return this.parent?this.parent.currentPropertyData:this.currentPropertyData}get polymerResidueCount(){return-1===this.state.polymerResidueCount&&(this.state.polymerResidueCount=function v6e(e){const{units:t}=e;let n=0;for(let r=0,i=t.length;r0&&(n+=1);return n}(this)),this.state.polymerUnitCount}get uniqueElementCount(){return-1===this.state.uniqueElementCount&&(this.state.uniqueElementCount=function b6e(e){const{unitSymmetryGroups:t}=e;let n=0;for(let r=0,i=t.length;rsn.isCoarseGrained(t))}get isEmpty(){return 0===this.units.length}get hashCode(){return-1!==this.state.hashCode?this.state.hashCode:this.computeHash()}get transformHash(){return-1!==this.state.transformHash||(this.state.transformHash=ha(this.units.map(t=>t.id))),this.state.transformHash}computeHash(){let t=23;for(let n=0,r=this.units.length;n500?c6e:u6e}(t.length);n.reset();for(let r=0,i=t.length;rf+p.properties.saccharideComponentMap.size,0))return J5e;const t=[],n=[],r=[],i=[],o=new Map;function s(f,p,m){return`${f}|${p}|${m}`}function a(f,p){o.has(f)?o.get(f).push(p):o.set(f,[p])}function c(f,p){v.sub(r[f].geometry.direction,r[p].geometry.center,r[f].geometry.center),v.normalize(r[f].geometry.direction,r[f].geometry.direction)}const u=v();function l(f,p,m){const g=r[f].geometry;v.sub(g.direction,m.conformation.position(m.elements[p],u),g.center),v.normalize(g.direction,g.direction)}for(let f=0,p=e.units.length;f{h.connectedIndices.forEach(g=>{h.getEdges(g).forEach(({props:y,indexB:b})=>{if(!jn.isCovalent(y.flag))return;const x=e.unitMap.get(h.unitA),_=e.unitMap.get(h.unitB),S=d(x,g),A=d(_,b);if(S.length>0&&A.length>0){const E=S.length,w=A.length;for(let D=0,I=Math.max(E,w);Di[r.get(a.id)]+Fe.indexOf(a.elements,c)}}(this))}get model(){if(this.state.model)return this.state.model;if(this.state.representativeModel)return this.state.representativeModel;if(this.state.masterModel)return this.state.masterModel;const t=this.models;if(t.length>1)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}get masterModel(){return this.state.masterModel}get representativeModel(){return this.state.representativeModel}hasElement(t){return!!this.unitMap.has(t.unit.id)&&je.has(this.unitMap.get(t.unit.id).elements,t.element)}getModelIndex(t){return this.models.indexOf(t)}remapModel(t){const{dynamicBonds:n,interUnitBonds:r,parent:i}=this.state,o=[];for(const s of this.unitSymmetryGroups){const a=s.units[0].remapModel(t,n);o.push(a);for(let c=1,u=s.units.length;c0?X[0].id:0;for(let ne=0,de=X.length;ne2e5||p(X,ne)?g(X,U,oe,We,de):oe.addUnit(0,X,de,U,We?Ee.Trait.MultiChain:Ee.Trait.None):oe.addUnit(0,X,de,U,We?Ee.Trait.MultiChain:Ee.Trait.None)}const K=X.coarseHierarchy;return K.isDefined&&(K.spheres.count>0&&y(oe,X,X.coarseHierarchy.spheres,1),K.gaussians.count>0&&y(oe,X,X.coarseHierarchy.gaussians,2)),oe.getStructure()}function p(X,J){const ce=X.atomicHierarchy.index.getEntityFromChain(J);return"water"===X.entities.data.type.value(ce)}function m(X,J){const ce=X.atomicHierarchy.index.getEntityFromChain(J);return"polymer"===X.entities.data.type.value(ce)}function h(X,J,ce,be,ae){const{x:me,y:oe,z:K}=X.atomicConformation,ne={x:me,y:oe,z:K,indices:J},de=rd(ne,pp(ne),8192),{offset:we,count:Le,array:We}=de.buckets,U=(be?Ee.Trait.MultiChain:Ee.Trait.None)|(we.length>1?Ee.Trait.Partitioned:Ee.Trait.None);ce.beginChainGroup();for(let Y=0,ge=we.length;Y1?Ee.Trait.Partitioned:Ee.Trait.None);ce.beginChainGroup();for(let $e=0,tt=Se.length;$eEe.conformationId(J)).join("|"))},e.areUnitIdsEqual=E,e.areUnitIdsAndIndicesEqual=function w(X,J){if(X===J)return!0;if(!E(X,J))return!1;for(let ce=0,be=X.units.length;ce=this.structure.units.length?this.hasNext=!1:(this.current.unit=this.structure.units[this.unitIndex],this.elements=this.current.unit.elements,this.maxIdx=this.elements.length-1,0===this.maxIdx&&(this.hasNext=this.unitIndex+10,this.hasNext&&(this.elements=J.units[0].elements,this.maxIdx=this.elements.length-1,this.current.unit=J.units[0])}};const N=v();function V(X,J,ce){const{elements:be,conformation:ae}=X,me=N;let oe=Number.MAX_VALUE;for(let K=0,ne=be.length;KJ.units[0].polymerElements.length>0)}let H;var X;e.distance=function L(X,J){if(0===X.elementCount||0===J.elementCount)return 0;const{units:ce}=X;let be=Number.MAX_VALUE;for(let ae=0,me=ce.length;aeae(ne)))return;const oe=X.lookup3d,K=v();for(const ne of X.units){if(!ae(ne))continue;const de=ne.boundary.sphere;v.transformMat4(K,de.center,ne.conformation.operator.matrix);const we=oe.findUnitIndices(K[0],K[1],K[2],de.radius+be);for(let Le=0;Le=We.id||!ae(We)||!me(ne,We)||(We.elements.length>=ne.elements.length?J(ne,We):J(We,ne))}}},e.eachAtomicHierarchyElement=function $(X,{chain:J,residue:ce,atom:be}){const ae=nt.create(X);for(const me of X.units){if(0!==me.kind)continue;ae.unit=me;const{elements:oe}=me,K=en.transientSegments(me.model.atomicHierarchy.chainAtomSegments,oe),ne=en.transientSegments(me.model.atomicHierarchy.residueAtomSegments,oe);for(;K.hasNext;){const de=K.move();if(J&&(ae.element=oe[de.start],J(ae)),ce||be)for(ne.setSegment(de);ne.hasNext;){const we=ne.move();if(ce&&(ae.element=oe[we.start],ce(ae)),be)for(let Le=we.start,We=we.end;Le=be.largeResidueCount*ce?function O(X,J){const ce=ee(X);return ce.length>=1&&ce[0].units.length>J.highSymmetryUnitCount}(X,be)?H.Huge:H.Gigantic:function q(X,J){const ce=ee(X);return 1===ce.length&&ce[0].units.length>2&&ce[0].units[0].polymerElements.length0)return!1;return!0}function o(Q){let fe=0;for(const{indices:X}of Q.elements)fe+="number"==typeof X?w6e(X):X.length;return fe}function u(Q){return r(Q)?Q:e(Q.structure,[{unit:Q.elements[0].unit,indices:Fe.ofSingleton(Fe.start(Q.elements[0].indices))}])}function _(Q){return Q.length>3&&je.isRange(Q)?Ce.ofRange(Q[0],Q[Q.length-1]):je.ofSortedArray(Q)}function S(Q,fe){const X=[],J=new Set;for(const ce of Q.elements)if(E(ce))X[X.length]=ce;else if(0===ce.unit.kind){const be=ce.unit.elements,ae=ce.unit.model.atomicHierarchy,{label_alt_id:me}=ce.unit.model.atomicHierarchy.atoms,{index:oe,offsets:K}=ae.residueAtomSegments,ne=[],de=ce.indices,we=Fe.size(de);let Le=0;for(;Le=0){const Ne=me.value(ge);(!fe||Y||!Ne||J.has(Ne))&&(ne[ne.length]=Re)}}}X[X.length]={unit:ce.unit,indices:_(ne)}}else X[X.length]=ce;return e(Q.structure,X)}function A(Q){switch(Q.kind){case 0:return Q.model.atomicHierarchy.chainAtomSegments;case 1:return Q.model.coarseHierarchy.spheres.chainElementSegments;case 2:return Q.model.coarseHierarchy.gaussians.chainElementSegments}}function E(Q){return Q.unit.elements.length===Fe.size(Q.indices)}function w(Q,fe,X){const{index:J}=A(Q),ce=Q.elements;let be=0;for(let me=0,oe=ce.length;me0&&(X[X.length]={unit:Q,indices:_(ae)})}function D(Q,fe,X,J,ce){const{index:be}=A(Q.elements[0].unit),ae=new Set;for(let me=fe;me({unit:fe,indices:Fe.ofBounds(0,fe.elements.length)})))},e.none=function a(Q){return e(Q,[])},e.getFirstLocation=function c(Q,fe){if(r(Q))return;const X=Q.elements[0].unit,J=X.elements[Fe.getAt(Q.elements[0].indices,0)];return fe?(fe.structure=Q.structure,fe.unit=Q.elements[0].unit,fe.element=J,fe):nt.create(Q.structure,X,J)},e.firstElement=u,e.firstResidue=function l(Q){return r(Q)?Q:S(u(Q))},e.firstChain=function d(Q){return r(Q)?Q:I(u(Q))},e.toStructure=function f(Q){const fe=[];for(const X of Q.elements){const{unit:J,indices:ce}=X,be=new Int32Array(Fe.size(ce));Fe.forEach(ce,(ae,me)=>be[me]=J.elements[ae]),fe.push(J.getChild(je.ofSortedArray(be)))}return Ve.create(fe,{parent:Q.structure.parent})},e.forEachLocation=function p(Q,fe){if(e.isEmpty(Q))return;const X=nt.create(Q.structure);for(const J of Q.elements){const{unit:ce,indices:be}=J;X.unit=ce;const{elements:ae}=J.unit;for(let me=0,oe=Fe.size(be);me{if(!fe.unitMap.has(J.unit.id))return;const ce=fe.unitMap.get(J.unit.id),be=Fe.indexedIntersect(J.indices,J.unit.elements,ce.elements);Fe.size(be)>0&&X.push({unit:ce,indices:be})}),e(fe,X)},e.union=function h(Q,fe){if(Q.elements.length>fe.elements.length)return h(fe,Q);if(e.isEmpty(Q))return fe;const X=new Map;for(const ce of Q.elements)X.set(ce.unit.id,ce.indices);const J=[];for(const ce of fe.elements)X.has(ce.unit.id)?(J[J.length]={unit:ce.unit,indices:Fe.union(X.get(ce.unit.id),ce.indices)},X.delete(ce.unit.id)):J[J.length]=ce;return X.forEach((ce,be)=>{J[J.length]={unit:Q.structure.unitMap.get(be),indices:ce}}),e(Q.structure,J)},e.subtract=function g(Q,fe){const X=new Map;for(const ce of fe.elements)X.set(ce.unit.id,ce.indices);const J=[];for(const ce of Q.elements)if(X.has(ce.unit.id)){const be=Fe.subtract(ce.indices,X.get(ce.unit.id));if(0===Fe.size(be))continue;J[J.length]={unit:ce.unit,indices:be}}else J[J.length]=ce;return e(Q.structure,J)},e.intersect=function y(Q,fe){const X=new Map;for(const ce of Q.elements)X.set(ce.unit.id,ce.indices);const J=[];for(const ce of fe.elements){if(!X.has(ce.unit.id))continue;const be=Fe.intersect(X.get(ce.unit.id),ce.indices);0!==Fe.size(be)&&(J[J.length]={unit:ce.unit,indices:be})}return e(Q.structure,J)},e.areIntersecting=function b(Q,fe){if(Q.elements.length>fe.elements.length)return b(fe,Q);if(e.isEmpty(Q))return e.isEmpty(fe);const X=new Map;for(const J of Q.elements)X.set(J.unit.id,J.indices);for(const J of fe.elements)if(X.has(J.unit.id)&&Fe.areIntersecting(X.get(J.unit.id),J.indices))return!0;return!1},e.isSubset=function x(Q,fe){if(e.isEmpty(Q))return e.isEmpty(fe);const X=new Map;for(const ce of Q.elements)X.set(ce.unit.id,ce.indices);let J=!1;for(const ce of fe.elements)if(X.has(ce.unit.id)){if(!Fe.isSubset(X.get(ce.unit.id),ce.indices))return!1;J=!0}return J},e.extendToWholeResidues=S,e.extendToWholeChains=I,e.extendToWholeEntities=function T(Q){const fe=[],X=nt.create(Q.structure),J=new Set,{units:ce}=Q.structure;for(let be=0,ae=Q.elements.length;be12)be[be.length]=fe[K],be[be.length]=fe[ne-1];else for(let de=K;de{fe+=o(ce)});const X=new Float32Array(3*fe);let J=0;return Q.forEach(ce=>{$(ce,X,J),J+=3*o(ce)}),nd.ofPositions(X)},e.toExpression=function H(Q){if(e.isEmpty(Q))return ue.struct.generator.empty();const fe=Q.structure.models,X=new Map;for(const me of Q.elements){const{indices:oe}=me,{elements:K}=me.unit,ne=me.unit.conformation.operator.name;let de;X.has(ne)?de=X.get(ne).xs:(de=kr.create(),X.set(ne,{modelLabel:me.unit.model.label,modelIndex:me.unit.model.modelNum,xs:de}));for(let we=0,Le=Fe.size(oe);we1,oe.modelLabel,oe.modelIndex))}const be=new Map;for(let me=0,oe=J.length;me{const{ranges:oe,set:K}=me.atom,{opName:ne}=me.chain,de=ue.struct.atomProperty.core.operatorName(),we=ue.struct.atomProperty.core.sourceIndex(),Le=[];K.length>0&&(Le[Le.length]=ue.core.set.has([ue.core.type.set(K),we]));for(let We=0,U=oe.length/2;We1?ue.core.logic.or(Le):Le[0],"chain-test":ne.length>1?ue.core.set.has([ue.core.type.set(ne),de]):ue.core.rel.eq([de,ne[0]]),"entity-test":ue.core.logic.and([ue.core.rel.eq([ue.struct.atomProperty.core.modelLabel(),We]),ue.core.rel.eq([ue.struct.atomProperty.core.modelIndex(),U])])}))}else ae.push(ue.struct.generator.atomGroups({"atom-test":Le.length>1?ue.core.logic.or(Le):Le[0],"chain-test":ne.length>1?ue.core.set.has([ue.core.type.set(ne),de]):ue.core.rel.eq([de,ne[0]])}))}),ue.struct.modifier.union([1===ae.length?ae[0]:ue.struct.combinator.merge(ae.map(me=>ue.struct.modifier.union([me])))])}}(De||(De={})),function(e){function t(){return{elementCount:0,conformationCount:0,residueCount:0,chainCount:0,unitCount:0,structureCount:0,firstElementLoc:nt.create(void 0),firstConformationLoc:nt.create(void 0),firstResidueLoc:nt.create(void 0),firstChainLoc:nt.create(void 0),firstUnitLoc:nt.create(void 0),firstStructureLoc:nt.create(void 0)}}function n(c,u,l){const d=c.get(u)||0;c.set(u,d+l)}function r(c,u,l){const{indices:d,unit:f}=l,{elements:p}=f,m=Fe.size(d),h=new Map,g=new Map;if(m>0&&nt.set(c.firstElementLoc,u,f,p[Fe.start(d)]),m===p.length)c.unitCount+=1,1===c.unitCount&&nt.set(c.firstUnitLoc,u,f,p[Fe.start(d)]);else if(1===m){if(Ee.Traits.is(f.traits,Ee.Trait.MultiChain))return;c.elementCount+=1,1===c.elementCount&&nt.set(c.firstElementLoc,u,f,p[Fe.start(d)])}else if(Ee.isAtomic(f)){const{index:y,offsets:b}=f.model.atomicHierarchy.residueAtomSegments,{label_alt_id:x}=f.model.atomicHierarchy.atoms;let _=0;for(;_{if(g.get(D)===w){if(""!==D&&(c.conformationCount+=1,1===c.conformationCount))for(let I=b[E],R=b[E+1];I{g[_+1]-g[_]===x&&(c.chainCount+=1,1===c.chainCount&&(b=_))}),!(b<0))for(let x=d;x(i in c[o]||(c[o][i]={props:{...C.getDefaultValues(r.getParams(c))},data:Gh.create(void 0)}),c[o][i]),a=(c,u,l)=>{const d=s(c);c[o][i]={props:u,data:Gh.withValue(d.data,l)}};return{label:r.label,descriptor:r.descriptor,isHidden:r.isHidden,getParams:c=>{const u=C.clone(r.getParams(c));return C.setDefaultValues(u,s(c).props),u},defaultParams:r.defaultParams,isApplicable:r.isApplicable,attach:(c=ie(function*(u,l,d={},f){f&&l.customProperties.reference(r.descriptor,!0);const p=s(l),m=C.merge(r.defaultParams,p.props,d);if(p.data.value&&C.areEqual(r.defaultParams,p.props,m))return;const{value:h,assets:g}=yield r.obtain(u,l,m);l.customProperties.add(r.descriptor),l.customProperties.assets(r.descriptor,g),a(l,m,h)}),function(l,d){return c.apply(this,arguments)}),ref:(c,u)=>c.customProperties.reference(r.descriptor,u),get:c=>{var u;return null===(u=s(c))||void 0===u?void 0:u.data},set:(c,u={},l)=>{const d=s(c),f=C.merge(r.defaultParams,d.props,u);C.areEqual(r.defaultParams,d.props,f)||(a(c,f,l),c.customProperties.assets(r.descriptor))},props:c=>s(c).props};var c}e.createProvider=t,e.createSimple=function n(r,i,o){const s={value:C.Value(o,{isHidden:!0})};return t({label:zu(r),descriptor:au({name:r}),isHidden:!0,type:i,defaultParams:s,getParams:()=>({value:C.Value(o,{isHidden:!0})}),isApplicable:()=>!0,obtain:(a=ie(function*(c,u,l){return{...C.getDefaultValues(s),...l}}),function(u,l,d){return a.apply(this,arguments)})});var a}}(Kg||(Kg={})),function(e){var o;function t(o){if(!Er.is(o.sourceData))return!1;const{pdbx_sifts_xref_db_name:s,pdbx_sifts_xref_db_acc:a,pdbx_sifts_xref_db_num:c,pdbx_sifts_xref_db_res:u}=o.sourceData.data.db.atom_site;return s.isDefined&&a.isDefined&&c.isDefined&&u.isDefined}function i(o){if(!Er.is(o.sourceData))return;const{pdbx_sifts_xref_db_name:s,pdbx_sifts_xref_db_acc:a,pdbx_sifts_xref_db_num:c,pdbx_sifts_xref_db_res:u}=o.sourceData.data.db.atom_site;if(!(s.isDefined&&a.isDefined&&c.isDefined&&u.isDefined))return;const{atomSourceIndex:l}=o.atomicHierarchy,{count:d,offsets:f}=o.atomicHierarchy.residueAtomSegments,p=new Array(d),m=new Array(d),h=new Array(d),g=new Array(d);for(let y=0;y({}),isApplicable:o=>t(o),obtain:(o=ie(function*(s,a){return{value:i(a)}}),function(a,c){return o.apply(this,arguments)})}),e.isAvailable=t,e.getKey=function n(o){const s=o.unit.model,a=e.Provider.get(s).value;return a?a.accession[s.atomicHierarchy.residueAtomSegments.index[o.element]]:""},e.getLabel=function r(o){const s=o.unit.model,a=e.Provider.get(s).value;if(!a)return;const c=s.atomicHierarchy.residueAtomSegments.index[o.element],u=a.dbName[c];return u?`${u} ${a.accession[c]} ${a.num[c]} ${a.residue[c]}`:void 0}}(sf||(sf={}));function M2(e,t){if(Er.is(e.sourceData))return e.sourceData.data.db[t]}function Hee(e){if(0===e.length)return[];if(1===e.length)return e[0].entityIndices;const t=kr.create();for(const n of e)for(const r of n.entityIndices)kr.add(t,r,r);return Ou(t.array),t.array}function Zu(e,t){return{name:e,instance({structures:n}){if(t&&!t(n[0]))return Bi.Category.Empty;const r=n[0].model;if(!Er.is(r.sourceData))return Bi.Category.Empty;const i=r.sourceData.data.db[e];return i&&i._rowCount?Bi.Category.ofTable(i):Bi.Category.Empty}}}var qee=Bi.Category;XO("struct_asym"),XO("entity_poly"),XO("entity_poly_seq");function XO(e){return{name:e,instance:({structures:t,cache:n})=>function W6e(e,t,n){const r=M2(e[0].model,t);if(!r)return qee.Empty;const{entity_id:i}=r,o=n.uniqueEntityIds||(n.uniqueEntityIds=function O6e(e){if(0===e.length)return new Set;const t=e[0].model.entities.data.id;return new Set(Hee(e).map(n=>t.value(n)))}(e)),s=te.indicesOf(i,a=>o.has(a));return qee.ofTable(r,s)}(t,e,n)}}var KO;!function(e){e.create=function t(n){const r=Array.isArray(n)?n:[n];return{structures:r,firstModel:r[0].model,cache:Object.create(null)}}}(KO||(KO={}));function ZO(e){return e.units.every(t=>t.conformation.operator.isIdentity)}function QO(e){return ZO(e)&&e.units.every(t=>!t.conformation.operator.assembly&&!t.conformation.operator.suffix)}var JO;Zu("entry"),Zu("exptl"),Zu("cell",ZO),Zu("symmetry",ZO),Zu("pdbx_struct_assembly",QO),Zu("pdbx_struct_assembly_gen",QO),Zu("pdbx_struct_oper_list",QO),Zu("pdbx_entity_branch"),Zu("pdbx_entity_branch_link"),Zu("pdbx_branch_scheme"),Zu("struct_conn"),Zu("atom_sites"),function(e){e.AtomSitePositionsFieldNames=new Set(["id","Cartn_x","Cartn_y","Cartn_z"])}(JO||(JO={}));const Q6e={molstar_atom_site_operator_mapping:{label_asym_id:te.Schema.Str(),auth_asym_id:te.Schema.Str(),operator_name:te.Schema.Str(),suffix:te.Schema.Str(),assembly_id:te.Schema.Str(),assembly_operator_id:te.Schema.Int(),symmetry_operator_index:te.Schema.Int(),symmetry_hkl:te.Schema.Vector(3),ncs_id:te.Schema.Int()}},$ee=(e,t)=>typeof t[e].operator.assembly>"u"?1:0,e4=(e,t)=>-1===t[e].operator.spgrOp?1:0;function tv(e,t){return t?1===t.length?uu(t.charCodeAt(0),e):2===t.length?uu(t.charCodeAt(0),uu(t.charCodeAt(1),e)):`${e} ${t}`:e}function r8e(e,t,n,r){if(e.has(t)){const i=e.get(t);i.has(n)||i.set(n,r)}else{const i=new Map;e.set(t,i),i.set(n,r)}}function i8e(e){throw new Error(`Missing entity entry for entity id '${e}'.`)}Bi.fields().str("label_asym_id",(e,t)=>t[e].label_asym_id).str("auth_asym_id",(e,t)=>t[e].auth_asym_id).str("operator_name",(e,t)=>t[e].operator.name).str("suffix",(e,t)=>t[e].operator.suffix).str("assembly_id",(e,t)=>{var n;return(null===(n=t[e].operator.assembly)||void 0===n?void 0:n.id)||""},{valueKind:$ee}).int("assembly_operator_id",(e,t)=>{var n;return(null===(n=t[e].operator.assembly)||void 0===n?void 0:n.operId)||0},{valueKind:$ee}).int("symmetry_operator_index",(e,t)=>t[e].operator.spgrOp,{valueKind:e4}).vec("symmetry_hkl",[(e,t)=>t[e].operator.hkl[0],(e,t)=>t[e].operator.hkl[1],(e,t)=>t[e].operator.hkl[2]],{valueKind:e4}).int("ncs_id",(e,t)=>t[e].operator.ncsId,{valueKind:e4}).getFields();const R2=lO.EmptyResidueKey();class s8e{getEntityFromChain(t){return this.map.chain_index_entity_index[t]}findEntity(t){const n=this.map.label_asym_id.get(t);return void 0!==n?n:-1}findChainLabel(t){const n=this.entityIndex(t.label_entity_id);if(n<0||!this.map.entity_index_label_asym_id.has(n))return-1;const r=this.map.entity_index_label_asym_id.get(n);return r&&r.has(t.label_asym_id)?r.get(t.label_asym_id):-1}findChainAuth(t){if(!this.map.auth_asym_id_auth_seq_id.has(t.auth_asym_id))return-1;const n=this.map.auth_asym_id_auth_seq_id.get(t.auth_asym_id);return n.has(t.auth_seq_id)?n.get(t.auth_seq_id):-1}findResidue(t,n,r,i){let o;1===arguments.length?o=t:(R2.label_entity_id=t,R2.label_asym_id=n,R2.auth_seq_id=r,R2.pdbx_PDB_ins_code=i,o=R2);const s=this.findChainLabel(o);if(s<0)return-1;const a=this.map.chain_index_auth_seq_id.get(s),c=tv(o.auth_seq_id,o.pdbx_PDB_ins_code||"");return a.has(c)?a.get(c):-1}findResidueLabel(t){const n=this.findChainLabel(t);if(n<0)return-1;const r=this.map.chain_index_label_seq_id.get(n),i=tv(t.label_seq_id,t.pdbx_PDB_ins_code||"");return r.has(i)?r.get(i):-1}findResidueAuth(t){const n=this.findChainAuth(t);if(n<0)return-1;const r=this.map.chain_index_auth_seq_id.get(n),i=tv(t.auth_seq_id,t.pdbx_PDB_ins_code||"");return r.has(i)?r.get(i):-1}findResidueInsertion(t){const n=this.findChainLabel(t);if(n<0)return-1;const r=this.map.chain_index_label_seq_id.get(n),i=tv(t.label_seq_id,t.pdbx_PDB_ins_code||"");if(r.has(i))return r.get(i);const o=je.findPredecessorIndex(this.map.label_seq_id,t.label_seq_id),s=Gg.chainStartResidueIndex(this.map.segments,n);if(o=a?a:o}findAtom(t){const n=this.findResidue(t);return n<0?-1:typeof t.label_alt_id>"u"?t4(this.residueOffsets[n],this.residueOffsets[n+1],this.map.label_atom_id,t.label_atom_id):n4(this.residueOffsets[n],this.residueOffsets[n+1],this.map.label_atom_id,this.map.label_alt_id,t.label_atom_id,t.label_alt_id)}findAtomAuth(t){const n=this.findResidueAuth(t);return n<0?-1:typeof t.label_alt_id>"u"?t4(this.residueOffsets[n],this.residueOffsets[n+1],this.map.auth_atom_id,t.auth_atom_id):n4(this.residueOffsets[n],this.residueOffsets[n+1],this.map.auth_atom_id,this.map.label_alt_id,t.auth_atom_id,t.label_alt_id)}findAtomOnResidue(t,n,r){return typeof r>"u"?t4(this.residueOffsets[t],this.residueOffsets[t+1],this.map.label_atom_id,n):n4(this.residueOffsets[t],this.residueOffsets[t+1],this.map.label_atom_id,this.map.label_alt_id,n,r)}findAtomsOnResidue(t,n){return function a8e(e,t,n,r){for(let i=e;i=c[u+1]&&(u+=1,l=0),s[d]=++l;i.label_seq_id=te.ofIntArray(s)}return Xn.columnToArray(i,"label_seq_id",Int32Array),Xn.columnToArray(i,"auth_seq_id",Int32Array),{atoms:r,residues:i,chains:o,atomSourceIndex:t}}(e,t,s),c=function h8e(e,t){const n=new Map;if(!Er.is(t))return n;const{molstar_atom_site_operator_mapping:r}=Zd(Q6e,t.data.frame);if(0===r._rowCount)return n;const i=new Map,o=new Map;for(let l=0;l-1,findChainKey:()=>-1,getEntityFromChain:()=>-1,count:0,entity_id:te.Undefined(0,te.Schema.str),asym_id:te.Undefined(0,te.Schema.str),seq_id_begin:te.Undefined(0,te.Schema.int),seq_id_end:te.Undefined(0,te.Schema.int),chainElementSegments:en.create([]),polymerRanges:wr.ofSortedRanges([]),gapRanges:wr.ofSortedRanges([])};var Kee=function(e){return e.Empty={isDefined:!1,spheres:Xee,gaussians:Xee},e}(Kee||{});function g8e(e,t,n){if(e.has(t))return e.get(t);const r=n.index++;return e.set(t,r),r}function y8e(e,t){if(e.has(t))return e.get(t);const n=new Map;return e.set(t,n),n}function v8e(e){throw new Error(`Missing entity entry for entity id '${e}'.`)}function Zee(e,t){const{entity_id:n,asym_id:r,seq_id_begin:i,seq_id_end:o,count:s,chainElementSegments:a}=e,c=new Map,u=new Map,l={index:0},d=new Int32Array(s),f=new Int32Array(s),p=new Int32Array(a.count);for(let y=0;y{const c=r(s);if(c<0)return-1;const u=t.get(c);return u.has(a)?u.get(a):-1},findSequenceKey:(s,a,c)=>{const u=r(s);if(u<0)return-1;const l=t.get(u);if(void 0===l)return-1;const d=l.get(a);if(void 0===d)return-1;const f=n.get(d),{elementIndices:p,seqRanges:m}=f,h=wr.firstIntersectionIndex(m,Fe.ofSingleton(c));return-1!==h?p[h]:-1}}}(t,u,c);return{chainKey:d,entityKey:f,findSequenceKey:h,findChainKey:m,getEntityFromChain:y=>p[y]}}function Qee(e,t){const n=[],r=[],i=en.transientSegments(e.chainElementSegments,Ce.ofBounds(0,e.count)),{seq_id_begin:o,seq_id_end:s}=e;for(;i.hasNext;){const{start:a,end:c}=i.move();let u=-1,l=-1;for(let d=a;d1&&(n.push(u,d-1),r.push(d-1,d),u=d),d===c-1&&n.push(u,d),l=f}}return{polymerRanges:wr.ofSortedRanges(n),gapRanges:wr.ofSortedRanges(r)}}const Jee={hierarchy:Kee.Empty,conformation:void 0};function C8e(e,t,n){const r=[0];for(let i=1,o=e.rowCount;i{if(t.has(n))return t.get(n);const r=e(n);return t.set(n,r),r}}function T8e(e){const t=new Map,n=(i,o,s)=>`${i}|${o}|${s}`,r=e.pdbx_unobs_or_zero_occ_residues;for(let i=0,o=r._rowCount;it.has(n(i,o,s)),get:(i,o,s)=>t.get(n(i,o,s)),size:t.size}}function D8e(e){const t=new Map;if(e.chem_comp._rowCount>0){const{id:n}=e.chem_comp;for(let r=0,i=n.rowCount;r{t.set(r,function sFe(e){return{formula:"",formula_weight:0,id:e,name:e,mon_nstd_flag:$b.has(e)?"y":"n",pdbx_synonyms:[],type:KQ(e)}}(r))});return t}function E8e(e){const t=new Map;if(e.pdbx_chem_comp_identifier._rowCount>0){const{comp_id:n,type:r,identifier:i}=e.pdbx_chem_comp_identifier;for(let o=0,s=n.rowCount;o0){const{id:n,type:r}=e.chem_comp;for(let i=0,o=n.rowCount;i{!t.has(i)&&n.has(i)&&t.set(i,r)})}return t}!function(e){let t;var u;(u=t=e.Kind||(e.Kind={})).Protein="protein",u.RNA="RNA",u.DNA="DNA",u.Generic="generic",e.getSequenceString=function n(u){const l=u.code.toArray();return(l instanceof Array?l:Array.from(l)).join("")},e.ofResidueNames=function o(u,l){if(0===l.rowCount)throw new Error("cannot be empty");const d=function r(u){for(let l=0,d=Math.min(u.rowCount,10);l"X";break;default:Rr()}return l&&l.size>0?f=>{const p=d(f);return"X"===p&&l.has(f)?d(l.get(f)):p}:d}(l),m=[],h=[],g=[],y=new Map;let b=0;const x=new Map;for(let S=0,A=f.rowCount;S{const I=p(D);return"X"===I?D:I});_[S]=`(${w.join("|")})`}else _[S]="X"===m[S]?h[S]:m[S]}this.length=b,this.code=te.ofStringArray(m),this.compId=te.ofStringArray(h),this.seqId=te.ofIntArray(g),this.label=te.ofStringArray(_),this.microHet=y,this.indexMap=x}}e.ofSequenceRanges=function a(u,l){return new c(t.Generic,u,l)};class c{index(l){return l-this.minSeqId}constructor(l,d,f){this.kind=l,this.seqIdStart=d,this.seqIdEnd=f,this.microHet=new Map;let p=0,m=Number.MAX_SAFE_INTEGER;for(let g=0,y=this.seqIdStart.rowCount;gg+m+1,rowCount:h,schema:te.Schema.int}),this.compId=te.ofConst("",h,te.Schema.str),this.length=h,this.minSeqId=m}}}(k2||(k2={})),function(e){const t={byEntityKey:{},sequences:[]};function n(...a){const c=[],u={};for(let l=0,d=a.length;l{const t=new Set,{label_comp_id:n,auth_comp_id:r}=e.atom_site,i=n.isDefined?n:r;for(let o=0,s=i.rowCount;o0?yield function F8e(e,t,n,r){return c4.apply(this,arguments)}(n,e,r,t):yield function N8e(e,t,n,r){return s4.apply(this,arguments)}(n,e,r,t);for(let o=0;o0?i[i.length-1]:void 0);i.push(d),a=c}}return i}),s4.apply(this,arguments)}function a4(e,t){const n=new Map,r=e._rowCount;let i=0;for(;iF._dynamicPropertyData[u]||{index:0,size:1},set:(F,G)=>F._dynamicPropertyData[u]=G};const l="__AsymIdCount__";e.AsymIdCount={get(F){if(F._dynamicPropertyData[l])return F._dynamicPropertyData[l];const G=function RMe(e){const t=new Set,n=new Set;return e.properties.structAsymMap.forEach(({auth_id:r},i)=>{t.add(r),n.add(i)}),{auth:t.size,label:n.size}}(F);return F._dynamicPropertyData[l]=G,G}},e.AsymIdOffset=Kg.createSimple("asym_id_offset","static"),e.Index=Kg.createSimple("index","static"),e.MaxIndex=Kg.createSimple("max_index","static"),e.getRoot=function d(F){return F.parent||F},e.areHierarchiesEqual=function f(F,G){return F.atomicHierarchy===G.atomicHierarchy&&F.coarseHierarchy===G.coarseHierarchy};const p="__CoordinatesHistory__";e.CoordinatesHistory={get:F=>F._staticPropertyData[p],set:(F,G)=>F._staticPropertyData[p]=G};const m="__CoarseGrained__";function h(F){let G=e.CoarseGrained.get(F);if(void 0===G){let L=0;const{polymerType:z}=F.atomicHierarchy.derived.residue;for(let q=0;qF._staticPropertyData[m],set:(F,G)=>F._staticPropertyData[m]=G},e.isCoarseGrained=h,e.hasCarbohydrate=function g(F){return F.properties.saccharideComponentMap.size>0},e.hasProtein=function y(F){const{subtype:G}=F.entities;for(let L=0,z=G.rowCount;L=0)return!0;return!1}function I(F){if(!Er.is(F.sourceData))return!1;const{db:G}=F.sourceData.data;for(let L=0;L=0)return!0;return!1}function T(F){if(!Er.is(F.sourceData)||!D(F))return!1;const{db:G}=F.sourceData.data,{status_code_sf:L}=G.pdbx_database_status;return L.isDefined&&"REL"===L.value(0)}function M(F){if(!Er.is(F.sourceData))return!1;const{db:G}=F.sourceData.data,{db_name:L,content_type:z}=G.pdbx_database_related;for(let j=0,Z=G.pdbx_database_related._rowCount;j=0)return!0;return!1},e.hasXrayMap=T,e.hasEmMap=M,e.hasDensityMap=N,e.probablyHasDensityMap=function V(F){if(!Er.is(F.sourceData))return!1;const{db:G}=F.sourceData.data;return N(F)||_(F)&&(!G.exptl.method.isDefined||D(F)&&(!G.pdbx_database_status.status_code_sf.isDefined||2===G.pdbx_database_status.status_code_sf.valueKind(0))||I(F)&&!G.pdbx_database_related.db_name.isDefined)}}(sn||(sn={})),function(e){e.getCifDataSource=function t(d,f,p){if(!f)return{rowCount:0};if(p&&p[f.id])return p[f.id];const m=f.getElements(d),h={data:m,rowCount:m.elements.length};return p&&(p[f.id]=h),h},e.fromAtomMap=function n(d){return new mte(d)},e.fromAtomArray=function r(d){return new mte(u4(d))};const i=d=>d.atomicHierarchy.residueAtomSegments;e.fromResidueMap=function o(d){return new RT("residue",d,i,0)},e.fromResidueArray=function s(d){return new RT("residue",u4(d),i,0)};const a=d=>d.atomicHierarchy.chainAtomSegments;e.fromChainMap=function c(d){return new RT("chain",d,a,0)},e.fromChainArray=function u(d){return new RT("chain",u4(d),a,0)},e.fromEntityMap=function l(d){return new B8e(d)}}(hte||(hte={}));class RT{has(t){return this.map.has(t)}get(t){return this.map.get(t)}getStructureElements(t){const n=t.models;if(1!==n.length)throw new Error("Only works on structures with a single model.");const r=new Set,i=t.unitSymmetryGroups,o=[],s=this.segmentGetter(n[0]);for(const a of i){const c=a.units[0];if(c.kind!==this.kind)continue;const u=en.transientSegments(s,c.elements);for(;u.hasNext;){const l=u.move();!this.has(l.index)||r.has(l.index)||(r.add(l.index),o[o.length]=nt.create(t,c,c.elements[l.start]))}}return o.sort((a,c)=>a.element-c.element),o}getElements(t){const n=this.segmentGetter(t.model).index,r=this.getStructureElements(t);return{elements:r,property:i=>this.get(n[r[i].element])}}constructor(t,n,r,i){this.level=t,this.map=n,this.segmentGetter=r,this.id=Hr.create22(),this.kind=i}}class mte{has(t){return this.map.has(t)}get(t){return this.map.get(t)}getStructureElements(t){if(1!==t.models.length)throw new Error("Only works on structures with a single model.");const r=new Set,i=t.unitSymmetryGroups,o=[];for(const s of i){const a=s.units[0];if(a.kind!==this.kind)continue;const c=a.elements;for(let u=0,l=c.length;us.element-a.element),o}getElements(t){const n=this.getStructureElements(t);return{elements:n,property:r=>this.get(n[r].element)}}constructor(t){this.map=t,this.id=Hr.create22(),this.level="atom",this.kind=0}}class B8e{has(t){return this.map.has(t)}get(t){return this.map.get(t)}getStructureElements(t){const n=t.models;if(1!==n.length)throw new Error("Only works on structures with a single model.");const r=n[0].atomicHierarchy.index,i=new Set,o=t.unitSymmetryGroups,s=[],a=n[0].atomicHierarchy.chainAtomSegments;for(const c of o){const u=c.units[0];if(u.kind!==this.kind)continue;const l=en.transientSegments(a,u.elements);for(;l.hasNext;){const d=l.move(),f=r.getEntityFromChain(d.index);!this.has(f)||i.has(f)||(i.add(f),s[s.length]=nt.create(t,u,u.elements[d.start]))}}return s.sort((c,u)=>c.element-u.element),s}getElements(t){const n=this.getStructureElements(t),r=t.model.atomicHierarchy.chainAtomSegments.index,i=t.model.atomicHierarchy.index;return{elements:n,property:o=>this.get(i.getEntityFromChain(r[n[o].element]))}}constructor(t){this.map=t,this.id=Hr.create22(),this.level="entity",this.kind=0}}!function(e){function t(a){const c=new DataView(a.buffer);return Object.assign(a.subarray(0),{readInt8:u=>c.getInt8(u),readUInt8:u=>c.getUint8(u),writeInt8:(u,l)=>c.setInt8(l,u),writeUInt8:(u,l)=>c.setUint8(l,u),readInt16LE:u=>c.getInt16(u,!0),readInt32LE:u=>c.getInt32(u,!0),readUInt16LE:u=>c.getUint16(u,!0),readUInt32LE:u=>c.getUint32(u,!0),readFloatLE:u=>c.getFloat32(u,!0),readDoubleLE:u=>c.getFloat64(u,!0),writeInt16LE:(u,l)=>c.setInt16(l,u,!0),writeInt32LE:(u,l)=>c.setInt32(l,u,!0),writeUInt16LE:(u,l)=>c.setUint16(l,u,!0),writeUInt32LE:(u,l)=>c.setUint32(l,u,!0),writeFloatLE:(u,l)=>c.setFloat32(l,u,!0),writeDoubleLE:(u,l)=>c.setFloat64(l,u,!0),readInt16BE:u=>c.getInt16(u,!1),readInt32BE:u=>c.getInt32(u,!1),readUInt16BE:u=>c.getUint16(u,!1),readUInt32BE:u=>c.getUint32(u,!1),readFloatBE:u=>c.getFloat32(u,!1),readDoubleBE:u=>c.getFloat64(u,!1),writeInt16BE:(u,l)=>c.setInt16(l,u,!1),writeInt32BE:(u,l)=>c.setInt32(l,u,!1),writeUInt16BE:(u,l)=>c.setUint16(l,u,!1),writeUInt32BE:(u,l)=>c.setUint32(l,u,!1),writeFloatBE:(u,l)=>c.setFloat32(l,u,!1),writeDoubleBE:(u,l)=>c.setFloat64(l,u,!1),copy:(u,l,d,f)=>(l=Ds(l,0),d=Ds(d,0),f=Ds(f,a.length),u.set(a.subarray(d,f),l),f-d)})}function i(a,c,u,l,d){for(let f=0,p=u;f>8&255}},e.ensureLittleEndian=function s(a,c,u,l,d){e.IsNativeEndianLittle||!u||l<=1||i(a,c,u,l,d)}}(cd||(cd={})),function(e){e.fromBuffer=function t(n,r){return{name:r,readBuffer:(i,o,s,a)=>{let c,u;if("number"==typeof o){s=Ds(s,o);const l=i,d=Math.min(n.length,l+s);c=d-l,u=cd.fromUint8Array(new Uint8Array(n.buffer,l,d-l))}else{s=Ds(s,o.length);const l=i,d=Math.min(n.length,l+s);o.set(n.subarray(l,d),a),c=d-l,u=o}return s!==c&&console.warn(`byteCount ${s} and bytesRead ${c} differ`),Promise.resolve({bytesRead:c,buffer:u})},writeBuffer:(i,o,s)=>(s=Ds(s,o.length),console.error(".writeBuffer not implemented for FileHandle.fromBuffer"),Promise.resolve(0)),writeBufferSync:(i,o,s)=>(s=Ds(s,o.length),console.error(".writeSync not implemented for FileHandle.fromBuffer"),0),close:Ag}}}(kT||(kT={}));var us=function(e){return e.Float32="float32",e.Int8="int8",e.Int16="int16",e.Uint16="uint16",e}(us||{});function gte(e){return e===us.Float32?4:e===us.Int16||e===us.Uint16?2:1}function O8e(e,t,n=0,r){return e===us.Float32?new Float32Array(t,n,r):e===us.Int16?new Int16Array(t,n,r):e===us.Uint16?new Uint16Array(t,n,r):new Int8Array(t,n,r)}function l4(){return l4=ie(function*(e,t,n,r,i,o){return yield t.readBuffer(n,e.readBuffer,r,i),e.elementByteSize>1&&(void 0!==o&&o!==cd.IsNativeEndianLittle||!cd.IsNativeEndianLittle)&&cd.flipByteOrder(e.readBuffer,e.valuesBuffer,r,e.elementByteSize,i),e.values}),l4.apply(this,arguments)}function d4(){return d4=ie(function*(e){const{buffer:n}=yield e.readBuffer(0,1024),r=String.fromCharCode(n.readUInt8(208),n.readUInt8(209),n.readUInt8(210),n.readUInt8(211));if("MAP "!==r)throw new Error('ccp4 format error, missing "MAP " string');const i=[n.readUInt8(212),n.readUInt8(213)];let o=!1;68===i[0]&&65===i[1]?o=!0:17===i[0]&&17===i[1]?o=!1:n.readInt32LE(12)<=16&&(o=!0);const s=o?u=>n.readInt32LE(4*u):u=>n.readInt32BE(4*u),a=o?u=>n.readFloatLE(4*u):u=>n.readFloatBE(4*u);return{header:{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:a(10),yLength:a(11),zLength:a(12),alpha:a(13),beta:a(14),gamma:a(15),MAPC:s(16),MAPR:s(17),MAPS:s(18),AMIN:a(19),AMAX:a(20),AMEAN:a(21),ISPG:s(22),NSYMBT:s(23),LSKFLG:s(24),SKWMAT:[],SKWTRN:[],userFlag1:s(39),userFlag2:s(40),originX:a(49),originY:a(50),originZ:a(51),MAP:r,MACHST:i,ARMS:a(54)},littleEndian:o}}),d4.apply(this,arguments)}function f4(){return f4=ie(function*(e,t,n,r,i,o){if(bte(e)){const s=3*i;yield n.readBuffer(r,t.readBuffer,i,s);const a=new Int8Array(t.valuesBuffer.buffer,s),c=(e.AMAX-e.AMIN)/255,u=.5*(e.AMIN+e.AMAX+c);for(let l=0,d=i;le.readInt16LE(2*i):i=>e.readInt16BE(2*i),r=1/n(17);return{xStart:n(0),yStart:n(1),zStart:n(2),xExtent:n(3),yExtent:n(4),zExtent:n(5),xRate:n(6),yRate:n(7),zRate:n(8),xlen:n(9)*r,ylen:n(10)*r,zlen:n(11)*r,alpha:n(12)*r,beta:n(13)*r,gamma:n(14)*r,divisor:n(15)/100,summand:n(16),sigma:void 0}}function _te(e){const{xExtent:t,yExtent:n,zExtent:r}=e;return{xBlocks:Math.ceil(t/8),yBlocks:Math.ceil(n/8),zBlocks:Math.ceil(r/8)}}function m4(){return m4=ie(function*(e){const{buffer:t}=yield e.readBuffer(0,h4),n=String.fromCharCode.apply(null,t),r=n.startsWith(":-)"),i=r||100===t.readInt16LE(36);return{header:r?W8e(n):$8e(t,i),littleEndian:i}}),m4.apply(this,arguments)}function g4(){return g4=ie(function*(e,t,n,r){r||cd.flipByteOrderInPlace2(t.buffer);const{divisor:i,summand:o,xExtent:s,yExtent:a,zExtent:c}=e,{xBlocks:u,yBlocks:l,zBlocks:d}=_te(e);let f=0;for(let p=0;pl.get(d)})}function cUe(e,t){const{elements:n,tokenizer:r}=e,{count:i,property:o}=t,s=He.create(r.data,2*i*3),a=new Uint32Array(i+1);let c=0;for(let d=0,f=i;d{const f=a[d]+1,p=l.value(f-1);for(let m=f,h=f+p;mr.get(i)}}(r,i.map(c=>c.name),o);return Fr.success(a)}),v4.apply(this,arguments)}const{readLine:NT,skipWhitespace:Ste,eatValue:Cte,eatLine:dUe,markStart:_4}=ht,FT=/\s+/,fUe=/(^\*|REMARK)*/;function hUe(e,t){return x4.apply(this,arguments)}function x4(){return x4=ie(function*(e,t){const{tokenizer:n}=e,r=He.create(n.data,2*t),i=He.create(n.data,2*t),o=He.create(n.data,2*t),s=He.create(n.data,2*t),a=He.create(n.data,2*t),c=He.create(n.data,2*t),u=He.create(n.data,2*t),l=He.create(n.data,2*t),{position:d}=n,f=NT(n).trim();n.position=d;const p=7===f.split(FT).length,m=p?6:8,{length:h}=n;let g=0;return yield op(e.runtimeCtx,1e5,void 0,y=>{const b=Math.min(t-g,y);for(let x=0;xy.update({message:"Parsing...",current:n.position,max:h})),{count:t,atomId:Jt(r)(te.Schema.int),segmentName:p?Jt(o)(te.Schema.str):Jt(i)(te.Schema.str),residueId:Jt(o)(te.Schema.int),residueName:p?Jt(o)(te.Schema.str):Jt(s)(te.Schema.str),atomName:Jt(a)(te.Schema.str),atomType:Jt(c)(te.Schema.str),charge:Jt(u)(te.Schema.float),mass:Jt(l)(te.Schema.float)}}),x4.apply(this,arguments)}function mUe(e,t){return S4.apply(this,arguments)}function S4(){return S4=ie(function*(e,t){const{tokenizer:n}=e,r=He.create(n.data,2*t),i=He.create(n.data,2*t),{length:o}=n;let s=0;return yield op(e.runtimeCtx,10,void 0,a=>{const c=Math.min(t-s,a);for(let u=0;ua.update({message:"Parsing...",current:n.position,max:o})),{count:t,atomIdA:Jt(r)(te.Schema.int),atomIdB:Jt(i)(te.Schema.int)}}),S4.apply(this,arguments)}function gUe(e,t){const n=[];for(let r=0;rn(i)},e.create=n,e.hasTag=function r(i,o){if(!i.tags)return!1;for(const s of i.tags)if(s===o)return!0;return!1},e.Null={id:Hr.create22(),type:{name:"Null",typeClass:"Null"},data:void 0,label:"Null"}}(li||(li={})),function(e){e.is=function t(r){return!!(r&&r.transform&&r.parent&&r.status)},e.resolve=function n(r,i){const o="string"==typeof i?i:e.is(i)?i.transform.ref:i.ref;return r.cells.get(o)}}(N2||(N2={}));class wte{get cell(){var t;return null===(t=this.state)||void 0===t?void 0:t.cells.get(this.ref)}get obj(){var t,n;return null===(n=null===(t=this.state)||void 0===t?void 0:t.cells.get(this.ref))||void 0===n?void 0:n.obj}get data(){var t;return null===(t=this.obj)||void 0===t?void 0:t.data}update(t,n){if(!this.state)throw new Error("To use update() from StateObjectSelector, 'state' must be defined.");return n||(n=this.state.build()),(n||this.state.build()).to(this).update(t),n}checkValid(){if(!this.state)throw new Error("Unassigned State.");const t=this.cell;if(!t)throw new Error("Not created at all. Did you await/then the corresponding state update?");if("ok"===t.status)return!0;throw"error"===t.status?new Error(t.errorText):t.obj===li.Null?new Error("The object is Null."):new Error("Unresolved. Did you await/then the corresponding state update?")}get isOk(){const t=this.cell;return t&&"ok"===t.status&&t.obj!==li.Null}constructor(t,n){this.ref=t,this.state=n}}!function(e){function n(i,o){if(o)return N2.is(o)?o:"string"==typeof o?i.cells.get(o):o.cell}e.resolveRef=function t(i){var o;if(i)return"string"==typeof i?i:N2.is(i)?i.transform.ref:null===(o=i.cell)||void 0===o?void 0:o.transform.ref},e.resolve=n,e.resolveAndCheck=function r(i,o){const s=n(i,o);if(s&&s.obj&&"ok"===s.status)return s}}(ls||(ls={}));var F2="delete",Yi=5,Qu=1<>>0;if(""+n!==t||4294967295===n)return NaN;t=n}return t<0?nv(e)+t:t}function Ate(){return!0}function B2(e,t,n){return(0===e&&!Tte(e)||void 0!==n&&e<=-n)&&(void 0===t||void 0!==n&&t>=n)}function rv(e,t){return Ite(e,t,0)}function O2(e,t){return Ite(e,t,t)}function Ite(e,t,n){return void 0===e?n:Tte(e)?t===1/0?t:0|Math.max(0,t+e):void 0===t||t===e?e:0|Math.min(t,e)}function Tte(e){return e<0||0===e&&1/e==-1/0}var Dte="@@__IMMUTABLE_ITERABLE__@@";function Qa(e){return!(!e||!e[Dte])}var Ete="@@__IMMUTABLE_KEYED__@@";function Li(e){return!(!e||!e[Ete])}var Pte="@@__IMMUTABLE_INDEXED__@@";function ga(e){return!(!e||!e[Pte])}function L2(e){return Li(e)||ga(e)}var yo=function(t){return Qa(t)?t:ec(t)},el=function(e){function t(n){return Li(n)?n:am(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t}(yo),Zg=function(e){function t(n){return ga(n)?n:il(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t}(yo),iv=function(e){function t(n){return Qa(n)&&!L2(n)?n:av(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t}(yo);yo.Keyed=el,yo.Indexed=Zg,yo.Set=iv;var Mte="@@__IMMUTABLE_SEQ__@@";function BT(e){return!(!e||!e[Mte])}var Rte="@@__IMMUTABLE_RECORD__@@";function Qg(e){return!(!e||!e[Rte])}function tl(e){return Qa(e)||Qg(e)}var ov="@@__IMMUTABLE_ORDERED__@@";function nl(e){return!(!e||!e[ov])}var U2=0,ud=1,rl=2,I4="function"==typeof Symbol&&Symbol.iterator,kte="@@iterator",OT=I4||kte,Wr=function(t){this.next=t};function Xi(e,t,n,r){var i=0===e?t:1===e?n:[t,n];return r?r.value=i:r={value:i,done:!1},r}function Ja(){return{value:void 0,done:!0}}function T4(e){return!!Array.isArray(e)||!!LT(e)}function Nte(e){return e&&"function"==typeof e.next}function D4(e){var t=LT(e);return t&&t.call(e)}function LT(e){var t=e&&(I4&&e[I4]||e[kte]);if("function"==typeof t)return t}Wr.prototype.toString=function(){return"[Iterator]"},Wr.KEYS=U2,Wr.VALUES=ud,Wr.ENTRIES=rl,Wr.prototype.inspect=Wr.prototype.toSource=function(){return this.toString()},Wr.prototype[OT]=function(){return this};var sv=Object.prototype.hasOwnProperty;function E4(e){return!(!Array.isArray(e)&&"string"!=typeof e)||e&&"object"==typeof e&&Number.isInteger(e.length)&&e.length>=0&&(0===e.length?1===Object.keys(e).length:e.hasOwnProperty(e.length-1))}var ec=function(e){function t(n){return null==n?M4():tl(n)?n.toSeq():function SUe(e){var t=k4(e);if(t)return function vUe(e){var t=LT(e);return t&&t===e.entries}(e)?t.fromEntrySeq():function _Ue(e){var t=LT(e);return t&&t===e.keys}(e)?t.toSetSeq():t;if("object"==typeof e)return new P4(e);throw new TypeError("Expected Array or collection object of values, or keyed object: "+e)}(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.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(r,i){var o=this._cache;if(o){for(var s=o.length,a=0;a!==s;){var c=o[i?s-++a:a++];if(!1===r(c[1],c[0],this))break}return a}return this.__iterateUncached(r,i)},t.prototype.__iterator=function(r,i){var o=this._cache;if(o){var s=o.length,a=0;return new Wr(function(){if(a===s)return{value:void 0,done:!0};var c=o[i?s-++a:a++];return Xi(r,c[0],c[1])})}return this.__iteratorUncached(r,i)},t}(yo),am=function(e){function t(n){return null==n?M4().toKeyedSeq():Qa(n)?Li(n)?n.toSeq():n.fromEntrySeq():Qg(n)?n.toSeq():R4(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.toKeyedSeq=function(){return this},t}(ec),il=function(e){function t(n){return null==n?M4():Qa(n)?Li(n)?n.entrySeq():n.toIndexedSeq():Qg(n)?n.toSeq().entrySeq():Bte(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.of=function(){return t(arguments)},t.prototype.toIndexedSeq=function(){return this},t.prototype.toString=function(){return this.__toString("Seq [","]")},t}(ec),av=function(e){function t(n){return(Qa(n)&&!L2(n)?n:il(n)).toSetSeq()}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.of=function(){return t(arguments)},t.prototype.toSetSeq=function(){return this},t}(ec);ec.isSeq=BT,ec.Keyed=am,ec.Set=av,ec.Indexed=il,ec.prototype[Mte]=!0;var Jg=function(e){function t(n){this._array=n,this.size=n.length}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.get=function(r,i){return this.has(r)?this._array[sm(this,r)]:i},t.prototype.__iterate=function(r,i){for(var o=this._array,s=o.length,a=0;a!==s;){var c=i?s-++a:a++;if(!1===r(o[c],c,this))break}return a},t.prototype.__iterator=function(r,i){var o=this._array,s=o.length,a=0;return new Wr(function(){if(a===s)return{value:void 0,done:!0};var c=i?s-++a:a++;return Xi(r,c,o[c])})},t}(il),P4=function(e){function t(n){var r=Object.keys(n).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(n):[]);this._object=n,this._keys=r,this.size=r.length}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.get=function(r,i){return void 0===i||this.has(r)?this._object[r]:i},t.prototype.has=function(r){return sv.call(this._object,r)},t.prototype.__iterate=function(r,i){for(var o=this._object,s=this._keys,a=s.length,c=0;c!==a;){var u=s[i?a-++c:c++];if(!1===r(o[u],u,this))break}return c},t.prototype.__iterator=function(r,i){var o=this._object,s=this._keys,a=s.length,c=0;return new Wr(function(){if(c===a)return{value:void 0,done:!0};var u=s[i?a-++c:c++];return Xi(r,u,o[u])})},t}(am);P4.prototype[ov]=!0;var Fte,xUe=function(e){function t(n){this._collection=n,this.size=n.length||n.size}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.__iterateUncached=function(r,i){if(i)return this.cacheResult().__iterate(r,i);var s=D4(this._collection),a=0;if(Nte(s))for(var c;!(c=s.next()).done&&!1!==r(c.value,a++,this););return a},t.prototype.__iteratorUncached=function(r,i){if(i)return this.cacheResult().__iterator(r,i);var s=D4(this._collection);if(!Nte(s))return new Wr(Ja);var a=0;return new Wr(function(){var c=s.next();return c.done?c:Xi(r,a++,c.value)})},t}(il);function M4(){return Fte||(Fte=new Jg([]))}function R4(e){var t=k4(e);if(t)return t.fromEntrySeq();if("object"==typeof e)return new P4(e);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+e)}function Bte(e){var t=k4(e);if(t)return t;throw new TypeError("Expected Array or collection object of values: "+e)}function k4(e){return E4(e)?new Jg(e):T4(e)?new xUe(e):void 0}var Ote="@@__IMMUTABLE_MAP__@@";function UT(e){return!(!e||!e[Ote])}function N4(e){return UT(e)&&nl(e)}function F4(e){return!(!e||"function"!=typeof e.equals||"function"!=typeof e.hashCode)}function Ns(e,t){if(e===t||e!=e&&t!=t)return!0;if(!e||!t)return!1;if("function"==typeof e.valueOf&&"function"==typeof t.valueOf){if((e=e.valueOf())===(t=t.valueOf())||e!=e&&t!=t)return!0;if(!e||!t)return!1}return!!(F4(e)&&F4(t)&&e.equals(t))}var V2="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,n){var r=65535&(t|=0),i=65535&(n|=0);return r*i+((t>>>16)*i+r*(n>>>16)<<16>>>0)|0};function VT(e){return e>>>1&1073741824|3221225471&e}var CUe=Object.prototype.valueOf;function Mc(e){if(null==e)return Lte(e);if("function"==typeof e.hashCode)return VT(e.hashCode(e));var t=function EUe(e){return e.valueOf!==CUe&&"function"==typeof e.valueOf?e.valueOf(e):e}(e);if(null==t)return Lte(t);switch(typeof t){case"boolean":return t?1108378657:1108378656;case"number":return function wUe(e){if(e!=e||e===1/0)return 0;var t=0|e;for(t!==e&&(t^=4294967295*e);e>4294967295;)t^=e/=4294967295;return VT(t)}(t);case"string":return t.length>PUe?function AUe(e){var t=z4[e];return void 0===t&&(t=B4(e),V4===MUe&&(V4=0,z4={}),V4++,z4[e]=t),t}(t):B4(t);case"object":case"function":return function TUe(e){var t;if(O4&&void 0!==(t=L4.get(e))||void 0!==(t=e[e0])||!Vte&&(void 0!==(t=e.propertyIsEnumerable&&e.propertyIsEnumerable[e0])||(t=function DUe(e){if(e&&e.nodeType>0)switch(e.nodeType){case 1:return e.uniqueID;case 9:return e.documentElement&&e.documentElement.uniqueID}}(e),void 0!==t)))return t;if(t=zte(),O4)L4.set(e,t);else{if(void 0!==Ute&&!1===Ute(e))throw new Error("Non-extensible objects are not allowed as keys.");if(Vte)Object.defineProperty(e,e0,{enumerable:!1,configurable:!1,writable:!1,value:t});else if(void 0!==e.propertyIsEnumerable&&e.propertyIsEnumerable===e.constructor.prototype.propertyIsEnumerable)e.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},e.propertyIsEnumerable[e0]=t;else{if(void 0===e.nodeType)throw new Error("Unable to set a non-enumerable property on object.");e[e0]=t}}return t}(t);case"symbol":return function IUe(e){var t=Gte[e];return void 0!==t||(t=zte(),Gte[e]=t),t}(t);default:if("function"==typeof t.toString)return B4(t.toString());throw new Error("Value type "+typeof t+" cannot be hashed.")}}function Lte(e){return null===e?1108378658:1108378659}function B4(e){for(var t=0,n=0;n=0&&(u.get=function(l,d){return(l=sm(this,l))>=0&&lc)return{value:void 0,done:!0};var h=f.next();return r||l===ud||h.done?h:Xi(l,m-1,l===U2?void 0:h.value[1],h)})},u}function Xte(e,t,n,r){var i=cf(e);return i.__iterateUncached=function(o,s){var a=this;if(s)return this.cacheResult().__iterate(o,s);var c=!0,u=0;return e.__iterate(function(l,d,f){if(!c||!(c=t.call(n,l,d,f)))return u++,o(l,r?d:u-1,a)}),u},i.__iteratorUncached=function(o,s){var a=this;if(s)return this.cacheResult().__iterator(o,s);var c=e.__iterator(rl,s),u=!0,l=0;return new Wr(function(){var d,f,p;do{if((d=c.next()).done)return r||o===ud?d:Xi(o,l++,o===U2?void 0:d.value[1],d);var m=d.value;f=m[0],p=m[1],u&&(u=t.call(n,p,f,a))}while(u);return o===rl?d:Xi(o,f,p,d)})},i}function Kte(e,t,n){var r=cf(e);return r.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var s=0,a=!1;return function c(u,l){u.__iterate(function(d,f){return(!t||l0}function jT(e,t,n,r){var i=cf(e),o=new Jg(n).map(function(s){return s.size});return i.size=r?o.max():o.min(),i.__iterate=function(s,a){for(var u,c=this.__iterator(ud,a),l=0;!(u=c.next()).done&&!1!==s(u.value,l++,this););return l},i.__iteratorUncached=function(s,a){var c=n.map(function(d){return d=yo(d),D4(a?d.reverse():d)}),u=0,l=!1;return new Wr(function(){var d;return l||(d=c.map(function(f){return f.next()}),l=r?d.every(function(f){return f.done}):d.some(function(f){return f.done})),l?{value:void 0,done:!0}:Xi(s,u++,t.apply(null,d.map(function(f){return f.value})))})},i}function Ti(e,t){return e===t?e:BT(e)?t:e.constructor(t)}function Qte(e){if(e!==Object(e))throw new TypeError("Expected [K, V] tuple: "+e)}function H4(e){return Li(e)?el:ga(e)?Zg:iv}function cf(e){return Object.create((Li(e)?am:ga(e)?il:av).prototype)}function q4(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):ec.prototype.cacheResult.call(this)}function Jte(e,t){return void 0===e&&void 0===t?0:void 0===e?1:void 0===t?-1:e>t?1:e0;)t[n]=arguments[n+1];if("function"!=typeof e)throw new TypeError("Invalid merger function: "+e);return une(this,t,e)}function une(e,t,n){for(var r=[],i=0;i0;)t[n]=arguments[n+1];return G2(this,t,e)}function eL(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return t0(this,e,ld(),function(r){return j2(r,t)})}function tL(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return t0(this,e,ld(),function(r){return G2(r,t)})}function H2(e){var t=this.asMutable();return e(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this}function q2(){return this.__ownerID?this:this.__ensureOwner(new A4)}function W2(){return this.__ensureOwner()}function nL(){return this.__altered}var gu=function(e){function t(n){return null==n?ld():UT(n)&&!nl(n)?n:ld().withMutations(function(r){var i=e(n);mu(i.size),i.forEach(function(o,s){return r.set(s,o)})})}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.of=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];return ld().withMutations(function(o){for(var s=0;s=r.length)throw new Error("Missing value for key: "+r[s]);o.set(r[s],r[s+1])}})},t.prototype.toString=function(){return this.__toString("Map {","}")},t.prototype.get=function(r,i){return this._root?this._root.get(0,void 0,r,i):i},t.prototype.set=function(r,i){return hne(this,r,i)},t.prototype.remove=function(r){return hne(this,r,Pr)},t.prototype.deleteAll=function(r){var i=yo(r);return 0===i.size?this:this.withMutations(function(o){i.forEach(function(s){return o.remove(s)})})},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):ld()},t.prototype.sort=function(r){return ol(cv(this,r))},t.prototype.sortBy=function(r,i){return ol(cv(this,i,r))},t.prototype.map=function(r,i){var o=this;return this.withMutations(function(s){s.forEach(function(a,c){s.set(c,r.call(i,a,c,o))})})},t.prototype.__iterator=function(r,i){return new WUe(this,r,i)},t.prototype.__iterate=function(r,i){var o=this,s=0;return this._root&&this._root.iterate(function(a){return s++,r(a[1],a[0],o)},i),s},t.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?iL(this.size,this._root,r,this.__hash):0===this.size?ld():(this.__ownerID=r,this.__altered=!1,this)},t}(el);gu.isMap=UT;var Ki=gu.prototype;Ki[Ote]=!0,Ki[F2]=Ki.remove,Ki.removeAll=Ki.deleteAll,Ki.setIn=X4,Ki.removeIn=Ki.deleteIn=K4,Ki.update=Q4,Ki.updateIn=J4,Ki.merge=Ki.concat=ane,Ki.mergeWith=cne,Ki.mergeDeep=lne,Ki.mergeDeepWith=dne,Ki.mergeIn=eL,Ki.mergeDeepIn=tL,Ki.withMutations=H2,Ki.wasAltered=nL,Ki.asImmutable=W2,Ki["@@transducer/init"]=Ki.asMutable=q2,Ki["@@transducer/step"]=function(e,t){return e.set(t[0],t[1])},Ki["@@transducer/result"]=function(e){return e.asImmutable()};var $2=function(t,n){this.ownerID=t,this.entries=n};$2.prototype.get=function(t,n,r,i){for(var o=this.entries,s=0,a=o.length;s=QUe)return function $Ue(e,t,n,r){e||(e=new A4);for(var i=new Sp(e,Mc(n),[n,r]),o=0;o>>t)&Za),s=this.bitmap;return s&o?this.nodes[gne(s&o-1)].get(t+Yi,n,r,i):i},uv.prototype.update=function(t,n,r,i,o,s,a){void 0===r&&(r=Mc(i));var c=(0===n?r:r>>>n)&Za,u=1<=JUe)return function XUe(e,t,n,r,i){for(var o=0,s=new Array(Qu),a=0;0!==n;a++,n>>>=1)s[a]=1&n?t[o++]:void 0;return s[r]=i,new Y2(e,o+1,s)}(t,p,l,c,h);if(d&&!h&&2===p.length&&mne(p[1^f]))return p[1^f];if(d&&h&&1===p.length&&mne(h))return h;var g=t&&t===this.ownerID,y=d?h?l:l^u:l|u,b=d?h?yne(p,f,h,g):function ZUe(e,t,n){var r=e.length-1;if(n&&t===r)return e.pop(),e;for(var i=new Array(r),o=0,s=0;s>>t)&Za];return s?s.get(t+Yi,n,r,i):i},Y2.prototype.update=function(t,n,r,i,o,s,a){void 0===r&&(r=Mc(i));var c=(0===n?r:r>>>n)&Za,l=this.nodes,d=l[c];if(o===Pr&&!d)return this;var f=oL(d,t,n+Yi,r,i,o,s,a);if(f===d)return this;var p=this.count;if(d){if(!f&&--p>>n)&Za,s=(0===n?r:r>>>n)&Za,c=o===s?[sL(e,t,n+Yi,r,i)]:(a=new Sp(t,r,i),o>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,127&(e+=e>>8)+(e>>16)}function yne(e,t,n,r){var i=r?e:uf(e);return i[t]=n,i}var QUe=Qu/4,JUe=Qu/2,eVe=Qu/4,bne="@@__IMMUTABLE_LIST__@@";function aL(e){return!(!e||!e[bne])}var Cp=function(e){function t(n){var r=qT();if(null==n)return r;if(aL(n))return n;var i=e(n),o=i.size;return 0===o?r:(mu(o),o>0&&o=0&&r=e.size||t<0)return e.withMutations(function(s){t<0?lm(s,t).set(0,n):lm(s,0,t+1).set(t,n)});var r=e._tail,i=e._root,o={value:!1};return(t+=e._origin)>=Z2(e._capacity)?r=cL(r,e.__ownerID,0,t,n,o):i=cL(i,e.__ownerID,e._level,t,n,o),o.value?e.__ownerID?(e._root=i,e._tail=r,e.__hash=void 0,e.__altered=!0,e):K2(e._origin,e._capacity,e._level,i,r):e}(this,r,i)},t.prototype.remove=function(r){return this.has(r)?0===r?this.shift():r===this.size-1?this.pop():this.splice(r,1):this},t.prototype.insert=function(r,i){return this.splice(r,0,i)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=Yi,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):qT()},t.prototype.push=function(){var r=arguments,i=this.size;return this.withMutations(function(o){lm(o,0,i+r.length);for(var s=0;s>>n&Za;if(i>=this.array.length)return new um([],t);var s,o=0===i;if(n>0){var a=this.array[i];if((s=a&&a.removeBefore(t,n-Yi,r))===a&&o)return this}if(o&&!s)return this;var c=dv(this,t);if(!o)for(var u=0;u>>n&Za;if(i>=this.array.length)return this;if(n>0){var s=this.array[i];if((o=s&&s.removeAfter(t,n-Yi,r))===s&&i===this.array.length-1)return this}var a=dv(this,t);return a.array.splice(i+1),o&&(a.array[i]=o),a};var _ne,X2={};function vne(e,t){var n=e._origin,r=e._capacity,i=Z2(r),o=e._tail;return function s(u,l,d){return 0===l?function a(u,l){var d=l===i?o&&o.array:u&&u.array,f=l>n?0:n-l,p=r-l;return p>Qu&&(p=Qu),function(){if(f===p)return X2;var m=t?--p:f++;return d&&d[m]}}(u,d):function c(u,l,d){var f,p=u&&u.array,m=d>n?0:n-d>>l,h=1+(r-d>>l);return h>Qu&&(h=Qu),function(){for(;;){if(f){var g=f();if(g!==X2)return g;f=null}if(m===h)return X2;var y=t?--h:m++;f=s(p&&p[y],l-Yi,d+(y<>>n&Za,a=e&&s0){var u=e&&e.array[s],l=cL(u,t,n-Yi,r,i,o);return l===u?e:((c=dv(e,t)).array[s]=l,c)}return a&&e.array[s]===i?e:(o&&Ju(o),c=dv(e,t),void 0===i&&s===c.array.length-1?c.array.pop():c.array[s]=i,c)}function dv(e,t){return t&&e&&t===e.ownerID?e:new um(e?e.array.slice():[],t)}function xne(e,t){if(t>=Z2(e._capacity))return e._tail;if(t<1<0;)n=n.array[t>>>r&Za],r-=Yi;return n}}function lm(e,t,n){void 0!==t&&(t|=0),void 0!==n&&(n|=0);var r=e.__ownerID||new A4,i=e._origin,o=e._capacity,s=i+t,a=void 0===n?o:n<0?o+n:i+n;if(s===i&&a===o)return e;if(s>=a)return e.clear();for(var c=e._level,u=e._root,l=0;s+l<0;)u=new um(u&&u.array.length?[void 0,u]:[],r),l+=1<<(c+=Yi);l&&(s+=l,i+=l,a+=l,o+=l);for(var d=Z2(o),f=Z2(a);f>=1<d?new um([],r):p;if(p&&f>d&&sYi;g-=Yi){var y=d>>>g&Za;h=h.array[y]=dv(h.array[y],r)}h.array[d>>>Yi&Za]=p}if(a=f)s-=f,a-=f,c=Yi,u=null,m=m&&m.removeBefore(r,0,s);else if(s>i||f>>c&Za;if(b!==f>>>c&Za)break;b&&(l+=(1<i&&(u=u.removeBefore(r,c,s-l)),u&&f>>Yi<=Qu&&i.size>=2*r.size?(a=(c=i.filter(function(u,l){return void 0!==u&&o!==l})).toKeyedSeq().map(function(u){return u[0]}).flip().toMap(),e.__ownerID&&(a.__ownerID=c.__ownerID=e.__ownerID)):(a=r.remove(t),c=o===i.size-1?i.pop():i.set(o,void 0))}else if(s){if(n===i.get(o)[1])return e;a=r,c=i.set(o,[t,n])}else a=r.set(t,i.size),c=i.set(i.size,[t,n]);return e.__ownerID?(e.size=a.size,e._map=a,e._list=c,e.__hash=void 0,e.__altered=!0,e):uL(a,c)}ol.isOrderedMap=N4,ol.prototype[ov]=!0,ol.prototype[F2]=ol.prototype.remove;var wne="@@__IMMUTABLE_STACK__@@";function WT(e){return!(!e||!e[wne])}var $T=function(e){function t(n){return null==n?YT():WT(n)?n:YT().pushAll(n)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("Stack [","]")},t.prototype.get=function(r,i){var o=this._head;for(r=sm(this,r);o&&r--;)o=o.next;return o?o.value:i},t.prototype.peek=function(){return this._head&&this._head.value},t.prototype.push=function(){var r=arguments;if(0===arguments.length)return this;for(var i=this.size+arguments.length,o=this._head,s=arguments.length-1;s>=0;s--)o={value:r[s],next:o};return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):J2(i,o)},t.prototype.pushAll=function(r){if(0===(r=e(r)).size)return this;if(0===this.size&&WT(r))return r;mu(r.size);var i=this.size,o=this._head;return r.__iterate(function(s){i++,o={value:s,next:o}},!0),this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):J2(i,o)},t.prototype.pop=function(){return this.slice(1)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):YT()},t.prototype.slice=function(r,i){if(B2(r,i,this.size))return this;var o=rv(r,this.size);if(O2(i,this.size)!==this.size)return e.prototype.slice.call(this,r,i);for(var a=this.size-o,c=this._head;o--;)c=c.next;return this.__ownerID?(this.size=a,this._head=c,this.__hash=void 0,this.__altered=!0,this):J2(a,c)},t.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?J2(this.size,this._head,r,this.__hash):0===this.size?YT():(this.__ownerID=r,this.__altered=!1,this)},t.prototype.__iterate=function(r,i){var o=this;if(i)return new Jg(this.toArray()).__iterate(function(c,u){return r(c,u,o)},i);for(var s=0,a=this._head;a&&!1!==r(a.value,s++,this);)a=a.next;return s},t.prototype.__iterator=function(r,i){if(i)return new Jg(this.toArray()).__iterator(r,i);var o=0,s=this._head;return new Wr(function(){if(s){var a=s.value;return s=s.next,Xi(r,o++,a)}return{value:void 0,done:!0}})},t}(Zg);$T.isStack=WT;var Ane,tc=$T.prototype;function J2(e,t,n,r){var i=Object.create(tc);return i.size=e,i._head=t,i.__ownerID=n,i.__hash=r,i.__altered=!1,i}function YT(){return Ane||(Ane=J2(0))}tc[wne]=!0,tc.shift=tc.pop,tc.unshift=tc.push,tc.unshiftAll=tc.pushAll,tc.withMutations=H2,tc.wasAltered=nL,tc.asImmutable=W2,tc["@@transducer/init"]=tc.asMutable=q2,tc["@@transducer/step"]=function(e,t){return e.unshift(t)},tc["@@transducer/result"]=function(e){return e.asImmutable()};var Ine="@@__IMMUTABLE_SET__@@";function XT(e){return!(!e||!e[Ine])}function lL(e){return XT(e)&&nl(e)}function dL(e,t){if(e===t)return!0;if(!Qa(t)||void 0!==e.size&&void 0!==t.size&&e.size!==t.size||void 0!==e.__hash&&void 0!==t.__hash&&e.__hash!==t.__hash||Li(e)!==Li(t)||ga(e)!==ga(t)||nl(e)!==nl(t))return!1;if(0===e.size&&0===t.size)return!0;var n=!L2(e);if(nl(e)){var r=e.entries();return t.every(function(c,u){var l=r.next().value;return l&&Ns(l[1],c)&&(n||Ns(l[0],u))})&&r.next().done}var i=!1;if(void 0===e.size)if(void 0===t.size)"function"==typeof e.cacheResult&&e.cacheResult();else{i=!0;var o=e;e=t,t=o}var s=!0,a=t.__iterate(function(c,u){if(n?!e.has(c):i?!Ns(c,e.get(u,Pr)):!Ns(e.get(u,Pr),c))return s=!1,!1});return s&&e.size===a}function n0(e,t){var n=function(r){e.prototype[r]=t[r]};return Object.keys(t).forEach(n),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(t).forEach(n),e}function KT(e){if(!e||"object"!=typeof e)return e;if(!Qa(e)){if(!cm(e))return e;e=ec(e)}if(Li(e)){var t={};return e.__iterate(function(r,i){t[i]=KT(r)}),t}var n=[];return e.__iterate(function(r){n.push(KT(r))}),n}var eS=function(e){function t(n){return null==n?tS():XT(n)&&!nl(n)?n:tS().withMutations(function(r){var i=e(n);mu(i.size),i.forEach(function(o){return r.add(o)})})}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.of=function(){return this(arguments)},t.fromKeys=function(r){return this(el(r).keySeq())},t.intersect=function(r){return(r=yo(r).toArray()).length?ta.intersect.apply(t(r.pop()),r):tS()},t.union=function(r){return(r=yo(r).toArray()).length?ta.union.apply(t(r.pop()),r):tS()},t.prototype.toString=function(){return this.__toString("Set {","}")},t.prototype.has=function(r){return this._map.has(r)},t.prototype.add=function(r){return ZT(this,this._map.set(r,r))},t.prototype.remove=function(r){return ZT(this,this._map.remove(r))},t.prototype.clear=function(){return ZT(this,this._map.clear())},t.prototype.map=function(r,i){var o=this,s=!1,a=ZT(this,this._map.mapEntries(function(c){var u=c[1],l=r.call(i,u,u,o);return l!==u&&(s=!0),[l,l]},i));return s?a:this},t.prototype.union=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];return 0===(r=r.filter(function(o){return 0!==o.size})).length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(o){for(var s=0;s=0&&i=0&&o>>-15,461845907),t=V2(t<<13|t>>>-13,5),t=V2((t=t+3864292196^e)^t>>>16,2246822507),t=VT((t=V2(t^t>>>13,3266489909))^t>>>16)}(e.__iterate(n?t?function(o,s){r=31*r+One(Mc(o),Mc(s))|0}:function(o,s){r=r+One(Mc(o),Mc(s))|0}:t?function(o){r=31*r+Mc(o)|0}:function(o){r=r+Mc(o)|0}),r)}(this))}});var ya=yo.prototype;ya[Dte]=!0,ya[OT]=ya.values,ya.toJSON=ya.toArray,ya.__toStringMapper=z2,ya.inspect=ya.toSource=function(){return this.toString()},ya.chain=ya.flatMap,ya.contains=ya.includes,n0(el,{flip:function(){return Ti(this,Wte(this))},mapEntries:function(t,n){var r=this,i=0;return Ti(this,this.toSeq().map(function(o,s){return t.call(n,[s,o],i++,r)}).fromEntrySeq())},mapKeys:function(t,n){var r=this;return Ti(this,this.toSeq().flip().map(function(i,o){return t.call(n,i,o,r)}).flip())}});var nS=el.prototype;nS[Ete]=!0,nS[OT]=ya.entries,nS.toJSON=Rne,nS.__toStringMapper=function(e,t){return z2(t)+": "+z2(e)},n0(Zg,{toKeyedSeq:function(){return new zT(this,!1)},filter:function(t,n){return Ti(this,Yte(this,t,n,!1))},findIndex:function(t,n){var r=this.findEntry(t,n);return r?r[0]:-1},indexOf:function(t){var n=this.keyOf(t);return void 0===n?-1:n},lastIndexOf:function(t){var n=this.lastKeyOf(t);return void 0===n?-1:n},reverse:function(){return Ti(this,G4(this,!1))},slice:function(t,n){return Ti(this,j4(this,t,n,!1))},splice:function(t,n){var r=arguments.length;if(n=Math.max(n||0,0),0===r||2===r&&!n)return this;t=rv(t,t<0?this.count():this.size);var i=this.slice(0,t);return Ti(this,1===r?i:i.concat(uf(arguments,2),this.slice(t+n)))},findLastIndex:function(t,n){var r=this.findLastEntry(t,n);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Ti(this,Kte(this,t,!1))},get:function(t,n){return(t=sm(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?n:this.find(function(r,i){return i===t},void 0,n)},has:function(t){return(t=sm(this,t))>=0&&(void 0!==this.size?this.size===1/0||tt?-1:0}function One(e,t){return e^t+2654435769+(e<<6)+(e>>2)}pv.has=ya.includes,pv.contains=pv.includes,pv.keys=pv.values,n0(am,nS),n0(il,fv),n0(av,pv);var sl=function(e){function t(n){return null==n?mL():lL(n)?n:mL().withMutations(function(r){var i=iv(n);mu(i.size),i.forEach(function(o){return r.add(o)})})}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.of=function(){return this(arguments)},t.fromKeys=function(r){return this(el(r).keySeq())},t.prototype.toString=function(){return this.__toString("OrderedSet {","}")},t}(eS);sl.isOrderedSet=lL;var Une,r0=sl.prototype;function Lne(e,t){var n=Object.create(r0);return n.size=e?e.size:0,n._map=e,n.__ownerID=t,n}function mL(){return Une||(Une=Lne(Q2()))}r0[ov]=!0,r0.zip=fv.zip,r0.zipWith=fv.zipWith,r0.zipAll=fv.zipAll,r0.__empty=mL,r0.__make=Lne;var Es=function(t,n){var r;!function cVe(e){if(Qg(e))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(tl(e))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===e||"object"!=typeof e)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var i=function(a){var c=this;if(a instanceof i)return a;if(!(this instanceof i))return new i(a);if(!r){r=!0;var u=Object.keys(t),l=o._indices={};o._name=n,o._keys=u,o._defaultValues=t;for(var d=0;d({action:o,params:s}),id:Hr.create22(),definition:i,createDefaultParams:(s,a)=>i.params?C.getDefaultValues(i.params(s,a)):{}};return o}let r;e.create=t,e.fromTransformer=function n(i){const o=i.definition;return t({from:o.from,display:o.display,params:o.params,isApplicable:i.definition.isApplicable?(s,a,c)=>i.definition.isApplicable(s,c):void 0,run({cell:s,state:a,params:c}){const u=a.build().to(s.transform.ref).apply(i,c);return a.updateTree(u)}})},(r=e.Builder||(e.Builder={})).build=s=>function o(s){return a=>t({from:s.from instanceof Array?s.from:s.from?[s.from]:[],display:"string"==typeof s.display?{name:s.display}:s.display?s.display:{name:"Unnamed State Action"},params:"object"==typeof s.params?()=>s.params:s.params?s.params:void 0,isApplicable:s.isApplicable,..."function"==typeof a?{run:a}:a})}(s),e.build=r.build}(nc||(nc={})),function(e){let r;var h;e.getParamDefinition=function t(h,g,y){return h.definition.params?h.definition.params(g,y):{}},e.is=function n(h){return!!h&&"function"==typeof h.toAction&&"function"==typeof h.apply},(h=r=e.UpdateResult||(e.UpdateResult={}))[h.Unchanged=0]="Unchanged",h[h.Updated=1]="Updated",h[h.Recreate=2]="Recreate",h[h.Null=3]="Null";const i=new Map,o=new Map;function l(h,g){const{name:y}=g,b=`${h}.${y}`;if(i.has(b))throw new Error(`A transform with id '${y}' is already registered. Please pick a unique identifier for your transforms and/or register them only once. This is to ensure that transforms can be serialized and replayed.`);const x={apply:(_,S,A)=>ur.create(_,x,S,A),toAction:()=>nc.fromTransformer(x),namespace:h,id:b,definition:g,createDefaultParams:(_,S)=>g.params?C.getDefaultValues(g.params(_,S)):{}};return i.set(b,x),function s(h){for(const g of h.definition.from)o.has(g.type)?o.get(g.type).push(h):o.set(g.type,[h])}(x),x}let p;e.getAll=function a(){return Array.from(i.values())},e.get=function c(h){const g=i.get(h);if(!g)throw new Error(`A transformer with signature '${h}' is not registered.`);return g},e.fromType=function u(h){return o.get(h)||[]},e.create=l,e.factory=function d(h){return g=>l(h,g)},e.builderFactory=function f(h){return p.build(h)},function(h){h.build=function y(b){return x=>function g(b,x){return _=>l(b,{name:x.name,from:x.from instanceof Array?x.from:[x.from],to:x.to instanceof Array?x.to:[x.to],display:"string"==typeof x.display?{name:x.display}:x.display?x.display:{name:Fg(x.name.replace(/[-]/g," "))},params:"object"==typeof x.params?()=>x.params:x.params?x.params:void 0,isDecorator:x.isDecorator,..._})}(b,x)}}(p=e.Builder||(e.Builder={})),e.build=function m(h){return p.build(h)},e.ROOT=l("build-in",{name:"root",from:[],to:[],display:{name:"Root",description:"For internal use."},apply(){throw new Error("should never be applied")},update:()=>r.Unchanged})}(Qe||(Qe={})),function(e){function o(g,y,b,x){const _=x&&x.ref?x.ref:Hr.create22();let S;return x&&x.tags&&(S="string"==typeof x.tags?[x.tags]:x.tags,0===S.length?S=void 0:S.sort()),{parent:g,transformer:y,state:x?.state||{},tags:S,ref:_,dependsOn:x&&x.dependsOn,params:b,version:Hr.create22()}}function d(g,y){return!!g.tags&&g.tags.indexOf(y)>=0}function p(g){return g}e.RootRef="-=root=-",e.areStatesEqual=function t(g,y){return!!g.isHidden!=!!y.isHidden||!!g.isCollapsed!=!!y.isCollapsed||!!g.isGhost!=!!y.isGhost||!!g.isLocked!=!!y.isLocked},e.isStateChange=function n(g,y){return!!y&&(typeof y.isCollapsed<"u"&&g.isCollapsed!==y.isCollapsed||typeof y.isHidden<"u"&&g.isHidden!==y.isHidden||typeof y.isGhost<"u"&&g.isGhost!==y.isGhost||typeof y.isLocked<"u"&&g.isLocked!==y.isLocked)},e.assignState=function r(g,y){if(!y)return!1;let b=!1;for(const x of Object.keys(y)){const _=y[x];!!_!=!!g[x]&&(b=!0,g[x]=_)}return b},e.syncState=function i(g,y){if(!y)return!1;let b=!1;for(const x of Object.keys(y)){const _=y[x];!!_!=!!g[x]&&(b=!0,void 0!==_?g[x]=_:delete g[x])}for(const x of Object.keys(g)){const _=y[x];!!_!=!!g[x]&&(b=!0,void 0!==_?g[x]=_:delete g[x])}return b},e.create=o,e.withParams=function s(g,y){return{...g,params:y,version:Hr.create22()}},e.withState=function a(g,y){return y?{...g,state:{...g.state,...y}}:g},e.withTags=function c(g,y){let b;return y&&(b="string"==typeof y?[y]:y,0===b.length?b=void 0:b.sort()),{...g,tags:b,version:Hr.create22()}},e.withParent=function u(g,y){return{...g,parent:y,version:Hr.create22()}},e.createRoot=function l(g){return o(e.RootRef,Qe.ROOT,{},{ref:e.RootRef,state:g})},e.hasTag=d,e.hasTags=function f(g,y){if(!g.tags)return"string"!=typeof y&&0===y.length;if("string"==typeof y)return d(g,y);for(const b of y)if(g.tags.indexOf(b)<0)return!1;return!0},e.toJSON=function m(g){const y=g.transformer.definition.customSerialization?g.transformer.definition.customSerialization.toJSON:p;let b;for(const x of Object.keys(g.state))g.state[x]&&(b||(b={}),b[x]=!0);return{parent:g.parent,transformer:g.transformer.id,params:g.params?y(g.params):void 0,state:b,tags:g.tags,ref:g.ref,dependsOn:g.dependsOn,version:g.version}},e.fromJSON=function h(g){const y=Qe.get(g.transformer);return{parent:g.parent,transformer:y,params:g.params?(y.definition.customSerialization?y.definition.customSerialization.fromJSON:p)(g.params):void 0,state:g.state||{},tags:g.tags,ref:g.ref,dependsOn:g.dependsOn,version:g.version}}}(ur||(ur={}));class hVe{get childMutations(){return this._childMutations||(this._childMutations=new Map),this._childMutations}get dependencyMutations(){return this._dependencyMutations||(this._dependencyMutations=new Map),this._dependencyMutations}changeNodes(){this.changedNodes||(this.changedNodes=!0,this.transforms=this.transforms.asMutable())}changeChildren(){this.changedChildren||(this.changedChildren=!0,this.children=this.children.asMutable())}changeDependencies(){this.changedDependencies||(this.changedDependencies=!0,this.dependencies=this.dependencies.asMutable())}get root(){return this.transforms.get(ur.RootRef)}asTransient(){return this.asImmutable().asTransient()}addChild(t,n){if(this.changeChildren(),this.childMutations.has(t))this.childMutations.get(t).add(n);else{const r=this.children.get(t).asMutable();r.add(n),this.children.set(t,r),this.childMutations.set(t,r)}}removeChild(t,n){if(this.changeChildren(),this.childMutations.has(t))this.childMutations.get(t).remove(n);else{const r=this.children.get(t).asMutable();r.remove(n),this.children.set(t,r),this.childMutations.set(t,r)}}clearRoot(){const t=ur.RootRef;if(0===this.children.get(t).size)return;this.changeChildren();const n=sl();this.children.set(t,n),this.childMutations.set(t,n)}mutateDependency(t,n,r){let i=this.dependencyMutations.get(t);if(!i){const o=this.dependencies.get(t);if(!o&&"remove"===r)return;this.changeDependencies(),i=o?o.asMutable():sl().asMutable(),this.dependencyMutations.set(t,i),this.dependencies.set(t,i)}"add"===r?i.add(n):i.remove(n)}changeParent(t,n){QT(this.transforms,t);const r=this.transforms.get(t);this.removeChild(r.parent,t),this.addChild(n,t),this.changeNodes(),this.transforms.set(t,ur.withParent(r,n))}add(t){const n=t.ref;this.transforms.has(t.ref)&&this.transforms.get(t.ref).parent!==t.parent&&function yVe(e){throw new Error(`Transform '${e}' is already present in the tree.`)}(t.ref);const r=this.children.get(t.parent);if(r||function bVe(e){throw new Error(`Parent '${e}' must be present in the tree.`)}(t.parent),r.has(t.ref)||this.addChild(t.parent,t.ref),this.children.has(t.ref)||(this.changedChildren||(this.changedChildren=!0,this.children=this.children.asMutable()),this.children.set(t.ref,sl())),this.changeNodes(),this.transforms.set(n,t),t.dependsOn)for(const i of t.dependsOn)this.mutateDependency(i,n,"add");return this}setParams(t,n){QT(this.transforms,t);const r=this.transforms.get(t);return!JF(r.params,n)&&(this.changedNodes||(this.changedNodes=!0,this.transforms=this.transforms.asMutable()),this.transforms.set(r.ref,ur.withParams(r,n)),!0)}setTags(t,n){QT(this.transforms,t);const r=this.transforms.get(t),i=ur.withParams(r,n);return!LZ(r.tags,i.tags)&&(this.changedNodes||(this.changedNodes=!0,this.transforms=this.transforms.asMutable()),this.transforms.set(r.ref,i),!0)}assignState(t,n){QT(this.transforms,t);const r=this.transforms.get(t);if(this._stateUpdates&&this._stateUpdates.has(t))return ur.assignState(r.state,n),r;{this._stateUpdates||(this._stateUpdates=new Set),this._stateUpdates.add(r.ref),this.changeNodes();const i=ur.withState(r,n);return this.transforms.set(t,i),i}}remove(t){const n=this.transforms.get(t);if(!n)return[];const r=bo.subtreePostOrder(this,n);if(t===ur.RootRef){if(r.pop(),0===r.length)return r;this.clearRoot()}else{if(0===r.length)return r;this.removeChild(n.parent,n.ref)}this.changeNodes(),this.changeChildren();for(const o of r)this.transforms.delete(o.ref),this.children.delete(o.ref),this._childMutations&&this._childMutations.delete(o.ref);const i=[];for(const o of r){if(o.dependsOn)for(const s of o.dependsOn)this.transforms.has(s)&&this.mutateDependency(s,o.ref,"remove");if(this.dependencies.has(o.ref)){const s=this.dependencies.get(o.ref).toArray();this.changeDependencies(),this.dependencies.delete(o.ref),this._dependencyMutations&&this._dependencyMutations.delete(o.ref);for(const a of s)if(this.transforms.has(a))for(const c of this.remove(a))i[i.length]=c}}for(const o of i)r[r.length]=o;return r}asImmutable(){return this.changedNodes||this.changedChildren||this._childMutations?(this._childMutations&&this._childMutations.forEach(mVe,this.children),this._dependencyMutations&&this._dependencyMutations.forEach(gVe,this.dependencies),bo.create(this.changedNodes?this.transforms.asImmutable():this.transforms,this.changedChildren?this.children.asImmutable():this.children,this.changedDependencies?this.dependencies.asImmutable():this.dependencies)):this.tree}constructor(t){this.tree=t,this.transforms=this.tree.transforms,this.children=this.tree.children,this.dependencies=this.tree.dependencies,this.changedNodes=!1,this.changedChildren=!1,this.changedDependencies=!1,this._childMutations=void 0,this._dependencyMutations=void 0,this._stateUpdates=void 0}}function mVe(e,t){this.set(t,e.asImmutable())}function gVe(e,t){0===e.size?this.delete(t):this.set(t,e.asImmutable())}function QT(e,t){if(!e.has(t))throw new Error(`Node '${t}' is not present in the tree.`)}!function(e){class t{get root(){return this.transforms.get(ur.RootRef)}asTransient(){return new hVe(this)}constructor(_,S,A){this.transforms=_,this.children=S,this.dependencies=A}}function r(x,_,S){return new t(x,_,S)}function i(x){o(this,this.tree.transforms.get(x))}function o(x,_){const S=x.tree.children.get(_.ref);S&&S.size&&S.forEach(i,x),x.f(_,x.tree,x.state)}function s(x,_,S,A){const E={tree:x,state:S,f:A};return o(E,_),E.state}function a(x){c(this,this.tree.transforms.get(x))}function c(x,_){const S=x.f(_,x.tree,x.state);if("boolean"==typeof S&&!S)return;const A=x.tree.children.get(_.ref);A&&A.size&&A.forEach(a,x)}function u(x,_,S,A){const E={tree:x,state:S,f:A};return c(E,_),E.state}function l(x,_,S){S.push(x)}function f(x,_,S){S.push(ur.toJSON(x))}function g(x,_,S){if(_===S)return!0;const E=x.children.get(_).values();for(;;){const w=E.next();if(w.done)return!1;if(g(x,w.value,S))return!0}}e.createEmpty=function n(x){const _=x||ur.createRoot();return r(gu([[_.ref,_]]),gu([[_.ref,sl()]]),gu())},e.create=r,e.doPostOrder=s,e.doPreOrder=u,e.subtreePostOrder=function d(x,_){return s(x,_,[],l)},e.toJSON=function p(x){const _=[];return u(x,x.root,_,f),{transforms:_}},e.fromJSON=function m(x){const _=gu().asMutable(),S=gu().asMutable(),A=gu().asMutable();for(const w of x.transforms){const D=ur.fromJSON(w);_.set(D.ref,D),S.has(D.ref)||S.set(D.ref,sl().asMutable()),D.ref!==D.parent&&S.get(D.parent).add(D.ref)}const E=new Set;for(const w of x.transforms){const D=w.ref;if(S.set(D,S.get(D).asImmutable()),w.dependsOn)for(const I of w.dependsOn)E.add(I),A.has(I)?A.get(I).add(D):A.set(I,sl([D]).asMutable())}return E.forEach(w=>{A.set(w,A.get(w).asImmutable())}),r(_.asImmutable(),S.asImmutable(),A.asImmutable())},e.dump=function h(x){console.log({tr:x.transforms.keySeq().toArray(),tr1:x.transforms.valueSeq().toArray().map(_=>_.ref),ch:x.children.keySeq().toArray()})},e.subtreeHasRef=function y(x,_,S){return!(!x.transforms.has(_)||!x.transforms.has(S))&&g(x,_,S)},e.getDecoratorRoot=function b(x,_){const S=x.children.get(_);if(1!==S.size)return _;const A=x.transforms.get(S.first());return A.transformer.definition.isDecorator?b(x,A.ref):_}}(bo||(bo={})),function(e){function t(O,H){return n(O)(H)}function n(O){const H=O||u.root;let W;return W=function i(O){return void 0!==O.compile}(H)?H.compile():function r(O){return void 0!==O.transform&&void 0!==O.status}(H)?u.byValue(H).compile():function o(O){return"function"==typeof O}(H)?H:u.byRef(H).compile(),W}e.select=t,e.compile=n;const s={select(O){return t(this,O||this.state)}};function a(O,H){s[O]=function(...W){return H.call(void 0,this,...W)}}function c(O){return Object.create(s,{compile:{writable:!1,configurable:!1,value:O}})}let u;function l(O,H){const W=n(O);return c(()=>Q=>{const fe=[];for(const X of W(Q))for(const J of H(X,Q))fe.push(J);return fe})}function d(O,H){const W=n(O);return c(()=>Q=>{const fe=[];for(const X of W(Q)){const J=H(X,Q);J&&fe.push(J)}return fe})}function f(O){const H=n(O);return c(()=>W=>{const Q=new Set,fe=[];for(const X of H(W))X&&(Q.has(X.transform.ref)||(Q.add(X.transform.ref),fe.push(X)));return fe})}function p(O){const H=n(O);return c(()=>W=>{const Q=H(W);return Q.length?[Q[0]]:[]})}function m(O,H){return l(O,W=>H(W)?[W]:[])}function h(O,H){return m(O,W=>W.status===H)}function g(O,H){return m(O,W=>!!W.transform.tags&&W.transform.tags.indexOf(H)>=0)}function y(O){return l(O,(H,W)=>{const Q=[];return bo.doPreOrder(W.tree,W.tree.transforms.get(H.transform.ref),Q,(fe,X,J)=>{J.push(fe.ref)}),Q.map(fe=>W.cells.get(fe))})}function b(O){return l(O,(H,W)=>{const Q=[];return W.tree.children.get(H.transform.ref).forEach(fe=>Q.push(W.cells.get(fe))),Q})}function x(O,H){return m(O,W=>!!W.obj&&W.obj.type===H.type)}function _(O,H){return f(d(O,(W,Q)=>T(Q.tree,Q.cells,W.transform.ref,H)))}function S(O,H){return f(d(O,(W,Q)=>V(Q.tree,Q.cells,W.transform.ref,H)))}function A(O,H){return f(d(O,(W,Q)=>N(Q.tree,Q.cells,W.transform.ref,H)))}function E(O,H){return m(O,W=>W.transform.transformer===H)}function w(O,H){return f(d(O,(W,Q)=>M(Q.tree,Q.cells,W.transform.ref,H)))}function D(O,H){return f(d(O,(W,Q)=>F(Q.tree,Q.cells,W.transform.ref,H)))}function I(O){return f(d(O,(H,W)=>W.cells.get(W.tree.transforms.get(H.transform.ref).parent)))}function R(O,H,W,Q,fe){let J,X=O.transforms.get(W);for(;;){X=O.transforms.get(X.parent);const ce=H.get(X.ref);if(ce.obj&&Q(ce)&&(J=ce,fe)||X.ref===ur.RootRef)return J}}function T(O,H,W,Q){return R(O,H,W,Q,!0)}function M(O,H,W,Q){return R(O,H,W,Q,!1)}function N(O,H,W,Q){return T(O,H,W,Array.isArray(Q)?fe=>Q.indexOf(fe.transform.transformer)>=0:fe=>fe.transform.transformer===Q)}function V(O,H,W,Q){return T(O,H,W,G(Q))}function F(O,H,W,Q){return M(O,H,W,G(Q))}function G(O){return Array.isArray(O)?H=>{for(const W of O)if(W.type===H.obj.type)return!0}:H=>H.obj.type===O.type}function z(O,H,W){if(O.tags)for(const Q of O.tags)if(W.tags.has(Q)){W.refs[Q]=O.ref;break}return!0}function Z(O,H,W){return!(O.tags&&O.tags.indexOf(W.tag)>=0&&(W.ref=O.ref,1))}function ee(O,H,W){if(O.tags){const Q=W.tags.size;let fe=0;for(const X of O.tags)if(W.tags.has(X)&&(fe++,fe===Q)){W.refs.push(O);break}}else 0===W.tags.size&&W.refs.push(O)}(function(O){function ce(oe,K,ne){const de=ne.cells.get(oe.ref);return!de||!de.obj||de.obj.type!==ne.type||(ne.roots.push(de),!1)}function be(oe,K,ne){const de=ne.cells.get(oe.ref);return de&&de.obj&&de.obj.type===ne.type&&ne.ret.push(de),!0}function ae(oe,K,ne){const de=ne.cells.get(oe.ref);return de&&de.obj&&de.transform.transformer===ne.t&&ne.ret.push(de),!0}function me(oe,K,ne){const de=ne.cells.get(oe.ref);return de&&"error"===de.status&&de.transform.transformer===ne.t&&ne.ret.push(de),!0}O.root=c(()=>oe=>[oe.cells.get(oe.tree.root.ref)]),O.byRef=function H(...oe){return c(()=>K=>{const ne=[];for(const de of oe){const we=K.cells.get(de);we&&ne.push(we)}return ne})},O.byValue=function W(...oe){return c(()=>K=>oe)},O.rootsOfType=function Q(oe,K=ur.RootRef){return c(()=>ne=>{const de={roots:[],cells:ne.cells,type:oe.type};return bo.doPreOrder(ne.tree,ne.tree.transforms.get(K),de,ce),de.roots})},O.ofType=function fe(oe,K=ur.RootRef){return c(()=>ne=>{const de={ret:[],cells:ne.cells,type:oe.type};return bo.doPreOrder(ne.tree,ne.tree.transforms.get(K),de,be),de.ret})},O.ofTransformer=function X(oe,K=ur.RootRef){return c(()=>ne=>{const de={ret:[],cells:ne.cells,t:oe};return bo.doPreOrder(ne.tree,ne.tree.transforms.get(K),de,ae),de.ret})},O.ofTransformerWithError=function J(oe,K=ur.RootRef){return c(()=>ne=>{const de={ret:[],cells:ne.cells,t:oe};return bo.doPreOrder(ne.tree,ne.tree.transforms.get(K),de,me),de.ret})}})(u=e.Generators||(e.Generators={})),a("flatMap",l),e.flatMap=l,a("mapObject",d),e.mapObject=d,a("unique",f),e.unique=f,a("first",p),e.first=p,a("filter",m),e.filter=m,a("withStatus",h),e.withStatus=h,a("withTag",g),e.withTag=g,a("subtree",y),e.subtree=y,a("children",b),e.children=b,a("ofType",x),e.ofType=x,a("ancestor",_),e.ancestor=_,a("ancestorOfType",S),e.ancestorOfType=S,a("ancestorWithTransformer",A),e.ancestorWithTransformer=A,a("withTransformer",E),e.withTransformer=E,a("root",w),e.root=w,a("rootOfType",D),e.rootOfType=D,a("parent",I),e.parent=I,e.findAncestor=T,e.findRoot=M,e.findAncestorWithTransformer=N,e.findAncestorOfType=V,e.findRootOfType=F,e.findUniqueTagsInSubtree=function L(O,H,W){return bo.doPreOrder(O,O.transforms.get(H),{refs:{},tags:W},z).refs},e.findTagInSubtree=function j(O,H,W){return bo.doPreOrder(O,O.transforms.get(H),{ref:void 0,tag:W},Z).ref},e.findWithAllTags=function $(O,H,W){return bo.doPreOrder(O,O.transforms.get(H),{refs:[],tags:W},ee).refs},e.tryFindDecorator=function q(O,H,W){if(O.transforms.get(H).transformer===W)return O.cells.get(H);const fe=O.tree.children.get(H);if(1!==fe.size)return;const X=fe.first();return O.transforms.get(X).transformer.definition.isDecorator?q(O,X,W):void 0}}(In||(In={})),function(e){e.create=function t(){const n=new vVe,r=()=>n.create();return r.dispose=()=>n.dispose(),r.behavior=i=>n.behavior(i),r}}(wp||(wp={}));class vVe{constructor(){this._eventList=[],this._disposed=!1}create(){const t=new mr;return this._eventList.push(t),t}behavior(t){const n=new Ao(t);return this._eventList.push(n),n}dispose(){if(!this._disposed){for(const t of this._eventList)t.complete();this._disposed=!0}}}var vL=Symbol.for("immer-nothing"),rS=Symbol.for("immer-draftable"),zr=Symbol.for("immer-state");function Fs(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var o0=Object.getPrototypeOf;function dm(e){return!!e&&!!e[zr]}function lf(e){return!!e&&(zne(e)||Array.isArray(e)||!!e[rS]||!!e.constructor?.[rS]||oS(e)||sS(e))}var _Ve=Object.prototype.constructor.toString();function zne(e){if(!e||"object"!=typeof e)return!1;const t=o0(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===_Ve}function mv(e,t){0===s0(e)?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function s0(e){const t=e[zr];return t?t.type_:Array.isArray(e)?1:oS(e)?2:sS(e)?3:0}function iS(e,t){return 2===s0(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Gne(e,t,n){const r=s0(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function oS(e){return e instanceof Map}function sS(e){return e instanceof Set}function Bs(e){return e.copy_||e.base_}function xL(e,t){if(oS(e))return new Map(e);if(sS(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&zne(e))return o0(e)?{...e}:Object.assign(Object.create(null),e);const n=Object.getOwnPropertyDescriptors(e);delete n[zr];let r=Reflect.ownKeys(n);for(let i=0;i1&&(e.set=e.add=e.clear=e.delete=SVe),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>SL(r,!0))),e}function SVe(){Fs(2)}function JT(e){return Object.isFrozen(e)}var aS,CL={};function a0(e){const t=CL[e];return t||Fs(0),t}function eD(){return aS}function Hne(e,t){t&&(a0("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function wL(e){AL(e),e.drafts_.forEach(wVe),e.drafts_=null}function AL(e){e===aS&&(aS=e.parent_)}function qne(e){return aS=function CVe(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}(aS,e)}function wVe(e){const t=e[zr];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Wne(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[zr].modified_&&(wL(t),Fs(4)),lf(e)&&(e=tD(t,e),t.parent_||nD(t,e)),t.patches_&&a0("Patches").generateReplacementPatches_(n[zr].base_,e,t.patches_,t.inversePatches_)):e=tD(t,n,[]),wL(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==vL?e:void 0}function tD(e,t,n){if(JT(t))return t;const r=t[zr];if(!r)return mv(t,(i,o)=>$ne(e,r,t,i,o,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return nD(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const i=r.copy_;let o=i,s=!1;3===r.type_&&(o=new Set(i),i.clear(),s=!0),mv(o,(a,c)=>$ne(e,r,i,a,c,n,s)),nD(e,i,!1),n&&e.patches_&&a0("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function $ne(e,t,n,r,i,o,s){if(dm(i)){const c=tD(e,i,o&&t&&3!==t.type_&&!iS(t.assigned_,r)?o.concat(r):void 0);if(Gne(n,r,c),!dm(c))return;e.canAutoFreeze_=!1}else s&&n.add(i);if(lf(i)&&!JT(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;tD(e,i),(!t||!t.scope_.parent_)&&"symbol"!=typeof r&&Object.prototype.propertyIsEnumerable.call(n,r)&&nD(e,i)}}function nD(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&SL(t,n)}var IL={get(e,t){if(t===zr)return e;const n=Bs(e);if(!iS(n,t))return function IVe(e,t,n){const r=Yne(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}(e,n,t);const r=n[t];return e.finalized_||!lf(r)?r:r===TL(e.base_,t)?(DL(e),e.copy_[t]=uS(r,e)):r},has:(e,t)=>t in Bs(e),ownKeys:e=>Reflect.ownKeys(Bs(e)),set(e,t,n){const r=Yne(Bs(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=TL(Bs(e),t),o=i?.[zr];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function xVe(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,i)&&(void 0!==n||iS(e.base_,t)))return!0;DL(e),Ap(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==TL(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,DL(e),Ap(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Bs(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:r.enumerable,value:n[t]}},defineProperty(){Fs(11)},getPrototypeOf:e=>o0(e.base_),setPrototypeOf(){Fs(12)}},cS={};function TL(e,t){const n=e[zr];return(n?Bs(n):e)[t]}function Yne(e,t){if(!(t in e))return;let n=o0(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=o0(n)}}function Ap(e){e.modified_||(e.modified_=!0,e.parent_&&Ap(e.parent_))}function DL(e){e.copy_||(e.copy_=xL(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function uS(e,t){const n=oS(e)?a0("MapSet").proxyMap_(e,t):sS(e)?a0("MapSet").proxySet_(e,t):function AVe(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:eD(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,o=IL;n&&(i=[r],o=cS);const{revoke:s,proxy:a}=Proxy.revocable(i,o);return r.draft_=a,r.revoke_=s,a}(e,t);return(t?t.scope_:eD()).drafts_.push(n),n}function Xne(e){if(!lf(e)||JT(e))return e;const t=e[zr];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=xL(e,t.scope_.immer_.useStrictShallowCopy_)}else n=xL(e,!0);return mv(n,(r,i)=>{Gne(n,r,Xne(i))}),t&&(t.finalized_=!1),n}mv(IL,(e,t)=>{cS[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),cS.deleteProperty=function(e,t){return cS.set.call(this,e,t,void 0)},cS.set=function(e,t,n){return IL.set.call(this,e[0],t,n,e[0])};var u0,df,rD,yu=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if("function"==typeof t&&"function"!=typeof n){const o=n;n=t;const s=this;return function(c=o,...u){return s.produce(c,l=>n.call(this,l,...u))}}let i;if("function"!=typeof n&&Fs(6),void 0!==r&&"function"!=typeof r&&Fs(7),lf(t)){const o=qne(this),s=uS(t,void 0);let a=!0;try{i=n(s),a=!1}finally{a?wL(o):AL(o)}return Hne(o,r),Wne(i,o)}if(!t||"object"!=typeof t){if(i=n(t),void 0===i&&(i=t),i===vL&&(i=void 0),this.autoFreeze_&&SL(i,!0),r){const o=[],s=[];a0("Patches").generateReplacementPatches_(t,i,o,s),r(o,s)}return i}Fs(1)},this.produceWithPatches=(t,n)=>{if("function"==typeof t)return(s,...a)=>this.produceWithPatches(s,c=>t(c,...a));let r,i;return[this.produce(t,n,(s,a)=>{r=s,i=a}),r,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){lf(e)||Fs(8),dm(e)&&(e=function DVe(e){return dm(e)||Fs(10),Xne(e)}(e));const t=qne(this),n=uS(e,void 0);return n[zr].isManual_=!0,AL(t),n}finishDraft(e,t){const n=e&&e[zr];(!n||!n.isManual_)&&Fs(9);const{scope_:r}=n;return Hne(r,t),Wne(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=a0("Patches").applyPatches_;return dm(e)?r(e,t):this.produce(e,i=>r(i,t))}},c0=yu.produce,EVe=(yu.produceWithPatches.bind(yu),yu.setAutoFreeze.bind(yu));function Kne(...e){let t;const n=[];for(const r of e)if(r)if(t||(t=new Set),"string"==typeof r){if(t.has(r))continue;t.add(r),n.push(r)}else for(const i of r)t.has(i)||(t.add(i),n.push(i));return n}yu.setUseStrictShallowCopy.bind(yu),yu.applyPatches.bind(yu),yu.createDraft.bind(yu),yu.finishDraft.bind(yu),function(e){function t(s){if(!s.state||s.state.tree===s.editInfo.sourceTree)return s.tree.asImmutable();const a=s.state.tree.asTransient();for(const c of s.actions)switch(c.kind){case"add":a.add(c.transform);break;case"update":a.setParams(c.ref,c.params);break;case"delete":a.remove(c.ref);break;case"insert":{const u=a.children.get(c.ref).toArray();a.add(c.transform);for(const l of u)a.changeParent(l,c.transform.ref);break}}return s.editInfo.sourceTree=s.tree,a.asImmutable()}e.is=function n(s){return!!s&&"function"==typeof s.getTree},e.isTo=function r(s){return!!s&&"function"==typeof s.getTree&&"string"==typeof s.ref},e.Root=class i{get editInfo(){return this.state.editInfo}get currentTree(){return this.state.tree}to(a){const c="string"==typeof a?a:N2.is(a)?a.transform.ref:a.ref;return new o(this.state,c,this)}toRoot(){return new o(this.state,this.state.tree.root.ref,this)}delete(a){const c=ls.resolveRef(a);return c&&this.state.tree.transforms.has(c)?(this.editInfo.count++,this.state.tree.remove(c),this.state.actions.push({kind:"delete",ref:c}),this):this}getTree(){return t(this.state)}commit(a){if(!this.state.state)throw new Error("Cannot commit template tree");return this.state.state.runTask(this.state.state.updateTree(this,a))}constructor(a,c){this.state={state:c,tree:a.asTransient(),actions:[],editInfo:{applied:!1,sourceTree:a,count:0,lastUpdate:void 0}}}};class o{get editInfo(){return this.state.editInfo}get selector(){return new wte(this.ref,this.state.state)}getApplyRoot(){return bo.getDecoratorRoot(this.state.tree,this.ref)}apply(a,c,u){if(a.definition.isDecorator)return this.insert(a,c,u);const l=this.getApplyRoot(),d=a.apply(l,c,u);return this.state.tree.add(d),this.editInfo.count++,this.editInfo.lastUpdate=d.ref,this.state.actions.push({kind:"add",transform:d}),new o(this.state,d.ref,this.root)}applyOrUpdate(a,c,u,l){if(this.state.tree.transforms.has(a)){const d=this.to(a);return u&&d.update(u),d}return this.apply(c,u,{...l,ref:a})}applyOrUpdateTagged(a,c,u,l){if(c.definition.isDecorator)throw new Error("Can't use applyOrUpdateTagged on decorator transformers.");const d=this.getApplyRoot(),f=this.state.tree.children.get(d).values();for(;;){const m=f.next();if(m.done)break;const h=this.state.tree.transforms.get(m.value);if(h&&ur.hasTags(h,a)){const g=this.to(m.value);return g.updateTagged(u,Kne(h.tags,a,l&&l.tags)),g}}const p=c.apply(d,u,{...l,tags:Kne(a,l&&l.tags)});return this.state.tree.add(p),this.editInfo.count++,this.editInfo.lastUpdate=p.ref,this.state.actions.push({kind:"add",transform:p}),new o(this.state,p.ref,this.root)}group(a,c,u){return this.apply(a,c,u)}insert(a,c,u){const l=this.state.tree.children.get(this.ref).toArray(),d=a.apply(this.ref,c,u);this.state.tree.add(d);for(const f of l)this.state.tree.changeParent(f,d.ref);return this.editInfo.count++,this.editInfo.lastUpdate=d.ref,this.state.actions.push({kind:"insert",ref:this.ref,transform:d}),new o(this.state,d.ref,this.root)}updateTagged(a,c){(this.state.tree.setParams(this.ref,a)||this.state.tree.setTags(this.ref,c))&&(this.editInfo.count++,this.editInfo.lastUpdate=this.ref,this.state.actions.push({kind:"update",ref:this.ref,params:a}))}update(a,c){let u;if(c){const l=this.state.tree.transforms.get(this.ref);u=c0(l.params,c)}else u="function"==typeof a?c0(this.state.tree.transforms.get(this.ref).params,a):a;return this.state.tree.setParams(this.ref,u)&&(this.editInfo.count++,this.editInfo.lastUpdate=this.ref,this.state.actions.push({kind:"update",ref:this.ref,params:u})),this.root}to(a){return this.root.to(a)}toRoot(){return this.root.toRoot()}delete(a){return this.root.delete(a)}getTree(){return t(this.state)}commit(a){if(!this.state.state)throw new Error("Cannot commit template tree");return this.state.state.runTask(this.state.state.updateTree(this,a))}constructor(a,c,u){if(this.state=a,this.root=u,this.ref=c,!this.state.tree.transforms.has(c))throw new Error(`Could not find node '${c}'.`)}}e.To=o}(u0||(u0={}));class PVe{constructor(){this.ev=wp.create(),this.actions=new Map,this.fromTypeIndex=new Map,this.events={added:this.ev(),removed:this.ev()}}add(t){const n=Qe.is(t)?t.toAction():t;if(this.actions.has(n.id))return this;this.actions.set(n.id,n);for(const r of n.definition.from)this.fromTypeIndex.has(r.type)?this.fromTypeIndex.get(r.type).push(n):this.fromTypeIndex.set(r.type,[n]);return this.events.added.next(void 0),this}remove(t){const n=Qe.is(t)?t.toAction().id:Hr.is(t)?t:t.id,r=this.actions.get(n);if(!r)return this;this.actions.delete(n);for(const i of r.definition.from){const o=this.fromTypeIndex.get(i.type);o&&(Eg(o,r),0===o.length&&this.fromTypeIndex.delete(i.type))}return this.events.removed.next(void 0),this}fromCell(t,n){const r=t.obj;if(!r)return[];const i=this.fromTypeIndex.get(r.type);if(!i)return[];let o=!1;for(const a of i)if(a.definition.isApplicable){o=!0;break}if(!o)return i;const s=[];for(const a of i)a.definition.isApplicable?a.definition.isApplicable(r,t.transform,n)&&s.push(a):s.push(a);return s}dispose(){this.ev.dispose()}}!function(e){e.message=function t(o){return{type:"message",timestamp:new Date,message:o}},e.error=function n(o){return{type:"error",timestamp:new Date,message:o}},e.warning=function r(o){return{type:"warning",timestamp:new Date,message:o}},e.info=function i(o){return{type:"info",timestamp:new Date,message:o}}}(df||(df={})),function(e){e.Impl=class t{get current(){return this._current}set current(o){this._current=o}getAncestorOfType(o){if(!this._current)return;let s=this._current;for(;;){if(s=this.cells.get(s.transform.parent),!s.obj)return;if(s.obj.type===o.type)return s.obj;if(s.transform.ref===ur.RootRef)return}}getRootOfType(o){if(!this._current)return;let a,s=this._current;for(;;){if(!s.obj)return;if(s.obj.type===o.type&&(a=s),s.transform.ref===ur.RootRef)return a?a.obj:void 0;s=this.cells.get(s.transform.parent)}}constructor(o){this.cells=o,this._current=void 0}},e.getDecoratorChain=function n(i,o){const s=i.cells;let a=s.get(o);const c=[a];for(;a?.transform.transformer.definition.isDecorator;)a=s.get(a.transform.parent),c.push(a);return c},e.getRootOfType=function r(i,o,s){let a,c=i.cells.get(s);if(c)for(;;){if(!c.obj)return;if(c.obj.type===o.type&&(a=c),c.transform.ref===ur.RootRef)return a?a.obj:void 0;c=i.cells.get(c.transform.parent)}}}(rD||(rD={}));class MVe{constructor(){this.queue=[],this.signal=new mr}get length(){return this.queue.length}enqueue(t){return this.queue.push(t),1===this.queue.length||this.waitFor(t)}handled(t){Xx(this.queue,t),this.queue.length>0&&this.signal.next({v:this.queue[0],stillPresent:!0})}remove(t){const n=Xx(this.queue,t);return n&&this.signal.next({v:t,stillPresent:!1}),n}waitFor(t){return new Promise(n=>{const r=this.signal.subscribe(({v:i,stillPresent:o})=>{i===t&&(r.unsubscribe(),n(o))})})}}class iD{get tree(){return this._tree}get transforms(){return this._tree.transforms}get current(){return this.behaviors.currentObject.value.ref}get root(){return this.cells.get(this._tree.root.ref)}build(){return new u0.Root(this.tree,this)}addHistory(t,n){0!==this.historyCapacity&&(this.history.unshift([t,n||"Update"]),this.history.length>this.historyCapacity&&this.history.pop(),this.events.historyUpdated.next({state:this}))}clearHistory(){0!==this.history.length&&(this.history=[],this.events.historyUpdated.next({state:this}))}get latestUndoLabel(){return this.history.length>0?this.history[0][1]:void 0}get canUndo(){return this.history.length>0}undo(){var t=this;return Oe.create("Undo",function(){var n=ie(function*(r){const i=t.history.shift();if(i){t.events.historyUpdated.next({state:t}),t.undoingHistory=!0;try{yield t.updateTree(i[0],{canUndo:!1}).runInContext(r)}finally{t.undoingHistory=!1}}});return function(r){return n.apply(this,arguments)}}())}getSnapshot(){return{tree:bo.toJSON(this._tree)}}setSnapshot(t){const n=bo.fromJSON(t.tree);return this.updateTree(n)}setCurrent(t){this.behaviors.currentObject.next({state:this,ref:t})}updateCellState(t,n){const r=this.cells.get(t);if(!r)return;const i="function"==typeof n?n(r.state):n;ur.assignState(r.state,i)&&(r.transform=this._tree.assignState(r.transform.ref,i),this.events.cell.stateUpdated.next({state:this,ref:t,cell:r}))}dispose(){this.ev.dispose(),this.actions.dispose()}select(t){return In.select(t,this)}selectQ(t){return In.select("string"==typeof t?t:t(In.Generators),this)}applyAction(t,n,r=ur.RootRef){return Oe.create("Apply Action",i=>{const o=this.cells.get(r);if(!o)throw new Error(`'${r}' does not exist.`);if("ok"!==o.status)throw new Error(`Action cannot be applied to a cell with status '${o.status}'`);return NL(t.definition.run({ref:r,cell:o,a:o.obj,params:n,state:this},this.globalContext),i)})}transaction(t,n){var r=this;return Oe.create("State Transaction",function(){var i=ie(function*(o){const s=r.inTransaction,a=r._tree.asImmutable();let c=!1;try{s||r.behaviors.isUpdating.next(!0),r.inTransaction=!0,r.inTransactionError=!1,yield t(o),r.inTransactionError&&(c=!0,yield r.updateTree(a).runInContext(o))}catch(u){if(c||(c=!0,yield r.updateTree(a).runInContext(o),r.events.log.next(df.error("Error during state transaction, reverting"))),s)throw r.inTransactionError=!0,u;if(n?.rethrowErrors)throw u;console.error(u)}finally{s||(r.inTransaction=!1,r.events.changed.next({state:r,inTransaction:!1}),r.behaviors.isUpdating.next(!1),c||(n?.canUndo?r.addHistory(a,"string"==typeof n.canUndo?n.canUndo:void 0):r.clearHistory()))}});return function(o){return i.apply(this,arguments)}}())}get inUpdate(){return this._inUpdate}updateTree(t,n){var r=this;const i={tree:t,options:n};return Oe.create("Update Tree",function(){var o=ie(function*(s){if(!(yield r.updateQueue.enqueue(i)))return;r._inUpdate=!0;const c=n?.canUndo?r._tree.asImmutable():void 0;let u=!1;r.inTransaction||r.behaviors.isUpdating.next(!0);try{if(u0.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}r.reverted=!1;const l=n&&(n.revertIfAborted||n.revertOnError)?yield r._revertibleTreeUpdate(s,i,n):yield r._updateTree(s,i);return u=r.reverted,l.ctx.hadError&&(r.inTransactionError=!0),l.cell?new wte(l.cell.transform.ref,r):void 0}finally{r._inUpdate=!1,r.updateQueue.handled(i),r.inTransaction||(r.behaviors.isUpdating.next(!1),n?.canUndo?u||r.addHistory(c,"string"==typeof n.canUndo?n.canUndo:void 0):r.undoingHistory||r.clearHistory())}});return function(s){return o.apply(this,arguments)}}(),()=>{this.updateQueue.remove(i)})}_revertibleTreeUpdate(t,n,r){var i=this;return ie(function*(){const o=i.tree,s=yield i._updateTree(t,n);return(s.ctx.hadError||s.ctx.wasAborted)&&r.revertOnError||s.ctx.wasAborted&&r.revertIfAborted?(i.reverted=!0,yield i._updateTree(t,{tree:o,options:n.options})):s})()}_updateTree(t,n){var r=this;return ie(function*(){let i=!1;const o=r.updateTreeAndCreateCtx(n.tree,t,n.options);try{return i=yield function kVe(e){return EL.apply(this,arguments)}(o),u0.isTo(n.tree)?{ctx:o,cell:r.select(n.tree.ref)[0]}:{ctx:o}}finally{r.spine.current=void 0,i&&r.events.changed.next({state:r,inTransaction:r.inTransaction})}})()}updateTreeAndCreateCtx(t,n,r){const i=(u0.is(t)?t.getTree():t).asTransient(),o=this._tree;this._tree=i;const s=this.cells,a={parent:this,editInfo:u0.is(t)?t.editInfo:void 0,errorFree:this.errorFree,taskCtx:n,oldTree:o,tree:i,cells:this.cells,spine:this.spine,results:[],options:{...RVe,...r},changed:!1,hadError:!1,wasAborted:!1,newCurrent:void 0,getCellData:c=>{var u;return null===(u=s.get(c).obj)||void 0===u?void 0:u.data}};return this.errorFree=!0,a}constructor(t,n){this.errorFree=!0,this.ev=wp.create(),this.globalContext=void 0,this.events={cell:{stateUpdated:this.ev(),created:this.ev(),removed:this.ev()},object:{updated:this.ev(),created:this.ev(),removed:this.ev()},log:this.ev(),changed:this.ev(),historyUpdated:this.ev()},this.behaviors={currentObject:this.ev.behavior({state:this,ref:ur.RootRef}),isUpdating:this.ev.behavior(!1)},this.actions=new PVe,this.cells=new Map,this.spine=new rD.Impl(this.cells),this.tryGetCellData=o=>{var s,a;const c=null===(a=null===(s=this.cells.get(o))||void 0===s?void 0:s.obj)||void 0===a?void 0:a.data;if(void 0===c)throw new Error(`Cell '${o}' data undefined.`);return c},this.historyCapacity=5,this.history=[],this.undoingHistory=!1,this.inTransaction=!1,this.inTransactionError=!1,this._inUpdate=!1,this.reverted=!1,this.updateQueue=new MVe,this._tree=bo.createEmpty(ur.createRoot(n&&n.rootState)).asTransient();const i=this._tree.root;this.runTask=n.runTask,void 0!==n?.historyCapacity&&(this.historyCapacity=n.historyCapacity),this.cells.set(i.ref,{parent:this,transform:i,sourceRef:void 0,obj:t,status:"ok",state:{...i.state},errorText:void 0,params:{definition:{},values:{}},paramsNormalizedVersion:i.version,dependencies:{dependentBy:[],dependsOn:[]},cache:{}}),this.globalContext=n&&n.globalContext}}!function(e){let n;e.create=function t(r,i){return new e(r,i)},(n=e.ObjectEvent||(e.ObjectEvent={})).isCell=function i(o,s){return!!s&&o.ref===s.transform.ref&&o.state===s.parent}}(iD||(iD={}));const RVe={doNotLogTiming:!1,doNotUpdateCurrent:!0,revertIfAborted:!1,revertOnError:!1,canUndo:!1};function EL(){return EL=ie(function*(e){let n,i,r=[];if(e.editInfo&&1===e.editInfo.count&&e.editInfo.lastUpdate&&e.editInfo.sourceTree===e.oldTree)n=[],i=[e.editInfo.lastUpdate];else{n=function OVe(e){const t={newTree:e.tree,cells:e.cells,deletes:[]};return bo.doPostOrder(e.oldTree,e.oldTree.root,t,BVe),t.deletes}(e);const a=e.parent.current;let c=!1;for(const u of n)if(u===a){c=!0;break}if(c){const u=Zne(e.oldTree,a,n,e.cells);e.parent.setCurrent(u)}for(let u=n.length-1;u>=0;u--){const l=e.cells.get(n[u]);l&&sD(l.transform,l.obj,l?.transform.params,l.cache,e.parent.globalContext)}for(const u of n){const l=e.cells.get(u);l&&(l.parent=void 0,GVe(l));const d=l&&l.obj;e.cells.delete(u),r.push(d)}i=function NVe(e,t){const n={roots:[],cells:e};return bo.doPreOrder(t,t.root,n,FVe),n.roots}(e.cells,e.tree)}const o=function qVe(e,t){const n={ctx:e,visited:new Set,added:[]};for(const i of t)bo.doPreOrder(e.tree,e.tree.transforms.get(i),n,jVe);for(const i of n.added)HVe(i,e);let r;return n.visited.forEach(i=>{const o=e.cells.get(i);for(const s of o.dependencies.dependentBy)n.visited.has(s.transform.ref)||(r||(r=kr.create()),kr.add(r,s.transform.ref,s))}),{added:n.added,dependent:r?r.array:void 0}}(e,i);for(const a of o.added)e.parent.events.cell.created.next({state:e.parent,ref:a.transform.ref,cell:a});for(let a=0;a0||i.length>0||e.changed}),EL.apply(this,arguments)}function FVe(e,t,n){const r=n.cells.get(e.ref);return r&&r.transform.version===e.version?!("error"===r.status||r&&r.obj===li.Null):(n.roots.push(e.ref),!1)}function BVe(e,t,n){!n.newTree.transforms.has(e.ref)&&n.cells.has(e.ref)&&n.deletes.push(e.ref)}function LVe(e,t,n){const r=n.cells.get(e.ref);!r||!ur.syncState(r.state,e.state)||n.parent.events.cell.stateUpdated.next({state:n.parent,ref:e.ref,cell:r})}function oD(e,t,n,r){const i=e.cells.get(t),o=i.status!==n;i.status=n,i.errorText=r,o&&e.parent.events.cell.stateUpdated.next({state:e.parent,ref:t,cell:i})}function VVe(e,t,n){n.cells.get(e.ref).transform=e,oD(n,e.ref,"pending")}function GVe(e){for(const t of e.dependencies.dependsOn)Eg(t.dependencies.dependentBy,e)}function jVe(e,t,{ctx:n,added:r,visited:i}){if(i.add(e.ref),n.cells.has(e.ref))return;const o={parent:n.parent,transform:e,sourceRef:void 0,status:"pending",state:{...e.state},errorText:void 0,params:void 0,paramsNormalizedVersion:"",dependencies:{dependentBy:[],dependsOn:[]},cache:void 0};n.cells.set(e.ref,o),r.push(o)}function HVe(e,t){if(e.transform.dependsOn)for(const n of e.transform.dependsOn){if(!t.tree.transforms.get(n))throw new Error("Cannot depend on a non-existent transform.");const i=t.cells.get(n);eo(e.dependencies.dependsOn,i),eo(i.dependencies.dependentBy,e)}}function Zne(e,t,n,r){return Qne(e,t,new Set(n),r)}function Qne(e,t,n,r){if(t===ur.RootRef)return t;const i=e.transforms.get(t),o=e.children.get(i.parent).values();let s,a=!1;for(;;){const c=o.next();if(c.done)break;if(n.has(c.value))continue;const u=r.get(c.value);if(!u||"error"===u.status||u.obj===li.Null)continue;const l=e.transforms.get(c.value);if(!l.state.isGhost){if(c.value===t){a=!0,n.has(t)||(s=t);continue}if(a)return l.ref;s=l.ref}}return s||Qne(e,i.parent,n,r)}function PL(e,t,n,r){r||(e.hadError=!0,e.parent.errorFree=!1);const i=e.cells.get(t);if(n){e.wasAborted=e.wasAborted||Oe.isAbort(n);const s=""+n;oD(e,t,"error",s),r||e.parent.events.log.next({type:"error",timestamp:new Date,message:s})}else i.params=void 0;if(i.obj){const s=i.obj;i.obj=void 0,i.cache=void 0,e.parent.events.object.removed.next({state:e.parent,ref:t,obj:s})}const o=e.tree.children.get(t).values();for(;;){const s=o.next();if(s.done)return;PL(e,s.value,void 0,r)}}const WVe="Parent is null";function Jne(e,t){return ML.apply(this,arguments)}function ML(){return ML=ie(function*(e,t){oD(e,t,"processing");let n=!1;try{const i=yi(),o=yield function YVe(e,t){return RL.apply(this,arguments)}(e,t),s=yi()-i;"none"!==o.action&&(e.changed=!0),oD(e,t,"ok"),e.results.push(o),"created"===o.action?(n=o.obj===li.Null,!n&&!e.options.doNotLogTiming&&e.parent.events.log.next(df.info(`Created ${o.obj.label} in ${qF(s)}.`))):("updated"===o.action||"replaced"===o.action)&&(n=o.obj===li.Null,!n&&!e.options.doNotLogTiming&&e.parent.events.log.next(df.info(`Updated ${o.obj.label} in ${qF(s)}.`)))}catch(i){return e.changed=!0,e.hadError||(e.newCurrent=t),PL(e,t,i,!1),void console.error(i)}const r=e.tree.children.get(t).values();for(;;){const i=r.next();if(i.done)return;n?PL(e,i.value,void 0,!0):yield Jne(e,i.value)}}),ML.apply(this,arguments)}function RL(){return RL=ie(function*(e,t){var n;const{oldTree:r,tree:i}=e,o=e.cells.get(t),s=o.transform;if(o.transform.ref===ur.RootRef)return{action:"none"};const a=e.cells.get(o.transform.parent);if(a?.obj===li.Null)return o.sourceRef=a.transform.ref,r.transforms.has(t)&&o.params?(sD(s,o.obj,o.params.values,o.cache,e.parent.globalContext),o.params=void 0,o.obj=li.Null,{ref:t,action:"updated",obj:o.obj}):(o.params=void 0,{ref:t,action:"created",obj:li.Null});const u=0===s.transformer.definition.from.length?a:In.findAncestorOfType(i,e.cells,t,s.transformer.definition.from);if(!u)throw new Error(`No suitable parent found for '${t}'`);e.spine.current=o;const l=u.obj;o.sourceRef=u.transform.ref;const d=function $Ve(e,t,n,r){const i=t.transformer.definition.params,o=i?i(n,e.parent.globalContext):{};if(r.paramsNormalizedVersion!==t.version)t.params=C.normalizeParams(o,t.params,"all"),r.paramsNormalizedVersion=t.version;else{const s=C.getDefaultValues(o);t.params=t.params?function AMe(e,t){for(const n of Object.keys(t))OI.call(t,n)&&typeof e[n]>"u"&&(e[n]=t[n]);return e}(t.params,s):s}return C.resolveRefs(o,t.params,e.getCellData),{definition:o,values:t.params}}(e,s,l,o);if(!r.transforms.has(t)||!o.params){o.params=d;const f=yield tre(e,o,s.transformer,l,d.values);return kL(f,s),o.obj=f,{ref:t,action:"created",obj:f}}{const f=o.params.values,p=o.cache,m=null===(n=o.obj)||void 0===n?void 0:n.data,h=d.values;switch(o.params=d,o.obj&&o.obj!==li.Null?yield function XVe(e,t,n,r,i,o,s){return FL.apply(this,arguments)}(e,o,s.transformer,l,o.obj,f,h):Qe.UpdateResult.Recreate){case Qe.UpdateResult.Recreate:{const y=o.obj;sD(s,y,f,p,e.parent.globalContext);const b=yield tre(e,o,s.transformer,l,h);return kL(b,s),o.obj=b,{ref:t,action:"replaced",oldObj:y,obj:b}}case Qe.UpdateResult.Updated:return kL(o.obj,s),{ref:t,action:"updated",oldData:m,obj:o.obj};case Qe.UpdateResult.Null:return sD(s,o.obj,f,p,e.parent.globalContext),o.obj=li.Null,{ref:t,action:"updated",obj:o.obj};default:return{action:"none"}}}}),RL.apply(this,arguments)}function sD(e,t,n,r,i){var o,s;null===(s=(o=e.transformer.definition).dispose)||void 0===s||s.call(o,{b:t!==li.Null?t:void 0,params:n,cache:r},i)}function kL(e,t){!e||e===li.Null||(e.tags=t.tags)}function NL(e,t){return"function"==typeof e.runInContext?e.runInContext(t):e}function ere(e){if(0===e.dependencies.dependsOn.length)return;const t=Object.create(null);for(const n of e.dependencies.dependsOn){if(!n.obj)throw new Error("Unresolved dependency.");t[n.transform.ref]=n.obj}return t}function tre(e,t,n,r,i){return t.cache||(t.cache=Object.create(null)),NL(n.definition.apply({a:r,params:i,cache:t.cache,spine:e.spine,dependencies:ere(t)},e.parent.globalContext),e.taskCtx)}function FL(){return FL=ie(function*(e,t,n,r,i,o,s){return n.definition.update?(t.cache||(t.cache=Object.create(null)),NL(n.definition.update({a:r,oldParams:o,b:i,newParams:s,cache:t.cache,spine:e.spine,dependencies:ere(t)},e.parent.globalContext),e.taskCtx)):Qe.UpdateResult.Recreate}),FL.apply(this,arguments)}var pe,Rt;!function(e){function r(f){return e.Create({...f,typeClass:"Representation3D"})}e.Create=li.factory(),e.isRepresentation3D=function t(f){return!!f&&"Representation3D"===f.type.typeClass},e.isBehavior=function n(f){return!!f&&"Behavior"===f.type.typeClass},e.CreateRepresentation3D=r,e.CreateBehavior=function i(f){return e.Create({...f,typeClass:"Behavior"})};class o extends(e.Create({name:"Root",typeClass:"Root"})){}e.Root=o;class s extends(e.Create({name:"Group",typeClass:"Group"})){}let a,c,u,l,d;e.Group=s,function(f){class p extends(e.Create({name:"String Data",typeClass:"Data"})){}f.String=p;class m extends(e.Create({name:"Binary Data",typeClass:"Data"})){}f.Binary=m;class h extends(e.Create({name:"Data Blob",typeClass:"Data"})){}f.Blob=h}(a=e.Data||(e.Data={})),function(f){class p extends(e.Create({name:"JSON Data",typeClass:"Data"})){}f.Json=p;class m extends(e.Create({name:"CIF File",typeClass:"Data"})){}f.Cif=m;class h extends(e.Create({name:"Cube File",typeClass:"Data"})){}f.Cube=h;class g extends(e.Create({name:"PSF File",typeClass:"Data"})){}f.Psf=g;class y extends(e.Create({name:"PRMTOP File",typeClass:"Data"})){}f.Prmtop=y;class b extends(e.Create({name:"TOP File",typeClass:"Data"})){}f.Top=b;class x extends(e.Create({name:"PLY File",typeClass:"Data"})){}f.Ply=x;class _ extends(e.Create({name:"CCP4/MRC/MAP File",typeClass:"Data"})){}f.Ccp4=_;class S extends(e.Create({name:"DSN6/BRIX File",typeClass:"Data"})){}f.Dsn6=S;class A extends(e.Create({name:"DX File",typeClass:"Data"})){}f.Dx=A;class E extends(e.Create({name:"Format Blob",typeClass:"Data"})){}f.Blob=E}(c=e.Format||(e.Format={})),function(f){class p extends(e.Create({name:"Coordinates",typeClass:"Object"})){}f.Coordinates=p;class m extends(e.Create({name:"Topology",typeClass:"Object"})){}f.Topology=m;class h extends(e.Create({name:"Model",typeClass:"Object"})){}f.Model=h;class g extends(e.Create({name:"Trajectory",typeClass:"Object"})){}f.Trajectory=g;class y extends(e.Create({name:"Structure",typeClass:"Object"})){}f.Structure=y,function(b){class x extends(r({name:"Structure 3D"})){}b.Representation3D=x;class _ extends(e.Create({name:"Structure 3D State",typeClass:"Object"})){}b.Representation3DState=_;class S extends(e.Create({name:"Selections",typeClass:"Object"})){}b.Selections=S}(y=f.Structure||(f.Structure={}))}(u=e.Molecule||(e.Molecule={})),function(f){class p extends(e.Create({name:"Volume",typeClass:"Object"})){}f.Data=p;class m extends(e.Create({name:"Lazy Volume",typeClass:"Object"})){}f.Lazy=m;class h extends(r({name:"Volume 3D"})){}f.Representation3D=h}(l=e.Volume||(e.Volume={})),function(f){class p extends(e.Create({name:"Shape Provider",typeClass:"Object"})){}f.Provider=p;class m extends(r({name:"Shape 3D"})){}f.Representation3D=m}(d=e.Shape||(e.Shape={}))}(pe||(pe={})),function(e){e.CreateBuiltIn=Qe.factory("ms-plugin"),e.BuiltIn=Qe.builderFactory("ms-plugin")}(Rt||(Rt={}));const nre=.529177210859;function JVe(e,t){return Oe.create("Parse Cube",function(){var n=ie(function*(r){yield r.update("Reading header...");const i=ht(e),{header:o,atoms:s}=function KVe(e){const t=ht.readLines(e,6),n=(b,x)=>{const _=+t[b].trim().split(/\s+/g)[x];return Number.isNaN(_)?0:_},r=b=>{const x=n(b+2,0),_=nre;return[Math.abs(x),v.create(n(b+2,1)*_,n(b+2,2)*_,n(b+2,3)*_),x]},i=t[0].trim(),o=t[1].trim(),[s,a,c]=r(0),[u,l]=r(1),[d,f]=r(2),[p,m]=r(3),h=function ZVe(e,t,n){const r=new Int32Array(t),i=new Float64Array(t),o=new Float32Array(t),s=new Float32Array(t),a=new Float32Array(t);for(let c=0;c=0){let b=n(2,4);0===b&&(b=1);for(let x=0;x{const u=Math.min(r,s+a);for(let l=s;la.update({current:Math.min(u,r),max:r}))}(r,i,o);return Fr.success({header:o,atoms:s,values:a,name:t})});return function(r){return n.apply(this,arguments)}}())}function rre(e){const t={h:v()};let n=0,r=0;const i=/\s+/g;for(;;){const o=ht.readLine(e);let s;if(o.startsWith("object 1"))s=o.split(i),t.dim=v.create(parseInt(s[5]),parseInt(s[6]),parseInt(s[7]));else if(o.startsWith("origin"))s=o.split(i),t.min=v.create(parseFloat(s[1]),parseFloat(s[2]),parseFloat(s[3]));else if(o.startsWith("delta"))s=o.split(i),0===r?t.h[0]=parseFloat(s[1]):1===r?t.h[1]=parseFloat(s[2]):2===r&&(t.h[2]=parseFloat(s[3])),r+=1;else if(o.startsWith("object 3")){n+=o.length+1;break}n+=o.length+1}return{header:t,headerByteCount:n}}function BL(){return BL=ie(function*(e,t,n){yield e.update("Reading header...");const r=ht(t),{header:i}=rre(r);yield e.update("Reading values...");const o=yield function eze(e,t,n){const r=n.dim[0]*n.dim[1]*n.dim[2],i=1e6,o=new Float64Array(r);let s=0;return op(e,i,o,(a,c)=>{const u=Math.min(r,s+a);for(let l=s;la.update({current:Math.min(u,r),max:r}))}(e,r,i);return Fr.success({header:i,values:o,name:n})}),BL.apply(this,arguments)}function OL(){return OL=ie(function*(e,t,n){yield e.update("Reading header...");const i=ht(GB(t,0,1e3)),{header:o,headerByteCount:s}=rre(i);yield e.update("Reading values...");const a=o.dim[0]*o.dim[1]*o.dim[2],c=new DataView(t.buffer,t.byteOffset+s),u=new Float64Array(a);for(let l=0;l{e.set(xn[t],t)})}(),Object.keys({NATOM:"",NTYPES:"",NBONH:"",MBONA:"",NTHETH:"",MTHETA:"",NPHIH:"",MPHIA:"",NHPARM:"",NPARM:"",NNB:"",NRES:"",NBONA:"",NTHETA:"",NPHIA:"",NUMBND:"",NUMANG:"",NPTRA:"",NATYP:"",NPHB:"",IFPERT:"",NBPER:"",NGPER:"",NDPER:"",MBPER:"",MGPER:"",MDPER:"",IFBOX:"",NMXRS:"",IFCAP:"",NUMEXTRA:"",NCOPY:""})),{readLine:aD,markLine:ore,trim:ize}=ht;function sze(e){const{tokenizer:t}=e,n=[];for(;t.tokenEnd{n[i]=0});let r=0;for(;t.tokenEnd1e5&&t.shouldUpdate&&(o=n.position,yield t.update({current:n.position,max:n.length}));const s=aD(r.tokenizer).trim();if(s.startsWith("%VERSION"))i.version=s.substring(8).trim();else if(s.startsWith("%FLAG")){const a=s.substring(5).trim();if(!aD(r.tokenizer).trim().startsWith("%FORMAT"))throw new Error("expected %FORMAT");if("TITLE"===a)i.title=sze(r);else if("POINTERS"===a)i.pointers=aze(r);else if("ATOM_NAME"===a){const u=fm(r,i.pointers.NATOM,20,4);i.atomName=Jt(u)(te.Schema.str)}else if("CHARGE"===a){const u=fm(r,i.pointers.NATOM,5,16);i.charge=Jt(u)(te.Schema.float)}else if("MASS"===a){const u=fm(r,i.pointers.NATOM,5,16);i.mass=Jt(u)(te.Schema.float)}else if("RESIDUE_LABEL"===a){const u=fm(r,i.pointers.NRES,20,4);i.residueLabel=Jt(u)(te.Schema.str)}else if("RESIDUE_POINTER"===a){const u=fm(r,i.pointers.NRES,10,8);i.residuePointer=Jt(u)(te.Schema.int)}else if("BONDS_INC_HYDROGEN"===a){const u=fm(r,3*i.pointers.NBONH,10,8);i.bondsIncHydrogen=Jt(u)(te.Schema.int)}else if("BONDS_WITHOUT_HYDROGEN"===a){const u=fm(r,3*i.pointers.NBONA,10,8);i.bondsWithoutHydrogen=Jt(u)(te.Schema.int)}else if("RADII"===a){const u=fm(r,i.pointers.NATOM,5,16);i.radii=Jt(u)(te.Schema.float)}else for(;n.tokenEnd=t.length));){const i=t.data[t.position];if("["===i)break;if(";"!==i&&"*"!==i){for(let o=0;o<2;++o)switch(hm(t),cD(t),VL(t),o){case 0:He.add(n,t.tokenStart,t.tokenEnd);break;case 1:He.add(r,t.tokenStart,t.tokenEnd)}pze(t),cD(t)}else pm(t)}return Xn.ofColumns(fze,{compound:Jt(n)(te.Schema.str),molCount:Jt(r)(te.Schema.int)})}function zL(){return zL=ie(function*(e,t){const n=ht(e),r=function hze(e,t){return{tokenizer:e,runtimeCtx:t}}(n,t),i=Object.create(null);let o=0;i.compounds={};let s={},a="";function c(){a&&s.atoms&&(i.compounds[a]=s,s={},a="")}for(;n.tokenEnd1e5&&t.shouldUpdate&&(o=n.position,yield t.update({current:n.position,max:n.length}));const u=UL(r.tokenizer).trim();if(u&&"*"!==u[0]&&";"!==u[0]){if(u.startsWith("#include"))throw new Error("#include statements not allowed");if(u.startsWith("[")){const l=u.match(mze);if(null===l)throw new Error("expected field name");const d=l[1];if("moleculetype"===d)c(),a=yze(r);else if("atoms"===d)s.atoms=bze(r);else if("bonds"===d)s.bonds=vze(r);else if("system"===d)i.system=_ze(r);else if("molecules"===d)c(),i.molecules=xze(r);else for(;n.tokenEndOe.create("Download",function(){var r=ie(function*(i){const o=fr.getUrlAsset(n.managers.asset,e.url),s=yield n.managers.asset.resolve(o,e.isBinary?"binary":"string").runInContext(i);return t.asset=s,e.isBinary?new pe.Data.Binary(s.data,{label:e.label?e.label:o.url}):new pe.Data.String(s.data,{label:e.label?e.label:o.url})});return function(i){return r.apply(this,arguments)}}()),dispose({cache:e}){var t;null===(t=e?.asset)||void 0===t||t.dispose()},update:({oldParams:e,newParams:t,b:n})=>e.url!==t.url||e.isBinary!==t.isBinary?Qe.UpdateResult.Recreate:e.label!==t.label?(n.label=t.label||("string"==typeof t.url?t.url:t.url.url),Qe.UpdateResult.Updated):Qe.UpdateResult.Unchanged}),are=Rt.BuiltIn({name:"download-blob",display:{name:"Download Blob",description:"Download multiple string or binary data from the specified URLs."},from:pe.Root,to:pe.Data.Blob,params:{sources:C.ObjectList({id:C.Text("",{label:"Unique ID"}),url:C.Url("https://www.ebi.ac.uk/pdbe/static/entry/1cbs_updated.cif",{description:"Resource URL. Must be the same domain or support CORS."}),isBinary:C.Optional(C.Boolean(!1,{description:"If true, download data as binary (string otherwise)"})),canFail:C.Optional(C.Boolean(!1,{description:"Indicate whether the download can fail and not be included in the blob as a result."}))},e=>`${e.id}: ${e.url}`),maxConcurrency:C.Optional(C.Numeric(4,{min:1,max:12,step:1},{description:"The maximum number of concurrent downloads."}))}})({apply:({params:e,cache:t},n)=>Oe.create("Download Blob",function(){var r=ie(function*(i){const o=[],s=yield function ILe(e,t,n,r){return OO.apply(this,arguments)}(i,n.managers.asset,e.sources,e.maxConcurrency||4),a=[];for(let c=0;cOe.create("Raw Data",ie(function*(){return"string"==typeof e.data?new pe.Data.String(e.data,{label:e.label?e.label:"String"}):Array.isArray(e.data)||e.data instanceof ArrayBuffer?new pe.Data.Binary(new Uint8Array(e.data),{label:e.label?e.label:"Binary"}):e.data instanceof Uint8Array?new pe.Data.Binary(e.data,{label:e.label?e.label:"Binary"}):void Rr()})),update:({oldParams:e,newParams:t,b:n})=>e.data!==t.data?Qe.UpdateResult.Recreate:e.label!==t.label?(n.label=t.label||n.label,Qe.UpdateResult.Updated):Qe.UpdateResult.Unchanged,customSerialization:{toJSON(e){if("string"==typeof e.data||Array.isArray(e.data))return e;if(e.data instanceof ArrayBuffer){const t=new Uint8Array(e.data),n=new Array(t.length);for(let r=0,i=t.length;re}}),ure=Rt.BuiltIn({name:"read-file",display:{name:"Read File",description:"Read string or binary data from the specified file"},from:pe.Root,to:[pe.Data.String,pe.Data.Binary],params:{file:C.File(),label:C.Optional(C.Text("")),isBinary:C.Optional(C.Boolean(!1,{description:"If true, open file as as binary (string otherwise)"}))}})({apply:({params:e,cache:t},n)=>Oe.create("Open File",function(){var r=ie(function*(i){if(null===e.file)return n.log.error("No file(s) selected"),li.Null;const o=yield n.managers.asset.resolve(e.file,e.isBinary?"binary":"string").runInContext(i);return t.asset=o,e.isBinary?new pe.Data.Binary(o.data,{label:e.label?e.label:e.file.name}):new pe.Data.String(o.data,{label:e.label?e.label:e.file.name})});return function(i){return r.apply(this,arguments)}}()),dispose({cache:e}){var t;null===(t=e?.asset)||void 0===t||t.dispose()},update({oldParams:e,newParams:t,b:n}){var r;return e.label!==t.label?(n.label=t.label||(null===(r=e.file)||void 0===r?void 0:r.name)||"",Qe.UpdateResult.Updated):Qe.UpdateResult.Unchanged},isSerializable:()=>({isSerializable:!1,reason:"Cannot serialize user loaded files."})}),wze=Rt.BuiltIn({name:"parse-blob",display:{name:"Parse Blob",description:"Parse multiple data enties"},from:pe.Data.Blob,to:pe.Format.Blob,params:{formats:C.ObjectList({id:C.Text("",{label:"Unique ID"}),format:C.Select("cif",[["cif","cif"]])},e=>`${e.id}: ${e.format}`)}})({apply:({a:e,params:t},n)=>Oe.create("Parse Blob",function(){var r=ie(function*(i){const o=new Map;for(const a of t.formats)o.set(a.id,a.format);const s=[];for(const a of e.data){if(!o.has(a.id))continue;const c=yield("string"===a.kind?od.parse(a.data):od.parseBinary(a.data)).runInContext(i);if(c.isError)throw new Error(`${a.id}: ${c.message}`);s.push({id:a.id,kind:"cif",data:c.result})}return new pe.Format.Blob(s,{label:"Format Blob",description:`${s.length} ${1===s.length?"entry":"entries"}`})});return function(i){return r.apply(this,arguments)}}())}),Aze=Rt.BuiltIn({name:"parse-cif",display:{name:"Parse CIF",description:"Parse CIF from String or Binary data"},from:[pe.Data.String,pe.Data.Binary],to:pe.Format.Cif})({apply:({a:e})=>Oe.create("Parse CIF",function(){var t=ie(function*(n){const r=yield("string"==typeof e.data?od.parse(e.data):od.parseBinary(e.data)).runInContext(n);if(r.isError)throw new Error(r.message);return 0===r.result.blocks.length?li.Null:new pe.Format.Cif(r.result)});return function(n){return t.apply(this,arguments)}}())}),Ize=Rt.BuiltIn({name:"parse-cube",display:{name:"Parse Cube",description:"Parse Cube from String data"},from:pe.Data.String,to:pe.Format.Cube})({apply:({a:e})=>Oe.create("Parse Cube",function(){var t=ie(function*(n){const r=yield JVe(e.data,e.label).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Cube(r.result)});return function(n){return t.apply(this,arguments)}}())}),Tze=Rt.BuiltIn({name:"parse-psf",display:{name:"Parse PSF",description:"Parse PSF from String data"},from:[pe.Data.String],to:pe.Format.Psf})({apply:({a:e})=>Oe.create("Parse PSF",function(){var t=ie(function*(n){const r=yield function bUe(e){return Oe.create("Parse PSF",function(){var t=ie(function*(n){return yield function yUe(e,t){return C4.apply(this,arguments)}(e,n)});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Psf(r.result)});return function(n){return t.apply(this,arguments)}}())}),Dze=Rt.BuiltIn({name:"parse-prmtop",display:{name:"Parse PRMTOP",description:"Parse PRMTOP from String data"},from:[pe.Data.String],to:pe.Format.Prmtop})({apply:({a:e})=>Oe.create("Parse PRMTOP",function(){var t=ie(function*(n){const r=yield function uze(e){return Oe.create("Parse PRMTOP",function(){var t=ie(function*(n){return yield function cze(e,t){return LL.apply(this,arguments)}(e,n)});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Prmtop(r.result)});return function(n){return t.apply(this,arguments)}}())}),Eze=Rt.BuiltIn({name:"parse-top",display:{name:"Parse TOP",description:"Parse TOP from String data"},from:[pe.Data.String],to:pe.Format.Top})({apply:({a:e})=>Oe.create("Parse TOP",function(){var t=ie(function*(n){const r=yield function Cze(e){return Oe.create("Parse TOP",function(){var t=ie(function*(n){return yield function Sze(e,t){return zL.apply(this,arguments)}(e,n)});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Top(r.result)});return function(n){return t.apply(this,arguments)}}())}),Pze=Rt.BuiltIn({name:"parse-ply",display:{name:"Parse PLY",description:"Parse PLY from String data"},from:[pe.Data.String],to:pe.Format.Ply})({apply:({a:e})=>Oe.create("Parse PLY",function(){var t=ie(function*(n){const r=yield function lUe(e){return Oe.create("Parse PLY",function(){var t=ie(function*(n){return yield function uUe(e,t){return v4.apply(this,arguments)}(e,n)});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Ply(r.result,{label:r.result.comments[0]||"PLY Data"})});return function(n){return t.apply(this,arguments)}}())}),Mze=Rt.BuiltIn({name:"parse-ccp4",display:{name:"Parse CCP4/MRC/MAP",description:"Parse CCP4/MRC/MAP from Binary data"},from:[pe.Data.Binary],to:pe.Format.Ccp4})({apply:({a:e})=>Oe.create("Parse CCP4/MRC/MAP",function(){var t=ie(function*(n){const r=yield function q8e(e,t){return function H8e(e,t){return Oe.create("Parse CCP4/MRC/MAP",function(){var n=ie(function*(r){try{return Fr.success(yield function j8e(e,t,n){return p4.apply(this,arguments)}(e,t,r))}catch(i){return Fr.error(i)}});return function(r){return n.apply(this,arguments)}}())}(kT.fromBuffer(cd.fromUint8Array(e),t),e.length)}(e.data,e.label).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Ccp4(r.result)});return function(n){return t.apply(this,arguments)}}())}),Rze=Rt.BuiltIn({name:"parse-dsn6",display:{name:"Parse DSN6/BRIX",description:"Parse CCP4/BRIX from Binary data"},from:[pe.Data.Binary],to:pe.Format.Dsn6})({apply:({a:e})=>Oe.create("Parse DSN6/BRIX",function(){var t=ie(function*(n){const r=yield function J8e(e,t){return function Q8e(e,t){return Oe.create("Parse DSN6/BRIX",function(){var n=ie(function*(r){try{return Fr.success(yield function Z8e(e,t,n){return y4.apply(this,arguments)}(e,t,r))}catch(i){return Fr.error(i)}});return function(r){return n.apply(this,arguments)}}())}(kT.fromBuffer(cd.fromUint8Array(e),t),e.length)}(e.data,e.label).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Dsn6(r.result)});return function(n){return t.apply(this,arguments)}}())}),kze=Rt.BuiltIn({name:"parse-dx",display:{name:"Parse DX",description:"Parse DX from Binary/String data"},from:[pe.Data.Binary,pe.Data.String],to:pe.Format.Dx})({apply:({a:e})=>Oe.create("Parse DX",function(){var t=ie(function*(n){const r=yield function rze(e,t){return Oe.create("Parse DX",n=>"string"==typeof e?function tze(e,t,n){return BL.apply(this,arguments)}(n,e,t):function nze(e,t,n){return OL.apply(this,arguments)}(n,e,t))}(e.data,e.label).runInContext(n);if(r.isError)throw new Error(r.message);return new pe.Format.Dx(r.result)});return function(n){return t.apply(this,arguments)}}())}),Nze=Rt.BuiltIn({name:"import-string",display:{name:"Import String",description:"Import given data as a string"},from:pe.Root,to:pe.Data.String,params:{data:C.Value(""),label:C.Optional(C.Text(""))}})({apply:({params:{data:e,label:t}})=>new pe.Data.String(e,{label:t||""}),update:({oldParams:e,newParams:t,b:n})=>e.data!==t.data?Qe.UpdateResult.Recreate:e.label!==t.label?(n.label=t.label||"",Qe.UpdateResult.Updated):Qe.UpdateResult.Unchanged,isSerializable:()=>({isSerializable:!1,reason:"Cannot serialize user imported strings."})}),Fze=Rt.BuiltIn({name:"import-json",display:{name:"Import JSON",description:"Import given data as a JSON"},from:pe.Root,to:pe.Format.Json,params:{data:C.Value({}),label:C.Optional(C.Text(""))}})({apply:({params:{data:e,label:t}})=>new pe.Format.Json(e,{label:t||""}),update:({oldParams:e,newParams:t,b:n})=>e.data!==t.data?Qe.UpdateResult.Recreate:e.label!==t.label?(n.label=t.label||"",Qe.UpdateResult.Updated):Qe.UpdateResult.Unchanged,isSerializable:()=>({isSerializable:!1,reason:"Cannot serialize user imported JSON."})}),Bze=Rt.BuiltIn({name:"parse-json",display:{name:"Parse JSON",description:"Parse JSON from String data"},from:[pe.Data.String],to:pe.Format.Json})({apply:({a:e})=>Oe.create("Parse JSON",function(){var t=ie(function*(n){const r=yield new Response(e.data).json();return new pe.Format.Json(r)});return function(n){return t.apply(this,arguments)}}())}),Oze=Rt.BuiltIn({name:"lazy-volume",display:{name:"Lazy Volume",description:"A placeholder for lazy loaded volume representation"},from:pe.Root,to:pe.Volume.Lazy,params:{url:C.Url(""),isBinary:C.Boolean(!1),format:C.Text("ccp4"),entryId:C.Value("",{isHidden:!0}),isovalues:C.ObjectList({type:C.Text("relative"),value:C.Numeric(0),color:C.Color(xn.black),alpha:C.Numeric(1,{min:0,max:1,step:.01}),volumeIndex:C.Numeric(0)},e=>`${e.type} ${e.value}`)}})({apply:({params:t})=>Oe.create("Lazy Volume",function(){var n=ie(function*(r){const i=Array.isArray(t.entryId)?t.entryId.join(", "):t.entryId;return new pe.Volume.Lazy(t,{label:`${i||t.url}`,description:"Lazy Volume"})});return function(r){return n.apply(this,arguments)}}())}),Lze=Rt.BuiltIn({name:"create-group",display:{name:"Group"},from:[],to:pe.Group,params:{label:C.Text("Group"),description:C.Optional(C.Text(""))}})({apply:({params:e})=>new pe.Group({},e),update:({oldParams:e,newParams:t,b:n})=>EI(e,t)?Qe.UpdateResult.Unchanged:(n.label=t.label,n.description=t.description,Qe.UpdateResult.Updated)});function Hze(e,t){return{tokenizer:e,header:{title:"",timeInPs:0,hasVelocities:!1,precision:{position:0,velocity:0},box:[0,0,0]},numberOfAtoms:0,runtimeCtx:t}}function qze(e){const{tokenizer:t,header:n}=e;let r=ht.readLine(t);0===r.trim().length&&(r=ht.readLine(t));const i=r.lastIndexOf("t=");i>=0?(n.timeInPs=parseFloat(r.substring(i+2)),n.title=r.substring(0,i).trim(),n.title&&","===n.title[n.title.length-1]&&(n.title=n.title.substring(0,n.title.length-1))):n.title=r}function Wze(e){const{tokenizer:t}=e;ht.markLine(t);const n=ht.getTokenString(t);e.numberOfAtoms=parseInt(n)}function $ze(e){return GL.apply(this,arguments)}function GL(){return GL=ie(function*(e){const{tokenizer:t,numberOfAtoms:n}=e,r=yield ht.readLinesAsync(t,n,e.runtimeCtx,1e5),o=t.data.substring(r.indices[0],r.indices[1]).substring(20).match(/\.\d+/g),s=6===o.length;e.header.hasVelocities=s,e.header.precision.position=o[0].length-1,e.header.precision.velocity=s?o[3].length-1:0;const c=e.header.precision.position+5,u=20+3*c,l=e.header.precision.velocity+4,d=function zze(e){return function(t,n,r){return function Gze(e,t,n,r){const{data:i,indices:o,count:s}=e,{valueType:a}=r,c="str"===a?u=>{const l=o[2*u]+t,d=o[2*u+1];if(l>=d)return"";let f=l+n;return f>d&&(f=d),function NOe(e,t,n){let r=t,i=n-1,o=e.charCodeAt(r);for(;(9===o||32===o)&&r<=i;)o=e.charCodeAt(++r);for(o=e.charCodeAt(i);(9===o||32===o)&&i>=r;)o=e.charCodeAt(--i);return e.substring(r,i+1)}(i,l,f)}:"int"===a?u=>{const l=o[2*u]+t;return l>o[2*u+1]?0:Ig(i,l,l+n)}:u=>{const l=o[2*u]+t;return l>o[2*u+1]?0:function iMe(e,t,n){for(;t0,toArray:u=>Ps(s,c,u),areValuesEqual:(u,l)=>c(u)===c(l)}}(e,t,n,r)}}(r),f=te.Undefined(e.numberOfAtoms,te.Schema.float);return{count:e.numberOfAtoms,residueNumber:d(0,5,te.Schema.int),residueName:d(5,5,te.Schema.str),atomName:d(10,5,te.Schema.str),atomNumber:d(15,5,te.Schema.int),x:d(20,c,te.Schema.float),y:d(20+c,c,te.Schema.float),z:d(20+2*c,c,te.Schema.float),vx:s?d(u,l,te.Schema.float):f,vy:s?d(u+l,l,te.Schema.float):f,vz:s?d(u+2*l,l,te.Schema.float):f}}),GL.apply(this,arguments)}function Yze(e){const{tokenizer:t}=e,n=ht.readLine(t).trim().split(/\s+/g);e.header.box=[+n[0],+n[1],+n[2]]}function jL(){return jL=ie(function*(e,t){const n=ht(e);yield t.update({message:"Parsing...",current:0,max:e.length});const r=[];for(;n.position0?Math.ceil(e/r):0;return{width:r,height:i,length:r*i*t}}(e,t);return{array:r=r&&r.length>=i?r:new n(i),width:o,height:s}}const al=v(),r7e=new fu("14"),i7e=new fu("98");function hre(e){return e>1e5?r7e:i7e}function Ip(e,t,n){const r=3*n,i=hre(t);i.reset();for(let s=0,a=3*t;s>2),r=t-4>>2,i=4*r;let o=0;if(r<0)for(let s=0;s>16]}for(let s=i;s!1),s){if(e%n!=0)throw new Error("incompatible groupCount and stride");const a={location:rc,location2:rc,index:0,groupIndex:0,instanceIndex:0,isSecondary:!1};let c=a.groupIndex(c&&(a.groupIndex=l,a.instanceIndex=d,a.index=d*e+l,a.location=r(l,f?-1:d),p&&(a.location2=s(l,f?-1:d)),a.isSecondary=o(l,f?-1:d),l+=n,l===e?(++d,u=!0,d=85}return!1}(e);return{instancedArrays:t,standardDerivatives:r,elementIndexUint:n,textureFloat:i,textureFloatLinear:o,textureHalfFloat:s,textureHalfFloatLinear:a,depthTexture:c,blendMinMax:u,vertexArrayObject:l,fragDepth:d,colorBufferFloat:f,colorBufferHalfFloat:p,drawBuffers:m,drawBuffersIndexed:h,shaderTextureLod:g,sRGB:y,disjointTimerQuery:b,multiDraw:x,drawInstancedBaseVertexBaseInstance:_,multiDrawInstancedBaseVertexBaseInstance:S,parallelShaderCompile:A,fboRenderMipmap:E,provokingVertex:w,clipCullDistance:D,conservativeDepth:I,stencilTexturing:R,clipControl:T,noNonInstancedActiveAttribs:M}}var d0;!function(e){e.create=function t(i,o,s){return{array:i,width:o,height:s}},e.flipY=function n(i){const{array:o,width:s,height:a}=i,u=s*(o.length/(s*a));for(let l=0,d=a/2;l 0.0 && uBumpAmplitude > 0.0 && bumpiness > 0.0) {\n material.rgb += fbm(vModelPosition * uBumpFrequency) * uBumpAmplitude * bumpiness;\n material.rgb -= 0.5 * uBumpAmplitude * bumpiness;\n }\n #endif\n\n gl_FragColor = material;\n#else\n #ifdef bumpEnabled\n if (uBumpFrequency > 0.0 && uBumpAmplitude > 0.0 && bumpiness > 0.0) {\n normal = perturbNormal(-vViewPosition, normal, fbm(vModelPosition * uBumpFrequency), (uBumpAmplitude * bumpiness) / uBumpFrequency);\n }\n #endif\n\n vec4 color = material;\n\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n\n PhysicalMaterial physicalMaterial;\n physicalMaterial.diffuseColor = color.rgb * (1.0 - metalness);\n #ifdef enabledFragDepth\n physicalMaterial.roughness = min(max(roughness, 0.0525), 1.0);\n #else\n vec3 dxy = max(abs(dFdx(normal)), abs(dFdy(normal)));\n float geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\n physicalMaterial.roughness = min(max(roughness, 0.0525) + geometryRoughness, 1.0);\n #endif\n physicalMaterial.specularColor = mix(vec3(0.04), color.rgb, metalness);\n physicalMaterial.specularF90 = 1.0;\n\n GeometricContext geometry;\n geometry.position = -vViewPosition;\n geometry.normal = normal;\n geometry.viewDir = normalize(vViewPosition);\n\n IncidentLight directLight;\n #pragma unroll_loop_start\n for (int i = 0; i < dLightCount; ++i) {\n directLight.direction = uLightDirection[i];\n directLight.color = uLightColor[i] * PI; // * PI for punctual light\n RE_Direct_Physical(directLight, geometry, physicalMaterial, reflectedLight);\n }\n #pragma unroll_loop_end\n\n vec3 irradiance = uAmbientColor * PI; // * PI for punctual light\n RE_IndirectDiffuse_Physical(irradiance, geometry, physicalMaterial, reflectedLight);\n\n // indirect specular only metals\n vec3 radiance = uAmbientColor * metalness;\n vec3 iblIrradiance = uAmbientColor * metalness;\n vec3 clearcoatRadiance = vec3(0.0);\n RE_IndirectSpecular_Physical(radiance, iblIrradiance, clearcoatRadiance, geometry, physicalMaterial, reflectedLight);\n\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n outgoingLight = clamp(outgoingLight, 0.01, 0.99); // prevents black artifacts on specular highlight with transparent background\n\n gl_FragColor = vec4(outgoingLight, color.a);\n#endif\n\n#if defined(dXrayShaded_on)\n gl_FragColor.a *= 1.0 - pow(abs(dot(normal, vec3(0.0, 0.0, 1.0))), uXrayEdgeFalloff);\n#elif defined(dXrayShaded_inverted)\n gl_FragColor.a *= pow(abs(dot(normal, vec3(0.0, 0.0, 1.0))), uXrayEdgeFalloff);\n#endif\n\ngl_FragColor.rgb *= uExposure;\n",apply_marker_color:"\n\n#if defined(dColorMarker)\n if (marker > 0.0) {\n if ((uMarkerPriority == 1 && marker != 2.0) || (uMarkerPriority != 1 && marker == 1.0)) {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, uHighlightColor, uHighlightStrength);\n gl_FragColor.a = max(gl_FragColor.a, uHighlightStrength * 0.002); // for direct-volume rendering\n } else {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, uSelectColor, uSelectStrength);\n gl_FragColor.a = max(gl_FragColor.a, uSelectStrength * 0.002); // for direct-volume rendering\n }\n } else if (uMarkerAverage > 0.0) {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, uDimColor, uDimStrength);\n gl_FragColor.a = max(gl_FragColor.a, uDimStrength * 0.002); // for direct-volume rendering\n }\n#endif\n",assign_clipping_varying:"\n#if dClipObjectCount != 0 && defined(dClipping)\n #if defined(dClippingType_instance)\n vClipping = readFromTexture(tClipping, aInstance, uClippingTexDim).a;\n #elif defined(dMarkerType_groupInstance)\n vClipping = readFromTexture(tClipping, aInstance * float(uGroupCount) + group, uClippingTexDim).a;\n #endif\n#endif\n",assign_color_varying:"\n#if defined(dRenderVariant_color)\n #if defined(dColorType_attribute)\n vColor.rgb = aColor;\n #elif defined(dColorType_instance)\n vColor.rgb = readFromTexture(tColor, aInstance, uColorTexDim).rgb;\n #elif defined(dColorType_group)\n #if defined(dDualColor)\n vec4 color2;\n if (aColorMode == 2.0) {\n vColor.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;\n } else {\n vColor.rgb = readFromTexture(tColor, group * 2.0, uColorTexDim).rgb;\n color2.rgb = readFromTexture(tColor, group * 2.0 + 1.0, uColorTexDim).rgb;\n }\n #else\n vColor.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;\n #endif\n #elif defined(dColorType_groupInstance)\n #if defined(dDualColor)\n vec4 color2;\n if (aColorMode == 2.0) {\n vColor.rgb = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim).rgb;\n } else {\n vColor.rgb = readFromTexture(tColor, (aInstance * float(uGroupCount) + group) * 2.0, uColorTexDim).rgb;\n color2.rgb = readFromTexture(tColor, (aInstance * float(uGroupCount) + group) * 2.0 + 1.0, uColorTexDim).rgb;\n }\n #else\n vColor.rgb = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim).rgb;\n #endif\n #elif defined(dColorType_vertex)\n vColor.rgb = readFromTexture(tColor, VertexID, uColorTexDim).rgb;\n #elif defined(dColorType_vertexInstance)\n vColor.rgb = readFromTexture(tColor, int(aInstance) * uVertexCount + VertexID, uColorTexDim).rgb;\n #elif defined(dColorType_volume)\n vec3 cgridPos = (uColorGridTransform.w * (position - uColorGridTransform.xyz)) / uColorGridDim;\n vColor.rgb = texture3dFrom2dLinear(tColorGrid, cgridPos, uColorGridDim, uColorTexDim).rgb;\n #elif defined(dColorType_volumeInstance)\n vec3 cgridPos = (uColorGridTransform.w * (vModelPosition - uColorGridTransform.xyz)) / uColorGridDim;\n vColor.rgb = texture3dFrom2dLinear(tColorGrid, cgridPos, uColorGridDim, uColorTexDim).rgb;\n #endif\n\n #ifdef dUsePalette\n vPaletteV = ((vColor.r * 256.0 * 256.0 * 255.0 + vColor.g * 256.0 * 255.0 + vColor.b * 255.0) - 1.0) / 16777215.0;\n #endif\n\n #ifdef dOverpaint\n #if defined(dOverpaintType_instance)\n vOverpaint = readFromTexture(tOverpaint, aInstance, uOverpaintTexDim);\n #elif defined(dOverpaintType_groupInstance)\n vOverpaint = readFromTexture(tOverpaint, aInstance * float(uGroupCount) + group, uOverpaintTexDim);\n #elif defined(dOverpaintType_vertexInstance)\n vOverpaint = readFromTexture(tOverpaint, int(aInstance) * uVertexCount + VertexID, uOverpaintTexDim);\n #elif defined(dOverpaintType_volumeInstance)\n vec3 ogridPos = (uOverpaintGridTransform.w * (vModelPosition - uOverpaintGridTransform.xyz)) / uOverpaintGridDim;\n vOverpaint = texture3dFrom2dLinear(tOverpaintGrid, ogridPos, uOverpaintGridDim, uOverpaintTexDim);\n #endif\n\n // pre-mix to avoid darkening due to empty overpaint\n #ifdef dColorType_uniform\n vOverpaint.rgb = mix(uColor.rgb, vOverpaint.rgb, vOverpaint.a);\n #else\n vOverpaint.rgb = mix(vColor.rgb, vOverpaint.rgb, vOverpaint.a);\n #endif\n vOverpaint *= uOverpaintStrength;\n #endif\n\n #ifdef dSubstance\n #if defined(dSubstanceType_instance)\n vSubstance = readFromTexture(tSubstance, aInstance, uSubstanceTexDim);\n #elif defined(dSubstanceType_groupInstance)\n vSubstance = readFromTexture(tSubstance, aInstance * float(uGroupCount) + group, uSubstanceTexDim);\n #elif defined(dSubstanceType_vertexInstance)\n vSubstance = readFromTexture(tSubstance, int(aInstance) * uVertexCount + VertexID, uSubstanceTexDim);\n #elif defined(dSubstanceType_volumeInstance)\n vec3 sgridPos = (uSubstanceGridTransform.w * (vModelPosition - uSubstanceGridTransform.xyz)) / uSubstanceGridDim;\n vSubstance = texture3dFrom2dLinear(tSubstanceGrid, sgridPos, uSubstanceGridDim, uSubstanceTexDim);\n #endif\n\n // pre-mix to avoid artifacts due to empty substance\n vSubstance.rgb = mix(vec3(uMetalness, uRoughness, uBumpiness), vSubstance.rgb, vSubstance.a);\n vSubstance *= uSubstanceStrength;\n #endif\n#elif defined(dRenderVariant_pick)\n #ifdef requiredDrawBuffers\n vObject = vec4(packIntToRGB(float(uObjectId)), 1.0);\n vInstance = vec4(packIntToRGB(aInstance), 1.0);\n vGroup = vec4(packIntToRGB(group), 1.0);\n #else\n if (uPickType == 1) {\n vColor = vec4(packIntToRGB(float(uObjectId)), 1.0);\n } else if (uPickType == 2) {\n vColor = vec4(packIntToRGB(aInstance), 1.0);\n } else {\n vColor = vec4(packIntToRGB(group), 1.0);\n }\n #endif\n#endif\n\n#ifdef dTransparency\n #if defined(dTransparencyType_instance)\n vTransparency = readFromTexture(tTransparency, aInstance, uTransparencyTexDim).a;\n #elif defined(dTransparencyType_groupInstance)\n vTransparency = readFromTexture(tTransparency, aInstance * float(uGroupCount) + group, uTransparencyTexDim).a;\n #elif defined(dTransparencyType_vertexInstance)\n vTransparency = readFromTexture(tTransparency, int(aInstance) * uVertexCount + VertexID, uTransparencyTexDim).a;\n #elif defined(dTransparencyType_volumeInstance)\n vec3 tgridPos = (uTransparencyGridTransform.w * (vModelPosition - uTransparencyGridTransform.xyz)) / uTransparencyGridDim;\n vTransparency = texture3dFrom2dLinear(tTransparencyGrid, tgridPos, uTransparencyGridDim, uTransparencyTexDim).a;\n #endif\n vTransparency *= uTransparencyStrength;\n#endif\n",assign_group:"\n#ifdef dGeometryType_textureMesh\n float group = unpackRGBToInt(readFromTexture(tGroup, VertexID, uGeoTexDim).rgb);\n#else\n float group = aGroup;\n#endif\n",assign_marker_varying:"\n#if defined(dNeedsMarker)\n #if defined(dMarkerType_instance)\n vMarker = readFromTexture(tMarker, aInstance, uMarkerTexDim).a;\n #elif defined(dMarkerType_groupInstance)\n vMarker = readFromTexture(tMarker, aInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n #endif\n#endif\n",assign_material_color:"\n#if defined(dNeedsMarker)\n float marker = uMarker;\n if (uMarker == -1.0) {\n marker = floor(vMarker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n#endif\n\n#if defined(dRenderVariant_color)\n #if defined(dUsePalette)\n vec4 material = vec4(texture2D(tPalette, vec2(vPaletteV, 0.5)).rgb, uAlpha);\n #elif defined(dColorType_uniform)\n vec4 material = vec4(uColor, uAlpha);\n #elif defined(dColorType_varying)\n vec4 material = vec4(vColor.rgb, uAlpha);\n #endif\n\n // mix material with overpaint\n #if defined(dOverpaint)\n material.rgb = mix(material.rgb, vOverpaint.rgb, vOverpaint.a);\n #endif\n\n float metalness = uMetalness;\n float roughness = uRoughness;\n float bumpiness = uBumpiness;\n #ifdef dSubstance\n metalness = mix(metalness, vSubstance.r, vSubstance.a);\n roughness = mix(roughness, vSubstance.g, vSubstance.a);\n bumpiness = mix(bumpiness, vSubstance.b, vSubstance.a);\n #endif\n#elif defined(dRenderVariant_depth)\n if (fragmentDepth > getDepth(gl_FragCoord.xy / uDrawingBufferSize)) {\n discard;\n }\n\n #ifndef dXrayShaded\n #if defined(dTransparency)\n float dta = 1.0 - vTransparency;\n if (vTransparency < 0.2) dta = 1.0; // hard cutoff looks better\n\n if (uRenderMask == MaskTransparent && uAlpha * dta == 1.0) {\n discard;\n } else if (uRenderMask == MaskOpaque && uAlpha * dta < 1.0) {\n discard;\n }\n #else\n if (uRenderMask == MaskTransparent && uAlpha == 1.0) {\n discard;\n } else if (uRenderMask == MaskOpaque && uAlpha < 1.0) {\n discard;\n }\n #endif\n #else\n if (uRenderMask == MaskOpaque) {\n discard;\n }\n #endif\n\n vec4 material = packDepthToRGBA(fragmentDepth);\n#elif defined(dRenderVariant_marking)\n vec4 material;\n if(uMarkingType == 1) {\n if (marker > 0.0)\n discard;\n #ifdef enabledFragDepth\n material = packDepthToRGBA(gl_FragDepthEXT);\n #else\n material = packDepthToRGBA(gl_FragCoord.z);\n #endif\n } else {\n if (marker == 0.0)\n discard;\n float depthTest = 1.0;\n if (uMarkingDepthTest) {\n depthTest = (fragmentDepth >= getDepthPacked(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0;\n }\n bool isHighlight = intMod(marker, 2.0) > 0.1;\n float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);\n float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));\n if (fogFactor == 1.0)\n discard;\n material = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0 - fogFactor);\n }\n#endif\n\n// apply per-group transparency\n#if defined(dTransparency) && (defined(dRenderVariant_pick) || defined(dRenderVariant_color))\n float ta = 1.0 - vTransparency;\n if (vTransparency < 0.09) ta = 1.0; // hard cutoff looks better\n\n #if defined(dRenderVariant_pick)\n if (ta < uPickingAlphaThreshold)\n discard; // ignore so the element below can be picked\n #elif defined(dRenderVariant_color)\n material.a *= ta;\n\n #if defined(dRenderVariant_colorBlended)\n #if defined(dTransparentBackfaces_off)\n if ((uRenderMask == MaskOpaque && material.a < 1.0) ||\n (uRenderMask == MaskTransparent && material.a == 1.0) ||\n (interior && material.a < 1.0)\n ) {\n discard;\n }\n #elif defined(dTransparentBackfaces_on)\n if ((uRenderMask == MaskOpaque && material.a < 1.0) ||\n (uRenderMask == MaskTransparent && material.a == 1.0)\n ) {\n discard;\n }\n #elif defined(dTransparentBackfaces_opaque)\n if (interior) {\n material.a = 1.0;\n } else if (\n (uRenderMask == MaskOpaque && material.a < 1.0) ||\n (uRenderMask == MaskTransparent && material.a == 1.0)\n ) {\n discard;\n }\n #endif\n #endif\n #endif\n#endif\n",assign_position:"\nmat4 model = uModel * aTransform;\nmat4 modelView = uView * model;\n#ifdef dGeometryType_textureMesh\n vec3 position = readFromTexture(tPosition, VertexID, uGeoTexDim).xyz;\n#else\n vec3 position = aPosition;\n#endif\nvec4 position4 = vec4(position, 1.0);\n// for accessing tColorGrid in vert shader and for clipping in frag shader\nvModelPosition = (model * position4).xyz;\nvec4 mvPosition = modelView * position4;\nvViewPosition = mvPosition.xyz;\ngl_Position = uProjection * mvPosition;\n",assign_size:"\n#if defined(dSizeType_uniform)\n float size = uSize;\n#elif defined(dSizeType_attribute)\n float size = aSize;\n#elif defined(dSizeType_instance)\n float size = unpackRGBToInt(readFromTexture(tSize, aInstance, uSizeTexDim).rgb);\n#elif defined(dSizeType_group)\n float size = unpackRGBToInt(readFromTexture(tSize, group, uSizeTexDim).rgb);\n#elif defined(dSizeType_groupInstance)\n float size = unpackRGBToInt(readFromTexture(tSize, aInstance * float(uGroupCount) + group, uSizeTexDim).rgb);\n#endif\n\n#if defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance)\n size /= 100.0; // NOTE factor also set in TypeScript\n#endif\n\nsize *= uSizeFactor;\n",check_picking_alpha:"\nfloat viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);\nfloat fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));\nfloat alpha = (1.0 - fogFactor) * uAlpha;\n// if not opaque enough ignore so the element below can be picked\nif (uAlpha < uPickingAlphaThreshold || alpha < 0.1) {\n #ifdef dTransparentBackfaces_opaque\n if (!interior) discard;\n #else\n discard;\n #endif\n}\n",clip_instance:"\n#if defined(dClipVariant_instance) && dClipObjectCount != 0\n vec4 mCenter = uModel * aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0);\n if (clipTest(vec4(mCenter.xyz, uInvariantBoundingSphere.w)))\n // move out of [ -w, +w ] to 'discard' in vert shader\n gl_Position.z = 2.0 * gl_Position.w;\n#endif\n",clip_pixel:"\n#if defined(dClipVariant_pixel) && dClipObjectCount != 0\n if (clipTest(vec4(vModelPosition, 0.0)))\n discard;\n#endif\n",color_frag_params:"\nuniform float uMetalness;\nuniform float uRoughness;\nuniform float uBumpiness;\n#ifdef bumpEnabled\n uniform float uBumpFrequency;\n uniform float uBumpAmplitude;\n#endif\n\n#if defined(dRenderVariant_color)\n #if defined(dColorType_uniform)\n uniform vec3 uColor;\n #elif defined(dColorType_varying)\n varying vec4 vColor;\n #endif\n\n #ifdef dUsePalette\n uniform sampler2D tPalette;\n varying float vPaletteV;\n #endif\n\n #ifdef dOverpaint\n varying vec4 vOverpaint;\n #endif\n\n #ifdef dSubstance\n varying vec4 vSubstance;\n #endif\n#elif defined(dRenderVariant_pick)\n #if __VERSION__ == 100 || !defined(dVaryingGroup)\n #ifdef requiredDrawBuffers\n varying vec4 vObject;\n varying vec4 vInstance;\n varying vec4 vGroup;\n #else\n varying vec4 vColor;\n #endif\n #else\n #ifdef requiredDrawBuffers\n flat in vec4 vObject;\n flat in vec4 vInstance;\n flat in vec4 vGroup;\n #else\n flat in vec4 vColor;\n #endif\n #endif\n#endif\n\n#ifdef dTransparency\n varying float vTransparency;\n#endif\n",color_vert_params:"\nuniform float uMetalness;\nuniform float uRoughness;\nuniform float uBumpiness;\n\n#if defined(dRenderVariant_color)\n #if defined(dColorType_uniform)\n uniform vec3 uColor;\n #elif defined(dColorType_attribute)\n varying vec4 vColor;\n attribute vec3 aColor;\n #elif defined(dColorType_texture)\n varying vec4 vColor;\n uniform vec2 uColorTexDim;\n uniform sampler2D tColor;\n #elif defined(dColorType_grid)\n varying vec4 vColor;\n uniform vec2 uColorTexDim;\n uniform vec3 uColorGridDim;\n uniform vec4 uColorGridTransform;\n uniform sampler2D tColorGrid;\n #elif defined(dColorType_direct)\n varying vec4 vColor;\n #endif\n\n #ifdef dUsePalette\n varying float vPaletteV;\n #endif\n\n #ifdef dOverpaint\n #if defined(dOverpaintType_instance) || defined(dOverpaintType_groupInstance) || defined(dOverpaintType_vertexInstance)\n varying vec4 vOverpaint;\n uniform vec2 uOverpaintTexDim;\n uniform sampler2D tOverpaint;\n #elif defined(dOverpaintType_volumeInstance)\n varying vec4 vOverpaint;\n uniform vec2 uOverpaintTexDim;\n uniform vec3 uOverpaintGridDim;\n uniform vec4 uOverpaintGridTransform;\n uniform sampler2D tOverpaintGrid;\n #endif\n uniform float uOverpaintStrength;\n #endif\n\n #ifdef dSubstance\n #if defined(dSubstanceType_instance) || defined(dSubstanceType_groupInstance) || defined(dSubstanceType_vertexInstance)\n varying vec4 vSubstance;\n uniform vec2 uSubstanceTexDim;\n uniform sampler2D tSubstance;\n #elif defined(dSubstanceType_volumeInstance)\n varying vec4 vSubstance;\n uniform vec2 uSubstanceTexDim;\n uniform vec3 uSubstanceGridDim;\n uniform vec4 uSubstanceGridTransform;\n uniform sampler2D tSubstanceGrid;\n #endif\n uniform float uSubstanceStrength;\n #endif\n#elif defined(dRenderVariant_pick)\n #if __VERSION__ == 100 || !defined(dVaryingGroup)\n #ifdef requiredDrawBuffers\n varying vec4 vObject;\n varying vec4 vInstance;\n varying vec4 vGroup;\n #else\n varying vec4 vColor;\n #endif\n #else\n #ifdef requiredDrawBuffers\n flat out vec4 vObject;\n flat out vec4 vInstance;\n flat out vec4 vGroup;\n #else\n flat out vec4 vColor;\n #endif\n #endif\n#endif\n\n#ifdef dTransparency\n #if defined(dTransparencyType_instance) || defined(dTransparencyType_groupInstance) || defined(dTransparencyType_vertexInstance)\n varying float vTransparency;\n uniform vec2 uTransparencyTexDim;\n uniform sampler2D tTransparency;\n #elif defined(dTransparencyType_volumeInstance)\n varying float vTransparency;\n uniform vec2 uTransparencyTexDim;\n uniform vec3 uTransparencyGridDim;\n uniform vec4 uTransparencyGridTransform;\n uniform sampler2D tTransparencyGrid;\n #endif\n uniform float uTransparencyStrength;\n#endif\n",common_clip:"\n#if dClipObjectCount != 0\n vec3 quaternionTransform(const in vec4 q, const in vec3 v) {\n vec3 t = 2.0 * cross(q.xyz, v);\n return v + q.w * t + cross(q.xyz, t);\n }\n\n vec4 computePlane(const in vec3 normal, const in vec3 inPoint) {\n return vec4(normalize(normal), -dot(normal, inPoint));\n }\n\n float planeSD(const in vec4 plane, const in vec3 center) {\n return -dot(plane.xyz, center - plane.xyz * -plane.w);\n }\n\n float sphereSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in vec3 center) {\n return (\n length(quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position) / size) - 1.0\n ) * min(min(size.x, size.y), size.z);\n }\n\n float cubeSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in vec3 center) {\n vec3 d = abs(quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position)) - size;\n return min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0));\n }\n\n float cylinderSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in vec3 center) {\n vec3 t = quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position);\n\n vec2 d = abs(vec2(length(t.xz), t.y)) - size.xy;\n return min(max(d.x, d.y), 0.0) + length(max(d, 0.0));\n }\n\n float infiniteConeSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in vec3 center) {\n vec3 t = quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position);\n\n float q = length(t.xy);\n return dot(size.xy, vec2(q, t.z));\n }\n\n float getSignedDistance(const in vec3 center, const in int type, const in vec3 position, const in vec4 rotation, const in vec3 scale) {\n if (type == 1) {\n vec3 normal = quaternionTransform(rotation, vec3(0.0, 1.0, 0.0));\n vec4 plane = computePlane(normal, position);\n return planeSD(plane, center);\n } else if (type == 2) {\n return sphereSD(position, rotation, scale * 0.5, center);\n } else if (type == 3) {\n return cubeSD(position, rotation, scale * 0.5, center);\n } else if (type == 4) {\n return cylinderSD(position, rotation, scale * 0.5, center);\n } else if (type == 5) {\n return infiniteConeSD(position, rotation, scale * 0.5, center);\n } else {\n return 0.1;\n }\n }\n\n #if __VERSION__ == 100\n // 8-bit\n int bitwiseAnd(in int a, in int b) {\n int d = 128;\n int result = 0;\n for (int i = 0; i < 8; ++i) {\n if (d <= 0) break;\n if (a >= d && b >= d) result += d;\n if (a >= d) a -= d;\n if (b >= d) b -= d;\n d /= 2;\n }\n return result;\n }\n\n bool hasBit(const in int mask, const in int bit) {\n return bitwiseAnd(mask, bit) == 0;\n }\n #else\n bool hasBit(const in int mask, const in int bit) {\n return (mask & bit) == 0;\n }\n #endif\n\n bool clipTest(const in vec4 sphere) {\n // flag is a bit-flag for clip-objects to ignore (note, object ids start at 1 not 0)\n #if defined(dClipping)\n int flag = int(floor(vClipping * 255.0 + 0.5));\n #else\n int flag = 0;\n #endif\n\n #pragma unroll_loop_start\n for (int i = 0; i < dClipObjectCount; ++i) {\n if (flag == 0 || hasBit(flag, UNROLLED_LOOP_INDEX + 1)) {\n // TODO take sphere radius into account?\n bool test = getSignedDistance(sphere.xyz, uClipObjectType[i], uClipObjectPosition[i], uClipObjectRotation[i], uClipObjectScale[i]) <= 0.0;\n if ((!uClipObjectInvert[i] && test) || (uClipObjectInvert[i] && !test)) {\n return true;\n }\n }\n }\n #pragma unroll_loop_end\n return false;\n }\n#endif\n",common_frag_params:'\nuniform int uObjectId;\nuniform int uInstanceCount;\nuniform int uGroupCount;\n\nuniform int uPickType;\nuniform int uMarkingType;\n\nuniform vec4 uCameraPlane;\nuniform vec4 uLod;\n\n#if dClipObjectCount != 0\n uniform int uClipObjectType[dClipObjectCount];\n uniform bool uClipObjectInvert[dClipObjectCount];\n uniform vec3 uClipObjectPosition[dClipObjectCount];\n uniform vec4 uClipObjectRotation[dClipObjectCount];\n uniform vec3 uClipObjectScale[dClipObjectCount];\n\n #if defined(dClipping)\n #if __VERSION__ == 100 || defined(dClippingType_instance) || !defined(dVaryingGroup)\n varying float vClipping;\n #else\n flat in float vClipping;\n #endif\n #endif\n#endif\n\n#if defined(dColorMarker)\n uniform vec3 uHighlightColor;\n uniform vec3 uSelectColor;\n uniform vec3 uDimColor;\n uniform float uHighlightStrength;\n uniform float uSelectStrength;\n uniform float uDimStrength;\n uniform int uMarkerPriority;\n uniform float uMarkerAverage;\n#endif\n\n#if defined(dNeedsMarker)\n uniform float uMarker;\n #if __VERSION__ == 100 || defined(dMarkerType_instance) || !defined(dVaryingGroup)\n varying float vMarker;\n #else\n flat in float vMarker;\n #endif\n#endif\n\n#if defined(dRenderVariant_colorDpoit)\n #define MAX_DPOIT_DEPTH 99999.0 // NOTE constant also set in TypeScript\n uniform sampler2D tDpoitDepth;\n uniform sampler2D tDpoitFrontColor;\n#endif\n\nvarying vec3 vModelPosition;\nvarying vec3 vViewPosition;\n\nuniform vec2 uViewOffset;\n\nuniform float uNear;\nuniform float uFar;\nuniform float uIsOrtho;\n\nuniform bool uFog;\nuniform float uFogNear;\nuniform float uFogFar;\nuniform vec3 uFogColor;\n\nuniform float uAlpha;\nuniform float uPickingAlphaThreshold;\nuniform bool uTransparentBackground;\n\nuniform bool uDoubleSided;\nuniform float uInteriorDarkening;\nuniform bool uInteriorColorFlag;\nuniform vec3 uInteriorColor;\nbool interior;\n\nuniform float uXrayEdgeFalloff;\nuniform float uExposure;\n\nuniform mat4 uProjection;\n\nuniform int uRenderMask;\nuniform bool uMarkingDepthTest;\n\nuniform sampler2D tDepth;\nuniform vec2 uDrawingBufferSize;\n\nfloat getDepthPacked(const in vec2 coords) {\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n}\n\nfloat getDepth(const in vec2 coords) {\n #ifdef depthTextureSupport\n return texture2D(tDepth, coords).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n #endif\n}\n\nfloat calcDepth(const in vec3 pos) {\n vec2 clipZW = pos.z * uProjection[2].zw + uProjection[3].zw;\n return 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\n\n// "Bump Mapping Unparametrized Surfaces on the GPU" Morten S. Mikkelsen\n// https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf\nvec3 perturbNormal(in vec3 position, in vec3 normal, in float height, in float scale) {\n vec3 sigmaS = dFdx(position);\n vec3 sigmaT = dFdy(position);\n\n vec3 r1 = cross(sigmaT, normal);\n vec3 r2 = cross(normal, sigmaS);\n float det = dot(sigmaS, r1);\n\n float bs = dFdx(height);\n float bt = dFdy(height);\n\n vec3 surfGrad = sign(det) * (bs * r1 + bt * r2);\n return normalize(abs(det) * normal - scale * surfGrad);\n}\n\nfloat hash(in float h) {\n return fract(sin(h) * 43758.5453123);\n}\n\nfloat noise(in vec3 x) {\n vec3 p = floor(x);\n vec3 f = fract(x);\n f = f * f * (3.0 - 2.0 * f);\n\n float n = p.x + p.y * 157.0 + 113.0 * p.z;\n return mix(\n mix(mix(hash(n + 0.0), hash(n + 1.0), f.x),\n mix(hash(n + 157.0), hash(n + 158.0), f.x), f.y),\n mix(mix(hash(n + 113.0), hash(n + 114.0), f.x),\n mix(hash(n + 270.0), hash(n + 271.0), f.x), f.y), f.z);\n}\n\nfloat fbm(in vec3 p) {\n float f = 0.0;\n f += 0.5 * noise(p);\n p *= 2.01;\n f += 0.25 * noise(p);\n p *= 2.02;\n f += 0.125 * noise(p);\n\n return f;\n}\n',common_vert_params:"\nuniform mat4 uProjection, uModel, uView;\nuniform vec3 uCameraPosition;\nuniform vec4 uCameraPlane;\n\nuniform int uObjectId;\nuniform int uVertexCount;\nuniform int uInstanceCount;\nuniform int uGroupCount;\nuniform vec4 uInvariantBoundingSphere;\nuniform vec4 uLod;\n\nuniform bool uDoubleSided;\nuniform int uPickType;\n\n#if dClipObjectCount != 0\n uniform int uClipObjectType[dClipObjectCount];\n uniform bool uClipObjectInvert[dClipObjectCount];\n uniform vec3 uClipObjectPosition[dClipObjectCount];\n uniform vec4 uClipObjectRotation[dClipObjectCount];\n uniform vec3 uClipObjectScale[dClipObjectCount];\n\n #if defined(dClipping)\n uniform vec2 uClippingTexDim;\n uniform sampler2D tClipping;\n #if __VERSION__ == 100 || defined(dClippingType_instance) || !defined(dVaryingGroup)\n varying float vClipping;\n #else\n flat out float vClipping;\n #endif\n #endif\n#endif\n\n#if defined(dNeedsMarker)\n uniform float uMarker;\n uniform vec2 uMarkerTexDim;\n uniform sampler2D tMarker;\n #if __VERSION__ == 100 || defined(dMarkerType_instance) || !defined(dVaryingGroup)\n varying float vMarker;\n #else\n flat out float vMarker;\n #endif\n#endif\n\nvarying vec3 vModelPosition;\nvarying vec3 vViewPosition;\n\n#if defined(noNonInstancedActiveAttribs)\n // int() is needed for some Safari versions\n // see https://bugs.webkit.org/show_bug.cgi?id=244152\n #define VertexID int(gl_VertexID)\n#else\n attribute float aVertex;\n #define VertexID int(aVertex)\n#endif\n\n#if defined(enabledMultiDraw)\n #define DrawID gl_DrawID\n#else\n #define DrawID uDrawId\n#endif\n",common:"\n// TODO find a better place for these convenience defines\n\n#if defined(dRenderVariant_colorBlended) || defined(dRenderVariant_colorWboit) || defined(dRenderVariant_colorDpoit)\n #define dRenderVariant_color\n#endif\n\n#if defined(dColorType_instance) || defined(dColorType_group) || defined(dColorType_groupInstance) || defined(dColorType_vertex) || defined(dColorType_vertexInstance)\n #define dColorType_texture\n#endif\n\n#if defined(dColorType_volume) || defined(dColorType_volumeInstance)\n #define dColorType_grid\n#endif\n\n#if defined(dColorType_attribute) || defined(dColorType_texture) || defined(dColorType_grid)\n #define dColorType_varying\n#endif\n\n#if (defined(dRenderVariant_color) && defined(dColorMarker)) || defined(dRenderVariant_marking)\n #define dNeedsMarker\n#endif\n\n#if defined(dXrayShaded_on) || defined(dXrayShaded_inverted)\n #define dXrayShaded\n#endif\n\n#define MaskAll 0\n#define MaskOpaque 1\n#define MaskTransparent 2\n\n//\n\n#define PI 3.14159265\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n\n#define saturate(a) clamp(a, 0.0, 1.0)\n\n#if __VERSION__ == 100\n #define round(x) floor((x) + 0.5)\n#endif\n\nfloat intDiv(const in float a, const in float b) { return float(int(a) / int(b)); }\nvec2 ivec2Div(const in vec2 a, const in vec2 b) { return vec2(ivec2(a) / ivec2(b)); }\nfloat intMod(const in float a, const in float b) { return a - b * float(int(a) / int(b)); }\nint imod(const in int a, const in int b) { return a - b * (a / b); }\n\nfloat pow2(const in float x) { return x * x; }\n\nvec3 packIntToRGB(in float value) {\n value = clamp(round(value), 0.0, 16777216.0 - 1.0) + 1.0;\n vec3 c = vec3(0.0);\n c.b = mod(value, 256.0);\n value = floor(value / 256.0);\n c.g = mod(value, 256.0);\n value = floor(value / 256.0);\n c.r = mod(value, 256.0);\n return c / 255.0;\n}\nfloat unpackRGBToInt(const in vec3 rgb) {\n 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;\n}\n\nvec2 packUnitIntervalToRG(const in float v) {\n vec2 enc;\n enc.xy = vec2(fract(v * 256.0), v);\n enc.y -= enc.x * (1.0 / 256.0);\n enc.xy *= 256.0 / 255.0;\n\n return enc;\n}\n\nfloat unpackRGToUnitInterval(const in vec2 enc) {\n return dot(enc, vec2(255.0 / (256.0 * 256.0), 255.0 / 256.0));\n}\n\nvec3 screenSpaceToViewSpace(const in vec3 ssPos, const in mat4 invProjection) {\n vec4 p = vec4(ssPos * 2.0 - 1.0, 1.0);\n p = invProjection * p;\n return p.xyz / p.w;\n}\n\nconst float PackUpscale = 256.0 / 255.0; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255.0 / 256.0; // 0..1 -> fraction (excluding 1)\nconst vec3 PackFactors = vec3(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0);\nconst vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.0);\nconst float ShiftRight8 = 1.0 / 256.0;\n\nvec4 packDepthToRGBA(const in float v) {\n vec4 r = vec4(fract(v * PackFactors), v);\n r.yzw -= r.xyz * ShiftRight8; // tidy overflow\n return r * PackUpscale;\n}\nfloat unpackRGBAToDepth(const in vec4 v) {\n return dot(v, UnpackFactors);\n}\n\nvec4 sRGBToLinear(const in vec4 c) {\n 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);\n}\nvec4 linearTosRGB(const in vec4 c) {\n 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);\n}\n\nfloat linearizeDepth(const in float depth, const in float near, const in float far) {\n return (2.0 * near) / (far + near - depth * (far - near));\n}\n\nfloat perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {\n return (near * far) / ((far - near) * invClipZ - far);\n}\n\nfloat orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {\n return linearClipZ * (near - far) - near;\n}\n\nfloat depthToViewZ(const in float isOrtho, const in float linearClipZ, const in float near, const in float far) {\n return isOrtho == 1.0 ? orthographicDepthToViewZ(linearClipZ, near, far) : perspectiveDepthToViewZ(linearClipZ, near, far);\n}\n\n#if __VERSION__ == 100\n // transpose\n\n float transpose(const in float m) {\n return m;\n }\n\n mat2 transpose2(const in mat2 m) {\n return mat2(\n m[0][0], m[1][0],\n m[0][1], m[1][1]\n );\n }\n\n mat3 transpose3(const in mat3 m) {\n return mat3(\n m[0][0], m[1][0], m[2][0],\n m[0][1], m[1][1], m[2][1],\n m[0][2], m[1][2], m[2][2]\n );\n }\n\n mat4 transpose4(const in mat4 m) {\n return mat4(\n m[0][0], m[1][0], m[2][0], m[3][0],\n m[0][1], m[1][1], m[2][1], m[3][1],\n m[0][2], m[1][2], m[2][2], m[3][2],\n m[0][3], m[1][3], m[2][3], m[3][3]\n );\n }\n\n // inverse\n\n float inverse(const in float m) {\n return 1.0 / m;\n }\n\n mat2 inverse2(const in mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n }\n\n mat3 inverse3(const in mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n }\n\n mat4 inverse4(const in mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n }\n\n #define isNaN(x) ((x) != (x))\n #define isInf(x) ((x) == (x) + 1.0)\n#else\n #define transpose2(m) transpose(m)\n #define transpose3(m) transpose(m)\n #define transpose4(m) transpose(m)\n\n #define inverse2(m) inverse(m)\n #define inverse3(m) inverse(m)\n #define inverse4(m) inverse(m)\n\n #define isNaN isnan\n #define isInf isinf\n#endif\n",fade_lod:"\nif (uLod.w == 0.0 && (uLod.x != 0.0 || uLod.y != 0.0)) {\n float d = dot(uCameraPlane.xyz, vModelPosition) + uCameraPlane.w;\n float ta = min(\n smoothstep(uLod.x, uLod.x + uLod.z, d),\n 1.0 - smoothstep(uLod.y - uLod.z, uLod.y, d)\n );\n\n #if defined(dRenderVariant_color)\n float at = 0.0;\n\n // shift by view-offset during multi-sample rendering to allow for blending\n vec2 coord = gl_FragCoord.xy + uViewOffset * 0.25;\n\n const mat4 thresholdMatrix = mat4(\n 1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,\n 13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,\n 4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,\n 16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0\n );\n int ci = int(intMod(coord.x, 4.0));\n int ri = int(intMod(coord.y, 4.0));\n #if __VERSION__ == 100\n vec4 i = vec4(float(ci * 4 + ri));\n vec4 v = thresholdMatrix[0] * vec4(equal(i, vec4(0.0, 1.0, 2.0, 3.0))) +\n thresholdMatrix[1] * vec4(equal(i, vec4(4.0, 5.0, 6.0, 7.0))) +\n thresholdMatrix[2] * vec4(equal(i, vec4(8.0, 9.0, 10.0, 11.0))) +\n thresholdMatrix[3] * vec4(equal(i, vec4(12.0, 13.0, 14.0, 15.0)));\n at = v.x + v.y + v.z + v.w;\n #else\n at = thresholdMatrix[ci][ri];\n #endif\n\n if (ta < 0.99 && (ta < 0.01 || ta < at)) {\n discard;\n }\n #else\n if (ta < uPickingAlphaThreshold) {\n discard;\n }\n #endif\n}\n",float_to_rgba:"\n // floatToRgba adapted from https://github.com/equinor/glsl-float-to-rgba\n // MIT License, Copyright (c) 2020 Equinor\n\n float shiftRight (float v, float amt) {\n v = floor(v) + 0.5;\n return floor(v / exp2(amt));\n }\n float shiftLeft (float v, float amt) {\n return floor(v * exp2(amt) + 0.5);\n }\n float maskLast (float v, float bits) {\n return mod(v, shiftLeft(1.0, bits));\n }\n float extractBits (float num, float from, float to) {\n from = floor(from + 0.5); to = floor(to + 0.5);\n return maskLast(shiftRight(num, from), to - from);\n }\n\n vec4 floatToRgba(float texelFloat, bool littleEndian) {\n if (texelFloat == 0.0) return vec4(0.0, 0.0, 0.0, 0.0);\n float sign = texelFloat > 0.0 ? 0.0 : 1.0;\n texelFloat = abs(texelFloat);\n float exponent = floor(log2(texelFloat));\n float biased_exponent = exponent + 127.0;\n float fraction = ((texelFloat / exp2(exponent)) - 1.0) * 8388608.0;\n float t = biased_exponent / 2.0;\n float last_bit_of_biased_exponent = fract(t) * 2.0;\n float remaining_bits_of_biased_exponent = floor(t);\n float byte4 = extractBits(fraction, 0.0, 8.0) / 255.0;\n float byte3 = extractBits(fraction, 8.0, 16.0) / 255.0;\n float byte2 = (last_bit_of_biased_exponent * 128.0 + extractBits(fraction, 16.0, 23.0)) / 255.0;\n float byte1 = (sign * 128.0 + remaining_bits_of_biased_exponent) / 255.0;\n return (\n littleEndian\n ? vec4(byte4, byte3, byte2, byte1)\n : vec4(byte1, byte2, byte3, byte4)\n );\n }\n",light_frag_params:"\n#if dLightCount != 0\n uniform vec3 uLightDirection[dLightCount];\n uniform vec3 uLightColor[dLightCount];\n#endif\nuniform vec3 uAmbientColor;\n\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n float roughness;\n vec3 specularColor;\n float specularF90;\n};\n\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n};\n\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n\nstruct GeometricContext {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n};\n\nvec3 BRDF_Lambert(const in vec3 diffuseColor) {\n return RECIPROCAL_PI * diffuseColor;\n}\n\nvec3 F_Schlick(const in vec3 f0, const in float f90, const in float dotVH) {\n // Original approximation by Christophe Schlick '94\n // float fresnel = pow( 1.0 - dotVH, 5.0 );\n // Optimized variant (presented by Epic at SIGGRAPH '13)\n // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n float fresnel = exp2((-5.55473 * dotVH - 6.98316) * dotVH);\n return f0 * (1.0 - fresnel) + (f90 * fresnel);\n}\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat V_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {\n float a2 = pow2(alpha);\n float gv = dotNL * sqrt(a2 + (1.0 - a2) * pow2(dotNV));\n float gl = dotNV * sqrt(a2 + (1.0 - a2) * pow2(dotNL));\n return 0.5 / max(gv + gl, EPSILON);\n}\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is \"roughness squared\" in Disney\u2019s reparameterization\nfloat D_GGX(const in float alpha, const in float dotNH) {\n float a2 = pow2(alpha);\n float denom = pow2(dotNH) * (a2 - 1.0) + 1.0; // avoid alpha = 0 with dotNH = 1\n return RECIPROCAL_PI * a2 / pow2(denom);\n}\n\n// GGX Distribution, Schlick Fresnel, GGX_SmithCorrelated Visibility\nvec3 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) {\n float alpha = pow2(roughness); // UE4's roughness\n vec3 halfDir = normalize( lightDir + viewDir);\n float dotNL = saturate(dot(normal, lightDir));\n float dotNV = saturate(dot(normal, viewDir));\n float dotNH = saturate(dot(normal, halfDir));\n float dotVH = saturate(dot(viewDir, halfDir));\n vec3 F = F_Schlick(f0, f90, dotVH);\n float V = V_GGX_SmithCorrelated(alpha, dotNL, dotNV);\n float D = D_GGX(alpha, dotNH);\n return F * (V * D);\n}\n\n// Analytical approximation of the DFG LUT, one half of the\n// split-sum approximation used in indirect specular lighting.\n// via 'environmentBRDF' from \"Physically Based Shading on Mobile\"\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile\nvec2 DFGApprox(const in vec3 normal, const in vec3 viewDir, const in float roughness) {\n float dotNV = saturate(dot(normal, viewDir));\n const vec4 c0 = vec4(-1, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y;\n vec2 fab = vec2(-1.04, 1.04) * a004 + r.zw;\n return fab;\n}\n\n// Fdez-Ag\xfcera's \"Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting\"\n// Approximates multiscattering in order to preserve energy.\n// http://www.jcgt.org/published/0008/01/03/\nvoid 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) {\n vec2 fab = DFGApprox(normal, viewDir, roughness);\n vec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = specularColor + (1.0 - specularColor) * 0.047619; // 1/21\n vec3 Fms = FssEss * Favg / (1.0 - Ems * Favg);\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\n\nvoid RE_Direct_Physical(const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n float dotNL = saturate(dot(geometry.normal, directLight.direction));\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directSpecular += irradiance * BRDF_GGX(directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness);\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\n\nvoid RE_IndirectDiffuse_Physical(const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\n\nvoid 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) {\n // Both indirect specular and indirect diffuse light accumulate here\n vec3 singleScattering = vec3(0.0);\n vec3 multiScattering = vec3(0.0);\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n computeMultiscattering(geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering);\n vec3 diffuse = material.diffuseColor * (1.0 - ( singleScattering + multiScattering));\n reflectedLight.indirectSpecular += radiance * singleScattering;\n reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n",matrix_scale:"\nfloat matrixScale(in mat4 m){\n vec4 r = m[0];\n return sqrt(r[0] * r[0] + r[1] * r[1] + r[2] * r[2]);\n}\n",normal_frag_params:"\nvarying vec3 vNormal;\n",read_from_texture:"\nvec4 readFromTexture(const in sampler2D tex, const in float i, const in vec2 dim) {\n float x = intMod(i, dim.x);\n float y = floor(intDiv(i, dim.x));\n vec2 uv = (vec2(x, y) + 0.5) / dim;\n return texture2D(tex, uv);\n}\n\nvec4 readFromTexture(const in sampler2D tex, const in int i, const in vec2 dim) {\n int x = imod(i, int(dim.x));\n int y = i / int(dim.x);\n vec2 uv = (vec2(x, y) + 0.5) / dim;\n return texture2D(tex, uv);\n}\n",rgba_to_float:'\n // rgbaToFloat adapted from https://github.com/ihmeuw/glsl-rgba-to-float\n // BSD 3-Clause License\n //\n // Copyright (c) 2019, Institute for Health Metrics and Evaluation All rights reserved.\n // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n // - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n // - 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.\n // - 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.\n //\n // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,\n // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\n // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n // OF THE POSSIBILITY OF SUCH DAMAGE.\n\n ivec4 floatsToBytes(vec4 inputFloats, bool littleEndian) {\n ivec4 bytes = ivec4(inputFloats * 255.0);\n return (\n littleEndian\n ? bytes.abgr\n : bytes\n );\n }\n\n // Break the four bytes down into an array of 32 bits.\n void bytesToBits(const in ivec4 bytes, out bool bits[32]) {\n for (int channelIndex = 0; channelIndex < 4; ++channelIndex) {\n float acc = float(bytes[channelIndex]);\n for (int indexInByte = 7; indexInByte >= 0; --indexInByte) {\n float powerOfTwo = exp2(float(indexInByte));\n bool bit = acc >= powerOfTwo;\n bits[channelIndex * 8 + (7 - indexInByte)] = bit;\n acc = mod(acc, powerOfTwo);\n }\n }\n }\n\n // Compute the exponent of the 32-bit float.\n float getExponent(bool bits[32]) {\n const int startIndex = 1;\n const int bitStringLength = 8;\n const int endBeforeIndex = startIndex + bitStringLength;\n float acc = 0.0;\n int pow2 = bitStringLength - 1;\n for (int bitIndex = startIndex; bitIndex < endBeforeIndex; ++bitIndex) {\n acc += float(bits[bitIndex]) * exp2(float(pow2--));\n }\n return acc;\n }\n\n // Compute the mantissa of the 32-bit float.\n float getMantissa(bool bits[32], bool subnormal) {\n const int startIndex = 9;\n const int bitStringLength = 23;\n const int endBeforeIndex = startIndex + bitStringLength;\n // Leading/implicit/hidden bit convention:\n // If the number is not subnormal (with exponent 0), we add a leading 1 digit.\n float acc = float(!subnormal) * exp2(float(bitStringLength));\n int pow2 = bitStringLength - 1;\n for (int bitIndex = startIndex; bitIndex < endBeforeIndex; ++bitIndex) {\n acc += float(bits[bitIndex]) * exp2(float(pow2--));\n }\n return acc;\n }\n\n // Parse the float from its 32 bits.\n float bitsToFloat(bool bits[32]) {\n float signBit = float(bits[0]) * -2.0 + 1.0;\n float exponent = getExponent(bits);\n bool subnormal = abs(exponent - 0.0) < 0.01;\n float mantissa = getMantissa(bits, subnormal);\n float exponentBias = 127.0;\n return signBit * mantissa * exp2(exponent - exponentBias - 23.0);\n }\n\n float rgbaToFloat(vec4 texelRGBA, bool littleEndian) {\n ivec4 rgbaBytes = floatsToBytes(texelRGBA, littleEndian);\n bool bits[32];\n bytesToBits(rgbaBytes, bits);\n return bitsToFloat(bits);\n }\n',size_vert_params:"\n#if defined(dSizeType_uniform)\n uniform float uSize;\n#elif defined(dSizeType_attribute)\n attribute float aSize;\n#elif defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance)\n uniform vec2 uSizeTexDim;\n uniform sampler2D tSize;\n#endif\n\nuniform float uSizeFactor;\n",texture3d_from_1d_trilinear:"\nvec4 texture3dFrom1dTrilinear(const in sampler2D tex, const in vec3 pos, const in vec3 gridDim, const in vec2 texDim, const in float offset) {\n float gdYZ = gridDim.z * gridDim.y;\n float gdZ = gridDim.z;\n vec3 p0 = floor(pos * gridDim);\n vec3 p1 = ceil(pos * gridDim);\n vec3 pd = (pos * gridDim - p0) / (p1 - p0);\n vec4 s000 = readFromTexture(tex, offset + p0.z + p0.y * gdZ + p0.x * gdYZ, texDim);\n vec4 s100 = readFromTexture(tex, offset + p0.z + p0.y * gdZ + p1.x * gdYZ, texDim);\n vec4 s001 = readFromTexture(tex, offset + p1.z + p0.y * gdZ + p0.x * gdYZ, texDim);\n vec4 s101 = readFromTexture(tex, offset + p1.z + p0.y * gdZ + p1.x * gdYZ, texDim);\n vec4 s010 = readFromTexture(tex, offset + p0.z + p1.y * gdZ + p0.x * gdYZ, texDim);\n vec4 s110 = readFromTexture(tex, offset + p0.z + p1.y * gdZ + p1.x * gdYZ, texDim);\n vec4 s011 = readFromTexture(tex, offset + p1.z + p1.y * gdZ + p0.x * gdYZ, texDim);\n vec4 s111 = readFromTexture(tex, offset + p1.z + p1.y * gdZ + p1.x * gdYZ, texDim);\n vec4 s00 = mix(s000, s100, pd.x);\n vec4 s01 = mix(s001, s101, pd.x);\n vec4 s10 = mix(s010, s110, pd.x);\n vec4 s11 = mix(s011, s111, pd.x);\n vec4 s0 = mix(s00, s10, pd.y);\n vec4 s1 = mix(s01, s11, pd.y);\n return mix(s0, s1, pd.z);\n}\n",texture3d_from_2d_linear:"\nvec4 texture3dFrom2dLinear(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {\n float zSlice0 = floor(pos.z * gridDim.z);\n float column0 = intMod(zSlice0 * gridDim.x, texDim.x) / gridDim.x;\n float row0 = floor(intDiv(zSlice0 * gridDim.x, texDim.x));\n vec2 coord0 = (vec2(column0 * gridDim.x, row0 * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;\n vec4 color0 = texture2D(tex, coord0);\n\n float zSlice1 = zSlice0 + 1.0;\n float column1 = intMod(zSlice1 * gridDim.x, texDim.x) / gridDim.x;\n float row1 = floor(intDiv(zSlice1 * gridDim.x, texDim.x));\n vec2 coord1 = (vec2(column1 * gridDim.x, row1 * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;\n vec4 color1 = texture2D(tex, coord1);\n\n float delta0 = abs((pos.z * gridDim.z) - zSlice0);\n return mix(color0, color1, delta0);\n}\n",texture3d_from_2d_nearest:"\nvec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {\n float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice\n float column = intMod(zSlice * gridDim.x, texDim.x) / gridDim.x;\n float row = floor(intDiv(zSlice * gridDim.x, texDim.x));\n vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;\n return texture2D(tex, coord);\n}\n",wboit_write:"\n#if defined(dRenderVariant_colorWboit)\n if (uRenderMask == MaskOpaque) {\n if (preFogAlpha < 1.0) {\n discard;\n }\n } else if (uRenderMask == MaskTransparent) {\n if (preFogAlpha != 1.0 && fragmentDepth < getDepth(gl_FragCoord.xy / uDrawingBufferSize)) {\n #ifdef dTransparentBackfaces_off\n if (interior) discard;\n #endif\n float alpha = gl_FragColor.a;\n float wboitWeight = alpha * clamp(pow(1.0 - fragmentDepth, 2.0), 0.01, 1.0);\n gl_FragColor = vec4(gl_FragColor.rgb * alpha * wboitWeight, alpha);\n // extra alpha is to handle pre-multiplied alpha\n #ifndef dGeometryType_directVolume\n gl_FragData[1] = vec4((uTransparentBackground ? alpha : 1.0) * alpha * wboitWeight);\n #else\n gl_FragData[1] = vec4(alpha * alpha * wboitWeight);\n #endif\n } else {\n discard;\n }\n }\n#endif\n",dpoit_write:"\n#if defined(dRenderVariant_colorDpoit)\n if (uRenderMask == MaskOpaque) {\n if (preFogAlpha < 1.0) {\n discard;\n }\n } else if (uRenderMask == MaskTransparent) {\n vec2 coords = gl_FragCoord.xy / uDrawingBufferSize;\n if (preFogAlpha != 1.0 && fragmentDepth < getDepth(coords)) {\n #ifdef dTransparentBackfaces_off\n if (interior) discard;\n #endif\n\n // adapted from https://github.com/tsherif/webgl2examples\n // The MIT License, Copyright 2017 Tarek Sherif, Shuai Shao\n\n vec2 lastDepth = texture2D(tDpoitDepth, coords).rg;\n vec4 lastFrontColor = texture2D(tDpoitFrontColor, coords);\n\n vec4 fragColor = gl_FragColor;\n\n // depth value always increases\n // so we can use MAX blend equation\n gl_FragData[2].rg = vec2(-MAX_DPOIT_DEPTH);\n\n // front color always increases\n // so we can use MAX blend equation\n gl_FragColor = lastFrontColor;\n\n // back color is separately blend afterwards each pass\n gl_FragData[1] = vec4(0.0);\n\n float nearestDepth = -lastDepth.x;\n float furthestDepth = lastDepth.y;\n float alphaMultiplier = 1.0 - lastFrontColor.a;\n\n if (fragmentDepth < nearestDepth || fragmentDepth > furthestDepth) {\n // Skip this depth since it's been peeled.\n return;\n }\n\n if (fragmentDepth > nearestDepth && fragmentDepth < furthestDepth) {\n // This needs to be peeled.\n // The ones remaining after MAX blended for\n // all need-to-peel will be peeled next pass.\n gl_FragData[2].rg = vec2(-fragmentDepth, fragmentDepth);\n return;\n }\n\n // write to back and front color buffer\n if (fragmentDepth == nearestDepth) {\n gl_FragColor.rgb += fragColor.rgb * fragColor.a * alphaMultiplier;\n gl_FragColor.a = 1.0 - alphaMultiplier * (1.0 - fragColor.a);\n } else {\n gl_FragData[1] += fragColor;\n }\n\n } else {\n discard;\n }\n }\n#endif\n"},sGe=/^(?!\/\/)\s*#include\s+(\S+)/gm,aGe=/#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,cGe=/[ \t]*\/\/.*\n/g,uGe=/[ \t]*\/\*[\s\S]*?\*\//g,lGe=/\n{2,}/g;function Sre(e){return e.replace(sGe,(t,n)=>{const r=oGe[n];if(!r)throw new Error(`empty chunk, '${n}'`);return r}).trim().replace(cGe,"\n").replace(uGe,"\n").replace(lGe,"\n")}function fGe(e,t,n,r){let i="";for(let o=parseInt(t);o radius) discard;\n #elif defined(dPointStyle_fuzzy)\n float dist = distance(gl_PointCoord, center);\n float fuzzyAlpha = 1.0 - smoothstep(0.0, radius, dist);\n if (fuzzyAlpha < 0.0001) discard;\n #endif\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #ifdef requiredDrawBuffers\n gl_FragColor = vObject;\n gl_FragData[1] = vInstance;\n gl_FragData[2] = vGroup;\n gl_FragData[3] = packDepthToRGBA(fragmentDepth);\n #else\n gl_FragColor = vColor;\n #endif\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n gl_FragColor = material;\n\n #if defined(dPointStyle_fuzzy)\n gl_FragColor.a *= fuzzyAlpha;\n #endif\n\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{drawBuffers:"optional"},{},hD),mGe=Br("spheres","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include size_vert_params\n#include common_clip\n\nuniform mat4 uModelView;\nuniform mat4 uInvProjection;\nuniform float uIsOrtho;\n\nuniform vec2 uTexDim;\nuniform sampler2D tPositionGroup;\n\nattribute mat4 aTransform;\nattribute float aInstance;\n\nvarying float vRadius;\nvarying vec3 vPoint;\nvarying vec3 vPointViewPosition;\n\n#include matrix_scale\n\n/**\n * Bounding rectangle of a clipped, perspective-projected 3D Sphere.\n * Michael Mara, Morgan McGuire. 2013\n *\n * Specialization by Arseny Kapoulkine, MIT License Copyright (c) 2018\n * https://github.com/zeux/niagara\n */\nvoid sphereProjection(const in vec3 p, const in float r, const in vec2 mapping) {\n vec3 pr = p * r;\n float pzr2 = p.z * p.z - r * r;\n\n float vx = sqrt(p.x * p.x + pzr2);\n float minx = ((vx * p.x - pr.z) / (vx * p.z + pr.x)) * uProjection[0][0];\n float maxx = ((vx * p.x + pr.z) / (vx * p.z - pr.x)) * uProjection[0][0];\n\n float vy = sqrt(p.y * p.y + pzr2);\n float miny = ((vy * p.y - pr.z) / (vy * p.z + pr.y)) * uProjection[1][1];\n float maxy = ((vy * p.y + pr.z) / (vy * p.z - pr.y)) * uProjection[1][1];\n\n gl_Position.xy = vec2(maxx + minx, maxy + miny) * -0.5;\n gl_Position.xy -= mapping * vec2(maxx - minx, maxy - miny) * 0.5;\n gl_Position.xy *= gl_Position.w;\n}\n\nvoid main(void){\n vec2 mapping = vec2(1.0, 1.0); // vertices 2 and 5\n #if __VERSION__ == 100\n int m = imod(VertexID, 6);\n #else\n int m = VertexID % 6;\n #endif\n if (m == 0) {\n mapping = vec2(-1.0, 1.0);\n } else if (m == 1 || m == 3) {\n mapping = vec2(-1.0, -1.0);\n } else if (m == 4) {\n mapping = vec2(1.0, -1.0);\n }\n\n vec4 positionGroup = readFromTexture(tPositionGroup, VertexID / 6, uTexDim);\n vec3 position = positionGroup.rgb;\n float group = positionGroup.a;\n\n #include assign_color_varying\n #include assign_marker_varying\n #include assign_clipping_varying\n #include assign_size\n\n vRadius = size * matrixScale(uModelView);\n\n vec4 position4 = vec4(position, 1.0);\n vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader\n\n float d;\n if (uLod.w != 0.0 && (uLod.x != 0.0 || uLod.y != 0.0)) {\n d = dot(uCameraPlane.xyz, vModelPosition) + uCameraPlane.w;\n float f = min(\n smoothstep(uLod.x, uLod.x + uLod.z, d),\n 1.0 - smoothstep(uLod.y - uLod.z, uLod.y, d)\n ) * uLod.w;\n vRadius *= f;\n }\n\n vec4 mvPosition = uModelView * aTransform * position4;\n\n #ifdef dApproximate\n vec4 mvCorner = vec4(mvPosition.xyz, 1.0);\n mvCorner.xy += mapping * vRadius;\n gl_Position = uProjection * mvCorner;\n #else\n if (uIsOrtho == 1.0) {\n vec4 mvCorner = vec4(mvPosition.xyz, 1.0);\n mvCorner.xy += mapping * vRadius;\n gl_Position = uProjection * mvCorner;\n } else {\n gl_Position = uProjection * vec4(mvPosition.xyz, 1.0);\n sphereProjection(mvPosition.xyz, vRadius, mapping);\n }\n #endif\n\n vec4 vPoint4 = uInvProjection * gl_Position;\n vPoint = vPoint4.xyz / vPoint4.w;\n vPointViewPosition = -mvPosition.xyz / mvPosition.w;\n\n if (gl_Position.z < -gl_Position.w) {\n mvPosition.z -= 2.0 * vRadius; // avoid clipping\n gl_Position.z = (uProjection * vec4(mvPosition.xyz, 1.0)).z;\n }\n\n if (uLod.w != 0.0 && (uLod.x != 0.0 || uLod.y != 0.0)) {\n if (d < uLod.x || d > uLod.y) {\n // move out of [ -w, +w ] to 'discard' in vert shader\n gl_Position.z = 2.0 * gl_Position.w;\n }\n }\n\n #if defined(dClipPrimitive) && !defined(dClipVariant_instance) && dClipObjectCount != 0\n if (clipTest(vec4(vModelPosition.xyz, 0.0))) {\n // move out of [ -w, +w ] to 'discard' in vert shader\n gl_Position.z = 2.0 * gl_Position.w;\n }\n #else\n #include clip_instance\n #endif\n}\n","\nprecision highp float;\nprecision highp int;\n\n#define bumpEnabled\n\n#include common\n#include common_frag_params\n#include color_frag_params\n#include light_frag_params\n#include common_clip\n\nuniform mat4 uInvView;\nuniform float uAlphaThickness;\n\nvarying float vRadius;\nvarying vec3 vPoint;\nvarying vec3 vPointViewPosition;\n\n#ifdef dSolidInterior\n const bool solidInterior = true;\n#else\n const bool solidInterior = false;\n#endif\n\nbool SphereImpostor(out vec3 modelPos, out vec3 cameraPos, out vec3 cameraNormal, out bool interior, out float fragmentDepth){\n vec3 cameraSpherePos = -vPointViewPosition;\n\n vec3 rayOrigin = mix(vec3(0.0, 0.0, 0.0), vPoint, uIsOrtho);\n vec3 rayDirection = mix(normalize(vPoint), vec3(0.0, 0.0, 1.0), uIsOrtho);\n vec3 cameraSphereDir = mix(cameraSpherePos, rayOrigin - cameraSpherePos, uIsOrtho);\n\n float B = dot(rayDirection, cameraSphereDir);\n float det = B * B + vRadius * vRadius - dot(cameraSphereDir, cameraSphereDir);\n\n if (det < 0.0) return false;\n\n float sqrtDet = sqrt(det);\n float posT = mix(B + sqrtDet, B - sqrtDet, uIsOrtho);\n float negT = mix(B - sqrtDet, B + sqrtDet, uIsOrtho);\n\n cameraPos = rayDirection * negT + rayOrigin;\n modelPos = (uInvView * vec4(cameraPos, 1.0)).xyz;\n fragmentDepth = calcDepth(cameraPos);\n\n bool objectClipped = false;\n\n #if !defined(dClipPrimitive) && defined(dClipVariant_pixel) && dClipObjectCount != 0\n if (clipTest(vec4(modelPos, 0.0))) {\n objectClipped = true;\n fragmentDepth = -1.0;\n }\n #endif\n\n if (fragmentDepth > 0.0) {\n cameraNormal = normalize(cameraPos - cameraSpherePos);\n interior = false;\n return true;\n } else if (uDoubleSided || solidInterior) {\n cameraPos = rayDirection * posT + rayOrigin;\n modelPos = (uInvView * vec4(cameraPos, 1.0)).xyz;\n fragmentDepth = calcDepth(cameraPos);\n cameraNormal = -normalize(cameraPos - cameraSpherePos);\n interior = true;\n if (fragmentDepth > 0.0) {\n #ifdef dSolidInterior\n if (!objectClipped) {\n fragmentDepth = 0.0 + (0.0000001 / vRadius);\n cameraNormal = -mix(normalize(vPoint), vec3(0.0, 0.0, 1.0), uIsOrtho);\n }\n #endif\n return true;\n }\n }\n\n return false;\n}\n\nvoid main(void){\n vec3 cameraNormal;\n float fragmentDepth;\n\n #ifdef dApproximate\n vec3 pointDir = -vPointViewPosition - vPoint;\n if (dot(pointDir, pointDir) > vRadius * vRadius) discard;\n vec3 vViewPosition = -vPointViewPosition;\n fragmentDepth = gl_FragCoord.z;\n #if !defined(dIgnoreLight) || defined(dXrayShaded)\n pointDir.z -= cos(length(pointDir) / vRadius);\n cameraNormal = -normalize(pointDir / vRadius);\n #endif\n interior = false;\n #else\n vec3 modelPos;\n vec3 cameraPos;\n bool hit = SphereImpostor(modelPos, cameraPos, cameraNormal, interior, fragmentDepth);\n if (!hit) discard;\n\n if (fragmentDepth < 0.0) discard;\n if (fragmentDepth > 1.0) discard;\n\n gl_FragDepthEXT = fragmentDepth;\n\n vec3 vModelPosition = modelPos;\n vec3 vViewPosition = cameraPos;\n #endif\n\n #include fade_lod\n #if !defined(dClipPrimitive) && defined(dClipVariant_pixel) && dClipObjectCount != 0\n #include clip_pixel\n #endif\n #include assign_material_color\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #ifdef requiredDrawBuffers\n gl_FragColor = vObject;\n gl_FragData[1] = vInstance;\n gl_FragData[2] = vGroup;\n gl_FragData[3] = packDepthToRGBA(fragmentDepth);\n #else\n gl_FragColor = vColor;\n #endif\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n vec3 normal = -cameraNormal;\n #include apply_light_color\n\n if (uRenderMask == MaskTransparent && uAlphaThickness > 0.0) {\n gl_FragColor.a *= min(1.0, vRadius / uAlphaThickness);\n }\n\n #include apply_interior_color\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{fragDepth:"required",drawBuffers:"optional"},{},lS),gGe=Br("cylinders","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include size_vert_params\n#include common_clip\n\nuniform mat4 uModelView;\n\nattribute mat4 aTransform;\nattribute float aInstance;\nattribute float aGroup;\n\nattribute vec3 aMapping;\nattribute vec3 aStart;\nattribute vec3 aEnd;\nattribute float aScale;\nattribute float aCap;\nattribute float aColorMode;\n\nvarying mat4 vTransform;\nvarying vec3 vStart;\nvarying vec3 vEnd;\nvarying float vSize;\nvarying float vCap;\n\nuniform float uIsOrtho;\nuniform vec3 uCameraDir;\n\nvoid main() {\n #include assign_group\n #include assign_color_varying\n #include assign_marker_varying\n #include assign_clipping_varying\n #include assign_size\n\n mat4 modelTransform = uModel * aTransform;\n\n vTransform = aTransform;\n vStart = (modelTransform * vec4(aStart, 1.0)).xyz;\n vEnd = (modelTransform * vec4(aEnd, 1.0)).xyz;\n vSize = size * aScale;\n vCap = aCap;\n\n vModelPosition = (vStart + vEnd) * 0.5;\n vec3 camDir = -mix(normalize(vModelPosition - uCameraPosition), uCameraDir, uIsOrtho);\n vec3 dir = vEnd - vStart;\n float f = aMapping.x > 0.0 ? 1.0 : 0.0;\n // ensure cylinder 'dir' is pointing towards the camera\n if(dot(camDir, dir) < 0.0) {\n dir = -dir;\n f = 1.0 - f;\n }\n\n vec3 left = cross(camDir, dir);\n vec3 up = cross(left, dir);\n left = vSize * normalize(left);\n up = vSize * normalize(up);\n\n // move vertex in object-space from center to corner\n vModelPosition += aMapping.x * dir + aMapping.y * left + aMapping.z * up;\n\n vec4 mvPosition = uView * vec4(vModelPosition, 1.0);\n vViewPosition = mvPosition.xyz;\n gl_Position = uProjection * mvPosition;\n\n if (gl_Position.z < -gl_Position.w) {\n mvPosition.z -= 2.0 * (length(vEnd - vStart) + vSize); // avoid clipping\n gl_Position.z = (uProjection * mvPosition).z;\n }\n\n #if defined(dDualColor) && defined(dRenderVariant_color) && (defined(dColorType_group) || defined(dColorType_groupInstance))\n // dual-color mixing\n // - for aColorMode between 0 and 1 use aColorMode to interpolate\n // - for aColorMode == 2 do nothing, i.e., use vColor\n // - for aColorMode == 3 use position on cylinder axis to interpolate\n if (aColorMode <= 1.0){\n vColor.rgb = mix(vColor.rgb, color2.rgb, aColorMode);\n } else if (aColorMode == 3.0) {\n vColor.rgb = mix(vColor.rgb, color2.rgb, mix(-0.25, 1.25, f / 1.5));\n }\n #endif\n\n #include clip_instance\n}\n","\nprecision highp float;\nprecision highp int;\n\n#define bumpEnabled\n\nuniform mat4 uView;\n\nvarying mat4 vTransform;\nvarying vec3 vStart;\nvarying vec3 vEnd;\nvarying float vSize;\nvarying float vCap;\n\nuniform vec3 uCameraDir;\nuniform vec3 uCameraPosition;\nuniform mat4 uInvView;\n\n#include common\n#include common_frag_params\n#include color_frag_params\n#include light_frag_params\n#include common_clip\n\n#ifdef dSolidInterior\n const bool solidInterior = true;\n#else\n const bool solidInterior = false;\n#endif\n\n// adapted from https://www.shadertoy.com/view/4lcSRn\n// The MIT License, Copyright 2016 Inigo Quilez\nbool CylinderImpostor(\n in vec3 rayOrigin, in vec3 rayDir,\n in vec3 start, in vec3 end, in float radius,\n out vec3 cameraNormal, out bool interior,\n out vec3 modelPosition, out vec3 viewPosition, out float fragmentDepth\n){\n vec3 ba = end - start;\n vec3 oc = rayOrigin - start;\n\n float baba = dot(ba, ba);\n float bard = dot(ba, rayDir);\n float baoc = dot(ba, oc);\n\n float k2 = baba - bard * bard;\n float k1 = baba * dot(oc, rayDir) - baoc * bard;\n float k0 = baba * dot(oc, oc) - baoc * baoc - radius * radius * baba;\n\n float h = k1 * k1 - k2 * k0;\n if (h < 0.0) return false;\n\n bool topCap = (vCap > 0.9 && vCap < 1.1) || vCap >= 2.9;\n bool bottomCap = (vCap > 1.9 && vCap < 2.1) || vCap >= 2.9;\n\n #ifdef dSolidInterior\n bool topInterior = !topCap;\n bool bottomInterior = !bottomCap;\n topCap = true;\n bottomCap = true;\n #else\n bool topInterior = false;\n bool bottomInterior = false;\n #endif\n\n bool clipped = false;\n bool objectClipped = false;\n\n // body outside\n h = sqrt(h);\n float t = (-k1 - h) / k2;\n float y = baoc + t * bard;\n if (y > 0.0 && y < baba) {\n interior = false;\n cameraNormal = (oc + t * rayDir - ba * y / baba) / radius;\n modelPosition = rayOrigin + t * rayDir;\n viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;\n fragmentDepth = calcDepth(viewPosition);\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n if (clipTest(vec4(modelPosition, 0.0))) {\n objectClipped = true;\n fragmentDepth = -1.0;\n #ifdef dSolidInterior\n topCap = !topInterior;\n bottomCap = !bottomInterior;\n #endif\n }\n #endif\n if (fragmentDepth > 0.0) return true;\n clipped = true;\n }\n\n if (!clipped) {\n if (topCap && y < 0.0) {\n // top cap\n t = -baoc / bard;\n if (abs(k1 + k2 * t) < h) {\n interior = topInterior;\n cameraNormal = -ba / baba;\n modelPosition = rayOrigin + t * rayDir;\n viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;\n fragmentDepth = calcDepth(viewPosition);\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n if (clipTest(vec4(modelPosition, 0.0))) {\n objectClipped = true;\n fragmentDepth = -1.0;\n #ifdef dSolidInterior\n topCap = !topInterior;\n bottomCap = !bottomInterior;\n #endif\n }\n #endif\n if (fragmentDepth > 0.0) {\n #ifdef dSolidInterior\n if (interior) cameraNormal = -rayDir;\n #endif\n return true;\n }\n }\n } else if (bottomCap && y >= 0.0) {\n // bottom cap\n t = (baba - baoc) / bard;\n if (abs(k1 + k2 * t) < h) {\n interior = bottomInterior;\n cameraNormal = ba / baba;\n modelPosition = rayOrigin + t * rayDir;\n viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;\n fragmentDepth = calcDepth(viewPosition);\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n if (clipTest(vec4(modelPosition, 0.0))) {\n objectClipped = true;\n fragmentDepth = -1.0;\n #ifdef dSolidInterior\n topCap = !topInterior;\n bottomCap = !bottomInterior;\n #endif\n }\n #endif\n if (fragmentDepth > 0.0) {\n #ifdef dSolidInterior\n if (interior) cameraNormal = -rayDir;\n #endif\n return true;\n }\n }\n }\n }\n\n if (uDoubleSided || solidInterior) {\n // body inside\n h = -h;\n t = (-k1 - h) / k2;\n y = baoc + t * bard;\n if (y > 0.0 && y < baba) {\n interior = true;\n cameraNormal = -(oc + t * rayDir - ba * y / baba) / radius;\n modelPosition = rayOrigin + t * rayDir;\n viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;\n fragmentDepth = calcDepth(viewPosition);\n if (fragmentDepth > 0.0) {\n #ifdef dSolidInterior\n if (!objectClipped) {\n fragmentDepth = 0.0 + (0.0000002 / vSize);\n cameraNormal = -rayDir;\n }\n #endif\n return true;\n }\n }\n\n if (topCap && y < 0.0) {\n // top cap\n t = -baoc / bard;\n if (abs(k1 + k2 * t) < -h) {\n interior = true;\n cameraNormal = ba / baba;\n modelPosition = rayOrigin + t * rayDir;\n viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;\n fragmentDepth = calcDepth(viewPosition);\n if (fragmentDepth > 0.0) {\n #ifdef dSolidInterior\n if (!objectClipped) {\n fragmentDepth = 0.0 + (0.0000002 / vSize);\n cameraNormal = -rayDir;\n }\n #endif\n return true;\n }\n }\n } else if (bottomCap && y >= 0.0) {\n // bottom cap\n t = (baba - baoc) / bard;\n if (abs(k1 + k2 * t) < -h) {\n interior = true;\n cameraNormal = -ba / baba;\n modelPosition = rayOrigin + t * rayDir;\n viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;\n fragmentDepth = calcDepth(viewPosition);\n if (fragmentDepth > 0.0) {\n #ifdef dSolidInterior\n if (!objectClipped) {\n fragmentDepth = 0.0 + (0.0000002 / vSize);\n cameraNormal = -rayDir;\n }\n #endif\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\nvoid main() {\n vec3 rayOrigin = vModelPosition;\n vec3 rayDir = mix(normalize(vModelPosition - uCameraPosition), uCameraDir, uIsOrtho);\n\n vec3 cameraNormal;\n vec3 modelPosition;\n vec3 viewPosition;\n float fragmentDepth;\n bool hit = CylinderImpostor(rayOrigin, rayDir, vStart, vEnd, vSize, cameraNormal, interior, modelPosition, viewPosition, fragmentDepth);\n if (!hit) discard;\n\n if (fragmentDepth < 0.0) discard;\n if (fragmentDepth > 1.0) discard;\n\n gl_FragDepthEXT = fragmentDepth;\n\n vec3 vViewPosition = viewPosition;\n vec3 vModelPosition = modelPosition;\n\n #include fade_lod\n #include clip_pixel\n #include assign_material_color\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #ifdef requiredDrawBuffers\n gl_FragColor = vObject;\n gl_FragData[1] = vInstance;\n gl_FragData[2] = vGroup;\n gl_FragData[3] = packDepthToRGBA(fragmentDepth);\n #else\n gl_FragColor = vColor;\n #endif\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n mat3 normalMatrix = transpose3(inverse3(mat3(uView)));\n vec3 normal = normalize(normalMatrix * -normalize(cameraNormal));\n #include apply_light_color\n\n #include apply_interior_color\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{fragDepth:"required",drawBuffers:"optional"},{},lS),yGe=Br("text","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include size_vert_params\n#include common_clip\n\nuniform mat4 uModelView;\n\nattribute vec3 aPosition;\nattribute vec2 aMapping;\nattribute float aDepth;\nattribute vec2 aTexCoord;\nattribute mat4 aTransform;\nattribute float aInstance;\nattribute float aGroup;\n\nuniform float uOffsetX;\nuniform float uOffsetY;\nuniform float uOffsetZ;\n\nuniform float uIsOrtho;\nuniform float uPixelRatio;\nuniform vec4 uViewport;\n\nvarying vec2 vTexCoord;\n\n#include matrix_scale\n\nvoid main(void){\n #include assign_group\n #include assign_color_varying\n #include assign_marker_varying\n #include assign_clipping_varying\n #include assign_size\n\n vTexCoord = aTexCoord;\n\n float scale = matrixScale(uModelView);\n\n float offsetX = uOffsetX * scale;\n float offsetY = uOffsetY * scale;\n float offsetZ = (uOffsetZ + aDepth * 0.95) * scale;\n\n vec4 position4 = vec4(aPosition, 1.0);\n vec4 mvPosition = uModelView * aTransform * position4;\n\n vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader\n\n // TODO\n // #ifdef FIXED_SIZE\n // if (ortho) {\n // scale /= pixelRatio * ((uViewport.w / 2.0) / -uCameraPosition.z) * 0.1;\n // } else {\n // scale /= pixelRatio * ((uViewport.w / 2.0) / -mvPosition.z) * 0.1;\n // }\n // #endif\n\n vec4 mvCorner = vec4(mvPosition.xyz, 1.0);\n\n if (vTexCoord.x == 10.0) { // indicates background plane\n // move a bit to the back, taking distance to camera into account to avoid z-fighting\n offsetZ -= 0.001 * distance(uCameraPosition, (uProjection * mvCorner).xyz);\n }\n\n mvCorner.xy += aMapping * size * scale;\n mvCorner.x += offsetX;\n mvCorner.y += offsetY;\n\n if (uIsOrtho == 1.0) {\n mvCorner.z += offsetZ;\n } else {\n mvCorner.xyz += normalize(-mvCorner.xyz) * offsetZ;\n }\n\n gl_Position = uProjection * mvCorner;\n\n vViewPosition = -mvCorner.xyz;\n\n #include clip_instance\n}\n","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include common_frag_params\n#include color_frag_params\n#include common_clip\n\nuniform sampler2D tFont;\n\nuniform vec3 uBorderColor;\nuniform float uBorderWidth;\nuniform vec3 uBackgroundColor;\nuniform float uBackgroundOpacity;\n\nvarying vec2 vTexCoord;\n\nconst float smoothness = 32.0;\nconst float gamma = 2.2;\n\nvoid main2(){\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n}\n\nvoid main(){\n #include fade_lod\n #include clip_pixel\n\n float fragmentDepth = gl_FragCoord.z;\n #include assign_material_color\n\n if (vTexCoord.x > 1.0) {\n #if defined(dRenderVariant_color)\n material = vec4(uBackgroundColor, uBackgroundOpacity * material.a);\n #endif\n } else {\n // retrieve signed distance\n float sdf = texture2D(tFont, vTexCoord).a + uBorderWidth;\n\n // perform adaptive anti-aliasing of the edges\n float w = clamp(smoothness * (abs(dFdx(vTexCoord.x)) + abs(dFdy(vTexCoord.y))), 0.0, 0.5);\n float a = smoothstep(0.5 - w, 0.5 + w, sdf);\n\n // gamma correction for linear attenuation\n a = pow(a, 1.0 / gamma);\n\n if (a < 0.5) discard;\n\n #if defined(dRenderVariant_color)\n material.a *= a;\n\n // add border\n float t = 0.5 + uBorderWidth;\n if (uBorderWidth > 0.0 && sdf < t) {\n material.xyz = mix(uBorderColor, material.xyz, smoothstep(t - w, t, sdf));\n }\n #endif\n }\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #ifdef requiredDrawBuffers\n gl_FragColor = vObject;\n gl_FragData[1] = vInstance;\n gl_FragData[2] = vGroup;\n gl_FragData[3] = packDepthToRGBA(fragmentDepth);\n #else\n gl_FragColor = vColor;\n #endif\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n gl_FragColor = material;\n\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{drawBuffers:"optional"},{},hD),bGe=Br("lines","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include size_vert_params\n#include common_clip\n\nuniform float uPixelRatio;\nuniform vec4 uViewport;\n\nattribute mat4 aTransform;\nattribute float aInstance;\nattribute float aGroup;\n\nattribute vec2 aMapping;\nattribute vec3 aStart;\nattribute vec3 aEnd;\n\nvoid trimSegment(const in vec4 start, inout vec4 end) {\n // trim end segment so it terminates between the camera plane and the near plane\n // conservative estimate of the near plane\n float a = uProjection[2][2]; // 3rd entry in 3rd column\n float b = uProjection[3][2]; // 3rd entry in 4th column\n float nearEstimate = -0.5 * b / a;\n float alpha = (nearEstimate - start.z) / (end.z - start.z);\n end.xyz = mix(start.xyz, end.xyz, alpha);\n}\n\nvoid main(){\n float aspect = uViewport.z / uViewport.w;\n\n #include assign_group\n #include assign_color_varying\n #include assign_marker_varying\n #include assign_clipping_varying\n #include assign_size\n\n mat4 modelView = uView * uModel * aTransform;\n\n // camera space\n vec4 start = modelView * vec4(aStart, 1.0);\n vec4 end = modelView * vec4(aEnd, 1.0);\n\n // assign position\n vec4 position4 = vec4((aMapping.y < 0.5) ? aStart : aEnd, 1.0);\n vec4 mvPosition = modelView * position4;\n vViewPosition = mvPosition.xyz;\n\n vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader\n\n // special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n // but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n // perhaps there is a more elegant solution -- WestLangley\n bool perspective = (uProjection[2][3] == -1.0); // 4th entry in the 3rd column\n if (perspective) {\n if (start.z < 0.0 && end.z >= 0.0) {\n trimSegment(start, end);\n } else if (end.z < 0.0 && start.z >= 0.0) {\n trimSegment(end, start);\n }\n }\n\n // clip space\n vec4 clipStart = uProjection * start;\n vec4 clipEnd = uProjection * end;\n\n // ndc space\n vec2 ndcStart = clipStart.xy / clipStart.w;\n vec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n // direction\n vec2 dir = ndcEnd - ndcStart;\n\n // account for clip-space aspect ratio\n dir.x *= aspect;\n dir = normalize(dir);\n\n // perpendicular to dir\n vec2 offset = vec2(dir.y, - dir.x);\n\n // undo aspect ratio adjustment\n dir.x /= aspect;\n offset.x /= aspect;\n\n // sign flip\n if (aMapping.x < 0.0) offset *= -1.0;\n\n // calculate linewidth\n float linewidth;\n #ifdef dLineSizeAttenuation\n linewidth = size * uPixelRatio * ((uViewport.w / 2.0) / -start.z) * 5.0;\n #else\n linewidth = size * uPixelRatio;\n #endif\n linewidth = max(1.0, linewidth);\n\n // adjust for linewidth\n offset *= linewidth;\n\n // adjust for clip-space to screen-space conversion\n offset /= uViewport.w;\n\n // select end\n vec4 clip = (aMapping.y < 0.5) ? clipStart : clipEnd;\n\n // back to clip space\n offset *= clip.w;\n clip.xy += offset;\n gl_Position = clip;\n\n #include clip_instance\n}\n","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include common_frag_params\n#include color_frag_params\n#include common_clip\n\nvoid main(){\n #include fade_lod\n #include clip_pixel\n\n float fragmentDepth = gl_FragCoord.z;\n #include assign_material_color\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #ifdef requiredDrawBuffers\n gl_FragColor = vObject;\n gl_FragData[1] = vInstance;\n gl_FragData[2] = vGroup;\n gl_FragData[3] = packDepthToRGBA(fragmentDepth);\n #else\n gl_FragColor = vColor;\n #endif\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n gl_FragColor = material;\n\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{drawBuffers:"optional"},{},hD),wre=Br("mesh","\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include common_clip\n#include texture3d_from_2d_linear\n\n#ifdef dGeometryType_textureMesh\n uniform vec2 uGeoTexDim;\n uniform sampler2D tPosition;\n uniform sampler2D tGroup;\n uniform sampler2D tNormal;\n#else\n attribute vec3 aPosition;\n attribute float aGroup;\n attribute vec3 aNormal;\n#endif\nattribute mat4 aTransform;\nattribute float aInstance;\n\nvarying vec3 vNormal;\n\nvoid main(){\n #include assign_group\n #include assign_marker_varying\n #include assign_clipping_varying\n #include assign_position\n #include assign_color_varying\n #include clip_instance\n\n #ifdef dGeometryType_textureMesh\n vec3 normal = readFromTexture(tNormal, VertexID, uGeoTexDim).xyz;\n #else\n vec3 normal = aNormal;\n #endif\n mat3 normalMatrix = transpose3(inverse3(mat3(modelView)));\n vec3 transformedNormal = normalize(normalMatrix * normalize(normal));\n #if defined(dFlipSided)\n if (!uDoubleSided) { // TODO checking uDoubleSided should not be required, ASR\n transformedNormal = -transformedNormal;\n }\n #endif\n vNormal = transformedNormal;\n}\n","\nprecision highp float;\nprecision highp int;\n\n#define bumpEnabled\n\n#include common\n#include common_frag_params\n#include color_frag_params\n#include light_frag_params\n#include normal_frag_params\n#include common_clip\n\nvoid main() {\n #include fade_lod\n #include clip_pixel\n\n // Workaround for buggy gl_FrontFacing (e.g. on some integrated Intel GPUs)\n vec3 fdx = dFdx(vViewPosition);\n vec3 fdy = dFdy(vViewPosition);\n vec3 faceNormal = normalize(cross(fdx,fdy));\n bool frontFacing = dot(vNormal, faceNormal) > 0.0;\n\n #if defined(dFlipSided)\n interior = frontFacing;\n #else\n interior = !frontFacing;\n #endif\n\n float fragmentDepth = gl_FragCoord.z;\n #include assign_material_color\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #ifdef requiredDrawBuffers\n gl_FragColor = vObject;\n gl_FragData[1] = vInstance;\n gl_FragData[2] = vGroup;\n gl_FragData[3] = packDepthToRGBA(fragmentDepth);\n #else\n gl_FragColor = vColor;\n #endif\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n #if defined(dFlatShaded)\n vec3 normal = -faceNormal;\n #else\n vec3 normal = -normalize(vNormal);\n if (uDoubleSided) normal *= float(frontFacing) * 2.0 - 1.0;\n #endif\n #include apply_light_color\n\n #include apply_interior_color\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{drawBuffers:"optional"},{},lS),vGe=Br("direct-volume","\nprecision highp float;\n\nattribute vec3 aPosition;\nattribute mat4 aTransform;\nattribute float aInstance;\n\nuniform mat4 uModelView;\nuniform mat4 uProjection;\nuniform vec4 uInvariantBoundingSphere;\n\nvarying vec3 vOrigPos;\nvarying float vInstance;\nvarying vec4 vBoundingSphere;\nvarying mat4 vTransform;\n\nuniform vec3 uBboxSize;\nuniform vec3 uBboxMin;\nuniform vec3 uBboxMax;\nuniform vec3 uGridDim;\nuniform mat4 uTransform;\n\nuniform mat4 uUnitToCartn;\n\nvoid main() {\n vec4 unitCoord = vec4(aPosition + vec3(0.5), 1.0);\n vec4 mvPosition = uModelView * aTransform * uUnitToCartn * unitCoord;\n\n vOrigPos = (aTransform * uUnitToCartn * unitCoord).xyz;\n vInstance = aInstance;\n vBoundingSphere = vec4(\n (aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0)).xyz,\n uInvariantBoundingSphere.w\n );\n vTransform = aTransform;\n\n gl_Position = uProjection * mvPosition;\n\n // move z position to near clip plane (but not too close to get precision issues)\n gl_Position.z = gl_Position.w - 0.01;\n}\n","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include light_frag_params\n\n#if dClipObjectCount != 0\n uniform int uClipObjectType[dClipObjectCount];\n uniform bool uClipObjectInvert[dClipObjectCount];\n uniform vec3 uClipObjectPosition[dClipObjectCount];\n uniform vec4 uClipObjectRotation[dClipObjectCount];\n uniform vec3 uClipObjectScale[dClipObjectCount];\n#endif\n#include common_clip\n\n#include read_from_texture\n#include texture3d_from_1d_trilinear\n#include texture3d_from_2d_nearest\n#include texture3d_from_2d_linear\n\nuniform mat4 uProjection, uTransform, uModelView, uModel, uView;\nuniform vec3 uCameraDir;\n\nuniform sampler2D tDepth;\nuniform vec2 uDrawingBufferSize;\n\nvarying vec3 vOrigPos;\nvarying float vInstance;\nvarying vec4 vBoundingSphere;\nvarying mat4 vTransform;\n\nuniform mat4 uInvView;\nuniform vec3 uGridDim;\nuniform vec3 uBboxSize;\nuniform sampler2D tTransferTex;\nuniform float uTransferScale;\nuniform float uStepScale;\nuniform float uJumpLength;\n\nuniform int uObjectId;\nuniform int uVertexCount;\nuniform int uInstanceCount;\nuniform int uGroupCount;\n\n#if defined(dColorMarker)\n uniform vec3 uHighlightColor;\n uniform vec3 uSelectColor;\n uniform vec3 uDimColor;\n uniform float uHighlightStrength;\n uniform float uSelectStrength;\n uniform float uDimStrength;\n uniform int uMarkerPriority;\n uniform float uMarkerAverage;\n\n uniform float uMarker;\n uniform vec2 uMarkerTexDim;\n uniform sampler2D tMarker;\n#endif\n\nuniform float uMetalness;\nuniform float uRoughness;\n\nuniform bool uFog;\nuniform float uFogNear;\nuniform float uFogFar;\nuniform vec3 uFogColor;\n\nuniform float uAlpha;\nuniform bool uTransparentBackground;\nuniform float uXrayEdgeFalloff;\nuniform float uExposure;\n\nuniform int uRenderMask;\n\nuniform float uNear;\nuniform float uFar;\nuniform float uIsOrtho;\n\nuniform vec3 uCellDim;\nuniform vec3 uCameraPosition;\nuniform mat4 uCartnToUnit;\n\n#if __VERSION__ != 100\n // for webgl1 this is given as a 'define'\n uniform int uMaxSteps;\n#endif\n\n#if defined(dGridTexType_2d)\n precision highp sampler2D;\n uniform sampler2D tGridTex;\n uniform vec3 uGridTexDim;\n#elif defined(dGridTexType_3d)\n precision highp sampler3D;\n uniform sampler3D tGridTex;\n#endif\n\n#if defined(dColorType_uniform)\n uniform vec3 uColor;\n#elif defined(dColorType_texture)\n uniform vec2 uColorTexDim;\n uniform sampler2D tColor;\n#endif\n\n#ifdef dOverpaint\n #if defined(dOverpaintType_groupInstance) || defined(dOverpaintType_vertexInstance)\n uniform vec2 uOverpaintTexDim;\n uniform sampler2D tOverpaint;\n #endif\n#endif\n\n#ifdef dUsePalette\n uniform sampler2D tPalette;\n#endif\n\n#if defined(dGridTexType_2d)\n vec4 textureVal(vec3 pos) {\n return texture3dFrom2dLinear(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy);\n }\n vec4 textureGroup(vec3 pos) {\n return texture3dFrom2dNearest(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy);\n }\n#elif defined(dGridTexType_3d)\n vec4 textureVal(vec3 pos) {\n return texture(tGridTex, pos + (vec3(0.5) / uGridDim));\n }\n vec4 textureGroup(vec3 pos) {\n return texelFetch(tGridTex, ivec3(pos * uGridDim), 0);\n }\n#endif\n\nfloat calcDepth(const in vec3 pos) {\n vec2 clipZW = pos.z * uProjection[2].zw + uProjection[3].zw;\n return 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\n\nfloat transferFunction(float value) {\n return texture2D(tTransferTex, vec2(value, 0.0)).a;\n}\n\nfloat getDepth(const in vec2 coords) {\n #ifdef depthTextureSupport\n return texture2D(tDepth, coords).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n #endif\n}\n\nconst float gradOffset = 0.5;\n\nvec3 v3m4(vec3 p, mat4 m) {\n return (m * vec4(p, 1.0)).xyz;\n}\n\nfloat preFogAlphaBlended = 0.0;\n\nvec4 raymarch(vec3 startLoc, vec3 step, vec3 rayDir) {\n mat3 normalMatrix = transpose3(inverse3(mat3(uModelView * vTransform)));\n mat4 cartnToUnit = uCartnToUnit * inverse4(vTransform);\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n mat4 modelTransform = uModel * vTransform * uTransform;\n #endif\n mat4 modelViewTransform = uModelView * vTransform * uTransform;\n\n vec3 scaleVol = vec3(1.0) / uGridDim;\n vec3 pos = startLoc;\n vec4 cell;\n float prevValue = -1.0;\n float value = 0.0;\n vec4 src = vec4(0.0);\n vec4 dst = vec4(0.0);\n float fragmentDepth;\n\n vec3 posMin = vec3(0.0);\n vec3 posMax = vec3(1.0) - vec3(1.0) / uGridDim;\n\n vec3 unitPos;\n\n vec3 nextPos;\n float nextValue;\n\n vec4 material;\n vec4 overpaint;\n float metalness = uMetalness;\n float roughness = uRoughness;\n\n vec3 gradient = vec3(1.0);\n vec3 dx = vec3(gradOffset * scaleVol.x, 0.0, 0.0);\n vec3 dy = vec3(0.0, gradOffset * scaleVol.y, 0.0);\n vec3 dz = vec3(0.0, 0.0, gradOffset * scaleVol.z);\n\n float maxDist = min(vBoundingSphere.w * 2.0, uFar - uNear);\n float maxDistSq = maxDist * maxDist;\n\n for (int i = 0; i < uMaxSteps; ++i) {\n // break when beyond bounding-sphere or far-plane\n vec3 distVec = startLoc - pos;\n if (dot(distVec, distVec) > maxDistSq) break;\n\n unitPos = v3m4(pos, cartnToUnit);\n\n // continue when outside of grid\n if (unitPos.x > posMax.x || unitPos.y > posMax.y || unitPos.z > posMax.z ||\n unitPos.x < posMin.x || unitPos.y < posMin.y || unitPos.z < posMin.z\n ) {\n prevValue = value;\n pos += step;\n continue;\n }\n\n cell = textureVal(unitPos);\n value = cell.a; // current voxel value\n\n if (uJumpLength > 0.0 && value < 0.01) {\n nextPos = pos + rayDir * uJumpLength;\n nextValue = textureVal(v3m4(nextPos, cartnToUnit)).a;\n if (nextValue < 0.01) {\n prevValue = nextValue;\n pos = nextPos;\n continue;\n }\n }\n\n vec4 mvPosition = modelViewTransform * vec4(unitPos * uGridDim, 1.0);\n if (calcDepth(mvPosition.xyz) > getDepth(gl_FragCoord.xy / uDrawingBufferSize))\n break;\n\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n vec3 vModelPosition = v3m4(unitPos * uGridDim, modelTransform);\n if (clipTest(vec4(vModelPosition, 0.0))) {\n prevValue = value;\n pos += step;\n continue;\n }\n #endif\n\n vec3 vViewPosition = mvPosition.xyz;\n material.a = transferFunction(value);\n\n #ifdef dPackedGroup\n float group = unpackRGBToInt(textureGroup(floor(unitPos * uGridDim + 0.5) / uGridDim).rgb);\n #else\n vec3 g = floor(unitPos * uGridDim + 0.5);\n // note that we swap x and z because the texture is flipped around y\n #if defined(dAxisOrder_012)\n float group = g.z + g.y * uGridDim.z + g.x * uGridDim.z * uGridDim.y; // 210\n #elif defined(dAxisOrder_021)\n float group = g.y + g.z * uGridDim.y + g.x * uGridDim.y * uGridDim.z; // 120\n #elif defined(dAxisOrder_102)\n float group = g.z + g.x * uGridDim.z + g.y * uGridDim.z * uGridDim.x; // 201\n #elif defined(dAxisOrder_120)\n float group = g.x + g.z * uGridDim.x + g.y * uGridDim.x * uGridDim.z; // 021\n #elif defined(dAxisOrder_201)\n float group = g.y + g.x * uGridDim.y + g.z * uGridDim.y * uGridDim.x; // 102\n #elif defined(dAxisOrder_210)\n float group = g.x + g.y * uGridDim.x + g.z * uGridDim.x * uGridDim.y; // 012\n #endif\n #endif\n\n #if defined(dColorType_direct) && defined(dUsePalette)\n material.rgb = texture2D(tPalette, vec2(value, 0.0)).rgb;\n #elif defined(dColorType_uniform)\n material.rgb = uColor;\n #elif defined(dColorType_instance)\n material.rgb = readFromTexture(tColor, vInstance, uColorTexDim).rgb;\n #elif defined(dColorType_group)\n material.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;\n #elif defined(dColorType_groupInstance)\n material.rgb = readFromTexture(tColor, vInstance * float(uGroupCount) + group, uColorTexDim).rgb;\n #elif defined(dColorType_vertex)\n material.rgb = texture3dFrom1dTrilinear(tColor, unitPos, uGridDim, uColorTexDim, 0.0).rgb;\n #elif defined(dColorType_vertexInstance)\n material.rgb = texture3dFrom1dTrilinear(tColor, unitPos, uGridDim, uColorTexDim, vInstance * float(uVertexCount)).rgb;\n #endif\n\n #ifdef dOverpaint\n #if defined(dOverpaintType_groupInstance)\n overpaint = readFromTexture(tOverpaint, vInstance * float(uGroupCount) + group, uOverpaintTexDim);\n #elif defined(dOverpaintType_vertexInstance)\n overpaint = texture3dFrom1dTrilinear(tOverpaint, unitPos, uGridDim, uOverpaintTexDim, vInstance * float(uVertexCount));\n #endif\n\n material.rgb = mix(material.rgb, overpaint.rgb, overpaint.a);\n #endif\n\n #ifdef dIgnoreLight\n gl_FragColor.rgb = material.rgb;\n #else\n if (material.a >= 0.01) {\n #ifdef dPackedGroup\n // compute gradient by central differences\n gradient.x = textureVal(unitPos - dx).a - textureVal(unitPos + dx).a;\n gradient.y = textureVal(unitPos - dy).a - textureVal(unitPos + dy).a;\n gradient.z = textureVal(unitPos - dz).a - textureVal(unitPos + dz).a;\n #else\n gradient = cell.xyz * 2.0 - 1.0;\n #endif\n vec3 normal = -normalize(normalMatrix * normalize(gradient));\n #include apply_light_color\n } else {\n gl_FragColor.rgb = material.rgb;\n }\n #endif\n\n gl_FragColor.a = material.a * uAlpha * uTransferScale;\n\n #if defined(dColorMarker)\n float marker = uMarker;\n if (uMarker == -1.0) {\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n #endif\n #include apply_marker_color\n\n preFogAlphaBlended = (1.0 - preFogAlphaBlended) * gl_FragColor.a + preFogAlphaBlended;\n fragmentDepth = calcDepth(mvPosition.xyz);\n #include apply_fog\n\n src = gl_FragColor;\n\n if (!uTransparentBackground) {\n // done in 'apply_fog' otherwise\n src.rgb *= src.a;\n }\n dst = (1.0 - dst.a) * src + dst; // standard blending\n\n // break if the color is opaque enough\n if (dst.a > 0.95)\n break;\n\n pos += step;\n }\n\n return dst;\n}\n\n// TODO: support float texture for higher precision values???\n// TODO: support clipping exclusion texture support\n\nvoid main() {\n if (gl_FrontFacing)\n discard;\n\n vec3 rayDir = mix(normalize(vOrigPos - uCameraPosition), uCameraDir, uIsOrtho);\n vec3 step = rayDir * uStepScale;\n\n float boundingSphereNear = distance(vBoundingSphere.xyz, uCameraPosition) - vBoundingSphere.w;\n float d = max(uNear, boundingSphereNear) - mix(0.0, distance(vOrigPos, uCameraPosition), uIsOrtho);\n vec3 start = mix(uCameraPosition, vOrigPos, uIsOrtho) + (d * rayDir);\n gl_FragColor = raymarch(start, step, rayDir);\n\n float fragmentDepth = calcDepth((uModelView * vec4(start, 1.0)).xyz);\n float preFogAlpha = clamp(preFogAlphaBlended, 0.0, 1.0);\n #include wboit_write\n}\n",{fragDepth:"optional",drawBuffers:"optional"},{},lS),_Ge=Br("image","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include common_vert_params\n\nattribute vec3 aPosition;\nattribute vec2 aUv;\nattribute mat4 aTransform;\nattribute float aInstance;\n\nvarying vec2 vUv;\nvarying float vInstance;\n\nvoid main() {\n #include assign_position\n\n vUv = aUv;\n vInstance = aInstance;\n}\n","\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_frag_params\n#include common_clip\n\nuniform vec2 uImageTexDim;\nuniform sampler2D tImageTex;\nuniform sampler2D tGroupTex;\n\nuniform vec2 uMarkerTexDim;\nuniform sampler2D tMarker;\n\nvarying vec2 vUv;\nvarying float vInstance;\n\n#if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell) || defined(dInterpolation_bspline)\n #define dInterpolation_cubic\n#endif\n\n#if defined(dInterpolation_cubic)\n #if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell)\n #if defined(dInterpolation_catmulrom)\n const float B = 0.0;\n const float C = 0.5;\n #elif defined(dInterpolation_mitchell)\n const float B = 0.333;\n const float C = 0.333;\n #endif\n\n float cubicFilter(float x){\n float f = x;\n if (f < 0.0) {\n f = -f;\n }\n if (f < 1.0) {\n return ((12.0 - 9.0 * B - 6.0 * C) * (f * f * f) +\n (-18.0 + 12.0 * B + 6.0 * C) * (f * f) +\n (6.0 - 2.0 * B)) / 6.0;\n }else if (f >= 1.0 && f < 2.0){\n return ((-B - 6.0 * C) * ( f * f * f)\n + (6.0 * B + 30.0 * C) * (f * f) +\n (-(12.0 * B) - 48.0 * C) * f +\n 8.0 * B + 24.0 * C) / 6.0;\n }else{\n return 0.0;\n }\n }\n #elif defined(dInterpolation_bspline)\n float cubicFilter(float x) {\n float f = x;\n if (f < 0.0) {\n f = -f;\n }\n if (f >= 0.0 && f <= 1.0){\n return (2.0 / 3.0) + (0.5) * (f * f * f) - (f * f);\n } else if (f > 1.0 && f <= 2.0) {\n return 1.0 / 6.0 * pow((2.0 - f), 3.0);\n }\n return 1.0;\n }\n #endif\n\n vec4 biCubic(sampler2D tex, vec2 texCoord) {\n vec2 texelSize = 1.0 / uImageTexDim;\n texCoord -= texelSize / 2.0;\n vec4 nSum = vec4(0.0);\n float nDenom = 0.0;\n vec2 cell = fract(texCoord * uImageTexDim);\n for (float m = -1.0; m <= 2.0; ++m) {\n for (float n = -1.0; n <= 2.0; ++n) {\n vec4 vecData = texture2D(tex, texCoord + texelSize * vec2(m, n));\n float c = cubicFilter(m - cell.x) * cubicFilter(-n + cell.y);\n nSum += vecData * c;\n nDenom += c;\n }\n }\n return nSum / nDenom;\n }\n#endif\n\nvoid main() {\n #include fade_lod\n #include clip_pixel\n\n #if defined(dInterpolation_cubic)\n vec4 imageData = biCubic(tImageTex, vUv);\n #else\n vec4 imageData = texture2D(tImageTex, vUv);\n #endif\n imageData.a = clamp(imageData.a, 0.0, 1.0);\n if (imageData.a > 0.9) imageData.a = 1.0;\n\n float fragmentDepth = gl_FragCoord.z;\n\n #if defined(dRenderVariant_pick)\n if (imageData.a < 0.3)\n discard;\n #ifdef requiredDrawBuffers\n gl_FragColor = vec4(packIntToRGB(float(uObjectId)), 1.0);\n gl_FragData[1] = vec4(packIntToRGB(vInstance), 1.0);\n gl_FragData[2] = vec4(texture2D(tGroupTex, vUv).rgb, 1.0);\n gl_FragData[3] = packDepthToRGBA(gl_FragCoord.z);\n #else\n gl_FragColor = vColor;\n if (uPickType == 1) {\n gl_FragColor = vec4(packIntToRGB(float(uObjectId)), 1.0);\n } else if (uPickType == 2) {\n gl_FragColor = vec4(packIntToRGB(vInstance), 1.0);\n } else {\n gl_FragColor = vec4(texture2D(tGroupTex, vUv).rgb, 1.0);\n }\n #endif\n #elif defined(dRenderVariant_depth)\n if (imageData.a < 0.05)\n discard;\n gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n #elif defined(dRenderVariant_marking)\n float marker = uMarker;\n if (uMarker == -1.0) {\n float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb);\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n if (uMarkingType == 1) {\n if (marker > 0.0 || imageData.a < 0.05)\n discard;\n gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n } else {\n if (marker == 0.0 || imageData.a < 0.05)\n discard;\n float depthTest = 1.0;\n if (uMarkingDepthTest) {\n depthTest = (fragmentDepth >= getDepthPacked(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0;\n }\n bool isHighlight = intMod(marker, 2.0) > 0.1;\n gl_FragColor = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0);\n }\n #elif defined(dRenderVariant_color)\n if (imageData.a < 0.05)\n discard;\n gl_FragColor = imageData;\n gl_FragColor.a *= uAlpha;\n\n float marker = uMarker;\n if (uMarker == -1.0) {\n float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb);\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #include dpoit_write\n #endif\n}\n",{drawBuffers:"optional"},{},hD);function Are(e,t){var n;if(void 0===e)return"";const r=(null===(n=e.dRenderVariant)||void 0===n?void 0:n.ref.value)||"",i=[];for(const o in e){if(t?.(o,r,e))continue;const a=e[o].ref.value;void 0!==a&&("string"==typeof a?i.push(`#define ${o}_${a}`):"number"==typeof a?i.push(`#define ${o} ${a}`):"boolean"==typeof a?a&&i.push(`#define ${o}`):Rr())}return i.join("\n")+"\n"}const CGe="\n#define attribute in\n#define varying out\n#define texture2D texture\n",wGe="\n#define varying in\n#define texture2D texture\n#define textureCube texture\n#define texture2DLodEXT textureLod\n#define textureCubeLodEXT textureLod\n\n#define gl_FragColor out_FragData0\n#define gl_FragDepthEXT gl_FragDepth\n\n#define depthTextureSupport\n";function EGe(e,t){switch(t){case"b":case"b[]":return e.BOOL;case"f":case"f[]":return e.FLOAT;case"i":case"i[]":return e.INT;case"v2":case"v2[]":return e.FLOAT_VEC2;case"v3":case"v3[]":return e.FLOAT_VEC3;case"v4":case"v4[]":return e.FLOAT_VEC4;case"iv2":case"iv2[]":return e.INT_VEC2;case"iv3":case"iv3[]":return e.INT_VEC3;case"iv4":case"iv4[]":return e.INT_VEC4;case"m3":case"m3[]":return e.FLOAT_MAT3;case"m4":case"m4[]":return e.FLOAT_MAT4;default:console.error(`unknown uniform kind '${t}'`)}}function MGe(e,t,n){e.uniform1f(t,n)}function RGe(e,t,n){e.uniform1fv(t,n)}function kGe(e,t,n){e.uniform1i(t,n)}function NGe(e,t,n){e.uniform1iv(t,n)}function FGe(e,t,n){e.uniform2fv(t,n)}function BGe(e,t,n){e.uniform3fv(t,n)}function OGe(e,t,n){e.uniform4fv(t,n)}function LGe(e,t,n){e.uniform2iv(t,n)}function UGe(e,t,n){e.uniform3iv(t,n)}function VGe(e,t,n){e.uniform4iv(t,n)}function zGe(e,t,n){e.uniformMatrix3fv(t,!1,n)}function GGe(e,t,n){e.uniformMatrix4fv(t,!1,n)}function Ire(e){switch(e){case"f":return MGe;case"f[]":return RGe;case"i":case"t":case"b":return kGe;case"i[]":case"t[]":case"b[]":return NGe;case"v2":case"v2[]":return FGe;case"v3":case"v3[]":return BGe;case"v4":case"v4[]":return OGe;case"iv2":case"iv2[]":return LGe;case"iv3":case"iv3[]":return UGe;case"iv4":case"iv4[]":return VGe;case"m3":case"m3[]":return zGe;case"m4":case"m4[]":return GGe}}const qGe=pa();function WL(e){const t=e.createBuffer();if(null===t)throw new Error("Could not create WebGL buffer");return t}function Tre(e,t,n,r){let i=WL(e);const o=function WGe(e,t){switch(t){case"static":return e.STATIC_DRAW;case"dynamic":return e.DYNAMIC_DRAW;case"stream":return e.STREAM_DRAW}}(e,n),s=function YGe(e,t){switch(t){case"attribute":return e.ARRAY_BUFFER;case"elements":return e.ELEMENT_ARRAY_BUFFER;case"uniform":if(Wt(e))return e.UNIFORM_BUFFER;throw new Error("WebGL2 is required for uniform buffers")}}(e,r),a=function $Ge(e,t){return t instanceof Uint8Array?e.UNSIGNED_BYTE:t instanceof Int8Array?e.BYTE:t instanceof Uint16Array?e.UNSIGNED_SHORT:t instanceof Int16Array?e.SHORT:t instanceof Uint32Array?e.UNSIGNED_INT:t instanceof Int32Array?e.INT:t instanceof Float32Array?e.FLOAT:void Rr()}(e,t),c=t.BYTES_PER_ELEMENT,u=t.length;function l(f){e.bindBuffer(s,i),e.bufferData(s,f,o)}l(t);let d=!1;return{id:qGe(),_usageHint:o,_bufferType:s,_dataType:a,_bpe:c,length:u,getBuffer:()=>i,updateData:l,updateSubData:(f,p,m)=>{e.bindBuffer(s,i),m-p===f.length?e.bufferSubData(s,0,f):e.bufferSubData(s,p*c,f.subarray(p,p+m))},reset:()=>{i=WL(e),l(t)},destroy:()=>{d||(e.deleteBuffer(i),d=!0)}}}function XGe(e,t,n){if("float32"===t)switch(n){case 1:return e.FLOAT;case 2:return e.FLOAT_VEC2;case 3:return e.FLOAT_VEC3;case 4:return e.FLOAT_VEC4;case 16:return e.FLOAT_MAT4}Rr()}const JGe=pa();function $L(e){const t=e.createProgram();if(null===t)throw new Error("Could not create WebGL program");return t}function i9e(e,t,n,r,i){const{defineValues:o,shaderCode:s,schema:a}=i;let c=$L(e);const u=JGe(),l=function DGe(e,t,n,r){const i=Are(n,r.ignoreDefine),o=Are(n,r.ignoreDefine),s=Wt(e)?function AGe(e,t){const n=["#version 300 es"];if(t.drawBuffers&&e.drawBuffers&&n.push("#define requiredDrawBuffers"),t.multiDraw)if(e.multiDraw)n.push("#extension GL_ANGLE_multi_draw : require"),n.push("#define enabledMultiDraw");else if("required"===t.multiDraw)throw new Error("required 'GL_ANGLE_multi_draw' extension not available");if(t.clipCullDistance)if(e.clipCullDistance)n.push("#extension GL_ANGLE_clip_cull_distance : enable"),n.push("#define enabledClipCullDistance");else if("required"===t.clipCullDistance)throw new Error("required 'GL_ANGLE_clip_cull_distance' extension not available");if(t.conservativeDepth)if(e.conservativeDepth)n.push("#extension GL_EXT_conservative_depth : enable"),n.push("#define enabledConservativeDepth");else if("required"===t.conservativeDepth)throw new Error("required 'GL_EXT_conservative_depth' extension not available");return e.noNonInstancedActiveAttribs&&n.push("#define noNonInstancedActiveAttribs"),n.push(CGe),n.join("\n")+"\n"}(t,r.extensions):function xGe(e,t){const n=[];if(t.drawBuffers)if(e.drawBuffers)n.push("#define requiredDrawBuffers");else if("required"===t.drawBuffers)throw new Error("required 'GL_EXT_draw_buffers' extension not available");if(t.multiDraw)if(e.multiDraw)n.push("#extension GL_ANGLE_multi_draw : require"),n.push("#define enabledMultiDraw");else if("required"===t.multiDraw)throw new Error("required 'GL_ANGLE_multi_draw' extension not available");return n.join("\n")+"\n"}(t,r.extensions),a=Wt(e)?function IGe(e,t,n,r){const i=["#version 300 es",`layout(location = 0) out highp ${r[0]||"vec4"} out_FragData0;`];if(n.fragDepth&&t.fragDepth&&i.push("#define enabledFragDepth"),n.drawBuffers&&t.drawBuffers){i.push("#define requiredDrawBuffers");for(let s=1,a=e.getParameter(e.MAX_DRAW_BUFFERS);s{const o=n[i];if("attribute"===o.type){const s=e.getAttribLocation(t,i);r[i]=s}else if("uniform"===o.type){let s=e.getUniformLocation(t,i);null===s&&function PGe(e){return e.endsWith("[]")}(o.kind)&&(s=e.getUniformLocation(t,i+"[0]")),r[i]=s}else if("texture"===o.type){const s=e.getUniformLocation(t,i);r[i]=s}}),r}(e,c,a),m=function jGe(e){const t={};return Object.keys(e).forEach(n=>{const r=e[n];"uniform"===r.type?t[n]=Ire(r.kind):"texture"===r.type&&(t[n]=Ire("t"))}),t}(a),un&&(function t9e(e,t,n){const r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i{t.currentProgramId=u,e.useProgram(c)},setUniforms:y=>{for(let b=0,x=y.length;b{const x=p[y];null!==x&&m[y](e,x,b)},bindAttributes:y=>{t.clearVertexAttribsState();for(let b=0,x=y.length;b{for(let x=0,_=y.length;x<_;++x){const[S,A]=y[x],E=p[S];-1!==E&&A.changeOffset(E,b)}},bindTextures:(y,b)=>{for(let x=0,_=y.length;x<_;++x){const[S,A]=y[x],E=p[S];null!=E&&(A.bind(x+b),m[S](e,E,x+b))}},reset:()=>{c=$L(e),h()},destroy:()=>{g||(d.destroy(),f.destroy(),e.deleteProgram(c),g=!0)}}}const o9e=pa();function mD(e,t){const{type:n,source:r}=t,i=e.createShader("vert"===n?e.VERTEX_SHADER:e.FRAGMENT_SHADER);if(null===i)throw new Error(`Error creating ${n} shader`);if(e.shaderSource(i,r),e.compileShader(i),un&&!1===e.getShaderParameter(i,e.COMPILE_STATUS))throw console.warn(`'${n}' shader info log '${e.getShaderInfoLog(i)}'\n${function s9e(e){const t=e.split("\n");for(let n=0;n{const o=e(i);let s=r.get(o);return s||(s=function c9e(e,t=0){return{value:e,usageCount:t}}(t(i)),r.set(o,s)),s.usageCount+=1,function u9e(e){return{free:()=>{e.usageCount-=1},value:e.value}}(s)},clear:()=>{r.forEach((i,o)=>{i.usageCount<=0&&(i.usageCount<0&&console.warn("Reference usageCount below zero."),n(i.value),r.delete(o))})},get count(){return r.size},dispose:()=>{r.forEach(i=>n(i.value)),r.clear()}}}const l9e=pa();function Ere(e){const t=e.createRenderbuffer();if(null===t)throw new Error("Could not create WebGL renderbuffer");return t}const h9e=pa();function Pre(e){const{vertexArrayObject:t}=e;if(!t)throw new Error("VertexArrayObject not supported");const n=t.createVertexArray();if(!n)throw new Error("Could not create WebGL vertex array");return n}function Mre(e){const{vertexArrayObject:t}=e;if(null===t)throw new Error("VertexArrayObject not supported");return t}function Rre(e){return{...e.value,destroy:()=>{e.free()}}}function y9e(e,t,n,r){const i={attribute:new Set,elements:new Set,framebuffer:new Set,program:new Set,renderbuffer:new Set,shader:new Set,texture:new Set,cubeTexture:new Set,vertexArray:new Set};function o(u,l){return i[u].add(l),n.resourceCounts[u]+=1,{...l,destroy:()=>{l.destroy(),i[u].delete(l),n.resourceCounts[u]-=1}}}const s=Dre(u=>JSON.stringify(u),u=>o("shader",function a9e(e,t){let n=mD(e,t);return{id:o9e(),attach:r=>{e.attachShader(r,n)},reset:()=>{n=mD(e,t)},destroy:()=>{e.deleteShader(n)}}}(e,u)),u=>{u.destroy()});function a(u,l){return Rre(s.get({type:u,source:l}))}const c=Dre(u=>{var l;const d=[u.shaderCode.id],f=(null===(l=u.defineValues.dRenderVariant)||void 0===l?void 0:l.ref.value)||"";return Object.keys(u.defineValues).forEach(p=>{var m,h;null!==(h=(m=u.shaderCode).ignoreDefine)&&void 0!==h&&h.call(m,p,f,u.defineValues)||d.push(aB(p),function g9e(e){return"boolean"==typeof e?e?1:0:"number"==typeof e?1e4*e:aB(e)}(u.defineValues[p].ref.value))}),ha(d).toString()},u=>o("program",i9e(e,t,r,a,u)),u=>{u.destroy()});return{attribute:(u,l,d,f)=>o("attribute",function KGe(e,t,n,r,i,o,s="static"){const{instancedArrays:a}=n,c=Tre(e,r,s,"attribute"),{_bufferType:u,_dataType:l,_bpe:d}=c;return{...c,divisor:o,bind:f=>{if(e.bindBuffer(u,c.getBuffer()),16===i)for(let p=0;p<4;++p)t.enableVertexAttrib(f+p),e.vertexAttribPointer(f+p,4,l,!1,16*d,4*p*d),a.vertexAttribDivisor(f+p,o);else t.enableVertexAttrib(f),e.vertexAttribPointer(f,i,l,!1,0,0),a.vertexAttribDivisor(f,o)},changeOffset:(f,p)=>{const m=p*d*i;if(e.bindBuffer(u,c.getBuffer()),16===i)for(let h=0;h<4;++h)e.vertexAttribPointer(f+h,4,l,!1,16*d,4*h*d+m);else e.vertexAttribPointer(f,i,l,!1,0,m)}}}(e,t,r,u,l,d,f)),elements:(u,l)=>o("elements",function QGe(e,t,n="static"){const r=Tre(e,t,n,"elements");return{...r,bind:()=>{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r.getBuffer())}}}(e,u,l)),framebuffer:()=>o("framebuffer",function a7e(e){let t=vre(e),n=!1;return{id:bre(),bind:()=>e.bindFramebuffer(e.FRAMEBUFFER,t),reset:()=>{t=vre(e)},destroy:()=>{n||(e.deleteFramebuffer(t),n=!0)}}}(e)),program:(u,l,d)=>Rre(c.get({defineValues:u,shaderCode:l,schema:d})),renderbuffer:(u,l,d,f)=>o("renderbuffer",function p9e(e,t,n,r,i){let o=Ere(e);const s=()=>e.bindRenderbuffer(e.RENDERBUFFER,o),a=function d9e(e,t){switch(t){case"depth16":return e.DEPTH_COMPONENT16;case"stencil8":return e.STENCIL_INDEX8;case"rgba4":return e.RGBA4;case"depth-stencil":return e.DEPTH_STENCIL;case"depth24":if(Wt(e))return e.DEPTH_COMPONENT24;throw new Error("WebGL2 needed for `depth24` renderbuffer format");case"depth32f":if(Wt(e))return e.DEPTH_COMPONENT32F;throw new Error("WebGL2 needed for `depth32f` renderbuffer format");case"depth24-stencil8":if(Wt(e))return e.DEPTH24_STENCIL8;throw new Error("WebGL2 needed for `depth24-stencil8` renderbuffer format");case"depth32f-stencil8":if(Wt(e))return e.DEPTH32F_STENCIL8;throw new Error("WebGL2 needed for `depth32f-stencil8` renderbuffer format")}}(e,t),c=function f9e(e,t){switch(t){case"depth":return e.DEPTH_ATTACHMENT;case"stencil":return e.STENCIL_ATTACHMENT;case"depth-stencil":return e.DEPTH_STENCIL_ATTACHMENT;case"color0":return e.COLOR_ATTACHMENT0}}(e,n);function u(){s(),e.renderbufferStorage(e.RENDERBUFFER,a,r,i)}u();let l=!1;return{id:l9e(),bind:s,attachFramebuffer:d=>{d.bind(),s(),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,o),un&&pD(e)},detachFramebuffer:d=>{d.bind(),s(),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,null),un&&pD(e)},setSize:(d,f)=>{r=d,i=f,u()},reset:()=>{o=Ere(e),u()},destroy:()=>{l||(e.deleteRenderbuffer(o),l=!0)}}}(e,u,l,d,f)),shader:a,texture:(u,l,d,f)=>o("texture",function mje(e,t,n,r,i,o){const s=XL();let a=Xre(e);if(n.endsWith("float32")&&"float"!==i||n.endsWith("float16")&&"fp16"!==i||n.endsWith("uint8")&&"ubyte"!==i||n.endsWith("int32")&&"int"!==i||n.endsWith("depth")&&"ushort"!==i&&"float"!==i)throw new Error(`texture kind '${n}' and type '${i}' are incompatible`);if(!t.depthTexture&&"depth"===r)throw new Error("extension 'WEBGL_depth_texture' needed for 'depth' texture format");const c=function uje(e,t){switch(t){case"image-uint8":case"image-float32":case"image-float16":case"image-depth":return e.TEXTURE_2D}if(Wt(e))switch(t){case"image-int32":return e.TEXTURE_2D;case"volume-uint8":case"volume-float32":case"volume-float16":return e.TEXTURE_3D}throw new Error(`unknown texture kind '${t}'`)}(e,n),u=Wre(e,o),l=Hre(e,r,i),d=function lje(e,t,n){if(Wt(e))switch(t){case"alpha":switch(n){case"ubyte":return e.ALPHA;case"float":return e.R32F;case"fp16":return e.R16F;case"int":return e.R32I}case"rg":switch(n){case"ubyte":return e.RG;case"float":return e.RG32F;case"fp16":return e.RG16F;case"int":return e.RG32I}case"rgb":switch(n){case"ubyte":return e.RGB;case"float":return e.RGB32F;case"fp16":return e.RGB16F;case"int":return e.RGB32I}case"rgba":switch(n){case"ubyte":return e.RGBA;case"float":return e.RGBA32F;case"fp16":return e.RGBA16F;case"int":return e.RGBA32I}case"depth":switch(n){case"ushort":return e.DEPTH_COMPONENT16;case"float":return e.DEPTH_COMPONENT32F}}return Hre(e,t,n)}(e,r,i),f=function pje(e,t,n){switch(n){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(Wt(e))return e.INT;throw new Error('texture type "int" requires webgl2')}}(e,t,i);function p(){e.bindTexture(c,a),e.texParameteri(c,e.TEXTURE_MAG_FILTER,u),e.texParameteri(c,e.TEXTURE_MIN_FILTER,u),e.texParameteri(c,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(c,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(c,null)}p();let y,m=0,h=0,g=0,b=!1,x=!1;function _(w,D,I){if(0===w||0===D||Wt(e)&&c===e.TEXTURE_3D&&0===I)throw new Error("empty textures are not allowed");if(m!==w||h!==D||g!==(I||0))if(m=w,h=D,g=I||0,e.bindTexture(c,a),c===e.TEXTURE_2D)e.texImage2D(c,0,d,m,h,0,l,f,null);else{if(!Wt(e)||c!==e.TEXTURE_3D||void 0===g)throw new Error("unknown texture target");e.texImage3D(c,0,d,m,h,g,0,l,f,null)}}function S(w,D=!1){if(0===w.width||0===w.height||!$re(w)&&Wt(e)&&Yre(0,c,e)&&0===w.depth)throw new Error("empty textures are not allowed");if(e.bindTexture(c,a),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),$re(w))m=w.width,h=w.height,e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.bindTexture(e.TEXTURE_2D,a),e.texImage2D(e.TEXTURE_2D,0,d,l,f,w);else if(function hje(e,t,n){return t===n.TEXTURE_2D}(0,c,e)){const I=w.filter?Wre(e,w.filter):u;e.texParameteri(c,e.TEXTURE_MAG_FILTER,I),e.texParameteri(c,e.TEXTURE_MIN_FILTER,I),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!!w.flipY),D?e.texSubImage2D(c,0,0,0,w.width,w.height,l,f,w.array):(m=w.width,h=w.height,e.texImage2D(c,0,d,m,h,0,l,f,w.array))}else{if(!Wt(e)||!Yre(0,c,e))throw new Error("unknown texture target");e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),D?e.texSubImage3D(c,0,0,0,0,w.width,w.height,w.depth,l,f,w.array):(m=w.width,h=w.height,g=w.depth,e.texImage3D(c,0,d,m,h,g,0,l,f,w.array))}e.bindTexture(c,null),y=w}function A(){if(c!==e.TEXTURE_2D)throw new Error("mipmap only supported for 2d textures");if(!(Wt(e)||$x(m)&&$x(h)))throw new Error("mipmap unsupported for non-power-of-two textures and webgl1");e.bindTexture(c,a),e.texParameteri(c,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.generateMipmap(c),e.bindTexture(c,null),b=!0}return _(1,1,Wt(e)&&c===e.TEXTURE_3D?1:0),{id:s,target:c,format:l,internalFormat:d,type:f,filter:u,getWidth:()=>m,getHeight:()=>h,getDepth:()=>g,getByteCount:()=>qre(r,i,m,h,g),define:_,load:S,mipmap:A,bind:w=>{e.activeTexture(e.TEXTURE0+w),e.bindTexture(c,a)},unbind:w=>{e.activeTexture(e.TEXTURE0+w),e.bindTexture(c,null)},attachFramebuffer:function E(w,D,I){if(w.bind(),c===e.TEXTURE_2D)e.framebufferTexture2D(e.FRAMEBUFFER,yD(e,t,D),e.TEXTURE_2D,a,0);else{if(!Wt(e)||c!==e.TEXTURE_3D)throw new Error("unknown/unsupported texture target");if(void 0===I)throw new Error("need `layer` to attach 3D texture");e.framebufferTextureLayer(e.FRAMEBUFFER,yD(e,t,D),a,0,I)}},detachFramebuffer:(w,D)=>{if(w.bind(),c===e.TEXTURE_2D)e.framebufferTexture2D(e.FRAMEBUFFER,yD(e,t,D),e.TEXTURE_2D,null,0);else{if(!Wt(e)||c!==e.TEXTURE_3D)throw new Error("unknown texture target");e.framebufferTextureLayer(e.FRAMEBUFFER,yD(e,t,D),null,0,0)}},reset:()=>{a=Xre(e),p();const[w,D,I]=[m,h,g];m=0,h=0,g=0,_(w,D,I),y&&S(y),b&&A()},destroy:()=>{x||(e.deleteTexture(a),x=!0)}}}(e,r,u,l,d,f)),cubeTexture:(u,l,d)=>o("cubeTexture",function yje(e,t,n,r){const i=e.TEXTURE_CUBE_MAP,o=e.LINEAR,s=e.RGBA,a=e.RGBA,c=e.UNSIGNED_BYTE;let u=0;const l=e.createTexture();e.bindTexture(i,l);let d=0;$a(t,(p,m)=>{if(!p)return;const g=function gje(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}}(e,m),y=new Image;p instanceof File?y.src=URL.createObjectURL(p):kI(p)?p.then(b=>{y.src=URL.createObjectURL(b)}):y.src=p,y.addEventListener("load",()=>{0===u&&(u=y.width),e.texImage2D(g,0,s,u,u,0,a,c,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(i,l),e.texImage2D(g,0,s,a,c,y),d+=1,6===d&&(f||(n?(e.texParameteri(i,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.generateMipmap(i)):e.texParameteri(i,e.TEXTURE_MIN_FILTER,o),e.texParameteri(i,e.TEXTURE_MAG_FILTER,o)),r?.(f))}),y.addEventListener("error",()=>{r?.(!0)})});let f=!1;return{id:XL(),target:i,format:a,internalFormat:s,type:c,filter:o,getWidth:()=>u,getHeight:()=>u,getDepth:()=>0,getByteCount:()=>6*qre("rgba","ubyte",u,u,0)*(n?2:1),define:()=>{},load:()=>{},mipmap:()=>{},bind:p=>{e.activeTexture(e.TEXTURE0+p),e.bindTexture(i,l)},unbind:p=>{e.activeTexture(e.TEXTURE0+p),e.bindTexture(i,null)},attachFramebuffer:()=>{},detachFramebuffer:()=>{},reset:()=>{},destroy:()=>{f||(e.deleteTexture(l),f=!0)}}}(e,u,l,d)),vertexArray:(u,l,d)=>o("vertexArray",function m9e(e,t,n,r,i){const o=h9e();let s=Pre(t),a=Mre(t);function c(){a.bindVertexArray(s),i&&i.bind(),n.bindAttributes(r),a.bindVertexArray(null)}c();let u=!1;return{id:o,bind:()=>{a.bindVertexArray(s)},update:c,reset:()=>{s=Pre(t),a=Mre(t),c()},destroy:()=>{u||(i&&(a.bindVertexArray(s),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),a.deleteVertexArray(s),u=!0)}}}(e,r,u,l,d)),getByteCounts:()=>{let u=0;i.texture.forEach(f=>{u+=f.getByteCount()}),i.cubeTexture.forEach(f=>{u+=f.getByteCount()});let l=0;i.attribute.forEach(f=>{l+=4*f.length});let d=0;return i.elements.forEach(f=>{d+=4*f.length}),{texture:u,attribute:l,elements:d}},reset:()=>{i.attribute.forEach(u=>u.reset()),i.elements.forEach(u=>u.reset()),i.framebuffer.forEach(u=>u.reset()),i.renderbuffer.forEach(u=>u.reset()),i.shader.forEach(u=>u.reset()),i.program.forEach(u=>u.reset()),i.vertexArray.forEach(u=>u.reset()),i.texture.forEach(u=>u.reset())},destroy:()=>{i.attribute.forEach(u=>u.destroy()),i.elements.forEach(u=>u.destroy()),i.framebuffer.forEach(u=>u.destroy()),i.renderbuffer.forEach(u=>u.destroy()),i.shader.forEach(u=>u.destroy()),i.program.forEach(u=>u.destroy()),i.vertexArray.forEach(u=>u.destroy()),i.texture.forEach(u=>u.destroy()),s.clear(),c.clear()}}}const kre=pa();class Nre{add(t,n){let r=this.avgs.get(t)||n;return r=function _9e(e,t,n){return(e-=e/n)+t/n}(r,n,this.count),this.avgs.set(t,r),r}get(t){return this.avgs.get(t)}stats(){return Object.fromEntries(this.avgs.entries())}constructor(t){this.count=t,this.avgs=new Map}}function Fre(e){e.map(t=>{const n=function w9e(e){const t=`${(e.gpuElapsed/1e3/1e3).toFixed(2)}`,n=`${(e.gpuAvg/1e3/1e3).toFixed(2)}`,r=`${e.cpuElapsed.toFixed(2)}`,i=`${e.cpuAvg.toFixed(2)}`;return`${e.label} ${t} ms (avg. ${n} ms) | CPU: ${r} ms (avg. ${i} ms)`}(t);t.children.length||t.calls?(console.groupCollapsed(n),t.calls&&console.log(t.calls),Fre(t.children),console.groupEnd()):console.log(n)})}function Bre(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 Ore(e){const t=e.getError();if(t!==e.NO_ERROR)throw new Error(`WebGL error: '${Bre(e,t)}'`)}function gD(e){e.bindFramebuffer(e.FRAMEBUFFER,null)}const Lre=new Uint8Array(4);function Ure(e,t,n){e.getSyncParameter(t,e.SYNC_STATUS)===e.SIGNALED?(e.deleteSync(t),n()):Zx.setImmediate(Ure,e,t,n)}function Vre(e,t){const n=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);n?Zx.setImmediate(Ure,e,n,t):(console.warn("Could not create a WebGLSync object"),e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,Lre),t())}let zre=!1;function Gre(e){e.bindFramebuffer(e.FRAMEBUFFER,null),e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,Lre)}function YL(e,t,n,r,i,o){if(un&&pD(e),o instanceof Uint8Array)e.readPixels(t,n,r,i,e.RGBA,e.UNSIGNED_BYTE,o);else if(o instanceof Float32Array)e.readPixels(t,n,r,i,e.RGBA,e.FLOAT,o);else{if(!(o instanceof Int32Array&&Wt(e)))throw new Error("unsupported readPixels buffer type");e.readPixels(t,n,r,i,e.RGBA_INTEGER,e.INT,o)}un&&Ore(e)}function Wt(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext}const sje="\nattribute vec4 aPosition;\n\nvoid main() {\n gl_Position = aPosition;\n}",aje="\nprecision mediump float;\nuniform vec4 uColor;\nuniform sampler2D uTexture;\n\nvoid main() {\n gl_FragColor = texture2D(uTexture, vec2(0.5, 0.5)) * uColor;\n}",cje=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function jre(e,t){const n=mD(e,{type:"vert",source:sje}),r=mD(e,{type:"frag",source:aje});if(!n||!r)return!1;const i=$L(e);e.attachShader(i,n),e.attachShader(i,r),e.linkProgram(i),e.useProgram(i);const o=e.getAttribLocation(i,"aPosition"),s=e.getUniformLocation(i,"uColor");if(!s)return un&&console.log("error getting 'uColor' uniform location"),!1;const a=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,cje,e.STATIC_DRAW),e.enableVertexAttribArray(o),e.vertexAttribPointer(o,2,e.FLOAT,!1,0,0);const c=e.createTexture(),u=new Uint8Array([255,255,255,255]);e.bindTexture(e.TEXTURE_2D,c),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,u);const 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);const d=e.createFramebuffer();if(e.bindFramebuffer(e.FRAMEBUFFER,d),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l,0),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE)return un&&console.log(`error creating framebuffer for '${t}'`),!1;e.bindTexture(e.TEXTURE_2D,c),e.uniform4fv(s,[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(s,[0,.1,.05,1]),e.drawArrays(e.TRIANGLES,0,6);const p=new Uint8Array(4);if(e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,p),0!==p[0]||p[1]<248||p[2]<248||p[3]<254)return un&&console.log(`not able to actually render to '${t}' texture`),!1;if(t===e.FLOAT){e.bindFramebuffer(e.FRAMEBUFFER,d);const m=new Float32Array(4);e.readPixels(0,0,1,1,e.RGBA,e.FLOAT,m);const h=e.getError();if(h)return un&&console.log(`error reading float pixels: '${Bre(e,h)}'`),!1}return!0}const XL=pa();function Hre(e,t,n){switch(t){case"alpha":return Wt(e)&&"float"===n?e.RED:Wt(e)&&"int"===n?e.RED_INTEGER:e.ALPHA;case"rgb":return Wt(e)&&"int"===n?e.RGB_INTEGER:e.RGB;case"rg":if(Wt(e)&&"float"===n)return e.RG;if(Wt(e)&&"int"===n)return e.RG_INTEGER;throw new Error('texture format "rg" requires webgl2 and type "float" or int"');case"rgba":return Wt(e)&&"int"===n?e.RGBA_INTEGER:e.RGBA;case"depth":return e.DEPTH_COMPONENT}}function qre(e,t,n,r,i){return function dje(e){switch(e){case"alpha":return 1;case"rg":return 2;case"rgb":return 3;case"rgba":case"depth":return 4}}(e)*function fje(e){switch(e){case"ubyte":return 1;case"ushort":case"fp16":return 2;case"float":case"int":return 4}}(t)*n*r*(i||1)}function Wre(e,t){switch(t){case"nearest":return e.NEAREST;case"linear":return e.LINEAR}}function yD(e,t,n){switch(n){case"depth":return e.DEPTH_ATTACHMENT;case"stencil":return e.STENCIL_ATTACHMENT;case"color0":case 0:return e.COLOR_ATTACHMENT0}if(t.drawBuffers)switch(n){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 $re(e){return typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement}function Yre(e,t,n){return t===n.TEXTURE_3D}function Xre(e){const t=e.createTexture();if(null===t)throw new Error("Could not create WebGL texture");return t}function Kre(e,t,n){const{resources:r}=e,i=[];return Object.keys(t).forEach(o=>{const s=t[o];if("texture"===s.type){const a=n[o];if(a)if("texture"===s.kind)i[i.length]=[o,a.ref.value];else{const c=r.texture(s.kind,s.format,s.dataType,s.filter);c.load(a.ref.value),i[i.length]=[o,c]}}}),i}function Zre(e,t,n){const r=new Image;r.onload=function(){n.load(r),k.update(t,n)},r.src=e}const Qre=-1;function Os(e){var t;const n=null!==(t=e?.TEXTURE_2D)&&void 0!==t?t:3553;return{id:XL(),target:n,format:Qre,internalFormat:0,type:0,filter:0,getWidth:()=>0,getHeight:()=>0,getDepth:()=>0,getByteCount:()=>0,define:()=>{},load:()=>{},mipmap:()=>{},bind:r=>{e&&(e.activeTexture(e.TEXTURE0+r),e.bindTexture(n,null))},unbind:r=>{e&&(e.activeTexture(e.TEXTURE0+r),e.bindTexture(n,null))},attachFramebuffer:()=>{throw new Error("cannot attach null-texture to a framebuffer")},detachFramebuffer:()=>{throw new Error("cannot detach null-texture from a framebuffer")},reset:()=>{},destroy:()=>{}}}function bu(e,t,n,r){const i=function vje(e,t,n,r){switch(n.granularity){case"uniform":return function Sje(e,t,n){return function xje(e,t){return t?(k.update(t.uColor,st.toVec3Normalized(t.uColor.ref.value,e)),k.updateIfChanged(t.dColorType,"uniform"),t):{uColor:k.create(st.toVec3Normalized(v(),e)),tColor:k.create({array:new Uint8Array(3),width:1,height:1}),tColorGrid:k.create(Os()),tPalette:k.create({array:new Uint8Array(3),width:1,height:1}),uColorTexDim:k.create(Me.create(1,1)),uColorGridDim:k.create(v.create(1,1,1)),uColorGridTransform:k.create(nn.create(0,0,0,1)),dColorType:k.create("uniform"),dUsePalette:k.create(!1)}}(t(rc,!1),n)}(0,n.color,r);case"instance":return e.nonInstanceable?Jre(e,n.color,r):function Cje(e,t,n){const{instanceCount:r}=e,i=Po(Math.max(1,r),3,Uint8Array,n&&n.tColor.ref.value.array);for(e.reset();e.hasNext;){const{location:o,isSecondary:s,instanceIndex:a}=e.move();st.toArray(t(o,s),i.array,3*a),e.skipInstance()}return dS(i,"instance",n)}(e,n.color,r);case"group":return Jre(e,n.color,r);case"groupInstance":return function wje(e,t,n){const{groupCount:r,instanceCount:i,hasLocation2:o}=e,a=Po(Math.max(1,i*r*(o?2:1)),3,Uint8Array,n&&n.tColor.ref.value.array);e.reset();const c=o?6:3;for(;e.hasNext;){const{location:u,location2:l,isSecondary:d,index:f}=e.move();st.toArray(t(u,d),a.array,f*c),o&&st.toArray(t(l,d),a.array,f*c+3)}return dS(a,"groupInstance",n)}(e,n.color,r);case"vertex":return function Aje(e,t,n){const{groupCount:r,stride:i}=e,o=Po(Math.max(1,r),3,Uint8Array,n&&n.tColor.ref.value.array);for(e.reset(),e.voidInstances();e.hasNext&&!e.isNextNewInstance;){const{location:s,isSecondary:a,groupIndex:c}=e.move(),u=t(s,a);for(let l=0;l=16*t?o.transform.ref.value:new Float32Array(16*t);a.set(e),k.update(o.transform,a),k.updateIfChanged(o.uInstanceCount,t),k.updateIfChanged(o.instanceCount,t);const c=o.aTransform.ref.value.length>=16*t?o.aTransform.ref.value:new Float32Array(16*t);k.update(o.aTransform,c);const u=o.extraTransform.ref.value.length>=16*t?o.extraTransform.ref.value:new Float32Array(16*t);k.update(o.extraTransform,vD(u,t));const l=o.aInstance.ref.value.length>=t?o.aInstance.ref.value:new Float32Array(t);k.update(o.aInstance,Tc(l,t)),k.update(o.hasReflection,s)}else o={aTransform:k.create(new Float32Array(16*t)),matrix:k.create(le.identity()),transform:k.create(new Float32Array(e)),extraTransform:k.create(vD(new Float32Array(16*t),t)),uInstanceCount:k.create(t),instanceCount:k.create(t),aInstance:k.create(Tc(new Float32Array(t))),hasReflection:k.create(s),instanceGrid:k.create({cellSize:0,cellCount:0,cellOffsets:new Uint32Array,cellSpheres:new Float32Array,cellTransform:new Float32Array,cellInstance:new Float32Array,batchSize:0,batchCount:0,batchOffsets:new Uint32Array,batchSpheres:new Float32Array,batchCell:new Uint32Array})};return nie(o,n,r,i),o}const QL=new Float32Array(16);function JL(e){return ZL(new Float32Array(QL),1,void 0,0,0,e)}function vD(e,t){for(let n=0;n0){const l=function Pje(e,t,n){const r=function Mje(e,t){const{instanceCount:n,instance:r,transform:i,invariantBoundingSphere:o}=e,s=new Float32Array(n),a=new Float32Array(n),c=new Float32Array(n),u=Fe.ofBounds(0,n),l=St.setEmpty(St()),{center:d,radius:f}=o,p=v.create(f,f,f),m=v();for(let M=0;Mn,props:t,description:Fje,legend:$h([["uniform",n]])}}const Oje={name:"uniform",label:"Uniform",category:ni.Misc,factory:f0,getParams:function Bje(e){return bv},defaultValues:C.getDefaultValues(bv),isApplicable:e=>!0},iie={value:C.Numeric(1,{min:0,max:20,step:.1})};function e5(e,t){const n=t.value;return{factory:e5,granularity:"uniform",size:()=>n,props:t,description:"Gives everything the same, uniform size."}}const Vje={name:"uniform",label:"Uniform",category:"",factory:e5,getParams:function Uje(e){return iie},defaultValues:C.getDefaultValues(iie),isApplicable:e=>!0};function ba(e){return{...ba.Zero,...e}}function gm(){}!function(e){e.Zero={metalness:0,roughness:0,bumpiness:0},e.toArray=function t(i,o,s){return o[s]=255*i.metalness,o[s+1]=255*i.roughness,o[s+2]=255*i.bumpiness,o},e.toString=function n({metalness:i,roughness:o,bumpiness:s}){return`M ${i.toFixed(2)} | R ${o.toFixed(2)} | B ${s.toFixed(2)}`},e.getParam=function r(i){return C.Group({metalness:C.Numeric(0,{min:0,max:1,step:.01}),roughness:C.Numeric(1,{min:0,max:1,step:.01}),bumpiness:C.Numeric(0,{min:0,max:1,step:.01})},{...i,presets:[[{metalness:0,roughness:1,bumpiness:0},"Matte"],[{metalness:0,roughness:.2,bumpiness:0},"Plastic"],[{metalness:0,roughness:.6,bumpiness:0},"Glossy"],[{metalness:1,roughness:.6,bumpiness:0},"Metallic"]]})}}(ba||(ba={})),function(e){e.Type={none:0,plane:1,sphere:2,cube:3,cylinder:4,infiniteCone:5},e.Params={variant:C.Select("pixel",C.arrayToOptions(["instance","pixel"])),objects:C.ObjectList({type:C.Select("plane",C.objectToOptions(e.Type,c=>zu(c))),invert:C.Boolean(!1),position:C.Vec3(v()),rotation:C.Group({axis:C.Vec3(v.create(1,0,0)),angle:C.Numeric(0,{min:-180,max:180,step:1},{description:"Angle in Degrees"})},{isExpanded:!0}),scale:C.Vec3(v.create(1,1,1))},c=>zu(c.type))};const n=_r(),r=_r(),i=v(),o=v();e.getClip=function s(c,u){const l=c.objects.length,{type:d,invert:f,position:p,rotation:m,scale:h}=u?.objects||function t(c){return{count:0,type:new Array(c).fill(1),invert:new Array(c).fill(!1),position:new Array(3*c).fill(0),rotation:new Array(4*c).fill(0),scale:new Array(3*c).fill(1)}}(l);for(let g=0;g1.2&&(r=2)),{resolution:n,stride:r}}}var rt;function Gje(e,t,n,r){for(let i=t;itypeof s.quality<"u"&&"custom"!==s.quality},e.Params={alpha:C.Numeric(1,{min:0,max:1,step:.01},{label:"Opacity",isEssential:!0,description:"How opaque/transparent the representation is rendered."}),quality:C.Select("auto",t5,{isEssential:!0,description:"Visual/rendering quality of the representation."}),material:ba.getParam(),clip:C.Group(gm.Params),instanceGranularity:C.Boolean(!1,{description:"Use instance granularity for marker, transparency, clipping, overpaint, substance data to save memory."}),lod:C.Vec3(v(),void 0,{...e.CullingLodCategory,description:"Level of detail.",fieldLabels:{x:"Min Distance",y:"Max Distance",z:"Overlap (Shader)"}}),cellSize:C.Numeric(200,{min:0,max:5e3,step:100},{...e.CullingLodCategory,description:"Instance grid cell size."}),batchSize:C.Numeric(2e3,{min:0,max:5e4,step:500},{...e.CullingLodCategory,description:"Instance grid batch size."})},e.createSimple=function t(s=xn.grey,a=1,c){return c||(c=JL()),{transform:c,locationIterator:Mr(1,c.instanceCount.ref.value,1,()=>rc,!1,()=>!1),theme:{color:f0(0,{value:s,lightness:0,saturation:0}),size:e5(0,{value:a})}}},e.createValues=function n(s,a){const c=gm.getClip(s.clip);return{alpha:k.create(s.alpha),uAlpha:k.create(s.alpha),uVertexCount:k.create(a.vertexCount),uGroupCount:k.create(a.groupCount),drawCount:k.create(a.drawCount),uMetalness:k.create(s.material.metalness),uRoughness:k.create(s.material.roughness),uBumpiness:k.create(s.material.bumpiness),dLightCount:k.create(1),dColorMarker:k.create(!0),dClipObjectCount:k.create(c.objects.count),dClipVariant:k.create(c.variant),uClipObjectType:k.create(c.objects.type),uClipObjectInvert:k.create(c.objects.invert),uClipObjectPosition:k.create(c.objects.position),uClipObjectRotation:k.create(c.objects.rotation),uClipObjectScale:k.create(c.objects.scale),instanceGranularity:k.create(s.instanceGranularity),uLod:k.create(nn.create(s.lod[0],s.lod[1],s.lod[2],0))}},e.updateValues=function r(s,a){k.updateIfChanged(s.alpha,a.alpha),k.updateIfChanged(s.uMetalness,a.material.metalness),k.updateIfChanged(s.uRoughness,a.material.roughness),k.updateIfChanged(s.uBumpiness,a.material.bumpiness);const c=gm.getClip(a.clip);k.updateIfChanged(s.dClipObjectCount,c.objects.count),k.updateIfChanged(s.dClipVariant,c.variant),k.update(s.uClipObjectType,c.objects.type),k.update(s.uClipObjectInvert,c.objects.invert),k.update(s.uClipObjectPosition,c.objects.position),k.update(s.uClipObjectRotation,c.objects.rotation),k.update(s.uClipObjectScale,c.objects.scale),k.updateIfChanged(s.instanceGranularity,a.instanceGranularity),k.update(s.uLod,nn.set(s.uLod.ref.value,a.lod[0],a.lod[1],a.lod[2],0))},e.createRenderableState=function i(s={}){const a=void 0===s.alpha||1===s.alpha;return{disposed:!1,visible:!0,alphaFactor:1,pickable:!0,colorOnly:!1,opaque:a,writeDepth:a}},e.updateRenderableState=function o(s,a){s.opaque=a.alpha*s.alphaFactor>=1,s.writeDepth=s.opaque}}(rt||(rt={}));const aie={array:new Uint8Array(4),width:1,height:1};function Dp(e){return e?(k.update(e.tOverpaint,aie),k.update(e.uOverpaintTexDim,Me.create(1,1)),e):{tOverpaint:k.create(aie),uOverpaintTexDim:k.create(Me.create(1,1)),dOverpaint:k.create(!1),tOverpaintGrid:k.create(Os()),uOverpaintGridDim:k.create(v.create(1,1,1)),uOverpaintGridTransform:k.create(nn.create(0,0,0,1)),dOverpaintType:k.create("groupInstance"),uOverpaintStrength:k.create(1)}}function Hje(e,t,n,r){for(let i=t;i=3*T?R.normalBuffer.ref.value:new Float32Array(3*T);F===R.normalBuffer.ref.value&&F.fill(0,0,3*T),dre(N,V,F,T,M),k.update(R.normalBuffer,F)},e.checkForDuplicateVertices=function a(R,T=3){const M=R.vertexBuffer.ref.value,N=new Map,V=(L,z)=>`${L[0].toFixed(z)}|${L[1].toFixed(z)}|${L[2].toFixed(z)}`;let F=0;const G=v();for(let L=0,z=R.vertexCount;L{const L=t2(F,G),z=N.get(L)||0;N.set(L,z+1)};for(let F=0;F{1===N&&(XZ(M,V),T.add(M[0]),T.add(M[1]))}),T}function h(R,T,M){const N=new Map,V=(F,G)=>{N.has(F)?eo(N.get(F),G):N.set(F,[G])};return T.forEach(F=>{const G=R[F];for(const L of G)T.has(L)&&1===M.get(t2(F,L))&&V(F,L)}),N}function y(R,T,M,N){var V;const{vertexBuffer:F,indexBuffer:G,normalBuffer:L,triangleCount:z}=R,j=F.ref.value,Z=G.ref.value,$=L.ref.value,ee=ze.create(Uint32Array,3,1024,z);let q=0;for(let de=0;deM.get(de).length<2).map(de=>{const we=M.get(de);return v.fromArray(O,j,3*de),v.fromArray(H,j,3*we[0]),v.fromArray(W,j,3*we[1]),v.sub(fe,H,O),v.sub(X,W,O),[de,v.angle(fe,X)]});K.sort(([,de],[,we])=>de-we);for(const[de,we]of K){if(oe.has(de)||we>me)continue;const Le=M.get(de);if(T[Le[0]].includes(Le[1])&&(null===(V=M.get(Le[0]))||void 0===V||!V.includes(Le[1]))||(v.fromArray(O,j,3*de),v.fromArray(H,j,3*Le[0]),v.fromArray(W,j,3*Le[1]),v.sub(fe,H,O),v.sub(X,W,O),v.add(ce,fe,X),v.squaredDistance(O,H)>=N))continue;let We=!1;for(const U of T[de])if(!Le.includes(U)&&(v.fromArray(Q,j,3*U),v.sub(J,Q,O),v.dot(ce,J)<0)){We=!0;break}We&&(v.fromArray(be,$,3*de),v.triangleNormal(ae,O,H,W),v.dot(ae,be)>0?ze.add3(ee,de,Le[0],Le[1]):ze.add3(ee,Le[1],Le[0],de),oe.add(de),oe.add(Le[0]),oe.add(Le[1]),q+=1)}const ne=ze.compact(ee);return R.triangleCount=q,k.update(G,ne),R}function _(R,T){const M=R.vertexCount,N=T.instanceCount.ref.value,V=mm(),F=V.position,G=R.vertexBuffer.ref.value,L=T.aTransform.ref.value;return Mr(M,N,1,(j,Z)=>(Z<0?v.fromArray(F,G,3*j):v.transformMat4Offset(F,G,L,0,3*j,16*Z),V))}function S(R,T,M,N,V){const{instanceCount:F,groupCount:G}=M,z=bu(M,_(R,T),N.color),j=V.instanceGranularity?Vi(F,"instance"):Vi(F*G,"groupInstance"),Z=Dp(),$=Ep(),ee=Mp(),q=Pp(),O={drawCount:3*R.triangleCount,vertexCount:R.vertexCount,groupCount:G,instanceCount:F},H=_e.clone(R.boundingSphere),W=fs(H,T.aTransform.ref.value,F,0);return{dGeometryType:k.create("mesh"),aPosition:R.vertexBuffer,aNormal:R.normalBuffer,aGroup:R.groupBuffer,elements:R.indexBuffer,dVaryingGroup:R.varyingGroup,boundingSphere:k.create(W),invariantBoundingSphere:k.create(H),uInvariantBoundingSphere:k.create(nn.ofSphere(H)),...z,...j,...Z,...$,...ee,...q,...T,...rt.createValues(V,O),uDoubleSided:k.create(V.doubleSided),dFlatShaded:k.create(V.flatShaded),dFlipSided:k.create(V.flipSided),dIgnoreLight:k.create(V.ignoreLight),dXrayShaded:k.create("inverted"===V.xrayShaded?"inverted":!0===V.xrayShaded?"on":"off"),dTransparentBackfaces:k.create(V.transparentBackfaces),uBumpFrequency:k.create(V.bumpFrequency),uBumpAmplitude:k.create(V.bumpAmplitude),meta:k.create(R.meta)}}function I(R,T){rt.updateRenderableState(R,T),R.opaque=R.opaque&&!T.xrayShaded,R.writeDepth=R.opaque}e.transform=function u(R,T){const M=R.vertexBuffer.ref.value;l0(T,M,0,R.vertexCount),le.isTranslationAndUniformScaling(T)||function Qze(e,t,n,r){for(let i=0,o=3*r;i{const q=R.vertexBuffer.ref.value;Z.set(q),T.forEach((H,W)=>{if(2!==H.length)return;v.fromArray(F,q,3*W),v.fromArray(G,q,3*H[0]),v.fromArray(L,q,3*H[1]);const Q=1/v.distance(F,G),fe=1/v.distance(F,L);v.scale(G,G,Q),v.scale(L,L,fe),v.add(z,G,L),v.scale(z,z,1/(Q+fe)),v.sub(z,z,F),v.scale(z,z,ee),v.add(z,F,z),v.toArray(z,Z,3*W)});const O=R.vertexBuffer.ref.value;k.update(R.vertexBuffer,Z),Z=O};for(let ee=0;ee{v.toArray(a,n,o),v.toArray(c,n,o+3),v.toArray(u,n,o+6),v.triangleNormal(xD,a,c,u);for(let l=0;l<3;++l)v.toArray(xD,r,o+3*l),i[s+l]=o/3+l;o+=9,s+=3},addQuad:(a,c,u,l)=>{v.toArray(a,n,o),v.toArray(c,n,o+3),v.toArray(u,n,o+6),v.toArray(l,n,o+9),v.triangleNormal(xD,a,c,u);for(let f=0;f<4;++f)v.toArray(xD,r,o+3*f);const d=o/3;i[s]=d,i[s+1]=d+1,i[s+2]=d+2,i[s+3]=d+2,i[s+4]=d+3,i[s+5]=d,o+=12,s+=6},getPrimitive:()=>({vertices:n,normals:r,indices:i})}}const _v=v(),tHe=Kt();function n5(e,t){const{vertices:n,normals:r}=e,i=Kt.directionTransform(tHe,t);for(let o=0,s=n.length;o{t.push(r(i),r(o),r(s))}}}(),{vertices:s,indices:a}=o;(function u(d){const f=v(),p=v(),m=v();for(let h=0;h0&&y(!0),a&&n>0&&y(!1),{vertices:new Float32Array(d),normals:new Float32Array(f),indices:new Uint32Array(l)};function y(b){const x=!0===b?t:n,_=!0===b?1:-1,S=p;for(let E=1;E<=i;++E)d.push(0,h*_,0),f.push(0,_,0),++p;const A=p;for(let E=0;E<=i;++E){const D=E/i*u+c,I=Math.cos(D),R=Math.sin(D);d.push(x*R,h*_,x*I),f.push(0,_,0),++p}for(let E=0;E(w<0?v.fromArray(x,_,3*E):v.transformMat4Offset(x,_,S,0,3*E,16*w),b))}function c(m,h,g,y,b){const{instanceCount:x,groupCount:_}=g,A=bu(g,a(m,h),y.color),E=kp(g,y.size),w=b.instanceGranularity?Vi(x,"instance"):Vi(x*_,"groupInstance"),D=Dp(),I=Ep(),R=Mp(),T=Pp(),M={drawCount:m.pointCount,vertexCount:m.pointCount,groupCount:_,instanceCount:x},N=_e.clone(m.boundingSphere),V=fs(N,h.aTransform.ref.value,x,0);return{dGeometryType:k.create("points"),aPosition:m.centerBuffer,aGroup:m.groupBuffer,boundingSphere:k.create(V),invariantBoundingSphere:k.create(N),uInvariantBoundingSphere:k.create(nn.ofSphere(N)),...A,...E,...w,...D,...I,...R,...T,...h,...rt.createValues(b,M),uSizeFactor:k.create(b.sizeFactor),dPointSizeAttenuation:k.create(b.pointSizeAttenuation),dPointStyle:k.create(b.pointStyle)}}function p(m,h){rt.updateRenderableState(m,h),m.opaque=m.opaque&&"fuzzy"!==h.pointStyle,m.writeDepth=m.opaque}e.create=t,e.createEmpty=n,e.transform=function s(m,h){const g=m.centerBuffer.ref.value;l0(h,g,0,m.pointCount),k.update(m.centerBuffer,g)},e.StyleTypes={square:"Square",circle:"Circle",fuzzy:"Fuzzy"},e.StyleTypeNames=Object.keys(e.StyleTypes),e.Params={...rt.Params,sizeFactor:C.Numeric(3,{min:0,max:10,step:.1}),pointSizeAttenuation:C.Boolean(!1),pointStyle:C.Select("square",C.objectToOptions(e.StyleTypes))},e.Utils={Params:e.Params,createEmpty:n,createValues:c,createValuesSimple:function u(m,h,g,y,b){const x=rt.createSimple(g,y,b),_={...C.getDefaultValues(e.Params),...h};return c(m,x.transform,x.locationIterator,x.theme,_)},updateValues:function l(m,h){rt.updateValues(m,h),k.updateIfChanged(m.uSizeFactor,h.sizeFactor),k.updateIfChanged(m.dPointSizeAttenuation,h.pointSizeAttenuation),k.updateIfChanged(m.dPointStyle,h.pointStyle)},updateBoundingSphere:function d(m,h){const g=_e.clone(h.boundingSphere),y=fs(g,m.aTransform.ref.value,m.instanceCount.ref.value,0);_e.equals(y,m.boundingSphere.ref.value)||k.update(m.boundingSphere,y),_e.equals(g,m.invariantBoundingSphere.ref.value)||(k.update(m.invariantBoundingSphere,g),k.update(m.uInvariantBoundingSphere,nn.fromSphere(m.uInvariantBoundingSphere.ref.value,g)))},createRenderableState:function f(m){const h=rt.createRenderableState(m);return p(h,m),h},updateRenderableState:p,createPositionIterator:a}}(ym||(ym={}));const b5={},Fie={fontFamily:C.Select("sans-serif",[["sans-serif","Sans Serif"],["monospace","Monospace"],["serif","Serif"],["cursive","Cursive"]]),fontQuality:C.Select(3,[[0,"lower"],[1,"low"],[2,"medium"],[3,"high"],[4,"higher"]]),fontStyle:C.Select("normal",[["normal","Normal"],["italic","Italic"],["oblique","Oblique"]]),fontVariant:C.Select("normal",[["normal","Normal"],["small-caps","Small Caps"]]),fontWeight:C.Select("normal",[["normal","Normal"],["bold","Bold"]])};class MHe{constructor(t={}){this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.5;const n={...C.getDefaultValues(Fie),...t};this.props=n;const r=32*(n.fontQuality+1);this.buffer=r/8,this.radius=r/3,this.lineHeight=Math.round(r+2*this.buffer+this.radius),this.maxWidth=Math.round(.75*this.lineHeight),this.texture=Po(350*this.lineHeight*this.maxWidth,1,Uint8Array),this.scratchContext=function kHe(e,t,n){if(qg)return function RHe(){throw new Error("When running in Node.js and wanting to use Canvas API, call mol-util/data-source's setCanvasModule function first and pass imported `canvas` module to it.")}().createCanvas(e,t).getContext("2d",n);{const r=document.createElement("canvas");return r.width=e,r.height=t,r.getContext("2d",n)}}(this.maxWidth,this.lineHeight,{willReadFrequently:!0}),this.scratchContext.font=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${r}px ${n.fontFamily}`,this.scratchContext.fillStyle="black",this.scratchContext.textBaseline="middle",this.scratchData=new Uint8Array(this.lineHeight*this.maxWidth),this.gridOuter=new Float64Array(this.lineHeight*this.maxWidth),this.gridInner=new Float64Array(this.lineHeight*this.maxWidth),this.f=new Float64Array(Math.max(this.lineHeight,this.maxWidth)),this.d=new Float64Array(Math.max(this.lineHeight,this.maxWidth)),this.z=new Float64Array(Math.max(this.lineHeight,this.maxWidth)+1),this.v=new Int16Array(Math.max(this.lineHeight,this.maxWidth)),this.middle=Math.ceil(this.lineHeight/2),this.placeholder=this.get("\ufffd")}get(t){if(void 0===this.mapped[t]){this.draw(t);const{array:n,width:r,height:i}=this.texture,o=this.scratchData;if(this.currentX+this.scratchW>r&&(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(let s=0;si&&(i=u);const l=Math.abs(e[c+1]);l>i&&(i=l);const d=Math.abs(t[s]);d>o&&(o=d)}return Math.max(o,r+r*i)}!function(e){function t(p,m,h,g,y,b,x,_,S){return S?function o(p,m,h,g,y,b,x,_,S){return S.charCount=_,k.update(S.fontTexture,p),k.update(S.centerBuffer,m),k.update(S.mappingBuffer,h),k.update(S.depthBuffer,g),k.update(S.indexBuffer,y),k.update(S.groupBuffer,b),k.update(S.tcoordBuffer,x),S}(p,m,h,g,y,b,x,_,S):function i(p,m,h,g,y,b,x,_){const S=_e();let A,E=-1,w=-1;const D={kind:"text",charCount:_,fontTexture:k.create(p),centerBuffer:k.create(m),mappingBuffer:k.create(h),depthBuffer:k.create(g),indexBuffer:k.create(y),groupBuffer:k.create(b),tcoordBuffer:k.create(x),get boundingSphere(){const I=r(D);if(I!==E){const R=Ip(D.centerBuffer.ref.value,4*D.charCount,4);_e.copy(S,R),E=I}return S},get groupMapping(){return D.groupBuffer.ref.version!==w&&(A=yv(D.groupBuffer.ref.value,D.charCount,4),w=D.groupBuffer.ref.version),A},setBoundingSphere(I){_e.copy(S,I),E=r(D)}};return D}(p,m,h,g,y,b,x,_)}function n(p){return t(p?p.fontTexture.ref.value:Po(0,1,Uint8Array),p?p.centerBuffer.ref.value:new Float32Array(0),p?p.mappingBuffer.ref.value:new Float32Array(0),p?p.depthBuffer.ref.value:new Float32Array(0),p?p.indexBuffer.ref.value:new Uint32Array(0),p?p.groupBuffer.ref.value:new Float32Array(0),p?p.tcoordBuffer.ref.value:new Float32Array(0),0,p)}function r(p){return ha([p.charCount,p.fontTexture.ref.version,p.centerBuffer.ref.version,p.mappingBuffer.ref.version,p.depthBuffer.ref.version,p.indexBuffer.ref.version,p.groupBuffer.ref.version,p.tcoordBuffer.ref.version])}function s(p,m){const h=4*p.charCount,g=m.instanceCount.ref.value,y=mm(),b=y.position,x=p.centerBuffer.ref.value,_=m.aTransform.ref.value;return Mr(h,g,4,(A,E)=>(E<0?v.fromArray(b,x,3*A):v.transformMat4Offset(b,x,_,0,3*A,16*E),y))}function a(p,m,h,g,y){const{instanceCount:b,groupCount:x}=h,S=bu(h,s(p,m),g.color),A=kp(h,g.size),E=y.instanceGranularity?Vi(b,"instance"):Vi(b*x,"groupInstance"),w=Dp(),D=Ep(),I=Mp(),R=Pp(),T={drawCount:2*p.charCount*3,vertexCount:4*p.charCount,groupCount:x,instanceCount:b},M=Bie(p.mappingBuffer.ref.value,p.depthBuffer.ref.value,p.charCount,gS(A)),N=_e.expand(_e(),p.boundingSphere,M),V=fs(N,m.aTransform.ref.value,b,0);return{dGeometryType:k.create("text"),aPosition:p.centerBuffer,aMapping:p.mappingBuffer,aDepth:p.depthBuffer,aGroup:p.groupBuffer,elements:p.indexBuffer,boundingSphere:k.create(V),invariantBoundingSphere:k.create(N),uInvariantBoundingSphere:k.create(nn.ofSphere(N)),...S,...A,...E,...w,...D,...I,...R,...m,aTexCoord:p.tcoordBuffer,tFont:p.fontTexture,padding:k.create(M),...rt.createValues(y,T),uSizeFactor:k.create(y.sizeFactor),uBorderWidth:k.create(os(y.borderWidth,0,.5)),uBorderColor:k.create(st.toArrayNormalized(y.borderColor,v.zero(),0)),uOffsetX:k.create(y.offsetX),uOffsetY:k.create(y.offsetY),uOffsetZ:k.create(y.offsetZ),uBackgroundColor:k.create(st.toArrayNormalized(y.backgroundColor,v.zero(),0)),uBackgroundOpacity:k.create(y.backgroundOpacity)}}function f(p,m){rt.updateRenderableState(p,m),p.pickable=!1,p.opaque=!1,p.writeDepth=!0}e.create=t,e.createEmpty=n,e.Params={...rt.Params,...Fie,sizeFactor:C.Numeric(1,{min:0,max:10,step:.1}),borderWidth:C.Numeric(0,{min:0,max:.5,step:.01}),borderColor:C.Color(xn.grey),offsetX:C.Numeric(0,{min:0,max:10,step:.1}),offsetY:C.Numeric(0,{min:0,max:10,step:.1}),offsetZ:C.Numeric(0,{min:0,max:10,step:.1}),background:C.Boolean(!1),backgroundMargin:C.Numeric(.2,{min:0,max:1,step:.01}),backgroundColor:C.Color(xn.grey),backgroundOpacity:C.Numeric(1,{min:0,max:1,step:.01}),tether:C.Boolean(!1),tetherLength:C.Numeric(1,{min:0,max:5,step:.1}),tetherBaseWidth:C.Numeric(.3,{min:0,max:1,step:.01}),attachment:C.Select("middle-center",[["bottom-left","bottom-left"],["bottom-center","bottom-center"],["bottom-right","bottom-right"],["middle-left","middle-left"],["middle-center","middle-center"],["middle-right","middle-right"],["top-left","top-left"],["top-center","top-center"],["top-right","top-right"]])},e.Utils={Params:e.Params,createEmpty:n,createValues:a,createValuesSimple:function c(p,m,h,g,y){const b=rt.createSimple(h,g,y),x={...C.getDefaultValues(e.Params),...m};return a(p,b.transform,b.locationIterator,b.theme,x)},updateValues:function u(p,m){rt.updateValues(p,m),k.updateIfChanged(p.uSizeFactor,m.sizeFactor),k.updateIfChanged(p.uBorderWidth,m.borderWidth),st.fromNormalizedArray(p.uBorderColor.ref.value,0)!==m.borderColor&&(st.toArrayNormalized(m.borderColor,p.uBorderColor.ref.value,0),k.update(p.uBorderColor,p.uBorderColor.ref.value)),k.updateIfChanged(p.uOffsetX,m.offsetX),k.updateIfChanged(p.uOffsetY,m.offsetY),k.updateIfChanged(p.uOffsetZ,m.offsetZ),st.fromNormalizedArray(p.uBackgroundColor.ref.value,0)!==m.backgroundColor&&(st.toArrayNormalized(m.backgroundColor,p.uBackgroundColor.ref.value,0),k.update(p.uBackgroundColor,p.uBackgroundColor.ref.value)),k.updateIfChanged(p.uBackgroundOpacity,m.backgroundOpacity)},updateBoundingSphere:function l(p,m){const h=Bie(p.aMapping.ref.value,p.aDepth.ref.value,m.charCount,gS(p)),g=_e.expand(_e(),m.boundingSphere,h),y=fs(g,p.aTransform.ref.value,p.instanceCount.ref.value,0);_e.equals(y,p.boundingSphere.ref.value)||k.update(p.boundingSphere,y),_e.equals(g,p.invariantBoundingSphere.ref.value)||(k.update(p.invariantBoundingSphere,g),k.update(p.uInvariantBoundingSphere,nn.fromSphere(p.uInvariantBoundingSphere.ref.value,g))),k.update(p.padding,h)},createRenderableState:function d(p){const m=rt.createRenderableState(p);return f(m,p),m},updateRenderableState:f,createPositionIterator:s}}(vu||(vu={}));const ic=v(),fd=v(),yS=v(),Oie=ze.add,DD=ze.add3;var Fc,di;!function(e){e.create=function t(n=2048,r=1024,i){const o=ze.create(Float32Array,1,r,i?i.groupBuffer.ref.value:n),s=ze.create(Float32Array,3,r,i?i.startBuffer.ref.value:n),a=ze.create(Float32Array,3,r,i?i.endBuffer.ref.value:n),c=(d,f,p,m,h,g,y)=>{for(let b=0;b<4;++b)DD(s,d,f,p),DD(a,m,h,g),Oie(o,y)},l=(d,f,p,m)=>{const h=v.distance(d,f),g=p%2!=0,y=Math.floor((p+1)/2),b=h/(p+.5);v.setMagnitude(yS,v.sub(yS,f,d),b),v.copy(ic,d);for(let x=0;x{for(let m=0;m<4;++m)DD(s,d[0],d[1],d[2]),DD(a,f[0],f[1],f[2]),Oie(o,p)},addFixedCountDashes:l,addFixedLengthDashes:(d,f,p,m)=>{const h=v.distance(d,f);l(d,f,h/p,m)},addCage:(d,f,p)=>{const{vertices:m,edges:h}=f;for(let g=0,y=h.length;g{const d=o.elementCount/4,f=ze.compact(o,!0),p=ze.compact(s,!0),m=ze.compact(a,!0),h=i&&d<=i.lineCount?i.mappingBuffer.ref.value:new Float32Array(8*d),g=i&&d<=i.lineCount?i.indexBuffer.ref.value:new Uint32Array(6*d);return(!i||d>i.lineCount)&&function NHe(e,t,n){for(let r=0;rx.lineCount&&(k.update(x.mappingBuffer,p),k.update(x.indexBuffer,m)),x.lineCount=b,k.update(x.groupBuffer,h),k.update(x.startBuffer,g),k.update(x.endBuffer,y),x}(p,m,h,g,y,b,x):function o(p,m,h,g,y,b){const x=_e();let _,S=-1,A=-1;const E={kind:"lines",lineCount:b,mappingBuffer:k.create(p),indexBuffer:k.create(m),groupBuffer:k.create(h),startBuffer:k.create(g),endBuffer:k.create(y),get boundingSphere(){const w=i(E);if(w!==S){const D=Ip(E.startBuffer.ref.value,4*E.lineCount,4),I=Ip(E.endBuffer.ref.value,4*E.lineCount,4);_e.expandBySphere(x,D,I),S=w}return x},get groupMapping(){return E.groupBuffer.ref.version!==A&&(_=yv(E.groupBuffer.ref.value,E.lineCount,4),A=E.groupBuffer.ref.version),_},setBoundingSphere(w){_e.copy(x,w),S=i(E)}};return E}(p,m,h,g,y,b)}function n(p){return t(p?p.mappingBuffer.ref.value:new Float32Array(0),p?p.indexBuffer.ref.value:new Uint32Array(0),p?p.groupBuffer.ref.value:new Float32Array(0),p?p.startBuffer.ref.value:new Float32Array(0),p?p.endBuffer.ref.value:new Float32Array(0),0,p)}function i(p){return ha([p.lineCount,p.mappingBuffer.ref.version,p.indexBuffer.ref.version,p.groupBuffer.ref.version,p.startBuffer.ref.version,p.endBuffer.ref.version])}function c(p,m){const h=4*p.lineCount,g=m.instanceCount.ref.value,y=mm(),b=y.position,x=p.startBuffer.ref.value,_=p.endBuffer.ref.value,S=m.aTransform.ref.value;return Mr(h,g,2,(E,w)=>{const D=E%4==0?x:_;return w<0?v.fromArray(b,D,3*E):v.transformMat4Offset(b,D,S,0,3*E,16*w),y})}function u(p,m,h,g,y){const{instanceCount:b,groupCount:x}=h,S=bu(h,c(p,m),g.color),A=kp(h,g.size),E=y.instanceGranularity?Vi(b,"instance"):Vi(b*x,"groupInstance"),w=Dp(),D=Ep(),I=Mp(),R=Pp(),T={drawCount:2*p.lineCount*3,vertexCount:4*p.lineCount,groupCount:x,instanceCount:b},M=_e.clone(p.boundingSphere),N=fs(M,m.aTransform.ref.value,b,0);return{dGeometryType:k.create("lines"),aMapping:p.mappingBuffer,aGroup:p.groupBuffer,aStart:p.startBuffer,aEnd:p.endBuffer,elements:p.indexBuffer,boundingSphere:k.create(N),invariantBoundingSphere:k.create(M),uInvariantBoundingSphere:k.create(nn.ofSphere(M)),...S,...A,...E,...w,...D,...I,...R,...m,...rt.createValues(y,T),uSizeFactor:k.create(y.sizeFactor),dLineSizeAttenuation:k.create(y.lineSizeAttenuation),uDoubleSided:k.create(!0),dFlipSided:k.create(!1)}}e.create=t,e.createEmpty=n,e.fromMesh=function r(p,m){const h=p.vertexBuffer.ref.value,g=p.indexBuffer.ref.value,y=p.groupBuffer.ref.value,b=Fc.create(3*p.triangleCount,p.triangleCount/10,m);for(let x=0,_=3*p.triangleCount;x<_;x+=3){const S=g[x],A=g[x+1],E=g[x+2],w=h[3*S],D=h[3*S+1],I=h[3*S+2],R=h[3*A],T=h[3*A+1],M=h[3*A+2],N=h[3*E],V=h[3*E+1],F=h[3*E+2];b.add(w,D,I,R,T,M,y[S]),b.add(w,D,I,N,V,F,y[S]),b.add(R,T,M,N,V,F,y[A])}return b.getLines()},e.transform=function a(p,m){const h=p.startBuffer.ref.value;l0(m,h,0,4*p.lineCount),k.update(p.startBuffer,h);const g=p.endBuffer.ref.value;l0(m,g,0,4*p.lineCount),k.update(p.endBuffer,g)},e.Params={...rt.Params,sizeFactor:C.Numeric(2,{min:0,max:10,step:.1}),lineSizeAttenuation:C.Boolean(!1)},e.Utils={Params:e.Params,createEmpty:n,createValues:u,createValuesSimple:function l(p,m,h,g,y){const b=rt.createSimple(h,g,y),x={...C.getDefaultValues(e.Params),...m};return u(p,b.transform,b.locationIterator,b.theme,x)},updateValues:function d(p,m){rt.updateValues(p,m),k.updateIfChanged(p.uSizeFactor,m.sizeFactor),k.updateIfChanged(p.dLineSizeAttenuation,m.lineSizeAttenuation)},updateBoundingSphere:function f(p,m){const h=_e.clone(m.boundingSphere),g=fs(h,p.aTransform.ref.value,p.instanceCount.ref.value,0);_e.equals(g,p.boundingSphere.ref.value)||k.update(p.boundingSphere,g),_e.equals(h,p.invariantBoundingSphere.ref.value)||(k.update(p.invariantBoundingSphere,h),k.update(p.uInvariantBoundingSphere,nn.fromSphere(p.uInvariantBoundingSphere.ref.value,h)))},createRenderableState:rt.createRenderableState,updateRenderableState:rt.updateRenderableState,createPositionIterator:c}}(di||(di={}));const Np=v(),Fp=v(),Bp=v(),Av=v(),ao=hf(4,!0);function Lie(e){const r=vv(12,e?36:24);for(let i=0;i<4;++i){const o=(i+1)%4;v.set(Np,ao[3*i],ao[3*i+1],-.5),v.set(Fp,ao[3*o],ao[3*o+1],-.5),v.set(Bp,ao[3*o],ao[3*o+1],.5),v.set(Av,ao[3*i],ao[3*i+1],.5),e?r.add(Np,Fp,Bp):r.addQuad(Np,Fp,Bp,Av)}return v.set(Np,ao[0],ao[1],-.5),v.set(Fp,ao[3],ao[4],-.5),v.set(Bp,ao[6],ao[7],-.5),v.set(Av,ao[9],ao[10],-.5),e?r.add(Bp,Fp,Np):r.addQuad(Av,Bp,Fp,Np),v.set(Np,ao[0],ao[1],.5),v.set(Fp,ao[3],ao[4],.5),v.set(Bp,ao[6],ao[7],.5),v.set(Av,ao[9],ao[10],.5),e?r.add(Np,Fp,Bp):r.addQuad(Np,Fp,Bp,Av),r.getPrimitive()}let _5,S5,C5;function x5(){return _5||(_5=Lie(!1)),_5}function Uie(){return C5||(C5=fS([.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])),C5}function Vie(e){return e.map(t=>({x:t[0],alpha:t[1]}))}function zie(e,t){const n=[{x:0,alpha:0},{x:0,alpha:0},...e,{x:1,alpha:0},{x:1,alpha:0}],i=t?t.ref.value.array:new Uint8Array(256);let s,a,c,u,l,d,o=0;const f=e.length+1;for(let m=0;m=t?c=t-1:c<0&&(c=0),o[c]++}return{min:n,max:r,binWidth:i,counts:o}}var Ko,ED,MD,et;function jie(e,t){return Oe.create("Create Volume",function(){var n=ie(function*(r){const{volume_data_3d_info:i,volume_data_3d:o}=e,s=ma.create(i.spacegroup_number.value(0),v.ofArray(i.spacegroup_cell_size.value(0)),v.scale(v.zero(),v.ofArray(i.spacegroup_cell_angles.value(0)),Math.PI/180)),a=i.axis_order.value(0),c=wn.convertToCanonicalAxisIndicesFastToSlow(a),u=c(i.sample_count.value(0)),l=wn.Space(u,wn.invertAxisOrder(a),Float32Array),d=wn.create(l,wn.Data1(o.values.toArray({array:Float32Array}))),f=v.ofArray(c(i.origin.value(0))),p=v.ofArray(c(i.dimensions.value(0)));return{label:t?.label,entryId:t?.entryId,grid:{transform:{kind:"spacegroup",cell:s,fractionalBox:St.create(f,v.add(v.zero(),f,p))},cells:d,stats:{min:i.min_sampled.value(0),max:i.max_sampled.value(0),mean:i.mean_sampled.value(0),sigma:i.sigma_sampled.value(0)}},sourceData:MD.create(e),customProperties:new Ql,_propertyData:Object.create(null)}});return function(r){return n.apply(this,arguments)}}())}!function(e){e.One={transform:{kind:"matrix",matrix:le.identity()},cells:wn.create(wn.Space([1,1,1],[0,1,2]),wn.Data1([0])),stats:{min:0,max:0,mean:0,sigma:0}};const t=le.zero(),n=le.zero();e.getGridToCartesianTransform=function r(c){if("matrix"===c.transform.kind)return le.copy(le(),c.transform.matrix);if("spacegroup"===c.transform.kind){const{cells:{space:u}}=c,l=le.fromScaling(t,v.div(v.zero(),St.size(v.zero(),c.transform.fractionalBox),v.ofArray(u.dimensions))),d=le.fromTranslation(n,c.transform.fractionalBox.min);return le.mul3(le.zero(),c.transform.cell.fromFractional,d,l)}return le.identity()},e.areEquivalent=function i(c,u){return c===u},e.isEmpty=function o(c){return 0===c.cells.data.length},e.getBoundingSphere=function s(c,u){u||(u=_e());const l=c.cells.space.dimensions,d=e.getGridToCartesianTransform(c);return _e.fromDimensionsAndTransform(u,l,d)},e.getHistogram=function a(c,u){let l=c._historams;return l||(l=c._historams={}),l[u]||(l[u]=function BHe(e,t,n){if(n)return Gie(e,t,n.min,n.max);{const[r,i]=cu(e);return Gie(e,t,r,i)}}(c.cells.data,u,{min:c.stats.min,max:c.stats.max})),l[u]}}(Ko||(Ko={})),function(e){e.is=function t(r){return"cube"===r?.kind},e.create=function n(r){return{kind:"cube",name:r.name,data:r}}}(ED||(ED={})),function(e){e.is=function t(r){return"dscif"===r?.kind},e.create=function n(r){return{kind:"dscif",name:r._name,data:r}}}(MD||(MD={})),function(e){let n;e.is=function t(y){var b,x,_,S;return(null===(S=null===(_=null===(x=null===(b=y?.grid)||void 0===b?void 0:b.cells)||void 0===x?void 0:x.space)||void 0===_?void 0:_.dimensions)||void 0===S?void 0:S.length)&&y?.sourceData&&y?.customProperties&&y?._propertyData},function(y){function E(I,R){return"absolute"===I.kind?I:{kind:"absolute",absoluteValue:y.calcAbsolute(R,I.relativeValue)}}y.areSame=function b(I,R,T){return ai(E(I,T).absoluteValue,E(R,T).absoluteValue,T.sigma/100)},y.absolute=function x(I){return{kind:"absolute",absoluteValue:I}},y.relative=function _(I){return{kind:"relative",relativeValue:I}},y.calcAbsolute=function S(I,R){return R*I.sigma+I.mean},y.calcRelative=function A(I,R){return 0===I.sigma?0:(R-I.mean)/I.sigma},y.toAbsolute=E,y.toRelative=function w(I,R){return"relative"===I.kind?I:{kind:"relative",relativeValue:y.calcRelative(R,I.absoluteValue)}},y.toString=function D(I){return"relative"===I.kind?`${I.relativeValue.toFixed(2)} \u03c3`:`${I.absoluteValue.toPrecision(4)}`}}(n=e.IsoValue||(e.IsoValue={})),e.adjustedIsoValue=function r(y,b,x){if("relative"===x)return n.relative(b);const _=n.absolute(b);if(MD.is(y.sourceData)){const S={min:y.sourceData.data.volume_data_3d_info.min_source.value(0),max:y.sourceData.data.volume_data_3d_info.max_source.value(0),mean:y.sourceData.data.volume_data_3d_info.mean_source.value(0),sigma:y.sourceData.data.volume_data_3d_info.sigma_source.value(0)};return e.IsoValue.toRelative(_,S)}return _};const i={min:-1,max:1,mean:0,sigma:.1};function o(y,b){const x=b||i,{min:_,max:S,mean:A,sigma:E}=x,w=(_-A)/E,D=(S-A)/E;let I=y;return"absolute"===y.kind?y.absoluteValue<_?I=e.IsoValue.absolute(_):y.absoluteValue>S&&(I=e.IsoValue.absolute(S)):y.relativeValueD&&(I=e.IsoValue.relative(D)),C.Conditioned(I,{absolute:C.Converted(R=>e.IsoValue.toAbsolute(R,Ko.One.stats).absoluteValue,R=>e.IsoValue.absolute(R),C.Numeric(A,{min:_,max:S,step:iJ(E/100,2)},{immediateUpdate:!0})),relative:C.Converted(R=>e.IsoValue.toRelative(R,Ko.One.stats).relativeValue,R=>e.IsoValue.relative(R),C.Numeric(Math.min(1,D),{min:w,max:D,step:iJ(Math.round((S-_)/E)/100,2)},{immediateUpdate:!0}))},R=>"absolute"===R.kind?"absolute":"relative",(R,T)=>"absolute"===T?e.IsoValue.toAbsolute(R,x):e.IsoValue.toRelative(R,x),{isEssential:!0})}let m,h,g;e.createIsoValueParam=o,e.IsoValueParam=o(e.IsoValue.relative(2)),e.One={label:"",grid:Ko.One,sourceData:{kind:"",name:"",data:{}},customProperties:new Ql,_propertyData:Object.create(null)},e.areEquivalent=function s(y,b){return Ko.areEquivalent(y.grid,b.grid)},e.isEmpty=function a(y){return Ko.isEmpty(y.grid)},e.isOrbitals=function c(y){return!!ED.is(y.sourceData)&&y.sourceData.data.header.orbitals},e.Loci=function u(y){return{kind:"volume-loci",volume:y}},e.isLoci=function l(y){return!!y&&"volume-loci"===y.kind},e.areLociEqual=function d(y,b){return y.volume===b.volume},e.isLociEmpty=function f(y){return Ko.isEmpty(y.volume.grid)},e.getBoundingSphere=function p(y,b){return Ko.getBoundingSphere(y.grid,b)},function(y){y.Loci=function b(w,D){return{kind:"isosurface-loci",volume:w,isoValue:D}},y.isLoci=function x(w){return!!w&&"isosurface-loci"===w.kind},y.areLociEqual=function _(w,D){return w.volume===D.volume&&e.IsoValue.areSame(w.isoValue,D.isoValue,w.volume.grid.stats)},y.isLociEmpty=function S(w){return 0===w.volume.grid.cells.data.length};const A=St();y.getBoundingSphere=function E(w,D,I){const R=e.IsoValue.toAbsolute(D,w.grid.stats).absoluteValue,T=R<0,M=[0,0,0],N=w.grid.cells.space.getCoords,V=w.grid.cells.data,[F,G,L]=w.grid.cells.space.dimensions;let z=F-1,j=G-1,Z=L-1,$=0,ee=0,q=0;for(let H=0,W=V.length;H=R)&&(N(H,M),M[0]$&&($=M[0]),M[1]>ee&&(ee=M[1]),M[2]>q&&(q=M[2]));v.set(A.min,z-1,j-1,Z-1),v.set(A.max,$+1,ee+1,q+1);const O=Ko.getGridToCartesianTransform(w.grid);return St.transform(A,A,O),_e.fromBox3D(I||_e(),A)}}(m=e.Isosurface||(e.Isosurface={})),function(y){y.Loci=function b(D,I){return{kind:"cell-loci",volume:D,indices:I}},y.isLoci=function x(D){return!!D&&"cell-loci"===D.kind},y.areLociEqual=function _(D,I){return D.volume===I.volume&&Fe.areEqual(D.indices,I.indices)},y.isLociEmpty=function S(D){return 0===Fe.size(D.indices)};const A=new fu("98"),E=v();y.getBoundingSphere=function w(D,I,R){A.reset();const T=Ko.getGridToCartesianTransform(D.grid),{getCoords:M}=D.grid.cells.space;for(let V=0,F=Fe.size(I);Vy._propertyData.__segmentation__}}(et||(et={}));const w5=x5();var _u,fl,xa;function Ar(e,t,n){return{type:"attribute",kind:e,itemSize:t,divisor:n}}function xe(e,t){return{type:"uniform",kind:e,variant:t}}function jt(e,t,n,r,i){return{type:"texture",kind:e,format:t,dataType:n,filter:r,variant:i}}function Iv(e){return{type:"elements",kind:e}}function Ft(e,t){return{type:"define",kind:e,options:t}}function ri(e){return{type:"value",kind:e}}!function(e){function t(g,y,b,x,_,S,A,E,w,D){return D?function i(g,y,b,x,_,S,A,E,w,D){const I=S.getWidth(),R=S.getHeight(),T=S.getDepth();return k.update(D.gridDimension,y),k.update(D.gridTexture,S),k.update(D.gridTextureDim,v.set(D.gridTextureDim.ref.value,I,R,T)),k.update(D.gridStats,nn.set(D.gridStats.ref.value,A.min,A.max,A.mean,A.sigma)),k.update(D.bboxMin,g.min),k.update(D.bboxMax,g.max),k.update(D.bboxSize,v.sub(D.bboxSize.ref.value,g.max,g.min)),k.update(D.transform,b),k.update(D.cellDim,_),k.update(D.unitToCartn,x),k.update(D.cartnToUnit,le.invert(le(),x)),k.updateIfChanged(D.packedGroup,E),k.updateIfChanged(D.axisOrder,v.fromArray(D.axisOrder.ref.value,w,0)),D}(g,y,b,x,_,S,A,E,w,D):function r(g,y,b,x,_,S,A,E,w){const D=_e();let I=-1;const R=S.getWidth(),T=S.getHeight(),M=S.getDepth(),N={kind:"direct-volume",gridDimension:k.create(y),gridTexture:k.create(S),gridTextureDim:k.create(v.create(R,T,M)),gridStats:k.create(nn.create(A.min,A.max,A.mean,A.sigma)),bboxMin:k.create(g.min),bboxMax:k.create(g.max),bboxSize:k.create(v.sub(v(),g.max,g.min)),transform:k.create(b),cellDim:k.create(_),unitToCartn:k.create(x),cartnToUnit:k.create(le.invert(le(),x)),get boundingSphere(){const V=n(N);if(V!==I){const F=function LHe(e,t){return _e.fromDimensionsAndTransform(_e(),e,t)}(N.gridDimension.ref.value,N.transform.ref.value);_e.copy(D,F),I=V}return D},packedGroup:k.create(E),axisOrder:k.create(w),setBoundingSphere(V){_e.copy(D,V),I=n(N)}};return N}(g,y,b,x,_,S,A,E,w)}function n(g){return ha([g.bboxSize.ref.version,g.gridDimension.ref.version,g.gridTexture.ref.version,g.transform.ref.version,g.gridStats.ref.version])}function o(g){return t(St(),v(),le.identity(),le.identity(),v(),Os(),Ko.One.stats,!1,v.create(0,1,2),g)}function a(g,y){return Math.ceil(v.magnitude(g)*y)}function c(g,y){return Math.min(...g)*(1/y)}function u(g){return 1/g}function l(g,y,b,x,_){const{gridTexture:S,gridTextureDim:A,gridStats:E}=g,{bboxSize:w,bboxMin:D,bboxMax:I,gridDimension:R,transform:T}=g,{instanceCount:M,groupCount:N}=b,F=bu(b,e.Utils.createPositionIterator(g,y),x.color),G=_.instanceGranularity?Vi(M,"instance"):Vi(M*N,"groupInstance"),L=Dp(),z=Ep(),j=Mp(),Z=Pp(),[$,ee,q]=R.ref.value,O={drawCount:w5.indices.length,vertexCount:$*ee*q,groupCount:N,instanceCount:M},H=_e.clone(g.boundingSphere),W=fs(H,y.aTransform.ref.value,M,0),fe=zie(Vie(_.controlPoints));return{dGeometryType:k.create("directVolume"),...F,...G,...L,...z,...j,...Z,...y,...rt.createValues(_,O),aPosition:k.create(w5.vertices),elements:k.create(w5.indices),boundingSphere:k.create(W),invariantBoundingSphere:k.create(H),uInvariantBoundingSphere:k.create(nn.ofSphere(H)),uBboxMin:D,uBboxMax:I,uBboxSize:w,uMaxSteps:k.create(a(R.ref.value,_.stepsPerCell)),uStepScale:k.create(c(g.cellDim.ref.value,_.stepsPerCell)),uJumpLength:k.create(_.jumpLength),uTransform:T,uGridDim:R,tTransferTex:fe,uTransferScale:k.create(u(_.stepsPerCell)),dGridTexType:k.create(S.ref.value.getDepth()>0?"3d":"2d"),uGridTexDim:A,tGridTex:S,uGridStats:E,uCellDim:g.cellDim,uCartnToUnit:g.cartnToUnit,uUnitToCartn:g.unitToCartn,dPackedGroup:g.packedGroup,dAxisOrder:k.create(g.axisOrder.ref.value.join("")),dIgnoreLight:k.create(_.ignoreLight),dXrayShaded:k.create("inverted"===_.xrayShaded?"inverted":!0===_.xrayShaded?"on":"off")}}e.create=t,e.createEmpty=o,e.Params={...rt.Params,ignoreLight:C.Boolean(!1,rt.ShadingCategory),xrayShaded:C.Select(!1,[[!1,"Off"],[!0,"On"],["inverted","Inverted"]],rt.ShadingCategory),controlPoints:C.LineGraph([Me.create(.19,0),Me.create(.2,.05),Me.create(.25,.05),Me.create(.26,0),Me.create(.79,0),Me.create(.8,.05),Me.create(.85,.05),Me.create(.86,0)],{isEssential:!0}),stepsPerCell:C.Numeric(3,{min:1,max:10,step:1}),jumpLength:C.Numeric(0,{min:0,max:20,step:.1})},e.Utils={Params:e.Params,createEmpty:o,createValues:l,createValuesSimple:function d(g,y,b,x,_){const S=rt.createSimple(b,x,_),A={...C.getDefaultValues(e.Params),...y};return l(g,S.transform,S.locationIterator,S.theme,A)},updateValues:function f(g,y){rt.updateValues(g,y),k.updateIfChanged(g.dIgnoreLight,y.ignoreLight),k.updateIfChanged(g.dXrayShaded,"inverted"===y.xrayShaded?"inverted":!0===y.xrayShaded?"on":"off"),zie(Vie(y.controlPoints),g.tTransferTex),k.updateIfChanged(g.uMaxSteps,a(g.uGridDim.ref.value,y.stepsPerCell)),k.updateIfChanged(g.uStepScale,c(g.uCellDim.ref.value,y.stepsPerCell)),k.updateIfChanged(g.uTransferScale,u(y.stepsPerCell)),k.updateIfChanged(g.uJumpLength,y.jumpLength)},updateBoundingSphere:function p(g,y){const b=_e.clone(y.boundingSphere),x=fs(b,g.aTransform.ref.value,g.instanceCount.ref.value,0);_e.equals(x,g.boundingSphere.ref.value)||k.update(g.boundingSphere,x),_e.equals(b,g.invariantBoundingSphere.ref.value)||(k.update(g.invariantBoundingSphere,b),k.update(g.uInvariantBoundingSphere,nn.fromSphere(g.uInvariantBoundingSphere.ref.value,b)))},createRenderableState:function m(g){const y=rt.createRenderableState(g);return y.opaque=!1,y.writeDepth=!1,y},updateRenderableState:function h(g,y){rt.updateRenderableState(g,y),g.opaque=!1,g.writeDepth=!1},createPositionIterator:function s(g,y){const b=g.transform.ref.value,[x,_,S]=g.gridDimension.ref.value,A=x*_*S,E=y.instanceCount.ref.value,w=mm(),D=w.position,I=y.aTransform.ref.value;return Mr(A,E,1,(T,M)=>{const N=Math.floor(T/S);return D[0]=Math.floor(N/_),D[1]=N%_,D[2]=T%S,v.transformMat4(D,D,b),M>=0&&v.transformMat4Offset(D,D,I,0,0,16*M),w})}}}(_u||(_u={})),function(e){function t(x,_,S,A){return A?function o(x,_,S,A){return A.sphereCount=S,k.update(A.centerBuffer,x),k.update(A.groupBuffer,_),A.shaderData.update(),A}(x,_,S,A):function i(x,_,S){const A=_e();let E,w=-1,D=-1;const I=k.create(Po(1,4,Float32Array)),R=k.create(Me.create(0,0)),T=k.create([]),M=k.create(0),N={kind:"spheres",sphereCount:S,centerBuffer:k.create(x),groupBuffer:k.create(_),get boundingSphere(){const V=r(N);if(V!==w){const F=Ip(N.centerBuffer.ref.value,4*N.sphereCount,4);_e.copy(A,F),w=V}return A},get groupMapping(){return N.groupBuffer.ref.version!==D&&(E=yv(N.groupBuffer.ref.value,N.sphereCount,4),D=N.groupBuffer.ref.version),E},setBoundingSphere(V){_e.copy(A,V),w=r(N)},shaderData:{positionGroup:I,texDim:R,lodLevels:T,sizeFactor:M,update(V){var F,G;const L=null!==(F=V?.lodLevels)&&void 0!==F?F:u(T.ref.value),z=null!==(G=V?.sizeFactor)&&void 0!==G?G:M.ref.value,j=d(L,z),Z=Po(N.sphereCount,4,Float32Array,I.ref.value.array),$=s(Z,N.centerBuffer.ref.value,N.groupBuffer.ref.value,N.sphereCount,j),ee=$?c(L,z,$,N.sphereCount):[];k.update(I,Z),k.update(R,Me.set(R.ref.value,Z.width,Z.height)),k.update(T,ee),k.update(M,z)}}};return N}(x,_,S)}function n(x){return t(x?x.centerBuffer.ref.value:new Float32Array(0),x?x.groupBuffer.ref.value:new Float32Array(0),0,x)}function r(x){return ha([x.sphereCount,x.centerBuffer.ref.version,x.groupBuffer.ref.version])}function s(x,_,S,A,E){const{array:w}=x;if(0===E.length){for(let R=0;R{const D=l(E,_);return[E.minDistance,E.maxDistance,E.overlap,S[S.length-1-w],Math.pow(Math.min(A,D),1/E.scaleBias),E.stride,E.scaleBias]})}function u(x){return x.map(_=>({minDistance:_[0],maxDistance:_[1],overlap:_[2],stride:_[5],scaleBias:_[6]}))}function l(x,_){return Math.max(1,Math.round(x.stride/Math.pow(_,x.scaleBias)))}function d(x,_){return x.map(S=>l(S,_)).reverse()}function f(x,_){const S=x.sphereCount,A=_.instanceCount.ref.value,E=mm(),w=E.position,D=x.centerBuffer.ref.value,I=_.aTransform.ref.value;return Mr(S,A,1,(T,M)=>(M<0?v.fromArray(w,D,3*T):v.transformMat4Offset(w,D,I,0,3*T,16*M),E))}function p(x,_,S,A,E){const{instanceCount:w,groupCount:D}=S,R=bu(S,f(x,_),A.color),T=kp(S,A.size),M=E.instanceGranularity?Vi(w,"instance"):Vi(w*D,"groupInstance"),N=Dp(),V=Ep(),F=Mp(),G=Pp(),L={drawCount:2*x.sphereCount*3,vertexCount:6*x.sphereCount,groupCount:D,instanceCount:w},z=x.boundingSphere.radius?gS(T)*E.sizeFactor:0,j=_e.expand(_e(),x.boundingSphere,z),Z=fs(j,_.aTransform.ref.value,w,0);return x.shaderData.update({lodLevels:E.lodLevels,sizeFactor:E.sizeFactor}),{dGeometryType:k.create("spheres"),uTexDim:x.shaderData.texDim,tPositionGroup:x.shaderData.positionGroup,boundingSphere:k.create(Z),invariantBoundingSphere:k.create(j),uInvariantBoundingSphere:k.create(nn.ofSphere(j)),...R,...T,...M,...N,...V,...F,...G,..._,padding:k.create(z),...rt.createValues(E,L),uSizeFactor:x.shaderData.sizeFactor,uDoubleSided:k.create(E.doubleSided),dIgnoreLight:k.create(E.ignoreLight),dXrayShaded:k.create("inverted"===E.xrayShaded?"inverted":!0===E.xrayShaded?"on":"off"),dTransparentBackfaces:k.create(E.transparentBackfaces),dSolidInterior:k.create(E.solidInterior),dClipPrimitive:k.create(E.clipPrimitive),dApproximate:k.create(E.approximate),uAlphaThickness:k.create(E.alphaThickness),uBumpFrequency:k.create(E.bumpFrequency),uBumpAmplitude:k.create(E.bumpAmplitude),lodLevels:x.shaderData.lodLevels,centerBuffer:x.centerBuffer,groupBuffer:x.groupBuffer}}function b(x,_){rt.updateRenderableState(x,_),x.opaque=x.opaque&&!_.xrayShaded,x.writeDepth=x.opaque}e.create=t,e.createEmpty=n,e.Params={...rt.Params,sizeFactor:C.Numeric(1,{min:0,max:10,step:.1}),doubleSided:C.Boolean(!1,rt.CustomQualityParamInfo),ignoreLight:C.Boolean(!1,rt.ShadingCategory),xrayShaded:C.Select(!1,[[!1,"Off"],[!0,"On"],["inverted","Inverted"]],rt.ShadingCategory),transparentBackfaces:C.Select("off",C.arrayToOptions(["off","on","opaque"]),rt.ShadingCategory),solidInterior:C.Boolean(!0,rt.ShadingCategory),clipPrimitive:C.Boolean(!1,{...rt.ShadingCategory,description:"Clip whole sphere instead of cutting it."}),approximate:C.Boolean(!1,{...rt.ShadingCategory,description:"Faster rendering, but has artifacts."}),alphaThickness:C.Numeric(0,{min:0,max:20,step:1},{...rt.ShadingCategory,description:"If not zero, adjusts alpha for radius."}),bumpFrequency:C.Numeric(0,{min:0,max:10,step:.1},rt.ShadingCategory),bumpAmplitude:C.Numeric(1,{min:0,max:5,step:.1},rt.ShadingCategory),lodLevels:C.ObjectList({minDistance:C.Numeric(0),maxDistance:C.Numeric(0),overlap:C.Numeric(0),stride:C.Numeric(0),scaleBias:C.Numeric(3,{min:.1,max:10,step:.1})},x=>`${x.stride}`,{...rt.CullingLodCategory,defaultValue:[]})},e.Utils={Params:e.Params,createEmpty:n,createValues:p,createValuesSimple:function m(x,_,S,A,E){const w=rt.createSimple(S,A,E),D={...C.getDefaultValues(e.Params),..._};return p(x,w.transform,w.locationIterator,w.theme,D)},updateValues:function h(x,_){rt.updateValues(x,_),k.updateIfChanged(x.uSizeFactor,_.sizeFactor),k.updateIfChanged(x.uDoubleSided,_.doubleSided),k.updateIfChanged(x.dIgnoreLight,_.ignoreLight),k.updateIfChanged(x.dXrayShaded,"inverted"===_.xrayShaded?"inverted":!0===_.xrayShaded?"on":"off"),k.updateIfChanged(x.dTransparentBackfaces,_.transparentBackfaces),k.updateIfChanged(x.dSolidInterior,_.solidInterior),k.updateIfChanged(x.dClipPrimitive,_.clipPrimitive),k.updateIfChanged(x.dApproximate,_.approximate),k.updateIfChanged(x.uAlphaThickness,_.alphaThickness),k.updateIfChanged(x.uBumpFrequency,_.bumpFrequency),k.updateIfChanged(x.uBumpAmplitude,_.bumpAmplitude);const S=u(x.lodLevels.ref.value);if(!function a(x,_){if(x.length!==_.length)return!1;for(let S=0,A=x.length;Src);m.namedFramebuffers[i]||(m.namedFramebuffers[i]=m.resources.framebuffer());const h=m.namedFramebuffers[i],[g,y]=f.geoTextureDim.ref.value,b=new Float32Array(g*y*4);h.bind(),f.vertexTexture.ref.value.attachFramebuffer(h,0),m.readPixels(0,0,g,y,b);const x=f.vertexCount,_=p.instanceCount.ref.value,S=mm(),A=S.position,E=b,w=p.aTransform.ref.value;return Mr(x,_,1,(I,R)=>(R<0?v.fromArray(A,E,4*I):v.transformMat4Offset(A,E,w,0,4*I,16*R),S))}};const i="texture-mesh";function s(f,p,m,h,g){const{instanceCount:y,groupCount:b}=m,_=bu(m,e.Utils.createPositionIterator(f,p),h.color),S=g.instanceGranularity?Vi(y,"instance"):Vi(y*b,"groupInstance"),A=Dp(),E=Ep(),w=Mp(),D=Pp(),I={drawCount:f.vertexCount,vertexCount:f.vertexCount,groupCount:b,instanceCount:y},R=_e.clone(f.boundingSphere),T=fs(R,p.aTransform.ref.value,y,0);return{dGeometryType:k.create("textureMesh"),uGeoTexDim:f.geoTextureDim,tPosition:f.vertexTexture,tGroup:f.groupTexture,tNormal:f.normalTexture,dVaryingGroup:f.varyingGroup,boundingSphere:k.create(T),invariantBoundingSphere:k.create(R),uInvariantBoundingSphere:k.create(nn.ofSphere(R)),..._,...S,...A,...E,...w,...D,...p,...rt.createValues(g,I),uDoubleSided:k.create(g.doubleSided),dFlatShaded:k.create(g.flatShaded),dFlipSided:k.create(g.flipSided),dIgnoreLight:k.create(g.ignoreLight),dXrayShaded:k.create("inverted"===g.xrayShaded?"inverted":!0===g.xrayShaded?"on":"off"),dTransparentBackfaces:k.create(g.transparentBackfaces),uBumpFrequency:k.create(g.bumpFrequency),uBumpAmplitude:k.create(g.bumpAmplitude),meta:k.create(f.meta)}}function d(f,p){rt.updateRenderableState(f,p),f.opaque=f.opaque&&!p.xrayShaded,f.writeDepth=f.opaque}}(xa||(xa={}));const Op={uDrawId:xe("i"),uModel:xe("m4"),uView:xe("m4"),uInvView:xe("m4"),uModelView:xe("m4"),uInvModelView:xe("m4"),uProjection:xe("m4"),uInvProjection:xe("m4"),uModelViewProjection:xe("m4"),uInvModelViewProjection:xe("m4"),uIsOrtho:xe("f"),uPixelRatio:xe("f"),uViewport:xe("v4"),uViewOffset:xe("v2"),uDrawingBufferSize:xe("v2"),uCameraPosition:xe("v3"),uCameraDir:xe("v3"),uCameraPlane:xe("v4"),uNear:xe("f"),uFar:xe("f"),uFog:xe("b"),uFogNear:xe("f"),uFogFar:xe("f"),uFogColor:xe("v3"),uTransparentBackground:xe("b"),uLightDirection:xe("v3[]"),uLightColor:xe("v3[]"),uAmbientColor:xe("v3"),uPickingAlphaThreshold:xe("f"),uInteriorDarkening:xe("f"),uInteriorColorFlag:xe("b"),uInteriorColor:xe("v3"),uHighlightColor:xe("v3"),uSelectColor:xe("v3"),uDimColor:xe("v3"),uHighlightStrength:xe("f"),uSelectStrength:xe("f"),uDimStrength:xe("f"),uMarkerPriority:xe("i"),uMarkerAverage:xe("f"),uXrayEdgeFalloff:xe("f"),uExposure:xe("f"),uRenderMask:xe("i"),uMarkingDepthTest:xe("b"),uMarkingType:xe("i"),uPickType:xe("i")},Lp={tDepth:jt("texture","depth","ushort","nearest"),tDpoitDepth:jt("texture","rg","float","nearest"),tDpoitFrontColor:jt("texture","rgba","float","nearest"),tDpoitBackColor:jt("texture","rgba","float","nearest")},Up={uObjectId:xe("i")},zHe={uColor:xe("v3","material"),uColorTexDim:xe("v2"),uColorGridDim:xe("v3"),uColorGridTransform:xe("v4"),tColor:jt("image-uint8","rgb","ubyte","nearest"),tPalette:jt("image-uint8","rgb","ubyte","nearest"),tColorGrid:jt("texture","rgb","ubyte","linear"),dColorType:Ft("string",["uniform","attribute","instance","group","groupInstance","vertex","vertexInstance","volume","volumeInstance","direct"]),dUsePalette:Ft("boolean")},bS={uSize:xe("f","material"),uSizeTexDim:xe("v2"),tSize:jt("image-uint8","rgb","ubyte","nearest"),dSizeType:Ft("string",["uniform","attribute","instance","group","groupInstance"]),uSizeFactor:xe("f","material")},GHe={uMarker:xe("f"),uMarkerTexDim:xe("v2"),tMarker:jt("image-uint8","alpha","ubyte","nearest"),markerAverage:ri("number"),markerStatus:ri("number"),dMarkerType:Ft("string",["instance","groupInstance"])},jHe={uOverpaintTexDim:xe("v2"),tOverpaint:jt("image-uint8","rgba","ubyte","nearest"),dOverpaint:Ft("boolean"),uOverpaintGridDim:xe("v3"),uOverpaintGridTransform:xe("v4"),tOverpaintGrid:jt("texture","rgba","ubyte","linear"),dOverpaintType:Ft("string",["instance","groupInstance","volumeInstance"]),uOverpaintStrength:xe("f","material")},HHe={uTransparencyTexDim:xe("v2"),tTransparency:jt("image-uint8","alpha","ubyte","nearest"),dTransparency:Ft("boolean"),transparencyAverage:ri("number"),uTransparencyGridDim:xe("v3"),uTransparencyGridTransform:xe("v4"),tTransparencyGrid:jt("texture","alpha","ubyte","linear"),dTransparencyType:Ft("string",["instance","groupInstance","volumeInstance"]),uTransparencyStrength:xe("f","material")},qHe={uSubstanceTexDim:xe("v2"),tSubstance:jt("image-uint8","rgba","ubyte","nearest"),dSubstance:Ft("boolean"),uSubstanceGridDim:xe("v3"),uSubstanceGridTransform:xe("v4"),tSubstanceGrid:jt("texture","rgba","ubyte","linear"),dSubstanceType:Ft("string",["instance","groupInstance","volumeInstance"]),uSubstanceStrength:xe("f","material")},WHe={uClippingTexDim:xe("v2"),tClipping:jt("image-uint8","alpha","ubyte","nearest"),dClipping:Ft("boolean"),dClippingType:Ft("string",["instance","groupInstance"])},Vp={dGeometryType:Ft("string",["cylinders","directVolume","image","lines","mesh","points","spheres","text","textureMesh"]),...zHe,...GHe,...jHe,...HHe,...qHe,...WHe,dLightCount:Ft("number"),dColorMarker:Ft("boolean"),dClipObjectCount:Ft("number"),dClipVariant:Ft("string",["instance","pixel"]),uClipObjectType:xe("i[]","material"),uClipObjectInvert:xe("b[]","material"),uClipObjectPosition:xe("v3[]","material"),uClipObjectRotation:xe("v4[]","material"),uClipObjectScale:xe("v3[]","material"),aInstance:Ar("float32",1,1),aTransform:Ar("float32",16,1),uAlpha:xe("f","material"),uMetalness:xe("f","material"),uRoughness:xe("f","material"),uBumpiness:xe("f","material"),uVertexCount:xe("i"),uInstanceCount:xe("i"),uGroupCount:xe("i"),uInvariantBoundingSphere:xe("v4"),uLod:xe("v4"),drawCount:ri("number"),instanceCount:ri("number"),alpha:ri("number"),matrix:ri("m4"),transform:ri("float32"),extraTransform:ri("float32"),hasReflection:ri("boolean"),instanceGranularity:ri("boolean"),boundingSphere:ri("sphere"),invariantBoundingSphere:ri("sphere"),instanceGrid:ri("instanceGrid")},ps="\nprecision highp float;\n\nattribute vec2 aPosition;\nuniform vec2 uQuadScale;\n\nvoid main(void) {\n vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n",YHe=pa(),KHe=Object.keys({color:"",pick:"",depth:"",marking:""}),ZHe=Object.keys({compute:""});function A5(e,t,n,r,i){return n={...n,dRenderVariant:k.create(t)},void 0===i.dRenderVariant&&Object.defineProperty(i,"dRenderVariant",{value:Ft("string")}),e.resources.program(n,r,i)}function I5(e,t){if("color"===e)switch(t){case"blended":return"colorBlended";case"wboit":return"colorWboit";case"dpoit":return"colorDpoit"}return e}function zp(e,t,n,r,i,o,s){return Hie(e,t,n,r,i,o,KHe,s)}function zi(e,t,n,r,i,o=-1){return Hie(e,t,n,r,i,o,ZHe,void 0)}function Hie(e,t,n,r,i,o,s,a){const c=YHe(),{stats:u,state:l,resources:d}=e,{instancedArrays:f,vertexArrayObject:p,multiDrawInstancedBaseVertexBaseInstance:m,drawInstancedBaseVertexBaseInstance:h}=e.extensions;i.uVertexCount&&!e.extensions.noNonInstancedActiveAttribs&&(i.aVertex=k.create(Tc(new Float32Array(i.uVertexCount.ref.value))),r.aVertex=Ar("float32",1,0));const{attributeValues:g,defineValues:y,textureValues:b,materialTextureValues:x,uniformValues:_,materialUniformValues:S,bufferedUniformValues:A}=function UHe(e,t){const n={},r={},i={},o={},s={},a={},c={};return Object.keys(e).forEach(u=>{const l=e[u];"attribute"===l.type&&(n[u]=t[u]),"define"===l.type&&(r[u]=t[u]),"texture"===l.type&&void 0!==t[u]&&("material"===l.variant?o[u]=t[u]:i[u]=t[u]),"uniform"===l.type&&void 0!==t[u]&&("material"===l.variant?a[u]=t[u]:"buffered"===l.variant?c[u]=t[u]:s[u]=t[u])}),{attributeValues:n,defineValues:r,textureValues:i,materialTextureValues:o,uniformValues:s,materialUniformValues:a,bufferedUniformValues:c}}(r,i),E=Object.entries(_),w=Object.entries(S),D=Object.entries(A),I=Object.entries(function HGe(e){const t={};return Object.keys(e).forEach(n=>{t[n]=k.create(Jl(e[n].ref.value))}),t}(A)),R=Object.entries(y),T=function VHe(e){const t={};return Object.keys(e).forEach(n=>{t[n]=e[n].ref.version}),t}(i),M=function XHe(e,t){const{gl:n}=e;switch(t){case"points":return n.POINTS;case"lines":return n.LINES;case"line-strip":return n.LINE_STRIP;case"line-loop":return n.LINE_LOOP;case"triangles":return n.TRIANGLES;case"triangle-strip":return n.TRIANGLE_STRIP;case"triangle-fan":return n.TRIANGLE_FAN}}(e,t),N={};for(const W of s)N[W]=A5(e,I5(W,a),y,n,r);const V=Kre(e,r,b),F=Kre(e,r,x),G=function ZGe(e,t,n){const r=[];return Object.keys(t).forEach(i=>{const o=t[i];"attribute"===o.type&&(r[r.length]=[i,e.resources.attribute(n[i].ref.value,o.itemSize,o.divisor)])}),r}(e,r,g),L=[];for(let W=0,Q=G.length;WN[W],setTransparency:W=>{if(W!==a){a=W;for(const Q of s)N[Q].destroy(),N[Q]=A5(e,I5(Q,a),y,n,r)}},render:(W,Q,fe)=>{if(0===$||0===ee)return;const X=N[W];if(X.id===H&&l.currentRenderItemId===c)X.setUniforms(E),X.bindTextures(V,Q);else{const J=Z[W];(X.id!==l.currentProgramId||X.id!==H||-1===o||o!==l.currentMaterialId)&&(X.id!==l.currentProgramId&&X.use(),X.setUniforms(w),X.bindTextures(F,Q+V.length),l.currentMaterialId=o,H=X.id),X.setUniforms(E),X.setUniforms(I),X.bindTextures(V,Q),J?(J.bind(),z&&z.bind()):(z&&z.bind(),X.bindAttributes(G)),l.currentRenderItemId=c}if(un)try{pD(e.gl)}catch(J){throw new Error(`Framebuffer error rendering item id ${c}: '${J}'`)}if(fe){for(const J of fe)if(0!==J.count){if(X.setUniforms(J.uniforms),m)z?m.multiDrawElementsInstancedBaseVertexBaseInstance(M,J.counts,0,z._dataType,J.offsets,0,J.instanceCounts,0,J.baseVertices,0,J.baseInstances,0,J.count):m.multiDrawArraysInstancedBaseInstance(M,J.firsts,0,J.counts,0,J.instanceCounts,0,J.baseInstances,0,J.count);else if(h)if(z)for(let ce=0;ce0&&(X.uniform("uDrawId",ce),h.drawElementsInstancedBaseVertexBaseInstance(M,J.counts[ce],z._dataType,J.offsets[ce],J.instanceCounts[ce],J.baseVertices[ce],J.baseInstances[ce]));else for(let ce=0;ce0&&(X.uniform("uDrawId",ce),h.drawArraysInstancedBaseInstance(M,J.firsts[ce],J.counts[ce],J.instanceCounts[ce],J.baseInstances[ce]));else if(z)for(let ce=0;ce0&&(X.uniform("uDrawId",ce),X.offsetAttributes(L,J.baseInstances[ce]),f.drawElementsInstanced(M,J.counts[ce],z._dataType,J.offsets[ce],J.instanceCounts[ce]));else for(let ce=0;ce0&&(X.uniform("uDrawId",ce),X.offsetAttributes(L,J.baseInstances[ce]),f.drawArraysInstanced(M,0,J.counts[ce],J.instanceCounts[ce]));if(lt){m?u.calls.multiDrawInstancedBase+=1:h?u.calls.drawInstancedBase+=J.count:u.calls.drawInstanced+=J.count;for(let ce=0;ce{if(function JHe(e){e.attributes=!1,e.defines=!1,e.elements=!1,e.textures=!1}(q),i.aVertex){const W=i.uVertexCount.ref.value;i.aVertex.ref.value.length=J.ref.value.length)X.updateSubData(J.ref.value,0,X.length);else{X.destroy();const{itemSize:ce,divisor:be}=r[fe];G[W][1]=d.attribute(J.ref.value,ce,be),q.attributes=!0}T[fe]=J.ref.version}}if(z&&i.elements.ref.version!==T.elements&&(z.length>=i.elements.ref.value.length?z.updateSubData(i.elements.ref.value,0,z.length):(z.destroy(),z=d.elements(i.elements.ref.value),q.elements=!0),T.elements=i.elements.ref.version),q.attributes||q.defines||q.elements)for(const W of s){const Q=Z[W];Q&&Q.destroy(),Z[W]=p?d.vertexArray(N[W],G,z):null}for(let W=0,Q=V.length;W{if(!O){for(const W of s){N[W].destroy();const Q=Z[W];Q&&Q.destroy()}V.forEach(([W,Q])=>{"texture"!==r[W].kind&&Q.destroy()}),F.forEach(([W,Q])=>{"texture"!==r[W].kind&&Q.destroy()}),G.forEach(([W,Q])=>Q.destroy()),z&&z.destroy(),u.drawCount-=$,u.instanceCount-=ee,u.instancedDrawCount-=ee*$,O=!0}}}}function Gi(){return Gi.create(v.create(1,0,0),0)}function p0(){return p0.create(Gi(),Gi(),Gi(),Gi(),Gi(),Gi())}!function(e){function n(h,g){return v.copy(h.normal,g.normal),h.constant=g.constant,h}function c(h,g,y){return v.copy(h.normal,g),h.constant=-v.dot(h.normal,y),h}e.create=function t(h,g){return{normal:h,constant:g}},e.copy=n,e.clone=function r(h){return n(e(),h)},e.normalize=function i(h,g){const y=1/v.magnitude(g.normal);return v.scale(h.normal,g.normal,y),h.constant=g.constant*y,h},e.negate=function o(h,g){return v.negate(h.normal,g.normal),h.constant=-g.constant,h},e.toArray=function s(h,g,y){return v.toArray(h.normal,g,y),g[y+3]=h.constant,g},e.fromArray=function a(h,g,y){return v.fromArray(h.normal,g,y),h.constant=g[y+3],h},e.fromNormalAndCoplanarPoint=c,e.fromCoplanarPoints=function u(h,g,y,b){return c(h,v.triangleNormal(v(),g,y,b),g),h};const l=v();function f(h,g){return v.dot(h.normal,g)+h.constant}e.setUnnormalized=function d(h,g,y,b,x){v.set(l,g,y,b);const _=1/v.magnitude(l);return v.scale(h.normal,l,_),h.constant=x*_,h},e.distanceToPoint=f,e.distanceToSpher3D=function p(h,g){return f(h,g.center)-g.radius},e.projectPoint=function m(h,g,y){return v.scaleAndAdd(h,h,g.normal,-f(g,y))}}(Gi||(Gi={})),function(e){function n(u,l){for(let d=0;d<6;++d)Gi.copy(u[d],l[d]);return u}e.create=function t(u,l,d,f,p,m){return[u,l,d,f,p,m]},e.copy=n,e.clone=function r(u){return n(e(),u)},e.fromProjectionMatrix=function i(u,l){const d=l[0],f=l[1],p=l[2],m=l[3],h=l[4],g=l[5],y=l[6],b=l[7],x=l[8],_=l[9],S=l[10],A=l[11],E=l[12],w=l[13],D=l[14],I=l[15];return Gi.setUnnormalized(u[0],m-d,b-h,A-x,I-E),Gi.setUnnormalized(u[1],m+d,b+h,A+x,I+E),Gi.setUnnormalized(u[2],m+f,b+g,A+_,I+w),Gi.setUnnormalized(u[3],m-f,b-g,A-_,I-w),Gi.setUnnormalized(u[4],m-p,b-y,A-S,I-D),Gi.setUnnormalized(u[5],m+p,b+y,A+S,I+D),u},e.intersectsSphere3D=function o(u,l){const d=l.center,f=-l.radius;for(let p=0;p<6;++p)if(Gi.distanceToPoint(u[p],d)0?l.max[0]:l.min[0],s[1]=f.normal[1]>0?l.max[1]:l.min[1],s[2]=f.normal[2]>0?l.max[2]:l.min[2],Gi.distanceToPoint(f,s)<0)return!1}return!0},e.containsPoint=function c(u,l){for(let d=0;d<6;++d)if(Gi.distanceToPoint(u[d],l)<0)return!1;return!0}}(p0||(p0={}));const RD=Gi.distanceToPoint,kD=p0.intersectsSphere3D,ND=_e.fromArray,qie=pa();function T5(e,t){return t&&t.instanceCounts.length>=e?t:{firsts:new Int32Array(e),counts:new Int32Array(e),offsets:new Int32Array(e),instanceCounts:new Int32Array(e),baseVertices:new Int32Array(e),baseInstances:new Uint32Array(e),count:0,uniforms:[]}}function Gp(e,t,n){const r=qie();let i=T5(0);const o=[];let s=!1,a=-1;const c=_e(),u=()=>{var l;const d=null===(l=t.lodLevels)||void 0===l?void 0:l.ref.value;if(d&&d.length>0){const{cellCount:f}=t.instanceGrid.ref.value;o.length=d.length;for(let p=0,m=d.length;p{var m,h;if(s=!1,0===t.drawCount.ref.value||0===t.instanceCount.ref.value||!t.instanceGrid.ref.value)return;const{cellOffsets:g,cellSpheres:y,cellCount:b,batchOffsets:x,batchSpheres:_,batchCount:S,batchCell:A,batchSize:E}=t.instanceGrid.ref.value,[w,D]=t.uLod.ref.value,I=0!==w||0!==D,R=2*E,T=null===(m=t.lodLevels)||void 0===m?void 0:m.ref.value;if(T&&T.length>0){if((null===(h=t.lodLevels)||void 0===h?void 0:h.ref.version)!==a)u();else for(let M=0,N=T.length;MD))lt&&(p.culled.lod+=g[A[V-1]+1]-g[A[N]]);else if(kD(d,c))if(null!==f&&f(c))lt&&(p.culled.occlusion+=g[A[V-1]+1]-g[A[N]]);else for(let L=N;LD))lt&&(p.culled.lod+=$);else if(kD(d,c))if(null!==f&&ee-c.radiusT[q][1])continue;const H=o[q],W=H.count;W>0&&H.baseInstances[W-1]+H.instanceCounts[W-1]===j&&H.counts[W-1]===T[q][3]?H.instanceCounts[W-1]+=$:(H.counts[W]=T[q][3],H.instanceCounts[W]=$,H.baseInstances[W]=j,H.count+=1)}else lt&&(p.culled.frustum+=$)}else lt&&(p.culled.frustum+=g[A[V-1]+1]-g[A[N]])}}else{i=T5(b,i);const{baseInstances:M,instanceCounts:N,counts:V}=i;let F=0;for(let G=0;GD){lt&&(p.culled.lod+=g[A[z-1]+1]-g[A[L]]);continue}}if(!kD(d,c)){lt&&(p.culled.frustum+=g[A[z-1]+1]-g[A[L]]);continue}if(null!==f&&f(c)){lt&&(p.culled.occlusion+=g[A[z-1]+1]-g[A[L]]);continue}for(let Z=L;ZD)?lt&&(p.culled.lod+=O):kD(d,c)?null!==f&&H-c.radius0&&M[F-1]+N[F-1]===ee?N[F-1]+=O:(V[F]=t.drawCount.ref.value,N[F]=O,M[F]=ee,F+=1):lt&&(p.culled.frustum+=O)}}}i.count=F,o.length=1,o[0]=i,o[0].uniforms.length=0}s=!0},uncull:()=>{s=!1},render:(l,d)=>{t.uAlpha&&t.alpha&&k.updateIfChanged(t.uAlpha,os(t.alpha.ref.value*n.alphaFactor,0,1)),e.render(l,d,s?o:void 0)},getProgram:l=>e.getProgram(l),setTransparency:l=>e.setTransparency(l),update:()=>{e.update(),u()},dispose:()=>e.destroy()}}function ji(e,t){return{id:qie(),values:t,render:()=>e.render("compute",0),update:()=>e.update(),dispose:()=>e.destroy()}}const D5=new Float32Array([1,1,-1,1,-1,-1,-1,-1,1,-1,1,1]),vo={drawCount:ri("number"),instanceCount:ri("number"),aPosition:Ar("float32",2,0),uQuadScale:xe("v2")},_o={drawCount:k.create(6),instanceCount:k.create(1),aPosition:k.create(D5),uQuadScale:k.create(Me.create(1,1))},eqe={...vo,tColor:jt("texture","rgba","ubyte","nearest"),uTexSize:xe("v2")},tqe=Br("copy",ps,"\nprecision highp float;\nprecision highp sampler2D;\n\nuniform sampler2D tColor;\nuniform vec2 uTexSize;\n\nvoid main() {\n vec2 coords = gl_FragCoord.xy / uTexSize;\n gl_FragColor = texture2D(tColor, coords);\n}\n");function Tv(e,t){const n={..._o,tColor:k.create(t),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight()))},r={...eqe};return ji(zi(e,"triangles",tqe,r,n),n)}const Wie=new Uint32Array([0,1,2,1,3,2]),rqe=new Float32Array([0,1,0,0,1,1,1,0]),$ie={nearest:"Nearest",catmulrom:"Catmulrom (Cubic)",mitchell:"Mitchell (Cubic)",bspline:"B-Spline (Cubic)"},iqe=Object.keys($ie);var jp,oc,Zo;!function(e){function t(f,p,m,h){return h?function i(f,p,m,h){const g=f.width,y=f.height;return k.update(h.imageTexture,f),k.update(h.imageTextureDim,Me.set(h.imageTextureDim.ref.value,g,y)),k.update(h.cornerBuffer,p),k.update(h.groupTexture,m),h}(f,p,m,h):function r(f,p,m){const h=_e();let g=-1;const y=f.width,b=f.height,x={kind:"image",imageTexture:k.create(f),imageTextureDim:k.create(Me.create(y,b)),cornerBuffer:k.create(p),groupTexture:k.create(m),get boundingSphere(){const _=function n(f){return ha([f.cornerBuffer.ref.version])}(x);if(_!==g){const S=function oqe(e){const t=v(),n=[];for(let o=0,s=e.length;or&&(r=s)}const i=_e.create(t,r);return _e.setExtrema(i,n),i}(x.cornerBuffer.ref.value);_e.copy(h,S),g=_}return h}};return x}(f,p,m)}function o(f){return t(Po(0,4,Uint8Array),f?f.cornerBuffer.ref.value:new Float32Array(24),Po(0,4,Uint8Array),f)}function s(f,p,m,h,g){const{instanceCount:y,groupCount:b}=m,_=bu(m,e.Utils.createPositionIterator(f,p),h.color),S=g.instanceGranularity?Vi(y,"instance"):Vi(y*b,"groupInstance"),A=Dp(),E=Ep(),w=Mp(),D=Pp(),I={drawCount:Wie.length,vertexCount:D5.length/3,groupCount:b,instanceCount:y},R=_e.clone(f.boundingSphere),T=fs(R,p.aTransform.ref.value,y,0);return{dGeometryType:k.create("image"),..._,...S,...A,...E,...w,...D,...p,...rt.createValues(g,I),aPosition:f.cornerBuffer,aUv:k.create(rqe),elements:k.create(Wie),aGroup:k.create(Tc(new Float32Array(4))),boundingSphere:k.create(T),invariantBoundingSphere:k.create(R),uInvariantBoundingSphere:k.create(nn.ofSphere(R)),dInterpolation:k.create(g.interpolation),uImageTexDim:f.imageTextureDim,tImageTex:f.imageTexture,tGroupTex:f.groupTexture}}e.create=t,e.createEmpty=o,e.Params={...rt.Params,interpolation:C.Select("bspline",C.objectToOptions($ie))},e.Utils={Params:e.Params,createEmpty:o,createValues:s,createValuesSimple:function a(f,p,m,h,g){const y=rt.createSimple(m,h,g),b={...C.getDefaultValues(e.Params),...p};return s(f,y.transform,y.locationIterator,y.theme,b)},updateValues:function c(f,p){rt.updateValues(f,p),k.updateIfChanged(f.dInterpolation,p.interpolation)},updateBoundingSphere:function u(f,p){const m=_e.clone(p.boundingSphere),h=fs(m,f.aTransform.ref.value,f.instanceCount.ref.value,0);_e.equals(h,f.boundingSphere.ref.value)||k.update(f.boundingSphere,h),_e.equals(m,f.invariantBoundingSphere.ref.value)||(k.update(f.invariantBoundingSphere,m),k.update(f.uInvariantBoundingSphere,nn.fromSphere(f.uInvariantBoundingSphere.ref.value,m)))},createRenderableState:function l(f){const p=rt.createRenderableState(f);return p.opaque=!1,p},updateRenderableState:function d(f,p){rt.updateRenderableState(f,p),f.opaque=!1},createPositionIterator:()=>Mr(1,1,1,()=>rc)}}(jp||(jp={})),function(e){function t(m,h,g,y,b,x,_,S,A,E){return E?function o(m,h,g,y,b,x,_,S,A,E){return A>E.cylinderCount&&(k.update(E.mappingBuffer,m),k.update(E.indexBuffer,h)),E.cylinderCount=A,k.update(E.groupBuffer,g),k.update(E.startBuffer,y),k.update(E.endBuffer,b),k.update(E.scaleBuffer,x),k.update(E.capBuffer,_),k.update(E.colorModeBuffer,S),E}(m,h,g,y,b,x,_,S,A,E):function i(m,h,g,y,b,x,_,S,A){const E=_e();let w,D=-1,I=-1;const R={kind:"cylinders",cylinderCount:A,mappingBuffer:k.create(m),indexBuffer:k.create(h),groupBuffer:k.create(g),startBuffer:k.create(y),endBuffer:k.create(b),scaleBuffer:k.create(x),capBuffer:k.create(_),colorModeBuffer:k.create(S),get boundingSphere(){const T=r(R);if(T!==D){const M=Ip(R.startBuffer.ref.value,6*R.cylinderCount,6),N=Ip(R.endBuffer.ref.value,6*R.cylinderCount,6);_e.expandBySphere(E,M,N),D=T}return E},get groupMapping(){return R.groupBuffer.ref.version!==I&&(w=yv(R.groupBuffer.ref.value,R.cylinderCount,6),I=R.groupBuffer.ref.version),w},setBoundingSphere(T){_e.copy(E,T),D=r(R)}};return R}(m,h,g,y,b,x,_,S,A)}function n(m){return t(m?m.mappingBuffer.ref.value:new Float32Array(0),m?m.indexBuffer.ref.value:new Uint32Array(0),m?m.groupBuffer.ref.value:new Float32Array(0),m?m.startBuffer.ref.value:new Float32Array(0),m?m.endBuffer.ref.value:new Float32Array(0),m?m.scaleBuffer.ref.value:new Float32Array(0),m?m.capBuffer.ref.value:new Float32Array(0),m?m.colorModeBuffer.ref.value:new Float32Array(0),0,m)}function r(m){return ha([m.cylinderCount,m.mappingBuffer.ref.version,m.indexBuffer.ref.version,m.groupBuffer.ref.version,m.startBuffer.ref.version,m.endBuffer.ref.version,m.scaleBuffer.ref.version,m.capBuffer.ref.version,m.colorModeBuffer.ref.version])}function a(m,h){const g=6*m.cylinderCount,y=h.instanceCount.ref.value,b=mm(),x=b.position,_=m.startBuffer.ref.value,S=m.endBuffer.ref.value,A=h.aTransform.ref.value;return Mr(g,y,2,(w,D)=>{const I=w%6==0?_:S;return D<0?v.fromArray(x,I,3*w):v.transformMat4Offset(x,I,A,0,3*w,16*D),b})}function c(m,h,g,y,b){const{instanceCount:x,groupCount:_}=g,A=bu(g,a(m,h),y.color),E=kp(g,y.size),w=b.instanceGranularity?Vi(x,"instance"):Vi(x*_,"groupInstance"),D=Dp(),I=Ep(),R=Mp(),T=Pp(),M={drawCount:4*m.cylinderCount*3,vertexCount:6*m.cylinderCount,groupCount:_,instanceCount:x},N=gS(E)*b.sizeFactor,V=_e.clone(m.boundingSphere),F=fs(V,h.aTransform.ref.value,x,0);return{dGeometryType:k.create("cylinders"),aMapping:m.mappingBuffer,aGroup:m.groupBuffer,aStart:m.startBuffer,aEnd:m.endBuffer,aScale:m.scaleBuffer,aCap:m.capBuffer,aColorMode:m.colorModeBuffer,elements:m.indexBuffer,boundingSphere:k.create(F),invariantBoundingSphere:k.create(V),uInvariantBoundingSphere:k.create(nn.ofSphere(V)),...A,...E,...w,...D,...I,...R,...T,...h,padding:k.create(N),...rt.createValues(b,M),uSizeFactor:k.create(b.sizeFactor*b.sizeAspectRatio),uDoubleSided:k.create(b.doubleSided),dIgnoreLight:k.create(b.ignoreLight),dXrayShaded:k.create("inverted"===b.xrayShaded?"inverted":!0===b.xrayShaded?"on":"off"),dTransparentBackfaces:k.create(b.transparentBackfaces),dSolidInterior:k.create(b.solidInterior),uBumpFrequency:k.create(b.bumpFrequency),uBumpAmplitude:k.create(b.bumpAmplitude),dDualColor:k.create("interpolate"===b.colorMode)}}function p(m,h){rt.updateRenderableState(m,h),m.opaque=m.opaque&&!h.xrayShaded,m.writeDepth=m.opaque}e.create=t,e.createEmpty=n,e.transform=function s(m,h){const g=m.startBuffer.ref.value;l0(h,g,0,6*m.cylinderCount),k.update(m.startBuffer,g);const y=m.endBuffer.ref.value;l0(h,y,0,6*m.cylinderCount),k.update(m.endBuffer,y)},e.Params={...rt.Params,sizeFactor:C.Numeric(1,{min:0,max:10,step:.1}),sizeAspectRatio:C.Numeric(1,{min:0,max:3,step:.01}),doubleSided:C.Boolean(!1,rt.CustomQualityParamInfo),ignoreLight:C.Boolean(!1,rt.ShadingCategory),xrayShaded:C.Select(!1,[[!1,"Off"],[!0,"On"],["inverted","Inverted"]],rt.ShadingCategory),transparentBackfaces:C.Select("off",C.arrayToOptions(["off","on","opaque"]),rt.ShadingCategory),solidInterior:C.Boolean(!0,rt.ShadingCategory),bumpFrequency:C.Numeric(0,{min:0,max:10,step:.1},rt.ShadingCategory),bumpAmplitude:C.Numeric(1,{min:0,max:5,step:.1},rt.ShadingCategory),colorMode:C.Select("default",C.arrayToOptions(["default","interpolate"]),rt.ShadingCategory)},e.Utils={Params:e.Params,createEmpty:n,createValues:c,createValuesSimple:function u(m,h,g,y,b){const x=rt.createSimple(g,y,b),_={...C.getDefaultValues(e.Params),...h};return c(m,x.transform,x.locationIterator,x.theme,_)},updateValues:function l(m,h){rt.updateValues(m,h),k.updateIfChanged(m.uSizeFactor,h.sizeFactor*h.sizeAspectRatio),k.updateIfChanged(m.uDoubleSided,h.doubleSided),k.updateIfChanged(m.dIgnoreLight,h.ignoreLight),k.updateIfChanged(m.dXrayShaded,"inverted"===h.xrayShaded?"inverted":!0===h.xrayShaded?"on":"off"),k.updateIfChanged(m.dTransparentBackfaces,h.transparentBackfaces),k.updateIfChanged(m.dSolidInterior,h.solidInterior),k.updateIfChanged(m.uBumpFrequency,h.bumpFrequency),k.updateIfChanged(m.uBumpAmplitude,h.bumpAmplitude),k.updateIfChanged(m.dDualColor,"interpolate"===h.colorMode)},updateBoundingSphere:function d(m,h){const g=_e.clone(h.boundingSphere),y=fs(g,m.aTransform.ref.value,m.instanceCount.ref.value,0);_e.equals(y,m.boundingSphere.ref.value)||k.update(m.boundingSphere,y),_e.equals(g,m.invariantBoundingSphere.ref.value)||(k.update(m.invariantBoundingSphere,g),k.update(m.uInvariantBoundingSphere,nn.fromSphere(m.uInvariantBoundingSphere.ref.value,g)))},createRenderableState:function f(m){const h=rt.createRenderableState(m);return p(h,m),h},updateRenderableState:p,createPositionIterator:a}}(oc||(oc={})),function(e){function t(s){switch(s.kind){case"mesh":return 3*s.triangleCount;case"points":return s.pointCount;case"spheres":return 2*s.sphereCount*3;case"cylinders":return 4*s.cylinderCount*3;case"text":return 2*s.charCount*3;case"lines":return 2*s.lineCount*3;case"direct-volume":return 36;case"image":return 6;case"texture-mesh":return s.vertexCount}}e.getDrawCount=t,e.getVertexCount=function n(s){switch(s.kind){case"mesh":case"texture-mesh":return s.vertexCount;case"points":return s.pointCount;case"spheres":return 6*s.sphereCount;case"cylinders":return 6*s.cylinderCount;case"text":return 4*s.charCount;case"lines":return 4*s.lineCount;case"direct-volume":const[a,c,u]=s.gridDimension.ref.value;return a*c*u;case"image":return 4}},e.getGroupCount=function r(s){switch(s.kind){case"mesh":case"points":case"spheres":case"cylinders":case"text":case"lines":return 0===t(s)?0:Xd(s.groupBuffer.ref.value)+1;case"direct-volume":return 1;case"image":return Xd(s.groupTexture.ref.value.array)+1;case"texture-mesh":return s.groupCount}},e.getUtils=function i(s){switch(s.kind){case"mesh":return Nt.Utils;case"points":return ym.Utils;case"spheres":return fl.Utils;case"cylinders":return oc.Utils;case"text":return vu.Utils;case"lines":return di.Utils;case"direct-volume":return _u.Utils;case"image":return jp.Utils;case"texture-mesh":return xa.Utils}},e.getGranularity=function o(s,a){return"instance"===a&&s.nonInstanceable?"group":a}}(Zo||(Zo={}));const Yie={};function M5(e,t){return{factory:M5,granularity:"groupInstance",size:n=>ra.isLocation(n)?n.shape.getSize(n.group,n.instance):1,props:t,description:"Assigns sizes as defined by the shape object."}}const uqe={name:"shape-group",label:"Shape Group",category:"",factory:M5,getParams:function cqe(e){return Yie},defaultValues:C.getDefaultValues(Yie),isApplicable:e=>!!e.shape},lqe=st(13421772),Xie={};function R5(e,t){return{factory:R5,granularity:"groupInstance",color:n=>ra.isLocation(n)?n.shape.getColor(n.group,n.instance):lqe,props:t,description:"Assigns colors as defined by the shape object."}}const pqe={name:"shape-group",label:"Shape Group",category:ni.Misc,factory:R5,getParams:function fqe(e){return Xie},defaultValues:C.getDefaultValues(Xie),isApplicable:e=>!!e.shape},hqe={...Vp,aPosition:Ar("float32",3,0),elements:Iv("uint32"),uBboxMin:xe("v3"),uBboxMax:xe("v3"),uBboxSize:xe("v3"),uMaxSteps:xe("i"),uStepScale:xe("f"),uJumpLength:xe("f"),uTransform:xe("m4"),uGridDim:xe("v3"),tTransferTex:jt("image-uint8","alpha","ubyte","linear"),uTransferScale:xe("f","material"),dGridTexType:Ft("string",["2d","3d"]),uGridTexDim:xe("v3"),tGridTex:jt("texture","rgba","ubyte","linear"),uGridStats:xe("v4"),uCellDim:xe("v3"),uCartnToUnit:xe("m4"),uUnitToCartn:xe("m4"),dPackedGroup:Ft("boolean"),dAxisOrder:Ft("string",["012","021","102","120","201","210"]),dIgnoreLight:Ft("boolean"),dXrayShaded:Ft("string",["off","on","inverted"])},gqe={...Vp,aGroup:Ar("float32",1,0),aPosition:Ar("float32",3,0),aNormal:Ar("float32",3,0),elements:Iv("uint32"),dVaryingGroup:Ft("boolean"),dFlatShaded:Ft("boolean"),uDoubleSided:xe("b","material"),dFlipSided:Ft("boolean"),dIgnoreLight:Ft("boolean"),dXrayShaded:Ft("string",["off","on","inverted"]),dTransparentBackfaces:Ft("string",["off","on","opaque"]),uBumpFrequency:xe("f","material"),uBumpAmplitude:xe("f","material"),meta:ri("unknown")},bqe={...Vp,...bS,aGroup:Ar("float32",1,0),aPosition:Ar("float32",3,0),dPointSizeAttenuation:Ft("boolean"),dPointStyle:Ft("string",["square","circle","fuzzy"])},_qe={...Vp,...bS,aGroup:Ar("float32",1,0),aMapping:Ar("float32",2,0),aStart:Ar("float32",3,0),aEnd:Ar("float32",3,0),elements:Iv("uint32"),dLineSizeAttenuation:Ft("boolean"),uDoubleSided:xe("b","material"),dFlipSided:Ft("boolean")},Sqe={...Vp,...bS,uTexDim:xe("v2"),tPositionGroup:jt("image-float32","rgba","float","nearest"),padding:ri("number"),uDoubleSided:xe("b","material"),dIgnoreLight:Ft("boolean"),dXrayShaded:Ft("string",["off","on","inverted"]),dTransparentBackfaces:Ft("string",["off","on","opaque"]),dSolidInterior:Ft("boolean"),dClipPrimitive:Ft("boolean"),dApproximate:Ft("boolean"),uAlphaThickness:xe("f"),uBumpFrequency:xe("f","material"),uBumpAmplitude:xe("f","material"),lodLevels:ri("unknown"),centerBuffer:ri("float32"),groupBuffer:ri("float32")},wqe={...Vp,...bS,aGroup:Ar("float32",1,0),aPosition:Ar("float32",3,0),aMapping:Ar("float32",2,0),aDepth:Ar("float32",1,0),elements:Iv("uint32"),aTexCoord:Ar("float32",2,0),tFont:jt("image-uint8","alpha","ubyte","linear"),padding:ri("number"),uBorderWidth:xe("f","material"),uBorderColor:xe("v3","material"),uOffsetX:xe("f","material"),uOffsetY:xe("f","material"),uOffsetZ:xe("f","material"),uBackgroundColor:xe("v3","material"),uBackgroundOpacity:xe("f","material")},Iqe={...Vp,uGeoTexDim:xe("v2","buffered"),tPosition:jt("texture","rgb","float","nearest"),tGroup:jt("texture","alpha","float","nearest"),tNormal:jt("texture","rgb","float","nearest"),dVaryingGroup:Ft("boolean"),dFlatShaded:Ft("boolean"),uDoubleSided:xe("b","material"),dFlipSided:Ft("boolean"),dIgnoreLight:Ft("boolean"),dXrayShaded:Ft("string",["off","on","inverted"]),dTransparentBackfaces:Ft("string",["off","on","opaque"]),uBumpFrequency:xe("f","material"),uBumpAmplitude:xe("f","material"),meta:ri("unknown")},Dqe={...Vp,aGroup:Ar("float32",1,0),aPosition:Ar("float32",3,0),aUv:Ar("float32",2,0),elements:Iv("uint32"),uImageTexDim:xe("v2"),tImageTex:jt("image-uint8","rgba","ubyte","nearest"),tGroupTex:jt("image-uint8","rgba","ubyte","nearest"),dInterpolation:Ft("string",iqe)},Pqe={...Vp,...bS,aGroup:Ar("float32",1,0),aStart:Ar("float32",3,0),aEnd:Ar("float32",3,0),aMapping:Ar("float32",3,0),aScale:Ar("float32",1,0),aCap:Ar("float32",1,0),aColorMode:Ar("float32",1,0),elements:Iv("uint32"),padding:ri("number"),uDoubleSided:xe("b","material"),dIgnoreLight:Ft("boolean"),dXrayShaded:Ft("string",["off","on","inverted"]),dTransparentBackfaces:Ft("string",["off","on","opaque"]),dSolidInterior:Ft("boolean"),uBumpFrequency:xe("f","material"),uBumpAmplitude:xe("f","material"),dDualColor:Ft("boolean")},Rqe=pa(0,2147483647),Hp=pa(0,2147483647);function Ev(e,t,n,r){return{id:Rqe(),type:e,values:t,state:n,materialId:r}}var qn,ra;function Kie(e){const t=e&&e.getElement("vertex"),n=e&&e.getElement("material"),r={group:"",vRed:"",vGreen:"",vBlue:"",mRed:"",mGreen:"",mBlue:""},i=[["",""]],o=[["",""]];if(t){for(let c=0,u=t.propertyNames.length;c(f.group=m,f.instance=h,f))}function i(l,d,f,p,m){const h=m&&m.aTransform.ref.value.length>=16*l.length?m.aTransform.ref.value:new Float32Array(16*l.length);for(let g=0,y=l.length;g{for(let A=b[S],E=b[S+1];A{for(let A=b[S],E=b[S+1];A{const A=p.shape.getSize(S,_);h{const m="material"===i?p:u[p];return st.fromRgb(o.value(m),s.value(m),a.value(m))},()=>1,p=>`${l} ${c[p]}`,f)}function Lqe(){let e,t,n,r,i,o;return function(){var a=ie(function*(c,u,l,d){const f=u.source.getElement("vertex");if(!f)throw new Error("missing vertex element");const p=u.source.getElement("face");if(!p)throw new Error("missing face element");const m=u.source.getElement("material");let h=!1,g=!1;return(!e||e!=e)&&(h=!0),(!t||!C.isParamEqual(Zie.grouping,t.grouping,l.grouping))&&(h=!0),(!t||!C.isParamEqual(Zie.coloring,t.coloring,l.coloring))&&(g=!0),h?(i=Qie(f,m,l),o=function Oqe(e,t){const{grouping:n}=t,{rowCount:r}=e,i="vertex"===n.name?e.getProperty(n.params.group):void 0,o="vertex"===n.name?zu(n.params.group):"Vertex",s=i?i.toArray({array:Uint32Array}):Tc(new Uint32Array(r)),a=i?Xd(s):r-1,c=new Uint32Array(a+1);for(let u=0,l=s.length;u=48&&s<=57)&&i<=o;)s=t.charCodeAt(++i);for(s=t.charCodeAt(o);(32===s||s>=48&&s<=57)&&o>=i;)s=t.charCodeAt(--o);if(++o,i===o||i+1===o)return He.add(e,i,o);if(s=t.charCodeAt(i),i+2===o){const a=t.charCodeAt(i+1);if(!((78!==s&&110!==s||65!==a&&97!==a)&&(67!==s&&99!==s||76!==a&&108!==a)&&(70!==s&&102!==s||69!==a&&101!==a)&&(83!==s&&115!==s||73!==a&&105!==a)&&(66!==s&&98!==s||82!==a&&114!==a)&&(65!==s&&97!==s||83!==a&&115!==a)))return He.add(e,i,i+2)}if(67===s||99===s||72===s||104===s||78===s||110===s||79===s||111===s||80===s||112===s||83===s||115===s)return He.add(e,i,i+1);He.add(e,i,i)}!function(e){function t(i,o){return{size:i,anglesInRadians:o}}function n(){return t(v(),v())}e.create=t,e.empty=n,e.fromBasis=function r(i,o,s){const a=v.magnitude(i),c=v.magnitude(o),u=v.magnitude(s),l=Math.acos(v.dot(o,s)/(c*u)),d=Math.acos(v.dot(i,s)/(a*u)),f=Math.acos(v.dot(i,o)/(a*c));return a<=0||c<=0||u<=0||l>=Math.PI||d>=Math.PI||f>=Math.PI?n():t(v.create(a,c,u),v.create(l,d,f))}}(Wp||(Wp={}));const Gqe=new Set(["NA","CL","FE","SI","BR","AS","LI"]),jqe=new Set(["C","H","N","O","P","S","F","B"]),Hqe=/^[\s\d]+|[\s\d]+$/g;function Pv(e,t){const n=(e=e.replace(Hqe,"").toUpperCase()).length;if(0===n||1===n||Gqe.has(e))return e;if(3===n&&t===e){if("SOD"===e)return"NA";if("POT"===e)return"K";if("CES"===e)return"CS";if("CAL"===e)return"CA";if("CLA"===e)return"CL"}return jqe.has(e[0])?e[0]:""}const N5="ABCDEFGHIJKLMNOPQRSTUVWXYZ",vS=cte(function qqe(e){let n=e,r=0,i=N5[n%26];for(;n>=26;)n=Math.floor(n/26),i+=N5[n%26],r+=1;return r>=5&&console.warn("getChainId overflow"),i});function Wqe(e,t){const n=e.atomName,r=e.residueName,i=new Array(e.count),o=new Array(e.count),s=new Uint32Array(e.count),a=new Uint32Array(e.count),c=new Array(e.count),u=new sd,l=new ad(e.residueNumber,e.atomName);let d="",f=0,p="",m=0,h=0,g=-1;for(let x=0,_=e.count;x<_;++x){const S=e.residueNumber.value(x);if(S!==g){const A=e.residueName.value(x),E=Yh(l.add(A,x).type,A);(E!==h||S!==g+1&&!(99999===g&&0===S))&&(p=vS(f),f+=1,m=0),d=u.getEntityId(A,E,p),m+=1,g=S,h=E}i[x]=d,o[x]=p,s[x]=m,a[x]=x,c[x]=Pv(e.atomName.value(x),e.residueName.value(x))}const y=te.ofStringArray(o),b=Xn.ofPartialColumns(ks.atom_site,{auth_asym_id:y,auth_atom_id:n,auth_comp_id:r,auth_seq_id:e.residueNumber,Cartn_x:te.ofFloatArray(te.mapToArray(e.x,x=>10*x,Float32Array)),Cartn_y:te.ofFloatArray(te.mapToArray(e.y,x=>10*x,Float32Array)),Cartn_z:te.ofFloatArray(te.mapToArray(e.z,x=>10*x,Float32Array)),id:te.ofIntArray(a),label_asym_id:y,label_atom_id:n,label_comp_id:r,label_seq_id:te.ofIntArray(s),label_entity_id:te.ofStringArray(i),occupancy:te.ofConst(1,e.count,te.Schema.float),type_symbol:te.ofStringArray(c),pdbx_PDB_model_num:te.ofConst(t,e.count,te.Schema.int)},e.count);return $u({entity:u.getEntityTable(),chem_comp:l.getChemCompTable(),atom_site:b})}var F5;function Yqe(e,t){const n=(o,s)=>(t.substr(o,s)||"").trim(),r={entry_id:ft.ofString(e),length_a:ft.ofString(n(6,9)),length_b:ft.ofString(n(15,9)),length_c:ft.ofString(n(24,9)),angle_alpha:ft.ofString(n(33,7)),angle_beta:ft.ofString(n(40,7)),angle_gamma:ft.ofString(n(47,7)),Z_PDB:ft.ofString(n(66,4)),pdbx_unique_axis:ft.ofString("?")},i={entry_id:ft.ofString(e),"space_group_name_H-M":ft.ofString(n(55,11)),Int_Tables_number:ft.ofString("?"),cell_setting:ft.ofString("?"),space_group_name_Hall:ft.ofString("?")};return[ss.ofFields("cell",r),ss.ofFields("symmetry",i)]}function eoe(e,t){return{id:e,details:t,groups:[]}}function Xqe(e,t,n){const r=[];let i,o,s,a=1,c=1;const u=h=>e.data.substring(e.indices[2*h],e.indices[2*h+1]);for(let h=t;hh.id)),details:ft.ofStrings(r.map(h=>h.details))},d=[];for(const h of r)for(const g of h.groups)d.push({assembly_id:h.id,oper_expression:g.operators.map(y=>y.id).join(","),asym_id_list:g.chains.join(",")});const f={assembly_id:ft.ofStrings(d.map(h=>h.assembly_id)),oper_expression:ft.ofStrings(d.map(h=>h.oper_expression)),asym_id_list:ft.ofStrings(d.map(h=>h.asym_id_list))},p=[];for(const h of r)for(const g of h.groups)for(const y of g.operators){const b={id:""+y.id,type:"?",name:"?",symmetry_operation:"?"};for(let x=0;x<3;x++){for(let _=0;_<3;_++)b[`matrix[${x+1}][${_+1}]`]=""+le.getValue(y.matrix,x,_);b[`vector[${x+1}]`]=""+le.getValue(y.matrix,x,3)}p.push(b)}const m={id:ft.ofStrings(p.map(h=>h.id)),type:ft.ofStrings(p.map(h=>h.type)),name:ft.ofStrings(p.map(h=>h.name)),symmetry_operation:ft.ofStrings(p.map(h=>h.symmetry_operation))};for(let h=0;h<3;h++){for(let y=0;y<3;y++){const b=`matrix[${h+1}][${y+1}]`;m[b]=ft.ofStrings(p.map(x=>x[b]))}const g=`vector[${h+1}]`;m[g]=ft.ofStrings(p.map(y=>y[g]))}return[ss.ofFields("pdbx_struct_assembly",l),ss.ofFields("pdbx_struct_assembly_gen",f),ss.ofFields("pdbx_struct_oper_list",m)]}function Kqe(e,t,n){const r=[];let i;const o=u=>e.data.substring(e.indices[2*u],e.indices[2*u+1]);for(let u=t;uu.id)),code:ft.ofStrings(s.map(u=>u.code)),details:ft.ofStrings(s.map(u=>u.details))};for(let u=0;u<3;u++){for(let d=0;d<3;d++){const f=`matrix[${u+1}][${d+1}]`;c[f]=ft.ofStrings(s.map(p=>p[f]))}const l=`vector[${u+1}]`;c[l]=ft.ofStrings(s.map(d=>d[l]))}return[ss.ofFields("struct_ncs_oper",c)]}!function(e){e.is=function t(r){return"gro"===r?.kind},e.fromGro=function n(r){return{kind:"gro",name:r.structures[0].header.title,data:r}}}(F5||(F5={}));const Zqe={1:"helx_rh_al_p",2:"helx_rh_om_p",3:"helx_rh_pi_p",4:"helx_rh_ga_p",5:"helx_rh_3t_p",6:"helx_lh_al_p",7:"helx_lh_om_p",8:"helx_lh_ga_p",9:"helx_rh_27_p",10:"helx_rh_pp_p"};function Jqe(e,t,n){const r=[],i=l=>e.data.substring(e.indices[2*l],e.indices[2*l+1]);for(let l=t;ll.initChainID)),s=ft.ofStrings(r.map(l=>l.initResName)),a=ft.ofStrings(r.map(l=>l.endChainID)),c=ft.ofStrings(r.map(l=>l.endResName)),u={beg_label_asym_id:o,beg_label_comp_id:s,beg_label_seq_id:ft.ofUndefined(r.length,te.Schema.int),beg_auth_asym_id:o,beg_auth_comp_id:s,beg_auth_seq_id:ft.ofStrings(r.map(l=>l.initSeqNum)),conf_type_id:ft.ofStrings(r.map(l=>function Qqe(e){return Zqe[e]||"helx_p"}(l.helixClass))),details:ft.ofStrings(r.map(l=>l.comment)),end_label_asym_id:a,end_label_comp_id:c,end_label_seq_id:ft.ofUndefined(r.length,te.Schema.int),end_auth_asym_id:a,end_auth_comp_id:c,end_auth_seq_id:ft.ofStrings(r.map(l=>l.endSeqNum)),id:ft.ofStrings(r.map(l=>l.serNum)),pdbx_beg_PDB_ins_code:ft.ofStrings(r.map(l=>l.initICode)),pdbx_end_PDB_ins_code:ft.ofStrings(r.map(l=>l.endICode)),pdbx_PDB_helix_class:ft.ofStrings(r.map(l=>l.helixClass)),pdbx_PDB_helix_length:ft.ofStrings(r.map(l=>l.length)),pdbx_PDB_helix_id:ft.ofStrings(r.map(l=>l.helixID))};return ss.ofFields("struct_conf",u)}function eWe(e,t,n){const r=[],i=f=>e.data.substring(e.indices[2*f],e.indices[2*f+1]);for(let f=t;ff.initChainID)),s=ft.ofStrings(r.map(f=>f.initResName)),a=ft.ofStrings(r.map(f=>f.initSeqNum)),c=ft.ofStrings(r.map(f=>f.endChainID)),u=ft.ofStrings(r.map(f=>f.endResName)),l=ft.ofStrings(r.map(f=>f.endSeqNum)),d={beg_label_asym_id:o,beg_label_comp_id:s,beg_label_seq_id:a,beg_auth_asym_id:o,beg_auth_comp_id:s,beg_auth_seq_id:a,end_label_asym_id:c,end_label_comp_id:c,end_label_seq_id:l,end_auth_asym_id:c,end_auth_comp_id:u,end_auth_seq_id:l,id:ft.ofStrings(r.map(f=>f.strand)),sheet_id:ft.ofStrings(r.map(f=>f.sheetID)),pdbx_beg_PDB_ins_code:ft.ofStrings(r.map(f=>f.initICode)),pdbx_end_PDB_ins_code:ft.ofStrings(r.map(f=>f.endICode))};return ss.ofFields("struct_sheet_range",d)}const tWe={MOL_ID:"",MOLECULE:"",CHAIN:"",FRAGMENT:"",SYNONYM:"",EC:"",ENGINEERED:"",MUTATION:"",OTHER_DETAILS:""};function nWe(e,t,n){const r=c=>e.data.substring(e.indices[2*c],e.indices[2*c+1]);let i,o={chains:[],description:""};const s=[];for(let c=t;ce.data.substring(e.indices[2*o],e.indices[2*o+1]),i=new Map;for(let o=t;o=66?He.addToken(e.B_iso_or_equiv,ht.trim(n,r+60,r+66)):He.add(e.B_iso_or_equiv,0,0),o&&He.addToken(e.partial_charge,ht.trim(n,r+70,r+76)),a>=78&&!o?(ht.trim(n,r+76,r+78),n.tokenStart=78?(ht.trim(n,r+76,r+78),n.tokenStartHe.create(e,2*t);return{index:0,group_PDB:r(),id:[],auth_atom_id:r(),label_alt_id:r(),auth_comp_id:r(),auth_asym_id:r(),auth_seq_id:r(),pdbx_PDB_ins_code:r(),Cartn_x:r(),Cartn_y:r(),Cartn_z:r(),occupancy:r(),B_iso_or_equiv:r(),type_symbol:r(),pdbx_PDB_model_num:[],label_entity_id:[],partial_charge:r()}}(n,s),l=function sWe(e,t){const r=()=>new Float32Array(t),i=()=>He.create(e,2*t);return{index:0,count:t,id:[],type_symbol:i(),pdbx_label_atom_id:i(),pdbx_label_alt_id:i(),pdbx_label_comp_id:i(),pdbx_label_asym_id:i(),pdbx_label_seq_id:i(),pdbx_PDB_ins_code:i(),"U[1][1]":r(),"U[2][2]":r(),"U[3][3]":r(),"U[1][2]":r(),"U[1][3]":r(),"U[2][3]":r(),pdbx_auth_seq_id:i(),pdbx_auth_comp_id:i(),pdbx_auth_asym_id:i(),pdbx_auth_atom_id:i()}}(n,a),d=new sd,f=[],p=[];let g,m=0,h="",y=!1;const b=new Set;for(let I=0,R=t.count;Ie.data.substring(e.indices[2*E],e.indices[2*E+1]),s=[],a=[],c=[],u=[],l=[],d=[],f=[],p=[],m=[],h=[],g=[],y=[],b=[],x=[],_=[11,16,21,26];let S=1;for(let E=t;EM||void 0===I[M]&&(s.push(`covale${S}`),a.push("covale"),c.push(r.label_asym_id.str(D)),u.push(r.label_seq_id.int(D)),l.push(r.auth_seq_id.int(D)),d.push(r.label_atom_id.str(D)),f.push(r.label_alt_id.str(D)),p.push(r.pdbx_PDB_ins_code.str(D)),m.push(r.label_asym_id.str(M)),h.push(r.label_seq_id.int(M)),g.push(r.auth_seq_id.int(M)),y.push(r.label_atom_id.str(M)),b.push(r.label_alt_id.str(M)),x.push(r.pdbx_PDB_ins_code.str(M)),S+=1))}}const A={id:ft.ofStrings(s),conn_type_id:ft.ofStrings(a),ptnr1_label_asym_id:ft.ofStrings(c),ptnr1_label_seq_id:ft.ofNumbers(u),ptnr1_auth_seq_id:ft.ofNumbers(l),ptnr1_label_atom_id:ft.ofStrings(d),pdbx_ptnr1_label_alt_id:ft.ofStrings(f),pdbx_ptnr1_PDB_ins_code:ft.ofStrings(p),ptnr2_label_asym_id:ft.ofStrings(m),ptnr2_label_seq_id:ft.ofNumbers(h),ptnr2_auth_seq_id:ft.ofNumbers(g),ptnr2_label_atom_id:ft.ofStrings(y),pdbx_ptnr2_label_alt_id:ft.ofStrings(b),pdbx_ptnr2_PDB_ins_code:ft.ofStrings(x)};return ss.ofFields("struct_conn",A)}(t,g[0],g[1],w));const D={entity:ss.ofTable("entity",d.getEntityTable()),chem_comp:ss.ofTable("chem_comp",E.getChemCompTable()),atom_site:ss.ofFields("atom_site",w),atom_site_anisotrop:ss.ofFields("atom_site_anisotrop",aWe(l))};for(const I of f)D[I.name]=I;return{header:e.id||"PDB",categoryNames:Object.keys(D),categories:D}}),B5.apply(this,arguments)}var Mv,O5,L5;function mWe(e){return Object.keys(e).filter(t=>!isNaN(t)).map(t=>+t).sort((t,n)=>t-n).map(t=>e[t])}function U5(e,t,n){return e&&void 0!==e[t]?e[t]:n}function Je(e,...t){return{kind:"alias",aliases:t,symbol:e}}function BD(e,t,...n){return e.info.namespace="molscript-macro",e.id=`molscript-macro.${e.info.name}`,{kind:"macro",symbol:e,translate:t,aliases:[e.info.name,...n]}}function gWe(e){return"alias"===e.kind||"macro"===e.kind}!function(e){e.Descriptor={name:"atom_partial_charge"},e.Provider=td.create(e.Descriptor)}(Mv||(Mv={})),function(e){e.is=function t(r){return"pdb"===r?.kind},e.create=function n(r){return{kind:"pdb",name:r.id||"",data:r}}}(O5||(O5={})),function(e){e.is=function t(r){return"psf"===r?.kind},e.fromPsf=function n(r){return{kind:"psf",name:r.id,data:r}}}(L5||(L5={}));const yWe=[["Core symbols",Je(ye.core.type.bool,"bool"),Je(ye.core.type.num,"num"),Je(ye.core.type.str,"str"),Je(ye.core.type.regex,"regex"),Je(ye.core.type.list,"list"),Je(ye.core.type.set,"set"),Je(ye.core.type.compositeKey,"composite-key"),Je(ye.core.logic.not,"not"),Je(ye.core.logic.and,"and"),Je(ye.core.logic.or,"or"),Je(ye.core.ctrl.if,"if"),Je(ye.core.ctrl.fn,"fn"),Je(ye.core.ctrl.eval,"eval"),Je(ye.core.math.add,"add","+"),Je(ye.core.math.sub,"sub","-"),Je(ye.core.math.mult,"mult","*"),Je(ye.core.math.div,"div","/"),Je(ye.core.math.pow,"pow","**"),Je(ye.core.math.mod,"mod"),Je(ye.core.math.min,"min"),Je(ye.core.math.max,"max"),Je(ye.core.math.cantorPairing,"cantor-pairing"),Je(ye.core.math.sortedCantorPairing,"sorted-cantor-pairing"),Je(ye.core.math.invertCantorPairing,"invert-cantor-pairing"),Je(ye.core.math.floor,"floor"),Je(ye.core.math.ceil,"ceil"),Je(ye.core.math.roundInt,"round"),Je(ye.core.math.trunc,"trunc"),Je(ye.core.math.abs,"abs"),Je(ye.core.math.sign,"sign"),Je(ye.core.math.sqrt,"sqrt"),Je(ye.core.math.cbrt,"cbrt"),Je(ye.core.math.sin,"sin"),Je(ye.core.math.cos,"cos"),Je(ye.core.math.tan,"tan"),Je(ye.core.math.asin,"asin"),Je(ye.core.math.acos,"acos"),Je(ye.core.math.atan,"atan"),Je(ye.core.math.sinh,"sinh"),Je(ye.core.math.cosh,"cosh"),Je(ye.core.math.tanh,"tanh"),Je(ye.core.math.exp,"exp"),Je(ye.core.math.log,"log"),Je(ye.core.math.log10,"log10"),Je(ye.core.math.atan2,"atan2"),Je(ye.core.rel.eq,"eq","="),Je(ye.core.rel.neq,"neq","!="),Je(ye.core.rel.lt,"lt","<"),Je(ye.core.rel.lte,"lte","<="),Je(ye.core.rel.gr,"gr",">"),Je(ye.core.rel.gre,"gre",">="),Je(ye.core.rel.inRange,"in-range"),Je(ye.core.str.concat,"concat"),Je(ye.core.str.match,"regex.match"),Je(ye.core.list.getAt,"list.get"),Je(ye.core.set.has,"set.has"),Je(ye.core.set.isSubset,"set.subset")],["Structure",["Types",Je(ye.structureQuery.type.entityType,"ent-type"),Je(ye.structureQuery.type.authResidueId,"auth-resid"),Je(ye.structureQuery.type.labelResidueId,"label-resid"),Je(ye.structureQuery.type.ringFingerprint,"ringfp"),Je(ye.structureQuery.type.bondFlags,"bond-flags")],["Slots",Je(ye.structureQuery.slot.elementSetReduce,"atom.set.reduce.value")],["Generators",Je(ye.structureQuery.generator.atomGroups,"sel.atom.atom-groups"),Je(ye.structureQuery.generator.queryInSelection,"sel.atom.query-in-selection"),Je(ye.structureQuery.generator.rings,"sel.atom.rings"),Je(ye.structureQuery.generator.empty,"sel.atom.empty"),Je(ye.structureQuery.generator.all,"sel.atom.all"),Je(ye.structureQuery.generator.bondedAtomicPairs,"sel.atom.bonded-pairs"),BD(o2("sel.atom.atoms",Ot.Dictionary({0:ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test applied to each atom."})}),wt.ElementSelection,"A selection of singleton atom sets."),e=>ue.struct.generator.atomGroups({"atom-test":U5(e,0,!0)})),BD(o2("sel.atom.res",Ot.Dictionary({0:ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test applied to the 1st atom of each residue."})}),wt.ElementSelection,"A selection of atom sets grouped by residue."),e=>ue.struct.generator.atomGroups({"residue-test":U5(e,0,!0),"group-by":ue.ammp("residueKey")})),BD(o2("sel.atom.chains",Ot.Dictionary({0:ct(Ae.Bool,{isOptional:!0,defaultValue:!0,description:"Test applied to the 1st atom of each chain."})}),wt.ElementSelection,"A selection of atom sets grouped by chain."),e=>ue.struct.generator.atomGroups({"chain-test":U5(e,0,!0),"group-by":ue.ammp("chainKey")}))],["Modifiers",Je(ye.structureQuery.modifier.queryEach,"sel.atom.query-each"),Je(ye.structureQuery.modifier.intersectBy,"sel.atom.intersect-by"),Je(ye.structureQuery.modifier.exceptBy,"sel.atom.except-by"),Je(ye.structureQuery.modifier.unionBy,"sel.atom.union-by"),Je(ye.structureQuery.modifier.union,"sel.atom.union"),Je(ye.structureQuery.modifier.cluster,"sel.atom.cluster"),Je(ye.structureQuery.modifier.includeSurroundings,"sel.atom.include-surroundings"),Je(ye.structureQuery.modifier.surroundingLigands,"sel.atom.surrounding-ligands"),Je(ye.structureQuery.modifier.includeConnected,"sel.atom.include-connected"),Je(ye.structureQuery.modifier.expandProperty,"sel.atom.expand-property")],["Filters",Je(ye.structureQuery.filter.pick,"sel.atom.pick"),Je(ye.structureQuery.filter.first,"sel.atom.first"),Je(ye.structureQuery.filter.withSameAtomProperties,"sel.atom.with-same-atom-properties"),Je(ye.structureQuery.filter.intersectedBy,"sel.atom.intersected-by"),Je(ye.structureQuery.filter.within,"sel.atom.within"),Je(ye.structureQuery.filter.isConnectedTo,"sel.atom.is-connected-to")],["Combinators",Je(ye.structureQuery.combinator.intersect,"sel.atom.intersect"),Je(ye.structureQuery.combinator.merge,"sel.atom.merge"),Je(ye.structureQuery.combinator.distanceCluster,"sel.atom.dist-cluster")],["Atom Set Properties",Je(ye.structureQuery.atomSet.atomCount,"atom.set.atom-count"),Je(ye.structureQuery.atomSet.countQuery,"atom.set.count-query"),Je(ye.structureQuery.atomSet.reduce,"atom.set.reduce"),Je(ye.structureQuery.atomSet.propertySet,"atom.set.property")],["Atom Properties",Je(ye.structureQuery.atomProperty.core.elementSymbol,"atom.el"),Je(ye.structureQuery.atomProperty.core.vdw,"atom.vdw"),Je(ye.structureQuery.atomProperty.core.mass,"atom.mass"),Je(ye.structureQuery.atomProperty.core.atomicNumber,"atom.atomic-number"),Je(ye.structureQuery.atomProperty.core.x,"atom.x"),Je(ye.structureQuery.atomProperty.core.y,"atom.y"),Je(ye.structureQuery.atomProperty.core.z,"atom.z"),Je(ye.structureQuery.atomProperty.core.sourceIndex,"atom.src-index"),Je(ye.structureQuery.atomProperty.core.operatorName,"atom.op-name"),Je(ye.structureQuery.atomProperty.core.operatorKey,"atom.op-key"),Je(ye.structureQuery.atomProperty.core.modelIndex,"atom.model-index"),Je(ye.structureQuery.atomProperty.core.modelLabel,"atom.model-label"),Je(ye.structureQuery.atomProperty.core.atomKey,"atom.key"),Je(ye.structureQuery.atomProperty.core.bondCount,"atom.bond-count"),Je(ye.structureQuery.atomProperty.topology.connectedComponentKey,"atom.key.molecule"),Je(ye.structureQuery.atomProperty.macromolecular.authResidueId,"atom.auth-resid"),Je(ye.structureQuery.atomProperty.macromolecular.labelResidueId,"atom.label-resid"),Je(ye.structureQuery.atomProperty.macromolecular.residueKey,"atom.key.res"),Je(ye.structureQuery.atomProperty.macromolecular.chainKey,"atom.key.chain"),Je(ye.structureQuery.atomProperty.macromolecular.entityKey,"atom.key.entity"),Je(ye.structureQuery.atomProperty.macromolecular.isHet,"atom.is-het"),Je(ye.structureQuery.atomProperty.macromolecular.id,"atom.id"),Je(ye.structureQuery.atomProperty.macromolecular.label_atom_id,"atom.label_atom_id"),Je(ye.structureQuery.atomProperty.macromolecular.label_alt_id,"atom.label_alt_id","atom.altloc"),Je(ye.structureQuery.atomProperty.macromolecular.label_comp_id,"atom.label_comp_id"),Je(ye.structureQuery.atomProperty.macromolecular.label_asym_id,"atom.label_asym_id"),Je(ye.structureQuery.atomProperty.macromolecular.label_entity_id,"atom.label_entity_id"),Je(ye.structureQuery.atomProperty.macromolecular.label_seq_id,"atom.label_seq_id"),Je(ye.structureQuery.atomProperty.macromolecular.auth_atom_id,"atom.auth_atom_id","atom.name"),Je(ye.structureQuery.atomProperty.macromolecular.auth_comp_id,"atom.auth_comp_id","atom.resname"),Je(ye.structureQuery.atomProperty.macromolecular.auth_asym_id,"atom.auth_asym_id","atom.chain"),Je(ye.structureQuery.atomProperty.macromolecular.auth_seq_id,"atom.auth_seq_id","atom.resno"),Je(ye.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code,"atom.pdbx_PDB_ins_code","atom.inscode"),Je(ye.structureQuery.atomProperty.macromolecular.pdbx_formal_charge,"atom.pdbx_formal_charge"),Je(ye.structureQuery.atomProperty.macromolecular.occupancy,"atom.occupancy"),Je(ye.structureQuery.atomProperty.macromolecular.B_iso_or_equiv,"atom.B_iso_or_equiv","atom.bfactor"),Je(ye.structureQuery.atomProperty.macromolecular.entityType,"atom.entity-type"),Je(ye.structureQuery.atomProperty.macromolecular.entitySubtype,"atom.entity-subtype"),Je(ye.structureQuery.atomProperty.macromolecular.entityPrdId,"atom.entity-prd-id"),Je(ye.structureQuery.atomProperty.macromolecular.entityDescription,"atom.entity-description"),Je(ye.structureQuery.atomProperty.macromolecular.objectPrimitive,"atom.object-primitive"),Je(ye.structureQuery.atomProperty.macromolecular.chemCompType,"atom.chem-comp-type"),Je(ye.structureQuery.atomProperty.macromolecular.secondaryStructureKey,"atom.key.sec-struct"),Je(ye.structureQuery.atomProperty.macromolecular.isModified,"atom.is-modified"),Je(ye.structureQuery.atomProperty.macromolecular.modifiedParentName,"atom.modified-parent")],["Bond Properties",Je(ye.structureQuery.bondProperty.order,"bond.order"),Je(ye.structureQuery.bondProperty.length,"bond.length"),Je(ye.structureQuery.bondProperty.key,"bond.key"),Je(ye.structureQuery.bondProperty.atomA,"bond.atom-a"),Je(ye.structureQuery.bondProperty.atomB,"bond.atom-b"),BD(o2("bond.is",Ot.List(wt.BondFlag),Ae.Bool,`Test if the current bond has at least one (or all if partial = false) of the specified flags: ${Ae.oneOfValues(wt.BondFlag).join(", ")}`),e=>ue.core.flags.hasAny([ue.struct.bondProperty.flags(),ue.struct.type.bondFlags(mWe(e))]))]]],noe=[];!function roe(e){for(const t of e)gWe(t)?noe.push(t):t instanceof Array&&roe(t)}(yWe);const OD=function(){const e=[],t=Object.create(null),n=kr.create(),r=kr.create();for(const i of noe){for(const s of i.aliases){if(e.push([s,i]),t[s])throw new Error(`Alias '${s}' already in use.`);t[s]=i}const o=i.symbol.args;if("dictionary"===o.kind)for(const s of Object.keys(o.map)){isNaN(s)&&kr.add(n,s,s);const a=o.map[s];"oneof"===a.type.kind&&Ae.oneOfValues(a.type).forEach(c=>kr.add(r,c,c))}else"oneof"===o.type.kind&&Ae.oneOfValues(o.type).forEach(s=>kr.add(r,s,s))}return{symbolList:e,symbolMap:t,namedArgs:n.array,constants:r.array}}(),Rv=OD.symbolMap;function _S(e){if(as.isLiteral(e))return e;if(as.isSymbol(e)){if(!Rv[e.name])return e;const s=Rv[e.name];if("alias"===s.kind)return as.Symbol(Rv[e.name].symbol.id);throw s.translate([])}const t=as.isSymbol(e.head)&&!!Rv[e.head.name]&&"macro"===Rv[e.head.name].kind,n=t?e.head:_S(e.head),r=n!==e.head;if(!e.args)return t?_S(e.head):r?as.Apply(n):e;let o,i=!1;if(as.isArgumentsArray(e.args)){o=[];for(let s=0,a=e.args.length;s12?"...'":"'";return` at line ${n.line} column ${n.column}, got ${r>0?"'...":"'"}${e.slice(r,r+12)}${o}`}(e,t)}`}(t,n);throw new Error(r)}}or(t){return Be.alt(this,t)}trim(t){return this.wrap(t,t)}wrap(t,n){return V5(1,"string"==typeof t?Be.string(t):t,this,"string"==typeof n?Be.string(n):n)}thru(t){return t(this)}then(t){return V5(1,this,t)}many(){return new Be((t,n)=>{const r=[];let i;for(;;){if(i=pl(this._(t,n),i),!i.status)return pl(Sa(n,r),i);if(n===i.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");n=i.index,r.push(i.value)}})}times(t,n){const r=typeof n>"u"?t:n;return new Be((i,o)=>{const s=[];let a,c,u;for(u=0;ut)}atMost(t){return this.times(0,t)}atLeast(t){return Be.seq(this.times(t),this.many()).map(n=>[...n[0],...n[1]])}map(t){return new Be((n,r)=>{const i=this._(n,r);return i.status?pl(Sa(i.index,t(i.value)),i):i})}skip(t){return V5(0,this,t)}mark(){return Be.seq(Be.index,this,Be.index).map(t=>({start:t[0],value:t[1],end:t[2]}))}node(t){return Be.seq(Be.index,this,Be.index).map(n=>({name:t,start:n[0],value:n[1],end:n[2]}))}sepBy(t){return Be.sepBy(this,t)}sepBy1(t){return Be.sepBy1(this,t)}lookahead(t){return this.skip(Be.lookahead(t))}notFollowedBy(t){return this.skip(Be.notFollowedBy(t))}desc(t){return new Be((n,r)=>{const i=this._(n,r);return i.status||(i.expected=[t]),i})}fallback(t){return this.or(Be.succeed(t))}ap(t){return Be.seq(t,this).map(([n,r])=>n(r))}chain(t){return new Be((n,r)=>{const i=this._(n,r);return i.status?pl(t(i.value)._(n,i.index),i):i})}}function V5(e,...t){const n=t.length;return new Be((r,i)=>{let o,s,a=i;for(let c=0;ct.furthest)return e;const n=e.furthest===t.furthest?function SWe(e,t){const n=e.length,r=t.length;if(0===n)return t;if(0===r)return e;const i=new Set,o=[];for(let s=0;s{let T;const M=new Array(D);let N=R;for(let V=0;V{let T;for(let M=0;M[R[0],...R[1]])}function a(w){const D=`'${w}'`;if(1===w.length){const I=w.charCodeAt(0);return new e((R,T)=>R.charCodeAt(T)===I?Sa(T+1,w):$p(T,D))}return new e((I,R)=>{const T=R+w.length;return I.slice(R,T)===w?Sa(T,w):$p(R,D)})}function l(w,D=0){const I=function u(w){return RegExp("^(?:"+w.source+")",function c(w){const D=""+w;return D.slice(D.lastIndexOf("/")+1)}(w))}(w),R=""+w;return new e((T,M)=>{const N=I.exec(T.slice(M));return N?0<=D&&D<=N.length?Sa(M+N[0].length,N[D]):$p(M,`invalid match group (0 to ${N.length}) in ${R}`):$p(M,R)})}function d(w){return new e((D,I)=>Sa(I,w))}function f(w){return new e((D,I)=>$p(I,w))}function h(w){return new e((D,I)=>{const R=D.charAt(I);return I{const T=w()._;return D._=T,T(I,R)});return D}e.seqMap=function t(w,D,I){const R=[].slice.call(arguments);if(0===R.length)throw new Error("seqMap needs at least one argument");const T=R.pop();return function wWe(e){if("function"!=typeof e)throw new Error("not a function: "+e)}(T),r.apply(null,R).map(function(M){return T.apply(null,M)})},e.createLanguage=function n(w){const D={};for(const I of Object.keys(w))!function(R){D[R]=_(()=>w[R](D))}(I);return D},e.seq=r,e.alt=i,e.sepBy=function o(w,D){return s(w,D).or(d([]))},e.sepBy1=s,e.string=a,e.regexp=l,e.succeed=d,e.fail=f,e.lookahead=function p(w){if(function CWe(e){return e instanceof Be}(w))return new e((D,I)=>{const R=w._(D,I);return R.status&&(R.index=I,R.value=null),R});if("string"==typeof w)return p(a(w));if(w instanceof RegExp)return p(l(w));throw new Error("not a string, regexp, or parser: "+w)},e.notFollowedBy=function m(w){return new e((D,I)=>{const R=w._(D,I);return R.status?$p(I,'not "'+D.slice(I,R.index)+'"'):Sa(I,null)})},e.test=h,e.oneOf=function g(w){return h(D=>w.indexOf(D)>=0)},e.noneOf=function y(w){return h(D=>w.indexOf(D)<0)},e.range=function b(w,D){return h(I=>w<=I&&I<=D).desc(w+"-"+D)},e.takeWhile=function x(w){return new e((D,I)=>{let R=I;for(;RD>=w.length?$p(D,"any character"):Sa(D+1,w.charAt(D))),e.all=new e(function(w,D){return Sa(w.length,w.slice(D))}),e.eof=new e(function(w,D){return DBe.alt(i,d,o,s).trim(n)),i=Be.takeWhile(_=>"`"!==_).trim("`").map(t.str),o=Be.regexp(/[^()\[\]{};`,\n\r\s]+/).map(t.symb),s=Be.regexp(/\s*;+([^\n\r]*)\n/,1).map(t.comment),a=r.many(),c=a.wrap("(",")").map(_=>t.list("(",_)),u=a.wrap("[","]").map(_=>t.list("[",_)),l=a.wrap("{","}").map(_=>t.list("{",_)),d=Be.alt(c,u,l),f=r.many();function m(_){switch(_.kind){case"string":return _.value;case"symbol":{const S=_.value;if(S.length>1)switch(S.charAt(0)){case".":return ue.atomName(S.substr(1));case"_":return ue.struct.type.elementSymbol([S.substr(1)])}return"true"===S||"false"!==S&&(function b(_){return/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/.test(_)&&!isNaN(+_)}(S)?+S:as.Symbol(S))}case"list":switch(_.bracket){case"[":return ue.core.type.list(y(_.nodes).map(m));case"{":return ue.core.type.set(y(_.nodes).map(m));case"(":{if("comment"===_.nodes[0].kind)throw new Error("Invalid expression");const S=m(_.nodes[0]);return as.Apply(S,function h(_){if(_.length<=1)return;if(!function g(_){for(let S=1,A=_.length;S1&&":"===E.value.charAt(0))return!0}return!1}(_)){const w=[];for(let D=1,I=_.length;D1&&":"===I.value.charAt(0)){const R=I.value.substr(1);for(++w;w=D)throw new Error(`There must be a value foolowed a named arg ':${R}'.`);if("comment"===_[w].kind)throw new Error("Invalid expression");S[R]=m(_[w]),isNaN(+R)&&(A=!1)}else S[E++]=m(I)}if(A){const w=Object.keys(S).map(I=>+I).sort((I,R)=>I-R);let D=!0;for(let I=0,R=w.length;I"comment"!==A.kind):_}e.parse=function x(_){const S=function p(_){return f.tryParse(_)}(_),A=[];for(const E of S)"comment"!==E.kind&&(A[A.length]=m(E));return A}}(z5||(z5={}));const $r=ue;function Ca(e,t,n){const r=Be.lazy(()=>Be.seq(e,r).map(i=>n(...i)).or(t));return r}function LD(e,t,n){return Be.seqMap(t,e.many(),(r,i)=>i.reduce((o,s)=>n(s,o),r))}function sc(e,t,n){return Be.seqMap(t,Be.seq(e,t).many(),(r,i)=>i.reduce((o,s)=>{const[a,c]=s;return n(a,o,c)},r))}function xS(e,t){return e.reduce((r,i)=>{const o=i.isUnsupported?bm(`operator '${i.name}' not supported`):i.map;return i.type(i.rule,r,o)},t)}function Yp(e,t=0){return Be.optWhitespace.then(Be.regexp(e,t).skip(Be.optWhitespace))}function xu(e,t=0){return Be.regexp(e,t).skip(Be.optWhitespace)}function UD(e,t=0){return Be.optWhitespace.then(Be.regexp(e,t))}function G5(e,t){const n=t?`${e}|${s2(t)}`:e;return Yp(RegExp(`(${n})\\s+([-+]?[0-9]*\\.?[0-9]+)\\s+OF`,"i"),2).map(parseFloat)}function bm(e){return function(){throw new Error(e)}}function j5(e){return 1===e.length?e[0]:e.length>1?$r.core.logic.and(e):void 0}function H5(e,t){if(!t||void 0===t.op||void 0===t.val)return t&&void 0!==t.flags?$r.core.flags.hasAny([e,t.flags]):t&&void 0!==t.min&&void 0!==t.max?$r.core.rel.inRange([e,t.min,t.max]):Array.isArray(t)?t.length>1?$r.core.set.has([$r.core.type.set(t),e]):$r.core.rel.eq([e,t[0]]):$r.core.rel.eq([e,t]);{const n=[e,t.val];switch(t.op){case"=":return $r.core.rel.eq(n);case"!=":return $r.core.rel.neq(n);case">":return $r.core.rel.gr(n);case"<":return $r.core.rel.lt(n);case">=":return $r.core.rel.gre(n);case"<=":return $r.core.rel.lte(n);default:throw new Error(`operator '${t.op}' not supported`)}}}function Su(e){return $r.struct.generator.queryInSelection({0:e,query:$r.struct.generator.all(),"in-complement":!0})}function vf(e,t){return e.length{const r=e[n],i=bm(`property '${n}' not supported`),o=Be.regexp(r.regex).map(c=>(r.isUnsupported&&i(),H5(r.property,r.map(c)))),s=Be.regexp(q5(n,r.abbr)).trim(Be.optWhitespace),a=c=>$r.struct.generator.atomGroups({[r.level]:c});t.push(r.isNumeric?s.then(Be.seq(Be.regexp(/>=|<=|=|!=|>|(r.isUnsupported&&i(),H5(r.property,{op:c[0],val:c[1]}))).map(a):s.then(o).map(a))}),t}function W5(e){const t=[];return Object.keys(e).sort(vf).forEach(n=>{const r=e[n],i=r.map?r.map:bm(`keyword '${n}' not supported`),o=Be.regexp(q5(n,r.abbr)).map(i);t.push(o)}),t}function $5(e,t){const n=[];return Object.keys(e).sort(vf).forEach(r=>{const i=e[r],o=bm(`property '${r}' not supported`),s=Be.regexp(q5(r,i.abbr)).lookahead(t).map(()=>(i.isUnsupported&&o(),i.property));n.push(s)}),n}function Y5(e,t,n,r){const i=[];for(const o in e)i.push(o),e[o].abbr&&i.push(...e[o].abbr);for(const o in t)i.push(o),t[o].abbr&&i.push(...t[o].abbr);return n.forEach(o=>{i.push(o.name),o.abbr&&i.push(...o.abbr)}),i}function _f(e){return $r.core.type.set(e.map($r.atomName))}function xf(e){return $r.struct.generator.queryInSelection({0:e,query:$r.struct.generator.all()})}function SS(e,t,n){switch(e.head.name){case"structure-query.atom-property.macromolecular.label_atom_id":return $r.atomName(t);case"structure-query.atom-property.core.element-symbol":return $r.es(t);case"structure-query.atom-property.macromolecular.secondary-structure-flags":return n&&(t=[n[t.toUpperCase()]||"none"]),$r.struct.type.secondaryStructureFlags([t]);default:return t}}const EWe=["entityKey","label_entity_id","entityType"],PWe=["chainKey","label_asym_id","label_entity_id","auth_asym_id","entityType"],MWe=["residueKey","label_comp_id","label_seq_id","auth_comp_id","auth_seq_id","pdbx_formal_charge","secondaryStructureKey","secondaryStructureFlags","isModified","modifiedParentName"];function RWe(e){if(e.head.name.startsWith("structure-query.atom-property.macromolecular.")){const t=e.head.name.substr(45);if(EWe.includes(t))return"entity-test";if(PWe.includes(t))return"chain-test";if(MWe.includes(t))return"residue-test"}return"atom-test"}const kWe=["structure-query.atom-property.macromolecular.secondary-structure-flags"];function er(e){return $r.struct.generator.atomGroups({"residue-test":$r.core.set.has([$r.core.type.set(e),$r.ammp("label_comp_id")])})}const xo=ue,hl=/[-+]?[0-9]*\.?[0-9]+/,CS=/[0-9]+/;function Qt(e){return e}const FWe={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 aoe(e){if(e.head){if(e.head.name&&"core.type.regex"===e.head.name&&(e=e.args[0].replace(/^\^|\$$/g,"")),e=FWe[e.toString().toLowerCase()]||"none",-1!==["dna","rna","carbohydrate"].indexOf(e))throw new Error("values 'dna', 'rna', 'carbohydrate' not yet supported for 'structure' property");return xo.struct.type.secondaryStructureFlags([e])}}const coe={adpmax:{"@desc":"the maximum anisotropic displacement parameter for the selected atom","@examples":[""],isUnsupported:!0,regex:hl,map:e=>parseFloat(e),level:"atom-test"},adpmin:{"@desc":"the minimum anisotropic displacement parameter for the selected atom","@examples":[""],isUnsupported:!0,regex:hl,map:e=>parseFloat(e),level:"atom-test"},altloc:{"@desc":"PDB alternate location identifier","@examples":["altloc = A"],regex:/[a-zA-Z0-9]/,map:Qt,level:"atom-test",property:xo.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:Qt,level:"atom-test"},atomID:{"@desc":"special atom IDs for PDB atoms assigned by Jmol","@examples":[""],isUnsupported:!0,regex:CS,map:e=>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:CS,map:e=>parseInt(e),level:"atom-test"},atomName:{"@desc":"atom name","@examples":["atomName = CA"],regex:/[a-zA-Z0-9]+/,map:e=>xo.atomName(e),level:"atom-test",property:xo.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:CS,map:e=>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:e=>xo.atomName(e),level:"atom-test",property:xo.ammp("label_atom_id")},atomX:{"@desc":"Cartesian X coordinate (or just X)","@examples":["x = 4.2"],abbr:["X"],isNumeric:!0,regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.acp("x")},atomY:{"@desc":"Cartesian Y coordinate (or just Y)","@examples":["y < 42"],abbr:["Y"],isNumeric:!0,regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.acp("y")},atomZ:{"@desc":"Cartesian Z coordinate (or just Z)","@examples":["Z > 10"],abbr:["Z"],isNumeric:!0,regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.acp("z")},bondcount:{"@desc":"covalent bond count","@examples":["bondcount = 0"],isNumeric:!0,regex:CS,map:e=>parseInt(e),level:"atom-test",property:xo.acp("bondCount")},bondingRadius:{"@desc":"radius used for auto bonding; synonymous with ionic and ionicRadius","@examples":[""],abbr:["ionic","ionicRadius"],isUnsupported:!0,regex:hl,map:e=>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:Qt,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:CS,map:e=>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:Qt,level:"chain-test",property:xo.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:Qt,level:"atom-test"},color:{"@desc":"the atom color","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,level:"atom-test"},cs:{"@desc":"chemical shift calculated using computational results that include magnetic shielding tensors.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:e=>xo.es(e),level:"atom-test",property:xo.acp("elementSymbol")},elemno:{"@desc":"atomic element number","@examples":["elemno=8"],regex:/[0-9\s{}-]+/,map:e=>parseInt(e),level:"atom-test",property:xo.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:Qt,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:Qt,level:"atom-test"},file:{"@desc":"file number containing this atom","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},formalCharge:{"@desc":"formal charge","@examples":["formalCharge=1"],regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.ammp("pdbx_formal_charge")},format:{"@desc":"format (label) of the atom.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fXyz:{"@desc":"fractional XYZ coordinates","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fX:{"@desc":"fractional X coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fY:{"@desc":"fractional Y coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fZ:{"@desc":"fractional Z coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fuxyz:{"@desc":"fractional XYZ coordinates in the unitcell coordinate system","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fux:{"@desc":"fractional X coordinate in the unitcell coordinate system","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fuy:{"@desc":"fractional Y coordinate in the unitcell coordinate system","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},fuz:{"@desc":"fractional Z coordinate in the unit cell coordinate system","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},group:{"@desc":"3-letter residue code","@examples":["group = ALA"],regex:/[a-zA-Z0-9]{1,3}/,map:Qt,level:"residue-test",property:xo.ammp("label_comp_id")},group1:{"@desc":"single-letter residue code (amino acids only)","@examples":["group1 = G"],regex:/[a-zA-Z]/,map:Qt,level:"residue-test",property:xo.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:Qt,level:"atom-test"},groupindex:{"@desc":"overall group index","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,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:Qt,level:"atom-test"},insertion:{"@desc":"protein residue insertion code","@examples":["insertion=A"],regex:/[a-zA-Z0-9]/,map:Qt,level:"atom-test",property:xo.ammp("pdbx_PDB_ins_code")},label:{"@desc":"current atom label (same as format)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},mass:{"@desc":"atomic mass -- especially useful with appended .max or .sum","@examples":["mass > 13"],regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.acp("mass")},model:{"@desc":"model number","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,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:Qt,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:Qt,level:"atom-test"},molecule:{"@desc":"molecule number","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,level:"atom-test"},ms:{"@desc":"magnetic shielding calculated from file-loaded tensors.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.ammp("occupancy")},partialCharge:{"@desc":"partial charge","@examples":[""],isUnsupported:!0,regex:hl,map:e=>parseFloat(e),level:"atom-test"},phi:{"@desc":"protein group PHI angle for atom's residue","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},polymer:{"@desc":"sequential polymer number in a model, starting with 1.","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},polymerLength:{"@desc":"polymer length","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},property_xx:{"@desc":"a property created using the DATA command","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},psi:{"@desc":"protein group PSI angle for the atom's residue","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,level:"atom-test"},resno:{"@desc":"PDB residue number, not including insertion code (see also seqcode, below)","@examples":["resno = 100"],regex:/-?[0-9]+/,map:e=>parseInt(e),level:"residue-test",property:xo.ammp("auth_seq_id")},selected:{"@desc":"1.0 if atom is selected; 0.0 if not","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,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:Qt,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:Qt,level:"atom-test"},shape:{"@desc":'hybridization geometry such as "tetrahedral"',"@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},site:{"@desc":"crystallographic site number","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},spacefill:{"@desc":"currently displayed radius","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,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:Qt,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:Qt,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:Qt,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:Qt,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:Qt,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:Qt,level:"atom-test"},temperature:{"@desc":"yes yes temperature factor (B-factor)","@examples":["temperature >= 20"],regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.ammp("B_iso_or_equiv")},unitXyz:{"@desc":"unit cell XYZ coordinates","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},uX:{"@desc":"unit cell X coordinate normalized to [0,1)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},uY:{"@desc":"unit cell Y coordinate normalized to [0,1)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},uZ:{"@desc":"unit cell Z coordinate normalized to [0,1)","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,level:"atom-test"},vanderwaals:{"@desc":"van der Waals radius","@examples":["vanderwaals >2"],regex:hl,map:e=>parseFloat(e),level:"atom-test",property:xo.acp("vdw")},vectorScale:{"@desc":"vibration vector scale","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,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:Qt,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:Qt,level:"atom-test"},vY:{"@desc":"vibration vector Y coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,level:"atom-test"},vZ:{"@desc":"vibration vector Z coordinate","@examples":[""],isUnsupported:!0,regex:/[0-9\s{}-]+/,map:Qt,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:Qt,level:"atom-test"}},uoe=ue,loe=[{"@desc":"Selects atoms that are not included in s1.","@examples":["not ARG"],name:"not",type:Ca,rule:Be.alt(Be.regex(/NOT/i).skip(Be.whitespace),Be.string("!").skip(Be.optWhitespace)),map:(e,t)=>Su(t)},{"@desc":"Selects atoms included in both s1 and s2.","@examples":["ASP and .CA"],name:"and",type:sc,rule:Yp(/AND|&/i),map:(e,t,n)=>uoe.struct.modifier.intersectBy({0:t,by:n})},{"@desc":"Selects atoms included in either s1 or s2.","@examples":["ASP or GLU"],name:"or",type:sc,rule:Yp(/OR|\||,/i),map:(e,t,n)=>uoe.struct.combinator.merge([t,n])}],Pe=ue,Ci={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"]},doe_nucleic=["P","O3'","O5'","C5'","C4'","C3'","OP1","OP2","O3*","O5*","C5*","C4*","C3*","C2'","C1'","O4'","O2'"],doe_protein=["C","N","CA"];function wS(){return Pe.struct.combinator.merge([Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.set(...Ci.nucleic),Pe.ammp("label_comp_id")])}),Pe.struct.filter.pick({0:Pe.struct.generator.atomGroups({"group-by":Pe.ammp("residueKey")}),test:Pe.core.logic.and([Pe.core.rel.eq([Pe.struct.atomSet.atomCount(),1]),Pe.core.rel.eq([Pe.ammp("label_atom_id"),Pe.atomName("P")])])}),Pe.struct.filter.pick({0:Pe.struct.generator.atomGroups({"group-by":Pe.ammp("residueKey")}),test:Pe.core.logic.or([Pe.core.set.isSubset([_f(["C1'","C2'","O3'","C3'","C4'","C5'","O5'"]),Pe.ammpSet("label_atom_id")]),Pe.core.set.isSubset([_f(["C1*","C2*","O3*","C3*","C4*","C5*","O5*"]),Pe.ammpSet("label_atom_id")])])})])}const foe={all:{"@desc":"all atoms; same as *",abbr:["*"],map:()=>Pe.struct.generator.all()},bonded:{"@desc":"covalently bonded",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.rel.gr([Pe.struct.atomProperty.core.bondCount({flags:Pe.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:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.rel.gr([Pe.struct.atomProperty.core.bondCount({flags:Pe.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:()=>Pe.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:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.set(...["H","He","B","C","N","O","F","Ne","Si","P","S","Cl","Ar","As","Se","Br","Kr","Te","I","Xe","At","Rn"].map(Pe.es)),Pe.acp("elementSymbol")])})},metal:{"@desc":"!nonmetal",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.logic.not([Pe.core.set.has([Pe.set(...["H","He","B","C","N","O","F","Ne","Si","P","S","Cl","Ar","As","Se","Br","Kr","Te","I","Xe","At","Rn"].map(Pe.es)),Pe.acp("elementSymbol")])])})},alkaliMetal:{"@desc":"_Li,_Na,_K,_Rb,_Cs,_Fr",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.set(...["Li","Na","K","Rb","Cs","Fr"].map(Pe.es)),Pe.acp("elementSymbol")])})},alkalineEarth:{"@desc":"_Be,_Mg,_Ca,_Sr,_Ba,_Ra",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.set(...["Be","Mg","Ca","Sr","Ba","Ra"].map(Pe.es)),Pe.acp("elementSymbol")])})},nobleGas:{"@desc":"_He,_Ne,_Ar,_Kr,_Xe,_Rn",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.set(...["He","Ne","Ar","Kr","Xe","Rn"].map(Pe.es)),Pe.acp("elementSymbol")])})},metalloid:{"@desc":"_B,_Si,_Ge,_As,_Sb,_Te",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.set(...["B","Si","Ge","As","Sb","Te"].map(Pe.es)),Pe.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:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.logic.or([Pe.core.rel.inRange([Pe.acp("atomicNumber"),21,30]),Pe.core.rel.inRange([Pe.acp("atomicNumber"),39,48]),Pe.core.rel.inRange([Pe.acp("atomicNumber"),72,80]),Pe.core.rel.inRange([Pe.acp("atomicNumber"),104,112]),Pe.core.set.has([Pe.set(57,89),Pe.acp("atomicNumber")])])})},lanthanide:{"@desc":"(does not include La) elemno>57 and elemno<=71",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.rel.inRange([Pe.acp("atomicNumber"),57,71])})},actinide:{"@desc":"(does not include Ac) elemno>89 and elemno<=103",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.rel.inRange([Pe.acp("atomicNumber"),89,103])})},isaromatic:{"@desc":"atoms connected with the AROMATIC, AROMATICSINGLE, or AROMATICDOUBLE bond types",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.rel.gr([Pe.struct.atomProperty.core.bondCount({flags:Pe.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:()=>wS()},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:()=>Pe.struct.modifier.intersectBy({0:wS(),by:Pe.struct.combinator.merge([Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.set("A","G","I","DA","DG","DI","+A","+G","+I"),Pe.ammp("label_comp_id")])}),Pe.struct.filter.pick({0:Pe.struct.generator.atomGroups({"group-by":Pe.ammp("residueKey")}),test:Pe.core.set.isSubset([_f(["N7","C8","N9"]),Pe.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:()=>Pe.struct.modifier.intersectBy({0:wS(),by:Pe.struct.combinator.merge([Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.set("C","T","U","DC","DT","DU","+C","+T","+U"),Pe.ammp("label_comp_id")])}),Pe.struct.filter.pick({0:Pe.struct.generator.atomGroups({"group-by":Pe.ammp("residueKey")}),test:Pe.core.logic.or([Pe.core.set.has([Pe.ammpSet("label_atom_id"),Pe.atomName("O2*")]),Pe.core.set.has([Pe.ammpSet("label_atom_id"),Pe.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:()=>Pe.struct.modifier.intersectBy({0:wS(),by:Pe.struct.combinator.merge([Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.set("DG","DC","DA","DT","DU","DI","T","+G","+C","+A","+T"),Pe.ammp("label_comp_id")])}),Pe.struct.filter.pick({0:Pe.struct.generator.atomGroups({"group-by":Pe.ammp("residueKey")}),test:Pe.core.logic.not([Pe.core.logic.or([Pe.core.set.has([Pe.ammpSet("label_atom_id"),Pe.atomName("O2*")]),Pe.core.set.has([Pe.ammpSet("label_atom_id"),Pe.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:()=>Pe.struct.modifier.intersectBy({0:wS(),by:Pe.struct.combinator.merge([Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.set("G","C","A","U","I","+U","+I"),Pe.ammp("label_comp_id")])}),Pe.struct.filter.pick({0:Pe.struct.generator.atomGroups({"group-by":Pe.ammp("residueKey")}),test:Pe.core.logic.or([Pe.core.set.has([Pe.ammpSet("label_atom_id"),Pe.atomName("O2*")]),Pe.core.set.has([Pe.ammpSet("label_atom_id"),Pe.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 BWe(){return Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.set(...Ci.amino),Pe.ammp("label_comp_id")])})}()},acidic:{"@desc":"ASP GLU",map:()=>er(Ci.acidic)},acyclic:{"@desc":"amino and not cyclic",map:()=>Pe.struct.modifier.intersectBy({0:er(Ci.amino),by:Su(er(Ci.cyclic))})},aliphatic:{"@desc":"ALA GLY ILE LEU VAL",map:()=>er(Ci.aliphatic)},amino:{"@desc":"all twenty standard amino acids, plus ASX, GLX, UNK",map:()=>er(Ci.amino)},aromatic:{"@desc":'HIS PHE TRP TYR (see also "isaromatic" for aromatic bonds)',map:()=>er(Ci.aromatic)},basic:{"@desc":"ARG HIS LYS",map:()=>er(Ci.basic)},buried:{"@desc":"ALA CYS ILE LEU MET PHE TRP VAL",map:()=>er(Ci.buried)},charged:{"@desc":"same as acidic or basic -- ASP GLU, ARG HIS LYS",map:()=>er(Ci.acidic.concat(Ci.basic))},cyclic:{"@desc":"HIS PHE PRO TRP TYR",map:()=>er(Ci.cyclic)},helix:{"@desc":"secondary structure-related.",map:()=>Pe.struct.generator.atomGroups({"residue-test":Pe.core.flags.hasAny([Pe.struct.type.secondaryStructureFlags(["helix"]),Pe.ammp("secondaryStructureFlags")])})},helixalpha:{"@desc":"secondary structure-related.",map:()=>Pe.struct.generator.atomGroups({"residue-test":Pe.core.flags.hasAny([Pe.struct.type.secondaryStructureFlags(["alpha"]),Pe.ammp("secondaryStructureFlags")])})},helix310:{"@desc":"secondary structure-related.",map:()=>Pe.struct.generator.atomGroups({"residue-test":Pe.core.flags.hasAny([Pe.struct.type.secondaryStructureFlags(["3-10"]),Pe.ammp("secondaryStructureFlags")])})},helixpi:{"@desc":"secondary structure-related.",map:()=>Pe.struct.generator.atomGroups({"residue-test":Pe.core.flags.hasAny([Pe.struct.type.secondaryStructureFlags(["pi"]),Pe.ammp("secondaryStructureFlags")])})},hetero:{"@desc":"PDB atoms designated as HETATM",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.ammp("isHet")})},hydrophobic:{"@desc":"ALA GLY ILE LEU MET PHE PRO TRP TYR VAL",map:()=>er(Ci.hydrophobic)},large:{"@desc":"ARG GLU GLN HIS ILE LEU LYS MET PHE TRP TYR",map:()=>er(Ci.large)},medium:{"@desc":"ASN ASP CYS PRO THR VAL",map:()=>er(Ci.medium)},negative:{"@desc":"same as acidic -- ASP GLU",map:()=>er(Ci.acidic)},neutral:{"@desc":"amino and not (acidic or basic)",map:()=>Pe.struct.modifier.intersectBy({0:er(Ci.amino),by:Su(er(Ci.acidic.concat(Ci.basic)))})},polar:{"@desc":"amino and not hydrophobic",map:()=>Pe.struct.modifier.intersectBy({0:er(Ci.amino),by:Su(er(Ci.hydrophobic))})},positive:{"@desc":"same as basic -- ARG HIS LYS",map:()=>er(Ci.basic)},sheet:{"@desc":"secondary structure-related",map:()=>Pe.struct.generator.atomGroups({"residue-test":Pe.core.flags.hasAny([Pe.struct.type.secondaryStructureFlags(["sheet"]),Pe.ammp("secondaryStructureFlags")])})},small:{"@desc":"ALA GLY SER",map:()=>er(Ci.small)},surface:{"@desc":"amino and not buried",map:()=>Pe.struct.modifier.intersectBy({0:er(Ci.amino),by:Su(er(Ci.buried))})},turn:{"@desc":"secondary structure-related",map:()=>Pe.struct.generator.atomGroups({"residue-test":Pe.core.flags.hasAny([Pe.struct.type.secondaryStructureFlags(["turn"]),Pe.ammp("secondaryStructureFlags")])})},alpha:{"@desc":"(*.CA)",map:()=>Pe.struct.generator.atomGroups({"atom-test":Pe.core.rel.eq([Pe.atomName("CA"),Pe.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 OWe(){return Pe.struct.combinator.merge([Pe.struct.modifier.intersectBy({0:Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.core.type.set(Ci.amino),Pe.ammp("label_comp_id")])}),by:Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.core.type.set(doe_protein),Pe.ammp("label_atom_id")])})}),Pe.struct.modifier.intersectBy({0:Pe.struct.generator.atomGroups({"residue-test":Pe.core.set.has([Pe.core.type.set(Ci.nucleic),Pe.ammp("label_comp_id")])}),by:Pe.struct.generator.atomGroups({"atom-test":Pe.core.set.has([Pe.core.type.set(doe_nucleic),Pe.ammp("label_atom_id")])})})])}()},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'}},An=ue,LWe=[{"@desc":"value comparisons","@examples":[],name:"=",abbr:["=="],type:sc,rule:Be.regexp(/\s*(LIKE|>=|<=|=|!=|>|<)\s*/i,1),map:(e,t,n)=>{let r;if("structure"===t?r=An.core.flags.hasAny([An.ammp("secondaryStructureFlags"),aoe(n)]):"structure"===n?r=An.core.flags.hasAny([An.ammp("secondaryStructureFlags"),aoe(t)]):void 0!==t.head?"core.type.regex"===t.head.name&&(r=An.core.str.match([t,An.core.type.str([n])])):void 0!==n.head?"core.type.regex"===n.head.name&&(r=An.core.str.match([n,An.core.type.str([t])])):"LIKE"===e.toUpperCase()&&(r=An.core.str.match(t.head?[An.core.type.regex([`^${n}$`,"i"]),An.core.type.str([t])]:[An.core.type.regex([`^${t}$`,"i"]),An.core.type.str([n])])),!r)switch(t.head&&(n=SS(t,n)),n.head&&(t=SS(n,t)),e){case"=":r=An.core.rel.eq([t,n]);break;case"!=":r=An.core.rel.neq([t,n]);break;case">":r=An.core.rel.gr([t,n]);break;case"<":r=An.core.rel.lt([t,n]);break;case">=":r=An.core.rel.gre([t,n]);break;case"<=":r=An.core.rel.lte([t,n]);break;default:throw new Error(`value operator '${e}' not supported`)}return An.struct.generator.atomGroups({"atom-test":r})}}];function UWe(e){const[t,n,r,i,o,s,a]=e[1],c={};o&&(c["chain-test"]=An.core.rel.eq([An.ammp("auth_asym_id"),o]));const u=[];t&&u.push(An.core.rel.eq([An.ammp("label_comp_id"),t])),n&&u.push(An.core.logic.and([An.core.rel.gre([An.ammp("auth_seq_id"),n[0]]),An.core.rel.lte([An.ammp("auth_seq_id"),n[1]])])),r&&u.push(An.core.rel.eq([An.ammp("auth_seq_id"),r])),i&&u.push(An.core.rel.eq([An.ammp("pdbx_PDB_ins_code"),i])),u.length&&(c["residue-test"]=j5(u));const l=[];return s&&l.push(An.core.rel.eq([An.ammp("auth_atom_id"),s])),a&&l.push(An.core.rel.eq([An.ammp("label_alt_id"),a])),l.length&&(c["atom-test"]=j5(l)),An.struct.generator.atomGroups(c)}const VWe=Be.createLanguage({Integer:()=>Be.regexp(/-?[0-9]+/).map(Number).desc("integer"),Parens:function(e){return Be.alt(e.Parens,e.Operator,e.Expression).wrap(Be.regexp(/\(\s*/),Be.regexp(/\s*\)/))},Expression:function(e){return Be.alt(e.Keywords,e.AtomExpression.map(UWe),e.Within.map(t=>An.struct.modifier.includeSurroundings({0:t[1],radius:t[0]})),e.ValueQuery,e.Element.map(t=>An.struct.generator.atomGroups({"atom-test":An.core.rel.eq([An.acp("elementSymbol"),An.struct.type.elementSymbol(t)])})),e.Resname.map(t=>An.struct.generator.atomGroups({"residue-test":An.core.rel.eq([An.ammp("label_comp_id"),t])})))},Operator:function(e){return xS(loe,Be.alt(e.Parens,e.Expression))},AtomExpression:function(e){return Be.seq(Be.lookahead(e.AtomPrefix),Be.seq(e.BracketedResname.or(Be.of(null)),e.ResnoRange.or(Be.of(null)),e.Resno.or(Be.of(null)),e.Inscode.or(Be.of(null)),e.Chainname.or(Be.of(null)),e.Atomname.or(Be.of(null)),e.Altloc.or(Be.of(null)),e.Model.or(Be.of(null)))).desc("expression")},AtomPrefix:()=>Be.regexp(/[\[0-9:^%/.-]/).desc("atom-prefix"),Chainname:()=>Be.regexp(/:([A-Za-z]{1,3})/,1).desc("chainname"),Model:()=>Be.regexp(/\/([0-9]+)/,1).map(Number).desc("model"),Element:()=>Be.regexp(/_([A-Za-z]{1,3})/,1).desc("element"),Atomname:()=>Be.regexp(/\.([a-zA-Z0-9]{1,4})/,1).map(An.atomName).desc("atomname"),Resname:()=>Be.regexp(/[a-zA-Z0-9]{1,4}/).desc("resname"),Resno:e=>e.Integer.desc("resno"),Altloc:()=>Be.regexp(/%([a-zA-Z0-9])/,1).desc("altloc"),Inscode:()=>Be.regexp(/\^([a-zA-Z0-9])/,1).desc("inscode"),BracketedResname:()=>Be.regexp(/\[([a-zA-Z0-9]{1,4})\]/,1).desc("bracketed-resname"),ResnoRange:e=>Be.seq(e.Integer.skip(Be.seq(Be.optWhitespace,Be.string("-"),Be.optWhitespace)),e.Integer).desc("resno-range"),Within:e=>Be.regexp(/within/i).skip(Be.regexp(/\s*\(\s*/)).then(Be.seq(e.Integer.skip(Be.regexp(/\s*,\s*/)),e.Query)).skip(Be.regexp(/\)/)),Keywords:()=>Be.alt(...W5(foe)).desc("keyword"),Query:function(e){return Be.alt(e.Operator,e.Parens,e.Expression).trim(Be.optWhitespace)},Number:function(){return Be.regexp(/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/).map(Number).desc("number")},String:function(){const e=Y5(coe,foe,loe).sort(vf).map(s2).join("|");return Be.alt(Be.regexp(new RegExp(`(?!(${e}))[A-Z0-9_]+`,"i")),Be.regexp(/'((?:[^"\\]|\\.)*)'/,1),Be.regexp(/"((?:[^"\\]|\\.)*)"/,1).map(t=>An.core.type.regex([`^${t}$`,"i"]))).desc("string")},Value:function(e){return Be.alt(e.Number,e.String)},ValueParens:function(e){return Be.alt(e.ValueParens,e.ValueOperator,e.ValueExpressions).wrap(Be.string("("),Be.string(")"))},ValuePropertyNames:function(){return Be.alt(...$5(coe,/LIKE|>=|<=|=|!=|>|<|\)|\s/i))},ValueOperator:function(e){return xS(LWe,Be.alt(e.ValueParens,e.ValueExpressions))},ValueExpressions:function(e){return Be.alt(e.Value,e.ValuePropertyNames)},ValueQuery:function(e){return Be.alt(e.ValueOperator.map(t=>{if(t.head){if(t.head.name.startsWith("structure-query.generator"))return t}else if("string"==typeof t&&t.length<=4)return An.struct.generator.atomGroups({"residue-test":An.core.rel.eq([An.ammp("label_comp_id"),t])});throw new Error(`values must be part of an comparison, value '${t}'`)}))}}),Ls=ue,VD=/[-+]?[0-9]*\.?[0-9]+/;function kv(e){return e.split("+").map(t=>t.replace(/^["']|["']$/g,""))}function X5(e){if(e.includes("-")&&e.includes("+")){const t=e.split("+").map(r=>r.replace(/^["']|["']$/g,"")),n=[];return t.forEach(r=>{if(r.includes("-")&&!r.startsWith("-")){const[i,o]=r.split("-").map(s=>parseInt(s));for(let s=i;s<=o;s++)n.push(s)}else if(r.includes("-")&&r.startsWith("-")&&r.match(/[0-9]+-[-0-9]+/)){const i=-parseInt(r.split("-")[1]);let o;o=r.includes("--")?-parseInt(r.split("-")[3]):parseInt(r.split("-")[2]);for(let s=i;s<=o;s++)n.push(s)}else r.includes("-")&&r.startsWith("-")&&r.match(/[0-9]+-[-0-9]+/),n.push(parseInt(r))}),n}if(e.includes("-")&&!e.includes("+")){const t=[];if(e.startsWith("-"))if(e.startsWith("-")&&e.match(/[0-9]+-[-0-9]+/)){const n=-parseInt(e.split("-")[1]);let r;r=e.includes("--")?-parseInt(e.split("-")[3]):parseInt(e.split("-")[2]);for(let i=n;i<=r;i++)t.push(i)}else e.startsWith("-")&&e.match(/[0-9]+-[-0-9]+/),t.push(parseInt(e));else{const[n,r]=e.split("-").map(i=>parseInt(i));for(let i=n;i<=r;i++)t.push(i)}return t}return!e.includes("-")&&e.includes("+")?kv(e).map(t=>parseInt(t)):[parseInt(e)]}const HWe={H:"helix",S:"beta",L:"none"},zD={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:function jWe(e){return e.split("+").map(Ls.struct.type.elementSymbol)},level:"atom-test",property:Ls.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:function GWe(e){return e.split("+").map(Ls.atomName)},level:"atom-test",property:Ls.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:kv,level:"residue-test",property:Ls.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:X5,level:"residue-test",property:Ls.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:kv,level:"atom-test",property:Ls.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:kv,level:"chain-test",property:Ls.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:kv,level:"chain-test",property:Ls.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:e=>parseInt(e),level:"atom-test"},numeric_type:{"@desc":"type-number a single integer","@examples":["nt. 5"],isUnsupported:!0,abbr:["nt."],regex:/[0-9]+/,map:e=>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:kv,level:"atom-test"},id:{"@desc":"external-index-number a single integer","@examples":["id 23"],regex:/[0-9+-]+/,map:X5,level:"atom-test",property:Ls.ammp("id")},index:{"@desc":"internal-index-number a single integer","@examples":["index 11"],regex:/[0-9+-]+/,map:X5,level:"atom-test",property:Ls.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:function qWe(e){return{flags:Ls.struct.type.secondaryStructureFlags(e.toUpperCase().split("+").map(t=>HWe[t]||"none"))}},level:"residue-test",property:Ls.ammp("secondaryStructureFlags")},b:{"@desc":"comparison-operator b-factor-value a real number","@examples":["b > 10"],isNumeric:!0,abbr:[],regex:VD,map:e=>parseFloat(e),level:"atom-test",property:Ls.ammp("B_iso_or_equiv")},q:{"@desc":"comparison-operator occupancy-value a real number","@examples":["q <0.50"],isNumeric:!0,abbr:[],regex:VD,map:e=>parseFloat(e),level:"atom-test",property:Ls.ammp("occupancy")},formal_charge:{"@desc":"comparison-operator formal charge-value an integer","@examples":["fc. = -1"],isNumeric:!0,abbr:["fc."],regex:VD,map:e=>parseFloat(e),level:"atom-test",property:Ls.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:VD,map:e=>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:e=>Ls.es(e),level:"atom-test",property:Ls.acp("elementSymbol")}},gn=ue,poe=[{"@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:Ca,rule:Be.alt(Be.regexp(/NOT/i).skip(Be.whitespace),Be.string("!").skip(Be.optWhitespace)),map:(e,t)=>Su(t)},{"@desc":"Selects atoms included in both s1 and s2.","@examples":["chain A AND name CA"],name:"and",type:sc,rule:Yp(/AND|&/i),map:(e,t,n)=>gn.struct.modifier.intersectBy({0:t,by:n})},{"@desc":"Selects atoms included in either s1 or s2.","@examples":["chain A OR chain B"],name:"or",type:sc,rule:Yp(/OR|\|/i),map:(e,t,n)=>gn.struct.combinator.merge([t,n])},{"@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:sc,rule:Yp(/IN/i),map:(e,t,n)=>gn.struct.filter.withSameAtomProperties({0:t,source:n,property:gn.core.type.compositeKey([gn.ammp("label_atom_id"),gn.ammp("label_seq_id"),gn.ammp("label_comp_id"),gn.ammp("auth_asym_id"),gn.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:sc,rule:Yp(/LIKE|l\./i),map:(e,t,n)=>gn.struct.filter.withSameAtomProperties({0:t,source:n,property:gn.core.type.compositeKey([gn.ammp("label_atom_id"),gn.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:LD,rule:UD(/GAP\s+([-+]?[0-9]*\.?[0-9]+)/i,1).map(e=>parseFloat(e)),map:(e,t)=>gn.struct.filter.within({0:gn.struct.generator.all(),target:t,"atom-radius":gn.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:LD,rule:UD(/(AROUND|a\.)\s+([-+]?[0-9]*\.?[0-9]+)/i,2).map(e=>parseFloat(e)),map:(e,t)=>gn.struct.modifier.exceptBy({0:gn.struct.filter.within({0:gn.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:LD,rule:UD(/(EXPAND|x\.)\s+([-+]?[0-9]*\.?[0-9]+)/i,2).map(e=>parseFloat(e)),map:(e,t)=>gn.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:sc,rule:G5("WITHIN","w."),map:(e,t,n)=>gn.struct.filter.within({0:t,target:n,"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:sc,rule:G5("NEAR_TO","nto."),map:(e,t,n)=>gn.struct.modifier.exceptBy({0:gn.struct.filter.within({0:t,target:n,"max-radius":e}),by:n})},{"@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:sc,rule:G5("BEYOND","be."),map:(e,t,n)=>gn.struct.modifier.exceptBy({0:gn.struct.filter.within({0:t,target:n,"max-radius":e,invert:!0}),by:n})},{"@desc":"Expands selection to complete residues.","@examples":["BYRESIDUE name N"],name:"byresidue",abbr:["byresi","byres","br."],type:Ca,rule:xu(/BYRESIDUE|byresi|byres|br\./i),map:(e,t)=>xf(gn.struct.modifier.expandProperty({0:gn.struct.modifier.union({0:t}),property:gn.ammp("residueKey")}))},{"@desc":"Completely selects all alpha carbons in all residues covered by a selection.","@examples":["BYCALPHA chain A"],name:"bycalpha",abbr:["bca."],type:Ca,rule:xu(/BYCALPHA|bca\./i),map:(e,t)=>gn.struct.generator.queryInSelection({0:gn.struct.modifier.expandProperty({0:gn.struct.modifier.union({0:t}),property:gn.ammp("residueKey")}),query:gn.struct.generator.atomGroups({"atom-test":gn.core.rel.eq([gn.atomName("CA"),gn.ammp("label_atom_id")])})})},{"@desc":"Expands selection to complete molecules.","@examples":["BYMOLECULE resi 20-30"],name:"bymolecule",isUnsupported:!0,abbr:["bymol","bm."],type:Ca,rule:xu(/BYMOLECULE|bymol|bm\./i),map:(e,t)=>xf(gn.struct.modifier.expandProperty({0:gn.struct.modifier.union({0:t}),property:gn.atp("connectedComponentKey")}))},{"@desc":"Expands selection to complete fragments.","@examples":["BYFRAGMENT resi 10"],name:"byfragment",abbr:["byfrag","bf."],isUnsupported:!0,type:Ca,rule:xu(/BYFRAGMENT|byfrag|bf\./i),map:(e,t)=>[e,t]},{"@desc":"Expands selection to complete segments.","@examples":["BYSEGMENT resn CYS"],name:"bysegment",abbr:["bysegi","byseg","bs."],type:Ca,rule:xu(/BYSEGMENT|bysegi|byseg|bs\./i),map:(e,t)=>xf(gn.struct.modifier.expandProperty({0:gn.struct.modifier.union({0:t}),property:gn.ammp("chainKey")}))},{"@desc":"Expands selection to complete objects.","@examples":["BYOBJECT chain A"],name:"byobject",abbr:["byobj","bo."],isUnsupported:!0,type:Ca,rule:xu(/BYOBJECT|byobj|bo\./i),map:(e,t)=>[e,t]},{"@desc":"Expands selection to unit cell.","@examples":["BYCELL chain A"],name:"bycell",isUnsupported:!0,type:Ca,rule:xu(/BYCELL/i),map:(e,t)=>[e,t]},{"@desc":"All rings of size \u2264 7 which have at least one atom in s1.","@examples":["BYRING resn HEM"],name:"byring",type:Ca,rule:xu(/BYRING/i),map:(e,t)=>xf(gn.struct.modifier.intersectBy({0:gn.struct.filter.pick({0:gn.struct.generator.rings(),test:gn.core.logic.and([gn.core.rel.lte([gn.struct.atomSet.atomCount(),7]),gn.core.rel.gr([gn.struct.atomSet.countQuery([t]),1])])}),by:t}))},{"@desc":"Selects atoms directly bonded to s1, excludes s1.","@examples":["NEIGHBOR resn CYS"],name:"neighbor",type:Ca,abbr:["nbr."],rule:xu(/NEIGHBOR|nbr\./i),map:(e,t)=>gn.struct.modifier.exceptBy({0:xf(gn.struct.modifier.includeConnected({0:gn.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:Ca,rule:xu(/BOUND_TO|bto\./i),map:(e,t)=>xf(gn.struct.modifier.includeConnected({0:gn.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:LD,rule:UD(/(EXTEND|xt\.)\s+([0-9]+)/i,2).map(e=>parseInt(e)),map:(e,t)=>xf(gn.struct.modifier.includeConnected({0:gn.struct.modifier.union({0:t}),"bond-test":!0,"layer-count":e}))}],Dt=ue,wa={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"]},hoe_nucleic=["P","O3'","O5'","C5'","C4'","C3'","OP1","OP2","O3*","O5*","C5*","C4*","C3*","C2'","C1'","O4'","O2'"],hoe_protein=["C","N","CA","O"];function moe(){return Dt.struct.combinator.merge([Dt.struct.modifier.intersectBy({0:Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.protein),Dt.ammp("label_comp_id")])}),by:Dt.struct.generator.atomGroups({"atom-test":Dt.core.set.has([Dt.core.type.set(hoe_protein),Dt.ammp("label_atom_id")])})}),Dt.struct.modifier.intersectBy({0:Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.nucleic),Dt.ammp("label_comp_id")])}),by:Dt.struct.generator.atomGroups({"atom-test":Dt.core.set.has([Dt.core.type.set(hoe_nucleic),Dt.ammp("label_atom_id")])})})])}const goe={all:{"@desc":"All atoms currently loaded into PyMOL",abbr:["*"],map:()=>Dt.struct.generator.all()},none:{"@desc":"No atoms (empty selection)",map:()=>Dt.struct.generator.empty()},hydrogens:{"@desc":"All hydrogen atoms currently loaded into PyMOL",abbr:["hydro","h."],map:()=>Dt.struct.generator.atomGroups({"atom-test":Dt.core.rel.eq([Dt.acp("elementSymbol"),Dt.es("H")])})},hetatm:{"@desc":"All atoms loaded from Protein Data Bank HETATM records",abbr:["het"],map:()=>Dt.struct.generator.atomGroups({"atom-test":Dt.core.rel.eq([Dt.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:()=>Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.nucleic.concat(wa.protein)),Dt.ammp("label_comp_id")])})},sidechain:{"@desc":"Polymer non-backbone atoms (new in PyMOL 1.6.1)",abbr:["sc."],map:()=>Dt.struct.modifier.exceptBy({0:Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.nucleic.concat(wa.protein)),Dt.ammp("label_comp_id")])}),by:moe()})},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:()=>Dt.struct.generator.atomGroups({"atom-test":Dt.core.rel.gr([Dt.struct.atomProperty.core.bondCount({flags:Dt.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:()=>xf(Dt.struct.modifier.expandProperty({0:Dt.struct.modifier.union([Dt.struct.generator.queryInSelection({0:Dt.struct.generator.atomGroups({"residue-test":Dt.core.logic.not([Dt.core.set.has([Dt.core.type.set(wa.nucleic.concat(wa.protein)),Dt.ammp("label_comp_id")])])}),query:Dt.struct.generator.atomGroups({"atom-test":Dt.core.rel.eq([Dt.es("C"),Dt.acp("elementSymbol")])})})]),property:Dt.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:()=>xf(Dt.struct.modifier.expandProperty({0:Dt.struct.modifier.union([Dt.struct.filter.pick({0:Dt.struct.generator.atomGroups({"residue-test":Dt.core.logic.not([Dt.core.set.has([Dt.core.type.set(wa.nucleic.concat(wa.protein).concat(wa.solvent)),Dt.ammp("label_comp_id")])]),"group-by":Dt.ammp("residueKey")}),test:Dt.core.logic.not([Dt.core.set.has([Dt.struct.atomSet.propertySet([Dt.acp("elementSymbol")]),Dt.es("C")])])})]),property:Dt.ammp("residueKey")}))},solvent:{"@desc":"All water molecules. The hardcoded solvent residue identifiers are currently: HOH, WAT, H20, TIP, SOL.",abbr:["sol."],map:()=>Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.solvent),Dt.ammp("label_comp_id")])})},guide:{"@desc":"All protein CA and nucleic acid C4*/C4",map:()=>Dt.struct.combinator.merge([Dt.struct.generator.atomGroups({"atom-test":Dt.core.rel.eq([Dt.atomName("CA"),Dt.ammp("label_atom_id")]),"residue-test":Dt.core.set.has([Dt.core.type.set(wa.protein),Dt.ammp("label_comp_id")])}),Dt.struct.generator.atomGroups({"atom-test":Dt.core.set.has([_f(["C4*","C4'"]),Dt.ammp("label_atom_id")]),"residue-test":Dt.core.set.has([Dt.core.type.set(wa.nucleic),Dt.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:()=>moe()},"polymer.protein":{"@desc":"Protein (New in PyMOL 2.1)",abbr:["polymer.protein"],map:()=>Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.protein),Dt.ammp("label_comp_id")])})},"polymer.nucleic":{"@desc":"Nucleic Acid (New in PyMOL 2.1)",abbr:["polymer.nucleic"],map:()=>Dt.struct.generator.atomGroups({"residue-test":Dt.core.set.has([Dt.core.type.set(wa.nucleic),Dt.ammp("label_comp_id")])})}},WWe=ue,So=function TWe(e){const t={};return Object.keys(e).sort(vf).forEach(n=>{const r=e[n],i=bm(`property '${n}' not supported`),o=Be.regexp(r.regex).map(s=>(r.isUnsupported&&i(),H5(r.property,r.map(s))));r.isNumeric||(t[n]=o)}),t}(zD),Mo=Be.string("/");function bi(e){return e.or(Be.of(null))}function $We(e){const t={},n={};for(const r in e){const i=zD[r];if(!i)throw new Error(`property '${r}' not supported, value '${e[r]}'`);null!==e[r]&&(n[i.level]||(n[i.level]=[]),n[i.level].push(e[r]))}for(const r in n)t[r]=j5(n[r]);return WWe.struct.generator.atomGroups(t)}const YWe=Be.createLanguage({Parens:function(e){return Be.alt(e.Parens,e.Operator,e.Expression).wrap(Be.string("("),Be.string(")"))},Expression:function(e){return Be.alt(e.Keywords,e.AtomSelectionMacro.map($We),e.NamedAtomProperties,e.Pepseq,e.Rep,e.Object)},AtomSelectionMacro:function(e){return Be.alt(Mo.then(Be.alt(Be.seq(bi(e.ObjectProperty).skip(Mo),bi(So.segi).skip(Mo),bi(So.chain).skip(Mo),bi(So.resi).skip(Mo),bi(So.name)).map(t=>({object:t[0],segi:t[1],chain:t[2],resi:t[3],name:t[4]})),Be.seq(bi(e.ObjectProperty).skip(Mo),bi(So.segi).skip(Mo),bi(So.chain).skip(Mo),bi(So.resi)).map(t=>({object:t[0],segi:t[1],chain:t[2],resi:t[3]})),Be.seq(bi(e.ObjectProperty).skip(Mo),bi(So.segi).skip(Mo),bi(So.chain)).map(t=>({object:t[0],segi:t[1],chain:t[2]})),Be.seq(bi(e.ObjectProperty).skip(Mo),bi(So.segi)).map(t=>({object:t[0],segi:t[1]})),Be.seq(bi(e.ObjectProperty)).map(t=>({object:t[0]})))),Be.alt(Be.seq(bi(e.ObjectProperty).skip(Mo),bi(So.segi).skip(Mo),bi(So.chain).skip(Mo),bi(So.resi).skip(Mo),bi(So.name)).map(t=>({object:t[0],segi:t[1],chain:t[2],resi:t[3],name:t[4]})),Be.seq(bi(So.segi).skip(Mo),bi(So.chain).skip(Mo),bi(So.resi).skip(Mo),bi(So.name)).map(t=>({segi:t[0],chain:t[1],resi:t[2],name:t[3]})),Be.seq(bi(So.chain).skip(Mo),bi(So.resi).skip(Mo),bi(So.name)).map(t=>({chain:t[0],resi:t[1],name:t[2]})),Be.seq(bi(So.resi).skip(Mo),bi(So.name)).map(t=>({resi:t[0],name:t[1]}))))},NamedAtomProperties:function(){return Be.alt(...ooe(zD))},Keywords:()=>Be.alt(...W5(goe)),ObjectProperty:()=>{const e=Y5(zD,goe,poe).sort(vf).map(s2).join("|");return Be.regexp(new RegExp(`(?!(${e}))[A-Z0-9_]+`,"i"))},Object:e=>e.ObjectProperty.notFollowedBy(Mo).map(t=>{throw new Error(`property 'object' not supported, value '${t}'`)}),Pepseq:()=>Be.regexp(/(PEPSEQ|ps\.)\s+([a-z]+)/i,2).map(bm("operator 'pepseq' not supported")),Rep:()=>Be.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(bm("operator 'rep' not supported")),Operator:function(e){return xS(poe,Be.alt(e.Parens,e.Expression,e.Operator))},Query:function(e){return Be.alt(e.Operator,e.Parens,e.Expression).trim(Be.optWhitespace)}}),co=ue,Bc=/[-+]?[0-9]*\.?[0-9]+/,GD=/[+]?[0-9]+/,AS=/[-+]?[0-9]+/;function h0(e){return e}const yoe={T:"turn",E:"sheet",B:"strand",H:"alpha",G:"3-10",I:"pi",C:"none"};function K5(e){return co.struct.type.secondaryStructureFlags([yoe[e.toUpperCase()]||"none"])}const m0={name:{"@desc":"str atom name","@examples":["name CA"],regex:/[a-zA-Z0-9]+/,map:co.atomName,level:"atom-test",property:co.ammp("label_atom_id")},type:{"@desc":"str atom type","@examples":["type C3"],isUnsupported:!0,regex:/[a-zA-Z0-9]+/,map:h0,level:"atom-test"},index:{"@desc":"num the atom number, starting at 0","@examples":["index 10"],isNumeric:!0,regex:GD,map:e=>parseInt(e)-1,level:"atom-test",property:co.ammp("id")},serial:{"@desc":"num the atom number, starting at 1","@examples":["serial 11"],isNumeric:!0,regex:GD,map:e=>parseInt(e),level:"atom-test",property:co.ammp("id")},atomicnumber:{"@desc":"num atomic number (0 if undefined)","@examples":["atomicnumber 13"],isNumeric:!0,regex:GD,map:e=>parseInt(e),level:"atom-test",property:co.acp("atomicNumber")},element:{"@desc":'str atomic element symbol string ("X" if undefined)',"@examples":["element N"],regex:/[a-zA-Z0-9]{1,3}/,map:e=>co.es(e),level:"atom-test",property:co.acp("elementSymbol")},altloc:{"@desc":"str alternate location/conformation identifier","@examples":["altloc C"],regex:/[a-zA-Z0-9]+/,map:h0,level:"atom-test",property:co.ammp("label_alt_id")},chain:{"@desc":"str the one-character chain identifier","@examples":["chain A"],regex:/[a-zA-Z0-9]+/,map:h0,level:"residue-test",property:co.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:AS,map:e=>parseInt(e),level:"residue-test",property:co.ammp("auth_seq_id")},fragment:{"@desc":"num a set of connected residues","@examples":["fragment 42"],isUnsupported:!0,isNumeric:!0,regex:AS,map:e=>parseInt(e),level:"residue-test"},pfrag:{"@desc":"num a set of connected protein residues","@examples":["pfrag 42"],isUnsupported:!0,isNumeric:!0,regex:AS,map:e=>parseInt(e),level:"residue-test"},nfrag:{"@desc":"num a set of connected nucleic residues","@examples":["nfrag 42"],isUnsupported:!0,isNumeric:!0,regex:AS,map:e=>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:h0,level:"residue-test"},numbonds:{"@desc":"num number of bonds","@examples":["numbonds = 2","numbonds >= 3"],isNumeric:!0,regex:GD,map:e=>parseInt(e),level:"atom-test",property:co.acp("bondCount")},resname:{"@desc":"str residue name","@examples":["resname ALA"],regex:/[a-zA-Z0-9]+/,map:h0,level:"residue-test",property:co.ammp("auth_comp_id")},resid:{"@desc":"num residue id","@examples":["resid 42"],isNumeric:!0,regex:AS,map:e=>parseInt(e),level:"residue-test",property:co.ammp("auth_seq_id")},segname:{"@desc":"str segment name","@examples":["segname B"],regex:/[a-zA-Z0-9]+/,map:h0,level:"residue-test",property:co.ammp("label_asym_id")},x:{"@desc":"float x coordinate","@examples":["x 42"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.acp("x")},y:{"@desc":"float y coordinate","@examples":["y > 1.7"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.acp("y")},z:{"@desc":"float z coordinate","@examples":["z < 11","z > -21"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.acp("z")},radius:{"@desc":"float atomic radius","@examples":["radius > 1.3"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.acp("vdw")},mass:{"@desc":"float atomic mass","@examples":["mass > 2"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.acp("mass")},charge:{"@desc":"float atomic charge","@examples":["charge > 0","charge 1"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.ammp("pdbx_formal_charge")},beta:{"@desc":"float temperature factor","@examples":["beta < 20","beta > 35"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.ammp("B_iso_or_equiv")},occupancy:{"@desc":"float occupancy","@examples":["occupancy 1","occupancy < 1"],isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test",property:co.ammp("occupancy")},user:{"@desc":"float time-varying user-specified value","@examples":["user < 0.1"],isUnsupported:!0,isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"atom-test"},rasmol:{"@desc":"str translates Rasmol selection string to VMD","@examples":["rasmol 'all'"],isUnsupported:!0,regex:/[^']*/,map:h0,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:K5,level:"atom-test",property:co.ammp("secondaryStructureFlags")},phi:{"@desc":"float phi backbone conformational angles","@examples":["phi < 160"],isUnsupported:!0,isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"residue-test"},psi:{"@desc":"float psi backbone conformational angles","@examples":["psi < 160"],isUnsupported:!0,isNumeric:!0,regex:Bc,map:e=>parseFloat(e),level:"residue-test"},ufx:{"@desc":"num force to apply in the x coordinate","@examples":["ufx 1"],isUnsupported:!0,isNumeric:!0,regex:Bc,map:e=>parseInt(e),level:"atom-test"},ufy:{"@desc":"num force to apply in the y coordinate","@examples":["ufy 1"],isUnsupported:!0,isNumeric:!0,regex:Bc,map:e=>parseInt(e),level:"atom-test"},ufz:{"@desc":"num force to apply in the z coordinate","@examples":["ufz 1"],isUnsupported:!0,isNumeric:!0,regex:Bc,map:e=>parseInt(e),level:"atom-test"}},g0=ue,KWe=Object.keys(m0).sort(vf).filter(e=>!m0[e].isUnsupported).join("|"),boe=[{"@desc":"Selects atoms that are not included in s1.","@examples":["not protein"],name:"not",type:Ca,rule:Be.regexp(/NOT/i).skip(Be.whitespace),map:(e,t)=>Su(t)},{"@desc":"Selects atoms within a specified distance of a selection","@examples":["within 5 of name FE"],name:"within",type:Ca,rule:xu(/WITHIN\s+([-+]?[0-9]*\.?[0-9]+)\s+OF/i,1).map(e=>parseFloat(e)),map:(e,t)=>g0.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:Ca,rule:xu(/EXWITHIN\s+([-+]?[0-9]*\.?[0-9]+)\s+OF/i,1).map(e=>parseFloat(e)),map:(e,t)=>g0.struct.modifier.exceptBy({0:g0.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:Ca,rule:xu(new RegExp(`SAME\\s+(${KWe})\\s+AS`,"i"),1).map(e=>m0[e].property),map:(e,t)=>g0.struct.filter.withSameAtomProperties({0:g0.struct.generator.all(),source:t,property:e})},{"@desc":"Selects atoms included in both s1 and s2.","@examples":["backbone and protein"],name:"and",type:sc,rule:Be.alt(Yp(/AND/i),Be.whitespace),map:(e,t,n)=>g0.struct.modifier.intersectBy({0:t,by:n})},{"@desc":"Selects atoms included in either s1 or s2.","@examples":["water or protein"],name:"or",type:sc,rule:Yp(/OR/i),map:(e,t,n)=>g0.struct.combinator.merge([t,n])}],Dn=ue;function Xp(){return Dn.struct.filter.pick({0:Dn.struct.generator.atomGroups({"group-by":Dn.ammp("residueKey")}),test:Dn.core.set.isSubset([_f(["C","N","CA","O"]),Dn.ammpSet("label_atom_id")])})}function Z5(){return Dn.struct.filter.pick({0:Dn.struct.generator.atomGroups({"group-by":Dn.ammp("residueKey")}),test:Dn.core.logic.and([Dn.core.set.isSubset([_f(["P"]),Dn.ammpSet("label_atom_id")]),Dn.core.logic.or([Dn.core.set.isSubset([_f(["O3'","C3'","C4'","C5'","O5'"]),Dn.ammpSet("label_atom_id")]),Dn.core.set.isSubset([_f(["O3*","C3*","C4*","C5*","O5*"]),Dn.ammpSet("label_atom_id")])])])})}function voe(){return Dn.struct.combinator.merge([Dn.struct.generator.queryInSelection({0:Xp(),query:Dn.struct.generator.atomGroups({"atom-test":Dn.core.set.has([_f(_oe.protein),Dn.ammp("label_atom_id")])})}),Dn.struct.generator.queryInSelection({0:Z5(),query:Dn.struct.generator.atomGroups({"atom-test":Dn.core.set.has([_f(_oe.nucleic),Dn.ammp("label_atom_id")])})})])}function Sf(e){return Dn.struct.generator.atomGroups({"residue-test":Dn.core.flags.hasAll([Dn.ammp("secondaryStructureFlags"),Dn.struct.type.secondaryStructureFlags(e)])})}const _oe={nucleic:["P","O3'","O5'","C5'","C4'","C3'","OP1","OP2","O3*","O5*","C5*","C4*","C3*"],protein:["C","N","CA","O"]},Ro={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"]},xoe={all:{"@desc":"everything",map:()=>Dn.struct.generator.all()},none:{"@desc":"nothing",map:()=>Dn.struct.generator.empty()},protein:{"@desc":"a residue with atoms named C, N, CA, and O",map:()=>Xp()},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:()=>Z5()},backbone:{"@desc":"the C, N, CA, and O atoms of a protein and the equivalent atoms in a nucleic acid.",map:()=>voe()},sidechain:{"@desc":"non-backbone atoms and bonds",map:()=>Su(voe())},water:{"@desc":"all atoms with the resname H2O, HH0, OHH, HOH, OH2, SOL, WAT, TIP, TIP2, TIP3 or TIP4",abbr:["waters"],map:()=>er(Ro.water)},at:{"@desc":"residues named ADA A THY T",map:()=>er(Ro.at)},acidic:{"@desc":"residues named ASP GLU",map:()=>er(Ro.acidic)},acyclic:{"@desc":'"protein and not cyclic"',map:()=>Dn.struct.modifier.intersectBy({0:Xp(),by:Su(er(Ro.cyclic))})},aliphatic:{"@desc":"residues named ALA GLY ILE LEU VAL",map:()=>er(Ro.aliphatic)},alpha:{"@desc":"atom's residue is an alpha helix",map:()=>Sf(["alpha"])},amino:{"@desc":"a residue with atoms named C, N, CA, and O",map:()=>Xp()},aromatic:{"@desc":"residues named HIS PHE TRP TYR",map:()=>er(Ro.aromatic)},basic:{"@desc":"residues named ARG HIS LYS",map:()=>er(Ro.basic)},bonded:{"@desc":"atoms for which numbonds > 0",map:()=>xf(Dn.struct.filter.pick({0:Dn.struct.modifier.includeConnected({0:Dn.struct.generator.all(),"bond-test":Dn.core.flags.hasAny([Dn.struct.bondProperty.flags(),Dn.struct.type.bondFlags(["covalent","metallic","sulfide"])])}),test:Dn.core.rel.gr([Dn.struct.atomSet.atomCount(),1])}))},buried:{"@desc":"residues named ALA LEU VAL ILE PHE CYS MET TRP",map:()=>er(Ro.buried)},cg:{"@desc":"residues named CYT C GUA G",map:()=>er(Ro.cg)},charged:{"@desc":'"basic or acidic"',map:()=>er(Ro.basic.concat(Ro.acidic))},cyclic:{"@desc":"residues named HIS PHE PRO TRP TYR",map:()=>er(Ro.cyclic)},hetero:{"@desc":'"not (protein or nucleic)"',map:()=>Su(Dn.struct.combinator.merge([Xp(),Z5()]))},hydrogen:{"@desc":'name "[0-9]?H.*"',map:()=>Dn.struct.generator.atomGroups({"atom-test":Dn.core.str.match([Dn.core.type.regex(["^[0-9]?[H].*$","i"]),Dn.core.type.str([Dn.ammp("label_atom_id")])])})},large:{"@desc":'"protein and not (small or medium)"',map:()=>Dn.struct.modifier.intersectBy({0:Xp(),by:Su(er(Ro.small.concat(Ro.medium)))})},medium:{"@desc":"residues named VAL THR ASP ASN PRO CYS ASX PCA HYP",map:()=>er(Ro.medium)},neutral:{"@desc":"residues named VAL PHE GLN TYR HIS CYS MET TRP ASX GLX PCA HYP",map:()=>er(Ro.neutral)},hydrophobic:{"@desc":"hydrophobic resname ALA LEU VAL ILE PRO PHE MET TRP",map:()=>er(Ro.hydrophobic)},polar:{"@desc":'"protein and not hydrophobic"',map:()=>Dn.struct.modifier.intersectBy({0:Xp(),by:Su(er(Ro.hydrophobic))})},purine:{"@desc":"residues named ADE A GUA G",map:()=>er(Ro.purine)},pyrimidine:{"@desc":"residues named CYT C THY T URI U",map:()=>er(Ro.pyrimidine)},small:{"@desc":"residues named ALA GLY SER",map:()=>er(Ro.small)},surface:{"@desc":'"protein and not buried"',map:()=>Dn.struct.modifier.intersectBy({0:Xp(),by:Su(er(Ro.buried))})},alpha_helix:{"@desc":"atom's residue is in an alpha helix",map:()=>Sf(["alpha"])},pi_helix:{"@desc":"atom's residue is in a pi helix",map:()=>Sf(["pi"])},helix_3_10:{"@desc":"atom's residue is in a 3-10 helix",map:()=>Sf(["3-10"])},helix:{"@desc":"atom's residue is in an alpha or pi or 3-10 helix",map:()=>Sf(["helix"])},extended_beta:{"@desc":"atom's residue is a beta sheet",map:()=>Sf(["sheet"])},bridge_beta:{"@desc":"atom's residue is a beta sheet",map:()=>Sf(["strand"])},sheet:{"@desc":"atom's residue is a beta sheet",map:()=>Sf(["beta"])},turn:{"@desc":"atom's residue is in a turn conformation",map:()=>Sf(["turn"])},coil:{"@desc":"atom's residue is in a coil conformation",map:()=>Dn.struct.modifier.intersectBy({0:Xp(),by:Sf(["none"])})}},ia=ue,ZWe={sqr:{"@desc":"square of x","@examples":["sqr(2)"],map:e=>ia.core.math.pow([e,2])},sqrt:{"@desc":"square root of x","@examples":["sqrt(2)"],map:e=>ia.core.math.sqrt([e])},abs:{"@desc":"absolute value of x","@examples":["abs(2)"],map:e=>ia.core.math.abs([e])},floor:{"@desc":"largest integer not greater than x","@examples":["floor(2)"],map:e=>ia.core.math.floor([e])},ceil:{"@desc":"smallest integer not less than x","@examples":["ceil(2)"],map:e=>ia.core.math.ceil([e])},sin:{"@desc":"sine of x","@examples":["sin(2)"],map:e=>ia.core.math.sin([e])},cos:{"@desc":"cosine of x","@examples":["cos(2)"],map:e=>ia.core.math.cos([e])},tan:{"@desc":"tangent of x","@examples":["tan(2)"],map:e=>ia.core.math.tan([e])},atan:{"@desc":"arctangent of x","@examples":["atan(2)"],map:e=>ia.core.math.atan([e])},asin:{"@desc":"arcsin of x","@examples":["asin(2)"],map:e=>ia.core.math.asin([e])},acos:{"@desc":"arccos of x","@examples":["acos(2)"],map:e=>ia.core.math.acos([e])},sinh:{"@desc":"hyperbolic sine of x","@examples":["sinh(2)"],map:e=>ia.core.math.sinh([e])},cosh:{"@desc":"hyperbolic cosine of x","@examples":["cosh(2)"],map:e=>ia.core.math.cosh([e])},tanh:{"@desc":"hyperbolic tangent of x","@examples":["tanh(2)"],map:e=>ia.core.math.tanh([e])},exp:{"@desc":"e to the power x","@examples":["exp(2)"],map:e=>ia.core.math.exp([e])},log:{"@desc":"natural log of x","@examples":["log(2)"],map:e=>ia.core.math.log([e])},log10:{"@desc":"log base 10 of x","@examples":["log10(2)"],map:e=>ia.core.math.log10([e])}},Di=ue,QWe=[{"@desc":"multiplication, division","@examples":[],name:"mul-div",type:sc,rule:Be.regexp(/\s*(\*|\/)\s*/,1),map:(e,t,n)=>{switch(e){case"*":return Di.core.math.mult([t,n]);case"/":return Di.core.math.div([t,n]);default:throw new Error(`value operator '${e}' not supported`)}}},{"@desc":"addition, substraction","@examples":[],name:"add-sub",type:sc,rule:Be.regexp(/\s*(-|\+)\s*/,1),map:(e,t,n)=>{switch(e){case"-":return Di.core.math.sub([t,n]);case"+":return Di.core.math.add([t,n]);default:throw new Error(`value operator '${e}' not supported`)}}},{"@desc":"value comparisons","@examples":[],name:"comparison",type:sc,rule:Be.alt(Be.regexp(/\s*(=~|==|>=|<=|=|!=|>|<)\s*/,1),Be.whitespace.result("=")),map:(e,t,n)=>{let r;if(void 0!==t.head?("structure-query.atom-property.macromolecular.secondary-structure-flags"===t.head.name&&(r=Di.core.flags.hasAny([t,K5(n)])),"core.type.regex"===t.head.name&&(r=Di.core.str.match([t,Di.core.type.str([n])]))):void 0!==n.head?("structure-query.atom-property.macromolecular.secondary-structure-flags"===n.head.name&&(r=Di.core.flags.hasAny([n,K5(t)])),"core.type.regex"===n.head.name&&(r=Di.core.str.match([n,Di.core.type.str([t])]))):"=~"===e&&(r=Di.core.str.match(t.head?[Di.core.type.regex([`^${n}$`,"i"]),Di.core.type.str([t])]:[Di.core.type.regex([`^${t}$`,"i"]),Di.core.type.str([n])])),!r)switch(t.head&&(n=SS(t,n)),n.head&&(t=SS(n,t)),e){case"=":case"==":r=Di.core.rel.eq([t,n]);break;case"!=":r=Di.core.rel.neq([t,n]);break;case">":r=Di.core.rel.gr([t,n]);break;case"<":r=Di.core.rel.lt([t,n]);break;case">=":r=Di.core.rel.gre([t,n]);break;case"<=":r=Di.core.rel.lte([t,n]);break;default:throw new Error(`value operator '${e}' not supported`)}return Di.struct.generator.atomGroups({"atom-test":r})}}],JWe=Be.createLanguage({Parens:function(e){return Be.alt(e.Parens,e.Operator,e.Expression).wrap(Be.string("("),Be.string(")"))},Expression:function(e){return Be.alt(e.RangeListProperty,e.ValueQuery,e.Keywords)},NamedAtomProperties:function(){return Be.alt(...ooe(m0))},Keywords:()=>Be.alt(...W5(xoe)),ValueRange:function(e){return Be.seq(e.Value.skip(Be.regexp(/\s+TO\s+/i)),e.Value).map(t=>({range:t}))},RangeListProperty:function(e){return Be.seq(Be.alt(...$5(m0,/\s/)).skip(Be.whitespace),Be.alt(e.ValueRange,e.Value).sepBy1(Be.whitespace)).map(t=>{const[n,r]=t,i=[],o=[];r.forEach(u=>{u.range?o.push(Di.core.rel.inRange([n,u.range[0],u.range[1]])):i.push(SS(n,u,yoe))});const s=function IWe(e){return 1===e.length?e[0]:e.length>1?$r.core.logic.or(e):void 0}(o),a=function NWe(e,t){if(kWe.includes(e.head.name)){const n=t[0].head,r=[];return t.forEach(i=>r.push(...i.args[0])),$r.core.flags.hasAny([e,{head:n,args:r}])}return 1===t.length?$r.core.rel.eq([e,t[0]]):t.length>1?$r.core.set.has([$r.core.type.set(t),e]):void 0}(n,i);let c;return c=s&&a?Di.core.logic.or([s,a]):s||a,Di.struct.generator.atomGroups({[RWe(n)]:c})})},Operator:function(e){return xS(boe,Be.alt(e.Parens,e.Expression,e.ValueQuery))},Query:function(e){return Be.alt(e.Operator,e.Parens,e.Expression).trim(Be.optWhitespace)},Number:function(){return Be.regexp(/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/).map(Number).desc("number")},String:function(){const e=Y5(m0,xoe,boe).sort(vf).map(s2).join("|");return Be.alt(Be.regexp(new RegExp(`(?!(${e}))[A-Z0-9_]+`,"i")),Be.regexp(/'((?:[^"\\]|\\.)*)'/,1),Be.regexp(/"((?:[^"\\]|\\.)*)"/,1).map(t=>Di.core.type.regex([`^${t}$`,"i"]))).desc("string")},Value:function(e){return Be.alt(e.Number,e.String)},ValueParens:function(e){return Be.alt(e.ValueParens,e.ValueOperator,e.ValueExpressions).wrap(Be.string("("),Be.string(")"))},ValuePropertyNames:function(){return Be.alt(...$5(m0,/=~|==|>=|<=|=|!=|>|<|\)|\s|\+|-|\*|\//i))},ValueOperator:function(e){return xS(QWe,Be.alt(e.ValueParens,e.ValueExpressions))},ValueExpressions:function(e){return Be.alt(e.ValueFunctions,e.Value,e.ValuePropertyNames)},ValueFunctions:function(e){return Be.alt(...function DWe(e,t){const n=[],r=Be.regexp(/\(\s*/),i=Be.regexp(/\s*\)/);return Object.keys(e).sort(vf).forEach(o=>{const s=e[o],a=s.map?s.map:bm(`function '${o}' not supported`),c=Be.regexp(new RegExp(o,"i")).skip(r).then(t).skip(i).map(a);n.push(c)}),n}(ZWe,e.ValueOperator))},ValueQuery:function(e){return Be.alt(e.ValueOperator.map(t=>{if(!t.head.name||!t.head.name.startsWith("structure-query.generator"))throw new Error(`values must be part of an comparison, value '${t}'`);return t}))}}),e$e={pymol:e=>YWe.Query.tryParse(e),vmd:e=>JWe.Query.tryParse(e),jmol:e=>VWe.Query.tryParse(e)},jD=new class n$e{constructor(){this.map=new Map}removeSymbol(t){this.map.delete(t.symbol.id)}addSymbol(t){this.map.has(t.symbol.id)&&console.warn(`Symbol '${t.symbol.id}' already added. Call removeSymbol/removeCustomProps re-adding the symbol.`),this.map.set(t.symbol.id,t)}addCustomProp(t){if(t.symbols)for(const n of Object.keys(t.symbols))this.addSymbol(t.symbols[n])}removeCustomProp(t){if(t.symbols)for(const n of Object.keys(t.symbols))this.removeSymbol(t.symbols[n])}getRuntime(t){return this.map.get(t)}};class r$e{constructor(t){this.table=t,this.constQueryContext=new qu(Ve.Empty)}}var Soe,y0,IS,Nv;!function(e){e.Const=function t(r){return{kind:"const",value:r}},e.Dynamic=function n(r){return{kind:"dynamic",runtime:r}}}(Soe||(Soe={})),function(e){e.Const=function t(r){return{isConst:!0,fn:function(o){return r}}},e.Dynamic=function n(r){return{isConst:!1,fn:r}}}(y0||(y0={})),function(e){e.forEachEval=function t(n,r,i,o){if("number"==typeof n.length)for(let s=0,a=n.length;so[i]=r,[])}),rn(ye.core.type.set,function(t,n){return IS.forEachEval(n,t,function(i,o,s){return s.add(i)},new Set)}),rn(ye.core.type.regex,function(t,n){return new RegExp(n[0](t),n[1]&&n[1](t)||"")}),rn(ye.core.type.bitflags,function(t,n){return+n[0](t)}),rn(ye.core.type.compositeKey,function(t,n){return IS.forEachEval(n,t,(r,i,o)=>o[i]=""+r,[]).join("-")}),rn(ye.core.logic.not,(e,t)=>!t[0](e)),rn(ye.core.logic.and,(e,t)=>{if("number"==typeof t.length){for(let n=0,r=t.length;n{if("number"==typeof t.length){for(let n=0,r=t.length;nt[0](e)===t[1](e)),rn(ye.core.rel.neq,(e,t)=>t[0](e)!==t[1](e)),rn(ye.core.rel.lt,(e,t)=>t[0](e)t[0](e)<=t[1](e)),rn(ye.core.rel.gr,(e,t)=>t[0](e)>t[1](e)),rn(ye.core.rel.gre,(e,t)=>t[0](e)>=t[1](e)),rn(ye.core.rel.inRange,(e,t)=>{const n=t[0](e);return n>=t[1](e)&&n<=t[2](e)}),rn(ye.core.math.add,(e,t)=>{let n=0;if("number"==typeof t.length)for(let r=0,i=t.length;r{let n=0;if("number"==typeof t.length){if(1===t.length)return-t[0](e);n=t[0](e)||0;for(let r=1,i=t.length;r{let n=1;if("number"==typeof t.length)for(let r=0,i=t.length;rt[0](e)/t[1](e)),rn(ye.core.math.pow,(e,t)=>Math.pow(t[0](e),t[1](e))),rn(ye.core.math.mod,(e,t)=>t[0](e)%t[1](e)),rn(ye.core.math.min,(e,t)=>{let n=Number.POSITIVE_INFINITY;if("number"==typeof t.length)for(let r=0,i=t.length;r{let n=Number.NEGATIVE_INFINITY;if("number"==typeof t.length)for(let r=0,i=t.length;ruu(t[0](e),t[1](e))),rn(ye.core.math.sortedCantorPairing,(e,t)=>t2(t[0](e),t[1](e))),rn(ye.core.math.invertCantorPairing,(e,t)=>XZ([0,0],t[0](e))),rn(ye.core.math.floor,(e,t)=>Math.floor(t[0](e))),rn(ye.core.math.ceil,(e,t)=>Math.ceil(t[0](e))),rn(ye.core.math.roundInt,(e,t)=>Math.round(t[0](e))),rn(ye.core.math.trunc,(e,t)=>Math.trunc(t[0](e))),rn(ye.core.math.abs,(e,t)=>Math.abs(t[0](e))),rn(ye.core.math.sign,(e,t)=>Math.sign(t[0](e))),rn(ye.core.math.sqrt,(e,t)=>Math.sqrt(t[0](e))),rn(ye.core.math.cbrt,(e,t)=>Math.cbrt(t[0](e))),rn(ye.core.math.sin,(e,t)=>Math.sin(t[0](e))),rn(ye.core.math.cos,(e,t)=>Math.cos(t[0](e))),rn(ye.core.math.tan,(e,t)=>Math.tan(t[0](e))),rn(ye.core.math.asin,(e,t)=>Math.asin(t[0](e))),rn(ye.core.math.acos,(e,t)=>Math.acos(t[0](e))),rn(ye.core.math.atan,(e,t)=>Math.atan(t[0](e))),rn(ye.core.math.sinh,(e,t)=>Math.sinh(t[0](e))),rn(ye.core.math.cosh,(e,t)=>Math.cosh(t[0](e))),rn(ye.core.math.tanh,(e,t)=>Math.tanh(t[0](e))),rn(ye.core.math.exp,(e,t)=>Math.exp(t[0](e))),rn(ye.core.math.log,(e,t)=>Math.log(t[0](e))),rn(ye.core.math.log10,(e,t)=>Math.log10(t[0](e))),rn(ye.core.math.atan2,(e,t)=>Math.atan2(t[0](e),t[1](e))),rn(ye.core.str.match,(e,t)=>t[0](e).test(t[1](e))),rn(ye.core.str.concat,(e,t)=>{const n=[];if("number"==typeof t.length)for(let r=0,i=t.length;rt[0](e)[t[1](e)]),rn(ye.core.list.equal,(e,t)=>LZ(t[0](e),t[1](e))),rn(ye.core.set.has,function(t,n){return n[0](t).has(n[1](t))}),rn(ye.core.set.isSubset,function(t,n){return Si.isSuperset(n[1](t),n[0](t))}),rn(ye.core.flags.hasAny,(e,t)=>{const n=t[1](e),r=t[0](e);return n?!!(r&n):!!r}),rn(ye.core.flags.hasAll,(e,t)=>{const n=t[1](e),r=t[0](e);return n?(r&n)===n:!r}),rn(ye.structureQuery.type.elementSymbol,(e,t)=>Bg(t[0](e))),rn(ye.structureQuery.type.atomName,(e,t)=>function MNe(e){return e?"string"==typeof e?e.toUpperCase():`${e}`.toUpperCase():""}(t[0](e))),rn(ye.structureQuery.type.bondFlags,(e,t)=>{let n=0;if("number"==typeof t.length)for(let r=0,i=t.length;rHu.elementFingerprint(function o$e(e,t){const n=[];if(!t)return n;if("number"==typeof t.length)for(let r=0,i=t.length;r{let n=0;if("number"==typeof t.length)for(let r=0,i=t.length;rSr.filters.pick(t[0],t.test)(e)),Vt(ye.structureQuery.filter.first,(e,t)=>Sr.filters.first(t[0])(e)),Vt(ye.structureQuery.filter.withSameAtomProperties,(e,t)=>Sr.filters.withSameAtomProperties(t[0],t.source,t.property)(e)),Vt(ye.structureQuery.filter.intersectedBy,(e,t)=>Sr.filters.areIntersectedBy(t[0],t.by)(e)),Vt(ye.structureQuery.filter.within,(e,t)=>{var n,r,i;return Sr.filters.within({query:t[0],target:t.target,minRadius:null===(n=t["min-radius"])||void 0===n?void 0:n.call(t,e),maxRadius:null===(r=t["max-radius"])||void 0===r?void 0:r.call(t,e),elementRadius:t["atom-radius"],invert:null===(i=t.invert)||void 0===i?void 0:i.call(t,e)})(e)}),Vt(ye.structureQuery.filter.isConnectedTo,(e,t)=>{var n,r;return Sr.filters.isConnectedTo({query:t[0],target:t.target,disjunct:null===(n=t.disjunct)||void 0===n?void 0:n.call(t,e),invert:null===(r=t.invert)||void 0===r?void 0:r.call(t,e),bondTest:t["bond-test"]})(e)}),Vt(ye.structureQuery.generator.atomGroups,function(t,n){return Sr.generators.atoms({entityTest:n["entity-test"],chainTest:n["chain-test"],residueTest:n["residue-test"],atomTest:n["atom-test"],groupBy:n["group-by"]})(t)}),Vt(ye.structureQuery.generator.all,function(t){return Sr.generators.all(t)}),Vt(ye.structureQuery.generator.empty,function(t){return Sr.generators.none(t)}),Vt(ye.structureQuery.generator.bondedAtomicPairs,function(t,n){return Sr.generators.bondedAtomicPairs(n&&n[0])(t)}),Vt(ye.structureQuery.generator.rings,function(t,n){var r,i;return Sr.generators.rings(null===(r=n?.fingerprint)||void 0===r?void 0:r.call(n,t),null===(i=n?.["only-aromatic"])||void 0===i?void 0:i.call(n,t))(t)}),Vt(ye.structureQuery.generator.queryInSelection,function(t,n){var r;return Sr.generators.querySelection(n[0],n.query,null===(r=n["in-complement"])||void 0===r?void 0:r.call(n,t))(t)}),Vt(ye.structureQuery.modifier.includeSurroundings,function(t,n){return Sr.modifiers.includeSurroundings(n[0],{radius:n.radius(t),wholeResidues:!(!n["as-whole-residues"]||!n["as-whole-residues"](t)),elementRadius:n["atom-radius"]})(t)}),Vt(ye.structureQuery.modifier.surroundingLigands,function(t,n){return Sr.modifiers.surroundingLigands({query:n[0],radius:n.radius(t),includeWater:!(!n["include-water"]||!n["include-water"](t))})(t)}),Vt(ye.structureQuery.modifier.wholeResidues,function(t,n){return Sr.modifiers.wholeResidues(n[0])(t)}),Vt(ye.structureQuery.modifier.union,function(t,n){return Sr.modifiers.union(n[0])(t)}),Vt(ye.structureQuery.modifier.expandProperty,function(t,n){return Sr.modifiers.expandProperty(n[0],n.property)(t)}),Vt(ye.structureQuery.modifier.exceptBy,function(t,n){return Sr.modifiers.exceptBy(n[0],n.by)(t)}),Vt(ye.structureQuery.modifier.includeConnected,function(t,n){var r,i;return Sr.modifiers.includeConnected({query:n[0],bondTest:n["bond-test"],wholeResidues:!(!n["as-whole-residues"]||!n["as-whole-residues"](t)),layerCount:n["layer-count"]&&n["layer-count"](t)||1,fixedPoint:null!==(i=null===(r=n["fixed-point"])||void 0===r?void 0:r.call(n,t))&&void 0!==i&&i})(t)}),Vt(ye.structureQuery.modifier.intersectBy,function(t,n){return Sr.modifiers.intersectBy(n[0],n.by)(t)}),Vt(ye.structureQuery.combinator.merge,(e,t)=>Sr.combinators.merge(t)(e)),Vt(ye.structureQuery.atomProperty.core.elementSymbol,Gr(Ze.atom.type_symbol)),Vt(ye.structureQuery.atomProperty.core.vdw,(e,t)=>v2(Ze.atom.type_symbol(t&&t[0]&&t[0](e)||e.element))),Vt(ye.structureQuery.atomProperty.core.mass,(e,t)=>function C4e(e){const t=_T[e];return void 0===t?10.81:v4e[t]}(Ze.atom.type_symbol(t&&t[0]&&t[0](e)||e.element))),Vt(ye.structureQuery.atomProperty.core.atomicNumber,(e,t)=>_2(Ze.atom.type_symbol(t&&t[0]&&t[0](e)||e.element))),Vt(ye.structureQuery.atomProperty.core.x,Gr(Ze.atom.x)),Vt(ye.structureQuery.atomProperty.core.y,Gr(Ze.atom.y)),Vt(ye.structureQuery.atomProperty.core.z,Gr(Ze.atom.z)),Vt(ye.structureQuery.atomProperty.core.sourceIndex,Gr(Ze.atom.sourceIndex)),Vt(ye.structureQuery.atomProperty.core.operatorName,Gr(Ze.unit.operator_name)),Vt(ye.structureQuery.atomProperty.core.operatorKey,Gr(Ze.unit.operator_key)),Vt(ye.structureQuery.atomProperty.core.modelIndex,Gr(Ze.unit.model_index)),Vt(ye.structureQuery.atomProperty.core.modelLabel,Gr(Ze.unit.model_label)),Vt(ye.structureQuery.atomProperty.core.atomKey,(e,t)=>{const n=t&&t[0]&&t[0](e)||e.element;return uu(n.unit.id,n.element)}),Vt(ye.structureQuery.atomProperty.macromolecular.residueKey,(e,t)=>function A6e(e){return Ee.isAtomic(e.unit)?e.unit.residueIndex[e.element]:-1}(t&&t[0]&&t[0](e)||e.element)),Vt(ye.structureQuery.atomProperty.macromolecular.chainKey,(e,t)=>function I6e(e){return Ee.isAtomic(e.unit)?e.unit.chainIndex[e.element]:-1}(t&&t[0]&&t[0](e)||e.element)),Vt(ye.structureQuery.atomProperty.macromolecular.entityKey,(e,t)=>function T6e(e){return Ze.entity.key(e)}(t&&t[0]&&t[0](e)||e.element)),Vt(ye.structureQuery.atomProperty.macromolecular.id,Gr(Ze.atom.id)),Vt(ye.structureQuery.atomProperty.macromolecular.isHet,(e,t)=>"ATOM"!==Ze.residue.group_PDB(t&&t[0]&&t[0](e)||e.element)),Vt(ye.structureQuery.atomProperty.macromolecular.label_atom_id,Gr(Ze.atom.label_atom_id)),Vt(ye.structureQuery.atomProperty.macromolecular.label_alt_id,Gr(Ze.atom.label_alt_id)),Vt(ye.structureQuery.atomProperty.macromolecular.label_comp_id,Gr(Ze.atom.label_comp_id)),Vt(ye.structureQuery.atomProperty.macromolecular.label_seq_id,Gr(Ze.residue.label_seq_id)),Vt(ye.structureQuery.atomProperty.macromolecular.label_asym_id,Gr(Ze.chain.label_asym_id)),Vt(ye.structureQuery.atomProperty.macromolecular.label_entity_id,Gr(Ze.entity.id)),Vt(ye.structureQuery.atomProperty.macromolecular.auth_atom_id,Gr(Ze.atom.auth_atom_id)),Vt(ye.structureQuery.atomProperty.macromolecular.auth_comp_id,Gr(Ze.atom.auth_comp_id)),Vt(ye.structureQuery.atomProperty.macromolecular.auth_seq_id,Gr(Ze.residue.auth_seq_id)),Vt(ye.structureQuery.atomProperty.macromolecular.auth_asym_id,Gr(Ze.chain.auth_asym_id)),Vt(ye.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code,Gr(Ze.residue.pdbx_PDB_ins_code)),Vt(ye.structureQuery.atomProperty.macromolecular.pdbx_formal_charge,Gr(Ze.atom.pdbx_formal_charge)),Vt(ye.structureQuery.atomProperty.macromolecular.occupancy,Gr(Ze.atom.occupancy)),Vt(ye.structureQuery.atomProperty.macromolecular.B_iso_or_equiv,Gr(Ze.atom.B_iso_or_equiv)),Vt(ye.structureQuery.atomProperty.macromolecular.entityType,Gr(Ze.entity.type)),Vt(ye.structureQuery.atomProperty.macromolecular.entitySubtype,Gr(Ze.entity.subtype)),Vt(ye.structureQuery.atomProperty.macromolecular.entityPrdId,Gr(Ze.entity.prd_id)),Vt(ye.structureQuery.atomProperty.macromolecular.entityDescription,Gr(Ze.entity.pdbx_description)),Vt(ye.structureQuery.atomProperty.macromolecular.objectPrimitive,Gr(Ze.unit.object_primitive)),Vt(ye.structureQuery.atomProperty.macromolecular.isNonStandard,Gr(Ze.residue.isNonStandard)),Vt(ye.structureQuery.atomProperty.macromolecular.secondaryStructureKey,Gr(Ze.residue.secondary_structure_key)),Vt(ye.structureQuery.atomProperty.macromolecular.secondaryStructureFlags,Gr(Ze.residue.secondary_structure_type)),Vt(ye.structureQuery.atomProperty.macromolecular.chemCompType,Gr(Ze.residue.chem_comp_type)),Vt(ye.structureQuery.atomSet.atomCount,function(t,n){return Sr.atomset.atomCount(t)}),Vt(ye.structureQuery.atomSet.countQuery,function(t,n){return Sr.atomset.countQuery(n[0])(t)}),Vt(ye.structureQuery.atomSet.propertySet,function(t,n){return Sr.atomset.propertySet(n[0])(t)}),Vt(ye.structureQuery.bondProperty.order,(e,t)=>e.atomicBond.order),Vt(ye.structureQuery.bondProperty.flags,(e,t)=>e.atomicBond.type),Vt(ye.structureQuery.bondProperty.key,(e,t)=>e.atomicBond.key),Vt(ye.structureQuery.bondProperty.atomA,(e,t)=>e.atomicBond.a),Vt(ye.structureQuery.bondProperty.atomB,(e,t)=>e.atomicBond.b),Vt(ye.structureQuery.bondProperty.length,(e,t)=>e.atomicBond.length),Vt(ye.internal.generator.bundleElement,function(t,n){return FJ(n.groupedUnits(t),n.ranges(t),n.set(t))}),Vt(ye.internal.generator.bundle,function(t,n){return BJ(n.elements(t))(t)}),Vt(ye.internal.generator.current,function(t,n){return t.tryGetCurrentSelection()})];function Gr(e){return(t,n)=>e(n&&n[0]&&n[0](t)||t.element)}function Aoe(e,t){return e|(jn.isName(t)?jn.fromName(t):0)}function Ioe(e,t){switch(t.toLowerCase()){case"helix":return 2|e;case"alpha":return 4098|e;case"pi":return 32770|e;case"310":return 2050|e;case"beta":return 4|e;case"strand":return 4194308|e;case"sheet":return 8388612|e;case"turn":return 16|e;case"bend":return 8|e;case"coil":return 536870912|e;default:return e}}function ko(e,t){return{expression:e,language:t}}!function(){for(const e of i$e)jD.addSymbol(e)}(),function(e){function r(a){switch(a.language){case"mol-script":const c=function AWe(e){return z5.parse(e)}(a.expression);if(0===c.length)throw new Error("No query");return bWe(c[0]);case"pymol":case"jmol":case"vmd":return function t$e(e,t){try{return e$e[e](t)}catch(n){throw console.error(n.message),n}}(a.language,a.expression);default:Rr()}}function i(a){return TS(r(a))}e.Info={"mol-script":"Mol-Script",pymol:"PyMOL",vmd:"VMD",jmol:"Jmol"},e.is=function t(a){return!!a&&"string"==typeof a.expression&&!!a.language},e.areEqual=function n(a,c){return a.language===c.language&&a.expression===c.expression},e.toExpression=r,e.toQuery=i,e.toLoci=function o(a,c){const l=i(a)(new qu(c));return pt.toLociWithSourceUnits(l)},e.getStructureSelection=function s(a,c,u){return TS("function"==typeof a?a(ue):a)(new qu(c,u))}}(ko||(ko={}));const Fv={dynamicBonds:C.Optional(C.Boolean(!1,{description:"Ensure bonds are recalculated upon model changes. Also enables calculation of inter-unit bonds in water molecules and ions."}))};var b0,Aa;!function(e){function r(p,m,h,g,y){return i.apply(this,arguments)}function i(){return(i=ie(function*(p,m,h,g,y){let b;const x=no.Provider.get(h);!g&&x&&0!==x.assemblies.length&&(g=x.assemblies[0].id),x&&0!==x.assemblies.length?(b=h2.findAssembly(h,g||""),b||p.log.warn(`Model '${h.entryId}' has no assembly called '${g}', returning model structure.`)):p.log.warn(`Model '${h.entryId}' has no assembly, returning model structure.`);const _=Ve.ofModel(h,y);if(!b){const E={label:"Model",description:Ve.elementDescription(_)};return new pe.Molecule.Structure(_,E)}g=b.id;const S=yield nf.buildAssembly(_,g).runInContext(m),A={label:`Assembly ${g}`,description:Ve.elementDescription(S)};return new pe.Molecule.Structure(S,A)})).apply(this,arguments)}function s(){return(s=ie(function*(p,m,h,g,y){const b=Ve.ofModel(m,y),x=yield nf.buildSymmetryRange(b,h,g).runInContext(p),_={label:`Symmetry [${h}] to [${g}]`,description:Ve.elementDescription(x)};return new pe.Molecule.Structure(x,_)})).apply(this,arguments)}function c(){return(c=ie(function*(p,m,h,g){const y=Ve.ofModel(m,g),b=yield nf.builderSymmetryMates(y,h).runInContext(p),x={label:"Symmetry Mates",description:Ve.elementDescription(b)};return new pe.Molecule.Structure(b,x)})).apply(this,arguments)}function l(){return(l=ie(function*(p,m,h,g,y){const b=Ve.ofModel(m,y),x=yield nf.buildSymmetryAssembly(b,h,g).runInContext(p),_={label:"Symmetry Assembly",description:Ve.elementDescription(x)};return new pe.Molecule.Structure(x,_)})).apply(this,arguments)}function f(){return f=ie(function*(p,m,h,g){const y=g?.params,b=no.Provider.get(h);if(!b||!g||"model"===g.name){const x=Ve.ofModel(h,y);return new pe.Molecule.Structure(x,{label:"Model",description:Ve.elementDescription(x)})}if("auto"===g.name){if(0===b.assemblies.length){const x=Ve.ofModel(h,y);return new pe.Molecule.Structure(x,{label:"Model",description:Ve.elementDescription(x)})}return r(p,m,h,void 0,y)}return"assembly"===g.name?r(p,m,h,g.params.id,y):"symmetry"===g.name?function o(p,m,h,g,y){return s.apply(this,arguments)}(m,h,g.params.ijkMin,g.params.ijkMax,y):"symmetry-mates"===g.name?function a(p,m,h,g){return c.apply(this,arguments)}(m,h,g.params.radius,y):"symmetry-assembly"===g.name?function u(p,m,h,g,y){return l.apply(this,arguments)}(m,h,g.params.generators,b,y):void Rr()}),f.apply(this,arguments)}e.getParams=function t(p,m){const h=p&&no.Provider.get(p),g=h?h.assemblies.map(A=>[A.id,`${A.id}: ${zu(A.details)}`]):[],y=!h||!ma.isZero(h.spacegroup.cell),b=[];if(h){const{operators:A}=h.spacegroup;for(let E=0,w=A.length;E{x.push([A.id,A.id===A.auth_id?A.id:`${A.id} [auth ${A.auth_id}]`])});const _={auto:C.Group(Fv),model:C.Group(Fv),assembly:C.Group({id:C.Optional(p?C.Select(g.length?g[0][0]:"",g,{label:"Asm Id",description:"Assembly Id"}):C.Text("",{label:"Asm Id",description:"Assembly Id (use empty for the 1st assembly)"})),...Fv},{isFlat:!0}),"symmetry-mates":C.Group({radius:C.Numeric(5,{min:0,max:50,step:1}),...Fv},{isFlat:!0}),symmetry:C.Group({ijkMin:C.Vec3(v.create(-1,-1,-1),{step:1},{label:"Min IJK",fieldLabels:{x:"I",y:"J",z:"K"}}),ijkMax:C.Vec3(v.create(1,1,1),{step:1},{label:"Max IJK",fieldLabels:{x:"I",y:"J",z:"K"}}),...Fv},{isFlat:!0}),"symmetry-assembly":C.Group({generators:C.ObjectList({operators:C.ObjectList({index:C.Select(0,b),shift:C.Vec3(v(),{step:1},{label:"IJK",fieldLabels:{x:"I",y:"J",z:"K"}})},A=>`${A.index+1}_${A.shift.map(E=>E+5).join("")}`,{defaultValue:[]}),asymIds:C.MultiSelect([],x)},A=>`${A.asymIds.length} asym ids, ${A.operators.length} operators`,{defaultValue:[]}),...Fv},{isFlat:!0})},S=[];return"auto"===m&&S.push(["auto","Auto"]),S.push(["model","Model"]),g.length>0&&S.push(["assembly","Assembly"]),y&&(S.push(["symmetry-mates","Symmetry Mates"]),S.push(["symmetry","Symmetry (indices)"]),S.push(["symmetry-assembly","Symmetry (assembly)"])),{type:C.MappedStatic(m||"model",_,{options:S})}},e.canAutoUpdate=function n(p,m){return!("symmetry-assembly"===m.name||"symmetry"===m.name&&"symmetry"===p.name)},e.create=function d(p,m,h,g){return f.apply(this,arguments)}}(b0||(b0={})),function(e){function n(a,c){const u=ko.is(c)?c:void 0,l=ko.is(c)?ko.toExpression(c):c;return{script:u,expression:l,compiled:TS(l),originalStructure:a,currentStructure:a}}function r(a,c){return a.compiled(new qu(c))}e.isUnchanged=function t(a,c,u){return a.currentStructure===u&&(ko.is(c)?!!a.script&&ko.areEqual(a.script,c):a.expression===c)},e.create=n,e.run=r,e.createAndRun=function i(a,c){const u=n(a,c);return{entry:u,selection:r(u,a)}},e.updateStructure=function o(a,c){return a.currentStructure=c,a.compiled(new qu(c))},e.updateStructureObject=function s(a,c,u){const l=pt.unionStructure(c);a.label=`${u||"Selection"}`,a.description=Ve.elementDescription(l),a.data=l}}(Aa||(Aa={}));const s$e=new Set(["LI","NA","K","RB","CS","FR"]),c$e=new Set(["BE","MG","CA","SR","BA","RA"]),g$e=new Set(["ZN","GA","CD","IN","SN","HG","TI","PB","BI","PO","CN"]),v$e=new Set(["F","CL","BR","I","AT"]);function _$e(e){return v$e.has(e)}function Toe(e){const t=_2(e);return t>=21&&t<=29||t>=39&&t<=47||t>=72&&t<=79||t>=104&&t<=108}function C$e(e){return function a$e(e){return s$e.has(e)}(e)||function u$e(e){return c$e.has(e)}(e)||function x$e(e){const t=_2(e);return t>=57&&t<=71}(e)||function S$e(e){const t=_2(e);return t>=89&&t<=103}(e)||Toe(e)||function y$e(e){return g$e.has(e)}(e)}var pr=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}(pr||{});function lr(e,t,n={}){var r;let i;return{label:e,expression:t,description:n.description||"",category:null!==(r=n.category)&&void 0!==r?r:pr.Misc,isHidden:!!n.isHidden,priority:n.priority||0,referencesCurrent:!!n.referencesCurrent,get query(){return i||(i=TS(t)),i},ensureCustomProperties:n.ensureCustomProperties,getSelection:(o,s,a)=>ie(function*(){const c=o.managers.structure.selection.getStructure(a),u=c?pt.Sequence(a,[c]):pt.Empty(a);return n.ensureCustomProperties&&(yield n.ensureCustomProperties({runtime:s,assetManager:o.managers.asset},a)),i||(i=TS(t)),i(new qu(a,{currentSelection:u}))})()}}const w$e=lr("All",ue.struct.generator.all(),{category:"",priority:1e3}),A$e=lr("Current Selection",ue.internal.generator.current(),{category:"",referencesCurrent:!0}),I$e=lr("Polymer",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.logic.and([ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),ue.core.str.match([ue.re("(polypeptide|cyclic-pseudo-peptide|peptide-like|nucleotide|peptide nucleic acid)","i"),ue.ammp("entitySubtype")])])})]),{category:pr.Type}),T$e=lr("Trace",ue.struct.modifier.union([ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),"chain-test":ue.core.set.has([ue.set("sphere","gaussian"),ue.ammp("objectPrimitive")])})]),ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"atom-test":ue.core.set.has([ue.set("CA","P"),ue.ammp("label_atom_id")])})])])]),{category:pr.Structure}),Bv=ue.core.logic.and([ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),ue.core.str.match([ue.re("(polypeptide|cyclic-pseudo-peptide|peptide-like)","i"),ue.ammp("entitySubtype")])]),HD=ue.core.logic.and([ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),ue.core.str.match([ue.re("(nucleotide|peptide nucleic acid)","i"),ue.ammp("entitySubtype")])]),v0=ue.core.str.match([ue.re("non-polymer|(amino|carboxy) terminus|peptide-like","i"),ue.ammp("chemCompType")]),D$e=lr("Backbone",ue.struct.modifier.union([ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":Bv,"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([v0]),"atom-test":ue.core.set.has([ue.set(...Si.toArray(lp)),ue.ammp("label_atom_id")])})]),ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":HD,"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([v0]),"atom-test":ue.core.set.has([ue.set(...Si.toArray(ZI)),ue.ammp("label_atom_id")])})])])]),{category:pr.Structure}),E$e=lr("Sidechain",ue.struct.modifier.union([ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":Bv,"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([v0]),"atom-test":ue.core.logic.or([ue.core.logic.not([ue.core.set.has([ue.set(...Si.toArray(lp)),ue.ammp("label_atom_id")])])])})]),ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":HD,"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([v0]),"atom-test":ue.core.logic.or([ue.core.logic.not([ue.core.set.has([ue.set(...Si.toArray(ZI)),ue.ammp("label_atom_id")])])])})])])]),{category:pr.Structure}),P$e=lr("Sidechain with Trace",ue.struct.modifier.union([ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":Bv,"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([v0]),"atom-test":ue.core.logic.or([ue.core.logic.not([ue.core.set.has([ue.set(...Si.toArray(lp)),ue.ammp("label_atom_id")])]),ue.core.rel.eq([ue.ammp("label_atom_id"),"CA"]),ue.core.logic.and([ue.core.rel.eq([ue.ammp("auth_comp_id"),"PRO"]),ue.core.rel.eq([ue.ammp("label_atom_id"),"N"])])])})]),ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":HD,"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([v0]),"atom-test":ue.core.logic.or([ue.core.logic.not([ue.core.set.has([ue.set(...Si.toArray(ZI)),ue.ammp("label_atom_id")])]),ue.core.rel.eq([ue.ammp("label_atom_id"),"P"])])})])])]),{category:pr.Structure}),M$e=lr("Protein",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":Bv})]),{category:pr.Type}),R$e=lr("Nucleic",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":HD})]),{category:pr.Type}),k$e=lr("Helix",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":Bv,"residue-test":ue.core.flags.hasAny([ue.ammp("secondaryStructureFlags"),ue.core.type.bitflags([2])])})]),{category:pr.Structure,ensureCustomProperties:(e,t)=>Xu.attach(e,t)}),N$e=lr("Beta Strand/Sheet",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":Bv,"residue-test":ue.core.flags.hasAny([ue.ammp("secondaryStructureFlags"),ue.core.type.bitflags([4])])})]),{category:pr.Structure,ensureCustomProperties:(e,t)=>Xu.attach(e,t)}),F$e=lr("Water",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entityType"),"water"])})]),{category:pr.Type}),B$e=lr("Ion",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entitySubtype"),"ion"])})]),{category:pr.Type}),O$e=lr("Lipid",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entitySubtype"),"lipid"])})]),{category:pr.Type}),qD=lr("Carbohydrate",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.logic.or([ue.core.rel.eq([ue.ammp("entityType"),"branched"]),ue.core.logic.and([ue.core.rel.eq([ue.ammp("entityType"),"non-polymer"]),ue.core.str.match([ue.re("oligosaccharide","i"),ue.ammp("entitySubtype")])])])})]),{category:pr.Type}),Doe=lr("Carbohydrate with Connected",ue.struct.modifier.union([ue.struct.modifier.includeConnected({0:qD.expression,"layer-count":1,"as-whole-residues":!0})]),{category:pr.Internal,isHidden:!0}),Eoe=lr("Connected to Carbohydrate",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:Doe.expression,by:qD.expression})]),{category:pr.Internal,isHidden:!0}),J5=lr("Ligand",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:ue.struct.modifier.union([ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.logic.and([ue.core.logic.or([ue.core.rel.eq([ue.ammp("entityType"),"non-polymer"]),ue.core.rel.neq([ue.ammp("entityPrdId"),""])]),ue.core.logic.not([ue.core.str.match([ue.re("(oligosaccharide|lipid|ion)","i"),ue.ammp("entitySubtype")])])]),"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.logic.not([ue.core.str.match([ue.re("saccharide","i"),ue.ammp("chemCompType")])])})]),ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":v0})])])]),by:ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.set.has([ue.set(...Si.toArray($b)),ue.ammp("label_comp_id")])})]),ue.struct.generator.atomGroups({"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.core.set.has([ue.set(...Si.toArray(eFe)),ue.ammp("label_comp_id")])})])})]),{category:pr.Type}),Poe=lr("Ligand with Connected",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:ue.struct.modifier.union([ue.struct.modifier.includeConnected({0:J5.expression,"layer-count":1,"as-whole-residues":!0,"bond-test":ue.core.flags.hasAny([ue.struct.bondProperty.flags(),ue.core.type.bitflags([3])])})]),by:qD.expression})]),{category:pr.Internal,isHidden:!0}),Moe=lr("Connected to Ligand",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:Poe.expression,by:J5.expression})]),{category:pr.Internal,isHidden:!0}),L$e=lr("Connected to Ligand or Carbohydrate",ue.struct.modifier.union([ue.struct.combinator.merge([Eoe.expression,Moe.expression])]),{category:pr.Internal,isHidden:!0}),U$e=lr("Disulfide Bridges",ue.struct.modifier.union([ue.struct.combinator.merge([ue.struct.modifier.union([ue.struct.modifier.wholeResidues([ue.struct.filter.isConnectedTo({0:ue.struct.generator.atomGroups({"residue-test":ue.core.set.has([ue.set("CYS"),ue.ammp("auth_comp_id")]),"atom-test":ue.core.set.has([ue.set("SG"),ue.ammp("label_atom_id")])}),target:ue.struct.generator.atomGroups({"residue-test":ue.core.set.has([ue.set("CYS"),ue.ammp("auth_comp_id")]),"atom-test":ue.core.set.has([ue.set("SG"),ue.ammp("label_atom_id")])}),"bond-test":!0})])]),ue.struct.modifier.union([ue.struct.modifier.wholeResidues([ue.struct.modifier.union([ue.struct.generator.bondedAtomicPairs({0:ue.core.flags.hasAny([ue.struct.bondProperty.flags(),ue.core.type.bitflags([8])])})])])])])]),{category:pr.Bond}),V$e=lr("NOS Bridges",ue.struct.modifier.union([ue.struct.modifier.wholeResidues([ue.struct.filter.isConnectedTo({0:ue.struct.generator.atomGroups({"residue-test":ue.core.set.has([ue.set("CSO","LYS"),ue.ammp("auth_comp_id")]),"atom-test":ue.core.set.has([ue.set("OD","NZ"),ue.ammp("label_atom_id")])}),target:ue.struct.generator.atomGroups({"residue-test":ue.core.set.has([ue.set("CSO","LYS"),ue.ammp("auth_comp_id")]),"atom-test":ue.core.set.has([ue.set("OD","NZ"),ue.ammp("label_atom_id")])}),"bond-test":!0})])]),{category:pr.Bond}),z$e=lr("Non-standard Residues in Polymers",ue.struct.modifier.union([ue.struct.generator.atomGroups({"entity-test":ue.core.rel.eq([ue.ammp("entityType"),"polymer"]),"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":ue.ammp("isNonStandard")})]),{category:pr.Residue}),G$e=lr("Coarse Elements",ue.struct.modifier.union([ue.struct.generator.atomGroups({"chain-test":ue.core.set.has([ue.set("sphere","gaussian"),ue.ammp("objectPrimitive")])})]),{category:pr.Type}),j$e=lr("Rings in Residues",ue.struct.modifier.union([ue.struct.generator.rings()]),{category:pr.Residue}),H$e=lr("Aromatic Rings in Residues",ue.struct.modifier.union([ue.struct.generator.rings({"only-aromatic":!0})]),{category:pr.Residue}),q$e=lr("Surrounding Residues (5 \u212b) of Selection",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:ue.struct.modifier.includeSurroundings({0:ue.internal.generator.current(),radius:5,"as-whole-residues":!0}),by:ue.internal.generator.current()})]),{description:"Select residues within 5 \u212b of the current selection.",category:pr.Manipulate,referencesCurrent:!0}),W$e=lr("Surrounding Ligands (5 \u212b) of Selection",ue.struct.modifier.union([ue.struct.modifier.surroundingLigands({0:ue.internal.generator.current(),radius:5,"include-water":!0})]),{description:"Select ligand components within 5 \u212b of the current selection.",category:pr.Manipulate,referencesCurrent:!0}),$$e=lr("Surrounding Atoms (5 \u212b) of Selection",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:ue.struct.modifier.includeSurroundings({0:ue.internal.generator.current(),radius:5,"as-whole-residues":!1}),by:ue.internal.generator.current()})]),{description:"Select atoms within 5 \u212b of the current selection.",category:pr.Manipulate,referencesCurrent:!0}),Y$e=lr("Inverse / Complement of Selection",ue.struct.modifier.union([ue.struct.modifier.exceptBy({0:ue.struct.generator.all(),by:ue.internal.generator.current()})]),{description:"Select everything not in the current selection.",category:pr.Manipulate,referencesCurrent:!0}),X$e=lr("Residues Covalently Bonded to Selection",ue.struct.modifier.union([ue.struct.modifier.includeConnected({0:ue.internal.generator.current(),"layer-count":1,"as-whole-residues":!0})]),{description:"Select residues covalently bonded to current selection.",category:pr.Manipulate,referencesCurrent:!0}),K$e=lr("Covalently Bonded Component",ue.struct.modifier.union([ue.struct.modifier.includeConnected({0:ue.internal.generator.current(),"fixed-point":!0})]),{description:"Select covalently bonded component based on current selection.",category:pr.Manipulate,referencesCurrent:!0}),Z$e=lr("Residues with Cov. or Metallic Bond to Selection",ue.struct.modifier.union([ue.struct.modifier.includeConnected({0:ue.internal.generator.current(),"layer-count":1,"as-whole-residues":!0,"bond-test":ue.core.flags.hasAny([ue.struct.bondProperty.flags(),ue.core.type.bitflags([3])])})]),{description:"Select residues with covalent or metallic bond to current selection.",category:pr.Manipulate,referencesCurrent:!0}),Q$e=lr("Whole Residues of Selection",ue.struct.modifier.union([ue.struct.modifier.wholeResidues({0:ue.internal.generator.current()})]),{description:"Expand current selection to whole residues.",category:pr.Manipulate,referencesCurrent:!0}),J$e=[[["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((e,t)=>e[1]t[1]?1:0),eYe=[[["A","DA"],"Adenosine"],[["C","DC"],"Cytidine"],[["T","DT"],"Thymidine"],[["G","DG"],"Guanosine"],[["I","DI"],"Inosine"],[["U","DU"],"Uridine"],[["N","DN"],"Unknown"]].sort((e,t)=>e[1]t[1]?1:0);function e6([e,t],n,r=0){const i=1!==e.length||Roe.has(e[0])?`${t} (${e.join(", ")})`:`[${e[0]}] ${t}`;return lr(i,ue.struct.modifier.union([ue.struct.generator.atomGroups({"residue-test":ue.core.set.has([ue.set(...e),ue.ammp("auth_comp_id")])})]),{category:n,priority:r,description:i})}const Roe=Si.unionMany(DB,c2,u2,QI),No={all:w$e,current:A$e,polymer:I$e,trace:T$e,backbone:D$e,sidechain:E$e,sidechainWithTrace:P$e,protein:M$e,nucleic:R$e,helix:k$e,beta:N$e,water:F$e,ion:B$e,lipid:O$e,branched:qD,branchedPlusConnected:Doe,branchedConnectedOnly:Eoe,ligand:J5,ligandPlusConnected:Poe,ligandConnectedOnly:Moe,connectedOnly:L$e,disulfideBridges:U$e,nosBridges:V$e,nonStandardPolymer:z$e,coarse:G$e,ring:j$e,aromaticRing:H$e,surroundings:q$e,surroundingLigands:W$e,surroundingAtoms:$$e,complement:Y$e,covalentlyBonded:X$e,covalentlyOrMetallicBonded:Z$e,covalentlyBondedComponent:K$e,wholeResidues:Q$e};class rYe{add(t){this.list.push(t),this.options.push([t,t.label,t.category]),this.version+=1}remove(t){const n=this.list.indexOf(t);-1!==n&&(this.list.splice(n,1),this.options.splice(n,1),this.version+=1)}constructor(){this.list=[],this.options=[],this.version=1,this.list.push(...Object.values(No),...J$e.map(t=>e6(t,pr.AminoAcid)),...eYe.map(t=>e6(t,pr.NucleicBase))),this.options.push(...this.list.map(t=>[t,t.label,t.category]))}}function aYe(e){switch(e){case 7:return-3;case 6:return-2;case 5:return-1;case 0:case 4:return 0;case 3:return 1;case 2:return 2;case 1:return 3;default:return console.error(`Value ${e} is outside the 0-7 range, defaulting to 0.`),0}}function koe(e,t){const n=He.create(e.data,2*t),r=He.create(e.data,2*t),i=He.create(e.data,2*t),o=He.create(e.data,2*t),s=He.create(e.data,2*t);for(let a=0;a0)for(let g=0;g0){const g=te.ofIntArray(te.mapToArray(i.atomIdxA,_=>_-1,Int32Array)),y=te.ofIntArray(te.mapToArray(i.atomIdxB,_=>_-1,Int32Array)),b=te.asArrayColumn(i.order,Int32Array),x=Ms.fromData({pairs:{indexA:g,indexB:y,order:b},count:r.count},{maxDistance:1/0});Ms.Provider.set(h.representative,x)}return h}),t6.apply(this,arguments)}var n6,DS,o6;function r6(){return r6=ie(function*(e,t,n){var r;const i=e.atom_site._rowCount,o=te.ofConst("MOL",i,te.Schema.str),s=te.ofConst("A",i,te.Schema.str),a=te.ofConst(1,i,te.Schema.int),c=function pYe(e){const{cell:t,space_group:n}=e,r=function fYe(e){const t=e.it_number.value(0),n=e["name_h-m_full"].value(0).replace("-"," ");return e.it_number.isDefined?t:n}(n),i=ma.create(r,v.create(t.length_a.value(0),t.length_b.value(0),t.length_c.value(0)),v.scale(v(),v.create(t.angle_alpha.value(0),t.angle_beta.value(0),t.angle_gamma.value(0)),Math.PI/180));return{spacegroup:Ec.create(i),assemblies:[],isNonStandardCrystalFrame:!1,ncsOperators:[]}}(e),u=c.spacegroup.cell.fromFractional,{fract_x:l,fract_y:d,fract_z:f}=e.atom_site,p=new Float32Array(i),m=new Float32Array(i),h=new Float32Array(i),g=v();for(let R=0;R0){const R=I.representative;no.Provider.set(R,c);const T=e.geom_bond._rowCount;if(T>0){const M={},{label:N}=e.atom_site;for(let W=0,Q=N.rowCount;Wfunction HNe(e){return GQ.has(e)?GQ.get(e):Bg("H")}(d)),schema:te.Schema.Aliased(te.Schema.str)}),s=te.ofConst(1,n.count,te.Schema.int),a=Xn.ofPartialColumns(ks.atom_site,{auth_asym_id:i,auth_atom_id:o,auth_comp_id:r,auth_seq_id:s,Cartn_x:te.asArrayColumn(n.x,Float32Array),Cartn_y:te.asArrayColumn(n.y,Float32Array),Cartn_z:te.asArrayColumn(n.z,Float32Array),id:te.range(0,n.count-1),label_asym_id:i,label_atom_id:o,label_comp_id:r,label_seq_id:s,label_entity_id:te.ofConst("1",n.count,te.Schema.str),occupancy:te.ofConst(1,n.count,te.Schema.float),type_symbol:o,pdbx_PDB_model_num:te.ofConst(1,n.count,te.Schema.int)},n.count),c=new sd;c.setNames([["MOL","Unknown Entity"]]),c.getEntityId("MOL",0,"A");const u=new ad(s,o);u.setNames([["MOL","Unknown Molecule"]]),u.add("MOL",0);const l=$u({entity:c.getEntityTable(),chem_comp:u.getChemCompTable(),atom_site:a});return yield af(l,o6.create(e),t)}),i6.apply(this,arguments)}!function(e){e.is=function t(r){return"mol"===r?.kind},e.create=function n(r){return{kind:"mol",name:r.title,data:r}}}(n6||(n6={})),tf.Provider.formatRegistry.add("cifCore",function mYe(e){if(!DS.is(e.sourceData))return;const{atom_site:t,atom_site_aniso:n}=e.sourceData.data.db;return{data:Xn.ofPartialColumns(tf.Schema,{U:n.u},n._rowCount),elementToAnsiotrop:tf.getElementToAnsiotropFromLabel(t.label,n.label)}},function gYe(e){return!!DS.is(e.sourceData)&&e.sourceData.data.db.atom_site_aniso.u.isDefined}),function(e){e.is=function t(r){return"cifCore"===r?.kind},e.fromFrame=function n(r,i){return i||(i=od.schema.cifCore(r)),{kind:"cifCore",name:i.database_code.depnum_ccdc_archive.value(0)||i.database_code.depnum_ccdc_fiz.value(0)||i.database_code.icsd.value(0)||i.database_code.mdf.value(0)||i.database_code.nbs.value(0)||i.database_code.csd.value(0)||i.database_code.cod.value(0)||i._name,data:{db:i,frame:r}}}}(DS||(DS={})),function(e){e.is=function t(r){return"cube"===r?.kind},e.create=function n(r){return{kind:"cube",name:r.header.comment1,data:r}}}(o6||(o6={}));const{skipWhitespace:s6,eatValue:Ooe,markLine:ml,getTokenString:gl,readLine:Loe}=ht;function xYe(e,t){return{tokenizer:e,molecule:{mol_name:"",num_atoms:0,num_bonds:0,num_subst:0,num_feat:0,num_sets:0,mol_type:"",charge_type:"",status_bits:"",mol_comment:""},runtimeCtx:t}}const Uoe=/\s+/g;function SYe(e){const{tokenizer:t,molecule:n}=e;for(;"@MOLECULE"!==gl(t)&&t.position"))return;n.mol_type=i,ml(t);const o=gl(t);if(o.startsWith("@"))return;n.charge_type=o,ml(t);const s=gl(t);if(s.startsWith("@"))return;n.status_bits=s,ml(t);const a=gl(t);a.startsWith("@")||(n.mol_comment=a)}function CYe(e){return a6.apply(this,arguments)}function a6(){return a6=ie(function*(e){const{tokenizer:t,molecule:n}=e;for(;"@ATOM"!==gl(t)&&t.position{const D=Math.min(n.num_atoms-A,w);for(let I=0;Iw.update({message:"Parsing...",current:t.position,max:S})),{count:n.num_atoms,atom_id:Jt(c)(te.Schema.int),atom_name:Jt(u)(te.Schema.str),x:Jt(l)(te.Schema.float),y:Jt(d)(te.Schema.float),z:Jt(f)(te.Schema.float),atom_type:a>5?Jt(p)(te.Schema.str):_,subst_id:a>6?Jt(m)(te.Schema.int):x,subst_name:a>7?Jt(h)(te.Schema.str):_,charge:a>8?Jt(g)(te.Schema.float):b,status_bit:a>9?Jt(y)(te.Schema.str):_}}),a6.apply(this,arguments)}function wYe(e){return c6.apply(this,arguments)}function c6(){return c6=ie(function*(e){const{tokenizer:t,molecule:n}=e;for(;"@BOND"!==gl(t)&&t.position{const y=Math.min(n.num_bonds-m,g);for(let b=0;bg.update({message:"Parsing...",current:t.position,max:p})),{count:n.num_bonds,bond_id:Jt(c)(te.Schema.int),origin_atom_id:Jt(u)(te.Schema.int),target_atom_id:Jt(l)(te.Schema.int),bond_type:Jt(d)(te.Schema.str),status_bits:a>4?Jt(f)(te.Schema.str):te.Undefined(n.num_bonds,te.Schema.str)}}),c6.apply(this,arguments)}function AYe(e){const{tokenizer:t}=e;for(;t.positionMOLECULE"===r)return;if("@CRYSIN"===r)break;ml(t)}if(t.position>=t.data.length)return;ml(t);const n=gl(t).trim().split(Uoe);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 u6(){return u6=ie(function*(e,t,n){const r=ht(t);e.update({message:"Parsing...",current:0,max:t.length});const i=[];for(;r.positionMOLECULE"!==gl(r)&&r.position0){const y=te.ofIntArray(te.mapToArray(a.origin_atom_id,w=>w-1,Int32Array)),b=te.ofIntArray(te.mapToArray(a.target_atom_id,w=>w-1,Int32Array)),x=a.bond_id,_=te.ofIntArray(te.mapToArray(a.bond_type,w=>{switch(w){case"ar":case"am":case"un":return 1;case"du":case"nc":return 0;default:return parseInt(w)}},Int8Array)),S=te.ofIntArray(te.mapToArray(a.bond_type,w=>{switch(w){case"ar":case"am":return 17;case"du":case"nc":return 0;default:return 1}},Int8Array)),A=Ms.fromData({pairs:{key:x,indexA:y,indexB:b,order:_,flag:S},count:s.count},{maxDistance:c?-1:1/0}),E=g.representative;if(Ms.Provider.set(E,A),Mv.Provider.set(E,{data:s.charge,type:o.charge_type}),c){const w=EYe(c);w&&no.Provider.set(E,w)}n.push(E)}}return new xp(n)}),l6.apply(this,arguments)}function EYe(e){if(1!==e.setting)return;const t=ma.create(e.spaceGroup,v.create(e.a,e.b,e.c),v.scale(v(),v.create(e.alpha,e.beta,e.gamma),Math.PI/180));return{spacegroup:Ec.create(t),assemblies:[],isNonStandardCrystalFrame:!1,ncsOperators:[]}}var d6;!function(e){e.is=function t(r){return"mol2"===r?.kind},e.create=function n(r){return{kind:"mol2",name:r.name,data:r}}}(d6||(d6={}));const Ov=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]),f6=9;var Oc,h6;function MYe(){throw new Error("(xdrfile error) Undefined error.")}function p6(){return p6=ie(function*(e,t){const n=new DataView(t.buffer,t.byteOffset),r={frames:[],boxes:[],times:[],timeOffset:0,deltaTime:0},i=r.frames,o=r.boxes,s=r.times,a=[0,0,0,0,0,0],c=[0,0,0],u=[0,0,0],l=[0,0,0],d=[.1,.1,.1],f=[.1,.1,.1];let p=0;const m=Oc.buf;for(;;){let h;const g=n.getInt32(p+4);p+=12,s.push(n.getFloat32(p)),p+=4;const y=new Float32Array(9);for(let b=0;b<9;++b)y[b]=10*n.getFloat32(p),p+=4;if(o.push(y),g<=9){h={count:g/3,x:new Float32Array(g/3),y:new Float32Array(g/3),z:new Float32Array(g/3)};for(let b=0;b16777215?(u[0]=Oc.sizeOfInt(c[0]),u[1]=Oc.sizeOfInt(c[1]),u[2]=Oc.sizeOfInt(c[2]),S=0):S=Oc.sizeOfInts(3,c);let A=n.getInt32(p);p+=4;let E=A-1;E=f6>E?f6:E;let w=Ov[E]/2|0,D=Ov[A]/2|0;l[0]=l[1]=l[2]=Ov[A];const I=4*Math.ceil(n.getInt32(p)/4);p+=4;const R=1/_;let T=0,M=0;for(d[0]=d[1]=d[2]=0;M0){d[0]=d[1]=d[2]=0;for(let F=0;Ff6?Ov[A-1]/2|0:0):V>0&&(w=D,D=Ov[A]/2|0),l[0]=l[1]=l[2]=Ov[A],(0===l[0]||0===l[1]||0===l[2])&&MYe()}p+=I}for(let b=0;b=t.length)break}return s.length>=1&&(r.timeOffset=s[0]),s.length>=2&&(r.deltaTime=s[1]-s[0]),r}),p6.apply(this,arguments)}function FYe(e){let t=e.position>=e.data.length-1?0:+ht.readLine(e);isNaN(t)&&(t=0);const n=ht.readLine(e),r=new Float64Array(t),i=new Float64Array(t),o=new Float64Array(t),s=new Array(t);for(let a=0;a=d&&f<32;)f++,d<<=1;return f};const n=new Uint8Array(32);e.sizeOfInts=function r(l,d){let f=1,p=0;n[0]=1;for(let h=0;h>=8;for(;0!==y;)n[g++]=255&y,y>>=8;f=g}let m=1;for(f--;n[f]>=m;)p++,m*=2;return p+8*f};const i=new ArrayBuffer(24);e.buf=new Int32Array(i);const o=new Uint32Array(i);function s(l,d,f){let p=f;const m=(1<=8;)g=g<<8|l[d+y++],b|=g>>h<0&&(h>h&(1<>o[1]&255}e.decodeBits=s;const c=[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];e.decodeInts=function u(l,d,f,p,m){let h=f,g=0;for(c[0]=0,c[1]=0,c[2]=0,c[3]=0;h>8;)c[g++]=a(l,d),h-=8;h>0&&(c[g++]=s(l,d,h));for(let y=2;y>0;y--){let b=0;const x=p[y];for(let _=g-1;_>=0;_--){b=b<<8|c[_];const S=b/x|0;c[_]=S,b-=S*x}m[y]=b}m[0]=c[0]|c[1]<<8|c[2]<<16|c[3]<<24}}(Oc||(Oc={})),function(e){e.is=function t(r){return"xyz"===r?.kind},e.create=function n(r){return{kind:"xyz",name:"xyz",data:r}}}(h6||(h6={}));const m6="$$$$";function WYe(e){const t=ht.readLine(e).trim(),n=ht.readLine(e).trim(),r=ht.readLine(e).trim(),i=ht.readLine(e),o=function VYe(e){return e.trim().endsWith("V3000")}(i),{atomCount:s,bondCount:a}=o?function zYe(e){const t=He.create(e.data,1),n=He.create(e.data,1);return ht.eatLine(e),Kp(e),Kp(e),Kp(e),Zp(e,t),Zp(e,n),ht.eatLine(e),{atomCount:Jt(t)(te.Schema.int).value(0),bondCount:Jt(n)(te.Schema.int).value(0)}}(e):function qYe(e){return{atomCount:+e.substr(0,3),bondCount:+e.substr(3,3)}}(i);if(Number.isNaN(s)||Number.isNaN(a)){for(;e.position ")){He.add(t,e.tokenStart+2,e.tokenEnd),ht.markLine(e);const i=e.tokenStart;let o=e.tokenEnd,s=!1;for(;e.position ")){He.add(n,i,o),s=!0;break}o=e.tokenEnd}s||He.add(n,i,o)}}return{dataHeader:Jt(t)(te.Schema.str),data:Jt(n)(te.Schema.str)}}(e);return{molFile:{title:t,program:n,comment:r,atoms:u,bonds:l,formalCharges:d},dataItems:f}}var g6;function XYe(e){return Oe.create("Parse SDF",t=>Boe(e.molFile,g6.create(e),t))}function y6(){return y6=ie(function*(e){const t=new DataView(e.buffer),n={frames:[],boxes:[],times:[],timeOffset:0,deltaTime:0},r=n.frames,i=n.boxes,o=n.times;let s=0;for(;;){s+=8;const a=t.getInt32(s);s+=4,s+=a;const c=t.getInt32(s+8),u=t.getInt32(s+12),l=t.getInt32(s+16),d=t.getInt32(s+28),f=t.getInt32(s+32),p=t.getInt32(s+36),m=t.getInt32(s+40);s+=52;const h=c/9,g=3*m;if(o.push(8===h?t.getFloat64(s):t.getFloat32(s)),s+=2*h,c){const y=new Float32Array(9);if(8===h)for(let b=0;b<9;++b)y[b]=10*t.getFloat64(s),s+=8;else for(let b=0;b<9;++b)y[b]=10*t.getFloat32(s),s+=4;i.push(y)}if(s+=u,s+=l,d){const y=new Float32Array(m),b=new Float32Array(m),x=new Float32Array(m);if(8===h)for(let _=0;_>8&65280|E>>24&255}const S=new Float32Array(e.buffer,s,g);for(let A=0;A=e.byteLength)break}return o.length>=1&&(n.timeOffset=o[0]),o.length>=2&&(n.deltaTime=o[1]-o[0]),n}),y6.apply(this,arguments)}!function(e){e.is=function t(r){return"sdf"===r?.kind},e.create=function n(r){return{kind:"sdf",name:r.molFile.title,data:r}}}(g6||(g6={}));const b6=[];class eXe{constructor(t,n={}){this._mark=0,this._marks=[],this.offset=0,this.littleEndian=!0;let r=!1;void 0===t&&(t=8192),"number"==typeof t?t=new ArrayBuffer(t):r=!0;const i=n.offset?n.offset>>>0:0,o=t.byteLength-i;let s=i;t instanceof ArrayBuffer||(t.byteLength!==t.buffer.byteLength&&(s=t.byteOffset+i),t=t.buffer),this._lastWrittenByte=r?o:0,this.buffer=t,this.length=o,this.byteLength=o,this.byteOffset=s,this._data=new DataView(this.buffer,s,o)}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t){return void 0===t&&(t=1),this.offset+=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t){if(void 0===t&&(t=1),!this.available(t)){const r=2*(this.offset+t),i=new Uint8Array(r);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=this.byteLength=r,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t){void 0===t&&(t=1);const n=new Uint8Array(t);for(let r=0;rthis._lastWrittenByte&&(this._lastWrittenByte=this.offset)}}function yl(e,t){if(e)throw new TypeError("Not a valid NetCDF v3.x file: "+t)}function Voe(e){e.offset%4!=0&&e.skip(4-e.offset%4)}function v6(e){const t=e.readUint32(),n=e.readChars(t);return Voe(e),n}const uo={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function zoe(e){switch(Number(e)){case uo.BYTE:return"byte";case uo.CHAR:return"char";case uo.SHORT:return"short";case uo.INT:return"int";case uo.FLOAT:return"float";case uo.DOUBLE:return"double";default:return"undefined"}}function Goe(e){switch(Number(e)){case uo.BYTE:case uo.CHAR:return 1;case uo.SHORT:return 2;case uo.INT:case uo.FLOAT:return 4;case uo.DOUBLE:return 8;default:return-1}}function joe(e){switch(String(e)){case"byte":return uo.BYTE;case"char":return uo.CHAR;case"short":return uo.SHORT;case"int":return uo.INT;case"float":return uo.FLOAT;case"double":return uo.DOUBLE;default:return-1}}function WD(e,t){if(1!==e){const n=new Array(e);for(let r=0;r6,"non valid type "+s);const a=e.readUint32(),c=_6(e,s,a);Voe(e),t[i]={name:o,type:zoe(s),value:c}}}return t}class lXe{constructor(t){const n=new eXe(t);n.setBigEndian(),yl("CDF"!==n.readChars(3),"should start with CDF");const r=n.readByte();yl(r>2,"unknown version"),this.header=function aXe(e,t){const n={recordDimension:{length:e.readUint32()}};n.version=t;const r=function cXe(e){let t,n,r;const i=e.readUint32();if(i===Lv)return yl(e.readUint32()!==Lv,"wrong empty tag for list of dimensions"),[];{yl(10!==i,"wrong tag for list of dimensions");const o=e.readUint32();t=new Array(o);for(let s=0;s6,"non valid type "+f);const p=e.readUint32();let m=e.readUint32();2===n&&(yl(m>0,"offsets larger than 4GB not supported"),m=e.readUint32()),l[0]===t&&(i+=p),o[a]={name:c,dimensions:l,attributes:d,type:zoe(f),size:p,offset:m,record:l[0]===t}}}return{variables:o,recordStep:i}}(e,r.recordId,t);return n.variables=i.variables,n.recordDimension.recordStep=i.recordStep,n}(n,r),this.buffer=n}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}get variables(){return this.header.variables}hasDataVariable(t){return this.header.variables&&-1!==this.header.variables.findIndex(n=>n.name===t)}getDataVariable(t){var n;let r;if(r="string"==typeof t?null===(n=this.header.variables)||void 0===n?void 0:n.find(i=>i.name===t):t,void 0===r)throw new Error("variable not found");return this.buffer.seek(r.offset),r.record?function rXe(e,t,n){const r=joe(t.type),i=t.size?t.size/Goe(r):1,o=n.length,s=new Array(o),a=n.recordStep;for(let c=0;c=1&&(n.timeOffset=n.time[0]),n.time.length>=2&&(n.deltaTime=n.time[1]-n.time[0])),n}),x6.apply(this,arguments)}var S6,C6;!function(e){e.is=function t(r){return"prmtop"===r?.kind},e.fromPrmtop=function n(r){return{kind:"prmtop",name:r.title.join(" ")||"PRMTOP",data:r}}}(S6||(S6={})),function(e){e.is=function t(r){return"top"===r?.kind},e.fromTop=function n(r){return{kind:"top",name:r.system||"TOP",data:r}}}(C6||(C6={}));const vXe=Rt.BuiltIn({name:"coordinates-from-dcd",display:{name:"Parse DCD",description:"Parse DCD binary data."},from:[pe.Data.Binary],to:pe.Molecule.Coordinates})({apply:({a:e})=>Oe.create("Parse DCD",function(){var t=ie(function*(n){const r=yield function Vze(e){return Oe.create("Parse DCD",function(){var t=ie(function*(n){try{const r=function Uze(e){const t=new DataView(e.buffer),n=Object.create(null),r=[];let i=0;const o=new Int32Array(e.buffer,0,23),s=o[0]!==t.getInt32(0);if(84!==o[0]){const h=e.byteLength;for(let g=0;g28672){const t=[];for(let n=0;n0)throw new Error("dcd format with fixed atoms unsupported, aborting");const p=n.NATOM,m=4*p;for(let h=0,g=n.NSET;h=1?(r.ISTART-1)*i.value:0,i.unit),s=[];for(let a=0,c=e.frames.length;a=-1&&d[1]<=1&&d[3]>=-1&&d[3]<=1&&d[4]>=-1&&d[4]<=1?Wp.create(v.create(d[0],d[2],d[5]),v.create(Yn(90-90*Math.asin(d[1])/Wx),Yn(90-90*Math.asin(d[3])/Wx),Yn(90-90*Math.asin(d[4])/Wx))):d[0]<0||d[1]<0||d[2]<0||d[3]<0||d[4]<0||d[5]<0||d[3]>180||d[4]>180||d[5]>180?Wp.fromBasis(v.create(d[0],d[1],d[3]),v.create(d[1],d[2],d[4]),v.create(d[3],d[4],d[5])):Wp.create(v.create(d[0],d[2],d[5]),v.create(Yn(ai(d[1],0,vr)?90:d[1]),Yn(ai(d[3],0,vr)?90:d[3]),Yn(ai(d[4],0,vr)?90:d[4])))}s.push(l)}return Dg.create(s,i,o)});return function(n){return t.apply(this,arguments)}}())}(r.result).runInContext(n);return new pe.Molecule.Coordinates(i,{label:e.label,description:"Coordinates"})});return function(n){return t.apply(this,arguments)}}())}),_Xe=Rt.BuiltIn({name:"coordinates-from-xtc",display:{name:"Parse XTC",description:"Parse XTC binary data."},from:[pe.Data.Binary],to:pe.Molecule.Coordinates})({apply:({a:e})=>Oe.create("Parse XTC",function(){var t=ie(function*(n){const r=yield function kYe(e){return Oe.create("Parse XTC",function(){var t=ie(function*(n){try{n.update({canAbort:!0,message:"Parsing trajectory..."});const r=yield function RYe(e,t){return p6.apply(this,arguments)}(n,e);return Fr.success(r)}catch(r){return Fr.error(""+r)}});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function NYe(e){return Oe.create("Parse XTC",function(){var t=ie(function*(n){yield n.update("Converting to coordinates");const r=Ic(e.deltaTime,"step"),i=Ic(e.timeOffset,r.unit),o=[];for(let s=0,a=e.frames.length;sOe.create("Parse TRR",function(){var t=ie(function*(n){const r=yield function ZYe(e){return Oe.create("Parse TRR",function(){var t=ie(function*(n){try{n.update({canAbort:!0,message:"Parsing trajectory..."});const r=yield function KYe(e){return y6.apply(this,arguments)}(e);return Fr.success(r)}catch(r){return Fr.error(""+r)}});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function QYe(e){return Oe.create("Parse TRR",function(){var t=ie(function*(n){yield n.update("Converting to coordinates");const r=Ic(e.deltaTime,"step"),i=Ic(e.timeOffset,r.unit),o=[];for(let s=0,a=e.frames.length;sOe.create("Parse NCTRAJ",function(){var t=ie(function*(n){const r=yield function fXe(e){return Oe.create("Parse NCTRAJ",function(){var t=ie(function*(n){try{n.update({canAbort:!0,message:"Parsing trajectory..."});const r=yield function dXe(e){return x6.apply(this,arguments)}(e);return Fr.success(r)}catch(r){return Fr.error(""+r)}});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function pXe(e){return Oe.create("Parse NCTRAJ",function(){var t=ie(function*(n){yield n.update("Converting to coordinates");const r=Ic(e.deltaTime,"step"),i=Ic(e.timeOffset,r.unit),o=[];for(let s=0,a=e.coordinates.length;sOe.create("Create Topology",function(){var t=ie(function*(n){const r=yield function hWe(e){return Oe.create("Parse PSF",function(){var t=ie(function*(n){const r=L5.fromPsf(e),i=function pWe(e){const t=new Array(e.count),n=new Array(e.count),r=new Uint32Array(e.count),i=new Uint32Array(e.count),o=new Array(e.count),s=new sd,a=new ad(e.residueId,e.atomName);let c="",u=0,l="",d=0,f=e.segmentName.value(0),p=!1,m=0,h=-1;for(let y=0,b=e.count;yo.value(c)-1,rowCount:o.rowCount,schema:o.schema}),indexB:te.ofLambda({value:c=>s.value(c)-1,rowCount:s.rowCount,schema:s.schema}),order:te.ofConst(1,e.bonds.count,te.Schema.int)};return Yx.create(e.id,i,a,r)});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);return new pe.Molecule.Topology(r,{label:r.label||e.label,description:"Topology"})});return function(n){return t.apply(this,arguments)}}())}),wXe=Rt.BuiltIn({name:"topology-from-prmtop",display:{name:"PRMTOP Topology",description:"Create topology from PRMTOP."},from:[pe.Format.Prmtop],to:pe.Molecule.Topology})({apply:({a:e})=>Oe.create("Create Topology",function(){var t=ie(function*(n){const r=yield function mXe(e){return Oe.create("Parse PRMTOP",function(){var t=ie(function*(n){const r=S6.fromPrmtop(e),i=function hXe(e){const{pointers:t,residuePointer:n,residueLabel:r,atomName:i}=e,o=t.NATOM,s=t.NRES,a=new Uint32Array(o),c=[],u=(M,N,V)=>{const F=r.value(M);for(let G=N,L=V;GddOe.create("Create Topology",function(){var t=ie(function*(n){const r=yield function bXe(e){return Oe.create("Parse TOP",function(){var t=ie(function*(n){const r=C6.fromTop(e),i=function gXe(e){const{molecules:t,compounds:n}=e,r={};let i=0;for(let M=0,N=t._rowCount;MOe.create("Create trajectory from model/topology and coordinates",function(){var n=ie(function*(r){const i=t[e.coordinatesRef].data,o=yield function IXe(e,t,n){return w6.apply(this,arguments)}(r,t[e.modelRef],i);return new pe.Molecule.Trajectory(o,{label:"Trajectory",description:`${o.frameCount} model${1===o.frameCount?"":"s"}`})});return function(r){return n.apply(this,arguments)}}())}),TXe=Rt.BuiltIn({name:"trajectory-from-blob",display:{name:"Parse Blob",description:"Parse format blob into a single trajectory."},from:pe.Format.Blob,to:pe.Molecule.Trajectory})({apply:({a:e})=>Oe.create("Parse Format Blob",function(){var t=ie(function*(n){const r=[];for(const o of e.data){if("cif"!==o.kind)continue;const s=o.data.blocks[0],a=yield dO(s).runInContext(n);if(0===a.frameCount)throw new Error("No models found.");for(let c=0;c!0===r.loadAllBlocks})),blockIndex:C.Optional(C.Numeric(0,{min:0,step:1},{description:"Zero-based index of the block to parse. Only applies when Block Header parameter is not specified.",hideIf:r=>!0===r.loadAllBlocks||r.blockHeader}))};const{blocks:t}=e.data,n=t.map(r=>[r.header,r.header]);return n.push(["","[Use Block Index]"]),{loadAllBlocks:C.Optional(C.Boolean(!1,{description:"If True, ignore Block Header and Block Index parameters and parse all data blocks into a single trajectory."})),blockHeader:C.Optional(C.Select(t[0]&&t[0].header,n,{description:"Header of the block to parse. If not specifed, Block Index parameter applies.",hideIf:r=>!0===r.loadAllBlocks})),blockIndex:C.Optional(C.Numeric(0,{min:0,step:1,max:t.length-1},{description:"Zero-based index of the block to parse. Only applies when Block Header parameter is not specified.",hideIf:r=>!0===r.loadAllBlocks||r.blockHeader}))}}})({isApplicable:e=>e.data.blocks.length>0,apply:({a:e,params:t})=>Oe.create("Parse mmCIF",function(){var n=ie(function*(r){var i;let o;if(t.loadAllBlocks){const a=[];for(const c of e.data.blocks){r.shouldUpdate&&(yield r.update(`Parsing ${c.header}...`));const u=yield dO(c).runInContext(r);for(let l=0;ll.header===a);if(!c)throw new Error(`Data block '${[a]}' not found.`);o=!c.categoryNames.includes("chem_comp_atom")||c.categoryNames.includes("atom_site")||c.categoryNames.includes("ihm_sphere_obj_site")||c.categoryNames.includes("ihm_gaussian_obj_site")?yield dO(c,e.data).runInContext(r):yield function j4e(e){const t=x2.fromFrame(e);return Oe.create("Create CCD Models",n=>function H4e(e,t,n){return fO.apply(this,arguments)}(t.data.db,x2.fromFrame(e),n))}(c).runInContext(r)}if(0===o.frameCount)throw new Error("No models found.");const s=Qp(o);return new pe.Molecule.Trajectory(o,s)});return function(r){return n.apply(this,arguments)}}())}),EXe=Rt.BuiltIn({name:"trajectory-from-pdb",display:{name:"Parse PDB",description:"Parse PDB string and create trajectory."},from:[pe.Data.String],to:pe.Molecule.Trajectory,params:{isPdbqt:C.Boolean(!1)}})({apply:({a:e,params:t})=>Oe.create("Parse PDB",function(){var n=ie(function*(r){const i=yield function Zze(e,t,n=!1){return Oe.create("Parse PDB",function(){var r=ie(function*(i){return Fr.success({lines:yield ht.readAllLinesAsync(e,i),id:t,isPdbqt:n})});return function(i){return r.apply(this,arguments)}}())}(e.data,e.label,t.isPdbqt).runInContext(r);if(i.isError)throw new Error(i.message);const o=yield function fWe(e){return Oe.create("Parse PDB",function(){var t=ie(function*(n){var r;yield n.update("Converting to mmCIF");const i=yield function dWe(e){return B5.apply(this,arguments)}(e),o=Er.fromFrame(i,void 0,O5.create(e)),s=$u(o.data.db,!0),a=yield af(s,o,n),c=null===(r=i.categories.atom_site)||void 0===r?void 0:r.getField("partial_charge");if(c&&1===a.frameCount){const u=a.representative,l=u.atomicHierarchy.atomSourceIndex,f=te.isIdentity(l)?void 0:l.toArray({array:Int32Array}),p=c.toFloatArray(),m=te.ofFloatArray(f?te.mapToArray(l,h=>p[h],Float32Array):p);Mv.Provider.set(u,{data:m,type:"GASTEIGER"})}return a});return function(n){return t.apply(this,arguments)}}())}(i.result).runInContext(r),s=Qp(o);return new pe.Molecule.Trajectory(o,s)});return function(r){return n.apply(this,arguments)}}())}),PXe=Rt.BuiltIn({name:"trajectory-from-gro",display:{name:"Parse GRO",description:"Parse GRO string and create trajectory."},from:[pe.Data.String],to:pe.Molecule.Trajectory})({apply:({a:e})=>Oe.create("Parse GRO",function(){var t=ie(function*(n){const r=yield function Kze(e){return Oe.create("Parse GRO",function(){var t=ie(function*(n){return yield function Xze(e,t){return jL.apply(this,arguments)}(e,n)});return function(n){return t.apply(this,arguments)}}())}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function $qe(e){return Oe.create("Parse GRO",function(){var t=ie(function*(n){const r=F5.fromGro(e),i=[];for(let o=0,s=e.structures.length;oOe.create("Parse XYZ",function(){var t=ie(function*(n){const r=yield function OYe(e){return Oe.create("Parse Mol",ie(function*(){return function BYe(e){const t=ht(e),n=[];for(;;){const i=FYe(t);if(0===i.count)break;n.push(i)}return Fr.success({molecules:n})}(e)}))}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function UYe(e){return Oe.create("Parse XYZ",t=>function LYe(e,t){const{molecules:n}=e;let r=0;for(const x of n)r+=x.count;const i=new Array(r),o=new Int32Array(r),s=new Float32Array(r),a=new Float32Array(r),c=new Float32Array(r),u=new Int32Array(r);let l=0;for(let x=0;xOe.create("Parse MOL",function(){var t=ie(function*(n){const r=yield function lYe(e){return Oe.create("Parse Mol",ie(function*(){return function uYe(e){const t=ht(e),n=ht.readLine(t).trim(),r=ht.readLine(t).trim(),i=ht.readLine(t).trim(),o=ht.readLine(t),s=+o.substr(0,3),a=+o.substr(3,3),c=koe(t,s),u=Noe(t,a),l=Foe(t);return Fr.success({title:n,program:r,comment:i,atoms:c,bonds:u,formalCharges:l})}(e)}))}(e.data).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function dYe(e){return Oe.create("Parse MOL",t=>Boe(e,void 0,t))}(r.result).runInContext(n),o=Qp(i);return new pe.Molecule.Trajectory(i,o)});return function(n){return t.apply(this,arguments)}}())}),kXe=Rt.BuiltIn({name:"trajectory-from-sdf",display:{name:"Parse SDF",description:"Parse SDF string and create trajectory."},from:[pe.Data.String],to:pe.Molecule.Trajectory})({apply:({a:e})=>Oe.create("Parse SDF",function(){var t=ie(function*(n){const r=yield function YYe(e){return Oe.create("Parse Sdf",ie(function*(){return function $Ye(e){const t=ht(e),n=[];for(;t.positionOe.create("Parse MOL2",function(){var t=ie(function*(n){const r=yield function TYe(e,t){return Oe.create("Parse MOL2",function(){var n=ie(function*(r){return yield function IYe(e,t,n){return u6.apply(this,arguments)}(r,e,t)});return function(r){return n.apply(this,arguments)}}())}(e.data,e.label).runInContext(n);if(r.isError)throw new Error(r.message);const i=yield function PYe(e){return Oe.create("Parse MOL2",t=>function DYe(e,t){return l6.apply(this,arguments)}(e,t))}(r.result).runInContext(n),o=Qp(i);return new pe.Molecule.Trajectory(i,o)});return function(n){return t.apply(this,arguments)}}())}),FXe=Rt.BuiltIn({name:"trajectory-from-cube",display:{name:"Parse Cube",description:"Parse Cube file to create a trajectory."},from:pe.Format.Cube,to:pe.Molecule.Trajectory})({apply:({a:e})=>Oe.create("Parse MOL",function(){var t=ie(function*(n){const r=yield function vYe(e){return Oe.create("Parse Cube",t=>function bYe(e,t){return i6.apply(this,arguments)}(e,t))}(e.data).runInContext(n),i=Qp(r);return new pe.Molecule.Trajectory(r,i)});return function(n){return t.apply(this,arguments)}}())}),BXe=Rt.BuiltIn({name:"trajectory-from-cif-core",display:{name:"Parse CIF Core",description:"Identify and create all separate models in the specified CIF data block"},from:pe.Format.Cif,to:pe.Molecule.Trajectory,params(e){if(!e)return{blockHeader:C.Optional(C.Text(void 0,{description:"Header of the block to parse. If none is specifed, the 1st data block in the file is used."}))};const{blocks:t}=e.data;return{blockHeader:C.Optional(C.Select(t[0]&&t[0].header,t.map(n=>[n.header,n.header]),{description:"Header of the block to parse"}))}}})({apply:({a:e,params:t})=>Oe.create("Parse CIF Core",function(){var n=ie(function*(r){const i=t.blockHeader||e.data.blocks[0].header,o=e.data.blocks.find(c=>c.header===i);if(!o)throw new Error(`Data block '${[i]}' not found.`);const s=yield function yYe(e){const t=DS.fromFrame(e);return Oe.create("Parse CIF Core",n=>function hYe(e,t,n){return r6.apply(this,arguments)}(t.data.db,t,n))}(o).runInContext(r);if(0===s.frameCount)throw new Error("No models found.");const a=Qp(s);return new pe.Molecule.Trajectory(s,a)});return function(r){return n.apply(this,arguments)}}())}),OXe=e=>e+1,LXe=e=>e-1,qoe=Rt.BuiltIn({name:"model-from-trajectory",display:{name:"Molecular Model",description:"Create a molecular model from specified index in a trajectory."},from:pe.Molecule.Trajectory,to:pe.Molecule.Model,params:e=>e?{modelIndex:C.Converted(OXe,LXe,C.Numeric(1,{min:1,max:e.data.frameCount,step:1},{description:"Model Index",immediateUpdate:!0}))}:{modelIndex:C.Numeric(0,{},{description:"Zero-based index of the model",immediateUpdate:!0})}})({isApplicable:e=>e.data.frameCount>0,apply:({a:e,params:t})=>Oe.create("Model from Trajectory",function(){var n=ie(function*(r){let i=t.modelIndex%e.data.frameCount;i<0&&(i+=e.data.frameCount);const o=yield Oe.resolveInContext(e.data.getFrameAtIndex(i),r);return new pe.Molecule.Model(o,{label:`Model ${i+1}`,description:1===e.data.frameCount?void 0:`of ${e.data.frameCount}`})});return function(r){return n.apply(this,arguments)}}()),interpolate:(e,t,n)=>({modelIndex:n>=1?t.modelIndex:e.modelIndex+Math.floor((t.modelIndex-e.modelIndex+1)*n)}),dispose({b:e}){e?.data.customProperties.dispose()}}),UXe=Rt.BuiltIn({name:"structure-from-trajectory",display:{name:"Structure from Trajectory",description:"Create a molecular structure from a trajectory."},from:pe.Molecule.Trajectory,to:pe.Molecule.Structure})({apply:({a:e})=>Oe.create("Build Structure",function(){var t=ie(function*(n){const r=yield Ve.ofTrajectory(e.data,n),i={label:"Ensemble",description:Ve.elementDescription(r)};return new pe.Molecule.Structure(r,i)});return function(n){return t.apply(this,arguments)}}()),dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),VXe=Rt.BuiltIn({name:"structure-from-model",display:{name:"Structure",description:"Create a molecular structure (model, assembly, or symmetry) from the specified model."},from:pe.Molecule.Model,to:pe.Molecule.Structure,params:e=>b0.getParams(e&&e.data)})({canAutoUpdate:({oldParams:e,newParams:t})=>b0.canAutoUpdate(e.type,t.type),apply:({a:e,params:t},n)=>Oe.create("Build Structure",function(){var r=ie(function*(i){return b0.create(n,i,e.data,t&&t.type)});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,oldParams:n,newParams:r})=>Yd(n,r)?t.data.model===e.data?Qe.UpdateResult.Unchanged:sn.areHierarchiesEqual(e.data,t.data.model)?(t.data=t.data.remapModel(e.data),Qe.UpdateResult.Updated):Qe.UpdateResult.Recreate:Qe.UpdateResult.Recreate,dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),Woe=v(),$oe=le(),Yoe=le(),zXe=Rt.BuiltIn({name:"transform-structure-conformation",display:{name:"Transform Conformation"},isDecorator:!0,from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:{transform:C.MappedStatic("components",{components:C.Group({axis:C.Vec3(v.create(1,0,0)),angle:C.Numeric(0,{min:-180,max:180,step:.1}),translation:C.Vec3(v.create(0,0,0))},{isFlat:!0}),matrix:C.Group({data:C.Mat4(le.identity()),transpose:C.Boolean(!1)},{isFlat:!0})},{label:"Kind"})}})({canAutoUpdate:({newParams:e})=>"matrix"!==e.transform.name,apply({a:e,params:t}){const n=le();if("components"===t.transform.name){const{axis:i,angle:o,translation:s}=t.transform.params,a=e.data.boundary.sphere.center;le.fromTranslation($oe,v.negate(Woe,a)),le.fromTranslation(Yoe,v.add(Woe,a,s));const c=le.fromRotation(le(),Math.PI/180*o,v.normalize(v(),i));le.mul3(n,Yoe,c,$oe)}else"matrix"===t.transform.name&&(le.copy(n,t.transform.params.data),t.transform.params.transpose&&le.transpose(n,n));const r=Ve.transform(e.data,n);return new pe.Molecule.Structure(r,{label:e.label,description:`${e.description} [Transformed]`})},dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),GXe=Rt.BuiltIn({name:"structure-selection-from-expression",display:{name:"Selection",description:"Create a molecular structure from the specified expression."},from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:()=>({expression:C.Value(ue.struct.generator.all,{isHidden:!0}),label:C.Optional(C.Text("",{isHidden:!0}))})})({apply({a:e,params:t,cache:n}){const{selection:r,entry:i}=Aa.createAndRun(e.data,t.expression);if(n.entry=i,pt.isEmpty(r))return li.Null;const o=pt.unionStructure(r),s={label:`${t.label||"Selection"}`,description:Ve.elementDescription(o)};return new pe.Molecule.Structure(o,s)},update:({a:e,b:t,oldParams:n,newParams:r,cache:i})=>{if(n.expression!==r.expression)return Qe.UpdateResult.Recreate;const o=i.entry;if(o.currentStructure===e.data)return Qe.UpdateResult.Unchanged;const s=Aa.updateStructure(o,e.data);return pt.isEmpty(s)?Qe.UpdateResult.Null:(Aa.updateStructureObject(t,s,r.label),Qe.UpdateResult.Updated)},dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),jXe=Rt.BuiltIn({name:"structure-multi-selection-from-expression",display:{name:"Multi-structure Measurement Selection",description:"Create selection object from multiple structures."},from:pe.Root,to:pe.Molecule.Structure.Selections,params:()=>({selections:C.ObjectList({key:C.Text(void 0,{description:"A unique key."}),ref:C.Text(),groupId:C.Optional(C.Text()),expression:C.Value(ue.struct.generator.empty)},e=>e.ref,{isHidden:!0}),isTransitive:C.Optional(C.Boolean(!1,{isHidden:!0,description:"Remap the selections from the original structure if structurally equivalent."})),label:C.Optional(C.Text("",{isHidden:!0}))})})({apply({params:e,cache:t,dependencies:n}){const r=new Map,i=[];let o=0;for(const a of e.selections){const{selection:c,entry:u}=Aa.createAndRun(n[a.ref].data,a.expression);r.set(a.key,u);const l=pt.toLociWithSourceUnits(c);i.push({key:a.key,loci:l,groupId:a.groupId}),o+=De.size(l)}return t.entries=r,new pe.Molecule.Structure.Selections(i,{label:`${e.label||"Multi-selection"}`,description:`${e.selections.length} source(s), ${o} element(s) total`})},update:({b:e,oldParams:t,newParams:n,cache:r,dependencies:i})=>{if(!!t.isTransitive!=!!n.isTransitive)return Qe.UpdateResult.Recreate;const o=r.entries,s=new Map,a=new Map;for(const d of e.data)a.set(d.key,d);let c=!1,u=0;const l=[];for(const d of n.selections){const f=i[d.ref].data;let p=!1;if(o.has(d.key)){const m=o.get(d.key);if(Aa.isUnchanged(m,d.expression,f)&&a.has(d.key)){const h=a.get(d.key);h.groupId!==d.groupId&&(h.groupId=d.groupId,c=!0),s.set(d.key,m),l.push(h),u+=De.size(h.loci);continue}if(m.expression!==d.expression)p=!0;else{let h=!1;if(n.isTransitive)if(Ve.areUnitIdsAndIndicesEqual(m.originalStructure,f)){const g=Aa.run(m,m.originalStructure);m.currentStructure=f,s.set(d.key,m);const y=De.remap(pt.toLociWithSourceUnits(g),f);l.push({key:d.key,loci:y,groupId:d.groupId}),u+=De.size(y),c=!0}else h=!0;else h=!0;if(h){c=!0;const g=Aa.updateStructure(m,f);s.set(d.key,m);const y=pt.toLociWithSourceUnits(g);l.push({key:d.key,loci:y,groupId:d.groupId}),u+=De.size(y)}}}else p=!0;if(p){c=!0;const{selection:m,entry:h}=Aa.createAndRun(f,d.expression);s.set(d.key,h);const g=pt.toLociWithSourceUnits(m);l.push({key:d.key,loci:g}),u+=De.size(g)}}return c?(r.entries=s,e.data=l,e.label=`${n.label||"Multi-selection"}`,e.description=`${l.length} source(s), ${u} element(s) total`,Qe.UpdateResult.Updated):Qe.UpdateResult.Unchanged}}),HXe=Rt.BuiltIn({name:"structure-selection-from-script",display:{name:"Selection",description:"Create a molecular structure from the specified script."},from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:()=>({script:C.Script({language:"mol-script",expression:"(sel.atom.atom-groups :residue-test (= atom.resname ALA))"}),label:C.Optional(C.Text(""))})})({apply({a:e,params:t,cache:n}){const{selection:r,entry:i}=Aa.createAndRun(e.data,t.script);n.entry=i;const o=pt.unionStructure(r),s={label:`${t.label||"Selection"}`,description:Ve.elementDescription(o)};return new pe.Molecule.Structure(o,s)},update:({a:e,b:t,oldParams:n,newParams:r,cache:i})=>{if(!ko.areEqual(n.script,r.script))return Qe.UpdateResult.Recreate;const o=i.entry;if(o.currentStructure===e.data)return Qe.UpdateResult.Unchanged;const s=Aa.updateStructure(o,e.data);return Aa.updateStructureObject(t,s,r.label),Qe.UpdateResult.Updated},dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),qXe=Rt.BuiltIn({name:"structure-selection-from-bundle",display:{name:"Selection",description:"Create a molecular structure from the specified structure-element bundle."},from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:()=>({bundle:C.Value(Kn.Empty,{isHidden:!0}),label:C.Optional(C.Text("",{isHidden:!0}))})})({apply({a:e,params:t,cache:n}){if(t.bundle.hash!==e.data.hashCode)return li.Null;n.source=e.data;const r=Kn.toStructure(t.bundle,e.data);if(0===r.elementCount)return li.Null;const i={label:`${t.label||"Selection"}`,description:Ve.elementDescription(r)};return new pe.Molecule.Structure(r,i)},update:({a:e,b:t,oldParams:n,newParams:r,cache:i})=>{if(!Kn.areEqual(n.bundle,r.bundle))return Qe.UpdateResult.Recreate;if(r.bundle.hash!==e.data.hashCode)return Qe.UpdateResult.Null;if(i.source===e.data)return Qe.UpdateResult.Unchanged;i.source=e.data;const o=Kn.toStructure(r.bundle,e.data);return 0===o.elementCount?Qe.UpdateResult.Null:(t.label=`${r.label||"Selection"}`,t.description=Ve.elementDescription(o),t.data=o,Qe.UpdateResult.Updated)},dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),Xoe={polymer:"polymer",protein:"protein",nucleic:"nucleic",water:"water",branched:"branched",ligand:"ligand","non-standard":"non-standard",coarse:"coarse","atomic-sequence":"atomic-sequence","atomic-het":"atomic-het",spheres:"spheres"},WXe=C.objectToOptions(Xoe),$Xe=Rt.BuiltIn({name:"structure-complex-element",display:{name:"Complex Element",description:"Create a molecular structure from the specified model."},from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:{type:C.Select("atomic-sequence",WXe,{isHidden:!0})}})({apply({a:e,params:t}){let n,r;switch(t.type){case"polymer":n=No.polymer.query,r="Polymer";break;case"protein":n=No.protein.query,r="Protein";break;case"nucleic":n=No.nucleic.query,r="Nucleic";break;case"water":n=Sr.internal.water(),r="Water";break;case"branched":n=No.branchedPlusConnected.query,r="Branched";break;case"ligand":n=No.ligandPlusConnected.query,r="Ligand";break;case"non-standard":n=No.nonStandardPolymer.query,r="Non-standard";break;case"coarse":n=No.coarse.query,r="Coarse";break;case"atomic-sequence":n=Sr.internal.atomicSequence(),r="Sequence";break;case"atomic-het":n=Sr.internal.atomicHet(),r="HET Groups/Ligands";break;case"spheres":n=Sr.internal.spheres(),r="Coarse Spheres";break;default:Rr()}const i=n(new qu(e.data)),o=pt.unionStructure(i);return 0===o.elementCount?li.Null:new pe.Molecule.Structure(o,{label:r,description:Ve.elementDescription(o)})},dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),YXe=Rt.BuiltIn({name:"structure-component",display:{name:"Component",description:"A molecular structure component."},from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:()=>({type:C.MappedStatic("static",{static:C.Text("polymer"),expression:C.Value(ue.struct.generator.all),bundle:C.Value(Kn.Empty),script:C.Script({language:"mol-script",expression:"(sel.atom.all)"})},{isHidden:!0}),nullIfEmpty:C.Optional(C.Boolean(!0,{isHidden:!0})),label:C.Text("",{isHidden:!0})})})({apply:({a:e,params:t,cache:n})=>function oYe(e,t,n){n.source=e;let i,r=Ve.Empty;switch(t.type.name){case"static":{let s;switch(t.type.params){case"all":s=No.all.query,i="All";break;case"polymer":s=No.polymer.query,i="Polymer";break;case"protein":s=No.protein.query,i="Protein";break;case"nucleic":s=No.nucleic.query,i="Nucleic";break;case"water":s=Sr.internal.water(),i="Water";break;case"ion":s=No.ion.query,i="Ion";break;case"lipid":s=No.lipid.query,i="Lipid";break;case"branched":s=No.branchedPlusConnected.query,i="Branched";break;case"ligand":s=No.ligandPlusConnected.query,i="Ligand";break;case"non-standard":s=No.nonStandardPolymer.query,i="Non-standard";break;case"coarse":s=No.coarse.query,i="Coarse";break;default:Rr()}const a=s(new qu(e));r=pt.unionStructure(a);break}case"script":case"expression":{const{selection:s,entry:a}=Aa.createAndRun(e,t.type.params);n.entry=a,r=pt.unionStructure(s);break}case"bundle":if(t.type.params.hash!==e.hashCode)break;r=Kn.toStructure(t.type.params,e)}if(t.nullIfEmpty&&0===r.elementCount)return li.Null;const o={label:`${t.label||i||"Component"}`,description:Ve.elementDescription(r)};return new pe.Molecule.Structure(r,o)}(e.data,t,n),update:({a:e,b:t,oldParams:n,newParams:r,cache:i})=>function sYe(e,t,n,r,i){if(n.type.name!==r.type.name)return Qe.UpdateResult.Recreate;let o=!1;switch(r.type.name){case"static":return n.type.params===r.type.params&&Ve.areEquivalent(e,i.source)?t.data.model===e.model?Qe.UpdateResult.Unchanged:sn.areHierarchiesEqual(e.model,t.data.model)?(t.data=t.data.remapModel(e.model),Qe.UpdateResult.Updated):Qe.UpdateResult.Recreate:Qe.UpdateResult.Recreate;case"script":if(!ko.areEqual(n.type.params,r.type.params))return Qe.UpdateResult.Recreate;case"expression":{if(n.type.params!==r.type.params)return Qe.UpdateResult.Recreate;if(e===i.source)break;const a=Aa.updateStructure(i.entry,e);i.source=e,t.data=pt.unionStructure(a),Aa.updateStructureObject(t,a,r.label),o=!0;break}case"bundle":if(e===i.source&&Kn.areEqual(n.type.params,r.type.params))break;i.source=e,r.type.params.hash!==e.hashCode?(o=0!==t.data.elementCount,t.data=0===t.data.elementCount?t.data:Ve.Empty):(o=!0,t.data=Kn.toStructure(r.type.params,e))}if(o){if(r.nullIfEmpty&&0===t.data.elementCount)return Qe.UpdateResult.Null;t.description=Ve.elementDescription(t.data)}return n.label!==r.label&&(o=!0,t.label=`${r.label||t.label}`),o?Qe.UpdateResult.Updated:Qe.UpdateResult.Unchanged}(e.data,t,n,r,i),dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}}),Koe=Rt.BuiltIn({name:"custom-model-properties",display:{name:"Custom Model Properties"},isDecorator:!0,from:pe.Molecule.Model,to:pe.Molecule.Model,params:(e,t)=>t.customModelProperties.getParams(e?.data)})({apply:({a:e,params:t},n)=>Oe.create("Custom Props",function(){var r=ie(function*(i){return yield Zoe(e.data,n,i,t),new pe.Molecule.Model(e.data,{label:e.label,description:e.description})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,oldParams:n,newParams:r},i)=>Oe.create("Custom Props",function(){var o=ie(function*(s){t.data=e.data,t.label=e.label,t.description=e.description;for(const a of n.autoAttach){const c=i.customModelProperties.get(a);c&&e.data.customProperties.reference(c.descriptor,!1)}return yield Zoe(e.data,i,s,r),Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}()),dispose({b:e}){e?.data.customProperties.dispose()}});function Zoe(e,t,n,r){return I6.apply(this,arguments)}function I6(){return I6=ie(function*(e,t,n,r){const i={runtime:n,assetManager:t.managers.asset},{autoAttach:o,properties:s}=r;for(const a of Object.keys(s)){const c=t.customModelProperties.get(a),u=s[a];if(o.includes(a)||c.isHidden)try{yield c.attach(i,e,u,!0)}catch(l){t.log.warn(`Error attaching model prop '${a}': ${l}`)}else c.set(e,u)}}),I6.apply(this,arguments)}const Qoe=Rt.BuiltIn({name:"custom-structure-properties",display:{name:"Custom Structure Properties"},isDecorator:!0,from:pe.Molecule.Structure,to:pe.Molecule.Structure,params:(e,t)=>t.customStructureProperties.getParams(e?.data.root)})({apply:({a:e,params:t},n)=>Oe.create("Custom Props",function(){var r=ie(function*(i){return yield Joe(e.data.root,n,i,t),new pe.Molecule.Structure(e.data,{label:e.label,description:e.description})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,oldParams:n,newParams:r},i)=>e.data!==t.data?Qe.UpdateResult.Recreate:Oe.create("Custom Props",function(){var o=ie(function*(s){t.data=e.data,t.label=e.label,t.description=e.description;for(const a of n.autoAttach){const c=i.customStructureProperties.get(a);c&&e.data.customPropertyDescriptors.reference(c.descriptor,!1)}return yield Joe(e.data.root,i,s,r),Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}()),dispose({b:e}){e?.data.customPropertyDescriptors.dispose()}});function Joe(e,t,n,r){return T6.apply(this,arguments)}function T6(){return T6=ie(function*(e,t,n,r){const i={runtime:n,assetManager:t.managers.asset},{autoAttach:o,properties:s}=r;for(const a of Object.keys(s)){const c=t.customStructureProperties.get(a),u=s[a];if(o.includes(a)||c.isHidden)try{yield c.attach(i,e,u,!0)}catch(l){t.log.warn(`Error attaching structure prop '${a}': ${l}`)}else c.set(e,u)}}),T6.apply(this,arguments)}const XXe=Rt.BuiltIn({name:"shape-from-ply",display:{name:"Shape from PLY",description:"Create Shape from PLY data"},from:pe.Format.Ply,to:pe.Shape.Provider,params:e=>({transforms:C.Optional(C.Value([],{isHidden:!0})),label:C.Optional(C.Text("",{isHidden:!0}))})})({apply:({a:e,params:t})=>Oe.create("Create shape from PLY",function(){var n=ie(function*(r){const i=yield function Uqe(e,t){return Oe.create("Shape Provider",function(){var n=ie(function*(r){return{label:"Mesh",data:{source:e,transforms:t?.transforms},params:Kie(e),getShape:Lqe(),geometryUtils:Nt.Utils}});return function(r){return n.apply(this,arguments)}}())}(e.data,t).runInContext(r);return new pe.Shape.Provider(i,{label:t.label||"Shape"})});return function(r){return n.apply(this,arguments)}}())});var D6,E6,P6,M6;!function(e){e.is=function t(r){return"ccp4"===r?.kind},e.create=function n(r){return{kind:"ccp4",name:r.name,data:r}}}(D6||(D6={})),function(e){e.is=function t(r){return"dsn6"===r?.kind},e.create=function n(r){return{kind:"dsn6",name:r.name,data:r}}}(E6||(E6={})),function(e){e.is=function t(r){return"dx"===r?.kind},e.create=function n(r){return{kind:"dx",name:r.name,data:r}}}(P6||(P6={})),function(e){e.is=function t(r){return"segcif"===r?.kind},e.create=function n(r){return{kind:"segcif",name:r._name,data:r}}}(M6||(M6={}));const nKe=Rt.BuiltIn({name:"volume-from-ccp4",display:{name:"Volume from CCP4/MRC/MAP",description:"Create Volume from CCP4/MRC/MAP data"},from:pe.Format.Ccp4,to:pe.Volume.Data,params:e=>({voxelSize:C.Vec3(v.create(1,1,1)),offset:C.Vec3(v.create(0,0,0)),entryId:C.Text("")})})({apply:({a:e,params:t})=>Oe.create("Create volume from CCP4/MRC/MAP",function(){var n=ie(function*(r){const i=yield function QXe(e,t){return Oe.create("Create Volume",function(){var n=ie(function*(r){const{header:i,values:o}=e,s=v.create(i.xLength,i.yLength,i.zLength);t&&t.voxelSize&&v.mul(s,s,t.voxelSize);const a=v.create(Yn(i.alpha),Yn(i.beta),Yn(i.gamma)),u=ma.create((i.ISPG>65536?0:i.ISPG)||"P 1",s,a),l=v.create(i.MAPC-1,i.MAPR-1,i.MAPS-1),d=wn.convertToCanonicalAxisIndicesFastToSlow(l),f=[i.NX,i.NY,i.NZ],p=d([i.NC,i.NR,i.NS]),m=function KXe(e){return 0===e.originX&&0===e.originY&&0===e.originZ?v.create(e.NCSTART,e.NRSTART,e.NSSTART):v.create(e.originX/(e.xLength/e.NX),e.originY/(e.yLength/e.NY),e.originZ/(e.zLength/e.NZ))}(i);t?.offset&&v.add(m,m,t.offset);const h=d(m),g=v.create(h[0]/f[0],h[1]/f[1],h[2]/f[2]),y=v.create(p[0]/f[0],p[1]/f[1],p[2]/f[2]),b=wn.Space(p,wn.invertAxisOrder(l),function ZXe(e){const t=vte(e);switch(t){case us.Float32:return Float32Array;case us.Int8:return Int8Array;case us.Int16:return Int16Array;case us.Uint16:return Uint16Array}throw Error(`${t} is not a supported value format.`)}(i)),x=wn.create(b,wn.Data1(o)),_=0===i.AMIN&&0===i.AMAX&&0===i.AMEAN&&0===i.ARMS;return{label:t?.label,entryId:t?.entryId,grid:{transform:{kind:"spacegroup",cell:u,fractionalBox:St.create(g,v.add(v.zero(),g,y))},cells:x,stats:{min:isNaN(i.AMIN)||_?LI(o):i.AMIN,max:isNaN(i.AMAX)||_?Xd(o):i.AMAX,mean:isNaN(i.AMEAN)||_?UI(o):i.AMEAN,sigma:isNaN(i.ARMS)||0===i.ARMS?VI(o):i.ARMS}},sourceData:D6.create(e),customProperties:new Ql,_propertyData:Object.create(null)}});return function(r){return n.apply(this,arguments)}}())}(e.data,{...t,label:e.data.name||e.label}).runInContext(r);return new pe.Volume.Data(i,{label:i.label||"Volume",description:`Volume ${e.data.header.NX}\xd7${e.data.header.NX}\xd7${e.data.header.NX}`})});return function(r){return n.apply(this,arguments)}}()),dispose({b:e}){e?.data.customProperties.dispose()}}),rKe=Rt.BuiltIn({name:"volume-from-dsn6",display:{name:"Volume from DSN6/BRIX",description:"Create Volume from DSN6/BRIX data"},from:pe.Format.Dsn6,to:pe.Volume.Data,params:e=>({voxelSize:C.Vec3(v.create(1,1,1)),entryId:C.Text("")})})({apply:({a:e,params:t})=>Oe.create("Create volume from DSN6/BRIX",function(){var n=ie(function*(r){const i=yield function JXe(e,t){return Oe.create("Create Volume",function(){var n=ie(function*(r){const{header:i,values:o}=e,s=v.create(i.xlen,i.ylen,i.zlen);t&&t.voxelSize&&v.mul(s,s,t.voxelSize);const a=v.create(Yn(i.alpha),Yn(i.beta),Yn(i.gamma)),c=ma.create("P 1",s,a),u=[i.xRate,i.yRate,i.zRate],l=[i.xExtent,i.yExtent,i.zExtent],d=[i.xStart,i.yStart,i.zStart],f=v.create(d[0]/u[0],d[1]/u[1],d[2]/u[2]),p=v.create(l[0]/u[0],l[1]/u[1],l[2]/u[2]),m=wn.Space(l,[0,1,2],Float32Array),h=wn.create(m,wn.Data1(o));return{label:t?.label,entryId:t?.entryId,grid:{transform:{kind:"spacegroup",cell:c,fractionalBox:St.create(f,v.add(v.zero(),f,p))},cells:h,stats:{min:LI(o),max:Xd(o),mean:UI(o),sigma:void 0!==i.sigma?i.sigma:VI(o)}},sourceData:E6.create(e),customProperties:new Ql,_propertyData:Object.create(null)}});return function(r){return n.apply(this,arguments)}}())}(e.data,{...t,label:e.data.name||e.label}).runInContext(r);return new pe.Volume.Data(i,{label:i.label||"Volume",description:`Volume ${e.data.header.xExtent}\xd7${e.data.header.yExtent}\xd7${e.data.header.zExtent}`})});return function(r){return n.apply(this,arguments)}}()),dispose({b:e}){e?.data.customProperties.dispose()}}),iKe=Rt.BuiltIn({name:"volume-from-cube",display:{name:"Volume from Cube",description:"Create Volume from Cube data"},from:pe.Format.Cube,to:pe.Volume.Data,params:e=>({dataIndex:e?C.Select(0,e.data.header.dataSetIds.map((n,r)=>[r,`${n}`])):C.Numeric(0),entryId:C.Text("")})})({apply:({a:e,params:t})=>Oe.create("Create volume from Cube",function(){var n=ie(function*(r){const i=yield function OHe(e,t){return Oe.create("Create Volume",ie(function*(){const{header:n,values:r}=e,i=wn.Space(n.dim,[0,1,2],Float64Array);let o;if(0===n.dataSetIds.length)o=r;else{const[u,l,d]=n.dim,f=(t?.dataIndex||0)+1;let p=0,m=0;o=new Float64Array(u*l*d);for(let h=0;hOe.create("Parse DX",function(){var t=ie(function*(n){const r=yield function eKe(e,t){return Oe.create("Create Volume",ie(function*(){const{header:n,values:r}=e,i=wn.Space(n.dim,[0,1,2],Float64Array),o=wn.create(i,wn.Data1(r)),s=le.fromTranslation(le(),n.min),a=le.fromScaling(le(),n.h);return le.mul(s,s,a),{label:t?.label,entryId:t?.entryId,grid:{transform:{kind:"matrix",matrix:s},cells:o,stats:{min:LI(r),max:Xd(r),mean:UI(r),sigma:VI(r)}},sourceData:P6.create(e),customProperties:new Ql,_propertyData:Object.create(null)}}))}(e.data,{label:e.data.name||e.label}).runInContext(n);return new pe.Volume.Data(r,{label:r.label||"Volume",description:`Volume ${e.data.header.dim[0]}\xd7${e.data.header.dim[1]}\xd7${e.data.header.dim[2]}`})});return function(n){return t.apply(this,arguments)}}()),dispose({b:e}){e?.data.customProperties.dispose()}}),sKe=Rt.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:pe.Format.Cif,to:pe.Volume.Data,params(e){if(!e)return{blockHeader:C.Optional(C.Text(void 0,{description:"Header of the block to parse. If none is specifed, the 1st data block in the file is used."})),entryId:C.Text("")};const t=e.data.blocks.slice(1);return{blockHeader:C.Optional(C.Select(t[0]&&t[0].header,t.map(n=>[n.header,n.header]),{description:"Header of the block to parse"})),entryId:C.Text("")}}})({isApplicable:e=>e.data.blocks.length>0,apply:({a:e,params:t})=>Oe.create("Parse density-server CIF",function(){var n=ie(function*(r){var i;const o=t.blockHeader||e.data.blocks[1].header,s=e.data.blocks.find(p=>p.header===o);if(!s)throw new Error(`Data block '${[o]}' not found.`);const a=od.schema.densityServer(s),c=yield jie(a,{entryId:t.entryId}).runInContext(r),[u,l,d]=c.grid.cells.space.dimensions,f={label:null!==(i=t.entryId)&&void 0!==i?i:a.volume_data_3d_info.name.value(0),description:`Volume ${u}\xd7${l}\xd7${d}`};return new pe.Volume.Data(c,f)});return function(r){return n.apply(this,arguments)}}()),dispose({b:e}){e?.data.customProperties.dispose()}}),aKe=Rt.BuiltIn({name:"volume-from-segmentation-cif",display:{name:"Volume from Segmentation CIF"},from:pe.Format.Cif,to:pe.Volume.Data,params(e){const t=e?.data.blocks.slice(1);return{blockHeader:C.Optional(t?C.Select(t[0]&&t[0].header,t.map(r=>[r.header,r.header]),{description:"Header of the block to parse"}):C.Text(void 0,{description:"Header of the block to parse. If none is specifed, the 1st data block in the file is used."})),segmentLabels:C.ObjectList({id:C.Numeric(-1),label:C.Text("")},r=>`${r.id} = ${r.label}`,{description:"Mapping of segment IDs to segment labels"}),ownerId:C.Text("",{isHidden:!0,description:"Reference to the object which manages this volume"})}}})({isApplicable:e=>e.data.blocks.length>0,apply:({a:e,params:t})=>Oe.create("Parse segmentation CIF",function(){var n=ie(function*(r){const i=t.blockHeader||e.data.blocks[1].header,o=e.data.blocks.find(p=>p.header===i);if(!o)throw new Error(`Data block '${[i]}' not found.`);const s=od.schema.segmentation(o),a={};for(const p of t.segmentLabels)a[p.id]=p.label;const c=yield function tKe(e,t){return Oe.create("Create Segmentation Volume",function(){var n=ie(function*(r){var i;const{volume_data_3d_info:o,segmentation_data_3d:s}=e,a=ma.create(o.spacegroup_number.value(0),v.ofArray(o.spacegroup_cell_size.value(0)),v.scale(v(),v.ofArray(o.spacegroup_cell_angles.value(0)),Math.PI/180)),c=o.axis_order.value(0),u=wn.convertToCanonicalAxisIndicesFastToSlow(c),l=u(o.sample_count.value(0)),d=wn.Space(l,wn.invertAxisOrder(c),Float32Array),f=wn.create(d,wn.Data1(s.values.toArray({array:Float32Array}))),p=v.ofArray(u(o.origin.value(0))),m=v.ofArray(u(o.dimensions.value(0))),h={label:t?.label,entryId:void 0,grid:{transform:{kind:"spacegroup",cell:a,fractionalBox:St.create(p,v.add(v(),p,m))},cells:f,stats:{min:0,max:1,mean:0,sigma:1}},sourceData:M6.create(e),customProperties:new Ql,_propertyData:{ownerId:t?.ownerId}};et.PickingGranularity.set(h,"object");const g=new Map,y=new Map,{segment_id:b,set_id:x}=e.segmentation_data_table;for(let V=0,F=b.rowCount;V{V.forEach(G=>{g.has(G)||g.set(G,new Set),g.get(G).add(F)})});const _=[0,0,0],S=f.space.getCoords,A=f.data,[E,w,D]=h.grid.cells.space.dimensions,I=E-1,R=w-1,T=D-1,M={};y.forEach((V,F)=>{M[F]=[I,R,T,-1,-1,-1]});for(let V=0,F=A.length;VL[3]&&(L[3]=_[0]),_[1]>L[4]&&(L[4]=_[1]),_[2]>L[5]&&(L[5]=_[2])}const N={};return g.forEach((V,F)=>{N[F]=St.create(v.create(I,R,T),v.create(-1,-1,-1))}),$a(M,(V,F)=>{y.get(parseInt(F)).forEach(G=>{const L=N[G];V[0]L.max[0]&&(L.max[0]=V[3]),V[4]>L.max[1]&&(L.max[1]=V[4]),V[5]>L.max[2]&&(L.max[2]=V[5])})}),et.Segmentation.set(h,{segments:g,sets:y,bounds:N,labels:null!==(i=t?.segmentLabels)&&void 0!==i?i:{}}),h});return function(r){return n.apply(this,arguments)}}())}(s,{segmentLabels:a,ownerId:t.ownerId}).runInContext(r),[u,l,d]=c.grid.cells.space.dimensions,f={label:s.volume_data_3d_info.name.value(0),description:`Segmentation ${u}\xd7${l}\xd7${d}`};return new pe.Volume.Data(c,f)});return function(r){return n.apply(this,arguments)}}()),dispose({b:e}){e?.data.customProperties.dispose()}}),cKe=Rt.BuiltIn({name:"assign-color-volume",display:{name:"Assign Color Volume",description:"Assigns another volume to be available for coloring."},from:pe.Volume.Data,to:pe.Volume.Data,isDecorator:!0,params(e,t){if(!e)return{ref:C.Text()};const n=t.state.data.select(In.Generators.root.subtree().ofType(pe.Volume.Data).filter(r=>{var i;return!(!r.obj||null!==(i=r.obj)&&void 0!==i&&i.data.colorVolume||r.obj===e)}));return 0===n.length?{ref:C.Text("",{isHidden:!0})}:{ref:C.Select(n[0].transform.ref,n.map(r=>[r.transform.ref,r.obj.label]))}}})({apply:({a:e,params:t,dependencies:n})=>Oe.create("Assign Color Volume",function(){var r=ie(function*(i){if(!n||!n[t.ref])throw new Error("Dependency not available.");const s={...e.data,colorVolume:n[t.ref].data};return new pe.Volume.Data(s,{label:e.label,description:"Volume + Colors"})});return function(i){return r.apply(this,arguments)}}())}),$D=st(13421772),ese={},dKe={name:"carbohydrate-symbol",label:"Carbohydrate Symbol",category:ni.Residue,factory:function tse(e,t){let n;if(e.structure){const{elements:r,getElementIndices:i}=e.structure.carbohydrates,o=(s,a)=>{if(!Ee.isAtomic(s))return $D;const c=i(s,a);return c.length>0?r[c[0]].component.color:$D};n=(s,a)=>a?15854817:nt.is(s)?o(s.unit,s.element):Lt.isLocation(s)?o(s.aUnit,s.aUnit.elements[s.aIndex]):$D}else n=()=>$D;return{factory:tse,granularity:"group",color:n,props:t,description:"Assigns colors according to the Symbol Nomenclature for Glycans (SNFG).",legend:$h(UNe)}},getParams:function lKe(e){return ese},defaultValues:C.getDefaultValues(ese),isApplicable:e=>!!e.structure&&e.structure.models.some(t=>sn.hasCarbohydrate(t))},nse={hue:C.Interval([1,360],{min:0,max:360,step:1}),chroma:C.Interval([40,70],{min:0,max:100,step:1}),luminance:C.Interval([15,85],{min:0,max:100,step:1}),sort:C.Select("contrast",C.arrayToOptions(["none","contrast"]),{description:"no sorting leaves colors approximately ordered by hue"}),clusteringStepCount:C.Numeric(50,{min:10,max:200,step:1},{isHidden:!0}),minSampleCount:C.Numeric(800,{min:100,max:5e3,step:100},{isHidden:!0}),sampleCountFactor:C.Numeric(5,{min:1,max:100,step:1},{isHidden:!0})},Uv=2,_0=[0,0,0],x0=[0,0,0];function fKe(e,t){return Yo.toHcl(_0,e),Yo.fromColor(x0,Yo.toColor(e)),_0[0]>=t.hue[0]&&_0[0]<=t.hue[1]&&_0[1]>=t.chroma[0]&&_0[1]<=t.chroma[1]&&_0[2]>=t.luminance[0]&&_0[2]<=t.luminance[1]&&x0[0]>=e[0]-Uv&&x0[0]<=e[0]+Uv&&x0[1]>=e[1]-Uv&&x0[1]<=e[1]+Uv&&x0[2]>=e[2]-Uv&&x0[2]<=e[2]+Uv}function rse(e,t){let n=1/0,r=0;for(let i=0;i`${e+1}`,minLabel:"Start",maxLabel:"End"};function ac(e,t,n={}){var r;let i,o;if("colors"===t.palette.name&&"interpolate"===t.palette.params.list.kind){const{list:s}=t.palette.params,a=[0,e-1],{minLabel:c,maxLabel:u}={...ose,...n};let l=s.colors;0===l.length&&(l=cp(ise.colorList).list);const d=Gu.create({listOrName:l,domain:a,minLabel:c,maxLabel:u});o=d.legend,i=d.color}else{let s;"colors"===t.palette.name?(s=t.palette.params.list.colors.map(l=>Array.isArray(l)?l[0]:l),0===s.length&&(s=cp("dark-2").list.map(l=>Array.isArray(l)?l[0]:l))):(e=Math.min(e,t.palette.params.maxCount),s=function mKe(e,t={}){const n={...C.getDefaultValues(nse),...t};if(e<=0)return[];const r=function hKe(e,t){const n=new Map,r=Math.ceil(Math.cbrt(e)),i=id(),o=Math.max((t.hue[1]-t.hue[0])/r,1),s=Math.max((t.chroma[1]-t.chroma[0])/r,1),a=Math.max((t.luminance[1]-t.luminance[0])/r,1);for(let c=t.hue[0]+o/2;c<=t.hue[1];c+=o)for(let u=t.chroma[0]+s/2;u<=t.chroma[1];u+=s)for(let l=t.luminance[0]+a/2;l<=t.luminance[1];l+=a){const d=Yo.fromHcl(Yo(),id.set(i,c,u,l));fKe(d,t)&&n.set(Yo.toColor(d),d)}return Array.from(n.values())}(Math.max(n.minSampleCount,e*n.sampleCountFactor),n);if(r.length=e));c+=s);for(let c=1;c<=n.clusteringStepCount;++c){const u=Jl(o),l=Jl(r);for(let f=0;f0;){const r=n[n.length-1];let i=0,o=Number.NEGATIVE_INFINITY;for(let s=0;so&&(o=a,i=s)}n.push(t.splice(i,1)[0])}return n}(i):i).map(c=>Yo.toColor(c))}(e,t.palette.params));const a=null!==(r=n.valueLabel)&&void 0!==r?r:ose.valueLabel,c=s.length,u=[];for(let l=0;ls[l%c]}return{color:i,legend:o}}const sse=st(16448250),yKe="Gives every chain a color based on its `asym_id` value.",ES={asymId:C.Select("auth",C.arrayToOptions(["auth","label"])),...Ia({type:"colors",colorList:"many-distinct"})};function ase(e,t){const n=function vKe(e,t){switch(e.kind){case 0:return"auth"===t?Ze.chain.auth_asym_id:Ze.chain.label_asym_id;case 1:case 2:return Ze.coarse.asym_id}}(e.unit,t)(e);return e.structure.root.models.length>1?cse(e.unit.model,n):n}function cse(e,t){return`${t}|${(sn.Index.get(e).value||0)+1}`}function PS(e,t){let n,r;if(e.structure){const i=nt.create(e.structure.root),o=function _Ke(e,t){const n=new Map;for(const r of e.models){const i=sn.AsymIdOffset.get(r).value,o=("auth"===t?i?.auth:i?.label)||0;let s=0;r.properties.structAsymMap.forEach(({auth_id:a},c)=>{const u="auth"===t?a:c,l=e.models.length>1?cse(r,u):u;n.has(l)||(n.set(l,s+o),++s)})}return n}(e.structure.root,t.asymId),s=Array.from(o.keys()),c=ac(o.size,t,{valueLabel:u=>s[u]});r=c.legend,n=u=>{let l;if(nt.is(u)){const d=ase(u,t.asymId);l=o.get(d)}else if(Lt.isLocation(u)){i.unit=u.aUnit,i.element=u.aUnit.elements[u.aIndex];const d=ase(i,t.asymId);l=o.get(d)}return void 0===l?sse:c.color(l)}}else n=()=>sse;return{factory:PS,granularity:"group",color:n,props:t,description:yKe,legend:r}}const use={name:"chain-id",label:"Chain Id",category:ni.Chain,factory:PS,getParams:function bKe(e){var t;const n=C.clone(ES);return!(null===(t=e.structure)||void 0===t)&&t.models.some(r=>r.coarseHierarchy.isDefined)&&(n.asymId.defaultValue="label"),n},defaultValues:C.getDefaultValues(ES),isApplicable:e=>!!e.structure},lse=st(13421772),dse={...Ia({type:"colors",colorList:"red-yellow-blue"})},CKe={name:"element-index",label:"Element Index",category:ni.Atom,factory:function fse(e,t){let n,r;if(e.structure){const{units:i}=e.structure.root,o=i.length,s=new Map,a=new Map;let c=0;for(let l=0;l{if(nt.is(l)){const d=a.get(l.unit.id),f=Fe.findPredecessorIndex(i[d].elements,l.element);return u.color(s.get(d)+f)}if(Lt.isLocation(l)){const d=a.get(l.aUnit.id),f=Fe.findPredecessorIndex(i[d].elements,l.aUnit.elements[l.aIndex]);return u.color(s.get(d)+f)}return lse}}else n=()=>lse;return{factory:fse,granularity:"groupInstance",preferSmoothing:!0,color:n,props:t,description:"Gives every element (atom or coarse sphere/gaussian) a unique color based on the position (index) of the element in the list of elements in the structure.",legend:r}},getParams:function SKe(e){return dse},defaultValues:C.getDefaultValues(dse),isApplicable:e=>!!e.structure};function YD(e){const t={};return $a(e,(n,r)=>{t[r]=C.Color(e[r])}),t}const pse=st(13421772),AKe="Assigns a color based on the operator name of a transformed chain.",R6={...Ia({type:"colors",colorList:"many-distinct"})};function k6(e,t){let n,r;if(e.structure){const i=function TKe(e){const t=new Map;for(let n=0,r=e.units.length;no[c]});r=a.legend,n=c=>{let u;return nt.is(c)?u=i.get(c.unit.conformation.operator.name):Lt.isLocation(c)&&(u=i.get(c.aUnit.conformation.operator.name)),void 0===u?pse:a.color(u)}}else n=()=>pse;return{factory:k6,granularity:"instance",color:n,props:t,description:AKe,legend:r}}const N6={name:"operator-name",label:"Operator Name",category:ni.Symmetry,factory:k6,getParams:function IKe(e){return C.clone(R6)},defaultValues:C.getDefaultValues(R6),isApplicable:e=>!!e.structure},hse=st(16448250),EKe="Gives every chain a color based on its `label_entity_id` value.",RS={...Ia({type:"colors",colorList:"many-distinct"})};function kS(e,t){return`${e}|${t}`}function mse(e){switch(e.unit.kind){case 0:return Ze.chain.label_entity_id(e);case 1:case 2:return Ze.coarse.entity_id(e)}}function NS(e,t){let n,r;if(e.structure){const i=nt.create(e.structure.root),o=function MKe(e){const t=new Map;for(let n=0,r=e.models.length;ns[u]});r=c.legend,n=u=>{let l;if(nt.is(u)){const p=kS(mse(u),u.structure.models.indexOf(u.unit.model));l=o.get(p)}else if(Lt.isLocation(u)){i.unit=u.aUnit,i.element=u.aUnit.elements[u.aIndex];const p=kS(mse(i),i.structure.models.indexOf(i.unit.model));l=o.get(p)}return void 0===l?hse:c.color(l)}}else n=()=>hse;return{factory:NS,granularity:"group",color:n,props:t,description:EKe,legend:r}}const RKe={name:"entity-id",label:"Entity Id",category:ni.Chain,factory:NS,getParams:function PKe(e){return C.clone(RS)},defaultValues:C.getDefaultValues(RS),isApplicable:e=>!!e.structure},F6="dark-2",XD=st(16448250),kKe="Gives ranges of a polymer chain a color based on the entity source it originates from (e.g. gene, plasmid, organism).",FS={...Ia({type:"colors",colorList:F6})};function gse(e,t){return`${e}|${t}`}function FKe(e,t,n,r,i,o){return`${e}|${t}|${n}|${o||i||r}`}function B6(e,t,n,r,i,o,s,a){const{entity_id:c,pdbx_src_id:u,pdbx_beg_seq_num:l,pdbx_end_seq_num:d}=i;for(let f=0,p=i._rowCount;f{const r=n.split("|"),i=r[2];return`${function jFe(e){e=e.trim();const t=parseInt(e,10);return!isNaN(t)&&t.toString()===e}(r[3])?"Unnamed "+ ++t:r[3]}${i?` (${i})`:""}`})}(a),l=ac(a.size,t,{valueLabel:f=>c[f]});r=l.legend;const d=f=>{const h=gse(o.indexOf(f.unit.model),Ze.entity.id(f)),g=s.get(h);if(g){const y=g[Ze.residue.label_seq_id(f)-1]-1;return-1===y?XD:l.color(y)}return XD};n=f=>nt.is(f)?d(f):Lt.isLocation(f)?(i.unit=f.aUnit,i.element=f.aUnit.elements[f.aIndex],d(i)):XD}else n=()=>XD;return{factory:BS,granularity:"group",color:n,props:t,description:kKe,legend:r}}const OKe={name:"entity-source",label:"Entity Source",category:ni.Chain,factory:BS,getParams:function NKe(e){const t=C.clone(FS);return e.structure&&yse(e.structure.root.models).srcKeySerialMap.size>Pc[F6].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params={...t.palette.defaultValue.params,list:{kind:"interpolate",colors:cp(F6).list}}),t},defaultValues:C.getDefaultValues(FS),isApplicable:e=>!!e.structure},bse=st(13421772),LKe="Gives every model a unique color based on its index.",OS={...Ia({type:"colors",colorList:"many-distinct"})};function LS(e,t){var n;let r,i;if(e.structure){const s=ac((null!==(n=sn.MaxIndex.get(e.structure.models[0]).value)&&void 0!==n?n:-1)+1,t);i=s.legend,r=a=>nt.is(a)?s.color(sn.Index.get(a.unit.model).value||0):Lt.isLocation(a)?s.color(sn.Index.get(a.aUnit.model).value||0):bse}else r=()=>bse;return{factory:LS,granularity:"instance",color:r,props:t,description:LKe,legend:i}}const VKe={name:"model-index",label:"Model Index",category:ni.Chain,factory:LS,getParams:function UKe(e){return C.clone(OS)},defaultValues:C.getDefaultValues(OS),isApplicable:e=>!!e.structure&&e.structure.elementCount>0},vse=st(13421772),zKe="Gives every structure a unique color based on its index.",US={...Ia({type:"colors",colorList:"many-distinct"})};function VS(e,t){var n;let r,i;if(e.structure){const s=ac((null!==(n=Ve.MaxIndex.get(e.structure).value)&&void 0!==n?n:-1)+1,t);i=s.legend,r=a=>nt.is(a)?s.color(Ve.Index.get(a.structure).value||0):Lt.isLocation(a)?s.color(Ve.Index.get(a.aStructure).value||0):vse}else r=()=>vse;return{factory:VS,granularity:"instance",color:r,props:t,description:zKe,legend:i}}const jKe={name:"structure-index",label:"Structure Index",category:ni.Chain,factory:VS,getParams:function GKe(e){return C.clone(US)},defaultValues:C.getDefaultValues(US),isApplicable:e=>!!e.structure&&e.structure.elementCount>0},O6="dark-2",_se=st(13421772),HKe="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.",L6={...Ia({type:"colors",colorList:O6})};function U6(e,t){let n,r;if(e.structure){const{units:i}=e.structure.root,o=ac(i.length,t);r=o.legend;const s=new Map;for(let a=0,c=i.length;ant.is(a)?s.get(a.unit.id):Lt.isLocation(a)?s.get(a.aUnit.id):_se}else n=()=>_se;return{factory:U6,granularity:"instance",color:n,props:t,description:HKe,legend:r}}const WKe={name:"unit-index",label:"Chain Instance",category:ni.Chain,factory:U6,getParams:function qKe(e){const t=C.clone(L6);return e.structure&&e.structure.root.units.length>Pc[O6].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params={...t.palette.defaultValue.params,list:{kind:"interpolate",colors:cp(O6).list}}),t},defaultValues:C.getDefaultValues(L6),isApplicable:e=>!!e.structure},xse={H:16777215,D:16777152,T:16777120,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215},Sse=st(16777215),V6={carbonColor:C.MappedStatic("chain-id",{"chain-id":C.Group(ES),"unit-index":C.Group(L6,{label:"Chain Instance"}),"entity-id":C.Group(RS),"entity-source":C.Group(FS),"operator-name":C.Group(R6),"model-index":C.Group(OS),"structure-index":C.Group(US),uniform:C.Group(bv),"element-symbol":C.EmptyGroup()},{description:"Use chain-id coloring for carbon atoms."}),saturation:C.Numeric(0,{min:-6,max:6,step:.1}),lightness:C.Numeric(.2,{min:-6,max:6,step:.1}),colors:C.MappedStatic("default",{default:C.EmptyGroup(),custom:C.Group(YD(xse))})};function z6(e,t){var n;const r=KI("default"===t.colors.name?xse:t.colors.params,t.saturation,t.lightness),i=null===(n=function KKe(e,t){switch(t.name){case"chain-id":return PS(e,t.params);case"unit-index":return U6(e,t.params);case"entity-id":return NS(e,t.params);case"entity-source":return BS(e,t.params);case"operator-name":return k6(e,t.params);case"model-index":return LS(e,t.params);case"structure-index":return VS(e,t.params);case"uniform":return f0(0,t.params);case"element-symbol":return;default:Rr()}}(e,t.carbonColor))||void 0===n?void 0:n.color;function o(c,u){return i&&"C"===c?i(u,!1):function XKe(e,t){const n=e[t];return void 0===n?Sse:n}(r,c)}return{factory:z6,granularity:"operator-name"===t.carbonColor.name||"unit-index"===t.carbonColor.name?"groupInstance":"group",preferSmoothing:!0,color:function s(c){if(nt.is(c)){if(Ee.isAtomic(c.unit)){const{type_symbol:u}=c.unit.model.atomicHierarchy.atoms;return o(u.value(c.element),c)}}else if(Lt.isLocation(c)&&Ee.isAtomic(c.aUnit)){const{type_symbol:u}=c.aUnit.model.atomicHierarchy.atoms;return o(u.value(c.aUnit.elements[c.aIndex]),c)}return Sse},props:t,description:"Assigns a color to every atom according to its chemical element.",legend:$h(Object.keys(r).map(c=>[c,r[c]]))}}const ZKe={name:"element-symbol",label:"Element Symbol",category:ni.Atom,factory:z6,getParams:function YKe(e){return C.clone(V6)},defaultValues:C.getDefaultValues(V6),isApplicable:e=>!!e.structure},Cse={water:3697840,ion:15729279,protein:12496596,RNA:16629894,DNA:12540695,PNA:4367514,saccharide:8374655},G6=st(16777113),KD={saturation:C.Numeric(0,{min:-6,max:6,step:.1}),lightness:C.Numeric(0,{min:-6,max:6,step:.1}),colors:C.MappedStatic("default",{default:C.EmptyGroup(),custom:C.Group(YD(Cse))})};function wse(e,t,n){switch(jB(t,n)){case 2:return e.water;case 3:return e.ion;case 5:return e.protein;case 6:return e.RNA;case 7:return e.DNA;case 8:return e.PNA;case 9:return e.saccharide}return G6}function ZD(e,t){const n=KI("default"===t.colors.name?Cse:t.colors.params,t.saturation,t.lightness);return{factory:ZD,granularity:"group",color:function r(i){return nt.is(i)?wse(n,i.unit,i.element):Lt.isLocation(i)?wse(n,i.aUnit,i.aUnit.elements[i.aIndex]):G6},props:t,description:"Assigns a color based on the molecule type of a residue.",legend:$h(Object.keys(n).map(i=>[i,n[i]]).concat([["Other/unknown",G6]]))}}const eZe={name:"molecule-type",label:"Molecule Type",category:ni.Residue,factory:ZD,getParams:function JKe(e){return KD},defaultValues:C.getDefaultValues(KD),isApplicable:e=>!!e.structure},j6="dark-2",Ase=st(16448250),Ise={...Ia({type:"colors",colorList:j6})};function Tse(e){switch(e.kind){case 0:return Ze.chain.label_asym_id;case 1:case 2:return Ze.coarse.asym_id}}function Dse(e){const t=new Map;for(let n=0,r=e.unitSymmetryGroups.length;ns[u]});r=c.legend,n=u=>{let l;if(nt.is(u)){const d=Tse(u.unit);l=o.get(d(u))}else if(Lt.isLocation(u)){const d=Tse(u.aUnit);i.unit=u.aUnit,i.element=u.aUnit.elements[u.aIndex],l=o.get(d(i))}return void 0===l?Ase:c.color(l)}}else n=()=>Ase;return{factory:Ese,granularity:"group",color:n,props:t,description:"Gives every polymer chain a color based on its `asym_id` value.",legend:r}},getParams:function nZe(e){const t=C.clone(Ise);return e.structure&&Dse(e.structure.root).size>Pc[j6].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params={...t.palette.defaultValue.params,list:{kind:"interpolate",colors:cp(j6).list}}),t},defaultValues:C.getDefaultValues(Ise),isApplicable:e=>!!e.structure},H6="dark-2",Pse=st(13421772),Mse={...Ia({type:"colors",colorList:H6})};function Rse(e){let t=0;const{units:n}=e;for(let r=0,i=n.length;r0&&++t;return t}const sZe={name:"polymer-index",label:"Polymer Chain Instance",category:ni.Chain,factory:function kse(e,t){let n,r;if(e.structure){const i=ac(Rse(e.structure.root),t);r=i.legend;const{units:o}=e.structure.root,s=new Map;for(let a=0,c=0,u=o.length;a0&&(s.set(o[a].id,i.color(c)),++c);n=a=>{let c;return nt.is(a)?c=s.get(a.unit.id):Lt.isLocation(a)&&(c=s.get(a.aUnit.id)),void 0!==c?c:Pse}}else n=()=>Pse;return{factory:kse,granularity:"instance",color:n,props:t,description:"Gives every polymer chain instance a unique color based on the position (index) of the polymer in the list of polymers in the structure.",legend:r}},getParams:function oZe(e){const t=C.clone(Mse);return e.structure&&Rse(e.structure.root)>Pc[H6].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params={...t.palette.defaultValue.params,list:{kind:"interpolate",colors:cp(H6).list}}),t},defaultValues:C.getDefaultValues(Mse),isApplicable:e=>!!e.structure},Nse={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},q6=st(16711935),W6={saturation:C.Numeric(0,{min:-6,max:6,step:.1}),lightness:C.Numeric(1,{min:-6,max:6,step:.1}),colors:C.MappedStatic("default",{default:C.EmptyGroup(),custom:C.Group(YD(Nse))})};function Fse(e,t){return e.model.atomicHierarchy.atoms.label_comp_id.value(t)}function Bse(e,t){const n=e.coarseElements.seq_id_begin.value(t);if(n===e.coarseElements.seq_id_end.value(t))return e.model.sequence.byEntityKey[e.coarseElements.entityKey[t]].sequence.compId.value(n-1)}function QD(e,t){const n=e[t];return void 0===n?q6:n}function $6(e,t){const n=KI("default"===t.colors.name?Nse:t.colors.params,t.saturation,t.lightness);return{factory:$6,granularity:"group",preferSmoothing:!0,color:function r(i){if(nt.is(i)){if(Ee.isAtomic(i.unit)){const o=Fse(i.unit,i.element);return QD(n,o)}{const o=Bse(i.unit,i.element);if(o)return QD(n,o)}}else if(Lt.isLocation(i)){if(Ee.isAtomic(i.aUnit)){const o=Fse(i.aUnit,i.aUnit.elements[i.aIndex]);return QD(n,o)}{const o=Bse(i.aUnit,i.aUnit.elements[i.aIndex]);if(o)return QD(n,o)}}return q6},props:t,description:"Assigns a color to every residue according to its name.",legend:$h(Object.keys(n).map(i=>[i,n[i]]).concat([["Unknown",q6]]))}}const uZe={name:"residue-name",label:"Residue Name",category:ni.Residue,factory:$6,getParams:function cZe(e){return W6},defaultValues:C.getDefaultValues(W6),isApplicable:e=>!!e.structure},Ose={alphaHelix:16711808,threeTenHelix:10485888,piHelix:6291584,betaTurn:6324479,betaStrand:16762880,coil:16777215,bend:6740169,turn:45670,dna:11403518,rna:16580962,carbohydrate:10921722},Y6=st(8421504),X6={saturation:C.Numeric(-1,{min:-6,max:6,step:.1}),lightness:C.Numeric(0,{min:-6,max:6,step:.1}),colors:C.MappedStatic("default",{default:C.EmptyGroup(),custom:C.Group(YD(Ose))})};function Lse(e,t,n,r){let i=cr.create(0);if(r&&Ee.isAtomic(t)){const o=r.get(t.invariantId);o&&(i=o.type[o.getIndex(t.residueIndex[n])])}if(cr.is(i,2))return cr.is(i,2048)?e.threeTenHelix:cr.is(i,32768)?e.piHelix:e.alphaHelix;if(cr.is(i,4))return e.betaStrand;if(cr.is(i,8))return e.bend;if(cr.is(i,16))return e.turn;{const o=jB(t,n);if(7===o)return e.dna;if(6===o)return e.rna;if(9===o)return e.carbohydrate;if(5===o)return e.coil}return Y6}function K6(e,t){const n=e.structure&&Xu.get(e.structure),r=n?Pg(n.id,n.version):-1,i=KI("default"===t.colors.name?Ose:t.colors.params,t.saturation,t.lightness);return{factory:K6,granularity:"group",preferSmoothing:!0,color:function o(s){return nt.is(s)?Lse(i,s.unit,s.element,n?.value):Lt.isLocation(s)?Lse(i,s.aUnit,s.aUnit.elements[s.aIndex],n?.value):Y6},props:t,contextHash:r,description:"Assigns a color based on the type of secondary structure and basic molecule type.",legend:$h(Object.keys(i).map(s=>[s,i[s]]).concat([["Other",Y6]]))}}const fZe={name:"secondary-structure",label:"Secondary Structure",category:ni.Residue,factory:K6,getParams:function dZe(e){return X6},defaultValues:C.getDefaultValues(X6),isApplicable:e=>!!e.structure,ensureCustomProperties:{attach:(e,t)=>t.structure?Xu.attach(e,t.structure,void 0,!0):Promise.resolve(),detach:e=>e.structure&&Xu.ref(e.structure,!1)}},pZe=st(13421772),Use={list:C.ColorList("turbo",{presetKind:"scale"})};function Vse(e,t){const{model:n}=e;switch(e.kind){case 0:return n.atomicHierarchy.residues.label_seq_id.value(n.atomicHierarchy.residueAtomSegments.index[t]);case 1:return Math.round((n.coarseHierarchy.spheres.seq_id_begin.value(t)+n.coarseHierarchy.spheres.seq_id_end.value(t))/2);case 2:return Math.round((n.coarseHierarchy.gaussians.seq_id_begin.value(t)+n.coarseHierarchy.gaussians.seq_id_end.value(t))/2)}}function zse(e,t){const{model:n}=e;let r="";switch(e.kind){case 0:r=n.atomicHierarchy.chains.label_entity_id.value(n.atomicHierarchy.chainAtomSegments.index[t]);break;case 1:r=n.coarseHierarchy.spheres.entity_id.value(t);break;case 2:r=n.coarseHierarchy.gaussians.entity_id.value(t)}if(""===r)return 0;const i=n.entities.getEntityIndex(r);if(-1===i)return 0;const o=n.sequence.byEntityKey[i];return void 0===o?0:o.sequence.length}const gZe={name:"sequence-id",label:"Sequence Id",category:ni.Residue,factory:function Gse(e,t){const n=Gu.create({listOrName:t.list.colors,minLabel:"Start",maxLabel:"End"});return{factory:Gse,granularity:"group",preferSmoothing:!0,color:i=>{if(nt.is(i)){const{unit:o,element:s}=i,a=Vse(o,s);if(a>0){const c=zse(o,s);if(c)return n.setDomain(0,c-1),n.color(a)}}else if(Lt.isLocation(i)){const{aUnit:o,aIndex:s}=i,a=Vse(o,o.elements[s]);if(a>0){const c=zse(o,o.elements[s]);if(c)return n.setDomain(0,c-1),n.color(a)}}return pZe},props:t,description:"Gives every polymer residue a color based on its `seq_id` value.",legend:n?n.legend:void 0}},getParams:function mZe(e){return Use},defaultValues:C.getDefaultValues(Use),isApplicable:e=>!!e.structure},yZe=st(16777113),jse={domain:C.Interval([0,100]),list:C.ColorList("red-white-blue",{presetKind:"scale"})};function Hse(e,t){return Ee.isAtomic(e)?e.model.atomicConformation.B_iso_or_equiv.value(t):Ee.isSpheres(e)?e.model.coarseConformation.spheres.rmsf[t]:0}const _Ze={name:"uncertainty",label:"Uncertainty/Disorder",category:ni.Atom,factory:function qse(e,t){const n=Gu.create({reverse:!0,domain:t.domain,listOrName:t.list.colors});return{factory:qse,granularity:"group",preferSmoothing:!0,color:function r(i){return nt.is(i)?n.color(Hse(i.unit,i.element)):Lt.isLocation(i)?n.color(Hse(i.aUnit,i.aUnit.elements[i.aIndex])):yZe},props:t,description:"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.",legend:n?n.legend:void 0}},getParams:function vZe(e){return jse},defaultValues:C.getDefaultValues(jse),isApplicable:e=>!!e.structure&&e.structure.models.some(t=>t.atomicConformation.B_iso_or_equiv.isDefined||t.coarseHierarchy.isDefined)},xZe=st(15658734),Wse={style:C.MappedStatic("entity-id",{uniform:C.Group(bv),"chain-id":C.Group(ES),"entity-id":C.Group(RS),"entity-source":C.Group(FS),"molecule-type":C.Group(KD),"model-index":C.Group(OS),"structure-index":C.Group(US)}),carbonLightness:C.Numeric(.8,{min:-6,max:6,step:.1})},AZe={name:"illustrative",label:"Illustrative",category:ni.Misc,factory:function $se(e,t){const{color:n,legend:r}=function wZe(e,t){switch(t.name){case"uniform":return f0(0,t.params);case"chain-id":return PS(e,t.params);case"entity-id":return NS(e,t.params);case"entity-source":return BS(e,t.params);case"molecule-type":return ZD(0,t.params);case"model-index":return LS(e,t.params);case"structure-index":return VS(e,t.params);default:Rr()}}(e,t.style);function i(s,a){const c=n(s,!1);return"C"===a?st.lighten(c,t.carbonLightness):c}return{factory:$se,granularity:"group",preferSmoothing:!0,color:function o(s){if(nt.is(s)&&Ee.isAtomic(s.unit)){const a=s.unit.model.atomicHierarchy.atoms.type_symbol.value(s.element);return i(s,a)}if(Lt.isLocation(s)&&Ee.isAtomic(s.aUnit)){const c=s.aUnit.model.atomicHierarchy.atoms.type_symbol.value(s.aUnit.elements[s.aIndex]);return i(s,c)}return xZe},props:t,description:"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).",legend:r}},getParams:function CZe(e){return C.clone(Wse)},defaultValues:C.getDefaultValues(Wse),isApplicable:e=>!!e.structure},Yse={list:C.ColorList("red-yellow-green",{presetKind:"scale"}),scale:C.Select("DGwif",[["DGwif","DG water-membrane"],["DGwoct","DG water-octanol"],["Oct-IF","DG difference"]])},DZe={DGwif:0,DGwoct:1,"Oct-IF":2};function Xse(e,t){return e.model.atomicHierarchy.atoms.label_comp_id.value(t)}function Kse(e,t){const n=e.coarseElements.seq_id_begin.value(t);if(n===e.coarseElements.seq_id_end.value(t))return e.model.sequence.byEntityKey[e.coarseElements.entityKey[t]].sequence.compId.value(n-1)}const PZe={name:"hydrophobicity",label:"Hydrophobicity",category:ni.Residue,factory:function Zse(e,t){const n=DZe[t.scale];let r=1/0,i=-1/0;for(const a in PB){const c=PB[a][n];r=Math.min(r,c),i=Math.max(i,c)}const o=Gu.create({listOrName:t.list.colors,domain:[i,r],minLabel:"Hydrophilic",maxLabel:"Hydrophobic"});return{factory:Zse,granularity:"group",preferSmoothing:!0,color:function s(a){let c;return nt.is(a)?c=Ee.isAtomic(a.unit)?Xse(a.unit,a.element):Kse(a.unit,a.element):Lt.isLocation(a)&&(c=Ee.isAtomic(a.aUnit)?Xse(a.aUnit,a.aUnit.elements[a.aIndex]):Kse(a.aUnit,a.aUnit.elements[a.aIndex])),o.color(c?function EZe(e,t){const n=PB[e];return void 0===n?0:n[t]}(c,n):0)},props:t,description:'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).',legend:o?o.legend:void 0}},getParams:function TZe(e){return Yse},defaultValues:C.getDefaultValues(Yse),isApplicable:e=>!!e.structure},Qse=st(13421772),Jse={...Ia({type:"colors",colorList:"purples"})},kZe={name:"trajectory-index",label:"Trajectory Index",category:ni.Chain,factory:function eae(e,t){var n,r;let i,o;if(e.structure){const{models:s}=e.structure.root;let a=0;for(const l of s)a=Math.max(a,(null===(n=sn.TrajectoryInfo.get(l))||void 0===n?void 0:n.size)||0);const c=ac(a,t);o=c.legend;const u=new Map;for(let l=0,d=s.length;lnt.is(l)?u.get(sn.TrajectoryInfo.get(l.unit.model).index):Lt.isLocation(l)?u.get(sn.TrajectoryInfo.get(l.aUnit.model).index):Qse}else i=()=>Qse;return{factory:eae,granularity:"instance",color:i,props:t,description:"Gives every model (frame) a unique color based on the index in its trajectory.",legend:o}},getParams:function RZe(e){return C.clone(Jse)},defaultValues:C.getDefaultValues(Jse),isApplicable:e=>!!e.structure&&e.structure.elementCount>0&&sn.TrajectoryInfo.get(e.structure.models[0]).size>1},NZe=st(13421772),tae={domain:C.Interval([0,1]),list:C.ColorList("purples",{presetKind:"scale"})};function nae(e,t){return Ee.isAtomic(e)?e.model.atomicConformation.occupancy.value(t):0}const OZe={name:"occupancy",label:"Occupancy",category:ni.Atom,factory:function rae(e,t){const n=Gu.create({reverse:!1,domain:t.domain,listOrName:t.list.colors});return{factory:rae,granularity:"group",preferSmoothing:!0,color:function r(i){return nt.is(i)?n.color(nae(i.unit,i.element)):Lt.isLocation(i)?n.color(nae(i.aUnit,i.aUnit.elements[i.aIndex])):NZe},props:t,description:"Assigns a color based on the occupancy of an atom.",legend:n?n.legend:void 0}},getParams:function BZe(e){return tae},defaultValues:C.getDefaultValues(tae),isApplicable:e=>!!e.structure&&e.structure.models.some(t=>t.atomicConformation.occupancy.isDefined)},Z6="dark-2",iae=st(13421772),oae={...Ia({type:"colors",colorList:Z6})},zS=1e4;function Q6(e){return e.map(t=>`${t+zS}`.padStart(5,"0")).join("")}function J6(e){const t=function zFe(e,t){return Math.abs(e)t+5).join("")}function sae(e){const t=new Map,n=new Set;for(let s=0,a=e.units.length;st.set(s,t.size)),{min:J6(r[0]),max:J6(r[r.length-1]),map:t}}const VZe={name:"operator-hkl",label:"Operator HKL",category:ni.Symmetry,factory:function aae(e,t){let n,r;if(e.structure){const{min:i,max:o,map:s}=sae(e.structure.root),a=[];s.forEach((l,d)=>{const f=l%s.size,p=e8(J6(d));void 0===a[f]?a[f]=p:a[f]+=`, ${p}`});const c={minLabel:e8(i),maxLabel:e8(o),valueLabel:l=>a[l]},u=ac(s.size,t,c);r=u.legend,n=l=>{let d;if(nt.is(l)){const f=Q6(l.unit.conformation.operator.hkl);d=s.get(f)}else if(Lt.isLocation(l)){const f=Q6(l.aUnit.conformation.operator.hkl);d=s.get(f)}return void 0===d?iae:u.color(d)}}else n=()=>iae;return{factory:aae,granularity:"instance",color:n,props:t,description:"Assigns a color based on the operator HKL value of a transformed chain.",legend:r}},getParams:function UZe(e){const t=C.clone(oae);return e.structure&&sae(e.structure.root).map.size>Pc[Z6].list.length&&(t.palette.defaultValue.name="colors",t.palette.defaultValue.params={...t.palette.defaultValue.params,list:{kind:"interpolate",colors:cp(Z6).list}}),t},defaultValues:C.getDefaultValues(oae),isApplicable:e=>!!e.structure},t8=st(16777113),cae={domain:C.Interval([-1,1]),list:C.ColorList("red-white-blue",{presetKind:"scale"})};function uae(e,t){var n;return null===(n=Mv.Provider.get(e.model))||void 0===n?void 0:n.data.value(t)}const jZe={name:"partial-charge",label:"Partial Charge",category:ni.Atom,factory:function lae(e,t){const n=Gu.create({domain:t.domain,listOrName:t.list.colors});return{factory:lae,granularity:"group",preferSmoothing:!0,color:function r(i){if(nt.is(i)){const o=uae(i.unit,i.element);return void 0!==o?n.color(o):t8}if(Lt.isLocation(i)){const o=uae(i.aUnit,i.aUnit.elements[i.aIndex]);return void 0!==o?n.color(o):t8}return t8},props:t,description:"Assigns a color based on the partial charge of an atom.",legend:n?n.legend:void 0}},getParams:function GZe(e){return cae},defaultValues:C.getDefaultValues(cae),isApplicable:e=>!!e.structure&&e.structure.models.some(t=>void 0!==Mv.Provider.get(t))},dae=st(16448250),fae={...Ia({type:"colors",colorList:"many-distinct"})},YZe={name:"atom-id",label:"Atom Id",category:ni.Atom,factory:function pae(e,t){let n,r;if(e.structure){const i=nt.create(e.structure.root),o=function $Ze(e){const t=new Map;for(const n of e.models){const{label_atom_id:r}=n.atomicHierarchy.atoms;for(let i=0,o=r.rowCount;is[u]});r=c.legend,n=u=>{let l;if(nt.is(u)){const d=Ze.atom.label_atom_id(u);l=o.get(d)}else if(Lt.isLocation(u)){i.unit=u.aUnit,i.element=u.aUnit.elements[u.aIndex];const d=Ze.atom.label_atom_id(i);l=o.get(d)}return void 0===l?dae:c.color(l)}}else n=()=>dae;return{factory:pae,granularity:"group",preferSmoothing:!0,color:n,props:t,description:"Gives every atom a color based on its `label_atom_id` value.",legend:r}},getParams:function WZe(e){return C.clone(fae)},defaultValues:C.getDefaultValues(fae),isApplicable:e=>!!e.structure},hae={colorList:C.ColorList({kind:"interpolate",colors:[[xn.white,0],[xn.red,.25],[xn.white,.5],[xn.blue,.75],[xn.white,1]]},{offsets:!0,isEssential:!0})},ZZe={name:"volume-value",label:"Volume Value",category:ni.Misc,factory:function mae(e,t){const n=Gu.create({domain:[0,1],listOrName:t.colorList.colors}),r=[];for(let o=0;o<256;++o)r[o]=n.color(o/255);return{factory:mae,granularity:"direct",props:t,description:"Assign color based on the given value of a volume cell.",legend:n.legend,palette:{colors:r,filter:"linear"}}},getParams:function KZe(e){return hae},defaultValues:C.getDefaultValues(hae),isApplicable:e=>!!e.volume&&!et.Segmentation.get(e.volume)},gae=st(13421772),yae={...Ia({type:"colors",colorList:"many-distinct"})},eQe={name:"volume-segment",label:"Volume Segment",category:ni.Misc,factory:function bae(e,t){let n,r;const i=e.volume&&et.Segmentation.get(e.volume);if(i){const o=i.segments.size,s=Array.from(i.segments.keys()),a=ac(o,t);r=a.legend,n=c=>et.Segment.isLocation(c)?a.color(s.indexOf(c.segment)):gae}else n=()=>gae;return{factory:bae,granularity:"instance",color:n,props:t,description:"Gives every volume segment a unique color.",legend:r}},getParams:function JZe(e){return C.clone(yae)},defaultValues:C.getDefaultValues(yae),isApplicable:e=>!!e.volume&&!!et.Segmentation.get(e.volume)},vae={volume:C.ValueRef(e=>e.state.data.selectQ(n=>n.root.subtree().filter(r=>{var i;return et.is(null===(i=r.obj)||void 0===i?void 0:i.data)})).map(n=>{var r,i;return[n.transform.ref,null!==(i=null===(r=n.obj)||void 0===r?void 0:r.label)&&void 0!==i?i:""]}),(e,t)=>t(e)),coloring:C.MappedStatic("absolute-value",{"absolute-value":C.Group({domain:C.MappedStatic("auto",{custom:C.Interval([-1,1]),auto:C.Group({symmetric:C.Boolean(!1,{description:"If true the automatic range is determined as [-|max|, |max|]."})})}),list:C.ColorList("red-white-blue",{presetKind:"scale"})}),"relative-value":C.Group({domain:C.MappedStatic("auto",{custom:C.Interval([-1,1]),auto:C.Group({symmetric:C.Boolean(!1,{description:"If true the automatic range is determined as [-|max|, |max|]."})})}),list:C.ColorList("red-white-blue",{presetKind:"scale"})})}),defaultColor:C.Color(st(13421772))},nQe={name:"external-volume",label:"External Volume",category:ni.Misc,factory:function _ae(e,t){let n,r;try{n=t.volume.getValue()}catch{}if(n){const i=t.coloring.params,{stats:o}=n.grid,s="custom"===i.domain.name?i.domain.params:[o.min,o.max],a="relative-value"===t.coloring.name;if("auto"===i.domain.name&&a&&(s[0]=(s[0]-o.mean)/o.sigma,s[1]=(s[1]-o.mean)/o.sigma),"auto"===t.coloring.params.domain.name&&t.coloring.params.domain.params.symmetric){const y=Math.max(Math.abs(s[0]),Math.abs(s[1]));s[0]=-y,s[1]=y}const c=Gu.create({domain:s,listOrName:i.list.colors}),u=Ko.getGridToCartesianTransform(n.grid);le.invert(u,u);const l=v(),{dimensions:d,get:f}=n.grid.cells.space,p=n.grid.cells.data,[m,h,g]=d;r=y=>{if(!function o7e(e){return!!e&&"position-location"===e.kind}(y))return t.defaultColor;v.copy(l,y.position),v.transformMat4(l,l,u);const b=Math.floor(l[0]),x=Math.floor(l[1]),_=Math.floor(l[2]);if(b<0||b>=m||x<0||x>=h||_<0||_>=g)return t.defaultColor;const S=l[0]-b,A=l[1]-x,E=l[2]-_,w=Math.min(b+1,m-1),D=Math.min(x+1,h-1),I=Math.min(_+1,g-1);let R=f(p,b,x,_),T=f(p,w,x,_),M=f(p,b,D,_),N=f(p,w,D,_);const V=ci(ci(R,T,S),ci(M,N,S),A);R=f(p,b,x,I),T=f(p,w,x,I),M=f(p,b,D,I),N=f(p,w,D,I);const F=ci(ci(R,T,S),ci(M,N,S),A);let G=ci(V,F,E);return a&&(G=(G-o.mean)/o.sigma),c.color(G)}}else r=()=>t.defaultColor;return{factory:_ae,granularity:"vertex",preferSmoothing:!0,color:r,props:t,description:"Assigns a color based volume value at a given vertex."}},getParams:()=>vae,defaultValues:C.getDefaultValues(vae),isApplicable:e=>!0},xae={mainchain:C.MappedStatic("molecule-type",{uniform:C.Group(bv),"chain-id":C.Group(ES),"entity-id":C.Group(RS),"entity-source":C.Group(FS),"molecule-type":C.Group(KD),"model-index":C.Group(OS),"structure-index":C.Group(US),"secondary-structure":C.Group(X6)}),sidechain:C.MappedStatic("residue-name",{uniform:C.Group(bv),"residue-name":C.Group(W6),"element-symbol":C.Group(V6)})},aQe={name:"cartoon",label:"Cartoon",category:ni.Misc,factory:function Sae(e,t){var n,r;const i=function oQe(e,t){switch(t.name){case"uniform":return f0(0,t.params);case"chain-id":return PS(e,t.params);case"entity-id":return NS(e,t.params);case"entity-source":return BS(e,t.params);case"molecule-type":return ZD(0,t.params);case"model-index":return LS(e,t.params);case"structure-index":return VS(e,t.params);case"secondary-structure":return K6(e,t.params);default:Rr()}}(e,t.mainchain),o=function sQe(e,t){switch(t.name){case"uniform":return f0(0,t.params);case"residue-name":return $6(0,t.params);case"element-symbol":return z6(e,t.params);default:Rr()}}(e,t.sidechain);let a=i.legend;return"table-legend"===(null===(n=i.legend)||void 0===n?void 0:n.kind)&&"table-legend"===(null===(r=o.legend)||void 0===r?void 0:r.kind)&&(a={kind:"table-legend",table:[...i.legend.table,...o.legend.table]}),{factory:Sae,granularity:"group",preferSmoothing:!1,color:function s(c,u){return u?i.color(c,!1):o.color(c,!1)},props:t,description:"Uses separate themes for coloring mainchain and sidechain visuals.",legend:a}},getParams:function iQe(e){return C.clone(xae)},defaultValues:C.getDefaultValues(xae),isApplicable:e=>!!e.structure};var Lc;!function(e){e.Category=ni,e.PaletteScale=16777215,e.EmptyFactory=()=>e.Empty;const t=st(13421772);e.Empty={factory:e.EmptyFactory,granularity:"uniform",color:()=>t,props:{}},e.areEqual=function n(i,o){return i.contextHash===o.contextHash&&i.factory===o.factory&&Yd(i.props,o.props)},e.EmptyProvider={name:"",label:"",category:"",factory:e.EmptyFactory,getParams:()=>({}),defaultValues:{},isApplicable:()=>!0},e.createRegistry=function r(){return new Eae(e.BuiltIn,e.EmptyProvider)},e.BuiltIn={"atom-id":YZe,"carbohydrate-symbol":dKe,cartoon:aQe,"chain-id":use,"element-index":CKe,"element-symbol":ZKe,"entity-id":RKe,"entity-source":OKe,hydrophobicity:PZe,illustrative:AZe,"model-index":VKe,"molecule-type":eZe,occupancy:OZe,"operator-hkl":VZe,"operator-name":N6,"partial-charge":jZe,"polymer-id":rZe,"polymer-index":sZe,"residue-name":uZe,"secondary-structure":fZe,"sequence-id":gZe,"shape-group":pqe,"structure-index":jKe,"trajectory-index":kZe,uncertainty:_Ze,"unit-index":WKe,uniform:Oje,"volume-segment":eQe,"volume-value":ZZe,"external-volume":nQe}}(Lc||(Lc={}));const Cae={scale:C.Numeric(1,{min:.1,max:5,step:.1})};function n8(e,t){return Ee.isAtomic(e)?v2(e.model.atomicHierarchy.atoms.type_symbol.value(t)):Ee.isSpheres(e)?e.model.coarseConformation.spheres.radius[t]:0}const dQe={name:"physical",label:"Physical",category:"",factory:function wae(e,t){const n=void 0===t.scale?1:t.scale;return{factory:wae,granularity:"group",size:function r(i){let o;return o=nt.is(i)?n*n8(i.unit,i.element):Lt.isLocation(i)?n*Math.min(n8(i.aUnit,i.aUnit.elements[i.aIndex]),n8(i.bUnit,i.bUnit.elements[i.bIndex])):1*n,o},props:t,description:"Assigns a physical size, i.e. vdW radius for atoms or given radius for coarse spheres."}},getParams:function lQe(e){return Cae},defaultValues:C.getDefaultValues(Cae),isApplicable:e=>!!e.structure},Aae={bfactorFactor:C.Numeric(.1,{min:0,max:1,step:.01}),rmsfFactor:C.Numeric(.05,{min:0,max:1,step:.01}),baseSize:C.Numeric(.2,{min:0,max:2,step:.1})};function Iae(e,t,n){return Ee.isAtomic(e)?e.model.atomicConformation.B_iso_or_equiv.value(t)*n.bfactorFactor:Ee.isSpheres(e)?e.model.coarseConformation.spheres.rmsf[t]*n.rmsfFactor:0}const hQe={name:"uncertainty",label:"Uncertainty/Disorder",category:"",factory:function Tae(e,t){return{factory:Tae,granularity:"group",size:function n(r){let i=t.baseSize;return nt.is(r)?i+=Iae(r.unit,r.element,t):Lt.isLocation(r)&&(i+=Iae(r.aUnit,r.aUnit.elements[r.aIndex],t)),i},props:t,description:"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."}},getParams:function pQe(e){return Aae},defaultValues:C.getDefaultValues(Aae),isApplicable:e=>!!e.structure&&e.structure.models.some(t=>t.atomicConformation.B_iso_or_equiv.isDefined||t.coarseHierarchy.isDefined)};var Qo,Fo;function Dae(e){return e.map(t=>[t.name,t.provider.label,t.provider.category])}!function(e){e.EmptyFactory=()=>e.Empty,e.Empty={factory:e.EmptyFactory,granularity:"uniform",size:()=>1,props:{}},e.areEqual=function t(r,i){return r.contextHash===i.contextHash&&r.factory===i.factory&&Yd(r.props,i.props)},e.EmptyProvider={name:"",label:"",category:"",factory:e.EmptyFactory,getParams:()=>({}),defaultValues:{},isApplicable:()=>!0},e.createRegistry=function n(){return new Eae(e.BuiltIn,e.EmptyProvider)},e.BuiltIn={physical:dQe,"shape-group":uqe,uncertainty:hQe,uniform:Vje}}(Qo||(Qo={})),function(e){function n(){return{color:Lc.Empty,size:Qo.Empty}}function i(){return(i=ie(function*(s,a,c,u){var l,d;yield null===(l=a.colorThemeRegistry.get(u.colorTheme.name).ensureCustomProperties)||void 0===l?void 0:l.attach(s,c),yield null===(d=a.sizeThemeRegistry.get(u.sizeTheme.name).ensureCustomProperties)||void 0===d?void 0:d.attach(s,c)})).apply(this,arguments)}e.create=function t(s,a,c,u){u=u||n();const l=c.colorTheme,d=c.sizeTheme;return u.color=s.colorThemeRegistry.create(l.name,a,l.params),u.size=s.sizeThemeRegistry.create(d.name,a,d.params),u},e.createEmpty=n,e.ensureDependencies=function r(s,a,c,u){return i.apply(this,arguments)},e.releaseDependencies=function o(s,a,c){var u,l;null===(u=s.colorThemeRegistry.get(c.colorTheme.name).ensureCustomProperties)||void 0===u||u.detach(a),null===(l=s.sizeThemeRegistry.get(c.sizeTheme.name).ensureCustomProperties)||void 0===l||l.detach(a)}}(Fo||(Fo={}));class Eae{get default(){return this._list[0]}get list(){return this._list}get types(){return Dae(this._list)}constructor(t,n){this.emptyProvider=n,this._list=[],this._map=new Map,this._name=new Map,$a(t,(r,i)=>{if(r.name!==i)throw new Error(`Fix build in themes to have matching names. ${r.name} ${i}`);this.add(r)})}sort(){this._list.sort((t,n)=>t.provider.category===n.provider.category?t.provider.labeln.provider.label?1:0:t.provider.categoryr.name===t.name),1);const n=this._map.get(t.name);n&&(this._map.delete(t.name),this._name.delete(n))}has(t){return this._map.has(t.name)}get(t){return this._map.get(t)||this.emptyProvider}getName(t){if(!this._name.has(t))throw new Error(`'${t.label}' is not a registered theme provider.`);return this._name.get(t)}create(t,n,r={}){const i=this.get(t);return i.factory(n,{...C.getDefaultValues(i.getParams(n)),...r})}getApplicableList(t){return this._list.filter(n=>n.provider.isApplicable(t))}getApplicableTypes(t){return Dae(this.getApplicableList(t))}clear(){this._list.length=0,this._map.clear(),this._name.clear()}}var Us,Bt=function(e){return e[e.None=0]="None",e[e.Highlight=1]="Highlight",e[e.RemoveHighlight=2]="RemoveHighlight",e[e.Select=4]="Select",e[e.Deselect=8]="Deselect",e[e.Toggle=16]="Toggle",e[e.Clear=32]="Clear",e}(Bt||{});function r8(e,t,n){switch(n){case Bt.Highlight:e[t]|=1;break;case Bt.RemoveHighlight:e[t]&=-2;break;case Bt.Select:e[t]|=2;break;case Bt.Deselect:e[t]&=-3;break;case Bt.Toggle:e[t]^=2;break;case Bt.Clear:e[t]=0}}function i8(e,t,n){if(n===Bt.None)return!1;if(Ce.is(t)){const r=Ce.start(t),i=Ce.end(t),o=r+3>>2,s=o+(i-4*o>>2);if(s<=o){for(let f=r;f>2),c=r,u=Math.min(4*o,i),l=Math.max(r,4*s),d=i;switch(n){case Bt.Highlight:for(let f=o;fa(y)).filter(y=>!!y);t.reset();for(const y of g)t.includePositionRadius(y.center,y.radius);t.finishedIncludeStep();for(const y of g)t.radiusPositionRadius(y.center,y.radius);return t.getSphere()},e.areEqual=function r(h,g){return!!(Uc(h)&&Uc(g)||Ta(h)&&Ta(g))||(GS(h)&&GS(g)?function bQe(e,t){if(!Hx(e.data,t.data)||e.tag!==t.tag||e.elements.length!==t.elements.length)return!1;for(let n=0,r=e.elements.length;nh,residue:h=>De.is(h)?De.extendToWholeResidues(h,!0):h,chain:h=>De.is(h)?De.extendToWholeChains(h):h,entity:h=>De.is(h)?De.extendToWholeEntities(h):h,model:h=>De.is(h)?De.extendToWholeModels(h):h,operator:h=>De.is(h)?De.extendToWholeOperators(h):h,structure:h=>De.is(h)?Ve.toStructureElementLoci(h.structure):ra.isLoci(h)?qn.Loci(h.shape):et.Cell.isLoci(h)?et.Loci(h.volume):h,elementInstances:h=>De.is(h)?De.extendToAllInstances(h):h,residueInstances:h=>De.is(h)?De.extendToAllInstances(De.extendToWholeResidues(h,!0)):h,chainInstances:h=>De.is(h)?De.extendToAllInstances(De.extendToWholeChains(h)):h};function p(h,g){return d[g](h)}e.GranularityOptions=C.objectToOptions(d,h=>{switch(h){case"element":return"Atom/Coarse Element";case"elementInstances":return["Atom/Coarse Element Instances","With Symmetry"];case"structure":return"Structure/Shape";default:return h.indexOf("Instances")?[zu(h),"With Symmetry"]:zu(h)}}),e.simpleGranularity=function f(h){return h.replace("Instances","")},e.applyGranularity=p,e.normalize=function m(h,g,y=!1){return("element"!==g||y)&&Lt.isLoci(h)&&(h=Lt.toStructureElementLoci(h)),Ve.isLoci(h)&&(h=Ve.toStructureElementLoci(h.structure)),De.is(h)&&(h=De.remap(h,h.structure.root)),g&&(h=p(h,g)),h}}(pn||(pn={})),function(e){function n(u){return 0===u.layers.length}e.Empty={kind:"empty-loci",layers:[]},e.areEqual=function t(u,l){if(0===u.layers.length&&0===l.layers.length)return!0;if(u.layers.length!==l.layers.length)return!1;for(let d=0,f=u.layers.length;d{const g=-1===h,y=g?st(0):h;p.push({loci:m,color:y,clear:g})}),{kind:"element-loci",layers:p}}return u},e.filter=function o(u,l){if(n(u))return u;if("element-loci"===u.kind){const{structure:d}=u.layers[0].loci,f=[];for(const p of u.layers){let{loci:m,color:h,clear:g}=p;const y=De.remap(m,l);m=De.remap(y,d),De.isEmpty(m)||f.push({loci:m,color:h,clear:g})}return{kind:"element-loci",layers:f}}return u},e.ofScript=function s(u,l){const d=[];for(let f=0,p=u.length;f{p.push({loci:m,value:h})}),{kind:"element-loci",layers:p}}return u},e.filter=function o(u,l){if(n(u))return u;if("element-loci"===u.kind){const{structure:d}=u.layers[0].loci,f=[];for(const p of u.layers){let{loci:m,value:h}=p;const g=De.remap(m,l);m=De.remap(g,d),De.isEmpty(m)||f.push({loci:m,value:h})}return{kind:"element-loci",layers:f}}return u},e.ofScript=function s(u,l){const d=[];for(let f=0,p=u.length;fn.lowestElementCount?"lowest":r>n.lowerElementCount?"lower":r>n.lowElementCount?"low":r>n.mediumElementCount?"medium":r>n.highElementCount?"high":"higher"}function o8(e,t){let n=Ds(e.quality,"auto"),r=Ds(e.detail,1),i=Ds(e.radialSegments,12),o=Ds(e.linearSegments,8),s=Ds(e.resolution,2),a=Ds(e.probePositions,12),c=Ds(e.doubleSided,!0),u=0;if("auto"===n)if(t instanceof Ve)n=Pae(t.root),u=function xQe(e){if(1===e.root.models.length){const t=no.Provider.get(e.root.model);if(t&&"P 1"===t.spacegroup.name&&!ma.isZero(t.spacegroup.cell))return t.spacegroup.cell.volume}return St.volume(e.root.boundary.box)}(t);else if(et.is(t)){const[l,d,f]=t.grid.cells.space.dimensions;u=l*d*f,n=u<1e7?"medium":"low"}switch(n){case"highest":r=3,i=36,o=18,s=.1,a=72,c=!0;break;case"higher":r=3,i=28,o=14,s=.3,a=48,c=!0;break;case"high":r=2,i=20,o=10,s=.5,a=36,c=!0;break;case"medium":r=1,i=12,o=8,s=.8,a=24,c=!0;break;case"low":r=0,i=8,o=3,s=1.3,a=24,c=!1;break;case"lower":r=0,i=4,o=2,s=3,a=12,c=!1;break;case"lowest":r=0,i=2,o=1,s=8,a=12,c=!1}return s=Math.max(s,u/5e8),s=Math.min(s,20),"off"===e.transparentBackfaces&&(void 0!==e.alpha&&e.alpha<1||e.xrayShaded)&&(c=!1),{detail:r,radialSegments:i,linearSegments:o,resolution:s,probePositions:a,doubleSided:c}}const tE=v.set,Mae=v.normalize,Rae=v.sub,kae=v.addScalar,nE=v.scale,Nae=v.toArray;function rE(e,t,n,r){let i=!1;if(et.isLoci(e)){if(!et.areEquivalent(e.volume,t))return!1;r(Ce.ofLength(t.grid.cells.data.length))&&(i=!0)}else if(et.Isosurface.isLoci(e)){if(!et.areEquivalent(e.volume,t))return!1;if(n?.isoValue){if(!et.IsoValue.areSame(e.isoValue,n.isoValue,t.grid.stats))return!1;r(Ce.ofLength(t.grid.cells.data.length))&&(i=!0)}else{const{stats:o,cells:{data:s}}=t.grid,a=o.sigma,c=et.IsoValue.toAbsolute(e.isoValue,o).absoluteValue;for(let u=0,l=s.length;u{r(Ce.ofSingleton(o))&&(i=!0)})}else if(et.Segment.isLoci(e)){if(!et.areEquivalent(e.volume,t))return!1;if(n?.segments){if(!je.areIntersecting(e.segments,n.segments))return!1;r(Ce.ofLength(t.grid.cells.data.length))&&(i=!0)}else{const o=et.Segmentation.get(t);if(o){const s=new Set;for(let u=0,l=e.segments.length;u2)continue;const ge=2-Y,Se=N(ne,we,We);for(let Re=0;Reu)throw new Error("outputStride + itemOffset must NOT be larger than colorStride");const f=e.colorType.endsWith("Instance"),p=f?e.instanceCount:1,m=Po(Math.max(1,p*t),d,Uint8Array),{array:h}=m,[g,y]=o,b=s[0],x=v.fromArray(v(),a,0),_=a[3];function S(I,R,T){const M=Math.floor(T*g%b/g),N=Math.floor(T*g/b);return u*(N*y*b+R*b+(M*g+I))}const A=v(),E=v(),w=v(),D=v();for(let I=0;Is.drawCount.ref.value||i!==s.stride.ref.value)&&k.update(s.aSample,Bae(a,i)),k.updateIfChanged(s.drawCount,a),k.updateIfChanged(s.instanceCount,t.instanceCount),k.updateIfChanged(s.stride,i),k.updateIfChanged(s.uGroupCount,t.groupCount),k.update(s.aTransform,t.transformBuffer),k.update(s.aInstance,t.instanceBuffer),k.update(s.uGeoTexDim,Me.set(s.uGeoTexDim.ref.value,t.positionTexture.getWidth(),t.positionTexture.getHeight())),k.update(s.tPosition,t.positionTexture),k.update(s.tGroup,t.groupTexture),k.update(s.uColorTexDim,Me.set(s.uColorTexDim.ref.value,t.colorData.getWidth(),t.colorData.getHeight())),k.update(s.tColor,t.colorData),k.updateIfChanged(s.dColorType,t.colorType),k.updateIfChanged(s.uCurrentSlice,0),k.updateIfChanged(s.uCurrentX,0),k.updateIfChanged(s.uCurrentY,0),k.update(s.uBboxMin,n.min),k.update(s.uBboxSize,o),k.updateIfChanged(s.uResolution,r),e.namedComputeRenderables[Cu].update()}else e.namedComputeRenderables[Cu]=function OQe(e,t,n,r,i){const o=v.sub(v(),n.max,n.min),s=Math.round(t.vertexCount/i),a={drawCount:k.create(s),instanceCount:k.create(t.instanceCount),stride:k.create(i),uGroupCount:k.create(t.groupCount),aTransform:k.create(t.transformBuffer),aInstance:k.create(t.instanceBuffer),aSample:k.create(Bae(s,i)),uGeoTexDim:k.create(Me.create(t.positionTexture.getWidth(),t.positionTexture.getHeight())),tPosition:k.create(t.positionTexture),tGroup:k.create(t.groupTexture),uColorTexDim:k.create(Me.create(t.colorData.getWidth(),t.colorData.getHeight())),tColor:k.create(t.colorData),dColorType:k.create(t.colorType),uCurrentSlice:k.create(0),uCurrentX:k.create(0),uCurrentY:k.create(0),uBboxMin:k.create(n.min),uBboxSize:k.create(o),uResolution:k.create(r)},c={...FQe};return ji(zi(e,"points",Br("accumulate",NQe,kQe,{drawBuffers:"required"}),c,a),a)}(e,t,n,r,i);return e.namedComputeRenderables[Cu]}(r,e,m,t,n);c.currentRenderItemId=-1,D.bind(),o.drawBuffers([o.COLOR_ATTACHMENT0,o.COLOR_ATTACHMENT1]);const{uCurrentSlice:M,uCurrentX:N,uCurrentY:V}=T.values;lt&&r.timer.mark("ColorAccumulate.render"),function LQe(e){const{gl:t,state:n}=e;n.disable(t.CULL_FACE),n.enable(t.BLEND),n.disable(t.DEPTH_TEST),n.enable(t.SCISSOR_TEST),n.depthMask(!1),n.clearColor(0,0,0,0),n.blendFunc(t.ONE,t.ONE),n.blendEquation(t.FUNC_ADD)}(r),c.viewport(0,0,A,E),c.scissor(0,0,A,E),s.clear(s.COLOR_BUFFER_BIT),k.update(V,0);let F=0,G=0,L=0;for(let $=0;$=w&&(F-=w,G+=_,L=0,k.update(V,G)),k.update(N,L),k.update(M,$),c.viewport(L,G,x,_),c.scissor(L,G,x,_),T.render(),++F,L+=x;I.detachFramebuffer(D,0),R.detachFramebuffer(D,1),o.drawBuffers([s.COLOR_ATTACHMENT0,s.NONE]),lt&&r.timer.markEnd("ColorAccumulate.render"),lt&&r.timer.mark("ColorNormalize.render"),(!i||function bje(e){return e.format===Qre}(i))&&(i=a.texture("image-uint8","rgba","ubyte","linear")),i.define(A,E);const z=function VQe(e,t,n){if(e.namedComputeRenderables[HS]){const r=e.namedComputeRenderables[HS].values;k.update(r.tColor,t),k.update(r.tCount,n),k.update(r.uTexSize,Me.set(r.uTexSize.ref.value,t.getWidth(),t.getHeight())),e.namedComputeRenderables[HS].update()}else e.namedComputeRenderables[HS]=function zQe(e,t,n){const r={..._o,tColor:k.create(t),tCount:k.create(n),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight()))},i={...UQe};return ji(zi(e,"triangles",Br("normalize",ps,RQe),i,r),r)}(e,t,n);return e.namedComputeRenderables[HS]}(r,I,R);c.currentRenderItemId=-1,function GQe(e){const{gl:t,state:n}=e;n.disable(t.CULL_FACE),n.enable(t.BLEND),n.disable(t.DEPTH_TEST),n.enable(t.SCISSOR_TEST),n.depthMask(!1),n.clearColor(0,0,0,0),n.blendFunc(t.ONE,t.ONE),n.blendEquation(t.FUNC_ADD)}(r),i.attachFramebuffer(D,0),c.viewport(0,0,A,E),c.scissor(0,0,A,E),s.clear(s.COLOR_BUFFER_BIT),z.render(),lt&&r.timer.markEnd("ColorNormalize.render");const j=nn.create(b[0],b[1],b[2],h),Z=d?"volumeInstance":"volume";return lt&&r.timer.markEnd("calcTextureMeshColorSmoothing"),{texture:i,gridDim:y,gridTexDim:Me.create(A,E),gridTransform:j,type:Z}}const s8="color-smoothing-rgb",Vv="color-smoothing-rgba",a8="color-smoothing-alpha";function Oae(e,t,n,r,i){if(!function HQe(e){return"group"===e||"groupInstance"===e}(e.dColorType.ref.value))return;n*=3,r.namedTextures[s8]||(r.namedTextures[s8]=r.resources.texture("image-uint8","rgb","ubyte","nearest"));const o=r.namedTextures[s8];o.load(e.tColor.ref.value);const s=sE({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:o,colorType:e.dColorType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value},t,n,r,i);k.updateIfChanged(e.dColorType,s.type),k.update(e.tColorGrid,s.texture),k.update(e.uColorTexDim,s.gridTexDim),k.update(e.uColorGridDim,s.gridDim),k.update(e.uColorGridTransform,s.gridTransform)}var Sn,Lae;function Yr(e,t){return{kind:e,layers:t}}function zs(e,t){return{kind:e,layers:t}}!function(e){e.setVisibility=function t(f,p){f&&(f.state.visible=p)},e.setAlphaFactor=function n(f,p){f&&(f.state.alphaFactor=p)},e.setPickable=function r(f,p){f&&(f.state.pickable=p)},e.setColorOnly=function i(f,p){f&&(f.state.colorOnly=p)},e.mark=function o(f,p,m,h,g){if(!f||Ta(p))return!1;const{tMarker:y,uMarker:b,markerAverage:x,markerStatus:_,uGroupCount:S,instanceCount:A,instanceGranularity:E}=f.values,w=E.ref.value?A.ref.value:S.ref.value*A.ref.value,{array:D}=y.ref.value,I=_.ref.value;if(!Uc(p)){let N=0;if(h(p,V=>(N+=Ce.size(V),!0),!0),0===N)return!1;N===w&&(p=JD)}let R=!1,T=-1,M=-1;if(Uc(p)){const N=function gQe(e,t){let n=-1,r=-1;switch(e){case Bt.Highlight:0===t||1===t?(n=1,r=1):2===t||3===t?(n=1,r=3):n=1;break;case Bt.RemoveHighlight:0===t||1===t?(n=0,r=0):(2===t||3===t)&&(n=1,r=2);break;case Bt.Select:1===t||3===t?(n=1,r=3):0===t||2===t?(n=1,r=2):n=1;break;case Bt.Deselect:1===t||3===t?(n=1,r=1):(0===t||2===t)&&(n=0,r=0);break;case Bt.Toggle:1===t?(n=1,r=3):2===t?(n=0,r=0):3===t?(n=1,r=1):0===t&&(n=1,r=2);break;case Bt.Clear:n=0,r=0}return{average:n,status:r}}(m,I);-1!==N.status?(R=I!==N.status,R&&function mQe(e,t,n){e.fill(t,0,n)}(D,N.status,w)):R=i8(D,Ce.ofLength(w),m),T=N.average,M=N.status}else R=h(p,N=>i8(D,N,m),!0),R&&(T=function yQe(e,t){switch(e){case Bt.Highlight:return.5;case Bt.RemoveHighlight:return 0===t?0:2===t||3===t?.5:-1;case Bt.Select:return.5;case Bt.Deselect:return 1===t||3===t?.5:0===t?0:-1;case Bt.Toggle:return-1===t?-1:.5;case Bt.Clear:return-1===t?-1:0===t?0:.5;case Bt.None:return-1;default:Rr()}}(m,I),g&&-1!==g.status&&-1===T&&Us.isReverse(g.action,m)&&pn.areEqual(p,g.loci)&&(M=g.status,T=0===M?0:.5));return R&&(-1===T&&(T=mre(D,w),0===T&&(M=0)),g&&(g.action=m,g.loci=p,g.status=I),k.updateIfChanged(b,M),-1===M&&k.update(y,y.ref.value),k.updateIfChanged(x,T),k.updateIfChanged(_,M)),R},e.setOverpaint=function s(f,p,m,h,g){if(!f)return;const{tOverpaint:y,dOverpaintType:b,dOverpaint:x,uGroupCount:_,instanceCount:S,instanceGranularity:A}=f.values,E=A.ref.value?S.ref.value:_.ref.value*S.ref.value,w=A.ref.value?"instance":"groupInstance";!function jje(e,t,n){const r=Po(Math.max(1,e),4,Uint8Array,n&&n.tOverpaint.ref.value.array);n?(k.update(n.tOverpaint,r),k.update(n.uOverpaintTexDim,Me.create(r.width,r.height)),k.updateIfChanged(n.dOverpaint,e>0),k.updateIfChanged(n.dOverpaintType,t)):(k.create(r),k.create(Me.create(r.width,r.height)),k.create(e>0),k.create(Os()),k.create(v.create(1,1,1)),k.create(nn.create(0,0,0,1)),k.create(t),k.create(1))}(p.layers.length?E:0,w,f.values);const{array:D}=y.ref.value;h&&sie(D,0,E);for(let I=0,R=p.layers.length;I{const G=Ce.start(F),L=Ce.end(F);return N?sie(D,G,L):Gje(D,G,L,M)},!1)}if(k.update(y,y.ref.value),k.updateIfChanged(b,w),k.updateIfChanged(x,p.layers.length>0),0!==p.layers.length&&"instance"!==w&&g&&Tp(g.props)){const{geometry:I,props:R,webgl:T}=g;if("mesh"===I.kind){const{resolution:M,overpaintTexture:N}=I.meta,V=cl(R.smoothColors,!0,M);V&&(function TQe(e,t,n,r,i){if(!function IQe(e){return"groupInstance"===e}(e.dOverpaintType.ref.value))return;const o=iE({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,positionBuffer:e.aPosition.ref.value,groupBuffer:e.aGroup.ref.value,colorData:e.tOverpaint.ref.value,colorType:e.dOverpaintType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value,itemSize:4},t,n,r,i);"volume"===o.kind?(k.updateIfChanged(e.dOverpaintType,o.type),k.update(e.tOverpaintGrid,o.texture),k.update(e.uOverpaintTexDim,o.gridTexDim),k.update(e.uOverpaintGridDim,o.gridDim),k.update(e.uOverpaintGridTransform,o.gridTransform)):"vertex"===o.kind&&(k.updateIfChanged(e.dOverpaintType,o.type),k.update(e.tOverpaint,o.texture),k.update(e.uOverpaintTexDim,o.texDim))}(f.values,V.resolution,V.stride,T,N),I.meta.overpaintTexture=f.values.tOverpaintGrid.ref.value)}else if(T&&"texture-mesh"===I.kind){const{resolution:M,overpaintTexture:N}=I.meta,V=cl(R.smoothColors,!0,M);V&&(function WQe(e,t,n,r,i){if(!function qQe(e){return"groupInstance"===e}(e.dOverpaintType.ref.value))return;n*=3,r.namedTextures[Vv]||(r.namedTextures[Vv]=r.resources.texture("image-uint8","rgba","ubyte","nearest"));const o=r.namedTextures[Vv];o.load(e.tOverpaint.ref.value);const s=sE({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:o,colorType:e.dOverpaintType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value},t,n,r,i);k.updateIfChanged(e.dOverpaintType,s.type),k.update(e.tOverpaintGrid,s.texture),k.update(e.uOverpaintTexDim,s.gridTexDim),k.update(e.uOverpaintGridDim,s.gridDim),k.update(e.uOverpaintGridTransform,s.gridTransform)}(f.values,V.resolution,V.stride,T,N),I.meta.overpaintTexture=f.values.tOverpaintGrid.ref.value)}}},e.setTransparency=function a(f,p,m,h,g){if(!f)return;const{tTransparency:y,dTransparencyType:b,transparencyAverage:x,dTransparency:_,uGroupCount:S,instanceCount:A,instanceGranularity:E}=f.values,w=E.ref.value?A.ref.value:S.ref.value*A.ref.value,D=E.ref.value?"instance":"groupInstance";!function Wje(e,t,n){const r=Po(Math.max(1,e),1,Uint8Array,n&&n.tTransparency.ref.value.array);n?(k.update(n.tTransparency,r),k.update(n.uTransparencyTexDim,Me.create(r.width,r.height)),k.updateIfChanged(n.dTransparency,e>0),k.updateIfChanged(n.transparencyAverage,cie(r.array,e)),k.updateIfChanged(n.dTransparencyType,t)):(k.create(r),k.create(Me.create(r.width,r.height)),k.create(e>0),k.create(0),k.create(Os()),k.create(v.create(1,1,1)),k.create(nn.create(0,0,0,1)),k.create(t),k.create(1))}(p.layers.length?w:0,D,f.values);const{array:I}=y.ref.value;h&&function qje(e,t,n){e.fill(0,t,n)}(I,0,w);for(let R=0,T=p.layers.length;R{const G=Ce.start(F),L=Ce.end(F);return Hje(I,G,L,N)},!1)}if(k.update(y,y.ref.value),k.updateIfChanged(x,cie(I,w)),k.updateIfChanged(b,D),k.updateIfChanged(_,p.layers.length>0),0!==p.layers.length&&"instance"!==D&&g&&Tp(g.props)){const{geometry:R,props:T,webgl:M}=g;if("mesh"===R.kind){const{resolution:N,transparencyTexture:V}=R.meta,F=cl(T.smoothColors,!0,N);F&&(function EQe(e,t,n,r,i){if(!function DQe(e){return"groupInstance"===e}(e.dTransparencyType.ref.value))return;const o=iE({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,positionBuffer:e.aPosition.ref.value,groupBuffer:e.aGroup.ref.value,colorData:e.tTransparency.ref.value,colorType:e.dTransparencyType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value,itemSize:1},t,n,r,i);"volume"===o.kind?(k.updateIfChanged(e.dTransparencyType,o.type),k.update(e.tTransparencyGrid,o.texture),k.update(e.uTransparencyTexDim,o.gridTexDim),k.update(e.uTransparencyGridDim,o.gridDim),k.update(e.uTransparencyGridTransform,o.gridTransform)):"vertex"===o.kind&&(k.updateIfChanged(e.dTransparencyType,o.type),k.update(e.tTransparency,o.texture),k.update(e.uTransparencyTexDim,o.texDim))}(f.values,F.resolution,F.stride,M,V),R.meta.transparencyTexture=f.values.tTransparencyGrid.ref.value)}else if(M&&"texture-mesh"===R.kind){const{resolution:N,transparencyTexture:V}=R.meta,F=cl(T.smoothColors,!0,N);F&&(function YQe(e,t,n,r,i){if(!function $Qe(e){return"groupInstance"===e}(e.dTransparencyType.ref.value))return;n*=3,r.namedTextures[a8]||(r.namedTextures[a8]=r.resources.texture("image-uint8","alpha","ubyte","nearest"));const o=r.namedTextures[a8];o.load(e.tTransparency.ref.value);const s=sE({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:o,colorType:e.dTransparencyType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value},t,n,r,i);k.updateIfChanged(e.dTransparencyType,s.type),k.update(e.tTransparencyGrid,s.texture),k.update(e.uTransparencyTexDim,s.gridTexDim),k.update(e.uTransparencyGridDim,s.gridDim),k.update(e.uTransparencyGridTransform,s.gridTransform)}(f.values,F.resolution,F.stride,M,V),R.meta.transparencyTexture=f.values.tTransparencyGrid.ref.value)}}},e.setSubstance=function c(f,p,m,h,g){if(!f)return;const{tSubstance:y,dSubstanceType:b,dSubstance:x,uGroupCount:_,instanceCount:S,instanceGranularity:A}=f.values,E=A.ref.value?S.ref.value:_.ref.value*S.ref.value,w=A.ref.value?"instance":"groupInstance";!function Zje(e,t,n){const r=Po(Math.max(1,e),4,Uint8Array,n&&n.tSubstance.ref.value.array);n?(k.update(n.tSubstance,r),k.update(n.uSubstanceTexDim,Me.create(r.width,r.height)),k.updateIfChanged(n.dSubstance,e>0),k.updateIfChanged(n.dSubstanceType,t)):(k.create(r),k.create(Me.create(r.width,r.height)),k.create(e>0),k.create(Os()),k.create(v.create(1,1,1)),k.create(nn.create(0,0,0,1)),k.create(t),k.create(1))}(p.layers.length?E:0,w,f.values);const{array:D}=y.ref.value;h&&die(D,0,E);for(let I=0,R=p.layers.length;I{const G=Ce.start(F),L=Ce.end(F);return N?die(D,G,L):Kje(D,G,L,M)},!1)}if(k.update(y,y.ref.value),k.updateIfChanged(b,w),k.updateIfChanged(x,p.layers.length>0),0!==p.layers.length&&"instance"!==w&&g&&Tp(g.props)){const{geometry:I,props:R,webgl:T}=g;if("mesh"===I.kind){const{resolution:M,substanceTexture:N}=I.meta,V=cl(R.smoothColors,!0,M);V&&(function MQe(e,t,n,r,i){if(!function PQe(e){return"groupInstance"===e}(e.dSubstanceType.ref.value))return;const o=iE({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,positionBuffer:e.aPosition.ref.value,groupBuffer:e.aGroup.ref.value,colorData:e.tSubstance.ref.value,colorType:e.dSubstanceType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value,itemSize:4},t,n,r,i);"volume"===o.kind?(k.updateIfChanged(e.dSubstanceType,o.type),k.update(e.tSubstanceGrid,o.texture),k.update(e.uSubstanceTexDim,o.gridTexDim),k.update(e.uSubstanceGridDim,o.gridDim),k.update(e.uSubstanceGridTransform,o.gridTransform)):"vertex"===o.kind&&(k.updateIfChanged(e.dSubstanceType,o.type),k.update(e.tSubstance,o.texture),k.update(e.uSubstanceTexDim,o.texDim))}(f.values,V.resolution,V.stride,T,N),I.meta.substanceTexture=f.values.tSubstanceGrid.ref.value)}else if(T&&"texture-mesh"===I.kind){const{resolution:M,substanceTexture:N}=I.meta,V=cl(R.smoothColors,!0,M);V&&(function KQe(e,t,n,r,i){if(!function XQe(e){return"groupInstance"===e}(e.dSubstanceType.ref.value))return;n*=3,r.namedTextures[Vv]||(r.namedTextures[Vv]=r.resources.texture("image-uint8","rgba","ubyte","nearest"));const o=r.namedTextures[Vv];o.load(e.tSubstance.ref.value);const s=sE({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:o,colorType:e.dSubstanceType.ref.value,boundingSphere:e.boundingSphere.ref.value,invariantBoundingSphere:e.invariantBoundingSphere.ref.value},t,n,r,i);k.updateIfChanged(e.dSubstanceType,s.type),k.update(e.tSubstanceGrid,s.texture),k.update(e.uSubstanceTexDim,s.gridTexDim),k.update(e.uSubstanceGridDim,s.gridDim),k.update(e.uSubstanceGridTransform,s.gridTransform)}(f.values,V.resolution,V.stride,T,N),I.meta.substanceTexture=f.values.tSubstanceGrid.ref.value)}}},e.setClipping=function u(f,p,m,h){if(!f)return;const{tClipping:g,dClippingType:y,dClipping:b,uGroupCount:x,instanceCount:_,instanceGranularity:S}=f.values,A=S.ref.value?_.ref.value:x.ref.value*_.ref.value,{layers:E}=p,w=S.ref.value?"instance":"groupInstance";!function Xje(e,t,n){const r=Po(Math.max(1,e),1,Uint8Array,n&&n.tClipping.ref.value.array);n?(k.update(n.tClipping,r),k.update(n.uClippingTexDim,Me.create(r.width,r.height)),k.updateIfChanged(n.dClipping,e>0),k.updateIfChanged(n.dClippingType,t)):(k.create(r),k.create(Me.create(r.width,r.height)),k.create(e>0),k.create(t))}(E.length?A:0,w,f.values);const{array:D}=g.ref.value;h&&function Yje(e,t,n){e.fill(0,t,n)}(D,0,A);for(let I=0,R=p.layers.length;I{const F=Ce.start(V),G=Ce.end(V);return $je(D,F,G,M)},!1)}k.update(g,g.ref.value),k.updateIfChanged(y,w),k.updateIfChanged(b,p.layers.length>0)},e.setThemeStrength=function l(f,p){f&&(k.updateIfChanged(f.values.uOverpaintStrength,p.overpaint),k.updateIfChanged(f.values.uTransparencyStrength,p.transparency),k.updateIfChanged(f.values.uSubstanceStrength,p.substance))},e.setTransform=function d(f,p,m){if(!f||!p&&!m)return;const{values:h}=f;p&&(le.copy(h.matrix.ref.value,p),k.update(h.matrix,h.matrix.ref.value)),m?(h.extraTransform.ref.value.set(m),k.update(h.extraTransform,h.extraTransform.ref.value)):null===m&&(vD(h.extraTransform.ref.value,h.instanceCount.ref.value),k.update(h.extraTransform,h.extraTransform.ref.value)),nie(h,h.invariantBoundingSphere.ref.value,h.instanceGrid.ref.value.cellSize,h.instanceGrid.ref.value.batchSize);const g=fs(h.invariantBoundingSphere.ref.value,h.transform.ref.value,h.instanceCount.ref.value,0);k.update(h.boundingSphere,g)}}(Sn||(Sn={})),function(e){let t;function r(l){return 0===l.layers.length}e.Empty={kind:"empty-loci",layers:[]},function(l){let d;var y;function m(y){switch(y){case"one":return d.One;case"two":return d.Two;case"three":return d.Three;case"four":return d.Four;case"five":return d.Five;case"six":return d.Six}}l.is=ea.has,(y=d=l.Flag||(l.Flag={}))[y.None=0]="None",y[y.One=1]="One",y[y.Two=2]="Two",y[y.Three=4]="Three",y[y.Four=8]="Four",y[y.Five=16]="Five",y[y.Six=32]="Six",l.create=function f(y){return ea.create(y)},l.Names={one:d.One,two:d.Two,three:d.Three,four:d.Four,five:d.Five,six:d.Six},l.isName=function p(y){return y in l.Names},l.fromName=m,l.fromNames=function h(y){let b=d.None;for(let x=0,_=y.length;x<_;++x)b|=m(y[x]);return b},l.toNames=function g(y){const b=[];return l.is(y,d.One)&&b.push("one"),l.is(y,d.Two)&&b.push("two"),l.is(y,d.Three)&&b.push("three"),l.is(y,d.Four)&&b.push("four"),l.is(y,d.Five)&&b.push("five"),l.is(y,d.Six)&&b.push("six"),b}}(t=e.Groups||(e.Groups={})),e.areEqual=function n(l,d){if(l.layers.length!==d.layers.length)return!1;for(let f=0,p=l.layers.length;f{m.push({loci:h,groups:g})}),{kind:"element-loci",layers:m}}return l},e.filter=function s(l,d){if(r(l))return l;if("element-loci"===l.kind){const{structure:f}=l.layers[0].loci,p=[];for(const m of l.layers){let{loci:h,groups:g}=m;const y=De.remap(h,d);h=De.remap(y,f),De.isEmpty(h)||p.push({loci:h,groups:g})}return{kind:"element-loci",layers:p}}return l},e.ofScript=function a(l,d){const f=[];for(let p=0,m=l.length;p{m.push({loci:h,material:g,clear:!1})}),{kind:"element-loci",layers:m}}return u},e.filter=function o(u,l){if(n(u))return u;if("element-loci"===u.kind){const{structure:d}=u.layers[0].loci,f=[];for(const p of u.layers){let{loci:m,material:h,clear:g}=p;const y=De.remap(m,l);m=De.remap(y,d),De.isEmpty(m)||f.push({loci:m,material:h,clear:g})}return{kind:"element-loci",layers:f}}return u},e.ofScript=function s(u,l){const d=[];for(let f=0,p=u.length;fyn.Empty,getParams:()=>({}),defaultValues:{},defaultColorTheme:Lc.EmptyProvider,defaultSizeTheme:Qo.EmptyProvider,isApplicable:()=>!0};function Uae(e){return e.map(t=>[t.name,t.provider.label])}class Vae{get default(){return this._list[0]}get types(){return Uae(this._list)}constructor(){this._list=[],this._map=new Map,this._name=new Map}add(t){if(this._map.has(t.name))throw new Error(`${t.name} already registered.`);this._list.push({name:t.name,provider:t}),this._map.set(t.name,t),this._name.set(t,t.name)}getName(t){if(!this._name.has(t))throw new Error(`'${t.label}' is not a registered represenatation provider.`);return this._name.get(t)}remove(t){const n=t.name;this._list.splice(this._list.findIndex(i=>i.name===n),1);const r=this._map.get(n);r&&(this._map.delete(n),this._name.delete(r))}get(t){return this._map.get(t)||ZQe}get list(){return this._list}getApplicableList(t){return this._list.filter(n=>n.provider.isApplicable(t))}getApplicableTypes(t){return Uae(this.getApplicableList(t))}clear(){this._list.length=0,this._map.clear(),this._name.clear()}}var yn;function Jo(e,t,n={}){let r=0;const i=new mr,o=yn.createState(),s=Hp(),a=[];let c,u,l=-1;const d=Fo.createEmpty();let m,h,f=C.getDefaultValues(t.Params);n.modifyState&&yn.updateState(o,n.modifyState(o));const g=Cf.create();function _(S,A){return Uc(S)||qn.isLoci(S)&&S.shape===u?A(Ce.ofBounds(0,f.instanceGranularity?u.transforms.length:u.groupCount*u.transforms.length)):f.instanceGranularity?function x(S,A,E){let w=!1;if(!ra.isLoci(S)||ra.isLociEmpty(S)||S.shape!==A)return!1;for(const D of S.groups)E(Ce.ofSingleton(D.instance))&&(w=!0);return w}(S,u,A):function QQe(e,t,n){if(!ra.isLoci(e)||e.shape!==t)return!1;let r=!1;const{groupCount:i}=t,{groups:o}=e;for(const{ids:s,instance:a}of o)if(Ce.is(s)){const c=a*i+Ce.start(s),u=a*i+Ce.end(s);n(Ce.ofBounds(c,u))&&(r=!0)}else for(let c=0,u=s.length;c[qn.Loci(u)],eachLocation:S=>{for(m.reset();m.hasNext;){const{location:A,isSecondary:E}=m.move();S(A,E)}},mark(S,A){if(!Us.is(o.markerActions,A))return!1;if(ra.isLoci(S)||qn.isLoci(S)){if(S.shape!==u)return!1}else if(!Uc(S))return!1;return Sn.mark(c,S,A,_)},setState(S){n.modifyState&&(S=n.modifyState(S)),c&&(void 0!==S.visible&&Sn.setVisibility(c,S.visible),void 0!==S.alphaFactor&&Sn.setAlphaFactor(c,S.alphaFactor),void 0!==S.pickable&&Sn.setPickable(c,S.pickable),void 0!==S.colorOnly&&Sn.setColorOnly(c,S.colorOnly),void 0!==S.overpaint&&Sn.setOverpaint(c,S.overpaint,_,!0),void 0!==S.transparency&&Sn.setTransparency(c,S.transparency,_,!0),void 0!==S.substance&&Sn.setSubstance(c,S.substance,_,!0),void 0!==S.transform&&Sn.setTransform(c,S.transform)),yn.updateState(o,S)},setTheme(S){un&&console.warn("The `ShapeRepresentation` theme is fixed to `ShapeGroupColorTheme` and `ShapeGroupSizeTheme`. Colors are taken from `Shape.getColor` and sizes from `Shape.getSize`")},destroy(){a.length=0,c&&(c.state.disposed=!0,c=void 0)}}}!function(e){let t;var a;function n(){return{visible:!0,alphaFactor:1,pickable:!0,colorOnly:!1,syncManually:!1,transform:le.identity(),overpaint:Bo.Empty,transparency:Vs.Empty,substance:zs.Empty,clipping:Yr.Empty,themeStrength:{overpaint:1,transparency:1,substance:1},markerActions:Us.All}}function r(a,c){void 0!==c.visible&&(a.visible=c.visible),void 0!==c.alphaFactor&&(a.alphaFactor=c.alphaFactor),void 0!==c.pickable&&(a.pickable=c.pickable),void 0!==c.colorOnly&&(a.colorOnly=c.colorOnly),void 0!==c.overpaint&&(a.overpaint=c.overpaint),void 0!==c.transparency&&(a.transparency=c.transparency),void 0!==c.substance&&(a.substance=c.substance),void 0!==c.clipping&&(a.clipping=c.clipping),void 0!==c.themeStrength&&(a.themeStrength=c.themeStrength),void 0!==c.syncManually&&(a.syncManually=c.syncManually),void 0!==c.transform&&le.copy(a.transform,c.transform),void 0!==c.markerActions&&(a.markerActions=c.markerActions)}(a=t=e.Loci||(e.Loci={})).areEqual=function c(l,d){return l.repr===d.repr&&pn.areEqual(l.loci,d.loci)},a.isEmpty=function u(l){return pn.isEmpty(l.loci)},a.Empty={loci:$n},e.createState=n,e.updateState=r,e.StateBuilder={create:n,update:r},e.Empty={label:"",groupCount:0,renderObjects:[],geometryVersion:-1,props:{},params:{},updated:new mr,state:n(),theme:Fo.createEmpty(),createOrUpdate:()=>Oe.constant("",void 0),setState:()=>{},setTheme:()=>{},getLoci:()=>$n,getAllLoci:()=>[],eachLocation:()=>{},mark:()=>!1,destroy:()=>{}};class i{constructor(){this.curr=new Set,this.next=new Set,this._version=-1}get version(){return this._version}add(c,u){this.next.add(uu(c,u))}snapshot(){Si.areEqual(this.curr,this.next)||(this._version+=1),[this.curr,this.next]=[this.next,this.curr],this.next.clear()}}e.GeometryState=i,e.createMulti=function o(a,c,u,l,d){let f=0;const p=new mr,m=new i,h=l.create();let y,b,x,g=Fo.createEmpty();const _={},S=Object.keys(d).map((A,E)=>{_[E]=A;const w=d[A](c,u);return w.setState(h),w});return{label:a,updated:p,get groupCount(){let A=0;if(b){const{visuals:E}=b;for(let w=0,D=S.length;w{E&&E!==x&&(y=u(c,E),x=E,b||(b=C.getDefaultValues(y)));const w=o8(Object.assign({},b,A),x);Object.assign(b,A,w);const{visuals:D}=b;return Oe.create(`Creating or updating '${a}' representation`,function(){var I=ie(function*(R){for(let T=0,M=S.length;T{const{visuals:E}=b;for(let w=0,D=S.length;w{const A=[],{visuals:E}=b;for(let w=0,D=S.length;w{const{visuals:E}=b;for(let w=0,D=S.length;w{let w=!1;for(let D=0,I=S.length;D{l.update(h,A);for(let E=0,w=S.length;E{g=A;for(let E=0,w=S.length;E{const y=o8(Object.assign({},h,g));return Object.assign(h,g,y),Oe.create(`Updating '${a}' representation`,function(){var b=ie(function*(x){d.add(0,c.id),d.snapshot(),l.next(u++)});return function(x){return b.apply(this,arguments)}}())},get state(){return f},get theme(){return p},getLoci:()=>$n,getAllLoci:()=>[],eachLocation:()=>{},mark:(g,y)=>!1,setState:g=>{void 0!==g.visible&&Sn.setVisibility(c,g.visible),void 0!==g.alphaFactor&&Sn.setAlphaFactor(c,g.alphaFactor),void 0!==g.pickable&&Sn.setPickable(c,g.pickable),void 0!==g.colorOnly&&Sn.setColorOnly(c,g.colorOnly),void 0!==g.themeStrength&&Sn.setThemeStrength(c,g.themeStrength),void 0!==g.transform&&Sn.setTransform(c,g.transform),e.updateState(f,g)},setTheme:()=>{},destroy(){}}}}(yn||(yn={}));const zae=le();class zv{constructor(t){this.structure=t,this.groupUnitTransforms=[],this.unitOffsetMap=Lu.Mutable(),this.groupIndexMap=Lu.Mutable(),this._isIdentity=void 0,this.version=0,this.unitTransforms=new Float32Array(16*t.units.length),this.size=t.units.length,this.reset();let n=0;for(let r=0,i=t.unitSymmetryGroups.length;rJo(aJe,Nt.Utils)},Zae={...iJe};function aJe(e,t,n,r){const i=function sJe(e,t,n){const r=at.createState(256,128,n),{fromFractional:i}=e.symmetry.spacegroup.cell;v.copy(pd,e.ref),"center"===t.attachment?(v.trunc(pd,pd),v.subScalar(pd,pd,.5)):v.floor(pd,pd),le.fromTranslation(Kae,pd);const o=yie(gie(tJe),Kae),s=Math.cbrt(e.symmetry.spacegroup.cell.volume)/300*t.cellScale;r.currentGroup=1,at.addCage(r,i,o,s,2,20);const a=_e.fromDimensionsAndTransform(_e(),v.unit,i);v.transformMat4(pd,pd,i),_e.translate(a,a,pd),_e.expand(a,a,s);const c=at.getMesh(r);return c.setBoundingSphere(a),c}(t,n,r&&r.geometry),o=h2.getUnitcellLabel(t.symmetry);return qn.create(o,t,i,()=>n.cellColor,()=>1,()=>o)}function Qae(e,t,n){const r=v();return"model"===n.ref&&v.transformMat4(r,sn.getCenter(e),t.spacegroup.cell.toFractional),{symmetry:t,ref:r}}const bl=new Uint16Array([0,1,2,1,3,2]),S0=ze.add3,Gs=ze.add2,Jae=ze.add;var wf;!function(e){e.create=function t(n={},r=2048,i=1024,o){r*=2,i*=2;const s=ze.create(Float32Array,3,i,o?o.centerBuffer.ref.value:r),a=ze.create(Float32Array,2,i,o?o.mappingBuffer.ref.value:r),c=ze.create(Float32Array,1,i,o?o.depthBuffer.ref.value:r),u=ze.create(Uint32Array,3,i,o?o.indexBuffer.ref.value:r),l=ze.create(Float32Array,1,i,o?o.groupBuffer.ref.value:r),d=ze.create(Float32Array,2,i,o?o.tcoordBuffer.ref.value:r),f={...C.getDefaultValues(vu.Params),...n},{attachment:p,background:m,backgroundMargin:h,tether:g,tetherLength:y,tetherBaseWidth:b}=f,x=function PHe(e){const t=JSON.stringify(e);return void 0===b5[t]&&(b5[t]=new MHe(e)),b5[t]}(f),_=.4*h,S=x.buffer/x.lineHeight,A=(E,w,D,I,R)=>{S0(s,E,w,D),Jae(c,I),Jae(l,R)};return{add:(E,w,D,I,R,T,M)=>{let N=0;const V=E.length;for(let q=0;q{const E=x.texture,w=ze.compact(s,!0),D=ze.compact(a,!0),I=ze.compact(c,!0),R=ze.compact(u,!0),T=ze.compact(l,!0),M=ze.compact(d,!0);return vu.create(E,w,D,I,R,T,M,u.elementCount/2,o)}}}}(wf||(wf={}));const jv={granularity:"element",condensed:!1,reverse:!1,countsOnly:!1,hidePrefix:!1,htmlStyling:!0};function uE(e,t={}){var n;switch(e.kind){case"structure-loci":return e.structure.models.map(d=>d.entry).filter(d=>!!d).join(", ");case"element-loci":return lE(rf.ofLoci(e),t);case"bond-loci":const r=e.bonds[0];return r?c8(r,t):"";case"shape-loci":return e.shape.name;case"group-loci":const i=e.groups[0];return i?e.shape.getLabel(Fe.start(i.ids),i.instance):"";case"every-loci":return"Everything";case"empty-loci":return"Nothing";case"data-loci":return e.getLabel();case"volume-loci":return e.volume.label||"Volume";case"isosurface-loci":return[`${e.volume.label||"Volume"}`,`Isosurface at ${et.IsoValue.toString(e.isoValue)}`].join(" | ");case"cell-loci":const o=Fe.size(e.indices),s=Fe.start(e.indices),a=et.IsoValue.absolute(e.volume.grid.cells.data[s]),c=et.IsoValue.toRelative(a,e.volume.grid.stats),u=[`${e.volume.label||"Volume"}`,1===o?`Cell #${s}`:`${o} Cells`];return 1===o&&u.push(`${et.IsoValue.toString(a)} (${et.IsoValue.toString(c)})`),u.join(" | ");case"segment-loci":const l=null===(n=et.Segmentation.get(e.volume))||void 0===n?void 0:n.labels;if(l&&1===e.segments.length){const d=l[e.segments[0]];if(d)return d}return[`${e.volume.label||"Volume"}`,1===e.segments.length?`Segment ${e.segments[0]}`:`${e.segments.length} Segments`].join(" | ")}}function Hv(e,t){return 1===e?`1 ${t}`:`${e} ${t}s`}function qS(e,t,n,r,i,o){return`${Jp(t,{granularity:n,hidePrefix:r,reverse:i,condensed:o})} [+ ${Hv(e-1,`other ${Fg(n)}`)}]`}function lE(e,t={}){const n={...jv,...t},r=function lJe(e,t=!1,n=!1,r=!1,i=!1){const{structureCount:o,chainCount:s,residueCount:a,conformationCount:c,elementCount:u}=e;if(!t&&1===u&&0===a&&0===s)return Jp(e.firstElementLoc,{hidePrefix:n,condensed:r,granularity:"element",reverse:i});if(!t&&0===u&&1===a&&0===s)return Jp(e.firstResidueLoc,{hidePrefix:n,condensed:r,granularity:"residue",reverse:i});if(t||0!==u||0!==a||1!==s){if(t){const l=[];return o>0&&l.push(Hv(o,"Structure")),s>0&&l.push(Hv(s,"Chain")),a>0&&l.push(Hv(a,"Residue")),c>0&&l.push(Hv(c,"Conformation")),u>0&&l.push(Hv(u,"Element")),l.join(" + ")}{const l=[];return o>0&&l.push(1===o?Jp(e.firstStructureLoc,{hidePrefix:n,condensed:r,granularity:"structure",reverse:i}):qS(o,e.firstStructureLoc,"structure",n,i,r)),s>0&&(l.push(1===s?Jp(e.firstChainLoc,{condensed:r,granularity:"chain",hidePrefix:n,reverse:i}):qS(s,e.firstChainLoc,"chain",n,i,r)),n=!0),a>0&&(l.push(1===a?Jp(e.firstResidueLoc,{condensed:r,granularity:"residue",hidePrefix:n,reverse:i}):qS(a,e.firstResidueLoc,"residue",n,i,r)),n=!0),c>0&&(l.push(1===c?Jp(e.firstConformationLoc,{condensed:r,granularity:"conformation",hidePrefix:n,reverse:i}):qS(c,e.firstConformationLoc,"conformation",n,i,r)),n=!0),u>0&&l.push(1===u?Jp(e.firstElementLoc,{condensed:r,granularity:"element",hidePrefix:n,reverse:i}):qS(u,e.firstElementLoc,"element",n,i,r)),l.join(" + ")}}{const{unit:l}=e.firstChainLoc,d=Ee.isAtomic(l)&&1===function uJe(e){const{elements:t,model:n}=e,{chainAtomSegments:r,residueAtomSegments:i}=n.atomicHierarchy;return i.index[r.offsets[r.index[t[t.length-1]]+1]-1]-i.index[r.offsets[r.index[t[0]]]]+1}(l)||Ee.Traits.is(l.traits,Ee.Trait.MultiChain)?"residue":"chain";return Jp(e.firstChainLoc,{hidePrefix:n,condensed:r,granularity:d,reverse:i})}}(e,n.countsOnly,n.hidePrefix,n.condensed,n.reverse);return n.htmlStyling?r:IB(r)}function dE(e,t={}){const n=rf.create();for(const r of e)rf.add(n,n,rf.ofLoci(r));return lE(n,t)}function c8(e,t={}){return fE({loci:[De(e.aStructure,[{unit:e.aUnit,indices:Fe.ofSingleton(e.aIndex)}]),De(e.bStructure,[{unit:e.bUnit,indices:Fe.ofSingleton(e.bIndex)}])]},t)}function fE(e,t={}){const n={...jv,...t},r=function dJe(e,t){const{granularity:n,hidePrefix:r,reverse:i,condensed:o}=t;let s=!0;for(const a of e.loci)if(!De.is(a)||1!==De.size(a)){s=!1;break}if(s){const c=e.loci.map(l=>{const{unit:d,indices:f}=l.elements[0];return nt.create(l.structure,d,d.elements[Fe.start(f)])}).map(l=>ece(l,n,r,i||o));if(o)return c.map(l=>l[0].replace(/\[.*\]/g,"").trim()).filter(l=>!!l).join(" \u2014 ");let u=0;for(let l=0,d=Math.min(...c.map(f=>f.length))-1;l0){const l=[c[0].join(" | ")];for(let d=1,f=c.length;d!!p).join(" | "));return l.join(" \u2014 ")}return c.map(l=>l.filter(d=>!!d).join(" | ")).filter(l=>!!l).join("
")}return e.loci.map(c=>uE(c,t)).filter(c=>!!c).join(o?" \u2014 ":"
")}(e,n);return n.htmlStyling?r:IB(r)}function Jp(e,t={}){var n,r;const i={...jv,...t},o=ece(e,i.granularity,i.hidePrefix,i.reverse||i.condensed),s=i.condensed?null!==(r=null===(n=o[0])||void 0===n?void 0:n.replace(/\[.*\]/g,"").trim())&&void 0!==r?r:"":o.filter(a=>!!a).join(" | ");return i.htmlStyling?s:IB(s)}function ece(e,t="element",n=!1,r=!1){const i=[];if(!n){let o=e.unit.model.entry;o.length>30&&(o=o.substr(0,27)+"\u2026"),i.push(`${o}`),"structure"!==t&&(i.push(`Model ${e.unit.model.modelNum}`),i.push(`Instance ${e.unit.conformation.operator.name}`))}return Ee.isAtomic(e.unit)?i.push(...function fJe(e,t,n=!1){const r=nt.residueIndex(e),i=Ze.chain.label_asym_id(e),o=Ze.chain.auth_asym_id(e),s=0===e.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(r),a=Ze.residue.label_seq_id(e),c=Ze.residue.auth_seq_id(e),u=Ze.residue.pdbx_PDB_ins_code(e),l=Ze.atom.label_comp_id(e),d=Ze.atom.label_atom_id(e),f=Ze.atom.label_alt_id(e),p=Ze.atom.occupancy(e),m=Ze.residue.microheterogeneityCompIds(e),h="residue"===t&&m.length>1?`(${m.join("|")})`:l,g=[];switch(t){case"element":g.push(`${d}${f?`%${f}`:""}`);case"conformation":"conformation"===t&&f&&g.push(`Conformation ${f}`);case"residue":const y=a!==c&&s?a:c;g.push(`${h} ${y}${y!==c?` [auth ${c}]`:""}${u||""}`);case"chain":i===o?g.push(`${i}`):"chain"===t&&Ee.Traits.is(e.unit.traits,Ee.Trait.MultiChain)?g.push(`[auth ${o}]`):g.push(`${i} [auth ${o}]`)}return g.length>0&&1!==p&&!n&&(g[0]=`${g[0]} [occupancy ${Math.round(100*p)/100}]`),g.reverse()}(e,t,r)):Ee.isCoarse(e.unit)?i.push(...function pJe(e,t){const n=Ze.coarse.asym_id(e),r=Ze.coarse.seq_id_begin(e),i=Ze.coarse.seq_id_end(e),o=[];switch(t){case"element":case"conformation":case"residue":if(r===i){const s=Ze.coarse.entityKey(e),c=e.unit.model.sequence.byEntityKey[s].sequence.compId.value(r-1);o.push(`${c} ${r}`)}else o.push(`${r}-${i}`);case"chain":o.push(`${n}`)}return o.reverse()}(e,t)):i.push("Unknown"),r?i.reverse():i}function u8(e,t={}){const n={...jv,measureOnly:!1,unitLabel:"\u212b",...t},[r,i]=e.loci.map(a=>pn.getCenter(a)),o=`${v.distance(r,i).toFixed(2)} ${n.unitLabel}`;if(n.measureOnly)return o;const s=fE(e,n);return n.condensed?`${o} | ${s}`:`Distance ${o}
${s}`}function l8(e,t={}){const n={...jv,measureOnly:!1,...t},[r,i,o]=e.loci.map(l=>pn.getCenter(l)),s=v.sub(v(),r,i),a=v.sub(v(),o,i),c=`${su(v.angle(s,a)).toFixed(2)}\xb0`;if(n.measureOnly)return c;const u=fE(e,n);return n.condensed?`${c} | ${u}`:`Angle ${c}
${u}`}function d8(e,t={}){const n={...jv,measureOnly:!1,...t},[r,i,o,s]=e.loci.map(u=>pn.getCenter(u)),a=`${su(v.dihedralAngle(r,i,o,s)).toFixed(2)}\xb0`;if(n.measureOnly)return a;const c=fE(e,n);return n.condensed?`${a} | ${c}`:`Dihedral ${a}
${c}`}const tce={customText:C.Text("",{label:"Text",description:"Override the label with custom value.",isEssential:!0}),textColor:C.Color(xn.black,{isEssential:!0}),textSize:C.Numeric(.5,{min:.1,max:10,step:.1},{isEssential:!0})},pE={...vu.Params,...tce,borderWidth:C.Numeric(.2,{min:0,max:.5,step:.01})},nce={unitLabel:C.Text("\u212b",{isEssential:!0})},hJe={...di.Params,...nce,lineSizeAttenuation:C.Boolean(!0),linesColor:C.Color(xn.lightgreen,{isEssential:!0}),linesSize:C.Numeric(.075,{min:.01,max:5,step:.01}),dashLength:C.Numeric(.2,{min:.01,max:.2,step:.01})},mJe={...pE,...nce},rce={lines:(e,t)=>Jo(bJe,di.Utils,{modifyState:n=>({...n,markerActions:Us.Highlighting})}),text:(e,t)=>Jo(_Je,vu.Utils,{modifyState:n=>({...n,markerActions:Bt.None})})},ice={...hJe,...mJe,visuals:C.MultiSelect(["lines","text"],C.objectToOptions(rce))};function oce(e,t){const{sphereA:n,sphereB:r,center:i}=t,[o,s]=e.loci;return pn.getBoundingSphere(o,n),pn.getBoundingSphere(s,r),v.add(i,n.center,r.center),v.scale(i,i,.5),t.distance=v.distance(n.center,r.center),t}const WS=function gJe(){return{sphereA:_e(),sphereB:_e(),center:v(),distance:0}}();function sce(e,t){return 1===e.pairs.length?`Distance ${u8(e.pairs[0],{unitLabel:t,measureOnly:!0})}`:`${e.pairs.length} Distances`}function bJe(e,t,n,r){const i=function yJe(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.pairs.length;in.linesColor,()=>n.linesSize,a=>u8(t.pairs[a],n))}function _Je(e,t,n,r){const i=function vJe(e,t,n){const r=wf.create(t,128,64,n);for(let i=0,o=e.pairs.length;in.textColor,()=>n.textSize,a=>u8(t.pairs[a],n))}function ace(e){return{pairs:[{loci:[e[0].loci,e[1].loci]}]}}function cce(e){return{triples:[{loci:[e[0].loci,e[1].loci,e[2].loci]}]}}function uce(e){return{quads:[{loci:[e[0].loci,e[1].loci,e[2].loci,e[3].loci]}]}}function lce(e){return{infos:[{loci:e[0].loci}]}}function dce(e){return{locis:e.map(t=>t.loci)}}function fce(e){return{locis:e.map(t=>t.loci)}}const SJe={...pE},pce={text:(e,t)=>Jo(IJe,vu.Utils)},hce={...SJe,scaleByRadius:C.Boolean(!0),visuals:C.MultiSelect(["text"],C.objectToOptions(pce)),snapshotKey:C.Text("",{isEssential:!0,disableInteractiveUpdates:!0,description:"Activate the snapshot with the provided key when clicking on the label"}),tooltip:C.Text("",{isEssential:!0,multiline:!0,disableInteractiveUpdates:!0,placeholder:"Tooltip",description:"Tooltip text to be displayed when hovering over the label"})},CJe=_e();function f8(e,t=!1){return e.label||uE(e.loci,{hidePrefix:!0,htmlStyling:!1,condensed:t})}function IJe(e,t,n,r){var i,o;const s=function AJe(e,t,n){const r=wf.create(t,128,64,n),i=t.customText.trim();for(let o=0,s=e.infos.length;oc:u?d=>u:d=>f8(t.infos[d]),qn.create(a,t,s,()=>n.textColor,()=>n.textSize,l)}const C0=v(),DJe=le.identity(),w0=new Float32Array(18),EJe=new Uint8Array([0,1,2,3,4,5]);v.zero(),v.zero();const _m=v(),MJe=v(),RJe=v(),kJe=v(),NJe=le.identity(),mce=new Float32Array(24),FJe=new Uint8Array([0,1,0,3,0,6,1,2,1,7,2,3,2,4,3,5,4,5,4,7,5,6,6,7]),OJe=le.identity(),gce=v();function p8(e,t,n,r,i,o){at.addPrimitive(e,function LJe(e,t,n,r,i){return v.add(gce,t,n),le.targetTo(e,t,gce,r),le.setTranslation(e,t),le.scale(e,e,i)}(OJe,t,n,r,i),_ie(o))}const h8={color:C.Color(xn.orange),scaleFactor:C.Numeric(1,{min:.1,max:10,step:.1}),radiusScale:C.Numeric(2,{min:.1,max:10,step:.1})},UJe={...Nt.Params,...h8},VJe={...Nt.Params,...h8},zJe={...Nt.Params,...h8},yce={axes:(e,t)=>Jo(HJe,Nt.Utils),box:(e,t)=>Jo($Je,Nt.Utils),ellipsoid:(e,t)=>Jo(KJe,Nt.Utils)},bce={...UJe,...VJe,...zJe,visuals:C.MultiSelect(["box"],C.objectToOptions(yce))};function HJe(e,t,n,r){const i=function jJe(e,t,n){const r=at.createState(256,128,n),i=De.getPrincipalAxesMany(e.locis);return Rs.scale(i.momentsAxes,i.momentsAxes,t.scaleFactor),r.currentGroup=0,function PJe(e,t,n,r,i){const{origin:o,dirA:s,dirB:a,dirC:c}=t;v.add(C0,o,s),v.toArray(v.add(C0,o,s),w0,0),v.toArray(v.sub(C0,o,s),w0,3),v.toArray(v.add(C0,o,a),w0,6),v.toArray(v.sub(C0,o,a),w0,9),v.toArray(v.add(C0,o,c),w0,12),v.toArray(v.sub(C0,o,c),w0,15);const u=fS(w0,EJe),l=Rs.volume(t),d=Math.cbrt(l)/300*n;at.addCage(e,DJe,u,d,r,i)}(r,i.momentsAxes,t.radiusScale,2,20),at.getMesh(r)}(t,n,r&&r.geometry),o=function GJe(e){return`Principal Axes of ${dE(e,{countsOnly:!0})}`}(t.locis);return qn.create(o,t,i,()=>n.color,()=>1,()=>o)}function $Je(e,t,n,r){const i=function WJe(e,t,n){const r=at.createState(256,128,n),i=De.getPrincipalAxesMany(e.locis);return Rs.scale(i.boxAxes,i.boxAxes,t.scaleFactor),r.currentGroup=0,function BJe(e,t,n,r,i){const{origin:o,dirA:s,dirB:a,dirC:c}=t,u=v.negate(MJe,s),l=v.negate(RJe,a),d=v.negate(kJe,c);let f=0;const p=function(y,b,x){v.copy(_m,o),v.add(_m,_m,y),v.add(_m,_m,b),v.add(_m,_m,x),v.toArray(_m,mce,f),f+=3};p(s,a,c),p(s,a,d),p(s,l,d),p(s,l,c),p(u,l,d),p(u,l,c),p(u,a,c),p(u,a,d);const m=fS(mce,FJe),h=Rs.volume(t),g=Math.cbrt(h)/300*n;at.addCage(e,NJe,m,g,r,i)}(r,i.boxAxes,t.radiusScale,2,20),at.getMesh(r)}(t,n,r&&r.geometry),o=function qJe(e){return`Oriented Box of ${dE(e,{countsOnly:!0})}`}(t.locis);return qn.create(o,t,i,()=>n.color,()=>1,()=>o)}function KJe(e,t,n,r){const i=function XJe(e,t,n){const r=at.createState(256,128,n),o=De.getPrincipalAxesMany(e.locis).boxAxes,{origin:s,dirA:a,dirB:c}=o,u=Rs.size(v(),o);v.scale(u,u,.5*t.scaleFactor);const l=v.create(u[2],u[1],u[0]);return r.currentGroup=0,p8(r,s,a,c,l,2),at.getMesh(r)}(t,n,r&&r.geometry),o=function YJe(e){return`Oriented Ellipsoid of ${dE(e,{countsOnly:!0})}`}(t.locis);return qn.create(o,t,i,()=>n.color,()=>1,()=>o)}const QJe={radius:1,segments:36,thetaStart:0,thetaLength:2*Math.PI};function vce(e){const{radius:t,segments:n,thetaStart:r,thetaLength:i}={...QJe,...e},o=i===2*Math.PI,s=o?n+1:n+2,a=new Float32Array(3*s),c=new Float32Array(3*s),u=new Uint32Array(3*n);a[0]=0,a[1]=0,a[2]=0,c[0]=0,c[1]=1,c[2]=0;for(let l=0,d=3;lJo(iet,di.Utils,{modifyState:n=>({...n,pickable:!1})}),arc:(e,t)=>Jo(set,di.Utils,{modifyState:n=>({...n,pickable:!1})}),sector:(e,t)=>Jo(cet,Nt.Utils,{modifyProps:n=>({...n,alpha:n.sectorOpacity}),modifyState:n=>({...n,markerActions:Us.Highlighting})}),text:(e,t)=>Jo(det,vu.Utils,{modifyState:n=>({...n,markerActions:Bt.None})})},Cce={...JJe,...eet,...tet,...pE,visuals:C.MultiSelect(["vectors","sector","text"],C.objectToOptions(Sce))},xm=v(),$S=le();function hE(e,t,n){const{sphereA:r,sphereB:i,sphereC:o}=t,{arcDirA:s,arcDirC:a,arcNormal:c}=t,[u,l,d]=e.loci;pn.getBoundingSphere(u,r),pn.getBoundingSphere(l,i),pn.getBoundingSphere(d,o),v.sub(s,r.center,i.center),v.sub(a,o.center,i.center),v.cross(c,s,a);const p=Math.min(v.magnitude(s),v.magnitude(a))*n;return t.radius=p,t.angle=v.angle(s,a),t}function wce(e,t){const{radius:n,angle:r}=e,i=t?PZ(r,n)/t:32;return le.targetTo($S,e.sphereB.center,e.sphereA.center,e.arcNormal),le.setTranslation($S,e.sphereB.center),le.mul($S,$S,le.rotY180),n5(vce({radius:n,thetaLength:r,segments:i}),$S)}const js=function net(){return{sphereA:_e(),sphereB:_e(),sphereC:_e(),arcDirA:v(),arcDirC:v(),arcNormal:v(),radius:0,angle:0}}();function mE(e){return 1===e.triples.length?`Angle ${l8(e.triples[0],{measureOnly:!0})}`:`${e.triples.length} Angles`}function iet(e,t,n,r){const i=function ret(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.triples.length;in.color,()=>n.linesSize,()=>"")}function set(e,t,n,r){const i=function oet(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.triples.length;in.color,()=>n.linesSize,()=>"")}function cet(e,t,n,r){const i=function aet(e,t,n){const r=at.createState(128,64,n);for(let i=0,o=e.triples.length;in.color,()=>1,a=>l8(t.triples[a]))}function det(e,t,n,r){const i=function uet(e,t,n){const r=wf.create(t,128,64,n);for(let i=0,o=e.triples.length;in.textColor,()=>n.textSize,a=>l8(t.triples[a]))}const Ace={color:C.Color(xn.lightgreen),arcScale:C.Numeric(.7,{min:.01,max:1,step:.01})},gE={...di.Params,...Ace,lineSizeAttenuation:C.Boolean(!0),linesSize:C.Numeric(.04,{min:.01,max:5,step:.01}),dashLength:C.Numeric(.04,{min:.01,max:.2,step:.01})},pet={...gE},het={...gE},met={...gE},get={...gE},yet={...Nt.Params,...Ace,ignoreLight:C.Boolean(!0),sectorOpacity:C.Numeric(.75,{min:0,max:1,step:.01})},Ice={vectors:(e,t)=>Jo(_et,di.Utils,{modifyState:n=>({...n,pickable:!1})}),extenders:(e,t)=>Jo(Tet,di.Utils,{modifyState:n=>({...n,pickable:!1})}),connector:(e,t)=>Jo(Cet,di.Utils,{modifyState:n=>({...n,pickable:!1})}),arms:(e,t)=>Jo(Aet,di.Utils,{modifyState:n=>({...n,pickable:!1})}),arc:(e,t)=>Jo(Eet,di.Utils,{modifyState:n=>({...n,pickable:!1})}),sector:(e,t)=>Jo(Met,Nt.Utils,{modifyProps:n=>({...n,alpha:n.sectorOpacity}),modifyState:n=>({...n,markerActions:Us.Highlighting})}),text:(e,t)=>Jo(ket,vu.Utils,{modifyState:n=>({...n,markerActions:Bt.None})})},Tce={...pet,...het,...met,...get,...yet,...pE,visuals:C.MultiSelect(["extenders","arms","sector","text"],C.objectToOptions(Ice))},Da=v(),YS=le();function A0(e,t,n){const{sphereA:r,sphereB:i,sphereC:o,sphereD:s,dirBA:a,dirCD:c,projA:u,projD:l}=t,{arcPointA:d,arcPointD:f,arcDirA:p,arcDirD:m,arcCenter:h,arcNormal:g}=t,[y,b,x,_]=e.loci;pn.getBoundingSphere(y,r),pn.getBoundingSphere(b,i),pn.getBoundingSphere(x,o),pn.getBoundingSphere(_,s),v.add(h,i.center,o.center),v.scale(h,h,.5),v.sub(a,r.center,i.center),v.sub(c,s.center,o.center),v.add(d,h,a),v.add(f,h,c),v.sub(g,o.center,i.center),v.orthogonalize(p,g,a),v.orthogonalize(m,g,c),v.projectPointOnVector(u,d,p,h),v.projectPointOnVector(l,f,m,h);const A=Math.min(v.distance(u,h),v.distance(l,h))*n;v.setMagnitude(p,p,A),v.setMagnitude(m,m,A),v.add(d,h,p),v.add(f,h,m),t.radius=A,t.angle=v.dihedralAngle(r.center,i.center,o.center,s.center),v.matchDirection(Da,g,v.sub(Da,d,r.center));const E=v.angle(a,Da),w=A/Math.cos(E-Wx);v.add(u,i.center,v.setMagnitude(Da,a,w)),v.matchDirection(Da,g,v.sub(Da,f,s.center));const D=v.angle(c,Da),I=A/Math.cos(D-Wx);return v.add(l,o.center,v.setMagnitude(Da,c,I)),t}function Dce(e,t){const{radius:n,angle:r}=e,i=t?PZ(r,n)/t:32;return le.targetTo(YS,e.arcCenter,r<0?e.arcPointD:e.arcPointA,e.arcNormal),le.setTranslation(YS,e.arcCenter),le.mul(YS,YS,le.rotY180),n5(vce({radius:n,thetaLength:Math.abs(r),segments:i}),YS)}const Xr=function bet(){return{sphereA:_e(),sphereB:_e(),sphereC:_e(),sphereD:_e(),dirBA:v(),dirCD:v(),projA:v(),projD:v(),arcPointA:v(),arcPointD:v(),arcDirA:v(),arcDirD:v(),arcCenter:v(),arcNormal:v(),radius:0,angle:0}}();function I0(e){return 1===e.quads.length?`Dihedral ${d8(e.quads[0],{measureOnly:!0})}`:`${e.quads.length} Dihedrals`}function _et(e,t,n,r){const i=function vet(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.quads.length;in.color,()=>n.linesSize,()=>"")}function Cet(e,t,n,r){const i=function xet(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.quads.length;in.color,()=>n.linesSize,()=>"")}function Aet(e,t,n,r){const i=function wet(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.quads.length;in.color,()=>n.linesSize,()=>"")}function Tet(e,t,n,r){const i=function Iet(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.quads.length;in.color,()=>n.linesSize,()=>"")}function Eet(e,t,n,r){const i=function Det(e,t,n){const r=Fc.create(128,64,n);for(let i=0,o=e.quads.length;in.color,()=>n.linesSize,()=>"")}function Met(e,t,n,r){const i=function Pet(e,t,n){const r=at.createState(128,64,n);for(let i=0,o=e.quads.length;in.color,()=>1,a=>d8(t.quads[a]))}function ket(e,t,n,r){const i=function Ret(e,t,n){const r=wf.create(t,128,64,n);for(let i=0,o=e.quads.length;in.textColor,()=>n.textSize,a=>d8(t.quads[a]))}const Fet=Rt.BuiltIn({name:"box-shape-3d",display:"Box Shape",from:pe.Root,to:pe.Shape.Provider,params:{bottomLeft:C.Vec3(v()),topRight:C.Vec3(v.create(1,1,1)),radius:C.Numeric(.15,{min:.01,max:4,step:.01}),color:C.Color(xn.red)}})({canAutoUpdate:()=>!0,apply:({params:e})=>Oe.create("Shape Representation",function(){var t=ie(function*(n){return new pe.Shape.Provider({label:"Box",data:e,params:Nt.Params,getShape:(r,i)=>{const o=m8(St.create(e.bottomLeft,e.topRight),e.radius);return qn.create("Box",i,o,()=>i.color,()=>1,()=>"Box")},geometryUtils:Nt.Utils},{label:"Box"})});return function(n){return t.apply(this,arguments)}}())});function m8(e,t,n){const r=v.sub(v(),e.max,e.min),i=le.fromTranslation(le(),v.create(.5,.5,.5)),o=le.fromScaling(le(),r),s=le.fromTranslation(le(),e.min),a=le.mul3(le(),s,o,i),c=at.createState(256,128,n);c.currentGroup=1,at.addCage(c,a,Uie(),t,2,20);const u=at.getMesh(c),l=v.scaleAndAdd(v(),e.min,r,.5),d=v.distance(e.min,l);return u.setBoundingSphere(_e.create(l,d)),u}const Ece={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])};new Uint32Array([0,1,2,3,3,1,2,0]);const Let={...Nt.Params,color:C.Color(xn.orange),scaleFactor:C.Numeric(1,{min:.1,max:10,step:.1})},Pce={plane:(e,t)=>Jo(zet,Nt.Utils)},Mce={...Let,visuals:C.MultiSelect(["plane"],C.objectToOptions(Pce))},Sm=le(),g8=v();function zet(e,t,n,r){const i=function Vet(e,t,n){const r=at.createState(256,128,n),o=De.getPrincipalAxesMany(e.locis).boxAxes,s=function Oet(){return Ece}();return v.add(g8,o.origin,o.dirC),le.targetTo(Sm,g8,o.origin,o.dirB),le.scale(Sm,Sm,Rs.size(g8,o)),le.scaleUniformly(Sm,Sm,t.scaleFactor),le.setTranslation(Sm,o.origin),r.currentGroup=0,at.addPrimitive(r,Sm,s),at.addPrimitiveFlipped(r,Sm,s),at.getMesh(r)}(t,n,r&&r.geometry),o=function Uet(e){return`Best Fit Plane of ${dE(e,{countsOnly:!0})}`}(t.locis);return qn.create(o,t,i,()=>n.color,()=>1,()=>o)}const yE=Rt.BuiltIn({name:"structure-representation-3d",display:"3D Representation",from:pe.Molecule.Structure,to:pe.Molecule.Structure.Representation3D,params:(e,t)=>{const{registry:n,themes:r}=t.representation.structure,i=n.get(n.default.name);if(!e){const a={help:c=>{const{name:u,params:l}=c,f=r.colorThemeRegistry.get(u).factory({},l);return{description:f.description,legend:f.legend}}};return{type:C.Mapped(n.default.name,n.types,c=>C.Group(n.get(c).getParams(r,Ve.Empty))),colorTheme:C.Mapped(i.defaultColorTheme.name,r.colorThemeRegistry.types,c=>C.Group(r.colorThemeRegistry.get(c).getParams({structure:Ve.Empty})),a),sizeTheme:C.Mapped(i.defaultSizeTheme.name,r.sizeThemeRegistry.types,c=>C.Group(r.sizeThemeRegistry.get(c).getParams({structure:Ve.Empty})))}}const o={structure:e.data},s={help:a=>{const{name:c,params:u}=a,d=r.colorThemeRegistry.get(c).factory(o,u);return{description:d.description,legend:d.legend}}};return{type:C.Mapped(n.default.name,n.getApplicableTypes(e.data),a=>C.Group(n.get(a).getParams(r,e.data))),colorTheme:C.Mapped(i.defaultColorTheme.name,r.colorThemeRegistry.getApplicableTypes(o),a=>C.Group(r.colorThemeRegistry.get(a).getParams(o)),s),sizeTheme:C.Mapped(i.defaultSizeTheme.name,r.sizeThemeRegistry.getApplicableTypes(o),a=>C.Group(r.sizeThemeRegistry.get(a).getParams(o)))}}})({canAutoUpdate:({a:e,oldParams:t,newParams:n})=>e.data.elementCount<1e4||t.type.name===n.type.name&&"custom"!==n.type.params.quality,apply:({a:e,params:t},r)=>Oe.create("Structure Representation",function(){var i=ie(function*(o){var s,a;const c={runtime:o,assetManager:r.managers.asset},u=r.representation.structure.registry.get(t.type.name),l=(null===(s=u.getData)||void 0===s?void 0:s.call(u,e.data,t.type.params))||e.data;u.ensureCustomProperties&&(yield u.ensureCustomProperties.attach(c,l));const d=u.factory({webgl:null===(a=r.canvas3d)||void 0===a?void 0:a.webgl,...r.representation.structure.themes},u.getParams);yield Fo.ensureDependencies(c,r.representation.structure.themes,{structure:l},t),d.setTheme(Fo.create(r.representation.structure.themes,{structure:l},t));const f=t.type.params||{};return yield d.createOrUpdate(f,l).runInContext(o),new pe.Molecule.Structure.Representation3D({repr:d,sourceData:e.data},{label:u.label})});return function(o){return i.apply(this,arguments)}}()),update:({a:e,b:t,oldParams:n,newParams:r},o)=>Oe.create("Structure Representation",function(){var s=ie(function*(a){var c,u;if(r.type.name!==n.type.name)return Qe.UpdateResult.Recreate;const l=o.representation.structure.registry.get(r.type.name);if(null!==(c=l.mustRecreate)&&void 0!==c&&c.call(l,n.type.params,r.type.params))return Qe.UpdateResult.Recreate;const d=(null===(u=l.getData)||void 0===u?void 0:u.call(l,e.data,r.type.params))||e.data,f={runtime:a,assetManager:o.managers.asset};l.ensureCustomProperties&&(yield l.ensureCustomProperties.attach(f,d)),Fo.releaseDependencies(o.representation.structure.themes,{structure:t.data.sourceData},n),yield Fo.ensureDependencies(f,o.representation.structure.themes,{structure:d},r),t.data.repr.setTheme(Fo.create(o.representation.structure.themes,{structure:d},r));const p={...t.data.repr.props,...r.type.params};return yield t.data.repr.createOrUpdate(p,d).runInContext(a),t.data.sourceData=e.data,Qe.UpdateResult.Updated});return function(a){return s.apply(this,arguments)}}()),dispose({b:e,params:t},n){if(!e||!t)return;const r=e.data.sourceData,i=n.representation.structure.registry.get(t.type.name);i.ensureCustomProperties&&i.ensureCustomProperties.detach(r),Fo.releaseDependencies(n.representation.structure.themes,{structure:r},t)},interpolate(e,t,n){if("uniform"!==e.colorTheme.name||"uniform"!==t.colorTheme.name)return n<=.5?e:t;const o=st.interpolate(e.colorTheme.params.value,t.colorTheme.params.value,n);return{type:n<=.5?e.type:t.type,colorTheme:{name:"uniform",params:{value:o}},sizeTheme:n<=.5?e.sizeTheme:t.sizeTheme}}}),jet=Rt.BuiltIn({name:"unwind-structure-assembly-representation-3d",display:"Unwind Assembly 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:{t:C.Numeric(0,{min:0,max:1,step:.01})}})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=new zv(n);return jae(n,r,t.t),new pe.Molecule.Structure.Representation3DState({state:{unitTransforms:r},initialState:{unitTransforms:new zv(n)},info:n,repr:e.data.repr},{label:`Unwind T = ${t.t.toFixed(2)}`})},update({a:e,b:t,newParams:n,oldParams:r}){const i=t.data.info;return e.data.sourceData!==i||e.data.repr!==t.data.repr?Qe.UpdateResult.Recreate:r.t===n.t?Qe.UpdateResult.Unchanged:(jae(i,t.data.state.unitTransforms,n.t),t.label=`Unwind T = ${n.t.toFixed(2)}`,t.data.repr=e.data.repr,Qe.UpdateResult.Updated)}}),Het=Rt.BuiltIn({name:"explode-structure-representation-3d",display:"Explode 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:{t:C.Numeric(0,{min:0,max:1,step:.01})}})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=new zv(n);return qae(n,r,t.t,n.root.boundary.sphere),new pe.Molecule.Structure.Representation3DState({state:{unitTransforms:r},initialState:{unitTransforms:new zv(n)},info:n,repr:e.data.repr},{label:`Explode T = ${t.t.toFixed(2)}`})},update({a:e,b:t,newParams:n,oldParams:r}){const i=e.data.sourceData;return t.data.info!==i||e.data.repr!==t.data.repr?Qe.UpdateResult.Recreate:r.t===n.t?Qe.UpdateResult.Unchanged:(qae(i,t.data.state.unitTransforms,n.t,i.root.boundary.sphere),t.label=`Explode T = ${n.t.toFixed(2)}`,t.data.repr=e.data.repr,Qe.UpdateResult.Updated)}}),qet=Rt.BuiltIn({name:"spin-structure-representation-3d",display:"Spin 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:{t:C.Numeric(0,{min:0,max:1,step:.01}),...JQe}})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=new zv(n),{axis:i,origin:o}=Wae(n.root,t);return Xae(n,r,t.t,i,o),new pe.Molecule.Structure.Representation3DState({state:{unitTransforms:r},initialState:{unitTransforms:new zv(n)},info:n,repr:e.data.repr},{label:`Spin T = ${t.t.toFixed(2)}`})},update({a:e,b:t,newParams:n,oldParams:r}){const i=e.data.sourceData;if(t.data.info!==i||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;if(r.t===n.t&&r.axis===n.axis&&r.origin===n.origin)return Qe.UpdateResult.Unchanged;const o=t.data.state.unitTransforms,{axis:s,origin:a}=Wae(i.root,n);return Xae(i,o,n.t,s,a),t.label=`Spin T = ${n.t.toFixed(2)}`,t.data.repr=e.data.repr,Qe.UpdateResult.Updated}}),Wet=Rt.BuiltIn({name:"overpaint-structure-representation-3d-from-script",display:"Overpaint 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({script:C.Script(ko("(sel.atom.all)","mol-script")),color:C.Color(xn.blueviolet),clear:C.Boolean(!1)},e=>`${e.clear?"Clear":st.toRgbString(e.color)}`,{defaultValue:[{script:ko("(sel.atom.all)","mol-script"),color:xn.blueviolet,clear:!1}]})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=e.data.repr.geometryVersion,i=Bo.ofScript(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{overpaint:i},initialState:{overpaint:Bo.Empty},info:{structure:n,geometryVersion:r},repr:e.data.repr},{label:`Overpaint (${i.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info,o=e.data.sourceData;if(o!==i.structure||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const s=e.data.repr.geometryVersion;if(s!==i.geometryVersion&&Tp(e.data.repr.props))return Qe.UpdateResult.Recreate;const a=t.data.state.overpaint,c=Bo.ofScript(n.layers,o);return Bo.areEqual(a,c)?Qe.UpdateResult.Unchanged:(i.geometryVersion=s,t.data.state.overpaint=c,t.data.repr=e.data.repr,t.label=`Overpaint (${c.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),$et=Rt.BuiltIn({name:"overpaint-structure-representation-3d-from-bundle",display:"Overpaint 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({bundle:C.Value(Kn.Empty),color:C.Color(xn.blueviolet),clear:C.Boolean(!1)},e=>`${e.clear?"Clear":st.toRgbString(e.color)}`,{defaultValue:[{bundle:Kn.Empty,color:xn.blueviolet,clear:!1}],isHidden:!0})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=e.data.repr.geometryVersion,i=Bo.ofBundle(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{overpaint:i},initialState:{overpaint:Bo.Empty},info:{structure:n,geometryVersion:r},repr:e.data.repr},{label:`Overpaint (${i.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info,o=e.data.sourceData;if(o!==i.structure||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const s=e.data.repr.geometryVersion;if(s!==i.geometryVersion&&Tp(e.data.repr.props))return Qe.UpdateResult.Recreate;const a=t.data.state.overpaint,c=Bo.ofBundle(n.layers,o);return Bo.areEqual(a,c)?Qe.UpdateResult.Unchanged:(i.geometryVersion=s,t.data.state.overpaint=c,t.data.repr=e.data.repr,t.label=`Overpaint (${c.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),Yet=Rt.BuiltIn({name:"transparency-structure-representation-3d-from-script",display:"Transparency 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({script:C.Script(ko("(sel.atom.all)","mol-script")),value:C.Numeric(.5,{min:0,max:1,step:.01},{label:"Transparency"})},e=>`Transparency (${e.value})`,{defaultValue:[{script:ko("(sel.atom.all)","mol-script"),value:.5}]})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=e.data.repr.geometryVersion,i=Vs.ofScript(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{transparency:i},initialState:{transparency:Vs.Empty},info:{structure:n,geometryVersion:r},repr:e.data.repr},{label:`Transparency (${i.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info,o=e.data.sourceData;if(o!==i.structure||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const s=e.data.repr.geometryVersion;if(s!==i.geometryVersion&&Tp(e.data.repr.props))return Qe.UpdateResult.Recreate;const a=t.data.state.transparency,c=Vs.ofScript(n.layers,o);return Vs.areEqual(a,c)?Qe.UpdateResult.Unchanged:(i.geometryVersion=s,t.data.state.transparency=c,t.data.repr=e.data.repr,t.label=`Transparency (${c.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),Xet=Rt.BuiltIn({name:"transparency-structure-representation-3d-from-bundle",display:"Transparency 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({bundle:C.Value(Kn.Empty),value:C.Numeric(.5,{min:0,max:1,step:.01},{label:"Transparency"})},e=>`Transparency (${e.value})`,{defaultValue:[{bundle:Kn.Empty,value:.5}],isHidden:!0})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=e.data.repr.geometryVersion,i=Vs.ofBundle(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{transparency:i},initialState:{transparency:Vs.Empty},info:{structure:n,geometryVersion:r},repr:e.data.repr},{label:`Transparency (${i.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info,o=e.data.sourceData;if(o!==i.structure||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const s=e.data.repr.geometryVersion;if(s!==i.geometryVersion&&Tp(e.data.repr.props))return Qe.UpdateResult.Recreate;const a=t.data.state.transparency,c=Vs.ofBundle(n.layers,o);return Vs.areEqual(a,c)?Qe.UpdateResult.Unchanged:(i.geometryVersion=s,t.data.state.transparency=c,t.data.repr=e.data.repr,t.label=`Transparency (${c.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),Ket=Rt.BuiltIn({name:"substance-structure-representation-3d-from-script",display:"Substance 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({script:C.Script(ko("(sel.atom.all)","mol-script")),material:ba.getParam(),clear:C.Boolean(!1)},e=>`${e.clear?"Clear":ba.toString(e.material)}`,{defaultValue:[{script:ko("(sel.atom.all)","mol-script"),material:ba({roughness:1}),clear:!1}]})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=e.data.repr.geometryVersion,i=zs.ofScript(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{substance:i},initialState:{substance:zs.Empty},info:{structure:n,geometryVersion:r},repr:e.data.repr},{label:`Substance (${i.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info,o=e.data.sourceData;if(o!==i.structure||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const s=e.data.repr.geometryVersion;if(s!==i.geometryVersion&&Tp(e.data.repr.props))return Qe.UpdateResult.Recreate;const a=t.data.state.substance,c=zs.ofScript(n.layers,o);return zs.areEqual(a,c)?Qe.UpdateResult.Unchanged:(i.geometryVersion=s,t.data.state.substance=c,t.data.repr=e.data.repr,t.label=`Substance (${c.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),Zet=Rt.BuiltIn({name:"substance-structure-representation-3d-from-bundle",display:"Substance 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({bundle:C.Value(Kn.Empty),material:ba.getParam(),clear:C.Boolean(!1)},e=>`${e.clear?"Clear":ba.toString(e.material)}`,{defaultValue:[{bundle:Kn.Empty,material:ba({roughness:1}),clear:!1}],isHidden:!0})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=e.data.repr.geometryVersion,i=zs.ofBundle(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{substance:i},initialState:{substance:zs.Empty},info:{structure:n,geometryVersion:r},repr:e.data.repr},{label:`Substance (${i.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info,o=e.data.sourceData;if(o!==i.structure||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const s=e.data.repr.geometryVersion;if(s!==i.geometryVersion&&Tp(e.data.repr.props))return Qe.UpdateResult.Recreate;const a=t.data.state.substance,c=zs.ofBundle(n.layers,o);return zs.areEqual(a,c)?Qe.UpdateResult.Unchanged:(i.geometryVersion=s,t.data.state.substance=c,t.data.repr=e.data.repr,t.label=`Substance (${c.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),Qet=Rt.BuiltIn({name:"clipping-structure-representation-3d-from-script",display:"Clipping 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({script:C.Script(ko("(sel.atom.all)","mol-script")),groups:C.Converted(e=>Yr.Groups.toNames(e),e=>Yr.Groups.fromNames(e),C.MultiSelect(RI(Yr.Groups.Names),C.objectToOptions(Yr.Groups.Names)))},e=>`${Yr.Groups.toNames(e.groups).length} group(s)`,{defaultValue:[{script:ko("(sel.atom.all)","mol-script"),groups:Yr.Groups.Flag.None}]})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=Yr.ofScript(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{clipping:r},initialState:{clipping:Yr.Empty},info:n,repr:e.data.repr},{label:`Clipping (${r.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info;if(e.data.sourceData!==i||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const o=t.data.state.clipping,s=Yr.ofScript(n.layers,i);return Yr.areEqual(o,s)?Qe.UpdateResult.Unchanged:(t.data.state.clipping=s,t.data.repr=e.data.repr,t.label=`Clipping (${s.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),Jet=Rt.BuiltIn({name:"clipping-structure-representation-3d-from-bundle",display:"Clipping 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({layers:C.ObjectList({bundle:C.Value(Kn.Empty),groups:C.Converted(e=>Yr.Groups.toNames(e),e=>Yr.Groups.fromNames(e),C.MultiSelect(RI(Yr.Groups.Names),C.objectToOptions(Yr.Groups.Names)))},e=>`${Yr.Groups.toNames(e.groups).length} group(s)`,{defaultValue:[{bundle:Kn.Empty,groups:Yr.Groups.Flag.None}],isHidden:!0})})})({canAutoUpdate:()=>!0,apply({a:e,params:t}){const n=e.data.sourceData,r=Yr.ofBundle(t.layers,n);return new pe.Molecule.Structure.Representation3DState({state:{clipping:r},initialState:{clipping:Yr.Empty},info:n,repr:e.data.repr},{label:`Clipping (${r.layers.length} Layers)`})},update({a:e,b:t,newParams:n}){const i=t.data.info;if(e.data.sourceData!==i||e.data.repr!==t.data.repr)return Qe.UpdateResult.Recreate;const o=t.data.state.clipping,s=Yr.ofBundle(n.layers,i);return Yr.areEqual(o,s)?Qe.UpdateResult.Unchanged:(t.data.state.clipping=s,t.data.repr=e.data.repr,t.label=`Clipping (${s.layers.length} Layers)`,Qe.UpdateResult.Updated)}}),ett=Rt.BuiltIn({name:"theme-strength-representation-3d",display:"Theme Strength 3D Representation",from:pe.Molecule.Structure.Representation3D,to:pe.Molecule.Structure.Representation3DState,params:()=>({overpaintStrength:C.Numeric(1,{min:0,max:1,step:.01}),transparencyStrength:C.Numeric(1,{min:0,max:1,step:.01}),substanceStrength:C.Numeric(1,{min:0,max:1,step:.01})})})({canAutoUpdate:()=>!0,apply:({a:e,params:t})=>new pe.Molecule.Structure.Representation3DState({state:{themeStrength:{overpaint:t.overpaintStrength,transparency:t.transparencyStrength,substance:t.substanceStrength}},initialState:{themeStrength:{overpaint:1,transparency:1,substance:1}},info:{},repr:e.data.repr},{label:"Theme Strength",description:`${t.overpaintStrength.toFixed(2)}, ${t.transparencyStrength.toFixed(2)}, ${t.substanceStrength.toFixed(2)}`}),update({a:e,b:t,newParams:n}){var i,o,s;return n.overpaintStrength===(null===(i=t.data.state.themeStrength)||void 0===i?void 0:i.overpaint)&&n.transparencyStrength===(null===(o=t.data.state.themeStrength)||void 0===o?void 0:o.transparency)&&n.substanceStrength===(null===(s=t.data.state.themeStrength)||void 0===s?void 0:s.substance)?Qe.UpdateResult.Unchanged:(t.data.state.themeStrength={overpaint:n.overpaintStrength,transparency:n.transparencyStrength,substance:n.substanceStrength},t.data.repr=e.data.repr,t.label="Theme Strength",t.description=`${n.overpaintStrength.toFixed(2)}, ${n.transparencyStrength.toFixed(2)}, ${n.substanceStrength.toFixed(2)}`,Qe.UpdateResult.Updated)},interpolate:(e,t,n)=>({overpaintStrength:ci(e.overpaintStrength,t.overpaintStrength,n),transparencyStrength:ci(e.transparencyStrength,t.transparencyStrength,n),substanceStrength:ci(e.substanceStrength,t.substanceStrength,n)})});var Af;!function(e){e.getDefaultParams=function t(i,o,s,a,c,u,l,d){const f=i.representation.volume.registry.get(o),p=i.representation.volume.themes.colorThemeRegistry.get(c||f.defaultColorTheme.name),m=i.representation.volume.themes.sizeThemeRegistry.get(l||f.defaultSizeTheme.name),h=C.getDefaultValues(f.getParams(i.representation.volume.themes,s));return{type:{name:o,params:a?{...h,...a}:h},colorTheme:{name:p.name,params:u?{...p.defaultValues,...u}:p.defaultValues},sizeTheme:{name:m.name,params:d?{...m.defaultValues,...d}:m.defaultValues}}},e.getDefaultParamsStatic=function n(i,o,s,a,c,u,l){const d=i.representation.volume.registry.get(o),f=i.representation.volume.themes.colorThemeRegistry.get(a||d.defaultColorTheme.name),p=i.representation.volume.themes.sizeThemeRegistry.get(u||d.defaultSizeTheme.name);return{type:{name:o,params:s?{...d.defaultValues,...s}:d.defaultValues},colorTheme:{name:d.defaultColorTheme.name,params:c?{...f.defaultValues,...c}:f.defaultValues},sizeTheme:{name:d.defaultSizeTheme.name,params:l?{...p.defaultValues,...l}:p.defaultValues}}},e.getDescription=function r(i){var o,s,a,c;return i.isoValue?et.IsoValue.toString(i.isoValue):null!==(s=null===(o=i.renderMode)||void 0===o?void 0:o.params)&&void 0!==s&&s.isoValue?et.IsoValue.toString(null===(c=null===(a=i.renderMode)||void 0===a?void 0:a.params)||void 0===c?void 0:c.isoValue):void 0}}(Af||(Af={}));const ttt=Rt.BuiltIn({name:"volume-representation-3d",display:"3D Representation",from:pe.Volume.Data,to:pe.Volume.Representation3D,params:(e,t)=>{const{registry:n,themes:r}=t.representation.volume,i=n.get(n.default.name);if(!e)return{type:C.Mapped(n.default.name,n.types,s=>C.Group(n.get(s).getParams(r,et.One))),colorTheme:C.Mapped(i.defaultColorTheme.name,r.colorThemeRegistry.types,s=>C.Group(r.colorThemeRegistry.get(s).getParams({volume:et.One}))),sizeTheme:C.Mapped(i.defaultSizeTheme.name,r.sizeThemeRegistry.types,s=>C.Group(r.sizeThemeRegistry.get(s).getParams({volume:et.One})))};const o={volume:e.data};return{type:C.Mapped(n.default.name,n.types,s=>C.Group(n.get(s).getParams(r,e.data))),colorTheme:C.Mapped(i.defaultColorTheme.name,r.colorThemeRegistry.getApplicableTypes(o),s=>C.Group(r.colorThemeRegistry.get(s).getParams(o))),sizeTheme:C.Mapped(i.defaultSizeTheme.name,r.sizeThemeRegistry.getApplicableTypes(o),s=>C.Group(r.sizeThemeRegistry.get(s).getParams(o)))}}})({canAutoUpdate:({oldParams:e,newParams:t})=>e.type.name===t.type.name,apply:({a:e,params:t},n)=>Oe.create("Volume Representation",function(){var r=ie(function*(i){var o;const s={runtime:i,assetManager:n.managers.asset},a=n.representation.volume.registry.get(t.type.name);a.ensureCustomProperties&&(yield a.ensureCustomProperties.attach(s,e.data));const c=a.factory({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.volume.themes},a.getParams);c.setTheme(Fo.create(n.representation.volume.themes,{volume:e.data},t));const u=t.type.params||{};return yield c.createOrUpdate(u,e.data).runInContext(i),new pe.Volume.Representation3D({repr:c,sourceData:e.data},{label:a.label,description:Af.getDescription(u)})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,oldParams:n,newParams:r},i)=>Oe.create("Volume Representation",function(){var o=ie(function*(s){var a;if(r.type.name!==n.type.name)return null===(a=i.representation.volume.registry.get(n.type.name).ensureCustomProperties)||void 0===a||a.detach(e.data),Qe.UpdateResult.Recreate;const c={...t.data.repr.props,...r.type.params};return t.data.repr.setTheme(Fo.create(i.representation.volume.themes,{volume:e.data},r)),yield t.data.repr.createOrUpdate(c,e.data).runInContext(s),t.data.sourceData=e.data,t.description=Af.getDescription(c),Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),ntt=Rt.BuiltIn({name:"shape-representation-3d",display:"3D Representation",from:pe.Shape.Provider,to:pe.Shape.Representation3D,params:(e,t)=>e?e.data.params:rt.Params})({canAutoUpdate:()=>!0,apply:({a:e,params:t},n)=>Oe.create("Shape Representation",function(){var r=ie(function*(i){const o={...C.getDefaultValues(e.data.params),...t},s=Jo(e.data.getShape,e.data.geometryUtils);return yield s.createOrUpdate(o,e.data.data).runInContext(i),new pe.Shape.Representation3D({repr:s,sourceData:e.data},{label:e.data.label})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Shape Representation",function(){var o=ie(function*(s){const a={...t.data.repr.props,...r};return yield t.data.repr.createOrUpdate(a,e.data.data).runInContext(s),t.data.sourceData=e.data,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),rtt=Rt.BuiltIn({name:"model-unitcell-3d",display:"Model Unit Cell",from:pe.Molecule.Model,to:pe.Shape.Representation3D,params:()=>({...Zae})})({isApplicable:e=>!!no.Provider.get(e.data),canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Model Unit Cell",function(){var r=ie(function*(i){var o;const s=no.Provider.get(e.data);if(!s)return li.Null;const a=Qae(e.data,s,t),c=function cJe(e,t){return yn.createMulti("Unit Cell",e,t,yn.StateBuilder,oJe)}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>Zae);return yield c.createOrUpdate(t,a).runInContext(i),new pe.Shape.Representation3D({repr:c,sourceData:a},{label:"Unit Cell",description:s.spacegroup.name})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:n})=>Oe.create("Model Unit Cell",function(){var r=ie(function*(i){const o=no.Provider.get(e.data);if(!o)return Qe.UpdateResult.Null;const s={...t.data.repr.props,...n},a=Qae(e.data,o,s);return yield t.data.repr.createOrUpdate(s,a).runInContext(i),t.data.sourceData=a,Qe.UpdateResult.Updated});return function(i){return r.apply(this,arguments)}}())}),itt=Rt.BuiltIn({name:"structure-bounding-box-3d",display:"Bounding Box",from:pe.Molecule.Structure,to:pe.Shape.Representation3D,params:{radius:C.Numeric(.05,{min:.01,max:4,step:.01},{isEssential:!0}),color:C.Color(xn.red,{isEssential:!0}),...Nt.Params}})({canAutoUpdate:()=>!0,apply:({a:e,params:t},n)=>Oe.create("Bounding Box",function(){var r=ie(function*(i){const o=Jo((s,a,c,u)=>{const l=m8(a.box,a.radius,u?.geometry);return qn.create("Bouding Box",a,l,()=>a.color,()=>1,()=>"Bounding Box")},Nt.Utils);return yield o.createOrUpdate(t,{box:e.data.boundary.box,radius:t.radius,color:t.color}).runInContext(i),new pe.Shape.Representation3D({repr:o,sourceData:e.data},{label:"Bounding Box"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Bounding Box",function(){var o=ie(function*(s){return yield t.data.repr.createOrUpdate(r,{box:e.data.boundary.box,radius:r.radius,color:r.color}).runInContext(s),t.data.sourceData=e.data,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),ott=Rt.BuiltIn({name:"structure-selections-distance-3d",display:"3D Distance",from:pe.Molecule.Structure.Selections,to:pe.Shape.Representation3D,params:()=>({...ice})})({canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Structure Distance",function(){var r=ie(function*(i){var o;const s=ace(e.data),a=function xJe(e,t){return yn.createMulti("Distance",e,t,yn.StateBuilder,rce)}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>ice);return yield a.createOrUpdate(t,s).runInContext(i),new pe.Shape.Representation3D({repr:a,sourceData:s},{label:"Distance"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Structure Distance",function(){var o=ie(function*(s){const a={...t.data.repr.props,...r},c=ace(e.data);return yield t.data.repr.createOrUpdate(a,c).runInContext(s),t.data.sourceData=c,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),stt=Rt.BuiltIn({name:"structure-selections-angle-3d",display:"3D Angle",from:pe.Molecule.Structure.Selections,to:pe.Shape.Representation3D,params:()=>({...Cce})})({canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Structure Angle",function(){var r=ie(function*(i){var o;const s=cce(e.data),a=function fet(e,t){return yn.createMulti("Angle",e,t,yn.StateBuilder,Sce)}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>Cce);return yield a.createOrUpdate(t,s).runInContext(i),new pe.Shape.Representation3D({repr:a,sourceData:s},{label:"Angle"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Structure Angle",function(){var o=ie(function*(s){const a={...t.data.repr.props,...r},c=cce(e.data);return yield t.data.repr.createOrUpdate(a,c).runInContext(s),t.data.sourceData=c,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),att=Rt.BuiltIn({name:"structure-selections-dihedral-3d",display:"3D Dihedral",from:pe.Molecule.Structure.Selections,to:pe.Shape.Representation3D,params:()=>({...Tce})})({canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Structure Dihedral",function(){var r=ie(function*(i){var o;const s=uce(e.data),a=function Net(e,t){return yn.createMulti("Dihedral",e,t,yn.StateBuilder,Ice)}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>Tce);return yield a.createOrUpdate(t,s).runInContext(i),new pe.Shape.Representation3D({repr:a,sourceData:s},{label:"Dihedral"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Structure Dihedral",function(){var o=ie(function*(s){const a={...t.data.repr.props,...r},c=uce(e.data);return yield t.data.repr.createOrUpdate(a,c).runInContext(s),t.data.sourceData=c,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),ctt=Rt.BuiltIn({name:"structure-selections-label-3d",display:"3D Label",from:pe.Molecule.Structure.Selections,to:pe.Shape.Representation3D,params:()=>({...hce})})({canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Structure Label",function(){var r=ie(function*(i){var o,s,a;const c=lce(e.data),u=function TJe(e,t){return yn.createMulti("Label",e,t,yn.StateBuilder,pce)}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>hce);yield u.createOrUpdate(t,c).runInContext(i);const l=!!(null!==(s=t.snapshotKey)&&void 0!==s&&s.trim()||null!==(a=t.tooltip)&&void 0!==a&&a.trim());return u.setState({pickable:l,markerActions:l?Us.Highlighting:Bt.None}),new pe.Shape.Representation3D({repr:u,sourceData:c},{label:"Label"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Structure Label",function(){var o=ie(function*(s){var a,c;const u={...t.data.repr.props,...r},l=lce(e.data);yield t.data.repr.createOrUpdate(u,l).runInContext(s),t.data.sourceData=l;const d=!!(null!==(a=r.snapshotKey)&&void 0!==a&&a.trim()||null!==(c=r.tooltip)&&void 0!==c&&c.trim());return t.data.repr.setState({pickable:d,markerActions:d?Us.Highlighting:Bt.None}),Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),utt=Rt.BuiltIn({name:"structure-selections-orientation-3d",display:"3D Orientation",from:pe.Molecule.Structure.Selections,to:pe.Shape.Representation3D,params:()=>({...bce})})({canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Structure Orientation",function(){var r=ie(function*(i){var o;const s=dce(e.data),a=function ZJe(e,t){const n=yn.createMulti("Orientation",e,t,yn.StateBuilder,yce);return n.setState({markerActions:Us.Highlighting}),n}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>bce);return yield a.createOrUpdate(t,s).runInContext(i),new pe.Shape.Representation3D({repr:a,sourceData:s},{label:"Orientation"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Structure Orientation",function(){var o=ie(function*(s){const a={...t.data.repr.props,...r},c=dce(e.data);return yield t.data.repr.createOrUpdate(a,c).runInContext(s),t.data.sourceData=c,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),ltt=Rt.BuiltIn({name:"structure-selections-plane-3d",display:"3D Plane",from:pe.Molecule.Structure.Selections,to:pe.Shape.Representation3D,params:()=>({...Mce})})({canAutoUpdate:({})=>!0,apply:({a:e,params:t},n)=>Oe.create("Structure Plane",function(){var r=ie(function*(i){var o;const s=fce(e.data),a=function Get(e,t){const n=yn.createMulti("Plane",e,t,yn.StateBuilder,Pce);return n.setState({markerActions:Us.Highlighting}),n}({webgl:null===(o=n.canvas3d)||void 0===o?void 0:o.webgl,...n.representation.structure.themes},()=>Mce);return yield a.createOrUpdate(t,s).runInContext(i),new pe.Shape.Representation3D({repr:a,sourceData:s},{label:"Plane"})});return function(i){return r.apply(this,arguments)}}()),update:({a:e,b:t,newParams:r},i)=>Oe.create("Structure Plane",function(){var o=ie(function*(s){const a={...t.data.repr.props,...r},c=fce(e.data);return yield t.data.repr.createOrUpdate(a,c).runInContext(s),t.data.sourceData=c,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())}),Ye={Data:GP,Misc:jP,Model:HP,Volume:qP,Representation:$P,Shape:WP};function XS(e){let t;return e=e.replace(/^#/,""),[t,e]=[e.slice(6,8),e.slice(0,6)],[st.fromHexStyle("#"+e),1-+("0x"+(t||"ff"))/255]}const ftt=Qe.builderFactory("interactions")({name:"interactions",from:pe.Root,to:pe.Shape.Provider,params:{data:C.Value(void 0,{isHidden:!1})}})({apply:({params:e})=>new pe.Shape.Provider({label:"",data:e.data,params:Nt.Params,geometryUtils:Nt.Utils,getShape:(t,n)=>function dtt(e){const t=at.createState(512,512);for(let n=0;ne[n].color,()=>1,n=>e[n].label)}(n)},{label:""})});let KS=(()=>{class e{constructor(){this.settings$=new ou}set settings(n){this.settings$.next(this._settings=n)}get settings(){return this._settings}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();var eh;function ii(){const e=(t,n)=>t.commands.dispatch(e,n||{});return e.subscribe=(t,n)=>t.commands.subscribe(e,n),e.id=Hr.create22(),e}!function(e){e.create=function t(r){return r},e.getDuration=function n(r,i){var o,s;if(i.customDurationMs)return i.customDurationMs;const a=null===(s=(o=i.definition).getDuration)||void 0===s?void 0:s.call(o,i.params,r);return"fixed"===a?.kind?a.durationMs:void 0}}(eh||(eh={}));class ptt{constructor(){this.subs=new Map,this.disposing=!1}subscribe(t,n){let r=this.subs.get(t.id);return r||(r=[],this.subs.set(t.id,r)),r.push(n),{unsubscribe:()=>{const i=this.subs.get(t.id);if(!i)return;const o=i.indexOf(n);if(!(o<0)){for(let s=o+1;s{this.disposing?i("disposed"):this.subs.get(t.id)?this.resolve({cmd:t,params:n,resolve:r,reject:i}):r()})}dispose(){this.subs.clear()}resolve(t){var n=this;return ie(function*(){const r=n.subs.get(t.cmd.id);if(r)try{for(const i of r)yield i(t.params);t.resolve()}catch(i){t.reject(i)}else t.resolve()})()}}const Cn={State:{SetCurrentObject:ii(),ApplyAction:ii(),Update:ii(),RemoveObject:ii(),ToggleExpanded:ii(),ToggleVisibility:ii(),Snapshots:{Add:ii(),Replace:ii(),Move:ii(),Remove:ii(),Apply:ii(),Clear:ii(),Upload:ii(),Fetch:ii(),DownloadToFile:ii(),OpenFile:ii(),OpenUrl:ii()}},Interactivity:{Object:{Highlight:ii()},Structure:{Highlight:ii(),Select:ii()},ClearHighlights:ii()},Layout:{Update:ii()},Toast:{Show:ii(),Hide:ii()},Camera:{Reset:ii(),SetSnapshot:ii(),Focus:ii(),OrientAxes:ii(),ResetAxes:ii()},Canvas3D:{SetSettings:ii(),ResetSettings:ii()}},htt=eh.create({name:"built-in.animate-assembly-unwind",display:{name:"Unwind Assembly"},isExportable:!0,params:e=>{const t=[["all","All"]],n=e.state.data.select(In.Generators.rootsOfType(pe.Molecule.Structure));for(const r of n)t.push([r.transform.ref,r.obj.data.models[0].label]);return{durationInMs:C.Numeric(3e3,{min:100,max:1e4,step:100}),playOnce:C.Boolean(!1),target:C.Select(t[0][0],t)}},canApply:e=>({canApply:e.state.data.select(In.Generators.ofType(pe.Molecule.Structure.Representation3D,ur.RootRef)).length>0}),getDuration:e=>({kind:"fixed",durationMs:e.durationInMs}),initialState:()=>({t:0}),setup(e,t,n){const r=n.state.data,o=r.select(In.Generators.ofType(pe.Molecule.Structure.Representation3D,e.target&&"all"!==e.target?e.target:ur.RootRef)),s=r.build();let a=!1;for(const c of o)r.select(In.Generators.ofTransformer(Ye.Representation.UnwindStructureAssemblyRepresentation3D,c.transform.ref)).length>0||(a=!0,s.to(c).apply(Ye.Representation.UnwindStructureAssemblyRepresentation3D,{t:0},{tags:"animate-assembly-unwind"}));if(a)return s.commit({doNotUpdateCurrent:!0})},teardown(e,t,n){const r=n.state.data,i=r.select(In.Generators.ofType(pe.Molecule.Structure.Representation3DState).withTag("animate-assembly-unwind"));if(0===i.length)return;const o=r.build();for(const s of i)o.delete(s.transform.ref);return o.commit()},apply:(e,t,n)=>ie(function*(){const r=n.plugin.state.data,o=r.select(In.Generators.ofTransformer(Ye.Representation.UnwindStructureAssemblyRepresentation3D,n.params.target&&"all"!==n.params.target?n.params.target:ur.RootRef));if(0===o.length)return{kind:"finished"};const s=r.build();let c=e.t+(t.current-t.lastApplied)/n.params.durationInMs,u=!1;n.params.playOnce&&c>=1?(u=!0,c=1):c%=1;for(const l of o)s.to(l).update({t:c});return yield Cn.State.Update(n.plugin,{state:r,tree:s,options:{doNotLogTiming:!0}}),u?{kind:"finished"}:{kind:"next",state:{t:c}}})()}),bE=v(),Rce=v(),kce=_r(),mtt=eh.create({name:"built-in.animate-camera-spin",display:{name:"Camera Spin",description:"Spin the 3D scene around the x-axis in view space"},isExportable:!0,params:()=>({durationInMs:C.Numeric(4e3,{min:100,max:2e4,step:100}),speed:C.Numeric(1,{min:1,max:10,step:1},{description:"How many times to spin in the specified duration."}),direction:C.Select("cw",[["cw","Clockwise"],["ccw","Counter Clockwise"]],{cycle:!0})}),initialState:(e,t)=>{var n;return{snapshot:null===(n=t.canvas3d)||void 0===n?void 0:n.camera.getSnapshot()}},getDuration:e=>({kind:"fixed",durationMs:e.durationInMs}),teardown:(e,t,n)=>{var r;null===(r=n.canvas3d)||void 0===r||r.requestCameraReset({snapshot:t.snapshot,durationMs:0})},apply:(e,t,n)=>ie(function*(){var r,i;if(0===t.current)return{kind:"next",state:e};const o=e.snapshot;if(o.radiusMax<1e-4)return{kind:"finished"};const s=t.animation?(null===(r=t.animation)||void 0===r?void 0:r.currentFrame)/(t.animation.frameCount+1):os(t.current/n.params.durationInMs,0,1),a=2*Math.PI*s*n.params.speed*("ccw"===n.params.direction?-1:1);v.sub(bE,o.position,o.target),v.normalize(Rce,o.up),_r.setAxisAngle(kce,Rce,a),v.transformQuat(bE,bE,kce);const c=v.add(v(),o.target,bE);return null===(i=n.plugin.canvas3d)||void 0===i||i.requestCameraReset({snapshot:{...o,position:c},durationMs:0}),s>=.99999?{kind:"finished"}:{kind:"next",state:e}})()}),gtt=eh.create({name:"built-in.animate-model-index",display:{name:"Animate Trajectory"},isExportable:!0,params:()=>({mode:C.MappedStatic("loop",{palindrome:C.Group({}),loop:C.Group({direction:C.Select("forward",[["forward","Forward"],["backward","Backward"]])}),once:C.Group({direction:C.Select("forward",[["forward","Forward"],["backward","Backward"]])},{isFlat:!0})},{options:[["palindrome","Palindrome"],["loop","Loop"],["once","Once"]]}),duration:C.MappedStatic("fixed",{fixed:C.Group({durationInS:C.Numeric(5,{min:1,max:120,step:.1},{description:"Duration in seconds"})},{isFlat:!0}),computed:C.Group({targetFps:C.Numeric(30,{min:5,max:250,step:1},{label:"Target FPS"})},{isFlat:!0}),sequential:C.Group({maxFps:C.Numeric(30,{min:5,max:60,step:1})},{isFlat:!0})})}),canApply(e){const t=e.state.data,n=t.select(In.Generators.ofTransformer(Ye.Model.ModelFromTrajectory));for(const r of n){const i=In.findAncestorOfType(t.tree,t.cells,r.transform.ref,pe.Molecule.Trajectory);if(i&&i.obj&&i.obj.data.frameCount>1)return{canApply:!0}}return{canApply:!1,reason:"No trajectory to animate"}},getDuration:(e,t)=>{var n;if("fixed"===(null===(n=e.duration)||void 0===n?void 0:n.name))return{kind:"fixed",durationMs:1e3*e.duration.params.durationInS};if("computed"===e.duration.name){const r=t.state.data,i=r.select(In.Generators.ofTransformer(Ye.Model.ModelFromTrajectory));let o=0;for(const s of i){const a=In.findAncestorOfType(r.tree,r.cells,s.transform.ref,pe.Molecule.Trajectory);a&&a.obj&&(o=Math.max(Math.ceil(1e3*a.obj.data.frameCount/e.duration.params.targetFps),o))}return{kind:"fixed",durationMs:o}}return{kind:"unknown"}},initialState:()=>({}),apply:(e,t,n)=>ie(function*(){if("sequential"===n.params.duration.name&&t.current>0&&t.current-t.lastApplied<1e3/n.params.duration.params.maxFps)return{kind:"skip"};const r=n.plugin.state.data,i=r.select(In.Generators.ofTransformer(Ye.Model.ModelFromTrajectory));if(0===i.length)return{kind:"finished"};const o=r.build(),s=n.params,a=e.palindromeDirections||{};let c=!1,u=!0;for(const l of i){const d=In.findAncestorOfType(r.tree,r.cells,l.transform.ref,pe.Molecule.Trajectory);if(!d||!d.obj)continue;const f=d.obj;f.data.frameCount<=1||o.to(l).update(p=>{const m=f.data.frameCount;if(1===m)return p;if(u=!1,"sequential"===s.duration.name){let h=1;if("once"===s.mode.name){if(h="backward"===s.mode.params.direction?-1:1,-1===h&&0===p.modelIndex||1===h&&p.modelIndex===m-1)return c=!0,p}else"palindrome"===s.mode.name&&(h=0===p.modelIndex?1:p.modelIndex===m-1?-1:a[l.transform.ref]||1);a[l.transform.ref]=h;let g=(p.modelIndex+h)%m;return g<0&&(g+=m),c=c||-1===h&&0===g||1===h&&g===m-1,{modelIndex:g}}{const h="fixed"===s.duration.name?1e3*s.duration.params.durationInS:Math.ceil(1e3*f.data.frameCount/s.duration.params.targetFps);if("once"===s.mode.name&&t.current>=h)return c=!0,{modelIndex:f.data.frameCount-1};let g=t.current%h/h;return"loop"===s.mode.name&&"backward"===s.mode.params.direction&&(g=1-g),"palindrome"===s.mode.name&&(g*=2,g>1&&(g=2-g)),{modelIndex:Math.min(Math.floor(f.data.frameCount*g),f.data.frameCount-1)}}})}return u||(yield Cn.State.Update(n.plugin,{state:r,tree:o,options:{doNotLogTiming:!0}})),u||"once"===s.mode.name&&c?{kind:"finished"}:"palindrome"===s.mode.name?{kind:"next",state:{palindromeDirections:a}}:{kind:"next",state:{}}})()});function Nce(e,t){return y8.apply(this,arguments)}function y8(){return y8=ie(function*(e,t,n=!1){var r;t.snapshot.data&&(yield e.runTask(e.state.data.setSnapshot(t.snapshot.data))),t.snapshot.camera&&(null===(r=e.canvas3d)||void 0===r||r.requestCameraReset({snapshot:t.snapshot.camera.current,durationMs:n||"instant"===t.snapshot.camera.transitionStyle?0:t.snapshot.camera.transitionDurationInMs}))}),y8.apply(this,arguments)}const ytt=eh.create({name:"built-in.animate-state-snapshots",display:{name:"State Snapshots"},isExportable:!0,params:()=>({}),canApply(e){const t=e.managers.snapshot.state.entries;return t.size<2?{canApply:!1,reason:"At least 2 states required."}:t.some(n=>!!n?.snapshot.startAnimation)?{canApply:!1,reason:"Nested animations not supported."}:{canApply:e.managers.snapshot.state.entries.size>1}},setup(e,t,n){const r=n.managers.snapshot.state.entries.get(0);Nce(n,r,!0)},getDuration:(e,t)=>({kind:"fixed",durationMs:t.managers.snapshot.state.entries.toArray().reduce((n,r)=>{var i;return n+(null!==(i=r.snapshot.durationInMs)&&void 0!==i?i:0)},0)}),initialState:(e,t)=>{const n=t.managers.snapshot.state.entries.toArray();return{totalDuration:n.reduce((r,i)=>{var o;return r+(null!==(o=i.snapshot.durationInMs)&&void 0!==o?o:0)},0),snapshots:n,currentIndex:0}},apply:(e,t,n)=>ie(function*(){var r;if(t.current>=e.totalDuration)return{kind:"finished"};let i=0,o=0;for(const s of e.snapshots){if(i+=null!==(r=s.snapshot.durationInMs)&&void 0!==r?r:0,t.current=e.snapshots.length?{kind:"finished"}:o===e.currentIndex?{kind:"skip"}:(Nce(n.plugin,e.snapshots[o]),{kind:"next",state:{...e,currentIndex:o}})})()});var tr;!function(e){class t extends(pe.Create({name:"Root",typeClass:"Root"})){}e.Root=t;class n extends(pe.Create({name:"Category",typeClass:"Object"})){}e.Category=n;class r extends(pe.CreateBehavior({name:"Behavior"})){}e.Behavior=r,e.Categories={common:"Common",representation:"Representation",interaction:"Interaction","custom-props":"Custom Properties",misc:"Miscellaneous"},e.CreateCategory=Rt.BuiltIn({name:"create-behavior-category",display:{name:"Behavior Category"},from:t,to:n,params:{label:C.Text("",{isHidden:!0})}})({apply:({params:l})=>new n({},{label:l.label})});const i=new Map;e.getCategoryId=function o(l){return i.get(l.id)},e.create=function s(l){const d=Rt.CreateBuiltIn({name:l.name,display:l.display,from:[t],to:[r],params:l.params,apply({params:f},p){const m=l.label?l.label(f):{label:l.display.name,description:l.display.description};return new r(new l.ctor(p,f),m)},update:({b:f,newParams:p})=>Oe.create("Update Behavior",ie(function*(){return f.data.update&&(yield f.data.update(p))?Qe.UpdateResult.Updated:Qe.UpdateResult.Unchanged})),canAutoUpdate:l.canAutoUpdate});return i.set(d.id,l.category),d},e.simpleCommandHandler=function a(l,d){return class{register(){this.sub=l.subscribe(this.ctx,f=>d(f,this.ctx))}dispose(){this.sub&&this.sub.unsubscribe(),this.sub=void 0}constructor(f){this.ctx=f,this.sub=void 0}}},e.Handler=class c{subscribeCommand(d,f){this.subs.push(d.subscribe(this.ctx,f))}subscribeObservable(d,f){this.subs.push(d.subscribe(f))}track(d){this.subs.push(d)}dispose(){for(const d of this.subs)d.unsubscribe();this.subs=[]}update(d){return!EI(d,this.params)&&(this.params=d,!0)}constructor(d,f){this.ctx=d,this.params=f,this.subs=[]}},e.WithSubscribers=class u{subscribeCommand(d,f){this.subs.push(d.subscribe(this.plugin,f))}subscribeObservable(d,f){const p=d.subscribe(f);return this.subs.push(p),{unsubscribe:()=>{const m=this.subs.indexOf(p);m>=0&&(this.subs.splice(m,1),p.unsubscribe())}}}dispose(){for(const d of this.subs)d.unsubscribe();this.subs=[]}constructor(d,f){this.plugin=d,this.params=f,this.subs=[]}}}(tr||(tr={}));class ZS{constructor(){this.subs=void 0}subscribe(t,n){typeof this.subs>"u"&&(this.subs=[]);let r=t.subscribe(n);return this.subs.push(r),{unsubscribe:()=>{r&&this.subs&&Eg(this.subs,r)&&(r.unsubscribe(),r=void 0)}}}get ev(){return this._ev||(this._ev=wp.create())}dispose(){if(this._ev&&this._ev.dispose(),this.subs){for(const t of this.subs)t.unsubscribe();this.subs=void 0}}}class th extends ZS{updateState(...t){const n=this.state,r=function BZ(e,t){let n=e;for(let r=0;r{const o=s=>{s?r(s):i("no blob returned")};HTMLCanvasElement.prototype.toBlob?e.toBlob(o,t,n):function xtt(e,t,n,r){const i=atob(e.toDataURL(n,r).split(",")[1]),o=i.length,s=o>>2,a=new Uint8Array(o),c=new Uint32Array(a.buffer,0,s);let u=0;for(let d=0;d{class e extends th{getIndex(n){return this.state.entries.indexOf(n)}getEntry(n){if(n)return this.entryMap.get(n)}remove(n){const r=this.entryMap.get(n);r&&(r?.image&&this.plugin.managers.asset.delete(r.image),this.entryMap.delete(n),this.updateState({current:this.state.current===n?void 0:this.state.current,entries:this.state.entries.delete(this.getIndex(r))}),this.events.changed.next(void 0))}add(n){this.entryMap.set(n.snapshot.id,n),this.updateState({current:n.snapshot.id,entries:this.state.entries.push(n)}),this.events.changed.next(void 0)}replace(n,r,i){var o,s,a;const c=this.getEntry(n);if(!c)return;this.defaultSnapshotId=void 0,c?.image&&this.plugin.managers.asset.delete(c.image);const u=this.getIndex(c),l=e.Entry(r,{key:null!==(o=i?.key)&&void 0!==o?o:c.key,name:null!==(s=i?.name)&&void 0!==s?s:c.name,description:null!==(a=i?.description)&&void 0!==a?a:c.description,image:i?.image});this.entryMap.set(r.id,l),this.updateState({current:l.snapshot.id,entries:this.state.entries.set(u,l)}),this.events.changed.next(void 0)}move(n,r){const i=this.state.entries.size;if(i<2)return;const o=this.getEntry(n);if(!o)return;const s=this.getIndex(o);let a=(s+r)%i;a<0&&(a+=i);const c=this.state.entries.get(a),u=this.state.entries.asMutable();u.set(a,o),u.set(s,c),this.updateState({current:o.snapshot.id,entries:u.asImmutable()}),this.events.changed.next(void 0)}update(n,r){var i,o,s;const a=this.getIndex(n);if(a<0)return;const c=this.state.entries.set(a,{...n,key:(null===(i=r.key)||void 0===i?void 0:i.trim())||void 0,name:(null===(o=r.name)||void 0===o?void 0:o.trim())||void 0,description:(null===(s=r.description)||void 0===s?void 0:s.trim())||void 0});this.updateState({entries:c}),this.entryMap.set(n.snapshot.id,this.state.entries.get(a)),this.events.changed.next(void 0)}clear(){0!==this.state.entries.size&&(this.entryMap.forEach(n=>{n?.image&&this.plugin.managers.asset.delete(n.image)}),this.entryMap.clear(),this.updateState({current:void 0,entries:Cp()}),this.events.changed.next(void 0))}applyKey(n){const r=this.state.entries.find(i=>i.key===n);r&&(this.updateState({current:r.snapshot.id}),this.events.changed.next(void 0),this.plugin.state.setSnapshot(r.snapshot))}setCurrent(n){const r=this.getEntry(n);return r&&(this.updateState({current:n}),this.events.changed.next(void 0)),r&&r.snapshot}getNextId(n,r){const i=this.state.entries.size;if(!n){if(0===i)return;return this.state.entries.get(-1===r?i-1:0).snapshot.id}const o=this.getEntry(n);if(!o)return;let s=this.getIndex(o);return s<0?void 0:(s=(s+r)%i,s<0&&(s+=i),this.state.entries.get(s).snapshot.id)}setStateSnapshot(n){var r=this;return ie(function*(){r.clear();const i=Cp().asMutable();for(const c of n.entries)r.entryMap.set(c.snapshot.id,c),i.push(c);const o=n.current?n.current:n.entries.length>0?n.entries[0].snapshot.id:void 0;if(r.updateState({current:o,entries:i.asImmutable(),isPlaying:!1,nextSnapshotDelayInMs:n.playback?n.playback.nextSnapshotDelayInMs:e.DefaultNextSnapshotDelayInMs}),r.events.changed.next(void 0),!o)return;const s=r.getEntry(o),a=s&&s.snapshot;return a?(yield r.plugin.state.setSnapshot(a),n.playback&&n.playback.isPlaying&&r.play(!0),a):void 0})()}syncCurrent(n){var r=this;return ie(function*(){var i,o;const s=0===r.state.entries.size,a=1===r.state.entries.size&&r.state.current&&r.state.current===r.defaultSnapshotId;if(!s&&!a)return;const c=r.plugin.state.getSnapshot(n?.params),u=(null!==(o=null===(i=n?.params)||void 0===i?void 0:i.image)&&void 0!==o?o:r.plugin.state.snapshotParams.value.image)?yield e.getCanvasImageAsset(r.plugin,`${c.id}-image.png`):void 0;if(s)r.add(e.Entry(c,{name:n?.name,description:n?.description,image:u}));else if(a){const l=r.getEntry(r.state.current);l?.image&&r.plugin.managers.asset.delete(l.image),r.replace(r.state.current,c,{image:u})}r.defaultSnapshotId=c.id})()}getStateSnapshot(n){var r=this;return ie(function*(){return yield r.syncCurrent(n),{timestamp:+new Date,version:"4.0.1",name:n&&n.name,description:n&&n.description,current:r.state.current,playback:{isPlaying:!(!n||!n.playOnLoad),nextSnapshotDelayInMs:r.state.nextSnapshotDelayInMs},entries:r.state.entries.valueSeq().toArray()}})()}serialize(n){var r=this;return ie(function*(){const i=JSON.stringify(yield r.getStateSnapshot({params:n?.params}),null,2);if(!n?.type||"json"===n.type||"molj"===n.type)return new Blob([i],{type:"application/json;charset=utf-8"});{const o=new Uint8Array(sT(i));Xb(o,0,i);const s={"state.json":o},a=[];for(const{asset:u,file:l}of r.plugin.managers.asset.assets)a.push([u.id,u]),s[`assets/${u.id}`]=new Uint8Array(yield l.arrayBuffer());if(a.length>0){const u=JSON.stringify(a,null,2),l=new Uint8Array(sT(u));Xb(l,0,u),s["assets.json"]=l}const c=yield r.plugin.runTask(function mLe(e,t=!1){return Oe.create("Zip",n=>function gLe(e,t){return PO.apply(this,arguments)}(n,e,t))}(s));return new Blob([c],{type:"application/zip"})}})()}open(n){var r=this;return ie(function*(){try{const i=n.name.toLowerCase();if(i.endsWith("json")||i.endsWith("molj")){const o=yield r.plugin.runTask(bp(n,"string")),s=JSON.parse(o);e.isStateSnapshot(s)?yield r.setStateSnapshot(s):e.isStateSnapshot(s.data)?yield r.setStateSnapshot(s.data):yield r.plugin.state.setSnapshot(s)}else{const o=yield r.plugin.runTask(bp(n,"zip")),s=Object.create(null);$a(o,(l,d)=>{if("state.json"===d||"assets.json"===d)return;const f=d.substring(d.indexOf("/")+1);s[f]=l});const a=new File([o["state.json"]],"state.json"),c=yield r.plugin.runTask(bp(a,"string"));if(o["assets.json"]){const l=new File([o["assets.json"]],"assets.json"),d=JSON.parse(yield r.plugin.runTask(bp(l,"string")));for(const[f,p]of d)r.plugin.managers.asset.set(p,new File([s[f]],p.name))}const u=JSON.parse(c);yield r.setStateSnapshot(u)}r.events.opened.next(void 0)}catch(i){console.error(i),r.plugin.log.error("Error reading state")}})()}play(n=!1){if(this.updateState({isPlaying:!0}),n){const r=this.getEntry(this.state.current);if(!r)return void this.next();this.events.changed.next(void 0);const i=r.snapshot;this.timeoutHandle=setTimeout(this.next,typeof i.durationInMs<"u"?i.durationInMs:this.state.nextSnapshotDelayInMs)}else this.next()}stop(){this.updateState({isPlaying:!1}),typeof this.timeoutHandle<"u"&&clearTimeout(this.timeoutHandle),this.timeoutHandle=void 0,this.events.changed.next(void 0)}togglePlay(){this.state.isPlaying?(this.stop(),this.plugin.managers.animation.stop()):this.play()}dispose(){super.dispose(),this.entryMap.clear()}constructor(n){var r;super({current:void 0,entries:Cp(),isPlaying:!1,nextSnapshotDelayInMs:e.DefaultNextSnapshotDelayInMs}),r=this,this.plugin=n,this.entryMap=new Map,this.defaultSnapshotId=void 0,this.events={changed:this.ev(),opened:this.ev()},this.timeoutHandle=void 0,this.next=ie(function*(){r.timeoutHandle=void 0;const i=r.getNextId(r.state.current,1);if(!i||i===r.state.current)return void r.stop();const o=r.setCurrent(i);yield r.plugin.state.setSnapshot(o),r.state.isPlaying&&(r.timeoutHandle=setTimeout(r.next,typeof o.durationInMs<"u"?o.durationInMs:r.state.nextSnapshotDelayInMs))})}}return e.DefaultNextSnapshotDelayInMs=1500,e})();function Fce(e){try{e.dispatchEvent(new MouseEvent("click"))}catch{const n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(n)}}function Bce(e,t="download"){if(e)if("download"in HTMLAnchorElement.prototype){const n=document.createElement("a");n.download=t,n.rel="noopener","string"==typeof e?(n.href=e,Fce(n)):(n.href=URL.createObjectURL(e),setTimeout(()=>URL.revokeObjectURL(n.href),4e4),setTimeout(()=>Fce(n)))}else if(typeof navigator<"u"&&navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(e,t);else{const n=window.navigator.userAgent,r=/Safari/i.test(n),i=/CriOS\/[\d]+/.test(n),o=s=>{!function Ctt(e){window.open(e,"_blank")||(window.location.href=e)}(i?s:s.replace(/^data:[^;]*;/,"data:attachment/file;"))};if((r||i)&&FileReader)if(e instanceof Blob){const s=new FileReader;s.onloadend=()=>o(s.result),s.readAsDataURL(e)}else o(e);else{const s=URL.createObjectURL("string"==typeof e?new Blob([e]):e);location.href=s,setTimeout(()=>URL.revokeObjectURL(s),4e4)}}}function x8(e,t){return`${e}${"/"===e[e.length-1]||"/"===t[0]?"":"/"}${t}`}!function(e){function i(){return(i=ie(function*(o,s){if(!o.helpers.viewportScreenshot)return;const a=o.helpers.viewportScreenshot.getPreview(512);if(!a)return;const c=yield v8(a.canvas,"png"),u=new File([c],s),l={kind:"file",id:Hr.create22(),name:s};return o.managers.asset.set(l,u),l})).apply(this,arguments)}e.Entry=function t(o,s){return{timestamp:+new Date,snapshot:o,...s}},e.isStateSnapshot=function n(o){return!!o&&!!o.timestamp&&!!o.entries},e.getCanvasImageAsset=function r(o,s){return i.apply(this,arguments)}}(qv||(qv={}));const wtt={get preferWebGl1(){if(typeof navigator>"u"||typeof window>"u")return!1;if(["Version/15.1 Safari","Version/15.2 Safari","Version/15.3 Safari"].some(i=>navigator.userAgent.indexOf(i)>0))return!0;const t=/iPad|iPhone|iPod/.test(navigator.userAgent),n=navigator.userAgent.includes("Macintosh"),r=navigator.maxTouchPoints>=4;return!window.MSStream&&(t||n&&r)}};class Att{toString(){return this.key}valueOf(){return this.key}constructor(t,n){this.key=t,this.defaultValue=n}}function fi(e,t){return new Att(e,t)}const qi={item:fi,General:{IsBusyTimeoutMs:fi("plugin-config.is-busy-timeout",750),DisableAntialiasing:fi("plugin-config.disable-antialiasing",!1),DisablePreserveDrawingBuffer:fi("plugin-config.disable-preserve-drawing-buffer",!1),PixelScale:fi("plugin-config.pixel-scale",1),PickScale:fi("plugin-config.pick-scale",.25),Transparency:fi("plugin-config.transparency","wboit"),PreferWebGl1:fi("plugin-config.prefer-webgl1",wtt.preferWebGl1),AllowMajorPerformanceCaveat:fi("plugin-config.allow-major-performance-caveat",!1),PowerPreference:fi("plugin-config.power-preference","high-performance")},State:{DefaultServer:fi("plugin-state.server","https://webchem.ncbr.muni.cz/molstar-state"),CurrentServer:fi("plugin-state.server","https://webchem.ncbr.muni.cz/molstar-state"),HistoryCapacity:fi("history-capacity.server",5)},VolumeStreaming:{Enabled:fi("volume-streaming.enabled",!0),DefaultServer:fi("volume-streaming.server","https://ds.litemol.org"),CanStream:fi("volume-streaming.can-stream",(e,t)=>1===e.models.length&&sn.probablyHasDensityMap(e.models[0])),EmdbHeaderServer:fi("volume-streaming.emdb-header-server","https://files.wwpdb.org/pub/emdb/structures")},Viewport:{ShowExpand:fi("viewer.show-expand-button",!0),ShowControls:fi("viewer.show-controls-button",!0),ShowSettings:fi("viewer.show-settings-button",!0),ShowSelectionMode:fi("viewer.show-selection-model-button",!0),ShowAnimation:fi("viewer.show-animation-button",!0),ShowTrajectoryControls:fi("viewer.show-trajectory-controls",!0)},Download:{DefaultPdbProvider:fi("download.default-pdb-provider","pdbe"),DefaultEmdbProvider:fi("download.default-emdb-provider","pdbe")},Structure:{SizeThresholds:fi("structure.size-thresholds",Ve.DefaultSizeThresholds),DefaultRepresentationPreset:fi("structure.default-representation-preset","auto"),DefaultRepresentationPresetParams:fi("structure.default-representation-preset-params",{}),SaccharideCompIdMapType:fi("structure.saccharide-comp-id-map-type","default")},Background:{Styles:fi("background.styles",[])}};class Itt{get(t){return this._config.has(t)?this._config.get(t):t.defaultValue}set(t,n){this._config.set(t,n)}delete(t){this._config.delete(t)}constructor(t){this._config=new Map,t&&t.forEach(([n,r])=>this._config.set(n,r))}}function Ttt(e){Oce(e),Lce(e),Uce(e),Vce(e),zce(e),Gce(e),jce(e),Hce(e),qce(e),Wce(e)}function Oce(e){e.state.events.object.created.subscribe(t=>{pe.isBehavior(t.obj)&&t.obj.data.register(t.ref)}),e.state.events.object.removed.subscribe(t=>{var n,r,i,o;pe.isBehavior(t.obj)&&(null===(r=(n=t.obj.data).unregister)||void 0===r||r.call(n),null===(o=(i=t.obj.data).dispose)||void 0===o||o.call(i))}),e.state.events.object.updated.subscribe(t=>{var n,r,i,o;"recreate"===t.action&&(t.oldObj&&pe.isBehavior(t.oldObj)&&(null===(r=(n=t.oldObj.data).unregister)||void 0===r||r.call(n),null===(o=(i=t.oldObj.data).dispose)||void 0===o||o.call(i)),t.obj&&pe.isBehavior(t.obj)&&t.obj.data.register(t.ref))})}function Lce(e){Cn.State.SetCurrentObject.subscribe(e,({state:t,ref:n})=>t.setCurrent(n))}function Uce(e){Cn.State.Update.subscribe(e,({state:t,tree:n,options:r})=>e.runTask(t.updateTree(n,r)))}function Vce(e){Cn.State.ApplyAction.subscribe(e,({state:t,action:n,ref:r})=>e.runTask(t.applyAction(n.action,n.params,r)))}function zce(e){function t(n,r){const i=n.build().delete(r);return e.runTask(n.updateTree(i))}Cn.State.RemoveObject.subscribe(e,({state:n,ref:r,removeParentGhosts:i})=>{if(!i)return t(n,r);{const o=n.tree;let s=o.transforms.get(r);if(s.parent===r)return t(n,r);for(;;){const a=o.children.get(s.parent);if(s.parent===s.ref||a.size>1)return t(n,s.ref);const c=o.transforms.get(s.parent);if(!c.state.isGhost)return t(n,s.ref);s=c}}})}function Gce(e){Cn.State.ToggleExpanded.subscribe(e,({state:t,ref:n})=>t.updateCellState(n,({isCollapsed:r})=>({isCollapsed:!r})))}function jce(e){Cn.State.ToggleVisibility.subscribe(e,({state:t,ref:n})=>Wv(t,n,!t.cells.get(n).state.isHidden))}function Wv(e,t,n){bo.doPreOrder(e.tree,e.transforms.get(t),{state:e,value:n},Dtt)}function Dtt(e,t,n){n.state.updateCellState(e.ref,{isHidden:n.value})}function Hce(e){Cn.Interactivity.Object.Highlight.subscribe(e,({state:t,ref:n})=>{if(!e.canvas3d||e.isBusy)return;e.managers.interactivity.lociHighlights.clearHighlights();const r="string"==typeof n?[n]:n;for(const i of r){const o=t.cells.get(i);if(o)if(pe.Molecule.Structure.is(o.obj))e.managers.interactivity.lociHighlights.highlight({loci:Ve.Loci(o.obj.data)},!1);else if(o&&pe.isRepresentation3D(o.obj)){const{repr:s}=o.obj.data;for(const a of s.getAllLoci())e.managers.interactivity.lociHighlights.highlight({loci:a,repr:s},!1)}else if(pe.Molecule.Structure.Selections.is(o.obj))for(const s of o.obj.data)e.managers.interactivity.lociHighlights.highlight({loci:s.loci},!1)}})}function qce(e){Cn.Interactivity.ClearHighlights.subscribe(e,()=>{e.managers.interactivity.lociHighlights.clearHighlights()})}function Wce(e){e.config.set(qi.State.CurrentServer,e.config.get(qi.State.DefaultServer)),Cn.State.Snapshots.Clear.subscribe(e,()=>{e.managers.snapshot.clear()}),Cn.State.Snapshots.Remove.subscribe(e,({id:t})=>{e.managers.snapshot.remove(t)}),Cn.State.Snapshots.Add.subscribe(e,function(){var t=ie(function*({key:n,name:r,description:i,params:o}){var s;const a=e.state.getSnapshot(o),c=(null!==(s=o?.image)&&void 0!==s?s:e.state.snapshotParams.value.image)?yield qv.getCanvasImageAsset(e,`${a.id}-image.png`):void 0,u=qv.Entry(a,{key:n,name:r,description:i,image:c});e.managers.snapshot.add(u)});return function(n){return t.apply(this,arguments)}}()),Cn.State.Snapshots.Replace.subscribe(e,function(){var t=ie(function*({id:n,params:r}){var i;const o=e.state.getSnapshot(r),s=(null!==(i=r?.image)&&void 0!==i?i:e.state.snapshotParams.value.image)?yield qv.getCanvasImageAsset(e,`${o.id}-image.png`):void 0;e.managers.snapshot.replace(n,e.state.getSnapshot(r),{image:s})});return function(n){return t.apply(this,arguments)}}()),Cn.State.Snapshots.Move.subscribe(e,({id:t,dir:n})=>{e.managers.snapshot.move(t,n)}),Cn.State.Snapshots.Apply.subscribe(e,({id:t})=>{const n=e.managers.snapshot.setCurrent(t);if(n)return e.state.setSnapshot(n)}),Cn.State.Snapshots.Upload.subscribe(e,function(){var t=ie(function*({name:n,description:r,playOnLoad:i,serverUrl:o}){return fetch(x8(o,`set?name=${encodeURIComponent(n||"")}&description=${encodeURIComponent(r||"")}`),{method:"POST",mode:"cors",referrer:"no-referrer",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(yield e.managers.snapshot.getStateSnapshot({name:n,description:r,playOnLoad:i}))})});return function(n){return t.apply(this,arguments)}}()),Cn.State.Snapshots.Fetch.subscribe(e,function(){var t=ie(function*({url:n}){const r=yield e.runTask(e.fetch({url:n,type:"json"}));yield e.managers.snapshot.setStateSnapshot(r.data)});return function(n){return t.apply(this,arguments)}}()),Cn.State.Snapshots.DownloadToFile.subscribe(e,function(){var t=ie(function*({name:n,type:r,params:i}){const o=`mol-star_state_${n||function Stt(){const e=new Date;return e.getFullYear()+"-"+(e.getMonth()+1)+"-"+e.getDate()+"-"+e.getHours()+"-"+e.getMinutes()+"-"+e.getSeconds()}()}.${"json"===r?"molj":"molx"}`;Bce(yield e.managers.snapshot.serialize({type:r,params:i}),`${o}`)});return function(n){return t.apply(this,arguments)}}()),Cn.State.Snapshots.OpenFile.subscribe(e,({file:t})=>e.managers.snapshot.open(t)),Cn.State.Snapshots.OpenUrl.subscribe(e,function(){var t=ie(function*({url:n,type:r}){const i=yield e.runTask(e.fetch({url:n,type:"binary"}));return e.managers.snapshot.open(new File([i],`state.${r}`))});return function(n){return t.apply(this,arguments)}}())}function Ett(e){$ce(e),Yce(e),Xce(e)}function $ce(e){const t=e.state.data.events;t.object.created.subscribe(n=>{var r;pe.isRepresentation3D(n.obj)&&(S8(n.state.cells.get(n.ref),n.obj.data.repr),n.obj.data.repr.setState({syncManually:!0}),null===(r=e.canvas3d)||void 0===r||r.add(n.obj.data.repr))}),t.object.updated.subscribe(n=>{var r,i;n.oldObj&&pe.isRepresentation3D(n.oldObj)&&(null===(r=e.canvas3d)||void 0===r||r.remove(n.oldObj.data.repr),n.oldObj.data.repr.destroy()),pe.isRepresentation3D(n.obj)&&(S8(n.state.cells.get(n.ref),n.obj.data.repr),"recreate"===n.action&&n.obj.data.repr.setState({syncManually:!0}),null===(i=e.canvas3d)||void 0===i||i.add(n.obj.data.repr))}),t.object.removed.subscribe(n=>{var r;pe.isRepresentation3D(n.obj)&&(null===(r=e.canvas3d)||void 0===r||r.remove(n.obj.data.repr),n.obj.data.repr.destroy())})}function Yce(e){const t=e.state.data.events;t.object.created.subscribe(n=>{var r;if(!pe.Molecule.Structure.Representation3DState.is(n.obj))return;const i=n.obj.data;i.repr.setState(i.state),null===(r=e.canvas3d)||void 0===r||r.update(i.repr)}),t.object.updated.subscribe(n=>{var r;if(!pe.Molecule.Structure.Representation3DState.is(n.obj))return;const i=n.obj.data;i.repr.setState(i.state),null===(r=e.canvas3d)||void 0===r||r.update(i.repr)}),t.object.removed.subscribe(n=>{var r;if(!pe.Molecule.Structure.Representation3DState.is(n.obj))return;const i=n.obj.data;i.repr.setState(i.initialState),null===(r=e.canvas3d)||void 0===r||r.update(i.repr)})}function Xce(e){e.state.data.events.cell.stateUpdated.subscribe(t=>{var n;const r=t.state.cells.get(t.ref);pe.isRepresentation3D(r.obj)&&S8(r,r.obj.data.repr)&&(null===(n=e.canvas3d)||void 0===n||n.syncVisibility())})}function S8(e,t){return t.state.visible===!!e.state.isHidden&&(t.setState({visible:!e.state.isHidden}),!0)}function Ptt(e){Kce(e),Qce(e),Zce(e),Jce(e),eue(e)}function Kce(e){Cn.Camera.Reset.subscribe(e,t=>{e.managers.camera.reset(t?.snapshot,t?.durationMs)})}function Zce(e){Cn.Camera.SetSnapshot.subscribe(e,({snapshot:t,durationMs:n})=>{e.managers.camera.setSnapshot(t,n)})}function Qce(e){Cn.Camera.Focus.subscribe(e,({center:t,radius:n,durationMs:r})=>{e.managers.camera.focusSphere({center:t,radius:n},{durationMs:r}),e.events.canvas3d.settingsUpdated.next(void 0)})}function Jce(e){Cn.Camera.OrientAxes.subscribe(e,({structures:t,durationMs:n})=>{e.managers.camera.orientAxes(t,n)})}function eue(e){Cn.Camera.ResetAxes.subscribe(e,({durationMs:t})=>{e.managers.camera.resetAxes(t)})}function Lo(){return Lo.zero()}!function(e){e.zero=function t(){return{x:0,y:0,width:0,height:0}},e.create=function n(c,u,l,d){return{x:c,y:u,width:l,height:d}},e.clone=function r(c){return{...c}},e.copy=function i(c,u){return Object.assign(c,u)},e.set=function o(c,u,l,d,f){return c.x=u,c.y=l,c.width=d,c.height=f,c},e.toVec4=function s(c,u){return c[0]=u.x,c[1]=u.y,c[2]=u.width,c[3]=u.height,c},e.equals=function a(c,u){return c.x===u.x&&c.y===u.y&&c.width===u.width&&c.height===u.height}}(Lo||(Lo={}));const If=nn();function vE(e,t,n,r){const{x:i,y:o,width:s,height:a}=n,u=t[1]-o,l=t[2];return e[0]=2*(t[0]-i)/s-1,e[1]=2*u/a-1,e[2]=2*l-1,v.transformMat4(e,e,r)}function C8(e){if("object"==typeof e){if("buttons"in e)return e.buttons;if("which"in e){const t=e.which;if(2===t)return 4;if(3===t)return 2;if(t>0)return 1<=0)return 1<!0,pixelScale:1};var wu,Zi;!function(e){function t(o,s){return o.shift===s.shift&&o.alt===s.alt&&o.control===s.control&&o.meta===s.meta}function i(o={}){return{shift:!!o.shift,alt:!!o.alt,control:!!o.control,meta:!!o.meta}}e.None=i(),e.areEqual=t,e.areNone=function n(o){return t(o,e.None)},e.size=function r(o){if(!o)return 0;let s=0;return o.shift&&s++,o.alt&&s++,o.control&&s++,o.meta&&s++,s},e.create=i}(wu||(wu={})),function(e){let t;var n;e.has=ea.has,e.create=ea.create,(n=t=e.Flag||(e.Flag={}))[n.None=0]="None",n[n.Primary=1]="Primary",n[n.Secondary=2]="Secondary",n[n.Auxilary=4]="Auxilary",n[n.Forth=8]="Forth",n[n.Five=16]="Five"}(Zi||(Zi={}));const rue={key:"",code:"",modifiers:wu.None,x:-1,y:-1,pageX:-1,pageY:-1,preventDefault:Ag};var T0=function(e){return e[e.Stopped=0]="Stopped",e[e.Started=1]="Started",e[e.Moving=2]="Moving",e}(T0||{});function iue(){return{drag:new mr,interactionEnd:new mr,click:new mr,move:new mr,wheel:new mr,pinch:new mr,gesture:new mr,resize:new mr,leave:new mr,enter:new mr,modifiers:new mr,key:new mr,keyUp:new mr,keyDown:new mr,lock:new mr}}const Rtt=["Backspace","Delete"];var w8;!function(e){e.create=function t(r={}){const{noScroll:i,noContextMenu:o}={...nue,...r};return{noScroll:i,noContextMenu:o,pointerLock:!1,width:0,height:0,pixelRatio:1,...iue(),setPixelScale:Ag,requestPointerLock:Ag,exitPointerLock:Ag,dispose:Ag}},e.fromElement=function n(r,i={}){let{noScroll:o,noContextMenu:a,noPinchZoom:c,noTextSelect:u,mask:l,pixelScale:d,preventGestures:f}={...nue,...i},p=r.clientWidth*I(),m=r.clientHeight*I(),h=!1,g=Lo(),y=0,b=0;const x=Me(),_=Me(),S=Me(),A=Me(),E=Me(),w={shift:!1,alt:!1,control:!1,meta:!1},D={x:-1,y:-1,pageX:-1,pageY:-1};function I(){return window.devicePixelRatio*d}function R(){return{...w}}function T(Ue){return Ue.target===document.body||Ue.target===r}let z,M=T0.Stopped,N=!1,V=Zi.create(Zi.Flag.None),F=Zi.Flag.None,G=!1,L=!1;typeof window.ResizeObserver<"u"&&(z=new window.ResizeObserver(Ut));const j=iue(),{drag:Z,interactionEnd:$,wheel:ee,pinch:q,gesture:O,click:H,move:W,leave:Q,enter:fe,resize:X,modifiers:J,key:ce,keyUp:be,keyDown:ae,lock:me}=j;function ne(){h=r.ownerDocument.pointerLockElement===r,Ed(h),me.next(h)}function de(){console.error("Unable to use Pointer Lock API"),h=!1,Ed(h),me.next(h)}function we(Ue){l(Ue.clientX,Ue.clientY)&&a&&Ue.preventDefault()}function Le(Ue){w.alt=Ue.altKey,w.shift=Ue.shiftKey,w.control=Ue.ctrlKey,w.meta=Ue.metaKey}function We(){(V||w.shift||w.alt||w.meta||w.control)&&(V=0,w.shift=w.alt=w.control=w.meta=!1)}function U(Ue){let tn=!1;!w.alt&&Ue.altKey&&(tn=!0,w.alt=!0),!w.shift&&Ue.shiftKey&&(tn=!0,w.shift=!0),!w.control&&Ue.ctrlKey&&(tn=!0,w.control=!0),!w.meta&&Ue.metaKey&&(tn=!0,w.meta=!0),tn&&G&&J.next(R()),T(Ue)&&G&&ae.next({key:Ue.key,code:Ue.code,modifiers:R(),...D,preventDefault:()=>Ue.preventDefault()})}function Y(Ue){let tn=!1;w.alt&&!Ue.altKey&&(tn=!0,w.alt=!1),w.shift&&!Ue.shiftKey&&(tn=!0,w.shift=!1),w.control&&!Ue.ctrlKey&&(tn=!0,w.control=!1),w.meta&&!Ue.metaKey&&(tn=!0,w.meta=!1),tn&&G&&J.next(R()),Rtt.includes(Ue.key)&&ge(Ue),T(Ue)&&G&&be.next({key:Ue.key,code:Ue.code,modifiers:R(),...D,preventDefault:()=>Ue.preventDefault()})}function ge(Ue){!T(Ue)||!G||ce.next({key:Ue.key,code:Ue.code,modifiers:R(),...D,preventDefault:()=>Ue.preventDefault()})}function Se(Ue){const tn=Ue.touches[0],Ke=Ue.touches[1];return{clientX:(tn.clientX+Ke.clientX)/2,clientY:(tn.clientY+Ke.clientY)/2,pageX:(tn.pageX+Ke.pageX)/2,pageY:(tn.pageY+Ke.pageY)/2,target:Ue.target}}function Re(Ue){const tn=Ue.touches[0].pageX-Ue.touches[1].pageX,Ke=Ue.touches[0].pageY-Ue.touches[1].pageY;return Math.sqrt(tn*tn+Ke*Ke)}!function oe(){r.addEventListener("contextmenu",we,!1),r.addEventListener("wheel",dt,!1),r.addEventListener("mousedown",ut,!1),window.addEventListener("mousemove",Ct,!1),window.addEventListener("mouseup",Et,!1),r.addEventListener("touchstart",Xe,!1),r.addEventListener("touchmove",_t,!1),r.addEventListener("touchend",ot,!1),r.addEventListener("gesturechange",yt,!1),r.addEventListener("gesturestart",ve,!1),r.addEventListener("gestureend",xt,!1),window.addEventListener("blur",We),window.addEventListener("keyup",Y,!1),window.addEventListener("keydown",U,!1),window.addEventListener("keypress",ge,!1),document.addEventListener("pointerlockchange",ne,!1),document.addEventListener("pointerlockerror",de,!1),null!=z?z.observe(r.parentElement):window.addEventListener("resize",Ut,!1)}();let Ge,Ne=-1;const $e=Me(),tt=Me();function Xe(Ue){if(Ue.preventDefault(),Ge=void 0,Ne=-1,1===Ue.touches.length)Ne=0,Me.set($e,Ue.touches[0].pageX,Ue.touches[0].pageY),Ge=Ue.touches[0],V=F=Zi.Flag.Primary,ln(Ue.touches[0]);else if(2===Ue.touches.length){V=Zi.Flag.Secondary&Zi.Flag.Auxilary,F=Zi.Flag.Secondary,ln(Se(Ue));const tn=Re(Ue);y=tn,q.next({distance:tn,fraction:1,fractionDelta:0,delta:0,isStart:!0,buttons:V,button:F,modifiers:R()})}else 3===Ue.touches.length&&(V=F=Zi.Flag.Forth,ln(Se(Ue)))}function ot(Ue){if(Xt(),Ge&&Ne<=4){const tn=Ge;if(!l(tn.clientX,tn.clientY))return;hr(tt,tn);const{pageX:Ke,pageY:Pt}=Pi(tn),[Ht,Ur]=tt;H.next({x:Ht,y:Ur,pageX:Ke,pageY:Pt,buttons:V,button:F,modifiers:R()})}Ge=void 0}function _t(Ue){if(F=Zi.Flag.None,c&&(Ue.preventDefault(),Ue.stopPropagation(),Ue.originalEvent&&(Ue.originalEvent.preventDefault(),Ue.originalEvent.stopPropagation())),Ge=void 0,1===Ue.touches.length)V=Zi.Flag.Primary,Ge=Ue.touches[0],function ke(Ue){Ne<0||(Me.set(tt,Ue.touches[0].pageX,Ue.touches[0].pageY),Ne+=Me.distance($e,tt),Me.copy($e,tt))}(Ue),qe(Ue.touches[0]);else if(2===Ue.touches.length){const tn=Re(Ue),Ke=y-tn;if(Math.abs(Ke)<4)V=Zi.Flag.Secondary,qe(Se(Ue));else{V=Zi.Flag.Auxilary,Le(Ue);const Pt=y/tn;q.next({delta:Ke,fraction:Pt,fractionDelta:b-Pt,distance:tn,isStart:!1,buttons:V,button:F,modifiers:R()}),b=Pt}y=tn}else 3===Ue.touches.length&&(V=Zi.Flag.Forth,qe(Se(Ue)))}function ut(Ue){Le(Ue),V=C8(Ue),F=tue(Ue),ln(Ue)}function Ct(Ue){Le(Ue),V=C8(Ue),F=Zi.Flag.None,qe(Ue)}function Et(Ue){Le(Ue),V=C8(Ue),F=tue(Ue),function Qn(Ue){if(M=T0.Stopped,l(Ue.clientX,Ue.clientY)){if(hr(S,Ue),!L&&Me.distance(S,x)<4){const{pageX:tn,pageY:Ke}=Pi(Ue),[Pt,Ht]=S;H.next({x:Pt,y:Ht,pageX:tn,pageY:Ke,buttons:V,button:F,modifiers:R()})}L=!1}}(Ue),Xt()}function Xt(){$.next(void 0)}function ln(Ue){l(Ue.clientX,Ue.clientY)&&(hr(_,Ue),Me.copy(x,_),Nn(_)&&(M=T0.Started))}function qe(Ue){var tn;hr(S,Ue);const{pageX:Ke,pageY:Pt}=Pi(Ue),[Ht,Ur]=S,{movementX:Zs,movementY:Na}=Ue,gc=Nn(S)&&l(Ue.clientX,Ue.clientY);if(G&&!gc?Q.next(void 0):!G&&gc&&fe.next(void 0),G=gc,D.x=Ht,D.y=Ur,D.pageX=Ke,D.pageY=Pt,W.next({x:Ht,y:Ur,pageX:Ke,pageY:Pt,movementX:Zs,movementY:Na,buttons:V,button:F,modifiers:R(),inside:gc,onElement:Ue.target===r}),M===T0.Stopped||(u&&(null===(tn=Ue.preventDefault)||void 0===tn||tn.call(Ue)),Me.div(A,Me.sub(A,S,_),function hn(Ue){return Ue[0]=r.clientWidth,Ue[1]=r.clientHeight,Ue}(E)),Me.magnitude(A)=4&&(L=!0);const[Jm,eg]=A;Z.next({x:Ht,y:Ur,dx:Jm,dy:eg,pageX:Ke,pageY:Pt,buttons:V,button:F,modifiers:R(),isStart:yc}),Me.copy(_,S),M=T0.Moving}function dt(Ue){if(!l(Ue.clientX,Ue.clientY))return;hr(S,Ue);const{pageX:tn,pageY:Ke}=Pi(Ue),[Pt,Ht]=S;o&&Ue.preventDefault();const Ur=function ktt(e){let i=0,o=0,s=0,a=0,c=0;return"detail"in e&&(o=e.detail),"wheelDelta"in e&&(o=-e.wheelDelta/120),"wheelDeltaY"in e&&(o=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(i=-e.wheelDeltaX/120),"axis"in e&&e.axis===e.HORIZONTAL_AXIS&&(i=o,o=0),s=10*i,a=10*o,"deltaY"in e&&(a=e.deltaY),"deltaX"in e&&(s=e.deltaX),"deltaZ"in e&&(c=e.deltaZ),(s||a||c)&&e.deltaMode&&(1===e.deltaMode?(s*=40,a*=40,c*=40):(s*=800,a*=800,c*=800)),s&&!i&&(i=s<1?-1:1),a&&!o&&(o=a<1?-1:1),{spinX:i,spinY:o,dx:s,dy:a,dz:c}}(Ue);V=F=Zi.Flag.Auxilary,(Ur.dx||Ur.dy||Ur.dz)&&ee.next({x:Pt,y:Ht,pageX:tn,pageY:Ke,...Ur,buttons:V,button:F,modifiers:R()})}function gt(Ue){var tn,Ke;f&&(Ue.preventDefault(),null===(tn=Ue.stopImmediatePropagation)||void 0===tn||tn.call(Ue),null===(Ke=Ue.stopPropagation)||void 0===Ke||Ke.call(Ue))}let se=0,he=0;function ve(Ue){gt(Ue),se=Ue.scale,he=Ue.rotation,O.next({scale:Ue.scale,rotation:Ue.rotation,deltaRotation:0,deltaScale:0,isStart:!0})}function Te(Ue,tn){O.next({scale:Ue.scale,rotation:Ue.rotation,deltaRotation:he-Ue.rotation,deltaScale:se-Ue.scale,isEnd:tn}),he=Ue.rotation,se=Ue.scale}function yt(Ue){gt(Ue),Te(Ue)}function xt(Ue){gt(Ue),Te(Ue,!0)}function Ut(){X.next({})}function Nn(Ue){if(r instanceof Window||r instanceof Document||r===document.body)return!0;{const tn=r.getBoundingClientRect();return Ue[0]>=0&&Ue[1]>=0&&Ue[0]{d=Ue,p=r.clientWidth*I(),m=r.clientHeight*I()},requestPointerLock:Ue=>{g=Ue,h||r.requestPointerLock()},exitPointerLock:()=>{h&&r.ownerDocument.exitPointerLock()},dispose:function K(){N||(N=!0,r.removeEventListener("contextmenu",we,!1),r.removeEventListener("wheel",dt,!1),r.removeEventListener("mousedown",ut,!1),window.removeEventListener("mousemove",Ct,!1),window.removeEventListener("mouseup",Et,!1),r.removeEventListener("touchstart",Xe,!1),r.removeEventListener("touchmove",_t,!1),r.removeEventListener("touchend",ot,!1),r.removeEventListener("gesturechange",yt,!1),r.removeEventListener("gesturestart",ve,!1),r.removeEventListener("gestureend",xt,!1),window.removeEventListener("blur",We),window.removeEventListener("keyup",Y,!1),window.removeEventListener("keydown",U,!1),window.removeEventListener("keypress",ge,!1),document.removeEventListener("pointerlockchange",ne,!1),document.removeEventListener("pointerlockerror",de,!1),ho.remove(),null!=z?(z.unobserve(r.parentElement),z.disconnect()):window.removeEventListener("resize",Ut,!1))}}}}(w8||(w8={}));var D0=function(e){return e[e.None=0]="None",e[e.Object=1]="Object",e[e.Instance=2]="Instance",e[e.Group=3]="Group",e}(D0||{}),_E=function(e){return e[e.None=0]="None",e[e.Depth=1]="Depth",e[e.Mask=2]="Mask",e}(_E||{});const A8={backgroundColor:C.Color(st(0),{description:"Background color of the 3D canvas"}),pickingAlphaThreshold:C.Numeric(.5,{min:0,max:1,step:.01},{description:"The minimum opacity value needed for an object to be pickable."}),interiorDarkening:C.Numeric(.5,{min:0,max:1,step:.01}),interiorColorFlag:C.Boolean(!0,{label:"Use Interior Color"}),interiorColor:C.Color(st.fromNormalizedRgb(.3,.3,.3)),colorMarker:C.Boolean(!0,{description:"Enable color marker"}),highlightColor:C.Color(st.fromNormalizedRgb(1,.4,.6)),selectColor:C.Color(st.fromNormalizedRgb(.2,1,.1)),dimColor:C.Color(st.fromNormalizedRgb(1,1,1)),highlightStrength:C.Numeric(.3,{min:0,max:1,step:.1}),selectStrength:C.Numeric(.3,{min:0,max:1,step:.1}),dimStrength:C.Numeric(0,{min:0,max:1,step:.1}),markerPriority:C.Select(1,[[1,"Highlight"],[2,"Select"]]),xrayEdgeFalloff:C.Numeric(1,{min:0,max:3,step:.1}),exposure:C.Numeric(1,{min:0,max:3,step:.01}),light:C.ObjectList({inclination:C.Numeric(150,{min:0,max:180,step:1}),azimuth:C.Numeric(320,{min:0,max:360,step:1}),color:C.Color(st.fromNormalizedRgb(1,1,1)),intensity:C.Numeric(.6,{min:0,max:5,step:.01})},e=>st.toHexString(e.color),{defaultValue:[{inclination:150,azimuth:320,color:st.fromNormalizedRgb(1,1,1),intensity:.6}]}),ambientColor:C.Color(st.fromNormalizedRgb(1,1,1)),ambientIntensity:C.Numeric(.4,{min:0,max:2,step:.01})},oue=v(),I8=v();function sue(e,t){const n=e.length,{direction:r,color:i}=t||{direction:new Array(3*n).fill(0),color:new Array(3*n).fill(0)};for(let o=0;o{var K,ne,de;if(ae.state.disposed||!ae.state.visible||!ae.state.pickable&&"pick"===me||!p0.intersectsSphere3D(R,ae.values.boundingSphere.ref.value))return;const[we,Le]=ae.values.uLod.ref.value;if(0!==we||0!==Le){const{center:Y,radius:ge}=ae.values.boundingSphere.ref.value,Se=Gi.distanceToPoint(D,Y);if(Se+geLe)return}ae.values.instanceGrid.ref.value.cellSize>1||ae.values.lodLevels?ae.cull(D,R,p,n.stats):ae.uncull();let We=!1;ae.values.dLightCount.ref.value!==c.count&&(k.update(ae.values.dLightCount,c.count),We=!0),ae.values.dColorMarker.ref.value!==a.colorMarker&&(k.update(ae.values.dColorMarker,a.colorMarker),We=!0),We&&ae.update();const U=ae.getProgram(me);if(o.currentProgramId!==U.id&&(V=!0,U.use()),V&&(U.setUniforms(N),U.bindTextures(h,0),V=!1),"directVolume"===ae.values.dGeometryType.ref.value){if("color"!==me)return;o.disable(i.CULL_FACE),o.frontFace(i.CCW),3===oe&&(o.disable(i.DEPTH_TEST),o.depthMask(!1))}else 1===oe?(o.enable(i.CULL_FACE),null!==(K=ae.values.dFlipSided)&&void 0!==K&&K.ref.value?(o.frontFace(i.CW),o.cullFace(i.FRONT)):(o.frontFace(i.CCW),o.cullFace(i.BACK))):2===oe?(o.enable(i.CULL_FACE),null!==(ne=ae.values.dFlipSided)&&void 0!==ne&&ne.ref.value?(o.frontFace(i.CW),o.cullFace(i.BACK)):(o.frontFace(i.CCW),o.cullFace(i.FRONT))):(ae.values.uDoubleSided?ae.values.uDoubleSided.ref.value||ae.values.hasReflection.ref.value?o.disable(i.CULL_FACE):o.enable(i.CULL_FACE):o.disable(i.CULL_FACE),null!==(de=ae.values.dFlipSided)&&void 0!==de&&de.ref.value?(o.frontFace(i.CW),o.cullFace(i.FRONT)):(o.frontFace(i.CCW),o.cullFace(i.BACK)));ae.render(me,h.length)},L=(ae,me,oe,K,ne)=>{GI(h,"tDepth",oe||m),k.update(M.uModel,ae.view),k.update(M.uModelView,le.mul(b,me.view,ae.view)),k.update(M.uInvModelView,le.invert(x,b)),k.update(M.uModelViewProjection,le.mul(S,b,me.projection)),k.update(M.uInvModelViewProjection,le.invert(A,S)),k.updateIfChanged(M.uRenderMask,K),k.updateIfChanged(M.uMarkingDepthTest,ne),o.enable(i.SCISSOR_TEST),o.colorMask(!0,!0,!0,!0);const{x:de,y:we,width:Le,height:We}=u;o.viewport(de,we,Le,We),o.scissor(de,we,Le,We),V=!0,o.currentRenderItemId=-1},H=(ae,me,oe)=>{var K,ne;lt&&n.timer.mark("Renderer.renderBlendedOpaque"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,1,!1);const{renderables:de}=ae;for(let we=0,Le=de.length;we{var K,ne;lt&&n.timer.mark("Renderer.renderBlendedTransparent"),o.enable(i.DEPTH_TEST),L(ae,me,oe,2,!1);const{renderables:de}=ae;f?o.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA):o.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA),o.enable(i.BLEND),o.depthMask(!0);for(let we=0,Le=de.length;we0)&&(null!==(K=We.values.uDoubleSided)&&void 0!==K&&K.ref.value?("opaque"!==(null===(ne=We.values.dTransparentBackfaces)||void 0===ne?void 0:ne.ref.value)&&F(We,"color",2),F(We,"color",1)):F(We,"color",0))}lt&&n.timer.markEnd("Renderer.renderBlendedTransparent")};return{clear:(ae,me)=>{o.enable(i.SCISSOR_TEST),o.enable(i.DEPTH_TEST),o.colorMask(!0,!0,!0,!0),o.depthMask(!0),f&&!me?o.clearColor(0,0,0,0):ae?o.clearColor(d[0],d[1],d[2],1):o.clearColor(1,1,1,1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT)},clearDepth:(ae=!1)=>{o.enable(i.SCISSOR_TEST),ae?(o.colorMask(!0,!0,!0,!0),o.clearColor(1,1,1,1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT)):(o.enable(i.DEPTH_TEST),o.depthMask(!0),i.clear(i.DEPTH_BUFFER_BIT))},update:(ae,me)=>{k.update(M.uView,ae.view),k.update(M.uInvView,le.invert(y,ae.view)),k.update(M.uProjection,ae.projection),k.update(M.uInvProjection,le.invert(_,ae.projection)),k.updateIfChanged(M.uIsOrtho,"orthographic"===ae.state.mode?1:0),k.update(M.uViewOffset,ae.viewOffset.enabled?Me.set(I,16*ae.viewOffset.offsetX,16*ae.viewOffset.offsetY):Me.set(I,0,0)),k.update(M.uCameraPosition,v.copy(w,ae.state.position)),k.update(M.uCameraDir,v.normalize(E,v.sub(E,ae.state.target,ae.state.position))),k.updateIfChanged(M.uFar,ae.far),k.updateIfChanged(M.uNear,ae.near),k.updateIfChanged(M.uFog,ae.state.fog>0),k.updateIfChanged(M.uFogFar,ae.fogFar),k.updateIfChanged(M.uFogNear,ae.fogNear),k.updateIfChanged(M.uTransparentBackground,f),p0.fromProjectionMatrix(R,ae.projectionView),Gi.copy(D,R[5]),D.constant-=Gi.distanceToPoint(D,w),k.update(M.uCameraPlane,Gi.toArray(D,M.uCameraPlane.ref.value,0)),k.updateIfChanged(M.uMarkerAverage,me.markerAverage)},renderPick:(ae,me,oe,K,ne)=>{lt&&n.timer.mark("Renderer.renderPick"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,K,0,!1),k.updateIfChanged(M.uPickType,ne);const{renderables:de}=ae;for(let we=0,Le=de.length;we{lt&&n.timer.mark("Renderer.renderDepth"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,0,!1);const{renderables:K}=ae;for(let ne=0,de=K.length;ne{var K,ne;lt&&n.timer.mark("Renderer.renderDepthOpaque"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,1,!1);const{renderables:de}=ae;for(let we=0,Le=de.length;we{var K,ne;lt&&n.timer.mark("Renderer.renderDepthTransparent"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,2,!1);const{renderables:de}=ae;for(let we=0,Le=de.length;we0||U)&&F(We,"depth",0)}lt&&n.timer.markEnd("Renderer.renderDepthTransparent")},renderMarkingDepth:(ae,me,oe)=>{lt&&n.timer.mark("Renderer.renderMarkingDepth"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,0,!1),k.updateIfChanged(M.uMarkingType,_E.Depth);const{renderables:K}=ae;for(let ne=0,de=K.length;ne{lt&&n.timer.mark("Renderer.renderMarkingMask"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,0,!!oe),k.updateIfChanged(M.uMarkingType,_E.Mask);const{renderables:K}=ae;for(let ne=0,de=K.length;ne0&&F(K[ne],"marking",0);lt&&n.timer.markEnd("Renderer.renderMarkingMask")},renderBlended:(ae,me)=>{ae.hasOpaque&&H(ae,me,null),ae.opacityAverage<1&&W(ae,me,null)},renderBlendedOpaque:H,renderBlendedTransparent:W,renderBlendedVolume:(ae,me,oe)=>{lt&&n.timer.mark("Renderer.renderBlendedVolume"),o.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA),o.enable(i.BLEND),L(ae,me,oe,2,!1);const{renderables:K}=ae;for(let ne=0,de=K.length;ne{var K,ne,de,we;lt&&n.timer.mark("Renderer.renderWboitOpaque"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,1,!1);const{renderables:Le}=ae;for(let We=0,U=Le.length;We{var K,ne,de;lt&&n.timer.mark("Renderer.renderWboitTransparent"),L(ae,me,oe,2,!1);const{renderables:we}=ae;for(let Le=0,We=we.length;Le0||"directVolume"===U.values.dGeometryType.ref.value||"fuzzy"===(null===(de=U.values.dPointStyle)||void 0===de?void 0:de.ref.value)||"text"===U.values.dGeometryType.ref.value||ge)&&F(U,"color",0)}lt&&n.timer.markEnd("Renderer.renderWboitTransparent")},renderDpoitOpaque:(ae,me,oe)=>{var K,ne,de,we;lt&&n.timer.mark("Renderer.renderDpoitOpaque"),o.disable(i.BLEND),o.enable(i.DEPTH_TEST),o.depthMask(!0),L(ae,me,oe,1,!1);const{renderables:Le}=ae;for(let We=0,U=Le.length;We{var ne,de,we;lt&&n.timer.mark("Renderer.renderDpoitTransparent"),o.enable(i.BLEND),GI(h,"tDpoitDepth",K.depth),GI(h,"tDpoitFrontColor",K.frontColor),GI(h,"tDpoitBackColor",K.backColor),L(ae,me,oe,2,!1);const{renderables:Le}=ae;for(let We=0,U=Le.length;We0||"fuzzy"===(null===(we=Y.values.dPointStyle)||void 0===we?void 0:we.ref.value)||"text"===Y.values.dGeometryType.ref.value||Se)&&F(Y,"color",0)}lt&&n.timer.markEnd("Renderer.renderDpoitTransparent")},renderDpoitVolume:(ae,me,oe)=>{lt&&n.timer.mark("Renderer.renderDpoitVolume"),o.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA),o.enable(i.BLEND),L(ae,me,oe,2,!1);const{renderables:K}=ae;for(let ne=0,de=K.length;ne{void 0!==ae.backgroundColor&&ae.backgroundColor!==a.backgroundColor&&(a.backgroundColor=ae.backgroundColor,st.toVec3Normalized(d,a.backgroundColor),k.update(M.uFogColor,v.copy(M.uFogColor.ref.value,d))),void 0!==ae.pickingAlphaThreshold&&ae.pickingAlphaThreshold!==a.pickingAlphaThreshold&&(a.pickingAlphaThreshold=ae.pickingAlphaThreshold,k.update(M.uPickingAlphaThreshold,a.pickingAlphaThreshold)),void 0!==ae.interiorDarkening&&ae.interiorDarkening!==a.interiorDarkening&&(a.interiorDarkening=ae.interiorDarkening,k.update(M.uInteriorDarkening,a.interiorDarkening)),void 0!==ae.interiorColorFlag&&ae.interiorColorFlag!==a.interiorColorFlag&&(a.interiorColorFlag=ae.interiorColorFlag,k.update(M.uInteriorColorFlag,a.interiorColorFlag)),void 0!==ae.interiorColor&&ae.interiorColor!==a.interiorColor&&(a.interiorColor=ae.interiorColor,k.update(M.uInteriorColor,st.toVec3Normalized(M.uInteriorColor.ref.value,a.interiorColor))),void 0!==ae.colorMarker&&ae.colorMarker!==a.colorMarker&&(a.colorMarker=ae.colorMarker),void 0!==ae.highlightColor&&ae.highlightColor!==a.highlightColor&&(a.highlightColor=ae.highlightColor,k.update(M.uHighlightColor,st.toVec3Normalized(M.uHighlightColor.ref.value,a.highlightColor))),void 0!==ae.selectColor&&ae.selectColor!==a.selectColor&&(a.selectColor=ae.selectColor,k.update(M.uSelectColor,st.toVec3Normalized(M.uSelectColor.ref.value,a.selectColor))),void 0!==ae.dimColor&&ae.dimColor!==a.dimColor&&(a.dimColor=ae.dimColor,k.update(M.uDimColor,st.toVec3Normalized(M.uDimColor.ref.value,a.dimColor))),void 0!==ae.highlightStrength&&ae.highlightStrength!==a.highlightStrength&&(a.highlightStrength=ae.highlightStrength,k.update(M.uHighlightStrength,a.highlightStrength)),void 0!==ae.selectStrength&&ae.selectStrength!==a.selectStrength&&(a.selectStrength=ae.selectStrength,k.update(M.uSelectStrength,a.selectStrength)),void 0!==ae.dimStrength&&ae.dimStrength!==a.dimStrength&&(a.dimStrength=ae.dimStrength,k.update(M.uDimStrength,a.dimStrength)),void 0!==ae.markerPriority&&ae.markerPriority!==a.markerPriority&&(a.markerPriority=ae.markerPriority,k.update(M.uMarkerPriority,a.markerPriority)),void 0!==ae.xrayEdgeFalloff&&ae.xrayEdgeFalloff!==a.xrayEdgeFalloff&&(a.xrayEdgeFalloff=ae.xrayEdgeFalloff,k.update(M.uXrayEdgeFalloff,a.xrayEdgeFalloff)),void 0!==ae.exposure&&ae.exposure!==a.exposure&&(a.exposure=ae.exposure,k.update(M.uExposure,a.exposure)),void 0!==ae.light&&!Yd(ae.light,a.light)&&(a.light=ae.light,Object.assign(c,sue(ae.light,c)),k.update(M.uLightDirection,c.direction),k.update(M.uLightColor,c.color)),void 0!==ae.ambientColor&&ae.ambientColor!==a.ambientColor&&(a.ambientColor=ae.ambientColor,v.scale(T,st.toArrayNormalized(a.ambientColor,T,0),a.ambientIntensity),k.update(M.uAmbientColor,T)),void 0!==ae.ambientIntensity&&ae.ambientIntensity!==a.ambientIntensity&&(a.ambientIntensity=ae.ambientIntensity,v.scale(T,st.toArrayNormalized(a.ambientColor,T,0),a.ambientIntensity),k.update(M.uAmbientColor,T))},setViewport:(ae,me,oe,K)=>{o.viewport(ae,me,oe,K),o.scissor(ae,me,oe,K),(ae!==u.x||me!==u.y||oe!==u.width||K!==u.height)&&(Lo.set(u,ae,me,oe,K),k.update(M.uViewport,nn.set(M.uViewport.ref.value,ae,me,oe,K)))},setTransparentBackground:ae=>{f=ae},setDrawingBufferSize:(ae,me)=>{(ae!==l[0]||me!==l[1])&&k.update(M.uDrawingBufferSize,Me.set(l,ae,me))},setPixelRatio:ae=>{k.update(M.uPixelRatio,ae)},setOcclusionTest:ae=>{p=ae},props:a,get stats(){return{programCount:n.stats.resourceCounts.program,shaderCount:n.stats.resourceCounts.shader,attributeCount:n.stats.resourceCounts.attribute,elementsCount:n.stats.resourceCounts.elements,framebufferCount:n.stats.resourceCounts.framebuffer,renderbufferCount:n.stats.resourceCounts.renderbuffer,textureCount:n.stats.resourceCounts.texture,vertexArrayCount:n.stats.resourceCounts.vertexArray,drawCount:s.drawCount,instanceCount:s.instanceCount,instancedDrawCount:s.instancedDrawCount}},get light(){return c},dispose:()=>{}}}}(T8||(T8={})),function(e){function s(l){return l.triggers.map(c.format).join(" or ")}function c(l,d){return c.create(l,d)}var l;e.create=function t(l,d="",f=""){return{triggers:l,action:d,description:f}},e.isBinding=function n(l){return!!l&&Array.isArray(l.triggers)&&"string"==typeof l.action},e.Empty={triggers:[],action:"",description:""},e.isEmpty=function r(l){return 0===l.triggers.length||l.triggers.every(d=>void 0===d.buttons&&void 0===d.modifiers&&!d.code)},e.match=function i(l,d,f){return l.triggers.some(p=>c.match(p,d,f))},e.matchKey=function o(l,d,f,p){return l.triggers.some(m=>c.matchKey(m,d,f,p))},e.formatTriggers=s,e.format=function a(l,d=""){return function RNe(e,t){const n=Object.keys(t),r=Object.values(t);return new Function(...n,`return \`${e}\`;`)(...r)}(l.description||zu(d),{triggers:""+s(l)+""})},e.Trigger=c,e.TriggerKey=function u(l,d){return c.create(void 0,d,l)},(l=c=e.Trigger||(e.Trigger={})).create=function d(h,g,y){return{buttons:h,modifiers:g,code:y}},l.Empty={},l.match=function f(h,g,y){const{buttons:b,modifiers:x}=h;return void 0!==b&&(b===g||Zi.has(b,g))&&(!x||wu.areEqual(x,y))},l.matchKey=function p(h,g,y,b){const{modifiers:x,code:_}=h;return void 0!==_&&(_===g||1===_.length&&4===g.length&&g.startsWith("Key")&&!!b&&1===b.length&&b.toUpperCase()===_.toUpperCase())&&(!x||wu.areEqual(x,y))},l.format=function m(h){const g=[],y=function Ntt(e,t){const n=[];return void 0!==e||t?0===e?n.push("mouse hover"):void 0!==e&&(Cm.has(e,Cm.Flag.Primary)&&n.push("left mouse button"),Cm.has(e,Cm.Flag.Secondary)&&n.push("right mouse button"),Cm.has(e,Cm.Flag.Auxilary)&&n.push("wheel/middle mouse button"),Cm.has(e,Cm.Flag.Forth)&&n.push("three fingers")):n.push("any mouse button"),n.join(" + ")}(h.buttons,h.code);y&&g.push(y);const b=function Btt(e){return e?.startsWith("Key")&&(e=e.substring(3)),e&&function ENe(e){return Fg(RQ(e))}(e).toLowerCase()}(h.code);b&&g.push(b);const x=function Ftt(e,t){const n=[];return e?(e.alt&&n.push("alt key"),e.control&&n.push("control key"),e.meta&&n.push("meta/command key"),e.shift&&n.push("shift key"),t&&0===n.length&&n.push("no key")):t&&n.push("any key"),n.join(" + ")}(h.modifiers);return x&&g.push(x),g.join(" + ")}}(At||(At={}));const Cm=Zi,wm=Zi,Au=wu,Am=At.Trigger,Vc=At.TriggerKey,aue={dragRotate:At([Am(wm.Flag.Primary,Au.create())],"Rotate","Drag using ${triggers}"),dragRotateZ:At([Am(wm.Flag.Primary,Au.create({shift:!0,control:!0}))],"Rotate around z-axis (roll)","Drag using ${triggers}"),dragPan:At([Am(wm.Flag.Secondary,Au.create()),Am(wm.Flag.Primary,Au.create({control:!0}))],"Pan","Drag using ${triggers}"),dragZoom:At.Empty,dragFocus:At([Am(wm.Flag.Forth,Au.create())],"Focus","Drag using ${triggers}"),dragFocusZoom:At([Am(wm.Flag.Auxilary,Au.create())],"Focus and zoom","Drag using ${triggers}"),scrollZoom:At([Am(wm.Flag.Auxilary,Au.create())],"Zoom","Scroll using ${triggers}"),scrollFocus:At([Am(wm.Flag.Auxilary,Au.create({shift:!0}))],"Clip","Scroll using ${triggers}"),scrollFocusZoom:At.Empty,keyMoveForward:At([Vc("KeyW")],"Move forward","Press ${triggers}"),keyMoveBack:At([Vc("KeyS")],"Move back","Press ${triggers}"),keyMoveLeft:At([Vc("KeyA")],"Move left","Press ${triggers}"),keyMoveRight:At([Vc("KeyD")],"Move right","Press ${triggers}"),keyMoveUp:At([Vc("KeyR")],"Move up","Press ${triggers}"),keyMoveDown:At([Vc("KeyF")],"Move down","Press ${triggers}"),keyRollLeft:At([Vc("KeyQ")],"Roll left","Press ${triggers}"),keyRollRight:At([Vc("KeyE")],"Roll right","Press ${triggers}"),keyPitchUp:At([Vc("ArrowUp",Au.create({shift:!0}))],"Pitch up","Press ${triggers}"),keyPitchDown:At([Vc("ArrowDown",Au.create({shift:!0}))],"Pitch down","Press ${triggers}"),keyYawLeft:At([Vc("ArrowLeft",Au.create({shift:!0}))],"Yaw left","Press ${triggers}"),keyYawRight:At([Vc("ArrowRight",Au.create({shift:!0}))],"Yaw right","Press ${triggers}"),boostMove:At([Vc("ShiftLeft")],"Boost move","Press ${triggers}"),enablePointerLock:At([Vc("Space",Au.create({control:!0}))],"Enable pointer lock","Press ${triggers}")},cue={noScroll:C.Boolean(!0,{isHidden:!0}),rotateSpeed:C.Numeric(5,{min:1,max:10,step:1}),zoomSpeed:C.Numeric(7,{min:1,max:15,step:1}),panSpeed:C.Numeric(1,{min:.1,max:5,step:.1}),moveSpeed:C.Numeric(.75,{min:.1,max:3,step:.1}),boostMoveFactor:C.Numeric(5,{min:.1,max:10,step:.1}),flyMode:C.Boolean(!1),animate:C.MappedStatic("off",{off:C.EmptyGroup(),spin:C.Group({speed:C.Numeric(1,{min:-20,max:20,step:1})},{description:"Spin the 3D scene around the x-axis in view space"}),rock:C.Group({speed:C.Numeric(.3,{min:-5,max:5,step:.1}),angle:C.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:C.Boolean(!0,{isHidden:!0}),dynamicDampingFactor:C.Numeric(.2,{},{isHidden:!0}),minDistance:C.Numeric(.01,{},{isHidden:!0}),maxDistance:C.Numeric(1e150,{},{isHidden:!0}),gestureScaleFactor:C.Numeric(1,{},{isHidden:!0}),maxWheelDelta:C.Numeric(.02,{},{isHidden:!0}),bindings:C.Value(aue,{isHidden:!0}),autoAdjustMinMaxDistance:C.MappedStatic("on",{off:C.EmptyGroup(),on:C.Group({minDistanceFactor:C.Numeric(0),minDistancePadding:C.Numeric(5),maxDistanceFactor:C.Numeric(10),maxDistanceMin:C.Numeric(20)})},{isHidden:!0})};var D8,xE;!function(e){e.create=function t(n,r,i,o={}){const s={...C.getDefaultValues(cue),...o,bindings:{...aue,...o.bindings}},a=s.bindings,c=Lo.clone(r.viewport);let u=!1;const l=n.drag.subscribe(function Qn({x:Ke,y:Pt,pageX:Ht,pageY:Ur,buttons:Zs,modifiers:Na,isStart:gc}){const yc=Ct(Ke,Pt);if(gc&&yc||!gc&&!_)return;_=!0,Ue();const Jm=At.match(a.dragRotate,Zs,Na),eg=At.match(a.dragRotateZ,Zs,Na),Z1=At.match(a.dragPan,Zs,Na),Q1=At.match(a.dragZoom,Zs,Na),J1=At.match(a.dragFocus,Zs,Na),hy=At.match(a.dragFocusZoom,Zs,Na);Q(Ht,Ur),function H(Ke,Pt){Me.set(O,(Ke-c.x)/c.width,(Pt-c.y)/c.height)}(Ht,Ur);const e_=n.pixelRatio,t_=(Ke*e_-c.width/2-c.x)/c.width,n_=-(n.height-Pt*e_-c.height/2-c.y)/c.height;if(gc&&(Jm&&(Me.copy(w,W),Me.copy(E,w)),eg&&(Me.set(T,t_,n_),Me.copy(R,T)),(Q1||hy)&&(Me.copy(F,O),Me.copy(G,F)),J1&&(Me.copy(L,O),Me.copy(z,L)),Z1&&(Me.copy(j,O),Me.copy(Z,j))),Jm&&Me.copy(w,W),eg&&Me.set(T,t_,n_),(Q1||hy)&&Me.copy(G,O),J1&&Me.copy(z,O),hy){const my=v.distance(r.state.position,r.state.target);r.setState({radius:my/5})}Z1&&Me.copy(Z,O)}),d=n.interactionEnd.subscribe(function qe(){_=!1}),f=n.wheel.subscribe(function dt({x:Ke,y:Pt,spinX:Ht,spinY:Ur,dz:Zs,buttons:Na,modifiers:gc}){if(Ct(Ke,Pt))return;let yc=function nMe(...e){let t=0,n=0;for(let r=0,i=e.length;rn&&(t=o,n=s)}return t}(.075*Ht,.075*Ur,1e-4*Zs);yc<-s.maxWheelDelta?yc=-s.maxWheelDelta:yc>s.maxWheelDelta&&(yc=s.maxWheelDelta),At.match(a.scrollZoom,Na,gc)&&(G[1]+=yc),At.match(a.scrollFocus,Na,gc)&&(z[1]+=yc)}),p=n.pinch.subscribe(function gt({fractionDelta:Ke,buttons:Pt,modifiers:Ht}){At.match(a.scrollZoom,Pt,Ht)&&(_=!0,G[1]+=s.gestureScaleFactor*Ke)}),m=n.gesture.subscribe(function se({deltaScale:Ke}){_=!0,G[1]+=s.gestureScaleFactor*Ke}),h=n.keyDown.subscribe(function ve({modifiers:Ke,code:Pt,key:Ht,x:Ur,y:Zs}){Ct(Ur,Zs)||(At.matchKey(a.keyMoveForward,Pt,Ke,Ht)?ke.moveForward=1:At.matchKey(a.keyMoveBack,Pt,Ke,Ht)?ke.moveBack=1:At.matchKey(a.keyMoveLeft,Pt,Ke,Ht)?ke.moveLeft=1:At.matchKey(a.keyMoveRight,Pt,Ke,Ht)?ke.moveRight=1:At.matchKey(a.keyMoveUp,Pt,Ke,Ht)?ke.moveUp=1:At.matchKey(a.keyMoveDown,Pt,Ke,Ht)?ke.moveDown=1:At.matchKey(a.keyRollLeft,Pt,Ke,Ht)?ke.rollLeft=1:At.matchKey(a.keyRollRight,Pt,Ke,Ht)?ke.rollRight=1:At.matchKey(a.keyPitchUp,Pt,Ke,Ht)?ke.pitchUp=1:At.matchKey(a.keyPitchDown,Pt,Ke,Ht)?ke.pitchDown=1:At.matchKey(a.keyYawLeft,Pt,Ke,Ht)?ke.yawLeft=1:At.matchKey(a.keyYawRight,Pt,Ke,Ht)&&(ke.yawRight=1),At.matchKey(a.boostMove,Pt,Ke,Ht)&&(ke.boostMove=1),At.matchKey(a.enablePointerLock,Pt,Ke,Ht)&&n.requestPointerLock(c))}),g=n.keyUp.subscribe(function Te({modifiers:Ke,code:Pt,key:Ht,x:Ur,y:Zs}){var Na,gc,yc,Jm,eg,Z1,Q1,J1,hy,e_,t_,n_;if(Ct(Ur,Zs))return;let my=!1;Pt.startsWith("Alt")?(my=!0,Ke.alt=!0):Pt.startsWith("Shift")?(my=!0,Ke.shift=!0):Pt.startsWith("Control")?(my=!0,Ke.control=!0):Pt.startsWith("Meta")&&(my=!0,Ke.meta=!0);const Wc=[];my?(ke.moveForward&&Wc.push((null===(Na=a.keyMoveForward.triggers[0])||void 0===Na?void 0:Na.code)||""),ke.moveBack&&Wc.push((null===(gc=a.keyMoveBack.triggers[0])||void 0===gc?void 0:gc.code)||""),ke.moveLeft&&Wc.push((null===(yc=a.keyMoveLeft.triggers[0])||void 0===yc?void 0:yc.code)||""),ke.moveRight&&Wc.push((null===(Jm=a.keyMoveRight.triggers[0])||void 0===Jm?void 0:Jm.code)||""),ke.moveUp&&Wc.push((null===(eg=a.keyMoveUp.triggers[0])||void 0===eg?void 0:eg.code)||""),ke.moveDown&&Wc.push((null===(Z1=a.keyMoveDown.triggers[0])||void 0===Z1?void 0:Z1.code)||""),ke.rollLeft&&Wc.push((null===(Q1=a.keyRollLeft.triggers[0])||void 0===Q1?void 0:Q1.code)||""),ke.rollRight&&Wc.push((null===(J1=a.keyRollRight.triggers[0])||void 0===J1?void 0:J1.code)||""),ke.pitchUp&&Wc.push((null===(hy=a.keyPitchUp.triggers[0])||void 0===hy?void 0:hy.code)||""),ke.pitchDown&&Wc.push((null===(e_=a.keyPitchDown.triggers[0])||void 0===e_?void 0:e_.code)||""),ke.yawLeft&&Wc.push((null===(t_=a.keyYawLeft.triggers[0])||void 0===t_?void 0:t_.code)||""),ke.yawRight&&Wc.push((null===(n_=a.keyYawRight.triggers[0])||void 0===n_?void 0:n_.code)||"")):Wc.push(Pt);for(const Nl of Wc)At.matchKey(a.keyMoveForward,Nl,Ke,Ht)?ke.moveForward=0:At.matchKey(a.keyMoveBack,Nl,Ke,Ht)?ke.moveBack=0:At.matchKey(a.keyMoveLeft,Nl,Ke,Ht)?ke.moveLeft=0:At.matchKey(a.keyMoveRight,Nl,Ke,Ht)?ke.moveRight=0:At.matchKey(a.keyMoveUp,Nl,Ke,Ht)?ke.moveUp=0:At.matchKey(a.keyMoveDown,Nl,Ke,Ht)?ke.moveDown=0:At.matchKey(a.keyRollLeft,Nl,Ke,Ht)?ke.rollLeft=0:At.matchKey(a.keyRollRight,Nl,Ke,Ht)?ke.rollRight=0:At.matchKey(a.keyPitchUp,Nl,Ke,Ht)?ke.pitchUp=0:At.matchKey(a.keyPitchDown,Nl,Ke,Ht)?ke.pitchDown=0:At.matchKey(a.keyYawLeft,Nl,Ke,Ht)?ke.yawLeft=0:At.matchKey(a.keyYawRight,Nl,Ke,Ht)&&(ke.yawRight=0);At.matchKey(a.boostMove,Pt,Ke,Ht)&&(ke.boostMove=0)}),y=n.move.subscribe(function he({movementX:Ke,movementY:Pt}){if(!n.pointerLock||void 0===Ke||void 0===Pt)return;const Ht=.5*c.width-c.x,Ur=.5*c.height-c.y;Me.copy(E,Q(Ht,Ur)),Me.copy(w,Q(Ke+Ht,Pt+Ur))}),b=n.lock.subscribe(function Ut(Ke){Ke?yt():xt()}),x=n.leave.subscribe(function hn(){!function Nn(){ke.moveForward=0,ke.moveBack=0,ke.moveLeft=0,ke.moveRight=0,ke.moveUp=0,ke.moveDown=0,ke.rollLeft=0,ke.rollRight=0,ke.pitchUp=0,ke.pitchDown=0,ke.yawLeft=0,ke.yawRight=0,ke.boostMove=0}()});let _=!1;const S=v(),A=v(),E=Me(),w=Me(),D=v();let I=0;const R=Me(),T=Me();let M=0,N=0,V=0;const F=Me(),G=Me(),L=Me(),z=Me(),j=Me(),Z=Me(),$=v.clone(r.target),ee=v.clone(r.position),q=v.clone(r.up),O=Me(),W=Me();function Q(Ke,Pt){return Me.set(W,(Ke-.5*c.width-c.x)/(.5*c.width),(c.height+2*(c.y-Pt))/c.width)}function fe(){return s.rotateSpeed*n.pixelRatio*(n.width/n.height)}const X=v(),J=_r(),ce=v(),be=v(),ae=v(),me=v(),K=_r(),ne=v(),we=_r(),Le=v(),U=_r(),Y=v(),Ne=Me(),Ge=v(),$e=v(),ke={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},Xe=v(),ot=v();function ut(){const Ke=Math.min(Math.max(1e3*r.state.radiusMax,.01),s.maxDistance);v.squaredMagnitude(A)>Ke*Ke&&(v.setMagnitude(A,A,Ke),v.add(r.position,r.target,A),Me.copy(F,G),Me.copy(L,z)),v.squaredMagnitude(A)c.x+c.width||n.height-Pt>c.y+c.height||Ke0&&("spin"===s.animate.name?function Ks(Ke){if("spin"!==s.animate.name||0===s.animate.params.speed||_)return;const Pt=s.animate.params.speed/1e3;Pi[0]=60*Math.min(Math.abs(Ke),125)/1e3*Pt,Me.add(w,E,Pi)}(Pt):"rock"===s.animate.name&&function Ed(Ke){if("rock"!==s.animate.name||0===s.animate.params.speed||_)return;const Pt=Ke/1e3*s.animate.params.speed,Ht=Yn(s.animate.params.angle)/fe(),Ur=Math.sin(ho*Math.PI*2)*Ht,Zs=Math.sin((ho+Pt)*Math.PI*2)*Ht;mc[0]=Zs-Ur,Me.add(w,E,mc),ho+=Pt,ho>=1&&(ho=0)}(Pt)),v.sub(A,r.position,r.target),function oe(){const Ke=w[0]-E[0],Pt=w[1]-E[1];v.set(me,Ke,Pt,0);const Ht=v.magnitude(me)*fe();Ht?(v.sub(A,r.position,r.target),v.normalize(ce,A),v.normalize(be,r.up),v.normalize(ae,v.cross(ae,be,ce)),v.setMagnitude(be,be,Pt),v.setMagnitude(ae,ae,Ke),v.add(me,be,ae),v.normalize(X,v.cross(X,me,A)),_r.setAxisAngle(J,X,Ht),v.transformQuat(A,A,J),v.transformQuat(r.up,r.up,J),v.copy(D,X),I=Ht):!s.staticMoving&&I&&(I*=Math.sqrt(1-s.dynamicDampingFactor),v.sub(A,r.position,r.target),_r.setAxisAngle(J,D,I),v.transformQuat(A,A,J),v.transformQuat(r.up,r.up,J)),Me.copy(E,w)}(),function de(){const Ke=(ke.rollRight-ke.rollLeft)/45,Pt=(T[0]-R[0])*-Math.sign(T[1]),Ht=(T[1]-R[1])*-Math.sign(T[0]),Ur=-s.rotateSpeed*(-Pt+Ht)+Ke;Ur?(v.normalize(ne,A),_r.setAxisAngle(K,ne,Ur),v.transformQuat(r.up,r.up,K),M=Ur):!s.staticMoving&&M&&(M*=Math.sqrt(1-s.dynamicDampingFactor),v.normalize(ne,A),_r.setAxisAngle(K,ne,M),v.transformQuat(r.up,r.up,K)),Me.copy(R,T)}(),function We(){const Pt=(ke.pitchUp-ke.pitchDown)/(s.flyMode?360:90)*-s.rotateSpeed;Pt?(v.cross(Le,A,r.up),v.normalize(Le,Le),_r.setAxisAngle(we,Le,Pt),v.transformQuat(A,A,we),v.transformQuat(r.up,r.up,we),N=Pt):!s.staticMoving&&N&&(N*=Math.sqrt(1-s.dynamicDampingFactor),v.cross(Le,A,r.up),v.normalize(Le,Le),_r.setAxisAngle(we,Le,N),v.transformQuat(A,A,we),v.transformQuat(r.up,r.up,we))}(),function ge(){const Pt=(ke.yawRight-ke.yawLeft)/(s.flyMode?360:90)*-s.rotateSpeed;Pt?(v.normalize(Y,r.up),_r.setAxisAngle(U,Y,Pt),v.transformQuat(A,A,U),v.transformQuat(r.up,r.up,U),V=Pt):!s.staticMoving&&V&&(V*=Math.sqrt(1-s.dynamicDampingFactor),v.normalize(Y,r.up),_r.setAxisAngle(U,Y,V),v.transformQuat(A,A,U),v.transformQuat(r.up,r.up,U))}(),function Se(){const Ke=1+(G[1]-F[1])*s.zoomSpeed;1!==Ke&&Ke>0&&v.scale(A,A,Ke),s.staticMoving?Me.copy(F,G):F[1]+=(G[1]-F[1])*s.dynamicDampingFactor}(),function Re(){const Ke=(z[1]-L[1])*s.zoomSpeed;if(0!==Ke){const Pt=Math.max(1,r.state.radius+r.state.radius*Ke);r.setState({radius:Pt})}s.staticMoving?Me.copy(L,z):L[1]+=(z[1]-L[1])*s.dynamicDampingFactor}(),function tt(){if(Me.sub(Ne,Me.copy(Ne,Z),j),Me.squaredMagnitude(Ne)){const Ke=n.pixelRatio*s.panSpeed;Ne[0]*=1/r.zoom*r.viewport.width*Ke,Ne[1]*=1/r.zoom*r.viewport.height*Ke,v.cross($e,v.copy($e,A),r.up),v.setMagnitude($e,$e,Ne[0]),v.setMagnitude(Ge,r.up,Ne[1]),v.add($e,$e,Ge),v.add(r.position,r.position,$e),v.add(r.target,r.target,$e),s.staticMoving?Me.copy(j,Z):(Me.sub(Ne,Z,j),Me.scale(Ne,Ne,s.dynamicDampingFactor),Me.add(j,j,Ne))}}(),v.add(r.position,r.target,A),ut(),Et>0&&function _t(Ke){v.sub(ot,r.position,r.target);const Pt=Math.max(r.state.minNear,s.minDistance);v.setMagnitude(ot,ot,Pt);const Ht=.06*Ke*s.moveSpeed*(1===ke.boostMove?s.boostMoveFactor:1);if(1===ke.moveForward&&(v.normalize(Xe,ot),v.scaleAndSub(r.position,r.position,Xe,Ht),(s.flyMode||n.pointerLock)&&v.sub(r.target,r.position,ot)),1===ke.moveBack&&(v.normalize(Xe,ot),v.scaleAndAdd(r.position,r.position,Xe,Ht),(s.flyMode||n.pointerLock)&&v.sub(r.target,r.position,ot)),1===ke.moveLeft&&(v.cross(Xe,ot,r.up),v.normalize(Xe,Xe),s.flyMode||n.pointerLock?(v.scaleAndAdd(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,ot)):(v.scaleAndSub(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,A))),1===ke.moveRight&&(v.cross(Xe,ot,r.up),v.normalize(Xe,Xe),s.flyMode||n.pointerLock?(v.scaleAndSub(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,ot)):(v.scaleAndAdd(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,A))),1===ke.moveUp&&(v.normalize(Xe,r.up),s.flyMode||n.pointerLock?(v.scaleAndAdd(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,ot)):(v.scaleAndSub(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,A))),1===ke.moveDown&&(v.normalize(Xe,r.up),s.flyMode||n.pointerLock?(v.scaleAndSub(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,ot)):(v.scaleAndAdd(r.position,r.position,Xe,Ht),v.sub(r.target,r.position,A))),s.flyMode||n.pointerLock){const Ur=v.distance(r.position,i.boundingSphereVisible.center);r.setState({minFar:Ur+i.boundingSphereVisible.radius})}}(Math.min(Pt,250)),v.sub(A,r.position,r.target),ut(),v.squaredDistance(S,r.position)>vr&&v.copy(S,r.position),Et=Ke}function yt(){v.sub(ot,r.position,r.target);const Ke=Math.max(r.state.minNear,s.minDistance);v.setMagnitude(ot,ot,Ke),v.sub(r.target,r.position,ot);const Pt=v.distance(r.position,i.boundingSphereVisible.center);r.setState({minFar:Pt+i.boundingSphereVisible.radius})}function xt(){const{center:Ke,radius:Pt}=i.boundingSphereVisible;if(v.distance(r.position,Ke)>Pt){const Ur=r.getFocus(Ke,Pt);r.setState({...Ur,minFar:0})}else r.setState({minFar:0,radius:i.boundingSphereVisible.radius})}const Pi=Me.create(.005,0);let ho=0;const mc=Me.create(.005,0);function Ue(){ho=0}return{viewport:c,get isAnimating(){return"off"!==s.animate.name},get isMoving(){return 1===ke.moveForward||1===ke.moveBack||1===ke.moveLeft||1===ke.moveRight||1===ke.moveUp||1===ke.moveDown||1===ke.rollLeft||1===ke.rollRight||1===ke.pitchUp||1===ke.pitchDown||1===ke.yawLeft||1===ke.yawRight},get props(){return s},setProps:Ke=>{var Pt;"rock"===(null===(Pt=Ke.animate)||void 0===Pt?void 0:Pt.name)&&"rock"!==s.animate.name&&Ue(),void 0!==Ke.flyMode&&Ke.flyMode!==s.flyMode&&(Ke.flyMode?yt():xt()),Object.assign(s,Ke),Object.assign(a,Ke.bindings)},start:function tn(Ke){Et=-1,Xt(Ke)},update:Xt,reset:function ln(){v.copy(r.target,$),v.copy(r.position,ee),v.copy(r.up,q),v.sub(A,r.position,r.target),v.copy(S,r.position)},dispose:function hr(){u||(u=!0,l.unsubscribe(),f.unsubscribe(),p.unsubscribe(),m.unsubscribe(),d.unsubscribe(),h.unsubscribe(),g.unsubscribe(),y.unsubscribe(),b.unsubscribe(),x.unsubscribe())}}}}(D8||(D8={})),function(e){e.create=function t(){return{view:le.identity(),position:v.create(0,0,0),direction:v.create(0,0,-1),up:v.create(0,1,0)}};const n=v.zero();e.update=function r(i){v.add(n,i.position,i.direction),le.lookAt(i.view,i.position,n,i.up)}}(xE||(xE={}));class Ott{constructor(){this.removeList=wB(),this.removeMap=new Map,this.addList=wB(),this.addMap=new Map}get isEmpty(){return 0===this.removeList.count&&0===this.addList.count}get size(){return this.removeMap.size+this.addMap.size}add(t){if(this.removeMap.has(t)){const r=this.removeMap.get(t);this.removeMap.delete(t),this.removeList.remove(r)}if(this.addMap.has(t))return;const n=this.addList.addLast(t);this.addMap.set(t,n)}remove(t){if(this.addMap.has(t)){const r=this.addMap.get(t);this.addMap.delete(t),this.addList.remove(r)}if(this.removeMap.has(t))return;const n=this.removeList.addLast(t);this.removeMap.set(t,n)}tryGetRemove(){const t=this.removeList.removeFirst();return t&&this.removeMap.delete(t),t}tryGetAdd(){const t=this.addList.removeFirst();return t&&this.addMap.delete(t),t}}const QS=new fu("98");function uue(e,t,n){QS.reset();for(let r=0,i=e.length;r{r=L;for(let z=0,j=o.length;zR.add(L),remove:L=>R.remove(L),commit:(L=Number.MAX_VALUE)=>function I(L){const z=yi();let j=0;for(;;){const Z=R.tryGetRemove();if(!Z)break;if(w(Z),++j%100==0&&yi()-z>L)return!1}for(;;){const Z=R.tryGetAdd();if(!Z)break;if(E(Z),++j%100==0&&yi()-z>L)return!1}return o.sort(Ltt),f=!0,p=!0,m=!0,!0}(L),get commitQueueSize(){return R.size},get needsCommit(){return!R.isEmpty},has:L=>i.has(L),clear:()=>{for(let L=0,z=o.length;L{i.forEach(L)},get count(){return o.length},get boundingSphere(){return l&&(uue(o,s,!1),l=!1),s},get boundingSphereVisible(){return d&&(uue(o,a,!0),d=!1),a},get markerAverage(){return f&&(h=function V(){if(0===c.length)return 0;let L=0,z=0;for(let j=0,Z=c.length;j0?z/L:0}(),f=!1),h},get opacityAverage(){return p&&(g=function F(){var L,z;if(0===c.length)return 0;let j=0,Z=0;for(let $=0,ee=c.length;$0?Z/j:0}(),p=!1),g},get hasOpaque(){return m&&(y=function G(){var L;if(0===c.length)return!1;for(let z=0,j=c.length;z0)&&gr.copySnapshot(this._source,this.camera.state),this.inTransition||gr.copySnapshot(this._target,this.camera.state),gr.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&&n<=0||typeof t.mode<"u"&&t.mode!==this.camera.state.mode?this.finish(this._target):(this.inTransition=!0,this.func=r||Yv.defaultTransition,(!this.inTransition||n>0)&&(this.start=this.t,this.durationMs=n))}tick(t){this.t=t,this.update()}finish(t){gr.copySnapshot(this.camera.state,t),this.inTransition=!1}update(){if(!this.inTransition)return;const t=Math.min((this.t-this.start)/this.durationMs,1);1!==t?(this.func(this._current,t,this._source,this._target),gr.copySnapshot(this.camera.state,this._current)):this.finish(this._target)}constructor(t){this.camera=t,this.t=0,this.func=Yv.defaultTransition,this.start=0,this.inTransition=!1,this.durationMs=0,this._source=gr.createDefaultSnapshot(),this._target=gr.createDefaultSnapshot(),this._current=gr.createDefaultSnapshot()}}!function(e){const t=_r.identity();e.defaultTransition=function n(r,i,o,s){gr.copySnapshot(r,s),_r.slerp(t,_r.Identity,_r.rotationTo(t,o.up,s.up),i),v.transformQuat(r.up,o.up,t),v.lerp(r.target,o.target,s.target,i),v.lerp(r.position,o.position,s.position,i),r.radius=ci(o.radius,s.radius,i),r.radiusMax=ci(o.radiusMax,s.radiusMax,i),r.fov=ci(o.fov,s.fov,i),r.fog=ci(o.fog,s.fog,i)}}(Yv||(Yv={}));const lue=v(),due=v(),SE=nn();class gr{get position(){return this.state.position}set position(t){v.copy(this.state.position,t)}get up(){return this.state.up}set up(t){v.copy(this.state.up,t)}get target(){return this.state.target}set target(t){v.copy(this.state.target,t)}update(){const t=this.state;if(0===t.radiusMax)return!1;const n=2*Math.tan(t.fov/2)*v.distance(t.position,t.target);switch(this.zoom=this.viewport.height/n,function ztt(e){let{radius:t,radiusMax:n,fog:i,clipFar:o,minNear:s,minFar:a}=e.state;t<.01&&(t=.01);const c=Math.max(o?t:n,a),u=v.distance(e.position,e.target);let l=u-t,d=u+c;l=Math.max(Math.min(n,s),l),d=Math.max(s,d),l===d&&(d=l+.01);const p=u-c*(-(50-i)/50),m=d;e.near=l,e.far=d,e.fogNear=p,e.fogFar=m}(this),this.state.mode){case"orthographic":!function Utt(e){const{viewport:t,zoom:n,near:r,far:i,viewOffset:o}=e,s=-t.width/2,a=t.width/2,c=t.height/2,u=-t.height/2,l=(a-s)/(2*n),d=(c-u)/(2*n),f=(a+s)/2,p=(c+u)/2;let m=f-l,h=f+l,g=p+d,y=p-d;if(o.enabled){const b=n/(o.width/o.fullWidth),x=n/(o.height/o.fullHeight),_=(a-s)/o.width,S=(c-u)/o.height;m+=_*(o.offsetX/b),h=m+_*(o.width/b),g-=S*(o.offsetY/x),y=g-S*(o.height/x)}le.ortho(e.projection,m,h,g,y,r,i),le.lookAt(e.view,e.position,e.target,e.up)}(this);break;case"perspective":!function Vtt(e){const t=e.viewport.width/e.viewport.height,{near:n,far:r,viewOffset:i}=e;let o=n*Math.tan(.5*e.state.fov),s=2*o,a=t*s,c=-.5*a;i.enabled&&(c+=i.offsetX*a/i.fullWidth,o-=i.offsetY*s/i.fullHeight,a*=i.width/i.fullWidth,s*=i.height/i.fullHeight),le.perspective(e.projection,c,c+a,o,o-s,n,r),le.lookAt(e.view,e.position,e.target,e.up)}(this);break;default:Rr()}const r=!le.areEqual(this.projection,this.prevProjection,vr)||!le.areEqual(this.view,this.prevView,vr);if(r){if(le.mul(this.projectionView,this.projection,this.view),!le.tryInvert(this.inverseProjectionView,this.projectionView))return le.copy(this.view,this.prevView),le.copy(this.projection,this.prevProjection),le.mul(this.projectionView,this.projection,this.view),!1;le.copy(this.prevView,this.view),le.copy(this.prevProjection,this.projection)}return r}setState(t,n){this.transition.apply(t,n),this.stateChanged.next(t)}getSnapshot(){return gr.copySnapshot(gr.createDefaultSnapshot(),this.state)}getTargetDistance(t){return gr.targetDistance(t,this.state.mode,this.state.fov,this.viewport.width,this.viewport.height)}getFocus(t,n,r,i,o){var s,a;const c=Math.max(n,.01),u=this.getTargetDistance(c);v.sub(this.deltaDirection,null!==(s=o?.target)&&void 0!==s?s:this.target,null!==(a=o?.position)&&void 0!==a?a:this.position),i&&v.matchDirection(this.deltaDirection,i,this.deltaDirection),v.setMagnitude(this.deltaDirection,this.deltaDirection,u),v.sub(this.newPosition,t,this.deltaDirection);const l=gr.copySnapshot(gr.createDefaultSnapshot(),this.state);return l.target=v.clone(t),l.radius=c,l.position=v.clone(this.newPosition),r&&v.matchDirection(l.up,r,l.up),l}getCenter(t,n){v.sub(this.deltaDirection,this.target,this.position),v.sub(this.newPosition,t,this.deltaDirection);const r=gr.copySnapshot(gr.createDefaultSnapshot(),this.state);return r.target=v.clone(t),r.position=v.clone(this.newPosition),n&&(r.radius=Math.max(n,.01)),r}getInvariantFocus(t,n,r,i){const o=Math.max(n,.01),s=this.getTargetDistance(o);v.copy(this.deltaDirection,i),v.setMagnitude(this.deltaDirection,this.deltaDirection,s),v.sub(this.newPosition,t,this.deltaDirection);const a=gr.copySnapshot(gr.createDefaultSnapshot(),this.state);return a.target=v.clone(t),a.radius=o,a.position=v.clone(this.newPosition),v.copy(a.up,r),a}focus(t,n,r,i,o){n>0&&this.setState(this.getFocus(t,n,i,o),r)}center(t,n){this.setState(this.getCenter(t),n)}project(t,n){return function Mtt(e,t,n,r){const{x:i,y:o,width:s,height:a}=n;nn.set(If,t[0],t[1],t[2],1),nn.transformMat4(If,If,r);const c=If[3];return 0!==c&&(If[0]/=c,If[1]/=c,If[2]/=c),e[0]=(If[0]+1)*s*.5+i,e[1]=(If[1]+1)*a*.5+o,e[2]=.5*(If[2]+1),e[3]=0===c?0:1/c,e}(t,n,this.viewport,this.projectionView)}unproject(t,n){return vE(t,n,this.viewport,this.inverseProjectionView)}getPixelSize(t){return this.project(SE,t),this.unproject(lue,SE),SE[0]+=1,this.unproject(due,SE),v.distance(lue,due)}constructor(t,n=Lo.create(0,0,128,128)){this.view=le.identity(),this.projection=le.identity(),this.projectionView=le.identity(),this.inverseProjectionView=le.identity(),this.state=gr.createDefaultSnapshot(),this.viewOffset=gr.ViewOffset(),this.near=1,this.far=1e4,this.fogNear=5e3,this.fogFar=1e4,this.zoom=1,this.transition=new Yv(this),this.stateChanged=new Ao(this.state),this.prevProjection=le.identity(),this.prevView=le.identity(),this.deltaDirection=v(),this.newPosition=v(),this.viewport=n,gr.copySnapshot(this.state,t)}}!function(e){e.ViewOffset=function t(){return{enabled:!1,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}},e.setViewOffset=function n(c,u,l,d,f,p,m){c.fullWidth=u,c.fullHeight=l,c.offsetX=d,c.offsetY=f,c.width=p,c.height=m},e.copyViewOffset=function r(c,u){c.enabled=u.enabled,c.fullWidth=u.fullWidth,c.fullHeight=u.fullHeight,c.offsetX=u.offsetX,c.offsetY=u.offsetY,c.width=u.width,c.height=u.height},e.targetDistance=function i(c,u,l,d,f){const p=Math.max(c,.01),h=f{const o=this.objectsData.get(i),s=CE(this.scene,r.values.boundingSphere.ref.value,o,xn.tomato,Wtt);s&&this.objectsData.set(i,s);const a=this.instancesData.get(i),c=CE(this.scene,r.values.invariantBoundingSphere.ref.value,a,xn.skyblue,$tt,{aTransform:i.values.aTransform,matrix:i.values.matrix,transform:i.values.transform,extraTransform:i.values.extraTransform,uInstanceCount:i.values.uInstanceCount,instanceCount:i.values.instanceCount,aInstance:i.values.aInstance,hasReflection:i.values.hasReflection,instanceGrid:i.values.instanceGrid});c&&this.instancesData.set(i,c)}),this.objectsData.forEach((r,i)=>{this.parent.has(i)||(this.scene.remove(r.renderObject),this.objectsData.delete(i))}),this.instancesData.forEach((r,i)=>{this.parent.has(i)||(this.scene.remove(r.renderObject),this.instancesData.delete(i))}),this.scene.update(void 0,!1),this.scene.commit()}syncVisibility(){this.sceneData&&(this.sceneData.renderObject.state.visible=this._props.sceneBoundingSpheres),this.visibleSceneData&&(this.visibleSceneData.renderObject.state.visible=this._props.visibleSceneBoundingSpheres),this.parent.forEach((t,n)=>{const r=this.objectsData.get(n);r&&(r.renderObject.state.visible=n.state.visible&&this._props.objectBoundingSpheres);const i=this.instancesData.get(n);i&&(i.renderObject.state.visible=n.state.visible&&this._props.instanceBoundingSpheres)})}clear(){this.sceneData=void 0,this.objectsData.clear(),this.scene.clear()}get isEnabled(){return this._props.sceneBoundingSpheres||this._props.visibleSceneBoundingSpheres||this._props.objectBoundingSpheres||this._props.instanceBoundingSpheres}get props(){return this._props}setProps(t){Object.assign(this._props,t),this.isEnabled&&this.update()}}function CE(e,t,n,r,i,o){if(!n||!_e.equals(n.boundingSphere,t)){const s=function jtt(e,t){const r=xv(2),i=at.createState(r,r/2,t);if(e.radius&&(Zn(i,e.center,e.radius,2),_e.hasExtrema(e)))for(const o of e.extrema)Zn(i,o,1,0);return at.getMesh(i)}(t,n&&n.mesh),a=n?n.renderObject:function Ytt(e,t,n,r){return Ev("mesh",Nt.Utils.createValuesSimple(e,{alpha:.1,doubleSided:!1,cellSize:0,batchSize:0},t,1,r),{disposed:!1,visible:!0,alphaFactor:1,pickable:!1,colorOnly:!1,opaque:!1,writeDepth:!1},n)}(s,r,i,o);return n?k.updateIfChanged(a.values.drawCount,Zo.getDrawCount(s)):e.add(a),{boundingSphere:_e.clone(t),renderObject:a,mesh:s}}}const Htt=Hp(),qtt=Hp(),Wtt=Hp(),$tt=Hp();var E0=function(e){return e[e.Move=0]="Move",e[e.Click=1]="Click",e[e.Drag=2]="Drag",e}(E0||{});const P8=v(),M8=v(),fue=v(),pue={maxFps:C.Numeric(30,{min:10,max:60,step:10}),preferAtomPixelPadding:C.Numeric(3,{min:0,max:20,step:1},{description:"Number of extra pixels at which to prefer atoms over bonds."})};class Xtt{setProps(t){Object.assign(this.props,t)}identify(t,n){const r=this.startX!==this.endX||this.startY!==this.endY||this.input.pointerLock&&!this.controls.isMoving;if(t===E0.Drag)return void(r&&!this.outsideViewport(this.startX,this.startY)&&(this.events.drag.next({current:this.prevLoci,buttons:this.buttons,button:this.button,modifiers:this.modifiers,pageStart:Me.create(this.startX,this.startY),pageEnd:Me.create(this.endX,this.endY)}),this.startX=this.endX,this.startY=this.endY));if(r){const o=this.canvasIdentify(this.endX,this.endY);this.id=o?.id,this.position=o?.position,this.startX=this.endX,this.startY=this.endY}if(t===E0.Click){const o=this.getLoci(this.id,this.position);return this.events.click.next({current:o,buttons:this.buttons,button:this.button,modifiers:this.modifiers,page:Me.create(this.endX,this.endY),position:this.position}),void(this.prevLoci=o)}if(!this.inside||this.currentIdentifyT!==n||!r||this.outsideViewport(this.endX,this.endY))return;const i=this.getLoci(this.id,this.position);this.events.hover.next({current:i,buttons:this.buttons,button:this.button,modifiers:this.modifiers,page:Me.create(this.endX,this.endY),position:this.position}),this.prevLoci=i}tick(t){this.inside&&t-this.prevT>1e3/this.props.maxFps&&(this.prevT=t,this.currentIdentifyT=t,this.identify(this.isInteracting?E0.Drag:E0.Move,t))}leave(){this.inside=!1,yn.Loci.isEmpty(this.prevLoci)||(this.prevLoci=yn.Loci.Empty,this.events.hover.next({current:this.prevLoci,buttons:this.buttons,button:this.button,modifiers:this.modifiers}))}move(t,n,r,i,o){this.inside=!0,this.buttons=r,this.button=i,this.modifiers=o,this.endX=t,this.endY=n}click(t,n,r,i,o){this.endX=t,this.endY=n,this.buttons=r,this.button=i,this.modifiers=o,this.identify(E0.Click,0)}drag(t,n,r,i,o){this.endX=t,this.endY=n,this.buttons=r,this.button=i,this.modifiers=o,this.identify(E0.Drag,0)}modify(t){wu.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}))}outsideViewport(t,n){const{input:r,camera:{viewport:i}}=this;return n*=r.pixelRatio,(t*=r.pixelRatio)>i.x+i.width||r.height-n>i.y+i.height||t{this.isInteracting=!0,this.drag(a,c,u,l,d)}),r.move.subscribe(({x:a,y:c,inside:u,buttons:l,button:d,modifiers:f,onElement:p})=>{if(u&&!this.isInteracting){if(!p)return void this.leave();this.move(a,c,l,d,f)}}),r.leave.subscribe(()=>{this.leave()}),r.click.subscribe(({x:a,y:c,buttons:u,button:l,modifiers:d})=>{this.outsideViewport(a,c)||this.click(a,c,u,l,d)}),r.interactionEnd.subscribe(()=>{this.isInteracting=!1}),r.modifiers.subscribe(a=>{this.modify(a)})}}const tnt={edgeThresholdMin:C.Numeric(.0312,{min:.0312,max:.0833,step:1e-4},{description:"Trims the algorithm from processing darks."}),edgeThresholdMax:C.Numeric(.063,{min:.063,max:.333,step:.001},{description:"The minimum amount of local contrast required to apply algorithm."}),iterations:C.Numeric(12,{min:0,max:16,step:1},{description:"Number of edge exploration steps."}),subpixelQuality:C.Numeric(.3,{min:0,max:1,step:.01},{description:"Choose the amount of sub-pixel aliasing removal."})};class nnt{constructor(t,n){this.webgl=t,this.renderable=function ont(e,t){const n=t.getWidth(),r=t.getHeight(),i={..._o,tColor:k.create(t),uTexSizeInv:k.create(Me.create(1/n,1/r)),dEdgeThresholdMin:k.create(.0312),dEdgeThresholdMax:k.create(.125),dIterations:k.create(12),dSubpixelQuality:k.create(.3)},o={...rnt};return ji(zi(e,"triangles",int,o,i),i)}(t,n)}updateState(t){const{gl:n,state:r}=this.webgl;r.enable(n.SCISSOR_TEST),r.disable(n.BLEND),r.disable(n.DEPTH_TEST),r.depthMask(!1);const{x:i,y:o,width:s,height:a}=t;r.viewport(i,o,s,a),r.scissor(i,o,s,a),r.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT)}setSize(t,n){k.update(this.renderable.values.uTexSizeInv,Me.set(this.renderable.values.uTexSizeInv.ref.value,1/t,1/n))}update(t,n){const{values:r}=this.renderable,{edgeThresholdMin:i,edgeThresholdMax:o,iterations:s,subpixelQuality:a}=n;let c=!1;r.tColor.ref.value!==t&&(k.update(this.renderable.values.tColor,t),c=!0),r.dEdgeThresholdMin.ref.value!==i&&(c=!0),k.updateIfChanged(r.dEdgeThresholdMin,i),r.dEdgeThresholdMax.ref.value!==o&&(c=!0),k.updateIfChanged(r.dEdgeThresholdMax,o),r.dIterations.ref.value!==s&&(c=!0),k.updateIfChanged(r.dIterations,s),r.dSubpixelQuality.ref.value!==a&&(c=!0),k.updateIfChanged(r.dSubpixelQuality,a),c&&this.renderable.update()}render(t,n){lt&&this.webgl.timer.mark("FxaaPass.render"),n?n.bind():this.webgl.unbindFramebuffer(),this.updateState(t),this.renderable.render(),lt&&this.webgl.timer.markEnd("FxaaPass.render")}}const rnt={...vo,tColor:jt("texture","rgba","ubyte","linear"),uTexSizeInv:xe("v2"),dEdgeThresholdMin:Ft("number"),dEdgeThresholdMax:Ft("number"),dIterations:Ft("number"),dSubpixelQuality:Ft("number")},int=Br("fxaa",ps,"\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tColor;\nuniform vec2 uTexSizeInv;\n\n// adapted from https://github.com/kosua20/Rendu\n// MIT License Copyright (c) 2017 Simon Rodriguez\n\n#define QUALITY(q) ((q) < 5 ? 1.0 : ((q) > 5 ? ((q) < 10 ? 2.0 : ((q) < 11 ? 4.0 : 8.0)) : 1.5))\n\nfloat rgb2luma(vec3 rgb){\n return sqrt(dot(rgb, vec3(0.299, 0.587, 0.114)));\n}\n\nfloat sampleLuma(vec2 uv) {\n return rgb2luma(texture2D(tColor, uv).rgb);\n}\n\nfloat sampleLuma(vec2 uv, float uOffset, float vOffset) {\n uv += uTexSizeInv * vec2(uOffset, vOffset);\n return sampleLuma(uv);\n}\n\nvoid main(void) {\n vec2 coords = gl_FragCoord.xy * uTexSizeInv;\n vec2 inverseScreenSize = uTexSizeInv;\n\n vec4 colorCenter = texture2D(tColor, coords);\n\n // Luma at the current fragment\n float lumaCenter = rgb2luma(colorCenter.rgb);\n\n // Luma at the four direct neighbours of the current fragment.\n float lumaDown = sampleLuma(coords, 0.0, -1.0);\n float lumaUp = sampleLuma(coords, 0.0, 1.0);\n float lumaLeft = sampleLuma(coords, -1.0, 0.0);\n float lumaRight = sampleLuma(coords, 1.0, 0.0);\n\n // Find the maximum and minimum luma around the current fragment.\n float lumaMin = min(lumaCenter, min(min(lumaDown, lumaUp), min(lumaLeft, lumaRight)));\n float lumaMax = max(lumaCenter, max(max(lumaDown, lumaUp), max(lumaLeft, lumaRight)));\n\n // Compute the delta.\n float lumaRange = lumaMax - lumaMin;\n\n // If the luma variation is lower that a threshold (or if we are in a really dark area),\n // we are not on an edge, don't perform any AA.\n if (lumaRange < max(dEdgeThresholdMin, lumaMax * dEdgeThresholdMax)) {\n gl_FragColor = colorCenter;\n return;\n }\n\n // Query the 4 remaining corners lumas.\n float lumaDownLeft = sampleLuma(coords, -1.0, -1.0);\n float lumaUpRight = sampleLuma(coords, 1.0, 1.0);\n float lumaUpLeft = sampleLuma(coords, -1.0, 1.0);\n float lumaDownRight = sampleLuma(coords, 1.0, -1.0);\n\n // Combine the four edges lumas (using intermediary variables for future computations\n // with the same values).\n float lumaDownUp = lumaDown + lumaUp;\n float lumaLeftRight = lumaLeft + lumaRight;\n\n // Same for corners\n float lumaLeftCorners = lumaDownLeft + lumaUpLeft;\n float lumaDownCorners = lumaDownLeft + lumaDownRight;\n float lumaRightCorners = lumaDownRight + lumaUpRight;\n float lumaUpCorners = lumaUpRight + lumaUpLeft;\n\n // Compute an estimation of the gradient along the horizontal and vertical axis.\n float edgeHorizontal = abs(-2.0 * lumaLeft + lumaLeftCorners) + abs(-2.0 * lumaCenter + lumaDownUp) * 2.0 + abs(-2.0 * lumaRight + lumaRightCorners);\n float edgeVertical = abs(-2.0 * lumaUp + lumaUpCorners) + abs(-2.0 * lumaCenter + lumaLeftRight) * 2.0 + abs(-2.0 * lumaDown + lumaDownCorners);\n\n // Is the local edge horizontal or vertical ?\n bool isHorizontal = (edgeHorizontal >= edgeVertical);\n\n // Choose the step size (one pixel) accordingly.\n float stepLength = isHorizontal ? inverseScreenSize.y : inverseScreenSize.x;\n\n // Select the two neighboring texels lumas in the opposite direction to the local edge.\n float luma1 = isHorizontal ? lumaDown : lumaLeft;\n float luma2 = isHorizontal ? lumaUp : lumaRight;\n // Compute gradients in this direction.\n float gradient1 = luma1 - lumaCenter;\n float gradient2 = luma2 - lumaCenter;\n\n // Which direction is the steepest ?\n bool is1Steepest = abs(gradient1) >= abs(gradient2);\n\n // Gradient in the corresponding direction, normalized.\n float gradientScaled = 0.25 * max(abs(gradient1), abs(gradient2));\n\n // Average luma in the correct direction.\n float lumaLocalAverage = 0.0;\n if(is1Steepest){\n // Switch the direction\n stepLength = -stepLength;\n lumaLocalAverage = 0.5 * (luma1 + lumaCenter);\n } else {\n lumaLocalAverage = 0.5 * (luma2 + lumaCenter);\n }\n\n // Shift UV in the correct direction by half a pixel.\n vec2 currentUv = coords;\n if(isHorizontal){\n currentUv.y += stepLength * 0.5;\n } else {\n currentUv.x += stepLength * 0.5;\n }\n\n // Compute offset (for each iteration step) in the right direction.\n vec2 offset = isHorizontal ? vec2(inverseScreenSize.x, 0.0) : vec2(0.0, inverseScreenSize.y);\n // Compute UVs to explore on each side of the edge, orthogonally.\n // The QUALITY allows us to step faster.\n vec2 uv1 = currentUv - offset * QUALITY(0);\n vec2 uv2 = currentUv + offset * QUALITY(0);\n\n // Read the lumas at both current extremities of the exploration segment,\n // and compute the delta wrt to the local average luma.\n float lumaEnd1 = sampleLuma(uv1);\n float lumaEnd2 = sampleLuma(uv2);\n lumaEnd1 -= lumaLocalAverage;\n lumaEnd2 -= lumaLocalAverage;\n\n // If the luma deltas at the current extremities is larger than the local gradient,\n // we have reached the side of the edge.\n bool reached1 = abs(lumaEnd1) >= gradientScaled;\n bool reached2 = abs(lumaEnd2) >= gradientScaled;\n bool reachedBoth = reached1 && reached2;\n\n // If the side is not reached, we continue to explore in this direction.\n if(!reached1){\n uv1 -= offset * QUALITY(1);\n }\n if(!reached2){\n uv2 += offset * QUALITY(1);\n }\n\n // If both sides have not been reached, continue to explore.\n if(!reachedBoth){\n for(int i = 2; i < dIterations; i++){\n // If needed, read luma in 1st direction, compute delta.\n if(!reached1){\n lumaEnd1 = sampleLuma(uv1);\n lumaEnd1 = lumaEnd1 - lumaLocalAverage;\n }\n // If needed, read luma in opposite direction, compute delta.\n if(!reached2){\n lumaEnd2 = sampleLuma(uv2);\n lumaEnd2 = lumaEnd2 - lumaLocalAverage;\n }\n // If the luma deltas at the current extremities is larger than the local gradient,\n // we have reached the side of the edge.\n reached1 = abs(lumaEnd1) >= gradientScaled;\n reached2 = abs(lumaEnd2) >= gradientScaled;\n reachedBoth = reached1 && reached2;\n\n // If the side is not reached, we continue to explore in this direction,\n // with a variable quality.\n if(!reached1){\n uv1 -= offset * QUALITY(i);\n }\n if(!reached2){\n uv2 += offset * QUALITY(i);\n }\n\n // If both sides have been reached, stop the exploration.\n if(reachedBoth){\n break;\n }\n }\n }\n\n // Compute the distances to each side edge of the edge (!).\n float distance1 = isHorizontal ? (coords.x - uv1.x) : (coords.y - uv1.y);\n float distance2 = isHorizontal ? (uv2.x - coords.x) : (uv2.y - coords.y);\n\n // In which direction is the side of the edge closer ?\n bool isDirection1 = distance1 < distance2;\n float distanceFinal = min(distance1, distance2);\n\n // Thickness of the edge.\n float edgeThickness = (distance1 + distance2);\n\n // Is the luma at center smaller than the local average ?\n bool isLumaCenterSmaller = lumaCenter < lumaLocalAverage;\n\n // If the luma at center is smaller than at its neighbour,\n // the delta luma at each end should be positive (same variation).\n bool correctVariation1 = (lumaEnd1 < 0.0) != isLumaCenterSmaller;\n bool correctVariation2 = (lumaEnd2 < 0.0) != isLumaCenterSmaller;\n\n // Only keep the result in the direction of the closer side of the edge.\n bool correctVariation = isDirection1 ? correctVariation1 : correctVariation2;\n\n // UV offset: read in the direction of the closest side of the edge.\n float pixelOffset = - distanceFinal / edgeThickness + 0.5;\n\n // If the luma variation is incorrect, do not offset.\n float finalOffset = correctVariation ? pixelOffset : 0.0;\n\n // Sub-pixel shifting\n // Full weighted average of the luma over the 3x3 neighborhood.\n float lumaAverage = (1.0 / 12.0) * (2.0 * (lumaDownUp + lumaLeftRight) + lumaLeftCorners + lumaRightCorners);\n // Ratio of the delta between the global average and the center luma,\n // over the luma range in the 3x3 neighborhood.\n float subPixelOffset1 = clamp(abs(lumaAverage - lumaCenter) / lumaRange, 0.0, 1.0);\n float subPixelOffset2 = (-2.0 * subPixelOffset1 + 3.0) * subPixelOffset1 * subPixelOffset1;\n // Compute a sub-pixel offset based on this delta.\n float subPixelOffsetFinal = subPixelOffset2 * subPixelOffset2 * float(dSubpixelQuality);\n\n // Pick the biggest of the two offsets.\n finalOffset = max(finalOffset, subPixelOffsetFinal);\n\n // Compute the final UV coordinates.\n vec2 finalUv = coords;\n if(isHorizontal){\n finalUv.y += finalOffset * stepLength;\n } else {\n finalUv.x += finalOffset * stepLength;\n }\n\n // Read the color at the new UV coordinates, and use it.\n gl_FragColor = texture2D(tColor, finalUv);\n}\n"),fnt={edgeThreshold:C.Numeric(.1,{min:.05,max:.15,step:.01}),maxSearchSteps:C.Numeric(16,{min:0,max:32,step:1})};class pnt{get supported(){return this._supported}constructor(t,n){if(this.webgl=t,this._supported=!1,typeof HTMLImageElement>"u")return void(un&&console.log('Missing "HTMLImageElement" required for "SMAA"'));const r=n.getWidth(),i=n.getHeight();this.edgesTarget=t.createRenderTarget(r,i,!1,"uint8","linear"),this.weightsTarget=t.createRenderTarget(r,i,!1,"uint8","linear"),this.edgesRenderable=function gnt(e,t){const n=t.getWidth(),r=t.getHeight(),i={..._o,tColor:k.create(t),uTexSizeInv:k.create(Me.create(1/n,1/r)),uViewport:k.create(nn()),dEdgeThreshold:k.create(.1)},o={...hnt};return ji(zi(e,"triangles",mnt,o,i),i)}(t,n),this.weightsRenderable=function vnt(e,t){const n=t.getWidth(),r=t.getHeight(),i=e.resources.texture("image-uint8","rgb","ubyte","linear"),o=e.resources.texture("image-uint8","rgba","ubyte","nearest"),s={..._o,tEdges:k.create(t),tArea:k.create(i),tSearch:k.create(o),uTexSizeInv:k.create(Me.create(1/n,1/r)),uViewport:k.create(nn()),dMaxSearchSteps:k.create(16)};Zre("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=",s.tArea,i),Zre("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII=",s.tSearch,o);const a={...ynt};return ji(zi(e,"triangles",bnt,a,s),s)}(t,this.edgesTarget.texture),this.blendRenderable=function Snt(e,t,n){const r=t.getWidth(),i=t.getHeight(),o={..._o,tColor:k.create(t),tWeights:k.create(n),uTexSizeInv:k.create(Me.create(1/r,1/i)),uViewport:k.create(nn())},s={..._nt};return ji(zi(e,"triangles",xnt,s,o),o)}(t,n,this.weightsTarget.texture),this._supported=!0}updateState(t){const{gl:n,state:r}=this.webgl;r.enable(n.SCISSOR_TEST),r.disable(n.BLEND),r.disable(n.DEPTH_TEST),r.depthMask(!1);const{x:i,y:o,width:s,height:a}=t;r.viewport(i,o,s,a),r.scissor(i,o,s,a),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT),k.update(this.edgesRenderable.values.uViewport,Lo.toVec4(this.edgesRenderable.values.uViewport.ref.value,t)),k.update(this.weightsRenderable.values.uViewport,Lo.toVec4(this.weightsRenderable.values.uViewport.ref.value,t)),k.update(this.blendRenderable.values.uViewport,Lo.toVec4(this.blendRenderable.values.uViewport.ref.value,t))}setSize(t,n){const r=this.edgesTarget.getWidth(),i=this.edgesTarget.getHeight();(t!==r||n!==i)&&(this.edgesTarget.setSize(t,n),this.weightsTarget.setSize(t,n),k.update(this.edgesRenderable.values.uTexSizeInv,Me.set(this.edgesRenderable.values.uTexSizeInv.ref.value,1/t,1/n)),k.update(this.weightsRenderable.values.uTexSizeInv,Me.set(this.weightsRenderable.values.uTexSizeInv.ref.value,1/t,1/n)),k.update(this.blendRenderable.values.uTexSizeInv,Me.set(this.blendRenderable.values.uTexSizeInv.ref.value,1/t,1/n)))}update(t,n){let r=!1;this.edgesRenderable.values.tColor.ref.value!==t&&(k.update(this.edgesRenderable.values.tColor,t),r=!0),this.edgesRenderable.values.dEdgeThreshold.ref.value!==n.edgeThreshold&&(k.update(this.edgesRenderable.values.dEdgeThreshold,n.edgeThreshold),r=!0),r&&this.edgesRenderable.update(),this.weightsRenderable.values.dMaxSearchSteps.ref.value!==n.maxSearchSteps&&(k.update(this.weightsRenderable.values.dMaxSearchSteps,n.maxSearchSteps),this.weightsRenderable.update()),this.blendRenderable.values.tColor.ref.value!==t&&(k.update(this.blendRenderable.values.tColor,t),this.blendRenderable.update())}render(t,n){lt&&this.webgl.timer.mark("SmaaPass.render"),this.edgesTarget.bind(),this.updateState(t),this.edgesRenderable.render(),this.weightsTarget.bind(),this.updateState(t),this.weightsRenderable.render(),n?n.bind():this.webgl.unbindFramebuffer(),this.updateState(t),this.blendRenderable.render(),lt&&this.webgl.timer.markEnd("SmaaPass.render")}}const hnt={...vo,tColor:jt("texture","rgba","ubyte","linear"),uTexSizeInv:xe("v2"),uViewport:xe("v4"),dEdgeThreshold:Ft("number")},mnt=Br("smaa-edges","\nprecision highp float;\n\nattribute vec2 aPosition;\nuniform vec2 uQuadScale;\n\nuniform vec2 uTexSizeInv;\nuniform vec4 uViewport;\n\nvarying vec2 vUv;\nvarying vec4 vOffset[3];\n\nvoid SMAAEdgeDetectionVS(vec2 texCoord) {\n vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-1.0, 0.0, 0.0, 1.0); // WebGL port note: Changed sign in W component\n vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(1.0, 0.0, 0.0, -1.0); // WebGL port note: Changed sign in W component\n vOffset[2] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-2.0, 0.0, 0.0, 2.0); // WebGL port note: Changed sign in W component\n}\n\nvoid main() {\n vec2 scale = uViewport.zw * uTexSizeInv;\n vec2 shift = uViewport.xy * uTexSizeInv;\n vUv = (aPosition + 1.0) * 0.5 * scale + shift;\n SMAAEdgeDetectionVS(vUv);\n vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n","\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tColor;\nuniform vec2 uTexSizeInv;\n\nvarying vec2 vUv;\nvarying vec4 vOffset[3];\n\nvec4 SMAAColorEdgeDetectionPS(vec2 texcoord, vec4 offset[3], sampler2D colorTex) {\n vec2 threshold = vec2(dEdgeThreshold, dEdgeThreshold);\n\n // Calculate color deltas:\n vec4 delta;\n vec3 C = texture2D(colorTex, texcoord).rgb;\n\n vec3 Cleft = texture2D(colorTex, offset[0].xy).rgb;\n vec3 t = abs(C - Cleft);\n delta.x = max(max(t.r, t.g), t.b);\n\n vec3 Ctop = texture2D(colorTex, offset[0].zw).rgb;\n t = abs(C - Ctop);\n delta.y = max(max(t.r, t.g), t.b);\n\n // We do the usual threshold:\n vec2 edges = step(threshold, delta.xy);\n\n // Then discard if there is no edge:\n if (dot(edges, vec2(1.0, 1.0 )) == 0.0)\n discard;\n\n // Calculate right and bottom deltas:\n vec3 Cright = texture2D(colorTex, offset[1].xy).rgb;\n t = abs( C - Cright );\n delta.z = max(max(t.r, t.g), t.b);\n\n vec3 Cbottom = texture2D(colorTex, offset[1].zw).rgb;\n t = abs(C - Cbottom);\n delta.w = max(max(t.r, t.g), t.b);\n\n // Calculate the maximum delta in the direct neighborhood:\n float maxDelta = max(max(max(delta.x, delta.y), delta.z), delta.w );\n\n // Calculate left-left and top-top deltas:\n vec3 Cleftleft = texture2D(colorTex, offset[2].xy).rgb;\n t = abs( C - Cleftleft );\n delta.z = max(max(t.r, t.g), t.b);\n\n vec3 Ctoptop = texture2D(colorTex, offset[2].zw).rgb;\n t = abs(C - Ctoptop);\n delta.w = max(max(t.r, t.g), t.b);\n\n // Calculate the final maximum delta:\n maxDelta = max(max(maxDelta, delta.z), delta.w);\n\n // Local contrast adaptation in action:\n edges.xy *= step(0.5 * maxDelta, delta.xy);\n\n return vec4(edges, 0.0, 0.0);\n}\n\nvoid main() {\n gl_FragColor = SMAAColorEdgeDetectionPS(vUv, vOffset, tColor);\n}\n"),ynt={...vo,tEdges:jt("texture","rgba","ubyte","linear"),tArea:jt("texture","rgb","ubyte","linear"),tSearch:jt("texture","rgba","ubyte","nearest"),uTexSizeInv:xe("v2"),uViewport:xe("v4"),dMaxSearchSteps:Ft("number")},bnt=Br("smaa-weights","\nprecision highp float;\n\nattribute vec2 aPosition;\nuniform vec2 uQuadScale;\n\nuniform vec2 uTexSizeInv;\nuniform vec4 uViewport;\n\nvarying vec2 vUv;\nvarying vec4 vOffset[3];\nvarying vec2 vPixCoord;\n\nvoid SMAABlendingWeightCalculationVS(vec2 texCoord) {\n vPixCoord = texCoord / uTexSizeInv;\n\n // We will use these offsets for the searches later on (see @PSEUDO_GATHER4):\n 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\n 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\n\n // And these for the searches, they indicate the ends of the loops:\n vOffset[2] = vec4(vOffset[0].xz, vOffset[1].yw) + vec4(-2.0, 2.0, -2.0, 2.0) * uTexSizeInv.xxyy * float(dMaxSearchSteps);\n}\n\nvoid main() {\n vec2 scale = uViewport.zw * uTexSizeInv;\n vec2 shift = uViewport.xy * uTexSizeInv;\n vUv = (aPosition + 1.0) * 0.5 * scale + shift;\n SMAABlendingWeightCalculationVS(vUv);\n vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n","\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#define SMAASampleLevelZeroOffset(tex, coord, offset) texture2D(tex, coord + float(offset) * uTexSizeInv, 0.0)\n\n#define SMAA_AREATEX_MAX_DISTANCE 16\n#define SMAA_AREATEX_PIXEL_SIZE (1.0 / vec2(160.0, 560.0))\n#define SMAA_AREATEX_SUBTEX_SIZE (1.0 / 7.0)\n\nuniform sampler2D tEdges;\nuniform sampler2D tArea;\nuniform sampler2D tSearch;\nuniform vec2 uTexSizeInv;\n\nvarying vec2 vUv;\nvarying vec4 vOffset[3];\nvarying vec2 vPixCoord;\n\n#if __VERSION__ == 100\n vec2 round(vec2 x) {\n return sign(x) * floor(abs(x) + 0.5);\n }\n#endif\n\nfloat SMAASearchLength(sampler2D searchTex, vec2 e, float bias, float scale) {\n // Not required if searchTex accesses are set to point:\n // float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);\n // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +\n // e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;\n e.r = bias + e.r * scale;\n return 255.0 * texture2D(searchTex, e, 0.0).r;\n}\n\nfloat SMAASearchXLeft(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {\n /**\n * @PSEUDO_GATHER4\n * This texCoord has been offset by (-0.25, -0.125) in the vertex shader to\n * sample between edge, thus fetching four edges in a row.\n * Sampling with different offsets in each direction allows to disambiguate\n * which edges are active from the four fetched ones.\n */\n vec2 e = vec2(0.0, 1.0);\n\n for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for\n e = texture2D( edgesTex, texCoord, 0.0).rg;\n texCoord -= vec2(2.0, 0.0) * uTexSizeInv;\n if (!(texCoord.x > end && e.g > 0.8281 && e.r == 0.0)) break;\n }\n\n // We correct the previous (-0.25, -0.125) offset we applied:\n texCoord.x += 0.25 * uTexSizeInv.x;\n\n // The searches are bias by 1, so adjust the coords accordingly:\n texCoord.x += uTexSizeInv.x;\n\n // Disambiguate the length added by the last step:\n texCoord.x += 2.0 * uTexSizeInv.x; // Undo last step\n texCoord.x -= uTexSizeInv.x * SMAASearchLength(searchTex, e, 0.0, 0.5);\n\n return texCoord.x;\n}\n\nfloat SMAASearchXRight(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {\n vec2 e = vec2( 0.0, 1.0 );\n\n for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for\n e = texture2D(edgesTex, texCoord, 0.0).rg;\n texCoord += vec2(2.0, 0.0) * uTexSizeInv;\n if (!(texCoord.x < end && e.g > 0.8281 && e.r == 0.0)) break;\n }\n\n texCoord.x -= 0.25 * uTexSizeInv.x;\n texCoord.x -= uTexSizeInv.x;\n texCoord.x -= 2.0 * uTexSizeInv.x;\n texCoord.x += uTexSizeInv.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );\n\n return texCoord.x;\n}\n\nfloat SMAASearchYUp(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {\n vec2 e = vec2( 1.0, 0.0 );\n\n for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for\n e = texture2D(edgesTex, texCoord, 0.0).rg;\n texCoord += vec2(0.0, 2.0) * uTexSizeInv; // WebGL port note: Changed sign\n if (!(texCoord.y > end && e.r > 0.8281 && e.g == 0.0)) break;\n }\n\n texCoord.y -= 0.25 * uTexSizeInv.y; // WebGL port note: Changed sign\n texCoord.y -= uTexSizeInv.y; // WebGL port note: Changed sign\n texCoord.y -= 2.0 * uTexSizeInv.y; // WebGL port note: Changed sign\n texCoord.y += uTexSizeInv.y * SMAASearchLength(searchTex, e.gr, 0.0, 0.5); // WebGL port note: Changed sign\n\n return texCoord.y;\n}\n\nfloat SMAASearchYDown(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {\n vec2 e = vec2( 1.0, 0.0 );\n\n for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for\n e = texture2D(edgesTex, texCoord, 0.0).rg;\n texCoord -= vec2( 0.0, 2.0 ) * uTexSizeInv; // WebGL port note: Changed sign\n if (!(texCoord.y < end && e.r > 0.8281 && e.g == 0.0)) break;\n }\n\n texCoord.y += 0.25 * uTexSizeInv.y; // WebGL port note: Changed sign\n texCoord.y += uTexSizeInv.y; // WebGL port note: Changed sign\n texCoord.y += 2.0 * uTexSizeInv.y; // WebGL port note: Changed sign\n texCoord.y -= uTexSizeInv.y * SMAASearchLength(searchTex, e.gr, 0.5, 0.5); // WebGL port note: Changed sign\n\n return texCoord.y;\n}\n\nvec2 SMAAArea(sampler2D areaTex, vec2 dist, float e1, float e2, float offset) {\n // Rounding prevents precision errors of bilinear filtering:\n vec2 texCoord = float(SMAA_AREATEX_MAX_DISTANCE) * round(4.0 * vec2(e1, e2)) + dist;\n\n // We do a scale and bias for mapping to texel space:\n texCoord = SMAA_AREATEX_PIXEL_SIZE * texCoord + (0.5 * SMAA_AREATEX_PIXEL_SIZE);\n\n // Move to proper place, according to the subpixel offset:\n texCoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;\n\n return texture2D(areaTex, texCoord, 0.0).rg;\n}\n\nvec4 SMAABlendingWeightCalculationPS(vec2 texCoord, vec2 pixCoord, vec4 offset[3], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices) {\n vec4 weights = vec4(0.0, 0.0, 0.0, 0.0);\n\n vec2 e = texture2D(edgesTex, texCoord).rg;\n\n if (e.g > 0.0) { // Edge at north\n vec2 d;\n\n // Find the distance to the left:\n vec2 coords;\n coords.x = SMAASearchXLeft(edgesTex, searchTex, offset[0].xy, offset[2].x );\n coords.y = offset[1].y; // offset[1].y = texCoord.y - 0.25 * uTexSizeInv.y (@CROSSING_OFFSET)\n d.x = coords.x;\n\n // Now fetch the left crossing edges, two at a time using bilinear\n // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to\n // discern what value each edge has:\n float e1 = texture2D(edgesTex, coords, 0.0).r;\n\n // Find the distance to the right:\n coords.x = SMAASearchXRight(edgesTex, searchTex, offset[0].zw, offset[2].y);\n d.y = coords.x;\n\n // We want the distances to be in pixel units (doing this here allow to\n // better interleave arithmetic and memory accesses):\n d = d / uTexSizeInv.x - pixCoord.x;\n\n // SMAAArea below needs a sqrt, as the areas texture is compressed\n // quadratically:\n vec2 sqrt_d = sqrt(abs(d));\n\n // Fetch the right crossing edges:\n coords.y -= 1.0 * uTexSizeInv.y; // WebGL port note: Added\n float e2 = SMAASampleLevelZeroOffset(edgesTex, coords, ivec2(1, 0)).r;\n\n // Ok, we know how this pattern looks like, now it is time for getting\n // the actual area:\n weights.rg = SMAAArea(areaTex, sqrt_d, e1, e2, float(subsampleIndices.y));\n }\n\n if (e.r > 0.0) { // Edge at west\n vec2 d;\n\n // Find the distance to the top:\n vec2 coords;\n\n coords.y = SMAASearchYUp(edgesTex, searchTex, offset[1].xy, offset[2].z );\n coords.x = offset[0].x; // offset[1].x = texCoord.x - 0.25 * uTexSizeInv.x;\n d.x = coords.y;\n\n // Fetch the top crossing edges:\n float e1 = texture2D(edgesTex, coords, 0.0).g;\n\n // Find the distance to the bottom:\n coords.y = SMAASearchYDown(edgesTex, searchTex, offset[1].zw, offset[2].w);\n d.y = coords.y;\n\n // We want the distances to be in pixel units:\n d = d / uTexSizeInv.y - pixCoord.y;\n\n // SMAAArea below needs a sqrt, as the areas texture is compressed\n // quadratically:\n vec2 sqrt_d = sqrt(abs(d));\n\n // Fetch the bottom crossing edges:\n coords.y -= 1.0 * uTexSizeInv.y; // WebGL port note: Added\n float e2 = SMAASampleLevelZeroOffset(edgesTex, coords, ivec2(0, 1)).g;\n\n // Get the area for this direction:\n weights.ba = SMAAArea(areaTex, sqrt_d, e1, e2, float(subsampleIndices.x));\n }\n\n return weights;\n}\n\nvoid main() {\n gl_FragColor = SMAABlendingWeightCalculationPS(vUv, vPixCoord, vOffset, tEdges, tArea, tSearch, ivec4(0.0));\n}\n"),_nt={...vo,tColor:jt("texture","rgba","ubyte","linear"),tWeights:jt("texture","rgba","ubyte","linear"),uTexSizeInv:xe("v2"),uViewport:xe("v4")},xnt=Br("smaa-blend","\nprecision highp float;\n\nattribute vec2 aPosition;\nuniform vec2 uQuadScale;\n\nuniform vec2 uTexSizeInv;\nuniform vec4 uViewport;\n\nvarying vec2 vUv;\nvarying vec4 vOffset[2];\n\nvoid SMAANeighborhoodBlendingVS(vec2 texCoord) {\n vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-1.0, 0.0, 0.0, 1.0); // WebGL port note: Changed sign in W component\n vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(1.0, 0.0, 0.0, -1.0); // WebGL port note: Changed sign in W component\n}\n\nvoid main() {\n vec2 scale = uViewport.zw * uTexSizeInv;\n vec2 shift = uViewport.xy * uTexSizeInv;\n vUv = (aPosition + 1.0) * 0.5 * scale + shift;\n SMAANeighborhoodBlendingVS(vUv);\n vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n","\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tWeights;\nuniform sampler2D tColor;\nuniform vec2 uTexSizeInv;\n\nvarying vec2 vUv;\nvarying vec4 vOffset[2];\n\nvec4 SMAANeighborhoodBlendingPS(vec2 texCoord, vec4 offset[2], sampler2D colorTex, sampler2D blendTex) {\n // Fetch the blending weights for current pixel:\n vec4 a;\n a.xz = texture2D(blendTex, texCoord).xz;\n a.y = texture2D(blendTex, offset[1].zw).g;\n a.w = texture2D(blendTex, offset[1].xy).a;\n\n // Is there any blending weight with a value greater than 0.0?\n if (dot(a, vec4(1.0, 1.0, 1.0, 1.0)) < 1e-5) {\n return texture2D(colorTex, texCoord, 0.0);\n } else {\n // Up to 4 lines can be crossing a pixel (one through each edge). We\n // favor blending by choosing the line with the maximum weight for each\n // direction:\n vec2 offset;\n offset.x = a.a > a.b ? a.a : -a.b; // left vs. right\n offset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs\n\n // Then we go in the direction that has the maximum weight:\n if (abs(offset.x) > abs(offset.y)) { // horizontal vs. vertical\n offset.y = 0.0;\n } else {\n offset.x = 0.0;\n }\n\n // Fetch the opposite color and lerp by hand:\n vec4 C = texture2D(colorTex, texCoord, 0.0);\n texCoord += sign(offset) * uTexSizeInv;\n vec4 Cop = texture2D(colorTex, texCoord, 0.0);\n float s = abs(offset.x) > abs(offset.y) ? abs(offset.x) : abs(offset.y);\n\n // WebGL port note: Added gamma correction\n C.xyz = pow(C.xyz, vec3(2.2));\n Cop.xyz = pow(Cop.xyz, vec3(2.2));\n vec4 mixed = mix(C, Cop, s);\n mixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));\n\n return mixed;\n }\n}\n\nvoid main() {\n gl_FragColor = SMAANeighborhoodBlendingPS(vUv, vOffset, tColor, tWeights);\n}\n"),hue={opacity:C.Numeric(1,{min:0,max:1,step:.01}),saturation:C.Numeric(0,{min:-1,max:1,step:.01}),lightness:C.Numeric(0,{min:-1,max:1,step:.01})},Tnt={faces:C.MappedStatic("urls",{urls:C.Group({nx:C.Text("",{label:"Negative X / Left"}),ny:C.Text("",{label:"Negative Y / Bottom"}),nz:C.Text("",{label:"Negative Z / Back"}),px:C.Text("",{label:"Positive X / Right"}),py:C.Text("",{label:"Positive Y / Top"}),pz:C.Text("",{label:"Positive Z / Front"})},{isExpanded:!0,label:"URLs"}),files:C.Group({nx:C.File({label:"Negative X / Left",accept:"image/*"}),ny:C.File({label:"Negative Y / Bottom",accept:"image/*"}),nz:C.File({label:"Negative Z / Back",accept:"image/*"}),px:C.File({label:"Positive X / Right",accept:"image/*"}),py:C.File({label:"Positive Y / Top",accept:"image/*"}),pz:C.File({label:"Positive Z / Front",accept:"image/*"})},{isExpanded:!0,label:"Files"})}),blur:C.Numeric(0,{min:0,max:1,step:.01},{description:'Note, this only works in WebGL2 or when "EXT_shader_texture_lod" is available.'}),...hue},Dnt={source:C.MappedStatic("url",{url:C.Text(""),file:C.File({accept:"image/*"})}),blur:C.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.'}),...hue,coverage:C.Select("viewport",C.arrayToOptions(["viewport","canvas"]))},Ent={topColor:C.Color(st(14540253)),bottomColor:C.Color(st(15658734)),ratio:C.Numeric(.5,{min:0,max:1,step:.01}),coverage:C.Select("viewport",C.arrayToOptions(["viewport","canvas"]))},Pnt={centerColor:C.Color(st(14540253)),edgeColor:C.Color(st(15658734)),ratio:C.Numeric(.5,{min:0,max:1,step:.01}),coverage:C.Select("viewport",C.arrayToOptions(["viewport","canvas"]))},Mnt={variant:C.MappedStatic("off",{off:C.EmptyGroup(),skybox:C.Group(Tnt,{isExpanded:!0}),image:C.Group(Dnt,{isExpanded:!0}),horizontalGradient:C.Group(Ent,{isExpanded:!0}),radialGradient:C.Group(Pnt,{isExpanded:!0})},{label:"Environment"})};class Rnt{constructor(t,n,r,i){this.webgl=t,this.assetManager=n,this.camera=new gr,this.target=v(),this.position=v(),this.dir=v(),this.renderable=function znt(e,t,n){const r={drawCount:k.create(6),instanceCount:k.create(1),aPosition:k.create(D5),tSkybox:k.create(Os()),tImage:k.create(Os()),uImageScale:k.create(Me()),uImageOffset:k.create(Me()),uTexSize:k.create(Me.create(t,n)),uViewport:k.create(nn()),uViewportAdjusted:k.create(!0),uViewDirectionProjectionInverse:k.create(le()),uGradientColorA:k.create(v()),uGradientColorB:k.create(v()),uGradientRatio:k.create(.5),uBlur:k.create(0),uOpacity:k.create(1),uSaturation:k.create(0),uLightness:k.create(0),dVariant:k.create("skybox")},i={...Unt};return ji(zi(e,"triangles",Vnt,i,r),r)}(t,r,i)}setSize(t,n){const[r,i]=this.renderable.values.uTexSize.ref.value;(t!==r||n!==i)&&k.update(this.renderable.values.uTexSize,Me.set(this.renderable.values.uTexSize.ref.value,t,n))}clearSkybox(){void 0!==this.skybox&&(this.skybox.texture.destroy(),this.skybox.assets.forEach(t=>this.assetManager.release(t)),this.skybox=void 0)}updateSkybox(t,n,r){var i;const o=null===(i=this.skybox)||void 0===i?void 0:i.props.faces,s=n.faces.params;if(!(s.nx&&s.ny&&s.nz&&s.px&&s.py&&s.pz))return this.clearSkybox(),void r?.(!1);if(this.skybox&&o&&function Fnt(e,t){return gue(e)===gue(t)}(n.faces,this.skybox.props.faces))r?.(!1);else{this.clearSkybox();const{texture:u,assets:l}=function Bnt(e,t,n,r){const i=function knt(e,t){return"urls"===t.name?{nx:fr.getUrlAsset(e,t.params.nx),ny:fr.getUrlAsset(e,t.params.ny),nz:fr.getUrlAsset(e,t.params.nz),px:fr.getUrlAsset(e,t.params.px),py:fr.getUrlAsset(e,t.params.py),pz:fr.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}}(t,n),o=function Nnt(e,t){const n=r=>e.resolve(r,"binary").run().then(i=>new Blob([i.data]));return{nx:n(t.nx),ny:n(t.ny),nz:n(t.nz),px:n(t.px),py:n(t.py),pz:n(t.pz)}}(t,i),s=[i.nx,i.ny,i.nz,i.px,i.py,i.pz];return typeof HTMLImageElement>"u"?(console.error('Missing "HTMLImageElement" required for background skybox'),r?.(!0),{texture:Os(),assets:s}):{texture:e.resources.cubeTexture(o,!0,r),assets:s}}(this.webgl,this.assetManager,n.faces,d=>{this.skybox&&(this.skybox.loaded=!d),r?.(!0)});this.skybox={texture:u,props:{...n},assets:l,loaded:!1},k.update(this.renderable.values.tSkybox,u),this.renderable.update()}if(!this.skybox)return;let a=t;"orthographic"===t.state.mode&&(this.camera.setState({...t.state,mode:"perspective"}),this.camera.update(),a=this.camera);const c=this.renderable.values.uViewDirectionProjectionInverse.ref.value;v.sub(this.dir,a.state.position,a.state.target),v.setMagnitude(this.dir,this.dir,.1),v.copy(this.position,this.dir),le.lookAt(c,this.position,this.target,a.state.up),le.mul(c,a.projection,c),le.invert(c,c),k.update(this.renderable.values.uViewDirectionProjectionInverse,c),k.updateIfChanged(this.renderable.values.uBlur,n.blur),k.updateIfChanged(this.renderable.values.uOpacity,n.opacity),k.updateIfChanged(this.renderable.values.uSaturation,n.saturation),k.updateIfChanged(this.renderable.values.uLightness,n.lightness),k.updateIfChanged(this.renderable.values.dVariant,"skybox"),this.renderable.update()}clearImage(){void 0!==this.image&&(this.image.texture.destroy(),this.assetManager.release(this.image.asset),this.image=void 0)}updateImage(t,n){if(!t.source.params)return this.clearImage(),void n?.(!1);if(this.image&&this.image.props.source.params&&function Ont(e,t){return bue(e)===bue(t)}(t.source,this.image.props.source))n?.(!1);else{this.clearImage();const{texture:r,asset:i}=function Lnt(e,t,n,r){const i="url"===n.name?fr.getUrlAsset(t,n.params):n.params;if(typeof HTMLImageElement>"u")return console.error('Missing "HTMLImageElement" required for background image'),r?.(!0),{texture:Os(),asset:i};const o=e.resources.texture("image-uint8","rgba","ubyte","linear"),s=new Image;return s.onload=()=>{o.load(s),(e.isWebGL2||$x(s.width)&&$x(s.height))&&o.mipmap(),r?.()},s.onerror=()=>{r?.(!0)},t.resolve(i,"binary").run().then(a=>{const c=new Blob([a.data]);s.src=URL.createObjectURL(c)}),{texture:o,asset:i}}(this.webgl,this.assetManager,t.source,o=>{this.image&&(this.image.loaded=!o),n?.(!0)});this.image={texture:r,props:{...t},asset:i,loaded:!1},k.update(this.renderable.values.tImage,r),this.renderable.update()}this.image&&(k.updateIfChanged(this.renderable.values.uBlur,t.blur),k.updateIfChanged(this.renderable.values.uOpacity,t.opacity),k.updateIfChanged(this.renderable.values.uSaturation,t.saturation),k.updateIfChanged(this.renderable.values.uLightness,t.lightness),k.updateIfChanged(this.renderable.values.uViewportAdjusted,"viewport"===t.coverage),k.updateIfChanged(this.renderable.values.dVariant,"image"),this.renderable.update())}updateImageScaling(){var t,n;const r=this.renderable.values,[i,o]=r.uTexSize.ref.value,s=(null===(t=this.image)||void 0===t?void 0:t.texture.getWidth())||0,a=(null===(n=this.image)||void 0===n?void 0:n.texture.getHeight())||0,c=i/o;k.update(r.uImageScale,cc?Me.set(r.uImageOffset.ref.value,(1-c/f)/2,0):Me.set(r.uImageOffset.ref.value,0,(1-f/c)/2))}updateGradient(t,n,r,i,o){k.update(this.renderable.values.uGradientColorA,st.toVec3Normalized(this.renderable.values.uGradientColorA.ref.value,t)),k.update(this.renderable.values.uGradientColorB,st.toVec3Normalized(this.renderable.values.uGradientColorB.ref.value,n)),k.updateIfChanged(this.renderable.values.uGradientRatio,r),k.updateIfChanged(this.renderable.values.uViewportAdjusted,o),k.updateIfChanged(this.renderable.values.dVariant,i),this.renderable.update()}update(t,n,r){if("off"===n.variant.name)return this.clearSkybox(),this.clearImage(),void r?.(!1);"skybox"===n.variant.name?(this.clearImage(),this.updateSkybox(t,n.variant.params,r)):"image"===n.variant.name?(this.clearSkybox(),this.updateImage(n.variant.params,r)):"horizontalGradient"===n.variant.name?(this.clearSkybox(),this.clearImage(),this.updateGradient(n.variant.params.topColor,n.variant.params.bottomColor,n.variant.params.ratio,n.variant.name,"viewport"===n.variant.params.coverage),r?.(!1)):"radialGradient"===n.variant.name&&(this.clearSkybox(),this.clearImage(),this.updateGradient(n.variant.params.centerColor,n.variant.params.edgeColor,n.variant.params.ratio,n.variant.name,"viewport"===n.variant.params.coverage),r?.(!1));const{x:i,y:o,width:s,height:a}=t.viewport;k.update(this.renderable.values.uViewport,nn.set(this.renderable.values.uViewport.ref.value,i,o,s,a))}isEnabled(t){return!!(this.skybox&&this.skybox.loaded||this.image&&this.image.loaded||"horizontalGradient"===t.variant.name||"radialGradient"===t.variant.name)}isReady(){return!!(this.skybox&&this.skybox.loaded||this.image&&this.image.loaded||"horizontalGradient"===this.renderable.values.dVariant.ref.value||"radialGradient"===this.renderable.values.dVariant.ref.value)}render(){this.isReady()&&("image"===this.renderable.values.dVariant.ref.value&&this.updateImageScaling(),lt&&this.webgl.timer.mark("BackgroundPass.render"),this.renderable.render(),lt&&this.webgl.timer.markEnd("BackgroundPass.render"))}dispose(){this.clearSkybox(),this.clearImage()}}const mue="background-skybox";function gue(e){var t,n,r,i,o,s;return"urls"===e.name?`${mue}_${e.params.nx}|${e.params.ny}|${e.params.nz}|${e.params.px}|${e.params.py}|${e.params.pz}`:`${mue}_${null===(t=e.params.nx)||void 0===t?void 0:t.id}|${null===(n=e.params.ny)||void 0===n?void 0:n.id}|${null===(r=e.params.nz)||void 0===r?void 0:r.id}|${null===(i=e.params.px)||void 0===i?void 0:i.id}|${null===(o=e.params.py)||void 0===o?void 0:o.id}|${null===(s=e.params.pz)||void 0===s?void 0:s.id}`}const yue="background-image";function bue(e){var t;return"url"===e.name?`${yue}_${e.params}`:`${yue}_${null===(t=e.params)||void 0===t?void 0:t.id}`}const Unt={drawCount:ri("number"),instanceCount:ri("number"),aPosition:Ar("float32",2,0),tSkybox:jt("texture","rgba","ubyte","linear"),tImage:jt("texture","rgba","ubyte","linear"),uImageScale:xe("v2"),uImageOffset:xe("v2"),uTexSize:xe("v2"),uViewport:xe("v4"),uViewportAdjusted:xe("b"),uViewDirectionProjectionInverse:xe("m4"),uGradientColorA:xe("v3"),uGradientColorB:xe("v3"),uGradientRatio:xe("f"),uBlur:xe("f"),uOpacity:xe("f"),uSaturation:xe("f"),uLightness:xe("f"),dVariant:Ft("string",["skybox","image","verticalGradient","horizontalGradient","radialGradient"])},Vnt=Br("background","\nprecision mediump float;\n\nattribute vec2 aPosition;\n\nvarying vec4 vPosition;\n\nvoid main() {\n vPosition = vec4(aPosition, 1.0, 1.0);\n gl_Position = vec4(aPosition, 1.0, 1.0);\n}\n","\nprecision mediump float;\nprecision mediump samplerCube;\nprecision mediump sampler2D;\n\n#if defined(dVariant_skybox)\n uniform samplerCube tSkybox;\n uniform mat4 uViewDirectionProjectionInverse;\n uniform float uBlur;\n uniform float uOpacity;\n uniform float uSaturation;\n uniform float uLightness;\n#elif defined(dVariant_image)\n uniform sampler2D tImage;\n uniform vec2 uImageScale;\n uniform vec2 uImageOffset;\n uniform float uBlur;\n uniform float uOpacity;\n uniform float uSaturation;\n uniform float uLightness;\n#elif defined(dVariant_horizontalGradient) || defined(dVariant_radialGradient)\n uniform vec3 uGradientColorA;\n uniform vec3 uGradientColorB;\n uniform float uGradientRatio;\n#endif\n\nuniform vec2 uTexSize;\nuniform vec4 uViewport;\nuniform bool uViewportAdjusted;\nvarying vec4 vPosition;\n\n// TODO: add as general pp option to remove banding?\n// Iestyn's RGB dither from http://alex.vlachos.com/graphics/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf\nvec3 ScreenSpaceDither(vec2 vScreenPos) {\n vec3 vDither = vec3(dot(vec2(171.0, 231.0), vScreenPos.xy));\n vDither.rgb = fract(vDither.rgb / vec3(103.0, 71.0, 97.0));\n return vDither.rgb / 255.0;\n}\n\nvec3 saturateColor(vec3 c, float amount) {\n // https://www.w3.org/TR/WCAG21/#dfn-relative-luminance\n const vec3 W = vec3(0.2125, 0.7154, 0.0721);\n vec3 intensity = vec3(dot(c, W));\n return mix(intensity, c, 1.0 + amount);\n}\n\nvec3 lightenColor(vec3 c, float amount) {\n return c + amount;\n}\n\nvoid main() {\n #if defined(dVariant_skybox)\n vec4 t = uViewDirectionProjectionInverse * vPosition;\n #ifdef enabledShaderTextureLod\n gl_FragColor = textureCubeLodEXT(tSkybox, normalize(t.xyz / t.w), uBlur * 8.0);\n #else\n gl_FragColor = textureCube(tSkybox, normalize(t.xyz / t.w));\n #endif\n gl_FragColor.a = uOpacity;\n gl_FragColor.rgb = lightenColor(saturateColor(gl_FragColor.rgb, uSaturation), uLightness);\n #elif defined(dVariant_image)\n vec2 coords;\n if (uViewportAdjusted) {\n coords = ((gl_FragCoord.xy - uViewport.xy) * (uTexSize / uViewport.zw) / uImageScale) + uImageOffset;\n } else {\n coords = (gl_FragCoord.xy / uImageScale) + uImageOffset;\n }\n #ifdef enabledShaderTextureLod\n gl_FragColor = texture2DLodEXT(tImage, vec2(coords.x, 1.0 - coords.y), uBlur * 8.0);\n #else\n gl_FragColor = texture2D(tImage, vec2(coords.x, 1.0 - coords.y));\n #endif\n gl_FragColor.a = uOpacity;\n gl_FragColor.rgb = lightenColor(saturateColor(gl_FragColor.rgb, uSaturation), uLightness);\n #elif defined(dVariant_horizontalGradient)\n float d;\n if (uViewportAdjusted) {\n d = ((gl_FragCoord.y - uViewport.y) * (uTexSize.y / uViewport.w) / uTexSize.y) + 1.0 - (uGradientRatio * 2.0);\n } else {\n d = (gl_FragCoord.y / uTexSize.y) + 1.0 - (uGradientRatio * 2.0);\n }\n gl_FragColor = vec4(mix(uGradientColorB, uGradientColorA, clamp(d, 0.0, 1.0)), 1.0);\n gl_FragColor.rgb += ScreenSpaceDither(gl_FragCoord.xy);\n #elif defined(dVariant_radialGradient)\n float d;\n if (uViewportAdjusted) {\n d = distance(vec2(0.5), (gl_FragCoord.xy - uViewport.xy) * (uTexSize / uViewport.zw) / uTexSize) + uGradientRatio - 0.5;\n } else {\n d = distance(vec2(0.5), gl_FragCoord.xy / uTexSize) + uGradientRatio - 0.5;\n }\n gl_FragColor = vec4(mix(uGradientColorB, uGradientColorA, 1.0 - clamp(d, 0.0, 1.0)), 1.0);\n gl_FragColor.rgb += ScreenSpaceDither(gl_FragCoord.xy);\n #endif\n}\n",{shaderTextureLod:"optional"}),Hnt={sharpness:C.Numeric(.5,{min:0,max:1,step:.05}),denoise:C.Boolean(!0)};class qnt{constructor(t,n){this.webgl=t,this.renderable=function Ynt(e,t){const n=t.getWidth(),r=t.getHeight(),i={..._o,tColor:k.create(t),uTexSizeInv:k.create(Me.create(1/n,1/r)),uSharpness:k.create(.5),dDenoise:k.create(!0)},o={...Wnt};return ji(zi(e,"triangles",$nt,o,i),i)}(t,n)}updateState(t){const{gl:n,state:r}=this.webgl;r.enable(n.SCISSOR_TEST),r.disable(n.BLEND),r.disable(n.DEPTH_TEST),r.depthMask(!1);const{x:i,y:o,width:s,height:a}=t;r.viewport(i,o,s,a),r.scissor(i,o,s,a),r.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT)}setSize(t,n){k.update(this.renderable.values.uTexSizeInv,Me.set(this.renderable.values.uTexSizeInv.ref.value,1/t,1/n))}update(t,n){const{values:r}=this.renderable,{sharpness:i,denoise:o}=n;let s=!1;r.tColor.ref.value!==t&&(k.update(this.renderable.values.tColor,t),s=!0),k.updateIfChanged(r.uSharpness,2-2*Math.pow(i,.25)),r.dDenoise.ref.value!==o&&(s=!0),k.updateIfChanged(r.dDenoise,o),s&&this.renderable.update()}render(t,n){lt&&this.webgl.timer.mark("CasPass.render"),n?n.bind():this.webgl.unbindFramebuffer(),this.updateState(t),this.renderable.render(),lt&&this.webgl.timer.markEnd("CasPass.render")}}const Wnt={...vo,tColor:jt("texture","rgba","ubyte","linear"),uTexSizeInv:xe("v2"),uSharpness:xe("f"),dDenoise:Ft("boolean")},$nt=Br("cas",ps,"\nprecision mediump float;\nprecision mediump sampler2D;\n\nuniform sampler2D tColor;\nuniform vec2 uTexSizeInv;\n\nuniform float uSharpness;\n\n// adapted from https://www.shadertoy.com/view/stXSWB\n\n/*\n* FidelityFX Super Resolution scales up a low resolution\n* image, while adding fine detail.\n*\n* MIT Open License\n*\n* https://gpuopen.com/fsr\n*\n* Left: FSR processed\n* Right: Original texture, bilinear interpolation\n*\n* Mouse at top: Sharpness 0 stops (maximum)\n* Mouse at bottom: Sharpness 2 stops (minimum)\n*\n* It works in two passes-\n* EASU upsamples the image with a clamped Lanczos kernel.\n* RCAS sharpens the image at the target resolution.\n*\n* I needed to make a few changes to improve readability and\n* WebGL compatibility in an algorithm I don't fully understand.\n* Expect bugs.\n*\n* Shader not currently running for WebGL1 targets (eg. mobile Safari)\n*\n* There is kind of no point to using FSR in Shadertoy, as it renders buffers\n* at full target resolution. But this might be useful for WebGL based demos\n* running smaller-than-target render buffers.\n*\n* For sharpening with a full resolution render buffer,\n* FidelityFX CAS is a better option.\n* https://www.shadertoy.com/view/ftsXzM\n*\n* For readability and compatibility, these optimisations have been removed:\n* * Fast approximate inverse and inversesqrt\n* * textureGather fetches (not WebGL compatible)\n* * Multiplying by reciprocal instead of division\n*\n* Apologies to AMD for the numerous slowdowns and errors I have introduced.\n*\n*/\n\n/***** RCAS *****/\n#define FSR_RCAS_LIMIT (0.25-(1.0/16.0))\n\n// Input callback prototypes that need to be implemented by calling shader\nvec4 FsrRcasLoadF(vec2 p);\n//------------------------------------------------------------------------------------------------------------------------------\nvoid FsrRcasCon(\n out float con,\n // The scale is {0.0 := maximum, to N>0, where N is the number of stops (halving) of the reduction of sharpness}.\n float sharpness\n) {\n // Transform from stops to linear value.\n con = exp2(-sharpness);\n}\n\nvec3 FsrRcasF(\n vec2 ip, // Integer pixel position in output.\n float con\n) {\n // Constant generated by RcasSetup().\n // Algorithm uses minimal 3x3 pixel neighborhood.\n // b\n // d e f\n // h\n vec2 sp = vec2(ip);\n vec3 b = FsrRcasLoadF(sp + vec2( 0,-1)).rgb;\n vec3 d = FsrRcasLoadF(sp + vec2(-1, 0)).rgb;\n vec3 e = FsrRcasLoadF(sp).rgb;\n vec3 f = FsrRcasLoadF(sp + vec2( 1, 0)).rgb;\n vec3 h = FsrRcasLoadF(sp + vec2( 0, 1)).rgb;\n\n // Luma times 2.\n float bL = b.g + .5 * (b.b + b.r);\n float dL = d.g + .5 * (d.b + d.r);\n float eL = e.g + .5 * (e.b + e.r);\n float fL = f.g + .5 * (f.b + f.r);\n float hL = h.g + .5 * (h.b + h.r);\n\n // Noise detection.\n #ifdef dDenoise\n float nz = .25 * (bL + dL + fL + hL) - eL;\n nz=clamp(\n abs(nz)\n /(\n max(max(bL,dL),max(eL,max(fL,hL)))\n -min(min(bL,dL),min(eL,min(fL,hL)))\n ),\n 0., 1.\n );\n nz=1.-.5*nz;\n #endif\n\n // Min and max of ring.\n vec3 mn4 = min(b, min(f, h));\n vec3 mx4 = max(b, max(f, h));\n\n // Immediate constants for peak range.\n vec2 peakC = vec2(1., -4.);\n\n // Limiters, these need to be high precision RCPs.\n vec3 hitMin = mn4 / (4. * mx4);\n vec3 hitMax = (peakC.x - mx4) / (4.* mn4 + peakC.y);\n vec3 lobeRGB = max(-hitMin, hitMax);\n float lobe = max(\n -FSR_RCAS_LIMIT,\n min(max(lobeRGB.r, max(lobeRGB.g, lobeRGB.b)), 0.)\n )*con;\n\n // Apply noise removal.\n #ifdef dDenoise\n lobe *= nz;\n #endif\n\n // Resolve, which needs the medium precision rcp approximation to avoid visible tonality changes.\n return (lobe * (b + d + h + f) + e) / (4. * lobe + 1.);\n}\n\n\nvec4 FsrRcasLoadF(vec2 p) {\n return texture2D(tColor, p * uTexSizeInv);\n}\n\nvoid main() {\n // Set up constants\n float con;\n FsrRcasCon(con, uSharpness);\n\n // Perform RCAS pass\n vec3 col = FsrRcasF(gl_FragCoord.xy, con);\n\n gl_FragColor = vec4(col, FsrRcasLoadF(gl_FragCoord.xy).a);\n}\n"),Xnt={...vo,tDepthOpaque:jt("texture","rgba","ubyte","nearest"),tDepthTransparent:jt("texture","rgba","ubyte","nearest"),uTexSize:xe("v2"),dOrthographic:Ft("number"),uNear:xe("f"),uFar:xe("f"),uInvProjection:xe("m4"),uOutlineThreshold:xe("f"),dTransparentOutline:Ft("boolean")},Znt={...vo,tDepth:jt("texture","rgba","ubyte","nearest"),uTexSize:xe("v2"),uProjection:xe("m4"),uInvProjection:xe("m4"),uBounds:xe("v4"),dOrthographic:Ft("number"),uNear:xe("f"),uFar:xe("f"),dSteps:Ft("number"),uMaxDistance:xe("f"),uTolerance:xe("f"),uBias:xe("f"),uLightDirection:xe("v3[]"),uLightColor:xe("v3[]"),dLightCount:Ft("number")},Jnt={...vo,tDepth:jt("texture","rgba","ubyte","nearest"),tDepthHalf:jt("texture","rgba","ubyte","nearest"),tDepthQuarter:jt("texture","rgba","ubyte","nearest"),uSamples:xe("v3[]"),dNSamples:Ft("number"),uProjection:xe("m4"),uInvProjection:xe("m4"),uBounds:xe("v4"),uTexSize:xe("v2"),uRadius:xe("f"),uBias:xe("f"),dMultiScale:Ft("boolean"),dLevels:Ft("number"),uLevelRadius:xe("f[]"),uLevelBias:xe("f[]"),uNearThreshold:xe("f"),uFarThreshold:xe("f")},trt={...vo,tSsaoDepth:jt("texture","rgba","ubyte","nearest"),uTexSize:xe("v2"),uKernel:xe("f[]"),dOcclusionKernelSize:Ft("number"),uBlurDirectionX:xe("f"),uBlurDirectionY:xe("f"),uInvProjection:xe("m4"),uNear:xe("f"),uFar:xe("f"),uBounds:xe("v4"),dOrthographic:Ft("number")};function vue(e,t,n){const r={..._o,tSsaoDepth:k.create(t),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight())),uKernel:k.create(_ue(15)),dOcclusionKernelSize:k.create(15),uBlurDirectionX:k.create("horizontal"===n?1:0),uBlurDirectionY:k.create("vertical"===n?1:0),uInvProjection:k.create(le.identity()),uNear:k.create(0),uFar:k.create(1e4),uBounds:k.create(nn()),dOrthographic:k.create(0)},i={...trt};return ji(zi(e,"triangles",Br("ssao_blur",ps,"\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tSsaoDepth;\nuniform vec2 uTexSize;\nuniform vec4 uBounds;\n\nuniform float uKernel[dOcclusionKernelSize];\n\nuniform float uBlurDirectionX;\nuniform float uBlurDirectionY;\n\nuniform mat4 uInvProjection;\nuniform float uNear;\nuniform float uFar;\n\n#include common\n\nfloat getViewZ(const in float depth) {\n #if dOrthographic == 1\n return orthographicDepthToViewZ(depth, uNear, uFar);\n #else\n return perspectiveDepthToViewZ(depth, uNear, uFar);\n #endif\n}\n\nbool isBackground(const in float depth) {\n return depth == 1.0;\n}\n\nbool outsideBounds(const in vec2 p) {\n return p.x < uBounds.x || p.y < uBounds.y || p.x > uBounds.z || p.y > uBounds.w;\n}\n\nfloat getPixelSize(const in vec2 coords, const in float depth) {\n vec3 viewPos0 = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection);\n vec3 viewPos1 = screenSpaceToViewSpace(vec3(coords + vec2(1.0, 0.0) / uTexSize, depth), uInvProjection);\n return distance(viewPos0, viewPos1);\n}\n\nvoid main(void) {\n vec2 coords = gl_FragCoord.xy / uTexSize;\n\n vec2 packedDepth = texture2D(tSsaoDepth, coords).zw;\n\n if (outsideBounds(coords)) {\n gl_FragColor = vec4(packUnitIntervalToRG(1.0), packedDepth);\n return;\n }\n\n float selfDepth = unpackRGToUnitInterval(packedDepth);\n // if background and if second pass\n if (isBackground(selfDepth) && uBlurDirectionY != 0.0) {\n gl_FragColor = vec4(packUnitIntervalToRG(1.0), packedDepth);\n return;\n }\n\n float selfViewZ = getViewZ(selfDepth);\n float pixelSize = getPixelSize(coords, selfDepth);\n float maxDiffViewZ = pixelSize * 10.0;\n\n vec2 offset = vec2(uBlurDirectionX, uBlurDirectionY) / uTexSize;\n\n float sum = 0.0;\n float kernelSum = 0.0;\n // only if kernelSize is odd\n for (int i = -dOcclusionKernelSize / 2; i <= dOcclusionKernelSize / 2; i++) {\n if (abs(float(i)) > 1.0 && abs(float(i)) * pixelSize > 0.8) continue;\n\n vec2 sampleCoords = coords + float(i) * offset;\n if (outsideBounds(sampleCoords)) {\n continue;\n }\n\n vec4 sampleSsaoDepth = texture2D(tSsaoDepth, sampleCoords);\n\n float sampleDepth = unpackRGToUnitInterval(sampleSsaoDepth.zw);\n if (isBackground(sampleDepth)) {\n continue;\n }\n\n if (abs(float(i)) > 1.0) {\n float sampleViewZ = getViewZ(sampleDepth);\n if (abs(selfViewZ - sampleViewZ) > maxDiffViewZ) {\n continue;\n }\n }\n\n float kernel = uKernel[int(abs(float(i)))]; // abs is not defined for int in webgl1\n float sampleValue = unpackRGToUnitInterval(sampleSsaoDepth.xy);\n\n sum += kernel * sampleValue;\n kernelSum += kernel;\n }\n\n gl_FragColor = vec4(packUnitIntervalToRG(sum / kernelSum), packedDepth);\n}\n"),i,r),r)}function _ue(e){const t=e/3,n=Math.floor((e+1)/2),r=[];for(let i=0;i`${e.radius}, ${e.bias}`,{defaultValue:[{radius:2,bias:1},{radius:5,bias:1},{radius:8,bias:1},{radius:11,bias:1}]}),nearThreshold:C.Numeric(10,{min:0,max:50,step:1}),farThreshold:C.Numeric(1500,{min:0,max:1e4,step:100})}),off:C.Group({})},{cycle:!0}),radius:C.Numeric(5,{min:0,max:20,step:.1},{description:"Final occlusion radius is 2^x",hideIf:e=>"on"===e?.multiScale.name}),bias:C.Numeric(.8,{min:0,max:3,step:.1}),blurKernelSize:C.Numeric(15,{min:1,max:25,step:2}),resolutionScale:C.Numeric(1,{min:.1,max:1,step:.05},{description:"Adjust resolution of occlusion calculation"}),color:C.Color(st(0))}),off:C.Group({})},{cycle:!0,description:"Darken occluded crevices with the ambient occlusion effect"}),shadow:C.MappedStatic("off",{on:C.Group({steps:C.Numeric(1,{min:1,max:64,step:1}),bias:C.Numeric(.6,{min:0,max:1,step:.01}),maxDistance:C.Numeric(3,{min:0,max:256,step:1}),tolerance:C.Numeric(1,{min:0,max:10,step:.1})}),off:C.Group({})},{cycle:!0,description:"Simplistic shadows"}),outline:C.MappedStatic("off",{on:C.Group({scale:C.Numeric(1,{min:1,max:5,step:1}),threshold:C.Numeric(.33,{min:.01,max:1,step:.01}),color:C.Color(st(0)),includeTransparent:C.Boolean(!0,{description:"Whether to show outline for transparent objects"})}),off:C.Group({})},{cycle:!0,description:"Draw outline around 3D objects"}),antialiasing:C.MappedStatic("smaa",{fxaa:C.Group(tnt),smaa:C.Group(fnt),off:C.Group({})},{options:[["fxaa","FXAA"],["smaa","SMAA"],["off","Off"]],description:"Smooth pixel edges"}),sharpening:C.MappedStatic("off",{on:C.Group(Hnt),off:C.Group({})},{cycle:!0,description:"Contrast Adaptive Sharpening"}),background:C.Group(Mnt,{isFlat:!0})};class uc{static isEnabled(t){return"on"===t.occlusion.name||"on"===t.shadow.name||"on"===t.outline.name||"off"!==t.background.variant.name}static isTransparentOutlineEnabled(t){return"on"===t.outline.name&&t.outline.params.includeTransparent}calcSsaoScale(t){return Math.min(1,1/this.webgl.pixelRatio)*t}constructor(t,n,r){this.webgl=t,this.drawPass=r,this.bgColor=v(),this.occlusionOffset=[0,0],this.transparentBackground=!1;const{colorTarget:i,depthTextureTransparent:o,depthTextureOpaque:s}=r,a=i.getWidth(),c=i.getHeight();this.nSamples=1,this.blurKernelSize=1,this.ssaoScale=this.calcSsaoScale(1),this.levels=[],this.target=t.createRenderTarget(a,c,!1,"uint8","linear"),this.outlinesTarget=t.createRenderTarget(a,c,!1),this.outlinesRenderable=function Knt(e,t,n,r){const i=t.getWidth(),o=t.getHeight(),s={..._o,tDepthOpaque:k.create(t),tDepthTransparent:k.create(n),uTexSize:k.create(Me.create(i,o)),dOrthographic:k.create(0),uNear:k.create(1),uFar:k.create(1e4),uInvProjection:k.create(le.identity()),uOutlineThreshold:k.create(.33),dTransparentOutline:k.create(r)},a={...Xnt};return ji(zi(e,"triangles",Br("outlines",ps,"\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tDepthOpaque;\nuniform sampler2D tDepthTransparent;\nuniform vec2 uTexSize;\n\nuniform float uNear;\nuniform float uFar;\nuniform mat4 uInvProjection;\n\nuniform float uOutlineThreshold;\n\n#include common\n\nfloat getViewZ(const in float depth) {\n #if dOrthographic == 1\n return orthographicDepthToViewZ(depth, uNear, uFar);\n #else\n return perspectiveDepthToViewZ(depth, uNear, uFar);\n #endif\n}\n\nfloat getDepthOpaque(const in vec2 coords) {\n #ifdef depthTextureSupport\n return texture2D(tDepthOpaque, coords).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepthOpaque, coords));\n #endif\n}\n\nfloat getDepthTransparent(const in vec2 coords) {\n #ifdef dTransparentOutline\n return unpackRGBAToDepth(texture2D(tDepthTransparent, coords));\n #else\n return 1.0;\n #endif\n}\n\nbool isBackground(const in float depth) {\n return depth == 1.0;\n}\n\nfloat getPixelSize(const in vec2 coords, const in float depth) {\n vec3 viewPos0 = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection);\n vec3 viewPos1 = screenSpaceToViewSpace(vec3(coords + vec2(1.0, 0.0) / uTexSize, depth), uInvProjection);\n return distance(viewPos0, viewPos1);\n}\n\nvoid main(void) {\n float backgroundViewZ = 2.0 * uFar;\n\n vec2 coords = gl_FragCoord.xy / uTexSize;\n vec2 invTexSize = 1.0 / uTexSize;\n\n float selfDepthOpaque = getDepthOpaque(coords);\n float selfViewZOpaque = isBackground(selfDepthOpaque) ? backgroundViewZ : getViewZ(selfDepthOpaque);\n float pixelSizeOpaque = getPixelSize(coords, selfDepthOpaque) * uOutlineThreshold;\n\n float selfDepthTransparent = getDepthTransparent(coords);\n float selfViewZTransparent = isBackground(selfDepthTransparent) ? backgroundViewZ : getViewZ(selfDepthTransparent);\n float pixelSizeTransparent = getPixelSize(coords, selfDepthTransparent) * uOutlineThreshold;\n\n float outline = 1.0;\n float bestDepth = 1.0;\n float transparentFlag = 0.0;\n\n for (int y = -1; y <= 1; y++) {\n for (int x = -1; x <= 1; x++) {\n vec2 sampleCoords = coords + vec2(float(x), float(y)) * invTexSize;\n\n float sampleDepthOpaque = getDepthOpaque(sampleCoords);\n float sampleDepthTransparent = getDepthTransparent(sampleCoords);\n\n float sampleViewZOpaque = isBackground(sampleDepthOpaque) ? backgroundViewZ : getViewZ(sampleDepthOpaque);\n if (abs(selfViewZOpaque - sampleViewZOpaque) > pixelSizeOpaque && selfDepthOpaque > sampleDepthOpaque && sampleDepthOpaque <= bestDepth) {\n outline = 0.0;\n bestDepth = sampleDepthOpaque;\n }\n\n if (sampleDepthTransparent < sampleDepthOpaque) {\n float sampleViewZTransparent = isBackground(sampleDepthTransparent) ? backgroundViewZ : getViewZ(sampleDepthTransparent);\n if (abs(selfViewZTransparent - sampleViewZTransparent) > pixelSizeTransparent && selfDepthTransparent > sampleDepthTransparent && sampleDepthTransparent <= bestDepth) {\n outline = 0.0;\n bestDepth = sampleDepthTransparent;\n transparentFlag = 1.0;\n }\n }\n }\n }\n\n gl_FragColor = vec4(outline, packUnitIntervalToRG(bestDepth), transparentFlag);\n}\n"),a,s),s)}(t,s,o,!0),this.shadowsTarget=t.createRenderTarget(a,c,!1),this.shadowsRenderable=function Qnt(e,t){const n=t.getWidth(),r=t.getHeight(),i={..._o,tDepth:k.create(t),uTexSize:k.create(Me.create(n,r)),uProjection:k.create(le.identity()),uInvProjection:k.create(le.identity()),uBounds:k.create(nn()),dOrthographic:k.create(0),uNear:k.create(1),uFar:k.create(1e4),dSteps:k.create(1),uMaxDistance:k.create(3),uTolerance:k.create(1),uBias:k.create(.6),uLightDirection:k.create([]),uLightColor:k.create([]),dLightCount:k.create(0)},o={...Znt};return ji(zi(e,"triangles",Br("shadows",ps,"\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#include common\n\nuniform sampler2D tDepth;\nuniform vec2 uTexSize;\nuniform vec4 uBounds;\n\nuniform float uNear;\nuniform float uFar;\n\n#if dLightCount != 0\n uniform vec3 uLightDirection[dLightCount];\n uniform vec3 uLightColor[dLightCount];\n#endif\n\nuniform mat4 uProjection;\nuniform mat4 uInvProjection;\n\nuniform float uMaxDistance;\nuniform float uTolerance;\nuniform float uBias;\n\nbool isBackground(const in float depth) {\n return depth == 1.0;\n}\n\nbool outsideBounds(const in vec2 p) {\n return p.x < uBounds.x || p.y < uBounds.y || p.x > uBounds.z || p.y > uBounds.w;\n}\n\nfloat getViewZ(const in float depth) {\n #if dOrthographic == 1\n return orthographicDepthToViewZ(depth, uNear, uFar);\n #else\n return perspectiveDepthToViewZ(depth, uNear, uFar);\n #endif\n}\n\nfloat getDepth(const in vec2 coords) {\n #ifdef depthTextureSupport\n return texture2D(tDepth, coords).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n #endif\n}\n\nfloat screenFade(const in vec2 coords) {\n vec2 c = (coords - uBounds.xy) / (uBounds.zw - uBounds.xy);\n vec2 fade = max(12.0 * abs(c - 0.5) - 5.0, vec2(0.0));\n return saturate(1.0 - dot(fade, fade));\n}\n\n// based on https://panoskarabelas.com/posts/screen_space_shadows/\nfloat screenSpaceShadow(const in vec3 position, const in vec3 lightDirection, const in float stepLength) {\n // Ray position and direction (in view-space)\n vec3 rayPos = position;\n vec3 rayDir = -lightDirection;\n\n // Compute ray step\n vec3 rayStep = rayDir * stepLength;\n\n // Ray march towards the light\n float occlusion = 0.0;\n vec4 rayCoords = vec4(0.0);\n for (int i = 0; i < dSteps; ++i) {\n // Step the ray\n rayPos += rayStep;\n\n rayCoords = uProjection * vec4(rayPos, 1.0);\n rayCoords.xyz = (rayCoords.xyz / rayCoords.w) * 0.5 + 0.5;\n\n if (outsideBounds(rayCoords.xy))\n return 1.0;\n\n // Compute the difference between the ray's and the camera's depth\n float depth = getDepth(rayCoords.xy);\n float viewZ = getViewZ(depth);\n float zDelta = rayPos.z - viewZ;\n\n if (zDelta < uTolerance) {\n occlusion = 1.0;\n\n // Fade out as we approach the edges of the screen\n occlusion *= screenFade(rayCoords.xy);\n\n break;\n }\n }\n\n return 1.0 - (uBias * occlusion);\n}\n\nvoid main(void) {\n vec2 invTexSize = 1.0 / uTexSize;\n vec2 selfCoords = gl_FragCoord.xy * invTexSize;\n\n float selfDepth = getDepth(selfCoords);\n\n if (isBackground(selfDepth)) {\n gl_FragColor = vec4(0.0);\n return;\n }\n\n vec3 selfViewPos = screenSpaceToViewSpace(vec3(selfCoords, selfDepth), uInvProjection);\n float stepLength = uMaxDistance / float(dSteps);\n\n float o = 1.0;\n #if dLightCount != 0\n float sh[dLightCount];\n #pragma unroll_loop_start\n for (int i = 0; i < dLightCount; ++i) {\n sh[i] = screenSpaceShadow(selfViewPos, uLightDirection[i], stepLength);\n o = min(o, sh[i]);\n }\n #pragma unroll_loop_end\n #endif\n\n gl_FragColor = vec4(o);\n}\n"),o,i),i)}(t,s),this.ssaoFramebuffer=t.resources.framebuffer(),this.ssaoBlurFirstPassFramebuffer=t.resources.framebuffer(),this.ssaoBlurSecondPassFramebuffer=t.resources.framebuffer();const u=Math.floor(a*this.ssaoScale),l=Math.floor(c*this.ssaoScale),d=Math.max(1,Math.floor(.5*u)),f=Math.max(1,Math.floor(.5*l)),p=Math.max(1,Math.floor(.25*u)),m=Math.max(1,Math.floor(.25*l));this.downsampledDepthTarget=r.packedDepth?t.createRenderTarget(u,l,!1,"uint8","linear","rgba"):t.createRenderTarget(u,l,!1,"float32","linear",t.isWebGL2?"alpha":"rgba"),this.downsampleDepthRenderable=Tv(t,s);const h=1===this.ssaoScale?s:this.downsampledDepthTarget.texture;this.depthHalfTarget=r.packedDepth?t.createRenderTarget(d,f,!1,"uint8","linear","rgba"):t.createRenderTarget(d,f,!1,"float32","linear",t.isWebGL2?"alpha":"rgba"),this.depthHalfRenderable=Tv(t,h),this.depthQuarterTarget=r.packedDepth?t.createRenderTarget(p,m,!1,"uint8","linear","rgba"):t.createRenderTarget(p,m,!1,"float32","linear",t.isWebGL2?"alpha":"rgba"),this.depthQuarterRenderable=Tv(t,this.depthHalfTarget.texture),this.ssaoDepthTexture=t.resources.texture("image-uint8","rgba","ubyte","linear"),this.ssaoDepthTexture.define(u,l),this.ssaoDepthTexture.attachFramebuffer(this.ssaoFramebuffer,"color0"),this.ssaoDepthBlurProxyTexture=t.resources.texture("image-uint8","rgba","ubyte","linear"),this.ssaoDepthBlurProxyTexture.define(u,l),this.ssaoDepthBlurProxyTexture.attachFramebuffer(this.ssaoBlurFirstPassFramebuffer,"color0"),this.ssaoDepthTexture.attachFramebuffer(this.ssaoBlurSecondPassFramebuffer,"color0"),this.ssaoRenderable=function ert(e,t,n,r){const i={..._o,tDepth:k.create(t),tDepthHalf:k.create(n),tDepthQuarter:k.create(r),uSamples:k.create(xue(32)),dNSamples:k.create(32),uProjection:k.create(le.identity()),uInvProjection:k.create(le.identity()),uBounds:k.create(nn()),uTexSize:k.create(Me.create(e.gl.drawingBufferWidth,e.gl.drawingBufferHeight)),uRadius:k.create(Math.pow(2,5)),uBias:k.create(.8),dMultiScale:k.create(!1),dLevels:k.create(3),uLevelRadius:k.create([Math.pow(2,2),Math.pow(2,5),Math.pow(2,8)]),uLevelBias:k.create([.8,.8,.8]),uNearThreshold:k.create(10),uFarThreshold:k.create(1500)},o={...Jnt};return ji(zi(e,"triangles",Br("ssao",ps,"\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#include common\n\nuniform sampler2D tDepth;\nuniform sampler2D tDepthHalf;\nuniform sampler2D tDepthQuarter;\nuniform vec2 uTexSize;\nuniform vec4 uBounds;\n\nuniform vec3 uSamples[dNSamples];\n\nuniform mat4 uProjection;\nuniform mat4 uInvProjection;\n\n#ifdef dMultiScale\n uniform float uLevelRadius[dLevels];\n uniform float uLevelBias[dLevels];\n uniform float uNearThreshold;\n uniform float uFarThreshold;\n#else\n uniform float uRadius;\n#endif\nuniform float uBias;\n\nfloat smootherstep(float edge0, float edge1, float x) {\n x = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\n return x * x * x * (x * (x * 6.0 - 15.0) + 10.0);\n}\n\nfloat noise(const in vec2 coords) {\n float a = 12.9898;\n float b = 78.233;\n float c = 43758.5453;\n float dt = dot(coords, vec2(a,b));\n float sn = mod(dt, PI);\n return abs(fract(sin(sn) * c)); // is abs necessary?\n}\n\nvec2 getNoiseVec2(const in vec2 coords) {\n return vec2(noise(coords), noise(coords + vec2(PI, 2.71828)));\n}\n\nbool isBackground(const in float depth) {\n return depth == 1.0;\n}\n\nfloat getDepth(const in vec2 coords) {\n vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w));\n #ifdef depthTextureSupport\n return texture2D(tDepth, c).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepth, c));\n #endif\n}\n\n#define dQuarterThreshold 0.1\n#define dHalfThreshold 0.05\n\nfloat getMappedDepth(const in vec2 coords, const in vec2 selfCoords) {\n vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w));\n float d = distance(coords, selfCoords);\n #ifdef depthTextureSupport\n if (d > dQuarterThreshold) {\n return texture2D(tDepthQuarter, c).r;\n } else if (d > dHalfThreshold) {\n return texture2D(tDepthHalf, c).r;\n } else {\n return texture2D(tDepth, c).r;\n }\n #else\n if (d > dQuarterThreshold) {\n return unpackRGBAToDepth(texture2D(tDepthQuarter, c));\n } else if (d > dHalfThreshold) {\n return unpackRGBAToDepth(texture2D(tDepthHalf, c));\n } else {\n return unpackRGBAToDepth(texture2D(tDepth, c));\n }\n #endif\n}\n\nvec3 normalFromDepth(const in float depth, const in float depth1, const in float depth2, vec2 offset1, vec2 offset2) {\n vec3 p1 = vec3(offset1, depth1 - depth);\n vec3 p2 = vec3(offset2, depth2 - depth);\n\n vec3 normal = cross(p1, p2);\n normal.z = -normal.z;\n\n return normalize(normal);\n}\n\nfloat getPixelSize(const in vec2 coords, const in float depth) {\n vec3 viewPos0 = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection);\n vec3 viewPos1 = screenSpaceToViewSpace(vec3(coords + vec2(1.0, 0.0) / uTexSize, depth), uInvProjection);\n return distance(viewPos0, viewPos1);\n}\n\n// StarCraft II Ambient Occlusion by [Filion and McNaughton 2008]\nvoid main(void) {\n vec2 invTexSize = 1.0 / uTexSize;\n vec2 selfCoords = gl_FragCoord.xy * invTexSize;\n\n float selfDepth = getDepth(selfCoords);\n vec2 selfPackedDepth = packUnitIntervalToRG(selfDepth);\n\n if (isBackground(selfDepth)) {\n gl_FragColor = vec4(packUnitIntervalToRG(1.0), selfPackedDepth);\n return;\n }\n\n vec2 offset1 = vec2(0.0, invTexSize.y);\n vec2 offset2 = vec2(invTexSize.x, 0.0);\n\n float selfDepth1 = getDepth(selfCoords + offset1);\n float selfDepth2 = getDepth(selfCoords + offset2);\n\n vec3 selfViewNormal = normalFromDepth(selfDepth, selfDepth1, selfDepth2, offset1, offset2);\n vec3 selfViewPos = screenSpaceToViewSpace(vec3(selfCoords, selfDepth), uInvProjection);\n\n vec3 randomVec = normalize(vec3(getNoiseVec2(selfCoords) * 2.0 - 1.0, 0.0));\n vec3 tangent = normalize(randomVec - selfViewNormal * dot(randomVec, selfViewNormal));\n vec3 bitangent = cross(selfViewNormal, tangent);\n mat3 TBN = mat3(tangent, bitangent, selfViewNormal);\n\n float occlusion = 0.0;\n #ifdef dMultiScale\n float pixelSize = getPixelSize(selfCoords, selfDepth);\n\n for(int l = 0; l < dLevels; l++) {\n // TODO: smooth transition\n if (pixelSize * uNearThreshold > uLevelRadius[l]) continue;\n if (pixelSize * uFarThreshold < uLevelRadius[l]) continue;\n\n float levelOcclusion = 0.0;\n for(int i = 0; i < dNSamples; i++) {\n vec3 sampleViewPos = TBN * uSamples[i];\n sampleViewPos = selfViewPos + sampleViewPos * uLevelRadius[l];\n\n vec4 offset = vec4(sampleViewPos, 1.0);\n offset = uProjection * offset;\n offset.xyz = (offset.xyz / offset.w) * 0.5 + 0.5;\n\n float sampleDepth = getMappedDepth(offset.xy, selfCoords);\n float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, sampleDepth), uInvProjection).z;\n\n levelOcclusion += step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uLevelRadius[l] / abs(selfViewPos.z - sampleViewZ)) * uLevelBias[l];\n }\n occlusion = max(occlusion, levelOcclusion);\n }\n #else\n for(int i = 0; i < dNSamples; i++) {\n vec3 sampleViewPos = TBN * uSamples[i];\n sampleViewPos = selfViewPos + sampleViewPos * uRadius;\n\n vec4 offset = vec4(sampleViewPos, 1.0);\n offset = uProjection * offset;\n offset.xyz = (offset.xyz / offset.w) * 0.5 + 0.5;\n\n float sampleDepth = getMappedDepth(offset.xy, selfCoords);\n float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, sampleDepth), uInvProjection).z;\n\n occlusion += step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uRadius / abs(selfViewPos.z - sampleViewZ));\n }\n #endif\n occlusion = 1.0 - (uBias * occlusion / float(dNSamples));\n\n vec2 packedOcclusion = packUnitIntervalToRG(clamp(occlusion, 0.01, 1.0));\n\n gl_FragColor = vec4(packedOcclusion, selfPackedDepth);\n}\n"),o,i),i)}(t,h,this.depthHalfTarget.texture,this.depthQuarterTarget.texture),this.ssaoBlurFirstPassRenderable=vue(t,this.ssaoDepthTexture,"horizontal"),this.ssaoBlurSecondPassRenderable=vue(t,this.ssaoDepthBlurProxyTexture,"vertical"),this.renderable=function rrt(e,t,n,r,i,o,s,a){const c={..._o,tSsaoDepth:k.create(s),tColor:k.create(t),tDepthOpaque:k.create(n),tDepthTransparent:k.create(r),tShadows:k.create(i),tOutlines:k.create(o),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight())),dOrthographic:k.create(0),uNear:k.create(1),uFar:k.create(1e4),uFogNear:k.create(1e4),uFogFar:k.create(1e4),uFogColor:k.create(v.create(1,1,1)),uOutlineColor:k.create(v.create(0,0,0)),uOcclusionColor:k.create(v.create(0,0,0)),uTransparentBackground:k.create(!1),dOcclusionEnable:k.create(!0),uOcclusionOffset:k.create(Me.create(0,0)),dShadowEnable:k.create(!1),dOutlineEnable:k.create(!1),dOutlineScale:k.create(1),dTransparentOutline:k.create(a)},u={...nrt};return ji(zi(e,"triangles",Br("postprocessing",ps,"\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tSsaoDepth;\nuniform sampler2D tColor;\nuniform sampler2D tDepthOpaque;\nuniform sampler2D tDepthTransparent;\nuniform sampler2D tShadows;\nuniform sampler2D tOutlines;\nuniform vec2 uTexSize;\n\nuniform float uNear;\nuniform float uFar;\nuniform float uFogNear;\nuniform float uFogFar;\nuniform vec3 uFogColor;\nuniform vec3 uOutlineColor;\nuniform vec3 uOcclusionColor;\nuniform bool uTransparentBackground;\nuniform vec2 uOcclusionOffset;\n\n#include common\n\nfloat getViewZ(const in float depth) {\n #if dOrthographic == 1\n return orthographicDepthToViewZ(depth, uNear, uFar);\n #else\n return perspectiveDepthToViewZ(depth, uNear, uFar);\n #endif\n}\n\nfloat getDepthOpaque(const in vec2 coords) {\n #ifdef depthTextureSupport\n return texture2D(tDepthOpaque, coords).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepthOpaque, coords));\n #endif\n}\n\nfloat getDepthTransparent(const in vec2 coords) {\n #ifdef dTransparentOutline\n return unpackRGBAToDepth(texture2D(tDepthTransparent, coords));\n #else\n return 1.0;\n #endif\n}\n\nbool isBackground(const in float depth) {\n return depth == 1.0;\n}\n\nfloat getOutline(const in vec2 coords, const in float opaqueDepth, out float closestTexel) {\n float backgroundViewZ = 2.0 * uFar;\n vec2 invTexSize = 1.0 / uTexSize;\n\n float transparentDepth = getDepthTransparent(coords);\n float opaqueSelfViewZ = isBackground(opaqueDepth) ? backgroundViewZ : getViewZ(opaqueDepth);\n float transparentSelfViewZ = isBackground(transparentDepth) ? backgroundViewZ : getViewZ(transparentDepth);\n float selfDepth = min(opaqueDepth, transparentDepth);\n\n float outline = 1.0;\n closestTexel = 1.0;\n for (int y = -dOutlineScale; y <= dOutlineScale; y++) {\n for (int x = -dOutlineScale; x <= dOutlineScale; x++) {\n if (x * x + y * y > dOutlineScale * dOutlineScale) {\n continue;\n }\n\n vec2 sampleCoords = coords + vec2(float(x), float(y)) * invTexSize;\n\n vec4 sampleOutlineCombined = texture2D(tOutlines, sampleCoords);\n float sampleOutline = sampleOutlineCombined.r;\n float sampleOutlineDepth = unpackRGToUnitInterval(sampleOutlineCombined.gb);\n float sampleOutlineViewZ = isBackground(sampleOutlineDepth) ? backgroundViewZ : getViewZ(sampleOutlineDepth);\n\n float selfViewZ = sampleOutlineCombined.a == 0.0 ? opaqueSelfViewZ : transparentSelfViewZ;\n if (sampleOutline == 0.0 && sampleOutlineDepth < closestTexel) {\n outline = 0.0;\n closestTexel = sampleOutlineDepth;\n }\n }\n }\n return closestTexel < opaqueDepth ? outline : 1.0;\n}\n\nfloat getSsao(vec2 coords) {\n float rawSsao = unpackRGToUnitInterval(texture2D(tSsaoDepth, coords).xy);\n if (rawSsao > 0.999) {\n return 1.0;\n } else if (rawSsao > 0.001) {\n return rawSsao;\n }\n // treat values close to 0.0 as errors and return no occlusion\n return 1.0;\n}\n\nvoid main(void) {\n vec2 coords = gl_FragCoord.xy / uTexSize;\n vec4 color = texture2D(tColor, coords);\n\n float viewDist;\n float fogFactor;\n float opaqueDepth = getDepthOpaque(coords);\n\n #ifdef dOcclusionEnable\n if (!isBackground(opaqueDepth)) {\n viewDist = abs(getViewZ(opaqueDepth));\n fogFactor = smoothstep(uFogNear, uFogFar, viewDist);\n float occlusionFactor = getSsao(coords + uOcclusionOffset);\n if (!uTransparentBackground) {\n color.rgb = mix(mix(uOcclusionColor, uFogColor, fogFactor), color.rgb, occlusionFactor);\n } else {\n color.rgb = mix(uOcclusionColor * (1.0 - fogFactor), color.rgb, occlusionFactor);\n }\n }\n #endif\n\n #ifdef dShadowEnable\n if (!isBackground(opaqueDepth)) {\n viewDist = abs(getViewZ(opaqueDepth));\n fogFactor = smoothstep(uFogNear, uFogFar, viewDist);\n vec4 shadow = texture2D(tShadows, coords);\n if (!uTransparentBackground) {\n color.rgb = mix(mix(vec3(0), uFogColor, fogFactor), color.rgb, shadow.a);\n } else {\n color.rgb = mix(vec3(0) * (1.0 - fogFactor), color.rgb, shadow.a);\n }\n }\n #endif\n\n // outline needs to be handled after occlusion and shadow to keep them clean\n #ifdef dOutlineEnable\n float closestTexel;\n float outline = getOutline(coords, opaqueDepth, closestTexel);\n if (outline == 0.0) {\n viewDist = abs(getViewZ(closestTexel));\n fogFactor = smoothstep(uFogNear, uFogFar, viewDist);\n if (!uTransparentBackground) {\n color.rgb = mix(uOutlineColor, uFogColor, fogFactor);\n } else {\n color.a = 1.0 - fogFactor;\n color.rgb = mix(uOutlineColor, color.rgb, fogFactor);\n }\n }\n #endif\n\n gl_FragColor = color;\n}\n"),u,c),c)}(t,i.texture,s,o,this.shadowsTarget.texture,this.outlinesTarget.texture,this.ssaoDepthTexture,!0),this.background=new Rnt(t,n,a,c)}setSize(t,n){const[r,i]=this.renderable.values.uTexSize.ref.value,o=this.calcSsaoScale(1);if(t!==r||n!==i||this.ssaoScale!==o){this.ssaoScale=o,this.target.setSize(t,n),this.outlinesTarget.setSize(t,n),this.shadowsTarget.setSize(t,n);const s=Math.floor(t*this.ssaoScale),a=Math.floor(n*this.ssaoScale);this.downsampledDepthTarget.setSize(s,a),this.ssaoDepthTexture.define(s,a),this.ssaoDepthBlurProxyTexture.define(s,a);const c=Math.max(1,Math.floor(.5*s)),u=Math.max(1,Math.floor(.5*a));this.depthHalfTarget.setSize(c,u);const l=Math.max(1,Math.floor(.25*s)),d=Math.max(1,Math.floor(.25*a));this.depthQuarterTarget.setSize(l,d),k.update(this.renderable.values.uTexSize,Me.set(this.renderable.values.uTexSize.ref.value,t,n)),k.update(this.outlinesRenderable.values.uTexSize,Me.set(this.outlinesRenderable.values.uTexSize.ref.value,t,n)),k.update(this.shadowsRenderable.values.uTexSize,Me.set(this.shadowsRenderable.values.uTexSize.ref.value,t,n)),k.update(this.downsampleDepthRenderable.values.uTexSize,Me.set(this.downsampleDepthRenderable.values.uTexSize.ref.value,s,a)),k.update(this.depthHalfRenderable.values.uTexSize,Me.set(this.depthHalfRenderable.values.uTexSize.ref.value,c,u)),k.update(this.depthQuarterRenderable.values.uTexSize,Me.set(this.depthQuarterRenderable.values.uTexSize.ref.value,l,d)),k.update(this.ssaoRenderable.values.uTexSize,Me.set(this.ssaoRenderable.values.uTexSize.ref.value,s,a)),k.update(this.ssaoBlurFirstPassRenderable.values.uTexSize,Me.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value,s,a)),k.update(this.ssaoBlurSecondPassRenderable.values.uTexSize,Me.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value,s,a));const f=1===this.ssaoScale?this.drawPass.depthTextureOpaque:this.downsampledDepthTarget.texture;k.update(this.depthHalfRenderable.values.tColor,f),k.update(this.ssaoRenderable.values.tDepth,f),this.depthHalfRenderable.update(),this.ssaoRenderable.update(),this.background.setSize(t,n)}}updateState(t,n,r,i,o){var s;let a=!1,c=!1,u=!1,l=!1,d=!1,f=!1;const p="orthographic"===t.state.mode?1:0,m="on"===i.outline.name,h="on"===i.shadow.name,g="on"===i.occlusion.name,y=le.identity();le.invert(y,t.projection);const[b,x]=this.renderable.values.uTexSize.ref.value,_=t.viewport;if("on"===i.occlusion.name){k.update(this.ssaoRenderable.values.uProjection,t.projection),k.update(this.ssaoRenderable.values.uInvProjection,y);const E=this.ssaoRenderable.values.uBounds,w=this.ssaoScale;nn.set(E.ref.value,Math.floor(_.x*w)/(b*w),Math.floor(_.y*w)/(x*w),Math.ceil((_.x+_.width)*w)/(b*w),Math.ceil((_.y+_.height)*w)/(x*w)),k.update(E,E.ref.value),k.update(this.ssaoBlurFirstPassRenderable.values.uBounds,E.ref.value),k.update(this.ssaoBlurSecondPassRenderable.values.uBounds,E.ref.value),k.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uNear,t.near),k.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uNear,t.near),k.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uFar,t.far),k.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uFar,t.far),k.update(this.ssaoBlurFirstPassRenderable.values.uInvProjection,y),k.update(this.ssaoBlurSecondPassRenderable.values.uInvProjection,y),this.ssaoBlurFirstPassRenderable.values.dOrthographic.ref.value!==p&&(l=!0,k.update(this.ssaoBlurFirstPassRenderable.values.dOrthographic,p),k.update(this.ssaoBlurSecondPassRenderable.values.dOrthographic,p)),this.nSamples!==i.occlusion.params.samples&&(u=!0,this.nSamples=i.occlusion.params.samples,k.update(this.ssaoRenderable.values.uSamples,xue(this.nSamples)),k.updateIfChanged(this.ssaoRenderable.values.dNSamples,this.nSamples));const D="on"===i.occlusion.params.multiScale.name;if(this.ssaoRenderable.values.dMultiScale.ref.value!==D&&(u=!0,k.update(this.ssaoRenderable.values.dMultiScale,D)),"on"===i.occlusion.params.multiScale.name){const R=i.occlusion.params.multiScale.params;if(!Yd(this.levels,R.levels)){u=!0,this.levels=R.levels;const T=function irt(e,t){const n=e.length,{radius:r,bias:i}=t||{radius:new Array(3*n).fill(0),bias:new Array(3*n).fill(0)};e=e.slice().sort((o,s)=>o.radius-s.radius);for(let o=0;o=p.length)return-2;const{x:m,y:h,width:g,height:y}=o.viewport,b=1/p.length;if(-1===t)u.render(n,r,!1),k.update(s.values.uWeight,1),k.update(s.values.tColor,u.getColorTarget(r.postprocessing).texture),s.update(),c.bind(),f.disable(d.BLEND),f.disable(d.DEPTH_TEST),f.depthMask(!1),f.viewport(m,h,g,y),f.scissor(m,h,g,y),s.render(),t+=1;else{o.viewOffset.enabled=!0,k.update(s.values.tColor,u.getColorTarget(r.postprocessing).texture),k.update(s.values.uWeight,b),s.update();const _=Math.pow(2,Math.max(0,r.multiSample.sampleLevel-2));for(let S=0;S<_;++S){const A=p[t];if(gr.setViewOffset(o.viewOffset,g,y,A[0],A[1],g,y),o.update(),0===t?u.postprocessing.setOcclusionOffset(0,0):u.postprocessing.setOcclusionOffset(A[0]/g,A[1]/y),u.render(n,r,!1),a.bind(),f.enable(d.BLEND),f.blendEquationSeparate(d.FUNC_ADD,d.FUNC_ADD),f.blendFuncSeparate(d.ONE,d.ONE,d.ONE,d.ONE),f.disable(d.DEPTH_TEST),f.depthMask(!1),f.viewport(m,h,g,y),f.scissor(m,h,g,y),0===t&&(f.clearColor(0,0,0,0),d.clear(d.COLOR_BUFFER_BIT)),s.render(),(t+=1)>=p.length)break}}u.postprocessing.setOcclusionOffset(0,0),this.bindOutputTarget(i),f.viewport(m,h,g,y),f.scissor(m,h,g,y);const x=t*b;return x>0&&(k.update(s.values.uWeight,1),k.update(s.values.tColor,a.texture),s.update(),f.disable(d.BLEND),s.render()),x<1&&(k.update(s.values.uWeight,1-x),k.update(s.values.tColor,c.texture),s.update(),0===x?f.disable(d.BLEND):f.enable(d.BLEND),s.render()),o.viewOffset.enabled=!1,o.update(),lt&&l.timer.markEnd("MultiSamplePass.renderTemporalMultiSample"),t>=p.length?-2:t}}const k8=[[[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]]];k8.forEach(e=>{e.forEach(t=>{t[0]*=.0625,t[1]*=.0625})});class wue{update(t,n){return t&&(this.sampleIndex=-1),"temporal"===n.mode&&-2!==this.sampleIndex}render(t,n,r,i){return this.sampleIndex=this.multiSamplePass.render(this.sampleIndex,t,n,r,!!i),this.sampleIndex<0}constructor(t){this.multiSamplePass=t,this.sampleIndex=-2}}const Aue={eyeSeparation:C.Numeric(.062,{min:.02,max:.1,step:.001},{description:"Distance between left and right camera."}),focus:C.Numeric(10,{min:1,max:20,step:.1},{description:"Apparent object distance."})},urt=C.getDefaultValues(Aue);class Xv{get viewport(){return this.parent.viewport}get viewOffset(){return this.parent.viewOffset}constructor(t,n={}){this.parent=t,this.left=new Iue,this.right=new Iue,this.props={...urt,...n}}setProps(t){Object.assign(this.props,t)}update(){this.parent.update(),function lrt(e,t,n,r){Lo.copy(n.viewport,e.viewport),le.copy(n.view,e.view),le.copy(n.projection,e.projection),gr.copySnapshot(n.state,e.state),gr.copyViewOffset(n.viewOffset,e.viewOffset),n.far=e.far,n.near=e.near,n.fogFar=e.fogFar,n.fogNear=e.fogNear,Lo.copy(r.viewport,e.viewport),le.copy(r.view,e.view),le.copy(r.projection,e.projection),gr.copySnapshot(r.state,e.state),gr.copyViewOffset(r.viewOffset,e.viewOffset),r.far=e.far,r.near=e.near,r.fogFar=e.fogFar,r.fogNear=e.fogNear;const i=Math.floor(e.viewport.width/2),o=i/e.viewport.height;n.viewport.width=i,r.viewport.x+=i,r.viewport.width-=i;const s=t.eyeSeparation/2,a=s*e.near/t.focus,c=e.near*Math.tan(.5*e.state.fov);let u,l;Tue[12]=-s,Due[12]=s,u=-c*o+a,l=c*o+a,n.projection[0]=2*e.near/(l-u),n.projection[8]=(l+u)/(l-u),le.mul(n.view,n.view,Tue),le.mul(n.projectionView,n.projection,n.view),le.invert(n.inverseProjectionView,n.projectionView),u=-c*o-a,l=c*o-a,r.projection[0]=2*e.near/(l-u),r.projection[8]=(l+u)/(l-u),le.mul(r.view,r.view,Due),le.mul(r.projectionView,r.projection,r.view),le.invert(r.inverseProjectionView,r.projectionView)}(this.parent,this.props,this.left,this.right)}}!function(e){e.is=function t(n){return"left"in n&&"right"in n}}(Xv||(Xv={}));class Iue{constructor(){this.viewport=Lo.create(0,0,0,0),this.view=le(),this.projection=le(),this.projectionView=le(),this.inverseProjectionView=le(),this.state=gr.createDefaultSnapshot(),this.viewOffset=gr.ViewOffset(),this.far=0,this.near=0,this.fogFar=0,this.fogNear=0}}const Tue=le.identity(),Due=le.identity(),N8=Math.pow(2,24)-2;class drt{constructor(t,n,r){this.webgl=t,this.drawPass=n,this.pickScale=r;const i=r/t.pixelRatio;this.pickWidth=Math.ceil(n.colorTarget.getWidth()*i),this.pickHeight=Math.ceil(n.colorTarget.getHeight()*i);const{resources:o,extensions:{drawBuffers:s},gl:a}=t;s?(this.objectPickTexture=o.texture("image-uint8","rgba","ubyte","nearest"),this.objectPickTexture.define(this.pickWidth,this.pickHeight),this.instancePickTexture=o.texture("image-uint8","rgba","ubyte","nearest"),this.instancePickTexture.define(this.pickWidth,this.pickHeight),this.groupPickTexture=o.texture("image-uint8","rgba","ubyte","nearest"),this.groupPickTexture.define(this.pickWidth,this.pickHeight),this.depthPickTexture=o.texture("image-uint8","rgba","ubyte","nearest"),this.depthPickTexture.define(this.pickWidth,this.pickHeight),this.framebuffer=o.framebuffer(),this.objectPickFramebuffer=o.framebuffer(),this.instancePickFramebuffer=o.framebuffer(),this.groupPickFramebuffer=o.framebuffer(),this.depthPickFramebuffer=o.framebuffer(),this.framebuffer.bind(),s.drawBuffers([s.COLOR_ATTACHMENT0,s.COLOR_ATTACHMENT1,s.COLOR_ATTACHMENT2,s.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=Wt(a)?o.renderbuffer("depth32f","depth",this.pickWidth,this.pickHeight):o.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))}get pickRatio(){return this.pickScale/this.webgl.pixelRatio}setPickScale(t){this.pickScale=t,this.syncSize()}bindObject(){this.webgl.extensions.drawBuffers?this.objectPickFramebuffer.bind():this.objectPickTarget.bind()}bindInstance(){this.webgl.extensions.drawBuffers?this.instancePickFramebuffer.bind():this.instancePickTarget.bind()}bindGroup(){this.webgl.extensions.drawBuffers?this.groupPickFramebuffer.bind():this.groupPickTarget.bind()}bindDepth(){this.webgl.extensions.drawBuffers?this.depthPickFramebuffer.bind():this.depthPickTarget.bind()}get drawingBufferHeight(){return this.drawPass.colorTarget.getHeight()}syncSize(){const t=this.pickScale/this.webgl.pixelRatio,n=Math.ceil(this.drawPass.colorTarget.getWidth()*t),r=Math.ceil(this.drawPass.colorTarget.getHeight()*t);(n!==this.pickWidth||r!==this.pickHeight)&&(this.pickWidth=n,this.pickHeight=r,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)))}renderVariant(t,n,r,i,o,s){t.clear(!1),t.update(n,r),t.renderPick(r.primitives,n,o,null,s),i.handle.isEnabled&&t.renderPick(i.handle.scene,n,o,null,s),i.camera.isEnabled&&(i.camera.update(n),t.update(i.camera.camera,i.camera.scene),t.renderPick(i.camera.scene,i.camera.camera,o,null,s))}render(t,n,r,i){this.webgl.extensions.drawBuffers?(this.framebuffer.bind(),this.renderVariant(t,n,r,i,"pick",D0.None)):(this.objectPickTarget.bind(),this.renderVariant(t,n,r,i,"pick",D0.Object),this.instancePickTarget.bind(),this.renderVariant(t,n,r,i,"pick",D0.Instance),this.groupPickTarget.bind(),this.renderVariant(t,n,r,i,"pick",D0.Group),this.depthPickTarget.bind(),this.renderVariant(t,n,r,i,"depth",D0.None))}}class frt{setupBuffers(){const 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))}setViewport(t,n,r,i){Lo.set(this.viewport,t,n,r,i),this.pickRatio=this.pickPass.pickRatio,this.pickX=Math.ceil(t*this.pickRatio),this.pickY=Math.ceil(n*this.pickRatio);const o=Math.floor(r*this.pickRatio),s=Math.floor(i*this.pickRatio);(o!==this.pickWidth||s!==this.pickHeight)&&(this.pickWidth=o,this.pickHeight=s,this.halfPickWidth=Math.floor(this.pickWidth/2),this.setupBuffers()),this.spiral=function rMe(e){let t=0,n=0;const r=[0,-1],i=2*e+1,o=i/2,s=[];for(let a=Math.pow(i,2);a>0;--a)-o0&&t===1-n)&&([r[0],r[1]]=[-r[1],r[0]]),t+=r[0],n+=r[1];return s}(Math.round(this.pickRatio*this.pickPadding))}syncBuffers(){lt&&this.webgl.timer.mark("PickHelper.syncBuffers");const{pickX:t,pickY:n,pickWidth:r,pickHeight:i}=this;this.pickPass.bindObject(),this.webgl.readPixels(t,n,r,i,this.objectBuffer),this.pickPass.bindInstance(),this.webgl.readPixels(t,n,r,i,this.instanceBuffer),this.pickPass.bindGroup(),this.webgl.readPixels(t,n,r,i,this.groupBuffer),this.pickPass.bindDepth(),this.webgl.readPixels(t,n,r,i,this.depthBuffer),lt&&this.webgl.timer.markEnd("PickHelper.syncBuffers")}getBufferIdx(t,n){return 4*(n*this.pickWidth+t)}getDepth(t,n){const r=this.getBufferIdx(t,n),i=this.depthBuffer;return function SHe(e,t,n,r){return nn.set(Rie,e/255,t/255,n/255,r/255),nn.dot(Rie,xHe)}(i[r],i[r+1],i[r+2],i[r+3])}getId(t,n,r){const i=this.getBufferIdx(t,n);return m5(r[i],r[i+1],r[i+2])}render(t){lt&&this.webgl.timer.mark("PickHelper.render",!0);const{pickX:n,pickY:r,pickWidth:i,pickHeight:o,halfPickWidth:s}=this,{renderer:a,scene:c,helper:u}=this;a.setTransparentBackground(!1),a.setDrawingBufferSize(i,o),a.setPixelRatio(this.pickRatio),Xv.is(t)?(a.setViewport(n,r,s,o),this.pickPass.render(a,t.left,c,u),a.setViewport(n+s,r,i-s,o),this.pickPass.render(a,t.right,c,u)):(a.setViewport(n,r,i,o),this.pickPass.render(a,t,c,u)),this.dirty=!1,lt&&this.webgl.timer.markEnd("PickHelper.render")}identifyInternal(t,n,r){const{webgl:i,pickRatio:o}=this;if(i.isContextLost)return;t*=i.pixelRatio,n=this.pickPass.drawingBufferHeight-(n*=i.pixelRatio);const{viewport:s}=this;if(ts.x+s.width||n>s.y+s.height)return;this.dirty&&(lt&&this.webgl.timer.mark("PickHelper.identify"),this.render(r),this.syncBuffers(),lt&&this.webgl.timer.markEnd("PickHelper.identify"));const a=t-s.x,c=n-s.y,u=Math.floor(a*o),l=Math.floor(c*o),d=this.getId(u,l,this.objectBuffer);if(-1===d||d===N8)return;const f=this.getId(u,l,this.instanceBuffer);if(-1===f||f===N8)return;const p=this.getId(u,l,this.groupBuffer);if(-1===p||p===N8)return;const m=this.getDepth(u,l),h=v.create(t,n,m);if(Xv.is(r)){const g=Math.floor(s.width/2);t>s.x+g?(h[0]=s.x+2*(a-g),vE(h,h,s,r.right.inverseProjectionView)):(h[0]=s.x+2*a,vE(h,h,s,r.left.inverseProjectionView))}else vE(h,h,s,r.inverseProjectionView);return{id:{objectId:d,instanceId:f,groupId:p},position:h}}identify(t,n,r){for(const i of this.spiral){const o=this.identifyInternal(t+i[0],n+i[1],r);if(o)return o}}constructor(t,n,r,i,o,s,a=1){this.webgl=t,this.renderer=n,this.scene=r,this.helper=i,this.pickPass=o,this.pickPadding=a,this.dirty=!0,this.viewport=Lo(),this.setViewport(s.x,s.y,s.width,s.height)}}const hrt={...vo,tWboitA:jt("texture","rgba","float","nearest"),tWboitB:jt("texture","rgba","float","nearest"),uTexSize:xe("v2")},mrt=Br("evaluate-wboit",ps,"\nprecision highp float;\n\nuniform sampler2D tWboitA;\nuniform sampler2D tWboitB;\nuniform vec2 uTexSize;\n\nvoid main() {\n vec2 coords = gl_FragCoord.xy / uTexSize;\n\n vec4 accum = texture2D(tWboitA, coords);\n float r = 1.0 - accum.a;\n\n accum.a = texture2D(tWboitB, coords).r;\n // divisor needs to allow very small values for nice fading\n gl_FragColor = vec4(accum.rgb / clamp(accum.a, 0.00000001, 50000.0), r);\n}\n");class F8{get supported(){return this._supported}bind(){const{state:t,gl:n}=this.webgl;this.framebuffer.bind(),t.clearColor(0,0,0,1),n.clear(n.COLOR_BUFFER_BIT),t.disable(n.DEPTH_TEST),t.blendFuncSeparate(n.ONE,n.ONE,n.ZERO,n.ONE_MINUS_SRC_ALPHA),t.enable(n.BLEND)}render(){lt&&this.webgl.timer.mark("WboitPass.render");const{state:t,gl:n}=this.webgl;t.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA),t.enable(n.BLEND),this.renderable.update(),this.renderable.render(),lt&&this.webgl.timer.markEnd("WboitPass.render")}setSize(t,n){const[r,i]=this.renderable.values.uTexSize.ref.value;(t!==r||n!==i)&&(this.textureA.define(t,n),this.textureB.define(t,n),this.depthRenderbuffer.setSize(t,n),k.update(this.renderable.values.uTexSize,Me.set(this.renderable.values.uTexSize.ref.value,t,n)))}reset(){this._supported&&this._init()}_init(){const{extensions:{drawBuffers:t}}=this.webgl;this.framebuffer.bind(),t.drawBuffers([t.COLOR_ATTACHMENT0,t.COLOR_ATTACHMENT1]),this.textureA.attachFramebuffer(this.framebuffer,"color0"),this.textureB.attachFramebuffer(this.framebuffer,"color1"),this.depthRenderbuffer.attachFramebuffer(this.framebuffer)}static isSupported(t){const{extensions:{drawBuffers:n,textureFloat:r,colorBufferFloat:i,depthTexture:o}}=t;if(r&&i&&o&&n)return!0;if(un){const s=[];r||s.push("textureFloat"),i||s.push("colorBufferFloat"),o||s.push("depthTexture"),n||s.push("drawBuffers"),console.log(`Missing "${s.join('", "')}" extensions required for "wboit"`)}return!1}constructor(t,n,r){if(this.webgl=t,this._supported=!1,!F8.isSupported(t))return;const{resources:i,gl:o}=t;this.textureA=i.texture("image-float32","rgba","float","nearest"),this.textureA.define(n,r),this.textureB=i.texture("image-float32","rgba","float","nearest"),this.textureB.define(n,r),this.depthRenderbuffer=Wt(o)?i.renderbuffer("depth32f","depth",n,r):i.renderbuffer("depth16","depth",n,r),this.renderable=function grt(e,t,n){const r={..._o,tWboitA:k.create(t),tWboitB:k.create(n),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight()))},i={...hrt};return ji(zi(e,"triangles",mrt,i,r),r)}(t,this.textureA,this.textureB),this.framebuffer=i.framebuffer(),this._supported=!0,this._init()}}const vrt={...vo,tDpoitBackColor:jt("texture","rgba","float","nearest"),uTexSize:xe("v2")},_rt=Br("blend-back-dpoit",ps,"\n precision highp float;\n\n uniform sampler2D tDpoitBackColor;\n uniform vec2 uTexSize;\n\n void main() {\n vec2 coords = gl_FragCoord.xy / uTexSize;\n gl_FragColor = texture2D(tDpoitBackColor, coords);\n if (gl_FragColor.a == 0.0) {\n discard;\n }\n }\n"),Srt={...vo,tDpoitFrontColor:jt("texture","rgba","float","nearest"),uTexSize:xe("v2")},Crt=Br("evaluate-dpoit",ps,"\nprecision highp float;\n\nuniform sampler2D tDpoitFrontColor;\nuniform vec2 uTexSize;\n\nvoid main() {\n vec2 coords = gl_FragCoord.xy / uTexSize;\n gl_FragColor = texture2D(tDpoitFrontColor, coords);\n}\n");class B8{get supported(){return this._supported}bind(){const{state:t,gl:n,extensions:{blendMinMax:r}}=this.webgl;return this.passCount=0,this.depthFramebuffers[0].bind(),t.clearColor(this.DEPTH_CLEAR_VALUE,this.DEPTH_CLEAR_VALUE,0,0),n.clear(n.COLOR_BUFFER_BIT),this.depthFramebuffers[1].bind(),t.clearColor(-this.MIN_DEPTH,this.MAX_DEPTH,0,0),n.clear(n.COLOR_BUFFER_BIT),this.colorFramebuffers[0].bind(),t.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),this.colorFramebuffers[1].bind(),t.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),this.depthFramebuffers[0].bind(),t.blendEquation(r.MAX),t.depthMask(!1),{depth:this.depthTextures[1],frontColor:this.colorFrontTextures[1],backColor:this.colorBackTextures[1]}}bindDualDepthPeeling(){const{state:t,gl:n,extensions:{blendMinMax:r}}=this.webgl;return this.readId=this.passCount%2,this.writeId=1-this.readId,this.passCount+=1,this.depthFramebuffers[this.writeId].bind(),t.clearColor(this.DEPTH_CLEAR_VALUE,this.DEPTH_CLEAR_VALUE,0,0),n.clear(n.COLOR_BUFFER_BIT),this.colorFramebuffers[this.writeId].bind(),t.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),this.depthFramebuffers[this.writeId].bind(),t.blendEquation(r.MAX),t.depthMask(!1),{depth:this.depthTextures[this.readId],frontColor:this.colorFrontTextures[this.readId],backColor:this.colorBackTextures[this.readId]}}renderBlendBack(){lt&&this.webgl.timer.mark("DpoitPass.renderBlendBack");const{state:t,gl:n}=this.webgl;t.blendEquation(n.FUNC_ADD),t.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA),k.update(this.blendBackRenderable.values.tDpoitBackColor,this.colorBackTextures[this.writeId]),this.blendBackRenderable.update(),this.blendBackRenderable.render(),lt&&this.webgl.timer.markEnd("DpoitPass.renderBlendBack")}render(){lt&&this.webgl.timer.mark("DpoitPass.render");const{state:t,gl:n}=this.webgl;t.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA),k.update(this.renderable.values.tDpoitFrontColor,this.colorFrontTextures[this.writeId]),this.renderable.update(),this.renderable.render(),lt&&this.webgl.timer.markEnd("DpoitPass.render")}setSize(t,n){const[r,i]=this.renderable.values.uTexSize.ref.value;if(t!==r||n!==i){for(let o=0;o<2;o++)this.depthTextures[o].define(t,n),this.colorFrontTextures[o].define(t,n),this.colorBackTextures[o].define(t,n);k.update(this.renderable.values.uTexSize,Me.set(this.renderable.values.uTexSize.ref.value,t,n)),k.update(this.blendBackRenderable.values.uTexSize,Me.set(this.blendBackRenderable.values.uTexSize.ref.value,t,n))}}reset(){this._supported&&this._init()}_init(){const{extensions:{drawBuffers:t}}=this.webgl;for(let n=0;n<2;n++)this.depthFramebuffers[n].bind(),t.drawBuffers([t.COLOR_ATTACHMENT0,t.COLOR_ATTACHMENT1,t.COLOR_ATTACHMENT2]),this.colorFrontTextures[n].attachFramebuffer(this.depthFramebuffers[n],"color0"),this.colorBackTextures[n].attachFramebuffer(this.depthFramebuffers[n],"color1"),this.depthTextures[n].attachFramebuffer(this.depthFramebuffers[n],"color2"),this.colorFramebuffers[n].bind(),t.drawBuffers([t.COLOR_ATTACHMENT0,t.COLOR_ATTACHMENT1]),this.colorFrontTextures[n].attachFramebuffer(this.colorFramebuffers[n],"color0"),this.colorBackTextures[n].attachFramebuffer(this.colorFramebuffers[n],"color1")}static isSupported(t){const{extensions:{drawBuffers:n,textureFloat:r,colorBufferFloat:i,blendMinMax:o}}=t;if(r&&i&&n&&o)return!0;if(un){const s=[];r||s.push("textureFloat"),i||s.push("colorBufferFloat"),n||s.push("drawBuffers"),o||s.push("blendMinMax"),console.log(`Missing "${s.join('", "')}" extensions required for "dpoit"`)}return!1}constructor(t,n,r){if(this.webgl=t,this.DEPTH_CLEAR_VALUE=-99999,this.MAX_DEPTH=1,this.MIN_DEPTH=0,this.passCount=0,this._supported=!1,!B8.isSupported(t))return;const{resources:i,extensions:{colorBufferHalfFloat:o,textureHalfFloat:s}}=t;Wt(t.gl)?(this.depthTextures=[i.texture("image-float32","rg","float","nearest"),i.texture("image-float32","rg","float","nearest")],this.colorFrontTextures=o&&s?[i.texture("image-float16","rgba","fp16","nearest"),i.texture("image-float16","rgba","fp16","nearest")]:[i.texture("image-float32","rgba","float","nearest"),i.texture("image-float32","rgba","float","nearest")],this.colorBackTextures=o&&s?[i.texture("image-float16","rgba","fp16","nearest"),i.texture("image-float16","rgba","fp16","nearest")]:[i.texture("image-float32","rgba","float","nearest"),i.texture("image-float32","rgba","float","nearest")]):(this.depthTextures=[i.texture("image-float32","rgba","float","nearest"),i.texture("image-float32","rgba","float","nearest")],this.colorFrontTextures=[i.texture("image-float32","rgba","float","nearest"),i.texture("image-float32","rgba","float","nearest")],this.colorBackTextures=[i.texture("image-float32","rgba","float","nearest"),i.texture("image-float32","rgba","float","nearest")]),this.depthTextures[0].define(n,r),this.depthTextures[1].define(n,r),this.colorFrontTextures[0].define(n,r),this.colorFrontTextures[1].define(n,r),this.colorBackTextures[0].define(n,r),this.colorBackTextures[1].define(n,r),this.depthFramebuffers=[i.framebuffer(),i.framebuffer()],this.colorFramebuffers=[i.framebuffer(),i.framebuffer()],this.blendBackRenderable=function xrt(e,t){const n={..._o,tDpoitBackColor:k.create(t),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight()))},r={...vrt};return ji(zi(e,"triangles",_rt,r,n),n)}(t,this.colorBackTextures[0]),this.renderable=function wrt(e,t){const n={..._o,tDpoitFrontColor:k.create(t),uTexSize:k.create(Me.create(t.getWidth(),t.getHeight()))},r={...Srt};return ji(zi(e,"triangles",Crt,r,n),n)}(t,this.colorFrontTextures[0]),this._supported=!0,this._init()}}const Eue={enabled:C.Boolean(!0),highlightEdgeColor:C.Color(st.darken(st.fromNormalizedRgb(1,.4,.6),1)),selectEdgeColor:C.Color(st.darken(st.fromNormalizedRgb(.2,1,.1),1)),edgeScale:C.Numeric(1,{min:1,max:3,step:1},{description:"Thickness of the edge."}),highlightEdgeStrength:C.Numeric(1,{min:0,max:1,step:.1}),selectEdgeStrength:C.Numeric(1,{min:0,max:1,step:.1}),ghostEdgeStrength:C.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:C.Numeric(1.5,{min:0,max:3,step:.1},{description:"Factor to multiply the inner edge color with - for added contrast."})};class Pue{static isEnabled(t){return t.enabled}constructor(t,n,r){this.webgl=t,this.depthTarget=t.createRenderTarget(n,r),this.maskTarget=t.createRenderTarget(n,r),this.edgesTarget=t.createRenderTarget(n,r),this.edge=function Ert(e,t){const n=t.getWidth(),r=t.getHeight(),i={..._o,tMaskTexture:k.create(t),uTexSizeInv:k.create(Me.create(1/n,1/r)),dEdgeScale:k.create(1)},o={...Trt};return ji(zi(e,"triangles",Drt,o,i),i)}(t,this.maskTarget.texture),this.overlay=function Rrt(e,t){const n=t.getWidth(),r=t.getHeight(),i={..._o,tEdgeTexture:k.create(t),uTexSizeInv:k.create(Me.create(1/n,1/r)),uHighlightEdgeColor:k.create(v()),uSelectEdgeColor:k.create(v()),uHighlightEdgeStrength:k.create(1),uSelectEdgeStrength:k.create(1),uGhostEdgeStrength:k.create(0),uInnerEdgeFactor:k.create(0)},o={...Prt};return ji(zi(e,"triangles",Mrt,o,i),i)}(t,this.edgesTarget.texture)}setEdgeState(t){const{gl:n,state:r}=this.webgl;r.enable(n.SCISSOR_TEST),r.enable(n.BLEND),r.blendFunc(n.ONE,n.ONE),r.blendEquation(n.FUNC_ADD),r.disable(n.DEPTH_TEST),r.depthMask(!1);const{x:i,y:o,width:s,height:a}=t;r.viewport(i,o,s,a),r.scissor(i,o,s,a),r.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT)}setOverlayState(t){const{gl:n,state:r}=this.webgl;r.enable(n.SCISSOR_TEST),r.enable(n.BLEND),r.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),r.blendEquation(n.FUNC_ADD),r.disable(n.DEPTH_TEST),r.depthMask(!1);const{x:i,y:o,width:s,height:a}=t;r.viewport(i,o,s,a),r.scissor(i,o,s,a)}setSize(t,n){const r=this.depthTarget.getWidth(),i=this.depthTarget.getHeight();(t!==r||n!==i)&&(this.depthTarget.setSize(t,n),this.maskTarget.setSize(t,n),this.edgesTarget.setSize(t,n),k.update(this.edge.values.uTexSizeInv,Me.set(this.edge.values.uTexSizeInv.ref.value,1/t,1/n)),k.update(this.overlay.values.uTexSizeInv,Me.set(this.overlay.values.uTexSizeInv.ref.value,1/t,1/n)))}update(t){const{highlightEdgeColor:n,selectEdgeColor:r,edgeScale:i,innerEdgeFactor:o,ghostEdgeStrength:s,highlightEdgeStrength:a,selectEdgeStrength:c}=t,{values:u}=this.edge,l=Math.max(1,Math.round(i*this.webgl.pixelRatio));u.dEdgeScale.ref.value!==l&&(k.update(u.dEdgeScale,l),this.edge.update());const{values:d}=this.overlay;k.update(d.uHighlightEdgeColor,st.toVec3Normalized(d.uHighlightEdgeColor.ref.value,n)),k.update(d.uSelectEdgeColor,st.toVec3Normalized(d.uSelectEdgeColor.ref.value,r)),k.updateIfChanged(d.uInnerEdgeFactor,o),k.updateIfChanged(d.uGhostEdgeStrength,s),k.updateIfChanged(d.uHighlightEdgeStrength,a),k.updateIfChanged(d.uSelectEdgeStrength,c)}render(t,n){lt&&this.webgl.timer.mark("MarkingPass.render"),this.edgesTarget.bind(),this.setEdgeState(t),this.edge.render(),n?n.bind():this.webgl.unbindFramebuffer(),this.setOverlayState(t),this.overlay.render(),lt&&this.webgl.timer.markEnd("MarkingPass.render")}}const Trt={...vo,tMaskTexture:jt("texture","rgba","ubyte","linear"),uTexSizeInv:xe("v2"),dEdgeScale:Ft("number")},Drt=Br("edge",ps,"\nprecision highp float;\nprecision highp sampler2D;\n\nuniform sampler2D tMaskTexture;\nuniform vec2 uTexSizeInv;\n\nvoid main() {\n vec2 coords = gl_FragCoord.xy * uTexSizeInv;\n vec4 offset = vec4(float(dEdgeScale), 0.0, 0.0, float(dEdgeScale)) * vec4(uTexSizeInv, uTexSizeInv);\n vec4 c0 = texture2D(tMaskTexture, coords);\n vec4 c1 = texture2D(tMaskTexture, coords + offset.xy);\n vec4 c2 = texture2D(tMaskTexture, coords - offset.xy);\n vec4 c3 = texture2D(tMaskTexture, coords + offset.yw);\n vec4 c4 = texture2D(tMaskTexture, coords - offset.yw);\n float diff1 = (c1.r - c2.r) * 0.5;\n float diff2 = (c3.r - c4.r) * 0.5;\n float d = length(vec2(diff1, diff2));\n if (d <= 0.0)\n discard;\n float a1 = min(c1.g, c2.g);\n float a2 = min(c3.g, c4.g);\n float visibility = min(a1, a2) > 0.001 ? 1.0 : 0.0;\n float mask = c0.r;\n float marker = min(c1.b, min(c2.b, min(c3.b, c4.b)));\n float fogAlpha = min(c1.a, min(c2.a, min(c3.a, c4.a)));\n gl_FragColor = vec4(visibility, mask, marker, fogAlpha);\n}\n"),Prt={...vo,tEdgeTexture:jt("texture","rgba","ubyte","linear"),uTexSizeInv:xe("v2"),uHighlightEdgeColor:xe("v3"),uSelectEdgeColor:xe("v3"),uHighlightEdgeStrength:xe("f"),uSelectEdgeStrength:xe("f"),uGhostEdgeStrength:xe("f"),uInnerEdgeFactor:xe("f")},Mrt=Br("overlay",ps,"\nprecision highp float;\nprecision highp sampler2D;\n\nuniform vec2 uTexSizeInv;\nuniform sampler2D tEdgeTexture;\nuniform vec3 uHighlightEdgeColor;\nuniform vec3 uSelectEdgeColor;\nuniform float uHighlightEdgeStrength;\nuniform float uSelectEdgeStrength;\nuniform float uGhostEdgeStrength;\nuniform float uInnerEdgeFactor;\n\nvoid main() {\n vec2 coords = gl_FragCoord.xy * uTexSizeInv;\n vec4 edgeValue = texture2D(tEdgeTexture, coords);\n if (edgeValue.a > 0.0) {\n vec3 edgeColor = edgeValue.b == 1.0 ? uHighlightEdgeColor : uSelectEdgeColor;\n gl_FragColor.rgb = edgeValue.g > 0.0 ? edgeColor : edgeColor * uInnerEdgeFactor;\n gl_FragColor.a = (edgeValue.r == 1.0 ? uGhostEdgeStrength : 1.0) * edgeValue.a;\n float edgeStrength = edgeValue.b == 1.0 ? uHighlightEdgeStrength : uSelectEdgeStrength;\n gl_FragColor.a *= edgeStrength;\n } else {\n gl_FragColor = vec4(0.0);\n }\n}\n");class Mue{setTransparency(t){this.transparencyMode="wboit"===t?this.wboit.supported?"wboit":"blended":"dpoit"===t&&this.dpoit.supported?"dpoit":"blended",this.depthTextureOpaque.detachFramebuffer(this.postprocessing.target.framebuffer,"depth")}get transparency(){return this.transparencyMode}constructor(t,n,r,i,o){this.webgl=t,this.transparencyMode="blended";const{extensions:s,resources:a,isWebGL2:c}=t;this.drawTarget=function v9e(e){return{id:kre(),texture:Os(e),framebuffer:{id:bre(),bind:()=>{},reset:()=>{},destroy:()=>{}},depthRenderbuffer:null,getWidth:()=>0,getHeight:()=>0,bind:()=>{e.bindFramebuffer(e.FRAMEBUFFER,null)},setSize:()=>{},reset:()=>{},destroy:()=>{}}}(t.gl),this.colorTarget=t.createRenderTarget(r,i,!0,"uint8","linear"),this.packedDepth=!s.depthTexture,this.depthTargetTransparent=t.createRenderTarget(r,i),this.depthTextureTransparent=this.depthTargetTransparent.texture,this.depthTargetOpaque=this.packedDepth?t.createRenderTarget(r,i):null,this.depthTextureOpaque=this.depthTargetOpaque?this.depthTargetOpaque.texture:a.texture("image-depth","depth",c?"float":"ushort","nearest"),this.packedDepth||this.depthTextureOpaque.define(r,i),this.wboit=new F8(t,r,i),this.dpoit=new B8(t,r,i),this.marking=new Pue(t,r,i),this.postprocessing=new uc(t,n,this),this.antialiasing=new R8(t,this),this.copyFboTarget=Tv(t,this.colorTarget.texture),this.copyFboPostprocessing=Tv(t,this.postprocessing.target.texture),this.setTransparency(o)}reset(){this.wboit.reset(),this.dpoit.reset()}setSize(t,n){const r=this.colorTarget.getWidth(),i=this.colorTarget.getHeight();(t!==r||n!==i)&&(this.colorTarget.setSize(t,n),this.depthTargetTransparent.setSize(t,n),this.depthTargetOpaque?this.depthTargetOpaque.setSize(t,n):this.depthTextureOpaque.define(t,n),k.update(this.copyFboTarget.values.uTexSize,Me.set(this.copyFboTarget.values.uTexSize.ref.value,t,n)),k.update(this.copyFboPostprocessing.values.uTexSize,Me.set(this.copyFboPostprocessing.values.uTexSize.ref.value,t,n))),this.wboit.supported&&this.wboit.setSize(t,n),this.dpoit.supported&&this.dpoit.setSize(t,n),this.marking.setSize(t,n),this.postprocessing.setSize(t,n),this.antialiasing.setSize(t,n)}_renderDpoit(t,n,r,i,o,s){if(!this.dpoit.supported)throw new Error("expected dpoit to be supported");if(this.depthTextureOpaque.attachFramebuffer(this.colorTarget.framebuffer,"depth"),t.clear(!0),r.hasOpaque&&t.renderDpoitOpaque(r.primitives,n,null),uc.isEnabled(s)&&(uc.isTransparentOutlineEnabled(s)&&(this.depthTargetTransparent.bind(),t.clearDepth(!0),r.opacityAverage<1&&t.renderDepthTransparent(r.primitives,n,this.depthTextureOpaque)),this.postprocessing.render(n,!1,o,t.props.backgroundColor,s,t.light)),this.depthTextureOpaque.detachFramebuffer(this.colorTarget.framebuffer,"depth"),r.opacityAverage<1){const a=uc.isEnabled(s)?this.postprocessing.target:this.colorTarget,c=this.dpoit.bind();t.renderDpoitTransparent(r.primitives,n,this.depthTextureOpaque,c);for(let u=0;u0&&t.renderDpoitVolume(r.volumes,n,this.depthTextureOpaque)}_renderWboit(t,n,r,i,o){if(!this.wboit.supported)throw new Error("expected wboit to be supported");this.depthTextureOpaque.attachFramebuffer(this.colorTarget.framebuffer,"depth"),t.clear(!0),r.hasOpaque&&t.renderWboitOpaque(r.primitives,n,null),uc.isEnabled(o)&&(uc.isTransparentOutlineEnabled(o)&&(this.depthTargetTransparent.bind(),t.clearDepth(!0),r.opacityAverage<1&&t.renderDepthTransparent(r.primitives,n,this.depthTextureOpaque)),this.postprocessing.render(n,!1,i,t.props.backgroundColor,o,t.light)),(r.opacityAverage<1||r.volumes.renderables.length>0)&&(this.wboit.bind(),r.opacityAverage<1&&t.renderWboitTransparent(r.primitives,n,this.depthTextureOpaque),r.volumes.renderables.length>0&&t.renderWboitTransparent(r.volumes,n,this.depthTextureOpaque),uc.isEnabled(o)?this.postprocessing.target.bind():this.colorTarget.bind(),this.wboit.render())}_renderBlended(t,n,r,i,o,s){var a,c,u,l;if(i?this.drawTarget.bind():this.packedDepth?this.colorTarget.bind():this.depthTextureOpaque.attachFramebuffer(this.colorTarget.framebuffer,"depth"),t.clear(!0),r.hasOpaque&&t.renderBlendedOpaque(r.primitives,n,null),!i&&(this.depthTargetOpaque&&(this.depthTargetOpaque.bind(),t.clearDepth(!0),t.renderDepthOpaque(r.primitives,n,null),this.colorTarget.bind()),uc.isEnabled(s)&&(this.packedDepth?null===(a=this.colorTarget.depthRenderbuffer)||void 0===a||a.detachFramebuffer(this.postprocessing.target.framebuffer):this.depthTextureOpaque.detachFramebuffer(this.postprocessing.target.framebuffer,"depth"),uc.isTransparentOutlineEnabled(s)&&(this.depthTargetTransparent.bind(),t.clearDepth(!0),r.opacityAverage<1&&t.renderDepthTransparent(r.primitives,n,this.depthTextureOpaque)),this.postprocessing.render(n,!1,o,t.props.backgroundColor,s,t.light),this.packedDepth?null===(c=this.colorTarget.depthRenderbuffer)||void 0===c||c.attachFramebuffer(this.postprocessing.target.framebuffer):this.depthTextureOpaque.attachFramebuffer(this.postprocessing.target.framebuffer,"depth")),r.volumes.renderables.length>0)){const d=uc.isEnabled(s)?this.postprocessing.target:this.colorTarget;this.packedDepth?null===(u=this.colorTarget.depthRenderbuffer)||void 0===u||u.detachFramebuffer(d.framebuffer):this.depthTextureOpaque.detachFramebuffer(d.framebuffer,"depth"),d.bind(),t.renderBlendedVolume(r.volumes,n,this.depthTextureOpaque),this.packedDepth?null===(l=this.colorTarget.depthRenderbuffer)||void 0===l||l.attachFramebuffer(d.framebuffer):this.depthTextureOpaque.attachFramebuffer(d.framebuffer,"depth"),d.bind()}r.opacityAverage<1&&t.renderBlendedTransparent(r.primitives,n,null)}_render(t,n,r,i,o,s,a){const c=r.volumes.renderables.length>0,u=uc.isEnabled(a.postprocessing),l=R8.isEnabled(a.postprocessing),d=Pue.isEnabled(a.marking),{x:f,y:p,width:m,height:h}=n.viewport;t.setViewport(f,p,m,h),t.update(n,r),s&&!l&&o&&(this.drawTarget.bind(),t.clear(!1));let g=!1;"wboit"===this.transparencyMode&&this.wboit.supported?(this._renderWboit(t,n,r,s,a.postprocessing),g=!0):"dpoit"===this.transparencyMode&&this.dpoit.supported?(this._renderDpoit(t,n,r,a.dpoitIterations,s,a.postprocessing),g=!0):this._renderBlended(t,n,r,!c&&!u&&!l&&o,s,a.postprocessing);const y=u?this.postprocessing.target:!o||c||g?this.colorTarget:this.drawTarget;if(d&&r.markerAverage>0){const b=a.marking.ghostEdgeStrength<1;b&&1!==r.markerAverage&&(this.marking.depthTarget.bind(),t.clear(!1,!0),t.renderMarkingDepth(r.primitives,n,null)),this.marking.maskTarget.bind(),t.clear(!1,!0),t.renderMarkingMask(r.primitives,n,b?this.marking.depthTarget.texture:null),this.marking.update(a.marking),this.marking.render(n.viewport,y)}else y.bind();i.debug.isEnabled&&(i.debug.syncVisibility(),t.renderBlended(i.debug.scene,n)),i.handle.isEnabled&&t.renderBlended(i.handle.scene,n),i.camera.isEnabled&&(i.camera.update(n),t.update(i.camera.camera,i.camera.scene),t.renderBlended(i.camera.scene,i.camera.camera)),l?this.antialiasing.render(n,o,a.postprocessing):o&&(this.drawTarget.bind(),this.webgl.state.disable(this.webgl.gl.DEPTH_TEST),u?this.copyFboPostprocessing.render():(c||g)&&this.copyFboTarget.render()),this.webgl.gl.flush()}render(t,n,r){lt&&this.webgl.timer.mark("DrawPass.render");const{renderer:i,camera:o,scene:s,helper:a}=t;this.postprocessing.setTransparentBackground(n.transparentBackground);const c=n.transparentBackground||this.postprocessing.background.isEnabled(n.postprocessing.background);i.setTransparentBackground(c),i.setDrawingBufferSize(this.colorTarget.getWidth(),this.colorTarget.getHeight()),i.setPixelRatio(this.webgl.pixelRatio),Xv.is(o)?(lt&&this.webgl.timer.mark("StereoCamera.left"),this._render(i,o.left,s,a,r,c,n),lt&&this.webgl.timer.markEnd("StereoCamera.left"),lt&&this.webgl.timer.mark("StereoCamera.right"),this._render(i,o.right,s,a,r,c,n),lt&&this.webgl.timer.markEnd("StereoCamera.right")):this._render(i,o,s,a,r,c,n),lt&&this.webgl.timer.markEnd("DrawPass.render")}getColorTarget(t){return R8.isEnabled(t)?this.antialiasing.target:uc.isEnabled(t)?this.postprocessing.target:this.colorTarget}}const krt={alpha:C.Numeric(.51,{min:0,max:1,step:.01},{isEssential:!0,label:"Opacity"}),colorX:C.Color(xn.red,{isEssential:!0}),colorY:C.Color(xn.green,{isEssential:!0}),colorZ:C.Color(xn.blue,{isEssential:!0}),scale:C.Numeric(.33,{min:.1,max:2,step:.1},{isEssential:!0}),location:C.Select("bottom-left",C.arrayToOptions(["bottom-left","bottom-right","top-left","top-right"])),locationOffsetX:C.Numeric(0),locationOffsetY:C.Numeric(0),originColor:C.Color(xn.grey),radiusScale:C.Numeric(.075,{min:.01,max:.3,step:.001}),showPlanes:C.Boolean(!0),planeColorXY:C.Color(xn.grey,{label:"Plane Color XY"}),planeColorXZ:C.Color(xn.grey,{label:"Plane Color XZ"}),planeColorYZ:C.Color(xn.grey,{label:"Plane Color YZ"}),showLabels:C.Boolean(!1),labelX:C.Text("X"),labelY:C.Text("Y"),labelZ:C.Text("Z"),labelColorX:C.Color(xn.grey),labelColorY:C.Color(xn.grey),labelColorZ:C.Color(xn.grey),labelOpacity:C.Numeric(1,{min:0,max:1,step:.01}),labelScale:C.Numeric(.25,{min:.1,max:1,step:.01})},IE={axes:C.MappedStatic("on",{on:C.Group(krt),off:C.Group({})},{cycle:!0,description:"Show camera orientation axes"})};class Rue{constructor(t,n={}){this.webgl=t,this.props={axes:{name:"off",params:{}}},this.pixelRatio=1,this.eachGroup=(r,i)=>{if(!O8(r))return!1;let o=!1;if(this.meshRenderObject){const s=this.meshRenderObject.values.uGroupCount.ref.value;for(const{groupId:a,instanceId:c}of r.elements)i(Ce.ofSingleton(c*s+a))&&(o=!0)}if(this.textRenderObject){const s=this.textRenderObject.values.uGroupCount.ref.value;for(const{groupId:a,instanceId:c}of r.elements)i(Ce.ofSingleton(c*s+a))&&(o=!0)}return o},this.scene=$v.create(t,"blended"),this.camera=new gr,v.set(this.camera.up,0,1,0),v.set(this.camera.target,0,0,0),this.setProps(n)}setProps(t){this.props=c0(this.props,n=>{if(void 0!==t.axes&&(n.axes.name=t.axes.name,"on"===t.axes.name)){this.scene.clear(),this.pixelRatio=this.webgl.pixelRatio;const r={...t.axes.params,scale:t.axes.params.scale*this.pixelRatio,labelScale:t.axes.params.labelScale*this.pixelRatio};this.meshRenderObject=function Urt(e){const t=function Lrt(e,t){const n=100*e.scale,r=function Ort(e,t){const n=at.createState(512,256,t),r=100*e.scale,i=e.radiusScale*r,o=e.showLabels?100*e.labelScale/3:0,s=v.scale(v(),v.unitX,r-o),a=v.scale(v(),v.unitY,r-o),c=v.scale(v(),v.unitZ,r-o),u={radiusTop:i,radiusBottom:i,radialSegments:32};if(n.currentGroup=Cr.Origin,Zn(n,v.origin,i,2),n.currentGroup=Cr.X,Zn(n,s,i,2),Hn(n,v.origin,s,1,u),n.currentGroup=Cr.Y,Zn(n,a,i,2),Hn(n,v.origin,a,1,u),n.currentGroup=Cr.Z,Zn(n,c,i,2),Hn(n,v.origin,c,1,u),e.showPlanes){v.scale(s,s,.5),v.scale(a,a,.5),v.scale(c,c,.5),n.currentGroup=Cr.XY,at.addTriangle(n,v.origin,s,a),at.addTriangle(n,v.origin,a,s);const l=v.add(v(),s,a);at.addTriangle(n,l,s,a),at.addTriangle(n,l,a,s),n.currentGroup=Cr.XZ,at.addTriangle(n,v.origin,s,c),at.addTriangle(n,v.origin,c,s);const d=v.add(v(),s,c);at.addTriangle(n,d,s,c),at.addTriangle(n,d,c,s),n.currentGroup=Cr.YZ,at.addTriangle(n,v.origin,a,c),at.addTriangle(n,v.origin,c,a);const f=v.add(v(),a,c);at.addTriangle(n,f,a,c),at.addTriangle(n,f,c,a)}return at.getMesh(n)}(e,t?.geometry);r.setBoundingSphere(_e.create(v.create(n/2,n/2,n/2),n+n/4));return qn.create("axes-mesh",{},r,o=>{switch(o){case Cr.X:return e.colorX;case Cr.Y:return e.colorY;case Cr.Z:return e.colorZ;case Cr.XY:return e.planeColorXY;case Cr.XZ:return e.planeColorXZ;case Cr.YZ:return e.planeColorYZ;case Cr.Origin:return e.originColor;default:return xn.grey}},()=>1,()=>"")}(e);return qn.createRenderObject(t,{...C.getDefaultValues(Nt.Params),...e,ignoreLight:!0,cellSize:0})}(r),this.scene.add(this.meshRenderObject),t.axes.params.showLabels?(this.textRenderObject=function Grt(e){const t=function zrt(e,t){const n=100*e.scale,r=function Vrt(e,t){const n=wf.create(e,8,8,t),r=100*e.scale,i=v.scale(v(),v.unitX,r),o=v.scale(v(),v.unitY,r),s=v.scale(v(),v.unitZ,r),a=100*e.labelScale;return n.add(e.labelX,i[0],i[1],i[2],0,a,Cr.X),n.add(e.labelY,o[0],o[1],o[2],0,a,Cr.Y),n.add(e.labelZ,s[0],s[1],s[2],0,a,Cr.Z),n.getText()}(e,t?.geometry);r.setBoundingSphere(_e.create(v.create(n/2,n/2,n/2),n));return qn.create("axes-text",{},r,o=>{switch(o){case Cr.X:return e.labelColorX;case Cr.Y:return e.labelColorY;case Cr.Z:return e.labelColorZ;default:return xn.grey}},()=>1,()=>"")}(e);return qn.createRenderObject(t,{...C.getDefaultValues(vu.Params),...e,alpha:e.labelOpacity,cellSize:0})}(r),this.scene.add(this.textRenderObject)):this.textRenderObject=void 0,this.scene.commit(),v.set(this.camera.position,0,0,200*r.scale),le.lookAt(this.camera.view,this.camera.position,this.camera.target,this.camera.up),n.axes.params={...t.axes.params}}})}get isEnabled(){return"on"===this.props.axes.name}getLoci(t){const{objectId:n,groupId:r,instanceId:i}=t;return(this.meshRenderObject&&n===this.meshRenderObject.id||this.textRenderObject&&n===this.textRenderObject.id)&&r!==Cr.None?function Frt(e,t,n){return eE("camera-axes",e,[{groupId:t,instanceId:n}],void 0,()=>function Nrt(e,t){const n=t.props.axes,r="on"===n.name?n.params.labelX:"X",i="on"===n.name?n.params.labelY:"Y",o="on"===n.name?n.params.labelZ:"Z";switch(e){case Cr.X:return`${r} Axis`;case Cr.Y:return`${i} Axis`;case Cr.Z:return`${o} Axis`;case Cr.XY:return`${r}${i} Plane`;case Cr.XZ:return`${r}${o} Plane`;case Cr.YZ:return`${i}${o} Plane`;case Cr.Origin:return"Origin";default:return"Axes"}}(t,e))}(this,r,i):$n}mark(t,n){return!(!Us.is(Us.Highlighting,n)||!(Uc(t)||O8(t)&&t.data===this))&&(Sn.mark(this.meshRenderObject,t,n,this.eachGroup)||Sn.mark(this.textRenderObject,t,n,this.eachGroup))}update(t){if(!this.meshRenderObject||"off"===this.props.axes.name)return;this.pixelRatio!==this.webgl.pixelRatio&&this.setProps(this.props),function Brt(e,t,n){const{near:r,far:i}=e,o=-t.width/2,s=t.width/2,a=t.height/2,c=-t.height/2,u=(s-o)/2,l=(a-c)/2,d=(s+o)/2,f=(a+c)/2;let p=d-u,m=d+u,h=f+l,g=f-l;if(n.enabled){const y=(s-o)/n.width,b=(a-c)/n.height;p+=y*n.offsetX,m=p+y*n.width,h-=b*n.offsetY,g=h-b*n.height}le.ortho(e.projection,p,m,h,g,r,i)}(this.camera,t.viewport,t.viewOffset),le.extractRotation(this.scene.view,t.view);const n=this.textRenderObject?this.textRenderObject.values.boundingSphere.ref.value.radius:this.meshRenderObject.values.boundingSphere.ref.value.radius,r=this.props.axes.params.location,i=this.props.axes.params.locationOffsetX*this.pixelRatio,o=this.props.axes.params.locationOffsetY*this.pixelRatio;"bottom-left"===r?le.setTranslation(this.scene.view,v.create(-t.viewport.width/2+n+i,-t.viewport.height/2+n+o,0)):"bottom-right"===r?le.setTranslation(this.scene.view,v.create(t.viewport.width/2-n-i,-t.viewport.height/2+n+o,0)):"top-left"===r?le.setTranslation(this.scene.view,v.create(-t.viewport.width/2+n+i,t.viewport.height/2-n-o,0)):"top-right"===r?le.setTranslation(this.scene.view,v.create(t.viewport.width/2-n-i,t.viewport.height/2-n-o,0)):Rr()}}var Cr=function(e){return e[e.None=0]="None",e[e.X=1]="X",e[e.Y=2]="Y",e[e.Z=3]="Z",e[e.XY=4]="XY",e[e.XZ=5]="XZ",e[e.YZ=6]="YZ",e[e.Origin=7]="Origin",e}(Cr||{});function O8(e){return"data-loci"===e.kind&&"camera-axes"===e.tag}const jrt={transparentBackground:C.Boolean(!1),dpoitIterations:C.Numeric(2,{min:1,max:10,step:1}),multiSample:C.Group(Cue),postprocessing:C.Group(Sue),marking:C.Group(Eue),cameraHelper:C.Group(IE)};class Hrt{get colorTarget(){return this._colorTarget}get width(){return this._width}get height(){return this._height}constructor(t,n,r,i,o,s,a,c){this.webgl=t,this.renderer=r,this.scene=i,this.camera=o,this._width=0,this._height=0,this._camera=new gr,this.props={...C.getDefaultValues(jrt),...c},this.drawPass=new Mue(t,n,128,128,a),this.multiSamplePass=new AE(t,this.drawPass),this.multiSampleHelper=new wue(this.multiSamplePass),this.helper={camera:new Rue(t,this.props.cameraHelper),debug:s.debug,handle:s.handle},this.setSize(1024,768)}updateBackground(){return new Promise(t=>{this.drawPass.postprocessing.background.update(this.camera,this.props.postprocessing.background,()=>{t()})})}setSize(t,n){t===this._width&&n===this._height||(this._width=t,this._height=n,this.drawPass.setSize(t,n),this.multiSamplePass.syncSize())}setProps(t={}){Object.assign(this.props,t),t.cameraHelper&&this.helper.camera.setProps(t.cameraHelper)}render(){gr.copySnapshot(this._camera.state,this.camera.state),Lo.set(this._camera.viewport,0,0,this._width,this._height),this._camera.update();const t={renderer:this.renderer,camera:this._camera,scene:this.scene,helper:this.helper};AE.isEnabled(this.props.multiSample)?(this.multiSampleHelper.render(t,this.props,!1),this._colorTarget=this.multiSamplePass.colorTarget):(this.drawPass.render(t,this.props,!1),this._colorTarget=this.drawPass.getColorTarget(this.props.postprocessing))}getImageData(t,n,r){var i,o;this.setSize(t,n),this.render(),this.colorTarget.bind();const s=null!==(i=r?.width)&&void 0!==i?i:t,a=null!==(o=r?.height)&&void 0!==o?o:n,c=new Uint8Array(s*a*4);r?this.webgl.readPixels(r.x,n-r.y-r.height,s,a,c):this.webgl.readPixels(0,0,s,a,c);const u=d0.create(c,s,a);return d0.flipY(u),d0.divideByAlpha(u),new ImageData(new Uint8ClampedArray(c),s,a)}}const qrt={...Nt.Params,alpha:{...Nt.Params.alpha,defaultValue:1},ignoreLight:{...Nt.Params.ignoreLight,defaultValue:!0},colorX:C.Color(xn.red,{isEssential:!0}),colorY:C.Color(xn.green,{isEssential:!0}),colorZ:C.Color(xn.blue,{isEssential:!0}),scale:C.Numeric(.33,{min:.1,max:2,step:.1},{isEssential:!0})},kue={handle:C.MappedStatic("off",{on:C.Group(qrt),off:C.Group({})},{cycle:!0,description:"Show handle tool"})};class Wrt{getBoundingSphere(t,n){return this.renderObject&&(_e.copy(t,this.renderObject.values.invariantBoundingSphere.ref.value),le.fromArray(this._transform,this.renderObject.values.aTransform.ref.value,16*n),_e.transform(t,t,this._transform)),t}setProps(t){this.props=c0(this.props,n=>{if(void 0!==t.handle&&(n.handle.name=t.handle.name,"on"===t.handle.name)){this.scene.clear(),this.pixelRatio=this.webgl.pixelRatio;const r={...t.handle.params,scale:t.handle.params.scale*this.webgl.pixelRatio,cellSize:0};this.renderObject=function Krt(e){const t=function Xrt(e,t){const n=10*e.scale,r=function $rt(e,t){const n=at.createState(512,256,t),r=.05*e,i=v.scale(v(),v.unitX,e),o=v.scale(v(),v.unitY,e),s=v.scale(v(),v.unitZ,e),a={radiusTop:r,radiusBottom:r,radialSegments:32};return n.currentGroup=P0.TranslateScreenXY,Zn(n,v.origin,3*r,2),n.currentGroup=P0.TranslateObjectX,Zn(n,i,r,2),Hn(n,v.origin,i,1,a),n.currentGroup=P0.TranslateObjectY,Zn(n,o,r,2),Hn(n,v.origin,o,1,a),n.currentGroup=P0.TranslateObjectZ,Zn(n,s,r,2),Hn(n,v.origin,s,1,a),at.getMesh(n)}(n,t?.geometry);r.setBoundingSphere(_e.create(v.create(n/2,n/2,n/2),n+n/4));return qn.create("handle",{},r,o=>{switch(o){case P0.TranslateObjectX:return e.colorX;case P0.TranslateObjectY:return e.colorY;case P0.TranslateObjectZ:return e.colorZ;default:return xn.grey}},()=>1,()=>"")}(e);return qn.createRenderObject(t,e)}(r),this.scene.add(this.renderObject),this.scene.commit(),n.handle.params={...t.handle.params}}})}get isEnabled(){return"on"===this.props.handle.name}update(t,n,r){this.renderObject&&(this.pixelRatio!==this.webgl.pixelRatio&&this.setProps(this.props),le.setTranslation(this.renderObject.values.aTransform.ref.value,n),le.fromMat3(this.renderObject.values.aTransform.ref.value,r),k.update(this.renderObject.values.aTransform,this.renderObject.values.aTransform.ref.value),this.scene.update([this.renderObject],!0))}getLoci(t){const{objectId:n,groupId:r,instanceId:i}=t;return this.renderObject&&n===this.renderObject.id?function Yrt(e,t,n){return eE("handle",e,[{groupId:t,instanceId:n}],r=>e.getBoundingSphere(r,n),()=>`Handle Helper | Group Id ${t} | Instance Id ${n}`)}(this,r,i):$n}mark(t,n){return!(!Us.is(Us.Highlighting,n)||!(Uc(t)||Nue(t)&&t.data===this))&&Sn.mark(this.renderObject,t,n,this.eachGroup)}constructor(t,n={}){this.webgl=t,this.props={handle:{name:"off",params:{}}},this.pixelRatio=1,this._transform=le(),this.eachGroup=(r,i)=>{if(!this.renderObject||!Nue(r))return!1;let o=!1;const s=this.renderObject.values.uGroupCount.ref.value,{elements:a}=r;for(const{groupId:c,instanceId:u}of a)i(Ce.ofSingleton(u*s+c))&&(o=!0);return o},this.scene=$v.create(t,"blended"),this.setProps(n)}}const P0={None:0,TranslateScreenXY:1,TranslateObjectX:3,TranslateObjectY:4,TranslateObjectZ:5};function Nue(e){return"data-loci"===e.kind&&"handle"===e.tag}const Zrt={debug:C.Group(E8),camera:C.Group({helper:C.Group(IE)}),handle:C.Group(kue)},Qrt=C.getDefaultValues(Zrt);class Jrt{constructor(t,n,r={}){const i={...Qrt,...r};this.debug=new Gtt(t,n,i.debug),this.camera=new Rue(t,i.camera.helper),this.handle=new Wrt(t,i.handle)}}class eit{constructor(t,n,r={}){this.webgl=t;const{gl:i}=t;this.draw=new Mue(t,n,i.drawingBufferWidth,i.drawingBufferHeight,r.transparency||"blended"),this.pick=new drt(t,this.draw,r.pickScale||.25),this.multiSample=new AE(t,this.draw)}setPickScale(t){this.pick.setPickScale(t)}setTransparency(t){this.draw.setTransparency(t)}updateSize(){const{gl:t}=this.webgl,n=Math.max(t.drawingBufferWidth,2),r=Math.max(t.drawingBufferHeight,2);this.draw.setSize(n,r),this.pick.syncSize(),this.multiSample.syncSize()}}const nit={...vo,tPreviousLevel:jt("texture","alpha","float","nearest"),uInvSize:xe("v2"),uOffset:xe("v2")},rit=Br("hi-z",ps,"\nprecision highp float;\nprecision highp sampler2D;\n\nuniform sampler2D tPreviousLevel;\nuniform vec2 uInvSize;\nuniform vec2 uOffset;\n\nvoid main(void) {\n vec2 position = gl_FragCoord.xy * uInvSize + uOffset;\n\n float x = texture(tPreviousLevel, position).r;\n float y = textureOffset(tPreviousLevel, position, ivec2(-1, 0)).r;\n float z = textureOffset(tPreviousLevel, position, ivec2(-1, -1)).r;\n float w = textureOffset(tPreviousLevel, position, ivec2(0, -1)).r;\n\n gl_FragColor = vec4(max(max(x, y), max(z, w)));\n}\n"),Fue=new ArrayBuffer(4);new Int32Array(Fue),new Float32Array(Fue);const Bue=new ArrayBuffer(4),cit=new Int32Array(Bue),uit=new Float32Array(Bue);function Kv(e){return function lit(e){return cit[0]=(1<<23)*((e<-126?-126:e)+126.94269504),uit[0]}(1.44269504*e)}const Oue=new ArrayBuffer(8);new Int32Array(Oue),new Float32Array(Oue);const Uue=new ArrayBuffer(4),dit=new Int32Array(Uue),fit=new Float32Array(Uue);Math,Math,Math,Math,Math,Math,Math,Math,Math;const Gue=new ArrayBuffer(16);new Int32Array(Gue),new Float32Array(Gue);const jue=new ArrayBuffer(8);new Int32Array(jue),new Float32Array(jue);const que=new ArrayBuffer(4);new Int32Array(que),new Float32Array(que),Math;const Ait=v.transformMat4,$ue=nn.set,Iit=function V8(e){return fit[0]=e,1.1920928955078125e-7*dit[0]-126.94269504};function PE(e,t,n,r){return-1===r[11]?function Tit(e,t,n){return t*n/((n-t)*e-n)}(e,t,n):function Dit(e,t,n){return e*(t-n)-t}(e,t,n)}const Yue={enabled:C.Boolean(!1,{description:"Hierarchical Z-buffer occlusion culling. Only available for WebGL2."}),maxFrameLag:C.Numeric(10,{min:1,max:30,step:1},{description:"Maximum number of frames to wait for Z-buffer data."}),minLevel:C.Numeric(3,{min:1,max:10,step:1})};class Rit{clear(){if(!this.supported)return;const{gl:t}=this.webgl;Wt(t)&&(null!==this.sync&&(t.deleteSync(this.sync),this.sync=null),this.frameLag=0,this.ready=!1,this.debug&&(this.debug.rect.style.display="none",this.debug.container.style.display="none"))}render(t){if(!this.supported||!this.props.enabled)return;const{gl:n,state:r}=this.webgl;if(!Wt(n)||null!==this.sync)return;this.nextNear=t.near,this.nextFar=t.far,le.copy(this.nextView,t.view),le.copy(this.nextProjection,t.projection),lt&&this.webgl.timer.mark("hi-Z"),r.disable(n.CULL_FACE),r.disable(n.BLEND),r.disable(n.DEPTH_TEST),r.disable(n.SCISSOR_TEST),r.depthMask(!1),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0);const i=this.renderable.values,o=Math.pow(2,Math.ceil(Math.log(Math.max(n.drawingBufferWidth,n.drawingBufferHeight))/Math.log(2))-1);for(let c=0,u=this.levelData.length;c0?(k.update(i.uInvSize,l.invSize),k.update(i.uOffset,Me.set(i.uOffset.ref.value,0,0)),k.update(i.tPreviousLevel,this.levelData[c-1].texture)):(k.update(i.uInvSize,Me.set(i.uInvSize.ref.value,1/o,1/o)),k.update(i.uOffset,Me.set(i.uOffset.ref.value,this.viewport.x/n.drawingBufferWidth,this.viewport.y/n.drawingBufferHeight)),k.update(i.tPreviousLevel,this.drawPass.depthTextureOpaque)),r.currentRenderItemId=-1,r.viewport(0,0,l.size[0],l.size[1]),n.clear(n.COLOR_BUFFER_BIT),this.renderable.update(),this.renderable.render(),c>=this.props.minLevel&&(this.tex.bind(0),n.copyTexSubImage2D(n.TEXTURE_2D,0,l.offset,0,0,0,l.size[0],l.size[1]),this.tex.unbind(0))}this.tex.attachFramebuffer(this.fb,0);const s=this.tex.getWidth(),a=this.tex.getHeight();n.bindBuffer(n.PIXEL_PACK_BUFFER,this.buf),n.bufferData(n.PIXEL_PACK_BUFFER,this.buffer.byteLength,n.STREAM_READ),n.readPixels(0,0,s,a,n.RED,n.FLOAT,0),n.bindBuffer(n.PIXEL_PACK_BUFFER,null),this.sync=n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE,0),n.flush(),lt&&this.webgl.timer.markEnd("hi-Z")}tick(){if(!this.supported||!this.props.enabled||null===this.sync)return;const{gl:t}=this.webgl;if(!Wt(t))return;const n=t.clientWaitSync(this.sync,0,0);n===t.WAIT_FAILED||this.frameLag>=this.props.maxFrameLag?(t.deleteSync(this.sync),this.sync=null,this.frameLag=0,this.ready=!1):n===t.TIMEOUT_EXPIRED?this.frameLag+=1:(t.bindBuffer(t.PIXEL_PACK_BUFFER,this.buf),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this.buffer),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),t.deleteSync(this.sync),this.sync=null,this.frameLag=0,this.ready=!0,this.near=this.nextNear,this.far=this.nextFar,le.copy(this.view,this.nextView),le.copy(this.projection,this.nextProjection))}transform(t){const{view:n,vp:r}=this;return Ait(r,t.center,n),{vp:r,r:1.2*t.radius+1.52}}project(t,n){const{projection:r,aabb:i,viewport:o}=this;!function Mit(e,t,n,r){return-1===r[11]?function Eit(e,t,n,r){const i=t[0]*n,o=t[1]*n,s=t[2]*n,a=t[2]*t[2]-n*n,c=Math.sqrt(t[0]*t[0]+a),u=(c*t[0]-s)/(c*t[2]+i)*r[0],l=(c*t[0]+s)/(c*t[2]-i)*r[0],d=Math.sqrt(t[1]*t[1]+a);return $ue(e,-.5*l+.5,(d*t[1]-s)/(d*t[2]+o)*r[5]*.5+.5,-.5*u+.5,(d*t[1]+s)/(d*t[2]-o)*r[5]*.5+.5)}(e,t,n,r):function Pit(e,t,n,r){const i=r[0],o=r[5];return $ue(e,(t[0]-n)*i*.5+.5,(t[1]+n)*o*-.5+.5,(t[0]+n)*i*.5+.5,(t[1]-n)*o*-.5+.5)}(e,t,n,r)}(i,t,n,r);const s=i[2]-i[0],a=i[3]-i[1],c=Math.max(s*o.width,a*o.height);return{aabb:i,w:s,h:a,pr:c,lod:Math.ceil(Iit(c/2))}}setViewport(t,n,r,i){if(!this.supported)return;r=Math.max(r,2),i=Math.max(i,2),Lo.set(this.viewport,t,n,r,i);const o=Math.ceil(Math.log(Math.max(r,i))/Math.log(2));if(o===this.levelData.length)return;const{minLevel:s}=this.props;this.buffer=new Float32Array(Math.pow(2,o-s)*Math.pow(2,o-1-s)),this.tex.define(Math.pow(2,o-s),Math.pow(2,o-1-s));for(const c of this.levelData)c.framebuffer.destroy(),c.texture.destroy();this.levelData.length=0;for(let c=0;c=s&&(this.levelData[c].offset=a,a+=l.size[0])}this.clear()}setProps(t){if(this.supported)if(this.props.minLevel!==t.minLevel){Object.assign(this.props,t);const{x:n,y:r,width:i,height:o}=this.viewport;this.setViewport(n,r,i,o)}else Object.assign(this.props,t),this.props.enabled||this.clear()}initDebug(t){if(!t.parentElement)return;const n=document.createElement("div");Object.assign(n.style,{display:"block",position:"absolute",pointerEvents:"none"}),t.parentElement.appendChild(n);const r=document.createElement("canvas"),i=r.getContext("2d");if(!i)throw new Error("Could not create canvas 2d context");Object.assign(r.style,{width:"100%",height:"100%",imageRendering:"pixelated",position:"relative",pointerEvents:"none"}),n.appendChild(r);const o=document.createElement("div");Object.assign(o.style,{display:"none",position:"absolute",pointerEvents:"none"}),t.parentElement.appendChild(o),this.debug={container:n,canvas:r,ctx:i,rect:o}}canDebug(t){return this.supported&&this.props.enabled&&this.ready&&!!this.debug}showRect(t,n){if(!this.canDebug(this.debug))return;const{gl:{drawingBufferHeight:r},pixelRatio:i}=this.webgl,{viewport:{x:o,y:s,width:a,height:c}}=this,u=(t[0]*a+o)/i,l=(t[1]*c-s)/i;Object.assign(this.debug.rect.style,{border:n?"solid red":"solid green",display:"block",left:`${u}px`,top:`${l+(r-c)/i}px`,width:(t[2]*a+o)/i-u+"px",height:(t[3]*c-s)/i-l+"px"})}showBuffer(t){if(!this.canDebug(this.debug))return;if(t>=this.levelData.length||t{if(!this.supported||!this.props.enabled||!this.ready)return!1;const{vp:l,r:d}=this.transform(u),{near:f,far:p,projection:m}=this,h=l[2]+d;if(-h=this.levelData.length||x=w||T+1>=w)return!1;const N=(w-T-1)*M+R+_;if(h>PE(this.buffer[N],f,p,m)||h>PE(this.buffer[N+1],f,p,m))return!1;const V=(w-T+1-1)*M+R+_;return!(h>PE(this.buffer[V],f,p,m)||h>PE(this.buffer[V+1],f,p,m))};const{gl:o,extensions:s}=t;if(!Wt(o)||!s.colorBufferFloat)return un&&console.log('Missing webgl2 and/or colorBufferFloat support required for "Hi-Z"'),void(this.supported=!1);this.fb=t.resources.framebuffer(),this.tex=t.resources.texture("image-float32","alpha","float","nearest"),this.tex.attachFramebuffer(this.fb,0);const a=o.getParameter(o.IMPLEMENTATION_COLOR_READ_FORMAT),c=o.getParameter(o.IMPLEMENTATION_COLOR_READ_TYPE);if(a!==o.RED||c!==o.FLOAT)return un&&console.log('Missing red/float reading support required for "Hi-Z"'),void(this.supported=!1);this.supported=!0,this.props={...C.getDefaultValues(Yue),...i},this.buf=WL(o),this.renderable=function iit(e,t){const n={..._o,tPreviousLevel:k.create(t),uInvSize:k.create(Me()),uOffset:k.create(Me())},r={...nit};return ji(zi(e,"triangles",rit,r,n),n)}(t,this.drawPass.depthTextureOpaque),un&&r&&this.initDebug(r)}}const Xue={camera:C.Group({mode:C.Select("perspective",C.arrayToOptions(["perspective","orthographic"]),{label:"Camera"}),helper:C.Group(IE,{isFlat:!0}),stereo:C.MappedStatic("off",{on:C.Group(Aue),off:C.Group({})},{cycle:!0,hideIf:e=>"perspective"!==e?.mode}),fov:C.Numeric(45,{min:10,max:130,step:1},{label:"Field of View"}),manualReset:C.Boolean(!1,{isHidden:!0})},{pivot:"mode"}),cameraFog:C.MappedStatic("on",{on:C.Group({intensity:C.Numeric(15,{min:1,max:100,step:1})}),off:C.Group({})},{cycle:!0,description:"Show fog in the distance"}),cameraClipping:C.Group({radius:C.Numeric(100,{min:0,max:99,step:1},{label:"Clipping",description:"How much of the scene to show."}),far:C.Boolean(!0,{description:"Hide scene in the distance"}),minNear:C.Numeric(5,{min:.1,max:100,step:.1},{description:"Note, may cause performance issues rendering impostors when set too small and cause issues with outline rendering when too close to 0."})},{pivot:"radius"}),viewport:C.MappedStatic("canvas",{canvas:C.Group({}),"static-frame":C.Group({x:C.Numeric(0),y:C.Numeric(0),width:C.Numeric(128),height:C.Numeric(128)}),"relative-frame":C.Group({x:C.Numeric(.33,{min:0,max:1,step:.01}),y:C.Numeric(.33,{min:0,max:1,step:.01}),width:C.Numeric(.5,{min:.01,max:1,step:.01}),height:C.Numeric(.5,{min:.01,max:1,step:.01})})}),cameraResetDurationMs:C.Numeric(250,{min:0,max:1e3,step:1},{description:"The time it takes to reset the camera."}),sceneRadiusFactor:C.Numeric(1,{min:1,max:10,step:.1}),transparentBackground:C.Boolean(!1),dpoitIterations:C.Numeric(2,{min:1,max:10,step:1}),pickPadding:C.Numeric(3,{min:0,max:10,step:1},{description:"extra pixels to around target to check in case target is empty"}),multiSample:C.Group(Cue),postprocessing:C.Group(Sue),marking:C.Group(Eue),hiZ:C.Group(Yue),renderer:C.Group(A8),trackball:C.Group(cue),interaction:C.Group(pue),debug:C.Group(E8),handle:C.Group(kue)},j8=C.getDefaultValues(Xue);var ME;!function(e){e.DefaultAttribs={powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,antialias:!0,preserveDrawingBuffer:!0,preferWebGl1:!1,handleResize:()=>{}},e.Params={pixelScale:C.Numeric(1,{min:.1,max:2,step:.05}),pickScale:C.Numeric(.25,{min:.1,max:1,step:.05}),transparency:C.Select("wboit",[["blended","Blended"],["wboit","Weighted, Blended"],["dpoit","Depth Peeling"]])},e.DefaultProps=C.getDefaultValues(e.Params),e.fromCanvas=function t(n,r,i={},o={}){const s={...e.DefaultAttribs,...i},a={...e.DefaultProps,...o},{powerPreference:c,failIfMajorPerformanceCaveat:u,antialias:l,preserveDrawingBuffer:d,preferWebGl1:f}=s,p=function A9e(e,t){function n(i){try{return e.getContext(i,t)}catch{return null}}const r=(t?.preferWebGl1?null:n("webgl2"))||n("webgl")||n("experimental-webgl");return un&&console.log(`isWebgl2: ${Wt(r)}`),r}(n,{powerPreference:c,failIfMajorPerformanceCaveat:u,antialias:l,preserveDrawingBuffer:d,alpha:!0,depth:!0,premultipliedAlpha:!0,preferWebGl1:f});if(null===p)throw new Error("Could not create a WebGL rendering context");const{pixelScale:m,pickScale:h,transparency:g}=a,y=w8.fromElement(n,{pixelScale:m,preventGestures:!0}),b=function P9e(e,t={}){const n=_re(e),r=function u7e(e,t){let n={},r=e.getParameter(e.FRONT_FACE),i=e.getParameter(e.CULL_FACE_MODE),o=e.getParameter(e.DEPTH_WRITEMASK),s=e.getParameter(e.DEPTH_CLEAR_VALUE),a=e.getParameter(e.DEPTH_FUNC),c=e.getParameter(e.COLOR_WRITEMASK),u=e.getParameter(e.COLOR_CLEAR_VALUE),l=e.getParameter(e.BLEND_SRC_RGB),d=e.getParameter(e.BLEND_DST_RGB),f=e.getParameter(e.BLEND_SRC_ALPHA),p=e.getParameter(e.BLEND_DST_ALPHA),m=e.getParameter(e.BLEND_COLOR),h=e.getParameter(e.BLEND_EQUATION_RGB),g=e.getParameter(e.BLEND_EQUATION_ALPHA),y=e.getParameter(e.STENCIL_FUNC),b=e.getParameter(e.STENCIL_VALUE_MASK),x=e.getParameter(e.STENCIL_REF),_=e.getParameter(e.STENCIL_BACK_FUNC),S=e.getParameter(e.STENCIL_BACK_VALUE_MASK),A=e.getParameter(e.STENCIL_BACK_REF),E=e.getParameter(e.STENCIL_WRITEMASK),w=e.getParameter(e.STENCIL_BACK_WRITEMASK),D=e.getParameter(e.STENCIL_FAIL),I=e.getParameter(e.STENCIL_PASS_DEPTH_PASS),R=e.getParameter(e.STENCIL_PASS_DEPTH_FAIL),T=e.getParameter(e.STENCIL_BACK_FAIL),M=e.getParameter(e.STENCIL_BACK_PASS_DEPTH_PASS),N=e.getParameter(e.STENCIL_BACK_PASS_DEPTH_FAIL),V=e.getParameter(e.MAX_VERTEX_ATTRIBS);const F=[];let G=e.getParameter(e.VIEWPORT),L=e.getParameter(e.SCISSOR_BOX),z=t.clipControl?e.getParameter(t.clipControl.CLIP_ORIGIN):-1,j=t.clipControl?e.getParameter(t.clipControl.CLIP_DEPTH_MODE):-1;const Z=()=>{for(let $=0;${!0!==n[$]&&(e.enable($),n[$]=!0)},disable:$=>{!1!==n[$]&&(e.disable($),n[$]=!1)},frontFace:$=>{$!==r&&(e.frontFace($),r=$)},cullFace:$=>{$!==i&&(e.cullFace($),i=$)},depthMask:$=>{$!==o&&(e.depthMask($),o=$)},clearDepth:$=>{$!==s&&(e.clearDepth($),s=$)},depthFunc:$=>{$!==a&&(e.depthFunc($),a=$)},colorMask:($,ee,q,O)=>{($!==c[0]||ee!==c[1]||q!==c[2]||O!==c[3])&&(e.colorMask($,ee,q,O),c[0]=$,c[1]=ee,c[2]=q,c[3]=O)},clearColor:($,ee,q,O)=>{($!==u[0]||ee!==u[1]||q!==u[2]||O!==u[3])&&(e.clearColor($,ee,q,O),u[0]=$,u[1]=ee,u[2]=q,u[3]=O)},blendFunc:($,ee)=>{($!==l||ee!==d||$!==f||ee!==p)&&(e.blendFunc($,ee),l=$,d=ee,f=$,p=ee)},blendFuncSeparate:($,ee,q,O)=>{($!==l||ee!==d||q!==f||O!==p)&&(e.blendFuncSeparate($,ee,q,O),l=$,d=ee,f=q,p=O)},blendEquation:$=>{($!==h||$!==g)&&(e.blendEquation($),h=$,g=$)},blendEquationSeparate:($,ee)=>{($!==h||ee!==g)&&(e.blendEquationSeparate($,ee),h=$,g=ee)},blendColor:($,ee,q,O)=>{($!==m[0]||ee!==m[1]||q!==m[2]||O!==m[3])&&(e.blendColor($,ee,q,O),m[0]=$,m[1]=ee,m[2]=q,m[3]=O)},stencilFunc:($,ee,q)=>{($!==y||ee!==x||q!==b||$!==_||ee!==A||q!==S)&&(e.stencilFunc($,ee,q),y=$,x=ee,b=q,_=$,A=ee,S=q)},stencilFuncSeparate:($,ee,q,O)=>{$===e.FRONT?(ee!==y||q!==x||O!==b)&&(e.stencilFuncSeparate($,ee,q,O),y=ee,x=q,b=O):$===e.BACK?(ee!==_||q!==A||O!==S)&&(e.stencilFuncSeparate($,ee,q,O),_=ee,A=q,S=O):$===e.FRONT_AND_BACK&&(ee!==y||q!==x||O!==b||ee!==_||q!==A||O!==S)&&(e.stencilFuncSeparate($,ee,q,O),y=ee,x=q,b=O,_=ee,A=q,S=O)},stencilMask:$=>{($!==E||$!==w)&&(e.stencilMask($),E=$,w=$)},stencilMaskSeparate:($,ee)=>{$===e.FRONT?ee!==E&&(e.stencilMaskSeparate($,ee),E=ee):$===e.BACK?ee!==w&&(e.stencilMaskSeparate($,ee),w=ee):$===e.FRONT_AND_BACK&&(ee!==E||ee!==w)&&(e.stencilMaskSeparate($,ee),E=ee,w=ee)},stencilOp:($,ee,q)=>{($!==D||ee!==R||q!==I||$!==T||ee!==N||q!==M)&&(e.stencilOp($,ee,q),D=$,R=ee,I=q,T=$,N=ee,M=q)},stencilOpSeparate:($,ee,q,O)=>{$===e.FRONT?(ee!==D||q!==R||O!==I)&&(e.stencilOpSeparate($,ee,q,O),D=ee,R=q,I=O):$===e.BACK?(ee!==T||q!==N||O!==M)&&(e.stencilOpSeparate($,ee,q,O),T=ee,N=q,M=O):$===e.FRONT_AND_BACK&&(ee!==D||q!==R||O!==I||ee!==T||q!==N||O!==M)&&(e.stencilOpSeparate($,ee,q,O),D=ee,R=q,I=O,T=ee,N=q,M=O)},enableVertexAttrib:$=>{e.enableVertexAttribArray($),F[$]=1},clearVertexAttribsState:Z,disableUnusedVertexAttribs:()=>{for(let $=0;${($!==G[0]||ee!==G[1]||q!==G[2]||O!==G[3])&&(e.viewport($,ee,q,O),G[0]=$,G[1]=ee,G[2]=q,G[3]=O)},scissor:($,ee,q,O)=>{($!==L[0]||ee!==L[1]||q!==L[2]||O!==L[3])&&(e.scissor($,ee,q,O),L[0]=$,L[1]=ee,L[2]=q,L[3]=O)},clipControl:t.clipControl?($,ee)=>{($!==z||ee!==j)&&(t.clipControl.clipControl($,ee),z=$,j=ee)}:void 0,reset:()=>{n={},r=e.getParameter(e.FRONT_FACE),i=e.getParameter(e.CULL_FACE_MODE),o=e.getParameter(e.DEPTH_WRITEMASK),s=e.getParameter(e.DEPTH_CLEAR_VALUE),a=e.getParameter(e.DEPTH_FUNC),c=e.getParameter(e.COLOR_WRITEMASK),u=e.getParameter(e.COLOR_CLEAR_VALUE),l=e.getParameter(e.BLEND_SRC_RGB),d=e.getParameter(e.BLEND_DST_RGB),f=e.getParameter(e.BLEND_SRC_ALPHA),p=e.getParameter(e.BLEND_DST_ALPHA),m=e.getParameter(e.BLEND_COLOR),h=e.getParameter(e.BLEND_EQUATION_RGB),g=e.getParameter(e.BLEND_EQUATION_ALPHA),y=e.getParameter(e.STENCIL_FUNC),b=e.getParameter(e.STENCIL_VALUE_MASK),x=e.getParameter(e.STENCIL_REF),_=e.getParameter(e.STENCIL_BACK_FUNC),S=e.getParameter(e.STENCIL_BACK_VALUE_MASK),A=e.getParameter(e.STENCIL_BACK_REF),E=e.getParameter(e.STENCIL_WRITEMASK),w=e.getParameter(e.STENCIL_BACK_WRITEMASK),D=e.getParameter(e.STENCIL_FAIL),I=e.getParameter(e.STENCIL_PASS_DEPTH_PASS),R=e.getParameter(e.STENCIL_PASS_DEPTH_FAIL),T=e.getParameter(e.STENCIL_BACK_FAIL),M=e.getParameter(e.STENCIL_BACK_PASS_DEPTH_PASS),N=e.getParameter(e.STENCIL_BACK_PASS_DEPTH_FAIL),V=e.getParameter(e.MAX_VERTEX_ATTRIBS),F.length=0;for(let $=0;${o&&(a.forEach((y,b)=>{o.deleteQuery(b)}),c.clear(),f=[],p=null)},g=()=>{if(!o)return;const y=function S9e(e){return e.disjointTimerQuery?e.disjointTimerQuery.createQuery():null}(t);y&&(o.beginQuery(o.TIME_ELAPSED,y),c.forEach((b,x)=>{b.queries.push(y)}),a.set(y,{refCount:c.size}),p=y)};return{resolve:()=>{const y=[];if(!o||!f.length)return y;a.forEach((x,_)=>{if(void 0!==x.timeElapsed)return;const S=o.getQueryParameter(_,o.QUERY_RESULT_AVAILABLE),A=e.getParameter(o.GPU_DISJOINT);if(S&&!A){const E=o.getQueryParameter(_,o.QUERY_RESULT);x.timeElapsed=E}(S||A)&&o.deleteQuery(_)});const b=[];for(const x of f)if(x.queries.every(_=>{var S;return void 0!==(null===(S=a.get(_))||void 0===S?void 0:S.timeElapsed)})){let _=0;for(const S of x.queries){const A=a.get(S);_+=A.timeElapsed,A.refCount-=1}if(x.timeElapsed=_,x.root){const S=[],A=(w,D)=>{for(const I of w){const R=I.timeElapsed,T=I.cpu.end-I.cpu.start,M={label:I.label,gpuElapsed:R,gpuAvg:l.add(I.label,R),cpuElapsed:T,cpuAvg:d.add(I.label,T),children:[],calls:I.calls};D.push(M),A(I.children,M.children)}};A(x.children,S);const E=x.cpu.end-x.cpu.start;y.push({label:x.label,gpuElapsed:_,gpuAvg:l.add(x.label,_),cpuElapsed:E,cpuAvg:d.add(x.label,E),children:S,calls:x.calls})}}else b.push(x);return f=b,a.forEach((x,_)=>{0===x.refCount&&a.delete(_)}),y},mark:(y,b=!1)=>{if(!o)return;if(c.has(y))throw new Error(`Timer mark for '${y}' already exists`);null!==p&&o.endQuery(o.TIME_ELAPSED);const x={label:y,queries:[],children:[],root:null===p,cpu:{start:yi(),end:-1},captureStats:b};if(c.set(y,x),u.length&&u[u.length-1].children.push(x),u.push(x),b){if(m)throw new Error("Already capturing stats");(function x9e(e){e.calls.drawInstanced=0,e.calls.drawInstancedBase=0,e.calls.multiDrawInstancedBase=0,e.calls.counts=0,e.culled.lod=0,e.culled.frustum=0,e.culled.occlusion=0})(n),m=!0}g()},markEnd:y=>{var b;if(!o)return;const x=c.get(y);if(!x)throw new Error(`Timer mark for '${y}' does not exist`);if((null===(b=u.pop())||void 0===b?void 0:b.label)!==y)throw new Error(`Timer mark for '${y}' has pending nested mark`);o.endQuery(o.TIME_ELAPSED),c.delete(y),x.cpu.end=yi(),x.captureStats&&(x.calls={...n.calls},m=!1),f.push(x),c.size>0?g():p=null},stats:()=>({gpu:l.stats(),cpu:d.stats()}),formatedStats:()=>{const y={},b=l.stats(),x=d.stats();for(const _ of Object.keys(b)){const S=`${(b[_]/1e3/1e3).toFixed(2)}`,A=`${x[_].toFixed(2)}`;y[_]=`${S} ms | CPU: ${A} ms`}return y},clear:h,destroy:()=>{h()}}}(e,n,i),a={maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),max3dTextureSize:Wt(e)?e.getParameter(e.MAX_3D_TEXTURE_SIZE):0,maxRenderbufferSize:e.getParameter(e.MAX_RENDERBUFFER_SIZE),maxDrawBuffers:n.drawBuffers?e.getParameter(n.drawBuffers.MAX_DRAW_BUFFERS):0,maxTextureImageUnits:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextureImageUnits:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)};if(a.maxVertexTextureImageUnits<8)throw new Error('Need "MAX_VERTEX_TEXTURE_IMAGE_UNITS" >= 8');const c=n.provokingVertex;c?.provokingVertex(c.FIRST_VERTEX_CONVENTION);let u=!1;const l=new Ao(0);let f,d=t.pixelScale||1;if(Wt(e)){const m=e.createBuffer();let h,g,y=!1;const b=()=>{e.bindBuffer(e.PIXEL_PACK_BUFFER,m),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,h),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),y=!1,g(),g=void 0,h=void 0};f=(x,_,S,A,E)=>new Promise((w,D)=>{y?D("Can not call multiple readPixelsAsync at the same time"):(y=!0,e.bindBuffer(e.PIXEL_PACK_BUFFER,m),e.bufferData(e.PIXEL_PACK_BUFFER,S*A*4,e.STREAM_READ),e.readPixels(x,_,S,A,e.RGBA,e.UNSIGNED_BYTE,0),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),g=w,h=E,Vre(e,b))})}else f=function(){var m=ie(function*(h,g,y,b,x){YL(e,h,g,y,b,x)});return function(g,y,b,x,_){return m.apply(this,arguments)}}();const p=new Set;return{gl:e,isWebGL2:Wt(e),get pixelRatio(){return(typeof window<"u"&&window.devicePixelRatio||1)*(d||1)},extensions:n,state:r,stats:i,resources:o,timer:s,get maxTextureSize(){return a.maxTextureSize},get max3dTextureSize(){return a.max3dTextureSize},get maxRenderbufferSize(){return a.maxRenderbufferSize},get maxDrawBuffers(){return a.maxDrawBuffers},get maxTextureImageUnits(){return a.maxTextureImageUnits},namedComputeRenderables:Object.create(null),namedFramebuffers:Object.create(null),namedTextures:Object.create(null),get isContextLost(){return u||e.isContextLost()},contextRestored:l,setContextLost:()=>{u=!0},handleContextRestored:m=>{Object.assign(n,_re(e)),r.reset(),r.currentMaterialId=-1,r.currentProgramId=-1,r.currentRenderItemId=-1,o.reset(),p.forEach(h=>h.reset()),m?.(),u=!1,l.next(yi())},setPixelScale:m=>{d=m},createRenderTarget:(m,h,g,y,b,x)=>{const _=function b9e(e,t,n,r,i=!0,o="uint8",s="nearest",a="rgba"){if("alpha"===a&&!Wt(e))throw new Error("cannot render to alpha format in webgl1");const c=t.framebuffer(),u="fp16"===o?t.texture("image-float16",a,"fp16",s):"float32"===o?t.texture("image-float32",a,"float",s):t.texture("image-uint8",a,"ubyte",s),l=i?Wt(e)?t.renderbuffer("depth32f","depth",n,r):t.renderbuffer("depth16","depth",n,r):null;function d(){u.define(n,r),u.attachFramebuffer(c,"color0"),l&&l.attachFramebuffer(c)}d();let f=!1;return{id:kre(),texture:u,framebuffer:c,depthRenderbuffer:l,getWidth:()=>n,getHeight:()=>r,bind:()=>{c.bind()},setSize:(p,m)=>{n===p&&r===m||(u.define(n=p,r=m),l&&l.setSize(n,r))},reset:()=>{d()},destroy:()=>{f||(u.destroy(),c.destroy(),l&&l.destroy(),f=!0)}}}(e,o,m,h,g,y,b,x);return p.add(_),{..._,destroy:()=>{_.destroy(),p.delete(_)}}},unbindFramebuffer:()=>gD(e),readPixels:(m,h,g,y,b)=>{YL(e,m,h,g,y,b)},readPixelsAsync:f,waitForGpuCommandsComplete:()=>function T9e(e){return new Promise(t=>{Wt(e)?Vre(e,t):(zre||(console.info("Sync object not supported in WebGL"),zre=!0),Gre(e),t())})}(e),waitForGpuCommandsCompleteSync:()=>Gre(e),getDrawingBufferPixelData:()=>function D9e(e,t){const n=e.drawingBufferWidth,r=e.drawingBufferHeight,i=new Uint8Array(n*r*4);return gD(e),t.viewport(0,0,n,r),YL(e,0,0,n,r,i),d0.flipY(d0.create(i,n,r))}(e,r),clear:(m,h,g,y)=>{gD(e),r.enable(e.SCISSOR_TEST),r.depthMask(!0),r.colorMask(!0,!0,!0,!0),r.clearColor(m,h,g,y),r.viewport(0,0,e.drawingBufferWidth,e.drawingBufferHeight),r.scissor(0,0,e.drawingBufferWidth,e.drawingBufferHeight),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)},destroy:m=>{var h,g;o.destroy(),function I9e(e){const t=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);for(let i=0;i{b.isContextLost||!D.shiftKey||!D.ctrlKey||!D.altKey||(un&&console.log("lose context"),w.loseContext(),setTimeout(()=>{b.isContextLost&&(un&&console.log("restore context"),w.restoreContext())},1e3))},!1)}const _=new Ao(0),S=w=>{b.setContextLost(),w.preventDefault(),un&&console.log("context lost"),_.next(yi())},A=()=>{b.isContextLost&&(b.handleContextRestored(()=>{x.draw.reset()}),un&&console.log("context restored"))};n.addEventListener("webglcontextlost",S,!1),n.addEventListener("webglcontextrestored",A,!1);const E=new Ao(void 0);return{canvas:n,webgl:b,input:y,passes:x,attribs:s,get props(){return{...a}},contextLost:_,contextRestored:b.contextRestored,assetManager:r,changed:E,setProps:w=>{if(!w)return;let D=!1;void 0!==w.pixelScale&&w.pixelScale!==a.pixelScale&&(a.pixelScale=w.pixelScale,y.setPixelScale(w.pixelScale),b.setPixelScale(w.pixelScale),s.handleResize(),D=!0),void 0!==w.pickScale&&w.pickScale!==a.pickScale&&(a.pickScale=w.pickScale,x.setPickScale(w.pickScale),D=!0),void 0!==w.transparency&&w.transparency!==a.transparency&&(a.transparency=w.transparency,x.setTransparency(w.transparency),D=!0),D&&E.next(void 0)},dispose:w=>{y.dispose(),n.removeEventListener("webglcontextlost",S,!1),n.removeEventListener("webglcontextrestored",A,!1),b.destroy(w)}}}}(ME||(ME={}));const kit=typeof window<"u"?window.requestAnimationFrame:e=>setImmediate(()=>e(Date.now())),Kue=typeof window<"u"?window.cancelAnimationFrame:e=>clearImmediate(e);var H8;function Nit(e){Zue(e)}function Zue(e){Cn.Canvas3D.ResetSettings.subscribe(e,()=>{var t;null===(t=e.canvas3d)||void 0===t||t.setProps(j8),e.events.canvas3d.settingsUpdated.next(void 0)}),Cn.Canvas3D.SetSettings.subscribe(e,t=>{var n;e.canvas3d&&(null===(n=e.canvas3d)||void 0===n||n.setProps(t.settings),e.events.canvas3d.settingsUpdated.next(void 0))})}!function(e){e.create=function t(n,r={}){var i;const{webgl:o,input:s,passes:a,assetManager:c,canvas:u}=n,l={...Jl(j8),...Jl(r)},d=new Map,f=new Map,p=new Ao(0);let m=yi();const h=new Ao(0),g=new Ao(0),y=new Ao(0),{gl:b,contextRestored:x}=o;let _=0,S=0,A=128,E=128,w=!1,D=0;ln();const I=$v.create(o,n.props.transparency);function R(){return I.boundingSphere.radius*l.sceneRadiusFactor}const T=new gr({position:v.create(0,0,100),mode:l.camera.mode,fog:"on"===l.cameraFog.name?l.cameraFog.params.intensity:0,clipFar:l.cameraClipping.far,minNear:l.cameraClipping.minNear,fov:Yn(l.camera.fov)},{x:_,y:S,width:A,height:E}),M=new Xv(T,l.camera.stereo.params),N=D8.create(s,T,I,l.trackball),V=new Jrt(o,I,l),F=new Rit(o,a.draw,u,l.hiZ),G=T8.create(o,l.renderer);G.setOcclusionTest(F.isOccluded);const L=new frt(o,G,I,V,a.pick,{x:_,y:S,width:A,height:E},l.pickPadding),z=new Xtt(We,H,s,T,N,l.interaction),j=new wue(a.multiSample);a.draw.postprocessing.background.update(T,l.postprocessing.background,qe=>{qe&&me()});let $,ee,Z=!1,q=!1,O=!0;function H(qe){let dt=$n,gt=yn.Empty;if(qe){const se=V.camera.getLoci(qe);if(se!==$n)return{loci:se,repr:gt};dt=V.handle.getLoci(qe),d.forEach((he,ve)=>{const Te=ve.getLoci(qe);Ta(Te)||(Ta(dt)||console.warn("found another loci, this should not happen"),dt=Te,gt=ve)})}return{loci:dt,repr:gt}}let W=[];function X(qe,dt){const{repr:gt,loci:se}=qe;let he=!1;return gt?he=gt.mark(se,dt)||he:d.forEach((ve,Te)=>{he=Te.mark(se,dt)||he}),he=V.handle.mark(se,dt)||he,he=V.camera.mark(se,dt)||he,he}let ce=!1,be=!1;function ae(qe){be||function J(qe){if(o.isContextLost)return!1;let dt=!1;if(q&&(Et(!1),q=!1,dt=!0),_>b.drawingBufferWidth||_+A<0||S>b.drawingBufferHeight||S+E<0)return!1;const gt=function fe(){let qe=!1;for(const[dt,gt]of W)qe=X(dt,gt)||qe;return W=[],qe&&(I.update(void 0,!0),V.handle.scene.update(void 0,!0),V.camera.scene.update(void 0,!0)),qe}()&&(G.props.colorMarker||l.marking.enabled);let se=!1;N.update(D);const he=T.update(),ve=qe||he||dt||w;w=!1;const Te=j.update(gt||ve,l.multiSample);if(ve||Te||gt){let yt=T;"on"===l.camera.stereo.name&&(M.update(),yt=M),lt&&o.timer.mark("Canvas3D.render",!0);const xt={renderer:G,camera:yt,scene:I,helper:V};AE.isEnabled(l.multiSample)?j.render(xt,l,!0,l.multiSample.reduceFlicker&&!he&>&&!N.isAnimating):a.draw.render(xt,l,!0),F.render(T),lt&&o.timer.markEnd("Canvas3D.render"),L.dirty=L.dirty||ve,se=!0}return se}(!!qe?.force)&&O&&h.next(yi()-m)}function me(){w=!0}let oe=0;function K(qe,dt){D=qe,U(dt?.isSynchronous),T.transition.tick(D),F.tick(),!dt?.manualDraw&&(ae(),!T.transition.inTransition&&!o.isContextLost&&z.tick(D))}function ne(){K(yi()),oe=kit(ne)}function We(qe,dt){return o.isContextLost?void 0:L.identify(qe,dt,"on"===l.camera.stereo.name?M:T)}function U(qe=!1){(function Ge(qe){return!I.needsCommit||(_e.copy(ge,I.boundingSphereVisible),F.clear(),I.commit(qe?void 0:Ne)?(y.next(0),V.debug.isEnabled&&V.debug.update(),!l.camera.manualReset&&(0===p.value||function Re(){if(0===T.state.radiusMax)return!0;if(T.transition.inTransition||ee)return!1;let qe=!0,dt=!0;_e.set(Se,T.state.target,T.state.radius);for(const gt of I.renderables){if(!gt.state.visible)continue;const se=gt.values.boundingSphere.ref.value;if(!se.radius)continue;dt=!1;const he=v.distance(Se.center,se.center);if((he>Se.radius||he>se.radius||se.radius>T.state.radiusMax)&&!_e.includes(ge,se))return!0;_e.overlaps(Se,se)&&(qe=!1)}return qe||!dt&&Se.radius<=.1}())&&(Z=!0),0===ge.radius&&($=0),l.camera.manualReset||T.setState({radiusMax:R()},0),p.next(d.size),un&&$e(),!0):(y.next(I.commitQueueSize),!1))})(qe)&&(function Y(){if(!Z)return;const qe=I.boundingSphereVisible,{center:dt,radius:gt}=qe,se=N.props.autoAdjustMinMaxDistance;if("on"===se.name){const he=se.params.minDistanceFactor*gt+se.params.minDistancePadding,ve=Math.max(se.params.maxDistanceFactor*gt,se.params.maxDistanceMin);N.setProps({minDistance:he,maxDistance:ve})}if(gt>0){const he=void 0===$?l.cameraResetDurationMs:$,ve=T.getFocus(dt,gt),Te="function"==typeof ee?ee(I,T):ee,yt=Te?{...ve,...Te}:ve;T.setState({...yt,radiusMax:R()},he)}$=void 0,ee=void 0,Z=!1}(),ce&&(V.debug.isEnabled&&V.debug.update(),ae({force:!0}),ce=!1),g.next(yi()))}const ge=_e(),Se=_e(),Ne=250;function $e(){const qe=I.renderables.map(he=>({drawCount:he.values.drawCount.ref.value,instanceCount:he.values.instanceCount.ref.value,materialId:he.materialId,renderItemId:he.id}));console.groupCollapsed(`${qe.length} RenderItems`),qe.length<50?console.table(qe):console.log(qe),console.log(JSON.stringify(o.stats,void 0,4));const{texture:dt,attribute:gt,elements:se}=o.resources.getByteCounts();console.log(JSON.stringify({texture:`${(dt/1024/1024).toFixed(3)} MiB`,attribute:`${(gt/1024/1024).toFixed(3)} MiB`,elements:`${(se/1024/1024).toFixed(3)} MiB`},void 0,4)),console.log(JSON.stringify(o.timer.formatedStats(),void 0,4)),console.groupEnd()}function _t(){const qe=I.boundingSphere.radius>0?100-Math.round(T.transition.target.radius/R()*100):0;return{camera:{mode:T.state.mode,helper:{...V.camera.props},stereo:{...l.camera.stereo},fov:Math.round(su(T.state.fov)),manualReset:!!l.camera.manualReset},cameraFog:T.state.fog>0?{name:"on",params:{intensity:T.state.fog}}:{name:"off",params:{}},cameraClipping:{far:T.state.clipFar,radius:qe,minNear:T.state.minNear},cameraResetDurationMs:l.cameraResetDurationMs,sceneRadiusFactor:l.sceneRadiusFactor,transparentBackground:l.transparentBackground,dpoitIterations:l.dpoitIterations,pickPadding:l.pickPadding,viewport:l.viewport,postprocessing:{...l.postprocessing},marking:{...l.marking},multiSample:{...l.multiSample},hiZ:{...F.props},renderer:{...G.props},trackball:{...N.props},interaction:{...z.props},debug:{...V.debug.props},handle:{...V.handle.props}}}const ut=x.subscribe(()=>{L.dirty=!0,ae({force:!0}),ae({force:!0})}),Ct=new Ao(0);function Et(qe=!0){a.updateSize(),ln(),Qn(),qe&&me(),Ct.next(+new Date)}!function FMe(e){Jx.includes(e)||Jx.push(e)}($e);const Xt=null===(i=n.changed)||void 0===i?void 0:i.subscribe(()=>{I.setTransparency(n.props.transparency),me()});if(un&&u){let qe;const dt=gt=>{const se=gt&&pn.getBoundingSphere(pn.normalize(gt,"residue"));F.debugOcclusion(se)};s.click.subscribe(gt=>{if(!gt.modifiers.control||2!==gt.button)return;const se=We(gt.x,gt.y);if(!se)return qe=void 0,void dt(qe);qe=H(se.id).loci,dt(qe)}),h.subscribe(()=>{setTimeout(()=>{dt(qe)},100)})}return{webgl:o,add:function tt(qe){!function Xe(qe){f.has(qe)||f.set(qe,qe.updated.subscribe(dt=>{qe.state.syncManually||tt(qe)}))}(qe);const dt=d.get(qe),gt=new Set;qe.renderObjects.forEach(se=>gt.add(se)),dt?Si.areEqual(gt,dt)||(gt.forEach(se=>{dt.has(se)||I.add(se)}),dt.forEach(se=>{gt.has(se)||I.remove(se)})):qe.renderObjects.forEach(se=>I.add(se)),d.set(qe,gt),I.update(qe.renderObjects,!1),ce=!0,un&&$e()},remove:function ke(qe){!function ot(qe){const dt=f.get(qe);dt&&(dt.unsubscribe(),f.delete(qe))}(qe);const dt=d.get(qe);dt&&(dt.forEach(gt=>I.remove(gt)),d.delete(qe),ce=!0,un&&$e())},commit:U,update:(qe,dt)=>{if(qe){if(!d.has(qe))return;I.update(qe.renderObjects,!!dt)}else I.update(void 0,!!dt);ce=!0},clear:()=>{f.forEach(qe=>qe.unsubscribe()),f.clear(),d.clear(),I.clear(),V.debug.clear(),me(),p.next(d.size)},syncVisibility:()=>{0===T.state.radiusMax&&(Z=!0,$=0),I.syncVisibility()&&V.debug.isEnabled&&V.debug.update(),me()},requestDraw:me,tick:K,animate:function we(){be=!1,N.start(yi()),0===oe&&ne()},resetTime:function de(qe){m=qe,N.start(qe)},pause:function Le(qe=!1){be=qe,Kue(oe),oe=0},resume:()=>{be=!1},identify:We,mark:function Q(qe,dt){W.push([qe,dt])},getLoci:H,handleResize:Et,requestResize:()=>{q=!0},requestCameraReset:qe=>{$=qe?.durationMs,ee=qe?.snapshot,Z=!0},camera:T,boundingSphere:I.boundingSphere,boundingSphereVisible:I.boundingSphereVisible,get notifyDidDraw(){return O},set notifyDidDraw(qe){O=qe},didDraw:h,commited:g,commitQueueSize:y,reprCount:p,resized:Ct,setProps:(qe,dt=!1)=>{var gt,se,he,ve;const Te="function"==typeof qe?c0(_t(),qe):qe;void 0!==Te.sceneRadiusFactor&&(l.sceneRadiusFactor=Te.sceneRadiusFactor,T.setState({radiusMax:R()},0));const yt=Object.create(null);Te.camera&&void 0!==Te.camera.mode&&Te.camera.mode!==T.state.mode&&(yt.mode=Te.camera.mode);const xt=Math.round(su(T.state.fov));if(Te.camera&&void 0!==Te.camera.fov&&Te.camera.fov!==xt&&(yt.fov=Yn(Te.camera.fov)),void 0!==Te.cameraFog&&Te.cameraFog.params){const Ut="on"===Te.cameraFog.name?Te.cameraFog.params.intensity:0;Ut!==T.state.fog&&(yt.fog=Ut)}if(void 0!==Te.cameraClipping&&(void 0!==Te.cameraClipping.far&&Te.cameraClipping.far!==T.state.clipFar&&(yt.clipFar=Te.cameraClipping.far),void 0!==Te.cameraClipping.minNear&&Te.cameraClipping.minNear!==T.state.minNear&&(yt.minNear=Te.cameraClipping.minNear),void 0!==Te.cameraClipping.radius)){const Ut=R()/100*(100-Te.cameraClipping.radius);Ut>0&&Ut!==yt.radius&&(yt.radius=Math.max(Ut,.01))}Object.keys(yt).length>0&&T.setState(yt),!(null===(gt=Te.camera)||void 0===gt)&>.helper&&V.camera.setProps(Te.camera.helper),void 0!==(null===(se=Te.camera)||void 0===se?void 0:se.manualReset)&&(l.camera.manualReset=Te.camera.manualReset),void 0!==(null===(he=Te.camera)||void 0===he?void 0:he.stereo)&&(Object.assign(l.camera.stereo,Te.camera.stereo),M.setProps(l.camera.stereo.params)),void 0!==Te.cameraResetDurationMs&&(l.cameraResetDurationMs=Te.cameraResetDurationMs),void 0!==Te.transparentBackground&&(l.transparentBackground=Te.transparentBackground),void 0!==Te.dpoitIterations&&(l.dpoitIterations=Te.dpoitIterations),void 0!==Te.pickPadding&&(l.pickPadding=Te.pickPadding),void 0!==Te.viewport&&(l.viewport===Te.viewport||l.viewport.name===Te.viewport.name&&Hx(l.viewport.params,Te.viewport.params)||(l.viewport=Te.viewport,ln(),Qn())),!(null===(ve=Te.postprocessing)||void 0===ve)&&ve.background&&(Object.assign(l.postprocessing.background,Te.postprocessing.background),a.draw.postprocessing.background.update(T,l.postprocessing.background,Ut=>{Ut&&!dt&&me()})),Te.postprocessing&&Object.assign(l.postprocessing,Te.postprocessing),Te.marking&&Object.assign(l.marking,Te.marking),Te.multiSample&&Object.assign(l.multiSample,Te.multiSample),Te.hiZ&&F.setProps(Te.hiZ),Te.renderer&&G.setProps(Te.renderer),Te.trackball&&N.setProps(Te.trackball),Te.interaction&&z.setProps(Te.interaction),Te.debug&&V.debug.setProps(Te.debug),Te.handle&&V.handle.setProps(Te.handle),"orthographic"===yt.mode&&(l.camera.stereo.name="off"),dt||me()},getImagePass:(qe={})=>new Hrt(o,c,G,I,T,V,a.draw.transparency,qe),getRenderObjects(){const qe=[];return I.forEach((dt,gt)=>qe.push(gt)),qe},get props(){return _t()},get input(){return s},get stats(){return G.stats},get interaction(){return z.events},dispose:()=>{ut.unsubscribe(),Xt?.unsubscribe(),Kue(oe),W=[],I.clear(),V.debug.clear(),N.dispose(),G.dispose(),z.dispose(),F.dispose(),function BMe(e){const t=Jx.indexOf(e);-1!==t&&Jx.splice(t,1)}($e)}};function ln(){const qe=_,dt=S,gt=A,se=E;"canvas"===l.viewport.name?(_=0,S=0,A=b.drawingBufferWidth,E=b.drawingBufferHeight):"static-frame"===l.viewport.name?(_=l.viewport.params.x*o.pixelRatio,E=l.viewport.params.height*o.pixelRatio,S=b.drawingBufferHeight-E-l.viewport.params.y*o.pixelRatio,A=l.viewport.params.width*o.pixelRatio):"relative-frame"===l.viewport.name&&(_=Math.round(l.viewport.params.x*b.drawingBufferWidth),E=Math.round(l.viewport.params.height*b.drawingBufferHeight),S=Math.round(b.drawingBufferHeight-E-l.viewport.params.y*b.drawingBufferHeight),A=Math.round(l.viewport.params.width*b.drawingBufferWidth)),(qe!==_||dt!==S||gt!==A||se!==E)&&(w=!0)}function Qn(){L.setViewport(_,S,A,E),G.setViewport(_,S,A,E),Lo.set(T.viewport,_,S,A,E),Lo.set(N.viewport,_,S,A,E),F.setViewport(_,S,A,E)}}}(H8||(H8={}));const M0=Zi,Tm=wu,R0=At.Trigger,Fit={hoverHighlightOnly:At([R0(M0.Flag.None)],"Highlight","Hover element using ${triggers}"),hoverHighlightOnlyExtend:At([R0(M0.Flag.None,Tm.create({shift:!0}))],"Extend highlight","From selected to hovered element along polymer using ${triggers}")},Bit={bindings:C.Value(Fit,{isHidden:!0}),ignore:C.Value([],{isHidden:!0}),preferAtoms:C.Boolean(!1,{description:"Always prefer atoms over bonds"}),mark:C.Boolean(!0)},Oit=tr.create({name:"representation-highlight-loci",category:"interaction",ctor:class extends tr.Handler{constructor(){super(...arguments),this.lociMarkProvider=(e,t)=>{!this.ctx.canvas3d||!this.params.mark||this.ctx.canvas3d.mark(e,t)}}getLoci(e){return this.params.preferAtoms&&Lt.isLoci(e)&&2===e.bonds.length?Lt.toFirstStructureElementLoci(e):e}register(){this.subscribeObservable(this.ctx.behaviors.interaction.hover,({current:e,buttons:t,modifiers:n})=>{if(!this.ctx.canvas3d||this.ctx.isBusy)return;const r=this.getLoci(e.loci);if(this.params.ignore.includes(r.kind))return void this.ctx.managers.interactivity.lociHighlights.highlightOnly({repr:e.repr,loci:$n});let i=!1;At.match(this.params.bindings.hoverHighlightOnly,t,n)&&(this.ctx.managers.interactivity.lociHighlights.highlightOnly({loci:r}),i=!0),At.match(this.params.bindings.hoverHighlightOnlyExtend,t,n)&&(this.ctx.managers.interactivity.lociHighlights.highlightOnlyExtend({loci:r}),i=!0),i||this.ctx.managers.interactivity.lociHighlights.highlightOnly({repr:e.repr,loci:$n})}),this.ctx.managers.interactivity.lociHighlights.addProvider(this.lociMarkProvider)}unregister(){this.ctx.managers.interactivity.lociHighlights.removeProvider(this.lociMarkProvider)}},params:()=>Bit,display:{name:"Highlight Loci on Canvas"}}),Que={clickSelect:At.Empty,clickToggleExtend:At([R0(M0.Flag.Primary,Tm.create({shift:!0}))],"Toggle extended selection","Click on element using ${triggers} to extend selection along polymer"),clickSelectOnly:At.Empty,clickToggle:At([R0(M0.Flag.Primary,Tm.create())],"Toggle selection","Click on element using ${triggers}"),clickDeselect:At.Empty,clickDeselectAllOnEmpty:At([R0(M0.Flag.Primary,Tm.create())],"Deselect all","Click on nothing using ${triggers}")},Lit={bindings:C.Value(Que,{isHidden:!0}),ignore:C.Value([],{isHidden:!0}),preferAtoms:C.Boolean(!1,{description:"Always prefer atoms over bonds"}),mark:C.Boolean(!0)},Uit=tr.create({name:"representation-select-loci",category:"interaction",ctor:class extends tr.Handler{getLoci(e){return this.params.preferAtoms&&Lt.isLoci(e)&&2===e.bonds.length?Lt.toFirstStructureElementLoci(e):e}applySelectMark(e,t){const n=this.ctx.state.data.cells.get(e);if(n&&pe.isRepresentation3D(n.obj)){this.spine.current=n;const r=this.spine.getRootOfType(pe.Molecule.Structure);if(r){t&&this.lociMarkProvider({loci:Ve.Loci(r.data)},Bt.Deselect);const i=this.ctx.managers.structure.selection.getLoci(r.data);this.lociMarkProvider({loci:i},Bt.Select)}}}register(){const t=r=>!pn.isEmpty(r),n=[["clickSelect",r=>this.ctx.managers.interactivity.lociSelects.select(r),t],["clickToggle",r=>this.ctx.managers.interactivity.lociSelects.toggle(r),t],["clickToggleExtend",r=>this.ctx.managers.interactivity.lociSelects.toggleExtend(r),t],["clickSelectOnly",r=>this.ctx.managers.interactivity.lociSelects.selectOnly(r),t],["clickDeselect",r=>this.ctx.managers.interactivity.lociSelects.deselect(r),t],["clickDeselectAllOnEmpty",()=>this.ctx.managers.interactivity.lociSelects.deselectAll(),r=>pn.isEmpty(r)]];n.sort((r,i)=>{const o=this.params.bindings[r[0]],s=this.params.bindings[i[0]],a=0===o.triggers.length?0:Xd(o.triggers.map(u=>Tm.size(u.modifiers)));return(0===s.triggers.length?0:Xd(s.triggers.map(u=>Tm.size(u.modifiers))))-a}),this.subscribeObservable(this.ctx.behaviors.interaction.click,({current:r,button:i,modifiers:o})=>{if(!this.ctx.canvas3d||this.ctx.isBusy||!this.ctx.selectionMode)return;const s=this.getLoci(r.loci);if(!this.params.ignore.includes(s.kind))for(const[a,c,u]of n)if(At.match(this.params.bindings[a],i,o)&&(!u||u(s))){c({repr:r.repr,loci:s});break}}),this.ctx.managers.interactivity.lociSelects.addProvider(this.lociMarkProvider),this.subscribeObservable(this.ctx.state.events.object.created,({ref:r})=>this.applySelectMark(r)),this.subscribeObservable(this.ctx.state.events.object.updated,({ref:r,obj:i,oldObj:o,oldData:s,action:a})=>{const c=this.ctx.state.data.cells.get(r);if(c&&pe.Molecule.Structure.is(c.obj)){const u=i.data,l="recreate"===a?o?.data:"in-place"===a?s:void 0;if(l&&Ve.areEquivalent(u,l)&&Ve.areHierarchiesEqual(u,l))return;const d=this.ctx.state.data.select(In.children(r).ofType(pe.Molecule.Structure.Representation3D));for(const f of d)this.applySelectMark(f.transform.ref,!0)}})}unregister(){this.ctx.managers.interactivity.lociSelects.removeProvider(this.lociMarkProvider)}constructor(e,t){super(e,t),this.lociMarkProvider=(n,r)=>{!this.ctx.canvas3d||!this.params.mark||this.ctx.canvas3d.mark({loci:n.loci},r)},this.spine=new rD.Impl(e.state.data.cells)}},params:()=>Lit,display:{name:"Select Loci on Canvas"}}),Vit=tr.create({name:"default-loci-label-provider",category:"interaction",ctor:class{register(){this.ctx.managers.lociLabels.addProvider(this.f)}unregister(){this.ctx.managers.lociLabels.removeProvider(this.f)}constructor(e){this.ctx=e,this.f={label:t=>{const n=[];if(De.is(t)){const r=new Set;for(const{unit:i}of t.elements){const o=nt.create(t.structure,i,i.elements[0]),s=Ze.entity.pdbx_description(o).join(", ");r.add(s)}1===r.size&&r.forEach(i=>n.push(i))}return n.push(uE(t)),n.filter(r=>!!r).join("
")},group:t=>t.toString().replace(/Model [0-9]+/g,"Models"),priority:100}}},display:{name:"Provide Default Loci Label"}}),Jue={clickFocus:At([R0(M0.Flag.Primary,Tm.create())],"Representation Focus","Click element using ${triggers}"),clickFocusAdd:At([R0(M0.Flag.Primary,Tm.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}")},zit={bindings:C.Value(Jue,{isHidden:!0})},Git=tr.create({name:"representation-focus-loci",category:"interaction",ctor:class extends tr.Handler{register(){this.subscribeObservable(this.ctx.behaviors.interaction.click,({current:e,button:t,modifiers:n})=>{var r,i,o,s,a;const{clickFocus:c,clickFocusAdd:u,clickFocusSelectMode:l,clickFocusAddSelectMode:d}=this.params.bindings,p=At.match(this.ctx.selectionMode?l:c,t,n),m=null!==(s=null===(o=null===(i=null===(r=e.repr)||void 0===r?void 0:r.props)||void 0===i?void 0:i.snapshotKey)||void 0===o?void 0:o.trim())&&void 0!==s?s:"";if(!this.ctx.selectionMode&&p&&m)return void this.ctx.managers.snapshot.applyKey(m);const{granularity:h}=this.ctx.managers.interactivity.props;if("residue"!==h&&"element"!==h)return;const y=At.match(this.ctx.selectionMode?d:u,t,n);if(!p&&!y)return;const b=pn.normalize(e.loci,"residue"),x=this.ctx.managers.structure.focus.current;if(x&&pn.areEqual(x.loci,b))this.ctx.managers.structure.focus.clear();else if(p)this.ctx.managers.structure.focus.setFromLoci(b);else{this.ctx.managers.structure.focus.addFromLoci(b);const _=null===(a=this.ctx.managers.structure.focus.current)||void 0===a?void 0:a.loci;_&&this.ctx.managers.camera.focusLoci(_)}})}},params:()=>zit,display:{name:"Representation Focus Loci on Canvas"}}),Tf=Zi,hd=wu,Df=At.Trigger,RE=At.TriggerKey,q8=At([Df(Tf.Flag.Primary,hd.create()),Df(Tf.Flag.Secondary,hd.create()),Df(Tf.Flag.Primary,hd.create({control:!0}))],"Reset camera focus","Click on nothing using ${triggers}"),W8=At([Df(Tf.Flag.Secondary,hd.create()),Df(Tf.Flag.Primary,hd.create({control:!0}))],"Reset camera focus","Click on nothing using ${triggers}"),ele={clickCenterFocus:At([Df(Tf.Flag.Primary,hd.create()),Df(Tf.Flag.Secondary,hd.create()),Df(Tf.Flag.Primary,hd.create({control:!0}))],"Camera center and focus","Click element using ${triggers}"),clickCenterFocusSelectMode:At([Df(Tf.Flag.Secondary,hd.create()),Df(Tf.Flag.Primary,hd.create({control:!0}))],"Camera center and focus","Click element using ${triggers}"),clickResetCameraOnEmpty:q8,clickResetCameraOnEmptySelectMode:W8},jit={minRadius:C.Numeric(8,{min:1,max:50,step:1}),extraRadius:C.Numeric(4,{min:1,max:50,step:1},{description:"Value added to the bounding-sphere radius of the Loci"}),durationMs:C.Numeric(250,{min:0,max:1e3,step:1},{description:"Camera transition duration"}),bindings:C.Value(ele,{isHidden:!0})},Hit=tr.create({name:"camera-focus-loci",category:"interaction",ctor:class extends tr.Handler{register(){this.subscribeObservable(this.ctx.behaviors.interaction.click,({current:e,button:t,modifiers:n})=>{var r,i;if(!this.ctx.canvas3d)return;const o=this.ctx.selectionMode?this.params.bindings.clickCenterFocusSelectMode:this.params.bindings.clickCenterFocus,s=this.ctx.selectionMode?null!==(r=this.params.bindings.clickResetCameraOnEmptySelectMode)&&void 0!==r?r:W8:null!==(i=this.params.bindings.clickResetCameraOnEmpty)&&void 0!==i?i:q8;if(pn.isEmpty(e.loci)&&At.match(s,t,n))Cn.Camera.Reset(this.ctx,{});else if(At.match(o,t,n)){const a=pn.normalize(e.loci,this.ctx.managers.interactivity.props.granularity);this.ctx.managers.camera.focusLoci(a,this.params)}})}},params:()=>jit,display:{name:"Camera Focus Loci on Canvas"}}),qit=tr.create({name:"camera-axis-helper",category:"interaction",ctor:class extends tr.Handler{register(){let e=Cr.None,t=0;this.subscribeObservable(this.ctx.behaviors.interaction.click,({current:n})=>{if(!this.ctx.canvas3d||!O8(n.loci))return;const r=n.loci.elements[0].groupId;if(r===Cr.None)return e=Cr.None,void(t=0);const{camera:i}=this.ctx.canvas3d;let o,s;if(r>=Cr.X&&r<=Cr.Z){e=Cr.None,t=0;const a=v.sub(v(),i.target,i.position),c=v.cross(v(),a,i.up);s=v(),s[r-1]=1,o=v.cross(v(),s,c),0===v.magnitude(o)&&(o=a)}else e===r?t=(t+1)%2:(e=r,t=0),r===Cr.XY?(s=t?v.unitX:v.unitY,o=v.negUnitZ):r===Cr.XZ?(s=t?v.unitX:v.unitZ,o=v.negUnitY):(s=t?v.unitY:v.unitZ,o=v.negUnitX);this.ctx.canvas3d.requestCameraReset({snapshot:(a,c)=>c.getInvariantFocus(a.boundingSphereVisible.center,a.boundingSphereVisible.radius,s,o)})})}},params:()=>({}),display:{name:"Camera Axis Helper"}}),tle={keySpinAnimation:At([RE("I")],"Spin Animation","Press ${triggers}"),keyRockAnimation:At([RE("O")],"Rock Animation","Press ${triggers}"),keyToggleFlyMode:At([RE("Space",hd.create({shift:!0}))],"Toggle Fly Mode","Press ${triggers}"),keyResetView:At([RE("T")],"Reset View","Press ${triggers}")},Wit={bindings:C.Value(tle,{isHidden:!0})},$it=tr.create({name:"camera-controls",category:"interaction",ctor:class extends tr.Handler{register(){this.subscribeObservable(this.ctx.behaviors.interaction.key,({code:e,key:t,modifiers:n})=>{var r;if(!this.ctx.canvas3d)return;const i={...tle,...this.params.bindings},o=this.ctx.canvas3d.props.trackball;if(At.matchKey(i.keySpinAnimation,e,n,t)){const s="spin"!==o.animate.name?"spin":"off";this.ctx.canvas3d.setProps("off"===s?{trackball:{animate:{name:s,params:{}}}}:{trackball:{animate:{name:s,params:{speed:1}}}})}if(At.matchKey(i.keyRockAnimation,e,n,t)){const s="rock"!==o.animate.name?"rock":"off";this.ctx.canvas3d.setProps("off"===s?{trackball:{animate:{name:s,params:{}}}}:{trackball:{animate:{name:s,params:{speed:.3,angle:10}}}})}if(At.matchKey(i.keyToggleFlyMode,e,n,t)){const s=!o.flyMode;this.ctx.canvas3d.setProps({trackball:{flyMode:s}}),null!==(r=this.ctx.canvas3dContext)&&void 0!==r&&r.canvas&&(this.ctx.canvas3dContext.canvas.style.cursor=s?"crosshair":"unset")}At.matchKey(i.keyResetView,e,n,t)&&Cn.Camera.Reset(this.ctx,{})})}},params:()=>Wit,display:{name:"Camera Controls on Canvas"}}),Yit=tr.create({name:"structure-info-prop",category:"custom-props",display:{name:"Structure Info"},ctor:class extends tr.Handler{get maxModelIndex(){var e,t;let n=-1;const r=this.ctx.state.data.select(In.Generators.rootsOfType(pe.Molecule.Model));for(const i of r){const o=(null===(e=i.obj)||void 0===e?void 0:e.data)&&sn.Index.get(null===(t=i.obj)||void 0===t?void 0:t.data).value;void 0!==o&&o>n&&(n=o)}return n}get maxStructureIndex(){var e,t;let n=-1;const r=this.ctx.state.data.select(In.Generators.rootsOfType(pe.Molecule.Structure));for(const i of r){const o=(null===(e=i.obj)||void 0===e?void 0:e.data)&&Ve.Index.get(null===(t=i.obj)||void 0===t?void 0:t.data).value;void 0!==o&&o>n&&(n=o)}return n}get asymIdOffset(){var e;let t=0,n=0;const r=this.ctx.state.data.select(In.Generators.rootsOfType(pe.Molecule.Model));for(const i of r){const o=null===(e=i.obj)||void 0===e?void 0:e.data;if(o){const s=sn.AsymIdCount.get(o),a=sn.AsymIdOffset.get(o).value;void 0!==s&&void 0!==a&&(t=Math.max(t,a.auth+s.auth),n=Math.max(n,a.label+s.label))}}return{auth:t,label:n}}setModelMaxIndex(){var e;const t=this.maxModelIndex,n=this.ctx.state.data.select(In.Generators.rootsOfType(pe.Molecule.Model));for(const r of n){const i=null===(e=r.obj)||void 0===e?void 0:e.data;i&&sn.MaxIndex.get(i).value!==t&&sn.MaxIndex.set(i,{value:t},t)}}setStructureMaxIndex(){var e;const t=this.maxModelIndex,n=this.ctx.state.data.select(In.Generators.rootsOfType(pe.Molecule.Structure));for(const r of n){const i=null===(e=r.obj)||void 0===e?void 0:e.data;i&&Ve.MaxIndex.get(i).value!==t&&Ve.MaxIndex.set(i,{value:t},t)}}handleModel(e,t){if(void 0===sn.Index.get(e).value){const r=(t&&sn.Index.get(t).value)??this.maxModelIndex+1;sn.Index.set(e,{value:r},r)}if(void 0===sn.AsymIdOffset.get(e).value){const r=(t&&sn.AsymIdOffset.get(t).value)??{...this.asymIdOffset};sn.AsymIdOffset.set(e,{value:r},r)}}handleStructure(e,t){if(void 0!==e.parent||void 0!==Ve.Index.get(e).value)return;const r=(t&&Ve.Index.get(t).value)??this.maxStructureIndex+1;Ve.Index.set(e,{value:r},r)}handle(e,t,n){pe.Molecule.Structure.is(t)?!this.ctx.state.data.tree.transforms.get(e).transformer.definition.isDecorator&&void 0===t.data.parent&&this.handleStructure(t.data,n?.data):pe.Molecule.Model.is(t)&&(this.ctx.state.data.tree.transforms.get(e).transformer.definition.isDecorator||this.handleModel(t.data,n?.data))}register(){this.ctx.customModelProperties.register(sn.AsymIdOffset,!0),this.ctx.customModelProperties.register(sn.Index,!0),this.ctx.customModelProperties.register(sn.MaxIndex,!0),this.ctx.customStructureProperties.register(Ve.Index,!0),this.ctx.customStructureProperties.register(Ve.MaxIndex,!0),this.subscribeObservable(this.ctx.state.data.events.object.created,e=>{this.handle(e.ref,e.obj),this.setModelMaxIndex(),this.setStructureMaxIndex()}),this.subscribeObservable(this.ctx.state.data.events.object.updated,e=>{this.handle(e.ref,e.obj,e.oldObj)})}unregister(){this.ctx.customModelProperties.unregister(sn.AsymIdOffset.descriptor.name),this.ctx.customModelProperties.unregister(sn.Index.descriptor.name),this.ctx.customModelProperties.unregister(sn.MaxIndex.descriptor.name),this.ctx.customStructureProperties.unregister(Ve.Index.descriptor.name),this.ctx.customStructureProperties.unregister(Ve.MaxIndex.descriptor.name)}}}),Dm=[-1,1.76,1.87,1.65,1.5,1.4,1.85,1.8,1.6,1.4],nle={ALA:121,ARG:265,ASN:187,ASP:187,CYS:148,GLU:214,GLN:214,GLY:97,HIS:216,ILE:195,LEU:191,LYS:230,MET:203,PHE:228,PRO:154,SER:143,THR:163,TRP:264,TYR:255,VAL:165};function Zit(e,t,n){switch(t){case"O":return 5;case"S":return 6;case"N":return"NZ"===e?4:3;case"C":switch(e){case"C":case"CE1":case"CE2":case"CE3":case"CH2":case"CZ":case"CZ2":case"CZ3":return 1;case"CA":case"CB":case"CE":case"CG1":case"CG2":return 2;default:switch(n){case"PHE":case"TRP":case"TYR":case"HIS":case"ASP":case"ASN":return 1;case"PRO":case"LYS":case"ARG":case"MET":case"ILE":case"LEU":return 2;case"GLU":case"GLN":return"CD"===e?1:2}}}return $8(t)}function Qit(e,t,n){switch(t){case"C":return 7;case"N":return 8;case"P":return 9;case"O":return 5}return $8(t)}function $8(e){const t=v2(e);let n=Dm.indexOf(t);return-1===n&&(n=Dm.length,Dm[n]=t),n}function Y8(){return Y8=ie(function*(e,t){const{atomRadiusType:n}=t;for(let r=0;rG[0]-L[0]);let F=0;e:for(let G=0;G$)continue e}++F}s[o[b]]+=c*F*M*M}}const ile={numberOfSpherePoints:C.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:C.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:C.Boolean(!1,{description:"Include non-polymer atoms as occluders."}),traceOnly:C.Boolean(!1,{description:"Compute only using alpha-carbons, if true increase probeSize accordingly (e.g., 4 A). Considers only canonical amino acids."})};var Qv;!function(e){function r(){return r=ie(function*(l,d,f){const p=function i(l,d){const{elementCount:f,atomicResidueCount:p}=l,{probeSize:m,nonPolymer:h,traceOnly:g,numberOfSpherePoints:y}=d;return{structure:l,probeSize:m,nonPolymer:h,traceOnly:g,spherePoints:o(y),scalingConstant:4*Math.PI/y,maxLookupRadius:2*d.probeSize+2*Dm[2],atomRadiusType:new Int8Array(f),serialResidueIndex:new Int32Array(f),area:new Float32Array(p)}}(d,f);(function Kit(e){const{key:t}=Ze.residue,{type_symbol:n,label_atom_id:r,label_comp_id:i}=Ze.atom,{structure:o,atomRadiusType:s,serialResidueIndex:a}=e,c=nt.create(o);let u=0,l=0,d=-1;c.structure=o;for(let f=0,p=0,m=o.units.length;f{if(!Ee.isAtomic(e.element.unit))return!1;const t=vl.get(e.element.structure).value;return!!t&&1===Qv.getFlag(e.element,t)}),isAccessible:Nv.Dynamic(IQ("computed","accessible-surface-area.is-accessible",Ae.Bool),e=>{if(!Ee.isAtomic(e.element.unit))return!1;const t=vl.get(e.element.structure).value;return!!t&&2===Qv.getFlag(e.element,t)})},vl=vp.createProvider({label:"Accessible Surface Area",descriptor:au({name:"molstar_accessible_surface_area",symbols:K8}),type:"root",defaultParams:X8,getParams:e=>X8,isApplicable:e=>!0,obtain:function(){var e=ie(function*(t,n,r){const i={...C.getDefaultValues(X8),...r};return{value:yield Qv.compute(n,i).runInContext(t.runtime)}});return function(n,r,i){return e.apply(this,arguments)}}()}),Z8=st(16448250),ole={list:C.ColorList("rainbow",{presetKind:"scale"})},ale={name:"accessible-surface-area",label:"Accessible Surface Area",category:Lc.Category.Residue,factory:function sle(e,t){let n;const r=Gu.create({listOrName:t.list.colors,minLabel:"buried",maxLabel:"exposed",domain:[0,1]}),i=e.structure&&vl.get(e.structure),o=i?Pg(i.id,i.version):-1;if(i?.value&&e.structure){const s=nt.create(e.structure),a=i.value,c=u=>{const l=Qv.getNormalizedValue(u,a);return-1===l?Z8:r.color(l)};n=u=>nt.is(u)&&Ee.isAtomic(u.unit)?c(u):Lt.isLocation(u)?(s.unit=u.aUnit,s.element=u.aUnit.elements[u.aIndex],c(s)):Z8}else n=()=>Z8;return{factory:sle,granularity:"group",preferSmoothing:!0,color:n,props:t,contextHash:o,description:"Assigns a color based on the relative accessible surface area of a residue.",legend:r?r.legend:void 0}},getParams:function not(e){return ole},defaultValues:C.getDefaultValues(ole),isApplicable:e=>!!e.structure,ensureCustomProperties:{attach:(e,t)=>t.structure?vl.attach(e,t.structure,void 0,!0):Promise.resolve(),detach:e=>e.structure&&vl.ref(e.structure,!1)}},rot=tr.create({name:"computed-accessible-surface-area-prop",category:"custom-props",display:{name:"Accessible Surface Area"},ctor:class extends tr.Handler{constructor(){super(...arguments),this.provider=vl,this.labelProvider={label:e=>{if(this.params.showTooltip)return function iot(e){if("element-loci"===e.kind){if(0===e.elements.length)return;const t=vl.get(e.structure).value;if(!t||e.structure.customPropertyDescriptors.hasReference(vl.descriptor))return;const{getSerialIndex:n}=e.structure.root.serialMapping,{area:r,serialResidueIndex:i}=t,o=new Set;let s=0;for(const{indices:c,unit:u}of e.elements){const{elements:l}=u;Fe.forEach(c,d=>{const f=i[n(u,l[d])];-1!==f&&!o.has(f)&&(s+=r[f],o.add(f))})}return 0===o.size?void 0:`Accessible Surface Area (${o.size} ${o.size>1?"Residues sum":"Residue"}): ${s.toFixed(2)} \u212b2`}if("structure-loci"===e.kind){const t=vl.get(e.structure).value;return!t||e.structure.customPropertyDescriptors.hasReference(vl.descriptor)?void 0:`Accessible Surface Area (Whole Structure): ${OZ(t.area).toFixed(2)} \u212b2`}}(e)}}}update(e){const t=this.params.autoAttach!==e.autoAttach||this.params.showTooltip!==e.showTooltip;return this.params.autoAttach=e.autoAttach,this.params.showTooltip=e.showTooltip,this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name,this.params.autoAttach),t}register(){jD.addCustomProp(this.provider.descriptor),this.ctx.customStructureProperties.register(this.provider,this.params.autoAttach),this.ctx.representation.structure.themes.colorThemeRegistry.add(ale),this.ctx.managers.lociLabels.addProvider(this.labelProvider),this.ctx.query.structure.registry.add(cle),this.ctx.query.structure.registry.add(ule)}unregister(){jD.removeCustomProp(this.provider.descriptor),this.ctx.customStructureProperties.unregister(this.provider.descriptor.name),this.ctx.representation.structure.themes.colorThemeRegistry.remove(ale),this.ctx.managers.lociLabels.removeProvider(this.labelProvider),this.ctx.query.structure.registry.remove(cle),this.ctx.query.structure.registry.remove(ule)}},params:()=>({autoAttach:C.Boolean(!1),showTooltip:C.Boolean(!0)})}),cle=lr("Buried Protein Residues",ue.struct.modifier.union([ue.struct.modifier.wholeResidues([ue.struct.modifier.union([ue.struct.generator.atomGroups({"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":K8.isBuried.symbol()})])])]),{description:"Select buried protein residues.",category:pr.Residue,ensureCustomProperties:(e,t)=>vl.attach(e,t)}),ule=lr("Accessible Protein Residues",ue.struct.modifier.union([ue.struct.modifier.wholeResidues([ue.struct.modifier.union([ue.struct.generator.atomGroups({"chain-test":ue.core.rel.eq([ue.ammp("objectPrimitive"),"atomistic"]),"residue-test":K8.isAccessible.symbol()})])])]),{description:"Select accessible protein residues.",category:pr.Residue,ensureCustomProperties:(e,t)=>vl.attach(e,t)});function or(e,t){return e.model.atomicHierarchy.atoms.type_symbol.value(e.elements[t])}function lle(e,t){return e.model.atomicHierarchy.atoms.pdbx_formal_charge.value(e.elements[t])}function tC(e,t){return e.model.atomicHierarchy.atoms.label_atom_id.value(e.elements[t])}function kE(e,t){return e.model.atomicHierarchy.atoms.label_alt_id.value(e.elements[t])}function Q8(e,t){return e.model.atomicHierarchy.atoms.label_comp_id.value(e.elements[t])}function Ef(e,t,n){return function oot(e,t,n){let r=0;const i=e.interUnitBonds.getEdgeIndices(n,t.id);for(let o=0,s=i.length;o{or(o,s)===r&&(i+=1)}),i}function J8(e,t,n){const{offset:r,b:i,edgeProps:{flags:o}}=e.bonds;for(let s=r[t],a=r[t+1];s{"H"!==or(s,a)&&(s.conformation.position(s.elements[a],e1),v.sub(FE,e1,k0),o.push(v.angle(NE,FE)))}),o}function fle(e,t,n,r,i){t.conformation.position(t.elements[n],k0),r.conformation.position(r.elements[i],BE),v.sub(NE,BE,k0);const o=[v(),v()];let a,c,s=0;if(dc(e,t,n,(u,l)=>{s>1||"H"!==or(u,l)&&(a=u,c=l,u.conformation.position(u.elements[l],e1),v.sub(o[s++],e1,k0))}),1===s&&a&&c&&dc(e,a,c,(u,l)=>{s>1||u===t&&l===n||"H"!==or(u,l)&&(u.conformation.position(u.elements[l],e1),v.sub(o[s++],e1,k0))}),2===s)return v.cross(FE,o[0],o[1]),Math.abs(Math.PI/2-v.angle(FE,NE))}const eU=new Lt.ElementBondIterator,tU=new Lt.ElementBondIterator,t1=new Lt.ElementBondIterator,nU=new Lt.ElementBondIterator;function hot(e,t,n,r){const i=lc(e,t,n,"H"),o=or(t,n);let s=lle(t,n);const a="always"===r.assignCharge||"auto"===r.assignCharge&&0===s,c="always"===r.assignH||"auto"===r.assignH&&0===i,u=Ef(e,t,n),l=function pot(e,t,n){let r=0;const{offset:i,edgeProps:{flags:o,order:s}}=t.bonds;for(let a=i[n],c=i[n+1];a{const c=e.interUnitBonds.edges[a];jn.isCovalent(c.props.flag)&&(r+=c.props.order)}),r}(e,t,n),d=function fot(e,t,n){const r=or(t,n),i="O"===r||"N"===r;if(i&&4===Ef(e,t,n))return!1;for(eU.setElement(e,t,n);eU.hasNext;){const o=eU.move();if(o.order>1)return!0;if(i){const s=or(o.otherUnit,o.otherIndex);for(tU.setElement(e,o.otherUnit,o.otherIndex);tU.hasNext;){const a=tU.move();if(a.order>1){if(("P"===s||"S"===s)&&"O"===or(a.otherUnit,a.otherIndex))continue;return!0}}}}return!1}(e,t,n),f=l-u>0;let p=0,m=wi.Unknown;switch(o){case"H":a&&(0===u?(s=1,m=wi.Spherical):1===u&&(s=0,m=wi.Terminal));break;case"C":a&&(s=0),c&&(p=Math.max(0,4-l-Math.abs(s))),m=Jv(u+p+Math.max(0,-s));break;case"N":if(a)if(c)if(d&&l<4)s=u-i==1&&l-i==2?1:0;else for(t1.setElement(e,t,n);t1.hasNext;){const h=t1.move(),g=or(h.otherUnit,h.otherIndex);if("S"===g||C$e(g)){s=0;break}s=1}else s=l-3;c&&(p=Math.max(0,3-l+s)),m=Jv(d&&!f?u+p-s:u+p+1-s);break;case"O":if(a&&(c||(s=l-2),1===l)){t1.setElement(e,t,n);e:for(;t1.hasNext;){const h=t1.move();for(nU.setElement(e,h.otherUnit,h.otherIndex);nU.hasNext;){const g=nU.move();if((g.otherUnit!==t||g.otherIndex!==n)&&"O"===or(g.otherUnit,g.otherIndex)&&2===g.order){s=-1;break e}}}}c&&(p=Math.max(0,2-l+s)),m=Jv(d&&!f?u+p-s+1:u+p-s+2);break;case"S":a&&(c||(s=l<=3&&0===lc(e,t,n,"O")?l-2:0)),c&&l<2&&(p=Math.max(0,2-l+s)),l<=3&&(m=Jv(u+p-s+2));break;case"F":case"CL":case"BR":case"I":case"AT":a&&(s=l-1);break;case"LI":case"NA":case"K":case"RB":case"CS":case"FR":a&&(s=1-l);break;case"BE":case"MG":case"CA":case"SR":case"BA":case"RA":a&&(s=2-l);break;default:un&&console.warn("Requested charge, protonation for an unhandled element",o)}return[s,p,p+i,m]}function mot(e,t,n){const r=t.elements.length,i=new Int8Array(r),o=new Int8Array(r),s=new Int8Array(r),a=new Int8Array(r),c=!!e.parent;let u;if(c){const l=e.root.unitMap.get(t.id);if(u=je.indicesOf(l.elements,t.elements),u.length!==t.elements.length)throw new Error("expected to find an index for every element");t=l,e=e.root}for(let l=0;liU,isApplicable:e=>!0,obtain:function(){var e=ie(function*(t,n,r){const i={...C.getDefaultValues(iU),...r};return{value:yield got(t.runtime,n,i)}});return function(n,r,i){return e.apply(this,arguments)}}()});var Ai,oU,sU;!function(e){function n(d,f){const p=new Int32Array(f+1),m=new Int32Array(f),h=new Int32Array(f),{members:g,count:y,offsets:b}=d;for(let S=0,A=b[y];Si(f,h)}},e.createSubset=i,e.Info=function o(d,f,p){const m=nC.get(d).value;if(!m||!m.has(f.id))throw new Error("valence model required");return{unit:f,types:p.types,feature:-1,x:p.x,y:p.y,z:p.z,members:p.members,offsets:p.offsets,idealGeometry:m.get(f.id).idealGeometry}},e.position=function s(d,f){return v.set(d,f.x[f.feature],f.y[f.feature],f.z[f.feature]),v.transformMat4(d,d,f.unit.conformation.operator.matrix),d};const a=v(),c=v();e.distance=function u(d,f){const m=f.members[f.offsets[f.feature]];return d.unit.conformation.position(d.unit.elements[d.members[d.offsets[d.feature]]],a),f.unit.conformation.position(f.unit.elements[m],c),v.distance(a,c)},e.Provider=function l(d,f){return{types:new Set(d),add:f}}}(Ai||(Ai={})),function(e){e.create=function t(n=2048,r=1024,i){const o=ze.create(Float32Array,1,r,i?i.x:n),s=ze.create(Float32Array,1,r,i?i.y:n),a=ze.create(Float32Array,1,r,i?i.z:n),c=ze.create(Uint8Array,1,r,i?i.types:n),u=ze.create(Uint8Array,1,r,i?i.groups:n),l=ze.create(Uint32Array,1,r,i?i.offsets:n),d=ze.create(Uint32Array,1,r,i?i.members:n),f={x:0,y:0,z:0,offset:0,count:0};return{startState:()=>{f.x=0,f.y=0,f.z=0,f.offset=d.elementCount,f.count=0},pushMember:(p,m,h,g)=>{ze.add(d,g),f.x+=p,f.y+=m,f.z+=h,f.count+=1},finishState:(p,m)=>{const{count:h}=f;0!==h&&(ze.add(c,p),ze.add(u,m),ze.add(o,f.x/h),ze.add(s,f.y/h),ze.add(a,f.z/h),ze.add(l,f.offset))},add:(p,m,h,g,y,b)=>{ze.add(c,p),ze.add(u,m),ze.add(o,h),ze.add(s,g),ze.add(a,y),ze.add(l,d.elementCount),ze.add(d,b)},getFeatures:p=>{ze.add(l,d.elementCount);const m=ze.compact(o,!0),h=ze.compact(s,!0),g=ze.compact(a,!0);return Ai.create(p,{x:m,y:h,z:g,count:o.elementCount,types:ze.compact(c,!0),groups:ze.compact(u,!0),offsets:ze.compact(l,!0),members:ze.compact(d,!0)})}}}}(oU||(oU={})),function(e){e.createElementsIndex=function t(n,r,i){const o=new Int32Array(i+1),s=new Int32Array(i),a=new Int32Array(i),{members:c,offsets:u}=r;for(let f=0,p=2*n.edgeCount;fh)){for(let g=u[m],y=u[m+1];gh)){for(let g=u[m],y=u[m+1];gd||(d=sU.createElementsIndex(l,n,r))})}}}}(aU||(aU={})),function(e){e.create=function t(){const n=new ju.Builder;return{startUnitPair(r,i){n.startUnitPair(r.id,i.id)},finishUnitPair(){n.finishUnitPair()},add(r,i,o){n.add(r,i,{type:o,flag:Pf.None})},getContacts:r=>new yot(n.getMap(),r)}}}(cU||(cU={}));const xot={lineOfSightDistFactor:C.Numeric(1,{min:0,max:3,step:.1})},Sot=3;function mle(e,t,n){const r=t.members[t.offsets[t.feature]],i=n.members[n.offsets[n.feature]];if(r===i&&t.unit===n.unit)return!1;const o=kE(t.unit,r),s=kE(n.unit,i);return!(o&&s&&o!==s||t.unit===n.unit&&t.unit.model.atomicHierarchy.residueAtomSegments.count>1&&t.unit.residueIndex[t.unit.elements[r]]===n.unit.residueIndex[n.unit.elements[i]]||function uot(e,t,n,r,i){return t===r?function aot(e,t,n){const{offset:r,b:i,edgeProps:{flags:o}}=e.bonds;for(let s=r[t],a=r[t+1];s{Rot.includes(or(d,f))&&(l=!0)}),l&&n.add(7,Ir.None,i[r[a]],o[r[a]],s[r[a]],a)}}}),zot={name:"halogen-bonds",params:Dot,createTester:e=>{const t=function Oot(e){return{angleMax:Yn(e.angleMax)}}(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([6,7]),getType:(n,r,i)=>function Lot(e,t,n,r){const i=t.types[t.feature];if(!function Not(e,t){return 7===e&&6===t||6===e&&7===t}(i,n.types[n.feature]))return;const[s,a]=6===i?[t,n]:[n,t],c=s.members[s.offsets[s.feature]],u=a.members[a.offsets[a.feature]],l=OE(e,s.unit,c,a.unit,u);if(1!==l.length||Fot-l[0]>r.angleMax)return;const d=OE(e,a.unit,u,s.unit,c);return 0===d.length||d.some(f=>Bot-f>r.angleMax)?void 0:kn.HalogenBond}(n,r,i,t)}}},vle={distanceMax:C.Numeric(3.5,{min:1,max:5,step:.1}),backbone:C.Boolean(!0,{description:"Include backbone-to-backbone hydrogen bonds"}),accAngleDevMax:C.Numeric(45,{min:0,max:180,step:1},{description:"Max deviation from ideal acceptor angle"}),donAngleDevMax:C.Numeric(45,{min:0,max:180,step:1},{description:"Max deviation from ideal donor angle"}),accOutOfPlaneAngleMax:C.Numeric(90,{min:0,max:180,step:1}),donOutOfPlaneAngleMax:C.Numeric(45,{min:0,max:180,step:1})},Got={...vle,water:C.Boolean(!1,{description:"Include water-to-water hydrogen bonds"}),sulfurDistanceMax:C.Numeric(4.1,{min:1,max:5,step:.1})},jot={...vle};function dU(e,t){const n=nC.get(e).value;if(!n)throw Error("expected valence model to be available");const r=n.get(t.id);if(!r)throw Error("expected valence model for unit to be available");return r}function Wot(e,t){const{elementAromaticRingIndices:n,all:r}=e.rings,i=n.get(t);if(void 0===i)return!1;for(let o=0,s=i.length;oMath.abs(a-l)>r.maxDonAngleDev))return;if(t.idealGeometry[i]===wi.Trigonal){const l=fle(e,t.unit,i,n.unit,o);if(void 0!==l&&l>r.maxDonOutOfPlaneAngle)return}const c=OE(e,n.unit,o,t.unit,i),u=dle.get(n.idealGeometry[o])||wle;if(!c.some(l=>u-l>r.maxAccAngleDev)){if(n.idealGeometry[o]===wi.Trigonal){const l=fle(e,n.unit,o,t.unit,i);if(void 0!==l&&l>r.maxAccOutOfPlaneAngle)return}return!0}}const nst=Ai.Provider([4],function Hot(e,t,n){const{totalH:r}=dU(e,t),{elements:i}=t,{x:o,y:s,z:a}=t.model.atomicConformation;for(let c=0,u=i.length;c0&&("N"===l||"O"===l||"S"===l))&&n.add(4,Ir.None,o[i[c]],s[i[c]],a[i[c]],c)}}),rst=Ai.Provider([9],function qot(e,t,n){const{totalH:r}=dU(e,t),{elements:i}=t,{x:o,y:s,z:a}=t.model.atomicConformation;for(let c=0,u=i.length;c0&&(lc(e,t,c,"N")>0||lc(e,t,c,"O")>0||Wot(t,c))&&n.add(9,Ir.None,o[i[c]],s[i[c]],a[i[c]],c)}),ist=Ai.Provider([5],function $ot(e,t,n){const{charge:r,implicitH:i,idealGeometry:o}=dU(e,t),{elements:s}=t,{x:a,y:c,z:u}=t.model.atomicConformation,l=d=>{n.add(5,Ir.None,a[s[d]],c[s[d]],u[s[d]],d)};for(let d=0,f=s.length;d{const t=Math.max(e.distanceMax,e.sulfurDistanceMax),n=function Jot(e){return{...Cle(e),includeWater:e.water,maxSulfurDistSq:e.sulfurDistanceMax*e.sulfurDistanceMax,maxDistSq:e.distanceMax*e.distanceMax}}(e);return{maxDistance:t,requiredFeatures:new Set([4,5]),getType:(r,i,o,s)=>function est(e,t,n,r,i){const s=n.types[n.feature];if(!function Zot(e,t){return 5===e&&4===t||4===e&&5===t}(t.types[t.feature],s))return;const[a,c]=5===s?[t,n]:[n,t],u=a.members[a.offsets[a.feature]],l=c.members[c.offsets[c.feature]];return r>("S"===or(a.unit,u)||"S"===or(c.unit,l)?i.maxSulfurDistSq:i.maxDistSq)||!i.includeWater&&function Kot(e,t,n,r){return _le(e,t)&&_le(n,r)}(a.unit,u,c.unit,l)||!Ale(e,a,c,i)?void 0:kn.HydrogenBond}(r,i,o,s,n)}}},sst={name:"weak-hydrogen-bonds",params:jot,createTester:e=>{const t=Cle(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([9,5]),getType:(n,r,i,o)=>function tst(e,t,n,r,i){const s=n.types[n.feature];if(!function Qot(e,t){return 9===e&&5===t||5===e&&9===t}(t.types[t.feature],s))return;const[a,c]=5===s?[t,n]:[n,t];return Ale(e,a,c,i)?kn.WeakHydrogenBond:void 0}(n,r,i,0,t)}}};function cst(e,t,n){return"S"===or(t,n)&&3===lc(e,t,n,"O")}function ust(e,t,n){return"S"===or(t,n)&&4===lc(e,t,n,"O")}function Tle(e,t,n){return"P"===or(t,n)&&lc(e,t,n,"O")===Ef(e,t,n)}function dst(e,t,n){let r=0;return"C"===or(t,n)&&2===lc(e,t,n,"O")&&1===lc(e,t,n,"C")&&dc(e,t,n,(i,o)=>{"O"===or(i,o)&&Ef(e,i,o)-lc(e,i,o,"H")==1&&(r+=1)}),2===r}function fst(e,t,n){let r=0;return"C"===or(t,n)&&3===Ef(e,t,n)&&3===lc(e,t,n,"N")&&dc(e,t,n,(i,o)=>{Ef(e,i,o)-lc(e,i,o,"H")==1&&(r+=1)}),2===r}function pst(e,t,n){let r=0;return"C"===or(t,n)&&3===Ef(e,t,n)&&2===lc(e,t,n,"N")&&1===lc(e,t,n,"C")&&dc(e,t,n,(i,o)=>{Ef(e,i,o)-lc(e,i,o,"H")==1&&(r+=1)}),2===r}const hst=new Set(["N","O","S","F","CL","BR","I"]);const yst={distanceMax:C.Numeric(5,{min:0,max:8,step:.1})},bst={distanceMax:C.Numeric(5.5,{min:1,max:8,step:.1}),offsetMax:C.Numeric(2,{min:0,max:4,step:.1}),angleDevMax:C.Numeric(30,{min:0,max:180,step:1})},vst={distanceMax:C.Numeric(6,{min:1,max:8,step:.1}),offsetMax:C.Numeric(2,{min:0,max:4,step:.1})},_st=["ARG","HIS","LYS"],xst=["GLU","ASP"];function Dle(e,t){const n=nC.get(e).value;if(!n)throw Error("expected valence model to be available");const r=n.get(t.id);if(!r)throw Error("expected valence model for unit to be available");return r}const Ele=v(),Ple=v(),LE=v(),n1=v(),UE=v(),VE=v();function fU(e,t){const{unit:n,feature:r,offsets:i,members:o}=t,{elements:s}=n,a=i[r];return t.unit.conformation.position(s[o[a]],LE),t.unit.conformation.position(s[o[a+1]],n1),t.unit.conformation.position(s[o[a+2]],UE),v.triangleNormal(e,LE,n1,UE)}const pU=function(e,t,n){return Ai.position(LE,e),Ai.position(n1,t),v.sub(UE,LE,n1),v.projectOnPlane(VE,UE,n),v.add(VE,VE,n1),v.distance(VE,n1)},Rst=Yn(180),Mle=Yn(90),rC=v(),hU=v();const Bst=Ai.Provider([2],function Cst(e,t,n){const{charge:r}=Dle(e,t),{elements:i}=t,{x:o,y:s,z:a}=t.model.atomicConformation,c=new Set,{label_comp_id:u}=t.model.atomicHierarchy.atoms,l=en.transientSegments(t.model.atomicHierarchy.residueAtomSegments,i);for(;l.hasNext;){const{index:d,start:f,end:p}=l.move(),m=u.value(t.model.atomicHierarchy.residueAtomSegments.offsets[d]);if(xst.includes(m)){n.startState();for(let h=f;h{"O"===or(t,y)&&n.pushMember(o[i[y]],s[i[y]],a[i[y]],y)}),n.finishState(2,Ir.Phosphate));else if(!$b.has(m)){for(let h=f;h{"O"===or(t,b)&&(c.add(b),n.pushMember(o[i[b]],s[i[b]],a[i[b]],b))}),n.finishState(2,g))}for(let h=f;h{"N"===or(t,b)&&(c.add(b),n.pushMember(o[i[b]],s[i[b]],a[i[b]],b))}),n.finishState(1,g))}for(let h=f;h0&&!c.has(h)&&n.add(1,Ir.None,o[i[h]],s[i[h]],a[i[h]],h)}}}),Lst=Ai.Provider([3],function wst(e,t,n){const{elements:r}=t,{x:i,y:o,z:s}=t.model.atomicConformation;for(const a of t.rings.aromaticRings){const c=t.rings.all[a];n.startState();for(let u=0,l=c.length;u{const t=function Est(e){return{distanceMaxSq:e.distanceMax*e.distanceMax}}(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([2,1]),getType:(n,r,i,o)=>function kst(e,t,n,r,i){if(function Ast(e,t){return 2===e&&1===t||1===e&&2===t}(t.types[t.feature],n.types[n.feature])&&function Dst(e,t,n){const{feature:r,offsets:i,members:o}=e,{feature:s,offsets:a,members:c}=t;for(let u=i[r],l=i[r+1];u{const t=function Pst(e){return{offsetMax:e.offsetMax,angleDevMax:Yn(e.angleDevMax)}}(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([3]),getType:(n,r,i,o)=>function Nst(e,t,n,r,i){if(function Ist(e,t){return 3===e&&3===t}(t.types[t.feature],n.types[n.feature])){fU(rC,t),fU(hU,n);const a=v.angle(rC,hU);if(Math.min(pU(t,n,hU),pU(n,t,rC))<=i.offsetMax){if(a<=i.angleDevMax||a>=Rst-i.angleDevMax)return kn.PiStacking;if(a<=i.angleDevMax+Mle&&a>=Mle-i.angleDevMax)return kn.PiStacking}}}(0,r,i,0,t)}}},zst={name:"cation-pi",params:vst,createTester:e=>{const t=function Mst(e){return{offsetMax:e.offsetMax}}(e);return{maxDistance:e.distanceMax,requiredFeatures:new Set([3,1]),getType:(n,r,i,o)=>function Fst(e,t,n,r,i){const o=t.types[t.feature];if(function Tst(e,t){return 3===e&&1===t||1===e&&3===t}(o,n.types[n.feature])){const[a,c]=3===o?[t,n]:[n,t];if(fU(rC,a),pU(c,a,rC)<=i.offsetMax)return kn.CationPi}}(0,r,i,0,t)}}},Gst={distanceMax:C.Numeric(4,{min:1,max:5,step:.1})},Wst=Ai.Provider([8],function jst(e,t,n){const{elements:r}=t,{x:i,y:o,z:s}=t.model.atomicConformation;for(let a=0,c=r.length;a{const p=or(d,f);"C"!==p&&"H"!==p&&(l=!1)})):"F"===u&&(l=!0),l&&n.add(8,Ir.None,i[r[a]],o[r[a]],s[r[a]],a)}}),$st={name:"hydrophobic",params:Gst,createTester:e=>({maxDistance:e.distanceMax,requiredFeatures:new Set([8]),getType:(t,n,r,i)=>function qst(e,t,n,r){if(!function Hst(e,t){return 8===e&&8===t}(t.types[t.feature],n.types[n.feature]))return;const a=n.members[n.offsets[n.feature]];return"F"!==or(t.unit,t.members[t.offsets[t.feature]])||"F"!==or(n.unit,a)?kn.Hydrophobic:void 0}(0,n,r)})},Yst={distanceMax:C.Numeric(3,{min:1,max:5,step:.1})},Xst=["LI","NA","K","RB","CS","MG","CA","SR","BA","AL","GA","IN","TL","SC","SN","PB","BI","SB","HG"];function Rle(e){return!lp.has(e)}function Zst(e){return lp.has(e)}function Qst(e){return ZI.has(e)}function kle(e,t){return 12===e?11===t||12===t:13===e?10===t:void 0}const tat=Ai.Provider([13,12],function Kst(e,t,n){const{elements:r}=t,{x:i,y:o,z:s}=t.model.atomicConformation;for(let a=0,c=r.length;a({maxDistance:e.distanceMax,requiredFeatures:new Set([13,12,10,11]),getType:(t,n,r,i)=>function eat(e,t,n,r){const i=t.types[t.feature],o=n.types[n.feature];if(kle(i,o)||kle(o,i))return kn.MetalCoordination}(0,n,r)})};function oat(e,t){const{contacts:n}=t,r=function(u,l,d,f,p){const[m,h]=f.get(d)||[1/0,-1];un.edges[u].props.flag=Pf.Filtered;let a,c;return{isApplicable:u=>u===kn.Hydrophobic,handleInterContact:(u,l,d)=>{i(u,l,d,o,s)},startUnit:(u,l,d)=>{a=new Map,c=f=>l.edgeProps.flag[f]=Pf.Filtered},handleIntraContact:(u,l,d)=>{i(u,l,d,a,c)}}}function sat(e,t){const{contacts:n}=t,r=(i,o)=>{const s=9===i.types[i.feature]?o:i,a=s.members[s.offsets[s.feature]],{edgeProps:{type:c},elementsIndex:{offsets:u,indices:l}}=t.unitsContacts.get(s.unit.id);for(let f=u[a],p=u[a+1];fi===kn.WeakHydrogenBond,handleInterContact:(i,o,s)=>{r(o,s)&&(n.edges[i].props.flag=Pf.Filtered)},startUnit:()=>{},handleIntraContact:(i,o,s)=>{if(r(o,s)){const{flag:a}=t.unitsContacts.get(o.unit.id).edgeProps;a[i]=Pf.Filtered}}}}function mU(e,t,n,r,i){const{offsets:o,feature:s}=n,{offsets:a,feature:c}=r;for(let u=o[s],l=o[s+1];ur===kn.Ionic,handleInterContact:(r,i,o)=>{mU([kn.HydrogenBond,kn.WeakHydrogenBond],r,i,o,n)},startUnit:()=>{},handleIntraContact:(r,i,o)=>{gU([kn.HydrogenBond,kn.WeakHydrogenBond],r,i,o,t.unitsContacts.get(i.unit.id))}}}function cat(e,t){const{contacts:n}=t;return{isApplicable:r=>r===kn.Hydrophobic||r===kn.CationPi,handleInterContact:(r,i,o)=>{mU([kn.PiStacking],r,i,o,n)},startUnit:()=>{},handleIntraContact:(r,i,o)=>{gU([kn.PiStacking],r,i,o,t.unitsContacts.get(i.unit.id))}}}function uat(e,t){const{contacts:n}=t;return{isApplicable:r=>r===kn.Ionic,handleInterContact:(r,i,o)=>{mU([kn.MetalCoordination],r,i,o,n)},startUnit:()=>{},handleIntraContact:(r,i,o)=>{gU([kn.MetalCoordination],r,i,o,t.unitsContacts.get(i.unit.id))}}}var nh;!function(e){function i(l,d){const{unitA:f,indexA:p,unitB:m,indexB:h}=d,{contacts:g,unitsContacts:y}=l;if(f===m){const b=y.get(f.id),x=b.getDirectedEdgeIndex(p,h);return hle(b.edgeProps.type[x])}{const b=g.getEdgeIndex(p,f.id,h,m.id);return hle(g.edges[b].props.type)}}function c(l,d,f){const{unitsFeatures:p}=l;return Og.fromPairProvider(d.length,(m,h,g)=>{const y=d[m];Ai.setPosition(h,y.unitA,y.indexA,p.get(y.unitA.id)),Ai.setPosition(g,y.unitB,y.indexB,p.get(y.unitB.id))},f)}function u(l,d,f){const p=f[0];if(void 0===p)return"";const{unitA:m,indexA:h,unitB:g,indexB:y}=p,{unitsFeatures:b}=d,{members:x,offsets:_}=b.get(m.id),{members:S,offsets:A}=b.get(g.id),E={granularity:"element"};return(_[h+1]-_[h]>1||A[y+1]-A[y]>1)&&(E.granularity="residue"),[i(d,p),c8(Lt.Location(l,m,x[_[h]],l,g,S[A[y]]),E)].join("
")}e.Location=function t(l,d,f,p,m,h){return yre("interactions",{structure:d,interactions:l},{unitA:f,indexA:p,unitB:m,indexB:h})},e.isLocation=function n(l){return!!l&&"data-location"===l.kind&&"interactions"===l.tag},e.areLocationsEqual=function r(l,d){return l.data.structure===d.data.structure&&l.data.interactions===d.data.interactions&&l.element.indexA===d.element.indexA&&l.element.indexB===d.element.indexB&&l.element.unitA===d.element.unitA&&l.element.unitB===d.element.unitB},e.locationLabel=function o(l){return i(l.data.interactions,l.element)},e.Loci=function s(l,d,f){return eE("interactions",{structure:l,interactions:d},f,p=>c(d,f,p),()=>u(l,d,f))},e.isLoci=function a(l){return!!l&&"data-loci"===l.kind&&"interactions"===l.tag},e.getBoundingSphere=c,e.getLabel=u}(nh||(nh={}));const lat=[nst,rst,ist,Bst,Ost,Lst,Uot,Vot,Wst,tat,nat],zE={ionic:Ust,"pi-stacking":Vst,"cation-pi":zst,"halogen-bonds":zot,"hydrogen-bonds":ost,"weak-hydrogen-bonds":sst,hydrophobic:$st,"metal-coordination":rat},fat=function dat(e=[]){const t=Object.create(null);return Object.keys(zE).forEach(n=>{t[n]=C.MappedStatic(e.includes(n)?"on":"off",{on:C.Group(zE[n].params),off:C.Group({})},{cycle:!0})}),t}(["cation-pi","pi-stacking","hydrogen-bonds","halogen-bonds","metal-coordination"]),Nle={providers:C.Group(fat,{isFlat:!0}),contacts:C.Group(xot,{label:"Advanced Options"})};function pat(e,t,n){return yU.apply(this,arguments)}function yU(){return yU=ie(function*(e,t,n){const r={...C.getDefaultValues(Nle),...n};yield nC.attach(e,t);const i=[];RI(zE).forEach(d=>{const{name:f,params:p}=r.providers[d];"on"===f&&i.push(zE[d].createTester(p))});const o=new Set;i.forEach(d=>Si.add(o,d.requiredFeatures));const s=lat.filter(d=>Si.areIntersecting(o,d.types)),a=Lu.Mutable(),c=Lu.Mutable();for(let d=0,f=t.unitSymmetryGroups.length;d{const a=t.get(o.id),c=t.get(s.id);!function Tot(e,t,n,r,i,o,s,a){const{count:c,x:u,y:l,z:d}=n,{lookup3d:f}=i,p=le.mul(Iot,r.conformation.operator.inverse,t.conformation.operator.matrix),m=!le.isIdentity(p),h=v(),g=Math.max(...s.map(E=>E.maxDistance)),{center:y,radius:b}=f.boundary.sphere,x=(b+g)*(b+g),_=a.lineOfSightDistFactor,S=Ai.Info(e,t,n),A=Ai.Info(e,r,i);o.startUnitPair(t,r);for(let E=0;Ex)continue;const{indices:w,count:D,squaredDistances:I}=f.find(h[0],h[1],h[2],g);if(0!==D){S.feature=E;for(let R=0;Ro.maxDistance)),validUnit:o=>Ee.isAtomic(o),validUnitPair:(o,s)=>Ve.validUnitPair(e,o,s)}),i.getContacts(t)}(t,a,i,r.contacts),l={unitsFeatures:a,unitsContacts:c,contacts:u};return function iat(e,t){const{contacts:n,unitsContacts:r,unitsFeatures:i}=t,o=[oat(0,t),sat(0,t),aat(0,t),cat(0,t),uat(0,t)];for(let a=0,c=n.edgeCount;abU,isApplicable:e=>!e.isCoarseGrained,obtain:function(){var e=ie(function*(t,n,r){const i={...C.getDefaultValues(bU),...r};return{value:yield pat(t,n,i)}});return function(n,r,i){return e.apply(this,arguments)}}()}),vU=st(13421772),Ea_HydrogenBond=2851770,Ea_Hydrophobic=8421504,Ea_HalogenBond=4259775,Ea_Ionic=15779860,Ea_MetalCoordination=9191577,Ea_CationPi=16744448,Ea_PiStacking=9220966,Ea_WeakHydrogenBond=12967404,bat=[["Hydrogen Bond",Ea_HydrogenBond],["Hydrophobic",Ea_Hydrophobic],["Halogen Bond",Ea_HalogenBond],["Ionic",Ea_Ionic],["Metal Coordination",Ea_MetalCoordination],["Cation Pi",Ea_CationPi],["Pi Stacking",Ea_PiStacking],["Weak HydrogenBond",Ea_WeakHydrogenBond]];function Fle(e){switch(e){case kn.HydrogenBond:return Ea_HydrogenBond;case kn.Hydrophobic:return Ea_Hydrophobic;case kn.HalogenBond:return Ea_HalogenBond;case kn.Ionic:return Ea_Ionic;case kn.MetalCoordination:return Ea_MetalCoordination;case kn.CationPi:return Ea_CationPi;case kn.PiStacking:return Ea_PiStacking;case kn.WeakHydrogenBond:return Ea_WeakHydrogenBond;case kn.Unknown:return vU}}const Ble={},_U={name:"interaction-type",label:"Interaction Type",category:Lc.Category.Misc,factory:function Ole(e,t){let n;const r=e.structure?Qi.get(e.structure):void 0,i=r?Pg(r.id,r.version):-1;return n=r&&r.value?o=>{if(nh.isLocation(o)){const{unitsContacts:s,contacts:a}=o.data.interactions,{unitA:c,unitB:u,indexA:l,indexB:d}=o.element;if(c===u){const f=s.get(c.id),p=f.getDirectedEdgeIndex(l,d);return Fle(f.edgeProps.type[p])}{const f=a.getEdgeIndex(l,c.id,d,u.id);return Fle(a.edges[f].props.type)}}return vU}:()=>vU,{factory:Ole,granularity:"group",color:n,props:t,contextHash:i,description:"Assigns colors according the interaction type of a link.",legend:$h(bat)}},getParams:function vat(e){return Ble},defaultValues:C.getDefaultValues(Ble),isApplicable:e=>!!e.structure,ensureCustomProperties:{attach:(e,t)=>t.structure?Qi.attach(e,t.structure,void 0,!0):Promise.resolve(),detach:e=>e.structure&&Qi.ref(e.structure,!1)}};function Iu(e,t,n,r){let i=0;const{webgl:o}=t,s=new mr,a=new yn.GeometryState,c=Hp(),u=[],l=ms.create();let d,f,p,m,h=Fo.createEmpty();function S(w){if(ms.update(l,w),void 0!==w.visible&&d&&d.setVisibility(w.visible&&(null===l.unitTransforms||l.unitTransforms.isIdentity)),void 0!==w.alphaFactor&&d&&d.setAlphaFactor(w.alphaFactor),void 0!==w.pickable&&d&&d.setPickable(w.pickable),void 0!==w.overpaint&&d){const D=Bo.remap(w.overpaint,f);d.setOverpaint(D,o)}if(void 0!==w.transparency&&d){const D=Vs.remap(w.transparency,f);d.setTransparency(D,o)}if(void 0!==w.substance&&d){const D=zs.remap(w.substance,f);d.setSubstance(D,o)}if(void 0!==w.clipping&&d){const D=Yr.remap(w.clipping,f);d.setClipping(D)}void 0!==w.themeStrength&&d&&d.setThemeStrength(w.themeStrength),void 0!==w.transform&&d&&d.setTransform(w.transform),void 0!==w.unitTransforms&&d&&d.setVisibility(l.visible&&(null===w.unitTransforms||w.unitTransforms.isIdentity))}return{label:e,get groupCount(){return d?d.groupCount:0},get props(){return m},get params(){return p},get state(){return l},get theme(){return h},get geometryVersion(){return a.version},renderObjects:u,updated:s,createOrUpdate:function g(w={},D){return D&&D!==f&&(p=n(t,D),f=D,m||(m=C.getDefaultValues(p))),m=Object.assign({},m,w),Oe.create("Creating or updating ComplexRepresentation",function(){var I=ie(function*(R){var T;let M=!1;d?null!==(T=d.mustRecreate)&&void 0!==T&&T.call(d,f,m,o)&&(d.destroy(),d=r(c,f,m,o),M=!0):(d=r(c,f,m,o),M=!0);const N=d.createOrUpdate({webgl:o,runtime:R},h,m,D);N&&(yield N),M&&S(l),u.length=0,d&&d.renderObject&&(u.push(d.renderObject),a.add(d.renderObject.id,d.geometryVersion)),a.snapshot(),i+=1,s.next(i)});return function(R){return I.apply(this,arguments)}}())},setState:S,setTheme:function A(w){h=w},getLoci:function y(w){return d?d.getLoci(w):$n},getAllLoci:function b(){var w;return[Ve.Loci(null!==(w=f.child)&&void 0!==w?w:f)]},eachLocation:function x(w){d?.eachLocation(w)},mark:function _(w,D){if(!f||!Us.is(l.markerActions,D))return!1;if(Ve.isLoci(w)||De.is(w)||Lt.isLoci(w)){if(!Ve.areRootsEquivalent(w.structure,f))return!1;w=pn.remap(w,f),(Ve.isLoci(w)||De.is(w)&&De.isWholeStructure(w))&&(w=JD)}else if(!Uc(w)&&!GS(w))return!1;return!pn.isEmpty(w)&&!!d&&d.mark(w,D)},destroy:function E(){d&&d.destroy()}}}const _at=le.toArray;function Lle(e,t,n){const{elements:r,model:i}=t;if(-1!==Fe.indexOf(r,n)){const{index:o,offsets:s}=i.atomicHierarchy.residueAtomSegments,a=o[n],c=[];for(let l=s[a],d=s[a+1];ls.unitMap.has(d.id)):e.group.units,c=a.length,u=16*c,l=o&&o.aTransform.ref.value.length>=u?o.aTransform.ref.value:new Float32Array(u);for(let d=0;dc-a);const i=Math.floor(Math.cbrt(n)*Math.cbrt(n)),o=r[0]*r[1];return{area:o,areaCells:Math.ceil(o/(t*t)),maxAreaCells:i}}function Pm(e,t,n=Vle){const{area:r,areaCells:i,maxAreaCells:o}=zle(e,t.resolution,n),s=i>o?Math.sqrt(r/o):t.resolution;return{...t,resolution:s}}const GE={ignoreHydrogens:C.Boolean(!1,{description:"Whether or not to include hydrogen atoms in the surface calculation."}),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),traceOnly:C.Boolean(!1,{description:"Whether or not to only use trace atoms in the surface calculation."}),includeParent:C.Boolean(!1,{description:"Include elements of the parent structure in surface calculation to get a surface patch of the current structure."})},Iat=(C.getDefaultValues(GE),v());function Gle(e,t,n,r){return v.squaredDistance(v.set(Iat,e,t,n),r)}function jE(e,t,n,r){const{ignoreHydrogens:i,ignoreHydrogensVariant:o,traceOnly:s,includeParent:a}=r,c=a?e.root.unitMap.get(t.id):t,u=a&&c!==t,{x:l,y:d,z:f}=function Aat(e){switch(e.kind){case 0:return e.model.atomicConformation;case 1:return e.model.coarseConformation.spheres;case 2:return e.model.coarseConformation.gaussians}}(c),{elements:p}=c,{center:m,radius:h}=t.boundary.sphere,y=(h+11)*(h+11);let b,x;if(i||s||u){const w=[],D=[];for(let I=0,R=p.length;Iy||(w.push(T),D.push(I))}b=je.ofSortedArray(w),x=D}else b=p,x=Tc(new Int32Array(b.length));a&&c!==t&&function Tat(e,t,n){let r=0;const i=t.length;for(let o=0,s=n.length;o(A.element=w,n.size(A))}}function HE(e,t,n){const{ignoreHydrogens:r,ignoreHydrogensVariant:i,traceOnly:o,includeParent:s}=n,a=s&&!!e.parent,c=nt.create(e.root),{center:u,radius:l}=e.boundary.sphere,f=(l+11)*(l+11);let p,m,h,g,y,b;if(r||o||a){const{getSerialIndex:A}=e.serialMapping,E=a?e.root.units:e.units,w=[],D=[],I=[],R=[],T=[];for(let M=0,N=E.length;Mf||(w.push($),D.push(ee),I.push(q),c.element=Z,R.push(t.size(c)),a?-1===(L?je.indexOf(L.elements,Z):-1)?T.push(-2):T.push(A(L,Z)):T.push(A(V,Z)))}}p=w,m=D,h=I,g=R,y=T,b=Fe.ofRange(0,y.length)}else{const{elementCount:A}=e,E=new Float32Array(A),w=new Float32Array(A),D=new Float32Array(A),I=new Float32Array(A);for(let R=0,T=0,M=e.units.length;Rg[A]}}const jle=_T.H;function md(e,t,n,r){if(Ee.isCoarse(t)||t.model.atomicHierarchy.derived.atom.atomicNumber[n]!==jle)return!1;if("all"===r)return!0;const i=function gst(e,t,n){let r=!1;return dc(e,t,n,(i,o)=>{(function mst(e){return hst.has(e)})(or(i,o))&&(r=!0)}),r}(e,t,je.indexOf(t.elements,n));return!!(i&&"polar"===r||!i&&"non-polar"===r)}function Dat(e,t){return e[t]===jle}function xU(e,t){if(Ee.isCoarse(e))return!0;const n=e.model.atomicHierarchy.atoms.label_atom_id.value(t);return"CA"===n||"BB"===n||"P"===n}function oC(e){return C.MultiSelect(e,Cat,{description:"For which kinds of units/chains to show the representation visuals."})}const fc={unitKinds:oC(["atomic","spheres"]),includeParent:C.Boolean(!1,{isHidden:!0})},Hle={...Nt.Params},qle={...fl.Params},Wle={...oc.Params},Eat={...ym.Params},$le={...di.Params},Yle={...vu.Params},Xle={..._u.Params},Kle={...xa.Params};function N0(e,t){const{defaultProps:n,createGeometry:r,createLocationIterator:i,getLoci:o,eachLocation:s,setUpdateState:a,mustRecreate:c,processValues:u,dispose:l}=e,{updateValues:d,updateBoundingSphere:f,updateRenderableState:p,createPositionIterator:m}=e.geometryUtils,h=Cf.create(),g={loci:$n,action:Bt.None,status:-1};let y,b,x,_,E,w,I,R,S=Object.assign({},n),A=Fo.createEmpty(),D=-1;function M(L){if(h.createNew){if(I=i(_,b),!L)throw new Error("expected geometry to be given");y=function Pat(e,t,n,r,i,o){const{createValues:s,createRenderableState:a}=Zo.getUtils(t),u=s(t,JL(),n,r,i),l=a(i);return Ev(t.kind,u,l,o)}(0,L,I,x,b,t),R=m(L,y.values)}else{if(!y)throw new Error("expected renderObject to be available");if(h.updateTransform){I=i(_,b);const{instanceCount:z,groupCount:j}=I;b.instanceGranularity?Vi(z,"instance",y.values):Vi(z*j,"groupInstance",y.values)}if(h.createGeometry){if(!L)throw new Error("expected geometry to be given");k.updateIfChanged(y.values.drawCount,Zo.getDrawCount(L)),k.updateIfChanged(y.values.uVertexCount,Zo.getVertexCount(L)),k.updateIfChanged(y.values.uGroupCount,Zo.getGroupCount(L))}(h.updateTransform||h.createGeometry)&&(f(y.values,L||w),R=m(w,y.values)),h.updateSize&&"uSize"in y.values&&kp(I,x.size,y.values),h.updateColor&&bu(I,R,x.color,y.values),d(y.values,b),p(y.state,b)}S=b,A=x,E=_,L&&(w=L,D+=1)}function F(L,z,j){return function N(L){return!!(Uc(L)||Ve.isLoci(L)&&Ve.areRootsEquivalent(L.structure,E)||De.is(L)&&Ve.areRootsEquivalent(L.structure,E)&&De.isWholeStructure(L))}(L)?z(Ce.ofBounds(0,S.instanceGranularity?I.instanceCount:I.groupCount*I.instanceCount)):S.instanceGranularity?function V(L,z,j){let Z=!1;return!(!De.is(L)&&!Lt.isLoci(L)||!Ve.areEquivalent(L.structure,z))&&(j(Ce.ofSingleton(0))&&(Z=!0),Z)}(L,E,z):s(L,E,z,j)}function G(L){y&&u?.(y.values,w,S,A,L.webgl)}return{get groupCount(){return I?I.count:0},get renderObject(){return I&&I.count?y:void 0},get geometryVersion(){return D},createOrUpdate(L,z,j={},Z){if(function T(L,z,j){if(!j&&!E)throw new Error("missing structure");if(b=Object.assign({},S,z),x=L,_=j,Cf.reset(h),!y||!E)return h.createNew=!0,void(h.createGeometry=!0);a(h,b,S,x,A,_,E),Ve.areEquivalent(_,E)||(h.createGeometry=!0),Ve.areHierarchiesEqual(_,E)||(h.updateTransform=!0,h.createGeometry=!0),Lc.areEqual(L.color,A.color)||(h.updateColor=!0),Yd(b.unitKinds,S.unitKinds)||(h.createGeometry=!0),E.child!==_.child&&(h.createGeometry=!0),b.instanceGranularity!==S.instanceGranularity&&(h.updateTransform=!0),h.updateSize&&!("uSize"in y.values)&&(h.createGeometry=!0),h.createGeometry&&(h.updateColor=!0,h.updateSize=!0)}(z,j,Z||E),h.createGeometry){const $=r(L,_,x,b,w);if(kI($))return $.then(ee=>{M(ee),G(L)});M($)}else M();G(L)},getLoci:L=>y?o(L,E,y.id):$n,eachLocation(L){for(I.reset();I.hasNext;){const{location:z,isSecondary:j}=I.move();L(z,j)}},mark:(L,z)=>Sn.mark(y,L,z,F,g),setVisibility(L){Sn.setVisibility(y,L)},setAlphaFactor(L){Sn.setAlphaFactor(y,L)},setPickable(L){Sn.setPickable(y,L)},setColorOnly(L){Sn.setColorOnly(y,L)},setTransform(L,z){Sn.setTransform(y,L,z)},setOverpaint(L,z){Sn.setOverpaint(y,L,F,!0,{geometry:w,props:S,webgl:z})},setTransparency(L,z){Sn.setTransparency(y,L,F,!0,{geometry:w,props:S,webgl:z})},setSubstance(L,z){Sn.setSubstance(y,L,F,!0,{geometry:w,props:S,webgl:z})},setClipping(L){Sn.setClipping(y,L,F,!0)},setThemeStrength(L){Sn.setThemeStrength(y,L)},destroy(){l?.(w),y&&(y.state.disposed=!0,y=void 0)},mustRecreate:c}}const r1={...Hle,...fc};function rh(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.createGeometry=!0)},geometryUtils:Nt.Utils},t)}const Mat={...qle,...fc},kat={...Wle,...fc},Fat={...$le,...fc},Oat={...Yle,...fc},Uat={...Xle,...fc},zat={...Kle,...fc};function vi(e,t,n,r){let i=0;const{webgl:o}=t,s=new mr,a=Hp(),c=[],u=new yn.GeometryState,l=ms.create();let f,p,m,h,d=new Map,g=Fo.createEmpty();function A(I,R,T){const{visible:M,alphaFactor:N,pickable:V,overpaint:F,transparency:G,substance:L,clipping:z,themeStrength:j,transform:Z,unitTransforms:$}=T;void 0!==M&&I.setVisibility(M),void 0!==N&&I.setAlphaFactor(N),void 0!==V&&I.setPickable(V),void 0!==F&&I.setOverpaint(F,o),void 0!==G&&I.setTransparency(G,o),void 0!==L&&I.setSubstance(L,o),void 0!==z&&I.setClipping(z),void 0!==j&&I.setThemeStrength(j),void 0!==Z&&(Z!==l.transform||!le.areEqual(Z,l.transform,vr))&&I.setTransform(Z),void 0!==$&&($?I.setTransform(void 0,$.getSymmetryGroupTransforms(R)):$!==l.unitTransforms&&I.setTransform(void 0,null))}return{label:e,get groupCount(){let I=0;return d.forEach(({visual:R})=>{R.renderObject&&(I+=R.groupCount)}),I},get geometryVersion(){return u.version},get props(){return h},get params(){return m},get state(){return l},get theme(){return g},renderObjects:c,updated:s,createOrUpdate:function y(I={},R){return R&&R!==f&&(m=n(t,R),h||(h=C.getDefaultValues(m))),h=Object.assign({},h,I),Oe.create("Creating or updating UnitsRepresentation",function(){var T=ie(function*(M){var N,V,F;if(!f&&!R)throw new Error("missing structure");if(R&&!f){p=R.unitSymmetryGroups;for(let G=0;GG.push(L));for(let L=0,z=G.length;L{L.destroy()})}c.length=0,d.forEach(({visual:G})=>{G.renderObject&&(c.push(G.renderObject),u.add(G.renderObject.id,G.geometryVersion))}),u.snapshot(),R&&(f=R),s.next(i++)});return function(M){return T.apply(this,arguments)}}())},setState:function E(I){const{visible:R,alphaFactor:T,pickable:M,overpaint:N,transparency:V,substance:F,clipping:G,themeStrength:L,transform:z,unitTransforms:j,syncManually:Z,markerActions:$}=I,ee={};void 0!==R&&(ee.visible=R),void 0!==T&&(ee.alphaFactor=T),void 0!==M&&(ee.pickable=M),void 0!==N&&f&&(ee.overpaint=Bo.remap(N,f)),void 0!==V&&f&&(ee.transparency=Vs.remap(V,f)),void 0!==F&&f&&(ee.substance=zs.remap(F,f)),void 0!==G&&f&&(ee.clipping=Yr.remap(G,f)),void 0!==L&&(ee.themeStrength=L),void 0!==z&&!le.areEqual(z,l.transform,vr)&&(ee.transform=z),(j!==l.unitTransforms||j?.version!==l.unitTransformsVersion)&&(ee.unitTransforms=j,l.unitTransformsVersion=j?j?.version:-1),void 0!==Z&&(ee.syncManually=Z),void 0!==$&&(ee.markerActions=$),d.forEach(({visual:q,group:O})=>A(q,O,ee)),ms.update(l,ee)},setTheme:function w(I){g=I},getLoci:function b(I){let R=$n;return d.forEach(({visual:T})=>{const M=T.getLoci(I);Ta(M)||(R=M)}),R},getAllLoci:function _(){var I;return[Ve.Loci(null!==(I=f.child)&&void 0!==I?I:f)]},eachLocation:function x(I){d.forEach(({visual:R})=>{R.eachLocation(I)})},mark:function S(I,R){if(!f||!Us.is(l.markerActions,R))return!1;if(Ve.isLoci(I)||De.is(I)||Lt.isLoci(I)){if(!Ve.areRootsEquivalent(I.structure,f))return!1;I=pn.remap(I,f),(Ve.isLoci(I)||De.is(I)&&De.isWholeStructure(I))&&(I=JD)}else if(!Uc(I)&&!GS(I))return!1;if(pn.isEmpty(I))return!1;let T=!1;return d.forEach(({visual:M})=>{T=M.mark(I,R)||T}),T},destroy:function D(){d.forEach(({visual:I})=>I.destroy()),d.clear()}}}function Mm(e,t){const{defaultProps:n,createGeometry:r,createLocationIterator:i,getLoci:o,eachLocation:s,setUpdateState:a,mustRecreate:c,processValues:u,dispose:l}=e,{createEmpty:d,updateValues:f,updateBoundingSphere:p,updateRenderableState:m,createPositionIterator:h}=e.geometryUtils,g=Cf.create(),y={loci:$n,action:Bt.None,status:-1};let b,S,A,E,w,D,R,T,x=Object.assign({},n),_=Fo.createEmpty(),I=-1;function N(j){if(g.createNew){if(R=i(S,x),!j)throw new Error("expected geometry to be given");b=function jat(e,t,n,r,i,o){const{createValues:s,createRenderableState:a}=Zo.getUtils(t),u=s(t,Ule(e,i.includeParent,t.boundingSphere,i.cellSize,i.batchSize),n,r,i),l=a(i);return Ev(t.kind,u,l,o)}(S,j,R,_,x,t),T=h(j,b.values)}else{if(!b)throw new Error("expected renderObject to be available");if(g.updateTransform){R=i(S,x);const{instanceCount:Z,groupCount:$}=R;x.instanceGranularity?Vi(Z,"instance",b.values):Vi(Z*$,"groupInstance",b.values)}if(g.updateMatrix&&(Ule(S,x.includeParent,b.values.invariantBoundingSphere.ref.value,x.cellSize,x.batchSize,b.values),"lodLevels"in b.values&&k.update(b.values.lodLevels,b.values.lodLevels.ref.value)),g.createGeometry){if(!j)throw new Error("expected geometry to be given");k.updateIfChanged(b.values.drawCount,Zo.getDrawCount(j)),k.updateIfChanged(b.values.uVertexCount,Zo.getVertexCount(j)),k.updateIfChanged(b.values.uGroupCount,Zo.getGroupCount(j))}(g.updateTransform||g.createGeometry)&&(p(b.values,j||D),T=h(j||D,b.values)),g.updateSize&&"uSize"in b.values&&kp(R,_.size,b.values),g.updateColor&&bu(R,T,_.color,b.values),f(b.values,x),m(b.state,x)}A=x,E=_,w=S,j&&(D=j,I+=1)}function L(j,Z,$){return function F(j){return!!(Uc(j)||Ve.isLoci(j)&&Ve.areRootsEquivalent(j.structure,w.structure)||De.is(j)&&Ve.areRootsEquivalent(j.structure,w.structure)&&De.isWholeStructure(j))}(j)?Z(Ce.ofBounds(0,A.instanceGranularity?R.instanceCount:R.groupCount*R.instanceCount)):A.instanceGranularity?function G(j,Z,$){let ee=!1;if(Lt.isLoci(j)){const{structure:q,group:O}=Z;if(!Ve.areEquivalent(j.structure,q))return!1;for(const H of j.bonds){if(H.aUnit!==H.bUnit)continue;const W=O.unitIndexMap.get(H.aUnit.id);void 0!==W&&$(Ce.ofSingleton(W))&&(ee=!0)}}else if(De.is(j)){const{structure:q,group:O}=Z;if(!Ve.areEquivalent(j.structure,q))return!1;for(const H of j.elements){const W=O.unitIndexMap.get(H.unit.id);void 0!==W&&$(Ce.ofSingleton(W))&&(ee=!0)}}return ee}(j,w,Z):s(j,w,Z,$)}function z(j){b&&u?.(b.values,D,A,E,j.webgl)}return{get groupCount(){return R?R.count:0},get renderObject(){return R&&R.count?b:void 0},get geometryVersion(){return I},createOrUpdate(j,Z,$,ee){if(function M(j,Z,$){if(!$&&!w)throw new Error("missing structureGroup");if(x=Z,_=j,S=$,Cf.reset(g),!b||!w)return g.createNew=!0,void(g.createGeometry=!0);a(g,x,A,_,E,S,w),Ve.areHierarchiesEqual(w.structure,S.structure)||(g.updateTransform=!0,g.updateColor=!0,g.updateSize=!0),Lc.areEqual(_.color,E.color)||(g.updateColor=!0),w.structure.child!==S.structure.child&&(g.createGeometry=!0),(x.instanceGranularity!==A.instanceGranularity||x.cellSize!==A.cellSize||x.batchSize!==A.batchSize)&&(g.updateTransform=!0),Yd(x.unitKinds,A.unitKinds)||(g.createGeometry=!0),S.group.transformHash!==w.group.transformHash&&(S.group.units.length!==w.group.units.length||g.updateColor?g.updateTransform=!0:g.updateMatrix=!0);const ee=S.group.units[0],q=w.group.units[0];Ee.areOperatorsEqual(ee,q)||(g.updateTransform=!0),Ee.areConformationsEqual(ee,q)||(g.createGeometry=!0),g.updateTransform&&(g.updateMatrix=!0),g.updateSize&&!("uSize"in b.values)&&(g.createGeometry=!0),(g.createGeometry||g.updateTransform)&&(w.structure.hashCode!==S.structure.hashCode&&(g.updateColor=!0,g.updateSize=!0),(_.color.granularity.startsWith("vertex")||b.values.dColorType.ref.value.startsWith("vertex")||_.color.granularity.startsWith("volume")||b.values.dColorType.ref.value.startsWith("volume"))&&(g.updateColor=!0))}(Z,$,ee||w),g.createGeometry){const q=function V(j,Z,$,ee,q,O){return function wat(e,t){for(let n=0,r=e.length;n{N(O),z(j)});N(q)}else N();z(j)},getLoci:j=>b?o(j,w,b.id):$n,eachLocation(j){for(R.reset();R.hasNext;){const{location:Z,isSecondary:$}=R.move();j(Z,$)}},mark(j,Z){let $=!0;if(De.is(j)){$=!1;const{invariantId:ee}=w.group.units[0];for(const q of j.elements)if(q.unit.invariantId===ee){$=!0;break}}return!!$&&Sn.mark(b,j,Z,L,y)},setVisibility(j){Sn.setVisibility(b,j)},setAlphaFactor(j){Sn.setAlphaFactor(b,j)},setPickable(j){Sn.setPickable(b,j)},setColorOnly(j){Sn.setColorOnly(b,j)},setTransform(j,Z){Sn.setTransform(b,j,Z)},setOverpaint(j,Z){Sn.setOverpaint(b,j,L,!0,{geometry:D,props:A,webgl:Z})},setTransparency(j,Z){Sn.setTransparency(b,j,L,!0,{geometry:D,props:A,webgl:Z})},setSubstance(j,Z){Sn.setSubstance(b,j,L,!0,{geometry:D,props:A,webgl:Z})},setClipping(j){Sn.setClipping(b,j,L,!0)},setThemeStrength(j){Sn.setThemeStrength(b,j)},destroy(){l?.(D),b&&(b.state.disposed=!0,b=void 0)},mustRecreate:c}}const hs={...Hle,...fc};function Hs(e,t){return Mm({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.createGeometry=!0)},geometryUtils:Nt.Utils},t)}const SU={...qle,...fc};function CU(e,t){return Mm({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:fl.Utils},t)}const wU={...Wle,...fc};function AU(e,t){return Mm({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:oc.Utils},t)}const Hat={...Eat,...fc},qE={...$le,...fc};function WE(e,t){return Mm({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:di.Utils},t)}const Wat={...Xle,...fc},Yat={...Kle,...fc},ms={create:()=>({...yn.createState(),unitTransforms:null,unitTransformsVersion:-1}),update:(e,t)=>{yn.updateState(e,t),void 0!==t.unitTransforms&&(e.unitTransforms=t.unitTransforms)}},ih=v(),i1=v(),sC=v(),$E=ze.add,Zle=ze.add3;var aC;!function(e){e.create=function t(n=2048,r=1024,i){const o=ze.create(Float32Array,1,r,i?i.groupBuffer.ref.value:n),s=ze.create(Float32Array,3,r,i?i.startBuffer.ref.value:n),a=ze.create(Float32Array,3,r,i?i.endBuffer.ref.value:n),c=ze.create(Float32Array,1,r,i?i.scaleBuffer.ref.value:n),u=ze.create(Float32Array,1,r,i?i.capBuffer.ref.value:n),l=ze.create(Float32Array,1,r,i?i.colorModeBuffer.ref.value:n),d=(p,m,h,g,y,b,x,_,S,A,E)=>{for(let w=0;w<6;++w)Zle(s,p,m,h),Zle(a,g,y,b),$E(o,E),$E(c,x),$E(u,(_?1:0)+(S?2:0)),$E(l,A)},f=(p,m,h,g,y,b,x,_,S)=>{const A=v.distance(p,m),E=h%2!=0,w=Math.floor((h+1)/2),D=A/(h+.5);let I=2;v.setMagnitude(sC,v.sub(sC,m,p),D),v.copy(ih,p);for(let R=0;R{const S=v.distance(p,m);f(p,m,S/h,g,y,b,!0,x,_)},getCylinders:()=>{const p=o.elementCount/6,m=ze.compact(o,!0),h=ze.compact(s,!0),g=ze.compact(a,!0),y=ze.compact(c,!0),b=ze.compact(u,!0),x=ze.compact(l,!0),_=i&&p<=i.cylinderCount?i.mappingBuffer.ref.value:new Float32Array(18*p),S=i&&p<=i.cylinderCount?i.indexBuffer.ref.value:new Uint32Array(12*p);return(!i||p>i.cylinderCount)&&function Kat(e,t,n){for(let r=0;r0,z=c(F),j=a?a(F):0,Z=S&&!!l&&l(F),[$,ee]=L?[Z,m]:[m,Z];if(E.currentGroup=F,0===j)M.radiusTop=M.radiusBottom=z,M.topCap=$,M.bottomCap=ee,Hn(E,w,D,.5,M);else if(1===j)M.radiusTop=M.radiusBottom=z*x,M.topCap=M.bottomCap=_,wv(E,w,D,.5,b,Z,M);else if(2===j||3===j||4===j||5===j||7===j||8===j){const q=2===j||3===j?2:4===j||5===j?3:1.5,O=z*(d/(.5*q)),H=(z-O)*f;if(IU(I,w,D,o?o(F):null),M.topCap=$,M.bottomCap=ee,7===j||8===j){M.radiusTop=M.radiusBottom=z,Hn(E,w,D,.5,M);const W=z+h*z+h*z*g;qs(Or,Co(Or,D,w),.5*z),Ei(w,w,Or),Co(D,D,Or),M.radiusTop=M.radiusBottom=z*h,M.topCap=M.bottomCap=_,qs(I,I,W),Co(w,w,I),Co(D,D,I),wv(E,w,D,.5,y,Z,M),8===j&&(qs(I,I,2*W),Ei(w,w,I),Ei(D,D,I),wv(E,w,D,.5,y,Z,M))}else if(3===j||5===j){const W=z+O+d*z*f;qs(I,I,W),M.radiusTop=M.radiusBottom=z,Hn(E,w,D,.5,M),gd(Or,Or,f*d*.2),Ei(w,w,Or),Co(D,D,Or),M.radiusTop=M.radiusBottom=O,M.topCap=L?Z:_,M.bottomCap=L?_:Z,qs(I,I,W),Co(w,w,I),Co(D,D,I),Hn(E,w,D,.5,M),3===q&&(qs(I,I,2*W),Ei(w,w,I),Ei(D,D,I),Hn(E,w,D,.5,M))}else qs(I,I,H),M.radiusTop=M.radiusBottom=O,3===q&&Hn(E,w,D,.5,M),vHe(E,w,D,.5,I,M)}else 6===j&&(gd(Or,Or,.475),Ei(w,w,Or),Co(D,D,Or),M.radiusTop=M.radiusBottom=z,M.topCap=$,M.bottomCap=ee,Hn(E,w,D,.5,M))}const N=r?_e.clone(r.boundingSphere):void 0,V=at.getMesh(E);return 0===T?{mesh:V}:(v.scale(R,R,1/T),N&&v.distance(R,N.center)/N.radius<.1?{mesh:V,boundingSphere:N}:{mesh:V})}function Jle(e,t,n,r){const{linkCount:i,referencePosition:o,position:s,style:a,radius:c,ignore:u,stub:l}=t;if(!i)return{cylinders:oc.createEmpty(r)};const{linkScale:d,linkSpacing:f,linkCap:p,aromaticScale:m,aromaticSpacing:h,aromaticDashCount:g,dashCount:y,dashScale:b,dashCap:x,stubCap:_,colorMode:S}=n,A="interpolate"===S,E=!0===A?3:2,w=2*i,D=aC.create(w,w/4,r),I=v(),R=v(),T=v(),M=v(),N=v();let V=0;for(let L=0,z=i;L{const Z=S[j];if(E&&"all"===w||Z!==kn.HydrogenBond&&Z!==kn.WeakHydrogenBond)v.set(L,f[b[j]],p[b[j]],m[b[j]]),v.set(z,f[x[j]],p[x[j]],m[x[j]]);else{const $=h[g[b[j]]],ee=h[g[x[j]]];R.invariantPosition(I[$],M),R.invariantPosition(I[ee],N);let q=v.distance(M,N),O=q;v.copy(L,M),v.copy(z,N),J8(t,$,(H,W)=>{if(md(n,t,I[W],"polar")){R.invariantPosition(I[W],T);const Q=v.distance(T,N);Q{if(md(n,t,I[W],"polar")){R.invariantPosition(I[W],T);const Q=v.distance(T,M);Q1,radius:L=>{c.element=I[h[g[b[L]]]];const z=r.size.size(c);c.element=I[h[g[x[L]]]];const j=r.size.size(c);return Math.min(z,j)*A},ignore:L=>{if(_[L]===Pf.Filtered)return!0;if(a)if("stub"===D){const z=b[L];for(let j=g[z],Z=g[z+1];j0){const L=_e.expand(_e(),(a??t).boundary.sphere,1*A);F.setBoundingSphere(L)}return F})).apply(this,arguments)}const nde={...hs,...F0,...tde};function ect(e){return Hs({defaultProps:C.getDefaultValues(nde),createGeometry:Jat,createLocationIterator:rct,getLoci:tct,eachLocation:nct,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.dashCount!==r.dashCount||n.dashScale!==r.dashScale||n.dashCap!==r.dashCap||n.radialSegments!==r.radialSegments||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.parentDisplay!==r.parentDisplay;const c=Qi.get(s.structure).version;t.info.interactionsHash!==c&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.info.interactionsHash=c)}},e)}function tct(e,t,n){const{objectId:r,instanceId:i,groupId:o}=e;if(n===r){const{structure:s,group:a}=t,c=s.unitMap.get(a.units[i].id),u=Qi.get(s).value,{a:l,b:d}=u.unitsContacts.get(c.id);return nh.Loci(s,u,[{unitA:c,indexA:l[o],unitB:c,indexB:d[o]},{unitA:c,indexA:d[o],unitB:c,indexB:l[o]}])}return $n}const DU=new Set;function nct(e,t,n,r){let i=!1;if(nh.isLoci(e)){const{structure:o,group:s}=t;if(!Ve.areEquivalent(e.data.structure,o))return!1;const a=Qi.get(o).value;if(e.data.interactions!==a)return!1;const u=a.unitsContacts.get(s.units[0].id),l=2*u.edgeCount;for(const d of e.elements){if(d.unitA!==d.unitB)continue;const f=s.unitIndexMap.get(d.unitA.id);if(void 0!==f){const p=u.getDirectedEdgeIndex(d.indexA,d.indexB);-1!==p&&n(Ce.ofSingleton(f*l+p))&&(i=!0)}}}else if(De.is(e)){const{structure:o,group:s}=t;if(!Ve.areEquivalent(e.structure,o))return!1;const a=Qi.get(o).value;if(!a)return!1;const c=s.units[0],u=a.unitsContacts.get(c.id),l=a.unitsFeatures.get(c.id),d=2*u.edgeCount,{offset:f}=u,{offsets:p,indices:m}=l.elementsIndex,{members:h,offsets:g}=l;for(const y of e.elements){const b=s.unitIndexMap.get(y.unit.id);void 0!==b&&(Fe.forEach(y.indices,x=>{for(let _=p[x],S=p[x+1];_{if(r){const _=u.a[x];for(let A=g[_],E=g[_+1];A{const p=n.units[f];return u.unitA=p,u.indexA=o.a[d],u.unitB=p,u.indexB=o.b[d],c})}function ict(e,t,n,r,i){if(!t.hasAtomic)return Nt.createEmpty(i);const o=nt.create(t),s=Qi.get(t).value,{contacts:a,unitsFeatures:c}=s,{edgeCount:u,edges:l}=a,{sizeFactor:d,ignoreHydrogens:f,ignoreHydrogensVariant:p,parentDisplay:m}=r;if(!u)return Nt.createEmpty(i);const{child:h}=t,g=v(),y=v(),b=v(),x={linkCount:u,position:(A,E,w)=>{const{unitA:D,indexA:I,unitB:R,indexB:T,props:{type:M}}=l[w],N=c.get(D),V=c.get(R),F=t.unitMap.get(D),G=t.unitMap.get(R);if(f&&"all"===p||M!==kn.HydrogenBond&&M!==kn.WeakHydrogenBond)v.set(A,N.x[I],N.y[I],N.z[I]),v.transformMat4(A,A,F.conformation.operator.matrix),v.set(E,V.x[T],V.y[T],V.z[T]),v.transformMat4(E,E,G.conformation.operator.matrix);else{const L=N.members[N.offsets[I]],z=V.members[V.offsets[T]];F.conformation.position(F.elements[L],y),G.conformation.position(G.elements[z],b);let j=v.distance(y,b),Z=j;v.copy(A,y),v.copy(E,b),dc(t,F,L,($,ee)=>{const q=$.elements[ee];if(md(t,$,q,"polar")){$.conformation.position(q,g);const O=v.distance(g,b);O{const q=$.elements[ee];if(md(t,$,q,"polar")){$.conformation.position(q,g);const O=v.distance(g,y);O1,radius:A=>{const E=l[A],w=c.get(E.unitA);o.unit=t.unitMap.get(E.unitA),o.element=o.unit.elements[w.members[w.offsets[E.indexA]]];const D=n.size.size(o),I=c.get(E.unitB);o.unit=t.unitMap.get(E.unitB),o.element=o.unit.elements[I.members[I.offsets[E.indexB]]];const R=n.size.size(o);return Math.min(D,R)*d},ignore:A=>{if(l[A].props.flag===Pf.Filtered)return!0;if(h){const E=l[A];if("stub"===m){const w=h.unitMap.get(E.unitA);if(!w)return!0;const D=t.unitMap.get(E.unitA),{offsets:I,members:R}=c.get(E.unitA);for(let T=I[E.indexA],M=I[E.indexA+1];T0){const{child:A}=t,E=_e.expand(_e(),(A??t).boundary.sphere,1*d);_.setBoundingSphere(E)}return _}const rde={...r1,...F0,...tde};function oct(e){return rh({defaultProps:C.getDefaultValues(rde),createGeometry:ict,createLocationIterator:cct,getLoci:sct,eachLocation:act,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.dashCount!==r.dashCount||n.dashScale!==r.dashScale||n.dashCap!==r.dashCap||n.radialSegments!==r.radialSegments||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.parentDisplay!==r.parentDisplay;const c=Qi.get(s).version;t.info.interactionsHash!==c&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.info.interactionsHash=c)}},e)}function sct(e,t,n){const{objectId:r,groupId:i}=e;if(n===r){const o=Qi.get(t).value,s=o.contacts.edges[i],a=t.unitMap.get(s.unitA),c=t.unitMap.get(s.unitB);return nh.Loci(t,o,[{unitA:a,indexA:s.indexA,unitB:c,indexB:s.indexB},{unitA:c,indexA:s.indexB,unitB:a,indexB:s.indexA}])}return $n}const YE=new Map,EU=new Set;function act(e,t,n,r){let i=!1;if(nh.isLoci(e)){if(!Ve.areEquivalent(e.data.structure,t))return!1;const o=Qi.get(t).value;if(e.data.interactions!==o)return!1;const{contacts:s}=o;for(const a of e.elements){const c=s.getEdgeIndex(a.indexA,a.unitA.id,a.indexB,a.unitB.id);-1!==c&&n(Ce.ofSingleton(c))&&(i=!0)}}else if(De.is(e)){if(!Ve.areEquivalent(e.structure,t)||r&&1===e.elements.length)return!1;const o=Qi.get(t).value;if(!o)return!1;const{contacts:s,unitsFeatures:a}=o;for(const c of e.elements)YE.set(c.unit.id,c.indices);for(const c of e.elements){const{unit:u}=c;Ee.isAtomic(u)&&Fe.forEach(c.indices,l=>{for(const d of s.getContactIndicesForElement(l,u))EU.add(d)})}EU.forEach(c=>{if(r){const{indexA:u,unitA:l,indexB:d,unitB:f}=s.edges[c],p=YE.get(l),m=YE.get(f);if(!p||!m)return;const{offsets:h,members:g}=a.get(l);for(let x=h[u],_=h[u+1];x<_;++x)if(!Fe.has(p,g[x]))return;const{offsets:y,members:b}=a.get(f);for(let x=y[d],_=y[d+1];x<_;++x)if(!Fe.has(m,b[x]))return}n(Ce.ofSingleton(c))&&(i=!0)}),YE.clear(),EU.clear()}return i}function cct(e){const t=Qi.get(e).value,{contacts:n}=t,r=n.edgeCount,o=nh.Location(t,e),{element:s}=o;return Mr(r,1,1,c=>{const u=n.edges[c];return s.unitA=e.unitMap.get(u.unitA),s.indexA=u.indexA,s.unitB=e.unitMap.get(u.unitB),s.indexB=u.indexB,o},!0)}const ide={"intra-unit":(e,t)=>vi("Intra-unit interactions cylinder",e,t,ect),"inter-unit":(e,t)=>Iu("Inter-unit interactions cylinder",e,t,oct)},ode={...nde,...rde,unitKinds:oC(["atomic"]),sizeFactor:C.Numeric(.2,{min:.01,max:1,step:.01}),visuals:C.MultiSelect(["intra-unit","inter-unit"],C.objectToOptions(ide))},XE={name:"interactions",label:"Non-covalent Interactions",description:"Displays non-covalent interactions as dashed cylinders.",factory:function lct(e,t){return yn.createMulti("Interactions",e,t,ms,ide)},getParams:function uct(e,t){return C.clone(ode)},defaultValues:C.getDefaultValues(ode),defaultColorTheme:{name:"interaction-type"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.elementCount>0&&Qi.isApplicable(e),ensureCustomProperties:{attach:(e,t)=>Qi.attach(e,t,void 0,!0),detach:e=>Qi.ref(e,!1)},getData:(e,t)=>t.includeParent?e.asParent():e,mustRecreate:(e,t)=>e.includeParent!==t.includeParent},dct=tr.create({name:"computed-interactions-prop",category:"custom-props",display:{name:"Interactions"},ctor:class extends tr.Handler{constructor(){super(...arguments),this.provider=Qi,this.labelProvider={label:e=>{if(this.params.showTooltip&&"element-loci"===e.kind){if(0===e.elements.length)return;const t=[],n=this.getStructures(e.structure);for(const r of n){const i=this.provider.get(r).value;if(!i)continue;const o=De.remap(e,r);if(1!==o.elements.length)continue;const s=o.elements[0];if(1!==Fe.size(s.indices))continue;const a=i.unitsFeatures.get(s.unit.id);if(!a)continue;const c=[],u=[],l=[],d=Fe.start(s.indices),{types:f,groups:p,elementsIndex:{indices:m,offsets:h}}=a;for(let g=h[d],y=h[d+1];gTypes ${c.join(", ")}`),u.length&&l.push(`Groups ${u.join(", ")}`),l.length&&t.push(`Interaction Feature: ${l.join(" | ")}`)}return t.length?t.join("
"):void 0}}}}getStructures(e){const t=[],n=this.ctx.helpers.substructureParent.get(e);if(n){const i=this.ctx.state.data.select(In.Generators.ofType(pe.Molecule.Structure,n.transform.ref));for(const o of i)o.obj&&eo(t,o.obj.data)}return t}update(e){const t=this.params.autoAttach!==e.autoAttach||this.params.showTooltip!==e.showTooltip;return this.params.autoAttach=e.autoAttach,this.params.showTooltip=e.showTooltip,this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name,this.params.autoAttach),t}register(){this.ctx.customStructureProperties.register(this.provider,this.params.autoAttach),this.ctx.representation.structure.themes.colorThemeRegistry.add(_U),this.ctx.managers.lociLabels.addProvider(this.labelProvider),this.ctx.representation.structure.registry.add(XE)}unregister(){this.ctx.customStructureProperties.unregister(this.provider.descriptor.name),this.ctx.representation.structure.themes.colorThemeRegistry.remove(_U),this.ctx.managers.lociLabels.removeProvider(this.labelProvider),this.ctx.representation.structure.registry.remove(XE)}},params:()=>({autoAttach:C.Boolean(!1),showTooltip:C.Boolean(!0)})}),fct=tr.create({name:"computed-secondary-structure-prop",category:"custom-props",display:{name:"Secondary Structure"},ctor:class extends tr.Handler{constructor(){super(...arguments),this.provider=Xu}update(e){const t=this.params.autoAttach!==e.autoAttach;return this.params.autoAttach=e.autoAttach,this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name,this.params.autoAttach),t}register(){this.ctx.customStructureProperties.register(this.provider,this.params.autoAttach)}unregister(){this.ctx.customStructureProperties.unregister(this.provider.descriptor.name)}},params:()=>({autoAttach:C.Boolean(!1)})}),pct=tr.create({name:"computed-valence-model-prop",category:"custom-props",display:{name:"Valence Model"},ctor:class extends tr.Handler{constructor(){super(...arguments),this.provider=nC,this.labelProvider={label:e=>{if(this.params.showTooltip&&"element-loci"===e.kind){if(0===e.elements.length)return;const t=[],n=this.getStructures(e.structure);for(const r of n){const i=this.provider.get(r).value;if(!i)continue;const o=De.remap(e,r);if(1!==o.elements.length)continue;const s=o.elements[0];if(1!==Fe.size(s.indices))continue;const a=i.get(s.unit.id);if(!a)continue;const c=Fe.start(s.indices),d=a.implicitH[c],f=a.totalH[c];t.push(`Valence Model: Charge ${a.charge[c]} | Ideal Geometry ${dot(a.idealGeometry[c])} | Implicit H ${d} | Total H ${f}`)}return t.length?t.join("
"):void 0}}}}getStructures(e){const t=[],n=this.ctx.helpers.substructureParent.get(e);if(n){const i=this.ctx.state.data.select(In.Generators.ofType(pe.Molecule.Structure,n.transform.ref));for(const o of i)o.obj&&eo(t,o.obj.data)}return t}update(e){const t=this.params.autoAttach!==e.autoAttach||this.params.showTooltip!==e.showTooltip;return this.params.autoAttach=e.autoAttach,this.params.showTooltip=e.showTooltip,this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name,this.params.autoAttach),t}register(){this.ctx.customStructureProperties.register(this.provider,this.params.autoAttach),this.ctx.managers.lociLabels.addProvider(this.labelProvider)}unregister(){this.ctx.customStructureProperties.unregister(this.provider.descriptor.name),this.ctx.managers.lociLabels.removeProvider(this.labelProvider)}},params:()=>({autoAttach:C.Boolean(!1),showTooltip:C.Boolean(!0)})}),PU=st(16448250),cC=new Map,sde={...Ia({type:"colors",colorList:"set-1"})},cde={name:"sifts-mapping",label:"SIFTS Mapping",category:Lc.Category.Residue,factory:function ade(e,t){let n;if(e.structure){for(const a of e.structure.models){const c=sf.Provider.get(a).value;if(c)for(const u of c.accession)!u||cC.has(u)||cC.set(u,cC.size)}const r=nt.create(e.structure),i=ac(cC.size+1,t,{valueLabel:a=>`${a}`}),o=new Map,s=a=>{const c=sf.getKey(a);if(!c)return PU;if(o.has(c))return o.get(c);const u=i.color(cC.get(c));return o.set(c,u),u};n=a=>nt.is(a)&&Ee.isAtomic(a.unit)?s(a):Lt.isLocation(a)?(r.unit=a.aUnit,r.element=a.aUnit.elements[a.aIndex],s(r)):PU}else n=()=>PU;return{factory:ade,granularity:"group",preferSmoothing:!0,color:n,props:t,description:"Assigns a color based on SIFTS mapping."}},getParams:function mct(e){return sde},defaultValues:C.getDefaultValues(sde),isApplicable:e=>{var t;return!(null===(t=e.structure)||void 0===t||!t.models.some(n=>sf.Provider.isApplicable(n)))},ensureCustomProperties:{attach:function(){var e=ie(function*(t,n){if(n.structure)for(const r of n.structure.models)yield sf.Provider.attach(t,r,void 0,!0)});return function(n,r){return e.apply(this,arguments)}}(),detach:e=>{if(e.structure)for(const t of e.structure.models)sf.Provider.ref(t,!1)}}},gct=tr.create({name:"sifts-mapping-prop",category:"custom-props",display:{name:"SIFTS Mapping"},ctor:class extends tr.Handler{constructor(){super(...arguments),this.provider=sf.Provider,this.labelProvider={label:e=>{if(this.params.showTooltip)return function yct(e){if("element-loci"===e.kind){if(0===e.elements.length)return;const t=e.elements[0],n=t.unit,r=nt.create(e.structure,n,n.elements[Fe.getAt(t.indices,0)]);return sf.getLabel(r)}}(e)}}}update(e){const t=this.params.autoAttach!==e.autoAttach||this.params.showTooltip!==e.showTooltip;return this.params.autoAttach=e.autoAttach,this.params.showTooltip=e.showTooltip,this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name,this.params.autoAttach),t}register(){this.ctx.customModelProperties.register(this.provider,this.params.autoAttach),this.ctx.representation.structure.themes.colorThemeRegistry.add(cde),this.ctx.managers.lociLabels.addProvider(this.labelProvider)}unregister(){this.ctx.customModelProperties.unregister(this.provider.descriptor.name),this.ctx.representation.structure.themes.colorThemeRegistry.remove(cde),this.ctx.managers.lociLabels.removeProvider(this.labelProvider)}},params:()=>({autoAttach:C.Boolean(!0),showTooltip:C.Boolean(!0)})});var oh;!function(e){e.Descriptor={name:"ihm_cross_link_restraint"},e.Provider=td.create(e.Descriptor),e.fromTable=function t(n,r){const i={entity_id:n.entity_id_1,asym_id:n.asym_id_1,seq_id:n.seq_id_1,atom_id:n.atom_id_1},o={entity_id:n.entity_id_2,asym_id:n.asym_id_2,seq_id:n.seq_id_2,atom_id:n.atom_id_2};function s(p,m,h){const g=p.get(m);g?g.push(h):p.set(m,[h])}function a(p,m){const h=m.entity_id.value(p),g=m.asym_id.value(p),y=m.seq_id.value(p);if("by-atom"===n.model_granularity.value(p)){const b=r.atomicHierarchy.index.findAtom({auth_seq_id:y,label_asym_id:g,label_atom_id:m.atom_id.value(p),label_entity_id:h});b>=0&&s(u,b,p)}else if(r.coarseHierarchy.isDefined){const b=r.coarseHierarchy.spheres.findSequenceKey(h,g,y);if(b>=0)s(l,b,p);else{const x=r.coarseHierarchy.gaussians.findSequenceKey(h,g,y);x>=0&&s(d,x,p)}}}const u=new Map,l=new Map,d=new Map,f=[];for(let p=0;p{const g=function c(p){switch(p){case 0:return u;case 1:return l;case 2:return d}}(m).get(p);return void 0!==g?g:f},data:n}}}(oh||(oh={}));const bct=[];function ude(e,t,n,r){return`${e}|${t.id}|${n}|${r.id}`}class lde{getPairIndices(t,n,r,i){const o=ude(t,n,r,i);return this.pairKeyIndices.get(o)||bct}getPairs(t,n,r,i){return this.getPairIndices(t,n,r,i).map(s=>this.pairs[s])}constructor(t){this.pairs=t;const n=new Map;this.pairs.forEach((r,i)=>{const o=ude(r.indexA,r.unitA,r.indexB,r.unitB),s=n.get(o);s?s.push(i):n.set(o,[i])}),this.count=t.length,this.pairKeyIndices=n}}const sh=vp.createProvider({label:"Cross Link Restraint",descriptor:au({name:"integrative-cross-link-restraint"}),type:"local",defaultParams:{},getParams:e=>({}),isApplicable:e=>e.models.some(t=>!!oh.Provider.get(t)),obtain:function(){var e=ie(function*(t,n,r){return{value:xct(n)}});return function(n,r,i){return e.apply(this,arguments)}}()});var yd;function dde(e,t,n){const{elements:r}=t,i=r.length,o=t.kind;for(let s=0;se.set(c,s))}function vct(e,t,n){if(t.model!==n.model||"mmCIF"!==t.model.sourceData.kind)return;const r=oh.Provider.get(t.model);if(!r)return;const i=new Map,o=new Map;dde(i,t,r),dde(o,n,r),i.forEach((s,a)=>{const c=o.get(a);void 0!==c&&e.push(KE(t,s,n,c,r,a),KE(n,c,t,s,r,a))})}function _ct(e,t){if("mmCIF"!==t.model.sourceData.kind)return;const n=oh.Provider.get(t.model);if(!n)return;const{elements:r}=t,i=r.length,o=t.kind,s=new Map;for(let a=0;a{const l=s.get(u);l?l.push(a):s.set(u,[a])});s.forEach((a,c)=>{if(a.length<2)return;const[u,l]=a;e.push(KE(t,u,t,l,n,c),KE(t,l,t,u,n,c))})}function KE(e,t,n,r,i,o){return{unitA:e,indexA:t,unitB:n,indexB:r,restraintType:i.data.restraint_type.value(o),distanceThreshold:i.data.distance_threshold.value(o),psi:i.data.psi.value(o),sigma1:i.data.sigma_1.value(o),sigma2:i.data.sigma_2.value(o)}}function xct(e){const t=[];if(!e.models.some(r=>oh.Provider.get(r)))return new lde(t);const n=e.units.length;for(let r=0;r{const m=o.pairs[p],h=m.unitA,g=m.unitB;h.conformation.position(h.elements[m.indexA],d),g.conformation.position(g.elements[m.indexB],f)},radius:d=>{const f=o.pairs[d];return a.unit=f.unitA,a.element=f.unitA.elements[f.indexA],n.size.size(a)*s}},{mesh:u,boundingSphere:l}=B0(0,c,r,i);if(l)u.setBoundingSphere(l);else if(u.triangleCount>0){const d=_e.expand(_e(),t.boundary.sphere,1*s);u.setBoundingSphere(d)}return u}!function(e){let t;(t=e.Tag||(e.Tag={})).CrossLinkRestraint="cross-link-restraint",e.isApplicable=function n(h){return h.models.some(g=>!!oh.Provider.get(g))};const r=v(),i=v();function o(h){return h.unitA.conformation.position(h.unitA.elements[h.indexA],r),h.unitB.conformation.position(h.unitB.elements[h.indexB],i),v.distance(r,i)}function u(h,g){const y=h.pairs[g];return`Cross Link Restraint | Type: ${y.restraintType} | Threshold: ${y.distanceThreshold} \u212b | Psi: ${y.psi} | Sigma 1: ${y.sigma1} | Sigma 2: ${y.sigma2} | Distance: ${o(y).toFixed(2)} \u212b`}function p(h,g,y){return Og.fromPairProvider(g.length,(b,x,_)=>{const S=h.pairs[g[b]];S.unitA.conformation.position(S.unitA.elements[S.indexA],x),S.unitB.conformation.position(S.unitB.elements[S.indexB],_)},y)}function m(h,g,y){const b=y[0];if(void 0===b)return"";const x=g.pairs[b];return[u(g,b),c8(Lt.Location(h,x.unitA,x.indexA,h,x.unitB,x.indexB))].join("
")}e.distance=o,e.Location=function s(h,g,y){return yre("cross-link-restraints",{structure:g,crossLinkRestraints:h},y)},e.isLocation=function a(h){return!!h&&"data-location"===h.kind&&"cross-link-restraints"===h.tag},e.areLocationsEqual=function c(h,g){return h.data.structure===g.data.structure&&h.data.crossLinkRestraints===g.data.crossLinkRestraints&&h.element===g.element},e.locationLabel=function l(h){return u(h.data.crossLinkRestraints,h.element)},e.Loci=function d(h,g,y){return eE("cross-link-restraints",{structure:h,crossLinkRestraints:g},y,b=>p(g,y,b),()=>m(h,g,y))},e.isLoci=function f(h){return!!h&&"data-loci"===h.kind&&"interactions"===h.tag},e.getBoundingSphere=p,e.getLabel=m}(yd||(yd={}));const fde={...r1,...F0,sizeFactor:C.Numeric(.5,{min:0,max:10,step:.1})};function Cct(e){return rh({defaultProps:C.getDefaultValues(fde),createGeometry:Sct,createLocationIterator:wct,getLoci:Act,eachLocation:Ict,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.radialSegments!==r.radialSegments||n.linkCap!==r.linkCap}},e)}function wct(e){const t=sh.get(e).value,{pairs:n}=t,r=n.length,o=yd.Location(t,e);return Mr(r,1,1,a=>(o.element=a,o),!0)}function Act(e,t,n){const{objectId:r,groupId:i}=e;if(n===r){const o=sh.get(t).value;if(o.pairs[i])return yd.Loci(t,o,[i])}return $n}function Ict(e,t,n){let r=!1;if(yd.isLoci(e)){if(!Ve.areEquivalent(e.data.structure,t))return!1;const i=sh.get(t).value;if(e.data.crossLinkRestraints!==i)return!1;for(const o of e.elements)n(Ce.ofSingleton(o))&&(r=!0)}return r}const Tct={"cross-link-restraint":(e,t)=>Iu("Cross-link restraint",e,t,Cct)},pde={...fde},hde={name:yd.Tag.CrossLinkRestraint,label:"Cross Link Restraint",description:"Displays cross-link restraints.",factory:function Ect(e,t){return yn.createMulti("CrossLinkRestraint",e,t,ms,Tct)},getParams:function Dct(e,t){return C.clone(pde)},defaultValues:C.getDefaultValues(pde),defaultColorTheme:{name:yd.Tag.CrossLinkRestraint},defaultSizeTheme:{name:"uniform"},isApplicable:e=>yd.isApplicable(e),ensureCustomProperties:{attach:(e,t)=>sh.attach(e,t,void 0,!0),detach:e=>sh.ref(e,!1)}},mde=st(13421772),gde={domain:C.Interval([.5,1.5],{step:.01}),list:C.ColorList("red-grey",{presetKind:"scale"})},bde={name:"cross-link",label:"Cross Link",category:Lc.Category.Misc,factory:function yde(e,t){let n,r;const i=e.structure&&sh.get(e.structure).value;if(i){r=Gu.create({domain:t.domain,listOrName:t.list.colors});const o=r.color;n=s=>{if(yd.isLocation(s)){const a=i.pairs[s.element];if(a)return o(yd.distance(a)/a.distanceThreshold)}return mde}}else n=()=>mde;return{factory:yde,granularity:"group",color:n,props:t,description:"Colors cross-links by the deviation of the observed distance versus the modeled distance (e.g. modeled / `ihm_cross_link_restraint.distance_threshold`).",legend:r?r.legend:void 0}},getParams:function Mct(e){return gde},defaultValues:C.getDefaultValues(gde),isApplicable:e=>!!e.structure&&yd.isApplicable(e.structure),ensureCustomProperties:{attach:(e,t)=>t.structure?sh.attach(e,t.structure,void 0,!0):Promise.resolve(),detach:e=>e.structure&&sh.ref(e.structure,!1)}},Rct=tr.create({name:"integrative-cross-link-restraint",category:"custom-props",display:{name:"Cross Link Restraint"},ctor:class extends tr.Handler{constructor(){super(...arguments),this.provider=oh.Provider}register(){this.provider.formatRegistry.add("mmCIF",kct),this.ctx.representation.structure.themes.colorThemeRegistry.add(bde),this.ctx.representation.structure.registry.add(hde)}unregister(){this.provider.formatRegistry.remove("mmCIF"),this.ctx.representation.structure.themes.colorThemeRegistry.remove(bde),this.ctx.representation.structure.registry.remove(hde)}}});function kct(e){if(!Er.is(e.sourceData))return;const{ihm_cross_link_restraint:t}=e.sourceData.data.db;return 0!==t._rowCount?oh.fromTable(t,e):void 0}const ZE={State:YP,Representation:XP,Camera:KP,Misc:ZP},zc={Representation:QP,Camera:JP,CustomProps:eM};function QE(e,t,n={}){return"string"==typeof n.type||"string"==typeof n.color||"string"==typeof n.size?function Nct(e,t,n){const r=n.type&&e.representation.structure.registry.get(n.type)||e.representation.structure.registry.default.provider,i=n.color&&e.representation.structure.themes.colorThemeRegistry.get(n.color)||e.representation.structure.themes.colorThemeRegistry.get(r.defaultColorTheme.name),o=n.size&&e.representation.structure.themes.sizeThemeRegistry.get(n.size)||e.representation.structure.themes.sizeThemeRegistry.get(r.defaultSizeTheme.name);return _de(e,t,{type:r,typeParams:n.typeParams,color:i,colorParams:n.colorParams,size:o,sizeParams:n.sizeParams})}(e,t||Ve.Empty,n):_de(e,t||Ve.Empty,n)}function MU(e,t,n,r,i){const{registry:o,themes:s}=e.representation.structure,a=o.get(n||o.default.name),c=s.colorThemeRegistry.get(r||a.defaultColorTheme.name),u=C.getDefaultValues(c.getParams({structure:t||Ve.Empty}));return c.name===a.defaultColorTheme.name&&Object.assign(u,a.defaultColorTheme.props),{name:c.name,params:Object.assign(u,i)}}function vde(e,t,n,r,i){const{registry:o,themes:s}=e.representation.structure,a=o.get(n||o.default.name),c=s.sizeThemeRegistry.get(r||a.defaultSizeTheme.name),u=C.getDefaultValues(c.getParams({structure:t||Ve.Empty}));return c.name===a.defaultSizeTheme.name&&Object.assign(u,a.defaultSizeTheme.props),{name:c.name,params:Object.assign(u,i)}}function _de(e,t,n={}){const{themes:r}=e.representation.structure,i={structure:t},o=n.type||e.representation.structure.registry.default.provider,s=C.getDefaultValues(o.getParams(r,t)),a=Object.assign(s,n.typeParams),c=n.color||r.colorThemeRegistry.get(o.defaultColorTheme.name),u=C.getDefaultValues(c.getParams(i));c.name===o.defaultColorTheme.name&&Object.assign(u,o.defaultColorTheme.props);const l=Object.assign(u,n.colorParams),d=n.size||r.sizeThemeRegistry.get(o.defaultSizeTheme.name),f=C.getDefaultValues(d.getParams(i));d.name===o.defaultSizeTheme.name&&Object.assign(f,o.defaultSizeTheme.props);const p=Object.assign(f,n.sizeParams);return{type:{name:o.name,params:a},colorTheme:{name:c.name,params:l},sizeTheme:{name:d.name,params:p}}}const xde=["target","surroundings","interactions"];var oi=function(e){return e.TargetSel="structure-focus-target-sel",e.TargetRepr="structure-focus-target-repr",e.SurrSel="structure-focus-surr-sel",e.SurrRepr="structure-focus-surr-repr",e.SurrNciRepr="structure-focus-surr-nci-repr",e}(oi||{});const Bct=new Set([oi.TargetSel,oi.TargetRepr,oi.SurrSel,oi.SurrRepr,oi.SurrNciRepr]),JE=tr.create({name:"create-structure-focus-representation",display:{name:"Structure Focus Representation"},category:"interaction",ctor:class Oct extends tr.WithSubscribers{constructor(){super(...arguments),this.currentSource=void 0}get surrLabel(){return`[Focus] Surroundings (${this.params.expandRadius} \xc5)`}getReprParams(t){return{...t,type:{name:t.type.name,params:{...t.type.params,ignoreHydrogens:this.params.ignoreHydrogens,ignoreHydrogensVariant:this.params.ignoreHydrogensVariant,ignoreLight:this.params.ignoreLight,material:this.params.material,clip:this.params.clip}}}}ensureShape(t){var n;const r=this.plugin.state.data,i=r.tree,o=r.build(),s=In.findUniqueTagsInSubtree(i,t.transform.ref,Bct);s[oi.TargetSel]||(s[oi.TargetSel]=o.to(t).apply(Ye.Model.StructureSelectionFromBundle,{bundle:Kn.Empty,label:"[Focus] Target"},{tags:oi.TargetSel}).ref),s[oi.SurrSel]||(s[oi.SurrSel]=o.to(t).apply(Ye.Model.StructureSelectionFromExpression,{expression:ue.struct.generator.empty(),label:this.surrLabel},{tags:oi.SurrSel}).ref);const a=this.params.components;return a.indexOf("target")>=0&&!s[oi.TargetRepr]&&(s[oi.TargetRepr]=o.to(s[oi.TargetSel]).apply(Ye.Representation.StructureRepresentation3D,this.getReprParams(this.params.targetParams),{tags:oi.TargetRepr}).ref),a.indexOf("surroundings")>=0&&!s[oi.SurrRepr]&&(s[oi.SurrRepr]=o.to(s[oi.SurrSel]).apply(Ye.Representation.StructureRepresentation3D,this.getReprParams(this.params.surroundingsParams),{tags:oi.SurrRepr}).ref),a.indexOf("interactions")>=0&&!s[oi.SurrNciRepr]&&t.obj&&XE.isApplicable(null===(n=t.obj)||void 0===n?void 0:n.data)&&(s[oi.SurrNciRepr]=o.to(s[oi.SurrSel]).apply(Ye.Representation.StructureRepresentation3D,this.getReprParams(this.params.nciParams),{tags:oi.SurrNciRepr}).ref),{state:r,builder:o,refs:s}}clear(t){const n=this.plugin.state.data;this.currentSource=void 0;const r=n.select(In.Generators.byRef(t).subtree().withTag(oi.TargetSel)),i=n.select(In.Generators.byRef(t).subtree().withTag(oi.SurrSel));if(0===r.length&&0===i.length)return;const o=n.build(),s=Kn.Empty;for(const c of r)o.to(c).update(Ye.Model.StructureSelectionFromBundle,u=>({...u,bundle:s}));const a=ue.struct.generator.empty();for(const c of i)o.to(c).update(Ye.Model.StructureSelectionFromExpression,u=>({...u,expression:a}));return Cn.State.Update(this.plugin,{state:n,tree:o,options:{doNotLogTiming:!0,doNotUpdateCurrent:!0}})}focus(t){var n=this;return ie(function*(){const r=n.plugin.helpers.substructureParent.get(t.structure);if(!r||!r.obj)return;n.currentSource=t;const i=De.remap(t,r.obj.data),o=De.extendToWholeResidues(i),s=Kn.fromLoci(o),a=Kn.toExpression(s);let c=ue.struct.modifier.includeSurroundings({0:a,radius:n.params.expandRadius,"as-whole-residues":!0});n.params.excludeTargetFromSurroundings&&(c=ue.struct.modifier.exceptBy({0:c,by:a}));const{state:u,builder:l,refs:d}=n.ensureShape(r);l.to(d[oi.TargetSel]).update(Ye.Model.StructureSelectionFromBundle,f=>({...f,bundle:s})),l.to(d[oi.SurrSel]).update(Ye.Model.StructureSelectionFromExpression,f=>({...f,expression:c,label:n.surrLabel})),yield Cn.State.Update(n.plugin,{state:u,tree:l,options:{doNotLogTiming:!0,doNotUpdateCurrent:!0}})})()}register(t){this.subscribeObservable(this.plugin.managers.structure.focus.behaviors.current,n=>{n?this.focus(n.loci):this.clear(ur.RootRef)})}update(t){var n=this;return ie(function*(){const r=n.params;if(n.params=t,r.excludeTargetFromSurroundings!==t.excludeTargetFromSurroundings)return n.currentSource&&n.focus(n.currentSource),!0;const i=n.plugin.state.data,o=i.build(),s=In.Generators.root.subtree(),a=n.params.components;let c=a.indexOf("target")>=0;for(const u of i.select(s.withTag(oi.TargetRepr)))c?o.to(u).update(n.getReprParams(n.params.targetParams)):o.delete(u.transform.ref);c=a.indexOf("surroundings")>=0;for(const u of i.select(s.withTag(oi.SurrRepr)))c?o.to(u).update(n.getReprParams(n.params.surroundingsParams)):o.delete(u.transform.ref);c=a.indexOf("interactions")>=0;for(const u of i.select(s.withTag(oi.SurrNciRepr)))c?o.to(u).update(n.getReprParams(n.params.nciParams)):o.delete(u.transform.ref);return yield Cn.State.Update(n.plugin,{state:i,tree:o,options:{doNotLogTiming:!0,doNotUpdateCurrent:!0}}),t.expandRadius!==r.expandRadius&&n.currentSource&&n.focus(n.currentSource),!0})()}},params:(e,t)=>(e=>{const t=Ye.Representation.StructureRepresentation3D.definition.params(void 0,e);return{expandRadius:C.Numeric(5,{min:1,max:10,step:1}),targetParams:C.Group(t,{label:"Target",customDefault:QE(e,void 0,{type:"ball-and-stick",size:"physical",typeParams:{sizeFactor:.22,sizeAspectRatio:.73,adjustCylinderLength:!0,xrayShaded:!0,aromaticBonds:!1,multipleBonds:"off",excludeTypes:["hydrogen-bond","metal-coordination"]}})}),surroundingsParams:C.Group(t,{label:"Surroundings",customDefault:QE(e,void 0,{type:"ball-and-stick",size:"physical",typeParams:{sizeFactor:.16,excludeTypes:["hydrogen-bond","metal-coordination"]}})}),nciParams:C.Group(t,{label:"Non-covalent Int.",customDefault:QE(e,void 0,{type:XE,color:_U,size:Qo.BuiltIn.uniform})}),components:C.MultiSelect(xde,C.arrayToOptions(xde)),excludeTargetFromSurroundings:C.Boolean(!1,{label:"Exclude Target",description:'Exclude the focus "target" from the surroudings component.'}),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),ignoreLight:C.Boolean(!1),material:ba.getParam(),clip:C.Group(gm.Params)}})(t)});function oa(e){return e}!function(e){function t(o){return"chain-id"===o?{name:o,params:use.defaultValues}:"operator-name"===o?{name:o,params:N6.defaultValues}:{name:o,params:{}}}e.CommonParams={ignoreHydrogens:C.Optional(C.Boolean(!1)),ignoreHydrogensVariant:C.Optional(C.Select("all",C.arrayToOptions(["all","non-polar"]))),ignoreLight:C.Optional(C.Boolean(!1)),quality:C.Optional(C.Select("auto",t5)),theme:C.Optional(C.Group({globalName:C.Optional(C.Text("")),globalColorParams:C.Optional(C.Value({},{isHidden:!0})),carbonColor:C.Optional(C.Select("chain-id",C.arrayToOptions(["chain-id","operator-name","element-symbol"]))),symmetryColor:C.Optional(C.Text("")),symmetryColorParams:C.Optional(C.Value({},{isHidden:!0})),focus:C.Optional(C.Group({name:C.Optional(C.Text("")),params:C.Optional(C.Value({}))}))}))},e.reprBuilder=function r(o,s,a){var c,u,l,d,f,p,m,h,g,y,b,x,_,S;const A=o.state.data.build(),E=o.builders.structure.representation,w=o.managers.structure.component.state.options.hydrogens,D={quality:o.managers.structure.component.state.options.visualQuality,ignoreHydrogens:"all"!==w,ignoreHydrogensVariant:"only-polar"===w?"non-polar":"all",ignoreLight:o.managers.structure.component.state.options.ignoreLight};s.quality&&"auto"!==s.quality&&(D.quality=s.quality),void 0!==s.ignoreHydrogens&&(D.ignoreHydrogens=!!s.ignoreHydrogens),void 0!==s.ignoreHydrogensVariant&&(D.ignoreHydrogensVariant=s.ignoreHydrogensVariant),void 0!==s.ignoreLight&&(D.ignoreLight=!!s.ignoreLight);const I=null!==(c=s.theme)&&void 0!==c&&c.globalName?null===(u=s.theme)||void 0===u?void 0:u.globalName:void 0,R=void 0!==(null===(l=s.theme)||void 0===l?void 0:l.carbonColor)?{carbonColor:t(null===(d=s.theme)||void 0===d?void 0:d.carbonColor),...null===(f=s.theme)||void 0===f?void 0:f.globalColorParams}:{...null===(p=s.theme)||void 0===p?void 0:p.globalColorParams},T=a&&null!==(m=s.theme)&&void 0!==m&&m.symmetryColor&&function n(o){return o.units.some(s=>!s.conformation.operator.assembly&&s.conformation.operator.spgrOp>=0)}(a)?null===(h=s.theme)||void 0===h?void 0:h.symmetryColor:I;return{update:A,builder:E,color:I,symmetryColor:T,symmetryColorParams:null!==(g=s.theme)&&void 0!==g&&g.symmetryColorParams?{...null===(y=s.theme)||void 0===y?void 0:y.globalColorParams,...null===(b=s.theme)||void 0===b?void 0:b.symmetryColorParams}:{...null===(x=s.theme)||void 0===x?void 0:x.globalColorParams},globalColorParams:null!==(_=s.theme)&&void 0!==_&&_.globalColorParams?{...null===(S=s.theme)||void 0===S?void 0:S.globalColorParams}:void 0,typeParams:D,ballAndStickColor:R}},e.updateFocusRepr=function i(o,s,a,c){if(o.state.hasBehavior(JE))return o.state.updateBehavior(JE,u=>{const l=MU(o,s,"ball-and-stick",a||"element-symbol",c);u.surroundingsParams.colorTheme=l,u.targetParams.colorTheme=l})}}(oa||(oa={}));const km=oa.CommonParams,O0=oa.reprBuilder,L0=oa.updateFocusRepr,Lct=oa({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:()=>km,apply(e,t,n){var r,i;const o=null===(i=null===(r=ls.resolveAndCheck(n.state.data,e))||void 0===r?void 0:r.obj)||void 0===i?void 0:i.data;if(!o)return{};const s=n.config.get(qi.Structure.SizeThresholds)||Ve.DefaultSizeThresholds,a=Ve.getSize(o,s),c=o.polymerResidueCount/o.polymerGapCount;switch(a){case Ve.Size.Gigantic:case Ve.Size.Huge:return Cde.apply(e,t,n);case Ve.Size.Large:return wde.apply(e,t,n);case Ve.Size.Medium:if(c>3)return Sde.apply(e,t,n);case Ve.Size.Small:return Ade.apply(e,{...t,showCarbohydrateSymbol:!0},n);default:Rr()}}}),Uct=oa({id:"preset-structure-representation-empty",display:{name:"Empty",description:"Removes all existing representations."},apply:(e,t,n)=>ie(function*(){return{}})()}),uC="Basic",Sde=oa({id:"preset-structure-representation-polymer-and-ligand",display:{name:"Polymer & Ligand",group:uC,description:"Shows polymers as Cartoon, ligands as Ball & Stick, carbohydrates as 3D-SNFG and water molecules semi-transparent."},params:()=>km,apply:(e,t,n)=>ie(function*(){var r,i,o,s,a,c,u,l,d,f;const p=ls.resolveAndCheck(n.state.data,e);if(!p)return{};const m={polymer:yield pc(n,p,"polymer"),ligand:yield pc(n,p,"ligand"),nonStandard:yield pc(n,p,"non-standard"),branched:yield pc(n,p,"branched",{label:"Carbohydrate"}),water:yield pc(n,p,"water"),ion:yield pc(n,p,"ion"),lipid:yield pc(n,p,"lipid"),coarse:yield pc(n,p,"coarse")},h=p.obj.data,g={sizeFactor:h.isCoarseGrained?.8:.2},y=((null===(o=null===(i=null===(r=m.water)||void 0===r?void 0:r.obj)||void 0===i?void 0:i.data)||void 0===o?void 0:o.elementCount)||0)>5e4?"line":"ball-and-stick",b=((null===(c=null===(a=null===(s=m.lipid)||void 0===s?void 0:s.obj)||void 0===a?void 0:a.data)||void 0===c?void 0:c.elementCount)||0)>2e4?"line":"ball-and-stick",{update:x,builder:_,typeParams:S,color:A,symmetryColor:E,symmetryColorParams:w,globalColorParams:D,ballAndStickColor:I}=O0(n,t,h),R={polymer:_.buildRepresentation(x,m.polymer,{type:"cartoon",typeParams:{...S,...g},color:E,colorParams:w},{tag:"polymer"}),ligand:_.buildRepresentation(x,m.ligand,{type:"ball-and-stick",typeParams:S,color:A,colorParams:I},{tag:"ligand"}),nonStandard:_.buildRepresentation(x,m.nonStandard,{type:"ball-and-stick",typeParams:S,color:A,colorParams:I},{tag:"non-standard"}),branchedBallAndStick:_.buildRepresentation(x,m.branched,{type:"ball-and-stick",typeParams:{...S,alpha:.3},color:A,colorParams:I},{tag:"branched-ball-and-stick"}),branchedSnfg3d:_.buildRepresentation(x,m.branched,{type:"carbohydrate",typeParams:S,color:A,colorParams:D},{tag:"branched-snfg-3d"}),water:_.buildRepresentation(x,m.water,{type:y,typeParams:{...S,alpha:.6,visuals:"line"===y?["intra-bond","element-point"]:void 0},color:A,colorParams:{carbonColor:{name:"element-symbol",params:{}},...D}},{tag:"water"}),ion:_.buildRepresentation(x,m.ion,{type:"ball-and-stick",typeParams:S,color:A,colorParams:{carbonColor:{name:"element-symbol",params:{}},...D}},{tag:"ion"}),lipid:_.buildRepresentation(x,m.lipid,{type:b,typeParams:{...S,alpha:.6,visuals:"line"===b?["intra-bond"]:void 0},color:A,colorParams:{carbonColor:{name:"element-symbol",params:{}},...D}},{tag:"lipid"}),coarse:_.buildRepresentation(x,m.coarse,{type:"spacefill",typeParams:S,color:A||"chain-id",colorParams:D},{tag:"coarse"})};return yield x.commit({revertOnError:!1}),yield L0(n,h,null===(l=null===(u=t.theme)||void 0===u?void 0:u.focus)||void 0===l?void 0:l.name,null===(f=null===(d=t.theme)||void 0===d?void 0:d.focus)||void 0===f?void 0:f.params),{components:m,representations:R}})()}),Vct=oa({id:"preset-structure-representation-protein-and-nucleic",display:{name:"Protein & Nucleic",group:uC,description:"Shows proteins as Cartoon and RNA/DNA as Gaussian Surface."},params:()=>km,apply:(e,t,n)=>ie(function*(){var r,i,o,s;const a=ls.resolveAndCheck(n.state.data,e);if(!a)return{};const c={protein:yield Ide(n,a,"protein"),nucleic:yield Ide(n,a,"nucleic")},u=a.obj.data,l={sizeFactor:u.isCoarseGrained?.8:.2},d={radiusOffset:u.isCoarseGrained?2:0,smoothness:u.isCoarseGrained?1:1.5},{update:f,builder:p,typeParams:m,symmetryColor:h,symmetryColorParams:g}=O0(n,t,u),y={protein:p.buildRepresentation(f,c.protein,{type:"cartoon",typeParams:{...m,...l},color:h,colorParams:g},{tag:"protein"}),nucleic:p.buildRepresentation(f,c.nucleic,{type:"gaussian-surface",typeParams:{...m,...d},color:h,colorParams:g},{tag:"nucleic"})};return yield f.commit({revertOnError:!0}),yield L0(n,u,null===(i=null===(r=t.theme)||void 0===r?void 0:r.focus)||void 0===i?void 0:i.name,null===(s=null===(o=t.theme)||void 0===o?void 0:o.focus)||void 0===s?void 0:s.params),{components:c,representations:y}})()}),Cde=oa({id:"preset-structure-representation-coarse-surface",display:{name:"Coarse Surface",group:uC,description:"Shows polymers and lipids as coarse Gaussian Surface."},params:()=>km,apply:(e,t,n)=>ie(function*(){var r,i,o,s;const a=ls.resolveAndCheck(n.state.data,e);if(!a)return{};const c={polymer:yield pc(n,a,"polymer"),lipid:yield pc(n,a,"lipid")},u=a.obj.data,l=n.config.get(qi.Structure.SizeThresholds)||Ve.DefaultSizeThresholds,d=Ve.getSize(u,l),f=Object.create(null);d===Ve.Size.Gigantic?Object.assign(f,{traceOnly:!u.isCoarseGrained,radiusOffset:2,smoothness:1,visuals:["structure-gaussian-surface-mesh"]}):d===Ve.Size.Huge?Object.assign(f,{radiusOffset:u.isCoarseGrained?2:0,smoothness:1}):u.isCoarseGrained&&Object.assign(f,{radiusOffset:2,smoothness:1});const{update:p,builder:m,typeParams:h,symmetryColor:g,symmetryColorParams:y}=O0(n,t,u),b={polymer:m.buildRepresentation(p,c.polymer,{type:"gaussian-surface",typeParams:{...h,...f},color:g,colorParams:y},{tag:"polymer"}),lipid:m.buildRepresentation(p,c.lipid,{type:"gaussian-surface",typeParams:{...h,...f},color:g,colorParams:y},{tag:"lipid"})};return yield p.commit({revertOnError:!0}),yield L0(n,u,null===(i=null===(r=t.theme)||void 0===r?void 0:r.focus)||void 0===i?void 0:i.name,null===(s=null===(o=t.theme)||void 0===o?void 0:o.focus)||void 0===s?void 0:s.params),{components:c,representations:b}})()}),wde=oa({id:"preset-structure-representation-polymer-cartoon",display:{name:"Polymer Cartoon",group:uC,description:"Shows polymers as Cartoon."},params:()=>km,apply:(e,t,n)=>ie(function*(){var r,i,o,s;const a=ls.resolveAndCheck(n.state.data,e);if(!a)return{};const c={polymer:yield pc(n,a,"polymer")},u=a.obj.data,l={sizeFactor:u.isCoarseGrained?.8:.2},{update:d,builder:f,typeParams:p,symmetryColor:m,symmetryColorParams:h}=O0(n,t,u),g={polymer:f.buildRepresentation(d,c.polymer,{type:"cartoon",typeParams:{...p,...l},color:m,colorParams:h},{tag:"polymer"})};return yield d.commit({revertOnError:!0}),yield L0(n,u,null===(i=null===(r=t.theme)||void 0===r?void 0:r.focus)||void 0===i?void 0:i.name,null===(s=null===(o=t.theme)||void 0===o?void 0:o.focus)||void 0===s?void 0:s.params),{components:c,representations:g}})()}),Ade=oa({id:"preset-structure-representation-atomic-detail",display:{name:"Atomic Detail",group:uC,description:"Shows everything in atomic detail with Ball & Stick."},params:()=>({...km,showCarbohydrateSymbol:C.Boolean(!1)}),apply:(e,t,n)=>ie(function*(){var r,i,o,s,a,c;const u=ls.resolveAndCheck(n.state.data,e);if(!u)return{};const l={all:yield pc(n,u,"all"),branched:void 0},d=u.obj.data,f=d.elementCount>1e5,p=d.atomicResidueCount&&d.elementCount>1e3&&d.atomicResidueCount/d.elementCount<3,m=d.models[0],h=!!Ms.Provider.get(m)||du.isExhaustive(m);let g="ball-and-stick";d.isCoarseGrained?g=d.elementCount>1e6?"point":"spacefill":p&&!h?g="spacefill":f&&(g="line");const y=t.showCarbohydrateSymbol&&!f&&!p;y&&Object.assign(l,{branched:yield pc(n,u,"branched",{label:"Carbohydrate"})});const{update:b,builder:x,typeParams:_,color:S,ballAndStickColor:A,globalColorParams:E}=O0(n,t,d),w=p&&!h?{carbonColor:{name:"element-symbol",params:{}},...E}:A,D={all:x.buildRepresentation(b,l.all,{type:g,typeParams:_,color:S,colorParams:w},{tag:"all"})};return y&&Object.assign(D,{snfg3d:x.buildRepresentation(b,l.branched,{type:"carbohydrate",typeParams:{..._,alpha:.4,visuals:["carbohydrate-symbol"]},color:S,colorParams:E},{tag:"snfg-3d"})}),yield b.commit({revertOnError:!0}),yield L0(n,d,null!==(o=null===(i=null===(r=t.theme)||void 0===r?void 0:r.focus)||void 0===i?void 0:i.name)&&void 0!==o?o:S,null!==(c=null===(a=null===(s=t.theme)||void 0===s?void 0:s.focus)||void 0===a?void 0:a.params)&&void 0!==c?c:w),{components:l,representations:D}})()}),zct=oa({id:"preset-structure-representation-illustrative",display:{name:"Illustrative",group:"Miscellaneous",description:"..."},params:()=>({...km,showCarbohydrateSymbol:C.Boolean(!1)}),apply:(e,t,n)=>ie(function*(){var r,i,o,s,a;const c=ls.resolveAndCheck(n.state.data,e);if(!c)return{};const u={all:yield pc(n,c,"all"),branched:void 0},l=c.obj.data,{update:d,builder:f,typeParams:p,color:m}=O0(n,t,l),h={all:f.buildRepresentation(d,u.all,{type:"spacefill",typeParams:{...p,ignoreLight:!0},color:"illustrative"},{tag:"all"})};return yield d.commit({revertOnError:!0}),yield L0(n,l,null!==(o=null===(i=null===(r=t.theme)||void 0===r?void 0:r.focus)||void 0===i?void 0:i.name)&&void 0!==o?o:m,null===(a=null===(s=t.theme)||void 0===s?void 0:s.focus)||void 0===a?void 0:a.params),{components:u,representations:h}})()}),Gct=oa({id:"preset-structure-representation-auto-lod",display:{name:"Automatic Detail",group:"Miscellaneous",description:"Shows more (or less) detailed representations automatically based on camera distance."},params:()=>km,apply:(e,t,n)=>ie(function*(){var r,i,o,s;const a=ls.resolveAndCheck(n.state.data,e);if(!a)return{};const c={all:yield pc(n,a,"all")},u=a.obj.data,l={sizeFactor:u.isCoarseGrained?.8:.2},{update:d,builder:f,typeParams:p,color:m,symmetryColor:h,symmetryColorParams:g,ballAndStickColor:y}=O0(n,t,u),b={gaussianSurface:f.buildRepresentation(d,c.all,{type:"gaussian-surface",typeParams:{...p,lod:v.create(30,1e7,100)},color:h,colorParams:g},{tag:"gaussian-surface"}),cartoon:f.buildRepresentation(d,c.all,{type:"cartoon",typeParams:{...p,...l,lod:v.create(-20,300,100)},color:h,colorParams:g},{tag:"cartoon"}),ballAndStick:f.buildRepresentation(d,c.all,{type:"ball-and-stick",typeParams:{...p,lod:v.create(-20,40,20)},color:m,colorParams:y},{tag:"ball-and-stick"})};return yield d.commit({revertOnError:!1}),yield L0(n,u,null===(i=null===(r=t.theme)||void 0===r?void 0:r.focus)||void 0===i?void 0:i.name,null===(s=null===(o=t.theme)||void 0===o?void 0:o.focus)||void 0===s?void 0:s.params),{components:c,representations:b}})()});function pc(e,t,n,r){return e.builders.structure.tryCreateComponentStatic(t,n,r)}function Ide(e,t,n,r){return e.builders.structure.tryCreateComponentFromSelection(t,No[n],`selection-${n}`,r)}const Mf={empty:Uct,auto:Lct,"atomic-detail":Ade,"polymer-cartoon":wde,"polymer-and-ligand":Sde,"protein-and-nucleic":Vct,"coarse-surface":Cde,illustrative:zct,"auto-lod":Gct};function e3(e,t){if("bcif"===e.ext)try{const{encoder:n}=$J(t);if(n.startsWith("VolumeServer"))return"dscif";if(n.startsWith("volseg-volume-server"))return"segcif"}catch(n){console.error(n)}else if("cif"===e.ext){const n=t;if(n.startsWith("data_SERVER\n#\n_density_server_result"))return"dscif";if(n.startsWith("data_SERVER\n#\ndata_SEGMENTATION_DATA"))return"segcif";if(n.includes("atom_site_fract_x")||n.includes("atom_site.fract_x"))return"coreCif"}return-1}const bd="Trajectory";function ah(e,t){return e.builders.structure.hierarchy.applyPreset(t.trajectory,"default")}const jct={label:"mmCIF",description:"mmCIF",category:bd,stringExtensions:["cif","mmcif","mcif"],binaryExtensions:["bcif"],isApplicable:(e,t)=>"mmcif"===e.ext||"mcif"===e.ext||("cif"===e.ext||"bcif"===e.ext)&&-1===e3(e,t),parse:function(){var e=ie(function*(t,n,r){var i,o;const a=t.state.data.build().to(n).apply(Ye.Data.ParseCif,void 0,{state:{isGhost:!0}}),c=yield a.apply(Ye.Model.TrajectoryFromMmCif,void 0,{tags:r?.trajectoryTags}).commit({revertOnError:!0});return((null===(o=null===(i=a.selector.cell)||void 0===i?void 0:i.obj)||void 0===o?void 0:o.data.blocks.length)||0)>1&&t.state.data.updateCellState(a.ref,{isGhost:!1}),{trajectory:c}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:ah},Hct={label:"cifCore",description:"CIF Core",category:bd,stringExtensions:["cif"],isApplicable:(e,t)=>"cif"===e.ext&&"coreCif"===e3(e,t),parse:function(){var e=ie(function*(t,n,r){var i,o;const a=t.state.data.build().to(n).apply(Ye.Data.ParseCif,void 0,{state:{isGhost:!0}}),c=yield a.apply(Ye.Model.TrajectoryFromCifCore,void 0,{tags:r?.trajectoryTags}).commit({revertOnError:!0});return((null===(o=null===(i=a.selector.cell)||void 0===i?void 0:i.obj)||void 0===o?void 0:o.data.blocks.length)||0)>1&&t.state.data.updateCellState(a.ref,{isGhost:!1}),{trajectory:c}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:ah};function U0(e,t){return function(){var n=ie(function*(r,i,o){return{trajectory:yield r.state.data.build().to(i).apply(e,t,{tags:o?.trajectoryTags}).commit({revertOnError:!0})}});return function(r,i,o){return n.apply(this,arguments)}}()}const qct={label:"PDB",description:"PDB",category:bd,stringExtensions:["pdb","ent"],parse:U0(Ye.Model.TrajectoryFromPDB),visuals:ah},Wct={label:"PDBQT",description:"PDBQT",category:bd,stringExtensions:["pdbqt"],parse:U0(Ye.Model.TrajectoryFromPDB,{isPdbqt:!0}),visuals:ah},$ct={label:"XYZ",description:"XYZ",category:bd,stringExtensions:["xyz"],parse:U0(Ye.Model.TrajectoryFromXYZ),visuals:ah},Tde=[["mmcif",jct],["cifCore",Hct],["pdb",qct],["pdbqt",Wct],["gro",{label:"GRO",description:"GRO",category:bd,stringExtensions:["gro"],binaryExtensions:[],parse:U0(Ye.Model.TrajectoryFromGRO),visuals:ah}],["xyz",$ct],["mol",{label:"MOL",description:"MOL",category:bd,stringExtensions:["mol"],parse:U0(Ye.Model.TrajectoryFromMOL),visuals:ah}],["sdf",{label:"SDF",description:"SDF",category:bd,stringExtensions:["sdf","sd"],parse:U0(Ye.Model.TrajectoryFromSDF),visuals:ah}],["mol2",{label:"MOL2",description:"MOL2",category:bd,stringExtensions:["mol2"],parse:U0(Ye.Model.TrajectoryFromMOL2),visuals:ah}]],Qct=["gz","zip"];function o1(e){let t=e,n="";const r=t.lastIndexOf("?"),i=-1!==r?t.substring(r):"";t=t.substring(0,-1===r?t.length:r);const o=t.replace(/^.*[\\/]/,"");let s=o.substring(0,o.lastIndexOf("."));const a=o.split(".");let c=a.length>1?(a.pop()||"").toLowerCase():"";const u=t.match(/^(.+):\/\/(.+)$/);u&&(n=u[1].toLowerCase(),t=u[2]||"");const l=t.substring(0,t.lastIndexOf("/")+1);return Qct.includes(c)&&(c=(t.substr(0,t.length-c.length-1).split(".").pop()||"").toLowerCase(),s=s.substr(0,s.length-c.length-1)),{path:t,name:o,ext:c,base:s,dir:l,protocol:n,query:i}}const lC="Topology",Jct={label:"PSF",description:"PSF",category:lC,stringExtensions:["psf"],parse:function(){var e=ie(function*(t,n){const r=t.state.data.build().to(n).apply(Ye.Data.ParsePsf,{},{state:{isGhost:!0}}),i=r.apply(Ye.Model.TopologyFromPsf);return yield r.commit(),{format:r.selector,topology:i.selector}});return function(n,r){return e.apply(this,arguments)}}()},eut={label:"PRMTOP",description:"PRMTOP",category:lC,stringExtensions:["prmtop","parm7"],parse:function(){var e=ie(function*(t,n){const r=t.state.data.build().to(n).apply(Ye.Data.ParsePrmtop,{},{state:{isGhost:!0}}),i=r.apply(Ye.Model.TopologyFromPrmtop);return yield r.commit(),{format:r.selector,topology:i.selector}});return function(n,r){return e.apply(this,arguments)}}()},tut={label:"TOP",description:"TOP",category:lC,stringExtensions:["top"],parse:function(){var e=ie(function*(t,n){const r=t.state.data.build().to(n).apply(Ye.Data.ParseTop,{},{state:{isGhost:!0}}),i=r.apply(Ye.Model.TopologyFromTop);return yield r.commit(),{format:r.selector,topology:i.selector}});return function(n,r){return e.apply(this,arguments)}}()},nut=[["psf",Jct],["prmtop",eut],["top",tut]],s1="Coordinates",rut={label:"DCD",description:"DCD",category:s1,binaryExtensions:["dcd"],parse:(e,t)=>e.state.data.build().to(t).apply(Ye.Model.CoordinatesFromDcd).commit()},iut={label:"XTC",description:"XTC",category:s1,binaryExtensions:["xtc"],parse:(e,t)=>e.state.data.build().to(t).apply(Ye.Model.CoordinatesFromXtc).commit()},out={label:"TRR",description:"TRR",category:s1,binaryExtensions:["trr"],parse:(e,t)=>e.state.data.build().to(t).apply(Ye.Model.CoordinatesFromTrr).commit()},sut={label:"NCTRAJ",description:"NCTRAJ",category:s1,binaryExtensions:["nc","nctraj"],parse:(e,t)=>e.state.data.build().to(t).apply(Ye.Model.CoordinatesFromNctraj).commit()},aut=[["dcd",rut],["xtc",iut],["trr",out],["nctraj",sut]],Dde={rcsb:C.Group({encoding:C.Select("bcif",C.arrayToOptions(["cif","bcif"]))},{label:"RCSB PDB",isFlat:!0}),pdbe:C.Group({variant:C.Select("updated-bcif",[["updated-bcif","Updated (bcif)"],["updated","Updated"],["archival","Archival"]])},{label:"PDBe",isFlat:!0}),pdbj:C.EmptyGroup({label:"PDBj"})},uut=nc.build({from:pe.Root,display:{name:"Download Structure",description:"Load a structure from the provided source and create its representation."},params:(e,t)=>{const n=(e=>{const t=e.config.get(qi.Structure.DefaultRepresentationPreset)||Mf.auto.id;return C.Group({type:b0.getParams(void 0,"auto").type,representation:C.Select(t,e.builders.structure.representation.getPresets().map(n=>[n.id,n.display.name,n.display.group]),{description:"Which representation preset to use."}),representationParams:C.Group(oa.CommonParams,{isHidden:!0}),asTrajectory:C.Optional(C.Boolean(!1,{description:"Load all entries into a single trajectory."}))},{isExpanded:!1})})(t),r=t.config.get(qi.Download.DefaultPdbProvider)||"pdbe";return{source:C.MappedStatic("pdb",{pdb:C.Group({provider:C.Group({id:C.Text("1tqn",{label:"PDB Id(s)",description:"One or more comma/space separated PDB ids."}),server:C.MappedStatic(r,Dde)},{pivot:"id"}),options:n},{isFlat:!0,label:"PDB"}),"pdb-dev":C.Group({provider:C.Group({id:C.Text("PDBDEV_00000001",{label:"PDB-Dev Id(s)",description:"One or more comma/space separated ids."}),encoding:C.Select("bcif",C.arrayToOptions(["cif","bcif"]))},{pivot:"id"}),options:n},{isFlat:!0,label:"PDB-Dev"}),swissmodel:C.Group({id:C.Text("Q9Y2I8",{label:"UniProtKB AC(s)",description:"One or more comma/space separated ACs."}),options:n},{isFlat:!0,label:"SWISS-MODEL",description:"Loads the best homology model or experimental structure"}),alphafolddb:C.Group({id:C.Text("Q8W3K0",{label:"UniProtKB AC(s)",description:"One or more comma/space separated ACs."}),options:n},{isFlat:!0,label:"AlphaFold DB",description:"Loads the predicted model if available"}),modelarchive:C.Group({id:C.Text("ma-bak-cepc-0003",{label:"Accession Code(s)",description:"One or more comma/space separated ACs."}),options:n},{isFlat:!0,label:"Model Archive"}),pubchem:C.Group({id:C.Text("2244,2245",{label:"PubChem ID",description:"One or more comma/space separated IDs."}),options:n},{isFlat:!0,label:"PubChem",description:"Loads 3D conformer from PubChem."}),url:C.Group({url:C.Url(""),format:C.Select("mmcif",C.arrayToOptions(Tde.map(i=>i[0]),i=>i)),isBinary:C.Boolean(!1),label:C.Optional(C.Text("")),options:n},{isFlat:!0,label:"URL"})})}}})(({params:e,state:t},n)=>Oe.create("Download Structure",function(){var r=ie(function*(i){n.behaviors.layout.leftPanelTabName.next("data");const o=e.source;let s,a=!1,c="mmcif";switch(o.name){case"url":s=[{url:o.params.url,isBinary:o.params.isBinary,label:o.params.label||void 0}],c=o.params.format;break;case"pdb":s=yield"pdbe"===o.params.provider.server.name?function lut(e){return kU.apply(this,arguments)}(o):"pdbj"===o.params.provider.server.name?function dut(e){return NU.apply(this,arguments)}(o):"rcsb"===o.params.provider.server.name?function fut(e){return FU.apply(this,arguments)}(o):Rr(),a=!!o.params.options.asTrajectory;break;case"pdb-dev":s=yield vd(o.params.provider.id,f=>{const p=f.toUpperCase().startsWith("PDBDEV_")?f:`PDBDEV_${f.padStart(8,"0")}`;return"bcif"===o.params.provider.encoding?`https://pdb-dev.wwpdb.org/bcif/${p.toUpperCase()}.bcif`:`https://pdb-dev.wwpdb.org/cif/${p.toUpperCase()}.cif`},f=>f.toUpperCase().startsWith("PDBDEV_")?f:`PDBDEV_${f.padStart(8,"0")}`,"bcif"===o.params.provider.encoding),a=!!o.params.options.asTrajectory;break;case"swissmodel":s=yield vd(o.params.id,f=>`https://swissmodel.expasy.org/repository/uniprot/${f.toUpperCase()}.pdb`,f=>`SWISS-MODEL: ${f}`,!1),a=!!o.params.options.asTrajectory,c="pdb";break;case"alphafolddb":s=yield vd(o.params.id,function(){var f=ie(function*(p){const m=`https://www.alphafold.ebi.ac.uk/api/prediction/${p.toUpperCase()}`,h=yield n.runTask(n.fetch({url:m,type:"json"}));if(Array.isArray(h)&&h.length>0)return h[0].cifUrl;throw new Error(`No AlphaFold DB entry for '${p}'`)});return function(p){return f.apply(this,arguments)}}(),f=>`AlphaFold DB: ${f}`,!1),a=!!o.params.options.asTrajectory,c="mmcif";break;case"modelarchive":s=yield vd(o.params.id,f=>`https://www.modelarchive.org/doi/10.5452/${f.toLowerCase()}.cif`,f=>`Model Archive: ${f}`,!1),a=!!o.params.options.asTrajectory,c="mmcif";break;case"pubchem":s=yield vd(o.params.id,f=>`https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/CID/${f.trim()}/record/SDF/?record_type=3d`,f=>`PubChem: ${f}`,!1),a=!!o.params.options.asTrajectory,c="mol";break;default:Rr()}const u=e.source.params.options.representation||n.config.get(qi.Structure.DefaultRepresentationPreset)||Mf.auto.id,l=u!==Mf.empty.id,d="auto"===o.params.options.type.name?void 0:o.params.options.type;yield t.transaction(ie(function*(){var f;if(s.length>0&&a){const p=yield n.builders.data.downloadBlob({sources:s.map((h,g)=>({id:""+g,url:h.url,isBinary:h.isBinary})),maxConcurrency:6},{state:{isGhost:!0}}),m=yield n.builders.structure.parseTrajectory(p,{formats:s.map((h,g)=>({id:""+g,format:"cif"}))});yield n.builders.structure.hierarchy.applyPreset(m,"default",{structure:d,showUnitcell:l,representationPreset:u,representationPresetParams:e.source.params.options.representationParams})}else for(const p of s){const m=yield n.builders.data.download(p,{state:{isGhost:!0}}),h="auto"===c?n.dataFormats.auto(o1(fr.getUrl(p.url)),null===(f=m.cell)||void 0===f?void 0:f.obj):n.dataFormats.get(c);if(!h)throw new Error("unknown file format");const g=yield n.builders.structure.parseTrajectory(m,h);yield n.builders.structure.hierarchy.applyPreset(g,"default",{structure:d,showUnitcell:l,representationPreset:u,representationPresetParams:e.source.params.options.representationParams})}})).runInContext(i)});return function(i){return r.apply(this,arguments)}}()));function vd(e,t,n,r){return RU.apply(this,arguments)}function RU(){return RU=ie(function*(e,t,n,r){const i=e.split(/[,\s]/).map(s=>s.trim()).filter(s=>!!s&&(s.length>=4||/^[1-9][0-9]*$/.test(s))),o=[];for(const s of i)o.push({url:fr.Url(yield t(s)),isBinary:r,label:n(s)});return o}),RU.apply(this,arguments)}function kU(){return kU=ie(function*(e){if("pdb"!==e.name||"pdbe"!==e.params.provider.server.name)throw new Error("expected pdbe");return"updated"===e.params.provider.server.params.variant?vd(e.params.provider.id,t=>`https://www.ebi.ac.uk/pdbe/static/entry/${t.toLowerCase()}_updated.cif`,t=>`PDBe: ${t} (updated cif)`,!1):"updated-bcif"===e.params.provider.server.params.variant?vd(e.params.provider.id,t=>`https://www.ebi.ac.uk/pdbe/entry-files/download/${t.toLowerCase()}.bcif`,t=>`PDBe: ${t} (updated cif)`,!0):vd(e.params.provider.id,t=>`https://www.ebi.ac.uk/pdbe/static/entry/${t.toLowerCase()}.cif`,t=>`PDBe: ${t} (cif)`,!1)}),kU.apply(this,arguments)}function NU(){return NU=ie(function*(e){if("pdb"!==e.name||"pdbj"!==e.params.provider.server.name)throw new Error("expected pdbj");return vd(e.params.provider.id,t=>`https://data.pdbjbk1.pdbj.org/pub/pdb/data/structures/divided/mmCIF/${t.toLowerCase().substring(1,3)}/${t.toLowerCase()}.cif`,t=>`PDBj: ${t} (cif)`,!1)}),NU.apply(this,arguments)}function FU(){return FU=ie(function*(e){if("pdb"!==e.name||"rcsb"!==e.params.provider.server.name)throw new Error("expected rcsb");return"cif"===e.params.provider.server.params.encoding?vd(e.params.provider.id,t=>`https://files.rcsb.org/download/${t.toUpperCase()}.cif`,t=>`RCSB PDB: ${t} (cif)`,!1):vd(e.params.provider.id,t=>`https://models.rcsb.org/${t.toUpperCase()}.bcif`,t=>`RCSB PDB: ${t} (bcif)`,!0)}),FU.apply(this,arguments)}const put=nc.build({display:{name:"Update Trajectory"},params:{action:C.Select("advance",C.arrayToOptions(["advance","reset"])),by:C.Optional(C.Numeric(1,{min:-1,max:1,step:1}))}})(({params:e,state:t})=>{const n=t.selectQ(i=>i.ofTransformer(Ye.Model.ModelFromTrajectory)),r=t.build();if("reset"===e.action)for(const i of n)r.to(i).update({modelIndex:0});else for(const i of n){const o=In.findAncestorOfType(t.tree,t.cells,i.transform.ref,pe.Molecule.Trajectory);if(!o||!o.obj)continue;const s=o.obj;r.to(i).update(a=>{let c=(a.modelIndex+e.by)%s.data.frameCount;return c<0&&(c+=s.data.frameCount),{modelIndex:c}})}return t.updateTree(r)}),hut=nc.build({display:{name:"Custom Model Properties",description:"Enable parameters for custom properties of the model."},from:pe.Molecule.Model,params:(e,t)=>t.customModelProperties.getParams(e?.data),isApplicable:(e,t,n)=>t.transformer!==Koe})(({ref:e,params:t},n)=>n.builders.structure.insertModelProperties(e,t)),mut=nc.build({display:{name:"Custom Structure Properties",description:"Enable parameters for custom properties of the structure."},from:pe.Molecule.Structure,params:(e,t)=>t.customStructureProperties.getParams(e?.data),isApplicable:(e,t,n)=>t.transformer!==Qoe})(({ref:e,params:t},n)=>n.builders.structure.insertStructureProperties(e,t)),gut=nc.build({display:{name:"Add Trajectory",description:"Add trajectory from existing model/topology and coordinates."},from:pe.Root,params(e,t){const n=t.state.data,i=[...n.selectQ(a=>a.rootsOfType(pe.Molecule.Model)),...n.selectQ(a=>a.rootsOfType(pe.Molecule.Topology))].map(a=>[a.transform.ref,a.obj.label]),s=n.selectQ(a=>a.rootsOfType(pe.Molecule.Coordinates)).map(a=>[a.transform.ref,a.obj.label]);return{model:C.Select(i.length?i[0][0]:"",i),coordinates:C.Select(s.length?s[0][0]:"",s)}}})(({params:e,state:t},n)=>Oe.create("Add Trajectory",r=>t.transaction(ie(function*(){const i=[e.model,e.coordinates],o=t.build().toRoot().apply(A6,{modelRef:e.model,coordinatesRef:e.coordinates},{dependsOn:i}).apply(Ye.Model.ModelFromTrajectory,{modelIndex:0});yield t.updateTree(o).runInContext(r);const s=yield n.builders.structure.createStructure(o.selector);yield n.builders.structure.representation.applyPreset(s,"auto")})).runInContext(r))),yut=nc.build({display:{name:"Load Trajectory",description:"Load trajectory of model/topology and coordinates from URL or file."},from:pe.Root,params(e,t){const{options:n}=t.dataFormats,r=n.filter(a=>a[2]===bd||a[2]===lC),i=n.filter(a=>a[2]===s1),o=[],s=[];for(const{provider:a}of t.dataFormats.list)a.category===bd||a.category===lC?(a.binaryExtensions&&o.push(...a.binaryExtensions),a.stringExtensions&&o.push(...a.stringExtensions)):a.category===s1&&(a.binaryExtensions&&s.push(...a.binaryExtensions),a.stringExtensions&&s.push(...a.stringExtensions));return{source:C.MappedStatic("file",{url:C.Group({model:C.Group({url:C.Url(""),format:C.Select(r[0][0],r),isBinary:C.Boolean(!1)},{isExpanded:!0}),coordinates:C.Group({url:C.Url(""),format:C.Select(i[0][0],i)},{isExpanded:!0})},{isFlat:!0}),file:C.Group({model:C.File({accept:o.map(a=>`.${a}`).join(","),label:"Model"}),coordinates:C.File({accept:s.map(a=>`.${a}`).join(","),label:"Coordinates"})},{isFlat:!0})},{options:[["url","URL"],["file","File"]]})}}})(({params:e,state:t},n)=>Oe.create("Load Trajectory",r=>t.transaction(ie(function*(){const i=e.source;if("file"===i.name&&(null===i.params.model||null===i.params.coordinates))return void n.log.error("No file(s) selected");if(!("url"!==i.name||i.params.model&&i.params.coordinates))return void n.log.error("No URL(s) given");const o=function(){var a=ie(function*(c,u,l){const d=yield n.builders.data.download({url:c,isBinary:l}),f=n.dataFormats.get(u);if(f)return f.parse(n,d);n.log.warn(`LoadTrajectory: could not find data provider for '${u}'`)});return function(u,l,d){return a.apply(this,arguments)}}(),s=function(){var a=ie(function*(c){var u,l,d;if(!c)throw new Error("No file selected");const f=o1(null!==(l=null===(u=c.file)||void 0===u?void 0:u.name)&&void 0!==l?l:""),p=n.dataFormats.binaryExtensions.has(f.ext),{data:m}=yield n.builders.data.readFile({file:c,isBinary:p}),h=n.dataFormats.auto(f,null===(d=m.cell)||void 0===d?void 0:d.obj);return h?h.parse(n,m):(n.log.warn(`LoadTrajectory: could not find data provider for '${f.ext}'`),void(yield n.state.data.build().delete(m).commit()))});return function(u){return a.apply(this,arguments)}}();try{const a="url"===i.name?yield o(i.params.model.url,i.params.model.format,i.params.model.isBinary):yield s(i.params.model);let c;c="trajectory"in a?yield t.build().to(a.trajectory).apply(qoe,{modelIndex:0}).commit():a.topology;const u="url"===i.name?yield o(i.params.coordinates.url,i.params.coordinates.format,!0):yield s(i.params.coordinates),l=[c.ref,u.ref],d=t.build().toRoot().apply(A6,{modelRef:c.ref,coordinatesRef:u.ref},{dependsOn:l}).apply(Ye.Model.ModelFromTrajectory,{modelIndex:0});yield t.updateTree(d).runInContext(r);const f=yield n.builders.structure.createStructure(d.selector);yield n.builders.structure.representation.applyPreset(f,"auto")}catch(a){console.error(a),n.log.error("Error loading trajectory")}})).runInContext(r))),but=nc.build({from:pe.Root,display:{name:"Download Density",description:"Load a density from the provided source and create its default visual."},params:(e,t)=>{const{options:n}=t.dataFormats;return{source:C.MappedStatic("pdb-xray",{"pdb-xray":C.Group({provider:C.Group({id:C.Text("1tqn",{label:"Id"}),server:C.Select("rcsb",[["pdbe","PDBe"],["rcsb","RCSB PDB"]])},{pivot:"id"}),type:C.Select("2fofc",[["2fofc","2Fo-Fc"],["fofc","Fo-Fc"]])},{isFlat:!0}),"pdb-xray-ds":C.Group({provider:C.Group({id:C.Text("1tqn",{label:"Id"}),server:C.Select("pdbe",[["pdbe","PDBe"],["rcsb","RCSB PDB"]])},{pivot:"id"}),detail:C.Numeric(3,{min:0,max:6,step:1},{label:"Detail"})},{isFlat:!0}),"pdb-emd-ds":C.Group({provider:C.Group({id:C.Text("emd-8004",{label:"Id"}),server:C.Select("pdbe",[["pdbe","PDBe"],["rcsb","RCSB PDB"]])},{pivot:"id"}),detail:C.Numeric(3,{min:0,max:6,step:1},{label:"Detail"})},{isFlat:!0}),url:C.Group({url:C.Url(""),isBinary:C.Boolean(!1),format:C.Select("auto",n)},{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"]]})}}})(({params:e},t)=>Oe.create("Download Density",function(){var n=ie(function*(r){var i,o;const s=e.source;let a,c;switch(s.name){case"url":a=s.params;break;case"pdb-xray":a="pdbe"===s.params.provider.server?{url:fr.Url("2fofc"===s.params.type?`https://www.ebi.ac.uk/pdbe/coordinates/files/${s.params.provider.id.toLowerCase()}.ccp4`:`https://www.ebi.ac.uk/pdbe/coordinates/files/${s.params.provider.id.toLowerCase()}_diff.ccp4`),isBinary:!0,label:`PDBe X-ray map: ${s.params.provider.id}`}:{url:fr.Url("2fofc"===s.params.type?`https://edmaps.rcsb.org/maps/${s.params.provider.id.toLowerCase()}_2fofc.dsn6`:`https://edmaps.rcsb.org/maps/${s.params.provider.id.toLowerCase()}_fofc.dsn6`),isBinary:!0,label:`RCSB X-ray map: ${s.params.provider.id}`};break;case"pdb-emd-ds":a="pdbe"===s.params.provider.server?{url:fr.Url(`https://www.ebi.ac.uk/pdbe/densities/emd/${s.params.provider.id.toLowerCase()}/cell?detail=${s.params.detail}`),isBinary:!0,label:`PDBe EMD Density Server: ${s.params.provider.id}`}:{url:fr.Url(`https://maps.rcsb.org/em/${s.params.provider.id.toLowerCase()}/cell?detail=${s.params.detail}`),isBinary:!0,label:`RCSB PDB EMD Density Server: ${s.params.provider.id}`};break;case"pdb-xray-ds":a="pdbe"===s.params.provider.server?{url:fr.Url(`https://www.ebi.ac.uk/pdbe/densities/x-ray/${s.params.provider.id.toLowerCase()}/cell?detail=${s.params.detail}`),isBinary:!0,label:`PDBe X-ray Density Server: ${s.params.provider.id}`}:{url:fr.Url(`https://maps.rcsb.org/x-ray/${s.params.provider.id.toLowerCase()}/cell?detail=${s.params.detail}`),isBinary:!0,label:`RCSB PDB X-ray Density Server: ${s.params.provider.id}`};break;default:Rr()}const u=yield t.builders.data.download(a);let l;switch(s.name){case"url":a=s.params,c="auto"===s.params.format?t.dataFormats.auto(o1(fr.getUrl(a.url)),null===(i=u.cell)||void 0===i?void 0:i.obj):t.dataFormats.get(s.params.format);break;case"pdb-xray":l=s.params.provider.id,c=t.dataFormats.get("pdbe"===s.params.provider.server?"ccp4":"dsn6");break;case"pdb-emd-ds":case"pdb-xray-ds":l=s.params.provider.id,c=t.dataFormats.get("dscif");break;default:Rr()}if(!c)return void t.log.warn("DownloadDensity: Format provider not found.");const d=yield c.parse(t,u,{entryId:l});yield null===(o=c.visuals)||void 0===o?void 0:o.call(c,t,d)});return function(r){return n.apply(this,arguments)}}())),Ede=nc.build({display:{name:"Assign Volume Colors",description:"Assigns another volume to be available for coloring."},from:pe.Volume.Data,isApplicable:e=>!e.data.colorVolume,params(e,t){const n=t.state.data.select(In.Generators.root.subtree().ofType(pe.Volume.Data).filter(r=>{var i;return!(!r.obj||null!==(i=r.obj)&&void 0!==i&&i.data.colorVolume||r.obj===e)}));return 0===n.length?{ref:C.Text("",{isHidden:!0,label:"Volume"})}:{ref:C.Select(n[0].transform.ref,n.map(r=>[r.transform.ref,r.obj.label]),{label:"Volume"})}}})(({ref:e,params:t},r)=>r.build().to(e).apply(Ye.Volume.AssignColorVolume,{ref:t.ref},{dependsOn:[t.ref]}).commit());function t3(e,t,n,r){return BU.apply(this,arguments)}function BU(){return BU=ie(function*(e,t,n,r){var i,o,s,a;const c=o1(null!==(o=null===(i=e.file)||void 0===i?void 0:i.name)&&void 0!==o?o:""),u=t.dataFormats.binaryExtensions.has(c.ext),{data:l}=yield t.builders.data.readFile({file:e,isBinary:u}),d="auto"===n?t.dataFormats.auto(c,null===(s=l.cell)||void 0===s?void 0:s.obj):t.dataFormats.get(n);if(!d)return t.log.warn(`OpenFiles: could not find data provider for '${c.ext}'`),void(yield t.state.data.build().delete(l).commit());const f=yield d.parse(t,l);r&&(yield null===(a=d.visuals)||void 0===a?void 0:a.call(d,t,f))}),BU.apply(this,arguments)}const Pde=nc.build({display:{name:"Open Files",description:"Load one or more files and optionally create default visuals"},from:pe.Root,params:(e,t)=>{const{extensions:n,options:r}=t.dataFormats;return{files:C.FileList({accept:Array.from(n.values()).map(i=>`.${i}`).join(",")+",.gz,.zip",multiple:!0}),format:C.MappedStatic("auto",{auto:C.EmptyGroup(),specific:C.Select(r[0][0],r)}),visuals:C.Boolean(!0,{description:"Add default visuals"})}}})(({params:e,state:t},n)=>Oe.create("Open Files",function(){var r=ie(function*(i){n.behaviors.layout.leftPanelTabName.next("data"),yield t.transaction(ie(function*(){if(null!==e.files)for(const o of e.files)try{if(o.file&&o.name.toLowerCase().endsWith(".zip")){const s=yield T2(i,yield o.file.arrayBuffer());for(const[a,c]of Object.entries(s)){if(!(c instanceof Uint8Array)||0===c.length)continue;const u=fr.File(new File([c],a));yield t3(u,n,"auto",e.visuals)}}else{const s="auto"===e.format.name?"auto":e.format.params;yield t3(o,n,s,e.visuals)}}catch(s){console.error(s),n.log.error(`Error opening file '${o.name}'`)}else n.log.error("No file(s) selected")})).runInContext(i)});return function(i){return r.apply(this,arguments)}}())),vut=nc.build({display:{name:"Download File",description:"Load one or more file from an URL"},from:pe.Root,params:(e,t)=>{const n=[...t.dataFormats.options,["zip","Zip"],["gzip","Gzip"]];return{url:C.Url(""),format:C.Select(n[0][0],n),isBinary:C.Boolean(!1),visuals:C.Boolean(!0,{description:"Add default visuals"})}}})(({params:e,state:t},n)=>Oe.create("Open Files",function(){var r=ie(function*(i){n.behaviors.layout.leftPanelTabName.next("data"),yield t.transaction(ie(function*(){var o,s,a;try{if("zip"===e.format||"gzip"===e.format){const c=yield n.builders.data.download({url:e.url,isBinary:!0});if("zip"===e.format){const u=yield T2(i,(null===(o=c.obj)||void 0===o?void 0:o.data).buffer);for(const[l,d]of Object.entries(u)){if(!(d instanceof Uint8Array)||0===d.length)continue;const f=fr.File(new File([d],l));yield t3(f,n,"auto",e.visuals)}}else{const l=o1(fr.getUrl(e.url)).name;yield t3(fr.File(new File([null===(s=c.obj)||void 0===s?void 0:s.data],l)),n,"auto",e.visuals)}}else{const c=n.dataFormats.get(e.format);if(!c)return void n.log.warn(`DownloadFile: could not find data provider for '${e.format}'`);const u=yield n.builders.data.download({url:e.url,isBinary:e.isBinary}),l=yield c.parse(n,u);e.visuals&&(yield null===(a=c.visuals)||void 0===a?void 0:a.call(c,n,l))}}catch(c){console.error(c),n.log.error(`Error downloading '${"string"==typeof e.url?e.url:e.url.url}'`)}})).runInContext(i)});return function(i){return r.apply(this,arguments)}}())),V0={Structure:tM,Volume:nM,DataFormat:rM};class OU extends(pe.Create({name:"Volume Streaming",typeClass:"Object"})){}var Mde,dC;function Rde(e,t,n,r){return LU.apply(this,arguments)}function LU(){return LU=ie(function*(e,t,n,r){switch(e){case"emdb":return kde(t,n,r);case"pdbe":return function wut(e,t,n){return VU.apply(this,arguments)}(t,n,r)}}),LU.apply(this,arguments)}function kde(e,t,n){return UU.apply(this,arguments)}function UU(){return UU=ie(function*(e,t,n){const r=e.config.get(qi.VolumeStreaming.EmdbHeaderServer),s=(yield e.fetch({url:`${r}/${n.toUpperCase()}/header/${n.toLowerCase()}.xml`,type:"xml"}).runInContext(t)).getElementsByTagName("map")[0].getElementsByTagName("contour");let a=s[0];for(let u=1;uu.primary))||void 0===o?void 0:o.level)&&void 0!==s?s:c[0].level:function Aut(e,t,n){return zU.apply(this,arguments)}(e,t,n)}),VU.apply(this,arguments)}function zU(){return zU=ie(function*(e,t,n){var r,i,o;n=n.toUpperCase();const s=yield e.fetch({url:`https://www.ebi.ac.uk/pdbe/api/emdb/entry/map/${n}`,type:"json"}).runInContext(t),a=s?.[n];let c;return void 0!==(null===(o=null===(i=null===(r=a?.[0])||void 0===r?void 0:r.map)||void 0===i?void 0:i.contour_level)||void 0===o?void 0:o.value)&&(c=+a[0].map.contour_level.value),c}),zU.apply(this,arguments)}function Iut(e,t,n){return GU.apply(this,arguments)}function GU(){return GU=ie(function*(e,t,n){var r;const i=yield e.fetch({url:`https://www.ebi.ac.uk/pdbe/api/pdb/entry/summary/${n}`,type:"json"}).runInContext(t),o=i?.[n],s=[];if(null===(r=o?.[0])||void 0===r||!r.related_structures)throw new Error(`No related EMDB entry found for '${n}'.`);{const a=o[0].related_structures.filter(c=>"EMDB"===c.resource&&"associated EM volume"===c.relationship);if(!a.length)throw new Error(`No related EMDB entry found for '${n}'.`);s.push(...a.map(c=>c.accession))}return s}),GU.apply(this,arguments)}!function(e){let t;var n;(n=t=e.ValueType||(e.ValueType={})).Float32="float32",n.Int8="int8"}(Mde||(Mde={})),function(e){e.create=function n(s){return{entries:wB(),capacity:Math.max(1,s)}},e.get=function r(s,a){for(let c=s.entries.first;c;c=c.next)if(c.value.key===a)return s.entries.remove(c),s.entries.addLast(c.value),c.value.data},e.set=function i(s,a,c){let u;if(s.entries.count>=s.capacity){const l=s.entries.first;u=l.value.data,s.entries.remove(l)}return s.entries.addLast(function t(s,a){return{key:s,data:a}}(a,c)),u},e.remove=function o(s,a){for(let c=s.entries.first;c;c=c.next)if(c.value.key===a){s.entries.remove(c);break}}}(dC||(dC={}));class Tut extends Fa{constructor(t,n){super()}schedule(t,n=0){return this}}const n3={setInterval(e,t,...n){const{delegate:r}=n3;return r?.setInterval?r.setInterval(e,t,...n):setInterval(e,t,...n)},clearInterval(e){const{delegate:t}=n3;return(t?.clearInterval||clearInterval)(e)},delegate:void 0};class fC{constructor(t,n=fC.now){this.schedulerActionCtor=t,this.now=n}schedule(t,n=0,r){return new this.schedulerActionCtor(this,t).schedule(r,n)}}fC.now=jF.now;const r3=new class Eut extends fC{constructor(t,n=fC.now){super(t,n),this.actions=[],this._active=!1}flush(t){const{actions:n}=this;if(this._active)return void n.push(t);let r;this._active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=n.shift());if(this._active=!1,r){for(;t=n.shift();)t.unsubscribe();throw r}}}(class Dut extends Tut{constructor(t,n){super(t,n),this.scheduler=t,this.work=n,this.pending=!1}schedule(t,n=0){var r;if(this.closed)return this;this.state=t;const i=this.id,o=this.scheduler;return null!=i&&(this.id=this.recycleAsyncId(o,i,n)),this.pending=!0,this.delay=n,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(o,this.id,n),this}requestAsyncId(t,n,r=0){return n3.setInterval(t.flush.bind(t,this),r)}recycleAsyncId(t,n,r=0){if(null!=r&&this.delay===r&&!1===this.pending)return n;null!=n&&n3.clearInterval(n)}execute(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;const r=this._execute(t,n);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))}_execute(t,n){let i,r=!1;try{this.work(t)}catch(o){r=!0,i=o||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),i}unsubscribe(){if(!this.closed){const{id:t,scheduler:n}=this,{actions:r}=n;this.work=this.state=this.scheduler=null,this.pending=!1,QC(r,this),null!=t&&(this.id=this.recycleAsyncId(n,t,null)),this.delay=null,super.unsubscribe()}}}),Put=r3;function Nde(e=0,t,n=Put){let r=-1;return null!=t&&(mK(t)?n=t:r=t),new ns(i=>{let o=function Rut(e){return e instanceof Date&&!isNaN(e)}(e)?+e-n.now():e;o<0&&(o=0);let s=0;return n.schedule(function(){i.closed||(i.next(s++),0<=r?this.schedule(void 0,r):i.complete())},o)})}function Fde(e,t=r3,n){const r=Nde(e,t);return function Mut(e,t){return mo((n,r)=>{const{leading:i=!0,trailing:o=!1}=t??{};let s=!1,a=null,c=null,u=!1;const l=()=>{c?.unsubscribe(),c=null,o&&(p(),u&&r.complete())},d=()=>{c=null,u&&r.complete()},f=m=>c=ru(e(m)).subscribe(Io(r,l,d)),p=()=>{if(s){s=!1;const m=a;a=null,r.next(m),!u&&f(m)}};n.subscribe(Io(r,m=>{s=!0,a=m,(!c||c.closed)&&(i?p():f(m))},()=>{u=!0,(!(o&&s&&c)||c.closed)&&r.complete()}))})}(()=>r,n)}function Bde(e,t=vh){return e=e??kut,mo((n,r)=>{let i,o=!0;n.subscribe(Io(r,s=>{const a=t(s);(o||!e(i,a))&&(o=!1,i=a,r.next(s))}))})}function kut(e,t){return e===t}class Nut{constructor(t=!1){this.isRunning=!1,this.queue=[],this.counter=0,this.log=t}enqueue(t){this.log&&console.log("SingleAsyncQueue enqueue",this.counter),this.queue[0]={id:this.counter,func:t},this.counter++,this.run()}run(){var t=this;return ie(function*(){if(t.isRunning)return;const n=t.queue.pop();if(n){t.isRunning=!0;try{t.log&&console.log("SingleAsyncQueue run",n.id),yield n.func(),t.log&&console.log("SingleAsyncQueue complete",n.id)}finally{t.isRunning=!1,t.run()}}})()}}class Tu extends(pe.CreateBehavior({name:"Volume Streaming"})){}function Nm(e,t,n){return{i:e,j:t,k:n}}function xl(e,t){return{a:e,b:t}}!function(e){function t(c,u,l,d,f={}){var p,m,h,g;return C.Group({isoValue:et.createIsoValueParam(null!==(p=f.isoValue)&&void 0!==p?p:l,d),color:C.Color(null!==(m=f.color)&&void 0!==m?m:u),wireframe:C.Boolean(null!==(h=f.wireframe)&&void 0!==h&&h),opacity:C.Numeric(null!==(g=f.opacity)&&void 0!==g?g:.3,{min:0,max:1,step:.01})},{label:c,isExpanded:!0})}e.RootTag="volume-streaming-info";const n={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 i(c){const{entryData:u,defaultView:l,structure:d,channelParams:f={}}=c,p=u||{kind:"em",header:{sampling:[n],availablePrecisions:[{precision:0,maxVoxels:0}]},emDefaultContourLevel:et.IsoValue.relative(0)},m=d&&d.boundary.box||St();return{view:C.MappedStatic(l||("em"===p.kind?"auto":"selection-box"),{off:C.Group({}),box:C.Group({bottomLeft:C.Vec3(m.min),topRight:C.Vec3(m.max)},{description:"Static box defined by cartesian coords.",isFlat:!0}),"selection-box":C.Group({radius:C.Numeric(5,{min:0,max:50,step:.5},{description:"Radius in \u212b within which the volume is shown."}),bottomLeft:C.Vec3(v.create(0,0,0),{},{isHidden:!0}),topRight:C.Vec3(v.create(0,0,0),{},{isHidden:!0})},{description:"Box around focused element.",isFlat:!0}),"camera-target":C.Group({radius:C.Numeric(.5,{min:0,max:1,step:.05},{description:"Radius within which the volume is shown (relative to the field of view)."}),dynamicDetailLevel:o(p.header.availablePrecisions,0,{label:"Dynamic Detail"}),bottomLeft:C.Vec3(v.create(0,0,0),{},{isHidden:!0}),topRight:C.Vec3(v.create(0,0,0),{},{isHidden:!0})},{description:"Box around camera target.",isFlat:!0}),cell:C.Group({}),auto:C.Group({radius:C.Numeric(5,{min:0,max:50,step:.5},{description:"Radius in \u212b within which the volume is shown."}),selectionDetailLevel:o(p.header.availablePrecisions,6,{label:"Selection Detail"}),isSelection:C.Boolean(!1,{isHidden:!0}),bottomLeft:C.Vec3(m.min,{},{isHidden:!0}),topRight:C.Vec3(m.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:o(p.header.availablePrecisions,3),channels:C.Group("em"===p.kind?{em:t("EM",st(6524815),p.emDefaultContourLevel||et.IsoValue.relative(1),p.header.sampling[0].valuesInfo[0],f.em)}:{"2fo-fc":t("2Fo-Fc",st(3367602),et.IsoValue.relative(1.5),p.header.sampling[0].valuesInfo[0],f["2fo-fc"]),"fo-fc(+ve)":t("Fo-Fc(+ve)",st(3390259),et.IsoValue.relative(3),p.header.sampling[0].valuesInfo[1],f["fo-fc(+ve)"]),"fo-fc(-ve)":t("Fo-Fc(-ve)",st(12268339),et.IsoValue.relative(-3),p.header.sampling[0].valuesInfo[1],f["fo-fc(-ve)"])},{isFlat:!0})}}function o(c,u,l){return C.Select(Math.min(u,c.length-1),c.map((d,f)=>[f,`${f+1} [ ${0|Math.pow(d.maxVoxels,1/3)}^3 cells ]`]),{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 s(c){return{entry:{name:c.entry.name,params:{detailLevel:c.entry.params.detailLevel,channels:c.entry.params.channels,view:{name:c.entry.params.view.name,params:{...c.entry.params.view.params}}}}}}e.createParams=function r(c={}){const{data:u,defaultView:l,channelParams:d}=c,f=new Map;u&&u.entries.forEach(h=>f.set(h.dataId,h));const p=u?u.entries.map(h=>[h.dataId,h.dataId]):[];return{entry:C.Mapped(u?u.entries[0].dataId:"",p,h=>C.Group(i({entryData:f.get(h),defaultView:l,structure:u&&u.structure,channelParams:d})))}},e.createEntryParams=i,e.copyParams=s,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)"]],e.Behavior=class a extends tr.WithSubscribers{get info(){return this.infoMap.get(this.params.entry.name)}queryData(u){var l=this;return ie(function*(){let d=x8(l.data.serverUrl,`${l.info.kind}/${l.info.dataId.toLowerCase()}`);if(u){const{min:b,max:x}=u;d+=`/box/${b.map(_=>Math.round(1e3*_)/1e3).join(",")}/${x.map(_=>Math.round(1e3*_)/1e3).join(",")}`}else d+="/cell";let f=l.params.entry.params.detailLevel;"auto"===l.params.entry.params.view.name&&l.params.entry.params.view.params.isSelection&&(f=l.params.entry.params.view.params.selectionDetailLevel),"camera-target"===l.params.entry.params.view.name&&u&&(f=l.decideDetail(u,l.params.entry.params.view.params.dynamicDetailLevel)),d+=`?detail=${f}`;const p=dC.get(l.cache,d);if(p)return p.data;const m=fr.getUrlAsset(l.plugin.managers.asset,d),h=yield l.plugin.runTask(l.plugin.managers.asset.resolve(m,"binary")),g=yield l.parseCif(h.data);if(!g)return;const y=dC.set(l.cache,d,{data:g,asset:h});return y&&y.asset.dispose(),g})()}parseCif(u){var l=this;return ie(function*(){const d=yield l.plugin.runTask(od.parseBinary(u));if(d.isError)return void l.plugin.log.error("VolumeStreaming, parsing CIF: "+d.toString());if(d.result.blocks.length<2)return void l.plugin.log.error("VolumeStreaming: Invalid data.");const f={};for(let p=1;p{!pe.Molecule.Structure.is(l.obj)||!De.is(this.lastLoci)||this.lastLoci.structure===l.obj.data&&(this.lastLoci=$n)}),this.subscribeObservable(this.plugin.state.events.object.updated,l=>{!pe.Molecule.Structure.is(l.oldObj)||!De.is(this.lastLoci)||this.lastLoci.structure===l.oldObj.data&&(this.lastLoci=$n)}),this.subscribeObservable(this.plugin.managers.structure.focus.behaviors.current,l=>{if(!this.plugin.state.data.tree.children.has(this.ref))return;const d=l?l.loci:$n;switch(this.params.entry.params.view.name){case"auto":this.updateAuto(d);break;case"selection-box":this.updateSelectionBox(d);break;default:this.lastLoci=d}})}unregister(){let u=this.cache.entries.first;for(;u;)u.value.data.asset.dispose(),u=u.next}isCameraTargetSame(u,l){if(!u||!l)return!1;const d=v.equals(u.target,l.target),f=v.squaredDistance(u.target,u.position),p=v.squaredDistance(l.target,l.position),m=Math.abs(f-p)/f<.001;return d&&m}cameraTargetDistance(u){return v.distance(u.target,u.position)}getBoxFromLoci(u){var l,d,f;if(pn.isEmpty(u)||Ta(u))return St();const p=this.plugin.helpers.substructureParent.get(u.structure,!0);if(!p)return St();const m=this.getStructureRoot();if(!m||(null===(l=m.obj)||void 0===l?void 0:l.data)!==(null===(d=p.obj)||void 0===d?void 0:d.data))return St();const h=Hg.get(null===(f=m.obj)||void 0===f?void 0:f.data.models[0]);h&&le.invert(this._invTransform,h);const g=De.extendToWholeResidues(u),y=De.getBoundary(g,h&&!Number.isNaN(this._invTransform[0])?this._invTransform:void 0).box;return 1===De.size(g)&&St.expand(y,y,v.create(1,1,1)),y}updateAuto(u){var l=this;this.updateQueue.enqueue(ie(function*(){l.lastLoci=u,Ta(u)?yield l.updateParams("x-ray"===l.info.kind?l.data.structure.boundary.box:void 0,!1):yield l.updateParams(l.getBoxFromLoci(u),!0)}))}updateSelectionBox(u){var l=this;this.updateQueue.enqueue(ie(function*(){l.lastLoci=pn.areEqual(l.lastLoci,u)?$n:u;const d=l.getBoxFromLoci(l.lastLoci);yield l.updateParams(d)}))}updateCameraTarget(u){var l=this;this.updateQueue.enqueue(ie(function*(){var d,f,p;const m=null===(d=l.plugin.canvas3d)||void 0===d?void 0:d.props.camera.manualReset;try{m||null===(f=l.plugin.canvas3d)||void 0===f||f.setProps({camera:{manualReset:!0}});const h=l.boxFromCameraTarget(u,!0);yield l.updateParams(h)}finally{m||null===(p=l.plugin.canvas3d)||void 0===p||p.setProps({camera:{manualReset:m}})}}))}boxFromCameraTarget(u,l){var d;const f=u.target,p=this.cameraTargetDistance(u);let h=Math.tan(.5*u.fov)*p;const g=null===(d=this.plugin.canvas3d)||void 0===d?void 0:d.camera.viewport;let b,x,_;if(g&&g.width>g.height&&(h*=g.width/g.height),h*="camera-target"===this.params.entry.params.view.name?this.params.entry.params.view.params.radius:.5,l){const S=v.zero();St.size(S,this.data.structure.boundary.box),b=Math.min(h,.5*S[0]),x=Math.min(h,.5*S[1]),_=Math.min(h,.5*S[2])}else b=x=_=h;return St.create(v.create(f[0]-b,f[1]-x,f[2]-_),v.create(f[0]+b,f[1]+x,f[2]+_))}decideDetail(u,l){const d="x-ray"===this.info.kind?St.volume(this.data.structure.boundary.box):this.info.header.spacegroup.size.reduce((g,y)=>g*y,1);let p=St.volume(u)/d;const m=this.info.header.availablePrecisions.length-1;let h=l;for(;p<=.5&&hl.updateCameraTarget(g))),f=l.boxFromCameraTarget(l.plugin.canvas3d.camera.getSnapshot(),!0);break;case"cell":f="x-ray"===l.info.kind?l.data.structure.boundary.box:void 0;break;case"auto":if(f=u.entry.params.view.params.isSelection||"x-ray"===l.info.kind?St.create(v.clone(u.entry.params.view.params.bottomLeft),v.clone(u.entry.params.view.params.topRight)):void 0,f&&(p=St.volume(f)<1e-4,u.entry.params.view.params.isSelection)){const g=u.entry.params.view.params.radius;St.expand(f,f,v.create(g,g,g))}}const m=p?{}:yield l.queryData(f);if(!m)return!1;const h=u.entry.params.channels;return"x-ray"===l.info.kind?(l.channels["2fo-fc"]=l.createChannel(m["2FO-FC"]||et.One,h["2fo-fc"],l.info.header.sampling[0].valuesInfo[0]),l.channels["fo-fc(+ve)"]=l.createChannel(m["FO-FC"]||et.One,h["fo-fc(+ve)"],l.info.header.sampling[0].valuesInfo[1]),l.channels["fo-fc(-ve)"]=l.createChannel(m["FO-FC"]||et.One,h["fo-fc(-ve)"],l.info.header.sampling[0].valuesInfo[1])):l.channels.em=l.createChannel(m.EM||et.One,h.em,l.info.header.sampling[0].valuesInfo[0]),!0})()}createChannel(u,l,d){return{data:u,color:l.color,wireframe:l.wireframe,opacity:l.opacity,isoValue:"relative"===l.isoValue.kind?l.isoValue:et.IsoValue.toRelative(l.isoValue,d)}}getDescription(){return"selection-box"===this.params.entry.params.view.name?"Selection":"camera-target"===this.params.entry.params.view.name?"Camera":"box"===this.params.entry.params.view.name?"Static Box":"cell"===this.params.entry.params.view.name?"Cell":""}constructor(u,l){super(u,{}),this.plugin=u,this.data=l,this.cache=dC.create(25),this.params={},this.lastLoci=$n,this.ref="",this.cameraTargetObservable=this.plugin.canvas3d.didDraw.pipe(Fde(500,void 0,{leading:!0,trailing:!0}),qt(()=>{var d;return null===(d=this.plugin.canvas3d)||void 0===d?void 0:d.camera.getSnapshot()}),Bde((d,f)=>this.isCameraTargetSame(d,f)),Yl(d=>void 0!==d)),this.cameraTargetSubscription=void 0,this.channels={},this._invTransform=le(),this.infoMap=new Map,this.data.entries.forEach(d=>this.infoMap.set(d.dataId,d)),this.updateQueue=new Nut}}}(Tu||(Tu={}));const lo=[Nm(0,0,0),Nm(1,0,0),Nm(1,1,0),Nm(0,1,0),Nm(0,0,1),Nm(1,0,1),Nm(1,1,1),Nm(0,1,1)],Fut=[xl(lo[0],lo[1]),xl(lo[1],lo[2]),xl(lo[2],lo[3]),xl(lo[3],lo[0]),xl(lo[4],lo[5]),xl(lo[5],lo[6]),xl(lo[6],lo[7]),xl(lo[7],lo[4]),xl(lo[0],lo[4]),xl(lo[1],lo[5]),xl(lo[2],lo[6]),xl(lo[3],lo[7])],But=[{i:0,j:0,k:0,e:0},{i:1,j:0,k:0,e:1},{i:0,j:1,k:0,e:0},{i:0,j:0,k:0,e:1},{i:0,j:0,k:1,e:0},{i:1,j:0,k:1,e:1},{i:0,j:1,k:1,e:0},{i:0,j:0,k:1,e:1},{i:0,j:0,k:0,e:2},{i:1,j:0,k:0,e:2},{i:1,j:1,k:0,e:2},{i:0,j:1,k:0,e:2}],Out=[0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0],a1=[[],[0,8,3],[0,1,9],[1,8,3,9,8,1],[1,2,10],[0,8,3,1,2,10],[9,2,10,0,2,9],[2,8,3,2,10,8,10,9,8],[3,11,2],[0,11,2,8,11,0],[1,9,0,2,3,11],[1,11,2,1,9,11,9,8,11],[3,10,1,11,10,3],[0,10,1,0,8,10,8,11,10],[3,9,0,3,11,9,11,10,9],[9,8,10,10,8,11],[4,7,8],[4,3,0,7,3,4],[0,1,9,8,4,7],[4,1,9,4,7,1,7,3,1],[1,2,10,8,4,7],[3,4,7,3,0,4,1,2,10],[9,2,10,9,0,2,8,4,7],[2,10,9,2,9,7,2,7,3,7,9,4],[8,4,7,3,11,2],[11,4,7,11,2,4,2,0,4],[9,0,1,8,4,7,2,3,11],[4,7,11,9,4,11,9,11,2,9,2,1],[3,10,1,3,11,10,7,8,4],[1,11,10,1,4,11,1,0,4,7,11,4],[4,7,8,9,0,11,9,11,10,11,0,3],[4,7,11,4,11,9,9,11,10],[9,5,4],[9,5,4,0,8,3],[0,5,4,1,5,0],[8,5,4,8,3,5,3,1,5],[1,2,10,9,5,4],[3,0,8,1,2,10,4,9,5],[5,2,10,5,4,2,4,0,2],[2,10,5,3,2,5,3,5,4,3,4,8],[9,5,4,2,3,11],[0,11,2,0,8,11,4,9,5],[0,5,4,0,1,5,2,3,11],[2,1,5,2,5,8,2,8,11,4,8,5],[10,3,11,10,1,3,9,5,4],[4,9,5,0,8,1,8,10,1,8,11,10],[5,4,0,5,0,11,5,11,10,11,0,3],[5,4,8,5,8,10,10,8,11],[9,7,8,5,7,9],[9,3,0,9,5,3,5,7,3],[0,7,8,0,1,7,1,5,7],[1,5,3,3,5,7],[9,7,8,9,5,7,10,1,2],[10,1,2,9,5,0,5,3,0,5,7,3],[8,0,2,8,2,5,8,5,7,10,5,2],[2,10,5,2,5,3,3,5,7],[7,9,5,7,8,9,3,11,2],[9,5,7,9,7,2,9,2,0,2,7,11],[2,3,11,0,1,8,1,7,8,1,5,7],[11,2,1,11,1,7,7,1,5],[9,5,8,8,5,7,10,1,3,10,3,11],[5,7,0,5,0,9,7,11,0,1,0,10,11,10,0],[11,10,0,11,0,3,10,5,0,8,0,7,5,7,0],[11,10,5,7,11,5],[10,6,5],[0,8,3,5,10,6],[9,0,1,5,10,6],[1,8,3,1,9,8,5,10,6],[1,6,5,2,6,1],[1,6,5,1,2,6,3,0,8],[9,6,5,9,0,6,0,2,6],[5,9,8,5,8,2,5,2,6,3,2,8],[2,3,11,10,6,5],[11,0,8,11,2,0,10,6,5],[0,1,9,2,3,11,5,10,6],[5,10,6,1,9,2,9,11,2,9,8,11],[6,3,11,6,5,3,5,1,3],[0,8,11,0,11,5,0,5,1,5,11,6],[3,11,6,0,3,6,0,6,5,0,5,9],[6,5,9,6,9,11,11,9,8],[5,10,6,4,7,8],[4,3,0,4,7,3,6,5,10],[1,9,0,5,10,6,8,4,7],[10,6,5,1,9,7,1,7,3,7,9,4],[6,1,2,6,5,1,4,7,8],[1,2,5,5,2,6,3,0,4,3,4,7],[8,4,7,9,0,5,0,6,5,0,2,6],[7,3,9,7,9,4,3,2,9,5,9,6,2,6,9],[3,11,2,7,8,4,10,6,5],[5,10,6,4,7,2,4,2,0,2,7,11],[0,1,9,4,7,8,2,3,11,5,10,6],[9,2,1,9,11,2,9,4,11,7,11,4,5,10,6],[8,4,7,3,11,5,3,5,1,5,11,6],[5,1,11,5,11,6,1,0,11,7,11,4,0,4,11],[0,5,9,0,6,5,0,3,6,11,6,3,8,4,7],[6,5,9,6,9,11,4,7,9,7,11,9],[10,4,9,6,4,10],[4,10,6,4,9,10,0,8,3],[10,0,1,10,6,0,6,4,0],[8,3,1,8,1,6,8,6,4,6,1,10],[1,4,9,1,2,4,2,6,4],[3,0,8,1,2,9,2,4,9,2,6,4],[0,2,4,4,2,6],[8,3,2,8,2,4,4,2,6],[10,4,9,10,6,4,11,2,3],[0,8,2,2,8,11,4,9,10,4,10,6],[3,11,2,0,1,6,0,6,4,6,1,10],[6,4,1,6,1,10,4,8,1,2,1,11,8,11,1],[9,6,4,9,3,6,9,1,3,11,6,3],[8,11,1,8,1,0,11,6,1,9,1,4,6,4,1],[3,11,6,3,6,0,0,6,4],[6,4,8,11,6,8],[7,10,6,7,8,10,8,9,10],[0,7,3,0,10,7,0,9,10,6,7,10],[10,6,7,1,10,7,1,7,8,1,8,0],[10,6,7,10,7,1,1,7,3],[1,2,6,1,6,8,1,8,9,8,6,7],[2,6,9,2,9,1,6,7,9,0,9,3,7,3,9],[7,8,0,7,0,6,6,0,2],[7,3,2,6,7,2],[2,3,11,10,6,8,10,8,9,8,6,7],[2,0,7,2,7,11,0,9,7,6,7,10,9,10,7],[1,8,0,1,7,8,1,10,7,6,7,10,2,3,11],[11,2,1,11,1,7,10,6,1,6,7,1],[8,9,6,8,6,7,9,1,6,11,6,3,1,3,6],[0,9,1,11,6,7],[7,8,0,7,0,6,3,11,0,11,6,0],[7,11,6],[7,6,11],[3,0,8,11,7,6],[0,1,9,11,7,6],[8,1,9,8,3,1,11,7,6],[10,1,2,6,11,7],[1,2,10,3,0,8,6,11,7],[2,9,0,2,10,9,6,11,7],[6,11,7,2,10,3,10,8,3,10,9,8],[7,2,3,6,2,7],[7,0,8,7,6,0,6,2,0],[2,7,6,2,3,7,0,1,9],[1,6,2,1,8,6,1,9,8,8,7,6],[10,7,6,10,1,7,1,3,7],[10,7,6,1,7,10,1,8,7,1,0,8],[0,3,7,0,7,10,0,10,9,6,10,7],[7,6,10,7,10,8,8,10,9],[6,8,4,11,8,6],[3,6,11,3,0,6,0,4,6],[8,6,11,8,4,6,9,0,1],[9,4,6,9,6,3,9,3,1,11,3,6],[6,8,4,6,11,8,2,10,1],[1,2,10,3,0,11,0,6,11,0,4,6],[4,11,8,4,6,11,0,2,9,2,10,9],[10,9,3,10,3,2,9,4,3,11,3,6,4,6,3],[8,2,3,8,4,2,4,6,2],[0,4,2,4,6,2],[1,9,0,2,3,4,2,4,6,4,3,8],[1,9,4,1,4,2,2,4,6],[8,1,3,8,6,1,8,4,6,6,10,1],[10,1,0,10,0,6,6,0,4],[4,6,3,4,3,8,6,10,3,0,3,9,10,9,3],[10,9,4,6,10,4],[4,9,5,7,6,11],[0,8,3,4,9,5,11,7,6],[5,0,1,5,4,0,7,6,11],[11,7,6,8,3,4,3,5,4,3,1,5],[9,5,4,10,1,2,7,6,11],[6,11,7,1,2,10,0,8,3,4,9,5],[7,6,11,5,4,10,4,2,10,4,0,2],[3,4,8,3,5,4,3,2,5,10,5,2,11,7,6],[7,2,3,7,6,2,5,4,9],[9,5,4,0,8,6,0,6,2,6,8,7],[3,6,2,3,7,6,1,5,0,5,4,0],[6,2,8,6,8,7,2,1,8,4,8,5,1,5,8],[9,5,4,10,1,6,1,7,6,1,3,7],[1,6,10,1,7,6,1,0,7,8,7,0,9,5,4],[4,0,10,4,10,5,0,3,10,6,10,7,3,7,10],[7,6,10,7,10,8,5,4,10,4,8,10],[6,9,5,6,11,9,11,8,9],[3,6,11,0,6,3,0,5,6,0,9,5],[0,11,8,0,5,11,0,1,5,5,6,11],[6,11,3,6,3,5,5,3,1],[1,2,10,9,5,11,9,11,8,11,5,6],[0,11,3,0,6,11,0,9,6,5,6,9,1,2,10],[11,8,5,11,5,6,8,0,5,10,5,2,0,2,5],[6,11,3,6,3,5,2,10,3,10,5,3],[5,8,9,5,2,8,5,6,2,3,8,2],[9,5,6,9,6,0,0,6,2],[1,5,8,1,8,0,5,6,8,3,8,2,6,2,8],[1,5,6,2,1,6],[1,3,6,1,6,10,3,8,6,5,6,9,8,9,6],[10,1,0,10,0,6,9,5,0,5,6,0],[0,3,8,5,6,10],[10,5,6],[11,5,10,7,5,11],[11,5,10,11,7,5,8,3,0],[5,11,7,5,10,11,1,9,0],[10,7,5,10,11,7,9,8,1,8,3,1],[11,1,2,11,7,1,7,5,1],[0,8,3,1,2,7,1,7,5,7,2,11],[9,7,5,9,2,7,9,0,2,2,11,7],[7,5,2,7,2,11,5,9,2,3,2,8,9,8,2],[2,5,10,2,3,5,3,7,5],[8,2,0,8,5,2,8,7,5,10,2,5],[9,0,1,5,10,3,5,3,7,3,10,2],[9,8,2,9,2,1,8,7,2,10,2,5,7,5,2],[1,3,5,3,7,5],[0,8,7,0,7,1,1,7,5],[9,0,3,9,3,5,5,3,7],[9,8,7,5,9,7],[5,8,4,5,10,8,10,11,8],[5,0,4,5,11,0,5,10,11,11,3,0],[0,1,9,8,4,10,8,10,11,10,4,5],[10,11,4,10,4,5,11,3,4,9,4,1,3,1,4],[2,5,1,2,8,5,2,11,8,4,5,8],[0,4,11,0,11,3,4,5,11,2,11,1,5,1,11],[0,2,5,0,5,9,2,11,5,4,5,8,11,8,5],[9,4,5,2,11,3],[2,5,10,3,5,2,3,4,5,3,8,4],[5,10,2,5,2,4,4,2,0],[3,10,2,3,5,10,3,8,5,4,5,8,0,1,9],[5,10,2,5,2,4,1,9,2,9,4,2],[8,4,5,8,5,3,3,5,1],[0,4,5,1,0,5],[8,4,5,8,5,3,9,0,5,0,3,5],[9,4,5],[4,11,7,4,9,11,9,10,11],[0,8,3,4,9,7,9,11,7,9,10,11],[1,10,11,1,11,4,1,4,0,7,4,11],[3,1,4,3,4,8,1,10,4,7,4,11,10,11,4],[4,11,7,9,11,4,9,2,11,9,1,2],[9,7,4,9,11,7,9,1,11,2,11,1,0,8,3],[11,7,4,11,4,2,2,4,0],[11,7,4,11,4,2,8,3,4,3,2,4],[2,9,10,2,7,9,2,3,7,7,4,9],[9,10,7,9,7,4,10,2,7,8,7,0,2,0,7],[3,7,10,3,10,2,7,4,10,1,10,0,4,0,10],[1,10,2,8,7,4],[4,9,1,4,1,7,7,1,3],[4,9,1,4,1,7,0,8,1,8,7,1],[4,0,3,7,4,3],[4,8,7],[9,10,8,10,11,8],[3,0,9,3,9,11,11,9,10],[0,1,10,0,10,8,8,10,11],[3,1,10,11,3,10],[1,2,11,1,11,9,9,11,8],[3,0,9,3,9,11,1,2,9,2,11,9],[0,2,11,8,0,11],[3,2,11],[2,3,8,2,8,10,10,8,9],[9,10,2,0,9,2],[2,3,8,2,8,10,0,1,8,1,10,8],[1,10,2],[1,3,8,9,1,8],[0,9,1],[0,3,8],[]],jU=[[0,4,4,4,2,0,0,0,2,2,0,0],[4,0,4,4,0,8,0,0,0,8,8,0],[4,4,0,4,0,0,8,0,0,0,8,8],[4,4,4,0,0,0,0,1,1,0,0,1],[2,0,0,0,0,8,8,8,2,2,0,0],[0,8,0,0,8,0,8,8,0,8,8,0],[0,0,8,0,8,8,0,8,0,0,8,8],[0,0,0,1,8,8,8,0,1,0,0,1],[2,0,0,1,2,0,0,1,0,2,0,1],[2,8,0,0,2,8,0,0,2,0,8,0],[0,8,8,0,0,8,8,0,0,8,0,8],[0,0,8,1,0,0,8,1,1,0,8,0]];function Ode(e){return{...e,bottomLeft:Ds(e.bottomLeft,[0,0,0]),topRight:Ds(e.topRight,e.scalarField.space.dimensions)}}function Lde(e){return{dX:e.topRight[0]-e.bottomLeft[0],dY:e.topRight[1]-e.bottomLeft[1],dZ:e.topRight[2]-e.bottomLeft[2]}}function c1(e,t){return Oe.create("Marching Cubes Mesh",function(){var n=ie(function*(r){const i=Ode(e),{dX:o,dY:s,dZ:a}=Lde(i),u=function Lut(e,t){const n=Math.min(65536,4*e),r=ze.create(Float32Array,3,e,t&&t.vertexBuffer.ref.value),i=ze.create(Float32Array,3,e,t&&t.normalBuffer.ref.value),o=ze.create(Float32Array,1,e,t&&t.groupBuffer.ref.value),s=ze.create(Uint32Array,3,n,t&&t.indexBuffer.ref.value);let a=0,c=0;return{addVertex:(u,l,d)=>(++a,ze.add3(r,u,l,d)),addNormal:(u,l,d)=>{ze.add3(i,u,l,d)},addGroup:u=>{ze.add(o,u)},addTriangle:(u,l,d,f)=>{const p=u[l],m=u[d],h=u[f];p>=0&&m>=0&&h>=0&&(++c,ze.add3(s,p,m,h))},get:()=>{const u=ze.compact(r,!0),l=ze.compact(i,!0),d=ze.compact(s,!0),f=ze.compact(o,!0);return Nt.create(u,d,l,f,a,c,t)}}}(Math.min(262144,Math.max(o*s*a/32,1024)),t);return yield new Ude(r,u,i).run(),u.get()});return function(r){return n.apply(this,arguments)}}())}function HU(e,t){return Oe.create("Marching Cubes Lines",function(){var n=ie(function*(r){const i=Ode(e),{dX:o,dY:s,dZ:a}=Lde(i),u=function Uut(e,t){const n=ze.create(Float32Array,3,e),r=ze.create(Float32Array,1,e),i=ze.create(Float32Array,2,e);let o=0;return{addVertex:(s,a,c)=>ze.add3(n,s,a,c),addNormal:()=>Ag,addGroup:s=>{ze.add(r,s)},addTriangle:(s,a,c,u,l)=>{s[a]>=0&&s[c]>=0&&s[u]>=0&&(jU[a][c]&l&&(++o,ze.add2(i,s[a],s[c])),jU[c][u]&l&&(++o,ze.add2(i,s[c],s[u])),jU[a][u]&l&&(++o,ze.add2(i,s[a],s[u])))},get:()=>{const s=ze.compact(n,!0),a=ze.compact(i,!0),c=ze.compact(r,!0),u=Fc.create(o,o/10,t);for(let l=0;l0)return i-1;const o=this.scalarField,s=this.scalarFieldGet,a=Fut[t],c=a.a,u=a.b,l=c.i+this.i,d=c.j+this.j,f=c.k+this.k,p=u.i+this.i,m=u.j+this.j,h=u.k+this.k,g=s(o,l,d,f),y=s(o,p,m,h),b=(this.isoLevel-g)/(g-y);if(this.idField){const M=this.idFieldGet(this.idField,l,d,f),N=this.idFieldGet(this.idField,p,m,h);let V=b<.5?M:N;if(-1===V&&(V=b<.5?N:M),-2===V)return-1;this.builder.addGroup(V)}else this.builder.addGroup(0);const x=this.builder.addVertex(l+b*(l-p),d+b*(d-m),f+b*(f-h));this.verticesOnEdges[r]=x+1;const _=s(o,Math.max(0,l-1),d,f)-s(o,Math.min(this.nX-1,l+1),d,f),S=s(o,l,Math.max(0,d-1),f)-s(o,l,Math.min(this.nY-1,d+1),f),A=s(o,l,d,Math.max(0,f-1))-s(o,l,d,Math.min(this.nZ,f+1)),I=_+b*(_-(s(o,Math.max(0,p-1),m,h)-s(o,Math.min(this.nX-1,p+1),m,h))),R=S+b*(S-(s(o,p,Math.max(0,m-1),h)-s(o,p,Math.min(this.nY-1,m+1),h))),T=A+b*(A-(s(o,p,m,Math.max(0,h-1))-s(o,p,m,Math.min(this.nZ-1,h+1))));return this.isoLevel>=0?this.builder.addNormal(I,R,T):this.builder.addNormal(-I,-R,-T),x}constructor(t,n){this.builder=t,this.vertList=[0,0,0,0,0,0,0,0,0,0,0,0],this.i=0,this.j=0,this.k=0;const r=n.scalarField.space.dimensions;this.nX=r[0],this.nY=r[1],this.nZ=r[2],this.isoLevel=n.isoLevel,this.scalarFieldGet=n.scalarField.space.get,this.scalarField=n.scalarField.data,n.idField&&(this.idField=n.idField.data,this.idFieldGet=n.idField.space.get),this.verticesOnEdges=new Int32Array(3*this.nX*this.nY*2)}get(t,n,r){return this.scalarFieldGet(this.scalarField,t,n,r)}processCell(t,n,r,i){let o=0;if(this.get(t,n,r)0&&(this.vertList[0]=this.interpolate(0)),(2&s)>0&&(this.vertList[1]=this.interpolate(1)),(4&s)>0&&(this.vertList[2]=this.interpolate(2)),(8&s)>0&&(this.vertList[3]=this.interpolate(3)),(16&s)>0&&(this.vertList[4]=this.interpolate(4)),(32&s)>0&&(this.vertList[5]=this.interpolate(5)),(64&s)>0&&(this.vertList[6]=this.interpolate(6)),(128&s)>0&&(this.vertList[7]=this.interpolate(7)),(256&s)>0&&(this.vertList[8]=this.interpolate(8)),(512&s)>0&&(this.vertList[9]=this.interpolate(9)),(1024&s)>0&&(this.vertList[10]=this.interpolate(10)),(2048&s)>0&&(this.vertList[11]=this.interpolate(11));const a=a1[o];for(let c=0;c=0?this.builder.addTriangle(this.vertList,u,l,d,i):this.builder.addTriangle(this.vertList,d,l,u,i)}}}function z0(e,t){const{defaultProps:n,createGeometry:r,createLocationIterator:i,getLoci:o,eachLocation:s,setUpdateState:a,mustRecreate:c,dispose:u}=e,{updateValues:l,updateBoundingSphere:d,updateRenderableState:f,createPositionIterator:p}=e.geometryUtils,m=Cf.create();let h,g,y,b,x,A,E,w,I,R,_=Object.assign({},n),S=Fo.createEmpty(),D=-1;function M(F){if(m.createNew){if(I=i(b,x),!F)throw new Error("expected geometry to be given");h=function zut(e,t,n,r,i,o){const{createValues:s,createRenderableState:a}=Zo.getUtils(t),u=s(t,JL(),n,r,i),l=a(i);return Ev(t.kind,u,l,o)}(0,F,I,y,g,t),R=p(F,h.values)}else{if(!h)throw new Error("expected renderObject to be available");if(m.updateTransform){I=i(b,x);const{instanceCount:G,groupCount:L}=I;g.instanceGranularity?Vi(G,"instance",h.values):Vi(G*L,"groupInstance",h.values)}else I.reset();if(m.createGeometry){if(!F)throw new Error("expected geometry to be given");k.updateIfChanged(h.values.drawCount,Zo.getDrawCount(F)),k.updateIfChanged(h.values.uVertexCount,Zo.getVertexCount(F)),k.updateIfChanged(h.values.uGroupCount,Zo.getGroupCount(F))}(m.updateTransform||m.createGeometry)&&(d(h.values,F||w),R=p(F||w,h.values)),m.updateSize&&"uSize"in h.values&&kp(I,y.size,h.values),m.updateColor&&bu(I,R,y.color,h.values),l(h.values,g),f(h.state,g)}_=g,S=y,A=b,E=x,F&&(w=F,D+=1)}function V(F,G){return Uc(F)?G(Ce.ofBounds(0,_.instanceGranularity?I.instanceCount:I.groupCount*I.instanceCount)):_.instanceGranularity?function N(F,G,L,z){let j=!1;if(et.Cell.isLoci(F)){if(et.Cell.isLociEmpty(F)||!et.areEquivalent(F.volume,G))return!1;z(Ce.ofSingleton(0))&&(j=!0)}else if(et.Segment.isLoci(F)){if(et.Segment.isLociEmpty(F)||!et.areEquivalent(F.volume,G)||!je.has(F.segments,L))return!1;z(Ce.ofSingleton(0))&&(j=!0)}return j}(F,A,E,G):s(F,A,E,_,G)}return{get groupCount(){return I?I.count:0},get renderObject(){return h},get geometryVersion(){return D},createOrUpdate:(F,G,L={},z)=>ie(function*(){if(function T(F,G,L,z){if(!L&&!A)throw new Error("missing volume");g=Object.assign({},_,G),y=F,b=L,x=z,Cf.reset(m),h?(!et.areEquivalent(b,A)||x!==E)&&(m.createNew=!0):m.createNew=!0,m.createNew?m.createGeometry=!0:(a(m,L,g,_,y,S),Lc.areEqual(F.color,S.color)||(m.updateColor=!0),m.createGeometry&&(m.updateColor=!0),g.instanceGranularity!==_.instanceGranularity&&(m.updateTransform=!0))}(G,L,z?.volume||A,z?.key||E),m.createGeometry){const j=r(F,b,x,y,g,w);return kI(j)?j.then(M):M(j)}M()})(),getLoci:F=>h?o(F,A,E,_,h.id):$n,eachLocation(F){for(I.reset();I.hasNext;){const{location:G,isSecondary:L}=I.move();F(G,L)}},mark:(F,G)=>Sn.mark(h,F,G,V),setVisibility(F){Sn.setVisibility(h,F)},setAlphaFactor(F){Sn.setAlphaFactor(h,F)},setPickable(F){Sn.setPickable(h,F)},setColorOnly(F){Sn.setColorOnly(h,F)},setTransform(F,G){Sn.setTransform(h,F,G)},setOverpaint:F=>Sn.setOverpaint(h,F,V,!0),setTransparency:F=>Sn.setTransparency(h,F,V,!0),setSubstance:F=>Sn.setSubstance(h,F,V,!0),setClipping:F=>Sn.setClipping(h,F,V,!0),setThemeStrength(F){Sn.setThemeStrength(h,F)},destroy(){u?.(w),h&&(h.state.disposed=!0,h=void 0)},mustRecreate:c}}function pC(e,t,n,r,i,o=(()=>[-1])){let s=0;const{webgl:a}=t,c=new mr,u=new yn.GeometryState,l=Hp(),d=[],f=yn.createState(),p=new Map;let m,h,g,y,b=Fo.createEmpty();function x(R,T){return _.apply(this,arguments)}function _(){return(_=ie(function*(R,T){var M;let N=p.get(T);return N?!(null===(M=N.mustRecreate)||void 0===M)&&M.call(N,{volume:m,key:T},y,a)&&(N.destroy(),N=r(l,m,T,y,a),p.set(T,N)):(N=r(l,m,T,y,a),p.set(T,N)),N.createOrUpdate({webgl:a,runtime:R},b,y,{volume:m,key:T})})).apply(this,arguments)}return{label:e,get groupCount(){let R=0;return p.forEach(T=>{T.renderObject&&(R+=T.groupCount)}),R},get props(){return y},get params(){return g},get state(){return f},get theme(){return b},get geometryVersion(){return u.version},renderObjects:d,updated:c,createOrUpdate:function S(R={},T){T&&T!==m&&(g=n(t,T),m=T,y||(y=C.getDefaultValues(g)));const M=o8(Object.assign({},y,R),m);return Object.assign(y,R,M),h=o(y),Oe.create("Creating or updating VolumeRepresentation",function(){var N=ie(function*(V){const F=new Set(p.keys());for(let G=0,L=h.length;G{var L;null===(L=p.get(G))||void 0===L||L.destroy(),p.delete(G)}),d.length=0,p.forEach(G=>{G.renderObject&&(d.push(G.renderObject),u.add(G.renderObject.id,G.geometryVersion))}),u.snapshot(),c.next(s++)});return function(V){return N.apply(this,arguments)}}())},setState:function w(R){const{visible:T,alphaFactor:M,pickable:N,overpaint:V,transparency:F,substance:G,clipping:L,transform:z,themeStrength:j,syncManually:Z,markerActions:$}=R,ee={};void 0!==T&&(ee.visible=T),void 0!==M&&(ee.alphaFactor=M),void 0!==N&&(ee.pickable=N),void 0!==V&&(ee.overpaint=V),void 0!==F&&(ee.transparency=F),void 0!==G&&(ee.substance=G),void 0!==L&&(ee.clipping=L),void 0!==j&&(ee.themeStrength=j),void 0!==z&&!le.areEqual(z,f.transform,vr)&&(ee.transform=z),void 0!==Z&&(ee.syncManually=Z),void 0!==$&&(ee.markerActions=$),p.forEach(q=>function E(R,T){void 0!==T.visible&&R&&R.setVisibility(T.visible),void 0!==T.alphaFactor&&R&&R.setAlphaFactor(T.alphaFactor),void 0!==T.pickable&&R&&R.setPickable(T.pickable),void 0!==T.overpaint&&R&&R.setOverpaint(T.overpaint),void 0!==T.transparency&&R&&R.setTransparency(T.transparency),void 0!==T.substance&&R&&R.setSubstance(T.substance),void 0!==T.clipping&&R&&R.setClipping(T.clipping),void 0!==T.transform&&R&&R.setTransform(T.transform),void 0!==T.themeStrength&&R&&R.setThemeStrength(T.themeStrength)}(q,ee)),yn.updateState(f,R)},setTheme:function D(R){b=R},getLoci:R=>{let T=$n;return p.forEach(M=>{const N=M.getLoci(R);Ta(N)||(T=N)}),T},getAllLoci:()=>[i(m,y)],eachLocation:R=>{p.forEach(T=>{T.eachLocation(R)})},mark:function A(R,T){let M=!1;return p.forEach(N=>{M=N.mark(R,T)||M}),M},destroy:function I(){p.forEach(R=>R.destroy()),p.clear()}}}const Gut="\nprecision highp float;\nprecision highp int;\n\n#if __VERSION__ == 100\n precision highp sampler2D;\n uniform sampler2D tTexture;\n#else\n precision highp isampler2D;\n uniform isampler2D tTexture;\n#endif\n\nvoid main(void) {\n #if __VERSION__ == 100\n gl_FragColor = texture2D(tTexture, vec2(0.5));\n #else\n gl_FragColor = ivec4(texture2D(tTexture, vec2(0.5)).r);\n #endif\n}\n",jut={...vo,tTexture:jt("texture","rgba","float","nearest")},Sl="histopyramid-sum";const i3=new Uint8Array(4),Vde=new Int32Array(4),Yut="\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tInputLevel;\n\n// previous level used to evaluate the new level\n#if __VERSION__ == 100\n uniform sampler2D tPreviousLevel;\n#else\n precision highp isampler2D;\n uniform isampler2D tPreviousLevel;\n#endif\n\n// inverted size of the previous level texture.\nuniform float uSize;\nuniform float uTexSize;\nuniform bool uFirst;\n\n#include common\n\nvoid main(void) {\n float k = 0.5 * uSize;\n vec2 position = floor((gl_FragCoord.xy / uTexSize) / uSize) * uSize;\n\n #if __VERSION__ == 100\n float a, b, c, d;\n\n if (uFirst) {\n a = texture2D(tInputLevel, position).r * 255.0;\n b = texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0;\n c = texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0;\n d = texture2D(tInputLevel, position + vec2(k, k)).r * 255.0;\n } else {\n a = unpackRGBToInt(texture2D(tPreviousLevel, position).rgb);\n b = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(k, 0.0)).rgb);\n c = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(0.0, k)).rgb);\n d = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(k, k)).rgb);\n }\n gl_FragColor = vec4(packIntToRGB(a + b + c + d), 1.0);\n #else\n int a, b, c, d;\n\n if (uFirst) {\n a = int(texture2D(tInputLevel, position).r * 255.0);\n b = int(texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0);\n c = int(texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0);\n d = int(texture2D(tInputLevel, position + vec2(k, k)).r * 255.0);\n } else {\n a = texture2D(tPreviousLevel, position).r;\n b = texture2D(tPreviousLevel, position + vec2(k, 0.0)).r;\n c = texture2D(tPreviousLevel, position + vec2(0.0, k)).r;\n d = texture2D(tPreviousLevel, position + vec2(k, k)).r;\n }\n gl_FragColor = ivec4(a + b + c + d);\n #endif\n}\n",Xut={...vo,tInputLevel:jt("texture","rgba","float","nearest"),tPreviousLevel:jt("texture","rgba","float","nearest"),uSize:xe("f"),uTexSize:xe("f"),uFirst:xe("b")},Fm="histogram-pyramid";function Qut(e,t){const n=Math.pow(2,t),r=`level${t}`,i=e.isWebGL2?o3(r,e,"image-int32","alpha","int","nearest"):o3(r,e,"image-uint8","rgba","ubyte","nearest");i.define(n,n);let o=function elt(e,t){return t.namedFramebuffers[`${Fm}-${e}`]}(r,e);return o||(o=zde(r,e),i.attachFramebuffer(o,0)),{texture:i,framebuffer:o}}function zde(e,t){const n=`${Fm}-${e}`;return t.namedFramebuffers[n]||(t.namedFramebuffers[n]=t.resources.framebuffer()),t.namedFramebuffers[n]}function o3(e,t,n,r,i,o){const s=`${Fm}-${e}`;return t.namedTextures[s]||(t.namedTextures[s]=t.resources.texture(n,r,i,o)),t.namedTextures[s]}function tlt(e,t,n,r){lt&&e.timer.mark("createHistogramPyramid");const{gl:i,state:o}=e,s=t.getWidth();if(s!==t.getHeight()||!$x(s))throw new Error("inputTexture must be of square power-of-two size");const c=Math.ceil(Math.log(s)/Math.log(2)),u=Math.pow(2,c),l=Math.pow(2,c),d=Math.pow(2,c-1),f=e.isWebGL2?o3("pyramid",e,"image-int32","alpha","int","nearest"):o3("pyramid",e,"image-uint8","rgba","ubyte","nearest");f.define(l,d);const p=zde("pyramid",e);f.attachFramebuffer(p,0),o.viewport(0,0,l,d),Wt(i)?i.clearBufferiv(i.COLOR,0,[0,0,0,0]):i.clear(i.COLOR_BUFFER_BIT);const m=[];for(let x=0;x0&&(k.update(h.values.tPreviousLevel,m[c-x].texture),h.update()),o.currentRenderItemId=-1,o.viewport(0,0,A,A),o.scissor(0,0,A,A),Wt(i)?i.clearBufferiv(i.COLOR,0,[0,0,0,0]):i.clear(i.COLOR_BUFFER_BIT),o.scissor(0,0,r[0],r[1]),h.render(),f.bind(0),i.copyTexSubImage2D(i.TEXTURE_2D,0,g,0,0,0,A,A),f.unbind(0),g+=A}i.finish(),lt&&e.timer.markEnd("createHistogramPyramid");const y=Math.max(1,function $ut(e,t){lt&&e.timer.mark("getHistopyramidSum");const{gl:n,state:r,resources:i}=e,o=function Hut(e,t){return e.namedComputeRenderables[Sl]?(k.update(e.namedComputeRenderables[Sl].values.tTexture,t),e.namedComputeRenderables[Sl].update()):e.namedComputeRenderables[Sl]=function qut(e,t){const n={..._o,tTexture:k.create(t)},r={...jut};return ji(zi(e,"triangles",Br("sum",ps,Gut,{},{0:"ivec4"}),r,n),n)}(e,t),e.namedComputeRenderables[Sl]}(e,t);e.state.currentRenderItemId=-1,e.namedFramebuffers[Sl]||(e.namedFramebuffers[Sl]=i.framebuffer());const s=e.namedFramebuffers[Sl];return e.namedTextures[Sl]||(e.namedTextures[Sl]=Wt(n)?i.texture("image-int32","rgba","int","nearest"):i.texture("image-uint8","rgba","ubyte","nearest"),e.namedTextures[Sl].define(1,1)),e.namedTextures[Sl].attachFramebuffer(s,0),function Wut(e){const{gl:t,state:n}=e;n.disable(t.CULL_FACE),n.disable(t.BLEND),n.disable(t.DEPTH_TEST),n.disable(t.SCISSOR_TEST),n.depthMask(!1),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0)}(e),r.viewport(0,0,1,1),o.render(),n.finish(),e.readPixels(0,0,1,1,Wt(n)?Vde:i3),e.unbindFramebuffer(),lt&&e.timer.markEnd("getHistopyramidSum"),Wt(n)?Vde[0]:m5(i3[0],i3[1],i3[2])}(e,m[0].texture));return{pyramidTex:f,count:y,height:Math.ceil(y/Math.pow(2,c)),levels:c,scale:n}}let hC,mC;function nlt(){if(void 0!==hC)return hC;hC=Po(256,1,Uint8Array);const{array:e}=hC;for(let t=0,n=a1.length;tMr(t.grid.cells.data.length,1,1,()=>rc),getLoci:WU,eachLocation:$U,setUpdateState:(t,n,r,i)=>{et.IsoValue.areSame(r.isoValue,i.isoValue,n.grid.stats)||(t.createGeometry=!0)},geometryUtils:xa.Utils,mustRecreate:(t,n,r)=>!n.tryUseGpu||!r||!qU(t.volume,r),dispose:t=>{t.vertexTexture.ref.value.destroy(),t.groupTexture.ref.value.destroy(),t.normalTexture.ref.value.destroy(),t.doubleBuffer.destroy()}},e)}(e):function vlt(e){return z0({defaultProps:C.getDefaultValues(XU),createGeometry:blt,createLocationIterator:t=>Mr(t.grid.cells.data.length,1,1,()=>rc),getLoci:WU,eachLocation:$U,setUpdateState:(t,n,r,i)=>{et.IsoValue.areSame(r.isoValue,i.isoValue,n.grid.stats)||(t.createGeometry=!0)},geometryUtils:Nt.Utils,mustRecreate:(t,n,r)=>n.tryUseGpu&&!!r&&qU(t.volume,r)},e)}(e)}function jde(e,t){return et.Isosurface.Loci(e,t.isoValue)}function WU(e,t,n,r,i){const{objectId:o,groupId:s}=e;if(i===o){const a=et.PickingGranularity.get(t);return"volume"===a?et.Loci(t):"object"===a?et.Isosurface.Loci(t,r.isoValue):et.Cell.Loci(t,Ce.ofSingleton(s))}return $n}function $U(e,t,n,r,i){return rE(e,t,{isoValue:r.isoValue},i)}function blt(e,t,n,r,i,o){return YU.apply(this,arguments)}function YU(){return YU=ie(function*(e,t,n,r,i,o){e.runtime.update({message:"Marching cubes..."});const s=Tc(new Int32Array(t.grid.cells.data.length)),a=yield c1({isoLevel:et.IsoValue.toAbsolute(i.isoValue,t.grid.stats).absoluteValue,scalarField:t.grid.cells,idField:wn.create(t.grid.cells.space,wn.Data1(s))},o).runAsChild(e.runtime),c=Ko.getGridToCartesianTransform(t.grid);return Nt.transform(a,c),e.webgl&&!e.webgl.isWebGL2?(Nt.uniformTriangleGroup(a,!1),k.updateIfChanged(a.varyingGroup,!1)):k.updateIfChanged(a.varyingGroup,!0),a.setBoundingSphere(et.Isosurface.getBoundingSphere(t,i.isoValue)),a}),YU.apply(this,arguments)}const XU={...Nt.Params,...xa.Params,...Gde,quality:{...Nt.Params.quality,isEssential:!1},tryUseGpu:C.Boolean(!0)};var KU;function _lt(e,t,n,r,i,o){return ZU.apply(this,arguments)}function ZU(){return ZU=ie(function*(e,t,n,r,i,o){if(!e.webgl)throw new Error("webgl context required to create volume isosurface texture-mesh");if(t.grid.cells.data.length<=1)return xa.createEmpty(o);const{max:s,min:a}=t.grid.stats,c=s-a,u=et.IsoValue.toAbsolute(i.isoValue,t.grid.stats).absoluteValue,l=(u-a)/c,{texture:d,gridDimension:f,gridTexDim:p,gridTexScale:m,transform:h}=KU.get(t,e.webgl),g=t.grid.cells.space.axisOrderSlowToFast,y=o?.doubleBuffer.get(),b=s3(e.webgl,d,f,p,m,h,l,u<0,!1,g,!0,y?.vertex,y?.group,y?.normal),x=t.grid.cells.data.length,_=et.getBoundingSphere(t),S=xa.create(b.vertexCount,x,b.vertexTexture,b.groupTexture,b.normalTexture,_,o);return S.meta.webgl=e.webgl,S}),ZU.apply(this,arguments)}function Slt(e,t,n,r,i,o){return QU.apply(this,arguments)}function QU(){return QU=ie(function*(e,t,n,r,i,o){e.runtime.update({message:"Marching cubes..."});const s=Tc(new Int32Array(t.grid.cells.data.length)),a=yield HU({isoLevel:et.IsoValue.toAbsolute(i.isoValue,t.grid.stats).absoluteValue,scalarField:t.grid.cells,idField:wn.create(t.grid.cells.space,wn.Data1(s))},o).runAsChild(e.runtime),c=Ko.getGridToCartesianTransform(t.grid);return di.transform(a,c),a.setBoundingSphere(et.Isosurface.getBoundingSphere(t,i.isoValue)),a}),QU.apply(this,arguments)}!function(e){const t="volume-isosurface-texture";e.descriptor=au({name:t}),e.get=function n(r,i){const{resources:o}=i,s=Ko.getGridToCartesianTransform(r.grid),a=v.clone(r.grid.cells.space.dimensions),{width:c,height:u,powerOfTwoSize:l}=vm(a,gC),d=v.create(c,u,0),f=Me.create(c/l,u/l);if(l>i.maxTextureSize/2)throw new Error("volume too large for gpu isosurface extraction");if(!r._propertyData[t]){r._propertyData[t]=o.texture("image-uint8","alpha","ubyte","linear");const p=r._propertyData[t];p.define(l,l),p.load(Fae(r,"data",gC),!0),r.customProperties.add(e.descriptor),r.customProperties.assets(e.descriptor,[{dispose:()=>p.destroy()}])}return a[0]+=gC,a[1]+=gC,{texture:r._propertyData[t],transform:s,gridDimension:a,gridTexDim:d,gridTexScale:f}}}(KU||(KU={}));const Hde={...di.Params,...Gde,quality:{...di.Params.quality,isEssential:!1},sizeFactor:C.Numeric(3,{min:0,max:10,step:.1})};function Clt(e){return z0({defaultProps:C.getDefaultValues(Hde),createGeometry:Slt,createLocationIterator:t=>Mr(t.grid.cells.data.length,1,1,()=>rc),getLoci:WU,eachLocation:$U,setUpdateState:(t,n,r,i)=>{et.IsoValue.areSame(r.isoValue,i.isoValue,n.grid.stats)||(t.createGeometry=!0)},geometryUtils:di.Utils},e)}const qde={solid:(e,t)=>pC("Isosurface mesh",e,t,ylt,jde),wireframe:(e,t)=>pC("Isosurface wireframe",e,t,Clt,jde)},Wde={...XU,...Hde,visuals:C.MultiSelect(["solid"],C.objectToOptions(qde)),bumpFrequency:C.Numeric(1,{min:0,max:10,step:.1},rt.ShadingCategory)},Ilt={name:"isosurface",label:"Isosurface",description:"Displays a triangulated isosurface of volumetric data.",factory:function Alt(e,t){return yn.createMulti("Isosurface",e,t,yn.StateBuilder,qde)},getParams:function wlt(e,t){const n=C.clone(Wde);return n.isoValue=et.createIsoValueParam(et.IsoValue.relative(2),t.grid.stats),n},defaultValues:C.getDefaultValues(Wde),defaultColorTheme:{name:"uniform"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>!et.isEmpty(e)&&!et.Segmentation.get(e)};function Tlt(e,t,n,r,i,o){return JU.apply(this,arguments)}function JU(){return JU=ie(function*(e,t,n,r,i,o){const{dimension:{name:s},isoValue:a}=i,{space:c,data:u}=t.grid.cells,{min:l,max:d}=t.grid.stats,f=et.IsoValue.toAbsolute(a,t.grid.stats).absoluteValue,p="color"in r.color?r.color.color(rc,!1):st(16777215),[m,h,g]=st.toRgbNormalized(p),{width:y,height:b,x,y:_,z:S,x0:A,y0:E,z0:w,nx:D,ny:I,nz:R}=eV(t.grid,i),T=new Float32Array("x"===s?[x,0,0,x,_,0,x,0,S,x,_,S]:"y"===s?[0,_,0,x,_,0,0,_,S,x,_,S]:[0,0,S,0,_,S,x,0,S,x,_,S]),M=new Uint8Array(y*b*4),N=function Dlt(e,t){const{space:n}=e.cells,{width:r,height:i,x0:o,y0:s,z0:a,nx:c,ny:u,nz:l}=eV(e,t),d=new Uint8Array(r*i*4);let f=0;for(let p=s;p=f?255:0,V+=4}const F={width:y,height:b,array:M,flipY:!0},G={width:y,height:b,array:N,flipY:!0};return l0(Ko.getGridToCartesianTransform(t.grid),T,0,4),jp.create(F,T,G,o)}),JU.apply(this,arguments)}function eV(e,t){const{dimension:{name:n,params:r}}=t,{space:i}=e.cells;let o,s,a,c,u,l=0,d=0,f=0,[p,m,h]=i.dimensions;return"x"===n?(a=r,c=m-1,u=h-1,o=h,s=m,l=a,p=l+1):"y"===n?(a=p-1,c=r,u=h-1,o=h,s=p,d=c,m=d+1):(a=p-1,c=m-1,u=r,o=p,s=m,f=u,h=f+1),{width:o,height:s,x:a,y:c,z:u,x0:l,y0:d,z0:f,nx:p,ny:m,nz:h}}function $de(e,t){const n=function Elt(e,t){const{space:n}=e.cells,{width:r,height:i,x0:o,y0:s,z0:a,nx:c,ny:u,nz:l}=eV(e,t),d=new Uint32Array(r*i);let f=0;for(let p=s;pMr(t.grid.cells.data.length,1,1,()=>rc),getLoci:Plt,eachLocation:Mlt,setUpdateState:(t,n,r,i,o,s)=>{t.createGeometry=r.dimension.name!==i.dimension.name||r.dimension.params!==i.dimension.params||!et.IsoValue.areSame(r.isoValue,i.isoValue,n.grid.stats)||!Lc.areEqual(o.color,s.color)},geometryUtils:{...jp.Utils,createRenderableState:t=>{const n=jp.Utils.createRenderableState(t);return Yde(n,t),n},updateRenderableState:Yde}},e)}function Yde(e,t){jp.Utils.updateRenderableState(e,t),e.opaque=!1,e.writeDepth=!0}const Flt={name:"slice",label:"Slice",description:"Slice of volume rendered as image with interpolation.",factory:function Nlt(e,t){return pC("Slice",e,t,klt,$de)},getParams:function Rlt(e,t){const n=C.clone(tV),r=t.grid.cells.space.dimensions;return n.dimension=C.MappedStatic("x",{x:C.Numeric(0,{min:0,max:r[0]-1,step:1}),y:C.Numeric(0,{min:0,max:r[1]-1,step:1}),z:C.Numeric(0,{min:0,max:r[2]-1,step:1})},{isEssential:!0}),n.isoValue=et.createIsoValueParam(et.IsoValue.absolute(t.grid.stats.min),t.grid.stats),n},defaultValues:C.getDefaultValues(tV),defaultColorTheme:{name:"uniform"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>!et.isEmpty(e)&&!et.Segmentation.get(e)};function Xde(e,t){const n=St();return St.add(n,e),St.transform(n,n,t),n}function Kde(e){if("matrix"===e.transform.kind)return{unitToCartn:le.mul(le(),e.transform.matrix,le.fromScaling(le(),e.cells.space.dimensions)),cellDim:le.getScaling(v(),e.transform.matrix)};const t=e.transform.fractionalBox,n=St.size(v(),t);return{unitToCartn:le.mul3(le(),e.transform.cell.fromFractional,le.fromTranslation(le(),t.min),le.fromScaling(le(),n)),cellDim:v.div(v(),e.transform.cell.size,e.cells.space.dimensions)}}function Llt(e,t,n,r,i,o){return nV.apply(this,arguments)}function nV(){return nV=ie(function*(e,t,n,r,i,o){const{webgl:a}=e;if(void 0===a)throw new Error("DirectVolumeVisual requires `webgl` in props");return a.isWebGL2?function Olt(e,t,n,r){const i=n.grid.cells.space.dimensions;if(Math.max(...i)>t.max3dTextureSize/2)throw new Error("volume too large for direct-volume rendering");const o=function SQe(e){const{cells:{space:t,data:n},stats:{max:r,min:i}}=e.grid,[o,s,a]=t.dimensions,{dataOffset:c}=t,u=new Uint8Array(o*s*a*4),l={array:u,width:o,height:s,depth:a},d=r-i,f=v(),p=v(),m=o-1,h=s-1,g=a-1;let y=0;for(let b=0;bt.maxTextureSize/2)throw new Error("volume too large for direct-volume rendering");const a=Fae(n,"normals"),c=Ko.getGridToCartesianTransform(n.grid),u=Xde(i,c),l=r?r.gridTexture.ref.value:t.resources.texture("image-uint8","rgba","ubyte","linear");l.load(a);const{unitToCartn:d,cellDim:f}=Kde(n.grid);return _u.create(u,i,c,d,f,l,n.grid.stats,!1,n.grid.cells.space.axisOrderSlowToFast,r)}(0,a,t,o)}),nV.apply(this,arguments)}function Ult(e,t){return et.Loci(e)}function Vlt(e,t,n,r,i){const{objectId:o,groupId:s}=e;return i===o?et.Cell.Loci(t,Ce.ofSingleton(s)):$n}function zlt(e,t,n,r,i){return rE(e,t,void 0,i)}const rV={..._u.Params,quality:{..._u.Params.quality,isEssential:!1}};function jlt(e){return z0({defaultProps:C.getDefaultValues(rV),createGeometry:Llt,createLocationIterator:t=>Mr(t.grid.cells.data.length,1,1,()=>rc),getLoci:Vlt,eachLocation:zlt,setUpdateState:(t,n,r,i)=>{},geometryUtils:_u.Utils,dispose:t=>{t.gridTexture.ref.value.destroy()}},e)}const qlt={name:"direct-volume",label:"Direct Volume",description:"Direct rendering of volumetric data.",factory:function Hlt(e,t){return pC("Direct Volume",e,t,jlt,Ult)},getParams:function Glt(e,t){const n=C.clone(rV);return n.controlPoints.getVolume=()=>t,n},defaultValues:C.getDefaultValues(rV),defaultColorTheme:{name:"volume-value"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>!et.isEmpty(e)&&!et.Segmentation.get(e)},Wlt={segments:C.Converted(e=>e.map(t=>`${t}`),e=>e.map(t=>parseInt(t)),C.MultiSelect(["0"],C.arrayToOptions(["0"]),{isEssential:!0}))},yC=1;function iV(e,t){if(e.grid.cells.data.length{const r=et.Segment.Location(t,n);return Mr(t.grid.cells.data.length,1,1,()=>r)},getLoci:Qde,eachLocation:Jde,setUpdateState:(t,n,r,i)=>{},geometryUtils:xa.Utils,mustRecreate:(t,n,r)=>!n.tryUseGpu||!r||!iV(t.volume,r),dispose:t=>{t.vertexTexture.ref.value.destroy(),t.groupTexture.ref.value.destroy(),t.normalTexture.ref.value.destroy(),t.doubleBuffer.destroy()}},e)}(e):function Jlt(e){return z0({defaultProps:C.getDefaultValues(sV),createGeometry:Qlt,createLocationIterator:(t,n)=>{const r=et.Segment.Location(t,n);return Mr(t.grid.cells.data.length,1,1,()=>r)},getLoci:Qde,eachLocation:Jde,setUpdateState:(t,n,r,i)=>{},geometryUtils:Nt.Utils,mustRecreate:(t,n,r)=>n.tryUseGpu&&!!r&&iV(t.volume,r)},e)}(e)}function Klt(e,t){return et.Segment.Loci(e,t.segments)}function Qde(e,t,n,r,i){const{objectId:o,groupId:s}=e;if(i===o){const a=et.PickingGranularity.get(t);return"volume"===a?et.Loci(t):"object"===a?et.Segment.Loci(t,[n]):et.Cell.Loci(t,Ce.ofSingleton(s))}return $n}function Jde(e,t,n,r,i){return rE(e,t,{segments:je.ofSingleton(n)},i)}function Qlt(e,t,n,r,i,o){return oV.apply(this,arguments)}function oV(){return oV=ie(function*(e,t,n,r,i,o){const s=et.Segmentation.get(t);if(!s)throw new Error("missing volume segmentation");e.runtime.update({message:"Marching cubes..."});const a=St.clone(s.bounds[n]);St.expand(a,a,v.create(2,2,2));const u=function Zlt(e,t,n){const r=n.data,i=n.space.dataOffset,o=St.size(v(),t),[s,a,c]=o,u=s-1,l=a-1,d=c-1,[f,p,m]=t.min,[h,g,y]=t.max,b=[...n.space.axisOrderSlowToFast],x=wn.Space(o,b,Uint8Array),_=wn.create(x,x.create()),S=_.data,A=x.set;for(let E=0;En.maxTextureSize/2)throw new Error("volume too large for gpu segment extraction");n.namedTextures[aV]||(n.namedTextures[aV]=i.texture("image-uint8","alpha","ubyte","linear"));const p=n.namedTextures[aV];p.define(l,l);const m=Array.from(r.segments.get(t).values());return p.load(function CQe(e,t,n,r=0){const i=e.grid.cells.data,o=St.size(v(),n),s=e.grid.cells.space.dataOffset,{width:a,height:c}=vm(o,r),l=new Uint8Array(a*c*1),d={array:l,width:a,height:c},[f,p,m]=o,h=f-1,g=p-1,y=m-1,b=f+r,x=p+r,[_,S,A]=n.min,[E,w,D]=n.max;for(let I=0;IpC("Segment mesh",e,t,Xlt,Klt,rdt)},tfe={...sV,visuals:C.MultiSelect(["segment"],C.objectToOptions(efe)),bumpFrequency:C.Numeric(1,{min:0,max:10,step:.1},rt.ShadingCategory)},sdt={name:"segment",label:"Segment",description:"Displays a triangulated segment of volumetric data.",factory:function odt(e,t){return yn.createMulti("Segment",e,t,yn.StateBuilder,efe)},getParams:function idt(e,t){const n=C.clone(tfe),r=et.Segmentation.get(t);if(r){const i=Array.from(r.segments.keys());n.segments=C.Converted(o=>o.map(s=>`${s}`),o=>o.map(s=>parseInt(s)),C.MultiSelect(i.map(o=>`${o}`),C.arrayToOptions(i.map(o=>`${o}`)),{isEssential:!0}))}return n},defaultValues:C.getDefaultValues(tfe),defaultColorTheme:{name:"volume-segment"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>!et.isEmpty(e)&&!!et.Segmentation.get(e)};class u1 extends Vae{constructor(){super(),$a(u1.BuiltIn,(t,n)=>{if(t.name!==n)throw new Error(`Fix BuiltInVolumeRepresentations to have matching names. ${t.name} ${n}`);this.add(t)})}}function nfe(e,t,n,r){e.push({source:"em"===t?{name:"em",params:{isoValue:et.IsoValue.absolute(r||0)}}:{name:"x-ray",params:{}},dataId:n})}!function(e){e.BuiltIn={isosurface:Ilt,slice:Flt,"direct-volume":qlt,segment:sdt}}(u1||(u1={}));const adt=nc.build({display:{name:"Volume Streaming"},from:pe.Molecule.Structure,params(e,t){const n=function _ut(e,t="x-ray"){if(!e)return t;const n=e.models[0];return Er.is(n.sourceData)?sn.hasEmMap(n)?"em":sn.hasXrayMap(n)?"x-ray":sn.isFromEm(n)?"em":sn.isFromXray(n)?"x-ray":t:t}(e&&e.data),r=function Cut(e,t){if(!t||!t.models.length)return[];const n=t.models[0];switch(e){case"em":return function xut(e){const t=[];if(!Er.is(e.sourceData))return[e.entryId];const{db_id:n,db_name:r,content_type:i}=e.sourceData.data.db.pdbx_database_related;if(!r.isDefined)return[e.entryId];for(let o=0,s=r.rowCount;oi,{defaultValue:r.map(i=>({id:i}))}),defaultView:C.Select("em"===n?"auto":"selection-box",Tu.ViewTypeOptions),options:C.Group({serverUrl:C.Text(t.config.get(qi.VolumeStreaming.DefaultServer)||"https://ds.litemol.org"),behaviorRef:C.Text("",{isHidden:!0}),emContourProvider:C.Select("emdb",[["emdb","EMDB"],["pdbe","PDBe"]],{isHidden:!0}),channelParams:C.Value({},{isHidden:!0})})}},isApplicable:(e,t,n)=>{const r=n.config.get(qi.VolumeStreaming.CanStream);return r?r(e.data,n):1===e.data.models.length&&sn.probablyHasDensityMap(e.data.models[0])}})(({ref:e,state:t,params:n},r)=>Oe.create("Volume Streaming",function(){var i=ie(function*(o){const s=[];for(let f=0,p=n.entries.length;f0&&(yield r.managers.structure.hierarchy.remove(u?.toArray()));const l=c.cell.obj,d=t.build().to(a.ref).apply(rfe,C.getDefaultValues(Tu.createParams({data:l.data,defaultView:n.defaultView,channelParams:n.options.channelParams})),{ref:n.options.behaviorRef?n.options.behaviorRef:void 0});"em"===n.method?d.apply(a3,{channel:"em"},{state:{isGhost:!0},tags:"em"}):(d.apply(a3,{channel:"2fo-fc"},{state:{isGhost:!0},tags:"2fo-fc"}),d.apply(a3,{channel:"fo-fc(+ve)"},{state:{isGhost:!0},tags:"fo-fc(+ve)"}),d.apply(a3,{channel:"fo-fc(-ve)"},{state:{isGhost:!0},tags:"fo-fc(-ve)"})),yield t.updateTree(d).runInContext(o)});return function(o){return i.apply(this,arguments)}}())),cdt=nc.build({display:{name:"Boxify Volume Streaming",description:"Make the current box permanent."},from:Tu,isApplicable:e=>"selection-box"===e.data.params.entry.params.view.name})(({a:e,ref:t,state:n},r)=>{const i=e.data.params;if("selection-box"!==i.entry.params.view.name)return;const o=St.create(v.clone(i.entry.params.view.params.bottomLeft),v.clone(i.entry.params.view.params.topRight)),s=i.entry.params.view.params.radius;St.expand(o,o,v.create(s,s,s));const a={...i,entry:{name:i.entry.name,params:{...i.entry.params,view:{name:"box",params:{bottomLeft:o.min,topRight:o.max}}}}};return n.updateTree(n.build().to(t).update(a))}),udt={dataId:C.Text(""),source:C.MappedStatic("x-ray",{em:C.Group({isoValue:et.createIsoValueParam(et.IsoValue.relative(1))}),"x-ray":C.Group({})})},ldt=Rt.BuiltIn({name:"create-volume-streaming-info",display:{name:"Volume Streaming Info"},from:pe.Molecule.Structure,to:OU,params:e=>({serverUrl:C.Text("https://ds.litemol.org"),entries:C.ObjectList(udt,({dataId:t})=>t,{defaultValue:[{dataId:"",source:{name:"x-ray",params:{}}}]})})})({apply:({a:e,params:t},n)=>Oe.create("",function(){var r=ie(function*(i){const o=[];for(let a=0,c=t.entries.length;aa.dataId).join(", ")}`})});return function(i){return r.apply(this,arguments)}}())}),rfe=Rt.BuiltIn({name:"create-volume-streaming-behavior",display:{name:"Volume Streaming Behavior"},from:OU,to:Tu,params:e=>Tu.createParams({data:e&&e.data})})({canAutoUpdate:({oldParams:e,newParams:t})=>e.entry.params.view===t.entry.params.view||"selection-box"===t.entry.params.view.name||"camera-target"===t.entry.params.view.name||"off"===t.entry.params.view.name,apply:({a:e,params:t},n)=>Oe.create("Volume streaming",function(){var r=ie(function*(i){const o=new Tu.Behavior(n,e.data);return yield o.update(t),new Tu(o,{label:"Volume Streaming",description:o.getDescription()})});return function(i){return r.apply(this,arguments)}}()),update:({b:t,oldParams:n,newParams:r})=>Oe.create("Update Volume Streaming",function(){var i=ie(function*(o){if(n.entry.name!==r.entry.name&&"em"in r.entry.params.channels){const{emDefaultContourLevel:a}=t.data.infoMap.get(r.entry.name);a&&(r.entry.params.channels.em.isoValue=a)}const s=(yield t.data.update(r))?Qe.UpdateResult.Updated:Qe.UpdateResult.Unchanged;return t.description=t.data.getDescription(),s});return function(o){return i.apply(this,arguments)}}())}),a3=Rt.BuiltIn({name:"create-volume-streaming-visual",display:{name:"Volume Streaming Visual"},from:Tu,to:pe.Volume.Representation3D,params:{channel:C.Select("em",Tu.ChannelTypeOptions,{isHidden:!0})}})({apply:({a:e,params:t,spine:n},r)=>Oe.create("Volume Representation",function(){var i=ie(function*(o){var s,a;const c=e.data.channels[t.channel];if(!c)return li.Null;const u=ife(e.data,t.channel),l=u1.BuiltIn.isosurface,d=u.type.params||{},f=l.factory({webgl:null===(s=r.canvas3d)||void 0===s?void 0:s.webgl,...r.representation.volume.themes},l.getParams);f.setTheme(Fo.create(r.representation.volume.themes,{volume:c.data},u));const p=null===(a=n.getAncestorOfType(pe.Molecule.Structure))||void 0===a?void 0:a.data,m=0===p?.models.length?void 0:Hg.get(p?.models[0]);return yield f.createOrUpdate(d,c.data).runInContext(o),m&&f.setState({transform:m}),new pe.Volume.Representation3D({repr:f,sourceData:c.data},{label:`${Math.round(100*c.isoValue.relativeValue)/100} \u03c3 [${t.channel}]`})});return function(o){return i.apply(this,arguments)}}()),update:({a:e,b:t,newParams:n},i)=>Oe.create("Volume Representation",function(){var o=ie(function*(s){const a=e.data.channels[n.channel];if(!a)return Qe.UpdateResult.Unchanged;const c=t.data.repr.state.visible,u=ife(e.data,n.channel),l={...t.data.repr.props,...u.type.params};return t.data.repr.setTheme(Fo.create(i.representation.volume.themes,{volume:a.data},u)),yield t.data.repr.createOrUpdate(l,a.data).runInContext(s),t.data.repr.setState({visible:c}),t.data.sourceData=a.data,Qe.UpdateResult.Updated});return function(s){return o.apply(this,arguments)}}())});function ife(e,t){const n=e.channels[t];return Af.getDefaultParamsStatic(e.plugin,"isosurface",{isoValue:n.isoValue,alpha:n.opacity,visuals:n.wireframe?["wireframe"]:["solid"]},"uniform",{value:n.color})}const ddt=eh.create({name:"built-in.animate-state-interpolation",display:{name:"Animate State (experimental)"},params:()=>({transtionDurationInMs:C.Numeric(2e3,{min:100,max:3e4,step:10})}),canApply:e=>({canApply:e.managers.snapshot.state.entries.size>1}),initialState:()=>({}),apply:(e,t,n)=>ie(function*(){const r=n.plugin.managers.snapshot.state.entries;if(r.size<2)return{kind:"finished"};const i=t.current%n.params.transtionDurationInMs/n.params.transtionDurationInMs,o=Math.floor(t.current/n.params.transtionDurationInMs)%r.size;let s=Math.ceil(t.current/n.params.transtionDurationInMs);s===o&&s++,s%=r.size;const a=r.get(o).snapshot,c=r.get(s).snapshot;if(!a.data||!c.data)return{kind:"skip"};const u=a.data.tree.transforms,l=c.data.tree.transforms,d=n.plugin.state.data,f=d.build();for(const p of u)for(const m of l){if(m.ref!==p.ref||m.version===p.version)continue;const h=ur.fromJSON(p),g=ur.fromJSON(m),y=d.cells.get(p.ref);if(!y)continue;let b;b=h.transformer.definition.interpolate?h.transformer.definition.interpolate(h.params,g.params,i,n.plugin):i<=.5?h.params:g.params,Hx(y,b)||f.to(p.ref).update(b)}return yield Cn.State.Update(n.plugin,{state:d,tree:f,options:{doNotLogTiming:!0}}),{kind:"next",state:{}}})()}),fdt=eh.create({name:"built-in.animate-structure-spin",display:{name:"Spin Structure"},isExportable:!0,params:()=>({durationInMs:C.Numeric(3e3,{min:100,max:1e4,step:100})}),initialState:()=>({t:0}),getDuration:e=>({kind:"fixed",durationMs:e.durationInMs}),setup:(e,t,n)=>ie(function*(){const r=n.state.data,i=r.select(In.Generators.ofType(pe.Molecule.Structure.Representation3D)),o=r.build();let s=!1;for(const a of i)r.select(In.Generators.ofTransformer(Ye.Representation.SpinStructureRepresentation3D,a.transform.ref)).length>0||(s=!0,o.to(a.transform.ref).apply(Ye.Representation.SpinStructureRepresentation3D,{t:0},{tags:"animate-structure-spin"}));if(s)return o.commit({doNotUpdateCurrent:!0})})(),teardown(e,t,n){const r=n.state.data,i=r.select(In.Generators.ofType(pe.Molecule.Structure.Representation3DState).withTag("animate-structure-spin"));if(0===i.length)return;const o=r.build();for(const s of i)o.delete(s.transform.ref);return o.commit()},apply:(e,t,n)=>ie(function*(){var r;const i=n.plugin.state.data,o=i.select(In.Generators.ofTransformer(Ye.Representation.SpinStructureRepresentation3D));if(0===o.length)return{kind:"finished"};const s=i.build(),c=(e.t+(t.current-t.lastApplied)/n.params.durationInMs)%1;for(const u of o)s.to(u).update({...null===(r=u.params)||void 0===r?void 0:r.values,t:c});return yield Cn.State.Update(n.plugin,{state:i,tree:s,options:{doNotLogTiming:!0}}),{kind:"next",state:{t:c}}})()}),c3=v(),ofe=v(),sfe=_r(),pdt=eh.create({name:"built-in.animate-camera-rock",display:{name:"Camera Rock",description:"Rock the 3D scene around the x-axis in view space"},isExportable:!0,params:()=>({durationInMs:C.Numeric(4e3,{min:100,max:2e4,step:100}),speed:C.Numeric(1,{min:1,max:10,step:1},{description:"How many times to rock from side to side."}),angle:C.Numeric(10,{min:0,max:180,step:1},{description:"How many degrees to rotate in each direction."})}),initialState:(e,t)=>({snapshot:t.canvas3d.camera.getSnapshot()}),getDuration:e=>({kind:"fixed",durationMs:e.durationInMs}),teardown:(e,t,n)=>{var r;null===(r=n.canvas3d)||void 0===r||r.requestCameraReset({snapshot:t.snapshot,durationMs:0})},apply:(e,t,n)=>ie(function*(){var r,i;if(0===t.current)return{kind:"next",state:e};const o=e.snapshot;if(o.radiusMax<1e-4)return{kind:"finished"};const s=t.animation?(null===(r=t.animation)||void 0===r?void 0:r.currentFrame)/(t.animation.frameCount+1):os(t.current/n.params.durationInMs,0,1),a=Math.sin(s*n.params.speed*Math.PI*2)*Yn(n.params.angle);v.sub(c3,o.position,o.target),v.normalize(ofe,o.up),_r.setAxisAngle(sfe,ofe,a),v.transformQuat(c3,c3,sfe);const c=v.add(v(),o.target,c3);return null===(i=n.plugin.canvas3d)||void 0===i||i.requestCameraReset({snapshot:{...o,position:c},durationMs:0}),s>=.99999?{kind:"finished"}:{kind:"next",state:e}})()});var an,u3;function ch(...e){const t=Sb(e),n=yK(e,1/0),r=e;return r.length?1===r.length?ru(r[0]):xg(n)($i(r,t)):$l}function afe(e,t=r3){return mo((n,r)=>{let i=null,o=null,s=null;const a=()=>{if(i){i.unsubscribe(),i=null;const u=o;o=null,r.next(u)}};function c(){const u=s+e,l=t.now();if(l{o=u,s=t.now(),i||(i=t.schedule(c,e),r.add(i))},()=>{a(),r.complete()},void 0,()=>{o=i=null}))})}!function(e){e.Action=function t(r,i){return{action:r,customControl:i&&i.customControl,autoUpdate:i&&i.autoUpdate}},e.Behavior=function n(r,i={}){return{transformer:r,defaultParams:i}}}(an||(an={})),function(e){e.Registry=class t{constructor(){this.providers=ol().asMutable(),this.defaultAutoAttachValues=new Map}getParams(r){const i={},o=[],s=[];if(r){const a=this.providers.values();for(;;){const c=a.next();if(c.done)break;const u=c.value;u.isApplicable(r)&&(u.isHidden||(o.push([u.descriptor.name,u.label]),this.defaultAutoAttachValues.get(u.descriptor.name)&&s.push(u.descriptor.name)),i[u.descriptor.name]=C.Group({...u.getParams(r)},{label:u.label,isHidden:u.isHidden}))}}return{autoAttach:C.MultiSelect(s,o),properties:C.Group(i,{isFlat:!0})}}setDefaultAutoAttach(r,i){this.defaultAutoAttachValues.set(r,i)}get(r){if(!this.providers.get(r))throw new Error(`Custom property '${r}' is not registered.`);return this.providers.get(r)}register(r,i){this.providers.set(r.descriptor.name,r),this.defaultAutoAttachValues.set(r.descriptor.name,i)}unregister(r){this.providers.delete(r),this.defaultAutoAttachValues.delete(r)}}}(u3||(u3={}));class mdt{get dataState(){return this.plugin.state.data}rawData(t,n){return this.dataState.build().toRoot().apply(cre,t,n).commit({revertOnError:!0})}download(t,n){return this.dataState.build().toRoot().apply(sre,t,n).commit({revertOnError:!0})}downloadBlob(t,n){return this.dataState.build().toRoot().apply(are,t,n).commit({revertOnError:!0})}readFile(t,n){var r=this;return ie(function*(){var i,o,s;return{data:yield r.dataState.build().toRoot().apply(ure,t,n).commit({revertOnError:!0}),fileInfo:o1(null!==(s=null===(o=null===(i=t.file)||void 0===i?void 0:i.file)||void 0===o?void 0:o.name)&&void 0!==s?s:"")}})()}constructor(t){this.plugin=t}}class gdt{get dataState(){return this.plugin.state.data}resolveProvider(t){var n;return"string"==typeof t?null!==(n=Mf[t])&&void 0!==n?n:cB(this._providers,r=>r.id===t):t}hasPreset(t){for(const n of this._providers)if(!n.isApplicable||n.isApplicable(t,this.plugin))return!0;return!1}get providers(){return this._providers}getPresets(t){if(!t)return this.providers;const n=[];for(const r of this._providers)r.isApplicable&&!r.isApplicable(t,this.plugin)||n.push(r);return n}getPresetSelect(t){const n=[];for(const r of this._providers)t&&r.isApplicable&&!r.isApplicable(t,this.plugin)||n.push([r.id,r.display.name,r.display.group]);return C.Select("auto",n)}getPresetsWithOptions(t){const n=[],r=Object.create(null);for(const i of this._providers)i.isApplicable&&!i.isApplicable(t,this.plugin)||(n.push([i.id,i.display.name]),r[i.id]=i.params?C.Group(i.params(t,this.plugin)):C.EmptyGroup());return 0===n.length?C.MappedStatic("",{"":C.EmptyGroup()}):C.MappedStatic(n[0][0],r,{options:n})}registerPreset(t){if(this.providerMap.has(t.id))throw new Error(`Representation provider with id '${t.id}' already registered.`);this._providers.push(t),this.providerMap.set(t.id,t)}unregisterPreset(t){this.providerMap.delete(t.id),Xx(this._providers,t)}applyPreset(t,n,r){var i;const o=this.resolveProvider(n);if(!o)return;const a=ls.resolveAndCheck(this.plugin.state.data,t);if(!a)return void(Qx||console.warn("Applying structure repr. provider to bad cell."));const c=(null===(i=o.params)||void 0===i?void 0:i.call(o,a.obj,this.plugin))||{};let u=r||(o.params?C.getDefaultValues(c):{});const l=this.plugin.config.get(qi.Structure.DefaultRepresentationPresetParams);u=C.merge(c,l,u);const d=Oe.create(`${o.display.name}`,()=>o.apply(a,u,this.plugin));return this.plugin.runTask(d)}addRepresentation(t,n,r){var i=this;return ie(function*(){const o=i.dataState.build(),s=i.buildRepresentation(o,t,n,r);if(s)return yield o.commit(),s})()}buildRepresentation(t,n,r,i){var o,s;if(!n)return;const a=null===(s=null===(o=ls.resolveAndCheck(this.dataState,n))||void 0===o?void 0:o.obj)||void 0===s?void 0:s.data;if(!a)return;const c=QE(this.plugin,a,r);return i?.tag?t.to(n).applyOrUpdateTagged(i.tag,yE,c,{state:i?.initialState}).selector:t.to(n).apply(yE,c,{state:i?.initialState}).selector}constructor(t){this.plugin=t,this._providers=[],this.providerMap=new Map,this.defaultProvider=Mf.auto,$a(Mf,n=>this.registerPreset(n))}}function Om(e){return e}!function(e){e.CommonParams=(t,n)=>({modelProperties:C.Optional(C.Group(Qe.getParamDefinition(Ye.Model.CustomModelProperties,void 0,n))),structureProperties:C.Optional(C.Group(Qe.getParamDefinition(Ye.Model.CustomStructureProperties,void 0,n))),representationPreset:C.Optional(C.Text("auto"))})}(Om||(Om={}));const l3=Om.CommonParams,cfe=Om({id:"preset-trajectory-default",display:{name:"Default (Assembly)",group:"Preset",description:"Shows the first assembly or, if that is unavailable, the first model."},isApplicable:e=>!0,params:(e,t)=>({model:C.Optional(C.Group(Qe.getParamDefinition(Ye.Model.ModelFromTrajectory,e,t))),showUnitcell:C.Optional(C.Boolean(!1)),structure:C.Optional(b0.getParams(void 0,"assembly").type),representationPresetParams:C.Optional(C.Group(oa.CommonParams)),...l3(e,t)}),apply:(e,t,n)=>ie(function*(){const r=n.builders.structure,i=yield r.createModel(e,t.model),o=yield r.insertModelProperties(i,t.modelProperties),s=yield r.createStructure(o||i,t.structure),a=yield r.insertStructureProperties(s,t.structureProperties),c=void 0===t.showUnitcell||t.showUnitcell?yield r.tryCreateUnitcell(o,void 0,{isHidden:!0}):void 0,u=t.representationPreset||n.config.get(qi.Structure.DefaultRepresentationPreset)||Mf.auto.id;return{model:i,modelProperties:o,unitcell:c,structure:s,structureProperties:a,representation:yield n.builders.structure.representation.applyPreset(a,u,t.representationPresetParams)}})()}),ydt=Om({id:"preset-trajectory-all-models",display:{name:"All Models",group:"Preset",description:"Shows all models; colored by trajectory-index."},isApplicable:e=>e.data.frameCount>1,params:(e,t)=>({useDefaultIfSingleModel:C.Optional(C.Boolean(!1)),representationPresetParams:C.Optional(C.Group(oa.CommonParams)),...l3(e,t)}),apply:(e,t,n)=>ie(function*(){var r,i;const o=null===(i=null===(r=ls.resolveAndCheck(n.state.data,e))||void 0===r?void 0:r.obj)||void 0===i?void 0:i.data;if(!o)return{};if(1===o.frameCount&&t.useDefaultIfSingleModel)return cfe.apply(e,t,n);const s=n.builders.structure,a=[],c=[];for(let u=0;u({model:C.Optional(C.Group(Qe.getParamDefinition(Ye.Model.ModelFromTrajectory,e,t))),...l3(e,t)});function lfe(e,t,n,r){return uV.apply(this,arguments)}function uV(){return uV=ie(function*(e,t,n,r){const i=r.builders.structure,o=yield i.createModel(t,n.model),s=yield i.insertModelProperties(o,n.modelProperties),a=yield i.createStructure(s||o,{name:"symmetry",params:e}),c=yield i.insertStructureProperties(a,n.structureProperties),u=yield i.tryCreateUnitcell(s,void 0,{isHidden:!1}),l=n.representationPreset||r.config.get(qi.Structure.DefaultRepresentationPreset)||Mf.auto.id;return{model:o,modelProperties:s,unitcell:u,structure:a,structureProperties:c,representation:yield r.builders.structure.representation.applyPreset(c,l,{theme:{globalName:e.theme}})}}),uV.apply(this,arguments)}const bdt=Om({id:"preset-trajectory-unitcell",display:{name:"Unit Cell",group:"Preset",description:"Shows the fully populated unit cell."},isApplicable:e=>sn.hasCrystalSymmetry(e.data.representative),params:ufe,apply:(e,t,n)=>ie(function*(){return yield lfe({ijkMin:v.create(0,0,0),ijkMax:v.create(0,0,0)},e,t,n)})()}),vdt=Om({id:"preset-trajectory-supercell",display:{name:"Super Cell",group:"Preset",description:"Shows the super cell, i.e. the central unit cell and all adjacent unit cells."},isApplicable:e=>sn.hasCrystalSymmetry(e.data.representative),params:ufe,apply:(e,t,n)=>ie(function*(){return yield lfe({ijkMin:v.create(-1,-1,-1),ijkMax:v.create(1,1,1),theme:"operator-hkl"},e,t,n)})()}),_dt=Om({id:"preset-trajectory-crystal-contacts",display:{name:"Crystal Contacts",group:"Preset",description:"Showsasymetric unit and chains from neighbours within 5 \u212b, i.e., symmetry mates."},isApplicable:e=>sn.hasCrystalSymmetry(e.data.representative),params:(e,t)=>({model:C.Optional(C.Group(Qe.getParamDefinition(Ye.Model.ModelFromTrajectory,e,t))),...l3(e,t)}),apply:(e,t,n)=>ie(function*(){const r=n.builders.structure,i=yield r.createModel(e,t.model),o=yield r.insertModelProperties(i,t.modelProperties),s=yield r.createStructure(o||i,{name:"symmetry-mates",params:{radius:5}}),a=yield r.insertStructureProperties(s,t.structureProperties),c=yield r.tryCreateUnitcell(o,void 0,{isHidden:!0}),u=t.representationPreset||n.config.get(qi.Structure.DefaultRepresentationPreset)||Mf.auto.id;return{model:i,modelProperties:o,unitcell:c,structure:s,structureProperties:a,representation:yield n.builders.structure.representation.applyPreset(a,u,{theme:{globalName:"operator-name",carbonColor:"operator-name",focus:{name:"element-symbol",params:{carbonColor:{name:"operator-name",params:N6.defaultValues}}}}})}})()}),lV={default:cfe,"all-models":ydt,unitcell:bdt,supercell:vdt,crystalContacts:_dt};class xdt{resolveProvider(t){var n;return"string"==typeof t?null!==(n=lV[t])&&void 0!==n?n:cB(this._providers,r=>r.id===t):t}hasPreset(t){for(const n of this._providers)if(!n.isApplicable||n.isApplicable(t,this.plugin))return!0;return!1}get providers(){return this._providers}getPresets(t){if(!t)return this.providers;const n=[];for(const r of this._providers)r.isApplicable&&!r.isApplicable(t,this.plugin)||n.push(r);return n}getPresetSelect(t){const n=[];for(const r of this._providers)t&&r.isApplicable&&!r.isApplicable(t,this.plugin)||n.push([r.id,r.display.name]);return C.Select("auto",n)}getPresetsWithOptions(t){const n=[],r=Object.create(null);for(const i of this._providers)i.isApplicable&&!i.isApplicable(t,this.plugin)||(n.push([i.id,i.display.name]),r[i.id]=i.params?C.Group(i.params(t,this.plugin)):C.EmptyGroup());return 0===n.length?C.MappedStatic("",{"":C.EmptyGroup()}):C.MappedStatic(n[0][0],r,{options:n})}registerPreset(t){if(this.providerMap.has(t.id))throw new Error(`Hierarchy provider with id '${t.id}' already registered.`);this._providers.push(t),this.providerMap.set(t.id,t)}unregisterPreset(t){this.providerMap.delete(t.id),Xx(this._providers,t)}applyPreset(t,n,r){const i=this.resolveProvider(n);if(!i)return;const s=ls.resolveAndCheck(this.plugin.state.data,t);if(!s)return void(Qx||console.warn("Applying hierarchy preset provider to bad cell."));const a=r||(i.params?C.getDefaultValues(i.params(s.obj,this.plugin)):{}),c=Oe.create(`${i.display.name}`,()=>i.apply(s,a,this.plugin));return this.plugin.runTask(c)}constructor(t){this.plugin=t,this._providers=[],this.providerMap=new Map,this.defaultProvider=lV.default,$a(lV,n=>this.registerPreset(n))}}class Sdt{get dataState(){return this.plugin.state.data}parseTrajectoryData(t,n){var r=this;return ie(function*(){const i="string"==typeof n?r.plugin.dataFormats.get(n):n;if(!i)throw new Error(`'${n}' is not a supported data format.`);const{trajectory:o}=yield i.parse(r.plugin,t);return o})()}parseTrajectoryBlob(t,n){return this.dataState.build().to(t).apply(Ye.Data.ParseBlob,n,{state:{isGhost:!0}}).apply(Ye.Model.TrajectoryFromBlob,void 0).commit({revertOnError:!0})}parseTrajectory(t,n){const r=ls.resolveAndCheck(this.dataState,t);if(!r)throw new Error("Invalid data cell.");return pe.Data.Blob.is(r.obj)?this.parseTrajectoryBlob(t,n):this.parseTrajectoryData(t,n)}createModel(t,n,r){return this.dataState.build().to(t).apply(Ye.Model.ModelFromTrajectory,n||{modelIndex:0},{state:r}).commit({revertOnError:!0})}insertModelProperties(t,n,r){return this.dataState.build().to(t).apply(Ye.Model.CustomModelProperties,n,{state:r}).commit({revertOnError:!0})}tryCreateUnitcell(t,n,r){var i,o,s;const a=this.dataState,c=null===(o=null===(i=ls.resolveAndCheck(a,t))||void 0===i?void 0:i.obj)||void 0===o?void 0:o.data;if(!c)return;const u=null===(s=no.Provider.get(c))||void 0===s?void 0:s.spacegroup.cell;return ma.isZero(u)?void 0:a.build().to(t).apply(Ye.Representation.ModelUnitcell3D,n,{state:r}).commit({revertOnError:!0})}createStructure(t,n,r,i){var o;const s=this.dataState;if(!n){const c=ls.resolveAndCheck(s,t);if(c){const u=no.Provider.get(null===(o=c.obj)||void 0===o?void 0:o.data);(!u||0===u?.assemblies.length)&&(n={name:"model",params:{}})}}return s.build().to(t).apply(Ye.Model.StructureFromModel,{type:n||{name:"assembly",params:{}}},{state:r,tags:i}).commit({revertOnError:!0})}insertStructureProperties(t,n){return this.dataState.build().to(t).apply(Ye.Model.CustomStructureProperties,n).commit({revertOnError:!0})}isComponentTransform(t){return t.transform.transformer===Ye.Model.StructureComponent}tryCreateComponent(t,n,r,i){var o=this;return ie(function*(){var s,a;const c=o.dataState,u=c.build().to(t),l=`structure-component-${r}`,d=u.applyOrUpdateTagged(l,Ye.Model.StructureComponent,n,{tags:i?[...i,l]:[l]});yield d.commit();const f=d.selector;if(f.isOk&&0!==(null===(a=null===(s=f.cell)||void 0===s?void 0:s.obj)||void 0===a?void 0:a.data.elementCount))return f;yield c.build().delete(f.ref).commit()})()}tryCreateComponentFromExpression(t,n,r,i){return this.tryCreateComponent(t,{type:{name:"expression",params:n},nullIfEmpty:!0,label:(i?.label||"").trim()},r,i?.tags)}tryCreateComponentStatic(t,n,r){return this.tryCreateComponent(t,{type:{name:"static",params:n},nullIfEmpty:!0,label:(r?.label||"").trim()},`static-${n}`,r?.tags)}tryCreateComponentFromSelection(t,n,r,i){var o=this;return this.plugin.runTask(Oe.create("Query Component",function(){var s=ie(function*(a){var c,u;let{label:l,tags:d}=i||{};l=(l||"").trim();const f=null===(u=null===(c=ls.resolveAndCheck(o.dataState,t))||void 0===c?void 0:c.obj)||void 0===u?void 0:u.data;if(!f)return;const p=n.referencesCurrent?{type:{name:"bundle",params:Kn.fromSelection(yield n.getSelection(o.plugin,a,f))},nullIfEmpty:!0,label:l||n.label}:{type:{name:"expression",params:n.expression},nullIfEmpty:!0,label:l||n.label};return n.ensureCustomProperties&&(yield n.ensureCustomProperties({runtime:a,assetManager:o.plugin.managers.asset},f)),o.tryCreateComponent(t,p,r,d)});return function(a){return s.apply(this,arguments)}}()))}constructor(t){this.plugin=t,this.hierarchy=new xdt(this.plugin),this.representation=new gdt(this.plugin)}}function bC(e,t,n={}){return"string"==typeof n.type||"string"==typeof n.color||"string"==typeof n.size?function Cdt(e,t,n){const r=n.type&&e.representation.volume.registry.get(n.type)||e.representation.volume.registry.default.provider,i=n.color&&e.representation.volume.themes.colorThemeRegistry.get(n.color)||e.representation.volume.themes.colorThemeRegistry.get(r.defaultColorTheme.name),o=n.size&&e.representation.volume.themes.sizeThemeRegistry.get(n.size)||e.representation.volume.themes.sizeThemeRegistry.get(r.defaultSizeTheme.name);return dfe(e,t,{type:r,typeParams:n.typeParams,color:i,colorParams:n.colorParams,size:o,sizeParams:n.sizeParams})}(e,t||et.One,n):dfe(e,t||et.One,n)}function dfe(e,t,n={}){const{themes:r}=e.representation.volume,i={volume:t},o=n.type||e.representation.volume.registry.default.provider,s=C.getDefaultValues(o.getParams(r,t)),a=Object.assign(s,n.typeParams),c=n.color||r.colorThemeRegistry.get(o.defaultColorTheme.name),u=C.getDefaultValues(c.getParams(i));c.name===o.defaultColorTheme.name&&Object.assign(u,o.defaultColorTheme.props);const l=Object.assign(u,n.colorParams),d=n.size||r.sizeThemeRegistry.get(o.defaultSizeTheme.name),f=C.getDefaultValues(d.getParams(i));d.name===o.defaultSizeTheme.name&&Object.assign(f,o.defaultSizeTheme.props);const p=Object.assign(f,n.sizeParams);return{type:{name:o.name,params:a},colorTheme:{name:c.name,params:l},sizeTheme:{name:d.name,params:p}}}var dV,d3;!function(e){e.create=function t(n){const{name:r}=n;return{descriptor:n,get:i=>i._propertyData[r],set(i,o){i.customProperties.add(n),i._propertyData[r]=o}}}}(dV||(dV={})),function(e){e.Descriptor={name:"recommended_iso_value"},e.Provider=dV.create(e.Descriptor)}(d3||(d3={}));const l1="Volume";function vC(e,t){return fV.apply(this,arguments)}function fV(){return fV=ie(function*(e,t){if(!t)return;const{entryId:n}=t;return n&&n.toLowerCase().startsWith("emd")?e.runTask(Oe.create("Try Set Recommended IsoValue",function(){var r=ie(function*(i){try{const o=yield kde(e,i,n);d3.Provider.set(t,et.IsoValue.absolute(o))}catch(o){console.warn(o)}});return function(i){return r.apply(this,arguments)}}())):void 0}),fV.apply(this,arguments)}function ffe(e){const t=d3.Provider.get(e);if(t)return"relative"===t.kind?t:et.adjustedIsoValue(e,t.absoluteValue,"absolute")}function pV(e,t){return hV.apply(this,arguments)}function hV(){return hV=ie(function*(e,t){const n={},r=t.volume.data&&ffe(t.volume.data);return r&&(n.isoValue=r),[yield e.build().to(t.volume).apply(Ye.Representation.VolumeRepresentation3D,bC(e,t.volume.data,{type:"isosurface",typeParams:n})).commit()]}),hV.apply(this,arguments)}const wdt={label:"CCP4/MRC/MAP",description:"CCP4/MRC/MAP",category:l1,binaryExtensions:["ccp4","mrc","map"],parse:function(){var e=ie(function*(t,n,r){const i=t.build().to(n).apply(Ye.Data.ParseCcp4,{},{state:{isGhost:!0}}),o=i.apply(Ye.Volume.VolumeFromCcp4,{entryId:r?.entryId});return yield i.commit({revertOnError:!0}),yield vC(t,o.selector.data),{format:i.selector,volume:o.selector}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:pV},Adt={label:"DSN6/BRIX",description:"DSN6/BRIX",category:l1,binaryExtensions:["dsn6","brix"],parse:function(){var e=ie(function*(t,n,r){const i=t.build().to(n).apply(Ye.Data.ParseDsn6,{},{state:{isGhost:!0}}),o=i.apply(Ye.Volume.VolumeFromDsn6,{entryId:r?.entryId});return yield i.commit({revertOnError:!0}),yield vC(t,o.selector.data),{format:i.selector,volume:o.selector}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:pV},Idt={label:"DX",description:"DX",category:l1,stringExtensions:["dx"],binaryExtensions:["dxbin"],parse:function(){var e=ie(function*(t,n,r){const o=t.build().to(n).apply(Ye.Data.ParseDx,{},{state:{isGhost:!0}}).apply(Ye.Volume.VolumeFromDx,{entryId:r?.entryId});return yield o.commit({revertOnError:!0}),yield vC(t,o.selector.data),{volume:o.selector}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:pV},Tdt={label:"Cube",description:"Cube",category:l1,stringExtensions:["cub","cube"],parse:function(){var e=ie(function*(t,n,r){const i=t.build().to(n).apply(Ye.Data.ParseCube,{},{state:{isGhost:!0}}),o=i.apply(Ye.Volume.VolumeFromCube,{entryId:r?.entryId}),s=i.apply(Ye.Model.TrajectoryFromCube,void 0,{state:{isGhost:!0}}).apply(Ye.Model.ModelFromTrajectory).apply(Ye.Model.StructureFromModel);return yield i.commit({revertOnError:!0}),yield vC(t,o.selector.data),{format:i.selector,volume:o.selector,structure:s.selector}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:function(){var e=ie(function*(t,n){var r,i;const o=t.build(),s=[],a=null===(i=null===(r=n.volume.cell)||void 0===r?void 0:r.obj)||void 0===i?void 0:i.data;if(a&&et.isOrbitals(a)){const l=o.to(n.volume).apply(Ye.Representation.VolumeRepresentation3D,bC(t,a,{type:"isosurface",typeParams:{isoValue:et.IsoValue.relative(1),alpha:.4},color:"uniform",colorParams:{value:xn.blue}})),d=o.to(n.volume).apply(Ye.Representation.VolumeRepresentation3D,bC(t,a,{type:"isosurface",typeParams:{isoValue:et.IsoValue.relative(-1),alpha:.4},color:"uniform",colorParams:{value:xn.red}}));s.push(l.selector,d.selector)}else{const l=o.to(n.volume).apply(Ye.Representation.VolumeRepresentation3D,bC(t,a,{type:"isosurface",typeParams:{isoValue:et.IsoValue.relative(2),alpha:.4},color:"uniform",colorParams:{value:xn.grey}}));s.push(l.selector)}const c=yield t.builders.structure.representation.applyPreset(n.structure,"auto");yield o.commit();const u=[];return $a(c?.representations,l=>{l&&u.push(l)}),[...s,...u]});return function(n,r){return e.apply(this,arguments)}}()},Ddt={label:"DensityServer CIF",description:"DensityServer CIF",category:l1,stringExtensions:["cif"],binaryExtensions:["bcif"],isApplicable:(e,t)=>"dscif"===e3(e,t),parse:function(){var e=ie(function*(t,n,r){var i;const o=yield t.build().to(n).apply(Ye.Data.ParseCif).commit(),s=t.build().to(o),a=o.obj.data.blocks;if(0===a.length)throw new Error("no data blocks");const c=[];let u=0;for(const l of a){if("SERVER"===l.header.toUpperCase())continue;const d=Array.isArray(r?.entryId)?r?.entryId[u]:r?.entryId;(null===(i=l.categories.volume_data_3d_info)||void 0===i?void 0:i.rowCount)>0&&(c.push(s.apply(Ye.Volume.VolumeFromDensityServerCif,{blockHeader:l.header,entryId:d}).selector),u++)}yield s.commit();for(const l of c)yield vC(t,l.data);return{volumes:c}});return function(n,r,i){return e.apply(this,arguments)}}(),visuals:function(){var e=ie(function*(t,n){const{volumes:r}=n,i=t.build(),o=[];if(r.length>0){const s=r[0].data&&ffe(r[0].data)||et.IsoValue.relative(1.5);o[0]=i.to(r[0]).apply(Ye.Representation.VolumeRepresentation3D,Af.getDefaultParamsStatic(t,"isosurface",{isoValue:s,alpha:1},"uniform",{value:xn.teal})).selector}if(r.length>1){const s=Af.getDefaultParamsStatic(t,"isosurface",{isoValue:et.IsoValue.relative(3),alpha:.3},"uniform",{value:xn.green}),a=Af.getDefaultParamsStatic(t,"isosurface",{isoValue:et.IsoValue.relative(-3),alpha:.3},"uniform",{value:xn.red});o[o.length]=i.to(r[1]).apply(Ye.Representation.VolumeRepresentation3D,s).selector,o[o.length]=i.to(r[1]).apply(Ye.Representation.VolumeRepresentation3D,a).selector}return yield i.commit(),o});return function(n,r){return e.apply(this,arguments)}}()},Edt={label:"Segmentation CIF",description:"Segmentation CIF",category:l1,stringExtensions:["cif"],binaryExtensions:["bcif"],isApplicable:(e,t)=>"segcif"===e3(e,t),parse:function(){var e=ie(function*(t,n){var r;const i=yield t.build().to(n).apply(Ye.Data.ParseCif).commit(),o=t.build().to(i),s=i.obj.data.blocks;if(0===s.length)throw new Error("no data blocks");const a=[];for(const c of s)"SERVER"!==c.header.toUpperCase()&&(null===(r=c.categories.volume_data_3d_info)||void 0===r?void 0:r.rowCount)>0&&a.push(o.apply(Ye.Volume.VolumeFromSegmentationCif,{blockHeader:c.header}).selector);return yield o.commit(),{volumes:a}});return function(n,r){return e.apply(this,arguments)}}(),visuals:function(){var e=ie(function*(t,n){const{volumes:r}=n,i=t.build(),o=[];return r.length>0&&et.Segmentation.get(r[0].data)&&(o[o.length]=i.to(r[0]).apply(Ye.Representation.VolumeRepresentation3D,Af.getDefaultParams(t,"segment",r[0].data,{alpha:1,instanceGranularity:!0},"volume-segment",{})).selector),yield i.commit(),o});return function(n,r){return e.apply(this,arguments)}}()},Pdt=[["ccp4",wdt],["dsn6",Adt],["cube",Tdt],["dx",Idt],["dscif",Ddt],["segcif",Edt]],Mdt=[["ply",{label:"PLY",description:"PLY",category:"Shape",stringExtensions:["ply"],parse:function(){var e=ie(function*(t,n){const r=t.state.data.build().to(n).apply(Ye.Data.ParsePly,{},{state:{isGhost:!0}}),i=r.apply(Ye.Model.ShapeFromPly);return yield r.commit(),{format:r.selector,shape:i.selector}});return function(n,r){return e.apply(this,arguments)}}(),visuals:(e,t)=>e.state.data.build().to(t.shape).apply(Ye.Representation.ShapeRepresentation3D).commit()}]];class Rdt{get types(){return this._list.map(t=>[t.name,t.provider.label])}get extensions(){if(this._extensions)return this._extensions;const t=new Set;return this._list.forEach(({provider:n})=>{var r,i;null===(r=n.stringExtensions)||void 0===r||r.forEach(o=>t.add(o)),null===(i=n.binaryExtensions)||void 0===i||i.forEach(o=>t.add(o))}),this._extensions=t,t}get binaryExtensions(){if(this._binaryExtensions)return this._binaryExtensions;const t=new Set;return this._list.forEach(({provider:n})=>{var r;return null===(r=n.binaryExtensions)||void 0===r?void 0:r.forEach(i=>t.add(i))}),this._binaryExtensions=t,t}get options(){if(this._options)return this._options;const t=[];return this._list.forEach(({name:n,provider:r})=>t.push([n,r.label,r.category||""])),this._options=t,t}constructor(){this._list=[],this._map=new Map,this._extensions=void 0,this._binaryExtensions=void 0,this._options=void 0;for(const[t,n]of Pdt)this.add(t,n);for(const[t,n]of nut)this.add(t,n);for(const[t,n]of aut)this.add(t,n);for(const[t,n]of Mdt)this.add(t,n);for(const[t,n]of Tde)this.add(t,n)}_clear(){this._extensions=void 0,this._binaryExtensions=void 0,this._options=void 0}add(t,n){this._clear(),this._list.push({name:t,provider:n}),this._map.set(t,n)}remove(t){this._clear(),this._list.splice(this._list.findIndex(n=>n.name===t),1),this._map.delete(t)}auto(t,n){var r,i;for(let o=0,s=this.list.length;o[t.name,t.display.name]),{label:"Animation"})}),this._params}updateParams(t){if(this.isEmpty)return;this.updateState({params:{...this.state.params,...t}});const n=this.map.get(this.state.params.current),r=n.params(this.context);this._current={anim:n,params:r,paramValues:C.getDefaultValues(r),state:{},startedTime:-1,lastTime:0},this.triggerUpdate()}updateCurrentParams(t){this.isEmpty||(this._current.paramValues={...this._current.paramValues,...t},this.triggerUpdate())}register(t){this.map.has(t.name)?this.context.log.error(`Animation '${t.name}' is already registered.`):(this._params=void 0,this.map.set(t.name,t),this._animations.push(t),1===this._animations.length?this.updateParams({current:t.name}):this.triggerUpdate())}play(t,n){var r=this;return ie(function*(){yield r.stop(),r.map.has(t.name)||r.register(t),r.updateParams({current:t.name}),r.updateCurrentParams(n),yield r.start()})()}tick(t,n,r){var i=this;return ie(function*(){i.currentTime=t,!i.isStopped&&(n||r?yield i.applyFrame(r):i.applyAsync())})()}start(){var t=this;return ie(function*(){t.updateState({animationState:"playing"}),t.context.behaviors.state.isAnimating.value||t.context.behaviors.state.isAnimating.next(!0),t.triggerUpdate();const n=t._current.anim;let r=t._current.anim.initialState(t._current.paramValues,t.context);if(n.setup){const i=yield n.setup(t._current.paramValues,r,t.context);i&&(r=i)}t._current.lastTime=0,t._current.startedTime=-1,t._current.state=r,t.isStopped=!1})()}stop(){var t=this;return ie(function*(){if(t.isStopped=!0,"stopped"!==t.state.animationState){const n=t._current.anim;n.teardown&&(yield n.teardown(t._current.paramValues,t._current.state,t.context)),t.updateState({animationState:"stopped"}),t.triggerUpdate()}t.context.behaviors.state.isAnimating.value&&t.context.behaviors.state.isAnimating.next(!1)})()}get isAnimating(){return"playing"===this.state.animationState}applyAsync(){var t=this;return ie(function*(){if(!t.isApplying){t.isApplying=!0;try{yield t.applyFrame()}finally{t.isApplying=!1}}})()}applyFrame(t){var n=this;return ie(function*(){const r=n.currentTime;n._current.startedTime<0&&(n._current.startedTime=r);const i=yield n._current.anim.apply(n._current.state,{lastApplied:n._current.lastTime,current:r-n._current.startedTime,animation:t},{params:n._current.paramValues,plugin:n.context});"finished"===i.kind?n.stop():"next"===i.kind&&(n._current.state=i.state,n._current.lastTime=r-n._current.startedTime),n.triggerApply()})()}getSnapshot(){return this.current?{state:this.state,current:{paramValues:this._current.paramValues,state:this._current.anim.stateSerialization?this._current.anim.stateSerialization.toJSON(this._current.state):this._current.state}}:{state:this.state}}setSnapshot(t){this.isEmpty||(this.updateState({animationState:t.state.animationState}),this.updateParams(t.state.params),t.current&&(this.current.paramValues=t.current.paramValues,this.current.state=this._current.anim.stateSerialization?this._current.anim.stateSerialization.fromJSON(t.current.state):t.current.state,this.triggerUpdate(),"playing"===this.state.animationState&&this.resume()))}resume(){var t=this;return ie(function*(){t._current.lastTime=0,t._current.startedTime=-1;const n=t._current.anim;t.context.behaviors.state.isAnimating.value||t.context.behaviors.state.isAnimating.next(!0),n.setup&&(yield n.setup(t._current.paramValues,t._current.state,t.context)),t.isStopped=!1})()}constructor(t){super({params:{current:""},animationState:"stopped"}),this.context=t,this.map=new Map,this._animations=[],this.currentTime=0,this._params=void 0,this.events={updated:this.ev(),applied:this.ev()},this.isStopped=!0,this.isApplying=!1}}function pfe(e,t,n){const r=n[0],i=n[1],o=n[2];return(r*e[0]+i*e[1]+o*e[2]+(-r*t[0]-i*t[1]-o*t[2]))/Math.sqrt(r*r+i*i+o*o)}const Rf={identity:Kt.create(1,0,0,0,1,0,0,0,1),rotX90:Kt.create(1,0,0,0,0,1,0,-1,0),rotY90:Kt.create(0,0,-1,0,1,0,1,0,0),rotZ90:Kt.create(0,1,0,-1,0,0,0,0,1),rotX270:Kt.create(1,0,0,0,0,-1,0,1,0),rotY270:Kt.create(0,0,1,0,1,0,-1,0,0),rotZ270:Kt.create(0,-1,0,1,0,0,0,0,1),rotX180:Kt.create(1,0,0,0,-1,0,0,0,-1),rotY180:Kt.create(-1,0,0,0,1,0,0,0,-1),rotZ180:Kt.create(-1,0,0,0,-1,0,0,0,1)};function mV(e,t){const{onlyTrace:n,skipHydrogens:r,skipWater:i}=t,{x:o,y:s,z:a,type_symbol:c,label_comp_id:u}=Ze.atom,l=[];for(const d of e){const f=nt.create(d);for(const p of d.units){f.unit=p;const m=n?p.polymerElements:p.elements;for(let h=0;hi,n)}focusLoci(t,n){let r;if(Array.isArray(t)&&t.length>1){const i=[];for(const o of t){const s=pn.getBoundingSphere(this.transformedLoci(o));s&&i.push(s)}if(0===i.length)return;this.boundaryHelper.reset();for(const o of i)this.boundaryHelper.includeSphere(o);this.boundaryHelper.finishedIncludeStep();for(const o of i)this.boundaryHelper.radiusSphere(o);r=this.boundaryHelper.getSphere()}else if(Array.isArray(t)){if(0===t.length)return;r=pn.getBoundingSphere(this.transformedLoci(t[0]))}else r=pn.getBoundingSphere(this.transformedLoci(t));r&&this.focusSphere(r,n)}focusSpheres(t,n,r){const i=[];for(const o of t){const s=n(o);s&&i.push(s)}if(0!==i.length){if(1===i.length)return this.focusSphere(i[0],r);this.boundaryHelper.reset();for(const o of i)this.boundaryHelper.includeSphere(o);this.boundaryHelper.finishedIncludeStep();for(const o of i)this.boundaryHelper.radiusSphere(o);this.focusSphere(this.boundaryHelper.getSphere(),r)}}focusSphere(t,n){var r;const{canvas3d:i}=this.plugin;if(!i)return;const{extraRadius:o,minRadius:s,durationMs:a}={...$dt,...n},c=Math.max(t.radius+o,s);if(n?.principalAxes){const u=function Odt(e,t,n){if(!e.canvas3d)return;const{origin:r,dirA:i,dirB:o,dirC:s}=n.principalAxes.boxAxes,a=v.clone(i),c=v.clone(s);if(n.positionToFlip){const{aroundX:l,aroundY:d}=function Fdt(e,t,n,r){const i=pfe(e,t,r);return{aroundX:pfe(e,t,n)<0,aroundY:i<0}}(n.positionToFlip,r,a,o);l&&(v.negate(c,c),v.negate(a,a)),d&&v.negate(c,c)}const u=v.scale(v(),r,-100);return v.dot(u,a)<=0&&v.negate(c,c),v.dot(v.unitY,c)<=0&&v.negate(a,a),e.canvas3d.camera.getFocus(r,t,a,c,gr.createDefaultSnapshot())}(this.plugin,c,n);null===(r=this.plugin.canvas3d)||void 0===r||r.requestCameraReset({durationMs:a,snapshot:u})}else{const u=i.camera.getFocus(t.center,c);i.requestCameraReset({durationMs:a,snapshot:u})}}orientAxes(t,n){if(!this.plugin.canvas3d)return;t||(t=this.plugin.state.data.selectQ(a=>a.ofType(pe.Molecule.Structure)).filter(a=>a.obj&&!a.transform.transformer.definition.isDecorator&&!a.obj.data.parent).map(a=>{var c;return null===(c=a.obj)||void 0===c?void 0:c.data}).filter(a=>!!a));const{rotation:r}=function Udt(e,t){const n=function zdt(e,t){let n;return n=mV(e,{onlyTrace:!0}),n.length>=3*t||(n=mV(e,{skipHydrogens:!0,skipWater:!0}),n.length>=3*t)||(n=mV(e,{})),n}(e,3);return function Vdt(e,t){if(0===e.length)return console.warn("Skipping PCA, no atoms"),{rotation:Rf.identity,origin:v.zero()};const n=nd.calculateMomentsAxes(e),r=nd.calculateNormalizedAxes(n),i=function qdt(e,t,n){const r=Kt();return Kt.setValue(r,0,0,e[0]),Kt.setValue(r,0,1,e[1]),Kt.setValue(r,0,2,e[2]),Kt.setValue(r,1,0,t[0]),Kt.setValue(r,1,1,t[1]),Kt.setValue(r,1,2,t[2]),Kt.setValue(r,2,0,n[0]),Kt.setValue(r,2,1,n[1]),Kt.setValue(r,2,2,n[2]),r}(r.dirA,r.dirB,r.dirC);!function Wdt(e){Kt.determinant(e)<0&&(Kt.setValue(e,2,0,-Kt.getValue(e,2,0)),Kt.setValue(e,2,1,-Kt.getValue(e,2,1)),Kt.setValue(e,2,2,-Kt.getValue(e,2,2)))}(i);const o=t?function Gdt(e,t){let n=Rf.identity,r=0;const i=Kt();for(const o of[Rf.identity,Rf.rotX180,Rf.rotY180,Rf.rotZ180]){const s=Kt.innerProduct(Kt.mul(i,o,e),t);s>r&&(n=o,r=s)}return n}(i,t):function jdt(e,t,n){const r=v.create(Kt.getValue(t,0,0),Kt.getValue(t,0,1),Kt.getValue(t,0,2)),i=v.create(Kt.getValue(t,1,0),Kt.getValue(t,1,1),Kt.getValue(t,1,2)),o=v.create(Kt.getValue(t,2,0),Kt.getValue(t,2,1),Kt.getValue(t,2,2)),s=Math.floor(e.length/3),a=v();let c=0,u=0,l=0;for(let p=0;ps!==o)}normalizedLoci(o,s,a=!1){const{loci:c,repr:u}=o;return{loci:pn.normalize(c,s?this.props.granularity:void 0,a),repr:u}}mark(o,s,a=!1){if(!pn.isEmpty(o.loci))for(const c of this.providers)c(o,s,a)}dispose(){this.providers.length=0,this.sel.dispose()}constructor(o,s={}){this.ctx=o,this.providers=[],this.props=C.getDefaultValues(e.Params),this.sel=o.managers.structure.selection,this.setProps(s)}}e.LociMarkManager=t,e.LociHighlightManager=class n extends t{constructor(){super(...arguments),this.prev=[],this.clearHighlights=(o=!1)=>{for(const s of this.prev)this.mark(s,Bt.RemoveHighlight,o);this.prev.length=0}}isHighlighted(o){for(const s of this.prev)if(yn.Loci.areEqual(s,o))return!0;return!1}addHighlight(o){this.mark(o,Bt.Highlight),this.prev.push(o)}highlight(o,s=!0){const a=this.normalizedLoci(o,s);this.isHighlighted(a)||this.addHighlight(a)}highlightOnly(o,s=!0){const a=this.normalizedLoci(o,s);this.isHighlighted(a)||(pn.isEmpty(a.loci)?this.clearHighlights():(this.clearHighlights(!0),this.addHighlight(a)))}highlightOnlyExtend(o,s=!0){const a=this.normalizedLoci(o,s);if(De.is(a.loci)){const c={loci:this.sel.tryGetRange(a.loci)||a.loci,repr:a.repr};this.isHighlighted(c)||(pn.isEmpty(c.loci)?this.clearHighlights():(this.clearHighlights(!0),this.addHighlight(c)))}}dispose(){super.dispose(),this.prev.length=0}},e.LociSelectManager=class r extends t{toggle(o,s=!0){if(pn.isEmpty(o.loci))return;const a=this.normalizedLoci(o,s,!0);De.is(a.loci)?this.toggleSel(a):super.mark(a,Bt.Toggle)}toggleExtend(o,s=!0){if(pn.isEmpty(o.loci))return;const a=this.normalizedLoci(o,s,!0);if(De.is(a.loci)){const c=this.sel.tryGetRange(a.loci)||a.loci;this.toggleSel({loci:c,repr:a.repr})}}select(o,s=!0){const a=this.normalizedLoci(o,s,!0);De.is(a.loci)&&this.sel.modify("add",a.loci),this.mark(a,Bt.Select)}selectJoin(o,s=!0){const a=this.normalizedLoci(o,s,!0);De.is(a.loci)&&this.sel.modify("intersect",a.loci),this.mark(a,Bt.Select)}selectOnly(o,s=!0){const a=this.normalizedLoci(o,s,!0);De.is(a.loci)&&(this.mark({loci:Ve.Loci(a.loci.structure),repr:a.repr},Bt.Deselect),this.sel.modify("set",a.loci)),this.mark(a,Bt.Select)}deselect(o,s=!0){const a=this.normalizedLoci(o,s,!0);De.is(a.loci)&&this.sel.modify("remove",a.loci),this.mark(a,Bt.Deselect)}deselectAll(){this.sel.clear(),this.mark({loci:JD},Bt.Deselect)}deselectAllOnEmpty(o){Ta(o.loci)&&this.deselectAll()}mark(o,s){const{loci:a}=o;if(!pn.isEmpty(a))if(De.is(a)){const c=this.sel.getLoci(a.structure);super.mark({loci:Ve.Loci(a.structure)},Bt.Deselect,!pn.isEmpty(c)),super.mark({loci:c},Bt.Select)}else super.mark(o,s)}toggleSel(o){this.sel.has(o.loci)?(this.sel.modify("remove",o.loci),this.mark(o,Bt.Deselect)):(this.sel.modify("add",o.loci),this.mark(o,Bt.Select))}}}(Lm||(Lm={}));class Xdt{clearProviders(){this.providers=[],this.isDirty=!0,this.showLabels()}addProvider(t){this.providers.push(t),this.providers.sort((n,r)=>(r.priority||0)-(n.priority||0)),this.isDirty=!0,this.showLabels()}removeProvider(t){this.providers=this.providers.filter(n=>n!==t),this.isDirty=!0,this.showLabels()}mark(t,n){const r=this.locis.findIndex(i=>yn.Loci.areEqual(t,i));-1===r&&n===Bt.Highlight?(this.locis.push(t),this.isDirty=!0):-1!==r&&n===Bt.RemoveHighlight&&(Kx(this.locis,r),this.isDirty=!0)}showLabels(){this.ctx.behaviors.labels.highlight.next({labels:this.getLabels()})}getLabels(){if(this.isDirty){this.groupedLabels.clear(),this.labels.length=0;for(const t of this.providers)for(const n of this.locis){if(pn.isEmpty(n.loci))continue;const r=t.label(n.loci,n.repr);if(r){const i=t.group?t.group(r):r.toString(),o=this.groupedLabels.get(i);o?o.push(r):this.groupedLabels.set(i,[r])}}this.labels.length=0,this.groupedLabels.forEach((t,n)=>{const r=t.length,i=r>1&&t[0]!==t[1]?n:t[0];this.labels.push(1===r?i:`${i} || \xd7 ${r}`)}),this.isDirty=!1}return this.labels}constructor(t){this.ctx=t,this.providers=[],this.locis=[],this.isDirty=!1,this.labels=[],this.groupedLabels=new Map,t.managers.interactivity.lociHighlights.addProvider((n,r,i)=>{0!==this.providers.length&&(this.mark(n,r),i||this.showLabels())})}}const mfe="overpaint-controls";function gfe(e,t,n,r,i){return gV.apply(this,arguments)}function gV(){return gV=ie(function*(e,t,n,r,i){yield function yfe(e,t,n){return bV.apply(this,arguments)}(e,t,function(){var o=ie(function*(s,a,c){if(i&&i.length>0&&!i.includes(a.params.values.type.name))return;const u=a.obj.data.sourceData,l=yield r(u.root);if(pn.isEmpty(l)||Ta(l))return;const d={bundle:Kn.fromLoci(l),color:-1===n?st(0):n,clear:-1===n};if(c){const p=bfe([...c.params.values.layers,d],u);s.to(c).update(Bo.toBundle(p))}else{const f=bfe([d],u);s.to(a.transform.ref).apply(Ye.Representation.OverpaintStructureRepresentation3DFromBundle,Bo.toBundle(f),{tags:mfe})}});return function(s,a,c){return o.apply(this,arguments)}}())}),gV.apply(this,arguments)}function bV(){return bV=ie(function*(e,t,n){const r=e.state.data,i=r.build();for(const o of t)for(const s of o.representations){const a=r.select(In.Generators.ofTransformer(Ye.Representation.OverpaintStructureRepresentation3DFromBundle,s.cell.transform.ref).withTag(mfe));yield n(i,s.cell,a[0])}return i.commit({doNotUpdateCurrent:!0})}),bV.apply(this,arguments)}function bfe(e,t){const n=Bo.ofBundle(e,t.root),r=Bo.merge(n);return Bo.filter(r,t)}const vfe="clipping-controls";function Kdt(e,t,n,r,i){return vV.apply(this,arguments)}function vV(){return vV=ie(function*(e,t,n,r,i){yield function Zdt(e,t,n){return _V.apply(this,arguments)}(e,t,function(){var o=ie(function*(s,a,c){if(i&&i.length>0&&!i.includes(a.params.values.type.name))return;const u=a.obj.data.sourceData,l=yield r(u.root);if(pn.isEmpty(l)||Ta(l))return;const d={bundle:Kn.fromLoci(l),groups:n};if(c){const p=_fe([...c.params.values.layers,d],u);s.to(c).update(Yr.toBundle(p))}else{const f=_fe([d],u);s.to(a.transform.ref).apply(Ye.Representation.ClippingStructureRepresentation3DFromBundle,Yr.toBundle(f),{tags:vfe})}});return function(s,a,c){return o.apply(this,arguments)}}())}),vV.apply(this,arguments)}function _V(){return _V=ie(function*(e,t,n){const r=e.state.data,i=r.build();for(const o of t)for(const s of o.representations){const a=r.select(In.Generators.ofTransformer(Ye.Representation.ClippingStructureRepresentation3DFromBundle,s.cell.transform.ref).withTag(vfe));yield n(i,s.cell,a[0])}return i.commit({doNotUpdateCurrent:!0})}),_V.apply(this,arguments)}function _fe(e,t){const n=Yr.ofBundle(e,t.root),r=Yr.merge(n);return Yr.filter(r,t)}const xfe="transparency-controls";function Qdt(e,t,n,r,i){return xV.apply(this,arguments)}function xV(){return xV=ie(function*(e,t,n,r,i){yield function Sfe(e,t,n){return CV.apply(this,arguments)}(e,t,function(){var o=ie(function*(s,a,c){if(i&&i.length>0&&!i.includes(a.params.values.type.name))return;const u=a.obj.data.sourceData,l=yield r(u.root);if(pn.isEmpty(l)||Ta(l))return;const d={bundle:Kn.fromLoci(l),value:n};if(c){const p=Cfe([...c.params.values.layers,d],u);s.to(c).update(Vs.toBundle(p))}else{const f=Cfe([d],u);s.to(a.transform.ref).apply(Ye.Representation.TransparencyStructureRepresentation3DFromBundle,Vs.toBundle(f),{tags:xfe})}});return function(s,a,c){return o.apply(this,arguments)}}())}),xV.apply(this,arguments)}function CV(){return CV=ie(function*(e,t,n){const r=e.state.data,i=r.build();for(const o of t)for(const s of o.representations){const a=r.select(In.Generators.ofTransformer(Ye.Representation.TransparencyStructureRepresentation3DFromBundle,s.cell.transform.ref).withTag(xfe));yield n(i,s.cell,a[0])}return i.commit({doNotUpdateCurrent:!0})}),CV.apply(this,arguments)}function Cfe(e,t){const n=Vs.ofBundle(e,t.root),r=Vs.merge(n);return Vs.filter(r,t)}const wfe="substance-controls";function Afe(e,t,n,r,i){return wV.apply(this,arguments)}function wV(){return wV=ie(function*(e,t,n,r,i){yield function Ife(e,t,n){return IV.apply(this,arguments)}(e,t,function(){var o=ie(function*(s,a,c){if(i&&i.length>0&&!i.includes(a.params.values.type.name))return;const u=a.obj.data.sourceData,l=yield r(u.root);if(pn.isEmpty(l)||Ta(l))return;const d={bundle:Kn.fromLoci(l),material:n??ba(),clear:!n};if(c){const p=Tfe([...c.params.values.layers,d],u);s.to(c).update(zs.toBundle(p))}else{const f=Tfe([d],u);s.to(a.transform.ref).apply(Ye.Representation.SubstanceStructureRepresentation3DFromBundle,zs.toBundle(f),{tags:wfe})}});return function(s,a,c){return o.apply(this,arguments)}}())}),wV.apply(this,arguments)}function IV(){return IV=ie(function*(e,t,n){const r=e.state.data,i=r.build();for(const o of t)for(const s of o.representations){const a=r.select(In.Generators.ofTransformer(Ye.Representation.SubstanceStructureRepresentation3DFromBundle,s.cell.transform.ref).withTag(wfe));yield n(i,s.cell,a[0])}return i.commit({doNotUpdateCurrent:!0})}),IV.apply(this,arguments)}function Tfe(e,t){const n=zs.ofBundle(e,t.root),r=zs.merge(n);return zs.filter(r,t)}class _C extends th{get currentStructures(){return this.plugin.managers.structure.hierarchy.selection.structures}get pivotStructure(){return this.currentStructures[0]}_setSnapshotState(t){this.updateState({options:t}),this.events.optionsUpdated.next(void 0)}setOptions(t){var n=this;return ie(function*(){const r=t.interactions!==n.state.options.interactions;n.updateState({options:t}),n.events.optionsUpdated.next(void 0);const i=n.dataState.build();for(const o of n.currentStructures)for(const s of o.components)n.updateReprParams(i,s);return n.plugin.dataTransaction(ie(function*(){yield i.commit(),yield n.plugin.state.updateBehavior(JE,o=>{o.ignoreHydrogens="all"!==t.hydrogens,o.ignoreHydrogensVariant="only-polar"===t.hydrogens?"non-polar":"all",o.ignoreLight=t.ignoreLight,o.material=t.materialStyle,o.clip=t.clipObjects}),r&&(yield n.updateInterationProps())}))})()}updateReprParams(t,n){const{hydrogens:r,visualQuality:i,ignoreLight:o,materialStyle:s,clipObjects:a}=this.state.options,c="all"!==r,u="only-polar"===r?"non-polar":"all";for(const l of n.representations){if(l.cell.transform.transformer!==yE)continue;const d=l.cell.transform.params;(!!d.type.params.ignoreHydrogens!==c||d.type.params.ignoreHydrogensVariant!==u||d.type.params.quality!==i||d.type.params.ignoreLight!==o||!Hx(d.type.params.material,s)||!C.areEqual(gm.Params,d.type.params.clip,a))&&t.to(l.cell).update(f=>{f.type.params.ignoreHydrogens=c,f.type.params.ignoreHydrogensVariant=u,f.type.params.quality=i,f.type.params.ignoreLight=o,f.type.params.material=s,f.type.params.clip=a})}}updateInterationProps(){var t=this;return ie(function*(){var n,r,i;for(const o of t.currentStructures){const s=Qi.getParams(null===(n=o.cell.obj)||void 0===n?void 0:n.data);if(o.properties){const a=null===(r=o.properties.cell.transform.params)||void 0===r?void 0:r.properties[Qi.descriptor.name];if(C.areEqual(s,a,t.state.options.interactions))continue;yield t.dataState.build().to(o.properties.cell).update(c=>{c.properties[Qi.descriptor.name]=t.state.options.interactions}).commit()}else{const a=t.plugin.customStructureProperties.getParams(null===(i=o.cell.obj)||void 0===i?void 0:i.data),c=C.getDefaultValues(a);if(C.areEqual(s,c.properties[Qi.descriptor.name],t.state.options.interactions))continue;c.properties[Qi.descriptor.name]=t.state.options.interactions,yield t.plugin.builders.structure.insertStructureProperties(o.cell,c)}}})()}applyPreset(t,n,r){var i=this;return this.plugin.dataTransaction(ie(function*(){for(const o of t){const s=yield i.plugin.builders.structure.representation.applyPreset(o.cell,n,r);yield i.syncPreset(o,s)}}),{canUndo:"Preset"})}syncPreset(t,n){if(!n||!n.components)return this.clearComponents([t]);const r=new Set;if($a(n.components,a=>{a&&r.add(a.ref)}),n.representations&&$a(n.representations,a=>{a&&r.add(a.ref)}),0===r.size)return this.clearComponents([t]);let i=!1;const o=this.dataState.build(),s=a=>{r.has(a.cell.transform.ref)||(i=!0,o.delete(a.cell))};for(const a of t.components){s(a);for(const c of a.representations)s(c);if(a.genericRepresentations)for(const c of a.genericRepresentations)s(c)}if(t.genericRepresentations)for(const a of t.genericRepresentations)s(a);return i?o.commit():void 0}clear(t){return this.clearComponents(t)}selectThis(t){var n;const r=this.plugin.managers.structure.selection;r.clear();for(const i of t){const o=Ve.toSubStructureElementLoci(i.structure.cell.obj.data,null===(n=i.cell.obj)||void 0===n?void 0:n.data);r.fromLoci("set",o)}}canBeModified(t){return this.plugin.builders.structure.isComponentTransform(t.cell)}modifyByCurrentSelection(t,n){var r=this;return this.plugin.runTask(Oe.create("Modify Component",function(){var i=ie(function*(o){const s=r.dataState.build();for(const a of t){if(!r.canBeModified(a))continue;const c=r.plugin.managers.structure.selection.getStructure(a.structure.cell.obj.data);!c||0===c.elementCount||r.modifyComponent(s,a,c,n)}yield r.dataState.updateTree(s,{canUndo:"Modify Selection"}).runInContext(o)});return function(o){return i.apply(this,arguments)}}()))}toggleVisibility(t,n){if(0!==t.length)if(n){const r=t[0].representations.indexOf(n),i=!n.cell.state.isHidden;for(const o of t){const s=o.representations[r];s&&Wv(this.dataState,s.cell.transform.ref,i)}}else{const r=!t[0].cell.state.isHidden;for(const i of t)Wv(this.dataState,i.cell.transform.ref,r)}}removeRepresentations(t,n){if(0===t.length)return;const r=[];if(n){const i=t[0].representations.indexOf(n);if(i<0)return;for(const o of t)o.representations[i]&&r.push(o.representations[i])}else for(const i of t)for(const o of i.representations)r.push(o);return this.plugin.managers.structure.hierarchy.remove(r,!0)}updateRepresentations(t,n,r){if(0===t.length)return Promise.resolve();const i=t[0].representations.indexOf(n);if(i<0)return Promise.resolve();const o=this.dataState.build();for(const s of t){const a=s.representations[i];a&&a.cell.transform.transformer===n.cell.transform.transformer&&o.to(a.cell).update(r)}return o.commit({canUndo:"Update Representation"})}updateRepresentationsTheme(t,n){var r,i,o,s;if(0===t.length)return;const a=this.dataState.build();for(const c of t)for(const u of c.representations){const l=u.cell.transform.params,d="function"==typeof n?n(c,u):n,f="default"===d.color?MU(this.plugin,null===(r=c.structure.cell.obj)||void 0===r?void 0:r.data,l?.type.name):d.color?MU(this.plugin,null===(i=c.structure.cell.obj)||void 0===i?void 0:i.data,l?.type.name,d.color,d.colorParams):void 0,p="default"===d.size?vde(this.plugin,null===(o=c.structure.cell.obj)||void 0===o?void 0:o.data,l?.type.name):d.color?vde(this.plugin,null===(s=c.structure.cell.obj)||void 0===s?void 0:s.data,l?.type.name,d.size,d.sizeParams):void 0;(f||p)&&a.to(u.cell).update(m=>{f&&(m.colorTheme=f),p&&(m.sizeTheme=p)})}return a.commit({canUndo:"Update Theme"})}addRepresentation(t,n){var r=this;if(0===t.length)return;const{hydrogens:i,visualQuality:o,ignoreLight:s,materialStyle:a,clipObjects:c}=this.state.options,d={ignoreHydrogens:"all"!==i,ignoreHydrogensVariant:"only-polar"===i?"non-polar":"all",quality:o,ignoreLight:s,material:a,clip:c};return this.plugin.dataTransaction(ie(function*(){for(const f of t)yield r.plugin.builders.structure.representation.addRepresentation(f.cell,{type:r.plugin.representation.structure.registry.get(n),typeParams:d})}),{canUndo:"Add Representation"})}tryFindComponent(t,n){var r=this;if(0!==t.components.length)return this.plugin.runTask(Oe.create("Find Component",function(){var i=ie(function*(o){var s,a;const c=null===(s=t.cell.obj)||void 0===s?void 0:s.data;if(!c)return;const u=pt.unionStructure(yield n.getSelection(r.plugin,o,c));for(const l of t.components){const d=null===(a=l.cell.obj)||void 0===a?void 0:a.data;if(d&&l.cell.parent&&vOe(u,d))return l.cell}});return function(o){return i.apply(this,arguments)}}()))}add(t,n){var r=this;return ie(function*(){return r.plugin.dataTransaction(ie(function*(){const i=n||r.currentStructures;if(0===i.length)return;const{hydrogens:o,visualQuality:s,ignoreLight:a,materialStyle:c,clipObjects:u}=r.state.options,f={ignoreHydrogens:"all"!==o,ignoreHydrogensVariant:"only-polar"===o?"non-polar":"all",quality:s,ignoreLight:a,material:c,clip:u},p=Hr.create22();for(const m of i){let h;t.options.checkExisting&&(h=yield r.tryFindComponent(m,t.selection)),h||(h=yield r.plugin.builders.structure.tryCreateComponentFromSelection(m.cell,t.selection,p,{label:t.options.label||(t.selection===No.current?"Custom Selection":"")})),"none"!==t.representation&&h&&(yield r.plugin.builders.structure.representation.addRepresentation(h,{type:r.plugin.representation.structure.registry.get(t.representation),typeParams:f}))}}),{canUndo:"Add Selection"})})()}applyTheme(t,n){var r=this;return ie(function*(){return r.plugin.dataTransaction(function(){var i=ie(function*(o){const s=n||r.currentStructures;if(0===s.length)return;const a=function(){var c=ie(function*(u){return pt.toLociWithSourceUnits(yield t.selection.getSelection(r.plugin,o,u))});return function(l){return c.apply(this,arguments)}}();for(const c of s)if("color"===t.action.name){const u=t.action.params;yield gfe(r.plugin,c.components,u.color,a,t.representations)}else if("resetColor"===t.action.name)yield gfe(r.plugin,c.components,-1,a,t.representations);else if("transparency"===t.action.name){const u=t.action.params;yield Qdt(r.plugin,c.components,u.value,a,t.representations)}else if("material"===t.action.name){const u=t.action.params;yield Afe(r.plugin,c.components,u.material,a,t.representations)}else if("resetMaterial"===t.action.name)yield Afe(r.plugin,c.components,void 0,a,t.representations);else if("clipping"===t.action.name){const u=t.action.params;yield Kdt(r.plugin,c.components,Yr.Groups.fromNames(u.excludeGroups),a,t.representations)}});return function(o){return i.apply(this,arguments)}}(),{canUndo:"Apply Theme"})})()}modifyComponent(t,n,r,i){var o,s,a;const c=null===(o=n.cell.obj)||void 0===o?void 0:o.data;if(!c||("subtract"===i||"intersect"===i)&&!fT(c,r))return;const u=null===(s=n.structure.cell.obj)||void 0===s?void 0:s.data,l="union"===i?m2(u,[c,r]):"intersect"===i?NJ(c,r):YB(c,r);if(0===l.elementCount)t.delete(n.cell.transform.ref);else{const f={type:{name:"bundle",params:Kn.fromSubStructure(u,l)},nullIfEmpty:!0,label:null===(a=n.cell.obj)||void 0===a?void 0:a.label};t.to(n.cell).update(f)}}updateLabel(t,n){var r,i;const o={type:null===(r=t.cell.params)||void 0===r?void 0:r.values.type,nullIfEmpty:null===(i=t.cell.params)||void 0===i?void 0:i.values.nullIfEmpty,label:n};this.dataState.build().to(t.cell).update(o).commit()}get dataState(){return this.plugin.state.data}clearComponents(t){const n=this.dataState.build();for(const r of t)for(const i of r.components)n.delete(i.cell.transform.ref);return n.commit({canUndo:"Clear Selections"})}constructor(t){super({options:C.getDefaultValues(_C.OptionsParams)}),this.plugin=t,this.events={optionsUpdated:this.ev()}}}!function(e){function r(o,s){var a,c;return null!==(a=s?.cell.obj)&&void 0!==a&&a.data?o.representation.structure.registry.getApplicableTypes(null===(c=s.cell.obj)||void 0===c?void 0:c.data):o.representation.structure.registry.types}function i(o,s,a,c){const u=[...a,...r(o,s)];return C.Select(u[0][0],u,{label:c})}e.OptionsParams={hydrogens:C.Select("all",[["all","Show All"],["hide-all","Hide All"],["only-polar","Only Polar"]],{description:"Determine display of hydrogen atoms in representations"}),visualQuality:C.Select("auto",t5,{description:"Control the visual/rendering quality of representations"}),ignoreLight:C.Boolean(!1,{description:"Ignore light for stylized rendering of representations"}),materialStyle:ba.getParam(),clipObjects:C.Group(gm.Params),interactions:C.Group(Qi.defaultParams,{label:"Non-covalent Interactions"})},e.getAddParams=function t(o,s){const{options:a}=o.query.structure.registry;return s={pivot:o.managers.structure.component.pivotStructure,allowNone:!0,hideSelection:!1,checkExisting:!1,...s},{selection:C.Select(a[1][0],a,{isHidden:s?.hideSelection}),representation:i(o,s?.pivot,s?.allowNone?[["none","< Create Later >"]]:[]),options:C.Group({label:C.Text(""),checkExisting:C.Boolean(!!s?.checkExisting,{help:()=>({description:"Checks if a selection with the specifield elements already exists to avoid creating duplicate components."})})})}},e.getThemeParams=function n(o,s){const{options:a}=o.query.structure.registry;return{selection:C.Select(a[1][0],a,{isHidden:!1}),action:C.MappedStatic("color",{color:C.Group({color:C.Color(xn.blue,{isExpanded:!0})},{isFlat:!0}),resetColor:C.EmptyGroup({label:"Reset Color"}),transparency:C.Group({value:C.Numeric(.5,{min:0,max:1,step:.01})},{isFlat:!0}),material:C.Group({material:ba.getParam({isFlat:!0})},{isFlat:!0}),resetMaterial:C.EmptyGroup({label:"Reset Material"}),clipping:C.Group({excludeGroups:C.MultiSelect([],C.objectToOptions(Yr.Groups.Names))},{isFlat:!0})}),representations:C.MultiSelect([],r(o,s),{emptyValue:"All"})}},e.getRepresentationTypes=r}(_C||(_C={}));class eft extends th{get current(){return this.state.current}get history(){return this.state.history}tryAddHistory(t){if(De.isEmpty(t.loci))return;let r,n=0;for(const i of this.state.history){if(De.areEqual(i.loci,t.loci)){r=i;break}n++}if(r)return Kx(this.state.history,n),this.state.history.unshift(t),void this.events.historyUpdated.next(void 0);this.state.history.unshift(t),this.state.history.length>8&&this.state.history.pop(),this.events.historyUpdated.next(void 0)}set(t){this.tryAddHistory(t),(!this.state.current||!De.areEqual(this.state.current.loci,t.loci))&&(this.state.current=t,this.behaviors.current.next(t))}setFromLoci(t){const n=pn.normalize(t);De.is(n)&&!De.isEmpty(n)?this.set({loci:n,label:uE(n,{reverse:!0,hidePrefix:!0,htmlStyling:!1})}):this.clear()}addFromLoci(t){const n=this.state.current&&De.is(t)&&t.structure===this.state.current.loci.structure?De.union(t,this.state.current.loci):t;this.setFromLoci(n)}clear(){this.state.current&&(this.state.current=void 0,this.behaviors.current.next(void 0))}getSnapshot(){if(!this.current)return{};const t=this.plugin.helpers.substructureParent.get(this.current.loci.structure),n=t?.transform.ref;return n?{current:{label:this.current.label,ref:n,bundle:Kn.fromLoci(this.current.loci),category:this.current.category}}:{}}setSnapshot(t){var n,r;if(!t.current)return void this.clear();const{label:i,ref:o,bundle:s,category:a}=t.current,c=null===(r=null===(n=this.plugin.state.data.select(In.Generators.byRef(o))[0])||void 0===n?void 0:n.obj)||void 0===r?void 0:r.data;if(!c)return;const u=Kn.toLoci(s,c);this.set({label:i,loci:u,category:a})}constructor(t){super({history:[]}),this.plugin=t,this.events={historyUpdated:this.ev()},this.behaviors={current:this.ev.behavior(void 0)},t.state.data.events.object.removed.subscribe(({obj:r})=>{var i;if(!pe.Molecule.Structure.is(r))return;(null===(i=this.current)||void 0===i?void 0:i.loci.structure)===r.data&&this.clear();const o=[];for(const s of this.history)s.loci.structure===r.data&&o.push(s);o.length!==this.history.length&&(this.history.length=0,this.history.push(...o),this.events.historyUpdated.next(void 0))});const n=_e();t.state.data.events.object.updated.subscribe(({oldData:r,obj:i,action:o})=>{var s;if(pe.Molecule.Structure.is(i)&&r!==i.data&&"in-place"===o){const a=this.state.current;if(a&&a.loci.structure===r){const u=De.remap(a.loci,i.data);this.state.current={...a,loci:u},this.behaviors.current.next(this.state.current),pn.getBoundingSphere(u,n);const l=null===(s=this.plugin.canvas3d)||void 0===s?void 0:s.camera,d=l.getTargetDistance(n.radius+4);(v.distance(l.target,n.center)>n.radius||d>l.viewport.height/l.zoom)&&this.plugin.managers.camera.focusSphere(n,{durationMs:0})}}})}}function TV(){return{trajectories:[],models:[],structures:[],refs:new Map}}function nft(e){return{kind:"trajectory",cell:e,version:e.transform.version,models:[]}}function Dfe(e,t){return{kind:"model",cell:e,version:e.transform.version,trajectory:t,structures:[]}}function rft(e,t){return{kind:"model-properties",cell:e,version:e.transform.version,model:t}}function ift(e,t){return{kind:"model-unitcell",cell:e,version:e.transform.version,model:t}}function Efe(e,t){return{kind:"structure",cell:e,version:e.transform.version,model:t,components:[]}}function oft(e,t){return{kind:"structure-properties",cell:e,version:e.transform.version,structure:t}}function sft(e,t){return{kind:"structure-transform",cell:e,version:e.transform.version,structure:t}}function aft(e,t){return{kind:"structure-volume-streaming",cell:e,version:e.transform.version,structure:t}}function cft(e){return e.transform.tags?[...e.transform.tags].sort().join():e.transform.ref}function uft(e,t){return{kind:"structure-component",cell:e,version:e.transform.version,structure:t,key:cft(e),representations:[]}}function lft(e,t){return{kind:"structure-representation",cell:e,version:e.transform.version,component:t}}function dft(e,t){return{kind:"generic-representation",cell:e,version:e.transform.version,parent:t}}function d1(e,t,n,r,...i){const o=r(...i);n.push(o),e.hierarchy.refs.set(t.transform.ref,o);const s=e.oldHierarchy.refs.get(t.transform.ref);return s?s.version!==t.transform.version&&(e.changed=!0):(e.added.add(o.cell.transform.ref),e.changed=!0),o}function G0(e,t,n,...r){const i=n(...r);e.hierarchy.refs.set(t.transform.ref,i);const o=e.oldHierarchy.refs.get(t.transform.ref);return o?o.version!==t.transform.version&&(e.changed=!0):(e.added.add(i.cell.transform.ref),e.changed=!0),i}function Pfe(e){return t=>e.is(t.obj)}function Mfe(e,t){return(n,r)=>!t(r)&&e.is(n.obj)}function f3(e){return t=>t.transform.transformer===e}function j0(){}const pft=[[Pfe(pe.Molecule.Trajectory),(e,t)=>{e.currentTrajectory=d1(e,t,e.hierarchy.trajectories,nft,t)},e=>e.currentTrajectory=void 0],[Mfe(pe.Molecule.Model,e=>e.currentModel),(e,t)=>{e.currentModel=e.currentTrajectory?d1(e,t,e.currentTrajectory.models,Dfe,t,e.currentTrajectory):G0(e,t,Dfe,t),e.hierarchy.models.push(e.currentModel)},e=>e.currentModel=void 0],[f3(Ye.Model.CustomModelProperties),(e,t)=>{if(!e.currentModel)return!1;e.currentModel.properties=G0(e,t,rft,t,e.currentModel)},j0],[f3(Ye.Representation.ModelUnitcell3D),(e,t)=>{if(!e.currentModel)return!1;e.currentModel.unitcell=G0(e,t,ift,t,e.currentModel)},j0],[Mfe(pe.Molecule.Structure,e=>e.currentStructure),(e,t)=>{e.currentStructure=e.currentModel?d1(e,t,e.currentModel.structures,Efe,t,e.currentModel):G0(e,t,Efe,t),e.hierarchy.structures.push(e.currentStructure)},e=>e.currentStructure=void 0],[f3(Ye.Model.CustomStructureProperties),(e,t)=>{if(!e.currentStructure)return!1;e.currentStructure.properties=G0(e,t,oft,t,e.currentStructure)},j0],[f3(Ye.Model.TransformStructureConformation),(e,t)=>{if(!e.currentStructure)return!1;e.currentStructure.transform=G0(e,t,sft,t,e.currentStructure)},j0],[Pfe(Tu),(e,t)=>(e.currentStructure&&(e.currentStructure.volumeStreaming=G0(e,t,aft,t,e.currentStructure)),!1),j0],[(e,t)=>!(t.currentComponent||!t.currentStructure||e.transform.transformer.definition.isDecorator)&&pe.Molecule.Structure.is(e.obj),(e,t)=>{e.currentStructure&&(e.currentComponent=d1(e,t,e.currentStructure.components,uft,t,e.currentStructure))},e=>e.currentComponent=void 0],[(e,t)=>!e.state.isGhost&&!!t.currentComponent&&pe.Molecule.Structure.Representation3D.is(e.obj),(e,t)=>(e.currentComponent&&d1(e,t,e.currentComponent.representations,lft,t,e.currentComponent),!1),j0],[e=>!e.state.isGhost&&pe.isRepresentation3D(e.obj),(e,t)=>{const n=e.currentComponent||e.currentStructure||e.currentModel;n&&(n.genericRepresentations||(n.genericRepresentations=[]),d1(e,t,n.genericRepresentations,dft,t,n))},j0]];function Rfe(e){if(!e||!e?.parent||!e.parent.cells.has(e.transform.ref))return!1;const{obj:t}=e;return!(!t||t===li.Null||"ok"!==e.status&&"error"!==e.status)}function hft(e){const{cell:t}=e;Rfe(t)||(this.changed=!0)}function mft(e){kfe(this,this.tree.transforms.get(e))}function kfe(e,t){const{state:n}=e,r=n.state.cells.get(t.ref);if(!Rfe(r))return;let i,o=!1;for(const[a,c,u]of pft)if(a(r,n)){if(!1===c(n,r)){o=!0;break}i=u;break}if(o)return;const s=e.tree.children.get(t.ref);s&&s.size&&s.forEach(mft,e),i&&i(n)}class xC extends ZS{get dataState(){return this.plugin.state.data}get currentComponentGroups(){return this._currentComponentGroups||(this._currentComponentGroups=xC.getComponentGroups(this.selection.structures)),this._currentComponentGroups}get seletionSet(){if(this._currentSelectionSet)return this._currentSelectionSet;this._currentSelectionSet=new Set;for(const t of this.selection.trajectories)this._currentSelectionSet.add(t.cell.transform.ref);for(const t of this.selection.models)this._currentSelectionSet.add(t.cell.transform.ref);for(const t of this.selection.structures)this._currentSelectionSet.add(t.cell.transform.ref);return this._currentSelectionSet}get current(){return this.sync(!1),this.state.hierarchy}get selection(){return this.sync(!1),this.state.selection}getStructuresWithSelection(){const t=this.plugin.managers.structure.hierarchy.current.structures,n=[];for(const r of t)this.plugin.managers.structure.selection.structureHasSelection(r)&&n.push(r);return n}findStructure(t){if(!t)return;const n=this.plugin.helpers.substructureParent.get(t);if(!n)return;const r=this.plugin.state.data.selectQ(i=>i.byValue(n).rootOfType(pe.Molecule.Structure))[0];return r?this.behaviors.selection.value.structures.find(i=>i.cell===r):void 0}syncCurrent(t,n){const r=this.seletionSet,i=[];for(const o of t){const s=o.cell.transform.ref;(r.has(s)||n.has(s))&&i.push(o)}return 0===i.length?t.length>0?[t[0]]:[]:i}sync(t){if(!t&&this.dataState.inUpdate)return;if(this.state.syncedTree===this.dataState.tree)return void(t&&!this.state.notified&&(this.state.notified=!0,this.behaviors.selection.next({hierarchy:this.state.hierarchy,...this.state.selection})));this.state.syncedTree=this.dataState.tree;const n=function tft(e,t){const n=function fft(e,t){return{state:e,oldHierarchy:t,hierarchy:TV(),changed:!1,added:new Set}}(e,t||TV());return function gft(e,t){kfe({tree:e,state:t},e.root)}(e.tree,n),t&&t.refs.forEach(hft,n),{hierarchy:n.hierarchy,added:n.added,changed:n.changed}}(this.plugin.state.data,this.current);if(!n.changed)return;const{hierarchy:r}=n,i=this.syncCurrent(r.trajectories,n.added),o=this.syncCurrent(r.models,n.added),s=this.syncCurrent(r.structures,n.added);this._currentComponentGroups=void 0,this._currentSelectionSet=void 0,this.state.hierarchy=r,this.state.selection.trajectories=i,this.state.selection.models=o,this.state.selection.structures=s,t?(this.state.notified=!0,this.behaviors.selection.next({hierarchy:r,trajectories:i,models:o,structures:s})):this.state.notified=!1}updateCurrent(t,n){const r=this.current,i="add"===n?Si.union(this.seletionSet,new Set(t.map(c=>c.cell.transform.ref))):Si.difference(this.seletionSet,new Set(t.map(c=>c.cell.transform.ref))),o=[],s=[],a=[];for(const c of r.trajectories)i.has(c.cell.transform.ref)&&o.push(c);for(const c of r.models)i.has(c.cell.transform.ref)&&s.push(c);for(const c of r.structures)i.has(c.cell.transform.ref)&&a.push(c);this._currentComponentGroups=void 0,this._currentSelectionSet=void 0,this.state.selection.trajectories=o,this.state.selection.models=s,this.state.selection.structures=a,this.behaviors.selection.next({hierarchy:r,trajectories:o,models:s,structures:a})}remove(t,n){if(0===t.length)return;const r=this.plugin.state.data.build();for(const i of t)r.delete("string"==typeof i?i:i.cell.transform.ref);return r.commit({canUndo:!!n&&"Remove"})}toggleVisibility(t,n){if(0===t.length)return;const r=void 0!==n?"show"!==n:!t[0].cell.state.isHidden;for(const i of t)Wv(this.dataState,i.cell.transform.ref,r)}applyPreset(t,n,r){var i=this;return this.plugin.dataTransaction(ie(function*(){for(const o of t)o.models.length>0&&(yield i.clearTrajectory(o)),yield i.plugin.builders.structure.hierarchy.applyPreset(o.cell,n,r)}))}updateStructure(t,n){var r=this;return ie(function*(){yield r.plugin.dataTransaction(ie(function*(){const i=bo.getDecoratorRoot(r.dataState.tree,t.cell.transform.ref),o=r.dataState.tree.children.get(i).toArray();yield r.remove(o,!1),yield r.plugin.state.updateTransform(r.plugin.state.data,t.cell.transform.ref,n,"Structure Type"),yield r.plugin.builders.structure.representation.applyPreset(t.cell.transform.ref,"auto")}),{canUndo:"Structure Type"}),Cn.Camera.Reset(r.plugin)})()}clearTrajectory(t){const n=this.dataState.build();for(const r of t.models)n.delete(r.cell);return n.commit()}constructor(t){super(),this.plugin=t,this.state={syncedTree:this.dataState.tree,notified:!1,hierarchy:TV(),selection:{trajectories:[],models:[],structures:[]}},this.behaviors={selection:this.ev.behavior({hierarchy:this.current,trajectories:this.selection.trajectories,models:this.selection.models,structures:this.selection.structures})},this._currentComponentGroups=void 0,this._currentSelectionSet=void 0,this.subscribe(t.state.data.events.changed,n=>{n.inTransaction||t.behaviors.state.isAnimating.value||this.sync(!0)}),this.subscribe(t.behaviors.state.isAnimating,n=>{!n&&!t.behaviors.state.isUpdating.value&&this.sync(!0)})}}!function(e){e.getComponentGroups=function t(r){if(!r.length)return[];if(1===r.length)return r[0].components.map(s=>[s]);const i=[],o=new Map;for(const s of r)for(const a of s.components){const c=a.key;if(!c)continue;let u=o.get(c);u||(u=[],o.set(c,u),i.push(u)),u.push(a)}return i},e.getSelectedStructuresDescription=function n(r){var i,o,s,a,c,u,l,d,f;const{structures:p}=r.managers.structure.hierarchy.selection;if(0===p.length)return"";if(1===p.length){const y=p[0],b=null===(i=y.cell.obj)||void 0===i?void 0:i.data;if(!b)return(null===(o=y.cell.obj)||void 0===o?void 0:o.label)||"Structure";const x=b.models[0]||b.representativeModel||b.masterModel;if(!x)return(null===(s=y.cell.obj)||void 0===s?void 0:s.label)||"Structure";const _=x.entryId;return null!==(c=null===(a=y.model)||void 0===a?void 0:a.trajectory)&&void 0!==c&&c.models&&1===y.model.trajectory.models.length?_:y.model?`${null===(u=y.model.cell.obj)||void 0===u?void 0:u.label} | ${_}`:_}const m=p[0],h=null===(l=m?.model)||void 0===l?void 0:l.trajectory;let g=!0;for(const y of p)if((null===(d=y?.model)||void 0===d?void 0:d.trajectory)!==h){g=!1;break}return g&&h?`${null===(f=h.cell.obj)||void 0===f?void 0:f.label} | ${p.length} structures`:`${p.length} structures`}}(xC||(xC={}));const DV="measurement-group",p3="measurement-order-label",yft={distanceUnitLabel:C.Text("\u212b",{isEssential:!0}),textColor:tce.textColor},bft=C.getDefaultValues(yft);class vft extends th{stateUpdated(){this.behaviors.state.next(this.state)}getGroup(){const n=In.findTagInSubtree(this.plugin.state.data.tree,ur.RootRef,DV),r=this.plugin.state.data.build();return n?r.to(n):r.toRoot().group(Ye.Misc.CreateGroup,{label:"Measurements"},{tags:DV})}setOptions(t){var n=this;return ie(function*(){n.updateState({options:t})&&n.stateUpdated();const r=n.plugin.state.data.build();for(const i of n.state.distances)r.to(i).update(o=>{o.unitLabel=t.distanceUnitLabel,o.textColor=t.textColor});for(const i of n.state.labels)r.to(i).update(o=>{o.textColor=t.textColor});for(const i of n.state.angles)r.to(i).update(o=>{o.textColor=t.textColor});for(const i of n.state.dihedrals)r.to(i).update(o=>{o.textColor=t.textColor});0!==r.editInfo.count&&(yield Cn.State.Update(n.plugin,{state:n.plugin.state.data,tree:r,options:{doNotLogTiming:!0}}))})()}addDistance(t,n,r){var i=this;return ie(function*(){const o=i.plugin.helpers.substructureParent.get(t.structure),s=i.plugin.helpers.substructureParent.get(n.structure);if(!o||!s)return;const a=[o.transform.ref];eo(a,s.transform.ref);const c=i.getGroup();c.apply(Ye.Model.MultiStructureSelectionFromExpression,{selections:[{key:"a",groupId:"a",ref:o.transform.ref,expression:De.toExpression(t)},{key:"b",groupId:"b",ref:s.transform.ref,expression:De.toExpression(n)}],isTransitive:!0,label:"Distance"},{dependsOn:a,tags:r?.selectionTags}).apply(Ye.Representation.StructureSelectionsDistance3D,{customText:r?.customText||"",unitLabel:i.state.options.distanceUnitLabel,textColor:i.state.options.textColor,...r?.lineParams,...r?.labelParams,...r?.visualParams},{tags:r?.reprTags});const u=i.plugin.state.data;yield Cn.State.Update(i.plugin,{state:u,tree:c,options:{doNotLogTiming:!0}})})()}addAngle(t,n,r,i){var o=this;return ie(function*(){const s=o.plugin.helpers.substructureParent.get(t.structure),a=o.plugin.helpers.substructureParent.get(n.structure),c=o.plugin.helpers.substructureParent.get(r.structure);if(!s||!a||!c)return;const u=[s.transform.ref];eo(u,a.transform.ref),eo(u,c.transform.ref);const l=o.getGroup();l.apply(Ye.Model.MultiStructureSelectionFromExpression,{selections:[{key:"a",ref:s.transform.ref,expression:De.toExpression(t)},{key:"b",ref:a.transform.ref,expression:De.toExpression(n)},{key:"c",ref:c.transform.ref,expression:De.toExpression(r)}],isTransitive:!0,label:"Angle"},{dependsOn:u,tags:i?.selectionTags}).apply(Ye.Representation.StructureSelectionsAngle3D,{customText:i?.customText||"",textColor:o.state.options.textColor,...i?.lineParams,...i?.labelParams,...i?.visualParams},{tags:i?.reprTags});const d=o.plugin.state.data;yield Cn.State.Update(o.plugin,{state:d,tree:l,options:{doNotLogTiming:!0}})})()}addDihedral(t,n,r,i,o){var s=this;return ie(function*(){const a=s.plugin.helpers.substructureParent.get(t.structure),c=s.plugin.helpers.substructureParent.get(n.structure),u=s.plugin.helpers.substructureParent.get(r.structure),l=s.plugin.helpers.substructureParent.get(i.structure);if(!(a&&c&&u&&l))return;const d=[a.transform.ref];eo(d,c.transform.ref),eo(d,u.transform.ref),eo(d,l.transform.ref);const f=s.getGroup();f.apply(Ye.Model.MultiStructureSelectionFromExpression,{selections:[{key:"a",ref:a.transform.ref,expression:De.toExpression(t)},{key:"b",ref:c.transform.ref,expression:De.toExpression(n)},{key:"c",ref:u.transform.ref,expression:De.toExpression(r)},{key:"d",ref:l.transform.ref,expression:De.toExpression(i)}],isTransitive:!0,label:"Dihedral"},{dependsOn:d,tags:o?.selectionTags}).apply(Ye.Representation.StructureSelectionsDihedral3D,{customText:o?.customText||"",textColor:s.state.options.textColor,...o?.lineParams,...o?.labelParams,...o?.visualParams},{tags:o?.reprTags});const p=s.plugin.state.data;yield Cn.State.Update(s.plugin,{state:p,tree:f,options:{doNotLogTiming:!0}})})()}addLabel(t,n){var r=this;return ie(function*(){const i=r.plugin.helpers.substructureParent.get(t.structure);if(!i)return;const o=[i.transform.ref],s=r.getGroup();s.apply(Ye.Model.MultiStructureSelectionFromExpression,{selections:[{key:"a",ref:i.transform.ref,expression:De.toExpression(t)}],isTransitive:!0,label:"Label"},{dependsOn:o,tags:n?.selectionTags}).apply(Ye.Representation.StructureSelectionsLabel3D,{textColor:r.state.options.textColor,...n?.labelParams,...n?.visualParams},{tags:n?.reprTags});const a=r.plugin.state.data;yield Cn.State.Update(r.plugin,{state:a,tree:s,options:{doNotLogTiming:!0}})})()}addOrientation(t){var n=this;return ie(function*(){const r=[],i=[];for(let a=0,c=t.length;a{n.inTransaction||t.behaviors.state.isAnimating.value||this.sync()}),t.behaviors.state.isAnimating.subscribe(n=>{!n&&!t.behaviors.state.isUpdating.value&&this.sync()})}}const SC=new fu("98");class xft extends th{get entries(){return this.state.entries}get additionsHistory(){return this.state.additionsHistory}get stats(){return this.state.stats||(this.state.stats=this.calcStats()),this.state.stats}getEntry(t){const n=this.plugin.helpers.substructureParent.get(t,!0);if(!n)return;const r=n.transform.ref;if(!this.entries.has(r)){const i=new EV(De(t,[]));return this.entries.set(r,i),i}return this.entries.get(r)}calcStats(){let t=0,n=0;const r=rf.create();this.entries.forEach(o=>{const{elements:s}=o.selection;if(s.length){t+=1;for(let a=0,c=s.length;a24&&this.additionsHistory.pop(),this.events.additionsHistoryUpdated.next(void 0)}clearHistory(){0!==this.state.additionsHistory.length&&(this.state.additionsHistory=[],this.events.additionsHistoryUpdated.next(void 0))}clearHistoryForStructure(t){const n=[];for(const r of this.state.additionsHistory)r.loci.structure.root===t.root&&n.push(r);for(const r of n)this.modifyHistory(r,"remove");0!==n.length&&this.events.additionsHistoryUpdated.next(void 0)}onRemove(t,n){var r;this.entries.has(t)&&(this.entries.delete(t),n?.data&&this.clearHistoryForStructure(n.data),(null===(r=this.referenceLoci)||void 0===r?void 0:r.structure)===n?.data&&(this.referenceLoci=void 0),this.state.stats=void 0,this.events.changed.next(void 0))}onUpdate(t,n,r){var i,o,s,a;if(n===r||n?.data===r.data)return;const c=this.plugin.helpers.substructureParent.get(r.data,!0);if(!c||t!==c.transform.ref||!this.entries.has(t))return;const u=null===(o=null===(i=this.plugin.helpers.substructureParent.get(r.data))||void 0===i?void 0:i.obj)||void 0===o?void 0:o.data;if(u)if(!n?.data||Ve.areUnitIdsAndIndicesEqual(n.data,r.data)){this.entries.set(t,function Cft(e,t){return new EV(De.remap(e.selection,t))}(this.entries.get(t),u)),(null===(s=this.referenceLoci)||void 0===s?void 0:s.structure.root)===u.root&&(this.referenceLoci=De.remap(this.referenceLoci,u));let l=!1;for(const d of this.state.additionsHistory)d.loci.structure.root===u.root&&(d.loci=De.remap(d.loci,u),l=!0);l&&this.events.additionsHistoryUpdated.next(void 0)}else this.entries.set(t,new EV(De(u,[]))),(null===(a=this.referenceLoci)||void 0===a?void 0:a.structure.root)===u.root&&(this.referenceLoci=void 0),this.clearHistoryForStructure(u),this.state.stats=void 0,this.events.changed.next(void 0)}clear(){const t=this.entries.keys(),n=[];for(;;){const r=t.next();if(r.done)break;const i=this.entries.get(r.value);De.isEmpty(i.selection)||n.push(i.selection),i.selection=De(i.selection.structure,[])}return this.referenceLoci=void 0,this.state.stats=void 0,this.events.changed.next(void 0),this.events.loci.clear.next(void 0),this.clearHistory(),n}getLoci(t){const n=this.getEntry(t);return n?n.selection:$n}getStructure(t){const n=this.getEntry(t);if(n)return n.structure}structureHasSelection(t){var n,r;const i=null===(r=null===(n=t.cell)||void 0===n?void 0:n.obj)||void 0===r?void 0:r.data;if(!i)return!1;const o=this.getEntry(i);return!!o&&!De.isEmpty(o.selection)}has(t){if(De.is(t)){const n=this.getEntry(t.structure);if(n)return De.isSubset(n.selection,t)}return!1}tryGetRange(t){if(!De.is(t)||1!==t.elements.length||!this.getEntry(t.structure))return;const r=t.elements[0];if(!r)return;const i=this.referenceLoci;if(!i||!De.is(i)||i.structure!==t.structure)return;let o;for(const s of i.elements)if(r.unit===s.unit){o=s;break}return o&&r.unit===o.unit?function wft(e,t,n){const r=Math.min(Fe.min(t.indices),Fe.min(n.indices)),i=Math.max(Fe.max(t.indices),Fe.max(n.indices));return De(e,[{unit:t.unit,indices:Fe.ofRange(r,i)}])}(t.structure,o,r):void 0}elementCount(){let t=0;return this.entries.forEach(n=>{t+=De.size(n.selection)}),t}getBoundary(){const t=v.create(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=v.create(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);SC.reset();const r=[];this.entries.forEach(i=>{const o=i.selection;De.isEmpty(o)||r.push(De.getBoundary(o))});for(let i=0,o=r.length;in.selection))}modify(t,n){let r=!1;switch(t){case"add":r=this.add(n);break;case"remove":r=this.remove(n);break;case"intersect":r=this.intersect(n);break;case"set":r=this.set(n)}r&&(this.state.stats=void 0,this.events.changed.next(void 0))}get applicableStructures(){return this.plugin.managers.structure.hierarchy.selection.structures.filter(t=>!!t.cell.obj).map(t=>t.cell.obj.data)}triggerInteraction(t,n,r=!0){switch(t){case"add":this.plugin.managers.interactivity.lociSelects.select({loci:n},r);break;case"remove":this.plugin.managers.interactivity.lociSelects.deselect({loci:n},r);break;case"intersect":this.plugin.managers.interactivity.lociSelects.selectJoin({loci:n},r);break;case"set":this.plugin.managers.interactivity.lociSelects.selectOnly({loci:n},r)}}fromLoci(t,n,r=!0){this.triggerInteraction(t,n,r)}fromCompiledQuery(t,n,r=!0){for(const i of this.applicableStructures){const o=n(new qu(i));this.triggerInteraction(t,pt.toLociWithSourceUnits(o),r)}}fromSelectionQuery(t,n,r=!0){var i=this;this.plugin.runTask(Oe.create("Structure Selection",function(){var o=ie(function*(s){for(const a of i.applicableStructures){const c=yield n.getSelection(i.plugin,s,a);i.triggerInteraction(t,pt.toLociWithSourceUnits(c),r)}});return function(s){return o.apply(this,arguments)}}()))}fromSelections(t){var n;const r=ls.resolveAndCheck(this.plugin.state.data,t);if(r&&r.obj){if(!pe.Molecule.Structure.Selections.is(r.obj))return void console.warn("fromSelections applied to wrong object type.",r.obj);this.clear();for(const i of null===(n=r.obj)||void 0===n?void 0:n.data)this.fromLoci("set",i.loci)}}getSnapshot(){const t=[];return this.entries.forEach((n,r)=>{t.push({ref:r,bundle:Kn.fromLoci(n.selection)})}),{entries:t}}setSnapshot(t){var n,r;this.entries.clear();for(const{ref:i,bundle:o}of t.entries){const s=null===(r=null===(n=this.plugin.state.data.select(In.Generators.byRef(i))[0])||void 0===n?void 0:n.obj)||void 0===r?void 0:r.data;if(!s)continue;const a=Kn.toLoci(o,s);this.fromLoci("set",a,!1)}}constructor(t){super({entries:new Map,additionsHistory:[],stats:{structureCount:0,elementCount:0,label:"Nothing Selected"}}),this.plugin=t,this.events={changed:this.ev(),additionsHistoryUpdated:this.ev(),loci:{add:this.ev(),remove:this.ev(),clear:this.ev()}},t.helpers.substructureParent.events.removed.subscribe(n=>this.onRemove(n.ref,n.obj)),t.helpers.substructureParent.events.updated.subscribe(n=>this.onUpdate(n.ref,n.oldObj,n.obj))}}class EV{get selection(){return this._selection}set selection(t){this._selection=t,this._structure=void 0}get structure(){return this._structure||(this._structure=pn.isEmpty(this._selection)?void 0:De.toStructure(this._selection)),this._structure}constructor(t){this._structure=void 0,this._selection=t}}function PV(){return{volumes:[],lazyVolumes:[],refs:new Map}}function Ift(e){return{kind:"volume",cell:e,version:e.transform.version,representations:[]}}function Tft(e){return{kind:"lazy-volume",cell:e,version:e.transform.version}}function Dft(e,t){return{kind:"volume-representation",cell:e,version:e.transform.version,volume:t}}function MV(e,t,n,r,...i){const o=r(...i);n.push(o),e.hierarchy.refs.set(t.transform.ref,o);const s=e.oldHierarchy.refs.get(t.transform.ref);return s?s.version!==t.transform.version&&(e.changed=!0):(e.added.add(o.cell.transform.ref),e.changed=!0),o}function Nfe(){}const Mft=[[function Pft(e,t){return(n,r)=>!t(r)&&e.is(n.obj)}(pe.Volume.Data,e=>e.currentVolume),(e,t)=>{e.currentVolume=MV(e,t,e.hierarchy.volumes,Ift,t)},e=>e.currentVolume=void 0],[e=>pe.Volume.Lazy.is(e.obj),(e,t)=>{MV(e,t,e.hierarchy.lazyVolumes,Tft,t)},Nfe],[(e,t)=>!e.state.isGhost&&!!t.currentVolume&&pe.Volume.Representation3D.is(e.obj),(e,t)=>(e.currentVolume&&MV(e,t,e.currentVolume.representations,Dft,t,e.currentVolume),!1),Nfe]];function Ffe(e){if(!e||!e?.parent||!e.parent.cells.has(e.transform.ref))return!1;const{obj:t}=e;return!(!t||t===li.Null||"ok"!==e.status&&"error"!==e.status)}function Rft(e){const{cell:t}=e;Ffe(t)||(this.changed=!0)}function kft(e){Bfe(this,this.tree.transforms.get(e))}function Bfe(e,t){const{state:n}=e,r=n.state.cells.get(t.ref);if(!Ffe(r))return;let i,o=!1;for(const[a,c,u]of Mft)if(a(r,n)){if(!1===c(n,r)){o=!0;break}i=u;break}if(o)return;const s=e.tree.children.get(t.ref);s&&s.size&&s.forEach(kft,e),i&&i(n)}class RV extends ZS{get dataState(){return this.plugin.state.data}get current(){return this.sync(!1),this.state.hierarchy}get selection(){return this.sync(!1),this.state.selection}sync(t){if(!t&&this.dataState.inUpdate)return;if(this.state.syncedTree===this.dataState.tree)return void(t&&!this.state.notified&&(this.state.notified=!0,this.behaviors.selection.next({hierarchy:this.state.hierarchy,volume:this.state.selection})));this.state.syncedTree=this.dataState.tree;const n=function Aft(e,t){const n=function Eft(e,t){return{state:e,oldHierarchy:t,hierarchy:PV(),changed:!1,added:new Set}}(e,t||PV());return function Nft(e,t){Bfe({tree:e,state:t},e.root)}(e.tree,n),t&&t.refs.forEach(Rft,n),{hierarchy:n.hierarchy,added:n.added,changed:n.changed}}(this.plugin.state.data,this.current);if(!n.changed)return;const{hierarchy:r}=n;this.state.hierarchy=r,this.state.selection=this.state.selection&&r.refs.has(this.state.selection.cell.transform.ref)?r.refs.get(this.state.selection.cell.transform.ref):r.volumes[0],t?(this.state.notified=!0,this.behaviors.selection.next({hierarchy:r,volume:this.state.selection})):this.state.notified=!1}setCurrent(t){this.state.selection=t||this.state.hierarchy.volumes[0],this.behaviors.selection.next({hierarchy:this.state.hierarchy,volume:t||this.state.hierarchy.volumes[0]})}remove(t,n){if(0===t.length)return;const r=this.plugin.state.data.build();for(const i of t)r.delete("string"==typeof i?i:i.cell.transform.ref);return r.commit({canUndo:!!n&&"Remove"})}toggleVisibility(t,n){if(0===t.length)return;const r=void 0!==n?"show"!==n:!t[0].cell.state.isHidden;for(const i of t)Wv(this.dataState,i.cell.transform.ref,r)}addRepresentation(t,n){var r;return this.dataState.build().to(t.cell).apply(Ye.Representation.VolumeRepresentation3D,bC(this.plugin,null===(r=t.cell.obj)||void 0===r?void 0:r.data,{type:n})).commit({canUndo:"Add Representation"})}constructor(t){super(),this.plugin=t,this.state={syncedTree:this.dataState.tree,notified:!1,hierarchy:PV(),selection:void 0},this.behaviors={selection:this.ev.behavior({hierarchy:this.current,volume:this.selection})},this.subscribe(t.state.data.events.changed,n=>{n.inTransaction||t.behaviors.state.isAnimating.value||this.sync(!0)}),this.subscribe(t.behaviors.state.isAnimating,n=>{!n&&!t.behaviors.state.isUpdating.value&&this.sync(!0)})}}!function(e){e.getRepresentationTypes=function t(n,r){var i,o;return null!==(i=r?.cell.obj)&&void 0!==i&&i.data?n.representation.volume.registry.getApplicableTypes(null===(o=r.cell.obj)||void 0===o?void 0:o.data):n.representation.volume.registry.types}}(RV||(RV={}));const kV=[["full","Full"],["hidden","Hidden"]],Bft={isExpanded:C.Boolean(!1),showControls:C.Boolean(!0),regionState:C.Group({left:C.Select("full",[["full","Full"],["collapsed","Collapsed"],["hidden","Hidden"]]),top:C.Select("full",kV),right:C.Select("full",kV),bottom:C.Select("full",kV)}),controlsDisplay:C.Value("outside",{isHidden:!0})};class Oft extends th{updateProps(t){const n=!!this.state.isExpanded;this.updateState(t),this.root&&"boolean"==typeof t.isExpanded&&t.isExpanded!==n&&this.handleExpand(),this.events.updated.next(void 0)}setProps(t){this.updateState(t)}setRoot(t){this.root=t,this.state.isExpanded&&this.handleExpand()}getScrollElement(){return document.scrollingElement?document.scrollingElement:document.documentElement?document.documentElement:document.body}handleExpand(){try{const t=document.getElementsByTagName("body")[0],n=document.getElementsByTagName("head")[0];if(!t||!n||!this.root)return;if(this.state.isExpanded){const r=n.children,i=[];let o=!1;for(let l=0;lthis.updateProps(n.state)),typeof document<"u"&&(this.expandedViewport=document.createElement("meta"),this.expandedViewport.name="viewport",this.expandedViewport.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0")}}const NV={includeTypes:C.MultiSelect(RI(jn.Names),C.objectToOptions(jn.Names)),excludeTypes:C.MultiSelect([],C.objectToOptions(jn.Names)),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),aromaticBonds:C.Boolean(!0,{description:"Display aromatic bonds with dashes"}),multipleBonds:C.Select("symmetric",C.arrayToOptions(["off","symmetric","offset"]))},FV=(C.getDefaultValues(NV),{...F0,...NV,adjustCylinderLength:C.Boolean(!1,{description:"Shorten cylinders to reduce overlap with spheres. Useful for for transparent bonds. Not working well with aromatic bonds."})}),BV=(C.getDefaultValues(FV),{...Qle,...NV});function h3(e,t,n){return!jn.is(e,n)||jn.is(t,n)}function Ofe(e,t,n){const r=t.elements,i=t.bonds,{a:o,b:s,edgeProps:a}=i,{flags:c}=a,{ignoreHydrogens:u,ignoreHydrogensVariant:l,includeTypes:d,excludeTypes:f}=n,p=jn.fromNames(d),m=jn.fromNames(f),h=jn.isAll(p)&&0===m,{child:g}=e,y=g?.unitMap.get(t.id);if(g&&!y)throw new Error("expected childUnit to exist if child exists");if(!h||u||g)return b=>{const x=o[b],_=s[b];return!!(y&&!je.has(y.elements,r[x])||!h&&h3(p,m,c[b]))||!!u&&!(!md(e,t,r[x],l)&&!md(e,t,r[_],l))}}function Lfe(e,t){const n=e.interUnitBonds,{edges:r}=n,{ignoreHydrogens:i,ignoreHydrogensVariant:o,includeTypes:s,excludeTypes:a}=t,c=jn.fromNames(s),u=jn.fromNames(a),l=jn.isAll(c)&&0===u,{child:d}=e;if(!l||i||d)return f=>{if(d){const p=r[f],m=d.unitMap.get(p.unitA);if(!m)return!0;const g=e.unitMap.get(p.unitA).elements[p.indexA];if(!je.has(m.elements,g))return!0}if(i){const p=r[f],m=e.unitMap.get(p.unitA),h=e.unitMap.get(p.unitB);if(md(e,m,m.elements[p.indexA],o)||md(e,h,h.elements[p.indexB],o))return!0}return!(l||!h3(c,u,r[f].props.flag))}}var Um;function OV(e,t,n){const{objectId:r,instanceId:i,groupId:o}=e;if(n===r){const{structure:s,group:a}=t,c=a.units[i];if(Ee.isAtomic(c)){const{target:u}=s,l=c.bonds.a[o],d=c.bonds.b[o];return Lt.Loci(u,[Lt.Location(u,c,l,u,c,d),Lt.Location(u,c,d,u,c,l)])}}return $n}function LV(e,t,n,r){let i=!1;if(Lt.isLoci(e)){const{structure:o,group:s}=t;if(!Ve.areEquivalent(e.structure,o))return!1;const a=s.units[0];if(!Ee.isAtomic(a))return!1;const c=2*a.bonds.edgeCount;for(const u of e.bonds){if(u.aUnit!==u.bUnit)continue;const l=s.unitIndexMap.get(u.aUnit.id);if(void 0!==l){const d=a.bonds.getDirectedEdgeIndex(u.aIndex,u.bIndex);-1!==d&&n(Ce.ofSingleton(l*c+d))&&(i=!0)}}}else if(De.is(e)){const{structure:o,group:s}=t;if(!Ve.areEquivalent(e.structure,o))return!1;const a=s.units[0];if(!Ee.isAtomic(a))return!1;const c=2*a.bonds.edgeCount;for(const u of e.elements){const l=s.unitIndexMap.get(u.unit.id);if(void 0!==l){const{offset:d,b:f}=a.bonds;Fe.forEach(u.indices,p=>{for(let m=d[p],h=d[p+1];m{const m=o.units[p];return l.aUnit=m,l.bUnit=m,l.aIndex=m.bonds.a[f],l.bIndex=m.bonds.b[f],l};if(i?.includeLocation2){const f=Lt.Location(s,void 0,void 0,s,void 0,void 0);return Mr(c,u,1,d,!1,()=>!1,(m,h)=>{const g=o.units[h];return f.aUnit=g,f.bUnit=g,f.aIndex=g.bonds.b[m],f.bIndex=g.bonds.a[m],f})}return Mr(c,u,1,d)},e.fromStructure=function n(r,i){const o=r.interUnitBonds.edgeCount,a=Lt.Location(r,void 0,void 0,r,void 0,void 0),c=u=>{const l=r.interUnitBonds.edges[u];return a.aUnit=r.unitMap.get(l.unitA),a.aIndex=l.indexA,a.bUnit=r.unitMap.get(l.unitB),a.bIndex=l.indexB,a};if(i?.includeLocation2){const u=Lt.Location(r,void 0,void 0,r,void 0,void 0);return Mr(o,1,1,c,!0,()=>!1,d=>{const f=r.interUnitBonds.edges[d];return u.aUnit=r.unitMap.get(f.unitB),u.aIndex=f.indexB,u.bUnit=r.unitMap.get(f.unitA),u.bIndex=f.indexA,u})}return Mr(o,1,1,c,!0)}}(Um||(Um={}));const VV=new Map;function zV(e,t,n,r){let i=!1;if(Lt.isLoci(e)){if(!Ve.areEquivalent(e.structure,t))return!1;for(const o of e.bonds){const s=t.interUnitBonds.getBondIndexFromLocation(o);-1!==s&&n(Ce.ofSingleton(s))&&(i=!0)}}else if(De.is(e)){if(!Ve.areEquivalent(e.structure,t)||r&&1===e.elements.length)return!1;for(const o of e.elements)VV.set(o.unit.id,o.indices);for(const o of e.elements){const{unit:s}=o;Ee.isAtomic(s)&&t.interUnitBonds.getConnectedUnits(s.id).forEach(a=>{const c=VV.get(a.unitB);(!r||c)&&Fe.forEach(o.indices,u=>{a.connectedIndices.includes(u)&&a.getEdges(u).forEach(l=>{if(!r||c&&Fe.has(c,l.indexB)){const d=t.interUnitBonds.getEdgeIndex(u,s.id,l.indexB,a.unitB);n(Ce.ofSingleton(d))&&(i=!0)}})})})}VV.clear()}return i}const GV=jn.is;function Ufe(e,t,n,r){const i=e.elements,o=e.bonds,{edgeCount:s,a,b:c,edgeProps:u,offset:l}=o,{order:d,flags:f}=u,{sizeFactor:p,sizeAspectRatio:m,adjustCylinderLength:h,aromaticBonds:g,includeTypes:y,excludeTypes:b,multipleBonds:x}=r,_="off"===x,S="symmetric"===x,w=h3(jn.fromNames(y),jn.fromNames(b),32),D=v(),I=v(),R=e.conformation;let T;const M=nt.create(t,e),N=Lt.Location(t,e,void 0,t,e,void 0),{child:V}=t;if(r.includeParent&&V){const $=V.unitMap.get(e.id);if(!$)throw new Error("expected childUnit to exist");T=ee=>{const O=i[c[ee]];return je.has($.elements,i[a[ee]])&&!je.has($.elements,O)}}const{elementRingIndices:z,elementAromaticRingIndices:j}=e.rings,Z=g?e.resonance.delocalizedTriplets:void 0;return{linkCount:2*s,referencePosition:$=>{let ee=a[$],q=c[$];const O=Z?.getThirdElement(ee,q);if(void 0!==O)return R.invariantPosition(i[O],D);ee>q&&([ee,q]=[q,ee]),l[ee+1]-l[ee]==1&&([ee,q]=[q,ee]);const H=j.get(ee)||z.get(ee);let W=0;for(let Q=l[ee],fe=l[ee+1];QW&&(W=ce,R.invariantPosition(i[X],D))}}}return W>0?D:null},position:($,ee,q)=>{if(R.invariantPosition(i[a[q]],$),R.invariantPosition(i[c[q]],ee),h){const O=($=>(M.element=i[a[$]],n.size.size(M)*p))(q),H=($=>(M.element=i[c[$]],n.size.size(M)*p))(q),W=Math.min(O,H)*m,Q=Math.sqrt(Math.max(0,O*O-W*W))-.05,fe=Math.sqrt(Math.max(0,H*H-W*W))-.05;if(Q<=.01&&fe<=.01)return;v.normalize(I,v.sub(I,ee,$)),v.scaleAndAdd($,$,I,Q),v.scaleAndAdd(ee,ee,I,-fe)}},style:$=>{const ee=d[$],q=f[$];if(GV(q,2)||GV(q,4))return 1;if(3===ee)return _?0:S?4:5;if(g){const H=c[$],W=j.get(a[$]),Q=j.get(H),fe=W&&Q?zI(W,Q):0;if(GV(q,16)||fe&&!w)return 2===fe?8:7}return 2!==ee||_?0:S?2:3},radius:$=>($=>(N.aIndex=a[$],N.bIndex=c[$],n.size.size(N)*p))($)*m,ignore:Ofe(t,e,r),stub:T}}function Lft(e,t,n,r,i,o){if(!Ee.isAtomic(t)||!t.bonds.edgeCount)return oc.createEmpty(o);const{child:s}=n,a=s?.unitMap.get(t.id);if(s&&!a)return oc.createEmpty(o);const c=Ufe(t,n,r,i),{cylinders:u,boundingSphere:l}=Jle(0,c,i,o);if(l)u.setBoundingSphere(l);else if(u.cylinderCount>0){const d=_e.expand(_e(),(a??t).boundary.sphere,1*i.sizeFactor);u.setBoundingSphere(d)}return u}function Uft(e,t,n,r,i,o){if(!Ee.isAtomic(t)||!t.bonds.edgeCount)return Nt.createEmpty(o);const{child:s}=n,a=s?.unitMap.get(t.id);if(s&&!a)return Nt.createEmpty(o);const c=Ufe(t,n,r,i),{mesh:u,boundingSphere:l}=B0(0,c,i,o);if(l)u.setBoundingSphere(l);else if(u.triangleCount>0){const d=_e.expand(_e(),(a??t).boundary.sphere,1*i.sizeFactor);u.setBoundingSphere(d)}return u}const m3={...hs,...wU,...FV,sizeFactor:C.Numeric(.3,{min:0,max:10,step:.01}),sizeAspectRatio:C.Numeric(2/3,{min:0,max:3,step:.01}),tryUseImpostor:C.Boolean(!0),includeParent:C.Boolean(!1)};function Vfe(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth?function Vft(e){return AU({defaultProps:C.getDefaultValues(m3),createGeometry:Lft,createLocationIterator:(t,n)=>Um.fromGroup(t,{includeLocation2:"interpolate"===n.colorMode}),getLoci:OV,eachLocation:LV,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.sizeAspectRatio!==r.sizeAspectRatio||n.linkScale!==r.linkScale||n.linkSpacing!==r.linkSpacing||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.linkCap!==r.linkCap||n.aromaticScale!==r.aromaticScale||n.aromaticSpacing!==r.aromaticSpacing||n.aromaticDashCount!==r.aromaticDashCount||n.dashCount!==r.dashCount||n.dashScale!==r.dashScale||n.dashCap!==r.dashCap||n.stubCap!==r.stubCap||!Wa(n.includeTypes,r.includeTypes)||!Wa(n.excludeTypes,r.excludeTypes)||n.adjustCylinderLength!==r.adjustCylinderLength||n.aromaticBonds!==r.aromaticBonds||n.multipleBonds!==r.multipleBonds,n.colorMode!==r.colorMode&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0);const c=s.group.units[0],u=a.group.units[0];Ee.isAtomic(c)&&Ee.isAtomic(u)&&(Dc.areEqual(c.bonds,u.bonds)||(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0))},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function zft(e){return Hs({defaultProps:C.getDefaultValues(m3),createGeometry:Uft,createLocationIterator:t=>Um.fromGroup(t),getLoci:OV,eachLocation:LV,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.sizeAspectRatio!==r.sizeAspectRatio||n.radialSegments!==r.radialSegments||n.linkScale!==r.linkScale||n.linkSpacing!==r.linkSpacing||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.linkCap!==r.linkCap||n.aromaticScale!==r.aromaticScale||n.aromaticSpacing!==r.aromaticSpacing||n.aromaticDashCount!==r.aromaticDashCount||n.dashCount!==r.dashCount||n.dashScale!==r.dashScale||n.dashCap!==r.dashCap||n.stubCap!==r.stubCap||!Wa(n.includeTypes,r.includeTypes)||!Wa(n.excludeTypes,r.excludeTypes)||n.adjustCylinderLength!==r.adjustCylinderLength||n.aromaticBonds!==r.aromaticBonds||n.multipleBonds!==r.multipleBonds;const c=s.group.units[0],u=a.group.units[0];Ee.isAtomic(c)&&Ee.isAtomic(u)&&(Dc.areEqual(c.bonds,u.bonds)||(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0))},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}const jV=new Lt.ElementBondIterator;function zfe(e,t,n,r){for(jV.setElement(t,n,r);jV.hasNext;){const i=jV.move();return i.otherUnit.conformation.position(i.otherUnit.elements[i.otherIndex],e),e}return null}const Gfe=v();function jfe(e,t,n){const r=nt.create(e),i=Lt.Location(e,void 0,void 0,e,void 0,void 0),o=e.interUnitBonds,{edgeCount:s,edges:a}=o,{sizeFactor:c,sizeAspectRatio:u,adjustCylinderLength:l,aromaticBonds:d,multipleBonds:f}=n,p="off"===f,m="symmetric"===f,h=v();let g;const{child:y}=e;return n.includeParent&&y&&(g=S=>{const A=a[S],E=y.unitMap.get(A.unitA),w=y.unitMap.get(A.unitB),I=e.unitMap.get(A.unitA).elements[A.indexA],T=e.unitMap.get(A.unitB).elements[A.indexB];return E&&je.has(E.elements,I)&&(!w||!je.has(w.elements,T))}),{linkCount:s,referencePosition:S=>{const A=a[S];let E,w,D,I;if(A.unitAA.unitB))throw new Error("same units in createInterUnitBondCylinderMesh");E=e.unitMap.get(A.unitB),w=e.unitMap.get(A.unitA),D=A.indexB,I=A.indexA}return zfe(Gfe,e,E,D)||zfe(Gfe,e,w,I)},position:(S,A,E)=>{const w=a[E],D=e.unitMap.get(w.unitA),I=e.unitMap.get(w.unitB);if(D.conformation.position(D.elements[w.indexA],S),I.conformation.position(I.elements[w.indexB],A),l){const R=(S=>{const A=a[S];return r.unit=e.unitMap.get(A.unitA),r.element=r.unit.elements[A.indexA],t.size.size(r)*c})(E),T=(S=>{const A=a[S];return r.unit=e.unitMap.get(A.unitB),r.element=r.unit.elements[A.indexB],t.size.size(r)*c})(E),M=Math.min(R,T)*u,N=Math.sqrt(Math.max(0,R*R-M*M))-.05,V=Math.sqrt(Math.max(0,T*T-M*M))-.05;if(N<=.01&&V<=.01)return;v.normalize(h,v.sub(h,A,S)),v.scaleAndAdd(S,S,h,N),v.scaleAndAdd(A,A,h,-V)}},style:S=>{const A=a[S].props.order,E=ea.create(a[S].props.flag);return jn.is(E,2)||jn.is(E,4)?1:3===A?p?0:m?4:5:d&&jn.is(E,16)?7:2!==A||p?0:m?2:3},radius:S=>(S=>{const A=a[S];return i.aUnit=e.unitMap.get(A.unitA),i.aIndex=A.indexA,i.bUnit=e.unitMap.get(A.unitB),i.bIndex=A.indexB,t.size.size(i)*c})(S)*u,ignore:Lfe(e,n),stub:g}}function Gft(e,t,n,r,i){if(!t.interUnitBonds.edgeCount)return oc.createEmpty(i);const o=jfe(t,n,r),{cylinders:s,boundingSphere:a}=Jle(0,o,r,i);if(a)s.setBoundingSphere(a);else if(s.cylinderCount>0){const{child:c}=t,u=_e.expand(_e(),(c??t).boundary.sphere,1*r.sizeFactor);s.setBoundingSphere(u)}return s}function jft(e,t,n,r,i){if(!t.interUnitBonds.edgeCount)return Nt.createEmpty(i);const o=jfe(t,n,r),{mesh:s,boundingSphere:a}=B0(0,o,r,i);if(a)s.setBoundingSphere(a);else if(s.triangleCount>0){const{child:c}=t,u=_e.expand(_e(),(c??t).boundary.sphere,1*r.sizeFactor);s.setBoundingSphere(u)}return s}const g3={...r1,...kat,...FV,sizeFactor:C.Numeric(.3,{min:0,max:10,step:.01}),sizeAspectRatio:C.Numeric(2/3,{min:0,max:3,step:.01}),tryUseImpostor:C.Boolean(!0),includeParent:C.Boolean(!1)};function Hfe(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth?function Hft(e){return function Nat(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:oc.Utils},t)}({defaultProps:C.getDefaultValues(g3),createGeometry:Gft,createLocationIterator:(t,n)=>Um.fromStructure(t,{includeLocation2:"interpolate"===n.colorMode}),getLoci:UV,eachLocation:zV,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.sizeAspectRatio!==r.sizeAspectRatio||n.linkScale!==r.linkScale||n.linkSpacing!==r.linkSpacing||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.linkCap!==r.linkCap||n.aromaticScale!==r.aromaticScale||n.aromaticSpacing!==r.aromaticSpacing||n.aromaticDashCount!==r.aromaticDashCount||n.dashCount!==r.dashCount||n.dashScale!==r.dashScale||n.dashCap!==r.dashCap||n.stubCap!==r.stubCap||!Wa(n.includeTypes,r.includeTypes)||!Wa(n.excludeTypes,r.excludeTypes)||n.adjustCylinderLength!==r.adjustCylinderLength||n.multipleBonds!==r.multipleBonds,n.colorMode!==r.colorMode&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0),s.interUnitBonds!==a.interUnitBonds&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0)},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function qft(e){return rh({defaultProps:C.getDefaultValues(g3),createGeometry:jft,createLocationIterator:t=>Um.fromStructure(t),getLoci:UV,eachLocation:zV,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.sizeAspectRatio!==r.sizeAspectRatio||n.radialSegments!==r.radialSegments||n.linkScale!==r.linkScale||n.linkSpacing!==r.linkSpacing||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.linkCap!==r.linkCap||n.aromaticScale!==r.aromaticScale||n.aromaticSpacing!==r.aromaticSpacing||n.aromaticDashCount!==r.aromaticDashCount||n.dashCount!==r.dashCount||n.dashScale!==r.dashScale||n.dashCap!==r.dashCap||n.stubCap!==r.stubCap||!Wa(n.includeTypes,r.includeTypes)||!Wa(n.excludeTypes,r.excludeTypes)||n.adjustCylinderLength!==r.adjustCylinderLength||n.multipleBonds!==r.multipleBonds,s.interUnitBonds!==a.interUnitBonds&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0)},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}const Wft=ze.add3,$ft=ze.add;var f1;!function(e){e.create=function t(n=2048,r=1024,i){const o=ze.create(Float32Array,3,r,i?i.centerBuffer.ref.value:n),s=ze.create(Float32Array,1,r,i?i.groupBuffer.ref.value:n);return{add:(a,c,u,l)=>{Wft(o,a,c,u),$ft(s,l)},getSpheres:()=>{const a=ze.compact(o,!0),c=ze.compact(s,!0);return fl.create(a,c,o.elementCount,i)}}}}(f1||(f1={}));const p1=v.add;function H0(e,t,n){const{ignoreHydrogens:r,ignoreHydrogensVariant:i,traceOnly:o}=n,s=Ee.isCoarse(t),{child:a}=e,c=a?.unitMap.get(t.id);if(a&&!c)throw new Error("expected childUnit to exist if child exists");if(a||r||o)return u=>!!c&&!je.has(c.elements,u)||!s&&r&&md(e,t,u,i)||o&&!xU(t,u)}function Yft(e,t,n,r,i,o){const{child:s}=n,a=s?.unitMap.get(t.id);if(s&&!a)return Nt.createEmpty(o);const{detail:c,sizeFactor:u,stride:l}=i,{elements:d,conformation:f}=t,p=d.length,m=p*xv(c),h=at.createState(m,m/2,o),g=v(),y=H0(n,t,i),b=nt.create(n,t),x=r.size.size,_=v();let S=0,A=0;for(let I=0;IS&&(S=R),h.currentGroup=I,Zn(h,g,R*u,c)}const E=o?_e.clone(o.boundingSphere):void 0,w=at.getMesh(h);if(0===A)return w;let D;return v.scale(_,_,1/A),D=E&&v.distance(_,E.center)/E.radius<.1?E:_e.expand(_e(),(a??t).boundary.sphere,S*u+.05),w.setBoundingSphere(D),w}function Xft(e,t,n,r,i,o){const{child:s}=n,a=s?.unitMap.get(t.id);if(s&&!a)return fl.createEmpty(o);const{sizeFactor:c,stride:u}=i,{elements:l,conformation:d}=t,f=l.length,p=f1.create(f,f/2,o),m=v(),h=H0(n,t,i),g=nt.create(n,t),y=r.size.size,b=v();let x=0,_=0;if(u&&u>1||h||"uniform"!==r.size.granularity)for(let w=0;wx&&(x=D)}else{for(let w=0;wh&&(h=N),f.currentGroup=u(_,M),Zn(f,D,N*a,s)}}const y=i?_e.clone(i.boundingSphere):void 0,b=at.getMesh(f);if(0===g)return b;let x;return v.scale(m,m,1/g),x=y&&v.distance(m,y.center)/y.radius<1?y:_e.expand(_e(),(o??t).boundary.sphere,h*a+.05),b.setBoundingSphere(x),b}function Zft(e,t,n,r,i){const{child:o}=t,{sizeFactor:s,stride:a}=r,{getSerialIndex:c}=t.serialMapping,u=t.elementCount,l=f1.create(u,u/2,i),d=n.size.size,f=v();let p=0,m=0;for(const b of t.units){const x=o?.unitMap.get(b.id);if(o&&!x)return fl.createEmpty(i);const{elements:_,conformation:S}=b,A=_.length,E=v(),w=H0(t,b,r),D=nt.create(t,b);if(a&&a>1||w||"uniform"!==n.size.granularity)for(let I=0;Ip&&(p=T)}else{for(let I=0;I{const f=i.units[d];return c.unit=f,c.element=f.elements[l],c})},e.fromStructure=function n(r){const{units:i,elementCount:o}=r,s=o,{unitIndices:c,elementIndices:u}=r.serialMapping,l=nt.create(r);return Mr(s,1,1,f=>(l.unit=i[c[f]],l.element=u[f],l),!0)}}(gs||(gs={}));const qfe={sizeFactor:C.Numeric(1,{min:0,max:10,step:.1}),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),traceOnly:C.Boolean(!1),tryUseImpostor:C.Boolean(!0),stride:C.Numeric(1,{min:1,max:100,step:1})},y3={...hs,...SU,...qfe};function Wfe(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth&&r.extensions.textureFloat?function Qft(e){return CU({defaultProps:C.getDefaultValues(y3),createGeometry:Xft,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{t.createGeometry=n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.traceOnly!==r.traceOnly||n.stride!==r.stride},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function Jft(e){return Hs({defaultProps:C.getDefaultValues(y3),createGeometry:Yft,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.traceOnly!==r.traceOnly||n.stride!==r.stride},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}const $fe={...r1,...Mat,...qfe};function ept(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth&&r.extensions.textureFloat?function tpt(e){return function Rat(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:fl.Utils},t)}({defaultProps:C.getDefaultValues($fe),createGeometry:Zft,createLocationIterator:gs.fromStructure,getLoci:W0,eachLocation:q0,setUpdateState:(t,n,r)=>{t.createGeometry=n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.traceOnly!==r.traceOnly||n.stride!==r.stride},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function npt(e){return rh({defaultProps:C.getDefaultValues($fe),createGeometry:Kft,createLocationIterator:gs.fromStructure,getLoci:W0,eachLocation:q0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.traceOnly!==r.traceOnly||n.stride!==r.stride},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}const Yfe={"element-sphere":(e,t)=>vi("Element sphere",e,t,Wfe),"intra-bond":(e,t)=>vi("Intra-unit bond cylinder",e,t,Vfe),"inter-bond":(e,t)=>Iu("Inter-unit bond cylinder",e,t,Hfe)},HV={...y3,traceOnly:C.Boolean(!1,{isHidden:!0}),...m3,...g3,includeParent:C.Boolean(!1),unitKinds:oC(["atomic"]),sizeFactor:C.Numeric(.15,{min:.01,max:10,step:.01}),sizeAspectRatio:C.Numeric(2/3,{min:.01,max:3,step:.01}),visuals:C.MultiSelect(["element-sphere","intra-bond","inter-bond"],C.objectToOptions(Yfe)),bumpFrequency:C.Numeric(0,{min:0,max:10,step:.1},rt.ShadingCategory)},opt={name:"ball-and-stick",label:"Ball & Stick",description:"Displays atoms as spheres and bonds as cylinders.",factory:function ipt(e,t){return yn.createMulti("Ball & Stick",e,t,ms,Yfe)},getParams:function rpt(e,t){if(Ve.getSize(t)>=Ve.Size.Huge){const r=C.clone(HV);return r.visuals.defaultValue=["element-sphere","intra-bond"],r}return HV},defaultValues:C.getDefaultValues(HV),defaultColorTheme:{name:"element-symbol"},defaultSizeTheme:{name:"physical"},isApplicable:e=>e.elementCount>0,getData:(e,t)=>t.includeParent?e.asParent():e,mustRecreate:(e,t)=>e.includeParent!==t.includeParent};function spt(e,t,n,r,i){const{links:o,elements:s}=t.carbohydrates,{linkSizeFactor:a}=r,c=nt.create(t),u={linkCount:o.length,position:(f,p,m)=>{const h=o[m];v.copy(f,s[h.carbohydrateIndexA].geometry.center),v.copy(p,s[h.carbohydrateIndexB].geometry.center)},radius:f=>{const m=s[o[f].carbohydrateIndexA],h=m.unit.rings.all[m.ringIndex];return c.unit=m.unit,c.element=m.unit.elements[h[0]],n.size.size(c)*a}},{mesh:l,boundingSphere:d}=B0(0,u,r,i);if(d)l.setBoundingSphere(d);else if(l.triangleCount>0){const f=_e.expand(_e(),t.boundary.sphere,1*a);l.setBoundingSphere(f)}return l}const Xfe={...hs,...F0,linkSizeFactor:C.Numeric(.3,{min:0,max:3,step:.01})};function apt(e){return rh({defaultProps:C.getDefaultValues(Xfe),createGeometry:spt,createLocationIterator:cpt,getLoci:upt,eachLocation:lpt,setUpdateState:(t,n,r)=>{t.createGeometry=n.linkSizeFactor!==r.linkSizeFactor||n.radialSegments!==r.radialSegments||n.linkCap!==r.linkCap}},e)}function cpt(e){const{elements:t,links:n}=e.carbohydrates,r=n.length,o=nt.create(e);return Mr(r,1,1,a=>{const u=t[n[a].carbohydrateIndexA],l=u.unit.rings.all[u.ringIndex];return o.unit=u.unit,o.element=u.unit.elements[l[0]],o},!0)}function upt(e,t,n){const{objectId:r,groupId:i}=e;if(n===r){const{links:o,elements:s}=t.carbohydrates,a=o[i],c=s[a.carbohydrateIndexA],u=s[a.carbohydrateIndexB];return De.union(iC(t,c.unit,c.residueIndex,c.altId),iC(t,u.unit,u.residueIndex,u.altId))}return $n}const qV=new Set;function lpt(e,t,n){let r=!1;if(!De.is(e)||!Ve.areEquivalent(e.structure,t))return!1;const{getLinkIndices:i}=t.carbohydrates;for(const{unit:o,indices:s}of e.elements)Ee.isAtomic(o)&&(qV.clear(),Fe.forEach(s,a=>{const c=i(o,o.elements[a]);for(let u=0,l=c.length;u{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail}},e)}function kpt(e){const t=e.carbohydrates.elements,n=2*t.length,i=nt.create(e);return Mr(n,1,1,function o(a,c){const u=t[Math.floor(a/2)],l=u.unit.rings.all[u.ringIndex];return i.unit=u.unit,i.element=u.unit.elements[l[0]],i},!0,function s(a,c){return a%2==1})}function Npt(e,t,n){const{objectId:r,groupId:i}=e;if(n===r){const o=t.carbohydrates.elements[Math.floor(i/2)];return iC(t,o.unit,o.residueIndex,o.altId)}return $n}const rz=new Set;function Fpt(e,t,n){const{getElementIndices:r}=t.carbohydrates;let i=!1;if(!De.is(e)||!Ve.areEquivalent(e.structure,t))return!1;for(const{unit:o,indices:s}of e.elements)Ee.isAtomic(o)&&(rz.clear(),Fe.forEach(s,a=>{const c=r(o,o.elements[a]);for(let u=0,l=c.length;u{const h=o[m];h.fromCarbohydrate?(v.copy(f,s[h.carbohydrateIndex].geometry.center),h.elementUnit.conformation.position(h.elementUnit.elements[h.elementIndex],p)):(h.elementUnit.conformation.position(h.elementUnit.elements[h.elementIndex],f),v.copy(p,s[h.carbohydrateIndex].geometry.center))},radius:f=>{const p=o[f];if(p.fromCarbohydrate){const m=s[p.carbohydrateIndex],h=m.unit.rings.all[m.ringIndex];c.unit=m.unit,c.element=m.unit.elements[h[0]]}else c.unit=p.elementUnit,c.element=p.elementUnit.elements[p.elementIndex];return n.size.size(c)*a},style:f=>{const p=o[f],h=Qd(p.elementUnit.model.atomicHierarchy.atoms.type_symbol.value(p.elementUnit.elements[p.elementIndex]));return d2.has(h)?1:0}},{mesh:l,boundingSphere:d}=B0(0,u,r,i);if(d)l.setBoundingSphere(d);else if(l.triangleCount>0){const f=_e.expand(_e(),t.boundary.sphere,1*a);l.setBoundingSphere(f)}return l}const ope={...hs,...F0,terminalLinkSizeFactor:C.Numeric(.2,{min:0,max:3,step:.01})};function Opt(e){return rh({defaultProps:C.getDefaultValues(ope),createGeometry:Bpt,createLocationIterator:Lpt,getLoci:Upt,eachLocation:Vpt,setUpdateState:(t,n,r)=>{t.createGeometry=n.terminalLinkSizeFactor!==r.terminalLinkSizeFactor||n.radialSegments!==r.radialSegments||n.linkCap!==r.linkCap}},e)}function Lpt(e){const{elements:t,terminalLinks:n}=e.carbohydrates,r=n.length,o=nt.create(e);return Mr(r,1,1,a=>{const c=n[a];if(c.fromCarbohydrate){const u=t[c.carbohydrateIndex],l=u.unit.rings.all[u.ringIndex];o.unit=u.unit,o.element=u.unit.elements[l[0]]}else o.unit=c.elementUnit,o.element=c.elementUnit.elements[c.elementIndex];return o},!0)}function Upt(e,t,n){const{objectId:r,groupId:i}=e;if(n===r){const{terminalLinks:o,elements:s}=t.carbohydrates,a=o[i],c=s[a.carbohydrateIndex];return De.union(iC(t,c.unit,c.residueIndex,c.altId),function xat(e,t,n){const{elements:r,model:i}=t,{label_alt_id:o}=i.atomicHierarchy.atoms,s=o.value(n);if(-1!==Fe.indexOf(r,n)){const{index:a}=i.atomicHierarchy.residueAtomSegments;return iC(e,t,a[n],s)}return De(e,[])}(t,a.elementUnit,a.elementUnit.elements[a.elementIndex]))}return $n}const iz=new Set;function Vpt(e,t,n){let r=!1;if(!De.is(e)||!Ve.areEquivalent(e.structure,t))return!1;const{getTerminalLinkIndices:i}=t.carbohydrates;for(const{unit:o,indices:s}of e.elements)Ee.isAtomic(o)&&(iz.clear(),Fe.forEach(s,a=>{const c=i(o,o.elements[a]);for(let u=0,l=c.length;uIu("Carbohydrate symbol mesh",e,t,Rpt),"carbohydrate-link":(e,t)=>Iu("Carbohydrate link cylinder",e,t,apt),"carbohydrate-terminal-link":(e,t)=>Iu("Carbohydrate terminal link cylinder",e,t,Opt)},ape={...ipe,...Xfe,...ope,visuals:C.MultiSelect(["carbohydrate-symbol","carbohydrate-link","carbohydrate-terminal-link"],C.objectToOptions(spe)),bumpFrequency:C.Numeric(0,{min:0,max:10,step:.1},rt.ShadingCategory)},jpt={name:"carbohydrate",label:"Carbohydrate",description:"Displays carbohydrate symbols (3D SNFG).",factory:function Gpt(e,t){return yn.createMulti("Carbohydrate",e,t,ms,spe)},getParams:function zpt(e,t){return ape},defaultValues:C.getDefaultValues(ape),defaultColorTheme:{name:"carbohydrate-symbol"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.models.some(t=>sn.hasCarbohydrate(t))};function cpe(e,t){switch(e.kind){case 0:return function Hpt(e,t){const n=e.model.atomicRanges.cyclicPolymerMap,r=wr.transientSegments(AC(e),e.elements),i=en.transientSegments(e.model.atomicHierarchy.residueAtomSegments,e.elements),o=e.model.atomicHierarchy.derived.residue.traceElementIndex,{moleculeType:s}=e.model.atomicHierarchy.derived.residue;let a=-1,c=-1,u=!0,l=-1,d=0;for(;r.hasNext;){for(u=!0,l=d,i.setSegment(r.move());i.hasNext;){if(u){const p=i.move().index;if(++d,!i.hasNext)continue;u=!1,c=p}a=c,c=i.move().index,t(o[a],o[c],d-1,d,s[a]),++d}n.has(c)&&(a=c,c=n.get(a),t(o[a],o[c],d-1,l,s[a]))}}(e,t);case 1:case 2:return function qpt(e,t){const n=wr.transientSegments(AC(e),e.elements),{elements:r}=e;let i=!0,o=0;for(;n.hasNext;){i=!0;const s=n.move();for(let u=s.start,l=s.end;ul)continue;i=!1}t(r[u-1],r[u],o-1,o,0),++o}}}(e,t)}}function upe(e,t){switch(e.kind){case 0:return function Wpt(e,t){const n=wr.transientSegments(AC(e),e.elements),r=en.transientSegments(e.model.atomicHierarchy.residueAtomSegments,e.elements),i=e.model.atomicHierarchy.derived.residue.traceElementIndex;let o=0;for(;n.hasNext;)for(r.setSegment(n.move());r.hasNext;)t(i[r.move().index],o),++o}(e,t);case 1:case 2:return function $pt(e,t){const n=wr.transientSegments(AC(e),e.elements),{elements:r}=e;let i=0;for(;n.hasNext;){const o=n.move();for(let c=o.start,u=o.end;c({}),isApplicable:e=>!0,obtain:function(){var e=ie(function*(t,n){return{value:Zpt(n)}});return function(n,r){return e.apply(this,arguments)}}()});function Cd(e){return cr.is(e,2)}function sz(e,t,n={}){switch(e.kind){case 0:return new Jpt(e,t,n);case 1:case 2:return new eht(e,t)}}const _3=cr.create(536870912);function dpe(e,t){return{center:nt.create(e,t),centerPrev:nt.create(e,t),centerNext:nt.create(e,t),first:!1,last:!1,initial:!1,final:!1,secStrucFirst:!1,secStrucLast:!1,secStrucType:_3,moleculeType:0,coarseBackboneFirst:!1,coarseBackboneLast:!1,isCoarseBackbone:!1,p0:v(),p1:v(),p2:v(),p3:v(),p4:v(),d12:v(),d23:v()}}const on=v(),x3=v(),S3=v();class Jpt{atomicPos(t,n){-1!==n&&(t[0]=this.atomicConformation.x[n],t[1]=this.atomicConformation.y[n],t[2]=this.atomicConformation.z[n])}pos(t,n,r){const i=this.traceElementIndex[n];this.helixOrientationCenters&&Cd(r)?v.fromArray(t,this.helixOrientationCenters,3*n):this.atomicPos(t,i)}updateResidueSegmentRange(t){const{index:n}=this.residueAtomSegments;this.residueSegmentMin=n[this.polymerRanges[2*t.index]],this.residueSegmentMax=n[this.polymerRanges[2*t.index+1]]}getResidueIndex(t){if(tthis.residueSegmentMax){const n=this.cyclicPolymerMap.get(this.residueSegmentMax);t=void 0!==n?n+(t-this.residueSegmentMax-1):this.residueSegmentMax}return t}getSecStruc(t){if(this.secondaryStructure){const{type:n,getIndex:r}=this.secondaryStructure,i=n[r(t)];return Cd(i)?2:i}return _3}setControlPoint(t,n,r,i,o){(function Qpt(e){return cr.is(e,4)})(o)||this.helixOrientationCenters&&Cd(o)?v.scale(t,v.add(t,n,v.add(t,i,v.add(t,r,r))),1/4):v.copy(t,r)}setFromToVector(t,n,r){this.value.isCoarseBackbone||this.helixOrientationCenters&&Cd(r)?v.set(t,1,0,0):(this.atomicPos(x3,this.directionFromElementIndex[n]),this.atomicPos(S3,this.directionToElementIndex[n]),v.sub(t,S3,x3))}setDirection(t,n,r,i){v.matchDirection(x3,n,r),v.matchDirection(S3,i,r),v.scale(t,v.add(t,x3,v.add(t,S3,v.add(t,r,r))),1/4)}move(){const{residueIt:t,polymerIt:n,value:r}=this;if(0===this.state)for(;n.hasNext;)if(this.polymerSegment=n.move(),t.setSegment(this.polymerSegment),this.updateResidueSegmentRange(this.polymerSegment),t.hasNext){this.state=1;const i=this.residueAtomSegments.index[this.unit.elements[this.polymerSegment.start]],o=this.getResidueIndex(i-1);this.currSecStrucType=i===o?_3:this.getSecStruc(o),this.nextSecStrucType=this.getSecStruc(i),this.currCoarseBackbone=-1===this.directionFromElementIndex[o]||-1===this.directionToElementIndex[o],this.nextCoarseBackbone=-1===this.directionFromElementIndex[i]||-1===this.directionToElementIndex[i];break}if(1===this.state){const{index:i}=t.move(),o=this.getResidueIndex(i-3),s=this.getResidueIndex(i-2),a=this.getResidueIndex(i-1),c=this.getResidueIndex(i+1),u=this.getResidueIndex(i+2),l=this.getResidueIndex(i+3);this.prevSecStrucType=this.getSecStruc(a),this.currSecStrucType=this.getSecStruc(i),this.nextSecStrucType=i===c?_3:this.getSecStruc(c),this.prevCoarseBackbone=this.currCoarseBackbone,this.currCoarseBackbone=this.nextCoarseBackbone,this.nextCoarseBackbone=-1===this.directionFromElementIndex[c]||-1===this.directionToElementIndex[c],r.secStrucType=this.currSecStrucType,r.secStrucFirst=this.prevSecStrucType!==this.currSecStrucType,r.secStrucLast=this.currSecStrucType!==this.nextSecStrucType,r.isCoarseBackbone=this.currCoarseBackbone,r.coarseBackboneFirst=this.prevCoarseBackbone!==this.currCoarseBackbone,r.coarseBackboneLast=this.currCoarseBackbone!==this.nextCoarseBackbone,r.first=i===this.residueSegmentMin,r.last=i===this.residueSegmentMax,r.moleculeType=this.moleculeType[i],r.initial=i===a,r.final=i===c,r.centerPrev.element=this.traceElementIndex[a],r.center.element=this.traceElementIndex[i],r.centerNext.element=this.traceElementIndex[c];const d=this.getSecStruc(o),f=this.getSecStruc(s),p=this.getSecStruc(a),m=this.getSecStruc(i),h=this.getSecStruc(c),g=this.getSecStruc(u),y=this.getSecStruc(l);this.pos(this.p0,o,d),this.pos(this.p1,s,f),this.pos(this.p2,a,p),this.pos(this.p3,i,m),this.pos(this.p4,c,h),this.pos(this.p5,u,g),this.pos(this.p6,l,y);const b=Cd(d),x=Cd(f),_=Cd(p),S=Cd(m),A=Cd(h),E=Cd(g),w=Cd(y);this.helixOrientationCenters&&(S!==_?S?(v.copy(this.p0,this.p3),v.copy(this.p1,this.p3),v.copy(this.p2,this.p3)):_&&(v.scale(on,v.sub(on,this.p2,this.p3),2),v.add(this.p2,this.p3,on),v.add(this.p1,this.p2,on),v.add(this.p0,this.p1,on)):S!==x?S?(v.copy(this.p0,this.p2),v.copy(this.p1,this.p2)):x&&(v.scale(on,v.sub(on,this.p1,this.p2),2),v.add(this.p1,this.p2,on),v.add(this.p0,this.p1,on)):S!==b&&(S?v.copy(this.p0,this.p1):b&&(v.scale(on,v.sub(on,this.p0,this.p1),2),v.add(this.p0,this.p1,on))),S!==A?S?(v.copy(this.p4,this.p3),v.copy(this.p5,this.p3),v.copy(this.p6,this.p3)):A&&(v.scale(on,v.sub(on,this.p4,this.p3),2),v.add(this.p4,this.p3,on),v.add(this.p5,this.p4,on),v.add(this.p6,this.p5,on)):S!==E?S?(v.copy(this.p5,this.p4),v.copy(this.p6,this.p4)):E&&(v.scale(on,v.sub(on,this.p5,this.p4),2),v.add(this.p5,this.p4,on),v.add(this.p6,this.p5,on)):S!==w&&(S?v.copy(this.p6,this.p5):w&&(v.scale(on,v.sub(on,this.p6,this.p5),2),v.add(this.p6,this.p5,on)))),this.setFromToVector(this.d01,a,p),this.setFromToVector(this.d12,i,m),this.setFromToVector(this.d23,c,h),this.setFromToVector(this.d34,u,g);const D=S&&this.helixOrientationCenters,I=1.5;i===a||m!==p&&D?(v.setMagnitude(on,v.sub(on,this.p3,this.p4),I),v.add(this.p2,this.p3,on),v.add(this.p1,this.p2,on),v.add(this.p0,this.p1,on)):a===s||m!==f&&D?(v.setMagnitude(on,v.sub(on,this.p2,this.p3),I),v.add(this.p1,this.p2,on),v.add(this.p0,this.p1,on)):(s===o||m!==d&&D)&&(v.setMagnitude(on,v.sub(on,this.p1,this.p2),I),v.add(this.p0,this.p1,on)),i===c||m!==h&&D?(v.setMagnitude(on,v.sub(on,this.p3,this.p2),I),v.add(this.p4,this.p3,on),v.add(this.p5,this.p4,on),v.add(this.p6,this.p5,on)):c===u||m!==g&&D?(v.setMagnitude(on,v.sub(on,this.p4,this.p3),I),v.add(this.p5,this.p4,on),v.add(this.p6,this.p5,on)):(u===l||m!==y&&D)&&(v.setMagnitude(on,v.sub(on,this.p5,this.p4),I),v.add(this.p6,this.p5,on)),this.setControlPoint(r.p0,this.p0,this.p1,this.p2,f),this.setControlPoint(r.p1,this.p1,this.p2,this.p3,p),this.setControlPoint(r.p2,this.p2,this.p3,this.p4,m),this.setControlPoint(r.p3,this.p3,this.p4,this.p5,h),this.setControlPoint(r.p4,this.p4,this.p5,this.p6,g),this.setDirection(r.d12,this.d01,this.d12,this.d23),this.setDirection(r.d23,this.d12,this.d23,this.d34),t.hasNext||(this.state=0)}return this.hasNext=t.hasNext||n.hasNext,this.value}constructor(t,n,r={}){var i;if(this.unit=t,this.state=0,this.p0=v(),this.p1=v(),this.p2=v(),this.p3=v(),this.p4=v(),this.p5=v(),this.p6=v(),this.d01=v(),this.d12=v(),this.d23=v(),this.d34=v(),this.hasNext=!1,this.atomicConformation=t.model.atomicConformation,this.residueAtomSegments=t.model.atomicHierarchy.residueAtomSegments,this.polymerRanges=t.model.atomicRanges.polymerRanges,this.traceElementIndex=t.model.atomicHierarchy.derived.residue.traceElementIndex,this.directionFromElementIndex=t.model.atomicHierarchy.derived.residue.directionFromElementIndex,this.directionToElementIndex=t.model.atomicHierarchy.derived.residue.directionToElementIndex,this.moleculeType=t.model.atomicHierarchy.derived.residue.moleculeType,this.cyclicPolymerMap=t.model.atomicRanges.cyclicPolymerMap,this.polymerIt=wr.transientSegments(this.polymerRanges,t.elements),this.residueIt=en.transientSegments(this.residueAtomSegments,t.elements),this.value=dpe(n,t),this.hasNext=this.residueIt.hasNext&&this.polymerIt.hasNext,r.ignoreSecondaryStructure||(this.secondaryStructure=null===(i=Xu.get(n).value)||void 0===i?void 0:i.get(t.invariantId)),r.useHelixOrientation){const o=oz.get(t.model).value;if(!o)throw new Error("missing helix-orientation");this.helixOrientationCenters=o.centers}}}class eht{getElementIndex(t){return Math.min(Math.max(this.polymerSegment.start,t),this.polymerSegment.end-1)}pos(t,n){const r=this.unit.elements[n];t[0]=this.conformation.x[r],t[1]=this.conformation.y[r],t[2]=this.conformation.z[r]}move(){if(0===this.state)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)){a=u;break}}if(s<0)return!1;let c=s;for(let u=o;u>a;u--){const l=n[u];if(l<0)continue;const d=Fe.indexOf(t,l);if(d>=0){c=d;break}}return r(Ce.ofRange(e+s,e+c))}function xpe(e,t,n,r,i){let o=!1;const{elements:s}=i.unit,{traceElementIndex:a}=i.unit.model.atomicHierarchy.derived.residue,{index:c}=i.unit.model.atomicHierarchy.residueAtomSegments,u=n(i.unit);if(Ce.is(i.indices))o=0===Ce.start(i.indices)&&Ce.end(i.indices)===i.unit.elements.length?r(Ce.ofBounds(e,e+t))||o:_pe(e,u,a,r,c[s[Ce.min(i.indices)]],c[s[Ce.max(i.indices)]])||o;else{const{indices:l}=i;for(let d=0,f=l.length;d1)break;m=g,h++}d=h-1,o=_pe(e,u,a,r,p,m)||o}}return o}function uht(e){return e.polymerElements}function X0(e,t,n){let r=!1;if(!De.is(e))return!1;const{structure:i,group:o}=t;if(!Ve.areEquivalent(e.structure,i))return!1;const s=o.units[0].polymerElements.length;for(const a of e.elements){if(!o.unitIndexMap.has(a.unit.id))continue;const c=o.unitIndexMap.get(a.unit.id)*s;if(Ee.isAtomic(a.unit))r=xpe(c,s,uht,n,a)||r;else if(Ce.is(a.indices)){const u=c+Ce.start(a.indices),l=c+Ce.end(a.indices);r=n(Ce.ofBounds(u,l))||r}else for(let u=0,l=a.indices.length;u{const l=Fe.indexOf(a.unit.gapElements,a.unit.elements[u]);-1!==l&&n(Ce.ofSingleton(c*s+l))&&(r=!0)})}}return r}function K0(e,t,n){const{objectId:r,instanceId:i,groupId:o}=e;if(n===r){const{structure:s,group:a}=t,c=a.units[i];if(Ee.isAtomic(c))return Lle(s,c,c.nucleotideElements[o])}return $n}function fht(e){return e.nucleotideElements}function Z0(e,t,n){let r=!1;if(!De.is(e))return!1;const{structure:i,group:o}=t;if(!Ve.areEquivalent(e.structure,i))return!1;const s=o.units[0];if(!Ee.isAtomic(s))return!1;const{nucleotideElements:a}=s,c=a.length;for(const u of e.elements){if(!Ee.isAtomic(u.unit)||!o.unitIndexMap.has(u.unit.id))continue;const l=o.unitIndexMap.get(u.unit.id)*c;Ee.isAtomic(u.unit)&&(r=xpe(l,c,fht,n,u)||r)}return r}!function(e){e.fromGroup=function t(n,r){const{group:i,structure:o}=n,s=i.units[0].polymerElements,a=s.length,c=i.units.length,u=nt.create(o),d=!!r?.asSecondary;return Mr(a,c,1,(p,m)=>(u.unit=i.units[m],u.element=s[p],u),!1,function f(p,m){return d})}}(lh||(lh={})),function(e){e.fromGroup=function t(n){const{group:r,structure:i}=n,o=r.units[0].gapElements,s=o.length,a=r.units.length,c=nt.create(i);return Mr(s,a,1,(l,d)=>(c.unit=r.units[d],c.element=o[l],c))}}(gz||(gz={})),function(e){e.fromGroup=function t(n){const{group:r,structure:i}=n,o=r.units[0],s=Ee.isAtomic(o)?o.nucleotideElements:[],a=s.length,c=r.units.length,u=nt.create(i);return Mr(a,c,1,(d,f)=>(u.unit=r.units[f],u.element=s[d],u))}}(dh||(dh={}));const pht=v(),hht=v();function Q0(e,t){const{model:n,conformation:r}=e,{residueAtomSegments:i,atoms:o,index:s}=n.atomicHierarchy,{label_comp_id:a}=o,c=a.value(i.offsets[t]);let u=rFe(c),l=iFe(c);if(!u&&!l){const d=s.findAtomOnResidue(t,"C4"),f=s.findAtomOnResidue(t,"N9");-1!==d&&-1!==f&&v.distance(r.invariantPosition(d,pht),r.invariantPosition(f,hht))<1.6?u=!0:l=!0}return{isPurine:u,isPyrimidine:l}}function ey(e,t,n){const r=t.model.atomicHierarchy.index,{traceElementIndex:i}=t.model.atomicHierarchy.derived.residue;return e.trace=i[n],e.N1=r.findAtomOnResidue(n,"N1"),e.C2=r.findAtomOnResidue(n,"C2"),e.N3=r.findAtomOnResidue(n,"N3"),e.C4=r.findAtomOnResidue(n,"C4"),e.C5=r.findAtomOnResidue(n,"C5"),-1===e.C5&&(e.C5=r.findAtomOnResidue(n,"N5")),e.C6=r.findAtomOnResidue(n,"C6"),e.N7=r.findAtomOnResidue(n,"N7"),-1===e.N7&&(e.N7=r.findAtomOnResidue(n,"C7")),e.C8=r.findAtomOnResidue(n,"C8"),e.N9=r.findAtomOnResidue(n,"N9"),e}function y1(e){return-1!==e.trace&&-1!==e.N1&&-1!==e.C2&&-1!==e.N3&&-1!==e.C4&&-1!==e.C5&&-1!==e.C6&&-1!==e.N7&&-1!==e.C8&&-1!==e.N9}function ty(e,t,n){const r=t.model.atomicHierarchy.index,{traceElementIndex:i}=t.model.atomicHierarchy.derived.residue;return e.trace=i[n],e.N1=r.findAtomOnResidue(n,"N1"),-1===e.N1&&(e.N1=r.findAtomOnResidue(n,"C1")),e.C2=r.findAtomOnResidue(n,"C2"),e.N3=r.findAtomOnResidue(n,"N3"),e.C4=r.findAtomOnResidue(n,"C4"),e.C5=r.findAtomOnResidue(n,"C5"),e.C6=r.findAtomOnResidue(n,"C6"),e}function b1(e){return-1!==e.trace&&-1!==e.N1&&-1!==e.C2&&-1!==e.N3&&-1!==e.C4&&-1!==e.C5&&-1!==e.C6}function IC(e,t,n){const r=t.model.atomicHierarchy.index,{traceElementIndex:i}=t.model.atomicHierarchy.derived.residue;return e.trace=i[n],e.C1_1=r.findAtomOnResidue(n,"C1'"),e.C2_1=r.findAtomOnResidue(n,"C2'"),e.C3_1=r.findAtomOnResidue(n,"C3'"),e.C4_1=r.findAtomOnResidue(n,"C4'"),e.O4_1=r.findAtomOnResidue(n,"O4'"),e}function TC(e){return-1!==e.trace&&-1!==e.C1_1&&-1!==e.C2_1&&-1!==e.C3_1&&-1!==e.C4_1&&-1!==e.O4_1}const T3=v(),yz=v(),Spe=v(),Cpe=v(),wpe=v(),Ape=v(),D3=v(),bz=v(),vz=v(),Ipe=v(),DC=le.identity(),mht=v(),Tpe=x5(),Dpe={sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),thicknessFactor:C.Numeric(1,{min:0,max:2,step:.01}),radialSegments:C.Numeric(16,{min:2,max:56,step:2},rt.CustomQualityParamInfo)};function ght(e,t,n,r,i,o){if(!Ee.isAtomic(t))return Nt.createEmpty(o);const s=t.nucleotideElements.length;if(!s)return Nt.createEmpty(o);const{sizeFactor:a,thicknessFactor:c,radialSegments:u}=i,l=s*(Tpe.vertices.length/3+2*u),d=at.createState(l,l/4,o),{elements:f,model:p,conformation:m}=t,{chainAtomSegments:h,residueAtomSegments:g}=p.atomicHierarchy,{moleculeType:y}=p.atomicHierarchy.derived.residue,b=en.transientSegments(h,f),x=en.transientSegments(g,f),_=1*a,A=c*a*2,E={radiusTop:_,radiusBottom:_,radialSegments:u,bottomCap:!0};let w=0;for(;b.hasNext;)for(x.setSegment(b.move());x.hasNext;){const{index:R}=x.move();if(Ya(y[R])){const T={trace:-1,N1:-1,C2:-1,N3:-1,C4:-1,C5:-1,C6:-1,N7:-1,C8:-1,N9:-1,C1_1:-1,C2_1:-1,C3_1:-1,C4_1:-1,O4_1:-1};let M=-1,N=-1,V=-1,F=-1,G=-1,L=4.5;const{isPurine:z,isPyrimidine:j}=Q0(t,R);z?(L=4.5,ey(T,t,R),M=T.N1,N=T.C4,V=T.C6,F=T.C2,G=T.N9):j&&(L=3,ty(T,t,R),M=T.N3,N=T.C6,V=T.C4,F=T.C2,G=T.N1),-1!==G&&-1!==T.trace&&(m.invariantPosition(G,wpe),m.invariantPosition(T.trace,Ape),d.currentGroup=w,Hn(d,wpe,Ape,1,E),-1!==M&&-1!==N&&-1!==V&&-1!==F&&(m.invariantPosition(M,T3),m.invariantPosition(N,yz),m.invariantPosition(V,Spe),m.invariantPosition(F,Cpe),v.normalize(D3,v.sub(D3,yz,T3)),v.normalize(bz,v.sub(bz,Cpe,Spe)),v.normalize(vz,v.cross(vz,D3,bz)),le.targetTo(DC,T3,yz,vz),v.scaleAndAdd(Ipe,T3,D3,L/2-.2),le.scale(DC,DC,v.set(mht,4.5,A,L)),le.setTranslation(DC,Ipe),at.addPrimitive(d,DC,Tpe))),++w}}const D=at.getMesh(d),I=_e.expand(_e(),t.boundary.sphere,_);return D.setBoundingSphere(I),D}C.getDefaultValues(Dpe);const Epe={...hs,...Dpe};function yht(e){return Hs({defaultProps:C.getDefaultValues(Epe),createGeometry:ght,createLocationIterator:dh.fromGroup,getLoci:K0,eachLocation:Z0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.thicknessFactor!==r.thicknessFactor||n.radialSegments!==r.radialSegments}},e)}const E3=v(),jm=v(),P3=v(),M3=v(),v1=v(),_1=v(),R3=v(),Ppe=v(),Mpe=v(),k3=v(),Hm=v(),Rpe={sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),thicknessFactor:C.Numeric(1,{min:0,max:2,step:.01}),radialSegments:C.Numeric(16,{min:2,max:56,step:2},rt.CustomQualityParamInfo),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo)},N3=(C.getDefaultValues(Rpe),new Float32Array(54)),bht=new Uint32Array([0,1,2,3,4,5,6,7,16,17,14,15,12,13,8,9,10,11,0,1]),vht=new Uint32Array([8,12,14,16,6,4,2,0,10]),_ht=new Uint32Array([9,11,1,3,5,7,17,15,13]),F3=new Float32Array(36),xht=new Uint32Array([0,1,2,3,4,5,6,7,8,9,10,11,0,1]),Sht=new Uint32Array([0,10,8,6,4,2]),Cht=new Uint32Array([1,3,5,7,9,11]),kpe=v();function Npe(e,t,...n){for(let r=0,i=n.length;r{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.thicknessFactor!==r.thicknessFactor||n.radialSegments!==r.radialSegments}},e)}const x1=v(),B3=v(),O3=v(),S1=v(),C1=v(),L3=v(),Bpe=v(),Ope=v(),Lpe=v(),U3=v(),_z=v(),V3=v(),z3=v(),xz=v(),w1=v(),Ws=v(),A1=v(),Upe={sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),thicknessFactor:C.Numeric(1,{min:0,max:2,step:.01})},G3=(C.getDefaultValues(Upe),new Float32Array(54)),Iht=new Uint32Array([0,1,2,3,4,5,6,7,16,17,14,15,12,13,8,9,10,11,0,1]),Tht=new Uint32Array([8,12,14,16,6,4,2,0,10]),Dht=new Uint32Array([9,11,1,3,5,7,17,15,13]),j3=new Float32Array(36),Eht=new Uint32Array([2,3,4,5,6,7,8,9,10,11,2,3]),Pht=new Uint32Array([0,10,8,6,4,2,10]),Mht=new Uint32Array([1,3,5,7,9,11,3]),H3=new Float32Array(36),Rht=new Uint32Array([0,1,2,3,4,5,6,7,8,9,10,11,0,1]),kht=new Uint32Array([0,10,8,6,4,2]),Nht=new Uint32Array([1,3,5,7,9,11]),Vpe=v();function Sz(e,t,...n){for(let r=0,i=n.length;r{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.thicknessFactor!==r.thicknessFactor}},e)}const $s=v(),Kr=v(),ys=v(),bs=v(),fo=v(),po=v(),vs=v(),kf=v(),Nf=v(),Uo=v(),Vo=v(),Ff=v(),Gc=v(),Bf=v(),Of=v(),Cz={...hs,...wU,sizeFactor:C.Numeric(.3,{min:0,max:10,step:.01}),radialSegments:C.Numeric(16,{min:2,max:56,step:2},rt.CustomQualityParamInfo),tryUseImpostor:C.Boolean(!0)};function Oht(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth?function Uht(e){return AU({defaultProps:C.getDefaultValues(Cz),createGeometry:Lht,createLocationIterator:dh.fromGroup,getLoci:K0,eachLocation:Z0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function zht(e){return Hs({defaultProps:C.getDefaultValues(Cz),createGeometry:Vht,createLocationIterator:dh.fromGroup,getLoci:K0,eachLocation:Z0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.radialSegments!==r.radialSegments},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}function Lht(e,t,n,r,i,o){if(!Ee.isAtomic(t))return oc.createEmpty(o);const s=t.nucleotideElements.length;if(!s)return oc.createEmpty(o);const a=15*s,c=aC.create(a,a/4,o),{elements:u,model:l,conformation:d}=t,{chainAtomSegments:f,residueAtomSegments:p}=l.atomicHierarchy,{moleculeType:m}=l.atomicHierarchy.derived.residue,h=en.transientSegments(f,u),g=en.transientSegments(p,u);let y=0;for(;h.hasNext;)for(g.setSegment(h.move());g.hasNext;){const{index:S}=g.move();if(Ya(m[S])){const A={trace:-1,N1:-1,C2:-1,N3:-1,C4:-1,C5:-1,C6:-1,N7:-1,C8:-1,N9:-1,C1_1:-1,C2_1:-1,C3_1:-1,C4_1:-1,O4_1:-1};IC(A,t,S),TC(A)&&(d.invariantPosition(A.C1_1,Vo),d.invariantPosition(A.C2_1,Ff),d.invariantPosition(A.C3_1,Gc),d.invariantPosition(A.C4_1,Bf),d.invariantPosition(A.O4_1,Of),d.invariantPosition(A.trace,$s),c.add(Gc[0],Gc[1],Gc[2],$s[0],$s[1],$s[2],1,!0,!0,2,y),c.add(Gc[0],Gc[1],Gc[2],Bf[0],Bf[1],Bf[2],1,!0,!0,2,y),c.add(Bf[0],Bf[1],Bf[2],Of[0],Of[1],Of[2],1,!0,!0,2,y),c.add(Of[0],Of[1],Of[2],Vo[0],Vo[1],Vo[2],1,!0,!0,2,y),c.add(Vo[0],Vo[1],Vo[2],Ff[0],Ff[1],Ff[2],1,!0,!0,2,y),c.add(Ff[0],Ff[1],Ff[2],Gc[0],Gc[1],Gc[2],1,!0,!0,2,y));const{isPurine:E,isPyrimidine:w}=Q0(t,S);E?(ey(A,t,S),-1!==A.C1_1&&-1!==A.N9?(d.invariantPosition(A.C1_1,Vo),d.invariantPosition(A.N9,Uo),c.add(Uo[0],Uo[1],Uo[2],Vo[0],Vo[1],Vo[2],1,!0,!0,2,y)):-1!==A.N9&&-1!==A.trace&&(d.invariantPosition(A.N9,Uo),d.invariantPosition(A.trace,$s),c.add(Uo[0],Uo[1],Uo[2],$s[0],$s[1],$s[2],1,!0,!0,2,y)),y1(A)&&(d.invariantPosition(A.N1,Kr),d.invariantPosition(A.C2,ys),d.invariantPosition(A.N3,bs),d.invariantPosition(A.C4,fo),d.invariantPosition(A.C5,po),d.invariantPosition(A.C6,vs),d.invariantPosition(A.N7,kf),d.invariantPosition(A.C8,Nf),d.invariantPosition(A.N9,Uo),c.add(Uo[0],Uo[1],Uo[2],Nf[0],Nf[1],Nf[2],1,!0,!0,2,y),c.add(Nf[0],Nf[1],Nf[2],kf[0],kf[1],kf[2],1,!0,!0,2,y),c.add(kf[0],kf[1],kf[2],po[0],po[1],po[2],1,!0,!0,2,y),c.add(po[0],po[1],po[2],vs[0],vs[1],vs[2],1,!0,!0,2,y),c.add(vs[0],vs[1],vs[2],Kr[0],Kr[1],Kr[2],1,!0,!0,2,y),c.add(Kr[0],Kr[1],Kr[2],ys[0],ys[1],ys[2],1,!0,!0,2,y),c.add(ys[0],ys[1],ys[2],bs[0],bs[1],bs[2],1,!0,!0,2,y),c.add(bs[0],bs[1],bs[2],fo[0],fo[1],fo[2],1,!0,!0,2,y),c.add(fo[0],fo[1],fo[2],po[0],po[1],po[2],1,!0,!0,2,y),c.add(fo[0],fo[1],fo[2],Uo[0],Uo[1],Uo[2],1,!0,!0,2,y))):w&&(ty(A,t,S),-1!==A.C1_1&&-1!==A.N1?(d.invariantPosition(A.N1,Kr),d.invariantPosition(A.C1_1,Vo),c.add(Kr[0],Kr[1],Kr[2],Vo[0],Vo[1],Vo[2],1,!0,!0,2,y)):-1!==A.N1&&-1!==A.trace&&(d.invariantPosition(A.N1,Kr),d.invariantPosition(A.trace,$s),c.add(Kr[0],Kr[1],Kr[2],$s[0],$s[1],$s[2],1,!0,!0,2,y)),b1(A)&&(d.invariantPosition(A.N1,Kr),d.invariantPosition(A.C2,ys),d.invariantPosition(A.N3,bs),d.invariantPosition(A.C4,fo),d.invariantPosition(A.C5,po),d.invariantPosition(A.C6,vs),c.add(Kr[0],Kr[1],Kr[2],vs[0],vs[1],vs[2],1,!0,!0,2,y),c.add(vs[0],vs[1],vs[2],po[0],po[1],po[2],1,!0,!0,2,y),c.add(po[0],po[1],po[2],fo[0],fo[1],fo[2],1,!0,!0,2,y),c.add(fo[0],fo[1],fo[2],bs[0],bs[1],bs[2],1,!0,!0,2,y),c.add(bs[0],bs[1],bs[2],ys[0],ys[1],ys[2],1,!0,!0,2,y),c.add(ys[0],ys[1],ys[2],Kr[0],Kr[1],Kr[2],1,!0,!0,2,y))),++y}}const x=c.getCylinders(),_=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return x.setBoundingSphere(_),x}function Vht(e,t,n,r,i,o){if(!Ee.isAtomic(t))return Nt.createEmpty(o);const s=t.nucleotideElements.length;if(!s)return Nt.createEmpty(o);const{sizeFactor:a,radialSegments:c}=i,u=s*(15*c),l=at.createState(u,u/4,o),{elements:d,model:f,conformation:p}=t,{chainAtomSegments:m,residueAtomSegments:h}=f.atomicHierarchy,{moleculeType:g}=f.atomicHierarchy.derived.residue,y=en.transientSegments(m,d),b=en.transientSegments(h,d),x={radiusTop:1*a,radiusBottom:1*a,radialSegments:c};let _=0;for(;y.hasNext;)for(b.setSegment(y.move());b.hasNext;){const{index:E}=b.move();if(Ya(g[E])){const w={trace:-1,N1:-1,C2:-1,N3:-1,C4:-1,C5:-1,C6:-1,N7:-1,C8:-1,N9:-1,C1_1:-1,C2_1:-1,C3_1:-1,C4_1:-1,O4_1:-1};l.currentGroup=_,IC(w,t,E),TC(w)&&(p.invariantPosition(w.C1_1,Vo),p.invariantPosition(w.C2_1,Ff),p.invariantPosition(w.C3_1,Gc),p.invariantPosition(w.C4_1,Bf),p.invariantPosition(w.O4_1,Of),p.invariantPosition(w.trace,$s),Hn(l,Gc,$s,1,x),Hn(l,Gc,Bf,1,x),Hn(l,Bf,Of,1,x),Hn(l,Of,Vo,1,x),Hn(l,Vo,Ff,1,x),Hn(l,Ff,Gc,1,x));const{isPurine:D,isPyrimidine:I}=Q0(t,E);D?(ey(w,t,E),-1!==w.C1_1&&-1!==w.N9?(p.invariantPosition(w.C1_1,Vo),p.invariantPosition(w.N9,Uo),Hn(l,Uo,Vo,1,x)):-1!==w.N9&&-1!==w.trace&&(p.invariantPosition(w.N9,Uo),p.invariantPosition(w.trace,$s),Hn(l,Uo,$s,1,x)),y1(w)&&(p.invariantPosition(w.N1,Kr),p.invariantPosition(w.C2,ys),p.invariantPosition(w.N3,bs),p.invariantPosition(w.C4,fo),p.invariantPosition(w.C5,po),p.invariantPosition(w.C6,vs),p.invariantPosition(w.N7,kf),p.invariantPosition(w.C8,Nf),p.invariantPosition(w.N9,Uo),Hn(l,Uo,Nf,1,x),Hn(l,Nf,kf,1,x),Hn(l,kf,po,1,x),Hn(l,po,vs,1,x),Hn(l,vs,Kr,1,x),Hn(l,Kr,ys,1,x),Hn(l,ys,bs,1,x),Hn(l,bs,fo,1,x),Hn(l,fo,po,1,x),Hn(l,fo,Uo,1,x))):I&&(ty(w,t,E),-1!==w.C1_1&&-1!==w.N1?(p.invariantPosition(w.N1,Kr),p.invariantPosition(w.C1_1,Vo),Hn(l,Kr,Vo,1,x)):-1!==w.N1&&-1!==w.trace&&(p.invariantPosition(w.N1,Kr),p.invariantPosition(w.trace,$s),Hn(l,Kr,$s,1,x)),b1(w)&&(p.invariantPosition(w.N1,Kr),p.invariantPosition(w.C2,ys),p.invariantPosition(w.N3,bs),p.invariantPosition(w.C4,fo),p.invariantPosition(w.C5,po),p.invariantPosition(w.C6,vs),Hn(l,Kr,vs,1,x),Hn(l,vs,po,1,x),Hn(l,po,fo,1,x),Hn(l,fo,bs,1,x),Hn(l,bs,ys,1,x),Hn(l,ys,Kr,1,x))),++_}}const S=at.getMesh(l),A=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return S.setBoundingSphere(A),S}const I1=v(),Cl=v(),wl=v(),Al=v(),Il=v(),Du=v(),Tl=v(),T1=v(),D1=v(),E1=v(),P1=v(),M1=v(),R1=v(),k1=v(),N1=v(),wz={...hs,...SU,sizeFactor:C.Numeric(.3,{min:0,max:10,step:.01}),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo),tryUseImpostor:C.Boolean(!0)};function Ght(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth?function Hht(e){return CU({defaultProps:C.getDefaultValues(wz),createGeometry:jht,createLocationIterator:dh.fromGroup,getLoci:K0,eachLocation:Z0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function Wht(e){return Hs({defaultProps:C.getDefaultValues(wz),createGeometry:qht,createLocationIterator:dh.fromGroup,getLoci:K0,eachLocation:Z0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}function jht(e,t,n,r,i,o){if(!Ee.isAtomic(t))return fl.createEmpty(o);const s=t.nucleotideElements.length;if(!s)return fl.createEmpty(o);const a=15*s,c=f1.create(a,a/4,o),{elements:u,model:l,conformation:d}=t,{chainAtomSegments:f,residueAtomSegments:p}=l.atomicHierarchy,{moleculeType:m}=l.atomicHierarchy.derived.residue,h=en.transientSegments(f,u),g=en.transientSegments(p,u);let y=0;for(;h.hasNext;)for(g.setSegment(h.move());g.hasNext;){const{index:_}=g.move();if(Ya(m[_])){const S={trace:-1,N1:-1,C2:-1,N3:-1,C4:-1,C5:-1,C6:-1,N7:-1,C8:-1,N9:-1,C1_1:-1,C2_1:-1,C3_1:-1,C4_1:-1,O4_1:-1};IC(S,t,_),TC(S)&&(d.invariantPosition(S.C1_1,P1),d.invariantPosition(S.C2_1,M1),d.invariantPosition(S.C3_1,R1),d.invariantPosition(S.C4_1,k1),d.invariantPosition(S.O4_1,N1),d.invariantPosition(S.trace,I1),c.add(I1[0],I1[1],I1[2],y),c.add(R1[0],R1[1],R1[2],y),c.add(k1[0],k1[1],k1[2],y),c.add(N1[0],N1[1],N1[2],y),c.add(P1[0],P1[1],P1[2],y),c.add(M1[0],M1[1],M1[2],y));const{isPurine:A,isPyrimidine:E}=Q0(t,_);A?(ey(S,t,_),y1(S)&&(d.invariantPosition(S.N1,Cl),d.invariantPosition(S.C2,wl),d.invariantPosition(S.N3,Al),d.invariantPosition(S.C4,Il),d.invariantPosition(S.C5,Du),d.invariantPosition(S.C6,Tl),d.invariantPosition(S.N7,T1),d.invariantPosition(S.C8,D1),d.invariantPosition(S.N9,E1),c.add(E1[0],E1[1],E1[2],y),c.add(D1[0],D1[1],D1[2],y),c.add(T1[0],T1[1],T1[2],y),c.add(Du[0],Du[1],Du[2],y),c.add(Tl[0],Tl[1],Tl[2],y),c.add(Cl[0],Cl[1],Cl[2],y),c.add(wl[0],wl[1],wl[2],y),c.add(Al[0],Al[1],Al[2],y),c.add(Il[0],Il[1],Il[2],y))):E&&(ty(S,t,_),b1(S)&&(d.invariantPosition(S.N1,Cl),d.invariantPosition(S.C2,wl),d.invariantPosition(S.N3,Al),d.invariantPosition(S.C4,Il),d.invariantPosition(S.C5,Du),d.invariantPosition(S.C6,Tl),c.add(Cl[0],Cl[1],Cl[2],y),c.add(Tl[0],Tl[1],Tl[2],y),c.add(Du[0],Du[1],Du[2],y),c.add(Il[0],Il[1],Il[2],y),c.add(Al[0],Al[1],Al[2],y),c.add(wl[0],wl[1],wl[2],y))),++y}}const b=c.getSpheres(),x=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return b.setBoundingSphere(x),b}function qht(e,t,n,r,i,o){if(!Ee.isAtomic(t))return Nt.createEmpty(o);const s=t.nucleotideElements.length;if(!s)return Nt.createEmpty(o);const{sizeFactor:a,detail:c}=i,u=s*xv(c),l=at.createState(u,u/2,o),{elements:d,model:f,conformation:p}=t,{chainAtomSegments:m,residueAtomSegments:h}=f.atomicHierarchy,{moleculeType:g}=f.atomicHierarchy.derived.residue,y=en.transientSegments(m,d),b=en.transientSegments(h,d),x=1*a;let _=0;for(;y.hasNext;)for(b.setSegment(y.move());b.hasNext;){const{index:E}=b.move();if(Ya(g[E])){const w={trace:-1,N1:-1,C2:-1,N3:-1,C4:-1,C5:-1,C6:-1,N7:-1,C8:-1,N9:-1,C1_1:-1,C2_1:-1,C3_1:-1,C4_1:-1,O4_1:-1};l.currentGroup=_,IC(w,t,E),TC(w)&&(p.invariantPosition(w.C1_1,P1),p.invariantPosition(w.C2_1,M1),p.invariantPosition(w.C3_1,R1),p.invariantPosition(w.C4_1,k1),p.invariantPosition(w.O4_1,N1),p.invariantPosition(w.trace,I1),Zn(l,I1,x,c),Zn(l,k1,x,c),Zn(l,N1,x,c),Zn(l,P1,x,c),Zn(l,M1,x,c),Zn(l,R1,x,c));const{isPurine:D,isPyrimidine:I}=Q0(t,E);D?(ey(w,t,E),y1(w)&&(p.invariantPosition(w.N1,Cl),p.invariantPosition(w.C2,wl),p.invariantPosition(w.N3,Al),p.invariantPosition(w.C4,Il),p.invariantPosition(w.C5,Du),p.invariantPosition(w.C6,Tl),p.invariantPosition(w.N7,T1),p.invariantPosition(w.C8,D1),p.invariantPosition(w.N9,E1),Zn(l,D1,x,c),Zn(l,T1,x,c),Zn(l,Du,x,c),Zn(l,Tl,x,c),Zn(l,Cl,x,c),Zn(l,wl,x,c),Zn(l,Al,x,c),Zn(l,Il,x,c),Zn(l,Du,x,c),Zn(l,E1,x,c))):I&&(ty(w,t,E),b1(w)&&(p.invariantPosition(w.N1,Cl),p.invariantPosition(w.C2,wl),p.invariantPosition(w.N3,Al),p.invariantPosition(w.C4,Il),p.invariantPosition(w.C5,Du),p.invariantPosition(w.C6,Tl),Zn(l,Tl,x,c),Zn(l,Du,x,c),Zn(l,Il,x,c),Zn(l,Al,x,c),Zn(l,wl,x,c),Zn(l,Cl,x,c))),++_}}const S=at.getMesh(l),A=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return S.setBoundingSphere(A),S}const ny=v.zero(),F1=v.zero(),ry=v.zero(),Gpe=v.zero(),es=hf(3,!1);let Az;const iy=le.identity(),Xht=v.zero(),jpe=v.zero(),Hpe=v.zero(),Tz=v.zero(),Kht=4,Zht=4,Qht=6,Jht=function Yht(){return Az||(Az=function $ht(){const e=vv(8);for(let t=0;t<3;++t){const n=(t+1)%3;v.set(ny,es[3*t],es[3*t+1],-.5),v.set(F1,es[3*n],es[3*n+1],-.5),v.set(ry,es[3*n],es[3*n+1],.5),v.set(Gpe,es[3*t],es[3*t+1],.5),e.add(ny,F1,ry),e.add(ry,Gpe,ny)}return v.set(ny,es[0],es[1],-.5),v.set(F1,es[3],es[4],-.5),v.set(ry,es[6],es[7],-.5),e.add(ry,F1,ny),v.set(ny,es[0],es[1],.5),v.set(F1,es[3],es[4],.5),v.set(ry,es[6],es[7],.5),e.add(ny,F1,ry),e.getPrimitive()}()),Az}(),qpe={sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01})};function emt(e,t,n,r,i,o){const s=t.polymerElements.length;if(!s)return Nt.createEmpty(o);const{sizeFactor:a}=i,c=24*s,u=at.createState(c,c/10,o),d=uz(1),{normalVectors:f,binormalVectors:p}=d;let m=0;const h=sz(t,n);for(;h.hasNext;){const b=h.move();u.currentGroup=m;const x=Ya(b.moleculeType),_=cr.is(b.secStrucType,4);if(lz(d,b,x||_?.5:.9,x?.3:.5),_&&!b.secStrucLast||!_){const E=r.size.size(b.center)*a,w=Kht*E,D=Zht*E,I=Qht*E,R=x?p:f;v.fromArray(jpe,R,0),v.fromArray(Hpe,R,3),v.normalize(Tz,v.add(Tz,jpe,Hpe)),le.targetTo(iy,b.p3,b.p1,Tz),le.mul(iy,iy,le.rotY90Z180),le.scale(iy,iy,v.set(Xht,I,D,w)),le.setTranslation(iy,b.p2),at.addPrimitive(u,iy,Jht)}++m}const g=at.getMesh(u),y=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return g.setBoundingSphere(y),g}C.getDefaultValues(qpe);const Wpe={...hs,...qpe};function tmt(e){return Hs({defaultProps:C.getDefaultValues(Wpe),createGeometry:emt,createLocationIterator:t=>lh.fromGroup(t),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor}},e)}const Dz=10,$pe={sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),radialSegments:C.Numeric(16,{min:2,max:56,step:2},rt.CustomQualityParamInfo)};function nmt(e,t,n,r,i,o){const s=t.gapElements.length;if(!s)return Nt.createEmpty(o);const{sizeFactor:a,radialSegments:c}=i,u=Dz*c*2*s*2,l=at.createState(u,u/10,o),d=v(),f=v(),p={radiusTop:1,radiusBottom:1,topCap:!0,bottomCap:!0,radialSegments:c};let m=0;const h=function Ypt(e,t){switch(t.kind){case 0:return new Xpt(e,t);case 1:case 2:return new Kpt(e,t)}}(n,t);for(;h.hasNext;){const{centerA:b,centerB:x}=h.move();b.element===x.element||(t.conformation.invariantPosition(b.element,d),t.conformation.invariantPosition(x.element,f),p.radiusTop=p.radiusBottom=r.size.size(b)*a,l.currentGroup=m,wv(l,d,f,.5,Dz,!1,p),p.radiusTop=p.radiusBottom=r.size.size(x)*a,l.currentGroup=m+1,wv(l,f,d,.5,Dz,!1,p)),m+=2}const g=at.getMesh(l),y=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return g.setBoundingSphere(y),g}C.getDefaultValues($pe);const q3={...hs,...$pe};function Ez(e){return Hs({defaultProps:C.getDefaultValues(q3),createGeometry:nmt,createLocationIterator:gz.fromGroup,getLoci:lht,eachLocation:dht,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.radialSegments!==r.radialSegments}},e)}const nr=v(),Tr=v(),rmt=v(),Eu=v(),Lf=v(),W3=v(),$3=v(),EC=v(),Ad=v(),Uf=v(),Pz=v(),qm=v(),Wm=v(),$m=v(),Ym=v(),Dl=v.fromArray,B1=v.scale,El=v.add,fh=v.sub,imt=v.magnitude,Ype=v.negate,Mz=v.copy,Xpe=v.cross,omt=v.set,Lr=ze.add3,smt=ze.add;function Y3(e,t,n,r,i,o,s,a,c){const{vertices:u,normals:l,indices:d}=t,f=u.elementCount;if(Dl(nr,r,e),B1($3,nr,s),B1(W3,nr,a),Dl(Tr,i,e),B1(Eu,Tr,o),Xpe(Uf,Tr,nr),Dl(Ad,n,e),El(qm,El(qm,Ad,Eu),W3),fh(Wm,El(Wm,Ad,Eu),$3),fh($m,fh($m,Ad,Eu),$3),El(Ym,fh(Ym,Ad,Eu),W3),s0?(Dl(nr,t,0),Dl(Tr,t,3*i),g=a/imt(fh(rmt,Tr,nr))):omt(EC,0,0,0);for(let b=0;b<=i;++b){const x=o[b],S=0===a?s[b]:a*(1-b/i),A=3*b;Dl(Lf,n,A),B1(Lf,Lf,S),Dl(Eu,r,A),B1(Eu,Eu,x),a>0&&(Dl(nr,n,A),Dl(Tr,r,A),B1(EC,Xpe(EC,nr,Tr),g)),Dl(Ad,t,A),Dl(Uf,n,A),Dl(Pz,r,A),El(nr,El(nr,Ad,Eu),Lf),El(Tr,Uf,EC),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),El(nr,fh(nr,Ad,Eu),Lf),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),Ype(Tr,Pz),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),fh(nr,fh(nr,Ad,Eu),Lf),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),El(Tr,Ype(Tr,Uf),EC),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),fh(nr,El(nr,Ad,Eu),Lf),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),Mz(Tr,Pz),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2]),El(nr,El(nr,Ad,Eu),Lf),Lr(d,nr[0],nr[1],nr[2]),Lr(f,Tr[0],Tr[1],Tr[2])}for(let b=0;b0){const b=o[0],x=s[0];Y3(0,e,t,n,r,b,a,-x,!1),Y3(0,e,t,n,r,b,-a,x,!1)}if(u&&0===a){const x=s[i];Y3(3*i,e,t,n,r,o[i],x,x,!0)}for(let b=0,x=8*(i+1)+(c?4:a>0?8:0)+(u&&0===a?4:0);bD;for(let T=0;T=_?I-D:-I+D:T>=x&&T<_?-I+D:I-D;Rz(ts,ts,Ys,M),T===x||T===x-1?K3(wo,Ys,Pa,0,1):T===_||T===_-1?K3(wo,Ys,Pa,0,-1):K3(wo,Ys,Pa,y[T],b[T])}else O1(ts,Ys,Pa,hc,I*y[T],D*b[T]),K3(wo,Ys,Pa,D*y[T],I*b[T]);amt(wo,wo),Ma(f,ts[0],ts[1],ts[2]),Ma(p,wo[0],wo[1],wo[2])}}const S=Math.round(o/2);for(let E=0;ED;R&&(I-=D),g=f.elementCount;for(let T=0;T=_?I:-I)):O1(ts,Ys,Pa,hc,I*y[T],D*b[T]),Ma(f,ts[0],ts[1],ts[2]),Ma(p,wo[0],wo[1],wo[2]),Ma(m,g+(T+1)%o,g+T,w)}if(u){const E=3*i,w=f.elementCount;ph(Ys,n,E),ph(Pa,r,E),ph(hc,t,E),Kpe(wo,Ys,Pa),Ma(f,hc[0],hc[1],hc[2]),Ma(p,wo[0],wo[1],wo[2]);const D=s[i];let I=a[i];const R="rounded"===l&&I>D;R&&(I-=D),g=f.elementCount;for(let T=0;T=_?I:-I)):O1(ts,Ys,Pa,hc,I*y[T],D*b[T]),Ma(f,ts[0],ts[1],ts[2]),Ma(p,wo[0],wo[1],wo[2]),Ma(m,g+T,g+(T+1)%o,w)}ze.addRepeat(h,(i+1)*o+(c?o+1:0)+(u?o+1:0),d)}const hh=v.fromArray,dmt=v.magnitude,Fz=v.sub,Zpe=v.add,Bz=v.scale,fmt=v.negate,pmt=v.copy,hmt=v.cross,Pl=ze.add3,mmt=ze.add,_s=v(),Xs=v(),gmt=v(),Oz=v(),oy=v(),Qpe=v(),PC=v(),ymt=v(),Lz=v();function Z3(e,t,n,r,i,o,s,a){const{currentGroup:c,vertices:u,normals:l,indices:d,groups:f}=e,p=u.elementCount;let m=0;a>0&&(hh(_s,t,0),hh(Xs,t,3*i),m=a/dmt(Fz(gmt,Xs,_s)));for(let g=0;g<=i;++g){const y=o[g],x=0===a?s[g]:a*(1-g/i),_=3*g;hh(oy,n,_),Bz(oy,oy,x),hh(Oz,r,_),Bz(Oz,Oz,y),a>0&&(hh(_s,n,_),hh(Xs,r,_),Bz(Qpe,hmt(Qpe,_s,Xs),m)),hh(PC,t,_),hh(ymt,n,_),hh(Lz,r,_),Zpe(_s,PC,oy),fmt(Xs,Lz),Pl(u,_s[0],_s[1],_s[2]),Pl(l,Xs[0],Xs[1],Xs[2]),Fz(_s,PC,oy),Pl(u,_s[0],_s[1],_s[2]),Pl(l,Xs[0],Xs[1],Xs[2]),Zpe(_s,PC,oy),pmt(Xs,Lz),Pl(u,_s[0],_s[1],_s[2]),Pl(l,Xs[0],Xs[1],Xs[2]),Fz(_s,PC,oy),Pl(u,_s[0],_s[1],_s[2]),Pl(l,Xs[0],Xs[1],Xs[2])}for(let g=0;glh.fromGroup(t,{asSecondary:!0}),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.tubularHelices!==r.tubularHelices||n.detail!==r.detail||n.linearSegments!==r.linearSegments||n.radialSegments!==r.radialSegments||n.aspectRatio!==r.aspectRatio||n.arrowFactor!==r.arrowFactor||n.helixProfile!==r.helixProfile||n.nucleicProfile!==r.nucleicProfile;const c=Xu.get(s.structure).version;t.info.secondaryStructureHash!==c&&(void 0!==t.info.secondaryStructureHash&&(t.createGeometry=!0),t.info.secondaryStructureHash=c)}},e)}const the={"polymer-trace":(e,t)=>vi("Polymer trace mesh",e,t,vmt),"polymer-gap":(e,t)=>vi("Polymer gap cylinder",e,t,Ez),"nucleotide-block":(e,t)=>vi("Nucleotide block mesh",e,t,yht),"nucleotide-ring":(e,t)=>vi("Nucleotide ring mesh",e,t,Aht),"nucleotide-atomic-ring-fill":(e,t)=>vi("Nucleotide atomic ring fill",e,t,Bht),"nucleotide-atomic-bond":(e,t)=>vi("Nucleotide atomic bond",e,t,Oht),"nucleotide-atomic-element":(e,t)=>vi("Nucleotide atomic element",e,t,Ght),"direction-wedge":(e,t)=>vi("Polymer direction wedge",e,t,tmt)},nhe={...ehe,...q3,...Epe,...Fpe,...Cz,...wz,...zpe,...Wpe,sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),visuals:C.MultiSelect(["polymer-trace","polymer-gap","nucleotide-ring","nucleotide-atomic-ring-fill","nucleotide-atomic-bond","nucleotide-atomic-element"],C.objectToOptions(the)),bumpFrequency:C.Numeric(2,{min:0,max:10,step:.1},rt.ShadingCategory),colorMode:C.Select("default",C.arrayToOptions(["default","interpolate"]),{...rt.ShadingCategory,isHidden:!0})},Smt={name:"cartoon",label:"Cartoon",description:"Displays ribbons, planks, tubes smoothly following the trace atoms of polymers.",factory:function xmt(e,t){return yn.createMulti("Cartoon",e,t,ms,the)},getParams:function _mt(e,t){const n=C.clone(nhe);let r=!1,i=!1;return t.units.forEach(o=>{!r&&Ee.isAtomic(o)&&o.nucleotideElements.length&&(r=!0),!i&&o.gapElements.length&&(i=!0)}),n.visuals.defaultValue=["polymer-trace"],r&&n.visuals.defaultValue.push("nucleotide-ring"),i&&n.visuals.defaultValue.push("polymer-gap"),n},defaultValues:C.getDefaultValues(nhe),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.polymerResidueCount>0,ensureCustomProperties:{attach:function(){var e=ie(function*(t,n){yield Xu.attach(t,n,void 0,!0);for(const r of n.models)yield oz.attach(t,r,void 0,!0)});return function(n,r){return e.apply(this,arguments)}}(),detach:e=>{Xu.ref(e,!1);for(const t of e.models)oz.ref(t,!1)}}},rhe={...hs,sizeFactor:C.Numeric(1,{min:0,max:10,step:.1}),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo),ignoreHydrogens:C.Boolean(!1)};function Cmt(e){return Hs({defaultProps:C.getDefaultValues(rhe),createGeometry:wmt,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail||n.ignoreHydrogens!==r.ignoreHydrogens}},e)}function wmt(e,t,n,r,i,o){const{child:s}=n,a=s?.unitMap.get(t.id);if(s&&!a)return Nt.createEmpty(o);const{detail:c,sizeFactor:u,ignoreHydrogens:l}=i,{elements:d,model:f}=t,{atomicNumber:p}=t.model.atomicHierarchy.derived.atom,m=d.length,h=m*xv(c),g=at.createState(h,h/2,o),y=tf.Provider.get(f);if(!y)return Nt.createEmpty(o);const b=v(),x=Kt(),_=v(),S=v(),A=v(),{elementToAnsiotrop:E,data:w}=y,{U:D}=w,I=w._schema.U.space,R=t.conformation,T=nt.create(n);T.unit=t;for(let V=0;Vvi("Ellipsoid Mesh",e,t,Cmt),"intra-bond":(e,t)=>vi("Intra-unit bond cylinder",e,t,Vfe),"inter-bond":(e,t)=>Iu("Inter-unit bond cylinder",e,t,Hfe)},ohe={...rhe,...m3,...g3,includeParent:C.Boolean(!1),adjustCylinderLength:C.Boolean(!1,{isHidden:!0}),unitKinds:oC(["atomic"]),sizeFactor:C.Numeric(1,{min:.01,max:10,step:.01}),sizeAspectRatio:C.Numeric(.1,{min:.01,max:3,step:.01}),linkCap:C.Boolean(!0),visuals:C.MultiSelect(["ellipsoid-mesh","intra-bond","inter-bond"],C.objectToOptions(ihe)),bumpFrequency:C.Numeric(0,{min:0,max:10,step:.1},rt.ShadingCategory)},Tmt={name:"ellipsoid",label:"Ellipsoid",description:"Displays anisotropic displacement ellipsoids of atomic elements plus bonds as cylinders.",factory:function Imt(e,t){return yn.createMulti("Ellipsoid",e,t,ms,ihe)},getParams:function Amt(e,t){return ohe},defaultValues:C.getDefaultValues(ohe),defaultColorTheme:{name:"element-symbol"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.elementCount>0&&e.models.some(t=>tf.Provider.isApplicable(t)),getData:(e,t)=>t.includeParent?e.asParent():e,mustRecreate:(e,t)=>e.includeParent!==t.includeParent},Dmt="\nprecision highp float;\n\nattribute vec3 aPosition;\nattribute float aRadius;\n\nvarying vec3 vPosition;\nvarying float vRadiusSqInv;\n\n#if defined(dCalcType_groupId)\n attribute float aGroup;\n varying float vGroup;\n#endif\n\nuniform vec3 uBboxSize;\nuniform vec3 uBboxMin;\nuniform float uResolution;\n\nvoid main() {\n vRadiusSqInv = 1.0 / (aRadius * aRadius);\n #if defined(dCalcType_groupId)\n vGroup = aGroup;\n #endif\n gl_PointSize = ceil(((aRadius * 3.0) / uResolution) + uResolution);\n vPosition = (aPosition - uBboxMin) / uResolution;\n gl_Position = vec4(((aPosition - uBboxMin) / uBboxSize) * 2.0 - 1.0, 1.0);\n}\n",Emt="\nprecision highp float;\n\nvarying vec3 vPosition;\nvarying float vRadiusSqInv;\n#if defined(dCalcType_groupId)\n #if defined(dGridTexType_2d)\n precision highp sampler2D;\n uniform sampler2D tMinDistanceTex;\n uniform vec3 uGridTexDim;\n #elif defined(dGridTexType_3d)\n precision highp sampler3D;\n uniform sampler3D tMinDistanceTex;\n #endif\n varying float vGroup;\n#endif\n\n#include common\n\nuniform vec3 uGridDim;\nuniform vec2 uGridTexScale;\nuniform float uCurrentSlice;\nuniform float uCurrentX;\nuniform float uCurrentY;\nuniform float uAlpha;\nuniform float uResolution;\nuniform float uRadiusFactorInv;\n\nvoid main() {\n vec2 v = gl_FragCoord.xy - vec2(uCurrentX, uCurrentY) - 0.5;\n vec3 fragPos = vec3(v.x, v.y, uCurrentSlice);\n float dist = distance(fragPos, vPosition) * uResolution;\n\n #if defined(dCalcType_density)\n float density = exp(-uAlpha * ((dist * dist) * vRadiusSqInv));\n gl_FragColor.a = density * uRadiusFactorInv;\n #elif defined(dCalcType_minDistance)\n gl_FragColor.a = 1.0 - dist * uRadiusFactorInv;\n #elif defined(dCalcType_groupId)\n #if defined(dGridTexType_2d)\n float minDistance = 1.0 - texture2D(tMinDistanceTex, (gl_FragCoord.xy) / (uGridTexDim.xy / uGridTexScale)).a;\n #elif defined(dGridTexType_3d)\n float minDistance = 1.0 - texelFetch(tMinDistanceTex, ivec3(gl_FragCoord.xy, uCurrentSlice), 0).a;\n #endif\n if (dist * uRadiusFactorInv > minDistance + uResolution * 0.05)\n discard;\n gl_FragColor.rgb = packIntToRGB(vGroup);\n #endif\n}\n",Pmt={drawCount:ri("number"),instanceCount:ri("number"),aRadius:Ar("float32",1,0),aPosition:Ar("float32",3,0),aGroup:Ar("float32",1,0),uCurrentSlice:xe("f"),uCurrentX:xe("f"),uCurrentY:xe("f"),uBboxMin:xe("v3","material"),uBboxSize:xe("v3","material"),uGridDim:xe("v3","material"),uGridTexDim:xe("v3","material"),uGridTexScale:xe("v2","material"),uAlpha:xe("f","material"),uResolution:xe("f","material"),uRadiusFactorInv:xe("f","material"),tMinDistanceTex:jt("texture","rgba","float","nearest","material"),dGridTexType:Ft("string",["2d","3d"]),dCalcType:Ft("string",["density","minDistance","groupId"])},Vf="gaussian-density";function Uz(e){return e.namedFramebuffers[Vf]||(e.namedFramebuffers[Vf]=e.resources.framebuffer()),e.namedFramebuffers[Vf]}function Vz(e,t,n,r,i,o){const s=`${Vf}-${e}`;return t.namedTextures[s]||(t.namedTextures[s]=t.resources.texture(n,r,i,o)),t.namedTextures[s]}function she(e,t,n,r,i,o){return e.isWebGL2?function Mmt(e,t,n,r,i,o){lt&&e.timer.mark("GaussianDensityTexture3d");const s=function Rmt(e,t,n,r,i,o){const{gl:s,resources:a,state:c,extensions:{colorBufferFloat:u,textureFloat:l,colorBufferHalfFloat:d,textureHalfFloat:f}}=e,{smoothness:p,resolution:m}=i,{drawCount:h,positions:g,radii:y,groups:b,scale:x,expandedBox:_,dim:S,maxRadius:A}=lhe(t,n,r,i),[E,w,D]=S,I=Vz("min-dist-3d",e,"volume-uint8","rgba","ubyte","nearest");I.define(E,w,D);const R=Me.create(1,1),T=2*A,M=dhe(e,h,g,y,b,I,_,S,S,R,p,m,T),{uCurrentSlice:N}=M.values,V=Uz(e);function F(G,L){c.currentRenderItemId=-1;for(let z=0;z=N&&(X-=N,J+=I,ce=0,k.update(O,J)),k.update(q,ce),k.update(ee,be),u.viewport(ce,J,D,I),u.scissor(ce,J,D,I),$.render(),++X,ce+=D;a.flush()}return H.bind(),fhe(e),s||(s=f&&p?c.texture("image-float16","rgba","fp16","linear"):l&&d?c.texture("image-float32","rgba","float","linear"):c.texture("image-uint8","rgba","ubyte","linear")),s.define(z,j),hhe(e,$),W(s,!0),m&&(phe(e,$),W(Z,!0),mhe(e,$),W(s,!1)),{texture:s,scale:S,bbox:A,gridDim:E,gridTexDim:F,gridTexScale:G,radiusFactor:L,resolution:g,maxRadius:w}}(e,t,n,r,i,o,s);return lt&&e.timer.markEnd("GaussianDensityTexture2d"),ahe(a)}function ahe({texture:e,scale:t,bbox:n,gridDim:r,gridTexDim:i,gridTexScale:o,radiusFactor:s,resolution:a,maxRadius:c}){return{transform:che(t,n),texture:e,bbox:n,gridDim:r,gridTexDim:i,gridTexScale:o,radiusFactor:s,resolution:a,maxRadius:c}}function che(e,t){const n=le.identity();return le.fromScaling(n,e),le.setTranslation(n,t.min),n}function lhe(e,t,n,r){const{resolution:i,radiusOffset:o}=r,s=1/i,{indices:a,x:c,y:u,z:l,id:d}=e,f=Fe.size(a),p=new Float32Array(3*f),m=new Float32Array(f),h=new Float32Array(f);let g=0;for(let A=0;A0?"3d":"2d"),k.updateIfChanged(m.dCalcType,"density"),e.namedComputeRenderables[Vf].update()}else e.namedComputeRenderables[Vf]=function kmt(e,t,n,r,i,o,s,a,c,u,l,d,f){const p=v.sub(v(),s.max,s.min),m={drawCount:k.create(t),instanceCount:k.create(1),aRadius:k.create(r),aPosition:k.create(n),aGroup:k.create(i),uCurrentSlice:k.create(0),uCurrentX:k.create(0),uCurrentY:k.create(0),uBboxMin:k.create(s.min),uBboxSize:k.create(p),uGridDim:k.create(a),uGridTexDim:k.create(c),uGridTexScale:k.create(u),uAlpha:k.create(l),uResolution:k.create(d),uRadiusFactorInv:k.create(1/f),tMinDistanceTex:k.create(o),dGridTexType:k.create(o.getDepth()>0?"3d":"2d"),dCalcType:k.create("density")},h={...Pmt};return ji(zi(e,"points",Br(Vf,Dmt,Emt),h,m),m)}(e,t,n,r,i,o,s,a,c,u,l,d,f);return e.namedComputeRenderables[Vf]}function fhe(e){const{gl:t,state:n}=e;n.disable(t.CULL_FACE),n.enable(t.BLEND),n.disable(t.DEPTH_TEST),n.enable(t.SCISSOR_TEST),n.depthMask(!1),n.clearColor(0,0,0,0)}function phe(e,t){const{gl:n,state:r}=e;if(k.update(t.values.dCalcType,"minDistance"),t.update(),r.colorMask(!1,!1,!1,!0),r.blendFunc(n.ONE,n.ONE),!e.extensions.blendMinMax)throw new Error("GPU gaussian surface calculation requires EXT_blend_minmax");r.blendEquation(e.extensions.blendMinMax.MAX)}function hhe(e,t){const{gl:n,state:r}=e;k.update(t.values.dCalcType,"density"),t.update(),r.colorMask(!1,!1,!1,!0),r.blendFunc(n.ONE,n.ONE),r.blendEquation(n.FUNC_ADD)}function mhe(e,t){const{gl:n,state:r}=e;k.update(t.values.dCalcType,"groupId"),t.update(),r.colorMask(!0,!0,!0,!1),r.blendFunc(n.ONE,n.ZERO),r.blendEquation(n.FUNC_ADD)}function ghe(e,t,n,r,i){return Gz.apply(this,arguments)}function Gz(){return Gz=ie(function*(e,t,n,r,i){const{resolution:o,radiusOffset:s,smoothness:a}=i,c=1/o,{indices:u,x:l,y:d,z:f,id:p}=t,m=Fe.size(u),h=new Float32Array(m);let g=0;for(let W=0;Wj[ln]&&(j[ln]=Xt,D[ln]=p?p[fe]:fe)}}}}}}function O(){return(O=ie(function*(){for(let W=0;W1)return!1;const r=n.maxTextureSize/3,{areaCells:i,maxAreaCells:o}=zle(e.boundary.box,t.resolution,r*r);return i{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.createGeometry=!0)},geometryUtils:xa.Utils},t)}({defaultProps:C.getDefaultValues(jz),createGeometry:$mt,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0),n.smoothColors.name!==r.smoothColors.name?t.updateColor=!0:"on"===n.smoothColors.name&&"on"===r.smoothColors.name&&(n.smoothColors.params.resolutionFactor!==r.smoothColors.params.resolutionFactor&&(t.updateColor=!0),n.smoothColors.params.sampleStride!==r.smoothColors.params.sampleStride&&(t.updateColor=!0))},mustRecreate:(t,n,r)=>!n.tryUseGpu||!r||!L1(t.structure,n,r),processValues:(t,n,r,i,o)=>{const{resolution:s,colorTexture:a}=n.meta,c=cl(r.smoothColors,i.color.preferSmoothing,s);c&&o&&(Oae(t,c.resolution,c.stride,o,a),n.meta.colorTexture=t.tColorGrid.ref.value)},dispose:t=>{var n;t.vertexTexture.ref.value.destroy(),t.groupTexture.ref.value.destroy(),t.normalTexture.ref.value.destroy(),t.doubleBuffer.destroy(),null===(n=t.meta.colorTexture)||void 0===n||n.destroy()}},e)}(e):function Hmt(e){return Hs({defaultProps:C.getDefaultValues(jz),createGeometry:jmt,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0),n.smoothColors.name!==r.smoothColors.name?t.updateColor=!0:"on"===n.smoothColors.name&&"on"===r.smoothColors.name&&(n.smoothColors.params.resolutionFactor!==r.smoothColors.params.resolutionFactor&&(t.updateColor=!0),n.smoothColors.params.sampleStride!==r.smoothColors.params.sampleStride&&(t.updateColor=!0))},mustRecreate:(t,n,r)=>n.tryUseGpu&&!!r&&L1(t.structure,n,r),processValues:(t,n,r,i,o)=>{const{resolution:s,colorTexture:a}=n.meta,c=cl(r.smoothColors,i.color.preferSmoothing,s);c&&(oE(t,c.resolution,c.stride,o,a),n.meta.colorTexture=t.tColorGrid.ref.value)},dispose:t=>{var n;null===(n=t.meta.colorTexture)||void 0===n||n.destroy()}},e)}(e)}function Gmt(e,t,n,r){return n.tryUseGpu&&r&&xhe(r)&&L1(t,n,r)?function Kmt(e){return function Gat(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.createGeometry=!0)},geometryUtils:xa.Utils},t)}({defaultProps:C.getDefaultValues(_he),createGeometry:Xmt,createLocationIterator:gs.fromStructure,getLoci:W0,eachLocation:q0,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0),n.smoothColors.name!==r.smoothColors.name?t.updateColor=!0:"on"===n.smoothColors.name&&"on"===r.smoothColors.name&&(n.smoothColors.params.resolutionFactor!==r.smoothColors.params.resolutionFactor&&(t.updateColor=!0),n.smoothColors.params.sampleStride!==r.smoothColors.params.sampleStride&&(t.updateColor=!0))},mustRecreate:(t,n,r)=>!n.tryUseGpu||!r||!L1(t,n,r),processValues:(t,n,r,i,o)=>{const{resolution:s,colorTexture:a}=n.meta,c=cl(r.smoothColors,i.color.preferSmoothing,s);c&&o&&(Oae(t,c.resolution,c.stride,o,a),n.meta.colorTexture=t.tColorGrid.ref.value)},dispose:t=>{var n;t.vertexTexture.ref.value.destroy(),t.groupTexture.ref.value.destroy(),t.normalTexture.ref.value.destroy(),t.doubleBuffer.destroy(),null===(n=t.meta.colorTexture)||void 0===n||n.destroy()}},e)}(e):function Wmt(e){return rh({defaultProps:C.getDefaultValues(_he),createGeometry:qmt,createLocationIterator:gs.fromStructure,getLoci:W0,eachLocation:q0,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.smoothColors.name!==r.smoothColors.name?t.updateColor=!0:"on"===n.smoothColors.name&&"on"===r.smoothColors.name&&(n.smoothColors.params.resolutionFactor!==r.smoothColors.params.resolutionFactor&&(t.updateColor=!0),n.smoothColors.params.sampleStride!==r.smoothColors.params.sampleStride&&(t.updateColor=!0))},mustRecreate:(t,n,r)=>n.tryUseGpu&&!!r&&L1(t,n,r),processValues:(t,n,r,i,o)=>{const{resolution:s,colorTexture:a}=n.meta,c=cl(r.smoothColors,i.color.preferSmoothing,s);c&&(oE(t,c.resolution,c.stride,o,a),n.meta.colorTexture=t.tColorGrid.ref.value)},dispose:t=>{var n;null===(n=t.meta.colorTexture)||void 0===n||n.destroy()}},e)}(e)}function jmt(e,t,n,r,i,o){return Hz.apply(this,arguments)}function Hz(){return Hz=ie(function*(e,t,n,r,i,o){const{smoothness:s}=i,{transform:a,field:c,idField:u,radiusFactor:l,resolution:d,maxRadius:f}=yield bhe(n,t,r.size,i).runInContext(e.runtime),p={isoLevel:Math.exp(-s)/l,scalarField:c,idField:u},m=yield c1(p,o).runAsChild(e.runtime);m.meta.resolution=d,Nt.transform(m,a),e.webgl&&!e.webgl.isWebGL2?(Nt.uniformTriangleGroup(m),k.updateIfChanged(m.varyingGroup,!1)):k.updateIfChanged(m.varyingGroup,!0);const h=_e.expand(_e(),t.boundary.sphere,f);return m.setBoundingSphere(h),m}),Hz.apply(this,arguments)}function qmt(e,t,n,r,i){return qz.apply(this,arguments)}function qz(){return qz=ie(function*(e,t,n,r,i){const{smoothness:o}=r,{transform:s,field:a,idField:c,radiusFactor:u,resolution:l,maxRadius:d}=yield function Lmt(e,t,n){const{position:r,boundary:i,radius:o}=HE(e,t,n),s=Pm(i.box,n);return Oe.create("Gaussian Density",function(){var a=ie(function*(c){return yield ghe(c,r,i.box,o,s)});return function(c){return a.apply(this,arguments)}}())}(t,n.size,r).runInContext(e.runtime),f={isoLevel:Math.exp(-o)/u,scalarField:a,idField:c},p=yield c1(f,i).runAsChild(e.runtime);p.meta.resolution=l,Nt.transform(p,s),e.webgl&&!e.webgl.isWebGL2?(Nt.uniformTriangleGroup(p),k.updateIfChanged(p.varyingGroup,!1)):k.updateIfChanged(p.varyingGroup,!0);const m=_e.expand(_e(),t.boundary.sphere,d);return p.setBoundingSphere(m),p}),qz.apply(this,arguments)}const U1="gaussian-surface";function $mt(e,t,n,r,i,o){return Wz.apply(this,arguments)}function Wz(){return Wz=ie(function*(e,t,n,r,i,o){if(!e.webgl)throw new Error("webgl context required to create gaussian surface texture-mesh");lt&&e.webgl.timer.mark("createGaussianSurfaceTextureMesh");const{namedTextures:s,resources:a,extensions:{colorBufferFloat:c,textureFloat:u,colorBufferHalfFloat:l,textureHalfFloat:d}}=e.webgl;s[U1]||(s[U1]=l&&d?a.texture("image-float16","rgba","fp16","linear"):c&&u?a.texture("image-float32","rgba","float","linear"):a.texture("image-uint8","rgba","ubyte","linear"));const f=yield function Omt(e,t,n,r,i,o,s){const{position:a,boundary:c,radius:u}=jE(e,t,n,i),l=Pm(c.box,i,yhe(o,e));return Oe.create("Gaussian Density",function(){var d=ie(function*(f){return zz(o,a,c.box,u,r,l,s)});return function(f){return d.apply(this,arguments)}}())}(n,t,r.size,!0,i,e.webgl,s[U1]).runInContext(e.runtime),p=Math.exp(-i.smoothness)/f.radiusFactor,m=v.create(0,1,2),h=o?.doubleBuffer.get(),g=s3(e.webgl,f.texture,f.gridDim,f.gridTexDim,f.gridTexScale,f.transform,p,!1,!0,m,!0,h?.vertex,h?.group,h?.normal);lt&&e.webgl.timer.markEnd("createGaussianSurfaceTextureMesh");const y=t.elements.length,b=_e.expand(_e(),t.boundary.sphere,f.maxRadius),x=xa.create(g.vertexCount,y,g.vertexTexture,g.groupTexture,g.normalTexture,b,o);return x.meta.resolution=f.resolution,x.meta.webgl=e.webgl,x}),Wz.apply(this,arguments)}function Xmt(e,t,n,r,i){return $z.apply(this,arguments)}function $z(){return $z=ie(function*(e,t,n,r,i){if(!e.webgl)throw new Error("webgl context required to create structure gaussian surface texture-mesh");lt&&e.webgl.timer.mark("createStructureGaussianSurfaceTextureMesh");const{namedTextures:o,resources:s,extensions:{colorBufferFloat:a,textureFloat:c,colorBufferHalfFloat:u,textureHalfFloat:l}}=e.webgl;o[U1]||(o[U1]=u&&l?s.texture("image-float16","rgba","fp16","linear"):a&&c?s.texture("image-float32","rgba","float","linear"):s.texture("image-uint8","rgba","ubyte","linear"));const d=yield function Vmt(e,t,n,r,i,o){const{box:s}=e.lookup3d.boundary,{position:a,boundary:c,radius:u}=HE(e,t,r),l=Pm(c.box,r);return Oe.create("Gaussian Density",function(){var d=ie(function*(f){return zz(i,a,s,u,n,l,o)});return function(f){return d.apply(this,arguments)}}())}(t,n.size,!0,r,e.webgl,o[U1]).runInContext(e.runtime),f=Math.exp(-r.smoothness)/d.radiusFactor,p=v.create(0,1,2),m=i?.doubleBuffer.get(),h=s3(e.webgl,d.texture,d.gridDim,d.gridTexDim,d.gridTexScale,d.transform,f,!1,!0,p,!0,m?.vertex,m?.group,m?.normal);lt&&e.webgl.timer.markEnd("createStructureGaussianSurfaceTextureMesh");const g=t.elementCount,y=_e.expand(_e(),t.boundary.sphere,d.maxRadius),b=xa.create(h.vertexCount,g,h.vertexTexture,h.groupTexture,h.normalTexture,y,i);return b.meta.resolution=d.resolution,b.meta.webgl=e.webgl,b}),$z.apply(this,arguments)}function Zmt(e,t,n,r,i,o){return Yz.apply(this,arguments)}function Yz(){return Yz=ie(function*(e,t,n,r,i,o){const{smoothness:s}=i,{transform:a,field:c,idField:u,maxRadius:l}=yield bhe(n,t,r.size,i).runInContext(e.runtime),d={isoLevel:Math.exp(-s),scalarField:c,idField:u},f=yield HU(d,o).runAsChild(e.runtime);di.transform(f,a);const p=_e.expand(_e(),t.boundary.sphere,l);return f.setBoundingSphere(p),f}),Yz.apply(this,arguments)}const She={...qE,...MC,sizeFactor:C.Numeric(3,{min:0,max:10,step:.1}),lineSizeAttenuation:C.Boolean(!1),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),includeParent:C.Boolean(!1,{isHidden:!0})};function Qmt(e){return WE({defaultProps:C.getDefaultValues(She),createGeometry:Zmt,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0)}},e)}const Che={"gaussian-surface-mesh":(e,t)=>vi("Gaussian surface mesh",e,t,zmt),"structure-gaussian-surface-mesh":(e,t)=>Iu("Structure-Gaussian surface mesh",e,t,Gmt),"gaussian-surface-wireframe":(e,t)=>vi("Gaussian surface wireframe",e,t,Qmt)},whe={...jz,...She,visuals:C.MultiSelect(["gaussian-surface-mesh"],C.objectToOptions(Che)),bumpFrequency:C.Numeric(1,{min:0,max:10,step:.1},rt.ShadingCategory)},tgt={name:"gaussian-surface",label:"Gaussian Surface",description:"Displays a gaussian molecular surface.",factory:function egt(e,t){return yn.createMulti("Gaussian Surface",e,t,ms,Che)},getParams:function Jmt(e,t){return whe},defaultValues:C.getDefaultValues(whe),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"physical"},isApplicable:e=>e.elementCount>0},Ahe={...Oat,background:C.Boolean(!1),backgroundMargin:C.Numeric(0,{min:0,max:1,step:.01}),backgroundColor:C.Color(xn.black),backgroundOpacity:C.Numeric(.5,{min:0,max:1,step:.01}),borderWidth:C.Numeric(.25,{min:0,max:.5,step:.01}),level:C.Select("residue",[["chain","Chain"],["residue","Residue"],["element","Element"]],{isEssential:!0}),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),chainScale:C.Numeric(10,{min:0,max:20,step:.1}),residueScale:C.Numeric(1,{min:0,max:20,step:.1}),elementScale:C.Numeric(.5,{min:0,max:20,step:.1})};function ngt(e){return function Lat(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0),r.background!==i.background&&(n.createGeometry=!0),r.backgroundMargin!==i.backgroundMargin&&(n.createGeometry=!0),r.tether!==i.tether&&(n.createGeometry=!0),r.tetherLength!==i.tetherLength&&(n.createGeometry=!0),r.tetherBaseWidth!==i.tetherBaseWidth&&(n.createGeometry=!0),r.attachment!==i.attachment&&(n.createGeometry=!0),r.fontFamily!==i.fontFamily&&(n.createGeometry=!0),r.fontQuality!==i.fontQuality&&(n.createGeometry=!0),r.fontStyle!==i.fontStyle&&(n.createGeometry=!0),r.fontVariant!==i.fontVariant&&(n.createGeometry=!0),r.fontWeight!==i.fontWeight&&(n.createGeometry=!0)},geometryUtils:vu.Utils},t)}({defaultProps:C.getDefaultValues(Ahe),createGeometry:rgt,createLocationIterator:gs.fromStructure,getLoci:W0,eachLocation:q0,setUpdateState:(t,n,r)=>{t.createGeometry=n.level!==r.level||"chain"===n.level&&n.chainScale!==r.chainScale||"residue"===n.level&&n.residueScale!==r.residueScale||"element"===n.level&&n.elementScale!==r.elementScale||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant}},e)}function rgt(e,t,n,r,i){switch(r.level){case"chain":return function igt(e,t,n,r,i){const o=nt.create(t),{units:s,serialMapping:a}=t,{auth_asym_id:c,label_asym_id:u}=Ze.chain,{cumulativeUnitElementCount:l}=a,d=s.length,{chainScale:f}=r,p=wf.create(r,d,d/2,i);for(let m=0,h=s.length;mIu("Label text",e,t,ngt)},The={...Ahe,visuals:C.MultiSelect(["label-text"],C.objectToOptions(Ihe))},ugt={name:"label",label:"Label",description:"Displays labels.",factory:function cgt(e,t){const n=yn.createMulti("Label",e,t,ms,Ihe);return n.setState({pickable:!1,markerActions:Bt.None}),n},getParams:function agt(e,t){return The},defaultValues:C.getDefaultValues(The),defaultColorTheme:{name:"uniform"},defaultSizeTheme:{name:"physical"},isApplicable:e=>e.elementCount>0},Xz={probeRadius:C.Numeric(1.4,{min:0,max:10,step:.1},{description:"Radius of the probe tracing the molecular surface."}),resolution:C.Numeric(.5,{min:.01,max:20,step:.01},{description:"Grid resolution/cell spacing.",...rt.CustomQualityParamInfo}),probePositions:C.Numeric(36,{min:12,max:90,step:1},{description:"Number of positions tested for probe target intersection.",...rt.CustomQualityParamInfo})};function Kz(){return Kz=ie(function*(e,t,n,r,i,o){let s=-1;function a(Y,ge,Se,Re,Ne){if(-1!==s){const Ge=s;if(Ge!==Re&&Ge!==Ne&&c(Ge,Y,ge,Se))return Ge;s=-1}for(let Ge=0,$e=R.count;Ge<$e;++Ge){const tt=Fe.getAt(T,R.indices[Ge]);if(tt!==Re&&tt!==Ne&&c(tt,Y,ge,Se))return s=tt,tt}return-1}function c(Y,ge,Se,Re){const Ne=G[Y],Ge=M[Y]-ge,$e=N[Y]-Se,tt=V[Y]-Re;return Ge*Ge+$e*$e+tt*tt0&&Ue{n.resolution!==r.resolution&&(t.createGeometry=!0),n.probeRadius!==r.probeRadius&&(t.createGeometry=!0),n.probePositions!==r.probePositions&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0),n.smoothColors.name!==r.smoothColors.name?t.updateColor=!0:"on"===n.smoothColors.name&&"on"===r.smoothColors.name&&(n.smoothColors.params.resolutionFactor!==r.smoothColors.params.resolutionFactor&&(t.updateColor=!0),n.smoothColors.params.sampleStride!==r.smoothColors.params.sampleStride&&(t.updateColor=!0))},processValues:(t,n,r,i,o)=>{const{resolution:s,colorTexture:a}=n.meta,c=cl(r.smoothColors,i.color.preferSmoothing,s);c&&(oE(t,c.resolution,c.stride,o,a),n.meta.colorTexture=t.tColorGrid.ref.value)},dispose:t=>{var n;null===(n=t.meta.colorTexture)||void 0===n||n.destroy()}},e)}function bgt(e,t,n,r,i){return e7.apply(this,arguments)}function e7(){return e7=ie(function*(e,t,n,r,i){const{transform:o,field:s,idField:a,resolution:c,maxRadius:u}=yield function mgt(e,t,n){const{position:r,boundary:i,maxRadius:o}=function hgt(e,t,n){const{probeRadius:r}=n,{position:i,boundary:o,radius:s}=HE(e,t,n),{indices:a}=i,c=Fe.size(a),u=new Float32Array(Fe.end(a));let l=0;for(let d=0;d{n.resolution!==r.resolution&&(t.createGeometry=!0),n.probeRadius!==r.probeRadius&&(t.createGeometry=!0),n.probePositions!==r.probePositions&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0),n.smoothColors.name!==r.smoothColors.name?t.updateColor=!0:"on"===n.smoothColors.name&&"on"===r.smoothColors.name&&(n.smoothColors.params.resolutionFactor!==r.smoothColors.params.resolutionFactor&&(t.updateColor=!0),n.smoothColors.params.sampleStride!==r.smoothColors.params.sampleStride&&(t.updateColor=!0))},processValues:(t,n,r,i,o)=>{const{resolution:s,colorTexture:a}=n.meta,c=cl(r.smoothColors,i.color.preferSmoothing,s);c&&(oE(t,c.resolution,c.stride,o,a),n.meta.colorTexture=t.tColorGrid.ref.value)},dispose:t=>{var n;null===(n=t.meta.colorTexture)||void 0===n||n.destroy()}},e)}const Phe={...qE,...Xz,...GE,sizeFactor:C.Numeric(1.5,{min:0,max:10,step:.1})};function _gt(e,t,n,r,i,o){return t7.apply(this,arguments)}function t7(){return t7=ie(function*(e,t,n,r,i,o){const{transform:s,field:a,idField:c,maxRadius:u}=yield Dhe(n,t,r.size,i).runInContext(e.runtime),l={isoLevel:i.probeRadius,scalarField:a,idField:c},d=yield HU(l,o).runAsChild(e.runtime);di.transform(d,s);const f=_e.expand(_e(),t.boundary.sphere,u);return d.setBoundingSphere(f),d}),t7.apply(this,arguments)}function xgt(e){return WE({defaultProps:C.getDefaultValues(Phe),createGeometry:_gt,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.probeRadius!==r.probeRadius&&(t.createGeometry=!0),n.probePositions!==r.probePositions&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0)}},e)}const Mhe={"molecular-surface-mesh":(e,t)=>vi("Molecular surface mesh",e,t,ygt),"structure-molecular-surface-mesh":(e,t)=>Iu("Structure Molecular surface mesh",e,t,vgt),"molecular-surface-wireframe":(e,t)=>vi("Molecular surface wireframe",e,t,xgt)},Rhe={...Qz,...Phe,visuals:C.MultiSelect(["molecular-surface-mesh"],C.objectToOptions(Mhe)),bumpFrequency:C.Numeric(1,{min:0,max:10,step:.1},rt.ShadingCategory)},wgt={name:"molecular-surface",label:"Molecular Surface",description:"Displays a molecular surface.",factory:function Cgt(e,t){return yn.createMulti("Molecular Surface",e,t,ms,Mhe)},getParams:function Sgt(e,t){return Rhe},defaultValues:C.getDefaultValues(Rhe),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"physical"},isApplicable:e=>e.elementCount>0},khe={...hs,sizeFactor:C.Numeric(1,{min:0,max:2,step:.1}),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo)};function Agt(e){return Hs({defaultProps:C.getDefaultValues(khe),createGeometry:Tgt,createLocationIterator:Dgt,getLoci:Egt,eachLocation:Pgt,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail}},e)}function Tgt(e,t,n,r,i,o){if(!function Igt(e){if(Ee.Traits.is(e.traits,Ee.Trait.MultiChain)||Ee.Traits.is(e.traits,Ee.Trait.Partitioned))return!1;if(Ee.isCoarse(e))return!0;if(0===e.elements.length)return!1;const n=e.model.atomicHierarchy.derived.residue.moleculeType[e.residueIndex[e.elements[0]]];return!(3===n||2===n)}(t))return Nt.createEmpty(o);const{detail:s,sizeFactor:a}=i,u=at.createState(256,128,o),l=t.principalAxes.boxAxes,{origin:d,dirA:f,dirB:p}=l,m=Rs.size(v(),l);v.scale(m,m,a/2);const h=v.create(m[2],m[1],m[0]);u.currentGroup=0,p8(u,d,f,p,h,s+1);const g=at.getMesh(u),y=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return g.setBoundingSphere(y),g}function Dgt(e){const{group:t,structure:n}=e,i=t.units.length,o=nt.create(n);return Mr(1,i,1,(a,c)=>{const u=t.units[c];return o.unit=u,o.element=u.elements[a],o})}function Egt(e,t,n){const{objectId:r,instanceId:i}=e;if(n===r){const{structure:o,group:s}=t,a=s.units[i];return De(o,[{unit:a,indices:Fe.ofBounds(0,a.elements.length)}])}return $n}function Pgt(e,t,n){let r=!1;if(!De.is(e))return!1;const{structure:i,group:o}=t;if(!Ve.areEquivalent(e.structure,i))return!1;const s=o.elements.length;for(const a of e.elements){const c=o.unitIndexMap.get(a.unit.id);void 0!==c&&Fe.size(a.indices)===s&&n(Ce.ofSingleton(c))&&(r=!0)}return r}const Nhe={"orientation-ellipsoid-mesh":(e,t)=>vi("Orientation ellipsoid mesh",e,t,Agt)},Fhe={...khe,visuals:C.MultiSelect(["orientation-ellipsoid-mesh"],C.objectToOptions(Nhe)),bumpFrequency:C.Numeric(1,{min:0,max:10,step:.1},rt.ShadingCategory)},kgt={name:"orientation",label:"Orientation",description:"Displays orientation ellipsoids for polymer chains.",factory:function Rgt(e,t){return yn.createMulti("Orientation",e,t,ms,Nhe)},getParams:function Mgt(e,t){return Fhe},defaultValues:C.getDefaultValues(Fhe),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.elementCount>0},Ngt=ze.add3,Fgt=ze.add;var n7;!function(e){e.create=function t(n=2048,r=1024,i){const o=ze.create(Float32Array,3,r,i?i.centerBuffer.ref.value:n),s=ze.create(Float32Array,1,r,i?i.groupBuffer.ref.value:n);return{add:(a,c,u,l)=>{Ngt(o,a,c,u),Fgt(s,l)},getPoints:()=>{const a=ze.compact(o,!0),c=ze.compact(s,!0);return ym.create(a,c,o.elementCount,i)}}}}(n7||(n7={}));const Bhe=v.add,r7={...Hat,pointSizeAttenuation:C.Boolean(!1),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),traceOnly:C.Boolean(!1),stride:C.Numeric(1,{min:1,max:100,step:1})};function Bgt(e,t,n,r,i,o){const{child:s}=n;if(s&&!s.unitMap.get(t.id))return ym.createEmpty(o);const a=t.elements,c=a.length,u=n7.create(c,c/10,o),l=v(),d=t.conformation,f=H0(n,t,i),p=v();let m=0;if(f)for(let b=0;b{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:ym.Utils},t)}({defaultProps:C.getDefaultValues(r7),createGeometry:Bgt,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{t.createGeometry=n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.traceOnly!==r.traceOnly||n.stride!==r.stride}},e)}const Ogt={"element-point":(e,t)=>vi("Points",e,t,Ohe)},Lhe={...r7},Vgt={name:"point",label:"Point",description:"Displays elements (atoms, coarse spheres) as points.",factory:function Ugt(e,t){return yn.createMulti("Point",e,t,ms,Ogt)},getParams:function Lgt(e,t){return Lhe},defaultValues:C.getDefaultValues(Lhe),defaultColorTheme:{name:"element-symbol"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.elementCount>0},Uhe={sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo),linearSegments:C.Numeric(8,{min:1,max:48,step:1},rt.CustomQualityParamInfo),radialSegments:C.Numeric(16,{min:2,max:56,step:2},rt.CustomQualityParamInfo)},Hc=(C.getDefaultValues(Uhe),v());function zgt(e,t,n,r,i,o){const s=t.polymerElements.length;if(!s)return Nt.createEmpty(o);const{sizeFactor:a,detail:c,linearSegments:u,radialSegments:l}=i,d=u*l*s+(l+1)*s*2,f=at.createState(d,d/10,o),p=uz(u),{curvePoints:m,normalVectors:h,binormalVectors:g,widthValues:y,heightValues:b}=p;let x=0;const _=sz(t,n,{ignoreSecondaryStructure:!0});for(;_.hasNext;){const E=_.move();f.currentGroup=x;const D=Ya(E.moleculeType)?A3:w3;lz(p,E,bpe,D);const I=E.coarseBackboneFirst||E.first,R=E.coarseBackboneLast||E.last,T=r.size.size(E.centerPrev)*a,M=r.size.size(E.center)*a,N=r.size.size(E.centerNext)*a;mz(p,T,M,N,T,M,N,D);let V=u;if(E.initial){V=Math.max(Math.round(u*D),1);const F=u-V;m.copyWithin(0,3*F),g.copyWithin(0,3*F),h.copyWithin(0,3*F),y.copyWithin(0,3*F),b.copyWithin(0,3*F),v.fromArray(Hc,m,3),v.normalize(Hc,v.sub(Hc,E.p2,Hc)),v.scaleAndAdd(Hc,E.p2,Hc,M*I3),v.toArray(Hc,m,0)}else E.final&&(V=Math.max(Math.round(u*(1-D)),1),v.fromArray(Hc,m,3*V-3),v.normalize(Hc,v.sub(Hc,E.p2,Hc)),v.scaleAndAdd(Hc,E.p2,Hc,M*I3),v.toArray(Hc,m,3*V));!0===E.initial&&!0===E.final?Zn(f,E.p2,2*M,c):2===l?Z3(f,m,h,g,V,y,b,0):4===l?X3(f,m,h,g,V,y,b,0,I,R):Nz(f,m,h,g,V,l,y,b,I,R,"elliptical"),++x}const S=at.getMesh(f),A=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return S.setBoundingSphere(A),S}const Vhe={...hs,...Uhe};function Ggt(e){return Hs({defaultProps:C.getDefaultValues(Vhe),createGeometry:zgt,createLocationIterator:t=>lh.fromGroup(t,{asSecondary:!0}),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail||n.linearSegments!==r.linearSegments||n.radialSegments!==r.radialSegments}},e)}const zhe={"polymer-tube":(e,t)=>vi("Polymer tube mesh",e,t,Ggt),"polymer-gap":(e,t)=>vi("Polymer gap cylinder",e,t,Ez)},Ghe={...Vhe,...q3,sizeFactor:C.Numeric(.2,{min:0,max:10,step:.01}),visuals:C.MultiSelect(["polymer-tube","polymer-gap"],C.objectToOptions(zhe)),bumpFrequency:C.Numeric(2,{min:0,max:10,step:.1},rt.ShadingCategory)},qgt={name:"putty",label:"Putty",description:"Displays a tube smoothly following the trace atoms of polymers.",factory:function Hgt(e,t){return yn.createMulti("Putty",e,t,ms,zhe)},getParams:function jgt(e,t){const n=C.clone(Ghe);let r=!1,i=!1;return t.units.forEach(o=>{!r&&Ee.isAtomic(o)&&o.nucleotideElements.length&&(r=!0),!i&&o.gapElements.length&&(i=!0)}),n.visuals.defaultValue=["polymer-tube"],i&&n.visuals.defaultValue.push("polymer-gap"),n},defaultValues:C.getDefaultValues(Ghe),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"uncertainty"},isApplicable:e=>e.polymerResidueCount>0},jhe={"element-sphere":(e,t)=>vi("Sphere mesh/impostor",e,t,Wfe),"structure-element-sphere":(e,t)=>Iu("Structure sphere mesh/impostor",e,t,ept)},i7={...y3,bumpFrequency:C.Numeric(1,{min:0,max:10,step:.1},rt.ShadingCategory),visuals:C.MultiSelect(["element-sphere"],C.objectToOptions(jhe))};let Q3;const Ygt={name:"spacefill",label:"Spacefill",description:"Displays atomic/coarse elements as spheres.",factory:function $gt(e,t){return yn.createMulti("Spacefill",e,t,ms,jhe)},getParams:function Wgt(e,t){return t.isCoarseGrained?(Q3||(Q3=C.clone(i7),Q3.sizeFactor.defaultValue=2),Q3):i7},defaultValues:C.getDefaultValues(i7),defaultColorTheme:{name:"element-symbol"},defaultSizeTheme:{name:"physical"},isApplicable:e=>e.elementCount>0},o7=jn.is;function Xgt(e,t,n,r,i,o){if(!Ee.isAtomic(t))return di.createEmpty(o);const{child:s}=n,a=s?.unitMap.get(t.id);if(s&&!a)return di.createEmpty(o);const c=nt.create(n,t),u=t.elements,l=t.bonds,{edgeCount:d,a:f,b:p,edgeProps:m,offset:h}=l;if(!d)return di.createEmpty(o);const{order:g,flags:y}=m,{sizeFactor:b,aromaticBonds:x,includeTypes:_,excludeTypes:S,multipleBonds:A}=i,E="off"===A,w="symmetric"===A,R=h3(jn.fromNames(_),jn.fromNames(S),32),T=v(),M=t.conformation,{elementRingIndices:N,elementAromaticRingIndices:V}=t.rings,F=x?t.resonance.delocalizedTriplets:void 0,G={linkCount:2*d,referencePosition:j=>{let Z=f[j],$=p[j];const ee=F?.getThirdElement(Z,$);if(void 0!==ee)return M.invariantPosition(u[ee],T);Z>$&&([Z,$]=[$,Z]),h[Z+1]-h[Z]==1&&([Z,$]=[$,Z]);const q=V.get(Z)||N.get(Z);let O=0;for(let H=h[Z],W=h[Z+1];HO&&(O=X,M.invariantPosition(u[Q],T))}}}return O>0?T:null},position:(j,Z,$)=>{M.invariantPosition(u[f[$]],j),M.invariantPosition(u[p[$]],Z)},style:j=>{const Z=g[j],$=y[j];if(o7($,2)||o7($,4))return 1;if(3===Z)return E?0:w?4:5;if(x){const q=p[j],O=V.get(f[j]),H=V.get(q),W=O&&H?zI(O,H):0;if(o7($,16)||W&&!R)return 2===W?8:7}return 2!==Z||E?0:w?2:3},radius:j=>{c.element=u[f[j]];const Z=r.size.size(c);c.element=u[p[j]];const $=r.size.size(c);return Math.min(Z,$)*b},ignore:Ofe(n,t,i)},{lines:L,boundingSphere:z}=ede(0,G,i,o);if(z)L.setBoundingSphere(z);else if(L.lineCount>0){const j=_e.expand(_e(),(a??t).boundary.sphere,1*b);L.setBoundingSphere(j)}return L}const Hhe={...qE,...BV,includeParent:C.Boolean(!1)};function Kgt(e){return WE({defaultProps:C.getDefaultValues(Hhe),createGeometry:Xgt,createLocationIterator:t=>Um.fromGroup(t),getLoci:OV,eachLocation:LV,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.linkScale!==r.linkScale||n.linkSpacing!==r.linkSpacing||n.aromaticDashCount!==r.aromaticDashCount||n.dashCount!==r.dashCount||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||!Wa(n.includeTypes,r.includeTypes)||!Wa(n.excludeTypes,r.excludeTypes)||n.aromaticBonds!==r.aromaticBonds||n.multipleBonds!==r.multipleBonds;const c=s.group.units[0],u=a.group.units[0];Ee.isAtomic(c)&&Ee.isAtomic(u)&&(Dc.areEqual(c.bonds,u.bonds)||(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0))}},e)}const s7=new Lt.ElementBondIterator;function qhe(e,t,n,r){for(s7.setElement(t,n,r);s7.hasNext;){const i=s7.move();return i.otherUnit.conformation.position(i.otherUnit.elements[i.otherIndex],e),e}return null}function Zgt(e,t,n,r,i){const o=t.interUnitBonds,{edgeCount:s,edges:a}=o;if(!s)return di.createEmpty(i);const{sizeFactor:c,aromaticBonds:u,multipleBonds:l}=r,d="off"===l,f="symmetric"===l,p=v(),m=nt.create(),h={linkCount:s,referencePosition:b=>{const x=a[b];let _,S,A,E;if(x.unitAx.unitB))throw new Error("same units in createInterUnitBondLines");_=t.unitMap.get(x.unitB),S=t.unitMap.get(x.unitA),A=x.indexB,E=x.indexA}return qhe(p,t,_,A)||qhe(p,t,S,E)},position:(b,x,_)=>{const S=a[_],A=t.unitMap.get(S.unitA),E=t.unitMap.get(S.unitB);A.conformation.position(A.elements[S.indexA],b),E.conformation.position(E.elements[S.indexB],x)},style:b=>{const x=a[b].props.order,_=ea.create(a[b].props.flag);return jn.is(_,2)||jn.is(_,4)?1:3===x?d?0:f?4:5:u&&jn.is(_,16)?7:2!==x||d?0:f?2:3},radius:b=>{const x=a[b];m.structure=t,m.unit=t.unitMap.get(x.unitA),m.element=m.unit.elements[x.indexA];const _=n.size.size(m);m.unit=t.unitMap.get(x.unitB),m.element=m.unit.elements[x.indexB];const S=n.size.size(m);return Math.min(_,S)*c},ignore:Lfe(t,r)},{lines:g,boundingSphere:y}=ede(0,h,r,i);if(y)g.setBoundingSphere(y);else if(g.lineCount>0){const{child:b}=t,x=_e.expand(_e(),(b??t).boundary.sphere,1*c);g.setBoundingSphere(x)}return g}const Whe={...Fat,...BV,includeParent:C.Boolean(!1)};function Qgt(e){return function Bat(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.updateSize=!0)},geometryUtils:di.Utils},t)}({defaultProps:C.getDefaultValues(Whe),createGeometry:Zgt,createLocationIterator:t=>Um.fromStructure(t),getLoci:UV,eachLocation:zV,setUpdateState:(t,n,r,i,o,s,a)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.linkScale!==r.linkScale||n.linkSpacing!==r.linkSpacing||n.aromaticDashCount!==r.aromaticDashCount||n.dashCount!==r.dashCount||n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||!Wa(n.includeTypes,r.includeTypes)||!Wa(n.excludeTypes,r.excludeTypes)||n.multipleBonds!==r.multipleBonds,s.interUnitBonds!==a.interUnitBonds&&(t.createGeometry=!0,t.updateTransform=!0,t.updateColor=!0,t.updateSize=!0)}},e)}const V1=v.scaleAndAdd,$he=v.unitX,Yhe=v.unitY,Xhe=v.unitZ,Khe={...qE,lineSizeAttenuation:C.Boolean(!1),ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),traceOnly:C.Boolean(!1),crosses:C.Select("lone",C.arrayToOptions(["lone","all"])),crossSize:C.Numeric(.35,{min:0,max:2,step:.01})};function Jgt(e,t,n,r,i,o){const{child:s}=n;if(s&&!s.unitMap.get(t.id))return di.createEmpty(o);const a=t.elements,c=a.length,u=Fc.create(c,c/10,o),l=v(),d=v(),f=v(),p=t.conformation,m=H0(n,t,i),h=i.crossSize/2,g="lone"===i.crosses;for(let x=0;x{t.createGeometry=n.ignoreHydrogens!==r.ignoreHydrogens||n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant||n.traceOnly!==r.traceOnly||n.crosses!==r.crosses||n.crossSize!==r.crossSize}},e)}const Zhe={"intra-bond":(e,t)=>vi("Intra-unit bond line",e,t,Kgt),"inter-bond":(e,t)=>Iu("Inter-unit bond line",e,t,Qgt),"element-point":(e,t)=>vi("Points",e,t,Ohe),"element-cross":(e,t)=>vi("Crosses",e,t,e0t)},a7={...Hhe,...Whe,...r7,...Khe,pointStyle:C.Select("circle",C.objectToOptions(ym.StyleTypes)),multipleBonds:C.Select("offset",C.arrayToOptions(["off","symmetric","offset"])),includeParent:C.Boolean(!1),sizeFactor:C.Numeric(2,{min:.01,max:10,step:.01}),unitKinds:oC(["atomic"]),visuals:C.MultiSelect(["intra-bond","inter-bond","element-point","element-cross"],C.objectToOptions(Zhe))},r0t={name:"line",label:"Line",description:"Displays bonds as lines and atoms as points or croses.",factory:function n0t(e,t){return yn.createMulti("Line",e,t,ms,Zhe)},getParams:function t0t(e,t){if(Ve.getSize(t)>=Ve.Size.Huge){const r=C.clone(a7);return r.visuals.defaultValue=["intra-bond","element-point","element-cross"],r}return a7},defaultValues:C.getDefaultValues(a7),defaultColorTheme:{name:"element-symbol"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.elementCount>0,getData:(e,t)=>t.includeParent?e.asParent():e,mustRecreate:(e,t)=>e.includeParent!==t.includeParent};function i0t(e,t,n,r,i){return c7.apply(this,arguments)}function c7(){return c7=ie(function*(e,t,n,r,i){const{runtime:o,webgl:s}=e;if(!s||!s.extensions.blendMinMax)throw new Error("GaussianDensityVolume requires `webgl` and `blendMinMax` extension");const a=i?i.gridTexture.ref.value:void 0,c=yield function Umt(e,t,n,r,i){const{position:o,boundary:s,radius:a}=HE(e,t,n),c=Pm(s.box,n);return Oe.create("Gaussian Density",function(){var u=ie(function*(l){return she(r,o,s.box,a,c,i)});return function(l){return u.apply(this,arguments)}}())}(t,n.size,r,s,a).runInContext(o),{transform:u,texture:l,bbox:d,gridDim:f}=c,m=le.mul(le(),u,le.fromScaling(le(),f)),h=le.getScaling(v(),u),g=v.create(0,1,2),y=_u.create(d,f,u,m,h,l,{min:0,max:1,mean:.04,sigma:.01},!0,g,i),b=_e.expand(_e(),t.boundary.sphere,c.maxRadius);return y.setBoundingSphere(b),y}),c7.apply(this,arguments)}const Qhe={...Uat,...MC,ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),includeParent:C.Boolean(!1,{isHidden:!0})};function o0t(e){return function Vat(e,t){return N0({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.createGeometry=!0)},geometryUtils:_u.Utils},t)}({defaultProps:C.getDefaultValues(Qhe),createGeometry:i0t,createLocationIterator:gs.fromStructure,getLoci:W0,eachLocation:q0,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0)},dispose:t=>{t.gridTexture.ref.value.destroy()}},e)}function s0t(e,t,n,r,i,o){return u7.apply(this,arguments)}function u7(){return u7=ie(function*(e,t,n,r,i,o){const{runtime:s,webgl:a}=e;if(!a)throw new Error("GaussianDensityVolume requires `webgl`");const c=o?o.gridTexture.ref.value:void 0,u=yield function Bmt(e,t,n,r,i,o){const{position:s,boundary:a,radius:c}=jE(e,t,n,r),u=Pm(a.box,r,yhe(i,e));return Oe.create("Gaussian Density",function(){var l=ie(function*(d){return she(i,s,a.box,c,u,o)});return function(d){return l.apply(this,arguments)}}())}(n,t,r.size,i,a,c).runInContext(s),{transform:l,texture:d,bbox:f,gridDim:p}=u,h=le.mul(le(),l,le.fromScaling(le(),p)),g=le.getScaling(v(),l),y=v.create(0,1,2),b=_u.create(f,p,l,h,g,d,{min:0,max:1,mean:.04,sigma:.01},!0,y,o),x=_e.expand(_e(),t.boundary.sphere,u.maxRadius);return b.setBoundingSphere(x),b}),u7.apply(this,arguments)}const a0t={...Wat,...MC,ignoreHydrogens:C.Boolean(!1),ignoreHydrogensVariant:C.Select("all",C.arrayToOptions(["all","non-polar"])),includeParent:C.Boolean(!1,{isHidden:!0})};function c0t(e){return function $at(e,t){return Mm({...e,setUpdateState:(n,r,i,o,s,a,c)=>{e.setUpdateState(n,r,i,o,s,a,c),Qo.areEqual(o.size,s.size)||(n.createGeometry=!0)},geometryUtils:_u.Utils},t)}({defaultProps:C.getDefaultValues(a0t),createGeometry:s0t,createLocationIterator:gs.fromGroup,getLoci:Sd,eachLocation:xd,setUpdateState:(t,n,r)=>{n.resolution!==r.resolution&&(t.createGeometry=!0),n.radiusOffset!==r.radiusOffset&&(t.createGeometry=!0),n.smoothness!==r.smoothness&&(t.createGeometry=!0),n.ignoreHydrogens!==r.ignoreHydrogens&&(t.createGeometry=!0),n.ignoreHydrogensVariant!==r.ignoreHydrogensVariant&&(t.createGeometry=!0),n.traceOnly!==r.traceOnly&&(t.createGeometry=!0),n.includeParent!==r.includeParent&&(t.createGeometry=!0)},dispose:t=>{t.gridTexture.ref.value.destroy()}},e)}const Jhe={"gaussian-volume":(e,t)=>Iu("Gaussian volume",e,t,o0t),"units-gaussian-volume":(e,t)=>vi("Units-Gaussian volume",e,t,c0t)},eme={...Qhe,jumpLength:C.Numeric(4,{min:0,max:20,step:.1}),visuals:C.MultiSelect(["gaussian-volume"],C.objectToOptions(Jhe))},d0t={name:"gaussian-volume",label:"Gaussian Volume",description:"Displays a gaussian molecular density using direct volume rendering.",factory:function l0t(e,t){return yn.createMulti("Gaussian Volume",e,t,ms,Jhe)},getParams:function u0t(e,t){return eme},defaultValues:C.getDefaultValues(eme),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"physical"},isApplicable:e=>e.elementCount>0},f0t=v.scale,p0t=v.add,h0t=v.sub,l7={...hs,...wU,sizeFactor:C.Numeric(.3,{min:0,max:10,step:.01}),radialSegments:C.Numeric(16,{min:2,max:56,step:2},rt.CustomQualityParamInfo),tryUseImpostor:C.Boolean(!0)};function m0t(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth?function y0t(e){return AU({defaultProps:C.getDefaultValues(l7),createGeometry:g0t,createLocationIterator:t=>lh.fromGroup(t),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r)=>{},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function v0t(e){return Hs({defaultProps:C.getDefaultValues(l7),createGeometry:b0t,createLocationIterator:t=>lh.fromGroup(t),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.radialSegments!==r.radialSegments},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}function g0t(e,t,n,r,i,o){const s=t.polymerElements.length;if(!s)return oc.createEmpty(o);const a=2*s,c=aC.create(a,a/4,o),u=t.conformation,l=v(),d=v(),f=v();cpe(t,function(g,y,b,x,_){u.invariantPosition(g,l),u.invariantPosition(y,d);const A=Ya(_)?A3:w3;p0t(f,l,f0t(f,h0t(f,d,l),A)),c.add(l[0],l[1],l[2],f[0],f[1],f[2],1,!1,!1,2,b),c.add(f[0],f[1],f[2],d[0],d[1],d[2],1,!1,!1,2,x)});const m=c.getCylinders(),h=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return m.setBoundingSphere(h),m}function b0t(e,t,n,r,i,o){const s=t.polymerElements.length;if(!s)return Nt.createEmpty(o);const{radialSegments:a,sizeFactor:c}=i,u=2*a*s*2,l=at.createState(u,u/10,o),d=t.conformation,f=v(),p=v(),m={radiusTop:1,radiusBottom:1,radialSegments:a},h=nt.create(n,t),g=nt.create(n,t);cpe(t,function(_,S,A,E,w){h.element=_,g.element=S,d.invariantPosition(h.element,f),d.invariantPosition(g.element,p);const I=Ya(w)?A3:w3;m.radiusTop=m.radiusBottom=r.size.size(h)*c,l.currentGroup=A,Hn(l,f,p,I,m),m.radiusTop=m.radiusBottom=r.size.size(g)*c,l.currentGroup=E,Hn(l,p,f,1-I,m)});const b=at.getMesh(l),x=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return b.setBoundingSphere(x),b}const d7={...hs,...SU,sizeFactor:C.Numeric(.3,{min:0,max:10,step:.01}),detail:C.Numeric(0,{min:0,max:3,step:1},rt.CustomQualityParamInfo),tryUseImpostor:C.Boolean(!0)};function _0t(e,t,n,r){return n.tryUseImpostor&&r&&r.extensions.fragDepth&&r.extensions.textureFloat?function S0t(e){return CU({defaultProps:C.getDefaultValues(d7),createGeometry:x0t,createLocationIterator:t=>lh.fromGroup(t),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r)=>{},mustRecreate:(t,n,r)=>!n.tryUseImpostor||!r},e)}(e):function w0t(e){return Hs({defaultProps:C.getDefaultValues(d7),createGeometry:C0t,createLocationIterator:t=>lh.fromGroup(t),getLoci:Y0,eachLocation:X0,setUpdateState:(t,n,r)=>{t.createGeometry=n.sizeFactor!==r.sizeFactor||n.detail!==r.detail},mustRecreate:(t,n,r)=>n.tryUseImpostor&&!!r},e)}(e)}function x0t(e,t,n,r,i,o){const s=t.polymerElements.length;if(!s)return fl.createEmpty(o);const a=f1.create(s,s/2,o),c=t.conformation,u=v();upe(t,(p,m)=>{c.invariantPosition(p,u),a.add(u[0],u[1],u[2],m)});const d=a.getSpheres(),f=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return d.setBoundingSphere(f),d}function C0t(e,t,n,r,i,o){const s=t.polymerElements.length;if(!s)return Nt.createEmpty(o);const{detail:a,sizeFactor:c}=i,u=s*xv(a),l=at.createState(u,u/2,o),d=t.conformation,f=v(),p=nt.create(n,t);upe(t,(y,b)=>{p.element=y,d.invariantPosition(p.element,f),l.currentGroup=b,Zn(l,f,r.size.size(p)*c,a)});const h=at.getMesh(l),g=_e.expand(_e(),t.boundary.sphere,1*i.sizeFactor);return h.setBoundingSphere(g),h}const tme={"polymer-backbone-cylinder":(e,t)=>vi("Polymer backbone cylinder",e,t,m0t),"polymer-backbone-sphere":(e,t)=>vi("Polymer backbone sphere",e,t,_0t),"polymer-gap":(e,t)=>vi("Polymer gap cylinder",e,t,Ez)},nme={...d7,...l7,...q3,sizeAspectRatio:C.Numeric(1,{min:.1,max:3,step:.1}),visuals:C.MultiSelect(["polymer-backbone-cylinder","polymer-backbone-sphere","polymer-gap"],C.objectToOptions(tme)),bumpFrequency:C.Numeric(0,{min:0,max:10,step:.1},rt.ShadingCategory),colorMode:C.Select("default",C.arrayToOptions(["default","interpolate"]),{...rt.ShadingCategory,isHidden:!0})},T0t={name:"backbone",label:"Backbone",description:"Displays polymer backbone with cylinders and spheres.",factory:function I0t(e,t){return yn.createMulti("Backbone",e,t,ms,tme)},getParams:function A0t(e,t){const n=C.clone(nme);let r=!1;return t.units.forEach(i=>{!r&&i.gapElements.length&&(r=!0)}),n.visuals.defaultValue=["polymer-backbone-cylinder","polymer-backbone-sphere"],r&&n.visuals.defaultValue.push("polymer-gap"),n},defaultValues:C.getDefaultValues(nme),defaultColorTheme:{name:"chain-id"},defaultSizeTheme:{name:"uniform"},isApplicable:e=>e.polymerResidueCount>0};class kC extends Vae{constructor(){super(),$a(kC.BuiltIn,(t,n)=>{if(t.name!==n)throw new Error(`Fix BuiltInStructureRepresentations to have matching names. ${t.name} ${n}`);this.add(t)})}}!function(e){e.BuiltIn={cartoon:Smt,backbone:T0t,"ball-and-stick":opt,carbohydrate:jpt,ellipsoid:Tmt,"gaussian-surface":tgt,"gaussian-volume":d0t,label:ugt,line:r0t,"molecular-surface":wgt,orientation:kgt,point:Vgt,putty:qgt,spacefill:Ygt}}(kC||(kC={}));class D0t{get isAnimating(){return this._isAnimating}tick(t,n){var r=this;return ie(function*(){var i,o;if(yield r.plugin.managers.animation.tick(t,n?.isSynchronous,n?.animation),null===(i=r.plugin.canvas3d)||void 0===i||i.tick(t,n),lt){const s=null===(o=r.plugin.canvas3d)||void 0===o?void 0:o.webgl.timer.resolve();if(s)for(const a of s)Fre([a])}})()}resetTime(t=yi()){var n;null===(n=this.plugin.canvas3d)||void 0===n||n.resetTime(t)}start(t){var n;null===(n=this.plugin.canvas3d)||void 0===n||n.resume(),this._isAnimating=!0,this.resetTime(),t?.immediate?this.frame():this.currentFrame=requestAnimationFrame(this.frame)}stop(t){var n;this._isAnimating=!1,void 0!==this.currentFrame&&(cancelAnimationFrame(this.currentFrame),this.currentFrame=void 0),t?.noDraw&&(null===(n=this.plugin.canvas3d)||void 0===n||n.pause(t?.noDraw))}constructor(t){this.plugin=t,this.currentFrame=void 0,this._isAnimating=!1,this.frame=()=>{this.tick(yi()),this._isAnimating&&(this.currentFrame=requestAnimationFrame(this.frame))}}}class z1 extends ZS{get animation(){return this.plugin.managers.animation}getSnapshot(t){var n,r,i;const o={...this.snapshotParams.value,...t};return{id:Hr.create22(),data:o.data?this.data.getSnapshot():void 0,behaviour:o.behavior?this.behaviors.getSnapshot():void 0,animation:o.animation?this.animation.getSnapshot():void 0,startAnimation:o.startAnimation?!!o.startAnimation:void 0,camera:o.camera?{current:this.plugin.canvas3d.camera.getSnapshot(),transitionStyle:o.cameraTransition.name,transitionDurationInMs:"animate"===(null===(n=o?.cameraTransition)||void 0===n?void 0:n.name)?o.cameraTransition.params.durationInMs:void 0}:void 0,canvas3dContext:o.canvas3dContext?{props:null===(r=this.plugin.canvas3dContext)||void 0===r?void 0:r.props}:void 0,canvas3d:o.canvas3d?{props:null===(i=this.plugin.canvas3d)||void 0===i?void 0:i.props}:void 0,interactivity:o.interactivity?{props:this.plugin.managers.interactivity.props}:void 0,structureFocus:this.plugin.managers.structure.focus.getSnapshot(),structureSelection:o.structureSelection?this.plugin.managers.structure.selection.getSnapshot():void 0,structureComponentManager:o.componentManager?{options:this.plugin.managers.structure.component.state.options}:void 0,durationInMs:o?.durationInMs}}setSnapshot(t){var n=this;return ie(function*(){var r,i,o,s,a;if(yield n.animation.stop(),!(null===(r=t.structureComponentManager)||void 0===r)&&r.options&&n.plugin.managers.structure.component._setSnapshotState(null===(i=t.structureComponentManager)||void 0===i?void 0:i.options),t.behaviour&&(yield n.plugin.runTask(n.behaviors.setSnapshot(t.behaviour))),t.data&&(yield n.plugin.runTask(n.data.setSnapshot(t.data))),null!==(o=t.canvas3d)&&void 0!==o&&o.props){const c=C.normalizeParams(Xue,t.canvas3d.props,"children");yield Cn.Canvas3D.SetSettings(n.plugin,{settings:c})}if(null!==(s=t.canvas3dContext)&&void 0!==s&&s.props){const c=C.normalizeParams(ME.Params,t.canvas3dContext.props,"children");null===(a=n.plugin.canvas3dContext)||void 0===a||a.setProps(c)}t.interactivity&&t.interactivity.props&&n.plugin.managers.interactivity.setProps(t.interactivity.props),t.structureFocus&&n.plugin.managers.structure.focus.setSnapshot(t.structureFocus),t.structureSelection&&n.plugin.managers.structure.selection.setSnapshot(t.structureSelection),t.animation&&n.animation.setSnapshot(t.animation),t.camera&&Cn.Camera.Reset(n.plugin,{snapshot:t.camera.current,durationMs:"animate"===t.camera.transitionStyle?t.camera.transitionDurationInMs:void 0}),t.startAnimation&&n.animation.start()})()}updateTransform(t,n,r,i){const o=t.build().to(n).update(r);return Cn.State.Update(this.plugin,{state:t,tree:o,options:{canUndo:i}})}hasBehavior(t){return this.behaviors.tree.transforms.has(t.id)}updateBehavior(t,n){const r=this.behaviors.build();if(this.behaviors.tree.transforms.has(t.id))r.to(t.id).update(n);else{const i=t.createDefaultParams(void 0,this.plugin);r.to(tr.getCategoryId(t)).apply(t,c0(i,n),{ref:t.id})}return this.plugin.runTask(this.behaviors.updateTree(r))}dispose(){this.behaviors.cells.forEach(t=>{var n,r,i,o;tr.Behavior.is(t.obj)&&(null===(r=(n=t.obj.data).unregister)||void 0===r||r.call(n),null===(o=(i=t.obj.data).dispose)||void 0===o||o.call(i))}),super.dispose(),this.data.dispose(),this.behaviors.dispose(),this.animation.dispose()}constructor(t){super(),this.plugin=t,this.data=iD.create(new pe.Root({}),{runTask:this.plugin.runTask,globalContext:this.plugin,historyCapacity:this.plugin.config.get(qi.State.HistoryCapacity)}),this.behaviors=iD.create(new tr.Root({}),{runTask:this.plugin.runTask,globalContext:this.plugin,rootState:{isLocked:!0}}),this.events={cell:{stateUpdated:ch(this.data.events.cell.stateUpdated,this.behaviors.events.cell.stateUpdated),created:ch(this.data.events.cell.created,this.behaviors.events.cell.created),removed:ch(this.data.events.cell.removed,this.behaviors.events.cell.removed)},object:{created:ch(this.data.events.object.created,this.behaviors.events.object.created),removed:ch(this.data.events.object.removed,this.behaviors.events.object.removed),updated:ch(this.data.events.object.updated,this.behaviors.events.object.updated)}},this.snapshotParams=this.ev.behavior(z1.DefaultSnapshotParams),this.setSnapshotParams=n=>{this.snapshotParams.next({...z1.DefaultSnapshotParams,...n})}}}!function(e){e.SnapshotParams={durationInMs:C.Numeric(1500,{min:100,max:15e3,step:100},{label:"Duration in ms"}),data:C.Boolean(!0),behavior:C.Boolean(!1),structureSelection:C.Boolean(!1),componentManager:C.Boolean(!0),animation:C.Boolean(!0),startAnimation:C.Boolean(!1),canvas3d:C.Boolean(!0),canvas3dContext:C.Boolean(!0),interactivity:C.Boolean(!0),camera:C.Boolean(!0),cameraTransition:C.MappedStatic("animate",{animate:C.Group({durationInMs:C.Numeric(250,{min:100,max:5e3,step:500},{label:"Duration in ms"})}),instant:C.Group({})},{options:[["animate","Animate"],["instant","Instant"]]}),image:C.Boolean(!1)},e.DefaultSnapshotParams=C.getDefaultValues(e.SnapshotParams)}(z1||(z1={}));class E0t{getDecorator(t){const n=this.plugin.state.data.tree,r=n.children.get(t);if(1!==r.size)return t;const i=r.first();return n.transforms.get(i).transformer.definition.isDecorator?this.getDecorator(i):t}get(t,n=!1){const r=this.root.get(t);if(r)return this.plugin.state.data.cells.get(n?r.ref:this.getDecorator(r.ref))}addMapping(t,n,r){if(!pe.Molecule.Structure.is(r))return!1;if(this.tracked.set(n,r.data),this.root.has(r.data))this.root.get(r.data).count++;else{const i=t.select(In.Generators.byRef(n).rootOfType([pe.Molecule.Structure]))[0];this.root.set(r.data,i?{ref:i.transform.ref,count:1}:{ref:n,count:1})}return!0}removeMapping(t){if(!this.tracked.has(t))return!1;const n=this.tracked.get(t);this.tracked.delete(t);const r=this.root.get(n);return r.count>1?r.count--:this.root.delete(n),!0}updateMapping(t,n,r,i){return!!pe.Molecule.Structure.is(i)&&(this.removeMapping(n),this.addMapping(t,n,i),!0)}dispose(){this.ev.dispose()}constructor(t){this.plugin=t,this.ev=wp.create(),this.events={updated:this.ev(),removed:this.ev()},this.root=new Map,this.tracked=new Map,t.state.data.events.object.created.subscribe(n=>{this.addMapping(n.state,n.ref,n.obj)}),t.state.data.events.object.removed.subscribe(n=>{this.removeMapping(n.ref)&&this.events.removed.next({ref:n.ref,obj:n.obj})}),t.state.data.events.object.updated.subscribe(n=>{this.updateMapping(n.state,n.ref,n.oldObj,n.obj)&&this.events.updated.next({ref:n.ref,oldObj:n.oldObj,obj:n.obj})})}}class f7{constructor(){this.ev=wp.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()}}tryGetAbortTaskId(t){if(this.abortRequests.has(t.progress.taskId))return t.progress.taskId;for(const n of t.children){const r=this.tryGetAbortTaskId(n);if(void 0!==r)return r}}track(t,n){return r=>{var i;if(r.canAbort&&r.requestAbort){const s=this.tryGetAbortTaskId(r.root);void 0!==s&&r.requestAbort(this.abortRequests.get(s))}const o=yi()-r.root.progress.startedTime;this.events.progress.next({id:t,useOverlay:null===(i=this.options.get(n))||void 0===i?void 0:i.useOverlay,level:o<250?"none":"background",progress:r})}}run(t,n){var r=this;return ie(function*(){const i=r.id++;let o;n?.createNewContext||0===r.currentContext.length?o={ctx:LMe(t,r.track(i,t.id),100),refCount:1}:(o=r.currentContext[r.currentContext.length-1],o.refCount++);try{return r.options.set(t.id,{useOverlay:!!n?.useOverlay}),r.runningTasks.add(t.id),yield UZ(o.ctx,t)}finally{r.options.delete(t.id),r.runningTasks.delete(t.id),r.events.finished.next({id:i}),r.abortRequests.delete(t.id),o.refCount--,0===o.refCount&&Xx(r.currentContext,o)}})()}requestAbortAll(t){this.runningTasks.forEach(n=>this.abortRequests.set(n,t))}requestAbort(t,n){this.abortRequests.set("number"==typeof t?t:t.root.progress.taskId,n)}dispose(){this.ev.dispose()}}!function(e){function t(r){return new Promise(i=>setTimeout(i,r))}e.testTask=function n(r){return Oe.create("Test",function(){var i=ie(function*(o){let s=0;for(;s!!n&&n.key===t)}show(t){let r,n=this.state.entries;const i=++this.serialId;let o;t.key&&(r=this.findByKey(t.key))?(void 0!==r.timeout&&clearTimeout(r.timeout),o=r.serialNumber,n=n.remove(r.id)):o=++this.serialNumber,r={id:i,serialNumber:o,key:t.key,title:t.title,message:t.message,timeout:this.timeout(i,t.timeoutMs),hide:()=>this.hideId(i)},this.updateState({entries:n.set(i,r)})&&this.events.changed.next(void 0)}timeout(t,n){if(void 0!==n)return n<0&&(n=500),setTimeout(()=>{const r=this.state.entries.get(t);r.timeout=void 0,this.hide(r)},n)}hideId(t){this.hide(this.state.entries.get(t))}hide(t){t&&(void 0!==t.timeout&&clearTimeout(t.timeout),t.hide=void 0,this.updateState({entries:this.state.entries.delete(t.id)})&&this.events.changed.next(void 0))}constructor(t){super({entries:ol()}),this.events={changed:this.ev()},this.serialNumber=0,this.serialId=0,Cn.Toast.Show.subscribe(t,n=>this.show(n)),Cn.Toast.Hide.subscribe(t,n=>this.hide(this.findByKey(n.key)))}}class M0t extends ZS{createParams(){const t=Math.min(this.plugin.canvas3d?this.plugin.canvas3d.webgl.maxRenderbufferSize:4096,4096);return{resolution:C.MappedStatic("viewport",{viewport:C.Group({}),hd:C.Group({}),"full-hd":C.Group({}),"ultra-hd":C.Group({}),custom:C.Group({width:C.Numeric(1920,{min:128,max:t,step:1}),height:C.Numeric(1080,{min:128,max:t,step:1})},{isFlat:!0})},{options:[["viewport","Viewport"],["hd","HD (1280 x 720)"],["full-hd","Full HD (1920 x 1080)"],["ultra-hd","Ultra HD (3840 x 2160)"],["custom","Custom"]]}),transparent:C.Boolean(!1),axes:IE.axes}}get params(){return this._params?this._params:this._params=this.createParams()}get values(){return this.behaviors.values.value}get cropParams(){return this.behaviors.cropParams.value}get relativeCrop(){return this.behaviors.relativeCrop.value}getCanvasSize(){var t,n;return{width:(null===(t=this.plugin.canvas3d)||void 0===t?void 0:t.webgl.gl.drawingBufferWidth)||0,height:(null===(n=this.plugin.canvas3d)||void 0===n?void 0:n.webgl.gl.drawingBufferHeight)||0}}getSize(){const t=this.values;switch(t.resolution.name){case"viewport":return this.getCanvasSize();case"hd":return{width:1280,height:720};case"full-hd":return{width:1920,height:1080};case"ultra-hd":return{width:3840,height:2160};default:return{width:t.resolution.params.width,height:t.resolution.params.height}}}createPass(t){const n=this.plugin.canvas3d,{colorBufferFloat:r,textureFloat:i}=n.webgl.extensions,o=n.props.postprocessing.occlusion;return n.getImagePass({transparentBackground:this.values.transparent,cameraHelper:{axes:this.values.axes},multiSample:{...n.props.multiSample,mode:t?"on":"off",sampleLevel:r&&i?4:2},postprocessing:{...n.props.postprocessing,occlusion:"on"===o.name?{name:"on",params:{...o.params,samples:128,resolutionScale:n.webgl.pixelRatio}}:o},marking:{...n.props.marking}})}get previewPass(){return this._previewPass||(this._previewPass=this.createPass(!1))}get imagePass(){if(this._imagePass){const t=this.plugin.canvas3d,n=t.props.postprocessing.occlusion;return this._imagePass.setProps({cameraHelper:{axes:this.values.axes},transparentBackground:this.values.transparent,postprocessing:{...t.props.postprocessing,occlusion:"on"===n.name?{name:"on",params:{...n.params,samples:128,resolutionScale:t.webgl.pixelRatio}}:n},marking:{...t.props.marking}}),this._imagePass}return this._imagePass=this.createPass(!0)}getFilename(t=".png"){const n=this.plugin.state.data.select(In.Generators.rootsOfType(pe.Molecule.Model)).map(o=>o.obj.data),r=new Set;return n.forEach(o=>r.add(o.entryId.toUpperCase())),`${Si.toArray(r).join("-")||"molstar-image"}${t}`}resetCrop(){this.behaviors.relativeCrop.next({x:0,y:0,width:1,height:1})}toggleAutocrop(){this.cropParams.auto?(this.behaviors.cropParams.next({...this.cropParams,auto:!1}),this.resetCrop()):this.behaviors.cropParams.next({...this.cropParams,auto:!0})}get isFullFrame(){const t=this.relativeCrop;return ai(t.x,0,1e-5)&&ai(t.y,0,1e-5)&&ai(t.width,1,1e-5)&&ai(t.height,1,1e-5)}autocrop(t=this.cropParams.relativePadding){const{data:n,width:r,height:i}=this.previewData.image,o=this.previewData.transparent,s=o?this.previewData.background:4278190080|this.previewData.background;let a=r,c=0,u=i,l=0;for(let m=0;mc&&(c=g),ml&&(l=m)}}if(a>c){const m=a;a=c,c=m}if(u>l){const m=u;u=l,l=m}const d=c-a+1,f=l-u+1;a-=t*d,c+=t*d,u-=t*f,l+=t*f;const p={x:Math.max(0,a/r),y:Math.max(0,u/i),width:Math.min(1,(c-a+1)/r),height:Math.min(1,(l-u+1)/i)};this.behaviors.relativeCrop.next(p)}getPreview(t=320){const{width:n,height:r}=this.getSize();if(n<=0||r<=0)return;const i=n/r;let o=0,s=0;i>1?(o=t,s=Math.round(t/i)):(s=t,o=Math.round(t*i));const a=this.plugin.canvas3d.props;this.previewPass.setProps({cameraHelper:{axes:this.values.axes},transparentBackground:this.values.transparent,postprocessing:a.postprocessing,marking:a.marking});const c=this.previewPass.getImageData(o,s),u=this.previewCanvas;u.width=c.width,u.height=c.height,this.previewData.image=c,this.previewData.background=a.renderer.backgroundColor,this.previewData.transparent=this.values.transparent;const l=u.getContext("2d");if(!l)throw new Error("Could not create canvas 2d context");return l.putImageData(c,0,0),this.cropParams.auto&&this.autocrop(),this.events.previewed.next(void 0),{canvas:u,width:o,height:s}}getSizeAndViewport(){const{width:t,height:n}=this.getSize(),r=this.relativeCrop,i={x:Math.floor(r.x*t),y:Math.floor(r.y*n),width:Math.ceil(r.width*t),height:Math.ceil(r.height*n)};return i.width+i.x>t&&(i.width=t-i.x),i.height+i.y>n&&(i.height=n-i.y),{width:t,height:n,viewport:i}}draw(t){var n=this;return ie(function*(){const{width:r,height:i,viewport:o}=n.getSizeAndViewport();if(r<=0||i<=0)return;yield t.update("Rendering image...");const s=n.imagePass;yield s.updateBackground();const a=s.getImageData(r,i,o);yield t.update("Encoding image...");const c=n.canvas;c.width=a.width,c.height=a.height;const u=c.getContext("2d");if(!u)throw new Error("Could not create canvas 2d context");u.putImageData(a,0,0)})()}copyToClipboardTask(){var t=this;const n=navigator.clipboard;if(n?.write)return Oe.create("Copy Image",function(){var r=ie(function*(i){yield t.draw(i),yield i.update("Converting image...");const o=yield v8(t.canvas,"png"),s=new ClipboardItem({"image/png":o});yield n.write([s]),t.plugin.log.message("Image copied to clipboard.")});return function(i){return r.apply(this,arguments)}}());this.plugin.log.error("clipboard.write not supported!")}getImageDataUri(){var t=this;return this.plugin.runTask(Oe.create("Generate Image",function(){var n=ie(function*(r){return yield t.draw(r),yield r.update("Converting image..."),t.canvas.toDataURL("png")});return function(r){return n.apply(this,arguments)}}()))}copyToClipboard(){const t=this.copyToClipboardTask();if(t)return this.plugin.runTask(t)}downloadTask(t){var n=this;return Oe.create("Download Image",function(){var r=ie(function*(i){yield n.draw(i),yield i.update("Downloading image..."),Bce(yield v8(n.canvas,"png"),t??n.getFilename())});return function(i){return r.apply(this,arguments)}}())}download(t){this.plugin.runTask(this.downloadTask(t))}constructor(t){super(),this.plugin=t,this._params=void 0,this.behaviors={values:this.ev.behavior({transparent:this.params.transparent.defaultValue,axes:{name:"off",params:{}},resolution:this.params.resolution.defaultValue}),cropParams:this.ev.behavior({auto:!0,relativePadding:.1}),relativeCrop:this.ev.behavior({x:0,y:0,width:1,height:1})},this.events={previewed:this.ev()},this.canvas=document.createElement("canvas"),this.previewCanvas=document.createElement("canvas"),this.previewData={image:{data:new Uint8ClampedArray(1),width:1,height:0},background:st(0),transparent:!1}}}class R0t{addHandler(t,n){const r=this.handlers.findIndex(i=>i[0]===t);r<0?this.handlers.push([t,n]):this.handlers[r][1]=n}removeHandler(t){const n=this.handlers.findIndex(r=>r[0]===t);n>=0&&this.handlers.splice(n,1)}handle(t){var n=this;return ie(function*(){for(let r=n.handlers.length-1;r>=0;r--){const i=n.handlers[r][1];if(yield i(t,n.plugin))return}!function k0t(e,t){const n=t.filter(r=>{const i=r.name.toLowerCase();return i.endsWith(".molx")||i.endsWith(".molj")});n.length>0?Cn.State.Snapshots.OpenFile(e,{file:n[0]}):e.runTask(e.state.data.applyAction(Pde,{files:t.map(r=>fr.File(r)),format:{name:"auto",params:{}},visuals:!0}))}(n.plugin,t)})()}dispose(){this.handlers.length=0}constructor(t){this.plugin=t,this.handlers=[]}}class N0t{get isInitialized(){return this._isInitialized}build(){return this.state.data.build()}initContainer(t){var n;if(this.canvasContainer)return!0;const r=document.createElement("div");Object.assign(r.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"});let i=null===(n=t?.canvas3dContext)||void 0===n?void 0:n.canvas;return i||(i=document.createElement("canvas"),t?.checkeredCanvasBackground&&Object.assign(i.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"}),r.appendChild(i)),!!this.initViewer(i,r,t?.canvas3dContext)&&(this.canvasContainer=r,!0)}mount(t,n){var r;if(this.disposed)throw new Error("Cannot mount a disposed context");return!!this.initContainer(n)&&(this.canvasContainer.parentElement!==t&&(null===(r=this.canvasContainer.parentElement)||void 0===r||r.removeChild(this.canvasContainer)),t.appendChild(this.canvasContainer),this.handleResize(),!0)}unmount(){var t,n;null===(n=null===(t=this.canvasContainer)||void 0===t?void 0:t.parentElement)||void 0===n||n.removeChild(this.canvasContainer)}initViewer(t,n,r){var i,o,s,a,c,u;try{this.layout.setRoot(n),this.spec.layout&&this.spec.layout.initial&&this.layout.setProps(this.spec.layout.initial),r||(r=ME.fromCanvas(t,this.managers.asset,{antialias:!(null!==(i=this.config.get(qi.General.DisableAntialiasing))&&void 0!==i&&i),preserveDrawingBuffer:!(null!==(o=this.config.get(qi.General.DisablePreserveDrawingBuffer))&&void 0!==o&&o),preferWebGl1:this.config.get(qi.General.PreferWebGl1)||!1,failIfMajorPerformanceCaveat:!(null!==(s=this.config.get(qi.General.AllowMajorPerformanceCaveat))&&void 0!==s&&s),powerPreference:this.config.get(qi.General.PowerPreference)||"high-performance",handleResize:this.handleResize},{pixelScale:this.config.get(qi.General.PixelScale)||1,pickScale:this.config.get(qi.General.PickScale)||.25,transparency:this.config.get(qi.General.Transparency)||"wboit"})),this.canvas3dContext=r,this.canvas3d=H8.create(this.canvas3dContext),this.canvas3dInit.next(!0);let l=this.spec.canvas3d;const d=st(16579577);return l?(void 0===(null===(c=l.renderer)||void 0===c?void 0:c.backgroundColor)&&(l=c0(l,f=>{f.renderer?f.renderer.backgroundColor=d:f.renderer={backgroundColor:d}})),null===(u=this.canvas3d)||void 0===u||u.setProps(l)):null===(a=this.canvas3d)||void 0===a||a.setProps({renderer:{backgroundColor:d}}),this.animationLoop.start(),this.helpers.viewportScreenshot=new M0t(this),this.subs.push(this.canvas3d.interaction.click.subscribe(f=>this.behaviors.interaction.click.next(f))),this.subs.push(this.canvas3d.interaction.drag.subscribe(f=>this.behaviors.interaction.drag.next(f))),this.subs.push(this.canvas3d.interaction.hover.subscribe(f=>this.behaviors.interaction.hover.next(f))),this.subs.push(this.canvas3d.input.resize.pipe(afe(50),Fde(100,void 0,{leading:!1,trailing:!0})).subscribe(()=>this.handleResize())),this.subs.push(this.canvas3d.input.keyDown.subscribe(f=>this.behaviors.interaction.key.next(f))),this.subs.push(this.canvas3d.input.keyUp.subscribe(f=>this.behaviors.interaction.keyReleased.next(f))),this.subs.push(this.layout.events.updated.subscribe(()=>requestAnimationFrame(()=>this.handleResize()))),this.handleResize(),Zx.setImmediate(()=>this.initCanvas3dPromiseCallbacks[0]()),!0}catch(l){return this.log.error(""+l),console.error(l),Zx.setImmediate(()=>this.initCanvas3dPromiseCallbacks[1](l)),!1}}get isBusy(){return this.behaviors.state.isAnimating.value||this.behaviors.state.isUpdating.value}get selectionMode(){return this.behaviors.interaction.selectionMode.value}set selectionMode(t){this.behaviors.interaction.selectionMode.next(t)}dataTransaction(t,n){return this.runTask(this.state.data.transaction(t,n))}clear(t=!1){var n;return t&&(null===(n=this.canvas3d)||void 0===n||n.setProps(j8)),Cn.State.RemoveObject(this,{state:this.state.data,ref:ur.RootRef})}dispose(t){var n,r;if(!this.disposed){for(const i of this.subs)i.unsubscribe();this.subs=[],this.animationLoop.stop(),this.commands.dispose(),null===(n=this.canvas3d)||void 0===n||n.dispose(),null===(r=this.canvas3dContext)||void 0===r||r.dispose(t),this.ev.dispose(),this.state.dispose(),this.helpers.substructureParent.dispose(),$a(this.managers,i=>{var o;return null===(o=i?.dispose)||void 0===o?void 0:o.call(i)}),$a(this.managers.structure,i=>{var o;return null===(o=i?.dispose)||void 0===o?void 0:o.call(i)}),$a(this.managers.volume,i=>{var o;return null===(o=i?.dispose)||void 0===o?void 0:o.call(i)}),this.unmount(),this.canvasContainer=void 0,this.customState={},this.disposed=!0}}initBehaviorEvents(){this.subs.push(ch(this.state.data.behaviors.isUpdating,this.state.behaviors.behaviors.isUpdating).subscribe(s=>{this.behaviors.state.isUpdating.value!==s&&this.behaviors.state.isUpdating.next(s)}));const t=this.config.get(qi.General.IsBusyTimeoutMs)||750,n=this.behaviors.state.isBusy;let r;const i=()=>{n.value||n.next(!0)},o=()=>{void 0!==r&&clearTimeout(r),r=void 0};this.subs.push(ch(this.behaviors.state.isUpdating,this.behaviors.state.isAnimating).subscribe(s=>{this.behaviors.state.isUpdating.value||this.behaviors.state.isAnimating.value?n.value||(o(),r=setTimeout(i,t)):(o(),n.next(!1))})),this.subs.push(this.behaviors.interaction.selectionMode.subscribe(s=>{var a;s||null===(a=this.managers.interactivity)||void 0===a||a.lociSelects.deselectAll()}))}initBuiltInBehavior(){ZE.State.registerDefault(this),ZE.Representation.registerDefault(this),ZE.Camera.registerDefault(this),ZE.Misc.registerDefault(this),this.subs.push(ch(this.state.data.events.log,this.state.behaviors.events.log).subscribe(t=>this.events.log.next(t)))}initBehaviors(){var t=this;return ie(function*(){let n=t.state.behaviors.build();for(const r of Object.keys(tr.Categories))n.toRoot().apply(tr.CreateCategory,{label:tr.Categories[r]},{ref:r,state:{isLocked:!0}});for(const r of t.spec.behaviors)"custom-props"===tr.getCategoryId(r.transformer)&&n.to(tr.getCategoryId(r.transformer)).apply(r.transformer,r.defaultParams,{ref:r.transformer.id});yield t.runTask(t.state.behaviors.updateTree(n,{doNotUpdateCurrent:!0,doNotLogTiming:!0})),n=t.state.behaviors.build();for(const r of t.spec.behaviors)"custom-props"!==tr.getCategoryId(r.transformer)&&n.to(tr.getCategoryId(r.transformer)).apply(r.transformer,r.defaultParams,{ref:r.transformer.id});yield t.runTask(t.state.behaviors.updateTree(n,{doNotUpdateCurrent:!0,doNotLogTiming:!0}))})()}initCustomFormats(){if(this.spec.customFormats)for(const t of this.spec.customFormats)this.dataFormats.add(t[0],t[1])}initAnimations(){if(this.spec.animations)for(const t of this.spec.animations)this.managers.animation.register(t)}initDataActions(){if(this.spec.actions)for(const t of this.spec.actions)this.state.data.actions.add(t.action)}init(){var t=this;return ie(function*(){try{t.subs.push(t.events.log.subscribe(n=>t.log.entries=t.log.entries.push(n))),t.initCustomFormats(),t.initBehaviorEvents(),t.initBuiltInBehavior(),t.managers.interactivity=new Lm(t),t.managers.lociLabels=new Xdt(t),t.builders.structure=new Sdt(t),t.initAnimations(),t.initDataActions(),yield t.initBehaviors(),t.log.message(`Mol* Plugin 4.0.1 [${btt.toLocaleString()}]`),Qx||t.log.message("Development mode enabled"),un&&t.log.message("Debug mode enabled"),t._isInitialized=!0,t.initializedPromiseCallbacks[0]()}catch(n){throw t.initializedPromiseCallbacks[1](n),n}})()}constructor(t){var n;this.spec=t,this.runTask=(r,i)=>this.managers.task.run(r,i),this.resolveTask=r=>{if(r)return Oe.is(r)?this.runTask(r):r},this.subs=[],this.initCanvas3dPromiseCallbacks=[()=>{},()=>{}],this._isInitialized=!1,this.initializedPromiseCallbacks=[()=>{},()=>{}],this.disposed=!1,this.canvasContainer=void 0,this.ev=wp.create(),this.config=new Itt(this.spec.config),this.state=new z1(this),this.commands=new ptt,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:yn.Loci.Empty,modifiers:wu.None,buttons:0,button:0}),click:this.ev.behavior({current:yn.Loci.Empty,modifiers:wu.None,buttons:0,button:0}),drag:this.ev.behavior({current:yn.Loci.Empty,modifiers:wu.None,buttons:0,button:0,pageStart:Me(),pageEnd:Me()}),key:this.ev.behavior(rue),keyReleased:this.ev.behavior(rue),selectionMode:this.ev.behavior(!1)},labels:{highlight:this.ev.behavior({labels:[]})},layout:{leftPanelTabName:this.ev.behavior("root")},canvas3d:{initialized:this.canvas3dInit.pipe(Yl(r=>!!r),Sg(1))}},this.canvas3dInitialized=new Promise((r,i)=>{this.initCanvas3dPromiseCallbacks=[r,i]}),this.initialized=new Promise((r,i)=>{this.initializedPromiseCallbacks=[r,i]}),this.layout=new Oft(this),this.animationLoop=new D0t(this),this.representation={structure:{registry:new kC,themes:{colorThemeRegistry:Lc.createRegistry(),sizeThemeRegistry:Qo.createRegistry()}},volume:{registry:new u1,themes:{colorThemeRegistry:Lc.createRegistry(),sizeThemeRegistry:Qo.createRegistry()}}},this.query={structure:{registry:new rYe}},this.dataFormats=new Rdt,this.builders={data:new mdt(this),structure:void 0},this.helpers={substructureParent:new E0t(this),viewportScreenshot:void 0},this.managers={structure:{hierarchy:new xC(this),component:new _C(this),measurement:new vft(this),selection:new xft(this),focus:new eft(this)},volume:{hierarchy:new RV(this)},interactivity:void 0,camera:new Ydt(this),animation:new kdt(this),snapshot:new qv(this),lociLabels:void 0,toast:new P0t(this),asset:new TLe,task:new f7,dragAndDrop:new R0t(this)},this.events={log:this.ev(),task:this.managers.task.events,canvas3d:{settingsUpdated:this.ev()}},this.customModelProperties=new u3.Registry,this.customStructureProperties=new u3.Registry,this.customStructureControls=new Map,this.customImportControls=new Map,this.genericRepresentationControls=new Map,this.customState=Object.create(null),this.handleResize=()=>{var r,i;const o=null===(r=this.canvas3dContext)||void 0===r?void 0:r.canvas,s=this.layout.root;s&&o&&(function _tt(e,t,n=1){let r=window.innerWidth,i=window.innerHeight;t!==document.body&&(r=t.offsetWidth,i=t.offsetHeight),function vtt(e,t,n,r=1){e.width=Math.round(window.devicePixelRatio*r*t),e.height=Math.round(window.devicePixelRatio*r*n),Object.assign(e.style,{width:`${t}px`,height:`${n}px`})}(e,r,i,n)}(o,s,this.canvas3dContext.props.pixelScale),null===(i=this.canvas3d)||void 0===i||i.requestResize())},this.log={entries:Cp(),entry:r=>this.events.log.next(r),error:r=>this.events.log.next(df.error(r)),message:r=>this.events.log.next(df.message(r)),info:r=>this.events.log.next(df.info(r)),warn:r=>this.events.log.next(df.warning(r))},this.fetch=MO,EVe(!1),function GNe(e){up="default"===e?UQ:zNe}(null!==(n=this.config.get(qi.Structure.SaccharideCompIdMapType))&&void 0!==n?n:"default")}}let NC=(()=>{class e{set container(n){this.container$.next(n)}constructor(n){this.settingsService=n,this.container$=new ou(1),this.plugin=new N0t({actions:[an.Action(V0.Structure.DownloadStructure),an.Action(V0.Volume.DownloadDensity),an.Action(V0.DataFormat.DownloadFile),an.Action(V0.DataFormat.OpenFiles),an.Action(V0.Structure.LoadTrajectory),an.Action(V0.Structure.EnableModelCustomProps),an.Action(V0.Structure.EnableStructureCustomProps),an.Action(adt),an.Action(cdt),an.Action(rfe),an.Action(Ye.Data.Download),an.Action(Ye.Data.ParseCif),an.Action(Ye.Data.ParseCcp4),an.Action(Ye.Data.ParseDsn6),an.Action(Ye.Model.TrajectoryFromMmCif),an.Action(Ye.Model.TrajectoryFromCifCore),an.Action(Ye.Model.TrajectoryFromPDB),an.Action(Ye.Model.TransformStructureConformation),an.Action(Ye.Model.StructureFromModel),an.Action(Ye.Model.StructureFromTrajectory),an.Action(Ye.Model.ModelFromTrajectory),an.Action(Ye.Model.StructureSelectionFromScript),an.Action(Ye.Representation.StructureRepresentation3D),an.Action(Ye.Representation.StructureSelectionsDistance3D),an.Action(Ye.Representation.StructureSelectionsAngle3D),an.Action(Ye.Representation.StructureSelectionsDihedral3D),an.Action(Ye.Representation.StructureSelectionsLabel3D),an.Action(Ye.Representation.StructureSelectionsOrientation3D),an.Action(Ye.Representation.ModelUnitcell3D),an.Action(Ye.Representation.StructureBoundingBox3D),an.Action(Ye.Representation.ExplodeStructureRepresentation3D),an.Action(Ye.Representation.SpinStructureRepresentation3D),an.Action(Ye.Representation.UnwindStructureAssemblyRepresentation3D),an.Action(Ye.Representation.OverpaintStructureRepresentation3DFromScript),an.Action(Ye.Representation.TransparencyStructureRepresentation3DFromScript),an.Action(Ye.Representation.ClippingStructureRepresentation3DFromScript),an.Action(Ye.Representation.SubstanceStructureRepresentation3DFromScript),an.Action(Ye.Representation.ThemeStrengthRepresentation3D),an.Action(Ede),an.Action(Ye.Volume.VolumeFromCcp4),an.Action(Ye.Volume.VolumeFromDsn6),an.Action(Ye.Volume.VolumeFromCube),an.Action(Ye.Volume.VolumeFromDx),an.Action(Ye.Representation.VolumeRepresentation3D)],behaviors:[an.Behavior(zc.Representation.HighlightLoci),an.Behavior(zc.Representation.SelectLoci),an.Behavior(zc.Representation.DefaultLociLabelProvider),an.Behavior(zc.Representation.FocusLoci),an.Behavior(zc.Camera.FocusLoci),an.Behavior(zc.Camera.CameraAxisHelper),an.Behavior(zc.Camera.CameraControls),an.Behavior(JE),an.Behavior(zc.CustomProps.StructureInfo),an.Behavior(zc.CustomProps.AccessibleSurfaceArea),an.Behavior(zc.CustomProps.BestDatabaseSequenceMapping),an.Behavior(zc.CustomProps.Interactions),an.Behavior(zc.CustomProps.SecondaryStructure),an.Behavior(zc.CustomProps.ValenceModel),an.Behavior(zc.CustomProps.CrossLinkRestraint)],animations:[gtt,mtt,pdt,ytt,htt,fdt,ddt]});const r=this.settingsService.settings$;this.plugin$=this.container$.pipe(qt(i=>{const o=i.nativeElement;return{div:o,canvas:o.firstElementChild}}),jr(({div:i,canvas:o})=>this.plugin.initViewer(o,i)),To(()=>$i(this.plugin.init())),qt(()=>this.plugin),Zl(1),Lb(r),qt(([i,o])=>{if(i.canvas3d){const[s,a]=XS(o["background-color"]);i.canvas3d.setProps({renderer:{backgroundColor:s,pickingAlphaThreshold:a}})}return i}))}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(KS))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})(),J3=(()=>{class e{set source(n){this.source$.next(n)}constructor(n,r){var i=this;this.settingsService=n,this.pluginService=r,this.source$=new ou,this.structure$=uI([this.pluginService.plugin$,this.source$]).pipe(qt(([a,c])=>({plugin:a,source:c})),To(({source:a})=>$i(ie(function*(){return"local"===a.type?{data:yield i.parseLocalSource(a),source:a}:{data:yield i.parseRemoteSource(a),source:a}})())),To(({data:a,source:c})=>$i(ie(function*(){const u=i.pluginService.plugin,l=yield u.builders.structure.parseTrajectory(a,c.format),d=yield u.builders.structure.createModel(l,{modelIndex:0}),m=yield u.builders.structure.createStructure(d,{name:"model",params:{}}),h=yield u.builders.structure.tryCreateComponentStatic(m,"polymer",{label:c.label}),[g]=XS(i.settingsService.settings["backbone-color"]);return yield u.builders.structure.representation.addRepresentation(h,{type:"cartoon",color:"uniform",colorParams:{value:g}}),m.cell?.obj?.data})())),jr(a=>{let c=0;const u=this.r2i=new Map,l=this.i2r=new Map;Ve.eachAtomicHierarchyElement(a,{residue:d=>{const f=Ze.residue.auth_seq_id(d),p=Ze.residue.pdbx_PDB_ins_code(d),h=(Ze.chain.auth_asym_id(d)+f+p).trim();u.set(h,c),l.set(c,h),c++}})}),Zl(1))}parseRemoteSource(n){var r=this;return ie(function*(){const i=fr.Url(n.link);return r.pluginService.plugin.builders.data.download({url:i,label:n.label,isBinary:n.binary})})()}parseLocalSource(n){var r=this;return ie(function*(){const i=n.binary,o=n.label,s=r.pluginService.plugin;if("string"==typeof n.data)return s.builders.data.rawData({data:n.data,label:o});let a;a=n.data instanceof File?fr.File(n.data):fr.File(new File([n.data],`${o}.${"mmcif"===n.format?"cif":"ent"}`));const{data:c}=yield s.builders.data.readFile({file:a,label:o,isBinary:i});return c})()}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(KS),Zt(NC))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();function p7(e,t){return function F0t(e,t){const n=ko.getStructureSelection(e,t);return pt.toLociWithSourceUnits(n)}(ue.struct.generator.atomGroups({"residue-test":ue.core.set.has([ue.set(...e),ue.core.str.concat([ue.ammp("auth_asym_id"),ue.ammp("auth_seq_id"),ue.ammp("pdbx_PDB_ins_code")])])}),t)}let rme=(()=>{class e{set loci(n){this.loci$.next(n)}set interactions(n){this.interactions$.next(n)}constructor(n,r,i){this.structureService=n,this.settingsService=r,this.pluginService=i,this.loci$=new ou(1),this.interactions$=new ou(1);const o=this.getLociRepresentation(),s=this.getInteractionsRepresentation();this.representation$=this.structureService.structure$.pipe(Lb(o),Lb(s),qt(()=>{}),Zl(1)),this._representation=this.representation$.subscribe()}ngOnDestroy(){this._representation.unsubscribe()}getLociRepresentation(){return this.structureService.structure$.pipe(Lb(this.loci$),qt(([n,r])=>({structure:n,loci:r})),qt(({structure:n,loci:r})=>{const i=[...this.structureService.i2r.values()];return{structure:n,loci:r.map(s=>{if(s.start){s={...s,end:s.end||s.start};const a=this.structureService.r2i.get(s.chain+s.start),c=this.structureService.r2i.get(s.chain+s.end);return{...s,ids:i.slice(a,c+1)}}return{...s,ids:i.filter(a=>a.startsWith(s.chain))}})}}),To(({structure:n,loci:r})=>{const i=[];for(const{ids:c,color:u}of r){const l=p7(c,n),d=Kn.fromLoci(l),[f]=XS(u||this.settingsService.settings["backbone-color"]);i.push({bundle:d,color:f,clear:!1})}const o=this.pluginService.plugin,s=o.state.data.build(),a=function B0t(e,t){const n=Bo.ofBundle(e,t.root),r=Bo.merge(n);return Bo.filter(r,t)}(i,n);for(const c of o.managers.structure.hierarchy.current.structures)for(const u of c.components)for(const l of u.representations){s.to(l.cell.transform.ref).apply(Ye.Representation.OverpaintStructureRepresentation3DFromBundle,Bo.toBundle(a));const d=p7([...this.structureService.i2r.values()],n),f=Kn.fromLoci(d),[p,m]=XS(this.settingsService.settings["backbone-color"]);s.to(l.cell.transform.ref).apply(Ye.Representation.TransparencyStructureRepresentation3DFromBundle,{layers:[{bundle:f,value:m}]})}return $i(s.commit({doNotUpdateCurrent:!0}))}))}getInteractionsRepresentation(){let n;return this.structureService.structure$.pipe(Lb(this.interactions$),qt(([r,i])=>({structure:r,interactions:i})),qt(({structure:r,interactions:i})=>{const o=i.reduce((s,{from:a,to:c})=>[...s,a,c],[]);return Ve.eachAtomicHierarchyElement(r,{atom:s=>{const a=v.create(Ze.atom.x(s),Ze.atom.y(s),Ze.atom.z(s));for(const c of o)c.coordinates||(c["atom.id"]===Ze.atom.id(s)||c["chain.id"]===Ze.chain.auth_asym_id(s)&&c["residue.id"]===Ze.residue.auth_seq_id(s)+Ze.residue.pdbx_PDB_ins_code(s)&&c["atom.name"]===Ze.atom.auth_atom_id(s))&&(c.coordinates=a)}}),{structure:r,interactions:i=i.filter(({from:s,to:a})=>s.coordinates&&a.coordinates)}}),To(({interactions:r})=>{const o=this.pluginService.plugin.state.data.build(),s=r.map(({from:c,to:u,color:l,label:d,size:f})=>({from:c.coordinates,to:u.coordinates,color:XS(l||this.settingsService.settings["interaction-color"]).at(0),size:f||this.settingsService.settings["interaction-size"],label:d}));return n&&o.delete(n),n=o.toRoot().apply(ftt,{data:s}).apply(Ye.Representation.ShapeRepresentation3D).ref,$i(o.commit({doNotUpdateCurrent:!0}))}),Zl(1))}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(J3),Zt(KS),Zt(NC))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();let ime=(()=>{class e{set highlights(n){this.input$.next(n)}constructor(n,r){this.structureService=n,this.pluginService=r,this.input$=new ou(1);const i=this.pluginService.plugin,o=i.behaviors.interaction.hover,s=this.structureService.structure$.pipe(Lb(this.input$),qt(([c,u])=>({structure:c,highlights:u})),qt(({structure:c,highlights:u})=>{if(u){const l=[...this.structureService.i2r.values()],d=this.structureService.r2i.get(u.chain+u.start),f=this.structureService.r2i.get(u.chain+u.end);return{structure:c,highlights:{...u,ids:l.slice(d,f+1)}}}return{structure:c,highlights:{start:"",end:"",chain:"",ids:[]}}}),qt(({structure:c,highlights:u})=>{if(u.ids.length>0){const l=p7(u.ids,c);i.managers.interactivity.lociHighlights.highlightOnly({loci:l})}}));this.output$=o.pipe(qt(c=>{if(c&&"element-loci"===c.current.loci.kind&&De.is(c.current.loci)){const u=De.getFirstLocation(c.current.loci);if(u){const l=Ze.chain.auth_asym_id(u),p=Ze.residue.auth_seq_id(u)+Ze.residue.pdbx_PDB_ins_code(u);return{start:p,end:p+"",chain:l}}}}),Zl(1),jr(c=>console.log("Highlighted",c)));const a=s.pipe(function L0t(...e){return function O0t(...e){const t=Sb(e),n=yK(e,1/0);return e=CZ(e),mo((r,i)=>{xg(n)($i([r,...e],t)).subscribe(i)})}(...e)}(this.output$),qt(()=>{}));this._highlights=a.subscribe()}ngOnDestroy(){this._highlights.unsubscribe()}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(J3),Zt(NC))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();const U0t=["container"];let eP=(()=>{class e{set container(n){this.pluginService.container=n}set source(n){this.structureService.source=n}set loci(n){this.representationService.loci=n}set interactions(n){this.representationService.interactions=n}set settings(n){this.settingsService.settings=n}set highlights(n){this.highlightService.highlights=n}constructor(n,r,i,o,s){this.representationService=n,this.highlightService=r,this.structureService=i,this.settingsService=o,this.pluginService=s,this.highlights$=this.highlightService.output$}static#e=this.\u0275fac=function(r){return new(r||e)(cn(rme),cn(ime),cn(J3),cn(KS),cn(NC))};static#t=this.\u0275cmp=Mu({type:e,selectors:[["ngx-structure-viewer"]],viewQuery:function(r,i){if(1&r&&uN(U0t,5),2&r){let o;EA(o=PA())&&(i.container=o.first)}},inputs:{source:"source",loci:"loci",interactions:"interactions",settings:"settings",highlights:"highlights"},outputs:{highlights$:"highlights"},standalone:!0,features:[mN([rme,ime,J3,KS,NC]),Nu],decls:4,vars:0,consts:[["container",""],["canvas",""],[2,"position","relative","width","100%","height","100%"],[2,"position","absolute","left","0","top","0","width","100%","height","100%"]],template:function(r,i){1&r&&(dn(0,"div",2,0),gi(2,"canvas",3,1),fn())}})}return e})();function ome(e=0,t=r3){return e<0&&(e=0),Nde(e,e,t)}const sme=e=>({coordinates:e}),ame=e=>({"atom.id":e}),cme=(e,t,n)=>({"chain.id":e,"residue.id":t,"atom.id":n});function V0t(e,t){1&e&&gi(0,"div",9),2&e&&pb("background-color",t)}function z0t(e,t){1&e&&(dn(0,"code",6)(1,"pre",10),ar(2),Ga(3,"json"),fn()()),2&e&&(mi(2),ku(ja(3,1,mx(3,sme,t.coordinates))))}function G0t(e,t){1&e&&(dn(0,"code",6)(1,"pre",10),ar(2),Ga(3,"json"),fn()()),2&e&&(mi(2),ku(ja(3,1,mx(3,sme,t.coordinates))))}function j0t(e,t){1&e&&gi(0,"div",9),2&e&&pb("background-color",t)}function H0t(e,t){1&e&&(dn(0,"code",6)(1,"pre",10),ar(2),Ga(3,"json"),fn()()),2&e&&(mi(2),ku(ja(3,1,mx(3,ame,t["atom.id"]))))}function q0t(e,t){1&e&&(dn(0,"code",6)(1,"pre",10),ar(2),Ga(3,"json"),fn()()),2&e&&(mi(2),ku(ja(3,1,mx(3,ame,t["atom.id"]))))}function W0t(e,t){1&e&&gi(0,"div",9),2&e&&pb("background-color",t)}function $0t(e,t){if(1&e&&(dn(0,"code",6)(1,"pre",10),ar(2),Ga(3,"json"),fn()()),2&e){const n=t;mi(2),ku(ja(3,1,gN(3,cme,n["chain.id"],n["residue.id"],n["atom.id"])))}}function Y0t(e,t){if(1&e&&(dn(0,"code",6)(1,"pre",10),ar(2),Ga(3,"json"),fn()()),2&e){const n=t;mi(2),ku(ja(3,1,gN(3,cme,n["chain.id"],n["residue.id"],n["atom.id"])))}}function X0t(e,t){if(1&e&&gi(0,"ngx-structure-viewer",8),2&e){const n=hx();Bh("settings",n.settings)("source",n.source)("interactions",t)}}let K0t=(()=>{class e{constructor(n){this.location=n,this.settings={"background-color":"#2b3035ff","backbone-color":"#6ea8fe40","interaction-color":"#ff0000ff","interaction-size":.5},this.source={type:"remote",format:"mmcif",label:"8VAP.A",binary:!1,link:this.location.prepareExternalUrl("assets/8vap.A.cif")},this.interactions=[{from:{coordinates:v.create(165.36768,188.18981,113.00826)},to:{coordinates:v.create(160.33379,162.30181,108.49545)},color:"#ff4500"},{from:{"atom.id":211},to:{"atom.id":374},color:"#adff2f"},{from:{"chain.id":"A","residue.id":"148","atom.name":"CA"},to:{"chain.id":"A","residue.id":"89","atom.name":"CD"},color:"#8a2be2"}],this.interactions$=ome(3e3).pipe(qt(()=>this.interactions.map(r=>({...r}))),qt(r=>r.sort(()=>Math.random()-.5)),qt(r=>[r[0]]),Dx([this.interactions[0]]),Zl(1))}static#e=this.\u0275fac=function(r){return new(r||e)(cn(_b))};static#t=this.\u0275cmp=Mu({type:e,selectors:[["app-section-interactions"]],standalone:!0,features:[Nu],decls:29,vars:12,consts:[[1,"row","mb-3"],[1,"col-6"],[1,"mb-3"],[1,"mb-1"],[1,"d-flex","flex-row","align-items-stretch","gap-1"],[1,"d-block","p-2",3,"background-color"],[1,"d-block","flex-1"],[1,"rounded","squared","overflow-hidden","bg-body-tertiary"],[3,"settings","source","interactions"],[1,"d-block","p-2"],[1,"bg-body-tertiary","p-3","m-0"]],template:function(r,i){if(1&r&&(dn(0,"div",0)(1,"div",1)(2,"h2"),ar(3,"Interactions"),fn(),dn(4,"div",2)(5,"p",3),ar(6,"1. Provide atom coordinates"),fn(),dn(7,"div",4),Jc(8,V0t,1,2,"div",5)(9,z0t,4,5,"code",6)(10,G0t,4,5,"code",6),fn()(),dn(11,"div",2)(12,"p",3),ar(13,"2. Provide atom identifier"),fn(),dn(14,"div",4),Jc(15,j0t,1,2,"div",5)(16,H0t,4,5,"code",6)(17,q0t,4,5,"code",6),fn()(),dn(18,"div",2)(19,"p",3),ar(20,"3. Provide chain, residue identifier and atom name"),fn(),dn(21,"div",4),Jc(22,W0t,1,2,"div",5)(23,$0t,4,7,"code",6)(24,Y0t,4,7,"code",6),fn()()(),dn(25,"div",1)(26,"div",7),Jc(27,X0t,1,3,"ngx-structure-viewer",8),Ga(28,"async"),fn()()()),2&r){let o,s,a,c,u,l,d,f,p,m;mi(8),Va(8,(o=i.interactions[0].color)?8:-1,o),mi(),Va(9,(s=i.interactions[0].from)?9:-1,s),mi(),Va(10,(a=i.interactions[0].to)?10:-1,a),mi(5),Va(15,(c=i.interactions[1].color)?15:-1,c),mi(),Va(16,(u=i.interactions[1].from)?16:-1,u),mi(),Va(17,(l=i.interactions[1].to)?17:-1,l),mi(5),Va(22,(d=i.interactions[2].color)?22:-1,d),mi(),Va(23,(f=i.interactions[2].from)?23:-1,f),mi(),Va(24,(p=i.interactions[2].to)?24:-1,p),mi(3),Va(27,(m=ja(28,10,i.interactions$))?27:-1,m)}},dependencies:[eP,Uh,Cx,sI]})}return e})();class tP{}class nP{}class Rl{constructor(t){this.normalizedNames=new Map,this.lazyUpdate=null,t?"string"==typeof t?this.lazyInit=()=>{this.headers=new Map,t.split("\n").forEach(n=>{const r=n.indexOf(":");if(r>0){const i=n.slice(0,r),o=i.toLowerCase(),s=n.slice(r+1).trim();this.maybeSetNormalizedName(i,o),this.headers.has(o)?this.headers.get(o).push(s):this.headers.set(o,[s])}})}:typeof Headers<"u"&&t instanceof Headers?(this.headers=new Map,t.forEach((n,r)=>{this.setHeaderEntries(r,n)})):this.lazyInit=()=>{this.headers=new Map,Object.entries(t).forEach(([n,r])=>{this.setHeaderEntries(n,r)})}:this.headers=new Map}has(t){return this.init(),this.headers.has(t.toLowerCase())}get(t){this.init();const n=this.headers.get(t.toLowerCase());return n&&n.length>0?n[0]:null}keys(){return this.init(),Array.from(this.normalizedNames.values())}getAll(t){return this.init(),this.headers.get(t.toLowerCase())||null}append(t,n){return this.clone({name:t,value:n,op:"a"})}set(t,n){return this.clone({name:t,value:n,op:"s"})}delete(t,n){return this.clone({name:t,value:n,op:"d"})}maybeSetNormalizedName(t,n){this.normalizedNames.has(n)||this.normalizedNames.set(n,t)}init(){this.lazyInit&&(this.lazyInit instanceof Rl?this.copyFrom(this.lazyInit):this.lazyInit(),this.lazyInit=null,this.lazyUpdate&&(this.lazyUpdate.forEach(t=>this.applyUpdate(t)),this.lazyUpdate=null))}copyFrom(t){t.init(),Array.from(t.headers.keys()).forEach(n=>{this.headers.set(n,t.headers.get(n)),this.normalizedNames.set(n,t.normalizedNames.get(n))})}clone(t){const n=new Rl;return n.lazyInit=this.lazyInit&&this.lazyInit instanceof Rl?this.lazyInit:this,n.lazyUpdate=(this.lazyUpdate||[]).concat([t]),n}applyUpdate(t){const n=t.name.toLowerCase();switch(t.op){case"a":case"s":let r=t.value;if("string"==typeof r&&(r=[r]),0===r.length)return;this.maybeSetNormalizedName(t.name,n);const i=("a"===t.op?this.headers.get(n):void 0)||[];i.push(...r),this.headers.set(n,i);break;case"d":const o=t.value;if(o){let s=this.headers.get(n);if(!s)return;s=s.filter(a=>-1===o.indexOf(a)),0===s.length?(this.headers.delete(n),this.normalizedNames.delete(n)):this.headers.set(n,s)}else this.headers.delete(n),this.normalizedNames.delete(n)}}setHeaderEntries(t,n){const r=(Array.isArray(n)?n:[n]).map(o=>o.toString()),i=t.toLowerCase();this.headers.set(i,r),this.maybeSetNormalizedName(t,i)}forEach(t){this.init(),Array.from(this.normalizedNames.keys()).forEach(n=>t(this.normalizedNames.get(n),this.headers.get(n)))}}class Z0t{encodeKey(t){return ume(t)}encodeValue(t){return ume(t)}decodeKey(t){return decodeURIComponent(t)}decodeValue(t){return decodeURIComponent(t)}}const J0t=/%(\d[a-f0-9])/gi,eyt={40:"@","3A":":",24:"$","2C":",","3B":";","3D":"=","3F":"?","2F":"/"};function ume(e){return encodeURIComponent(e).replace(J0t,(t,n)=>eyt[n]??t)}function rP(e){return`${e}`}class Xm{constructor(t={}){if(this.updates=null,this.cloneFrom=null,this.encoder=t.encoder||new Z0t,t.fromString){if(t.fromObject)throw new Error("Cannot specify both fromString and fromObject.");this.map=function Q0t(e,t){const n=new Map;return e.length>0&&e.replace(/^\?/,"").split("&").forEach(i=>{const o=i.indexOf("="),[s,a]=-1==o?[t.decodeKey(i),""]:[t.decodeKey(i.slice(0,o)),t.decodeValue(i.slice(o+1))],c=n.get(s)||[];c.push(a),n.set(s,c)}),n}(t.fromString,this.encoder)}else t.fromObject?(this.map=new Map,Object.keys(t.fromObject).forEach(n=>{const r=t.fromObject[n],i=Array.isArray(r)?r.map(rP):[rP(r)];this.map.set(n,i)})):this.map=null}has(t){return this.init(),this.map.has(t)}get(t){this.init();const n=this.map.get(t);return n?n[0]:null}getAll(t){return this.init(),this.map.get(t)||null}keys(){return this.init(),Array.from(this.map.keys())}append(t,n){return this.clone({param:t,value:n,op:"a"})}appendAll(t){const n=[];return Object.keys(t).forEach(r=>{const i=t[r];Array.isArray(i)?i.forEach(o=>{n.push({param:r,value:o,op:"a"})}):n.push({param:r,value:i,op:"a"})}),this.clone(n)}set(t,n){return this.clone({param:t,value:n,op:"s"})}delete(t,n){return this.clone({param:t,value:n,op:"d"})}toString(){return this.init(),this.keys().map(t=>{const n=this.encoder.encodeKey(t);return this.map.get(t).map(r=>n+"="+this.encoder.encodeValue(r)).join("&")}).filter(t=>""!==t).join("&")}clone(t){const n=new Xm({encoder:this.encoder});return n.cloneFrom=this.cloneFrom||this,n.updates=(this.updates||[]).concat(t),n}init(){null===this.map&&(this.map=new Map),null!==this.cloneFrom&&(this.cloneFrom.init(),this.cloneFrom.keys().forEach(t=>this.map.set(t,this.cloneFrom.map.get(t))),this.updates.forEach(t=>{switch(t.op){case"a":case"s":const n=("a"===t.op?this.map.get(t.param):void 0)||[];n.push(rP(t.value)),this.map.set(t.param,n);break;case"d":if(void 0===t.value){this.map.delete(t.param);break}{let r=this.map.get(t.param)||[];const i=r.indexOf(rP(t.value));-1!==i&&r.splice(i,1),r.length>0?this.map.set(t.param,r):this.map.delete(t.param)}}}),this.cloneFrom=this.updates=null)}}class tyt{constructor(){this.map=new Map}set(t,n){return this.map.set(t,n),this}get(t){return this.map.has(t)||this.map.set(t,t.defaultValue()),this.map.get(t)}delete(t){return this.map.delete(t),this}has(t){return this.map.has(t)}keys(){return this.map.keys()}}function lme(e){return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer}function dme(e){return typeof Blob<"u"&&e instanceof Blob}function fme(e){return typeof FormData<"u"&&e instanceof FormData}class FC{constructor(t,n,r,i){let o;if(this.url=n,this.body=null,this.reportProgress=!1,this.withCredentials=!1,this.responseType="json",this.method=t.toUpperCase(),function nyt(e){switch(e){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"JSONP":return!1;default:return!0}}(this.method)||i?(this.body=void 0!==r?r:null,o=i):o=r,o&&(this.reportProgress=!!o.reportProgress,this.withCredentials=!!o.withCredentials,o.responseType&&(this.responseType=o.responseType),o.headers&&(this.headers=o.headers),o.context&&(this.context=o.context),o.params&&(this.params=o.params),this.transferCache=o.transferCache),this.headers??=new Rl,this.context??=new tyt,this.params){const s=this.params.toString();if(0===s.length)this.urlWithParams=n;else{const a=n.indexOf("?");this.urlWithParams=n+(-1===a?"?":ad.set(f,t.setHeaders[f]),c)),t.setParams&&(u=Object.keys(t.setParams).reduce((d,f)=>d.set(f,t.setParams[f]),u)),new FC(n,r,o,{params:u,headers:c,context:l,reportProgress:a,responseType:i,withCredentials:s})}}var Km=function(e){return e[e.Sent=0]="Sent",e[e.UploadProgress=1]="UploadProgress",e[e.ResponseHeader=2]="ResponseHeader",e[e.DownloadProgress=3]="DownloadProgress",e[e.Response=4]="Response",e[e.User=5]="User",e}(Km||{});class h7{constructor(t,n=BC.Ok,r="OK"){this.headers=t.headers||new Rl,this.status=void 0!==t.status?t.status:n,this.statusText=t.statusText||r,this.url=t.url||null,this.ok=this.status>=200&&this.status<300}}class iP extends h7{constructor(t={}){super(t),this.type=Km.ResponseHeader}clone(t={}){return new iP({headers:t.headers||this.headers,status:void 0!==t.status?t.status:this.status,statusText:t.statusText||this.statusText,url:t.url||this.url||void 0})}}class sy extends h7{constructor(t={}){super(t),this.type=Km.Response,this.body=void 0!==t.body?t.body:null}clone(t={}){return new sy({body:void 0!==t.body?t.body:this.body,headers:t.headers||this.headers,status:void 0!==t.status?t.status:this.status,statusText:t.statusText||this.statusText,url:t.url||this.url||void 0})}}class G1 extends h7{constructor(t){super(t,0,"Unknown Error"),this.name="HttpErrorResponse",this.ok=!1,this.message=this.status>=200&&this.status<300?`Http failure during parsing for ${t.url||"(unknown url)"}`:`Http failure response for ${t.url||"(unknown url)"}: ${t.status} ${t.statusText}`,this.error=t.error||null}}var BC=function(e){return e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.EarlyHints=103]="EarlyHints",e[e.Ok=200]="Ok",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultiStatus=207]="MultiStatus",e[e.AlreadyReported=208]="AlreadyReported",e[e.ImUsed=226]="ImUsed",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.Unused=306]="Unused",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.UriTooLong=414]="UriTooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.ImATeapot=418]="ImATeapot",e[e.MisdirectedRequest=421]="MisdirectedRequest",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.Locked=423]="Locked",e[e.FailedDependency=424]="FailedDependency",e[e.TooEarly=425]="TooEarly",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HttpVersionNotSupported=505]="HttpVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired",e}(BC||{});function m7(e,t){return{body:t,headers:e.headers,context:e.context,observe:e.observe,params:e.params,reportProgress:e.reportProgress,responseType:e.responseType,withCredentials:e.withCredentials,transferCache:e.transferCache}}let pme=(()=>{class e{constructor(n){this.handler=n}request(n,r,i={}){let o;if(n instanceof FC)o=n;else{let c,u;c=i.headers instanceof Rl?i.headers:new Rl(i.headers),i.params&&(u=i.params instanceof Xm?i.params:new Xm({fromObject:i.params})),o=new FC(n,r,void 0!==i.body?i.body:null,{headers:c,context:i.context,params:u,reportProgress:i.reportProgress,responseType:i.responseType||"json",withCredentials:i.withCredentials,transferCache:i.transferCache})}const s=Pn(o).pipe(Cb(c=>this.handler.handle(c)));if(n instanceof FC||"events"===i.observe)return s;const a=s.pipe(Yl(c=>c instanceof sy));switch(i.observe||"body"){case"body":switch(o.responseType){case"arraybuffer":return a.pipe(qt(c=>{if(null!==c.body&&!(c.body instanceof ArrayBuffer))throw new Error("Response is not an ArrayBuffer.");return c.body}));case"blob":return a.pipe(qt(c=>{if(null!==c.body&&!(c.body instanceof Blob))throw new Error("Response is not a Blob.");return c.body}));case"text":return a.pipe(qt(c=>{if(null!==c.body&&"string"!=typeof c.body)throw new Error("Response is not a string.");return c.body}));default:return a.pipe(qt(c=>c.body))}case"response":return a;default:throw new Error(`Unreachable: unhandled observe type ${i.observe}}`)}}delete(n,r={}){return this.request("DELETE",n,r)}get(n,r={}){return this.request("GET",n,r)}head(n,r={}){return this.request("HEAD",n,r)}jsonp(n,r){return this.request("JSONP",n,{params:(new Xm).append(r,"JSONP_CALLBACK"),observe:"body",responseType:"json"})}options(n,r={}){return this.request("OPTIONS",n,r)}patch(n,r,i={}){return this.request("PATCH",n,m7(i,r))}post(n,r,i={}){return this.request("POST",n,m7(i,r))}put(n,r,i={}){return this.request("PUT",n,m7(i,r))}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tP))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();function mme(e,t){return t(e)}function cyt(e,t){return(n,r)=>t.intercept(n,{handle:i=>e(i,r)})}const lyt=new Yt(""),OC=new Yt(""),gme=new Yt(""),yme=new Yt("");function dyt(){let e=null;return(t,n)=>{null===e&&(e=(bt(lyt,{optional:!0})??[]).reduceRight(cyt,mme));const r=bt(kh),i=r.add();return e(t,n).pipe(Ex(()=>r.remove(i)))}}let bme=(()=>{class e extends tP{constructor(n,r){super(),this.backend=n,this.injector=r,this.chain=null,this.pendingTasks=bt(kh);const i=bt(yme,{optional:!0});this.backend=i??n}handle(n){if(null===this.chain){const i=Array.from(new Set([...this.injector.get(OC),...this.injector.get(gme,[])]));this.chain=i.reduceRight((o,s)=>function uyt(e,t,n){return(r,i)=>Md(n,()=>t(r,o=>e(o,i)))}(o,s,this.injector),mme)}const r=this.pendingTasks.add();return this.chain(n,i=>this.backend.handle(i)).pipe(Ex(()=>this.pendingTasks.remove(r)))}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(nP),Zt(xc))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();const gyt=/^\)\]\}',?\n/;let _me=(()=>{class e{constructor(n){this.xhrFactory=n}handle(n){if("JSONP"===n.method)throw new It(-2800,!1);const r=this.xhrFactory;return(r.\u0275loadImpl?$i(r.\u0275loadImpl()):Pn(null)).pipe(To(()=>new ns(o=>{const s=r.build();if(s.open(n.method,n.urlWithParams),n.withCredentials&&(s.withCredentials=!0),n.headers.forEach((h,g)=>s.setRequestHeader(h,g.join(","))),n.headers.has("Accept")||s.setRequestHeader("Accept","application/json, text/plain, */*"),!n.headers.has("Content-Type")){const h=n.detectContentTypeHeader();null!==h&&s.setRequestHeader("Content-Type",h)}if(n.responseType){const h=n.responseType.toLowerCase();s.responseType="json"!==h?h:"text"}const a=n.serializeBody();let c=null;const u=()=>{if(null!==c)return c;const h=s.statusText||"OK",g=new Rl(s.getAllResponseHeaders()),y=function yyt(e){return"responseURL"in e&&e.responseURL?e.responseURL:/^X-Request-URL:/m.test(e.getAllResponseHeaders())?e.getResponseHeader("X-Request-URL"):null}(s)||n.url;return c=new iP({headers:g,status:s.status,statusText:h,url:y}),c},l=()=>{let{headers:h,status:g,statusText:y,url:b}=u(),x=null;g!==BC.NoContent&&(x=typeof s.response>"u"?s.responseText:s.response),0===g&&(g=x?BC.Ok:0);let _=g>=200&&g<300;if("json"===n.responseType&&"string"==typeof x){const S=x;x=x.replace(gyt,"");try{x=""!==x?JSON.parse(x):null}catch(A){x=S,_&&(_=!1,x={error:A,text:x})}}_?(o.next(new sy({body:x,headers:h,status:g,statusText:y,url:b||void 0})),o.complete()):o.error(new G1({error:x,headers:h,status:g,statusText:y,url:b||void 0}))},d=h=>{const{url:g}=u(),y=new G1({error:h,status:s.status||0,statusText:s.statusText||"Unknown Error",url:g||void 0});o.error(y)};let f=!1;const p=h=>{f||(o.next(u()),f=!0);let g={type:Km.DownloadProgress,loaded:h.loaded};h.lengthComputable&&(g.total=h.total),"text"===n.responseType&&s.responseText&&(g.partialText=s.responseText),o.next(g)},m=h=>{let g={type:Km.UploadProgress,loaded:h.loaded};h.lengthComputable&&(g.total=h.total),o.next(g)};return s.addEventListener("load",l),s.addEventListener("error",d),s.addEventListener("timeout",d),s.addEventListener("abort",d),n.reportProgress&&(s.addEventListener("progress",p),null!==a&&s.upload&&s.upload.addEventListener("progress",m)),s.send(a),o.next({type:Km.Sent}),()=>{s.removeEventListener("error",d),s.removeEventListener("abort",d),s.removeEventListener("load",l),s.removeEventListener("timeout",d),n.reportProgress&&(s.removeEventListener("progress",p),null!==a&&s.upload&&s.upload.removeEventListener("progress",m)),s.readyState!==s.DONE&&s.abort()}})))}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(PX))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();const b7=new Yt(""),xme=new Yt("",{providedIn:"root",factory:()=>"XSRF-TOKEN"}),Sme=new Yt("",{providedIn:"root",factory:()=>"X-XSRF-TOKEN"});class Cme{}let _yt=(()=>{class e{constructor(n,r,i){this.doc=n,this.platform=r,this.cookieName=i,this.lastCookieString="",this.lastToken=null,this.parseCount=0}getToken(){if("server"===this.platform)return null;const n=this.doc.cookie||"";return n!==this.lastCookieString&&(this.parseCount++,this.lastToken=xX(n,this.cookieName),this.lastCookieString=n),this.lastToken}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(tu),Zt(Th),Zt(xme))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac})}return e})();function xyt(e,t){const n=e.url.toLowerCase();if(!bt(b7)||"GET"===e.method||"HEAD"===e.method||n.startsWith("http://")||n.startsWith("https://"))return t(e);const r=bt(Cme).getToken(),i=bt(Sme);return null!=r&&!e.headers.has(i)&&(e=e.clone({headers:e.headers.set(i,r)})),t(e)}var Zm=function(e){return e[e.Interceptors=0]="Interceptors",e[e.LegacyInterceptors=1]="LegacyInterceptors",e[e.CustomXsrfConfiguration=2]="CustomXsrfConfiguration",e[e.NoXsrfProtection=3]="NoXsrfProtection",e[e.JsonpSupport=4]="JsonpSupport",e[e.RequestsMadeViaParent=5]="RequestsMadeViaParent",e[e.Fetch=6]="Fetch",e}(Zm||{});function Syt(...e){const t=[pme,_me,bme,{provide:tP,useExisting:bme},{provide:nP,useExisting:_me},{provide:OC,useValue:xyt,multi:!0},{provide:b7,useValue:!0},{provide:Cme,useClass:_yt}];for(const n of e)t.push(...n.\u0275providers);return Iy(t)}const wme=new Yt("");function Cyt(){return function ay(e,t){return{\u0275kind:e,\u0275providers:t}}(Zm.LegacyInterceptors,[{provide:wme,useFactory:dyt},{provide:OC,useExisting:wme,multi:!0}])}let wyt=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275mod=p_({type:e});static#n=this.\u0275inj=Sy({providers:[Syt(Cyt())]})}return e})();function Pyt(e,t){1&e&&gi(0,"ngx-structure-viewer",5),2&e&&Bh("settings",hx().settings)("source",t)}function Myt(e,t){1&e&&gi(0,"ngx-structure-viewer",5),2&e&&Bh("settings",hx().settings)("source",t)}let Ryt=(()=>{class e{constructor(n){this.http=n,this.local={type:"local",format:"mmcif",label:"8VAP.A",binary:!1,data:"..."},this.remote={type:"remote",format:"mmcif",label:"8VAP",binary:!1,link:"..."},this.settings={"background-color":"#2b3035ff","backbone-color":"#6ea8fecc","interaction-color":"#ff0000ff","interaction-size":1},this.local$=this.http.get("assets/8vap.A.cif",{responseType:"text"}).pipe(qt(r=>new Blob([r],{type:"text/plain"})),qt(r=>({...this.local,data:r}))),this.remote$=Pn({...this.remote,link:"https://files.rcsb.org/view/8VAP.cif"})}static#e=this.\u0275fac=function(r){return new(r||e)(cn(pme))};static#t=this.\u0275cmp=Mu({type:e,selectors:[["app-section-sources"]],standalone:!0,features:[Nu],decls:25,vars:12,consts:[[1,"row","mb-3"],[1,"col-6"],[1,"d-flex","flex-row","align-items-start","gap-3","mb-3"],[1,"d-block","flex-grow-1"],[1,"rounded","squared","bg-body-tertiary","overflow-hidden"],[3,"settings","source"],[1,"d-block","flex-shrink-0","bg-body-tertiary","p-3"],[1,"mb-0"]],template:function(r,i){if(1&r&&(dn(0,"div",0)(1,"div",1)(2,"h2"),ar(3,"Upload local structure"),fn(),dn(4,"div",2)(5,"div",3)(6,"div",4),Jc(7,Pyt,1,2,"ngx-structure-viewer",5),Ga(8,"async"),fn()(),dn(9,"code",6)(10,"pre",7),ar(11),Ga(12,"json"),fn()()()(),dn(13,"div",1)(14,"h2"),ar(15,"Download remote structure"),fn(),dn(16,"div",2)(17,"div",3)(18,"div",4),Jc(19,Myt,1,2,"ngx-structure-viewer",5),Ga(20,"async"),fn()(),dn(21,"code",6)(22,"pre",7),ar(23),Ga(24,"json"),fn()()()()()),2&r){let o,s;mi(7),Va(7,(o=ja(8,4,i.local$))?7:-1,o),mi(4),ku(ja(12,6,i.local)),mi(8),Va(19,(s=ja(20,8,i.remote$))?19:-1,s),mi(4),ku(ja(24,10,i.remote))}},dependencies:[eP,wyt,Uh,Cx,sI]})}return e})();function kyt(e,t){if(1&e&&(dn(0,"div",6)(1,"div",7),gi(2,"div",8),dn(3,"code",9)(4,"pre",10),ar(5),Ga(6,"json"),fn()()()()),2&e){const n=t.$implicit;mi(2),pb("background-color",n.color),mi(3),ku(ja(6,3,n))}}function Nyt(e,t){if(1&e&&(dn(0,"div",0)(1,"div",1)(2,"div",2),gi(3,"ngx-structure-viewer",3),fn()(),dn(4,"div",4)(5,"h2"),ar(6,"Color chain"),fn(),dn(7,"div",5),function PW(e,t,n,r,i,o,s,a,c,u,l,d,f){Vd("NgControlFlow");const p=void 0!==c,m=it(),h=a?s.bind(m[go][Mi]):s,g=new Y2e(p,h);m[Vn+e]=g,Jc(e+1,t,n,r,i,o),p&&Jc(e+2,c,u,l,d,f)}(8,kyt,7,5,"div",6,EW),fn()()()),2&e){const n=t,r=hx();mi(3),Bh("settings",r.settings)("source",r.source)("loci",n),mi(5),function MW(e){const t=sr(null),n=la();try{const r=it(),i=r[Mt],o=r[n];if(void 0===o.liveCollection){const a=n+1,c=tN(r,a),u=nN(i,a);o.liveCollection=new X2e(c,r,u)}else o.liveCollection.reset();const s=o.liveCollection;if(function q2e(e,t,n){let r,i,o=0,s=e.length-1;if(Array.isArray(t)){let a=t.length-1;for(;o<=s&&o<=a;){const c=e.at(o),u=t[o],l=Jk(o,c,o,u,n);if(0!==l){l<0&&e.updateValue(o,u),o++;continue}const d=e.at(s),f=t[a],p=Jk(s,d,a,f,n);if(0!==p){p<0&&e.updateValue(s,f),s--,a--;continue}const m=n(o,c),h=n(s,d),g=n(o,u);if(Object.is(g,h)){const y=n(a,f);Object.is(y,m)?(e.swap(o,s),e.updateValue(s,f),a--,s--):e.move(s,o),e.updateValue(o,u),o++}else if(r??=new DW,i??=TW(e,o,s,n),eN(e,r,o,g))e.updateValue(o,u),o++,s++;else if(i.has(g))r.set(m,e.detach(o)),s--;else{const y=e.create(o,t[o]);e.attach(o,y),o++,s++}}for(;o<=a;)IW(e,r,n,o,t[o]),o++}else if(null!=t){const a=t[Symbol.iterator]();let c=a.next();for(;!c.done&&o<=s;){const u=e.at(o),l=c.value,d=Jk(o,u,o,l,n);if(0!==d)d<0&&e.updateValue(o,l),o++,c=a.next();else{r??=new DW,i??=TW(e,o,s,n);const f=n(o,l);if(eN(e,r,o,f))e.updateValue(o,l),o++,s++,c=a.next();else if(i.has(f)){const p=n(o,u);r.set(p,e.detach(o)),s--}else e.attach(o,e.create(o,l)),o++,s++,c=a.next()}}for(;!c.done;)IW(e,r,n,e.length,c.value),c=a.next()}for(;o<=s;)e.destroy(e.detach(s--));r?.forEach(a=>{e.destroy(a)})}(s,e,o.trackByFn),s.updateIndexes(),o.hasEmptyBlock){const a=zl(),c=0===s.length;if(jo(r,a,c)){const u=n+2,l=tN(r,u);if(c){const d=nN(i,u),f=Xy(l,d.tView.ssrId);G_(l,z_(r,d,void 0,{dehydratedView:f}),0,Yy(d,f))}else dk(l,0)}}}finally{sr(t)}}(n)}}let Fyt=(()=>{class e{constructor(){this.settings={"background-color":"#2b3035ff","backbone-color":"#6ea8fecc","interaction-color":"#ff0000ff","interaction-size":1},this.source={type:"remote",format:"mmcif",label:"8VAP",binary:!1,link:"assets/8vap.cif"};const n=[{chain:"A",color:"#6f42c1"},{chain:"B",color:"#0d6efd"},{chain:"C",color:"#dc3545"},{chain:"D",color:"#ffc107"},{chain:"E",color:"#28a745"},{chain:"F",color:"#17a2b8"},{chain:"G",color:"#fd7e14"}];this.chains$=ome(3e3).pipe(qt(()=>n.map(r=>r.color)),qt(r=>r.sort(()=>Math.random()-.5)),qt(r=>r.map((i,o)=>({...n[o],color:i}))),Dx(n),Zl(1))}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["app-section-chains"]],standalone:!0,features:[Nu],decls:2,vars:3,consts:[[1,"row","mb-3"],[1,"col-9"],[1,"rounded","squared","overflow-hidden","shadow-sm"],[3,"settings","source","loci"],[1,"col-3","pt-0","p-3"],[1,"d-flex","flex-column","gap-2"],[1,"flex-1"],[1,"d-flex","flex-row","gap-2"],[1,"d-block","flex-shrink-0","p-2"],[1,"bg-body-tertiary","flex-grow-1","p-3"],[1,"m-0"]],template:function(r,i){if(1&r&&(Jc(0,Nyt,10,3,"div",0),Ga(1,"async")),2&r){let o;Va(0,(o=ja(1,1,i.chains$))?0:-1,o)}},dependencies:[eP,Uh,Cx,sI],changeDetection:0})}return e})();function Byt(e,t){1&e&&(dn(0,"div",4)(1,"code",6),ar(2),fn()()),2&e&&(mi(2),ku(t))}let Oyt=(()=>{class e{constructor(){this.label$=new ou(1),this.settings={"background-color":"#2b3035ff","backbone-color":"#6ea8fecc","interaction-color":"#ff0000ff","interaction-size":1},this.source={type:"remote",format:"mmcif",label:"8VAP",binary:!1,link:"assets/8vap.cif"}}onHighlights(n){this.label$.next(n?`Chain: ${n.chain}; Start: ${n.start}; End: ${n.end}.`:"")}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["app-section-highlights"]],standalone:!0,features:[Nu],decls:9,vars:5,consts:[[1,"row","mb-3"],[1,"col-6","position-relative"],[1,"squared","rounded","overflow-hidden","bg-body-tertiary"],[3,"highlights","settings","source"],[1,"d-block","position-absolute","bottom-0","end-0","w-auto","h-auto","pe-3"],[1,"col-6"],[1,"d-block","p-3"]],template:function(r,i){if(1&r&&(dn(0,"div",0)(1,"div",1)(2,"div",2)(3,"ngx-structure-viewer",3),px("highlights",function(s){return i.onHighlights(s)}),fn()(),Jc(4,Byt,3,1,"div",4),Ga(5,"async"),fn(),dn(6,"div",5)(7,"h2"),ar(8,"Highlights"),fn()()()),2&r){let o;mi(3),Bh("settings",i.settings)("source",i.source),mi(),Va(4,(o=ja(5,3,i.label$))?4:-1,o)}},dependencies:[eP,Uh,Cx],changeDetection:0})}return e})(),Lyt=(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["page-structure-viewer"]],standalone:!0,features:[Nu],decls:13,vars:0,consts:[[1,"container","pt-3"],[1,"mb-3"]],template:function(r,i){1&r&&(dn(0,"div",0)(1,"div",1)(2,"h1"),ar(3,"Structure viewer"),fn(),dn(4,"p"),ar(5," The "),dn(6,"b"),ar(7,"ngx-structure-viewer"),fn(),ar(8," is a Mol* wrapper for Angular. It is a viewer for molecular structures and can be used to visualize and interact with 3D molecular structures. It works out of the box with the latest releases of Angular and automatized the most common features of Mol*. "),fn()(),gi(9,"app-section-sources")(10,"app-section-chains")(11,"app-section-interactions")(12,"app-section-highlights"),fn())},dependencies:[K0t,Oyt,Ryt,Fyt,GF,Uh],styles:[".progress-bar[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_progress 10s linear infinite;width:0}@keyframes _ngcontent-%COMP%_progress{0%{width:0}to{width:100%}}"]})}return e})();function Uyt(e){return e}function Vyt(e){return"translate("+e+",0)"}function zyt(e){return"translate(0,"+e+")"}function Gyt(e){return t=>+e(t)}function jyt(e,t){return t=Math.max(0,e.bandwidth()-2*t)/2,e.round()&&(t=Math.round(t)),n=>+e(n)+t}function Hyt(){return!this.__axis}function cP(e,t){var n=[],r=null,i=null,o=6,s=6,a=3,c=typeof window<"u"&&window.devicePixelRatio>1?0:.5,u=1===e||4===e?-1:1,l=4===e||2===e?"x":"y",d=1===e||3===e?Vyt:zyt;function f(p){var m=r??(t.ticks?t.ticks.apply(t,n):t.domain()),h=i??(t.tickFormat?t.tickFormat.apply(t,n):Uyt),g=Math.max(o,0)+a,y=t.range(),b=+y[0]+c,x=+y[y.length-1]+c,_=(t.bandwidth?jyt:Gyt)(t.copy(),c),S=p.selection?p.selection():p,A=S.selectAll(".domain").data([null]),E=S.selectAll(".tick").data(m,t).order(),w=E.exit(),D=E.enter().append("g").attr("class","tick"),I=E.select("line"),R=E.select("text");A=A.merge(A.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),E=E.merge(D),I=I.merge(D.append("line").attr("stroke","currentColor").attr(l+"2",u*o)),R=R.merge(D.append("text").attr("fill","currentColor").attr(l,u*g).attr("dy",1===e?"0em":3===e?"0.71em":"0.32em")),p!==S&&(A=A.transition(p),E=E.transition(p),I=I.transition(p),R=R.transition(p),w=w.transition(p).attr("opacity",1e-6).attr("transform",function(T){return isFinite(T=_(T))?d(T+c):this.getAttribute("transform")}),D.attr("opacity",1e-6).attr("transform",function(T){var M=this.parentNode.__axis;return d((M&&isFinite(M=M(T))?M:_(T))+c)})),w.remove(),A.attr("d",4===e||2===e?s?"M"+u*s+","+b+"H"+c+"V"+x+"H"+u*s:"M"+c+","+b+"V"+x:s?"M"+b+","+u*s+"V"+c+"H"+x+"V"+u*s:"M"+b+","+c+"H"+x),E.attr("opacity",1).attr("transform",function(T){return d(_(T)+c)}),I.attr(l+"2",u*o),R.attr(l,u*g).text(h),S.filter(Hyt).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===e?"start":4===e?"end":"middle"),S.each(function(){this.__axis=_})}return f.scale=function(p){return arguments.length?(t=p,f):t},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(p){return arguments.length?(n=null==p?[]:Array.from(p),f):n.slice()},f.tickValues=function(p){return arguments.length?(r=null==p?null:Array.from(p),f):r&&r.slice()},f.tickFormat=function(p){return arguments.length?(i=p,f):i},f.tickSize=function(p){return arguments.length?(o=s=+p,f):o},f.tickSizeInner=function(p){return arguments.length?(o=+p,f):o},f.tickSizeOuter=function(p){return arguments.length?(s=+p,f):s},f.tickPadding=function(p){return arguments.length?(a=+p,f):a},f.offset=function(p){return arguments.length?(c=+p,f):c},f}function Wyt(){}function _7(e){return null==e?Wyt:function(){return this.querySelector(e)}}function Xyt(){return[]}function Rme(e){return null==e?Xyt:function(){return this.querySelectorAll(e)}}function kme(e){return function(){return this.matches(e)}}function Nme(e){return function(t){return t.matches(e)}}var Qyt=Array.prototype.find;function ebt(){return this.firstElementChild}var nbt=Array.prototype.filter;function rbt(){return Array.from(this.children)}function Fme(e){return new Array(e.length)}function uP(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function ubt(e,t,n,r,i,o){for(var a,s=0,c=t.length,u=o.length;st?1:e>=t?0:NaN}uP.prototype={constructor:uP,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};var x7="http://www.w3.org/1999/xhtml";const Bme={svg:"http://www.w3.org/2000/svg",xhtml:x7,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function lP(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),Bme.hasOwnProperty(t)?{space:Bme[t],local:e}:e}function Ibt(e){return function(){this.removeAttribute(e)}}function Tbt(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Dbt(e,t){return function(){this.setAttribute(e,t)}}function Ebt(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Pbt(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function Mbt(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Ome(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function kbt(e){return function(){this.style.removeProperty(e)}}function Nbt(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Fbt(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function j1(e,t){return e.style.getPropertyValue(t)||Ome(e).getComputedStyle(e,null).getPropertyValue(t)}function Obt(e){return function(){delete this[e]}}function Lbt(e,t){return function(){this[e]=t}}function Ubt(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function Lme(e){return e.trim().split(/^|\s+/)}function S7(e){return e.classList||new Ume(e)}function Ume(e){this._node=e,this._names=Lme(e.getAttribute("class")||"")}function Vme(e,t){for(var n=S7(e),r=-1,i=t.length;++r=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var jme=[null];function Pu(e,t){this._groups=e,this._parents=t}function Hme(){return new Pu([[document.documentElement]],jme)}Pu.prototype=Hme.prototype={constructor:Pu,select:function $yt(e){"function"!=typeof e&&(e=_7(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=x&&(x=b+1);!(S=g[x])&&++x=0;)(s=r[i])&&(o&&4^s.compareDocumentPosition(o)&&o.parentNode.insertBefore(s,o),o=s);return this},sort:function bbt(e){function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}e||(e=vbt);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==t?kbt:"function"==typeof t?Fbt:Nbt)(e,t,n??"")):j1(this.node(),e)},property:function Vbt(e,t){return arguments.length>1?this.each((null==t?Obt:"function"==typeof t?Ubt:Lbt)(e,t)):this.node()[e]},classed:function Hbt(e,t){var n=Lme(e+"");if(arguments.length<2){for(var r=S7(this.node()),i=-1,o=n.length;++i=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}(e+""),o=r.length;if(!(arguments.length<2)){for(a=t?yvt:gvt,i=0;i{}};function qme(){for(var r,e=0,t=arguments.length,n={};e=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}(e+"",n),o=-1,s=r.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++o0)for(var i,o,n=new Array(i),r=0;r=0&&e._call.call(void 0,t),e=e._next;--H1}()}finally{H1=0,function Pvt(){for(var e,n,t=fP,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:fP=n);GC=e,A7(r)}(),cy=0}}function Evt(){var e=jC.now(),t=e-pP;t>Yme&&(hP-=t,pP=e)}function A7(e){H1||(VC&&(VC=clearTimeout(VC)),e-cy>24?(e<1/0&&(VC=setTimeout(Zme,e-jC.now()-hP)),zC&&(zC=clearInterval(zC))):(zC||(pP=jC.now(),zC=setInterval(Evt,Yme)),H1=1,Xme(Zme)))}function Qme(e,t,n){var r=new mP;return r.restart(i=>{r.stop(),e(i+t)},t=null==t?0:+t,n),r}mP.prototype=Kme.prototype={constructor:mP,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?w7():+n)+(null==t?0:+t),!this._next&&GC!==this&&(GC?GC._next=this:fP=this,GC=this),this._call=e,this._time=n,A7()},stop:function(){this._call&&(this._call=null,this._time=1/0,A7())}};var Mvt=$me("start","end","cancel","interrupt"),Rvt=[],Jme=0,I7=2,gP=3,T7=5,yP=6;function bP(e,t,n,r,i,o){var s=e.__transition;if(s){if(n in s)return}else e.__transition={};!function kvt(e,t,n){var i,r=e.__transition;function s(u){var l,d,f,p;if(1!==n.state)return c();for(l in r)if((p=r[l]).name===n.name){if(p.state===gP)return Qme(s);4===p.state?(p.state=yP,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete r[l]):+lJme)throw new Error("too late; already scheduled");return n}function zf(e,t){var n=Id(e,t);if(n.state>gP)throw new Error("too late; already running");return n}function Id(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function vP(e,t){var r,i,s,n=e.__transition,o=!0;if(n){for(s in t=null==t?null:t+"",n)(r=n[s]).name===t?(i=r.state>I7&&r.state180?l+=360:l-u>180&&(u+=360),f.push({i:d.push(i(d)+"rotate(",null,r)-2,x:Td(u,l)})):l&&d.push(i(d)+"rotate("+l+r)}(u.rotate,l.rotate,d,f),function a(u,l,d,f){u!==l?f.push({i:d.push(i(d)+"skewX(",null,r)-2,x:Td(u,l)}):l&&d.push(i(d)+"skewX("+l+r)}(u.skewX,l.skewX,d,f),function c(u,l,d,f,p,m){if(u!==d||l!==f){var h=p.push(i(p)+"scale(",null,",",null,")");m.push({i:h-4,x:Td(u,d)},{i:h-2,x:Td(l,f)})}else(1!==d||1!==f)&&p.push(i(p)+"scale("+d+","+f+")")}(u.scaleX,u.scaleY,l.scaleX,l.scaleY,d,f),u=l=null,function(p){for(var g,m=-1,h=f.length;++m>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?SP(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?SP(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=jvt.exec(e))?new qc(t[1],t[2],t[3],1):(t=Hvt.exec(e))?new qc(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=qvt.exec(e))?SP(t[1],t[2],t[3],t[4]):(t=Wvt.exec(e))?SP(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=$vt.exec(e))?fge(t[1],t[2]/100,t[3]/100,1):(t=Yvt.exec(e))?fge(t[1],t[2]/100,t[3]/100,t[4]):sge.hasOwnProperty(e)?uge(sge[e]):"transparent"===e?new qc(NaN,NaN,NaN,0):null}function uge(e){return new qc(e>>16&255,e>>8&255,255&e,1)}function SP(e,t,n,r){return r<=0&&(e=t=n=NaN),new qc(e,t,n,r)}function CP(e,t,n,r){return 1===arguments.length?function Zvt(e){return e instanceof HC||(e=uy(e)),e?new qc((e=e.rgb()).r,e.g,e.b,e.opacity):new qc}(e):new qc(e,t,n,r??1)}function qc(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function lge(){return`#${dy(this.r)}${dy(this.g)}${dy(this.b)}`}function dge(){const e=wP(this.opacity);return`${1===e?"rgb(":"rgba("}${ly(this.r)}, ${ly(this.g)}, ${ly(this.b)}${1===e?")":`, ${e})`}`}function wP(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ly(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function dy(e){return((e=ly(e))<16?"0":"")+e.toString(16)}function fge(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Dd(e,t,n,r)}function pge(e){if(e instanceof Dd)return new Dd(e.h,e.s,e.l,e.opacity);if(e instanceof HC||(e=uy(e)),!e)return new Dd;if(e instanceof Dd)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),s=NaN,a=o-i,c=(o+i)/2;return a?(s=t===o?(n-r)/a+6*(n0&&c<1?0:s,new Dd(s,a,c,e.opacity)}function Dd(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function hge(e){return(e=(e||0)%360)<0?e+360:e}function AP(e){return Math.max(0,Math.min(1,e||0))}function R7(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}function mge(e,t,n,r,i){var o=e*e,s=o*e;return((1-3*e+3*o-s)*t+(4-6*o+3*s)*n+(1+3*e+3*o-3*s)*r+s*i)/6}M7(HC,uy,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:age,formatHex:age,formatHex8:function Xvt(){return this.rgb().formatHex8()},formatHsl:function Kvt(){return pge(this).formatHsl()},formatRgb:cge,toString:cge}),M7(qc,CP,oge(HC,{brighter(e){return e=null==e?xP:Math.pow(xP,e),new qc(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new qc(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new qc(ly(this.r),ly(this.g),ly(this.b),wP(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:lge,formatHex:lge,formatHex8:function Qvt(){return`#${dy(this.r)}${dy(this.g)}${dy(this.b)}${dy(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:dge,toString:dge})),M7(Dd,function Jvt(e,t,n,r){return 1===arguments.length?pge(e):new Dd(e,t,n,r??1)},oge(HC,{brighter(e){return e=null==e?xP:Math.pow(xP,e),new Dd(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new Dd(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new qc(R7(e>=240?e-240:e+120,i,r),R7(e,i,r),R7(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Dd(hge(this.h),AP(this.s),AP(this.l),wP(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=wP(this.opacity);return`${1===e?"hsl(":"hsla("}${hge(this.h)}, ${100*AP(this.s)}%, ${100*AP(this.l)}%${1===e?")":`, ${e})`}`}}));const k7=e=>()=>e;function yge(e,t){var n=t-e;return n?function gge(e,t){return function(n){return e+n*t}}(e,n):k7(isNaN(e)?t:e)}const IP=function e(t){var n=function r1t(e){return 1==(e=+e)?yge:function(t,n){return n-t?function n1t(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}(t,n,e):k7(isNaN(t)?n:t)}}(t);function r(i,o){var s=n((i=CP(i)).r,(o=CP(o)).r),a=n(i.g,o.g),c=n(i.b,o.b),u=yge(i.opacity,o.opacity);return function(l){return i.r=s(l),i.g=a(l),i.b=c(l),i.opacity=u(l),i+""}}return r.gamma=e,r}(1);function bge(e){return function(t){var s,a,n=t.length,r=new Array(n),i=new Array(n),o=new Array(n);for(s=0;s=1?(n=1,t-1):Math.floor(n*t),i=e[r],o=e[r+1];return mge((n-r/t)*t,r>0?e[r-1]:2*i-o,i,o,rn&&(o=t.slice(n,o),a[s]?a[s]+=o:a[++s]=o),(r=r[0])===(i=i[0])?a[s]?a[s]+=i:a[++s]=i:(a[++s]=null,c.push({i:s,x:Td(r,i)})),n=F7.lastIndex;return n=0&&(t=t.slice(0,n)),!t||"start"===t})}(t)?D7:zf;return function(){var s=o(this,e),a=s.on;a!==r&&(i=(r=a).copy()).on(t,n),s.on=i}}(n,e,t))},attr:function f1t(e,t){var n=lP(e),r="transform"===n?Lvt:_ge;return this.attrTween(e,"function"==typeof t?(n.local?d1t:l1t)(n,r,P7(this,"attr."+e,t)):null==t?(n.local?a1t:s1t)(n):(n.local?u1t:c1t)(n,r,t))},attrTween:function y1t(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var r=lP(e);return this.tween(n,(r.local?m1t:g1t)(r,t))},style:function j1t(e,t,n){var r="transform"==(e+="")?Ovt:_ge;return null==t?this.styleTween(e,function U1t(e,t){var n,r,i;return function(){var o=j1(this,e),s=(this.style.removeProperty(e),j1(this,e));return o===s?null:o===n&&s===r?i:i=t(n=o,r=s)}}(e,r)).on("end.style."+e,xge(e)):"function"==typeof t?this.styleTween(e,function z1t(e,t,n){var r,i,o;return function(){var s=j1(this,e),a=n(this),c=a+"";return null==a&&(this.style.removeProperty(e),c=a=j1(this,e)),s===c?null:s===r&&c===i?o:(i=c,o=t(r=s,a))}}(e,r,P7(this,"style."+e,t))).each(function G1t(e,t){var n,r,i,a,o="style."+t,s="end."+o;return function(){var c=zf(this,e),u=c.on,l=null==c.value[o]?a||(a=xge(t)):void 0;(u!==n||i!==l)&&(r=(n=u).copy()).on(s,i=l),c.on=r}}(this._id,e)):this.styleTween(e,function V1t(e,t,n){var r,o,i=n+"";return function(){var s=j1(this,e);return s===i?null:s===r?o:o=t(r=s,n)}}(e,r,t),n).on("end.style."+e,null)},styleTween:function W1t(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==t)return this.tween(r,null);if("function"!=typeof t)throw new Error;return this.tween(r,function q1t(e,t,n){var r,i;function o(){var s=t.apply(this,arguments);return s!==i&&(r=(i=s)&&function H1t(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}(e,s,n)),r}return o._value=t,o}(e,t,n??""))},text:function X1t(e){return this.tween("text","function"==typeof e?function Y1t(e){return function(){var t=e(this);this.textContent=t??""}}(P7(this,"text",e)):function $1t(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function Q1t(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function Z1t(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&function K1t(e){return function(t){this.textContent=e.call(this,t)}}(i)),t}return r._value=e,r}(e))},remove:function N1t(){return this.on("end.remove",function k1t(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function zvt(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s,r=Id(this.node(),n).tween,i=0,o=r.length;i1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Y1(e){return(e=EP(Math.abs(e)))?e[1]:NaN}["w","e"].map($C),["n","s"].map($C),["n","w","e","s","nw","ne","sw","se"].map($C);var Dge,y_t=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function PP(e){if(!(t=y_t.exec(e)))throw new Error("invalid format: "+e);var t;return new V7({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function V7(e){this.fill=void 0===e.fill?" ":e.fill+"",this.align=void 0===e.align?">":e.align+"",this.sign=void 0===e.sign?"-":e.sign+"",this.symbol=void 0===e.symbol?"":e.symbol+"",this.zero=!!e.zero,this.width=void 0===e.width?void 0:+e.width,this.comma=!!e.comma,this.precision=void 0===e.precision?void 0:+e.precision,this.trim=!!e.trim,this.type=void 0===e.type?"":e.type+""}function Ege(e,t){var n=EP(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}PP.prototype=V7.prototype,V7.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};const Pge={"%":(e,t)=>(100*e).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:function h_t(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)},e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Ege(100*e,t),r:Ege,s:function v_t(e,t){var n=EP(e,t);if(!n)return e+"";var r=n[0],i=n[1],o=i-(Dge=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,s=r.length;return o===s?r:o>s?r+new Array(o-s+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+EP(e,Math.max(0,t+o-1))[0]},X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Mge(e){return e}var MP,z7,Nge,Rge=Array.prototype.map,kge=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"];!function x_t(e){MP=function __t(e){var t=void 0===e.grouping||void 0===e.thousands?Mge:function m_t(e,t){return function(n,r){for(var i=n.length,o=[],s=0,a=e[0],c=0;i>0&&a>0&&(c+a+1>r&&(a=Math.max(1,r-c)),o.push(n.substring(i-=a,i+a)),!((c+=a+1)>r));)a=e[s=(s+1)%e.length];return o.reverse().join(t)}}(Rge.call(e.grouping,Number),e.thousands+""),n=void 0===e.currency?"":e.currency[0]+"",r=void 0===e.currency?"":e.currency[1]+"",i=void 0===e.decimal?".":e.decimal+"",o=void 0===e.numerals?Mge:function g_t(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}(Rge.call(e.numerals,String)),s=void 0===e.percent?"%":e.percent+"",a=void 0===e.minus?"\u2212":e.minus+"",c=void 0===e.nan?"NaN":e.nan+"";function u(d){var f=(d=PP(d)).fill,p=d.align,m=d.sign,h=d.symbol,g=d.zero,y=d.width,b=d.comma,x=d.precision,_=d.trim,S=d.type;"n"===S?(b=!0,S="g"):Pge[S]||(void 0===x&&(x=12),_=!0,S="g"),(g||"0"===f&&"="===p)&&(g=!0,f="0",p="=");var A="$"===h?n:"#"===h&&/[boxX]/.test(S)?"0"+S.toLowerCase():"",E="$"===h?r:/[%p]/.test(S)?s:"",w=Pge[S],D=/[defgprs%]/.test(S);function I(R){var N,V,F,T=A,M=E;if("c"===S)M=w(R)+M,R="";else{var G=(R=+R)<0||1/R<0;if(R=isNaN(R)?c:w(Math.abs(R),x),_&&(R=function b_t(e){e:for(var i,t=e.length,n=1,r=-1;n0&&(r=0)}return r>0?e.slice(0,r)+e.slice(i+1):e}(R)),G&&0==+R&&"+"!==m&&(G=!1),T=(G?"("===m?m:a:"-"===m||"("===m?"":m)+T,M=("s"===S?kge[8+Dge/3]:"")+M+(G&&"("===m?")":""),D)for(N=-1,V=R.length;++N(F=R.charCodeAt(N))||F>57){M=(46===F?i+R.slice(N+1):R.slice(N))+M,R=R.slice(0,N);break}}b&&!g&&(R=t(R,1/0));var L=T.length+R.length+M.length,z=L>1)+T+R+M+z.slice(L);break;default:R=z+T+R+M}return o(R)}return x=void 0===x?6:/[gprs]/.test(S)?Math.max(1,Math.min(21,x)):Math.max(0,Math.min(20,x)),I.toString=function(){return d+""},I}return{format:u,formatPrefix:function l(d,f){var p=u(((d=PP(d)).type="f",d)),m=3*Math.max(-8,Math.min(8,Math.floor(Y1(f)/3))),h=Math.pow(10,-m),g=kge[8+m/3];return function(y){return p(h*y)+g}}}}(e),z7=MP.format,Nge=MP.formatPrefix}({thousands:",",grouping:[3],currency:["$",""]});const S_t=Math.sqrt(50),C_t=Math.sqrt(10),w_t=Math.sqrt(2);function RP(e,t,n){const r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),s=o>=S_t?10:o>=C_t?5:o>=w_t?2:1;let a,c,u;return i<0?(u=Math.pow(10,-i)/s,a=Math.round(e*u),c=Math.round(t*u),a/ut&&--c,u=-u):(u=Math.pow(10,i)*s,a=Math.round(e/u),c=Math.round(t/u),a*ut&&--c),ct?1:e>=t?0:NaN}function T_t(e,t){return null==e||null==t?NaN:te?1:t>=e?0:NaN}function Fge(e){let t,n,r;function i(a,c,u=0,l=a.length){if(u>>1;n(a[d],c)<0?u=d+1:l=d}while(ukP(e(a),c),r=(a,c)=>e(a)-c):(t=e===kP||e===T_t?e:D_t,n=e,r=e),{left:i,center:function s(a,c,u=0,l=a.length){const d=i(a,c,u,l-1);return d>u&&r(a[d-1],c)>-r(a[d],c)?d-1:d},right:function o(a,c,u=0,l=a.length){if(u>>1;n(a[d],c)<=0?u=d+1:l=d}while(u0))return[];if((e=+e)==(t=+t))return[e];const r=t=i))return[];const a=o-i+1,c=new Array(a);if(r)if(s<0)for(let u=0;u0;){if((u=G7(s,a,n))===c)return r[i]=s,r[o]=a,t(r);if(u>0)s=Math.floor(s/u)*u,a=Math.ceil(a/u)*u;else{if(!(u<0))break;s=Math.ceil(s*u)/u,a=Math.floor(a*u)/u}c=u}return e},e}function Vge(){var e=function H_t(){return function j_t(){var r,i,o,a,c,u,e=Lge,t=Lge,n=j7,s=X1;function l(){var f=Math.min(e.length,t.length);return s!==X1&&(s=function U_t(e,t){var n;return e>t&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}(e[0],e[f-1])),a=f>2?z_t:V_t,c=u=null,d}function d(f){return null==f||isNaN(f=+f)?o:(c||(c=a(e.map(r),t,n)))(r(s(f)))}return d.invert=function(f){return s(i((u||(u=a(t,e.map(r),Td)))(f)))},d.domain=function(f){return arguments.length?(e=Array.from(f,L_t),l()):e.slice()},d.range=function(f){return arguments.length?(t=Array.from(f),l()):t.slice()},d.rangeRound=function(f){return t=Array.from(f),n=B_t,l()},d.clamp=function(f){return arguments.length?(s=!!f||X1,l()):s!==X1},d.interpolate=function(f){return arguments.length?(n=f,l()):n},d.unknown=function(f){return arguments.length?(o=f,d):o},function(f,p){return r=f,i=p,l()}}()(X1,X1)}();return e.copy=function(){return function G_t(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}(e,Vge())},Uge.apply(e,arguments),X_t(e)}class zge extends Map{constructor(t,n=Hge){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),null!=t)for(const[r,i]of t)this.set(r,i)}get(t){return super.get(q7(this,t))}has(t){return super.has(q7(this,t))}set(t,n){return super.set(function Gge({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}(this,t),n)}delete(t){return super.delete(function jge({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}(this,t))}}function q7({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function Hge(e){return null!==e&&"object"==typeof e?e.valueOf():e}Set;const qge=Symbol("implicit");function Wge(){var e=new zge,t=[],n=[],r=qge;function i(o){let s=e.get(o);if(void 0===s){if(r!==qge)return r;e.set(o,s=t.push(o)-1)}return n[s%n.length]}return i.domain=function(o){if(!arguments.length)return t.slice();t=[],e=new zge;for(const s of o)e.has(s)||e.set(s,t.push(s)-1);return i},i.range=function(o){return arguments.length?(n=Array.from(o),i):n.slice()},i.unknown=function(o){return arguments.length?(r=o,i):r},i.copy=function(){return Wge(t,n).unknown(r)},Uge.apply(i,arguments),i}function kl(e){return"string"==typeof e?new Pu([[document.querySelector(e)]],[document.documentElement]):new Pu([[e]],jme)}function K1(e){return function(){return e}}function $ge(e){this._context=e}function Q_t(e){return new $ge(e)}$ge.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};const W7=Math.PI,$7=2*W7,fy=1e-6,J_t=$7-fy;function Yge(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return Yge;const n=10**t;return function(r){this._+=r[0];for(let i=1,o=r.length;ify)if(Math.abs(d*c-u*l)>fy&&o){let p=r-s,m=i-a,h=c*c+u*u,g=p*p+m*m,y=Math.sqrt(h),b=Math.sqrt(f),x=o*Math.tan((W7-Math.acos((h+f-g)/(2*y*b)))/2),_=x/b,S=x/y;Math.abs(_-1)>fy&&this._append`L${t+_*l},${n+_*d}`,this._append`A${o},${o},0,0,${+(d*p>l*m)},${this._x1=t+S*c},${this._y1=n+S*u}`}else this._append`L${this._x1=t},${this._y1=n}`}arc(t,n,r,i,o,s){if(t=+t,n=+n,s=!!s,(r=+r)<0)throw new Error(`negative radius: ${r}`);let a=r*Math.cos(i),c=r*Math.sin(i),u=t+a,l=n+c,d=1^s,f=s?i-o:o-i;null===this._x1?this._append`M${u},${l}`:(Math.abs(this._x1-u)>fy||Math.abs(this._y1-l)>fy)&&this._append`L${u},${l}`,r&&(f<0&&(f=f%$7+$7),f>J_t?this._append`A${r},${r},0,1,${d},${t-a},${n-c}A${r},${r},0,1,${d},${this._x1=u},${this._y1=l}`:f>fy&&this._append`A${r},${r},0,${+(f>=W7)},${d},${this._x1=t+r*Math.cos(o)},${this._y1=n+r*Math.sin(o)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function rxt(e){return e[0]}function ixt(e){return e[1]}function Xge(e){return e<0?-1:1}function Kge(e,t,n){var r=e._x1-e._x0,i=t-e._x1,o=(e._y1-e._y0)/(r||i<0&&-0),s=(n-e._y1)/(i||r<0&&-0),a=(o*i+s*r)/(r+i);return(Xge(o)+Xge(s))*Math.min(Math.abs(o),Math.abs(s),.5*Math.abs(a))||0}function Zge(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function Y7(e,t,n){var r=e._x0,o=e._x1,s=e._y1,a=(o-r)/3;e._context.bezierCurveTo(r+a,e._y0+a*t,o-a,s-a*n,o,s)}function FP(e){this._context=e}function Jge(e){this._context=e}function sxt(e){return new FP(e)}FP.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Y7(this,this._t0,Zge(this,this._t0))}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(t=+t,(e=+e)!==this._x1||t!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Y7(this,Zge(this,n=Kge(this,e,t)),n);break;default:Y7(this,this._t0,n=Kge(this,e,t))}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}},(function Qge(e){this._context=new Jge(e)}.prototype=Object.create(FP.prototype)).point=function(e,t){FP.prototype.point.call(this,t,e)},Jge.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,o){this._context.bezierCurveTo(t,e,r,n,o,i)}};const X7={capture:!0,passive:!1};function K7(e){e.preventDefault(),e.stopImmediatePropagation()}function e0e(e){return((e=Math.exp(e))+1/e)/2}const fxt=function e(t,n,r){function i(o,s){var g,y,a=o[0],c=o[1],u=o[2],f=s[2],p=s[0]-a,m=s[1]-c,h=p*p+m*m;if(h<1e-12)y=Math.log(f/u)/t,g=function(E){return[a+E*p,c+E*m,u*Math.exp(t*E*y)]};else{var b=Math.sqrt(h),x=(f*f-u*u+r*h)/(2*u*n*b),_=(f*f-u*u-r*h)/(2*f*n*b),S=Math.log(Math.sqrt(x*x+1)-x),A=Math.log(Math.sqrt(_*_+1)-_);y=(A-S)/t,g=function(E){var w=E*y,D=e0e(S),I=u/(n*b)*(D*function dxt(e){return((e=Math.exp(2*e))-1)/(e+1)}(t*w+S)-function lxt(e){return((e=Math.exp(e))-1/e)/2}(S));return[a+I*p,c+I*m,u*D/e0e(t*w+S)]}}return g.duration=1e3*y*t/Math.SQRT2,g}return i.rho=function(o){var s=Math.max(.001,+o),a=s*s;return e(s,a,a*a)},i}(Math.SQRT2,2,4);function py(e,t){if(e=function pxt(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,[(r=r.matrixTransform(t.getScreenCTM().inverse())).x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const BP=e=>()=>e;function hxt(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function bh(e,t,n){this.k=e,this.x=t,this.y=n}bh.prototype={constructor:bh,scale:function(e){return 1===e?this:new bh(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new bh(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Z7=new bh(1,0,0);function Q7(e){e.stopImmediatePropagation()}function YC(e){e.preventDefault(),e.stopImmediatePropagation()}function gxt(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function yxt(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function t0e(){return this.__zoom||Z7}function bxt(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function vxt(){return navigator.maxTouchPoints||"ontouchstart"in this}function _xt(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}let XC=(()=>{class e{get div(){return this.root.nativeElement}get width(){return this.div.offsetWidth}get margin(){const{"margin-top":n,"margin-right":r,"margin-bottom":i,"margin-left":o}=this.settings;return{top:n,right:r,bottom:i,left:o}}constructor(){this.initialize$=new ou(1),this.initialized$=this.initialize$.pipe(jr(n=>this.root=n),qt(()=>{const n=function K_t(e){return kl(C7(e).call(document.documentElement))}("svg"),r=n.node();if(!r)throw new Error("Could not create SVG node");return this.div.append(r),n}),jr(n=>this.svg=n),jr(n=>{const r=n.append("defs");this.clip=r.append("SVG:clipPath").attr("id","clip").append("SVG:rect"),this.draw=n.append("g").attr("class","features").attr("clip-path","url(#clip)"),this.zoom=function xxt(){var l,d,f,e=gxt,t=yxt,n=_xt,r=bxt,i=vxt,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=fxt,u=$me("start","zoom","end"),p=500,m=150,h=0,g=10;function y(N){N.property("__zoom",t0e).on("wheel.zoom",w,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",I).filter(i).on("touchstart.zoom",R).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(N,V){return(V=Math.max(o[0],Math.min(o[1],V)))===N.k?N:new bh(V,N.x,N.y)}function x(N,V,F){var G=V[0]-F[0]*N.k,L=V[1]-F[1]*N.k;return G===N.x&&L===N.y?N:new bh(N.k,G,L)}function _(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function S(N,V,F,G){N.on("start.zoom",function(){A(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(G).end()}).tween("zoom",function(){var L=this,z=arguments,j=A(L,z).event(G),Z=t.apply(L,z),$=null==F?_(Z):"function"==typeof F?F.apply(L,z):F,ee=Math.max(Z[1][0]-Z[0][0],Z[1][1]-Z[0][1]),q=L.__zoom,O="function"==typeof V?V.apply(L,z):V,H=c(q.invert($).concat(ee/q.k),O.invert($).concat(ee/O.k));return function(W){if(1===W)W=O;else{var Q=H(W),fe=ee/Q[2];W=new bh(fe,$[0]-Q[0]*fe,$[1]-Q[1]*fe)}j.zoom(null,W)}})}function A(N,V,F){return!F&&N.__zooming||new E(N,V)}function E(N,V){this.that=N,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply(N,V),this.taps=0}function w(N,...V){if(e.apply(this,arguments)){var F=A(this,V).event(N),G=this.__zoom,L=Math.max(o[0],Math.min(o[1],G.k*Math.pow(2,r.apply(this,arguments)))),z=py(N);if(F.wheel)(F.mouse[0][0]!==z[0]||F.mouse[0][1]!==z[1])&&(F.mouse[1]=G.invert(F.mouse[0]=z)),clearTimeout(F.wheel);else{if(G.k===L)return;F.mouse=[z,G.invert(z)],vP(this),F.start()}YC(N),F.wheel=setTimeout(function j(){F.wheel=null,F.end()},m),F.zoom("mouse",n(x(b(G,L),F.mouse[0],F.mouse[1]),F.extent,s))}}function D(N,...V){if(!f&&e.apply(this,arguments)){var F=N.currentTarget,G=A(this,V,!0).event(N),L=kl(N.view).on("mousemove.zoom",function $(q){if(YC(q),!G.moved){var O=q.clientX-j,H=q.clientY-Z;G.moved=O*O+H*H>h}G.event(q).zoom("mouse",n(x(G.that.__zoom,G.mouse[0]=py(q,F),G.mouse[1]),G.extent,s))},!0).on("mouseup.zoom",function ee(q){L.on("mousemove.zoom mouseup.zoom",null),function cxt(e,t){var n=e.document.documentElement,r=kl(e).on("dragstart.drag",null);t&&(r.on("click.drag",K7,X7),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}(q.view,G.moved),YC(q),G.event(q).end()},!0),z=py(N,F),j=N.clientX,Z=N.clientY;(function axt(e){var t=e.document.documentElement,n=kl(e).on("dragstart.drag",K7,X7);"onselectstart"in t?n.on("selectstart.drag",K7,X7):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")})(N.view),Q7(N),G.mouse=[z,this.__zoom.invert(z)],vP(this),G.start()}}function I(N,...V){if(e.apply(this,arguments)){var F=this.__zoom,G=py(N.changedTouches?N.changedTouches[0]:N,this),L=F.invert(G),j=n(x(b(F,F.k*(N.shiftKey?.5:2)),G,L),t.apply(this,V),s);YC(N),a>0?kl(this).transition().duration(a).call(S,j,G,N):kl(this).call(y.transform,j,G,N)}}function R(N,...V){if(e.apply(this,arguments)){var z,j,Z,$,F=N.touches,G=F.length,L=A(this,V,N.changedTouches.length===G).event(N);for(Q7(N),j=0;j{const r=n.append("g").attr("class","x axis"),i=n.append("g").attr("class","y axis");this.axes={x:r,y:i}}),jr(()=>this.scale={x:Vge(),y:Wge()}),Zl(1))}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();function Sxt(e){return"trace"!==e.type?{type:"trace",values:[e],label:e.label}:{...e,type:"trace"}}let J7=(()=>{class e{set hierarchy(n){let r=0;for(n=[...n],this._traces=new Map,this._parent=new Map,this._children=new Map;n.length>0;){const i=n.splice(0,1).at(0),{nested:o,...s}=i,a=Object.assign(i,Sxt(s));this._children.set(a,[]);for(const u of o||[])this._parent.set(u,r),n.push(u);const c=this.getParent(a);c&&this._children.get(c).push(r),this._traces.set(r,a),r++}}get traces(){return this._traces}getTrace(n){return this.traces.get(n)}getParent(n){const r=this._parent.get(n);return r&&this._traces.get(r)}getBranch(n){const r=[],i=[n];for(;i.length>0;){const o=i.pop();r.push(o);const s=this.getChildren(o);i.push(...s)}return r}getChildren(n){return this._children.get(n).map(i=>this._traces.get(i))}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"root"})}return e})();function n0e(e,t,n){e.attr("height",t.height).attr("width",t.width).attr("y",n.top).attr("x",n.left)}let eG=(()=>{class e{get svg(){return this.initializeService.svg}get div(){return this.initializeService.div}get height(){return this.div.offsetHeight}get width(){return this.div.offsetWidth}get margin(){return this.initializeService.margin}get scale(){return this.initializeService.scale}get axes(){return this.initializeService.axes}constructor(n){this.initializeService=n,this.resize$=new ou(1);const r=this.resize$.pipe(qt(()=>({width:this.width,height:this.height})),afe(100),Bde((i,o)=>i.width===o.width),qt(()=>{}),Dx(void 0));this.resized$=r.pipe(qt(()=>this.updateRoot()),qt(()=>this.updateDraw()),qt(()=>this.updateAxes()),qt(()=>this.updateRangeX()),qt(()=>this.updateRangeY()),jr(()=>console.log("Resized!")))}updateRoot(){const{y:n}=this.scale,i=n.range().at(-1)+this.margin.bottom,o=this.width;this.svg.attr("height",i).attr("width",o)}updateDraw(){const n={width:0,height:0};n.height=this.height-this.margin.top-this.margin.bottom,n.width=this.width-this.margin.left-this.margin.right,n0e(this.initializeService.clip,n,this.margin),n0e(this.initializeService.events,n,this.margin)}updateAxes(){const{x:n,y:r}=this.axes;n.attr("transform",`translate(0, ${this.height-this.margin.top})`),r.attr("transform",`translate(${this.margin.left}, 0)`)}updateRangeX(){const n=this.scale.x,r=this.width,{left:i,right:o}=this.margin;n.range([i,r-o])}updateRangeY(){}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(XC))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})(),r0e=(()=>{class e{get draw(){return this.initService.draw}constructor(n){this.initService=n,this.zoom$=new ou(1);const i=this.initService.initialized$.pipe(qt(()=>this._scale={x:this.initService.scale.x.copy(),y:this.initService.scale.y.copy()}),Zl(1)).pipe(To(()=>this.zoom$),qt(o=>{const{x:s}=this._scale,{x:a}=this.initService.scale,c=o.transform.rescaleX(s),[u,l]=c.domain();return a.domain([u,l]),this.initService.scale}),Dx(this.initService.scale));this.zoomed$=i.pipe(qt(()=>{const o=this.initService.axes,s=this.initService.scale,a=s.x.ticks().filter(u=>Number.isInteger(u)).slice(1,-1),c=function qyt(e){return cP(3,e)}(s.x).tickValues(a).tickFormat(z7(".0f"));o.x.call(c)}),jr(()=>console.log("Zoomed!")))}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(XC))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();const i0e={H:"blue",K:"blue",R:"blue",D:"red",E:"red",S:"green",T:"green",N:"green",Q:"green",A:"white",V:"white",L:"white",I:"white",M:"white",F:"magenta",W:"magenta",Y:"magenta",P:"brown",G:"brown",C:"yellow",B:"grey",Z:"grey",X:"grey","-":"grey"},tG=(parseFloat(getComputedStyle(document.documentElement).fontSize),e=>e.id),Qm=(e,t)=>t;let o0e=(()=>{class e{constructor(n,r,i){this.initializeService=n,this.featuresService=r,this.resizeService=i,this.traces$=new ou(1),this.sequence$=new ou(1),this.draw$=this.sequence$.pipe(jr(o=>{this.initializeService.scale.x.domain([0,o.length+1])}),qt(o=>this.createSequence(o)),Zl(1),To(()=>this.traces$),jr(o=>this.updateScale(o)),jr(o=>this.createLabels(o)),jr(o=>this.createGrid(o)),jr(o=>this.createTraces(o)),Zl(1)),this.drawn$=this.draw$.pipe(qt(()=>this.updateSequence()),qt(()=>this.updateGrid()),qt(()=>this.updateLabels()),qt(()=>this.updateTraces()),jr(()=>console.log("Re-drawn!")))}updateScale(n){const r=this.initializeService.scale.y,i=["sequence",...n.map(({id:s})=>String(s))],o=i.reduce((s,a,c)=>{if(0===c&&"sequence"===a){const d=this.initializeService.settings["margin-top"];return[d,d+this.initializeService.settings["line-height"]]}const u=this.featuresService.getTrace(+a);if(u){const l=s.at(-1);let d=u["line-height"]||this.initializeService.settings["line-height"];return"dodge"===u.position&&(d=u.values.reduce((f,p)=>f+(p["line-height"]||this.initializeService.settings["line-height"]),0)),[...s,l+d]}throw new Error("Trace not found")},[]);r.domain(i).range(o)}createSequence(n){const i=this.initializeService.draw.selectAll("g.sequence").data([n]).join("g").attr("class","sequence");this.residues=i.selectAll("g.residue").data(n).join("g").attr("id",(o,s)=>`residue-${s+1}`).attr("class","residue"),this.residues.append("rect").attr("class","color").attr("fill",o=>(o=>i0e[o]||i0e.X)(o)).attr("fill-opacity",.1),this.residues.append("text").attr("class","name").text(o=>""+o)}updateSequence(){const n=this.initializeService.settings["line-height"],r=this.initializeService.margin,{x:i,y:o}=this.initializeService.scale,s=i(1)-i(0);this.residues.select("rect.color").attr("x",(a,c)=>i(c+.5)).attr("y",r.top).attr("width",()=>s).attr("height","100%"),this.residues.select("text.name").attr("x",(a,c)=>i(c+1)).attr("y",o("sequence")+n/2).attr("width",()=>s).attr("height",n).attr("dominant-baseline","central").style("text-anchor","middle")}createLabels(n){const r=this.initializeService.settings,{left:i}=this.initializeService.margin,o=this.initializeService.svg.selectAll("g.labels").data([n],Qm).join("g").attr("class","labels");this.labels=o.selectAll("g.label").data([{id:"sequence",label:"Sequence",visible:!0},...n],tG).join("g").attr("id",s=>"label-"+String(s.id)).attr("class","label"),this.labels.selectAll("rect").data(s=>[s],Qm).join("rect").attr("height",s=>s["line-height"]||r["line-height"]).attr("width",()=>i).attr("fill","none").attr("stroke","#D3D3D380"),this.labels.selectAll("text").data(s=>[s],Qm).join("text").text(s=>(s.label||"")+" "+(s.visible?"(visible)":"(hidden)")).attr("height",s=>s["line-height"]||r["line-height"]).attr("width",()=>i).filter(s=>"sequence"!==s.id).on("click",(s,a)=>{a.visible=!1===a.visible;const c=Array.from(this.featuresService.traces.values()),u=new Array;for(const l of c){const{visible:d}={visible:!0,...l};if(!0!==d){const f=this.featuresService.getBranch(l).slice(1);u.push(...f)}}this.traces$.next(c.filter(l=>!u.includes(l)))})}updateLabels(){const n=this.initializeService.scale.y,r=this.initializeService.settings;this.labels.select("rect").attr("y",i=>n(String(i.id))).attr("x",0),this.labels.select("text").attr("y",i=>n(String(i.id))+(i["line-height"]||r["line-height"])/2).attr("x",0).attr("dominant-baseline","central")}createGrid(n){const r=this.initializeService.svg.selectAll("g.grid").data([n],Qm).join("g").attr("class","grid");this.grid=r.selectAll("rect.grid-line").data(n,tG).join("rect").attr("id",i=>"grid-"+String(i.id)).attr("class","grid-line")}updateGrid(){const n=this.initializeService.scale.y,r=this.initializeService.width,i=this.initializeService.margin,o=this.initializeService.settings;this.grid.attr("x",i.left).attr("y",s=>{const c=s.values.sort((f,p)=>"continuous"===f.type?-1:"continuous"===p.type?1:0)[0],u=n(String(s.id)),l=c["line-height"]||s["line-height"]||o["line-height"];return"continuous"!==c.type?u+l/2-.5:u+l/2-(c["content-size"]||s["content-size"]||o["content-size"])/2}).attr("width",r-i.left-i.right).attr("height",s=>{const a=s.values[0];return"continuous"===a.type?a["content-size"]||s["content-size"]||o["content-size"]:1}).attr("fill",this.initializeService.settings["grid-color"])}createTraces(n){this.traces=this.initializeService.draw.selectAll("g.trace").data(n,tG).join("g").attr("id",r=>"trace-"+String(r.id)).attr("class","trace"),this.traces.each(function(r){kl(this).selectAll("g.feature").data(r.values,Qm).join("g").attr("class","feature").each(function(o){const s=kl(this);"continuous"===o.type?s.selectAll("path.continuous").data([o],Qm).join("path").attr("class","continuous").attr("fill","pink").attr("fill-opacity",0).attr("stroke","#ff1493").attr("stroke-opacity",1).attr("stroke-width",2):s.selectAll("rect.locus").data(o.values,Qm).join("rect").attr("class","locus").attr("fill","steelblue").attr("fill-opacity",.3).attr("stroke","steelblue").attr("stroke-opacity",1).attr("stroke-width",1.5)})})}updateTraces(){const n=this.initializeService.scale,r=this.initializeService.settings;this.traces.each(function(i){const o=i.values;kl(this).selectAll("g.feature").each(function(a,c){const u=kl(this),l=o[c],d=n.y(String(i.id)),f=l["line-height"]||i["line-height"]||r["line-height"],p=l["content-size"]||i["content-size"]||r["content-size"];if("continuous"===l.type){const m=l.values,h=void 0!==l.min?l.min:Math.min(...l.values),g=void 0!==l.max?l.max:Math.max(...l.values),y=m.map((_,S)=>[S+1,1-(_-h)/(g-h)]),b=u.select("path.continuous"),x=function oxt(e,t){var n=K1(!0),r=null,i=Q_t,o=null,s=function nxt(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(null==n)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new NP(t)}(a);function a(c){var u,d,p,l=(c=function Z_t(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}(c)).length,f=!1;for(null==r&&(o=i(p=s())),u=0;u<=l;++u)!(un.x(_)).y(([_,S])=>d+f/2-p/2+p*S);b.attr("d",x(y))}else{const m=n.x(1)-n.x(0);u.selectAll("rect.locus").data(l.values,Qm).attr("x",h=>n.x(h.start-.5)).attr("y",d+f/2-p/2).attr("height",p).attr("width",h=>{const{start:g,end:y}={end:h.start+1,...h};return m*(y-g)})}})})}static#e=this.\u0275fac=function(r){return new(r||e)(Zt(XC),Zt(J7),Zt(eG))};static#t=this.\u0275prov=Gt({token:e,factory:e.\u0275fac,providedIn:"platform"})}return e})();const Cxt=["root"];let wxt=(()=>{class e{set settings(n){this.initService.settings=n}set features(n){this.featuresService.hierarchy=n;const r=Array.from(this.featuresService.traces.entries()).map(([i,o])=>Object.assign(o,{id:i,visible:!0}));this.traces$.next(r)}constructor(n,r,i,o,s){this.featuresService=n,this.initService=r,this.resizeService=i,this.zoomService=o,this.drawService=s,this.traces$=this.drawService.traces$,this.sequence$=this.drawService.sequence$,this.update$=this.initService.initialized$.pipe(To(()=>this.drawService.draw$),To(()=>this.resizeService.resized$),jr(()=>{const{margin:a,width:c}=this.resizeService,u=this.sequence.length+1;this.initService.zoom.extent([[a.left,0],[c-a.right,1/0]]).scaleExtent([1,u/5]).translateExtent([[a.left,0],[c-a.right,0]]).on("zoom",l=>{this.onFeaturesZoom(l)})}),To(()=>this.zoomService.zoomed$),To(()=>this.drawService.drawn$)),this._update=this.update$.subscribe()}ngOnChanges(n){n&&n.sequence&&this.sequence$.next(this.sequence)}ngAfterViewInit(){this.initService.initialize$.next(this._root)}ngOnDestroy(){this._update.unsubscribe()}onResize(n){this.resizeService.resize$.next(n)}onFeaturesZoom(n){this.zoomService.zoom$.next(n)}static#e=this.\u0275fac=function(r){return new(r||e)(cn(J7),cn(XC),cn(eG),cn(r0e),cn(o0e))};static#t=this.\u0275cmp=Mu({type:e,selectors:[["ngx-features-viewer"]],viewQuery:function(r,i){if(1&r&&uN(Cxt,5),2&r){let o;EA(o=PA())&&(i._root=o.first)}},hostBindings:function(r,i){1&r&&px("resize",function(s){return i.onResize(s)},0,Hj)},inputs:{settings:"settings",features:"features",sequence:"sequence"},standalone:!0,features:[mN([XC,J7,eG,o0e,r0e]),wh,Nu],decls:2,vars:0,consts:[["root",""],[2,"position","relative","display","block","width","100%","height","100%"]],template:function(r,i){1&r&&gi(0,"div",1,0)},styles:['@charset "UTF-8";.labels #label-sequence .parent div{cursor:default}.labels #label-sequence .parent div i{display:none}.labels .label .children-0>i{visibility:hidden}.labels .label i:before{transition:transform .4s}.labels .label.active i:before{transform:roate(0deg)}.labels .label:not(.active) i:before{transform:rotate(-90deg)}.labels .label div{display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between;align-items:center;box-sizing:border-box;height:100%;width:100%;cursor:pointer}.labels .label div span{text-wrap:wrap;line-break:anywhere;flex-shrink:1;flex-grow:1}.labels .label div i{flex-shrink:0;flex-grow:0}.labels div.depth-0{width:100%;padding:0 .25rem 0 .75rem}.labels div.depth-1{width:100%;padding:0 .25rem 0 1.5rem}.labels div.depth-2{width:100%;padding:0 .25rem 0 2.25rem}.labels div.depth-3{width:100%;padding:0 .25rem 0 3rem}.labels div.depth-4{width:100%;padding:0 .25rem 0 3.75rem}.labels div.depth-5{width:100%;padding:0 .25rem 0 4.5rem}/*!\n * Bootstrap Icons v1.11.3 (https://icons.getbootstrap.com/)\n * Copyright 2019-2024 The Bootstrap Authors\n * Licensed under MIT (https://github.com/twbs/icons/blob/main/LICENSE)\n */@font-face{font-display:block;font-family:bootstrap-icons;src:url(bootstrap-icons.bfa90bda92a84a6a.woff2) format("woff2"),url(bootstrap-icons.70a9dee9e5ab72aa.woff) format("woff")}.bi:before,[class^=bi-]:before,[class*=" bi-"]:before{display:inline-block;font-family:bootstrap-icons!important;font-style:normal;font-weight:400!important;font-variant:normal;text-transform:none;line-height:1;vertical-align:-.125em;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.bi-123:before{content:"\\f67f"}.bi-alarm-fill:before{content:"\\f101"}.bi-alarm:before{content:"\\f102"}.bi-align-bottom:before{content:"\\f103"}.bi-align-center:before{content:"\\f104"}.bi-align-end:before{content:"\\f105"}.bi-align-middle:before{content:"\\f106"}.bi-align-start:before{content:"\\f107"}.bi-align-top:before{content:"\\f108"}.bi-alt:before{content:"\\f109"}.bi-app-indicator:before{content:"\\f10a"}.bi-app:before{content:"\\f10b"}.bi-archive-fill:before{content:"\\f10c"}.bi-archive:before{content:"\\f10d"}.bi-arrow-90deg-down:before{content:"\\f10e"}.bi-arrow-90deg-left:before{content:"\\f10f"}.bi-arrow-90deg-right:before{content:"\\f110"}.bi-arrow-90deg-up:before{content:"\\f111"}.bi-arrow-bar-down:before{content:"\\f112"}.bi-arrow-bar-left:before{content:"\\f113"}.bi-arrow-bar-right:before{content:"\\f114"}.bi-arrow-bar-up:before{content:"\\f115"}.bi-arrow-clockwise:before{content:"\\f116"}.bi-arrow-counterclockwise:before{content:"\\f117"}.bi-arrow-down-circle-fill:before{content:"\\f118"}.bi-arrow-down-circle:before{content:"\\f119"}.bi-arrow-down-left-circle-fill:before{content:"\\f11a"}.bi-arrow-down-left-circle:before{content:"\\f11b"}.bi-arrow-down-left-square-fill:before{content:"\\f11c"}.bi-arrow-down-left-square:before{content:"\\f11d"}.bi-arrow-down-left:before{content:"\\f11e"}.bi-arrow-down-right-circle-fill:before{content:"\\f11f"}.bi-arrow-down-right-circle:before{content:"\\f120"}.bi-arrow-down-right-square-fill:before{content:"\\f121"}.bi-arrow-down-right-square:before{content:"\\f122"}.bi-arrow-down-right:before{content:"\\f123"}.bi-arrow-down-short:before{content:"\\f124"}.bi-arrow-down-square-fill:before{content:"\\f125"}.bi-arrow-down-square:before{content:"\\f126"}.bi-arrow-down-up:before{content:"\\f127"}.bi-arrow-down:before{content:"\\f128"}.bi-arrow-left-circle-fill:before{content:"\\f129"}.bi-arrow-left-circle:before{content:"\\f12a"}.bi-arrow-left-right:before{content:"\\f12b"}.bi-arrow-left-short:before{content:"\\f12c"}.bi-arrow-left-square-fill:before{content:"\\f12d"}.bi-arrow-left-square:before{content:"\\f12e"}.bi-arrow-left:before{content:"\\f12f"}.bi-arrow-repeat:before{content:"\\f130"}.bi-arrow-return-left:before{content:"\\f131"}.bi-arrow-return-right:before{content:"\\f132"}.bi-arrow-right-circle-fill:before{content:"\\f133"}.bi-arrow-right-circle:before{content:"\\f134"}.bi-arrow-right-short:before{content:"\\f135"}.bi-arrow-right-square-fill:before{content:"\\f136"}.bi-arrow-right-square:before{content:"\\f137"}.bi-arrow-right:before{content:"\\f138"}.bi-arrow-up-circle-fill:before{content:"\\f139"}.bi-arrow-up-circle:before{content:"\\f13a"}.bi-arrow-up-left-circle-fill:before{content:"\\f13b"}.bi-arrow-up-left-circle:before{content:"\\f13c"}.bi-arrow-up-left-square-fill:before{content:"\\f13d"}.bi-arrow-up-left-square:before{content:"\\f13e"}.bi-arrow-up-left:before{content:"\\f13f"}.bi-arrow-up-right-circle-fill:before{content:"\\f140"}.bi-arrow-up-right-circle:before{content:"\\f141"}.bi-arrow-up-right-square-fill:before{content:"\\f142"}.bi-arrow-up-right-square:before{content:"\\f143"}.bi-arrow-up-right:before{content:"\\f144"}.bi-arrow-up-short:before{content:"\\f145"}.bi-arrow-up-square-fill:before{content:"\\f146"}.bi-arrow-up-square:before{content:"\\f147"}.bi-arrow-up:before{content:"\\f148"}.bi-arrows-angle-contract:before{content:"\\f149"}.bi-arrows-angle-expand:before{content:"\\f14a"}.bi-arrows-collapse:before{content:"\\f14b"}.bi-arrows-expand:before{content:"\\f14c"}.bi-arrows-fullscreen:before{content:"\\f14d"}.bi-arrows-move:before{content:"\\f14e"}.bi-aspect-ratio-fill:before{content:"\\f14f"}.bi-aspect-ratio:before{content:"\\f150"}.bi-asterisk:before{content:"\\f151"}.bi-at:before{content:"\\f152"}.bi-award-fill:before{content:"\\f153"}.bi-award:before{content:"\\f154"}.bi-back:before{content:"\\f155"}.bi-backspace-fill:before{content:"\\f156"}.bi-backspace-reverse-fill:before{content:"\\f157"}.bi-backspace-reverse:before{content:"\\f158"}.bi-backspace:before{content:"\\f159"}.bi-badge-3d-fill:before{content:"\\f15a"}.bi-badge-3d:before{content:"\\f15b"}.bi-badge-4k-fill:before{content:"\\f15c"}.bi-badge-4k:before{content:"\\f15d"}.bi-badge-8k-fill:before{content:"\\f15e"}.bi-badge-8k:before{content:"\\f15f"}.bi-badge-ad-fill:before{content:"\\f160"}.bi-badge-ad:before{content:"\\f161"}.bi-badge-ar-fill:before{content:"\\f162"}.bi-badge-ar:before{content:"\\f163"}.bi-badge-cc-fill:before{content:"\\f164"}.bi-badge-cc:before{content:"\\f165"}.bi-badge-hd-fill:before{content:"\\f166"}.bi-badge-hd:before{content:"\\f167"}.bi-badge-tm-fill:before{content:"\\f168"}.bi-badge-tm:before{content:"\\f169"}.bi-badge-vo-fill:before{content:"\\f16a"}.bi-badge-vo:before{content:"\\f16b"}.bi-badge-vr-fill:before{content:"\\f16c"}.bi-badge-vr:before{content:"\\f16d"}.bi-badge-wc-fill:before{content:"\\f16e"}.bi-badge-wc:before{content:"\\f16f"}.bi-bag-check-fill:before{content:"\\f170"}.bi-bag-check:before{content:"\\f171"}.bi-bag-dash-fill:before{content:"\\f172"}.bi-bag-dash:before{content:"\\f173"}.bi-bag-fill:before{content:"\\f174"}.bi-bag-plus-fill:before{content:"\\f175"}.bi-bag-plus:before{content:"\\f176"}.bi-bag-x-fill:before{content:"\\f177"}.bi-bag-x:before{content:"\\f178"}.bi-bag:before{content:"\\f179"}.bi-bar-chart-fill:before{content:"\\f17a"}.bi-bar-chart-line-fill:before{content:"\\f17b"}.bi-bar-chart-line:before{content:"\\f17c"}.bi-bar-chart-steps:before{content:"\\f17d"}.bi-bar-chart:before{content:"\\f17e"}.bi-basket-fill:before{content:"\\f17f"}.bi-basket:before{content:"\\f180"}.bi-basket2-fill:before{content:"\\f181"}.bi-basket2:before{content:"\\f182"}.bi-basket3-fill:before{content:"\\f183"}.bi-basket3:before{content:"\\f184"}.bi-battery-charging:before{content:"\\f185"}.bi-battery-full:before{content:"\\f186"}.bi-battery-half:before{content:"\\f187"}.bi-battery:before{content:"\\f188"}.bi-bell-fill:before{content:"\\f189"}.bi-bell:before{content:"\\f18a"}.bi-bezier:before{content:"\\f18b"}.bi-bezier2:before{content:"\\f18c"}.bi-bicycle:before{content:"\\f18d"}.bi-binoculars-fill:before{content:"\\f18e"}.bi-binoculars:before{content:"\\f18f"}.bi-blockquote-left:before{content:"\\f190"}.bi-blockquote-right:before{content:"\\f191"}.bi-book-fill:before{content:"\\f192"}.bi-book-half:before{content:"\\f193"}.bi-book:before{content:"\\f194"}.bi-bookmark-check-fill:before{content:"\\f195"}.bi-bookmark-check:before{content:"\\f196"}.bi-bookmark-dash-fill:before{content:"\\f197"}.bi-bookmark-dash:before{content:"\\f198"}.bi-bookmark-fill:before{content:"\\f199"}.bi-bookmark-heart-fill:before{content:"\\f19a"}.bi-bookmark-heart:before{content:"\\f19b"}.bi-bookmark-plus-fill:before{content:"\\f19c"}.bi-bookmark-plus:before{content:"\\f19d"}.bi-bookmark-star-fill:before{content:"\\f19e"}.bi-bookmark-star:before{content:"\\f19f"}.bi-bookmark-x-fill:before{content:"\\f1a0"}.bi-bookmark-x:before{content:"\\f1a1"}.bi-bookmark:before{content:"\\f1a2"}.bi-bookmarks-fill:before{content:"\\f1a3"}.bi-bookmarks:before{content:"\\f1a4"}.bi-bookshelf:before{content:"\\f1a5"}.bi-bootstrap-fill:before{content:"\\f1a6"}.bi-bootstrap-reboot:before{content:"\\f1a7"}.bi-bootstrap:before{content:"\\f1a8"}.bi-border-all:before{content:"\\f1a9"}.bi-border-bottom:before{content:"\\f1aa"}.bi-border-center:before{content:"\\f1ab"}.bi-border-inner:before{content:"\\f1ac"}.bi-border-left:before{content:"\\f1ad"}.bi-border-middle:before{content:"\\f1ae"}.bi-border-outer:before{content:"\\f1af"}.bi-border-right:before{content:"\\f1b0"}.bi-border-style:before{content:"\\f1b1"}.bi-border-top:before{content:"\\f1b2"}.bi-border-width:before{content:"\\f1b3"}.bi-border:before{content:"\\f1b4"}.bi-bounding-box-circles:before{content:"\\f1b5"}.bi-bounding-box:before{content:"\\f1b6"}.bi-box-arrow-down-left:before{content:"\\f1b7"}.bi-box-arrow-down-right:before{content:"\\f1b8"}.bi-box-arrow-down:before{content:"\\f1b9"}.bi-box-arrow-in-down-left:before{content:"\\f1ba"}.bi-box-arrow-in-down-right:before{content:"\\f1bb"}.bi-box-arrow-in-down:before{content:"\\f1bc"}.bi-box-arrow-in-left:before{content:"\\f1bd"}.bi-box-arrow-in-right:before{content:"\\f1be"}.bi-box-arrow-in-up-left:before{content:"\\f1bf"}.bi-box-arrow-in-up-right:before{content:"\\f1c0"}.bi-box-arrow-in-up:before{content:"\\f1c1"}.bi-box-arrow-left:before{content:"\\f1c2"}.bi-box-arrow-right:before{content:"\\f1c3"}.bi-box-arrow-up-left:before{content:"\\f1c4"}.bi-box-arrow-up-right:before{content:"\\f1c5"}.bi-box-arrow-up:before{content:"\\f1c6"}.bi-box-seam:before{content:"\\f1c7"}.bi-box:before{content:"\\f1c8"}.bi-braces:before{content:"\\f1c9"}.bi-bricks:before{content:"\\f1ca"}.bi-briefcase-fill:before{content:"\\f1cb"}.bi-briefcase:before{content:"\\f1cc"}.bi-brightness-alt-high-fill:before{content:"\\f1cd"}.bi-brightness-alt-high:before{content:"\\f1ce"}.bi-brightness-alt-low-fill:before{content:"\\f1cf"}.bi-brightness-alt-low:before{content:"\\f1d0"}.bi-brightness-high-fill:before{content:"\\f1d1"}.bi-brightness-high:before{content:"\\f1d2"}.bi-brightness-low-fill:before{content:"\\f1d3"}.bi-brightness-low:before{content:"\\f1d4"}.bi-broadcast-pin:before{content:"\\f1d5"}.bi-broadcast:before{content:"\\f1d6"}.bi-brush-fill:before{content:"\\f1d7"}.bi-brush:before{content:"\\f1d8"}.bi-bucket-fill:before{content:"\\f1d9"}.bi-bucket:before{content:"\\f1da"}.bi-bug-fill:before{content:"\\f1db"}.bi-bug:before{content:"\\f1dc"}.bi-building:before{content:"\\f1dd"}.bi-bullseye:before{content:"\\f1de"}.bi-calculator-fill:before{content:"\\f1df"}.bi-calculator:before{content:"\\f1e0"}.bi-calendar-check-fill:before{content:"\\f1e1"}.bi-calendar-check:before{content:"\\f1e2"}.bi-calendar-date-fill:before{content:"\\f1e3"}.bi-calendar-date:before{content:"\\f1e4"}.bi-calendar-day-fill:before{content:"\\f1e5"}.bi-calendar-day:before{content:"\\f1e6"}.bi-calendar-event-fill:before{content:"\\f1e7"}.bi-calendar-event:before{content:"\\f1e8"}.bi-calendar-fill:before{content:"\\f1e9"}.bi-calendar-minus-fill:before{content:"\\f1ea"}.bi-calendar-minus:before{content:"\\f1eb"}.bi-calendar-month-fill:before{content:"\\f1ec"}.bi-calendar-month:before{content:"\\f1ed"}.bi-calendar-plus-fill:before{content:"\\f1ee"}.bi-calendar-plus:before{content:"\\f1ef"}.bi-calendar-range-fill:before{content:"\\f1f0"}.bi-calendar-range:before{content:"\\f1f1"}.bi-calendar-week-fill:before{content:"\\f1f2"}.bi-calendar-week:before{content:"\\f1f3"}.bi-calendar-x-fill:before{content:"\\f1f4"}.bi-calendar-x:before{content:"\\f1f5"}.bi-calendar:before{content:"\\f1f6"}.bi-calendar2-check-fill:before{content:"\\f1f7"}.bi-calendar2-check:before{content:"\\f1f8"}.bi-calendar2-date-fill:before{content:"\\f1f9"}.bi-calendar2-date:before{content:"\\f1fa"}.bi-calendar2-day-fill:before{content:"\\f1fb"}.bi-calendar2-day:before{content:"\\f1fc"}.bi-calendar2-event-fill:before{content:"\\f1fd"}.bi-calendar2-event:before{content:"\\f1fe"}.bi-calendar2-fill:before{content:"\\f1ff"}.bi-calendar2-minus-fill:before{content:"\\f200"}.bi-calendar2-minus:before{content:"\\f201"}.bi-calendar2-month-fill:before{content:"\\f202"}.bi-calendar2-month:before{content:"\\f203"}.bi-calendar2-plus-fill:before{content:"\\f204"}.bi-calendar2-plus:before{content:"\\f205"}.bi-calendar2-range-fill:before{content:"\\f206"}.bi-calendar2-range:before{content:"\\f207"}.bi-calendar2-week-fill:before{content:"\\f208"}.bi-calendar2-week:before{content:"\\f209"}.bi-calendar2-x-fill:before{content:"\\f20a"}.bi-calendar2-x:before{content:"\\f20b"}.bi-calendar2:before{content:"\\f20c"}.bi-calendar3-event-fill:before{content:"\\f20d"}.bi-calendar3-event:before{content:"\\f20e"}.bi-calendar3-fill:before{content:"\\f20f"}.bi-calendar3-range-fill:before{content:"\\f210"}.bi-calendar3-range:before{content:"\\f211"}.bi-calendar3-week-fill:before{content:"\\f212"}.bi-calendar3-week:before{content:"\\f213"}.bi-calendar3:before{content:"\\f214"}.bi-calendar4-event:before{content:"\\f215"}.bi-calendar4-range:before{content:"\\f216"}.bi-calendar4-week:before{content:"\\f217"}.bi-calendar4:before{content:"\\f218"}.bi-camera-fill:before{content:"\\f219"}.bi-camera-reels-fill:before{content:"\\f21a"}.bi-camera-reels:before{content:"\\f21b"}.bi-camera-video-fill:before{content:"\\f21c"}.bi-camera-video-off-fill:before{content:"\\f21d"}.bi-camera-video-off:before{content:"\\f21e"}.bi-camera-video:before{content:"\\f21f"}.bi-camera:before{content:"\\f220"}.bi-camera2:before{content:"\\f221"}.bi-capslock-fill:before{content:"\\f222"}.bi-capslock:before{content:"\\f223"}.bi-card-checklist:before{content:"\\f224"}.bi-card-heading:before{content:"\\f225"}.bi-card-image:before{content:"\\f226"}.bi-card-list:before{content:"\\f227"}.bi-card-text:before{content:"\\f228"}.bi-caret-down-fill:before{content:"\\f229"}.bi-caret-down-square-fill:before{content:"\\f22a"}.bi-caret-down-square:before{content:"\\f22b"}.bi-caret-down:before{content:"\\f22c"}.bi-caret-left-fill:before{content:"\\f22d"}.bi-caret-left-square-fill:before{content:"\\f22e"}.bi-caret-left-square:before{content:"\\f22f"}.bi-caret-left:before{content:"\\f230"}.bi-caret-right-fill:before{content:"\\f231"}.bi-caret-right-square-fill:before{content:"\\f232"}.bi-caret-right-square:before{content:"\\f233"}.bi-caret-right:before{content:"\\f234"}.bi-caret-up-fill:before{content:"\\f235"}.bi-caret-up-square-fill:before{content:"\\f236"}.bi-caret-up-square:before{content:"\\f237"}.bi-caret-up:before{content:"\\f238"}.bi-cart-check-fill:before{content:"\\f239"}.bi-cart-check:before{content:"\\f23a"}.bi-cart-dash-fill:before{content:"\\f23b"}.bi-cart-dash:before{content:"\\f23c"}.bi-cart-fill:before{content:"\\f23d"}.bi-cart-plus-fill:before{content:"\\f23e"}.bi-cart-plus:before{content:"\\f23f"}.bi-cart-x-fill:before{content:"\\f240"}.bi-cart-x:before{content:"\\f241"}.bi-cart:before{content:"\\f242"}.bi-cart2:before{content:"\\f243"}.bi-cart3:before{content:"\\f244"}.bi-cart4:before{content:"\\f245"}.bi-cash-stack:before{content:"\\f246"}.bi-cash:before{content:"\\f247"}.bi-cast:before{content:"\\f248"}.bi-chat-dots-fill:before{content:"\\f249"}.bi-chat-dots:before{content:"\\f24a"}.bi-chat-fill:before{content:"\\f24b"}.bi-chat-left-dots-fill:before{content:"\\f24c"}.bi-chat-left-dots:before{content:"\\f24d"}.bi-chat-left-fill:before{content:"\\f24e"}.bi-chat-left-quote-fill:before{content:"\\f24f"}.bi-chat-left-quote:before{content:"\\f250"}.bi-chat-left-text-fill:before{content:"\\f251"}.bi-chat-left-text:before{content:"\\f252"}.bi-chat-left:before{content:"\\f253"}.bi-chat-quote-fill:before{content:"\\f254"}.bi-chat-quote:before{content:"\\f255"}.bi-chat-right-dots-fill:before{content:"\\f256"}.bi-chat-right-dots:before{content:"\\f257"}.bi-chat-right-fill:before{content:"\\f258"}.bi-chat-right-quote-fill:before{content:"\\f259"}.bi-chat-right-quote:before{content:"\\f25a"}.bi-chat-right-text-fill:before{content:"\\f25b"}.bi-chat-right-text:before{content:"\\f25c"}.bi-chat-right:before{content:"\\f25d"}.bi-chat-square-dots-fill:before{content:"\\f25e"}.bi-chat-square-dots:before{content:"\\f25f"}.bi-chat-square-fill:before{content:"\\f260"}.bi-chat-square-quote-fill:before{content:"\\f261"}.bi-chat-square-quote:before{content:"\\f262"}.bi-chat-square-text-fill:before{content:"\\f263"}.bi-chat-square-text:before{content:"\\f264"}.bi-chat-square:before{content:"\\f265"}.bi-chat-text-fill:before{content:"\\f266"}.bi-chat-text:before{content:"\\f267"}.bi-chat:before{content:"\\f268"}.bi-check-all:before{content:"\\f269"}.bi-check-circle-fill:before{content:"\\f26a"}.bi-check-circle:before{content:"\\f26b"}.bi-check-square-fill:before{content:"\\f26c"}.bi-check-square:before{content:"\\f26d"}.bi-check:before{content:"\\f26e"}.bi-check2-all:before{content:"\\f26f"}.bi-check2-circle:before{content:"\\f270"}.bi-check2-square:before{content:"\\f271"}.bi-check2:before{content:"\\f272"}.bi-chevron-bar-contract:before{content:"\\f273"}.bi-chevron-bar-down:before{content:"\\f274"}.bi-chevron-bar-expand:before{content:"\\f275"}.bi-chevron-bar-left:before{content:"\\f276"}.bi-chevron-bar-right:before{content:"\\f277"}.bi-chevron-bar-up:before{content:"\\f278"}.bi-chevron-compact-down:before{content:"\\f279"}.bi-chevron-compact-left:before{content:"\\f27a"}.bi-chevron-compact-right:before{content:"\\f27b"}.bi-chevron-compact-up:before{content:"\\f27c"}.bi-chevron-contract:before{content:"\\f27d"}.bi-chevron-double-down:before{content:"\\f27e"}.bi-chevron-double-left:before{content:"\\f27f"}.bi-chevron-double-right:before{content:"\\f280"}.bi-chevron-double-up:before{content:"\\f281"}.bi-chevron-down:before{content:"\\f282"}.bi-chevron-expand:before{content:"\\f283"}.bi-chevron-left:before{content:"\\f284"}.bi-chevron-right:before{content:"\\f285"}.bi-chevron-up:before{content:"\\f286"}.bi-circle-fill:before{content:"\\f287"}.bi-circle-half:before{content:"\\f288"}.bi-circle-square:before{content:"\\f289"}.bi-circle:before{content:"\\f28a"}.bi-clipboard-check:before{content:"\\f28b"}.bi-clipboard-data:before{content:"\\f28c"}.bi-clipboard-minus:before{content:"\\f28d"}.bi-clipboard-plus:before{content:"\\f28e"}.bi-clipboard-x:before{content:"\\f28f"}.bi-clipboard:before{content:"\\f290"}.bi-clock-fill:before{content:"\\f291"}.bi-clock-history:before{content:"\\f292"}.bi-clock:before{content:"\\f293"}.bi-cloud-arrow-down-fill:before{content:"\\f294"}.bi-cloud-arrow-down:before{content:"\\f295"}.bi-cloud-arrow-up-fill:before{content:"\\f296"}.bi-cloud-arrow-up:before{content:"\\f297"}.bi-cloud-check-fill:before{content:"\\f298"}.bi-cloud-check:before{content:"\\f299"}.bi-cloud-download-fill:before{content:"\\f29a"}.bi-cloud-download:before{content:"\\f29b"}.bi-cloud-drizzle-fill:before{content:"\\f29c"}.bi-cloud-drizzle:before{content:"\\f29d"}.bi-cloud-fill:before{content:"\\f29e"}.bi-cloud-fog-fill:before{content:"\\f29f"}.bi-cloud-fog:before{content:"\\f2a0"}.bi-cloud-fog2-fill:before{content:"\\f2a1"}.bi-cloud-fog2:before{content:"\\f2a2"}.bi-cloud-hail-fill:before{content:"\\f2a3"}.bi-cloud-hail:before{content:"\\f2a4"}.bi-cloud-haze-fill:before{content:"\\f2a6"}.bi-cloud-haze:before{content:"\\f2a7"}.bi-cloud-haze2-fill:before{content:"\\f2a8"}.bi-cloud-lightning-fill:before{content:"\\f2a9"}.bi-cloud-lightning-rain-fill:before{content:"\\f2aa"}.bi-cloud-lightning-rain:before{content:"\\f2ab"}.bi-cloud-lightning:before{content:"\\f2ac"}.bi-cloud-minus-fill:before{content:"\\f2ad"}.bi-cloud-minus:before{content:"\\f2ae"}.bi-cloud-moon-fill:before{content:"\\f2af"}.bi-cloud-moon:before{content:"\\f2b0"}.bi-cloud-plus-fill:before{content:"\\f2b1"}.bi-cloud-plus:before{content:"\\f2b2"}.bi-cloud-rain-fill:before{content:"\\f2b3"}.bi-cloud-rain-heavy-fill:before{content:"\\f2b4"}.bi-cloud-rain-heavy:before{content:"\\f2b5"}.bi-cloud-rain:before{content:"\\f2b6"}.bi-cloud-slash-fill:before{content:"\\f2b7"}.bi-cloud-slash:before{content:"\\f2b8"}.bi-cloud-sleet-fill:before{content:"\\f2b9"}.bi-cloud-sleet:before{content:"\\f2ba"}.bi-cloud-snow-fill:before{content:"\\f2bb"}.bi-cloud-snow:before{content:"\\f2bc"}.bi-cloud-sun-fill:before{content:"\\f2bd"}.bi-cloud-sun:before{content:"\\f2be"}.bi-cloud-upload-fill:before{content:"\\f2bf"}.bi-cloud-upload:before{content:"\\f2c0"}.bi-cloud:before{content:"\\f2c1"}.bi-clouds-fill:before{content:"\\f2c2"}.bi-clouds:before{content:"\\f2c3"}.bi-cloudy-fill:before{content:"\\f2c4"}.bi-cloudy:before{content:"\\f2c5"}.bi-code-slash:before{content:"\\f2c6"}.bi-code-square:before{content:"\\f2c7"}.bi-code:before{content:"\\f2c8"}.bi-collection-fill:before{content:"\\f2c9"}.bi-collection-play-fill:before{content:"\\f2ca"}.bi-collection-play:before{content:"\\f2cb"}.bi-collection:before{content:"\\f2cc"}.bi-columns-gap:before{content:"\\f2cd"}.bi-columns:before{content:"\\f2ce"}.bi-command:before{content:"\\f2cf"}.bi-compass-fill:before{content:"\\f2d0"}.bi-compass:before{content:"\\f2d1"}.bi-cone-striped:before{content:"\\f2d2"}.bi-cone:before{content:"\\f2d3"}.bi-controller:before{content:"\\f2d4"}.bi-cpu-fill:before{content:"\\f2d5"}.bi-cpu:before{content:"\\f2d6"}.bi-credit-card-2-back-fill:before{content:"\\f2d7"}.bi-credit-card-2-back:before{content:"\\f2d8"}.bi-credit-card-2-front-fill:before{content:"\\f2d9"}.bi-credit-card-2-front:before{content:"\\f2da"}.bi-credit-card-fill:before{content:"\\f2db"}.bi-credit-card:before{content:"\\f2dc"}.bi-crop:before{content:"\\f2dd"}.bi-cup-fill:before{content:"\\f2de"}.bi-cup-straw:before{content:"\\f2df"}.bi-cup:before{content:"\\f2e0"}.bi-cursor-fill:before{content:"\\f2e1"}.bi-cursor-text:before{content:"\\f2e2"}.bi-cursor:before{content:"\\f2e3"}.bi-dash-circle-dotted:before{content:"\\f2e4"}.bi-dash-circle-fill:before{content:"\\f2e5"}.bi-dash-circle:before{content:"\\f2e6"}.bi-dash-square-dotted:before{content:"\\f2e7"}.bi-dash-square-fill:before{content:"\\f2e8"}.bi-dash-square:before{content:"\\f2e9"}.bi-dash:before{content:"\\f2ea"}.bi-diagram-2-fill:before{content:"\\f2eb"}.bi-diagram-2:before{content:"\\f2ec"}.bi-diagram-3-fill:before{content:"\\f2ed"}.bi-diagram-3:before{content:"\\f2ee"}.bi-diamond-fill:before{content:"\\f2ef"}.bi-diamond-half:before{content:"\\f2f0"}.bi-diamond:before{content:"\\f2f1"}.bi-dice-1-fill:before{content:"\\f2f2"}.bi-dice-1:before{content:"\\f2f3"}.bi-dice-2-fill:before{content:"\\f2f4"}.bi-dice-2:before{content:"\\f2f5"}.bi-dice-3-fill:before{content:"\\f2f6"}.bi-dice-3:before{content:"\\f2f7"}.bi-dice-4-fill:before{content:"\\f2f8"}.bi-dice-4:before{content:"\\f2f9"}.bi-dice-5-fill:before{content:"\\f2fa"}.bi-dice-5:before{content:"\\f2fb"}.bi-dice-6-fill:before{content:"\\f2fc"}.bi-dice-6:before{content:"\\f2fd"}.bi-disc-fill:before{content:"\\f2fe"}.bi-disc:before{content:"\\f2ff"}.bi-discord:before{content:"\\f300"}.bi-display-fill:before{content:"\\f301"}.bi-display:before{content:"\\f302"}.bi-distribute-horizontal:before{content:"\\f303"}.bi-distribute-vertical:before{content:"\\f304"}.bi-door-closed-fill:before{content:"\\f305"}.bi-door-closed:before{content:"\\f306"}.bi-door-open-fill:before{content:"\\f307"}.bi-door-open:before{content:"\\f308"}.bi-dot:before{content:"\\f309"}.bi-download:before{content:"\\f30a"}.bi-droplet-fill:before{content:"\\f30b"}.bi-droplet-half:before{content:"\\f30c"}.bi-droplet:before{content:"\\f30d"}.bi-earbuds:before{content:"\\f30e"}.bi-easel-fill:before{content:"\\f30f"}.bi-easel:before{content:"\\f310"}.bi-egg-fill:before{content:"\\f311"}.bi-egg-fried:before{content:"\\f312"}.bi-egg:before{content:"\\f313"}.bi-eject-fill:before{content:"\\f314"}.bi-eject:before{content:"\\f315"}.bi-emoji-angry-fill:before{content:"\\f316"}.bi-emoji-angry:before{content:"\\f317"}.bi-emoji-dizzy-fill:before{content:"\\f318"}.bi-emoji-dizzy:before{content:"\\f319"}.bi-emoji-expressionless-fill:before{content:"\\f31a"}.bi-emoji-expressionless:before{content:"\\f31b"}.bi-emoji-frown-fill:before{content:"\\f31c"}.bi-emoji-frown:before{content:"\\f31d"}.bi-emoji-heart-eyes-fill:before{content:"\\f31e"}.bi-emoji-heart-eyes:before{content:"\\f31f"}.bi-emoji-laughing-fill:before{content:"\\f320"}.bi-emoji-laughing:before{content:"\\f321"}.bi-emoji-neutral-fill:before{content:"\\f322"}.bi-emoji-neutral:before{content:"\\f323"}.bi-emoji-smile-fill:before{content:"\\f324"}.bi-emoji-smile-upside-down-fill:before{content:"\\f325"}.bi-emoji-smile-upside-down:before{content:"\\f326"}.bi-emoji-smile:before{content:"\\f327"}.bi-emoji-sunglasses-fill:before{content:"\\f328"}.bi-emoji-sunglasses:before{content:"\\f329"}.bi-emoji-wink-fill:before{content:"\\f32a"}.bi-emoji-wink:before{content:"\\f32b"}.bi-envelope-fill:before{content:"\\f32c"}.bi-envelope-open-fill:before{content:"\\f32d"}.bi-envelope-open:before{content:"\\f32e"}.bi-envelope:before{content:"\\f32f"}.bi-eraser-fill:before{content:"\\f330"}.bi-eraser:before{content:"\\f331"}.bi-exclamation-circle-fill:before{content:"\\f332"}.bi-exclamation-circle:before{content:"\\f333"}.bi-exclamation-diamond-fill:before{content:"\\f334"}.bi-exclamation-diamond:before{content:"\\f335"}.bi-exclamation-octagon-fill:before{content:"\\f336"}.bi-exclamation-octagon:before{content:"\\f337"}.bi-exclamation-square-fill:before{content:"\\f338"}.bi-exclamation-square:before{content:"\\f339"}.bi-exclamation-triangle-fill:before{content:"\\f33a"}.bi-exclamation-triangle:before{content:"\\f33b"}.bi-exclamation:before{content:"\\f33c"}.bi-exclude:before{content:"\\f33d"}.bi-eye-fill:before{content:"\\f33e"}.bi-eye-slash-fill:before{content:"\\f33f"}.bi-eye-slash:before{content:"\\f340"}.bi-eye:before{content:"\\f341"}.bi-eyedropper:before{content:"\\f342"}.bi-eyeglasses:before{content:"\\f343"}.bi-facebook:before{content:"\\f344"}.bi-file-arrow-down-fill:before{content:"\\f345"}.bi-file-arrow-down:before{content:"\\f346"}.bi-file-arrow-up-fill:before{content:"\\f347"}.bi-file-arrow-up:before{content:"\\f348"}.bi-file-bar-graph-fill:before{content:"\\f349"}.bi-file-bar-graph:before{content:"\\f34a"}.bi-file-binary-fill:before{content:"\\f34b"}.bi-file-binary:before{content:"\\f34c"}.bi-file-break-fill:before{content:"\\f34d"}.bi-file-break:before{content:"\\f34e"}.bi-file-check-fill:before{content:"\\f34f"}.bi-file-check:before{content:"\\f350"}.bi-file-code-fill:before{content:"\\f351"}.bi-file-code:before{content:"\\f352"}.bi-file-diff-fill:before{content:"\\f353"}.bi-file-diff:before{content:"\\f354"}.bi-file-earmark-arrow-down-fill:before{content:"\\f355"}.bi-file-earmark-arrow-down:before{content:"\\f356"}.bi-file-earmark-arrow-up-fill:before{content:"\\f357"}.bi-file-earmark-arrow-up:before{content:"\\f358"}.bi-file-earmark-bar-graph-fill:before{content:"\\f359"}.bi-file-earmark-bar-graph:before{content:"\\f35a"}.bi-file-earmark-binary-fill:before{content:"\\f35b"}.bi-file-earmark-binary:before{content:"\\f35c"}.bi-file-earmark-break-fill:before{content:"\\f35d"}.bi-file-earmark-break:before{content:"\\f35e"}.bi-file-earmark-check-fill:before{content:"\\f35f"}.bi-file-earmark-check:before{content:"\\f360"}.bi-file-earmark-code-fill:before{content:"\\f361"}.bi-file-earmark-code:before{content:"\\f362"}.bi-file-earmark-diff-fill:before{content:"\\f363"}.bi-file-earmark-diff:before{content:"\\f364"}.bi-file-earmark-easel-fill:before{content:"\\f365"}.bi-file-earmark-easel:before{content:"\\f366"}.bi-file-earmark-excel-fill:before{content:"\\f367"}.bi-file-earmark-excel:before{content:"\\f368"}.bi-file-earmark-fill:before{content:"\\f369"}.bi-file-earmark-font-fill:before{content:"\\f36a"}.bi-file-earmark-font:before{content:"\\f36b"}.bi-file-earmark-image-fill:before{content:"\\f36c"}.bi-file-earmark-image:before{content:"\\f36d"}.bi-file-earmark-lock-fill:before{content:"\\f36e"}.bi-file-earmark-lock:before{content:"\\f36f"}.bi-file-earmark-lock2-fill:before{content:"\\f370"}.bi-file-earmark-lock2:before{content:"\\f371"}.bi-file-earmark-medical-fill:before{content:"\\f372"}.bi-file-earmark-medical:before{content:"\\f373"}.bi-file-earmark-minus-fill:before{content:"\\f374"}.bi-file-earmark-minus:before{content:"\\f375"}.bi-file-earmark-music-fill:before{content:"\\f376"}.bi-file-earmark-music:before{content:"\\f377"}.bi-file-earmark-person-fill:before{content:"\\f378"}.bi-file-earmark-person:before{content:"\\f379"}.bi-file-earmark-play-fill:before{content:"\\f37a"}.bi-file-earmark-play:before{content:"\\f37b"}.bi-file-earmark-plus-fill:before{content:"\\f37c"}.bi-file-earmark-plus:before{content:"\\f37d"}.bi-file-earmark-post-fill:before{content:"\\f37e"}.bi-file-earmark-post:before{content:"\\f37f"}.bi-file-earmark-ppt-fill:before{content:"\\f380"}.bi-file-earmark-ppt:before{content:"\\f381"}.bi-file-earmark-richtext-fill:before{content:"\\f382"}.bi-file-earmark-richtext:before{content:"\\f383"}.bi-file-earmark-ruled-fill:before{content:"\\f384"}.bi-file-earmark-ruled:before{content:"\\f385"}.bi-file-earmark-slides-fill:before{content:"\\f386"}.bi-file-earmark-slides:before{content:"\\f387"}.bi-file-earmark-spreadsheet-fill:before{content:"\\f388"}.bi-file-earmark-spreadsheet:before{content:"\\f389"}.bi-file-earmark-text-fill:before{content:"\\f38a"}.bi-file-earmark-text:before{content:"\\f38b"}.bi-file-earmark-word-fill:before{content:"\\f38c"}.bi-file-earmark-word:before{content:"\\f38d"}.bi-file-earmark-x-fill:before{content:"\\f38e"}.bi-file-earmark-x:before{content:"\\f38f"}.bi-file-earmark-zip-fill:before{content:"\\f390"}.bi-file-earmark-zip:before{content:"\\f391"}.bi-file-earmark:before{content:"\\f392"}.bi-file-easel-fill:before{content:"\\f393"}.bi-file-easel:before{content:"\\f394"}.bi-file-excel-fill:before{content:"\\f395"}.bi-file-excel:before{content:"\\f396"}.bi-file-fill:before{content:"\\f397"}.bi-file-font-fill:before{content:"\\f398"}.bi-file-font:before{content:"\\f399"}.bi-file-image-fill:before{content:"\\f39a"}.bi-file-image:before{content:"\\f39b"}.bi-file-lock-fill:before{content:"\\f39c"}.bi-file-lock:before{content:"\\f39d"}.bi-file-lock2-fill:before{content:"\\f39e"}.bi-file-lock2:before{content:"\\f39f"}.bi-file-medical-fill:before{content:"\\f3a0"}.bi-file-medical:before{content:"\\f3a1"}.bi-file-minus-fill:before{content:"\\f3a2"}.bi-file-minus:before{content:"\\f3a3"}.bi-file-music-fill:before{content:"\\f3a4"}.bi-file-music:before{content:"\\f3a5"}.bi-file-person-fill:before{content:"\\f3a6"}.bi-file-person:before{content:"\\f3a7"}.bi-file-play-fill:before{content:"\\f3a8"}.bi-file-play:before{content:"\\f3a9"}.bi-file-plus-fill:before{content:"\\f3aa"}.bi-file-plus:before{content:"\\f3ab"}.bi-file-post-fill:before{content:"\\f3ac"}.bi-file-post:before{content:"\\f3ad"}.bi-file-ppt-fill:before{content:"\\f3ae"}.bi-file-ppt:before{content:"\\f3af"}.bi-file-richtext-fill:before{content:"\\f3b0"}.bi-file-richtext:before{content:"\\f3b1"}.bi-file-ruled-fill:before{content:"\\f3b2"}.bi-file-ruled:before{content:"\\f3b3"}.bi-file-slides-fill:before{content:"\\f3b4"}.bi-file-slides:before{content:"\\f3b5"}.bi-file-spreadsheet-fill:before{content:"\\f3b6"}.bi-file-spreadsheet:before{content:"\\f3b7"}.bi-file-text-fill:before{content:"\\f3b8"}.bi-file-text:before{content:"\\f3b9"}.bi-file-word-fill:before{content:"\\f3ba"}.bi-file-word:before{content:"\\f3bb"}.bi-file-x-fill:before{content:"\\f3bc"}.bi-file-x:before{content:"\\f3bd"}.bi-file-zip-fill:before{content:"\\f3be"}.bi-file-zip:before{content:"\\f3bf"}.bi-file:before{content:"\\f3c0"}.bi-files-alt:before{content:"\\f3c1"}.bi-files:before{content:"\\f3c2"}.bi-film:before{content:"\\f3c3"}.bi-filter-circle-fill:before{content:"\\f3c4"}.bi-filter-circle:before{content:"\\f3c5"}.bi-filter-left:before{content:"\\f3c6"}.bi-filter-right:before{content:"\\f3c7"}.bi-filter-square-fill:before{content:"\\f3c8"}.bi-filter-square:before{content:"\\f3c9"}.bi-filter:before{content:"\\f3ca"}.bi-flag-fill:before{content:"\\f3cb"}.bi-flag:before{content:"\\f3cc"}.bi-flower1:before{content:"\\f3cd"}.bi-flower2:before{content:"\\f3ce"}.bi-flower3:before{content:"\\f3cf"}.bi-folder-check:before{content:"\\f3d0"}.bi-folder-fill:before{content:"\\f3d1"}.bi-folder-minus:before{content:"\\f3d2"}.bi-folder-plus:before{content:"\\f3d3"}.bi-folder-symlink-fill:before{content:"\\f3d4"}.bi-folder-symlink:before{content:"\\f3d5"}.bi-folder-x:before{content:"\\f3d6"}.bi-folder:before{content:"\\f3d7"}.bi-folder2-open:before{content:"\\f3d8"}.bi-folder2:before{content:"\\f3d9"}.bi-fonts:before{content:"\\f3da"}.bi-forward-fill:before{content:"\\f3db"}.bi-forward:before{content:"\\f3dc"}.bi-front:before{content:"\\f3dd"}.bi-fullscreen-exit:before{content:"\\f3de"}.bi-fullscreen:before{content:"\\f3df"}.bi-funnel-fill:before{content:"\\f3e0"}.bi-funnel:before{content:"\\f3e1"}.bi-gear-fill:before{content:"\\f3e2"}.bi-gear-wide-connected:before{content:"\\f3e3"}.bi-gear-wide:before{content:"\\f3e4"}.bi-gear:before{content:"\\f3e5"}.bi-gem:before{content:"\\f3e6"}.bi-geo-alt-fill:before{content:"\\f3e7"}.bi-geo-alt:before{content:"\\f3e8"}.bi-geo-fill:before{content:"\\f3e9"}.bi-geo:before{content:"\\f3ea"}.bi-gift-fill:before{content:"\\f3eb"}.bi-gift:before{content:"\\f3ec"}.bi-github:before{content:"\\f3ed"}.bi-globe:before{content:"\\f3ee"}.bi-globe2:before{content:"\\f3ef"}.bi-google:before{content:"\\f3f0"}.bi-graph-down:before{content:"\\f3f1"}.bi-graph-up:before{content:"\\f3f2"}.bi-grid-1x2-fill:before{content:"\\f3f3"}.bi-grid-1x2:before{content:"\\f3f4"}.bi-grid-3x2-gap-fill:before{content:"\\f3f5"}.bi-grid-3x2-gap:before{content:"\\f3f6"}.bi-grid-3x2:before{content:"\\f3f7"}.bi-grid-3x3-gap-fill:before{content:"\\f3f8"}.bi-grid-3x3-gap:before{content:"\\f3f9"}.bi-grid-3x3:before{content:"\\f3fa"}.bi-grid-fill:before{content:"\\f3fb"}.bi-grid:before{content:"\\f3fc"}.bi-grip-horizontal:before{content:"\\f3fd"}.bi-grip-vertical:before{content:"\\f3fe"}.bi-hammer:before{content:"\\f3ff"}.bi-hand-index-fill:before{content:"\\f400"}.bi-hand-index-thumb-fill:before{content:"\\f401"}.bi-hand-index-thumb:before{content:"\\f402"}.bi-hand-index:before{content:"\\f403"}.bi-hand-thumbs-down-fill:before{content:"\\f404"}.bi-hand-thumbs-down:before{content:"\\f405"}.bi-hand-thumbs-up-fill:before{content:"\\f406"}.bi-hand-thumbs-up:before{content:"\\f407"}.bi-handbag-fill:before{content:"\\f408"}.bi-handbag:before{content:"\\f409"}.bi-hash:before{content:"\\f40a"}.bi-hdd-fill:before{content:"\\f40b"}.bi-hdd-network-fill:before{content:"\\f40c"}.bi-hdd-network:before{content:"\\f40d"}.bi-hdd-rack-fill:before{content:"\\f40e"}.bi-hdd-rack:before{content:"\\f40f"}.bi-hdd-stack-fill:before{content:"\\f410"}.bi-hdd-stack:before{content:"\\f411"}.bi-hdd:before{content:"\\f412"}.bi-headphones:before{content:"\\f413"}.bi-headset:before{content:"\\f414"}.bi-heart-fill:before{content:"\\f415"}.bi-heart-half:before{content:"\\f416"}.bi-heart:before{content:"\\f417"}.bi-heptagon-fill:before{content:"\\f418"}.bi-heptagon-half:before{content:"\\f419"}.bi-heptagon:before{content:"\\f41a"}.bi-hexagon-fill:before{content:"\\f41b"}.bi-hexagon-half:before{content:"\\f41c"}.bi-hexagon:before{content:"\\f41d"}.bi-hourglass-bottom:before{content:"\\f41e"}.bi-hourglass-split:before{content:"\\f41f"}.bi-hourglass-top:before{content:"\\f420"}.bi-hourglass:before{content:"\\f421"}.bi-house-door-fill:before{content:"\\f422"}.bi-house-door:before{content:"\\f423"}.bi-house-fill:before{content:"\\f424"}.bi-house:before{content:"\\f425"}.bi-hr:before{content:"\\f426"}.bi-hurricane:before{content:"\\f427"}.bi-image-alt:before{content:"\\f428"}.bi-image-fill:before{content:"\\f429"}.bi-image:before{content:"\\f42a"}.bi-images:before{content:"\\f42b"}.bi-inbox-fill:before{content:"\\f42c"}.bi-inbox:before{content:"\\f42d"}.bi-inboxes-fill:before{content:"\\f42e"}.bi-inboxes:before{content:"\\f42f"}.bi-info-circle-fill:before{content:"\\f430"}.bi-info-circle:before{content:"\\f431"}.bi-info-square-fill:before{content:"\\f432"}.bi-info-square:before{content:"\\f433"}.bi-info:before{content:"\\f434"}.bi-input-cursor-text:before{content:"\\f435"}.bi-input-cursor:before{content:"\\f436"}.bi-instagram:before{content:"\\f437"}.bi-intersect:before{content:"\\f438"}.bi-journal-album:before{content:"\\f439"}.bi-journal-arrow-down:before{content:"\\f43a"}.bi-journal-arrow-up:before{content:"\\f43b"}.bi-journal-bookmark-fill:before{content:"\\f43c"}.bi-journal-bookmark:before{content:"\\f43d"}.bi-journal-check:before{content:"\\f43e"}.bi-journal-code:before{content:"\\f43f"}.bi-journal-medical:before{content:"\\f440"}.bi-journal-minus:before{content:"\\f441"}.bi-journal-plus:before{content:"\\f442"}.bi-journal-richtext:before{content:"\\f443"}.bi-journal-text:before{content:"\\f444"}.bi-journal-x:before{content:"\\f445"}.bi-journal:before{content:"\\f446"}.bi-journals:before{content:"\\f447"}.bi-joystick:before{content:"\\f448"}.bi-justify-left:before{content:"\\f449"}.bi-justify-right:before{content:"\\f44a"}.bi-justify:before{content:"\\f44b"}.bi-kanban-fill:before{content:"\\f44c"}.bi-kanban:before{content:"\\f44d"}.bi-key-fill:before{content:"\\f44e"}.bi-key:before{content:"\\f44f"}.bi-keyboard-fill:before{content:"\\f450"}.bi-keyboard:before{content:"\\f451"}.bi-ladder:before{content:"\\f452"}.bi-lamp-fill:before{content:"\\f453"}.bi-lamp:before{content:"\\f454"}.bi-laptop-fill:before{content:"\\f455"}.bi-laptop:before{content:"\\f456"}.bi-layer-backward:before{content:"\\f457"}.bi-layer-forward:before{content:"\\f458"}.bi-layers-fill:before{content:"\\f459"}.bi-layers-half:before{content:"\\f45a"}.bi-layers:before{content:"\\f45b"}.bi-layout-sidebar-inset-reverse:before{content:"\\f45c"}.bi-layout-sidebar-inset:before{content:"\\f45d"}.bi-layout-sidebar-reverse:before{content:"\\f45e"}.bi-layout-sidebar:before{content:"\\f45f"}.bi-layout-split:before{content:"\\f460"}.bi-layout-text-sidebar-reverse:before{content:"\\f461"}.bi-layout-text-sidebar:before{content:"\\f462"}.bi-layout-text-window-reverse:before{content:"\\f463"}.bi-layout-text-window:before{content:"\\f464"}.bi-layout-three-columns:before{content:"\\f465"}.bi-layout-wtf:before{content:"\\f466"}.bi-life-preserver:before{content:"\\f467"}.bi-lightbulb-fill:before{content:"\\f468"}.bi-lightbulb-off-fill:before{content:"\\f469"}.bi-lightbulb-off:before{content:"\\f46a"}.bi-lightbulb:before{content:"\\f46b"}.bi-lightning-charge-fill:before{content:"\\f46c"}.bi-lightning-charge:before{content:"\\f46d"}.bi-lightning-fill:before{content:"\\f46e"}.bi-lightning:before{content:"\\f46f"}.bi-link-45deg:before{content:"\\f470"}.bi-link:before{content:"\\f471"}.bi-linkedin:before{content:"\\f472"}.bi-list-check:before{content:"\\f473"}.bi-list-nested:before{content:"\\f474"}.bi-list-ol:before{content:"\\f475"}.bi-list-stars:before{content:"\\f476"}.bi-list-task:before{content:"\\f477"}.bi-list-ul:before{content:"\\f478"}.bi-list:before{content:"\\f479"}.bi-lock-fill:before{content:"\\f47a"}.bi-lock:before{content:"\\f47b"}.bi-mailbox:before{content:"\\f47c"}.bi-mailbox2:before{content:"\\f47d"}.bi-map-fill:before{content:"\\f47e"}.bi-map:before{content:"\\f47f"}.bi-markdown-fill:before{content:"\\f480"}.bi-markdown:before{content:"\\f481"}.bi-mask:before{content:"\\f482"}.bi-megaphone-fill:before{content:"\\f483"}.bi-megaphone:before{content:"\\f484"}.bi-menu-app-fill:before{content:"\\f485"}.bi-menu-app:before{content:"\\f486"}.bi-menu-button-fill:before{content:"\\f487"}.bi-menu-button-wide-fill:before{content:"\\f488"}.bi-menu-button-wide:before{content:"\\f489"}.bi-menu-button:before{content:"\\f48a"}.bi-menu-down:before{content:"\\f48b"}.bi-menu-up:before{content:"\\f48c"}.bi-mic-fill:before{content:"\\f48d"}.bi-mic-mute-fill:before{content:"\\f48e"}.bi-mic-mute:before{content:"\\f48f"}.bi-mic:before{content:"\\f490"}.bi-minecart-loaded:before{content:"\\f491"}.bi-minecart:before{content:"\\f492"}.bi-moisture:before{content:"\\f493"}.bi-moon-fill:before{content:"\\f494"}.bi-moon-stars-fill:before{content:"\\f495"}.bi-moon-stars:before{content:"\\f496"}.bi-moon:before{content:"\\f497"}.bi-mouse-fill:before{content:"\\f498"}.bi-mouse:before{content:"\\f499"}.bi-mouse2-fill:before{content:"\\f49a"}.bi-mouse2:before{content:"\\f49b"}.bi-mouse3-fill:before{content:"\\f49c"}.bi-mouse3:before{content:"\\f49d"}.bi-music-note-beamed:before{content:"\\f49e"}.bi-music-note-list:before{content:"\\f49f"}.bi-music-note:before{content:"\\f4a0"}.bi-music-player-fill:before{content:"\\f4a1"}.bi-music-player:before{content:"\\f4a2"}.bi-newspaper:before{content:"\\f4a3"}.bi-node-minus-fill:before{content:"\\f4a4"}.bi-node-minus:before{content:"\\f4a5"}.bi-node-plus-fill:before{content:"\\f4a6"}.bi-node-plus:before{content:"\\f4a7"}.bi-nut-fill:before{content:"\\f4a8"}.bi-nut:before{content:"\\f4a9"}.bi-octagon-fill:before{content:"\\f4aa"}.bi-octagon-half:before{content:"\\f4ab"}.bi-octagon:before{content:"\\f4ac"}.bi-option:before{content:"\\f4ad"}.bi-outlet:before{content:"\\f4ae"}.bi-paint-bucket:before{content:"\\f4af"}.bi-palette-fill:before{content:"\\f4b0"}.bi-palette:before{content:"\\f4b1"}.bi-palette2:before{content:"\\f4b2"}.bi-paperclip:before{content:"\\f4b3"}.bi-paragraph:before{content:"\\f4b4"}.bi-patch-check-fill:before{content:"\\f4b5"}.bi-patch-check:before{content:"\\f4b6"}.bi-patch-exclamation-fill:before{content:"\\f4b7"}.bi-patch-exclamation:before{content:"\\f4b8"}.bi-patch-minus-fill:before{content:"\\f4b9"}.bi-patch-minus:before{content:"\\f4ba"}.bi-patch-plus-fill:before{content:"\\f4bb"}.bi-patch-plus:before{content:"\\f4bc"}.bi-patch-question-fill:before{content:"\\f4bd"}.bi-patch-question:before{content:"\\f4be"}.bi-pause-btn-fill:before{content:"\\f4bf"}.bi-pause-btn:before{content:"\\f4c0"}.bi-pause-circle-fill:before{content:"\\f4c1"}.bi-pause-circle:before{content:"\\f4c2"}.bi-pause-fill:before{content:"\\f4c3"}.bi-pause:before{content:"\\f4c4"}.bi-peace-fill:before{content:"\\f4c5"}.bi-peace:before{content:"\\f4c6"}.bi-pen-fill:before{content:"\\f4c7"}.bi-pen:before{content:"\\f4c8"}.bi-pencil-fill:before{content:"\\f4c9"}.bi-pencil-square:before{content:"\\f4ca"}.bi-pencil:before{content:"\\f4cb"}.bi-pentagon-fill:before{content:"\\f4cc"}.bi-pentagon-half:before{content:"\\f4cd"}.bi-pentagon:before{content:"\\f4ce"}.bi-people-fill:before{content:"\\f4cf"}.bi-people:before{content:"\\f4d0"}.bi-percent:before{content:"\\f4d1"}.bi-person-badge-fill:before{content:"\\f4d2"}.bi-person-badge:before{content:"\\f4d3"}.bi-person-bounding-box:before{content:"\\f4d4"}.bi-person-check-fill:before{content:"\\f4d5"}.bi-person-check:before{content:"\\f4d6"}.bi-person-circle:before{content:"\\f4d7"}.bi-person-dash-fill:before{content:"\\f4d8"}.bi-person-dash:before{content:"\\f4d9"}.bi-person-fill:before{content:"\\f4da"}.bi-person-lines-fill:before{content:"\\f4db"}.bi-person-plus-fill:before{content:"\\f4dc"}.bi-person-plus:before{content:"\\f4dd"}.bi-person-square:before{content:"\\f4de"}.bi-person-x-fill:before{content:"\\f4df"}.bi-person-x:before{content:"\\f4e0"}.bi-person:before{content:"\\f4e1"}.bi-phone-fill:before{content:"\\f4e2"}.bi-phone-landscape-fill:before{content:"\\f4e3"}.bi-phone-landscape:before{content:"\\f4e4"}.bi-phone-vibrate-fill:before{content:"\\f4e5"}.bi-phone-vibrate:before{content:"\\f4e6"}.bi-phone:before{content:"\\f4e7"}.bi-pie-chart-fill:before{content:"\\f4e8"}.bi-pie-chart:before{content:"\\f4e9"}.bi-pin-angle-fill:before{content:"\\f4ea"}.bi-pin-angle:before{content:"\\f4eb"}.bi-pin-fill:before{content:"\\f4ec"}.bi-pin:before{content:"\\f4ed"}.bi-pip-fill:before{content:"\\f4ee"}.bi-pip:before{content:"\\f4ef"}.bi-play-btn-fill:before{content:"\\f4f0"}.bi-play-btn:before{content:"\\f4f1"}.bi-play-circle-fill:before{content:"\\f4f2"}.bi-play-circle:before{content:"\\f4f3"}.bi-play-fill:before{content:"\\f4f4"}.bi-play:before{content:"\\f4f5"}.bi-plug-fill:before{content:"\\f4f6"}.bi-plug:before{content:"\\f4f7"}.bi-plus-circle-dotted:before{content:"\\f4f8"}.bi-plus-circle-fill:before{content:"\\f4f9"}.bi-plus-circle:before{content:"\\f4fa"}.bi-plus-square-dotted:before{content:"\\f4fb"}.bi-plus-square-fill:before{content:"\\f4fc"}.bi-plus-square:before{content:"\\f4fd"}.bi-plus:before{content:"\\f4fe"}.bi-power:before{content:"\\f4ff"}.bi-printer-fill:before{content:"\\f500"}.bi-printer:before{content:"\\f501"}.bi-puzzle-fill:before{content:"\\f502"}.bi-puzzle:before{content:"\\f503"}.bi-question-circle-fill:before{content:"\\f504"}.bi-question-circle:before{content:"\\f505"}.bi-question-diamond-fill:before{content:"\\f506"}.bi-question-diamond:before{content:"\\f507"}.bi-question-octagon-fill:before{content:"\\f508"}.bi-question-octagon:before{content:"\\f509"}.bi-question-square-fill:before{content:"\\f50a"}.bi-question-square:before{content:"\\f50b"}.bi-question:before{content:"\\f50c"}.bi-rainbow:before{content:"\\f50d"}.bi-receipt-cutoff:before{content:"\\f50e"}.bi-receipt:before{content:"\\f50f"}.bi-reception-0:before{content:"\\f510"}.bi-reception-1:before{content:"\\f511"}.bi-reception-2:before{content:"\\f512"}.bi-reception-3:before{content:"\\f513"}.bi-reception-4:before{content:"\\f514"}.bi-record-btn-fill:before{content:"\\f515"}.bi-record-btn:before{content:"\\f516"}.bi-record-circle-fill:before{content:"\\f517"}.bi-record-circle:before{content:"\\f518"}.bi-record-fill:before{content:"\\f519"}.bi-record:before{content:"\\f51a"}.bi-record2-fill:before{content:"\\f51b"}.bi-record2:before{content:"\\f51c"}.bi-reply-all-fill:before{content:"\\f51d"}.bi-reply-all:before{content:"\\f51e"}.bi-reply-fill:before{content:"\\f51f"}.bi-reply:before{content:"\\f520"}.bi-rss-fill:before{content:"\\f521"}.bi-rss:before{content:"\\f522"}.bi-rulers:before{content:"\\f523"}.bi-save-fill:before{content:"\\f524"}.bi-save:before{content:"\\f525"}.bi-save2-fill:before{content:"\\f526"}.bi-save2:before{content:"\\f527"}.bi-scissors:before{content:"\\f528"}.bi-screwdriver:before{content:"\\f529"}.bi-search:before{content:"\\f52a"}.bi-segmented-nav:before{content:"\\f52b"}.bi-server:before{content:"\\f52c"}.bi-share-fill:before{content:"\\f52d"}.bi-share:before{content:"\\f52e"}.bi-shield-check:before{content:"\\f52f"}.bi-shield-exclamation:before{content:"\\f530"}.bi-shield-fill-check:before{content:"\\f531"}.bi-shield-fill-exclamation:before{content:"\\f532"}.bi-shield-fill-minus:before{content:"\\f533"}.bi-shield-fill-plus:before{content:"\\f534"}.bi-shield-fill-x:before{content:"\\f535"}.bi-shield-fill:before{content:"\\f536"}.bi-shield-lock-fill:before{content:"\\f537"}.bi-shield-lock:before{content:"\\f538"}.bi-shield-minus:before{content:"\\f539"}.bi-shield-plus:before{content:"\\f53a"}.bi-shield-shaded:before{content:"\\f53b"}.bi-shield-slash-fill:before{content:"\\f53c"}.bi-shield-slash:before{content:"\\f53d"}.bi-shield-x:before{content:"\\f53e"}.bi-shield:before{content:"\\f53f"}.bi-shift-fill:before{content:"\\f540"}.bi-shift:before{content:"\\f541"}.bi-shop-window:before{content:"\\f542"}.bi-shop:before{content:"\\f543"}.bi-shuffle:before{content:"\\f544"}.bi-signpost-2-fill:before{content:"\\f545"}.bi-signpost-2:before{content:"\\f546"}.bi-signpost-fill:before{content:"\\f547"}.bi-signpost-split-fill:before{content:"\\f548"}.bi-signpost-split:before{content:"\\f549"}.bi-signpost:before{content:"\\f54a"}.bi-sim-fill:before{content:"\\f54b"}.bi-sim:before{content:"\\f54c"}.bi-skip-backward-btn-fill:before{content:"\\f54d"}.bi-skip-backward-btn:before{content:"\\f54e"}.bi-skip-backward-circle-fill:before{content:"\\f54f"}.bi-skip-backward-circle:before{content:"\\f550"}.bi-skip-backward-fill:before{content:"\\f551"}.bi-skip-backward:before{content:"\\f552"}.bi-skip-end-btn-fill:before{content:"\\f553"}.bi-skip-end-btn:before{content:"\\f554"}.bi-skip-end-circle-fill:before{content:"\\f555"}.bi-skip-end-circle:before{content:"\\f556"}.bi-skip-end-fill:before{content:"\\f557"}.bi-skip-end:before{content:"\\f558"}.bi-skip-forward-btn-fill:before{content:"\\f559"}.bi-skip-forward-btn:before{content:"\\f55a"}.bi-skip-forward-circle-fill:before{content:"\\f55b"}.bi-skip-forward-circle:before{content:"\\f55c"}.bi-skip-forward-fill:before{content:"\\f55d"}.bi-skip-forward:before{content:"\\f55e"}.bi-skip-start-btn-fill:before{content:"\\f55f"}.bi-skip-start-btn:before{content:"\\f560"}.bi-skip-start-circle-fill:before{content:"\\f561"}.bi-skip-start-circle:before{content:"\\f562"}.bi-skip-start-fill:before{content:"\\f563"}.bi-skip-start:before{content:"\\f564"}.bi-slack:before{content:"\\f565"}.bi-slash-circle-fill:before{content:"\\f566"}.bi-slash-circle:before{content:"\\f567"}.bi-slash-square-fill:before{content:"\\f568"}.bi-slash-square:before{content:"\\f569"}.bi-slash:before{content:"\\f56a"}.bi-sliders:before{content:"\\f56b"}.bi-smartwatch:before{content:"\\f56c"}.bi-snow:before{content:"\\f56d"}.bi-snow2:before{content:"\\f56e"}.bi-snow3:before{content:"\\f56f"}.bi-sort-alpha-down-alt:before{content:"\\f570"}.bi-sort-alpha-down:before{content:"\\f571"}.bi-sort-alpha-up-alt:before{content:"\\f572"}.bi-sort-alpha-up:before{content:"\\f573"}.bi-sort-down-alt:before{content:"\\f574"}.bi-sort-down:before{content:"\\f575"}.bi-sort-numeric-down-alt:before{content:"\\f576"}.bi-sort-numeric-down:before{content:"\\f577"}.bi-sort-numeric-up-alt:before{content:"\\f578"}.bi-sort-numeric-up:before{content:"\\f579"}.bi-sort-up-alt:before{content:"\\f57a"}.bi-sort-up:before{content:"\\f57b"}.bi-soundwave:before{content:"\\f57c"}.bi-speaker-fill:before{content:"\\f57d"}.bi-speaker:before{content:"\\f57e"}.bi-speedometer:before{content:"\\f57f"}.bi-speedometer2:before{content:"\\f580"}.bi-spellcheck:before{content:"\\f581"}.bi-square-fill:before{content:"\\f582"}.bi-square-half:before{content:"\\f583"}.bi-square:before{content:"\\f584"}.bi-stack:before{content:"\\f585"}.bi-star-fill:before{content:"\\f586"}.bi-star-half:before{content:"\\f587"}.bi-star:before{content:"\\f588"}.bi-stars:before{content:"\\f589"}.bi-stickies-fill:before{content:"\\f58a"}.bi-stickies:before{content:"\\f58b"}.bi-sticky-fill:before{content:"\\f58c"}.bi-sticky:before{content:"\\f58d"}.bi-stop-btn-fill:before{content:"\\f58e"}.bi-stop-btn:before{content:"\\f58f"}.bi-stop-circle-fill:before{content:"\\f590"}.bi-stop-circle:before{content:"\\f591"}.bi-stop-fill:before{content:"\\f592"}.bi-stop:before{content:"\\f593"}.bi-stoplights-fill:before{content:"\\f594"}.bi-stoplights:before{content:"\\f595"}.bi-stopwatch-fill:before{content:"\\f596"}.bi-stopwatch:before{content:"\\f597"}.bi-subtract:before{content:"\\f598"}.bi-suit-club-fill:before{content:"\\f599"}.bi-suit-club:before{content:"\\f59a"}.bi-suit-diamond-fill:before{content:"\\f59b"}.bi-suit-diamond:before{content:"\\f59c"}.bi-suit-heart-fill:before{content:"\\f59d"}.bi-suit-heart:before{content:"\\f59e"}.bi-suit-spade-fill:before{content:"\\f59f"}.bi-suit-spade:before{content:"\\f5a0"}.bi-sun-fill:before{content:"\\f5a1"}.bi-sun:before{content:"\\f5a2"}.bi-sunglasses:before{content:"\\f5a3"}.bi-sunrise-fill:before{content:"\\f5a4"}.bi-sunrise:before{content:"\\f5a5"}.bi-sunset-fill:before{content:"\\f5a6"}.bi-sunset:before{content:"\\f5a7"}.bi-symmetry-horizontal:before{content:"\\f5a8"}.bi-symmetry-vertical:before{content:"\\f5a9"}.bi-table:before{content:"\\f5aa"}.bi-tablet-fill:before{content:"\\f5ab"}.bi-tablet-landscape-fill:before{content:"\\f5ac"}.bi-tablet-landscape:before{content:"\\f5ad"}.bi-tablet:before{content:"\\f5ae"}.bi-tag-fill:before{content:"\\f5af"}.bi-tag:before{content:"\\f5b0"}.bi-tags-fill:before{content:"\\f5b1"}.bi-tags:before{content:"\\f5b2"}.bi-telegram:before{content:"\\f5b3"}.bi-telephone-fill:before{content:"\\f5b4"}.bi-telephone-forward-fill:before{content:"\\f5b5"}.bi-telephone-forward:before{content:"\\f5b6"}.bi-telephone-inbound-fill:before{content:"\\f5b7"}.bi-telephone-inbound:before{content:"\\f5b8"}.bi-telephone-minus-fill:before{content:"\\f5b9"}.bi-telephone-minus:before{content:"\\f5ba"}.bi-telephone-outbound-fill:before{content:"\\f5bb"}.bi-telephone-outbound:before{content:"\\f5bc"}.bi-telephone-plus-fill:before{content:"\\f5bd"}.bi-telephone-plus:before{content:"\\f5be"}.bi-telephone-x-fill:before{content:"\\f5bf"}.bi-telephone-x:before{content:"\\f5c0"}.bi-telephone:before{content:"\\f5c1"}.bi-terminal-fill:before{content:"\\f5c2"}.bi-terminal:before{content:"\\f5c3"}.bi-text-center:before{content:"\\f5c4"}.bi-text-indent-left:before{content:"\\f5c5"}.bi-text-indent-right:before{content:"\\f5c6"}.bi-text-left:before{content:"\\f5c7"}.bi-text-paragraph:before{content:"\\f5c8"}.bi-text-right:before{content:"\\f5c9"}.bi-textarea-resize:before{content:"\\f5ca"}.bi-textarea-t:before{content:"\\f5cb"}.bi-textarea:before{content:"\\f5cc"}.bi-thermometer-half:before{content:"\\f5cd"}.bi-thermometer-high:before{content:"\\f5ce"}.bi-thermometer-low:before{content:"\\f5cf"}.bi-thermometer-snow:before{content:"\\f5d0"}.bi-thermometer-sun:before{content:"\\f5d1"}.bi-thermometer:before{content:"\\f5d2"}.bi-three-dots-vertical:before{content:"\\f5d3"}.bi-three-dots:before{content:"\\f5d4"}.bi-toggle-off:before{content:"\\f5d5"}.bi-toggle-on:before{content:"\\f5d6"}.bi-toggle2-off:before{content:"\\f5d7"}.bi-toggle2-on:before{content:"\\f5d8"}.bi-toggles:before{content:"\\f5d9"}.bi-toggles2:before{content:"\\f5da"}.bi-tools:before{content:"\\f5db"}.bi-tornado:before{content:"\\f5dc"}.bi-trash-fill:before{content:"\\f5dd"}.bi-trash:before{content:"\\f5de"}.bi-trash2-fill:before{content:"\\f5df"}.bi-trash2:before{content:"\\f5e0"}.bi-tree-fill:before{content:"\\f5e1"}.bi-tree:before{content:"\\f5e2"}.bi-triangle-fill:before{content:"\\f5e3"}.bi-triangle-half:before{content:"\\f5e4"}.bi-triangle:before{content:"\\f5e5"}.bi-trophy-fill:before{content:"\\f5e6"}.bi-trophy:before{content:"\\f5e7"}.bi-tropical-storm:before{content:"\\f5e8"}.bi-truck-flatbed:before{content:"\\f5e9"}.bi-truck:before{content:"\\f5ea"}.bi-tsunami:before{content:"\\f5eb"}.bi-tv-fill:before{content:"\\f5ec"}.bi-tv:before{content:"\\f5ed"}.bi-twitch:before{content:"\\f5ee"}.bi-twitter:before{content:"\\f5ef"}.bi-type-bold:before{content:"\\f5f0"}.bi-type-h1:before{content:"\\f5f1"}.bi-type-h2:before{content:"\\f5f2"}.bi-type-h3:before{content:"\\f5f3"}.bi-type-italic:before{content:"\\f5f4"}.bi-type-strikethrough:before{content:"\\f5f5"}.bi-type-underline:before{content:"\\f5f6"}.bi-type:before{content:"\\f5f7"}.bi-ui-checks-grid:before{content:"\\f5f8"}.bi-ui-checks:before{content:"\\f5f9"}.bi-ui-radios-grid:before{content:"\\f5fa"}.bi-ui-radios:before{content:"\\f5fb"}.bi-umbrella-fill:before{content:"\\f5fc"}.bi-umbrella:before{content:"\\f5fd"}.bi-union:before{content:"\\f5fe"}.bi-unlock-fill:before{content:"\\f5ff"}.bi-unlock:before{content:"\\f600"}.bi-upc-scan:before{content:"\\f601"}.bi-upc:before{content:"\\f602"}.bi-upload:before{content:"\\f603"}.bi-vector-pen:before{content:"\\f604"}.bi-view-list:before{content:"\\f605"}.bi-view-stacked:before{content:"\\f606"}.bi-vinyl-fill:before{content:"\\f607"}.bi-vinyl:before{content:"\\f608"}.bi-voicemail:before{content:"\\f609"}.bi-volume-down-fill:before{content:"\\f60a"}.bi-volume-down:before{content:"\\f60b"}.bi-volume-mute-fill:before{content:"\\f60c"}.bi-volume-mute:before{content:"\\f60d"}.bi-volume-off-fill:before{content:"\\f60e"}.bi-volume-off:before{content:"\\f60f"}.bi-volume-up-fill:before{content:"\\f610"}.bi-volume-up:before{content:"\\f611"}.bi-vr:before{content:"\\f612"}.bi-wallet-fill:before{content:"\\f613"}.bi-wallet:before{content:"\\f614"}.bi-wallet2:before{content:"\\f615"}.bi-watch:before{content:"\\f616"}.bi-water:before{content:"\\f617"}.bi-whatsapp:before{content:"\\f618"}.bi-wifi-1:before{content:"\\f619"}.bi-wifi-2:before{content:"\\f61a"}.bi-wifi-off:before{content:"\\f61b"}.bi-wifi:before{content:"\\f61c"}.bi-wind:before{content:"\\f61d"}.bi-window-dock:before{content:"\\f61e"}.bi-window-sidebar:before{content:"\\f61f"}.bi-window:before{content:"\\f620"}.bi-wrench:before{content:"\\f621"}.bi-x-circle-fill:before{content:"\\f622"}.bi-x-circle:before{content:"\\f623"}.bi-x-diamond-fill:before{content:"\\f624"}.bi-x-diamond:before{content:"\\f625"}.bi-x-octagon-fill:before{content:"\\f626"}.bi-x-octagon:before{content:"\\f627"}.bi-x-square-fill:before{content:"\\f628"}.bi-x-square:before{content:"\\f629"}.bi-x:before{content:"\\f62a"}.bi-youtube:before{content:"\\f62b"}.bi-zoom-in:before{content:"\\f62c"}.bi-zoom-out:before{content:"\\f62d"}.bi-bank:before{content:"\\f62e"}.bi-bank2:before{content:"\\f62f"}.bi-bell-slash-fill:before{content:"\\f630"}.bi-bell-slash:before{content:"\\f631"}.bi-cash-coin:before{content:"\\f632"}.bi-check-lg:before{content:"\\f633"}.bi-coin:before{content:"\\f634"}.bi-currency-bitcoin:before{content:"\\f635"}.bi-currency-dollar:before{content:"\\f636"}.bi-currency-euro:before{content:"\\f637"}.bi-currency-exchange:before{content:"\\f638"}.bi-currency-pound:before{content:"\\f639"}.bi-currency-yen:before{content:"\\f63a"}.bi-dash-lg:before{content:"\\f63b"}.bi-exclamation-lg:before{content:"\\f63c"}.bi-file-earmark-pdf-fill:before{content:"\\f63d"}.bi-file-earmark-pdf:before{content:"\\f63e"}.bi-file-pdf-fill:before{content:"\\f63f"}.bi-file-pdf:before{content:"\\f640"}.bi-gender-ambiguous:before{content:"\\f641"}.bi-gender-female:before{content:"\\f642"}.bi-gender-male:before{content:"\\f643"}.bi-gender-trans:before{content:"\\f644"}.bi-headset-vr:before{content:"\\f645"}.bi-info-lg:before{content:"\\f646"}.bi-mastodon:before{content:"\\f647"}.bi-messenger:before{content:"\\f648"}.bi-piggy-bank-fill:before{content:"\\f649"}.bi-piggy-bank:before{content:"\\f64a"}.bi-pin-map-fill:before{content:"\\f64b"}.bi-pin-map:before{content:"\\f64c"}.bi-plus-lg:before{content:"\\f64d"}.bi-question-lg:before{content:"\\f64e"}.bi-recycle:before{content:"\\f64f"}.bi-reddit:before{content:"\\f650"}.bi-safe-fill:before{content:"\\f651"}.bi-safe2-fill:before{content:"\\f652"}.bi-safe2:before{content:"\\f653"}.bi-sd-card-fill:before{content:"\\f654"}.bi-sd-card:before{content:"\\f655"}.bi-skype:before{content:"\\f656"}.bi-slash-lg:before{content:"\\f657"}.bi-translate:before{content:"\\f658"}.bi-x-lg:before{content:"\\f659"}.bi-safe:before{content:"\\f65a"}.bi-apple:before{content:"\\f65b"}.bi-microsoft:before{content:"\\f65d"}.bi-windows:before{content:"\\f65e"}.bi-behance:before{content:"\\f65c"}.bi-dribbble:before{content:"\\f65f"}.bi-line:before{content:"\\f660"}.bi-medium:before{content:"\\f661"}.bi-paypal:before{content:"\\f662"}.bi-pinterest:before{content:"\\f663"}.bi-signal:before{content:"\\f664"}.bi-snapchat:before{content:"\\f665"}.bi-spotify:before{content:"\\f666"}.bi-stack-overflow:before{content:"\\f667"}.bi-strava:before{content:"\\f668"}.bi-wordpress:before{content:"\\f669"}.bi-vimeo:before{content:"\\f66a"}.bi-activity:before{content:"\\f66b"}.bi-easel2-fill:before{content:"\\f66c"}.bi-easel2:before{content:"\\f66d"}.bi-easel3-fill:before{content:"\\f66e"}.bi-easel3:before{content:"\\f66f"}.bi-fan:before{content:"\\f670"}.bi-fingerprint:before{content:"\\f671"}.bi-graph-down-arrow:before{content:"\\f672"}.bi-graph-up-arrow:before{content:"\\f673"}.bi-hypnotize:before{content:"\\f674"}.bi-magic:before{content:"\\f675"}.bi-person-rolodex:before{content:"\\f676"}.bi-person-video:before{content:"\\f677"}.bi-person-video2:before{content:"\\f678"}.bi-person-video3:before{content:"\\f679"}.bi-person-workspace:before{content:"\\f67a"}.bi-radioactive:before{content:"\\f67b"}.bi-webcam-fill:before{content:"\\f67c"}.bi-webcam:before{content:"\\f67d"}.bi-yin-yang:before{content:"\\f67e"}.bi-bandaid-fill:before{content:"\\f680"}.bi-bandaid:before{content:"\\f681"}.bi-bluetooth:before{content:"\\f682"}.bi-body-text:before{content:"\\f683"}.bi-boombox:before{content:"\\f684"}.bi-boxes:before{content:"\\f685"}.bi-dpad-fill:before{content:"\\f686"}.bi-dpad:before{content:"\\f687"}.bi-ear-fill:before{content:"\\f688"}.bi-ear:before{content:"\\f689"}.bi-envelope-check-fill:before{content:"\\f68b"}.bi-envelope-check:before{content:"\\f68c"}.bi-envelope-dash-fill:before{content:"\\f68e"}.bi-envelope-dash:before{content:"\\f68f"}.bi-envelope-exclamation-fill:before{content:"\\f691"}.bi-envelope-exclamation:before{content:"\\f692"}.bi-envelope-plus-fill:before{content:"\\f693"}.bi-envelope-plus:before{content:"\\f694"}.bi-envelope-slash-fill:before{content:"\\f696"}.bi-envelope-slash:before{content:"\\f697"}.bi-envelope-x-fill:before{content:"\\f699"}.bi-envelope-x:before{content:"\\f69a"}.bi-explicit-fill:before{content:"\\f69b"}.bi-explicit:before{content:"\\f69c"}.bi-git:before{content:"\\f69d"}.bi-infinity:before{content:"\\f69e"}.bi-list-columns-reverse:before{content:"\\f69f"}.bi-list-columns:before{content:"\\f6a0"}.bi-meta:before{content:"\\f6a1"}.bi-nintendo-switch:before{content:"\\f6a4"}.bi-pc-display-horizontal:before{content:"\\f6a5"}.bi-pc-display:before{content:"\\f6a6"}.bi-pc-horizontal:before{content:"\\f6a7"}.bi-pc:before{content:"\\f6a8"}.bi-playstation:before{content:"\\f6a9"}.bi-plus-slash-minus:before{content:"\\f6aa"}.bi-projector-fill:before{content:"\\f6ab"}.bi-projector:before{content:"\\f6ac"}.bi-qr-code-scan:before{content:"\\f6ad"}.bi-qr-code:before{content:"\\f6ae"}.bi-quora:before{content:"\\f6af"}.bi-quote:before{content:"\\f6b0"}.bi-robot:before{content:"\\f6b1"}.bi-send-check-fill:before{content:"\\f6b2"}.bi-send-check:before{content:"\\f6b3"}.bi-send-dash-fill:before{content:"\\f6b4"}.bi-send-dash:before{content:"\\f6b5"}.bi-send-exclamation-fill:before{content:"\\f6b7"}.bi-send-exclamation:before{content:"\\f6b8"}.bi-send-fill:before{content:"\\f6b9"}.bi-send-plus-fill:before{content:"\\f6ba"}.bi-send-plus:before{content:"\\f6bb"}.bi-send-slash-fill:before{content:"\\f6bc"}.bi-send-slash:before{content:"\\f6bd"}.bi-send-x-fill:before{content:"\\f6be"}.bi-send-x:before{content:"\\f6bf"}.bi-send:before{content:"\\f6c0"}.bi-steam:before{content:"\\f6c1"}.bi-terminal-dash:before{content:"\\f6c3"}.bi-terminal-plus:before{content:"\\f6c4"}.bi-terminal-split:before{content:"\\f6c5"}.bi-ticket-detailed-fill:before{content:"\\f6c6"}.bi-ticket-detailed:before{content:"\\f6c7"}.bi-ticket-fill:before{content:"\\f6c8"}.bi-ticket-perforated-fill:before{content:"\\f6c9"}.bi-ticket-perforated:before{content:"\\f6ca"}.bi-ticket:before{content:"\\f6cb"}.bi-tiktok:before{content:"\\f6cc"}.bi-window-dash:before{content:"\\f6cd"}.bi-window-desktop:before{content:"\\f6ce"}.bi-window-fullscreen:before{content:"\\f6cf"}.bi-window-plus:before{content:"\\f6d0"}.bi-window-split:before{content:"\\f6d1"}.bi-window-stack:before{content:"\\f6d2"}.bi-window-x:before{content:"\\f6d3"}.bi-xbox:before{content:"\\f6d4"}.bi-ethernet:before{content:"\\f6d5"}.bi-hdmi-fill:before{content:"\\f6d6"}.bi-hdmi:before{content:"\\f6d7"}.bi-usb-c-fill:before{content:"\\f6d8"}.bi-usb-c:before{content:"\\f6d9"}.bi-usb-fill:before{content:"\\f6da"}.bi-usb-plug-fill:before{content:"\\f6db"}.bi-usb-plug:before{content:"\\f6dc"}.bi-usb-symbol:before{content:"\\f6dd"}.bi-usb:before{content:"\\f6de"}.bi-boombox-fill:before{content:"\\f6df"}.bi-displayport:before{content:"\\f6e1"}.bi-gpu-card:before{content:"\\f6e2"}.bi-memory:before{content:"\\f6e3"}.bi-modem-fill:before{content:"\\f6e4"}.bi-modem:before{content:"\\f6e5"}.bi-motherboard-fill:before{content:"\\f6e6"}.bi-motherboard:before{content:"\\f6e7"}.bi-optical-audio-fill:before{content:"\\f6e8"}.bi-optical-audio:before{content:"\\f6e9"}.bi-pci-card:before{content:"\\f6ea"}.bi-router-fill:before{content:"\\f6eb"}.bi-router:before{content:"\\f6ec"}.bi-thunderbolt-fill:before{content:"\\f6ef"}.bi-thunderbolt:before{content:"\\f6f0"}.bi-usb-drive-fill:before{content:"\\f6f1"}.bi-usb-drive:before{content:"\\f6f2"}.bi-usb-micro-fill:before{content:"\\f6f3"}.bi-usb-micro:before{content:"\\f6f4"}.bi-usb-mini-fill:before{content:"\\f6f5"}.bi-usb-mini:before{content:"\\f6f6"}.bi-cloud-haze2:before{content:"\\f6f7"}.bi-device-hdd-fill:before{content:"\\f6f8"}.bi-device-hdd:before{content:"\\f6f9"}.bi-device-ssd-fill:before{content:"\\f6fa"}.bi-device-ssd:before{content:"\\f6fb"}.bi-displayport-fill:before{content:"\\f6fc"}.bi-mortarboard-fill:before{content:"\\f6fd"}.bi-mortarboard:before{content:"\\f6fe"}.bi-terminal-x:before{content:"\\f6ff"}.bi-arrow-through-heart-fill:before{content:"\\f700"}.bi-arrow-through-heart:before{content:"\\f701"}.bi-badge-sd-fill:before{content:"\\f702"}.bi-badge-sd:before{content:"\\f703"}.bi-bag-heart-fill:before{content:"\\f704"}.bi-bag-heart:before{content:"\\f705"}.bi-balloon-fill:before{content:"\\f706"}.bi-balloon-heart-fill:before{content:"\\f707"}.bi-balloon-heart:before{content:"\\f708"}.bi-balloon:before{content:"\\f709"}.bi-box2-fill:before{content:"\\f70a"}.bi-box2-heart-fill:before{content:"\\f70b"}.bi-box2-heart:before{content:"\\f70c"}.bi-box2:before{content:"\\f70d"}.bi-braces-asterisk:before{content:"\\f70e"}.bi-calendar-heart-fill:before{content:"\\f70f"}.bi-calendar-heart:before{content:"\\f710"}.bi-calendar2-heart-fill:before{content:"\\f711"}.bi-calendar2-heart:before{content:"\\f712"}.bi-chat-heart-fill:before{content:"\\f713"}.bi-chat-heart:before{content:"\\f714"}.bi-chat-left-heart-fill:before{content:"\\f715"}.bi-chat-left-heart:before{content:"\\f716"}.bi-chat-right-heart-fill:before{content:"\\f717"}.bi-chat-right-heart:before{content:"\\f718"}.bi-chat-square-heart-fill:before{content:"\\f719"}.bi-chat-square-heart:before{content:"\\f71a"}.bi-clipboard-check-fill:before{content:"\\f71b"}.bi-clipboard-data-fill:before{content:"\\f71c"}.bi-clipboard-fill:before{content:"\\f71d"}.bi-clipboard-heart-fill:before{content:"\\f71e"}.bi-clipboard-heart:before{content:"\\f71f"}.bi-clipboard-minus-fill:before{content:"\\f720"}.bi-clipboard-plus-fill:before{content:"\\f721"}.bi-clipboard-pulse:before{content:"\\f722"}.bi-clipboard-x-fill:before{content:"\\f723"}.bi-clipboard2-check-fill:before{content:"\\f724"}.bi-clipboard2-check:before{content:"\\f725"}.bi-clipboard2-data-fill:before{content:"\\f726"}.bi-clipboard2-data:before{content:"\\f727"}.bi-clipboard2-fill:before{content:"\\f728"}.bi-clipboard2-heart-fill:before{content:"\\f729"}.bi-clipboard2-heart:before{content:"\\f72a"}.bi-clipboard2-minus-fill:before{content:"\\f72b"}.bi-clipboard2-minus:before{content:"\\f72c"}.bi-clipboard2-plus-fill:before{content:"\\f72d"}.bi-clipboard2-plus:before{content:"\\f72e"}.bi-clipboard2-pulse-fill:before{content:"\\f72f"}.bi-clipboard2-pulse:before{content:"\\f730"}.bi-clipboard2-x-fill:before{content:"\\f731"}.bi-clipboard2-x:before{content:"\\f732"}.bi-clipboard2:before{content:"\\f733"}.bi-emoji-kiss-fill:before{content:"\\f734"}.bi-emoji-kiss:before{content:"\\f735"}.bi-envelope-heart-fill:before{content:"\\f736"}.bi-envelope-heart:before{content:"\\f737"}.bi-envelope-open-heart-fill:before{content:"\\f738"}.bi-envelope-open-heart:before{content:"\\f739"}.bi-envelope-paper-fill:before{content:"\\f73a"}.bi-envelope-paper-heart-fill:before{content:"\\f73b"}.bi-envelope-paper-heart:before{content:"\\f73c"}.bi-envelope-paper:before{content:"\\f73d"}.bi-filetype-aac:before{content:"\\f73e"}.bi-filetype-ai:before{content:"\\f73f"}.bi-filetype-bmp:before{content:"\\f740"}.bi-filetype-cs:before{content:"\\f741"}.bi-filetype-css:before{content:"\\f742"}.bi-filetype-csv:before{content:"\\f743"}.bi-filetype-doc:before{content:"\\f744"}.bi-filetype-docx:before{content:"\\f745"}.bi-filetype-exe:before{content:"\\f746"}.bi-filetype-gif:before{content:"\\f747"}.bi-filetype-heic:before{content:"\\f748"}.bi-filetype-html:before{content:"\\f749"}.bi-filetype-java:before{content:"\\f74a"}.bi-filetype-jpg:before{content:"\\f74b"}.bi-filetype-js:before{content:"\\f74c"}.bi-filetype-jsx:before{content:"\\f74d"}.bi-filetype-key:before{content:"\\f74e"}.bi-filetype-m4p:before{content:"\\f74f"}.bi-filetype-md:before{content:"\\f750"}.bi-filetype-mdx:before{content:"\\f751"}.bi-filetype-mov:before{content:"\\f752"}.bi-filetype-mp3:before{content:"\\f753"}.bi-filetype-mp4:before{content:"\\f754"}.bi-filetype-otf:before{content:"\\f755"}.bi-filetype-pdf:before{content:"\\f756"}.bi-filetype-php:before{content:"\\f757"}.bi-filetype-png:before{content:"\\f758"}.bi-filetype-ppt:before{content:"\\f75a"}.bi-filetype-psd:before{content:"\\f75b"}.bi-filetype-py:before{content:"\\f75c"}.bi-filetype-raw:before{content:"\\f75d"}.bi-filetype-rb:before{content:"\\f75e"}.bi-filetype-sass:before{content:"\\f75f"}.bi-filetype-scss:before{content:"\\f760"}.bi-filetype-sh:before{content:"\\f761"}.bi-filetype-svg:before{content:"\\f762"}.bi-filetype-tiff:before{content:"\\f763"}.bi-filetype-tsx:before{content:"\\f764"}.bi-filetype-ttf:before{content:"\\f765"}.bi-filetype-txt:before{content:"\\f766"}.bi-filetype-wav:before{content:"\\f767"}.bi-filetype-woff:before{content:"\\f768"}.bi-filetype-xls:before{content:"\\f76a"}.bi-filetype-xml:before{content:"\\f76b"}.bi-filetype-yml:before{content:"\\f76c"}.bi-heart-arrow:before{content:"\\f76d"}.bi-heart-pulse-fill:before{content:"\\f76e"}.bi-heart-pulse:before{content:"\\f76f"}.bi-heartbreak-fill:before{content:"\\f770"}.bi-heartbreak:before{content:"\\f771"}.bi-hearts:before{content:"\\f772"}.bi-hospital-fill:before{content:"\\f773"}.bi-hospital:before{content:"\\f774"}.bi-house-heart-fill:before{content:"\\f775"}.bi-house-heart:before{content:"\\f776"}.bi-incognito:before{content:"\\f777"}.bi-magnet-fill:before{content:"\\f778"}.bi-magnet:before{content:"\\f779"}.bi-person-heart:before{content:"\\f77a"}.bi-person-hearts:before{content:"\\f77b"}.bi-phone-flip:before{content:"\\f77c"}.bi-plugin:before{content:"\\f77d"}.bi-postage-fill:before{content:"\\f77e"}.bi-postage-heart-fill:before{content:"\\f77f"}.bi-postage-heart:before{content:"\\f780"}.bi-postage:before{content:"\\f781"}.bi-postcard-fill:before{content:"\\f782"}.bi-postcard-heart-fill:before{content:"\\f783"}.bi-postcard-heart:before{content:"\\f784"}.bi-postcard:before{content:"\\f785"}.bi-search-heart-fill:before{content:"\\f786"}.bi-search-heart:before{content:"\\f787"}.bi-sliders2-vertical:before{content:"\\f788"}.bi-sliders2:before{content:"\\f789"}.bi-trash3-fill:before{content:"\\f78a"}.bi-trash3:before{content:"\\f78b"}.bi-valentine:before{content:"\\f78c"}.bi-valentine2:before{content:"\\f78d"}.bi-wrench-adjustable-circle-fill:before{content:"\\f78e"}.bi-wrench-adjustable-circle:before{content:"\\f78f"}.bi-wrench-adjustable:before{content:"\\f790"}.bi-filetype-json:before{content:"\\f791"}.bi-filetype-pptx:before{content:"\\f792"}.bi-filetype-xlsx:before{content:"\\f793"}.bi-1-circle-fill:before{content:"\\f796"}.bi-1-circle:before{content:"\\f797"}.bi-1-square-fill:before{content:"\\f798"}.bi-1-square:before{content:"\\f799"}.bi-2-circle-fill:before{content:"\\f79c"}.bi-2-circle:before{content:"\\f79d"}.bi-2-square-fill:before{content:"\\f79e"}.bi-2-square:before{content:"\\f79f"}.bi-3-circle-fill:before{content:"\\f7a2"}.bi-3-circle:before{content:"\\f7a3"}.bi-3-square-fill:before{content:"\\f7a4"}.bi-3-square:before{content:"\\f7a5"}.bi-4-circle-fill:before{content:"\\f7a8"}.bi-4-circle:before{content:"\\f7a9"}.bi-4-square-fill:before{content:"\\f7aa"}.bi-4-square:before{content:"\\f7ab"}.bi-5-circle-fill:before{content:"\\f7ae"}.bi-5-circle:before{content:"\\f7af"}.bi-5-square-fill:before{content:"\\f7b0"}.bi-5-square:before{content:"\\f7b1"}.bi-6-circle-fill:before{content:"\\f7b4"}.bi-6-circle:before{content:"\\f7b5"}.bi-6-square-fill:before{content:"\\f7b6"}.bi-6-square:before{content:"\\f7b7"}.bi-7-circle-fill:before{content:"\\f7ba"}.bi-7-circle:before{content:"\\f7bb"}.bi-7-square-fill:before{content:"\\f7bc"}.bi-7-square:before{content:"\\f7bd"}.bi-8-circle-fill:before{content:"\\f7c0"}.bi-8-circle:before{content:"\\f7c1"}.bi-8-square-fill:before{content:"\\f7c2"}.bi-8-square:before{content:"\\f7c3"}.bi-9-circle-fill:before{content:"\\f7c6"}.bi-9-circle:before{content:"\\f7c7"}.bi-9-square-fill:before{content:"\\f7c8"}.bi-9-square:before{content:"\\f7c9"}.bi-airplane-engines-fill:before{content:"\\f7ca"}.bi-airplane-engines:before{content:"\\f7cb"}.bi-airplane-fill:before{content:"\\f7cc"}.bi-airplane:before{content:"\\f7cd"}.bi-alexa:before{content:"\\f7ce"}.bi-alipay:before{content:"\\f7cf"}.bi-android:before{content:"\\f7d0"}.bi-android2:before{content:"\\f7d1"}.bi-box-fill:before{content:"\\f7d2"}.bi-box-seam-fill:before{content:"\\f7d3"}.bi-browser-chrome:before{content:"\\f7d4"}.bi-browser-edge:before{content:"\\f7d5"}.bi-browser-firefox:before{content:"\\f7d6"}.bi-browser-safari:before{content:"\\f7d7"}.bi-c-circle-fill:before{content:"\\f7da"}.bi-c-circle:before{content:"\\f7db"}.bi-c-square-fill:before{content:"\\f7dc"}.bi-c-square:before{content:"\\f7dd"}.bi-capsule-pill:before{content:"\\f7de"}.bi-capsule:before{content:"\\f7df"}.bi-car-front-fill:before{content:"\\f7e0"}.bi-car-front:before{content:"\\f7e1"}.bi-cassette-fill:before{content:"\\f7e2"}.bi-cassette:before{content:"\\f7e3"}.bi-cc-circle-fill:before{content:"\\f7e6"}.bi-cc-circle:before{content:"\\f7e7"}.bi-cc-square-fill:before{content:"\\f7e8"}.bi-cc-square:before{content:"\\f7e9"}.bi-cup-hot-fill:before{content:"\\f7ea"}.bi-cup-hot:before{content:"\\f7eb"}.bi-currency-rupee:before{content:"\\f7ec"}.bi-dropbox:before{content:"\\f7ed"}.bi-escape:before{content:"\\f7ee"}.bi-fast-forward-btn-fill:before{content:"\\f7ef"}.bi-fast-forward-btn:before{content:"\\f7f0"}.bi-fast-forward-circle-fill:before{content:"\\f7f1"}.bi-fast-forward-circle:before{content:"\\f7f2"}.bi-fast-forward-fill:before{content:"\\f7f3"}.bi-fast-forward:before{content:"\\f7f4"}.bi-filetype-sql:before{content:"\\f7f5"}.bi-fire:before{content:"\\f7f6"}.bi-google-play:before{content:"\\f7f7"}.bi-h-circle-fill:before{content:"\\f7fa"}.bi-h-circle:before{content:"\\f7fb"}.bi-h-square-fill:before{content:"\\f7fc"}.bi-h-square:before{content:"\\f7fd"}.bi-indent:before{content:"\\f7fe"}.bi-lungs-fill:before{content:"\\f7ff"}.bi-lungs:before{content:"\\f800"}.bi-microsoft-teams:before{content:"\\f801"}.bi-p-circle-fill:before{content:"\\f804"}.bi-p-circle:before{content:"\\f805"}.bi-p-square-fill:before{content:"\\f806"}.bi-p-square:before{content:"\\f807"}.bi-pass-fill:before{content:"\\f808"}.bi-pass:before{content:"\\f809"}.bi-prescription:before{content:"\\f80a"}.bi-prescription2:before{content:"\\f80b"}.bi-r-circle-fill:before{content:"\\f80e"}.bi-r-circle:before{content:"\\f80f"}.bi-r-square-fill:before{content:"\\f810"}.bi-r-square:before{content:"\\f811"}.bi-repeat-1:before{content:"\\f812"}.bi-repeat:before{content:"\\f813"}.bi-rewind-btn-fill:before{content:"\\f814"}.bi-rewind-btn:before{content:"\\f815"}.bi-rewind-circle-fill:before{content:"\\f816"}.bi-rewind-circle:before{content:"\\f817"}.bi-rewind-fill:before{content:"\\f818"}.bi-rewind:before{content:"\\f819"}.bi-train-freight-front-fill:before{content:"\\f81a"}.bi-train-freight-front:before{content:"\\f81b"}.bi-train-front-fill:before{content:"\\f81c"}.bi-train-front:before{content:"\\f81d"}.bi-train-lightrail-front-fill:before{content:"\\f81e"}.bi-train-lightrail-front:before{content:"\\f81f"}.bi-truck-front-fill:before{content:"\\f820"}.bi-truck-front:before{content:"\\f821"}.bi-ubuntu:before{content:"\\f822"}.bi-unindent:before{content:"\\f823"}.bi-unity:before{content:"\\f824"}.bi-universal-access-circle:before{content:"\\f825"}.bi-universal-access:before{content:"\\f826"}.bi-virus:before{content:"\\f827"}.bi-virus2:before{content:"\\f828"}.bi-wechat:before{content:"\\f829"}.bi-yelp:before{content:"\\f82a"}.bi-sign-stop-fill:before{content:"\\f82b"}.bi-sign-stop-lights-fill:before{content:"\\f82c"}.bi-sign-stop-lights:before{content:"\\f82d"}.bi-sign-stop:before{content:"\\f82e"}.bi-sign-turn-left-fill:before{content:"\\f82f"}.bi-sign-turn-left:before{content:"\\f830"}.bi-sign-turn-right-fill:before{content:"\\f831"}.bi-sign-turn-right:before{content:"\\f832"}.bi-sign-turn-slight-left-fill:before{content:"\\f833"}.bi-sign-turn-slight-left:before{content:"\\f834"}.bi-sign-turn-slight-right-fill:before{content:"\\f835"}.bi-sign-turn-slight-right:before{content:"\\f836"}.bi-sign-yield-fill:before{content:"\\f837"}.bi-sign-yield:before{content:"\\f838"}.bi-ev-station-fill:before{content:"\\f839"}.bi-ev-station:before{content:"\\f83a"}.bi-fuel-pump-diesel-fill:before{content:"\\f83b"}.bi-fuel-pump-diesel:before{content:"\\f83c"}.bi-fuel-pump-fill:before{content:"\\f83d"}.bi-fuel-pump:before{content:"\\f83e"}.bi-0-circle-fill:before{content:"\\f83f"}.bi-0-circle:before{content:"\\f840"}.bi-0-square-fill:before{content:"\\f841"}.bi-0-square:before{content:"\\f842"}.bi-rocket-fill:before{content:"\\f843"}.bi-rocket-takeoff-fill:before{content:"\\f844"}.bi-rocket-takeoff:before{content:"\\f845"}.bi-rocket:before{content:"\\f846"}.bi-stripe:before{content:"\\f847"}.bi-subscript:before{content:"\\f848"}.bi-superscript:before{content:"\\f849"}.bi-trello:before{content:"\\f84a"}.bi-envelope-at-fill:before{content:"\\f84b"}.bi-envelope-at:before{content:"\\f84c"}.bi-regex:before{content:"\\f84d"}.bi-text-wrap:before{content:"\\f84e"}.bi-sign-dead-end-fill:before{content:"\\f84f"}.bi-sign-dead-end:before{content:"\\f850"}.bi-sign-do-not-enter-fill:before{content:"\\f851"}.bi-sign-do-not-enter:before{content:"\\f852"}.bi-sign-intersection-fill:before{content:"\\f853"}.bi-sign-intersection-side-fill:before{content:"\\f854"}.bi-sign-intersection-side:before{content:"\\f855"}.bi-sign-intersection-t-fill:before{content:"\\f856"}.bi-sign-intersection-t:before{content:"\\f857"}.bi-sign-intersection-y-fill:before{content:"\\f858"}.bi-sign-intersection-y:before{content:"\\f859"}.bi-sign-intersection:before{content:"\\f85a"}.bi-sign-merge-left-fill:before{content:"\\f85b"}.bi-sign-merge-left:before{content:"\\f85c"}.bi-sign-merge-right-fill:before{content:"\\f85d"}.bi-sign-merge-right:before{content:"\\f85e"}.bi-sign-no-left-turn-fill:before{content:"\\f85f"}.bi-sign-no-left-turn:before{content:"\\f860"}.bi-sign-no-parking-fill:before{content:"\\f861"}.bi-sign-no-parking:before{content:"\\f862"}.bi-sign-no-right-turn-fill:before{content:"\\f863"}.bi-sign-no-right-turn:before{content:"\\f864"}.bi-sign-railroad-fill:before{content:"\\f865"}.bi-sign-railroad:before{content:"\\f866"}.bi-building-add:before{content:"\\f867"}.bi-building-check:before{content:"\\f868"}.bi-building-dash:before{content:"\\f869"}.bi-building-down:before{content:"\\f86a"}.bi-building-exclamation:before{content:"\\f86b"}.bi-building-fill-add:before{content:"\\f86c"}.bi-building-fill-check:before{content:"\\f86d"}.bi-building-fill-dash:before{content:"\\f86e"}.bi-building-fill-down:before{content:"\\f86f"}.bi-building-fill-exclamation:before{content:"\\f870"}.bi-building-fill-gear:before{content:"\\f871"}.bi-building-fill-lock:before{content:"\\f872"}.bi-building-fill-slash:before{content:"\\f873"}.bi-building-fill-up:before{content:"\\f874"}.bi-building-fill-x:before{content:"\\f875"}.bi-building-fill:before{content:"\\f876"}.bi-building-gear:before{content:"\\f877"}.bi-building-lock:before{content:"\\f878"}.bi-building-slash:before{content:"\\f879"}.bi-building-up:before{content:"\\f87a"}.bi-building-x:before{content:"\\f87b"}.bi-buildings-fill:before{content:"\\f87c"}.bi-buildings:before{content:"\\f87d"}.bi-bus-front-fill:before{content:"\\f87e"}.bi-bus-front:before{content:"\\f87f"}.bi-ev-front-fill:before{content:"\\f880"}.bi-ev-front:before{content:"\\f881"}.bi-globe-americas:before{content:"\\f882"}.bi-globe-asia-australia:before{content:"\\f883"}.bi-globe-central-south-asia:before{content:"\\f884"}.bi-globe-europe-africa:before{content:"\\f885"}.bi-house-add-fill:before{content:"\\f886"}.bi-house-add:before{content:"\\f887"}.bi-house-check-fill:before{content:"\\f888"}.bi-house-check:before{content:"\\f889"}.bi-house-dash-fill:before{content:"\\f88a"}.bi-house-dash:before{content:"\\f88b"}.bi-house-down-fill:before{content:"\\f88c"}.bi-house-down:before{content:"\\f88d"}.bi-house-exclamation-fill:before{content:"\\f88e"}.bi-house-exclamation:before{content:"\\f88f"}.bi-house-gear-fill:before{content:"\\f890"}.bi-house-gear:before{content:"\\f891"}.bi-house-lock-fill:before{content:"\\f892"}.bi-house-lock:before{content:"\\f893"}.bi-house-slash-fill:before{content:"\\f894"}.bi-house-slash:before{content:"\\f895"}.bi-house-up-fill:before{content:"\\f896"}.bi-house-up:before{content:"\\f897"}.bi-house-x-fill:before{content:"\\f898"}.bi-house-x:before{content:"\\f899"}.bi-person-add:before{content:"\\f89a"}.bi-person-down:before{content:"\\f89b"}.bi-person-exclamation:before{content:"\\f89c"}.bi-person-fill-add:before{content:"\\f89d"}.bi-person-fill-check:before{content:"\\f89e"}.bi-person-fill-dash:before{content:"\\f89f"}.bi-person-fill-down:before{content:"\\f8a0"}.bi-person-fill-exclamation:before{content:"\\f8a1"}.bi-person-fill-gear:before{content:"\\f8a2"}.bi-person-fill-lock:before{content:"\\f8a3"}.bi-person-fill-slash:before{content:"\\f8a4"}.bi-person-fill-up:before{content:"\\f8a5"}.bi-person-fill-x:before{content:"\\f8a6"}.bi-person-gear:before{content:"\\f8a7"}.bi-person-lock:before{content:"\\f8a8"}.bi-person-slash:before{content:"\\f8a9"}.bi-person-up:before{content:"\\f8aa"}.bi-scooter:before{content:"\\f8ab"}.bi-taxi-front-fill:before{content:"\\f8ac"}.bi-taxi-front:before{content:"\\f8ad"}.bi-amd:before{content:"\\f8ae"}.bi-database-add:before{content:"\\f8af"}.bi-database-check:before{content:"\\f8b0"}.bi-database-dash:before{content:"\\f8b1"}.bi-database-down:before{content:"\\f8b2"}.bi-database-exclamation:before{content:"\\f8b3"}.bi-database-fill-add:before{content:"\\f8b4"}.bi-database-fill-check:before{content:"\\f8b5"}.bi-database-fill-dash:before{content:"\\f8b6"}.bi-database-fill-down:before{content:"\\f8b7"}.bi-database-fill-exclamation:before{content:"\\f8b8"}.bi-database-fill-gear:before{content:"\\f8b9"}.bi-database-fill-lock:before{content:"\\f8ba"}.bi-database-fill-slash:before{content:"\\f8bb"}.bi-database-fill-up:before{content:"\\f8bc"}.bi-database-fill-x:before{content:"\\f8bd"}.bi-database-fill:before{content:"\\f8be"}.bi-database-gear:before{content:"\\f8bf"}.bi-database-lock:before{content:"\\f8c0"}.bi-database-slash:before{content:"\\f8c1"}.bi-database-up:before{content:"\\f8c2"}.bi-database-x:before{content:"\\f8c3"}.bi-database:before{content:"\\f8c4"}.bi-houses-fill:before{content:"\\f8c5"}.bi-houses:before{content:"\\f8c6"}.bi-nvidia:before{content:"\\f8c7"}.bi-person-vcard-fill:before{content:"\\f8c8"}.bi-person-vcard:before{content:"\\f8c9"}.bi-sina-weibo:before{content:"\\f8ca"}.bi-tencent-qq:before{content:"\\f8cb"}.bi-wikipedia:before{content:"\\f8cc"}.bi-alphabet-uppercase:before{content:"\\f2a5"}.bi-alphabet:before{content:"\\f68a"}.bi-amazon:before{content:"\\f68d"}.bi-arrows-collapse-vertical:before{content:"\\f690"}.bi-arrows-expand-vertical:before{content:"\\f695"}.bi-arrows-vertical:before{content:"\\f698"}.bi-arrows:before{content:"\\f6a2"}.bi-ban-fill:before{content:"\\f6a3"}.bi-ban:before{content:"\\f6b6"}.bi-bing:before{content:"\\f6c2"}.bi-cake:before{content:"\\f6e0"}.bi-cake2:before{content:"\\f6ed"}.bi-cookie:before{content:"\\f6ee"}.bi-copy:before{content:"\\f759"}.bi-crosshair:before{content:"\\f769"}.bi-crosshair2:before{content:"\\f794"}.bi-emoji-astonished-fill:before{content:"\\f795"}.bi-emoji-astonished:before{content:"\\f79a"}.bi-emoji-grimace-fill:before{content:"\\f79b"}.bi-emoji-grimace:before{content:"\\f7a0"}.bi-emoji-grin-fill:before{content:"\\f7a1"}.bi-emoji-grin:before{content:"\\f7a6"}.bi-emoji-surprise-fill:before{content:"\\f7a7"}.bi-emoji-surprise:before{content:"\\f7ac"}.bi-emoji-tear-fill:before{content:"\\f7ad"}.bi-emoji-tear:before{content:"\\f7b2"}.bi-envelope-arrow-down-fill:before{content:"\\f7b3"}.bi-envelope-arrow-down:before{content:"\\f7b8"}.bi-envelope-arrow-up-fill:before{content:"\\f7b9"}.bi-envelope-arrow-up:before{content:"\\f7be"}.bi-feather:before{content:"\\f7bf"}.bi-feather2:before{content:"\\f7c4"}.bi-floppy-fill:before{content:"\\f7c5"}.bi-floppy:before{content:"\\f7d8"}.bi-floppy2-fill:before{content:"\\f7d9"}.bi-floppy2:before{content:"\\f7e4"}.bi-gitlab:before{content:"\\f7e5"}.bi-highlighter:before{content:"\\f7f8"}.bi-marker-tip:before{content:"\\f802"}.bi-nvme-fill:before{content:"\\f803"}.bi-nvme:before{content:"\\f80c"}.bi-opencollective:before{content:"\\f80d"}.bi-pci-card-network:before{content:"\\f8cd"}.bi-pci-card-sound:before{content:"\\f8ce"}.bi-radar:before{content:"\\f8cf"}.bi-send-arrow-down-fill:before{content:"\\f8d0"}.bi-send-arrow-down:before{content:"\\f8d1"}.bi-send-arrow-up-fill:before{content:"\\f8d2"}.bi-send-arrow-up:before{content:"\\f8d3"}.bi-sim-slash-fill:before{content:"\\f8d4"}.bi-sim-slash:before{content:"\\f8d5"}.bi-sourceforge:before{content:"\\f8d6"}.bi-substack:before{content:"\\f8d7"}.bi-threads-fill:before{content:"\\f8d8"}.bi-threads:before{content:"\\f8d9"}.bi-transparency:before{content:"\\f8da"}.bi-twitter-x:before{content:"\\f8db"}.bi-type-h4:before{content:"\\f8dc"}.bi-type-h5:before{content:"\\f8dd"}.bi-type-h6:before{content:"\\f8de"}.bi-backpack-fill:before{content:"\\f8df"}.bi-backpack:before{content:"\\f8e0"}.bi-backpack2-fill:before{content:"\\f8e1"}.bi-backpack2:before{content:"\\f8e2"}.bi-backpack3-fill:before{content:"\\f8e3"}.bi-backpack3:before{content:"\\f8e4"}.bi-backpack4-fill:before{content:"\\f8e5"}.bi-backpack4:before{content:"\\f8e6"}.bi-brilliance:before{content:"\\f8e7"}.bi-cake-fill:before{content:"\\f8e8"}.bi-cake2-fill:before{content:"\\f8e9"}.bi-duffle-fill:before{content:"\\f8ea"}.bi-duffle:before{content:"\\f8eb"}.bi-exposure:before{content:"\\f8ec"}.bi-gender-neuter:before{content:"\\f8ed"}.bi-highlights:before{content:"\\f8ee"}.bi-luggage-fill:before{content:"\\f8ef"}.bi-luggage:before{content:"\\f8f0"}.bi-mailbox-flag:before{content:"\\f8f1"}.bi-mailbox2-flag:before{content:"\\f8f2"}.bi-noise-reduction:before{content:"\\f8f3"}.bi-passport-fill:before{content:"\\f8f4"}.bi-passport:before{content:"\\f8f5"}.bi-person-arms-up:before{content:"\\f8f6"}.bi-person-raised-hand:before{content:"\\f8f7"}.bi-person-standing-dress:before{content:"\\f8f8"}.bi-person-standing:before{content:"\\f8f9"}.bi-person-walking:before{content:"\\f8fa"}.bi-person-wheelchair:before{content:"\\f8fb"}.bi-shadows:before{content:"\\f8fc"}.bi-suitcase-fill:before{content:"\\f8fd"}.bi-suitcase-lg-fill:before{content:"\\f8fe"}.bi-suitcase-lg:before{content:"\\f8ff"}.bi-suitcase:before{content:"\\f900"}.bi-suitcase2-fill:before{content:"\\f901"}.bi-suitcase2:before{content:"\\f902"}.bi-vignette:before{content:"\\f903"}foreignObject.loci{box-sizing:border-box;border-radius:.375rem;position:relative;display:block}foreignObject.loci div.foreground{position:relative;display:flex;height:100%;width:100%;justify-content:center;align-items:center;box-sizing:inherit;border-radius:inherit;border-width:1px;border-style:solid;opacity:1}foreignObject.loci div.background{position:absolute;left:0;top:0;display:block;height:100%;width:100%;opacity:.3}foreignObject.pins div.foreground{position:relative;display:flex;height:100%;width:100%;justify-content:center;align-items:flex-end;box-sizing:border-box}foreignObject.dssp div.foreground{position:relative;display:flex;height:100%;width:100%;justify-content:center;align-items:flex-end;box-sizing:border-box}foreignObject.dssp i[class^=dssp]{position:relative;visibility:hidden;display:flex;height:100%;width:100%}foreignObject.dssp i.dssp-helix{visibility:visible;background-color:inherit;-webkit-mask-image:url(dssp-helix.74d0a47e4d7ed27e.svg);mask-image:url(dssp-helix.74d0a47e4d7ed27e.svg);-webkit-mask-position:0 center;mask-position:0 center;-webkit-mask-size:auto 100%;mask-size:auto 100%}foreignObject.dssp i.dssp-strand{display:flex;visibility:hidden}foreignObject.dssp i.dssp-strand:before{visibility:visible;background-color:inherit;-webkit-mask-image:url(dssp-strand-tail.783864b28823e2c7.svg);mask-image:url(dssp-strand-tail.783864b28823e2c7.svg);-webkit-mask-position:0 center;mask-position:0 center;-webkit-mask-size:auto 100%;mask-size:auto 100%;flex-shrink:1;flex-grow:1;content:""}foreignObject.dssp i.dssp-strand:after{visibility:visible;background-color:inherit;-webkit-mask-image:url(dssp-strand-head.85a295955fb4c220.svg);mask-image:url(dssp-strand-head.85a295955fb4c220.svg);-webkit-mask-position:0 center;mask-position:0 center;-webkit-mask-size:auto 100%;mask-size:auto 100%;flex-shrink:0;flex-grow:0;content:"";width:31px}.axis-grid line{stroke-opacity:.3;stroke:gray}.axis-grid line:nth-child(1){stroke-dasharray:2}.y.axis .tick text{display:none}\n'],encapsulation:2})}return e})();const Axt={providers:[function MPe(e,...t){return Iy([{provide:Ob,multi:!0,useValue:e},[],{provide:Rb,useFactory:yZ,deps:[Kl]},{provide:OA,multi:!0,useFactory:bZ},t.map(n=>n.\u0275providers)])}([{path:"structure",component:Lyt},{path:"feature",component:(()=>{class e{constructor(){this.settings={"line-height":24,"content-size":16,"background-color":"transparent","trace-color":"pink","grid-color":"white","margin-top":24,"margin-right":24,"margin-bottom":24,"margin-left":128},this.sequence=["M","E","E","P","Q"],this.features=[{label:"Feature #1",type:"continuous",values:[1.2,2.7,5.4,2.8,3.7]},{label:"Feature #2",type:"loci",values:[{start:1,end:3},{start:4,end:5}]},{label:"Feature #3",type:"trace",position:"overlap",values:[{type:"loci",values:[{start:3,end:5}]},{type:"loci",values:[{start:1,end:4}]},{type:"continuous",values:[3.2,1.1,.7,.9,2.2]}]},{label:"Feature #4",type:"loci",values:[{start:1,end:2},{start:3,end:4}],nested:[{label:"Feature #5",type:"trace",values:[{type:"loci",values:[{start:1,end:1},{start:2,end:5}]},{type:"loci",values:[{start:2,end:4}]}]},{label:"Feature #6",type:"continuous",values:[.2,1.1,3.7,2.8,2.9]}]}]}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["page-features-viewer"]],standalone:!0,features:[Nu],decls:14,vars:3,consts:[[1,"container","pt-3"],[1,"mb-3"],[1,"d-flex","flex-row","gap-3","mb-3"],[2,"display","block","width","1rem","height","1rem","background","black","font-size","1rem","line-height","1rem"],[2,"display","block","width","1rem","height","auto","background","black","color","white","font-size","1rem","line-height",".5rem"],[2,"display","block","width","auto","height","1rem","background","black","color","white","font-size","1rem","line-height","1rem"],[2,"display","block","height","auto","width","100%"],[3,"sequence","features","settings"]],template:function(r,i){1&r&&(dn(0,"div",0)(1,"div",1)(2,"h1"),ar(3,"Feature viewer"),fn(),dn(4,"p"),ar(5," The feature viewer allows you to represent features on a reference seqeunce... "),fn()(),dn(6,"div",2),gi(7,"div",3),dn(8,"div",4),ar(9,"W"),fn(),dn(10,"div",5),ar(11,"W"),fn()(),dn(12,"div",6),gi(13,"ngx-features-viewer",7),fn()()),2&r&&(mi(13),Bh("sequence",i.sequence)("features",i.features)("settings",i.settings))},dependencies:[Uh,wxt],changeDetection:0})}return e})()},{path:"",component:(()=>{class e{static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["page-home"]],standalone:!0,features:[Nu],decls:48,vars:0,consts:[[1,"container","pt-3"],[1,"row"],[1,"col-12"],[1,"mb-3"],[1,"row","align-items-stretch","mb-3"],[1,"col-4"],["routerLink","/structure",1,"product-card","rounded","bg-body-tertiary","p-3","mb-3"],[1,"bi","bi-boxes","me-3"],["src","assets/structure-viewer.png","alt","Structure viewer",1,"w-100","h-auto","mb-3"],[1,"text-justify","mb-3"],[1,"text-center","mt-auto"],[1,"badge","rounded-pill","text-bg-warning"],[1,"bi","bi-chevron-right"],[1,"col-4","product"],["routerLink","/feature",1,"product-card","rounded","bg-body-tertiary","p-3","mb-3"],[1,"bi","bi-sliders"],["routerLink","/sequence",1,"product-card","rounded","bg-body-tertiary","p-3","mb-3"],[1,"bi","bi-body-text"],[1,"rounded","bg-body-tertiary","shadow-sm","p-3","mb-3"],[1,"bi","bi-share-fill"]],template:function(r,i){1&r&&(dn(0,"div",0)(1,"div",1)(2,"div",2)(3,"h1",3),ar(4,"Products"),fn()()(),dn(5,"div",4)(6,"div",5)(7,"div",6)(8,"h2"),gi(9,"i",7),ar(10," Structure viewer "),fn(),gi(11,"img",8),dn(12,"p",9),ar(13," Visualize and interact with 3D molecular structures. Provides Mol* functionalities out-of-the-box for Angular developers. "),fn(),dn(14,"div",10)(15,"span",11),ar(16," Try it out "),gi(17,"i",12),fn()()()(),dn(18,"div",13)(19,"div",14)(20,"h2"),gi(21,"i",15),ar(22," Feature viewer "),fn(),dn(23,"p",3),ar(24," The feature viewer is a powerful tool designed for visualizing features of biological sequences, such as proteins, DNA, or RNA. It provides a comprehensive set of functionalities to explore and analyze these sequences. With the feature viewer, users can easily identify and visualize various features, including structural elements, functional domains, mutations, and more. It offers a user-friendly interface with intuitive gestures and actions, allowing users to zoom in and out, pan across the sequence, highlight specific regions, and perform interactive selections. Whether you are a biologist, bioinformatician, or researcher, the feature viewer is an indispensable tool for gaining insights into the intricate details of biological sequences. "),fn(),dn(25,"div",10)(26,"span",11),ar(27," Try it out "),gi(28,"i",12),fn()()()(),dn(29,"div",5)(30,"div",16)(31,"h2"),gi(32,"i",17),ar(33," Sequence viewer "),fn(),dn(34,"p",3),ar(35," The sequence viewer is a specialized tool designed for visualizing multiple sequence alignments and other features across protein sequences. It provides a comprehensive view of the similarities and differences between multiple protein sequences, allowing users to easily identify conserved regions, mutations, and other important features. The sequence viewer supports various display options, enabling users to customize the view according to their needs. It also allows for interactive exploration, with features such as zooming and panning, highlighting specific regions, and hovering over specific points for more detailed information. This makes the sequence viewer an essential tool for bioinformaticians and researchers studying protein sequences and their relationships. "),fn(),dn(36,"div",10)(37,"span",11),ar(38," Try it out "),gi(39,"i",12),fn()()()()(),dn(40,"div",1)(41,"div",2)(42,"div",18)(43,"h2"),gi(44,"i",19),ar(45," Enhanced interactivity"),fn(),dn(46,"p"),ar(47," Our components are designed starting from the same, generic data structures. This is meant to easily wire up various compoents in the same page. Hence, implementing interactivity out-of-the-box "),fn()()()()())},dependencies:[Uh,GF,TI],styles:[".product-card[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:nowrap;height:100%;width:100%;cursor:pointer;box-shadow:0 .125rem .25rem #00000013}.product-card[_ngcontent-%COMP%]:hover{box-shadow:0 .5rem 1rem #00000026}"]})}return e})()},{path:"**",redirectTo:""}])]};(function hDe(e,t){return DAe({rootComponent:e,...YX(t)})})((()=>{class e{constructor(){this.title="ngx-bio-tools",this.sequence="MLPGLALLLLAAWTARALEVPTDGNAGLLAEPQIAMFCGRLNMHMNVQNGKWDSDPSGTKTCIDTKEGILQYCQEVYPELQITNVVEANQPVTIQNWCKRGRKQCKTHPHFVIPYRCLVGEFVSDALLVPDKCKFLHQERMDVCETHLHWHTVAKETCSEKSTNLHDYGMLLPCGIDKFRGVEFVCCPLAEESDNVDSADAEEDDSDVWWGGADTDYADGSEDKVVEVAEEEEVAEVEEEEADDDEDDEDGDEVEEEAEEPYEEATERTTSIATTTTTTTESVEEVVREVCSEQAETGPCRAMISRWYFDVTEGKCAPFFYGGCGGNRNNFDTEEYCMAVCGSAMSQSLLKTTQEPLARDPVKLPTTAASTPDAVDKYLETPGDENEHAHFQKAKERLEAKHRERMSQVMREWEEAERQAKNLPKADKKAVIQHFQEKVESLEQEAANERQQLVETHMARVEAMLNDRRRLALENYITALQAVPPRPRHVFNMLKKYVRAEQKDRQHTLKHFEHVRMVDPKKAAQIRSQVMTHLRVIYERMNQSLSLLYNVPAVAEEIQDEVDELLQKEQNYSDDVLANMISEPRISYGNDALMPSLTETKTTVELLPVNGEFSLDDLQPWHSFGADSVPANTENEVEPVDARPAADRGLTTRPGSGLTNIKTEEISEVKMDAEFRHDSGYEVHHQKLVFFAEDVGSNKGAIIGLMVGGVVIATVIVITLVMLKKKQYTSIHHGVVEVDAAVTPEERHLSKMQQNGYENPTYKFFEQMQN".split(""),this.features=[{id:0,type:"continuous",color:"blue",values:this.sequence.map(()=>Math.random()),parent:void 0,height:128},{id:1,type:"loci",color:"red",values:[{start:1,end:3},{start:5,end:6}],parent:void 0,height:96},{id:2,type:"pins",color:"green",values:[{start:5},{start:100,color:"blue"},{start:400,color:"red"}],parent:1},{id:3,type:"loci",color:"orange",values:[{start:10,end:20},{start:30,end:70}],parent:1},{id:4,type:"loci",color:"purple",values:[{start:100,end:300}],parent:void 0},{id:5,type:"dssp",color:"black",values:[{start:30,end:90,code:"H",color:"orange"},{start:120,end:300,code:"E",color:"purple"}],parent:void 0}]}static#e=this.\u0275fac=function(r){return new(r||e)};static#t=this.\u0275cmp=Mu({type:e,selectors:[["app-root"]],standalone:!0,features:[Nu],decls:17,vars:0,consts:[[1,"navbar"],[1,"container-fluid"],["href","#",1,"navbar-brand"],["src","assets/ngx-biocomp-up-white.svg","alt","ngx-biocomp-up","height","32",1,"d-inline-block","align-text-top"],[1,"container-fluid","bg-dark","pt-2","pb-2"],[1,"row"],[1,"col-3","d-flex","justify-content-start"],["src","assets/biocomp.svg","alt","BioComputing UP","height","36"],[1,"col-6","d-flex","align-items-center","justify-content-center"],["href","https://github.com/damiclem",1,"text-light","small"],[1,"bi","bi-github"],[1,"col-3","d-flex","justify-content-end"],["src","assets/unipd.svg","alt","University of Padua","height","36"]],template:function(r,i){1&r&&(dn(0,"header")(1,"nav",0)(2,"div",1)(3,"a",2),gi(4,"img",3),fn()()()(),dn(5,"main"),gi(6,"router-outlet"),fn(),dn(7,"footer",4)(8,"div",5)(9,"div",6),gi(10,"img",7),fn(),dn(11,"div",8)(12,"a",9),ar(13," Developed by Damiano Clementel "),gi(14,"i",10),fn()(),dn(15,"div",11),gi(16,"img",12),fn()()())},dependencies:[Uh,GF,MF],styles:["[_nghost-%COMP%]{height:inherit;display:inherit;flex-direction:inherit}"]})}return e})(),Axt).catch(e=>console.error(e))},684:r_=>{r_.exports=XMLHttpRequest}},r_=>{r_(r_.s=540)}]); \ No newline at end of file