From 96dd10e442c3c55606396a1c5f4175689a02a2fa Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Mon, 16 Sep 2024 11:41:09 +0200 Subject: [PATCH 1/9] Replace haddock3-analysis-components with haddock3-ui package --- src/haddock/libs/libplots.py | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/haddock/libs/libplots.py b/src/haddock/libs/libplots.py index 042414be9b..a32ed4d3c9 100644 --- a/src/haddock/libs/libplots.py +++ b/src/haddock/libs/libplots.py @@ -980,7 +980,7 @@ def _css_styles_for_report(): } """ - css_link = "https://esm.sh/@i-vresse/haddock3-analysis-components@~0.4.1/dist/style.css" # noqa:E501 + css_link = "https://esm.sh/@i-vresse/haddock3-ui@~0.2.2/dist/index.css" table_css = f' ' return f"{table_css}" @@ -1028,16 +1028,6 @@ def _generate_html_head(step): head += f"Analysis report of step {step}" head += f"

Analysis report of step {step}

" head += _css_styles_for_report() - head += """ - """ # noqa : E501 head += "" return head @@ -1068,9 +1058,9 @@ def _generate_unclustered_table_html( }} """ # noqa : E501 def _generate_clustered_table_html( table_id: str, df: pd.DataFrame, + bundle_url: str, ) -> str: data = df.to_json(orient='records') nr_best_columns = df.filter(like="best").shape[1] @@ -1105,15 +1115,10 @@ def _generate_clustered_table_html( }} """ # noqa : E501 @@ -1127,6 +1132,8 @@ def _generate_html_body(figures: list[Figure], offline: bool = False) -> str: A list of figures to include in the HTML body. Each figure can be either a string representing a table or a plotly.graph_objects.Figure object. + offline : bool + If True, the HTML will be generated for offline use. Returns ------- @@ -1142,10 +1149,14 @@ def _generate_html_body(figures: list[Figure], offline: bool = False) -> str: table_id = f"table{table_index}" is_unclustered = 'cluster_rank' not in figure + bundle_url = "https://cdn.jsdelivr.net/npm/@i-vresse/haddock3-ui@~0.3.0/dist/report.bundle.js" + if offline: + # TODO copy the bundle to the run_dir folder + bundle_url = "../../data/ui/report.bundle.js" if is_unclustered: - inner_html = _generate_unclustered_table_html(table_id, figure) + inner_html = _generate_unclustered_table_html(table_id, figure, bundle_url) else: - inner_html = _generate_clustered_table_html(table_id, figure) + inner_html = _generate_clustered_table_html(table_id, figure, bundle_url) else: # plots inner_json = figure.to_json() inner_html = create_html( @@ -1162,7 +1173,7 @@ def _generate_html_body(figures: list[Figure], offline: bool = False) -> str: return body -def report_generator(boxes, scatters, tables, step): +def report_generator(boxes, scatters, tables, step, offline): """ Create a figure include plots and tables. @@ -1177,6 +1188,8 @@ def report_generator(boxes, scatters, tables, step): list of scatter plots generated by scatter_plot_handler table: list a list including tables generated by clt_table_handler + offline: bool + If True, the HTML will be generated for offline use. """ figures = [tables] # Combine scatters @@ -1191,7 +1204,7 @@ def report_generator(boxes, scatters, tables, step): figures.append(report_plots_handler(boxes)) # Write everything to a html file - html_report = _generate_html_report(step, figures) + html_report = _generate_html_report(step, figures, offline) with open("report.html", "w", encoding="utf-8") as report: report.write(html_report) From 5794238df6f55663664a4c93dc33c1dd83e2efe7 Mon Sep 17 00:00:00 2001 From: sverhoeven Date: Fri, 20 Sep 2024 13:40:25 +0200 Subject: [PATCH 5/9] Copy haddock3-ui css and js file to here + copy them to run dir during analysis --- MANIFEST.in | 1 + setup.py | 2 +- src/haddock/libs/assets/__init__.py | 12 + src/haddock/libs/assets/index.css | 1 + src/haddock/libs/assets/report.bundle.js | 5263 ++++++++++++++++++++++ src/haddock/libs/libplots.py | 12 +- 6 files changed, 5288 insertions(+), 3 deletions(-) create mode 100644 src/haddock/libs/assets/__init__.py create mode 100644 src/haddock/libs/assets/index.css create mode 100644 src/haddock/libs/assets/report.bundle.js diff --git a/MANIFEST.in b/MANIFEST.in index 0dbcc6531a..294329d1f2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -36,3 +36,4 @@ recursive-include varia *.lua recursive-include varia *.md include src/haddock/bin/* +include src/haddock/libs/assets/* diff --git a/setup.py b/setup.py index c1bbe77d52..160f9388db 100644 --- a/setup.py +++ b/setup.py @@ -172,7 +172,7 @@ def read_description(*names, **kwargs) -> str: url="https://github.com/haddocking/haddock3", packages=find_packages("src"), package_dir={"": "src"}, - package_data={"haddock": ["bin/*"]}, + package_data={"haddock": ["bin/*"], "haddock.libs.assets": ["*.css", "*.js"]}, include_package_data=True, zip_safe=False, classifiers=[ diff --git a/src/haddock/libs/assets/__init__.py b/src/haddock/libs/assets/__init__.py new file mode 100644 index 0000000000..19442a12b5 --- /dev/null +++ b/src/haddock/libs/assets/__init__.py @@ -0,0 +1,12 @@ +"""Static assets + +Static assets for analysis report. + +Files where downloaded from +https://cdn.jsdelivr.net/npm/@i-vresse/haddock3-ui@~0.3.0/dist/index.css +and +https://cdn.jsdelivr.net/npm/@i-vresse/haddock3-ui@~0.3.0/dist/report.bundle.js +""" +import importlib.resources as importlib_resources + +haddock_ui_path = importlib_resources.files("haddock.libs.assets") diff --git a/src/haddock/libs/assets/index.css b/src/haddock/libs/assets/index.css new file mode 100644 index 0000000000..b0159a7ca2 --- /dev/null +++ b/src/haddock/libs/assets/index.css @@ -0,0 +1 @@ +/*! tailwindcss v3.4.6 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}:root{--background:0 0% 100%;--foreground:0 0% 3.9%;--card:0 0% 100%;--card-foreground:0 0% 3.9%;--popover:0 0% 100%;--popover-foreground:0 0% 3.9%;--primary:0 0% 9%;--primary-foreground:0 0% 98%;--secondary:0 0% 96.1%;--secondary-foreground:0 0% 9%;--muted:0 0% 96.1%;--muted-foreground:0 0% 45.1%;--accent:0 0% 96.1%;--accent-foreground:0 0% 9%;--destructive:0 84.2% 60.2%;--destructive-foreground:0 0% 98%;--border:0 0% 89.8%;--input:0 0% 89.8%;--ring:0 0% 3.9%;--radius:0.3rem;--chart-1:12 76% 61%;--chart-2:173 58% 39%;--chart-3:197 37% 24%;--chart-4:43 74% 66%;--chart-5:27 87% 67%}.dark{--background:0 0% 3.9%;--foreground:0 0% 98%;--card:0 0% 3.9%;--card-foreground:0 0% 98%;--popover:0 0% 3.9%;--popover-foreground:0 0% 98%;--primary:0 0% 98%;--primary-foreground:0 0% 9%;--secondary:0 0% 14.9%;--secondary-foreground:0 0% 98%;--muted:0 0% 14.9%;--muted-foreground:0 0% 63.9%;--accent:0 0% 14.9%;--accent-foreground:0 0% 98%;--destructive:0 62.8% 30.6%;--destructive-foreground:0 0% 98%;--border:0 0% 14.9%;--input:0 0% 14.9%;--ring:0 0% 83.1%;--chart-1:220 70% 50%;--chart-2:160 60% 45%;--chart-3:30 80% 55%;--chart-4:280 65% 60%;--chart-5:340 75% 55%}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.left-1\/2{left:50%}.right-4{right:1rem}.top-1\/2{top:50%}.top-2{top:.5rem}.z-10{z-index:10}.m-2{margin:.5rem}.inline-block{display:inline-block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-12{height:3rem}.h-3\/4{height:75%}.h-5{height:1.25rem}.h-9{height:2.25rem}.h-\[3rem\]{height:3rem}.h-\[4\.5rem\]{height:4.5rem}.h-auto{height:auto}.h-full{height:100%}.w-3\/4{width:75%}.w-4{width:1rem}.w-5{width:1.25rem}.w-full{width:100%}.caption-bottom{caption-side:bottom}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-pointer{cursor:pointer}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.justify-items-center{justify-items:center}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.overflow-hidden{overflow:hidden}.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-none{border-radius:0}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity))}.bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity))}.bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity))}.bg-green-400{--tw-bg-opacity:1;background-color:rgb(74 222 128/var(--tw-bg-opacity))}.bg-inherit{background-color:inherit}.bg-secondary{background-color:hsl(var(--secondary))}.bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}.p-4{padding:1rem}.px-4{padding-left:1rem;padding-right:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.pl-1{padding-left:.25rem}.pr-1{padding-right:.25rem}.text-left{text-align:left}.text-center{text-align:center}.text-start{text-align:start}.align-middle{vertical-align:middle}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-\[0\.5rem\]{font-size:.5rem}.text-\[0\.8rem\]{font-size:.8rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.text-inherit{color:inherit}.text-muted-foreground{color:hsl(var(--muted-foreground))}.text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.no-underline{text-decoration-line:none}.opacity-25{opacity:.25}.shadow-sm{--tw-shadow:0 1px 2px 0 #0000000d;--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.drop-shadow-xl{--tw-drop-shadow:drop-shadow(0 20px 13px #00000008) drop-shadow(0 8px 5px #00000014)}.drop-shadow-xl,.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover\:bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity))}.hover\:bg-gray-300:hover{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity))}.hover\:bg-gray-300\/80:hover{background-color:#d1d5dbcc}.hover\:bg-green-500:hover{--tw-bg-opacity:1;background-color:rgb(34 197 94/var(--tw-bg-opacity))}.hover\:bg-muted\/50:hover{background-color:hsl(var(--muted)/.5)}.hover\:bg-secondary:hover{background-color:hsl(var(--secondary))}.hover\:text-black:hover{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.hover\:text-secondary-foreground:hover{color:hsl(var(--secondary-foreground))}.hover\:underline:hover{text-decoration-line:underline}.focus-visible\:outline-none:focus-visible{outline:2px solid #0000;outline-offset:2px}.focus-visible\:ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\:ring-ring:focus-visible{--tw-ring-color:hsl(var(--ring))}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:opacity-50:disabled{opacity:.5}.group:hover .group-hover\:opacity-100{opacity:1}.dark\:bg-green-700:where(.dark,.dark *){--tw-bg-opacity:1;background-color:rgb(21 128 61/var(--tw-bg-opacity))}.dark\:bg-inherit:where(.dark,.dark *){background-color:inherit}.dark\:bg-secondary-foreground:where(.dark,.dark *){background-color:hsl(var(--secondary-foreground))}.dark\:bg-yellow-700:where(.dark,.dark *){--tw-bg-opacity:1;background-color:rgb(161 98 7/var(--tw-bg-opacity))}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-width:0} \ No newline at end of file diff --git a/src/haddock/libs/assets/report.bundle.js b/src/haddock/libs/assets/report.bundle.js new file mode 100644 index 0000000000..0c133b5402 --- /dev/null +++ b/src/haddock/libs/assets/report.bundle.js @@ -0,0 +1,5263 @@ +var oR=Object.create;var zw=Object.defineProperty;var aR=Object.getOwnPropertyDescriptor;var lR=Object.getOwnPropertyNames;var cR=Object.getPrototypeOf,uR=Object.prototype.hasOwnProperty;var hr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var hR=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of lR(e))!uR.call(n,r)&&r!==t&&zw(n,r,{get:()=>e[r],enumerable:!(i=aR(e,r))||i.enumerable});return n};var Dn=(n,e,t)=>(t=n!=null?oR(cR(n)):{},hR(e||!n||!n.__esModule?zw(t,"default",{value:n,enumerable:!0}):t,n));var Jw=hr(Ft=>{"use strict";var _u=Symbol.for("react.element"),dR=Symbol.for("react.portal"),fR=Symbol.for("react.fragment"),pR=Symbol.for("react.strict_mode"),mR=Symbol.for("react.profiler"),gR=Symbol.for("react.provider"),yR=Symbol.for("react.context"),_R=Symbol.for("react.forward_ref"),vR=Symbol.for("react.suspense"),xR=Symbol.for("react.memo"),bR=Symbol.for("react.lazy"),Vw=Symbol.iterator;function wR(n){return n===null||typeof n!="object"?null:(n=Vw&&n[Vw]||n["@@iterator"],typeof n=="function"?n:null)}var $w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ww=Object.assign,jw={};function dl(n,e,t){this.props=n,this.context=e,this.refs=jw,this.updater=t||$w}dl.prototype.isReactComponent={};dl.prototype.setState=function(n,e){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,e,"setState")};dl.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function Xw(){}Xw.prototype=dl.prototype;function U0(n,e,t){this.props=n,this.context=e,this.refs=jw,this.updater=t||$w}var z0=U0.prototype=new Xw;z0.constructor=U0;Ww(z0,dl.prototype);z0.isPureReactComponent=!0;var Hw=Array.isArray,qw=Object.prototype.hasOwnProperty,V0={current:null},Yw={key:!0,ref:!0,__self:!0,__source:!0};function Zw(n,e,t){var i,r={},s=null,o=null;if(e!=null)for(i in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)qw.call(e,i)&&!Yw.hasOwnProperty(i)&&(r[i]=e[i]);var a=arguments.length-2;if(a===1)r.children=t;else if(1{"use strict";Qw.exports=Jw()});var cS=hr(nn=>{"use strict";function j0(n,e){var t=n.length;n.push(e);e:for(;0>>1,r=n[i];if(0>>1;izd(a,t))lzd(c,a)?(n[i]=c,n[l]=t,i=l):(n[i]=a,n[o]=t,i=o);else if(lzd(c,t))n[i]=c,n[l]=t,i=l;else break e}}return e}function zd(n,e){var t=n.sortIndex-e.sortIndex;return t!==0?t:n.id-e.id}typeof performance=="object"&&typeof performance.now=="function"?(eS=performance,nn.unstable_now=function(){return eS.now()}):(G0=Date,tS=G0.now(),nn.unstable_now=function(){return G0.now()-tS});var eS,G0,tS,is=[],fo=[],ER=1,dr=null,di=3,Gd=!1,ua=!1,xu=!1,rS=typeof setTimeout=="function"?setTimeout:null,sS=typeof clearTimeout=="function"?clearTimeout:null,nS=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function X0(n){for(var e=Rr(fo);e!==null;){if(e.callback===null)Hd(fo);else if(e.startTime<=n)Hd(fo),e.sortIndex=e.expirationTime,j0(is,e);else break;e=Rr(fo)}}function q0(n){if(xu=!1,X0(n),!ua)if(Rr(is)!==null)ua=!0,Z0(Y0);else{var e=Rr(fo);e!==null&&K0(q0,e.startTime-n)}}function Y0(n,e){ua=!1,xu&&(xu=!1,sS(bu),bu=-1),Gd=!0;var t=di;try{for(X0(e),dr=Rr(is);dr!==null&&(!(dr.expirationTime>e)||n&&!lS());){var i=dr.callback;if(typeof i=="function"){dr.callback=null,di=dr.priorityLevel;var r=i(dr.expirationTime<=e);e=nn.unstable_now(),typeof r=="function"?dr.callback=r:dr===Rr(is)&&Hd(is),X0(e)}else Hd(is);dr=Rr(is)}if(dr!==null)var s=!0;else{var o=Rr(fo);o!==null&&K0(q0,o.startTime-e),s=!1}return s}finally{dr=null,di=t,Gd=!1}}var $d=!1,Vd=null,bu=-1,oS=5,aS=-1;function lS(){return!(nn.unstable_now()-aSn||125i?(n.sortIndex=t,j0(fo,n),Rr(is)===null&&n===Rr(fo)&&(xu?(sS(bu),bu=-1):xu=!0,K0(q0,t-i))):(n.sortIndex=r,j0(is,n),ua||Gd||(ua=!0,Z0(Y0))),n};nn.unstable_shouldYield=lS;nn.unstable_wrapCallback=function(n){var e=di;return function(){var t=di;di=e;try{return n.apply(this,arguments)}finally{di=t}}}});var hS=hr((aV,uS)=>{"use strict";uS.exports=cS()});var mM=hr(Ki=>{"use strict";var TR=fl(),Yi=hS();function Ze(n){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+n,t=1;t"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),x1=Object.prototype.hasOwnProperty,PR=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,dS={},fS={};function IR(n){return x1.call(fS,n)?!0:x1.call(dS,n)?!1:PR.test(n)?fS[n]=!0:(dS[n]=!0,!1)}function RR(n,e,t,i){if(t!==null&&t.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return i?!1:t!==null?!t.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function kR(n,e,t,i){if(e===null||typeof e>"u"||RR(n,e,t,i))return!0;if(i)return!1;if(t!==null)switch(t.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Mi(n,e,t,i,r,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=i,this.attributeNamespace=r,this.mustUseProperty=t,this.propertyName=n,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var oi={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){oi[n]=new Mi(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];oi[e]=new Mi(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){oi[n]=new Mi(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){oi[n]=new Mi(n,2,!1,n,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){oi[n]=new Mi(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){oi[n]=new Mi(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){oi[n]=new Mi(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){oi[n]=new Mi(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){oi[n]=new Mi(n,5,!1,n.toLowerCase(),null,!1,!1)});var dy=/[\-:]([a-z])/g;function fy(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var e=n.replace(dy,fy);oi[e]=new Mi(e,1,!1,n,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var e=n.replace(dy,fy);oi[e]=new Mi(e,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(n){var e=n.replace(dy,fy);oi[e]=new Mi(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){oi[n]=new Mi(n,1,!1,n.toLowerCase(),null,!1,!1)});oi.xlinkHref=new Mi("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){oi[n]=new Mi(n,1,!1,n.toLowerCase(),null,!0,!0)});function py(n,e,t,i){var r=oi.hasOwnProperty(e)?oi[e]:null;(r!==null?r.type!==0:i||!(2a||r[o]!==s[a]){var l=` +`+r[o].replace(" at new "," at ");return n.displayName&&l.includes("")&&(l=l.replace("",n.displayName)),l}while(1<=o&&0<=a);break}}}finally{Q0=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?Iu(n):""}function LR(n){switch(n.tag){case 5:return Iu(n.type);case 16:return Iu("Lazy");case 13:return Iu("Suspense");case 19:return Iu("SuspenseList");case 0:case 2:case 15:return n=e1(n.type,!1),n;case 11:return n=e1(n.type.render,!1),n;case 1:return n=e1(n.type,!0),n;default:return""}}function A1(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case yl:return"Fragment";case gl:return"Portal";case b1:return"Profiler";case my:return"StrictMode";case w1:return"Suspense";case S1:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case x3:return(n.displayName||"Context")+".Consumer";case v3:return(n._context.displayName||"Context")+".Provider";case gy:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case yy:return e=n.displayName||null,e!==null?e:A1(n.type)||"Memo";case mo:e=n._payload,n=n._init;try{return A1(n(e))}catch{}}return null}function DR(n){var e=n.type;switch(n.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=e.render,n=n.displayName||n.name||"",e.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return A1(e);case 8:return e===my?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Po(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function w3(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function NR(n){var e=w3(n)?"checked":"value",t=Object.getOwnPropertyDescriptor(n.constructor.prototype,e),i=""+n[e];if(!n.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var r=t.get,s=t.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return r.call(this)},set:function(o){i=""+o,s.call(this,o)}}),Object.defineProperty(n,e,{enumerable:t.enumerable}),{getValue:function(){return i},setValue:function(o){i=""+o},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function jd(n){n._valueTracker||(n._valueTracker=NR(n))}function S3(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),i="";return n&&(i=w3(n)?n.checked?"true":"false":n.value),n=i,n!==t?(e.setValue(n),!0):!1}function bf(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function M1(n,e){var t=e.checked;return An({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function mS(n,e){var t=e.defaultValue==null?"":e.defaultValue,i=e.checked!=null?e.checked:e.defaultChecked;t=Po(e.value!=null?e.value:t),n._wrapperState={initialChecked:i,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function A3(n,e){e=e.checked,e!=null&&py(n,"checked",e,!1)}function C1(n,e){A3(n,e);var t=Po(e.value),i=e.type;if(t!=null)i==="number"?(t===0&&n.value===""||n.value!=t)&&(n.value=""+t):n.value!==""+t&&(n.value=""+t);else if(i==="submit"||i==="reset"){n.removeAttribute("value");return}e.hasOwnProperty("value")?E1(n,e.type,t):e.hasOwnProperty("defaultValue")&&E1(n,e.type,Po(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function gS(n,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var i=e.type;if(!(i!=="submit"&&i!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+n._wrapperState.initialValue,t||e===n.value||(n.value=e),n.defaultValue=e}t=n.name,t!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,t!==""&&(n.name=t)}function E1(n,e,t){(e!=="number"||bf(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var Ru=Array.isArray;function Tl(n,e,t,i){if(n=n.options,e){e={};for(var r=0;r"+e.valueOf().toString()+"",e=Xd.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function $u(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var Du={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},FR=["Webkit","ms","Moz","O"];Object.keys(Du).forEach(function(n){FR.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),Du[e]=Du[n]})});function T3(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||Du.hasOwnProperty(n)&&Du[n]?(""+e).trim():e+"px"}function P3(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var i=t.indexOf("--")===0,r=T3(t,e[t],i);t==="float"&&(t="cssFloat"),i?n.setProperty(t,r):n[t]=r}}var OR=An({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function I1(n,e){if(e){if(OR[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(Ze(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(Ze(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(Ze(61))}if(e.style!=null&&typeof e.style!="object")throw Error(Ze(62))}}function R1(n,e){if(n.indexOf("-")===-1)return typeof e.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var k1=null;function _y(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var L1=null,Pl=null,Il=null;function vS(n){if(n=lh(n)){if(typeof L1!="function")throw Error(Ze(280));var e=n.stateNode;e&&(e=Yf(e),L1(n.stateNode,n.type,e))}}function I3(n){Pl?Il?Il.push(n):Il=[n]:Pl=n}function R3(){if(Pl){var n=Pl,e=Il;if(Il=Pl=null,vS(n),e)for(n=0;n>>=0,n===0?32:31-(qR(n)/YR|0)|0}var qd=64,Yd=4194304;function ku(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Mf(n,e){var t=n.pendingLanes;if(t===0)return 0;var i=0,r=n.suspendedLanes,s=n.pingedLanes,o=t&268435455;if(o!==0){var a=o&~r;a!==0?i=ku(a):(s&=o,s!==0&&(i=ku(s)))}else o=t&~r,o!==0?i=ku(o):s!==0&&(i=ku(s));if(i===0)return 0;if(e!==0&&e!==i&&!(e&r)&&(r=i&-i,s=e&-e,r>=s||r===16&&(s&4194240)!==0))return e;if(i&4&&(i|=t&16),e=n.entangledLanes,e!==0)for(n=n.entanglements,e&=i;0t;t++)e.push(n);return e}function oh(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-Fr(e),n[e]=t}function QR(n,e){var t=n.pendingLanes&~e;n.pendingLanes=e,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=e,n.mutableReadLanes&=e,n.entangledLanes&=e,e=n.entanglements;var i=n.eventTimes;for(n=n.expirationTimes;0=Fu),TS=" ",PS=!1;function K3(n,e){switch(n){case"keyup":return Ek.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function J3(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var _l=!1;function Pk(n,e){switch(n){case"compositionend":return J3(e);case"keypress":return e.which!==32?null:(PS=!0,TS);case"textInput":return n=e.data,n===TS&&PS?null:n;default:return null}}function Ik(n,e){if(_l)return n==="compositionend"||!Cy&&K3(n,e)?(n=Y3(),df=Sy=vo=null,_l=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:t,offset:e-n};n=i}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=kS(t)}}function nA(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?nA(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function iA(){for(var n=window,e=bf();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=bf(n.document)}return e}function Ey(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}function Uk(n){var e=iA(),t=n.focusedElem,i=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&nA(t.ownerDocument.documentElement,t)){if(i!==null&&Ey(t)){if(e=i.start,n=i.end,n===void 0&&(n=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(n,t.value.length);else if(n=(e=t.ownerDocument||document)&&e.defaultView||window,n.getSelection){n=n.getSelection();var r=t.textContent.length,s=Math.min(i.start,r);i=i.end===void 0?s:Math.min(i.end,r),!n.extend&&s>i&&(r=i,i=s,s=r),r=LS(t,s);var o=LS(t,i);r&&o&&(n.rangeCount!==1||n.anchorNode!==r.node||n.anchorOffset!==r.offset||n.focusNode!==o.node||n.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(r.node,r.offset),n.removeAllRanges(),s>i?(n.addRange(e),n.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),n.addRange(e)))}}for(e=[],n=t;n=n.parentNode;)n.nodeType===1&&e.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t=document.documentMode,vl=null,U1=null,Bu=null,z1=!1;function DS(n,e,t){var i=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;z1||vl==null||vl!==bf(i)||(i=vl,"selectionStart"in i&&Ey(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Bu&&Zu(Bu,i)||(Bu=i,i=Tf(U1,"onSelect"),0wl||(n.current=j1[wl],j1[wl]=null,wl--)}function rn(n,e){wl++,j1[wl]=n.current,n.current=e}var Io={},gi=ko(Io),Ni=ko(!1),_a=Io;function Nl(n,e){var t=n.type.contextTypes;if(!t)return Io;var i=n.stateNode;if(i&&i.__reactInternalMemoizedUnmaskedChildContext===e)return i.__reactInternalMemoizedMaskedChildContext;var r={},s;for(s in t)r[s]=e[s];return i&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=e,n.__reactInternalMemoizedMaskedChildContext=r),r}function Fi(n){return n=n.childContextTypes,n!=null}function If(){ln(Ni),ln(gi)}function GS(n,e,t){if(gi.current!==Io)throw Error(Ze(168));rn(gi,e),rn(Ni,t)}function dA(n,e,t){var i=n.stateNode;if(e=e.childContextTypes,typeof i.getChildContext!="function")return t;i=i.getChildContext();for(var r in i)if(!(r in e))throw Error(Ze(108,DR(n)||"Unknown",r));return An({},t,i)}function Rf(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Io,_a=gi.current,rn(gi,n),rn(Ni,Ni.current),!0}function $S(n,e,t){var i=n.stateNode;if(!i)throw Error(Ze(169));t?(n=dA(n,e,_a),i.__reactInternalMemoizedMergedChildContext=n,ln(Ni),ln(gi),rn(gi,n)):ln(Ni),rn(Ni,t)}var Ps=null,Zf=!1,h1=!1;function fA(n){Ps===null?Ps=[n]:Ps.push(n)}function Yk(n){Zf=!0,fA(n)}function Lo(){if(!h1&&Ps!==null){h1=!0;var n=0,e=Zt;try{var t=Ps;for(Zt=1;n>=o,r-=o,Is=1<<32-Fr(e)+r|t<A?(M=w,w=null):M=w.sibling;var T=f(g,w,h[A],v);if(T===null){w===null&&(w=M);break}n&&w&&T.alternate===null&&e(g,w),b=s(T,b,A),x===null?S=T:x.sibling=T,x=T,w=M}if(A===h.length)return t(g,w),pn&&ha(g,A),S;if(w===null){for(;AA?(M=w,w=null):M=w.sibling;var R=f(g,w,T.value,v);if(R===null){w===null&&(w=M);break}n&&w&&R.alternate===null&&e(g,w),b=s(R,b,A),x===null?S=R:x.sibling=R,x=R,w=M}if(T.done)return t(g,w),pn&&ha(g,A),S;if(w===null){for(;!T.done;A++,T=h.next())T=d(g,T.value,v),T!==null&&(b=s(T,b,A),x===null?S=T:x.sibling=T,x=T);return pn&&ha(g,A),S}for(w=i(g,w);!T.done;A++,T=h.next())T=m(w,g,A,T.value,v),T!==null&&(n&&T.alternate!==null&&w.delete(T.key===null?A:T.key),b=s(T,b,A),x===null?S=T:x.sibling=T,x=T);return n&&w.forEach(function(C){return e(g,C)}),pn&&ha(g,A),S}function y(g,b,h,v){if(typeof h=="object"&&h!==null&&h.type===yl&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case Wd:e:{for(var S=h.key,x=b;x!==null;){if(x.key===S){if(S=h.type,S===yl){if(x.tag===7){t(g,x.sibling),b=r(x,h.props.children),b.return=g,g=b;break e}}else if(x.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===mo&&XS(S)===x.type){t(g,x.sibling),b=r(x,h.props),b.ref=Cu(g,x,h),b.return=g,g=b;break e}t(g,x);break}else e(g,x);x=x.sibling}h.type===yl?(b=ya(h.props.children,g.mode,v,h.key),b.return=g,g=b):(v=xf(h.type,h.key,h.props,null,g.mode,v),v.ref=Cu(g,b,h),v.return=g,g=v)}return o(g);case gl:e:{for(x=h.key;b!==null;){if(b.key===x)if(b.tag===4&&b.stateNode.containerInfo===h.containerInfo&&b.stateNode.implementation===h.implementation){t(g,b.sibling),b=r(b,h.children||[]),b.return=g,g=b;break e}else{t(g,b);break}else e(g,b);b=b.sibling}b=v1(h,g.mode,v),b.return=g,g=b}return o(g);case mo:return x=h._init,y(g,b,x(h._payload),v)}if(Ru(h))return p(g,b,h,v);if(wu(h))return _(g,b,h,v);af(g,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,b!==null&&b.tag===6?(t(g,b.sibling),b=r(b,h),b.return=g,g=b):(t(g,b),b=_1(h,g.mode,v),b.return=g,g=b),o(g)):t(g,b)}return y}var Ol=yA(!0),_A=yA(!1),Df=ko(null),Nf=null,Ml=null,Ry=null;function ky(){Ry=Ml=Nf=null}function Ly(n){var e=Df.current;ln(Df),n._currentValue=e}function Y1(n,e,t){for(;n!==null;){var i=n.alternate;if((n.childLanes&e)!==e?(n.childLanes|=e,i!==null&&(i.childLanes|=e)):i!==null&&(i.childLanes&e)!==e&&(i.childLanes|=e),n===t)break;n=n.return}}function kl(n,e){Nf=n,Ry=Ml=null,n=n.dependencies,n!==null&&n.firstContext!==null&&(n.lanes&e&&(Di=!0),n.firstContext=null)}function yr(n){var e=n._currentValue;if(Ry!==n)if(n={context:n,memoizedValue:e,next:null},Ml===null){if(Nf===null)throw Error(Ze(308));Ml=n,Nf.dependencies={lanes:0,firstContext:n}}else Ml=Ml.next=n;return e}var pa=null;function Dy(n){pa===null?pa=[n]:pa.push(n)}function vA(n,e,t,i){var r=e.interleaved;return r===null?(t.next=t,Dy(e)):(t.next=r.next,r.next=t),e.interleaved=t,Ns(n,i)}function Ns(n,e){n.lanes|=e;var t=n.alternate;for(t!==null&&(t.lanes|=e),t=n,n=n.return;n!==null;)n.childLanes|=e,t=n.alternate,t!==null&&(t.childLanes|=e),t=n,n=n.return;return t.tag===3?t.stateNode:null}var go=!1;function Ny(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function xA(n,e){n=n.updateQueue,e.updateQueue===n&&(e.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function ks(n,e){return{eventTime:n,lane:e,tag:0,payload:null,callback:null,next:null}}function Mo(n,e,t){var i=n.updateQueue;if(i===null)return null;if(i=i.shared,Vt&2){var r=i.pending;return r===null?e.next=e:(e.next=r.next,r.next=e),i.pending=e,Ns(n,t)}return r=i.interleaved,r===null?(e.next=e,Dy(i)):(e.next=r.next,r.next=e),i.interleaved=e,Ns(n,t)}function pf(n,e,t){if(e=e.updateQueue,e!==null&&(e=e.shared,(t&4194240)!==0)){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,xy(n,t)}}function qS(n,e){var t=n.updateQueue,i=n.alternate;if(i!==null&&(i=i.updateQueue,t===i)){var r=null,s=null;if(t=t.firstBaseUpdate,t!==null){do{var o={eventTime:t.eventTime,lane:t.lane,tag:t.tag,payload:t.payload,callback:t.callback,next:null};s===null?r=s=o:s=s.next=o,t=t.next}while(t!==null);s===null?r=s=e:s=s.next=e}else r=s=e;t={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:s,shared:i.shared,effects:i.effects},n.updateQueue=t;return}n=t.lastBaseUpdate,n===null?t.firstBaseUpdate=e:n.next=e,t.lastBaseUpdate=e}function Ff(n,e,t,i){var r=n.updateQueue;go=!1;var s=r.firstBaseUpdate,o=r.lastBaseUpdate,a=r.shared.pending;if(a!==null){r.shared.pending=null;var l=a,c=l.next;l.next=null,o===null?s=c:o.next=c,o=l;var u=n.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==o&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(s!==null){var d=r.baseState;o=0,u=c=l=null,a=s;do{var f=a.lane,m=a.eventTime;if((i&f)===f){u!==null&&(u=u.next={eventTime:m,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var p=n,_=a;switch(f=e,m=t,_.tag){case 1:if(p=_.payload,typeof p=="function"){d=p.call(m,d,f);break e}d=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=_.payload,f=typeof p=="function"?p.call(m,d,f):p,f==null)break e;d=An({},d,f);break e;case 2:go=!0}}a.callback!==null&&a.lane!==0&&(n.flags|=64,f=r.effects,f===null?r.effects=[a]:f.push(a))}else m={eventTime:m,lane:f,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(c=u=m,l=d):u=u.next=m,o|=f;if(a=a.next,a===null){if(a=r.shared.pending,a===null)break;f=a,a=f.next,f.next=null,r.lastBaseUpdate=f,r.shared.pending=null}}while(!0);if(u===null&&(l=d),r.baseState=l,r.firstBaseUpdate=c,r.lastBaseUpdate=u,e=r.shared.interleaved,e!==null){r=e;do o|=r.lane,r=r.next;while(r!==e)}else s===null&&(r.shared.lanes=0);ba|=o,n.lanes=o,n.memoizedState=d}}function YS(n,e,t){if(n=e.effects,e.effects=null,n!==null)for(e=0;et?t:4,n(!0);var i=f1.transition;f1.transition={};try{n(!1),e()}finally{Zt=t,f1.transition=i}}function OA(){return _r().memoizedState}function Qk(n,e,t){var i=Eo(n);if(t={lane:i,action:t,hasEagerState:!1,eagerState:null,next:null},BA(n))UA(e,t);else if(t=vA(n,e,t,i),t!==null){var r=Ai();Or(t,n,i,r),zA(t,e,i)}}function eL(n,e,t){var i=Eo(n),r={lane:i,action:t,hasEagerState:!1,eagerState:null,next:null};if(BA(n))UA(e,r);else{var s=n.alternate;if(n.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,t);if(r.hasEagerState=!0,r.eagerState=a,Br(a,o)){var l=e.interleaved;l===null?(r.next=r,Dy(e)):(r.next=l.next,l.next=r),e.interleaved=r;return}}catch{}finally{}t=vA(n,e,r,i),t!==null&&(r=Ai(),Or(t,n,i,r),zA(t,e,i))}}function BA(n){var e=n.alternate;return n===Sn||e!==null&&e===Sn}function UA(n,e){Uu=Bf=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function zA(n,e,t){if(t&4194240){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,xy(n,t)}}var Uf={readContext:yr,useCallback:fi,useContext:fi,useEffect:fi,useImperativeHandle:fi,useInsertionEffect:fi,useLayoutEffect:fi,useMemo:fi,useReducer:fi,useRef:fi,useState:fi,useDebugValue:fi,useDeferredValue:fi,useTransition:fi,useMutableSource:fi,useSyncExternalStore:fi,useId:fi,unstable_isNewReconciler:!1},tL={readContext:yr,useCallback:function(n,e){return ss().memoizedState=[n,e===void 0?null:e],n},useContext:yr,useEffect:KS,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,gf(4194308,4,kA.bind(null,e,n),t)},useLayoutEffect:function(n,e){return gf(4194308,4,n,e)},useInsertionEffect:function(n,e){return gf(4,2,n,e)},useMemo:function(n,e){var t=ss();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var i=ss();return e=t!==void 0?t(e):e,i.memoizedState=i.baseState=e,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:e},i.queue=n,n=n.dispatch=Qk.bind(null,Sn,n),[i.memoizedState,n]},useRef:function(n){var e=ss();return n={current:n},e.memoizedState=n},useState:ZS,useDebugValue:Gy,useDeferredValue:function(n){return ss().memoizedState=n},useTransition:function(){var n=ZS(!1),e=n[0];return n=Jk.bind(null,n[1]),ss().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var i=Sn,r=ss();if(pn){if(t===void 0)throw Error(Ze(407));t=t()}else{if(t=e(),Qn===null)throw Error(Ze(349));xa&30||AA(i,e,t)}r.memoizedState=t;var s={value:t,getSnapshot:e};return r.queue=s,KS(CA.bind(null,i,s,n),[n]),i.flags|=2048,rh(9,MA.bind(null,i,s,t,e),void 0,null),t},useId:function(){var n=ss(),e=Qn.identifierPrefix;if(pn){var t=Rs,i=Is;t=(i&~(1<<32-Fr(i)-1)).toString(32)+t,e=":"+e+"R"+t,t=nh++,0<\/script>",n=n.removeChild(n.firstChild)):typeof i.is=="string"?n=o.createElement(t,{is:i.is}):(n=o.createElement(t),t==="select"&&(o=n,i.multiple?o.multiple=!0:i.size&&(o.size=i.size))):n=o.createElementNS(n,t),n[os]=e,n[Qu]=i,ZA(n,e,!1,!1),e.stateNode=n;e:{switch(o=R1(t,i),t){case"dialog":an("cancel",n),an("close",n),r=i;break;case"iframe":case"object":case"embed":an("load",n),r=i;break;case"video":case"audio":for(r=0;rzl&&(e.flags|=128,i=!0,Eu(s,!1),e.lanes=4194304)}else{if(!i)if(n=Of(o),n!==null){if(e.flags|=128,i=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Eu(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!pn)return pi(e),null}else 2*Nn()-s.renderingStartTime>zl&&t!==1073741824&&(e.flags|=128,i=!0,Eu(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(t=s.last,t!==null?t.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Nn(),e.sibling=null,t=wn.current,rn(wn,i?t&1|2:t&1),e):(pi(e),null);case 22:case 23:return Yy(),i=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==i&&(e.flags|=8192),i&&e.mode&1?ji&1073741824&&(pi(e),e.subtreeFlags&6&&(e.flags|=8192)):pi(e),null;case 24:return null;case 25:return null}throw Error(Ze(156,e.tag))}function cL(n,e){switch(Py(e),e.tag){case 1:return Fi(e.type)&&If(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return Bl(),ln(Ni),ln(gi),By(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return Oy(e),null;case 13:if(ln(wn),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(Ze(340));Fl()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return ln(wn),null;case 4:return Bl(),null;case 10:return Ly(e.type._context),null;case 22:case 23:return Yy(),null;case 24:return null;default:return null}}var cf=!1,mi=!1,uL=typeof WeakSet=="function"?WeakSet:Set,ut=null;function Cl(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(i){In(n,e,i)}else t.current=null}function ry(n,e,t){try{t()}catch(i){In(n,e,i)}}var l3=!1;function hL(n,e){if(V1=Cf,n=iA(),Ey(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var i=t.getSelection&&t.getSelection();if(i&&i.rangeCount!==0){t=i.anchorNode;var r=i.anchorOffset,s=i.focusNode;i=i.focusOffset;try{t.nodeType,s.nodeType}catch{t=null;break e}var o=0,a=-1,l=-1,c=0,u=0,d=n,f=null;t:for(;;){for(var m;d!==t||r!==0&&d.nodeType!==3||(a=o+r),d!==s||i!==0&&d.nodeType!==3||(l=o+i),d.nodeType===3&&(o+=d.nodeValue.length),(m=d.firstChild)!==null;)f=d,d=m;for(;;){if(d===n)break t;if(f===t&&++c===r&&(a=o),f===s&&++u===i&&(l=o),(m=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=m}t=a===-1||l===-1?null:{start:a,end:l}}else t=null}t=t||{start:0,end:0}}else t=null;for(H1={focusedElem:n,selectionRange:t},Cf=!1,ut=e;ut!==null;)if(e=ut,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,ut=n;else for(;ut!==null;){e=ut;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var _=p.memoizedProps,y=p.memoizedState,g=e.stateNode,b=g.getSnapshotBeforeUpdate(e.elementType===e.type?_:Lr(e.type,_),y);g.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var h=e.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ze(163))}}catch(v){In(e,e.return,v)}if(n=e.sibling,n!==null){n.return=e.return,ut=n;break}ut=e.return}return p=l3,l3=!1,p}function zu(n,e,t){var i=e.updateQueue;if(i=i!==null?i.lastEffect:null,i!==null){var r=i=i.next;do{if((r.tag&n)===n){var s=r.destroy;r.destroy=void 0,s!==void 0&&ry(e,t,s)}r=r.next}while(r!==i)}}function Qf(n,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&n)===n){var i=t.create;t.destroy=i()}t=t.next}while(t!==e)}}function sy(n){var e=n.ref;if(e!==null){var t=n.stateNode;switch(n.tag){case 5:n=t;break;default:n=t}typeof e=="function"?e(n):e.current=n}}function QA(n){var e=n.alternate;e!==null&&(n.alternate=null,QA(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[os],delete e[Qu],delete e[W1],delete e[Xk],delete e[qk])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function eM(n){return n.tag===5||n.tag===3||n.tag===4}function c3(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||eM(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function oy(n,e,t){var i=n.tag;if(i===5||i===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=Pf));else if(i!==4&&(n=n.child,n!==null))for(oy(n,e,t),n=n.sibling;n!==null;)oy(n,e,t),n=n.sibling}function ay(n,e,t){var i=n.tag;if(i===5||i===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(i!==4&&(n=n.child,n!==null))for(ay(n,e,t),n=n.sibling;n!==null;)ay(n,e,t),n=n.sibling}var ri=null,Dr=!1;function po(n,e,t){for(t=t.child;t!==null;)tM(n,e,t),t=t.sibling}function tM(n,e,t){if(as&&typeof as.onCommitFiberUnmount=="function")try{as.onCommitFiberUnmount(Wf,t)}catch{}switch(t.tag){case 5:mi||Cl(t,e);case 6:var i=ri,r=Dr;ri=null,po(n,e,t),ri=i,Dr=r,ri!==null&&(Dr?(n=ri,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):ri.removeChild(t.stateNode));break;case 18:ri!==null&&(Dr?(n=ri,t=t.stateNode,n.nodeType===8?u1(n.parentNode,t):n.nodeType===1&&u1(n,t),qu(n)):u1(ri,t.stateNode));break;case 4:i=ri,r=Dr,ri=t.stateNode.containerInfo,Dr=!0,po(n,e,t),ri=i,Dr=r;break;case 0:case 11:case 14:case 15:if(!mi&&(i=t.updateQueue,i!==null&&(i=i.lastEffect,i!==null))){r=i=i.next;do{var s=r,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&ry(t,e,o),r=r.next}while(r!==i)}po(n,e,t);break;case 1:if(!mi&&(Cl(t,e),i=t.stateNode,typeof i.componentWillUnmount=="function"))try{i.props=t.memoizedProps,i.state=t.memoizedState,i.componentWillUnmount()}catch(a){In(t,e,a)}po(n,e,t);break;case 21:po(n,e,t);break;case 22:t.mode&1?(mi=(i=mi)||t.memoizedState!==null,po(n,e,t),mi=i):po(n,e,t);break;default:po(n,e,t)}}function u3(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new uL),e.forEach(function(i){var r=xL.bind(null,n,i);t.has(i)||(t.add(i),i.then(r,r))})}}function kr(n,e){var t=e.deletions;if(t!==null)for(var i=0;ir&&(r=o),i&=~s}if(i=r,i=Nn()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*fL(i/1960))-i,10n?16:n,xo===null)var i=!1;else{if(n=xo,xo=null,Hf=0,Vt&6)throw Error(Ze(331));var r=Vt;for(Vt|=4,ut=n.current;ut!==null;){var s=ut,o=s.child;if(ut.flags&16){var a=s.deletions;if(a!==null){for(var l=0;lNn()-Xy?ga(n,0):jy|=t),Oi(n,e)}function cM(n,e){e===0&&(n.mode&1?(e=Yd,Yd<<=1,!(Yd&130023424)&&(Yd=4194304)):e=1);var t=Ai();n=Ns(n,e),n!==null&&(oh(n,e,t),Oi(n,t))}function vL(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),cM(n,t)}function xL(n,e){var t=0;switch(n.tag){case 13:var i=n.stateNode,r=n.memoizedState;r!==null&&(t=r.retryLane);break;case 19:i=n.stateNode;break;default:throw Error(Ze(314))}i!==null&&i.delete(e),cM(n,t)}var uM;uM=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||Ni.current)Di=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return Di=!1,aL(n,e,t);Di=!!(n.flags&131072)}else Di=!1,pn&&e.flags&1048576&&pA(e,Lf,e.index);switch(e.lanes=0,e.tag){case 2:var i=e.type;yf(n,e),n=e.pendingProps;var r=Nl(e,gi.current);kl(e,t),r=zy(null,e,i,n,r,t);var s=Vy();return e.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Fi(i)?(s=!0,Rf(e)):s=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,Ny(e),r.updater=Jf,e.stateNode=r,r._reactInternals=e,K1(e,i,n,t),e=ey(null,e,i,!0,s,t)):(e.tag=0,pn&&s&&Ty(e),Si(null,e,r,t),e=e.child),e;case 16:i=e.elementType;e:{switch(yf(n,e),n=e.pendingProps,r=i._init,i=r(i._payload),e.type=i,r=e.tag=wL(i),n=Lr(i,n),r){case 0:e=Q1(null,e,i,n,t);break e;case 1:e=s3(null,e,i,n,t);break e;case 11:e=i3(null,e,i,n,t);break e;case 14:e=r3(null,e,i,Lr(i.type,n),t);break e}throw Error(Ze(306,i,""))}return e;case 0:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Lr(i,r),Q1(n,e,i,r,t);case 1:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Lr(i,r),s3(n,e,i,r,t);case 3:e:{if(XA(e),n===null)throw Error(Ze(387));i=e.pendingProps,s=e.memoizedState,r=s.element,xA(n,e),Ff(e,i,null,t);var o=e.memoizedState;if(i=o.element,s.isDehydrated)if(s={element:i,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){r=Ul(Error(Ze(423)),e),e=o3(n,e,i,t,r);break e}else if(i!==r){r=Ul(Error(Ze(424)),e),e=o3(n,e,i,t,r);break e}else for(Xi=Ao(e.stateNode.containerInfo.firstChild),qi=e,pn=!0,Nr=null,t=_A(e,null,i,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(Fl(),i===r){e=Fs(n,e,t);break e}Si(n,e,i,t)}e=e.child}return e;case 5:return bA(e),n===null&&q1(e),i=e.type,r=e.pendingProps,s=n!==null?n.memoizedProps:null,o=r.children,G1(i,r)?o=null:s!==null&&G1(i,s)&&(e.flags|=32),jA(n,e),Si(n,e,o,t),e.child;case 6:return n===null&&q1(e),null;case 13:return qA(n,e,t);case 4:return Fy(e,e.stateNode.containerInfo),i=e.pendingProps,n===null?e.child=Ol(e,null,i,t):Si(n,e,i,t),e.child;case 11:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Lr(i,r),i3(n,e,i,r,t);case 7:return Si(n,e,e.pendingProps,t),e.child;case 8:return Si(n,e,e.pendingProps.children,t),e.child;case 12:return Si(n,e,e.pendingProps.children,t),e.child;case 10:e:{if(i=e.type._context,r=e.pendingProps,s=e.memoizedProps,o=r.value,rn(Df,i._currentValue),i._currentValue=o,s!==null)if(Br(s.value,o)){if(s.children===r.children&&!Ni.current){e=Fs(n,e,t);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var l=a.firstContext;l!==null;){if(l.context===i){if(s.tag===1){l=ks(-1,t&-t),l.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}s.lanes|=t,l=s.alternate,l!==null&&(l.lanes|=t),Y1(s.return,t,e),a.lanes|=t;break}l=l.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(Ze(341));o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),Y1(o,t,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}Si(n,e,r.children,t),e=e.child}return e;case 9:return r=e.type,i=e.pendingProps.children,kl(e,t),r=yr(r),i=i(r),e.flags|=1,Si(n,e,i,t),e.child;case 14:return i=e.type,r=Lr(i,e.pendingProps),r=Lr(i.type,r),r3(n,e,i,r,t);case 15:return $A(n,e,e.type,e.pendingProps,t);case 17:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Lr(i,r),yf(n,e),e.tag=1,Fi(i)?(n=!0,Rf(e)):n=!1,kl(e,t),VA(e,i,r),K1(e,i,r,t),ey(null,e,i,!0,n,t);case 19:return YA(n,e,t);case 22:return WA(n,e,t)}throw Error(Ze(156,e.tag))};function hM(n,e){return B3(n,e)}function bL(n,e,t,i){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mr(n,e,t,i){return new bL(n,e,t,i)}function Ky(n){return n=n.prototype,!(!n||!n.isReactComponent)}function wL(n){if(typeof n=="function")return Ky(n)?1:0;if(n!=null){if(n=n.$$typeof,n===gy)return 11;if(n===yy)return 14}return 2}function To(n,e){var t=n.alternate;return t===null?(t=mr(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&14680064,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t}function xf(n,e,t,i,r,s){var o=2;if(i=n,typeof n=="function")Ky(n)&&(o=1);else if(typeof n=="string")o=5;else e:switch(n){case yl:return ya(t.children,r,s,e);case my:o=8,r|=8;break;case b1:return n=mr(12,t,e,r|2),n.elementType=b1,n.lanes=s,n;case w1:return n=mr(13,t,e,r),n.elementType=w1,n.lanes=s,n;case S1:return n=mr(19,t,e,r),n.elementType=S1,n.lanes=s,n;case b3:return tp(t,r,s,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case v3:o=10;break e;case x3:o=9;break e;case gy:o=11;break e;case yy:o=14;break e;case mo:o=16,i=null;break e}throw Error(Ze(130,n==null?n:typeof n,""))}return e=mr(o,t,e,r),e.elementType=n,e.type=i,e.lanes=s,e}function ya(n,e,t,i){return n=mr(7,n,i,e),n.lanes=t,n}function tp(n,e,t,i){return n=mr(22,n,i,e),n.elementType=b3,n.lanes=t,n.stateNode={isHidden:!1},n}function _1(n,e,t){return n=mr(6,n,null,e),n.lanes=t,n}function v1(n,e,t){return e=mr(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function SL(n,e,t,i,r){this.tag=e,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=n1(0),this.expirationTimes=n1(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=n1(0),this.identifierPrefix=i,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function Jy(n,e,t,i,r,s,o,a,l){return n=new SL(n,e,t,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=mr(3,null,null,e),n.current=s,s.stateNode=n,s.memoizedState={element:i,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ny(s),n}function AL(n,e,t){var i=3{"use strict";function gM(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(gM)}catch(n){console.error(n)}}gM(),yM.exports=mM()});var xM=hr(n_=>{"use strict";var vM=_M();n_.createRoot=vM.createRoot,n_.hydrateRoot=vM.hydrateRoot;var uV});var CE=hr((Dh,Nh)=>{(function(){var n,e,t,i,r,s,o,a,l,c,u,d,f,m,p,_,y,g,b,h,v,S,x,w,A,M,T,R,C,P,E,I,O,D,N,H,z,L,F,te,Q,Z,J,re,X,se,ne,oe,ee,le,xe,Se,Re,ke,$e,_e,Ie,We,Fe,Y,$,de,Te,fe,Ae,Be,Ee,Ue,je,at,Pe,lt,tt,He,Qe,Oe,et,ie,ye,pe,ve,Ne,st,wt=[].slice;ye=function(){var k,G,V,q,K;for(k={},K="Boolean Number String Function Array Date RegExp Undefined Null".split(" "),q=0,G=K.length;qV&&(k=V),k},pe=function(k){return k.length>=3?Array.prototype.slice.call(k):k[0]},v=function(k){var G,V;for(k._clipped=!1,k._unclipped=k.slice(0),G=V=0;V<3;G=++V)G<3?((k[G]<0||k[G]>255)&&(k._clipped=!0),k[G]<0&&(k[G]=0),k[G]>255&&(k[G]=255)):G===3&&(k[G]<0&&(k[G]=0),k[G]>1&&(k[G]=1));return k._clipped||delete k._unclipped,k},i=Math.PI,He=Math.round,w=Math.cos,C=Math.floor,Ie=Math.pow,ee=Math.log,Oe=Math.sin,et=Math.sqrt,m=Math.atan2,Se=Math.max,f=Math.abs,o=i*2,r=i/3,e=i/180,s=180/i,h=function(){return arguments[0]instanceof n?arguments[0]:function(k,G,V){V.prototype=k.prototype;var q=new V,K=k.apply(q,G);return Object(K)===K?K:q}(n,arguments,function(){})},h.default=h,d=[],typeof Nh<"u"&&Nh!==null&&Nh.exports!=null&&(Nh.exports=h),typeof define=="function"&&define.amd?define([],function(){return h}):(tt=typeof Dh<"u"&&Dh!==null?Dh:this,tt.chroma=h),h.version="1.4.1",u={},l=[],c=!1,n=function(){function k(){var G,V,q,K,ae,ue,me,De,ze;for(ue=this,V=[],De=0,K=arguments.length;De1&&(me=V[V.length-1]),u[me]!=null)ue._rgb=v(u[me](pe(V.slice(0,-1))));else{for(c||(l=l.sort(function(Ye,mt){return mt.p-Ye.p}),c=!0),ze=0,ae=l.length;ze3?G[3]:1]},st=function(k){return 255*(k<=.00304?12.92*k:1.055*Ie(k,1/2.4)-.055)},re=function(k){return k>t.t1?k*k*k:t.t2*(k-t.t0)},t={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},Ae=function(){var k,G,V,q,K,ae,ue,me;return q=pe(arguments),V=q[0],G=q[1],k=q[2],K=at(V,G,k),ae=K[0],ue=K[1],me=K[2],[116*ue-16,500*(ae-ue),200*(ue-me)]},Pe=function(k){return(k/=255)<=.04045?k/12.92:Ie((k+.055)/1.055,2.4)},Ne=function(k){return k>t.t3?Ie(k,1/3):k/t.t2+t.t0},at=function(){var k,G,V,q,K,ae,ue;return q=pe(arguments),V=q[0],G=q[1],k=q[2],V=Pe(V),G=Pe(G),k=Pe(k),K=Ne((.4124564*V+.3575761*G+.1804375*k)/t.Xn),ae=Ne((.2126729*V+.7151522*G+.072175*k)/t.Yn),ue=Ne((.0193339*V+.119192*G+.9503041*k)/t.Zn),[K,ae,ue]},h.lab=function(){return function(k,G,V){V.prototype=k.prototype;var q=new V,K=k.apply(q,G);return Object(K)===K?K:q}(n,wt.call(arguments).concat(["lab"]),function(){})},u.lab=J,n.prototype.lab=function(){return Ae(this._rgb)},p=function(k){var G,V,q,K,ae,ue,me,De,ze,Ye,mt;return k=function(){var Je,Ge,ht;for(ht=[],Ge=0,Je=k.length;Ge=0&&G[3]<=1)return"rgb"}}),u.lrgb=u.rgb,F=function(k,G,V,q){var K,ae;return K=k._rgb,ae=G._rgb,new n(et(Ie(K[0],2)*(1-V)+Ie(ae[0],2)*V),et(Ie(K[1],2)*(1-V)+Ie(ae[1],2)*V),et(Ie(K[2],2)*(1-V)+Ie(ae[2],2)*V),q)},a=function(k){var G,V,q,K,ae,ue;for(V=1/k.length,ue=[0,0,0,0],K=0,q=k.length;K1&&(ue[3]=1),new n(v(ue))},d.push(["lrgb",F]),h.average=function(k,G){var V,q,K,ae,ue,me,De,ze,Ye,mt,Je,Ge,ht;if(G==null&&(G="rgb"),Ye=k.length,k=k.map(function(j){return h(j)}),De=k.splice(0,1)[0],G==="lrgb")return a(k);Ge=De.get(G),ae=[],ue=0,me=0;for(ze in Ge)Ge[ze]=Ge[ze]||0,ae.push(isNaN(Ge[ze])?0:1),G.charAt(ze)==="h"&&!isNaN(Ge[ze])&&(V=Ge[ze]/180*i,ue+=w(V),me+=Oe(V));for(q=De.alpha(),Je=0,mt=k.length;Je=360;)V-=360;Ge[ze]=V}else Ge[ze]=Ge[ze]/ae[ze];return h(Ge,G).alpha(q/Ye)},E=function(k){var G,V,q,K,ae,ue;if(k.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return(k.length===4||k.length===7)&&(k=k.substr(1)),k.length===3&&(k=k.split(""),k=k[0]+k[0]+k[1]+k[1]+k[2]+k[2]),ue=parseInt(k,16),K=ue>>16,q=ue>>8&255,V=ue&255,[K,q,V,1];if(k.match(/^#?([A-Fa-f0-9]{8})$/))return k.length===9&&(k=k.substr(1)),ue=parseInt(k,16),K=ue>>24&255,q=ue>>16&255,V=ue>>8&255,G=He((ue&255)/255*100)/100,[K,q,V,G];if(u.css!=null&&(ae=u.css(k)))return ae;throw"unknown color: "+k},$=function(k,G){var V,q,K,ae,ue,me,De;return G==null&&(G="auto"),ue=k[0],K=k[1],q=k[2],V=k[3],G==="auto"&&(G=V<1?"rgba":"rgb"),ue=Math.round(ue),K=Math.round(K),q=Math.round(q),De=ue<<16|K<<8|q,me="000000"+De.toString(16),me=me.substr(me.length-6),ae="0"+He(V*255).toString(16),ae=ae.substr(ae.length-2),"#"+function(){switch(G.toLowerCase()){case"rgba":return me+ae;case"argb":return ae+me;default:return me}}()},u.hex=function(k){return E(k)},h.hex=function(){return function(k,G,V){V.prototype=k.prototype;var q=new V,K=k.apply(q,G);return Object(K)===K?K:q}(n,wt.call(arguments).concat(["hex"]),function(){})},n.prototype.hex=function(k){return k==null&&(k="auto"),$(this._rgb,k)},l.push({p:4,test:function(k){if(arguments.length===1&&ye(k)==="string")return"hex"}}),D=function(){var k,G,V,q,K,ae,ue,me,De,ze,Ye,mt,Je,Ge;if(k=pe(arguments),K=k[0],Ye=k[1],ue=k[2],Ye===0)De=q=G=ue*255;else{for(Ge=[0,0,0],V=[0,0,0],Je=ue<.5?ue*(1+Ye):ue+Ye-ue*Ye,mt=2*ue-Je,K/=360,Ge[0]=K+1/3,Ge[1]=K,Ge[2]=K-1/3,ae=me=0;me<=2;ae=++me)Ge[ae]<0&&(Ge[ae]+=1),Ge[ae]>1&&(Ge[ae]-=1),6*Ge[ae]<1?V[ae]=mt+(Je-mt)*6*Ge[ae]:2*Ge[ae]<1?V[ae]=Je:3*Ge[ae]<2?V[ae]=mt+(Je-mt)*(2/3-Ge[ae])*6:V[ae]=mt;ze=[He(V[0]*255),He(V[1]*255),He(V[2]*255)],De=ze[0],q=ze[1],G=ze[2]}return k.length>3?[De,q,G,k[3]]:[De,q,G]},Te=function(k,G,V){var q,K,ae,ue,me;return k!==void 0&&k.length>=3&&(ue=k,k=ue[0],G=ue[1],V=ue[2]),k/=255,G/=255,V/=255,ae=Math.min(k,G,V),Se=Math.max(k,G,V),K=(Se+ae)/2,Se===ae?(me=0,q=Number.NaN):me=K<.5?(Se-ae)/(Se+ae):(Se-ae)/(2-Se-ae),k===Se?q=(G-V)/(Se-ae):G===Se?q=2+(V-k)/(Se-ae):V===Se&&(q=4+(k-G)/(Se-ae)),q*=60,q<0&&(q+=360),[q,me,K]},h.hsl=function(){return function(k,G,V){V.prototype=k.prototype;var q=new V,K=k.apply(q,G);return Object(K)===K?K:q}(n,wt.call(arguments).concat(["hsl"]),function(){})},u.hsl=D,n.prototype.hsl=function(){return Te(this._rgb)},N=function(){var k,G,V,q,K,ae,ue,me,De,ze,Ye,mt,Je,Ge,ht,j,he,be;if(k=pe(arguments),K=k[0],j=k[1],be=k[2],be*=255,j===0)De=q=G=be;else switch(K===360&&(K=0),K>360&&(K-=360),K<0&&(K+=360),K/=60,ae=C(K),V=K-ae,ue=be*(1-j),me=be*(1-j*V),he=be*(1-j*(1-V)),ae){case 0:ze=[be,he,ue],De=ze[0],q=ze[1],G=ze[2];break;case 1:Ye=[me,be,ue],De=Ye[0],q=Ye[1],G=Ye[2];break;case 2:mt=[ue,be,he],De=mt[0],q=mt[1],G=mt[2];break;case 3:Je=[ue,me,be],De=Je[0],q=Je[1],G=Je[2];break;case 4:Ge=[he,ue,be],De=Ge[0],q=Ge[1],G=Ge[2];break;case 5:ht=[be,ue,me],De=ht[0],q=ht[1],G=ht[2]}return[De,q,G,k.length>3?k[3]:1]},fe=function(){var k,G,V,q,K,ae,ue,me,De;return ue=pe(arguments),ae=ue[0],V=ue[1],k=ue[2],K=Math.min(ae,V,k),Se=Math.max(ae,V,k),G=Se-K,De=Se/255,Se===0?(q=Number.NaN,me=0):(me=G/Se,ae===Se&&(q=(V-k)/G),V===Se&&(q=2+(k-ae)/G),k===Se&&(q=4+(ae-V)/G),q*=60,q<0&&(q+=360)),[q,me,De]},h.hsv=function(){return function(k,G,V){V.prototype=k.prototype;var q=new V,K=k.apply(q,G);return Object(K)===K?K:q}(n,wt.call(arguments).concat(["hsv"]),function(){})},u.hsv=N,n.prototype.hsv=function(){return fe(this._rgb)},$e=function(k){var G,V,q;return ye(k)==="number"&&k>=0&&k<=16777215?(q=k>>16,V=k>>8&255,G=k&255,[q,V,G,1]):(console.warn("unknown num color: "+k),[0,0,0,1])},Ue=function(){var k,G,V,q;return q=pe(arguments),V=q[0],G=q[1],k=q[2],(V<<16)+(G<<8)+k},h.num=function(k){return new n(k,"num")},n.prototype.num=function(k){return k==null&&(k="rgb"),Ue(this._rgb,k)},u.num=$e,l.push({p:1,test:function(k){if(arguments.length===1&&ye(k)==="number"&&k>=0&&k<=16777215)return"num"}}),P=function(){var k,G,V,q,K,ae,ue,me,De,ze,Ye,mt,Je,Ge,ht,j,he,be,Me,ge;if(V=pe(arguments),me=V[0],K=V[1],G=V[2],K=K/100,ue=ue/100*255,k=K*255,K===0)mt=ue=q=G;else switch(me===360&&(me=0),me>360&&(me-=360),me<0&&(me+=360),me/=60,De=C(me),ae=me-De,ze=G*(1-K),Ye=ze+k*(1-ae),Me=ze+k*ae,ge=ze+k,De){case 0:Je=[ge,Me,ze],mt=Je[0],ue=Je[1],q=Je[2];break;case 1:Ge=[Ye,ge,ze],mt=Ge[0],ue=Ge[1],q=Ge[2];break;case 2:ht=[ze,ge,Me],mt=ht[0],ue=ht[1],q=ht[2];break;case 3:j=[ze,Ye,ge],mt=j[0],ue=j[1],q=j[2];break;case 4:he=[Me,ze,ge],mt=he[0],ue=he[1],q=he[2];break;case 5:be=[ge,ze,Ye],mt=be[0],ue=be[1],q=be[2]}return[mt,ue,q,V.length>3?V[3]:1]},Y=function(){var k,G,V,q,K,ae,ue,me,De;return De=pe(arguments),me=De[0],K=De[1],G=De[2],ue=Math.min(me,K,G),Se=Math.max(me,K,G),q=Se-ue,V=q*100/255,k=ue/(255-q)*100,q===0?ae=Number.NaN:(me===Se&&(ae=(K-G)/q),K===Se&&(ae=2+(G-me)/q),G===Se&&(ae=4+(me-K)/q),ae*=60,ae<0&&(ae+=360)),[ae,V,k]},h.hcg=function(){return function(k,G,V){V.prototype=k.prototype;var q=new V,K=k.apply(q,G);return Object(K)===K?K:q}(n,wt.call(arguments).concat(["hcg"]),function(){})},u.hcg=P,n.prototype.hcg=function(){return Y(this._rgb)},A=function(k){var G,V,q,K,ae,ue,me,De;if(k=k.toLowerCase(),h.colors!=null&&h.colors[k])return E(h.colors[k]);if(ae=k.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(me=ae.slice(1,4),K=ue=0;ue<=2;K=++ue)me[K]=+me[K];me[3]=1}else if(ae=k.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))for(me=ae.slice(1,5),K=De=0;De<=3;K=++De)me[K]=+me[K];else if(ae=k.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(me=ae.slice(1,4),K=G=0;G<=2;K=++G)me[K]=He(me[K]*2.55);me[3]=1}else if(ae=k.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){for(me=ae.slice(1,5),K=V=0;V<=2;K=++V)me[K]=He(me[K]*2.55);me[3]=+me[3]}else(ae=k.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?(q=ae.slice(1,4),q[1]*=.01,q[2]*=.01,me=D(q),me[3]=1):(ae=k.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&(q=ae.slice(1,4),q[1]*=.01,q[2]*=.01,me=D(q),me[3]=+ae[4]);return me},Fe=function(k){var G;if(G=k[3]<1?"rgba":"rgb",G==="rgb")return G+"("+k.slice(0,3).map(He).join(",")+")";if(G==="rgba")return G+"("+k.slice(0,3).map(He).join(",")+","+k[3]+")"},lt=function(k){return He(k*100)/100},O=function(k,G){var V;return V=G<1?"hsla":"hsl",k[0]=lt(k[0]||0),k[1]=lt(k[1]*100)+"%",k[2]=lt(k[2]*100)+"%",V==="hsla"&&(k[3]=G),V+"("+k.join(",")+")"},u.css=function(k){return A(k)},h.css=function(){return function(k,G,V){V.prototype=k.prototype;var q=new V,K=k.apply(q,G);return Object(K)===K?K:q}(n,wt.call(arguments).concat(["css"]),function(){})},n.prototype.css=function(k){if(k==null&&(k="rgb"),k.slice(0,3)==="rgb")return Fe(this._rgb);if(k.slice(0,3)==="hsl")return O(this.hsl(),this.alpha())},u.named=function(k){return E(ve[k])},l.push({p:5,test:function(k){if(arguments.length===1&&ve[k]!=null)return"named"}}),n.prototype.name=function(k){var G,V;arguments.length&&(ve[k]&&(this._rgb=E(ve[k])),this._rgb[3]=1),G=this.hex("rgb");for(V in ve)if(G===ve[V])return V;return G},X=function(){var k,G,V,q;return q=pe(arguments),V=q[0],k=q[1],G=q[2],G=G*e,[V,w(G)*k,Oe(G)*k]},se=function(){var k,G,V,q,K,ae,ue,me,De,ze,Ye;return V=pe(arguments),me=V[0],K=V[1],ue=V[2],ze=X(me,K,ue),k=ze[0],G=ze[1],q=ze[2],Ye=J(k,G,q),De=Ye[0],ae=Ye[1],q=Ye[2],[De,ae,q,V.length>3?V[3]:1]},Z=function(){var k,G,V,q,K,ae;return ae=pe(arguments),K=ae[0],k=ae[1],G=ae[2],V=et(k*k+G*G),q=(m(G,k)*s+360)%360,He(V*1e4)===0&&(q=Number.NaN),[K,V,q]},Be=function(){var k,G,V,q,K,ae,ue;return ae=pe(arguments),K=ae[0],V=ae[1],G=ae[2],ue=Ae(K,V,G),q=ue[0],k=ue[1],G=ue[2],Z(q,k,G)},h.lch=function(){var k;return k=pe(arguments),new n(k,"lch")},h.hcl=function(){var k;return k=pe(arguments),new n(k,"hcl")},u.lch=se,u.hcl=function(){var k,G,V,q;return q=pe(arguments),G=q[0],k=q[1],V=q[2],se([V,k,G])},n.prototype.lch=function(){return Be(this._rgb)},n.prototype.hcl=function(){return Be(this._rgb).reverse()},We=function(k){var G,V,q,K,ae,ue,me,De,ze;return k==null&&(k="rgb"),De=pe(arguments),me=De[0],K=De[1],G=De[2],me=me/255,K=K/255,G=G/255,ae=1-Math.max(me,Math.max(K,G)),q=ae<1?1/(1-ae):0,V=(1-me-ae)*q,ue=(1-K-ae)*q,ze=(1-G-ae)*q,[V,ue,ze,ae]},S=function(){var k,G,V,q,K,ae,ue,me,De;return G=pe(arguments),q=G[0],ue=G[1],De=G[2],ae=G[3],k=G.length>4?G[4]:1,ae===1?[0,0,0,k]:(me=q>=1?0:255*(1-q)*(1-ae),K=ue>=1?0:255*(1-ue)*(1-ae),V=De>=1?0:255*(1-De)*(1-ae),[me,K,V,k])},u.cmyk=function(){return S(pe(arguments))},h.cmyk=function(){return function(k,G,V){V.prototype=k.prototype;var q=new V,K=k.apply(q,G);return Object(K)===K?K:q}(n,wt.call(arguments).concat(["cmyk"]),function(){})},n.prototype.cmyk=function(){return We(this._rgb)},u.gl=function(){var k,G,V,q,K;for(q=function(){var ae,ue;ae=pe(arguments),ue=[];for(G in ae)K=ae[G],ue.push(K);return ue}.apply(this,arguments),k=V=0;V<=2;k=++V)q[k]*=255;return q},h.gl=function(){return function(k,G,V){V.prototype=k.prototype;var q=new V,K=k.apply(q,G);return Object(K)===K?K:q}(n,wt.call(arguments).concat(["gl"]),function(){})},n.prototype.gl=function(){var k;return k=this._rgb,[k[0]/255,k[1]/255,k[2]/255,k[3]]},Ee=function(k,G,V){var q;return q=pe(arguments),k=q[0],G=q[1],V=q[2],k=le(k),G=le(G),V=le(V),.2126*k+.7152*G+.0722*V},le=function(k){return k/=255,k<=.03928?k/12.92:Ie((k+.055)/1.055,2.4)},Q=function(k,G,V,q){var K,ae;return K=k._rgb,ae=G._rgb,new n(K[0]+V*(ae[0]-K[0]),K[1]+V*(ae[1]-K[1]),K[2]+V*(ae[2]-K[2]),q)},d.push(["rgb",Q]),n.prototype.luminance=function(k,G){var V,q,K,ae,ue;return G==null&&(G="rgb"),arguments.length?(ae=this._rgb,k===0?ae=[0,0,0,this._rgb[3]]:k===1?ae=[255,255,255,this[3]]:(V=Ee(this._rgb),q=1e-7,K=20,ue=function(me,De){var ze,Ye;return Ye=me.interpolate(De,.5,G),ze=Ye.luminance(),Math.abs(k-ze)k?ue(me,Ye):ue(Ye,De)},V>k?ae=ue(h("black"),this).rgba():ae=ue(this,h("white")).rgba()),h(ae).alpha(this.alpha())):Ee(this._rgb)},ie=function(k){var G,V,q,K;return K=k/100,K<66?(q=255,V=-155.25485562709179-.44596950469579133*(V=K-2)+104.49216199393888*ee(V),G=K<20?0:-254.76935184120902+.8274096064007395*(G=K-10)+115.67994401066147*ee(G)):(q=351.97690566805693+.114206453784165*(q=K-55)-40.25366309332127*ee(q),V=325.4494125711974+.07943456536662342*(V=K-50)-28.0852963507957*ee(V),G=255),[q,V,G]},je=function(){var k,G,V,q,K,ae,ue,me,De;for(ue=pe(arguments),ae=ue[0],V=ue[1],k=ue[2],K=1e3,q=4e4,G=.4;q-K>G;)De=(q+K)*.5,me=ie(De),me[2]/me[0]>=k/ae?q=De:K=De;return He(De)},h.temperature=h.kelvin=function(){return function(k,G,V){V.prototype=k.prototype;var q=new V,K=k.apply(q,G);return Object(K)===K?K:q}(n,wt.call(arguments).concat(["temperature"]),function(){})},u.temperature=u.kelvin=u.K=ie,n.prototype.temperature=function(){return je(this._rgb)},n.prototype.kelvin=n.prototype.temperature,h.contrast=function(k,G){var V,q,K,ae;return((K=ye(k))==="string"||K==="number")&&(k=new n(k)),((ae=ye(G))==="string"||ae==="number")&&(G=new n(G)),V=k.luminance(),q=G.luminance(),V>q?(V+.05)/(q+.05):(q+.05)/(V+.05)},h.distance=function(k,G,V){var q,K,ae,ue,me,De,ze;V==null&&(V="lab"),((me=ye(k))==="string"||me==="number")&&(k=new n(k)),((De=ye(G))==="string"||De==="number")&&(G=new n(G)),ae=k.get(V),ue=G.get(V),ze=0;for(K in ae)q=(ae[K]||0)-(ue[K]||0),ze+=q*q;return Math.sqrt(ze)},h.deltaE=function(k,G,V,q){var K,ae,ue,me,De,ze,Ye,mt,Je,Ge,ht,j,he,be,Me,ge,rt,ct,Ke,nt,vt,Ce,Ve,ft,St,pt,Ct;for(V==null&&(V=1),q==null&&(q=1),((rt=ye(k))==="string"||rt==="number")&&(k=new n(k)),((ct=ye(G))==="string"||ct==="number")&&(G=new n(G)),Ke=k.lab(),K=Ke[0],ue=Ke[1],De=Ke[2],nt=G.lab(),ae=nt[0],me=nt[1],ze=nt[2],Ye=et(ue*ue+De*De),mt=et(me*me+ze*ze),Ve=K<16?.511:.040975*K/(1+.01765*K),vt=.0638*Ye/(1+.0131*Ye)+.638,ge=Ye<1e-6?0:m(De,ue)*180/i;ge<0;)ge+=360;for(;ge>=360;)ge-=360;return ft=ge>=164&&ge<=345?.56+f(.2*w(i*(ge+168)/180)):.36+f(.4*w(i*(ge+35)/180)),Je=Ye*Ye*Ye*Ye,Me=et(Je/(Je+1900)),Ce=vt*(Me*ft+1-Me),be=K-ae,he=Ye-mt,ht=ue-me,j=De-ze,Ge=ht*ht+j*j-he*he,St=be/(V*Ve),pt=he/(q*vt),Ct=Ce,et(St*St+pt*pt+Ge/(Ct*Ct))},n.prototype.get=function(k){var G,V,q,K,ae,ue;return q=this,ae=k.split("."),K=ae[0],G=ae[1],ue=q[K](),G?(V=K.indexOf(G),V>-1?ue[V]:console.warn("unknown channel "+G+" in mode "+K)):ue},n.prototype.set=function(k,G){var V,q,K,ae,ue,me;if(K=this,ue=k.split("."),ae=ue[0],V=ue[1],V)if(me=K[ae](),q=ae.indexOf(V),q>-1)if(ye(G)==="string")switch(G.charAt(0)){case"+":me[q]+=+G;break;case"-":me[q]+=+G;break;case"*":me[q]*=+G.substr(1);break;case"/":me[q]/=+G.substr(1);break;default:me[q]=+G}else me[q]=G;else console.warn("unknown channel "+V+" in mode "+ae);else me=G;return h(me,ae).alpha(K.alpha())},n.prototype.clipped=function(){return this._rgb._clipped||!1},n.prototype.alpha=function(k){return arguments.length?h.rgb([this._rgb[0],this._rgb[1],this._rgb[2],k]):this._rgb[3]},n.prototype.darken=function(k){var G,V;return k==null&&(k=1),V=this,G=V.lab(),G[0]-=t.Kn*k,h.lab(G).alpha(V.alpha())},n.prototype.brighten=function(k){return k==null&&(k=1),this.darken(-k)},n.prototype.darker=n.prototype.darken,n.prototype.brighter=n.prototype.brighten,n.prototype.saturate=function(k){var G,V;return k==null&&(k=1),V=this,G=V.lch(),G[1]+=k*t.Kn,G[1]<0&&(G[1]=0),h.lch(G).alpha(V.alpha())},n.prototype.desaturate=function(k){return k==null&&(k=1),this.saturate(-k)},n.prototype.premultiply=function(){var k,G;return G=this.rgb(),k=this.alpha(),h(G[0]*k,G[1]*k,G[2]*k,k)},_=function(k,G,V){if(!_[V])throw"unknown blend mode "+V;return _[V](k,G)},y=function(k){return function(G,V){var q,K;return q=h(V).rgb(),K=h(G).rgb(),h(k(q,K),"rgb")}},R=function(k){return function(G,V){var q,K,ae;for(ae=[],q=K=0;K<=3;q=++K)ae[q]=k(G[q],V[q]);return ae}},ke=function(k,G){return k},Re=function(k,G){return k*G/255},M=function(k,G){return k>G?G:k},ne=function(k,G){return k>G?k:G},Qe=function(k,G){return 255*(1-(1-k/255)*(1-G/255))},_e=function(k,G){return G<128?2*k*G/255:255*(1-2*(1-k/255)*(1-G/255))},b=function(k,G){return 255*(1-(1-G/255)/(k/255))},T=function(k,G){return k===255||(k=255*(G/255)/(1-k/255),k>255)?255:k},_.normal=y(R(ke)),_.multiply=y(R(Re)),_.screen=y(R(Qe)),_.overlay=y(R(_e)),_.darken=y(R(M)),_.lighten=y(R(ne)),_.dodge=y(R(T)),_.burn=y(R(b)),h.blend=_,h.analyze=function(k){var G,V,q,K;for(q={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0},V=0,G=k.length;Vq.max&&(q.max=K),q.count+=1);return q.domain=[q.min,q.max],q.limits=function(ae,ue){return h.limits(q,ae,ue)},q},h.scale=function(k,G){var V,q,K,ae,ue,me,De,ze,Ye,mt,Je,Ge,ht,j,he,be,Me,ge,rt,ct,Ke,nt,vt;return mt="rgb",Je=h("#ccc"),he=0,me=!1,ue=[0,1],j=[],ht=[0,0],V=!1,K=[],Ge=!1,Ye=0,ze=1,ae=!1,q={},be=!0,De=1,nt=function(Ce){var Ve,ft,St,pt,Ct,xt;if(Ce==null&&(Ce=["#fff","#000"]),Ce!=null&&ye(Ce)==="string"&&h.brewer!=null&&(Ce=h.brewer[Ce]||h.brewer[Ce.toLowerCase()]||Ce),ye(Ce)==="array"){for(Ce.length===1&&(Ce=[Ce[0],Ce[0]]),Ce=Ce.slice(0),Ve=St=0,pt=Ce.length-1;0<=pt?St<=pt:St>=pt;Ve=0<=pt?++St:--St)ft=Ce[Ve],ye(ft)==="string"&&(Ce[Ve]=h(ft));for(j.length=0,Ve=xt=0,Ct=Ce.length-1;0<=Ct?xt<=Ct:xt>=Ct;Ve=0<=Ct?++xt:--xt)j.push(Ve/(Ce.length-1))}return Ke(),K=Ce},rt=function(Ce){var Ve,ft;if(V!=null){for(ft=V.length-1,Ve=0;Ve=V[Ve];)Ve++;return Ve-1}return 0},vt=function(Ce){return Ce},Me=function(Ce){var Ve,ft,St,pt,Ct;return Ct=Ce,V.length>2&&(pt=V.length-1,Ve=rt(Ce),St=V[0]+(V[1]-V[0])*(0+he*.5),ft=V[pt-1]+(V[pt]-V[pt-1])*(1-he*.5),Ct=Ye+(V[Ve]+(V[Ve+1]-V[Ve])*.5-St)/(ft-St)*(ze-Ye)),Ct},ct=function(Ce,Ve){var ft,St,pt,Ct,xt,ot,Pn,_t;if(Ve==null&&(Ve=!1),isNaN(Ce)||Ce===null)return Je;if(Ve?_t=Ce:V&&V.length>2?(ft=rt(Ce),_t=ft/(V.length-2)):ze!==Ye?_t=(Ce-Ye)/(ze-Ye):_t=1,Ve||(_t=vt(_t)),De!==1&&(_t=Ie(_t,De)),_t=ht[0]+_t*(1-ht[0]-ht[1]),_t=Math.min(1,Math.max(0,_t)),Ct=Math.floor(_t*1e4),be&&q[Ct])St=q[Ct];else{if(ye(K)==="array")for(pt=xt=0,Pn=j.length-1;0<=Pn?xt<=Pn:xt>=Pn;pt=0<=Pn?++xt:--xt){if(ot=j[pt],_t<=ot){St=K[pt];break}if(_t>=ot&&pt===j.length-1){St=K[pt];break}if(_t>ot&&_t=xt;Ve=0<=xt?++ot:--ot)j.push(Ve/(St-1));return ue=[Ye,ze],ge},ge.mode=function(Ce){return arguments.length?(mt=Ce,Ke(),ge):mt},ge.range=function(Ce,Ve){return nt(Ce,Ve),ge},ge.out=function(Ce){return Ge=Ce,ge},ge.spread=function(Ce){return arguments.length?(he=Ce,ge):he},ge.correctLightness=function(Ce){return Ce==null&&(Ce=!0),ae=Ce,Ke(),ae?vt=function(Ve){var ft,St,pt,Ct,xt,ot,Pn,_t,fn;for(ft=ct(0,!0).lab()[0],St=ct(1,!0).lab()[0],Pn=ft>St,pt=ct(Ve,!0).lab()[0],xt=ft+(St-ft)*Ve,Ct=pt-xt,_t=0,fn=1,ot=20;Math.abs(Ct)>.01&&ot-- >0;)(function(){return Pn&&(Ct*=-1),Ct<0?(_t=Ve,Ve+=(fn-Ve)*.5):(fn=Ve,Ve+=(_t-Ve)*.5),pt=ct(Ve,!0).lab()[0],Ct=pt-xt})();return Ve}:vt=function(Ve){return Ve},ge},ge.padding=function(Ce){return Ce!=null?(ye(Ce)==="number"&&(Ce=[Ce,Ce]),ht=Ce,ge):ht},ge.colors=function(Ce,Ve){var ft,St,pt,Ct,xt,ot,Pn,_t,fn;if(arguments.length<2&&(Ve="hex"),ot=[],arguments.length===0)ot=K.slice(0);else if(Ce===1)ot=[ge(.5)];else if(Ce>1)St=ue[0],ft=ue[1]-St,ot=function(){Pn=[];for(var Kn=0;0<=Ce?KnCe;0<=Ce?Kn++:Kn--)Pn.push(Kn);return Pn}.apply(this).map(function(Kn){return ge(St+Kn/(Ce-1)*ft)});else{if(k=[],_t=[],V&&V.length>2)for(pt=fn=1,xt=V.length;1<=xt?fnxt;pt=1<=xt?++fn:--fn)_t.push((V[pt-1]+V[pt])*.5);else _t=ue;ot=_t.map(function(Kn){return ge(Kn)})}return h[Ve]&&(ot=ot.map(function(Kn){return Kn[Ve]()})),ot},ge.cache=function(Ce){return Ce!=null?(be=Ce,ge):be},ge.gamma=function(Ce){return Ce!=null?(De=Ce,ge):De},ge.nodata=function(Ce){return Ce!=null?(Je=h(Ce),ge):Je},ge},h.scales==null&&(h.scales={}),h.scales.cool=function(){return h.scale([h.hsl(180,1,.9),h.hsl(250,.7,.4)])},h.scales.hot=function(){return h.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},h.analyze=function(k,G,V){var q,K,ae,ue,me,De,ze;if(me={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0},V==null&&(V=function(){return!0}),q=function(Ye){Ye!=null&&!isNaN(Ye)&&(me.values.push(Ye),me.sum+=Ye,Yeme.max&&(me.max=Ye),me.count+=1)},ze=function(Ye,mt){if(V(Ye,mt))return G!=null&&ye(G)==="function"?q(G(Ye)):G!=null&&ye(G)==="string"||ye(G)==="number"?q(Ye[G]):q(Ye)},ye(k)==="array")for(ue=0,ae=k.length;ue=Ir;Ke=1<=Ir?++Pn:--Pn)Ce.push(ft+Ke/V*(Se-ft));Ce.push(Se)}else if(G.substr(0,1)==="l"){if(ft<=0)throw"Logarithmic scales are only possible for values > 0";for(St=Math.LOG10E*ee(ft),Ve=Math.LOG10E*ee(Se),Ce.push(ft),Ke=yu=1,Cs=V-1;1<=Cs?yu<=Cs:yu>=Cs;Ke=1<=Cs?++yu:--yu)Ce.push(Ie(10,St+Ke/V*(Ve-St)));Ce.push(Se)}else if(G.substr(0,1)==="q"){for(Ce.push(ft),Ke=q=1,ca=V-1;1<=ca?q<=ca:q>=ca;Ke=1<=ca?++q:--q)_t=(ns.length-1)*Ke/V,fn=C(_t),fn===_t?Ce.push(ns[fn]):(Kn=_t-fn,Ce.push(ns[fn]*(1-Kn)+ns[fn+1]*Kn));Ce.push(Se)}else if(G.substr(0,1)==="k"){for(Ct=ns.length,he=new Array(Ct),rt=new Array(V),gu=!0,xt=0,Me=null,Me=[],Me.push(ft),Ke=K=1,uo=V-1;1<=uo?K<=uo:K>=uo;Ke=1<=uo?++K:--K)Me.push(ft+Ke/V*(Se-ft));for(Me.push(Se);gu;){for(nt=ae=0,uu=V-1;0<=uu?ae<=uu:ae>=uu;nt=0<=uu?++ae:--ae)rt[nt]=0;for(Ke=ue=0,hu=Ct-1;0<=hu?ue<=hu:ue>=hu;Ke=0<=hu?++ue:--ue){for(Uw=ns[Ke],pt=Number.MAX_VALUE,nt=me=0,du=V-1;0<=du?me<=du:me>=du;nt=0<=du?++me:--me)ct=f(Me[nt]-Uw),ct=fu;nt=0<=fu?++De:--De)ot[nt]=null;for(Ke=ze=0,pu=Ct-1;0<=pu?ze<=pu:ze>=pu;Ke=0<=pu?++ze:--ze)ge=he[Ke],ot[ge]===null?ot[ge]=ns[Ke]:ot[ge]+=ns[Ke];for(nt=Ye=0,mu=V-1;0<=mu?Ye<=mu:Ye>=mu;nt=0<=mu?++Ye:--Ye)ot[nt]*=1/rt[nt];for(gu=!1,nt=mt=0,Ln=V-1;0<=Ln?mt<=Ln:mt>=Ln;nt=0<=Ln?++mt:--mt)if(ot[nt]!==Me[Ke]){gu=!0;break}Me=ot,xt++,xt>200&&(gu=!1)}for(vt={},nt=Je=0,Wi=V-1;0<=Wi?Je<=Wi:Je>=Wi;nt=0<=Wi?++Je:--Je)vt[nt]=[];for(Ke=Ge=0,Es=Ct-1;0<=Es?Ge<=Es:Ge>=Es;Ke=0<=Es?++Ge:--Ge)ge=he[Ke],vt[ge].push(ns[Ke]);for(ho=[],nt=ht=0,$n=V-1;0<=$n?ht<=$n:ht>=$n;nt=0<=$n?++ht:--ht)ho.push(vt[nt][0]),ho.push(vt[nt][vt[nt].length-1]);for(ho=ho.sort(function(F0,O0){return F0-O0}),Ce.push(ho[0]),Ke=j=1,hl=ho.length-1;j<=hl;Ke=j+=2)Fd=ho[Ke],!isNaN(Fd)&&Ce.indexOf(Fd)===-1&&Ce.push(Fd)}return Ce},I=function(k,G,V){var q,K,ae,ue;return q=pe(arguments),k=q[0],G=q[1],V=q[2],isNaN(k)&&(k=0),k/=360,k<1/3?(K=(1-G)/3,ue=(1+G*w(o*k)/w(r-o*k))/3,ae=1-(K+ue)):k<2/3?(k-=1/3,ue=(1-G)/3,ae=(1+G*w(o*k)/w(r-o*k))/3,K=1-(ue+ae)):(k-=2/3,ae=(1-G)/3,K=(1+G*w(o*k)/w(r-o*k))/3,ue=1-(ae+K)),ue=oe(V*ue*3),ae=oe(V*ae*3),K=oe(V*K*3),[ue*255,ae*255,K*255,q.length>3?q[3]:1]},de=function(){var k,G,V,q,K,ae,ue,me;return ue=pe(arguments),ae=ue[0],G=ue[1],k=ue[2],o=Math.PI*2,ae/=255,G/=255,k/=255,K=Math.min(ae,G,k),q=(ae+G+k)/3,me=1-K/q,me===0?V=0:(V=(ae-G+(ae-k))/2,V/=Math.sqrt((ae-G)*(ae-G)+(ae-k)*(G-k)),V=Math.acos(V),k>G&&(V=o-V),V/=o),[V*360,me,q]},h.hsi=function(){return function(k,G,V){V.prototype=k.prototype;var q=new V,K=k.apply(q,G);return Object(K)===K?K:q}(n,wt.call(arguments).concat(["hsi"]),function(){})},u.hsi=I,n.prototype.hsi=function(){return de(this._rgb)},z=function(k,G,V,q){var K,ae,ue,me,De,ze,Ye,mt,Je,Ge,ht,j,he;return q==="hsl"?(j=k.hsl(),he=G.hsl()):q==="hsv"?(j=k.hsv(),he=G.hsv()):q==="hcg"?(j=k.hcg(),he=G.hcg()):q==="hsi"?(j=k.hsi(),he=G.hsi()):(q==="lch"||q==="hcl")&&(q="hcl",j=k.hcl(),he=G.hcl()),q.substr(0,1)==="h"&&(ue=j[0],Ge=j[1],ze=j[2],me=he[0],ht=he[1],Ye=he[2]),!isNaN(ue)&&!isNaN(me)?(me>ue&&me-ue>180?K=me-(ue+360):me180?K=me+360-ue:K=me-ue,ae=ue+V*K):isNaN(ue)?isNaN(me)?ae=Number.NaN:(ae=me,(ze===1||ze===0)&&q!=="hsv"&&(Je=ht)):(ae=ue,(Ye===1||Ye===0)&&q!=="hsv"&&(Je=Ge)),Je==null&&(Je=Ge+V*(ht-Ge)),De=ze+V*(Ye-ze),mt=h[q](ae,Je,De)},d=d.concat(function(){var k,G,V,q;for(V=["hsv","hsl","hsi","hcl","lch","hcg"],q=[],G=0,k=V.length;G{(function(n){function e(s,o,a,l,c){this._listener=o,this._isOnce=a,this.context=l,this._signal=s,this._priority=c||0}e.prototype={active:!0,params:null,execute:function(s){var o,a;return this.active&&this._listener&&(a=this.params?this.params.concat(s):s,o=this._listener.apply(this.context,a),this._isOnce&&this.detach()),o},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};function t(s,o){if(typeof s!="function")throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",o))}function i(){this._bindings=[],this._prevParams=null;var s=this;this.dispatch=function(){i.prototype.dispatch.apply(s,arguments)}}i.prototype={VERSION:"1.0.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(s,o,a,l){var c=this._indexOfListener(s,a),u;if(c!==-1){if(u=this._bindings[c],u.isOnce()!==o)throw new Error("You cannot add"+(o?"":"Once")+"() then add"+(o?"Once":"")+"() the same listener without removing the relationship first.")}else u=new e(this,s,o,a,l),this._addBinding(u);return this.memorize&&this._prevParams&&u.execute(this._prevParams),u},_addBinding:function(s){var o=this._bindings.length;do--o;while(this._bindings[o]&&s._priority<=this._bindings[o]._priority);this._bindings.splice(o+1,0,s)},_indexOfListener:function(s,o){for(var a=this._bindings.length,l;a--;)if(l=this._bindings[a],l._listener===s&&l.context===o)return a;return-1},has:function(s,o){return this._indexOfListener(s,o)!==-1},add:function(s,o,a){return t(s,"add"),this._registerListener(s,!1,o,a)},addOnce:function(s,o,a){return t(s,"addOnce"),this._registerListener(s,!0,o,a)},remove:function(s,o){t(s,"remove");var a=this._indexOfListener(s,o);return a!==-1&&(this._bindings[a]._destroy(),this._bindings.splice(a,1)),s},removeAll:function(){for(var s=this._bindings.length;s--;)this._bindings[s]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(s){if(this.active){var o=Array.prototype.slice.call(arguments),a=this._bindings.length,l;if(this.memorize&&(this._prevParams=o),!!a){l=this._bindings.slice(),this._shouldPropagate=!0;do a--;while(l[a]&&this._shouldPropagate&&l[a].execute(o)!==!1)}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};var r=i;r.Signal=i,typeof define=="function"&&define.amd?define(function(){return r}):typeof dm<"u"&&dm.exports?dm.exports=r:n.signals=r})(EE)});var TE=hr(pm=>{(function(){"use strict";var n={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function e(o){return i(s(o),arguments)}function t(o,a){return e.apply(null,[o].concat(a||[]))}function i(o,a){var l=1,c=o.length,u,d="",f,m,p,_,y,g,b,h;for(f=0;f=0),p.type){case"b":u=parseInt(u,10).toString(2);break;case"c":u=String.fromCharCode(parseInt(u,10));break;case"d":case"i":u=parseInt(u,10);break;case"j":u=JSON.stringify(u,null,p.width?parseInt(p.width):0);break;case"e":u=p.precision?parseFloat(u).toExponential(p.precision):parseFloat(u).toExponential();break;case"f":u=p.precision?parseFloat(u).toFixed(p.precision):parseFloat(u);break;case"g":u=p.precision?String(Number(u.toPrecision(p.precision))):parseFloat(u);break;case"o":u=(parseInt(u,10)>>>0).toString(8);break;case"s":u=String(u),u=p.precision?u.substring(0,p.precision):u;break;case"t":u=String(!!u),u=p.precision?u.substring(0,p.precision):u;break;case"T":u=Object.prototype.toString.call(u).slice(8,-1).toLowerCase(),u=p.precision?u.substring(0,p.precision):u;break;case"u":u=parseInt(u,10)>>>0;break;case"v":u=u.valueOf(),u=p.precision?u.substring(0,p.precision):u;break;case"x":u=(parseInt(u,10)>>>0).toString(16);break;case"X":u=(parseInt(u,10)>>>0).toString(16).toUpperCase();break}n.json.test(p.type)?d+=u:(n.number.test(p.type)&&(!b||p.sign)?(h=b?"+":"-",u=u.toString().replace(n.sign,"")):h="",y=p.pad_char?p.pad_char==="0"?"0":p.pad_char.charAt(1):" ",g=p.width-(h+u).length,_=p.width&&g>0?y.repeat(g):"",d+=p.align?h+u+_:y==="0"?h+_+u:_+h+u)}return d}var r=Object.create(null);function s(o){if(r[o])return r[o];for(var a=o,l,c=[],u=0;a;){if((l=n.text.exec(a))!==null)c.push(l[0]);else if((l=n.modulo.exec(a))!==null)c.push("%");else if((l=n.placeholder.exec(a))!==null){if(l[2]){u|=1;var d=[],f=l[2],m=[];if((m=n.key.exec(f))!==null)for(d.push(m[1]);(f=f.substring(m[0].length))!=="";)if((m=n.key_access.exec(f))!==null)d.push(m[1]);else if((m=n.index_access.exec(f))!==null)d.push(m[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=d}else u|=2;if(u===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");c.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");a=a.substring(l[0].length)}return r[o]=c}typeof pm<"u"&&(pm.sprintf=e,pm.vsprintf=t),typeof window<"u"&&(window.sprintf=e,window.vsprintf=t,typeof define=="function"&&define.amd&&define(function(){return{sprintf:e,vsprintf:t}}))})()});var WI=hr(L0=>{"use strict";var V8=fl(),H8=Symbol.for("react.element"),G8=Symbol.for("react.fragment"),$8=Object.prototype.hasOwnProperty,W8=V8.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,j8={key:!0,ref:!0,__self:!0,__source:!0};function $I(n,e,t){var i,r={},s=null,o=null;t!==void 0&&(s=""+t),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(i in e)$8.call(e,i)&&!j8.hasOwnProperty(i)&&(r[i]=e[i]);if(n&&n.defaultProps)for(i in e=n.defaultProps,e)r[i]===void 0&&(r[i]=e[i]);return{$$typeof:H8,type:n,key:s,ref:o,props:r,_owner:W8.current}}L0.Fragment=G8;L0.jsx=$I;L0.jsxs=$I});var ur=hr((f9,jI)=>{"use strict";jI.exports=WI()});var Ow=Dn(xM(),1);var D0=Dn(fl(),1);var YI=Dn(fl(),1);function bM(n){var e,t,i="";if(typeof n=="string"||typeof n=="number")i+=n;else if(typeof n=="object")if(Array.isArray(n)){var r=n.length;for(e=0;eo(s))?.classGroupId}var SM=/^\[(.+)\]$/;function IL(n){if(SM.test(n)){let e=SM.exec(n)[1],t=e?.substring(0,e.indexOf(":"));if(t)return"arbitrary.."+t}}function RL(n){let{theme:e,prefix:t}=n,i={nextPart:new Map,validators:[]};return LL(Object.entries(n.classGroups),t).forEach(([s,o])=>{i_(o,i,s,e)}),i}function i_(n,e,t,i){n.forEach(r=>{if(typeof r=="string"){let s=r===""?e:AM(e,r);s.classGroupId=t;return}if(typeof r=="function"){if(kL(r)){i_(r(i),e,t,i);return}e.validators.push({validator:r,classGroupId:t});return}Object.entries(r).forEach(([s,o])=>{i_(o,AM(e,s),t,i)})})}function AM(n,e){let t=n;return e.split(r_).forEach(i=>{t.nextPart.has(i)||t.nextPart.set(i,{nextPart:new Map,validators:[]}),t=t.nextPart.get(i)}),t}function kL(n){return n.isThemeGetter}function LL(n,e){return e?n.map(([t,i])=>{let r=i.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,a])=>[e+o,a])):s);return[t,r]}):n}function DL(n){if(n<1)return{get:()=>{},set:()=>{}};let e=0,t=new Map,i=new Map;function r(s,o){t.set(s,o),e++,e>n&&(e=0,i=t,t=new Map)}return{get(s){let o=t.get(s);if(o!==void 0)return o;if((o=i.get(s))!==void 0)return r(s,o),o},set(s,o){t.has(s)?t.set(s,o):r(s,o)}}}var CM="!";function NL(n){let{separator:e,experimentalParseClassName:t}=n,i=e.length===1,r=e[0],s=e.length;function o(a){let l=[],c=0,u=0,d;for(let y=0;yu?d-u:void 0;return{modifiers:l,hasImportantModifier:m,baseClassName:p,maybePostfixModifierPosition:_}}return t?function(l){return t({className:l,parseClassName:o})}:o}function FL(n){if(n.length<=1)return n;let e=[],t=[];return n.forEach(i=>{i[0]==="["?(e.push(...t.sort(),i),t=[]):t.push(i)}),e.push(...t.sort()),e}function OL(n){return{cache:DL(n.cacheSize),parseClassName:NL(n),...PL(n)}}var BL=/\s+/;function UL(n,e){let{parseClassName:t,getClassGroupId:i,getConflictingClassGroupIds:r}=e,s=new Set;return n.trim().split(BL).map(o=>{let{modifiers:a,hasImportantModifier:l,baseClassName:c,maybePostfixModifierPosition:u}=t(o),d=!!u,f=i(d?c.substring(0,u):c);if(!f){if(!d)return{isTailwindClass:!1,originalClassName:o};if(f=i(c),!f)return{isTailwindClass:!1,originalClassName:o};d=!1}let m=FL(a).join(":");return{isTailwindClass:!0,modifierId:l?m+CM:m,classGroupId:f,originalClassName:o,hasPostfixModifier:d}}).reverse().filter(o=>{if(!o.isTailwindClass)return!0;let{modifierId:a,classGroupId:l,hasPostfixModifier:c}=o,u=a+l;return s.has(u)?!1:(s.add(u),r(l,c).forEach(d=>s.add(a+d)),!0)}).reverse().map(o=>o.originalClassName).join(" ")}function zL(){let n=0,e,t,i="";for(;nd(u),n());return t=OL(c),i=t.cache.get,r=t.cache.set,s=a,a(l)}function a(l){let c=i(l);if(c)return c;let u=UL(l,t);return r(l,u),u}return function(){return s(zL.apply(null,arguments))}}function cn(n){let e=t=>t[n]||[];return e.isThemeGetter=!0,e}var TM=/^\[(?:([a-z-]+):)?(.+)\]$/i,HL=/^\d+\/\d+$/,GL=new Set(["px","full","screen"]),$L=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,WL=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,jL=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,XL=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,qL=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/;function Bs(n){return Ma(n)||GL.has(n)||HL.test(n)}function Do(n){return Gl(n,"length",nD)}function Ma(n){return!!n&&!Number.isNaN(Number(n))}function op(n){return Gl(n,"number",Ma)}function uh(n){return!!n&&Number.isInteger(Number(n))}function YL(n){return n.endsWith("%")&&Ma(n.slice(0,-1))}function kt(n){return TM.test(n)}function No(n){return $L.test(n)}var ZL=new Set(["length","size","percentage"]);function KL(n){return Gl(n,ZL,PM)}function JL(n){return Gl(n,"position",PM)}var QL=new Set(["image","url"]);function eD(n){return Gl(n,QL,rD)}function tD(n){return Gl(n,"",iD)}function hh(){return!0}function Gl(n,e,t){let i=TM.exec(n);return i?i[1]?typeof e=="string"?i[1]===e:e.has(i[1]):t(i[2]):!1}function nD(n){return WL.test(n)&&!jL.test(n)}function PM(){return!1}function iD(n){return XL.test(n)}function rD(n){return qL.test(n)}function sD(){let n=cn("colors"),e=cn("spacing"),t=cn("blur"),i=cn("brightness"),r=cn("borderColor"),s=cn("borderRadius"),o=cn("borderSpacing"),a=cn("borderWidth"),l=cn("contrast"),c=cn("grayscale"),u=cn("hueRotate"),d=cn("invert"),f=cn("gap"),m=cn("gradientColorStops"),p=cn("gradientColorStopPositions"),_=cn("inset"),y=cn("margin"),g=cn("opacity"),b=cn("padding"),h=cn("saturate"),v=cn("scale"),S=cn("sepia"),x=cn("skew"),w=cn("space"),A=cn("translate"),M=()=>["auto","contain","none"],T=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto",kt,e],C=()=>[kt,e],P=()=>["",Bs,Do],E=()=>["auto",Ma,kt],I=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],O=()=>["solid","dashed","dotted","double","none"],D=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],N=()=>["start","end","center","between","around","evenly","stretch"],H=()=>["","0",kt],z=()=>["auto","avoid","all","avoid-page","page","left","right","column"],L=()=>[Ma,op],F=()=>[Ma,kt];return{cacheSize:500,separator:":",theme:{colors:[hh],spacing:[Bs,Do],blur:["none","",No,kt],brightness:L(),borderColor:[n],borderRadius:["none","","full",No,kt],borderSpacing:C(),borderWidth:P(),contrast:L(),grayscale:H(),hueRotate:F(),invert:H(),gap:C(),gradientColorStops:[n],gradientColorStopPositions:[YL,Do],inset:R(),margin:R(),opacity:L(),padding:C(),saturate:L(),scale:L(),sepia:H(),skew:F(),space:C(),translate:C()},classGroups:{aspect:[{aspect:["auto","square","video",kt]}],container:["container"],columns:[{columns:[No]}],"break-after":[{"break-after":z()}],"break-before":[{"break-before":z()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...I(),kt]}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[_]}],"inset-x":[{"inset-x":[_]}],"inset-y":[{"inset-y":[_]}],start:[{start:[_]}],end:[{end:[_]}],top:[{top:[_]}],right:[{right:[_]}],bottom:[{bottom:[_]}],left:[{left:[_]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",uh,kt]}],basis:[{basis:R()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",kt]}],grow:[{grow:H()}],shrink:[{shrink:H()}],order:[{order:["first","last","none",uh,kt]}],"grid-cols":[{"grid-cols":[hh]}],"col-start-end":[{col:["auto",{span:["full",uh,kt]},kt]}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":[hh]}],"row-start-end":[{row:["auto",{span:[uh,kt]},kt]}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",kt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",kt]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...N()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...N(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...N(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[y]}],mx:[{mx:[y]}],my:[{my:[y]}],ms:[{ms:[y]}],me:[{me:[y]}],mt:[{mt:[y]}],mr:[{mr:[y]}],mb:[{mb:[y]}],ml:[{ml:[y]}],"space-x":[{"space-x":[w]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[w]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",kt,e]}],"min-w":[{"min-w":[kt,e,"min","max","fit"]}],"max-w":[{"max-w":[kt,e,"none","full","min","max","fit","prose",{screen:[No]},No]}],h:[{h:[kt,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[kt,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[kt,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[kt,e,"auto","min","max","fit"]}],"font-size":[{text:["base",No,Do]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",op]}],"font-family":[{font:[hh]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",kt]}],"line-clamp":[{"line-clamp":["none",Ma,op]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Bs,kt]}],"list-image":[{"list-image":["none",kt]}],"list-style-type":[{list:["none","disc","decimal",kt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[n]}],"placeholder-opacity":[{"placeholder-opacity":[g]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[n]}],"text-opacity":[{"text-opacity":[g]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...O(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Bs,Do]}],"underline-offset":[{"underline-offset":["auto",Bs,kt]}],"text-decoration-color":[{decoration:[n]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",kt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",kt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[g]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...I(),JL]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",KL]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},eD]}],"bg-color":[{bg:[n]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[g]}],"border-style":[{border:[...O(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[g]}],"divide-style":[{divide:O()}],"border-color":[{border:[r]}],"border-color-x":[{"border-x":[r]}],"border-color-y":[{"border-y":[r]}],"border-color-t":[{"border-t":[r]}],"border-color-r":[{"border-r":[r]}],"border-color-b":[{"border-b":[r]}],"border-color-l":[{"border-l":[r]}],"divide-color":[{divide:[r]}],"outline-style":[{outline:["",...O()]}],"outline-offset":[{"outline-offset":[Bs,kt]}],"outline-w":[{outline:[Bs,Do]}],"outline-color":[{outline:[n]}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[n]}],"ring-opacity":[{"ring-opacity":[g]}],"ring-offset-w":[{"ring-offset":[Bs,Do]}],"ring-offset-color":[{"ring-offset":[n]}],shadow:[{shadow:["","inner","none",No,tD]}],"shadow-color":[{shadow:[hh]}],opacity:[{opacity:[g]}],"mix-blend":[{"mix-blend":[...D(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":D()}],filter:[{filter:["","none"]}],blur:[{blur:[t]}],brightness:[{brightness:[i]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",No,kt]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[h]}],sepia:[{sepia:[S]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[t]}],"backdrop-brightness":[{"backdrop-brightness":[i]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[g]}],"backdrop-saturate":[{"backdrop-saturate":[h]}],"backdrop-sepia":[{"backdrop-sepia":[S]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",kt]}],duration:[{duration:F()}],ease:[{ease:["linear","in","out","in-out",kt]}],delay:[{delay:F()}],animate:[{animate:["none","spin","ping","pulse","bounce",kt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[v]}],"scale-x":[{"scale-x":[v]}],"scale-y":[{"scale-y":[v]}],rotate:[{rotate:[uh,kt]}],"translate-x":[{"translate-x":[A]}],"translate-y":[{"translate-y":[A]}],"skew-x":[{"skew-x":[x]}],"skew-y":[{"skew-y":[x]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",kt]}],accent:[{accent:["auto",n]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",kt]}],"caret-color":[{caret:[n]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",kt]}],fill:[{fill:[n,"none"]}],"stroke-w":[{stroke:[Bs,Do,op]}],stroke:[{stroke:[n,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}}var IM=VL(sD);function Mn(...n){return IM(wM(n))}var Av="158";var oD=0,RM=1,aD=2;var lE=1,lD=2,$s=3,ds=0,vi=1,Hr=2;var us=0,hs=1,Dp=2,kM=3,LM=4,cD=5,ka=100,uD=101,hD=102,DM=103,NM=104,dD=200,fD=201,pD=202,mD=203,O_=204,B_=205,gD=206,yD=207,_D=208,vD=209,xD=210,bD=211,wD=212,SD=213,AD=214,MD=0,CD=1,ED=2,Np=3,TD=4,PD=5,ID=6,RD=7,cE=0,kD=1,LD=2,Ho=0,DD=1,ND=2,FD=3,OD=4,BD=5;var uE=300,uc=301,hc=302,U_=303,z_=304,cm=306,V_=1e3,Gr=1001,H_=1002,en=1003,FM=1004;var s_=1005;var li=1006,UD=1007;var xh=1008;var wr=1009,zD=1010,VD=1011,Mv=1012,hE=1013,Vo=1014,br=1015,Go=1016,dE=1017,fE=1018,Da=1020,HD=1021,Ei=1023,GD=1024,$D=1025,Na=1026,dc=1027,WD=1028,pE=1029,jD=1030,mE=1031,gE=1033,o_=33776,a_=33777,l_=33778,c_=33779,OM=35840,BM=35841,UM=35842,zM=35843,XD=36196,VM=37492,HM=37496,GM=37808,$M=37809,WM=37810,jM=37811,XM=37812,qM=37813,YM=37814,ZM=37815,KM=37816,JM=37817,QM=37818,eC=37819,tC=37820,nC=37821,u_=36492,iC=36494,rC=36495,qD=36283,sC=36284,oC=36285,aC=36286;var Fp=2300,Op=2301,h_=2302,lC=2400,cC=2401,uC=2402;var yE=3e3,Fa=3001,YD=3200,ZD=3201,KD=0,JD=1,xr="",ai="srgb",Xs="srgb-linear",Cv="display-p3",um="display-p3-linear",Bp="linear",un="srgb",Up="rec709",zp="p3";var $l=7680;var hC=519,QD=512,e4=513,t4=514,n4=515,i4=516,r4=517,s4=518,o4=519,qs=35044,Ha=35048;var dC="300 es",G_=1035,js=2e3,Vp=2001,$o=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let r=this._listeners[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let i=this._listeners[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let s=0,o=r.length;s>8&255]+yi[n>>16&255]+yi[n>>24&255]+"-"+yi[e&255]+yi[e>>8&255]+"-"+yi[e>>16&15|64]+yi[e>>24&255]+"-"+yi[t&63|128]+yi[t>>8&255]+"-"+yi[t>>16&255]+yi[t>>24&255]+yi[i&255]+yi[i>>8&255]+yi[i>>16&255]+yi[i>>24&255]).toLowerCase()}function Ui(n,e,t){return Math.max(e,Math.min(t,n))}function a4(n,e){return(n%e+e)%e}function d_(n,e,t){return(1-t)*n+t*e}function fC(n){return(n&n-1)===0&&n!==0}function W_(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function dh(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Bi(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}var Et=class n{constructor(e=0,t=0){n.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Ui(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Lt=class n{constructor(e,t,i,r,s,o,a,l,c){n.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,l,c)}set(e,t,i,r,s,o,a,l,c){let u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],u=i[4],d=i[7],f=i[2],m=i[5],p=i[8],_=r[0],y=r[3],g=r[6],b=r[1],h=r[4],v=r[7],S=r[2],x=r[5],w=r[8];return s[0]=o*_+a*b+l*S,s[3]=o*y+a*h+l*x,s[6]=o*g+a*v+l*w,s[1]=c*_+u*b+d*S,s[4]=c*y+u*h+d*x,s[7]=c*g+u*v+d*w,s[2]=f*_+m*b+p*S,s[5]=f*y+m*h+p*x,s[8]=f*g+m*v+p*w,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-i*s*u+i*a*l+r*s*c-r*o*l}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],d=u*o-a*c,f=a*l-u*s,m=c*s-o*l,p=t*d+i*f+r*m;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/p;return e[0]=d*_,e[1]=(r*c-u*i)*_,e[2]=(a*i-r*o)*_,e[3]=f*_,e[4]=(u*t-r*l)*_,e[5]=(r*s-a*t)*_,e[6]=m*_,e[7]=(i*l-c*t)*_,e[8]=(o*t-i*s)*_,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,o,a){let l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*o+c*a)+o+e,-r*c,r*l,-r*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(f_.makeScale(e,t)),this}rotate(e){return this.premultiply(f_.makeRotation(-e)),this}translate(e,t){return this.premultiply(f_.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},f_=new Lt;function _E(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Hp(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function l4(){let n=Hp("canvas");return n.style.display="block",n}var pC={};function _h(n){n in pC||(pC[n]=!0,console.warn(n))}var mC=new Lt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),gC=new Lt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ap={[Xs]:{transfer:Bp,primaries:Up,toReference:n=>n,fromReference:n=>n},[ai]:{transfer:un,primaries:Up,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[um]:{transfer:Bp,primaries:zp,toReference:n=>n.applyMatrix3(gC),fromReference:n=>n.applyMatrix3(mC)},[Cv]:{transfer:un,primaries:zp,toReference:n=>n.convertSRGBToLinear().applyMatrix3(gC),fromReference:n=>n.applyMatrix3(mC).convertLinearToSRGB()}},c4=new Set([Xs,um]),Qt={enabled:!0,_workingColorSpace:Xs,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(n){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!n},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!c4.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;let i=ap[e].toReference,r=ap[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return ap[n].primaries},getTransfer:function(n){return n===xr?Bp:ap[n].transfer}};function lc(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function p_(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var Wl,Gp=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Wl===void 0&&(Wl=Hp("canvas")),Wl.width=e.width,Wl.height=e.height;let i=Wl.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Wl}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Hp("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==uE)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case V_:e.x=e.x-Math.floor(e.x);break;case Gr:e.x=e.x<0?0:1;break;case H_:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case V_:e.y=e.y-Math.floor(e.y);break;case Gr:e.y=e.y<0?0:1;break;case H_:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return _h("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===ai?Fa:yE}set encoding(e){_h("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Fa?ai:xr}};tr.DEFAULT_IMAGE=null;tr.DEFAULT_MAPPING=uE;tr.DEFAULT_ANISOTROPY=1;var ti=class n{constructor(e=0,t=0,i=0,r=1){n.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s,l=e.elements,c=l[0],u=l[4],d=l[8],f=l[1],m=l[5],p=l[9],_=l[2],y=l[6],g=l[10];if(Math.abs(u-f)<.01&&Math.abs(d-_)<.01&&Math.abs(p-y)<.01){if(Math.abs(u+f)<.1&&Math.abs(d+_)<.1&&Math.abs(p+y)<.1&&Math.abs(c+m+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let h=(c+1)/2,v=(m+1)/2,S=(g+1)/2,x=(u+f)/4,w=(d+_)/4,A=(p+y)/4;return h>v&&h>S?h<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(h),r=x/i,s=w/i):v>S?v<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(v),i=x/r,s=A/r):S<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(S),i=w/s,r=A/s),this.set(i,r,s,t),this}let b=Math.sqrt((y-p)*(y-p)+(d-_)*(d-_)+(f-u)*(f-u));return Math.abs(b)<.001&&(b=1),this.x=(y-p)/b,this.y=(d-_)/b,this.z=(f-u)/b,this.w=Math.acos((c+m+g-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},j_=class extends $o{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new ti(0,0,e,t),this.scissorTest=!1,this.viewport=new ti(0,0,e,t);let r={width:e,height:t,depth:1};i.encoding!==void 0&&(_h("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===Fa?ai:xr),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:li,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new tr(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps,this.texture.internalFormat=i.internalFormat,this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}setSize(e,t,i=1){(this.width!==e||this.height!==t||this.depth!==i)&&(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new $p(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},nr=class extends j_{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},Wp=class extends tr{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=en,this.minFilter=en,this.wrapR=Gr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var X_=class extends tr{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=en,this.minFilter=en,this.wrapR=Gr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Xn=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,o,a){let l=i[r+0],c=i[r+1],u=i[r+2],d=i[r+3],f=s[o+0],m=s[o+1],p=s[o+2],_=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d;return}if(a===1){e[t+0]=f,e[t+1]=m,e[t+2]=p,e[t+3]=_;return}if(d!==_||l!==f||c!==m||u!==p){let y=1-a,g=l*f+c*m+u*p+d*_,b=g>=0?1:-1,h=1-g*g;if(h>Number.EPSILON){let S=Math.sqrt(h),x=Math.atan2(S,g*b);y=Math.sin(y*x)/S,a=Math.sin(a*x)/S}let v=a*b;if(l=l*y+f*v,c=c*y+m*v,u=u*y+p*v,d=d*y+_*v,y===1-a){let S=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=S,c*=S,u*=S,d*=S}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,s,o){let a=i[r],l=i[r+1],c=i[r+2],u=i[r+3],d=s[o],f=s[o+1],m=s[o+2],p=s[o+3];return e[t]=a*p+u*d+l*m-c*f,e[t+1]=l*p+u*f+c*d-a*m,e[t+2]=c*p+u*m+a*f-l*d,e[t+3]=u*p-a*d-l*f-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){let i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(i/2),u=a(r/2),d=a(s/2),f=l(i/2),m=l(r/2),p=l(s/2);switch(o){case"XYZ":this._x=f*u*d+c*m*p,this._y=c*m*d-f*u*p,this._z=c*u*p+f*m*d,this._w=c*u*d-f*m*p;break;case"YXZ":this._x=f*u*d+c*m*p,this._y=c*m*d-f*u*p,this._z=c*u*p-f*m*d,this._w=c*u*d+f*m*p;break;case"ZXY":this._x=f*u*d-c*m*p,this._y=c*m*d+f*u*p,this._z=c*u*p+f*m*d,this._w=c*u*d-f*m*p;break;case"ZYX":this._x=f*u*d-c*m*p,this._y=c*m*d+f*u*p,this._z=c*u*p-f*m*d,this._w=c*u*d+f*m*p;break;case"YZX":this._x=f*u*d+c*m*p,this._y=c*m*d+f*u*p,this._z=c*u*p-f*m*d,this._w=c*u*d-f*m*p;break;case"XZY":this._x=f*u*d-c*m*p,this._y=c*m*d-f*u*p,this._z=c*u*p+f*m*d,this._w=c*u*d+f*m*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],d=t[10],f=i+a+d;if(f>0){let m=.5/Math.sqrt(f+1);this._w=.25/m,this._x=(u-l)*m,this._y=(s-c)*m,this._z=(o-r)*m}else if(i>a&&i>d){let m=2*Math.sqrt(1+i-a-d);this._w=(u-l)/m,this._x=.25*m,this._y=(r+o)/m,this._z=(s+c)/m}else if(a>d){let m=2*Math.sqrt(1+a-i-d);this._w=(s-c)/m,this._x=(r+o)/m,this._y=.25*m,this._z=(l+u)/m}else{let m=2*Math.sqrt(1+d-i-a);this._w=(o-r)/m,this._x=(s+c)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return iMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ui(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+o*a+r*c-s*l,this._y=r*u+o*l+s*a-i*c,this._z=s*u+o*c+i*l-r*a,this._w=o*u-i*a-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,s=this._z,o=this._w,a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let m=1-t;return this._w=m*o+t*this._w,this._x=m*i+t*this._x,this._y=m*r+t*this._y,this._z=m*s+t*this._z,this.normalize(),this._onChangeCallback(),this}let c=Math.sqrt(l),u=Math.atan2(c,a),d=Math.sin((1-t)*u)/c,f=Math.sin(t*u)/c;return this._w=o*d+this._w*f,this._x=i*d+this._x*f,this._y=r*d+this._y*f,this._z=s*d+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),r=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(r),i*Math.sin(s),i*Math.cos(s),t*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},W=class n{constructor(e=0,t=0,i=0){n.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(yC.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(yC.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*r-a*i),u=2*(a*t-s*r),d=2*(s*i-o*t);return this.x=t+l*c+o*d-a*u,this.y=i+l*u+a*c-s*d,this.z=r+l*d+s*u-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=r*l-s*a,this.y=s*o-i*l,this.z=i*a-r*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return g_.copy(this).projectOnVector(e),this.sub(g_)}reflect(e){return this.sub(g_.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Ui(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},g_=new W,yC=new Xn,sn=class{constructor(e=new W(1/0,1/0,1/0),t=new W(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Ur),Ur.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(fh),cp.subVectors(this.max,fh),jl.subVectors(e.a,fh),Xl.subVectors(e.b,fh),ql.subVectors(e.c,fh),Fo.subVectors(Xl,jl),Oo.subVectors(ql,Xl),Ca.subVectors(jl,ql);let t=[0,-Fo.z,Fo.y,0,-Oo.z,Oo.y,0,-Ca.z,Ca.y,Fo.z,0,-Fo.x,Oo.z,0,-Oo.x,Ca.z,0,-Ca.x,-Fo.y,Fo.x,0,-Oo.y,Oo.x,0,-Ca.y,Ca.x,0];return!y_(t,jl,Xl,ql,cp)||(t=[1,0,0,0,1,0,0,0,1],!y_(t,jl,Xl,ql,cp))?!1:(up.crossVectors(Fo,Oo),t=[up.x,up.y,up.z],y_(t,jl,Xl,ql,cp))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ur).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ur).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Us[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Us[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Us[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Us[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Us[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Us[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Us[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Us[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Us),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Us=[new W,new W,new W,new W,new W,new W,new W,new W],Ur=new W,lp=new sn,jl=new W,Xl=new W,ql=new W,Fo=new W,Oo=new W,Ca=new W,fh=new W,cp=new W,up=new W,Ea=new W;function y_(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){Ea.fromArray(n,s);let a=r.x*Math.abs(Ea.x)+r.y*Math.abs(Ea.y)+r.z*Math.abs(Ea.z),l=e.dot(Ea),c=t.dot(Ea),u=i.dot(Ea);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var d4=new sn,ph=new W,__=new W,Oa=class{constructor(e=new W,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):d4.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ph.subVectors(e,this.center);let t=ph.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(ph,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(__.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ph.copy(e.center).add(__)),this.expandByPoint(ph.copy(e.center).sub(__))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},zs=new W,v_=new W,hp=new W,Bo=new W,x_=new W,dp=new W,b_=new W,bh=class{constructor(e=new W,t=new W(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,zs)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=zs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(zs.copy(this.origin).addScaledVector(this.direction,t),zs.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){v_.copy(e).add(t).multiplyScalar(.5),hp.copy(t).sub(e).normalize(),Bo.copy(this.origin).sub(v_);let s=e.distanceTo(t)*.5,o=-this.direction.dot(hp),a=Bo.dot(this.direction),l=-Bo.dot(hp),c=Bo.lengthSq(),u=Math.abs(1-o*o),d,f,m,p;if(u>0)if(d=o*l-a,f=o*a-l,p=s*u,d>=0)if(f>=-p)if(f<=p){let _=1/u;d*=_,f*=_,m=d*(d+o*f+2*a)+f*(o*d+f+2*l)+c}else f=s,d=Math.max(0,-(o*f+a)),m=-d*d+f*(f+2*l)+c;else f=-s,d=Math.max(0,-(o*f+a)),m=-d*d+f*(f+2*l)+c;else f<=-p?(d=Math.max(0,-(-o*s+a)),f=d>0?-s:Math.min(Math.max(-s,-l),s),m=-d*d+f*(f+2*l)+c):f<=p?(d=0,f=Math.min(Math.max(-s,-l),s),m=f*(f+2*l)+c):(d=Math.max(0,-(o*s+a)),f=d>0?s:Math.min(Math.max(-s,-l),s),m=-d*d+f*(f+2*l)+c);else f=o>0?-s:s,d=Math.max(0,-(o*f+a)),m=-d*d+f*(f+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(v_).addScaledVector(hp,f),m}intersectSphere(e,t){zs.subVectors(e.center,this.origin);let i=zs.dot(this.direction),r=zs.dot(zs)-i*i,s=e.radius*e.radius;if(r>s)return null;let o=Math.sqrt(s-r),a=i-o,l=i+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,l,c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,f=this.origin;return c>=0?(i=(e.min.x-f.x)*c,r=(e.max.x-f.x)*c):(i=(e.max.x-f.x)*c,r=(e.min.x-f.x)*c),u>=0?(s=(e.min.y-f.y)*u,o=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,o=(e.min.y-f.y)*u),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o=0?(a=(e.min.z-f.z)*d,l=(e.max.z-f.z)*d):(a=(e.max.z-f.z)*d,l=(e.min.z-f.z)*d),i>l||a>r)||((a>i||i!==i)&&(i=a),(l=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,zs)!==null}intersectTriangle(e,t,i,r,s){x_.subVectors(t,e),dp.subVectors(i,e),b_.crossVectors(x_,dp);let o=this.direction.dot(b_),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Bo.subVectors(this.origin,e);let l=a*this.direction.dot(dp.crossVectors(Bo,dp));if(l<0)return null;let c=a*this.direction.dot(x_.cross(Bo));if(c<0||l+c>o)return null;let u=-a*Bo.dot(b_);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},qe=class n{constructor(e,t,i,r,s,o,a,l,c,u,d,f,m,p,_,y){n.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,l,c,u,d,f,m,p,_,y)}set(e,t,i,r,s,o,a,l,c,u,d,f,m,p,_,y){let g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=s,g[5]=o,g[9]=a,g[13]=l,g[2]=c,g[6]=u,g[10]=d,g[14]=f,g[3]=m,g[7]=p,g[11]=_,g[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new n().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/Yl.setFromMatrixColumn(e,0).length(),s=1/Yl.setFromMatrixColumn(e,1).length(),o=1/Yl.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){let f=o*u,m=o*d,p=a*u,_=a*d;t[0]=l*u,t[4]=-l*d,t[8]=c,t[1]=m+p*c,t[5]=f-_*c,t[9]=-a*l,t[2]=_-f*c,t[6]=p+m*c,t[10]=o*l}else if(e.order==="YXZ"){let f=l*u,m=l*d,p=c*u,_=c*d;t[0]=f+_*a,t[4]=p*a-m,t[8]=o*c,t[1]=o*d,t[5]=o*u,t[9]=-a,t[2]=m*a-p,t[6]=_+f*a,t[10]=o*l}else if(e.order==="ZXY"){let f=l*u,m=l*d,p=c*u,_=c*d;t[0]=f-_*a,t[4]=-o*d,t[8]=p+m*a,t[1]=m+p*a,t[5]=o*u,t[9]=_-f*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let f=o*u,m=o*d,p=a*u,_=a*d;t[0]=l*u,t[4]=p*c-m,t[8]=f*c+_,t[1]=l*d,t[5]=_*c+f,t[9]=m*c-p,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let f=o*l,m=o*c,p=a*l,_=a*c;t[0]=l*u,t[4]=_-f*d,t[8]=p*d+m,t[1]=d,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=m*d+p,t[10]=f-_*d}else if(e.order==="XZY"){let f=o*l,m=o*c,p=a*l,_=a*c;t[0]=l*u,t[4]=-d,t[8]=c*u,t[1]=f*d+_,t[5]=o*u,t[9]=m*d-p,t[2]=p*d-m,t[6]=a*u,t[10]=_*d+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(f4,e,p4)}lookAt(e,t,i){let r=this.elements;return Ji.subVectors(e,t),Ji.lengthSq()===0&&(Ji.z=1),Ji.normalize(),Uo.crossVectors(i,Ji),Uo.lengthSq()===0&&(Math.abs(i.z)===1?Ji.x+=1e-4:Ji.z+=1e-4,Ji.normalize(),Uo.crossVectors(i,Ji)),Uo.normalize(),fp.crossVectors(Ji,Uo),r[0]=Uo.x,r[4]=fp.x,r[8]=Ji.x,r[1]=Uo.y,r[5]=fp.y,r[9]=Ji.y,r[2]=Uo.z,r[6]=fp.z,r[10]=Ji.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],u=i[1],d=i[5],f=i[9],m=i[13],p=i[2],_=i[6],y=i[10],g=i[14],b=i[3],h=i[7],v=i[11],S=i[15],x=r[0],w=r[4],A=r[8],M=r[12],T=r[1],R=r[5],C=r[9],P=r[13],E=r[2],I=r[6],O=r[10],D=r[14],N=r[3],H=r[7],z=r[11],L=r[15];return s[0]=o*x+a*T+l*E+c*N,s[4]=o*w+a*R+l*I+c*H,s[8]=o*A+a*C+l*O+c*z,s[12]=o*M+a*P+l*D+c*L,s[1]=u*x+d*T+f*E+m*N,s[5]=u*w+d*R+f*I+m*H,s[9]=u*A+d*C+f*O+m*z,s[13]=u*M+d*P+f*D+m*L,s[2]=p*x+_*T+y*E+g*N,s[6]=p*w+_*R+y*I+g*H,s[10]=p*A+_*C+y*O+g*z,s[14]=p*M+_*P+y*D+g*L,s[3]=b*x+h*T+v*E+S*N,s[7]=b*w+h*R+v*I+S*H,s[11]=b*A+h*C+v*O+S*z,s[15]=b*M+h*P+v*D+S*L,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],d=e[6],f=e[10],m=e[14],p=e[3],_=e[7],y=e[11],g=e[15];return p*(+s*l*d-r*c*d-s*a*f+i*c*f+r*a*m-i*l*m)+_*(+t*l*m-t*c*f+s*o*f-r*o*m+r*c*u-s*l*u)+y*(+t*c*d-t*a*m-s*o*d+i*o*m+s*a*u-i*c*u)+g*(-r*a*u-t*l*d+t*a*f+r*o*d-i*o*f+i*l*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],d=e[9],f=e[10],m=e[11],p=e[12],_=e[13],y=e[14],g=e[15],b=d*y*c-_*f*c+_*l*m-a*y*m-d*l*g+a*f*g,h=p*f*c-u*y*c-p*l*m+o*y*m+u*l*g-o*f*g,v=u*_*c-p*d*c+p*a*m-o*_*m-u*a*g+o*d*g,S=p*d*l-u*_*l-p*a*f+o*_*f+u*a*y-o*d*y,x=t*b+i*h+r*v+s*S;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let w=1/x;return e[0]=b*w,e[1]=(_*f*s-d*y*s-_*r*m+i*y*m+d*r*g-i*f*g)*w,e[2]=(a*y*s-_*l*s+_*r*c-i*y*c-a*r*g+i*l*g)*w,e[3]=(d*l*s-a*f*s-d*r*c+i*f*c+a*r*m-i*l*m)*w,e[4]=h*w,e[5]=(u*y*s-p*f*s+p*r*m-t*y*m-u*r*g+t*f*g)*w,e[6]=(p*l*s-o*y*s-p*r*c+t*y*c+o*r*g-t*l*g)*w,e[7]=(o*f*s-u*l*s+u*r*c-t*f*c-o*r*m+t*l*m)*w,e[8]=v*w,e[9]=(p*d*s-u*_*s-p*i*m+t*_*m+u*i*g-t*d*g)*w,e[10]=(o*_*s-p*a*s+p*i*c-t*_*c-o*i*g+t*a*g)*w,e[11]=(u*a*s-o*d*s-u*i*c+t*d*c+o*i*m-t*a*m)*w,e[12]=S*w,e[13]=(u*_*r-p*d*r+p*i*f-t*_*f-u*i*y+t*d*y)*w,e[14]=(p*a*r-o*_*r-p*i*l+t*_*l+o*i*y-t*a*y)*w,e[15]=(o*d*r-u*a*r+u*i*l-t*d*l-o*i*f+t*a*f)*w,this}scale(e){let t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+i,c*a-r*l,c*l+r*a,0,c*a+r*l,u*a+i,u*l-r*o,0,c*l-r*a,u*l+r*o,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,d=a+a,f=s*c,m=s*u,p=s*d,_=o*u,y=o*d,g=a*d,b=l*c,h=l*u,v=l*d,S=i.x,x=i.y,w=i.z;return r[0]=(1-(_+g))*S,r[1]=(m+v)*S,r[2]=(p-h)*S,r[3]=0,r[4]=(m-v)*x,r[5]=(1-(f+g))*x,r[6]=(y+b)*x,r[7]=0,r[8]=(p+h)*w,r[9]=(y-b)*w,r[10]=(1-(f+_))*w,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,s=Yl.set(r[0],r[1],r[2]).length(),o=Yl.set(r[4],r[5],r[6]).length(),a=Yl.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],zr.copy(this);let c=1/s,u=1/o,d=1/a;return zr.elements[0]*=c,zr.elements[1]*=c,zr.elements[2]*=c,zr.elements[4]*=u,zr.elements[5]*=u,zr.elements[6]*=u,zr.elements[8]*=d,zr.elements[9]*=d,zr.elements[10]*=d,t.setFromRotationMatrix(zr),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=js){let l=this.elements,c=2*s/(t-e),u=2*s/(i-r),d=(t+e)/(t-e),f=(i+r)/(i-r),m,p;if(a===js)m=-(o+s)/(o-s),p=-2*o*s/(o-s);else if(a===Vp)m=-o/(o-s),p=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=p,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=js){let l=this.elements,c=1/(t-e),u=1/(i-r),d=1/(o-s),f=(t+e)*c,m=(i+r)*u,p,_;if(a===js)p=(o+s)*d,_=-2*d;else if(a===Vp)p=s*d,_=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=_,l[14]=-p,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},Yl=new W,zr=new qe,f4=new W(0,0,0),p4=new W(1,1,1),Uo=new W,fp=new W,Ji=new W,_C=new qe,vC=new Xn,Ba=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,s=r[0],o=r[4],a=r[8],l=r[1],c=r[5],u=r[9],d=r[2],f=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(Ui(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ui(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ui(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-d,m),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Ui(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(f,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Ui(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(a,m));break;case"XZY":this._z=Math.asin(-Ui(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return _C.makeRotationFromQuaternion(e),this.setFromRotationMatrix(_C,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return vC.setFromEuler(this),this.setFromQuaternion(vC,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Ba.DEFAULT_ORDER="XYZ";var jp=class{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(i=i.concat(o))}return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,e,g4),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,y4,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){r.children=[];for(let a=0;a0){r.animations=[];for(let a=0;a0&&(i.geometries=a),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),f.length>0&&(i.skeletons=f),m.length>0&&(i.animations=m),p.length>0&&(i.nodes=p)}return i.object=r,i;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Vr.subVectors(r,t),Hs.subVectors(i,t),w_.subVectors(e,t);let o=Vr.dot(Vr),a=Vr.dot(Hs),l=Vr.dot(w_),c=Hs.dot(Hs),u=Hs.dot(w_),d=o*c-a*a;if(d===0)return s.set(-2,-1,-1);let f=1/d,m=(c*l-a*u)*f,p=(o*u-a*l)*f;return s.set(1-m-p,p,m)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Gs),Gs.x>=0&&Gs.y>=0&&Gs.x+Gs.y<=1}static getUV(e,t,i,r,s,o,a,l){return mp===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),mp=!0),this.getInterpolation(e,t,i,r,s,o,a,l)}static getInterpolation(e,t,i,r,s,o,a,l){return this.getBarycoord(e,t,i,r,Gs),l.setScalar(0),l.addScaledVector(s,Gs.x),l.addScaledVector(o,Gs.y),l.addScaledVector(a,Gs.z),l}static isFrontFacing(e,t,i,r){return Vr.subVectors(i,t),Hs.subVectors(e,t),Vr.cross(Hs).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Vr.subVectors(this.c,this.b),Hs.subVectors(this.a,this.b),Vr.cross(Hs).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,r,s){return mp===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),mp=!0),n.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}getInterpolation(e,t,i,r,s){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,s=this.c,o,a;Kl.subVectors(r,i),Jl.subVectors(s,i),S_.subVectors(e,i);let l=Kl.dot(S_),c=Jl.dot(S_);if(l<=0&&c<=0)return t.copy(i);A_.subVectors(e,r);let u=Kl.dot(A_),d=Jl.dot(A_);if(u>=0&&d<=u)return t.copy(r);let f=l*d-u*c;if(f<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(i).addScaledVector(Kl,o);M_.subVectors(e,s);let m=Kl.dot(M_),p=Jl.dot(M_);if(p>=0&&m<=p)return t.copy(s);let _=m*c-l*p;if(_<=0&&c>=0&&p<=0)return a=c/(c-p),t.copy(i).addScaledVector(Jl,a);let y=u*p-m*d;if(y<=0&&d-u>=0&&m-p>=0)return AC.subVectors(s,r),a=(d-u)/(d-u+(m-p)),t.copy(r).addScaledVector(AC,a);let g=1/(y+_+f);return o=_*g,a=f*g,t.copy(i).addScaledVector(Kl,o).addScaledVector(Jl,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},vE={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},zo={h:0,s:0,l:0},gp={h:0,s:0,l:0};function C_(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}var dt=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=ai){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Qt.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=Qt.workingColorSpace){return this.r=e,this.g=t,this.b=i,Qt.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=Qt.workingColorSpace){if(e=a4(e,1),t=Ui(t,0,1),i=Ui(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,o=2*i-s;this.r=C_(o,s,e+1/3),this.g=C_(o,s,e),this.b=C_(o,s,e-1/3)}return Qt.toWorkingColorSpace(this,r),this}setStyle(e,t=ai){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=ai){let i=vE[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=lc(e.r),this.g=lc(e.g),this.b=lc(e.b),this}copyLinearToSRGB(e){return this.r=p_(e.r),this.g=p_(e.g),this.b=p_(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ai){return Qt.fromWorkingColorSpace(_i.copy(this),e),Math.round(Ui(_i.r*255,0,255))*65536+Math.round(Ui(_i.g*255,0,255))*256+Math.round(Ui(_i.b*255,0,255))}getHexString(e=ai){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Qt.workingColorSpace){Qt.fromWorkingColorSpace(_i.copy(this),t);let i=_i.r,r=_i.g,s=_i.b,o=Math.max(i,r,s),a=Math.min(i,r,s),l,c,u=(a+o)/2;if(a===o)l=0,c=0;else{let d=o-a;switch(c=u<=.5?d/(o+a):d/(2-o-a),o){case i:l=(r-s)/d+(r0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==hs&&(i.blending=this.blending),this.side!==ds&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==O_&&(i.blendSrc=this.blendSrc),this.blendDst!==B_&&(i.blendDst=this.blendDst),this.blendEquation!==ka&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Np&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==hC&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==$l&&(i.stencilFail=this.stencilFail),this.stencilZFail!==$l&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==$l&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(t){let s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Xp=class extends Wo{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new dt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=cE,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};var Un=new W,yp=new Et,gn=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=qs,this.updateRange={offset:0,count:-1},this.gpuType=br,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r0&&(e.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let l in i){let c=i[l];e.data.attributes[l]=c.toJSON(e.data)}let r={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let d=0,f=c.length;d0&&(r[l]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone(t));let r=e.attributes;for(let c in r){let u=r[c];this.setAttribute(c,u.clone(t))}let s=e.morphAttributes;for(let c in s){let u=[],d=s[c];for(let f=0,m=d.length;f0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s(e.far-e.near)**2))&&(MC.copy(s).invert(),Ta.copy(e.ray).applyMatrix4(MC),!(i.boundingBox!==null&&Ta.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Ta)))}_computeIntersections(e,t,i){let r,s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,d=s.attributes.normal,f=s.groups,m=s.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,_=f.length;p<_;p++){let y=f[p],g=o[y.materialIndex],b=Math.max(y.start,m.start),h=Math.min(a.count,Math.min(y.start+y.count,m.start+m.count));for(let v=b,S=h;vt.far?null:{distance:c,point:Ap.clone(),object:n}}function Mp(n,e,t,i,r,s,o,a,l,c){n.getVertexPosition(a,ec),n.getVertexPosition(l,tc),n.getVertexPosition(c,nc);let u=w4(n,e,t,i,ec,tc,nc,Sp);if(u){r&&(xp.fromBufferAttribute(r,a),bp.fromBufferAttribute(r,l),wp.fromBufferAttribute(r,c),u.uv=oc.getInterpolation(Sp,ec,tc,nc,xp,bp,wp,new Et)),s&&(xp.fromBufferAttribute(s,a),bp.fromBufferAttribute(s,l),wp.fromBufferAttribute(s,c),u.uv1=oc.getInterpolation(Sp,ec,tc,nc,xp,bp,wp,new Et),u.uv2=u.uv1),o&&(EC.fromBufferAttribute(o,a),TC.fromBufferAttribute(o,l),PC.fromBufferAttribute(o,c),u.normal=oc.getInterpolation(Sp,ec,tc,nc,EC,TC,PC,new W),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let d={a,b:l,c,normal:new W,materialIndex:0};oc.getNormal(ec,tc,nc,d.normal),u.face=d}return u}var Ua=class n extends Vn{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};let a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let l=[],c=[],u=[],d=[],f=0,m=0;p("z","y","x",-1,-1,i,t,e,o,s,0),p("z","y","x",1,-1,i,t,-e,o,s,1),p("x","z","y",1,1,e,i,t,r,o,2),p("x","z","y",1,-1,e,i,-t,r,o,3),p("x","y","z",1,-1,e,t,i,r,s,4),p("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new zn(c,3)),this.setAttribute("normal",new zn(u,3)),this.setAttribute("uv",new zn(d,2));function p(_,y,g,b,h,v,S,x,w,A,M){let T=v/w,R=S/A,C=v/2,P=S/2,E=x/2,I=w+1,O=A+1,D=0,N=0,H=new W;for(let z=0;z0?1:-1,u.push(H.x,H.y,H.z),d.push(F/w),d.push(1-z/A),D+=1}}for(let z=0;z0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},Zp=class extends xi{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new qe,this.projectionMatrix=new qe,this.projectionMatrixInverse=new qe,this.coordinateSystem=js}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},ci=class extends Zp{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=$_*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Lp*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return $_*2*Math.atan(Math.tan(Lp*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Lp*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*r/l,t-=o.offsetY*i/c,r*=o.width/l,i*=o.height/c}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},ic=-90,rc=1,q_=class extends xi{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new ci(ic,rc,e,t);r.layers=this.layers,this.add(r);let s=new ci(ic,rc,e,t);s.layers=this.layers,this.add(s);let o=new ci(ic,rc,e,t);o.layers=this.layers,this.add(o);let a=new ci(ic,rc,e,t);a.layers=this.layers,this.add(a);let l=new ci(ic,rc,e,t);l.layers=this.layers,this.add(l);let c=new ci(ic,rc,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,l]=t;for(let c of t)this.remove(c);if(e===js)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Vp)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,l,c,u]=this.children,d=e.getRenderTarget(),f=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let _=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,o),e.setRenderTarget(i,2,r),e.render(t,a),e.setRenderTarget(i,3,r),e.render(t,l),e.setRenderTarget(i,4,r),e.render(t,c),i.texture.generateMipmaps=_,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(d,f,m),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}},Kp=class extends tr{constructor(e,t,i,r,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:uc,super(e,t,i,r,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Y_=class extends nr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];t.encoding!==void 0&&(_h("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Fa?ai:xr),this.texture=new Kp(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:li}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},r=new Ua(5,5,5),s=new Ti({name:"CubemapFromEquirect",uniforms:fc(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:vi,blending:us});s.uniforms.tEquirect.value=t;let o=new er(r,s),a=t.minFilter;return t.minFilter===xh&&(t.minFilter=li),new q_(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,r){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,r);e.setRenderTarget(s)}},P_=new W,C4=new W,E4=new Lt,Ws=class{constructor(e=new W(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=P_.subVectors(i,t).cross(C4.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let i=e.delta(P_),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||E4.getNormalMatrix(e),r=this.coplanarPoint(P_).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Pa=new Oa,Cp=new W,wh=class{constructor(e=new Ws,t=new Ws,i=new Ws,r=new Ws,s=new Ws,o=new Ws){this.planes=[e,t,i,r,s,o]}set(e,t,i,r,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=js){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],l=r[3],c=r[4],u=r[5],d=r[6],f=r[7],m=r[8],p=r[9],_=r[10],y=r[11],g=r[12],b=r[13],h=r[14],v=r[15];if(i[0].setComponents(l-s,f-c,y-m,v-g).normalize(),i[1].setComponents(l+s,f+c,y+m,v+g).normalize(),i[2].setComponents(l+o,f+u,y+p,v+b).normalize(),i[3].setComponents(l-o,f-u,y-p,v-b).normalize(),i[4].setComponents(l-a,f-d,y-_,v-h).normalize(),t===js)i[5].setComponents(l+a,f+d,y+_,v+h).normalize();else if(t===Vp)i[5].setComponents(a,d,_,h).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Pa.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Pa.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Pa)}intersectsSprite(e){return Pa.center.set(0,0,0),Pa.radius=.7071067811865476,Pa.applyMatrix4(e.matrixWorld),this.intersectsSphere(Pa)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)0?e.max.x:e.min.x,Cp.y=r.normal.y>0?e.max.y:e.min.y,Cp.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Cp)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function bE(){let n=null,e=!1,t=null,i=null;function r(s,o){t(s,o),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function T4(n,e){let t=e.isWebGL2,i=new WeakMap;function r(c,u){let d=c.array,f=c.usage,m=n.createBuffer();n.bindBuffer(u,m),n.bufferData(u,d,f),c.onUploadCallback();let p;if(d instanceof Float32Array)p=n.FLOAT;else if(d instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(t)p=n.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else p=n.UNSIGNED_SHORT;else if(d instanceof Int16Array)p=n.SHORT;else if(d instanceof Uint32Array)p=n.UNSIGNED_INT;else if(d instanceof Int32Array)p=n.INT;else if(d instanceof Int8Array)p=n.BYTE;else if(d instanceof Uint8Array)p=n.UNSIGNED_BYTE;else if(d instanceof Uint8ClampedArray)p=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:m,type:p,bytesPerElement:d.BYTES_PER_ELEMENT,version:c.version}}function s(c,u,d){let f=u.array,m=u.updateRange;n.bindBuffer(d,c),m.count===-1?n.bufferSubData(d,0,f):(t?n.bufferSubData(d,m.offset*f.BYTES_PER_ELEMENT,f,m.offset,m.count):n.bufferSubData(d,m.offset*f.BYTES_PER_ELEMENT,f.subarray(m.offset,m.offset+m.count)),m.count=-1),u.onUploadCallback()}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),i.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);let u=i.get(c);u&&(n.deleteBuffer(u.buffer),i.delete(c))}function l(c,u){if(c.isGLBufferAttribute){let f=i.get(c);(!f||f.version 0 + vec4 plane; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif +#endif`,G4=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,$4=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,W4=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,j4=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,X4=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,q4=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + varying vec3 vColor; +#endif`,Y4=`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif`,Z4=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +mat3 transposeMat3( const in mat3 m ) { + mat3 tmp; + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + return tmp; +} +float luminance( const in vec3 rgb ) { + const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); + return dot( weights, rgb ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,K4=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_v0 0.339 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_v1 0.276 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_v4 0.046 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_v5 0.016 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_v6 0.0038 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,J4=`vec3 transformedNormal = objectNormal; +#ifdef USE_INSTANCING + mat3 m = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); + transformedNormal = m * transformedNormal; +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,Q4=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,e5=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,t5=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,n5=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,i5="gl_FragColor = linearToOutputTexel( gl_FragColor );",r5=` +const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3( + vec3( 0.8224621, 0.177538, 0.0 ), + vec3( 0.0331941, 0.9668058, 0.0 ), + vec3( 0.0170827, 0.0723974, 0.9105199 ) +); +const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3( + vec3( 1.2249401, - 0.2249404, 0.0 ), + vec3( - 0.0420569, 1.0420571, 0.0 ), + vec3( - 0.0196376, - 0.0786361, 1.0982735 ) +); +vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) { + return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a ); +} +vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) { + return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a ); +} +vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +} +vec4 LinearToLinear( in vec4 value ) { + return value; +} +vec4 LinearTosRGB( in vec4 value ) { + return sRGBTransferOETF( value ); +}`,s5=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif +#endif`,o5=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`,a5=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,l5=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,c5=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,u5=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,h5=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,d5=`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,f5=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,p5=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,m5=`#ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + reflectedLight.indirectDiffuse += lightMapIrradiance; +#endif`,g5=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,y5=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,_5=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,v5=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + #if defined ( LEGACY_LIGHTS ) + if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { + return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); + } + return 1.0; + #else + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; + #endif +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`,x5=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,b5=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,w5=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,S5=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,A5=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,M5=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y; +#endif`,C5=`struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + float v = 0.5 / ( gv + gl ); + return saturate(v); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColor; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + return fab; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + vec2 fab = DFGApprox( normal, viewDir, roughness ); + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,E5=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,T5=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,P5=`#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,I5=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,R5=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,k5=`#ifdef USE_LOGDEPTHBUF + #ifdef USE_LOGDEPTHBUF_EXT + varying float vFragDepth; + varying float vIsPerspective; + #else + uniform float logDepthBufFC; + #endif +#endif`,L5=`#ifdef USE_LOGDEPTHBUF + #ifdef USE_LOGDEPTHBUF_EXT + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); + #else + if ( isPerspectiveMatrix( projectionMatrix ) ) { + gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; + gl_Position.z *= gl_Position.w; + } + #endif +#endif`,D5=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); + + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,N5=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,F5=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,O5=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,B5=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,U5=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,z5=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,V5=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } + #else + objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; + objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; + objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; + objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; + #endif +#endif`,H5=`#ifdef USE_MORPHTARGETS + uniform float morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } + #else + #ifndef USE_MORPHNORMALS + uniform float morphTargetInfluences[ 8 ]; + #else + uniform float morphTargetInfluences[ 4 ]; + #endif + #endif +#endif`,G5=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } + #else + transformed += morphTarget0 * morphTargetInfluences[ 0 ]; + transformed += morphTarget1 * morphTargetInfluences[ 1 ]; + transformed += morphTarget2 * morphTargetInfluences[ 2 ]; + transformed += morphTarget3 * morphTargetInfluences[ 3 ]; + #ifndef USE_MORPHNORMALS + transformed += morphTarget4 * morphTargetInfluences[ 4 ]; + transformed += morphTarget5 * morphTargetInfluences[ 5 ]; + transformed += morphTarget6 * morphTargetInfluences[ 6 ]; + transformed += morphTarget7 * morphTargetInfluences[ 7 ]; + #endif + #endif +#endif`,$5=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,W5=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,j5=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,X5=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,q5=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,Y5=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,Z5=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,K5=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,J5=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,Q5=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,eN=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,tN=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; +const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); +const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); +const float ShiftRight8 = 1. / 256.; +vec4 packDepthToRGBA( const in float v ) { + vec4 r = vec4( fract( v * PackFactors ), v ); + r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors ); +} +vec2 packDepthToRG( in highp float v ) { + return packDepthToRGBA( v ).yx; +} +float unpackRGToDepth( const in highp vec2 v ) { + return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); +} +vec4 pack2HalfToRGBA( vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + return depth * ( near - far ) - near; +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * depth - far ); +}`,nN=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,iN=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,rN=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,sN=`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,oN=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,aN=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,lN=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + } + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + } + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + float occlusion = 1.0; + vec2 distribution = texture2DDistribution( shadow, uv ); + float hard_shadow = step( compare , distribution.x ); + if (hard_shadow != 1.0 ) { + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + } + return occlusion; + } + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + #if defined( SHADOWMAP_TYPE_PCF ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + #elif defined( SHADOWMAP_TYPE_VSM ) + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + #else + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + #endif + } + return shadow; + } + vec2 cubeToUV( vec3 v, float texelSizeY ) { + vec3 absV = abs( v ); + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + vec2 planar = v.xy; + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + if ( absV.z >= almostOne ) { + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + } else if ( absV.x >= almostOne ) { + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + } else if ( absV.y >= almostOne ) { + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + } + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + } + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + vec3 lightToPosition = shadowCoord.xyz; + float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + return ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + #else + return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } +#endif`,cN=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,uN=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,hN=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,dN=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,fN=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + uniform int boneTextureSize; + mat4 getBoneMatrix( const in float i ) { + float j = i * 4.0; + float x = mod( j, float( boneTextureSize ) ); + float y = floor( j / float( boneTextureSize ) ); + float dx = 1.0 / float( boneTextureSize ); + float dy = 1.0 / float( boneTextureSize ); + y = dy * ( y + 0.5 ); + vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); + vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); + vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); + vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); + mat4 bone = mat4( v1, v2, v3, v4 ); + return bone; + } +#endif`,pN=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,mN=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,gN=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,yN=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,_N=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,vN=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 OptimizedCineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,xN=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,bN=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,wN=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,SN=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,AN=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,MN=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`,CN=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,EN=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,TN=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,PN=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,IN=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,RN=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,kN=`#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,LN=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + vec4 diffuseColor = vec4( 1.0 ); + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #endif +}`,DN=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,NN=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +#include +void main () { + #include + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`,FN=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,ON=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,BN=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,UN=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,zN=`#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,VN=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,HN=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,GN=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,$N=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,WN=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,jN=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,XN=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,qN=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,YN=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,ZN=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,KN=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,JN=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,QN=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,eF=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,tF=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,nF=`#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,iF=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include +}`,rF=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); + vec2 scale; + scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); + scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,sF=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,It={alphahash_fragment:P4,alphahash_pars_fragment:I4,alphamap_fragment:R4,alphamap_pars_fragment:k4,alphatest_fragment:L4,alphatest_pars_fragment:D4,aomap_fragment:N4,aomap_pars_fragment:F4,begin_vertex:O4,beginnormal_vertex:B4,bsdfs:U4,iridescence_fragment:z4,bumpmap_pars_fragment:V4,clipping_planes_fragment:H4,clipping_planes_pars_fragment:G4,clipping_planes_pars_vertex:$4,clipping_planes_vertex:W4,color_fragment:j4,color_pars_fragment:X4,color_pars_vertex:q4,color_vertex:Y4,common:Z4,cube_uv_reflection_fragment:K4,defaultnormal_vertex:J4,displacementmap_pars_vertex:Q4,displacementmap_vertex:e5,emissivemap_fragment:t5,emissivemap_pars_fragment:n5,colorspace_fragment:i5,colorspace_pars_fragment:r5,envmap_fragment:s5,envmap_common_pars_fragment:o5,envmap_pars_fragment:a5,envmap_pars_vertex:l5,envmap_physical_pars_fragment:x5,envmap_vertex:c5,fog_vertex:u5,fog_pars_vertex:h5,fog_fragment:d5,fog_pars_fragment:f5,gradientmap_pars_fragment:p5,lightmap_fragment:m5,lightmap_pars_fragment:g5,lights_lambert_fragment:y5,lights_lambert_pars_fragment:_5,lights_pars_begin:v5,lights_toon_fragment:b5,lights_toon_pars_fragment:w5,lights_phong_fragment:S5,lights_phong_pars_fragment:A5,lights_physical_fragment:M5,lights_physical_pars_fragment:C5,lights_fragment_begin:E5,lights_fragment_maps:T5,lights_fragment_end:P5,logdepthbuf_fragment:I5,logdepthbuf_pars_fragment:R5,logdepthbuf_pars_vertex:k5,logdepthbuf_vertex:L5,map_fragment:D5,map_pars_fragment:N5,map_particle_fragment:F5,map_particle_pars_fragment:O5,metalnessmap_fragment:B5,metalnessmap_pars_fragment:U5,morphcolor_vertex:z5,morphnormal_vertex:V5,morphtarget_pars_vertex:H5,morphtarget_vertex:G5,normal_fragment_begin:$5,normal_fragment_maps:W5,normal_pars_fragment:j5,normal_pars_vertex:X5,normal_vertex:q5,normalmap_pars_fragment:Y5,clearcoat_normal_fragment_begin:Z5,clearcoat_normal_fragment_maps:K5,clearcoat_pars_fragment:J5,iridescence_pars_fragment:Q5,opaque_fragment:eN,packing:tN,premultiplied_alpha_fragment:nN,project_vertex:iN,dithering_fragment:rN,dithering_pars_fragment:sN,roughnessmap_fragment:oN,roughnessmap_pars_fragment:aN,shadowmap_pars_fragment:lN,shadowmap_pars_vertex:cN,shadowmap_vertex:uN,shadowmask_pars_fragment:hN,skinbase_vertex:dN,skinning_pars_vertex:fN,skinning_vertex:pN,skinnormal_vertex:mN,specularmap_fragment:gN,specularmap_pars_fragment:yN,tonemapping_fragment:_N,tonemapping_pars_fragment:vN,transmission_fragment:xN,transmission_pars_fragment:bN,uv_pars_fragment:wN,uv_pars_vertex:SN,uv_vertex:AN,worldpos_vertex:MN,background_vert:CN,background_frag:EN,backgroundCube_vert:TN,backgroundCube_frag:PN,cube_vert:IN,cube_frag:RN,depth_vert:kN,depth_frag:LN,distanceRGBA_vert:DN,distanceRGBA_frag:NN,equirect_vert:FN,equirect_frag:ON,linedashed_vert:BN,linedashed_frag:UN,meshbasic_vert:zN,meshbasic_frag:VN,meshlambert_vert:HN,meshlambert_frag:GN,meshmatcap_vert:$N,meshmatcap_frag:WN,meshnormal_vert:jN,meshnormal_frag:XN,meshphong_vert:qN,meshphong_frag:YN,meshphysical_vert:ZN,meshphysical_frag:KN,meshtoon_vert:JN,meshtoon_frag:QN,points_vert:eF,points_frag:tF,shadow_vert:nF,shadow_frag:iF,sprite_vert:rF,sprite_frag:sF},it={common:{diffuse:{value:new dt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Lt},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Lt}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Lt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Lt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Lt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Lt},normalScale:{value:new Et(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Lt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Lt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Lt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Lt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new dt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new dt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0},uvTransform:{value:new Lt}},sprite:{diffuse:{value:new dt(16777215)},opacity:{value:1},center:{value:new Et(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Lt},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0}}},cs={basic:{uniforms:Ci([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.fog]),vertexShader:It.meshbasic_vert,fragmentShader:It.meshbasic_frag},lambert:{uniforms:Ci([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.fog,it.lights,{emissive:{value:new dt(0)}}]),vertexShader:It.meshlambert_vert,fragmentShader:It.meshlambert_frag},phong:{uniforms:Ci([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.fog,it.lights,{emissive:{value:new dt(0)},specular:{value:new dt(1118481)},shininess:{value:30}}]),vertexShader:It.meshphong_vert,fragmentShader:It.meshphong_frag},standard:{uniforms:Ci([it.common,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.roughnessmap,it.metalnessmap,it.fog,it.lights,{emissive:{value:new dt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:It.meshphysical_vert,fragmentShader:It.meshphysical_frag},toon:{uniforms:Ci([it.common,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.gradientmap,it.fog,it.lights,{emissive:{value:new dt(0)}}]),vertexShader:It.meshtoon_vert,fragmentShader:It.meshtoon_frag},matcap:{uniforms:Ci([it.common,it.bumpmap,it.normalmap,it.displacementmap,it.fog,{matcap:{value:null}}]),vertexShader:It.meshmatcap_vert,fragmentShader:It.meshmatcap_frag},points:{uniforms:Ci([it.points,it.fog]),vertexShader:It.points_vert,fragmentShader:It.points_frag},dashed:{uniforms:Ci([it.common,it.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:It.linedashed_vert,fragmentShader:It.linedashed_frag},depth:{uniforms:Ci([it.common,it.displacementmap]),vertexShader:It.depth_vert,fragmentShader:It.depth_frag},normal:{uniforms:Ci([it.common,it.bumpmap,it.normalmap,it.displacementmap,{opacity:{value:1}}]),vertexShader:It.meshnormal_vert,fragmentShader:It.meshnormal_frag},sprite:{uniforms:Ci([it.sprite,it.fog]),vertexShader:It.sprite_vert,fragmentShader:It.sprite_frag},background:{uniforms:{uvTransform:{value:new Lt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:It.background_vert,fragmentShader:It.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:It.backgroundCube_vert,fragmentShader:It.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:It.cube_vert,fragmentShader:It.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:It.equirect_vert,fragmentShader:It.equirect_frag},distanceRGBA:{uniforms:Ci([it.common,it.displacementmap,{referencePosition:{value:new W},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:It.distanceRGBA_vert,fragmentShader:It.distanceRGBA_frag},shadow:{uniforms:Ci([it.lights,it.fog,{color:{value:new dt(0)},opacity:{value:1}}]),vertexShader:It.shadow_vert,fragmentShader:It.shadow_frag}};cs.physical={uniforms:Ci([cs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Lt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Lt},clearcoatNormalScale:{value:new Et(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Lt},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Lt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Lt},sheen:{value:0},sheenColor:{value:new dt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Lt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Lt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Lt},transmissionSamplerSize:{value:new Et},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Lt},attenuationDistance:{value:0},attenuationColor:{value:new dt(0)},specularColor:{value:new dt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Lt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Lt},anisotropyVector:{value:new Et},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Lt}}]),vertexShader:It.meshphysical_vert,fragmentShader:It.meshphysical_frag};var Ep={r:0,b:0,g:0};function oF(n,e,t,i,r,s,o){let a=new dt(0),l=s===!0?0:1,c,u,d=null,f=0,m=null;function p(y,g){let b=!1,h=g.isScene===!0?g.background:null;h&&h.isTexture&&(h=(g.backgroundBlurriness>0?t:e).get(h)),h===null?_(a,l):h&&h.isColor&&(_(h,1),b=!0);let v=n.xr.getEnvironmentBlendMode();v==="additive"?i.buffers.color.setClear(0,0,0,1,o):v==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||b)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),h&&(h.isCubeTexture||h.mapping===cm)?(u===void 0&&(u=new er(new Ua(1,1,1),new Ti({name:"BackgroundCubeMaterial",uniforms:fc(cs.backgroundCube.uniforms),vertexShader:cs.backgroundCube.vertexShader,fragmentShader:cs.backgroundCube.fragmentShader,side:vi,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(S,x,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),u.material.uniforms.envMap.value=h,u.material.uniforms.flipEnvMap.value=h.isCubeTexture&&h.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=g.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,u.material.toneMapped=Qt.getTransfer(h.colorSpace)!==un,(d!==h||f!==h.version||m!==n.toneMapping)&&(u.material.needsUpdate=!0,d=h,f=h.version,m=n.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null)):h&&h.isTexture&&(c===void 0&&(c=new er(new Sh(2,2),new Ti({name:"BackgroundMaterial",uniforms:fc(cs.background.uniforms),vertexShader:cs.background.vertexShader,fragmentShader:cs.background.fragmentShader,side:ds,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=h,c.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,c.material.toneMapped=Qt.getTransfer(h.colorSpace)!==un,h.matrixAutoUpdate===!0&&h.updateMatrix(),c.material.uniforms.uvTransform.value.copy(h.matrix),(d!==h||f!==h.version||m!==n.toneMapping)&&(c.material.needsUpdate=!0,d=h,f=h.version,m=n.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function _(y,g){y.getRGB(Ep,xE(n)),i.buffers.color.setClear(Ep.r,Ep.g,Ep.b,g,o)}return{getClearColor:function(){return a},setClearColor:function(y,g=1){a.set(y),l=g,_(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,_(a,l)},render:p}}function aF(n,e,t,i){let r=n.getParameter(n.MAX_VERTEX_ATTRIBS),s=i.isWebGL2?null:e.get("OES_vertex_array_object"),o=i.isWebGL2||s!==null,a={},l=y(null),c=l,u=!1;function d(E,I,O,D,N){let H=!1;if(o){let z=_(D,O,I);c!==z&&(c=z,m(c.object)),H=g(E,D,O,N),H&&b(E,D,O,N)}else{let z=I.wireframe===!0;(c.geometry!==D.id||c.program!==O.id||c.wireframe!==z)&&(c.geometry=D.id,c.program=O.id,c.wireframe=z,H=!0)}N!==null&&t.update(N,n.ELEMENT_ARRAY_BUFFER),(H||u)&&(u=!1,A(E,I,O,D),N!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.get(N).buffer))}function f(){return i.isWebGL2?n.createVertexArray():s.createVertexArrayOES()}function m(E){return i.isWebGL2?n.bindVertexArray(E):s.bindVertexArrayOES(E)}function p(E){return i.isWebGL2?n.deleteVertexArray(E):s.deleteVertexArrayOES(E)}function _(E,I,O){let D=O.wireframe===!0,N=a[E.id];N===void 0&&(N={},a[E.id]=N);let H=N[I.id];H===void 0&&(H={},N[I.id]=H);let z=H[D];return z===void 0&&(z=y(f()),H[D]=z),z}function y(E){let I=[],O=[],D=[];for(let N=0;N=0){let Q=N[F],Z=H[F];if(Z===void 0&&(F==="instanceMatrix"&&E.instanceMatrix&&(Z=E.instanceMatrix),F==="instanceColor"&&E.instanceColor&&(Z=E.instanceColor)),Q===void 0||Q.attribute!==Z||Z&&Q.data!==Z.data)return!0;z++}return c.attributesNum!==z||c.index!==D}function b(E,I,O,D){let N={},H=I.attributes,z=0,L=O.getAttributes();for(let F in L)if(L[F].location>=0){let Q=H[F];Q===void 0&&(F==="instanceMatrix"&&E.instanceMatrix&&(Q=E.instanceMatrix),F==="instanceColor"&&E.instanceColor&&(Q=E.instanceColor));let Z={};Z.attribute=Q,Q&&Q.data&&(Z.data=Q.data),N[F]=Z,z++}c.attributes=N,c.attributesNum=z,c.index=D}function h(){let E=c.newAttributes;for(let I=0,O=E.length;I=0){let te=N[L];if(te===void 0&&(L==="instanceMatrix"&&E.instanceMatrix&&(te=E.instanceMatrix),L==="instanceColor"&&E.instanceColor&&(te=E.instanceColor)),te!==void 0){let Q=te.normalized,Z=te.itemSize,J=t.get(te);if(J===void 0)continue;let re=J.buffer,X=J.type,se=J.bytesPerElement,ne=i.isWebGL2===!0&&(X===n.INT||X===n.UNSIGNED_INT||te.gpuType===hE);if(te.isInterleavedBufferAttribute){let oe=te.data,ee=oe.stride,le=te.offset;if(oe.isInstancedInterleavedBuffer){for(let xe=0;xe0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&n.constructor.name==="WebGL2RenderingContext",a=t.precision!==void 0?t.precision:"highp",l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,d=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),f=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_TEXTURE_SIZE),p=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),_=n.getParameter(n.MAX_VERTEX_ATTRIBS),y=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),g=n.getParameter(n.MAX_VARYING_VECTORS),b=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),h=f>0,v=o||e.has("OES_texture_float"),S=h&&v,x=o?n.getParameter(n.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:r,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:d,maxVertexTextures:f,maxTextureSize:m,maxCubemapSize:p,maxAttributes:_,maxVertexUniforms:y,maxVaryings:g,maxFragmentUniforms:b,vertexTextures:h,floatFragmentTextures:v,floatVertexTextures:S,maxSamples:x}}function uF(n){let e=this,t=null,i=0,r=!1,s=!1,o=new Ws,a=new Lt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){let m=d.length!==0||f||i!==0||r;return r=f,i=d.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,f){t=u(d,f,0)},this.setState=function(d,f,m){let p=d.clippingPlanes,_=d.clipIntersection,y=d.clipShadows,g=n.get(d);if(!r||p===null||p.length===0||s&&!y)s?u(null):c();else{let b=s?0:i,h=b*4,v=g.clippingState||null;l.value=v,v=u(p,f,h,m);for(let S=0;S!==h;++S)v[S]=t[S];g.clippingState=v,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,f,m,p){let _=d!==null?d.length:0,y=null;if(_!==0){if(y=l.value,p!==!0||y===null){let g=m+_*4,b=f.matrixWorldInverse;a.getNormalMatrix(b),(y===null||y.length0){let c=new Y_(l.height/2);return c.fromEquirectangularTexture(n,o),e.set(o,c),o.addEventListener("dispose",r),t(c.texture,o.mapping)}else return null}}return o}function r(o){let a=o.target;a.removeEventListener("dispose",r);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}var jo=class extends Zp{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,o=i+e,a=r+t,l=r-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},ac=4,IC=[.125,.215,.35,.446,.526,.582],La=20,I_=new jo,RC=new dt,R_=null,k_=0,L_=0,Ra=(1+Math.sqrt(5))/2,sc=1/Ra,kC=[new W(1,1,1),new W(-1,1,1),new W(1,1,-1),new W(-1,1,-1),new W(0,Ra,sc),new W(0,Ra,-sc),new W(sc,0,Ra),new W(-sc,0,Ra),new W(Ra,sc,0),new W(-Ra,sc,0)],Jp=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){R_=this._renderer.getRenderTarget(),k_=this._renderer.getActiveCubeFace(),L_=this._renderer.getActiveMipmapLevel(),this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=NC(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=DC(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?h:0,h,h),u.setRenderTarget(r),_&&u.render(p,a),u.render(e,a)}p.geometry.dispose(),p.material.dispose(),u.toneMapping=f,u.autoClear=d,e.background=y}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===uc||e.mapping===hc;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=NC()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=DC());let s=r?this._cubemapMaterial:this._equirectMaterial,o=new er(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let l=this._cubeSize;Tp(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,I_)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let r=1;rLa&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${La}`);let g=[],b=0;for(let w=0;wh-ac?r-h+ac:0),x=4*(this._cubeSize-v);Tp(t,S,x,3*v,2*v),l.setRenderTarget(t),l.render(d,I_)}};function dF(n){let e=[],t=[],i=[],r=n,s=n-ac+1+IC.length;for(let o=0;on-ac?l=IC[o-n+ac-1]:o===0&&(l=0),i.push(l);let c=1/(a-2),u=-c,d=1+c,f=[u,u,d,u,d,d,u,u,d,d,u,d],m=6,p=6,_=3,y=2,g=1,b=new Float32Array(_*p*m),h=new Float32Array(y*p*m),v=new Float32Array(g*p*m);for(let x=0;x2?0:-1,M=[w,A,0,w+2/3,A,0,w+2/3,A+1,0,w,A,0,w+2/3,A+1,0,w,A+1,0];b.set(M,_*p*x),h.set(f,y*p*x);let T=[x,x,x,x,x,x];v.set(T,g*p*x)}let S=new Vn;S.setAttribute("position",new gn(b,_)),S.setAttribute("uv",new gn(h,y)),S.setAttribute("faceIndex",new gn(v,g)),e.push(S),r>ac&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function LC(n,e,t){let i=new nr(n,e,t);return i.texture.mapping=cm,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Tp(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function fF(n,e,t){let i=new Float32Array(La),r=new W(0,1,0);return new Ti({name:"SphericalGaussianBlur",defines:{n:La,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Ev(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:us,depthTest:!1,depthWrite:!1})}function DC(){return new Ti({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ev(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:us,depthTest:!1,depthWrite:!1})}function NC(){return new Ti({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ev(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:us,depthTest:!1,depthWrite:!1})}function Ev(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}function pF(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let l=a.mapping,c=l===U_||l===z_,u=l===uc||l===hc;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let d=e.get(a);return t===null&&(t=new Jp(n)),d=c?t.fromEquirectangular(a,d):t.fromCubemap(a,d),e.set(a,d),d.texture}else{if(e.has(a))return e.get(a).texture;{let d=a.image;if(c&&d&&d.height>0||u&&d&&r(d)){t===null&&(t=new Jp(n));let f=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,f),a.addEventListener("dispose",s),f.texture}else return null}}}return a}function r(a){let l=0,c=6;for(let u=0;ue.maxTextureSize&&(T=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);let R=new Float32Array(M*T*4*p),C=new Wp(R,M,T,p);C.type=br,C.needsUpdate=!0;let P=A*4;for(let I=0;I0)return n;let r=e*t,s=FC[r];if(s===void 0&&(s=new Float32Array(r),FC[r]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function qn(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t":" "} ${a}: ${t[o]}`)}return i.join(` +`)}function fO(n){let e=Qt.getPrimaries(Qt.workingColorSpace),t=Qt.getPrimaries(n),i;switch(e===t?i="":e===zp&&t===Up?i="LinearDisplayP3ToLinearSRGB":e===Up&&t===zp&&(i="LinearSRGBToLinearDisplayP3"),n){case Xs:case um:return[i,"LinearTransferOETF"];case ai:case Cv:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function GC(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";let s=/ERROR: 0:(\d+)/.exec(r);if(s){let o=parseInt(s[1]);return t.toUpperCase()+` + +`+r+` + +`+dO(n.getShaderSource(e),o)}else return r}function pO(n,e){let t=fO(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function mO(n,e){let t;switch(e){case DD:t="Linear";break;case ND:t="Reinhard";break;case FD:t="OptimizedCineon";break;case OD:t="ACESFilmic";break;case BD:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function gO(n){return[n.extensionDerivatives||n.envMapCubeUVHeight||n.bumpMap||n.normalMapTangentSpace||n.clearcoatNormalMap||n.flatShading||n.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(n.extensionFragDepth||n.logarithmicDepthBuffer)&&n.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",n.extensionDrawBuffers&&n.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(n.extensionShaderTextureLOD||n.envMap||n.transmission)&&n.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(yh).join(` +`)}function yO(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` +`)}function _O(n,e){let t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function Q_(n){return n.replace(vO,bO)}var xO=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function bO(n,e){let t=It[e];if(t===void 0){let i=xO.get(e);if(i!==void 0)t=It[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return Q_(t)}var wO=/#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;function jC(n){return n.replace(wO,SO)}function SO(n,e,t,i){let r="";for(let s=parseInt(e);s0&&(y+=` +`),g=[m,"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(yh).join(` +`),g.length>0&&(g+=` +`)):(y=[XC(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(yh).join(` +`),g=[m,XC(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Ho?"#define TONE_MAPPING":"",t.toneMapping!==Ho?It.tonemapping_pars_fragment:"",t.toneMapping!==Ho?mO("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",It.colorspace_pars_fragment,pO("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(yh).join(` +`)),o=Q_(o),o=$C(o,t),o=WC(o,t),a=Q_(a),a=$C(a,t),a=WC(a,t),o=jC(o),a=jC(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(b=`#version 300 es +`,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+y,g=["precision mediump sampler2DArray;","#define varying in",t.glslVersion===dC?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===dC?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+g);let h=b+y+o,v=b+g+a,S=HC(r,r.VERTEX_SHADER,h),x=HC(r,r.FRAGMENT_SHADER,v);r.attachShader(_,S),r.attachShader(_,x),t.index0AttributeName!==void 0?r.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(_,0,"position"),r.linkProgram(_);function w(R){if(n.debug.checkShaderErrors){let C=r.getProgramInfoLog(_).trim(),P=r.getShaderInfoLog(S).trim(),E=r.getShaderInfoLog(x).trim(),I=!0,O=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(I=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,_,S,x);else{let D=GC(r,S,"vertex"),N=GC(r,x,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+` + +Program Info Log: `+C+` +`+D+` +`+N)}else C!==""?console.warn("THREE.WebGLProgram: Program Info Log:",C):(P===""||E==="")&&(O=!1);O&&(R.diagnostics={runnable:I,programLog:C,vertexShader:{log:P,prefix:y},fragmentShader:{log:E,prefix:g}})}r.deleteShader(S),r.deleteShader(x),A=new cc(r,_),M=_O(r,_)}let A;this.getUniforms=function(){return A===void 0&&w(this),A};let M;this.getAttributes=function(){return M===void 0&&w(this),M};let T=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return T===!1&&(T=r.getProgramParameter(_,uO)),T},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=hO++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=S,this.fragmentShader=x,this}var IO=0,ev=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new tv(e),t.set(e,i)),i}},tv=class{constructor(e){this.id=IO++,this.code=e,this.usedTimes=0}};function RO(n,e,t,i,r,s,o){let a=new jp,l=new ev,c=[],u=r.isWebGL2,d=r.logarithmicDepthBuffer,f=r.vertexTextures,m=r.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function _(M){return M===0?"uv":`uv${M}`}function y(M,T,R,C,P){let E=C.fog,I=P.geometry,O=M.isMeshStandardMaterial?C.environment:null,D=(M.isMeshStandardMaterial?t:e).get(M.envMap||O),N=D&&D.mapping===cm?D.image.height:null,H=p[M.type];M.precision!==null&&(m=r.getMaxPrecision(M.precision),m!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",m,"instead."));let z=I.morphAttributes.position||I.morphAttributes.normal||I.morphAttributes.color,L=z!==void 0?z.length:0,F=0;I.morphAttributes.position!==void 0&&(F=1),I.morphAttributes.normal!==void 0&&(F=2),I.morphAttributes.color!==void 0&&(F=3);let te,Q,Z,J;if(H){let k=cs[H];te=k.vertexShader,Q=k.fragmentShader}else te=M.vertexShader,Q=M.fragmentShader,l.update(M),Z=l.getVertexShaderID(M),J=l.getFragmentShaderID(M);let re=n.getRenderTarget(),X=P.isInstancedMesh===!0,se=!!M.map,ne=!!M.matcap,oe=!!D,ee=!!M.aoMap,le=!!M.lightMap,xe=!!M.bumpMap,Se=!!M.normalMap,Re=!!M.displacementMap,ke=!!M.emissiveMap,$e=!!M.metalnessMap,_e=!!M.roughnessMap,Ie=M.anisotropy>0,We=M.clearcoat>0,Fe=M.iridescence>0,Y=M.sheen>0,$=M.transmission>0,de=Ie&&!!M.anisotropyMap,Te=We&&!!M.clearcoatMap,fe=We&&!!M.clearcoatNormalMap,Ae=We&&!!M.clearcoatRoughnessMap,Be=Fe&&!!M.iridescenceMap,Ee=Fe&&!!M.iridescenceThicknessMap,Ue=Y&&!!M.sheenColorMap,je=Y&&!!M.sheenRoughnessMap,at=!!M.specularMap,Pe=!!M.specularColorMap,lt=!!M.specularIntensityMap,tt=$&&!!M.transmissionMap,He=$&&!!M.thicknessMap,Qe=!!M.gradientMap,Oe=!!M.alphaMap,et=M.alphaTest>0,ie=!!M.alphaHash,ye=!!M.extensions,pe=!!I.attributes.uv1,ve=!!I.attributes.uv2,Ne=!!I.attributes.uv3,st=Ho;return M.toneMapped&&(re===null||re.isXRRenderTarget===!0)&&(st=n.toneMapping),{isWebGL2:u,shaderID:H,shaderType:M.type,shaderName:M.name,vertexShader:te,fragmentShader:Q,defines:M.defines,customVertexShaderID:Z,customFragmentShaderID:J,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:m,instancing:X,instancingColor:X&&P.instanceColor!==null,supportsVertexTextures:f,outputColorSpace:re===null?n.outputColorSpace:re.isXRRenderTarget===!0?re.texture.colorSpace:Xs,map:se,matcap:ne,envMap:oe,envMapMode:oe&&D.mapping,envMapCubeUVHeight:N,aoMap:ee,lightMap:le,bumpMap:xe,normalMap:Se,displacementMap:f&&Re,emissiveMap:ke,normalMapObjectSpace:Se&&M.normalMapType===JD,normalMapTangentSpace:Se&&M.normalMapType===KD,metalnessMap:$e,roughnessMap:_e,anisotropy:Ie,anisotropyMap:de,clearcoat:We,clearcoatMap:Te,clearcoatNormalMap:fe,clearcoatRoughnessMap:Ae,iridescence:Fe,iridescenceMap:Be,iridescenceThicknessMap:Ee,sheen:Y,sheenColorMap:Ue,sheenRoughnessMap:je,specularMap:at,specularColorMap:Pe,specularIntensityMap:lt,transmission:$,transmissionMap:tt,thicknessMap:He,gradientMap:Qe,opaque:M.transparent===!1&&M.blending===hs,alphaMap:Oe,alphaTest:et,alphaHash:ie,combine:M.combine,mapUv:se&&_(M.map.channel),aoMapUv:ee&&_(M.aoMap.channel),lightMapUv:le&&_(M.lightMap.channel),bumpMapUv:xe&&_(M.bumpMap.channel),normalMapUv:Se&&_(M.normalMap.channel),displacementMapUv:Re&&_(M.displacementMap.channel),emissiveMapUv:ke&&_(M.emissiveMap.channel),metalnessMapUv:$e&&_(M.metalnessMap.channel),roughnessMapUv:_e&&_(M.roughnessMap.channel),anisotropyMapUv:de&&_(M.anisotropyMap.channel),clearcoatMapUv:Te&&_(M.clearcoatMap.channel),clearcoatNormalMapUv:fe&&_(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ae&&_(M.clearcoatRoughnessMap.channel),iridescenceMapUv:Be&&_(M.iridescenceMap.channel),iridescenceThicknessMapUv:Ee&&_(M.iridescenceThicknessMap.channel),sheenColorMapUv:Ue&&_(M.sheenColorMap.channel),sheenRoughnessMapUv:je&&_(M.sheenRoughnessMap.channel),specularMapUv:at&&_(M.specularMap.channel),specularColorMapUv:Pe&&_(M.specularColorMap.channel),specularIntensityMapUv:lt&&_(M.specularIntensityMap.channel),transmissionMapUv:tt&&_(M.transmissionMap.channel),thicknessMapUv:He&&_(M.thicknessMap.channel),alphaMapUv:Oe&&_(M.alphaMap.channel),vertexTangents:!!I.attributes.tangent&&(Se||Ie),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!I.attributes.color&&I.attributes.color.itemSize===4,vertexUv1s:pe,vertexUv2s:ve,vertexUv3s:Ne,pointsUvs:P.isPoints===!0&&!!I.attributes.uv&&(se||Oe),fog:!!E,useFog:M.fog===!0,fogExp2:E&&E.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:P.isSkinnedMesh===!0,morphTargets:I.morphAttributes.position!==void 0,morphNormals:I.morphAttributes.normal!==void 0,morphColors:I.morphAttributes.color!==void 0,morphTargetsCount:L,morphTextureStride:F,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:M.dithering,shadowMapEnabled:n.shadowMap.enabled&&R.length>0,shadowMapType:n.shadowMap.type,toneMapping:st,useLegacyLights:n._useLegacyLights,decodeVideoTexture:se&&M.map.isVideoTexture===!0&&Qt.getTransfer(M.map.colorSpace)===un,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Hr,flipSided:M.side===vi,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionDerivatives:ye&&M.extensions.derivatives===!0,extensionFragDepth:ye&&M.extensions.fragDepth===!0,extensionDrawBuffers:ye&&M.extensions.drawBuffers===!0,extensionShaderTextureLOD:ye&&M.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||i.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()}}function g(M){let T=[];if(M.shaderID?T.push(M.shaderID):(T.push(M.customVertexShaderID),T.push(M.customFragmentShaderID)),M.defines!==void 0)for(let R in M.defines)T.push(R),T.push(M.defines[R]);return M.isRawShaderMaterial===!1&&(b(T,M),h(T,M),T.push(n.outputColorSpace)),T.push(M.customProgramCacheKey),T.join()}function b(M,T){M.push(T.precision),M.push(T.outputColorSpace),M.push(T.envMapMode),M.push(T.envMapCubeUVHeight),M.push(T.mapUv),M.push(T.alphaMapUv),M.push(T.lightMapUv),M.push(T.aoMapUv),M.push(T.bumpMapUv),M.push(T.normalMapUv),M.push(T.displacementMapUv),M.push(T.emissiveMapUv),M.push(T.metalnessMapUv),M.push(T.roughnessMapUv),M.push(T.anisotropyMapUv),M.push(T.clearcoatMapUv),M.push(T.clearcoatNormalMapUv),M.push(T.clearcoatRoughnessMapUv),M.push(T.iridescenceMapUv),M.push(T.iridescenceThicknessMapUv),M.push(T.sheenColorMapUv),M.push(T.sheenRoughnessMapUv),M.push(T.specularMapUv),M.push(T.specularColorMapUv),M.push(T.specularIntensityMapUv),M.push(T.transmissionMapUv),M.push(T.thicknessMapUv),M.push(T.combine),M.push(T.fogExp2),M.push(T.sizeAttenuation),M.push(T.morphTargetsCount),M.push(T.morphAttributeCount),M.push(T.numDirLights),M.push(T.numPointLights),M.push(T.numSpotLights),M.push(T.numSpotLightMaps),M.push(T.numHemiLights),M.push(T.numRectAreaLights),M.push(T.numDirLightShadows),M.push(T.numPointLightShadows),M.push(T.numSpotLightShadows),M.push(T.numSpotLightShadowsWithMaps),M.push(T.numLightProbes),M.push(T.shadowMapType),M.push(T.toneMapping),M.push(T.numClippingPlanes),M.push(T.numClipIntersection),M.push(T.depthPacking)}function h(M,T){a.disableAll(),T.isWebGL2&&a.enable(0),T.supportsVertexTextures&&a.enable(1),T.instancing&&a.enable(2),T.instancingColor&&a.enable(3),T.matcap&&a.enable(4),T.envMap&&a.enable(5),T.normalMapObjectSpace&&a.enable(6),T.normalMapTangentSpace&&a.enable(7),T.clearcoat&&a.enable(8),T.iridescence&&a.enable(9),T.alphaTest&&a.enable(10),T.vertexColors&&a.enable(11),T.vertexAlphas&&a.enable(12),T.vertexUv1s&&a.enable(13),T.vertexUv2s&&a.enable(14),T.vertexUv3s&&a.enable(15),T.vertexTangents&&a.enable(16),T.anisotropy&&a.enable(17),T.alphaHash&&a.enable(18),M.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.skinning&&a.enable(4),T.morphTargets&&a.enable(5),T.morphNormals&&a.enable(6),T.morphColors&&a.enable(7),T.premultipliedAlpha&&a.enable(8),T.shadowMapEnabled&&a.enable(9),T.useLegacyLights&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),M.push(a.mask)}function v(M){let T=p[M.type],R;if(T){let C=cs[T];R=Lh.clone(C.uniforms)}else R=M.uniforms;return R}function S(M,T){let R;for(let C=0,P=c.length;C0?i.push(g):m.transparent===!0?r.push(g):t.push(g)}function l(d,f,m,p,_,y){let g=o(d,f,m,p,_,y);m.transmission>0?i.unshift(g):m.transparent===!0?r.unshift(g):t.unshift(g)}function c(d,f){t.length>1&&t.sort(d||LO),i.length>1&&i.sort(f||qC),r.length>1&&r.sort(f||qC)}function u(){for(let d=e,f=n.length;d=s.length?(o=new YC,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function NO(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new W,color:new dt};break;case"SpotLight":t={position:new W,direction:new W,color:new dt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new W,color:new dt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new W,skyColor:new dt,groundColor:new dt};break;case"RectAreaLight":t={color:new dt,position:new W,halfWidth:new W,halfHeight:new W};break}return n[e.id]=t,t}}}function FO(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Et};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Et};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Et,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}var OO=0;function BO(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function UO(n,e){let t=new NO,i=FO(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)r.probe.push(new W);let s=new W,o=new qe,a=new qe;function l(u,d){let f=0,m=0,p=0;for(let C=0;C<9;C++)r.probe[C].set(0,0,0);let _=0,y=0,g=0,b=0,h=0,v=0,S=0,x=0,w=0,A=0,M=0;u.sort(BO);let T=d===!0?Math.PI:1;for(let C=0,P=u.length;C0&&(e.isWebGL2||n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=it.LTC_FLOAT_1,r.rectAreaLTC2=it.LTC_FLOAT_2):n.has("OES_texture_half_float_linear")===!0?(r.rectAreaLTC1=it.LTC_HALF_1,r.rectAreaLTC2=it.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=f,r.ambient[1]=m,r.ambient[2]=p;let R=r.hash;(R.directionalLength!==_||R.pointLength!==y||R.spotLength!==g||R.rectAreaLength!==b||R.hemiLength!==h||R.numDirectionalShadows!==v||R.numPointShadows!==S||R.numSpotShadows!==x||R.numSpotMaps!==w||R.numLightProbes!==M)&&(r.directional.length=_,r.spot.length=g,r.rectArea.length=b,r.point.length=y,r.hemi.length=h,r.directionalShadow.length=v,r.directionalShadowMap.length=v,r.pointShadow.length=S,r.pointShadowMap.length=S,r.spotShadow.length=x,r.spotShadowMap.length=x,r.directionalShadowMatrix.length=v,r.pointShadowMatrix.length=S,r.spotLightMatrix.length=x+w-A,r.spotLightMap.length=w,r.numSpotLightShadowsWithMaps=A,r.numLightProbes=M,R.directionalLength=_,R.pointLength=y,R.spotLength=g,R.rectAreaLength=b,R.hemiLength=h,R.numDirectionalShadows=v,R.numPointShadows=S,R.numSpotShadows=x,R.numSpotMaps=w,R.numLightProbes=M,r.version=OO++)}function c(u,d){let f=0,m=0,p=0,_=0,y=0,g=d.matrixWorldInverse;for(let b=0,h=u.length;b=a.length?(l=new ZC(n,e),a.push(l)):l=a[o],l}function r(){t=new WeakMap}return{get:i,dispose:r}}var nv=class extends Wo{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=YD,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},iv=class extends Wo{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},VO=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,HO=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +#include +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( squared_mean - mean * mean ); + gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); +}`;function GO(n,e,t){let i=new wh,r=new Et,s=new Et,o=new ti,a=new nv({depthPacking:ZD}),l=new iv,c={},u=t.maxTextureSize,d={[ds]:vi,[vi]:ds,[Hr]:Hr},f=new Ti({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Et},radius:{value:4}},vertexShader:VO,fragmentShader:HO}),m=f.clone();m.defines.HORIZONTAL_PASS=1;let p=new Vn;p.setAttribute("position",new gn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new er(p,f),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=lE;let g=this.type;this.render=function(S,x,w){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||S.length===0)return;let A=n.getRenderTarget(),M=n.getActiveCubeFace(),T=n.getActiveMipmapLevel(),R=n.state;R.setBlending(us),R.buffers.color.setClear(1,1,1,1),R.buffers.depth.setTest(!0),R.setScissorTest(!1);let C=g!==$s&&this.type===$s,P=g===$s&&this.type!==$s;for(let E=0,I=S.length;Eu||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/N.x),r.x=s.x*N.x,D.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/N.y),r.y=s.y*N.y,D.mapSize.y=s.y)),D.map===null||C===!0||P===!0){let z=this.type!==$s?{minFilter:en,magFilter:en}:{};D.map!==null&&D.map.dispose(),D.map=new nr(r.x,r.y,z),D.map.texture.name=O.name+".shadowMap",D.camera.updateProjectionMatrix()}n.setRenderTarget(D.map),n.clear();let H=D.getViewportCount();for(let z=0;z0||x.map&&x.alphaTest>0){let R=M.uuid,C=x.uuid,P=c[R];P===void 0&&(P={},c[R]=P);let E=P[C];E===void 0&&(E=M.clone(),P[C]=E),M=E}if(M.visible=x.visible,M.wireframe=x.wireframe,A===$s?M.side=x.shadowSide!==null?x.shadowSide:x.side:M.side=x.shadowSide!==null?x.shadowSide:d[x.side],M.alphaMap=x.alphaMap,M.alphaTest=x.alphaTest,M.map=x.map,M.clipShadows=x.clipShadows,M.clippingPlanes=x.clippingPlanes,M.clipIntersection=x.clipIntersection,M.displacementMap=x.displacementMap,M.displacementScale=x.displacementScale,M.displacementBias=x.displacementBias,M.wireframeLinewidth=x.wireframeLinewidth,M.linewidth=x.linewidth,w.isPointLight===!0&&M.isMeshDistanceMaterial===!0){let R=n.properties.get(M);R.light=w}return M}function v(S,x,w,A,M){if(S.visible===!1)return;if(S.layers.test(x.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&M===$s)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,S.matrixWorld);let C=e.update(S),P=S.material;if(Array.isArray(P)){let E=C.groups;for(let I=0,O=E.length;I=1):z.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),N=H>=2);let L=null,F={},te=n.getParameter(n.SCISSOR_BOX),Q=n.getParameter(n.VIEWPORT),Z=new ti().fromArray(te),J=new ti().fromArray(Q);function re(ie,ye,pe,ve){let Ne=new Uint8Array(4),st=n.createTexture();n.bindTexture(ie,st),n.texParameteri(ie,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(ie,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let wt=0;wt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap,_,y=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function b(Y,$){return g?new OffscreenCanvas(Y,$):Hp("canvas")}function h(Y,$,de,Te){let fe=1;if((Y.width>Te||Y.height>Te)&&(fe=Te/Math.max(Y.width,Y.height)),fe<1||$===!0)if(typeof HTMLImageElement<"u"&&Y instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Y instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Y instanceof ImageBitmap){let Ae=$?W_:Math.floor,Be=Ae(fe*Y.width),Ee=Ae(fe*Y.height);_===void 0&&(_=b(Be,Ee));let Ue=de?b(Be,Ee):_;return Ue.width=Be,Ue.height=Ee,Ue.getContext("2d").drawImage(Y,0,0,Be,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Y.width+"x"+Y.height+") to ("+Be+"x"+Ee+")."),Ue}else return"data"in Y&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Y.width+"x"+Y.height+")."),Y;return Y}function v(Y){return fC(Y.width)&&fC(Y.height)}function S(Y){return a?!1:Y.wrapS!==Gr||Y.wrapT!==Gr||Y.minFilter!==en&&Y.minFilter!==li}function x(Y,$){return Y.generateMipmaps&&$&&Y.minFilter!==en&&Y.minFilter!==li}function w(Y){n.generateMipmap(Y)}function A(Y,$,de,Te,fe=!1){if(a===!1)return $;if(Y!==null){if(n[Y]!==void 0)return n[Y];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Y+"'")}let Ae=$;if($===n.RED&&(de===n.FLOAT&&(Ae=n.R32F),de===n.HALF_FLOAT&&(Ae=n.R16F),de===n.UNSIGNED_BYTE&&(Ae=n.R8)),$===n.RED_INTEGER&&(de===n.UNSIGNED_BYTE&&(Ae=n.R8UI),de===n.UNSIGNED_SHORT&&(Ae=n.R16UI),de===n.UNSIGNED_INT&&(Ae=n.R32UI),de===n.BYTE&&(Ae=n.R8I),de===n.SHORT&&(Ae=n.R16I),de===n.INT&&(Ae=n.R32I)),$===n.RG&&(de===n.FLOAT&&(Ae=n.RG32F),de===n.HALF_FLOAT&&(Ae=n.RG16F),de===n.UNSIGNED_BYTE&&(Ae=n.RG8)),$===n.RGBA){let Be=fe?Bp:Qt.getTransfer(Te);de===n.FLOAT&&(Ae=n.RGBA32F),de===n.HALF_FLOAT&&(Ae=n.RGBA16F),de===n.UNSIGNED_BYTE&&(Ae=Be===un?n.SRGB8_ALPHA8:n.RGBA8),de===n.UNSIGNED_SHORT_4_4_4_4&&(Ae=n.RGBA4),de===n.UNSIGNED_SHORT_5_5_5_1&&(Ae=n.RGB5_A1)}return(Ae===n.R16F||Ae===n.R32F||Ae===n.RG16F||Ae===n.RG32F||Ae===n.RGBA16F||Ae===n.RGBA32F)&&e.get("EXT_color_buffer_float"),Ae}function M(Y,$,de){return x(Y,de)===!0||Y.isFramebufferTexture&&Y.minFilter!==en&&Y.minFilter!==li?Math.log2(Math.max($.width,$.height))+1:Y.mipmaps!==void 0&&Y.mipmaps.length>0?Y.mipmaps.length:Y.isCompressedTexture&&Array.isArray(Y.image)?$.mipmaps.length:1}function T(Y){return Y===en||Y===FM||Y===s_?n.NEAREST:n.LINEAR}function R(Y){let $=Y.target;$.removeEventListener("dispose",R),P($),$.isVideoTexture&&p.delete($)}function C(Y){let $=Y.target;$.removeEventListener("dispose",C),I($)}function P(Y){let $=i.get(Y);if($.__webglInit===void 0)return;let de=Y.source,Te=y.get(de);if(Te){let fe=Te[$.__cacheKey];fe.usedTimes--,fe.usedTimes===0&&E(Y),Object.keys(Te).length===0&&y.delete(de)}i.remove(Y)}function E(Y){let $=i.get(Y);n.deleteTexture($.__webglTexture);let de=Y.source,Te=y.get(de);delete Te[$.__cacheKey],o.memory.textures--}function I(Y){let $=Y.texture,de=i.get(Y),Te=i.get($);if(Te.__webglTexture!==void 0&&(n.deleteTexture(Te.__webglTexture),o.memory.textures--),Y.depthTexture&&Y.depthTexture.dispose(),Y.isWebGLCubeRenderTarget)for(let fe=0;fe<6;fe++){if(Array.isArray(de.__webglFramebuffer[fe]))for(let Ae=0;Ae=l&&console.warn("THREE.WebGLTextures: Trying to use "+Y+" texture units while this GPU supports only "+l),O+=1,Y}function H(Y){let $=[];return $.push(Y.wrapS),$.push(Y.wrapT),$.push(Y.wrapR||0),$.push(Y.magFilter),$.push(Y.minFilter),$.push(Y.anisotropy),$.push(Y.internalFormat),$.push(Y.format),$.push(Y.type),$.push(Y.generateMipmaps),$.push(Y.premultiplyAlpha),$.push(Y.flipY),$.push(Y.unpackAlignment),$.push(Y.colorSpace),$.join()}function z(Y,$){let de=i.get(Y);if(Y.isVideoTexture&&We(Y),Y.isRenderTargetTexture===!1&&Y.version>0&&de.__version!==Y.version){let Te=Y.image;if(Te===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Te.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{se(de,Y,$);return}}t.bindTexture(n.TEXTURE_2D,de.__webglTexture,n.TEXTURE0+$)}function L(Y,$){let de=i.get(Y);if(Y.version>0&&de.__version!==Y.version){se(de,Y,$);return}t.bindTexture(n.TEXTURE_2D_ARRAY,de.__webglTexture,n.TEXTURE0+$)}function F(Y,$){let de=i.get(Y);if(Y.version>0&&de.__version!==Y.version){se(de,Y,$);return}t.bindTexture(n.TEXTURE_3D,de.__webglTexture,n.TEXTURE0+$)}function te(Y,$){let de=i.get(Y);if(Y.version>0&&de.__version!==Y.version){ne(de,Y,$);return}t.bindTexture(n.TEXTURE_CUBE_MAP,de.__webglTexture,n.TEXTURE0+$)}let Q={[V_]:n.REPEAT,[Gr]:n.CLAMP_TO_EDGE,[H_]:n.MIRRORED_REPEAT},Z={[en]:n.NEAREST,[FM]:n.NEAREST_MIPMAP_NEAREST,[s_]:n.NEAREST_MIPMAP_LINEAR,[li]:n.LINEAR,[UD]:n.LINEAR_MIPMAP_NEAREST,[xh]:n.LINEAR_MIPMAP_LINEAR},J={[QD]:n.NEVER,[o4]:n.ALWAYS,[e4]:n.LESS,[n4]:n.LEQUAL,[t4]:n.EQUAL,[s4]:n.GEQUAL,[i4]:n.GREATER,[r4]:n.NOTEQUAL};function re(Y,$,de){if(de?(n.texParameteri(Y,n.TEXTURE_WRAP_S,Q[$.wrapS]),n.texParameteri(Y,n.TEXTURE_WRAP_T,Q[$.wrapT]),(Y===n.TEXTURE_3D||Y===n.TEXTURE_2D_ARRAY)&&n.texParameteri(Y,n.TEXTURE_WRAP_R,Q[$.wrapR]),n.texParameteri(Y,n.TEXTURE_MAG_FILTER,Z[$.magFilter]),n.texParameteri(Y,n.TEXTURE_MIN_FILTER,Z[$.minFilter])):(n.texParameteri(Y,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(Y,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),(Y===n.TEXTURE_3D||Y===n.TEXTURE_2D_ARRAY)&&n.texParameteri(Y,n.TEXTURE_WRAP_R,n.CLAMP_TO_EDGE),($.wrapS!==Gr||$.wrapT!==Gr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(Y,n.TEXTURE_MAG_FILTER,T($.magFilter)),n.texParameteri(Y,n.TEXTURE_MIN_FILTER,T($.minFilter)),$.minFilter!==en&&$.minFilter!==li&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),$.compareFunction&&(n.texParameteri(Y,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(Y,n.TEXTURE_COMPARE_FUNC,J[$.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){let Te=e.get("EXT_texture_filter_anisotropic");if($.magFilter===en||$.minFilter!==s_&&$.minFilter!==xh||$.type===br&&e.has("OES_texture_float_linear")===!1||a===!1&&$.type===Go&&e.has("OES_texture_half_float_linear")===!1)return;($.anisotropy>1||i.get($).__currentAnisotropy)&&(n.texParameterf(Y,Te.TEXTURE_MAX_ANISOTROPY_EXT,Math.min($.anisotropy,r.getMaxAnisotropy())),i.get($).__currentAnisotropy=$.anisotropy)}}function X(Y,$){let de=!1;Y.__webglInit===void 0&&(Y.__webglInit=!0,$.addEventListener("dispose",R));let Te=$.source,fe=y.get(Te);fe===void 0&&(fe={},y.set(Te,fe));let Ae=H($);if(Ae!==Y.__cacheKey){fe[Ae]===void 0&&(fe[Ae]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,de=!0),fe[Ae].usedTimes++;let Be=fe[Y.__cacheKey];Be!==void 0&&(fe[Y.__cacheKey].usedTimes--,Be.usedTimes===0&&E($)),Y.__cacheKey=Ae,Y.__webglTexture=fe[Ae].texture}return de}function se(Y,$,de){let Te=n.TEXTURE_2D;($.isDataArrayTexture||$.isCompressedArrayTexture)&&(Te=n.TEXTURE_2D_ARRAY),$.isData3DTexture&&(Te=n.TEXTURE_3D);let fe=X(Y,$),Ae=$.source;t.bindTexture(Te,Y.__webglTexture,n.TEXTURE0+de);let Be=i.get(Ae);if(Ae.version!==Be.__version||fe===!0){t.activeTexture(n.TEXTURE0+de);let Ee=Qt.getPrimaries(Qt.workingColorSpace),Ue=$.colorSpace===xr?null:Qt.getPrimaries($.colorSpace),je=$.colorSpace===xr||Ee===Ue?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,$.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,$.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,$.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,je);let at=S($)&&v($.image)===!1,Pe=h($.image,at,!1,u);Pe=Fe($,Pe);let lt=v(Pe)||a,tt=s.convert($.format,$.colorSpace),He=s.convert($.type),Qe=A($.internalFormat,tt,He,$.colorSpace,$.isVideoTexture);re(Te,$,lt);let Oe,et=$.mipmaps,ie=a&&$.isVideoTexture!==!0,ye=Be.__version===void 0||fe===!0,pe=M($,Pe,lt);if($.isDepthTexture)Qe=n.DEPTH_COMPONENT,a?$.type===br?Qe=n.DEPTH_COMPONENT32F:$.type===Vo?Qe=n.DEPTH_COMPONENT24:$.type===Da?Qe=n.DEPTH24_STENCIL8:Qe=n.DEPTH_COMPONENT16:$.type===br&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),$.format===Na&&Qe===n.DEPTH_COMPONENT&&$.type!==Mv&&$.type!==Vo&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),$.type=Vo,He=s.convert($.type)),$.format===dc&&Qe===n.DEPTH_COMPONENT&&(Qe=n.DEPTH_STENCIL,$.type!==Da&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),$.type=Da,He=s.convert($.type))),ye&&(ie?t.texStorage2D(n.TEXTURE_2D,1,Qe,Pe.width,Pe.height):t.texImage2D(n.TEXTURE_2D,0,Qe,Pe.width,Pe.height,0,tt,He,null));else if($.isDataTexture)if(et.length>0&<){ie&&ye&&t.texStorage2D(n.TEXTURE_2D,pe,Qe,et[0].width,et[0].height);for(let ve=0,Ne=et.length;ve>=1,Ne>>=1}}else if(et.length>0&<){ie&&ye&&t.texStorage2D(n.TEXTURE_2D,pe,Qe,et[0].width,et[0].height);for(let ve=0,Ne=et.length;ve0&&ye++,t.texStorage2D(n.TEXTURE_CUBE_MAP,ye,Oe,Pe[0].width,Pe[0].height));for(let ve=0;ve<6;ve++)if(at){et?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,Pe[ve].width,Pe[ve].height,He,Qe,Pe[ve].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,Oe,Pe[ve].width,Pe[ve].height,0,He,Qe,Pe[ve].data);for(let Ne=0;Ne>Ae),Pe=Math.max(1,$.height>>Ae);fe===n.TEXTURE_3D||fe===n.TEXTURE_2D_ARRAY?t.texImage3D(fe,Ae,Ue,at,Pe,$.depth,0,Be,Ee,null):t.texImage2D(fe,Ae,Ue,at,Pe,0,Be,Ee,null)}t.bindFramebuffer(n.FRAMEBUFFER,Y),Ie($)?f.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Te,fe,i.get(de).__webglTexture,0,_e($)):(fe===n.TEXTURE_2D||fe>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&fe<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Te,fe,i.get(de).__webglTexture,Ae),t.bindFramebuffer(n.FRAMEBUFFER,null)}function ee(Y,$,de){if(n.bindRenderbuffer(n.RENDERBUFFER,Y),$.depthBuffer&&!$.stencilBuffer){let Te=a===!0?n.DEPTH_COMPONENT24:n.DEPTH_COMPONENT16;if(de||Ie($)){let fe=$.depthTexture;fe&&fe.isDepthTexture&&(fe.type===br?Te=n.DEPTH_COMPONENT32F:fe.type===Vo&&(Te=n.DEPTH_COMPONENT24));let Ae=_e($);Ie($)?f.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ae,Te,$.width,$.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,Ae,Te,$.width,$.height)}else n.renderbufferStorage(n.RENDERBUFFER,Te,$.width,$.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,Y)}else if($.depthBuffer&&$.stencilBuffer){let Te=_e($);de&&Ie($)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,Te,n.DEPTH24_STENCIL8,$.width,$.height):Ie($)?f.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Te,n.DEPTH24_STENCIL8,$.width,$.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,$.width,$.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,Y)}else{let Te=$.isWebGLMultipleRenderTargets===!0?$.texture:[$.texture];for(let fe=0;fe0){de.__webglFramebuffer[Ee]=[];for(let Ue=0;Ue<$.mipmaps.length;Ue++)de.__webglFramebuffer[Ee][Ue]=n.createFramebuffer()}else de.__webglFramebuffer[Ee]=n.createFramebuffer()}else{if(a&&$.mipmaps&&$.mipmaps.length>0){de.__webglFramebuffer=[];for(let Ee=0;Ee<$.mipmaps.length;Ee++)de.__webglFramebuffer[Ee]=n.createFramebuffer()}else de.__webglFramebuffer=n.createFramebuffer();if(Ae)if(r.drawBuffers){let Ee=Y.texture;for(let Ue=0,je=Ee.length;Ue0&&Ie(Y)===!1){let Ee=Ae?$:[$];de.__webglMultisampledFramebuffer=n.createFramebuffer(),de.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,de.__webglMultisampledFramebuffer);for(let Ue=0;Ue0)for(let Ue=0;Ue<$.mipmaps.length;Ue++)oe(de.__webglFramebuffer[Ee][Ue],Y,$,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,Ue);else oe(de.__webglFramebuffer[Ee],Y,$,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,0);x($,Be)&&w(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ae){let Ee=Y.texture;for(let Ue=0,je=Ee.length;Ue0)for(let Ue=0;Ue<$.mipmaps.length;Ue++)oe(de.__webglFramebuffer[Ue],Y,$,n.COLOR_ATTACHMENT0,Ee,Ue);else oe(de.__webglFramebuffer,Y,$,n.COLOR_ATTACHMENT0,Ee,0);x($,Be)&&w(Ee),t.unbindTexture()}Y.depthBuffer&&xe(Y)}function ke(Y){let $=v(Y)||a,de=Y.isWebGLMultipleRenderTargets===!0?Y.texture:[Y.texture];for(let Te=0,fe=de.length;Te0&&Ie(Y)===!1){let $=Y.isWebGLMultipleRenderTargets?Y.texture:[Y.texture],de=Y.width,Te=Y.height,fe=n.COLOR_BUFFER_BIT,Ae=[],Be=Y.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ee=i.get(Y),Ue=Y.isWebGLMultipleRenderTargets===!0;if(Ue)for(let je=0;je<$.length;je++)t.bindFramebuffer(n.FRAMEBUFFER,Ee.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+je,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ee.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+je,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ee.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ee.__webglFramebuffer);for(let je=0;je<$.length;je++){Ae.push(n.COLOR_ATTACHMENT0+je),Y.depthBuffer&&Ae.push(Be);let at=Ee.__ignoreDepthValues!==void 0?Ee.__ignoreDepthValues:!1;if(at===!1&&(Y.depthBuffer&&(fe|=n.DEPTH_BUFFER_BIT),Y.stencilBuffer&&(fe|=n.STENCIL_BUFFER_BIT)),Ue&&n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ee.__webglColorRenderbuffer[je]),at===!0&&(n.invalidateFramebuffer(n.READ_FRAMEBUFFER,[Be]),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[Be])),Ue){let Pe=i.get($[je]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Pe,0)}n.blitFramebuffer(0,0,de,Te,0,0,de,Te,fe,n.NEAREST),m&&n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Ae)}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Ue)for(let je=0;je<$.length;je++){t.bindFramebuffer(n.FRAMEBUFFER,Ee.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+je,n.RENDERBUFFER,Ee.__webglColorRenderbuffer[je]);let at=i.get($[je]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ee.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+je,n.TEXTURE_2D,at,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ee.__webglMultisampledFramebuffer)}}function _e(Y){return Math.min(d,Y.samples)}function Ie(Y){let $=i.get(Y);return a&&Y.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&$.__useRenderToTexture!==!1}function We(Y){let $=o.render.frame;p.get(Y)!==$&&(p.set(Y,$),Y.update())}function Fe(Y,$){let de=Y.colorSpace,Te=Y.format,fe=Y.type;return Y.isCompressedTexture===!0||Y.isVideoTexture===!0||Y.format===G_||de!==Xs&&de!==xr&&(Qt.getTransfer(de)===un?a===!1?e.has("EXT_sRGB")===!0&&Te===Ei?(Y.format=G_,Y.minFilter=li,Y.generateMipmaps=!1):$=Gp.sRGBToLinear($):(Te!==Ei||fe!==wr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",de)),$}this.allocateTextureUnit=N,this.resetTextureUnits=D,this.setTexture2D=z,this.setTexture2DArray=L,this.setTexture3D=F,this.setTextureCube=te,this.rebindTextures=Se,this.setupRenderTarget=Re,this.updateRenderTargetMipmap=ke,this.updateMultisampleRenderTarget=$e,this.setupDepthRenderbuffer=xe,this.setupFrameBufferTexture=oe,this.useMultisampledRTT=Ie}function jO(n,e,t){let i=t.isWebGL2;function r(s,o=xr){let a,l=Qt.getTransfer(o);if(s===wr)return n.UNSIGNED_BYTE;if(s===dE)return n.UNSIGNED_SHORT_4_4_4_4;if(s===fE)return n.UNSIGNED_SHORT_5_5_5_1;if(s===zD)return n.BYTE;if(s===VD)return n.SHORT;if(s===Mv)return n.UNSIGNED_SHORT;if(s===hE)return n.INT;if(s===Vo)return n.UNSIGNED_INT;if(s===br)return n.FLOAT;if(s===Go)return i?n.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===HD)return n.ALPHA;if(s===Ei)return n.RGBA;if(s===GD)return n.LUMINANCE;if(s===$D)return n.LUMINANCE_ALPHA;if(s===Na)return n.DEPTH_COMPONENT;if(s===dc)return n.DEPTH_STENCIL;if(s===G_)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===WD)return n.RED;if(s===pE)return n.RED_INTEGER;if(s===jD)return n.RG;if(s===mE)return n.RG_INTEGER;if(s===gE)return n.RGBA_INTEGER;if(s===o_||s===a_||s===l_||s===c_)if(l===un)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===o_)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===a_)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===l_)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===c_)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===o_)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===a_)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===l_)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===c_)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===OM||s===BM||s===UM||s===zM)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===OM)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===BM)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===UM)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===zM)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===XD)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===VM||s===HM)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===VM)return l===un?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===HM)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===GM||s===$M||s===WM||s===jM||s===XM||s===qM||s===YM||s===ZM||s===KM||s===JM||s===QM||s===eC||s===tC||s===nC)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===GM)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===$M)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===WM)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===jM)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===XM)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===qM)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===YM)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===ZM)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===KM)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===JM)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===QM)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===eC)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===tC)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===nC)return l===un?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===u_||s===iC||s===rC)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===u_)return l===un?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===iC)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===rC)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===qD||s===sC||s===oC||s===aC)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===u_)return a.COMPRESSED_RED_RGTC1_EXT;if(s===sC)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===oC)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===aC)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Da?i?n.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:r}}var rv=class extends ci{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},$t=class extends xi{constructor(){super(),this.isGroup=!0,this.type="Group"}},XO={type:"move"},vh=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new $t,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new $t,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new W,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new W),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new $t,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new W,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new W),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(let _ of e.hand.values()){let y=t.getJointPose(_,i),g=this._getHandJoint(c,_);y!==null&&(g.matrix.fromArray(y.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=y.radius),g.visible=y!==null}let u=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],f=u.position.distanceTo(d.position),m=.02,p=.005;c.inputState.pinching&&f>m+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=m-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(XO)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new $t;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},sv=class extends tr{constructor(e,t,i,r,s,o,a,l,c,u){if(u=u!==void 0?u:Na,u!==Na&&u!==dc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Na&&(i=Vo),i===void 0&&u===dc&&(i=Da),super(null,r,s,o,a,l,u,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:en,this.minFilter=l!==void 0?l:en,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},ov=class extends $o{constructor(e,t){super();let i=this,r=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,d=null,f=null,m=null,p=null,_=t.getContextAttributes(),y=null,g=null,b=[],h=[],v=new ci;v.layers.enable(1),v.viewport=new ti;let S=new ci;S.layers.enable(2),S.viewport=new ti;let x=[v,S],w=new rv;w.layers.enable(1),w.layers.enable(2);let A=null,M=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(L){let F=b[L];return F===void 0&&(F=new vh,b[L]=F),F.getTargetRaySpace()},this.getControllerGrip=function(L){let F=b[L];return F===void 0&&(F=new vh,b[L]=F),F.getGripSpace()},this.getHand=function(L){let F=b[L];return F===void 0&&(F=new vh,b[L]=F),F.getHandSpace()};function T(L){let F=h.indexOf(L.inputSource);if(F===-1)return;let te=b[F];te!==void 0&&(te.update(L.inputSource,L.frame,c||o),te.dispatchEvent({type:L.type,data:L.inputSource}))}function R(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",R),r.removeEventListener("inputsourceschange",C);for(let L=0;L=0&&(h[Q]=null,b[Q].disconnect(te))}for(let F=0;F=h.length){h.push(te),Q=J;break}else if(h[J]===null){h[J]=te,Q=J;break}if(Q===-1)break}let Z=b[Q];Z&&Z.connect(te)}}let P=new W,E=new W;function I(L,F,te){P.setFromMatrixPosition(F.matrixWorld),E.setFromMatrixPosition(te.matrixWorld);let Q=P.distanceTo(E),Z=F.projectionMatrix.elements,J=te.projectionMatrix.elements,re=Z[14]/(Z[10]-1),X=Z[14]/(Z[10]+1),se=(Z[9]+1)/Z[5],ne=(Z[9]-1)/Z[5],oe=(Z[8]-1)/Z[0],ee=(J[8]+1)/J[0],le=re*oe,xe=re*ee,Se=Q/(-oe+ee),Re=Se*-oe;F.matrixWorld.decompose(L.position,L.quaternion,L.scale),L.translateX(Re),L.translateZ(Se),L.matrixWorld.compose(L.position,L.quaternion,L.scale),L.matrixWorldInverse.copy(L.matrixWorld).invert();let ke=re+Se,$e=X+Se,_e=le-Re,Ie=xe+(Q-Re),We=se*X/$e*ke,Fe=ne*X/$e*ke;L.projectionMatrix.makePerspective(_e,Ie,We,Fe,ke,$e),L.projectionMatrixInverse.copy(L.projectionMatrix).invert()}function O(L,F){F===null?L.matrixWorld.copy(L.matrix):L.matrixWorld.multiplyMatrices(F.matrixWorld,L.matrix),L.matrixWorldInverse.copy(L.matrixWorld).invert()}this.updateCamera=function(L){if(r===null)return;w.near=S.near=v.near=L.near,w.far=S.far=v.far=L.far,(A!==w.near||M!==w.far)&&(r.updateRenderState({depthNear:w.near,depthFar:w.far}),A=w.near,M=w.far);let F=L.parent,te=w.cameras;O(w,F);for(let Q=0;Q0&&(y.alphaTest.value=g.alphaTest);let b=e.get(g).envMap;if(b&&(y.envMap.value=b,y.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=g.reflectivity,y.ior.value=g.ior,y.refractionRatio.value=g.refractionRatio),g.lightMap){y.lightMap.value=g.lightMap;let h=n._useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=g.lightMapIntensity*h,t(g.lightMap,y.lightMapTransform)}g.aoMap&&(y.aoMap.value=g.aoMap,y.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,y.aoMapTransform))}function o(y,g){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,g.map&&(y.map.value=g.map,t(g.map,y.mapTransform))}function a(y,g){y.dashSize.value=g.dashSize,y.totalSize.value=g.dashSize+g.gapSize,y.scale.value=g.scale}function l(y,g,b,h){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,y.size.value=g.size*b,y.scale.value=h*.5,g.map&&(y.map.value=g.map,t(g.map,y.uvTransform)),g.alphaMap&&(y.alphaMap.value=g.alphaMap,t(g.alphaMap,y.alphaMapTransform)),g.alphaTest>0&&(y.alphaTest.value=g.alphaTest)}function c(y,g){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,y.rotation.value=g.rotation,g.map&&(y.map.value=g.map,t(g.map,y.mapTransform)),g.alphaMap&&(y.alphaMap.value=g.alphaMap,t(g.alphaMap,y.alphaMapTransform)),g.alphaTest>0&&(y.alphaTest.value=g.alphaTest)}function u(y,g){y.specular.value.copy(g.specular),y.shininess.value=Math.max(g.shininess,1e-4)}function d(y,g){g.gradientMap&&(y.gradientMap.value=g.gradientMap)}function f(y,g){y.metalness.value=g.metalness,g.metalnessMap&&(y.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,y.metalnessMapTransform)),y.roughness.value=g.roughness,g.roughnessMap&&(y.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,y.roughnessMapTransform)),e.get(g).envMap&&(y.envMapIntensity.value=g.envMapIntensity)}function m(y,g,b){y.ior.value=g.ior,g.sheen>0&&(y.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),y.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(y.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,y.sheenColorMapTransform)),g.sheenRoughnessMap&&(y.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,y.sheenRoughnessMapTransform))),g.clearcoat>0&&(y.clearcoat.value=g.clearcoat,y.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(y.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,y.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(y.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===vi&&y.clearcoatNormalScale.value.negate())),g.iridescence>0&&(y.iridescence.value=g.iridescence,y.iridescenceIOR.value=g.iridescenceIOR,y.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(y.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,y.iridescenceMapTransform)),g.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),g.transmission>0&&(y.transmission.value=g.transmission,y.transmissionSamplerMap.value=b.texture,y.transmissionSamplerSize.value.set(b.width,b.height),g.transmissionMap&&(y.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,y.transmissionMapTransform)),y.thickness.value=g.thickness,g.thicknessMap&&(y.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=g.attenuationDistance,y.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(y.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(y.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=g.specularIntensity,y.specularColor.value.copy(g.specularColor),g.specularColorMap&&(y.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,y.specularColorMapTransform)),g.specularIntensityMap&&(y.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,y.specularIntensityMapTransform))}function p(y,g){g.matcap&&(y.matcap.value=g.matcap)}function _(y,g){let b=e.get(g).light;y.referencePosition.value.setFromMatrixPosition(b.matrixWorld),y.nearDistance.value=b.shadow.camera.near,y.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function YO(n,e,t,i){let r={},s={},o=[],a=t.isWebGL2?n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(b,h){let v=h.program;i.uniformBlockBinding(b,v)}function c(b,h){let v=r[b.id];v===void 0&&(p(b),v=u(b),r[b.id]=v,b.addEventListener("dispose",y));let S=h.program;i.updateUBOMapping(b,S);let x=e.render.frame;s[b.id]!==x&&(f(b),s[b.id]=x)}function u(b){let h=d();b.__bindingPointIndex=h;let v=n.createBuffer(),S=b.__size,x=b.usage;return n.bindBuffer(n.UNIFORM_BUFFER,v),n.bufferData(n.UNIFORM_BUFFER,S,x),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,h,v),v}function d(){for(let b=0;b0){x=v%S;let C=S-x;x!==0&&C-T.boundary<0&&(v+=S-x,M.__offset=v)}v+=T.storage}return x=v%S,x>0&&(v+=S-x),b.__size=v,b.__cache={},this}function _(b){let h={boundary:0,storage:0};return typeof b=="number"?(h.boundary=4,h.storage=4):b.isVector2?(h.boundary=8,h.storage=8):b.isVector3||b.isColor?(h.boundary=16,h.storage=12):b.isVector4?(h.boundary=16,h.storage=16):b.isMatrix3?(h.boundary=48,h.storage=48):b.isMatrix4?(h.boundary=64,h.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),h}function y(b){let h=b.target;h.removeEventListener("dispose",y);let v=o.indexOf(h.__bindingPointIndex);o.splice(v,1),n.deleteBuffer(r[h.id]),delete r[h.id],delete s[h.id]}function g(){for(let b in r)n.deleteBuffer(r[b]);o=[],r={},s={}}return{bind:l,update:c,dispose:g}}var Ah=class{constructor(e={}){let{canvas:t=l4(),context:i=null,depth:r=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let f;i!==null?f=i.getContextAttributes().alpha:f=o;let m=new Uint32Array(4),p=new Int32Array(4),_=null,y=null,g=[],b=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=ai,this._useLegacyLights=!1,this.toneMapping=Ho,this.toneMappingExposure=1;let h=this,v=!1,S=0,x=0,w=null,A=-1,M=null,T=new ti,R=new ti,C=null,P=new dt(0),E=0,I=t.width,O=t.height,D=1,N=null,H=null,z=new ti(0,0,I,O),L=new ti(0,0,I,O),F=!1,te=new wh,Q=!1,Z=!1,J=null,re=new qe,X=new Et,se=new W,ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function oe(){return w===null?D:1}let ee=i;function le(j,he){for(let be=0;be{function rt(){if(Me.forEach(function(ct){$e.get(ct).currentProgram.isReady()&&Me.delete(ct)}),Me.size===0){ge(j);return}setTimeout(rt,10)}xe.get("KHR_parallel_shader_compile")!==null?rt():setTimeout(rt,10)})};let wt=null;function k(j){wt&&wt(j)}function G(){q.stop()}function V(){q.start()}let q=new bE;q.setAnimationLoop(k),typeof self<"u"&&q.setContext(self),this.setAnimationLoop=function(j){wt=j,Oe.setAnimationLoop(j),j===null?q.stop():q.start()},Oe.addEventListener("sessionstart",G),Oe.addEventListener("sessionend",V),this.render=function(j,he){if(he!==void 0&&he.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;j.matrixWorldAutoUpdate===!0&&j.updateMatrixWorld(),he.parent===null&&he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),Oe.enabled===!0&&Oe.isPresenting===!0&&(Oe.cameraAutoUpdate===!0&&Oe.updateCamera(he),he=Oe.getCamera()),j.isScene===!0&&j.onBeforeRender(h,j,he,w),y=Ae.get(j,b.length),y.init(),b.push(y),re.multiplyMatrices(he.projectionMatrix,he.matrixWorldInverse),te.setFromProjectionMatrix(re),Z=this.localClippingEnabled,Q=Be.init(this.clippingPlanes,Z),_=fe.get(j,g.length),_.init(),g.push(_),K(j,he,0,h.sortObjects),_.finish(),h.sortObjects===!0&&_.sort(N,H),this.info.render.frame++,Q===!0&&Be.beginShadows();let be=y.state.shadowsArray;if(Ee.render(be,j,he),Q===!0&&Be.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ue.render(_,j),y.setupLights(h._useLegacyLights),he.isArrayCamera){let Me=he.cameras;for(let ge=0,rt=Me.length;ge0?y=b[b.length-1]:y=null,g.pop(),g.length>0?_=g[g.length-1]:_=null};function K(j,he,be,Me){if(j.visible===!1)return;if(j.layers.test(he.layers)){if(j.isGroup)be=j.renderOrder;else if(j.isLOD)j.autoUpdate===!0&&j.update(he);else if(j.isLight)y.pushLight(j),j.castShadow&&y.pushShadow(j);else if(j.isSprite){if(!j.frustumCulled||te.intersectsSprite(j)){Me&&se.setFromMatrixPosition(j.matrixWorld).applyMatrix4(re);let ct=$.update(j),Ke=j.material;Ke.visible&&_.push(j,ct,Ke,be,se.z,null)}}else if((j.isMesh||j.isLine||j.isPoints)&&(!j.frustumCulled||te.intersectsObject(j))){let ct=$.update(j),Ke=j.material;if(Me&&(j.boundingSphere!==void 0?(j.boundingSphere===null&&j.computeBoundingSphere(),se.copy(j.boundingSphere.center)):(ct.boundingSphere===null&&ct.computeBoundingSphere(),se.copy(ct.boundingSphere.center)),se.applyMatrix4(j.matrixWorld).applyMatrix4(re)),Array.isArray(Ke)){let nt=ct.groups;for(let vt=0,Ce=nt.length;vt0&&ue(ge,rt,he,be),Me&&Re.viewport(T.copy(Me)),ge.length>0&&me(ge,he,be),rt.length>0&&me(rt,he,be),ct.length>0&&me(ct,he,be),Re.buffers.depth.setTest(!0),Re.buffers.depth.setMask(!0),Re.buffers.color.setMask(!0),Re.setPolygonOffset(!1)}function ue(j,he,be,Me){if((be.isScene===!0?be.overrideMaterial:null)!==null)return;let rt=Se.isWebGL2;J===null&&(J=new nr(1,1,{generateMipmaps:!0,type:xe.has("EXT_color_buffer_half_float")?Go:wr,minFilter:xh,samples:rt?4:0})),h.getDrawingBufferSize(X),rt?J.setSize(X.x,X.y):J.setSize(W_(X.x),W_(X.y));let ct=h.getRenderTarget();h.setRenderTarget(J),h.getClearColor(P),E=h.getClearAlpha(),E<1&&h.setClearColor(16777215,.5),h.clear();let Ke=h.toneMapping;h.toneMapping=Ho,me(j,be,Me),_e.updateMultisampleRenderTarget(J),_e.updateRenderTargetMipmap(J);let nt=!1;for(let vt=0,Ce=he.length;vt0),Ve=!!be.morphAttributes.position,ft=!!be.morphAttributes.normal,St=!!be.morphAttributes.color,pt=Ho;Me.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(pt=h.toneMapping);let Ct=be.morphAttributes.position||be.morphAttributes.normal||be.morphAttributes.color,xt=Ct!==void 0?Ct.length:0,ot=$e.get(Me),Pn=y.state.lights;if(Q===!0&&(Z===!0||j!==M)){let $n=j===M&&Me.id===A;Be.setState(Me,j,$n)}let _t=!1;Me.version===ot.__version?(ot.needsLights&&ot.lightsStateVersion!==Pn.state.version||ot.outputColorSpace!==Ke||ge.isInstancedMesh&&ot.instancing===!1||!ge.isInstancedMesh&&ot.instancing===!0||ge.isSkinnedMesh&&ot.skinning===!1||!ge.isSkinnedMesh&&ot.skinning===!0||ge.isInstancedMesh&&ot.instancingColor===!0&&ge.instanceColor===null||ge.isInstancedMesh&&ot.instancingColor===!1&&ge.instanceColor!==null||ot.envMap!==nt||Me.fog===!0&&ot.fog!==rt||ot.numClippingPlanes!==void 0&&(ot.numClippingPlanes!==Be.numPlanes||ot.numIntersection!==Be.numIntersection)||ot.vertexAlphas!==vt||ot.vertexTangents!==Ce||ot.morphTargets!==Ve||ot.morphNormals!==ft||ot.morphColors!==St||ot.toneMapping!==pt||Se.isWebGL2===!0&&ot.morphTargetsCount!==xt)&&(_t=!0):(_t=!0,ot.__version=Me.version);let fn=ot.currentProgram;_t===!0&&(fn=ze(Me,he,ge));let Kn=!1,Ir=!1,Cs=!1,Ln=fn.getUniforms(),Wi=ot.uniforms;if(Re.useProgram(fn.program)&&(Kn=!0,Ir=!0,Cs=!0),Me.id!==A&&(A=Me.id,Ir=!0),Kn||M!==j){Ln.setValue(ee,"projectionMatrix",j.projectionMatrix),Ln.setValue(ee,"viewMatrix",j.matrixWorldInverse);let $n=Ln.map.cameraPosition;$n!==void 0&&$n.setValue(ee,se.setFromMatrixPosition(j.matrixWorld)),Se.logarithmicDepthBuffer&&Ln.setValue(ee,"logDepthBufFC",2/(Math.log(j.far+1)/Math.LN2)),(Me.isMeshPhongMaterial||Me.isMeshToonMaterial||Me.isMeshLambertMaterial||Me.isMeshBasicMaterial||Me.isMeshStandardMaterial||Me.isShaderMaterial)&&Ln.setValue(ee,"isOrthographic",j.isOrthographicCamera===!0),M!==j&&(M=j,Ir=!0,Cs=!0)}if(ge.isSkinnedMesh){Ln.setOptional(ee,ge,"bindMatrix"),Ln.setOptional(ee,ge,"bindMatrixInverse");let $n=ge.skeleton;$n&&(Se.floatVertexTextures?($n.boneTexture===null&&$n.computeBoneTexture(),Ln.setValue(ee,"boneTexture",$n.boneTexture,_e),Ln.setValue(ee,"boneTextureSize",$n.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let Es=be.morphAttributes;if((Es.position!==void 0||Es.normal!==void 0||Es.color!==void 0&&Se.isWebGL2===!0)&&je.update(ge,be,fn),(Ir||ot.receiveShadow!==ge.receiveShadow)&&(ot.receiveShadow=ge.receiveShadow,Ln.setValue(ee,"receiveShadow",ge.receiveShadow)),Me.isMeshGouraudMaterial&&Me.envMap!==null&&(Wi.envMap.value=nt,Wi.flipEnvMap.value=nt.isCubeTexture&&nt.isRenderTargetTexture===!1?-1:1),Ir&&(Ln.setValue(ee,"toneMappingExposure",h.toneMappingExposure),ot.needsLights&&Ge(Wi,Cs),rt&&Me.fog===!0&&Te.refreshFogUniforms(Wi,rt),Te.refreshMaterialUniforms(Wi,Me,D,O,J),cc.upload(ee,Ye(ot),Wi,_e)),Me.isShaderMaterial&&Me.uniformsNeedUpdate===!0&&(cc.upload(ee,Ye(ot),Wi,_e),Me.uniformsNeedUpdate=!1),Me.isSpriteMaterial&&Ln.setValue(ee,"center",ge.center),Ln.setValue(ee,"modelViewMatrix",ge.modelViewMatrix),Ln.setValue(ee,"normalMatrix",ge.normalMatrix),Ln.setValue(ee,"modelMatrix",ge.matrixWorld),Me.isShaderMaterial||Me.isRawShaderMaterial){let $n=Me.uniformsGroups;for(let hl=0,ca=$n.length;hl0&&_e.useMultisampledRTT(j)===!1?ge=$e.get(j).__webglMultisampledFramebuffer:Array.isArray(Ce)?ge=Ce[be]:ge=Ce,T.copy(j.viewport),R.copy(j.scissor),C=j.scissorTest}else T.copy(z).multiplyScalar(D).floor(),R.copy(L).multiplyScalar(D).floor(),C=F;if(Re.bindFramebuffer(ee.FRAMEBUFFER,ge)&&Se.drawBuffers&&Me&&Re.drawBuffers(j,ge),Re.viewport(T),Re.scissor(R),Re.setScissorTest(C),rt){let nt=$e.get(j.texture);ee.framebufferTexture2D(ee.FRAMEBUFFER,ee.COLOR_ATTACHMENT0,ee.TEXTURE_CUBE_MAP_POSITIVE_X+he,nt.__webglTexture,be)}else if(ct){let nt=$e.get(j.texture),vt=he||0;ee.framebufferTextureLayer(ee.FRAMEBUFFER,ee.COLOR_ATTACHMENT0,nt.__webglTexture,be||0,vt)}A=-1},this.readRenderTargetPixels=function(j,he,be,Me,ge,rt,ct){if(!(j&&j.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ke=$e.get(j).__webglFramebuffer;if(j.isWebGLCubeRenderTarget&&ct!==void 0&&(Ke=Ke[ct]),Ke){Re.bindFramebuffer(ee.FRAMEBUFFER,Ke);try{let nt=j.texture,vt=nt.format,Ce=nt.type;if(vt!==Ei&<.convert(vt)!==ee.getParameter(ee.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Ve=Ce===Go&&(xe.has("EXT_color_buffer_half_float")||Se.isWebGL2&&xe.has("EXT_color_buffer_float"));if(Ce!==wr&<.convert(Ce)!==ee.getParameter(ee.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ce===br&&(Se.isWebGL2||xe.has("OES_texture_float")||xe.has("WEBGL_color_buffer_float")))&&!Ve){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}he>=0&&he<=j.width-Me&&be>=0&&be<=j.height-ge&&ee.readPixels(he,be,Me,ge,lt.convert(vt),lt.convert(Ce),rt)}finally{let nt=w!==null?$e.get(w).__webglFramebuffer:null;Re.bindFramebuffer(ee.FRAMEBUFFER,nt)}}},this.copyFramebufferToTexture=function(j,he,be=0){let Me=Math.pow(2,-be),ge=Math.floor(he.image.width*Me),rt=Math.floor(he.image.height*Me);_e.setTexture2D(he,0),ee.copyTexSubImage2D(ee.TEXTURE_2D,be,0,0,j.x,j.y,ge,rt),Re.unbindTexture()},this.copyTextureToTexture=function(j,he,be,Me=0){let ge=he.image.width,rt=he.image.height,ct=lt.convert(be.format),Ke=lt.convert(be.type);_e.setTexture2D(be,0),ee.pixelStorei(ee.UNPACK_FLIP_Y_WEBGL,be.flipY),ee.pixelStorei(ee.UNPACK_PREMULTIPLY_ALPHA_WEBGL,be.premultiplyAlpha),ee.pixelStorei(ee.UNPACK_ALIGNMENT,be.unpackAlignment),he.isDataTexture?ee.texSubImage2D(ee.TEXTURE_2D,Me,j.x,j.y,ge,rt,ct,Ke,he.image.data):he.isCompressedTexture?ee.compressedTexSubImage2D(ee.TEXTURE_2D,Me,j.x,j.y,he.mipmaps[0].width,he.mipmaps[0].height,ct,he.mipmaps[0].data):ee.texSubImage2D(ee.TEXTURE_2D,Me,j.x,j.y,ct,Ke,he.image),Me===0&&be.generateMipmaps&&ee.generateMipmap(ee.TEXTURE_2D),Re.unbindTexture()},this.copyTextureToTexture3D=function(j,he,be,Me,ge=0){if(h.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let rt=j.max.x-j.min.x+1,ct=j.max.y-j.min.y+1,Ke=j.max.z-j.min.z+1,nt=lt.convert(Me.format),vt=lt.convert(Me.type),Ce;if(Me.isData3DTexture)_e.setTexture3D(Me,0),Ce=ee.TEXTURE_3D;else if(Me.isDataArrayTexture)_e.setTexture2DArray(Me,0),Ce=ee.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ee.pixelStorei(ee.UNPACK_FLIP_Y_WEBGL,Me.flipY),ee.pixelStorei(ee.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Me.premultiplyAlpha),ee.pixelStorei(ee.UNPACK_ALIGNMENT,Me.unpackAlignment);let Ve=ee.getParameter(ee.UNPACK_ROW_LENGTH),ft=ee.getParameter(ee.UNPACK_IMAGE_HEIGHT),St=ee.getParameter(ee.UNPACK_SKIP_PIXELS),pt=ee.getParameter(ee.UNPACK_SKIP_ROWS),Ct=ee.getParameter(ee.UNPACK_SKIP_IMAGES),xt=be.isCompressedTexture?be.mipmaps[0]:be.image;ee.pixelStorei(ee.UNPACK_ROW_LENGTH,xt.width),ee.pixelStorei(ee.UNPACK_IMAGE_HEIGHT,xt.height),ee.pixelStorei(ee.UNPACK_SKIP_PIXELS,j.min.x),ee.pixelStorei(ee.UNPACK_SKIP_ROWS,j.min.y),ee.pixelStorei(ee.UNPACK_SKIP_IMAGES,j.min.z),be.isDataTexture||be.isData3DTexture?ee.texSubImage3D(Ce,ge,he.x,he.y,he.z,rt,ct,Ke,nt,vt,xt.data):be.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ee.compressedTexSubImage3D(Ce,ge,he.x,he.y,he.z,rt,ct,Ke,nt,xt.data)):ee.texSubImage3D(Ce,ge,he.x,he.y,he.z,rt,ct,Ke,nt,vt,xt),ee.pixelStorei(ee.UNPACK_ROW_LENGTH,Ve),ee.pixelStorei(ee.UNPACK_IMAGE_HEIGHT,ft),ee.pixelStorei(ee.UNPACK_SKIP_PIXELS,St),ee.pixelStorei(ee.UNPACK_SKIP_ROWS,pt),ee.pixelStorei(ee.UNPACK_SKIP_IMAGES,Ct),ge===0&&Me.generateMipmaps&&ee.generateMipmap(Ce),Re.unbindTexture()},this.initTexture=function(j){j.isCubeTexture?_e.setTextureCube(j,0):j.isData3DTexture?_e.setTexture3D(j,0):j.isDataArrayTexture||j.isCompressedArrayTexture?_e.setTexture2DArray(j,0):_e.setTexture2D(j,0),Re.unbindTexture()},this.resetState=function(){S=0,x=0,w=null,Re.reset(),tt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return js}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===Cv?"display-p3":"srgb",t.unpackColorSpace=Qt.workingColorSpace===um?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===ai?Fa:yE}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Fa?ai:Xs}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}},av=class extends Ah{};av.prototype.isWebGL1Renderer=!0;var Qp=class n{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new dt(e),this.near=t,this.far=i}clone(){return new n(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Mh=class extends xi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}};var pc=class extends tr{constructor(e=null,t=1,i=1,r,s,o,a,l,c=en,u=en,d,f){super(null,o,a,l,c,u,r,s,d,f),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var lv=class extends Wo{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new dt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},KC=new W,JC=new W,QC=new qe,N_=new bh,Pp=new Oa,cv=class extends xi{constructor(e=new Vn,t=new lv){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;rl)continue;f.applyMatrix4(this.matrixWorld);let A=e.ray.origin.distanceTo(f);Ae.far||t.push({distance:A,point:d.clone().applyMatrix4(this.matrixWorld),index:h,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,o.start),b=Math.min(y.count,o.start+o.count);for(let h=g,v=b-1;hl)continue;f.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(f);xe.far||t.push({distance:x,point:d.clone().applyMatrix4(this.matrixWorld),index:h,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;sr.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}var em=class extends tr{constructor(e,t,i,r,s,o,a,l,c){super(e,t,i,r,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var Eh=class n extends Vn{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;r=Math.floor(r),s=Math.floor(s);let u=[],d=[],f=[],m=[],p=0,_=[],y=i/2,g=0;b(),o===!1&&(e>0&&h(!0),t>0&&h(!1)),this.setIndex(u),this.setAttribute("position",new zn(d,3)),this.setAttribute("normal",new zn(f,3)),this.setAttribute("uv",new zn(m,2));function b(){let v=new W,S=new W,x=0,w=(t-e)/i;for(let A=0;A<=s;A++){let M=[],T=A/s,R=T*(t-e)+e;for(let C=0;C<=r;C++){let P=C/r,E=P*l+a,I=Math.sin(E),O=Math.cos(E);S.x=R*I,S.y=-T*i+y,S.z=R*O,d.push(S.x,S.y,S.z),v.set(I,w,O).normalize(),f.push(v.x,v.y,v.z),m.push(P,1-T),M.push(p++)}_.push(M)}for(let A=0;A.9&&w<.1&&(h<.2&&(o[b+0]+=1),v<.2&&(o[b+2]+=1),S<.2&&(o[b+4]+=1))}}function f(b){s.push(b.x,b.y,b.z)}function m(b,h){let v=b*3;h.x=e[v+0],h.y=e[v+1],h.z=e[v+2]}function p(){let b=new W,h=new W,v=new W,S=new W,x=new Et,w=new Et,A=new Et;for(let M=0,T=0;M=s)){let a=t[1];e=s)break t}o=i,i=0;break n}break e}for(;i>>1;et;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(r!==void 0&&ZO(r))for(let a=0,l=r.length;a!==l;++a){let c=r[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===h_,s=e.length-1,o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*i,l=o*i,c=0;c!==i;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};$r.prototype.TimeBufferType=Float32Array;$r.prototype.ValueBufferType=Float32Array;$r.prototype.DefaultInterpolation=Op;var za=class extends $r{};za.prototype.ValueTypeName="bool";za.prototype.ValueBufferType=Array;za.prototype.DefaultInterpolation=Fp;za.prototype.InterpolantFactoryMethodLinear=void 0;za.prototype.InterpolantFactoryMethodSmooth=void 0;var mv=class extends $r{};mv.prototype.ValueTypeName="color";var gv=class extends $r{};gv.prototype.ValueTypeName="number";var yv=class extends gc{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(i-t)/(r-t),c=e*a;for(let u=c+a;c!==u;c+=4)Xn.slerpFlat(s,0,o,c-a,o,c,l);return s}},Ih=class extends $r{InterpolantFactoryMethodLinear(e){return new yv(this.times,this.values,this.getValueSize(),e)}};Ih.prototype.ValueTypeName="quaternion";Ih.prototype.DefaultInterpolation=Op;Ih.prototype.InterpolantFactoryMethodSmooth=void 0;var Va=class extends $r{};Va.prototype.ValueTypeName="string";Va.prototype.ValueBufferType=Array;Va.prototype.DefaultInterpolation=Fp;Va.prototype.InterpolantFactoryMethodLinear=void 0;Va.prototype.InterpolantFactoryMethodSmooth=void 0;var _v=class extends $r{};_v.prototype.ValueTypeName="vector";var vv=class{constructor(e,t,i){let r=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,d){return c.push(u,d),this},this.removeHandler=function(u){let d=c.indexOf(u);return d!==-1&&c.splice(d,2),this},this.getHandler=function(u){for(let d=0,f=c.length;d"u")return;let e=new RegExp(`${n}=([^&#=]*)`).exec(window.location.search);return e?decodeURIComponent(e[1]):void 0}function U(n,e){return n!==void 0?n:e}function or(n,e){let t=Object.assign({},n);for(let i in e)n[i]===void 0&&(t[i]=e[i]);return t}function RP(n,e){for(let t in e){let i=e[t];i!==void 0&&(n[t]=i)}return n}function aB(){if(typeof window>"u")return!1;let n=window.navigator.userAgent;return/Opera|OPR/.test(n)?"Opera":/Chrome/i.test(n)?"Chrome":/Firefox/i.test(n)?"Firefox":/Mobile(\/.*)? Safari/i.test(n)?"Mobile Safari":/MSIE/i.test(n)?"Internet Explorer":!!/Safari/i.test(n)&&"Safari"}function lB(n,e){return ne?1:0}function ja(n,e,t=lB){let i=0,r=n.length-1;for(;i<=r;){let s=i+r>>1,o=t(e,n[s]);if(o>0)i=s+1;else{if(!(o<0))return s;r=s-1}}return-i-1}function yw(n,e,t){let i=function(s,o){let a=s.length-1;if(s[a]>1;s[c]>=o?a=c-1:l=c+1}return a+1}(n,e),r=function(s,o){if(s[0]>o)return-1;let a=0,l=s.length-1;for(;a<=l;){let c=a+l>>1;s[c]>o?l=c-1:a=c+1}return a-1}(n,t);return i===-1||r===-1||i>r?0:r-i+1}function _w(n){return n.sort().filter(function(e,t,i){return t===0||e!==i[t-1]})}function pd(n){if(n.length>28672){let t=[];for(let i=0;i65535?Uint32Array:Uint16Array)(n)}function ou(n){return n.buffer&&n.buffer instanceof ArrayBuffer?n.buffer:n}function C0(n,e){return n===void 0?n=new e:Array.isArray(n)&&(n=new e().fromArray(n)),n}function Za(n){return C0(n,W)}function jh(n){return C0(n,qe)}function Nx(n){return C0(n,Xn)}function Iv(n){return e=n,t=Float32Array,e instanceof t?e:new t(e);var e,t}function PE(n){return U(n,"").toString().toLowerCase()}var ws=class{constructor(e){this.name=e,this._dict={}}add(e,t){this._dict[PE(e)]=t}get(e){return this._dict[PE(e)]}get names(){return Object.keys(this._dict)}};function En(n){return .01745*n}var cB="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),mm=new Array(36);function vw(){let n,e=0;for(let t=0;t<36;t++)t===8||t===13||t===18||t===23?mm[t]="-":t===14?mm[t]="4":(e<=2&&(e=33554432+16777216*Math.random()|0),n=15&e,e>>=4,mm[t]=cB[t===19?3&n|8:n]);return mm.join("")}function Fx(n,e,t){return Math.max(e,Math.min(t,n))}function Cr(n,e,t){return n+(e-n)*t}function no(n,e,t,i,r,s){let o=(t-n)*s,a=(i-e)*s,l=r*r;return(2*e-2*t+o+a)*(r*l)+(-3*e+3*t-2*o-a)*l+o*r+e}function Pd(n,e,t){var i;return i=function(r,s,o){return(r-s)/(o-s)}(t,n,e),(t=Fx(i,0,1))*t*(3-2*t)}var LP="sRGB",uB={scale:"uniform",mode:"hcl",domain:[0,1],value:16777215,reverse:!1},$m=new dt;function Xt(n,e,t){let i=t.value;return t.value=function(r,s){let o=i.bind(this,r,s)();return LP=="linear"?($m.set(o),$m.convertSRGBToLinear(),$m.getHex()):o},t}var Yt=class{constructor(e={}){this.parameters=or(e,uB),typeof this.parameters.value=="string"&&(this.parameters.value=$m.set(this.parameters.value).getHex()),this.parameters.structure&&(this.atomProxy=this.parameters.structure.getAtomProxy())}getScale(e={}){let t=or(e,this.parameters);return t.scale==="rainbow"?t.scale=["red","orange","yellow","green","blue"]:t.scale==="rwb"&&(t.scale=["red","white","blue"]),t.reverse&&(t.domain=t.domain.slice().reverse()),PP.scale(t.scale).mode(t.mode).domain(t.domain).out("num")}colorToArray(e,t=[],i=0){return t[i]=(e>>16&255)/255,t[i+1]=(e>>8&255)/255,t[i+2]=(255&e)/255,t}atomColorToArray(e,t,i){return this.colorToArray(this.atomColor?this.atomColor(e):0,t,i)}bondColor(e,t){return this.atomProxy&&this.atomColor?(this.atomProxy.index=t?e.atomIndex1:e.atomIndex2,this.atomColor(this.atomProxy)):0}bondColorToArray(e,t,i,r){return this.colorToArray(this.bondColor(e,t),i,r)}volumeColorToArray(e,t,i){return this.colorToArray(this.volumeColor?this.volumeColor(e):0,t,i)}positionColorToArray(e,t,i){return this.colorToArray(this.positionColor?this.positionColor(e):0,t,i)}},yt;(function(n){n[n.PROTEIN=1]="PROTEIN",n[n.NUCLEIC=2]="NUCLEIC",n[n.RNA=3]="RNA",n[n.DNA=4]="DNA",n[n.POLYMER=5]="POLYMER",n[n.WATER=6]="WATER",n[n.HELIX=7]="HELIX",n[n.SHEET=8]="SHEET",n[n.TURN=9]="TURN",n[n.BACKBONE=10]="BACKBONE",n[n.SIDECHAIN=11]="SIDECHAIN",n[n.ALL=12]="ALL",n[n.HETERO=13]="HETERO",n[n.ION=14]="ION",n[n.SACCHARIDE=15]="SACCHARIDE",n[n.SUGAR=15]="SUGAR",n[n.BONDED=16]="BONDED",n[n.RING=17]="RING",n[n.AROMATICRING=18]="AROMATICRING",n[n.METAL=19]="METAL",n[n.POLARH=20]="POLARH",n[n.NONE=21]="NONE"})(yt||(yt={}));var IE=["*","","ALL"],hB=["NONE"],xw=[yt.BACKBONE,yt.SIDECHAIN,yt.BONDED,yt.RING,yt.AROMATICRING,yt.METAL,yt.POLARH],DP=[yt.POLYMER,yt.WATER],dB=["ALA","GLY","SER"],fB=["CYS","SER","THR"],pB=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],mB=["PHE","TRP","TYR","HIS"],gB=["ASN","GLN"],yB=["ASP","GLU"],_B=["ARG","HIS","LYS"],vB=["ARG","ASP","GLU","HIS","LYS"],xB=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],bB=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],wB=["HIS","PHE","PRO","TRP","TYR"],SB=["ALA","GLY","ILE","LEU","VAL"];function AB(n,e){if(e.atomname===void 0&&e.element===void 0&&e.altloc===void 0&&e.atomindex===void 0&&e.keyword===void 0&&e.inscode===void 0&&e.resname===void 0&&e.sstruc===void 0&&e.resno===void 0&&e.chainname===void 0&&e.model===void 0)return-1;if(e.keyword!==void 0&&(e.keyword===yt.BACKBONE&&!n.isBackbone()||e.keyword===yt.SIDECHAIN&&!n.isSidechain()||e.keyword===yt.BONDED&&!n.isBonded()||e.keyword===yt.RING&&!n.isRing()||e.keyword===yt.AROMATICRING&&!n.isAromatic()||e.keyword===yt.HETERO&&!n.isHetero()||e.keyword===yt.PROTEIN&&!n.isProtein()||e.keyword===yt.NUCLEIC&&!n.isNucleic()||e.keyword===yt.RNA&&!n.isRna()||e.keyword===yt.DNA&&!n.isDna()||e.keyword===yt.POLYMER&&!n.isPolymer()||e.keyword===yt.WATER&&!n.isWater()||e.keyword===yt.HELIX&&!n.isHelix()||e.keyword===yt.SHEET&&!n.isSheet()||e.keyword===yt.TURN&&!n.isTurn()||e.keyword===yt.ION&&!n.isIon()||e.keyword===yt.SACCHARIDE&&!n.isSaccharide()||e.keyword===yt.METAL&&!n.isMetal()||e.keyword===yt.POLARH&&!n.isPolarHydrogen())||e.atomname!==void 0&&e.atomname!==n.atomname||e.element!==void 0&&e.element!==n.element||e.altloc!==void 0&&e.altloc!==n.altloc||e.atomindex!==void 0&&ja(e.atomindex,n.index)<0)return!1;if(e.resname!==void 0){if(Array.isArray(e.resname)){if(!e.resname.includes(n.resname))return!1}else if(e.resname!==n.resname)return!1}if(e.sstruc!==void 0&&e.sstruc!==n.sstruc)return!1;if(e.resno!==void 0){if(Array.isArray(e.resno)&&e.resno.length===2){if(e.resno[0]>n.resno||e.resno[1]n.resno||e.resno[1]0?n:null}function RE(n,e=!1){let t=n;return e&&(t=Rd(n,function(i){return i.keyword!==void 0&&!xw.includes(i.keyword)||i.model!==void 0||i.chainname!==void 0||i.resname!==void 0||i.resno!==void 0||i.sstruc!==void 0})),Id(t,AB)}function kE(n,e=!1){let t=n;return e&&(t=Rd(n,function(i){return!(i.keyword===void 0||!xw.includes(i.keyword))||i.model!==void 0||i.chainname!==void 0||i.atomname!==void 0||i.element!==void 0||i.altloc!==void 0})),Id(t,MB)}function LE(n,e=!1){let t=n;return e&&(t=Rd(n,function(i){return i.keyword!==void 0&&!DP.includes(i.keyword)||i.resname!==void 0||i.resno!==void 0||i.atomname!==void 0||i.element!==void 0||i.altloc!==void 0||i.sstruc!==void 0||i.inscode!==void 0})),Id(t,CB)}function DE(n,e=!1){let t=n;return e&&(t=Rd(n,function(i){return i.keyword!==void 0||i.chainname!==void 0||i.resname!==void 0||i.resno!==void 0||i.atomname!==void 0||i.element!==void 0||i.altloc!==void 0||i.sstruc!==void 0||i.inscode!==void 0})),Id(t,EB)}var tn=class{constructor(e){this.signals={stringChanged:new Pt.Signal},this.setString(e)}get type(){return"selection"}setString(e,t){if(e===void 0&&(e=this.string||""),e===this.string)return;try{this.selection=function(r){let s={operator:void 0,rules:[]};if(!r)return s;let o,a,l=s,c=[];(r=r.replace(/\(/g," ( ").replace(/\)/g," ) ").trim()).charAt(0)==="("&&r.substr(-1)===")"&&(r=r.slice(1,-1).trim());let u=r.split(/\s+/),d=_=>{o={operator:_,rules:[]},l===void 0?(l=o,s=o):(l.rules.push(o),c.push(l),l=o)},f=function(_){a=l,l=c.pop(),l===void 0&&(d(_),m(a))},m=function(_){l.rules.push(_)},p=!1;for(let _=0;_0)if(g==="NOT")p=1;else if(p===1)p=2;else{if(p!==2)throw new Error("something went wrong with 'not'");p=!1,f()}if(g==="AND"){if(l.operator==="OR"){let A=l.rules.pop();d("AND"),m(A)}else l.operator="AND";continue}if(g==="OR"){l.operator==="AND"?f("OR"):l.operator="OR";continue}if(y.toUpperCase()==="NOT"){p=1,d(),l.negate=!0;continue}if(+g!=+g){let A=yt[g];if(A!==void 0){m({keyword:A});continue}}if(g==="HYDROGEN"){m({operator:"OR",rules:[{element:"H"},{element:"D"}]});continue}if(g==="SMALL"){m({resname:dB});continue}if(g==="NUCLEOPHILIC"){m({resname:fB});continue}if(g==="HYDROPHOBIC"){m({resname:pB});continue}if(g==="AROMATIC"){m({resname:mB});continue}if(g==="AMIDE"){m({resname:gB});continue}if(g==="ACIDIC"){m({resname:yB});continue}if(g==="BASIC"){m({resname:_B});continue}if(g==="CHARGED"){m({resname:vB});continue}if(g==="POLAR"){m({resname:xB});continue}if(g==="NONPOLAR"){m({resname:bB});continue}if(g==="CYCLIC"){m({resname:wB});continue}if(g==="ALIPHATIC"){m({resname:SB});continue}if(g==="SIDECHAINATTACHED"){m({operator:"OR",rules:[{keyword:yt.SIDECHAIN},{operator:"AND",negate:!1,rules:[{keyword:yt.PROTEIN},{operator:"OR",negate:!1,rules:[{atomname:"CA"},{atomname:"BB"}]}]},{operator:"AND",negate:!1,rules:[{resname:"PRO"},{atomname:"N"}]},{operator:"AND",negate:!1,rules:[{keyword:yt.NUCLEIC},{operator:"OR",negate:!0,rules:[{atomname:"P"},{atomname:"OP1"},{atomname:"OP2"},{atomname:"O3'"},{atomname:"O3*"},{atomname:"HO3'"},{atomname:"O5'"},{atomname:"O5*"},{atomname:"HO5'"},{atomname:"C5'"},{atomname:"C5*"},{atomname:"H5'"},{atomname:"H5''"}]}]}]});continue}if(g==="APOLARH"){m({operator:"AND",negate:!1,rules:[{element:"H"},{negate:!0,operator:void 0,rules:[{keyword:yt.POLARH}]}]});continue}if(g==="LIGAND"){m({operator:"AND",rules:[{operator:"OR",rules:[{operator:"AND",rules:[{keyword:yt.HETERO},{negate:!0,operator:void 0,rules:[{keyword:yt.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{keyword:yt.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{operator:"OR",rules:[{keyword:yt.WATER},{keyword:yt.ION}]}]}]});continue}if(IE.indexOf(g)!==-1){m({keyword:yt.ALL});continue}if(y.charAt(0)==="@"){let A=y.substr(1).split(",").map(M=>parseInt(M));A.sort(function(M,T){return M-T}),m({atomindex:A});continue}if(y.charAt(0)==="#"){console.error("# for element selection deprecated, use _"),m({element:g.substr(1)});continue}if(y.charAt(0)==="_"){m({element:g.substr(1)});continue}if(y[0]==="["&&y[y.length-1]==="]"){let A=g.substr(1,y.length-2).split(","),M=A.length>1?A:A[0];m({resname:M});continue}if(y.length>=1&&y.length<=4&&y[0]!=="^"&&y[0]!==":"&&y[0]!=="."&&y[0]!=="%"&&y[0]!=="/"&&isNaN(parseInt(y))){m({resname:g});continue}let b={operator:"AND",rules:[]},h=y.split("/");if(h.length>1&&h[1]){if(isNaN(parseInt(h[1])))throw new Error("model must be an integer");b.rules.push({model:parseInt(h[1])})}let v=h[0].split("%");v.length>1&&b.rules.push({altloc:v[1]});let S=v[0].split(".");if(S.length>1&&S[1]){if(S[1].length>4)throw new Error("atomname must be one to four characters");b.rules.push({atomname:S[1].substring(0,4).toUpperCase()})}let x=S[0].split(":");x.length>1&&x[1]&&b.rules.push({chainname:x[1]});let w=x[0].split("^");if(w.length>1&&b.rules.push({inscode:w[1]}),w[0]){let A,M;w[0][0]==="-"&&(w[0]=w[0].substr(1),A=!0),w[0].includes("--")&&(w[0]=w[0].replace("--","-"),M=!0);let T=w[0].split("-");if(T.length===1){let R=parseInt(T[0]);if(isNaN(R))throw new Error("resi must be an integer");A&&(R*=-1),b.rules.push({resno:R})}else{if(T.length!==2)throw new Error("resi range must contain one '-'");{let R=T.map(C=>parseInt(C));A&&(R[0]*=-1),M&&(R[1]*=-1),b.rules.push({resno:[R[0],R[1]]})}}}if(b.rules.length===1)m(b.rules[0]);else{if(!(b.rules.length>1))throw new Error("empty selection chunk");m(b)}}return s.operator===void 0&&s.rules.length===1&&s.rules[0].hasOwnProperty("operator")&&(s=s.rules[0]),s}(e)}catch(r){this.selection={error:r.message}}let i=this.selection;this.string=e,this.test=RE(i),this.residueTest=kE(i),this.chainTest=LE(i),this.modelTest=DE(i),this.atomOnlyTest=RE(i,!0),this.residueOnlyTest=kE(i,!0),this.chainOnlyTest=LE(i,!0),this.modelOnlyTest=DE(i,!0),t||this.signals.stringChanged.dispatch(this.string)}isAllSelection(){return IE.includes(this.string.toUpperCase())}isNoneSelection(){return hB.includes(this.string.toUpperCase())}},Ox=class extends Yt{constructor(e){super(e),this.colormakerList=[],this.selectionList=[],(e.dataList||[]).forEach(t=>{let[i,r,s={}]=t;Dt.hasScheme(i)?Object.assign(s,{scheme:i,structure:this.parameters.structure}):Object.assign(s,{scheme:"uniform",value:new dt(i).getHex()}),this.colormakerList.push(Dt.getScheme(s)),this.selectionList.push(new tn(r))})}atomColor(e){for(let t=0,i=this.selectionList.length;t{},n)}catch{}var BP=typeof window<"u"&&window.orientation!==void 0,gs=!1;function NE(n){gs=n}var ys=!1;function FE(n){ys=n}var we={log:Function.prototype.bind.call(console.log,console),info:Function.prototype.bind.call(console.info,console),warn:Function.prototype.bind.call(console.warn,console),error:Function.prototype.bind.call(console.error,console),time:Function.prototype.bind.call(console.time,console),timeEnd:Function.prototype.bind.call(console.timeEnd,console)},Fh={color:"green",labelColor:8421504,labelAttachment:"bottom-center",labelSize:.7,labelZOffset:.5,labelYOffset:.1,labelBorder:!0,labelBorderColor:13882323,labelBorderWidth:.25,lineOpacity:.8,linewidth:5,opacity:.6,labelUnit:"angstrom",arcVisible:!0,planeVisible:!1};var Le=!!(Rv=oB("debug"))&&(typeof Rv!="string"||/^1|true|t|yes|y$/i.test(Rv)),Rv;var LB=["ngl","js"],td=new class{constructor(){this.activeWorkerCount=0,this._funcDict={},this._depsDict={},this._blobDict={}}add(n,e,t){this._funcDict[n]=e,this._depsDict[n]=t}get(n){return this._blobDict[n]||(this._blobDict[n]=kB(this._funcDict[n],this._depsDict[n])),this._blobDict[n]}},Dt=new class{constructor(){this.schemes={},this.userSchemes={}}getScheme(n){let e=((n||{}).scheme||"").toLowerCase(),t;return t=e in this.schemes?this.schemes[e]:e in this.userSchemes?this.userSchemes[e]:Yt,new t(n)}getSchemes(){let n={};return Object.keys(this.schemes).forEach(function(e){n[e]=e}),Object.keys(this.userSchemes).forEach(function(e){n[e]=e.split("|")[1]}),n}getScales(){return TB}getModes(){return PB}add(n,e){n=n.toLowerCase(),this.schemes[n]=e}addScheme(n,e){return function(t){return t instanceof Yt}(n)||(n=this._createScheme(n)),this._addUserScheme(n,e)}_addUserScheme(n,e){e=e||"";let t=`${vw()}|${e}`.toLowerCase();return this.userSchemes[t]=n,t}removeScheme(n){n=n.toLowerCase(),delete this.userSchemes[n]}_createScheme(n){return class extends Yt{constructor(e){super(e),n.call(this,e)}}}addSelectionScheme(n,e){return this._addUserScheme(class extends Ox{constructor(t){super(Object.assign({dataList:n},t))}},e)}hasScheme(n){return(n=n.toLowerCase())in this.schemes||n in this.userSchemes}},Jo=new ws("datasource"),on=new ws("representatation"),At=new class extends ws{constructor(){super("parser")}__hasObjName(n,e){let t=this.get(n);return t&&t.prototype.__objName===e}isTrajectory(n){return this.__hasObjName(n,"frames")}isStructure(n){return this.__hasObjName(n,"structure")}isVolume(n){return this.__hasObjName(n,"volume")}isSurface(n){return this.__hasObjName(n,"surface")}isBinary(n){let e=this.get(n);return e&&e.prototype.isBinary}isXml(n){let e=this.get(n);return e&&e.prototype.isXml}isJson(n){let e=this.get(n);return e&&e.prototype.isJson}getTrajectoryExtensions(){return this.names.filter(n=>this.isTrajectory(n))}getStructureExtensions(){return this.names.filter(n=>this.isStructure(n))}getVolumeExtensions(){return this.names.filter(n=>this.isVolume(n))}getSurfaceExtensions(){return this.names.filter(n=>this.isSurface(n))}},zt=new ws("shader"),bw=new ws("decompressor"),Gc=new ws("component"),cr=new ws("buffer"),Mr=new ws("picker");var kv;var tg=class{constructor(e,t={}){this.chunkSize=10485760,this.newline=` +`,this.__pointer=0,this.__partialLine="",this.compressed=U(t.compressed,!1),this.binary=U(t.binary,!1),this.json=U(t.json,!1),this.xml=U(t.xml,!1),this.src=e}isBinary(){return this.binary||this.compressed}read(){return this._read().then(e=>{let t=this.compressed?bw.get(this.compressed):void 0;return this.compressed&&t?this.data=t(e):((this.binary||this.compressed)&&e instanceof ArrayBuffer&&(e=new Uint8Array(e)),this.data=e),this.data})}_chunk(e,t){return t=Math.min(this.data.length,t),e===0&&this.data.length===t?this.data:this.isBinary()?this.data.subarray(e,t):this.data.substring(e,t)}chunk(e){let t=e+this.chunkSize;return this._chunk(e,t)}peekLines(e){let t=this.data,i=t.length,r=this.isBinary()?this.newline.charCodeAt(0):this.newline,s,o=0;for(s=0;si).lines}chunkCount(){return Math.floor(this.data.length/this.chunkSize)+1}asText(){return this.isBinary()?pd(this.data):this.data}chunkToLines(e,t,i){let r=this.newline;if(!this.isBinary()&&e.length===this.data.length)return{lines:e.split(r),partialLine:""};let s=[],o=this.isBinary()?pd(e):e,a=o.lastIndexOf(r);if(a===-1)t+=o;else{let l=t+o.substr(0,a);s=s.concat(l.split(r)),t=a===o.length-r.length?"":o.substr(a+r.length)}return i&&t!==""&&s.push(t),{lines:s,partialLine:t}}nextChunk(){let e=this.__pointer;if(!(e>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(e)}nextChunkOfLines(){let e=this.nextChunk();if(e===void 0)return;let t=this.__pointer>this.data.length,i=this.chunkToLines(e,this.__partialLine,t);return this.__partialLine=i.partialLine,i.lines}eachChunk(e){let t=this.chunkSize,i=this.data.length,r=this.chunkCount();for(let s=0;s{let s=i===r+1,o=this.chunkToLines(t,this.__partialLine,s);this.__partialLine=o.partialLine,e(o.lines,i,r)})}dispose(){delete this.src}},Bx=class extends tg{_read(){return new Promise((e,t)=>{let i=this.src,r=new FileReader;r.onload=s=>{s.target&&e(s.target.result)},r.onerror=s=>t(s),this.binary||this.compressed?r.readAsArrayBuffer(i):r.readAsText(i)})}},Ux=class extends tg{_read(){return new Promise((e,t)=>{let i=this.src,r=new XMLHttpRequest;r.open("GET",i,!0),r.addEventListener("load",()=>{if(r.status===200||r.status===304||r.status===0)try{e(r.response)}catch(s){t(s)}else t(r.statusText)},!1),r.addEventListener("error",s=>t("network error"),!1),this.isBinary()?r.responseType="arraybuffer":this.json?r.responseType="json":this.xml?r.responseType="document":r.responseType="text",r.send()})}},ng=class{constructor(e,t={}){this.parameters=or(t,{ext:"",compressed:!1,binary:At.isBinary(t.ext||""),name:"",dir:"",path:"",protocol:""});let i={compressed:this.parameters.compressed,binary:this.parameters.binary,json:At.isJson(this.parameters.ext),xml:At.isXml(this.parameters.ext)};typeof File<"u"&&e instanceof File||typeof Blob<"u"&&e instanceof Blob?this.streamer=new Bx(e,i):this.streamer=new Ux(e,i)}},zx=class extends ng{constructor(e,t={}){super(e,t),this.parserParams={voxelSize:t.voxelSize,firstModelOnly:t.firstModelOnly,asTrajectory:t.asTrajectory,cAlphaOnly:t.cAlphaOnly,delimiter:t.delimiter,comment:t.comment,columnNames:t.columnNames,inferBonds:t.inferBonds,name:this.parameters.name,path:this.parameters.path}}load(){return new(At.get(this.parameters.ext))(this.streamer,this.parserParams).parse()}},Vx=class{constructor(e,t,i){this.name=t,this.path=i,this.signals={elementAdded:new Pt.Signal,elementRemoved:new Pt.Signal,nameChanged:new Pt.Signal},this.type="Script",this.dir=i.substring(0,i.lastIndexOf("/")+1);try{this.fn=new Function("stage","__name","__path","__dir",e)}catch(r){we.error("Script compilation failed",r),this.fn=function(){}}}run(e){return new Promise((t,i)=>{try{this.fn.apply(null,[e,this.name,this.path,this.dir]),t()}catch(r){we.error("Script.fn",r),i(r)}})}},Hx=class extends ng{load(){return this.streamer.read().then(()=>new Vx(this.streamer.asText(),this.parameters.name,this.parameters.path))}};function Gi(n){let e=bw.names,t,i,r="";t=n instanceof File?n.name:n instanceof Blob?"":n;let s=t.lastIndexOf("?"),o=s!==-1?t.substring(s):"";t=t.substring(0,s===-1?t.length:s);let a=t.replace(/^.*[\\/]/,""),l=a.substring(0,a.lastIndexOf(".")),c=a.split("."),u=c.length>1?(c.pop()||"").toLowerCase():"",d=t.match(/^(.+):\/\/(.+)$/);d&&(r=d[1].toLowerCase(),t=d[2]||"");let f=t.substring(0,t.lastIndexOf("/")+1);if(e.includes(u)){i=u;let m=t.length-u.length-1;u=(t.substr(0,m).split(".").pop()||"").toLowerCase();let p=l.length-u.length-1;l=l.substr(0,p)}else i=!1;return{path:t,name:a,ext:u,base:l,dir:f,compressed:i,protocol:r,query:o,src:n}}function DB(n){let e=Gi(n),t=Jo.get(e.protocol);return t&&(e=Gi(t.getUrl(e.src)),!e.ext&&t.getExt&&(e.ext=t.getExt(n))),e}function OE(n,e={}){let t=Object.assign(DB(n),e),i;return At.names.includes(t.ext)?i=new zx(t.src,t):LB.includes(t.ext)&&(i=new Hx(t.src,t)),i?i.load():Promise.reject(new Error(`autoLoad: ext '${t.ext}' unknown`))}var Lv=[],Gx=class{constructor(e,t={}){this._mark=0,this._marks=[],this.offset=0,this.littleEndian=!0;let i=!1;e===void 0&&(e=8192),typeof e=="number"?e=new ArrayBuffer(e):i=!0;let r=t.offset?t.offset>>>0:0,s=e.byteLength-r,o=r;e instanceof ArrayBuffer||(e.byteLength!==e.buffer.byteLength&&(o=e.byteOffset+r),e=e.buffer),this._lastWrittenByte=i?s:0,this.buffer=e,this.length=s,this.byteLength=s,this.byteOffset=o,this._data=new DataView(this.buffer,o,s)}available(e){return e===void 0&&(e=1),this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e){return e===void 0&&(e=1),this.offset+=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e){if(e===void 0&&(e=1),!this.available(e)){let t=2*(this.offset+e),i=new Uint8Array(t);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=this.byteLength=t,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e){e===void 0&&(e=1);for(var t=new Uint8Array(e),i=0;ithis._lastWrittenByte&&(this._lastWrittenByte=this.offset)}};var ig=class{constructor(){this.count=0,this.signals={countChanged:new Td.Signal}}clear(){this.change(-this.count)}change(e){this.count+=e,this.signals.countChanged.dispatch(e,this.count),this.count<0&&we.warn("Counter.count below zero",this.count)}increment(){this.change(1)}decrement(){this.change(-1)}listen(e){this.change(e.count),e.signals.countChanged.add(this.change,this)}unlisten(e){let t=e.signals.countChanged;t.has(this.change,this)&&t.remove(this.change,this)}onZeroOnce(e,t){if(this.count===0)e.call(t);else{let i=()=>{this.count===0&&(this.signals.countChanged.remove(i,this),e.call(t))};this.signals.countChanged.add(i,this)}}dispose(){this.clear(),this.signals.countChanged.dispose()}};zt.add("shader/BasicLine.vert",`void main(){ +#include begin_vertex +#include project_vertex +}`),zt.add("shader/BasicLine.frag",`uniform vec3 uColor; +#include common +#include fog_pars_fragment +void main(){ +gl_FragColor = vec4( uColor, 1.0 ); +#include premultiplied_alpha_fragment +#include tonemapping_fragment +#include colorspace_fragment +#include fog_fragment +}`),zt.add("shader/Quad.vert",`varying vec2 vUv; +void main() { +vUv = uv; +gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); +}`),zt.add("shader/Quad.frag",`varying vec2 vUv; +uniform sampler2D tForeground; +uniform float scale; +void main() { +vec4 foreground = texture2D( tForeground, vUv ); +gl_FragColor = foreground * scale; +}`);var $x=class{constructor(){this.signals={updated:new Td.Signal},this.maxDuration=-1/0,this.minDuration=1/0,this.avgDuration=14,this.lastDuration=1/0,this.prevFpsTime=0,this.lastFps=1/0,this.lastFrames=1,this.frames=0,this.count=0,this.begin()}update(){this.startTime=this.end(),this.currentTime=this.startTime,this.signals.updated.dispatch()}begin(){this.startTime=window.performance.now(),this.lastFrames=this.frames}end(){let e=window.performance.now();return this.count+=1,this.frames+=1,this.lastDuration=e-this.startTime,this.minDuration=Math.min(this.minDuration,this.lastDuration),this.maxDuration=Math.max(this.maxDuration,this.lastDuration),this.avgDuration-=this.avgDuration/30,this.avgDuration+=this.lastDuration/30,e>this.prevFpsTime+1e3&&(this.lastFps=this.frames,this.prevFpsTime=e,this.frames=0),e}};zt.add("shader/chunk/fog_fragment.glsl",`#ifdef USE_FOG +float depth = length( vViewPosition ); +#ifdef FOG_EXP2 +float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) ); +#else +float fogFactor = smoothstep( fogNear, fogFar, depth ); +#endif +gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`),zt.add("shader/chunk/interior_fragment.glsl",`if( gl_FrontFacing == false ){ +#ifdef USE_INTERIOR_COLOR +outgoingLight.xyz = interiorColor; +#else +#ifdef DIFFUSE_INTERIOR +outgoingLight.xyz = vColor; +#endif +#endif +outgoingLight.xyz *= 1.0 - interiorDarkening; +}`),zt.add("shader/chunk/matrix_scale.glsl",`float matrixScale( in mat4 m ){ +vec4 r = m[ 0 ]; +return sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] ); +}`),zt.add("shader/chunk/nearclip_vertex.glsl",`#ifdef NEAR_CLIP +if( vViewPosition.z < clipNear - 5.0 ) +gl_Position.z = 2.0 * gl_Position.w; +#endif`),zt.add("shader/chunk/nearclip_fragment.glsl",`#ifdef NEAR_CLIP +if( vViewPosition.z < clipNear ) +discard; +#endif`),zt.add("shader/chunk/opaque_back_fragment.glsl",`#ifdef OPAQUE_BACK +#ifdef FLIP_SIDED +if( gl_FrontFacing == true ){ +gl_FragColor.a = 1.0; +} +#else +if( gl_FrontFacing == false ){ +gl_FragColor.a = 1.0; +} +#endif +#endif`),zt.add("shader/chunk/radiusclip_vertex.glsl",`#ifdef RADIUS_CLIP +if( distance( vViewPosition, vClipCenter ) > clipRadius + 5.0 ) +gl_Position.z = 2.0 * gl_Position.w; +#endif`),zt.add("shader/chunk/radiusclip_fragment.glsl",`#ifdef RADIUS_CLIP +if( distance( vViewPosition, vClipCenter ) > clipRadius ) +discard; +#endif`),zt.add("shader/chunk/unpack_color.glsl",`vec3 unpackColor(float f) { +vec3 color; +color.r = floor(f / 256.0 / 256.0); +color.g = floor((f - color.r * 256.0 * 256.0) / 256.0); +color.b = floor(f - color.r * 256.0 * 256.0 - color.g * 256.0); +return color / 255.0; +}`);var NB=/^(?!\/\/)\s*#include\s+(\S+)/gim,Dv={};function Xh(n,e={}){let t=n+"|";for(let i in e)t+=i+":"+e[i];if(!Dv[t]){let i=function(s){if(s===void 0)return"";let o=[];for(let a in s){let l=s[a];l&&o.push(`#define ${a} ${l}`)}return o.join(` +`)+` +`}(e),r=zt.get(`shader/${n}`);if(!r)throw new Error(`empty shader, '${n}'`);r=r.replace(NB,function(s,o){let a=`shader/chunk/${o}.glsl`,l=zt.get(a)||It[o];if(!l)throw new Error(`empty chunk, '${o}'`);return l}),Dv[t]=i+r}return Dv[t]}if(typeof WebGLRenderingContext<"u"){let n=WebGLRenderingContext.prototype,e=n.getShaderParameter;n.getShaderParameter=function(){return!Le||e.apply(this,arguments)};let t=n.getShaderInfoLog;n.getShaderInfoLog=function(){return Le?t.apply(this,arguments):""};let i=n.getProgramParameter;n.getProgramParameter=function(s,o){return!Le&&o===n.LINK_STATUS||i.apply(this,arguments)};let r=n.getProgramInfoLog;n.getProgramInfoLog=function(){return Le?r.apply(this,arguments):""}}var UP=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-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]],[[-4,-7],[-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]]];UP.forEach(n=>{n.forEach(e=>{e[0]*=.0625,e[1]*=.0625})});var Wx=class{constructor(e,t,i,r){this.canvas=document.createElement("canvas"),this._viewer=i,this._factor=U(r.factor,2),this._antialias=U(r.antialias,!1),this._onProgress=r.onProgress,this._onFinish=r.onFinish,this._antialias&&(this._factor*=2),this._n=this._factor*this._factor,this._width=this._viewer.width,this._height=this._viewer.height,this._antialias?(this.canvas.width=this._width*this._factor/2,this.canvas.height=this._height*this._factor/2):(this.canvas.width=this._width*this._factor,this.canvas.height=this._height*this._factor),this._ctx=this.canvas.getContext("2d"),this._viewerSampleLevel=i.sampleLevel,this._viewer.setSampling(-1)}_renderTile(e){let t=this._viewer,i=this._width,r=this._height,s=this._factor,o=e%s*i,a=Math.floor(e/s)*r;if(t.camera.setViewOffset(i*s,r*s,o,a,i,r),t.render(),this._antialias){let l=Math.round((o+i)/2)-Math.round(o/2),c=Math.round((a+r)/2)-Math.round(a/2);this._ctx.drawImage(t.renderer.domElement,Math.round(o/2),Math.round(a/2),l,c)}else this._ctx.drawImage(t.renderer.domElement,Math.floor(o),Math.floor(a),Math.ceil(i),Math.ceil(r));typeof this._onProgress=="function"&&this._onProgress(e+1,this._n,!1)}_finalize(){this._viewer.setSampling(this._viewerSampleLevel),this._viewer.camera.view=null,typeof this._onFinish=="function"&&this._onFinish(this._n+1,this._n,!1)}render(){for(let e=0;e<=this._n;++e)e===this._n?this._finalize():this._renderTile(e)}renderAsync(){let e=0,t=this._n,i=()=>{e===t?this._finalize():this._renderTile(e),e+=1};for(let r=0;r<=t;++r)setTimeout(i,0)}},Nv=2*Math.PI,zP=180/Math.PI;function Fv(n,e,t=1,i=0,r){let s=r?r.length:n.length/t,o=0,a=0;if(r)for(let l=0;le&&(e=n[t]);return e}function jm(n){let e=1/0;for(let t=0,i=n.length;t=0;A--){for(w=S-1;w>=0;w--)if(T=4*(A*S+w),x[T]!==y||x[T+1]!==g||x[T+2]!==b||x[T+3]!==h){M=!0;break}if(M)break}let P=A;for(M=!1,w=S-1;w>=0;w--){for(A=v-1;A>=0;A--)if(T=4*(A*S+w),x[T]!==y||x[T+1]!==g||x[T+2]!==b||x[T+3]!==h){M=!0;break}if(M)break}let E=w,I=document.createElement("canvas");return I.width=E-C,I.height=P-R,I.getContext("2d").drawImage(_,C,R,I.width,I.height,0,0,I.width,I.height),I}(m,s?0:255*p.r,s?0:255*p.g,s?0:255*p.b,s?0:255)}return m}function f(m,p,_){typeof e.onProgress=="function"&&e.onProgress(m,p,_)}return new Promise(function(m,p){let _=new Wx(o,a,n,{factor:i,antialias:r,onProgress:f,onFinish:function(y,g){d(_.canvas).toBlob(function(b){o.setClearAlpha(l),u(!0),n.requestRender(),f(g,g,!0),b?m(b):p("error creating image")},"image/png")}});o.setClearAlpha(s?0:1),u(),_.renderAsync()})}var Bv=new W,UE=new qe,zE=new qe,VE=new Et,rg=new qe,sg=new qe;function Uv(n,e){rg.copy(e.projectionMatrix).invert(),sg.copy(e.projectionMatrix).transpose(),n.traverse(function(t){let i=t.material;if(!i)return;let r=i.uniforms;r&&(r.projectionMatrixInverse&&r.projectionMatrixInverse.value.copy(rg),r.projectionMatrixTranspose&&r.projectionMatrixTranspose.value.copy(sg))})}function HE(n,e,t){let i=n.createShader(t);return i?(n.shaderSource(i,e),n.compileShader(i),n.getShaderParameter(i,n.COMPILE_STATUS)?i:(console.log(`error compiling shader ${i}: ${n.getShaderInfoLog(i)}`),n.deleteShader(i),null)):void console.log(`error creating WebGL shader ${t}`)}function zv(n,e){let t=n.getExtension(e);return t||console.log(`extension '${e}' not available`),t}var BB=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function gm(n){let e=document.createElement("canvas");e.width=16,e.height=16,e.style.width="16px",e.style.height="16px";let t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return console.log(`error creating webgl context for ${n}`),!1;if(!(t instanceof WebGLRenderingContext))return console.log("Got unexpected type for WebGL rendering context"),!1;zv(t,"OES_texture_float"),zv(t,"OES_texture_half_float"),zv(t,"WEBGL_color_buffer_float");let i=HE(t,` +attribute vec4 a_position; + +void main() { + gl_Position = a_position; +}`,t.VERTEX_SHADER),r=HE(t,` +precision mediump float; +uniform vec4 u_color; +uniform sampler2D u_texture; + +void main() { + gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color; +}`,t.FRAGMENT_SHADER);if(!i||!r)return!1;let s=function(p,_,y,g){let b=p.createProgram();return b?(_.forEach(h=>p.attachShader(b,h)),y&&y.forEach((h,v)=>{p.bindAttribLocation(b,g?g[v]:v,h)}),p.linkProgram(b),p.getProgramParameter(b,p.LINK_STATUS)?b:(console.log(`error linking program: ${p.getProgramInfoLog(b)}`),p.deleteProgram(b),null)):void console.log("error creating WebGL program")}(t,[i,r]);if(!s)return console.log("error creating WebGL program"),!1;t.useProgram(s);let o=t.getAttribLocation(s,"a_position"),a=t.getUniformLocation(s,"u_color");if(!a)return console.log("error getting 'u_color' uniform location"),!1;let l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l),t.bufferData(t.ARRAY_BUFFER,BB,t.STATIC_DRAW),t.enableVertexAttribArray(o),t.vertexAttribPointer(o,2,t.FLOAT,!1,0,0);let c=t.createTexture(),u=new Uint8Array([255,255,255,255]);t.bindTexture(t.TEXTURE_2D,c),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,u);let d=t.createTexture();t.bindTexture(t.TEXTURE_2D,d),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,n,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);let f=t.createFramebuffer();if(t.bindFramebuffer(t.FRAMEBUFFER,f),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,d,0),t.checkFramebufferStatus(t.FRAMEBUFFER)!==t.FRAMEBUFFER_COMPLETE)return console.log(`error creating framebuffer for ${n}`),!1;t.bindTexture(t.TEXTURE_2D,c),t.uniform4fv(a,[0,10,20,1]),t.drawArrays(t.TRIANGLES,0,6),t.bindTexture(t.TEXTURE_2D,d),t.bindFramebuffer(t.FRAMEBUFFER,null),t.clearColor(1,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.uniform4fv(a,[0,.1,.05,1]),t.drawArrays(t.TRIANGLES,0,6);let m=new Uint8Array(4);if(t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,m),m[0]!==0||m[1]<248||m[2]<248||m[3]<254)return console.log(`not able to actually render to ${n} texture`),!1;if(n===t.FLOAT){t.bindFramebuffer(t.FRAMEBUFFER,f);let p=new Float32Array(4);t.readPixels(0,0,1,1,t.RGBA,t.FLOAT,p);let _=t.getError();if(_)return console.log(`error reading pixels as float: '${function(y,g){switch(g){case y.NO_ERROR:return"no error";case y.INVALID_ENUM:return"invalid enum";case y.INVALID_VALUE:return"invalid value";case y.INVALID_OPERATION:return"invalid operation";case y.INVALID_FRAMEBUFFER_OPERATION:return"invalid framebuffer operation";case y.OUT_OF_MEMORY:return"out of memory";case y.CONTEXT_LOST_WEBGL:return"context lost"}return"unknown error"}(t,_)}'`),!1}return!0}var UB=new Float32Array(100),zB=new Uint8Array(100),GE=[12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20],ym=new qe;function VB(n,e,t,i,r){let s=r.uniforms,o=[];if(s&&(s.objectId&&(s.objectId.value=gs?this.id:this.id/255,o.push("objectId")),(s.modelViewMatrixInverse||s.modelViewMatrixInverseTranspose||s.modelViewProjectionMatrix||s.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,this.matrixWorld),s.modelViewMatrixInverse&&(s.modelViewMatrixInverse.value.copy(this.modelViewMatrix).invert(),o.push("modelViewMatrixInverse")),s.modelViewMatrixInverseTranspose&&(s.modelViewMatrixInverse?s.modelViewMatrixInverseTranspose.value.copy(s.modelViewMatrixInverse.value).transpose():s.modelViewMatrixInverseTranspose.value.copy(this.modelViewMatrix).invert().transpose(),o.push("modelViewMatrixInverseTranspose")),s.modelViewProjectionMatrix&&(s.modelViewProjectionMatrix.value.multiplyMatrices(t.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),s.modelViewProjectionMatrixInverse&&(s.modelViewProjectionMatrix?(ym.copy(s.modelViewProjectionMatrix.value),s.modelViewProjectionMatrixInverse.value.copy(ym.invert())):(ym.multiplyMatrices(t.projectionMatrix,this.modelViewMatrix),s.modelViewProjectionMatrixInverse.value.copy(ym.invert())),o.push("modelViewProjectionMatrixInverse")),o.length)){let a=n.properties.get(r);if(a.program){let l=n.getContext(),c=a.program;l.useProgram(c.program);let u=c.getUniforms();o.forEach(function(d){u.setValue(l,d,s[d].value)})}}}var Xx=class{constructor(e){if(this.boundingBox=new sn,this.boundingBoxSize=new W,this.boundingBoxLength=0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}},this.distVector=new W,this.signals={ticked:new Pt.Signal,rendered:new Pt.Signal},typeof e=="string"){let t=document.getElementById(e);this.container=t===null?document.createElement("div"):t}else e instanceof HTMLElement?this.container=e:this.container=document.createElement("div");if(this.container===document.body)this.width=window.innerWidth||1,this.height=window.innerHeight||1;else{let t=this.container.getBoundingClientRect();this.width=t.width||1,this.height=t.height||1,this.container.style.overflow="hidden"}this.wrapper=document.createElement("div"),this.wrapper.style.position="relative",this.container.appendChild(this.wrapper),this._initParams(),this._initStats(),this._initCamera(),this._initScene(),this._initRenderer()!==!1?(this._initHelper(),this.setBackground(),this.setFog(),this.animate=this.animate.bind(this)):we.error("Viewer: could not initialize renderer")}_initParams(){this.parameters={fogColor:new dt(0),fogNear:50,fogFar:100,backgroundColor:new dt(0),cameraType:"perspective",cameraFov:40,cameraEyeSep:.3,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",lightColor:new dt(14540253),lightIntensity:1.2,ambientColor:new dt(14540253),ambientIntensity:.3,sampleLevel:0,outputColorSpace:"srgb-linear"}}_initCamera(){let e=new W(0,0,0),{width:t,height:i}=this;this.perspectiveCamera=new ci(this.parameters.cameraFov,t/i),this.perspectiveCamera.position.z=this.parameters.cameraZ,this.perspectiveCamera.lookAt(e),this.orthographicCamera=new jo(t/-2,t/2,i/2,i/-2),this.orthographicCamera.position.z=this.parameters.cameraZ,this.orthographicCamera.lookAt(e),this.stereoCamera=new lm,this.stereoCamera.aspect=.5,this.stereoCamera.eyeSep=this.parameters.cameraEyeSep;let r=this.parameters.cameraType;if(r==="orthographic")this.camera=this.orthographicCamera;else{if(r!=="perspective"&&r!=="stereo")throw new Error(`Unknown cameraType '${r}'`);this.camera=this.perspectiveCamera}this.camera.updateProjectionMatrix()}_initStats(){this.stats=new $x}_initScene(){this.scene||(this.scene=new Mh,this.scene.name="scene"),this.rotationGroup=new $t,this.rotationGroup.name="rotationGroup",this.scene.add(this.rotationGroup),this.translationGroup=new $t,this.translationGroup.name="translationGroup",this.rotationGroup.add(this.translationGroup),this.modelGroup=new $t,this.modelGroup.name="modelGroup",this.translationGroup.add(this.modelGroup),this.pickingGroup=new $t,this.pickingGroup.name="pickingGroup",this.translationGroup.add(this.pickingGroup),this.backgroundGroup=new $t,this.backgroundGroup.name="backgroundGroup",this.translationGroup.add(this.backgroundGroup),this.helperGroup=new $t,this.helperGroup.name="helperGroup",this.translationGroup.add(this.helperGroup),this.scene.fog=new Qp(this.parameters.fogColor.getHex()),this.directionalLight=new om(this.parameters.lightColor.getHex(),this.parameters.lightIntensity),this.scene.add(this.directionalLight),this.ambientLight=new am(this.parameters.ambientColor.getHex(),this.parameters.ambientIntensity),this.scene.add(this.ambientLight)}_initRenderer(){let e=window.devicePixelRatio,{width:t,height:i}=this;try{this.renderer=new Ah({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch{return this.wrapper.innerHTML='

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

',!1}this.renderer.setPixelRatio(e),this.renderer.setSize(t,i),this.renderer.autoClear=!1,this.renderer.sortObjects=!0,this.renderer.outputColorSpace=this.parameters.outputColorSpace,this.renderer.useLegacyLights=!0;let r=this.renderer.getContext();this.renderer.capabilities.isWebGL2?(FE(!0),NE(this.renderer.extensions.get("EXT_color_buffer_float")),this.supportsHalfFloat=!0):(FE(this.renderer.extensions.get("EXT_frag_depth")),this.renderer.extensions.get("OES_element_index_uint"),NE(this.renderer.extensions.get("OES_texture_float")&&this.renderer.extensions.get("WEBGL_color_buffer_float")||this.renderer.extensions.get("OES_texture_float")&&gm(r.FLOAT)),this.renderer.extensions.get("OES_texture_float"),this.supportsHalfFloat=this.renderer.extensions.get("OES_texture_half_float")&&gm(36193)),this.wrapper.appendChild(this.renderer.domElement);let s=t*e,o=i*e;Le&&console.log(JSON.stringify({Browser:FP,OES_texture_float:!!this.renderer.extensions.get("OES_texture_float"),OES_texture_half_float:!!this.renderer.extensions.get("OES_texture_half_float"),WEBGL_color_buffer_float:!!this.renderer.extensions.get("WEBGL_color_buffer_float"),"testTextureSupport Float":gm(r.FLOAT),"testTextureSupport HalfFloat":gm(36193),"this.supportsHalfFloat":this.supportsHalfFloat,SupportsReadPixelsFloat:gs},null,2)),this.pickingTarget=new nr(s,o,{minFilter:en,magFilter:en,stencilBuffer:!1,format:Ei,type:gs?br:wr}),this.pickingTarget.texture.generateMipmaps=!1,this.pickingTarget.texture.colorSpace=this.parameters.outputColorSpace,this.renderer.setRenderTarget(this.pickingTarget),this.renderer.clear(),this.renderer.setRenderTarget(null),this.sampleTarget=new nr(s,o,{minFilter:li,magFilter:li,format:Ei,type:this.supportsHalfFloat?Go:gs?br:wr}),this.sampleTarget.texture.colorSpace=this.parameters.outputColorSpace,this.holdTarget=new nr(s,o,{minFilter:en,magFilter:en,format:Ei,type:this.supportsHalfFloat?Go:gs?br:wr}),this.holdTarget.texture.colorSpace=this.parameters.outputColorSpace,this.compositeUniforms={tForeground:new Rh(this.sampleTarget.texture),scale:new Rh(1)},this.compositeMaterial=new Ti({uniforms:this.compositeUniforms,vertexShader:Xh("Quad.vert"),fragmentShader:Xh("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:Dp,depthTest:!1,depthWrite:!1}),this.compositeCamera=new jo(-1,1,1,-1,0,1),this.compositeScene=new Mh,this.compositeScene.name="compositeScene",this.compositeScene.add(new er(new Sh(2,2),this.compositeMaterial))}_initHelper(){let e=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),t=new Float32Array(24),i=new Vn;i.setIndex(new gn(e,1)),i.setAttribute("position",new gn(t,3));let r=new Ti({uniforms:{uColor:{value:new dt("skyblue")}},vertexShader:Xh("BasicLine.vert"),fragmentShader:Xh("BasicLine.frag")});this.boundingBoxMesh=new mc(i,r),this.helperGroup.add(this.boundingBoxMesh)}updateHelper(){let e=this.boundingBoxMesh.geometry.attributes.position,t=e.array,{min:i,max:r}=this.boundingBox;t[0]=r.x,t[1]=r.y,t[2]=r.z,t[3]=i.x,t[4]=r.y,t[5]=r.z,t[6]=i.x,t[7]=i.y,t[8]=r.z,t[9]=r.x,t[10]=i.y,t[11]=r.z,t[12]=r.x,t[13]=r.y,t[14]=i.z,t[15]=i.x,t[16]=r.y,t[17]=i.z,t[18]=i.x,t[19]=i.y,t[20]=i.z,t[21]=r.x,t[22]=i.y,t[23]=i.z,e.needsUpdate=!0,this.boundingBox.isEmpty()||this.boundingBoxMesh.geometry.computeBoundingSphere()}get cameraDistance(){return Math.abs(this.camera.position.z)}set cameraDistance(e){this.camera.position.z=-e}add(e,t){t?t.forEach(i=>this.addBuffer(e,i)):this.addBuffer(e),e.group.name="meshGroup",e.wireframeGroup.name="wireframeGroup",e.parameters.background?(this.backgroundGroup.add(e.group),this.backgroundGroup.add(e.wireframeGroup)):(this.modelGroup.add(e.group),this.modelGroup.add(e.wireframeGroup)),e.pickable&&this.pickingGroup.add(e.pickingGroup),Le&&this.updateHelper()}addBuffer(e,t){function i(o){o instanceof $t?o.children.forEach(i):(o.userData.buffer=e,o.userData.instance=t,o.onBeforeRender=VB)}let r=e.getMesh();t&&r.applyMatrix4(t.matrix),i(r),e.group.add(r);let s=e.getWireframeMesh();if(t&&(s.matrix.copy(r.matrix),s.position.copy(r.position),s.quaternion.copy(r.quaternion),s.scale.copy(r.scale)),i(s),e.wireframeGroup.add(s),e.pickable){let o=e.getPickingMesh();t&&(o.matrix.copy(r.matrix),o.position.copy(r.position),o.quaternion.copy(r.quaternion),o.scale.copy(r.scale)),i(o),e.pickingGroup.add(o)}t?this._updateBoundingBox(e.geometry,e.matrix,t.matrix):this._updateBoundingBox(e.geometry,e.matrix)}remove(e){this.translationGroup.children.forEach(function(t){t.remove(e.group),t.remove(e.wireframeGroup)}),e.pickable&&this.pickingGroup.remove(e.pickingGroup),this.updateBoundingBox(),Le&&this.updateHelper()}_updateBoundingBox(e,t,i){let r=this.boundingBox;function s(a,l,c){a.boundingBox==null&&a.computeBoundingBox();let u=a.boundingBox.clone();l&&u.applyMatrix4(l),c&&u.applyMatrix4(c),u.min.equals(u.max)&&u.expandByScalar(5),r.union(u)}function o(a){if(a.geometry!==void 0){let l,c;a.userData.buffer&&(l=a.userData.buffer.matrix),a.userData.instance&&(c=a.userData.instance.matrix),s(a.geometry,l,c)}}e?s(e,t,i):(r.makeEmpty(),this.modelGroup.traverse(o),this.backgroundGroup.traverse(o)),r.getSize(this.boundingBoxSize),this.boundingBoxLength=this.boundingBoxSize.length()}updateBoundingBox(){this._updateBoundingBox(),Le&&this.updateHelper()}getPickingPixels(){let{width:e,height:t}=this,i=e*t*4,r=gs?new Float32Array(i):new Uint8Array(i);return this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,0,0,e,t,r),r}getImage(e){return new Promise(t=>{if(e){let{width:i,height:r}=this,s=i*r*4,o=this.getPickingPixels();if(gs){let u=new Uint8Array(s);for(let d=0;d500&&!this.isStill&&this.sampleLevel<3&&this.sampleLevel!==-1){let e=this.sampleLevel;this.sampleLevel=3,this.renderPending=!0,this.render(),this.isStill=!0,this.sampleLevel=e,Le&&we.log("rendered still frame")}this.frameRequest=window.requestAnimationFrame(this.animate)}pick(e,t){if(this.parameters.cameraType==="stereo")return{pid:0,instance:void 0,picker:void 0};e*=window.devicePixelRatio,t*=window.devicePixelRatio,e=Math.max(e-2,0),t=Math.max(t-2,0);let i,r,s=0,o=gs?UB:zB;this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,e,t,5,5,o);for(let a=0;a22&&(this.stats.begin(),this.isStill=!1),this.renderPending=!0,window.requestAnimationFrame(()=>{this.render(),this.stats.update()}))}updateZoom(){let e=En(this.perspectiveCamera.fov),t=2*Math.tan(e/2)*this.cameraDistance;this.orthographicCamera.zoom=this.height/t}absoluteToRelative(e){return 50*(1-e/this.bRadius)}relativeToAbsolute(e){return this.bRadius*(1-e/50)}__updateClipping(){let e=this.parameters;this.bRadius=Math.max(10,.5*this.boundingBoxLength),isFinite(this.bRadius)||(this.bRadius=50),this.camera.getWorldPosition(this.distVector),this.cDist=this.distVector.length(),this.cDist||(this.cameraDistance=Math.abs(e.cameraZ),this.cDist=Math.abs(e.cameraZ));let t=this.scene.fog;if(t.color.set(e.fogColor),e.clipMode==="camera")this.camera.near=e.clipNear,this.camera.far=e.clipFar,t.near=e.fogNear,t.far=e.fogFar;else if(e.clipScale==="absolute")this.camera.near=this.cDist-e.clipNear,this.camera.far=this.cDist+e.clipFar,t.near=this.cDist-e.fogNear,t.far=this.cDist+e.fogFar;else{let i=(50-e.clipNear)/50,r=-(50-e.clipFar)/50;this.camera.near=this.cDist-this.bRadius*i,this.camera.far=this.cDist+this.bRadius*r;let s=(50-e.fogNear)/50,o=-(50-e.fogFar)/50;t.near=this.cDist-this.bRadius*s,t.far=this.cDist+this.bRadius*o}e.clipMode!=="camera"&&(this.camera.type==="PerspectiveCamera"?(this.camera.near=Math.max(.1,e.clipDist,this.camera.near),this.camera.far=Math.max(1,this.camera.far),t.near=Math.max(.1,t.near),t.far=Math.max(1,t.far)):this.camera.type==="OrthographicCamera"&&e.clipDist>0&&(this.camera.near=Math.max(e.clipDist,this.camera.near)))}__updateCamera(){let e=this.camera;e.updateMatrix(),e.updateMatrixWorld(!0),e.updateProjectionMatrix(),function(t,i,r,s,o){let a=new Et;r.getSize(a);let l=a.height,c=r.getPixelRatio(),u=i.type==="OrthographicCamera";VE.set(a.width,a.height),rg.copy(i.projectionMatrix).invert(),sg.copy(i.projectionMatrix).transpose(),t.traverse(function(d){let f=d.material;if(!f)return;let m=f.uniforms;if(m){if(f.clipNear){let p=(50-f.clipNear)/50,_=s-o*p;m.clipNear.value=_}m.canvasHeight&&(m.canvasHeight.value=l),m.resolution&&m.resolution.value.copy(VE),m.pixelRatio&&(m.pixelRatio.value=c),m.projectionMatrixInverse&&m.projectionMatrixInverse.value.copy(rg),m.projectionMatrixTranspose&&m.projectionMatrixTranspose.value.copy(sg),m.ortho&&(m.ortho.value=u)}})}(this.scene,e,this.renderer,this.cDist,this.bRadius),function(t,i){t.traverseVisible(function(r){if(!(r instanceof Ch&&r.userData.buffer.parameters.sortParticles))return;let s=r.geometry.attributes,o=s.position.count;if(o===0)return;let a,l,c,u,d,f,m,p;UE.multiplyMatrices(i.matrixWorldInverse,r.matrixWorld),zE.multiplyMatrices(i.projectionMatrix,UE),r.userData.sortData?(a=r.userData.sortData,c=a.__zArray,l=a.__sortArray,u=a.__cmpFn):(c=new Float32Array(o),l=new Uint32Array(o),u=function(_,y){let g=c[_],b=c[y];return g>b?1:gC?1:R=A&&y(_[S],v)>0;)_[S+1]=_[S],--S;_[S+1]=v}if(w===-1)break;M=h[w--],A=h[w--]}else{for(S=A+1,x=M,T(A+M>>1,S),y(_[A],_[M])>0&&T(A,M),y(_[S],_[M])>0&&T(S,M),y(_[A],_[S])>0&&T(A,S),v=_[S];;){do S++;while(y(_[S],v)<0);do x--;while(y(_[x],v)>0);if(x=x-A?(h[++w]=S,h[++w]=M,M=x-1):(h[++w]=A,h[++w]=x-1,A=S)}})(l,u);for(let _ in s){let y=s[_],g=y.array,b=y.itemSize;a[_]||(a[_]=new Float32Array(b*o)),p=a[_],a[_]=g;for(let h=0;h0&&this.parameters.cameraType!=="stereo"?this.__renderSuperSample(t,i):this.__renderModelGroup(t,i)}render(e=!1,t){if(this.rendering)we.warn("'tried to call 'render' from within 'render'");else{this.rendering=!0;try{this.__updateClipping(),this.__updateCamera(),this.__updateLights(),this.updateInfo(!0),this.parameters.cameraType==="stereo"?this.__renderStereo(e,t):this.__render(e,this.camera,t),this.lastRenderedPicking=e}finally{this.rendering=!1,this.renderPending=!1}this.signals.rendered.dispatch()}}clear(){we.log("scene cleared"),this.scene.remove(this.rotationGroup),this._initScene(),this.renderer.clear()}dispose(){this.renderer.dispose(),window.cancelAnimationFrame(this.frameRequest)}};function $E(n){let e=n.touches[0].pageX-n.touches[1].pageX,t=n.touches[0].pageY-n.touches[1].pageY;return Math.sqrt(e*e+t*t)}var qx=class{constructor(e,t={}){this.domElement=e,this.signals={moved:new Pt.Signal,scrolled:new Pt.Signal,dragged:new Pt.Signal,dropped:new Pt.Signal,clicked:new Pt.Signal,hovered:new Pt.Signal,doubleClicked:new Pt.Signal},this.position=new Et,this.prevPosition=new Et,this.down=new Et,this.canvasPosition=new Et,this.prevClickCP=new Et,this.moving=!1,this.hovering=!0,this.scrolled=!1,this.lastMoved=1/0,this.which=0,this.buttons=0,this.pressed=!1,this.altKey=!1,this.ctrlKey=!1,this.metaKey=!1,this.shiftKey=!1,this.domElement.style.touchAction="none",this.hoverTimeout=U(t.hoverTimeout,50),this.handleScroll=U(t.handleScroll,!0),this.doubleClickSpeed=U(t.doubleClickSpeed,500),this._listen=this._listen.bind(this),this._onMousewheel=this._onMousewheel.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onMouseup=this._onMouseup.bind(this),this._onContextmenu=this._onContextmenu.bind(this),this._onTouchstart=this._onTouchstart.bind(this),this._onTouchend=this._onTouchend.bind(this),this._onTouchmove=this._onTouchmove.bind(this),this._listen();let i={passive:!1};document.addEventListener("mousewheel",this._onMousewheel,i),document.addEventListener("wheel",this._onMousewheel,i),document.addEventListener("MozMousePixelScroll",this._onMousewheel,i),document.addEventListener("mousemove",this._onMousemove,i),document.addEventListener("mousedown",this._onMousedown,i),document.addEventListener("mouseup",this._onMouseup,i),document.addEventListener("contextmenu",this._onContextmenu,i),document.addEventListener("touchstart",this._onTouchstart,i),document.addEventListener("touchend",this._onTouchend,i),document.addEventListener("touchmove",this._onTouchmove,i)}get key(){let e=0;return this.altKey&&(e+=1),this.ctrlKey&&(e+=2),this.metaKey&&(e+=4),this.shiftKey&&(e+=8),e}setParameters(e={}){this.hoverTimeout=U(e.hoverTimeout,this.hoverTimeout)}_listen(){let e=window.performance.now(),t=this.canvasPosition;this.doubleClickPending&&e-this.lastClicked>this.doubleClickSpeed&&(this.doubleClickPending=!1),e-this.lastMoved>this.hoverTimeout&&(this.moving=!1),(this.scrolled||!this.moving&&!this.hovering)&&(this.scrolled=!1,this.hoverTimeout!==-1&&this.overElement&&(this.hovering=!0,this.signals.hovered.dispatch(t.x,t.y))),this.frameRequest=window.requestAnimationFrame(this._listen)}_onMousewheel(e){if(e.target!==this.domElement||!this.handleScroll)return;e.preventDefault(),this._setKeys(e);let t=0;"deltaY"in e&&"deltaMode"in e&&e.deltaY!==void 0&&e.deltaMode!==void 0?t=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?.025*-e.deltaY:e.deltaMode===WheelEvent.DOM_DELTA_LINE?-e.deltaY*(2.5/3):2.5*-e.deltaY:"deltaY"in e&&!("detail"in e)?t=.025*-e.deltaY:e.wheelDelta!==void 0?t=.025*-e.wheelDelta:e.wheelDeltaY!==void 0?t=.025*-e.wheelDeltaY:e.detail!==void 0&&(t=-e.detail/3),this.signals.scrolled.dispatch(t),setTimeout(()=>{this.scrolled=!0},this.hoverTimeout)}_onMousemove(e){e.target===this.domElement?(e.preventDefault(),this.overElement=!0):this.overElement=!1,this._setKeys(e),this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(e.clientX,e.clientY),this._setCanvasPosition(e);let t=this.prevPosition.x-this.position.x,i=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(t,i),this.pressed&&this.signals.dragged.dispatch(t,i)}_onMousedown(e){e.target===this.domElement&&(e.preventDefault(),this._setKeys(e),this.moving=!1,this.hovering=!1,this.down.set(e.clientX,e.clientY),this.position.set(e.clientX,e.clientY),this.which=e.which,this.buttons=function(t){if(typeof t=="object"){if("buttons"in t)return t.buttons;if("which"in t){let i=t.which;if(i===2)return 4;if(i===3)return 2;if(i>0)return 1<=0)return 1<2&&this.handleScroll&&this.position.distanceTo(this.prevPosition)<2)this.which=0,this.buttons=0,this.signals.scrolled.dispatch(i/2);else{this.which=3,this.buttons=2;let r=this.prevPosition.x-this.position.x,s=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(r,s),this.pressed&&this.signals.dragged.dispatch(r,s)}}}}_distance(){return this.position.distanceTo(this.down)}_setCanvasPosition(e){let t=this.domElement.getBoundingClientRect(),i,r;"clientX"in e&&"clientY"in e?(i=e.clientX-t.left,r=e.clientY-t.top):(i=e.offsetX,r=e.offsetY),this.canvasPosition.set(i,t.height-r)}_setKeys(e){this.altKey=e.altKey,this.ctrlKey=e.ctrlKey,this.metaKey=e.metaKey,this.shiftKey=e.shiftKey}dispose(){document.removeEventListener("mousewheel",this._onMousewheel),document.removeEventListener("wheel",this._onMousewheel),document.removeEventListener("MozMousePixelScroll",this._onMousewheel),document.removeEventListener("mousemove",this._onMousemove),document.removeEventListener("mousedown",this._onMousedown),document.removeEventListener("mouseup",this._onMouseup),document.removeEventListener("contextmenu",this._onContextmenu),document.removeEventListener("touchstart",this._onTouchstart),document.removeEventListener("touchend",this._onTouchend),document.removeEventListener("touchmove",this._onTouchmove),window.cancelAnimationFrame(this.frameRequest)}},Vv=new qe,Hv=new qe,WE=new qe,ir=new qe,jE=new qe,Sr=new W,Oh=new Xn,XE=new Xn,Xo=new qe,Ga=new W,_m=new W,Yx=class{constructor(e,t={}){this.stage=e,this.rotateSpeed=U(t.rotateSpeed,2),this.zoomSpeed=U(t.zoomSpeed,1.2),this.panSpeed=U(t.panSpeed,1),this.viewer=e.viewer,this.mouse=e.mouseObserver,this.controls=e.viewerControls}get component(){return this.stage.transformComponent}get atom(){return this.stage.transformAtom}_setPanVector(e,t,i=0){let r=this.controls.getCanvasScaleFactor(i);Ga.set(e,t,0),Ga.multiplyScalar(this.panSpeed*r)}_getRotateXY(e,t){return[this.rotateSpeed*-e*.01,this.rotateSpeed*t*.01]}_getCameraRotation(e){return e.extractRotation(this.viewer.camera.matrixWorld),e.multiply(Hv.makeRotationY(Math.PI)),e}_transformPanVector(){this.component&&(Xo.extractRotation(this.component.transform),Xo.premultiply(this.viewer.rotationGroup.matrix),Xo.invert(),Xo.multiply(this._getCameraRotation(ir)),Ga.applyMatrix4(Xo))}zoom(e){this.controls.zoom(this.zoomSpeed*e*.02)}pan(e,t){this._setPanVector(e,t),Xo.copy(this.viewer.rotationGroup.matrix).invert(),Xo.multiply(this._getCameraRotation(ir)),Ga.applyMatrix4(Xo),this.controls.translate(Ga)}panComponent(e,t){this.component&&(this._setPanVector(e,t),this._transformPanVector(),this.component.position.add(Ga),this.component.updateMatrix())}panAtom(e,t){this.atom&&this.component&&(this.atom.positionToVector3(_m),_m.add(this.viewer.translationGroup.position),_m.applyMatrix4(this.viewer.rotationGroup.matrix),this._setPanVector(e,t,_m.z),this._transformPanVector(),this.atom.positionAdd(Ga),this.component.updateRepresentations({position:!0}))}rotate(e,t){let[i,r]=this._getRotateXY(e,t);this._getCameraRotation(ir),Sr.set(1,0,0),Sr.applyMatrix4(ir),Oh.setFromAxisAngle(Sr,r),Sr.set(0,1,0),Sr.applyMatrix4(ir),XE.setFromAxisAngle(Sr,i),Oh.multiply(XE),ir.makeRotationFromQuaternion(Oh),this.controls.applyMatrix(ir)}zRotate(e,t){let i=this.rotateSpeed*((-e+t)/-2)*.01;WE.makeRotationZ(i),this.controls.applyMatrix(WE)}rotateComponent(e,t){if(!this.component)return;let[i,r]=this._getRotateXY(e,t);this._getCameraRotation(jE),ir.extractRotation(this.component.transform),ir.premultiply(this.viewer.rotationGroup.matrix),ir.invert(),ir.premultiply(jE),Sr.set(1,0,0),Sr.applyMatrix4(ir),Vv.makeRotationAxis(Sr,r),Sr.set(0,1,0),Sr.applyMatrix4(ir),Hv.makeRotationAxis(Sr,i),Vv.multiply(Hv),Oh.setFromRotationMatrix(Vv),this.component.quaternion.premultiply(Oh),this.component.quaternion.normalize(),this.component.updateMatrix()}},_c=new W,Zx=class{constructor(e,t){this.stage=t,this.pid=e.pid,this.picker=e.picker,this.instance=e.instance,this.stage=t,this.controls=t.viewerControls,this.mouse=t.mouseObserver}get type(){return this.picker.type}get altKey(){return this.mouse.altKey}get ctrlKey(){return this.mouse.ctrlKey}get metaKey(){return this.mouse.metaKey}get shiftKey(){return this.mouse.shiftKey}get canvasPosition(){return this.mouse.canvasPosition}get component(){return this.stage.getComponentsByObject(this.picker.data).list[0]}get object(){return this.picker.getObject(this.pid)}get position(){return this.picker.getPosition(this.pid,this.instance,this.component)}get closestBondAtom(){if(this.type!=="bond"||!this.bond)return;let e=this.bond,t=this.controls,i=this.canvasPosition,r=e.atom1.positionToVector3(),s=e.atom2.positionToVector3();r.applyMatrix4(this.component.matrix),s.applyMatrix4(this.component.matrix);let o=t.getPositionOnCanvas(r),a=t.getPositionOnCanvas(s);return c=o,u=a,(l=i).distanceTo(c)=r.length))return new Zx(i,this.stage);console.error("pid >= picker.array.length")}}},qE=new Xn,YE=new W,ZE=new W,Gv=new W,HB=new W,KE=new qe,JE=new W,QE=new qe,Jx=class{constructor(e){this.stage=e,this.signals={changed:new Td.Signal},this.viewer=e.viewer}get position(){return this.viewer.translationGroup.position}get rotation(){return this.viewer.rotationGroup.quaternion}changed(){this.viewer.requestRender(),this.signals.changed.dispatch()}getPositionOnCanvas(e,t){let i=C0(t,Et),r=this.viewer;return Gv.copy(e).add(r.translationGroup.position).applyMatrix4(r.rotationGroup.matrix).project(r.camera),i.set((Gv.x+1)*r.width/2,(Gv.y+1)*r.height/2)}getCanvasScaleFactor(e=0){let t=this.viewer.camera;if(t instanceof jo)return 1/t.zoom;{e=Math.abs(e),e+=this.getCameraDistance();let i=En(t.fov);return 2*e*Math.tan(i/2)/this.viewer.height}}getOrientation(e){let t=jh(e);t.copy(this.viewer.rotationGroup.matrix);let i=this.getCameraDistance();return t.scale(HB.set(i,i,i)),t.setPosition(this.viewer.translationGroup.position),t}orient(e){jh(e).decompose(YE,qE,ZE);let t=this.viewer;t.rotationGroup.setRotationFromQuaternion(qE),t.translationGroup.position.copy(YE),t.cameraDistance=ZE.z,t.updateZoom(),this.changed()}translate(e){this.viewer.translationGroup.position.add(Za(e)),this.changed()}center(e){this.viewer.translationGroup.position.copy(Za(e)).negate(),this.changed()}zoom(e){this.distance(this.getCameraDistance()*(1-e))}getCameraDistance(){return this.viewer.cameraDistance}distance(e){this.viewer.cameraDistance=Math.max(Math.abs(e),.2),this.viewer.updateZoom(),this.changed()}spin(e,t){KE.copy(this.viewer.rotationGroup.matrix).invert(),JE.copy(Za(e)).applyMatrix4(KE),this.viewer.rotationGroup.rotateOnAxis(JE,t),this.changed()}rotate(e){this.viewer.rotationGroup.setRotationFromQuaternion(Nx(e)),this.changed()}align(e){QE.copy(jh(e)).invert(),this.viewer.rotationGroup.setRotationFromMatrix(QE),this.changed()}applyMatrix(e){this.viewer.rotationGroup.applyMatrix4(jh(e)),this.changed()}},io=class{constructor(e,t,...i){this.pausedTime=-1,this.elapsedDuration=0,this.pausedDuration=0,this.ignoreGlobalToggle=!1,this._paused=!1,this._resolveList=[],this.duration=U(e,1e3),this.controls=t,this.startTime=window.performance.now(),this._init(...i)}get done(){return this.alpha===1}get paused(){return this._paused}tick(e){if(!this._paused)return this.elapsedDuration=e.currentTime-this.startTime-this.pausedDuration,this.duration===0?this.alpha=1:this.alpha=Pd(0,1,this.elapsedDuration/this.duration),this._tick(e),this.done&&this._resolveList.forEach(t=>t()),this.done}pause(e){e&&(this._hold=!0),this.pausedTime===-1&&(this.pausedTime=window.performance.now()),this._paused=!0}resume(e){!e&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)}toggle(){this._paused?this.resume():this.pause()}then(e){let t;return t=this.done?Promise.resolve():new Promise(i=>this._resolveList.push(i)),t.then(e)}},og=class extends io{constructor(e,t,...i){super(U(e,1/0),t,...i)}_init(e,t){Array.isArray(e)?this.axis=new W().fromArray(e):this.axis=U(e,new W(0,1,0)),this.angle=U(t,.01)}_tick(e){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*e.lastDuration/16)}},ag=class extends io{constructor(e,t,...i){super(U(e,1/0),t,...i),this.angleSum=0,this.direction=1}_init(e,t,i){Array.isArray(e)?this.axis=new W().fromArray(e):this.axis=U(e,new W(0,1,0)),this.angleStep=U(t,.01),this.angleEnd=U(i,.2)}_tick(e){if(!this.axis||!this.angleStep||!this.angleEnd)return;let t=Pd(0,1,Math.abs(this.angleSum)/this.angleEnd),i=this.angleStep*this.direction*(1.1-t);this.controls.spin(this.axis,i*e.lastDuration/16),this.angleSum+=this.angleStep,this.angleSum>=this.angleEnd&&(this.direction*=-1,this.angleSum=-this.angleEnd)}},lg=class extends io{_init(e,t){this.moveFrom=Za(U(e,new W)),this.moveTo=Za(U(t,new W))}_tick(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()}},Qx=class extends io{_init(e,t){this.zoomFrom=e,this.zoomTo=t}_tick(){this.controls.distance(Cr(this.zoomFrom,this.zoomTo,this.alpha))}},eb=class extends io{constructor(){super(...arguments),this._currentRotation=new Xn}_init(e,t){this.rotateFrom=Nx(e),this.rotateTo=Nx(t),this._currentRotation=new Xn}_tick(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)}},tb=class extends io{_init(e,t,i){this.valueFrom=e,this.valueTo=t,this.callback=i}_tick(){this.callback(Cr(this.valueFrom,this.valueTo,this.alpha))}},nb=class extends io{_init(e){this.callback=e}_tick(){this.alpha===1&&this.callback()}},cg=class{constructor(e=[]){this._resolveList=[],this._list=e}get done(){return this._list.every(e=>e.done)}then(e){let t;return t=this.done?Promise.resolve():new Promise(i=>{this._resolveList.push(i),this._list.forEach(r=>{r.then(()=>{this._resolveList.forEach(s=>{s()}),this._resolveList.length=0})})}),t.then(e)}},ib=class{constructor(e){this.stage=e,this.animationList=[],this.finishedList=[],this.viewer=e.viewer,this.controls=e.viewerControls}get paused(){return this.animationList.every(e=>e.paused)}add(e){return e.duration===0?e.tick(this.viewer.stats):this.animationList.push(e),e}remove(e){let t=this.animationList,i=t.indexOf(e);i>-1&&t.splice(i,1)}run(e){let t=this.finishedList,i=this.animationList,r=i.length;for(let o=0;oe.pause())}resume(){this.animationList.forEach(e=>e.resume())}toggle(){this.paused?this.resume():this.pause()}clear(){this.animationList.length=0}dispose(){this.clear()}},rb=class{constructor(e,t){if(this.fn=e,this.queue=[],this.pending=!1,this.next=this.next.bind(this),t){for(let i=0,r=t.length;ithis.run(e))):this.pending=!1}push(e){this.queue.push(e),this.pending||this.next()}kill(){this.queue.length=0}length(){return this.queue.length}},el=class{constructor(e,t,i){this.type="",this.parameters={lazy:{type:"boolean"},clipNear:{type:"range",step:1,max:100,min:0,buffer:!0},clipRadius:{type:"number",precision:1,max:1e3,min:0,buffer:!0},clipCenter:{type:"vector3",precision:1,buffer:!0},flatShaded:{type:"boolean",buffer:!0},opacity:{type:"range",step:.01,max:1,min:0,buffer:!0},depthWrite:{type:"boolean",buffer:!0},side:{type:"select",buffer:!0,options:{front:"front",back:"back",double:"double"}},wireframe:{type:"boolean",buffer:!0},colorData:{type:"hidden",update:"color"},colorScheme:{type:"select",update:"color",options:{}},colorScale:{type:"select",update:"color",options:Dt.getScales()},colorReverse:{type:"boolean",update:"color"},colorValue:{type:"color",update:"color"},colorDomain:{type:"hidden",update:"color"},colorMode:{type:"select",update:"color",options:Dt.getModes()},roughness:{type:"range",step:.01,max:1,min:0,buffer:!0},metalness:{type:"range",step:.01,max:1,min:0,buffer:!0},diffuse:{type:"color",buffer:!0},diffuseInterior:{type:"boolean",buffer:!0},useInteriorColor:{type:"boolean",buffer:!0},interiorColor:{type:"color",buffer:!0},interiorDarkening:{type:"range",step:.01,max:1,min:0,buffer:!0},matrix:{type:"hidden",buffer:!0},disablePicking:{type:"boolean",rebuild:!0}},this.viewer=t,this.tasks=new ig,this.queue=new rb(this.make.bind(this)),this.bufferList=[],this.parameters.colorScheme&&(this.parameters.colorScheme.options=Dt.getSchemes()),this.toBePrepared=!1}init(e){let t=e||{};this.clipNear=U(t.clipNear,0),this.clipRadius=U(t.clipRadius,0),this.clipCenter=U(t.clipCenter,new W),this.flatShaded=U(t.flatShaded,!1),this.side=U(t.side,"double"),this.opacity=U(t.opacity,1),this.depthWrite=U(t.depthWrite,!0),this.wireframe=U(t.wireframe,!1),this.setColor(t.color,t),this.colorData=U(t.colorData,void 0),this.colorScheme=U(t.colorScheme,"uniform"),this.colorScale=U(t.colorScale,""),this.colorReverse=U(t.colorReverse,!1),this.colorValue=U(t.colorValue,9474192),this.colorDomain=U(t.colorDomain,void 0),this.colorMode=U(t.colorMode,"hcl"),this.visible=U(t.visible,!0),this.quality=U(t.quality,void 0),this.roughness=U(t.roughness,.4),this.metalness=U(t.metalness,0),this.diffuse=U(t.diffuse,16777215),this.diffuseInterior=U(t.diffuseInterior,!1),this.useInteriorColor=U(t.useInteriorColor,!1),this.interiorColor=U(t.interiorColor,2236962),this.interiorDarkening=U(t.interiorDarkening,0),this.lazy=U(t.lazy,!1),this.lazyProps={build:!1,bufferParams:{},what:{}},this.matrix=U(t.matrix,new qe),this.disablePicking=U(t.disablePicking,!1);let i=this.parameters;i.sphereDetail===!0&&(i.sphereDetail={type:"integer",max:3,min:0,rebuild:"impostor"}),i.radialSegments===!0&&(i.radialSegments={type:"integer",max:25,min:5,rebuild:"impostor"}),i.openEnded===!0&&(i.openEnded={type:"boolean",rebuild:"impostor",buffer:!0}),i.disableImpostor===!0&&(i.disableImpostor={type:"boolean",rebuild:!0}),t.quality==="low"?(i.sphereDetail&&(this.sphereDetail=0),i.radialSegments&&(this.radialSegments=5)):t.quality==="medium"?(i.sphereDetail&&(this.sphereDetail=1),i.radialSegments&&(this.radialSegments=10)):t.quality==="high"?(i.sphereDetail&&(this.sphereDetail=2),i.radialSegments&&(this.radialSegments=20)):(i.sphereDetail&&(this.sphereDetail=U(t.sphereDetail,1)),i.radialSegments&&(this.radialSegments=U(t.radialSegments,10))),i.openEnded&&(this.openEnded=U(t.openEnded,!0)),i.disableImpostor&&(this.disableImpostor=U(t.disableImpostor,!1))}getColorParams(e){return Object.assign({data:this.colorData,scheme:this.colorScheme,scale:this.colorScale,reverse:this.colorReverse,value:this.colorValue,domain:this.colorDomain,mode:this.colorMode,colorSpace:this.colorSpace},e)}getBufferParams(e={}){return Object.assign({clipNear:this.clipNear,clipRadius:this.clipRadius,clipCenter:this.clipCenter,flatShaded:this.flatShaded,opacity:this.opacity,depthWrite:this.depthWrite,side:this.side,wireframe:this.wireframe,roughness:this.roughness,metalness:this.metalness,diffuse:this.diffuse,diffuseInterior:this.diffuseInterior,useInteriorColor:this.useInteriorColor,interiorColor:this.interiorColor,interiorDarkening:this.interiorDarkening,matrix:this.matrix,disablePicking:this.disablePicking},e)}setColor(e,t){let i=Object.keys(Dt.getSchemes());if(typeof e=="string"&&i.includes(e.toLowerCase()))t?t.colorScheme=e:this.setParameters({colorScheme:e});else if(e!==void 0){let r=new dt(e).getHex();t?(t.colorScheme="uniform",t.colorValue=r):this.setParameters({colorScheme:"uniform",colorValue:r})}return this}prepare(e){}create(){}update(e){this.build()}build(e){if(!this.lazy||this.visible&&this.opacity){if(!this.toBePrepared)return this.tasks.increment(),void this.make();this.queue.length()>0?(this.tasks.change(1-this.queue.length()),this.queue.kill()):this.tasks.increment(),this.queue.push(e||!1)}else this.lazyProps.build=!0}make(e,t){Le&&we.time("Representation.make "+this.type);let i=()=>{e?(this.update(e),this.viewer.requestRender(),this.tasks.decrement(),t&&t()):(this.clear(),this.create(),this.manualAttach||this.disposed||(Le&&we.time("Representation.attach "+this.type),this.attach(()=>{Le&&we.timeEnd("Representation.attach "+this.type),this.tasks.decrement(),t&&t()}))),Le&&we.timeEnd("Representation.make "+this.type)};this.toBePrepared?this.prepare(i):i()}attach(e){this.setVisibility(this.visible),e()}setVisibility(e,t){if(this.visible=e,this.visible&&this.opacity){let i=this.lazyProps,r=i.bufferParams,s=i.what;if(i.build)return i.build=!1,this.build(),this;(Object.keys(r).length||Object.keys(s).length)&&(i.bufferParams={},i.what={},this.updateParameters(r,s))}return this.bufferList.forEach(function(i){i.setVisibility(e)}),t||this.viewer.requestRender(),this}setParameters(e,t={},i=!1){let r=e||{},s=this.parameters,o={};this.opacity||r.opacity===void 0||(this.lazyProps.build?(this.lazyProps.build=!1,i=!0):(Object.assign(o,this.lazyProps.bufferParams),Object.assign(t,this.lazyProps.what),this.lazyProps.bufferParams={},this.lazyProps.what={})),this.setColor(r.color,r);for(let a in r)r[a]!==void 0&&s[a]!=null&&(s[a].int&&(r[a]=parseInt(r[a])),s[a].float&&(r[a]=parseFloat(r[a])),r[a]!==this[a]||r[a].equals&&!r[a].equals(this[a]))&&(this[a]&&this[a].copy&&r[a].copy?this[a].copy(r[a]):this[a]&&this[a].set?this[a].set(r[a]):this[a]=r[a],s[a].buffer&&(s[a].buffer===!0?o[a]=r[a]:o[s[a].buffer]=r[a]),s[a].update&&(t[s[a].update]=!0),!s[a].rebuild||s[a].rebuild==="impostor"&&ys&&!this.disableImpostor||(i=!0));return i?this.build():this.updateParameters(o,t),this}updateParameters(e={},t){if(this.lazy&&(!this.visible||!this.opacity)&&e.hasOwnProperty("opacity")===!1)return Object.assign(this.lazyProps.bufferParams,e),void Object.assign(this.lazyProps.what,t);this.bufferList.forEach(function(i){i.setParameters(e)}),Object.keys(t).length&&this.update(t),this.viewer.requestRender()}getParameters(){let e={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach(t=>{this.parameters[t]!==null&&(e[t]=this[t])}),e}clear(){this.bufferList.forEach(e=>{this.viewer.remove(e),e.dispose()}),this.bufferList.length=0,this.viewer.requestRender()}dispose(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()}},ug=class{constructor(e){this.pending=0,this.postCount=0,this.onmessageDict={},this.onerrorDict={},this.name=e,this.blobUrl=window.URL.createObjectURL(td.get(e)),this.worker=new Worker(this.blobUrl),td.activeWorkerCount+=1,this.worker.onmessage=t=>{this.pending-=1;let i=t.data.__postId;Le&&we.timeEnd("Worker.postMessage "+e+" #"+i);let r=this.onmessageDict[i];r&&r.call(this.worker,t),delete this.onmessageDict[i],delete this.onerrorDict[i]},this.worker.onerror=t=>{if(this.pending-=1,t.data){let i=t.data.__postId,r=this.onerrorDict[i];r?r.call(this.worker,t):we.error("Worker.onerror",i,e,t),delete this.onmessageDict[i],delete this.onerrorDict[i]}else we.error("Worker.onerror",e,t)}}post(e={},t,i,r){this.onmessageDict[this.postCount]=i,this.onerrorDict[this.postCount]=r,e.__name=this.name,e.__postId=this.postCount,e.__debug=Le,Le&&we.time(`Worker.postMessage ${this.name} #${this.postCount}`);try{this.worker.postMessage(e,t)}catch(s){we.error("worker.post:",s),this.worker.postMessage(e)}return this.pending+=1,this.postCount+=1,this}terminate(){this.worker?(this.worker.terminate(),window.URL.revokeObjectURL(this.blobUrl),td.activeWorkerCount-=1):we.log("no worker to terminate")}},md=class{constructor(e,t=2){this.pool=[],this.count=0,this.maxCount=Math.min(8,t),this.name=e}post(e={},t,i,r){let s=this.getNextWorker();return s?s.post(e,t,i,r):console.error("unable to get worker from pool"),this}terminate(){this.pool.forEach(function(e){e.terminate()})}getNextWorker(){let e,t=1/0;for(let i=0;i=this.count){e=new ug(this.name),this.pool.push(e),this.count+=1;break}let r=this.pool[i];if(r.pending===0){e=r;break}r.pendingr&&(r=c),u>s&&(s=u),d>o&&(o=d)}return[Mt([e,t,i]),Mt([r,s,o])]}function T0(n,e){for(let t=0,i=e.length;t0){let a=1/Math.sqrt(o);n[e]=i*a,n[e+1]=r*a,n[e+2]=s*a}}}function Mt(n){return new Float32Array(n||3)}function $i(n,e,t){let i=e[0],r=e[1],s=e[2],o=t[0],a=t[1],l=t[2];n[0]=r*l-s*a,n[1]=s*o-i*l,n[2]=i*a-r*o}function Vi(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function xn(n,e,t){n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2]}function Zr(n,e,t){n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2]}function Ri(n,e,t=0){n[0]=e[t],n[1]=e[t+1],n[2]=e[t+2]}function Tt(n,e,t=0){e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2]}function HP(n){return n[0]*n[0]+n[1]*n[1]+n[2]*n[2]}function Qo(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2])}function Pc(n,e,t){Jt(n,e,1/t)}function Jt(n,e,t){n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t}function Cn(n,e){let t=HP(e);t==0?(n[0]=e[0],n[1]=e[1],n[2]=e[2]):Jt(n,e,1/Math.sqrt(t))}function GP(n,e,t){n[0]=e[0]-t,n[1]=e[1]-t,n[2]=e[2]-t}function qm(n,e,t){n[0]=e[0]+t,n[1]=e[1]+t,n[2]=e[2]+t}function ob(n,e){n[0]=Math.floor(e[0]),n[1]=Math.floor(e[1]),n[2]=Math.floor(e[2])}function qh(n,e){n[0]=Math.ceil(e[0]),n[1]=Math.ceil(e[1]),n[2]=Math.ceil(e[2])}function P0(n,e){n[0]=-e[0],n[1]=-e[1],n[2]=-e[2]}function GB(n,e){let t=n[0],i=n[1],r=n[2],s=e[0],o=e[1],a=e[2],l=i*a-r*o,c=r*s-t*a,u=t*o-i*s,d=Math.sqrt(l*l+c*c+u*u),f=t*s+i*o+r*a;return Math.atan2(d,f)}function $B(n,e=9){let t=Math.floor(e/2),i=n.position1.length/3,r=3*(t*i),s=1/e,o=E0(n.position1,n.position2),a=new Float32Array(r),l=new Float32Array(r),c=new W;for(let m=0;m0){let S=3*m;r[S]=n.position2[3*u-3],r[S+1]=n.position2[3*u-2],r[S+1]=n.position2[3*u-1]}let y=new Float32Array(i),g=new Float32Array(r),b=_s(y,g),h=new Float32Array(s),v={position:b,position1:y,position2:g,color:h,color2:h};return o&&(v.radius=new Float32Array(o)),a&&n.picking&&(n.picking.array=new Float32Array(a),v.picking=n.picking),l&&(v.primitiveId=new Float32Array(l)),v}md.prototype.constructor=md,gd.__deps=[Mt],Pc.__deps=[Jt],Cn.__deps=[Jt,HP];var na=new W,Ss=class{static get Picker(){return Mr.get(this.type)}static get Buffer(){return cr.get(this.type)}static getShapeKey(e){return this.type+e[0].toUpperCase()+e.substr(1)}static expandBoundingBox(e,t){}static valueToShape(e,t,i){let r=e._primitiveData[this.getShapeKey(t)];switch(this.fields[t]){case"v3":case"c":(function(s,o){s.toArray!==void 0?s=s.toArray():s.x!==void 0?s=[s.x,s.y,s.z]:s.r!==void 0&&(s=[s.r,s.g,s.b]),o.push.apply(o,s)})(i,r);break;default:r.push(i)}}static objectToShape(e,t){Object.keys(this.fields).forEach(i=>{this.valueToShape(e,i,t[i])}),this.valueToShape(e,"name",t.name),this.expandBoundingBox(e.boundingBox,t)}static valueFromShape(e,t,i){let r=e._primitiveData[this.getShapeKey(i)];switch(this.fields[i]){case"v3":return new W().fromArray(r,3*t);case"c":return new dt().fromArray(r,3*t);default:return r[t]}}static objectFromShape(e,t){let i=this.valueFromShape(e,t,"name");i===void 0&&(i=`${this.type}: ${t} (${e.name})`);let r={shape:e,name:i};return Object.keys(this.fields).forEach(s=>{r[s]=this.valueFromShape(e,t,s)}),r}static arrayFromShape(e,t){let i=e._primitiveData[this.getShapeKey(t)];return this.fields[t]==="s"?i:new Float32Array(i)}static dataFromShape(e){let t={};return this.Picker&&(t.picking=new this.Picker(e)),Object.keys(this.fields).forEach(i=>{t[i]=this.arrayFromShape(e,i)}),t}static bufferFromShape(e,t){return new this.Buffer(this.dataFromShape(e),t)}};Ss.type="",Ss.fields={};var ia=class extends Ss{static positionFromShape(e,t){return this.valueFromShape(e,t,"position")}static expandBoundingBox(e,t){e.expandByPoint(na.fromArray(t.position))}};ia.type="sphere",ia.fields={position:"v3",color:"c",radius:"f"};var ro=class extends Ss{static positionFromShape(e,t){return this.valueFromShape(e,t,"position")}static expandBoundingBox(e,t){e.expandByPoint(na.fromArray(t.position))}};ro.type="box",ro.fields={position:"v3",color:"c",size:"f",heightAxis:"v3",depthAxis:"v3"};var $c=class extends ro{};$c.type="octahedron";var Wc=class extends ro{};Wc.type="tetrahedron";var so=class extends Ss{static positionFromShape(e,t){let i=this.valueFromShape(e,t,"position1"),r=this.valueFromShape(e,t,"position2");return i.add(r).multiplyScalar(.5)}static expandBoundingBox(e,t){e.expandByPoint(na.fromArray(t.position1)),e.expandByPoint(na.fromArray(t.position2))}static bufferFromShape(e,t={}){let i=this.dataFromShape(e);return this.type==="cylinder"&&t.dashedCylinder&&(i=$P(i)),new this.Buffer(i,t)}};so.type="cylinder",so.fields={position1:"v3",position2:"v3",color:"c",radius:"f"};var jc=class extends so{};jc.type="arrow";var Xc=class extends so{};Xc.type="cone";var ra=class extends ia{};ra.type="ellipsoid",ra.fields={position:"v3",color:"c",radius:"f",majorAxis:"v3",minorAxis:"v3"};var qc=class extends ra{};qc.type="torus";var Yc=class extends Ss{static positionFromShape(e,t){return this.valueFromShape(e,t,"position")}static expandBoundingBox(e,t){e.expandByPoint(na.fromArray(t.position))}};Yc.type="text",Yc.fields={position:"v3",color:"c",size:"f",text:"s"};var tl=class extends Ss{static positionFromShape(e,t){return this.valueFromShape(e,t,"position")}static expandBoundingBox(e,t){e.expandByPoint(na.fromArray(t.position))}};tl.type="point",tl.fields={position:"v3",color:"c"};var nl=class extends Ss{static positionFromShape(e,t){let i=this.valueFromShape(e,t,"position1"),r=this.valueFromShape(e,t,"position2");return i.add(r).multiplyScalar(.5)}static expandBoundingBox(e,t){e.expandByPoint(na.fromArray(t.position1)),e.expandByPoint(na.fromArray(t.position2))}};nl.type="wideline",nl.fields={position1:"v3",position2:"v3",color:"c"};var il=class{constructor(e,t){this.exp=3;let i=t||function(y){let{x:g,y:b,z:h}=y,v=new sn,S=g.length,{min:x,max:w}=v;for(let A=0;A>this.exp),this.boundY=1+(i.max.y-this.minY>>this.exp),this.boundZ=1+(i.max.z-this.minZ>>this.exp);let r=this.boundX*this.boundY*this.boundZ,s=e.count!==void 0?e.count:e.x.length,o=e.x,a=e.y,l=e.z,c=0,u=new Uint32Array(r),d=new Int32Array(s);for(let y=0;y>this.exp,b=a[y]-this.minY>>this.exp,h=l[y]-this.minZ>>this.exp,v=(g*this.boundY+b)*this.boundZ+h;(u[v]+=1)===1&&(c+=1),d[y]=v}let f=new Uint16Array(c);for(let y=0,g=0;y0&&(u[y]=g+1,f[g]=b,g+=1)}let m=new Uint32Array(c);for(let y=1;y0){let b=g-1;_[m[b]+p[b]]=y,p[b]+=1}}this.grid=u,this.bucketCount=f,this.bucketOffset=m,this.bucketArray=_,this.xArray=o,this.yArray=a,this.zArray=l}within(e,t,i,r){let s=[];return this.eachWithin(e,t,i,r,o=>s.push(o)),s}eachWithin(e,t,i,r,s){let o=r*r,a=Math.max(0,e-r-this.minX>>this.exp),l=Math.max(0,t-r-this.minY>>this.exp),c=Math.max(0,i-r-this.minZ>>this.exp),u=Math.min(this.boundX,1+(e+r-this.minX>>this.exp)),d=Math.min(this.boundY,1+(t+r-this.minY>>this.exp)),f=Math.min(this.boundZ,1+(i+r-this.minZ>>this.exp));for(let m=a;m0){let b=g-1,h=this.bucketOffset[b],v=h+this.bucketCount[b];for(let S=h;So?a.set(this[r].subarray(0,o)):a.set(this[r]),this[r]=a}}growIfFull(){if(this.count>=this.length){let e=Math.round(1.5*this.length);this.resize(Math.max(256,e))}}copyFrom(e,t,i,r){for(let s=0,o=this._fields.length;s0;)d-=1;u<=d&&(u===c?c=d:d===c&&(c=u),(a=u)!==(l=d)&&(i.copyFrom(t,0,a,1),t.copyWithin(a,l,1),t.copyFrom(i,l,0,1)),u+=1,d-=1)}while(u<=d);r(s,d),r(u,o)}var a,l})(0,this.count-1),we.timeEnd("Store.sort")}clear(){this.count=0}dispose(){for(let e=0,t=this._fields.length;e>>1&1431655765))+(n>>>2&858993459))+(n>>>4)&252645135)>>>24}var ii=class n{constructor(e,t){this.length=e,this._words=new Uint32Array(e+32>>>5),t===!0&&this.setAll()}get(e){return!!(this._words[e>>>5]&1<>>5]|=1<>>5]&=~(1<>>5]^=1<>>5,a=t>>>5;for(let u=o+1;u>>5]|=1<>>5]|=1<>>5]|=1<>>5]&=~(1<>>5]&=~(1<>>5]&=~(1<>>5]|=1<>>5]&=~(1<>>i,this}_isRangeValue(e,t,i){if(t>>5,a=t>>>5;for(let l=o+1;l>>5]&1<>>5]&1<>>5]&1<>>5]&1<>>5]&1<0){let{types:i,groups:r,centers:s,atomSets:o}=n;i.push(e.type),r.push(e.group),s.x.push(e.x/t),s.y.push(e.y/t),s.z.push(e.z/t),o.push(e.atomSet)}}var rl=0,WB=["D-BETA-PEPTIDE, C-GAMMA LINKING","D-GAMMA-PEPTIDE, C-DELTA LINKING","D-PEPTIDE COOH CARBOXY TERMINUS","D-PEPTIDE NH3 AMINO TERMINUS","D-PEPTIDE LINKING","L-BETA-PEPTIDE, C-GAMMA LINKING","L-GAMMA-PEPTIDE, C-DELTA LINKING","L-PEPTIDE COOH CARBOXY TERMINUS","L-PEPTIDE NH3 AMINO TERMINUS","L-PEPTIDE LINKING","PEPTIDE LINKING","PEPTIDE-LIKE"],jB=["RNA OH 3 PRIME TERMINUS","RNA OH 5 PRIME TERMINUS","RNA LINKING"],XB=["DNA OH 3 PRIME TERMINUS","DNA OH 5 PRIME TERMINUS","DNA LINKING","L-DNA LINKING","L-RNA LINKING"],jP=["D-SACCHARIDE","D-SACCHARIDE 1,4 AND 1,4 LINKING","D-SACCHARIDE 1,4 AND 1,6 LINKING","L-SACCHARIDE","L-SACCHARIDE 1,4 AND 1,4 LINKING","L-SACCHARIDE 1,4 AND 1,6 LINKING","SACCHARIDE"],qB=["NON-POLYMER"].concat(["OTHER"],jP),XP=["h","g","i"],qP=["e","b"],YP=["s","t","l",""],ZP={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,DS:110,RG:111,CN:112,NH:113,FL:114,MC:115,LV:116,TS:117,OG:118},YB={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,110:2,111:2,112:2,113:2,114:2,115:2,116:2,117:2,118:2},ZB={1:.31,2:.28,3:1.28,4:.96,5:.84,6:.76,7:.71,8:.66,9:.57,10:.58,11:1.66,12:1.41,13:1.21,14:1.11,15:1.07,16:1.05,17:1.02,18:1.06,19:2.03,20:1.76,21:1.7,22:1.6,23:1.53,24:1.39,25:1.39,26:1.32,27:1.26,28:1.24,29:1.32,30:1.22,31:1.22,32:1.2,33:1.19,34:1.2,35:1.2,36:1.16,37:2.2,38:1.95,39:1.9,40:1.75,41:1.64,42:1.54,43:1.47,44:1.46,45:1.42,46:1.39,47:1.45,48:1.44,49:1.42,50:1.39,51:1.39,52:1.38,53:1.39,54:1.4,55:2.44,56:2.15,57:2.07,58:2.04,59:2.03,60:2.01,61:1.99,62:1.98,63:1.98,64:1.96,65:1.94,66:1.92,67:1.92,68:1.89,69:1.9,70:1.87,71:1.87,72:1.75,73:1.7,74:1.62,75:1.51,76:1.44,77:1.41,78:1.36,79:1.36,80:1.32,81:1.45,82:1.46,83:1.48,84:1.4,85:1.5,86:1.5,87:2.6,88:2.21,89:2.15,90:2.06,91:2,92:1.96,93:1.9,94:1.87,95:1.8,96:1.69,97:1.6,98:1.6,99:1.6,100:1.6,101:1.6,102:1.6,103:1.6,104:1.6,105:1.6,106:1.6,107:1.6,108:1.6,109:1.6,110:1.6,111:1.6,112:1.6,113:1.6,114:1.6,115:1.6,116:1.6,117:1.6,118:1.6},eT={1:[1],2:[0],3:[1],4:[2],5:[3],6:[4],7:[3],8:[2],9:[1],10:[0],11:[1],12:[2],13:[6],14:[6],15:[3,5,7],16:[2,4,6],17:[1],18:[0],19:[1],20:[2],31:[3],32:[4],33:[3,5],34:[2,4,6],35:[1],36:[0],37:[1],38:[2],49:[3],50:[4],51:[3,5],52:[2],53:[1,2,5],54:[0,2],55:[1],56:[2],81:[3],82:[4],83:[3],84:[2],85:[1],86:[0],87:[1],88:[2]},KB={1:1,2:2,3:1,4:2,5:3,6:4,7:5,8:6,9:7,10:8,11:1,12:2,13:3,14:4,15:5,16:6,17:7,18:8,19:1,20:2,21:3,22:4,23:5,24:6,25:7,26:8,27:9,28:10,29:11,30:2,31:3,32:4,33:5,34:6,35:7,36:8,37:1,38:2,39:3,40:4,41:5,42:6,43:7,44:8,45:9,46:10,47:11,48:2,49:3,50:4,51:5,52:6,53:7,54:8,55:1,56:2,57:3,58:4,59:3,60:4,61:5,62:6,63:7,64:8,65:9,66:10,67:11,68:12,69:13,70:14,71:15,72:4,73:5,74:6,75:7,76:8,77:9,78:10,79:11,80:2,81:3,82:4,83:5,84:6,85:7,86:8,87:1,88:2,89:3,90:4,91:3,92:4,93:5,94:6,95:7,96:8,97:9,98:10,99:11,100:12,101:13,102:14,103:15,104:2,105:2,106:2,107:2,108:2,109:2,110:2,111:2,112:2,113:3,114:4,115:5,116:6,117:7,118:8},tT={ALA:[.17,.5,.33],ARG:[.81,1.81,1],ASN:[.42,.85,.43],ASP:[1.23,3.64,2.41],ASH:[-.07,.43,.5],CYS:[-.24,-.02,.22],GLN:[.58,.77,.19],GLU:[2.02,3.63,1.61],GLH:[-.01,.11,.12],GLY:[.01,1.15,1.14],HIS:[.17,.11,-.06],ILE:[-.31,-1.12,-.81],LEU:[-.56,-1.25,-.69],LYS:[.99,2.8,1.81],MET:[-.23,-.67,-.44],PHE:[-1.13,-1.71,-.58],PRO:[.45,.14,-.31],SER:[.13,.46,.33],THR:[.14,.25,.11],TRP:[-1.85,-2.09,-.24],TYR:[-.94,-.71,.23],VAL:[.07,-.46,-.53]},JB=[0,0,0],hg={HIS:"H",ARG:"R",LYS:"K",ILE:"I",PHE:"F",LEU:"L",TRP:"W",ALA:"A",MET:"M",PRO:"P",CYS:"C",ASN:"N",VAL:"V",GLY:"G",SER:"S",GLN:"Q",TYR:"Y",ASP:"D",GLU:"E",THR:"T",SEC:"U",PYL:"O"},Fc=Object.keys(hg),KP=["A","C","T","G","U","I"],JP=["DA","DC","DT","DG","DU","DI"],QB=["A","G","I","DA","DG","DI"],nd=KP.concat(JP),dg=["SOL","WAT","HOH","H2O","W","DOD","D3O","TIP3","TIP4","SPC"],eU=["118","119","1AL","1CU","2FK","2HP","2OF","3CO","3MT","3NI","3OF","3P8","4MO","4PU","543","6MO","ACT","AG","AL","ALF","AM","ATH","AU","AU3","AUC","AZI","BA","BCT","BEF","BF4","BO4","BR","BS3","BSY","CA","CAC","CD","CD1","CD3","CD5","CE","CHT","CL","CO","CO3","CO5","CON","CR","CS","CSB","CU","CU1","CU3","CUA","CUZ","CYN","DME","DMI","DSC","DTI","DY","E4N","EDR","EMC","ER3","EU","EU3","F","FE","FE2","FPO","GA","GD3","GEP","HAI","HG","HGC","IN","IOD","IR","IR3","IRI","IUM","K","KO4","LA","LCO","LCP","LI","LU","MAC","MG","MH2","MH3","MLI","MLT","MMC","MN","MN3","MN5","MN6","MO1","MO2","MO3","MO4","MO5","MO6","MOO","MOS","MOW","MW1","MW2","MW3","NA","NA2","NA5","NA6","NAO","NAW","NCO","NET","NH4","NI","NI1","NI2","NI3","NO2","NO3","NRU","O4M","OAA","OC1","OC2","OC3","OC4","OC5","OC6","OC7","OC8","OCL","OCM","OCN","OCO","OF1","OF2","OF3","OH","OS","OS4","OXL","PB","PBM","PD","PDV","PER","PI","PO3","PO4","PR","PT","PT4","PTN","RB","RH3","RHD","RU","SB","SCN","SE4","SEK","SM","SMO","SO3","SO4","SR","T1A","TB","TBA","TCN","TEA","TH","THE","TL","TMA","TRA","UNX","V","VN3","VO4","W","WO5","Y1","YB","YB2","YH","YT3","ZCM","ZN","ZN2","ZN3","ZNO","ZO3","OHX"],tU=["045","0AT","0BD","0MK","0NZ","0TS","0V4","0XY","0YT","10M","147","149","14T","15L","16G","18T","18Y","1AR","1BW","1GL","1GN","1JB","1LL","1NA","1S3","26M","26Q","26R","26V","26W","26Y","27C","289","291","293","2DG","2F8","2FG","2FL","2FP","2GL","2M4","2M5","32O","34V","3CM","3DO","3DY","3FM","3LR","3MF","3MG","3SA","3ZW","46D","46M","46Z","48Z","4CQ","4GC","4NN","50A","5DI","5GF","5MM","5RP","5SA","5SP","64K","6PG","6SA","7JZ","7SA","A1Q","A2G","AAB","AAL","AAO","ABC","ABD","ABE","ABF","ABL","ACG","ACI","ACR","ACX","ADA","ADG","ADR","AF1","AFD","AFL","AFO","AFP","AFR","AGC","AGH","AGL","AHR","AIG","ALL","ALX","AMU","AOG","AOS","ARA","ARB","ARE","ARI","ASG","ASO","AXP","AXR","B0D","B16","B2G","B4G","B6D","B8D","B9D","BBK","BCD","BDG","BDP","BDR","BEM","BFP","BGC","BGL","BGP","BGS","BHG","BMA","BMX","BNG","BNX","BOG","BRI","BXF","BXP","BXX","BXY","C3X","C4X","C5X","CAP","CBI","CBK","CBS","CDR","CEG","CGF","CHO","CR1","CR6","CRA","CT3","CTO","CTR","CTT","D6G","DAF","DAG","DDA","DDB","DDL","DEL","DFR","DFX","DG0","DGC","DGD","DGM","DGS","DIG","DLF","DLG","DMU","DNO","DOM","DP5","DQQ","DQR","DR2","DR3","DR4","DRI","DSR","DT6","DVC","E4P","E5G","EAG","EBG","EBQ","EGA","EJT","EPG","ERE","ERI","F1P","F1X","F6P","FBP","FCA","FCB","FCT","FDP","FDQ","FFC","FIX","FMO","FRU","FSI","FU4","FUB","FUC","FUD","FUL","FXP","G16","G1P","G2F","G3I","G4D","G4S","G6D","G6P","G6S","GAC","GAD","GAL","GC1","GC4","GCD","GCN","GCO","GCS","GCT","GCU","GCV","GCW","GCX","GE1","GFG","GFP","GIV","GL0","GL2","GL5","GL6","GL7","GL9","GLA","GLB","GLC","GLD","GLF","GLG","GLO","GLP","GLS","GLT","GLW","GMH","GN1","GNX","GP1","GP4","GPH","GPM","GQ1","GQ2","GQ4","GS1","GS4","GSA","GSD","GTE","GTH","GTK","GTR","GTZ","GU0","GU1","GU2","GU3","GU4","GU5","GU6","GU8","GU9","GUF","GUP","GUZ","GYP","GYV","H2P","HDL","HMS","HS2","HSD","HSG","HSH","HSJ","HSQ","HSR","HSU","HSX","HSY","HSZ","IAB","IDG","IDR","IDS","IDT","IDU","IDX","IDY","IMK","IN1","IPT","ISL","KBG","KD2","KDA","KDM","KDO","KFN","KO1","KO2","KTU","L6S","LAG","LAI","LAK","LAO","LAT","LB2","LBT","LCN","LDY","LGC","LGU","LM2","LMT","LMU","LOG","LOX","LPK","LSM","LTM","LVZ","LXB","LXZ","M1F","M3M","M6P","M8C","MA1","MA2","MA3","MAB","MAG","MAL","MAN","MAT","MAV","MAW","MBG","MCU","MDA","MDM","MDP","MFA","MFB","MFU","MG5","MGA","MGL","MLB","MMA","MMN","MN0","MRP","MTT","MUG","MVP","MXY","N1L","N9S","NAA","NAG","NBG","NDG","NED","NG1","NG6","NGA","NGB","NGC","NGE","NGF","NGL","NGS","NGY","NHF","NM6","NM9","NTF","NTO","NTP","NXD","NYT","OPG","OPM","ORP","OX2","P3M","P53","P6P","PA5","PNA","PNG","PNW","PRP","PSJ","PSV","PTQ","QDK","QPS","QV4","R1P","R1X","R2B","R5P","RAA","RAE","RAF","RAM","RAO","RAT","RB5","RBL","RCD","RDP","REL","RER","RF5","RG1","RGG","RHA","RIB","RIP","RNS","RNT","ROB","ROR","RPA","RST","RUB","RUU","RZM","S6P","S7P","SA0","SCR","SDD","SF6","SF9","SG4","SG5","SG6","SG7","SGA","SGC","SGD","SGN","SGS","SHB","SHG","SI3","SIO","SOE","SOL","SSG","SUC","SUP","SUS","T6P","T6T","TAG","TCB","TDG","TGK","TGY","TH1","TIA","TM5","TM6","TM9","TMR","TMX","TOA","TOC","TRE","TYV","UCD","UDC","VG1","X0X","X1X","X2F","X4S","X5S","X6X","XBP","XDN","XDP","XIF","XIM","XLF","XLS","XMM","XUL","XXR","XYP","XYS","YO5","Z3Q","Z6J","Z9M","ZDC","ZDM"],nU=["CA","C","N","O","O1","O2","OC1","OC2","OX1","OXT","OT1","OT2","H","H1","H2","H3","HA","HN","BB"],QP=["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*"],Yh={1:{trace:"CA",direction1:"C",direction2:["O","OC1","O1","OX1","OXT","OT1","OT2"],backboneStart:"N",backboneEnd:"C"},2:{trace:["C4'","C4*"],direction1:["C1'","C1*"],direction2:["C3'","C3*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},3:{trace:["C3'","C3*"],direction1:["C2'","C2*"],direction2:["O4'","O4*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},4:{trace:["CA","BB"],backboneStart:["CA","BB"],backboneEnd:["CA","BB"]},5:{trace:["C4'","C4*","P"],backboneStart:["C4'","C4*","P"],backboneEnd:["C4'","C4*","P"]},6:{trace:["C3'","C3*","C2'","P"],backboneStart:["C3'","C3*","C2'","P"],backboneEnd:["C3'","C3*","C2'","P"]}};Yh[rl]={};var nT={HD:"H",HS:"H",A:"C",NA:"N",NS:"N",OA:"O",OS:"O",SA:"S",G0:"C",G1:"C",G2:"C",G3:"C",CG0:"C",CG1:"C",CG2:"C",CG3:"C",W:"O"};function xm(n){switch(n){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;default:return 8}}var iT=new Map([[2,En(180)],[3,En(120)],[4,En(109.4721)],[6,En(90)]]);function bm(n,e){let t=[],i=new W,r=new W;return i.subVectors(e,n),n.eachBondedAtom(s=>{s.number!==1&&(r.subVectors(s,n),t.push(i.angleTo(r)))}),t}function rT(n,e){let t=n.clone(),i=new W;i.subVectors(e,n);let r=[new W,new W],s=0;if(n.eachBondedAtom(a=>{s>1||a.number!==1&&(t.index=a.index,r[s++].subVectors(a,n))}),s===1&&t.eachBondedAtom(a=>{s>1||a.number!==1&&a.index!==n.index&&r[s++].subVectors(a,n)}),s!==2)return;let o=r[0].cross(r[1]);return Math.abs(Math.PI/2-o.angleTo(i))}function iU(n,e){let t=n.structure,i=t.atomCount,r=new Int8Array(i),s=new Int8Array(i),o=new Int8Array(i),a=new Int8Array(i);return t.eachAtom(l=>{let c=l.index,[u,d,f,m]=function(p,_){let y=p.bondToElementCount(1),g=p.formalCharge||0,b=_.assignCharge==="always"||_.assignCharge==="auto"&&g===0,h=_.assignH==="always"||_.assignH==="auto"&&y===0,v=p.bondCount,S=function(T){let R=0;return T.eachBond(C=>R+=C.bondOrder),R}(p),x=function(T){let R=T.structure.getBondProxy(),C=T.number,P=C===8||C===7;if(P&&T.bondCount===4)return!1;let E=!1;return T.eachBond(I=>{if(I.bondOrder>1)E=!0;else if(P){let O=I.getOtherAtom(T);O.eachBond(D=>{if(D.bondOrder>1){let N=O.number;if((N===15||N===16)&&D.getOtherAtom(O).number===8)return;E=!0}},R)}}),E}(p),w=S-v>0,A=0,M=8;switch(p.number){case 1:b&&(v===0?(g=1,M=0):v===1&&(g=0,M=1));break;case 6:b&&(g=0),h&&(A=Math.max(0,4-S-Math.abs(g))),M=xm(v+A+Math.max(0,-g));break;case 7:if(b)if(h)if(x&&S<4)g=v-y==1&&S-y==2?1:0;else{let T=!1;p.eachBondedAtom(R=>{(R.number===16||R.isMetal())&&(T=!0)}),g=T?0:1}else g=S-3;h&&(A=Math.max(0,3-S+g)),M=xm(x&&!w?v+A-g:v+A+1-g);break;case 8:b&&(h||(g=S-2),S===1&&p.eachBondedAtom(T=>{T.eachBond(R=>{let C=R.getOtherAtom(T);C.index!==p.index&&C.number===8&&R.bondOrder===2&&(g=-1)})})),h&&(A=Math.max(0,2-S+g)),M=xm(x&&!w?v+A-g+1:v+A-g+2);break;case 16:b&&(h||(g=S<=3&&!p.bondToElementCount(8)?S-2:0)),h&&S<2&&(A=Math.max(0,2-S+g)),S<=3&&(M=xm(v+A-g+2));break;case 9:case 17:case 35:case 53:case 85:b&&(g=S-1);break;case 3:case 11:case 19:case 37:case 55:case 87:b&&(g=1-S);break;case 4:case 12:case 20:case 38:case 56:case 88:b&&(g=2-S);break;default:console.warn("Requested charge, protonation for an unhandled element",p.element)}return[g,A,A+y,M]}(l,e);r[c]=u,s[c]=d,o[c]=f,a[c]=m}),{charge:r,implicitH:s,totalH:o,idealGeometry:a}}function Ec(n){if(n["@valenceModel"])return n["@valenceModel"];let e=iU(n,{assignCharge:"auto",assignH:"auto"});return n["@valenceModel"]=e,e}function sT(n){return n.number===15&&n.bondToElementCount(8)===n.bondCount}var rU=["ARG","HIS","LYS"],sU=["GLU","ASP"];function oU(n,e){return n===2&&e===1||n===1&&e===2}function aU(n,e){return n===3&&e===3}function lU(n,e){return n===3&&e===1||n===1&&e===3}function oT(n){return n.resname==="HIS"&&n.number==7&&n.isRing()}function cU(n,e){return n===5&&e===4||n===4&&e===5}function uU(n,e){return n===9&&e===5||n===5&&e===9}var hU=[3,11,19,37,55,12,20,38,56,13,31,49,81,21,50,82,83,51,80];function dU(n,e){return n===12?e===11||e===12:n===13?e===10:void 0}var fU=[17,35,53,85],pU=[7,8,16],mU=[6,7,15,16],gU=En(180),yU=En(120);function aT(n,e,t){return!eI(n,e,t)&&(n.modelIndex!==e.modelIndex||n.altloc&&e.altloc&&n.altloc!==e.altloc)}var yn={maxHydrophobicDist:4,maxHbondDist:3.5,maxHbondSulfurDist:4.1,maxHbondAccAngle:45,maxHbondDonAngle:45,maxHbondAccPlaneAngle:90,maxHbondDonPlaneAngle:30,maxPiStackingDist:5.5,maxPiStackingOffset:2,maxPiStackingAngle:30,maxCationPiDist:6,maxCationPiOffset:2,maxIonicDist:5,maxHalogenBondDist:4,maxHalogenBondAngle:30,maxMetalDist:3,refineSaltBridges:!0,masterModelIndex:-1,lineOfSightDistFactor:1};function eI(n,e,t){return n.modelIndex===t&&e.modelIndex!==t||e.modelIndex===t&&n.modelIndex!==t}function Bh(n,e,t){return!eI(n,e,t)&&(n.modelIndex!==e.modelIndex||n.residueIndex===e.residueIndex||n.altloc&&e.altloc&&n.altloc!==e.altloc)}function _U(n){let e={types:[],groups:[],centers:{x:[],y:[],z:[]},atomSets:[]};return Le&&we.time("calculateFeatures"),function(t,i){let{charge:r}=Ec(t.data),s={};t.eachResidue(o=>{if(rU.includes(o.resname)){let a=ni(1);o.eachAtom(l=>{l.number===7&&l.isSidechain()&&Fn(a,l)}),On(i,a)}else Fc.includes(o.resname)||o.isNucleic()||(o.eachAtom(a=>{let l=!1,c=ni(1);(function(u){let d=0;return u.number===6&&u.bondCount===3&&u.bondToElementCount(7)===3&&u.eachBondedAtom(f=>{f.bondCount-f.bondToElementCount(1)==1&&++d}),d===2})(a)?(c.group=8,l=!0):function(u){let d=0;return u.number===6&&u.bondCount===3&&u.bondToElementCount(7)===2&&u.bondToElementCount(6)===1&&u.eachBondedAtom(f=>{f.bondCount-f.bondToElementCount(1)==1&&++d}),d===2}(a)&&(c.group=9,l=!0),l&&(a.eachBondedAtom(u=>{u.number===7&&(s[u.index]=!0,Fn(c,u))}),On(i,c))}),o.eachAtom(a=>{let l=ni(1);r[a.index]>0&&(s[a.index]||(Fn(l,a),On(i,l)))}))})}(n,e),function(t,i){let{charge:r}=Ec(t.data),s={};t.eachResidue(o=>{if(sU.includes(o.resname)){let a=ni(2);o.eachAtom(l=>{l.number===8&&l.isSidechain()&&Fn(a,l)}),On(i,a)}else if(nd.includes(o.resname)){let a=ni(2);o.eachAtom(l=>{sT(l)&&(a.group=6,l.eachBondedAtom(c=>{c.number===8&&Fn(a,c)}),On(i,a))})}else Fc.includes(o.resname)||nd.includes(o.resname)||(o.eachAtom(a=>{let l=!1,c=ni(2);(function(u){return u.number===16&&u.bondToElementCount(8)===3})(a)?(c.group=4,l=!0):sT(a)?(c.group=6,l=!0):function(u){return u.number===16&&u.bondToElementCount(8)===4}(a)?(c.group=5,l=!0):function(u){let d=0;return u.number===6&&u.bondToElementCount(8)===2&&u.bondToElementCount(6)===1&&u.eachBondedAtom(f=>{f.number===8&&f.bondCount-f.bondToElementCount(1)==1&&++d}),d===2}(a)&&(c.group=10,l=!0),l&&(a.eachBondedAtom(u=>{u.number===8&&(s[u.index]=!0,Fn(c,u))}),On(i,c))}),o.eachAtom(a=>{let l=ni(2);r[a.index]<0&&(s[a.index]||(Fn(l,a),On(i,l)))}))})}(n,e),function(t,i){let r=t.getAtomProxy();t.eachResidue(s=>{let o=s.getAromaticRings();if(o){let a=s.atomOffset;o.forEach(l=>{let c=ni(3);l.forEach(u=>{r.index=u+a,Fn(c,r)}),On(i,c)})}})}(n,e),function(t,i){let{charge:r,implicitH:s,idealGeometry:o}=Ec(t.data);t.eachAtom(a=>{let l=ni(5),c=a.number;if(c===8)Fn(l,a),On(i,l);else if(c===7){if(oT(a))Fn(l,a),On(i,l);else if(r[a.index]<1){let u=a.bondCount+s[a.index],d=o[a.index];(d===4&&u<4||d===3&&u<3||d===2&&u<2)&&(Fn(l,a),On(i,l))}}else c===16&&(a.resname!=="CYS"&&a.resname!=="MET"&&a.formalCharge!==-1||(Fn(l,a),On(i,l)))})}(n,e),function(t,i){let{totalH:r}=Ec(t.data);t.eachAtom(s=>{let o=ni(4),a=s.number;(oT(s)||r[s.index]>0&&(a===7||a===8||a===16))&&(Fn(o,s),On(i,o))})}(n,e),function(t,i){let{totalH:r}=Ec(t.data);t.eachAtom(s=>{if(s.number===6&&r[s.index]>0&&(s.bondToElementCount(7)>0||s.bondToElementCount(8)>0||function(o){if(!o.isAromatic())return!1;let a=o.residueType.getRings();if(!a)return!1;let l=!1;return a.rings.forEach(c=>{l||c.some(u=>o.index-o.residueAtomOffset===u)&&(l=c.some(u=>{let d=o.residueType.atomTypeIdList[u],f=o.atomMap.get(d).number;return f===7||f===8}))}),l}(s))){let o=ni(9);Fn(o,s),On(i,o)}})}(n,e),function(t,i){t.eachAtom(r=>{let s=!1,o=!1,a=Fc.includes(r.resname),l=nd.includes(r.resname);if(a||l?a?r.number===8?(["ASP","GLU","SER","THR","TYR","ASN","GLN"].includes(r.resname)&&r.isSidechain()||r.isBackbone())&&(s=!0,o=!0):r.number===16&&r.resname==="CYS"?(s=!0,o=!0):r.number===7&&r.resname==="HIS"&&r.isSidechain()&&(s=!0):l&&(r.number===8&&r.isBackbone()?(s=!0,o=!0):["N3","N4","N7"].includes(r.atomname)?s=!0:["O2","O4","O6"].includes(r.atomname)&&(s=!0,o=!0)):r.isHalogen()||r.number===8||r.number===16?(s=!0,o=!0):r.number===7&&(s=!0),s){let c=ni(11);Fn(c,r),On(i,c)}if(o){let c=ni(10);Fn(c,r),On(i,c)}})}(n,e),function(t,i){t.eachAtom(r=>{if(r.isTransitionMetal()||r.number===30||r.number===48){let s=ni(12);Fn(s,r),On(i,s)}else if(hU.includes(r.number)){let s=ni(13);Fn(s,r),On(i,s)}})}(n,e),function(t,i){t.eachAtom(r=>{let s=ni(8),o=!1;r.number===6?(o=!0,r.eachBondedAtom(a=>{let l=a.number;l!==6&&l!==1&&(o=!1)})):r.number===9&&(o=!0),o&&(Fn(s,r),On(i,s))})}(n,e),function(t,i){t.eachAtom(r=>{if(pU.includes(r.number)){let s=!1;if(r.eachBondedAtom(o=>{mU.includes(o.number)&&(s=!0)}),s){let o=ni(7);Fn(o,r),On(i,o)}}})}(n,e),function(t,i){t.eachAtom(r=>{if(fU.includes(r.number)&&r.bondToElementCount(6)===1){let s=ni(6);Fn(s,r),On(i,s)}})}(n,e),Le&&we.timeEnd("calculateFeatures"),e}function vU(n,e=yn){let t=function(r){let{types:s,centers:o}=r;return{features:r,spatialHash:new il(o),contactStore:new lb,featureSet:new ii(s.length,!1)}}(_U(n));Le&&we.time("calculateContacts"),function(r,s,o={}){let a=U(o.maxIonicDist,yn.maxIonicDist),l=U(o.maxPiStackingDist,yn.maxPiStackingDist),c=U(o.maxPiStackingOffset,yn.maxPiStackingOffset),u=U(o.maxPiStackingAngle,yn.maxPiStackingAngle),d=U(o.maxCationPiDist,yn.maxCationPiDist),f=U(o.maxCationPiOffset,yn.maxCationPiOffset),m=U(o.masterModelIndex,yn.masterModelIndex),p=Math.max(a+2,l,d),_=l*l,y=d*d,{features:g,spatialHash:b,contactStore:h,featureSet:v}=s,{types:S,centers:x,atomSets:w}=g,{x:A,y:M,z:T}=x,R=S.length,C=r.atomStore.x,P=r.atomStore.y,E=r.atomStore.z,I=r.getAtomProxy(),O=r.getAtomProxy(),D=function(X,se,ne){let oe=X.length,ee=se.length;for(let le=0;le{if(se<=X||(I.index=w[X][0],O.index=w[se][0],Bh(I,O,m)))return;let oe=S[X],ee=S[se];if(oU(oe,ee))D(w[X],w[se],a)&&re(X,se,1);else if(aU(oe,ee)){if(ne<=_){Z(w[X],te),Z(w[se],Q);let le=57.29578*te.angleTo(Q);Math.min(J(X,se,Q),J(se,X,te))<=c&&(le<=u||le>=180-u||le<=u+90&&le>=90-u)&&re(X,se,3)}}else if(lU(oe,ee)&&ne<=y){let[le,xe]=oe===3?[X,se]:[se,X];Z(w[le],te),J(xe,le,te)<=f&&re(le,xe,2)}})}(n,t,e),function(r,s,o={}){let a=U(o.maxHbondDist,yn.maxHbondDist),l=U(o.maxHbondSulfurDist,yn.maxHbondSulfurDist),c=En(U(o.maxHbondAccAngle,yn.maxHbondAccAngle)),u=En(U(o.maxHbondDonAngle,yn.maxHbondDonAngle)),d=En(U(o.maxHbondAccPlaneAngle,yn.maxHbondAccPlaneAngle)),f=En(U(o.maxHbondDonPlaneAngle,yn.maxHbondDonPlaneAngle)),m=U(o.masterModelIndex,yn.masterModelIndex),p=Math.max(a,l),_=a*a,{features:y,spatialHash:g,contactStore:b,featureSet:h}=s,{types:v,centers:S,atomSets:x}=y,{x:w,y:A,z:M}=S,T=v.length,{idealGeometry:R}=Ec(r.data),C=r.getAtomProxy(),P=r.getAtomProxy();for(let E=0;E{if(I<=E)return;let D=v[E],N=v[I],H=uU(D,N);if(!H&&!cU(D,N))return;let[z,L]=N===5?[E,I]:[I,E];if(C.index=x[z][0],P.index=x[L][0],P.index===C.index||Bh(C,P,m)||C.number!==16&&P.number!==16&&O>_||C.connectedTo(P))return;let F=bm(C,P),te=iT.get(R[C.index])||En(120);if(F.some(se=>Math.abs(te-se)>u))return;if(R[C.index]===3){let se=rT(C,P);if(se!==void 0&&se>f)return}let Q=bm(P,C),Z=iT.get(R[P.index])||En(120);if(Q.some(se=>Z-se>c))return;if(R[P.index]===3){let se=rT(P,C);if(se!==void 0&&se>d)return}h.setBits(z,L);let J=H?8:function(se,ne){return se.isWater()&&ne.isWater()}(re=C,X=P)?9:function(se,ne){return se.isBackbone()&&ne.isBackbone()}(re,X)?10:4;var re,X;b.addContact(z,L,J)})}(n,t,e),function(r,s,o={}){let a=U(o.maxMetalDist,yn.maxMetalDist),l=U(o.masterModelIndex,yn.masterModelIndex),{features:c,spatialHash:u,contactStore:d,featureSet:f}=s,{types:m,centers:p,atomSets:_}=c,{x:y,y:g,z:b}=p,h=m.length,v=r.getAtomProxy(),S=r.getAtomProxy();for(let x=0;x{if(w<=x||(v.index=_[x][0],S.index=_[w][0],Bh(v,S,l)))return;let M=v.isMetal(),T=S.isMetal();if(!M&&!T)return;let[R,C]=M?[m[x],m[w]]:[m[w],m[x]];dU(R,C)&&(f.setBits(x,w),d.addContact(x,w,7))})}(n,t,e),function(r,s,o={}){let a=U(o.maxHydrophobicDist,yn.maxHydrophobicDist),l=U(o.masterModelIndex,yn.masterModelIndex),{features:c,spatialHash:u,contactStore:d,featureSet:f}=s,{types:m,centers:p,atomSets:_}=c,{x:y,y:g,z:b}=p,h=m.length,v=r.getAtomProxy(),S=r.getAtomProxy();for(let x=0;x{var M,T;w<=x||(v.index=_[x][0],S.index=_[w][0],Bh(v,S,l)||v.number===9&&S.number===9||v.connectedTo(S)||(M=m[x],T=m[w],M===8&&T===8&&(f.setBits(x,w),d.addContact(x,w,6))))})}(n,t,e),function(r,s,o={}){let a=U(o.maxHalogenBondDist,yn.maxHalogenBondDist),l=En(U(o.maxHalogenBondAngle,yn.maxHalogenBondAngle)),c=U(o.masterModelIndex,yn.masterModelIndex),{features:u,spatialHash:d,contactStore:f,featureSet:m}=s,{types:p,centers:_,atomSets:y}=u,{x:g,y:b,z:h}=_,v=p.length,S=r.getAtomProxy(),x=r.getAtomProxy();for(let w=0;w{if(A<=w||(S.index=y[w][0],x.index=y[A][0],Bh(S,x,c))||(T=p[w],R=p[A],!(T===7&&R===6||T===6&&R===7)))return;var T,R;let[C,P]=p[w]===6?[S,x]:[x,S],E=bm(C,P);if(E.length!==1||gU-E[0]>l)return;let I=bm(P,C);I.length!==0&&(I.some(O=>yU-O>l)||(m.setBits(w,A),f.addContact(w,A,5)))})}(n,t,e);let i=function(r){let{index1:s,index2:o,count:a}=r.contactStore,l=WP({nodeArray1:s,nodeArray2:o,edgeCount:a,nodeCount:r.featureSet.length}),c=new ii(r.contactStore.count,!0);return Object.assign({adjacencyList:l,contactSet:c},r)}(t);return function(r,s,o={}){Le&&we.time("refineLineOfSight");let a=U(o.lineOfSightDistFactor,yn.lineOfSightDistFactor),l=U(o.masterModelIndex,yn.masterModelIndex),c=r.spatialHash,{contactSet:u,contactStore:d,features:f}=s,{index1:m,index2:p}=d,{centers:_,atomSets:y}=f,{x:g,y:b,z:h}=_,v=r.getAtomProxy(),S=r.getAtomProxy(),x=r.getAtomProxy(),w=new W,A=new W,M=3*a,T=a*a;u.forEach(R=>{w.set(g[m[R]],b[m[R]],h[m[R]]),A.set(g[p[R]],b[p[R]],h[p[R]]);let C=(w.x+A.x)/2,P=(w.y+A.y)/2,E=(w.z+A.z)/2,I=y[m[R]],O=y[p[R]];v.index=I[0],S.index=O[0],c.eachWithin(C,P,E,M,(D,N)=>{x.index=D,x.number!==1&&x.vdw*x.vdw*T>N&&!aT(v,x,l)&&!aT(S,x,l)&&!I.includes(D)&&!O.includes(D)&&w.distanceToSquared(x)>1&&A.distanceToSquared(x)>1&&(u.clear(R),Le&&we.log("removing",v.qualifiedName(),S.qualifiedName(),"because",x.qualifiedName()))})}),Le&&we.timeEnd("refineLineOfSight")}(n,i,e),function(r,s){let{contactSet:o,contactStore:a,features:l}=s,{type:c,index1:u,index2:d}=a,{atomSets:f}=l,m=r.getAtomProxy(),p=r.getAtomProxy(),_={},y=function(g,b,h){let[v,S]=_[h]||[1/0,-1];g{if(c[g]!==6)return;m.index=f[u[g]][0],p.index=f[d[g]][0];let b=m.distanceTo(p);y(b,g,`${m.index}|${p.residueIndex}`),y(b,g,`${p.index}|${m.residueIndex}`)})}(n,i),e.refineSaltBridges&&function(r,s){let{contactSet:o,contactStore:a,features:l}=s,{type:c,index1:u,index2:d}=a,{atomSets:f}=l,m={},p=function(_,y){m[_]||(m[_]=[]),m[_].push(y)};o.forEach(_=>{c[_]===1&&(f[u[_]].forEach(y=>p(y,_)),f[d[_]].forEach(y=>p(y,_)))}),o.forEach(_=>{if(!function(h){return h===4||h===9||h===10}(c[_]))return;let y=m[f[u[_]][0]],g=m[f[d[_]][0]];if(!y||!g)return;let b=y.length;for(let h=0;h{c[_]===3&&(f[u[_]].forEach(y=>p(y,_)),f[d[_]].forEach(y=>p(y,_)))}),o.forEach(_=>{if(c[_]!==6&&c[_]!==2)return;let y=m[f[u[_]][0]],g=m[f[d[_]][0]];if(!y||!g)return;let b=y.length;for(let h=0;h{c[_]===1&&(f[u[_]].forEach(y=>p(y,_)),f[d[_]].forEach(y=>p(y,_)))}),o.forEach(_=>{if(c[_]!==7)return;let y=m[f[u[_]][0]],g=m[f[d[_]][0]];if(!y||!g)return;let b=y.length;for(let h=0;he.getAtomSet(new tn(x))):e.getAtomSet(new tn(i.filterSele))),o.forEach(x=>{let w=_[x];if(!r.includes(w))return;if(S){let T=c[m[x]][0],R=c[p[x]][0];if(Array.isArray(S)){if(!(S[0].isSet(T)&&S[1].isSet(R)||S[1].isSet(T)&&S[0].isSet(R)))return}else if(!S.isSet(T)&&!S.isSet(R))return}let A=m[x],M=p[x];y.push(u[A],d[A],f[A]),g.push(u[M],d[M],f[M]),b.push(...function(T){switch(T){case 4:case 9:case 10:return Ys.setHex(2851770).toArray();case 6:return Ys.setHex(8421504).toArray();case 5:return Ys.setHex(4259775).toArray();case 1:return Ys.setHex(15779860).toArray();case 7:return Ys.setHex(9191577).toArray();case 2:return Ys.setHex(16744448).toArray();case 3:return Ys.setHex(9220966).toArray();case 8:return Ys.setHex(12967404).toArray();default:return Ys.setHex(13421772).toArray()}}(w)),h.push(i.radius),v.push(x)}),{position1:new Float32Array(y),position2:new Float32Array(g),color:new Float32Array(b),color2:new Float32Array(b),radius:new Float32Array(h),picking:new ub(v,n,e)}}var Tr=class{constructor(e){this.array=e}get type(){return""}get data(){return{}}getIndex(e){return this.array?this.array[e]:e}getObject(e){return{}}_applyTransformations(e,t,i){return t&&e.applyMatrix4(t.matrix),i&&e.applyMatrix4(i.matrix),e}_getPosition(e){return new W}getPosition(e,t,i){return this._applyTransformations(this._getPosition(e),t,i)}},zi=class extends Tr{constructor(e){super(),this.shape=e}get primitive(){}get data(){return this.shape}get type(){return this.primitive.type}getObject(e){return this.primitive.objectFromShape(this.shape,this.getIndex(e))}_getPosition(e){return this.primitive.positionFromShape(this.shape,this.getIndex(e))}},oo=class extends Tr{constructor(e,t){super(e),this.structure=t}get type(){return"atom"}get data(){return this.structure}getObject(e){return this.structure.getAtomProxy(this.getIndex(e))}_getPosition(e){return new W().copy(this.getObject(e))}},cb=class extends Tr{constructor(e){super(),this.axes=e}get type(){return"axes"}get data(){return this.axes}getObject(){return{axes:this.axes}}_getPosition(){return this.axes.center.clone()}},fg=class extends Tr{constructor(e,t,i){super(e),this.structure=t,this.bondStore=i||t.bondStore}get type(){return"bond"}get data(){return this.structure}getObject(e){let t=this.structure.getBondProxy(this.getIndex(e));return t.bondStore=this.bondStore,t}_getPosition(e){let t=this.getObject(e);return new W().copy(t.atom1).add(t.atom2).multiplyScalar(.5)}},ub=class extends Tr{constructor(e,t,i){super(e),this.contacts=t,this.structure=i}get type(){return"contact"}get data(){return this.contacts}getObject(e){let t=this.getIndex(e),{features:i,contactStore:r}=this.contacts,{centers:s,atomSets:o}=i,{x:a,y:l,z:c}=s,{index1:u,index2:d,type:f}=r,m=u[t],p=d[t];return{center1:new W(a[m],l[m],c[m]),center2:new W(a[p],l[p],c[p]),atom1:this.structure.getAtomProxy(o[m][0]),atom2:this.structure.getAtomProxy(o[p][0]),type:xU(f[t])}}_getPosition(e){let{center1:t,center2:i}=this.getObject(e);return new W().addVectors(t,i).multiplyScalar(.5)}},hb=class extends Tr{constructor(e,t,i){super(e),this.validation=t,this.structure=i}get type(){return"clash"}get data(){return this.validation}getObject(e){let t=this.validation,i=this.getIndex(e);return{validation:t,index:i,clash:t.clashArray[i]}}_getAtomProxyFromSele(e){let t=new tn(e),i=this.structure.getAtomIndices(t)[0];return this.structure.getAtomProxy(i)}_getPosition(e){let t=this.getObject(e).clash,i=this._getAtomProxyFromSele(t.sele1),r=this._getAtomProxyFromSele(t.sele2);return new W().copy(i).add(r).multiplyScalar(.5)}},db=class extends fg{get type(){return"distance"}},fb=class extends Tr{get type(){return"ignore"}},pb=class extends zi{constructor(e,t){super(e),this.mesh=t}get type(){return"mesh"}getObject(){let e=this.mesh;return{shape:this.shape,name:e.name,serial:e.serial}}_getPosition(){return this.__position||(this.__position=sb(this.mesh.position)),this.__position}},mb=class extends Tr{constructor(e,t){super(e),this.surface=t}get type(){return"surface"}get data(){return this.surface}getObject(e){return{surface:this.surface,index:this.getIndex(e)}}_getPosition(){return this.surface.center.clone()}},gb=class extends Tr{constructor(e,t){super(),this.unitcell=e,this.structure=t}get type(){return"unitcell"}get data(){return this.unitcell}getObject(){return{unitcell:this.unitcell,structure:this.structure}}_getPosition(){return this.unitcell.getCenter(this.structure)}},pg=class extends Tr{constructor(e,t){super(e),this.volume=t}get type(){return"volume"}get data(){return this.volume}getObject(e){let t=this.volume,i=this.getIndex(e);return{volume:t,index:i,value:t.data[i]}}_getPosition(e){let t=this.volume.position,i=this.getIndex(e);return new W(t[3*i],t[3*i+1],t[3*i+2])}},yb=class extends pg{get type(){return"slice"}};function tI(){return new Uint32Array([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])}function nI(){return new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])}function Aw(n,e,t,i,r){var s,o,a,l,c,u,d,f=[[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]],m=0,p=!1,_=!1,y=!1,g=!1,b=-1,h=e*t*i,v=e,S=e*t,x=new Int32Array(12),w=[],A=[],M=[],T=[],R=tI(),C=nI();function P(L,F,te){return L+(F-L)*te}function E(L,F,te){return S*(te=(te+d)%i)+v*(F=(F+u)%t)+(L=(L+c)%e)}function I(L,F,te,Q,Z,J,re){var X=3*L;if(o[X]<0){var se=(m-J)/(re-J),ne=s,oe=3*a;if(w[oe]=te+se,w[oe+1]=Q,w[oe+2]=Z,!p){var ee=3*L;A[oe]=b*P(ne[ee],ne[ee+3],se),A[oe+1]=b*P(ne[ee+1],ne[ee+4],se),A[oe+2]=b*P(ne[ee+2],ne[ee+5],se)}r&&(T[a]=r[L+Math.round(se)]),o[X]=a,x[F]=a,a+=1}else x[F]=o[X]}function O(L,F,te,Q,Z,J,re){var X=3*L+1;if(o[X]<0){var se=(m-J)/(re-J),ne=s,oe=3*a;if(w[oe]=te,w[oe+1]=Q+se,w[oe+2]=Z,!p){var ee=3*L,le=ee+3*v;A[oe]=b*P(ne[ee],ne[le],se),A[oe+1]=b*P(ne[ee+1],ne[le+1],se),A[oe+2]=b*P(ne[ee+2],ne[le+2],se)}r&&(T[a]=r[L+Math.round(se)*v]),o[X]=a,x[F]=a,a+=1}else x[F]=o[X]}function D(L,F,te,Q,Z,J,re){var X=3*L+2;if(o[X]<0){var se=(m-J)/(re-J),ne=s,oe=3*a;if(w[oe]=te,w[oe+1]=Q,w[oe+2]=Z+se,!p){var ee=3*L,le=ee+3*S;A[oe]=b*P(ne[ee],ne[le],se),A[oe+1]=b*P(ne[ee+1],ne[le+1],se),A[oe+2]=b*P(ne[ee+2],ne[le+2],se)}r&&(T[a]=r[L+Math.round(se)*S]),o[X]=a,x[F]=a,a+=1}else x[F]=o[X]}function N(L){var F=3*L;s[F]===0&&(s[F]=n[(L-1+h)%h]-n[(L+1)%h],s[F+1]=n[(L-v+h)%h]-n[(L+v)%h],s[F+2]=n[(L-S+h)%h]-n[(L+S)%h])}function H(L,F,te,Q,Z){var J,re,X,se,ne,oe,ee;y?(Q=E(L,F,te),J=E(L+1,F,te),re=E(L,F+1,te),X=E(L,F,te+1),se=E(L+1,F+1,te),ne=E(L+1,F,te+1),oe=E(L,F+1,te+1),ee=E(L+1,F+1,te+1)):(J=Q+1,se=(re=Q+v)+1,ne=(X=Q+S)+1,ee=(oe=re+S)+1);var le=0,xe=n[Q],Se=n[J],Re=n[re],ke=n[se],$e=n[X],_e=n[ne],Ie=n[oe],We=n[ee];xe=m){Y=oe,Ie=!0;break}if(Ie)break}if(Ie)break}for(Ie=!1,ne=F;ne=m){Fe=ne,Ie=!0;break}if(Ie)break}if(Ie)break}for(Ie=!1,se=L;se=m){We=se,Ie=!0;break}if(Ie)break}if(Ie)break}for(Ie=!1,oe=J;oe>=te;--oe){for(ne=Z;ne>=F;--ne){for(se=Q;se>=L;--se)if(re=e*t*oe+e*ne+se,n[re]>=m){Te=oe,Ie=!0;break}if(Ie)break}if(Ie)break}for(Ie=!1,ne=Z;ne>=F;--ne){for(oe=Te;oe>=te;--oe){for(se=Q;se>=L;--se)if(re=e*t*oe+e*ne+se,n[re]>=m){de=ne,Ie=!0;break}if(Ie)break}if(Ie)break}for(Ie=!1,se=Q;se>=L;--se){for(ne=de;ne>=F;--ne){for(oe=Te;oe>=te;--oe)if(re=e*t*oe+e*ne+se,n[re]>=m){$=se,Ie=!0;break}if(Ie)break}if(Ie)break}p?(L=Math.max(0,We-1),F=Math.max(0,Fe-1),te=Math.max(0,Y-1),Q=Math.min(e-1,$+1),Z=Math.min(t-1,de+1),J=Math.min(i-1,Te+1)):(L=Math.max(1,We-1),F=Math.max(1,Fe-1),te=Math.max(1,Y-1),Q=Math.min(e-2,$+1),Z=Math.min(t-2,de+1),J=Math.min(i-2,Te+1))}var fe=15;for(oe=te;oe0?-1:1,s||(s=new Float32Array(3*h)));var J=3*h;if(o&&o.length===J||(o=new Int32Array(J)),a=0,l=0,te!==void 0){var re=te[0].map(Math.round),X=te[1].map(Math.round);c=e*Math.ceil(Math.abs(re[0])/e),u=t*Math.ceil(Math.abs(re[1])/t),d=i*Math.ceil(Math.abs(re[2])/i),z(re[0],re[1],re[2],X[0],X[1],X[2])}else c=u=d=0,z();return w.length=3*a,p||(A.length=3*a),M.length=l,r&&(T.length=a),{position:new Float32Array(w),normal:p?void 0:new Float32Array(A),index:bs(M,w.length/3),atomindex:r?new Int32Array(T):void 0,contour:_}}}Mr.add("arrow",class extends zi{get primitive(){return jc}}),Mr.add("box",class extends zi{get primitive(){return ro}}),Mr.add("cone",class extends zi{get primitive(){return Xc}}),Mr.add("cylinder",class extends zi{get primitive(){return so}}),Mr.add("ellipsoid",class extends zi{get primitive(){return ra}}),Mr.add("octahedron",class extends zi{get primitive(){return $c}}),Mr.add("sphere",class extends zi{get primitive(){return ia}}),Mr.add("tetrahedron",class extends zi{get primitive(){return Wc}}),Mr.add("torus",class extends zi{get primitive(){return qc}}),Mr.add("point",class extends zi{get primitive(){return tl}}),Mr.add("wideline",class extends zi{get primitive(){return nl}}),Object.assign(Aw,{__deps:[tI,nI,bs]});var Ht=class{constructor(e,t){this.cols=e,this.rows=t,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)}copyTo(e){e.data.set(this.data)}};function Kr(n,e){let t=0,i=0,r=e.rows,s=e.cols,o=0,a=0,l=0,c=e.data,u=n.data;for(;t(e=Math.abs(e))?(e/=n,n*Math.sqrt(1+e*e)):e>0?(n/=e,e*Math.sqrt(1+n*n)):0}var AU=1192092896e-16,MU=1e-37;function iI(n,e,t,i){let r=0,s=0,o=n.rows,a=n.cols,l=o,c=a;l>16?oe:-oe,m[w*p+M]=ne;for(T=0;T<2;T++)for(A=0;A{let d=u.data.sd,f=u.data.p;a(this._makeSurface(d,f.isolevel,f.smooth))},u=>{console.warn("Volume.getSurfaceWorker error - trying without worker",u);let d=this.getSurface(e,t,i,r,s,o);a(d)})}else{let l=this.getSurface(e,t,i,r,s,o);a(l)}}getValueForSigma(e){return this.mean+U(e,2)*this.rms}getSigmaForValue(e){return(U(e,0)-this.mean)/this.rms}get position(){if(!this._position){let e=this.nz,t=this.ny,i=this.nx,r=new Float32Array(i*t*e*3),s=0;for(let o=0;oo){let l=s;s=o,o=l}let a=e[s];return a===void 0?(e[s]=[o],!0):!a.includes(o)&&(a.push(o),!0)}let i=this.geometry,r=i.index;if(this.parameters.wireframe)if(r){let s=r.array,o,a=s.length;i.drawRange.count!==1/0&&(a=i.drawRange.count),this.wireframeIndex&&this.wireframeIndex.length>2*a?o=this.wireframeIndex:o=bs(2*a,i.attributes.position.count);let l=0;e.length=0;for(let c=0;c2*s?this.wireframeIndex:bs(2*s,s);for(let a=0,l=0;athis.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new gn(this.wireframeIndex,1).setUsage(this.dynamic?Ha:qs));else{let e=this.wireframeGeometry.getIndex();if(!e)return void we.error("Index is null");e.set(this.wireframeIndex),e.needsUpdate=this.wireframeIndexCount>0,e.updateRange.count=this.wireframeIndexCount}this.wireframeGeometry.setDrawRange(0,this.wireframeIndexCount)}}getRenderOrder(){let e=0;return this.isText?e=1:this.transparent&&(e=this.isSurface?3:2),e}_getMesh(e){this.material||this.makeMaterial();let t=this.geometry,i=this[e],r;return r=this.isLine?new mc(t,i):this.isPoint?new Ch(t,i):new er(t,i),r.frustumCulled=!1,r.renderOrder=this.getRenderOrder(),r}getMesh(){return this._getMesh("material")}getWireframeMesh(){let e;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),e=new mc(this.wireframeGeometry,this.wireframeMaterial),e.frustumCulled=!1,e.renderOrder=this.getRenderOrder(),e}getPickingMesh(){return this._getMesh("pickingMaterial")}getShader(e,t){return Xh(e,this.getDefines(t))}getVertexShader(e){return this.getShader(this.vertexShader,e)}getFragmentShader(e){return this.getShader(this.fragmentShader,e)}getDefines(e){let t={};return this.parameters.clipNear&&(t.NEAR_CLIP=1),this.parameters.clipRadius&&(t.RADIUS_CLIP=1),e==="picking"?t.PICKING=1:((e==="background"||this.parameters.background)&&(t.NOLIGHT=1),this.parameters.flatShaded&&(t.FLAT_SHADED=1),this.parameters.opaqueBack&&(t.OPAQUE_BACK=1),this.parameters.diffuseInterior&&(t.DIFFUSE_INTERIOR=1),this.parameters.useInteriorColor&&(t.USE_INTERIOR_COLOR=1)),t}getParameters(){return this.parameters}addUniforms(e){this.uniforms=Lh.merge([this.uniforms,e]),this.pickingUniforms=Lh.merge([this.pickingUniforms,e])}addAttributes(e){for(let t in e){let i,r=e[t],s=this.attributeSize*cT[r.type];r.value?(s!==r.value.length&&we.error("attribute value has wrong length",t),i=r.value):i=kP("float32",s),this.geometry.setAttribute(t,new gn(i,cT[r.type]).setUsage(this.dynamic?Ha:qs))}}updateRenderOrder(){let e=this.getRenderOrder();function t(i){i.renderOrder=e}this.group.children.forEach(t),this.pickingGroup&&this.pickingGroup.children.forEach(t)}updateShader(){let e=this.material,t=this.wireframeMaterial,i=this.pickingMaterial;e.vertexShader=this.getVertexShader(),e.fragmentShader=this.getFragmentShader(),e.needsUpdate=!0,t.vertexShader=this.getShader("Line.vert"),t.fragmentShader=this.getShader("Line.frag"),t.needsUpdate=!0,i.vertexShader=this.getVertexShader("picking"),i.fragmentShader=this.getFragmentShader("picking"),i.needsUpdate=!0}setParameters(e){let t=e,i=this.parameterTypes,r=this.parameters,s={},o={},a=!1,l=!1;for(let c in t){let u=t[c];u!==void 0&&(r[c]=u,i[c]!==void 0&&(i[c].property&&(i[c].property!==!0?s[i[c].property]=u:s[c]=u),i[c].uniform&&(i[c].uniform!==!0?o[i[c].uniform]=u:o[c]=u),i[c].updateShader&&(a=!0),i[c].updateVisibility&&(l=!0),this.dynamic&&c==="wireframe"&&u===!0&&this.updateWireframeIndex(),c==="forceTransparent"&&(s.transparent=this.transparent),c==="matrix"&&(this.matrix=u)))}this.setProperties(s),this.setUniforms(o),a&&this.updateShader(),l&&this.setVisibility(this.visible)}setAttributes(e){let t=this.geometry,i=t.attributes;for(let r in e){if(r==="picking")continue;let s=e[r],o=s.length;if(r==="index"){let a=t.getIndex();if(!a){we.error("Index is null");continue}t.setDrawRange(0,1/0),o>a.array.length?t.setIndex(new gn(s,1).setUsage(this.dynamic?Ha:qs)):(a.set(s),a.needsUpdate=o>0,a.updateRange.count=o,t.setDrawRange(0,o)),this.indexVersion++,this.parameters.wireframe&&this.updateWireframeIndex()}else{let a=i[r];o>a.array.length?t.setAttribute(r,new gn(s,a.itemSize).setUsage(this.dynamic?Ha:qs)):(i[r].set(s),i[r].needsUpdate=o>0,i[r].updateRange.count=o)}}}setUniforms(e){if(!e)return;let t=this.material.uniforms,i=this.wireframeMaterial.uniforms,r=this.pickingMaterial.uniforms;for(let s in e)s==="opacity"&&this.setProperties({transparent:this.transparent}),t[s]!==void 0&&(t[s].value.isVector3?t[s].value.copy(e[s]):t[s].value.set?t[s].value.set(e[s]):t[s].value=e[s]),i[s]!==void 0&&(i[s].value.isVector3?i[s].value.copy(e[s]):i[s].value.set?i[s].value.set(e[s]):i[s].value=e[s]),r[s]!==void 0&&(r[s].value.isVector3?r[s].value.copy(e[s]):r[s].value.set?r[s].value.set(e[s]):r[s].value=e[s])}setProperties(e){if(!e)return;let t=this.material,i=this.wireframeMaterial,r=this.pickingMaterial;for(let s in e){let o=s,a=e[o];o==="transparent"?this.updateRenderOrder():o==="side"&&(a=lT(a)),t[o]=a,i[o]=a,r[o]=a}t.needsUpdate=!0,i.needsUpdate=!0,r.needsUpdate=!0}setVisibility(e){this.visible=e,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=e,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=e,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=e))}dispose(){this.material&&this.material.dispose(),this.wireframeMaterial&&this.wireframeMaterial.dispose(),this.pickingMaterial&&this.pickingMaterial.dispose(),this.geometry.dispose(),this.wireframeGeometry&&this.wireframeGeometry.dispose()}toJSON(){var e={};for(var t in this)t!=="group"&&t!=="wireframeGroup"&&t!="pickingGroup"&&t!=="picking"&&(e[t]=this[t]);return e}},Jr=class extends Pr{constructor(e,t={}){super(e,t),this.vertexShader="Mesh.vert",this.fragmentShader="Mesh.frag",this.addAttributes({normal:{type:"v3",value:e.normal}}),e.normal===void 0&&this.geometry.computeVertexNormals()}},mg=class extends Jr{constructor(){super(...arguments),this.isSurface=!0}};function wm(n){n.visible=!0}function uT(n){n.visible=!1}var gg=class{constructor(e){this.group=new $t,this.wireframeGroup=new $t,this.pickingGroup=new $t,this.frontMeshes=[],this.backMeshes=[],this.size=e.size,this.side=e.parameters.side,this.visible=e.visible,this.geometry=e.geometry,this.picking=e.picking,this.group=new $t,this.wireframeGroup=new $t,this.pickingGroup=new $t,this.matrix=e.matrix;let t=e,i=new e.constructor({position:new Float32Array(0)});t.makeMaterial(),i.makeMaterial(),i.picking=e.picking,i.geometry=e.geometry,i.wireframeGeometry=e.wireframeGeometry,i.setParameters(e.getParameters()),i.updateShader(),t.setParameters({side:"front"}),i.setParameters({side:"back",opacity:i.parameters.opacity}),this.buffer=e,this.frontBuffer=t,this.backBuffer=i}set matrix(e){Pr.prototype.setMatrix.call(this,e)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking&&!this.parameters.disablePicking}get parameters(){return this.buffer.parameters}getParameters(){let e=Object.assign({},this.buffer.parameters);return e.side=this.side,e}getMesh(e){let t,i;return e?(i=this.backBuffer.getPickingMesh(),t=this.frontBuffer.getPickingMesh()):(i=this.backBuffer.getMesh(),t=this.frontBuffer.getMesh()),this.frontMeshes.push(t),this.backMeshes.push(i),this.setParameters({side:this.side}),new $t().add(i,t)}getWireframeMesh(){return this.buffer.getWireframeMesh()}getPickingMesh(){return this.getMesh(!0)}setAttributes(e){this.buffer.setAttributes(e)}setParameters(e){(e=Object.assign({},e)).side==="front"?(this.frontMeshes.forEach(wm),this.backMeshes.forEach(uT)):e.side==="back"?(this.frontMeshes.forEach(uT),this.backMeshes.forEach(wm)):e.side==="double"&&(this.frontMeshes.forEach(wm),this.backMeshes.forEach(wm)),e.side!==void 0&&(this.side=e.side),delete e.side,e.matrix!==void 0&&(this.matrix=e.matrix),delete e.matrix,this.frontBuffer.setParameters(e),e.wireframe!==void 0&&(this.wireframe=e.wireframe,this.setVisibility(this.visible)),delete e.wireframe,this.backBuffer.setParameters(e)}setVisibility(e){this.visible=e,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=e,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=e,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=e))}dispose(){this.frontBuffer.dispose(),this.backBuffer.dispose()}toJSON(){var e={};for(var t in this)["side","size","visible","matrix","parameters"].includes(t)&&(e[t]=this[t]);return e}};zt.add("shader/Line.vert",`uniform float clipNear; +uniform vec3 clipCenter; +varying vec3 vViewPosition; +#if defined( RADIUS_CLIP ) +varying vec3 vClipCenter; +#endif +#include color_pars_vertex +void main(){ +#include color_vertex +#include begin_vertex +#include project_vertex +vViewPosition = -mvPosition.xyz; +#if defined( RADIUS_CLIP ) +vClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz; +#endif +#include nearclip_vertex +}`),zt.add("shader/Line.frag",`uniform float opacity; +uniform float clipNear; +uniform float clipRadius; +varying vec3 vViewPosition; +#if defined( RADIUS_CLIP ) +varying vec3 vClipCenter; +#endif +#include common +#include color_pars_fragment +#include fog_pars_fragment +void main(){ +#include nearclip_fragment +#include radiusclip_fragment +gl_FragColor = vec4( vColor, opacity ); +#include premultiplied_alpha_fragment +#include tonemapping_fragment +#include colorspace_fragment +#include fog_fragment +}`);var yg=class extends Pr{constructor(){super(...arguments),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag"}},vd=class extends el{constructor(e,t,i){super(e,t,i),this.type="surface",this.parameters=Object.assign({isolevelType:{type:"select",options:{value:"value",sigma:"sigma"}},isolevel:{type:"number",precision:2,max:1e3,min:-1e3},negateIsolevel:{type:"boolean"},isolevelScroll:{type:"boolean"},smooth:{type:"integer",precision:1,max:10,min:0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},boxSize:{type:"integer",precision:1,max:100,min:0},colorVolume:{type:"hidden"},contour:{type:"boolean",rebuild:!0},useWorker:{type:"boolean",rebuild:!0},wrap:{type:"boolean",rebuild:!0}},this.parameters),e instanceof Hi?(this.surface=void 0,this.volume=e):(this.surface=e,this.volume=void 0),this.boxCenter=new W,this.__boxCenter=new W,this.box=new sn,this.__box=new sn,this._position=new W,this.inverseMatrix=new qe,this.setBox=function(){this._position.copy(t.translationGroup.position).negate(),this._position.applyMatrix4(this.inverseMatrix),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.toBePrepared=!0,this.viewer.signals.ticked.add(this.setBox,this),this.init(i)}init(e){let t=e||{};t.colorScheme=U(t.colorScheme,"uniform"),t.colorValue=U(t.colorValue,14540253),this.isolevelType=U(t.isolevelType,"sigma"),this.isolevel=U(t.isolevel,2),this.negateIsolevel=U(t.negateIsolevel,!1),this.isolevelScroll=U(t.isolevelScroll,!1),this.smooth=U(t.smooth,0),this.background=U(t.background,!1),this.opaqueBack=U(t.opaqueBack,!0),this.boxSize=U(t.boxSize,0),this.colorVolume=U(t.colorVolume,void 0),this.contour=U(t.contour,!1),this.useWorker=U(t.useWorker,!0),this.wrap=U(t.wrap,!1),super.init(t),this.inverseMatrix.copy(this.matrix).invert(),this.build()}attach(e){this.bufferList.forEach(t=>{this.viewer.add(t)}),this.setVisibility(this.visible),e()}prepare(e){if(this.volume){let t;if(t=this.isolevelType==="sigma"?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(t*=-1),!this.surface||this.__isolevel!==t||this.__smooth!==this.smooth||this.__contour!==this.contour||this.__wrap!==this.wrap||this.__boxSize!==this.boxSize||this.boxSize>0&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=t,this.__smooth=this.smooth,this.__contour=this.contour,this.__wrap=this.wrap,this.__boxSize=this.boxSize,this.__boxCenter.copy(this.boxCenter),this.__box.copy(this.box);let i=r=>{this.surface=r,e()};this.useWorker?this.volume.getSurfaceWorker(t,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,i):i(this.volume.getSurface(t,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else e()}else e()}create(){let e={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()},t;if(this.contour)t=new yg(e,this.getBufferParams({wireframe:!1}));else{Object.assign(e,{normal:this.surface.getNormal(),picking:this.surface.getPicking()});let i=new mg(e,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));t=new gg(i)}this.bufferList.push(t)}update(e){if(this.bufferList.length===0)return;let t={};(e=e||{}).position&&(t.position=this.surface.getPosition()),e.color&&(t.color=this.surface.getColor(this.getColorParams())),e.index&&(t.index=this.surface.getIndex()),e.normal&&(t.normal=this.surface.getNormal()),this.bufferList.forEach(function(i){i.setAttributes(t)})}setParameters(e,t,i){return e&&e.isolevelType!==void 0&&this.volume&&(this.isolevelType==="value"&&e.isolevelType==="sigma"?this.isolevel=this.volume.getSigmaForValue(this.isolevel):this.isolevelType==="sigma"&&e.isolevelType==="value"&&(this.isolevel=this.volume.getValueForSigma(this.isolevel)),this.isolevelType=e.isolevelType),e&&e.boxCenter&&(this.boxCenter.copy(e.boxCenter),delete e.boxCenter),e&&e.wireframe&&(e.contour||e.contour===void 0&&this.contour)&&(e.wireframe=!1),super.setParameters(e,t,i),e.matrix&&this.inverseMatrix.copy(e.matrix).invert(),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),e&&e.colorVolume!==void 0&&t&&(t.color=!0),this.surface&&(e.isolevel!==void 0||e.negateIsolevel!==void 0||e.smooth!==void 0||e.wrap!==void 0||e.boxSize!==void 0||this.boxSize>0&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!this.contour}),this}getColorParams(){let e=super.getColorParams();return e.volume=this.colorVolume,e}dispose(){this.viewer.signals.ticked.remove(this.setBox,this),super.dispose()}},Nt=class{static zoomScroll(e,t){e.trackballControls.zoom(t)}static clipNearScroll(e,t){let i=e.getParameters();e.setParameters({clipNear:i.clipNear+t/10})}static focusScroll(e,t){let i=e.getFocus(),r=Math.sign(t)*function(s,o,a){if(s>o)return s;let l=s/o;return((2*a-o)*l+(2*o-3*a))*l*l+a}((100-i)/10,5,.2);e.setFocus(i+r)}static zoomFocusScroll(e,t){e.trackballControls.zoom(t);let i=e.viewer.camera.position.z;e.setFocus(100-Math.abs(i/8))}static isolevelScroll(e,t){let i=Math.sign(t)/10;e.eachRepresentation((r,s)=>{if(r.repr instanceof vd){let o=r.getParameters();o.isolevelScroll&&r.setParameters({isolevel:o.isolevel+i})}})}static panDrag(e,t,i){e.trackballControls.pan(t,i)}static rotateDrag(e,t,i){e.trackballControls.rotate(t,i)}static zRotateDrag(e,t,i){e.trackballControls.zRotate(t,i)}static zoomDrag(e,t,i){e.trackballControls.zoom((t+i)/-2)}static zoomFocusDrag(e,t,i){e.trackballControls.zoom((t+i)/-2);let r=e.viewer.camera.position.z;e.setFocus(100-Math.abs(r/8))}static panComponentDrag(e,t,i){e.trackballControls.panComponent(t,i)}static panAtomDrag(e,t,i){e.trackballControls.panAtom(t,i)}static rotateComponentDrag(e,t,i){e.trackballControls.rotateComponent(t,i)}static movePick(e,t){t&&e.animationControls.move(t.position.clone())}static tooltipPick(e,t){let i=e.tooltip;if(e.getParameters().tooltip&&t){let r=t.mouse.position;i.innerText=t.getLabel(),i.style.bottom=window.innerHeight-r.y+3+"px",i.style.left=r.x+3+"px",i.style.display="block"}else i.style.display="none"}static measurePick(e,t){if(t&&(t.atom||t.bond)){let i=t.atom||t.closestBondAtom;t.component.measurePick(i)}else e.measureClear()}},oI={default:[["scroll",Nt.zoomScroll],["scroll-shift",Nt.focusScroll],["scroll-ctrl",Nt.isolevelScroll],["scroll-shift-ctrl",Nt.zoomFocusScroll],["drag-left",Nt.rotateDrag],["drag-right",Nt.panDrag],["drag-ctrl-left",Nt.panDrag],["drag-ctrl-right",Nt.zRotateDrag],["drag-shift-left",Nt.zoomDrag],["drag-middle",Nt.zoomFocusDrag],["drag-ctrl-shift-right",Nt.panComponentDrag],["drag-ctrl-shift-left",Nt.rotateComponentDrag],["clickPick-right",Nt.measurePick],["clickPick-ctrl-left",Nt.measurePick],["clickPick-middle",Nt.movePick],["clickPick-left",Nt.movePick],["hoverPick",Nt.tooltipPick]],pymol:[["drag-left",Nt.rotateDrag],["drag-middle",Nt.panDrag],["drag-right",Nt.zoomDrag],["scroll",Nt.focusScroll],["drag-shift-right",Nt.focusScroll],["clickPick-ctrl+shift-middle",Nt.movePick],["hoverPick",Nt.tooltipPick]],coot:[["scroll",Nt.isolevelScroll],["drag-left",Nt.rotateDrag],["drag-middle",Nt.panDrag],["drag-ctrl-left",Nt.panDrag],["drag-right",Nt.zoomFocusDrag],["drag-ctrl-right",Nt.focusScroll],["clickPick-middle",Nt.movePick],["hoverPick",Nt.tooltipPick]],astexviewer:[["drag-left",Nt.rotateDrag],["drag-ctrl-left",Nt.panDrag],["drag-shift-left",Nt.zoomDrag],["scroll",Nt.focusScroll],["clickPick-middle",Nt.movePick],["hoverPick",Nt.tooltipPick]]};function hT(n){let e=n.split(/[-+]/),t="";e.includes("scroll")&&(t="scroll"),e.includes("drag")&&(t="drag"),e.includes("click")&&(t="click"),e.includes("doubleClick")&&(t="doubleClick"),e.includes("hover")&&(t="hover"),e.includes("clickPick")&&(t="clickPick"),e.includes("hoverPick")&&(t="hoverPick");let i=0;e.includes("alt")&&(i+=1),e.includes("ctrl")&&(i+=2),e.includes("meta")&&(i+=4),e.includes("shift")&&(i+=8);let r=0;return e.includes("left")&&(r+=1),e.includes("right")&&(r+=2),e.includes("middle")&&(r+=4),[t,i,r]}var Sb=class{constructor(e,t={}){this.stage=e,this.actionList=[],this.mouse=e.mouseObserver,this.disabled=t.disabled||!1,this.preset(t.preset||"default")}run(e,...t){if(this.disabled)return;let i=this.mouse.key||0,r=this.mouse.buttons||0;this.actionList.forEach(s=>{s.type===e&&s.key===i&&s.button===r&&s.callback(this.stage,...t)})}add(e,t){let[i,r,s]=hT(e);this.actionList.push({type:i,key:r,button:s,callback:t})}remove(e,t){let i=e.includes("*"),[r,s,o]=hT(e),a=this.actionList.filter(function(l){return!((l.type===r||i&&r==="")&&(l.key===s||i&&s===0)&&(l.button===o||i&&o===0)&&(l.callback===t||t===void 0))});this.actionList=a}preset(e){this.clear(),(oI[e]||[]).forEach(t=>this.add(t[0],t[1]))}clear(){this.actionList.length=0}},Xa=class{static autoView(e){e.autoView(1e3)}static toggleAnimations(e){e.animationControls.toggle()}static toggleRock(e){e.toggleRock()}static toggleSpin(e){e.toggleSpin()}static toggleAntialiasing(e){let t=e.getParameters();e.setParameters({sampleLevel:t.sampleLevel===-1?0:-1})}},CU={default:[["i",Xa.toggleSpin],["k",Xa.toggleRock],["p",Xa.toggleAnimations],["a",Xa.toggleAntialiasing],["r",Xa.autoView]]},Ab=class{constructor(e,t={}){this.stage=e,this.actionList=[],this.disabled=t.disabled||!1,this.preset(t.preset||"default")}run(e){this.disabled||this.actionList.forEach(t=>{t.key===e&&t.callback(this.stage)})}add(e,t){this.actionList.push({key:e,callback:t})}remove(e,t){let i=this.actionList.filter(function(r){return!(r.key===e&&(r.callback===t||t===void 0))});this.actionList=i}preset(e){this.clear(),(CU[e]||[]).forEach(t=>this.add(t[0],t[1]))}clear(){this.actionList.length=0}},Mb=class{constructor(e){this.stage=e,this.stage=e,this.mouse=e.mouseObserver,this.controls=e.mouseControls,this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this)}_onClick(e,t){let i=this.stage.pickingControls.pick(e,t);this.stage.signals.clicked.dispatch(i),this.controls.run("clickPick",i)}_onHover(e,t){let i=this.stage.pickingControls.pick(e,t);i&&this.mouse.down.equals(this.mouse.position)&&(this.stage.transformComponent=i.component,this.stage.transformAtom=i.atom),this.stage.signals.hovered.dispatch(i),this.controls.run("hoverPick",i)}dispose(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)}},Cb=class{constructor(e){this.stage=e,this.stage=e,this.mouse=e.mouseObserver,this.controls=e.mouseControls,this.mouse.signals.moved.add(this._onMove,this),this.mouse.signals.scrolled.add(this._onScroll,this),this.mouse.signals.dragged.add(this._onDrag,this),this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this),this.mouse.signals.doubleClicked.add(this._onDblclick,this)}_onMove(){this.stage.tooltip.style.display="none"}_onScroll(e){this.controls.run("scroll",e)}_onDrag(e,t){this.controls.run("drag",e,t)}_onClick(e,t){this.controls.run("click",e,t)}_onDblclick(e,t){this.controls.run("doubleClick",e,t)}_onHover(e,t){this.controls.run("hover",e,t)}dispose(){this.mouse.signals.moved.remove(this._onMove,this),this.mouse.signals.scrolled.remove(this._onScroll,this),this.mouse.signals.dragged.remove(this._onDrag,this),this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)}},Eb=class{constructor(e){this.stage=e,this.viewer=e.viewer,this.animationControls=e.animationControls,this.viewer.signals.ticked.add(this._onTick,this)}_onTick(e){this.animationControls.run(e)}dispose(){this.viewer.signals.ticked.remove(this._onTick,this)}},dT=!!OP&&{passive:!0},Tb=class{constructor(e){this.stage=e,this.stage=e,this.controls=e.keyControls,this.domElement=e.viewer.renderer.domElement,this.domElement.setAttribute("tabIndex","-1"),this.domElement.style.outline="none",this._focusDomElement=this._focusDomElement.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),this.domElement.addEventListener("mousedown",this._focusDomElement),this.domElement.addEventListener("touchstart",this._focusDomElement,dT),this.domElement.addEventListener("keydown",this._onKeydown),this.domElement.addEventListener("keyup",this._onKeyup),this.domElement.addEventListener("keypress",this._onKeypress)}_onKeydown(){}_onKeyup(){}_onKeypress(e){let t;t="key"in KeyboardEvent.prototype?e.key:String.fromCharCode(e.which||e.keyCode),this.controls.run(t)}_focusDomElement(){this.domElement.focus()}dispose(){this.domElement.removeEventListener("mousedown",this._focusDomElement),this.domElement.removeEventListener("touchstart",this._focusDomElement,dT),this.domElement.removeEventListener("keydown",this._onKeypress),this.domElement.removeEventListener("keyup",this._onKeypress),this.domElement.removeEventListener("keypress",this._onKeypress)}},Pb=class{constructor(e,t,i,r={}){this.component=e,this.position=t,this.offsetX=U(r.offsetX,0),this.offsetY=U(r.offsetY,0),this.visible=U(r.visible,!0),this.stage=e.stage,this.viewer=e.stage.viewer,this._viewerPosition=new W,this._updateViewerPosition(),this._canvasPosition=new Et,this._cameraPosition=new W,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"block",position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",left:"-10000px"}),this.viewer.wrapper.appendChild(this.element),this.setContent(i),this.updateVisibility(),this.viewer.signals.rendered.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)}setContent(e){let t=this.element.style.display;if(t==="none"&&(this.element.style.left="-10000px",this.element.style.display="block"),e instanceof HTMLElement)this.element.appendChild(e);else{let i=document.createElement("div");i.innerText=e,Object.assign(i.style,{backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.element.appendChild(i)}this._clientRect=this.element.getBoundingClientRect(),t==="none"&&(this.element.style.display=t)}setVisibility(e){this.visible=e,this.updateVisibility()}getVisibility(){return this.visible&&this.component.parameters.visible}updateVisibility(){this.element.style.display=this.getVisibility()?"block":"none"}_updateViewerPosition(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)}_update(){if(!this.getVisibility())return;let e=this.element.style,t=this._canvasPosition,i=this._viewerPosition,r=this._clientRect;if(this._cameraPosition.copy(i).add(this.viewer.translationGroup.position).applyMatrix4(this.viewer.rotationGroup.matrix).sub(this.viewer.camera.position),this._cameraPosition.z<0)return void(e.display="none");e.display="block";let s=this._cameraPosition.length(),o=this.viewer.scene.fog;e.opacity=(1-Pd(o.near,o.far,s)).toString(),e.zIndex=Math.round(100*(o.far-s)).toString(),this.stage.viewerControls.getPositionOnCanvas(i,t),e.bottom=this.offsetX+t.y+r.height/2+"px",e.left=this.offsetY+t.x-r.width/2+"px"}dispose(){this.viewer.wrapper.removeChild(this.element),this.viewer.signals.ticked.remove(this._update,this),this.component.signals.matrixChanged.remove(this._updateViewerPosition,this)}},qo=new qe,Sm=new W,fT=new Xn,Ib=class{constructor(e){this.component=e,this.signals={changed:new Td.Signal},this.stage=e.stage,this.viewer=e.stage.viewer}get position(){return this.component.position}get rotation(){return this.component.quaternion}changed(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()}spin(e,t){qo.copy(this.viewer.rotationGroup.matrix).invert(),Sm.copy(Za(e)).applyMatrix4(qo),qo.extractRotation(this.component.transform),qo.premultiply(this.viewer.rotationGroup.matrix),qo.invert(),Sm.copy(Za(e)),Sm.applyMatrix4(qo),qo.makeRotationAxis(Sm,t),fT.setFromRotationMatrix(qo),this.component.quaternion.premultiply(fT),this.changed()}},aI={"":"",vdw:"by vdW radius",covalent:"by covalent radius",sstruc:"by secondary structure",bfactor:"by bfactor",size:"size",data:"data",explicit:"explicit"},Qr=class{constructor(e={}){this.max=10,this.type=U(e.type,"size"),this.scale=U(e.scale,1),this.size=U(e.size,1),this.data=U(e.data,{})}atomRadius(e){let t;switch(this.type){case"vdw":t=e.vdw;break;case"covalent":t=e.covalent;break;case"bfactor":t=e.bfactor||1;break;case"sstruc":let i=e.sstruc;t=i==="h"||i==="g"||i==="i"||i==="e"||i==="b"?.25:QP.includes(e.atomname)?.4:.1;break;case"data":t=U(this.data[e.index],1);break;case"explicit":t=e.radius,t===null&&(t=this.size);break;default:t=this.size}return Math.min(t*this.scale,this.max)}};Qr.types=aI;var EU=new W(-1,-1,-1),TU=new qe,_g=class{constructor(e){let t=e.rows,i=t/3,r=new Ht(t,3),s=new Ht(3,3),o=new Ht(1,3),a=new Ht(3,3),l=new Ht(3,3),c=_b(e);vb(e,c),Kr(r,e),Ym(s,r,r),iI(s,o,a,l);let u=new W(c[0],c[1],c[2]),d=new W(a.data[0],a.data[3],a.data[6]),f=new W(a.data[1],a.data[4],a.data[7]),m=new W(a.data[2],a.data[5],a.data[8]),p=d.clone().multiplyScalar(Math.sqrt(o.data[0]/i)),_=f.clone().multiplyScalar(Math.sqrt(o.data[1]/i)),y=m.clone().multiplyScalar(Math.sqrt(o.data[2]/i));this.begA=u.clone().sub(p),this.endA=u.clone().add(p),this.begB=u.clone().sub(_),this.endB=u.clone().add(_),this.begC=u.clone().sub(y),this.endC=u.clone().add(y),this.center=u,this.vecA=p,this.vecB=_,this.vecC=y,this.normVecA=d,this.normVecB=f,this.normVecC=m}getBasisMatrix(e=new qe){let t=e;return t.makeBasis(this.normVecB,this.normVecA,this.normVecC),t.determinant()<0&&t.scale(EU),t}getRotationQuaternion(e=new Xn){let t=e;return t.setFromRotationMatrix(this.getBasisMatrix(TU)),t.invert()}getProjectedScaleForAtoms(e){let t=-1/0,i=-1/0,r=-1/0,s=-1/0,o=-1/0,a=-1/0,l=new W,c=new W,u=this.center,d=this.normVecA,f=this.normVecB,m=this.normVecC;return e.eachAtom(function(p){Ka(l.copy(p),d,u);let _=c.subVectors(l,u).normalize().dot(d),y=l.distanceTo(u);_>0?y>t&&(t=y):y>i&&(i=y),Ka(l.copy(p),f,u);let g=c.subVectors(l,u).normalize().dot(f),b=l.distanceTo(u);g>0?b>r&&(r=b):b>s&&(s=b),Ka(l.copy(p),m,u);let h=c.subVectors(l,u).normalize().dot(m),v=l.distanceTo(u);h>0?v>o&&(o=v):v>a&&(a=v)}),{d1a:t,d2a:r,d3a:o,d1b:-i,d2b:-s,d3b:-a}}},qr=class{constructor(e,t,i,r){this.volume=e,this.setFilter(t,i,r)}get header(){return this.volume.header}get matrix(){return this.volume.matrix}get normalMatrix(){return this.volume.normalMatrix}get inverseMatrix(){return this.volume.inverseMatrix}get center(){return this.volume.center}get boundingBox(){return this.volume.boundingBox}get min(){return this.volume.min}get max(){return this.volume.max}get mean(){return this.volume.mean}get rms(){return this.volume.rms}_getFilterHash(e,t,i){return JSON.stringify([e,t,i])}setFilter(e,t,i){isNaN(e)&&this.header&&(e=this.header.DMEAN+2*this.header.ARMS),e=e===void 0||isNaN(e)?-1/0:e,t=U(t,1/0),i=U(i,!1);let r=this.volume.data,s=this.volume.position,o=this.volume.atomindex,a=this._getFilterHash(e,t,i);if(a!==this._filterHash){if(e===-1/0&&t===1/0)this.data=r,this.position=s,this.atomindex=o;else{let l=r.length;this._dataBuffer||(this._dataBuffer=new ArrayBuffer(4*l),this._positionBuffer=new ArrayBuffer(3*l*4),o&&(this._atomindexBuffer=new ArrayBuffer(4*l)));let c=new Float32Array(this._dataBuffer),u=new Float32Array(this._positionBuffer),d;o&&(d=new Uint32Array(this._atomindexBuffer));let f=0;for(let m=0;m=e&&_<=t||i&&(_t)){let y=3*f;c[f]=_,u[y+0]=s[p+0],u[y+1]=s[p+1],u[y+2]=s[p+2],o&&d&&(d[f]=o[m]),f+=1}}this.data=new Float32Array(this._dataBuffer,0,f),this.position=new Float32Array(this._positionBuffer,0,3*f),o&&(this.atomindex=new Int32Array(this._atomindexBuffer,0,f))}this._filterHash=a}}};qr.prototype.getValueForSigma=Hi.prototype.getValueForSigma,qr.prototype.getSigmaForValue=Hi.prototype.getSigmaForValue,qr.prototype.getDataAtomindex=Hi.prototype.getDataAtomindex,qr.prototype.getDataPosition=Hi.prototype.getDataPosition,qr.prototype.getDataColor=Hi.prototype.getDataColor,qr.prototype.getDataPicking=Hi.prototype.getDataPicking,qr.prototype.getDataSize=Hi.prototype.getDataSize;var Rb=class{constructor(e,t){let i=WP({nodeArray1:e.atomIndex1,nodeArray2:e.atomIndex2,edgeCount:e.count,nodeCount:t});this.countArray=i.countArray,this.offsetArray=i.offsetArray,this.indexArray=i.indexArray}},Bc=class extends sa{get _defaultFields(){return[["atomIndex1",1,"int32"],["atomIndex2",1,"int32"],["bondOrder",1,"int8"]]}addBond(e,t,i){this.growIfFull();let r=this.count,s=e.index,o=t.index;s0&&(a[N]=v.angleTo(S));let z=Math.cos(_.angleTo(y));u[N]=180/Math.PI*Math.acos(z);let L=_.length(),F=y.length();l[N]=Math.sqrt(F*L)/Math.max(2,2*(1-z)),c[N]=Math.abs(m.dot(v)),g.copy(_).multiplyScalar(l[N]/L),b.copy(y).multiplyScalar(l[N]/F),g.subVectors(T,g),b.subVectors(R,b),g.toArray(s,H+3),b.toArray(s,H+6),x.subVectors(M,w),x.toArray(d,H),S.copy(v),w.copy(g)}g.fromArray(s,3),b.fromArray(s,6),v.subVectors(g,b).normalize(),M.index=e.getAtomIndexByType(0,A),w.copy(M),h.copy(M),Ka(h,v,g),h.toArray(s,0),x.subVectors(w,g),x.toArray(d,0),g.fromArray(s,3*i-6),b.fromArray(s,3*i-9),v.subVectors(g,b).normalize(),M.index=e.getAtomIndexByType(i-1,A),w.copy(M),h.copy(M),Ka(h,v,g),h.toArray(s,3*i-3);for(let N=i-3;Nt||u.bending[F]>e)&&(z=!0)),z){if(F-p<4){p=F,z=!1;continue}D.index=I.traceAtomIndex,R=u.axis.subarray(3*p+3,3*F),C=u.center.subarray(3*p,3*F+3),M=sb(R).normalize(),T=sb(C),P.fromArray(C),Ka(P,M,T),E.fromArray(C,C.length-3),Ka(E,M,T),M.subVectors(E,P),M.toArray(y,_),T.toArray(g,_),P.toArray(b,_),E.toArray(h,_),f.atomColorToArray(D,v,_),S.push(D.index),x.push(m.atomRadius(D)),w.push(c+p),A.push(c+F+1-p),_+=3,p=F,z=!1}let L=new Float32Array(S);return{axis:new Float32Array(y),center:new Float32Array(g),begin:new Float32Array(b),end:new Float32Array(h),color:new Float32Array(v),picking:new oo(L,a),size:new Float32Array(x),residueOffset:w,residueCount:A}}},Fb=class{constructor(e){this.scoreFunction=e,this.content=[],this.scoreFunction=e}push(e){this.content.push(e),this.bubbleUp(this.content.length-1)}pop(){let e=this.content[0],t=this.content.pop();return t&&this.content.length>0&&(this.content[0]=t,this.sinkDown(0)),e}peek(){return this.content[0]}remove(e){let t=this.content.length;for(let i=0;i0;){let i=Math.floor((e+1)/2)-1,r=this.content[i];if(!(this.scoreFunction(t)this.maxDepth&&(this.maxDepth=e);let s=r-i;if(s===0)return-1;let o=4*this.currentNode,a=this.nodes;if(this.currentNode+=1,s===1)return a[o]=i,a[o+1]=-1,a[o+2]=-1,a[o+3]=t,o;let l=this.indices,c=this.points,u=i+Math.floor(s/2),d=e%3,f,m,p,_,y,g=i,b=r-1;for(;b>g;){for(p=g+b>>1,_=c[3*l[p]+d],m=l[p],l[p]=l[b],l[b]=m,y=g,f=g;f-u[1]),s=this.nodes,o=this.points,a=this.indices,l=u=>{let d,f,m=this.getNodeDepth(u)%3,p=3*a[s[u]],_=[o[p+0],o[p+1],o[p+2]],y=this.metric(e,_);function g(x,w){r.push([x,w]),r.size()>t&&r.pop()}let b=s[u+1],h=s[u+2];if(h===-1&&b===-1)return void((r.size()o[3*a[s[e]]+r])throw new Error("left child is > parent!");i+=this.verify(l,t+1)}if(c!==-1){if(o[3*a[s[c]]+r]0}isBackbone(){let e=this.residueType.backboneIndexList;return e.length>0&&e.includes(this.index-this.residueAtomOffset)}isPolymer(){if(this.structure.entityList.length>0)return this.entity.isPolymer();{let e=this.residueType.moleculeType;return e===3||e===4||e===5}}isSidechain(){return this.isPolymer()&&!this.isBackbone()}isCg(){let e=this.residueType.backboneType;return e===4||e===5||e===6}isTrace(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset}isHetero(){return this.residueType.hetero===1}isProtein(){return this.residueType.moleculeType===3}isNucleic(){let e=this.residueType.moleculeType;return e===4||e===5}isRna(){return this.residueType.moleculeType===4}isDna(){return this.residueType.moleculeType===5}isWater(){return this.residueType.moleculeType===1}isIon(){return this.residueType.moleculeType===2}isSaccharide(){return this.residueType.moleculeType===6}isHelix(){return XP.includes(this.sstruc)}isSheet(){return qP.includes(this.sstruc)}isTurn(){return YP.includes(this.sstruc)&&this.isProtein()}isBonded(){return this.bondHash.countArray[this.index]!==0}isRing(){return this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]!==void 0}isAromatic(){return this.aromatic===1}isPolarHydrogen(){let e=!1;return this.number!==1||(e=!this.hasBondToElement(6)),e}isMetal(){return this.atomType.isMetal()}isNonmetal(){return this.atomType.isNonmetal()}isMetalloid(){return this.atomType.isMetalloid()}isHalogen(){return this.atomType.isHalogen()}isDiatomicNonmetal(){return this.atomType.isDiatomicNonmetal()}isPolyatomicNonmetal(){return this.atomType.isPolyatomicNonmetal()}isAlkaliMetal(){return this.atomType.isAlkaliMetal()}isAlkalineEarthMetal(){return this.atomType.isAlkalineEarthMetal()}isNobleGas(){return this.atomType.isNobleGas()}isTransitionMetal(){return this.atomType.isTransitionMetal()}isPostTransitionMetal(){return this.atomType.isPostTransitionMetal()}isLanthanide(){return this.atomType.isLanthanide()}isActinide(){return this.atomType.isActinide()}getDefaultValence(){return this.atomType.getDefaultValence()}getValenceList(){return this.atomType.getValenceList()}getOuterShellElectronCount(){return this.atomType.getOuterShellElectronCount()}distanceTo(e){let t=this.atomStore,i=e.atomStore,r=this.index,s=e.index,o=t.x[r]-i.x[s],a=t.y[r]-i.y[s],l=t.z[r]-i.z[s],c=o*o+a*a+l*l;return Math.sqrt(c)}connectedTo(e){let t=this.atomStore,i=e.atomStore,r=this.index,s=e.index;if(t.altloc&&i.altloc){let m=t.altloc[r],p=i.altloc[s];if(m!==0&&p!==0&&m!==32&&p!==32&&m!==p)return!1}let o=t.x[r]-i.x[s],a=t.y[r]-i.y[s],l=t.z[r]-i.z[s],c=o*o+a*a+l*l;if(c<48&&this.isCg())return!0;if(isNaN(c))return!1;let u=this.covalent+e.covalent,d=u+.3,f=u-.5;return cf*f}positionFromArray(e,t=0){return this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this}positionToArray(e=[],t=0){let i=this.index,r=this.atomStore;return e[t+0]=r.x[i],e[t+1]=r.y[i],e[t+2]=r.z[i],e}positionToVector3(e){return e===void 0&&(e=new W),e.x=this.x,e.y=this.y,e.z=this.z,e}positionFromVector3(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}positionAdd(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}positionSub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}getResidueBonds(e=!1){let t=this.residueAtomOffset,i=this.index-this.residueAtomOffset,r=this.residueType.getBonds(),s=r.atomIndices1,o=r.atomIndices2,a,l,c,u;for(e||(u=[]),a=s.indexOf(i);a!==-1;){if(c=o[a]+t,!u)return c;u.push(c),a=s.indexOf(i,a+1)}for(l=o.indexOf(i);l!==-1;){if(c=s[l]+t,!u)return c;u.push(c),l=o.indexOf(i,l+1)}return u}qualifiedName(e=!1){var t="";return this.resname&&!e&&(t+="["+this.resname+"]"),this.resno!==void 0&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chainname&&(t+=":"+this.chainname),this.atomname&&(t+="."+this.atomname),this.altloc&&(t+="%"+this.altloc),this.structure.modelStore.count>1&&(t+="/"+this.modelIndex),t}clone(){return new n(this.structure,this.index)}toObject(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}}};function lI(n,e){let t=n[0]-e[0],i=n[1]-e[1],r=n[2]-e[2];return t*t+i*i+r*r}function PU(n,e){return Math.sqrt(lI(n,e))}var Xv=new Float32Array(3),Bb=class{constructor(e,t=!1){Le&&we.time("Kdtree build");let i=t?lI:PU,r=new Float32Array(3*e.atomCount),s=new Uint32Array(e.atomCount),o=0;e.eachAtom(function(a){r[o+0]=a.x,r[o+1]=a.y,r[o+2]=a.z,s[o/3]=a.index,o+=3}),this.atomIndices=s,this.points=r,this.kdtree=new Ob(r,i),Le&&we.timeEnd("Kdtree build")}nearest(e,t,i){e instanceof W?e.toArray(Xv):e instanceof xg&&e.positionToArray(Xv);let r=this.kdtree.nearest(Xv,t,i),s=this.kdtree.indices,o=this.kdtree.nodes,a=this.atomIndices,l=[];for(let c=0,u=r.length;c":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},RU={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","F 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ","F 4/m -3 2/c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},kU=/^[1-9]$/;function cI(n){let e="";return n.length>0&&(e=":"+_w(n).join(" OR :")),new tn(e)}var As=class{constructor(e=""){this.name=e,this.partList=[]}get type(){return"Assembly"}addPart(e,t){let i=new Ub(e,t);return this.partList.push(i),i}getAtomCount(e){return this.partList.reduce((t,i)=>t+i.getAtomCount(e),0)}getResidueCount(e){return this.partList.reduce((t,i)=>t+i.getResidueCount(e),0)}getInstanceCount(){let e=0;return this.partList.forEach(function(t){e+=t.matrixList.length}),e}isIdentity(e){if(this.partList.length!==1)return!1;let t=this.partList[0];if(t.matrixList.length!==1||!new qe().equals(t.matrixList[0]))return!1;let i=[];return e.eachChain(function(r){i.push(r.chainname)}),i=_w(i),t.chainList.length===i.length}getBoundingBox(e){let t=new sn;return this.partList.forEach(function(i){let r=i.getBoundingBox(e);t.expandByPoint(r.min),t.expandByPoint(r.max)}),t}getCenter(e){return this.getBoundingBox(e).getCenter(new W)}getSelection(){let e=[];return this.partList.forEach(function(t){e=e.concat(t.chainList)}),cI(e)}},Ub=class{constructor(e=[],t=[]){this.matrixList=e,this.chainList=t}get type(){return"AssemblyPart"}_getCount(e,t){let i=0;return e.eachChain(r=>{(this.chainList.length===0||this.chainList.includes(r.chainname))&&(i+=r[t])}),this.matrixList.length*i}getAtomCount(e){return this._getCount(e,"atomCount")}getResidueCount(e){return this._getCount(e,"residueCount")}getBoundingBox(e){let t=new sn,i=new sn,r=this.getSelection(),s=e.getBoundingBox(r);return this.matrixList.forEach(function(o){i.copy(s).applyMatrix4(o),t.expandByPoint(i.min),t.expandByPoint(i.max)}),t}getSelection(){return cI(this.chainList)}getView(e){let t=this.getSelection();return t?e.getView(t):e}getInstanceList(){let e=[];for(let t=0,i=this.matrixList.length;t0&&this.addResidueType(this.ri-1),u.growIfFull(),u.resno[this.ri]=s,a!==void 0&&(u.sstruc[this.ri]=a.charCodeAt(0)),l!==void 0&&(u.inscode[this.ri]=l.charCodeAt(0)),u.atomOffset[this.ri]=this.ai,u.atomCount[this.ri]=0,u.count+=1,u.chainIndex[this.ri]=this.ci,d.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,u.atomCount[this.ri]+=1,this.currentModelindex=e,this.currentChainid=i,this.currentResname=r,this.currentResno=s,this.currentInscode=l,this.currentHetero=o}finalize(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)}};function uI(n,e){if(!e)return;Le&&we.time("assignSecondaryStructure");let t=[];n.eachModel(function(c){c.eachChain(function(u){t.push(u.chainname)})});let i=t.slice().sort(),r=[];i.forEach(function(c){r.push(t.indexOf(c))});let s=e.helices.filter(function(c){return ja(i,c[0])>=0});s.sort(function(c,u){let d=c[0],f=u[0],m=c[1],p=u[1];if(d===f)return m===p?0:m=0});a.sort(function(c,u){let d=c[0],f=u[0];if(d===f)return 0;let m=ja(i,d),p=ja(i,f);return r[m]=i.residueCount)continue;c.index=l+m,u.index=l+m+p,d.index=c.traceAtomIndex,f.index=u.traceAtomIndex;let _=d.distanceTo(f);if(Math.abs(_-s[p-2])>o)return!1}return!0},e=function(i,r){return n(i,r,[5.45,5.18,6.37],2.1)},t=function(i,r){return n(i,r,[6.1,10.4,13],1.42)};return function(i){Le&&we.time("calculateSecondaryStructure"),i.eachPolymer(function(r){if(r.residueCount<4)return;if(r.isCg())(function(a){let l=a.residueStore,c=a.residueIndexStart,u=new vg(a).position,d=new W,f=new W;for(let m=0,p=a.residueCount;m1&&u.bending[m]<20&&(l.sstruc[c+m]=104,l.sstruc[c+m+1]=104)}})(r);else{if(!r.isProtein())return;(function(a){let l=a.residueStore,c=a.residueIndexStart;for(let u=0,d=a.residueCount;u=e;)t=Math.floor(t/e),r+=qv[t%e],i+=1;return i>=5&&we.warn("chainname overflow"),r}function R0(n,e=!1){Le&&we.time("calculateChainnames");let t=!0;if(n.eachChain(function(i){i.chainname&&(t=!1)}),t){let i=n.modelStore,r=n.chainStore,s=n.residueStore,o=function(_,y,g,b){let h=r.count;for(let v=0;v{u.add(f),d.forEach(m=>{u.add(m)})})),n.eachResidue(function(d){if(!e&&c){let p=d.atomCount,_=d.atomOffset;if(p>500)return void we.warn("more than 500 atoms, skip residue for auto-bonding",d.qualifiedName());if(t==="auto"&&d.hetero){for(let S=d.atomOffset;S{u.forEach(y=>{p.push(_.clone().multiply(y))})}),l.addPart(p)}else l.addPart(c);let d=new W,f=new As("SUPERCELL"),m=Array.prototype.concat.call(a(d.set(1,0,0)),a(d.set(0,1,0)),a(d.set(0,0,1)),a(d.set(-1,0,0)),a(d.set(0,-1,0)),a(d.set(0,0,-1)),a(d.set(1,1,0)),a(d.set(1,0,1)),a(d.set(0,1,1)),a(d.set(-1,-1,0)),a(d.set(-1,0,-1)),a(d.set(0,-1,-1)),a(d.set(1,-1,-1)),a(d.set(1,1,-1)),a(d.set(1,-1,1)),a(d.set(-1,1,1)),a(d.set(-1,-1,1)),a(d.set(-1,1,-1)),a(d.set(0,1,-1)),a(d.set(0,-1,1)),a(d.set(1,0,-1)),a(d.set(-1,0,1)),a(d.set(1,-1,0)),a(d.set(-1,1,0)),a(),a(d.set(1,1,1)),a(d.set(-1,-1,-1)));if(n.biomolDict.NCS){let p=[];m.forEach(function(_){u.forEach(function(y){p.push(_.clone().multiply(y))})}),f.addPart(p)}else f.addPart(m);n.biomolDict.UNITCELL=l,n.biomolDict.SUPERCELL=f,Le&&we.timeEnd("buildUnitcellAssembly")}var mT=["H","C","O","N","S","P"],DU=["NA","CL","FE"];function Ew(n){let e=n.toUpperCase(),t=0,i=0;for(let s=0;s0)break;++t}else i=s+1;(t>0||i=3&&mT.indexOf(e[0])!==-1?e[0]:""}function sl(n){let e=n.bondHash,t=e.countArray,i=e.offsetArray,r=e.indexArray,s=n.getBondProxy();n.eachResidue(function(o){let a=o.residueType;if(a.bonds!==void 0)return;var l=o.atomOffset,c=[],u=[],d=[],f={};let m=l+o.atomCount;o.eachAtom(function(p){let _=p.index,y=i[_];for(let g=0,b=t[_];g=m)continue;let v=s.atomIndex2;if(v=m)continue;if(h>v){let x=v;v=h,h=x}let S=h+"|"+v;f[S]===void 0&&(f[S]=!0,c.push(h-l),u.push(v-l),d.push(s.bondOrder))}}),a.bonds={atomIndices1:c,atomIndices2:u,bondOrders:d}})}var NU=[3,11,19,37,55,87],FU=[4,12,20,38,56,88],OU=[6,15,16,34],BU=[1,7,8,9,17,35,53],UU=[2,10,18,36,54,86],zU=[13,30,31,48,49,50,80,81,82,83,84,85,112],VU=[5,14,32,33,51,52,85],HU=[9,17,35,53,85],Vb=class{constructor(e,t,i){this.structure=e,this.atomname=t,i=i||Ew(t),this.element=i,this.number=ZP[i]||0,this.vdw=YB[this.number]||2,this.covalent=ZB[this.number]||1.6}getDefaultValence(){let e=eT[this.number];return e?e[0]:-1}getValenceList(){return eT[this.number]||[]}getOuterShellElectronCount(){return KB[this.number]||2}isMetal(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()}isNonmetal(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()}isMetalloid(){return VU.includes(this.number)}isHalogen(){return HU.includes(this.number)}isDiatomicNonmetal(){return BU.includes(this.number)}isPolyatomicNonmetal(){return OU.includes(this.number)}isAlkaliMetal(){return NU.includes(this.number)}isAlkalineEarthMetal(){return FU.includes(this.number)}isNobleGas(){return UU.includes(this.number)}isTransitionMetal(){let e=this.number;return e>=21&&e<=29||e>=39&&e<=47||e>=72&&e<=79||e>=104&&e<=108}isPostTransitionMetal(){return zU.includes(this.number)}isLanthanide(){return this.number>=57&&this.number<=71}isActinide(){return this.number>=89&&this.number<=103}},Hb=class{constructor(e){this.structure=e,this.dict={},this.list=[],this.structure=e}add(e,t){let i=function(s,o){return s+"|"+o}(e=e.toUpperCase(),t=t?t.toUpperCase():Ew(e)),r=this.dict[i];if(r===void 0){let s=new Vb(this.structure,e,t);r=this.list.length,this.dict[i]=r,this.list.push(s)}return r}get(e){return this.list[e]}},Gb=class{constructor(e,t,i,r,s,o){this.structure=e,this.bondReferenceAtomIndices=[],this.resname=t,this.atomTypeIdList=i,this.hetero=r?1:0,this.chemCompType=s,this.bonds=o,this.atomCount=i.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();let a=Yh[this.backboneType],l=Yh[this.backboneStartType],c=Yh[this.backboneEndType],u=this.getAtomIndexByName(a.trace);this.traceAtomIndex=U(u,-1);let d=this.getAtomIndexByName(a.direction1);this.direction1AtomIndex=U(d,-1);let f=this.getAtomIndexByName(a.direction2);this.direction2AtomIndex=U(f,-1);let m=this.getAtomIndexByName(l.backboneStart);this.backboneStartAtomIndex=U(m,-1);let p=this.getAtomIndexByName(c.backboneEnd),_;this.backboneEndAtomIndex=U(p,-1),_=QB.includes(t)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=U(_,-1)}getBackboneIndexList(){let e=[],t;switch(this.moleculeType){case 3:t=nU;break;case 4:case 5:t=QP;break;default:return e}let i=this.structure.atomMap,r=this.atomTypeIdList;for(let s=0,o=this.atomCount;s500)Le&&we.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(o>50){let f=new Bb(t,!0),m=t.isCg()?1.2:2.3;for(let p=a;p=0||jU(e,t);this.rings={atomRings:e.atomRings,rings:e.rings}}isAromatic(e){return this.aromaticAtoms=this.getAromatic(e),this.aromaticAtoms[e.index-e.residueAtomOffset]===1}calculateAromatic(e){let t=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,r=i.map(o=>function(a){if(a.some(d=>!GU.includes(d.number)))return!1;let l=0,c=new Ht(3,a.length),u=c.data;return a.forEach(d=>{u[l+0]=d.x,u[l+1]=d.y,u[l+2]=d.z,l+=3}),new _g(c).vecC.length()<$U}(o.map(a=>this.structure.getAtomProxy(a+e.atomOffset)))),s=this.aromaticRings=[];i.forEach((o,a)=>{r[a]&&(s.push(o),o.forEach(l=>t[l]=1))})}assignBondReferenceAtomIndices(){let e=this.getBondGraph(),t=this.getRings(),i=t.atomRings,r=t.rings,s=this.bonds,o=s.atomIndices1,a=s.atomIndices2,l=s.bondOrders,c=this.bondReferenceAtomIndices,u=s.atomIndices1.length;c.length=0;for(let d=0;d1)for(let g=0;g1)for(let g=0;g=0;g--)p[_++]=o[g];let y=n.rings.length;for(let g=0;g0?s[f]!==l&&s[l]!==f&&WU(n,l,f):(i[f]=1,r[a++]=f,s[f]=l)}}}var id=4,$b=class{constructor(e){this.structure=e,this.dict={},this.list=[]}add(e,t,i,r="",s){let o=function(l,c,u,d=""){return l+"|"+c.join(",")+"|"+(u?1:0)+"|"+d}(e=e.toUpperCase(),t,i,r),a=this.dict[o];if(a===void 0){let l=new Gb(this.structure,e,t,i,r,s);a=this.list.length,this.dict[o]=a,this.list.push(l)}return a}get(e){return this.list[e]}},Wb=class n{constructor(e,t=0){this.structure=e,this.index=t,this.bondStore=e.bondStore,this._v12=new W,this._v13=new W,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()}get atom1(){return this.structure.getAtomProxy(this.atomIndex1)}get atom2(){return this.structure.getAtomProxy(this.atomIndex2)}get atomIndex1(){return this.bondStore.atomIndex1[this.index]}set atomIndex1(e){this.bondStore.atomIndex1[this.index]=e}get atomIndex2(){return this.bondStore.atomIndex2[this.index]}set atomIndex2(e){this.bondStore.atomIndex2[this.index]=e}get bondOrder(){return this.bondStore.bondOrder[this.index]}set bondOrder(e){this.bondStore.bondOrder[this.index]=e}getOtherAtomIndex(e){return e===this.atomIndex1?this.atomIndex2:this.atomIndex1}getOtherAtom(e){return this.structure.getAtomProxy(this.getOtherAtomIndex(e.index))}getReferenceAtomIndex(){let e=this._ap1,t=this._ap2;if(e.index=this.atomIndex1,t.index=this.atomIndex2,e.residueIndex!==t.residueIndex)return;let i=e.index-e.residueAtomOffset,r=t.index-t.residueAtomOffset,s=e.residueType.getBondReferenceAtomIndex(i,r);if(s!==void 0)return s+e.residueAtomOffset;console.warn("No reference atom found",e.index,t.index)}calculateShiftDir(e=new W){let t=this._ap1,i=this._ap2,r=this._ap3,s=this._v12,o=this._v13;t.index=this.atomIndex1,i.index=this.atomIndex2;let a=this.getReferenceAtomIndex();s.subVectors(t,i).normalize(),a!==void 0?(r.index=a,o.subVectors(t,r)):o.copy(t),o.normalize();let l=s.dot(o);return 1-Math.abs(l)<1e-5&&(o.set(1,0,0),l=s.dot(o),1-Math.abs(l)<1e-5&&(o.set(0,1,0),l=s.dot(o))),e.copy(o.sub(s.multiplyScalar(l))).normalize()}qualifiedName(){return this.atomIndex1+"="+this.atomIndex2}clone(){return new n(this.structure,this.index)}toObject(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}}},jb=class n{constructor(e,t=0){this.structure=e,this.index=t,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueMap=e.residueMap,this.atomMap=e.atomMap}get entity(){return this.structure.entityList[this.entityIndex]}get entityIndex(){return this.chainStore.entityIndex[this.chainIndex]}get chain(){return this.structure.getChainProxy(this.chainIndex)}get chainIndex(){return this.residueStore.chainIndex[this.index]}set chainIndex(e){this.residueStore.chainIndex[this.index]=e}get atomOffset(){return this.residueStore.atomOffset[this.index]}set atomOffset(e){this.residueStore.atomOffset[this.index]=e}get atomCount(){return this.residueStore.atomCount[this.index]}set atomCount(e){this.residueStore.atomCount[this.index]=e}get atomEnd(){return this.atomOffset+this.atomCount-1}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}get chainid(){return this.chainStore.getChainid(this.chainIndex)}get resno(){return this.residueStore.resno[this.index]}set resno(e){this.residueStore.resno[this.index]=e}get sstruc(){return this.residueStore.getSstruc(this.index)}set sstruc(e){this.residueStore.setSstruc(this.index,e)}get inscode(){return this.residueStore.getInscode(this.index)}set inscode(e){this.residueStore.setInscode(this.index,e)}get residueType(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])}get resname(){return this.residueType.resname}get hetero(){return this.residueType.hetero}get moleculeType(){return this.residueType.moleculeType}get backboneType(){return this.residueType.backboneType}get backboneStartType(){return this.residueType.backboneStartType}get backboneEndType(){return this.residueType.backboneEndType}get traceAtomIndex(){return this.residueType.traceAtomIndex+this.atomOffset}get direction1AtomIndex(){return this.residueType.direction1AtomIndex+this.atomOffset}get direction2AtomIndex(){return this.residueType.direction2AtomIndex+this.atomOffset}get backboneStartAtomIndex(){return this.residueType.backboneStartAtomIndex+this.atomOffset}get backboneEndAtomIndex(){return this.residueType.backboneEndAtomIndex+this.atomOffset}get rungEndAtomIndex(){return this.residueType.rungEndAtomIndex+this.atomOffset}get x(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.x[t];return e/this.atomCount}get y(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.y[t];return e/this.atomCount}get z(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.z[t];return e/this.atomCount}eachAtom(e,t){let i=this.atomCount,r=this.atomOffset,s=this.structure._ap,o=r+i;if(t&&t.atomOnlyTest){let a=t.atomOnlyTest;for(let l=r;l0)return this.entity.isPolymer();{let e=this.residueType.moleculeType;return e===3||e===4||e===5}}isHetero(){return this.residueType.hetero===1}isWater(){return this.residueType.moleculeType===1}isIon(){return this.residueType.moleculeType===2}isSaccharide(){return this.residueType.moleculeType===6}isStandardAminoacid(){return this.residueType.isStandardAminoacid()}isStandardBase(){return this.residueType.isStandardBase()}isHelix(){return XP.includes(this.sstruc)}isSheet(){return qP.includes(this.sstruc)}isTurn(){return YP.includes(this.sstruc)&&this.isProtein()}getAtomType(e){return this.atomMap.get(this.atomStore.atomTypeId[e])}getResname1(){return hg[this.resname.toUpperCase()]||"X"}getBackboneType(e){switch(e){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}}getAtomIndexByName(e){let t=this.residueType.getAtomIndexByName(e);return t!==void 0&&(t+=this.atomOffset),t}hasAtomWithName(e){return this.residueType.hasAtomWithName(e)}getAtomnameList(){console.warn("getAtomnameList - might be expensive");let e=this.atomCount,t=this.atomOffset,i=new Array(e);for(let r=0;r=t){let r=U(e,this.structure.getResidueProxy());if(r.index=i,r.connectedTo(this))return r}else if(i===t-1){let r=this.chainStore.residueCount[this.chainIndex],s=U(e,this.structure.getResidueProxy());if(s.index=t+r-1,s.connectedTo(this))return s}}getBonds(){return this.residueType.getBonds(this)}getRings(){return this.residueType.getRings()}getAromaticRings(){return this.residueType.getAromaticRings(this)}qualifiedName(e=!1){let t="";return this.resname&&!e&&(t+="["+this.resname+"]"),this.resno!==void 0&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chain&&(t+=":"+this.chainname),t+="/"+this.modelIndex,t}clone(){return new n(this.structure,this.index)}toObject(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}}},rd=class{constructor(e,t,i){this.structure=e,this.residueIndexStart=t,this.residueIndexEnd=i,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueCount=i-t+1;let r=this.structure.getResidueProxy(this.residueIndexStart),s=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=r.getPreviousConnectedResidue()!==void 0;let o=s.getNextConnectedResidue();this.isNextConnected=o!==void 0,this.isNextNextConnected=o!==void 0&&o.getNextConnectedResidue()!==void 0,this.isCyclic=s.connectedTo(r),this.__residueProxy=this.structure.getResidueProxy()}get chainIndex(){return this.residueStore.chainIndex[this.residueIndexStart]}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}isProtein(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()}isCg(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()}isNucleic(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()}getMoleculeType(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType}getBackboneType(e){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(e)}getAtomIndexByType(e,t){this.isCyclic?e===-1?e=this.residueCount-1:e===this.residueCount&&(e=0):(e!==-1||this.isPrevConnected||(e+=1),e!==this.residueCount||this.isNextNextConnected||(e-=1));let i=this.__residueProxy,r;switch(i.index=this.residueIndexStart+e,t){case"trace":r=i.traceAtomIndex;break;case"direction1":r=i.direction1AtomIndex;break;case"direction2":r=i.direction2AtomIndex;break;default:r=i.getAtomIndexByName(t)}return r}eachAtom(e,t){this.eachResidue(function(i){i.eachAtom(e,t)})}eachAtomN(e,t,i){let r=this.residueCount,s=new Array(e);for(let a=0;a1&&e(new rd(o,i,u.index)),i=r)):(y!==rl&&u.index-i>1&&e(new rd(o,i,u.index)),i=r)}r-i>1&&this.structure.getResidueProxy(i).backboneEndType&&e(new rd(o,i,r))}qualifiedName(){return":"+this.chainname+"/"+this.modelIndex}clone(){return new n(this.structure,this.index)}toObject(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}}},qb=class n{constructor(e,t=0){this.structure=e,this.index=t,this.modelStore=e.modelStore,this.chainStore=e.chainStore,this.residueStore=e.residueStore}get chainOffset(){return this.modelStore.chainOffset[this.index]}set chainOffset(e){this.modelStore.chainOffset[this.index]=e}get chainCount(){return this.modelStore.chainCount[this.index]}set chainCount(e){this.modelStore.chainCount[this.index]=e}get residueOffset(){return this.chainStore.residueOffset[this.chainOffset]}get atomOffset(){return this.residueStore.atomOffset[this.residueOffset]}get chainEnd(){return this.chainOffset+this.chainCount-1}get residueEnd(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1}get atomEnd(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1}get residueCount(){return this.chainCount===0?0:this.residueEnd-this.residueOffset+1}get atomCount(){return this.residueCount===0?0:this.atomEnd-this.atomOffset+1}eachAtom(e,t){this.eachChain(function(i){i.eachAtom(e,t)},t)}eachResidue(e,t){this.eachChain(function(i){i.eachResidue(e,t)},t)}eachPolymer(e,t){if(t&&t.chainOnlyTest){let i=t.chainOnlyTest;this.eachChain(function(r){i(r)&&r.eachPolymer(e,t)})}else this.eachChain(function(i){i.eachPolymer(e,t)})}eachChain(e,t){let i=this.chainCount,r=this.chainOffset,s=this.structure._cp,o=r+i;if(t&&t.test){let a=t.chainOnlyTest;if(a)for(let l=r;l{let g=3*y;l.index=_,u&&l.positionToArray(u,g),d&&o.atomColorToArray(l,d,g),f&&(f.array[y]=_),m&&(m[y]=s.atomRadius(l)),p&&(p[y]=_)}),a}getBondData(e){let t=Object.assign({},e);t.colorParams&&(t.colorParams.structure=this.getStructure());let i=t.what,r=U(t.bondSet,this.bondSet),s=U(t.multipleBond,"off"),o=s!=="off",a=s==="offset",l=U(t.bondScale,.4),c=U(t.bondSpacing,1),u,d,f={},m=this.getBondProxy();t.bondStore&&(m.bondStore=t.bondStore);let p=this.getAtomProxy(),_=this.getAtomProxy(),y;if(o){let N=m.bondStore.bondOrder;y=0,r.forEach(function(H){y+=N[H]})}else y=r.getSize();i&&!i.position||(f.position1=new Float32Array(3*y),f.position2=new Float32Array(3*y)),i&&!i.color||!t.colorParams||(f.color=new Float32Array(3*y),f.color2=new Float32Array(3*y),d=Dt.getScheme(t.colorParams)),i&&!i.picking||(f.picking=new fg(new Float32Array(y),this.getStructure(),t.bondStore)),(!i||i.radius||o&&i.position)&&(u=new Qr(t.radiusParams)),i&&!i.radius||(f.radius=new Float32Array(y),t.radius2&&(f.radius2=new Float32Array(y)));let{position1:g,position2:b,color:h,color2:v,picking:S,radius:x,radius2:w}=f,A,M,T,R,C,P,E=0,I=new W,O=new W,D=new W;return r.forEach(N=>{if(M=3*E,m.index=N,p.index=m.atomIndex1,_.index=m.atomIndex2,R=m.bondOrder,g)if(o&&R>1){let H=u.atomRadius(p);P=H*l/(.5*R),m.calculateShiftDir(D),a?(C=2*c*H,D.multiplyScalar(C),D.negate(),O.subVectors(_,p).multiplyScalar(Math.max(.1,C/1.88)),p.positionToArray(g,M),_.positionToArray(b,M),R>=2&&(I.addVectors(p,D).add(O).toArray(g,M+3),I.addVectors(_,D).sub(O).toArray(b,M+3),R>=3&&(I.subVectors(p,D).add(O).toArray(g,M+6),I.subVectors(_,D).sub(O).toArray(b,M+6)))):(C=(c-l)*H,D.multiplyScalar(C),R===2?(I.addVectors(p,D).toArray(g,M),I.subVectors(p,D).toArray(g,M+3),I.addVectors(_,D).toArray(b,M),I.subVectors(_,D).toArray(b,M+3)):R===3?(p.positionToArray(g,M),I.addVectors(p,D).toArray(g,M+3),I.subVectors(p,D).toArray(g,M+6),_.positionToArray(b,M),I.addVectors(_,D).toArray(b,M+3),I.subVectors(_,D).toArray(b,M+6)):(p.positionToArray(g,M),_.positionToArray(b,M)))}else p.positionToArray(g,M),_.positionToArray(b,M);if(h&&v&&(d.bondColorToArray(m,1,h,M),d.bondColorToArray(m,0,v,M),o&&R>1))for(A=1;A1))for(A=1;A1))for(P=x[E]*l/(a?1:.5*R),A=a?1:0;A1))for(P=w[E]*l/(a?1:.5*R),A=a?1:0;A{let u=c.x,d=c.y,f=c.z;uo&&(o=u),d>a&&(a=d),f>l&&(l=f)},e),t.min.set(i,r,s),t.max.set(o,a,l),Le&&we.timeEnd("getBoundingBox"),t}getPrincipalAxes(e){Le&&we.time("getPrincipalAxes");let t=0,i=new Ht(3,this.atomCount),r=i.data;return this.eachAtom(s=>{r[t+0]=s.x,r[t+1]=s.y,r[t+2]=s.z,t+=3},e),Le&&we.timeEnd("getPrincipalAxes"),new _g(i)}atomCenter(e){return e?this.getBoundingBox(e).getCenter(new W):this.center.clone()}hasCoords(){if(this._hasCoords===void 0){let e=this.atomStore;this._hasCoords=jm(e.x)!==0||Wm(e.x)!==0||jm(e.y)!==0||Wm(e.y)!==0||jm(e.z)!==0||Wm(e.z)!==0||e.count/this.modelStore.count==1}return this._hasCoords}getSequence(e){let t=[],i=this.getResidueProxy();return this.eachAtom(function(r){i.index=r.residueIndex,r.index===i.traceAtomIndex&&t.push(i.getResname1())},e),t}getAtomIndices(e){if(e&&e.string){let t=[];return this.eachAtom(function(i){t.push(i.index)},e),new Uint32Array(t)}{let t={what:{index:!0}};return this.getAtomData(t).index}}getChainnameCount(e){let t=new Set;return this.eachChain(function(i){i.residueCount&&t.add(i.chainname)},e),t.size}updatePosition(e,t=!0){let i=0;this.eachAtom(function(r){r.positionFromArray(e,i),i+=3},void 0),this._hasCoords=void 0,t&&this.refreshPosition()}refreshPosition(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new il(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)}dispose(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet}},gT=new sn,Yv=[jc,ro,Xc,so,ra,$c,ia,Wc,Yc,qc,tl,nl],XU={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2},Yb=class{constructor(e="shape",t={}){this.boundingBox=new sn,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=e,this.parameters=or(t,XU),Yv.forEach(i=>{Object.keys(i.fields).forEach(r=>{this._primitiveData[i.getShapeKey(r)]=[]}),this._primitiveData[i.getShapeKey("name")]=[]})}addBuffer(e){this.bufferList.push(e);let t=e.geometry;return t.boundingBox||t.computeBoundingBox(),this.boundingBox.union(t.boundingBox),this}addMesh(e,t,i,r,s){let o;e=Iv(e),t=Iv(t),Array.isArray(i)&&(i=bs(i,e.length)),r&&(r=Iv(r)),o=r===void 0||r.length==0?{position:e,color:t,index:i}:{position:e,color:t,index:i,normal:r};let a=new pb(this,Object.assign({serial:this.meshCount,name:s},o)),l=new Jr(Object.assign({picking:a},o));return this.bufferList.push(l),gT.setFromArray(e),this.boundingBox.union(gT),this.meshCount+=1,this}addSphere(e,t,i,r){return ia.objectToShape(this,{position:e,color:t,radius:i,name:r}),this}addEllipsoid(e,t,i,r,s,o){return ra.objectToShape(this,{position:e,color:t,radius:i,majorAxis:r,minorAxis:s,name:o}),this}addTorus(e,t,i,r,s,o){return qc.objectToShape(this,{position:e,color:t,radius:i,majorAxis:r,minorAxis:s,name:o}),this}addCylinder(e,t,i,r,s){return so.objectToShape(this,{position1:e,position2:t,color:i,radius:r,name:s}),this}addCone(e,t,i,r,s){return Xc.objectToShape(this,{position1:e,position2:t,color:i,radius:r,name:s}),this}addArrow(e,t,i,r,s){return jc.objectToShape(this,{position1:e,position2:t,color:i,radius:r,name:s}),this}addBox(e,t,i,r,s,o){return ro.objectToShape(this,{position:e,color:t,size:i,heightAxis:r,depthAxis:s,name:o}),this}addOctahedron(e,t,i,r,s,o){return $c.objectToShape(this,{position:e,color:t,size:i,heightAxis:r,depthAxis:s,name:o}),this}addTetrahedron(e,t,i,r,s,o){return Wc.objectToShape(this,{position:e,color:t,size:i,heightAxis:r,depthAxis:s,name:o}),this}addText(e,t,i,r){return Yc.objectToShape(this,{position:e,color:t,size:i,text:r}),this}addPoint(e,t,i){return tl.objectToShape(this,{position:e,color:t,name:i}),this}addWideline(e,t,i,r,s){return this.parameters.linewidth=r,nl.objectToShape(this,{position1:e,position2:t,color:i,name:s}),this}addLabel(e,t,i,r){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(e,t,i,r)}getBufferList(){let e=[];return Yv.forEach(t=>{this._primitiveData[t.getShapeKey("color")].length&&e.push(t.bufferFromShape(this,this.parameters))}),this.bufferList.concat(e)}dispose(){this.bufferList.forEach(function(e){e.dispose()}),this.bufferList.length=0,Yv.forEach(e=>{Object.keys(e.fields).forEach(t=>{this._primitiveData[e.getShapeKey(t)].length=0}),this._primitiveData[e.getShapeKey("name")].length=0})}get center(){return this._center||(this._center=this.boundingBox.getCenter(new W)),this._center}get type(){return"Shape"}},Sg=class extends el{constructor(e,t,i){Array.isArray(e)||(e=[e]),super(e,t,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(i)}init(e){super.init(e),this.build()}create(){this.bufferList.push.apply(this.bufferList,this.buffer)}attach(e){this.bufferList.forEach(t=>{this.viewer.add(t),t.setParameters(this.getBufferParams())}),this.setVisibility(this.visible),e()}},Am=new qe,yT=new Lt,Ms=class extends Jr{constructor(e,t={},i){super(function(l,c){let u=c.attributes.position.array,d=c.index?c.index.array:void 0,f=l.position.length/3,m=u.length/3,p=f*m,_=new Float32Array(3*p),y=new Float32Array(3*p),g=new Float32Array(3*p),b;return d&&(b=bs(f*d.length,p)),{position:_,color:g,index:b,normal:y,primitiveId:l.primitiveId||jx(f,m),picking:l.picking}}(e,i),t),this.updateNormals=!1;let r=i.attributes.position.array,s=i.attributes.normal.array,o=i.index?i.index.array:void 0;this.geoPosition=r,this.geoNormal=s,this.geoIndex=o,this.positionCount=e.position.length/3,this.geoPositionCount=r.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);let a=this.geometry.attributes;if(this.meshPosition=a.position.array,this.meshColor=a.color.array,this.meshNormal=a.normal.array,this.setAttributes(e),o){let l=this.geometry.getIndex();if(!l)return void we.error("Index is null");this.meshIndex=l.array,this.makeIndex()}}setAttributes(e={},t=!1){let i=this.geometry.attributes,r,s,o,a,l,c,u,d,f,m=this.updateNormals;e.position&&(r=e.position,o=this.geoPosition,u=this.meshPosition,l=this.transformedGeoPosition,i.position.needsUpdate=!0,(m||t)&&(a=this.geoNormal,f=this.meshNormal,c=this.transformedGeoNormal,i.normal.needsUpdate=!0)),e.color&&(s=e.color,d=this.meshColor,i.color.needsUpdate=!0);let p=this.positionCount,_=this.geoPositionCount;for(let y=0;y 0.0 ){ +cameraPos = rayDirection * posT + rayOrigin; +interior = true; +flag2 = true; +} +#else +if( calcDepth( cameraPos ) <= 0.0 ){ +cameraPos = rayDirection * posT + rayOrigin; +interior = true; +} +#endif +cameraNormal = normalize( cameraPos - cameraSpherePos ); +cameraNormal *= float(!interior) * 2.0 - 1.0; +return !interior; +} +void main(void){ +bool flag = Impostor( cameraPos, cameraNormal ); +#ifdef NEAR_CLIP +if( calcClip( cameraPos ) > 0.0 ) +discard; +#endif +gl_FragDepthEXT = calcDepth( cameraPos ); +if( !flag ){ +#ifdef NEAR_CLIP +if( flag2 ){ +gl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) ); +}else if( gl_FragDepthEXT >= 0.0 ){ +gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius ); +} +#else +if( gl_FragDepthEXT >= 0.0 ){ +gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius ); +} +#endif +} +if (gl_FragDepthEXT < 0.0) +discard; +if (gl_FragDepthEXT > 1.0) +discard; +#ifdef PICKING +if( opacity < 0.3 ) +discard; +gl_FragColor = vec4( vPickingColor, objectId ); +#else +vec3 vNormal = cameraNormal; +vec3 vViewPosition = -cameraPos; +vec4 diffuseColor = vec4( diffuse, opacity ); +ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); +vec3 totalEmissiveLight = emissive; +#include color_fragment +#include roughnessmap_fragment +#include metalnessmap_fragment +#include normal_fragment_begin +#include lights_physical_fragment +#include lights_fragment_begin +#include lights_fragment_end +vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight; +if( interior ){ +#ifdef USE_INTERIOR_COLOR +outgoingLight.xyz = interiorColor; +#else +#ifdef DIFFUSE_INTERIOR +outgoingLight.xyz = vColor; +#endif +#endif +outgoingLight.xyz *= 1.0 - interiorDarkening; +} +gl_FragColor = vec4( outgoingLight, diffuseColor.a ); +#include premultiplied_alpha_fragment +#include tonemapping_fragment +#include colorspace_fragment +#include fog_fragment +#endif +}`);var bd=class extends Pr{constructor(e,t,i={}){super(t,i),this.index=bs(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:e,value:null}}),this.setAttributes({primitiveId:au(this.size)})}get attributeSize(){return this.size*this.mappingSize}get indexSize(){return this.size*this.mappingIndicesSize}addAttributes(e){let t={};for(let i in e){let r=e[i];t[i]={type:r.type,value:null}}super.addAttributes(t)}getAttributeIndex(e){return 3*e*this.mappingSize}setAttributes(e){e&&!e.position&&e.position1&&e.position2&&(e.position=_s(e.position1,e.position2));let t=this.size,i=this.mappingSize,r=this.geometry.attributes,s,o,a,l,c,u,d;for(let f in e)if(f!=="index"&&f!=="picking"){o=e[f],s=r[f],a=s.itemSize,l=s.array;for(let m=0;m0&&this.parameters.alphaTest<=1&&(t.USE_ALPHATEST=1),t}setUniforms(e){e&&e.edgeBleach!==void 0&&(this.makeTexture(),e.map=this.tex),super.setUniforms(e)}dispose(){super.dispose(),this.tex&&this.tex.dispose()}};cr.add("point",Sd);var Ag=class extends el{constructor(e,t,i){super(e,t,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),e instanceof Hi?(this.surface=void 0,this.volume=new qr(e)):(this.surface=e,this.volume=void 0),this.init(i)}init(e){var t=e||{};t.colorScheme=U(t.colorScheme,"uniform"),t.colorValue=U(t.colorValue,14540253),this.thresholdType=U(t.thresholdType,"sigma"),this.thresholdMin=U(t.thresholdMin,2),this.thresholdMax=U(t.thresholdMax,1/0),this.thresholdOut=U(t.thresholdOut,!1),this.dotType=U(t.dotType,"point"),this.radius=U(t.radius,.1),this.scale=U(t.scale,1),this.pointSize=U(t.pointSize,1),this.sizeAttenuation=U(t.sizeAttenuation,!0),this.sortParticles=U(t.sortParticles,!1),this.useTexture=U(t.useTexture,!1),this.alphaTest=U(t.alphaTest,.5),this.forceTransparent=U(t.forceTransparent,!1),this.edgeBleach=U(t.edgeBleach,0),super.init(t),this.build()}attach(e){this.bufferList.forEach(t=>{this.viewer.add(t)}),this.setVisibility(this.visible),e()}create(){var e={};if(this.volume){var t,i,r=this.volume;this.thresholdType==="sigma"?(t=r.getValueForSigma(this.thresholdMin),i=r.getValueForSigma(this.thresholdMax)):(t=this.thresholdMin,i=this.thresholdMax),r.setFilter(t,i,this.thresholdOut),Object.assign(e,{position:r.getDataPosition(),color:r.getDataColor(this.getColorParams())}),this.dotType==="sphere"&&Object.assign(e,{radius:r.getDataSize(this.radius,this.scale),picking:r.getDataPicking()})}else{var s=this.surface;Object.assign(e,{position:s.getPosition(),color:s.getColor(this.getColorParams())}),this.dotType==="sphere"&&Object.assign(e,{radius:s.getSize(this.radius,this.scale),picking:s.getPicking()})}this.dotType==="sphere"?this.dotBuffer=new la(e,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new Sd(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)}update(e={}){if(this.bufferList.length===0)return;let t={};e.color&&(this.volume?Object.assign(t,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(t,{color:this.surface.getColor(this.getColorParams())})),this.dotType==="sphere"&&(e.radius||e.scale)&&(this.volume?Object.assign(t,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(t,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(t)}setParameters(e,t={},i){return e&&e.thresholdType!==void 0&&this.volume instanceof Hi&&(this.thresholdType==="value"&&e.thresholdType==="sigma"?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):this.thresholdType==="sigma"&&e.thresholdType==="value"&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=e.thresholdType),e&&e.radiusType!==void 0&&(e.radiusType==="radius"?this.radius=.1:this.radius=parseFloat(e.radiusType),t.radius=!0,this.dotType!=="sphere"||ys&&!this.disableImpostor||(i=!0)),e&&e.radius!==void 0&&(t.radius=!0,this.dotType!=="sphere"||ys&&!this.disableImpostor||(i=!0)),e&&e.scale!==void 0&&(t.scale=!0,this.dotType!=="sphere"||ys&&!this.disableImpostor||(i=!0)),super.setParameters(e,t,i),this}};zt.add("shader/Image.vert",`uniform float clipRadius; +uniform vec3 clipCenter; +varying vec2 vUv; +#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING ) +varying vec3 vViewPosition; +#endif +#if defined( RADIUS_CLIP ) +varying vec3 vClipCenter; +#endif +void main() { +#include begin_vertex +#include project_vertex +vUv = uv; +#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING ) +vViewPosition = -mvPosition.xyz; +#endif +#if defined( RADIUS_CLIP ) +vClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz; +#endif +}`),zt.add("shader/Image.frag",`uniform sampler2D map; +uniform float opacity; +uniform vec2 mapSize; +uniform float clipNear; +uniform float clipRadius; +varying vec2 vUv; +#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING ) +varying vec3 vViewPosition; +#endif +#if defined( RADIUS_CLIP ) +varying vec3 vClipCenter; +#endif +#if defined( PICKING ) +uniform sampler2D pickingMap; +uniform float objectId; +#else +#include fog_pars_fragment +#endif +#if defined( CUBIC_INTERPOLATION ) +#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER ) +#if defined( CATMULROM_FILTER ) +const float B = 0.0; +const float C = 0.5; +#elif defined( MITCHELL_FILTER ) +const float B = 0.333; +const float C = 0.333; +#endif +float applyFilter( float x ){ +float f = x; +if( f < 0.0 ){ +f = -f; +} +if( f < 1.0 ){ +return ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) + +( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) + +( 6.0 - 2.0 * B ) ) / 6.0; +}else if( f >= 1.0 && f < 2.0 ){ +return ( ( -B - 6.0 * C ) * ( f * f * f ) ++ ( 6.0 * B + 30.0 * C ) * ( f *f ) + +( - ( 12.0 * B ) - 48.0 * C ) * f + +8.0 * B + 24.0 * C ) / 6.0; +}else{ +return 0.0; +} +} +#elif defined( BSPLINE_FILTER ) +float applyFilter( float x ){ +float f = x; +if( f < 0.0 ){ +f = -f; +} +if( f >= 0.0 && f <= 1.0 ){ +return ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f ); +}else if( f > 1.0 && f <= 2.0 ){ +return 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 ); +} +return 1.0; +} +#else +float applyFilter( float x ){ +return 1.0; +} +#endif +vec4 biCubic( sampler2D tex, vec2 texCoord ){ +vec2 texelSize = 1.0 / mapSize; +texCoord -= texelSize / 2.0; +vec4 nSum = vec4( 0.0 ); +float nDenom = 0.0; +vec2 cell = fract( texCoord * mapSize ); +for( float m = -1.0; m <= 2.0; ++m ){ +for( float n = -1.0; n <= 2.0; ++n ){ +vec4 vecData = texture2D( +tex, texCoord + texelSize * vec2( m, n ) +); +float c = applyFilter( m - cell.x ) * applyFilter( -n + cell.y ); +nSum += vecData * c; +nDenom += c; +} +} +return nSum / nDenom; +} +#endif +void main(){ +#include nearclip_fragment +#include radiusclip_fragment +#if defined( CUBIC_INTERPOLATION ) +gl_FragColor = biCubic( map, vUv ); +#else +gl_FragColor = texture2D( map, vUv ); +#endif +#if defined( PICKING ) +if( gl_FragColor.a < 0.3 ) +discard; +gl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId ); +#else +if( gl_FragColor.a < 0.01 ) +discard; +gl_FragColor.a *= opacity; +#include fog_fragment +#endif +}`);var QU=new Uint16Array([0,1,2,1,3,2]),ez=new Float32Array([0,1,0,0,1,1,1,0]),tz=Object.assign({filter:"nearest",forceTransparent:!0},ki),nz=Object.assign({filter:{updateShader:!0,uniform:!0}},cl),Jb=class extends Pr{constructor(e,t){super({position:e.position,index:QU,picking:e.picking},t),this.parameterTypes=nz,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";let{imageData:i,width:r,height:s}=e,o=new pc(i,r,s);o.flipY=!0,this.tex=o;let a=i.length,l=new Uint8Array(a);for(let u=0;u>16&255,l[u+1]=d>>8&255,l[u+2]=255&d}let c=new pc(l,r,s);c.flipY=!0,c.minFilter=en,c.magFilter=en,this.pickingTex=c,this.addUniforms({map:{value:o},pickingMap:{value:c},mapSize:{value:new Et(r,s)}}),this.geometry.setAttribute("uv",new gn(ez,2))}get defaultParameters(){return tz}getDefines(e){let t=super.getDefines(e),i=this.parameters.filter;return i.startsWith("cubic")&&(t.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?t.BSPLINE_FILTER=1:i.endsWith("catmulrom")?t.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(t.MITCHELL_FILTER=1)),t}updateTexture(){let e=this.tex,t=this.parameters.filter;t.startsWith("cubic")?(e.minFilter=en,e.magFilter=en):t==="linear"?(e.minFilter=li,e.magFilter=li):(e.minFilter=en,e.magFilter=en),e.needsUpdate=!0,this.pickingTex.needsUpdate=!0}makeMaterial(){super.makeMaterial(),this.updateTexture();let e=this.material;e.uniforms.map.value=this.tex,e.blending=hs,e.needsUpdate=!0;let t=this.wireframeMaterial;t.uniforms.map.value=this.tex,t.blending=hs,t.needsUpdate=!0;let i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=hs,i.needsUpdate=!0}setUniforms(e){e&&e.filter!==void 0&&(this.updateTexture(),e.map=this.tex),super.setUniforms(e)}},Qb=class{constructor(e,t){let i=t||{};this.dimension=U(i.dimension,"x"),this.positionType=U(i.positionType,"percent"),this.position=U(i.position,30),this.thresholdType=U(i.thresholdType,"sigma"),this.thresholdMin=U(i.thresholdMin,-1/0),this.thresholdMax=U(i.thresholdMax,1/0),this.normalize=U(i.normalize,!1),this.volume=e}getPositionFromCoordinate(e){let t=this.dimension,i=this.volume,r=i.matrix,s=new W().setFromMatrixPosition(r)[t],o=new W().setFromMatrixScale(r)[t],a;return a=t==="x"?i.nx:t==="y"?i.ny:i.nz,Math.round(((e-s)/(a/100)+1)/o)}getData(e){e=e||{};let t=this.volume,i=t.data,r=t.matrix,s;function o(z){return Math.round(z/100*(s-1))}function a(z,L,F,te){return 3*(F*t.ny*t.nx+L*t.nx+z)+te}s=this.positionType==="coordinate"?this.getPositionFromCoordinate(this.position):this.position;let l=new Float32Array(12),c=new W,u,d,f,m,p,_=0,y=0,g=0,b=t.nx,h=t.ny,v=t.nz;function S(z,L,F,te){c.set(z,L,F).applyMatrix4(r).toArray(l,te)}this.dimension==="x"?(f=o(t.nx),m=t.ny-1,p=t.nz-1,u=t.nz,d=t.ny,_=f,b=_+1,S(f,0,0,0),S(f,m,0,3),S(f,0,p,6),S(f,m,p,9)):this.dimension==="y"?(f=t.nx-1,m=o(t.ny),p=t.nz-1,u=t.nz,d=t.nx,y=m,h=y+1,S(0,m,0,0),S(f,m,0,3),S(0,m,p,6),S(f,m,p,9)):this.dimension==="z"&&(f=t.nx-1,m=t.ny-1,p=o(t.nz),u=t.nx,d=t.ny,g=p,v=g+1,S(0,0,p,0),S(0,m,p,3),S(f,0,p,6),S(f,m,p,9));let x=0,w=0,A=new Uint8Array(u*d*4),M=new Float32Array(u*d),T,R;this.thresholdType==="sigma"?(T=t.getValueForSigma(this.thresholdMin),R=t.getValueForSigma(this.thresholdMax)):(T=this.thresholdMin,R=this.thresholdMax);let C=Object.assign({},e.colorParams,{volume:t});this.normalize&&(C.domain=[0,1]);let P=Dt.getScheme(C),E=new Float32Array(3),I=P.getScale(),O,D=0,N=0;if(this.normalize){D=1/0,O=-1/0;for(let z=y;zO&&(O=te)}N=O-D}for(let z=y;zT&&Q{this.viewer.add(t)}),this.setVisibility(this.visible),e()}create(){let e=new Qb(this.volume,{positionType:this.positionType,position:this.position,dimension:this.dimension,thresholdType:this.thresholdType,thresholdMin:this.thresholdMin,thresholdMax:this.thresholdMax,normalize:this.normalize}),t=new Jb(e.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(t)}};function Zv(n){we.error(`makeRepresentation: representation type ${n} unknown`)}var Tw={name:"some element",status:""},Mg=class{constructor(e,t={}){this.stage=e,this.signals={statusChanged:new Pt.Signal,nameChanged:new Pt.Signal,disposed:new Pt.Signal},this.parameters=or(t,this.defaultParameters),this.uuid=vw()}get defaultParameters(){return Tw}get name(){return this.parameters.name}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}dispose(){this.signals.disposed.dispatch()}},iz=Object.assign({visible:!0},Tw),t2=class extends Mg{constructor(e,t,i={},r){super(e,Object.assign({name:t.type},i)),this.parent=r,this.signals=Object.assign({visibilityChanged:new Pt.Signal,parametersChanged:new Pt.Signal},this.signals),this.setRepresentation(t)}get defaultParameters(){return iz}get visible(){return this.parameters.visible}get type(){return"representation"}getType(){return this.repr.type}setRepresentation(e){this._disposeRepresentation(),this.repr=e,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()}_disposeRepresentation(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())}dispose(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this._disposeRepresentation(),this.signals.disposed.dispatch())}setVisibility(e){return this.parameters.visible=e,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.parameters.visible),this}getVisibility(){return this.parent?this.parent.parameters.visible&&this.parameters.visible:this.parameters.visible}toggleVisibility(){return this.setVisibility(!this.parameters.visible)}updateVisibility(){this.repr.setVisibility(this.getVisibility())}update(e){return this.repr.update(e),this}build(e){return this.repr.build(e),this}setSelection(e){let t=this.repr;return t.setSelection&&t.setSelection(e),this}setParameters(e){return this.repr.setParameters(e),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this}getParameters(){return this.repr.getParameters()}setColor(e){return this.repr.setColor(e),this}},vc=new qe,rz=new W,dI={name:"",status:"",visible:!0},Jc=class{constructor(e,t,i={}){this.stage=e,this.object=t,this.signals={representationAdded:new Pt.Signal,representationRemoved:new Pt.Signal,visibilityChanged:new Pt.Signal,matrixChanged:new Pt.Signal,statusChanged:new Pt.Signal,nameChanged:new Pt.Signal,disposed:new Pt.Signal},this.reprList=[],this.annotationList=[],this.matrix=new qe,this.position=new W,this.quaternion=new Xn,this.scale=new W(1,1,1),this.transform=new qe,this.parameters=or(i,this.defaultParameters),this.uuid=vw(),this.viewer=e.viewer,this.controls=new Ib(this)}get defaultParameters(){return dI}get name(){return this.parameters.name}get status(){return this.parameters.status}get visible(){return this.parameters.visible}setPosition(e){return Array.isArray(e)?this.position.fromArray(e):this.position.copy(e),this.updateMatrix(),this}setRotation(e){if(Array.isArray(e))if(e.length===3){let t=new Ba().fromArray(e);this.quaternion.setFromEuler(t)}else this.quaternion.fromArray(e);else e instanceof Ba?this.quaternion.setFromEuler(e):this.quaternion.copy(e);return this.updateMatrix(),this}setScale(e){return this.scale.set(e,e,e),this.updateMatrix(),this}setTransform(e){return this.transform.copy(e),this.updateMatrix(),this}updateMatrix(){let e=this.getCenterUntransformed(rz);this.matrix.makeTranslation(-e.x,-e.y,-e.z),vc.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply(vc),vc.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply(vc);let t=this.position;vc.makeTranslation(t.x+e.x,t.y+e.y,t.z+e.z),this.matrix.premultiply(vc),this.matrix.premultiply(this.transform),this.updateRepresentationMatrices(),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)}updateRepresentationMatrices(){this.reprList.forEach(e=>{e.setParameters({matrix:this.matrix})})}addAnnotation(e,t,i){let r=new Pb(this,e,t,i);return this.annotationList.push(r),r}eachAnnotation(e){this.annotationList.slice().forEach(e)}removeAnnotation(e){let t=this.annotationList.indexOf(e);t!==-1&&(this.annotationList.splice(t,1),e.dispose())}removeAllAnnotations(){this.eachAnnotation(e=>e.dispose()),this.annotationList.length=0}_addRepresentation(e,t,i,r=!1){let s=i||{},o=this.stage.getParameters();s.matrix=this.matrix.clone(),s.quality=s.quality||o.quality,s.disableImpostor=U(s.disableImpostor,!o.impostor),s.useWorker=U(s.useWorker,o.workerDefault),s.visible=U(s.visible,!0);let a=Object.assign({},s,{visible:this.parameters.visible&&s.visible}),l=function(u,d,f,m){var p;if(Le&&we.time("makeRepresentation "+u),d instanceof Er){if(!(p=on.get(u)))return void Zv(u)}else if(d instanceof Zc)if(u==="surface")p=vd;else{if(u!=="dot")return void Zv(u);p=Ag}else if(d instanceof Hi)if(u==="surface")p=vd;else if(u==="dot")p=Ag;else{if(u!=="slice")return void Zv(u);p=e2}else if(d instanceof Yb)p=Sg,d=d.getBufferList();else{if(u!=="buffer")return void we.error("makeRepresentation: object "+d+" unknown");p=Sg}let _=new p(d,f,m);return Le&&we.timeEnd("makeRepresentation "+u),_}(e,t,this.viewer,a),c=new t2(this.stage,l,s,this);return r||(this.reprList.push(c),this.signals.representationAdded.dispatch(c)),c}addBufferRepresentation(e,t){return this._addRepresentation.call(this,"buffer",e,t)}hasRepresentation(e){return this.reprList.indexOf(e)!==-1}eachRepresentation(e){this.reprList.slice().forEach(e)}removeRepresentation(e){let t=this.reprList.indexOf(e);t!==-1&&(this.reprList.splice(t,1),e.dispose(),this.signals.representationRemoved.dispatch(e))}updateRepresentations(e){this.reprList.forEach(t=>t.update(e)),this.stage.viewer.requestRender()}removeAllRepresentations(){this.eachRepresentation(e=>e.dispose())}dispose(){this.removeAllAnnotations(),this.removeAllRepresentations(),this.reprList.length=0,this.signals.disposed.dispatch()}setVisibility(e){return this.parameters.visible=e,this.eachRepresentation(t=>t.updateVisibility()),this.eachAnnotation(t=>t.updateVisibility()),this.signals.visibilityChanged.dispatch(e),this}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}getBox(...e){return this.getBoxUntransformed(...e).clone().applyMatrix4(this.matrix)}getCenter(...e){return this.getCenterUntransformed(...e).clone().applyMatrix4(this.matrix)}getZoom(...e){return this.stage.getZoomForBox(this.getBox(...e))}getBoxUntransformed(...e){return new sn}getCenterUntransformed(...e){return this.getBoxUntransformed().getCenter(new W)}autoView(e){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),U(e,0))}},Cg=class{constructor(e=[]){this.list=e;let t=e.length;for(let i=0;i0?this.list[0]:void 0}forEach(e){return this.list.forEach(e),this}dispose(){return this.forEach(e=>e.dispose())}},Eg=class extends Cg{setParameters(e){return this.forEach(t=>t.setParameters(e))}setVisibility(e){return this.forEach(t=>t.setVisibility(e))}setSelection(e){return this.forEach(t=>t.setSelection(e))}setColor(e){return this.forEach(t=>t.setColor(e))}update(e){return this.forEach(t=>t.update(e))}build(e){return this.forEach(t=>t.build(e))}dispose(e){return this.forEach(t=>t.dispose())}},sz=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},Tw),n2=class extends Mg{constructor(e,t,i={}){super(e,Object.assign({name:t.name},i)),this.trajectory=t,this.signals=Object.assign(this.signals,{frameChanged:new Pt.Signal,playerChanged:new Pt.Signal,countChanged:new Pt.Signal,parametersChanged:new Pt.Signal}),t.signals.frameChanged.add(r=>{this.signals.frameChanged.dispatch(r)}),t.signals.playerChanged.add(r=>{this.signals.playerChanged.dispatch(r)}),t.signals.countChanged.add(r=>{this.signals.countChanged.dispatch(r)}),i.initialFrame!==void 0&&this.setFrame(i.initialFrame)}get defaultParameters(){return sz}get type(){return"trajectory"}setFrame(e){this.trajectory.setFrame(e)}setParameters(e={}){this.trajectory.setParameters(e),this.signals.parametersChanged.dispatch(e)}dispose(){this.trajectory.dispose(),super.dispose()}},Tg=class{constructor(e,t){this.name=e,this.path=t,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1}get type(){return"Frames"}},Pg=class{constructor(e,t){let i,r;if(this.A=new Ht(3,3),this.W=new Ht(1,3),this.U=new Ht(3,3),this.V=new Ht(3,3),this.VH=new Ht(3,3),this.R=new Ht(3,3),this.tmp=new Ht(3,3),this.c=new Ht(3,3),e instanceof Er)i=e.atomCount;else{if(!(e instanceof Float32Array))return;i=e.length/3}if(t instanceof Er)r=t.atomCount;else{if(!(t instanceof Float32Array))return;r=t.length/3}let s=Math.min(i,r),o=new Ht(3,s),a=new Ht(3,s);this.coords1t=new Ht(s,3),this.coords2t=new Ht(s,3),this.transformationMatrix=new qe,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(e,o,s,!1),this.prepCoords(t,a,s,!1),this._superpose(o,a)}_superpose(e,t){this.mean1=_b(e),this.mean2=_b(t),vb(e,this.mean1),vb(t,this.mean2),Kr(this.coords1t,e),Kr(this.coords2t,t),Ym(this.A,this.coords2t,this.coords1t),iI(this.A,this.W,this.U,this.V),function(f,m){let p=f.data,_=m.data,y=p[4],g=p[8],b=p[5],h=p[7],v=p[0],S=v*y,x=v*b,w=p[3],A=p[1],M=w*A,T=p[2],R=w*T,C=p[6],P=C*A,E=C*T,I=1/(S*g-x*h-M*g+R*h+P*b-E*y);_[0]=(y*g-b*h)*I,_[1]=-(A*g-T*h)*I,_[2]=-(-A*b+T*y)*I,_[3]=-(w*g-b*C)*I,_[4]=(v*g-E)*I,_[5]=-(x-R)*I,_[6]=-(-w*h+y*C)*I,_[7]=-(v*h-P)*I,_[8]=(S-M)*I}(this.V,this.VH),$v(this.R,this.U,this.VH),function(f){let m=f.data;return m[0]*m[4]*m[8]-m[0]*m[5]*m[7]-m[3]*m[1]*m[8]+m[3]*m[2]*m[7]+m[6]*m[1]*m[5]-m[6]*m[2]*m[4]}(this.R)<0&&(Le&&we.log("R not a right handed system"),$v(this.tmp,this.c,this.VH),$v(this.R,this.U,this.tmp));let i=new Ht(4,4),r=new Ht(4,4),s=new Ht(4,4),o=new Ht(4,4),a=new Ht(4,4),l=new Ht(4,4),c=this.R.data,u=this.mean1,d=this.mean2;o.data.set([1,0,0,-u[0],0,1,0,-u[1],0,0,1,-u[2],0,0,0,1]),a.data.set([c[0],c[1],c[2],0,c[3],c[4],c[5],0,c[6],c[7],c[8],0,0,0,0,1]),l.data.set([1,0,0,d[0],0,1,0,d[1],0,0,1,d[2],0,0,0,1]),Kr(r,o),Ym(i,a,r),Kr(s,i),Ym(r,l,s),Kr(i,r),this.transformationMatrix.elements=i.data}prepCoords(e,t,i,r){let s=0,o=t.data,a=3,l=3*i;if(r&&(l=4*i,a=4),e instanceof Er)e.eachAtom(function(c){s{r!==this&&this.pause()},this);let i=U(e.frameCount,1);this.traj=e,this.parameters=or(t,oz),this.parameters.end=Math.min(U(t.end,i-1),i-1),this.parameters.step=U(t.step,Math.ceil((i+1)/100)),this._currentFrame=this.parameters.start,this._direction=this.parameters.direction==="bounce"?"forward":this.parameters.direction,e.signals.countChanged.add(r=>{this.parameters.end=Math.min(U(this.parameters.end,r-1),r-1)},this),this._animate=this._animate.bind(this)}get isRunning(){return this._run}setParameters(e={}){RP(this.parameters,e),e.direction!==void 0&&this.parameters.direction!=="bounce"&&(this._direction=this.parameters.direction)}_animate(){if(!this._run)return;this._currentTime=window.performance.now();let e=this._currentTime-this._previousTime,t=this.parameters.interpolateType?this.parameters.interpolateStep:1,i=this.parameters.timeout/t,r=this.traj;if(r&&r.frameCount&&!r.inProgress&&e>=i)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),this._currentStep===1&&(this._currentFrame=this._nextInterpolated()),r.hasFrame(this._currentFrame)){this._currentStep+=1;let s=this._currentStep/(this.parameters.interpolateStep+1),[o,a,l,c]=this._currentFrame;r.setFrameInterpolated(o,a,l,c,s,this.parameters.interpolateType),this._previousTime=this._currentTime}else r.loadFrame(this._currentFrame);else{let s=this._next();r.hasFrame(s)?(r.setFrame(s),this._previousTime=this._currentTime):r.loadFrame(s)}window.requestAnimationFrame(this._animate)}_next(){let e=this.parameters,t;return t=this._direction==="forward"?this.traj.currentFrame+e.step:this.traj.currentFrame-e.step,(t>e.end||t=e.end?i=e.start:e.direction==="backward"&&t<=e.start&&(i=e.end),this.traj.setFrame(i),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}}pause(){this._run=!1,this.signals.haltedRunning.dispatch()}stop(){this.pause(),this.traj.setFrame(this.parameters.start)}},Qc=class{constructor(e,t,i={}){this.signals={countChanged:new Pt.Signal,frameChanged:new Pt.Signal,playerChanged:new Pt.Signal},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=U(i.deltaTime,0),this.timeOffset=U(i.timeOffset,0),this.centerPbc=U(i.centerPbc,!1),this.removePbc=U(i.removePbc,!1),this.removePeriodicity=U(i.removePeriodicity,!1),this.superpose=U(i.superpose,!1),this.name=e.replace(/^.*[\\/]/,""),this.trajPath=e,this.selection=new tn(U(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add(()=>{this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)})}get frameCount(){return this._frameCount}get currentFrame(){return this._currentFrame}_init(e){this.setStructure(e),this._loadFrameCount(),this.setPlayer(new i2(this))}_loadFrameCount(){}setStructure(e){this.structure=e,this.atomCount=e.atomCount,this.backboneIndices=this._getIndices(new tn("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}_saveInitialCoords(){this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,()=>this._saveInitialCoords())}_saveStructureCoords(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position}setSelection(e){return this.selection.setString(e),this}_getIndices(e){let t=0,i=e.test,r=[];return i&&this.structure.eachAtom(s=>{i(s)&&r.push(t),t+=1}),r}_makeSuperposeCoords(){let e=3*this.selectionIndices.length;this.coords1=new Float32Array(e),this.coords2=new Float32Array(e);let t=this.initialCoords,i=this.coords2;for(let r=0;r!!this.frameCache[t]):!!this.frameCache[e]}setFrame(e,t){return e===void 0||(this.inProgress=!0,e===-1||this.frameCache[e]?(this._updateStructure(e),t&&t()):this.loadFrame(e,()=>{this._updateStructure(e),t&&t()})),this}_interpolate(e,t,i,r,s,o){let a=this.frameCache,l;l=o==="spline"?function(c,u,d,f,m){let p=c.length,_=new Float32Array(p);for(let y=0;y{this._interpolate(e,t,i,r,s,o),a&&a()}):(this._interpolate(e,t,i,r,s,o),a&&a()),this}loadFrame(e,t){Array.isArray(e)?e.forEach(i=>{this.loadQueue[i]||this.frameCache[i]||(this.loadQueue[i]=!0,this._loadFrame(i,()=>{delete this.loadQueue[i]}))}):this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,()=>{delete this.loadQueue[e],t&&t()}))}_loadFrame(e,t){we.error("Trajectory._loadFrame not implemented",e,t)}_updateStructure(e){this._disposed?console.error("updateStructure: traj disposed"):(e===-1?this.structureCoords&&this.structure.updatePosition(this.structureCoords):this.structure.updatePosition(this.frameCache[e]),this.structure.trajectory={name:this.trajPath,frame:e},this._currentFrame=e,this.inProgress=!1,this.signals.frameChanged.dispatch(e))}_doSuperpose(e){let t=3*this.selectionIndices.length,i=this.coords1,r=this.coords2;for(let s=0;s0&&this.centerPbc){let s=[t[0],t[4],t[8]],o=function(a,l,c){return[Fv(l,c[0],3,0,a),Fv(l,c[1],3,1,a),Fv(l,c[2],3,2,a)]}(this.backboneIndices,i,s);(function(a,l,c){if(c[0]===0||c[8]===0||c[4]===0)return;let u=a.length,d=c[0],f=c[1],m=c[2],p=-l[0]+d+d/2,_=-l[1]+f+f/2,y=-l[2]+m+m/2;for(let g=0;g.5&&(o[u+d]-=a[3*d+d]*Math.round(f))}})(i,t,s)}this.removePbc&&function(s,o){if(o[0]===0||o[8]===0||o[4]===0)return;let a=s.length;for(let l=3;l.9*o[3*c+c])if(u>0)for(let d=0;d<3;++d)s[l+d]-=o[3*c+d];else for(let d=0;d<3;++d)s[l+d]+=o[3*c+d]}}(i,t)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(i),this.frameCache[e]=i,this.boxCache[e]=t,this.frameCacheSize+=1}_setFrameCount(e){e!==this._frameCount&&(this._frameCount=e,this.signals.countChanged.dispatch(e))}dispose(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()}setPlayer(e){this.player=e,this.signals.playerChanged.dispatch(e)}getFrameTime(e){return this.timeOffset+e*this.deltaTime}},r2=class extends Qc{constructor(e,t,i){let r=i||{};r.timeOffset=U(r.timeOffset,e.timeOffset),r.deltaTime=U(r.deltaTime,e.deltaTime),super("",t,r),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this._init(t)}get type(){return"frames"}_makeAtomIndices(){this.structure.type==="StructureView"?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0}_loadFrame(e,t){let i,r=this.frames[e];if(this.atomIndices){let a=this.atomIndices,l=a.length;i=new Float32Array(3*l);for(let c=0;c{let o=i.response;if(!o)return void we.error(`empty arrayBuffer for '${r}'`);let a=new Int32Array(o,0,1)[0],l=new Float32Array(o,8,9),c=new Float32Array(o,44);this._process(e,l,c,a),typeof t=="function"&&t()},!1),i.send(s)}_loadFrameCount(){let e=new XMLHttpRequest,t=kv.getCountUrl(this.trajPath);e.open("GET",t,!0),e.addEventListener("load",()=>{this._setFrameCount(parseInt(e.response))},!1),e.send()}},a2=class extends Qc{constructor(e,t,i){super("",t,i),this.requestCallback=e,this._init(t)}get type(){return"callback"}_makeAtomIndices(){let e=[];if(this.structure.type==="StructureView"){let t=this.structure.getAtomIndices(),i=t.length,r=t[0],s=t[0];for(let o=1;o{this._process(i,r,s,o),typeof t=="function"&&t()},e,this.atomIndices)}_loadFrameCount(){this.requestCallback(e=>this._setFrameCount(e))}};Er.prototype.getView=function(n){return new Ig(this,n)};var Ig=class extends Er{constructor(e,t){super(),this.structure=e,this.selection=t,this.center=new W,this.boundingBox=new sn,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy(),this.selection&&this.selection.signals.stringChanged.add(this.refresh,this),this.structure.signals.refreshed.add(this.refresh,this),this.refresh()}init(){}get type(){return"StructureView"}get name(){return this.structure.name}get path(){return this.structure.path}get title(){return this.structure.title}get id(){return this.structure.id}get data(){return this.structure.data}get atomSetDict(){return this.structure.atomSetDict}get biomolDict(){return this.structure.biomolDict}get entityList(){return this.structure.entityList}get unitcell(){return this.structure.unitcell}get frames(){return this.structure.frames}get boxes(){return this.structure.boxes}get validation(){return this.structure.validation}get bondStore(){return this.structure.bondStore}get backboneBondStore(){return this.structure.backboneBondStore}get rungBondStore(){return this.structure.rungBondStore}get atomStore(){return this.structure.atomStore}get residueStore(){return this.structure.residueStore}get chainStore(){return this.structure.chainStore}get modelStore(){return this.structure.modelStore}get atomMap(){return this.structure.atomMap}get residueMap(){return this.structure.residueMap}get bondHash(){return this.structure.bondHash}get spatialHash(){return this.structure.spatialHash}get _hasCoords(){return this.structure._hasCoords}set _hasCoords(e){this.structure._hasCoords=e}refresh(){Le&&we.time("StructureView.refresh"),this.atomSetCache={};let e=this.structure;if(this.selection.isAllSelection()&&e!==this&&e.atomSet&&e.bondSet){this.atomSet=e.atomSet.clone(),this.bondSet=e.bondSet.clone();for(let t in this.atomSetDict){let i=this.atomSetDict[t];this.atomSetCache["__"+t]=i.clone()}this.atomCount=e.atomCount,this.bondCount=e.bondCount,this.boundingBox.copy(e.boundingBox),this.center.copy(e.center)}else if(this.selection.isNoneSelection()&&e!==this&&e.atomSet&&e.bondSet){this.atomSet=new ii(e.atomCount),this.bondSet=new ii(e.bondCount);for(let t in this.atomSetDict)this.atomSetCache["__"+t]=new ii(e.atomCount);this.atomCount=0,this.bondCount=0,this.boundingBox.makeEmpty(),this.center.set(0,0,0)}else{this.atomSet=this.getAtomSet(this.selection,!0),e.atomSet&&(this.atomSet=this.atomSet.intersection(e.atomSet)),this.bondSet=this.getBondSet();for(let t in this.atomSetDict){let i=this.atomSetDict[t];this.atomSetCache["__"+t]=i.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(new W)}Le&&we.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()}setSelection(e){this.selection=e,this.refresh()}getSelection(e){let t=[];e&&e.string&&t.push(e.string);let i=this.structure.getSelection();i&&i.string&&t.push(i.string),this.selection&&this.selection.string&&t.push(this.selection.string);let r="";return t.length>0&&(r=`( ${t.join(" ) AND ( ")} )`),new tn(r)}getStructure(){return this.structure.getStructure()}eachBond(e,t){this.structure.eachBond(e,this.getSelection(t))}eachAtom(e,t){let i=this.getAtomProxy(),r=this.getAtomSet(t),s=this.atomStore.count;if(r.getSize()=this.V[i][r]?(t="S",this.score=this.S[i][r]):this.V[i][r]>=this.H[i][r]?(t="V",this.score=this.V[i][r]):(t="H",this.score=this.H[i][r]),Le&&we.log("Alignment: SCORE",this.score),Le&&we.log("Alignment: S, V, H",this.S[i][r],this.V[i][r],this.H[i][r]);i>0&&r>0;)t==="S"?this.S[i][r]===this.S[i-1][r-1]+e(i-1,r-1)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--i,--r,t="S"):this.S[i][r]===this.V[i][r]?t="V":this.S[i][r]===this.H[i][r]?t="H":(--i,--r):t==="V"?this.V[i][r]===this.V[i-1][r]+this.gapExtensionPenalty?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,t="V"):this.V[i][r]===this.S[i-1][r]+this.gap(0)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,t="S"):--i:t==="H"?this.H[i][r]===this.H[i][r-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,t="H"):this.H[i][r]===this.S[i][r-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,t="S"):--r:we.error("Alignment: no matrix");for(;i>0;)this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i;for(;r>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r;Le&&we.timeEnd("Alignment.trace"),Le&&we.log([this.ali1,this.ali2])}};function cz(n,e,t=!1,i="",r=""){let s,o,a,l,c;if(t){let d=n,f=e;i&&r&&(d=n.getView(new tn(i)),f=e.getView(new tn(r)));let m=d.getSequence(),p=f.getSequence(),_=new l2(m.join(""),p.join("")),y,g;_.calc(),_.trace(),s=0,o=0,a=_.ali1.length;let b=[],h=[];for(let A=0;Ar[s])}}}(),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:Fh.opacity,color:Fh.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",Fh,!0),this.angleRepresentation=this.addRepresentation("angle",Fh,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",Fh,!0),this.measureRepresentations=new Eg([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add(()=>{this.updateRepresentations({position:!0})})}get defaultParameters(){return uz}get type(){return"structure"}initSelection(e){this.selection=new tn(e),this.structureView=new Ig(this.structure,this.selection),this.selection.signals.stringChanged.add(()=>{this.structureView.setSelection(this.selection),this.rebuildRepresentations(),this.rebuildTrajectories()})}setSelection(e){return this.parameters.sele=e,this.selection.setString(e),this}setDefaultAssembly(e){if(this.structure.biomolDict[e]===void 0&&(e=""),this.parameters.defaultAssembly!==e){let t={defaultAssembly:e};this.reprList.forEach(i=>i.setParameters(t)),this.measureRepresentations.setParameters(t),this.parameters.defaultAssembly=e,this.signals.defaultAssemblyChanged.dispatch(e)}return this}rebuildRepresentations(){this.reprList.forEach(e=>{e.build()}),this.measureRepresentations.build()}rebuildTrajectories(){this.trajList.forEach(e=>{e.trajectory.setStructure(this.structureView)})}updateRepresentations(e){super.updateRepresentations(e),this.measureRepresentations.update(e)}updateRepresentationMatrices(){super.updateRepresentationMatrices(),this.measureRepresentations.setParameters({matrix:this.matrix})}addRepresentation(e,t={},i=!1){t.defaultAssembly=this.parameters.defaultAssembly;let r=this._addRepresentation(e,this.structureView,t,i);return i||r.signals.parametersChanged.add(()=>this.measureUpdate()),r}addTrajectory(e="",t={}){let i=function(s,o,a){let l;return l=s&&s instanceof Tg?new r2(s,o,a):!s&&o.frames?new s2(s,o,a):s&&typeof s=="function"?new a2(s,o,a):new o2(s,o,a),l}(e,this.structureView,t),r=new n2(this.stage,i,t);return this.trajList.push(r),this.signals.trajectoryAdded.dispatch(r),r}removeTrajectory(e){let t=this.trajList.indexOf(e);t!==-1&&this.trajList.splice(t,1),e.dispose(),this.signals.trajectoryRemoved.dispatch(e)}dispose(){this.trajList.slice().forEach(e=>e.dispose()),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),super.dispose()}autoView(e,t){typeof e=="number"&&(t=e,e=""),this.stage.animationControls.zoomMove(this.getCenter(e),this.getZoom(e),U(t,0))}getBoxUntransformed(e){let t;return t=e?this.structureView.getBoundingBox(new tn(e)):this.structureView.boundingBox,t}getCenterUntransformed(e){return e&&typeof e=="string"?this.structure.atomCenter(new tn(e)):this.structure.center}superpose(e,t,i,r){return cz(this.structureView,e.structureView,t,i,r),this.updateRepresentations({position:!0}),this}getMaxRepresentationRadius(e){let t=0,i=this.structure.getAtomProxy(e);return this.eachRepresentation(r=>{if(r.getVisibility()){let s=r.repr;t=Math.max(s.getAtomRadius(i),t)}}),t}measurePick(e){let t=this.pickBuffer.count;if(this.lastPick===e.index&&t>=1){if(t>1){let i=this.pickBuffer.data,r=this.pickBuffer.data.sort();this.pickDict.has(r)?this.pickDict.del(r):this.pickDict.add(r,i),t===2?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter(s=>s.length===2)}):t===3?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter(s=>s.length===3)}):t===4&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter(s=>s.length===4)})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(e.index)||this.pickBuffer.push(e.index),this.lastPick=e.index;this.measureUpdate()}measureClear(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")}measureBuild(){let e=this.measureData();this.distanceRepresentation.setParameters({atomPair:e.distance}),this.angleRepresentation.setParameters({atomTriple:e.angle}),this.dihedralRepresentation.setParameters({atomQuad:e.dihedral})}measureUpdate(){let e=this.pickBuffer.data,t={};e.forEach(i=>{let r=Math.max(.1,this.getMaxRepresentationRadius(i));t[i]=r*(2.3-Pd(.1,2,r))}),this.spacefillRepresentation.setSelection(e.length?"@"+e.join(","):"none"),e.length&&this.spacefillRepresentation.setParameters({radiusData:t})}measureData(){let e=this.pickDict.values;return{distance:e.filter(t=>t.length===2),angle:e.filter(t=>t.length===3),dihedral:e.filter(t=>t.length===4)}}removeAllMeasurements(e){let t=this.pickDict,i=t.values,r=function(s){i.filter(o=>o.length===s).forEach(o=>t.del(o.slice().sort()))};(!e||1&e)&&r(2),(!e||2&e)&&r(3),(!e||4&e)&&r(4),this.measureBuild()}removeMeasurement(e){this.pickDict.del(e.slice().sort()),this.measureBuild()}addMeasurement(e){if(e.length<2||e.length>4)return;let t=e.slice().sort();this.pickDict.has(t)||this.pickDict.add(t,e),this.measureBuild()}};Gc.add("structure",Ad),Gc.add("structureview",Ad);var Rg=class extends Jc{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.surface=t}get type(){return"surface"}addRepresentation(e,t={}){return this._addRepresentation(e,this.surface,t)}getBoxUntransformed(){return this.surface.boundingBox}getCenterUntransformed(){return this.surface.center}dispose(){this.surface.dispose(),super.dispose()}};Gc.add("surface",Rg);var kg=class extends Jc{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.volume=t}get type(){return"volume"}addRepresentation(e,t={}){return this._addRepresentation(e,this.volume,t)}getBoxUntransformed(){return this.volume.boundingBox}getCenterUntransformed(){return this.volume.center}dispose(){this.volume.dispose(),super.dispose()}};Gc.add("volume",kg);var Lg=class extends Cg{addRepresentation(e,t){return this.forEach(i=>i.addRepresentation(e,t))}autoView(e){return this.forEach(t=>t.autoView(e))}};function xT(n,e){return n instanceof RegExp?e.name.match(n)!==null:e.name===n}var hz=new W,dz={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1.2,ambientColor:14540253,ambientIntensity:.3,hoverTimeout:0,tooltip:!0,mousePreset:"default"},Dg=class{constructor(e,t={}){this.signals={parametersChanged:new Pt.Signal,fullscreenChanged:new Pt.Signal,componentAdded:new Pt.Signal,componentRemoved:new Pt.Signal,clicked:new Pt.Signal,hovered:new Pt.Signal},this.tasks=new ig,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new Xx(e),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new qx(this.viewer.renderer.domElement),this.viewerControls=new Jx(this),this.trackballControls=new Yx(this),this.pickingControls=new Kx(this),this.animationControls=new ib(this),this.mouseControls=new Sb(this),this.keyControls=new Ab(this),this.pickingBehavior=new Mb(this),this.mouseBehavior=new Cb(this),this.animationBehavior=new Eb(this),this.keyBehavior=new Tb(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=or(t,dz),this.setParameters(this.parameters),this.viewer.animate())}setParameters(e={}){RP(this.parameters,e);let t=e,i=this.parameters,r=this.viewer,s=this.trackballControls;return t.quality!==void 0&&this.setQuality(i.quality),t.impostor!==void 0&&this.setImpostor(i.impostor),t.rotateSpeed!==void 0&&(s.rotateSpeed=i.rotateSpeed),t.zoomSpeed!==void 0&&(s.zoomSpeed=i.zoomSpeed),t.panSpeed!==void 0&&(s.panSpeed=i.panSpeed),t.mousePreset!==void 0&&this.mouseControls.preset(i.mousePreset),this.mouseObserver.setParameters({hoverTimeout:i.hoverTimeout}),r.setClip(i.clipNear,i.clipFar,i.clipDist,i.clipMode,i.clipScale),r.setFog(void 0,i.fogNear,i.fogFar),r.setCamera(i.cameraType,i.cameraFov,i.cameraEyeSep),r.setSampling(i.sampleLevel),r.setBackground(i.backgroundColor),r.setLight(i.lightColor,i.lightIntensity,i.ambientColor,i.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this}log(e){console.log("STAGE LOG",e),this.logList.push(e)}getParameters(){return Object.assign({},this.parameters)}defaultFileRepresentation(e){if(e instanceof Ad){let t,i,r;e.setSelection("/0");let s=e.structure;if(s.biomolDict.BU1){let d=s.biomolDict.BU1;t=d.getAtomCount(s),i=d.getResidueCount(s),r=d.getInstanceCount(),e.setDefaultAssembly("BU1")}else t=s.getModelProxy(0).atomCount,i=s.getModelProxy(0).residueCount,r=1;let o=t;BP&&(o*=4);let a=s.atomStore.count/s.residueStore.count<2;a&&(o*=10);let l="chainname",c="RdYlBu",u=!1;if(s.getChainnameCount(new tn("polymer and /0"))===1&&(l="residueindex",c="Spectral",u=!0),Le&&console.log(o,t,r,a),i/r<4)e.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(r>5&&o>15e3||o>7e5){let d=Math.min(2,Math.max(.1,6e3/(o/r)));a&&(d=Math.min(d,.5)),e.addRepresentation("surface",{colorScheme:l,colorScale:c,colorReverse:u,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:d,useWorker:!1})}else o>25e4?e.addRepresentation("backbone",{colorScheme:l,colorScale:c,colorReverse:u,lineOnly:!0}):o>1e5?e.addRepresentation("backbone",{colorScheme:l,colorScale:c,colorReverse:u,quality:"low",disableImpostor:!0,radiusScale:2}):o>8e4?e.addRepresentation("backbone",{colorScheme:l,colorScale:c,colorReverse:u,radiusScale:2}):(e.addRepresentation("cartoon",{colorScheme:l,colorScale:c,colorReverse:u,radiusScale:.7,aspectRatio:5,quality:"auto"}),o<5e4&&e.addRepresentation("base",{colorScheme:l,colorScale:c,colorReverse:u,quality:"auto"}),e.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));e.structure.frames.length&&e.addTrajectory()}else(e instanceof Rg||e instanceof kg)&&e.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)}loadFile(e,t={}){let i=Object.assign({},this.defaultFileParams,t),r=Gi(e).name;this.tasks.increment(),this.log(`loading file '${r}'`);let s=U(i.ext,Gi(e).ext),o;return o=At.isTrajectory(s)?Promise.reject(new Error(`loadFile: ext '${s}' is a trajectory and must be loaded into a structure component`)):OE(e,i),o.then(a=>{this.log(`loaded '${r}'`);let l=this.addComponentFromObject(a,i);return i.defaultRepresentation&&this.defaultFileRepresentation(l),this.tasks.decrement(),l},a=>{this.tasks.decrement();let l=`error loading file: '${a}'`;throw this.log(l),l})}loadScript(e){let t=Gi(e).name;return this.log(`loading script '${t}'`),OE(e).then(i=>{this.tasks.increment(),this.log(`running script '${t}'`),i.run(this).then(()=>{this.tasks.decrement(),this.log(`finished script '${t}'`)}),this.log(`called script '${t}'`)},i=>{this.tasks.decrement();let r=`errored script '${t}' "${i}"`;throw this.log(r),r})}addComponent(e){e?(this.compList.push(e),this.signals.componentAdded.dispatch(e)):we.warn("Stage.addComponent: no component given")}addComponentFromObject(e,t={}){let i=Gc.get(e.type);if(i){let r=new i(this,e,t);return this.addComponent(r),r}we.warn("no component for object type",e.type)}removeComponent(e){let t=this.compList.indexOf(e);t!==-1&&(this.compList.splice(t,1),e.dispose(),this.signals.componentRemoved.dispatch(e))}removeAllComponents(){this.compList.slice().forEach(e=>this.removeComponent(e))}handleResize(){this.viewer.handleResize()}setSize(e,t){let i=this.viewer.container;i!==document.body&&(e!==void 0&&(i.style.width=e),t!==void 0&&(i.style.height=t),this.handleResize())}toggleFullscreen(e){if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void we.log("fullscreen mode (currently) not possible");let t=this;function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){if(!i()&&t.lastFullscreenElement){let s=t.lastFullscreenElement;s.style.width=s.dataset.normalWidth||"",s.style.height=s.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",r),document.removeEventListener("mozfullscreenchange",r),document.removeEventListener("webkitfullscreenchange",r),document.removeEventListener("MSFullscreenChange",r),t.handleResize(),t.signals.fullscreenChanged.dispatch(!1)}}e=e||this.viewer.container,this.lastFullscreenElement=e,i()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(e.dataset.normalWidth=e.style.width||"",e.dataset.normalHeight=e.style.height||"",e.style.width=window.screen.width+"px",e.style.height=window.screen.height+"px",e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",r),document.addEventListener("mozfullscreenchange",r),document.addEventListener("webkitfullscreenchange",r),document.addEventListener("MSFullscreenChange",r),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout(function(){t.handleResize()},100))}setSpin(e){e?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)}setRock(e){e?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)}toggleSpin(){this.setSpin(this.spinAnimation.paused)}toggleRock(){this.setRock(this.rockAnimation.paused)}getFocus(){let e=this.parameters;if(e.clipMode!=="scene")return 0;let t=e.clipNear;return e.clipScale==="absolute"&&(t=this.viewer.absoluteToRelative(t)),2*t}setFocus(e){if(this.parameters.clipMode!=="scene")return;let t,i,r,s;this.parameters.clipScale==="relative"?(t=Fx(e/2,0,49.9),i=100-t,r=50,s=function(o){return Fx(o,0,100)}(2*i-50)):(t=this.viewer.relativeToAbsolute(e/2),i=t,r=0,s=2*i),this.setParameters({clipNear:t,clipFar:i,fogNear:r,fogFar:s})}getZoomForBox(e){let t=e.getSize(hz),i=Math.max(t.x,t.y,t.z),r=Math.min(t.x,t.y,t.z),s=i+Math.sqrt(r),o=En(this.viewer.perspectiveCamera.fov),a=this.viewer.width,l=this.viewer.height,c=l{this.tasks.onZeroOnce(()=>{this.tasks.increment(),this.viewer.makeImage(e).then(r=>{this.tasks.decrement(),t(r)}).catch(r=>{this.tasks.decrement(),i(r)})})})}setImpostor(e){this.parameters.impostor=e;let t=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation(function(i){if(!t.includes(i.getType()))return;let r=i.getParameters();r.disableImpostor=!e,i.build(r)})}setQuality(e){this.parameters.quality=e;let t=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation(function(r){let s=r.getParameters();if(!t.includes(r.getType())){if(!i.includes(r.getType()))return;if(!s.disableImpostor)return void(r.repr.quality=e)}s.quality=e,r.build(s)})}eachComponent(e,t){this.compList.slice().forEach(i=>{t!==void 0&&t!==i.type||e(i)})}eachRepresentation(e,t){this.eachComponent(i=>{i.reprList.slice().forEach(r=>{t!==void 0&&t!==r.getType()||e(r,i)})})}getComponentsByName(e){let t=[];return this.eachComponent(i=>{(e===void 0||xT(e,i))&&t.push(i)}),new Lg(t)}getComponentsByObject(e){let t=[];return this.eachComponent(i=>{i.object===e&&t.push(i)}),new Lg(t)}getRepresentationsByName(e){let t=[];return this.eachRepresentation((i,r)=>{(e===void 0||xT(e,i))&&t.push(i)}),new Eg(t)}measureClear(){this.eachComponent(e=>e.measureClear(),"structure")}measureUpdate(){this.eachComponent(e=>e.measureUpdate(),"structure")}dispose(){this.tasks.dispose(),this.viewer.dispose(),this.mouseObserver.dispose()}},c2=class extends Jc{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.shape=t}get type(){return"shape"}addRepresentation(e,t={}){return this._addRepresentation(e,this.shape,t)}getBoxUntransformed(){return this.shape.boundingBox}getCenterUntransformed(){return this.shape.center}dispose(){this.shape.dispose(),super.dispose()}};function qt(n,e,t,i){var r,s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,e,t,i);else for(var a=n.length-1;a>=0;a--)(r=n[a])&&(o=(s<3?r(o):s>3?r(e,t,o):r(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}function fI(n,e,t,i){return new(t||(t=Promise))(function(r,s){function o(c){try{l(i.next(c))}catch(u){s(u)}}function a(c){try{l(i.throw(c))}catch(u){s(u)}}function l(c){c.done?r(c.value):function(u){return u instanceof t?u:new t(function(d){d(u)})}(c.value).then(o,a)}l((i=i.apply(n,e||[])).next())})}Gc.add("shape",c2),typeof SuppressedError=="function"&&SuppressedError;var Ng=class extends Yt{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=U(e.reverse,!0)),this.scalePerModel={},e.structure.eachModel(t=>{this.parameters.domain=[t.atomOffset,t.atomEnd],this.scalePerModel[t.index]=this.getScale()})}atomColor(e){return this.scalePerModel[e.modelIndex](e.index)}};qt([Xt],Ng.prototype,"atomColor",null),Dt.add("atomindex",Ng);var Fg=class extends Yt{constructor(e){if(super(e),e.scale||(this.parameters.scale="OrRd"),!e.domain){let t,i=1/0,r=-1/0;e.sele&&(t=new tn(e.sele)),e.structure.eachAtom(function(s){let o=s.bfactor;i=Math.min(i,o),r=Math.max(r,o)},t),this.parameters.domain=[i,r]}this.bfactorScale=this.getScale()}atomColor(e){return this.bfactorScale(e.bfactor)}};qt([Xt],Fg.prototype,"atomColor",null),Dt.add("bfactor",Fg);var Og=class extends Yt{constructor(e){super(e),this.chainidDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel(t=>{let i=0,r={};t.eachChain(function(s){r[s.chainid]===void 0&&(r[s.chainid]=i,i+=1)}),this.parameters.domain=[0,i-1],this.chainidDictPerModel[t.index]=r,this.scalePerModel[t.index]=this.getScale()})}atomColor(e){let t=this.chainidDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainid])}};qt([Xt],Og.prototype,"atomColor",null),Dt.add("chainid",Og);var Bg=class extends Yt{constructor(e){super(e),this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel(t=>{this.parameters.domain=[t.chainOffset,t.chainEnd],this.scalePerModel[t.index]=this.getScale()})}atomColor(e){return this.scalePerModel[e.modelIndex](e.chainIndex)}};qt([Xt],Bg.prototype,"atomColor",null),Dt.add("chainindex",Bg);var Ug=class extends Yt{constructor(e){super(e),this.chainnameDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel(t=>{let i=0,r={};t.eachChain(function(s){r[s.chainname]===void 0&&(r[s.chainname]=i,i+=1)}),this.parameters.domain=[0,i-1],this.chainnameDictPerModel[t.index]=r,this.scalePerModel[t.index]=this.getScale()})}atomColor(e){let t=this.chainnameDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainname])}};qt([Xt],Ug.prototype,"atomColor",null),Dt.add("chainname",Ug);var zg=class extends Yt{constructor(e){super(e),this.rsrzDict={},this.rsccDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});let t=e.structure.validation;t&&(this.rsrzDict=t.rsrzDict,this.rsccDict=t.rsccDict)}atomColor(e){let t=e.resno+"";e.inscode&&(t+="^"+e.inscode),e.chainname&&(t+=":"+e.chainname),t+="/"+e.modelIndex;let i=this.rsrzDict[t];if(i!==void 0)return this.rsrzScale(i);let r=this.rsccDict[t];return r!==void 0?this.rsccScale(r):9474192}};qt([Xt],zg.prototype,"atomColor",null),Dt.add("densityfit",zg);var Kv={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}},Vg=class extends Yt{constructor(e){super(e),this.delta=new W,this.hCharges=[],e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(e.structure.atomCount);let t=[];e.structure.eachAtom(r=>{var s;if(this.charges[r.index]=((s=r).partialCharge!==null?s.partialCharge:s.isProtein()&&(Kv[s.resname]&&Kv[s.resname][s.atomname]||Kv.backbone[s.atomname])||0)*r.occupancy,r.atomname==="N"){if(r.bondCount>=3||r.bondToElementCount(1))return;let o=function(a,l=new W){let c=!1,u=!1,d=!1;return l.set(2*a.x,2*a.y,2*a.z),a.eachBondedAtom(function(f){if(!c)return f.atomname==="H"?(l.set(f.x,f.y,f.z),void(c=!0)):void(u||f.atomname!=="CA"?d||f.atomname!=="C"||(d=!0,l.sub(f)):(l.sub(f),u=!0))}),c?l:u&&d?(l.normalize(),l.multiplyScalar(1.04),l.add(a),l):void 0}(r);o!==void 0&&(t.push(o),this.hCharges.push(.25*r.occupancy))}});let i=e.structure.getBoundingBox();i.expandByScalar(1.04),this.hStore=function(r){let s=r.length,o=new Float32Array(s),a=new Float32Array(s),l=new Float32Array(s);for(let c=0;c{let a=t[s];a!==0&&(r+=a/o)}),this.hHash.eachWithin(e.x,e.y,e.z,12,(s,o)=>{let a=i[s];a!==0&&(r+=a/o)}),this.scale(332*r)}};qt([Xt],Vg.prototype,"positionColor",null),Dt.add("electrostatic",Vg);var bT={H:16777215,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,D:16777152,T:16777120},Hg=class extends Yt{constructor(e){e.value=U(e.value,bT.C),super(e)}atomColor(e){let t=e.element;return t==="C"?this.parameters.value:bT[t]||16777215}};qt([Xt],Hg.prototype,"atomColor",null),Dt.add("element",Hg);var Gg=class extends Yt{constructor(e){super(e),e.scale||(this.parameters.scale="Spectral"),e.domain||(this.parameters.domain=[0,e.structure.entityList.length-1]),this.entityindexScale=this.getScale()}atomColor(e){return this.entityindexScale(e.entityIndex)}};qt([Xt],Gg.prototype,"atomColor",null),Dt.add("entityindex",Gg);var $g=class extends Yt{atomColor(e){let t=e.entity;switch(t?t.entityType:void 0){case 1:return 8374655;case 2:return 16629894;case 3:return 12496596;case 4:return 3697840;default:return 16777113}}};qt([Xt],$g.prototype,"atomColor",null),Dt.add("entitytype",$g);var Wg=class extends Yt{constructor(e){super(e),this.geoAtomDict={},this.geoDict={};let t=e.structure.validation;t&&(this.geoAtomDict=t.geoAtomDict,this.geoDict=t.geoDict)}atomColor(e){let t,i=e.resno+"";e.inscode&&(i+="^"+e.inscode),e.chainname&&(i+=":"+e.chainname),i+="/"+e.modelIndex;let r=this.geoAtomDict[i];r!==void 0?(s=r[e.atomname]||0,t=16843009*((s=(858993459&(s-=s>>1&1431655765))+(s>>2&858993459))+(s>>4)&252645135)>>24):t=this.geoDict[i]||0;var s;return t===0?2188972:t===1?16703627:t===2?16018755:t>=3?10813478:9474192}};qt([Xt],Wg.prototype,"atomColor",null),Dt.add("geoquality",Wg);var jg=class extends Yt{constructor(e){super(e),this.resHF={},e.scale||(this.parameters.scale="RdYlGn");for(let t in tT)this.resHF[t]=tT[t][0];if(this.defaultResidueHydrophobicity=JB[0],!e.domain){let t=1/0,i=-1/0;for(let r in this.resHF){let s=this.resHF[r];t=Math.min(t,s),i=Math.max(i,s)}this.parameters.domain=[t,0,i]}this.hfScale=this.getScale()}atomColor(e){return this.hfScale(this.resHF[e.resname]||this.defaultResidueHydrophobicity)}};qt([Xt],jg.prototype,"atomColor",null),Dt.add("hydrophobicity",jg);var Xg=class extends Yt{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow"),e.domain||(this.parameters.domain=[0,e.structure.modelStore.count]),this.modelindexScale=this.getScale()}atomColor(e){return this.modelindexScale(e.modelIndex)}};qt([Xt],Xg.prototype,"atomColor",null),Dt.add("modelindex",Xg);var qg=class extends Yt{atomColor(e){switch(e.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}}};qt([Xt],qg.prototype,"atomColor",null),Dt.add("moleculetype",qg);var Yg=class extends Yt{constructor(e){super(e),e.scale||(this.parameters.scale="PuBu"),e.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}atomColor(e){return this.occupancyScale(e.occupancy)}};qt([Xt],Yg.prototype,"atomColor",null),Dt.add("occupancy",Yg);var Zg=class extends Yt{constructor(e){super(e),e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}atomColor(e){return this.partialchargeScale(e.partialCharge||0)}};function Jv(){return 16777215*Math.random()}qt([Xt],Zg.prototype,"atomColor",null),Dt.add("partialcharge",Zg);var Ic=class extends Yt{atomColor(){return Jv()}volumeColor(){return Jv()}positionColor(){return Jv()}};qt([Xt],Ic.prototype,"atomColor",null),qt([Xt],Ic.prototype,"volumeColor",null),qt([Xt],Ic.prototype,"positionColor",null),Dt.add("random",Ic);var Kg=class extends Yt{constructor(e){super(e),this.rciDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});let t=e.structure.validation;t&&(this.rciDict=t.rciDict)}atomColor(e){let t=`[${e.resname}]${e.resno}`;e.chainname&&(t+=":"+e.chainname);let i=this.rciDict[t];return i!==void 0?this.rciScale(i):9474192}};qt([Xt],Kg.prototype,"atomColor",null),Dt.add("randomcoilindex",Kg);var Jg=class extends Yt{constructor(e){super(e),this.scalePerChain={},e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=U(e.reverse,!0)),e.structure.eachChain(t=>{this.parameters.domain=[t.residueOffset,t.residueEnd],this.scalePerChain[t.index]=this.getScale()})}atomColor(e){return this.scalePerChain[e.chainIndex](e.residueIndex)}};qt([Xt],Jg.prototype,"atomColor",null),Dt.add("residueindex",Jg);var fz={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723},Qg=class extends Yt{atomColor(e){return fz[e.resname]||16711935}};qt([Xt],Qg.prototype,"atomColor",null),Dt.add("resname",Qg);var pz=16711808,mz=10485888,gz=6291584,yz=16762880,_z=6324479,vz=16777215,xz=11403518,bz=16580962,wz=10921722,e0=class extends Yt{constructor(e){super(e),this.residueProxy=e.structure.getResidueProxy()}atomColor(e){let t=e.sstruc,i=this.residueProxy;return t==="h"?pz:t==="g"?mz:t==="i"?gz:t==="e"||t==="b"?yz:t==="t"?_z:(i.index=e.residueIndex,i.isDna()?xz:i.isRna()?bz:i.isSaccharide()?wz:i.isProtein()||t==="s"||t==="l"?vz:8421504)}};qt([Xt],e0.prototype,"atomColor",null),Dt.add("sstruc",e0);var sd=class extends Yt{constructor(e){var t,i;super(e),e.scale||(this.parameters.scale="rwb"),this.atomData=(t=this.parameters.data)===null||t===void 0?void 0:t.atomData,this.bondData=(i=this.parameters.data)===null||i===void 0?void 0:i.bondData,this.scale=this.getScale(this.parameters)}atomColor(e){var t;let i=(t=this.atomData)===null||t===void 0?void 0:t[e.index];return i!==void 0?this.scale(i):this.parameters.value}bondColor(e,t){var i;let r=(i=this.bondData)===null||i===void 0?void 0:i[e.index];return r!==void 0?this.scale(r):this.atomProxy?(this.atomProxy.index=t?e.atomIndex1:e.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value}};qt([Xt],sd.prototype,"atomColor",null),qt([Xt],sd.prototype,"bondColor",null),Dt.add("structuredata",sd);var qa=class extends Yt{atomColor(){return this.parameters.value}bondColor(){return this.parameters.value}valueColor(){return this.parameters.value}volumeColor(){return this.parameters.value}};qt([Xt],qa.prototype,"atomColor",null),qt([Xt],qa.prototype,"bondColor",null),qt([Xt],qa.prototype,"valueColor",null),qt([Xt],qa.prototype,"volumeColor",null),Dt.add("uniform",qa);var t0=class extends Yt{constructor(e){super(e),this.valueScale=this.getScale()}volumeColor(e){return this.valueScale(this.parameters.volume.data[e])}};qt([Xt],t0.prototype,"volumeColor",null),Dt.add("value",t0);var n0=class extends Yt{constructor(e){super(e),this.vec=new W,this.valueScale=this.getScale()}positionColor(e){let t=this.parameters.volume;if(!t||!t.inverseMatrix)return this.parameters.value;let i=this.vec,r=t.data,s=t.nx,o=t.ny,a=s*o;i.copy(e),i.applyMatrix4(t.inverseMatrix);let l=Math.floor(i.x),c=Math.floor(i.y),u=Math.floor(i.z),d=(u*o+c)*s+l,f=d+1,m=d+s,p=d+a,_=m+1,y=p+1,g=m+a,b=g+1,h=r[d],v=r[f],S=r[m],x=r[p],w=r[_],A=r[y],M=r[g],T=r[b],R=i.x-l,C=i.y-c,P=i.z-u,E=Cr(h,v,R),I=Cr(x,A,R),O=Cr(S,w,R),D=Cr(M,T,R),N=Cr(E,O,C),H=Cr(I,D,C),z=Cr(N,H,P);return this.valueScale(z)}};qt([Xt],n0.prototype,"positionColor",null),Dt.add("volume",n0);var Zn=class extends el{constructor(e,t,i){let r=i||{};if(super(e,t,r),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:Qr.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new tn(r.sele),this.dataList=[],this.structure=e,this.structureView=this.structure.getView(this.selection),e.biomolDict){let s={default:"default","":e.unitcell?"AU":"FULL"};Object.keys(e.biomolDict).forEach(function(o){s[o]=o}),this.parameters.assembly={type:"select",options:s,rebuild:!0}}else this.parameters.assembly=null}get defaultScale(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}}init(e){let t=e||{};t.colorScheme=U(t.colorScheme,"element"),this.setRadius(t.radius,t),this.radiusType=U(t.radiusType,"vdw"),this.radiusData=U(t.radiusData,{}),this.radiusSize=U(t.radiusSize,1),this.radiusScale=U(t.radiusScale,1),this.assembly=U(t.assembly,"default"),this.defaultAssembly=U(t.defaultAssembly,""),t.quality==="auto"&&(t.quality=this.getQuality()),super.init(t),this.selection.signals.stringChanged.add(()=>{this.build()}),this.build()}setRadius(e,t){let i=Object.keys(aI);return typeof e=="string"&&i.includes(e.toLowerCase())?t.radiusType=e:e!==void 0&&(t.radiusType="size",t.radiusSize=e),this}getAssembly(){let e=this.assembly==="default"?this.defaultAssembly:this.assembly;return this.structure.biomolDict[e]}getQuality(){let e,t=this.structureView,i=this.getAssembly();return e=i?i.getAtomCount(t):t.atomCount,BP&&(e*=4),t.atomStore.count/t.residueStore.count<2&&(e*=10),e<15e3?"high":e<8e4?"medium":"low"}create(){if(this.structureView.atomCount===0)return;if(!this.structureView.hasCoords())return void(this.needsBuild=!0);this.needsBuild=!1;let e=this.getAssembly();if(e)e.partList.forEach((t,i)=>{let r=t.getView(this.structureView);if(r.atomCount===0)return;let s=this.createData(r,i);s&&(s.sview=r,s.instanceList=t.getInstanceList(),this.dataList.push(s))});else{let t=this.createData(this.structureView,0);t&&(t.sview=this.structureView,this.dataList.push(t))}}update(e){!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach(t=>{t.bufferList.length>0&&this.updateData(e,t)},this):Object.assign(this.lazyProps.what,e)}updateData(e,t){this.build()}getColorParams(){return Object.assign(Object.assign({},super.getColorParams()),{structure:this.structure})}getRadiusParams(e){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}}getAtomParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getBondParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getAtomRadius(e){return this.structureView.atomSet.isSet(e.index)?new Qr(this.getRadiusParams()).atomRadius(e):0}setSelection(e,t){return this.selection.setString(e,t),this}setParameters(e,t={},i=!1){let r=e||{};return this.setRadius(r.radius,r),r.radiusType===void 0&&r.radiusData===void 0&&r.radiusSize===void 0&&r.radiusScale===void 0||(t.radius=!0,ys&&!this.disableImpostor||(i=!0)),r.defaultAssembly!==void 0&&r.defaultAssembly!==this.defaultAssembly&&(this.assembly==="default"&&r.assembly===void 0||r.assembly==="default")&&(i=!0),super.setParameters(r,t,i),this}getParameters(){return Object.assign(super.getParameters(),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})}attach(e){let t=this.viewer,i=this.bufferList;this.dataList.forEach(function(r){r.bufferList.forEach(function(s){i.push(s),t.add(s,r.instanceList)})}),this.setVisibility(this.visible),e()}clear(){this.dataList.length=0,super.clear()}dispose(){this.structureView.dispose(),super.dispose()}},Md=class extends Zn{constructor(e,t,i){super(e,t,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"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"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}init(e){let t=e||{};this.labelVisible=U(t.labelVisible,!0),this.labelSize=U(t.labelSize,2),this.labelColor=U(t.labelColor,16777215),this.labelFontFamily=U(t.labelFontFamily,"sans-serif"),this.labelFontStyle=U(t.labelFontstyle,"normal"),this.labelFontWeight=U(t.labelFontWeight,"bold"),this.labelsdf=U(t.labelsdf,FP==="Chrome"),this.labelXOffset=U(t.labelXOffset,0),this.labelYOffset=U(t.labelYOffset,0),this.labelZOffset=U(t.labelZOffset,.5),this.labelAttachment=U(t.labelAttachment,"bottom-left"),this.labelBorder=U(t.labelBorder,!1),this.labelBorderColor=U(t.labelBorderColor,"lightgrey"),this.labelBorderWidth=U(t.labelBorderWidth,.15),this.labelBackground=U(t.labelBackground,!1),this.labelBackgroundColor=U(t.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=U(t.labelBackgroundMargin,.5),this.labelBackgroundOpacity=U(t.labelBackgroundOpacity,1),this.labelFixedSize=U(t.labelFixedSize,!1),this.lineOpacity=U(t.lineOpacity,1),this.linewidth=U(t.linewidth,2),super.init(t)}update(e){e.position?this.build():super.update(e)}updateData(e,t){let i={};if(e&&!e.labelSize||Object.assign(i,{size:ar(this.n,this.labelSize)}),!e||e.labelColor){let r=new dt(this.labelColor);Object.assign(i,{color:Kt(this.n,r.r,r.g,r.b)})}this.textBuffer.setAttributes(i)}setParameters(e,t={},i=!1){return e&&e.labelSize&&(t.labelSize=!0),e&&(e.labelColor||e.labelColor===0)&&(t.labelColor=!0,i=!0),super.setParameters(e,t,i),e&&e.opacity!==void 0&&this.textBuffer.setParameters({opacity:1}),e&&e.labelVisible!==void 0&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),t||this.viewer.requestRender(),this}getLabelBufferParams(e={}){return super.getBufferParams(Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},e,{opacity:1}))}getAtomRadius(){return 0}};function Pw(n,e){let t=n.getAtomProxy(),i=new tn,r=e.length;if(r===0)return new Float32Array(0);let s=e[0].length,o=n.getAtomSet(),a=new Float32Array(r*s*3),l=0;return e.forEach(function(c){let u=!1;for(let d=0;d 1.0 ){ +gl_FragColor = vec4( backgroundColor, backgroundOpacity ); +}else{ +float sdf = texture2D( fontTexture, texCoord ).a; +if( showBorder ) sdf += borderWidth; +float a = smoothstep(padding - gamma, padding + gamma, sdf); +if( a < 0.2 ) discard; +a *= opacity; +vec3 outgoingLight = vColor; +if( showBorder && sdf < ( padding + borderWidth ) ){ +outgoingLight = borderColor; +} +gl_FragColor = vec4( outgoingLight, a ); +} +#if defined( PICKING ) +if( opacity < 0.3 ) +discard; +gl_FragColor = vec4( vPickingColor, objectId ); +#else +#include premultiplied_alpha_fragment +#include tonemapping_fragment +#include colorspace_fragment +#include fog_fragment +#endif +}`);var Qv={},Sz={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024},u2=class{constructor(e={}){this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=or(e,Sz);let t=this.parameters;this.radius=t.size/8,this.padding=t.size/3;let i=this.lineHeight=t.size+2*t.outline+Math.round(t.size/4),r=this.maxWidth=t.width/4,s=this.canvas=document.createElement("canvas");s.width=r,s.height=i;let o=this.context=this.canvas.getContext("2d",{willReadFrequently:!0});o.font=`${t.style} ${t.variant} ${t.weight} ${t.size}px ${t.font}`,o.fillStyle="black",o.textAlign="left",o.textBaseline="bottom",o.lineJoin="round",this.gridOuter=new Float64Array(i*r),this.gridInner=new Float64Array(i*r),this.f=new Float64Array(Math.max(i,r)),this.d=new Float64Array(Math.max(i,r)),this.z=new Float64Array(Math.max(i,r)+1),this.v=new Int16Array(Math.max(i,r)),this.data=new Uint8Array(t.width*t.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=t.width,this.canvas2.height=t.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map("\uFFFD");for(let a=32;a<=126;++a)this.map(String.fromCharCode(a));this.map("\xB0"),this.map("\u212B"),this.texture=new em(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0}map(e){let t=this.parameters;return this.mapped[e]===void 0&&(this.draw(e),this.currentX+this.scratchW>t.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>t.height&&console.warn("canvas to small"),this.mapped[e]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[e]}get(e){return this.mapped[e]||this.placeholder}draw(e){let t=this.parameters,i=this.lineHeight,r=t.outline,s=this.context,o=this.maxWidth,a=r,l=i-t.outline,c=s.measureText(e),u=Math.min(o,Math.ceil(c.width+2*a+1)),d=u*i;s.clearRect(0,0,u,i),s.fillText(e,a,l);let f=s.getImageData(0,0,u,i),m=f.data;for(let p=0;p= 0.0 ) { +trimSegment( start, end ); +} else if ( end.z < 0.0 && start.z >= 0.0 ) { +trimSegment( end, start ); +} +} +vec4 clipStart = projectionMatrix * start; +vec4 clipEnd = projectionMatrix * end; +vec2 ndcStart = clipStart.xy / clipStart.w; +vec2 ndcEnd = clipEnd.xy / clipEnd.w; +vec2 dir = ndcEnd - ndcStart; +dir.x *= aspect; +dir = normalize( dir ); +vec2 offset = vec2( dir.y, - dir.x ); +dir.x /= aspect; +offset.x /= aspect; +if ( mapping.x < 0.0 ) offset *= - 1.0; +offset *= linewidth; +offset /= resolution.y; +vec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd; +offset *= clip.w; +clip.xy += offset; +gl_Position = clip; +#ifndef PICKING +vViewPosition = ( projectionMatrixInverse * clip ).xyz; +#endif +#if defined( RADIUS_CLIP ) +vClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz; +#endif +#include nearclip_vertex +}`),zt.add("shader/WideLine.frag",`uniform vec3 diffuse; +uniform float opacity; +uniform float clipNear; +uniform float clipRadius; +#if defined( RADIUS_CLIP ) +varying vec3 vClipCenter; +#endif +#ifdef PICKING +uniform float objectId; +varying vec3 vPickingColor; +#else +#include common +#include fog_pars_fragment +varying vec3 vViewPosition; +varying vec3 vColor; +varying vec3 vColor2; +varying float flag; +#endif +void main() { +#include nearclip_fragment +#include radiusclip_fragment +#if defined( PICKING ) +if( opacity < 0.3 ) +discard; +gl_FragColor = vec4( vPickingColor, objectId ); +#else +vec3 outgoingLight = vec3( 0.0 ); +vec4 diffuseColor = vec4( diffuse, 1.0 ); +if ( flag < 0.0 ) { +diffuseColor.rgb *= vColor; +} else { +diffuseColor.rgb *= vColor2; +} +#include alphatest_fragment +outgoingLight = diffuseColor.rgb; +gl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity ); +#include premultiplied_alpha_fragment +#include tonemapping_fragment +#include colorspace_fragment +#include fog_fragment +#endif +}`);var Cz=Object.assign({linewidth:2},ki),Ez=Object.assign({linewidth:{uniform:!0}},cl),es=class extends wd{constructor(e,t={}){super(e,t),this.parameterTypes=Ez,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!e.color2&&e.color&&(e.color2=e.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new Et},projectionMatrixInverse:{value:new qe}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Cz}setParameters(e){super.setParameters(e)}};cr.add("wideline",es);var h2=class extends Md{constructor(e,t,i){super(e,t,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}init(e){let t=e||{};t.side=U(t.side,"double"),t.opacity=U(t.opacity,.5),this.atomTriple=U(t.atomTriple,[]),this.arcVisible=U(t.arcVisible,!0),this.sectorVisible=U(t.sectorVisible,!0),this.vectorVisible=U(t.vectorVisible,!0),super.init(t)}createData(e){if(!e.atomCount||!this.atomTriple.length)return;let t=function(a,l){return function(c){let u=[],d=c.length/9;for(let p=0;p radius2) { +discard; +} +#ifdef CAP +surface_point = front_point; +_normal = axis; +#else +surface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction; +dNV = dot(-axis, ray_direction); +near = dot(axis, end) / dNV; +new_point2 = ray_direction * near + ray_origin; +if (dot(new_point2 - end, new_point2-base) < radius2) { +discard; +} +interior = true; +#endif +} +if( end_cap_test > 0.0 ) +{ +float dNV; +float near; +vec3 end_point; +if ( ortho == 1.0 ) { +end_point = ray_target; +} else { +dNV = dot(axis, ray_direction); +if (dNV < 0.0) { +discard; +} +near = dot(axis, end) / dNV; +end_point = ray_direction * near + ray_origin; +} +if( dot(end_point - end, end_point-base) > radius2 ) { +discard; +} +#ifdef CAP +surface_point = end_point; +_normal = axis; +#else +surface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction; +dNV = dot(-axis, ray_direction); +near = dot(-axis, (base)) / dNV; +new_point2 = ray_direction * near + ray_origin; +if (dot(new_point2 - base, new_point2-base) < radius2) { +discard; +} +interior = true; +#endif +} +gl_FragDepthEXT = calcDepth( surface_point ); +#ifdef NEAR_CLIP +if( calcClip( surface_point ) > 0.0 ){ +dist = (-a1 - sqrt(d)) / a2; +surface_point = ray_target + dist * ray_direction; +if( calcClip( surface_point ) > 0.0 ) { +discard; +} +interior = true; +gl_FragDepthEXT = calcDepth( surface_point ); +if( gl_FragDepthEXT >= 0.0 ){ +gl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) ); +} +}else if( gl_FragDepthEXT <= 0.0 ){ +dist = (-a1 - sqrt(d)) / a2; +surface_point = ray_target + dist * ray_direction; +interior = true; +gl_FragDepthEXT = calcDepth( surface_point ); +if( gl_FragDepthEXT >= 0.0 ){ +gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius ); +} +} +#else +if( gl_FragDepthEXT <= 0.0 ){ +dist = (-a1 - sqrt(d)) / a2; +surface_point = ray_target + dist * ray_direction; +interior = true; +gl_FragDepthEXT = calcDepth( surface_point ); +if( gl_FragDepthEXT >= 0.0 ){ +gl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius ); +} +} +#endif +if (gl_FragDepthEXT < 0.0) { +discard; +} +if (gl_FragDepthEXT > 1.0) { +discard; +} +#ifdef PICKING +if( opacity < 0.3 ) +discard; +gl_FragColor = vec4( vPickingColor, objectId ); +#else +vec3 vViewPosition = -surface_point; +vec3 vNormal = _normal; +vec3 vColor; +if( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){ +if( b < 0.0 ){ +vColor = vColor1; +}else{ +vColor = vColor2; +} +}else{ +if( b > 0.0 ){ +vColor = vColor1; +}else{ +vColor = vColor2; +} +} +vec4 diffuseColor = vec4( diffuse, opacity ); +ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); +vec3 totalEmissiveLight = emissive; +#include color_fragment +#include roughnessmap_fragment +#include metalnessmap_fragment +vec3 normal = normalize( vNormal ); +vec3 nonPerturbedNormal = normal; +#include lights_physical_fragment +#include lights_fragment_begin +#include lights_fragment_end +vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight; +if( interior ){ +#ifdef USE_INTERIOR_COLOR +outgoingLight.xyz = interiorColor; +#else +#ifdef DIFFUSE_INTERIOR +outgoingLight.xyz = vColor; +#endif +#endif +outgoingLight.xyz *= 1.0 - interiorDarkening; +} +gl_FragColor = vec4( outgoingLight, diffuseColor.a ); +#include premultiplied_alpha_fragment +#include tonemapping_fragment +#include colorspace_fragment +#include fog_fragment +#endif +}`);var Pz=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),Iz=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]),r0=class extends bd{constructor(e,t={}){super("v3",e,t)}get mapping(){return Pz}get mappingIndices(){return Iz}get mappingIndicesSize(){return 12}get mappingSize(){return 6}get mappingItemSize(){return 3}},pI=Object.assign({openEnded:!1},ki),Rz=Object.assign({openEnded:{updateShader:!0}},cl),d2=class extends r0{constructor(e,t={}){super(e,t),this.parameterTypes=Rz,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new qe},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return pI}getDefines(e){let t=r0.prototype.getDefines.call(this,e);return this.parameters.openEnded||(t.CAP=1),t}};Object.assign({disableImpostor:!1},Iw,pI);var ao=class{constructor(n,e={}){return!n.color2&&n.color&&(n.color2=n.color),!ys||e&&e.disableImpostor?new i0(n,e):new d2(n,e)}};cr.add("cylinder",ao);var f2=class extends Zn{constructor(e,t,i){super(e,t,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}init(e){let t=e||{};t.radiusSize=U(t.radiusSize,.5),t.colorValue=U(t.colorValue,"lightgreen"),t.useInteriorColor=U(t.useInteriorColor,!0),this.showAxes=U(t.showAxes,!0),this.showBox=U(t.showBox,!1),super.init(t)}getPrincipalAxes(){let e,t=this.getAssembly();return t&&(e=t.partList[0].getSelection()),this.structureView.getPrincipalAxes(e)}getAxesData(e){let t=this.getPrincipalAxes(),i=new dt(this.colorValue),r=0,s=0;this.showAxes&&(r+=6,s+=3),this.showBox&&(r+=8,s+=12);let o=new Float32Array(3*r),a=Kt(r,i.r,i.g,i.b),l=ar(r,this.radiusSize),c=new Float32Array(3*s),u=new Float32Array(3*s),d=Kt(s,i.r,i.g,i.b),f=ar(s,this.radiusSize),m=0;if(this.showAxes){let _=function(y,g){y.toArray(o,2*m),g.toArray(o,2*m+3),y.toArray(c,m),g.toArray(u,m),m+=3};_(t.begA,t.endA),_(t.begB,t.endB),_(t.begC,t.endC)}if(this.showBox){let _=new W,{d1a:y,d2a:g,d3a:b,d1b:h,d2b:v,d3b:S}=t.getProjectedScaleForAtoms(e),x=2*m,w=function(T,R,C){_.copy(t.center).addScaledVector(t.normVecA,T).addScaledVector(t.normVecB,R).addScaledVector(t.normVecC,C),_.toArray(o,x),x+=3};w(y,g,b),w(y,g,S),w(y,v,S),w(y,v,b),w(h,v,S),w(h,v,b),w(h,g,b),w(h,g,S);let A=m,M=function(T,R){_.fromArray(o,2*m+3*T).toArray(c,A),_.fromArray(o,2*m+3*R).toArray(u,A),A+=3};M(0,1),M(0,3),M(0,6),M(1,2),M(1,7),M(2,3),M(2,4),M(3,5),M(4,5),M(4,7),M(5,6),M(6,7)}let p=new cb(t);return{vertex:{position:o,color:a,radius:l,picking:p},edge:{position1:c,position2:u,color:d,color2:d,radius:f,picking:p}}}create(){let e=this.getAxesData(this.structureView);this.sphereBuffer=new la(e.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new ao(e.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}createData(e){}updateData(e,t){let i=this.getAxesData(t.sview),r={},s={};e&&!e.position||(Object.assign(r,{position:i.vertex.position}),Object.assign(s,{position1:i.edge.position1,position2:i.edge.position2})),e&&!e.color||(Object.assign(r,{color:i.vertex.color}),Object.assign(s,{color:i.edge.color,color2:i.edge.color})),e&&!e.radius||(Object.assign(r,{radius:i.vertex.radius}),Object.assign(s,{radius:i.edge.radius})),this.sphereBuffer.setAttributes(r),this.cylinderBuffer.setAttributes(s)}};on.add("axes",f2);var eu=class extends Zn{constructor(e,t,i){super(e,t,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}init(e){var t=e||{};t.radiusType=U(t.radiusType,"size"),t.radiusSize=U(t.radiusSize,.15),t.useInteriorColor=U(t.useInteriorColor,!0),this.aspectRatio=U(t.aspectRatio,2),this.lineOnly=U(t.lineOnly,!1),this.cylinderOnly=U(t.cylinderOnly,!1),this.multipleBond=U(t.multipleBond,"off"),this.bondSpacing=U(t.bondSpacing,1),this.bondScale=U(t.bondScale,.4),this.linewidth=U(t.linewidth,2),super.init(t)}getAtomRadius(e){return this.aspectRatio*super.getAtomRadius(e)}getAtomParams(e,t){var i=super.getAtomParams(e,t);return i.radiusParams.scale*=this.aspectRatio,i}getAtomData(e,t,i){return e.getAtomData(this.getAtomParams(t,i))}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},t),super.getBondParams(e,t)}getBondData(e,t,i){return e.getBondData(this.getBondParams(t,i))}createData(e){let t=[];if(this.lineOnly)this.lineBuffer=new es(this.getBondData(e,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),t.push(this.lineBuffer);else{let i=new ao(this.getBondData(e),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(t.push(i),!this.cylinderOnly){let r=new la(this.getAtomData(e),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));t.push(r)}}return{bufferList:t}}updateData(e,t){this.multipleBond!=="off"&&e&&e.radius&&(e.position=!0);let i=this.getBondData(t.sview,e);if(this.lineOnly){let a={};e&&!e.position||Object.assign(a,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(a,{color:i.color,color2:i.color2}),t.bufferList[0].setAttributes(a)}else{var r={};if(e&&!e.position||Object.assign(r,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(r,{color:i.color,color2:i.color2}),e&&!e.radius||Object.assign(r,{radius:i.radius}),t.bufferList[0].setAttributes(r),!this.cylinderOnly){var s=this.getAtomData(t.sview,e),o={};e&&!e.position||Object.assign(o,{position:s.position}),e&&!e.color||Object.assign(o,{color:s.color}),e&&!e.radius||Object.assign(o,{radius:s.radius}),t.bufferList[1].setAttributes(o)}}}setParameters(e={}){let t=!1,i={};return(e.aspectRatio||e.bondSpacing||e.bondScale)&&(Object.assign(i,{radius:!0}),ys&&!this.disableImpostor||(t=!0)),super.setParameters(e,i,t),this}};on.add("ball+stick",eu);var p2=class extends eu{constructor(e,t,i){super(e,t,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}init(e){var t=e||{};t.aspectRatio=U(t.aspectRatio,1),t.radiusSize=U(t.radiusSize,.25),super.init(t)}getAtomRadius(e){return e.isTrace()?super.getAtomRadius(e):0}getAtomData(e,t,i){return e.getBackboneAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){return e.getBackboneBondData(this.getBondParams(t,i))}};on.add("backbone",p2);var m2=class extends eu{constructor(e,t,i){super(e,t,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}init(e){let t=e||{};t.aspectRatio=U(t.aspectRatio,1),t.radiusSize=U(t.radiusSize,.3),super.init(t)}getAtomData(e,t,i){return e.getRungAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){let r=this.getBondParams(t,i);return Object.assign(r.colorParams,{rung:!0}),e.getRungBondData(r)}};on.add("base",m2);var g2=class{constructor(e,t){this.m=e,this.tension=t,this.dt=1/this.m,this.delta=1e-4,this.vec1=new W,this.vec2=new W,this.vDir=new W,this.vTan=new W,this.vNorm=new W,this.vBin=new W,this.m2=Math.ceil(this.m/2)}interpolateToArr(e,t,i,r,s,o,a){o[a+0]=no(e.x,t.x,i.x,r.x,s,this.tension),o[a+1]=no(e.y,t.y,i.y,r.y,s,this.tension),o[a+2]=no(e.z,t.z,i.z,r.z,s,this.tension)}interpolateToVec(e,t,i,r,s,o){o.x=no(e.x,t.x,i.x,r.x,s,this.tension),o.y=no(e.y,t.y,i.y,r.y,s,this.tension),o.z=no(e.z,t.z,i.z,r.z,s,this.tension)}interpolatePosition(e,t,i,r,s,o){for(var a=0;a1&&(u=1),this.interpolateToVec(e,t,i,r,c,this.vec1),this.interpolateToVec(e,t,i,r,u,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(s,d)}}vectorSubdivide(e,t,i,r,s){let o,a=t.next(),l=t.next(),c=t.next(),u=t.size,d=u-1,f=r||0;for(let m=0;m0&&m{if(r.residueCount<4)return;i.push(r);let s=this.getSpline(r),o=this.getAspectRatio(r),a=s.getSubdividedPosition(),l=s.getSubdividedOrientation(),c=s.getSubdividedColor(this.getColorParams()),u=s.getSubdividedPicking(),d=s.getSubdividedSize(this.getRadiusParams());t.push(new y2(Object.assign({},a,l,c,u,d),this.getBufferParams({radialSegments:this.radialSegments,aspectRatio:o,capped:this.capped})))},e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){Le&&we.time(this.type+" repr update"),e=e||{};for(var i=0,r=t.polymerList.length;i0;xn(P,M,E);let ee=Vi(P,R)<0;if(Jt(P,R,Vi(R,T)),xn(I,T,P),Jt(P,R,Vi(R,C)),xn(O,C,P),Qo(I)===0||Qo(O)===0)continue;Cn(I,I),Cn(O,O);let le=f[L]=GB(I,O);p[L]=(zP*le).toFixed(1)+"\xB0",$i(H,I,R),Cn(H,H),Vi(H,O)<0&&P0(H,H),Yr(P,E,I,H,le/2),Tt(P,m,3*L);let xe=Math.ceil(le/c),Se=xe+(l.extendLine?4:2),Re=l.extendLine?36:0,ke=new Float32Array(3*Se),$e=new Float32Array(3*Se),_e=new Float32Array(9*xe),Ie=new Float32Array(Re);_[L]=ke,y[L]=$e,g[L]=_e,b[L]=Ie,l.extendLine&&(oe?(xn(P,x,A),Cn(P,P),Jt(D,P,1/Vi(I,P)),Zr(D,D,A)):(Jt(D,T,1/Vi(I,T)),Zr(D,D,w)),ee?(xn(P,M,w),Cn(P,P),Jt(N,P,1/Vi(O,P)),Zr(N,N,w)):(Jt(N,C,1/Vi(O,C)),Zr(N,N,A))),Zr(z,E,I);let We=0;l.extendLine?(Tt(x,ke,We),Tt(D,$e,We),We+=3,Tt(D,ke,We),Tt(z,$e,We),We+=3,Tt(D,Ie,0),Tt(z,Ie,3),Tt(oe?A:w,Ie,6),Tt(oe?A:w,Ie,9),Tt(z,Ie,12),Tt(E,Ie,15)):(Tt(E,ke,We),Tt(z,$e,We),We+=3);let Fe=function($,de){let Te=9*de;Tt(E,_e,Te),Tt(z,_e,Te+3),Tt(z,ke,We),Yr(z,E,I,H,$),Tt(z,_e,Te+6),Tt(z,$e,We),We+=3},Y=0;for(let $=c;${let o=nx(i,s);Object.assign(s,o)}),t.side=U(t.side,"double"),t.opacity=U(t.opacity,.5),t.radiusType=U(t.radiusType,"size"),t.radiusSize=U(t.radiusSize,.15),super.init(t)}getHistogramBinBorderBufferParameters(){return this.getBufferParams({linewidth:this.histogramBinBorderWidth,visible:this.histogramBinBorderVisible,opacity:this.histogramBinBorderOpacity})}getBondArrowsBufferParameters(){return this.getBufferParams({linewidth:this.bondArrowWidth,visible:this.bondArrowVisible,opacity:this.bondArrowOpacity})}getOpaqueMiddleDiscBufferParameters(){return this.getBufferParams({visible:this.opaqueMiddleDiscVisible,opacity:this.opaqueMiddleDiscOpacity})}getHistogramBufferParameters(){return this.getBufferParams({visible:!0,opacity:this.histogramOpacity,side:"double"})}createData(e){if(!e.atomCount||!this.histogramsData.length)return;this.histogramsData.forEach(a=>a.atomPositions=Pw(e,[a.atomQuad]));let t=this.scaleBinToSectorArea?function(a){return Math.sqrt(a)}:function(a){return a};function i(a){let l=a.map(d=>d.length),c=new Float32Array(ww(l)),u=0;for(let d=0;dc.startPoints)),position2:i(a.map(c=>c.endPoints)),color:i(a.map(c=>c.startColors)),color2:i(a.map(c=>c.endColors))},l)}function s(a,l){return new Jr({position:i(a.map(c=>c.triangles)),color:i(a.map(c=>c.triangleColors))},l)}this.histogramsData.forEach(a=>a.histogram360Scaled=a.histogram360.map(t));let o=[];for(let a=0;a=3&&(l=Lz(c)),l!==void 0&&o.push(l)}return this.frontHistogramBinBordersBuffer=r(o.map(a=>a.frontHistogramBinBorders),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=r(o.map(a=>a.backHistogramBinBorders),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=r(o.map(a=>a.adjacentBondArrows),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=r(o.map(a=>a.distantBondArrows),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=s(o.map(a=>a.opaqueMiddleDisc),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=s(o.map(a=>a.frontHistogram),this.getHistogramBufferParameters()),this.backHistogramBuffer=s(o.map(a=>a.backHistogram),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}setParameters(e){return super.setParameters(e,{},!1),e&&e.histogramBinBorderVisible!==void 0&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.frontHistogramBinBordersBuffer&&this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),this.backHistogramBinBordersBuffer&&this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),t||this.viewer.requestRender(),this}};function Lz(n){let e=n.atomPositions,t=n.histogram360Scaled,i=t.length<=180?360:2*t.length,r={triangles:new Float32Array(3*i*3),triangleColors:Wr(n.opaqueMiddleDiscColor,3*i)},s={triangles:new Float32Array(3*t.length*3),triangleColors:Wr(n.frontHistogramColor,3*t.length)},o={triangles:new Float32Array(3*t.length*3),triangleColors:Wr(n.backHistogramColor,3*t.length)},a={startPoints:new Float32Array(3*t.length),endPoints:new Float32Array(3*t.length),startColors:Wr(n.histogramBinBorderColor,t.length),endColors:Wr(n.histogramBinBorderColor,t.length)},l={startPoints:new Float32Array(3*t.length),endPoints:new Float32Array(3*t.length),startColors:Wr(n.histogramBinBorderColor,t.length),endColors:Wr(n.histogramBinBorderColor,t.length)},c={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:Wr(n.adjacentBondArrowColor,t.length),endColors:Wr(n.adjacentBondArrowColor,t.length)},u={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:Wr(n.distantBondArrowColor,t.length),endColors:Wr(n.distantBondArrowColor,t.length)},d=Mt(),f=Mt(),m=Mt(),p=Mt(),_=Mt(),y=Mt(),g=Mt(),b=Mt(),h=Mt(),v=Mt(),S=Mt(),x=Mt(),w=Mt(),A=Mt(),M=Mt(),T=Mt(),R=[d,f,m,p];for(let H=0;H{let y=p[0],g=p[1];if(typeof y=="number"&&Number.isInteger(y)&&typeof g=="number"&&Number.isInteger(g)){if(!f.get(y)||!f.get(g))return void(d+=1);c.index=y,u.index=g}else{o.setString(y),a.setString(g);var b=e.getAtomIndices(o),h=e.getAtomIndices(a);if(!b.length||!h.length)return void(d+=1);c.index=b[0],u.index=h[0]}l.addBond(c,u,1),_-=d;var v=c.distanceTo(u);switch(this.labelUnit){case"angstrom":r[_]=v.toFixed(2)+" \u212B";break;case"nm":r[_]=(v/10).toFixed(2)+" nm";break;default:r[_]=v.toFixed(2)}var S=3*_;s[S+0]=(c.x+u.x)/2,s[S+1]=(c.y+u.y)/2,s[S+2]=(c.z+u.z)/2}),d>0&&(i-=d,s=s.subarray(0,3*i));var m=new ii(l.count,!0);return{text:r,position:s,bondSet:m,bondStore:l}}getBondData(e,t,i){let r=e.getBondData(this.getBondParams(t,i));return r.picking&&(r.picking=new db(r.picking.array,r.picking.structure,i.bondStore)),r}createData(e){if(!e.atomCount||!this.atomPair.length)return;let t=this.atomPair.length,i=new dt(this.labelColor),r=this.getDistanceData(e,this.atomPair);this.textBuffer=new oa({position:r.position,size:ar(t,this.labelSize),color:Kt(t,i.r,i.g,i.b),text:r.text},this.getLabelBufferParams());let s={bondSet:r.bondSet,bondStore:r.bondStore},o=this.getBondData(e,{position:!0,color:!0,picking:!0,radius:this.useCylinder},s);return this.useCylinder?this.distanceBuffer=new ao(o,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new es($P(o),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:r.bondSet,bondStore:r.bondStore,position:r.position,bufferList:[this.textBuffer,this.distanceBuffer]}}updateData(e,t){super.updateData(e,t);let i={bondSet:t.bondSet,bondStore:t.bondStore},r=this.getBondData(t.sview,e,i),s={};e&&!e.color||Object.assign(s,{color:r.color,color2:r.color2}),e&&!e.radius||Object.assign(s,{radius:r.radius}),this.distanceBuffer.setAttributes(s)}setParameters(e){return super.setParameters(e,{},!1),this.useCylinder||(e&&e.lineOpacity&&this.distanceBuffer.setParameters({opacity:e.lineOpacity}),e&&e.opacity!==void 0&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),e&&e.linewidth&&this.distanceBuffer.setParameters({linewidth:e.linewidth})),this}};function ix(n){return 2*(n.position.length/3)*3}on.add("distance",b2);var Dz=Object.assign({scale:1,color:"grey"},ki),s0=class extends Pr{constructor(e,t={}){super({position:new Float32Array(ix(e)),color:new Float32Array(ix(e))},t),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";let i=new dt(this.parameters.color),r=this.geometry.attributes;Kt(ix(e)/3,i.r,i.g,i.b,r.color.array),this.setAttributes(e)}get defaultParameters(){return Dz}setAttributes(e={}){let t=this.geometry.attributes,i,r,s;e.position&&e.vector&&(i=e.position,r=e.vector,s=t.position.array,t.position.needsUpdate=!0);let o=this.size/2,a=this.parameters.scale;if(i&&r)for(let l=0;l{if(r.residueCount<4)return;i.push(r);let s=new Kc(r),o=s.getPosition(),a=s.getColor(this.getColorParams()),l=s.getSize(this.getRadiusParams()),c=s.getPicking();t.push(new la({position:o.center,color:a.color,radius:l.size,picking:c.picking},this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),new s0({position:o.center,vector:o.axis},this.getBufferParams({color:"skyblue",scale:1})),new s0({position:o.center,vector:o.resdir},this.getBufferParams({color:"lightgreen",scale:1})))},e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){Le&&we.time(this.type+" repr update"),e=e||{};for(let i=0,r=t.polymerList.length;i radius2) { +spaceposition.y = mapping.y * 1.5 * radius1; +spaceposition.x = mapping.x * 1.5 * radius1; +} else { +spaceposition.y = mapping.y * 1.5 * radius2; +spaceposition.x = mapping.x * 1.5 * radius2; +} +spaceposition.w = 1.0; +vec4 e3 = vec4( 1.0 ); +vec3 e1, e1_temp, e2, e2_temp; +e3.xyz = normalize(position_atom1-position_atom2); +if (e3.z == 0.0) { e3.z = 0.0000000000001;} +if ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;} +if ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;} +if ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;} +vec4 focus = vec4( 1.0 ); +focus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x + +( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x)); +focus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y + +( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y)); +focus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z + +( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z)); +e1.x = 1.0; +e1.y = 1.0; +e1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z; +e1_temp = e1 - focus.xyz; +e1 = normalize(e1_temp); +e2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx; +e2 = normalize(e2_temp); +mat3 R= mat3( e1.xyz, e2.xyz, e3.xyz ); +vertex_position.xyz = R * spaceposition.xyz; +vertex_position.w = 1.0; +vertex_position.x += (position_atom1.x+position_atom2.x) / 2.0; +vertex_position.y += (position_atom1.y+position_atom2.y) / 2.0; +vertex_position.z += (position_atom1.z+position_atom2.z) / 2.0; +gl_Position = modelViewProjectionMatrix * vertex_position; +vec4 i_near, i_far; +vec4 near = gl_Position; +near.z = 0.0 ; +near = modelViewProjectionMatrixInverse * near; +i_near = near; +vec4 far = gl_Position; +far.z = far.w ; +i_far = modelViewProjectionMatrixInverse * far; +prime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 ); +prime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 ); +float Rsquare = (radius1*radius1/shrink) - ( +(position_atom1.x - focus.x)*(position_atom1.x - focus.x) + +(position_atom1.y - focus.y)*(position_atom1.y - focus.y) + +(position_atom1.z - focus.z)*(position_atom1.z - focus.z) +); +focus.w = Rsquare; +matrix_near = mat4( i_near, i_far, focus, e3 ); +gl_Position.z = 1.0; +}`),zt.add("shader/HyperballStickImpostor.frag",`#define STANDARD +#define IMPOSTOR +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 interiorColor; +uniform float interiorDarkening; +uniform float roughness; +uniform float metalness; +uniform float opacity; +uniform float clipNear; +uniform float shrink; +uniform mat4 modelViewMatrix; +uniform mat4 modelViewProjectionMatrix; +uniform mat4 modelViewMatrixInverseTranspose; +uniform mat4 projectionMatrix; +varying mat4 matrix_near; +varying vec4 prime1; +varying vec4 prime2; +varying float vRadius; +varying float vRadius2; +#ifdef PICKING +uniform float objectId; +varying vec3 vPickingColor; +#else +varying vec3 vColor1; +varying vec3 vColor2; +#include common +#include fog_pars_fragment +#include bsdfs +#include lights_pars_begin +#include lights_physical_pars_fragment +#endif +bool interior = false; +float calcClip( vec4 cameraPos ){ +return dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) ); +} +float calcClip( vec3 cameraPos ){ +return calcClip( vec4( cameraPos, 1.0 ) ); +} +float calcDepth( in vec3 cameraPos ){ +vec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw; +return 0.5 + 0.5 * clipZW.x / clipZW.y; +} +struct Ray { +vec3 origin ; +vec3 direction ; +}; +bool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){ +float a = x3.x; +float b = x3.y; +float c = x3.z; +float d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z; +float l = a*M.x+b*M.y+c*M.z+d; +if (l<0.0) {return true;} +else{return false;} +} +vec3 isect_surf(Ray r, mat4 matrix_coef){ +vec4 direction = vec4(r.direction, 0.0); +vec4 origin = vec4(r.origin, 1.0); +float a = dot(direction,(matrix_coef*direction)); +float b = dot(origin,(matrix_coef*direction)); +float c = dot(origin,(matrix_coef*origin)); +float delta =b*b-a*c; +gl_FragColor.a = 1.0; +if (delta<0.0){ +discard; +} +float t1 =(-b-sqrt(delta))/a; +return r.origin+t1*r.direction; +} +vec3 isect_surf2(Ray r, mat4 matrix_coef){ +vec4 direction = vec4(r.direction, 0.0); +vec4 origin = vec4(r.origin, 1.0); +float a = dot(direction,(matrix_coef*direction)); +float b = dot(origin,(matrix_coef*direction)); +float c = dot(origin,(matrix_coef*origin)); +float delta =b*b-a*c; +gl_FragColor.a = 1.0; +if (delta<0.0){ +discard; +} +float t2 =(-b+sqrt(delta))/a; +return r.origin+t2*r.direction; +} +Ray primary_ray(vec4 near1, vec4 far1){ +vec3 near=near1.xyz/near1.w; +vec3 far=far1.xyz/far1.w; +return Ray(near,far-near); +} +float update_z_buffer(vec3 M, mat4 ModelViewP){ +float depth1; +vec4 Ms=(ModelViewP*vec4(M,1.0)); +return depth1=(1.0+Ms.z/Ms.w)/2.0; +} +void main(){ +float radius = max( vRadius, vRadius2 ); +vec4 i_near, i_far, focus; +vec3 e3, e1, e1_temp, e2; +i_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]); +i_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]); +focus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]); +e3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]); +e1.x = 1.0; +e1.y = 1.0; +e1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z; +e1_temp = e1 - focus.xyz; +e1 = normalize(e1_temp); +e2 = normalize(cross(e1,e3)); +vec4 equation = focus; +float shrinkfactor = shrink; +float t1 = -1.0/(1.0-shrinkfactor); +float t2 = 1.0/(shrinkfactor); +vec4 colonne1, colonne2, colonne3, colonne4; +mat4 mat; +vec3 equation1 = vec3(t2,t2,t1); +float A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z; +float A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z; +float A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z; +float A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x; +float A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y; +float A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z; +float A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3; +float A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y; +float A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z; +float A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3; +float A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z; +float A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3; +float A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w; +colonne1 = vec4(A11,A21,A31,A41); +colonne2 = vec4(A21,A22,A32,A42); +colonne3 = vec4(A31,A32,A33,A43); +colonne4 = vec4(A41,A42,A43,A44); +mat = mat4(colonne1,colonne2,colonne3,colonne4); +Ray ray = primary_ray(i_near,i_far) ; +vec3 M; +M = isect_surf(ray, mat); +if (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; } +vec4 M1 = vec4(M,1.0); +vec4 M2 = mat*M1; +vec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz; +gl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ; +#ifdef NEAR_CLIP +if( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){ +M = isect_surf2(ray, mat); +if( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ) +discard; +interior = true; +gl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ; +if( gl_FragDepthEXT >= 0.0 ){ +gl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) ); +} +}else if( gl_FragDepthEXT <= 0.0 ){ +M = isect_surf2(ray, mat); +interior = true; +gl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix); +if( gl_FragDepthEXT >= 0.0 ){ +gl_FragDepthEXT = 0.0 + ( 0.0000001 / radius ); +} +} +#else +if( gl_FragDepthEXT <= 0.0 ){ +M = isect_surf2(ray, mat); +interior = true; +gl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ; +if( gl_FragDepthEXT >= 0.0 ){ +gl_FragDepthEXT = 0.0 + ( 0.0000001 / radius ); +} +} +#endif +if (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; } +if (gl_FragDepthEXT < 0.0) +discard; +if (gl_FragDepthEXT > 1.0) +discard; +float distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) / +distance(prime2.xyz,prime1.xyz); +#ifdef PICKING +if( opacity < 0.3 ) +discard; +gl_FragColor = vec4( vPickingColor, objectId ); +#else +vec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz; +vec3 vNormal = _normal; +vec3 vColor; +if( distance_ratio>0.5 ){ +vColor = vColor1; +}else{ +vColor = vColor2; +} +vec4 diffuseColor = vec4( diffuse, opacity ); +ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); +vec3 totalEmissiveLight = emissive; +#include color_fragment +#include roughnessmap_fragment +#include metalnessmap_fragment +vec3 normal = normalize( vNormal ); +vec3 nonPerturbedNormal = normal; +#include lights_physical_fragment +#include lights_fragment_begin +#include lights_fragment_end +vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight; +if( interior ){ +#ifdef USE_INTERIOR_COLOR +outgoingLight.xyz = interiorColor; +#else +#ifdef DIFFUSE_INTERIOR +outgoingLight.xyz = vColor; +#endif +#endif +outgoingLight.xyz *= 1.0 - interiorDarkening; +} +gl_FragColor = vec4( outgoingLight, diffuseColor.a ); +#include premultiplied_alpha_fragment +#include tonemapping_fragment +#include colorspace_fragment +#include fog_fragment +#endif +}`);var Nz=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),Fz=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]),S2=class extends bd{constructor(e,t={}){super("v3",e,t)}get mapping(){return Nz}get mappingIndices(){return Fz}get mappingIndicesSize(){return 36}get mappingSize(){return 8}get mappingItemSize(){return 3}},mI=Object.assign({shrink:.14},ki),Oz=Object.assign({shrink:{uniform:!0}},cl),A2=class extends S2{constructor(e,t={}){super(e,t),this.parameterTypes=Oz,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new qe},modelViewProjectionMatrixInverse:{value:new qe},modelViewMatrixInverseTranspose:{value:new qe},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return mI}};Object.assign({disableImpostor:!1},Iw,mI);var Bz=class{constructor(n,e={}){return!ys||e&&e.disableImpostor?(n.radius=function(t,i){let r=t.length,s=new Float32Array(r);for(let o=0;ol.push(r.atomLabel(m))))}else if(this.labelGrouping==="residue"){t&&!t.position||(c=[]),t&&!t.color||(d=[]),t&&!t.radius||(u=[]),t&&!t.text||(l=[]),i.colorParams&&(i.colorParams.structure=e.getStructure());let f=Dt.getScheme(i.colorParams),m=new Qr(i.radiusParams),p=e.getAtomProxy(),_=0;e.eachResidue(y=>{let g=3*_;y.isProtein()||y.isNucleic()?(p.index=y.traceAtomIndex,t&&!t.position||p.positionToArray(c,g)):(p.index=y.atomOffset,t&&!t.position||y.positionToArray(c,g)),t&&!t.color||f.atomColorToArray(p,d,g),t&&!t.radius||(u[_]=m.atomRadius(p)),t&&!t.text||l.push(r.atomLabel(p)),++_}),t&&!t.position||(s=new Float32Array(c)),t&&!t.color||(a=new Float32Array(d)),t&&!t.radius||(o=new Float32Array(u))}return{position:s,size:o,color:a,text:l}}createData(e){return{bufferList:[new oa(this.getTextData(e,{position:!0,color:!0,radius:!0,text:!0}),this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,xOffset:this.xOffset,yOffset:this.yOffset,zOffset:this.zOffset,attachment:this.attachment,showBorder:this.showBorder,borderColor:this.borderColor,borderWidth:this.borderWidth,showBackground:this.showBackground,backgroundColor:this.backgroundColor,backgroundMargin:this.backgroundMargin,backgroundOpacity:this.backgroundOpacity,fixedSize:this.fixedSize}))]}}updateData(e,t){t.bufferList[0].setAttributes(this.getTextData(t.sview,e))}getAtomRadius(){return 0}};function Uz(n){let e=n.getAtomSet(),t=n.getBondSet(),i=n.getBondProxy();return t.forEach(function(r){i.index=r,e.clear(i.atomIndex1),e.clear(i.atomIndex2)}),e}on.add("label",C2);var E2=class extends Zn{constructor(e,t,i){super(e,t,i),this.type="line",this.parameters=Object.assign({multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0},lines:{type:"boolean",rebuild:!0},crosses:{type:"select",rebuild:!0,options:{off:"off",lone:"lone",all:"all"}},crossSize:{type:"number",precision:2,max:2,min:.1}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.multipleBond=U(t.multipleBond,"off"),this.bondSpacing=U(t.bondSpacing,1),this.linewidth=U(t.linewidth,2),this.lines=U(t.lines,!0),this.crosses=U(t.crosses,"lone"),this.crossSize=U(t.crossSize,.4),super.init(t)}getAtomRadius(e){return .1}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{type:"size",size:.1,scale:1}},t),super.getBondParams(e,t)}_crossData(e,t){if(e&&!e.position&&!e.color)return;let i={};this.crosses==="lone"&&Object.assign(i,{atomSet:Uz(t)});let r=t.getAtomData(this.getAtomParams(e,i)),s={},o=r.position,a=r.color,l=r.picking,c=(o||a).length,u=3*c,d=new Float32Array(0),f=new Float32Array(0),m=new Float32Array(0),p=new Float32Array(0),_=0,y=new Float32Array(0);e&&!e.position||(d=s.position1=new Float32Array(u),f=s.position2=new Float32Array(u),_=this.crossSize/2),e&&!e.color||(m=s.color=new Float32Array(u),p=s.color2=new Float32Array(u)),e&&!e.picking||(y=new Float32Array(3*r.picking.array.length));for(let g=0;gte?J[re]=-1:(F=Math.sqrt(te-L),J[re]=Math.floor(F)),++re;p[X]=Z,m[X]=J}}function C(D){var N,H,z,L,F,te,Q,Z,J,re,X,se,ne,oe,ee,le,xe,Se,Re=3*D,ke=D;N=Math.floor(.5+o*(n[Re]+f[0])),H=Math.floor(.5+o*(n[Re+1]+f[1])),z=Math.floor(.5+o*(n[Re+2]+f[2]));var $e,_e=e[ke],Ie=m[_e],We=0,Fe=c*u,Y=p[_e];for(re=0;re=l||oe>=c||ee>=u)){var $=ne*Fe+oe*u+ee;if(y)if(g[$]&w){if(g[$]&w){var de=h[$];de!==Re&&Q*Q+Z*Z+J*J<(L=N+Q-Math.floor(.5+o*(n[de]+f[0])))*L+(F=H+Z-Math.floor(.5+o*(n[de+1]+f[1])))*F+(te=z+J-Math.floor(.5+o*(n[de+2]+f[2])))*te&&(h[$]=D)}}else g[$]|=w,h[$]=D;else g[$]|=w}}}We++}}function P(D){var N,H;for(console.time("EDTSurface fillvoxels"),N=0,H=g.length;N=l||X>=c||se>=u)){var Fe=re*We+X*u+se;if(g[Fe]&A){if(y){var Y=h[Fe];Q*Q+Z*Z+J*J<(L=Math.floor(.5+o*(n[Y]+f[0])))*L+(F=Math.floor(.5+o*(n[Y+1]+f[1])))*F+(te=Math.floor(.5+o*(n[Y+2]+f[2])))*te&&(h[Fe]=D)}}else g[Fe]|=A,y&&(h[Fe]=D)}}}_e++}}function I(){var D,N,H,z;console.time("EDTSurface fastdistancemap");var L,F=gI(l,c,u,Uint16Array,3),te=c*u,Q=_*_,Z=0;for(D=0;D0);var ne,oe=a*a,ee=new Uint16Array(3);for(D=0;D=oe)||(g[L]|=M,y&&g[L]&A&&(F.toArray(D,N,H,ee),ne=ee[0]*te+ee[1]*u+ee[2],h[L]=h[ne])));console.timeEnd("EDTSurface fastdistancemap")}function O(D,N,H,z){var L,F,te,Q,Z,J,re,X,se,ne,oe,ee,le=new Uint16Array(3),xe=0;if(H===0)return xe;var Se=-1,Re=-1,ke=-1,$e=c*u;for(re=0,se=H;re-1&&Re-1&&ke-1&&(g[oe=Se*$e+u*Re+ke]&w&&!(g[oe]&A)?(N.fromArray(Se,Re,ke,le),ne=(Q=Se-le[0])*Q+(Z=Re-le[1])*Z+(J=ke-le[2])*J,b[oe]=ne,g[oe]|=A,g[oe]|=M,z[xe]=Se,z[xe+1]=Re,z[xe+2]=ke,xe+=3):g[oe]&w&&g[oe]&A&&(ne=(Q=Se-le[0])*Q+(Z=Re-le[1])*Z+(J=ke-le[2])*J)-1&&Re-1&&ke-1&&(g[oe=Se*$e+u*Re+ke]&w&&!(g[oe]&A)?(N.fromArray(Se,Re,ke,le),ne=(Q=Se-le[0])*Q+(Z=Re-le[1])*Z+(J=ke-le[2])*J,b[oe]=ne,g[oe]|=A,g[oe]|=M,z[xe]=Se,z[xe+1]=Re,z[xe+2]=ke,xe+=3):g[oe]&w&&g[oe]&A&&(ne=(Q=Se-le[0])*Q+(Z=Re-le[1])*Z+(J=ke-le[2])*J)-1&&Re-1&&ke-1&&(g[oe=Se*$e+u*Re+ke]&w&&!(g[oe]&A)?(N.fromArray(Se,Re,ke,le),ne=(Q=Se-le[0])*Q+(Z=Re-le[1])*Z+(J=ke-le[2])*J,b[oe]=ne,g[oe]|=A,g[oe]|=M,z[xe]=Se,z[xe+1]=Re,z[xe+2]=ke,xe+=3):g[oe]&w&&g[oe]&A&&(ne=(Q=Se-le[0])*Q+(Z=Re-le[1])*Z+(J=ke-le[2])*J)-1&&oe-1&&le-1&&eeE&&(E=N)}return{neighbourListLength:27*E+1,withinRadii:function(H,z,L,F,te){for(var Q=0,Z=p(H,l),J=p(z,c),re=p(L,u),X=Math.max(0,Z-1),se=Math.max(0,J-1),ne=Math.max(0,re-1),oe=Math.min(b,Z+2),ee=Math.min(h,J+2),le=Math.min(v,re+2),xe=X;xef&&(f=u[ne]);(function(){let ne=_d(l,c,f,p,0);p=ne.scaleFactor,g=ne.dim,b=ne.matrix,D=Math.max(5,2+Math.floor(m*p)),h=ar(g[0]*g[1]*g[2],-1001),v=new Int32Array(h.length),S=new Float32Array(g[0]),x=new Float32Array(g[1]),w=new Float32Array(g[2]),H(S,l[0],1/p),H(x,l[1],1/p),H(w,l[2],1/p)})(),function(){var ne=0,oe=2*Math.PI/y;M=new Float32Array(y),A=new Float32Array(y);for(var ee=0;ee=0;){if(ne!==X&&ne!==se&&L(ne,Z,J,re))return C=ne,ne;ne=R[++oe]}return C=-1,-1}function L(Z,J,re,X){var se=3*Z,ne=d[Z],oe=n[se]-J,ee=n[se+1]-re,le=n[se+2]-X;return oe*oe+ee*ee+le*le0&&ee=0;)X{t(this._makeSurface(u.data.sd,i))},u=>{console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",u),this.worker.terminate(),this.worker=void 0;let d=this.getSurface(i);t(d)})}else{let r=this.getSurface(i);t(r)}}dispose(){this.worker&&this.worker.terminate()}},P2=class extends Zn{constructor(e,t,i){super(e,t,i),this.type="surface",this.parameters=Object.assign({surfaceType:{type:"select",rebuild:!0,options:{vws:"vws",sas:"sas",ms:"ms",ses:"ses",av:"av"}},probeRadius:{type:"number",precision:1,max:20,min:0,rebuild:!0},smooth:{type:"integer",precision:1,max:10,min:0,rebuild:!0},scaleFactor:{type:"number",precision:1,max:5,min:0,rebuild:!0},cutoff:{type:"number",precision:2,max:50,min:0,rebuild:!0},contour:{type:"boolean",rebuild:!0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},filterSele:{type:"text",rebuild:!0},colorVolume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},this.parameters,{radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add(()=>{this.__forceNewMolsurf=!0}),this.toBePrepared=!0,this.init(i)}init(e){let t=e||{};t.colorScheme=U(t.colorScheme,"uniform"),t.colorValue=U(t.colorValue,14540253),t.disablePicking=U(t.disablePicking,!0),this.surfaceType=U(t.surfaceType,"ms"),this.probeRadius=U(t.probeRadius,1.4),this.smooth=U(t.smooth,2),this.scaleFactor=U(t.scaleFactor,2),this.cutoff=U(t.cutoff,0),this.contour=U(t.contour,!1),this.background=U(t.background,!1),this.opaqueBack=U(t.opaqueBack,!0),this.filterSele=U(t.filterSele,""),this.colorVolume=U(t.colorVolume,void 0),this.useWorker=U(t.useWorker,!0),super.init(e)}prepareData(e,t,i){let r=this.__infoList[t];if(r||(r={},this.__infoList[t]=r),r.molsurf&&r.sele===e.selection.string)i(t);else{if(this.filterSele){let a=e.structure.getView(new tn(this.filterSele)),l=a.boundingBox.getSize(new W),c=Math.max(l.x,l.y,l.z),u=e.getAtomSetWithinPoint(a.center,c/2+6);if((e=e.getView(new tn(e.getAtomSetWithinSelection(u,3).toSeleString()))).atomCount===0)return void i(t)}r.sele=e.selection.string,r.molsurf=new T2(e);let s=this.getSurfaceParams(),o=a=>{r.surface=a,i(t)};this.useWorker?r.molsurf.getSurfaceWorker(s,o):o(r.molsurf.getSurface(s))}}prepare(e){if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach(s=>{s&&s.molsurf&&s.molsurf.dispose()}),this.__infoList.length=0),this.structureView.atomCount===0)return void e();let t=()=>{this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,e()},i=this.assembly==="default"?this.defaultAssembly:this.assembly,r=this.structure.biomolDict[i];r?r.partList.forEach((s,o)=>{let a=s.getView(this.structureView);this.prepareData(a,o,l=>{l===r.partList.length-1&&t()})}):this.prepareData(this.structureView,0,t)}createData(e,t){let i=this.__infoList[t],r=i.surface;if(!r)return;let s={position:r.getPosition(),color:r.getColor(this.getColorParams()),index:r.getFilteredIndex(this.filterSele,e)},o=[];if(r.contour){let a=new yg(s,this.getBufferParams({wireframe:!1}));o.push(a)}else{Object.assign(s,{normal:r.getNormal(),picking:r.getPicking(e.getStructure())});let a=new mg(s,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));if(this.getBufferParams().side=="double"){let l=new gg(a);o.push(l)}else o.push(a)}return{bufferList:o,info:i}}updateData(e,t){let i={};if(e.position||e.radius)return this.__forceNewMolsurf=!0,void this.build();e.color&&(i.color=t.info.surface.getColor(this.getColorParams())),e.index&&(i.index=t.info.surface.getFilteredIndex(this.filterSele,t.sview)),t.bufferList[0].setAttributes(i)}setParameters(e,t={},i){return e&&e.filterSele&&(t.index=!0),e&&e.colorVolume!==void 0&&(t.color=!0),e&&e.wireframe&&(e.contour||e.contour===void 0&&this.contour)&&(e.wireframe=!1),super.setParameters(e,t,i),this}getSurfaceParams(e={}){return Object.assign({type:this.surfaceType,probeRadius:this.probeRadius,scaleFactor:this.scaleFactor,smooth:this.smooth&&!this.contour,cutoff:this.cutoff,contour:this.contour,useWorker:this.useWorker,radiusParams:this.getRadiusParams()},e)}getColorParams(){let e=super.getColorParams();return e.volume=this.colorVolume,e}getAtomRadius(){return 0}clear(){super.clear()}dispose(){this.__infoList.forEach(e=>{e&&e.molsurf&&e.molsurf.dispose()}),this.__infoList.length=0,super.dispose()}};on.add("surface",P2);var I2=class extends Zn{constructor(e,t,i){super(e,t,i),this.type="point",this.parameters=Object.assign({pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{flatShaded:null,wireframe:null,linewidth:null,side:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.pointSize=U(t.pointSize,1),this.sizeAttenuation=U(t.sizeAttenuation,!0),this.sortParticles=U(t.sortParticles,!1),this.useTexture=U(t.useTexture,!1),this.alphaTest=U(t.alphaTest,.5),this.forceTransparent=U(t.forceTransparent,!1),this.edgeBleach=U(t.edgeBleach,0),super.init(t)}createData(e){var t=e.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new Sd(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),r={};e&&!e.position||Object.assign(r,{position:i.position}),e&&!e.color||Object.assign(r,{color:i.color}),t.bufferList[0].setAttributes(r)}getAtomRadius(){return .1}};on.add("point",I2),zt.add("shader/Ribbon.vert",`#define STANDARD +uniform float clipNear; +uniform vec3 clipCenter; +#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING ) +varying vec3 vViewPosition; +#endif +#if defined( RADIUS_CLIP ) +varying vec3 vClipCenter; +#endif +attribute vec3 dir; +attribute float size; +#ifdef PICKING +#include unpack_color +attribute float primitiveId; +varying vec3 vPickingColor; +#else +#include color_pars_vertex +#ifndef FLAT_SHADED +varying vec3 vNormal; +#endif +#endif +#include common +void main(void){ +#ifdef PICKING +vPickingColor = unpackColor( primitiveId ); +#else +#include color_vertex +#include beginnormal_vertex +#include defaultnormal_vertex +#ifndef FLAT_SHADED +vNormal = normalize( transformedNormal ); +#endif +#endif +#include begin_vertex +transformed += normalize( dir ) * size; +#include project_vertex +#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING ) +vViewPosition = -mvPosition.xyz; +#endif +#if defined( RADIUS_CLIP ) +vClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz; +#endif +#include nearclip_vertex +}`);var zz=new Uint16Array([0,1,2,1,3,2]);function Uh(n){return 3*(4*(n.position.length/3-1))}var R2=class extends Jr{constructor(e,t={}){super({position:new Float32Array(Uh(e)),color:new Float32Array(Uh(e)),index:bs(Uh(e),Uh(e)/3),normal:new Float32Array(Uh(e)),picking:e.picking},t),this.vertexShader="Ribbon.vert";let i=e.position.length/3-1,r=4*i,s=3*r;this.addAttributes({dir:{type:"v3",value:new Float32Array(s)}}),this.addAttributes({size:{type:"f",value:new Float32Array(r)}}),e.primitiveId=au(i),this.setAttributes(e),this.makeIndex()}setAttributes(e={}){let t=this.size/4,i=this.geometry.attributes,r,s,o,a,l,c,u,d,f,m,p,_,y,g,b,h,v,S,x;e.position&&(r=e.position,u=i.position.array,i.position.needsUpdate=!0),e.normal&&(s=e.normal,d=i.normal.array,i.normal.needsUpdate=!0),e.size&&(o=e.size,f=i.size.array,i.size.needsUpdate=!0),e.dir&&(a=e.dir,m=i.dir.array,i.dir.needsUpdate=!0),e.color&&(l=e.color,p=i.color.array,i.color.needsUpdate=!0),e.primitiveId&&(c=e.primitiveId,_=i.primitiveId.array,i.primitiveId.needsUpdate=!0);let w=o?o[0]:null;for(y=0;y{if(!(r.residueCount<4)){i.push(r);var s=new aa(r,this.getSplineParams()),o=s.getSubdividedPosition(),a=s.getSubdividedOrientation(),l=s.getSubdividedColor(this.getColorParams()),c=s.getSubdividedPicking(),u=s.getSubdividedSize(this.getRadiusParams());t.push(new R2({position:o.position,normal:a.binormal,dir:a.normal,color:l.color,size:u.size,picking:c.picking},this.getBufferParams()))}},e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,r=t.polymerList.length;for(i=0;i{if(l.residueCount<4||l.isNucleic())return;let c=new vg(l),u=c.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());t+=u.size.length,i.push(u),r.push(c)},e.getSelection());let s={begin:new Float32Array(3*t),end:new Float32Array(3*t),size:new Float32Array(t),color:new Float32Array(3*t),picking:{}},o=new Float32Array(t),a=0;return i.forEach(function(l){s.begin.set(l.begin,3*a),s.end.set(l.end,3*a),s.size.set(l.size,a),s.color.set(l.color,3*a),o.set(l.picking.array,a),a+=l.size.length}),t&&(s.picking=new oo(o,e.getStructure())),{bufferList:[new ao({position1:s.begin,position2:s.end,color:s.color,color2:s.color,radius:s.size,picking:s.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:i,helixbundleList:r,axisData:s}}updateData(e,t){if((e=e||{}).position)this.build();else{var i={};if(e.color||e.radius){var r=0;t.helixbundleList.forEach(s=>{var o=s.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());e.color&&t.axisData.color.set(o.color,3*r),(e.radius||e.scale)&&t.axisData.size.set(o.size,r),r+=o.size.length}),e.color&&Object.assign(i,{color:t.axisData.color,color2:t.axisData.color}),(e.radius||e.scale)&&Object.assign(i,{radius:t.axisData.size})}t.bufferList[0].setAttributes(i)}}};on.add("rocket",L2);var D2=class extends Cd{constructor(e,t,i){super(e,t,i),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}init(e){var t=e||{};t.aspectRatio=1,t.tension=U(t.tension,.5),t.radiusScale=U(t.radiusScale,5),t.smoothSheet=!1,this.smooth=U(t.smooth,2),super.init(t)}getSpline(e){var t=new Kc(e);return new aa(e,this.getSplineParams({directional:!1,positionIterator:t.getCenterIterator(this.smooth)}))}};on.add("rope",D2);var N2=class extends Zn{constructor(e,t,i){super(e,t,i),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}init(e){var t=e||{};t.useInteriorColor=U(t.useInteriorColor,!0),super.init(t)}createData(e){return{bufferList:[new la(e.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),r={};e&&!e.position||Object.assign(r,{position:i.position}),e&&!e.color||Object.assign(r,{color:i.color}),e&&!e.radius||Object.assign(r,{radius:i.radius}),t.bufferList[0].setAttributes(r)}};function TT(n){return 3*(n.position.length/3-1)*2}on.add("spacefill",N2);var F2=class extends Pr{constructor(e,t={}){super({position:new Float32Array(TT(e)),color:new Float32Array(TT(e))},t),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.setAttributes(e)}setAttributes(e){let t,i,r,s,o=this.geometry.attributes;if(e.position&&(t=e.position,r=o.position.array,o.position.needsUpdate=!0),e.color&&(i=e.color,s=o.color.array,o.color.needsUpdate=!0),!t&&!i)return void we.warn("TraceBuffer.prototype.setAttributes no data");let a,l,c=this.size-1;for(let u=0;u{if(!(r.residueCount<4)){i.push(r);var s=new aa(r,this.getSplineParams()),o=s.getSubdividedPosition(),a=s.getSubdividedColor(this.getColorParams());t.push(new F2(Object.assign({},o,a),this.getBufferParams()))}},e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,r=t.polymerList.length;for(i=0;i{e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox)})}},Gz=Object.assign({aspectRatio:1.5,radialSegments:50,openEnded:!1,disableImpostor:!1},ki),H2=class{constructor(e,t={}){this.group=new $t,this.wireframeGroup=new $t,this.pickingGroup=new $t,this.visible=!0,this.parameters=or(t,this.defaultParameters),this.splitPosition=new Float32Array(e.position1.length),this.cylinderRadius=new Float32Array(e.radius.length);let i=this.makeAttributes(e),r={radialSegments:this.parameters.radialSegments,openEnded:this.parameters.openEnded,disableImpostor:this.parameters.disableImpostor};this.cylinderBuffer=new ao(i.cylinder,r),this.coneBuffer=new a0(i.cone,r),this.geometry=new V2([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.matrix=U(t.matrix,new qe),this.picking=e.picking}get defaultParameters(){return Gz}set matrix(e){Pr.prototype.setMatrix.call(this,e)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking}makeAttributes(e={}){let t=this.splitPosition,i=this.cylinderRadius,r=this.parameters.aspectRatio,s,o,a={},l={};if(e.radius){for(s=0,o=i.length;s0&&(D=1/Math.sqrt(D),C[0]=P[0]*D,C[1]=P[1]*D,C[2]=P[2]*D),C}function d(C,P){return C[0]*P[0]+C[1]*P[1]+C[2]*P[2]}function f(C,P,E){let I=P[0],O=P[1],D=P[2],N=E[0],H=E[1],z=E[2];return C[0]=O*z-D*H,C[1]=D*N-I*z,C[2]=I*H-O*N,C}n.zero=e,n.clone=function(C){let P=e();return P[0]=C[0],P[1]=C[1],P[2]=C[2],P},n.isFinite=function(C){return gx(C[0])&&gx(C[1])&&gx(C[2])},n.hasNaN=function(C){return isNaN(C[0])||isNaN(C[1])||isNaN(C[2])},n.setNaN=function(C){return C[0]=NaN,C[1]=NaN,C[2]=NaN,C},n.fromObj=function(C){return t(C.x,C.y,C.z)},n.toObj=function(C){return{x:C[0],y:C[1],z:C[2]}},n.fromArray=function(C,P,E){return C[0]=P[E+0],C[1]=P[E+1],C[2]=P[E+2],C},n.toArray=function(C,P,E){return P[E+0]=C[0],P[E+1]=C[1],P[E+2]=C[2],P},n.create=t,n.ofArray=function(C){let P=e();return P[0]=C[0],P[1]=C[1],P[2]=C[2],P},n.set=function(C,P,E,I){return C[0]=P,C[1]=E,C[2]=I,C},n.copy=i,n.add=r,n.sub=s,n.mul=function(C,P,E){return C[0]=P[0]*E[0],C[1]=P[1]*E[1],C[2]=P[2]*E[2],C},n.div=function(C,P,E){return C[0]=P[0]/E[0],C[1]=P[1]/E[1],C[2]=P[2]/E[2],C},n.scale=o,n.scaleAndAdd=a,n.scaleAndSub=function(C,P,E,I){return C[0]=P[0]-E[0]*I,C[1]=P[1]-E[1]*I,C[2]=P[2]-E[2]*I,C},n.addScalar=function(C,P,E){return C[0]=P[0]+E,C[1]=P[1]+E,C[2]=P[2]+E,C},n.subScalar=function(C,P,E){return C[0]=P[0]-E,C[1]=P[1]-E,C[2]=P[2]-E,C},n.round=function(C,P){return C[0]=Math.round(P[0]),C[1]=Math.round(P[1]),C[2]=Math.round(P[2]),C},n.ceil=function(C,P){return C[0]=Math.ceil(P[0]),C[1]=Math.ceil(P[1]),C[2]=Math.ceil(P[2]),C},n.floor=function(C,P){return C[0]=Math.floor(P[0]),C[1]=Math.floor(P[1]),C[2]=Math.floor(P[2]),C},n.trunc=function(C,P){return C[0]=Math.trunc(P[0]),C[1]=Math.trunc(P[1]),C[2]=Math.trunc(P[2]),C},n.abs=function(C,P){return C[0]=Math.abs(P[0]),C[1]=Math.abs(P[1]),C[2]=Math.abs(P[2]),C},n.min=function(C,P,E){return C[0]=Math.min(P[0],E[0]),C[1]=Math.min(P[1],E[1]),C[2]=Math.min(P[2],E[2]),C},n.max=function(C,P,E){return C[0]=Math.max(P[0],E[0]),C[1]=Math.max(P[1],E[1]),C[2]=Math.max(P[2],E[2]),C},n.clamp=function(C,P,E,I){return C[0]=Math.max(E[0],Math.min(I[0],P[0])),C[1]=Math.max(E[1],Math.min(I[1],P[1])),C[2]=Math.max(E[2],Math.min(I[2],P[2])),C},n.distance=function(C,P){let E=P[0]-C[0],I=P[1]-C[1],O=P[2]-C[2];return Math.sqrt(E*E+I*I+O*O)},n.squaredDistance=function(C,P){let E=P[0]-C[0],I=P[1]-C[1],O=P[2]-C[2];return E*E+I*I+O*O},n.magnitude=function(C){let P=C[0],E=C[1],I=C[2];return Math.sqrt(P*P+E*E+I*I)},n.squaredMagnitude=l,n.setMagnitude=function(C,P,E){return o(C,u(C,P),E)},n.negate=c,n.inverse=function(C,P){return C[0]=1/P[0],C[1]=1/P[1],C[2]=1/P[2],C},n.normalize=u,n.dot=d,n.cross=f,n.lerp=function(C,P,E,I){let O=P[0],D=P[1],N=P[2];return C[0]=O+I*(E[0]-O),C[1]=D+I*(E[1]-D),C[2]=N+I*(E[2]-N),C};let m=e();function p(C,P){let E=Math.sqrt(l(C)*l(P));if(E===0)return Math.PI/2;let I=d(C,P)/E;return Math.acos(OT(I,-1,1))}n.slerp=function(C,P,E,I){let O=OT(d(P,E),-1,1),D=Math.acos(O)*I;return a(m,E,P,-O),u(m,m),r(C,o(C,P,Math.cos(D)),o(m,m,Math.sin(D)))},n.hermite=function(C,P,E,I,O,D){let N=D*D,H=N*(2*D-3)+1,z=N*(D-2)+D,L=N*(D-1),F=N*(3-2*D);return C[0]=P[0]*H+E[0]*z+I[0]*L+O[0]*F,C[1]=P[1]*H+E[1]*z+I[1]*L+O[1]*F,C[2]=P[2]*H+E[2]*z+I[2]*L+O[2]*F,C},n.bezier=function(C,P,E,I,O,D){let N=1-D,H=N*N,z=D*D,L=H*N,F=3*D*H,te=3*z*N,Q=z*D;return C[0]=P[0]*L+E[0]*F+I[0]*te+O[0]*Q,C[1]=P[1]*L+E[1]*F+I[1]*te+O[1]*Q,C[2]=P[2]*L+E[2]*F+I[2]*te+O[2]*Q,C},n.quadraticBezier=function(C,P,E,I,O){return C[0]=mx(P[0],E[0],I[0],O),C[1]=mx(P[1],E[1],I[1],O),C[2]=mx(P[2],E[2],I[2],O),C},n.spline=function(C,P,E,I,O,D,N){return C[0]=px(P[0],E[0],I[0],O[0],D,N),C[1]=px(P[1],E[1],I[1],O[1],D,N),C[2]=px(P[2],E[2],I[2],O[2],D,N),C},n.random=function(C,P){let E=2*Math.random()*Math.PI,I=2*Math.random()-1,O=Math.sqrt(1-I*I)*P;return C[0]=Math.cos(E)*O,C[1]=Math.sin(E)*O,C[2]=I*P,C},n.transformMat4=function(C,P,E){let I=P[0],O=P[1],D=P[2],N=1/(E[3]*I+E[7]*O+E[11]*D+E[15]||1);return C[0]=(E[0]*I+E[4]*O+E[8]*D+E[12])*N,C[1]=(E[1]*I+E[5]*O+E[9]*D+E[13])*N,C[2]=(E[2]*I+E[6]*O+E[10]*D+E[14])*N,C},n.transformDirection=function(C,P,E){let I=P[0],O=P[1],D=P[2];return C[0]=E[0]*I+E[4]*O+E[8]*D,C[1]=E[1]*I+E[5]*O+E[9]*D,C[2]=E[2]*I+E[6]*O+E[10]*D,u(C,C)},n.transformMat4Offset=function(C,P,E,I,O,D){let N=P[0+O],H=P[1+O],z=P[2+O],L=1/(E[3+D]*N+E[7+D]*H+E[11+D]*z+E[15+D]||1);return C[0+I]=(E[0+D]*N+E[4+D]*H+E[8+D]*z+E[12+D])*L,C[1+I]=(E[1+D]*N+E[5+D]*H+E[9+D]*z+E[13+D])*L,C[2+I]=(E[2+D]*N+E[6+D]*H+E[10+D]*z+E[14+D])*L,C},n.transformDirectionOffset=function(C,P,E,I,O,D){let N=P[0+O],H=P[1+O],z=P[2+O];C[0+I]=E[0+D]*N+E[4+D]*H+E[8+D]*z,C[1+I]=E[1+D]*N+E[5+D]*H+E[9+D]*z,C[2+I]=E[2+D]*N+E[6+D]*H+E[10+D]*z;let L=Math.hypot(C[0+I],C[1+I],C[2+I]);return L>0&&(C[0+I]/=L,C[1+I]/=L,C[2+I]/=L),C},n.transformMat3=function(C,P,E){let I=P[0],O=P[1],D=P[2];return C[0]=I*E[0]+O*E[3]+D*E[6],C[1]=I*E[1]+O*E[4]+D*E[7],C[2]=I*E[2]+O*E[5]+D*E[8],C},n.transformQuat=function(C,P,E){let I=P[0],O=P[1],D=P[2],N=E[0],H=E[1],z=E[2],L=E[3],F=L*I+H*D-z*O,te=L*O+z*I-N*D,Q=L*D+N*O-H*I,Z=-N*I-H*O-z*D;return C[0]=F*L+Z*-N+te*-z-Q*-H,C[1]=te*L+Z*-H+Q*-N-F*-z,C[2]=Q*L+Z*-z+F*-H-te*-N,C},n.angle=p;let _=e(),y=e(),g=e(),b=e(),h=e(),v=e(),S=e();n.dihedralAngle=function(C,P,E,I){s(_,C,P),s(y,E,P),s(g,P,E),s(b,I,E),f(h,_,y),f(v,g,b);let O=p(h,v);return f(S,h,v),d(y,S)>0?O:-O},n.directionFromSpherical=function(C,P,E,I){return n.set(C,I*Math.cos(E)*Math.sin(P),I*Math.sin(E)*Math.sin(P),I*Math.cos(P))},n.exactEquals=function(C,P){return C[0]===P[0]&&C[1]===P[1]&&C[2]===P[2]},n.equals=function(C,P){let E=C[0],I=C[1],O=C[2],D=P[0],N=P[1],H=P[2];return Math.abs(E-D)<=kn*Math.max(1,Math.abs(E),Math.abs(D))&&Math.abs(I-N)<=kn*Math.max(1,Math.abs(I),Math.abs(N))&&Math.abs(O-H)<=kn*Math.max(1,Math.abs(O),Math.abs(H))};let x=e();n.makeRotation=function(C,P,E){let I=p(P,E);if(Math.abs(I)<1e-4)return Ko.setIdentity(C);if(Math.abs(I-Math.PI)0?i(C,P):c(C,i(C,P)),C};let T=e(),R=e();n.triangleNormal=function(C,P,E,I){return s(T,E,P),s(R,I,P),u(C,f(C,T,R))},n.toString=function(C,P){return`[${C[0].toPrecision(P)} ${C[1].toPrecision(P)} ${C[2].toPrecision(P)}]`},n.origin=t(0,0,0),n.unit=t(1,1,1),n.negUnit=t(-1,-1,-1),n.unitX=t(1,0,0),n.unitY=t(0,1,0),n.unitZ=t(0,0,1),n.negUnitX=t(-1,0,0),n.negUnitY=t(0,-1,0),n.negUnitZ=t(0,0,-1)})(jt||(jt={}));var Kz=Math.PI/180;function $a(n){return n*Kz}function Ko(){return Ko.zero()}function Qm(){return Qm.zero()}function q2(){return q2.zero()}function Y2(){return Y2.zero()}function c0(n){throw new Error("unreachable")}function Z2(){return Z2.zero()}var Kh,dn,BT,Ii;function Uc(n,e,t){let i=e,r=0,s=1;for(n.charCodeAt(i)===45?(s=-1,++i):n.charCodeAt(i)===43&&++i;i9||o<0)return s*r|0;r=10*r+o|0}return s*r}function UT(n,e,t,i){return e.charCodeAt(t)===43&&t++,n*Math.pow(10,Uc(e,t,i))}function od(n,e,t){let i=e,r=1,s=0,o=0,a=1;for(n.charCodeAt(i)===45?(r=-1,++i):n.charCodeAt(i)===43&&++i;i=0&&l<10)){if(l===-2){for(++i;i=0&&l<10))return l===53||l===21?UT(r*(s+o/a),n,i+1,t):r*(s+o/a);o=10*o+l,a*=10,++i}return r*(s+o/a)}if(l===53||l===21)return UT(r*s,n,i+1,t);break}s=10*s+l,++i}return r*s}function zT(n,e,t,i){return{schema:t,__array:void 0,isDefined:i===0,rowCount:e,value:r=>n,valueKind:r=>i,toArray:r=>{let{array:s}=kd(e,r);for(let o=0,a=s.length;o!0}}function Cm({value:n,valueKind:e,areValuesEqual:t,rowCount:i,schema:r}){return{schema:r,__array:void 0,isDefined:!0,rowCount:i,value:n,valueKind:e||(s=>0),toArray:s=>{let{array:o,start:a}=kd(i,s);for(let l=0,c=o.length;ln(s)===n(o))}}function to({array:n,schema:e,valueKind:t}){let i=n.length,r=e.T,s=e.valueType==="str"?e.transform==="lowercase"?a=>{let l=n[a];return typeof l=="string"?l.toLowerCase():`${l??r}`.toLowerCase()}:e.transform==="uppercase"?a=>{let l=n[a];return typeof l=="string"?l.toUpperCase():`${l??r}`.toUpperCase()}:a=>{let l=n[a];return typeof l=="string"?l:`${l??r}`}:a=>n[a],o=Rw(n);return{schema:e,__array:n,isDefined:!0,rowCount:i,value:s,valueKind:t||(a=>0),toArray:e.valueType==="str"?e.transform==="lowercase"?a=>{let{start:l,end:c}=Rc(i,a),u=new(a&&a.array!==void 0?a.array:n.constructor)(c-l);for(let d=0,f=c-l;d{let{start:l,end:c}=Rc(i,a),u=new(a&&a.array!==void 0?a.array:n.constructor)(c-l);for(let d=0,f=c-l;d{let{start:l,end:c}=Rc(i,a),u=new(a&&a.array!==void 0?a.array:n.constructor)(c-l);for(let d=0,f=c-l;dl0(n,a):a=>{let{start:l,end:c}=Rc(i,a);if(l===0&&c===n.length)return n;let u=new(a&&a.array!==void 0?a.array:n.constructor)(c-l);for(let d=0,f=c-l;dn[a]===n[l]}}function Jz(n,e,t){return n.isDefined?e===0&&t===n.rowCount?n:n.__array&&Rw(n.__array)?function(i,r,s){let o=l0(i.__array,{start:r,end:s}),a=i.valueKind;return to({array:o,schema:i.schema,valueKind:l=>a(r+l)})}(n,e,t):function(i,r,s){let o=i.value,a=i.valueKind,l=i.areValuesEqual,c=r===0?o:d=>o(d+r),u=s-r;return{schema:i.schema,__array:void 0,isDefined:i.isDefined,rowCount:u,value:c,valueKind:r===0?a:d=>a(d+r),toArray:d=>{let{array:f}=kd(u,d);for(let m=0,p=f.length;ml(d+r,f+r)}}(n,e,t):dn.Undefined(t-e,n.schema)}function Qz(n,e,t){return n.rowCount===0||t&&function(i,r){if(i.length!==r)return!1;for(let s=0,o=i.length;sa(r[l])})}(n,e):function(i,r){let s=i.value,o=i.valueKind,a=i.areValuesEqual,l=u=>s(r[u]),c=r.length;return{schema:i.schema,__array:void 0,isDefined:i.isDefined,rowCount:c,value:l,valueKind:u=>o(r[u]),toArray:u=>{let{array:d}=kd(c,u);for(let f=0,m=d.length;fa(r[u],r[d])}}(n,e)}function eg(n,e,t){return n[e]-n[t]}function Jh(n,e,t){let i=n[e];n[e]=n[t],n[t]=i}function _I(n,e,t,i){let r=t+i>>1;return e(n,t,i)>0?e(n,t,r)>0?e(n,r,i)>0?r:i:t:e(n,i,r)>0?e(n,r,t)>0?r:t:i}function e6(n,e,t){let{cmp:i,swap:r,data:s,parts:o}=n,a=e+1,l=t;for(r(s,e,_I(s,i,e,t));i(s,l,e)>0;)--l;for(let c=e+1;c<=l;c++){let u=i(s,c,e);if(u>0){for(r(s,c,l),--l;i(s,l,e)>0;)--l;c--}else u===0&&(r(s,c,a),a++)}for(let c=e;c=i&&e(n,o,o+1)>0;)t(n,o,o+1),o-=1}}function K2(n,e,t){let{parts:i}=n;for(;eo;)--s;for(let a=t+1;a<=s;a++){let l=n[a];if(l>o){for(Jh(n,a,s),--s;n[s]>o;)--s;a--}else l===o&&(Jh(n,a,r),++r)}for(let a=t;a=e&&n[s]>r;)n[s+1]=n[s],s-=1;n[s+1]=r}}function J2(n,e,t,i){for(;tS)return!1;return!0}function a(h,v,S,x){h[4*S+v]=x}function l(h,v){return h[0]=v[0],h[1]=v[1],h[2]=v[2],h[3]=v[3],h[4]=v[4],h[5]=v[5],h[6]=v[6],h[7]=v[7],h[8]=v[8],h[9]=v[9],h[10]=v[10],h[11]=v[11],h[12]=v[12],h[13]=v[13],h[14]=v[14],h[15]=v[15],h}function c(h,v){let S=v[0]+v[5]+v[10],x=0;return S>0?(x=2*Math.sqrt(S+1),h[3]=.25*x,h[0]=(v[6]-v[9])/x,h[1]=(v[8]-v[2])/x,h[2]=(v[1]-v[4])/x):v[0]>v[5]&&v[0]>v[10]?(x=2*Math.sqrt(1+v[0]-v[5]-v[10]),h[3]=(v[6]-v[9])/x,h[0]=.25*x,h[1]=(v[1]+v[4])/x,h[2]=(v[8]+v[2])/x):v[5]>v[10]?(x=2*Math.sqrt(1+v[5]-v[0]-v[10]),h[3]=(v[8]-v[2])/x,h[0]=(v[1]+v[4])/x,h[1]=.25*x,h[2]=(v[6]+v[9])/x):(x=2*Math.sqrt(1+v[10]-v[0]-v[5]),h[3]=(v[1]-v[4])/x,h[0]=(v[8]+v[2])/x,h[1]=(v[6]+v[9])/x,h[2]=.25*x),h}function u(h,v){let S=v[0],x=v[1],w=v[2],A=v[3],M=v[4],T=v[5],R=v[6],C=v[7],P=v[8],E=v[9],I=v[10],O=v[11],D=v[12],N=v[13],H=v[14],z=v[15],L=S*T-x*M,F=S*R-w*M,te=S*C-A*M,Q=x*R-w*T,Z=x*C-A*T,J=w*C-A*R,re=P*N-E*D,X=P*H-I*D,se=P*z-O*D,ne=E*H-I*N,oe=E*z-O*N,ee=I*z-O*H,le=L*ee-F*oe+te*ne+Q*se-Z*X+J*re;return!!le&&(le=1/le,h[0]=(T*ee-R*oe+C*ne)*le,h[1]=(w*oe-x*ee-A*ne)*le,h[2]=(N*J-H*Z+z*Q)*le,h[3]=(I*Z-E*J-O*Q)*le,h[4]=(R*se-M*ee-C*X)*le,h[5]=(S*ee-w*se+A*X)*le,h[6]=(H*te-D*J-z*F)*le,h[7]=(P*J-I*te+O*F)*le,h[8]=(M*oe-T*se+C*re)*le,h[9]=(x*se-S*oe-A*re)*le,h[10]=(D*Z-N*te+z*L)*le,h[11]=(E*te-P*Z-O*L)*le,h[12]=(T*X-M*ne-R*re)*le,h[13]=(S*ne-x*X+w*re)*le,h[14]=(N*F-D*Q-H*L)*le,h[15]=(P*Q-E*F+I*L)*le,!0)}function d(h,v,S){let x=v[0],w=v[1],A=v[2],M=v[3],T=v[4],R=v[5],C=v[6],P=v[7],E=v[8],I=v[9],O=v[10],D=v[11],N=v[12],H=v[13],z=v[14],L=v[15],F=S[0],te=S[1],Q=S[2],Z=S[3];return h[0]=F*x+te*T+Q*E+Z*N,h[1]=F*w+te*R+Q*I+Z*H,h[2]=F*A+te*C+Q*O+Z*z,h[3]=F*M+te*P+Q*D+Z*L,F=S[4],te=S[5],Q=S[6],Z=S[7],h[4]=F*x+te*T+Q*E+Z*N,h[5]=F*w+te*R+Q*I+Z*H,h[6]=F*A+te*C+Q*O+Z*z,h[7]=F*M+te*P+Q*D+Z*L,F=S[8],te=S[9],Q=S[10],Z=S[11],h[8]=F*x+te*T+Q*E+Z*N,h[9]=F*w+te*R+Q*I+Z*H,h[10]=F*A+te*C+Q*O+Z*z,h[11]=F*M+te*P+Q*D+Z*L,F=S[12],te=S[13],Q=S[14],Z=S[15],h[12]=F*x+te*T+Q*E+Z*N,h[13]=F*w+te*R+Q*I+Z*H,h[14]=F*A+te*C+Q*O+Z*z,h[15]=F*M+te*P+Q*D+Z*L,h}function f(h,v,S){let x=S[0],w=S[1],A=S[2],M=Math.sqrt(x*x+w*w+A*A);if(Math.abs(M)0&&(O=1/Math.sqrt(O),P*=O,E*=O,I*=O);let D=R*I-C*E,N=C*P-T*I,H=T*E-R*P;return O=D*D+N*N+H*H,O>0&&(O=1/Math.sqrt(O),D*=O,N*=O,H*=O),h[0]=D,h[1]=N,h[2]=H,h[3]=0,h[4]=E*H-I*N,h[5]=I*D-P*H,h[6]=P*N-E*D,h[7]=0,h[8]=P,h[9]=E,h[10]=I,h[11]=0,h[12]=w,h[13]=A,h[14]=M,h[15]=1,h},n.fromPermutation=function(h,v){r(h);for(let S=0;S<4;S++)a(h,S,v[S],1);return h},n.getMaxScaleOnAxis=function(h){let v=h[0]*h[0]+h[1]*h[1]+h[2]*h[2],S=h[4]*h[4]+h[5]*h[5]+h[6]*h[6],x=h[8]*h[8]+h[9]*h[9]+h[10]*h[10];return Math.sqrt(Math.max(v,S,x))};let y=[1,0,0],g=[0,1,0],b=[0,0,1];n.rotX90=f(e(),$a(90),y),n.rotX180=f(e(),$a(180),y),n.rotY90=f(e(),$a(90),g),n.rotY180=f(e(),$a(180),g),n.rotY270=f(e(),$a(270),g),n.rotZ90=f(e(),$a(90),b),n.rotZ180=f(e(),$a(180),b),n.rotXY90=d(e(),n.rotX90,n.rotY90),n.rotZY90=d(e(),n.rotZ90,n.rotY90),n.rotZYZ90=d(e(),n.rotZY90,n.rotZ90),n.rotZ90X180=d(e(),n.rotZ90,n.rotX180),n.rotY90Z180=d(e(),n.rotY90,n.rotZ180),n.id=t()})(Ko||(Ko={})),function(n){function e(){let x=[.1,0,0,0,0,0,0,0,0];return x[0]=0,x}function t(){let x=e();return x[0]=1,x[1]=0,x[2]=0,x[3]=0,x[4]=1,x[5]=0,x[6]=0,x[7]=0,x[8]=1,x}function i(x,w){return x[0]=w[0],x[1]=w[1],x[2]=w[2],x[3]=w[4],x[4]=w[5],x[5]=w[6],x[6]=w[8],x[7]=w[9],x[8]=w[10],x}n.zero=e,n.identity=t,n.setIdentity=function(x){return x[0]=1,x[1]=0,x[2]=0,x[3]=0,x[4]=1,x[5]=0,x[6]=0,x[7]=0,x[8]=1,x},n.toArray=function(x,w,A){return w[A+0]=x[0],w[A+1]=x[1],w[A+2]=x[2],w[A+3]=x[3],w[A+4]=x[4],w[A+5]=x[5],w[A+6]=x[6],w[A+7]=x[7],w[A+8]=x[8],w},n.fromArray=function(x,w,A){return x[0]=w[A+0],x[1]=w[A+1],x[2]=w[A+2],x[3]=w[A+3],x[4]=w[A+4],x[5]=w[A+5],x[6]=w[A+6],x[7]=w[A+7],x[8]=w[A+8],x},n.fromColumns=function(x,w,A,M){return x[0]=w[0],x[1]=w[1],x[2]=w[2],x[3]=A[0],x[4]=A[1],x[5]=A[2],x[6]=M[0],x[7]=M[1],x[8]=M[2],x},n.fromMat4=i;let r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];n.fromEuler=function(x,w,A){return Ko.fromEuler(r,w,A),i(x,r)},n.create=function(x,w,A,M,T,R,C,P,E){let I=e();return I[0]=x,I[1]=w,I[2]=A,I[3]=M,I[4]=T,I[5]=R,I[6]=C,I[7]=P,I[8]=E,I};let s=t();function o(x,w,A){for(let M=0;M<9;M++)if(Math.abs(x[M]-w[M])>A)return!1;return!0}function a(x,w){return x[0]=w[0],x[1]=w[1],x[2]=w[2],x[3]=w[3],x[4]=w[4],x[5]=w[5],x[6]=w[6],x[7]=w[7],x[8]=w[8],x}function l(x,w){if(x===w){let A=w[1],M=w[2],T=w[5];x[1]=w[3],x[2]=w[6],x[3]=A,x[5]=w[7],x[6]=M,x[7]=T}else x[0]=w[0],x[1]=w[3],x[2]=w[6],x[3]=w[1],x[4]=w[4],x[5]=w[7],x[6]=w[2],x[7]=w[5],x[8]=w[8];return x}function c(x,w){let A=w[0],M=w[1],T=w[2],R=w[3],C=w[4],P=w[5],E=w[6],I=w[7],O=w[8],D=O*C-P*I,N=-O*R+P*E,H=I*R-C*E,z=A*D+M*N+T*H;return z?(z=1/z,x[0]=D*z,x[1]=(-O*M+T*I)*z,x[2]=(P*M-T*C)*z,x[3]=N*z,x[4]=(O*A-T*E)*z,x[5]=(-P*A+T*R)*z,x[6]=H*z,x[7]=(-I*A+M*E)*z,x[8]=(C*A-M*R)*z,x):(console.warn("non-invertible matrix.",w),x)}function u(x){let w=x[0],A=x[1],M=x[2],T=x[3],R=x[4],C=x[5],P=x[6],E=x[7],I=x[8];return w*(I*R-C*E)+A*(-I*T+C*P)+M*(E*T-R*P)}function d(x){return x[0]+x[4]+x[8]}function f(x,w,A){return x[0]=w[0]-A[0],x[1]=w[1]-A[1],x[2]=w[2]-A[2],x[3]=w[3]-A[3],x[4]=w[4]-A[4],x[5]=w[5]-A[5],x[6]=w[6]-A[6],x[7]=w[7]-A[7],x[8]=w[8]-A[8],x}function m(x,w,A){return x[0]=w[0]*A,x[1]=w[1]*A,x[2]=w[2]*A,x[3]=w[3]*A,x[4]=w[4]*A,x[5]=w[5]*A,x[6]=w[6]*A,x[7]=w[7]*A,x[8]=w[8]*A,x}n.isIdentity=function(x,w){return o(x,s,w===void 0?kn:w)},n.hasNaN=function(x){for(let w=0;w<9;w++)if(isNaN(x[w]))return!0;return!1},n.clone=function(x){return a(e(),x)},n.areEqual=o,n.setValue=function(x,w,A,M){x[3*A+w]=M},n.getValue=function(x,w,A){return x[3*A+w]},n.copy=a,n.transpose=l,n.invert=c,n.symmtricFromUpper=function(x,w){return x===w?(x[3]=w[1],x[6]=w[2],x[7]=w[5]):(x[0]=w[0],x[1]=w[1],x[2]=w[2],x[3]=w[1],x[4]=w[4],x[5]=w[5],x[6]=w[2],x[7]=w[5],x[8]=w[8]),x},n.symmtricFromLower=function(x,w){return x===w?(x[1]=w[3],x[2]=w[6],x[5]=w[7]):(x[0]=w[0],x[1]=w[3],x[2]=w[6],x[3]=w[3],x[4]=w[4],x[5]=w[7],x[6]=w[6],x[7]=w[7],x[8]=w[8]),x},n.determinant=u,n.trace=d,n.sub=f,n.add=function(x,w,A){return x[0]=w[0]+A[0],x[1]=w[1]+A[1],x[2]=w[2]+A[2],x[3]=w[3]+A[3],x[4]=w[4]+A[4],x[5]=w[5]+A[5],x[6]=w[6]+A[6],x[7]=w[7]+A[7],x[8]=w[8]+A[8],x},n.mul=function(x,w,A){let M=w[0],T=w[1],R=w[2],C=w[3],P=w[4],E=w[5],I=w[6],O=w[7],D=w[8],N=A[0],H=A[1],z=A[2],L=A[3],F=A[4],te=A[5],Q=A[6],Z=A[7],J=A[8];return x[0]=N*M+H*C+z*I,x[1]=N*T+H*P+z*O,x[2]=N*R+H*E+z*D,x[3]=L*M+F*C+te*I,x[4]=L*T+F*P+te*O,x[5]=L*R+F*E+te*D,x[6]=Q*M+Z*C+J*I,x[7]=Q*T+Z*P+J*O,x[8]=Q*R+Z*E+J*D,x},n.subScalar=function(x,w,A){return x[0]=w[0]-A,x[1]=w[1]-A,x[2]=w[2]-A,x[3]=w[3]-A,x[4]=w[4]-A,x[5]=w[5]-A,x[6]=w[6]-A,x[7]=w[7]-A,x[8]=w[8]-A,x},n.addScalar=function(x,w,A){return x[0]=w[0]+A,x[1]=w[1]+A,x[2]=w[2]+A,x[3]=w[3]+A,x[4]=w[4]+A,x[5]=w[5]+A,x[6]=w[6]+A,x[7]=w[7]+A,x[8]=w[8]+A,x},n.mulScalar=m;let p=Math.PI/3,_=e();n.symmetricEigenvalues=function(x,w){let A=w[1]*w[1]+w[2]*w[2]+w[5]*w[5];if(A===0)x[0]=w[0],x[1]=w[4],x[2]=w[8];else{let M=d(w)/3,T=w[0]-M,R=w[4]-M,C=w[8]-M,P=T*T+R*R+C*C+2*A,E=Math.sqrt(P/6);m(_,n.Identity,M),f(_,w,_),m(_,_,1/E);let I=u(_)/2,O=I<=-1?p:I>=1?0:Math.acos(I)/3;x[0]=M+2*E*Math.cos(O),x[2]=M+2*E*Math.cos(O+2*p),x[1]=3*M-x[0]-x[2]}return x};let y=[.1,0,0],g=[.1,0,0],b=[.1,0,0],h=[.1,0,0],v=[.1,0,0],S=[.1,0,0];n.eigenvector=function(x,w,A){jt.set(y,w[0]-A,w[1],w[2]),jt.set(g,w[1],w[4]-A,w[5]),jt.set(b,w[2],w[5],w[8]-A),jt.cross(h,y,g),jt.cross(v,y,b),jt.cross(S,g,b);let M=jt.dot(h,h),T=jt.dot(v,v),R=jt.dot(S,S),C=M,P=0;return T>C&&(C=T,P=1),R>C&&(P=2),P===0?jt.scale(x,h,1/Math.sqrt(M)):P===1?jt.scale(x,v,1/Math.sqrt(T)):jt.scale(x,S,1/Math.sqrt(R)),x},n.directionTransform=function(x,w){return i(x,w),c(x,x),l(x,x),x},n.Identity=t(),n.innerProduct=function(x,w){return x[0]*w[0]+x[1]*w[1]+x[2]*w[2]+x[3]*w[3]+x[4]*w[4]+x[5]*w[5]+x[6]*w[6]+x[7]*w[7]+x[8]*w[8]}}(Qm||(Qm={})),function(n){function e(){let t=[.1,0];return t[0]=0,t}n.zero=e,n.clone=function(t){let i=e();return i[0]=t[0],i[1]=t[1],i},n.create=function(t,i){let r=e();return r[0]=t,r[1]=i,r},n.hasNaN=function(t){return isNaN(t[0])||isNaN(t[1])},n.toArray=function(t,i,r){return i[r+0]=t[0],i[r+1]=t[1],i},n.fromArray=function(t,i,r){return t[0]=i[r+0],t[1]=i[r+1],t},n.copy=function(t,i){return t[0]=i[0],t[1]=i[1],t},n.set=function(t,i,r){return t[0]=i,t[1]=r,t},n.add=function(t,i,r){return t[0]=i[0]+r[0],t[1]=i[1]+r[1],t},n.sub=function(t,i,r){return t[0]=i[0]-r[0],t[1]=i[1]-r[1],t},n.mul=function(t,i,r){return t[0]=i[0]*r[0],t[1]=i[1]*r[1],t},n.div=function(t,i,r){return t[0]=i[0]/r[0],t[1]=i[1]/r[1],t},n.scale=function(t,i,r){return t[0]=i[0]*r,t[1]=i[1]*r,t},n.round=function(t,i){return t[0]=Math.round(i[0]),t[1]=Math.round(i[1]),t},n.ceil=function(t,i){return t[0]=Math.ceil(i[0]),t[1]=Math.ceil(i[1]),t},n.floor=function(t,i){return t[0]=Math.floor(i[0]),t[1]=Math.floor(i[1]),t},n.distance=function(t,i){let r=i[0]-t[0],s=i[1]-t[1];return Math.sqrt(r*r+s*s)},n.squaredDistance=function(t,i){let r=i[0]-t[0],s=i[1]-t[1];return r*r+s*s},n.magnitude=function(t){let i=t[0],r=t[1];return Math.sqrt(i*i+r*r)},n.squaredMagnitude=function(t){let i=t[0],r=t[1];return i*i+r*r},n.inverse=function(t,i){return t[0]=1/i[0],t[1]=1/i[1],t},n.areEqual=function(t,i){return t[0]===i[0]&&t[1]===i[1]},n.toString=function(t,i){return`[${t[0].toPrecision(i)} ${t[1].toPrecision(i)}}]`}}(q2||(q2={})),function(n){function e(){let i=[.1,0,0,0];return i[0]=0,i}function t(i,r){return i[0]=r.center[0],i[1]=r.center[1],i[2]=r.center[2],i[3]=r.radius,i}n.zero=e,n.clone=function(i){let r=e();return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r},n.create=function(i,r,s,o){let a=e();return a[0]=i,a[1]=r,a[2]=s,a[3]=o,a},n.fromSphere=t,n.ofSphere=function(i){return t(e(),i)},n.hasNaN=function(i){return isNaN(i[0])||isNaN(i[1])||isNaN(i[2])||isNaN(i[3])},n.toArray=function(i,r,s){return r[s+0]=i[0],r[s+1]=i[1],r[s+2]=i[2],r[s+3]=i[3],r},n.fromArray=function(i,r,s){return i[0]=r[s+0],i[1]=r[s+1],i[2]=r[s+2],i[3]=r[s+3],i},n.toVec3Array=function(i,r,s){r[s+0]=i[0],r[s+1]=i[1],r[s+2]=i[2]},n.fromVec3Array=function(i,r,s){return i[0]=r[s+0],i[1]=r[s+1],i[2]=r[s+2],i[3]=0,i},n.copy=function(i,r){return i[0]=r[0],i[1]=r[1],i[2]=r[2],i[3]=r[3],i},n.set=function(i,r,s,o,a){return i[0]=r,i[1]=s,i[2]=o,i[3]=a,i},n.add=function(i,r,s){return i[0]=r[0]+s[0],i[1]=r[1]+s[1],i[2]=r[2]+s[2],i[3]=r[3]+s[3],i},n.distance=function(i,r){let s=r[0]-i[0],o=r[1]-i[1],a=r[2]-i[2],l=r[3]-i[3];return Math.sqrt(s*s+o*o+a*a+l*l)},n.scale=function(i,r,s){return i[0]=r[0]*s,i[1]=r[1]*s,i[2]=r[2]*s,i[4]=r[4]*s,i},n.round=function(i,r){return i[0]=Math.round(r[0]),i[1]=Math.round(r[1]),i[2]=Math.round(r[2]),i[3]=Math.round(r[3]),i},n.ceil=function(i,r){return i[0]=Math.ceil(r[0]),i[1]=Math.ceil(r[1]),i[2]=Math.ceil(r[2]),i[3]=Math.ceil(r[3]),i},n.floor=function(i,r){return i[0]=Math.floor(r[0]),i[1]=Math.floor(r[1]),i[2]=Math.floor(r[2]),i[3]=Math.floor(r[3]),i},n.squaredDistance=function(i,r){let s=r[0]-i[0],o=r[1]-i[1],a=r[2]-i[2],l=r[3]-i[3];return s*s+o*o+a*a+l*l},n.norm=function(i){let r=i[0],s=i[1],o=i[2],a=i[3];return Math.sqrt(r*r+s*s+o*o+a*a)},n.squaredNorm=function(i){let r=i[0],s=i[1],o=i[2],a=i[3];return r*r+s*s+o*o+a*a},n.transformMat4=function(i,r,s){let o=r[0],a=r[1],l=r[2],c=r[3];return i[0]=s[0]*o+s[4]*a+s[8]*l+s[12]*c,i[1]=s[1]*o+s[5]*a+s[9]*l+s[13]*c,i[2]=s[2]*o+s[6]*a+s[10]*l+s[14]*c,i[3]=s[3]*o+s[7]*a+s[11]*l+s[15]*c,i},n.dot=function(i,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]+i[3]*r[3]},n.inverse=function(i,r){return i[0]=1/r[0],i[1]=1/r[1],i[2]=1/r[2],i[3]=1/r[3],i},n.exactEquals=function(i,r){return i[0]===r[0]&&i[1]===r[1]&&i[2]===r[2]&&i[3]===r[3]},n.equals=function(i,r){let s=i[0],o=i[1],a=i[2],l=i[3],c=r[0],u=r[1],d=r[2],f=r[3];return Math.abs(s-c)<=kn*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(o-u)<=kn*Math.max(1,Math.abs(o),Math.abs(u))&&Math.abs(a-d)<=kn*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(l-f)<=kn*Math.max(1,Math.abs(l),Math.abs(f))},n.toString=function(i,r){return`[${i[0].toPrecision(r)} ${i[1].toPrecision(r)} ${i[2].toPrecision(r)} ${i[3].toPrecision(r)}]`}}(Y2||(Y2={})),function(n){function e(){let p=[.1,0,0,0];return p[0]=0,p}function t(){let p=e();return p[3]=1,p}function i(p,_,y){y*=.5;let g=Math.sin(y);return p[0]=g*_[0],p[1]=g*_[1],p[2]=g*_[2],p[3]=Math.cos(y),p}function r(p,_,y,g){let b=_[0],h=_[1],v=_[2],S=_[3],x,w,A,M,T,R=y[0],C=y[1],P=y[2],E=y[3];return w=b*R+h*C+v*P+S*E,w<0&&(w=-w,R=-R,C=-C,P=-P,E=-E),1-w>1e-6?(x=Math.acos(w),A=Math.sin(x),M=Math.sin((1-g)*x)/A,T=Math.sin(g*x)/A):(M=1-g,T=g),p[0]=M*b+T*R,p[1]=M*h+T*C,p[2]=M*v+T*P,p[3]=M*S+T*E,p}function s(p,_){let y=_[0]+_[4]+_[8],g;if(y>0)g=Math.sqrt(y+1),p[3]=.5*g,g=.5/g,p[0]=(_[5]-_[7])*g,p[1]=(_[6]-_[2])*g,p[2]=(_[1]-_[3])*g;else{let b=0;_[4]>_[0]&&(b=1),_[8]>_[3*b+b]&&(b=2);let h=(b+1)%3,v=(b+2)%3;g=Math.sqrt(_[3*b+b]-_[3*h+h]-_[3*v+v]+1),p[b]=.5*g,g=.5/g,p[3]=(_[3*h+v]-_[3*v+h])*g,p[h]=(_[3*h+b]+_[3*b+h])*g,p[v]=(_[3*v+b]+_[3*b+v])*g}return p}n.zero=e,n.identity=t,n.setIdentity=function(p){p[0]=0,p[1]=0,p[2]=0,p[3]=1},n.hasNaN=function(p){return isNaN(p[0])||isNaN(p[1])||isNaN(p[2])||isNaN(p[3])},n.create=function(p,_,y,g){let b=t();return b[0]=p,b[1]=_,b[2]=y,b[3]=g,b},n.setAxisAngle=i,n.getAxisAngle=function(p,_){let y=2*Math.acos(_[3]),g=Math.sin(y/2);return g!==0?(p[0]=_[0]/g,p[1]=_[1]/g,p[2]=_[2]/g):(p[0]=1,p[1]=0,p[2]=0),y},n.multiply=function(p,_,y){let g=_[0],b=_[1],h=_[2],v=_[3],S=y[0],x=y[1],w=y[2],A=y[3];return p[0]=g*A+v*S+b*w-h*x,p[1]=b*A+v*x+h*S-g*w,p[2]=h*A+v*w+g*x-b*S,p[3]=v*A-g*S-b*x-h*w,p},n.rotateX=function(p,_,y){y*=.5;let g=_[0],b=_[1],h=_[2],v=_[3],S=Math.sin(y),x=Math.cos(y);return p[0]=g*x+v*S,p[1]=b*x+h*S,p[2]=h*x-b*S,p[3]=v*x-g*S,p},n.rotateY=function(p,_,y){y*=.5;let g=_[0],b=_[1],h=_[2],v=_[3],S=Math.sin(y),x=Math.cos(y);return p[0]=g*x-h*S,p[1]=b*x+v*S,p[2]=h*x+g*S,p[3]=v*x-b*S,p},n.rotateZ=function(p,_,y){y*=.5;let g=_[0],b=_[1],h=_[2],v=_[3],S=Math.sin(y),x=Math.cos(y);return p[0]=g*x+b*S,p[1]=b*x-g*S,p[2]=h*x+v*S,p[3]=v*x-h*S,p},n.calculateW=function(p,_){let y=_[0],g=_[1],b=_[2];return p[0]=y,p[1]=g,p[2]=b,p[3]=Math.sqrt(Math.abs(1-y*y-g*g-b*b)),p},n.slerp=r,n.invert=function(p,_){let y=_[0],g=_[1],b=_[2],h=_[3],v=y*y+g*g+b*b+h*h,S=v?1/v:0;return p[0]=-y*S,p[1]=-g*S,p[2]=-b*S,p[3]=h*S,p},n.conjugate=function(p,_){return p[0]=-_[0],p[1]=-_[1],p[2]=-_[2],p[3]=_[3],p},n.dot=function(p,_){return p[0]*_[0]+p[1]*_[1]+p[2]*_[2]+p[3]*_[3]},n.fromMat3=s,n.fromEuler=function(p,_,y){let[g,b,h]=_,v=Math.cos(g/2),S=Math.cos(b/2),x=Math.cos(h/2),w=Math.sin(g/2),A=Math.sin(b/2),M=Math.sin(h/2);switch(y){case"XYZ":p[0]=w*S*x+v*A*M,p[1]=v*A*x-w*S*M,p[2]=v*S*M+w*A*x,p[3]=v*S*x-w*A*M;break;case"YXZ":p[0]=w*S*x+v*A*M,p[1]=v*A*x-w*S*M,p[2]=v*S*M-w*A*x,p[3]=v*S*x+w*A*M;break;case"ZXY":p[0]=w*S*x-v*A*M,p[1]=v*A*x+w*S*M,p[2]=v*S*M+w*A*x,p[3]=v*S*x-w*A*M;break;case"ZYX":p[0]=w*S*x-v*A*M,p[1]=v*A*x+w*S*M,p[2]=v*S*M-w*A*x,p[3]=v*S*x+w*A*M;break;case"YZX":p[0]=w*S*x+v*A*M,p[1]=v*A*x+w*S*M,p[2]=v*S*M-w*A*x,p[3]=v*S*x-w*A*M;break;case"XZY":p[0]=w*S*x-v*A*M,p[1]=v*A*x-w*S*M,p[2]=v*S*M+w*A*x,p[3]=v*S*x+w*A*M;break;default:c0()}return p};let o=[0,0,0];function a(p,_){let y=_[0],g=_[1],b=_[2],h=_[3],v=y*y+g*g+b*b+h*h;return v>0&&(v=1/Math.sqrt(v),p[0]=y*v,p[1]=g*v,p[2]=b*v,p[3]=h*v),p}n.fromUnitVec3=function(p,_,y){let g=jt.dot(_,y)+1;return gMath.abs(_[2])?jt.set(o,-_[1],_[0],0):jt.set(o,0,-_[2],_[1])):jt.cross(o,_,y),p[0]=o[0],p[1]=o[1],p[2]=o[2],p[3]=g,a(p,p),p},n.clone=function(p){let _=e();return _[0]=p[0],_[1]=p[1],_[2]=p[2],_[3]=p[3],_},n.toArray=function(p,_,y){return _[y+0]=p[0],_[y+1]=p[1],_[y+2]=p[2],_[y+3]=p[3],_},n.fromArray=function(p,_,y){return p[0]=_[y+0],p[1]=_[y+1],p[2]=_[y+2],p[3]=_[y+3],p},n.copy=function(p,_){return p[0]=_[0],p[1]=_[1],p[2]=_[2],p[3]=_[3],p},n.set=function(p,_,y,g,b){return p[0]=_,p[1]=y,p[2]=g,p[3]=b,p},n.exactEquals=function(p,_){return p[0]===_[0]&&p[1]===_[1]&&p[2]===_[2]&&p[3]===_[3]},n.equals=function(p,_){let y=p[0],g=p[1],b=p[2],h=p[3],v=_[0],S=_[1],x=_[2],w=_[3];return Math.abs(y-v)<=kn*Math.max(1,Math.abs(y),Math.abs(v))&&Math.abs(g-S)<=kn*Math.max(1,Math.abs(g),Math.abs(S))&&Math.abs(b-x)<=kn*Math.max(1,Math.abs(b),Math.abs(x))&&Math.abs(h-w)<=kn*Math.max(1,Math.abs(h),Math.abs(w))},n.add=function(p,_,y){return p[0]=_[0]+y[0],p[1]=_[1]+y[1],p[2]=_[2]+y[2],p[3]=_[3]+y[3],p},n.normalize=a;let l=[0,0,0],c=[1,0,0],u=[0,1,0];n.rotationTo=function(p,_,y){let g=jt.dot(_,y);return g<-.999999?(jt.cross(l,c,_),jt.magnitude(l)<1e-6&&jt.cross(l,u,_),jt.normalize(l,l),i(p,l,Math.PI),p):g>.999999?(p[0]=0,p[1]=0,p[2]=0,p[3]=1,p):(jt.cross(l,_,y),p[0]=l[0],p[1]=l[1],p[2]=l[2],p[3]=1+g,a(p,p))};let d=e(),f=e();n.sqlerp=function(p,_,y,g,b,h){return r(d,_,b,h),r(f,y,g,h),r(p,d,f,2*h*(1-h)),p};let m=[0,0,0,0,0,0,0,0,0];n.setAxes=function(p,_,y,g){return m[0]=y[0],m[3]=y[1],m[6]=y[2],m[1]=g[0],m[4]=g[1],m[7]=g[2],m[2]=-_[0],m[5]=-_[1],m[8]=-_[2],a(p,s(p,m))},n.toString=function(p,_){return`[${p[0].toPrecision(_)} ${p[1].toPrecision(_)} ${p[2].toPrecision(_)} ${p[3].toPrecision(_)}]`},n.Identity=t()}(Z2||(Z2={})),function(n){function e(o,a,l){let c=function(_,y,g){let b=[];for(let v=0;vc[u],set:(c,u,d)=>c[u]=d,add:(c,u,d)=>c[u]+=d,dataOffset:c=>c,getCoords:(c,u)=>(u[0]=c,u)};case 2:if(l[0]===0&&l[1]===1){let c=a[0];return{get:(u,d,f)=>u[f*c+d],set:(u,d,f,m)=>u[f*c+d]=m,add:(u,d,f,m)=>u[f*c+d]+=m,dataOffset:(u,d)=>d*c+u,getCoords:(u,d)=>(d[0]=u%c,d[1]=Math.floor(u/c),d)}}if(l[0]===1&&l[1]===0){let c=a[1];return{get:(u,d,f)=>u[d*c+f],set:(u,d,f,m)=>u[d*c+f]=m,add:(u,d,f,m)=>u[d*c+f]+=m,dataOffset:(u,d)=>u*c+d,getCoords:(u,d)=>(d[0]=Math.floor(u/c),d[1]=u%c,d)}}throw new Error("bad axis order");case 3:if(l[0]===0&&l[1]===1&&l[2]===2){let c=a[0],u=a[1],d=c*u;return{get:(f,m,p,_)=>f[m+p*c+_*d],set:(f,m,p,_,y)=>f[m+p*c+_*d]=y,add:(f,m,p,_,y)=>f[m+p*c+_*d]+=y,dataOffset:(f,m,p)=>f+m*c+p*d,getCoords:(f,m)=>{let p=Math.floor(f/c);return m[0]=f%c,m[1]=p%u,m[2]=Math.floor(p/u),m}}}if(l[0]===0&&l[1]===2&&l[2]===1){let c=a[0],u=a[2],d=c*u;return{get:(f,m,p,_)=>f[m+_*c+p*d],set:(f,m,p,_,y)=>f[m+_*c+p*d]=y,add:(f,m,p,_,y)=>f[m+_*c+p*d]+=y,dataOffset:(f,m,p)=>f+p*c+m*d,getCoords:(f,m)=>{let p=Math.floor(f/c);return m[0]=f%c,m[1]=Math.floor(p/u),m[2]=p%u,m}}}if(l[0]===1&&l[1]===0&&l[2]===2){let c=a[1],u=a[0],d=c*u;return{get:(f,m,p,_)=>f[p+m*c+_*d],set:(f,m,p,_,y)=>f[p+m*c+_*d]=y,add:(f,m,p,_,y)=>f[p+m*c+_*d]+=y,dataOffset:(f,m,p)=>m+f*c+p*d,getCoords:(f,m)=>{let p=Math.floor(f/c);return m[0]=p%u,m[1]=f%c,m[2]=Math.floor(p/u),m}}}if(l[0]===1&&l[1]===2&&l[2]===0){let c=a[1],u=a[2],d=c*u;return{get:(f,m,p,_)=>f[p+_*c+m*d],set:(f,m,p,_,y)=>f[p+_*c+m*d]=y,add:(f,m,p,_,y)=>f[p+_*c+m*d]+=y,dataOffset:(f,m,p)=>m+p*c+f*d,getCoords:(f,m)=>{let p=Math.floor(f/c);return m[0]=Math.floor(p/u),m[1]=f%c,m[2]=p%u,m}}}if(l[0]===2&&l[1]===0&&l[2]===1){let c=a[2],u=a[0],d=c*u;return{get:(f,m,p,_)=>f[_+m*c+p*d],set:(f,m,p,_,y)=>f[_+m*c+p*d]=y,add:(f,m,p,_,y)=>f[_+m*c+p*d]+=y,dataOffset:(f,m,p)=>p+f*c+m*d,getCoords:(f,m)=>{let p=Math.floor(f/c);return m[0]=p%u,m[1]=Math.floor(p/u),m[2]=f%c,m}}}if(l[0]===2&&l[1]===1&&l[2]===0){let c=a[2],u=a[1],d=c*u;return{get:(f,m,p,_)=>f[_+p*c+m*d],set:(f,m,p,_,y)=>f[_+p*c+m*d]=y,add:(f,m,p,_,y)=>f[_+p*c+m*d]+=y,dataOffset:(f,m,p)=>p+m*c+f*d,getCoords:(f,m)=>{let p=Math.floor(f/c);return m[0]=Math.floor(p/u),m[1]=p%u,m[2]=f%c,m}}}throw new Error("bad axis order");default:return{get:(c,...u)=>c[r(o,u)],set:(c,...u)=>c[r(o,u)]=u[u.length-1],add:(c,...u)=>c[r(o,u)]+=u[u.length-1],dataOffset:(...c)=>r(o,c),getCoords:(c,u)=>function(d,f,m){let{dimensions:p,axisOrderFastToSlow:_}=d,y=p.length,g=f;for(let b=0;bnew(c||o.defaultCtor)(l)}function r(o,a){let{accessDimensions:l,axisOrderFastToSlow:c}=o,u=l.length-1,d=l[u]*a[c[u]];for(let f=u-1;f>=0;f--)d=(d+a[c[f]])*l[f];return d}function s(o,a){let l=[];for(let c=0;cs(l,a)},n.convertToCanonicalAxisIndicesSlowToFast=function(o){let a=new Int32Array(o.length);for(let l=0;ls(l,a)}}(Kh||(Kh={})),function(n){let e;function t(r,s){return zT(s.T,r,s,1)}function i(r){return Cm(r)}(function(r){function s(o,a=r.float){return{"@type":"tensor",T:o.create(),space:o,valueType:"tensor",baseType:a}}r.str={"@type":"str",T:"",valueType:"str"},r.ustr={"@type":"str",T:"",valueType:"str",transform:"uppercase"},r.lstr={"@type":"str",T:"",valueType:"str",transform:"lowercase"},r.int={"@type":"int",T:0,valueType:"int"},r.coord={"@type":"coord",T:0,valueType:"float"},r.float={"@type":"float",T:0,valueType:"float"},r.Str=function(o){var a;return{"@type":"str",T:(a=o?.defaultValue)!==null&&a!==void 0?a:"",transform:o?.transform,valueType:"str"}},r.Int=function(o=0){return{"@type":"int",T:o,valueType:"int"}},r.Float=function(o=0){return{"@type":"float",T:o,valueType:"float"}},r.Tensor=s,r.Vector=function(o,a=r.float){return s(Kh.Vector(o,a["@type"]==="int"?Int32Array:Float64Array),a)},r.Matrix=function(o,a,l=r.float){return s(Kh.ColumnMajorMatrix(o,a,l["@type"]==="int"?Int32Array:Float64Array),l)},r.Aliased=function(o){return o},r.List=function(o,a,l=[]){return{"@type":"list",T:l,separator:o,itemParse:a,valueType:"list"}}})(e=n.Schema||(n.Schema={})),n.is=function(r){return!!r&&!!r.schema&&!!r.value},n.ValueKind={Present:0,NotPresent:1,Unknown:2},n.Undefined=t,n.ofConst=function(r,s,o){return zT(r,s,o,0)},n.ofLambda=i,n.range=function(r,s){return i({value:o=>o+r,rowCount:Math.max(s-r+1,0),schema:e.int})},n.ofArray=function(r){return to(r)},n.ofIntArray=function(r){return to({array:r,schema:e.int})},n.ofFloatArray=function(r){return to({array:r,schema:e.float})},n.ofStringArray=function(r){return to({array:r,schema:e.str})},n.ofStringAliasArray=function(r){return to({array:r,schema:e.Aliased(e.str)})},n.ofStringListArray=function(r,s=","){return to({array:r,schema:e.List(s,o=>o)})},n.ofIntTokens=function(r){let{count:s,data:o,indices:a}=r;return Cm({value:l=>Uc(o,a[2*l],a[2*l+1])||0,rowCount:s,schema:e.int})},n.ofFloatTokens=function(r){let{count:s,data:o,indices:a}=r;return Cm({value:l=>od(o,a[2*l],a[2*l+1])||0,rowCount:s,schema:e.float})},n.ofStringTokens=function(r){let{count:s,data:o,indices:a}=r;return Cm({value:l=>{let c=o.substring(a[2*l],a[2*l+1]);return c==="."||c==="?"?"":c},rowCount:s,schema:e.str})},n.window=function(r,s,o){return Jz(r,s,o)},n.view=function(r,s,o=!0){return Qz(r,s,o)},n.createFirstIndexMap=function(r){return function(s){let o=new Map;for(let a=0,l=s.rowCount;ao.has(a)?o.get(a):-1}(r)},n.mapToArray=function(r,s,o){return function(a,l,c){let u=new c(a.rowCount);for(let d=0,f=a.rowCount;d0&&(r.chunks[r.chunks.length]=r.current.length===r.offset?r.current.join(""):r.current.slice(0,r.offset).join("")),r.chunks.join("")):r.current.length===r.offset?r.current.join(""):r.current.splice(0,r.offset).join("")},n.getSize=function(r){let s=0;for(let o of r.chunks)s+=o.length;for(let o=0;o0&&(r.current.length===r.offset?r.chunks[r.chunks.length]=r.current.join(""):r.chunks[r.chunks.length]=r.current.slice(0,r.offset).join(""),r.offset=0),r.chunks};let e=[];function t(r,s){s>0&&i(r,e[s])}function i(r,s){r.offset===r.capacity&&(r.chunks[r.chunks.length]=r.current.join(""),r.offset=0),r.current[r.offset++]=s}(function(){let r="";for(let s=0;s<512;s++)e[s]=r,r+=" "})(),n.newline=function(r){i(r,` +`)},n.whitespace=t,n.whitespace1=function(r){i(r," ")},n.write=function(r,s){s&&(r.offset===r.capacity&&(r.chunks[r.chunks.length]=r.current.join(""),r.offset=0),r.current[r.offset++]=s)},n.writeSafe=i,n.writePadLeft=function(r,s,o){if(!s)return void t(r,o);t(r,o-s.length),i(r,s)},n.writePadRight=function(r,s,o){if(!s)return void t(r,o);let a=o-s.length;i(r,s),t(r,a)},n.writeInteger=function(r,s){i(r,""+s)},n.writeIntegerAndSpace=function(r,s){i(r,s+" ")},n.writeIntegerPadLeft=function(r,s,o){let a=""+s;t(r,o-a.length),i(r,a)},n.writeIntegerPadRight=function(r,s,o){let a=""+s,l=o-a.length;i(r,a),t(r,l)},n.writeFloat=function(r,s,o){i(r,""+Math.round(o*s)/o)},n.writeFloatPadLeft=function(r,s,o,a){let l=""+Math.round(o*s)/o;t(r,a-l.length),i(r,l)},n.writeFloatPadRight=function(r,s,o,a){let l=""+Math.round(o*s)/o,c=a-l.length;i(r,l),t(r,c)}}(Ii||(Ii={}));var vs=function(){if(typeof window<"u"&&window.performance){let n=window.performance;return()=>n.now()}return typeof process<"u"&&process.hrtime!=="undefined"&&typeof process.hrtime=="function"?()=>{let n=process.hrtime();return 1e3*n[0]+n[1]/1e6}:Date.now?()=>Date.now():()=>+new Date}(),VT,HT,ad;function s6(n,e){return n-e}function vI(n=0,e=Number.MAX_SAFE_INTEGER){let t=n;return()=>{let i=t;return t=(t+1)%e,i}}(function(n){let e=typeof btoa<"u"?btoa:i=>Buffer.from(i).toString("base64"),t=[];n.create22=function(){let i=+new Date+vs();for(let r=0;r<16;r++)t[r]=String.fromCharCode((i+255*Math.random())%255|0),i=Math.floor(i/255);return e(t.join("")).replace(/\+/g,"-").replace(/\//g,"_").substr(0,22)},n.createv4=function(){let i=+new Date+vs();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let s=(i+16*Math.random())%16|0;return i=Math.floor(i/16),(r==="x"?s:3&s|8).toString(16)})},n.is=function(i){return typeof i=="string"}})(VT||(VT={})),function(n){class e{has(c){return!1}forEach(c,u){return u}constructor(){this.size=0}}class t{has(c){return c===this.idx}forEach(c,u){return c(this.idx,u),u}constructor(c){this.idx=c,this.size=1}}class i{has(c){return cc[u++]=d),function(d){Array.prototype.sort.call(d,s6)}(c),this._flat=c,this._flat}forEach(c,u){return this._forEach(c,u),u}constructor(c){this.set=c,this._flat=void 0,this.size=c.size}}function o(l){return new s(l)}function a(l,c){return new i(l,c)}n.always=function(l){return new r(l)},n.never=new e,n.ofSet=o,n.singleton=function(l){return new t(l)},n.ofUniqueIndices=function(l){let c=l.length;if(c===0)return new e;if(c===1)return new t(l[0]);let u=0;for(let f of l)f>u&&(u=f);if(c===u)return new r(c);if(c/u<1/12){let f=new Set;for(let m of l)f.add(m);return new s(f)}let d=new Int8Array(u+1);for(let f of l)d[f]=1;return new i(d,l.length)},n.ofMask=a,n.hasAny=function(l,c){for(let u of c)if(l.has(u))return!0;return!1},n.complement=function(l,c){let u=0,d=0;if(c.forEach(f=>{l.has(f)||(u++,f>d&&(d=f))}),u/d<1/12){let f=new Set;return c.forEach(m=>{l.has(m)||f.add(m)}),o(f)}{let f=new Uint8Array(d+1);return c.forEach(m=>{l.has(m)||(f[m]=1)}),a(f,u)}}}(HT||(HT={})),function(n){n.create=function(e){return{ref:e}},n.set=function(e,t){return e.ref=t,e}}(ad||(ad={}));var o6=vI(0,2147483647),Em,GT,Tm,Q2,zc;function a6(n){let{data:e,indices:t}=n;return function(i,r){let s=t[2*i],o=t[2*r],a=t[2*i+1]-s;if(a!==t[2*r+1]-o)return!1;for(let l=0;li[r]}}(function(n){n.create=function(e,t){return{id:o6(),version:0,value:e,metadata:t}},n.withValue=function(e,t){return{id:e.id,version:e.version+1,value:t,metadata:e.metadata}}})(Em||(Em={})),function(n){function e(t,i){return ad.set(t,Em.withValue(t.ref,i))}n.create=function(t,i){return ad.create(Em.create(t,i))},n.update=e,n.set=function(t,i){return ad.set(t,i)},n.updateIfChanged=function(t,i){return t.ref.value!==i?e(t,i):t}}(GT||(GT={})),function(n){function e(i,r,s){let o=Object.create(null),a=Object.keys(r);o._rowCount=s.length,o._columns=a,o._schema=r;for(let l of a)o[l]=dn.view(i[l],s);return o}function t(i,r){let s=Object.create(null),{_columns:o}=i;for(let a=0;ar[c][l],valueKind:c=>r[c][l]===void 0?1:0});return s},n.ofArrays=function(i,r){var s;let o=Object.create(null),a=Object.keys(i);o._rowCount=0,o._columns=a,o._schema=i;for(let l of a)r[l]!==void 0?(o[l]=dn.ofArray({array:r[l],schema:i[l]}),o._rowCount=(s=r[l])===null||s===void 0?void 0:s.length):o[l]=dn.Undefined(o._rowCount,i[l]);return o},n.view=e,n.pick=function(i,r,s){let o=[];for(let a=0,l=i._rowCount;ar(c,u));let o=!0;for(let l=0,c=s.length;l0?i[r[0]].rowCount:0,name:t,fieldNames:r,getField:s=>i[s]}}n.empty=function(t){return{rowCount:0,name:t,fieldNames:[],getField(i){}}},n.ofFields=e,n.ofTable=function(t,i){let r={};for(let s of i._columns)r[s]=zc.ofColumn(i[s]);return e(t,r)}}(u0||(u0={})),function(n){function e(i){let r=i.length,s=l=>{let c=i[l];return c&&c!=="."&&c!=="?"?c:""},o=l=>{let c=i[l];return Uc(c,0,c.length)||0},a=l=>{let c=i[l];return od(c,0,c.length)||0};return{__array:void 0,binaryEncoding:void 0,isDefined:!0,rowCount:r,str:s,int:o,float:a,valueKind:l=>{let c=i[l],u=c.length;if(u>1)return 0;if(u===0)return 1;let d=c.charCodeAt(0);return d===46?1:d===63?2:0},areValuesEqual:(l,c)=>i[l]===i[c],toStringArray:l=>l?bi(r,s,l):i,toIntArray:l=>bi(r,o,l),toFloatArray:l=>bi(r,a,l)}}function t(i){let{rowCount:r,valueKind:s,areValuesEqual:o,isDefined:a}=i,l,c,u;switch(i.schema.valueType){case"float":case"int":l=f=>""+i.value(f),c=i.value,u=i.value;break;case"str":l=i.value,c=f=>{let m=i.value(f);return Uc(m,0,m.length)||0},u=f=>{let m=i.value(f);return od(m,0,m.length)||0};break;case"list":let{separator:d}=i.schema;l=f=>i.value(f).join(d),c=f=>NaN,u=f=>NaN;break;default:throw new Error(`unsupported valueType '${i.schema.valueType}'`)}return{__array:void 0,binaryEncoding:void 0,isDefined:a,rowCount:r,str:l,int:c,float:u,valueKind:s,areValuesEqual:o,toStringArray:d=>bi(r,l,d),toIntArray:d=>bi(r,c,d),toFloatArray:d=>bi(r,u,d)}}n.ofString=function(i){return e([i])},n.ofStrings=e,n.ofNumbers=function(i){let r=i.length,s=l=>""+i[l],o=l=>i[l],a=l=>!l||l.array&&i instanceof l.array?i:bi(r,o,l);return{__array:void 0,binaryEncoding:void 0,isDefined:!0,rowCount:r,str:s,int:o,float:o,valueKind:l=>0,areValuesEqual:(l,c)=>i[l]===i[c],toStringArray:l=>bi(r,s,l),toIntArray:a,toFloatArray:a}},n.ofTokens=function(i){let{data:r,indices:s,count:o}=i,a=u=>{let d=r.substring(s[2*u],s[2*u+1]);return d==="."||d==="?"?"":d},l=u=>Uc(r,s[2*u],s[2*u+1])||0,c=u=>od(r,s[2*u],s[2*u+1])||0;return{__array:void 0,binaryEncoding:void 0,isDefined:!0,rowCount:o,str:a,int:l,float:c,valueKind:u=>{let d=s[2*u],f=s[2*u+1]-d;if(f>1)return 0;if(f===0)return 1;let m=r.charCodeAt(d);return m===46?1:m===63?2:0},areValuesEqual:a6(i),toStringArray:u=>bi(o,a,u),toIntArray:u=>bi(o,l,u),toFloatArray:u=>bi(o,c,u)}},n.ofColumn=t,n.ofUndefined=function(i,r){return t(dn.Undefined(i,r))}}(zc||(zc={}));var ew=typeof setImmediate<"u"?typeof window<"u"?{setImmediate:(n,...e)=>window.setImmediate(n,...e),clearImmediate:n=>window.clearImmediate(n)}:{setImmediate,clearImmediate}:function(){let n=function(){let a=typeof window<"u"&&window,l=typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&self;return a||typeof global<"u"&&global||l}(),e={},t=typeof document<"u"?document:void 0,i,r=1;function s(a){delete e[a]}function o(a){let l=e[a];s(a),function(c){let u=c.callback,d=c.args;switch(d.length){case 0:u();break;case 1:u(d[0]);break;case 2:u(d[0],d[1]);break;case 3:u(d[0],d[1],d[2]);break;default:u.apply(void 0,d)}}(l)}return typeof process<"u"&&{}.toString.call(process)==="[object process]"?i=function(a){process.nextTick(function(){o(a)})}:function(){if(n&&n.postMessage&&!n.importScripts){let a=!0,l=n.onmessage;return n.onmessage=function(){a=!1},n.postMessage("","*"),n.onmessage=l,a}}()?function(){let a="setImmediate$"+Math.random()+"$",l=function(c){c.source===n&&typeof c.data=="string"&&c.data.indexOf(a)===0&&o(+c.data.slice(a.length))};window.addEventListener?window.addEventListener("message",l,!1):window.attachEvent("onmessage",l),i=function(c){window.postMessage(a+c,"*")}}():typeof MessageChannel<"u"?function(){let a=new MessageChannel;a.port1.onmessage=function(l){o(l.data)},i=function(l){a.port2.postMessage(l)}}():t&&"onreadystatechange"in t.createElement("script")?function(){let a=t.documentElement;i=function(l){let c=t.createElement("script");c.onreadystatechange=function(){o(l),c.onreadystatechange=null,a.removeChild(c),c=null},a.appendChild(c)}}():i=function(a){setTimeout(o,0,a)},{setImmediate:function(a,...l){typeof a!="function"&&(a=new Function(""+a));let c={callback:a,args:l};return e[r]=c,i(r),r++},clearImmediate:s}}();function l6(n){ew.setImmediate(n)}var c6={setImmediate:ew.setImmediate,clearImmediate:ew.clearImmediate,immediatePromise:()=>new Promise(l6),delay:(n,e=void 0)=>new Promise(t=>setTimeout(t,n,e))};(function(){try{return!0}catch{return!1}})(),function(){try{let n=process.env.DEBUG;return n==="*"||n==="molstar"}catch{return!1}}();var yx=typeof performance<"u"&&!!performance.mark&&performance.measure&&!1,ld;function u6(n,e,t=250){let i=function(r,s,o){let a={abortRequested:!1,treeAborted:!1,reason:""};return{updateRateMs:o,lastNotified:vs(),observer:s,abortToken:a,taskId:r.id,root:{progress:bI(r),children:[]},tryAbort:h6(a)}}(n,e,t);return Lw(n,new tw(i,i.root))}function bI(n){return{taskId:n.id,taskName:n.name,message:"",startedTime:0,canAbort:!0,isIndeterminate:!0,current:0,max:0}}function h6(n){return e=>{n.abortRequested=!0,n.reason=e||n.reason}}function wI(n){return{progress:{...n.progress},children:n.children.map(wI)}}function SI(n){return n.progress.canAbort&&n.children.every(SI)}async function Lw(n,e){ld.markStart(n),e.node.progress.startedTime=vs();try{let t=await n.f(e);return ld.markEnd(n),ld.measure(n),e.info.abortToken.abortRequested&&AI(e.info),t}catch(t){throw ol.isAbort(t)&&(e.isAborted=!0,e.node.children.length>0&&await new Promise(i=>{e.onChildrenFinished=i}),n.onAbort&&n.onAbort()),t}}function AI(n){throw n.abortToken.treeAborted||(n.abortToken.treeAborted=!0,MI(n.root),CI(n,vs())),ol.Aborted(n.abortToken.reason)}function MI(n){let e=n.progress;e.isIndeterminate=!0,e.canAbort=!1,e.message="Aborting...";for(let t of n.children)MI(t)}function CI(n,e){n.lastNotified=e;let t=function(i){return{root:wI(i.root),canAbort:SI(i.root),requestAbort:i.tryAbort}}(n);n.observer(t)}(function(n){function e(i){return`startTask${i.id}`}function t(i){return`endTask${i.id}`}n.markStart=function(i){yx&&performance.mark(e(i))},n.markEnd=function(i){yx&&performance.mark(t(i))},n.measure=function(i){yx&&performance.measure(`\u2733\uFE0F ${i.name}`,e(i),t(i))}})(ld||(ld={}));var tw=class n{checkAborted(){this.info.abortToken.abortRequested&&(this.isAborted=!0,AI(this.info))}get shouldUpdate(){return this.checkAborted(),vs()-this.lastUpdatedTime>this.info.updateRateMs}updateProgress(e){if(this.checkAborted(),!e)return;let t=this.node.progress;typeof e=="string"?(t.message=e,t.isIndeterminate=!0):(e.canAbort!==void 0&&(t.canAbort=e.canAbort),e.message!==void 0&&(t.message=e.message),e.current!==void 0&&(t.current=e.current),e.max!==void 0&&(t.max=e.max),t.isIndeterminate=t.current===void 0||t.max===void 0,e.isIndeterminate!==void 0&&(t.isIndeterminate=e.isIndeterminate))}update(e,t){if(this.lastUpdatedTime=vs(),this.updateProgress(e),!t)return CI(this.info,this.lastUpdatedTime),this.checkAborted(),c6.immediatePromise()}async runChild(e,t){this.updateProgress(t);let i={progress:bI(e),children:[]},r=this.node.children;r.push(i);let s=new n(this.info,i);try{return await Lw(e,s)}catch(o){if(ol.isAbort(o)&&this.isAborted)return;throw o}finally{let o=r.indexOf(i);if(o>=0){for(let a=o,l=r.length-1;a0;){o+=c;let d=vs()-l;u+=d,a+=d,n.shouldUpdate&&(await r(n,t,o),s=Math.round(u*o/a)+1,l=vs(),u=0)}return n.shouldUpdate&&await r(n,t,o),t}function iw(n){return{data:n,position:0,length:n.length,lineNumber:1,tokenStart:0,tokenEnd:0}}function jT(n){for(;n.position=n.length)return void(n.tokenType=6);n.tokenStart=n.position,n.tokenEnd=n.position,n.isEscaped=!1;let t=n.data.charCodeAt(n.position);switch(t){case 35:(function(i){for(;i.position=5&&n.data.charCodeAt(n.tokenStart+4)===95?function(i){let r=i.data.charCodeAt(i.tokenStart);return!(r!==68&&r!==100||(r=i.data.charCodeAt(i.tokenStart+1),r!==65&&r!==97||(r=i.data.charCodeAt(i.tokenStart+2),r!==84&&r!==116||(r=i.data.charCodeAt(i.tokenStart+3),r!==65&&r!==97))))}(n)?n.tokenType=0:function(i){let r=i.data.charCodeAt(i.tokenStart);return!(r!==83&&r!==115||(r=i.data.charCodeAt(i.tokenStart+1),r!==65&&r!==97||(r=i.data.charCodeAt(i.tokenStart+2),r!==86&&r!==118||(r=i.data.charCodeAt(i.tokenStart+3),r!==69&&r!==101))))}(n)?n.tokenType=1:function(i){if(i.tokenEnd-i.tokenStart!=5)return!1;let r=i.data.charCodeAt(i.tokenStart);return!(r!==76&&r!==108||(r=i.data.charCodeAt(i.tokenStart+1),r!==79&&r!==111||(r=i.data.charCodeAt(i.tokenStart+2),r!==79&&r!==111||(r=i.data.charCodeAt(i.tokenStart+3),r!==80&&r!==112))))}(n)?n.tokenType=2:n.tokenType=3:n.tokenType=3}}function ta(n){for(qT(n);n.tokenType===5;)qT(n)}function Im(){return{categoryNames:[],categoryData:Object.create(null)}}function Dw(n,e){let t=Object.create(null);for(let i of n){let r=e[i];t[i]=u0(r.name,r.rowCount,r.fieldNames,r.fields)}return t}function YT(n,e,t){return kw(n.categoryNames,Dw(n.categoryNames,n.categoryData),e,t)}function f6(n,e){return kw(n.categoryNames,Dw(n.categoryNames,n.categoryData),e)}function sw(n,e,t,i,r){if(e in n.categoryData){let s=n.categoryData[e];s.fieldNames.push(...i),Object.assign(s.fields,r)}else n.categoryData[e]={name:e,rowCount:t,fieldNames:i,fields:r},n.categoryNames.push(e)}function p6(n,e){let t=n.tokenStart,i=EI(n),r=TI(n,i),s=Object.create(null),o=[],a=!0;for(;a;){if(n.tokenType!==4||!d6(n,t,i)){a=!1;break}let l=rw(n).substring(r.length+1);if(ta(n),n.tokenType!==3)return{hasError:!0,errorLine:n.lineNumber,errorMessage:"Expected value."};s[l]=zc.ofTokens({data:n.data,indices:[n.tokenStart,n.tokenEnd],count:1}),o[o.length]=l,ta(n)}return sw(e,r.substr(1),1,o,s),{hasError:!1,errorLine:0,errorMessage:""}}function m6(n,e){let{tokenizer:t,tokens:i,fieldCount:r}=e,s=e.tokenCount,o=0;for(;t.tokenType===3&&o0&&t.push(YT(s,r,o)),r=n.substring(i.tokenStart+5,i.tokenEnd),s=Im(),o=[],ta(i)}else if(u===1){if(i.tokenEnd-i.tokenStart==5)a.categoryNames.length>0&&(o[o.length]=f6(a,c)),i.inSaveFrame=!1;else{if(i.inSaveFrame)return xc(i.lineNumber,"Save frames cannot be nested.");i.inSaveFrame=!0,c=n.substring(i.tokenStart+5,i.tokenEnd),a=Im()}ta(i)}else if(u===2){let d=await y6(i,i.inSaveFrame?a:s);if(d.hasError)return xc(d.errorLine,d.errorMessage)}else{if(u!==4)return console.log(i.tokenType,iw.getTokenString(i)),xc(i.lineNumber,"Unexpected token. Expected data_, loop_, or data name.");{let d=p6(i,i.inSaveFrame?a:s);if(d.hasError)return xc(d.errorLine,d.errorMessage)}}}return i.inSaveFrame?xc(i.lineNumber,`Unfinished save frame (${l.header}).`):((s.categoryNames.length>0||o.length>0)&&t.push(YT(s,r,o)),function(u){return Ja.success(u)}(xI(t)))}function ZT(n){return ol.create("Parse CIF",async e=>await _6(n,e))}(function(n){class e{run(o,a=250){return o?u6(this,o,a):this.f(Pm)}runAsChild(o,a){return o.isSynchronous?this.f(Pm):function(l,c,u){return l.runChild(c,u)}(o,this,a)}runInContext(o){return o.isSynchronous?this.f(Pm):function(a,l){return Lw(l,a)}(o,this)}constructor(o,a,l){this.name=o,this.f=a,this.onAbort=l,this.id=r()}}function t(s){let o=s;return!!s&&typeof o.id=="number"&&typeof o.name=="string"&&!!o.run}function i(s,o,a){return new e(s,o,a)}n.is=t,n.isAbort=function(s){return!!s&&!!s.isAborted},n.Aborted=function(s){return{isAborted:!0,reason:s,toString:()=>"Aborted"+(s?": "+s:"")}},n.create=i,n.constant=function(s,o){return i(s,async a=>o)},n.empty=function(){return i("",async s=>{})},n.fail=function(s,o){return i(s,async a=>{throw new Error(o)})},n.resolveInContext=function(s,o){return t(s)?o?s.runInContext(o):s.run():s};let r=vI(0,1073741823)})(ol||(ol={})),function(n){n.Synchronous=Pm}($T||($T={})),function(n){function e(t,i=""){let r=t.progress;if(!t.children.length)return r.isIndeterminate?`${i}${r.taskName}: ${r.message}`:`${i}${r.taskName}: [${r.current}/${r.max}] ${r.message}`;let s=i+" |_ ",o=t.children.map(a=>e(a,s));return r.isIndeterminate?`${i}${r.taskName}: ${r.message} +${o.join(` +`)}`:`${i}${r.taskName}: [${r.current}/${r.max}] ${r.message} +${o.join(` +`)}`}n.format=function(t){return e(t.root)}}(WT||(WT={})),function(n){function e(o){return o.data.substring(o.tokenStart,o.tokenEnd)}function t(o){let{data:a}=o;for(;o.position=u;)f=c.charCodeAt(--d);return o.tokenStart=u,o.tokenEnd=d+1,o.position=l,o}n.getTokenString=e,n.reset=function(o){o.position=0,o.lineNumber=1,o.tokenStart=0,o.tokenEnd=0},n.eatLine=t,n.markStart=function(o){o.tokenStart=o.position},n.markLine=i,n.readLine=function(o){return i(o),e(o)},n.readLineTrim=function(o){i(o);let a=o.position;return s(o,o.tokenStart,o.tokenEnd),o.position=a,e(o)},n.markLines=function(o,a){let l=Xr.create(o.data,2*a);return r(o,a,l),l},n.readLines=function(o,a){let l=[];for(let c=0;c{let p=Math.min(a-d,f);return r(m,p,u),d+=p,p},(f,m)=>f.update({message:"Parsing...",current:m.position,max:m.length})),u},n.readAllLines=function(o){let a=n(o),l=Xr.create(a.data,Math.max(o.length/80,2));for(;i(a);)Xr.add(l,a.tokenStart,a.tokenEnd);return l},n.readAllLinesAsync=async function(o,a,l=1e5){let c=n(o),u=Xr.create(c.data,Math.max(o.length/80,2));return await nw(a,l,c,(d,f)=>(function(m,p,_){let y=0;for(let g=0;gd.update({message:"Parsing...",current:f.position,max:f.length})),u},n.eatValue=function(o){for(;o.positions.indicesLenMinus2&&function(o){let a=new Uint32Array(1.61*o.indices.length|0);a.set(o.indices),o.indices=a,o.indicesLenMinus2=a.length-2|0}(s),s.indices[s.offset++]=i,s.indices[s.offset++]=r,t.count++}n.add=e,n.addToken=function(t,i){e(t,i.tokenStart,i.tokenEnd)},n.addUnchecked=function(t,i,r){t.indices[t.offset++]=i,t.indices[t.offset++]=r,t.count++},n.create=function(t,i){return{data:t,indicesLenMinus2:(i=Math.max(10,i))-2|0,count:0,offset:0,indices:new Uint32Array(i)}}}(Xr||(Xr={})),function(n){n.error=function(i,r=-1){return new e(i,r)},n.success=function(i,r=[]){return new t(i,r)};class e{toString(){return this.line>=0?`[Line ${this.line}] ${this.message}`:this.message}constructor(r,s){this.message=r,this.line=s,this.isError=!0}}n.Error=e;class t{constructor(r,s){this.result=r,this.warnings=s,this.isError=!1}}n.Success=t}(Ja||(Ja={})),function(n){var e,t;(e=n.IntDataType||(n.IntDataType={}))[e.Int8=1]="Int8",e[e.Int16=2]="Int16",e[e.Int32=3]="Int32",e[e.Uint8=4]="Uint8",e[e.Uint16=5]="Uint16",e[e.Uint32=6]="Uint32",(t=n.FloatDataType||(n.FloatDataType={}))[t.Float32=32]="Float32",t[t.Float64=33]="Float64",n.getDataType=function(i){let r;return r=i instanceof Int8Array?n.IntDataType.Int8:i instanceof Int16Array?n.IntDataType.Int16:i instanceof Int32Array?n.IntDataType.Int32:i instanceof Uint8Array?n.IntDataType.Uint8:i instanceof Uint16Array?n.IntDataType.Uint16:i instanceof Uint32Array?n.IntDataType.Uint32:i instanceof Float32Array?n.FloatDataType.Float32:i instanceof Float64Array?n.FloatDataType.Float64:n.IntDataType.Int32,r},n.isSignedIntegerDataType=function(i){if(i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array)return!0;for(let r=0,s=i.length;r=0;t--)e=x6(e,n.encoding[t]);return e}function x6(n,e){switch(e.kind){case"ByteArray":switch(e.type){case Rt.IntDataType.Uint8:return n;case Rt.IntDataType.Int8:return function(t){return new Int8Array(t.buffer,t.byteOffset)}(n);case Rt.IntDataType.Int16:return function(t){return bc(t,2,Int16Array)}(n);case Rt.IntDataType.Uint16:return function(t){return bc(t,2,Uint16Array)}(n);case Rt.IntDataType.Int32:return function(t){return bc(t,4,Int32Array)}(n);case Rt.IntDataType.Uint32:return function(t){return bc(t,4,Uint32Array)}(n);case Rt.FloatDataType.Float32:return function(t){return bc(t,4,Float32Array)}(n);case Rt.FloatDataType.Float64:return function(t){return bc(t,8,Float64Array)}(n);default:c0(e.type)}case"FixedPoint":return function(t,i){let r=t.length,s=JT(i.srcType,r),o=1/i.factor;for(let a=0;a=i.currentSize)c.set(d,u);else for(let f=0,m=d.length;f=i.currentSize&&e(i);let l=i.currentChunk,c=i.currentIndex;return l[c]=r,l[c+1]=s,l[c+2]=o,l[c+3]=a,i.currentIndex+=4,i.elementCount++},n.add3=function(i,r,s,o){i.currentIndex>=i.currentSize&&e(i);let a=i.currentChunk,l=i.currentIndex;return a[l]=r,a[l+1]=s,a[l+2]=o,i.currentIndex+=3,i.elementCount++},n.add2=function(i,r,s){i.currentIndex>=i.currentSize&&e(i);let o=i.currentChunk,a=i.currentIndex;return o[a]=r,o[a+1]=s,i.currentIndex+=2,i.elementCount++},n.add=function(i,r){return i.currentIndex>=i.currentSize&&e(i),i.currentChunk[i.currentIndex]=r,i.currentIndex+=1,i.elementCount++},n.addRepeat=function(i,r,s){for(let o=0;o=i.currentSize&&e(i),i.currentChunk[i.currentIndex++]=s,i.elementCount++;return i.elementCount},n.addMany=function(i,r){let{elementSize:s}=i;for(let o=0,a=r.length;o=i.currentSize&&e(i);let{currentChunk:l}=i;for(let c=0;c=0?Math.ceil((u+1)/d):Math.ceil((u+1)/(-d-1))}function t({limit8:u,limit16:d},f,m){f.pack8+=e(m,u),f.pack16+=e(m,d),f.count+=1}function i(u,d){u.pack8+=e(d,127),u.pack16+=e(d,32767),u.count+=1}function r(u){return 4*u.count<2*u.pack16?{length:4*u.count,elem:4}:2*u.pack16m.length-p.length),f}n.getSize=c,n.classify=function(u){if(u.length<2)return Bt.by(Bt.byteArray);switch(c(u)[0].kind){case"pack":return Bt.by(Bt.integerPacking);case"rle":return Bt.by(Bt.runLength).and(Bt.integerPacking);case"delta":return Bt.by(Bt.delta).and(Bt.integerPacking);case"delta-rle":return Bt.by(Bt.delta).and(Bt.runLength).and(Bt.integerPacking);default:c0()}}}(Qh||(Qh={})),function(n){n.classify=function(e){let{mantissaDigits:t,integerDigits:i}=function(l,c,u){let d=1,f=0;for(let m=0,p=l.length;m=0){let y=b6(l[m],c,u);y<0?d=-1:y>d&&(d=y)}let _=Math.abs(l[m]);if(_>u){let y=Math.floor(Math.log10(Math.abs(_)))+1;y>f&&(f=y)}}return{mantissaDigits:d,integerDigits:f}}(e,4,1e-6);if(t<0||t+i>10)return Bt.by(Bt.byteArray);if(t===0)return Qh.classify(e);let r=function(l){let c=1;for(let u=0;u=0?f/a|0:f/l|0}return c+=o.length,c}n.byteArray=i,n.fixedPoint=function(o){return a=>function(l,c){let u=Rt.getDataType(l),d=new Int32Array(l.length);for(let f=0,m=l.length;ffunction(d,f,m,p,_){let y=Rt.getDataType(d);if(!d.length)return{encodings:[{kind:"IntervalQuantization",min:f,max:m,numSteps:p,srcType:y}],data:new Int32Array(0)};if(m=m?p-1:0|Math.round((S-f)/g)}return{encodings:[{kind:"IntervalQuantization",min:f,max:m,numSteps:p,srcType:y}],data:b}}(u,o,a,l,c)},n.runLength=function(o){let a=Rt.getDataType(o);if(a===void 0&&(o=new Int32Array(o),a=Rt.IntDataType.Int32),!o.length)return{encodings:[{kind:"RunLength",srcType:a,srcSize:0}],data:new Int32Array(0)};let l=2;for(let f=1,m=o.length;f=0)for(;g>=u;)m[p]=u,++p,g-=u;else for(;g<=d;)m[p]=d,++p,g-=d;m[p]=g,++p}let _=i(m);return{encodings:[{kind:"IntegerPacking",byteCount:c.bytesPerElement,isUnsigned:!c.isSigned,srcSize:f},_.encodings[0]],data:_.data}}(o,a)},n.stringArray=function(o){let a=Object.create(null),l=[],c=new Int32Array(o.length),u=kc.create(Int32Array,1,Math.min(1024,o.length<32?o.length+1:Math.round(o.length/8)+1));kc.add(u,0);let d=0,f=0;for(let y of o){if(y==null){c[f++]=-1;continue}let g=a[y];g===void 0&&(d+=y.length,g=l.length,l[g]=y,a[y]=g,kc.add(u,d)),c[f++]=g}let m=kc.compact(u),p=tP(m).encode(m),_=tP(c).encode(c);return{encodings:[{kind:"StringArray",dataEncoding:_.encoding,stringData:l.join(""),offsetEncoding:p.encoding,offsets:p.data}],data:_.data}}}(Bt||(Bt={}));var w6=function(){let n=[];for(let e=0;e<1024;e++)n[e]=String.fromCharCode(e);return n}();function S6(n){throw new Error(n)}var nP=typeof TextDecoder<"u"?new TextDecoder:void 0;function A6(n,e,t){if(nP){let i=e||t!==n.length?n.subarray(e,e+t):n;return nP.decode(i)}return function(i,r,s){let o=w6,a,l=0,c=[];for(let u=r,d=r+s;u0&&(a[a.length]=c.slice(0,l).join("")),a.join("")):c.slice(0,l).join("")}(n,e,t)}function _x(n,e){let t={};for(let i=0;ii.name),getField(i){let r=e[i];if(r)return t[i]||(t[i]=function(s){let o=s.mask?h0(s.mask):void 0,a=h0(s.data),l=Rw(a),c=l?o?p=>o[p]===0?""+a[p]:"":p=>""+a[p]:o?p=>o[p]===0?a[p]:"":p=>a[p],u=l?p=>a[p]:p=>{let _=a[p];return Uc(_,0,_.length)},d=l?p=>a[p]:p=>{let _=a[p];return od(_,0,_.length)},f=o?p=>o[p]:p=>0,m=a.length;return{__array:a,binaryEncoding:s.data.encoding,isDefined:!0,rowCount:m,str:c,int:u,float:d,valueKind:f,areValuesEqual:(p,_)=>a[p]===a[_],toStringArray:p=>bi(m,c,p),toIntArray:l?p=>l0(a,p):p=>bi(m,u,p),toFloatArray:l?p=>l0(a,p):p=>bi(m,d,p)}}(r)),t[i]}}}function iP(n){return ol.create("Parse BinaryCIF",async e=>{let t=[0,3];try{let r=f0({buffer:i=n,offset:0,dataView:new DataView(i.buffer)});if(!function(o,a){for(let l=0;l<2;l++)if(o[l]>a[l])return!1;return!0}(t,r.version.match(/(\d)\.(\d)\.\d/).slice(1).map(o=>+o)))return Ja.error(`Unsupported format version. Current ${r.version}, required ${t.join(".")}.`);let s=xI(r.dataBlocks.map(o=>{let a=Object.create(null);for(let l of o.categories)a[l.name.substr(1)]=M6(l);return kw(o.categories.map(l=>l.name.substr(1)),a,o.header)}));return Ja.success(s)}catch(r){return Ja.error(""+r)}var i})}var Vc;function Zs(n,e,t){return function(i,r,s){let o=Object.create(null);for(let a of Object.keys(i))o[a]=I6(a,i[a],r,s);return Q2.ofTables(r.header,i,o)}(n,e,t)}function C6(n){switch(n.valueType){case"str":return(e,t,i)=>function(r,s,o,a){return{schema:r,__array:s.__array,isDefined:s.isDefined,rowCount:s.rowCount,value:r.transform==="lowercase"?l=>o(l).toLowerCase():r.transform==="uppercase"?l=>o(l).toUpperCase():o,valueKind:s.valueKind,areValuesEqual:s.areValuesEqual,toArray:r.transform==="lowercase"?l=>Array.from(a(l)).map(c=>c.toLowerCase()):r.transform==="uppercase"?l=>Array.from(a(l)).map(c=>c.toUpperCase()):a}}(n,e,e.str,e.toStringArray);case"int":return(e,t,i)=>rP(n,e,e.int,e.toIntArray);case"float":return(e,t,i)=>rP(n,e,e.float,e.toFloatArray);case"list":throw new Error("Use createListColumn instead.");case"tensor":throw new Error("Use createTensorColumn instead.")}}function rP(n,e,t,i){return{schema:n,__array:e.__array,isDefined:e.isDefined,rowCount:e.rowCount,value:t,valueKind:e.valueKind,areValuesEqual:e.areValuesEqual,toArray:i}}function E6(n,e,t){let i=n.separator,r=n.itemParse,s=e.getField(t),o=s?a=>s.str(a).split(i).map(l=>r(l.trim())).filter(l=>!!l):a=>[];return{schema:n,__array:void 0,isDefined:!!s,rowCount:e.rowCount,value:o,valueKind:s?s.valueKind:()=>1,areValuesEqual:(a,l)=>function(c,u){let d=c.length;if(d!==u.length)return!1;for(let f=0;fbi(e.rowCount,o,a)}}function T6(n,e,t){let i=n.space,r=e.fieldNames.includes(`${t}[0]`)||e.fieldNames.includes(`${t}[0][0]`)||e.fieldNames.includes(`${t}[0][0][0]`),s=r?0:1,o=e.fieldNames.includes(`${t}_1`)||e.fieldNames.includes(`${t}_11`)||e.fieldNames.includes(`${t}_111`)?"underscore":"brackets",a=function(u,d,f,m){let p=f?0:1;switch(d){case 1:return m==="brackets"?_=>`${u}[${_+p}]`:_=>`${u}_${_+p}`;case 2:return m==="brackets"?(_,y)=>`${u}[${_+p}][${y+p}]`:(_,y)=>`${u}_${_+p}${y+p}`;case 3:return m==="brackets"?(_,y,g)=>`${u}[${_+p}][${y+p}][${g+p}]`:(_,y,g)=>`${u}_${_+p}${y+p}${g+p}`;default:throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.")}}(t,i.rank,r,o),l=e.getField(a(s,s,s))||dn.Undefined(e.rowCount,n),c=u=>function(d,f,m,p){let _=f.create();if(f.rank===1){let y=f.dimensions[0];for(let g=0;g 3 or rank 0 are currently not supported.");{let y=f.dimensions[0],g=f.dimensions[1],b=f.dimensions[2];for(let h=0;hKh.areEqualExact(c(u),c(d)),toArray:u=>bi(e.rowCount,c,u)}}(function(n){function e(t){return t.replace(".","_").replace(/\[/,"_").replace(/(\[|\])/g,"")}n.canonical=e,n.equal=function(t,i){return e(t)===e(i)},n.create=function(t,i,r=!1){let s=`${t}${i?`.${i}`:""}`;return r?e(s):s}})(Vc||(Vc={}));var ow=class{constructor(e,t,i){this._isDefined=i;let r=Object.keys(t);this._rowCount=e.rowCount,this._columns=r,this._schema=t;let s=Object.create(null);for(let o of r)Object.defineProperty(this,o,{get:function(){if(s[o])return s[o];let a=t[o];if(a.valueType==="list")s[o]=E6(a,e,o);else if(a.valueType==="tensor")s[o]=T6(a,e,o);else{let l=C6(a),c=e.getField(o);s[o]=c?l(c,e,o):dn.Undefined(e.rowCount,a)}return s[o]},enumerable:!0,configurable:!1})}};function P6(n,e,t,i){let r=Vc.create(e,n),s=Vc.canonical(r);if(s in t)return t[s];if(i&&r in i)for(let o of i[r]){let a=Vc.canonical(o);if(a in t)return t[a]}}function I6(n,e,t,i){let r=t.categories[n];if(i){let s=function(c){let u=Object.create(null);for(let d of Object.keys(c.categories))for(let f of c.categories[d].fieldNames)u[Vc.create(d,f,!0)]=c.categories[d].getField(f);return u}(t),o=Object.create(null),a=[],l=0;for(let c of Object.keys(e)){let u=P6(c,n,s,i);u&&(o[c]=u,a.push(c),l=u.rowCount)}r={rowCount:l,name:n,fieldNames:[...a],getField:c=>o[c]}}return new ow(r||u0.empty(n),e,!!r)}var lo=dn.Schema,B=lo.str,ce=lo.int,bt=lo.float,bx=lo.coord,Xe=lo.Aliased,Yo=lo.Matrix,km=lo.Vector,Ot=lo.lstr,Wa=lo.List,R6={atom_site:{auth_asym_id:B,auth_atom_id:B,auth_comp_id:B,auth_seq_id:ce,B_iso_or_equiv:bt,Cartn_x:bx,Cartn_y:bx,Cartn_z:bx,group_PDB:Xe(B),id:ce,label_alt_id:B,label_asym_id:B,label_atom_id:B,label_comp_id:B,label_entity_id:B,label_seq_id:ce,occupancy:bt,type_symbol:B,pdbx_PDB_ins_code:B,pdbx_PDB_model_num:ce,pdbx_formal_charge:ce,pdbx_label_index:ce,pdbx_sifts_xref_db_name:B,pdbx_sifts_xref_db_acc:B,pdbx_sifts_xref_db_num:B,pdbx_sifts_xref_db_res:B,ihm_model_id:ce},atom_site_anisotrop:{id:ce,type_symbol:B,U:Yo(3,3),U_esd:Yo(3,3),pdbx_auth_seq_id:B,pdbx_auth_asym_id:B,pdbx_auth_atom_id:B,pdbx_auth_comp_id:B,pdbx_label_seq_id:ce,pdbx_label_alt_id:B,pdbx_label_asym_id:B,pdbx_label_atom_id:B,pdbx_label_comp_id:B,pdbx_PDB_ins_code:B},atom_sites:{entry_id:B,fract_transf_matrix:Yo(3,3),fract_transf_vector:km(3)},audit_author:{name:B,pdbx_ordinal:ce,identifier_ORCID:B},audit_conform:{dict_location:B,dict_name:B,dict_version:B},cell:{angle_alpha:bt,angle_beta:bt,angle_gamma:bt,entry_id:B,length_a:bt,length_b:bt,length_c:bt,Z_PDB:ce,pdbx_unique_axis:B},chem_comp:{formula:B,formula_weight:bt,id:B,mon_nstd_flag:Xe(Ot),name:B,type:Xe(Ot),pdbx_synonyms:Wa(";",n=>n)},chem_comp_bond:{atom_id_1:B,atom_id_2:B,comp_id:B,value_order:Xe(Ot),pdbx_ordinal:ce,pdbx_stereo_config:Xe(Ot),pdbx_aromatic_flag:Xe(Ot)},citation:{book_publisher:B,country:B,id:B,journal_abbrev:B,journal_id_ASTM:B,journal_id_CSD:B,journal_id_ISSN:B,journal_volume:B,page_first:B,page_last:B,title:B,year:ce,pdbx_database_id_DOI:B,pdbx_database_id_PubMed:ce},citation_author:{citation_id:B,name:B,ordinal:ce},database_2:{database_id:Xe(Ot),database_code:B},entity:{details:B,formula_weight:bt,id:B,src_method:Xe(Ot),type:Xe(Ot),pdbx_description:Wa(",",n=>n),pdbx_number_of_molecules:ce,pdbx_mutation:B,pdbx_fragment:B,pdbx_ec:Wa(",",n=>n)},entity_poly:{entity_id:B,nstd_linkage:Xe(Ot),nstd_monomer:Xe(Ot),type:Xe(B),pdbx_strand_id:Wa(",",n=>n),pdbx_seq_one_letter_code:B,pdbx_seq_one_letter_code_can:B,pdbx_target_identifier:B},entity_poly_seq:{entity_id:B,hetero:Xe(Ot),mon_id:B,num:ce},entry:{id:B},exptl:{entry_id:B,method:Xe(B)},software:{classification:B,date:B,description:B,name:B,type:Xe(Ot),version:B,pdbx_ordinal:ce},struct:{entry_id:B,title:B,pdbx_descriptor:B},struct_asym:{details:B,entity_id:B,id:B,pdbx_modified:B,pdbx_blank_PDB_chainid_flag:Xe(B)},struct_conf:{beg_label_asym_id:B,beg_label_comp_id:B,beg_label_seq_id:ce,beg_auth_asym_id:B,beg_auth_comp_id:B,beg_auth_seq_id:ce,conf_type_id:Xe(Ot),details:B,end_label_asym_id:B,end_label_comp_id:B,end_label_seq_id:ce,end_auth_asym_id:B,end_auth_comp_id:B,end_auth_seq_id:ce,id:B,pdbx_beg_PDB_ins_code:B,pdbx_end_PDB_ins_code:B,pdbx_PDB_helix_class:B,pdbx_PDB_helix_length:ce,pdbx_PDB_helix_id:B},struct_conn:{conn_type_id:Xe(Ot),details:B,id:B,ptnr1_label_asym_id:B,ptnr1_label_atom_id:B,ptnr1_label_comp_id:B,ptnr1_label_seq_id:ce,ptnr1_auth_asym_id:B,ptnr1_auth_comp_id:B,ptnr1_auth_seq_id:ce,ptnr1_symmetry:B,ptnr2_label_asym_id:B,ptnr2_label_atom_id:B,ptnr2_label_comp_id:B,ptnr2_label_seq_id:ce,ptnr2_auth_asym_id:B,ptnr2_auth_comp_id:B,ptnr2_auth_seq_id:ce,ptnr2_symmetry:B,pdbx_ptnr1_PDB_ins_code:B,pdbx_ptnr1_label_alt_id:B,pdbx_ptnr1_standard_comp_id:B,pdbx_ptnr2_PDB_ins_code:B,pdbx_ptnr2_label_alt_id:B,pdbx_ptnr3_PDB_ins_code:B,pdbx_ptnr3_label_alt_id:B,pdbx_ptnr3_label_asym_id:B,pdbx_ptnr3_label_atom_id:B,pdbx_ptnr3_label_comp_id:B,pdbx_ptnr3_label_seq_id:ce,pdbx_PDB_id:B,pdbx_dist_value:bt,pdbx_value_order:Xe(Ot)},struct_conn_type:{criteria:B,id:Xe(Ot),reference:B},struct_keywords:{entry_id:B,text:Wa(",",n=>n),pdbx_keywords:B},struct_ncs_oper:{code:Xe(B),details:B,id:ce,matrix:Yo(3,3),vector:km(3)},struct_sheet_range:{beg_label_asym_id:B,beg_label_comp_id:B,beg_label_seq_id:ce,end_label_asym_id:B,end_label_comp_id:B,end_label_seq_id:ce,beg_auth_asym_id:B,beg_auth_comp_id:B,beg_auth_seq_id:ce,end_auth_asym_id:B,end_auth_comp_id:B,end_auth_seq_id:ce,id:B,sheet_id:B,pdbx_beg_PDB_ins_code:B,pdbx_end_PDB_ins_code:B},struct_site:{details:B,id:B,pdbx_num_residues:ce,pdbx_evidence_code:B,pdbx_auth_asym_id:B,pdbx_auth_comp_id:B,pdbx_auth_seq_id:B,pdbx_auth_ins_code:B},struct_site_gen:{details:B,id:B,label_alt_id:B,label_asym_id:B,label_atom_id:B,label_comp_id:B,label_seq_id:ce,auth_asym_id:B,auth_comp_id:B,auth_seq_id:B,site_id:B,symmetry:B,pdbx_auth_ins_code:B,pdbx_num_res:ce},symmetry:{entry_id:B,cell_setting:Xe(Ot),Int_Tables_number:ce,space_group_name_Hall:B,"space_group_name_H-M":B},pdbx_database_status:{status_code:Xe(B),status_code_sf:Xe(B),status_code_mr:Xe(B),entry_id:B,recvd_initial_deposition_date:B,SG_entry:Xe(Ot),deposit_site:Xe(B),process_site:Xe(B),status_code_cs:Xe(B),methods_development_category:Xe(B),pdb_format_compatible:Xe(Ot)},pdbx_nonpoly_scheme:{asym_id:B,entity_id:B,mon_id:B,pdb_strand_id:B,ndb_seq_num:B,pdb_seq_num:B,auth_seq_num:B,pdb_mon_id:B,auth_mon_id:B,pdb_ins_code:B},pdbx_database_related:{db_name:B,details:B,db_id:B,content_type:Xe(B)},pdbx_entity_nonpoly:{entity_id:B,comp_id:B,name:B},pdbx_chem_comp_synonyms:{name:B,comp_id:B,provenance:Xe(B)},pdbx_chem_comp_identifier:{comp_id:B,identifier:B,type:Xe(B),program:B,program_version:B},pdbx_unobs_or_zero_occ_residues:{id:ce,polymer_flag:Xe(Ot),occupancy_flag:Xe(ce),PDB_model_num:ce,auth_asym_id:B,auth_comp_id:B,auth_seq_id:B,PDB_ins_code:B,label_asym_id:B,label_comp_id:B,label_seq_id:ce},pdbx_struct_mod_residue:{id:ce,auth_asym_id:B,auth_comp_id:B,auth_seq_id:ce,PDB_ins_code:B,label_asym_id:B,label_comp_id:B,label_seq_id:ce,parent_comp_id:B,details:B},pdbx_struct_oper_list:{id:B,type:Xe(B),name:B,symmetry_operation:B,matrix:Yo(3,3),vector:km(3)},pdbx_struct_assembly:{method_details:B,oligomeric_details:B,oligomeric_count:ce,details:B,id:B},pdbx_struct_assembly_gen:{asym_id_list:Wa(",",n=>n),assembly_id:B,oper_expression:B},pdbx_reference_entity_list:{prd_id:B,ref_entity_id:B,type:Xe(Ot),details:B,component_id:ce},pdbx_reference_entity_link:{link_id:ce,prd_id:B,details:B,ref_entity_id_1:B,ref_entity_id_2:B,entity_seq_num_1:ce,entity_seq_num_2:ce,comp_id_1:B,comp_id_2:B,atom_id_1:B,atom_id_2:B,value_order:Xe(Ot),component_1:ce,component_2:ce,link_class:Xe(B)},pdbx_reference_entity_poly_link:{link_id:ce,prd_id:B,ref_entity_id:B,component_id:ce,entity_seq_num_1:ce,entity_seq_num_2:ce,comp_id_1:B,comp_id_2:B,atom_id_1:B,atom_id_2:B,value_order:Xe(Ot)},pdbx_molecule:{prd_id:B,instance_id:ce,asym_id:B},pdbx_molecule_features:{prd_id:B,class:Xe(Ot),type:Xe(Ot),name:B,details:B},entity_src_nat:{entity_id:B,pdbx_organism_scientific:B,pdbx_plasmid_name:B,pdbx_src_id:ce,pdbx_beg_seq_num:ce,pdbx_end_seq_num:ce},entity_src_gen:{entity_id:B,pdbx_gene_src_gene:Wa(",",n=>n),pdbx_gene_src_scientific_name:B,plasmid_name:B,pdbx_src_id:ce,pdbx_beg_seq_num:ce,pdbx_end_seq_num:ce},pdbx_entity_src_syn:{organism_scientific:B,entity_id:B,pdbx_src_id:ce,pdbx_beg_seq_num:ce,pdbx_end_seq_num:ce},pdbx_entity_branch_descriptor:{entity_id:B,descriptor:B,type:Xe(Ot),program:B,program_version:B,ordinal:ce},pdbx_entity_instance_feature:{details:B,feature_type:Xe(B),auth_asym_id:B,asym_id:B,auth_seq_num:B,seq_num:ce,comp_id:B,auth_comp_id:B,ordinal:ce},pdbx_entity_branch_list:{entity_id:B,hetero:Xe(Ot),comp_id:B,num:ce},pdbx_entity_branch_link:{link_id:ce,details:B,entity_id:B,entity_branch_list_num_1:ce,entity_branch_list_num_2:ce,comp_id_1:B,comp_id_2:B,atom_id_1:B,leaving_atom_id_1:B,atom_stereo_config_1:Xe(Ot),atom_id_2:B,leaving_atom_id_2:B,atom_stereo_config_2:Xe(Ot),value_order:Xe(Ot)},pdbx_entity_branch:{entity_id:B,type:Xe(B)},pdbx_branch_scheme:{entity_id:B,hetero:Xe(Ot),asym_id:B,mon_id:B,num:ce,pdb_asym_id:B,pdb_seq_num:B,pdb_mon_id:B,auth_asym_id:B,auth_seq_num:B,auth_mon_id:B},pdbx_chem_comp_related:{comp_id:B,related_comp_id:B,relationship_type:Xe(B),details:B},ihm_starting_model_details:{starting_model_id:B,entity_id:B,entity_description:B,asym_id:B,entity_poly_segment_id:ce,starting_model_source:Xe(B),starting_model_auth_asym_id:B,starting_model_sequence_offset:ce,dataset_list_id:ce},ihm_starting_comparative_models:{id:ce,starting_model_id:B,starting_model_auth_asym_id:B,starting_model_seq_id_begin:ce,starting_model_seq_id_end:ce,template_auth_asym_id:B,template_seq_id_begin:ce,template_seq_id_end:ce,template_sequence_identity:bt,template_sequence_identity_denominator:Xe(ce),template_dataset_list_id:ce,alignment_file_id:ce},ihm_starting_model_seq_dif:{id:ce,entity_id:B,asym_id:B,seq_id:ce,comp_id:B,starting_model_id:B,db_asym_id:B,db_seq_id:ce,db_comp_id:B,details:B},ihm_model_representation:{id:ce,name:B,details:B},ihm_model_representation_details:{id:ce,representation_id:ce,entity_poly_segment_id:ce,entity_id:B,entity_description:B,entity_asym_id:B,model_object_primitive:Xe(B),starting_model_id:B,model_mode:Xe(B),model_granularity:Xe(B),model_object_count:ce},ihm_struct_assembly_details:{id:ce,assembly_id:ce,parent_assembly_id:ce,entity_description:B,entity_id:B,asym_id:B,entity_poly_segment_id:ce},ihm_struct_assembly:{id:ce,name:B,description:B},ihm_modeling_protocol:{id:ce,num_steps:ce,protocol_name:B},ihm_modeling_protocol_details:{id:ce,protocol_id:ce,step_id:ce,struct_assembly_id:ce,dataset_group_id:ce,struct_assembly_description:B,step_name:B,step_method:B,num_models_begin:ce,num_models_end:ce,multi_scale_flag:Xe(Ot),multi_state_flag:Xe(Ot),ordered_flag:Xe(Ot),script_file_id:ce,software_id:ce},ihm_multi_state_modeling:{state_id:ce,state_group_id:ce,population_fraction:bt,population_fraction_sd:bt,state_type:B,state_name:B,experiment_type:Xe(B),details:B},ihm_modeling_post_process:{id:ce,protocol_id:ce,analysis_id:ce,step_id:ce,type:Xe(B),feature:Xe(B),num_models_begin:ce,num_models_end:ce},ihm_ensemble_info:{ensemble_id:ce,ensemble_name:B,post_process_id:ce,model_group_id:ce,ensemble_clustering_method:Xe(B),ensemble_clustering_feature:Xe(B),num_ensemble_models:ce,num_ensemble_models_deposited:ce,ensemble_precision_value:bt,ensemble_file_id:ce},ihm_model_list:{model_id:ce,model_name:B,assembly_id:ce,protocol_id:ce,representation_id:ce},ihm_model_group:{id:ce,name:B,details:B},ihm_model_group_link:{model_id:ce,group_id:ce},ihm_model_representative:{id:ce,model_group_id:ce,model_id:ce,selection_criteria:Xe(B)},ihm_dataset_list:{id:ce,data_type:Xe(B),database_hosted:Xe(Ot)},ihm_dataset_group:{id:ce,name:B,application:Xe(B),details:B},ihm_dataset_group_link:{dataset_list_id:ce,group_id:ce},ihm_related_datasets:{dataset_list_id_derived:ce,dataset_list_id_primary:ce},ihm_dataset_related_db_reference:{id:ce,dataset_list_id:ce,db_name:Xe(B),accession_code:B,version:B,details:B},ihm_external_reference_info:{reference_id:ce,reference_provider:B,reference_type:Xe(B),reference:B,refers_to:Xe(B),associated_url:B},ihm_external_files:{id:ce,reference_id:ce,file_path:B,content_type:Xe(B),file_size_bytes:bt,details:B},ihm_dataset_external_reference:{id:ce,dataset_list_id:ce,file_id:ce},ihm_localization_density_files:{id:ce,file_id:ce,ensemble_id:ce,entity_id:B,entity_poly_segment_id:ce,asym_id:B},ihm_predicted_contact_restraint:{id:ce,group_id:ce,entity_id_1:B,entity_id_2:B,asym_id_1:B,asym_id_2:B,comp_id_1:B,comp_id_2:B,seq_id_1:ce,seq_id_2:ce,rep_atom_1:Xe(B),rep_atom_2:Xe(B),distance_lower_limit:bt,distance_upper_limit:bt,probability:bt,restraint_type:Xe(B),model_granularity:Xe(B),dataset_list_id:ce,software_id:ce},ihm_cross_link_list:{id:ce,group_id:ce,entity_description_1:B,entity_description_2:B,entity_id_1:B,entity_id_2:B,comp_id_1:B,comp_id_2:B,seq_id_1:ce,seq_id_2:ce,linker_type:Xe(B),dataset_list_id:ce},ihm_cross_link_restraint:{id:ce,group_id:ce,entity_id_1:B,entity_id_2:B,asym_id_1:B,asym_id_2:B,comp_id_1:B,comp_id_2:B,seq_id_1:ce,seq_id_2:ce,atom_id_1:B,atom_id_2:B,restraint_type:Xe(B),conditional_crosslink_flag:Xe(B),model_granularity:Xe(B),distance_threshold:bt,psi:bt,sigma_1:bt,sigma_2:bt},ihm_cross_link_result_parameters:{id:ce,restraint_id:ce,model_id:ce,psi:bt,sigma_1:bt,sigma_2:bt},ihm_2dem_class_average_restraint:{id:ce,dataset_list_id:ce,number_raw_micrographs:ce,pixel_size_width:bt,pixel_size_height:bt,image_resolution:bt,image_segment_flag:Xe(Ot),number_of_projections:ce,struct_assembly_id:ce,details:B},ihm_2dem_class_average_fitting:{id:ce,restraint_id:ce,model_id:ce,cross_correlation_coefficient:bt,rot_matrix:Yo(3,3),tr_vector:km(3)},ihm_3dem_restraint:{id:ce,dataset_list_id:ce,model_id:ce,struct_assembly_id:ce,fitting_method:B,number_of_gaussians:ce,cross_correlation_coefficient:bt},ihm_sas_restraint:{id:ce,dataset_list_id:ce,model_id:ce,struct_assembly_id:ce,profile_segment_flag:Xe(Ot),fitting_atom_type:B,fitting_method:B,fitting_state:Xe(B),radius_of_gyration:bt,chi_value:bt,details:B},ihm_starting_model_coord:{ordinal_id:ce,starting_model_id:B,group_PDB:Xe(B),id:ce,type_symbol:B,entity_id:B,atom_id:B,comp_id:B,seq_id:ce,asym_id:B,Cartn_x:bt,Cartn_y:bt,Cartn_z:bt,B_iso_or_equiv:bt},ihm_sphere_obj_site:{id:ce,entity_id:B,seq_id_begin:ce,seq_id_end:ce,asym_id:B,Cartn_x:bt,Cartn_y:bt,Cartn_z:bt,object_radius:bt,rmsf:bt,model_id:ce},ihm_gaussian_obj_site:{id:ce,entity_id:B,seq_id_begin:ce,seq_id_end:ce,asym_id:B,mean_Cartn_x:bt,mean_Cartn_y:bt,mean_Cartn_z:bt,weight:bt,covariance_matrix:Yo(3,3),model_id:ce},ihm_gaussian_obj_ensemble:{id:ce,entity_id:B,seq_id_begin:ce,seq_id_end:ce,asym_id:B,mean_Cartn_x:bt,mean_Cartn_y:bt,mean_Cartn_z:bt,weight:bt,covariance_matrix:Yo(3,3),ensemble_id:ce},ihm_feature_list:{feature_id:ce,feature_type:Xe(B),entity_type:Xe(B)},ihm_poly_residue_feature:{ordinal_id:ce,feature_id:ce,entity_id:B,asym_id:B,comp_id_begin:B,comp_id_end:B,seq_id_begin:ce,seq_id_end:ce},ihm_derived_distance_restraint:{id:ce,group_id:ce,feature_id_1:ce,feature_id_2:ce,group_conditionality:Xe(B),random_exclusion_fraction:bt,distance_upper_limit:bt,restraint_type:Xe(B),dataset_list_id:ce},ma_model_list:{ordinal_id:ce,model_id:ce,model_group_id:ce,model_name:B,model_group_name:B,model_type:Xe(B),data_id:ce},ma_target_entity:{entity_id:B,data_id:ce,origin:Xe(B)},ma_target_entity_instance:{asym_id:B,entity_id:B,details:B},ma_target_ref_db_details:{target_entity_id:B,db_name:Xe(B),db_code:B,db_accession:B,seq_db_isoform:B,seq_db_align_begin:B,seq_db_align_end:B,ncbi_taxonomy_id:B,organism_scientific:B},ma_data:{id:ce,content_type:Xe(B),content_type_other_details:B,name:B},ma_software_group:{ordinal_id:ce,group_id:ce,software_id:ce},ma_qa_metric:{id:ce,name:B,type:Xe(B),mode:Xe(B),software_group_id:ce},ma_qa_metric_global:{ordinal_id:ce,model_id:ce,metric_id:ce,metric_value:bt},ma_qa_metric_local:{ordinal_id:ce,model_id:ce,label_asym_id:B,label_seq_id:ce,label_comp_id:B,metric_id:ce,metric_value:bt}},ul=dn.Schema,Gt=ul.str,k6=ul.float,sP=ul.List,fs=ul.lstr,rr=ul.Aliased,zh=ul.int,wc=ul.coord,L6={chem_comp:{formula:Gt,formula_weight:k6,id:Gt,mon_nstd_parent_comp_id:sP(",",n=>n),name:Gt,one_letter_code:Gt,three_letter_code:Gt,type:rr(fs),pdbx_synonyms:sP(";",n=>n),pdbx_type:Gt,pdbx_ambiguous_flag:Gt,pdbx_replaced_by:Gt,pdbx_replaces:Gt,pdbx_formal_charge:zh,pdbx_model_coordinates_details:Gt,pdbx_model_coordinates_db_code:Gt,pdbx_ideal_coordinates_details:Gt,pdbx_ideal_coordinates_missing_flag:rr(fs),pdbx_model_coordinates_missing_flag:rr(fs),pdbx_initial_date:Gt,pdbx_modified_date:Gt,pdbx_release_status:rr(Gt),pdbx_processing_site:rr(Gt)},chem_comp_atom:{alt_atom_id:Gt,atom_id:Gt,charge:zh,model_Cartn_x:wc,model_Cartn_y:wc,model_Cartn_z:wc,comp_id:Gt,type_symbol:Gt,pdbx_align:zh,pdbx_ordinal:zh,pdbx_model_Cartn_x_ideal:wc,pdbx_model_Cartn_y_ideal:wc,pdbx_model_Cartn_z_ideal:wc,pdbx_stereo_config:rr(fs),pdbx_aromatic_flag:rr(fs),pdbx_leaving_atom_flag:rr(fs)},chem_comp_bond:{atom_id_1:Gt,atom_id_2:Gt,comp_id:Gt,value_order:rr(fs),pdbx_ordinal:zh,pdbx_stereo_config:rr(fs),pdbx_aromatic_flag:rr(fs)},pdbx_chem_comp_descriptor:{comp_id:Gt,descriptor:Gt,type:rr(fs),program:Gt,program_version:Gt},pdbx_chem_comp_identifier:{comp_id:Gt,identifier:Gt,type:rr(Gt),program:Gt,program_version:Gt}},Ld=dn.Schema,gt=Ld.str,D6=Ld.float,Ks=Ld.lstr,Pi=Ld.Aliased,Ar=Ld.int,N6={pdbx_reference_molecule:{prd_id:gt,formula_weight:D6,formula:gt,type:Pi(Ks),type_evidence_code:gt,class:Pi(Ks),class_evidence_code:gt,name:gt,represent_as:Pi(Ks),chem_comp_id:gt,compound_details:gt,description:gt,representative_PDB_id_code:gt,release_status:Pi(Ks),replaces:gt,replaced_by:gt},pdbx_reference_entity_list:{prd_id:gt,ref_entity_id:gt,type:Pi(Ks),details:gt,component_id:Ar},pdbx_reference_entity_nonpoly:{prd_id:gt,ref_entity_id:gt,name:gt,chem_comp_id:gt},pdbx_reference_entity_link:{link_id:Ar,prd_id:gt,details:gt,ref_entity_id_1:gt,ref_entity_id_2:gt,entity_seq_num_1:Ar,entity_seq_num_2:Ar,comp_id_1:gt,comp_id_2:gt,atom_id_1:gt,atom_id_2:gt,value_order:Pi(Ks),component_1:Ar,component_2:Ar,link_class:Pi(gt)},pdbx_reference_entity_poly_link:{link_id:Ar,prd_id:gt,ref_entity_id:gt,component_id:Ar,entity_seq_num_1:Ar,entity_seq_num_2:Ar,comp_id_1:gt,comp_id_2:gt,atom_id_1:gt,atom_id_2:gt,value_order:Pi(Ks)},pdbx_reference_entity_poly:{prd_id:gt,ref_entity_id:gt,type:Pi(gt),db_code:gt,db_name:gt},pdbx_reference_entity_poly_seq:{prd_id:gt,ref_entity_id:gt,mon_id:gt,parent_mon_id:gt,num:Ar,observed:Pi(Ks),hetero:Pi(Ks)},pdbx_reference_entity_sequence:{prd_id:gt,ref_entity_id:gt,type:Pi(gt),NRP_flag:Pi(gt),one_letter_codes:gt},pdbx_reference_entity_src_nat:{prd_id:gt,ref_entity_id:gt,ordinal:Ar,organism_scientific:gt,taxid:gt,db_code:gt,db_name:gt},pdbx_prd_audit:{prd_id:gt,date:gt,processing_site:Pi(gt),action_type:Pi(gt)}},PI=dn.Schema,Rn=PI.str,F6={datablock:{id:Rn,description:Rn},dictionary:{title:Rn,datablock_id:Rn,version:Rn},dictionary_history:{version:Rn,update:Rn,revision:Rn},sub_category:{id:Rn,description:Rn},category_group_list:{id:Rn,parent_id:Rn,description:Rn},item_type_list:{code:Rn,primitive_code:Rn,construct:Rn,detail:Rn},item_units_list:{code:Rn,detail:Rn},item_units_conversion:{from_code:Rn,to_code:Rn,operator:Rn,factor:PI.float}},Dd=dn.Schema,ed=Dd.str,Lm=Dd.int,Js=Dd.float,Dm=Dd.Aliased,Zo=Dd.Vector;Dm(ed),Dm(ed),Dm(ed),Dm(ed),Zo(3),Zo(3);var II={volume_data_3d_info:{name:ed,axis_order:Zo(3,Lm),origin:Zo(3),dimensions:Zo(3),sample_rate:Lm,sample_count:Zo(3,Lm),spacegroup_number:Lm,spacegroup_cell_size:Zo(3),spacegroup_cell_angles:Zo(3),mean_source:Js,mean_sampled:Js,sigma_source:Js,sigma_sampled:Js,min_source:Js,min_sampled:Js,max_source:Js,max_sampled:Js},volume_data_3d:{values:Js}},k0=dn.Schema,_n=k0.float,wx=k0.int,Wt=k0.str,O6={cell:{angle_alpha:_n,angle_beta:_n,angle_gamma:_n,formula_units_z:wx,length_a:_n,length_b:_n,length_c:_n,volume:_n},chemical:{melting_point:_n,name_common:Wt,name_systematic:Wt},chemical_formula:{moiety:Wt,sum:Wt,weight:_n},space_group:{crystal_system:Wt,it_number:wx,"name_h-m_full":Wt},space_group_symop:{operation_xyz:Wt},geom_bond:{atom_site_label_1:Wt,atom_site_label_2:Wt,distance:_n,publ_flag:Wt,site_symmetry_1:Wt,site_symmetry_2:Wt,valence:_n},audit:{block_doi:Wt},database_code:{cod:Wt,csd:Wt,depnum_ccdc_archive:Wt,depnum_ccdc_fiz:Wt,icsd:Wt,mdf:Wt,nbs:Wt},atom_site:{adp_type:Wt,calc_flag:Wt,disorder_assembly:Wt,disorder_group:Wt,fract_x:_n,fract_y:_n,fract_z:_n,label:Wt,occupancy:_n,refinement_flags:Wt,site_symmetry_multiplicity:wx,type_symbol:Wt,u_iso_or_equiv:_n},atom_site_aniso:{label:Wt,u_11:_n,u:(0,k0.Matrix)(3,3),u_12:_n,u_13:_n,u_22:_n,u_23:_n,u_33:_n},atom_type:{description:Wt,symbol:Wt},atom_type_scat:{dispersion_imag:_n,dispersion_real:_n,source:Wt}},B6={"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"]},Sx=dn.Schema.int,U6={volume_data_3d_info:II.volume_data_3d_info,segmentation_data_table:{set_id:Sx,segment_id:Sx},segmentation_data_3d:{values:Sx}},oP={parse:n=>typeof n=="string"?ZT(n):iP(n),parseText:ZT,parseBinary:iP,toDatabaseCollection:function(n,e,t){let i={};for(let r of e.blocks)i[r.header]=Zs(n,r,t);return i},toDatabase:Zs,schema:{mmCIF:n=>Zs(R6,n),CCD:n=>Zs(L6,n),BIRD:n=>Zs(N6,n),dic:n=>Zs(F6,n),cifCore:n=>Zs(O6,n,B6),densityServer:n=>Zs(II,n),segmentation:n=>Zs(U6,n)}},lr=class{constructor(e,t){var i=t||{};this.streamer=e,this.name=U(i.name,""),this.path=U(i.path,"")}get type(){return""}get __objName(){return""}get isBinary(){return!1}get isJson(){return!1}get isXml(){return!1}parse(){return this.streamer.read().then(()=>fI(this,void 0,void 0,function*(){return yield this._beforeParse(),yield this._parse(),yield this._afterParse(),this[this.__objName]}))}_parse(){}_beforeParse(){}_afterParse(){Le&&we.log(this[this.__objName])}},ts=class extends lr{constructor(e,t){var i=t||{};super(e,i),this.firstModelOnly=U(i.firstModelOnly,!1),this.asTrajectory=U(i.asTrajectory,!1),this.cAlphaOnly=U(i.cAlphaOnly,!1),this.structure=new Er(this.name,this.path),this.structureBuilder=new zb(this.structure)}get type(){return"structure"}get __objName(){return"structure"}},tu=class{constructor(e,t,i="",r,s=[]){this.structure=e,this.index=t,this.description=i,this.entityType=function(o){switch(o=o.toLowerCase()){case"polymer":return 1;case"non-polymer":return 2;case"macrolide":return 3;case"water":return 4;default:return 0}}(r||""),this.chainIndexList=s,s.forEach(function(o){e.chainStore.entityIndex[o]=t})}get type(){return function(e){switch(e){case 1:return"polymer";case 2:return"non-polymer";case 3:return"macrolide";case 4:return"water";default:return}}(this.entityType)}getEntityType(){return this.entityType}isPolymer(){return this.entityType===1}isNonPolymer(){return this.entityType===2}isMacrolide(){return this.entityType===3}isWater(){return this.entityType===4}eachChain(e){let t=this.structure.getChainProxy();this.chainIndexList.forEach(function(i){t.index=i,e(t)})}},z6={a:1,b:1,c:1,alpha:90,beta:90,gamma:90,spacegroup:"P 1"},nu=class{constructor(e=z6){this.cartToFrac=new qe,this.fracToCart=new qe,this.a=e.a,this.b=e.b,this.c=e.c,this.alpha=e.alpha,this.beta=e.beta,this.gamma=e.gamma,this.spacegroup=e.spacegroup;let t=En(this.alpha),i=En(this.beta),r=En(this.gamma),s=Math.cos(t),o=Math.cos(i),a=Math.cos(r),l=Math.sin(i),c=Math.sin(r);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-s*s-o*o-a*a+2*s*o*a),e.cartToFrac===void 0){let u=this.a*this.b*c/this.volume,d=(o*a-s)/(l*c);this.fracToCart.set(this.a,0,0,0,this.b*a,this.b*c,0,0,this.c*o,-this.c*l*d,1/u,0,0,0,0,1).transpose(),this.cartToFrac.copy(this.fracToCart).invert()}else this.cartToFrac.copy(e.cartToFrac),this.fracToCart.copy(this.cartToFrac).invert()}getPosition(e){let t=new Float32Array(24);if(e.unitcell){let i=e.unitcell,r=e.center.clone().applyMatrix4(i.cartToFrac).floor(),s=new W,o=0,a=function(l,c,u){s.set(l,c,u).add(r).applyMatrix4(i.fracToCart).toArray(t,o),o+=3};a(0,0,0),a(1,0,0),a(0,1,0),a(0,0,1),a(1,1,0),a(1,0,1),a(0,1,1),a(1,1,1)}return t}getCenter(e){return function(t,i=new W){let r=t.length;for(let s=0;s0)continue;let ie,ye,pe,ve,Ne,st=0;if(s){if(ve=A.split(aP),st=ve.length===10?1:0,O=ve[2],p&&O!=="CA")continue;ie=parseFloat(ve[6-st]),ye=parseFloat(ve[7-st]),pe=parseFloat(ve[8-st])}else{if(O=A.substr(12,4).trim(),p&&O!=="CA")continue;ie=parseFloat(A.substr(30,8)),ye=parseFloat(A.substr(38,8)),pe=parseFloat(A.substr(46,8))}if(m){let k=3*b;if(g[k+0]=ie,g[k+1]=ye,g[k+2]=pe,b+=1,h)continue}s?(T=parseInt(ve[1]),Ne="",D=A[0]==="H",R=st?"":ve[4],C=parseInt(ve[5-st]),I="",P=ve[3],H="",E=1):(T=parseInt(A.substr(6,5),u),c&&T===99999&&(u=16),D=A[0]==="H",R=A[21].trim(),C=parseInt(A.substr(22,4),d),c&&C===9999&&(d=16),I=A[26].trim(),P=A.substr(17,4).trim()||"MOL",N=parseFloat(A.substr(60,6)),H=A[16].trim(),E=parseFloat(A.substr(54,6)),e||(o?(Ne=A.substr(76,3).trim(),Ne in nT&&(Ne=nT[Ne])):(Ne=A.substr(76,2).trim(),R||(R=A.substr(72,4).trim())),z=parseInt((A.substr(79,1)+A.substr(78,1)).trim()))),Be.growIfFull(),Be.atomTypeId[je]=Ae.add(O,Ne),Be.x[je]=ie,Be.y[je]=ye,Be.z[je]=pe,Be.serial[je]=T,Be.altloc[je]=H.charCodeAt(0),Be.occupancy[je]=isNaN(E)?0:E,s?(Be.partialCharge[je]=parseFloat(ve[9-st]),Be.radius[je]=parseFloat(ve[10-st])):(Be.bfactor[je]=isNaN(N)?0:N,o&&(Be.partialCharge[je]=parseFloat(A.substr(70,6))),isFinite(z)&&(Be.formalCharge||Be.addField("formalCharge",1,"int8"),Be.formalCharge[je]=z));let wt=lP(C,R,I);!D||xe[wt]||V6.includes(P)?$e||_e===R||(Re+=1,ke=Re.toString()):_e===R&&We===P&&(dg.includes(P)||Ie===C&&Fe===I)||(Re+=1,ke=Re.toString(),Ie=C,We=P,Fe=I),l.addAtom(at,R,ke,P,C,D,void 0,I),re[T]=je,je+=1,$e=!1,_e=R}else if(M==="CONECT"){let ie=re[parseInt(A.substr(6,5))],ye=[11,16,21,26],pe={};if(ie===void 0)continue;for(let ve=0;ve<4;++ve){let Ne=parseInt(A.substr(ye[ve],5));if(!Number.isNaN(Ne)&&(Ne=re[Ne],Ne!==void 0))if(ie{var p;return[(p=s.get(f))===null||p===void 0?void 0:p.atomname,m]})),a=[],l=[],c=[],u,d;for(let f=0;f{var Ie;let We=Q.getField(Re),Fe=Q.getField(ke),Y=Q.getField($e),$=_e*F;for(let de=0;deTe*Te)return L.growIfFull(),L.atomTypeId[Re]=L.atomTypeId[_e],L.x[Re]=le.x,L.y[Re]=le.y,L.z[Re]=le.z,L.occupancy[Re]=L.occupancy[_e],L.serial[Re]=Re,L.altloc[Re]=65,N.addAtom(0,"","","HET",1,!0),void(Re+=1)}}})}})(I,x,w),w.finalize(),x.finalizeAtoms(),bg(x),x.finalizeBonds();else{let O={},D={},N=x.atomMap,H=x.atomStore,z=I.categories.atom_site,L=z.rowCount,F=z.getField("pdbx_PDB_model_num");if(!((e=F?.areValuesEqual(0,L-1))===null||e===void 0||e)&&(M||A)){let _e=F.int(0);for(let Ie=0;Ie_e){L=Ie;break}}x.chemCompMap=new aw(x);let te=I.categories.chem_comp,Q=te.getField("id"),Z=te.getField("type");for(let _e=0;_e{let Fe=_e.getField(Ie);return Fe?Fe.toFloatArray({array:Float32Array,start:0,end:We}):new Float32Array(We)};H.resize(L),H.x=J(z,"Cartn_x",L),H.y=J(z,"Cartn_y",L),H.z=J(z,"Cartn_z",L),H.serial=z.getField("id").toIntArray({start:0,end:L}),H.bfactor=J(z,"B_iso_or_equiv",L),H.occupancy=J(z,"occupancy",L);let re=z.getField("label_alt_id");re?.isDefined&&(H.altloc=Uint8Array.from(re.toStringArray(),_e=>_e.charCodeAt(0)));let X=z.getField("label_atom_id"),se=z.getField("type_symbol");Q=z.getField("label_comp_id");let ne=(t=z.getField("auth_seq_id"))!==null&&t!==void 0?t:z.getField("label_seq_id"),oe=z.getField("pdbx_PDB_ins_code"),ee=z.getField("auth_asym_id"),le=z.getField("label_asym_id"),xe=z.getField("group_PDB"),Se=z.getField("label_entity_id");for(let _e=0;_e0){let[Oe,et]=lt.split("(").filter(pe=>!!pe),ie=Ae(Oe),ye=Ae(et);Object.keys(ie).forEach(function(pe){Object.keys(ye).forEach(function(ve){let Ne=new qe;Ne.multiplyMatrices(ie[pe],ye[ve]),Pe[pe+"x"+ve]=Ne})})}else Pe=Ae(lt);let tt=[];for(let Oe in Pe)tt.push(Pe[Oe]);let He=""+at;/^(0|[1-9][0-9]*)$/.test(He)&&(He="BU"+He);let Qe=Ue.str(je).split(",").map(Oe=>We[Oe]);Y[He]===void 0&&(Y[He]=new As(He)),Y[He].addPart(tt,Qe)}}if(_e.struct_ncs_oper){let fe=_e.struct_ncs_oper,Ae="NCS";Y[Ae]=new As(Ae);let Be=Y[Ae].addPart(),Ee=fe.getField("code"),Ue=fe.getField("matrix[1][1]"),je=fe.getField("matrix[1][2]"),at=fe.getField("matrix[1][3]"),Pe=fe.getField("matrix[2][1]"),lt=fe.getField("matrix[2][2]"),tt=fe.getField("matrix[2][3]"),He=fe.getField("matrix[3][1]"),Qe=fe.getField("matrix[3][2]"),Oe=fe.getField("matrix[3][3]"),et=fe.getField("vector[1]"),ie=fe.getField("vector[2]"),ye=fe.getField("vector[3]");for(let pe=0;pe$&&([Y,$]=[$,Y],[k,K]=[K,k]),Y!==0&&$!==0)for(let ae=0;ae<$;++ae)de.index=k[ae%Y],Te.index=K[ae],de&&Te?Ie.bondStore.addBond(de,Te,cP(ie.str(ye))):we.log("atoms for connection not found");else Le&&we.warn("no atoms found for",wt,q)}}}(I.categories,x,O),function(_e,Ie,We){var Fe;if(_e.entity){let Y=_e.entity,$=Y.getField("id"),de=Y.getField("pdbx_description"),Te=Y.getField("type"),fe=Y.rowCount;for(let Ae=0;Aeb)continue}d=E.substr(5,5).trim(),f=parseInt(E.substr(0,5)),m=parseInt(E.substr(15,5)),v.growIfFull(),v.atomTypeId[S]=h.add(u),v.x[S]=D,v.y[S]=N,v.z[S]=H,v.serial[S]=m,i.addAtom(x,"","",d,f,!1,"l"),S+=1}}}})(0,A.length,A)}),i.finalize(),t.finalizeAtoms(),R0(t),bg(t),t.finalizeBonds(),I0(t),Le&&we.timeEnd("GroParser._parse "+this.name)}});var j6=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function Nd(n,e,t){return e?new n(e.buffer,e.byteOffset,e.byteLength/(t||1)):void 0}function lw(n){return Nd(DataView,n)}function Ax(n){return Nd(Int8Array,n)}function m0(n){return Nd(Int32Array,n,4)}function Vh(n,e){var t=n.length/2;e||(e=new Int16Array(t));for(var i=0,r=0;is&&++a;e=new Int32Array(a)}for(t=0,i=0;tu){for(var d=[],f=0;f0&&(s.biomolDict[N]=H)}let D=o.unitCell;D&&Array.isArray(D)&&D[0]?s.unitcell=new nu({a:D[0],b:D[1],c:D[2],alpha:D[3],beta:D[4],gamma:D[5],spacegroup:o.spaceGroup}):s.unitcell=void 0,cu(s,!0),lu(s,!0),s.finalizeAtoms(),s.finalizeBonds(),wg(s),Le&&we.timeEnd("MmtfParser._parse "+this.name)}});var Mx=/\s+/,K6={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};At.add("mol2",class extends ts{get type(){return"mol2"}_parse(){Le&&we.time("Mol2Parser._parse "+this.name);let n=this.structure,e=this.structureBuilder,t=this.firstModelOnly,i=this.asTrajectory,r=n.frames,s,o,a=!1,l=n.atomMap,c=n.atomStore;c.resize(Math.round(this.streamer.data.length/60)),c.addField("partialCharge",1,"float32");let u=0,d=0,f=0,m=-1,p=0,_=0,y=n.getAtomProxy(),g=n.getAtomProxy();this.streamer.eachChunkOfLines(function(b){(function(h,v,S){for(let x=h;xMOLECULE"?(_=1,d=0,++m):w==="@ATOM"?(_=2,f=c.count,i&&(o=0,s=new Float32Array(3*p),r.push(s),m>0&&(a=!0))):_=w==="@BOND"?3:0;else if(_===1){if(d===0)n.title=w,n.id=w;else if(d===1){let A=w.split(Mx);p=parseInt(A[0])}++d}else if(_===2){let A=w.split(Mx);if(t&&m>0)continue;let M=parseFloat(A[2]),T=parseFloat(A[3]),R=parseFloat(A[4]);if(i){let N=3*o;if(s[N+0]=M,s[N+1]=T,s[N+2]=R,o+=1,a)continue}let C=A[0],P=A[1],E=A[5].split(".")[0],I=A[6]?parseInt(A[6]):1,O=A[7]?A[7]:"",D=A[8]?parseFloat(A[8]):0;c.growIfFull(),c.atomTypeId[u]=l.add(P,E),c.x[u]=M,c.y[u]=T,c.z[u]=R,c.serial[u]=+C,c.partialCharge[u]=D,e.addAtom(m,"","",O,I,!0),u+=1}else if(_===3){if(t&&m>0||i&&m>0)continue;let A=w.split(Mx);y.index=parseInt(A[1])-1+f,g.index=parseInt(A[2])-1+f;let M=K6[A[3]];n.bondStore.addBond(y,g,M)}}}})(0,b.length,b)}),e.finalize(),n.finalizeAtoms(),R0(n),lu(n,!0),cu(n,!0),n.finalizeBonds(),sl(n),I0(n),Le&&we.timeEnd("Mol2Parser._parse "+this.name)}});At.add("pdbqt",class extends Qa{get type(){return"pdbqt"}});At.add("pqr",class extends Qa{get type(){return"pqr"}});var J6=/> +<(.+)>/,cd=class extends ts{get type(){return"sdf"}_parse(){Le&&we.time("SdfParser._parse "+this.name);let e=this.structure,t=this.structureBuilder,i=this.firstModelOnly,r=this.asTrajectory,s=this.streamer.peekLines(2);e.id=s[0].trim(),e.title=s[1].trim();let o=e.frames,a,l,c=!1,u=e.atomMap,d=e.atomStore;d.resize(Math.round(this.streamer.data.length/50)),d.addField("formalCharge",1,"int8");let f=e.getAtomProxy(),m=e.getAtomProxy(),p=0,_=0,y=0,g=0,b=[],h,v,S,x,w,A,M,T,R,C,P,E,I,O,D=!1,N={};e.extraData.sdf=b;let H=!1,z=!1,L=!1,F=[],te=[],Q=new Map;this.streamer.eachChunkOfLines(function(Z){(function(J,re,X){for(let se=J;se-1,H?Q.clear():(v=parseInt(ne.substr(0,3)),S=parseInt(ne.substr(3,3)),x=4,w=x+v,A=w,M=A+S,r&&(l=0,a=new Float32Array(3*v),o.push(a),y>0&&(c=!0)));else if(H&&F[0]==="COUNTS")v=parseInt(F[1]),r&&(l=0,a=new Float32Array(3*v),o.push(a),y>0&&(c=!0));else if(H&&F.length==2)F[1]==="ATOM"?F[0]==="BEGIN"?z=!0:F[0]==="END"&&(z=!1):F[1]==="BOND"&&(F[0]==="BEGIN"?L=!0:F[0]==="END"&&(L=!1));else if(z||!H&&_>=x&&_0)continue;let oe=0;if(H){if(T=parseFloat(F[2]),R=parseFloat(F[3]),C=parseFloat(F[4]),E=F[1],I=parseInt(F[0]),Q.set(I,p),P=E+I,F.length>6){let ee=F.slice(6).find(le=>le.indexOf("CHG=")===0);ee&&(oe=parseInt(ee.substring(4)))}}else T=parseFloat(ne.substr(0,10)),R=parseFloat(ne.substr(10,10)),C=parseFloat(ne.substr(20,10)),E=ne.substr(31,3).trim(),P=E+(p-g+1);if(r){let ee=3*l;if(a[ee+0]=T,a[ee+1]=R,a[ee+2]=C,l+=1,c)continue}d.growIfFull(),d.atomTypeId[p]=u.add(P,E),d.x[p]=T,d.y[p]=R,d.z[p]=C,d.serial[p]=H?I:p,d.formalCharge[p]=oe,t.addAtom(y,"","","HET",1,!0),p+=1}else if(L||!H&&_>=A&&_0||r&&y>0)continue;H?(f.index=Q.get(parseInt(F[2])),m.index=Q.get(parseInt(F[3])),O=parseInt(F[1])):(f.index=parseInt(ne.substr(0,3))-1+g,m.index=parseInt(ne.substr(3,3))-1+g,O=parseInt(ne.substr(6,3))),e.bondStore.addBond(f,m,O)}else if(ne.substr(0,6)==="M CHG"){let oe=parseInt(ne.substr(6,3));for(let ee=0,le=10;ee"&&(h=ne.match(J6))?(D=h[1],N[D]=[]):D!==!1&&ne&&N[D].push(ne);++_}}})(0,Z.length,Z)}),t.finalize(),e.finalizeAtoms(),e.finalizeBonds(),sl(e),Le&&we.timeEnd("SdfParser._parse "+this.name)}_postProcess(){sl(this.structure)}};At.add("sdf",cd),At.add("sd",cd),At.add("mol",cd);function Hh(n,e,t){return parseInt(n.substr(e,t).trim())}var _0=class extends ts{get type(){return"prmtop"}_parse(){Le&&we.time("PrmtopParser._parse "+this.name);let e=this.structure,t=this.structureBuilder,i=e.atomMap,r=e.atomStore;r.addField("partialCharge",1,"float32"),r.addField("radius",1,"float32");let s=[],o={},a=["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"],l,c,u,d,f;a.forEach(w=>{o[w]=0});let m,p,_,y,g,b=new Uint8Array(0);this.streamer.eachChunkOfLines(function(w){(function(A,M,T){for(let R=A;R0)return void we.error("dcd format with fixed atoms unsupported, aborting");let p=s.NATOM,_=4*p;for(let y=0,g=s.NSET;y=1&&(t.timeOffset=(s.ISTART-1)*t.deltaTime),Le&&we.timeEnd("DcdParser._parse "+this.name)}});var bn={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function DI(n){switch(Number(n)){case bn.BYTE:return"byte";case bn.CHAR:return"char";case bn.SHORT:return"short";case bn.INT:return"int";case bn.FLOAT:return"float";case bn.DOUBLE:return"double";default:return"undefined"}}function hP(n){switch(Number(n)){case bn.BYTE:case bn.CHAR:return 1;case bn.SHORT:return 2;case bn.INT:case bn.FLOAT:return 4;case bn.DOUBLE:return 8;default:return-1}}function dP(n){switch(String(n)){case"byte":return bn.BYTE;case"char":return bn.CHAR;case"short":return bn.SHORT;case"int":return bn.INT;case"float":return bn.FLOAT;case"double":return bn.DOUBLE;default:return-1}}function Bm(n,e){if(n!==1){let t=new Array(n);for(let i=0;i6,"non valid type "+g);let b=s.readUint32(),h=s.readUint32();a===2&&(sr(h>0,"offsets larger than 4GB not supported"),h=s.readUint32()),_[0]===o&&(u+=b),c[f]={name:m,dimensions:_,attributes:y,type:DI(g),size:b,offset:h,record:_[0]===o}}}return{variables:c,recordStep:u}}(n,i.recordId,e);return t.variables=r.variables,t.recordDimension.recordStep=r.recordStep,t}function fP(n){let e,t=n.readUint32();if(t===Dc)return sr(n.readUint32()!==Dc,"wrong empty tag for list of attributes"),[];{sr(t!==i8,"wrong tag for list of attributes");let i=n.readUint32();e=new Array(i);for(let r=0;r6,"non valid type "+o);let a=n.readUint32(),l=uw(n,o,a);LI(n),e[r]={name:s,type:DI(o),value:l}}}return e}var v0=class{constructor(e){let t=new Gx(e);t.setBigEndian(),sr(t.readChars(3)!=="CDF","should start with CDF");let i=t.readByte();sr(i>2,"unknown version"),this.header=r8(t,i),this.buffer=t}get version(){return this.header.version===1?"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(e){return this.header.variables.findIndex(function(t){return t.name===e})!==-1}getDataVariable(e){let t;return t=typeof e=="string"?this.header.variables.find(function(i){return i.name===e}):e,sr(t===void 0,"variable not found"),this.buffer.seek(t.offset),t.record?function(i,r,s){let o=dP(r.type),a=r.size?r.size/hP(o):1,l=s.length,c=new Array(l),u=s.recordStep;for(let d=0;d=1&&(t.timeOffset=s[0]),s.length>=2&&(t.deltaTime=s[1]-s[0]),Le&&we.timeEnd("NctrajParser._parse "+this.name)}};At.add("nctraj",ud),At.add("ncdf",ud),At.add("nc",ud);At.add("trr",class extends iu{get type(){return"trr"}get isBinary(){return!0}_parse(){Le&&we.time("TrrParser._parse "+this.name);let n=ou(this.streamer.data),e=new DataView(n),t=this.frames,i=t.coordinates,r=t.boxes,s=t.times,o=0;for(;;){o+=8;let a=e.getInt32(o);o+=4,o+=a;let l=e.getInt32(o+8),c=e.getInt32(o+12),u=e.getInt32(o+16),d=e.getInt32(o+28),f=e.getInt32(o+32),m=e.getInt32(o+36),p=e.getInt32(o+40);o+=52;let _=l/9,y=3*p;if(_===8?s.push(e.getFloat64(o)):s.push(e.getFloat32(o)),o+=2*_,l){let g=new Float32Array(9);if(_===8)for(let b=0;b<9;++b)g[b]=10*e.getFloat64(o),o+=8;else for(let b=0;b<9;++b)g[b]=10*e.getFloat32(o),o+=4;r.push(g)}if(o+=c,o+=u,d){let g;if(_===8){g=new Float32Array(y);for(let b=0;b>8&65280|v>>24&255}g=new Float32Array(n,o,y);for(let h=0;h=n.byteLength)break}s.length>=1&&(t.timeOffset=s[0]),s.length>=2&&(t.deltaTime=s[1]-s[0]),Le&&we.timeEnd("TrrParser._parse "+this.name)}});var Sc=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]);function Cx(n){let e=1,t=0;for(;n>=e&&t<32;)t++,e<<=1;return t}var Gh=new Uint8Array(32);function s8(n,e){let t=1,i=0;Gh[0]=1;for(let s=0;s>=8;for(;a!==0;)Gh[o++]=255&a,a>>=8;t=o}let r=1;for(t--;Gh[t]>=r;)i++,r*=2;return i+8*t}function Ya(n,e,t,i){let r=(1<=8;)o=o<<8|e[a++],l|=o>>s<0&&(s>s&(1<8;)jr[a++]=Ya(n,e,8,o),i-=8;i>0&&(jr[a++]=Ya(n,e,i,o));for(let l=t-1;l>0;l--){let c=0;for(let u=a-1;u>=0;u--){c=c<<8|jr[u];let d=c/r[l]|0;jr[u]=d,c-=d*r[l]}s[l]=c}s[0]=jr[0]|jr[1]<<8|jr[2]<<16|jr[3]<<24}At.add("xtc",class extends iu{get type(){return"xtc"}get isBinary(){return!0}_parse(){Le&&we.time("XtcParser._parse "+this.name);let n=ou(this.streamer.data),e=new DataView(n),t=this.frames,i=t.coordinates,r=t.boxes,s=t.times,o=new Int32Array(6),a=new Int32Array(3),l=new Int32Array(3),c=new Uint32Array(3),u=new Float32Array(3),d=new Float32Array(3),f=0,m=new Int32Array(3),p=new Uint32Array(m.buffer);for(;;){let _,y=e.getInt32(f+4);f+=12;let g=3*y;s.push(e.getFloat32(f)),f+=4;let b=new Float32Array(9);for(let h=0;h<9;++h)b[h]=10*e.getFloat32(f),f+=4;if(r.push(b),y<=9){_=new Float32Array(y);for(let h=0;h16777215?(l[0]=Cx(a[0]),l[1]=Cx(a[1]),l[2]=Cx(a[2]),x=0):x=s8(3,a);let w=e.getInt32(f);f+=4;let A=w-1;A=9>A?9:A;let M=Sc[A]/2|0,T=Sc[w]/2|0;c[0]=c[1]=c[2]=Sc[w];let R=4*Math.ceil(e.getInt32(f)/4);f+=4;let C=1/S,P=0,E=0,I=new Uint8Array(n,f);for(u[0]=u[1]=u[2]=0;E0){u[0]=u[1]=u[2]=0;for(let D=0;D9?Sc[w-1]/2|0:0):O>0&&(M=T,T=Sc[w]/2|0),c[0]=c[1]=c[2]=Sc[w],c[0]===0||c[1]===0||c[2]===0)return void console.error("(xdrfile error) Undefined error.")}f+=R}for(let h=0;h=n.byteLength)break}s.length>=1&&(t.timeOffset=s[0]),s.length>=2&&(t.deltaTime=s[1]-s[0]),Le&&we.timeEnd("XtcParser._parse "+this.name)}});var al=class extends lr{constructor(e,t){let i=t||{};super(e,i),this.volume=new Hi(this.name,this.path),this.voxelSize=U(i.voxelSize,1)}get type(){return"volume"}get __objName(){return"volume"}_afterParse(){this.volume.setMatrix(this.getMatrix()),super._afterParse()}getMatrix(){return new qe}},o8=/\s+/,a8=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,Um=.529177210859,x0=class extends al{get type(){return"cube"}_parse(){Le&&we.time("CubeParser._parse "+this.name);let e=this.volume,t=this.streamer.peekLines(6),i={},r=Um*this.voxelSize;function s(u,d){var f=t[u].trim().split(o8)[d];return parseFloat(f)}i.atomCount=Math.abs(s(2,0)),i.originX=s(2,1)*Um,i.originY=s(2,2)*Um,i.originZ=s(2,3)*Um,i.NVX=s(3,0),i.NVY=s(4,0),i.NVZ=s(5,0),i.basisX=new W(s(3,1),s(3,2),s(3,3)).multiplyScalar(r),i.basisY=new W(s(4,1),s(4,2),s(4,3)).multiplyScalar(r),i.basisZ=new W(s(5,1),s(5,2),s(5,3)).multiplyScalar(r);let o=new Float32Array(i.NVX*i.NVY*i.NVZ),a=0,l=0,c=s(2,0)>0?0:1;this.streamer.eachChunkOfLines(function(u){(function(d,f,m){for(let p=d;p=i.atomCount+6+c){let y=_.match(a8);for(let g=0,b=y.length;g>8&255}t.xStart=o[0],t.yStart=o[1],t.zStart=o[2],t.xExtent=o[3],t.yExtent=o[4],t.zExtent=o[5],t.xRate=o[6],t.yRate=o[7],t.zRate=o[8];let w=1/o[17],A=w*this.voxelSize;t.xlen=o[9]*A,t.ylen=o[10]*A,t.zlen=o[11]*A,t.alpha=o[12]*w,t.beta=o[13]*w,t.gamma=o[14]*w,i=o[15]/100,r=o[16],t.gamma=o[14]*w}e.header=t,Le&&we.log(t,i,r);let c=new Float32Array(t.xExtent*t.yExtent*t.zExtent),u=512,d=Math.ceil(t.xExtent/8),f=Math.ceil(t.yExtent/8),m=Math.ceil(t.zExtent/8);for(var p=0;ps){let _=m[p].trim();if(_!==""){let y=_.split(zm);for(let g=0,b=y.length;g=s&&(_-s)%m!=0&&p=0?i-1:i+t/3)},parseNormalIndex:function(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},addVertex:function(e,t,i){var r=this.vertices,s=this.object.geometry.vertices;s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addVertexLine:function(e){var t=this.vertices,i=this.object.geometry.vertices;i.push(t[e+0]),i.push(t[e+1]),i.push(t[e+2])},addNormal:function(e,t,i){var r=this.normals,s=this.object.geometry.normals;s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addFace:function(e,t,i,r,s,o,a,l){var c,u=this.vertices.length,d=this.parseVertexIndex(e,u),f=this.parseVertexIndex(t,u),m=this.parseVertexIndex(i,u);if(r===void 0?this.addVertex(d,f,m):(c=this.parseVertexIndex(r,u),this.addVertex(d,f,c),this.addVertex(f,m,c)),s!==void 0){var p=this.normals.length;d=this.parseNormalIndex(s,p),f=s===o?d:this.parseNormalIndex(o,p),m=s===a?d:this.parseNormalIndex(a,p),r===void 0?this.addNormal(d,f,m):(c=this.parseNormalIndex(l,p),this.addNormal(d,f,c),this.addNormal(f,m,c))}},addLineGeometry:function(e){this.object.geometry.type="Line";for(var t=this.vertices.length,i=0,r=e.length;i0?h.setAttribute("normal",new gn(new Float32Array(b.normals),3)):h.computeVertexNormals(),g.push(h)}}return g}};At.add("obj",class extends fw{get type(){return"obj"}getLoader(){return new pw}});At.add("csv",class extends lr{constructor(n,e){let t=e||{};super(n,t),this.delimiter=U(t.delimiter,","),this.comment=U(t.comment,"#"),this.columnNames=U(t.columnNames,!1),this.table={name:this.name,path:this.path,columnNames:[],data:[]}}get type(){return"csv"}get __objName(){return"table"}_parse(){let n=this.table.data,e=new RegExp("\\s*"+this.delimiter+"\\s*"),t=0;this.streamer.eachChunkOfLines(i=>{let r=i.length;for(let s=0;s/g,""),{declaration:e(),root:t()};function e(){if(!r(/^<\?xml\s*/))return;let a={attributes:{}};for(;!s()&&!o("?>");){let l=i();if(!l)return a;a.attributes[l.name]=l.value}return r(/\?>\s*/),a}function t(){let a=r(f8);if(!a)return;let l={name:a[1],attributes:{},children:[]};for(;!(s()||o(">")||o("?>")||o("/>"));){let u=i();if(!u)return l;l.attributes[u.name]=u.value}if(r(/^\s*\/>\s*/))return l;let c;for(r(/\??>\s*/),l.content=function(){let u=r(p8);return u?u[1]:""}();c=t();)l.children.push(c);return r(/^<\/[\w-:.]+>\s*/),l}function i(){let a=r(m8);var l;if(a)return{name:a[1],value:(l=a[2],l.replace(d8,""))}}function r(a){let l=n.match(a);if(l)return n=n.slice(l[0].length),l}function s(){return n.length===0}function o(a){return n.indexOf(a)===0}}var M0=class extends lr{constructor(e,t){let i=t||{};super(e,i),this.useDomParser=U(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}get type(){return"xml"}get __objName(){return"xml"}get isXml(){return!0}__xmlParser(e){return g8(e)}__domParser(e){return new window.DOMParser().parseFromString(e,"text/xml")}_parse(){Le&&we.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),Le&&we.timeEnd("XmlParser._parse "+this.name)}};function Hn(n,e){let t=n.getNamedItem(e);return t!==null?t.value:""}function mP(n,e,t=!1){let i=Hn(n,"icode").trim(),r=Hn(n,"chain").trim(),s=Hn(n,"altcode"),o=Hn(n,"resnum");return i&&(o+="^"+i),r&&(o+=":"+r),e&&(o+="."+e),t&&s.trim()&&(o+="%"+s),o+="/"+(parseInt(Hn(n,"model"))-1),o}function y8(n){let e=Hn(n,"chain").trim(),t=`[${Hn(n,"rescode")}]${Hn(n,"resnum")}`;return e&&(t+=`:${e}`),t}function Ix(n,e,t){n[e]===void 0?n[e]=t:n[e]|=t}function Rx(n,e){return n!==null&&n.value===e}function _8(n,e,t){let i=0,r=e.getElementsByTagName("clash");for(let s=0,o=r.length;s0&&(i+=1),e.getElementsByTagName("bond-outlier").length>0&&(i+=1),e.getElementsByTagName("plane-outlier").length>0&&(i+=1),Rx(t.getNamedItem("rota"),"OUTLIER")&&(i+=1),Rx(t.getNamedItem("rama"),"OUTLIER")&&(i+=1),Rx(t.getNamedItem("RNApucker"),"outlier")&&(i+=1),i}At.add("xml",M0);var mw=class{constructor(e,t){this.name=e,this.path=t,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"}get type(){return"validation"}fromXml(e){Le&&we.time("Validation.fromXml");let t=this.rsrzDict,i=this.rsccDict,r=this.rciDict,s=this.clashDict,o=this.clashArray,a=this.geoDict,l=this.geoAtomDict,c=this.atomDict,u=e.getElementsByTagName("Entry");if(u.length===1){let p=u[0].getElementsByTagName("chemical_shift_list");if(p.length===1){let _=p[0].getElementsByTagName("random_coil_index");for(let y=0,g=_.length;y0&&(a[b]=h)}else{let h=y.getElementsByTagName("clash"),v=y.getElementsByTagName("mog-bond-outlier"),S=y.getElementsByTagName("mog-angle-outlier");if(v.length>0||S.length>0||h.length>0){let x={};l[b]=x;for(let w=0,A=h.length;w>>16&65535,o=0;t!==0;){t-=o=t>2e3?2e3:t;do s=s+(r=r+e[i++]|0)|0;while(--o);r%=65521,s%=65521}return r|s<<16}At.add("validation",class extends M0{constructor(n,e){super(n,e||{}),this.useDomParser=!0,this.validation=new mw(this.name,this.path)}get __objName(){return"validation"}get isXml(){return!0}_parse(){super._parse(),Le&&we.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),Le&&we.timeEnd("ValidationParser._parse "+this.name)}});var v8=function(){for(var n,e=[],t=0;t<256;t++){n=t;for(var i=0;i<8;i++)n=1&n?3988292384^n>>>1:n>>>1;e[t]=n}return e}();function ms(n,e,t,i){var r=v8,s=i+t;n^=-1;for(var o=i;o>>8^r[255&(n^e[o])];return~n}var Gm=30,x8=12;function b8(n,e){var t,i,r,s,o,a,l,c,u,d,f,m,p,_,y,g,b,h,v,S,x,w,A,M,T;t=n.state,i=n.next_in,M=n.input,r=i+(n.avail_in-5),s=n.next_out,T=n.output,o=s-(e-n.avail_out),a=s+(n.avail_out-257),l=t.dmax,c=t.wsize,u=t.whave,d=t.wnext,f=t.window,m=t.hold,p=t.bits,_=t.lencode,y=t.distcode,g=(1<>>=v=h>>>24,p-=v,(v=h>>>16&255)===0)T[s++]=65535&h;else{if(!(16&v)){if(64&v){if(32&v){t.mode=x8;break e}n.msg="invalid literal/length code",t.mode=Gm;break e}h=_[(65535&h)+(m&(1<>>=v,p-=v),p<15&&(m+=M[i++]<>>=v=h>>>24,p-=v,16&(v=h>>>16&255)){if(x=65535&h,p<(v&=15)&&(m+=M[i++]<l){n.msg="invalid distance too far back",t.mode=Gm;break e}if(m>>>=v,p-=v,x>(v=s-o)){if((v=x-v)>u&&t.sane){n.msg="invalid distance too far back",t.mode=Gm;break e}if(w=0,A=f,d===0){if(w+=c-v,v2;)T[s++]=A[w++],T[s++]=A[w++],T[s++]=A[w++],S-=3;S&&(T[s++]=A[w++],S>1&&(T[s++]=A[w++]))}else{w=s-x;do T[s++]=T[w++],T[s++]=T[w++],T[s++]=T[w++],S-=3;while(S>2);S&&(T[s++]=T[w++],S>1&&(T[s++]=T[w++]))}break}if(64&v){n.msg="invalid distance code",t.mode=Gm;break e}h=y[(65535&h)+(m&(1<>3,m&=(1<<(p-=S<<3))-1,n.next_in=i,n.next_out=s,n.avail_in=i=1&&E[S]===0;S--);if(x>S&&(x=S),S===0)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(v=1;v0&&(n===_P||S!==1))return-1;for(I[1]=0,b=1;bgP||n===vP&&T>yP)return 1;for(;;){p=b-A,o[h]m?(_=O[D+o[h]],y=C[P+o[h]]):(_=96,y=0),l=1<>A)+(c-=l)]=p<<24|_<<16|y;while(c!==0);for(l=1<>=1;if(l!==0?(R&=l-1,R+=l):R=0,h++,--E[b]==0){if(b===S)break;b=e[t+o[h]]}if(b>x&&(R&d)!==u){for(A===0&&(A=x),f+=v,M=1<<(w=b-A);w+AgP||n===vP&&T>yP)return 1;r[u=R&d]=x<<24|w<<16|f-s}}return R!==0&&(r[f+R]=b-A<<24|64<<16),a.bits=x,0}var BI=1,UI=2,ru=0,xs=-2,zI=1,Qs=12,vn=30,C8=852,E8=592;function xP(n){return(n>>>24&255)+(n>>>8&65280)+((65280&n)<<8)+((255&n)<<24)}function T8(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function P8(n){var e;return n&&n.state?((e=n.state).wsize=0,e.whave=0,e.wnext=0,function(t){var i;return t&&t.state?(i=t.state,t.total_in=t.total_out=i.total=0,t.msg="",i.wrap&&(t.adler=1&i.wrap),i.mode=zI,i.last=0,i.havedict=0,i.dmax=32768,i.head=null,i.hold=0,i.bits=0,i.lencode=i.lendyn=new Int32Array(C8),i.distcode=i.distdyn=new Int32Array(E8),i.sane=1,i.back=-1,ru):xs}(n)):xs}function I8(n,e){var t,i;return n?(i=new T8,n.state=i,i.window=null,t=function(r,s){var o,a;return r&&r.state?(a=r.state,s<0?(o=0,s=-s):(o=1+(s>>4),s<48&&(s&=15)),s&&(s<8||s>15)?xs:(a.window!==null&&a.wbits!==s&&(a.window=null),a.wrap=o,a.wbits=s,P8(r))):xs}(n,e),t!==ru&&(n.state=null),t):xs}var Lx,Dx,bP=!0;function R8(n){if(bP){var e;for(Lx=new Int32Array(512),Dx=new Int32Array(32),e=0;e<144;)n.lens[e++]=8;for(;e<256;)n.lens[e++]=9;for(;e<280;)n.lens[e++]=7;for(;e<288;)n.lens[e++]=8;for(dd(BI,n.lens,0,288,Lx,0,n.work,{bits:9}),e=0;e<32;)n.lens[e++]=5;dd(UI,n.lens,0,32,Dx,0,n.work,{bits:5}),bP=!1}n.lencode=Lx,n.lenbits=9,n.distcode=Dx,n.distbits=5}function VI(n,e,t,i){var r,s=n.state;return s.window===null&&(s.wsize=1<=s.wsize?(Hc(s.window,e,t-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):((r=s.wsize-s.wnext)>i&&(r=i),Hc(s.window,e,t-i,r,s.wnext),(i-=r)?(Hc(s.window,e,t-i,i,0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,t.check=ms(t.check,R,2,0),c=0,u=0,t.mode=2;break}if(t.flags=0,t.head&&(t.head.done=!1),!(1&t.wrap)||(((255&c)<<8)+(c>>8))%31){n.msg="incorrect header check",t.mode=vn;break}if((15&c)!=8){n.msg="unknown compression method",t.mode=vn;break}if(u-=4,x=8+(15&(c>>>=4)),t.wbits===0)t.wbits=x;else if(x>t.wbits){n.msg="invalid window size",t.mode=vn;break}t.dmax=1<>8&1),512&t.flags&&(R[0]=255&c,R[1]=c>>>8&255,t.check=ms(t.check,R,2,0)),c=0,u=0,t.mode=3;case 3:for(;u<32;){if(a===0)break e;a--,c+=i[s++]<>>8&255,R[2]=c>>>16&255,R[3]=c>>>24&255,t.check=ms(t.check,R,4,0)),c=0,u=0,t.mode=4;case 4:for(;u<16;){if(a===0)break e;a--,c+=i[s++]<>8),512&t.flags&&(R[0]=255&c,R[1]=c>>>8&255,t.check=ms(t.check,R,2,0)),c=0,u=0,t.mode=5;case 5:if(1024&t.flags){for(;u<16;){if(a===0)break e;a--,c+=i[s++]<>>8&255,t.check=ms(t.check,R,2,0)),c=0,u=0}else t.head&&(t.head.extra=null);t.mode=6;case 6:if(1024&t.flags&&((m=t.length)>a&&(m=a),m&&(t.head&&(x=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Array(t.head.extra_len)),Hc(t.head.extra,i,s,m,x)),512&t.flags&&(t.check=ms(t.check,i,m,s)),a-=m,s+=m,t.length-=m),t.length))break e;t.length=0,t.mode=7;case 7:if(2048&t.flags){if(a===0)break e;m=0;do x=i[s+m++],t.head&&x&&t.length<65536&&(t.head.name+=String.fromCharCode(x));while(x&&m>9&1,t.head.done=!0),n.adler=t.check=0,t.mode=Qs;break;case 10:for(;u<32;){if(a===0)break e;a--,c+=i[s++]<>>=7&u,u-=7&u,t.mode=27;break}for(;u<3;){if(a===0)break e;a--,c+=i[s++]<>>=1)){case 0:t.mode=14;break;case 1:if(R8(t),t.mode=20,e===6){c>>>=2,u-=2;break e}break;case 2:t.mode=17;break;case 3:n.msg="invalid block type",t.mode=vn}c>>>=2,u-=2;break;case 14:for(c>>>=7&u,u-=7&u;u<32;){if(a===0)break e;a--,c+=i[s++]<>>16^65535)){n.msg="invalid stored block lengths",t.mode=vn;break}if(t.length=65535&c,c=0,u=0,t.mode=15,e===6)break e;case 15:t.mode=16;case 16:if(m=t.length){if(m>a&&(m=a),m>l&&(m=l),m===0)break e;Hc(r,i,s,m,o),a-=m,s+=m,l-=m,o+=m,t.length-=m;break}t.mode=Qs;break;case 17:for(;u<14;){if(a===0)break e;a--,c+=i[s++]<>>=5,u-=5,t.ndist=1+(31&c),c>>>=5,u-=5,t.ncode=4+(15&c),c>>>=4,u-=4,t.nlen>286||t.ndist>30){n.msg="too many length or distance symbols",t.mode=vn;break}t.have=0,t.mode=18;case 18:for(;t.have>>=3,u-=3}for(;t.have<19;)t.lens[C[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,A={bits:t.lenbits},w=dd(0,t.lens,0,19,t.lencode,0,t.work,A),t.lenbits=A.bits,w){n.msg="invalid code lengths set",t.mode=vn;break}t.have=0,t.mode=19;case 19:for(;t.have>>16&255,b=65535&T,!((y=T>>>24)<=u);){if(a===0)break e;a--,c+=i[s++]<>>=y,u-=y,t.lens[t.have++]=b;else{if(b===16){for(M=y+2;u>>=y,u-=y,t.have===0){n.msg="invalid bit length repeat",t.mode=vn;break}x=t.lens[t.have-1],m=3+(3&c),c>>>=2,u-=2}else if(b===17){for(M=y+3;u>>=y)),c>>>=3,u-=3}else{for(M=y+7;u>>=y)),c>>>=7,u-=7}if(t.have+m>t.nlen+t.ndist){n.msg="invalid bit length repeat",t.mode=vn;break}for(;m--;)t.lens[t.have++]=x}}if(t.mode===vn)break;if(t.lens[256]===0){n.msg="invalid code -- missing end-of-block",t.mode=vn;break}if(t.lenbits=9,A={bits:t.lenbits},w=dd(BI,t.lens,0,t.nlen,t.lencode,0,t.work,A),t.lenbits=A.bits,w){n.msg="invalid literal/lengths set",t.mode=vn;break}if(t.distbits=6,t.distcode=t.distdyn,A={bits:t.distbits},w=dd(UI,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,A),t.distbits=A.bits,w){n.msg="invalid distances set",t.mode=vn;break}if(t.mode=20,e===6)break e;case 20:t.mode=21;case 21:if(a>=6&&l>=258){n.next_out=o,n.avail_out=l,n.next_in=s,n.avail_in=a,t.hold=c,t.bits=u,b8(n,f),o=n.next_out,r=n.output,l=n.avail_out,s=n.next_in,i=n.input,a=n.avail_in,c=t.hold,u=t.bits,t.mode===Qs&&(t.back=-1);break}for(t.back=0;g=(T=t.lencode[c&(1<>>16&255,b=65535&T,!((y=T>>>24)<=u);){if(a===0)break e;a--,c+=i[s++]<>h)])>>>16&255,b=65535&T,!(h+(y=T>>>24)<=u);){if(a===0)break e;a--,c+=i[s++]<>>=h,u-=h,t.back+=h}if(c>>>=y,u-=y,t.back+=y,t.length=b,g===0){t.mode=26;break}if(32&g){t.back=-1,t.mode=Qs;break}if(64&g){n.msg="invalid literal/length code",t.mode=vn;break}t.extra=15&g,t.mode=22;case 22:if(t.extra){for(M=t.extra;u>>=t.extra,u-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=23;case 23:for(;g=(T=t.distcode[c&(1<>>16&255,b=65535&T,!((y=T>>>24)<=u);){if(a===0)break e;a--,c+=i[s++]<>h)])>>>16&255,b=65535&T,!(h+(y=T>>>24)<=u);){if(a===0)break e;a--,c+=i[s++]<>>=h,u-=h,t.back+=h}if(c>>>=y,u-=y,t.back+=y,64&g){n.msg="invalid distance code",t.mode=vn;break}t.offset=b,t.extra=15&g,t.mode=24;case 24:if(t.extra){for(M=t.extra;u>>=t.extra,u-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){n.msg="invalid distance too far back",t.mode=vn;break}t.mode=25;case 25:if(l===0)break e;if(m=f-l,t.offset>m){if((m=t.offset-m)>t.whave&&t.sane){n.msg="invalid distance too far back",t.mode=vn;break}m>t.wnext?(m-=t.wnext,p=t.wsize-m):p=t.wnext-m,m>t.length&&(m=t.length),_=t.window}else _=r,p=o-t.offset,m=t.length;m>l&&(m=l),l-=m,t.length-=m;do r[o++]=_[p++];while(--m);t.length===0&&(t.mode=21);break;case 26:if(l===0)break e;r[o++]=t.length,l--,t.mode=21;break;case 27:if(t.wrap){for(;u<32;){if(a===0)break e;a--,c|=i[s++]<=252?6:eo>=248?5:eo>=240?4:eo>=224?3:eo>=192?2:1;var su,eo;function D8(n){var e,t,i,r,s,o=n.length,a=0;for(r=0;r>>6,e[s++]=128|63&t):t<65536?(e[s++]=224|t>>>12,e[s++]=128|t>>>6&63,e[s++]=128|63&t):(e[s++]=240|t>>>18,e[s++]=128|t>>>12&63,e[s++]=128|t>>>6&63,e[s++]=128|63&t);return e}function N8(n,e){var t,i,r,s,o=e||n.length,a=new Array(2*o);for(i=0,t=0;t4)a[i++]=65533,t+=s-1;else{for(r&=s===2?31:s===3?15:7;s>1&&t1?a[i++]=65533:r<65536?a[i++]=r:(r-=65536,a[i++]=55296|r>>10&1023,a[i++]=56320|1023&r)}return function(l,c){if(c<65537&&(l.subarray&&GI||!l.subarray&&HI))return String.fromCharCode.apply(null,OI(l,c));for(var u="",d=0;dn.length&&(e=n.length),t=e-1;t>=0&&(192&n[t])==128;)t--;return t<0||t===0?e:t+su[n[t]]>e?t:e}su[254]=su[254]=1;var Tc=0,O8={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function B8(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function U8(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var wP=Object.prototype.toString;function Nc(n){if(!(this instanceof Nc))return new Nc(n);this.options=function(o){for(var a=Array.prototype.slice.call(arguments,1);a.length;){var l=a.shift();if(l){if(typeof l!="object")throw new TypeError(l+"must be non-object");for(var c in l)l.hasOwnProperty(c)&&(o[c]=l[c])}}return o}({chunkSize:16384,windowBits:0,to:""},n||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||n&&n.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new B8,this.strm.avail_out=0;var t,i,r,s=I8(this.strm,e.windowBits);if(s!==Tc)throw new Error(O8[s]);this.header=new U8,t=this.strm,i=this.header,t&&t.state&&2&(r=t.state).wrap&&(r.head=i,i.done=!1)}Nc.prototype.push=function(n,e){var t,i,r,s,o,a,l=this.strm,c=this.options.chunkSize,u=this.options.dictionary,d=!1;if(this.ended)return!1;i=e===~~e?e:e===!0?4:0,typeof n=="string"?l.input=function(f){for(var m=new Uint8Array(f.length),p=0,_=m.length;p<_;p++)m[p]=f.charCodeAt(p);return m}(n):wP.call(n)==="[object ArrayBuffer]"?l.input=new Uint8Array(n):l.input=n,l.next_in=0,l.avail_in=l.input.length;do{if(l.avail_out===0&&(l.output=new Uint8Array(c),l.next_out=0,l.avail_out=c),(t=k8(l,0))===2&&u&&(a=typeof u=="string"?D8(u):wP.call(u)==="[object ArrayBuffer]"?new Uint8Array(u):u,t=L8(this.strm,a)),t===-5&&d===!0&&(t=Tc,d=!1),t!==1&&t!==Tc)return this.onEnd(t),this.ended=!0,!1;l.next_out&&(l.avail_out!==0&&t!==1&&(l.avail_in!==0||i!==4&&i!==2)||(this.options.to==="string"?(r=F8(l.output,l.next_out),s=l.next_out-r,o=N8(l.output,r),l.next_out=s,l.avail_out=c-s,s&&Hc(l.output,l.output,r,s,0),this.onData(o)):this.onData(OI(l.output,l.next_out)))),l.avail_in===0&&l.avail_out===0&&(d=!0)}while((l.avail_in>0||l.avail_out===0)&&t!==1);return t===1&&(i=4),i===4?(t=function(f){if(!f||!f.state)return xs;var m=f.state;return m.window&&(m.window=null),f.state=null,ru}(this.strm),this.onEnd(t),this.ended=!0,t===Tc):i!==2||(this.onEnd(Tc),l.avail_out=0,!0)},Nc.prototype.onData=function(n){this.chunks.push(n)},Nc.prototype.onEnd=function(n){n===Tc&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=function(e){var t,i,r,s,o,a;for(r=0,t=0,i=e.length;t-1?e.name:e.name.substring(0,4);return!["pdb","cif"].includes(e.ext)||e.compressed!==!1&&e.compressed!=="gz"?(e.ext==="mmtf"&&(we.warn(`MMTF files distribution has been discontinued by RCSB PDB as of July 2024. + Defaulting to bcif format instead. See https://www.rcsb.org/news/65a1af31c76ca3abcc925d0c for the deprecation notice`),e.base.endsWith(".bb")&&we.warn("Backbone only files are not available from RCSB PDB anymore."),e.ext=""),e.ext?we.warn("unsupported ext",e.ext):we.warn(`mmCif files available from RCSB PDB lack connectivity information. + Consider using PDBe as the data provider for using "Updated mmCif files" that contain residues connectivity records.`),SP+"//models.rcsb.org/"+t+".bcif.gz"):SP+"//files.rcsb.org/download/"+e.path}getExt(n){return Gi(n).ext||"bcif"}});var $h="//www.ebi.ac.uk/pdbe/entry-files/download/";Jo.add("pdbe",new class extends ll{getUrl(n){let e=Gi(n),t,i=e.name.indexOf("_")>-1?e.name:e.name.substring(0,4);switch(e.ext){case"cif":t=$h+i+"_updated.cif";break;case"pdb":case"ent":i.startsWith("pdb")||(i="pdb"+i),t=$h+i+".ent";break;case"bcif":t=$h+e.path;break;case"":t=$h+i+".bcif";break;default:we.warn("unsupported ext",e.ext),t=$h+i+".bcif"}return"https://"+t}getExt(n){return Gi(n).ext||"bcif"}});var AP="//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/",MP="/SDF?record_type=3d";Jo.add("pubchem",new class extends ll{getUrl(n){let e=Gi(n),t=e.name,i;return e.ext&&e.ext!=="sdf"&&we.warn("unsupported ext",e.ext),i=AP+t+MP,function(){let r=window.location.protocol;return r.match(/http(s)?:/gi)===null?"http:":r}()+i}getExt(n){return Gi(n).ext||"sdf"}});var fd=class extends ll{getUrl(e){return e}getExt(e){return Gi(e).ext}};Jo.add("ftp",new fd),Jo.add("http",new fd),Jo.add("https",new fd);var CP="//alphafold.ebi.ac.uk/files/AF-",EP="-F1-model_v4.pdb";Jo.add("alphafold",new class extends ll{getUrl(n){let e=Gi(n),t=e.name,i;return e.ext&&e.ext!=="pdb"&&we.warn("unsupported AF ext",e.ext),i=CP+t+EP,"https://"+i}getExt(n){return Gi(n).ext||"pdb"}});function TP(n,e){return{type:"integer",max:n,min:e}}function Mc(n,e,t){return{type:"number",precision:n,max:e,min:t}}function Cc(n,e,t){return{type:"range",step:n,max:e,min:t}}function Wh(...n){return{type:"select",options:n.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:t}),{})}}var bV={backgroundColor:{type:"color"},quality:Wh("auto","low","medium","high"),sampleLevel:Cc(1,5,-1),impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:Mc(1,10,0),zoomSpeed:Mc(1,10,0),panSpeed:Mc(1,10,0),clipNear:Cc(1,100,0),clipFar:Cc(1,100,0),clipDist:TP(200,0),clipMode:Wh("scene","camera"),clipScale:Wh("relative","absolute"),fogNear:Cc(1,100,0),fogFar:Cc(1,100,0),cameraType:Wh("perspective","orthographic","stereo"),cameraEyeSep:Mc(3,1,.01),cameraFov:Cc(1,120,15),lightColor:{type:"color"},lightIntensity:Mc(2,10,0),ambientColor:{type:"color"},ambientIntensity:Mc(2,10,0),hoverTimeout:TP(1e4,-1),tooltip:{type:"boolean"},mousePreset:Wh(...Object.keys(oI))};var Tn=Dn(fl(),1),hi=Dn(ur(),1);function X8(){return document?.getElementsByClassName("dark").length?"black":document?.getElementsByClassName("light").length?"white":window?.matchMedia("(prefers-color-scheme: dark)").matches?"black":"white"}var XI=(0,Tn.createContext)(void 0);function q8(){let n=(0,Tn.useContext)(XI);if(!n)throw new Error("useStage must be used within a StageProvider");return n}function Y8(n){return n!==void 0&&n.atomStore.x!==void 0}function Z8(n){return n.structure!==void 0}function K8(n,e){let t=n.getComponentsByName(e).first;return t?Z8(t)&&Y8(t.structure):!1}var J8=(0,Tn.createContext)(void 0);var Q8=new Set(["angle","axes","backbone","ball+stick","base","cartoon","contact","dihedral","dihedral-histogram","distance","dot","helixorient","hyperball","label","licorice","line","molecularsurface","point","ribbon","rocket","rope","slice","spacefill","surface","trace","tube","unitcell","validation"]);function eV({structure:n,chain:e="",opacity:t=1,children:i,defaultRepresentation:r=!0}){let s=q8(),[o,a]=(0,Tn.useState)(void 0);return(0,Tn.useEffect)(()=>{async function l(){let c=typeof n=="string"?n:n.name;s.getComponentsByName(c).dispose();let u=await s.loadFile(n,{defaultRepresentation:r});u&&(s.autoView(),a(u))}return l(),()=>{let c=typeof n=="string"?n:n.name;s.getComponentsByName(c).dispose()}},[s,n,r]),(0,Tn.useEffect)(()=>{o&&(s.eachRepresentation(l=>{l.parent.name===o.name&&Q8.has(l.name)&&l.setParameters({opacity:t})}),s.viewer.requestRender())},[t,o,s]),(0,Tn.useEffect)(()=>{if(o)return e===""?o.setSelection(""):o.setSelection(`:${e}`),s.autoView(),()=>{!o||!K8(s,o.name)||!s.getComponentsByObject(o.structure).first||o.setSelection("")}},[s,e,o]),(0,hi.jsx)(hi.Fragment,{children:o&&(0,hi.jsx)(J8.Provider,{value:o,children:i})})}function tV({onMouseLeave:n=()=>{},onPick:e,onHover:t,children:i}){let[r,s]=(0,Tn.useState)(),o=(0,Tn.useCallback)(c=>{if(c){let u=X8(),d=new Dg(c,{backgroundColor:u});s(d)}},[]);(0,Tn.useEffect)(()=>()=>{},[r]);let a=(0,Tn.useCallback)(c=>{e&&c?.atom?.resno&&c?.atom?.chainname&&e(c.atom.chainname,c.atom.resno,c.component.name,c.atom.resname)},[e]);(0,Tn.useEffect)(()=>{if(!(!a||!r))return r.signals.clicked.add(a),()=>{a&&r.signals.clicked.remove(a)}},[r,a]);let l=(0,Tn.useCallback)(c=>{t&&c?.atom?.resno&&c?.atom?.chainname&&t(c.atom.chainname,c.atom.resno,c.component.name,c.atom.resname)},[t]);return(0,Tn.useEffect)(()=>{if(!(!l||!r))return r.signals.hovered.add(l),()=>{l&&r.signals.hovered.remove(l)}},[r,l]),(0,hi.jsxs)("div",{className:"relative h-full w-full overflow-hidden",onMouseLeave:n,children:[(0,hi.jsx)("div",{ref:o,className:"h-full w-full "}),r&&(0,hi.jsxs)(hi.Fragment,{children:[(0,hi.jsx)("div",{className:"absolute top-2 right-4 z-10",children:(0,hi.jsx)("span",{title:"Center all",className:"h-5 w-5 cursor-pointer",onClick:c=>{c.preventDefault(),r.autoView()},children:"\u25CE"})}),(0,hi.jsx)(XI.Provider,{value:r,children:i})]})]})}var Nw=class extends Tn.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error(e,t)}render(){return this.state.hasError?(0,hi.jsx)("h1",{children:"Something went wrong. See DevTools console"}):this.props.children}};function qI({structure:n,chain:e="",defaultRepresentation:t=!0,opacity:i=1}){return(0,hi.jsx)(Nw,{children:(0,hi.jsx)(tV,{children:(0,hi.jsx)(eV,{structure:n,chain:e,defaultRepresentation:t,opacity:i})})})}var co=Dn(ur(),1);function ZI({url:n,children:e,labelTrigger:t="Open",labelClose:i="X",classNameTrigger:r="",classNameClose:s="",classNameTitle:o="",classNameDialog:a=""}){let[l,c]=(0,YI.useState)(!1),u=n.split("/").pop(),d=null;return l&&(d=e??(0,co.jsx)(qI,{structure:n})),(0,co.jsxs)("div",{children:[(0,co.jsx)("button",{className:Mn("inline-flex items-center justify-center whitespace-nowrap rounded-md font-medium text-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50","h-9 px-4 py-2","bg-gray-300 text-black shadow-sm hover:bg-gray-300/80",r),onClick:()=>c(!0),children:t}),(0,co.jsxs)("dialog",{open:l,className:Mn("-translate-x-1/2 -translate-y-1/2 fixed top-1/2 left-1/2 z-10 h-3/4 w-3/4 transform drop-shadow-xl",a),children:[(0,co.jsxs)("div",{className:"flex w-full flex-row items-center justify-between",children:[(0,co.jsx)("a",{className:Mn("m-2 hover:underline",o),href:n,download:u,children:u}),(0,co.jsx)("button",{className:Mn("inline-flex items-center justify-center whitespace-nowrap rounded-md font-medium text-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50","h-9 px-4 py-2","hover:bg-gray-300 hover:text-black",s),onClick:()=>c(!1),children:i})]}),d]})]})}var Ut=Dn(ur(),1),eR={type:"number",sortable:!0};function KI({header:n,sortState:e,setSortState:t,orientation:i,className:r=""}){let s=i==="top"?"col":"row",o={...eR,...n},a="",l={top:{asc:"\u2193",desc:"\u2191",both:"\u2195"},left:{asc:"\u2192",desc:"\u2190",both:"\u21C4"}},c={onClick:()=>{}};return n.key===e.key?(a=l[i][e.direction],c.onClick=()=>t({key:n.key,direction:e.direction==="asc"?"desc":"asc"})):o.sortable&&(a=l[i].both,c.onClick=()=>t({key:n.key,direction:n.sorted||"asc"})),(0,Ut.jsxs)("th",{scope:s,className:Mn({"group cursor-pointer":o.sortable},r),...c,children:[(0,Ut.jsx)("span",{children:o.label}),(0,Ut.jsx)("span",{children:"\xA0"}),(0,Ut.jsx)("span",{className:Mn({"opacity-25 group-hover:opacity-100":o.sortable&&n.key!==e.key}),children:a})]})}function JI({data:n,header:e}){let t=n[e.key],i={...eR,...e};if(t==null)return(0,Ut.jsx)(Ut.Fragment,{children:"NA"});if(i.type==="stats"&&typeof t=="object")return t.std===0?(0,Ut.jsx)(Ut.Fragment,{children:t.mean}):(0,Ut.jsxs)(Ut.Fragment,{children:[t.mean," \xB1 ",t.std]});if(i.type==="structure"&&typeof t=="string"&&t!==""){let r=t,s=r.split("/").pop();return(0,Ut.jsxs)("div",{children:[(0,Ut.jsx)("a",{href:t,download:s,className:"hover:underline",children:"\u2193\xA0Download"}),(0,Ut.jsx)(ZI,{url:r,labelTrigger:"\u{1F441}\xA0View",classNameTrigger:"text-inherit bg-inherit inline-block rounded-none h-auto"})]})}return(0,Ut.jsx)(Ut.Fragment,{children:t})}var QI=(n,e)=>n.type==="stats"&&e!=null&&typeof e=="object"?e.mean:e;function nV(n,e,t){let i=t.find(r=>r.key===e.key);return i===void 0?n:n.toSorted((r,s)=>{let o=QI(i,r[e.key]),a=QI(i,s[e.key]);return oa?e.direction==="asc"?1:-1:0})}function Fw(n,e){let t=n[e];return t==null?"NA":typeof t=="object"?t.mean.toString():t.toString()}function N0({orientation:n="top",headers:e,data:t,className:i="",tableClassName:r="",theadClassName:s="",tbodyClassName:o="",trClassName:a="",thClassName:l="",tdClassName:c=""}){let u=e.find(_=>_.sorted!==void 0),d=(u??e[0]).key,[f,m]=(0,D0.useState)(()=>u&&u.sorted!==void 0?{key:u.key,direction:u.sorted}:{key:"",direction:"asc"}),p=(0,D0.useMemo)(()=>nV(t,f,e),[t,f,e]);return n==="top"?(0,Ut.jsx)("div",{className:Mn("",i),children:(0,Ut.jsxs)("table",{className:Mn("caption-bottom text-sm",r),children:[(0,Ut.jsx)("thead",{className:Mn("&_tr]:border-b",s),children:(0,Ut.jsx)("tr",{className:Mn("border-b transition-colors hover:bg-muted/50",a),children:e.map(_=>(0,Ut.jsx)(KI,{header:_,sortState:f,setSortState:m,orientation:n,className:Mn("h-12 px-4 text-left align-middle font-medium text-muted-foreground",l)},_.key))})}),(0,Ut.jsx)("tbody",{className:Mn("[&_tr:last-child]:border-0",o),children:p.map(_=>(0,Ut.jsx)("tr",{className:Mn("border-b transition-colors hover:bg-muted/50",a),children:e.map(y=>(0,Ut.jsx)("td",{className:Mn("p-4 align-middle",c),children:(0,Ut.jsx)(JI,{data:_,header:y})},`${Fw(_,d)}-${y.key}`))},Fw(_,d)))})]})}):(0,Ut.jsx)("div",{className:Mn("",i),children:(0,Ut.jsxs)("table",{className:Mn("caption-bottom text-sm",r),children:[(0,Ut.jsx)("thead",{className:Mn("",s)}),(0,Ut.jsx)("tbody",{className:Mn("",o),children:e.map(_=>(0,Ut.jsxs)("tr",{className:Mn("transition-colors",a),children:[(0,Ut.jsx)(KI,{header:_,sortState:f,setSortState:m,orientation:n,className:Mn("h-12 border-r px-4 text-left align-middle font-medium text-muted-foreground",l)},_.key),p.map((y,g)=>(0,Ut.jsx)("td",{className:Mn("p-4 align-middle",{"border-r":g + * Released under the MIT license + * Author: Miller Medeiros + * Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM) + *) + +react/cjs/react-jsx-runtime.production.min.js: + (** + * @license React + * react-jsx-runtime.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +three/build/three.module.js: + (** + * @license + * Copyright 2010-2023 Three.js Authors + * SPDX-License-Identifier: MIT + *) + +ngl/dist/ngl.esm.js: + (** + * Kdtree + * @class + * @author Alexander Rose , 2016 + * @author Roman Bolzern , 2013 + * @author I4DS http://www.fhnw.ch/i4ds, 2013 + * @license MIT License + * @description + * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place + * provides fast nearest neighbour search + * + * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs + * + * Further information (including mathematical properties) + * http://en.wikipedia.org/wiki/Binary_tree + * http://en.wikipedia.org/wiki/K-d_tree + * + * @example + * points: [x, y, z, x, y, z, x, y, z, ...] + * metric: function(a, b){ + * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2); + * } + * + * @param {Float32Array} points - points + * @param {Function} metric - metric + *) +*/ diff --git a/src/haddock/libs/libplots.py b/src/haddock/libs/libplots.py index 2fae359452..ed6afb52ff 100644 --- a/src/haddock/libs/libplots.py +++ b/src/haddock/libs/libplots.py @@ -1,6 +1,7 @@ """Plotting functionalities.""" import json +import shutil import numpy as np import pandas as pd @@ -24,6 +25,7 @@ Optional, Union, ) +from haddock.libs.assets import haddock_ui_path SCATTER_PAIRS = [ @@ -984,7 +986,9 @@ def _css_styles_for_report(offline: bool) -> str: """ css_link = "https://cdn.jsdelivr.net/npm/@i-vresse/haddock3-ui@~0.3.0/dist/index.css" if offline: - # TODO copy the css file to the report directory + # copy the css file to the report directory + src = haddock_ui_path / 'index.css' + shutil.copyfile(str(src), "../data/ui/index.css") css_link = "../../data/ui/index.css" table_css = f' ' return f"{table_css}" @@ -1151,7 +1155,9 @@ def _generate_html_body(figures: list[Figure], offline: bool = False) -> str: is_unclustered = 'cluster_rank' not in figure bundle_url = "https://cdn.jsdelivr.net/npm/@i-vresse/haddock3-ui@~0.3.0/dist/report.bundle.js" if offline: - # TODO copy the bundle to the run_dir folder + # copy the bundle to the run_dir folder + src = haddock_ui_path / 'report.bundle.js' + shutil.copyfile(str(src), "../data/ui/report.bundle.js") bundle_url = "../../data/ui/report.bundle.js" if is_unclustered: inner_html = _generate_unclustered_table_html(table_id, figure, bundle_url) @@ -1203,6 +1209,8 @@ def report_generator(boxes, scatters, tables, step, offline): # Combine boxes" figures.append(report_plots_handler(boxes)) + if offline: + Path('../data/ui').mkdir(parents=True, exist_ok=True) # Write everything to a html file html_report = _generate_html_report(step, figures, offline) with open("report.html", "w", encoding="utf-8") as report: From 528814247ba0cf30655d9cb3b399da74a6d36cae Mon Sep 17 00:00:00 2001 From: sverhoeven Date: Fri, 20 Sep 2024 13:55:38 +0200 Subject: [PATCH 6/9] Use structure table for unclustered data --- src/haddock/libs/libplots.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/haddock/libs/libplots.py b/src/haddock/libs/libplots.py index ed6afb52ff..8752da09de 100644 --- a/src/haddock/libs/libplots.py +++ b/src/haddock/libs/libplots.py @@ -1072,11 +1072,11 @@ def _generate_unclustered_table_html( }} """ # noqa : E501 From d24a510d70727488465ce28f01a5bef3a649b92c Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Fri, 20 Sep 2024 15:50:23 +0200 Subject: [PATCH 7/9] Fix plotly menubar See https://github.com/plotly/plotly.js/issues/5828 --- src/haddock/libs/libplots.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/haddock/libs/libplots.py b/src/haddock/libs/libplots.py index 8752da09de..010afbee2f 100644 --- a/src/haddock/libs/libplots.py +++ b/src/haddock/libs/libplots.py @@ -983,6 +983,9 @@ def _css_styles_for_report(offline: bool) -> str: tr:nth-child(even) { background-color: #f2f2f2 } + .js-plotly-plot .plotly .modebar svg { + display: inline; + } """ css_link = "https://cdn.jsdelivr.net/npm/@i-vresse/haddock3-ui@~0.3.0/dist/index.css" if offline: @@ -1505,4 +1508,4 @@ def make_traceback_plot(tr_subset, plot_filename): figure_height=1200, figure_width=2000 ) - return plot_filename \ No newline at end of file + return plot_filename From 805cb5d04c70207b6c81b522636d2c33553af976 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Wed, 2 Oct 2024 09:04:17 +0200 Subject: [PATCH 8/9] No need to add css js to package-data ``` pip install build python3 -m build . ``` --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0be0f65ef6..4450950a13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,4 +88,4 @@ package-dir = {"" = "src"} include-package-data = true [tool.setuptools.package-data] -haddock = ["bin/*", "lib/assets/*.css", "lib/assets/*.js"] +haddock = ["bin/*"] From 49a0acc3f802b6984dc6c9866e6ef04a6d7c1706 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Fri, 4 Oct 2024 08:18:01 +0200 Subject: [PATCH 9/9] Add test for `haddock3-analyse --ofline true` --- tests/test_cli_analyse.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/test_cli_analyse.py b/tests/test_cli_analyse.py index 8440214b83..b1dda76e9b 100644 --- a/tests/test_cli_analyse.py +++ b/tests/test_cli_analyse.py @@ -113,4 +113,38 @@ def test_zip_top_ranked(example_capri_ss): zip_top_ranked(example_capri_ss, exp_cl_ranking, "summary.tgz") assert os.path.isfile("summary.tgz") is True os.chdir(cwd) - \ No newline at end of file + + +def test_main_offline(example_capri_ss, example_capri_clt, tmp_path): + """Test cli_analyse main in offline mode.""" + # build fake run_dir + run_dir = tmp_path / "example_dir" + if os.path.isdir(run_dir): + shutil.rmtree(run_dir) + step_name = "2_caprieval" + step_dir = run_dir / step_name + os.mkdir(run_dir) + os.mkdir(step_dir) + shutil.copy(example_capri_ss, step_dir / "capri_ss.tsv") + shutil.copy(example_capri_clt, step_dir / "capri_clt.tsv") + + # run haddock3-analyse + main( + run_dir, + [2], + 5, + format=None, + scale=None, + is_cleaned=False, + inter=False, + offline=True, + ) + + # check analysis directory exists + ana_dir = run_dir / "analysis/" + assert ana_dir.is_dir() + + # check whether there are js and css files + assert (run_dir / "data/ui/report.bundle.js").is_file() + assert (run_dir / "data/ui/index.css").is_file() + assert (ana_dir / "2_caprieval_analysis/plotly_bundle.js").is_file()